\section{Introduction}
\label{sec:introduction}

\begin{figure}[t!]
  \centering
    \begin{overpic}[width=.8\linewidth]{figs/acc_runtime.pdf}
    \end{overpic}
   \caption{
   \textbf{Accuracy (S-measure) and inference time (ms) of the update-to-date and representative deep-learning-based CoSOD methods on the CoSOD3k dataset~\cite{CoSOD3k}.} We conduct the comparison on both accuracy (the vertical axis) and speed (the horizontal axis) among seven existing representative CoSOD models and our MCCL{}. Larger bubbles mean larger volume of the model weights. Our MCCL{}~achieves great performance (0.860 S-measure) in real time (7.6 ms) with a lightweight model (104.5 Mb weights and 5.93G FLOPs).
   }\label{fig:acc_runtime}
\end{figure}

Co-Salient object detection (CoSOD) aims at detecting the most common salient objects among a group of source images. Compared with the standard salient object detection (SOD) task, CoSOD is more challenging for distinguishing co-occurring objects across a group of images where salient objects of different classes and non-salient objects of the same class are both hard distractors.
CoSOD methods also show their advantage of acting as a pre-processing step for other computer vision tasks, such as semantic segmentation~\cite{zeng2019joint},
co-segmentation~\cite{hsu2019deepco3},
and object tracking~\cite{Zhou2021SaliencyAssociatedOT}, \emph{etc}.} \def\vs{\emph{vs}..

Previous works tend to exploit various types of consistency among the image group to solve the CoSOD task, including shared features~\cite{CBCS} and common semantic information~\cite{MetricCoSOD}. With the success of unified models in up-stream tasks~\cite{Ren2015FasterRT,OIM}, the latest CoSOD models try to address salient object detection and common object detection in a unified framework~\cite{GCoNet,CoSOD3k,GICD}.
Despite the promising performance achieved by these methods, most of them only focus on learning better consistent feature representations in an individual group~\cite{GICD,GWD,CoADNet,GLNet,ICNet,SRG}, which may make them suffer from the following limitations. First, images from the same group can only act as positive samples of each other. Consensus representations learned from all positive samples might be difficult to be distinguished due to the lack of inter-group separability. Besides, the number of images in a single group is usually insufficient for models to learn robust and unique representations, which can be easily distinguishable from others. Due to the higher complexity of image context in real-world applications, the number of object classes will increase significantly, making the consensuses have a higher risk of getting closer to others and being hard to identify. In this situation, a module designed for bridging the cross-group connection and learning consensuses of distinction is in high demand.

To achieve accurate and fast CoSOD, we propose Memory-aided Contrastive Consensus Learning (MCCL{}), which exploits common features within each group and identifies distinctions among different groups, guiding the model to produce co-saliency maps with high integrity. To fulfill the above goal, three key components are proposed in MCCL{}. \textbf{First}, we present the Group Consensus Aggregation Module (GCAM) for mining the common feature within the same group by the correlation principle. \textbf{Second}, we introduce the Memory-based Contrastive Module (MCM) to conduct robust contrastive learning with a long-term memory. More concretely, the consensus of each class is saved and updated with momentum in a memory queue to avoid the instability of online contrastive learning. \textbf{Third}, we employ the Adversarial Integrity Learning (AIL) to improve the integrity and quality of predicted maps in an adversarial fashion, where a discriminator identifies whether the masked regions are obtained from predicted or ground-truth maps. Analogous to generative adversarial networks~\cite{GAN}, our model tries to fool the discriminator and produce high-quality and high-integrity maps that can mask complete and intact objects.

Our main contributions can be summarized as follows:
\begin{itemize}

\item We establish a fast yet strong CoSOD baseline with the Transformer, which outperforms most existing methods that are sophisticatedly equipped with many components.

\item We introduce the Group Consensus Aggregation Module (GCAM) to generate the consensus of each group in an effective way. To make the consensus more discriminative to each other, we propose the Memory-based Contrastive Module (MCM) in a metric learning way.

\item Furthermore, the Adversarial Integrity Learning (AIL) is proposed to improve the quality and integrity of predicted co-saliency maps in an adversarial learning manner.

\item We conduct extensive experiments to validate the superiority of our MCCL{}. Extensive quantitative and qualitative results show that our MCCL{}~can outperform existing CoSOD models by a large margin.

\end{itemize}

\section{Related Work}
\label{sec:Related Work}
\subsection{Salient Object Detection}
Before the deep learning era, handcrafted features played the most critical role in detection~\cite{Cheng2011GlobalCB,SOD_trad1,SOD_trad2} among the traditional SOD methods. When it comes to the early years of deep learning, features are usually extracted from image patches, which will then be used to generate object proposals~\cite{SOD_op1,SOD_op2,SOD_op3}, or super-pixels~\cite{SOD_patch1,SOD_patch2} as processing units.
As stated in~\cite{PoolNet+}, the network architectures of existing SOD methods can be divided into five categories, \emph{i.e}.} \def\Ie{\emph{I.e}., U-shape, side-fusion, multi-branch, single-steam, and multi-stream. So far, U-shape has been the most widely used architecture \cite{UNet}, especially when the fusion between low-level and high-level features is needed.
Supervision on the multi-stage output is also employed at the early stages by aggregating features from different levels of networks in the U-shape architecture to make the output features more robust and stable~\cite{EGNet,GCoNet,GICD}.~\cite{SOD_att1,SOD_att2,SOD_att3} employed the attention mechanism in their models for further improvement. Besides, some external information is also introduced as extra guidance for training, such as boundary~\cite{BASNet}, edge~\cite{EGNet}, and depth~\cite{EGNet}.

\subsection{Co-Salient Object Detection} CoSOD emphasizes on detecting salient objects across groups of images rather than in a single image. Traditional CoSOD methods utilize handcrafted cues (\emph{e.g}.} \def\Eg{\emph{E.g}., superpixels~\cite{SLIC}) to explore the correspondence of images. In contrast, the deep learning-based methods learn the consensus feature representation of common objects in an end-to-end manner~\cite{GWD,MetricCoSOD}. Various model architectures are applied to improve the CoSOD performance, including CNN-based~\cite{GCoNet,CoADNet,GICD} and Transformer-based models~\cite{CoSformer}. Though some of the existing methods investigate both intra-group and inter-group cues~\cite{GCoNet}, there is still much room for improvement in the fully coordinated and simultaneous use of intra-group and inter-group information.

\subsection{Integrity Learning for Saliency Maps}
The quality of saliency maps has attracted much attention in recent years to make existing saliency-related tasks closer to real-world applications.
\cite{integrity_1} tries to guide their models to learn integrity via the collaboration between global context and local objects. TSPOANet~\cite{integrity_3} adopts a capsule network to model the part-object relationship to achieve better wholeness and uniformity of segmented salient objects.
In~\cite{BASNet}, a hybrid loss is applied for more focus on improving the boundary of predicted maps. Furthermore,~\cite{integrity} investigates more into the integrity issue in SOD and tries solving this problem with their carefully designed components. In~\cite{GCoNet+}, a confidence enhancement module is proposed to make the predicted maps more binarized.

\section{Methodology}
\label{sec:methodology}

\begin{figure*}[t!]
  \centering
    \begin{overpic}[width=.95\linewidth]{figs/arch_final.pdf}
    \end{overpic}
   \caption{
   \textbf{Overall framework of the proposed Memory-aided Contrastive Consensus Learning (MCCL).} Input images are obtained from multiple groups and fed to an encoder. First, we employ the Group Consensus Aggregation Module (GCAM), where the intra-group features of each group can be learned separately. With the consensus learned from each single group, the consensus features are updated in the memory of each class in the queue of Memory-based Contrastive Module (MCM). Then, contrastive learning is conducted to make the consensus more discriminative to each other. Each stage of our encoder and decoder is connected with only a 1x1 convolution layer for feature adding with the least computation. Our decoder is composed of four DecBlk, which is the vanilla residual block. We design our model as simple as possible to make our study more open and solid. Finally, saliency maps of all groups are predicted based on the supervision from the BCE and IoU losses.
   }\label{fig:Arch}
\end{figure*}

In this section, we first introduce the overall architecture of our MCCL{}~for the CoSOD task. Then, we sequentially introduce the proposed three key components: Group Consensus Aggregation Module (GCAM), Memory-based Contrastive Module (MCM), and Adversarial Integrity Learning (AIL).

First, GCAM is used to exploit the common features of images in the same group. Second, MCM is applied to make the learned consensus of different groups more robust and discriminative to each other. Finally, we employ AIL to improve the integrity and quality of predicted maps in an adversarial way. Note that MCM and AIL are only used during training and thus can be entirely discarded during inference for a more lightweight model.

\subsection{Overview}
\label{sec:overview}

\figref{fig:Arch} illustrates the basic framework of the proposed MCCL{}~including the learning pipeline.
Different from existing CoSOD models that take images from a single group~\cite{CoSOD3k,CoADNet,ICNet,GICD} as input, our model receives images from multiple groups as input, bringing the potential to bridge the intersection between different groups.

First, we take images of $N$ (default as 2) groups as the input \{$G_1$, $G_2$, ..., $G_N$\}. We concatenate all the images as a whole batch $G$, which is then fed to the encoder. With the backbone network (default as the Transformer network PVTv2~\cite{PVTv2}) as our encoder, embedded features are extracted as $\mathcal{F}$, which is then split by their group categories as \{$\mathcal{F}_1, \mathcal{F}_2, ..., \mathcal{F}_N$\}, where $\mathcal{F}_N=\{F_{N,s}\}_{s=1}^S \in \mathbb{R}^{S \times C \times H \times W}$, $C$ denotes the channel number, $H \times W$ means the spatial size, and $N$ is the group size. Meanwhile, the intermediate features \{$\mathcal{F}_1^{lat}, \mathcal{F}_2^{lat}, \mathcal{F}_3^{lat}$\} at different stages of our encoder are saved and fed to their corresponding stages of the decoder by a 1x1 convolutional layer.

Then, \{$\mathcal{F}_1, \mathcal{F}_2, ..., \mathcal{F}_N$\} are sequentially fed to GCAM to obtain the consensus of each group. With the consensus of groups \{$\mathcal{F}_1^{out}, \mathcal{F}_2^{out}, ..., \mathcal{F}_N^{out}$\}, the memory of the corresponding classes is updated in the queue with momentum, supervised by a metric learning loss used in~\cite{GCoNet+}.

Furthermore, the consensus of all groups is concatenated as $\mathcal{F}^{out}$ and fed to the decoder, which consists of four stacked standard residual blocks and combines the early features from lateral connections. Co-saliency maps $\mathcal{M}$ are generated at the end of the decoder. The prediction of the decoder $M$ is supervised by the Binary Cross Entropy (BCE) loss and the Intersection over Union (IoU) loss, which provide pixel-level and region-level supervision, respectively.

Finally, the predicted co-saliency maps $\mathcal{M}$ are facilitated together with the source images $G$ and the ground-truth maps $GT$. The pixel-wise multiplication between $G$ and $M$ leads to $G^\mathcal{M}$, and we obtain $G^{GT}$ in a similar way. $G^\mathcal{M}$ and $G^{GT}$ are then fed to an independent discriminator, identifying whether the masked images are generated by the ground-truth maps $G^{GT}$ or the source images $G$, which include intact and complete objects. Accordingly, the adversarial loss from the discriminator is applied to the whole generator, and the BCE loss is given to the discriminator.

\subsection{Group Consensus Aggregation Module}
\label{sec:GCAM}

In the wild, objects of the same category tend to share similar appearance, which has been exploited in many related tasks, such as video tracking~\cite{wang2019learning} and semantic segmentation~\cite{Zhang2019CoOccurrentFI}, where the correspondence between common objects is used as prior information. Here we also apply this mechanism to CoSOD. Similar to~\cite{GCoNet}, we employ the non-local block~\cite{non_local} to extract the affinity feature. As shown in \figref{fig:GCAM}, we first split the output feature of the encoder $\mathcal{F}_n$ into \{$\mathcal{F}_n^A, \mathcal{F}_n^B$\}, which are then shuffled and fed into the non-local block. Subsequently, in the non-local block, we compute the affinity map of the feature and conduct matrix multiplication between the affinity map and the value feature (\emph{i.e}.} \def\Ie{\emph{I.e}., `V' in the non-local block) to obtain the consensus feature \{${\mathcal{F}_n^A}^\prime, {\mathcal{F}_n^B}^\prime$\}. Finally, we perform depth-wise correlation to fuse the original feature with the consensus feature, and concatenate them to form the final consensus representation $\mathcal{F}_{out}$.

\begin{figure}[t!]
  \centering
    \begin{overpic}[width=.75\linewidth]{figs/GCAM.pdf}
    \end{overpic}
   \caption{
   \textbf{Group Consensus Aggregation Module.} The feature of the encoder is fed to the GCAM and handled group by group. The original features of one group are evenly split and shuffled before being fed to the non-local block. The depth-wise correlation bridges the semantic interaction between the consensus and original features.
   }\label{fig:GCAM}
\end{figure}

\subsection{Memory-based Contrastive Module}
\label{sec:MCM}

Metric learning is a widely-used technique that contributes to distinguishing features of different clusters and works in many tasks, including CoSOD~\cite{MetricCoSOD,MetricCoSOD1,GCoNet+}. However, CoSOD datasets only contain a limited number of images (tens of images) of limited groups (less than 300 groups). In such cases, naive metric learning cannot work very well due to the small number of samples insufficient for distance measurement.

To overcome this issue, some contrastive learning methods introduce the memory queue to achieve more robust contrastive learning with a long-term memory, such as MoCo~\cite{MOCO}, OIM~\cite{OIM}, \emph{etc}.} \def\vs{\emph{vs}.{}. Inspired by these works, we propose the MCM, which saves the consensus features of each class into memory blocks and updates the corresponding blocks with momentum in every batch. To be more specific, as shown in \figref{fig:Arch}, the consensuses of all groups \{$\mathcal{F}_1^{out}, \mathcal{F}_2^{out}, ..., \mathcal{F}_N^{out}$\} are saved or updated in their own memory blocks as \{$\mathcal{C}_1, \mathcal{C}_2^, ..., \mathcal{C}_N$\}. The memory update is as follows:
\begin{equation}
  \mathcal{C}^t_1 = \beta * \mathcal{C}^{t-1}_1 + (1 - \beta) * \mathcal{F}_1^{out},
\end{equation}
where $\beta$ denotes the momentum factor and is set to 0.1 by default. When $\beta$ is set to 0, the MCM belongs to fully online metric learning.

As demonstrated in the MCM, each memory block splits itself into two parts, $\mathcal{C}_1^{A}$ and $\mathcal{C}_1^{B}$. In this case, $\mathcal{C}_1^{B}$ is viewed as the positive samples of $\mathcal{C}_1^{A}$, and the whole $\mathcal{C}_2$ is considered as the negative samples of $\mathcal{C}_1^{A}$~\cite{GCoNet+}. Then, the loss of MCM can be computed by the GST loss~\cite{GCoNet+} as follows:
\begin{equation}
  L_\mathrm{Triplet}(C_1, C_2) = ||\mathcal{C}_1^A - \mathcal{C}_1^B||_2 - ||\mathcal{C}_1^A - \mathcal{C}_2^B||_2 + \alpha
\end{equation}
\begin{equation}
  L_\mathrm{MCM} = \frac{1}{N^2}\sum_{i=1}^{N}\sum_{j=1}^{N}{L_\mathrm{Triplet}(C_i, C_j)},
\end{equation}
where $\alpha$ denotes the margin used in the triplet loss~\cite{TripletLoss}, which is set to 0.1. $|| \cdot ||_2$ means the $l_2$ norm of the input.

\subsection{Adversarial Integrity Learning}
\label{sec:AIL}

Although some latest works have investigated the integrity of SOD~\cite{integrity}, they try to solve this problem by designing sophisticated model architectures and critical components to make predicted maps of higher integrity. These attempts may lead to maps with better quality, but the motivation of their design is not intuitive to the integrity problem.

To explicitly solve this problem, we propose the Adversarial Integrity Learning (AIL) in our framework. Three data sources exist in AIL, \emph{i.e}.} \def\Ie{\emph{I.e}.{}, the source images, the ground-truth maps, and the predicted maps in the current batch. During training, we perform pixel-wise multiplications on two pairs, \emph{i.e}.} \def\Ie{\emph{I.e}.{}, (source images, ground-truth maps) and (source images, predicted maps), as shown in \figref{fig:Disc}, to obtain $G_{GT}$ and $G_M$, respectively. Then, we employ a discriminator to identify whether the regions of source images masked by these two maps are real or fake, as shown in \figref{fig:Arch}. Obviously, the regions masked by the ground-truth maps are complete and intact objects with 100\% integrity. During training, the loss from the discriminator guides the generator to produce maps that can localize objects with higher accuracy and integrity. The ablation results are shown in \figref{fig:abla_ail}.

\begin{figure}[t!]
  \centering
    \begin{overpic}[width=.95\linewidth]{figs/disc.pdf}
    \end{overpic}
   \caption{
   \textbf{Discriminator used in our AIL.} The discriminator has four discrimination blocks (DiscBlk) stacked sequentially, with 16, 32, 64, and 128 as the number of their output channels, respectively. Note that there is no batch normalization layer in the first DiscBlk in our implementation.
   }\label{fig:Disc}
\end{figure}

\subsection{Objective Function}
As shown in \figref{fig:Arch}, the objective function $L_{sal}$ of the main network (generator) is a weighted combination of the low-level losses (\emph{i.e}.} \def\Ie{\emph{I.e}., BCE and IoU losses) and the high-level losses (metric and adversarial losses). And the discriminator involves the BCE loss. The details of $L_{MCM}$ can be found in the `Methodology' section above.
The BCE, IoU, and adversarial losses are as follows:
\begin{equation}
  {L}_\mathrm{BCE} = - \sum{[Y log(\hat{Y}), (1 - Y)log(1 - \hat{Y})]},
  \label{eqn:loss_BCE}
\end{equation}
\begin{equation}
  {L}_\mathrm{IoU} = 1 - \frac{1}{N}\sum{\frac{Y \cap \hat{Y}}{Y \cup \hat{Y}}},
  \label{eqn:loss_IoU}
\end{equation}
where $Y$ is the ground-truth map, $\hat{Y}$ is the predicted map.
\begin{equation}
  \hat{T} = discriminator(\hat{Y} \cdot G),
  \label{eqn:loss_adv_g_0}
\end{equation}
\begin{equation}
  {L}_\mathrm{adv} = - \sum{[T log(\hat{T}), (1 - T)log(1 - \hat{T})]},
  \label{eqn:loss_adv_g_1}
\end{equation}
where $\hat{Y}$ is the predicted map, $G$ denotes the source images, $\cdot$ denotes the pixel-wise multiplication, $\hat{T}$ and $T$ denote the prediction of discriminator on whether $\hat{Y}$ and $Y$ is the ground-truth map, respectively.

Therefore, our final objective function is:
\begin{equation}
  {L_\mathrm{sal}} = \lambda_1 {L}_\mathrm{BCE} + \lambda_2 {L}_\mathrm{IoU} + \lambda_3 {L}_\mathrm{MCM} + \lambda_4 {L}_\mathrm{adv},
  \label{eqn:loss_final}
\end{equation}
\begin{equation}
  {L_\mathrm{disc}} = \lambda_5 {L}_\mathrm{BCE},
  \label{eqn:loss_disc}
\end{equation}
where $\lambda_1, \lambda_2, \lambda_3, \lambda_4$, and $\lambda_5$ are respectively set to 30, 0.5, 3, 10, and 3 to keep all the losses at a reasonable scale at the beginning of training to benefit the optimization.

\section{Experiments}

\subsection{Datasets}
\label{sec:exp_datasets}
\textbf{Training Sets.} We follow \cite{CoADNet} to use DUTS\_class~\cite{GICD} and COCO-SEG~\cite{COCO_SEG} as our training sets. The whole DUTS\_class is divided into 291 groups, which contain 8,250 images in total. COCO-SEG contains 200k images of 78 groups and corresponding binary maps.

\begin{table*}[t!]
\begin{center}
\footnotesize
\renewcommand{\arraystretch}{1.0}
\renewcommand{\tabcolsep}{1.14mm}
\begin{tabular}{r||c|cccc|cccc|cccc}
\hline
&  & \multicolumn{4}{c|}{CoCA~\cite{GICD}} & \multicolumn{4}{c|}{CoSOD3k~\cite{CoSOD3k}} & \multicolumn{4}{c}{CoSal2015~\cite{CoSal2015}} \\
\multirow{-2}{*}{Method} & \multirow{-2}{*}{Pub.} & $E_{\xi}^\mathrm{max} \uparrow$ & $S_\alpha \uparrow$ & $F_\beta^\mathrm{max} \uparrow$ & $\epsilon \downarrow$ & $E_{\xi}^\mathrm{max} \uparrow$ & $S_\alpha \uparrow$ & $F_\beta^\mathrm{max} \uparrow$ & $\epsilon \downarrow$ & $E_{\xi}^\mathrm{max} \uparrow$ & $S_\alpha \uparrow$ & $F_\beta^\mathrm{max} \uparrow$ & $\epsilon \downarrow$ \\
\hline
CBCS~\shortcite{CBCS} & TIP & 0.641 & 0.523 & 0.313 & 0.180 & 0.637 & 0.528 & 0.466 & 0.228 & 0.656 & 0.544 & 0.532 & 0.233 \\
GWD~\shortcite{GWD} & IJCAI & 0.701 & 0.602 & 0.408 & 0.166 & 0.777 & 0.716 & 0.649 & 0.147 & 0.802 & 0.744 & 0.706 & 0.148 \\
RCAN~\shortcite{RCAN} & IJCAI & 0.702 & 0.616 & 0.422 & 0.160 & 0.808 & 0.744 & 0.688 & 0.130 & 0.842 & 0.779 & 0.764 & 0.126 \\
GCAGC~\shortcite{GCAGC} & CVPR & 0.754 & 0.669 & 0.523 & 0.111 & 0.816 & 0.785 & 0.740 & 0.100 & 0.866 & 0.817 & 0.813 & 0.085 \\
GICD~\shortcite{GICD} & ECCV & 0.715 & 0.658 & 0.513 & 0.126 & 0.848 & 0.797 & 0.770 & 0.079 & 0.887 & 0.844 & 0.844 & 0.071 \\
ICNet~\shortcite{ICNet} & NeurIPS & 0.698 & 0.651 & 0.506 & 0.148 & 0.832 & 0.780 & 0.743 & 0.097 & 0.900 & 0.856 & 0.855 & 0.058 \\
CoADNet~\shortcite{CoADNet} & NeurIPS & - & - & - & - & 0.878 & 0.824 & 0.791 & 0.076 & 0.914 & 0.861 & 0.858 & 0.064 \\
DeepACG~\shortcite{DeepACG} & CVPR & 0.771 & 0.688 & 0.552 & 0.102 & 0.838 & 0.792 & 0.756 & 0.089 & 0.892 & 0.854 & 0.842 & 0.064 \\
GCoNet~\shortcite{GCoNet} & CVPR & 0.760 & 0.673 & 0.544 & 0.105 & 0.860 & 0.802 & 0.777 & 0.071 & 0.887 & 0.845 & 0.847 & 0.068 \\
CoEGNet~\shortcite{CoSOD3k} & TPAMI & 0.717 & 0.612 & 0.493 & 0.106 & 0.837 & 0.778 & 0.758 & 0.084 & 0.884 & 0.838 & 0.836 & 0.078 \\
CADC~\shortcite{CADC} & ICCV & 0.744 & 0.681 & 0.548 & 0.132 & 0.840 & 0.801 & 0.859 & 0.096 & 0.906 & 0.866 & 0.862 & 0.064 \\
DCFM$^*$~\shortcite{DCFM} & CVPR & 0.783 & 0.710 & \textbf{0.598} & \textbf{0.085} & 0.874 & 0.810 & 0.805 & 0.067 & 0.892 & 0.838 & 0.856 & 0.067 \\
UFO~\shortcite{arxiv_UFO} & arXiv & 0.782 & 0.697 & 0.571 & 0.095 & 0.874 & 0.819 & 0.797 & 0.073 & 0.906 & 0.860 & 0.865 & 0.064 \\
\hline
\rowcolor{mygray} \textbf{Ours} & Sub. & \textbf{0.796} & \textbf{0.714} & 0.590 & 0.103 & \textbf{0.903} & \textbf{0.858} & \textbf{0.837} & \textbf{0.061} & \textbf{0.927} & \textbf{0.890} & \textbf{0.891} & \textbf{0.051} \\
\hline
\end{tabular}
\caption{\textbf{Quantitative comparisons between our MCCL{}~and other methods.} ``$\uparrow$'' (``$\downarrow$'') means that the higher (lower) is better. $^*$ denotes the state-of-the-art method. UFO~\cite{arxiv_UFO} is still an arXiv paper and does not show much improvement compared with DCFM~\cite{DCFM}, so we set DCFM as the previous SoTA.}
\label{tab:sota}
\end{center}
\end{table*}

\textbf{Test Sets.}
For a comprehensive evaluation of our MCCL{}, we test it on three widely used CoSOD datasets, \emph{i.e}.} \def\Ie{\emph{I.e}., CoCA~\cite{GICD}, CoSOD3k~\cite{CoSOD3k}, and CoSal2015~\cite{CoSal2015}. Among the three datasets, CoCA is the most challenging one.
It is of much higher diversity and complexity in terms of background, occlusion, illumination, surrounding objects, \emph{etc}.} \def\vs{\emph{vs}.. Following the latest benchmark~\cite{CoSOD3k}, we do not evaluate on iCoseg~\cite{iCoseg} and MSRC~\cite{MSRC}, since only one salient object is given in most images there. It is more convincing to evaluate CoSOD methods on images with more salient objects, which is closer to real-life applications.

\subsection{Evaluation Protocol}
Following GCoNet~\cite{GCoNet}, we employ the S-measure~\cite{Smeasure}, maximum F-measure~\cite{Fmeasure}, maximum E-measure~\cite{Emeasure}, and mean absolute error (MAE) to evaluate the performance in our experiments.

\subsection{Implementation Details}

We select samples from DUTS\_class~\cite{GICD} and COCO-SEG~\cite{COCO_SEG} alternatively, and set the batch size as follows:
\begin{equation}
  batch size = min(\#group 1, ..., \#group N, 48),
  \label{eqn:batch_size}
\end{equation}
where $\#$ means the image number in the corresponding group. The images are resized to 256x256 for training and inference. The output maps are resized to the original size for evaluation. We apply three data augmentation strategies, \emph{i.e}.} \def\Ie{\emph{I.e}., horizontal flip, color enhancement, and rotation. Our MCCL{}~is trained for 250 epochs with the AdamW optimizer~\cite{AdamW}. The initial learning rate is 1e-4 and divided by 10 at the last 20th epoch. The whole training process takes $\sim$3.5 hours and consumes only $\sim$7.5GB GPU memory. All the experiments are implemented based on the PyTorch library~\cite{PyTorch} with a single NVIDIA RTX3090 GPU.

\subsection{Ablation Study}
\label{sec:Ablation}
We conduct the ablation study to validate the effectiveness of each component (\emph{i.e}.} \def\Ie{\emph{I.e}., GCAM, MCM, and AIL) employed in our MCCL{}.
The qualitative results regarding each module and the combination are shown in \figref{fig:qualitive_ablation}.

\begin{figure}[t!]
	\flushright

    \begin{overpic}[width=.95\linewidth]{figs/ablation_mccl.pdf}

        \put(-4,29){\rotatebox{90}{Dice}}
        \put(-4,15){\rotatebox{90}{Bottle}}
        \put(-4,2){\rotatebox{90}{Bind}}
        \put(6,-4.5){{(a)}}
        \put(22.5,-4.5){{(b)}}
        \put(39,-4.5){{(c)}}
        \put(56,-4.5){{(d)}}
        \put(73,-4.5){{(e)}}
        \put(90,-4.5){{(f)}}
    \end{overpic}
	\vspace{10pt}
	\caption{\textbf{Qualitative ablation studies of different modules and their combinations in our MCCL.} (a) Source image; (b) Ground truth; (c) w/ GCAM; (d) w/ GCAM+MCM; (e) w/ GCAM+AIL; (f) w/ GCAM+MCM+AIL, \emph{i.e}.} \def\Ie{\emph{I.e}., the full version of our model.}
	\label{fig:qualitive_ablation}
\end{figure}

\begin{table*}[t!]
\begin{center}
\footnotesize
\renewcommand{\arraystretch}{1.0}
\setlength\tabcolsep{4.5pt}
\begin{tabular}{ccc||cccc|cccc|cccc}
\hline
\multicolumn{3}{c||}{Modules}  & \multicolumn{4}{c|}{CoCA~\cite{GICD}} & \multicolumn{4}{c|}{CoSOD3k~\cite{CoSOD3k}} & \multicolumn{4}{c}{CoSal2015~\cite{CoSal2015}} \\
\hspace{1.25mm}GCAM\hspace{1.25mm} & MCM & AIL & $E_{\xi}^\mathrm{ max} \uparrow$ & $S_\alpha \uparrow$ & $F_\beta^\mathrm{ max} \uparrow$ & $\epsilon \downarrow$ & $E_{\xi}^\mathrm{ max} \uparrow$ & $S_\alpha \uparrow$ & $F_\beta^\mathrm{ max} \uparrow$ & $\epsilon \downarrow$ & $E_{\xi}^\mathrm{ max} \uparrow$ & $S_\alpha \uparrow$ & $F_\beta^\mathrm{ max} \uparrow$ & $\epsilon \downarrow$ \\
\hline
 &  &  & 0.756 & 0.683 & 0.553 & 0.118 & 0.880 & 0.828 & 0.798 & 0.075 & 0.905 & 0.866 & 0.861 & 0.062 \\
\checkmark &  &  & 0.779 & 0.709 & 0.577 & 0.103 & 0.894 & 0.851 & 0.824 & 0.061 & 0.921 & 0.884 & 0.882 & 0.053 \\
\checkmark & \checkmark &  & 0.788 & 0.711 & 0.585 & 0.100 & 0.898 & 0.853 & 0.828 & 0.060 & 0.925 & 0.889 & 0.886 & \textbf{0.050} \\

\checkmark &  & \checkmark & 0.789 & 0.714 & 0.585 & \textbf{0.097} & 0.900 & 0.855 & 0.831 & 0.060 & 0.924 & 0.888 & 0.887 & 0.053 \\
\hline
\rowcolor{mygray}
\checkmark & \checkmark & \checkmark & \textbf{0.796} & \textbf{0.714} & \textbf{0.590} & 0.103 & \textbf{0.903} & \textbf{0.858} & \textbf{0.837} & \textbf{0.061} & \textbf{0.927} & \textbf{0.890} & \textbf{0.891} & 0.051 \\
\hline
\end{tabular}
\caption{\textbf{Quantitative ablation studies of the proposed components in our MCCL{}.} The components include the GCAM, MCM, AIL, and their combinations.}
\label{tab:ablation_modules}
\end{center}
\end{table*}

\begin{figure*}[t!]
	\centering
    \begin{overpic}[width=.96\textwidth]{figs/qual_mccl.pdf}
        \put(-1.5,42){\rotatebox{90}{Input}}
        \put(-1.5,36){\rotatebox{90}{GT}}
        \put(-1.5,29){\rotatebox{90}{\textbf{Ours}}}
        \put(-1.5,21){\rotatebox{90}{DCFM}}
        \put(-1.5,15){\rotatebox{90}{UFO}}
        \put(-1.5,7){\rotatebox{90}{CADC}}
        \put(-1.5,-0.5){\rotatebox{90}{GCoNet}}
        \put(6,-2){{Salient Distractors}}
        \put(29,-2){{Complex Structure}}
        \put(57,-2){{Tiny Objects}}
        \put(77,-2){{Extremely Difficult Cases}}
    \end{overpic}
	\vspace{10pt}
	\caption{\textbf{Qualitative comparisons of our MCCL{} and other methods.} `GT' denotes the ground truth. We select the results of hard cases due to various reasons. The `Extremely Difficult Cases' means the chopstick group on the test set of CoCA~\cite{GICD}, as chopsticks are thin, tall, and hard to detect. This could be the most difficult case among all groups on the existing test sets.}
	\label{fig:qual}
\end{figure*}

\textbf{Baseline.} We establish a solid CoSOD network as the baseline. To keep pace with the latest Transformer network, we also build our model with both Transformer and convolutional neural networks as the backbone. Following GCoNet~\cite{GCoNet}, we feed images of multiple classes and their ground-truth as the input to train our MCCL{}. Compared with previous CoSOD models, our baseline network achieves promising performance with a simpler architecture and much higher speed. To be consistent with the widely used Transformer network~\cite{ViT,PVTv1,PVTv2}, in contrast with the previous CoSOD models~\cite{GICD,GCoNet,CADC,DCFM}, we make our model shallower and build it with only four stages in its encoder and decoder. To achieve a pure and fast baseline network, we firstly substitute all the complex blocks in each lateral connection used in~\cite{GICD,GCoNet,CADC,DCFM} with a single 1x1 convolution layer~\cite{FPN} as the vanilla Feature Pyramid Network (FPN)~\cite{FPN} does. Secondly, we set only a single residual block as the decoding block, where the output is added with the features from the lateral connection. Finally, instead of the multi-stage supervision on all stages of the decoder~\cite{GICD,GCoNet,DCFM}, we set the pixel-level supervision on only the final output with a weighted sum of BCE and IoU losses to guide the model locally and globally, respectively. Our baseline can beat most of the existing CoSOD methods, and thus can be referred to as a strong baseline for others in the future.

\textbf{GCAM.} As the performance evaluated in \tabref{tab:ablation_modules}, our GCAM brings much improvement not only on CoCA and CoSOD3k that focus more on complex context with multiple objects, but also on CoSal2015 that is a relatively simple dataset but needs more attention on the precise SOD in a simple environment.

\textbf{MCM.} In \tabref{tab:ablation_modules}, MCM shows its consistent improvement in all metrics on all datasets. As shown in \figref{fig:qualitive_ablation}, MCM helps our model make more accurate predictions than those models without it.

\textbf{AIL.}
AIL guides our model to learn the integrity of predicted regions, and the produced co-saliency maps tend to be more robust and contain one or more complete and intact objects. As shown in \figref{fig:abla_ail}, the improvement brought by AIL can be seen from three perspectives. 1) On the object level, AIL increases the completeness of predicted maps of slender objects, which is usually hard to be fully detected. 2) Inside the object, AIL helps fill the unconfident regions which break the structural integrity of the detected objects. 3) Outside the object, AIL suppresses the distractors, with which the regions include just not a complete object.

In summary, 1) GCAM splits features into two parts, accelerating the affinity generation. 2) MCM is initially motivated by OIM~\cite{OIM}. Differently, MCM saves features by classes instead of identities; OIM uses the final normalized features to update the queue, while we use the consensus generated by GCAM, which aligns well with CoSOD. 3) The adversarial learning strategy in AIL can also be found in domain adaptation~\cite{adv_da}, but we are the first to accommodate it to SOD and to use the segmented regions for discrimination. We also apply AIL to other CoSOD models to validate its high generalizability, as shown in~\tabref{tab:ablation_ail}.

