\documentclass{ltjsarticle}

\usepackage{qworld}

\usepackage{bookmark}
\usepackage{fontspec}
\usepackage{pdfpages}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{ascmac}
\usepackage{fancybox}
\usepackage{float}
\usepackage{xparse}
\usepackage{bbm}
\usepackage{mathrsfs}
%\numberwithin{equation}{subsection}

\usepackage{changelog}

\usepackage{framed}
\newenvironment{longshadowbox}{%
  \def\FrameCommand{\fboxsep=\FrameSep \shadowbox}%
  \MakeFramed {\FrameRestore}}%
{\endMakeFramed}

\usepackage{url}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue}

\usepackage{iitem}

\usepackage{multirow}

\usepackage{here}

\usepackage{fontawesome}

\usepackage{xspace}
\newcommand{\qworldname}{\texttt{QWorld}\xspace}
\newcommand{\tikzname}{Ti\emph{k}Z\xspace}
\newcommand{\texlivename}{\TeX{} \textsf{Live}\xspace}

\setcounter{tocdepth}{3}

\usepackage{listings}
\lstset{basicstyle=\ttfamily}
\usepackage[most]{tcolorbox}
\newtcblisting{mybox}[2][]{%
  colback=red!5!white,
  colframe=red!75!black,
  fonttitle=\bfseries,
  title=#2,
  #1
}

