Debian Codegraph @

texmf-dist/doc/latex/qworld/qworld.tex

raw
1 \documentclass{ltjsarticle}
2
3 \usepackage{qworld}
4
5 \usepackage{bookmark}
6 \usepackage{fontspec}
7 \usepackage{pdfpages}
8 \usepackage{amsmath}
9 \usepackage{amssymb}
10 \usepackage{amsfonts}
11 \usepackage{mathtools}
12 \usepackage{ascmac}
13 \usepackage{fancybox}
14 \usepackage{float}
15 \usepackage{xparse}
16 \usepackage{bbm}
17 \usepackage{mathrsfs}
18 %\numberwithin{equation}{subsection}
19
20 \usepackage{changelog}
21
22 \usepackage{framed}
23 \newenvironment{longshadowbox}{%
24 \def\FrameCommand{\fboxsep=\FrameSep \shadowbox}%
25 \MakeFramed {\FrameRestore}}%
26 {\endMakeFramed}
27
28 \usepackage{url}
29 \usepackage{hyperref}
30 \hypersetup{colorlinks=true, linkcolor=blue}
31
32 \usepackage{iitem}
33
34 \usepackage{multirow}
35
36 \usepackage{here}
37
38 \usepackage{fontawesome}
39
40 \usepackage{xspace}
41 \newcommand{\qworldname}{\texttt{QWorld}\xspace}
42 \newcommand{\tikzname}{Ti\emph{k}Z\xspace}
43 \newcommand{\texlivename}{\TeX{} \textsf{Live}\xspace}
44
45 \setcounter{tocdepth}{3}
46
47 \usepackage{listings}
48 \lstset{basicstyle=\ttfamily}
49 \usepackage[most]{tcolorbox}
50 \newtcblisting{mybox}[2][]{%
51 colback=red!5!white,
52 colframe=red!75!black,
53 fonttitle=\bfseries,
54 title=#2,
55 #1
56 }
57
58 \tcbset
59 {
60 codeinfo/.style=
61 {
62 colframe=cyan!90,
63 coltitle=cyan!60,
64 colbacktitle=black,
65 fonttitle=\small\sffamily\bfseries,
66 fontupper=\small,
67 fontlower=\small
68 },
69 exampletitleinfo/.style 2 args=
70 {
71 codeinfo,
72 title={例 \thetcbcounter #1},
73 label={#2}
74 },
75 failurecodeinfo/.style=
76 {
77 colframe=red!90,
78 coltitle=red!60,
79 colbacktitle=black,
80 fonttitle=\small\sffamily\bfseries,
81 fontupper=\small,
82 fontlower=\small
83 },
84 failureexampletitleinfo/.style 2 args=
85 {
86 failurecodeinfo,
87 title={失敗例 \thetcbcounter #1},
88 label={#2}
89 }
90 }
91 \newtcblisting{texexp}[1]
92 {
93 codeinfo,
94 #1
95 }
96 \newtcblisting[auto counter,number within=section]{codebox}[3][center lower,listing side text,righthand width=3.5cm,bicolor,colbacklower=white]
97 {
98 exampletitleinfo={#2}{#3},
99 breakable,
100 #1
101 }
102
103 \newtcblisting[use counter from=codebox,number within=section]{CODEBOX}[3][center lower,bicolor,colbacklower=white]
104 {
105 exampletitleinfo={#2}{#3},
106 breakable,
107 #1
108 }
109 \newtcolorbox[use counter from=codebox]{codeboxspec}[3][]
110 {
111 exampletitleinfo={#2}{#3},
112 breakable,
113 #1
114 }
115 \newtcblisting{texfexp}[1]
116 {
117 failurecodeinfo,
118 #1
119 }
120 \newtcblisting[auto counter,number within=section]{fcodebox}[3][center lower,listing side text,righthand width=3.5cm,bicolor,colbacklower=white]
121 {
122 failureexampletitleinfo={#2}{#3},
123 breakable,
124 #1
125 }
126
127 \newtcblisting[use counter from=fcodebox,number within=section]{FCODEBOX}[3][center lower,bicolor,colbacklower=white]
128 {
129 failureexampletitleinfo={#2}{#3},
130 breakable,
131 #1
132 }
133 \newtcolorbox[use counter from=fcodebox]{fcodeboxspec}[3][]
134 {
135 failureexampletitleinfo={#2}{#3},
136 breakable,
137 #1
138 }
139
140 \usepackage{xcolor}
141 \NewDocumentCommand{\showcmd}{O{\textbackslash} m O{black}}{%
142 \leavevmode%
143 \ifthenelse{\equal{#3}{new}}{%
144 \textcolor{green!50!black}{\texttt{#1#2}}%
145 }{%
146 \ifthenelse{\equal{#3}{old}}{%
147 \textcolor{red}{\texttt{#1#2}}%
148 }{%
149 \textcolor{#3}{\texttt{#1#2}}%
150 }%
151 }%
152 }
153
154 \begin{document}
155 % \title{
156 % \Huge \textbf{\qworldname}\\[4pt]
157 % \scriptsize\texttt{Version 1.1.1} \\[4pt]
158 % }
159 % \author{
160 % \textbf{新名 亮太} \\[4pt]
161 % }
162 % \date{\today}
163 % \maketitle
164
165 \begin{titlepage}
166 \centering
167 \vspace*{2.5cm}
168
169 % パッケージ名とバージョン
170 {\Huge\bfseries The QWorld\par}
171 \vspace{1ex}
172
173 % {\large A \LaTeX{} package for diagrammatic reasoning\\
174 % in monoidal categories and categorical quantum mechanics\par}
175
176 {\large モノイダル圏および量子力学のためのストリング図式生成\par}
177 \vspace{2ex}
178
179 {\normalsize\ttfamily v1.1.2\par}
180
181 \vspace{3cm}
182
183 % 著者情報
184 {\large\bfseries 新名亮太\par}
185 \vspace{1ex}
186 \href{[email protected]}
187 {\normalsize\ttfamily [email protected]}
188
189 \vfill
190
191 % 日付
192 {\today}
193 \end{titlepage}
194
195 \begin{abstract}
196 \qworldname は, モノイダル圏における図式計算を直感的かつ効率的に描画するために設計された\LaTeX パッケージである.
197 特に, 圏論的手法が重要な役割を果たす量子論, トポロジカル量子計算, 及び関連分野における図式的推論の可視化を支援する.
198 本パッケージは\tikzname\cite{tikz-manual} を基盤としており, シンプルなコマンドで複雑な図式を容易に描画できる.
199 \end{abstract}
200
201 \tableofcontents
202
203 \section{導入}
204 本稿では, \qworldname パッケージのインストール方法, 基本的な使用法, 応用例を体系的に解説する.
205 \qworldname は, モノイダル圏に基づく図式言語の組版に特化した\LaTeX パッケージであり,
206 モノイダル圏, フロベニウス構造, 組紐, ホップ代数, シンメトリー, 双対性, ピボタル構造, ダガーなど, 多岐にわたる圏論的概念を図式表現するための直感的なコマンドセットを提供する.
207
208 \section{基本的な使い方}
209 \subsection{基本要素}
210 \qworldname パッケージのの最も基本的なコマンドを以下に示す.
211 これらは図式を描画するための基礎となる.
212 \begin{itemize}
213 \item \showcmd{q}: 図の素子を配置するためのキャンバス.
214 \item \showcmd{qbox}: ボックス\q[scale=0.5]{\qbox}の描画.
215 \item \showcmd{qwire}: ワイヤー\q[scale=0.5]{\qwire}の描画.
216 \item \showcmd{qcirc}: 合成.
217 \end{itemize}
218 これらのコマンドは, キャンバスである\verb|\q{...}|内に記述する.
219 例えば\verb|\q{\qbox}|と記述すると, ボックス\q[scale=0.5]{\qbox}が描画される.\par
220 \(\q[scale=0.5]{\qbox}\)と\(\q[scale=0.5]{\qbox}\)を合成するためには, \verb|\qcirc|を使用する.
221 これは数学における合成\(g\circ f\) (\verb|\(g\circ f\)|) と似ている.
222 \begin{codebox}{}{Ex:7812973891217}
223 \q{ \qbox \qcirc \qbox }
224 \end{codebox}
225 また, \verb|\qbox| を並置すると, 描画結果でもボックス\(\q[scale=0.5]{\qbox}\)が横に並ぶ:
226 \begin{codebox}{}{boxs2}
227 \q{ \qbox \qbox \qbox }
228 \end{codebox}
229 \verb|\qcirc| を用いて複数のボックスを合成することも可能である:
230 \begin{codebox}{}{boxsbr}
231 \q
232 {
233 \qbox \qbox \qbox
234 \qcirc
235 \qbox \qbox \qbox
236 }
237 \end{codebox}
238 なお, \verb|\n|は\verb|\qcirc|と同義である:
239 \begin{codebox}{}{boxsn}
240 \q
241 {
242 \qbox \qbox \qbox \n
243 \qbox \qbox \qbox
244 }
245 \end{codebox}
246 \begin{codebox}{}{ex:hopflink}
247 \q{
248 \qcaprev \qcap \n
249 \qwire \qbraid \qwire \n
250 \qwire \qbraid \qwire \n
251 \qcup \qcuprev
252 }
253 \end{codebox}
254 \verb|\qcaprev|は\q[scale=0.6]{\qcaprev}を,
255 \verb|\qcap|は\q[scale=0.6]{\qcap}を,
256 \verb|\qwire|は\q[scale=0.5]{\qwire}を,
257 \verb|\qbraid|は\q[scale=0.5]{\qbraid}を,
258 \verb|\qcup|は\q[scale=0.6]{\qcup}を,
259 \verb|\qcuprev|は\q[scale=0.6]{\qcuprev}を, 各々描画する.
260 全体として, コマンドの配置の通りに描画されていることが分かる.\par
261 \subsection{数式モード}
262 図式言語を含んだ数式を記述する場合は, 数式モードを使用する.
263 \begin{CODEBOX}{}{IntroEx}
264 \[
265 \operatorname{Tr}\left(
266 \q{
267 \qbraid\n
268 \qbraid
269 }
270 \right)
271 =\q{
272 \qcap \qcap \n
273 \qwire \qbraidinv \qwire \n
274 \qwire \qbraidinv \qwire \n
275 \qcuprev \qcuprev
276 }
277 \]
278 \end{CODEBOX}
279
280 \subsection{インストール}
281 \qworldname パッケージのスタイルファイル\showcmd[]{qworld.sty}は, \href{https://ctan.org/pkg/qworld}{CTAN}上の以下のページから入手可能である:
282 \begin{center}
283 \url{https://ctan.org/pkg/qworld}
284 \end{center}
285 ダウンロードしたファイルを\TeX のパッケージディレクトリに配置し,
286 プリアンブルに以下を記述することで使用可能となる:
287 \begin{verbatim}
288 \usepackage{qworld}
289 \end{verbatim}
290
291 パッケージが\TeX ディストリビューションに含まれている場合は, \showcmd[]{tlmgr}や\showcmd[]{MiKTeX Console}などを利用してインストールすることもできる.
292
293 \paragraph{依存関係}
294 依存パッケージは以下の通りである:
295 \begin{itemize}
296 \item \tikzname
297 \iitem \showcmd[]{cd}
298 \iitem \showcmd[]{positioning}
299 \iitem \showcmd[]{arrows}
300 \iitem \showcmd[]{arrows.meta}
301 \iitem \showcmd[]{calc}
302 \iitem \showcmd[]{intersections}
303 \iitem \showcmd[]{shapes.symbols}
304 \iitem \showcmd[]{shapes.geometric}
305 \iitem \showcmd[]{shapes.misc}
306 \iitem \showcmd[]{decorations.pathreplacing}
307 \iitem \showcmd[]{decorations.markings}
308 \iitem \showcmd[]{decorations.pathmorphing}
309 \item \showcmd[]{pgffor}
310 \item \showcmd[]{ifthen}
311 \item \showcmd[]{xparse}
312 \item \showcmd[]{xfp}
313 \item \showcmd[]{xstring}
314 \end{itemize}
315 これらのパッケージは\texlivename ディストリビューションに標準で含まれており, 特別な手間をかける必要はない.
316 \section{基本的なカスタマイズ}
317 本節では, \qworldname のコマンドをカスタマイズする方法を解説する.
318 \subsection{識別番号}
319
320 \verb|\q{...}|内に配置された全てのコマンドには, 実行順に基づいて自動的に固有の識別番号が割り当てられる.
321 例えば, 先の例 \ref{boxsn} では各\verb|\qbox|に番号が振られる:
322 \[\q{\qloop[2]{\qloop[3]{\qbox[show id={true}]}\n}}\]
323 詳細は, \pageref{subsec:showid}ページの\ref{subsec:showid}節を参照せよ.
324
325 \subsection{バウンディングボックス}
326
327 \[\q{
328 \qcaprev \qcap \n
329 \qwire \qbraid \qwire \n
330 \qwire \qbraid \qwire \n
331 \qcup \qcuprev
332 \qbb[red][1,2]
333 \bbsymbol{Measure}
334 \bbsymbol[W]{Output}[left]
335 \bbsymbol[NW]{Computation}[above left]
336 \bbsymbol[NE]{Physics}[above right]
337 \qbb[yellow][3,5,6,8]
338 \bbsymbol{Braid}
339 \bbsymbol[W]{Compute}[left]
340 \qbb[cyan][9,10]
341 \bbsymbol{Create}
342 \bbsymbol[W]{Initialize}[left]
343 }\]
344
345 各素子には, バウンディングボックスが付随する.
346 以下に例を示す:
347 \begin{itemize}
348 \item \q{\qcaprev}のバウンディングボックスを可視化すると\q{\qcaprev\qbball}.
349 \item \q{\qbraid}のバウンディングボックスを可視化すると\q{\qbraid\qbball}.
350 \item \q{\qwire}のバウンディングボックスを可視化すると\q{\qwire\qbball}.
351 \item \q{\qcuprev}のバウンディングボックスを可視化すると\q{\qcuprev\qbball}.
352 \end{itemize}
353 バウンディングボックスを可視化するコマンドと,
354 可視化したバウンディングボックス近辺にテキストを置くコマンドは次の通りである:
355 \begin{itemize}
356 \item 可視化
357 \iitem \showcmd{qbb}: 特定の素子のバウンディングボックスを表示.
358 \iitem \showcmd{qbball}: 全ての素子のバウンディングボックスを一度に表示.
359 \iitem \showcmd{qBBall}: キャンバス全体を囲むバウンディングボックスをを表示.
360 \item テキストを置く
361 \iitem \showcmd{bbsymbol}: バウンディングボックスにテキストを配置.
362 \end{itemize}
363
364 \begin{verbatim}
365 \qbb[<色>][<ID列>]
366 \end{verbatim}
367 \begin{itemize}
368 \item 第一引数 (オプション): 色を指定. 未指定の場合は無色.
369 \item 第二引数: 対象となる素子の識別番号のリストを指定し, それらを含むバウンディングボックスを表示.
370 \end{itemize}
371 \begin{codebox}{}{Ex:7812973891220}
372 \q{\qbox\qbb[1]}
373 \end{codebox}
374 \begin{codebox}{}{ex:78129738912270454}
375 \q{
376 \qcaprev \qcap \n
377 \qwire \qbraid \qwire \n
378 \qwire \qbraid \qwire \n
379 \qcup \qcuprev
380 \qbb[4,7]
381 }
382 \end{codebox}
383 \begin{CODEBOX}{}{Ex:7812973891221}
384 \q{\qbox\qbox\qbox\qbox\qbox\qbox\qbb[yellow][2,...,5]}
385 \end{CODEBOX}
386 \begin{codebox}{}{Ex:74839722}
387 \q
388 {
389 \qbox\qbox\qbox\n
390 \qbox\qbox\qbox
391 \qbb[green][2,5]
392 }
393 \end{codebox}
394 \begin{codebox}{}{Ex:7812973891218}
395 \q{
396 \qcaprev \qcap \n
397 \qwire \qbraid \qwire \n
398 \qwire \qbraid \qwire \n
399 \qcup \qcuprev
400 \qbb[blue][4,7]
401 }
402 \end{codebox}
403 \begin{verbatim}
404 \qbball[<色>]
405 \end{verbatim}
406 複数 (一個でも良いが) のバウンディングボックスを一度に可視化する.
407 \begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{Ex:78129738912270511}
408 \q{
409 \qcaprev \qcap \n
410 \qwire \qbraid \qwire \n
411 \qwire \qbraid \qwire \n
412 \qcup \qcuprev
413 \qbball
414 }
415 \end{codebox}
416 各素子のバウンディングボックスが重なることなく組み合っていることが判る.
417 \qworldname パッケージは, 図式描画に伴う\textbf{細かく面倒な座標設定の多くを省略できる}.
418
419 \begin{verbatim}
420 \qBBall[<色>]
421 \end{verbatim}
422 キャンバス内の全素子を囲むバウンディングボックスを表示する.
423 \begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{Ex:7812973891216}
424 \q{
425 \qcaprev \qcap \n
426 \qwire \qbraid \qwire \n
427 \qwire \qbraid \qwire \n
428 \qcup \qcuprev
429 \qBBall
430 }
431 \end{codebox}
432 \begin{verbatim}
433 \bbsymbol[<方角>]{<text>}[<オプション>]
434 \end{verbatim}
435 直前のバウンディングボックスにテキストを配置する.
436 \begin{itemize}
437 \item 第一引数 (オプション): \showcmd[]{N} (北), \showcmd[]{S} (南), \showcmd[]{E} (東), \showcmd[]{S} (西), \showcmd[]{NW} (北西), \showcmd[]{NE} (北東), \showcmd[]{SE} (南東), \showcmd[]{SW} (南西) のいずれかを指定. デフォルトは\showcmd[]{E}.
438 \item 第二引数: 配置するテキスト.
439 \item 第三引数 (オプション): 位置調整 (例: \showcmd[]{above}, \showcmd[]{below}, \showcmd[]{left}, \showcmd[]{right}). デフォルトは\showcmd[]{right}.
440 \end{itemize}
441 \begin{CODEBOX}{}{Ex:bbsymbol}
442 \q[scale=5]{
443 \qbox
444 \qbb[1]
445 \bbsymbol{東 (デフォルト)}
446 \bbsymbol[W]{西}[left]
447 \bbsymbol[N]{北}[above]
448 \bbsymbol[S]{南}[below]
449 \bbsymbol[NE]{北東}[above right]
450 \bbsymbol[NW]{北西}[above left]
451 \bbsymbol[SE]{南東}[below right]
452 \bbsymbol[SW]{南西}[below left]
453 \bbsymbol[C]{重心}[]
454 }
455 \end{CODEBOX}
456 \begin{CODEBOX}{}{Ex:7812973891215}
457 \q
458 {
459 \qcaprev \qcap \n
460 \qwire \qbraid \qwire \n
461 \qwire \qbraid \qwire \n
462 \qcup \qcuprev
463 \qbb[red][1,2]
464 \bbsymbol{Measure}
465 \bbsymbol[W]{Output}[left]
466 \bbsymbol[NW]{Computation}[above left]
467 \bbsymbol[NE]{Physics}[above right]
468 \qbb[yellow][3,5,6,8]
469 \bbsymbol{Braid}
470 \bbsymbol[W]{Compute}[left]
471 \qbb[cyan][9,10]
472 \bbsymbol{Create}
473 \bbsymbol[W]{Initialize}[left]
474 }
475 \end{CODEBOX}
476 \subsection{ボックスのカスタマイズ}
477 \label{subsec:boxcustomization}
478 キーを使い, ボックスの経線の数や配置を調整できる.
479 例えば以下のようなボックスが描画可能である:
480 \begin{itemize}
481 \item \(\q[scale=0.5]{\qbox[p=20,hlen=3]}\)
482 \item \(\q[scale=0.5]{\qbox[p=10,N={1,2,3,8,9,10},S={4,5,6,7},hlen=3]}\)
483 \end{itemize}
484 これらのキーはワイヤー以外の多くの素子にも適用可能である.
485 主要なキーは以下の通り:
486 \begin{itemize}
487 \item \showcmd[]{n}
488 \iitem ボックス\(\q[scale=0.5]{\qbox[p=2, P={}]}\)の北縁において経線\q[scale=0.31]{\qwire}を生やすことができる点 (このような点を\showcmd[]{n}端子と呼ぶこととする) の数.
489 \iitem 例えば \showcmd[]{n=3}とすれば, ボックスの北縁に \(3\) 点等間隔に打つことができる.
490 \iitem デフォルト値は \showcmd[]{n=1}.
491 \iitem \showcmd[]{n}端子を最北端まで垂直移動させた点を\showcmd[]{N}端子と呼ぶ.
492 \iitem \showcmd[]{n}端子及び\showcmd[]{N}端子は西 (左) から順に\(1,2,...\)と添え字付けられる.
493 \iitem \(i\)番目の\showcmd[]{n}端子に経線を生やすとは, \(i\)番目の\showcmd[]{n}端子と\(i\)番目の\showcmd[]{N}端子を線分で結ぶことをいう.
494 \item \showcmd[]{N}
495 \iitem 経線を実際に生やす\showcmd[]{n}端子の添え字の集合.
496 \iitem 例えば \showcmd[]{n=3}とした上で\showcmd[]{N=\{2\}}とすれば, \(3\)点のうち\(2\)番目の\showcmd[]{n}端子に経線を生やすことができる.
497 \iitem \showcmd[]{n}が未指定で, \showcmd[]{N}が指定されているときは, 自動で \(\showcmd[]{n}\coloneq\max\showcmd[]{N}\) となる.
498 \iitem \showcmd[]{N}が未指定で, \showcmd[]{n}が指定されているときは, 自動で \(\showcmd[]{N}\coloneq\{1,...,\showcmd[]{n}\}\) となる.
499 \iitem \showcmd[]{n}端子から実際に生えた経線の最北端を出力点, あるいは\showcmd[]{O}端子と呼ぶこととする.
500 \item \showcmd[]{s}
501 \iitem ボックスの南縁において経線を生やすことができる点 (このような点を\showcmd[]{s}端子と呼ぶこととする) の数.
502 \iitem 例えば \showcmd[]{s=4}とすれば, ボックスの南縁に\(4\)点等間隔に打つことができる.
503 \iitem デフォルト値は\showcmd[]{s=1}.
504 \iitem \showcmd[]{s}端子を最南端まで垂直移動させた点を\showcmd[]{S}端子と呼ぶ.
505 \iitem \showcmd[]{s}端子及び\showcmd[]{S}端子は西 (左) から順に\(1,2,...\)と添え字付けられる.
506 \iitem \(i\)番目の\showcmd[]{s}端子に経線を生やすとは, \(i\)番目の\showcmd[]{s}端子と\(i\)番目の\showcmd[]{S}端子を線分で結ぶことをいう.
507 \item \showcmd[]{S}
508 \iitem 経線を実際に生やす\showcmd[]{s}端子の添え字の集合.
509 \iitem 例えば \showcmd[]{s=4}とした上で \showcmd[]{S=\{1,4\}} とすれば, \(4\)点のうち\(1\)番目と\(4\)番目の点に経線を生やすことができる.
510 \iitem \showcmd[]{s}が未指定で, \showcmd[]{S}が指定されているときは, 自動で \(\showcmd[]{s}\coloneq\max \showcmd[]{S}\) となる.
511 \iitem \showcmd[]{S}が未指定で, \showcmd[]{s}が指定されているときは, 自動で \(\showcmd[]{S}\coloneq\{1,...,\showcmd[]{s}\}\) となる.
512 \iitem \showcmd[]{s}端子から実際に生えた経線の最南端を入力点, あるいは\showcmd[]{I}端子と呼ぶこととする.
513 \item \showcmd[]{hlen}
514 \iitem 水平方向のバウンディングボックスの長さ.
515 \iitem 例えば\showcmd[]{hlen=2}とすれば, 水平方向のバウンディングボックスの長さが\(2\)となる.
516 \iitem 唯一つの例外を除いて, 最西端の経線とバウンディングボックスの境界線との距離, 最東端の経線とバウンディングボックスの境界線との距離はともに\(\fpeval{0.5}\)である.
517 \iitem \showcmd[]{hlen}が未指定であるとき, \showcmd[]{n}端子及び\showcmd[]{s}端子は, 間隔を\(1\)に保って並べられる.
518 \iitem \showcmd[]{hlen}が指定されているとき, \showcmd[]{n}端子及び\showcmd[]{s}端子は, 長さ\(\showcmd[]{hlen}-1\)の区間を等間隔に並べられる. このときの端子の間隔は\showcmd[]{hlen}及び端子の数に依存する.
519 \iiitem 端子の数が\(1\)つであるときは, 区間の中心に置かれる. このとき, \(\showcmd[]{hlen}>1\) であるならば, 最西端の経線とバウンディングボックスの境界線との距離, 及び最東端の経線とバウンディングボックスの境界線との距離はともに\(\frac{\showcmd[]{hlen}}{2}>\fpeval{0.5}\)である.
520 \item \showcmd[]{vlen}
521 \iitem 垂直方向のバウンディングボックスの長さ (高さ).
522 \iitem デフォルト値は \showcmd[]{vlen=1}.
523 \item \showcmd[]{id}
524 \iitem ボックスの識別子.
525 \iitem 例えば\showcmd[]{id=ID}とすれば, ここまで登場した様々な点に次のような名前が自動的に付けられる:
526 \iiitem (西から数えて) \(i\)番目の\showcmd[]{n}端子: (n-\(i\)-ID)
527 \iiitem \(i\)番目の\showcmd[]{s}端子: (s-\(i\)-ID)
528 \iiitem \(i\)番目の\showcmd[]{n}端子をボックスの北縁へ垂直移動させた点: (N-\(i\)-ID)
529 \iiitem \(i\)番目の\showcmd[]{s}端子をボックスの南縁へ垂直移動させた点: (S-\(i\)-ID)
530 \iiitem バウンディングボックスの最北西端: (NW-ID)
531 \iiitem バウンディングボックスの最北東端: (NE-ID)
532 \iiitem バウンディングボックスの最南西端: (SW-ID)
533 \iiitem バウンディングボックスの最南東端: (SE-ID)
534 \iiitem バウンディングボックスの最北端: (N-ID)
535 \iiitem バウンディングボックスの最南端: (S-ID)
536 \iiitem バウンディングボックスの最西端: (W-ID)
537 \iiitem バウンディングボックスの最東端: (E-ID)
538 \iiitem バウンディングボックスの重心: (C-ID)
539 \iiitem ボックスの最北西端: (nw-ID)
540 \iiitem ボックスの最北東端: (ne-ID)
541 \iiitem ボックスの最南西端: (sw-ID)
542 \iiitem ボックスの最南東端: (se-ID)
543 \iiitem ボックスの最北端: (n-ID)
544 \iiitem ボックスの最南端: (s-ID)
545 \iiitem ボックスの最西端: (w-ID)
546 \iiitem ボックスの最東端: (e-ID)
547 \iiitem \(i\) 番目の出力点: (O-\(i\)-ID)
548 \iiitem \(i\) 番目の入力点: (I-\(i\)-ID)
549 \iitem 指定の有無にかかわらず, \showcmd{q\{...\}}内に置かれた各コマンドには識別番号が振られている. 各々\showcmd[]{ID}部分をその番号に置き換えても同じ点を表す. 詳細は \ref{subsec:showid} 節を確認されたし.
550 \item \showcmd[]{p}, \showcmd[]{P}
551 \iitem 正整数\showcmd[]{k}に対して, \showcmd[]{p=k}は\showcmd[]{n=k}, \showcmd[]{s=k}を意味する.
552 \iitem 正整数の有限集合\showcmd[]{K}に対して, \showcmd[]{P=K}は\showcmd[]{N=K}, \showcmd[]{S=K}を意味する.
553 \item \showcmd[]{name}
554 \iitem \showcmd[]{name=<text>} により, ボックスの重心に\showcmd[]{<text>}が置かれる.
555 \end{itemize}
556 \begin{CODEBOX}{}{ex:boxpoints}
557 \def\pradius{0.4pt}
558 \q[scale=5]
559 {
560 \qbox
561 [
562 n=3,N={2},
563 s=4,S={1,4},
564 hlen=2,
565 vlen=2,
566 id={ID},
567 name={重心 (C-ID)}
568 ]\n
569 \qbb[ID]
570 \node [above] at (NE-ID) {NE-ID};
571 \node [above] at (NW-ID) {NW-ID};
572 \node [below] at (SE-ID) {SE-ID};
573 \node [below] at (SW-ID) {SW-ID};
574 \fill (NE-ID) circle (\pradius);
575 \fill (NW-ID) circle (\pradius);
576 \fill (SE-ID) circle (\pradius);
577 \fill (SW-ID) circle (\pradius);
578 \node [above] at (ne-ID) {ne-ID};
579 \node [above] at (nw-ID) {nw-ID};
580 \node [below] at (se-ID) {se-ID};
581 \node [below] at (sw-ID) {sw-ID};
582 \fill (ne-ID) circle (\pradius);
583 \fill (nw-ID) circle (\pradius);
584 \fill (se-ID) circle (\pradius);
585 \fill (sw-ID) circle (\pradius);
586 \foreach\i in {1,...,3}
587 {
588 \symboln[\i]{n-\i-ID}[below]
589 \fill (n-\i-ID) circle (\pradius);
590 \symbolN[\i]{N-\i-ID}
591 \fill (N-\i-ID) circle (\pradius);
592 }
593 \foreach\i in {1,...,4}
594 {
595 \symbols[\i]{s-\i-ID}[above]
596 \fill (s-\i-ID) circle (\pradius);
597 \symbolS[\i]{S-\i-ID}[below]
598 \fill (S-\i-ID) circle (\pradius);
599 }
600 \draw[line width=0.2pt] (NW-ID)
601 to [bend left=60] node [fill=white, midway] {hlen} (NE-ID);
602 \draw[line width=0.2pt] (NW-ID)
603 to [bend right=60] node [fill=white, midway] {vlen} (SW-ID);
604 \draw [red, <->] (C-ID -| W-ID)
605 -- node [midway, auto, font=\footnotesize] {0.5} (C-ID -| S-1-ID);
606 \draw [red, <->] (C-ID -| S-4-ID)
607 -- node [midway, auto, font=\footnotesize] {0.5} (C-ID -| E-ID);
608 \qwire[arrowtype={loosely dotted}, dom={s-1-ID}, cod={n-1-ID}]
609 \qwire[arrowtype={loosely dotted}, dom={s-4-ID}, cod={n-3-ID}]
610 \node (O1prime) at ([shift={(0.25,0.25)}]O-1-ID){O-1-ID};
611 \draw[->,red] (O1prime) to ([shift={(0.05,0.05)}]O-1-ID);
612 \node (I1prime) at ([shift={(0.5,-0.5)}]I-1-ID){I-1-ID};
613 \node (I2prime) at ([shift={(0.5,-0.5)}]I-2-ID) {I-2-ID};
614 \draw[->,red](I1prime) to ([shift={(0.05,-0.05)}]I-1-ID);
615 \draw[->,red](I2prime) to ([shift={(0.05,-0.05)}]I-2-ID);
616 }
617 \end{CODEBOX}
618 \verb|\qwire|の\verb|arrowtype|キーと\verb|dom|, \verb|cod|キーは
619 \pageref{subsec:wirecustomization}ページの\ref{subsec:wirecustomization}節にて説明する.
620 \paragraph{ラベル (\showcmd{symbol})}
621 \begin{verbatim}
622 \symbolI[<番号>]{<label>}[<オプション>]
623 \end{verbatim}
624 例えば, \verb|\symbolI[2]{text}[below right, id=<ID>]| により,
625 \verb|\q{\qbox[p=3, id=ID]}| (\(\q[scale=0.5]{\qbox[p=3, id=ID]}\)) の\(2\)番目の入力点 (I-2-ID) の右下に``text''が置かれる.
626 番号とオプションの指定のないときは, デフォルト値\(1\), below, \verb|id=<直前のもの>| が各々適用される.
627 他にもラベル表示コマンドとして,
628 \begin{verbatim}
629 \symbolS[<番号>]{<label>}[<オプション>]
630 \end{verbatim}
631 \begin{verbatim}
632 \symbols[<番号>]{<label>}[<オプション>]
633 \end{verbatim}
634 \begin{verbatim}
635 \symbolO[<番号>]{<label>}[<オプション>]
636 \end{verbatim}
637 \begin{verbatim}
638 \symbolN[<番号>]{<label>}[<オプション>]
639 \end{verbatim}
640 \begin{verbatim}
641 \symboln[<番号>]{<label>}[<オプション>]
642 \end{verbatim}
643 がある. \verb|\symbolS|, \verb|\symbols|はそれぞれ点 (S-\(i\)-ID), (s-\(i\)-ID) に\textless label\textgreater を置く.
644 番号\(i\)のデフォルト値は \(1\), オプションのデフォルト値は below である.
645 \verb|\symbolO|, \verb|\symbolN|, \verb|\symboln| はそれぞれ点 (O-\(i\)-ID), (N-\(i\)-ID), (n-\(i\)-ID) に\textless label\textgreater を置く.
646 番号\(i\)のデフォルト値は \(1\), オプションのデフォルト値は above である.
647 \begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{Ex:7812973891211}
648 \q{
649 \qbox[p=5, S={1,4,5}, id=ID]
650 \symbolO{A}
651 \symbolN[3]{B}
652 \symboln[5]{C}[below left]
653 \symbolS[2]{D}
654 \symbols[3]{E}
655 \symbolI[2]{F}
656 \symbolI[3]{G}[below right]
657 }
658 \end{codebox}
659 \begin{CODEBOX}{}{Ex:7812973891210}
660 \q{
661 \qbox[p=10,N={1,2,5,6,9,10}, id=ID]
662 \foreach\i in {1,...,10}
663 {
664 \symbolI[\i]{\(x_{\i}\)}
665 }
666 \foreach\j in {1,...,6}
667 {
668 \symbolO[\j]{\(y_{\j}\)}
669 }
670 }
671 \end{CODEBOX}
672
673 \subsection{繰り返し}
674 \label{subsub:forloop}
675 \begin{verbatim}
676 \qloop[<回数>]{<コマンド>}
677 \end{verbatim}
678 \verb|\qloop|コマンドを用いれば, 指定した回数だけコマンドを繰り返せる:
679 \begin{CODEBOX}{}{Ex:7812973891205}
680 \q{ \qloop[10]{\qbox} }
681 \end{CODEBOX}
682 \verb|\qloop|コマンドは\verb|\q|外でも使用可能である:
683 \begin{CODEBOX}[bicolor,colbacklower=white]{}{Ex:78129738912220930}
684 結論だけ, 書く.\par
685 \qloop[20]{失敗した}\par
686 あたしは\qloop[10]{失敗した}
687 \end{CODEBOX}
688 \subsection{識別番号の表示}
689 \label{subsec:showid}
690 \verb|\q{...}| 内のコマンドには自動的に識別番号が付与される.
691 \showcmd[]{show id=true}を指定すると, それらが表示される.
692 \begin{CODEBOX}{}{Ex:7812973891203}
693 \q{
694 \qbox[show id={true}] \qbox[show id={true}] \qbox[show id={true}]\n
695 \qbox[show id={true}] \qbox[show id={true}] \qbox[show id={true}]
696 }
697 \end{CODEBOX}
698 \begin{CODEBOX}{}{Ex:7812973891202}
699 \q
700 {
701 \qloop[10]
702 {
703 \qloop[10]
704 {
705 \qbox[show id={true}]
706 }\n
707 }\n
708 }
709 \end{CODEBOX}
710
711 \subsection{色}
712 \label{subsec:color}
713 ボックスに三種類の色属性を指定できる:
714 \begin{itemize}
715 \item \showcmd[]{color}
716 \iitem ボックス内部の色, 例えば\showcmd[]{color=green}により\q[scale=0.5]{\qbox[color={green}]}
717 \item \showcmd[]{frame color}
718 \iitem ボックスの枠の色, 例えば\showcmd[]{frame color=cyan}により\q[scale=0.5]{\qbox[frame color={cyan}]}
719 \item \showcmd[]{morphism color}
720 \iitem ボックス内の射の色, 例えば\showcmd[]{morphism colon=red}により\q[scale=0.5]{\qbox[morphism color={red}, name={\(f\)}]}
721 \end{itemize}
722 \begin{CODEBOX}{}{Ex:74839759}
723 \q
724 {
725 \qbox
726 [
727 name={\(f\)},
728 color=red,
729 frame color={green!50!black},
730 morphism color=yellow
731 ]
732 }
733 \end{CODEBOX}
734
735 \subsubsection*{組紐, シンメトリー, キャップ, カップの色指定}
736 \label{subsubsec:tanglecolor}
737 組紐, シンメトリー, キャップ, カップといった一部の射は, 図式上では箱ではなく曲線として描画される.
738 これらには明確な内部領域が存在せず, 射のラベルも通常付けないため, \showcmd[]{color}及び\showcmd[]{morphism color}は適用されない.
739
740 \paragraph{\showcmd[]{N}, \showcmd[]{S}, 等差数列}
741 \qworldname は\showcmd[]{pgffor}パッケージをロードしているため, リストに対して\verb|...|を用いた省略記法が使用できる:
742 \begin{itemize}
743 \item \(1,...,10\): 公差\(1\)の等差数列
744 \item \(1,3,...,11\): 最初の二項に基づいた公差の等差数列
745 \end{itemize}
746 \begin{CODEBOX}{}{Ex:74839758}
747 \q{
748 \qbox[N={1,...,10}, S={1,3,...,11}]
749 }
750 \end{CODEBOX}
751 \begin{CODEBOX}{}{Ex:74839757}
752 \q{
753 \qbox[N={1,...,4,6,8,...,20}, S={1,...,20}, hlen=10]
754 }
755 \end{CODEBOX}
756 \begin{CODEBOX}{}{Ex:74839756}
757 \q{
758 \qbox[N={1,...,4,7,10,...,19,20,21,...,25}, S={1,...,25}, hlen=10]
759 }
760 \end{CODEBOX}
761 \subsection{相対座標}
762 素子の位置座標を相対的に指定するコマンドである.
763 なお, \(x\), \(y\) は整数である必要はなく, \verb|2^1.5|や\verb|cos(pi)|, \verb|sqrt(2)|などの\verb|\fpeval|の評価可能式であればよい.
764 \begin{itemize}
765 \item \showcmd{qmv[\(x\),\(y\)]}
766 \iitem (\(x\), \(y\)) だけ並行移動する.
767 \iitem デフォルトで\(x=y=0\).
768 \item \showcmd{n[\(y\)]}
769 \iitem \(y\)だけ垂直降下し (\(Y\mapsto Y-y\)), X座標を\(0\)にする.
770 \iitem デフォルトで \(y=1\) であり, 改行のような挙動をみせる.
771 \item \showcmd{qspace[\(x\)]}
772 \iitem \(x\) だけ水平移動する.
773 \iitem デフォルトで \(x=1\) であり, スペースキーのような挙動をみせる.
774 \iitem \showcmd{qmv[\(x\),0]} と同義である.
775 \item \showcmd{qreset[\(x\),\(y\)]}
776 \iitem 点 (\(x\),\(y\)) に移動する.
777 \end{itemize}
778 \[\q[scale=2.35]{
779 \fill[blue] (qworldat) circle (1pt);
780 \coordinate (I) at (qworldat);
781 \qbox
782 \fill[blue] (qworldat) circle (1pt);
783 \coordinate (II) at (qworldat);
784 \n
785 \fill[blue] (qworldat) circle (1pt);
786 \coordinate (III) at (qworldat);
787 \qspace
788 \fill[blue] (qworldat) circle (1pt);
789 \coordinate (IV) at (qworldat);
790 \qspace[0.5]
791 \fill[blue] (qworldat) circle (1pt);
792 \coordinate (V) at (qworldat);
793 \n[2]
794 \fill[blue] (qworldat) circle (1pt);
795 \coordinate (VI) at (qworldat);
796 \qmv[-2,-1]
797 \fill[blue] (qworldat) circle (1pt);
798 \coordinate (VII) at (qworldat);
799 \n
800 \fill[blue] (qworldat) circle (1pt);
801 \coordinate (VIII) at (qworldat);
802 \qspace[-3]
803 \fill[blue] (qworldat) circle (1pt);
804 \coordinate (IX) at (qworldat);
805 \qreset
806 \fill[blue] (qworldat) circle (1pt);
807 \coordinate (X) at (qworldat);
808 \qreset[-2,1]
809 \fill[blue] (qworldat) circle (1pt);
810 \coordinate (XI) at (qworldat);
811 \qbball
812 \qwireup[dom={I}, cod={II},
813 label={自動更新}, label side={below},
814 label at={midway}, color=cyan]
815 \qwireup[dom={II},cod={III},
816 label={\showcmd{n}},
817 label side={below}, color=cyan]
818 \qwireup[dom={III},cod={IV},
819 label={\showcmd{qspace}},
820 label side={below}, color=cyan]
821 \qwireup[dom={IV},cod={V},
822 label={\showcmd{qspace[0.5]}},
823 label side={above}, color=cyan]
824 \qwireup[dom={V},cod={VI},
825 label={\showcmd{n[2]}},color=cyan]
826 \qwireup[dom={VI},cod={VII},
827 label={\showcmd{qmv[-2,-1]}},color=cyan]
828 \qwireup[dom={VII},cod={VIII},
829 label={\showcmd{n}},color=cyan]
830 \qwireup[dom={VIII},cod={IX},
831 label={\showcmd{qspace[-3]}},
832 label side={below},color=cyan]
833 \qwireup[dom={IX},cod={X},
834 label={\showcmd{qreset}},
835 label side=left, color=cyan]
836 \qwireup[dom={X},cod={XI},
837 label={\showcmd{qreset[-2,1]}},
838 label side=left,
839 label at={near start},
840 color=cyan]
841 \draw[help lines] (-4,-6) grid (2,2);
842 }\]
843
844 \subsection{絶対座標}
845 \showcmd[]{at}キーを用いれば, 絶対座標で位置を指定できる.
846 \verb|\q{\qbox[at={2,3}]}|は\verb|\q{\qreset[2,3]\qbox}|と同義である.
847 \begin{CODEBOX}{絶対座標}{Ex:74839754}
848 \q{
849 \coordinate (a) at (0,{\fpeval{2*sqrt(3)}});
850 \qbox[at=a]
851 \qbox[at={-2,0}]
852 \qbox[at={2,0}]
853 \fill[red] (a) circle (2pt);
854 \fill[red] (-2,0) circle (2pt);
855 \fill[red] (2,0) circle (2pt);
856 \node[below left] at (a) {a};
857 \node[below left] at (-2,0) {(-2,0)};
858 \node[below left] at (2,0) {(2,0)};
859 }
860 \end{CODEBOX}
861 \TeX 言語はチューリング完全である\footnote{例えば, チューリングマシンをシミュレートできることがLiterateProgramsの例で示されてる\cite{literateprograms}. また, Overleafの記事では, \TeX を用いたフィボナッチ数列の計算方法が紹介されており, そのチューリング完全性の実用性が理解できる\cite{overleaf}.}.
862 すなわち, この世に存在するあらゆるアルゴリズムは \TeX で記述可能である.
863 物理シミュレーション (天気予報や化学反応予測),
864 経済シミュレーション (投資戦略),
865 さらには人工知能の学習アルゴリズム (画像認識や自然言語処理) ------.\par
866 どれも\TeX で実装できる.\par
867 しかし, それを実際にやろうと思う人間は果たしてどれほどいるだろうか?
868 筆者はソートアルゴリズムですら\TeX で書きたくない.
869 それは表計算ソフトでスーパーマリオを作るようなものだからである.\par
870 ------ところが, である.\par
871 筆者は``天啓''を受けた
872 \footnote{元ネタ: 2011年1月20日, 匿名掲示板4chanにおいて``Sleep Sort''というソートアルゴリズムが公開された\cite{geniussorting,gfxhatena}. このアルゴリズムは\showcmd[]{Bash}スクリプトを用いて各入力値をスレッドとして非同期に実行し, それぞれのスレッドの終了タイミング (指定された``スリープ''時間) を用いてリストをソートする手法である.}.
873 そして\showcmd[]{at}キーを用いたソートアルゴリズムを作り上げた.
874 \begin{codebox}{}{Ex:genius}
875 \newcommand{\AtSort}[1][1]{
876 \q
877 {
878 \foreach \i in {#1}
879 {
880 \qbox[name={\i}, at={0, -\i}]\n
881 }
882 }
883 }
884 \AtSort[4,1,3,-1,6,2]
885 \end{codebox}
886 動く. 確かに動く.\par
887 だが, 一つ問題がある.\par
888 \textbf{リストの要素に絶対値の大きな値が含まれていると, 出力が紙面からはみ出してしまうのである}.
889
890 \subsection{ワイヤーのカスタマイズ}
891 \label{subsec:wirecustomization}
892 \[\q{
893 \def\maxn{11}
894 \foreach \i in {0,...,\maxn}
895 {
896 \qwireup[dom={0,0}, cod={{\fpeval{\i*360/(\maxn+1)}}:3}]
897 \node at ({\fpeval{\i*360/(\maxn+1)}}:3.6) {\showcmd[]{cod}\i};
898 }
899 }\]
900 \ref{subsec:boxcustomization} 節で登場したボックス\q[scale=0.5]{\qbox}のキーの中で, \showcmd[]{id}, \showcmd[]{vlen} はワイヤーでも有効である.
901 ワイヤー特有のキーとして, 基本的なものは次の通りである:
902 \begin{itemize}
903 \item \showcmd[]{dom}: 入力点.
904 \item \showcmd[]{cod}: 出力点.
905 \iitem デフォルト値は\showcmd[]{dom}を \(1\) だけ北へ垂直移動した位置.
906 \item \showcmd[]{label}: ワイヤーにラベルを付ける.
907 \item \showcmd[]{label at}: ラベルのワイヤー上の位置.
908 \iitem デフォルトで midway.
909 \item \showcmd[]{label side}: ラベルとワイヤーの位置関係.
910 \iitem デフォルトで right.
911 \end{itemize}
912 \begin{codebox}{}{ex:78129738912260951}
913 \q{
914 \qbox[n=3,hlen=1.5]
915 \qbox[at={1,2}, s=2, hlen=1.5]
916 \qbox[at={-1,4}, s=2, hlen=1.5]
917 \qwire[dom={N-1-1}, cod={S-1-3}]
918 \qwire[dom={N-2-1}, cod={S-1-2}]
919 \qwire[dom={N-3-1}, cod={S-2-2}]
920 \qwire[dom={N-1-2}, cod={S-2-3}]
921 }
922 \end{codebox}
923 \begin{CODEBOX}{}{ex:193477432894112213}
924 \q{
925 \def\maxi{11}
926 \foreach \i in {0,...,\maxi}
927 {
928 \qwireup[dom={0,0}, cod={{\fpeval{\i*360/(\maxi+1)}}:2}]
929 \node at ({\fpeval{\i*360/(\maxi+1)}}:2.4) {\texttt{cod} \i};
930 }
931 }
932 \end{CODEBOX}
933 ワイヤー\q[scale=0.6]{\qwire}のバウンディングボックスは, \q[scale=0.5]{\qbox}と同じである:
934 \begin{codebox}{}{ex:78129738912220926}
935 \q
936 {
937 \qwire\qbox\qwire\n
938 \qbox\qwire\qbox
939 \qbball
940 }
941 \end{codebox}
942 ワイヤーのバウンディングボックスは, \showcmd[]{dom}を入力点, \showcmd[]{cod}を出力点とするようなボックスのそれと一致する:
943 \begin{itemize}
944 \item \(\q[scale=0.5]{\qwire}\) と \(\q[scale=0.5]{\qbox}\)
945 \item \(\q[scale=0.5]{\qwire[dom={0,0},cod={1,1}]}\) と \(\q[scale=0.5]{\qbox[p=2,S={1},N={2}]}\)
946 \end{itemize}
947
948 \begin{CODEBOX}{}{Ex:7812973891209}
949 \q[scale=3]{
950 \coordinate (A) at (0,0);
951 \coordinate (B) at (2,3);
952 \qwire[dom=A, cod={1,1}, label={wire1}, label side={left}]
953 \qwire[dom={1,1}, cod=B, label={wire2}, label at={near end}]
954 \node[fill=red, circle] at (A) {A};
955 \node[fill=green, circle] at (B) {B};
956 \node[fill=yellow, circle] at (1,1) {(1,1)};
957 \qbball
958 }
959 \end{CODEBOX}
960
961 \begin{CODEBOX}{}{Ex:7812973891201}
962 \q{
963 \qloop[5]{
964 \qloop[10]{
965 \qbox[show id={true}]
966 }\n
967 }\n
968 \qspace[3]\qbox[s=2,show id={true},id={ego1}]\n\n
969 \qspace[6]\qbox[n=2,show id={true},id={ego2}]\n\n
970 \qloop[5]{
971 \qloop[10]{
972 \qbox[show id={true}]
973 }\n
974 }
975 \qwire[dom={O-1-55},cod={I-1-51}]
976 \qwire[dom={O-1-60},cod={I-1-52}]
977 \qwire[dom={O-1-51},cod={I-1-45}]
978 \qwire[dom={O-1-52},cod={I-2-51}]
979 \qwire[dom={O-2-52},cod={I-1-48}]
980 }
981 \end{CODEBOX}
982
983 \paragraph{arrowtype}
984 ワイヤーのスタイルは, \showcmd[]{arrowtype}キーを用いて指定する.
985 \begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{wirearrowtype}
986 \q{
987 \qwire[arrowtype=dotted]
988 \qwire[arrowtype=dashed]
989 \qwire[arrowtype={dash dot}]
990 \qwire[arrowtype={dash dot dot}]
991 \qwire[arrowtype={densely dotted}]
992 \qwire[arrowtype={loosely dotted}]
993 }
994 \end{codebox}
995
996 \begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{boxarrowtype}
997 \q{
998 \qbox[dom arrowtype={dotted}]
999 \qbox[cod arrowtype={dotted}]
1000 \qbox[arrowtype={dotted}]
1001 }
1002 \end{codebox}
1003
1004 \begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{spiderarrowtype}
1005 \q{
1006 \qspider[dom arrowtype={dotted}]
1007 \qspider[cod arrowtype={dotted}]
1008 \qspider[arrowtype={dotted}]
1009 }
1010 \end{codebox}
1011
1012 \subsection{キャンバス}
1013 \begin{verbatim}
1014 \q[オプション]
1015 {
1016 コマンド
1017 コマンド
1018 ...
1019 }
1020 \end{verbatim}
1021 キャンバスのオプションで図式全体を変換できる.
1022 \begin{codebox}{}{Ex:74839753}
1023 \q[scale=2,rotate=30]{\qbox}
1024 \end{codebox}
1025 キャンバスを傾けることもできる.
1026 \begin{CODEBOX}{}{Ex:74839752}
1027 \def\anglerot{-55}
1028 \tikzset
1029 {
1030 my slant style/.style={
1031 yslant=-cot(\anglerot),
1032 xscale=sin(-\anglerot)
1033 }
1034 }
1035 \q[my slant style]
1036 {
1037 \qcaprev\qcap\n
1038 \qwire\qbraidinv\qwiredown\n
1039 \qwiredown\qbraidinv\qwire\n
1040 \qcup\qcuprev
1041 \qBBall
1042 }
1043 \end{CODEBOX}
1044 \begin{CODEBOX}{}{Ex:74839751}
1045 \def\anglerot{-60}
1046 \tikzset
1047 {
1048 my slant style/.style={
1049 yslant=-cot(\anglerot),
1050 xscale=sin(-\anglerot)
1051 }
1052 }
1053 \[\q[my slant style]
1054 {
1055 \qbraid\qwire\n
1056 \qwire\qbraid\n
1057 \qbraid\qwire
1058 }
1059 =\q[my slant style]
1060 {
1061 \qbraid\qwire\n
1062 \qwire\qwire\qwire\n
1063 \qbraid[num R=2]
1064 \qbb[red][1]
1065 \qbb[cyan][6]
1066 }
1067 =\q[my slant style]
1068 {
1069 \qbraid[ num R=2]\n
1070 \qwire\qwire\qwire\n
1071 \qwire\qbraid
1072 \qbb[red][6]
1073 \qbb[cyan][1]
1074 }
1075 =\q[my slant style]
1076 {
1077 \qwire\qbraid\n
1078 \qbraid\qwire\n
1079 \qwire\qbraid
1080 }\]
1081 \end{CODEBOX}
1082
1083 \section{モノイダル圏と\qworldname}
1084 本章では, \qworldname パッケージを用いてモノイダル圏の図式計算をどのように表現できるかを探る.
1085 \qworldname は, それ単体で機能し, 図式を扱うことができるが,
1086 数式をより柔軟に表現するために, その基盤となるパッケージ (\showcmd[]{amsmath}, \showcmd[]{amssymb}, \showcmd[]{mathtools}) を使用する.
1087 再現の際は, 以下のようにパッケージを適宜ロードせよ:
1088 \begin{verbatim}
1089 \usepackage{amsmath, amssymb, mathtools}
1090 \usepackage{qworld}
1091 \end{verbatim}
1092 \subsection{圏}
1093 \begin{codebox}{ドメイン}{ex:dom2}
1094 \[
1095 \operatorname{dom}\left(
1096 \q{
1097 \qbox[name={\(f\)}]
1098 \symbolI{\(x\)}
1099 \symbolO{\(y\)}
1100 }
1101 \right)=x
1102 \]
1103 \end{codebox}
1104 \begin{codebox}{コドメイン}{ex:cod2}
1105 \[
1106 \operatorname{cod}\left(
1107 \q{
1108 \qbox[name={\(f\)}]
1109 \symbolI{\(x\)}
1110 \symbolO{\(y\)}
1111 }
1112 \right)=\q{\qwire[label={\(y\)}]}
1113 \]
1114 \end{codebox}
1115
1116 \begin{codebox}{合成 (垂直合成)}{def:composite}
1117 \[
1118 \q{
1119 \qbox[name={\(f\)}]\qcirc\qbox[name={\(g\)}]
1120 }=\q{\qbox[name={\(f\circ g\)}]}
1121 \]
1122 \end{codebox}
1123 \begin{CODEBOX}{結合律}{Ex:74839750}
1124 \[
1125 \forall\q{\qbox[name={\(h\)}] \symbolI{\(z\)} \symbolO{\(w\)}},
1126 \q{\qbox[name={\(g\)}] \symbolI{\(y\)} \symbolO{\(z\)}},
1127 \q{\qbox[name={\(f\)}] \symbolI{\(x\)} \symbolO{\(y\)}}:
1128 \q{
1129 \qbox[name={\(h\)}]\qcirc\qbox[name={\(g\)}]\qcirc\qbox[name={\(f\)}]
1130 \qbb[2,3]
1131 }
1132 =
1133 \q{
1134 \qbox[name={\(h\)}]\qcirc\qbox[name={\(g\)}]\qcirc\qbox[name={\(f\)}]
1135 \qbb[1,2]
1136 }
1137 \]
1138 \end{CODEBOX}
1139 \begin{CODEBOX}{恒等律}{IdentityLaw}
1140 \begin{equation}
1141 \label{law:identity}
1142 \forall\q
1143 {
1144 \qbox[name={\(f\)}]
1145 \symbolS{\(x\)}
1146 \symbolN{\(y\)}
1147 }\colon
1148 \q{
1149 \qwire[label={\(y\)}]\n
1150 \qbox[name={\(f\)}]
1151 }=\q{
1152 \qbox[name={\(f\)}]
1153 }=\q{
1154 \qbox[name={\(f\)}]\n
1155 \qwire[label={\(x\)}]
1156 }
1157 \end{equation}
1158 \end{CODEBOX}
1159 \subsubsection{対象情報と色}
1160 \label{subsubsec:objectcolor}
1161 圏の図式計算において, 恒等射は通常, 単なるワイヤーとして描かれる.
1162 こうしたワイヤーがどの対象の恒等射であるかを, \textbf{対象ごとに固有の色を割り当てる}ことによって視認可能にする手法が存在する.
1163 この手法を用いることにより, ワイヤ上に対象の情報をエンコードすることが可能となり, 曲線構造からなる図式において, 対象の区別を直感的に把握する助けとなる.
1164 この手法の理論的背景には, \textbf{任意の射に対してドメインとなる対象とコドメインとなる対象がそれぞれ一意的に存在する}という事実がある.
1165 この構造が前提として存在する以上, 図式表現において``色''という視覚的属性を通じて対象を暗示/表現することは十分に正当化される操作である.
1166 例えば組紐 (\pageref{subsubsec:braid:color}ページの\ref{subsubsec:braid:color}項) や双対性 (\pageref{subsubsec:duality:color}ページ\ref{subsubsec:duality:color}項) を含む図式において, 色による補助が正確な解釈を支援する.
1167 この考え方のもとでは, 対象とはワイヤーを彩る色のような存在であり,
1168 \begin{CODEBOX}[bicolor,colbacklower=white]{}{objectcolor}
1169 \(\operatorname{dom}\)は射
1170 \(\q{\qbox[name={\(f\)}, dom color=red, cod color=cyan]}\)
1171 のドメインの色\(\q{\qwire[color=red]}\)
1172 を識別するための関数であり,
1173 \(\operatorname{cod}\)は同様に, コドメインの色
1174 \(\q{\qwire[color=cyan]}\)を識別するための関数である.\par
1175 そして紙面上で
1176 \(\q{\qbox[name={\(f\)}, dom color=purple, cod color=teal]}\)
1177 のコドメインの色と
1178 \(\q{\qbox[name={\(g\)}, dom color=teal, cod color=orange]}\)
1179 のドメインの色が一致していることが色によって明示され,
1180 この条件が満たされているときに限り, 合成 (垂直合成)
1181 \[
1182 \q{
1183 \qbox[name={\(g\)}, dom color=cyan, cod color=orange]\n
1184 \qbox[name={\(f\)}, dom color=red, cod color=cyan]
1185 }
1186 \]
1187 が整合性を保つ操作として許容される.
1188 \end{CODEBOX}
1189 \subsection{モノイダル圏}
1190 \begin{CODEBOX}{テンソル積 (並列合成)}{monoidalproduct}
1191 \[
1192 \q
1193 {
1194 \qbox[name={\(f\)}] \qbox[name={\(g\)}]
1195 \symbolO{\(Y_1\)}[id=1] \symbolO{\(Y_2\)}
1196 \symbolI{\(X_1\)}[id=1] \symbolI{\(X_2\)}
1197 }
1198 =\q
1199 {
1200 \qbox[name={\(f\otimes g\)}, p=2]
1201 \symbolO{\(Y_1\)} \symbolO[2]{\(Y_2\)}
1202 \symbolI{\(X_1\)} \symbolI[2]{\(X_2\)}
1203 }
1204 =\q
1205 {
1206 \qbox[name={\(f\otimes g\)}]
1207 \symbolO{\(Y_1\otimes Y_2\)}
1208 \symbolI{\(X_1\otimes X_2\)}
1209 }
1210 \]
1211 \end{CODEBOX}
1212 \subsubsection{交換則}
1213 \begin{CODEBOX}{交換則 (\(\bigotimes\)の共変関手性)}{InterchangeLaw}
1214 \begin{equation}
1215 \label{law:interchange}
1216 \q
1217 {
1218 \qbox[name={\(f_2\)}]\qbox[name={\(g_2\)}]\n
1219 \qbox[name={\(f_1\)}]\qbox[name={\(g_1\)}]
1220 \qbb[1,2]
1221 \qbb[3,4]
1222 }
1223 =\q
1224 {
1225 \qbox[name={\(f_2\)}]\qbox[name={\(g_2\)}]\n
1226 \qbox[name={\(f_1\)}]\qbox[name={\(g_1\)}]
1227 \qbb[2,4]
1228 \qbb[1,3]
1229 }
1230 \end{equation}
1231 \end{CODEBOX}
1232
1233 \begin{CODEBOX}{単位対象}{Ex:74839744}
1234 \begin{gather}
1235 \q{ \qwire[arrowtype=dotted]}
1236 =\q{ \qunitob \qbball }\\
1237 \q{ \qunitob \qbox[name={\(f\)}] \qbball }
1238 =\q{ \qbox[name={\(f\)}] }
1239 =\q{ \qbox[name={\(f\)}] \qunitob \qbball }\label{cond:unitob}
1240 \end{gather}
1241 \end{CODEBOX}
1242 \begin{CODEBOX}{}{Ex:74839743}
1243 \[
1244 \q{\qunitob\qbball}
1245 =\q{\qloop[2]{\qunitob}\qbball}
1246 =\q{\qloop[3]{\qunitob}\qbball}
1247 =\cdots
1248 \]
1249 \end{CODEBOX}
1250
1251 \subsection{特殊ボックス}
1252
1253 \begin{itemize}
1254 \item \showcmd{qstate}: \(\q[scale=0.5]{\qstate}\) (\(0\)入力).
1255 \item \showcmd{qeffect}: \(\q[scale=0.5]{\qeffect}\) (\(0\)出力).
1256 \item \showcmd{qscalar}: \(\q[scale=0.5]{\qscalar}\) (\(0\)入力, \(0\)出力).
1257 \item \showcmd{qasym}: \(\q[scale=0.5]{\qasym}\) (非対称ボックス).
1258 \item \showcmd{qtrans}: \(\q[scale=0.5]{\qtrans}\) (転置ボックス). \pageref{subsub:transpose}ページの\ref{subsub:transpose}項.
1259 \item \showcmd{qadj}: \(\q[scale=0.5]{\qadj}\) (随伴ボックス). \pageref{subsub:adjoint}ページの\ref{subsub:adjoint}項.
1260 \item \showcmd{qconj}: \(\q[scale=0.5]{\qconj}\) (共役ボックス). \pageref{subsub:conj}ページの\ref{subsub:conj}項.
1261 \end{itemize}
1262 \subsubsection{ゼロ入力}
1263 \label{subsub:zeroinput}
1264 \begin{codebox}{}{def:state}
1265 \q{\qstate}
1266 \end{codebox}
1267 \subsubsection{ゼロ出力}
1268 \label{subsub:zerooutput}
1269 \begin{codebox}{}{def:effect}
1270 \q{\qeffect}
1271 \end{codebox}
1272 \subsubsection{ゼロ入力ゼロ出力}
1273 \label{subsub:zeroinputoutput}
1274 \begin{codebox}{}{def:scalar}
1275 \q{\qscalar}
1276 \end{codebox}
1277 \paragraph{\(\q[scale=0.4]{\qeffect\qstate\qwire[dom={O-1-2}, cod={1,2}]\qwire[dom={1,-1}, cod={I-1-1}]}=\q[scale=0.4]{\qwire[vlen=0.5]\n\qstate\n\qeffect\n[0.5]\qwire[vlen=0.5]}=\q[scale=0.4]{\qstate\qeffect\qwire[dom={O-1-1}, cod={1,2}]\qwire[dom={1,-1}, cod={I-1-2}]}\)}
1278 \begin{CODEBOX}{}{coherence:unitor}
1279 \[
1280 \q{
1281 \qeffect\qstate
1282 \qwire[dom={O-1-2}, cod={1,2}]
1283 \qwire[dom={1,-1}, cod={I-1-1}]
1284 }=\q{
1285 \qwire[arrowtype=dotted]\qwire\n
1286 \qeffect\qstate\n
1287 \qwire\qwire[arrowtype=dotted]
1288 }\stackrel{\text{(\ref{law:interchange}, \ref{law:identity})}}{=}\q{
1289 \qwire[arrowtype=dotted]\qstate\n
1290 \qeffect\qwire[arrowtype=dotted]
1291 }\stackrel{\text{(\ref{law:interchange}, \ref{cond:unitob})}}{=}\q{\qstate\n\qeffect}
1292 \]
1293 \end{CODEBOX}
1294 \begin{CODEBOX}{表現行列}{matrixrepre}
1295 \begin{align*}
1296 \q{\qbox[name={\(f\)}]}
1297 &=\sum\limits_{i,j}
1298 \left(
1299 \q{
1300 \qeffect[name={\(w_j^{\dagger}\)}]\n
1301 \qbox[name={\(f\)}]\n
1302 \qstate[name={\(v_i\)}]\n
1303 }\q{
1304 \qstate[name={\(w_j\)}]\n
1305 \qeffect[name={\(v_i^{\dagger}\)}]
1306 }
1307 \right)
1308 =\sum\limits_{i,j}\left(
1309 \q{
1310 \qscalar[name={\(w_j^{\dagger}\circ f\circ v_i\)}]
1311 }
1312 \q{
1313 \qstate[name={\(w_j\)}]\n
1314 \qeffect[name={\(v_i^{\dagger}\)}]
1315 }
1316 \right)\\
1317 &=\begin{pmatrix}
1318 \q{\qscalar[name={\(w_1^{\dagger}\circ f\circ v_1\)}]}&&\cdots&&\q{\qscalar[name={\(w_1^{\dagger}\circ f\circ v_{m}\)}]}\\
1319 &\ddots&&&\\
1320 \vdots& &\q{\qscalar[name={\(w_j^{\dagger}\circ f\circ v_i\)}]}& &\vdots\\
1321 &&&\ddots&\\
1322 \q{\qscalar[name={\(w_n^{\dagger}\circ f\circ v_1\)}]}&&\cdots&&\q{\qscalar[name={\(w_n^{\dagger}\circ f\circ v_m\)}]}
1323 \end{pmatrix}
1324 \end{align*}
1325 \end{CODEBOX}
1326
1327 \subsection{モノイド対象}
1328 \label{subsec:monoid}
1329 \begin{itemize}
1330 \item \showcmd{qmul}: \(\q[scale=0.5]{\qmul}\)
1331 \iitem \showcmd[]{hlen=2}: \(\q[scale=0.5]{\qmul[hlen=2]}\)
1332 \item \showcmd{qcomul}: \(\q[scale=0.5]{\qcomul}\)
1333 \iitem \showcmd[]{hlen=2}: \(\q[scale=0.5]{\qcomul[hlen=2]}\)
1334 \item \showcmd{qunit}: \(\q[scale=0.5]{\qunit}\)
1335 \item \showcmd{qcounit}: \(\q[scale=0.5]{\qcounit}\)
1336 \item \showcmd{qspider}: \(\q[scale=0.5]{\qspider}\)
1337 \end{itemize}
1338
1339 \begin{CODEBOX}{結合律}{AssociateLaw}
1340 \begin{equation}
1341 \label{law:associate}
1342 \q{
1343 \qspace[0.5]\qmul[hlen=2]\n
1344 \qmul[hlen=2]\qspace[-0.5]\qwire
1345 }=\q{
1346 \qmul[hlen=2]\n
1347 \qwire\qspace[-0.5]\qmul[hlen=2]
1348 }
1349 \end{equation}
1350 \end{CODEBOX}
1351 \begin{CODEBOX}{単位律}{UnitLaw}
1352 \begin{equation}
1353 \label{law:unit}
1354 \q{
1355 \qmul[hlen=2]\n
1356 \qwire\qunit
1357 }=\q{\qwire[vlen=2]}
1358 =\q
1359 {
1360 \qmul[hlen=2]\n
1361 \qunit\qwire
1362 }
1363 \end{equation}
1364 \end{CODEBOX}
1365 \begin{CODEBOX}{余結合律}{CoassociateLaw}
1366 \begin{equation}
1367 \label{law:coassociate}
1368 \q{
1369 \qcomul[hlen=2]\qspace[-0.5]\qwire\n
1370 \qspace[0.5]\qcomul[hlen=2]
1371 }
1372 =\q{
1373 \qwire\qspace[-0.5]\qcomul[hlen=2]\n
1374 \qcomul[hlen=2]
1375 }
1376 \end{equation}
1377 \end{CODEBOX}
1378 \begin{CODEBOX}{余単位律}{CounitLaw}
1379 \begin{equation}
1380 \label{law:counit}
1381 \q{
1382 \qcounit\qwire\n
1383 \qcomul[hlen=2]
1384 }
1385 =\q{\qwire[vlen=2]}
1386 =\q{
1387 \qwire\qcounit\n
1388 \qcomul[hlen=2]
1389 }
1390 \end{equation}
1391 \end{CODEBOX}
1392
1393 \subsubsection{フロベニウス則}
1394 \begin{FCODEBOX}{フロベニウス則}{FrobeniusLaw}
1395 \[
1396 \q{
1397 \qwire\qmul[color=black]\n
1398 \qcomul\qwire
1399 }=\q{
1400 \qcomul\n
1401 \qmul[color=black]
1402 }=\q{
1403 \qmul[color=black]\qwire\n
1404 \qwire\qcomul
1405 }
1406 \]
1407 \end{FCODEBOX}
1408 失敗例として挙げられているが, 実際にはフロベニウス則が正確に記述されている.
1409 むしろ, 全てのワイヤーの間隔が整数値に保たれているため, 垂直合成時の調整が容易であり, 場合によっては調整自体が不要となる可能性がある.
1410 これは単なる好みの問題に過ぎない.
1411 \verb|\qmul|や\verb|\qcomul|のデフォルトの描画結果が\(\q[scale=0.5]{\qmul}\), \(\q[scale=0.5]{\qcomul}\)であるのは,
1412 \verb|\qbox[s=2]|や\verb|\qbox[n=2]|の描画結果が\(\q[scale=0.5]{\qbox[s=2]}\), \(\q[scale=0.5]{\qbox[n=2]}\)であることの名残である.
1413 このような場合の調整キーとして\verb|hlen|がある:
1414 \begin{CODEBOX}{フロベニウス則}{FrobeniusLaw2}
1415 \[
1416 \q{
1417 \qwire\qmul[hlen=2,color=black]\n
1418 \qcomul[hlen=2]\qwire
1419 }=\q{
1420 \qcomul[hlen=2]\n
1421 \qmul[hlen=2,color=black]
1422 }=\q{
1423 \qmul[hlen=2,color=black]\qwire\n
1424 \qwire\qcomul[hlen=2]
1425 }
1426 \]
1427 \end{CODEBOX}
1428
1429 \verb|\qspider|は, ノードがボックスではなく円であることを除けば, \verb|\qbox|と同じである.
1430 \begin{codebox}{}{spider78129738912240521}
1431 \[\q{\qspider}\]
1432 \[\q{\qspider[n=0]}\]
1433 \[\q{\qspider[n=0,s=4]}\]
1434 \[\q{\qspider[n=2,s=4]}\]
1435 \[\q{\qspider[N={1,4},s=4]}\]
1436 \[\q{\qspider[N={2,3},s=4]}\]
1437 \[\q{\qspider[p=3,N={2},S={1,3}]}\]
1438 \[\q{\qspider[p=3,N={2},S={1,3},hlen=2]}\]
1439 \[\q{\qspider[n=1,s=2,hlen=2]}\]
1440 \end{codebox}
1441
1442 \begin{CODEBOX}{}{spider78129738912270738}
1443 \[
1444 \q{
1445 \qspider[n=2, s=4, hlen=4]\qwire\qwire\n
1446 \qwire\qwire\qspider[n=4, s=2, hlen=4]
1447 }
1448 =\q{\qspider[p=4]}\]
1449 \end{CODEBOX}
1450
1451 \subsection{組紐}
1452 \label{subsec:braidedcategory}
1453 \begin{itemize}
1454 \item \showcmd{qbraid}: \(\q[scale=0.5]{\qbraid}\)
1455 \item \showcmd{qbraidinv}: \(\q[scale=0.5]{\qbraidinv}\)
1456 \item \showcmd{qsym}: \(\q[scale=0.5]{\qsym}\)
1457 \end{itemize}
1458
1459 \paragraph{\showcmd[]{num L} と \showcmd[]{num R} キー}
1460 ワイヤーを交叉させた図式を描画するコマンド\verb|\qbraid|, \verb|\qbraidinv|, \verb|\qsym|に対し,
1461 \showcmd[]{num L}は左側のワイヤーの本数を, \showcmd[]{num R}は右側のワイヤーの本数を指定するキーである.
1462 例えば, \showcmd[]{num L=3}, \showcmd[]{num R=2} とすれば, \(\q{\qbraid[num L=3,num R=2]}\)が描画される.
1463 双方デフォルト値はともに\(1\)である.
1464
1465 \begin{CODEBOX}{六角形等式}{hexagon}
1466 \begin{equation}
1467 \label{eq:hexagon}
1468 \q
1469 {
1470 \qbraid[num R=2,,hlen=2,vlen=2]
1471 }
1472 =
1473 \q
1474 {
1475 \qwire\qbraid\n
1476 \qbraid\qwire
1477 }
1478 \qquad
1479 \q
1480 {
1481 \qbraid[num L=2,,hlen=2,vlen=2]
1482 }
1483 =
1484 \q
1485 {
1486 \qbraid\qwire\n
1487 \qwire\qbraid
1488 }
1489 \end{equation}
1490 \end{CODEBOX}
1491 \paragraph{\({\q[scale=0.5]{\qbraid}}^{-1}=\q[scale=0.5]{\qbraidinv}\)}
1492 \begin{CODEBOX}{}{braidisom2}
1493 \begin{equation}
1494 \label{eq:inverse:braid}
1495 \q
1496 {
1497 \qbraidinv\n
1498 \qbraid
1499 }
1500 =
1501 \q
1502 {
1503 \qwire[vlen=2]\qwire[vlen=2]
1504 }
1505 \qquad
1506 \q
1507 {
1508 \qbraid\n
1509 \qbraidinv
1510 }
1511 =
1512 \q
1513 {
1514 \qwire[vlen=2]\qwire[vlen=2]
1515 }
1516 \end{equation}
1517 \end{CODEBOX}
1518 \begin{CODEBOX}{組紐の自然性}{braidnatural}
1519 \begin{equation}
1520 \label{cond:naturality:braid}
1521 \q
1522 {
1523 \qbraid\n
1524 \qbox[name={\(f\)}]\qbox[name={\(g\)}]
1525 }
1526 =
1527 \q
1528 {
1529 \qbox[name={\(g\)}]\qbox[name={\(f\)}]\n
1530 \qbraid
1531 }
1532 \qquad
1533 \q
1534 {
1535 \qbraidinv\n
1536 \qbox[name={\(f\)}]\qbox[name={\(g\)}]
1537 }
1538 =
1539 \q
1540 {
1541 \qbox[name={\(g\)}]\qbox[name={\(f\)}]\n
1542 \qbraidinv
1543 }
1544 \end{equation}
1545 \end{CODEBOX}
1546
1547 コマンド\verb|\qbraid|, \verb|\qbraidinv|, \verb|\qsym|に対し,
1548 \showcmd[]{num R=0}と指定すると, \(\q[scale=0.65]{\qbraid[num R=0]}\)のように右側のワイヤーが点線となる.
1549 \showcmd[]{num L=0}と指定すると, \(\q[scale=0.65]{\qbraid[num L=0]}\)のように左側のワイヤーが点線となる.
1550 これは, 単位対象を空図式, すなわち\(0\)本のワイヤーとして表すことに由来している.
1551 \begin{CODEBOX}{}{stateeffect3dimbraid}
1552 \begin{gather}
1553 \q{
1554 \qwire\qstate\n
1555 \qwire
1556 }
1557 =\q{
1558 \qwire\qstate\n
1559 \qbraid[num L=0]
1560 }\stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q{
1561 \qbraid\n
1562 \qstate\qwire
1563 }\label{iso:u:state}\\
1564 \q{
1565 \qunitob\qwire\n
1566 \qeffect\qwire
1567 }
1568 =\q{
1569 \qbraid[num L=0]\n
1570 \qeffect\qwire
1571 }\stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q{
1572 \qwire\qeffect\n
1573 \qbraid
1574 }\label{iso:u:effect}
1575 \end{gather}
1576 \end{CODEBOX}
1577 \begin{CODEBOX}{}{iso:spatial:scalar}
1578 \begin{equation}
1579 \label{iso:spatial}
1580 \q{\qscalar\qmv[0,-1]\qwire[vlen=3]}
1581 =\q{\qbraid[num L=0]\n\qscalar\qmv[0,-1]\qwire[vlen=2]}
1582 \stackrel{\text{(\ref{cond:naturality:braid})}}{=}
1583 \q{\qwire[vlen=2]\qscalar\n\qbraid[num L=0]}
1584 =\q{\qscalar\qmv[-2,-1]\qwire[vlen=3]}
1585 \end{equation}
1586 \end{CODEBOX}
1587 \begin{CODEBOX}{}{iso:spatial:state.effect}
1588 \[
1589 \q{\qscalar\qmv[0,-1]\qwire[vlen=3]}
1590 =\q{\qeffect\n\qstate\qmv[0,-0.5]\qwire[vlen=3]}
1591 \stackrel{\text{(\ref{iso:u:effect})}}{=}
1592 \q{\qwire\qeffect\n\qbraid\n\qstate\qwire}
1593 \stackrel{\text{(\ref{iso:u:state})}}{=}
1594 \q{\qeffect\n\qstate\qmv[-2,-0.5]\qwire[vlen=3]}
1595 =\q{\qscalar\qmv[-2,-1]\qwire[vlen=3]}
1596 \]
1597 \end{CODEBOX}
1598 \paragraph{\(\q[scale=0.5]{\qbraid\qwire\n\qwire\qstate[n=2]}=\q[scale=0.5]{\qwire\qbraidinv\n\qstate[n=2]\qwire}\)}
1599 \begin{CODEBOX}{}{dashedbraid}
1600 \begin{align}
1601 \q
1602 {
1603 \qbraid\qwire\n
1604 \qwire\qstate[n=2]
1605 }
1606 &=\q
1607 {
1608 \qbraid\qwire\n
1609 \qwire\qstate[n=2]\n\n
1610 \qbraidinv[num L=0,vlen=2,hlen=2.5]
1611 }
1612 \stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q
1613 {
1614 \qbraid\qwire\n\n
1615 \qbraidinv[num L=2,vlen=2]\n
1616 \qstate[n=2]\qwire\n
1617 \qspace[0.5]\qwire[arrowtype={densely dotted}]\qspace[0.5]\qwire
1618 }\\
1619 &=\q
1620 {
1621 \qbraid\qwire\n\n
1622 \qbraidinv[num L=2,vlen=2]\n
1623 \qstate[n=2]\qwire\n
1624 \qspace[2]\qwire
1625 \qbb[green][3]
1626 }\stackrel{\text{(\ref{eq:hexagon})}}{=}\q
1627 {
1628 \qbraid\qwire\n
1629 \qbraidinv\qwire\n
1630 \qwire\qbraidinv\n
1631 \qstate[n=2]\qwire\n
1632 \qspace[2]\qwire
1633 \qbb[green][3,...,6]
1634 }\\
1635 &=\q
1636 {
1637 \qbraid\qwire\n
1638 \qbraidinv\qwire\n
1639 \qwire\qbraidinv\n
1640 \qstate[n=2]\qwire\n
1641 \qspace[2]\qwire
1642 \qbb[orange][1,3]
1643 }
1644 \stackrel{\text{(\ref{eq:inverse:braid})}}{=}\q
1645 {
1646 \qloop[2]{\qloop[3]{\qwire}\n}
1647 \qwire\qbraidinv\n
1648 \qstate[n=2]\qwire\n
1649 \qspace[2]\qwire
1650 \qbb[orange][1,2,4,5]
1651 }
1652 \end{align}
1653 \end{CODEBOX}
1654
1655 \begin{CODEBOX}{ヤン-バクスター方程式}{YangBaxer}
1656 \[
1657 \q
1658 {
1659 \qbraid\qwire\n
1660 \qwire\qbraid\n
1661 \qbraid\qwire
1662 }=\q
1663 {
1664 \qwire\qbraid\n
1665 \qbraid\qwire\n
1666 \qwire\qbraid
1667 }
1668 \]
1669 \end{CODEBOX}
1670
1671 \begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{可換性}{def:cmt}
1672 \begin{equation}
1673 \label{cond:cmt}
1674 \q{\qmul[hlen=2]}=\q{\qmul[hlen=2]\n\qbraid}
1675 \end{equation}
1676 \end{codebox}
1677 \begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{余可換性}{def:ccmt}
1678 \begin{equation}
1679 \label{cond:ccmt}
1680 \q{\qcomul[hlen=2]}=\q{\qbraid\n\qcomul[hlen=2]}
1681 \end{equation}
1682 \end{codebox}
1683 \subsubsection{双代数}
1684 \begin{CODEBOX}{双代数則}{law:bialgebra}
1685 \begin{gather}
1686 \q{\qcomul[hlen=2]\qcirc\qmul[hlen=2, color=black]}
1687 =\q{
1688 \qmul[hlen=2, color=black]\qmul[hlen=2, color=black]\n
1689 \qwire\qbraid\qwire\n\qcomul[hlen=2]\qcomul[hlen=2]
1690 }\\
1691 \q{\qspace[0.5]\qcounit\qcirc\qmul[hlen=2, color=black]}
1692 =\q{\qcounit\qcounit}\\
1693 \q{\qcomul[hlen=2]\qcirc\qspace[0.5]\qunit[color=black]}
1694 =\q{\qunit[color=black]\qunit[color=black]}\\
1695 \q{\qcounit\n\qunit[color=black]}
1696 =\q{\qunitob}
1697 \end{gather}
1698 \end{CODEBOX}
1699 \subsubsection{ホップ代数}
1700 \begin{CODEBOX}{対合射とホップ則}{law:hopf}
1701 \begin{equation}
1702 \q{
1703 \qmul[hlen=2, color=black]\n
1704 \qwire\qbox[name={\(s\)}]\n
1705 \qcomul[hlen=2]
1706 }
1707 =\q{\qunit[color=black]\qcirc\qcounit}
1708 =\q{
1709 \qmul[hlen=2, color=black]\n
1710 \qbox[name={\(s\)}]\qwire\n
1711 \qcomul[hlen=2]
1712 }
1713 \end{equation}
1714 \end{CODEBOX}
1715 \subsubsection{平衡圏}
1716 \label{subsub:balancedcategory}
1717 \begin{CODEBOX}{ツイスト}{def:twist}
1718 \begin{gather}
1719 \q{
1720 \qbox[name={\(\theta_{X\otimes Y}\)}, p=2]
1721 \symbolI{\(X\)}\symbolI[2]{\(Y\)}
1722 \symbolO{\(X\)}\symbolO[2]{\(Y\)}
1723 }
1724 =\q{
1725 \qbox[name={\(\theta_X\)}]\qbox[name={\(\theta_Y\)}]\n
1726 \qbraid\n\qbraid
1727 }\label{cond:twist}\\
1728 \q{\qbox[name={\(\theta_I\)}]}=\q{\qunitob}\label{cond:i:twist}\\
1729 \forall\q{\qbox[name={\(f\)}]}\colon
1730 \q{
1731 \qbox[name={\(\theta_{\operatorname{cod}(f)}\)}, hlen=1.5]\n
1732 \qbox[name={\(f\)}, hlen=1.5]
1733 }=\q{
1734 \qbox[name={\(f\)}, hlen=1.5]\n
1735 \qbox[name={\(\theta_{\operatorname{dom}(f)}\)}, hlen=1.5]
1736 }\label{cond:naturality:twist}
1737 \end{gather}
1738 \end{CODEBOX}
1739 \subsubsection{色}
1740 \label{subsubsec:braid:color}
1741
1742 \begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{対称}{defeq:sym}
1743 \begin{equation}
1744 \label{cond:symmetry}
1745 \q
1746 {
1747 \qbraid[L color=cyan, R color=red]\n
1748 \qbraid[L color=red, R color=cyan]
1749 }
1750 =\q{\qwire[color=red, vlen=2]\qwire[color=cyan, vlen=2]}
1751 \end{equation}
1752 \end{codebox}
1753
1754 \begin{CODEBOX}{}{wowsym}
1755 \[\q{\qbraid[L color=red, R color=cyan]}
1756 =\left(\q{\qbraid[L color=cyan, R color=red]}\right)^{-1}
1757 =\q{\qbraidinv[L color=red, R color=cyan]}\]
1758 \end{CODEBOX}
1759 \begin{codebox}{シンメトリー}{def:sym}
1760 \q{\qsym}
1761 \end{codebox}
1762
1763 \subsection{双対性}
1764 \label{subsub:duality}
1765 \begin{itemize}
1766 \item \showcmd{qcap}: \(\q[scale=0.6]{\qcap}\)
1767 \item \showcmd{qcup}: \(\q[scale=0.6]{\qcup}\)
1768 \item \showcmd{qcaprev}: \(\q[scale=0.6]{\qcaprev}\)
1769 \item \showcmd{qcuprev}: \(\q[scale=0.6]{\qcuprev}\)
1770 \end{itemize}
1771
1772 \begin{CODEBOX}{ジグザグ等式}{Snake}
1773 \begin{equation}
1774 \label{eq:snake}
1775 \q{
1776 \qcap\qwireup\n
1777 \qwireup\qcup
1778 }
1779 =\q{
1780 \qwireup[vlen=2]
1781 }
1782 \qquad\text{と}\qquad
1783 \q{
1784 \qwiredown\qcap\n
1785 \qcup\qwiredown
1786 }
1787 =\q{
1788 \qwiredown[vlen=2]
1789 }
1790 \end{equation}
1791 \end{CODEBOX}
1792
1793 \subsubsection{転置ボックス}
1794 \label{subsub:transpose}
1795 \begin{CODEBOX}{転置}{Transpose}
1796 \[
1797 \left(\q{\qwire\n\qasym[name={\(f\)}]\n\qwire}\right)^T
1798 =\q{
1799 \qwire\n
1800 \qtrans[name={\(f\)}]\n
1801 \qwire
1802 }\coloneq\q{
1803 \qwire\qcap\n
1804 \qwire\qasym[name={\(f\)}]\qwire\n
1805 \qcup\qwire
1806 }
1807 \]
1808 \end{CODEBOX}
1809 \begin{CODEBOX}{}{ex:193477432894021826}
1810 \begin{equation}
1811 \label{eq:wirerev}
1812 \left(\q{\qwireup}\right)^T=\q{\qwiredown}
1813 \end{equation}
1814 \end{CODEBOX}
1815 \begin{CODEBOX}{スライディング}{Sliding}
1816 \begin{equation}
1817 \label{eq:sliding}
1818 \q{
1819 \qcap \n
1820 \qasym \qwire
1821 }
1822 =\q{
1823 \qcap \n
1824 \qwire \qtrans
1825 }
1826 \qquad
1827 \q{
1828 \qwire \qasym \n
1829 \qcup
1830 }
1831 =\q{
1832 \qtrans \qwire \n
1833 \qcup
1834 }
1835 \end{equation}
1836 \end{CODEBOX}
1837
1838 \begin{CODEBOX}{}{MapStateDuality}
1839 \begin{equation}
1840 \begin{array}{rccc}
1841 \operatorname{NAME}\colon & \operatorname{Hom}(X,Y)
1842 & \to & \operatorname{Hom}(I,X^T\otimes Y)\\
1843 & \rotatebox{90}{\(\in\)} && \rotatebox{90}{\(\in\)}\\
1844 & \q{
1845 \qasym
1846 \symbolI{\(X\)}
1847 \symbolO{\(Y\)}
1848 } & \mapsto
1849 & \q{
1850 \qwire[label={\(X^T\)}, label at={at end}, label side={above}] \qasym \n
1851 \qcup
1852 \symbolO{\(Y\)}[id=2]
1853 }
1854 \end{array}
1855 \end{equation}
1856 \end{CODEBOX}
1857
1858 \begin{CODEBOX}{}{MapEffectDuality}
1859 \begin{equation}
1860 \begin{array}{rccc}
1861 \operatorname{CONAME}\colon & \operatorname{Hom}(X,Y)
1862 & \to & \operatorname{Hom}(X\otimes Y^T,I)\\
1863 & \rotatebox{90}{\(\in\)}&&\rotatebox{90}{\(\in\)}\\
1864 & \q{
1865 \qasym
1866 \symbolI{\(X\)}
1867 \symbolO{\(Y\)}
1868 } & \mapsto
1869 & \q{
1870 \qcap \n
1871 \qasym \qwire[label={\(Y^T\)}, label at={at start}, label side={below}]
1872 \symbolI{\(X\)}[id=2]
1873 }
1874 \end{array}
1875 \end{equation}
1876 \end{CODEBOX}
1877
1878 \subsubsection{コピー禁止定理}
1879 \label{subsub:nocopy}
1880 \begin{CODEBOX}{一様コピー}{def:copy}
1881 \begin{gather}
1882 \q{
1883 \qwire\qbraid\qwire\n
1884 \qcomul[hlen=2, name={\(\text{copy}_X\)}]\qcomul[hlen=2, name={\(\text{copy}_Y\)}]
1885 \symbolI{\(X\)}[id=4]\symbolI{\(Y\)}[id=5]
1886 \symbolO{\(X\)}[id=1]\symbolO{\(Y\)}[id=2]
1887 \symbolO[2]{\(X\)}[id=2]\symbolO{\(Y\)}[id=3]
1888 }=\q{
1889 \qcomul[hlen=3, vlen=2, name={\(\text{copy}_{X\otimes Y}\)}]\symbolI{\(X\otimes Y\)}
1890 \symbolO{\(X\otimes Y\)}\symbolO[2]{\(X\otimes Y\)}
1891 }\label{cond:copy}\\
1892 \forall\q{\qbox[name={\(f\)}]\symbolI{\(X\)}\symbolO{\(Y\)}}\colon
1893 \q{
1894 \qbox[name={\(f\)}]\qbox[name={\(f\)}]\n
1895 \qcomul[hlen=2, name={\(\text{copy}_X\)}]
1896 }=\q{
1897 \qcomul[hlen=2, name={\(\text{copy}_Y\)}]\n
1898 \qspace[0.5]\qbox[name={\(f\)}]
1899 }\label{cond:morcopy}\\
1900 \q{
1901 \qcomul[hlen=2, name={\(\text{copy}_I\)}]\symbolI{\(I\)}
1902 \symbolO{\(I\)}\symbolO[2]{\(I\)}
1903 }=\q{\qunitob}\label{cond:i:copy}
1904 \end{gather}
1905 \end{CODEBOX}
1906
1907 \begin{CODEBOX}{コピー可能状態}{def:copyablestate}
1908 \[
1909 \q{
1910 \qcomul[hlen=2, name={\(\operatorname{copy}\)}]\n
1911 \qspace[0.5]\qstate[name={\(a\)}]
1912 }=\q{
1913 \qstate[name={\(a\)}]\qstate[name={\(a\)}]
1914 }
1915 \]
1916 \end{CODEBOX}
1917 \begin{CODEBOX}{}{len:copycupcup}
1918 \begin{align*}
1919 \q{\qcup\qcup}&\stackrel{\text{(\ref{cond:i:copy})}}{=}
1920 \q{
1921 \qcup\qcup\n\qmv[0.5,0.4]
1922 \qcomul[dom arrowtype=dotted, cod arrowtype=dotted, hlen=3, name={\(\operatorname{copy}\)}]
1923 }\stackrel{\text{(\ref{cond:morcopy})}}{=}
1924 \q{
1925 \qspider[
1926 name={\(\operatorname{copy}\)},
1927 N={1,2,4,5},
1928 s=2,
1929 hlen=2
1930 ]\n\qcup
1931 }\\
1932 &\stackrel{\text{(\ref{cond:copy})}}{=}\q[scale=0.6]{
1933 \qwire\qbraid\qwire\n
1934 \qloop[4]{\qwire}\n
1935 \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
1936 \qspace[0.5]\qcup[hlen=3]
1937 \qbb[red][4,8]
1938 }\stackrel{\text{(\ref{cond:ccmt})}}{=}\q[scale=0.6]{
1939 \qwire\qbraid\qwire\n
1940 \qbraidinv\qwire\qwire\n
1941 \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
1942 \qspace[0.5]\qcup[hlen=3]
1943 \qbb[red][4,7]
1944 }\\
1945 &=\q[scale=0.6]{
1946 \qwire\qbraid\qwire\n
1947 \qbraidinv\qwire\qwire\n[2]
1948 \qloop[4]{\qwire[vlen=2]}\n
1949 \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
1950 \qspace[0.5]\qcup[hlen=3]
1951 \qbb[blue][8,9]
1952 }
1953 \stackrel{\text{(\ref{eq:inverse:braid})}}{=}
1954 \q[scale=0.6]{
1955 \qwire\qbraid\qwire\n
1956 \qbraidinv\qwire\qwire\n
1957 \qwire\qbraidinv\qwire\n
1958 \qwire\qbraid\qwire\n
1959 \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
1960 \qspace[0.5]\qcup[hlen=3]
1961 \qbb[blue][8,11]
1962 }\\
1963 &=\q[scale=0.6]{
1964 \qwire\qbraid\qwire\n
1965 \qbraidinv\qwire\qwire\n
1966 \qwire\qbraidinv\qwire\n
1967 \qwire\qbraid\qwire\n
1968 \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
1969 \qspace[0.5]\qcup[hlen=3]
1970 \qbb[yellow][10,14,15]
1971 }\stackrel{\text{(\ref{cond:copy}, \ref{cond:morcopy}, \ref{cond:i:copy})}}{=}
1972 \q[scale=0.6]{
1973 \qwire\qbraid\qwire\n
1974 \qbraidinv\qwire\qwire\n
1975 \qwire\qbraidinv\qwire\n
1976 \qcup\qcup
1977 \qbb[yellow][10,11]
1978 }\\
1979 &=\q{
1980 \qwire\qbraid\qwire\n
1981 \qcup[n=4]
1982 }
1983 \end{align*}
1984 \end{CODEBOX}
1985 \begin{CODEBOX}{}{len:copybraid}
1986 \begin{align*}
1987 \q{
1988 \qbraid
1989 \symbolI{\(X\)}\symbolO{\(X\)}
1990 \symbolI[2]{\(X\)}\symbolO[2]{\(X\)}
1991 }&\stackrel{\text{(\ref{eq:snake})}}{=}\q[scale=0.6]{
1992 \qwire\qspace[2]\qcap\qwire\n
1993 \qbraid[hlen=4]\qwire\qwire\n
1994 \qwire\qcap\qwire\qcup\n
1995 \qwire\qwire\qcup
1996 \qbb[blue][1,5]
1997 }=\q[scale=0.6]{
1998 \qcap[hlen=4]\qwire\n
1999 \qwire\qspace[2]\qbraidinv\n
2000 \qwire\qcap\qwire\qwire\qwire[vlen=3]\n
2001 \qwire\qwire\qcup\qcup
2002 \qbb[blue][1,4]
2003 \qbb[yellow][12,13]
2004 }\\
2005 &\stackrel{\text{例 \ref{len:copycupcup}}}{=}\q[scale=0.6]{
2006 \qcap[hlen=4]\qwire\n
2007 \qwire\qspace[2]\qbraidinv\n
2008 \qwire\qcap\qwire\qwire\qwire[vlen=3]\n
2009 \qwire\qwire\qwire\qbraid\qwire\n
2010 \qwire\qwire\qcup[n=4]
2011 \qbb[yellow][12,14,17]
2012 }\\
2013 &=\q[scale=0.6]{
2014 \qcap[s=4]\qwire\n
2015 \qloop[3]{\qwire}\qbraidinv\n
2016 \qloop[3]{\qwire}\qbraid\qwire[vlen=3]\n
2017 \qwire\qwire\qcup[n=4]
2018 \qbb[green][6,10]
2019 }\stackrel{\text{(\ref{eq:inverse:braid})}}{=}\q[scale=0.6]{
2020 \qcap[s=4]\qwire\qwire\n[2]
2021 \qloop[6]{\qwire[vlen=2]}\n
2022 \qwire\qwire\qcup[n=4]
2023 \qbb[green][7,8]
2024 }\\
2025 &\stackrel{\text{(\ref{eq:snake})}}{=}\q{
2026 \qwire\qwire
2027 \symbolI{\(X\)}[id=1]\symbolO{\(X\)}[id=1]
2028 \symbolI{\(X\)}\symbolO{\(X\)}
2029 }
2030 \end{align*}
2031 \end{CODEBOX}
2032
2033 \begin{CODEBOX}{クローン禁止定理}{thm:nocopy}
2034 \begin{align*}
2035 \q{
2036 \qasym[name={\(f\)}]
2037 \symbolI{\(X\)}\symbolO{\(X\)}
2038 }&\stackrel{\text{(\ref{eq:snake})}}{=}
2039 \q{
2040 \qcap\qasym[name={\(f\)}]\n
2041 \qwire\qcup
2042 }\stackrel{\text{(\ref{eq:inverse:braid})}}{=}\q{
2043 \qcap\qasym[name={\(f\)}]\n
2044 \qwire\qbraidinv\n
2045 \qwire\qbraid\n
2046 \qwire\qcup
2047 }\stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q{
2048 \qcap\qwire\n
2049 \qwire\qbraidinv\n
2050 \qwire\qasym[name={\(f\)}]\qwire\n
2051 \qwire\qbraid\n
2052 \qwire\qcup
2053 \qbb[red][1,4]
2054 }\\
2055 &=\q{
2056 \qwire\qcap\n
2057 \qbraid\qwire\n
2058 \qwire\qasym[name={\(f\)}]\qwire\n
2059 \qwire\qbraid\n
2060 \qwire\qcup
2061 \qbb[red][1,4]
2062 }=\q{
2063 \qwire\qcap\n
2064 \qbraid\qwire\n
2065 \qwire\qasym[name={\(f\)}]\qwire\n
2066 \qwire\qbraid\n
2067 \qwire\qcup
2068 \qbb[blue][3]
2069 }\stackrel{\text{例 \ref{len:copybraid}}}{=}\q{
2070 \qwire\qcap\n
2071 \qwire\qwire\qwire\n
2072 \qwire\qasym[name={\(f\)}]\qwire\n
2073 \qwire\qbraid\n
2074 \qwire\qcup
2075 \qbb[blue][3,4]
2076 }
2077 \end{align*}
2078 \end{CODEBOX}
2079 \subsection{ピボタル圏}
2080 \label{subsec:pivotal}
2081 \begin{CODEBOX}{}{struct:Pivotal}
2082 \begin{equation}
2083 \label{cond:naturality:pivotal}
2084 \forall\q{\qasym[name={\(f\)}]\symbolI{\(X\)}\symbolO{\(Y\)}}\colon
2085 \q[scale=0.5]{
2086 \qwire\qcap[s=4]\n
2087 \qwire\qwire\qasym[name={\(f\)}]\qwire\qwire\n
2088 \qcup[n=4]\qwire\qmv[-1,-1]\qasym[name={\(\pi_X\)}]
2089 }=\q{
2090 \qasym[name={\(\pi_Y\)}]\n
2091 \qasym[name={\(f\)}]
2092 }
2093 \end{equation}
2094 \end{CODEBOX}
2095 \begin{CODEBOX}{}{dualrev}
2096 \begin{equation}
2097 \label{def:dualrev}
2098 \q{
2099 \qcaprev\n
2100 \symbolI{\(X^T\)}\symbolI[2]{\(X\)}
2101 }\coloneq\q
2102 {
2103 \qcap \n
2104 \qwire \qwireupup \n
2105 \qwire \qasym[name={\(\pi_x\)}] \n
2106 }\qquad\q{
2107 \qcuprev
2108 \symbolO{\(X\)}\symbolO[2]{\(X^T\)}
2109 }\coloneq\q
2110 {
2111 \qasym[name={\(\pi_X^{-1}\)}]\qwire\n
2112 \qwireupup\qwire\n
2113 \qcup
2114 }
2115 \end{equation}
2116 \end{CODEBOX}
2117 \begin{CODEBOX}{}{revSliding}
2118 \begin{equation}
2119 \label{eq:sliding:rev}
2120 \q{
2121 \qcaprev\n
2122 \qtrans\qwire\n
2123 }=\q{
2124 \qcaprev\n
2125 \qwire\qasym
2126 }\qquad\q{
2127 \qwire\qtrans\n
2128 \qcuprev
2129 }=\q{
2130 \qasym\qwire\n
2131 \qcuprev
2132 }
2133 \end{equation}
2134 \end{CODEBOX}
2135 \begin{CODEBOX}{}{corr:pivotal:twist}
2136 \begin{gather}
2137 \q{
2138 \qwireuu[label={\(X^{TT}\)}]\n
2139 \qasym[name={\(\pi_X\)}]\n
2140 \qwireup[label={\(X\)}]
2141 }=\q{
2142 \qwireuu[label={\(X^{TT}\)}]\qcap\n
2143 \qbraid\qwired[label={\(X^T\)}]\n
2144 \qasym[name={\(\theta_X^{-1}\)}]\qcuprev\n
2145 \qwireup[label={\(X\)}]
2146 }\label{twist:pivotal}\\
2147 \q{
2148 \qwireup[label={\(X\)}]\n
2149 \qasym[name={\(\theta_X\)}]\n
2150 \qwireup[label={\(X\)}]
2151 }=\q{
2152 \qwireup[label={\(X\)}]\n
2153 \qasym[name={\(\pi_X^{-1}\)}]\n
2154 \qwireuu[label={\(X^{TT}\)}]\qcap\n
2155 \qbraid\qwired[label={\(X^T\)}]\n
2156 \qwire[label={\(X\)}]\qcuprev
2157 }\label{pivotal:twist}
2158 \end{gather}
2159 \end{CODEBOX}
2160 \begin{CODEBOX}{}{ex193477432894100303}
2161 \begin{align*}
2162 \q{\qasym[name={\(\theta_X\)}]}
2163 &=\q{
2164 \qwireu[label={\(X\)}]\qcap\n
2165 \qbraid\qwired\n
2166 \qwireu[label={\(X\)}]\qcuprev
2167 }&\q{\qasym[name={\(\theta_X^{-1}\)}]}
2168 &=\q{
2169 \qcaprev\qwireu[label={\(X\)}]\n
2170 \qwired\qbraidinv\n
2171 \qcup\qwireu[label={\(X\)}]
2172 }\\
2173 \q{\qtrans[name={\(\theta_X\)}]}
2174 &=\q{
2175 \qcap\qwired[label={\(X^T\)}]\n
2176 \qwireu\qbraid\n
2177 \qcuprev\qwired[label={\(X^T\)}]
2178 }&\q{\qtrans[name={\(\theta_X^{-1}\)}]}
2179 &=\q{
2180 \qwired[label={\(X^T\)}]\qcaprev\n
2181 \qbraidinv\qwireu\n
2182 \qwired[label={\(X^T\)}]\qcup
2183 }
2184 \end{align*}
2185 \end{CODEBOX}
2186 \begin{CODEBOX}{リボン圏}{code:def:ribboncategory}
2187 \begin{equation}
2188 \label{def:ribboncategory}
2189 \q{
2190 \qwired\qcaprev\n
2191 \qbraid\qwireu\n
2192 \qwired\qcup
2193 }=\q{
2194 \qcap\qwired\n
2195 \qwireu\qbraid\n
2196 \qcuprev\qwired
2197 }
2198 \end{equation}
2199 \end{CODEBOX}
2200
2201 \subsubsection{トレース}
2202 \label{subsub:trace}
2203 \begin{CODEBOX}{トレース}{Trdef}
2204 \[
2205 \begin{array}{rccc}
2206 \operatorname{Tr}\colon & \operatorname{Hom}(X,X) & \to &\operatorname{Hom}(I,I)\\
2207 &\rotatebox{90}{\(\in\)}&&\rotatebox{90}{\(\in\)}\\
2208 &\q{
2209 \qasym[name={\(f\)}]
2210 } & \mapsto & \q{
2211 \qcap\n
2212 \qasym[name={\(f\)}]\qwire\n
2213 \qcuprev
2214 }
2215 \end{array}
2216 \]
2217 \end{CODEBOX}
2218
2219 \begin{CODEBOX}{トレースの可換性}{Cotr}
2220 \begin{equation}
2221 \label{cmt:trace}
2222 \operatorname{Tr}\left(\q{
2223 \qasym[name={\(g\)}]\n
2224 \qasym[name={\(f\)}]
2225 }\right)
2226 =\q{
2227 \qcap\n
2228 \qasym[name={\(g\)}]\qwire\n
2229 \qasym[name={\(f\)}]\qwire\n
2230 \qcuprev
2231 }
2232 \stackrel{\text{(\ref{eq:sliding})}}{=}\q{
2233 \qcap\n
2234 \qasym[name={\(f\)}]\qtrans[name={\(g\)}]\n
2235 \qcuprev
2236 }\stackrel{\text{(\ref{eq:sliding:rev})}}{=}\q{
2237 \qcap\n
2238 \qasym[name={\(f\)}]\qwire\n
2239 \qasym[name={\(g\)}]\qwire\n
2240 \qcuprev
2241 }=\operatorname{Tr}\left(\q{
2242 \qasym[name={\(f\)}]\n
2243 \qasym[name={\(g\)}]
2244 }\right)
2245 \end{equation}
2246 \end{CODEBOX}
2247 \begin{CODEBOX}{対象の次元}{def:dim}
2248 \[
2249 \q{\qscalar[name={\(\operatorname{dim}(X)\)}]}
2250 \coloneq\q{\qscalar[name={\(\operatorname{Tr}(\operatorname{id}_X)\)}]}
2251 =\q{\qcap\n\qcuprev}
2252 \]
2253 \end{CODEBOX}
2254 \subsubsection{コンパクト圏}
2255 \label{subsubsec:compact}
2256 \begin{CODEBOX}{コンパクト圏}{Def:compact}
2257 \begin{equation}
2258 \label{def:compact}
2259 \q{\qasym[name={\(\pi_X\)}]}=\q{
2260 \qwireuu[label={\(X^{TT}\)}]\qcap\n
2261 \qsym\qwired[label={\(X^T\)}]\n
2262 \qwire[label={\(X\)}]\qcuprev
2263 }
2264 \end{equation}
2265 \end{CODEBOX}
2266 \subsubsection{色}
2267 \label{subsubsec:duality:color}
2268 \begin{CODEBOX}{}{Ex:coloredhopflink}
2269 \begin{equation}
2270 \label{eq:tr:hopf}
2271 \operatorname{Tr}\left(
2272 \q{
2273 \qbraid[L color=blue, R color=orange]\n
2274 \qbraid[L color=orange, R color=blue]}
2275 \right)
2276 =\q{
2277 \qcap[hlen=4, frame color=orange]\n
2278 \qwire[color=orange]\qcap[frame color=blue]\n
2279 \qbraid[L color=blue, R color=orange]\n
2280 \qbraid[L color=orange, R color=blue
2281 ]\qwiredown[vlen=2, color=blue]\n
2282 \qwire[color=orange]
2283 \qcuprev[frame color=blue]
2284 \qwiredown[vlen=4, color=orange]\n
2285 \qcuprev[hlen=4, frame color=orange]
2286 }=\q{
2287 \qcap[frame color=blue]
2288 \qcap[frame color=orange]\n
2289 \qspace
2290 \qbraidinv[L color=orange, R color=blue]\n
2291 \qwireup[vlen=2, color=blue]
2292 \qbraidinv[L color=blue, R color=orange]
2293 \qwiredown[vlen=2, color=orange]\n
2294 \qcuprev[frame color=blue]
2295 \qcuprev[frame color=orange]
2296 }
2297 \end{equation}
2298 \end{CODEBOX}
2299 \subsection{ダガー}
2300 \label{subsec:dagger}
2301 \subsubsection{随伴ボックス}
2302 \label{subsub:adjoint}
2303 \begin{CODEBOX}{随伴}{def:adj}
2304 \begin{gather}
2305 \left(
2306 \q{
2307 \qasym[name={\(f\)}]
2308 \symbolI{\(X\)}\symbolO{\(Y\)}
2309 }
2310 \right)^{\dagger}
2311 \coloneq
2312 \q{
2313 \qadj[name={\(f\)}]
2314 \symbolI{\(Y\)}\symbolO{\(X\)}
2315 }\\
2316 \left(\q{\qasym[name={\(f\)}]}\right)^{\dagger\dagger}
2317 =\left(\q{\qadj[name={\(f\)}]}\right)^{\dagger}
2318 =\q{\qasym[name={\(f\)}]}\\
2319 \left(\q{\qwire}\right)^{\dagger}=\q{\qwire}\\
2320 \q{
2321 \qadj[name={\(f\)}]\n
2322 \qadj[name={\(g\)}]
2323 }=\q{
2324 \qadj[name={\(g\circ f\)}]
2325 }
2326 \end{gather}
2327 \end{CODEBOX}
2328 \subsubsection{共役ボックス}
2329 \label{subsub:conj}
2330 \begin{CODEBOX}{}{prep:conj}
2331 \begin{align*}
2332 \left(\q{\qadj}\right)^T
2333 &=\q{
2334 \qwire\qcap\n
2335 \qwire\qadj\qwire\n
2336 \qcup\qwire
2337 }=\q{
2338 \qcaprev\qwire\n
2339 \qwire\qadj\qwire\n
2340 \qwire\qcuprev
2341 }=\left(
2342 \q{
2343 \qwire\qcap\n
2344 \qwire\qasym\qwire\n
2345 \qcup\qwire
2346 }
2347 \right)^{\dagger}=\left(\q{\qtrans}\right)^{\dagger}
2348 \end{align*}
2349 \end{CODEBOX}
2350 \section{素子一覧}
2351 \label{sec:fcommands}
2352 \begin{tcbraster}[raster columns=4,raster equal height=rows,fonttitle=\bfseries,
2353 colframe=cyan!90,coltitle=cyan!50,colbacktitle=black,
2354 subtitle style={boxrule=0.4pt,
2355 colback=black!70}
2356 ]
2357 \begin{tcolorbox}[adjusted title={\showcmd{qwire}[cyan]}]
2358 \[\q{\qwire}\]
2359 \end{tcolorbox}
2360 \begin{tcolorbox}[adjusted title={\showcmd{qbox}[cyan]}]
2361 \[
2362 \q{
2363 \qbox
2364 }
2365 \]
2366 \end{tcolorbox}
2367 \begin{tcolorbox}[adjusted title={\showcmd{qstate}[cyan]}]
2368 \[
2369 \q{
2370 \qstate
2371 }
2372 \]
2373 \end{tcolorbox}
2374 \begin{tcolorbox}[adjusted title={\showcmd{qeffect}[cyan]}]
2375 \[
2376 \q{
2377 \qeffect
2378 }
2379 \]
2380 \end{tcolorbox}
2381 \begin{tcolorbox}[adjusted title={\showcmd{qscalar}[cyan]}]
2382 \[
2383 \q{
2384 \qscalar
2385 }
2386 \]
2387 \end{tcolorbox}
2388 \begin{tcolorbox}[adjusted title={\showcmd{qunitob}[cyan]}]
2389 \[
2390 \q{
2391 \qunitob
2392 }
2393 \]
2394 \end{tcolorbox}
2395 \begin{tcolorbox}[adjusted title={\showcmd{qmul}[cyan]}]
2396 \[
2397 \q{
2398 \qmul[hlen=2]
2399 }
2400 \]
2401 \end{tcolorbox}
2402 \begin{tcolorbox}[adjusted title={\showcmd{qcomul}[cyan]}]
2403 \[
2404 \q{
2405 \qcomul[hlen=2]
2406 }
2407 \]
2408 \end{tcolorbox}
2409 \begin{tcolorbox}[adjusted title={\showcmd{qunit}[cyan]}]
2410 \[
2411 \q{
2412 \qunit
2413 }
2414 \]
2415 \end{tcolorbox}
2416 \begin{tcolorbox}[adjusted title={\showcmd{qcounit}[cyan]}]
2417 \[
2418 \q{
2419 \qcounit
2420 }
2421 \]
2422 \end{tcolorbox}
2423 \begin{tcolorbox}[adjusted title={\showcmd{qspider}[cyan]}]
2424 \[
2425 \q{
2426 \qspider[p=4,hlen=2]
2427 }
2428 \]
2429 \end{tcolorbox}
2430 \begin{tcolorbox}[adjusted title={\showcmd{qbraid}[cyan]}]
2431 \[
2432 \q{
2433 \qbraid
2434 }
2435 \]
2436 \end{tcolorbox}
2437 \begin{tcolorbox}[adjusted title={\showcmd{qbraidinv}[cyan]}]
2438 \[
2439 \q{
2440 \qbraidinv
2441 }
2442 \]
2443 \end{tcolorbox}
2444 \begin{tcolorbox}[adjusted title={\showcmd{qsym}[cyan]}]
2445 \[
2446 \q{
2447 \qsym
2448 }
2449 \]
2450 \end{tcolorbox}
2451 \begin{tcolorbox}[adjusted title={\showcmd{qcap}[cyan]}]
2452 \[
2453 \q{
2454 \qcap
2455 }
2456 \]
2457 \end{tcolorbox}
2458 \begin{tcolorbox}[adjusted title={\showcmd{qcup}[cyan]}]
2459 \[
2460 \q{
2461 \qcup
2462 }
2463 \]
2464 \end{tcolorbox}
2465 \begin{tcolorbox}[adjusted title={\showcmd{qwireu}[cyan]}]
2466 \[\q{\qwireup}\]
2467 \end{tcolorbox}
2468 \begin{tcolorbox}[adjusted title={\showcmd{qwired}[cyan]}]
2469 \[\q{\qwiredown}\]
2470 \end{tcolorbox}
2471 \begin{tcolorbox}[adjusted title={\showcmd{qwireuu}[cyan]}]
2472 \[\q{\qwireuu}\]
2473 \end{tcolorbox}
2474 \begin{tcolorbox}[adjusted title={\showcmd{qwiredd}[cyan]}]
2475 \[\q{\qwiredd}\]
2476 \end{tcolorbox}
2477 \begin{tcolorbox}[adjusted title={\showcmd{qasym}[cyan]}]
2478 \[
2479 \q{
2480 \qasym
2481 }
2482 \]
2483 \end{tcolorbox}
2484 \begin{tcolorbox}[adjusted title={\showcmd{qtrans}[cyan]}]
2485 \[
2486 \q{
2487 \qtrans
2488 }
2489 \]
2490 \end{tcolorbox}
2491 \begin{tcolorbox}[adjusted title={\showcmd{adj}[cyan]}]
2492 \[
2493 \q{
2494 \qadj
2495 }
2496 \]
2497 \end{tcolorbox}
2498 \begin{tcolorbox}[adjusted title={\showcmd{qconj}[cyan]}]
2499 \[
2500 \q{
2501 \qconj
2502 }
2503 \]
2504 \end{tcolorbox}
2505 \begin{tcolorbox}[adjusted title={\showcmd{qcaprev}[cyan]}]
2506 \[
2507 \q{
2508 \qcaprev
2509 }
2510 \]
2511 \end{tcolorbox}
2512 \begin{tcolorbox}[adjusted title={\showcmd{qcuprev}[cyan]}]
2513 \[
2514 \q{
2515 \qcuprev
2516 }
2517 \]
2518 \end{tcolorbox}
2519 \end{tcbraster}
2520 \addcontentsline{toc}{section}{参考文献}
2521 \begin{thebibliography}{99}
2522 \bibitem{tikz-manual}
2523 Till Tantau,
2524 \textit{The TikZ and PGF Packages Manual for Version 3.1.10},
2525 Institut für Theoretische Informatik, Universität zu Lübeck,
2526 n.d.,
2527 \url{https://github.com/pgf-tikz/pgf}
2528 (retrieved March 22, 2025).
2529 \bibitem{geniussorting}
2530 Anonymous,
2531 \textit{Genius Sorting Algorithm},
2532 4chan Programming Board,
2533 January 20, 2011,
2534 \url{https://dis.4chan.org/read/prog/1295544154}
2535 (accessed January 20, 2011; link currently inactive).
2536 \bibitem{gfxhatena}
2537 gfx,
2538 \textit{常識を覆すソートアルゴリズム!その名も"sleep sort"!},
2539 Hatena Diary,
2540 May 19, 2011,
2541 \url{https://gfx.hatenadiary.org/entry/20110519/1305810786}.
2542 \bibitem{literateprograms}
2543 LiteratePrograms,
2544 \textit{Turing Machine Simulator in \LaTeX},
2545 \url{https://literateprograms.org/turing_machine_simulator__latex_.html},
2546 n.d.,
2547 retrieved March 22, 2025.
2548 \bibitem{overleaf}
2549 Overleaf,
2550 \textit{\LaTeX\ is More Powerful than You Think: Computing the Fibonacci Numbers and Turing Completeness},
2551 \url{https://www.overleaf.com/learn/latex/Articles/LaTeX_is_More_Powerful_than_you_Think_-_Computing_the_Fibonacci_Numbers_and_Turing_Completeness},
2552 n.d.,
2553 retrieved March 22, 2025.
2554 \end{thebibliography}
2555 \begin{changelog}[author=新名亮太, sectioncmd=\section*]
2556
2557 \shortversion{v=1.1.2, date=2025-07-28,
2558 changes={英語版ドキュメンテーション (qworld\_en.pdf) および対応する\TeX\ ソースファイル (qworld\_en.tex) のタイプミスを修正した. この変更は英語版ドキュメンテーション (qworld\_en.pdf) と\TeX\ ソースファイル (qworld\_en.tex) のみに影響し, スタイルファイルには影響しない. }
2559 }
2560
2561 \begin{version}[v=1.1.1, date=2025-04-14]
2562 \added
2563 \item 彩色機能\par 図式表現において, 組紐, シンメトリー, キャップ, カップ等に対して色属性を指定できるようになった. 対象の識別に有効な視覚的手がかりを提供する.
2564 \fixed
2565 \item ワイヤーや組紐, シンメトリー, キャップ, カップの曲線処理が修正され, より滑らかな描画が可能となった.
2566 \end{version}
2567
2568 \begin{version}[v=1.1.0,date=2025-04-03]
2569 \changed
2570 \item コマンドの引数仕様の刷新\par 以下のコマンドがアップデートされ, 従来の必須引数から柔軟なキーバリュー形式の柔軟なオプション引数へと変更された:
2571 \begin{itemize}
2572 \item \showcmd{symbolI}
2573 \item \showcmd{symbols}
2574 \item \showcmd{symbolS}
2575 \item \showcmd{symbolO}
2576 \item \showcmd{symboln}
2577 \item \showcmd{symbolN}
2578 \end{itemize}
2579 \begin{description}
2580 \item[旧仕様] \showcmd{symbolI[i]\{ID\}\{text\}[位置オプション]}[old]
2581 \item[新仕様] \showcmd{symbolI[i]\{text\}[id=ID, 位置オプション]}[new]
2582 \end{description}
2583 この変更により, \showcmd[]{ID}の指定を省略できるようになり, 従来の\showcmd{symbolI\{ID\}\{text\}}[old]に比べ, \showcmd[]{ID}が不要な場面では\showcmd{symbolI\{text\}}[new]と記述するだけで済むようになった. 結果として, 記述量が削減されコードの可読性が向上した.
2584 \added
2585 \item 英語のドキュメントの追加\par パッケージのユーザーガイド (英語版) を新たに追加した.
2586 \end{version}
2587
2588 \shortversion{v=1.0.0,
2589 date=2025-04-01,
2590 changes={初回リリース}
2591 }
2592 \end{changelog}
2593 \section*{License and Copyright}
2594
2595 This package is distributed under the \textbf{LaTeX Project Public License (LPPL)}, version 1.3c or later.
2596 For details, see \url{https://www.latex-project.org/lppl.txt}.
2597
2598 Copyright \textcopyright 2025 Niina Ryota
2599
2600 You are free to distribute and modify this package under the terms of LPPL.
2601 However, any modified versions \textbf{must not} be distributed under the original name, and the original author must be credited.
2602 \end{document}