\begin{table}[t!]
\begin{center}
\footnotesize
\begin{tabular}{cc|cccc}
\hline
\multicolumn{1}{c}{CoSOD Models}  & \multicolumn{1}{c|}{AIL}  & \multicolumn{4}{c}{CoCA~\cite{GICD}} \\
\hline
GCoNet~\shortcite{GCoNet} &  & 0.760 & 0.673 & 0.544 & 0.105 \\
GCoNet~\shortcite{GCoNet} & \checkmark & 0.777 & 0.681 & 0.549 & 0.106 \\
GICD~\shortcite{GICD} &  & 0.715 & 0.658 & 0.513 & 0.126 \\
GICD~\shortcite{GICD} & \checkmark & 0.718 & 0.675 & 0.524 & 0.127 \\
\hline
\end{tabular}
\caption{\textbf{Quantitative ablation studies of the proposed AIL on different models.} We apply the proposed AIL to other CoSOD models~\cite{GCoNet,GICD} and conduct the evaluation on CoCA~\cite{GICD}.}
\label{tab:ablation_ail}
\end{center}
\end{table}

\begin{figure}[t!]
  \flushright
    \begin{overpic}[width=.95\linewidth]{figs/abla_ail.pdf}
        \put(-2.5,33){\rotatebox{90}{Frisbee}}
        \put(-2.5,18){\rotatebox{90}{Tomato}}
        \put(-2.5,-1){\rotatebox{90}{Flowerpot}}
        \put(7,-4.5){{Images}}
        \put(35.5,-4.5){{GT}}
        \put(56,-4.5){{w/ AIL}}
        \put(80,-4.5){{w/o AIL}}
    \end{overpic}
    \vspace{10pt}
    \caption{
    \textbf{Qualitative ablation studies of our AIL.} We conduct the qualitative comparison between the baseline model with (w/) and without (w/o) the proposed AIL.
    }\label{fig:abla_ail}