\tcbset
{
  codeinfo/.style=
  { 
    colframe=cyan!90,
    coltitle=cyan!60,
    colbacktitle=black,
    fonttitle=\small\sffamily\bfseries, 
    fontupper=\small, 
    fontlower=\small
  },
  exampletitleinfo/.style 2 args=
  {
    codeinfo,
    title={例 \thetcbcounter #1},
    label={#2}
  },
  failurecodeinfo/.style=
  {
    colframe=red!90,
    coltitle=red!60, 
    colbacktitle=black,
    fonttitle=\small\sffamily\bfseries, 
    fontupper=\small, 
    fontlower=\small
  },
  failureexampletitleinfo/.style 2 args=
  {
    failurecodeinfo,
    title={失敗例 \thetcbcounter #1},
    label={#2}
  }
}
\newtcblisting{texexp}[1]
{
  codeinfo,
  #1
}
\newtcblisting[auto counter,number within=section]{codebox}[3][center lower,listing side text,righthand width=3.5cm,bicolor,colbacklower=white]
{
  exampletitleinfo={#2}{#3},
  breakable,
  #1
}

\newtcblisting[use counter from=codebox,number within=section]{CODEBOX}[3][center lower,bicolor,colbacklower=white]
{
  exampletitleinfo={#2}{#3},
  breakable,
  #1
}
\newtcolorbox[use counter from=codebox]{codeboxspec}[3][]
{
  exampletitleinfo={#2}{#3},
  breakable,
  #1
}
\newtcblisting{texfexp}[1]
{
  failurecodeinfo,
  #1
}
\newtcblisting[auto counter,number within=section]{fcodebox}[3][center lower,listing side text,righthand width=3.5cm,bicolor,colbacklower=white]
{
  failureexampletitleinfo={#2}{#3},
  breakable,
  #1
}

\newtcblisting[use counter from=fcodebox,number within=section]{FCODEBOX}[3][center lower,bicolor,colbacklower=white]
{
  failureexampletitleinfo={#2}{#3},
  breakable,
  #1
}
\newtcolorbox[use counter from=fcodebox]{fcodeboxspec}[3][]
{
  failureexampletitleinfo={#2}{#3},
  breakable,
  #1
}

\usepackage{xcolor}
\NewDocumentCommand{\showcmd}{O{\textbackslash} m O{black}}{%
    \leavevmode%
    \ifthenelse{\equal{#3}{new}}{%
        \textcolor{green!50!black}{\texttt{#1#2}}%
    }{%
        \ifthenelse{\equal{#3}{old}}{%
            \textcolor{red}{\texttt{#1#2}}%
        }{%
            \textcolor{#3}{\texttt{#1#2}}%
        }%
    }%
}

\begin{document}
% \title{
%     \Huge \textbf{\qworldname}\\[4pt]
%     \scriptsize\texttt{Version 1.1.1} \\[4pt]
% }
% \author{
%     \textbf{新名 亮太} \\[4pt]
% }
% \date{\today}
% \maketitle

\begin{titlepage}
  \centering
\vspace*{2.5cm}

% パッケージ名とバージョン
{\Huge\bfseries The QWorld\par}
\vspace{1ex}

% {\large A \LaTeX{} package for diagrammatic reasoning\\
% in monoidal categories and categorical quantum mechanics\par}

{\large モノイダル圏および量子力学のためのストリング図式生成\par}
\vspace{2ex}

{\normalsize\ttfamily v1.1.2\par}

\vspace{3cm}

% 著者情報
{\large\bfseries 新名亮太\par}
\vspace{1ex}
\href{qworld-package@googlegroups.com}
   {\normalsize\ttfamily qworld-package@googlegroups.com}

\vfill

% 日付
{\today}
\end{titlepage}

\begin{abstract}
  \qworldname は, モノイダル圏における図式計算を直感的かつ効率的に描画するために設計された\LaTeX パッケージである. 
  特に, 圏論的手法が重要な役割を果たす量子論, トポロジカル量子計算, 及び関連分野における図式的推論の可視化を支援する. 
  本パッケージは\tikzname\cite{tikz-manual} を基盤としており, シンプルなコマンドで複雑な図式を容易に描画できる. 
\end{abstract}

\tableofcontents

\section{導入}
本稿では, \qworldname パッケージのインストール方法, 基本的な使用法, 応用例を体系的に解説する. 
\qworldname は, モノイダル圏に基づく図式言語の組版に特化した\LaTeX パッケージであり, 
モノイダル圏, フロベニウス構造, 組紐, ホップ代数, シンメトリー, 双対性, ピボタル構造, ダガーなど, 多岐にわたる圏論的概念を図式表現するための直感的なコマンドセットを提供する.  

\section{基本的な使い方}
\subsection{基本要素}
\qworldname パッケージのの最も基本的なコマンドを以下に示す. 
これらは図式を描画するための基礎となる. 
\begin{itemize}
  \item \showcmd{q}: 図の素子を配置するためのキャンバス.
  \item \showcmd{qbox}: ボックス\q[scale=0.5]{\qbox}の描画.
  \item \showcmd{qwire}: ワイヤー\q[scale=0.5]{\qwire}の描画.
  \item \showcmd{qcirc}: 合成.
\end{itemize}
  これらのコマンドは, キャンバスである\verb|\q{...}|内に記述する. 
  例えば\verb|\q{\qbox}|と記述すると, ボックス\q[scale=0.5]{\qbox}が描画される.\par
  \(\q[scale=0.5]{\qbox}\)と\(\q[scale=0.5]{\qbox}\)を合成するためには, \verb|\qcirc|を使用する. 
  これは数学における合成\(g\circ f\) (\verb|\(g\circ f\)|) と似ている. 
  \begin{codebox}{}{Ex:7812973891217}
    \q{ \qbox \qcirc \qbox }
  \end{codebox}
  また, \verb|\qbox| を並置すると, 描画結果でもボックス\(\q[scale=0.5]{\qbox}\)が横に並ぶ:
  \begin{codebox}{}{boxs2}
    \q{ \qbox \qbox \qbox }
  \end{codebox}
  \verb|\qcirc| を用いて複数のボックスを合成することも可能である:
  \begin{codebox}{}{boxsbr}
      \q
      {
        \qbox \qbox \qbox
          \qcirc
        \qbox \qbox \qbox
      }
  \end{codebox}
  なお, \verb|\n|は\verb|\qcirc|と同義である:
  \begin{codebox}{}{boxsn}
    \q
    {
      \qbox \qbox \qbox \n
      \qbox \qbox \qbox
    }
\end{codebox}
\begin{codebox}{}{ex:hopflink}
  \q{
    \qcaprev \qcap          \n
    \qwire   \qbraid \qwire \n
    \qwire   \qbraid \qwire \n
    \qcup    \qcuprev
  }
\end{codebox}
\verb|\qcaprev|は\q[scale=0.6]{\qcaprev}を, 
\verb|\qcap|は\q[scale=0.6]{\qcap}を, 
\verb|\qwire|は\q[scale=0.5]{\qwire}を, 
\verb|\qbraid|は\q[scale=0.5]{\qbraid}を, 
\verb|\qcup|は\q[scale=0.6]{\qcup}を, 
\verb|\qcuprev|は\q[scale=0.6]{\qcuprev}を, 各々描画する. 
全体として, コマンドの配置の通りに描画されていることが分かる.\par
\subsection{数式モード}
図式言語を含んだ数式を記述する場合は, 数式モードを使用する. 
\begin{CODEBOX}{}{IntroEx}
  \[
    \operatorname{Tr}\left(
      \q{
        \qbraid\n
        \qbraid
      }
    \right)
    =\q{
      \qcap    \qcap             \n
      \qwire   \qbraidinv \qwire \n
      \qwire   \qbraidinv \qwire \n
      \qcuprev \qcuprev
    }
  \]
\end{CODEBOX}

\subsection{インストール}
\qworldname パッケージのスタイルファイル\showcmd[]{qworld.sty}は, \href{https://ctan.org/pkg/qworld}{CTAN}上の以下のページから入手可能である:
\begin{center}
  \url{https://ctan.org/pkg/qworld}
\end{center} 
ダウンロードしたファイルを\TeX のパッケージディレクトリに配置し, 
プリアンブルに以下を記述することで使用可能となる:
\begin{verbatim}
  \usepackage{qworld}
\end{verbatim}

パッケージが\TeX ディストリビューションに含まれている場合は, \showcmd[]{tlmgr}や\showcmd[]{MiKTeX Console}などを利用してインストールすることもできる.

\paragraph{依存関係}
依存パッケージは以下の通りである:
\begin{itemize}
    \item \tikzname
      \iitem \showcmd[]{cd}
      \iitem \showcmd[]{positioning}
      \iitem \showcmd[]{arrows}
      \iitem \showcmd[]{arrows.meta}
      \iitem \showcmd[]{calc}
      \iitem \showcmd[]{intersections}
      \iitem \showcmd[]{shapes.symbols}
      \iitem \showcmd[]{shapes.geometric}
      \iitem \showcmd[]{shapes.misc}
      \iitem \showcmd[]{decorations.pathreplacing}
      \iitem \showcmd[]{decorations.markings}
      \iitem \showcmd[]{decorations.pathmorphing}
    \item \showcmd[]{pgffor}
    \item \showcmd[]{ifthen}
    \item \showcmd[]{xparse}
    \item \showcmd[]{xfp}
    \item \showcmd[]{xstring}
\end{itemize}
これらのパッケージは\texlivename ディストリビューションに標準で含まれており, 特別な手間をかける必要はない. 
\section{基本的なカスタマイズ}
本節では, \qworldname のコマンドをカスタマイズする方法を解説する.
\subsection{識別番号}

\verb|\q{...}|内に配置された全てのコマンドには, 実行順に基づいて自動的に固有の識別番号が割り当てられる. 
例えば, 先の例 \ref{boxsn} では各\verb|\qbox|に番号が振られる:
\[\q{\qloop[2]{\qloop[3]{\qbox[show id={true}]}\n}}\]
詳細は, \pageref{subsec:showid}ページの\ref{subsec:showid}節を参照せよ.

\subsection{バウンディングボックス}

\[\q{
  \qcaprev \qcap           \n
  \qwire   \qbraid  \qwire \n
  \qwire   \qbraid \qwire \n
  \qcup    \qcuprev
  \qbb[red][1,2]
    \bbsymbol{Measure}
    \bbsymbol[W]{Output}[left]
    \bbsymbol[NW]{Computation}[above left]
    \bbsymbol[NE]{Physics}[above right]
  \qbb[yellow][3,5,6,8]
    \bbsymbol{Braid}
    \bbsymbol[W]{Compute}[left]
  \qbb[cyan][9,10]
    \bbsymbol{Create}
    \bbsymbol[W]{Initialize}[left]
}\]

各素子には, バウンディングボックスが付随する. 
以下に例を示す:
\begin{itemize}
  \item \q{\qcaprev}のバウンディングボックスを可視化すると\q{\qcaprev\qbball}.
  \item \q{\qbraid}のバウンディングボックスを可視化すると\q{\qbraid\qbball}.
  \item \q{\qwire}のバウンディングボックスを可視化すると\q{\qwire\qbball}.
  \item \q{\qcuprev}のバウンディングボックスを可視化すると\q{\qcuprev\qbball}.
\end{itemize}
バウンディングボックスを可視化するコマンドと, 
可視化したバウンディングボックス近辺にテキストを置くコマンドは次の通りである:
\begin{itemize}
  \item 可視化
    \iitem \showcmd{qbb}: 特定の素子のバウンディングボックスを表示.
    \iitem \showcmd{qbball}: 全ての素子のバウンディングボックスを一度に表示.
    \iitem \showcmd{qBBall}: キャンバス全体を囲むバウンディングボックスをを表示.
  \item テキストを置く
    \iitem \showcmd{bbsymbol}: バウンディングボックスにテキストを配置.
\end{itemize}

\begin{verbatim}
  \qbb[<色>][<ID列>]
\end{verbatim}
\begin{itemize}
  \item 第一引数 (オプション): 色を指定. 未指定の場合は無色. 
  \item 第二引数: 対象となる素子の識別番号のリストを指定し, それらを含むバウンディングボックスを表示.
\end{itemize}
\begin{codebox}{}{Ex:7812973891220}
  \q{\qbox\qbb[1]}
\end{codebox}
\begin{codebox}{}{ex:78129738912270454}
  \q{
    \qcaprev \qcap          \n
    \qwire   \qbraid \qwire \n
    \qwire   \qbraid \qwire \n
    \qcup    \qcuprev
    \qbb[4,7]
  }
\end{codebox}
\begin{CODEBOX}{}{Ex:7812973891221}
  \q{\qbox\qbox\qbox\qbox\qbox\qbox\qbb[yellow][2,...,5]}
\end{CODEBOX}
\begin{codebox}{}{Ex:74839722}
  \q
  {
    \qbox\qbox\qbox\n
    \qbox\qbox\qbox
    \qbb[green][2,5]
  }
\end{codebox}
\begin{codebox}{}{Ex:7812973891218}
  \q{
    \qcaprev \qcap          \n
    \qwire   \qbraid \qwire \n
    \qwire   \qbraid \qwire \n
    \qcup    \qcuprev
    \qbb[blue][4,7]
  }
\end{codebox}
\begin{verbatim}
  \qbball[<色>]
\end{verbatim}
複数 (一個でも良いが) のバウンディングボックスを一度に可視化する. 
\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{Ex:78129738912270511}
  \q{
    \qcaprev \qcap          \n
    \qwire   \qbraid \qwire \n
    \qwire   \qbraid \qwire \n
    \qcup    \qcuprev
    \qbball
  }
\end{codebox}
各素子のバウンディングボックスが重なることなく組み合っていることが判る. 
\qworldname パッケージは, 図式描画に伴う\textbf{細かく面倒な座標設定の多くを省略できる}.

\begin{verbatim}
  \qBBall[<色>]
\end{verbatim}
キャンバス内の全素子を囲むバウンディングボックスを表示する. 
\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{Ex:7812973891216}
  \q{
    \qcaprev \qcap          \n
    \qwire   \qbraid \qwire \n
    \qwire   \qbraid \qwire \n
    \qcup    \qcuprev
    \qBBall
  }
\end{codebox}
\begin{verbatim}
  \bbsymbol[<方角>]{<text>}[<オプション>]
\end{verbatim}
直前のバウンディングボックスにテキストを配置する. 
\begin{itemize}
  \item 第一引数 (オプション): \showcmd[]{N} (北), \showcmd[]{S} (南), \showcmd[]{E} (東), \showcmd[]{S} (西), \showcmd[]{NW} (北西), \showcmd[]{NE} (北東), \showcmd[]{SE} (南東), \showcmd[]{SW} (南西) のいずれかを指定. デフォルトは\showcmd[]{E}.
  \item 第二引数: 配置するテキスト.
  \item 第三引数 (オプション): 位置調整 (例: \showcmd[]{above}, \showcmd[]{below}, \showcmd[]{left}, \showcmd[]{right}). デフォルトは\showcmd[]{right}.
\end{itemize}
\begin{CODEBOX}{}{Ex:bbsymbol}
  \q[scale=5]{
    \qbox
    \qbb[1]
    \bbsymbol{東 (デフォルト)}
    \bbsymbol[W]{西}[left]
    \bbsymbol[N]{北}[above]
    \bbsymbol[S]{南}[below]
    \bbsymbol[NE]{北東}[above right]
    \bbsymbol[NW]{北西}[above left]
    \bbsymbol[SE]{南東}[below right]
    \bbsymbol[SW]{南西}[below left]
    \bbsymbol[C]{重心}[]
  }
\end{CODEBOX}
\begin{CODEBOX}{}{Ex:7812973891215}
  \q
  {
    \qcaprev \qcap          \n
    \qwire   \qbraid \qwire \n
    \qwire   \qbraid \qwire \n
    \qcup    \qcuprev
    \qbb[red][1,2]
      \bbsymbol{Measure}
      \bbsymbol[W]{Output}[left]
      \bbsymbol[NW]{Computation}[above left]
      \bbsymbol[NE]{Physics}[above right]
    \qbb[yellow][3,5,6,8]
      \bbsymbol{Braid}
      \bbsymbol[W]{Compute}[left]
    \qbb[cyan][9,10]
      \bbsymbol{Create}
      \bbsymbol[W]{Initialize}[left]
  }
\end{CODEBOX}
\subsection{ボックスのカスタマイズ}
\label{subsec:boxcustomization}
キーを使い, ボックスの経線の数や配置を調整できる. 
例えば以下のようなボックスが描画可能である:
\begin{itemize}
  \item \(\q[scale=0.5]{\qbox[p=20,hlen=3]}\)
  \item \(\q[scale=0.5]{\qbox[p=10,N={1,2,3,8,9,10},S={4,5,6,7},hlen=3]}\)
\end{itemize}
これらのキーはワイヤー以外の多くの素子にも適用可能である. 
主要なキーは以下の通り:
\begin{itemize}
  \item \showcmd[]{n}
      \iitem ボックス\(\q[scale=0.5]{\qbox[p=2, P={}]}\)の北縁において経線\q[scale=0.31]{\qwire}を生やすことができる点 (このような点を\showcmd[]{n}端子と呼ぶこととする) の数. 
      \iitem 例えば \showcmd[]{n=3}とすれば, ボックスの北縁に \(3\) 点等間隔に打つことができる.
      \iitem デフォルト値は \showcmd[]{n=1}.
      \iitem \showcmd[]{n}端子を最北端まで垂直移動させた点を\showcmd[]{N}端子と呼ぶ. 
      \iitem \showcmd[]{n}端子及び\showcmd[]{N}端子は西 (左) から順に\(1,2,...\)と添え字付けられる.
      \iitem \(i\)番目の\showcmd[]{n}端子に経線を生やすとは, \(i\)番目の\showcmd[]{n}端子と\(i\)番目の\showcmd[]{N}端子を線分で結ぶことをいう.
  \item \showcmd[]{N}
      \iitem 経線を実際に生やす\showcmd[]{n}端子の添え字の集合.
      \iitem 例えば \showcmd[]{n=3}とした上で\showcmd[]{N=\{2\}}とすれば, \(3\)点のうち\(2\)番目の\showcmd[]{n}端子に経線を生やすことができる.
      \iitem \showcmd[]{n}が未指定で, \showcmd[]{N}が指定されているときは, 自動で \(\showcmd[]{n}\coloneq\max\showcmd[]{N}\) となる. 
      \iitem \showcmd[]{N}が未指定で, \showcmd[]{n}が指定されているときは, 自動で \(\showcmd[]{N}\coloneq\{1,...,\showcmd[]{n}\}\) となる. 
      \iitem \showcmd[]{n}端子から実際に生えた経線の最北端を出力点, あるいは\showcmd[]{O}端子と呼ぶこととする.
  \item \showcmd[]{s}
      \iitem ボックスの南縁において経線を生やすことができる点 (このような点を\showcmd[]{s}端子と呼ぶこととする) の数. 
      \iitem 例えば \showcmd[]{s=4}とすれば, ボックスの南縁に\(4\)点等間隔に打つことができる.
      \iitem デフォルト値は\showcmd[]{s=1}. 
      \iitem \showcmd[]{s}端子を最南端まで垂直移動させた点を\showcmd[]{S}端子と呼ぶ. 
      \iitem \showcmd[]{s}端子及び\showcmd[]{S}端子は西 (左) から順に\(1,2,...\)と添え字付けられる.
      \iitem \(i\)番目の\showcmd[]{s}端子に経線を生やすとは, \(i\)番目の\showcmd[]{s}端子と\(i\)番目の\showcmd[]{S}端子を線分で結ぶことをいう.
  \item \showcmd[]{S}
      \iitem 経線を実際に生やす\showcmd[]{s}端子の添え字の集合.
      \iitem 例えば \showcmd[]{s=4}とした上で \showcmd[]{S=\{1,4\}} とすれば,  \(4\)点のうち\(1\)番目と\(4\)番目の点に経線を生やすことができる.
      \iitem \showcmd[]{s}が未指定で, \showcmd[]{S}が指定されているときは, 自動で \(\showcmd[]{s}\coloneq\max \showcmd[]{S}\) となる. 
      \iitem \showcmd[]{S}が未指定で, \showcmd[]{s}が指定されているときは, 自動で \(\showcmd[]{S}\coloneq\{1,...,\showcmd[]{s}\}\) となる.
      \iitem \showcmd[]{s}端子から実際に生えた経線の最南端を入力点, あるいは\showcmd[]{I}端子と呼ぶこととする.
  \item \showcmd[]{hlen}
      \iitem 水平方向のバウンディングボックスの長さ.
      \iitem 例えば\showcmd[]{hlen=2}とすれば, 水平方向のバウンディングボックスの長さが\(2\)となる. 
      \iitem 唯一つの例外を除いて, 最西端の経線とバウンディングボックスの境界線との距離, 最東端の経線とバウンディングボックスの境界線との距離はともに\(\fpeval{0.5}\)である. 
      \iitem \showcmd[]{hlen}が未指定であるとき, \showcmd[]{n}端子及び\showcmd[]{s}端子は, 間隔を\(1\)に保って並べられる. 
      \iitem \showcmd[]{hlen}が指定されているとき, \showcmd[]{n}端子及び\showcmd[]{s}端子は, 長さ\(\showcmd[]{hlen}-1\)の区間を等間隔に並べられる. このときの端子の間隔は\showcmd[]{hlen}及び端子の数に依存する. 
          \iiitem 端子の数が\(1\)つであるときは, 区間の中心に置かれる. このとき, \(\showcmd[]{hlen}>1\) であるならば, 最西端の経線とバウンディングボックスの境界線との距離, 及び最東端の経線とバウンディングボックスの境界線との距離はともに\(\frac{\showcmd[]{hlen}}{2}>\fpeval{0.5}\)である. 
  \item \showcmd[]{vlen}
      \iitem 垂直方向のバウンディングボックスの長さ (高さ).
      \iitem デフォルト値は \showcmd[]{vlen=1}. 
  \item \showcmd[]{id}
      \iitem ボックスの識別子. 
      \iitem 例えば\showcmd[]{id=ID}とすれば, ここまで登場した様々な点に次のような名前が自動的に付けられる:
          \iiitem (西から数えて) \(i\)番目の\showcmd[]{n}端子: (n-\(i\)-ID)
          \iiitem \(i\)番目の\showcmd[]{s}端子: (s-\(i\)-ID)
          \iiitem \(i\)番目の\showcmd[]{n}端子をボックスの北縁へ垂直移動させた点: (N-\(i\)-ID)
          \iiitem \(i\)番目の\showcmd[]{s}端子をボックスの南縁へ垂直移動させた点: (S-\(i\)-ID)
          \iiitem バウンディングボックスの最北西端: (NW-ID)
          \iiitem バウンディングボックスの最北東端: (NE-ID)
          \iiitem バウンディングボックスの最南西端: (SW-ID)
          \iiitem バウンディングボックスの最南東端: (SE-ID)
          \iiitem バウンディングボックスの最北端: (N-ID)
          \iiitem バウンディングボックスの最南端: (S-ID)
          \iiitem バウンディングボックスの最西端: (W-ID)
          \iiitem バウンディングボックスの最東端: (E-ID)
          \iiitem バウンディングボックスの重心: (C-ID)
          \iiitem ボックスの最北西端: (nw-ID)
          \iiitem ボックスの最北東端: (ne-ID)
          \iiitem ボックスの最南西端: (sw-ID)
          \iiitem ボックスの最南東端: (se-ID)
          \iiitem ボックスの最北端: (n-ID)
          \iiitem ボックスの最南端: (s-ID)
          \iiitem ボックスの最西端: (w-ID)
          \iiitem ボックスの最東端: (e-ID)
          \iiitem \(i\) 番目の出力点: (O-\(i\)-ID)
          \iiitem \(i\) 番目の入力点: (I-\(i\)-ID)
      \iitem 指定の有無にかかわらず, \showcmd{q\{...\}}内に置かれた各コマンドには識別番号が振られている. 各々\showcmd[]{ID}部分をその番号に置き換えても同じ点を表す. 詳細は \ref{subsec:showid} 節を確認されたし. 
    \item \showcmd[]{p}, \showcmd[]{P}
        \iitem 正整数\showcmd[]{k}に対して, \showcmd[]{p=k}は\showcmd[]{n=k}, \showcmd[]{s=k}を意味する. 
        \iitem 正整数の有限集合\showcmd[]{K}に対して, \showcmd[]{P=K}は\showcmd[]{N=K}, \showcmd[]{S=K}を意味する. 
    \item \showcmd[]{name}
        \iitem \showcmd[]{name=<text>} により, ボックスの重心に\showcmd[]{<text>}が置かれる. 
\end{itemize}
\begin{CODEBOX}{}{ex:boxpoints}
  \def\pradius{0.4pt}
  \q[scale=5]
  {
    \qbox
    [
      n=3,N={2},
      s=4,S={1,4},
      hlen=2,
      vlen=2,
      id={ID},
      name={重心 (C-ID)}
    ]\n
    \qbb[ID]
    \node [above] at (NE-ID) {NE-ID};
    \node [above] at (NW-ID) {NW-ID};
    \node [below] at (SE-ID) {SE-ID};
    \node [below] at (SW-ID) {SW-ID};
    \fill (NE-ID) circle (\pradius);
    \fill (NW-ID) circle (\pradius);
    \fill (SE-ID) circle (\pradius);
    \fill (SW-ID) circle (\pradius);
    \node [above] at (ne-ID) {ne-ID};
    \node [above] at (nw-ID) {nw-ID};
    \node [below] at (se-ID) {se-ID};
    \node [below] at (sw-ID) {sw-ID};
    \fill (ne-ID) circle (\pradius);
    \fill (nw-ID) circle (\pradius);
    \fill (se-ID) circle (\pradius);
    \fill (sw-ID) circle (\pradius);
    \foreach\i in {1,...,3}
    {
      \symboln[\i]{n-\i-ID}[below]
      \fill (n-\i-ID) circle (\pradius);
      \symbolN[\i]{N-\i-ID}
      \fill (N-\i-ID) circle (\pradius);
    }
    \foreach\i in {1,...,4}
    {
      \symbols[\i]{s-\i-ID}[above]
      \fill (s-\i-ID) circle (\pradius);
      \symbolS[\i]{S-\i-ID}[below]
      \fill (S-\i-ID) circle (\pradius);
    }
    \draw[line width=0.2pt] (NW-ID) 
      to [bend left=60] node [fill=white, midway] {hlen} (NE-ID);
    \draw[line width=0.2pt] (NW-ID) 
      to [bend right=60] node [fill=white, midway] {vlen} (SW-ID);
    \draw [red, <->] (C-ID -| W-ID)
      -- node [midway, auto, font=\footnotesize] {0.5} (C-ID -| S-1-ID);
    \draw [red, <->] (C-ID -| S-4-ID)
      -- node [midway, auto, font=\footnotesize] {0.5} (C-ID -| E-ID);
    \qwire[arrowtype={loosely dotted}, dom={s-1-ID}, cod={n-1-ID}]
    \qwire[arrowtype={loosely dotted}, dom={s-4-ID}, cod={n-3-ID}]
    \node (O1prime) at ([shift={(0.25,0.25)}]O-1-ID){O-1-ID};
    \draw[->,red] (O1prime) to ([shift={(0.05,0.05)}]O-1-ID);
    \node (I1prime) at ([shift={(0.5,-0.5)}]I-1-ID){I-1-ID};
    \node (I2prime) at ([shift={(0.5,-0.5)}]I-2-ID) {I-2-ID};
    \draw[->,red](I1prime) to ([shift={(0.05,-0.05)}]I-1-ID);
    \draw[->,red](I2prime) to ([shift={(0.05,-0.05)}]I-2-ID);
  }
\end{CODEBOX}
\verb|\qwire|の\verb|arrowtype|キーと\verb|dom|, \verb|cod|キーは
\pageref{subsec:wirecustomization}ページの\ref{subsec:wirecustomization}節にて説明する. 
\paragraph{ラベル (\showcmd{symbol})}
\begin{verbatim}
  \symbolI[<番号>]{<label>}[<オプション>]
\end{verbatim}
例えば, \verb|\symbolI[2]{text}[below right, id=<ID>]| により, 
\verb|\q{\qbox[p=3, id=ID]}| (\(\q[scale=0.5]{\qbox[p=3, id=ID]}\)) の\(2\)番目の入力点 (I-2-ID) の右下に``text''が置かれる. 
番号とオプションの指定のないときは, デフォルト値\(1\), below, \verb|id=<直前のもの>| が各々適用される. 
他にもラベル表示コマンドとして, 
\begin{verbatim}
  \symbolS[<番号>]{<label>}[<オプション>]
\end{verbatim}
\begin{verbatim}
  \symbols[<番号>]{<label>}[<オプション>]
\end{verbatim}
\begin{verbatim}
  \symbolO[<番号>]{<label>}[<オプション>]
\end{verbatim}
\begin{verbatim}
  \symbolN[<番号>]{<label>}[<オプション>]
\end{verbatim}
\begin{verbatim}
  \symboln[<番号>]{<label>}[<オプション>]
\end{verbatim}
がある. \verb|\symbolS|, \verb|\symbols|はそれぞれ点 (S-\(i\)-ID), (s-\(i\)-ID) に\textless label\textgreater を置く. 
番号\(i\)のデフォルト値は \(1\), オプションのデフォルト値は below である. 
\verb|\symbolO|, \verb|\symbolN|, \verb|\symboln| はそれぞれ点 (O-\(i\)-ID), (N-\(i\)-ID), (n-\(i\)-ID) に\textless label\textgreater を置く. 
番号\(i\)のデフォルト値は \(1\), オプションのデフォルト値は above である. 
\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{Ex:7812973891211}
  \q{
    \qbox[p=5, S={1,4,5}, id=ID]
    \symbolO{A}
    \symbolN[3]{B}
    \symboln[5]{C}[below left]
    \symbolS[2]{D}
    \symbols[3]{E}
    \symbolI[2]{F}
    \symbolI[3]{G}[below right]
  }
\end{codebox}
\begin{CODEBOX}{}{Ex:7812973891210}
  \q{
    \qbox[p=10,N={1,2,5,6,9,10}, id=ID]
    \foreach\i in {1,...,10}
    {
      \symbolI[\i]{\(x_{\i}\)}
    }
    \foreach\j in {1,...,6}
    {
      \symbolO[\j]{\(y_{\j}\)}
    }
  }
\end{CODEBOX}

\subsection{繰り返し}
\label{subsub:forloop}
\begin{verbatim}
  \qloop[<回数>]{<コマンド>}
\end{verbatim}
\verb|\qloop|コマンドを用いれば, 指定した回数だけコマンドを繰り返せる:
\begin{CODEBOX}{}{Ex:7812973891205}
  \q{ \qloop[10]{\qbox} }
\end{CODEBOX}
\verb|\qloop|コマンドは\verb|\q|外でも使用可能である:
\begin{CODEBOX}[bicolor,colbacklower=white]{}{Ex:78129738912220930}
  結論だけ, 書く.\par
  \qloop[20]{失敗した}\par
  あたしは\qloop[10]{失敗した}
\end{CODEBOX}
\subsection{識別番号の表示}
\label{subsec:showid}
\verb|\q{...}| 内のコマンドには自動的に識別番号が付与される. 
\showcmd[]{show id=true}を指定すると, それらが表示される. 
\begin{CODEBOX}{}{Ex:7812973891203}
  \q{
    \qbox[show id={true}] \qbox[show id={true}] \qbox[show id={true}]\n
    \qbox[show id={true}] \qbox[show id={true}] \qbox[show id={true}]
  }
\end{CODEBOX}
\begin{CODEBOX}{}{Ex:7812973891202}
  \q
  {
    \qloop[10]
    {
      \qloop[10]
      {
        \qbox[show id={true}]
      }\n
    }\n
  }
\end{CODEBOX}

\subsection{色}
\label{subsec:color}
ボックスに三種類の色属性を指定できる: 
\begin{itemize}
  \item \showcmd[]{color}
    \iitem ボックス内部の色, 例えば\showcmd[]{color=green}により\q[scale=0.5]{\qbox[color={green}]}
  \item \showcmd[]{frame color}
    \iitem ボックスの枠の色, 例えば\showcmd[]{frame color=cyan}により\q[scale=0.5]{\qbox[frame color={cyan}]}
  \item \showcmd[]{morphism color}
    \iitem ボックス内の射の色, 例えば\showcmd[]{morphism colon=red}により\q[scale=0.5]{\qbox[morphism color={red}, name={\(f\)}]}
\end{itemize}
\begin{CODEBOX}{}{Ex:74839759}
    \q
    {
      \qbox
      [
        name={\(f\)},
        color=red,
        frame color={green!50!black},
        morphism color=yellow
      ]
    }
\end{CODEBOX}

\subsubsection*{組紐, シンメトリー, キャップ, カップの色指定}
\label{subsubsec:tanglecolor}
組紐, シンメトリー, キャップ, カップといった一部の射は, 図式上では箱ではなく曲線として描画される. 
これらには明確な内部領域が存在せず, 射のラベルも通常付けないため, \showcmd[]{color}及び\showcmd[]{morphism color}は適用されない. 

\paragraph{\showcmd[]{N}, \showcmd[]{S}, 等差数列}
\qworldname は\showcmd[]{pgffor}パッケージをロードしているため, リストに対して\verb|...|を用いた省略記法が使用できる:
\begin{itemize}
  \item \(1,...,10\): 公差\(1\)の等差数列
  \item \(1,3,...,11\): 最初の二項に基づいた公差の等差数列
\end{itemize}
\begin{CODEBOX}{}{Ex:74839758}
   \q{
     \qbox[N={1,...,10}, S={1,3,...,11}]
   }
\end{CODEBOX}
\begin{CODEBOX}{}{Ex:74839757}
  \q{
    \qbox[N={1,...,4,6,8,...,20}, S={1,...,20}, hlen=10]
  }
\end{CODEBOX}
\begin{CODEBOX}{}{Ex:74839756}
  \q{
    \qbox[N={1,...,4,7,10,...,19,20,21,...,25}, S={1,...,25}, hlen=10]
  }
\end{CODEBOX}
\subsection{相対座標}
素子の位置座標を相対的に指定するコマンドである. 
なお, \(x\), \(y\) は整数である必要はなく, \verb|2^1.5|や\verb|cos(pi)|, \verb|sqrt(2)|などの\verb|\fpeval|の評価可能式であればよい. 
\begin{itemize}
  \item \showcmd{qmv[\(x\),\(y\)]}
    \iitem (\(x\), \(y\)) だけ並行移動する.
    \iitem デフォルトで\(x=y=0\).
  \item \showcmd{n[\(y\)]}
    \iitem \(y\)だけ垂直降下し (\(Y\mapsto Y-y\)), X座標を\(0\)にする.
    \iitem デフォルトで \(y=1\) であり, 改行のような挙動をみせる.
  \item \showcmd{qspace[\(x\)]}
    \iitem \(x\) だけ水平移動する. 
    \iitem デフォルトで \(x=1\) であり, スペースキーのような挙動をみせる.
    \iitem \showcmd{qmv[\(x\),0]} と同義である.
  \item \showcmd{qreset[\(x\),\(y\)]}
    \iitem 点 (\(x\),\(y\)) に移動する.
\end{itemize}
\[\q[scale=2.35]{
  \fill[blue] (qworldat) circle (1pt);
  \coordinate (I) at (qworldat);
\qbox
  \fill[blue] (qworldat) circle (1pt);
  \coordinate (II) at (qworldat);
\n
  \fill[blue] (qworldat) circle (1pt);
  \coordinate (III) at (qworldat);
\qspace
  \fill[blue] (qworldat) circle (1pt);
  \coordinate (IV) at (qworldat);
\qspace[0.5]
  \fill[blue] (qworldat) circle (1pt);
  \coordinate (V) at (qworldat);
\n[2]
  \fill[blue] (qworldat) circle (1pt);
  \coordinate (VI) at (qworldat);
\qmv[-2,-1]
  \fill[blue] (qworldat) circle (1pt);
  \coordinate (VII) at (qworldat);
\n
  \fill[blue] (qworldat) circle (1pt);
  \coordinate (VIII) at (qworldat);
\qspace[-3]
  \fill[blue] (qworldat) circle (1pt);
  \coordinate (IX) at (qworldat);
\qreset
  \fill[blue] (qworldat) circle (1pt);
  \coordinate (X) at (qworldat);
\qreset[-2,1]
  \fill[blue] (qworldat) circle (1pt);
  \coordinate (XI) at (qworldat); 
\qbball
\qwireup[dom={I}, cod={II},
         label={自動更新}, label side={below},
         label at={midway}, color=cyan]
\qwireup[dom={II},cod={III},
         label={\showcmd{n}},
         label side={below}, color=cyan]
\qwireup[dom={III},cod={IV},
         label={\showcmd{qspace}},
         label side={below}, color=cyan]
\qwireup[dom={IV},cod={V},
         label={\showcmd{qspace[0.5]}},
         label side={above}, color=cyan]
\qwireup[dom={V},cod={VI},
         label={\showcmd{n[2]}},color=cyan]
\qwireup[dom={VI},cod={VII},
         label={\showcmd{qmv[-2,-1]}},color=cyan]
\qwireup[dom={VII},cod={VIII},
         label={\showcmd{n}},color=cyan]
\qwireup[dom={VIII},cod={IX},
         label={\showcmd{qspace[-3]}}, 
         label side={below},color=cyan]
\qwireup[dom={IX},cod={X},
         label={\showcmd{qreset}},
         label side=left, color=cyan]
\qwireup[dom={X},cod={XI},
         label={\showcmd{qreset[-2,1]}},
         label side=left, 
         label at={near start},
         color=cyan]
\draw[help lines] (-4,-6) grid (2,2);
}\]

\subsection{絶対座標}
\showcmd[]{at}キーを用いれば, 絶対座標で位置を指定できる. 
\verb|\q{\qbox[at={2,3}]}|は\verb|\q{\qreset[2,3]\qbox}|と同義である. 
\begin{CODEBOX}{絶対座標}{Ex:74839754}
  \q{
    \coordinate (a) at (0,{\fpeval{2*sqrt(3)}});
    \qbox[at=a]
    \qbox[at={-2,0}]
    \qbox[at={2,0}]
    \fill[red] (a) circle (2pt);
    \fill[red] (-2,0) circle (2pt);
    \fill[red] (2,0) circle (2pt);
    \node[below left] at (a) {a};
    \node[below left] at (-2,0) {(-2,0)};
    \node[below left] at (2,0) {(2,0)};
  }
\end{CODEBOX}
\TeX 言語はチューリング完全である\footnote{例えば, チューリングマシンをシミュレートできることがLiterateProgramsの例で示されてる\cite{literateprograms}. また, Overleafの記事では, \TeX を用いたフィボナッチ数列の計算方法が紹介されており, そのチューリング完全性の実用性が理解できる\cite{overleaf}.}. 
すなわち, この世に存在するあらゆるアルゴリズムは \TeX で記述可能である. 
物理シミュレーション (天気予報や化学反応予測), 
経済シミュレーション (投資戦略), 
さらには人工知能の学習アルゴリズム (画像認識や自然言語処理) ------.\par
どれも\TeX で実装できる.\par
しかし, それを実際にやろうと思う人間は果たしてどれほどいるだろうか? 
筆者はソートアルゴリズムですら\TeX で書きたくない. 
それは表計算ソフトでスーパーマリオを作るようなものだからである.\par
------ところが, である.\par
筆者は``天啓''を受けた
\footnote{元ネタ: 2011年1月20日, 匿名掲示板4chanにおいて``Sleep Sort''というソートアルゴリズムが公開された\cite{geniussorting,gfxhatena}. このアルゴリズムは\showcmd[]{Bash}スクリプトを用いて各入力値をスレッドとして非同期に実行し, それぞれのスレッドの終了タイミング (指定された``スリープ''時間) を用いてリストをソートする手法である.}. 
そして\showcmd[]{at}キーを用いたソートアルゴリズムを作り上げた.
\begin{codebox}{}{Ex:genius}
  \newcommand{\AtSort}[1][1]{
    \q
    {
      \foreach \i in {#1}
      {
        \qbox[name={\i}, at={0, -\i}]\n
      }
    }
  }
  \AtSort[4,1,3,-1,6,2]
\end{codebox}
動く. 確かに動く.\par
だが, 一つ問題がある.\par
\textbf{リストの要素に絶対値の大きな値が含まれていると, 出力が紙面からはみ出してしまうのである}. 

\subsection{ワイヤーのカスタマイズ}
\label{subsec:wirecustomization}
\[\q{
    \def\maxn{11}
    \foreach \i in {0,...,\maxn}
    {
        \qwireup[dom={0,0}, cod={{\fpeval{\i*360/(\maxn+1)}}:3}]
        \node at ({\fpeval{\i*360/(\maxn+1)}}:3.6) {\showcmd[]{cod}\i};
    }
}\]
\ref{subsec:boxcustomization} 節で登場したボックス\q[scale=0.5]{\qbox}のキーの中で, \showcmd[]{id}, \showcmd[]{vlen} はワイヤーでも有効である. 
ワイヤー特有のキーとして, 基本的なものは次の通りである:
\begin{itemize}
  \item \showcmd[]{dom}: 入力点. 
  \item \showcmd[]{cod}: 出力点.
      \iitem デフォルト値は\showcmd[]{dom}を \(1\) だけ北へ垂直移動した位置. 
  \item \showcmd[]{label}: ワイヤーにラベルを付ける. 
  \item \showcmd[]{label at}: ラベルのワイヤー上の位置.
      \iitem デフォルトで midway.
  \item \showcmd[]{label side}: ラベルとワイヤーの位置関係.
      \iitem デフォルトで right.
\end{itemize}
\begin{codebox}{}{ex:78129738912260951}
  \q{
    \qbox[n=3,hlen=1.5]
    \qbox[at={1,2}, s=2, hlen=1.5]
    \qbox[at={-1,4}, s=2, hlen=1.5]
    \qwire[dom={N-1-1}, cod={S-1-3}]
    \qwire[dom={N-2-1}, cod={S-1-2}]
    \qwire[dom={N-3-1}, cod={S-2-2}]
    \qwire[dom={N-1-2}, cod={S-2-3}]
  }
\end{codebox}
\begin{CODEBOX}{}{ex:193477432894112213}
  \q{
    \def\maxi{11}
    \foreach \i in {0,...,\maxi}
    {
        \qwireup[dom={0,0}, cod={{\fpeval{\i*360/(\maxi+1)}}:2}]
        \node at ({\fpeval{\i*360/(\maxi+1)}}:2.4) {\texttt{cod} \i};
    }
  }
\end{CODEBOX}
ワイヤー\q[scale=0.6]{\qwire}のバウンディングボックスは, \q[scale=0.5]{\qbox}と同じである:
\begin{codebox}{}{ex:78129738912220926}
  \q
  {
    \qwire\qbox\qwire\n
    \qbox\qwire\qbox
    \qbball
  }
\end{codebox}
ワイヤーのバウンディングボックスは, \showcmd[]{dom}を入力点, \showcmd[]{cod}を出力点とするようなボックスのそれと一致する:
\begin{itemize}
  \item \(\q[scale=0.5]{\qwire}\) と \(\q[scale=0.5]{\qbox}\)
  \item \(\q[scale=0.5]{\qwire[dom={0,0},cod={1,1}]}\) と \(\q[scale=0.5]{\qbox[p=2,S={1},N={2}]}\)
\end{itemize}

\begin{CODEBOX}{}{Ex:7812973891209}
  \q[scale=3]{
    \coordinate (A) at (0,0);
    \coordinate (B) at (2,3);
    \qwire[dom=A, cod={1,1}, label={wire1}, label side={left}]
    \qwire[dom={1,1}, cod=B, label={wire2}, label at={near end}]
    \node[fill=red, circle] at (A) {A};
    \node[fill=green, circle] at (B) {B};
    \node[fill=yellow, circle] at (1,1) {(1,1)};
    \qbball
  }
\end{CODEBOX}

\begin{CODEBOX}{}{Ex:7812973891201}
  \q{
    \qloop[5]{
      \qloop[10]{
        \qbox[show id={true}]
      }\n
    }\n
    \qspace[3]\qbox[s=2,show id={true},id={ego1}]\n\n
    \qspace[6]\qbox[n=2,show id={true},id={ego2}]\n\n
    \qloop[5]{
      \qloop[10]{
        \qbox[show id={true}]
      }\n
    }
    \qwire[dom={O-1-55},cod={I-1-51}]
    \qwire[dom={O-1-60},cod={I-1-52}]
    \qwire[dom={O-1-51},cod={I-1-45}]
    \qwire[dom={O-1-52},cod={I-2-51}]
    \qwire[dom={O-2-52},cod={I-1-48}]
  }
\end{CODEBOX}

\paragraph{arrowtype}
ワイヤーのスタイルは, \showcmd[]{arrowtype}キーを用いて指定する. 
\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{wirearrowtype}
  \q{
    \qwire[arrowtype=dotted]
    \qwire[arrowtype=dashed]
    \qwire[arrowtype={dash dot}]
    \qwire[arrowtype={dash dot dot}]
    \qwire[arrowtype={densely dotted}]
    \qwire[arrowtype={loosely dotted}]
  }
\end{codebox}

\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{boxarrowtype}
  \q{
    \qbox[dom arrowtype={dotted}]
    \qbox[cod arrowtype={dotted}]
    \qbox[arrowtype={dotted}]
  }
\end{codebox}

\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{spiderarrowtype}
  \q{
    \qspider[dom arrowtype={dotted}]
    \qspider[cod arrowtype={dotted}]
    \qspider[arrowtype={dotted}]
  }
\end{codebox}

\subsection{キャンバス}
\begin{verbatim}
  \q[オプション]
  {
    コマンド
    コマンド
    ...
  }
\end{verbatim}
キャンバスのオプションで図式全体を変換できる.
\begin{codebox}{}{Ex:74839753}
  \q[scale=2,rotate=30]{\qbox}
\end{codebox}
キャンバスを傾けることもできる. 
\begin{CODEBOX}{}{Ex:74839752}
  \def\anglerot{-55}
  \tikzset
  {
    my slant style/.style={
      yslant=-cot(\anglerot), 
      xscale=sin(-\anglerot)
      }
  }
  \q[my slant style]
  {
    \qcaprev\qcap\n
    \qwire\qbraidinv\qwiredown\n
    \qwiredown\qbraidinv\qwire\n
    \qcup\qcuprev
    \qBBall
  }
\end{CODEBOX}
\begin{CODEBOX}{}{Ex:74839751}
  \def\anglerot{-60}
  \tikzset
  {
    my slant style/.style={
      yslant=-cot(\anglerot), 
      xscale=sin(-\anglerot)
      }
  }
  \[\q[my slant style]
  {
    \qbraid\qwire\n
    \qwire\qbraid\n
    \qbraid\qwire
  }
  =\q[my slant style]
  {
    \qbraid\qwire\n
    \qwire\qwire\qwire\n
    \qbraid[num R=2]
    \qbb[red][1]
    \qbb[cyan][6]
  }
  =\q[my slant style]
  {
    \qbraid[ num R=2]\n
    \qwire\qwire\qwire\n
    \qwire\qbraid
    \qbb[red][6]
    \qbb[cyan][1]
  }
  =\q[my slant style]
  {
    \qwire\qbraid\n
    \qbraid\qwire\n
    \qwire\qbraid
  }\]
\end{CODEBOX}

\section{モノイダル圏と\qworldname}
本章では, \qworldname パッケージを用いてモノイダル圏の図式計算をどのように表現できるかを探る. 
\qworldname は, それ単体で機能し, 図式を扱うことができるが, 
数式をより柔軟に表現するために, その基盤となるパッケージ (\showcmd[]{amsmath}, \showcmd[]{amssymb}, \showcmd[]{mathtools}) を使用する. 
再現の際は, 以下のようにパッケージを適宜ロードせよ:
\begin{verbatim}
  \usepackage{amsmath, amssymb, mathtools}
  \usepackage{qworld}
\end{verbatim}
\subsection{圏}
\begin{codebox}{ドメイン}{ex:dom2}
  \[
    \operatorname{dom}\left(
      \q{
        \qbox[name={\(f\)}]
        \symbolI{\(x\)}
        \symbolO{\(y\)}
      }
    \right)=x
  \]
\end{codebox}
\begin{codebox}{コドメイン}{ex:cod2}
  \[
    \operatorname{cod}\left(
      \q{
        \qbox[name={\(f\)}]
        \symbolI{\(x\)}
        \symbolO{\(y\)}
      }
    \right)=\q{\qwire[label={\(y\)}]}
  \]
\end{codebox}

\begin{codebox}{合成 (垂直合成)}{def:composite}
  \[
    \q{
      \qbox[name={\(f\)}]\qcirc\qbox[name={\(g\)}]
    }=\q{\qbox[name={\(f\circ g\)}]}
  \]
\end{codebox}
\begin{CODEBOX}{結合律}{Ex:74839750}
  \[
    \forall\q{\qbox[name={\(h\)}] \symbolI{\(z\)} \symbolO{\(w\)}},
           \q{\qbox[name={\(g\)}] \symbolI{\(y\)} \symbolO{\(z\)}},
           \q{\qbox[name={\(f\)}] \symbolI{\(x\)} \symbolO{\(y\)}}:
    \q{
        \qbox[name={\(h\)}]\qcirc\qbox[name={\(g\)}]\qcirc\qbox[name={\(f\)}]
        \qbb[2,3]
    }
    =
    \q{
        \qbox[name={\(h\)}]\qcirc\qbox[name={\(g\)}]\qcirc\qbox[name={\(f\)}]
        \qbb[1,2]
    }
  \]
\end{CODEBOX}
\begin{CODEBOX}{恒等律}{IdentityLaw}
  \begin{equation}
    \label{law:identity}
    \forall\q
    {
      \qbox[name={\(f\)}]
      \symbolS{\(x\)}
      \symbolN{\(y\)}
    }\colon
    \q{
      \qwire[label={\(y\)}]\n
      \qbox[name={\(f\)}]
    }=\q{
      \qbox[name={\(f\)}]
    }=\q{
      \qbox[name={\(f\)}]\n
      \qwire[label={\(x\)}]
    }
  \end{equation}
\end{CODEBOX}
\subsubsection{対象情報と色}
\label{subsubsec:objectcolor}
圏の図式計算において, 恒等射は通常, 単なるワイヤーとして描かれる. 
こうしたワイヤーがどの対象の恒等射であるかを, \textbf{対象ごとに固有の色を割り当てる}ことによって視認可能にする手法が存在する. 
この手法を用いることにより, ワイヤ上に対象の情報をエンコードすることが可能となり, 曲線構造からなる図式において, 対象の区別を直感的に把握する助けとなる. 
この手法の理論的背景には, \textbf{任意の射に対してドメインとなる対象とコドメインとなる対象がそれぞれ一意的に存在する}という事実がある. 
この構造が前提として存在する以上, 図式表現において``色''という視覚的属性を通じて対象を暗示/表現することは十分に正当化される操作である. 
例えば組紐 (\pageref{subsubsec:braid:color}ページの\ref{subsubsec:braid:color}項) や双対性 (\pageref{subsubsec:duality:color}ページ\ref{subsubsec:duality:color}項) を含む図式において, 色による補助が正確な解釈を支援する. 
この考え方のもとでは, 対象とはワイヤーを彩る色のような存在であり, 
\begin{CODEBOX}[bicolor,colbacklower=white]{}{objectcolor}
  \(\operatorname{dom}\)は射
  \(\q{\qbox[name={\(f\)}, dom color=red, cod color=cyan]}\)
  のドメインの色\(\q{\qwire[color=red]}\)
  を識別するための関数であり, 
  \(\operatorname{cod}\)は同様に, コドメインの色
  \(\q{\qwire[color=cyan]}\)を識別するための関数である.\par
  そして紙面上で
  \(\q{\qbox[name={\(f\)}, dom color=purple, cod color=teal]}\)
  のコドメインの色と
  \(\q{\qbox[name={\(g\)}, dom color=teal, cod color=orange]}\)
  のドメインの色が一致していることが色によって明示され, 
  この条件が満たされているときに限り, 合成 (垂直合成)
  \[
    \q{
      \qbox[name={\(g\)}, dom color=cyan, cod color=orange]\n
      \qbox[name={\(f\)}, dom color=red, cod color=cyan]
    }
  \]
  が整合性を保つ操作として許容される.
\end{CODEBOX}
\subsection{モノイダル圏}
\begin{CODEBOX}{テンソル積 (並列合成)}{monoidalproduct}
  \[
    \q
    {
      \qbox[name={\(f\)}] \qbox[name={\(g\)}]
      \symbolO{\(Y_1\)}[id=1] \symbolO{\(Y_2\)}
      \symbolI{\(X_1\)}[id=1] \symbolI{\(X_2\)}
    }
    =\q
    {
      \qbox[name={\(f\otimes g\)}, p=2]
      \symbolO{\(Y_1\)} \symbolO[2]{\(Y_2\)}
      \symbolI{\(X_1\)} \symbolI[2]{\(X_2\)}
    }
    =\q
    {
      \qbox[name={\(f\otimes g\)}]
      \symbolO{\(Y_1\otimes Y_2\)}
      \symbolI{\(X_1\otimes X_2\)}
    }
  \]
\end{CODEBOX}
\subsubsection{交換則}
\begin{CODEBOX}{交換則 (\(\bigotimes\)の共変関手性)}{InterchangeLaw}
  \begin{equation}
    \label{law:interchange}
    \q
    {
      \qbox[name={\(f_2\)}]\qbox[name={\(g_2\)}]\n
      \qbox[name={\(f_1\)}]\qbox[name={\(g_1\)}]
      \qbb[1,2]
      \qbb[3,4]
    }
    =\q
    {
      \qbox[name={\(f_2\)}]\qbox[name={\(g_2\)}]\n
      \qbox[name={\(f_1\)}]\qbox[name={\(g_1\)}]
      \qbb[2,4]
      \qbb[1,3]
    }
  \end{equation}
\end{CODEBOX}

\begin{CODEBOX}{単位対象}{Ex:74839744}
  \begin{gather}
    \q{ \qwire[arrowtype=dotted]}
    =\q{ \qunitob \qbball }\\
    \q{ \qunitob \qbox[name={\(f\)}] \qbball }
    =\q{ \qbox[name={\(f\)}] }
    =\q{ \qbox[name={\(f\)}] \qunitob \qbball }\label{cond:unitob}
  \end{gather}
\end{CODEBOX}
\begin{CODEBOX}{}{Ex:74839743}
  \[
    \q{\qunitob\qbball}
    =\q{\qloop[2]{\qunitob}\qbball}
    =\q{\qloop[3]{\qunitob}\qbball}
    =\cdots
  \]
\end{CODEBOX}

\subsection{特殊ボックス}

\begin{itemize}
  \item \showcmd{qstate}: \(\q[scale=0.5]{\qstate}\) (\(0\)入力).
  \item \showcmd{qeffect}: \(\q[scale=0.5]{\qeffect}\) (\(0\)出力).
  \item \showcmd{qscalar}: \(\q[scale=0.5]{\qscalar}\) (\(0\)入力, \(0\)出力).
  \item \showcmd{qasym}: \(\q[scale=0.5]{\qasym}\) (非対称ボックス). 
  \item \showcmd{qtrans}: \(\q[scale=0.5]{\qtrans}\) (転置ボックス). \pageref{subsub:transpose}ページの\ref{subsub:transpose}項.
  \item \showcmd{qadj}: \(\q[scale=0.5]{\qadj}\) (随伴ボックス). \pageref{subsub:adjoint}ページの\ref{subsub:adjoint}項.
  \item \showcmd{qconj}: \(\q[scale=0.5]{\qconj}\) (共役ボックス). \pageref{subsub:conj}ページの\ref{subsub:conj}項.
\end{itemize}
\subsubsection{ゼロ入力}
\label{subsub:zeroinput}
\begin{codebox}{}{def:state}
  \q{\qstate}
\end{codebox}
\subsubsection{ゼロ出力}
\label{subsub:zerooutput}
\begin{codebox}{}{def:effect}
  \q{\qeffect}
\end{codebox}
\subsubsection{ゼロ入力ゼロ出力}
\label{subsub:zeroinputoutput}
\begin{codebox}{}{def:scalar}
  \q{\qscalar}
\end{codebox}
\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}]}\)}
\begin{CODEBOX}{}{coherence:unitor}
  \[
    \q{
      \qeffect\qstate
      \qwire[dom={O-1-2}, cod={1,2}]
      \qwire[dom={1,-1}, cod={I-1-1}]
    }=\q{
        \qwire[arrowtype=dotted]\qwire\n
        \qeffect\qstate\n
        \qwire\qwire[arrowtype=dotted]
    }\stackrel{\text{(\ref{law:interchange}, \ref{law:identity})}}{=}\q{
        \qwire[arrowtype=dotted]\qstate\n
        \qeffect\qwire[arrowtype=dotted]
    }\stackrel{\text{(\ref{law:interchange}, \ref{cond:unitob})}}{=}\q{\qstate\n\qeffect}
  \]
\end{CODEBOX}
\begin{CODEBOX}{表現行列}{matrixrepre}
  \begin{align*}
    \q{\qbox[name={\(f\)}]}
    &=\sum\limits_{i,j}
    \left(
      \q{
        \qeffect[name={\(w_j^{\dagger}\)}]\n
        \qbox[name={\(f\)}]\n
        \qstate[name={\(v_i\)}]\n
      }\q{
        \qstate[name={\(w_j\)}]\n
        \qeffect[name={\(v_i^{\dagger}\)}]
      }
    \right)
    =\sum\limits_{i,j}\left(
      \q{
        \qscalar[name={\(w_j^{\dagger}\circ f\circ v_i\)}]
      }
      \q{
        \qstate[name={\(w_j\)}]\n
        \qeffect[name={\(v_i^{\dagger}\)}]
      }
    \right)\\
    &=\begin{pmatrix}
      \q{\qscalar[name={\(w_1^{\dagger}\circ f\circ v_1\)}]}&&\cdots&&\q{\qscalar[name={\(w_1^{\dagger}\circ f\circ v_{m}\)}]}\\
      &\ddots&&&\\        
      \vdots& &\q{\qscalar[name={\(w_j^{\dagger}\circ f\circ v_i\)}]}& &\vdots\\
      &&&\ddots&\\
      \q{\qscalar[name={\(w_n^{\dagger}\circ f\circ v_1\)}]}&&\cdots&&\q{\qscalar[name={\(w_n^{\dagger}\circ f\circ v_m\)}]}
    \end{pmatrix}
  \end{align*}
\end{CODEBOX}

\subsection{モノイド対象}
\label{subsec:monoid}
\begin{itemize}
  \item \showcmd{qmul}: \(\q[scale=0.5]{\qmul}\)
    \iitem \showcmd[]{hlen=2}: \(\q[scale=0.5]{\qmul[hlen=2]}\)
  \item \showcmd{qcomul}: \(\q[scale=0.5]{\qcomul}\)
    \iitem \showcmd[]{hlen=2}: \(\q[scale=0.5]{\qcomul[hlen=2]}\)
  \item \showcmd{qunit}: \(\q[scale=0.5]{\qunit}\)
  \item \showcmd{qcounit}: \(\q[scale=0.5]{\qcounit}\)
  \item \showcmd{qspider}: \(\q[scale=0.5]{\qspider}\)
\end{itemize}

\begin{CODEBOX}{結合律}{AssociateLaw}
  \begin{equation}
    \label{law:associate}
    \q{
        \qspace[0.5]\qmul[hlen=2]\n
        \qmul[hlen=2]\qspace[-0.5]\qwire
    }=\q{
        \qmul[hlen=2]\n
        \qwire\qspace[-0.5]\qmul[hlen=2]
    }
  \end{equation}
\end{CODEBOX}
  \begin{CODEBOX}{単位律}{UnitLaw}
  \begin{equation}
    \label{law:unit}
    \q{
        \qmul[hlen=2]\n
        \qwire\qunit
    }=\q{\qwire[vlen=2]}
    =\q
    {
        \qmul[hlen=2]\n
        \qunit\qwire
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{余結合律}{CoassociateLaw}
  \begin{equation}
    \label{law:coassociate}
    \q{
        \qcomul[hlen=2]\qspace[-0.5]\qwire\n
        \qspace[0.5]\qcomul[hlen=2]
        }
    =\q{
        \qwire\qspace[-0.5]\qcomul[hlen=2]\n
        \qcomul[hlen=2]
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{余単位律}{CounitLaw}
  \begin{equation}
    \label{law:counit}
    \q{
        \qcounit\qwire\n
        \qcomul[hlen=2]
        }
    =\q{\qwire[vlen=2]}
    =\q{
        \qwire\qcounit\n
        \qcomul[hlen=2]
    }
  \end{equation}
\end{CODEBOX}

\subsubsection{フロベニウス則}
\begin{FCODEBOX}{フロベニウス則}{FrobeniusLaw}
    \[
      \q{
        \qwire\qmul[color=black]\n
        \qcomul\qwire
      }=\q{
        \qcomul\n
        \qmul[color=black]
      }=\q{
        \qmul[color=black]\qwire\n
        \qwire\qcomul
      }
    \]
  \end{FCODEBOX}
  失敗例として挙げられているが, 実際にはフロベニウス則が正確に記述されている. 
  むしろ, 全てのワイヤーの間隔が整数値に保たれているため, 垂直合成時の調整が容易であり, 場合によっては調整自体が不要となる可能性がある. 
  これは単なる好みの問題に過ぎない. 
  \verb|\qmul|や\verb|\qcomul|のデフォルトの描画結果が\(\q[scale=0.5]{\qmul}\), \(\q[scale=0.5]{\qcomul}\)であるのは, 
  \verb|\qbox[s=2]|や\verb|\qbox[n=2]|の描画結果が\(\q[scale=0.5]{\qbox[s=2]}\), \(\q[scale=0.5]{\qbox[n=2]}\)であることの名残である. 
  このような場合の調整キーとして\verb|hlen|がある:
  \begin{CODEBOX}{フロベニウス則}{FrobeniusLaw2}
    \[
      \q{
        \qwire\qmul[hlen=2,color=black]\n
        \qcomul[hlen=2]\qwire
      }=\q{
        \qcomul[hlen=2]\n
        \qmul[hlen=2,color=black]
      }=\q{
        \qmul[hlen=2,color=black]\qwire\n
        \qwire\qcomul[hlen=2]
      }
    \]
  \end{CODEBOX}

  \verb|\qspider|は, ノードがボックスではなく円であることを除けば, \verb|\qbox|と同じである. 
  \begin{codebox}{}{spider78129738912240521}
    \[\q{\qspider}\]
    \[\q{\qspider[n=0]}\]
    \[\q{\qspider[n=0,s=4]}\]
    \[\q{\qspider[n=2,s=4]}\]
    \[\q{\qspider[N={1,4},s=4]}\]
    \[\q{\qspider[N={2,3},s=4]}\]
    \[\q{\qspider[p=3,N={2},S={1,3}]}\]
    \[\q{\qspider[p=3,N={2},S={1,3},hlen=2]}\]
    \[\q{\qspider[n=1,s=2,hlen=2]}\]
  \end{codebox}

  \begin{CODEBOX}{}{spider78129738912270738}
    \[
      \q{
        \qspider[n=2, s=4, hlen=4]\qwire\qwire\n
        \qwire\qwire\qspider[n=4, s=2, hlen=4]
      }
      =\q{\qspider[p=4]}\]
  \end{CODEBOX}

\subsection{組紐}
\label{subsec:braidedcategory}
\begin{itemize}
  \item \showcmd{qbraid}: \(\q[scale=0.5]{\qbraid}\)
  \item \showcmd{qbraidinv}: \(\q[scale=0.5]{\qbraidinv}\)
  \item \showcmd{qsym}: \(\q[scale=0.5]{\qsym}\)
\end{itemize}

\paragraph{\showcmd[]{num L} と \showcmd[]{num R} キー}
ワイヤーを交叉させた図式を描画するコマンド\verb|\qbraid|, \verb|\qbraidinv|, \verb|\qsym|に対し, 
\showcmd[]{num L}は左側のワイヤーの本数を, \showcmd[]{num R}は右側のワイヤーの本数を指定するキーである. 
例えば, \showcmd[]{num L=3}, \showcmd[]{num R=2} とすれば, \(\q{\qbraid[num L=3,num R=2]}\)が描画される. 
双方デフォルト値はともに\(1\)である. 

\begin{CODEBOX}{六角形等式}{hexagon}
  \begin{equation}
    \label{eq:hexagon}
    \q
    {
      \qbraid[num R=2,,hlen=2,vlen=2]
    }
    =
    \q
    {
      \qwire\qbraid\n
      \qbraid\qwire
    }
    \qquad
    \q
    {
      \qbraid[num L=2,,hlen=2,vlen=2]
    }
    =
    \q
    {
      \qbraid\qwire\n
      \qwire\qbraid
    }
  \end{equation}
\end{CODEBOX}
\paragraph{\({\q[scale=0.5]{\qbraid}}^{-1}=\q[scale=0.5]{\qbraidinv}\)}
\begin{CODEBOX}{}{braidisom2}
  \begin{equation}
    \label{eq:inverse:braid}
    \q
    {
      \qbraidinv\n
      \qbraid
    }
    =
    \q
    {
      \qwire[vlen=2]\qwire[vlen=2]
    }
    \qquad
    \q
    {
      \qbraid\n
      \qbraidinv
    }
    =
    \q
    {
      \qwire[vlen=2]\qwire[vlen=2]
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{組紐の自然性}{braidnatural}
  \begin{equation}
    \label{cond:naturality:braid}
    \q
    {
      \qbraid\n
      \qbox[name={\(f\)}]\qbox[name={\(g\)}]
    }
    =
    \q
    {
      \qbox[name={\(g\)}]\qbox[name={\(f\)}]\n
      \qbraid
    }
    \qquad
    \q
    {
      \qbraidinv\n
      \qbox[name={\(f\)}]\qbox[name={\(g\)}]
    }
    =
    \q
    {
      \qbox[name={\(g\)}]\qbox[name={\(f\)}]\n
      \qbraidinv
    }
  \end{equation}
\end{CODEBOX}

コマンド\verb|\qbraid|, \verb|\qbraidinv|, \verb|\qsym|に対し, 
\showcmd[]{num R=0}と指定すると, \(\q[scale=0.65]{\qbraid[num R=0]}\)のように右側のワイヤーが点線となる. 
\showcmd[]{num L=0}と指定すると, \(\q[scale=0.65]{\qbraid[num L=0]}\)のように左側のワイヤーが点線となる. 
これは, 単位対象を空図式, すなわち\(0\)本のワイヤーとして表すことに由来している.
\begin{CODEBOX}{}{stateeffect3dimbraid}
  \begin{gather}
    \q{
      \qwire\qstate\n
      \qwire
    }
    =\q{
      \qwire\qstate\n
      \qbraid[num L=0]
    }\stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q{
      \qbraid\n
      \qstate\qwire
    }\label{iso:u:state}\\
    \q{
      \qunitob\qwire\n
      \qeffect\qwire
    }
    =\q{
      \qbraid[num L=0]\n
      \qeffect\qwire
    }\stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q{
      \qwire\qeffect\n
      \qbraid
    }\label{iso:u:effect}
  \end{gather}
\end{CODEBOX}
\begin{CODEBOX}{}{iso:spatial:scalar}
  \begin{equation}
    \label{iso:spatial}
    \q{\qscalar\qmv[0,-1]\qwire[vlen=3]}
    =\q{\qbraid[num L=0]\n\qscalar\qmv[0,-1]\qwire[vlen=2]}
    \stackrel{\text{(\ref{cond:naturality:braid})}}{=}
    \q{\qwire[vlen=2]\qscalar\n\qbraid[num L=0]}
    =\q{\qscalar\qmv[-2,-1]\qwire[vlen=3]}
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{}{iso:spatial:state.effect}
  \[
    \q{\qscalar\qmv[0,-1]\qwire[vlen=3]}
    =\q{\qeffect\n\qstate\qmv[0,-0.5]\qwire[vlen=3]}
    \stackrel{\text{(\ref{iso:u:effect})}}{=}
    \q{\qwire\qeffect\n\qbraid\n\qstate\qwire}
    \stackrel{\text{(\ref{iso:u:state})}}{=}
    \q{\qeffect\n\qstate\qmv[-2,-0.5]\qwire[vlen=3]}
    =\q{\qscalar\qmv[-2,-1]\qwire[vlen=3]}
  \]
\end{CODEBOX}
\paragraph{\(\q[scale=0.5]{\qbraid\qwire\n\qwire\qstate[n=2]}=\q[scale=0.5]{\qwire\qbraidinv\n\qstate[n=2]\qwire}\)}
\begin{CODEBOX}{}{dashedbraid}
  \begin{align}
    \q
    {
      \qbraid\qwire\n
      \qwire\qstate[n=2]
    }
    &=\q
    {
      \qbraid\qwire\n
      \qwire\qstate[n=2]\n\n
      \qbraidinv[num L=0,vlen=2,hlen=2.5]
    }
    \stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q
    {
      \qbraid\qwire\n\n
      \qbraidinv[num L=2,vlen=2]\n
      \qstate[n=2]\qwire\n
      \qspace[0.5]\qwire[arrowtype={densely dotted}]\qspace[0.5]\qwire
    }\\
    &=\q
    {
      \qbraid\qwire\n\n
      \qbraidinv[num L=2,vlen=2]\n
      \qstate[n=2]\qwire\n
      \qspace[2]\qwire
      \qbb[green][3]
    }\stackrel{\text{(\ref{eq:hexagon})}}{=}\q
    {
      \qbraid\qwire\n
      \qbraidinv\qwire\n
      \qwire\qbraidinv\n
      \qstate[n=2]\qwire\n
      \qspace[2]\qwire
      \qbb[green][3,...,6]
    }\\
    &=\q
    {
      \qbraid\qwire\n
      \qbraidinv\qwire\n
      \qwire\qbraidinv\n
      \qstate[n=2]\qwire\n
      \qspace[2]\qwire
      \qbb[orange][1,3]
    }
    \stackrel{\text{(\ref{eq:inverse:braid})}}{=}\q
    {
      \qloop[2]{\qloop[3]{\qwire}\n}
      \qwire\qbraidinv\n
      \qstate[n=2]\qwire\n
      \qspace[2]\qwire
      \qbb[orange][1,2,4,5]
    }
  \end{align}
\end{CODEBOX}
  
\begin{CODEBOX}{ヤン-バクスター方程式}{YangBaxer}
  \[
    \q
    {
      \qbraid\qwire\n
      \qwire\qbraid\n
      \qbraid\qwire
    }=\q
    {
      \qwire\qbraid\n
      \qbraid\qwire\n
      \qwire\qbraid
    }
  \]
\end{CODEBOX}

\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{可換性}{def:cmt}
  \begin{equation}
    \label{cond:cmt}
    \q{\qmul[hlen=2]}=\q{\qmul[hlen=2]\n\qbraid}
  \end{equation}
\end{codebox}
\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{余可換性}{def:ccmt}
  \begin{equation}
    \label{cond:ccmt}
    \q{\qcomul[hlen=2]}=\q{\qbraid\n\qcomul[hlen=2]}
  \end{equation}
\end{codebox}
\subsubsection{双代数}
\begin{CODEBOX}{双代数則}{law:bialgebra}
  \begin{gather}
    \q{\qcomul[hlen=2]\qcirc\qmul[hlen=2, color=black]}
    =\q{
      \qmul[hlen=2, color=black]\qmul[hlen=2, color=black]\n
      \qwire\qbraid\qwire\n\qcomul[hlen=2]\qcomul[hlen=2]
      }\\
    \q{\qspace[0.5]\qcounit\qcirc\qmul[hlen=2, color=black]}
    =\q{\qcounit\qcounit}\\
    \q{\qcomul[hlen=2]\qcirc\qspace[0.5]\qunit[color=black]}
    =\q{\qunit[color=black]\qunit[color=black]}\\
    \q{\qcounit\n\qunit[color=black]}
    =\q{\qunitob}
  \end{gather}
\end{CODEBOX}
\subsubsection{ホップ代数}
\begin{CODEBOX}{対合射とホップ則}{law:hopf}
  \begin{equation}
    \q{
      \qmul[hlen=2, color=black]\n
      \qwire\qbox[name={\(s\)}]\n
      \qcomul[hlen=2]
    }
    =\q{\qunit[color=black]\qcirc\qcounit}
    =\q{
      \qmul[hlen=2, color=black]\n
      \qbox[name={\(s\)}]\qwire\n
      \qcomul[hlen=2]
    }
  \end{equation}
\end{CODEBOX}
\subsubsection{平衡圏}
\label{subsub:balancedcategory}
\begin{CODEBOX}{ツイスト}{def:twist}
  \begin{gather}
    \q{
      \qbox[name={\(\theta_{X\otimes Y}\)}, p=2]
      \symbolI{\(X\)}\symbolI[2]{\(Y\)}
      \symbolO{\(X\)}\symbolO[2]{\(Y\)}
    }
    =\q{
      \qbox[name={\(\theta_X\)}]\qbox[name={\(\theta_Y\)}]\n
      \qbraid\n\qbraid
    }\label{cond:twist}\\
    \q{\qbox[name={\(\theta_I\)}]}=\q{\qunitob}\label{cond:i:twist}\\
    \forall\q{\qbox[name={\(f\)}]}\colon
    \q{
      \qbox[name={\(\theta_{\operatorname{cod}(f)}\)}, hlen=1.5]\n
      \qbox[name={\(f\)}, hlen=1.5]
    }=\q{
      \qbox[name={\(f\)}, hlen=1.5]\n
      \qbox[name={\(\theta_{\operatorname{dom}(f)}\)}, hlen=1.5]
    }\label{cond:naturality:twist}
  \end{gather}
\end{CODEBOX}
\subsubsection{色}
\label{subsubsec:braid:color}

\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{対称}{defeq:sym}
  \begin{equation}
    \label{cond:symmetry}
    \q
    {
      \qbraid[L color=cyan, R color=red]\n
      \qbraid[L color=red, R color=cyan]
    }
    =\q{\qwire[color=red, vlen=2]\qwire[color=cyan, vlen=2]}
  \end{equation}
\end{codebox}

\begin{CODEBOX}{}{wowsym}
  \[\q{\qbraid[L color=red, R color=cyan]}
  =\left(\q{\qbraid[L color=cyan, R color=red]}\right)^{-1}
  =\q{\qbraidinv[L color=red, R color=cyan]}\]
\end{CODEBOX}
\begin{codebox}{シンメトリー}{def:sym}
  \q{\qsym}
\end{codebox}

\subsection{双対性}
\label{subsub:duality}
\begin{itemize}
  \item \showcmd{qcap}: \(\q[scale=0.6]{\qcap}\)
  \item \showcmd{qcup}: \(\q[scale=0.6]{\qcup}\)
  \item \showcmd{qcaprev}: \(\q[scale=0.6]{\qcaprev}\)
  \item \showcmd{qcuprev}: \(\q[scale=0.6]{\qcuprev}\)
\end{itemize}

\begin{CODEBOX}{ジグザグ等式}{Snake}
  \begin{equation}
    \label{eq:snake}
    \q{
      \qcap\qwireup\n
      \qwireup\qcup
    }
    =\q{
      \qwireup[vlen=2]
    }
    \qquad\text{と}\qquad
    \q{
      \qwiredown\qcap\n
      \qcup\qwiredown
    }
    =\q{
      \qwiredown[vlen=2]
    }
  \end{equation}        
\end{CODEBOX}

\subsubsection{転置ボックス}
\label{subsub:transpose}
\begin{CODEBOX}{転置}{Transpose}
  \[
    \left(\q{\qwire\n\qasym[name={\(f\)}]\n\qwire}\right)^T
    =\q{
      \qwire\n
      \qtrans[name={\(f\)}]\n
      \qwire
    }\coloneq\q{
      \qwire\qcap\n
      \qwire\qasym[name={\(f\)}]\qwire\n
      \qcup\qwire
    }
  \]
\end{CODEBOX}
\begin{CODEBOX}{}{ex:193477432894021826}
  \begin{equation}
    \label{eq:wirerev}
    \left(\q{\qwireup}\right)^T=\q{\qwiredown}
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{スライディング}{Sliding}
  \begin{equation}
    \label{eq:sliding}
    \q{
      \qcap \n
      \qasym \qwire
    }
    =\q{
      \qcap \n
      \qwire \qtrans
    }
    \qquad
    \q{
      \qwire \qasym \n
      \qcup
    }
    =\q{
      \qtrans \qwire \n
      \qcup
    }
  \end{equation}
\end{CODEBOX}

\begin{CODEBOX}{}{MapStateDuality}
  \begin{equation}
    \begin{array}{rccc}
      \operatorname{NAME}\colon & \operatorname{Hom}(X,Y)
      & \to & \operatorname{Hom}(I,X^T\otimes Y)\\
      & \rotatebox{90}{\(\in\)} && \rotatebox{90}{\(\in\)}\\
      & \q{
        \qasym
        \symbolI{\(X\)}
        \symbolO{\(Y\)}
      } & \mapsto 
      & \q{
        \qwire[label={\(X^T\)}, label at={at end}, label side={above}] \qasym \n
        \qcup
        \symbolO{\(Y\)}[id=2]
      }
    \end{array}
  \end{equation}
\end{CODEBOX}

\begin{CODEBOX}{}{MapEffectDuality}
  \begin{equation}
    \begin{array}{rccc}
      \operatorname{CONAME}\colon & \operatorname{Hom}(X,Y) 
      & \to & \operatorname{Hom}(X\otimes Y^T,I)\\
      & \rotatebox{90}{\(\in\)}&&\rotatebox{90}{\(\in\)}\\
      & \q{
        \qasym
        \symbolI{\(X\)}
        \symbolO{\(Y\)}
      } & \mapsto 
      & \q{
        \qcap \n
        \qasym \qwire[label={\(Y^T\)}, label at={at start}, label side={below}]
        \symbolI{\(X\)}[id=2]
      }
    \end{array}
  \end{equation}
\end{CODEBOX}

\subsubsection{コピー禁止定理}
\label{subsub:nocopy}
\begin{CODEBOX}{一様コピー}{def:copy}
  \begin{gather}
    \q{
      \qwire\qbraid\qwire\n
      \qcomul[hlen=2, name={\(\text{copy}_X\)}]\qcomul[hlen=2, name={\(\text{copy}_Y\)}]
      \symbolI{\(X\)}[id=4]\symbolI{\(Y\)}[id=5]
      \symbolO{\(X\)}[id=1]\symbolO{\(Y\)}[id=2]
      \symbolO[2]{\(X\)}[id=2]\symbolO{\(Y\)}[id=3]
    }=\q{
      \qcomul[hlen=3, vlen=2, name={\(\text{copy}_{X\otimes Y}\)}]\symbolI{\(X\otimes Y\)}
      \symbolO{\(X\otimes Y\)}\symbolO[2]{\(X\otimes Y\)}
    }\label{cond:copy}\\
    \forall\q{\qbox[name={\(f\)}]\symbolI{\(X\)}\symbolO{\(Y\)}}\colon
    \q{
      \qbox[name={\(f\)}]\qbox[name={\(f\)}]\n
      \qcomul[hlen=2, name={\(\text{copy}_X\)}]
    }=\q{
      \qcomul[hlen=2, name={\(\text{copy}_Y\)}]\n
      \qspace[0.5]\qbox[name={\(f\)}]
    }\label{cond:morcopy}\\
    \q{
      \qcomul[hlen=2, name={\(\text{copy}_I\)}]\symbolI{\(I\)}
      \symbolO{\(I\)}\symbolO[2]{\(I\)}
    }=\q{\qunitob}\label{cond:i:copy}
  \end{gather}
\end{CODEBOX}

\begin{CODEBOX}{コピー可能状態}{def:copyablestate}
  \[
    \q{
      \qcomul[hlen=2, name={\(\operatorname{copy}\)}]\n
      \qspace[0.5]\qstate[name={\(a\)}]
    }=\q{
      \qstate[name={\(a\)}]\qstate[name={\(a\)}]
    }
  \]
\end{CODEBOX}
\begin{CODEBOX}{}{len:copycupcup}
  \begin{align*}
    \q{\qcup\qcup}&\stackrel{\text{(\ref{cond:i:copy})}}{=}
    \q{
      \qcup\qcup\n\qmv[0.5,0.4]
      \qcomul[dom arrowtype=dotted, cod arrowtype=dotted, hlen=3, name={\(\operatorname{copy}\)}]
    }\stackrel{\text{(\ref{cond:morcopy})}}{=}
    \q{
      \qspider[
        name={\(\operatorname{copy}\)}, 
        N={1,2,4,5}, 
        s=2, 
        hlen=2
      ]\n\qcup
    }\\
    &\stackrel{\text{(\ref{cond:copy})}}{=}\q[scale=0.6]{
        \qwire\qbraid\qwire\n
        \qloop[4]{\qwire}\n
        \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
        \qspace[0.5]\qcup[hlen=3]
        \qbb[red][4,8]
    }\stackrel{\text{(\ref{cond:ccmt})}}{=}\q[scale=0.6]{
        \qwire\qbraid\qwire\n
        \qbraidinv\qwire\qwire\n
        \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
        \qspace[0.5]\qcup[hlen=3]
        \qbb[red][4,7]
      }\\
      &=\q[scale=0.6]{
        \qwire\qbraid\qwire\n
        \qbraidinv\qwire\qwire\n[2]
        \qloop[4]{\qwire[vlen=2]}\n
        \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
        \qspace[0.5]\qcup[hlen=3]
        \qbb[blue][8,9]
      }
      \stackrel{\text{(\ref{eq:inverse:braid})}}{=}
      \q[scale=0.6]{
        \qwire\qbraid\qwire\n
        \qbraidinv\qwire\qwire\n
        \qwire\qbraidinv\qwire\n
        \qwire\qbraid\qwire\n
        \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
        \qspace[0.5]\qcup[hlen=3]
        \qbb[blue][8,11]
      }\\
      &=\q[scale=0.6]{
        \qwire\qbraid\qwire\n
        \qbraidinv\qwire\qwire\n
        \qwire\qbraidinv\qwire\n
        \qwire\qbraid\qwire\n
        \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
        \qspace[0.5]\qcup[hlen=3]
        \qbb[yellow][10,14,15]
      }\stackrel{\text{(\ref{cond:copy}, \ref{cond:morcopy}, \ref{cond:i:copy})}}{=}
      \q[scale=0.6]{
        \qwire\qbraid\qwire\n
        \qbraidinv\qwire\qwire\n
        \qwire\qbraidinv\qwire\n
        \qcup\qcup
        \qbb[yellow][10,11]
      }\\
      &=\q{
        \qwire\qbraid\qwire\n
        \qcup[n=4]
      }
  \end{align*}
\end{CODEBOX}
\begin{CODEBOX}{}{len:copybraid}
  \begin{align*}
    \q{
      \qbraid
      \symbolI{\(X\)}\symbolO{\(X\)}
      \symbolI[2]{\(X\)}\symbolO[2]{\(X\)}
    }&\stackrel{\text{(\ref{eq:snake})}}{=}\q[scale=0.6]{
      \qwire\qspace[2]\qcap\qwire\n
      \qbraid[hlen=4]\qwire\qwire\n
      \qwire\qcap\qwire\qcup\n
      \qwire\qwire\qcup
      \qbb[blue][1,5]
    }=\q[scale=0.6]{
      \qcap[hlen=4]\qwire\n
      \qwire\qspace[2]\qbraidinv\n
      \qwire\qcap\qwire\qwire\qwire[vlen=3]\n
      \qwire\qwire\qcup\qcup
      \qbb[blue][1,4]
      \qbb[yellow][12,13]
    }\\
    &\stackrel{\text{例 \ref{len:copycupcup}}}{=}\q[scale=0.6]{
      \qcap[hlen=4]\qwire\n
      \qwire\qspace[2]\qbraidinv\n
      \qwire\qcap\qwire\qwire\qwire[vlen=3]\n
      \qwire\qwire\qwire\qbraid\qwire\n
      \qwire\qwire\qcup[n=4]
      \qbb[yellow][12,14,17]
    }\\
    &=\q[scale=0.6]{
      \qcap[s=4]\qwire\n
      \qloop[3]{\qwire}\qbraidinv\n
      \qloop[3]{\qwire}\qbraid\qwire[vlen=3]\n
      \qwire\qwire\qcup[n=4]
      \qbb[green][6,10]
    }\stackrel{\text{(\ref{eq:inverse:braid})}}{=}\q[scale=0.6]{
      \qcap[s=4]\qwire\qwire\n[2]
      \qloop[6]{\qwire[vlen=2]}\n
      \qwire\qwire\qcup[n=4]
      \qbb[green][7,8]
    }\\
    &\stackrel{\text{(\ref{eq:snake})}}{=}\q{
      \qwire\qwire
      \symbolI{\(X\)}[id=1]\symbolO{\(X\)}[id=1]
      \symbolI{\(X\)}\symbolO{\(X\)}
    }
  \end{align*}
\end{CODEBOX}

\begin{CODEBOX}{クローン禁止定理}{thm:nocopy}
  \begin{align*}
    \q{
      \qasym[name={\(f\)}]
      \symbolI{\(X\)}\symbolO{\(X\)}
    }&\stackrel{\text{(\ref{eq:snake})}}{=}
    \q{
      \qcap\qasym[name={\(f\)}]\n
      \qwire\qcup
    }\stackrel{\text{(\ref{eq:inverse:braid})}}{=}\q{
      \qcap\qasym[name={\(f\)}]\n
      \qwire\qbraidinv\n
      \qwire\qbraid\n
      \qwire\qcup
    }\stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q{
      \qcap\qwire\n
      \qwire\qbraidinv\n
      \qwire\qasym[name={\(f\)}]\qwire\n
      \qwire\qbraid\n
      \qwire\qcup
      \qbb[red][1,4]
    }\\
    &=\q{
      \qwire\qcap\n
      \qbraid\qwire\n
      \qwire\qasym[name={\(f\)}]\qwire\n
      \qwire\qbraid\n
      \qwire\qcup
      \qbb[red][1,4]
    }=\q{
      \qwire\qcap\n
      \qbraid\qwire\n
      \qwire\qasym[name={\(f\)}]\qwire\n
      \qwire\qbraid\n
      \qwire\qcup
      \qbb[blue][3]
    }\stackrel{\text{例 \ref{len:copybraid}}}{=}\q{
      \qwire\qcap\n
      \qwire\qwire\qwire\n
      \qwire\qasym[name={\(f\)}]\qwire\n
      \qwire\qbraid\n
      \qwire\qcup
      \qbb[blue][3,4]
    }
  \end{align*}
\end{CODEBOX}
\subsection{ピボタル圏}
\label{subsec:pivotal}
\begin{CODEBOX}{}{struct:Pivotal}
  \begin{equation}
    \label{cond:naturality:pivotal}
    \forall\q{\qasym[name={\(f\)}]\symbolI{\(X\)}\symbolO{\(Y\)}}\colon
    \q[scale=0.5]{
      \qwire\qcap[s=4]\n
      \qwire\qwire\qasym[name={\(f\)}]\qwire\qwire\n
      \qcup[n=4]\qwire\qmv[-1,-1]\qasym[name={\(\pi_X\)}]
    }=\q{
        \qasym[name={\(\pi_Y\)}]\n
        \qasym[name={\(f\)}]
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{}{dualrev}
  \begin{equation}
    \label{def:dualrev}
    \q{
      \qcaprev\n
      \symbolI{\(X^T\)}\symbolI[2]{\(X\)}
    }\coloneq\q
    {
      \qcap \n
      \qwire \qwireupup \n
      \qwire \qasym[name={\(\pi_x\)}] \n
    }\qquad\q{
      \qcuprev
      \symbolO{\(X\)}\symbolO[2]{\(X^T\)}
    }\coloneq\q
    {
      \qasym[name={\(\pi_X^{-1}\)}]\qwire\n
      \qwireupup\qwire\n
      \qcup
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{}{revSliding}
  \begin{equation}
    \label{eq:sliding:rev}
    \q{
      \qcaprev\n
      \qtrans\qwire\n
    }=\q{
      \qcaprev\n
      \qwire\qasym
    }\qquad\q{
      \qwire\qtrans\n
      \qcuprev
    }=\q{
      \qasym\qwire\n
      \qcuprev
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{}{corr:pivotal:twist}
  \begin{gather}
    \q{
      \qwireuu[label={\(X^{TT}\)}]\n
      \qasym[name={\(\pi_X\)}]\n
      \qwireup[label={\(X\)}]
    }=\q{
      \qwireuu[label={\(X^{TT}\)}]\qcap\n
      \qbraid\qwired[label={\(X^T\)}]\n
      \qasym[name={\(\theta_X^{-1}\)}]\qcuprev\n
      \qwireup[label={\(X\)}]
    }\label{twist:pivotal}\\
    \q{
      \qwireup[label={\(X\)}]\n
      \qasym[name={\(\theta_X\)}]\n
      \qwireup[label={\(X\)}]
    }=\q{
      \qwireup[label={\(X\)}]\n
      \qasym[name={\(\pi_X^{-1}\)}]\n
      \qwireuu[label={\(X^{TT}\)}]\qcap\n
      \qbraid\qwired[label={\(X^T\)}]\n
      \qwire[label={\(X\)}]\qcuprev
    }\label{pivotal:twist}
  \end{gather}
\end{CODEBOX}
\begin{CODEBOX}{}{ex193477432894100303}
  \begin{align*}
    \q{\qasym[name={\(\theta_X\)}]}
    &=\q{
      \qwireu[label={\(X\)}]\qcap\n
      \qbraid\qwired\n
      \qwireu[label={\(X\)}]\qcuprev
    }&\q{\qasym[name={\(\theta_X^{-1}\)}]}
    &=\q{
      \qcaprev\qwireu[label={\(X\)}]\n
      \qwired\qbraidinv\n
      \qcup\qwireu[label={\(X\)}]
    }\\
    \q{\qtrans[name={\(\theta_X\)}]}
    &=\q{
      \qcap\qwired[label={\(X^T\)}]\n
      \qwireu\qbraid\n
      \qcuprev\qwired[label={\(X^T\)}]
    }&\q{\qtrans[name={\(\theta_X^{-1}\)}]}
    &=\q{
      \qwired[label={\(X^T\)}]\qcaprev\n
      \qbraidinv\qwireu\n
      \qwired[label={\(X^T\)}]\qcup
    }
  \end{align*}
\end{CODEBOX}
\begin{CODEBOX}{リボン圏}{code:def:ribboncategory}
  \begin{equation}
    \label{def:ribboncategory}
    \q{
      \qwired\qcaprev\n
      \qbraid\qwireu\n
      \qwired\qcup
    }=\q{
      \qcap\qwired\n
      \qwireu\qbraid\n
      \qcuprev\qwired
    }
  \end{equation}
\end{CODEBOX}

\subsubsection{トレース}
\label{subsub:trace}
\begin{CODEBOX}{トレース}{Trdef}
  \[
    \begin{array}{rccc}
      \operatorname{Tr}\colon & \operatorname{Hom}(X,X) & \to &\operatorname{Hom}(I,I)\\
      &\rotatebox{90}{\(\in\)}&&\rotatebox{90}{\(\in\)}\\
      &\q{
        \qasym[name={\(f\)}]
      } & \mapsto & \q{
        \qcap\n
        \qasym[name={\(f\)}]\qwire\n
        \qcuprev
      }
    \end{array}
  \]
\end{CODEBOX}

\begin{CODEBOX}{トレースの可換性}{Cotr}
  \begin{equation}
    \label{cmt:trace}
    \operatorname{Tr}\left(\q{
      \qasym[name={\(g\)}]\n
      \qasym[name={\(f\)}]
      }\right)
    =\q{
      \qcap\n
      \qasym[name={\(g\)}]\qwire\n
      \qasym[name={\(f\)}]\qwire\n
      \qcuprev
      }
    \stackrel{\text{(\ref{eq:sliding})}}{=}\q{
      \qcap\n
      \qasym[name={\(f\)}]\qtrans[name={\(g\)}]\n
      \qcuprev
    }\stackrel{\text{(\ref{eq:sliding:rev})}}{=}\q{
      \qcap\n
      \qasym[name={\(f\)}]\qwire\n
      \qasym[name={\(g\)}]\qwire\n
      \qcuprev
    }=\operatorname{Tr}\left(\q{
      \qasym[name={\(f\)}]\n
      \qasym[name={\(g\)}]
      }\right)
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{対象の次元}{def:dim}
  \[
    \q{\qscalar[name={\(\operatorname{dim}(X)\)}]}
    \coloneq\q{\qscalar[name={\(\operatorname{Tr}(\operatorname{id}_X)\)}]}
    =\q{\qcap\n\qcuprev}
  \]
\end{CODEBOX}
\subsubsection{コンパクト圏}
\label{subsubsec:compact}
\begin{CODEBOX}{コンパクト圏}{Def:compact}
  \begin{equation}
    \label{def:compact}
    \q{\qasym[name={\(\pi_X\)}]}=\q{
      \qwireuu[label={\(X^{TT}\)}]\qcap\n
      \qsym\qwired[label={\(X^T\)}]\n
      \qwire[label={\(X\)}]\qcuprev
    }
  \end{equation}
\end{CODEBOX}
\subsubsection{色}
\label{subsubsec:duality:color}
\begin{CODEBOX}{}{Ex:coloredhopflink}
  \begin{equation}
    \label{eq:tr:hopf}
    \operatorname{Tr}\left(
      \q{
        \qbraid[L color=blue, R color=orange]\n
        \qbraid[L color=orange, R color=blue]}
    \right)
    =\q{
      \qcap[hlen=4, frame color=orange]\n
      \qwire[color=orange]\qcap[frame color=blue]\n
      \qbraid[L color=blue, R color=orange]\n
      \qbraid[L color=orange, R color=blue
      ]\qwiredown[vlen=2, color=blue]\n
      \qwire[color=orange]
      \qcuprev[frame color=blue]
      \qwiredown[vlen=4, color=orange]\n
      \qcuprev[hlen=4, frame color=orange]
    }=\q{
      \qcap[frame color=blue]
      \qcap[frame color=orange]\n
      \qspace
      \qbraidinv[L color=orange, R color=blue]\n
      \qwireup[vlen=2, color=blue]
      \qbraidinv[L color=blue, R color=orange]
      \qwiredown[vlen=2, color=orange]\n
      \qcuprev[frame color=blue]
      \qcuprev[frame color=orange]
    }
  \end{equation}
\end{CODEBOX}
\subsection{ダガー}
\label{subsec:dagger}
\subsubsection{随伴ボックス}
\label{subsub:adjoint}
\begin{CODEBOX}{随伴}{def:adj}
  \begin{gather}
    \left(
      \q{
        \qasym[name={\(f\)}]
        \symbolI{\(X\)}\symbolO{\(Y\)}
      }
    \right)^{\dagger}
    \coloneq
    \q{
      \qadj[name={\(f\)}]
      \symbolI{\(Y\)}\symbolO{\(X\)}
    }\\
    \left(\q{\qasym[name={\(f\)}]}\right)^{\dagger\dagger}
    =\left(\q{\qadj[name={\(f\)}]}\right)^{\dagger}
    =\q{\qasym[name={\(f\)}]}\\
    \left(\q{\qwire}\right)^{\dagger}=\q{\qwire}\\
    \q{
      \qadj[name={\(f\)}]\n
      \qadj[name={\(g\)}]
    }=\q{
      \qadj[name={\(g\circ f\)}]
    }
\end{gather}
\end{CODEBOX}
\subsubsection{共役ボックス}
\label{subsub:conj}
\begin{CODEBOX}{}{prep:conj}
  \begin{align*}
    \left(\q{\qadj}\right)^T
    &=\q{
      \qwire\qcap\n
      \qwire\qadj\qwire\n
      \qcup\qwire
    }=\q{
      \qcaprev\qwire\n
      \qwire\qadj\qwire\n
      \qwire\qcuprev
    }=\left(
      \q{
        \qwire\qcap\n
        \qwire\qasym\qwire\n
        \qcup\qwire
      }
    \right)^{\dagger}=\left(\q{\qtrans}\right)^{\dagger}
  \end{align*}
\end{CODEBOX}
\section{素子一覧}
\label{sec:fcommands}
\begin{tcbraster}[raster columns=4,raster equal height=rows,fonttitle=\bfseries,
  colframe=cyan!90,coltitle=cyan!50,colbacktitle=black,
  subtitle style={boxrule=0.4pt,
  colback=black!70}
  ]
  \begin{tcolorbox}[adjusted title={\showcmd{qwire}[cyan]}]
    \[\q{\qwire}\]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qbox}[cyan]}]
    \[
      \q{
        \qbox
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qstate}[cyan]}]
    \[
      \q{
        \qstate
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qeffect}[cyan]}]
    \[
      \q{
        \qeffect
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qscalar}[cyan]}]
    \[
      \q{
        \qscalar
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qunitob}[cyan]}]
    \[
      \q{
        \qunitob
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qmul}[cyan]}]
    \[
      \q{
        \qmul[hlen=2]
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qcomul}[cyan]}]
    \[
      \q{
        \qcomul[hlen=2]
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qunit}[cyan]}]
    \[
      \q{
        \qunit
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qcounit}[cyan]}]
    \[
      \q{
        \qcounit
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qspider}[cyan]}]
    \[
      \q{
        \qspider[p=4,hlen=2]
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qbraid}[cyan]}]
    \[
      \q{
          \qbraid
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qbraidinv}[cyan]}]
    \[
      \q{
        \qbraidinv
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qsym}[cyan]}]
    \[
      \q{
        \qsym
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qcap}[cyan]}]
    \[
      \q{
        \qcap
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qcup}[cyan]}]
    \[
      \q{
        \qcup
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qwireu}[cyan]}]
    \[\q{\qwireup}\]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qwired}[cyan]}]
    \[\q{\qwiredown}\]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qwireuu}[cyan]}]
    \[\q{\qwireuu}\]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qwiredd}[cyan]}]
    \[\q{\qwiredd}\]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qasym}[cyan]}]
    \[
      \q{
        \qasym
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qtrans}[cyan]}]
    \[
      \q{
        \qtrans
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{adj}[cyan]}]
    \[
      \q{
        \qadj
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qconj}[cyan]}]
    \[
      \q{
        \qconj
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qcaprev}[cyan]}]
    \[
      \q{
        \qcaprev
      }
    \]
  \end{tcolorbox}
  \begin{tcolorbox}[adjusted title={\showcmd{qcuprev}[cyan]}]
    \[
      \q{
        \qcuprev
      }
    \]
  \end{tcolorbox}