\end{figure}

\subsection{Comparison to State-of-the-Art Methods}
To make a comprehensive comparison, we compare our MCCL{} with one traditional classical algorithm CBCS~\cite{CBCS} and 12 update-to-date deep learning based CoSOD models (see \tabref{tab:sota} for all methods used for comparison).
Since CoSOD methods have gained much improvement in the past few years and obtained much better performance compared with single-SOD methods, we do not list the single-SOD ones, following previous works~\cite{CoSOD3k,GCoNet,GICD,DCFM}. The detailed leaderboard of previous methods can be found in~\cite{CoSOD3k}.

\textbf{Quantitative Results.} \tabref{tab:sota} shows the quantitative results of our MCCL{} and previous competitive methods. Given the above results, we can see that our MCCL{} outperforms all the existing methods, especially on the CoSOD3k~\cite{CoSOD3k} and CoSal2015~\cite{CoSal2015} datasets, where the ability to detect salient objects is in a higher priority than finding objects with the common class.

\textbf{Qualitative Results.} \figref{fig:qual} shows the co-saliency maps predicted by different methods for a clear qualitative comparison, where we provide four different types of complex samples from CoCA~\cite{GICD} and CoSOD3k~\cite{CoSOD3k}. Compared with existing models, our~MCCL{} shows a stronger ability to eliminate distractors, detect tiny targets, and handle the objects that blend into complex scenes. The extremely difficult cases in which other up-to-date methods fail most of the time further demonstrate the more robust performance of our MCCL{}.

\section{Conclusion}
\label{sec:conclusion}
In this paper, we investigate a novel memory-aided contrastive consensus learning framework (\emph{i.e}.} \def\Ie{\emph{I.e}., MCCL) for CoSOD. As experiments show, the memory-based contrastive learning with group consensus works effectively to enhance the representation capability of the obtained group features. Besides, the adversarial integrity learning strategy does benefit the saliency model, with the potential to improve the integrity and quality of saliency maps for a variety of SOD and CoSOD models in a general way.

\clearpage


\section{Introduction} \label{intro}

Let $R$ be a commutative ring, and fix two scalars $[2]_s,[2]_t \in R$.
The \defnemph{two-colored Temperley--Lieb algebra} $2\mathrm{TL}_R(\prescript{}{s}{n}):=2\mathrm{TL}_R(\prescript{}{s}{n};[2]_s,[2]_t)$ is the $R$-algebra with generators
$e_i$ for $1 \leq i \leq n-1$,
subject to the relations
\begin{align}
e_i^2& =-[2]_s & & \text{$i$ odd,} \label{eq:oddquadratic} \\
e_i^2& =-[2]_t & & \text{$i$ even,} \label{eq:evenquadratic} \\
e_i e_j & =e_j e_i & & \text{for $|i-j|>1$,} \\
e_i e_{i\pm 1} e_i & =e_i & & \label{eq:braidreln}
\end{align}
The algebra $2\mathrm{TL}_R(\prescript{}{t}{n})$ is defined identically, except that the parity conditions on the relations \eqref{eq:oddquadratic} and \eqref{eq:evenquadratic} are swapped.
These algebras form a generalization of the ordinary Temperley--Lieb algebra, which occurs as a special case when $[2]_s=[2]_t$.
The relations immediately imply that there is an $R$-basis of $2\mathrm{TL}_R(\prescript{}{s}{n})$ consisting of monomials in the generators $e_i$.

We call a non-zero idempotent $\mathrm{JW}_R(\prescript{}{s}{n}) \in 2\mathrm{TL}_R(\prescript{}{s}{n})$ (and similarly for $\prescript{}{t}{n}$) a \defnemph{two-colored Jones--Wenzl projector} if $e_i\mathrm{JW}_R(\prescript{}{s}{n})=0$ for all $1 \leq i \leq n-1$ and the coefficient of $1$ in $\mathrm{JW}_R(\prescript{}{s}{n})$ is $1$.
Such idempotents (if they exist) are unique.

The behavior of $2\mathrm{TL}_R(\prescript{}{s}{n})$ is controlled by certain elements $[n]_s,[n]_t \in R$ for $n \in \mathbb{Z}$ called the \defnemph{two-colored quantum numbers}.
These elements (defined in \eqref{eq:twocolqnum} below) are bivariate polynomials in $[2]_s$ and $[2]_t$ which are analogous to ordinary quantum numbers.
For an integer $0 \leq k \leq n$ the \defnemph{two-colored quantum binomial coefficient}
\begin{equation*}
\qbinom{n}{k}_{s}=\frac{[n]_{s}!}{[k]_{s}![n-k]_{s}!}=\frac{[n]_{s}[n-1]_{s}\dotsm [n-k+1]_{s}}{[k]_{s}[k-1]_{s} \dotsm [1]_{s}}
\end{equation*}
can also be shown to be an element of $R$.
Our first main result is the two-colored analogue of the well-known existence theorem for ordinary Jones--Wenzl projectors.

\begin{thmletter} \label{existence}
The two-colored Jones--Wenzl projector $\mathrm{JW}_R(\prescript{}{s}{n})$ exists if and only if $\qbinom{n}{k}_{s}$ is invertible in $R$ for each integer $0 \leq k \leq n$.
\end{thmletter}

The terminology for two-colored Temperley--Lieb algebras comes from their presentation as diagram algebras.
We associate the labels $s$ and $t$ with the colors red and blue, respectively, writing ${\color{red} s}$ and ${\color{blue} t}$ for emphasis.
A \defnemph{two-colored Temperley Lieb diagram} is a Temperley--Lieb diagram with the planar regions between strands colored with alternating colors.
The algebra $2\mathrm{TL}_R(\prescript{}{{\color{red} s}}{n})$ is spanned by two-colored Temperley--Lieb diagrams with $n$ boundary points on the top and bottom whose leftmost region is colored red.
A blue circle inside a red region evaluates to $-[2]_{{\color{red} s}}$, while a red circle inside a blue region evaluates to $-[2]_{{\color{blue} t}}$.
We draw the two-colored Jones--Wenzl projector as a rectangle labeled $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$:
\begin{equation*}
\begin{gathered}
        \begin{tikzpicture}[xscale=-.3,yscale=0.2]
          \begin{scope}
            \clip (-3,3.5) rectangle (3,-3.5);
            \draw[fill=dgrmred] (0,4) rectangle (4,-4);
            \draw[fill=dgrmblu] (1,4) rectangle (2,-4);

         \draw[fill=dgrmblu] (-4,4) rectangle (-2,-4);
         \draw[fill=white] (-2.5,2) rectangle (2.5,-2);
         \node at (0,0) {$\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$};
         \node at (-1,2.7) {$\dots$};
         \node at (-1,-2.7) {$\dots$};
       \end{scope}
       \draw[dashed] (-3,3.5) to (3,3.5);
       \draw[dashed] (-3,-3.5) to (3,-3.5);
     \end{tikzpicture} \\