\end{tcbraster}
\addcontentsline{toc}{section}{参考文献}
\begin{thebibliography}{99}
  \bibitem{tikz-manual}
  Till Tantau,
  \textit{The TikZ and PGF Packages Manual for Version 3.1.10},
  Institut für Theoretische Informatik, Universität zu Lübeck,
  n.d.,
  \url{https://github.com/pgf-tikz/pgf}
  (retrieved March 22, 2025).
  \bibitem{geniussorting}
  Anonymous,
  \textit{Genius Sorting Algorithm},
  4chan Programming Board,
  January 20, 2011,
  \url{https://dis.4chan.org/read/prog/1295544154}
  (accessed January 20, 2011; link currently inactive).
  \bibitem{gfxhatena}
  gfx,
  \textit{常識を覆すソートアルゴリズム！その名も"sleep sort"！},
  Hatena Diary,
  May 19, 2011,
  \url{https://gfx.hatenadiary.org/entry/20110519/1305810786}.
  \bibitem{literateprograms}
  LiteratePrograms,
  \textit{Turing Machine Simulator in \LaTeX},
  \url{https://literateprograms.org/turing_machine_simulator__latex_.html},
  n.d.,
  retrieved March 22, 2025.
  \bibitem{overleaf}
  Overleaf,
  \textit{\LaTeX\ is More Powerful than You Think: Computing the Fibonacci Numbers and Turing Completeness},
  \url{https://www.overleaf.com/learn/latex/Articles/LaTeX_is_More_Powerful_than_you_Think_-_Computing_the_Fibonacci_Numbers_and_Turing_Completeness},
  n.d.,
  retrieved March 22, 2025.
\end{thebibliography}
\begin{changelog}[author=新名亮太, sectioncmd=\section*]

  \shortversion{v=1.1.2, date=2025-07-28,
    changes={英語版ドキュメンテーション (qworld\_en.pdf) および対応する\TeX\ ソースファイル (qworld\_en.tex) のタイプミスを修正した. この変更は英語版ドキュメンテーション (qworld\_en.pdf) と\TeX\ ソースファイル (qworld\_en.tex) のみに影響し, スタイルファイルには影響しない. }
  }

  \begin{version}[v=1.1.1, date=2025-04-14]
    \added
      \item 彩色機能\par 図式表現において, 組紐, シンメトリー, キャップ, カップ等に対して色属性を指定できるようになった. 対象の識別に有効な視覚的手がかりを提供する. 
    \fixed
      \item ワイヤーや組紐, シンメトリー, キャップ, カップの曲線処理が修正され, より滑らかな描画が可能となった. 
  \end{version}
  
  \begin{version}[v=1.1.0,date=2025-04-03]
    \changed
      \item コマンドの引数仕様の刷新\par 以下のコマンドがアップデートされ, 従来の必須引数から柔軟なキーバリュー形式の柔軟なオプション引数へと変更された:
      \begin{itemize}
        \item \showcmd{symbolI}
        \item \showcmd{symbols}
        \item \showcmd{symbolS}
        \item \showcmd{symbolO}
        \item \showcmd{symboln}
        \item \showcmd{symbolN}
      \end{itemize}
      \begin{description}
        \item[旧仕様] \showcmd{symbolI[i]\{ID\}\{text\}[位置オプション]}[old]
        \item[新仕様] \showcmd{symbolI[i]\{text\}[id=ID, 位置オプション]}[new]
      \end{description}
      この変更により, \showcmd[]{ID}の指定を省略できるようになり, 従来の\showcmd{symbolI\{ID\}\{text\}}[old]に比べ, \showcmd[]{ID}が不要な場面では\showcmd{symbolI\{text\}}[new]と記述するだけで済むようになった. 結果として, 記述量が削減されコードの可読性が向上した. 
    \added
      \item 英語のドキュメントの追加\par パッケージのユーザーガイド (英語版) を新たに追加した. 
  \end{version}
  
  \shortversion{v=1.0.0,
    date=2025-04-01,
    changes={初回リリース}
  }
\end{changelog}
\section*{License and Copyright}

This package is distributed under the \textbf{LaTeX Project Public License (LPPL)}, version 1.3c or later.  
For details, see \url{https://www.latex-project.org/lppl.txt}.

Copyright \textcopyright 2025 Niina Ryota

You are free to distribute and modify this package under the terms of LPPL.  
However, any modified versions \textbf{must not} be distributed under the original name, and the original author must be credited.
\end{document}