\text{$n$ odd}
\end{gathered} \qquad \qquad \qquad \qquad
\begin{gathered}
        \begin{tikzpicture}[xscale=-.3,yscale=0.2]
          \begin{scope}
            \clip (-3,3.5) rectangle (3,-3.5);
            \draw[fill=dgrmred] (0,4) rectangle (4,-4);
            \draw[fill=dgrmblu] (1,4) rectangle (2,-4);

         \draw[fill=dgrmred] (-4,4) rectangle (-2,-4);
         \draw[fill=white] (-2.5,2) rectangle (2.5,-2);
         \node at (0,0) {$\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$};
         \node at (-1,2.7) {$\dots$};
         \node at (-1,-2.7) {$\dots$};
       \end{scope}
       \draw[dashed] (-3,3.5) to (3,3.5);
       \draw[dashed] (-3,-3.5) to (3,-3.5);
     \end{tikzpicture} \\
\text{$n$ even}
\end{gathered}
\end{equation*}

Suppose both $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ and $\mathrm{JW}_R(\prescript{}{{\color{blue} t}}{n})$ exist.
We say that $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ is \defnemph{rotatable} if the (clockwise and counterclockwise) rotations of $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ by one strand are equal to some scalar multiple of $\mathrm{JW}_R(\prescript{}{{\color{blue} t}}{n})$:
\begin{align*}
\begin{gathered}
  \begin{tikzpicture}[xscale=.5,yscale=.4]
    \begin{scope}
         \clip (-3,2) rectangle (3.5,-2);
    \draw[fill=dgrmblu] (-3.3,3) rectangle (1.4,-3);
    \draw[fill=dgrmred] (3.8,3) rectangle (1.4,-3);
             \draw[fill=dgrmred] (-.9,3) rectangle (0.5,-3);
             \draw[fill=white] (-.3,3) rectangle (0.8,-3);
             \draw[fill=dgrmblu] (2,3) to (2,-1)
         to[out=-90,in=180] (2.5,-1.5) to[out=0,in=-90] (3,-1) to
         (3,3) to (2,3);
         \draw[fill=dgrmred] (-1.5,-3) to (-1.5,1)
         to[out=90,in=0] (-2,1.5) to[out=180,in=90] (-2.5,1) to
         (-2.5,-3) to (-1.5,-3);
         \draw[fill=white] (-1.9,1) rectangle (2.4,-1);
         \node at (.25,0) {$\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$};
         \node at (.3,1.4) {$\dots$};
         \node at (.3,-1.4) {$\dots$};
         \end{scope}
         \draw[dashed] (-3,2) to (3.5,2);
         \draw[dashed] (-3,-2) to (3.5,-2);
       \end{tikzpicture}
\end{gathered}
    & =
     \lambda
\begin{gathered}
  \begin{tikzpicture}[xscale=.5,yscale=.4]
    \begin{scope}
         \clip (-2.3,2) rectangle (2.8,-2);
    \draw[fill=dgrmblu] (-3.3,3) rectangle (.5,-3);
             \draw[fill=dgrmred] (-1.5,3) rectangle (-.9,-3);
    \draw[fill=dgrmred] (3.8,3) rectangle (.5,-3);
    \draw[fill=dgrmblu] (2,3) rectangle (1.4,-3);
             \draw[fill=white] (-.3,3) rectangle (.8,-3);
         \draw[fill=white] (-1.9,1) rectangle (2.4,-1);
         \node at (.25,0) {$\mathrm{JW}_R(\prescript{}{{\color{blue} t}}{n})$};
         \node at (.3,1.4) {$\dots$};
         \node at (.3,-1.4) {$\dots$};
         \end{scope}
         \draw[dashed] (-2.3,2) to (2.8,2);
         \draw[dashed] (-2.3,-2) to (2.8,-2);
       \end{tikzpicture}
\end{gathered}
=
\begin{gathered}
  \begin{tikzpicture}[xscale=.5,yscale=-.4]
    \begin{scope}
         \clip (-3,2) rectangle (3.5,-2);
    \draw[fill=dgrmblu] (-3.3,3) rectangle (1.4,-3);
    \draw[fill=dgrmred] (3.8,3) rectangle (1.4,-3);
             \draw[fill=dgrmred] (-.9,3) rectangle (0.5,-3);
             \draw[fill=white] (-.3,3) rectangle (0.8,-3);
             \draw[fill=dgrmblu] (2,3) to (2,-1)
         to[out=-90,in=180] (2.5,-1.5) to[out=0,in=-90] (3,-1) to
         (3,3) to (2,3);
         \draw[fill=dgrmred] (-1.5,-3) to (-1.5,1)
         to[out=90,in=0] (-2,1.5) to[out=180,in=90] (-2.5,1) to
         (-2.5,-3) to (-1.5,-3);
         \draw[fill=white] (-1.9,1) rectangle (2.4,-1);
         \node at (.25,0) {$\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$};
         \node at (.3,1.4) {$\dots$};
         \node at (.3,-1.4) {$\dots$};
         \end{scope}
         \draw[dashed] (-3,2) to (3.5,2);
         \draw[dashed] (-3,-2) to (3.5,-2);
       \end{tikzpicture}
\end{gathered} & \text{($n$ odd)} \\
\begin{gathered}
  \begin{tikzpicture}[xscale=.5,yscale=.4]
    \begin{scope}
         \clip (-3,2) rectangle (3.5,-2);
    \draw[fill=dgrmblu] (-3.3,3) rectangle (3.8,-3);
             \draw[fill=dgrmred] (-.9,3) rectangle (1.4,-3);
             \draw[fill=white] (-.3,3) rectangle (.8,-3);
             \draw[fill=dgrmred] (2,3) to (2,-1)
         to[out=-90,in=180] (2.5,-1.5) to[out=0,in=-90] (3,-1) to
         (3,3) to (2,3);
         \draw[fill=dgrmred] (-1.5,-3) to (-1.5,1)
         to[out=90,in=0] (-2,1.5) to[out=180,in=90] (-2.5,1) to
         (-2.5,-3) to (-1.5,-3);
         \draw[fill=white] (-1.9,1) rectangle (2.4,-1);
         \node at (.25,0) {$\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$};
         \node at (.3,1.4) {$\dots$};
         \node at (.3,-1.4) {$\dots$};
         \end{scope}
         \draw[dashed] (-3,2) to (3.5,2);
         \draw[dashed] (-3,-2) to (3.5,-2);
       \end{tikzpicture}
\end{gathered}
    & =
     \lambda
\begin{gathered}
  \begin{tikzpicture}[xscale=.5,yscale=.4]
    \begin{scope}
         \clip (-2.3,2) rectangle (2.8,-2);
    \draw[fill=dgrmblu] (-3.3,3) rectangle (3.8,-3);
             \draw[fill=dgrmred] (-1.5,3) rectangle (2,-3);
             \draw[fill=dgrmblu] (-.9,3) rectangle (1.4,-3);
             \draw[fill=white] (-.3,3) rectangle (.8,-3);
         \draw[fill=white] (-1.9,1) rectangle (2.4,-1);
         \node at (.25,0) {$\mathrm{JW}_R(\prescript{}{{\color{blue} t}}{n})$};
         \node at (.3,1.4) {$\dots$};
         \node at (.3,-1.4) {$\dots$};
         \end{scope}
         \draw[dashed] (-2.3,2) to (2.8,2);
         \draw[dashed] (-2.3,-2) to (2.8,-2);
       \end{tikzpicture}
\end{gathered}
=
\begin{gathered}
  \begin{tikzpicture}[xscale=.5,yscale=-0.4]
    \begin{scope}
         \clip (-3,2) rectangle (3.5,-2);
    \draw[fill=dgrmblu] (-3.3,3) rectangle (3.8,-3);
             \draw[fill=dgrmred] (-.9,3) rectangle (1.4,-3);
             \draw[fill=white] (-.3,3) rectangle (.8,-3);
             \draw[fill=dgrmred] (2,3) to (2,-1)
         to[out=-90,in=180] (2.5,-1.5) to[out=0,in=-90] (3,-1) to
         (3,3) to (2,3);
         \draw[fill=dgrmred] (-1.5,-3) to (-1.5,1)
         to[out=90,in=0] (-2,1.5) to[out=180,in=90] (-2.5,1) to
         (-2.5,-3) to (-1.5,-3);
         \draw[fill=white] (-1.9,1) rectangle (2.4,-1);
         \node at (.25,0) {$\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$};
         \node at (.3,1.4) {$\dots$};
         \node at (.3,-1.4) {$\dots$};
         \end{scope}
         \draw[dashed] (-3,2) to (3.5,2);
         \draw[dashed] (-3,-2) to (3.5,-2);
       \end{tikzpicture}
\end{gathered} & \text{($n$ even)}
\end{align*}
Our second main result gives a combined condition for the existence and rotatability of two-colored Jones--Wenzl projectors.

\begin{thmletter} \label{existsrotates}
The two-colored Jones--Wenzl projectors $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ and $\mathrm{JW}_R(\prescript{}{{\color{blue} t}}{n})$ exist and are rotatable if and only if $\qbinom{n+1}{k}_{{\color{red} s}}=\qbinom{n+1}{k}_{{\color{blue} t}}=0$ in $R$ for all integers $1 \leq k \leq n$.
\end{thmletter}

In the course of proving Theorems~\ref{existence} and \ref{existsrotates} we generalize several well-known results to the two-color setting which may be of independent interest.
These including computations of the greatest common divisor and least common multiple of (two-colored) quantum binomial coefficients (\cref{qbinomideal} and \cref{qbinominvideal}) and the genericness of coefficients of $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ (\cref{genericcoefs}) over arbitrary rings.

\subsection*{Soergel bimodules}

Two-colored Jones--Wenzl projectors lie at the heart of the Elias--Williamson construction of the diagrammatic Hecke category \cite{ew-soergelcalc}.
Recently Abe has shown that there is a ``bimodule-theoretic'' category (a modification of the category of classical Soergel bimodules) which is equivalent to the diagrammatic Hecke category under certain assumptions \cite{abe-bimodhecke,abe-homBS}.
An important consequence of \cref{existsrotates} (which we discuss in the final section) is that these assumptions essentially always hold.

\begin{corletter} \label{abeequalsew}
The diagrammatic Hecke category is equivalent to Abe's category of Soergel bimodules.
\end{corletter}

More precisely, we use \cref{existsrotates} to give an algebraic condition on the base ring for determining when the diagrammatic Hecke category is well defined (\cref{realizcorrected}), completely correcting an error in \cite{ew-soergelcalc} (first identified and partially corrected in \cite{ew-localizedcalc}).
This algebraic condition is precisely Abe's \cite[Assumption~1.1]{abe-homBS}, so \cref{abeequalsew} follows from Abe’s results \cite[Theorem~3.9]{abe-homBS} and \cite[Theorem~5.6]{abe-bimodhecke}.
We find it noteworthy that our correction gives the best possible equivalence result for two seemingly distinct categorifications of the Hecke algebra.

\subsection*{Acknowledgments}

We thank the Royal Commission for the Exhibition of 1851 and EPSRC (EP/V00090X/1) for financial support.

\section{Preliminaries}
\label{prelim}

Let $A=\mathbb{Z}[x_{{\color{red} s}},x_{{\color{blue} t}}]$ be the integral polynomial ring in two variables.
The \defnemph{two-colored quantum numbers} are defined as follows.
First set $[1]_{{\color{red} s}}=[1]_{{\color{blue} t}}=1$, $[2]_{{\color{red} s}}=x_{{\color{red} s}}$, and $[2]_{{\color{blue} t}}=x_{{\color{blue} t}}$ in $A$.
For $n>1$ we inductively define
\begin{align}
[n+1]_{{\color{red} s}}& =[2]_{{\color{red} s}} [n]_{{\color{blue} t}} - [n-1]_{{\color{red} s}} \text{,} & [n+1]_{{\color{blue} t}} & =[2]_{{\color{blue} t}} [n]_{{\color{red} s}} - [n-1]_{{\color{blue} t}} \text{.} \label{eq:twocolqnum}
\end{align}
These formulas can be rearranged to inductively define $[n]_{{\color{red} s}}$ and $[n]_{{\color{blue} t}}$ for $n \leq 0$.
For a commutative $A$-algebra $R$, we also define two-colored quantum numbers in $R$ to be the specializations of two-colored quantum numbers in $A$, which we will write in the same way.

These polynomials are bivariate extensions of the usual (one-colored) quantum numbers, which can be recovered as follows.
Let $\overline{A}=A/(x_{{\color{red} s}}-x_{{\color{blue} t}}) \cong \mathbb{Z}[x]$, where $x$ is the image of $x_{{\color{red} s}}$ or $x_{{\color{blue} t}}$.
Then the one-colored quantum number $[n]$ is the image of $[n]_{{\color{red} s}}$ or $[n]_{{\color{blue} t}}$ in $\overline{A}$.
When $n$ is odd, $[n]$ is an even polynomial, so we can formally evaluate $[n]$ at $x=\sqrt{x_{{\color{red} s}} x_{{\color{blue} t}}}$ to obtain an element of $A$.
When $n$ is even, $[n]/[2]$ is an even polynomial, which we can similarly formally evaluate at $x=\sqrt{x_{{\color{red} s}} x_{{\color{blue} t}}}$.
In both cases, it is easy to show by induction that
\begin{equation} \label{eq:colordependence}
\begin{aligned}
[n]_{{\color{red} s}}& =[n](\sqrt{x_{{\color{red} s}} x_{{\color{blue} t}}})=[n]_{{\color{blue} t}} & & \text{if $n$ is odd,} \\
\frac{[n]_{{\color{red} s}}}{[2]_{{\color{red} s}}}& =\left(\frac{[n]}{[2]}\right)(\sqrt{x_{{\color{red} s}} x_{{\color{blue} t}}})=\frac{[n]_{{\color{blue} t}}}{[2]_{{\color{blue} t}}} & & \text{if $n$ is even}
\end{aligned}
\end{equation}
in $A$.
In other words, two-colored quantum numbers are essentially the same as ordinary quantum numbers up to a factor of $[2]_{{\color{red} s}}$ and $[2]_{{\color{blue} t}}$ depending on color.

It is self-evident that the automorphism of $A$ which exchanges $x_{{\color{red} s}}$ and $x_{{\color{blue} t}}$ (``color swap'') also exchanges $[n]_{{\color{red} s}}$ and $[n]_{{\color{blue} t}}$ for all $n$.
For this reason, we will generally write statements only for $[n]_{{\color{red} s}}$ and leave it to the reader to formulate color-swapped analogues.
Similarly we have $2\mathrm{TL}(\prescript{}{{\color{red} s}}{n}; [2]_{{\color{red} s}},[2]_{{\color{blue} t}}) \cong 2\mathrm{TL}(\prescript{}{{\color{blue} t}}{n}; [2]_{{\color{blue} t}},[2]_{{\color{red} s}})$, and this isomorphism maps $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ to $\mathrm{JW}_R(\prescript{}{{\color{blue} t}}{n})$ when they exist, so we will only state our results for $2\mathrm{TL}_R(\prescript{}{{\color{red} s}}{n})$ and $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$.

As mentioned in \cref{intro}, the two-colored Temperley--Lieb algebra $2\mathrm{TL}(\prescript{}{{\color{red} s}}{n})$ has a basis consisting of reduced monomials in the generators $e_i$ (i.e.~monomials whose length cannot be reduced using \eqref{eq:oddquadratic}--\eqref{eq:braidreln}).
Each basis element corresponds to a unique two-colored Temperley--Lieb diagram on $n$ strands, whose leftmost region is colored red.
Given an element $f \in 2\mathrm{TL}_R(\prescript{}{{\color{red} s}}{n})$ and a two-colored Temperley--Lieb diagram $D$ we will write
\begin{equation*}
\coeff_{{} \in f} D
\end{equation*}
for the coefficient of $D$ when $f$ is written in the diagrammatic basis.

If $R$ is a commutative $A$-algebra for which $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ exists for all $n$ (e.g.~$R=\Frac A$), then the coefficients of $\mathrm{JW}_{R}(\prescript{}{{\color{red} s}}{n})$ can be calculated inductively as follows.
Suppose $D$ is a two-colored Temperley--Lieb diagram in $2\mathrm{TL}_R(\prescript{}{{\color{red} s}}{(n+1)})$.
Let $\hat{D}$ be the diagram with $n+2$ bottom boundary points and $n$ top boundary points obtained by folding down the strand connected to the top right boundary point of $D$.
If there is a strand connecting the $i$th and $(i+1)$th bottom boundary points of $\hat{D}$, let $D_i$ denote the two-colored Temperley--Lieb diagram with $n$ strands so obtained by deleting this cap.
For example, if
\begin{equation*}
D=\begin{gathered}
        \begin{tikzpicture}[xscale=.4,yscale=.2]
          \begin{scope}
            \clip (-3,3.5) rectangle (3,-3.5);
            \draw[fill=dgrmred] (2,4) rectangle (-3,-4);
            \draw[fill=dgrmblu] (2,4) rectangle (3,-4);

          \draw[fill=dgrmblu] (-2,-4) to (-2,4) to (-1,3.5) to[out=-90,in=90] (1,-3.5) to (1,-4) to (0,-3.5) to[out=90,in=0] (-.5,-2.5) to[out=180,in=90] (-1,-3.5) to (-2,-4);
          \draw[fill=dgrmblu] (0,4) to (0,3.5) to[out=-90,in=180] (.5,2.5) to[out=0,in=-90] (1,3.5) to (0,4);
       \end{scope}
       \draw[dashed] (-3,3.5) to (3,3.5);
       \draw[dashed] (-3,-3.5) to (3,-3.5);
     \end{tikzpicture}
\end{gathered}
\end{equation*}
then
\begin{equation*}
\hat{D}=\begin{gathered}
        \begin{tikzpicture}[xscale=.4,yscale=.2]
          \begin{scope}
            \clip (-3,3.5) rectangle (3.5,-3.5);
            \draw[fill=dgrmred] (3.5,4) rectangle (-3,-4);
            \draw[fill=dgrmblu] (2,-4) to (2,-3.5) to[out=90,in=180] (2.5,-2.5) to[out=0,in=90] (3,-3.5) to (2,-4);

          \draw[fill=dgrmblu] (-2,-4) to (-2,4) to (-1,3.5) to[out=-90,in=90] (1,-3.5) to (1,-4) to (0,-3.5) to[out=90,in=0] (-.5,-2.5) to[out=180,in=90] (-1,-3.5) to (-2,-4);
          \draw[fill=dgrmblu] (0,4) to (0,3.5) to[out=-90,in=180] (.5,2.5) to[out=0,in=-90] (1,3.5) to (0,4);
       \end{scope}
       \draw[dashed] (-3,3.5) to (3.5,3.5);
       \draw[dashed] (-3,-3.5) to (3.5,-3.5);
     \end{tikzpicture} \\
\end{gathered}
\end{equation*}
and
\begin{equation*}
D_2=\begin{gathered}
        \begin{tikzpicture}[xscale=.4,yscale=.2]
          \begin{scope}
            \clip (-3,3.5) rectangle (2,-3.5);
            \draw[fill=dgrmred] (3.5,4) rectangle (-3,-4);
            \draw[fill=dgrmblu] (-2,4) rectangle (-1,-4);

          \draw[fill=dgrmblu] (0,-4) to (0,-3.5) to[out=90,in=-180] (.5,-2.5) to[out=0,in=90] (1,-3.5) to (0,-4);
          \draw[fill=dgrmblu] (0,4) to (0,3.5) to[out=-90,in=180] (.5,2.5) to[out=0,in=-90] (1,3.5) to (0,4);
       \end{scope}
       \draw[dashed] (-3,3.5) to (2,3.5);
       \draw[dashed] (-3,-3.5) to (2,-3.5);
     \end{tikzpicture} \\
\end{gathered} \text{,} \qquad \qquad \qquad
D_5=\begin{gathered}
        \begin{tikzpicture}[xscale=.4,yscale=.2]
          \begin{scope}
            \clip (-3,3.5) rectangle (2,-3.5);
            \draw[fill=dgrmred] (3.5,4) rectangle (-3,-4);

          \draw[fill=dgrmblu] (-2,-4) to (-2,4) to (-1,3.5) to[out=-90,in=90] (1,-3.5) to (1,-4) to (0,-3.5) to[out=90,in=0] (-.5,-2.5) to[out=180,in=90] (-1,-3.5) to (-2,-4);
          \draw[fill=dgrmblu] (0,4) to (0,3.5) to[out=-90,in=180] (.5,2.5) to[out=0,in=-90] (1,3.5) to (0,4);
       \end{scope}
       \draw[dashed] (-3,3.5) to (2,3.5);
       \draw[dashed] (-3,-3.5) to (2,-3.5);
     \end{tikzpicture} \\
\end{gathered} \text{.}
\end{equation*}

\begin{thm} \label{JWcoef}
Suppose $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ and $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{(n+1)})$ both exist.
We have
\begin{equation*}
\coeff_{{} \in \mathrm{JW}_{R}(\prescript{}{{\color{red} s}}{(n+1)})} D=\sum_{i} \frac{[i]_{{\color{Plum} u}}}{[n+1]_{{\color{red} s}}}\coeff_{{} \in \mathrm{JW}_{R}(\prescript{}{{\color{red} s}}{n})} D_i \text{,}
\end{equation*}
where the sum is taken over all positions $i$ where $D_i$ is defined, and ${\color{Plum} u}$ is the color of the deleted cap.
\end{thm}

\begin{proof}
The argument in the one-color setting (see \cite[Proposition~4.1]{morrison-JW} or \cite[Corollary~3.7]{frenkelkhovanov}) follows essentially unchanged from \cite[(6.29)]{ew-localizedcalc}.
\end{proof}

We will carefully show later that this computation is ``generic'', i.e.~if $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ exists, then its coefficients are specializations of the coefficients of $\mathrm{JW}_{\Frac A}(n)$.

The existence criterion in \cref{existence} is known to hold in the one-color setting, i.e.~when the images of $x_{{\color{red} s}}$ and $x_{{\color{blue} t}}$ in $R$ are equal.
In these circumstances we write $\mathrm{TL}_R(n)$ and $\mathrm{JW}_R(n)$ for the one-color Temperley--Lieb algebra and Jones--Wenzl projector.

\begin{thm}[{\cite[Theorem~A.2]{el-univcox}}] \label{existence-onecol}
Suppose $R$ is a commutative $A$-algebra which factors through $\overline{A}$.
Then $\mathrm{JW}_R(n)$ exists if and only if the one-color quantum binomial coefficients
\begin{equation*}
\qbinom{n}{k}=\frac{[n]!}{[k]![n-k]!}=\frac{[n][n-1]\dotsm [n-k+1]}{[k][k-1] \dotsm [1]}
\end{equation*}
are invertible in $R$ for all integers $0 \leq k \leq n$.
\end{thm}

In light of the ``generic'' nature of the coefficients of $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$, we can interpret \cref{existence-onecol} as description of the denominators of the coefficients of $\mathrm{JW}_{\Frac \overline{A}}(n)$.
Unfortunately, none of the known proofs of this result (most of which use connections to Lie theory in a crucial way) generalize easily to the two-colored setting.

Finally, we will give an alternative criterion for checking rotatability.
For $f \in 2\mathrm{TL}_R(\prescript{}{{\color{red} s}}{n})$ define the \defnemph{partial trace} of $f$ to be
\begin{align*}
\pTr(f)& =\begin{gathered}
\begin{tikzpicture}[xscale=.6,yscale=0.8]
        \begin{scope}
          \clip (-1.5,1) rectangle (3,-1);
  \draw[fill=dgrmblu] (1,2) rectangle (3.5,-2);
  \draw[fill=dgrmred] (1.5,.6) to[out=90,in=180] (2,.8)
  to[out=0,in=90] (2.5,0) to[out=-90,in=0] (2,-.8) to[out=180,in=-90]
  (1.5,-.6) to (1.5,.6);
  \draw[fill=dgrmred] (0,2) rectangle (-2,-2);
  \draw[fill=dgrmblu] (-1,2) rectangle (-.5,-2);
  \draw[fill=white] (-1.25,.6) rectangle (1.9,-.6);
  \node at (.25,0) {$f$};
  \node at (.55,.8) {$\dots$};
  \node at (.55,-.8) {$\dots$};
  \end{scope}
  \draw[dashed] (-1.5,1) to (3,1);
  \draw[dashed] (-1.5,-1) to (3,-1);
\end{tikzpicture}
\end{gathered} & &
\text{($n$ odd)} \\
\pTr(f)& =\begin{gathered}
\begin{tikzpicture}[xscale=.6,yscale=0.8]
        \begin{scope}
          \clip (-1.5,1) rectangle (3,-1);
  \draw[fill=dgrmred] (1,2) rectangle (3.5,-2);
  \draw[fill=dgrmblu] (1.5,.6) to[out=90,in=180] (2,.8)
  to[out=0,in=90] (2.5,0) to[out=-90,in=0] (2,-.8) to[out=180,in=-90]
  (1.5,-.6) to (1.5,.6);
  \draw[fill=dgrmred] (0,2) rectangle (-2,-2);
  \draw[fill=dgrmblu] (-1,2) rectangle (-.5,-2);
  \draw[fill=white] (-1.25,.6) rectangle (1.9,-.6);
  \node at (.25,0) {$f$};
  \node at (.55,.8) {$\dots$};
  \node at (.55,-.8) {$\dots$};
  \end{scope}
  \draw[dashed] (-1.5,1) to (3,1);
  \draw[dashed] (-1.5,-1) to (3,-1);
\end{tikzpicture}
\end{gathered} & &
\text{($n$ even)}
\end{align*}
From the definition of the Jones--Wenzl projector, it is easy to see that $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ is rotatable if and only if $\pTr(\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n}))=0$.
Using entirely standard techniques (e.g.~\cite[\S 6.6]{ew-localizedcalc}), one can show that
\begin{equation}
\pTr(\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n}))=-\frac{[n+1]_{{\color{red} s}}}{[n]_{{\color{red} s}}}\mathrm{JW}_R(\prescript{}{{\color{red} s}}{(n-1)}) \label{eq:genericpTr}
\end{equation}
when both $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ and $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{(n-1)})$ exist.
This gives the following partial rotatability criterion.

\begin{prop} \label{genericrotatability}
Suppose both $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ and $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{(n-1)})$ exist.
Then $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ is rotatable if and only if $[n+1]_{{\color{red} s}}=0$.
\end{prop}

The key to proving the full rotatability criterion will be to interpret \eqref{eq:genericpTr} generically.

\section{Principal ideals}

In this section, we show that several ideals generated by certain two-colored quantum numbers and binomial coefficients are principal.
Recall that for ordinary quantum numbers, one can show that if $d|n$ then $[d]|[n]$.
Using $\eqref{eq:colordependence}$ it immediately follows that $[d]_{{\color{red} s}}|[n]_{{\color{red} s}}$.

\begin{lem}[Quantum B\'{e}zout's identity] \label{qbezout}
Let $m,n \in \mathbb{N}$.
There exist polynomials $a,b \in A$ such that
\begin{equation*}
a[m]_{{\color{red} s}}+b[n]_{{\color{red} s}}=[\gcd(m,n)]_{{\color{red} s}} \text{.}
\end{equation*}
\end{lem}

\begin{proof}
Suppose without loss of generality that $m<n$.
We will show that the ideal in $A$ generated by $[m]_{{\color{red} s}}$ and $[n]_{{\color{red} s}}$ contains $[n-m]_{{\color{red} s}}$.
If $m$ and $n$ are not both odd, then
\begin{align*}
\begin{split}
[n-1]_{{\color{blue} t}}[m]_{{\color{red} s}} - [m-1]_{{\color{blue} t}}[n]_{{\color{red} s}} & =
([m+n-2]_{{\color{red} s}}+[m+n-4]_{{\color{red} s}}+\dotsb+[-(n-m)+2]_{{\color{red} s}}) \\
& \quad -([m+n-2]_{{\color{red} s}}+[m+n-4]_{{\color{red} s}}+\dotsb+[n-m+2]_{{\color{red} s}})
\end{split} \\
& =[n-m]_{{\color{red} s}}+[n-m-2]_{{\color{red} s}}+\dotsb+[-(n-m)+2]_{{\color{red} s}} \\
& =[n-m]_{{\color{red} s}}
\end{align*}
by \cite[(6.5a)--(6.5c)]{ew-localizedcalc}.
If $m$ and $n$ are both odd, a similar calculation yields
\begin{equation*}
[n-1]_{{\color{red} s}}[m]_{{\color{red} s}} - [m-1]_{{\color{red} s}}[n]_{{\color{red} s}}=[n-m]_{{\color{red} s}} \text{.}
\end{equation*}
By repeating this step multiple times, we can run Euclid's algorithm, and the result follows.
\end{proof}

Next we introduce the cyclotomic parts of quantum numbers, which are roughly analogous to cyclotomic polynomials.
Recall that the one-color quantum numbers are renormalizations of Chebyshev polynomials of the second kind.
More precisely, if we evaluate a quantum number $[n]$ at $x=2\cos \theta$, we obtain
\begin{equation*}
[n](2\cos \theta) = \frac{\sin n\theta}{\sin \theta} \text{.}
\end{equation*}
Since $[n]$ is a monic polynomial in $x$ of degree $n-1$ we conclude that
\begin{equation*}
[n]=\prod_{k=1}^{n-1} \left(x-2\cos \frac{k\pi}{n}\right)
\end{equation*}
We define the \defnemph{cyclotomic part} of the one-color quantum number $[n]$ to be the polynomial
\begin{equation*}
\Theta_n = \prod_{\substack{1 \leq k < n\\ (k,n)=1}} \left(x-2\cos \frac{k\pi}{n}\right) \text{.}
\end{equation*}

\begin{lem} \label{cyclofacts}
Let $n \in \mathbb{N}$.
We have
\begin{enumerate}[label={\rm (\roman*)}]
\item \label{item:degree} $\Theta_n \in \mathbb{Z}[x]$, and $\deg \Theta_n=\varphi(n)$ when $n>1$;

\item \label{item:prod} $[n]=\prod_{k|n} \Theta_n$;

\item \label{item:mobinv} $\Theta_n=\prod_{k|n} [k]^{\mu(n/k)}$, where $\mu:\mathbb{N} \rightarrow \{\pm 1\}$ is the M\"{o}bius function.
\end{enumerate}
Moreover, if $n>2$ then we also have $\Theta_n(x)=\Psi_n(x^2)$, where $\Psi_n \in \mathbb{Z}[x]$ is the minimal polynomial of $4\cos^2(\pi/n)$.
\end{lem}

\begin{proof}
Both \ref{item:degree} and \ref{item:prod} follow from the definition and basic properties of cyclotomic fields and algebraic integers.
Applying M\"obius inversion to \ref{item:prod} yields \ref{item:mobinv}.
For the final claim, we observe that if $n>2$ then $\Theta_n$ is an even polynomial, so is of the form of $\Psi_n(x^2)$ for some $\Psi_n \in \mathbb{Z}[x]$ of degree $\varphi(n)/2$.
By construction $4\cos^2(\pi/n)$ is a root of $\Psi_n$.
Since
\begin{equation*}
4\cos^2 \frac{\pi}{n}=2\cos \frac{2\pi}{n}+2
\end{equation*}
and $\mathbb{Q}(2\cos(2\pi/n)+2)=\mathbb{Q}(\cos(2\pi/n))$ is a field extension of $\mathbb{Q}$ of degree $\varphi(n)/2$, $\Psi_n$ must be the minimal polynomial of $4\cos^2(\pi/n)$.
\end{proof}

\begin{defn}
For $n \in \mathbb{N}$, we define the \defnemph{cyclotomic part} of the two-colored quantum number $[n]_{{\color{red} s}}$ to be
\begin{equation*}
\Theta_{n,{\color{red} s}}=\begin{cases}
\Psi_n(x_{{\color{red} s}} x_{{\color{blue} t}}) & \text{if $n>2$,} \\
x_{{\color{red} s}} & \text{if $n=2$,} \\
1 & \text{if $n=1$.}
\end{cases}
\end{equation*}
\end{defn}

Using \eqref{eq:colordependence} and \cref{cyclofacts} we similarly obtain $[n]_{{\color{red} s}}=\prod_{k|n} \Theta_{n,{\color{red} s}}$ and $\Theta_{n,{\color{red} s}}=\prod_{k|n} [n]_{{\color{red} s}}^{\mu(n/k)}$.

\begin{lem} \label{thetabezout}
Let $m,n \in \mathbb{N}$ such that $m \nmid n$ and $n \nmid m$.
There exist polynomials $a,b \in A$ such that
\begin{equation*}
a\Theta_{m,{\color{red} s}}+b\Theta_{n,{\color{red} s}}=1 \text{.}
\end{equation*}
\end{lem}

\begin{proof}
Suppose without loss of generality that $m<n$, and let $d=\gcd(m,n)$.
By \cref{qbezout} there exist $a',b' \in A$ such that
\begin{equation*}
a'[m]_{{\color{red} s}}+b'[n]_{{\color{red} s}}=[d]_{{\color{red} s}} \text{.}
\end{equation*}
By assumption $d<m<n$, so we have
\begin{align*}
\frac{[m]_{{\color{red} s}}}{[d]_{{\color{red} s}}} & \in \Theta_{m,{\color{red} s}} A \\
\frac{[n]_{{\color{red} s}}}{[d]_{{\color{red} s}}} & \in \Theta_{n,{\color{red} s}} A
\end{align*}
and thus dividing by $[d]_{{\color{red} s}}$ we obtain
\begin{equation*}
a\Theta_{m,{\color{red} s}}+b\Theta_{n,{\color{red} s}}=1 \text{.} \qedhere
\end{equation*}
\end{proof}

\begin{prop} \label{thetaprincipal}
Let $m_1,m_2,\dotsc,m_k,n_1,n_2,\dotsc,n_l \in \mathbb{N}$ such that for all $i,j$ either $m_i=n_j$ or $m_i \nmid n_j$ and $n_j \nmid m_i$.
Then the ideal
\begin{equation*}
(\Theta_{m_1,{\color{red} s}}\Theta_{m_2,{\color{red} s}}\dotsm \Theta_{m_k,{\color{red} s}}, \Theta_{n_1,{\color{red} s}}\Theta_{n_2,{\color{red} s}}\dotsm \Theta_{n_l,{\color{red} s}})
\end{equation*}
in $A$ is principal.
\end{prop}

\begin{proof}
Let $I$ be the ideal above.
We may assume without loss of generality that $m_i \neq n_j$ for all $i,j$, i.e.~the generators of $I$ are coprime in $A$.
For each $i,j$ we can apply \cref{thetabezout} to obtain $a_{i,j},b_{i,j} \in A$ such that $a_{i,j}\Theta_{m_i,{\color{red} s}}+b_{i,j}\Theta_{n_j,{\color{red} s}}=1$.
Taking the product over all $i$ and $j$ we obtain
\begin{equation*}
1=\prod_{i} \left(\prod_{j} (a_{i,j}\Theta_{m_i,{\color{red} s}} + b_{i,j}\Theta_{n_j,{\color{red} s}})\right) \in \prod_{i} (\Theta_{m_i,{\color{red} s}},\Theta_{n_1,{\color{red} s}}\Theta_{n_2,{\color{red} s}}\dotsm \Theta_{n_l,{\color{red} s}}) \subseteq I
\end{equation*}
so $I=(1)$ is principal.
\end{proof}

For $f \in A$, we define the cyclotomic valuation $\nu_{l,{\color{red} s}}(f)$ to be the exponent of the highest power dividing $f$.
This extends to $\Frac A$ in the obvious way, namely we define $\nu_{l,{\color{red} s}}(f/g)=\nu_{l,{\color{red} s}}(f)-\nu_{l,{\color{red} s}}(g)$ for $f,g \in A$.
If $f$ and $g$ are products of ${\color{red} s}$-colored cyclotomic parts then
\begin{equation*}
\frac{f}{g}=\prod_l \Theta_{l,{\color{red} s}}^{\nu_{l,{\color{red} s}}(f/g)} \text{.}
\end{equation*}

\begin{lem} \label{valbinom}
Let $n,k$ be non-negative integers.
For all integers $1 \leq l \leq n$ we have
\begin{equation*}
\nu_{l,{\color{red} s}} \qbinom{n}{k}_{{\color{red} s}}=\left\lfloor \frac{n}{l} \right\rfloor - \left\lfloor \frac{k}{l} \right\rfloor - \left\lfloor \frac{n-k}{l} \right\rfloor \text{.}
\end{equation*}
In particular, $\nu_{l,{\color{red} s}} \qbinom{n}{k}_{{\color{red} s}} \in \{0,1\}$.
\end{lem}

\begin{proof}
Clearly
\begin{equation*}
\nu_{l,{\color{red} s}}[m]_{{\color{red} s}}=\begin{cases}
1 & \text{if $l|m$,} \\
0 & \text{otherwise,}
\end{cases}
\end{equation*}
so $\nu_l([m]_{{\color{red} s}}!)=\lfloor m/l \rfloor$ and the equation above follows.
To show the bound on the valuation, note that $m/l-1<\lfloor m/l\rfloor \leq m/l$, so
\begin{multline*}
-1=\left(\frac{n}{l}-1\right)-\frac{k}{l}-\frac{n-k}{l}<\left\lfloor \frac{n}{l} \right\rfloor - \left\lfloor \frac{k}{l} \right\rfloor - \left\lfloor \frac{n-k}{l} \right\rfloor \\
<\frac{n}{l}-\left(\frac{k}{l}-1\right)-\left(\frac{n-k}{l}-1\right)=2 \text{.}
\end{multline*}
\end{proof}

\begin{thm} \label{qbinomideal}
Let $n \in \mathbb{N}$.
The ideal
\begin{equation*}
\left(\qbinom{n}{1}_{{\color{red} s}}, \qbinom{n}{2}_{{\color{red} s}}, \dotsc, \qbinom{n}{n-1}_{{\color{red} s}}\right)
\end{equation*}
in $A$ is principal, generated by $\Theta_{n,{\color{red} s}}$.
\end{thm}

\begin{proof}
We will prove the result by induction.
Let
\begin{equation*}
I_m=\left(\qbinom{n}{1}_{{\color{red} s}},\qbinom{n}{2}_{{\color{red} s}}, \dotsc, \qbinom{n}{m}_{{\color{red} s}}\right)
\end{equation*}
and write
\begin{equation*}
[n]_{{\color{red} s}}^{>m}=\prod_{\substack{k>m\\ k|n}} \Theta_{k,{\color{red} s}} \text{.}
\end{equation*}
Suppose we have shown that $I_m$ is principal, generated by $[n]_{{\color{red} s}}^{>m}$.
We will show that $I_{m+1}$ is principal, generated by $[n]_{{\color{red} s}}^{>m+1}$.
It is enough to show that
\begin{equation}
\left(\qbinom{n}{m+1}_{{\color{red} s}},[n]_{{\color{red} s}}^{>m}\right)=([n]_{{\color{red} s}}^{>m+1}) \text{.} \label{eq:qbinomideal-induction}
\end{equation}

Clearly $[n]_{{\color{red} s}}^{>m+1}$ divides $[n]_{{\color{red} s}}^{>m}$.
If $k>m+1$ and $k|n$ it is easy to see that
\begin{equation*}
\left\lfloor\frac{n}{k}\right\rfloor - \left\lfloor\frac{m+1}{k}\right\rfloor - \left\lfloor\frac{n-(m+1)}{k}\right\rfloor=1 \text{,}
\end{equation*}
so $\Theta_k$ divides $\qbinom{n}{m+1}_{{\color{red} s}}$ exactly once, and thus $[n]_{{\color{red} s}}^{>m+1}$ divides $\qbinom{n}{m+1}_{{\color{red} s}}$.
If $m+1 \nmid n$ then $[n]_{{\color{red} s}}^{>m+1}=[n]_{{\color{red} s}}^{>m}$, \eqref{eq:qbinomideal-induction} follows trivially.

Otherwise suppose $m+1|n$.
We claim that if $\Theta_{l,{\color{red} s}}$ divides $\qbinom{n}{m+1}/[n]_{{\color{red} s}}^{>m+1}$ we must have $l \nmid m+1$ and $m+1 \nmid l$.
This implies that
\begin{equation*}
\left(\frac{\qbinom{n}{m+1}_{{\color{red} s}}}{[n]_{{\color{red} s}}^{>m+1}},\Theta_{m+1,{\color{red} s}}\right)=(1)
\end{equation*}
by \cref{thetaprincipal}, from which \eqref{eq:qbinomideal-induction} holds and the result follows.

To prove the claim, suppose $l|m+1$.
It is straightforward to check that
\begin{equation*}
\left\lfloor\frac{n}{l}\right\rfloor - \left\lfloor\frac{m+1}{l}\right\rfloor - \left\lfloor\frac{n-(m+1)}{l}\right\rfloor=0 \text{,}
\end{equation*}
so $\Theta_{l,{\color{red} s}}$ does not divide $\qbinom{n}{m+1}_{{\color{red} s}}$, let alone $\qbinom{n}{m+1}_{{\color{red} s}}/[n]_{{\color{red} s}}^{>m+1}$.

Similarly, suppose $m+1|l$, and take $0 \leq r<l$ such that $n-(m+1)=ql+r$.
If $\Theta_{l,{\color{red} s}}$ divides $\qbinom{n}{m+1}_{{\color{red} s}}$ then
\begin{equation*}
\left\lfloor\frac{n}{l}\right\rfloor - \left\lfloor\frac{m+1}{l}\right\rfloor - \left\lfloor\frac{n-(m+1)}{l}\right\rfloor=1
\end{equation*}
and we must have $r+m+1 \geq l$.
Now let $d=\gcd(l,n-(m+1))$.
As $m+1|n$ and $m+1|l$, we have $m+1|d$ and in particular $m+1 \leq d$.
We also have $d|r$, so in particular $l-r \geq d$.
We combine these two equalities to obtain $r+m+1 \leq l$, with equality if and only if $l-r=d$ and $m+1=d$.
This immediately implies that $l|n$, so $\Theta_{l,{\color{red} s}}$ does not divide $\qbinom{n}{m+1}_{{\color{red} s}}/[n]_{{\color{red} s}}^{>m+1}$.
\end{proof}

\begin{thm} \label{qbinominvideal}
Let $n \in \mathbb{N}$.
The fractional ideal of $A$ generated by
\begin{equation*}
\qbinom{n}{0}_{{\color{red} s}}^{-1}, \qbinom{n}{1}_{{\color{red} s}}^{-1}, \dotsc, \qbinom{n}{n}_{{\color{red} s}}^{-1}
\end{equation*}
is principal, generated by
\begin{equation*}
\left(\prod_{\substack{1 \leq k \leq n\\ k \nmid n+1}} \Theta_{k,{\color{red} s}}\right)^{-1} \text{.}
\end{equation*}
\end{thm}

\begin{proof}
We follow a similar strategy as in the proof of \cref{qbinomideal}.
Let $I_m$ denote the fractional ideal generated by
\begin{equation*}
\qbinom{n}{0}_{{\color{red} s}}^{-1},\qbinom{n}{1}_{{\color{red} s}}^{-1}, \dotsc, \qbinom{n}{m}_{{\color{red} s}}^{-1}
\end{equation*}
and let
\begin{equation*}
g_m=\prod_{\substack{k|n-m+i \text{ for some } 1 \leq i \leq m\\ k\nmid n+1}} \Theta_{k,{\color{red} s}} \text{.}
\end{equation*}
Suppose we have shown that $I_m$ is principal, generated by $g_m^{-1}$.
We will show that $I_{m+1}$ is principal, generated by $g_{m+1}^{-1}$.
It is enough to show that the fractional ideal generated by
\begin{equation*}
\qbinom{n}{m+1}_{{\color{red} s}}^{-1},g_m^{-1}
\end{equation*}
is equal to the principal fractional ideal generated by $g_{m+1}^{-1}$.
This is equivalent to proving equality of the following (ordinary) ideals
\begin{equation}
\left(g_m,\qbinom{n}{m+1}_{{\color{red} s}}\right)=\left(\frac{\qbinom{n}{m+1}_{{\color{red} s}}}{h_m}\right) \label{eq:qbinominvideal-induction}
\end{equation}
of $A$, where
\begin{equation*}
h_m=\frac{g_{m+1}}{g_m}=\prod_{\substack{k|n-m\\ k \nmid n-m+1, k \nmid n-m+2, \dotsc ,k \nmid n+1}} \Theta_{k,{\color{red} s}} \text{.}
\end{equation*}
We first check that the ideal on the right-hand side of \eqref{eq:qbinominvideal-induction} is an ordinary ideal.
If $\Theta_{k,{\color{red} s}}$ divides $h_m$ (i.e.~if $k|n-m$ and $k \nmid n-m+i$ for all $1 \leq i \leq m+1$) then $k \nmid m+1$ and the fractional part of $(n-(m+1))/k$ is $(k-1)/k$.
This implies that
\begin{equation*}
\left\lfloor \frac{n}{k} \right\rfloor - \left\lfloor \frac{m+1}{k} \right\rfloor - \left\lfloor \frac{n-(m+1)}{k} \right\rfloor = 1
\end{equation*}
so $\Theta_{k,{\color{red} s}}$ also divides $\qbinom{n}{m+1}_{{\color{red} s}}$.

It is clear that $\qbinom{n}{m+1}_{{\color{red} s}}/h_m$ divides $\qbinom{n}{m+1}_{{\color{red} s}}$.
Suppose $\Theta_{k,{\color{red} s}}$ divides $\qbinom{n}{m+1}_{{\color{red} s}}/h_m$.
Since we can write
\begin{equation*}
\qbinom{n}{m+1}=\frac{[n]_{{\color{red} s}} [n-1]_{{\color{red} s}} \dotsm [n-m]_{{\color{red} s}}}{[m+1]_{{\color{red} s}} [m]_{{\color{red} s}} \dotsm [1]_{{\color{red} s}}} \text{,}
\end{equation*}
this implies that either $k\nmid n-m$ and $k|n-m+i$ for some $1 \leq i \leq m$, or $k|n-m$ and $k|n-m+i$ for some $1 \leq i \leq m+1$.
In either case, it is easy to check that $k\nmid n+1$, for otherwise $n/k$ has fractional part $(k-1)/k$, so
\begin{equation*}
\left\lfloor \frac{n}{k} \right\rfloor - \left\lfloor \frac{m+1}{k} \right\rfloor - \left\lfloor \frac{n-(m+1)}{k} \right\rfloor = 0
\end{equation*}
and $\Theta_{k,{\color{red} s}}$ cannot divide $\qbinom{n}{m+1}_{{\color{red} s}}$.
This shows that $\qbinom{n}{m+1}_{{\color{red} s}}/h_m$ divides $g_m$.

We will now show that
\begin{equation*}
\left(\frac{g_{m+1}}{\qbinom{n}{m+1}_{{\color{red} s}}},h_m\right)=(1)
\end{equation*}
using \cref{thetaprincipal}, from which \eqref{eq:qbinominvideal-induction} holds and the result follows.
It is enough to show that for any $l,d>1$, we do not have $\Theta_{l,{\color{red} s}}|g_{m+1}/\qbinom{n}{m+1}_{{\color{red} s}}$ and $\Theta_{ld,{\color{red} s}}|h_m$, or $\Theta_{ld,{\color{red} s}}|g_{m+1}/\qbinom{n}{m+1}_{{\color{red} s}}$ and $\Theta_{l,{\color{red} s}}|h_m$.

Suppose first that $\Theta_{l,{\color{red} s}}|g_{m+1}/\qbinom{n}{m+1}_{{\color{red} s}}$ and $\Theta_{ld,{\color{red} s}}|h_m$.
Then $l \nmid n+1$ and $ld|n-m$, so $l|n-m$ and $l \nmid m+1$.
This shows that the fractional part of $(n-(m+1))/l$ is $(l-1)/l$ and the fractional part of $(m+1)/l$ is non-zero, so
\begin{equation*}
\left\lfloor \frac{n}{l} \right\rfloor - \left\lfloor \frac{m+1}{l} \right\rfloor - \left\lfloor \frac{n-(m+1)}{l} \right\rfloor = 1
\end{equation*}
which contradicts $\Theta_{l,{\color{red} s}}|g_{m+1}/\qbinom{n}{m+1}_{{\color{red} s}}$.

Similarly, suppose that $\Theta_{ld,{\color{red} s}}|g_{m+1}/\qbinom{n}{m+1}_{{\color{red} s}}$ and $\Theta_{l,{\color{red} s}}|h_m$.
Then $l|n-m$ and $l \nmid n-m+i$ for $1 \leq i \leq m+1$, while $ld|n-m+i$ for some $0 \leq i \leq m$ and $ld \nmid n+1$.
The only way this can happen is if $ld|n-m$.
This implies that $ld \nmid m+1$, and we similarly obtain
\begin{equation*}
\left\lfloor \frac{n}{ld} \right\rfloor - \left\lfloor \frac{m+1}{ld} \right\rfloor - \left\lfloor \frac{n-(m+1)}{ld} \right\rfloor = 1
\end{equation*}
which contradicts $\Theta_{ld,{\color{red} s}}|g_{m+1}/\qbinom{n}{m+1}_{{\color{red} s}}$.
\end{proof}

\section{Existence and rotatability}

Let $Q=\Frac A$ and $\overline{Q}=\Frac \overline{A}$.
Our goal in this section is to prove \cref{existence} by showing that the denominators of the coefficients of $\mathrm{JW}_Q(\prescript{}{{\color{red} s}}{n})$ divide
\begin{equation*}
\prod_{\substack{1 \leq k \leq n\\ k \nmid n+1}} \Theta_{k,{\color{red} s}}
\end{equation*}
by comparing them with the coefficients of $\mathrm{JW}_{\overline{Q}}(n)$.
First, we prove the analogous statement for $\mathrm{JW}_{\overline{Q}}(n)$.

\begin{lem} \label{onecolvalbound}
Let $k \in \mathbb{N}$, and let $D$ be a one-colored Temperley--Lieb diagram in $\mathrm{TL}_{\overline{Q}}(n)$.
Then
\begin{equation*}
\nu_k\left(\coeff_{{}\in \mathrm{JW}_{\overline{Q}}(n)} D \right) \geq -1 \text{,}
\end{equation*}
with equality only if $1 \leq k \leq n$ and $k \nmid n+1$.
\end{lem}

\begin{proof}
We proceed by induction.
Suppose the result holds for $n=m$, and let $D$ be a one-colored Temperley--Lieb diagram in $\mathrm{TL}_{\overline{Q}}(m+1)$.
By the one-color version of \cref{JWcoef} we have
\begin{equation}
\begin{split}
\nu_k\left(\coeff_{{}\in \mathrm{JW}_{\overline{Q}}(m+1)} D \right)& =\nu_k\left(\sum_{\{i\}} \frac{[i]}{[m+1]}\coeff_{{}\in \mathrm{JW}_{\overline{Q}}(m)} D_i\right) \\
& \geq \min_{\{i\}} \left(\nu_k\left(\frac{[i]}{[m+1]}\right)+\nu_k\left(\coeff_{{}\in \mathrm{JW}_{\overline{Q}}(m)} D_i\right)\right) \text{.}
\end{split}\label{eq:onecolvalbound}
\end{equation}
If $k \nmid m+1$, then $\nu_k([i]/[m+1]) \geq 0$ for any $i$ and $\nu_k(\coeff_{{}\in \mathrm{JW}_{\overline{Q}}(m)} D_i) \geq -1$.
On the other hand, if $k|m+1$, then $\nu_k([i]/[m+1]) \geq -1$ while $\nu_k(\coeff_{{}\in \mathrm{JW}_{\overline{Q}}(m)} D_i) \geq 0$.
In either case, the sum of the two valuations is at least $-1$, so the right-hand side of \eqref{eq:onecolvalbound} is at least $-1$.
In the case of equality, we must have $1 \leq k \leq m+1$ and $k \nmid m+2$ by \cref{existence-onecol} and the one-color version of \cref{qbinominvideal}.
\end{proof}

Now let $A'=A[x]/(x^2-x_{{\color{red} s}} x_{{\color{blue} t}})$.
We view $A'$ as both an $A$-algebra and an $\overline{A}$-algebra in the obvious way.
Writing $Q'=\Frac A'$, we have an isomorphism
\begin{equation*}
\begin{aligned}
\mathrm{TL}_{Q'}(n)& \longrightarrow 2\mathrm{TL}_{Q'}(\prescript{}{{\color{red} s}}{n})\\
e_i & \longmapsto \begin{cases}
\frac{x}{x_{{\color{red} s}}} e_i & \text{$i$ odd,} \\
\frac{x}{x_{{\color{blue} t}}} e_i & \text{$i$ even,}
\end{cases}
\end{aligned}
\end{equation*}
which maps $\mathrm{JW}_{Q'}(n) \mapsto \mathrm{JW}_{Q'}(\prescript{}{{\color{red} s}}{n})$.
So for any two-colored Temperley--Lieb diagram $D$, we have
\begin{equation*}
\coeff_{{}\in \mathrm{JW}_{Q}(\prescript{}{{\color{red} s}}{n})} D=\coeff_{{}\in \mathrm{JW}_{Q'}(\prescript{}{{\color{red} s}}{n})} D=x^a x_{{\color{red} s}}^b x_{{\color{blue} t}}^c \coeff_{{}\in \mathrm{JW}_{Q'}(n)} \overline{D}=x^a x_{{\color{red} s}}^b x_{{\color{blue} t}}^c \coeff_{{}\in \mathrm{JW}_{\overline{Q}}(n)} \overline{D}
\end{equation*}
for some integers $a,b,c$, where $\overline{D}$ denotes the one-color diagram obtained from $D$ by forgetting the coloring.
It follows that when $k>2$ we have
\begin{equation}
\nu_{k,{\color{red} s}}\left(\coeff_{{}\in \mathrm{JW}_{Q}(n)} D \right)=\nu_k\left(\coeff_{{}\in \mathrm{JW}_{\overline{Q}}(\prescript{}{{\color{red} s}}{n})} \overline{D} \right) \text{.} \label{eq:valequalitynottwo}
\end{equation}

\begin{lem} \label{twocolvalbound}
Let $k \in \mathbb{N}$, and let $D$ be a two-colored Temperley--Lieb diagram in $2\mathrm{TL}_{Q}(\prescript{}{{\color{red} s}}{n})$.
Then
\begin{equation*}
\nu_{k,{\color{Plum} u}}\left(\coeff_{{}\in \mathrm{JW}_{Q}(\prescript{}{{\color{red} s}}{n})} D \right) \geq -1 \text{,}
\end{equation*}
and if we have equality then $1 \leq k \leq n$ and $k \nmid n+1$, and ${\color{Plum} u}={\color{red} s}$ if $k=2$.-
\end{lem}

\begin{proof}
By \cref{onecolvalbound} and \eqref{eq:valequalitynottwo} we need only concern ourselves with the case where $k=2$.
We proceed by induction as in the proof of \cref{onecolvalbound}.
Suppose the result holds for $n=m$, and let $D$ be a two-colored Temperley--Lieb diagram in $\mathrm{TL}_{Q}(m+1)$.
By \cref{JWcoef} we have
\begin{equation}
\begin{split}
\nu_{2,{\color{Plum} u}}\left(\coeff_{{}\in \mathrm{JW}_{Q}(m+1)} D \right)& =\nu_{2,{\color{Plum} u}}\left(\sum_{\{i\}} \frac{[i]_{\color{OliveGreen} v}}{[m+1]_{{\color{red} s}}}\coeff_{{}\in \mathrm{JW}_{Q}(m)} D_i\right) \\
& \geq \min_{\{i\}} \left(\nu_{2,{\color{Plum} u}}\left(\frac{[i]_{{\color{OliveGreen} v}}}{[m+1]_{{\color{red} s}}}\right)+\nu_{2,{\color{Plum} u}}\left(\coeff_{{}\in \mathrm{JW}_{Q}(m)} D_i\right)\right) \text{.}
\end{split}\label{eq:twocolvalbound}
\end{equation}
If $m$ is even or ${\color{Plum} u}={\color{blue} t}$, then for all $i$
\begin{equation*}
\nu_{2,{\color{Plum} u}}\left(\frac{[i]_{{\color{OliveGreen} v}}}{[m+1]_{{\color{red} s}}}\right) \geq 0 \qquad \text{ and } \qquad \nu_{2,{\color{Plum} u}}\left(\coeff_{{}\in \mathrm{JW}_{Q}(m)} D_i\right) \geq -1 \text{.}
\end{equation*}
On the other hand, if $m$ is odd and ${\color{Plum} u}={\color{red} s}$, then for all $i$
\begin{equation*}
\nu_{2,{\color{Plum} u}}\left(\frac{[i]_{{\color{OliveGreen} v}}}{[m+1]_{{\color{red} s}}}\right) \geq -1 \qquad \text{ and } \qquad \nu_{2,{\color{red} s}}\left(\coeff_{{}\in \mathrm{JW}_{\overline{Q}}(m)} D_i\right) \geq 0 \text{.}
\end{equation*}
In either case, the sum of the two valuations is at least $-1$, so the right-hand side of \eqref{eq:twocolvalbound} is at least $-1$.

Now suppose the left-hand side of \eqref{eq:twocolvalbound} is $-1$ but $m$ is even.
Let $D'$ be the diagram in $2\mathrm{TL}(\prescript{}{{\color{red} s}}{m+1})$ obtained by reflecting $D$ about a vertical axis, and then recoloring to obtain a diagram in $2\mathrm{TL}(\prescript{}{{\color{red} s}}{n})$.
This reflection map extends to a twisted involution of $2\mathrm{TL}(n)$ mapping $e_i$ to $e_{n-i}$ and swapping $[2]_{{\color{red} s}}$ and $[2]_{{\color{blue} t}}$.
Thus $\nu_{k,{\color{blue} t}}(\coeff_{{} \in \mathrm{JW}_Q(m+1)} D')=-1$, which is a contradiction.
\end{proof}

\begin{lem} \label{qbinominvcoef}
Let $n,k$ be integers with $0 \leq k \leq n$.
There exists a two-colored diagram $D$ such that $\coeff_{{}\in \mathrm{JW}(\prescript{}{{\color{red} s}}{n})} D=\qbinom{n}{k}_{{\color{red} s}}^{-1}$.
\end{lem}

\begin{proof}
Take $D$ to be the diagram with $k$ nested caps on the bottom left, $k$ nested cups on the top right, and all other strands connected from bottom to top.
For example, if $n=5$ and $k=2$ we set
\begin{equation*}
D=\begin{gathered}
        \begin{tikzpicture}[xscale=.4,yscale=.2]
          \begin{scope}
            \clip (-3,3.5) rectangle (3,-3.5);
            \draw[fill=dgrmred] (2.5,4) rectangle (-4,-4);
            \draw[fill=dgrmblu] (4,-4) to (2,-3.5) to[out=90,in=-90] (-2,3.5) to (-2,4) to (-1,3.5) to[out=-90,in=180] (0.5,1.5) to[out=0,in=-90] (2,3.5) to (4,4) to (4,-4);

          \draw[fill=dgrmblu] (-2,-4) to (-2,-3.5) to[out=90,in=180] (-.5,-1.5) to[out=0,in=90] (1,-3.5) to (1,-4) to (0,-3.5) to[out=90,in=0] (-.5,-2.5) to[out=180,in=90] (-1,-3.5) to (-2,-4);
          \draw[fill=dgrmblu] (0,4) to (0,3.5) to[out=-90,in=180] (.5,2.5) to[out=0,in=-90] (1,3.5) to (0,4);
       \end{scope}
       \draw[dashed] (-3,3.5) to (3,3.5);
       \draw[dashed] (-3,-3.5) to (3,-3.5);
     \end{tikzpicture}
\end{gathered}
\end{equation*}
The result follows by \cref{JWcoef} and induction on $n$.
\end{proof}

\begin{thm} \label{genericcoefs}
For each two-colored Temperley--Lieb diagram $D$ there are coprime elements $f_D,g_D \in A$ such that if $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ exists,
\begin{equation*}
\coeff_{{} \in \mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})} D
\end{equation*}
is the specialization of $f_D/g_D$ in $R$.
In particular, the existence of $\mathrm{JW}_R(n)$ implies that the specialization of $g_D$ in $R$ is invertible for all diagrams $D$.
\end{thm}

\begin{rem}
We consider generic computation of the coefficients of one-colored Jones--Wenzl projectors (at least for subrings of $\mathbb{C}$) to be mathematical folklore, i.e.~a ``known'' result without a published proof.
In \cite[Theorem~6.13]{ew-localizedcalc} Elias--Williamson carefully prove an analogous result under the assumption that $R$ is both an integral domain and a henselian local ring.
Our proof does not require any restrictions on $R$ but is essentially equivalent to \cref{existence}.
\end{rem}

\begin{proof}
Let
\begin{equation*}
T_R=\{f \in 2\mathrm{TL}_R(\prescript{}{{\color{red} s}}{n}) : e_i f=0 \text{ for all } 1 \leq i \leq n-1\} \text{.}
\end{equation*}
In other words, $T_R$ is the (right) annihilator of the generators $e_1,\dotsc,e_{n-1}$.
One can show that $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ exists if and only if there exists $f \in T_R$ for which $\coeff_{{} \in f} 1$ is invertible in $R$ (see e.g.~\cite[Exercise~9.25]{emtw} for the one-colored case).
When this happens, $T_R=R\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$.

Clearly $\mathrm{JW}_Q(\prescript{}{{\color{red} s}}{n})$ exists so $T_Q=Q\mathrm{JW}_Q(n)$.
Thus $T_A$ is a free $A$-module of rank $1$, generated by $c\mathrm{JW}_Q(n) \in \mathrm{TL}_A(n)$, where $c$ is the least common multiple of the denominators of the coefficients of $\mathrm{JW}_Q(n)$.
\Cref{twocolvalbound} implies that $c$ divides
\begin{equation*}
g_n=\prod_{\substack{1 \leq k \leq n\\ k \nmid n+1}} \Theta_{k,{\color{red} s}} \text{,}
\end{equation*}
while \cref{qbinominvcoef} and \cref{qbinominvideal} give $c=g_n$.
If $\mathrm{JW}_R(n)$ exists, we have $T_R=R\mathrm{JW}_R(n) \geq R \otimes_A g_n\mathrm{JW}_Q(n)$, and thus $g_n\mathrm{JW}_R(n)=1 \otimes_A g_n\mathrm{JW}_Q(n)$.
But the coefficients of $g_n\mathrm{JW}_Q(n)$ (which lie in $A$) generate $(1)$ as an ideal of $A$ (again by \cref{qbinominvideal}), which directly implies that $g_n$ is invertible in $R$, and $\mathrm{JW}_R(n)=g_n^{-1} \otimes_A g_n \mathrm{JW}_Q(n)$.
\end{proof}

\begin{proof}[Proof of \cref{existence}]
The invertibility of $\qbinom{n}{k}_{{\color{red} s}}$ is necessary for $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ to exist by \cref{qbinominvcoef}.
Sufficiency follows from \cref{qbinominvideal}, \cref{twocolvalbound}, and \cref{genericcoefs} (or more simply from the proof of \cref{genericcoefs}).
\end{proof}

For $f \in Q$, say that $f$ exists in $R$ if there are $a,b \in A$ with $f=a/b$ and $b$ invertible in $R$.

\begin{lem}
Suppose $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ exists.
Then $\frac{[n+1]_{{\color{red} s}}}{[k]_{{\color{red} s}}}$ exists in $R$ for any integer $1 \leq k \leq n+1$.
\end{lem}

\begin{proof}
We have
\begin{equation*}
\frac{[n+1]_{{\color{red} s}}}{[k]_{{\color{red} s}}}=\frac{\prod_{l|n+1} \Theta_{l,{\color{red} s}}}{\prod_{l|k} \Theta_{l,{\color{red} s}}}=\frac{\prod_{\substack{l|n+1\\ l \nmid k}} \Theta_{l,{\color{red} s}}}{\prod_{\substack{l|k\\ l \nmid n+1}} \Theta_{l,{\color{red} s}}} \text{,}
\end{equation*}
and the denominator of the right-hand side divides
\begin{equation*}
\prod_{\substack{1 \leq l \leq n\\ l \nmid n+1}} \Theta_{l,{\color{red} s}}
\end{equation*}
which is invertible by \cref{existence} and \cref{qbinominvideal}.
\end{proof}

\begin{prop} \label{simple-rotatability}
Suppose the two-colored Jones--Wenzl projectors $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ and $\mathrm{JW}_R(\prescript{}{{\color{blue} t}}{n})$ exist.
Then $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ is rotatable if and only if $\frac{[n+1]_{{\color{red} s}}}{[k]_{{\color{red} s}}}=0$ for all integers $1 \leq k \leq n$.
\end{prop}

\begin{proof}
Calculating generically, we have
\begin{equation*}
\pTr(\mathrm{JW}_Q(\prescript{}{{\color{red} s}}{n}))=-\frac{[n+1]_{{\color{red} s}}}{[n]_{{\color{red} s}}}\mathrm{JW}_Q(\prescript{}{{\color{red} s}}{(n-1)})
\end{equation*}
by \eqref{eq:genericpTr}.
From the proof of \cref{genericcoefs} the coefficients of $\mathrm{JW}_Q(\prescript{}{{\color{red} s}}{(n-1)})$ can be written as sums of fractions of the form $a\qbinom{n-1}{k}_{{\color{red} s}}^{-1}$ for some $a \in A$ and some integer $0 \leq k \leq n-1$.
Now observe that
\begin{equation*}
-\frac{[n+1]_{{\color{red} s}}}{[n]_{{\color{red} s}}}\frac{a}{\qbinom{n-1}{k}_{{\color{red} s}}}=-\frac{[n+1]_{{\color{red} s}}[k]_{{\color{red} s}}! a}{[n]_{{\color{red} s}}[n-1]_{{\color{red} s}} \dotsm [n-k]_{{\color{red} s}}}=-\frac{[n+1]_{{\color{red} s}}}{[k+1]_{{\color{red} s}}}\frac{a}{\qbinom{n}{k+1}_{{\color{red} s}}}
\end{equation*}
noting that since $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ exists, $\qbinom{n}{k+1}_{{\color{red} s}}$ is invertible.
Thus $\mathrm{JW}_R(\prescript{}{{\color{red} s}}{n})$ is rotatable if $\frac{[n+1]_{{\color{red} s}}}{[k+1]_{{\color{red} s}}}=0$.
Conversely, by \cref{qbinominvcoef} there is a a diagram whose coefficient in $\mathrm{JW}_Q(\prescript{}{{\color{red} s}}{n})$ is exactly $\qbinom{n-1}{k}_{{\color{red} s}}^{-1}$, so the above calculation shows that rotatability implies $\frac{[n+1]_{{\color{red} s}}}{[k+1]_{{\color{red} s}}}=0$.
\end{proof}

\begin{proof}[Proof of \cref{existsrotates}]
The condition on quantum binomial coefficients is the same as \cite[Assumption~1.1]{abe-homBS}.
By \cite[Proposition~3.4]{abe-homBS} this implies that the quantum binomial coefficients $\qbinom{n}{k}_{{\color{red} s}}$ and $\qbinom{n}{k}_{{\color{blue} t}}$ are all invertible.
Since
\begin{equation}
\qbinom{n+1}{k}_{{\color{red} s}}=\frac{[n+1]_{{\color{red} s}}}{[k]_{{\color{red} s}}}\qbinom{n}{k-1}_{{\color{red} s}} \label{eq:binomcoefincrement}
\end{equation}
and similarly for ${\color{blue} t}$, we conclude that $\frac{[n+1]_{{\color{red} s}}}{[k]_{{\color{red} s}}}=\frac{[n+1]_{{\color{blue} t}}}{[k]_{{\color{blue} t}}}=0$ for all integers $1 \leq k \leq n$.
Conversely, if the two-colored Jones--Wenzl projectors exist and are rotatable, then \eqref{eq:binomcoefincrement} combined with \cref{existence} and \cref{simple-rotatability} show that $\qbinom{n+1}{k}_{{\color{red} s}}$ and $\qbinom{n+1}{k}_{{\color{blue} t}}$ vanish for all integers $1 \leq k \leq n$.
\end{proof}

\section{Applications to Soergel bimodules}

The diagrammatic Hecke category of Elias--Williamson is constructed from a reflection representation of a Coxeter group called a \defnemph{realization}.
For each finite parabolic dihedral subgroup they identify a corresponding two-colored Temperley--Lieb algebra, whose defining parameters depend on the realization \cite[\S 5.2]{ew-soergelcalc}.
In \cite[\S 5]{ew-localizedcalc} Elias--Williamson highlight some hidden assumptions about their realizations from \cite{ew-soergelcalc}.
Their most basic assumption (without which the diagrammatic Hecke category is not well defined) is that certain two-colored Jones--Wenzl projectors exist and are rotatable.
For the benefit of future work we give a corrected definition of a realization (which ensures the existence and rotatability of these Jones--Wenzl projectors) below.

\begin{defn} \label{realizcorrected}
Let $\Bbbk$ be an integral domain.
A \defnemph{realization} of a Coxeter system $(W,S)$ over $\Bbbk$ consists of a free, finite rank $\Bbbk$-module $V$ along with subsets
\begin{align*}
\{\alpha_s : s \in S\} & \subset V &  \{\alpha_s^\vee : s \in S\} \subset V^\ast=\Hom_\Bbbk(V,\Bbbk)
\end{align*}
 such that
\begin{enumerate}[label=(\roman*)]
\item $\langle \alpha_s^\vee,\alpha_s \rangle=2$ for all $s \in S$;

\item the assignment
\begin{equation*}
s(\beta)=\beta-\langle \alpha_s^\vee, \beta \rangle \alpha_s
\end{equation*}
for all $s \in S$ and $\beta \in V$ defines a representation of the Coxeter group $W$ on $V$;

\item \label{item:abecond} for all $s,t \in S$ with $m_{st}<\infty$, we have
\begin{equation*}
\qbinom{m_{st}}{k}_{{\color{red} s}}(\langle \alpha_s^\vee,\alpha_t\rangle, \langle \alpha_t^\vee,\alpha_s\rangle)=\qbinom{m_{st}}{k}_{{\color{blue} t}}(\langle \alpha_s^\vee,\alpha_t\rangle, \langle \alpha_t^\vee,\alpha_s\rangle)=0
\end{equation*}
for all integers $1 \leq k \leq m_{st}-1$.
\end{enumerate}
\end{defn}

By \cref{existsrotates}, condition \ref{item:abecond} above is equivalent to the existence and rotatability of $\mathrm{JW}_{\Bbbk}(\prescript{}{{\color{red} s}}{(m_{st}-1)})$ and $\mathrm{JW}_{\Bbbk}(\prescript{}{{\color{blue} t}}{(m_{st}-1)})$ for $[2]_{{\color{red} s}}=\langle \alpha_s^\vee,\alpha_t\rangle$ and $[2]_{{\color{blue} t}}=\langle \alpha_t^\vee,\alpha_s\rangle$.
This condition is exactly Abe's assumption \cite[Assumption~1.1]{abe-homBS}, so \cref{abeequalsew} immediately follows by Abe's results \cite[Theorem~3.9]{abe-homBS} and \cite[Theorem~5.6]{abe-bimodhecke}.
It is also equivalent to
\begin{equation} \label{eq:minpolycond}
\begin{aligned}
\Psi_{m_{st}}(\langle \alpha_s^\vee,\alpha_t \rangle \langle \alpha_t^\vee,\alpha_s \rangle)& =0 & &\text{if $m_{st}>2$,} \\
\langle \alpha_s^\vee,\alpha_t \rangle=\langle \alpha_t^\vee, \alpha_s^\vee \rangle& =0 & & \text{if $m_{st}=2$,}
\end{aligned}
\end{equation}
by \cref{qbinomideal}.

\begin{rem}
In \cite{ew-soergelcalc} Elias--Williamson incorrectly state that
\begin{equation} \label{eq:ewtechnicalcondition}
[m_{st}]_{{\color{red} s}}(\langle \alpha_s^\vee,\alpha_t\rangle, \langle \alpha_t^\vee,\alpha_s\rangle)=[m_{st}]_{{\color{blue} t}}(\langle \alpha_s^\vee,\alpha_t\rangle, \langle \alpha_t^\vee,\alpha_s\rangle)=0
\end{equation}
is enough to ensure the existence and rotatability of $\mathrm{JW}_\Bbbk(\prescript{}{{\color{red} s}}{(m_{st}-1)})$.
(This error was identified in \cite{ew-localizedcalc} but only partially resolved there.)
In the same paper Elias--Williamson also incorrectly state that \eqref{eq:ewtechnicalcondition} is equivalent to \eqref{eq:minpolycond}.
Amusingly, when these two statements are combined these errors accidentally cancel and the result is a correct statement!
\end{rem}

\printbibliography

\end{document}