text
stringlengths 28
935k
| meta
stringlengths 137
139
| red_pajama_subset
stringclasses 1
value |
---|---|---|
\section{Introduction}\label{Introduction}
Location data play an important part in offering customized services to mobile users. Whether they are used to find nearby points of interest, to offer location-based recommendations, or to locate friends situated in proximity to each other, location data significantly enrich the type of interactions between users and their favorite services. However, current service providers collect location data in clear, and often share it with third parties, compromising users' privacy. Movement data can disclose sensitive details about an individual's health status, political orientation, alternative lifestyles, etc. Hence, it is important to support such location-based interactions while protecting privacy.
Our focus is on {\em secure alert zones}, a type of location-based service where users report their locations in encrypted form to a service provider, and then they receive alerts when an event of interest occurs in their proximity. This operation is very relevant to contact tracing, which is proving to be essential in controlling pandemics, e.g., COVID-19. It is important to determine if a mobile user came in close proximity to an infected person, or to a surface that has been exposed to the virus, but at the same time one must prevent against intrusive surveillance of the population. More applications of alert zones include public safety notifications (e.g., active shooter), and commercial applications (e.g., notifying mobile users of nearby sales events).
{\em Searchable Encryption (SE)} \cite{song2000,boneh2007conjunctive,HXT18} is very suitable for implementing secure alert zones. Users encrypt their location before sending it to the service provider using a special kind of encryption, which allows the evaluation of predicates directly on ciphertexts. However, the underlying encryption functions are not specifically designed for geospatial queries, but for arbitrary keyword or range queries. As a result, a data mapping step is typically performed to transform spatial queries to the primitive operations supported on ciphertexts. Due to this translation, the performance overhead can be significant. Some solutions use {\em Symmetric Searchable Encryption (SSE)} \cite{song2000,curtmola2011searchable,HXT18}, where a trusted entity knows the secret key of the transformation, and collects the location of all users before encrypting them and sending the ciphertext to the service provider. While the performance of SSE can be quite good, the system model that requires mobile users to share their clear text locations with a trusted service is not adequate from a privacy perspective, since it still incurs a significant amount of disclosure.
To address the shortcomings of SSE models, the work in \cite{boneh2007conjunctive} introduced the novel concept of {\em Hidden Vector Encryption (HVE)}, which is an {\em asymmetric} type of encryption that allows direct evaluation of predicates on top of ciphertext. Each user encrypts her own location using the {\em public} key of the transformation, and no trusted component that accesses locations in clear is required. This approach has been considered in the location context in~\cite{ghinita2014efficient},~\cite{nguyen2019privacy}, with encouraging results. However, the performance overhead of HVE in the spatial domain remains high. Motivated by this fact, we study techniques to reduce the computational overhead of HVE. Specifically, we derive special types of spatial data mapping using graph embeddings, which allow us to express spatial queries with predicates that are less computationally-intensive to evaluate.
In existing HVE work for geospatial data~\cite{ghinita2014efficient},~\cite{nguyen2019privacy}, the data domain is partitioned into a hierarchical data structure, and each node in this structure is assigned a binary string identifier. The binary representation of each node plays an important part in the query encoding, and it influences the amount of computation that needs to be executed when evaluating predicates on ciphertexts. However, the impact of the specific encoding is not evaluated in-depth. Our approach embeds the geospatial data domain to a high-dimensional hypercube, and then it applies graph embedding \cite{chandrasekharam1994genetic} techniques that directly target the reduction of computation overhead in the predicate evaluation step. Finally, no existing work considers the case of alert zones that change over time. Support for dynamic alert zones is very important, given that in most use case scenarios, phenomena of interest evolve over time (e.g., places visited by COVID carriers, area affected by a gas leak, etc). Our work tackles this important challenge\footnote{This submission is an extended version of the work in \cite{dbsec}. Additional contributions include: a complexity analysis of Gray-based approaches (Section~\ref{Sec: Complexity Analysis}); novel techniques for supporting dynamic alert zones~(Section~\ref{Advance Modeling of Alert Zones}); and an updated experimental section, including empirical evaluation of dynamic alert zones algorithms.}.
Our specific contributions are:
\begin{itemize}
\item We introduce a novel transformation of the spatial data domain based on graph embedding that is able to model accurately the performance overhead incurred when running HVE queries for spatial predicates;
\item We transform the problem of minimizing HVE computation to a graph problem, and show that the optimal solution is NP-hard;
\item We devise several heuristics that can solve the problem efficiently in the embedded space, while reducing significantly the computational overhead;
\item We propose models that take into account the spatial and temporal evolution of alert zones, and choose encodings that improve performance under dynamic conditions;
\item We perform an extensive experimental evaluation which shows that the proposed approaches are able to halve the performance overhead incurred by HVE when processing spatial queries.
\end{itemize}
The rest of the paper is organized as follows: Section 2 introduces necessary background on the system model (an HVE primer is given in Appendix~\ref{sec:app}). Section 3 provides the details of the proposed graph embedding transformation. Section 4 introduces several heuristic algorithms that solve the problem efficiently. Section 5 focuses on modeling of dynamic alert zones, and on advanced encodings under changing conditions. Section 6 evaluates thoroughly the proposed approach on real-life datasets. We survey related work in Section 7 and conclude in Section 8.
\section{Background}\label{Sec: Background}
\subsection{System Model}\label{Sec: System Model}
Consider a [0,1]$\times$[0,1] spatial data domain divided into $n$ non-overlapping partitions, denoted as
\begin{equation}
\mathcal{V}=\{ v_1,\,,v_2,..., v_{n} \}.
\end{equation}
We use the term {\em cell} to refer to partitions, which can have an arbitrary size and shape. An example of such a partitioning is provided in Fig.~\ref{Fig: Sample grid}.
The system architecture of location-based alert system is represented in Fig.~\ref{fig:system model}, and consists of three types of entities:
\newcommand{\rvec}{\mathrm {\mathbf {r}}}
\begingroup
\begin{table}
\caption {Summary of notations.}
\centering
\begin{tabular}{>{\arraybackslash}m{2cm} >{\arraybackslash}m{5.8cm} }
\hline\hline
Symbol & Description\\ \hline
$n$ & Number of cells \\
$k$ & Length of HVE index \\
$\mathcal{V} = \{ \bigcup v_i\}$ & Set of all cells\\
$C_j$ & Encrypted location of user $j$\\
$TK$ & Token $j$\\
$M_j$ & message of user $j$\\
$G_1(\mathcal{C}, \mathcal{E}_1)$ & $k$-cube; vertices $\mathcal{C} = \{ \bigcup c_i\}$; edges $\mathcal{E}_1$\\
$G_2(\mathcal{V}, \mathcal{E}_2)$ & Complete graph; vertices $\mathcal{V} = \{ \bigcup v_i\}$; edges $\mathcal{E}_2$ \\
$(\mathcal{H}_1,\mathcal{H}_2,\mathcal{E}_3)$ & Bipartite graph; node sets $\mathcal{H}_1$ and $\mathcal{H}_2$; edges $\mathcal{E}_3$ \\
$\mathcal{D}_{i|c_j}$ & Set of nodes in $\mathcal{C}$ with Hamming distance $i$ from $c_j$ \\
$\mathcal{L}_x$ & Set of all complete $x$-bit gray cycles, $\mathcal{L}_x = \{ \bigcup l_i \}$ \\
$\mathcal{S}_n$& state space with $n$ cells\\
$Q_n$& state transition matrix with $n$ cells\\
Pois($\lambda$)& Poisson distribution; occurrence rate $\lambda$\\
$\boldsymbol{s}$& Stationary distribution vector\\
$\textbf{\underline{i}}$& state $i$\\
\hline\hline
\end{tabular}
\label{tab:table1}
\end{table}
\endgroup
\begin{enumerate}
\item
{\bf Mobile Users} subscribe to the alert system and periodically submit encrypted location updates.
\item
The {\bf Trusted Authority (TA)} is a trusted entity that decides which are the alert zones, and creates for each zone a search {\em token} that allows to check privately if a user location falls within the alert zone or not.
\item
The {\bf Server (S)} is the provider of the alert service. It receives encrypted updates from users and search tokens from TA, and performs the predicate evaluation to decide whether encrypted location $C_i$ of user $i$ falls within alert zone $j$ represented by token $TK_j$. If the predicate holds, the server learns message $M_i$ encrypted by the user, otherwise it learns nothing.
\end{enumerate}
Table~\ref{tab:table1} summarizes the notations used throughout the manuscript.
\begin{figure*}[t]
\centering
\includegraphics[scale=.55]{Figures/System_model2.png}
\hspace{1em}
\centering
\caption{Location-based alert system.}
\label{fig:system model}
\end{figure*}
\begin{figure}[t]
\centering
\includegraphics[scale=.45]{Figures/Match2.png}
\hspace{1em}
\centering
\caption{HVE evaluation.}
\label{fig:math-nonmatch}
\end{figure}
The system supports location-based {\em alerts}, with the following semantics: a {\em Trusted Authority (TA)} designates a subset of cells as an {\em alert zone}, and all the users enclosed by those cells must be notified. The TA can be, for instance, the Center for Disease Control (CDC), who is monitoring cases of a pandemic, and wishes to notify users who may have been affected; or, the TA can be some commercial entity that the users subscribe to, and who notifies users when a sales event occurs at selected locations.
The {\em privacy requirement} of the system dictates that the server must not learn any information about the user locations, other than what can be derived from the match outcome, i.e., whether the user is in a particular alert zone or not. In case of a successful match, the server $S$ learns that user $u$ is enclosed by zone $z$. In case of a non-match, the server $S$ learns only that the user is outside the zone $z$, but no additional location information. Note that, this model is applicable to many real-life scenarios. For instance, users wish to keep their location private most of the time, but they want to be immediately notified if they enter a zone where their personal safety may be threatened. Furthermore, the extent of alert zones is typically small compared to the entire data domain, so the fact that $S$ learns that $u$ is {\em not} within the set of alert zones does not disclose significant information about $u$'s location.
The TA can be an organization such as CDC, or a city's public emergency department, which is trusted not to compromise user privacy, but at the same time does not have the infrastructure to monitor a large user population, and outsources the service to a cloud provider.
\begin{figure*}[t]
\centering
\subfloat[Sample grid.\label{Fig: Sample grid}]{%
\includegraphics[scale = 0.5]{Figures/g12.png}
}
\subfloat[Graph $G_1(\mathcal{C}, \mathcal{E}_1)$.\label{Fig: Graph G1}]{%
\includegraphics[scale = 0.46]{Figures/g2.png}
}
\subfloat[Graph $G_2(\mathcal{V}, \mathcal{E}_2)$.\label{Fig: Graph G2}]{%
\includegraphics[scale=.5]{Figures/g3.png}
}
\caption{An example of embedding graphs generated based on a sample grid.}
\end{figure*}
\subsection{Problem Statement}\label{Sec: Problem Statement}
Prior work~\cite{ghinita2014efficient,nguyen2019privacy} assumed that all cells are equally likely be in an alert zone. However, that is not the case in practice. Some parts of the data domain (e.g., denser areas of a city) are more likely to become alert zones.
The cost of encrypted alert zone enclosure evaluation is given by the number of operations required to apply HVE matching at the service provider.
As we discuss in our HVE primer in Appendix A, the evaluation cost is directly proportional to the number of non-star bits in the tokens.
Armed with knowledge about the likelihood of cells to be part of an alert zone, one can create superior encodings that reduce processing overhead.
Our goal is to find an enhanced encoding that reduces non-star bits for a given set of alert zone tokens.
Denote by $p(v_i)$ the probability of cell $v_i$ being part of an alert zone. The {\em mutual} probability of multiple cells indicates how likely they are to be part of the {\em same} alert zone. Given individual cell probabilities, the mutual probability of a set of $i$ cells $\mathcal{L} = \{ v_1',\,,v_2',..., v_{i}' \}$ is calculated as:
\begin{equation}\label{base}
p(\mathcal{L}) = \prod_{j=1}^{i} p(v'_j).
\end{equation}
The problem we study is formally presented as follows:
\begin{problem}\label{Problem: 1}
Find an encoding of the grid that on average reduces the number of non-star bits in the tokens generated from alert zone cells.
\end{problem}
In the above formulation, the correlation between cells becoming part of an alert zone is assumed to be negligible. In essence, the assumption is that cells are independent in time and space (in Section~\ref{Advance Modeling of Alert Zones}, we provide an advanced modeling of the correlation of alert zones over space and time).
\section{Location Domain Mapping through Graph Embedding} \label{sec:ProblemEmbedding}
Our approach minimizes the number of non-star bits in alert zone tokens by modeling the data domain partitioning as an embedding problem of a $k$-cube onto a complete graph. We denote a $k$-cube as $G_1(\mathcal{C}, \mathcal{E}_1)$, where $\mathcal{C}=\{ c_1,\,,c_2,..., c_{n} \}$ and $c_i=\{0,1\}^k$. Fig.~\ref{Fig: Graph G1} illustrates a $k$-cube generated based on the sample partitioning in Fig~\ref{Fig: Sample grid}. In $G_1$, two nodes $c_i$ and $c_j$ are connected if their \textit{Hamming distance} is equal to one. We refer to such a bit as \textit{Hamming bit}.
\begin{defn}{(Hamming Distance and Bits).}\label{Hamming distance and bits}
The Hamming distance between two indices $c_i$ and $c_j$ in $G_1(\mathcal{C}, \mathcal{E}_1)$ is the minimum number of substitutions required to transform $c_i$ to $c_j$, denoted by the function $d_h(.)$. We refer to the bits that need to be substituted as the {\em Hamming bits} of the indices.
\end{defn}
\begin{exmp}
The Hamming distance between indices $c_1=0100$ and $c_2 = 0010$ is two ($d_h(c_i,c_j)=2$), and the Hamming bits are the second and third most significant bits of the indices.
\end{exmp}
The second graph required to formulate the problem of minimizing the number of non-stars is a complete graph generated by all cells in the partitioning, denoted by $G_2(\mathcal{V}, \mathcal{E}_2)$. The set $\mathcal{V}$ represents the nodes corresponding to cells, and an undirected edge connects every two nodes in $G_2$.
Note that, every token (including those containing stars), can be related to several cycles on the $k$-cube. For example, token 00** represents four indices 0000, 0001, 0010, 0011, which correspond to cycles $(c_1,c_2,c_6,c_3)$ and $(c_1,c_3,c_6,c_2)$ on the $k$-cube in Fig.~\ref{Fig: Graph G1}. Unfortunately, there is no one-to-one correspondence between the tokens and the cycles. In particular, for a larger number of stars, there exist several cycles representing the same token. To generate a one-to-one correspondence, we incorporate {\em Binary-Reflected Gray (BRG)} encoding on the $k$-cube to create unique cycles corresponding to tokens.
\begin{defn}(BRG path on $k$-cube).\label{Defn: gray path}
A BRG path between two nodes with non-zero Hamming distance is defined as the path on the $k$-cube going from one node to another based on BRG coding on Hamming bits.
\end{defn}
As an example, the Hamming bits between 0001 and 1000 are the least and most significant bits, and the BRG path connecting them on the $k$-cube in Fig.\ref{Fig: Graph G1} includes indices 0001, 1001, and 1000 in the given order. One can see that as the BRG codes are unique, the BRG path between two indices on the $k$-cube is also unique. This characteristic of BRG paths is formulated in Lemma~\ref{Thm: gray path lemma}.
\begin{lemma}\label{Thm: gray path lemma}
A BRG path between two nodes on a $k$-cube is unique.
\end{lemma}
\begin{proof}
The uniqueness of the path between two nodes on the $k$-cube follows from the uniqueness of BRG code, as only one such path can be constructed.
\end{proof}
\begin{defn}(Complete $x$-bit BRG cycle).\label{Defn: gray cycle}
Given a $k$-cube, a complete $x$-bit BRG cycle is a cyclic BRG path with the length of $2^x$, in which only $x$ bits are affected. We denote the set of all possible complete $x$-bit BRG cycles by $\mathcal{L}_x = \{ \bigcup l_i \}$.
\end{defn}
\begin{exmp}\label{Example: 2}
In Fig.~\ref{Fig: Graph G1}, token *0** entails eight indices 0000, 0001, 0011, 0010, 1010, 1011, 1001, 1000. This token maps uniquely to the complete 3-bit BRG cycle on the 4-cube with nodes $(c_1,\,c_2,\,c_6,\,c_3,\,c_{9},\,c_{13},\,c_8,\,c_5)$ and start point $c_1$.
\end{exmp}
We can uniquely associate a token to a cycle on the $k$-cube. Consider a token with $k$ bits and $x$ stars. This token is mapped to a complete $x$-bit BRG cycle on the $k$-cube, starting from a node in which all the star bits are set to zero. Such a cycle is unique and has a length of $2^x$. Based on this mapping, every token is associated with a unique cycle on the $k$-cube, and every complete $x$-bit BRG cycle is mapped to a unique token with $x$-stars. Therefore, there is a one-to-one correspondence between tokens and complete BRG cycles.
The formulation of Problem~\ref{Problem: 1} based on graph embedding can be written as follows:
\begin{problem}\label{Problem: 2}
Given two graphs $G_1(\mathcal{C}, \mathcal{E}_1)$ and $G_2(\mathcal{V}, \mathcal{E}_2)$, find a mapping function $\mathcal{F}: G_1\rightarrow G_2$ with the objective to
\begin{align}\label{maximizing1}
Maximize\{\sum_{i=1}^{k} p(\mathcal{L}_i)\}.
\end{align}
\end{problem}
\subsection{Gray Optimizer (GO)}\label{Sec: Gray Optimizer}
The problem of embedding a complete graph within a minimized size $k$-cube has been shown to be NP-hard~\cite{chandrasekharam1994genetic}. We develop an heuristic algorithm called \textit{Gray Optimizer} that solves Problem~\ref{Problem: 2}. Consider an initial node of the complete graph $v_r \in \mathcal{V}$, and without loss of generality assume that it is assigned to index $c_1$. We refer to nodes in $\mathcal{G}_1$ interchangeably using their vertex id or binary index. The optimization problem can be formulated as follows.
\begin{problem}\label{Problem: 3}
Given two graphs $G_1(\mathcal{C}, \mathcal{E}_1)$ and $G_2(\mathcal{V}, \mathcal{E}_2)$, and the node $v_r\in \mathcal{V}$ assigned to index $c_1$, find a mapping function $\mathcal{F}: G_1\rightarrow G_2$ that
\begin{align}\label{maximizing2}
Maximize\{ \sum_{i=1}^{k} p(\mathcal{L}_i|v_r)\}.
\end{align}
\end{problem}
Problem~\ref{Problem: 2} requires an assignment of vertices in $G_2$ to the nodes of $G_1$ such that the probability of complete BRG cycles is maximized; whereas Problem~\ref{Problem: 3} seeks to maximize the probability of cycles with respect to a particular node, in this case $v_r$, which is assigned to the index $c_1$. A reasonable candidate for assignment to $c_1$ is the cell with the highest probability, as it is most likely to be part of an alert zone. To solve this problem, we propose the heuristic in Algorithm~\ref{Algo: Mapping Algorithm}.
The input of the algorithm is the root index $c_1\in G_1$, the root node $v_r\in G_2$ (also called seed) and the graphs $G_1$ and $G_2$.
\begin{algorithm}[tbh]
\DontPrintSemicolon
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{output}
\Input{$G_1$; $G_2$; $c_1$; $v_r$}
Sort nodes in $G_2$ based on probabilities\\
Assign $v_r$ to $c_1$\\
\For {$i\, \textrm{in}\, [1:k]$} {
Initialize $\mathcal{H}_1, \mathcal{H}_2=\emptyset$\\
$\mathcal{H}_1 \leftarrow \{ \binom{k}{i}$ non-assigned nodes in $G_2$ with the highest probability$\}$\\
\For {$c_j \in \mathcal{D}_{i|c_1}$}{
Calculate $ p(l_j/c_j) = \prod_{v\in l_j/c_j} p(v)$\\
$\mathcal{H}_2 \leftarrow p(l_j/c_j)$\\
}
Sort nodes in $\mathcal{H}_2$ \\
Match vertices in $\mathcal{H}_1$ to $\mathcal{H}_2$\\
}
\caption{Gray Optimizer.}
\label{Algo: Mapping Algorithm}
\end{algorithm}
Denote by $\mathcal{D}_{i|c_1}$ the set of nodes on $\mathcal{C}$ that have a Hamming distance of $i$ from $c_1$. Note that $\mathcal{D}_{i|c_1}$ includes $\binom{k}{i}$ nodes, each one having a Hamming distance of $i$ from $c_1$. The overall assignment structure is as follows: first, Algorithm~\ref{Algo: Mapping Algorithm} assigns the remaining nodes of $\mathcal{V}$ of the graph $\mathcal{G}_2$ to nodes in $\mathcal{D}_{1|c_1}$. After assignment of all nodes in $\mathcal{D}_{1|c_1}$, the algorithm assigns the nodes in $\mathcal{D}_{2|c_1}$ and follows the same process until all nodes are assigned ($\mathcal{D}_{1|c_1}$ to $\mathcal{D}_{k|c_1}$). An initial sorting of nodes in $\mathcal{V}$ is conducted at the start of the algorithm, and is used throughout the assignment process to reduce the computation complexity.
The assignment objective in stage $i$ of the process is to maximize $p(\mathcal{L}_i|v_r)$.
Note that~(\ref{maximizing2}) can be written as:
\begin{align}\label{maximizing3}
\sum_{i=1}^{k} Maximize\{p(\mathcal{L}_i|v_r)\}.
\end{align}
where $p(\mathcal{L}_i|v_r)$ represents the probability of all complete $i$-bit BRG cycles that include $c_1$ ($v_r\rightarrow c_1$). Denote such a cycle by $l$. Based on the following lemma, there exists one and only one node $c_j$ in $l$ that has a Hamming distance of $i$ from $c_1$, which means that $c_j \in \mathcal{D}_{i|c_1}$. Therefore, every complete $i$-bit BRG cycle given index $c_1$ includes one node in $\mathcal{D}_{i|c_1}$. On the other hand, every node in $\mathcal{D}_{i|c_1}$ corresponds to a unique complete $i$-bit BRG cycle passing through $c_1$, as it results from Lemma~\ref{Thm: gray path lemma}. Therefore, all complete $i$-bit BRG cycles are considered in stage $i$ and we maximize their probabilities in this stage of the assignment.
\begin{lemma}\label{Thm: uniqueness}
For each node $c_i$ in a complete $x$-bit BRG cycle, there exists one and only one node with the Hamming distance of $x$ from $c_i$.
\end{lemma}
\begin{proof}
A complete $x$-bit BRG cycle includes $2^x$ nodes and only $x$ bits are affected. Therefore, the only index that can exist with the Hamming distance of $x$ from $c_i$ is the one in which all $x$ Hamming bits are flipped.
\end{proof}
The assignment process in the stage $i$ of GO creates a bipartite graph, i.e., $(\mathcal{H}_1,\mathcal{H}_2,\mathcal{E}_3)$, where $\mathcal{H}_1$ and $\mathcal{H}_2$ are two set of nodes, and $\mathcal{E}_3$ represents the set of edges. In this stage, the nodes in sets $\mathcal{D}_{1|c_1}$, $\mathcal{D}_{2|c_1}$,...,$\mathcal{D}_{i-1|c_1}$ are already assigned and we aim to find the best assignment for the nodes in $\mathcal{D}_{i|c_1}$ such that $p(\mathcal{L}_i|v_r)$ is maximized. Among the remaining nodes in $\mathcal{V}$, we choose $\binom{k}{i}$ of them that have the highest probabilities, as $|\mathcal{D}_{i|c_1}|=\binom{k}{i}$, and allocate them to $\mathcal{H}_1$.
On the other hand, for each node $c_j$ in $\mathcal{D}_{i|c_1}$, we construct the unique complete $i$-bit BRG cycle including $c_j$ and $c_1$. Let us represent this cycle by $l_j$. Note that all nodes included in $l_j$ are assigned except $c_j$. The algorithm calculates the probability of the set of nodes in $l_j$ excluding $c_j$ and allocates it to a node in $\mathcal{H}_2$. Based on~(\ref{base}), this probability can be calculated as:
\begin{equation}\label{base2}
p(l_j \diagdown \{c_j\}) = \prod_{v\in l_j \diagdown \{c_j\}} p(v),
\end{equation}
The algorithm repeats the process for all nodes in $\mathcal{D}_{i|c_1}$.
Next, the nodes in $\mathcal{H}_2$ are sorted, and the best matching is conducted between these two sets of nodes by assigning the $i^{th}$ node of $\mathcal{H}_1$ to the $i^{th}$ node of $\mathcal{H}_2$. The optimality of the matching process is proven in Lemma~\ref{Thm: matching}, and the achievement of maximal assignment in each stage is proven in Lemma~\ref{Thm: main proof}.
\begin{figure}[t]
\subfloat[Sample grid.\label{Fig: Sample grid 2}]{%
\includegraphics[scale=.38]{Figures/g4.png}
}
\hfill
\subfloat[Graph $G_1(\mathcal{C}, \mathcal{E}_1)$.\label{Fig: k-cube}]{%
\includegraphics[scale=.38]{Figures/g5.png}
}
\hfill
\centering
\subfloat[Graph $G_2(\mathcal{V}, \mathcal{E}_2)$.\label{Fig: Hungarian}]{%
\includegraphics[scale=.38]{Figures/g6.png}
}
\caption{An example of embedding graphs generated based on a sample grid.}
\end{figure}
\begin{lemma}\label{Thm: matching}
Suppose in the $i^{th}$ step of the algorithm $h_1$ to $h_{\binom{k}{i}}$ are the members of $\mathcal{H}_1$ and $h_1'$ to $h_{\binom{k}{i}}'$ are the members of $\mathcal{H}_2$ such that $h_1\leq h_2 \leq ... \leq h_{\binom{k}{i}}$ and $h_1'\leq h_2' \leq ... \leq h_{\binom{k}{i}}'$. The optimal value of matching is achieved when $h_i$ is matched with $h_i'$.
\end{lemma}
\begin{proof}
Suppose that the converse is true. Hence, there exist two nodes $h_i$ and $h_k$ which are paired with $h_j'$ and $h_t'$, respectively, such that $h_i \leq h_k$ and $h_j' \geq h_t'$. Since the current matching is maximal by swapping $h_j'$ and $h_t'$, we have
\begin{equation}\label{Equ: cost function}
h_ih_j'+h_kh_t' +R > h_ih_t'+h_kh_j'+R,
\end{equation}
where $R$ indicates the remaining pairing summation. Re-writing equation (\ref{Equ: cost function}) results in
\begin{equation}\label{Equ: cost function}
(h_i - h_k)\times (h_j'-h_t') > 0.
\end{equation}
However, $h_i \leq h_k$ and $h_j' \geq h_t'$, therefore, the left hand side of the equation is always less than or equal to zero, which is a contradiction. The case for equality of equation (\ref{Equ: cost function}) is removed as swapping does not change the summation and the lemma holds.
\end{proof}
\begin{lemma}\label{Thm: main proof}
In stage $i$, GO maximizes $p(\mathcal{L}_i|v_r)$ given the currently assigned nodes ($\mathcal{D}_{1|c_1},\, \mathcal{D}_{2|c_1}, ...,\, \mathcal{D}_{i-1|c_1}$).
\end{lemma}
\begin{proof}
We prove the lemma based on mathematical induction. \\
\textit{Base case:} For $i=1$, given that the node $v_r$ is assigned to $c_1$, we aim to prove that GO maximizes $p(\mathcal{L}_1|v_r)$. To start with, GO chooses $\binom{k}{1}$ remaining nodes of $\mathcal{V}$ for the purpose of assignment. The optimal assignment of nodes in $\mathcal{D}_{1|c_1}$ is a permutation of the chosen nodes; otherwise, they could be replaced with a node with a higher probability that would result in a higher value for $p(\mathcal{L}_1|v_r)$. Next, the algorithm generates a bipartite graph $(\mathcal{H}_1,\mathcal{H}_2,\mathcal{E}_3)$. The probability of chosen nodes are allocated to $\mathcal{H}_1$, and the nodes in $\mathcal{H}_2$ represent the probability of complete 1-bit gray cycles constructed from $c_j \in \mathcal{D}_{1|c_1}$ and the node $c_1$, excluding the probability of $c_j$ itself. Next, the optimal matching is done by assigning the $j^{th}$ maximum node in $\mathcal{H}_2$ to the $j^{th}$ maximum node in $\mathcal{H}_1$, achieving maximal $p(\mathcal{L}_1|v_r)$ given the node $c_1$.
\textit{Induction step:} Let us assume that GO has maximized the probabilities of complete x-bit BRG cycles for $x=1\textrm{ to }i-1$ in stages one to $i-1$. We prove that in stage $i$, the algorithm maximizes complete $i$-bit gray cycles, given the previously assigned nodes.
Based on Lemma~\ref{Thm: uniqueness}, all complete $i$-bit BRG cycles are considered in stage $i$, as each such cycle includes exactly one node in $\mathcal{D}_{i|c_1}$, which has the highest Hamming distance from $c_1$. {\em GO} starts by choosing the cells with the highest probabilities and assigning them to $\mathcal{H}_1$. Same as in the base case, we know that the optimal assignment in this stage includes the chosen set of nodes. Next, the nodes in $\mathcal{H}_2$ are assigned based on finding the probability of complete $i$-bit BRG cycles for nodes in $\mathcal{D}_{i|c_1}$, excluding the nodes themselves from the probability. As the matching process is optimal match, the best permutation of nodes in $\mathcal{H}_1$ is matched to complete $i$-bit BRG cycles.\qed
\end{proof}
\section{Scaling Up Gray Optimizer}\label{Sec: Scaling Up Gray Optimizer}
The GO algorithm can lead to significant improvements in the processing of HVE operations; however, there are two major drawbacks once the algorithm is applied to grids with high granularities. {\em (i)} The complexity of the algorithm creates a processing time bottleneck for its application in HVE; {\em (ii)} The calculation of probabilities for large complete BRG cycles may result in numerical inaccuracies. To make {\em GO} applicable to grids with higher levels of granularity, we propose two variations.
The first proposed algorithm, called {\em Multiple Seed Gray Optimizer (MSGO)} (Section~\ref{Sec: Multiple Seed Gray Optimizer (MSGO)}), generates non-overlapping clusters and applies {\em GO} within each one of them. The second algorithm, called Scaled Gray Optimizer (SGO) (Section~\ref{Sec: Large Grids}) takes a \textit{Breadth-First Search (BFS)}~\cite{leiserson2001introduction} approach. The performance of BFS is preferred to its counterpart \textit{Depth-First Search (DFS)} as the nodes closer to the seed have higher probabilities. Thus, it is reasonable to consider those nodes earlier in the process.
\subsection{Multiple Seed Gray Optimizer (MSGO)}\label{Sec: Multiple Seed Gray Optimizer (MSGO)}
The starting point of the {\em GO} algorithm, which we refer to as {\em seed}, was chosen as the node in $G_2$ with the maximum probability. However, the algorithm can work starting with any initial seed, then follow the assignment process for other nodes in ascending order of their Hamming distance from the seed.
Furthermore, as BRG cycles become larger, their associated probability becomes smaller. Thus, one way to reduce the complexity of {\em GO} is to run the algorithm up to a particular \textit{depth}.
Essentially, the algorithm aims at optimizing BRG cycles up to a certain length. We enhance {\em GO} by running Algorithm~\ref{Algo: Mapping Algorithm} with multiple seeds, and also by limiting the depth of the assignment.
\begin{defn}\label{Depth}
$\textit{Depth: }$ For a given seed $c_j$, the GO algorithm is said to run with a depth of $i$ if it only considers the assignment of nodes in $\mathcal{D}_{1|c_j},\, \mathcal{D}_{2|c_j}, ...,\, \mathcal{D}_{i|c_j}$.
\end{defn}
The pseudocode of the proposed approach is presented in Algorithm~\ref{Alg: Large Grid Mapping Algorithm (MSGO)}. The algorithm starts by assigning the node with the highest probability in $G_2$ to the origin of $G_1$ or a random index. However, instead of running GO with respect to this index for all depths from one to $k$, MSGO runs GO with the specified depth as input. The algorithm completes the process of assignment for a cluster of indices in $G_1$. MSGO then chooses a random index of $G_1$ among the remaining indices and assigns it to the node in $G_2$ with maximum probability among remaining nodes. Similarly, this index is used as a seed for GO with the specified depth and generates a new cluster. The cluster-based approach continues until all nodes are assigned to an index. The algorithm supports variable cluster sizes based on the underlying application.
\begin{algorithm}[tbh]
\DontPrintSemicolon
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{output}
\Input{$G_1$; $G_2$; \textit{depth}}
Sort nodes in $G_2$ based on probabilities\\
Select a random index on $G_1$ which is not currently assigned\\
Assign the index with the node that has the maximum probability in $G_2$\\
Apply Algorithm~\ref{Algo: Mapping Algorithm} on the selected index with the
specified depth\\
\textbf{Repeat} lines 2-4 \textbf{until} all indices are assigned\\
\caption{Multiple Seed Gray Optimizer~(MSGO).}
\label{Alg: Large Grid Mapping Algorithm (MSGO)}
\end{algorithm}
\begin{comment}
\begin{exmp}\label{Example: 3}
Consider the sample map provided in Fig.~\ref{Fig: Sample grid} and two banks $A$ and $B$ requested for location-based alert notification service with three and four branches, respectively, located on the map. Suppose that the headquarters of the banks have the highest probability of becoming an alert zone among the branches of each bank. In this scenario, MSGO proceeds by executing GO on three different clusters consisting of branches of bank $A$, branches of bank $B$, and the remaining cells of the grid. In the two clusters corresponding to the banks, headquarters would be the seeds used as input to GO, and for the third cluster, the cell with the highest probability is chosen as the seed. The depth of GO in each cluster is adjusted based on the corresponding number of cells.
\end{exmp}
\end{comment}
The MSGO algorithm provides a robust solution for grids with higher granularity. The algorithm no longer suffers the drawbacks of GO when the grid size grows, such as numerical inaccuracies in the calculation of the probability of large cycles. The complexity of the algorithm depends on the depth chosen as input, and in low depths, it can be implemented in $\mathcal{O}(n(\log_2n))$. MSGO can significantly reduce the number of operations required for the implementation of HVE in location-based alert systems, and therefore, making it a practical solution for preserving the privacy of users in location-based alert systems.
\subsection{Scaled Gray Optimizer (SGO)}\label{Sec: Large Grids}
SGO considers overlapping clusters and necessitates that all nodes act as seed during the assignment process. The pseudocode of the proposed approach is presented in Algorithm~\ref{Algo: Large Grid Mapping Algorithm}. SGO starts by assigning the node with the highest probability to an index on $G_1$. However, instead of assigning indices with all depths from one to $k$ with respect to index $c_1$, the SGO algorithm runs GO with the depth of one.
Next, SGO sorts the indices in $\mathcal{D}_{1|c_1}$ based on their assigned probabilities in descending order and runs GO with the depth of one on each index.
Once the algorithm is applied on all the indices in $\mathcal{D}_{1|c_1}$, the process repeats for indices in $\mathcal{D}_{2|c_1}$, $\mathcal{D}_{3|c_1}$, ..., etc. The algorithm continues until all indices are assigned to a node.
\begin{algorithm}[tbh]
\DontPrintSemicolon
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{output}
\Input{$G_1$; $G_2$}
Sort nodes in $G_2$ based on probabilities\\
Assign $v_r\in G_2$ with the highest probability to the origin of $G_1$, i.e., $c_1$\\
Apply Algorithm~\ref{Algo: Mapping Algorithm} on $c_1$ with the depth of one\\
\For {$i\, \textrm{in}\, [1:k]$} {
Sort $\mathcal{D}_{i|c_1}$ in descending order of probabilities assigned to its indices\\
\For {$c_j$ in $\mathcal{D}_{i|c_1}$} {
Apply Algorithm~\ref{Algo: Mapping Algorithm} on $c_j$ with the depth of one}
}
\caption{Scaled Gray Optimizer (SGO).}
\label{Algo: Large Grid Mapping Algorithm}
\end{algorithm}
\begin{comment}
\begin{exmp}\label{ex3t}
Consider a map of a vast rural area in which there is a likelihood of bush fire or security breaches for the residents. Therefore, the alert based notification system is implemented by a service provider to notify the farmers on their request. Due to a large number of cells included in the map, GO and MSGO require a comparably high computation overhead. Hence, the SGO algorithm could be used to improve the time complexity. Starting with the cell that has the highest probability, SGO executes GO with the minimum depth, i.e., one. Then, in a breadth-first-search manner, the algorithm moves to the first neighbors of that node, taking them as seeds of GO, prioritizing the nodes with higher assigned probability. The process continues until all the nodes of the grid are assigned.
\end{exmp}
\end{comment}
\subsection{Complexity Analysis}\label{Sec: Complexity Analysis}
The key computation overhead of the GO algorithm is in the calculation of probability of BRG cycles. Let the function $T(.)$ return the computational complexity. In the $i^{th}$ step of the algorithm, the nodes with the hamming distance of $i$ from $c_1$ are assigned to an index on the $k$-cube, i.e., $\mathcal{D}_{i|c_1}$. The number of nodes in $\mathcal{D}_{i|c_1}$ is $\binom{log_2(n)}{i}$. For each one of such nodes the complete BRG path is calculated which requires the multiplication of $2^i-1$ probabilities. Therefore, the assignment process for the nodes in $\mathcal{D}_{i|c_1}$ requires
\begin{equation}
T(\mathcal{D}_{i|c_1}) = (2^i-2)\times \binom{log_2(n)}{i}
\end{equation}
operations. Hence, the total number of operations required for the algorithm is
\begin{align}
\bigcup_i T( \mathcal{D}_{i|c_1}) & = \sum_{i=1}^{log_2(n)}(2^i-2)\times \binom{log_2(n)}{i} \\
& = \sum_{i=1}^{log_2(n)} 2^i\binom{log_2(n)}{i} -2\sum_{i=1}^{log_2(n)}\binom{log_2(n)}{i}\label{Equ: complexity}.
\end{align}
From the binomial theorem,
\begin{equation}
\sum_{i=1}^{log_2(n)} 2^i\binom{log_2(n)}{i} = (1+2)^{log_2(n)}-1 = 3^{log_2(n)}-1,
\end{equation}
and
\begin{equation}
\sum_{i=1}^{log_2(n)}\binom{log_2(n)}{i} = 2^{log_2(n)}-1.
\end{equation}
Therefore, Eq.~\eqref{Equ: complexity} can be written as
\begin{equation}
\bigcup_i T( \mathcal{D}_{i|c_1}) = n^{log_23} - 2n+1.
\end{equation}
In addition to the above operations, there exists an initial sorting of the probabilities that can be implemented based on merge sort with the complexity of $\mathcal{O}(n(\log_2n))$, and a sorting process in each stage for the nodes in $\mathcal{H}_2$. For the latter, the complexity can be written as
\begin{align}
&\sum_{i=1}^{log_2(n)} \mathcal{O}(\binom{log_2(n)}{i}\times \log_2(\binom{log_2(n)}{i})) = \\
& \sum_{i=1}^{log_2(n)} \mathcal{O}(
\log_2\binom{log_2(n)}{i}^{\binom{log_2(n)}{i}})\leq \\
& \sum_{i=1}^{log_2(n)} \mathcal{O}(
\log_2 n^{\binom{log_2(n)}{i}})\leq \\
& \mathcal{O}(
\log_2 n^{\sum_{i=1}^{log_2(n)}\binom{log_2(n)}{i}}) = \mathcal{O}(n(\log_2n))
\end{align}
Therefore, accounting for sorting, the closed-form expression for the total complexity is $\mathcal{O}(2n(\log_2n)) + n^{log_23} - 2n+1$.
The MSGO algorithm is based on executing the GO algorithm with shorter depths in a cluster based approach. Suppose that the depth is set to $r$ where $r\leq log_2n$. Running the algorithm in each cluster with similar logic as the GO requires the following number of operations.
\begin{equation}
\sum_{i=1}^{r} (2^i-2)\binom{log_2(n)}{i}.
\end{equation}
On the other hand, the total number of clusters is approximately
\begin{equation}
\# clusters \approx n/ \sum_{i=1}^{r} \binom{log_2(n)}{i}.
\end{equation}
Therefore, the total complexity considering the initial sorting algorithm is calculated as
\begin{equation}\label{Equ: approximate}
\begin{split}
\mathcal{O}(n(\log_2n))&+\\ (\sum_{i=1}^{r} &(2^i-2)\binom{log_2(n)}{i})\times (n/ \sum_{i=1}^{r} \binom{log_2(n)}{i}).
\end{split}
\end{equation}
Defining the binary entropy function as
\begin{equation}
H_2(x) = x \log_2(\dfrac{1}{x})+ (1-x)log(\dfrac{1}{1-x}),
\end{equation}
the following approximation can be used for deriving closed-form expression for various cluster sizes in Eq.~\eqref{Equ: approximate}
\begin{equation}
\binom{n}{i} \simeq 2^{nH_2(r/n)}.
\end{equation}
Lastly, the SGO algorithm executes the GO algorithm with the depth of one and has the computational complexity of $\mathcal{O}(n(\log_2n))$. The low computational complexity of SGO makes it a suitable option for the encoding of grids with higher levels of granularity.
\section{Supporting Dynamic Alert Zones}\label{Advance Modeling of Alert Zones}
So far, we considered the case of static alert zones, and we optimized the data encoding and token generation under this scenario. However, in practice, alert zones vary over time. Whether an alert corresponds to a natural phenomenon (e.g., gas leak) or a human activity (e.g., COVID carrier movement), alert zones exhibit spatio-temporal patterns that must be accounted for in order to obtain fast performance.
We maintain the grid-based partition of the spatial domain used for the static case, and we denote by {\em state} of the grid the set of all alert cells at a given time. The occurrence probability of a state can be modeled analytically and used as a basis for grid encoding. The higher the statistical model accuracy, the more precise the encoding becomes, reducing HVE operations overhead.
Next, we build a comprehensive statistical model to characterize alert zone evolution in space and time.
\begin{defn}(State Space).\label{Definition: State Space}
For a given grid $$\mathcal{V}=\{ v_1,\,,v_2,..., v_{n} \},$$ let $X$ be a random variable defined on all possible subsets of the cells. The state space of $X$ is defined as the power set $\mathcal{S}_n=\{\textbf{\underline{1}}, \textbf{\underline{2}},...,\textbf{\underline{$2^n$}}\}$.
\end{defn}
The {\em cardinality} of a state $\textbf{\underline{i}}$ represents the number of cells included in the state and is denoted by $|\textbf{\underline{i}}|$. The set of all states with the cardinality of $j$ are denoted by $\mathcal{S}^{|j|}_n$. Note that, the notation is not concerned with a precise order of states. For example, a grid with two cells $\{ v_1, v_2\}$ leads to the state space of
\noindent
$\mathcal{S}_2 = \{\{\emptyset\},\{v_1\},\{v_2\}, \{v_1,v_2\}\}$, which is depicted by $\mathcal{S}_2=\{\textbf{\underline{1}}, \textbf{\underline{2}},\textbf{\underline{3}},\textbf{\underline{4}}\}$; however, the order of states is not captured by the notation. Two examples of such an assignment can be $\{\textbf{\underline{1}} = \{\emptyset\}, \textbf{\underline{2}} = \{v_1\},\textbf{\underline{3}} = \{v_2\},\textbf{\underline{4}} = \{v_1,v_2\} \}$, and $\{\textbf{\underline{1}} = \{ \{v_1,v_2\} \}, \textbf{\underline{2}} = \{v_2\},\textbf{\underline{3}} = \{v_1\},\textbf{\underline{4}} = \emptyset \}$. We provide more details on the construction of the state space and ordering in Section~\ref{subsection: Recursive Construction}.
\begin{comment}
\begin{figure*}[h!]
\subfloat[x = 0.01]{%
\includegraphics[scale=.6]{Figures/ThrreeDx01.png}
}
\hfill
\subfloat[x = 0.1]{%
\includegraphics[scale=.6]{Figures/ThrreeDx1.png}
}
\hfill
\centering
\subfloat[x = 0.5]{%
\includegraphics[ scale=.6]{Figures/ThrreeDx05.png}
}
\caption{Sigmoid function with variable a, b, and x.}
\label{dist}
\end{figure*}
\end{comment}
Let $X_0, X_1,...,X_i,...$ denote the sequence of random variables modeling the occurrence of alert zones. The set of possible values for $X_i$ is the state space of the grid, and the index $i$ denotes the evolution of the process in time. The probability of $X_i$ being in a particular state $\textbf{\underline{j}}$ is denoted as $p(X_i = \textbf{\underline{j}})$. The probability of a cell becoming part of an alert zone depends on underlying phenomena properties, existing correlations among cells, and the history of alert zones on the map. Moreover, probabilities do not remain constant over time. We identify several distinct scenarios, and we create a statistical model for each: (i) the states are independent in both space and time; (ii) the states are independent in space, but dependent in time (i.e., temporal causality); (iii) the states are independent in time but exhibit space correlation (i.e., spatial causality); and (iv) the states are dependent in both time and space. The first case corresponds to the static case introduced in the previous sections; the last case is the most general one, whereas cases (ii) and (iii) are special cases of (iv). Each case may be relevant under different types of applications and data domains. Next, we investigate in details each of the cases, and propose a data encoding and token generation technique for each. Our goal is to obtain an accurate representation of how the probabilities $X_i$ are distributed over the state space.
\subsection{Independence in Time and Space}\label{Sect: Independence in Time and Space}
Having the independence assumption in space and time greatly simplifies the problem formulation as the sequence of random variables $X_0, X_1,...,X_i,...$ become a sequence of independent and identically distributed (iid) random variables defined over the state space. Such modeling indicates that the random variables $X_1$ to $X_i$ provide no information about the random variable $X_{i+1}$. Therefore, the {\em probability mass function (PMF}) of $X_i$ depends on the probabilities of individual cells. For a given $X_i$, the probability of cell $v_i\in \mathcal{V}$ becoming part of the alert zone is denoted by $p(v_i)$, and corresponds to a value between zero and one. The mutual probability of a subset of cells $\mathcal{L} = \{ v_1,\,,v_2,..., v_{i} \}$ being in an alert zone can be calculated as
\begin{equation}
p(\mathcal{L}) = \prod_{j=1}^{i} p(v_j).
\end{equation}
The calculation of mutual probabilities is the direct result of the independence assumption, which indicates that there are no correlations between cells.
\subsection{Independence in Space, Dependence in Time}\label{Sec: Independence in Space, Dependence in Time}
In this case, the grid state no longer consists of iid random variables following the same PMFs. The probability of state $\textbf{\underline{i}}$ at time $j$ is no longer assumed to be equal to the probability of being in state $\textbf{\underline{i}}$ at a different time $k$, i.e., $p(X_j = \textbf{\underline{i}}) \neq p(X_k = \textbf{\underline{i}})$. Our objective is to determine whether the system reaches a steady state in which the probabilities no longer change significantly over time. We model the evolution of alert cells over time using Markov chains.
We assume that alert zones evolve incrementally by addition or removal of a single cell at a time (this can always be achieved by properly choosing the time granularity).
The proposed model is represented in Fig~\ref{fig:markov model}. States $\textbf{\underline{i}}$ and $\textbf{\underline{j}}$ are connected if and only if the difference between their cardinality is one, $|\textbf{\underline{i}}-\textbf{\underline{j}}|=1$. The only exception is the state including all cells (if all cells are within the alert zone, then all have the same status). The model assumes that each state depends only on the previous state, and therefore, it follows Markov chain properties, i.e., for all $k\geq 0$,
\begin{equation}
\begin{split}
p(X_{k+1}=\textbf{\underline{j}}|X_k =\textbf{\underline{i}},X_{k-1}=\textbf{\underline{i}}_{k-1}&,...,X_0 =\textbf{\underline{i}}_0 )\\&
= p(X_{k+1}=\textbf{\underline{j}}|X_k =\textbf{\underline{i}}).
\end{split}
\end{equation}
The forward propagation to a state with a higher cardinality indicates the addition of an alert cell, whereas forward propagation to a state with a lower cardinality indicates the removal of an alert cell.
The value of $p(X_{k+1}=\textbf{\underline{j}}|X_k =\textbf{\underline{i}})$ is called the {\em transition probability} from state $\textbf{\underline{i}}$ to state $\textbf{\underline{j}}$ and we implicitly make the assumption that the transition probabilities are homogeneous over time. We are interested in understanding what the likelihood of being in a state is starting from any other state, and whether the chain reaches a {\em stationary distribution} in which the probabilities of individual states do not change over time.
First, we review three properties of the proposed Markov chain:
\begin{prop}\label{recurrency}
All states in the proposed model are recurrent. Therefore, starting from any state of the chain, it is possible to reach any other state, eventually.
\end{prop}
\begin{prop}\label{irreducable}
The proposed Markov chain is irreducible, as for any two states $\textbf{\underline{i}}$ and \textbf{\underline{j}}, it is possible to reach one from the other in a finite number of steps.
\end{prop}
\begin{prop}\label{periodic}
The proposed Markov chain for modeling alert zones is aperiodic, as the period of states is equal to one.
\end{prop}
The above properties help to characterize the long-term behaviour of the Markov chain. If after a certain period of time the {\em transition matrix} of the chain reaches a stationary distribution, it enables us to know the probability of each state in the state space. The state {\em transition matrix} is defined as follows:
\begin{figure}[t]
\centering
\includegraphics[scale=.5]{Figures/MarkovModel2.png}
\hspace{1em}
\centering
\caption{Proposed Markov model for alert zone evolution.}
\label{fig:markov model}
\end{figure}
\begin{defn}(Transition matrix).\label{Markov Chain}
For a Markov chain $X_0, X_1,...,X_i,...$ with a state space $\mathcal{S}_n=\{\textbf{\underline{1}}, \textbf{\underline{2}},...,\textbf{\underline{$2^n$}}\}$, let $q_{ij} =p(X_{k+1}=\textbf{\underline{j}}|X_k =\textbf{\underline{i}})$ be the transition probability from state $\textbf{\underline{i}}$ to state $\textbf{\underline{j}}$. The $2^n \times 2^n$ matrix $Q_n = (q_{ij})$ is called the transition matrix of the chain. The value of $q_{ij}$ for $i<2^n$ is defined as $p(v)$, where $v$ is the alert cell which exists in state $\textbf{\underline{i}}$ (row) and does not exist in state $\textbf{\underline{j}}$ (column).
\end{defn}
Recall that two states are connected if and only if their cardinality differs by one. The last row of the matrix represents the only outgoing directed edge from the state with the cardinality of $n$ to the state with cardinality of zero. Thus, the first element of the last row is one ($q_{2^n1}=1$) and all its other elements are zero. Such a row ensures the aperiodicity of the chain.
It can be inferred that the $i^{th}$ row of the transition matrix corresponds to outgoing edges from the state $\textbf{\underline{i}}$ of the Markov chain. Therefore, in order for the matrix to maintain the Markovian properties, the values in each row should sum up to one, which is indeed the case for the proposed transition matrix. This property is termed as {\em Markovian matrix property}. Let a row vector $\boldsymbol{t} = [t_1,t_2,...,t_{2^n}]$ be the PMF of $X_0$, where $t_i=p(X_0 = \textbf{\underline{i}})$. Then, based on the properties of Markovian chains, the marginal distribution of $X_m$ is given by the $j^{th}$ component of $\boldsymbol{t}Q_n^m$, i.e., $p(X_n= \textbf{\underline{j}})$. The marginal distribution indicates that given a initial state $\textbf{\underline{i}}$, the probability of being in state \textbf{\underline{j}} after $m$ transitions is the $j^{th}$ component of the vector $\boldsymbol{t}Q_n^m$. We are interested in the long run behaviour of the system and to understand if the proposed model will reach a {\em stationary distribution}.
\begin{defn}(Stationary distribution).\label{Dfn: stationary distribution}
Given a Markov chain with the transition matrix $Q_n$, a row vector $\boldsymbol{s} = [s_1,...,s_{2^n}]$, such that $s_i\geq 0$ and $\sum_i s_i = 1 $, is a stationary distribution if \begin{equation}\label{equ: stationary distribution}
\boldsymbol{s}Q_n=\boldsymbol{s}
\end{equation}
\end{defn}
We elaborate further on the meaning of the vector $\boldsymbol{s}$. Suppose that the $i^{th}$ element of the vector corresponds to the state $\textbf{\underline{i}}$. If the proposed Markov chain reaches a stationary distribution, this value represents probability $p(X_n= \textbf{\underline{i}})$ for any $n$ after reaching the stationary distribution. Thus, the importance of each state is revealed by its corresponding value in $\boldsymbol{s}$.
\begin{exmp}\label{example: transition matrix}
Consider a map with two cells $v_1$ and $v_2$, where $p(v_1) = 0.2$ and $p(v_2) = 0.8$. The state space includes four states $\{\{\emptyset\},\{v_1\}\,\{v_2\}\,\{v_1,v_2\}\}$, and the transition matrix is calculated as
\begin{equation}\nonumber
Q_2=
\begin{bmatrix}
0 & 0.2 & 0.8 & 0\\
0.2 & 0 & 0 & 0.8\\
0.8 & 0 & 0 & 0.2\\
1 & 0 & 0 & 0
\end{bmatrix},
\end{equation}
Solving Eq.~\eqref{equ: stationary distribution} for the matrix $Q_2$ results in the eigen vector $\boldsymbol{s} = [0.4310,\, 0.0862,\, 0.3448 ,\, 0.1379]$. Hence, the probability of states are $p(\{\emptyset\}) = 0.4310$, $p(\{v_1\}) = 0.0862$, $p(\{v_2\}) = 0.3448$, $p(\{v_1,\, v_2\}) = 0.1379$.
\end{exmp}
There are three important questions to be answered about the stationary distribution: (a) {\em does it exist?} (b) {
\em is it unique?} and (c) {\em does the Markov chain converge to the stationary distribution?}
The stationary distribution is the left eigenvector of the transition matrix corresponding to the eigenvector of one as shown by Eq.~\eqref{equ: stationary distribution}. The existence and uniqueness of a stationary distribution for the proposed Markov model is proven in the following theorem.
\begin{thm}
There exists a unique stationary distribution for the proposed Markov chain to model alert zones.
\end{thm}
\begin{proof}
According to~\cite{blitzstein2019introduction}, a stationary distribution exists for any finite-state Markov chain, and if the chain is irreducible, the solution is unique. Based on property~\ref{irreducable}, there exists a unique stationary distribution for the model. Later in Section~\ref{subsection: Recursive Construction}, we present the recursive construction of matrix $Q_n$ and show that the cardinality of the null space of the matrix $\boldsymbol{s}(Q_n-I)$ is one.
\end{proof}
The above theorem shows that there exists a unique stationary distribution for the proposed Markov model regardless of the initial probabilities of the cells; however, to reach the stationary distribution, the chain needs to be aperiodic as well as irreducible. Based on Property~\ref{periodic}, the proposed model is aperiodic. However, particular initial probabilities, including zero values, can result in periodic chains. To address this problem, we adopt a similar approach as the PageRank algorithm~\cite{sarma2013fast}, used to rank the relevance of webpages. Suppose that before moving to a new state on the chain, a coin is tossed with probability $\alpha$ of heads. If the result of the coin toss is heads, the state evolves using the transition matrix $Q$; otherwise, the system jumps to a state in a uniformly random distribution. The resulting transition matrix is represented as:
\begin{equation}
O_n = \alpha Q + (1-\alpha)\dfrac{J_n}{2^n},
\end{equation}
where $J_n$ is a $2^n \times 2^n$ matrix of all ones. The recommended value~\cite{sarma2013fast} of $\alpha$ is $0.85$. It can be observed that all elements of $O_n$ are positive, and therefore, the aperiodicity of the chain is guaranteed. Hence, solving Eq.~\eqref{equ: stationary distribution} for $O_n$ has a solution leading to a stationary distribution ($\boldsymbol{s}$) as well as converging to the stationary distribution. Similarly, the $i^{th}$ element of the vector $\boldsymbol{s}$ for the new transition matrix $O_n$ indicates the significance of state $\textbf{\underline{i}}$, as it represents $p(X_m= \textbf{\underline{i}})$ for any large value of $m$. In the following, we consider that the transition matrix is aperiodic, and we use the matrix $Q_n$ as our reference.
\begin{exmp}\label{example: Google transition matrix}
Going back to Example~\ref{example: transition matrix}, the transition matrix is derived as
\begin{equation}\nonumber
O_2=
\begin{bmatrix}
0.0375 & 0.2075 & 0.7175 & 0.0375\\
0.2075 & 0.0375 & 0.0375 & 0.7175\\
0.7175 & 0.0375 & 0.0375 & 0.2075\\
0.8875 & 0.0375 & 0.0375 & 0.0375
\end{bmatrix}.
\end{equation}
Solving Eq.~\eqref{equ: stationary distribution} for the matrix $O$ results in the eigenvector of $\boldsymbol{s} = [0.4111,\, 0.1074,\, 0.3171,\, 0.1644]$. Hence, the new probability of states are $p(\{\emptyset\}) = 0.4111$, $p(\{v_1\}) = 0.1074$, $p(\{v_2\}) = 0.3171$, $p(\{v_1,\, v_2\}) = 0.1644$. One can check the convergence by choosing a large enough value of $m$ and calculating $tO_2^m$ starting by an arbitrary PMF on $t$. As an example, if the vector $\boldsymbol{t} = [0.25, 0.25,0.25,0.25]$, then $\boldsymbol{t}O_2^{50}$ will result in $$[0.4111,\, 0.1074,\, 0.3171,\, 0.1644]$$ which is the stationary distribution vector~$\boldsymbol{s}$.
\end{exmp}
\subsection{Dependence in both space and time}
In this section, we study how to capture correlation among alert cells over time by incorporating spatial distance between cells within the Markov model. We embed spatial correlations in the transition matrix while maintaining Markovian properties, and thus the long-term behaviour of the model can be better defined. We use as starting point the proposed model from Fig.~\ref{fig:markov model}.
Consider a grid with two cells $\{ v_1, v_2\}$ and the state space of $\mathcal{S}_2 = \{\textbf{\underline{1}} = \{\emptyset\}, \textbf{\underline{2}} = \{v_1\},\textbf{\underline{3}} = \{v_2\},\textbf{\underline{4}} = \{v_1,v_2\} \}$. The matrix $Q_2$ is derived as
\begin{equation}\nonumber
Q_2=
\begin{bmatrix}
0 & p(\{v_1\}) & p(\{v_2\}) & 0\\
p(\{v_1\}) & 0 & 0 & p(\{v_2\})\\
p(\{v_2\}) & 0 & 0 & p(\{v_1\})\\
1 & 0 & 0 & 0
\end{bmatrix}.
\end{equation}
Investigating the transition matrix closely, one can see the impact of independence between cells in the matrix. Consider the entry $Q_2(2,4)$ as an example. This entry indicates the probability of going from state $ \textbf{\underline{2}} = \{v_1\}$ to state $\textbf{\underline{4}} = \{v_1,v_2\}$ is $p(\{v_2\})$. In other words, the transition captures the fact that the existence of another alert zone cell $v_1$ did not impact the cell $v_2$ (i.e., spatial independence between cells). More formally, from the {\em Bayes rule}:
\begin{equation}
p(\{v_1,v_2\}) = p(v_2| v_1)p(v_1) \rightarrow p(\{v_1,v_2\}) = p(v_2)p(v_1),
\end{equation}
given that
\begin{equation}
p(v_2| v_1) = p(v_2).
\end{equation}
In Section~\ref{Sec: Independence in Space, Dependence in Time}, we assumed independence between states. To address this issue, we propose the following method to capture the correlations between states without eliminating the Markov property of the matrix $Q_n$. The main idea behind the approach is that cells that are in close proximity to the alert zone are more likely to become part of the zone in the future.
Let $X_0, X_1,...,X_i,...$ be an order one Markov sequence of random variables modeling the occurrence of the alert zones, where $X_i$'s are defined over the state space of the grid. Without loss of generality assume that the $j'^{th}$ row of the matrix $Q$ corresponds to the state $\{v_1,v_2,...,v_j \}$. Based on the proposed Markov model in Fig.~\ref{fig:markov model}, it is known that this state can evolve by the addition or removal of a single alert cell. Therefore, there exist $n$ non-zero elements in each row of the matrix. For all $v_k \in \mathcal{V}$, we calculate the probability of its removal or addition as:
\begin{equation*}
\begin{aligned}
\textrm{If}\, v_k \notin &\{v_1,v_2,...,v_j \}\, \textrm{then};\\
& p(\{v_k\}\cup \{v_1,v_2,...,v_j \}) = p(v_k)/(d(v_k,c))\times \beta\\
\textrm{If}\, v_k \in &\{v_1,v_2,...,v_j \}\, \textrm{then};\\
& p( \{v_1,v_2,...,v_j \} -\{v_k\} ) = p(v_k)/(d(v_k,c))\times \beta,
\end{aligned}
\end{equation*}
where the function $d(.)$ returns the Euclidean distance between two points, $\beta$ is a normalization factor over the entire row, and the point $c$ is the centre point of $\{v_1,v_2,...,v_j \}$, calculated as
\begin{equation}
c = (\sum_{i=1}^j v_j)/j.
\end{equation}
Note that, in all above calculations, each cell's center point is used as its representative. The intuition behind the approach is that the correlation between cells becomes smaller as we go further away from the alert zone. The only special case is when there exists a single-cell alert zone, and we seek the probability of its removal. In this case $d(v_k,c)$ becomes close to zero and $p(v_k)/(d(v_k,c))$ tends to go to infinity. As there exist no other alert zone cell for this case, we consider this probability as $p(v_k)$ instead of $p(v_k)/(d(v_k,c))$ to avoid inaccuracies. As an example, consider a grid with three cells $\{ v_1, v_2, v_3\}$ and the average point $c$. Suppose that the $j^{th}$ row of the matrix $Q_3$ corresponds to the state $\{ v_1, v_2\}$. In this row, there exist three nonzero elements:
\begin{equation}
\begin{aligned}
& p(\{ v_1\})= p(v_2)/(d(v_2,c) ) \times \beta\\
&p(\{ v_2\}) = p(v_1)/(d(v_1,c)\times \beta\\
&p(\{ v_1, v_2, v_3\}) = p(v_3/(d(v_3,c))\times \beta, \textrm{where}\\
&\beta = 1/(p(v_2)/(d(v_2,c) ) + p(v_1)/d(v_1,c) + p(v_3/d(v_3,c)))
\end{aligned}
\end{equation}
The proposed method satisfies the Markovian matrix property. Hence, it can be used as part of the Markov model in Section~\ref{Sec: Independence in Space, Dependence in Time} to capture the long-term behavior of the system.
\subsection{Recursive Construction and Monte Carlo Sampling}\label{subsection: Recursive Construction}
Finding the eigenvector of matrix $Q_n$ corresponding to eigenvalue one is necessary to determine the probability of being in a particular state at a given time $p(X_n= \textbf{\underline{i}})$. The eigenvector provides valuable information that enables us to prioritize more likely states in the grid encoding process. However, there are two important issues with its calculation: {
em (i)} The matrix $Q_n$ has dimensions of $2^{n}\times 2^{n}$. Even considering a small grid with 100 cells, it requires an extremely large storage capacity. {\em (ii)} The calculation of the eigenvector for such a large matrix is expensive, with $\mathcal{O}(n^3)$~\cite{press1988numerical} complexity. For example, based on Householder transformations, eigenvalues and eigenvectors can be calculated with complexity $\mathcal{O}(n^2) + 4n^3/3$. To address the high computational overhead, we approximate the stationary distribution based on random walks on the Markov model.
We start by explaining the recursive construction of the matrix $Q_n$. The rows and columns of the matrix depend on the order in which states are chosen. We propose to construct the states of the $n+1$ cells, $v_1$ to $v_{n+1}$, from the grid with $n$ cells, $v_1$ to $v_n$ as follows:
\begin{align}
&\mathcal{S}_2 = \{\{\emptyset\},\{v_1\},\{v_2\}, \{v_1,v_2\}\},\\
&\mathcal{S}_{n+1} = \{\mathcal{S}_n ,\, \mathcal{S}_{n}\bigcup v_{n+1}\}.
\end{align}
For instance, $\mathcal{S}_3$ is constructed as
\begin{equation}
\begin{split}
\mathcal{S}_3 = \{\{\emptyset\},\{v_1\},\{v_2\}&,\{v_1,v_2\},\\
&\{v_3\},\{v_1,v_3\},\{v_2,v_3\}, \{v_1,v_2,v_3\}\},
\end{split}
\end{equation}
The matrix $Q_{n+1}$ can be constructed recursively as
\begin{equation}
Q_n=
\begin{bmatrix}
W_{n-1} & p(v_n)I_{2^{n-1}} \\
p(v_n)I_{2^{n-1}}& W_{n-1}
\end{bmatrix}
-W_n(2^n,:) + K_{2^n},
\end{equation}
where $I_{2^{n}}$ is the identity matrix and $K_{2^n}$ is an all-zero $2^n\times 2^n$ matrix except for element $K_{2^n}(2^n,0) = 1$, and
\begin{equation}
W_n=
\begin{bmatrix}
W_{n-1} & p(v_n)I_{2^{n-1}} \\
p(v_n)I_{2^{n-1}}& W_{n-1}
\end{bmatrix}
\end{equation}
\noindent given that
\begin{equation}\nonumber
W_2=
\begin{bmatrix}
0 & p(v_1) & p(v_2) & 0\\
p(v_1) & 0 & 0 & p(v_2)\\
p(v_2) & 0 & 0 & p(v_1)\\
0 & p(v_2) & p(v_1) & 0
\end{bmatrix}.
\end{equation}
The above representation of $Q_n$ works under the spatial independence assumption, but the construction of states holds regardless of that assumption.
To tackle the high computational complexity of determining eigenvectors, we use a probabilistic approach. PageRank's approach~\cite{sarma2013fast} to this problem is incorporating the power iteration method to calculate the eigenvectors, but still incurs a high computational complexity. An alternative approach is the Monte Carlo approximation, which is widely used in literature and results in an enhanced estimation of the stationary distribution. The Monte Carlo method provides several advantages over deterministic power iteration methods such as significantly lower computation complexity, opportunities for parallel implementation, and it facilitates updating of probabilities.
The main idea behind the Monte Carlo approximation is to start $R$ random walks on the Markov model's primary node, i.e., state $\textbf{\underline{1}}$. Each random walk terminates with the probability of $1-c$ and makes a transition to the next outgoing node with the PMF specified in the transition matrix $Q_n$. The fraction of walks ending at a state over all the random walks indicates the probability or significance of that state. The vector of calculated probabilities for all states is the approximation of stationary distribution. The number of samples required to estimate the stationary distribution is shown to pessimistically be in the order $\mathcal{O}(n^2)$, where $n$ indicates the number of states; however, it is shown that $n$ random walks are enough to provide a reasonable approximation of a stationary distribution~\cite{avrachenkov2007monte}.
\section{Experimental Evaluation}
\begin{figure*}[!ht]
\subfloat[a=0.75, b=10.\label{F11}]{%
\includegraphics[scale=.53]{Figures/F11.png}
}
\hfill
\subfloat[a=0.75, b=10.\label{F12}]{%
\includegraphics[scale=.53]{Figures/F12.png}
}
\hfill
\subfloat[a=0.75, b=10. \label{F13}.]{%
\includegraphics[scale=.53]{Figures/F13.png}
}
\hfill
\subfloat[a=0.75, b=30. \label{F21}]{%
\includegraphics[scale=.53]{Figures/F21.png}
}
\hfill
\subfloat[a=0.75, b=30. \label{F22}]{%
\includegraphics[scale=.53]{Figures/F22.png}
}
\hfill
\subfloat[a=0.75, b=30.\label{F23}]{%
\includegraphics[scale=.53]{Figures/F23.png}
}
\hfill
\subfloat[a=0.5, b=10 (baseline performance).\label{F31}]{%
\includegraphics[scale=.53]{Figures/F31.png}
}
\hfill
\subfloat[a=0.5, b=10. \label{F32}]{%
\includegraphics[scale=.53]{Figures/F32.png}
}
\hfill
\subfloat[a=0.5, b=10. \label{F33}]{%
\includegraphics[scale=.53]{Figures/F33.png}
}
\caption{Evaluation of GO, grid size = 100 cells.}
\label{Fig_GrayOptimizer}
\end{figure*}
\subsection{Experimental Setup}\label{Initial Cell Probabilities}
We conduct our experiments on a $3.40$GHz core-i7 Intel processor with 8GB RAM running $64$-bit Windows $7$ OS. The code is implemented in Python, and we used the LogicMin Library~\cite{Minimization} for binary minimization of token expressions. We compare the proposed approaches (GO, MGSO and SGO) against the hierarchical Gray encoding technique from~\cite{ghinita2014efficient} (labeled {\em HGE}), the state-of-the-art in location alerts on HVE-encrypted data.
To model the probability of partition cells becoming alert zones, we use the sigmoid function $\mathcal{S}(x)= 1/(1+\exp^{-b(x-a)})$, where $a$ and $b$ are parameters controlling the function shape. The output value is between zero and one. The sigmoid function is a frequent model used in machine learning, and we chose it because in practice, the probability of individual cells becoming part of an alert zone can be computed using such a model built on a regions' map of features (e.g., type of terrain, building designation, point-of-sale information, etc).
Parameter $a$ of the sigmoid controls the \textit{inflection} point of the curve, whereas $b$ controls the gradient.
\subsection{Gray Optimizer Evaluation}
GO is our core proposed algorithm to reduce the number of HVE operations required to support alert zones. Specifically, by \textit{HVE operations} we refer to the computation executed by the server to determine matches between tokens and encrypted user locations. Recall that, for each non-star item in a token, a number of expensive bilinear map operations are required. GO aims to minimize the number such non-star items in tokens by choosing an appropriate encoding of the domain.
Our comparison benchmark is the approach from~\cite{ghinita2014efficient} which uses a hierarchical quadtree structure to partition the data domain. We refer to this approach as \textit{HGE}, and we present our result as an improvement in terms of computation overhead compared with~\cite{ghinita2014efficient}.
\subsubsection{Improvement in HVE Operations}
Fig~\ref{Fig_GrayOptimizer} summarizes the evaluation results of GO for three logistic function parameter settings. The grid size is set to $100$ cells (recall from our earlier discussion that GO can only support relatively low granularities). Fig.~\ref{Fig_GrayOptimizer} shows the total number of bilinear pairings performed for a ciphertext-token pair. GO clearly outperforms the approach from~\cite{ghinita2014efficient}. The relative gain in performance of GO increases when the size of the alert zone increases (i.e., when there are more grid cells covered by the alert zone). This can be explained by the fact that a larger input set gives GO more flexibility to optimize the encoding and decrease the number of non-star entries in a token. In terms of percentage gains, GO can improve performance by up to 40\%, which is quite significant. Also, note that the gains are significant for all parameters of the sigmoid function used. In general, we identified that a higher $a$ value leads to more pronounced gains. This is an encouraging factor, because a higher $a$ corresponds to a more skewed probability case, where a relatively small number of cells are more likely to be included in an alert zone than others. In practice, one would expect that to be the case, since events that trigger alerts also tend to be concentrated over a relatively small area (e.g., very popular hotspots, certain facilities that present higher risks, like a chemical plant, etc.).
\begin{figure}[t]
\centering
\includegraphics[scale=.5]{Figures/F2.png}
\hspace{1em}
\centering
\caption{Performance evaluation of GO for varying depth (100 cells).}
\label{fig2}
\end{figure}
\begin{figure}[!t]
\subfloat[Gray Optimizer. \label{fig4a}]{%
\includegraphics[scale=.41]{Figures/F4_a.png}
}
\hfill
\subfloat[MSGO.\label{fig4b}]{%
\includegraphics[scale=.41]{Figures/F4_b.png}
}
\hfill
\centering
\subfloat[SGO.\label{fig4c}]{%
\includegraphics[height=2.6cm, scale=.41]{Figures/F4_c.png}
}
\vspace{-10pt}
\caption{Execution time.}
\label{fig4}
\end{figure}
\subsubsection{Impact of Depth}
Recall that the reduction in computation achieved by GO depends on the depth at which the algorithm is run (GO works similar to a depth-first search graph algorithm).
In general, running the algorithm with a higher depth will produce better results in terms of performance gain at runtime (i.e., when matching is performed at the server), but it also requires a lot more computational time to compute a good encoding (which is a one-time cost). Fig.~\ref{fig2} captures the impact of depth on improvement. In this experiment, GO is executed on a single cell with different depths, and the remaining cells are assigned randomly (the experiment is specifically designed to show the effect of using lower depths on GO).
As expected, there is a clear increasing trend, with higher depths resulting in better improvement factors. However, after a sharp initial gain (illustrated by the large distance between the chart graphs corresponding to depths 2 and 3), the improvement stabilizes, and it may no longer be worth increasing the depth of the computation considerably (the gains are stabilizing between depths 3 and 4).
\subsubsection{Execution Time}
Fig.~\ref{fig4a} illustrates the execution time of GO. Recall that, the execution time of GO is influenced by the granularity of the grid (finer granularities increase execution time). The results show that GO can complete within a short execution time for smaller grid sizes; however, as the grid granularity increases, there is a sharp increase in execution time. Therefore, GO may not be practical to apply for high granularity grids, and that is the main motivation behind our two variations, MSGO and SGO (which are evaluated next). Moreover, as the grid granularity increases, the length of cycles becomes larger, which will also result in numerical inaccuracies when executing GO. The execution time required by GO for values up to 600 cells is around 10 seconds. We observed that this value is the maximum number of cells for which GO performs reasonably; beyond this level, the algorithm is not suitable due to increased execution time and numerical inaccuracies associated with the calculation of probabilities for large cycles.
\begin{figure*}[!ht]
\subfloat[a=0.75, b=10.\label{F5_11}]{%
\includegraphics[scale=.53]{Figures/F5_11.png}
}
\hfill
\subfloat[a=0.75, b=10.\label{F5_12}]{%
\includegraphics[scale=.53]{Figures/F5_12.png}
}
\hfill
\subfloat[a=0.75, b=10. \label{F5_13}]{%
\includegraphics[scale=.53]{Figures/F5_13.png}
}
\hfill
\subfloat[a=0.75, b=30. \label{F5_21}]{%
\includegraphics[scale=.53]{Figures/F5_21.png}
}
\hfill
\subfloat[a=0.75, b=30. \label{F5_22}]{%
\includegraphics[scale=.53]{Figures/F5_22.png}
}
\hfill
\subfloat[a=0.75, b=30.\label{F5_23}]{%
\includegraphics[scale=.53]{Figures/F5_23.png}
}
\hfill
\subfloat[a=0.5, b=10.\label{F5_31}]{%
\includegraphics[scale=.53]{Figures/F5_31.png}
}
\hfill
\subfloat[a=0.5, b=10. \label{F5_32}]{%
\includegraphics[scale=.53]{Figures/F5_32.png}
}
\hfill
\subfloat[a=0.5, b=10. \label{F5_33}]{%
\includegraphics[scale=.53]{Figures/F5_33.png}
}
\caption{Performance evaluation of MSGO (grid size = 1024 cells).}
\label{fig_MSGO}
\end{figure*}
\subsection{Evaluation of GO Variations on Higher Granularity Grids}
As discussed previously, GO does not perform well when directly applied to high granularity grids.
To improve the computational complexity of GO, we proposed two extensions of the algorithm, namely, MSGO and SGO. Next, we evaluate experimentally both these variations
\subsubsection{MSGO}
\begin{figure*}[t]
\subfloat[Grid size=10000 ]{%
\includegraphics[scale=.57]{Figures/F3_a.png}
}
\hfill
\subfloat[Grid size=28900]{%
\includegraphics[scale=.57]{Figures/F3_c.png}
}
\hfill
\subfloat[Grid size=50625]{%
\includegraphics[scale=.57]{Figures/F3_e.png}
}
\vspace{-10pt}
\hfill
\subfloat[Grid size=10000 ]{%
\includegraphics[scale=.57]{Figures/F3_b.png}
}
\hfill
\subfloat[Grid size=28900]{%
\includegraphics[scale=.57]{Figures/F3_d.png}
}
\hfill
\subfloat[Grid size=50625]{%
\includegraphics[scale=.57]{Figures/F3_f.png}
}
\caption{SGO performance evaluation, varying grid size.}
\label{fig6}
\end{figure*}
\begin{figure*}[h!]
\subfloat[GO]{%
\includegraphics[scale=.57]{Figures/varSize_HVE_GO.png}
}
\hfill
\subfloat[MSGO, depth=4 ]{%
\includegraphics[scale=.57]{Figures/varSize_HVE_MSGO.png}
}
\hfill
\subfloat[SGO]{%
\includegraphics[scale=.57]{Figures/varSize_HVE_SGO.png}
}
\hfill
\subfloat[GO]{%
\includegraphics[scale=.57]{Figures/varSize_improvement_GO.png}
}
\hfill
\subfloat[MSGO, depth=4]{%
\includegraphics[scale=.57]{Figures/varSize_improvement_MSGO.png}
}
\hfill
\subfloat[SGO]{%
\includegraphics[scale=.57]{Figures/varSize_improvement_SGO.png}
}
\caption{Performance of algorithms, varying grid size, $30\%$ of cells on alert.}
\label{Fig: Grid Size Variation}
\end{figure*}
Fig~\ref{fig_MSGO} illustrates the performance of MSGO compared to the HGE benchmark scheme from~\cite{ghinita2014efficient}. Unlike the single seed GO, we are able to evaluate the performance of MSGO for grids with much higher granularity (i.e., 1024 cells in this case). There is a similar trend in terms of gain as we have observed with GO, where larger alert zones provide more opportunities for advantageous encodings, and thus overall performance is improved (the percentage of HVE operations eliminated is higher). The relative gain obtained is very close to 50\% compared to the benchmark. Also, the absolute amount of improvement is better than for GO in all cases. This occurs due to the fact that MSGO can support higher-granularity grids, and in this setting there is more flexibility in choosing a good encoding (due to the larger number of cells, there are significantly more choices for our algorithm).
As expected, increasing the depth of MSGO leads to higher improvement percentage, but the trade-off is a larger computation complexity.
Comparing Figs.~\ref{Fig_GrayOptimizer} and~\ref{fig_MSGO}, we remark that the MSGO algorithm obtains similar performance gains as the core algorithm GO for low granularity grids, but with a much lower computational overhead. For high granularity grids, GO cannot keep up in terms of computational overhead, whereas MSGO scales reasonably well, and it is able to still obtain significant improvements. One main reason is that MSGO no longer requires the calculation of probabilities of large cycles, avoiding numerical inaccuracies and reducing overall computational overhead. The complexity of the algorithm can be as low as $\mathcal{O}(n(\log_2n))$ depending on the chosen depth value, which provides a robust and efficient solution for reducing the number of HVE operations.
The execution time of MSGO is illustrated in~Fig.~\ref{fig4b}. The graph indicates that even for a high level of granularity, such as $4,000$, the algorithm requires less than $15$ minutes to encode the grid, depending on the specified depth at the input. As expected, by increasing the depth of the algorithm, better performance can be achieved in terms of HVE operations, at the cost of higher computational overhead. The MSGO algorithm can be extended for an arbitrary number of cells on the grid, and also it may have various cluster sizes depending on the application.
\subsubsection{SGO}
Fig~\ref{fig6} illustrates the performance gain obtained by SGO. In this experiment, we focused on applying the algorithm to much larger number of cells, up to $50,625$ (which is equivalent to a $225 \times 225$ square grid). Similar to the MSGO algorithm, the improvement achieved by SGO occurs even when the alert zones are small. Since the overall number of cells is larger, the SGO algorithm has even more flexibility in choosing an advantageous encoding, resulting in strong performance gains. For example, at $9$\% ratio of alert cells, the SGO algorithm results in $25.8$, $26$, and $27.3$\% improvements for grid sizes of $10,000$, $28,900$, and $50,625$, respectively.
The execution time of SGO is shown in Fig.~\ref{fig4c}. Even for very large grid sizes, such as $50,625$, the algorithm requires less than six minutes to encode the grid. Therefore, the system can be set to regularly update the probabilities and run the algorithm at six-minute intervals, if needed. To compare this time performance with GO, consider the maximum grid size for which the encoding can be computed within 60 seconds in each case. As shown in Fig.~\ref{fig4a}, this number corresponds to a grid size of $1200$ for GO, whereas in a similar time, SGO can be applied on the grid size of $22,000$ cells. Therefore, the SGO algorithm requires significantly lower computation overhead to execute compared with GO and even MSGO algorithms, while the performance gain in terms of HVE operations reductions is still solid.
Fig.~\ref{Fig: Grid Size Variation} presents the result of algorithms by fixing the percentage of alerted cells to $30\%$ and varying the grid size. It can be seen that the performance improvement of algorithms stays in a comparable margin for varying grid sizes. The slight fluctuation in graphs is due to two primary reasons (i) as all codewords have the same length, increasing the quantization level result in an addition of a bit to all codewords, and (ii) the initial probabilities are assigned to the cells in a random process based on the sigmoid activation function.
\begin{figure*}[h!]
\subfloat[Grid size=100 \label{F6a}]{%
\includegraphics[scale=.60]{Figures/FN_a.png}
}
\hfill
\subfloat[Grid size=1024 \label{F6e}]{%
\includegraphics[scale=.60]{Figures/FN_b.png}
}
\hfill
\subfloat[Grid size=10000 \label{F6c}]{%
\includegraphics[scale=.60]{Figures/FN_c.png}
}
\hfill
\subfloat[Grid size=100 \label{F6d}]{%
\includegraphics[scale=.60]{Figures/FN_d.png}
}
\hfill
\subfloat[Grid size=1024\label{F6b}]{%
\includegraphics[scale=.60]{Figures/FN_e.png}
}
\hfill
\subfloat[Grid size=10000 \label{F6f}]{%
\includegraphics[scale=.60]{Figures/FN_f.png}
}
\caption{Sensitivity analysis of algorithms, $40\%$ alerted cells.}
\label{Fig: Sensitivity analysis}
\end{figure*}
\begin{figure*}[h]
\subfloat[GO, grid size=100 ]{%
\includegraphics[scale=.59]{Figures/FMarkov_GO_operations.png}
}
\hfill
\subfloat[MSGO, depth=4, grid size=1024 ]{%
\includegraphics[scale=.59]{Figures/FMarkov_MSGO_operations.png}
}
\hfill
\subfloat[SGO, grid size=10000 ]{%
\includegraphics[scale=.59]{Figures/FMarkov_SGO_operations.png}
}
\hfill
\subfloat[GO, grid size=100 ]{%
\includegraphics[scale=.60]{Figures/FMarkov_GO.png}
}
\hfill
\subfloat[MSGO, depth=4, grid size=1024 ]{%
\includegraphics[scale=.60]{Figures/FMarkov_MSGO.png}
}
\hfill
\subfloat[SGO, grid size=10000 ]{%
\includegraphics[scale=.60]{Figures/FMarkov_SGO.png}
}
\caption{Markov model versus static approach.}
\label{Fig: dynamic approach}
\end{figure*}
\subsection{Imperfect Probabilities Information}
The knowledge of cell probabilities plays an important role in the reduction of HVE operations. These probabilities are input to GO and its extensions SGO and MSGO, used to find an enhanced encoding of space. Having imperfect initial cell probabilities can negatively impact the performance of algorithms by deviating the optimization result. Therefore, we aim at investigating the effect of imperfect initial probabilities on the improvement achieved compared with the previous work (HGE). This is done by the addition of noise to cell probabilities at the input of algorithms modeling the inaccuracies that might exist. Let us briefly illustrate how the addition of noise is conducted. Given the vector of cell probabilities:
$$\textrm{Probability of alert} = [p(v_1),\,p(v_2),\,...,\, p(v_n)],$$
each probability is added with an iid uniformly distributed random noise $n$ between $[0,u]$, where $u$ indicates the maximum noise value. For example, if the percentage of noise is $20\%$, this value is set to $0.2$, and the random noise is generated uniformly in the interval of $[0,0.2]$. Doing so, the transformed probabilities are acquired as
$$[p(v_1)',\,p(v_2)',\,...,\, p(v_n)'],\, \textrm{where}\, \,p(v_i)' = \,p(v_i)+n_i. $$
Note that the values are considered to be cyclic between zero and one, i.e., if the noise of $0.5$ is added with a cell probability of $0.8$, the resulting value would be recorded as $0.3$. Hence, with $100\%$ of noise, it is expected that the numbers would be uniformly distributed.
Fig.~\ref{Fig: Sensitivity analysis} indicates the sensitivity of GO, MSGO, and SGO to imperfect probability values used as input. For each algorithm, the number of HVE operations required is shown as well as the improvement gained in the performance compared with the previous work. The $x$-axis represents the percentage of noise added to the perfect probability information varied between 0 to 100, and the $y$-axis indicates HVE operations required side by side to the improvement achieved. The percentage of alerted cells is set to $40\%$ in all graphs.
The overall trend of reduction in the performance improvement by the addition of noise is consistent across all three algorithms. The improvement gained from algorithms stays at its highest when there exists no amount of noise at the input. The figure gradually drops as more noise is applied between zero to $50\%$, after which the performance improvement becomes almost negligible.
As expected, in the case of maximum noise, no information is available regarding probabilities, and therefore, no further gain could be made with respect to HGE. Hence, at $100\%$ of noise, the number of HVE operations required from all algorithms converges to the HVE operations of HGE. The rate of sensitivity to imperfect information varies among algorithms. Looking at $10\%$ of noise, it can be seen that the drop in MSGO performance occurs at a higher rate than the other two algorithms with GO and SGO indicating $25\%$ loss in the performance against the loss of $40\%$ for the MSGO algorithm. Overall, MSGO shows a higher sensitivity compared with the GO and SGO algorithms.
\subsection{Dynamic Alert Zones}
So far, we evaluated techniques for static alert zones. Next, we measure the performance of our proposed technique for dynamic alert zones introduced in Section~\ref{Advance Modeling of Alert Zones}.
Fig.~\ref{Fig: dynamic approach} investigates the performance gain acquired by applying the proposed Markov model. The random path approach (Monte Carlo sampling) is used as the underlying method to compute the transition matrix's stationary distribution, minimizing the induced computation complexity on the system. The $x$-axis of the graphs shows the percentage of alert cells, and the $y$-axis represents the percentage of improvement as well as the number of HVE operations required. To distinguish between the two modeling approaches, performance improvement achieved by incorporating the Markov model is labeled as {\em dynamic}, and the scenario in which the time dependence is not considered is referred to as {\em static}. The experiment is designed by initializing both static and dynamic approaches with the same set of initial probabilities; however, the system would continue evolving in a uniformly distributed manner. Therefore, if there are $m$ outgoing edges from a state of the model, the corresponding probability is set to $1/m$. The aim is to see if the Markov model is able to capture the evolution of the system and how much improvement can be achieved with the gained information. As before, the value of the $a$ and $b$ are set to $0.75$ and $10$ with the termination probability of $0.4$.
Fig.~\ref{Fig: dynamic approach} shows that the dynamic method can predict well the evolution of alert zones, as the resulting encoding requires far fewer HVE operations. The performance gain achieved for all three of the algorithms is significant. The percentage of improvement is approximately $35\%$ to $50\%$, indicating more impact on GO compared to MSGO and SGO.
\section{Related Work}
\subsection{Location Privacy.} Preserving the privacy of users in communication networks and online platforms has been one of the most challenging research problems in the past two decades. In the widely accepted scenario, users provide their location to service providers in exchange for location-based services they offer. The goal is to provide the service without user privacy being compromised by any of the parties involved. Early works to tackle this problem were focused on hiding or obfuscating user locations to achieve a privacy metric termed as $k$-anonymity. The location of a user is said to be $k$-anonymous if it is not distinguishable from at least $k-1$ other queried locations~\cite{sweeney2002k}.
In~\cite{kido2005anonymous}, the authors aim to provide $k$-anonymity by hiding the location of user among $k-1$ fake locations and requesting for desired services for all $k$ locations at the same time. The generation of such dummy locations based on a virtual grid or circle was considered in~\cite{niu2014privacy}. The authors in~\cite{niu2014achieving} conducted the selection of dummy locations predicated on the number of queries made on the map and aimed at increasing the entropy of $k$ locations in each set. In~\cite{cheng2006preserving}, random regions that enclose the user locations were introduced to bring uncertainty in the authentication of user locations. Unfortunately, fake locations can be revealed particularly in trajectories and with the existence of prior knowledge about the map and users.
Later on, approaches based on {\em Cloaking Regions (CRs)} proposed by~\cite{gruteser2003anonymous} gained momentum in the literature. The principal idea behind this method is to use a trusted anonymizer that clusters $k$ real user locations and query the area they are enclosed by to retrieve points of interest. Doing so, CRs aim to achieve $k$-anonymity for users and preserve their privacy. This approach is partially effective when snapshots of trajectories are considered, but once users are seen in trajectories, their location privacy would be severely at risk~\cite{shaham2020privacy}. Even for individual snapshots, it must be noted that a coarse area of real locations is released to the service provider, which could threaten the location privacy of users. Moreover, the CR-based approaches are susceptible to inference attacks predicated on the background knowledge or so-called side information. One such side information is the knowledge about the number of queries made on different locations of the map~\cite{niu2014achieving}.
More recently, a model for privacy preservation in statistical databases termed as {\em differential privacy} was developed in~\cite{dwork2006calibrating}. The metric provides a promising prospect for aggregate queries; however, it is not suitable for private retrieval of specific data from datasets. Closer to HVE approach, a private information protocol was proposed in~\cite{ghinita2008private}. The PIR technique is based on cryptography and shown to be secure for private retrieval of information. Despite the promising results, there exists an assumption behind PIR approach that the user already knows about the points of interest. Therefore, PIR is not suitable for location-based alert systems as users are not aware of alert zone whereabouts.
\subsection{Searchable Encryption.} Originated from works such as~\cite{song2000practical}, the concept of search encryption was proposed to provide a secure cryptographic search of keywords. Initially, only the exact matches of keywords were supported and later on the approach was extended for comparison queries in~\cite{boneh2006fully}, and to subset queries and conjunctions of equality in~\cite{boneh2007conjunctive}. The authors in~\cite{boneh2007conjunctive} also proposed the concept of HVE, used as the underlying tool to provide a secure location-based alert system. This approach and its extension in~\cite{blundo2009private} preserves the privacy of encrypted messages and tokens with the overhead of high computational complexity. The authors in~\cite{ghinita2014efficient} introduced and adopted the HVE for location-based alert systems, conducting the predicate match at a trusted provider, preserving the privacy of encrypted messages as well as tokens. Despite the promising results of the approach for privacy preservation in location-based alert systems, further reduction of computational overhead is necessary to increase the practicality.
\begin{table*}[th]
\caption{Summary of the proposed algorithms.}
\centering
\begin{tabular}{|>{\centering\arraybackslash}m{1.6cm} || >{\centering\arraybackslash}m{1.6cm} | >{\centering\arraybackslash}m{2.5 cm} |>{\centering\arraybackslash}m{2.7cm} |>{\centering\arraybackslash}m{1.2cm} |>{\centering\arraybackslash}m{5cm} |}
\hline Algorithms & Possible granularity& Complexity & Recommended depth & Number of seeds& Application\\
\hline Gray Optimizer & Low & $\mathcal{O}(2n(\log_2n)) + n^{log_23} - 2n+1$ & $|\log_2n|$ & one &The core algorithm used in MSGO and SGO, which is suitable for low granularity grids due to high complexity.\\
\hline MSGO & Medium to high& The minimum of $\mathcal{O}(n(\log_2n))$ depending on the depth variable& Depth=4 when the clusters are of equal length, otherwise it depends on the application & Equal to number of clusters &Advantageous in scenarios where the optimization is required for particular subsets of the grid. For example, the service is needed for two major non-overlapping organizations.\\
\hline SGO & High & $\mathcal{O}(n(\log_2n))$ &One & $n$ &SGO requires the lowest complexity, and it is advantageous in scenarios where the aim is to optimize the number of HVE operations for all the cells with equal significance.\\
\hline
\end{tabular}
\label{t1}
\end{table*}
\section{Conclusion}
We proposed a family of techniques to reduce the computational overhead of HVE predicate evaluation in location-based alert systems. Specifically, we used graph embeddings to find advantageous domain space encodings that help reduce the required number of expensive HVE operations. Our heuristic solutions provide a significant improvement in computation compared to existing work, and they can scale to domain partitionings of fine granularity. In addition, we studied how to extend these techniques to work for the challenging setting of dynamic alert zones. Table~\ref{t1} summarizes the properties of the proposed approaches.
In future work, we will focus on deriving cost models and strategies to reduce the HVE overhead based on workload-specific requirements. Certain families of tasks may exhibit specific patterns of operations, which can be taken into account to optimize HVE matching performance, as well as to re-use computation. We will also investigate extending the graph embedding approach to other types of searchable encryption, beyond HVE (e.g., Inner Product Evaluation), which exhibit different types of internal algebraic operations.
{\bf Acknowledgment.} This research has been funded in part by NSF grants IIS-1910950 and IIS-1909806, the USC Integrated Media Systems Center (IMSC), and unrestricted cash gifts from Microsoft and Google . Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of any of the sponsors such as the National Science Foundation.
\bibliographystyle{abbrv}
| {'timestamp': '2023-01-18T02:16:31', 'yymm': '2301', 'arxiv_id': '2301.06238', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06238'} | arxiv |
\section{Introduction}\label{sec:intro}
With the increasing availability of large amounts of textual content on the Internet, the need for efficient analysis of texts has become imperative. Online textual data encompasses a wide range of sizes and types, including books, encyclopedias and newspapers. In the last few decades, user-generated content in the form of short texts has also grown exponentially. Examples of such content include social media messages, product descriptions, online reviews, as well research papers~\cite{li2019key}.
In order to summarize this large amount of information, the task of keyword extraction (KE) has emerged as a crucial natural language processing (NLP) application. The goal of KE is to identify the most informative and relevant words or topics within a given document~\cite{timonen2012informativeness}. Keywords serve as a useful tool for users, allowing them to quickly understand the overall content of the texts. Moreover, keyword extraction plays an important role in various NLP applications, including text categorization, document summarization, document tagging, recommendation systems, speech recognition, and many more~\cite{li2016textrank, li2019key}.
The KE task has been the subject of numerous studies. These investigations can be broadly classified into three categories: statistical methods, linguistic/syntactic approaches, and graph-based methods. Different paradigms have also been used in a combined approach for supervised classification, where the extracted features are employed in a machine learning algorithm for a binary classification task~\cite{jiang2009ranking}. While these methods have demonstrated effectiveness in processing large texts, they present significant challenges when applied to short texts with high sparsity~\cite{chen2020inside}.
The identification of keywords within short texts, specifically in scientific manuscripts, poses a significant challenge, particularly when utilizing open scholarly datasets that only provide the title and abstract as sources of textual information~\cite{harzing2019two}. The challenge of extracting keywords from short texts, particularly in the case of scientific papers, has motivated the development of some approaches. One proposed method for addressing the sparsity of abstracts is to group abstracts using clustering techniques~\cite{silva2016using}. This can be accomplished by utilizing citations as a proxy for determining the similarity between papers, thereby circumventing the need for direct comparison of the short texts.
Despite the use of such clustering and other external information~\cite{li2019key,chen2020inside}, there is a lack of comprehensive studies comparing the compatibility of keywords extracted from abstracts and full texts. The accurate representation of the semantic information present in scientific papers is crucial in many areas, as it forms the foundation for many scientometric studies.
Thus, this study aims to address the following research questions:
\begin{enumerate}
\item To what extent are keywords extracted from abstracts similar to those extracted from the corresponding full papers?
\item Is there consistency in the set of keywords extracted by distinct community detection methods?
\item Does using citations result in superior performance as compared to directly assessing abstract similarity via textual information?
\end{enumerate}
We employed clustering methods to extract keywords from abstracts and compared them with keywords extracted from the corresponding full texts. Using a citation network, we evaluated the performance of various established community detection methods in identifying groups of related papers for the purpose of keyword extraction. We also evaluated clustering approaches that do not rely on citation information, including techniques based on neural embeddings.
The study revealed several interesting results. All evaluated methods were found to have a considerable discrepancy with keywords found in the full texts.
We observed that clustering methods that rely solely on textual information outperformed those based on citation networks, indicating that citations may not be an optimal proxy for semantic similarity. Furthermore, our results indicate that the various community detection strategies evaluated yielded similar performance levels, despite the observed differences in the set of keywords identified by each approach.
In summary, our findings suggest that the quantity of information used to extract keywords can strongly impact the performance of the task. Therefore, studies using similarity networks should consider the use of full texts, when available, to provide more robust information regarding topics extracted from paper networks.
The structure of this paper is as follows: In Section~\ref{sec:related}, we present a comprehensive review of the most pertinent studies in the area of keyword extraction. The proposed methodology for extracting keywords from both short and long texts is outlined in Section~\ref{sec:methods}, which also includes information regarding the adopted datasets. The main results are presented and discussed in Section~\ref{sec:results}. Finally, in Section~\ref{sec:conclusion}, we summarize with conclusions and suggest potential perspectives for future research.
\section{Related works}\label{sec:related}
The early works that addressed the keyword extraction problem focused on statistical methods. The spatial distribution of words along the text is used to gauge words' relevance~\cite{carretero2013improving}. The most simple approach is based on word frequency, where words with higher frequency values are considered keywords. However, these methods do not consider word order, therefore, if the text is shuffled, a meaningless version of the text would generate the same set of keywords. The combination of frequency and spatial distribution was then proposed to address this issue via word clustering and entropy~\cite{carretero2013improving,ortuno2002keyword}. The idea behind these methods is that important words are commonly concentrated in certain parts of the text, where the main topics are located. In this sense, irrelevant words are distributed regularly along texts, while keywords present an uneven distribution and tend to form semantic groups.
Another improvement to frequency-based methods is the tf-idf approach, which weights the importance of a word according to its frequency within a text and the frequency along the dataset. The main advantage of these methods is that they are simple and do not require an external corpus or knowledge of the language.
Graph-based methods have also been used approaches to model texts~\cite{machicao2018authorship}. Several works addressed the keyword extraction problem representing documents as word co-occurrence networks, where two words are connected if they co-occur in a given context~\cite{tohalino2022using}.
Centrality metrics are then used to assign an importance value to each word.
In~\cite{lahiri}, the authors concluded that network metrics are able to successfully extract relevant words for the keyword extraction task. They also highlighted that network-based approaches do not need the use of external corpora and they are language independent. The use of word embeddings and large contexts has also been useful in improving the quality of co-occurrence networks when extracting keywords~\cite{tohalino2022using}. A different approach was proposed by~\cite{grineva2009extracting}, where community detection methods were applied to a network of semantic relationships. The authors used Wikipedia to establish the semantic relatedness between the words of the document. According to~\cite{grineva2009extracting}, important words tend to be grouped into highly connected communities, which are related to the main topics of the document.
In order to address the keyword extraction problem in short texts, several works rely on the use of semantics and background knowledge. According to to~\cite{chen2020inside}, extracting only basic or straightforward features from the words is insufficient for finding keywords from short texts. In \cite{li2019key}, the authors remarked that text clustering approaches could also be useful in addressing the semantic sparseness of short texts.
These techniques enable the clustering of related texts, thereby allowing for the extraction of more semantic information by aggregating texts in the same cluster.
\cite{wan2008collabrank} employed clustering algorithms to identify the most relevant words for each cluster, operating under the hypothesis that texts with similar topics contain similar keywords. Then, a graph-based approach was applied to each text cluster; and the PageRank algorithm was used to extract keywords.
In~\cite{timonen2012informativeness}, the authors proposed a method for selecting keywords based on the informativeness value of each word.
This score was calculated at the corpus, cluster, and document levels. At the corpus level, the informativeness was computed taking into account all the documents, while at the cluster level, the word importance was calculated within a group of related texts. The results from the previous steps were then used to compute the informativeness at the document level. This approach yielded a good performance for extracting keywords.
Regarding graph-based techniques, several studies have enhanced TextRank~\cite{mihalcea2004textrank} by incorporating different semantic relationships between words as node weights for the word ranking algorithm. For instance, \cite{li2016textrank} used Wikipedia as an external knowledge base, while~\cite{li2019key} employed the Word2Vec and Doc2Vec embedding models to compute the semantic similarity between words.
While many works focus on extracting keywords either from short- and long-texts, here we conduct a comparative analysis of well-established methods for extracting keywords from both short and long texts. We focus on determining the compatibility of keywords extracted from abstracts and those extracted from the full content of research papers.
\section{Material and methods}\label{sec:methods}
The framework proposed to extract keywords
comprises the following main steps: i) text pre-processing; ii) network construction; iii) community detection; iv) short texts keyword extraction; and v) long texts keyword extraction. The steps are summarized below and illustrated in Figure \ref{fig:architecture}.
\begin{enumerate}
\item \emph{Text pre-processing}: this phase comprises the text-processing and vectorization steps.
The first step includes the removal of stopwords. The remaining words are stemmed and the tf-idf approach is employed to obtain the vectorized form of the pre-processed texts. Additional details on the pre-processing steps applied can be found in Section~\ref{sec:processing}.
\item \emph{Network creation}: we first constructed a paper citation network, which is used for short text keyword extraction. We also modeled the complete content of each paper as word co-occurrence networks, which were used to extract keywords from long texts. In Section~\ref{sec:network}, we describe the required steps for the creation of both network models.
\item \emph{Community detection}: we applied community detection methods to the citation networks in order to find clusters of related papers (see Section \ref{sec:community}).
\item \emph{Short texts keyword extraction}: this phase is responsible for the extraction of keywords from short texts (paper abstracts). The clusters obtained in the previous step are used in this phase. The relevance of each word is computed inside and outside communities. We also proposed two methods for keyword extraction based on tf-idf and the K-Means algorithm. The methods for short texts keyword extraction are described in Section ~\ref{sec:short}.
\item \emph{Long texts keyword extraction}: to identify reference keywords, we used the complete content of the papers as input from several well-known keyword extraction methods. We evaluated methods based on word frequency, tf-idf, entropy, intermittency, BERT, Yake and TextRank~\cite{carretero2013improving,amancio2013probing,campos2020yake,mihalcea2004textrank,devlin2018bert}. We also used a network approach based on co-occurrence networks and centrality metrics to find keywords for long texts. These networks were characterized using centrality metrics. A detailed explanation of the adopted methodology is shown in Section~\ref{sec:long}.
\end{enumerate}
\begin{figure}[h]
\centering
\includegraphics[width=1.0\textwidth]{architecture2.png}
\caption{The workflow of the adopted keyword extraction system involves several stages. The initial step is pre-processing of the text. Next, a citation network is constructed and community detection algorithms are employed to extract keywords from short texts. For comparative evaluation, we implemented both a tf-idf and K-Means approach. Both approaches do not consider citations to cluster papers.
In order to generate reference keywords, we employed a combination of statistical and traditional keyword extraction methods on the full texts. Additionally, we also evaluated a co-occurrence network approach as an alternative method for keyword extraction.
}
\label{fig:architecture}
\end{figure}
\subsection{Datasets}\label{sec:dataset}
The following two datasets were used:
\begin{enumerate}
\item \emph{Short texts KE dataset}: we used the dataset collected in~\cite{silva2016using}. The authors retrieved the information from 11,063 papers on the complex networks field. The data was obtained from the \emph{Web of Science} (WOS) database~\footnote{https://clarivate.com/webofsciencegroup/solutions/web-of-science/}. The selected papers were published from 1991 to 2013. For each paper, the authors extracted the title, abstract, and list of references. The latter was used to construct a citation network. The title and abstract of each paper were used as input for the application of keyword extraction techniques.
\item \emph{Long texts KE dataset}: In order to generate a list of reference keywords for each abstract, we collected the full content of each paper, including the introduction, methodology, results and discussion, conclusions, and appendix sections of each research article. We used the API of the arXiv database \footnote{https://arxiv.org/} to extract the complete content of the papers. We performed an automatic search using both the title and the abstract of each paper as keywords for the arXiv API.
\end{enumerate}
Table~\ref{tab:dataset} presents a summary of the statistical information for the datasets. The information provided was calculated from the pre-processed versions.
\begin{table}[h]
\caption{Statistical information from datasets. $|D|$ stands for the number of documents. We also show the average number of tokens ($W_{avg}$), and the first ($W_{q1}$) and third ($W_{q3}$) quartiles of the distribution of the number of tokens. Similarly, $U_{avg}$ represents the average vocabulary size, while $U_{q1}$, and $U_{q3}$ are the first and third quartiles of the vocabulary size distribution, respectively.}
\label{tab:dataset}
\begin{tabular}{c|c|c|c|c|c|c|c|c}
\hline \hline
\textbf{Dataset} & \textbf{Description} & $|D|$ & $W_{avg}$ & $W_{q1}$ & $W_{q3}$ & $U_{avg}$ & $U_{q1}$ & $U_{q3}$ \\ \hline
Short texts & Paper abstracts & 11,063 & 79.12 & 59.00 & 95.00 & 55.97 & 43.00 & 66.00 \\
Long texts & Full paper content & 1,982 & 2,020.58 & 1,170.25 & 2,405.00 & 517.64 & 394.00 & 595.00 \\ \hline \hline
\end{tabular}
\end{table}
\subsection{Data processing}\label{sec:processing}
This phase comprises three steps: data preparation, text pre-processing, and tf-idf vectorization. The data preparation step consisted of processing the recovered papers from the arXiv database (for the full content of the papers). We obtained a LaTeX version of each paper, so we had to remove all LaTeX tags. We also removed the authors list, institutions, and acknowledgments from the cleaned text. The following sections were included in the analysis of full papers: introduction, related works, methodology (or materials and methods), results, discussion, conclusion, and appendix sections.
Text pre-processing transformations were applied to all texts of the dataset. We first removed stopwords and punctuation marks. Then, a stemming step was applied to the remaining words. This step is required in order to map each word into its root or stem~\cite{pramana2022systematic}.
The tf-idf technique was used to transform the pre-processed text into a sparse vector representation. To compute the importance of a word $w$, the technique considers the internal frequency of $w$ in a single document. Moreover, the internal frequency is compared with the relative frequency of $w$ in all documents of the dataset~\cite{salton1973specification}.
The tf-idf representation of $w$ in a document $d$ is computed as
\begin{equation}
\textrm{tf-idf}(w,d) = \frac{f(w,d)}{n_d} . \frac{\log N}{\log (N_w)},
\end{equation}
where $f(w,d)$ represents the frequency $w$ in $d$, $n_d$ is the number of words in $d$, $N$ stands for the total number of documents in the dataset, and $N_w$ represents the number of documents in which $w$ appears at least once.
We used the tf-idf vector representations of each abstract as input values of a K-Means based method for short texts KE. We also used the tf-idf weight of each word from the full content of the papers in order to give an importance value for a long text KE method (LKE).
\subsection{Network creation}\label{sec:network}
Given the short size of paper abstracts,
it is infeasible to extract statistically significant information from individual texts. As such, we employed network representation techniques to extract supplementary information that would enhance the keyword extraction process. Upon analyzing the topological and structural properties of the networks, we are able to infer attributes of the texts that enable us to determine the relative importance of each word.
Two different network models are used in our study.
In order to cluster \emph{short texts} into groups of related papers, we used a citation network for the \emph{short texts} keyword extraction task. In this case, the network structure represent the whole dataset of documents. Conversely, when extracting keywords from long texts,
each text is modeled as a word co-occurrence network~\cite{castro2019multiplex,joseph2022cognitive,stella2020multiplex}.
The unweighted paper citation network was built following the methodology described in~\cite{silva2016using}.
The citation networks are intended to represent a semantical similarity structure that do not use textual information to establish links between papers. The resulting network was composed of $11,063$ nodes and $94,472$ edges. The community structure of this network and the information of title and abstract are then used to detect the most important words in each network community.
The \emph{full content} of a paper is modeled as a word co-occurrence network. In this graph model, each node represents a word, and the edges between two nodes are based on the neighborhood relationship of two words. We used the approach that can include virtual links, so that similar words can be linked. This model and its variations have been used in many different scenarios~\cite{de2016topic,correa2019word,ferraz2018representation,quispe2021using}. The networks were characterized using well-known centrality measurements to rank the words according to their structural importance in the networks~\cite{newman2018networks}.
\subsection{Community detection} \label{sec:community}
This phase is responsible for detecting communities, i.e. clusters of papers linked via citation links. Communities are groups of nodes that are more densely interconnected with each other in comparison with the rest of the nodes from the network~\cite{radicchi2004defining}. The identification of communities in large networks is quite a useful task. For example, the nodes that belong to the same community likely share several common properties. Also, the number of found communities and their respective features could help to identify the category of a network for classification tasks~\cite{wang2015network}. The identification of communities is also useful to understand the dynamic evolution and organization of a network~\cite{dakiche2019tracking}.
In this paper, we evaluated the following methods: Multilevel, Label Propagation, Infomap, Fast Greedy, and Leiden method~\cite{Blondel_2008,PhysRevE.76.036106,traag2019louvain,clauset2004finding,rosvall2008maps}. In the Appendix, we provide a brief description of each method.
In the context of community detection methods, we investigated if community-based methods are consistent in the sense that they generate well-defined, large communities. This is an important step in our analysis because small communities can lead to low performance~\cite{silva2016using}. In the paper citation network, most of the community detection methods found between 23 and 39 paper communities, which leads to communities comprising more than 100 papers, typically. The infomap, however, generated more than 400 communities, and most of them comprised less than 10 papers. {Before the computation of the relevance of each word, we decided to filter out those communities that contain few papers. }
\subsection{Short texts keyword extraction}\label{sec:short}
This step consists of the extraction of keywords from the pre-processed paper abstracts. We evaluated a network community-based approach that generates a word importance index to rank each word from the paper abstracts. For comparison purposes, we also evaluated tf-idf and K-Means-based methods for the short texts KE task.
\begin{enumerate}
\item \textit{Community-based approach:} we used the community structure found from papers citation networks to detect the word importance index of each word from paper abstracts. The adopted index quantifies the relative frequency of a word appearing inside a community against its frequency in the remaining documents of the citation network~\cite{silva2016using}. To compute the word importance index $I$ for a word $w$, we first compute the frequency of the word inside a community $\alpha$. This quantity is the relative internal frequency $F_\alpha^{\textrm{(in)}}(w)$, given by
%
\begin{equation}
F_\alpha^{\textrm{(in)}}(w) = \frac{n_\alpha(w)}{|\alpha|},
\end{equation}
%
where $n_\alpha(w)$ is the total number of papers containing $w$ appears within a community $\alpha$, and $|\alpha|$ represents the number of papers associated with a community $\alpha$. We also compute the relative frequency of $w$ outside $\alpha$, $F_\alpha^{\textrm{(out)}}(w)$, which is computed as:
%
\begin{equation}
F_\alpha^{\textrm{(out)}}(w) = \sum_{\gamma \neq \alpha} \frac{n_\gamma(w)}{N-|\alpha|},
\end{equation}
%
where $N$ is the total number of papers in the network. Then, the importance index $I(w)$ is calculated as the highest difference between the relative in-community and out-community frequencies, i.e.:
%
\begin{equation}
I(w) = \max_\alpha \Big{[} F_\alpha^{\textrm{(in)}}(w) - F_\alpha^{\textrm{(out)}}(w) \Big{]}.
\end{equation}
%
The word importance index was computed for all words from paper abstracts, and then the best-ranked words were considered as relevant keywords for each abstract.
\item \textit{tf-idf based approach:} the tf-idf values considering all paper abstracts from the dataset are computed. For each abstract, we considered the tf-idf weights of the words comprising the abstract. The words with the highest tf-idf values were selected as relevant keywords for each abstract.
\item \textit{K-Means based approach:} this method is equivalent to the \emph{community-based approach}. The difference is that clusters are obtained via the K-Means algorithm~\cite{rodriguez2019clustering}. To obtain the cluster, we first obtained the embedding of each abstract. Then we evaluated several values of $K$ to find the optimal number of clusters.
\end{enumerate}
\subsection{Long texts keyword extraction} \label{sec:long}
The keywords obtained from full texts are considered reference keywords when evaluating the quality of keywords extracted from short texts.
Here we considered as input texts the complete content of the research papers. We adopted several methods found in the literature to extract keywords documents.
The methods can be classified into two approaches: statistical and graph-based approaches:
\begin{itemize}
\item \textit{Statistical and traditional keyword extraction methods:} In this step we employed statistical techniques that are commonly used for keyword extraction tasks. These methods perform an appropriate analysis of the statistical distribution of words along documents. The main goal of statistical methods is to detect and rank relevant words of documents without any \emph{a priori} or external information~\cite{carretero2013improving}. The methods we adopted are based on frequency, word tf-idf, word entropy, word intermittency, and Yake. We also evaluated a graph-based approach named TextRank, and a method that uses word embeddings based on BERT. The methods are described in the Appendix.
\item \textit{Network-based methods:}
a comprehensive set of centrality measures were used to analyze the word co-occurrence networks derived from the full content of the papers.
%
The network measurements are useful to identify the most relevant nodes in a network~\cite{newman2018networks}. Therefore, they allow ranking the nodes according to their topological importance so that they can find the most important words for each text~\cite{tohalino2018extractive}. We selected as keywords for each text the best-ranked nodes (words) according to the following centrality metrics: degree, PageRank, betweenness, eigenvector centrality, closeness and accessibility computed at the first two levels~\cite{travenccolo2008accessibility}. We also employed a methodology that combines the results of each centrality metric. In the methodology henceforth referred to as voting system, the keywords found by the majority of the network measurements were selected as relevant keywords for each text.
\end{itemize}
\section{Results and discussion}\label{sec:results}
Our analysis is divided into two sections. Section~\ref{sec:dataset_analysis} describes a statistical analysis of the datasets. Section~\ref{sec:accuracy_analysis} provides a comparison of keywords extracted from short and full-text sources. We also analyze the performance of distinct network community methods for the task.
\subsection{Dataset analysis and selection of reference keywords}\label{sec:dataset_analysis}
In this section, we first perform a statistical evaluation of the datasets through the analysis of the number of common words between the paper abstracts (short-size texts) and the full content of the research paper (long-size texts). This analysis is an initial step to the generation of a set of gold standard keywords for each paper abstract. Because many datasets comprising full-text papers lack keywords selected by human experts, we used as a starting point the full content (including all sections except the abstract) of each paper. We employed keyword extraction methods to extract reference keywords from the complete content of each paper. However, we first analyzed the number of mutual words existing between each abstract and the full content. In some cases, it is possible that the paper authors use specific words to express their main ideas in the abstract and they could change to other words using synonyms or similar expressions in the rest of the paper. Therefore, it becomes important to analyze whether the information extracted from full texts is compatible with the content of abstracts.
We computed how many words ($w$) in the abstract are also present in the full content of the papers. The cumulative distribution (i.e. $P (x \geq w$)) of this quantity in the dataset is shown in Figure~\ref{fig:common_words}.
A significant number of research papers (80\%) present a high number of common words (40) between the abstracts and the full content of the papers. 50\% of the papers have at least 50 common words.
As expected, this means that most of the information in the abstract is also available in the remainder of the paper.
Now we evaluate how many \emph{keywords} found in the \emph{full content analysis} are also present in the abstract.
We used two approaches to extract reference keywords considering each paper's full content: statistical and graph-based KE methods. We evaluated these approaches by counting the number of mutual words between the keywords generated by each method and the words composing the paper abstracts. Figure~\ref{fig:common_words2} depicts the obtained results for each approach.
According to the size of the abstracts and the full content (see Table~\ref{tab:dataset}), we considered recovering between 5 and 50 keywords generated by each KE method. Then, we count the number of these keywords that are part of the abstracts.
\begin{figure}[h]
\centering
\includegraphics[width=0.9\textwidth]{common_words_3.png}
\caption{Analysis of the number of common words between the abstracts and the complete content of the research papers. The x-axis represents the number of mutual words between paper abstracts and their corresponding full content. The y-axis is the representation of $P(x \geq w)$, i.e. the fraction of papers comprising at least $w$ common words between abstracts and full texts.
}
\label{fig:common_words}
\end{figure}
\begin{figure}[h]
\centering
\subfigure[Analysis of traditional and statistical keyword extraction methods for the full content of research papers.]{\includegraphics[width=0.8\textwidth]{comp_traditional_3.png}\label{fig:common_words2_a}}
\subfigure[Analysis of network-based keyword extraction methods for the full content of research papers.]{\includegraphics[width=0.8\textwidth]{comp_network_3.png}\label{fig:common_words2_b}}
\caption{Analysis of the overlap between the common words found in the paper abstracts and those identified by keyword extraction methods for longer texts (i.e., the full content of the papers).
The x-axis represents the number of keywords recovered in the full content, while the y-axis indicates the average number of retrieved keywords that also appear in the paper abstract.
}
\label{fig:common_words2}
\end{figure}
In relation to traditional and statistical methods, the results displayed in Figure~\ref{fig:common_words2_a} show that the methods Yake, word frequency, and word entropy outperformed the other KE techniques. These methods were able to find the largest number of common words with the abstracts.
The voting system approach did not achieve the best results. The methods based on word intermittency and BERT also displayed a low number of mutual words with the paper abstracts.
We also evaluated the methods based on word co-occurrence networks and centrality measurements. The results depicted in Figure~\ref{fig:common_words2_b} suggest that almost all centrality metrics performed similarly. We observed that the voting system, node degree, PageRank, and accessibility (computed at the first hierarchical level) outperformed the other network-based methods. However, the difference in terms of performance with the other network metrics is not significant.
\subsection{Extracting keywords from abstracts} \label{sec:accuracy_analysis}
In this section, we analyze if the methods adopted to extract \emph{keywords from abstracts} are able to capture keywords that are found when the full-text content is analyzed. We used accuracy as a performance evaluation measure.
The performance of the methods is measured in terms of the number of common words between the reference keywords and the keywords generated by the short-text KE methods, divided by the total number of reference keywords.
We established a parameter $N$ to represent the number of reference keywords to be considered in the evaluation. As reference keywords (i.e. keywords obtained from full texts), we used the methods with the highest performance observed in the previous section.
Figure~\ref{fig:accuracy_a} shows the performance analysis considering as reference keywords the ones obtained from statistical methods.
The results in Figure~\ref{fig:accuracy_a} suggest that community-based approaches obtained similar accuracy values since no method clearly outperformed the others. The label propagation method achieved a slightly lower performance than the other methods. We also found that the tf-idf method displayed a performance that is similar to the other network community-based methods. Surprisingly, when citation information is disregarded and only the textual information is used, the performance is improved. The K-Means method is significantly better than all other approaches, with a gain of 25\% in performance, in some cases. {The complete analysis considering different values for the parameter $N$ is shown in the Appendix.}
\begin{figure}[h]
\centering
\subfigure[~ Performance analysis considering the traditional and statistical methods as reference keywords.
] {\includegraphics[width=0.8\textwidth]{statistical_2.png}\label{fig:accuracy_a}}
\subfigure[~ Accuracy analysis considering the network-based methods as reference keywords.] {\includegraphics[width=0.8\textwidth]{network_2.png}\label{fig:accuracy_b}}
\caption{ Comparative analysis of the accuracy obtained from the evaluation of KE methods for short texts (paper abstracts). We extracted $N=30$ keywords from full texts.}
\label{fig:accuracy}
\end{figure}
Figure~\ref{fig:accuracy_b} shows the performance analysis considering as reference keywords the ones obtained from (co-occurrence) network-based methods. Here we see that all considered network centrality metrics provide almost the same performance. This result is consistent with the literature in text network analysis since there is a correlation of centrality metrics when analyzing written texts. Concerning the formation of reference keywords via community detection methods, it is also worth noting that all community-based methods provided similar performance for the task. Conversely, choosing reference keywords via tf-idf yielded the worst performance. Once again, the best performance was obtained with the KMeans method.
One possible explanation for the similar performance achieved by the community-based detection methods could be the fact that all methods are generating similar partitions and, consequently, they are selecting the same set of keywords for each paper abstract. In order to evaluate this hypothesis, we computed the Spearman correlation coefficient of the ranking of words' relevance generated by different community detection methods. The results (not shown) revealed that the methods are actually selecting different sets of keywords. If one considers the full rank of words, the Spearman correlations are typically lower than 0.10. In a similar fashion, when considering only the top 30 ranked words, all correlations were below 0.27. As expected, in both scenarios, the highest correlation was found for the rankings generated by the Multilevel and Leiden methods~\cite{traag2019louvain,Blondel_2008}.
The performance results revealed interesting insights. First, we found that identifying keywords from citation information alone does not provide the highest match between keywords found in abstract and full-text. While citations have been used in numerous contexts~\cite{amancio2012using}, one possible reason for the observed low performance is that citations may not reflect the semantic similarity of texts, which may hinder the performance of the community detection methods. In fact, some studies have pointed out a discrepancy between citation and content similarity. For example,~\cite{amancio2012using} found that citation and content similarity are not consistent since the most similar papers are oftentimes disregarded when selecting references for papers. In a similar fashion, the differences in the content have been used to improve models reproducing the growth of citation networks, since content similarity has also been used as an important feature to model the growth of citation networks~\cite{zhao2022utilizing}.
While the use of textual information was able to provide a better performance in recovering keywords from full-text content, the obtained accuracy is still below $50\%$. This means that using cluster information from papers abstracts is not enough to recover the full content of papers. This may have implications in many studies that are based on recovering text content based on keywords. For example, when studying the properties of citation networks, the selection of papers via keywords may affect the stability of citation network metrics. A different number of communities depicting subfields of a major area can be found if the keywords terms are not well-defined to select the relevant papers.
The differences in content extracted from abstracts and full texts can also potentially lead to distinct interpretations in the context of \emph{Science of Science}. In a document similarity network, for example, the centrality of a paper may strongly depend on the use of abstracts or full texts. If such networks are studied in other contexts, this may lead to less robust conclusions. For example, comparing the semantic similarity between papers linked by citations may lead to different results depending on how much text is used to gauge semantic similarity~\cite{amancio2012using}.
Therefore, it remains relevant to consider full-text content to draw conclusions relying upon the analysis of papers' semantic similarity.
\section{Conclusion}\label{sec:conclusion}
The identification of keywords from short texts poses a significant challenge. In this paper, we evaluated whether well-known approaches are able to extract keywords from abstracts that are compatible with a full-content analysis.
Due to the limited context provided in abstracts, we employed methods that leverage the citation context to cluster papers into semantically similar groups. Additionally, we used strategies based on statistics and the K-Means algorithm. Reference keywords were obtained from the full content of papers through the use of multiple techniques.
The findings indicate that a simple approach such as the K-Means algorithm outperforms methods that rely on communities derived from citation networks. Additionally, the results demonstrate a similar performance among the various community detection methods applied to citation networks, with no clear superiority demonstrated by any particular method.
All in all, citation networks and alternative methods that do not rely on citations demonstrated suboptimal performance. This result implies that the keywords obtained from abstracts are not consistent with those obtained from a comprehensive content analysis. Consequently, further research is necessary to investigate whether the observed variations may lead to discrepancies in the analysis of document similarity networks~\cite{minaee2021deep}.
One way to potentially enhance the performance of clustering methods for keyword extraction is through the use of alternative methods for text vector representation. The incorporation of text embeddings, such as those generated by the BERT model~\cite{beltagy2019scibert}, may assist in effectively representing the documents. Additionally, implementing synonym handling during the generation of reference keywords could also prove beneficial. The performance could also be improved by integrating citation and text-based information when creating paper networks.
\section*{Acknowledgments}
This study was financed in part by the Coordenação de Aperfeiçoamento de Pessoal de Nível Superior - Brasil (CAPES) - Finance Code 001. Diego R. Amancio acknowledges financial support from CNPq-Brazil (Grant no. 304026/2018-2, 311074/2021-9) and FAPESP (Grant no. 20/06271-0). Thiago C. Silva (Grant no. 308171/2019-5, 408546/2018-2) gratefully acknowledges financial support from the CNPq foundation.
\section*{Appendix}
\subsection{Community detection methods}\label{app:community}
In this section, we provide a brief description of the network community methods employed in this paper:
\begin{enumerate}
\item \textit{Multilevel}: in this algorithm, each node is assigned to a different community. Then nodes are moved to the communities of their corresponding neighbors that yields the highest positive contribution to modularity~\cite{Blondel_2008}. This process is repeated until the local contribution of nodes to the modularity is no longer improved.
Each community from the original network is reduced into a single node (maintaining the total weight of the adjacent edges) and the method continues to the next level. The algorithm ends when there is no longer any possibility of increasing the modularity score after reducing communities to nodes.
\item \textit{Label propagation:} The method presented in~\cite{PhysRevE.76.036106} is based on the principles of neighborhood connectivity and information diffusion in networks. The approach begins by assigning unique community labels to each node in the network. These labels are subsequently propagated throughout the network. During each iteration, each node adopts the most prevalent label within its immediate neighborhood. The edges within the network are then randomly removed, and the nodes are updated in a random order before the next iteration commences. The algorithm stops when the nodes reach a consensus, which is defined as a state in which each node holds the majority label among its neighboring nodes.
\item \textit{Leiden:} The Leiden algorithm, which was proposed in~\cite{traag2019louvain}, represents an improvement to the widely-used multilevel method~\cite{Blondel_2008}. The latter is known to have a weakness of often discovering communities that are weakly connected. In contrast, the Leiden method aims at ensuring that communities are well-connected through the implementation of the following three phases:
(i) local moving of nodes (as in the multilevel method); (ii) refinement of partitions; and (iii) aggregation of the network. By incorporating these three phases, the Leiden algorithm is able to uncover higher-quality clusters in significantly less time when compared to the multilevel method.
\item \textit{Fast Greedy:} this algorithm is based on hierarchical agglomerative clustering and aims to optimize the modularity score~\cite{clauset2004finding}. The method begins by considering a subnetwork composed exclusively of edges between highly-connected nodes. This methodology subsequently evaluates randomly selected edges that improve the modularity of the subnetwork and aggregates them. This process is repeated until the incremental improvement in modularity becomes negligible. Finally, the communities are obtained by identifying the connected components within the subnetwork.
\item \textit{Infomap:} the algorithm was introduced by~\cite{rosvall2008maps} and is based on information theory. This method begins by encoding the network into modules in a manner that maximizes the amount of information retained from the original network. The encoded network is then transmitted through a channel with limited capacity. The goal of the decoder is to attempt to decode the message and construct a set of possible candidates for the original network. The fewer the number of candidates, the more information about the original network has been transmitted. The algorithm also uses random walks to analyze the flow of information through the network.
\end{enumerate}
\subsection{Statistical keyword detection}\label{app:statistical}
\begin{itemize}
\item \textit{Word frequency and tf-idf methods (Freq. and tf-idf):} one of the simplest techniques for keyword extraction is the frequency-based approach, which assigns relevance to words that occur at a high frequency. The words that rank the highest in terms of frequency are therefore considered as keywords. In order to mitigate the limitations of the frequency-based methods, we also evaluated the tf-idf method. Unlike the frequency-based approach, the tf-idf method assigns a weight to the frequency of each word based on its number of occurrences within the document as well as throughout the entire dataset. In this approach, the words with the highest tf-idf values are considered as keywords.
\item \textit{Word entropy (W.E.):} This method leverages Shannon's entropy to analyze the information content of the sequence of occurrences of each word in a given text~\cite{carretero2013improving}. This technique requires partitioning the texts into $N$ segments to calculate the entropy of each word. In this study, we partitioned the paper texts according to the number of sentences that make up each text. According to this method, the higher the value of entropy of a word, the greater the heterogeneity of the distribution of that word within the text, and thus the greater its relevance. One of the key advantages of this method is that it does not require a large text corpus for training; it only requires the input text.
\item \textit{Word intermittency (W.I.):} This metric takes into account the relationship between the significance of a word and its spatial distribution~\cite{amancio2013probing}. Previous research has found that important words are closely related to the main topics of the text and display a highly heterogeneous distribution. Such words tend to be located in specific regions of the text, exhibit large frequency fluctuations and often form clusters~\cite{carretero2013improving}. In contrast, common words such as stopwords are distributed randomly throughout the document and exhibit a relatively homogeneous distribution. Thus, as proposed by ~\cite{carretero2013improving}, a statistical analysis of the distribution of word occurrences can be employed to identify relevant keywords within a given text. Similar to the frequency and entropy methods, this technique identifies important words solely based on the target text and does not require external information.
\item \textit{Yake}: The Yake method extracts statistical features from the source text to identify the most relevant keywords~\cite{campos2020yake}. Five features are computed for each individual term: (i) casing, (ii) word positional, which assigns greater importance to words that appear at the beginning of a text, (iii) word frequency, which assigns relevance to words that occur more frequently, (iv) word relatedness to context, which measures the number of different terms that appear to the left and right of the target word, and (v) word \emph{difSentence}, which measures how often a word appears across different sentences. These features are then combined into a single measure to assign an importance weight to each word. According to this score, words with the lower values are considered as relevant keywords~\cite{campos2018yake}.
\item \textit{TextRank (TextR):} The TextRank method, proposed by~\cite{mihalcea2004textrank}, is a graph-based approach that employs the PageRank algorithm and is widely used for text summarization and keyword extraction tasks. In this method, texts are modeled as word co-occurrence networks, where the nodes are represented by words and edges are established between two nodes if they co-occur within a window size. In the original paper, the window size was set between 2 and 10 words. The PageRank algorithm is employed to rank each word, and the top-ranked words are selected as relevant keywords.
\item \textit{BERT-based method}: the Bidirectional Encoder Representations from Transformers (BERT) technique is a state-of-the-art embedding model that captures the semantic content of documents through dense vector representations~\cite{devlin2018bert}. The BERT-based method generates word embeddings for each n-gram in the text. Subsequently, the cosine similarity metric is applied to identify the words that are most similar to the original document. The top-ranking similar words are then considered as relevant keywords for each document.
\item \textit{Voting system (V.S.):} In order to improve the accuracy of the long text keyword extractor, we combined the results of the above proposed methods. We used a voting system based on the keywords found by most keyword extraction methods.
\end{itemize}
\subsection{Complete results based on accuracy analysis}\label{app:results}
\begin{table}[h!]
\caption{Accuracy obtained from the evaluation of keyword extraction methods for short texts (paper abstracts). Here we considered as reference keywords the relevant words found by the \emph{traditional and statistical} methods for the full content of the papers. $N$ represents the number of top keywords we recovered for both short and long texts keyword extraction methods.}
\label{tab:accuracy_statistical}
\begin{tabular}{c|cccc|cccc|}
\cline{2-9} & \multicolumn{4}{c|}{\textbf{Word Frequency}} & \multicolumn{4}{c|}{\textbf{tf-idf}} \\ \hline
\multicolumn{1}{|c|}{\textbf{method}} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} \\ \hline
\multicolumn{1}{|c|}{multilevel} & \multicolumn{1}{c}{0.1578} & \multicolumn{1}{c}{0.2559} & \multicolumn{1}{c}{0.3269} & 0.3678 & \multicolumn{1}{c}{0.0740} & \multicolumn{1}{c}{0.1066} & \multicolumn{1}{c}{0.1448} & 0.1793 \\
\multicolumn{1}{|c|}{labelProp} & \multicolumn{1}{c}{0.1375} & \multicolumn{1}{c}{0.2312} & \multicolumn{1}{c}{0.3022} & 0.3504 & \multicolumn{1}{c}{0.0787} & \multicolumn{1}{c}{0.1033} & \multicolumn{1}{c}{0.1363} & 0.1724 \\
\multicolumn{1}{|c|}{leiden} & \multicolumn{1}{c}{0.1496} & \multicolumn{1}{c}{0.2533} & \multicolumn{1}{c}{0.3260} & 0.3664 & \multicolumn{1}{c}{0.0819} & \multicolumn{1}{c}{0.1153} & \multicolumn{1}{c}{0.1463} & 0.1785 \\
\multicolumn{1}{|c|}{fastG} & \multicolumn{1}{c}{0.1465} & \multicolumn{1}{c}{0.2518} & \multicolumn{1}{c}{0.3290} & 0.3684 & \multicolumn{1}{c}{0.0713} & \multicolumn{1}{c}{0.1023} & \multicolumn{1}{c}{0.1419} & 0.1767 \\
\multicolumn{1}{|c|}{infomap} & \multicolumn{1}{c}{0.1375} & \multicolumn{1}{c}{0.2320} & \multicolumn{1}{c}{0.3175} & 0.3647 & \multicolumn{1}{c}{0.1458} & \multicolumn{1}{c}{0.1561} & \multicolumn{1}{c}{0.1726} & 0.1951 \\
\multicolumn{1}{|c|}{tf-idf} & \multicolumn{1}{c}{0.2858} & \multicolumn{1}{c}{0.2889} & \multicolumn{1}{c}{0.3071} & 0.3350 & \multicolumn{1}{c}{0.3596} & \multicolumn{1}{c}{0.3223} & \multicolumn{1}{c}{0.2984} & 0.2755 \\
\multicolumn{1}{|c|}{KMeans} & \multicolumn{1}{c}{0.4253} & \multicolumn{1}{c}{0.4213} & \multicolumn{1}{c}{0.4220} & 0.4146 & \multicolumn{1}{c}{0.2129} & \multicolumn{1}{c}{0.2106} & \multicolumn{1}{c}{0.2198} & 0.2279 \\ \hline
& \multicolumn{4}{c|}{\textbf{Word Entropy}} & \multicolumn{4}{c|}{\textbf{Word Intermittency}} \\ \hline
\multicolumn{1}{|c|}{\textbf{method}} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} \\ \hline
\multicolumn{1}{|c|}{multilevel} & \multicolumn{1}{c}{0.1341} & \multicolumn{1}{c}{0.2294} & \multicolumn{1}{c}{0.3004} & 0.3460 & \multicolumn{1}{c}{0.0679} & \multicolumn{1}{c}{0.1291} & \multicolumn{1}{c}{0.1828} & 0.2233 \\
\multicolumn{1}{|c|}{labelProp} & \multicolumn{1}{c}{0.1165} & \multicolumn{1}{c}{0.2052} & \multicolumn{1}{c}{0.2769} & 0.3285 & \multicolumn{1}{c}{0.0608} & \multicolumn{1}{c}{0.1159} & \multicolumn{1}{c}{0.1663} & 0.2110 \\
\multicolumn{1}{|c|}{leiden} & \multicolumn{1}{c}{0.1279} & \multicolumn{1}{c}{0.2293} & \multicolumn{1}{c}{0.3007} & 0.3455 & \multicolumn{1}{c}{0.0651} & \multicolumn{1}{c}{0.1288} & \multicolumn{1}{c}{0.1829} & 0.2228 \\
\multicolumn{1}{|c|}{fastG} & \multicolumn{1}{c}{0.1237} & \multicolumn{1}{c}{0.2232} & \multicolumn{1}{c}{0.3012} & 0.3456 & \multicolumn{1}{c}{0.0658} & \multicolumn{1}{c}{0.1241} & \multicolumn{1}{c}{0.1807} & 0.2218 \\
\multicolumn{1}{|c|}{infomap} & \multicolumn{1}{c}{0.1259} & \multicolumn{1}{c}{0.2166} & \multicolumn{1}{c}{0.2967} & 0.3441 & \multicolumn{1}{c}{0.0715} & \multicolumn{1}{c}{0.1274} & \multicolumn{1}{c}{0.1811} & 0.2225 \\
\multicolumn{1}{|c|}{tf-idf} & \multicolumn{1}{c}{0.2477} & \multicolumn{1}{c}{0.2708} & \multicolumn{1}{c}{0.2945} & 0.3217 & \multicolumn{1}{c}{0.1093} & \multicolumn{1}{c}{0.1539} & \multicolumn{1}{c}{0.1868} & 0.2180 \\
\multicolumn{1}{|c|}{KMeans} & \multicolumn{1}{c}{0.3596} & \multicolumn{1}{c}{0.3835} & \multicolumn{1}{c}{0.3929} & 0.3925
& \multicolumn{1}{c}{0.1335} & \multicolumn{1}{c}{0.1921} & \multicolumn{1}{c}{0.2280} & 0.2499 \\ \hline
& \multicolumn{4}{c|}{\textbf{Yake}} & \multicolumn{4}{c|}{\textbf{TextRank}} \\ \hline
\multicolumn{1}{|c|}{\textbf{method}} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} \\ \hline
\multicolumn{1}{|c|}{multilevel} & \multicolumn{1}{c}{0.1553} & \multicolumn{1}{c}{0.2536} & \multicolumn{1}{c}{0.3242} & 0.3650 & \multicolumn{1}{c}{0.1138} & \multicolumn{1}{c}{0.1689} & \multicolumn{1}{c}{0.2101} & 0.2326 \\
\multicolumn{1}{|c|}{labelProp} & \multicolumn{1}{c}{0.1362} & \multicolumn{1}{c}{0.2290} & \multicolumn{1}{c}{0.2997} & 0.3481 & \multicolumn{1}{c}{0.0967} & \multicolumn{1}{c}{0.1594} & \multicolumn{1}{c}{0.2012} & 0.2260 \\
\multicolumn{1}{|c|}{leiden} & \multicolumn{1}{c}{0.1509} & \multicolumn{1}{c}{0.2516} & \multicolumn{1}{c}{0.3226} & 0.3633 & \multicolumn{1}{c}{0.0986} & \multicolumn{1}{c}{0.1673} & \multicolumn{1}{c}{0.2090} & 0.2319 \\
\multicolumn{1}{|c|}{fastG} & \multicolumn{1}{c}{0.1448} & \multicolumn{1}{c}{0.2485} & \multicolumn{1}{c}{0.3256} & 0.3653 & \multicolumn{1}{c}{0.1172} & \multicolumn{1}{c}{0.1818} & \multicolumn{1}{c}{0.2184} & 0.2356 \\
\multicolumn{1}{|c|}{infomap} & \multicolumn{1}{c}{0.1400} & \multicolumn{1}{c}{0.2309} & \multicolumn{1}{c}{0.3153} & 0.3616 & \multicolumn{1}{c}{0.0829} & \multicolumn{1}{c}{0.1503} & \multicolumn{1}{c}{0.2034} & 0.2302 \\
\multicolumn{1}{|c|}{tf-idf} & \multicolumn{1}{c}{0.2905} & \multicolumn{1}{c}{0.2937} & \multicolumn{1}{c}{0.3091} & 0.3353 & \multicolumn{1}{c}{0.1381} & \multicolumn{1}{c}{0.1492} & \multicolumn{1}{c}{0.1703} & 0.1951 \\
\multicolumn{1}{|c|}{KMeans} & \multicolumn{1}{c}{0.4221} & \multicolumn{1}{c}{0.4190} & \multicolumn{1}{c}{0.4194} & 0.4121 & \multicolumn{1}{c}{0.2132} & \multicolumn{1}{c}{0.2337} & \multicolumn{1}{c}{0.2459} & 0.2479 \\ \hline
& \multicolumn{4}{c|}{\textbf{BERT}} & \multicolumn{4}{c|}{\textbf{Voting System}}\\ \hline
\multicolumn{1}{|c|}{\textbf{method}} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} \\ \hline
\multicolumn{1}{|c|}{multilevel} & \multicolumn{1}{c}{0.0573} & \multicolumn{1}{c}{0.0924} & \multicolumn{1}{c}{0.1254} & 0.1501 & \multicolumn{1}{c}{0.1231} & \multicolumn{1}{c}{0.1925} & \multicolumn{1}{c}{0.2688} & 0.3283 \\
\multicolumn{1}{|c|}{labelProp} & \multicolumn{1}{c}{0.0710} & \multicolumn{1}{c}{0.0936} & \multicolumn{1}{c}{0.1221} & 0.1462 & \multicolumn{1}{c}{0.1108} & \multicolumn{1}{c}{0.1758} & \multicolumn{1}{c}{0.2485} & 0.3123 \\
\multicolumn{1}{|c|}{leiden} & \multicolumn{1}{c}{0.0757} & \multicolumn{1}{c}{0.1092} & \multicolumn{1}{c}{0.1325} & 0.1518 & \multicolumn{1}{c}{0.1325} & \multicolumn{1}{c}{0.2003} & \multicolumn{1}{c}{0.2716} & 0.3274 \\
\multicolumn{1}{|c|}{fastG} & \multicolumn{1}{c}{0.0739} & \multicolumn{1}{c}{0.0965} & \multicolumn{1}{c}{0.1257} & 0.1494 & \multicolumn{1}{c}{0.1300} & \multicolumn{1}{c}{0.1941} & \multicolumn{1}{c}{0.2702} & 0.3280 \\
\multicolumn{1}{|c|}{infomap} & \multicolumn{1}{c}{0.0596} & \multicolumn{1}{c}{0.0938} & \multicolumn{1}{c}{0.1261} & 0.1483 & \multicolumn{1}{c}{0.1115} & \multicolumn{1}{c}{0.1826} & \multicolumn{1}{c}{0.2633} & 0.3251 \\
\multicolumn{1}{|c|}{tf-idf} & \multicolumn{1}{c}{0.0899} & \multicolumn{1}{c}{0.1043} & \multicolumn{1}{c}{0.1207} & 0.1394 & \multicolumn{1}{c}{0.1891} & \multicolumn{1}{c}{0.2280} & \multicolumn{1}{c}{0.2687} & 0.3070 \\
\multicolumn{1}{|c|}{KMeans} & \multicolumn{1}{c}{0.1804} & \multicolumn{1}{c}{0.1668} & \multicolumn{1}{c}{0.1688} & 0.1726 & \multicolumn{1}{c}{0.2761} & \multicolumn{1}{c}{0.3110} & \multicolumn{1}{c}{0.3531} & 0.3746 \\ \hline
\end{tabular}
\end{table}
\begin{table}[h!]
\caption{Accuracy obtained from the evaluation of keyword extraction methods for short texts (paper abstracts). Here we considered as reference keywords the most important words found by the \emph{network-based} methods for the full content of the papers. $N$ is the number of top keywords we recovered for both short and long texts keyword extraction methods.}
\label{tab:accuracy_network}
\begin{tabular}{c|cccc|cccc|}
\cline{2-9} & \multicolumn{4}{c|}{\textbf{Degree}} & \multicolumn{4}{c|}{\textbf{PageRank}} \\ \hline
\multicolumn{1}{|c|}{\textbf{method}} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} \\ \hline
\multicolumn{1}{|c|}{multilevel} & \multicolumn{1}{c}{0.1605} & \multicolumn{1}{c}{0.2490} & \multicolumn{1}{c}{0.3149} & 0.3539 & \multicolumn{1}{c}{0.1622} & \multicolumn{1}{c}{0.2498} & \multicolumn{1}{c}{0.3153} & 0.3514 \\
\multicolumn{1}{|c|}{labelProp} & \multicolumn{1}{c}{0.1324} & \multicolumn{1}{c}{0.2234} & \multicolumn{1}{c}{0.2903} & 0.3374 & \multicolumn{1}{c}{0.1329} & \multicolumn{1}{c}{0.2247} & \multicolumn{1}{c}{0.2899} & 0.3349 \\
\multicolumn{1}{|c|}{leiden} & \multicolumn{1}{c}{0.1417} & \multicolumn{1}{c}{0.2421} & \multicolumn{1}{c}{0.3125} & 0.3522 & \multicolumn{1}{c}{0.1428} & \multicolumn{1}{c}{0.2429} & \multicolumn{1}{c}{0.3120} & 0.3494 \\
\multicolumn{1}{|c|}{fastG} & \multicolumn{1}{c}{0.1466} & \multicolumn{1}{c}{0.2496} & \multicolumn{1}{c}{0.3195} & 0.3549 & \multicolumn{1}{c}{0.1481} & \multicolumn{1}{c}{0.2510} & \multicolumn{1}{c}{0.3194} & 0.3523 \\
\multicolumn{1}{|c|}{infomap} & \multicolumn{1}{c}{0.1256} & \multicolumn{1}{c}{0.2152} & \multicolumn{1}{c}{0.3002} & 0.3476 & \multicolumn{1}{c}{0.1247} & \multicolumn{1}{c}{0.2146} & \multicolumn{1}{c}{0.2979} & 0.3445 \\
\multicolumn{1}{|c|}{tf-idf} & \multicolumn{1}{c}{0.2529} & \multicolumn{1}{c}{0.2546} & \multicolumn{1}{c}{0.2757} & 0.3085 & \multicolumn{1}{c}{0.2516} & \multicolumn{1}{c}{0.2521} & \multicolumn{1}{c}{0.2725} & 0.3043 \\
\multicolumn{1}{|c|}{KMeans} & \multicolumn{1}{c}{0.4047} & \multicolumn{1}{c}{0.3989} & \multicolumn{1}{c}{0.4010} & 0.3948 & \multicolumn{1}{c}{0.4070} & \multicolumn{1}{c}{0.3998} & \multicolumn{1}{c}{0.3999} & 0.3920 \\ \hline
& \multicolumn{4}{c|}{\textbf{Betweenness}} & \multicolumn{4}{c|}{\textbf{Eigenvector}} \\ \hline
\multicolumn{1}{|c|}{\textbf{method}} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} \\ \hline
\multicolumn{1}{|c|}{multilevel} & \multicolumn{1}{c}{0.1563} & \multicolumn{1}{c}{0.2281} & \multicolumn{1}{c}{0.2809} & 0.3127 & \multicolumn{1}{c}{0.1484} & \multicolumn{1}{c}{0.2385} & \multicolumn{1}{c}{0.3008} & 0.3385 \\
\multicolumn{1}{|c|}{labelProp} & \multicolumn{1}{c}{0.1255} & \multicolumn{1}{c}{0.2021} & \multicolumn{1}{c}{0.2571} & 0.2973 & \multicolumn{1}{c}{0.1253} & \multicolumn{1}{c}{0.2136} & \multicolumn{1}{c}{0.2787} & 0.3238 \\
\multicolumn{1}{|c|}{leiden} & \multicolumn{1}{c}{0.1356} & \multicolumn{1}{c}{0.2202} & \multicolumn{1}{c}{0.2774} & 0.3099 & \multicolumn{1}{c}{0.1343} & \multicolumn{1}{c}{0.2315} & \multicolumn{1}{c}{0.2994} & 0.3370 \\
\multicolumn{1}{|c|}{fastG} & \multicolumn{1}{c}{0.1392} & \multicolumn{1}{c}{0.2272} & \multicolumn{1}{c}{0.2836} & 0.3134 & \multicolumn{1}{c}{0.1387} & \multicolumn{1}{c}{0.2373} & \multicolumn{1}{c}{0.3031} & 0.3393 \\
\multicolumn{1}{|c|}{infomap} & \multicolumn{1}{c}{0.1125} & \multicolumn{1}{c}{0.1855} & \multicolumn{1}{c}{0.2596} & 0.3028 & \multicolumn{1}{c}{0.1239} & \multicolumn{1}{c}{0.2120} & \multicolumn{1}{c}{0.2921} & 0.3346 \\
\multicolumn{1}{|c|}{tf-idf} & \multicolumn{1}{c}{0.2291} & \multicolumn{1}{c}{0.2255} & \multicolumn{1}{c}{0.2387} & 0.2661 & \multicolumn{1}{c}{0.2490} & \multicolumn{1}{c}{0.2522} & \multicolumn{1}{c}{0.2726} & 0.3021 \\
\multicolumn{1}{|c|}{KMeans} & \multicolumn{1}{c}{0.3828} & \multicolumn{1}{c}{0.3656} & \multicolumn{1}{c}{0.3574} & 0.3503 & \multicolumn{1}{c}{0.3865} & \multicolumn{1}{c}{0.3844} & \multicolumn{1}{c}{0.3847} & 0.3797 \\ \hline
& \multicolumn{4}{c|}{\textbf{Closeness}} & \multicolumn{4}{c|}{\textbf{Accessibility (h=1)}} \\ \hline
\multicolumn{1}{|c|}{\textbf{method}} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} \\ \hline
\multicolumn{1}{|c|}{multilevel} & \multicolumn{1}{c}{0.1585} & \multicolumn{1}{c}{0.2438} & \multicolumn{1}{c}{0.3066} & 0.3426 & \multicolumn{1}{c}{0.1605} & \multicolumn{1}{c}{0.2490} & \multicolumn{1}{c}{0.3149} & 0.3539 \\
\multicolumn{1}{|c|}{labelProp} & \multicolumn{1}{c}{0.1317} & \multicolumn{1}{c}{0.2198} & \multicolumn{1}{c}{0.2855} & 0.3278 & \multicolumn{1}{c}{0.1324} & \multicolumn{1}{c}{0.2234} & \multicolumn{1}{c}{0.2903} & 0.3374 \\
\multicolumn{1}{|c|}{leiden} & \multicolumn{1}{c}{0.1390} & \multicolumn{1}{c}{0.2373} & \multicolumn{1}{c}{0.3052} & 0.3411 & \multicolumn{1}{c}{0.1417} & \multicolumn{1}{c}{0.2421} & \multicolumn{1}{c}{0.3125} & 0.3522 \\
\multicolumn{1}{|c|}{fastG} & \multicolumn{1}{c}{0.1461} & \multicolumn{1}{c}{0.2446} & \multicolumn{1}{c}{0.3096} & 0.3431 & \multicolumn{1}{c}{0.1466} & \multicolumn{1}{c}{0.2496} & \multicolumn{1}{c}{0.3195} & 0.3549 \\
\multicolumn{1}{|c|}{infomap} & \multicolumn{1}{c}{0.1209} & \multicolumn{1}{c}{0.2127} & \multicolumn{1}{c}{0.2932} & 0.3367 & \multicolumn{1}{c}{0.1256} & \multicolumn{1}{c}{0.2152} & \multicolumn{1}{c}{0.3002} & 0.3476 \\
\multicolumn{1}{|c|}{tf-idf} & \multicolumn{1}{c}{0.2478} & \multicolumn{1}{c}{0.2499} & \multicolumn{1}{c}{0.2717} & 0.3019 & \multicolumn{1}{c}{0.2529} & \multicolumn{1}{c}{0.2546} & \multicolumn{1}{c}{0.2757} & 0.3085 \\
\multicolumn{1}{|c|}{KMeans} & \multicolumn{1}{c}{0.3936} & \multicolumn{1}{c}{0.3883} & \multicolumn{1}{c}{0.3891 } & 0.3828 & \multicolumn{1}{c}{0.4047} & \multicolumn{1}{c}{0.3989} & \multicolumn{1}{c}{0.4010} & 0.3948 \\ \hline
& \multicolumn{4}{c|}{\textbf{Accessibility(h=2)}} & \multicolumn{4}{c|}{\textbf{Voting System}}\\ \hline
\multicolumn{1}{|c|}{\textbf{method}} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} & \multicolumn{1}{c}{\textbf{N=10}} & \multicolumn{1}{c}{\textbf{N=20}} & \multicolumn{1}{c}{\textbf{N=30}} & \textbf{N=40} \\ \hline
\multicolumn{1}{|c|}{multilevel} & \multicolumn{1}{c}{0.1196} & \multicolumn{1}{c}{0.1943} & \multicolumn{1}{c}{0.2526} & 0.2904 & \multicolumn{1}{c}{0.1605} & \multicolumn{1}{c}{0.2481} & \multicolumn{1}{c}{0.3141} & 0.3535 \\
\multicolumn{1}{|c|}{labelProp} & \multicolumn{1}{c}{0.1048} & \multicolumn{1}{c}{0.1744} & \multicolumn{1}{c}{0.2338} & 0.2777 & \multicolumn{1}{c}{0.1324} & \multicolumn{1}{c}{0.2226} & \multicolumn{1}{c}{0.2909} & 0.3377 \\
\multicolumn{1}{|c|}{leiden} & \multicolumn{1}{c}{0.1088} & \multicolumn{1}{c}{0.1869} & \multicolumn{1}{c}{0.2508} & 0.2894 & \multicolumn{1}{c}{0.1426} & \multicolumn{1}{c}{0.2408} & \multicolumn{1}{c}{0.3119} & 0.3522 \\
\multicolumn{1}{|c|}{fastG} & \multicolumn{1}{c}{0.1108} & \multicolumn{1}{c}{0.1909} & \multicolumn{1}{c}{0.2519} & 0.2899 & \multicolumn{1}{c}{0.1464} & \multicolumn{1}{c}{0.2487} & \multicolumn{1}{c}{0.3175} & 0.3548 \\
\multicolumn{1}{|c|}{infomap} & \multicolumn{1}{c}{0.0997} & \multicolumn{1}{c}{0.1740} & \multicolumn{1}{c}{0.2419} & 0.2855 & \multicolumn{1}{c}{0.1255} & \multicolumn{1}{c}{0.2147} & \multicolumn{1}{c}{0.3001} & 0.3479 \\
\multicolumn{1}{|c|}{tf-idf} & \multicolumn{1}{c}{0.1977} & \multicolumn{1}{c}{0.2125} & \multicolumn{1}{c}{0.2344} & 0.2638 & \multicolumn{1}{c}{0.2536} & \multicolumn{1}{c}{0.2546} & \multicolumn{1}{c}{0.2759} & 0.3093 \\
\multicolumn{1}{|c|}{KMeans} & \multicolumn{1}{c}{0.3162} & \multicolumn{1}{c}{0.3167} & \multicolumn{1}{c}{0.3236} & 0.3264 & \multicolumn{1}{c}{0.4039} & \multicolumn{1}{c}{0.3963} & \multicolumn{1}{c}{0.3985 } & 0.3952 \\ \hline
\end{tabular}
\end{table}
\newpage
\bibliographystyle{ieeetr}
\bibliographystyle{abbrv}
| {'timestamp': '2023-01-18T02:14:37', 'yymm': '2301', 'arxiv_id': '2301.06168', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06168'} | arxiv |
\section{Introduction}
With the widespread adoption of vehicular automation technologies in today's vehicles, automobile manufacturers are becoming a centralized data monopoly, as they collect data produced by consumers' vehicles but grant only limited data access to consumers. This phenomenon, with rising numbers of reports and investigations on vehicular technology malfunctions~\cite{carinsurance, nhtsareport, teslascrahes, telsadrivelesscrash, waymoscrashes}, puts data integrity in jeopardy and has imposed difficulties on regulators and legal systems~\cite{americanbar, pattinson2020legal}.
In particular, in the event of an accident, legal responsibility between vehicle and driver is hard to delineate when the only source of data comes from a monopoly~\cite{pattinson2020legal}.
Unsurprisingly, recent years have seen surging worldwide disputes and protests against monopolizers, especially when consumers suspect vehicle defects and malfunctions~\cite{teslashprotest1, teslashprotest2, yourcaryourdatayourchoice}. In recent surveys, data integrity and transparency have topped consumer concerns about automation technologies~\cite{huff2021tell, abraham2016autonomous}, and many related stakeholders, including insurers~\cite{datamonopolygerman} and lawmakers~\cite{legislation}, have kept calling for ending data monopolies with transparent data management.
It is crucial to provide evidence-based assurance that vehicular automation technologies behave as intended (e.g., speed, direction, and decisions of autonomous driving systems) without a single party monopolizing data management. Pursuant to this goal, blockchain automotive solutions have been demanded by vehicle-to-everything (V2X) networks~\cite{cnbcbc, forbesbcautomotive, qadbcautomotive}, as their decentralization nature intrinsically breaks a data monopoly and avoids manipulation from a single source of “truth”.
In particular, since vehicles are manufactured with identities, permissioned blockchains, which scrutinize the identity of their participants, have been favored for achieving deterministic consensus with high performance~\cite{ibmblockchain, limechain}. Many blockchain initiatives have been launched by leading automobile manufacturers, such as BMW~\cite{bmwbc}, Mercedes~\cite{mercedesbc, forbesmercedesbc}, Volkswagen~\cite{vwbc1, vwbc2}, Toyota~\cite{toyotabc}, and Ford~\cite{forbesmercedesbc1, forbesmercedesbc2}.
\subsection{Why a new blockchain?}
The architecture of traditional permissioned blockchains (e.g., HyperLedger Fabric~\cite{androulaki2018hyperledger}, CCF~\cite{russinovich2019ccf}, and Diem~\cite{diem2020}) is designed to \emph{operate in a stable environment}, where each server is set up with a predefined membership profile (configuration), which often contains a static set of servers. When a membership change takes place (e.g., new servers join or old servers leave), the consensus algorithms (e.g., PBFT~\cite{castro1999practical} and HotStuff~\cite{yin2019hotstuff}) must stop to update the membership profile on each server. They suspend any ongoing consensus service and use additional reconfiguration approaches (e.g., MC~\cite{rodrigues2010automatic} and Lazarus~\cite{garcia2019lazarus}) to manage membership changes~\cite{lamport2010reconfiguring, martin2004framework}. After the reconfiguration succeeds, the consensus service resumes with the new membership profile. This suspend-and-update method that imposes a ``hard stop'' on transaction consensus could be acceptable when membership changes are infrequent, such as blockchains for enterprise collaboration and supply chains. Unfortunately, it cannot satisfy the use for blockchains in V2X, as vehicles' arbitrary connectivity will inevitably result in frequent membership changes~\cite{garcia2021tutorial, v2xconnectivity}.
While V2X networks connect vehicles to everything, they cannot guarantee stable connections among members in a system~\cite{qualcommv2x}. A running vehicle's surrounding vehicles will change dynamically on the roads and may become online and offline at any given time. Thus, this unpredictable connectivity will result in frequent membership changes. While traditional permissioned blockchains designed to operate on a static set of servers can use reconfiguration approaches to update membership, they suffer from significant performance degradation~\cite{duan2022foundations, lorch2006smart}. For example, an MC~\cite{rodrigues2010automatic} reconfiguration takes around $10$-$20$ seconds to complete a membership change.
The additional costs incurred by membership management can become significant under high system workloads and large scales~\cite{abraham2016solida, rodrigues2010automatic, bessani2020byzantine}. Therefore, blockchains for V2X networks are urgently in need of new solutions that can achieve consensus seamlessly during membership changes without impeding ongoing consensus.
\subsection{V-Guard\xspace for membership dynamicity}
To tackle the challenges, we introduce V-Guard\xspace, a permissioned blockchain architecture equipped with a new consensus algorithm, targeting the problem of achieving efficient consensus under dynamic memberships in V2X networks. In contrast to separating the management of membership changes and transaction consensus as in traditional BFT consensus algorithms (e.g., PBFT~\cite{castro1999practical} and HotStuff~\cite{yin2019hotstuff}), V-Guard\xspace integrates the agreement of membership configurations into each transaction consensus process. Thus, it delivers paired consensus results of traceable and immutable data entry records and their corresponding membership configurations.
V-Guard\xspace uses a membership management unit (MMU) to manage dynamic membership configurations. The MMU keeps track of available vehicles as potential members and includes them in different sets; it thus prepares a queue of membership configuration profiles, namely \emph{booths}, and provides an interface to consensus services. In each consensus instance, a data entry is paired with a provided booth in both the ordering and consensus phases. When the current booth becomes unavailable, the consensus instance acquires a new booth from the MMU. Consequently, V-Guard\xspace not only reaches agreement on what data is committed but also what booth (vehicles) committed the data.
In addition, since vehicle data produced by different sensors is often transactionally unrelated, V-Guard\xspace allows concurrent ordering for data by separating ordering from consensus, where the ordering and consensus phases can take place in different booths. The ordering phase concurrently appends data entries to a total order log, and the consensus phase periodically commits the ordered entries to an immutable ledger. This separation also empowers V-Guard\xspace to manage the memberships in a more granular way: a date entry can be ordered and committed in different booths; that is, consensus can be achieved seamlessly in dynamic memberships.
We implemented V-Guard\xspace and evaluated its performance under both static and dynamic memberships. V-Guard\xspace achieved high consensus throughput and low latency. For example, with a membership size of $n=4$, V-Guard\xspace achieved a peak consensus throughput of $765,930$~TPS (transactions per second) at a latency of $143$~ms under static membership and $615,328$ TPS at $1324$~ms under dynamic memberships.
To summarize, V-Guard\xspace has the following novel features.
\begin{itemize}
\item It achieves consensus seamlessly during membership changes without impeding transaction consensus. It integrates membership management into each phase of the consensus process, targeting the problem of frequent membership changes in blockchains for V2X networks.
\item It separates ordering from consensus and thus enables concurrent data ordering, reducing ordering latency and messaging costs. The separation also empowers data entries to be ordered (ordering) and committed (consensus) in different memberships.
\item Its implementation achieves high performance in terms of throughput and latency in both static and dynamic memberships. The implementation is open-source and available at \url{https://github.com/vguardbc/vguardbft}.
\end{itemize}
\section{V-Guard overview}
V-Guard\xspace provides a blockchain service among vehicles and their manufacturers to avoid a single point of control of data. To apply this service, a vehicle creates a V-Guard\xspace instance and starts to operate as a \emph{proposer}. The vehicle can also join other vehicles' instances by operating as a \emph{validator}. Each V-Guard\xspace instance must include at least four members: the proposer, automobile manufacturer (a.k.a., pivot validator), and other (at least two) vehicles (a.k.a., vehicle validators). The description of the roles is presented below.
\begin{description}
\item[Proposer ($V_p$).] Each vehicle is the proposer of its own V-Guard\xspace instance, so \emph{each instance has only one proposer}. The proposer operates as a leader in its V-Guard\xspace instance: it proposes data to validators and coordinates consensus for proposed data among validators.
\item[Validator.] In a V-Guard\xspace instance, except the proposer, other members operate as a validator. The automobile manufacturer always operates as a \textbf{pivot validator} (denoted by $V_{\pi}$), and the other vehicles operate as \textbf{vehicle validators} (denoted by $V_i$).
\end{description}
A vehicle may participate in multiple V-Guard\xspace instances simultaneously: it operates as the proposer of its own V-Guard\xspace instance and as a validator in other vehicles' V-Guard\xspace instances. We denote the number of instances a vehicle joins as \emph{catering factor}, $\gamma$.
\begin{description}
\item[Catering factor ($\gamma$).] The catering factor ($\gamma \in \mathbb{Z}^+$) of a vehicle describes the number of V-Guard\xspace instances this vehicle is currently participating in. It changes correspondingly when the vehicle joins and quits other vehicles' V-Guard\xspace instances.
\end{description}
\begin{figure}[t]
\centering
\includegraphics[width=0.95\linewidth]{figures/vgframwork.pdf}
\caption{V-Guard\xspace architecture. The consensus module operates in ordering and consensus instances interacting with the MMU. Committed data are stored in the storage module and further disseminated through the gossip module.}
\label{fig:vgframework}
\end{figure}
V-Guard\xspace operates as a middleware system that is independent of its residing automotive operating system. It takes input from the vehicle's infrastructure layer for data collection (e.g., from sensors and monitoring devices), communicates with other vehicles, and provides a blockchain service that underpins distributed applications in V2X networks. In general, as shown in Figure~\ref{fig:vgframework}, a V-Guard\xspace instance consists of two core modules of consensus and storage and an optional module of gossiping (not required for correctness).
\begin{itemize}
\item The consensus module coordinates consensus for collected data entries (\S~\ref{sec:consensus-module}). The proposer uses its membership management unit (MMU) to obtain a valid membership (\S~\ref{sec:boothcomposer}). Then, it starts an ordering instance to coordinate with other validators in the obtained configuration and secures a unique ordering ID for the data entries (\S~\ref{sec:ordering}). When a consensus instance, periodically scheduled with its own membership configuration, commits the ordered entries, the consensus is achieved (\S~\ref{sec:consensus}).
\item The gossip module is pluggable, with no effect on system correctness (\S~\ref{sec:gossiping}). It aims to increase robustness by further disseminating and replicating committed data entries to more vehicles in the network.
\item The storage module stores data entries committed in the consensus module (\S~\ref{sec:storage}). It temporarily stores all entries by default according to a predefined policy (e.g., for $24$ hours) and provides an option for users or applications to permanently store selected data.
\end{itemize}
\section{System model}
\label{sec:system-model}
V-Guard is a permissioned blockchain, which requires identity information from members; i.e., each vehicle can identify who they are communicating with. Since vehicles are manufactured with identities\footnote{Vehicle identification numbers (VIN)~\cite{vin} serve as vehicles' fingerprint, as no two vehicles in operation have the same VIN.}, this standard practice of permissioned blockchains is viable in practice.
\textit{Service properties.} V-Guard\xspace's blockchain architecture provides evidence-based assurance that vehicles behave as intended. For example, it can be used to record the decision-making data produced by applied automation technologies. \textbf{V-Guard\xspace provides two guarantees: no party can \circle<1> fabricate evidence or \circle<2> bury evidence.}
Data entries are ordered and committed by quorums of independent vehicles with their signatures. After consensus is reached, data entries are traceable and immutable.
Furthermore, neither the proposer nor the consensus pivot can bury evidence by claiming data loss because each committed data entry is consistently stored in vehicles included in the consensus process.
\emph{Network assumptions.}
V-Guard\xspace does not rely on network synchrony to ensure safety but requires \emph{partial synchrony} for liveness; i.e., message delivery and message processing times between two vehicles are bounded by a delay after an unknown global stabilization time (GST). The network may fail to deliver messages, delay them, duplicate them, or deliver them out of order.
\emph{Fault tolerance.} V-Guard\xspace assumes a Byzantine failure model where faulty members may behave arbitrarily, subject only to independent member failures. Each member is an independent entity, as V-Guard\xspace runs independently regardless of its underlying operating system; that is, when $f$ vehicles, regardless of their manufacturers, are faulty (individual or colluding), they are counted as $f$ failures.
Note that a vehicle's behavior may not be universal when participating in multiple V-Guard\xspace instances ($\gamma >1$); i.e., it could operate correctly in one instance and falsely in another one.
In addition, we do not consider junk-pouring attacks (e.g., DDoS attacks) from faulty members, as such behavior can not be handled by consensus algorithms alone. They can often be handled at lower levers, such as rate controls and blacklist methods.
\emph{Cryptographic primitives.} V-Guard\xspace applies ($t$, $n$)-threshold signatures where $t$ out of $n$ members can collectively sign a message~\cite{shoup2000practical, libert2016born}. Threshold signatures can convert $t$ partially signed messages (of size $O(n)$) into one fully signed message (of size $O(1)$). The fully signed message can then be verified by all $n$ members, proving that $t$ members have signed it. The reduction in message size has made threshold signatures commonly used in state-of-the-art linear BFT protocols, such as HotStuff~\cite{yin2019hotstuff}, SBFT~\cite{gueta2019sbft}, and Prosecutor~\cite{zhang2021prosecutor}.
\emph{A note on changing members.} Similar to other BFT protocols, V-Guard\xspace requires a minimum quorum size of $2f+1$ to tolerate $f$ Byzantine failures in a total of $n = 3f+1$ members. Since V-Guard\xspace is designed to provide an evidence chain for vehicles and their manufacturers, we always include the vehicle's manufacturer (i.e., pivot validator) as a member during membership changes; thus, a new booth can have up to $n-2$ new members, and both the proposer and pivot validator can witness the agreement of ordering and committing raw data.
\section{The V-Guard consensus protocol}
\label{sec:consensus-module}
This section presents the V-Guard\xspace consensus protocol in detail. As shown in Figure~\ref{fig:vguard-consensus}, V-Guard\xspace has two types of services: \emph{event-driven} and \emph{daemon} services. Event-driven services are invoked when data is collected. Their orchestration achieves consensus for the collected data and forms a blockchain recording data and membership information. Daemon services handle network connections by dynamically connecting to and disconnecting from vehicles according to their availability.
\begin{figure*}[t]
\centering
\includegraphics[width=\linewidth]{figures/vguard-consensus.pdf}
\caption{V-Guard\xspace workflow. The MMU prepares a queue of booths for ordering and consensus instances. Ordering instances concurrently append collected data entries to a total order log. Consensus instances aggregate ordered entries into transactions and commit them periodically. Committed transactions can be further disseminated to other connected vehicles through gossiping.}
\label{fig:vguard-consensus}
\end{figure*}
\subsection{Membership management unit (MMU)}
\label{sec:boothcomposer}
The MMU keeps track of available vehicle connections in the network and prepares a queue of valid \textit{booths} (shown in Figure~\ref{fig:vguard-consensus} \textcolor{green!80!black}{D1}; examples with animations can be found on V-Guard\xspace's GitHub page~\cite{vguardsource}). A booth, denoted by $\mathcal{V}$, is a \emph{membership configuration profile} that describes a set of participating members (vehicles). The profile contains vehicles' information of their network addresses and public keys. The size of each booth is a predefined parameter established in the system setup. A valid booth must include the proposer ($V_p$), pivot validator ($V_{\pi}$), and the other vehicles as vehicle validators. Since V-Guard\xspace assumes BFT failures, the minimum size of a booth is four ($3f{+}1$) to tolerate $f{=}1$ Byzantine failure~\cite{fischer1986easy}.
The MMU interface provides available booths for ordering and consensus instances (denoted by $\mathcal{V}_o$ and $\mathcal{V}_c$, respectively). If there is no booth available in the queue (e.g., when the vehicle has no network connection in a tunnel), the ordering and consensus instances wait for new booths from the interface. In addition, the MMU dynamically manages booths based on their availability and efficiency. It removes a booth from the queue when $f$ vehicles in the booth become unavailable. It also periodically pings the other vehicles and puts the booth with the lowest network latency on the top of the queue.
\subsection{Ordering -- Form a total order log}
\label{sec:ordering}
The ordering phase secures a unique sequence number (order) for each data batch on a total order log. V-Guard\xspace separates the ordering of data batches from consensus. The separation enables a non-blocking ordering procedure in which the ordering of a data batch does not wait for the completion of the consensus of its prior batch. The separation also allows ordering and consensus to be conducted in different booths during membership changes. The two features make V-Guard\xspace more applicable and efficient in V2X networks where vehicles are connected over unstable networks.
\textbf{The ordering phase instances append log entries to a total order log showing that \circle<1> what data is agreed upon in \circle<2> what order and by \circle<3> what vehicle membership.}
Specifically, first, the proposer starts an ordering instance when collected data reaches their predefined batch sizes (denoted by $\beta$). Then, the ordering instance distributes data batches collected from the proposer to all validators, including the pivot and vehicles (``what data''); the proposer assigns each data batch with a unique ordering ID (i.e., the sequence number) (``what order'') and a membership configuration that indicates which validators agree on the ordering ID as a quorum (``what membership''). We describe the workflow of an ordering phase instance for a data batch as follows.
\setdefaultleftmargin{0.6cm}{0.6cm}{0.3cm}{}{}{}
\begin{enumerate}
\renewcommand{\labelenumi}{\textbf{O\arabic{enumi}}}
\item \label{ordering:1}
The proposer $V_p$ assigns a unique sequence number (denoted by $i$) as the ordering ID (denoted by $O_i$) to a data batch (denoted by $\mathcal{B}_i$) and starts an ordering instance.
\begin{enumerate}
\item $V_p$ confirms with the MMU that the booth for this ordering instance ($\mathcal{V}_o$) is available and up-to-date; if not, it invokes the MMU to get a new $\mathcal{V}_o$.
\item $V_p$ sends $\langle \texttt{Pre-Order}, \mathcal{B}_i, h_{\mathcal{B}_i}, \mathcal{V}_o, h_{\mathcal{V}_o}, i, \sigma_{V_p} \rangle$ to all members in $\mathcal{V}_o$, where $h_{\mathcal{B}_i}$ is the hash of $\mathcal{B}_i$; $h_{\mathcal{V}_o}$ is the hash of $\mathcal{V}_o$; and $\sigma_{V_p}$ is the signature that $V_p$ signs the combination of $i$, $h_{\mathcal{B}_i}$, and $h_{\mathcal{V}_o}$.
\item $V_p$ creates a set $\mathcal{R}_{o}$, waiting for replies from validators in $\mathcal{V}_o$.
\end{enumerate}
\item \label{ordering:2}
After receiving a \texttt{Pre-Order} message, $V_i$ first verifies the message and then replies to $V_p$. The verification succeeds when \circle<1> $h_B$ and $h_{\mathcal{V}_o}$ match the hashes of $B$ and $\mathcal{V}_o$, respectively; \circle<2> $\sigma_{V_p}$ is valid; and \circle<3> $i$ has not been used. If the verification succeeds, $V_i$ then sends $\langle \texttt{PO-Reply}, i, \sigma_{V_i} \rangle$ to $V_p$, where $\sigma_{V_i}$ is the signature that $V_i$ signs the combination of $i$, $h_B$, and $h_{\mathcal{V}_o}$.
\item \label{ordering:3}
$V_p$ collects \texttt{PO-Reply} messages from validators and adds them to $\mathcal{R}_{o}$ until it receives $2f$ replies (i.e., $|\mathcal{R}_{o}| = 2f$); then, $V_p$ takes the following actions.
\begin{enumerate}
\item $V_p$ converts the $2f$ collected signatures (i.e., $\sigma_{V_i}$ in $\mathcal{R}_{o}$) to a ($t$, $n$)-threshold signature, $\sigma_{o_i}$, where $t=2f$.
\item $V_p$ creates a subset $\mathcal{Q}_{o_i}$ including the $2f$ vehicles, the signatures of which are converted to $\sigma_{o_i}$, from $\mathcal{V}_o$ as a membership quorum; i.e., $|\mathcal{Q}_{o_i}|=2f \land \mathcal{Q}_{o_i} \subset \mathcal{V}_o$.
\item $V_p$ sends $\langle \texttt{Order}, i, \mathcal{Q}_{o_i}, \sigma_{o_i} \rangle$ to all members in $\mathcal{V}_o$.
\end{enumerate}
$V_p$ now considers batch $\mathcal{B}_i$ ordered with ordering ID $O_i$ ($O_i=i$) by the quorum $\mathcal{Q}_{o_i}$ of the members from $\mathcal{V}_o$. It appends $\langle O_i, \mathcal{B}_i, \mathcal{Q}_{o_i}, \mathcal{V}_o, \sigma_{o_i} \rangle$ to the total order log.
\item \label{ordering:4}
After receiving an \texttt{Order} message, $V_i$ verifies it by three criteria:
\circle<1> $\sigma_{o_i}$ is valid with a threshold of $2f$ (correct quorum sizes);
\circle<2> signers of $\sigma_{o_i}$ match $\mathcal{Q}_{o_i}$ (valid validators);
and \circle<3> $\forall$ $V_i \in \mathcal{Q}_{o_i}, V_i \in \mathcal{V}_o$ (the same membership).
If the validation succeeds, $V_i$ considers batch $\mathcal{B}_i$ is ordered with ordering ID $O_i$ by quorum $\mathcal{Q}_{o_i}$ in $\mathcal{V}_o$. It appends $\langle O_i, \mathcal{B}_i, \mathcal{Q}_{o_i}, \mathcal{V}_o, \sigma_{o_i} \rangle$ to the total order log.
\end{enumerate}
In each ordering instance, each data entry is paired up with a verifiable booth. Validators receive the booth information ($\mathcal{V}_o$) in \textcolor{green!80!black}{O}\ref{ordering:1} and verify the quorum based on the received booth in \textcolor{green!80!black}{O}\ref{ordering:4}. The paired information is ordered with a unique ordering ID and will be committed in a consensus instance.
\subsection{Consensus -- Commit the total order log}
\label{sec:consensus}
The consensus phase ensures that all correct members in a booth agree on the entries shown on the total order log and produces an immutable ledger that periodically commits these log entries.
\textbf{Shuttled consensus.}
V-Guard\xspace periodically initiates consensus instances to commit the log entries appended to the total order log. Each consensus instance, similar to a ``shuttle bus'', is initiated at regular time intervals, denoted by $\Delta$ (e.g., $\Delta =100$~ms), and is responsible for log entries appended in $\Delta$. Formally, a consensus instance scheduled at time $ts+\Delta$ is responsible for log entries appended in [$ts$, $ts+\Delta$), where initially $ts=0$. Thus, consensus instances cover all the entries on the total order log; i.e., \textbf{no two adjacent consensus instances leave uncommitted log entries in between.} We use the starting timestamp (i.e., $ts$ in [$ts$, $ts+\Delta$)) as the ID of the corresponding consensus instance (i.e., $\mathcal{C}_i = ts$).
\textbf{Membership pruning.}
We denote all the entries to be committed in a consensus instance $\mathcal{C}_i$ as a transaction ($tx$); i.e., $tx = \lbrace entry_{ts}, ..., entry_{ts+\Delta} \rbrace$. A transaction may contain multiple log entries whose orderings were conducted in the same membership. In this case, the transaction prunes away redundant membership and quorum information, linking entries ordered in the same booth to the same membership profile. For example, in Figure~\ref{fig:vguard-consensus}~\textcolor{green!80!black}{E4}, if entries $\lbrace \langle \mathcal{O}_2, \mathcal{B}_2 \rangle, ..., \langle \mathcal{O}_k, \mathcal{B}_k \rangle \rbrace$ are ordered by the membership configuration $\langle \mathcal{Q}_{O_2}, \mathcal{V}_{O_2}, \rangle$, then they link to only one membership profile. When membership changes infrequently, pruning can reduce the message size while maintaining the traceable membership feature. After applying pruning, a consensus instance with its ID $\mathcal{C}_i = ts$ (i.e., scheduled at time $ts+\Delta$) works as follows.
\begin{enumerate}
\renewcommand{\labelenumi}{\textbf{C\arabic{enumi}}}
\item \label{c:c1}
$V_p$ prepares a pruned transaction ($tx$) for log entries appended in $[ts, ts+\Delta)$.
\begin{enumerate}
\item $V_p$ confirms with the MMU that the booth for this consensus instance ($\mathcal{V}_c$) is available and up-to-date. Note that $\mathcal{V}_c = \mathcal{V}_o$ if $\mathcal{V}_o$ is still available; otherwise, $\mathcal{V}_c$ is a new booth provided by the MMU.
\item
$V_p$ sends a \texttt{Pre-Commit} message to all $V_i$ in $\mathcal{V}_c$. Since the consensus phase may take place at a different booth (i.e., $\mathcal{V}_c \neq \mathcal{V}_o$), $V_p$ checks if $V_i$ has previously participated in the quorums and seen all entries in $tx$.
\begin{itemize}
\item If $V_i$ has seen all entries in $tx$, $V_p$ sends the starting and ending ordering IDs ($O_{ts}$ and $O_{ts+\Delta}$) of entries in $tx$ so that $V_i$ can locate $tx$ from its log. $V_p$ sends
\vspace{-0.5em}
$$\langle \texttt{Pre-Commit}, ts, h_{tx}, O_{ts}, O_{ts+\Delta}, \mathcal{V}_c, h_{\mathcal{V}_c}, \sigma_{V_p} \rangle,$$
%
where $h_{tx}$ and $h_{\mathcal{V}_c}$ are the hashes of $tx$ and $\mathcal{V}_c$, respectively, and $\sigma_{V_p}$ is the signature that $V_p$ signs the combination of $ts$, $h_{tx}$, and $h_{\mathcal{V}_c}$.
\item If $V_i$ has not seen the entries in $tx$, $V_p$ sends
\vspace{-0.5em}
$$\langle \texttt{Pre-Commit}, ts, h_{tx}, tx, \mathcal{V}_c, h_{\mathcal{V}_c}, \sigma_{V_p} \rangle,$$
%
piggybacking the entries to be committed in this consensus instance.
\end{itemize}
\item $V_p$ creates a set $\mathcal{R}_{c}$, waiting for replies from validators in $\mathcal{V}_c$.
\end{enumerate}
\item \label{c:c2}
After receiving a \texttt{Pre-Commit} message, $V_i$ first verifies the message based on the following criteria.
\begin{itemize}
\item If $V_i$ has seen $tx$, $V_i$ locates the log entries from $O_{ts}$ to $O_{ts+\Delta}$ and calculates the hash of them. \circle<1> The hash must equal to $h_{tx}$, \circle<2> $\sigma_{V_p}$ is valid, and \circle<3> $ts$ has not been assigned to other consensus instances.
\item If $V_i$ has not seen $tx$, $V_i$ first validates all signatures paired with their quorums included in each entry in $tx$ and then calculates the hash of $tx$; the remaining validation process follows the above three criteria (as $V_i$ has seen $tx$).
\end{itemize}
If the verification succeeds, $V_i$ sends $\langle \texttt{PC-Reply}, \mathcal{C}_i, \sigma_{V_i} \rangle$ to $V_p$, where $\sigma_{V_i}$ is the signature that $V_i$ signs the combination of $ts$, $h_{tx}$, and $h_{\mathcal{V}_c}$.
\item \label{commitmsg} \label{c:c3}
$V_p$ collects \texttt{PC-Reply} messages from validators and adds them to $\mathcal{R}_{c}$ until it receives $2f$ replies (i.e., $|\mathcal{R}_{c}|=2f$); $V_p$ then takes the following actions.
\begin{enumerate}
\item $V_p$ converts the $2f$ collected signatures (i.e., $\sigma_{V_i}$ in $\mathcal{R}_{c}$) to a ($t$, $n$) threshold signature, $\sigma_{c_{ts}}$, where $t=2f$.
\item $V_p$ creates a subset $\mathcal{Q}_{c_{ts}}$ including the $2f$ vehicles, the signatures of which are converted to $\sigma_{c_{ts}}$, from $\mathcal{V}_c$ as a membership quorum; i.e., $|\mathcal{Q}_{c_{ts}}|=2f \land \mathcal{Q}_{c_{ts}} \subset \mathcal{V}_c$.
\item $V_p$ sends $\langle \texttt{Commit}, ts, \mathcal{Q}_{o_i}, \mathcal{V}_c, \sigma_{c_{ts}} \rangle$ to all members in $\mathcal{V}_c$.
\end{enumerate}
$V_p$ now considers transaction $tx$ committed and broadcasts $tx$ to connected vehicles in the gossip module (introduced in~\S~\ref{sec:gossiping}).
\item \label{c:c4}
After receiving a \texttt{Commit} message, $V_i$ verifies it by three criteria:
%
\circle<1> $\sigma_{c_{ts}}$ is valid with a threshold of $2f$;
\circle<2> signers of $\sigma_{c_{ts}}$ match $\mathcal{Q}_{c_{ts}}$;
\circle<3> $\forall$ $V_i \in \mathcal{Q}_{c_{ts}}, V_i \in \mathcal{V}_c$.
If the verification succeeds, $V_i$ considers transaction $tx$ committed.
\end{enumerate}
With separate ordering and consensus instances, data entries can be ordered and committed in different booths. Nevertheless, in each ordering/consensus instance, the booth is unchangeable (required by safety); i.e., the same booth must persist through \textcolor{green!80!black}{O}\ref{ordering:1}-\textcolor{green!80!black}{O}\ref{ordering:4} or \textcolor{green!80!black}{C}\ref{c:c1}-\textcolor{green!80!black}{C}\ref{c:c4}. If a booth fails before an instance completes, the instance aborts the current ordering/consensus process and invokes the MMU to obtain a new booth. Then, it retries the corresponding process.
\textbf{Consistency of memberships.}
V-Guard\xspace's consensus contains agreements on both data entries and membership profiles. As illustrated in Figure~\ref{fig:vguard-consensus}, committed data batches form a \textit{data chain}, and pruned membership profiles form a \textit{membership chain}. Since each data entry is paired up with its residing instance's membership profiles, membership is agreed upon with data entries; they are both traceable and verifiable through participating members' signatures. This feature of supporting dynamic memberships makes V-Guard\xspace applicable and efficient in V2X networks.
In addition, V-Guard\xspace has a message complexity of $\mathcal{O}(n)$. Steps \textcolor{green!80!black}{O}\ref{ordering:1} and \textcolor{green!80!black}{O}\ref{ordering:2} in the ordering phase, and \textcolor{green!80!black}{C}\ref{c:c1} and \textcolor{green!80!black}{C}\ref{c:c2} in the consensus phase have a message complexity of $\mathcal{O}(n)$ as messages of size $\mathcal{O}(1)$ flow only between the proposer and ($n-1$) validators. In Step \textcolor{green!80!black}{O}\ref{ordering:3} and \textcolor{green!80!black}{C}\ref{c:c3}, the proposer converts $2f$ signatures (in total of size $\mathcal{O}(n)$) to one threshold signature of size $\mathcal{O}(1)$ and broadcasts it to ($n-1$) validators, so the message complexity in this step remains $\mathcal{O}(n)$. Therefore, V-Guard\xspace obtains linear message complexity.
\subsection{Correctness discussion}
\label{sec:correctness}
We now discuss the correctness of V-Guard\xspace. In contrast to traditional BFT protocols, V-Guard\xspace does not operate in the succession of views, so it does not apply view changes. The proposer takes both the client and the leader roles, as it is the only member that produces data. When the proposer fails, its V-Guard\xspace instance halts, and its validators will join other vehicles' V-Guard\xspace instances when being included by other vehicles' MMUs.
\begin{theorem}[Validity] \label{validity}
Every data entry committed by correct members in the consensus phase must have been proposed in the ordering phase.
\end{theorem}
\begin{proof}
Only a vehicle can be the proposer of the V-Guard\xspace instance it initiated. In \textcolor{green!80!black}{O}\ref{ordering:2}, validators sign the same content as the proposer, which includes the hash of a proposed data entry. In \textcolor{green!80!black}{O}\ref{ordering:3} and \textcolor{green!80!black}{O}\ref{ordering:4}, a valid threshold signature is converted from a quorum of signatures that sign the same hash of the proposed data entry. In addition, the proposer signs the hash of the transaction that includes the data entry in \textcolor{green!80!black}{C}\ref{c:c1}. If a transaction includes non-proposed data entries, the verification process in \textcolor{green!80!black}{C}\ref{c:c2} fails. Thus, a committed transaction must include data entries that have been proposed in the ordering phase.
\end{proof}
\begin{lemma} \label{lemma1}
No two correct members in an ordering booth agree on conflicting ordering IDs for the same data entry.
\end{lemma}
\begin{proof}
Under unchanged booths in the ordering phase, this lemma intuitively holds, as correct validators do not reply to a \texttt{Pre-Order} message that contains a previously assigned ordering ID (\circle<3> in \textcolor{green!80!black}{O}\ref{ordering:2}). Under dynamic booths, due to V-Guard\xspace's requirement on quorum constructions, each quorum must contain the proposer and pivot validator; if the proposer double assigns a data entry with two different ordering IDs and sends them to two ordering instances with different booths, one of the ordering instances will fail because the pivot validator must be included in both booths and does not collude with the proposer. When the pivot validator does not reply, the proposer cannot proceed with \textcolor{green!80!black}{O}\ref{ordering:3}, and this ordering instance will be aborted. Therefore, correct members do not agree on conflicting ordering IDs for the same data entry.
\end{proof}
\begin{theorem}[Safety] \label{safety}
All correct members agree on a total order for proposed data entries in the presence of less than $f$ failures in each booth.
\end{theorem}
\begin{proof}[Proof (sketch)]
We prove the safety theorem by contradiction. We claim that two correct members commit the two data entries in the same order. Say if two data entries are committed in consensus instances with the same order, then there must exist two quorums constructed in \textcolor{green!80!black}{C}\ref{c:c3} agreeing on the two entries, which have been appended to the total order log; otherwise, the proposer cannot receive sufficient votes in \textcolor{green!80!black}{C}\ref{c:c3}. In this case, the two entries must have been ordered with the same ordering ID in the ordering phase, which contradicts Lemma~\ref{lemma1}. Therefore, each entry is committed with a unique ordering ID.
\end{proof}
\begin{theorem}[Liveness]
A correct proposer eventually receives replies to proposed data entries in the consensus phase.
\end{theorem}
\begin{proof}
V-Guard\xspace assumes partial synchrony for liveness. After GST, the message delay and processing time are bounded.
Since no two adjacent consensus instances leave uncommitted log entries in between, with Theorems~\ref{validity} and~\ref{safety}, a transaction that failed to be committed in a consensus instance will always be handled in a future consensus instance. Thus, during sufficiently long periods of synchrony, a correct proposer eventually receives replies from validators.
\end{proof}
\section{Gossiping}
\label{sec:gossiping}
The gossiping module strengthens system robustness by further disseminating committed transactions to the network. This module does not affect the correctness of consensus and can be applied based on preferences. When gossiping is enabled, after the consensus module commits a transaction, the proposer sends a \texttt{Gossip} message piggybacking the transaction to other connected vehicles, which will keep propagating this message to their connected vehicles. Therefore, the transmission forms a \emph{propagation tree} where the proposer is the root node named \emph{propagator} and other nodes are \emph{gossipers}.
Each \texttt{Gossip} message has a \emph{lifetime} (denoted by $\lambda$) that determines the number of propagators it traverses in a transmission link; i.e., the height of the propagation tree. For example, in Figure~\ref{fig:propagation-tree}, $V_1$ is the proposer and has direct connections with $V_2$, $V_3$, and $V_4$. The gossip message has a lifetime of $2$, and its propagation stops when a path has included $2$ propagators; e.g., path <$V_1$, $V_2$, $V_5$>. Specifically, we describe the gossiping workflow as follows.
\begin{SCfigure}[1][t]
\centering
\begin{adjustbox}{width=0.5\linewidth}
\Tree[.V1 [.V2 [.V5 ] [.V6 ] [.V7 ]]
[.V3 [.V8 ]]
[.V4 [.V9 ] [.V10 ]]
]
\end{adjustbox}
\caption{A propagation tree of a gossip message with $\lambda=2$. $V_1$ is the proposer and others are propagators.}
\label{fig:propagation-tree}
\end{SCfigure}
\begin{description}
\item[Proposer:]
The proposer ($V_p$) starts to disseminate committed transactions (the \texttt{Commit} message in \textcolor{green!80!black}{C}\ref{commitmsg}) by taking the following actions.
\begin{enumerate}[(a)]
\item $V_p$ creates a lifetime (e.g., $\lambda = 3$) for a \texttt{Commit} message and a set $\mathcal{G}$ for recording the traverse information of the message's transmission path.
\item $V_p$ hashes the \texttt{Commit} message and signs the combination of the hash result ($h_c$) and $\lambda$ to obtain a signature $\sigma_{V_p}$. Then, it adds a \emph{traverse entry} containing $\lambda$, $\sigma_{V_p}$, and $C_{V_p}$ to $\mathcal{G}$; i.e., $\mathcal{G}.add([\lambda, \sigma_{V_p}, C_{V_p}])$, where $C_{V_p}$ is $V_p$'s address and public key (\S~\ref{sec:boothcomposer}).
\item $V_p$ sends $\langle \texttt{Gossip}, \langle \texttt{Commit} \rangle, h_c, tx, \mathcal{G} \rangle$ to connected vehicles that are not included in the consensus process of the $\texttt{Commit}$ message and then creates a list for receiving \texttt{ack} messages from propagators.
\end{enumerate}
\item[Propagator:] A propagator ($V_i$) stores a valid \texttt{Gossip} message and may further disseminate the message if there is lifetime remaining.
\begin{enumerate}[(a)]
\item \label{gossip:propagator:a}
$V_i$ verifies a received \texttt{Gossip} message by four criteria: \circle<1> it has not previously received this message; \circle<2> signatures in $\mathcal{G}$ are valid; \circle<3> $\lambda$s in $\mathcal{G}$ are strictly monotonically decreasing; and \circle<4> the message still has remaining lifetime; i.e., $\lambda_{min} = min \lbrace \mathcal{G.{\lambda}} \rbrace > 0$. If the verification succeeds, $V_i$ sends an \texttt{ack} message to this message's proposer and the pivot validator, registering itself on the propagator list.
\item
$V_i$ decrements this gossip message's lifetime; i.e., $\lambda_{new} {=} \max \lbrace \lambda_{min}-1, 0 \rbrace$. If $\lambda_{new} > 0$, then $V_i$ prepares to further disseminate the message. It signs the combination of $h_c$ and $\lambda_{new}$ to obtain a signature $\sigma_{V_i}$ and adds a new traverse entry into $\mathcal{G}$; i.e., $\mathcal{G}.add([\lambda_{new}, \sigma_{V_i}, V_i])$.
\item $V_i$ sends $\langle \texttt{Gossip}, \langle \texttt{Commit} \rangle, h_c, tx, \mathcal{G} \rangle$ to other connected vehicles, excluding those it receives this \texttt{Gossip} message from (in
\textcolor{green!80!black}{(\ref{gossip:propagator:a})}).
\end{enumerate}
\end{description}
The gossip module increases the redundancy of transactions by replicating them to more vehicles in the network. Since each propagator registers itself on the proposer's propagator list, the proposer can retrieve transactions from propagators. This module, especially when consensus is conducted in small booth sizes, strengthens system robustness without interfering with the core consensus process.
\section{The storage module}
\label{sec:storage}
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{figures/vstorage.pdf}
\caption{Storage master instances (SMIs). A vehicle may operate a proposer SMI when it conducts consensus for itself, validator SMIs when it participates in other vehicles' consensus, and gossiper SMIs when it enables the gossip module.}
\label{fig:vstorage}
\end{figure}
V-Guard\xspace stores committed data batches in a \emph{storage master}. The storage master creates storage master instances (SMIs) for transactions from different vehicles, as a vehicle may operate in different roles in different booths (i.e., $\gamma > 1$). For example, in Figure~\ref{fig:vstorage}, the storage master has three instance zones containing proposer, validator, and gossiper SMIs (if the gossiping module is applied). A vehicle's storage master has at most one proposer SMI because it is the only proposer of its own V-Guard\xspace instance. When the vehicle joins other booths (operating as a validator), its storage master creates validator SMIs. The number of proposer and validator SMIs equals the vehicle's catering factor ($\gamma$). When gossiping is enabled, a vehicle may receive gossiping messages, and its storage master creates gossiper SMIs storing consensus results disseminated from other vehicles.
Each storage master instance has two layers: temporary and permanent, with the purpose of maximizing the usage of vehicles' limited storage space. Unlike the blockchain platforms working in a server environment (e.g., HyperLedger Fabric~\cite{androulaki2018hyperledger}, CCF~\cite{russinovich2019ccf}, and Diem~\cite{diem2020}), V-Guard\xspace operates among vehicles, which usually have only limited storage capability.
The temporary storage temporarily stores transactions based on a predefined policy. V-Guard\xspace's implementation uses a timing policy that defines a time period (denoted by $\tau$) that the storage master stores a transaction (e.g., $\tau = 24$ hours). A transaction is registered in the temporary storage by default and is deleted after $\tau$ time if the user issues no further command. In addition, temporarily stored transactions can be moved to permanent storage and kept permanently per user request. This option hands over the control of storage to users. For example, when users suspect malfunctions of their vehicles, they may want to keep related transactions as evidence and move them to permanent storage. We introduce four SMI APIs for the layered design.
\begin{description}
\item \texttt{sm.RegisterToTemp(\&tx, time.Now())} is used to register a transaction to the temporary storage layer.
\item \texttt{sm.CleanUpTemp(time.Now())} is a daemon process that calculates the remaining time for transactions in the temporary storage and deletes expired ones.
\item \texttt{sm.MoveToPerm(\&tx)} is called by users. It moves selected transactions from temporary to permanent storage.
\item \texttt{sm.DeletePerm(\&tx)} is called by users. A user may delete a permanently stored transaction after it has served the user's purpose.
\end{description}
The policy of temporary storage can be implemented differently. For example, a policy that defines a fixed size of storage space may apply. When the temporary storage exceeds the predefined size, it clears up old transactions in a fist-in-first-out (FIFO) manner.
The policy-based storage module can significantly reduce the use of storage space as vehicles often have limited storage capability. Note that the pivot validator can permanently store all data as automobile manufacturers often operate on their cloud platforms with scalable storage devices.
\begin{figure*}[h!]
\minipage{0.33\textwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/eval-ordering-vg-batching-n4.pdf}
\caption{Ordering throughput vs. latency of V-Guard\xspace under varying batch sizes, where $\beta = 3000$ obtains the best performance under $n=4$, $\delta=0$, and $m=32$.}
\label{fig:eval-vgordering-n4}
\endminipage \hfill
\minipage{0.33\textwidth}
\centering
\includegraphics[width=0.99\textwidth]{figures/eval-consensus-n4.pdf}
\caption{Consensus throughput vs. latency comparison of V-Guard\xspace and its baselines with varying batch sizes under $n=4$, $\delta=0$, and $m=32$.}
\label{fig:eval-consensus-n4}
\endminipage \hfill
\minipage{0.31\textwidth}
\renewcommand{\arraystretch}{1.2}
\begin{adjustbox}{width=\linewidth}
\centering
\begin{tabular}{rlrr}
& Batch size & { Throughput} & { Latency} \\
& & (TPS) & (ms)\\
\hline
HotStuff & ($\beta{=}1000$) & $34,015$ & 155\\
ResilientDB & ($\beta{=}500$) & $80,580$ & 4368\\
Narwhal & ($\beta{=}10^{6*}$) & $423,058$ & $516$\\
\textbf{V-Guard} (o) & ($\beta{=}3000$) & $871,248$ & $13$ \\
(c) & & $765,930$ & $143$ \\
\hline
\end{tabular}
\end{adjustbox}
{
\footnotesize
* Narwhal uses fixed-bytes buffers as batches, so its buffer size $=m\times \beta_b$.
}
\caption{A summary of the peak performance of V-Guard (including ordering (o) and consensus (c)) and its baselines under their best batch sizes, where $n=4$, $\delta=0$, and $m=32$.}
\label{fig:eval-table}
\endminipage
\end{figure*}
\section{Evaluation}
We compared the end-to-end performance of our V-Guard\xspace implementation (\texttt{vg}) against three state-of-the-art baseline approaches (using their open-source implementations): HotStuff~\cite{yin2019hotstuff, libhotstuff} (\texttt{hs}), a linear BFT protocol, whose variant is used in the Facebook Diem blockchain~\cite{diem2020}; ResilientDB~\cite{gupta13resilientdb, rdbgithub} (\texttt{rdb}), a BFT key-value store using PBFT~\cite{castro1999practical} as its consensus protocol; and Narwhal~\cite{danezis2022narwhal, nwgithub} (\texttt{nw}), a DAG-based mempool protocol that distributes transactions before consensus. We deployed them on $4$, $16$, $31$, $61$, and $100$ VM instances on a popular cloud platform~\cite{canadacloud}. Each instance includes a machine with $2$ vCPUs supported by $2.40$ GHz Intel Xeon processors (Skylake) with a cache size of $16$ MB, $7.5$ GB of RAM, and $90$ GB of disk space running on Ubuntu $18.04.1$ LTS. The TCP/IP bandwidth measured by \texttt{iperf} and the raw network latency between two instances are around $400$ Megabytes/s and $2$~ms, respectively.
In addition, we used \texttt{netem} to implement additional network delays of $\delta=0, 10\pm5, 50\pm10, 100\pm20$~ms in normal distribution at all scales. The performance change under the emulated network delays implies the performance in more complicated networks (e.g., wireless networks). We introduce the following notation for reporting the results:
\vspace{1em}
\begin{tabular}{@{}rp{7.2cm}}
$m$ & The message size (bytes); i.e., the size of a data entry sent to achieve consensus, excluding any message header (other parameters in the message).\\
$\beta$ & The batch size; i.e., the number of data entries (transactions) in a data batch sent to achieve consensus.\\
$n$ & The number of nodes (the membership/cluster size). \\
$\delta$ & Emulated network delay implemented by \texttt{netem}.\\
\end{tabular}
The rest of this section is organized as follows. \S~\ref{sec:eval:stationary} shows the evaluation result of V-Guard\xspace comparing against its baselines in a static membership under varying messaging workloads ($m=32$, $64$, and $128$ bytes), network delays, system scales, and batch sizes; \S~\ref{sec:eval:dynamic} reports the performance of V-Guard\xspace's unique feature operating under dynamic memberships; and \S~\ref{sec:eval:summary} summarizes the evaluation results.
\subsection{Performance in static memberships}
\label{sec:eval:stationary}
We set V-Guard\xspace's consensus interval time to $\Delta=100$~ms throughout the evaluation; i.e., a consensus instance is scheduled every $100$~ms. Performance was reported in throughput and latency, where throughput is calculated as transactions per second (TPS) (i.e., the number of data entries each algorithm commits per second), and the latency is measured between when a request is sent and when the request is confirmed.
Batching is applied to measure performance. Under increasing batch sizes, throughput gains a diminishing marginal increase and peaks at a particular (the best) batch size; after this, throughput decreases as batching becomes more costly than other factors in the consensus process.
V-Guard\xspace operates only one instance (i.e., $\gamma =1$) when comparing against its baselines in \S~\ref{sec:eval-sta-peak} and~\ref{sec:eval-sta-scalability}; the performance of multiple simultaneously running V-Guard\xspace instances is shown \S~\ref{sec:eval:sta-catering}.
\begin{figure*}[t]
\minipage{\textwidth}
\centering
\includegraphics[width=0.5\textwidth]{figures/eval-scala-legend.pdf}\endminipage\\
\minipage{0.49\textwidth}
\includegraphics[width=\textwidth]{figures/eval-sta-scala-l0.pdf}
\subcaption{$\delta = 0$ ms.}
\label{fig:eval-scala-l0}
\endminipage \hfill
\minipage{0.49\textwidth}
\includegraphics[width=\textwidth]{figures/eval-sta-scala-l10.pdf}
\subcaption{$\delta = 10\pm5$ ms.}
\label{fig:eval-scala-l10}
\endminipage\\
\minipage{0.49\textwidth}
\includegraphics[width=\textwidth]{figures/eval-sta-scala-l50.pdf}
\subcaption{$\delta = 50\pm10$ ms.}
\label{fig:eval-scala-l50}
\endminipage \hfill
\minipage{0.49\textwidth}
\includegraphics[width=\textwidth]{figures/eval-sta-scala-l100.pdf}
\subcaption{$\delta = 100\pm20$ ms.}
\label{fig:eval-scala-l100}
\endminipage\\
\caption[Caption for LOF]{Performance comparisons of V-Guard\xspace and its baselines using their best batch sizes with varying message sizes of $m=32$, $64$, and $128$ bytes under implemented network delays of $\delta=0$, $10\pm5$, $50\pm10$, and $100\pm20$~ms (normal distribution) at increasing system scales of $n=4$, $16$, $31$, $61$, and $100$ nodes. (Narwhal's mempool protocol was unable to initialize because its required memory space exceeded our system resources under $n=100$.\protect\footnotemark
)}
\label{fig:eval:scalability}
\end{figure*}
\subsubsection{Peak performance}
\label{sec:eval-sta-peak}
The peak performance of all approaches occurred at $n{=}4$ nodes under a message size of $m{=}32$ bytes without implemented network delay (i.e., $\delta=0$~ms). To obtain V-Guard\xspace's peak performance, we kept increasing its batch size and monitoring the result (shown in Figure~\ref{fig:eval-vgordering-n4}): the ordering throughput first increases with diminishing marginal returns (e.g., $931>\frac{50,018}{100}=500.18 > \frac{871,248}{3000}=290$) and peaks at a throughput of $871,248$~TPS with a latency of $13$~ms under $\beta=3000$. After that, under a higher $\beta$, the ordering throughput decreases while the latency increases. We used this method to measure the peak performance of consensus throughput and latency for all approaches (shown in Figure~\ref{fig:eval-consensus-n4}). Under each batch size, we kept increasing clients to saturate the network (until an elbow of a curve occurs). We show the result of V-Guard\xspace and its baselines under three batch sizes that result in near-optimal (e.g., \texttt{vg\_1000}), optimal (e.g., \texttt{vg\_3000}), and over-optimal performance (e.g., \texttt{vg\_5000}).
Figure~\ref{fig:eval-table} summarises the peak performance of all approaches, where V-Guard\xspace outperforms its baselines both in throughput and latency. Since consensus instances periodically commit ordered data entries, ordering and consensus have similar throughput.
V-Guard\xspace's high performance benefits from its implementation and design. Compared with the implementations of HotStuff~\cite{libhotstuff} and ResilientDB~\cite{rdbgithub}, V-Guard\xspace makes use of threshold signatures and obtains a linear message complexity. In addition, the separated ordering reduces latency by issuing ordering instances concurrently, and shuttled consensus significantly reduces message passing, which saves network bandwidth and increases throughput.
\subsubsection{Scalability}
\label{sec:eval-sta-scalability}
We then measured the consensus performance of V-Guard\xspace and its baselines at increasing message sizes and system scales under varying network delays (shown in Figure~\ref{fig:eval:scalability}). We set each approach's batch size to their best (optimal) batch sizes when $n=4$. The results show that when the message size and network delay increase, all approaches experience a decline in throughput and an increase in latency; in particular, message sizes have a more pronounced effect on throughput while network delays have a more direct effect on consensus latency.
\begin{figure*}[t]
\minipage{0.49\textwidth}
\includegraphics[width=\textwidth]{figures/eval-catering-n-4.pdf}
\subcaption{ $n=4$.}
\label{fig:eval-catering-n4}
\endminipage \hfill
\minipage{0.495\textwidth}
\includegraphics[width=\textwidth]{figures/eval-catering-n-61.pdf}
\subcaption{$n=61$.}
\label{fig:eval-catering-n61}
\endminipage
\caption{V-Guard\xspace's performance under increasing catering factors, where $\delta=0$, $m=32$, and $\beta = 3000$.}
\label{fig:eval:catering}
\end{figure*}
\begin{figure*}[t]
\minipage{0.49\textwidth}
\includegraphics[width=\textwidth]{figures/dynamic-n4.pdf}
\subcaption{ $n=4$.}
\label{fig:eval-dynamic-n4}
\endminipage \hfill
\minipage{0.49\textwidth}
\includegraphics[width=\textwidth]{figures/dynamic-n61.pdf}
\subcaption{$n=61$.}
\label{fig:eval-dynamic-n61}
\endminipage
\caption{V-Guard\xspace's performance under dynamic memberships, where $\delta=0$ and $\beta = 3000$. Since a V-Guard\xspace membership always includes the proposer and pivot validator, the maximum changing members allowed under $n=4$ and $61$ are $2$ and $59$ nodes, respectively.}
\label{fig:eval-dynamic-mem}
\end{figure*}
Under increasing system scales, V-Guard\xspace, HotStuff, and ResilientDB, which use a single leader to manage the consensus and transaction distribution, witness a decrease in throughput. In contrast, Narwhal observes an increase in throughput when the system scales up from $16$ to $31$ nodes. Narwhal develops a mempool protocol that distills the distribution of transactions from consensus. Each node in Narwhal runs as a worker and a validator, where the worker disseminates transactions by the mempool protocol while the validator concentrates on achieving consensus on the hash of transactions. Consequently, Narwhal's throughput increases (from $16$ to $31$ nodes) when more transactions are fed into the network but then starts to decline when the transaction distribution becomes a heavier burden than the consensus process.
V-Guard\xspace shows the mildest performance drop under increasing message workloads, system scales, and network delays among all approaches.
In particular, compared to its baselines, V-Guard\xspace's consensus throughput and latency are the least affected by higher network delays.
For example, when $n=4$ and $m=32$, its throughput drops from $765,930$~TPS under $\delta=0$~ms to $531,594$~TPS under $\delta=100\pm20$~ms while latency rises from $143$ to $622$~ms.
V-Guard\xspace's ordering instances take place in a non-blocking manner, without waiting for the completion of their prior instances, and shuttled consensus instances amortize the network delay among data entries included in $\Delta$.
This feature makes V-Guard\xspace a strong fit for V2X applications, where higher network latency is the norm.
\footnotetext{{Narwhal's mempool protocol requires static memory allocations based on the system and batch sizes; when $n{=}100$, it requires each worker to allocate $5.7$ Gigabytes of static memory for the protocol alone before the program runs, which cannot be accommodated by our system resources.}}
\subsubsection{Performance under increasing catering factors}
\label{sec:eval:sta-catering}
We also evaluated V-Guard\xspace's performance when each node operates multiple V-Guard\xspace instances (i.e., $\gamma > 1$). For example, in a $4$-node system ($n_1$ to $n_4$) with $\gamma = 2$, $n_1$ and $n_2$ start their individual V-Guard\xspace instances and operate as the proposer; $n_1$ also operates as a validator in $n_2$'s instance and vice versa. The remaining two nodes, $n_3$ and $n_4$, operate as a validator in both $n_1$'s and $n_2$'s instances.
We measured V-Guard\xspace's throughput and latency at two system scales under increasing catering factors from $\gamma=1$ to $\gamma=n$ (shown in Figure~\ref{fig:eval:catering}). When $n{=}4$, the throughput increases with diminishing gains and peaks at a throughput of 2,307,151 TPS, while both the ordering and consensus latencies experience a slight increase. When $n{=}61$ and $m=32$, throughput peaks at $\gamma=31$ with $704,274$ TPS and decreases at $\gamma=61$ with $689,822$ TPS. With a higher catering factor, the performance of each instance drops as system resources are amortized among all instances.
\subsection{Performance in dynamic memberships}
\label{sec:eval:dynamic}
We measured the performance of V-Guard\xspace operating under dynamic memberships at two scales: $n=4$ and $n=61$.
We evaluated the worst-case scenario: each data entry is ordered and committed in different booths; i.e., the membership changes at the same pace as transaction consensus. In this case, each ordering and consensus instance gets a new booth from the MMU. For example, when $n=4$ with $1$ changing member, the ordering and consensus booths have one different member:
\vspace{1em}
\begin{tabular}{@{}rl}
\vspace{0.1em}
Ordering booth: & [$n_1$ (as $V_p$), $n_2$ (as $V_{\pi}$), $n_3$, and \textcolor{blue}{$n_4$}]\\
Consensus booth: & [$n_1$ (as $V_p$), $n_2$ (as $V_{\pi}$), $n_3$, and \textcolor{blue}{$n_5$}]
\vspace{0.1em}
\end{tabular}
\vspace{1em}
Since V-Guard\xspace always includes the proposer and pivot validator in membership, it allows a maximum of $2$ and $59$ members (nodes) to change under $n=4$ and $n=61$, respectively. The results show that dynamic memberships do not affect performance when the number of changing members is less than $f$.
When a consensus instance includes new members that have not previously seen the ordered data entries, new members must undergo a time-consuming task to
validate all signatures of data entries included in a transaction (\textcolor{green!80!black}{C}\ref{c:c2} in \S~\ref{sec:consensus}).
Thus, old members reply to the proposer faster than new members; when the remaining old members can still form a quorum ($2f+1$), the system performance is not affected by changed members; e.g., $1$ and $15$ changing members in Figure~\ref{fig:eval-dynamic-n4} and Figure~\ref{fig:eval-dynamic-n61}, respectively.
In contrast, when the number of remaining old members is less than $2f+1$, a consensus quorum has to wait for new members to join. In this case, new members become the bottleneck; the performance drops with surging consensus latency as new members must finish the validation task and then reply to the proposer. When $m=32$, throughput drops by $19\%$ and $27\%$ under $n=4$ and $n=61$, respectively. With $30$ new members in $n=61$, the consensus latency increases from $2177$ to $38,955$~ms.
\subsection{Summary of results}
\label{sec:eval:summary}
Under static membership, V-Guard\xspace outperforms its baselines in terms of throughput and latency (\S~\ref{sec:eval-sta-peak}). When the system scales up, V-Guard\xspace shows a similar performance decrease as its baselines under varying workloads (\S~\ref{sec:eval-sta-scalability}). Under increasing network delays, V-Guard\xspace exhibits a lower decrease in throughput than its baselines at all scales (\S~\ref{sec:eval-sta-scalability}).
With increasing V-Guard\xspace instances ($\gamma >1$), throughput first increases to a peak throughput and then starts to decrease (\S~\ref{sec:eval:sta-catering}). Under dynamic membership, V-Guard\xspace's performance remains unchanged when new members are less than $f$; with more than $f$ new members, latency surges drastically as the newly joined members must undergo the verification process (\S~\ref{sec:eval:dynamic}).
\section{Related work}
\label{sec:relatedwork}
\textbf{Blockchains in V2X networks.}
V2X blockchains should be able to achieve consensus in real-time for a large volume of data, such as vehicle status data generated by Telsa Autopilot~\cite{autopilot} and Cadillac SuperCruise~\cite{cadillacsupercurise}, and cope with unstable connections among vehicles on the roads~\cite{ibmblockchain, limechain}.
Depending on whether membership management is required, blockchains can be categorized as permissionless and permissioned blockchains. Permissionless blockchains, applying the Proof-of-X protocol family (e.g., Proof-of-Work~\cite{nakamoto2019bitcoin} and Proof-of-Stake~\cite{gilad2017algorand}) to reach probabilistic agreement, allow participants to join anonymously. Due to their performance limitation of low throughput and high latency, permissionless blockchains are often not deployed in latency-critical V2X blockchain applications coping with a large volume of data in real-time~\cite{hassija2020dagiov, elagin2020technological, yuan2016towards, jiang2018blockchain} but some privacy-critical V2X use cases because they allow anonymous participation~\cite{peng2021privacy, feng2019survey}.
In contrast, permissioned blockchains, registering participants with identities, achieve high throughput and low latency where participants can be verified by their signatures. They often apply BFT consensus algorithms (e.g., PBFT~\cite{castro1999practical}, SBFT~\cite{gueta2019sbft} and HotStuff~\cite{yin2019hotstuff}) to achieve deterministic agreement among all participants and have been favored by pioneering blockchain testbeds initiated by major automobile manufacturers~\cite{bmwbc, mercedesbc, vwbc1, toyotabc}. However, they are not adaptive to dynamic memberships; when membership changes, consensus has to temporarily stop and facilitates for updating configuration profiles~\cite{rodrigues2010automatic}.
\textbf{BFT consensus algorithms.}
Consensus algorithms are at the core of providing safety and liveness for state machine replication (SMR)~\cite{schneider1990state}. BFT SMR provides an abstraction of consensus services that agree on a total order of requests in the presence of Byzantine failures~\cite{schneider1984byzantine, lamport1982byzantine, lamport2019byzantine, attiya2004distributed}. Byzantine failures are becoming more common in blockchain systems as participating users may intentionally break the protocol (launching Byzantine attacks) to gain more profit~\cite{zhang2020byzantine, daian2020flash, lewis2014flash}.
Leader-based BFT algorithms have been widely used by permissioned blockchains, such as HyperLedger Fabric~\cite{androulaki2018hyperledger} and Diem~\cite{diem2020}. After PBFT~\cite{castro1999practical} pioneered a practical BFT solution, numerous approaches have been proposed for optimizations from various aspects. They use speculative decisions and reduce workloads for the single leader~\cite{kotla2007zyzzyva, duan2014hbft, gunn2019making},
develop high performance implementations~\cite{el2019blockchaindb, bessani2014state, guerraoui2010next, buchman2016tendermint, sousa2018byzantine, qi2021bidl},
reduce messaging costs~\cite{song2008bosco, yang2021dispersedledger, distler2011increasing, martin2006fast, liu2016xft, neiheiser2021kauri}, obtains linear message complexity by using threshold signatures~\cite{gueta2019sbft, yin2019hotstuff, zhang2021prosecutor},
distill transaction distribution from consensus~\cite{danezis2022narwhal},
limit faulty behavior using trusted hardware~\cite{behl2017hybrids, chun2007attested, kapitza2012cheapbft, levin2009trinc, decouchant2022damysus},
improve fault tolerance thresholds~\cite{hou2022using, xiang2021strengthened}, offer confidentiality protection dealing with secret sharing~\cite{vassantlal2022cobra},
and apply accountability for individual participants~\cite{civit2021polygraph, shamis2022ia, neu2021ebb}.
In addition to leader-based algorithms, leaderless BFT algorithms avoid single points of failure and single leader bottlenecks~\cite{lamport2011brief, miller2016honey, crain2018dbft, duan2018beat, suri2021basil}. Without a leader, leaderless BFT algorithms often utilize binary Byzantine agreement~\cite{mostefaoui2014signature} to jointly form quorums~\cite{ben1994asynchronous} but suffer from high message and time costs for conflict resolutions.
\textbf{Membership reconfiguration.} Membership changes involve reconfiguration of consensus systems~\cite{lamport2010reconfiguring}, where the agreement protocol needs to switch to the updated replica-group configuration~\cite{distler2021byzantine}.
Under loosely-consistent models, some approaches implement peer-to-peer lookups that determine a system membership as the neighborhood of a certain identifier (e.g, \cite{stoica2001chord, castro2002secure}). Under strong-consistent models, a sequence of consistent views of the system memberships is required to ensure the safety of consensus processes~\cite{johansen2006fireflies, cowling2009census, guerraoui2001generic}. For example, MC~\cite{rodrigues2010automatic} proposes a membership reconfiguration approach for PBFT~\cite{castro1999practical}, keeping track of system membership and periodically notifying other system nodes of membership changes. However, transaction consensus must wait for each membership reconfiguration to be completed, which makes it inefficient during frequent membership changes.
\section{Conclusions}
V-Guard\xspace is a permissioned blockchain that efficiently achieves consensus when system memberships constantly change (dynamic environment). It binds each data entry with a system membership profile and obtains chained consensus results of both proposed data and membership profiles.
In addition, it separates ordering from consensus and allows data entries to be ordered and committed among different members. This separation brings high performance both in static and dynamic environments. Under static memberships, V-Guard\xspace's peak throughput is $1.8\times$ higher than its best-performing baseline with the lowest consensus latency. In a dynamic environment, V-Guard\xspace exhibits flexibility to operate under changing memberships with less than $27\%$ drop in throughput.
\bibliographystyle{plain}
| {'timestamp': '2023-01-18T02:15:48', 'yymm': '2301', 'arxiv_id': '2301.06210', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06210'} | arxiv |
\section{Introduction}
We define $\Sigma_k := \{ 0,1,\ldots, k-1 \}$.
Suppose $x \in \Sigma_2^*$; that is,
suppose $x$ is a finite binary word. We say it is a {\it Dyck word}
if, considering $0$ as a left parenthesis and $1$ as a right parenthesis, the word represents a string of balanced parentheses \cite{Chomsky&Schutzenberger:1963}. For example, $010011$ is Dyck,
while $0110$ is not. Formally, $x$ is Dyck if $x$ is empty, or there
are Dyck words $y, z$ such that either $x = 0y1$ or
$x = yz$. The set of all Dyck words forms the {\it Dyck language},
denoted here by ${\cal D}_2$.
In this paper we are concerned with the properties of factors of infinite binary words that are Dyck words.
If $x$ is a Dyck word, we may talk about its {\it nesting level\/} $N(x)$, which is the deepest level of parenthesis nesting in the string it represents. Formally we have $N(\epsilon) = 0$,
$N(0y1) = N(y) + 1$, and
$N(yz) = \max(N(y), N(z))$ if
$y, z$ are Dyck words. The Dyck property and nesting level are intimately connected with {\it balance},
which is a function defined by $B(x) = |x|_0 - |x|_1$, the excess of $0$'s over $1$'s in $x$. It is easy to see that a word is Dyck if and only if $B(x) = 0$ and
$B(x') \geq 0$ for every prefix $x'$ of $x$. Furthermore, the nesting level of a Dyck word $x$ is the
maximum of $B(x')$ over all prefixes $x'$ of $x$.
In this paper we will also be concerned with pattern avoidance, particularly avoidance of powers. We say a finite word $w = w[1..n]$ has period $p \geq 1$ if $w[i] = w[i+p]$ for all indices $i$ with $1 \leq i \leq n-p$. The smallest period of $w$ is called {\it the\/} period, and is denoted $\per(w)$.
The {\it exponent\/} of a finite word $w$ is defined to be $\exp(w) := |w|/\per(w)$. A word with exponent $\alpha$ is said to be an
$\alpha$-power. For example,
$\exp({\tt alfalfa}) = 7/3$ and so
{\tt alfalfa} is a $7/3$-power. If a word contains no powers $\geq \alpha$, then we say it is {\it $\alpha$-power-free}. If it contains no powers $> \alpha$, then we say it is
{\it $\alpha^+$-power-free}. If $w$ is a finite or infinite word, its {\it critical exponent} is defined to be
$\ce(w) := \sup \{ \exp(x)\colon \, x \text{ is a finite nonempty factor of } w \}$. A \emph{square} is a word of the form $xx$, where $x$ is a nonempty word. An {\it overlap\/} is a word of the form
$axaxa$, where $a$ is a single letter and $x$ is a possibly empty word.
Some of our work is carried out using the {\tt Walnut} theorem prover, which can rigorously prove many results about automatic sequences. See \cite{Mousavi:2016,Shallit:2022} for more details.
{\tt Walnut} is free software that can be downloaded at \\
\centerline{\url{https://cs.uwaterloo.ca/~shallit/walnut.html} \ .}
\section{Repetitions and Dyck words}
\label{Sec:OverlapFree}
\begin{Theorem}\label{nesting}
If a binary word is $7/3$-power-free and Dyck, then its nesting level is at most $3$.
\end{Theorem}
\begin{proof}
The $7/3$-power-free Dyck words of nesting level $1$ are $01$ and $0101$.
The set of $7/3$-power-free Dyck words of nesting level $2$ is therefore a subset of
$\{01,0011,001011\}^*$. Let $x$ be a $7/3$-power-free Dyck word of nesting level $3$.
Suppose that $x=0y1$, where $y$ has nesting level $2$. Then to avoid the cubes $000$
and $111$, the word $y$ must begin with $01$ and end with $01$. Furthermore,
since $y$ has nesting level $2$ it must contain one of $0011$ or $001011$.
Write $x=001y'011$. The word $y'$ cannot begin or end with $01$, since that would
imply that $x$ contains one of the $5/2$-powers $01010$ or $10101$. Thus $y'$ begins with $001$
and ends with $011$, which means $x$ begins with $001001$ and ends with $011011$.
Consequently $x$ cannot be extended to the left or to the right without creating
a cube or $7/3$-power. Furthermore, this implies that a $7/3$-power-free Dyck word of nesting
level $3$ cannot be written as a concatenation of two non-empty Dyck words, nor can it be
extended to a $7/3$-power-free Dyck word of nesting level $4$.
\end{proof}
\begin{Theorem}\label{Thm:OverlapFreeChar}
Define $h(0) = 01$,
$h(1) = 0011$, and $h(2) = 001011$. A binary word $w$ is an overlap-free Dyck word if and only if either
\begin{enumerate}[label=\normalfont(\roman*)]
\item $w=h(x)$, where $x\in\Sigma_3^*$ is square-free and contains no $212$ or $20102$; or
\item $w=0h(x)1$, where $x\in \Sigma_3^*$ is square-free, begins with $01$ and ends with $10$, and contains no $212$ or $20102$.
\end{enumerate}
\end{Theorem}
\begin{proof}
Let $w$ be an overlap-free Dyck word. By Theorem~\ref{nesting}, we have $N(w) \leq 3$. Suppose $N(w) \leq 2$.
Then $w \in \{01,0011,001011\}^*$ by the proof of Theorem~\ref{nesting}. So we have $w=h(x)$ for some
$x \in \Sigma_2^*$. If $N(w)=3$, then by the proof of Theorem~\ref{nesting}, we have $w=0h(x)1$.
If $x$ contains a square $yy$ as a proper factor, then certainly $w$ contains one of the overlaps
$1h(y)h(y)$ or $h(y)h(y)0$. Furthermore, if $x$ contains $212$, then $w$ contains the overlap
$011001100$ and if $x$ contains $20102$, then $w$ contains the overlap $1101001101001$.
Finally, if $w=0h(x)1$, then $x$ must begin and end with $0$ and contain at least one $1$ or $2$.
If $x$ begins with $02$, then $w$ contains the overlap $0010010$, and if $x$ ends with $20$, then $w$ contains
the overlap $1011011$. Thus $x$ begins with $01$ and ends with $10$.
For the other direction, let $x\in \Sigma_3^*$ be a squarefree word that contains no $212$ or $20102$. First consider the word $h(x)$, which is clearly a Dyck word. We now show that $h(x)$ is overlap-free. We verify by computer that if $|x|\leq 10$, then $h(x)$ is overlap-free. So we may assume that $|x|\geq 11$. Suppose towards a contradiction that $h(x)$ contains an overlap $z$. Assume that $z=0y0y0$; the case $z=1y1y1$ is similar, and the proof is omitted. We consider several cases depending on the prefix of $y$.
If $y$ starts with $0$, then $h^{-1}(z0^{-1})=h^{-1}(0y0y)$ is a square that appears as a proper factor of $x$.
If $y$ starts with $100$, write $y=100y'$, so that $z=0100y'0100y'$. Then $h^{-1}(z0^{-1})=h^{-1}(0100y'0100y')$ is a square that appears as a proper factor of $x$.
If $y$ starts with $101$, write $y=101y'$, so that $z=0101y'0101y'$. Note that $00$ is not a factor of $x$, so any occurrence of $0101$ in $z$ is as a factor of
$h(2) = 001011$. Consequently, the word $h^{-1}(0z0^{-1})=h^{-1}(00101y'00101y')$ is a square that appears as a proper factor of $x$.
Finally, if $y$ starts with $11$, then write $y=11y'$, so that $z=011y'011y'0$. Then $z$ is a factor of $h(ax'bx'c)$, where $a,b,c \in \{1,2\}$, and the value of $b$
is determined by the suffix of $y'$: if $y'$ ends with $001$ then $b=2$ and if $y'$ ends with $0$ then $b=1$.
Clearly we have $a \neq b$ and $b \neq c$, since otherwise $x$ contains a square as a proper factor. However, if $b=2$ then $y'$ ends with $001$, which
implies $c=2$, a contradiction. So we have $b=1$, and further, since $a \neq b$ and $b \neq c$, we have $a=c=2$. We therefore have a
factor $2x'1x'2$ of $x$. Now $x'$ can neither begin nor end with $2$ or $1$, so we have $2x'1x'2 = 20x''010x''02$. Similarly, the word
$x''$ can neither begin nor end with $0$ or $1$, so we have $20x''010x''02 = 202x'''20102x'''202$, whence $x$ contains the forbidden
factor $20102$, a contradiction.
Thus, we conclude that $h(x)$ is an overlap-free Dyck word. Finally, assume that $x$ begins with $01$ and $10$, and consider the word $0h(x)1$. Again, it is clear that $0h(x)1$ is a Dyck word, and we have already shown that the word $h(x)$ is overlap-free.
Now $0h(x)1$ begins with $0010011$ and ends with $0011011$. Note that the only occurrences of
$00100$ and $11011$ as factors of $0h(x)1$ are as a prefix and a suffix, respectively. It follows that if $0h(x)1$ contains
an overlap, then this overlap has period at most $4$ and occurs as either a prefix or a suffix of $0h(x)1$. However,
one easily verifies that no such overlap exists. This completes the proof.
\end{proof}
\begin{Corollary}
There are arbitrarily long overlap-free Dyck words of nesting level $2$ (and $3$).
\end{Corollary}
\begin{proof}
Consider the well-known word $\bf s$, which is the infinite fixed point, starting with $0$, of the morphism defined by $0\mapsto 012$, $1\mapsto 02$, $2\mapsto 1$. Thue~\cite{Thue:1912} proved that $\bf s$ is squarefree and contains no $010$ or $212$; this is also easy to verify with \texttt{Walnut} (cf.~\cite{Shallit:2022}). Let $x$ be a prefix of $\bf s$ that ends in $10$. Since the factor $10$ appears infinitely many times in $\bf s$, there are arbitrarily long such words $x$. So $x$ is squarefree, contains no $212$ or $20102$, begins in $01$, and ends in $10$. By Theorem~\ref{Thm:OverlapFreeChar}, the words $h(x)$ and $0h(x)1$ are overlap-free Dyck words. It is easy to see that $h(x)$ has nesting level $2$, and $0h(x)1$ has nesting level $3$, which completes the proof.
\end{proof}
Theorem~\ref{nesting} says that every $7/3$-power-free Dyck word has nesting level at most $3$. We will see that this result is best possible with respect to the exponent $7/3$; in fact, there are $7/3^+$-power-free Dyck words of every nesting level. Before we proceed with the construction of such words, we provide a very simple construction of cube-free Dyck words of every nesting level, which serves as a preview of the main ideas in the more complicated construction of $7/3^+$-power-free Dyck words of every nesting level.
\begin{Lemma}\label{Lemma:BinaryMorphismTrick}
Let $u$ and $v$ be Dyck words, and let $f:\Sigma_2^*\rightarrow \Sigma_2^*$ be the morphism defined by $f(0)=0u$ and $f(1)=v1$.
If $w$ is a nonempty Dyck word, then $f(w)$ is a Dyck word, and $N(f(w))=N(w)+\max(N(u),N(v))$.
\end{Lemma}
\begin{proof}
The proof is by induction on $|w|$. In the base case, if $w=01$, then $f(w)=0uv1$, and $N(f(w))=1+\max(N(u),N(v))=N(w)+\max(N(u),N(v))$.
Now suppose that $|w|=n$ for some $n>2$, and that the statement holds for all nonempty Dyck words of length less than $n$. We have two cases.
\smallskip
\noindent
\textbf{Case 1:} We have $w=0y1$ for some nonempty Dyck word $y$.
\smallskip
\noindent
By the induction hypothesis, the word $f(y)$ is a Dyck word with $N(f(y))=N(y)+\max(N(u),N(v))$. So $f(w)=0uf(y)v1$ is a Dyck word with
\begin{align*}
N(f(w))&=1+\max(N(u),N(f(y)),N(v))\\
&=1+N(y)+\max(N(u),N(v))\\
&=N(w)+\max(N(u),N(v)).
\end{align*}
\smallskip
\noindent
\textbf{Case 2:} We have $w=yz$ for some nonempty Dyck words $y,z$.
\smallskip
\noindent
By the induction hypothesis, the word $f(y)$ is a Dyck word with $$N(f(y))=N(y)+\max(N(u),N(v)),$$ and $f(z)$ is a Dyck word with $N(f(z))=N(z)+\max(N(u),N(v))$. Therefore, the word $f(w)=f(y)f(z)$ is a Dyck word with
\begin{align*}
N(f(w))&=\max(N(f(y)),N(f(z)))\\
&=\max(N(y),N(z))+\max(N(u),N(v))\\
&=N(w)+\max(N(u),N(v)). \qedhere
\end{align*}
\end{proof}
\begin{Corollary}
There is a cube-free Dyck word of every nesting level.
\end{Corollary}
\begin{proof}
Let $f:\Sigma_2^*\rightarrow\Sigma_2^*$ be the morphism defined by $f(0)=001$ and $f(1)=011$. Note that $f(0)=0u$ and $f(1)=u1$, where $u=01$ is a Dyck word with $N(u)=1$. It is also well-known that the morphism $f$ is cube-free; for example, this follows easily from a criterion of Ker\"anen~\cite{Keranen1984}, which states that to confirm that a uniform binary morphism is cube-free, it suffices to check that the images of all words of length at most 4 are cube-free. Thus, by a straightforward induction using Lemma~\ref{Lemma:BinaryMorphismTrick}, we see that $w_t=f^t(01)$ is a cube-free Dyck word with $N(w_t)=t+1$.
\end{proof}
We now define the specific morphisms involved in our construction of $7/3^+$-power-free Dyck words of arbitrarily large nesting level. Let $g:\Sigma_3^*\rightarrow\Sigma_3^*$ be the $6$-uniform morphism defined by
\begin{align*}
g(0)&=022012,\\
g(1)&=022112, \text{ and}\\
g(2)&=202101.
\end{align*}
Let $f:\Sigma_3^*\rightarrow \Sigma_2^*$ be the $38$-uniform morphism defined by
\begin{align*}
f(0)&=00100110100110010110010011001011001101,\\
f(1)&=00101100110100110110011010010110011011, \text{ and}\\
f(2)&=00101101001101001011001101001011010011.
\end{align*}
We will show that for every $t\geq 0$, the word $f(g^t(2))$ is a $7/3^+$-power-free Dyck word of nesting level $2t+2$. The letters $f$ and $g$ denote these specific morphisms throughout the remainder of this section.
Over the ternary alphabet $\Sigma_3$, we think of the letter $0$ as a left parenthesis, the letter $1$ as a right parenthesis, and the letter $2$ as a Dyck word. So we will be particularly interested in the ternary words for which the removal of every occurrence of the letter $2$ leaves a Dyck word, and we call these \emph{ternary Dyck words}.
\begin{Definition}
Let $\beta:\Sigma_3^*\rightarrow \Sigma_2^*$ be defined by $\beta(0)=0$, $\beta(1)=1$, and $\beta(2)=\varepsilon$, and let $w\in\Sigma_3^*$. If $\beta(w)$ is a Dyck word, then we say that $w$ is a \emph{ternary Dyck word}. In this case, the \emph{nesting level} of $w$, denoted $N(w)$, is defined by $N(w)=N(\beta(w))$.
\end{Definition}
\begin{Lemma}\label{Lemma:g}
Let $w\in \Sigma_3^*$. If $w$ is a nonempty ternary Dyck word, then $g(w)$ is a ternary Dyck word with $N(g(w))=N(w)+1$.
\end{Lemma}
\begin{proof}
Throughout this proof, we let $u=01$, a Dyck word with nesting level $1$. Note that $\beta(g(0))=001=0u$, $\beta(g(1))=011=u1$, and $\beta(g(2))=0101=u^2$.
The proof is by induction on $|\beta(w)|$. We have two base cases. If $\beta(w)=\varepsilon$, then $w=2^i$ for some $i\geq 1$, and $N(w)=0$. We have $\beta(g(w))=u^{2i}$,
so we see that $g(w)$ is a ternary Dyck word with $N(g(w))=1=N(w)+1$. If $\beta(w)=01$, then $w=2^i02^j12^k$ for some $i,j,k\geq 0$, and $N(w)=1$. We have
\[
\beta(g(w))=u^{2i}(0u) u^{2j}(u1)u^{2k}=u^{2i}0u^{2j+2}1u^{2k},
\]
so we see that $g(w)$ is a ternary Dyck word with $N(g(w))=2=N(w)+1$, as desired.
Now suppose that $|\beta(w)|=n$ for some $n>2$, and that the statement holds for all ternary Dyck words $w'$ with $|\beta(w')|<n$. We have two cases.
\smallskip
\noindent
\textbf{Case 1:} We have $\beta(w)=0y1$ for some nonempty Dyck word $y$.
\smallskip
\noindent
In this case we may write $w=2^i0w'12^j$ for some $i,j\geq 0$, so that $\beta(w')=y$. By the induction hypothesis, the word $g(w')$ is a ternary Dyck word with $N(g(w'))=N(w')+1$. It follows that $\beta(g(w))=u^{2i}0u\beta(g(w'))u1u^{2j}$ is a Dyck word, so $g(w)$ is a ternary Dyck word, and
\begin{align*}
N(g(w))&=1+N(g(w'))\\
&=1+N(w')+1\\
&=N(w)+1.
\end{align*}
\noindent
\textbf{Case 2:} We have $\beta(w)=y_1y_2$ for some nonempty Dyck words $y_1,y_2$.
\smallskip
\noindent
Write $w=w_1w_2$ for some $w_1,w_2\in \Sigma_3^*$ such that $\beta(w_1)=y_1$, and $\beta(w_2)=y_2$. By the induction hypothesis, the words $g(w_1)$ and $g(w_2)$ are ternary Dyck words with $N(g(w_1))=N(w_1)+1$, and $N(g(w_2))=N(w_2)+1$. Therefore, the word $g(w)=g(w_1)g(w_2)$ is a ternary Dyck word with
\begin{align*}
N(g(w))&=\max\left(N(g(w_1)),N(g(w_2))\right)\\
&=\max(N(w_1)+1,N(w_2)+1)\\
&=\max(N(w_1),N(w_2))+1\\
&=N(w)+1. \qedhere
\end{align*}
\end{proof}
\begin{Lemma}\label{Lemma:f}
Let $w\in\Sigma_3^*$. If $w$ is a nonempty ternary Dyck word, then $f(w)$ is a Dyck word with $N(f(w))=2N(w)+2$.
\end{Lemma}
\begin{proof}
Note that $f(0)=0u_10u_2$, $f(1)=u_31u_41$, and $f(2)=v$, where $u_1$, $u_2$, $u_3$, and $u_4$ are Dyck words of nesting level $2$ and length $18$, and $v$ is a Dyck word of nesting level $2$ and length $38$.
The proof is by induction on $|\beta(w)|$. We have two base cases. If $\beta(w)=\varepsilon$, then $w=2^i$ for some $i\geq 1$, and $N(w)=0$. We have $f(w)=v$,
so we see that $f(w)$ is a Dyck word with $N(f(w))=2=2N(w)+2$. If $\beta(w)=01$, then $w=2^i02^j12^k$ for some $i,j,k\geq 0$, and $N(w)=1$. We have
\[
f(w)=v^i 0u_10u_2 v^j u_31u_41 v^k,
\]
so we see that $f(w)$ is a Dyck word with $N(f(w))=4=2N(w)+2$.
Now suppose that $|\beta(w)|=n$ for some $n>2$, and that the statement holds for all ternary Dyck words $w'$ with $|\beta(w')|<n$. We have two cases.
\smallskip
\noindent
\textbf{Case 1:} We have $\beta(w)=0y1$ for some nonempty Dyck word $y$.
\smallskip
\noindent
In this case we may write $w=2^i0w'12^j$ for some $i,j\geq 0$, so that $\beta(w')=y$. By the induction hypothesis, the word $f(w')$ is a Dyck word with $N(f(w'))=2N(w')+2$. It follows that $f(w)=v^i0u_10u_2f(w')u_31u_41v^j$ is a Dyck word with
\begin{align*}
N(f(w))&=2+N(f(w'))\\
&=2+2N(w')+2\\
&=2N(w)+2.
\end{align*}
\noindent
\textbf{Case 2:} We have $\beta(w)=y_1y_2$ for some nonempty Dyck words $y_1,y_2$.
\smallskip
\noindent
Write $w=w_1w_2$ for some $w_1,w_2\in \Sigma_3^*$ such that $\beta(w_1)=y_1$, and $\beta(w_2)=y_2$. By the induction hypothesis, the words $f(w_1)$ and $f(w_2)$ are Dyck words with $N(f(w_1))=2N(w_1)+2$, and $N(f(w_2))=N(w_2)+1$. Therefore, the word $f(w)=f(w_1)f(w_2)$ is a Dyck word with
\begin{align*}
N(f(w))&=\max\left(N(f(w_1)),N(f(w_2))\right)\\
&=\max(2N(w_1)+2,2N(w_2)+2)\\
&=2\max(N(w_1),N(w_2))+2\\
&=2N(w)+2. \qedhere
\end{align*}
\end{proof}
\begin{Theorem}
There are $7/3^+$-power-free Dyck words of every nesting level.
\end{Theorem}
\begin{proof}
Let $t\geq 0$. We claim that the word $f(g^t(2))$ is a $7/3^+$-free Dyck word of nesting level $2t+2$. Since $2$ is a ternary Dyck word with nesting level $0$, by Lemma~\ref{Lemma:g}, and a straightforward induction, the word $g^t(2)$ is a ternary Dyck word with nesting level $t$. Thus, by Lemma~\ref{Lemma:f}, the word $f(g^t(2))$ is a Dyck word with nesting level $2t+2$.
It remains only to show that $f(g^t(2))$ is $7/3^+$-power-free. We use the \texttt{Walnut} theorem-prover to show that $f(g^\omega(0))$ is $7/3^+$-power-free, which is equivalent. One only need type in the following commands:
\begin{verbatim}
morphism f
"0->00100110100110010110010011001011001101
1->00101100110100110110011010010110011011
2->00101101001101001011001101001011010011":
morphism g "0->022012 1->022112 2->202101":
promote GG g:
image DFG f GG:
eval DFGtest "?msd_6 Ei,n (n>=1) & At (3*t<=4*n) =>
DFG[i+t]=DFG[i+t+n]":
\end{verbatim}
and {\tt Walnut} returns {\tt FALSE}. Here the first two {\tt morphism} commands define $f$ and $g$, and the next two commands create a DFAO for $f(g^\omega(0))$. Finally, the last command asserts the existence of a $7/3^+$ power in $f(g^\omega(0))$.
This was a large computation in {\tt Walnut}, requiring 130G of memory and 20321 secs of CPU time.
\end{proof}
\begin{Remark}
An alternative method of proof is to first use {\tt Walnut} to show that the word $g^\omega(0)$ is overlap-free, and then apply an extended version~\cite[Lemma 23]{MolRampersadShallit2020} of a well-known result of Ochem~\cite[Lemma 2.1]{Ochem2006} to show that $f(g^\omega(0))$ is $7/3^+$-power-free.
\end{Remark}
\section{Dyck factors of Thue-Morse}
In this section we give a characterization of those
factors of $\bf t$, the Thue-Morse sequence, that are
Dyck.
Let $g:\Sigma_3^* \to \Sigma_2^*$ be the morphism defined by $g(0)=011$, $g(1)=01$, and $g(2)=0$ and let
$f:\Sigma_3^* \to \Sigma_3^*$ be the morphism defined by $f(0)=012$, $f(1)=02$, and $f(2)=1$. Define ${\bf s}=f^\omega(0)$. It is
well-known that $g({\bf s})={\bf t}$. Recall the morphism $h:\Sigma_2^* \to \Sigma_2^*$ defined earlier
by $h(0) = 01$, $h(1) = 0011$, and $h(2) = 001011$.
\begin{Theorem}\label{tm_dyck}
The Dyck factors of the Thue-Morse word are exactly the words $h(x)$ where $x$ is a factor of ${\bf s}$.
\label{dycktm}
\end{Theorem}
\begin{proof}
By considering the so-called ``returns to $11$'' in $\bf t$ we see that $\bf t$
begins with $011$ followed by a concatenation of the four words
$$0011,\quad 010011,\quad 001011,\quad 01001011.$$
These are all Dyck words, as shown by the bracketings
$$(0(01)1),\quad (01)(0(01)1),\quad (0(01)(01)1),\quad (01)(0(01)(01)1).$$
Furthermore, these words must have the above bracketings when they occur as factors
of any larger Dyck word in $\bf t$. It follows that ${\bf t}=011{\bf t}'$, where
${\bf t}'$ is a concatenation of the three Dyck words $h(0) = 01$, $h(1) = 0011$,
and $h(2) = 001011$.
To complete the proof, it suffices to show that $h({\bf s}) = (011)^{-1}{\bf t} = (011)^{-1}g({\bf s})$.
We have
\begin{align*}
h(f(0)) &= h(012) = g(120210) = g(0^{-1}f^2(0)0)\\
h(f(1)) &= h(02) = g(1210) = g(0^{-1}f^2(1)0)\\
h(f(2)) &= h(1) = g(20) = g(0^{-1}f^2(2)0),
\end{align*}
so
$$h({\bf s}) = h(f({\bf s})) = g(0^{-1}f^2({\bf s})) = g(0^{-1}{\bf s}) = (011)^{-1}g({\bf s}),$$
as required.
\end{proof}
\section{Dyck factors of some automatic sequences}
In this section we are concerned with Dyck factors of automatic sequences. Recall that a sequence over a finite alphabet
$(s(n))_{n \geq 0}$ is {\it $k$-automatic\/} if there exists
a DFAO (deterministic finite automaton with output) that,
on input $n$ expressed in base $k$, reaches a state
with output $s(n)$.
Since ${\cal D}_2$ is not a member of the FO[+]-definable languages \cite{Choffrut&Malcher&Mereghetti&Palano:2012}, this means that ``automatic'' methods (like that implemented in the {\tt Walnut} system; see \cite{Mousavi:2016,Shallit:2022}) cannot always directly handle such words.
However, in this section we show that if a $k$-automatic sequence also
has a certain special property, then the number of Dyck factors
of length $n$ occurring in it is a $k$-regular sequence.
To explain the special property, we need the notion of synchronized
sequence \cite{Shallit:2021h}. We say a $k$-automatic sequence $(v(n))_{n \geq 0}$ is {\it synchronized\/}
if there is a finite automaton accepting, in parallel, the base-$k$ representation of $n$ and $v(n)$. Here the shorter representation is padded with leading zeros, if necessary.
Now suppose ${\bf s} = (s(n))_{n \geq 0}$ is a $k$-automatic sequence taking values in $\Sigma_2$ and define the running sum
sequence $v(n) = \sum_{0 \leq i < n} s(i)$.
If ${\bf v} = (v(n))_{n \geq 0}$ is synchronized, we say that $\bf s$
is {\it running-sum synchronized}.
\begin{Theorem}
Suppose ${\bf s} = (s(n))_{n \geq 0}$ is a $k$-automatic sequence taking values in $\Sigma_2$ that is running-sum synchronized. Then there is an automaton accepting, in parallel,
the base-$k$ representations of those pairs $(i,n)$
for which ${\bf s}[i..i+n-1]$ is Dyck. Furthermore, there is an automaton accepting, in parallel, the
base-$k$ representations of those triples $(i,n,x)$
for which ${\bf s}[i..i+n-1]$ is Dyck and whose
nesting level is $x$. In both cases, the automaton can be effectively constructed.
\label{autothm}
\end{Theorem}
\begin{proof}
We use the fact that it suffices to create first-order logical formulas for these claims \cite{Shallit:2022}.
Suppose $V(n,x)$ is true
if and only $v(n) = x$. Then define
\begin{align*}
N_1(i,n,x): & \ \exists y, z \ V(i,y) \, \wedge \, V(i+n,z) \, \wedge \, x+y = z \\
N_0(i,n,x): &\ \exists y \ N_1(i,n,y) \, \wedge \, n=x+y \\
\Dyck(i,n): & \ (\exists w \ N_0(i,n,w) \, \wedge \, N_1(i,n,w))
\, \wedge \, \\
&(\forall t,y,z\ (t<n \, \wedge \, N_0(i,t,y) \, \wedge \, N_1(i,t,z)) \implies y \geq z) .
\end{align*}
Here
\begin{itemize}
\item $N_0(i,n,x)$ asserts that $|{\bf s}[i..i+n-1]|_0 = x$;
\item $N_1(i,n,x)$ asserts that $|{\bf s}[i..i+n-1]|_1 = x$;
\item $\Dyck(i,n)$ asserts that ${\bf s}[i..i+n-1]$ is Dyck.
\end{itemize}
We can now build an automaton for $\Dyck(i,n)$ using
the methods discussed in \cite{Shallit:2022}.
Next we turn to nesting level.
First we need a first-order formula for the balance $B(x)$ of a factor $x$. Since we are only interested in balance for prefixes of Dyck words, it suffices to compute $\max(0, B(x))$ for a factor $x$. We can do this
as follows:
$$\Bal(i,n,x): \ \exists y,z \ N_0(i,n,y) \, \wedge \, N_1(i,n,z) \, \wedge \, ((y<z \, \wedge \, x=0) \mid (y\geq z \, \wedge \, y=x+z)) .$$
Next, we compute the nesting level of a factor, assuming it is Dyck:
$$ \Nest(i,n,x): \ \exists m\ m<n \, \wedge \, \Bal(i,m,x) \, \wedge \, \forall p,y\ (p<n \, \wedge \, \Bal(i,p,y)) \implies y\leq x.$$
This completes the proof.
\end{proof}
\begin{Corollary}
If ${\bf s} = (s(n))_{n \geq 0}$ is a $k$-automatic sequence taking values in $\Sigma_2$ that is running-sum synchronized, then it is decidable
\begin{itemize}
\item[(a)] whether $\bf s$ has arbitrarily large Dyck factors;
\item[(b)] whether Dyck factors of
$\bf s$ are of unbounded nesting level.
\end{itemize}
\end{Corollary}
\begin{proof}
It suffices to create first-order logical statements asserting the two properties:
\begin{itemize}
\item[(a)] $\forall m \ \exists i,n \ m>n \, \wedge \, \Dyck(i,m) $
\item[(b)] $\forall q \ \exists i,n,p \
\Dyck(i,n) \, \wedge \, \Nest(i,n,p) \, \wedge \, p>q $. \qedhere
\end{itemize}
\end{proof}
\begin{Example}
As an example, let us use {\tt Walnut} to prove that
there is a Dyck factor of the Thue-Morse word for all even lengths.
We can use the following {\tt Walnut} commands, which implement the ideas above. We use the fact that the sum of $T[0..n-1]$ is $n/2$ if $n$
is even, and $(n-1)/2 + T[n-1]$ if $n$ is odd.
\begin{verbatim}
def even "Ek n=2*k":
def odd "Ek n=2*k+1":
def V "($even(n) & 2*x=n) | ($odd(n) & 2*x+1=n & T[n-1]=@0) |
($odd(n) & 2*x=n+1 & T[n-1]=@1)":
# number of 1's in prefix T[0..n-1]
def N1 "Ey,z $V(i,y) & $V(i+n,z) & x+y=z":
# number of 1's in T[i..i+n-1]
def N0 "Ey $N1(i,n,y) & n=x+y":
def Dyck "(Ew $N0(i,n,w) & $N1(i,n,w)) &
At,y,z (t<n & $N0(i,t,y) & $tmfac1(i,t,z)) => y>=z":
# is T[i..i+n-1] a Dyck word?
eval AllLengths "An $even(n) => Ei $Dyck(i,n)":
\end{verbatim}
and {\tt Walnut} returns {\tt TRUE}.
\end{Example}
\begin{Example}
Continuing the previous example, let us show that the nesting level of every Dyck factor of Thue-Morse is $\leq 2$. Of course, this follows from Theorem~\ref{dycktm}, but this shows how it can be done for any automatic sequence that is running-sum synchronized.
We use the following {\tt Walnut} commands:
\begin{verbatim}
def Bal "Ey,z $N0(i,n,y) & $N1(i,n,z) &
((y<z & x=0) | (y>=z & y=x+z))":
# computes max(0, B(T[i..i+n])) where B is balance; 14 states
def Nest "Em (m<n) & $Bal(i,m,x) &
Ap,y (p<n & $Bal(i,p,y)) => y<=x":
# computes nesting level of factor, assuming it is Dyck
eval maxnest2 "Ai,n,x ($Dyck(i,n) & $Nest(i,n,x)) => x<=2":
\end{verbatim}
and {\tt Walnut} returns {\tt TRUE} for the
last assertion.
\end{Example}
Now we turn to enumerating Dyck factors by
length.
Let us recall that a sequence
$(s(n))_{n\geq 0}$ is {\it $k$-regular\/} if
there is a finite set of sequences
$(s_i(n))_{n \geq 0}$, $i = 1, \ldots, t$,
with $s = s_1$, such that
every subsequence of the form
$(s(k^e n +a))_{n \geq 0}$ with $e \geq 0$
and $0 \leq a < k^e$ can be expressed as a linear
combination of the $g_i$. See
\cite{Allouche&Shallit:1992} for more details.
Alternatively, a sequence $(s(n))_{n \geq 0}$ is $k$-regular if there is
a linear representation for it.
If $v$ is a
row vector of dimension $t$, $w$ is a column
vector of dimension $t$, and $\gamma$ is a matrix-valued morphism with domain $\Sigma_k$
and range $t \times t$-matrices, then we say that the triple $(v, \gamma, w)$ is a {\it linear representation\/} for a function $s(n)$, of rank $t$. It is
defined by $s(n) = v \gamma(x) w$, where $x$ is any
base-$k$ representation of $n$.
See \cite{Berstel&Reutenauer:2011} for more details.
It is not difficult to use the characterization of Theorem~\ref{dycktm} to find a linear representation
for $f(n)$, the number of Dyck factors of length $2n$
appearing in $\bf t$, the Thue-Morse word. However,
in this section we will instead use a different approach that is more general.
\begin{Theorem}
Suppose ${\bf s} = (s(n))_{n \geq 0}$ is a $k$-automatic sequence that is running-sum synchronized.
Then $(f(n))_{n \geq 0}$, the number
of Dyck factors of length $2n$ appearing in $\bf s$,
is $k$-regular.
\label{autocor}
\end{Theorem}
\begin{proof}
It suffices to find a linear representation for $f(n)$.
To do so, we first find a first-order formula asserting that ${\bf s}[i..i+n-1]$ is {\it novel\/}; that is, it is the first occurrence of this factor in
$\bf s$:
\begin{align*}
\FacEq(i,j,n): & \ \forall t \ (t<n) \implies {\bf s}[i+t] = {\bf s}[j+t] \\
\Novel(i,n): & \ \forall j \ \FacEq(i,j,n) \implies j \geq i.
\end{align*}
Then the number of $i$ for which
$$ \Novel(i,2n) \, \wedge \, \Dyck(i,2n)$$
holds is precisely the number of Dyck factors of $\bf s$ of length $2n$.
Since $\bf s$ is $k$-automatic, and its running sum sequence $\bf v$ is synchronized, it follows that there is an automaton
recognizing those $i$ and $n$ for which
$ \Novel(i,2n) \, \wedge \, \Dyck(i,2n)$ evaluates to true, and
from known techniques we can construct a linear
representation for the number of such $i$.
\end{proof}
\begin{Corollary}
Let $f(n)$ denote the number of Dyck factors of length $2n$ appearing in the Thue-Morse word. Then $(f(n))_{n\geq 0}$ is a $2$-regular sequence.
\end{Corollary}
\begin{proof}
We can carry out the proof of Theorem~\ref{autocor} in
{\tt Walnut} for $\bf t$, as follows:
\begin{verbatim}
def FacEq "At (t<n) => T[i+t]=T[j+t]":
def Novel "Aj $FacEq(i,j,n) => j>=i":
def NovelDyck "$Dyck(i,n) & $Novel(i,n)":
def LR n "$NovelDyck(i,2*n)":
\end{verbatim}
The last command creates a rank-29 linear representation for the number of length-$2n$ Dyck factors.
\end{proof}
\begin{Remark}
Using the algorithm of Sch\"utzenberger discussed
in \cite[Chapter 2]{Berstel&Reutenauer:2011}, we
can minimize the linear representation obtained in the proof to find a linear representation
$(v_f, \gamma_f, w_f)$ for $f$ of
rank $7$, as follows:
\begin{align*}
v_f^T &= \left[ \begin{smallarray}{ccccccc}
1&0&0&0&0&0&0
\end{smallarray} \right]
& \quad
\gamma_f(0) & = \left[ \begin{smallarray}{ccccccc}
1& 0& 0& 0& 0& 0& 0 \\
0& 0& 1& 0& 0& 0& 0 \\
0& 0& 0& 0& 1& 0& 0 \\
0& 0& 0& 0& 0& 0& 1 \\
0& 0& 0& -2& 3& -2& 2 \\
0& 0& 0& 0& 2& -2& 2 \\
0 & 0 & 0 & 1/2 & 5/4& -5/2 & 3
\end{smallarray} \right] \\
\gamma_f(1) &= \left[\begin{smallarray}{ccccccc}
0& 1& 0& 0& 0& 0& 0 \\
0& 0& 0& 1& 0& 0& 0 \\
0& 0& 0& 0& 0& 1& 0 \\
0 & 0 & 0 & 3/4 & 11/8&-2 & 3/2 \\
0 & 0 & 0 & 1/2 & 1/4& 0 & 1 \\
0 & 0 & 0 & -5/2 & 11/4& -2 & 3 \\
0 & 0 & 0 & -7/2 & 19/4& -5 & 5 \\
\end{smallarray}\right]
& \quad
w_f &= \left[ \begin{smallarray}{c}
1\\
1\\
2\\
3\\
2\\
4\\
6
\end{smallarray}
\right] .
\end{align*}
This gives a very efficient way to compute $f(n)$.
\end{Remark}
Table~\ref{tab1} gives the first few terms
of the sequence $f(n)$. It is sequence
\seqnum{A345199}
in the {\it On-Line Encyclopedia of Integer
Sequences} \cite{Sloane:2022}.
\begin{table}[H]
\begin{center}
\begin{tabular}{c|ccccccccccccccccccccc}
$n$ & 0& 1& 2& 3& 4& 5& 6& 7& 8& 9&10&11&12&13&14&15&16&17&18&19&20\\
\hline
$f(n)$ & 1& 1& 2& 3& 2& 4& 6& 6& 4& 8& 8& 8&12& 9&12&13& 8&14&16&14&16
\end{tabular}
\end{center}
\caption{First few values of $f(n)$.}
\label{tab1}
\end{table}
\section{Upper and lower bounds for \texorpdfstring{$f(n)$}{f(n)}}
In this section we prove tight upper and lower bounds
for $f(n)$, the number of Dyck factors of $\bf t$
of length $2n$.
We start with a characterization of some of the subsequences
of $(f(n))_{n \geq 0}$.
\begin{Lemma}
We have
\begin{align}
f(2n) &= 2f(n) \label{a1} \\
f(4n+3) &= 2f(n) + f(2n+1) + q(n) \label{a2} \\
f(8n+1) &= 2f(2n+1) + f(4n+1) - q(n) \label{a3} \\
f(8n+5) &= 2f(n) + f(2n+1) + 2f(2n+2) \label{a4}
\end{align}
for all $n \geq 3$. Here $q(n)$ is the $2$-automatic sequence computed by the DFAO
in Figure~\ref{fig1}.
\begin{figure}[H]
\begin{center}
\vskip -0.5in
\includegraphics[scale=0.7]{auta.pdf}
\end{center}
\vskip -0.5in
\caption{DFAO computing $q(n)$. States are in the form $q/a$, where $q$ is the name of the state and $a$ is the output.}
\label{fig1}
\end{figure}
\end{Lemma}
\begin{proof}
Notice that $1 \leq q(n) \leq 2$ for $n \geq 1$.
These relations can be proved using linear
representations computable by {\tt Walnut}.
We only prove the most complicated one,
namely Eq.~\eqref{a3}. Substituting $n = m+3$, we see that Eq.~\eqref{a3} is equivalent to
the claim that $f(8m+25) = 2f(2m+7) + f(4m+13) - q(m+3)$ for $m \geq 0$. We now obtain
linear representations
for each of the terms, using the following
{\tt Walnut} commands.
\begin{verbatim}
morphism aa "0->01 1->23 2->22 3->33":
morphism b "0->0 1->1 2->2 3->1":
promote Q1 aa:
image Q b Q1:
def term1 m "$LR(i,8*m+25)":
def term2 m "$LR(i,2*m+7)":
def term3 m "$LR(i,4*m+13)":
def term4 m "(i=0 & Q[m+3]=@1) | (i<=1 & Q[m+3]=@2)":
\end{verbatim}
From these four linear representations,
using block matrices, we can easily create a linear
representation for
$$f(8m+25) - 2f(2m+7) - f(4m+13) + q(m+3).$$
It has rank $735$. When we minimize it (using a {\tt Maple} implementation of the Sch\"utzenberger algorithm mentioned previously), we
get the linear representation for the $0$
function, thus proving the identity.
The other identities can be proved similarly.
\end{proof}
\begin{Theorem}
We have $f(n) \leq n$ for all $n \geq 1$. Furthermore, this bound is tight, since
$f(n) = n$ for $n = 3 \cdot 2^i$ and $i \geq 0$.
\label{thm16}
\end{Theorem}
\begin{proof}
We will actually prove the stronger bound that $f(n) \leq n - (n \bmod 2)$
for $n \geq 1$, by induction.
The base case is $1 \leq n < 29$. In this case we can verify the bound by direct computation. Otherwise assume $n \geq 29$ and the bound is true for all smaller positive $n' < n$; we prove it for $n$.
There are four cases
to consider: $n \equiv \modd{0} {2}$,
$n \equiv \modd{3} {4}$,
$n \equiv \modd{1} {8}$,
and $n \equiv \modd{5} {8}$.
Suppose $n \equiv \modd{0} {2}$. By induction we have
$f(n/2) \leq n/2 - (n/2 \bmod 2)$.
But from Eq.~\eqref{a1} we have $f(n) = 2f(n/2)
\leq 2(n/2) - 2(n/2 \bmod 2 ) \leq n$.
Suppose $n \equiv \modd{3} {4}$. By induction we have $f({(n-3) / 4}) \leq {(n-3)/ 4} -
({(n-3)/ 4} \bmod 2)$ and
$f({(n-1)/ 2}) \leq {(n-1)/ 2} -
({(n-1) / 2} \bmod 2)$. From
Eq.~\eqref{a2} we have
\begin{align*}
f(n) &= 2f((n-3)/4) + f({(n-1) / 2}) + q({(n-3) / 4}) \\
&= {(n-3)/2} - 2({(n-3)/4}
\bmod 2) + {(n-1)/2}
- ({ (n-1)/2}
\bmod 2) \\
&\quad\quad\quad +q({(n-3) / 4}) \\
&\leq n-1,
\end{align*}
as desired.
Suppose $n \equiv \modd{1} {8}$. By induction
we have
$f ({(n+3)/ 4}) \leq {(n+3) / 4} - ({(n+3)/ 4} \bmod 2) $ and
$f ({(n+1) / 2}) \leq {(n+1) / 2} -
({(n+1)/ 2} \bmod 2)$.
From Eq.~\eqref{a3} we have
\begin{align*}
f(n) &= 2 f({(n+3)/ 4}) + f({(n+1) / 2} ) - q({(n-1)/ 8}) \\
&\leq {(n+3)/ 2} - 2({(n+3)/4} \bmod 2)
+ {(n+1)/2} - 2({(n+1)/2} \bmod 2) \\
&\quad\quad\quad - q({(n-1)/ 8}) \\
&\leq n-1,
\end{align*}
as desired.
Suppose $n \equiv \modd{5} {8}$. By induction
we have
\begin{align*}
f({(n-5)/ 8}) &\leq {(n-5)/ 8} - ({(n-5)/ 8} \bmod 2) \\
f({(n-1)/ 4}) &\leq {(n-1)/ 4} -
({(n-1) / 4} \bmod 2) \\
f({(n+3) / 4}) &\leq {(n+3)/ 4} -
({(n+3) / 4} \bmod 2).
\end{align*}
From
Eq.~\eqref{a4} we have
\begin{align*}
f(n) &= 2 f({(n-5)/ 8}) + f({(n-1)/ 4})
+ 2f({(n+3)/ 4}) \\
&\leq {(n-5) / 4} - 2({(n-5)/ 8} \bmod 2) + {(n-1)/ 4} -
({(n-1) / 4} \bmod 2) \\
&\quad\quad\quad
+{(n+3) / 2} - 2({(n+3) / 4} \bmod 2)
\\
&\leq n-1,
\end{align*}
as desired.
This completes the proof of the upper bound.
We can see that $f(n) = n$ for $n = 3 \cdot 2^i$
as follows. Using the linear representation
for $n$ we have
$f(3 \cdot 2^i) = v_f \gamma_f(11) \gamma_f (0)^i w_f$. The minimal polynomial of
$\gamma_f (0)$ is $X^2 (X-1)(X+1)(X-2)$.
It follows that
$f(3 \cdot 2^i) = a \cdot 2^i + b + c(-1)^i$
for $i \geq 2$. Solving for the constants,
we find that $a = 3$, $b = 0$, $c = 0$,
and hence $f(3 \cdot 2^i) = 3 \cdot 2^i$
as claimed.
\end{proof}
\begin{Theorem}
We have $f(n) \geq n/2$ for $n \geq 0$, and
$f(n) \geq (n+3)/2$ for $n\geq 1$ odd. Furthermore, the bound $f(n) \geq n/2$ is
attained infinitely often.
\end{Theorem}
\begin{proof}
We prove the result by induction on $n$.
It is easy to verify by direct computation
that the result is true for $n < 29$.
Otherwise assume $n \geq 29$ and the bound is true for all small positive $n'<n$; we prove it for $n$.
Again we consider the four cases
$n \equiv \modd{0} {2}$,
$n \equiv \modd{3} {4}$,
$n \equiv \modd{1} {8}$,
and $n \equiv \modd{5} {8}$.
Suppose $n \equiv \modd{0} {2}$. By induction and Eq.~\eqref{a1} we have
$f(n) = 2 f(n/2) \geq 2 (n/2)/2 = n/2$.
Otherwise $n$ is odd.
Suppose $n \equiv \modd{3} {4}$. By induction
we have
\begin{align*}
f((n-3)/4) &\geq (n-3)/8 \\
f((n-1)/2) &\geq (n+5)/4.
\end{align*}
Hence
using Eq.~\eqref{a2} we get
\begin{align*}
f(n) &= 2f((n-3)/4) + f((n-1)/2) + q((n-3)/4) \\
&\geq (n-3)/4 + (n+5)/4 + q((n-3)/4) \\
& \geq (n+1)/2 + 1 \\
& = (n+3)/2.
\end{align*}
Suppose $n \equiv \modd{1} {8}$. By induction
we have
\begin{align*}
f((n+3)/4) &\geq ((n+3)/4 + 3)/2 = (n+15)/8 \\ f((n+1)/2) &\geq ((n+1)/2 + 3)/2 = (n+7)/4.
\end{align*}
Hence using Eq.~\eqref{a3} we
get
\begin{align*}
f(n) &= 2f((n+3)/4) + f((n+1)/2) - q((n-1)/8) \\
&\geq (n+15)/4 + (n+7)/4 - 2 \\
& = (n+7)/2.
\end{align*}
Suppose $n \equiv \modd{5} {8}$. By induction
we have
\begin{align*}
f((n-5)/8) &\geq (n-5)/16 \\
f((n-1)/4) &\geq ((n-1)/4 + 3)/2 = (n+11)/8 \\
f((n+3)/4) &\geq (n+3)/8.
\end{align*}
Hence using Eq.~\eqref{a4} we get
\begin{align*}
f(n) &= 2f((n-5)/8) + f((n-1)/4) + 2f((n+3)/4) \\
&\geq 2(n-5)/16 + (n+11)/8 + 2(n+3)/8 \\
&= (n+3)/2.
\end{align*}
This completes the induction proof of both lower bounds.
\smallskip
It is easy to prove, using the same techniques
as in the last part of the proof of Theorem~\ref{thm16}, that
$f(n) = n/2$ for $n = 2^i$, $i \geq 2$.
\end{proof}
\begin{Theorem}
We have $\sum_{0 \leq i < 2^n} f(i) = 19\cdot 4^n/48 - 2^n/4 + 5/3$ for $n \geq 2$.
\end{Theorem}
\begin{proof}
The summation $\sum_{0 \leq i < 2^n} f(i)$
is easily seen to equal
$v_f (\gamma_f (0) + \gamma_f (1))^n w_f$.
We can then apply the same techniques as above to
the matrix $\gamma_f (0) + \gamma_f (1)$.
\end{proof}
It follows that the ``average'' value of
$f(n)$ is $\frac{19}{24} n$.
\section{Dyck words in other sequences}
\begin{Proposition}
The only nonempty Dyck words in the Fibonacci word {\bf f} are $01$ and $0101$.
\end{Proposition}
\begin{proof}
Let $\theta$ be the Fibonacci morphism defined by $\theta(0)=01$ and $\theta(1)=0$.
Let $w$ be a nonempty Dyck factor of the Fibonacci word. Then $w$ begins with $0$,
ends with $1$, and has an equal number of $0$'s and $1$'s. It follows that $w=\theta(w')$,
where $w'$ is a factor of the Fibonacci word consisting entirely of $0$'s.
However, the longest such $w'$ is $w'=00$.
\end{proof}
A similar argument applied to the morphism that maps $0 \to 01$ and $1 \to 00$ gives
the following result.
\begin{Proposition}
The only nonempty Dyck words in the period-doubling sequence are
$01$,
$0101$, and
$010101$.
\end{Proposition}
Recall that the Rudin-Shapiro sequence
${\bf r}= (r(n))_{n \geq 0}$
is defined to be the number
of occurrences of $11$, taken modulo $2$, in
the base-$2$ expansion of $n$.
\begin{Theorem}
There are Dyck factors of arbitrarily large nesting level in the Rudin-Shapiro sequence.
\end{Theorem}
\begin{proof}
For $n\geq 0$ define $x_n = {\bf r}[2\cdot 4^n..4^{n+1}-1]$.
We will show, by induction on $n$, that
$x_n$ is a Dyck factor of nesting level
$2^{n+1} - 1$.
The base case is $n=0$. In this case ${\bf r}[2..3] = 01$ is a Dyck factor of nesting level $1$.
Now assume the result is true for $n$; we prove it for $n+1$. For $n \geq 0$ define
$y_n = {\bf r}[0..2\cdot 4^n - 1]$. We claim that
$x_{n+1} = y_n x_n \overline{y_n} x_n$; this follows
immediately by considering the first three bits
of the base-$2$ representations of the numbers
in the range $[2 \cdot 4^{n+1} .. 4^{n+2}-1]$.
Define $s(n) = \sum_{0 \leq i \leq n} (-1)^{r(i)}$.
It should be clear that $s(n)$ is the imbalance between the number of $0$'s (left parens) and $1$'s (right parens) in ${\bf r}[0..n]$.
We now claim that $0 < s(i) \leq s(2 \cdot 4^n - 1) = 2^{n+1}$ for $0 \leq i \leq 2 \cdot 4^n - 1$. In fact, the stronger claim $s(i) > 0$ for all $i$
is \cite[Satz 9]{Brillhart&Morton:1978}. The fact that $s(2 \cdot 4^n - 1) = 2^{n+1}$ is
\cite[Beispiel 6]{Brillhart&Morton:1978}, and
the inequality $s(i) \leq 2^{n+1}$ for $0 \leq i \leq 2 \cdot 4^n - 1$ can be deduced from
\cite[Satz 9]{Brillhart&Morton:1978}. Thus we have shown that the imbalance of $y_n$ is $2^{n+1}$,
the imbalance of $x_n$ is $0$ and its nesting
level is $2^{n+1} - 1$, the imbalance of $\overline{y_n}$ is $-2^{n+1}$, and hence
$x_{n+1} = y_n x_n \overline{y_n} x_n$ is Dyck
with nesting level $2^{n+2} - 1$.
\end{proof}
\begin{Question}
Consider the set of $n$ such that there is a Dyck factor of length $n$ in the Rudin-Shapiro word. Is it a $2$-automatic set? If not, this would
give an alternate proof, different from
that of \cite{Choffrut&Malcher&Mereghetti&Palano:2012}, that being a Dyck word is not an FO[+]-definable property.
\end{Question}
\begin{Conjecture}
The paperfolding sequence has a Dyck factor of length $n$ iff $n$ is of the form $2^k - 2^i$
for $0 \leq i < k$.
\end{Conjecture}
| {'timestamp': '2023-01-18T02:13:58', 'yymm': '2301', 'arxiv_id': '2301.06145', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06145'} | arxiv |
\section{Adaptation of BMC to HyperLTL on Infinite Traces}
\label{sec:adaptation}
There are two main obstacles in extending the BMC approach of~\cite{hsu21bounded} to handle
infinite traces.
First, a trace may have an irregular behavior. Second, even traces
whose behavior is regular, that is, lasso shaped, are hard to
synchronize, since the length of their respective prefixes and lassos
need not to be equal.
For the latter issue, synchronizing two traces whose {\color{black} prefixes} and lassos
are of lengths $p_1,p_2$ and $l_1,l_2$, respectively, is equivalent to
coordinating the same two traces, when defining both their prefixes to
be of length {\color{black} $\max\{p_1,p_2\}$}, and their lassos to be of length
{\color{black} $\mathrm{lcm}\{l_1,l_2\}$, where `$\mathrm{lcm}$' stands for
`least common multiple'.}
As for the former challenge, we show that restricting the exploration
of traces in the models to only consider lasso traces is sound.
That is, considering only lasso-shaped traces is equivalent to
considering the entire trace set of the models.
{\color{black}
Let $K = \langle S, S^0, \trans, \mathsf{AP}, L \rangle$ be a Kripke structure.
A {\em lasso path} of $K$ is a path
$s(0)s(1)\ldots s(\ell)$ such that $(s(\ell), s(n)) \in \delta$ for some {$0 \leq n <\ell$}.
This path induces a {\em lasso trace} (or simply, a {\em lasso})
$L(s_0)\dots L(s_{n-1})~ (L(s_n)\dots L(s_{\ell}))^\omega$.
Let $\tupleof{K_1,\ldots, K_k}$ be a multi-model.
We denote the set of lasso traces of $K_i$ by $C_i$ for all $1 \leq i \leq k$,
and {we use $\mathcal{L}{(C_i)}$ as the shorthand for the set of lasso traces of $K_i$.}
}
\newcounter{thm-lassos}
\setcounter{thm-lassos}{\value{theorem}}
\begin{theorem}
\label{thm:lassos}
Let $\mathcal{K} = \tupleof{K_1,\ldots, K_k}$ be a multi-model, and let
$\varphi = \mathbb{Q}_1 \pi_1. \cdots\mathbb{Q}_k \\\pi_k.\psi$ be a \hltl formula, both over $\mathsf{AP}$, then $\mathcal{K} \models \varphi$ iff $\tupleof{C_1,\ldots, C_k}\models \varphi$.
\end{theorem}
\begin{proof}(sketch)
For an \code{LTL} formula $\psi$ over $\mathsf{AP}\times \{\pi_i\}_{i=1}^{k}$,
we denote the translation of $\psi$ to an NBW over
$2^{\mathsf{AP}\times \{\pi_i\}_{i=1}^{k}}$ by $A_\psi$~\cite{vw86}.
Given $\alpha = \mathbb{Q}_1 \pi_1\cdots\mathbb{Q}_k \pi_k$,
where $\mathbb{Q}_i\in\{\exists, \forall\}$,
we define the satisfaction of
$A_\psi$ by $\mathcal{K}$ w.r.t. $\alpha$,
denoted $\mathcal{K} \models (\alpha$, $A_\psi$), in the natural way:
$\exists\pi_i$ corresponds to the existence of
a path assigned to $\pi_i$ in $K_i$, and dually for $\forall\pi_i$.
Then, $\mathcal{K} \models (\alpha, A_\psi)$ iff the various $k$-assignments of traces of $\mathcal{K}$ to $\{\pi_i\}_{i=1}^{k}$ according to $\alpha$ are accepted by $A_\psi$, which holds iff $\mathcal{K}\models \varphi$.
For a model $K$, we denote by $K \cap_k A_\psi$ the intersection of $K$ and $A_\psi$ w.r.t. {$\mathsf{AP}\times \{\pi_k\}$},
taking the projection over $\mathsf{AP}\times \{\pi_i\}_{i=1}^{k-1}$.
Thus, $\mathcal{L}(K \cap_k A_\psi)$
is the set of all $(k-1)$-words that
{\em an extension} (i.e., $\exists$) by a word in $\mathcal{L}(K)$ to a $k$-word in $\mathcal{L}(A_\psi)$.
Oppositely,
{$\mathcal{L}(\overline{K\cap_k \overline{A_\psi}})$}
is the set of all $(k-1)$-words that
{\em every extension} (i.e., $\forall$) by a $k$-word in $\mathcal{L}(K)$
is in {$\mathcal{L}({A_\psi})$}.
We first construct NBWs {$A_2,\ldots, A_{k-1}, A_{k}$},
such that for every {$1< i < k$}, we have
{$\tupleof{K_1,\ldots, K_i}\models (\alpha_i, A_{i+1})$}
iff
$\mathcal{K}\models (\alpha,A_\psi)$, where $\alpha_i = \mathbb{Q}_1\pi_1\dots \mathbb{Q}_i\pi_i$.
For $i = k$, if $\mathbb{Q}_k = \exists$, then $A_k = K_k\cap_k A_\psi$;
otherwise if $\mathbb{Q}_k = \forall$, {$A_k = \overline{K_k\cap_k \overline{A_{\psi}}}$.}
For $1< i< k$,
if $\mathbb{Q}_i = \exists$ then $A_i = K_i\cap_i A_{i+1}$;
otherwise if $\mathbb{Q}_i = \forall$,
$A_i = \overline{K_i\cap_i{\overline{A_{i+1}}}}$.
Then, for every {$1< i < k$},
we have $\tupleof{K_1,\ldots, K_i}\models (\alpha_i, A_{i+1})$
iff $\tupleof{K_1,\ldots, K_k}\models \varphi$.
We now prove by induction on $k$ that $\mathcal{K}\models \varphi$ iff $\tupleof{C_1,\ldots C_k}\models \varphi$.
For $k=1$, it holds that $\mathcal{K}\models \varphi$
iff
$K_1\models (\mathbb{Q}_1\pi_1,A_2)$.
If $\mathbb{Q}_1 = \forall$, then $K_1\models (\mathbb{Q}_1\pi_1,A_2)$ iff $K_1\cap \overline{A_2}= \emptyset$.
If $\mathbb{Q}_1 = \exists$, then $K_1\models (\mathbb{Q}_1\pi_1,A_2)$ iff $K_1\cap A_2\neq \emptyset$.
In both cases, a lasso witness to the non-emptiness exists.
For $1<i<k$, we prove that $\tupleof{C_1, \ldots, C_i, K_{i+1}}\models (\alpha_{i+1}, A_{i+2})$ iff
$\tupleof{C_1, \ldots, C_i, C_{i+1}}\models (\alpha_{i+1}, A_{i+2})$.
If $\mathbb{Q}_i = \forall$, then the first direction simply holds because
{$\mathcal{L}(C_{i+1})\subseteq \\ \mathcal{L}(K_{i+1})$}.
For the second direction, every extension of $c_1,c_2,\ldots c_{i}$
(i.e., lassos in $C_1,C_2,\ldots C_i$) by a path $\tau$ in $K_{i+1}$ is in {$\mathcal{L}(A_{i+2})$}.
Indeed, otherwise we can extract a lasso $c_{i+1}$
such that $c_1,c_2,\ldots c_{i+1}$ is in {$\overline{\mathcal{L}(A_{i+2})}$}, a contradiction.
If $\mathbb{Q}_i = \exists$, then $\mathcal{L}(C_{i+1})\subseteq \mathcal{L}(K_{i+1})$ implies the second direction.
For the first direction,
we can extract a lasso $c_{i+1}\in \mathcal{L}(C_{i+1})$ such that
{$\tupleof{c_1,c_2,\ldots c_i,c_{i+1}}\in \mathcal{L}(A_{i+2})$}.
\qed
\end{proof}
One can use Theorem~\ref{thm:lassos} and the observations above
to construct a sound and complete BMC algorithm for
{both $\forall\exists$ and $\exists\forall$ hyperproperties.}
Indeed, consider a multi-model $\tupleof{K_1,K_2}$,
and a hyperproperty $\varphi = \forall \pi. \exists \pi'. ~\psi$.
Such a BMC algorithm would try and verify $\tupleof{K_1,K_2}\models\varphi$ directly, or try and prove $\tupleof{K_1,K_2}\models\neg\varphi$.
In both cases, a run {\color{black} may find} a short lasso example for the model under $\exists$
($K_2$ in the former case and $K_1$ in the latter), leading to a shorter run.
However, in both cases, the model under $\forall$ would have to be explored to the maximal lasso length implicated by Theorem~\ref{thm:lassos}, which is doubly-exponential. Therefore, this naive approach would be highly inefficient.
\section{Simulation-Based BMC Algorithms for HyperLTL}
\label{sec:simulation}
We now introduce efficient simulation-based BMC algorithms for
verifying hyperproperties of the types
$\forall \pi. \exists \pi'.\Box \code{Pred}$ and
$\exists \pi. \forall \pi'.\Box \code{Pred}$, where $\code{Pred}$ is a {\em relational predicate}
(a predicate over a pair of states).
The key observation is that simulation naturally induces the
exploration of infinite traces without the need to explicitly unroll
the structures, and without needing to synchronize the indices of the
symbolic variables in both traces.
Moreover, in some cases our algorithms allow to only partially explore
the state space of a Kripke structure and give a conclusive answer {\color{black} efficiently}.
Let
{$K_\AAA = \tupleof{S_P, S_{P}^0, \delta_P,$ $\mathsf{AP}_P, L_P} $ and
$K_\BBB = \tupleof{S_Q, S_{Q}^0, \delta_Q,$ $\mathsf{AP}_Q, L_Q} $}
be two
Kripke structures, and consider a hyperproperty of the form
$\forall \pi. \exists \pi'.~\Box \code{Pred}$.
Suppose that there exists a simulation from $K_\AAA$ to $K_\BBB$. Then,
every trace in $K_\AAA$ is embodied in $K_\BBB$.
Indeed, we can show by
induction that for every trace
$t_p = \pstate{1}\pstate{2}\ldots$ in $K_\AAA$,
there exists a trace $t_q = \qstate{1}\qstate{2}\ldots$ in $K_\BBB$,
such that $\qstate{i}$ simulates $\pstate{i}$ for every $i\geq 1$;
therefore, $t_p$ and $t_q$ are equally labeled.
We generalize the labeling constraint in the
definition of standard simulation by requiring, given $\code{Pred}$, that if
$(s_p, s_q)$ is in the simulation relation, then $(s_p,s_q)\models\code{Pred}$. We
denote this generalized simulation by $\code{SIM$_{\text{AE}}$}$.
Following similar considerations, we now have that for every trace
$t_p$ in $K_\AAA$, there exists a trace $t_q$ in $K_\BBB$ such that
$(t_p,t_q)\models\Box\code{Pred}$.
Therefore, the following result holds:
\begin{lemma}
\label{lem:AE}
Let $K_\AAA$ and $K_\BBB$ be Kripke structures, and let
$\varphi =\forall\pi.\exists\pi'.~\Box \code{Pred}$ be a \hltl formula. If there exists $\code{SIM$_{\text{AE}}$}$ from $K_\AAA$ to $K_\BBB$, then $\tupleof{K_\AAA,K_\BBB}\models \varphi$.
\end{lemma}
We now turn to properties of the type $\exists\pi. \forall \pi'.~\Box \code{Pred}$. In this case, we must find a single trace in $K_\AAA$ that matches {\color{black} every trace in $K_\BBB$.}
Notice that $\code{SIM$_{\text{AE}}$}$ (in the other direction) does not suffice, since it is not guaranteed that the same trace in $K_\AAA$ is used to match all traces in $K_\BBB$.
However, according to Theorem~\ref{thm:lassos}, it is guaranteed that if $\tupleof{K_\AAA,K_\BBB}\models \exists \pi. \forall \pi'.~\Box \code{Pred}$, then there exists such a single {lasso} trace $t_p$ in $K_\AAA$ {\color{black} as the witness of the satisfaction}.
We therefore define a second notion of simulation, denoted $\code{SIM$_{\text{EA}}$}$, as follows.
Let $t_p = \pstate{1} \pstate{2} \ldots \pstate{n} \ldots \pstate{\ell}$ be a lasso trace in $K_\AAA$
(where $\pstate{\ell}$ closes to $\pstate{n}$, that is, $(\pstate{\ell}, \pstate{n}) \in \delta_P$).
A relation ${R}$ from $t_p$ to $K_Q$ is considered as a $\code{SIM$_{\text{EA}}$}$ from $t_p$ to $K_Q$,
if the following holds:
\begin{enumerate}
\item $(s_p,s_q)\models\code{Pred}$ for every $(s_p,s_q)\in{R}$.
\item $(\pstate{1},s_q)\in{R}$ for every $s_q \in S_{Q}^0$.
\item If $(\pstate{i},s_q(i))\in {R}$, then for every successor $s_q(i+1)$ of $s_q(i)$, it holds that \\ $(\pstate{i+1},s_q(i+1))\in{R}$ (where $\pstate{\ell+1}$ is defined to be $\pstate{n}$).
\end{enumerate}
If there exists a lasso trace $t_p$, then we say that there exists $\code{SIM$_{\text{EA}}$}$ from $K_\AAA$ to $K_\BBB$.
Notice that the third requirement in fact unrolls $K_\BBB$ in a way that guarantees that for every trace $t_q$ in $K_\BBB$, it holds that $(t_p,t_q) \models \Box\code{Pred}$.
Therefore, the following result holds:
\begin{lemma}
\label{lem:EA}
Let $K_\AAA$ and $K_\BBB$ be Kripke structures, and let
$\varphi = \exists\pi.\forall\pi'.~\Box \code{Pred}$. If there exists a $\code{SIM$_{\text{EA}}$}$ from $K_\AAA$ to $K_\BBB$, then $\tupleof{K_\AAA,K_\BBB}\models \varphi$.
\end{lemma}
Lemmas~\ref{lem:AE} and~\ref{lem:EA} enable sound algorithms for
model-checking
$\forall \pi. \exists \pi'.~\Box\code{Pred}$ and
$\exists \pi. \forall \pi'.~\Box\code{Pred}$ hyperproperties with loop conditions.
To check the former, check whether there exists $\code{SIM$_{\text{AE}}$}$ from $K_\AAA$
to $K_\BBB$; to check the latter, check for a lasso trace $t_p$ in
$K_\AAA$ and $\code{SIM$_{\text{EA}}$}$ from $t_p$ to $K_\BBB$.
Based on these ideas, we introduce now two SAT-based BMC algorithms.
For $\forall\exists$ hyperproperties, we not only check for the
existence of $\code{SIM$_{\text{AE}}$}$, but also iteratively seek a small subset of $S_Q$ that
suffices to simulate all states of $S_P$.
While finding $\code{SIM$_{\text{AE}}$}$, as for standard simulation, is polynomial, the problem of finding a
simulation that uses a bounded number of $K_Q$ states is NP-complete {\color{black} (see Appendix~\ref{sec:bounded.sim} for details).}
This allows us to
efficiently handle instances in which $K_\BBB$ is large.
Moreover, {\color{black} we introduce in Subsection~\ref{subsec:prophecies}}
the use of {\em prophecy variables}, allowing us to overcome cases in
which the models satisfy the property but $\code{SIM$_{\text{AE}}$}$ does not exist.
For $\exists\forall$ hyperproperties, we search for $\code{SIM$_{\text{EA}}$}$ by
seeking a lasso trace $t_p$ in $K_\AAA$, whose length increases with
every iteration, similarly to standard BMC techniques for \code{LTL}.
Of course, in our case, $t_p$ must be matched with
the states of $K_\BBB$ in a way that ensures $\code{SIM$_{\text{EA}}$}$. In the worst case,
the length of $t_p$ may be doubly-exponential in the sizes
of the systems. However, as our experimental results show, in case of
satisfaction the process can terminate much sooner.
We now describe our BMC algorithms and our SAT encodings in detail.
First, we fix the unrolling depth of $K_\AAA$ to $n$ and of $K_\BBB$ to
$k$.
To encode states of $K_P$ we allocate a family of Boolean variables
$\{x_i\}_{i=1}^n$.
Similarly, we allocate $\{y_j\}_{j=1}^k$ to represent the states
of $K_Q$.
Additionally, we encode the simulation relation ${T}$ by creating
$n\times{}k$ Boolean variables $\{\KWD{sim}_{ij}\}_{i=1}^n,_{j=1}^k$ such
that $\KWD{sim}_{ij}$ holds if and only if ${T}(p_i,q_j)$.
We now present the three {\color{black} variations} of encoding:
(1) EA-Simulation ($\code{SIM$_{\text{EA}}$}$),
(2) AE-Simulation ($\code{SIM$_{\text{AE}}$}$), and
(3) a special variation where we enrich AE-Simulation with prophecies.
\subsection{Encodings for EA-Simulation}
\label{subsec:EA}
The goal of this encoding is to find a lasso path $t_p$ in $K_\AAA$
that guarantees that there exists $\code{SIM$_{\text{EA}}$}$ to $K_\BBB$.
Note that the set of states that $t_p$ uses may be much smaller than the whole
of $K_P$, while the state space of $K_Q$ must be explored exhaustively.
We force $x_0$ be an initial state of $K_P$
and for $x_{i+1}$ to follow
$x_i$ for { every $i$} we use, but for $K_Q$ we will let the solver fill
freely each $y_k$ and add constraints\footnote{An alternative is to
fix an enumeration of the states of $K_Q$ and force the assignment of
$y_0\ldots$ according to this enumeration instead of constraining a
symbolic encoding, but the explanation of the symbolic algorithm
above is simpler.} for the full exploration of $K_Q$.
\begin{itemize}
\item {\bf All states are legal states.} The solver must only search
legal encodings of states of $K_P$ and $K_Q$ (we use $K_\AAA(x_i)$ to
represent the combinations of values that represent a legal state in
$S_P$ and similarly $K_\BBB(y_j)$ for $S_Q$):
\begin{align}
\bigwedge\limits_{i=1}^n
K_\AAA(x_i)
\land
\bigwedge\limits_{j=1}^k
K_\BBB(y_j)
\label{EAone}
\end{align}
\item {\bf Exhaustive exploration of $K_Q$.}
%
{\color{black}
We require that two different indices $y_j$ and $y_r$ represent two different
states in $K_Q$, so if $k=|K_Q|$, then all states are represented
{(note that the validity of states is implied by (1))}:
}
{\color{black}
\begin{align}
\bigwedge\limits_{j\neq{}r}
(\Kr_Q(y_j) \land \Kr_Q(y_r))
\rightarrow
(y_j \neq y_r)
\label{EAtwo}
\end{align}}%
{\color{black}{}%
\noindent where $y_j\neq y_r$ captures that some bit
distinguishes the states encoded by $j$ and $r$.}
\item {\bf The initial $S_{P}^0$ state simulates all initial $S_{Q}^0$ states.}
%
{\color{black}
State $x_0$ is an initial state of $K_P$ and simulates all initial states of $K_Q$
(we use $I_P$ to represent a legal initial state in $K_P$ and $I_Q(y_j)$
for $S_{Q}^0$ of $K_Q$):
}
\begin{align}
I_P(x_0) \And
\big(\bigwedge\limits_{j=1}^k
I_Q(y_j)
\mathrel{\rightarrow}
{T}(x_0, y_j)
\big)
\label{EAthree}
\end{align}
\item {\bf Successors in $K_Q$ are simulated by successors in $K_P$.}
%
We first introduce the following formula {\color{black} $\KWD{succ}_T(x,x')$} to capture
one-step of the simulation, that is, $x'$ follows $x$ and for all
$y$ if $T(x,y)$ then $x'$ simulates all successors of $y$
{\color{black} (we use $\delta_Q(y, y')$ to represent that $y$ and $y'$ states are in $\delta_{Q}$ of $K_Q$, similarly for $(x, x') \in \delta_{P}$ of $K_P$ we use $\delta_{P}(x, x'))$ }:
\[
\KWD{succ}_T(x,x')\,\stackrel{\text{def}}{=}\,
\bigwedge\limits_{y=y_1}^{y_k} T(x, y)
\rightarrow \big(
\bigwedge\limits_{y'=y_1}^{y_k} \delta_{Q} (y,y')
\rightarrow T(x', y')
\big)
\]
We can then define that $x_{i+1}$ follows $x_i$:
\begin{align}
\bigwedge\limits_{i=1}^{n-1}\big[
\delta_{P} (x_i, x_{i+1}) \And
\KWD{succ}_T(x_i,x_{i+1})\big]
\label{EAfour}
\end{align}
And, $x_n$ has a jump-back to a previously seen state:
\begin{align}
\bigvee\limits_{i=1}^n
\big[
\transit{P} (x_n, x_i) \And
\KWD{succ}_T(x_n,x_i)
\big]
\label{EAfive}
\end{align}
\item {\bf Relational state predicates are fulfilled by simulation.}
Everything relating in the simulation fits the relational predicate,
defined as a function $\code{Pred}$ of two sets of labels
{\color{black} (we use $L_Q(y)$ to represent the set of labels on the $y$-encoded state in $K_Q$, similarly, $L_P(x)$ for the $x$-encoded state in $K_P$)}:
\begin{align}
\bigwedge\limits_{i=1}^n
\bigwedge\limits_{j=1}^k
{T}(x_i,y_j)
\rightarrow
\code{Pred}(L_P(x_i), L_Q(y_j))
\label{EAsix}
\end{align}
\end{itemize}
We use $\ensuremath{\varphiEA}^{n,k}$ for the SAT formula that results of conjoining
$(\ref{EAone})$-$(\ref{EAsix})$ for bounds $n$ and $k$.
If $\ensuremath{\varphiEA}^{n,k}$ is satisfiable, then there exists $\code{SIM$_{\text{EA}}$}$ from $K_\AAA$ to $K_\BBB$.
\commentout{
The following lemma guarantees the soundness of the technique.
\begin{proof}(sketch) Assume $\ensuremath{\varphiEA}^{n,k}$ is satisfiable and let
$t_p$ be the path that corresponds to the assignment given by the
SAT solver to $(x_1\ldots x_n)(x_j\ldots x_n)^\omega$, where $j$ is
obtained by $(\ref{EA5})$.
%
The proof proceeds by induction showing that for all naturals $i$,
the first $i$ steps of $t_p$ match the first $i$ steps of every
path of $K_\BBB$, according to $\code{Pred}$.
\qed
\end{proof}
}
\subsection{Encodings for AE-Simulation}
\label{subsec:AE}
Our goal now is to find a set of states $S_Q' \subseteq S_Q$ that is
able to simulate all states in $K_P$.
Therefore, as in the previous case, the state space $K_P$
corresponding to the $\forall$ quantifier will be explored
exhaustively, and so $n=|K_P|$, while $k$ is the number of states in
$K_Q$, which increases in every iteration. As we have explained, this
allows finding a small subset of states in $K_Q$ which suffices to simulate all
states of $K_\AAA$.
\begin{itemize}
\item {\bf All states in the simulation are legal states.} Again,
every state guessed in the simulation is a legal state from $K_P$
or $K_Q$:
\begin{align}
\bigwedge\limits_{i=1}^n
\Kr_P(x_i)
\land
\bigwedge\limits_{j=1}^k
\Kr_Q(y_j)
\tag{$1'$}
\label{AEone}
\end{align}
\item {\bf $K_P$ is exhaustively explored.} Every two different
indices in the states of $K_P$ are different states\footnote{As in the previous
case, we could fix an enumeration of the states of $S_P$ and fix
$x_0x_1\ldots$ to be the states according to the enumerations.}:
{\color{black}
\begin{align}
\bigwedge_{i \neq r} ( \Kr_P(x_i) \land \Kr_P(x_r)) \rightarrow (x_i \neq x_r)
\tag{$2'$}
\label{AE2}
\end{align}
}
\item {\bf All initial states in $K_P$ must match with some initial state in $K_Q$.}
Note that, contrary to the $\exists\forall$ case,
here the initial state
in $K_Q$ may be different for each initial state in $S_P$:
\begin{align}
\bigwedge\limits_{i=1}^n
\bigvee\limits_{j=1}^k
I_P(x_i)
\rightarrow
\big(
I_Q (y_j)
\land
{T}(x_i, y_j)
\big)
\tag{$3'$}
\label{AE3}
\end{align}
\item {\bf For every pair in the simulation, each successor in $K_P$
must match with some successor in $K_Q$.}
For each $(x_i, y_j)$ in the simulation, every successor state of
$x_i$ has a matching successor state of $y_j$:
\begin{align}
\bigwedge\limits_{i=1}^n
\bigwedge\limits_{t=1}^n
\transit{P}(x_i, x_t)
\rightarrow
\bigwedge\limits_{j=1}^k
\Big[
{T}(x_i, y_j)
\rightarrow
\bigvee\limits_{r=1}^k
\Big(
\transit{Q}(y_j, y_r)
\land
{T}(x_t, y_r)
\Big)
\Big]
\tag{$4'$}
\label{AE4}
\end{align}
\item {\bf Relational state predicates are fulfilled.}
Similarly, all pairs of states in the simulation should respect the relational $\code{Pred}$:
{\color{black}
\begin{align}
\bigwedge\limits_{i=1}^n
\bigwedge\limits_{j=1}^k
{T}(x_i,y_j)
\rightarrow
\code{Pred}(L_P(x_i), L_Q(y_j))
\tag{$5'$}
\label{AEfive}
\end{align}
}
\end{itemize}
We now use $\ensuremath{\varphiAE}^{n,k}$ for the SAT formula that results of
conjoining (\ref{AEone})-(\ref{AEfive}) for bounds $n$ and $k$.
If $\ensuremath{\varphiAE}^{n,k}$ is satisfiable, then there exists $\code{SIM$_{\text{AE}}$}$ from $K_\AAA$ to $K_\BBB$.
\input{proph}
\section{Implementation and Experiments}
Encode SAT query for each question manually using Z3 API in python.
\subsection{Matrix Multiplication (Certificate Translation)}
It is often the case that reasoning about source programs dies not provide guarantees about the desirable behavior of the executable code.
In [Barthe'09], {\em certificate translation} can can take inputs of high-level programs (source) with a defined specification, and compute a set of verification conditions for the low level implementation (target).
Here we argue that with our simulation technique can directly proof the same thing, that is, specification preserved from the source to target.
Consider a program that compute the multiplication of the following $2 \times 2$ matrix:
$$
\begin{pmatrix}
a & b\\
c & d
\end{pmatrix}
$$
Consider a C-style implementation, where a matrix is represented by an uni-dimensional array, that computes the multiplication of a matrix, is as follows:
\begin{minipage}{.93\textwidth}
\begin{algorithm}[H]
\setcounter{AlgoLine}{0}
$i := 0;$ \\
\While{i < m}
{
$j := 0;$ \\
\While{j < p}
{
$k := 0;$ \\
\code{c[ i $\ast$ p + j ]} := 0; \\
\While{k < n}
{
\code{c[ i $\ast$ p + j ]} := \code{c[ i $\ast$ p + j ]} + \code{a[ i $\ast$ n + k ]} $\ast$ \code{b[k $\ast$ p + j ]}; \\
$k := k+1;$
}
$j := j+1;$
}
$i := i+1;$
}
\Return{0}
\caption{Source Program of Matrix Multiplication.}
\end{algorithm}
\end{minipage}
The procedure specification in [Barthe'09] are triples of $\langle Pre, annot, Post \rangle$, where $Pre$, and $Post$ are assertions and $annot$ is a partial function from labels to assertions.
In our framework, all three elements can be expressed as {\em hyperproperties}. That is, instead of translating the specification, we make sure that for all source executions, there exists a target executions, which preserves that the specification fulfilled by the source will also be fulfilled by the target.
\includegraphics[scale=.25]{figs/spec}
A matrix multiplication program that is translated from high-level code (C) to low-level code (RTL-- Register Transfer Level). Instead of translating the certificate, we find simulation.
\begin{minipage}{.93\textwidth}
\begin{algorithm}[H]
{\includegraphics[scale=.2]{figs/matrix_exists}}
\caption{Target Program of Matrix Multiplication.}
\end{algorithm}
\end{minipage}
To check if a translation is valid, we check:
$$ \varphi = \forall \pi. \exists \pi'. \LTLsquare\ (p_\pi \leftrightarrow p_{\pi'})$$
\newcommand{\texttt{sender}}{\texttt{sender}}
\newcommand{\texttt{receiver}}{\texttt{receiver}}
\newcommand{\textit{send}}{\textit{send}}
\newcommand{\textit{receive}}{\textit{receive}}
\newcommand{\textit{wait}}{\textit{wait}}
\subsection{Alternating-Bit Protocol (Scenario-based Synthesis)}
Synthesize a implementation from a set of scenarios augmented with a set of safety properties, provided the given scenarios adequately cover all the states of the desired implementation. Instead of independently check the synthesized protocol (HVC'14), instead, we find a simulation between the scenarios and the synthesized outcome.
The protocol has two parties: \texttt{sender}\ and \texttt{receiver}, where they can take three different actions: \textit{send}, \textit{receive}, and \textit{wait}. Each action is also specified by which message is currently transmitted, which is either a {\em packet} or {\em acknowledgment.} (denoted as $p_i$ and $a_i$, where $i$ is simply the index to distinguish different messages).
\begin{minipage}{.55\textwidth}
\begin{algorithm}[H]
\setcounter{AlgoLine}{0}
\While{true}
{
$\texttt{sender}.\textit{send}(p_0)$ \\
$\texttt{receiver}.\textit{receive}(p_0)$ \\
$\texttt{receiver}.\textit{send}(a_0)$ \\
$\texttt{sender}.\textit{receive}(a_0)$ \\
$\texttt{sender}.\textit{send}(p_1)$ \\
$\texttt{receiver}.\textit{receive}(p_1)$ \\
$\texttt{receiver}.\textit{send}(a_1)$ \\
$\texttt{sender}.\textit{receive}(a_1)$ \\
}
\caption{ABP-\emph{no loss}.}
\end{algorithm}
\end{minipage}
\begin{minipage}{.55\textwidth}
\begin{algorithm}[H]
\setcounter{AlgoLine}{0}
\While{true}
{
$\texttt{sender}.\textit{send}(p_0)$ \\
$\texttt{receiver}.\textit{receive}(p_0)$ \\
$\texttt{receiver}.\textit{send}(a_0)$ \\
$\texttt{sender}.\textit{receive}(a_0)$ \\
$\texttt{sender}.\textit{send}(p_1)$ \\
\If{packet-loss}{ go back to 6.}
$\texttt{receiver}.\textit{receive}(p_1)$ \\
$\texttt{receiver}.\textit{send}(a_1)$ \\
$\texttt{sender}.\textit{receive}(a_1)$ \\
}
\caption{ABP-\emph{packet loss}.}
\end{algorithm}
\end{minipage}
\begin{minipage}{.55\textwidth}
\begin{algorithm}[H]
\setcounter{AlgoLine}{0}
\While{true}
{
$\texttt{sender}.\textit{send}(p_0)$ \\
$\texttt{receiver}.\textit{receive}(p_0)$ \\
$\texttt{receiver}.\textit{send}(a_0)$ \\
$\texttt{sender}.\textit{receive}(a_0)$ \\
$\texttt{sender}.\textit{send}(p_1)$ \\
$\texttt{receiver}.\textit{receive}(p_1)$ \\
$\texttt{receiver}.\textit{send}(a_1)$ \\
\If{ack-loss}{ go back to 6.}
$\texttt{sender}.\textit{receive}(a_1)$ \\
}
\caption{ABP-\emph{ack loss}.}
\end{algorithm}
\end{minipage}
The synthesized protocol should not only have complete functionality but also {\em include all scenarios}. That is, the for all traces appear in any of the scenarios, there must be a corresponding trace exists in the synthesized protocol.
In this example, we consider (1) a manually built ABP, and (2) a synthesized ABP, from [HVC'14] which the models are as follows:
\includegraphics[scale=.3]{figs/abp_exists}
Finally, to verify whether a synthesis is correct, we check:
Given two programs -- scenarios (\texttt{small}) and synthesized protocol (\texttt{big})
$$ \varphi = \forall \pi. \exists \pi'. \LTLsquare\ (p_\pi \leftrightarrow p_{\pi'})$$
example: {\em HVC'14}, APB Protocols
\subsection{Secure Compilation}
Compile from source program to target program that preserves the security property.
The below target program violates confidentiality:
The source and target programs are identical as the CCS'22 paper.
\subsection{(New) Software Architectural Specification}
Software architecture (SA) has emerged as an autonomous discipline. Through suitable abstractions, it provides the means to make large applications manageable.
Recently, various approaches have been proposed on testing driven by the architectural specification. Our goal is to provide a test manager with a systematic method to extract suitable test classes for the higher levels of testing and to refine them into concrete tests at the code level. Essentially:
$$
\text{Software architecture (SA) in LTSs} \rightarrow \text{Abstract LTSs} \rightarrow \text{code-level test}
$$
We use the example from [IEEE'04]. The Teleservice and Remote Medical Care System (TRMCS) [32] is a system that provides monitoring and assistance to disabled or elderly people; containing: User, Router, Server, Timer.
Step 1: Model.
\includegraphics[scale=.3]{figs/1}
Step 2: Abstraction.
\includegraphics[scale=.3]{figs/2}
Step 3: code-level test.
\includegraphics[scale=.3]{figs/3}
Check traceability. Traceability concerns “relating the abstract values of the specification to the concrete values of the implementation”
For step 3, we can replaced as a simulation search using our approach. Instead of checking the behavior of each component by the Finite State Process (FSP) generated by LTS, we can simply find the simulation and check conformance between the abstraction and the implementation.
\section{Completeness and Applications}
{\bf Contributions:} \\
\code{SIM$_{\text{AE}}$}, \code{SIM$_{\text{EA}}$}, and we use {prophecy variables for non-deterministic models}.\\
\noindent{\bf Goal:}\\
If a simulation exists, the following implications hold:
\begin{table}[h]
\renewcommand{\arraystretch}{1.2}
\centering
\scalebox{1}{
\input{table_complete}
}
\vspace{3mm}
\label{tab:results}
\end{table}
\begin{table}[h]
\input{table_exp}
\end{table}
\noindent{\bf Applications:}
\newcommand{\text{violation}}{\text{violation}}
\begin{itemize}
%
\item Verification of secure compiler optimization: \\
Given two programs -- target (\texttt{big})and source (\texttt{small})
$$ \varphi = \forall \pi. \exists \pi'. \LTLsquare\ (\text{violation}_\pi \rightarrow \text{violation}_{\pi'})$$
examples: {\em witnessing\_secure\_compilation}
%
\item Verification of scenario-based synthesis: \\
Given two programs -- scenarios (\texttt{small}) and synthesized protocol (\texttt{big})
$$ \varphi = \forall \pi. \exists \pi'. \LTLsquare\ (p_\pi \leftrightarrow p_{\pi'})$$
example: {\em HVC'14}, APB Protocols
%
\item Verification of model translations(semantic/behavioral conformance).\\
$$ \varphi = \forall \pi. \exists \pi'. \LTLsquare\ (p_\pi \leftrightarrow p_{\pi'})$$
example: {\em Barthe'09}, Matrix Multiplication
%
\item Verification of relational property without program composition.
\begin{itemize}
\item translation validation
\item predicate abstraction
\end{itemize}
\item Verification of equivalence for database-driven applications.
\end{itemize}
\section{Conclusion and Future Work}
\label{sec:concl}
We introduced efficient loop conditions for bounded model
checking of fragments of \hltl.
We proved that considering only lasso-shaped traces is equivalent to
considering the entire trace set of the models, and proposed two
simulation-based algorithms $\code{SIM$_{\text{EA}}$}$ and $\code{SIM$_{\text{AE}}$}$ to realize infinite
reasoning with finite exploration for \code{HyperLTL} formulas.
To handle non-determinism in the latter case, we combine the models
with prophecy automata to provide the (local) simulations with enough
information to select the right move for the inner $\exists$ path.
Our algorithms are implemented using \code{Z3py}.
We have evaluated the effectiveness and efficiency with successful
verification results for a rich set of input cases, which previous
bounded model checking approach would fail to prove.
As for future work, we are working on exploiting general prophecy
automata (beyond safety) in order to achieve full generality for the
$\forall\exists$ case.
The second direction is to handle asynchrony between the models in our
algorithm.
Even though model checking asynchronous variants of \hltl is in
general undecidable~\cite{gutsfeld21automata,baumeister21temporal,bozzelli21asynchronous},
we would like to explore semi-algorithms and fragments with
decidability properties.
{\color{black} Lastly, exploring how to handle infinite-state systems
with our framework by applying {\em abstraction} techniques is also another promising
future direction.}
\section{Implementation and Experiments}
\label{sec:exp}
\newcommand{\text{violation}}{\text{violation}}
We have implemented our algorithms using the SAT solver \code{Z3} through its python
API \code{Z3Py}~\cite{moura2008z3}.
The SAT formulas introduced in Section~\ref{sec:simulation} are encoded into the two scripts \texttt{simEA.py} and \texttt{simAE.py}, for finding simulation relations for the $\code{SIM$_{\text{EA}}$}$ and $\code{SIM$_{\text{AE}}$}$ cases, respectively.
We evaluate our algorithms with a set of experiments, which includes all forms of quantifiers
with different sizes of given models, {\color{black} as presented earlier in Table~\ref{tab:category}}.
Our simulation algorithms benefit the most in the cases of the form
$\forall_\texttt{small}~\exists_\texttt{big}$.
When the second model is
substantially larger than the first model, $\code{SIM$_{\text{AE}}$}$ is able to
prove that a $\forall\exists$ hyperproperty holds by exploring only a
subset of the second model.
In this section, besides $\forall_\texttt{small}~\exists_\texttt{big}$ cases, we also investigate multiple cases on each category in Table~\ref{tab:category} to demonstrate the generality and applicability of our algorithms.
All case studies are run on a MacBook Pro with Apple M1 Max chip and 64 GB of memory.
\subsection{{\color{black} Case Studies and Empirical Evaluation}}
\subsubsection{Conformance in Scenario-based Programming.}
In scenario-based programming, scenarios provide a big picture of the
desired behaviors of a program, and are often used in the context of
program synthesis or code generation.
A synthesized program should obey what is specified
in the given set of scenarios to be considered {\em correct}.
That is, the program {\em conforms} with the scenarios.
The conformance check between the scenarios and the
synthesized program can be specified as a $\forall\exists$-hyperproperty:
$$
\varphi_\textsf{conf} = \forall \pi. \exists \pi'. \bigwedge_{p \in \mathsf{AP}}\LTLsquare\ ({p}_\pi \leftrightarrow
{p}_{\pi'}),
$$
where $\pi$ is over the scenario model and $\pi'$ is over the synthesized program.
That is, for all possible runs in the scenarios, there must exists a run in the program, such that their behaviors always match.
We look into the case of synthesizing an {\em Alternating Bit Protocol (ABP)} from four given scenarios, inspired by~\cite{alur2014synthesizing}.
ABP is a networking protocol that guarantees reliable message transition, when message loss or data duplication are possible.
The protocol has two parties: \texttt{sender}\ and \texttt{receiver}, which can take three different actions: \textit{send}, \textit{receive}, and \textit{wait}. Each action also specifies which message is currently transmitted: either a {\em packet} or {\em acknowledgment}
{\color{black} (see~\cite{alur2014synthesizing} for more details)}.
The correctly synthesized protocol should not only have complete functionality but also {\em include all scenarios}. That is, for every trace that appears in some scenario, there must exist a corresponding trace in the synthesized protocol.
By finding $\code{SIM$_{\text{AE}}$}$ between the scenarios and the synthesized protocols, we can prove the conformance specified with $\varphi_\textsf{conf}$.
Note that the scenarios are often much smaller than the actual synthesized protocol, and so
this case falls in the $\forall_\texttt{small}~\exists_\texttt{big}$ category in Table~\ref{tab:category}.
We consider two variations: a correct and an incorrect ABP (that cannot handle packet loss).
Our algorithm successfully identifies
a $\code{SIM$_{\text{AE}}$}$ that satisfies $\varphi_\textsf{conf}$ for
the correct ABP, and returns UNSAT for the incorrect protocol, since
the packet loss scenario cannot be simulated.
\subsubsection{Verification of Model Translation.}
It is often the case that in model translation (e.g., compilation),
solely reasoning about the source program does not provide guarantees about the desirable behaviors in the target executable code.
Since program verification is expensive
compared with repeatedly checking the target,
alternative approaches such as {\em certificate translation}~\cite{barthe2009implementing} are often preferred.
Certificate translation takes inputs of a high-level program (source) with a given specification, and computes a set of verification conditions (certificates) for the low-level executable code (target) to prove that a model translation is safe.
However, this technique still requires extra efforts to map the
certificates to a target language, and the size of generated
certificates might explode quickly (see~\cite{barthe2009implementing} for retails).
We show that our simulation algorithm can directly show the correctness
of a model translation more efficiently by investigating the
source and target with the same formula $\varphi_\textsf{conf}$ used for ABP.
That is, the specifications from the source runs $\pi$ are always preserved in some target runs $\pi'$, which infers a correct model translation.
Since translating a model into executable code implies adding extra
instructions such as writing to registers, it also falls into the
$\forall_\texttt{small}~\exists_\texttt{big}$ category in Table~\ref{tab:category}.
We investigate a program from~\cite{barthe2009implementing} that performs
{\em matrix multiplication (MM)}.
When executed, the C program is translated from high-level code (C) to low-level code RTL (Register Transfer Level), which contains extra steps to read from/write to memories.
Specifications are triples of $\langle \textit{Pre}, \KWD{annot}, \KWD{Post} \rangle$,
where $\textit{Pre}$, and $\KWD{Post}$ are assertions and $\KWD{annot}$ is a partial
function from labels to assertions (see~\cite{barthe2009implementing}
for detailed explanations).
The goal is to make sure that the translation does not violate the
original verified specification.
In our framework, instead of translating the certification, we find a simulation that
satisfies {\color{black} $\varphi_\textsf{conf}$}, proving that the translated code also satisfies the specification.
We also investigate two variations in this case: a correct translation and an incorrect
translation, and our algorithm returns SAT (i.e., finds a correct \code{SIM$_{\text{AE}}$} simulation) in the former case, and returns UNSAT for the latter case.
\begin{wrapfigure}{r}{.4 \columnwidth}
\vspace*{-7mm}
\centering
\begin{minipage}{.4 \columnwidth}
\includegraphics[scale=.16]{fig_cbf1}
\end{minipage}
\begin{minipage}{.4 \columnwidth}
\includegraphics[scale=.16]{fig_cbf2}
\end{minipage}
\caption{The common branch factorization example~\cite{namjoshi2020witnessing}.}
\label{fig:cbf}
\vspace*{-5mm}
\end{wrapfigure}
\subsubsection{Compiler Optimization.}
Secure compiler optimization aims at preserving input-output behaviors of an original implementation and a target program after applying optimization techniques, including security policies.
The conformance between source and target programs guarantees that the optimizing procedure does not introduce vulnerabilities such as information leakage.
Furthermore, optimization is often not uniform for the same source, because one might compile the source to multiple different targets with different optimization techniques.
As a result, an efficient way to check the behavioral equivalence between the source and target
provides a correctness guarantee for the compiler optimization.
Imposing optimization usually results in a smaller program.
For instance, {\em common branch factorization} (CBF) finds common operations in an if-then-else
structure, and moves them outside of the conditional so that such operation is only executed once.
As a result, for these optimization techniques, checking the conformance
of the source and target falls in the $\forall_\texttt{big}~\exists_\texttt{small}$ category.
That is, given two programs, source (\texttt{big}) and target (\texttt{small}), we check the following formula:
$$ \varphi_\textsf{sc} = \forall \pi. \exists \pi'. ~ (\textsf{in}_\pi \leftrightarrow \textsf{in}_{\pi'}) \rightarrow \LTLsquare\ (\textsf{out}_\pi \leftrightarrow \textsf{out}_{\pi'}).$$
In this case study we investigate the strategy {\color{black} CBF} using the example in Figure~\ref{fig:cbf} inspired by~\cite{namjoshi2020witnessing}.
We consider two kinds of optimized programs for the strategy, one is the correct
optimization, one containing bugs that violates the original behavior due to the optimization.
For the correct version, our algorithm successfully discovered a simulation relation
between the source and target, and the simulation relation
returns a smaller subset of states in the second model (i.e., $|Q'| < |Q|$).
For the incorrect version, we received UNSAT.
\begin{wrapfigure}{r}{0.18 \columnwidth}
\vspace*{-7mm}
\scalebox{.6}{
\input{fig_rob.tex}
}
\caption{A\\ robust paths.}
\label{fig:robot}
\vspace*{-8mm}
\end{wrapfigure}
\subsubsection{Robust Path Planning.}
In robotic planning, {\em robustness planning (RP)} refers to a path that is able to consistently complete a mission without being interfered by the uncertainty in the environment (e.g., adversaries).
For instance, in the 2-D plane in Fig.~\ref{fig:robot}, an agent is trying to go from the
starting point (blue grid) to the goal position (green grid).
The plane also contains three adversaries on the three corners other
than the starting point (red-framed grids), and {\color{black} the
adversaries move trying to catch the agent but can only move in one
direction (e.g., clockwise).}
This is a $\exists_\texttt{small}~ \forall_\texttt{big}$ setting, since the adversaries may have
several ways to cooperate and attempt to catch the agent.
We formulate this planning problem as follows:
$$ \varphi_\textsf{rp} = \exists \pi. \forall \pi'.~ \LTLsquare\ (\textsf{pos}_\pi \not\leftrightarrow \textsf{pos}_{\pi'}).$$
That is, there exists a robust path for the agent to safely reach the goal regardless of all the ways that the adversaries could move.
We consider two scenarios, one in which there exists a way for the agent to form a robust path and one does not.
Our algorithm successfully returns SAT for case which the agent can form a robust path,
and returns UNSAT for which a robust path is impossible to find.
\subsubsection{Plan Synthesis.}
The goal of {\em plan synthesis (PS)} is to synthesize a single comprehensive plan that can simultaneously
satisfy all given small requirements has wide application in planning
problems.
We take the well-known toy example, {\em wolf, goat, and
cabbage}\footnote{\url{https://en.wikipedia.org/wiki/Wolf,_goat_and_cabbage_problem}},
as a representative case here.
The problem is as follows. A farmer needs to cross a river by boat with a wolf, a goat, and a cabbage.
However, the farmer can only bring one item with him onto the boat each time.
In addition, the wolf would eat the goat, and the goat would eat the
cabbage, if they are left unattended.
The goal is to find a plan that
allows the farmer to successfully cross the river with all three
items safely.
A plan requires the farmer to go back and forth with the boat
with certain possible ways to carry different items, while
all small requirements (i.e., the constraints among each item) always satisfied.
In this example, the overall plan is a big model while the requirements form
a much smaller automaton.
Hence, it is a $\exists_\texttt{big}~ \forall_\texttt{small}$ problem that can be specified with
the following formula:
$$ \varphi_\textsf{ps} = \exists \pi. \forall \pi'.~\LTLsquare\ ( \textsf{action}_\pi \not\leftrightarrow \textsf{violation}_{\pi'}).$$
\begin{table}[t]
\centering
\input{table_exp}
\caption{
{\color{black} Summary of our case studies.
The outcomes with simulation discovered
show how our algorithms find a smaller subset for either $K_P$ or $K_Q$.
}
}
\label{tab:summary}
\vspace*{-8mm}
\end{table}
\subsection{Analysis and Discussion}
The summary of our empirical evaluation is presented in Table~\ref{tab:summary}.
For the $\forall\exists$ cases, our algorithm successfully
{\color{black} finds a set $|S_Q'| < |S_Q|$ that satisfies the properties for the cases ABP and CBF.}
Note that case MM does not find a small subset, since we manually add
extra {\em paddings} on the first model to align the length of both
traces.
We note that handling this instance without padding requires asynchornicity---
a much more difficult problem, which we leave for future work.
For the $\exists\forall$ cases, we are able to find a subset of $S_P$
which forms a single lasso path that can simulate all runs in $S_Q$ for
all cases RP and GCW.
{\color{black} We emphasize here that previous BMC techniques
(i.e., $\code{HyperQB}\xspace$) cannot handle most of the cases in Table~\ref{tab:summary}
due to the lack of loop conditions.}
\section{Categories}
\newpage
\section{Ideas for Case Studies}
\noindent{$\forall \pi [M_1: small].\ \exists \pi' [M_2: large].$ {\it Box property always holds if \regs\ exists.}}
\begin{itemize}
\item {\bf Scenario programming (behavioral programming)}\\
Abstract design are in message sequence chart (MSC) and live sequence chart (LSC). The goal is to synthesize the desired program, and further test it using verification tools.
\begin{itemize}[label={$\circ$}]
\item ~{\color{blue} [HVC’14]:
Synthesis ABP protocol with 4 scenarios (example behaviors) and a set of temporal specification(safety/liveness)}.
\end{itemize}
\item {\bf Certificate translation} \\
Source + (proof, advice, certificate,…) to Target + (proof’, advice’, certificate’,…). Translate proof to proof’ to guarantee the correctness of the target program to deal with untrusted intermediaries such as compiler, translator, etc.
\begin{itemize}[label={$\circ$}]
\item ~ {\color{blue} [Barthe'09] Matrix Multiplication program, from
high-level code (C) $\rightarrow$ property (ACSL) $\rightarrow$ low-level code (RTL)}
\end{itemize}
\item {\bf Programming by Example (PBE)}
\begin{itemize}[label={$\circ$}]
\item ~[vldb'18]: Use code-by-example to form a program that transforms `Hierarchical data models` to `relational format`
\item ~[untrustedCG]:
\end{itemize}
\item {\bf Composability of interface automatas} \\
For automatic compatibility check. (Checking the interfaces of two components are compatible. It is computing `two interfaces` instead of with the implementation.
\begin{itemize}[label={$\circ$}]
\item ~[Henzinger'01]
\end{itemize}
\item {\bf Sequentialization} \\
Synthesize and verify the sequentialization of some concurrent programs. Sequential program over-approximates the semantics of the original distributed program, safety properties are thus proved. (They are always ‘equivalent’)
\item {\bf Verifying compiled programs (secure compilation)}\\
Verifying source and target programs compiled by a compiler.
Cannot locate on papers that provide concrete examples of before/after compilation, except for the optimization paper.
\begin{itemize}[label={$\circ$}]
\item ~[optimization paper]
\end{itemize}
\item {\bf Behavioral conformance}
\item \underline{Model/Program transformation verification (M2M)}
\item \underline{Flows}
\end{itemize}
\section{Introduction}
\label{sec:intro}
Hyperproperties~\cite{cs10} have been getting increasing attention due
to their power to reason about important specifications such as
information-flow security policies that require reasoning about the
interrelation among different execution traces.
\hltl~\cite{clarkson14temporal} is an extension of the linear-time temporal logic
\code{LTL}~\cite{pnueli77temporal} that allows
quantification over traces; hence, capable of describing
hyperproperties.
For example, the security policy {\em observational determinism} can
be specified as \hltl formula:
\(
\forall \pi.\forall \pi'.(o_{\pi} \leftrightarrow o{_{\pi'}})
\, \mathcal{W} \, \neg (i_{\pi} \leftrightarrow i{_{\pi'}}),
\)
which specifies that for every pair of traces $\pi$ and $\pi'$, if
they agree on the secret input $i$, then their public output $o$ must
also be observed the same (here `$\mathcal{W}$' denotes the weak until
operator).
Several works~\cite{frs15,coenen19verifying} have studied model
checking techniques for \hltl specifications, which typically reduce
this problem to \code{LTL} model checking queries of modified systems.
More recently,~\cite{hsu21bounded} proposed a QBF-based algorithm for
the direct application of bounded model checking (BMC)~\cite{cbrz01}
to \hltl, and successfully provided a push-button solution to
verify or falsify \hltl formulas with an arbitrary number of quantifier
alternations.
However, unlike the classic BMC for \code{LTL}, which included the
so-called {\em loop conditions}, the algorithm in~\cite{hsu21bounded}
is limited to (non-looping) linear exploration of paths.
The reason is that extending path exploration to include loops when
dealing with multiple paths simultaneously is not straightforward.
For example, consider the \hltl formula
\(
\varphi_1 = \forall {\pi}. \exists {\pi'}. ~\LTLsquare(a_{\pi}\rightarrow b_{\pi'})
\)
and a pair of Kripke structures $K_1$ and $K_2$ as
follows:
\begin{center}
\vspace{-2em}
\begin{tabularx}{\textwidth}{m{3em}@{}X@{\hspace{5em}}m{3em}@{}X}
$K_1$& \parbox[c]{\hsize}{\scalebox{0.6}{\KRIPKEA}} & $K_2$ & \parbox[c]{\hsize}{\scalebox{0.6}{\KRIPKEB}}
\end{tabularx}
\end{center}
\vspace*{-1em}
\noindent Assume trace $\pi$ ranges over $K_1$ and trace $\pi'$ ranges over $K_2$.
Proving $\langle K_1, K_2 \rangle \not\models \varphi_1$ can be achieved by finding a finite
counterexample (i.e., path $s_1s_2s_3$ from $K_1$).
Now, consider
\(
\varphi_2 = \forall {\pi}. \exists {\pi'}. ~\LTLsquare(a_{\pi}\leftrightarrow a_{\pi'}).
\)
It is easy to see that $\langle K_1, K_2 \rangle\models \varphi_2$.
However, to prove $\langle K_1, K_2 \rangle \models \varphi_2$, one
has to show the absence of counterexamples in infinite paths, which
is impossible with model unrolling in finite steps as proposed
in~\cite{hsu21bounded}.
In this paper, we propose efficient loop conditions for BMC of hyperproperties.
First, using an automata-based method, we show that lasso-shaped
traces are sufficient to prove infinite behaviors of traces within finite
exploration.
However, this technique requires an unrolling bound that renders it
impractical.
Instead, our efficient algorithms are based on the notion of {\em
simulation}~\cite{Pnu85} between two systems.
Simulation is an important tool in verification, as it is used
for abstraction, and preserves \code{ACTL$^{*}$} properties
\cite{BBLS92,GL94}.
As opposed to more complex properties such as language containment,
simulation is a more local property and is easier to check.
The main contribution of this paper is the introduction of practical algorithms that
achieve the exploration of infinite paths following a simulation-based
approach that is capable of relating the states of multiple models
with correct successor relations.
We present two different variants of simulation, \code{SIM$_{\text{EA}}$} and \code{SIM$_{\text{AE}}$},
allowing to check the satisfaction of $\exists\forall$ and $\forall\exists$ hyperproperties,
respectively. These notions circumvent the need to
boundlessly unroll traces in both structures and synchronize them.
For \code{SIM$_{\text{AE}}$}, in order to resolve non-determinism in the first model,
we also present a third variant, where we enhance \code{SIM$_{\text{AE}}$}
by using {\em prophecy variables}~\cite{al91,beutner22prophecy}.
Prophecy variables allow us to handle
cases in which $\forall\exists$ hyperproperties hold despite the lack of a direct
simulation.
With our simulation-based approach, one can capture infinite behaviors of traces
with finite exploration in a simple and concise way.
Furthermore, our BMC approach not only model-checks the systems for
hyperproperties, but also does so in a way that finds {\em minimal} witnesses to
the simulation (i.e., by partially exploring the existentially quantified model),
which we will further demonstrate in our empirical evaluation.
\begin{wraptable}{r}{.638 \textwidth}
\vspace*{-6mm}
\renewcommand{\arraystretch}{1.2}
\centering
\scalebox{1}{
\input{table_complete}
}
\caption{
Eight categories of \code{HyperLTL} formulas with different forms of quantifiers, sizes of models, and different temporal operators.
}
\label{tab:category}
\vspace*{-5mm}
\end{wraptable}
We also design algorithms that generate SAT formulas for each variant
(i.e., \code{SIM$_{\text{EA}}$}, \code{SIM$_{\text{AE}}$}, and \code{SIM$_{\text{AE}}$} with prophecies), where the
satisfiability of formulas implies the model checking outcome.
We also investigate the practical cases of models with different sizes
leading to the eight categories in Table~\ref{tab:category}.
For example, the first row indicates the category of verifying two models
of different sizes with the fragment that only allows $\forall\exists$ quantifiers and $\LTLsquare$ (i.e., {\em
globally} temporal operator);
$\forall_\texttt{small} \exists_\texttt{big}$ means that the first model is
relatively smaller than the second model, and the positive
outcome ($\models\forall\exists\LTLsquare\varphi$) can be proved by our
simulation-based technique \code{SIM$_{\text{AE}}$}, while the negative outcome
($\not\models\forall\exists\LTLsquare\varphi$) can be easily checked using
non-looping unrolling (i.e.,~\cite{hsu21bounded}).
We will show that in certain cases, one can verify a $\LTLsquare$ formula
without exploring the entire state space of the $\texttt{big}$ model to
achieve efficiency.
{\color{black} We have implemented our
algorithms\addtocounter{footnote}{-3}\footnote{Available at:
\url{https://github.com/TART-MSU/loop_condition_tacas23}} using
\code{Z3py}, the \code{Z3}~\cite{dmb08} API in python.}
We demonstrate the
efficiency of our algorithm exploring a subset of the state space for
the larger {\color{black} (i.e., \texttt{big})} model.
We evaluate the applicability and efficiency with cases including
conformance checking for distributed protocol synthesis, model
translation, and path planning problems.
In summary, we make the following contributions: (1) a bounded model
checking algorithm for hyperproperties with loop conditions, (2)
three different practical algorithms: \code{SIM$_{\text{EA}}$}, \code{SIM$_{\text{AE}}$}, and \code{SIM$_{\text{AE}}$} with
prophecies, and (3) a demonstration of the efficiency and
applicability by case studies that cover through all eight different
categories of \hltl formulas (see Table~\ref{tab:category}).
\mypar{Related Work}
Hyperproperties were first introduced by Clarkson and
Schneider~\cite{cs10}.
\hltl was introduced as a temporal logic for hyperproperties
in~\cite{clarkson14temporal}.
The first algorithms for model checking \hltl were introduced
in~\cite{frs15} using alternating automata.
Automated reasoning about \code{HyperLTL} specifications has received attention in many aspects, including static
verification~\cite{frs15,fmsz17,fht18,cfst19} and
monitoring~\cite{ab16,fhst19,bsb17,bss18,fhst18,sssb19,hst19}.
This includes tools support, such as \code{MCHyper}~\cite{frs15,cfst19}
for model checking, \code{EAHyper}~\cite{fhs17} and
\code{MGHyper}~\cite{fhh18} for satisfiability checking, and
\code{RVHyper}~\cite{fhst18} for runtime monitoring.
{\color{black}
However, the aforementioned tools are either limited to \code{HyperLTL} formulas
without quantifier alternations, or requiring additional inputs from the user (e.g., manually added strategies~\cite{cfst19}).
}
Recently, this difficulty of alternating formulas was tackled by the
bounded model checker \code{HyperQB}~\cite{hsu21bounded} using QBF
solving.
However, \code{HyperQB} lacks loop conditions to capture early
infinite traces in finite exploration.
In this paper, we develop simulation-based algorithms to overcome this limitation.
There are alternative approaches to reason about infinite traces, like reasoning about strategies to deal with $\forall\exists$
formulas~\cite{coenen19verifying}, whose completeness can be obtained
by generating a set of prophecy variables~\cite{beutner2022prophecy}.
In this work, we capture infinite traces in BMC approach using
simulation.
We also build an applicable prototype for model-check \code{HyperLTL} formulas
with models that contain loops.
\section{Meeting Notes}
\subsection{(Initial Idea) Finite Enumeration of Loops}
Explore each simple loops of the forall quantifier in $\forall\exists$ formula.
\begin{algorithm}
\caption{Matching Simple Loops}\label{alg:cap}
for each $\ell$ in loops of $\forall$ model: \\
~~~increase bound $k$ \\
~~~find $\ell'$ in $\exists$ model that matches $\ell$\\
~~~return when each $\ell$ in the $\forall$ model has a matching $\ell'$ in $\exists$ model.
\end{algorithm}
\subsection{Models as Language}
Decompose $\forall$ model as language $L(M_A)$, which can be
decomposed into:
$$|\{ L_1 \cup L_2 \cup L_2 \cup \ldots \cup L_m \}| \geq |L(M_A)|$$
Each $L_i$ must have {\em some properties} (i.e., simple candidates)
$$M = \langle M_1, M_2, \ldots, M_m \rangle, M \models \varphi \text{ iff }
\langle C_1, C_2, \ldots, C_m \rangle \models \varphi$$
The number of lasso paths is bounded by the size of automaton, so it limits the search.
\newcommand{{invisible}}{{invisible}}
\newcommand{{visible}}{{visible}}
\subsection{Visible and Invisible States}
Over-/Under-approximation by classifying some states as `invisible` (i.e., sink, or don't-care states). The transition relation $R(x, x')$ becomes:
$$ ( {invisible}_x \rightarrow {invisible}_{x'}) \land ({visible}_x \rightarrow R(x, x')) $$
\subsection{Simulations}
\begin{itemize}
\item Full-exploration for $\forall$ and under-approximation for $\exists$
\item Over-approximation for $\forall$ and under-approximation for $\exists$
\item IC3? (for loops)
\end{itemize}
\noindent QBF Encoding for simulations.
\noindent SAT Encoding for simulations.
\vspace{3mm}
\noindent{\bf Fair Simulation}
Fairness constraints$F$ that decides a fair-run.
\begin{itemize}
\item weak (Buchi) fair
\item strong (Streett) fair
\end{itemize}
$M_2$ fair simulate $M_1$ if all fair-run in $M_1$ has a matching fair-run in $M_2$.
\vspace{3mm}
\noindent{\bf Tasks:}
\begin{enumerate}
\item Make $\forall \exists$ simulation complete (for $\forall \exists \LTLsquare \varphi$).
\item Formalize $\exists \forall \LTLsquare \varphi$ algorithm.
\item Explore abstractions.
\end{enumerate}
\vspace{3mm}
\noindent{\bf Bounded Prophecy in Simulation}
If some branches are far from the initial states, it is possible that $\forall\exists$ simulation is not available but $\langle M_1, M_2 \rangle \models \LTLsquare \varphi$\\
\noindent {\question Q: enumerating prophecy?}\\
\noindent {\question Q: sophisticated prophecy?}
\vspace{3mm}
\noindent{\bf Completeness}
Run two algorithms with incremental search (simulation with bound $k$, and unrolling with bound $k$) and eventually one of them will halt.\\
\includegraphics[scale=.2]{table}
\subsection{Good Abstraction (from Cesar's note)}
We can find $\exists\forall \LTLsquare \varphi$ more efficiently by selecting a good abstraction for the second model. For example, consider
$$
\varphi = \LTLsquare(\neg p_{\pi_1} \lor \neg p_{\pi_2})
$$
Then the `worst choice` for $M_2$ is $p^\omega$. That is, for every $a'_0, a'_1, a'_2, \ldots \in L_{M'_2}$, there is $a_0, a_1, a_2, \ldots \in L_{M_2}$, such that $a'_0 \models \neg p$ then $a_0 \models \neg p$.
\section{Preliminaries}
\mypar{\textup{Kripke structures}}
A {\em Kripke structure} $K$ is a tuple $\langle S, S^0, \trans, \mathsf{AP}, L \rangle$, where $S$ is a
set of {\em states}, $S^0 \subseteq S$ is a set of {\em initial
states}, $\delta\subseteq S\times S$ is a total {\em transition
relation}, and $L:S\rightarrow 2^{\mathsf{AP}}$ is a {\em labeling
function}, which labels {\color{black} states $s \in S$} with a subset of
atomic propositions in $\mathsf{AP}$ that hold in $s$.
{\color{black}
A \emph{path} of $K$ is an infinite sequence of states
$s(0)s(1)\cdots \in S^\omega$, such that
$s(0) \in S^0$, and
$(s(i), s({i+1})) \in \delta$, for all $i \geq 0$.
A {\em loop} in $K$ is a finite path
$s(n)s(n+1)\cdots s(\ell)$, for some $0 \leq n \leq \ell$, such that
$(s(i), s({i+1})) \in \delta$,
for all $n \leq i < \ell$, and
$(s(\ell), s(n)) \in \delta$.
Note that $n=\ell$ indicates a {\em self-loop} on a state.
A \emph{trace} of $K$ is a trace
$t(0)t(1)t(2) \cdots \in \mathrm{\Sigma}^\omega$, such that there exists a
path $s(0)s(1)\cdots \in S^\omega$ with
$t(i) = L(s(i))$ for all $i\geq 0$.
We denote by $\textit{Traces}(K, s)$ the set of all traces of $K$
with paths that start in state $s \in S$.
We use $\textit{Traces}(K)$ as a shorthand for
$\bigcup_{s \in S^{0}}\textit{Traces}(K,s)$, and
$\mathcal{L}(K)$ as the shorthand for $\textit{Traces}(K)$.
}
\vspace{0.5em}
\mypar{\textup{Simulation relations}}
Let ${K}_{A} = \langle S_A, S_{A}^\init, \trans_A, \mathsf{AP}_A, L_A \rangle$ and ${K}_{B} = \langle S_B, S_{B}^0, \delta_B,$ $\mathsf{AP}_B, L_B \rangle$ be two Kripke structures.
A {\em simulation relation} ${R}$ from ${K}_{A}$ to ${K}_{B}$ is a relation ${R}\subseteq S_A\times S_B$ that meets the following conditions:
\begin{compactenum}
\item For every $s_A\in S_{A}^0$ there exists $s_B\in S_{A}^0$ such that $(s_A,s_B)\in {R}$.
\item For every $(s_A,s_B)\in {R}$, it holds that $L_A(s_A)=L_B(s_B)$.
\item For every $(s_A,s_B)\in {R}$, for every $(s_A, s'_A)\in \delta_A$, there exists
$(s_B,s'_B)\in \delta_B$ such that $(s'_A,s'_B)\in {R}$.
\end{compactenum}
\vspace{0.5em}
\input{prelim-cesar}
\input{prelim-sarai}
\section{Proofs}
\newcounter{aux}
\subsection{Bounded Simulation}\label{sec:bounded.sim}
Let $K_1$ and $K_2$ be two Kripke structures over $AP$, and let $k\in \mathcal{N}$.
The {\em bounded simulation problem} for $K_1,K_2$ and $k$ is to decide whether there exists a simulation relation from $K_1$ to $K_2$ that uses at most $k$ states of $K_2$ (note that in any case, all of the reachable states of $K_1$ must be used in such a simulation).
We prove this problem to be \comp{NP-complete}.
\begin{theorem}
The bounded simulation problem is \comp{NP-complete}.
\end{theorem}
\begin{proof}
Let $K_1$ and $K_2$ be two Kripke structures with sets of states $Q_1$ and $Q_2$, respectively, and let $k\in \mathcal{N}$.
A nondeterministic algorithm which guesses a set $Q'_2\subseteq Q_2$ of at most $k$ states, and searches for a simulation from $K_1$ to $K_2$ reduced to $Q'_2$. Finding a simulation can be done in polynomial time, and so the problem is in \comp{NP}.
We prove \comp{NP-hardness} by a reduction from the Vertex Cover problem. Given a directed graph $G=\tuple{V,E}$ where $|E|=m$ and where $V=\{v_1,\ldots v_n\}$, and $k\in\mathcal{N}$, we construct two Kripke structures $K_1$ and $K_2$, as follows.
$K_1$ is composed of $m$ states, where for every $e\in E$ there is a state labeled $e$, and an additional initial state $q$ labeled $q$. The transitions are from $q$ to all edge states and vice versa.
$K_2$ is composed of $m$ states similarly labeled as the edge states of $K_1$, and additional $n$ states $v_1,\ldots v_n$ all labeled $q$, all initial. From every $v_i$ there are transitions to all edge states. From every edge state $(v_i,v_j)$ there are transitions to $v_i$ and $v_j$.
It is easy to see that $K_2$ can simulate $K_1$ using at most $m+k$ states iff $G$ has a vertex cover of size at most $k$.
\end{proof}
\commentout{
Now, let $K_1, K_2$, and $k$ be as before.
The {\em bounded $\exists\forall$-problem} for $K_1,K_2$ and $k$ is to decide whether there exists a path in $K_1$ which uses at most $k$ states, which is equivalent to all paths in $K_2$. In other words, we ask whether there exists such a path witnessing the hyper-LTL formula $\exists\pi_1\forall\pi_2 \LTLsquare \bigwedge_{q\in AP}(q_{\pi_1} \iff q_{\pi_2})$.
We prove this problem to be \comp{NP-complete}.
\begin{theorem}\label{thm:bounded_simulation_NPC}
The bounded $\exists\forall$-problem is \comp{NP-complete}.
\end{theorem}
\begin{proof}
Let $K_1$ and $K_2$ be two Kripke structures with sets of states $Q_1$ and $Q_2$, respectively, and let $k\in \mathcal{N}$.
For the upper bound, we notice that in a yes-instance of the problem, all of the paths in $K_2$ must be equally labeled. This holds iff for every state $s$ in $K_2$, all the transitions from $s$ lead to equally labeled states, a condition which can easily be checked.
Then, to check that there is a path in $K_1$ that is equal to all paths in $K_2$ which uses at most $k$ states, we can guess $k$ states of $K_1$, and check the nonemptiness of the intersection of $K'_1$ with $K_2$, where $K'_1$ is $K_1$ reduced to the $k$ chosen states. Since intersecting and checking for nonemptiness can be done in polynomial time, we are done.
We prove \comp{NP-hardness} by a reduction from the Vertex Cover problem. Given a directed graph $G=\tuple{V,E}$ where $|E|=\{e_1,e_2,\ldots e_m\}$ and where $V=\{v_1,\ldots v_n\}$, and $k\in\mathcal{N}$, we construct two Kripke structures $K_1$ and $K_2$, as follows.
$K_1$ is $K_2$ of the proof of Theorem~\ref{thm:bounded_simulation_NPC}.
$K_2$ is composed of $2m$ states $q_1,q_2,\ldots q_{2m}$ arranged in a simple cycle, where $q_1$ is initial. The states in the odd indices are all labeled $q$, and for every $1\leq i\leq m$, state $q_{2i}$ is labeled by $e_i$ .
That is, the cycle enumerates all edges.
It is easy to see that there exists a path in $K_1$ that uses at most $m+k$ states that is equivalent to (the single) path in $K_2$ iff $G$ has a vertex cover of size at most $k$.
\end{proof}
}
\subsection{Encodings for AE-Simulation with Prophecies}
\label{subsec:prophecies}
{\color{black}
The AE-simulation encoding introduced in Section~\ref{subsec:AE} can handle most properties of the form
$\forall\exists \LTLsquare \code{Pred}$;
however, it is unable to cope well with systems
(in particular the system $K_P$ for the $\forall$ quantifier) that exhibit non-determinism.}
The reason, as illustrated in the following example, is that the
simulation matches immediately the successor for the $\exists$ path
without inspecting the future of the $\forall$ path.
This is illustrated in the following example.
\begin{example}
Consider Kripke structures $K_1$ and $K_2$ from
Section~\ref{sec:intro}, and \code{HyperLTL} formula {\color{black}
$\varphi_2 = \forall \pi. \exists \pi'.~ \LTLsquare (a_{\pi}
\leftrightarrow a_{\pi'})$. }
It is easy to see that the two models satisfy {\color{black} $\varphi_2$}, since
mapping the sequence of states $(s_1s_2s_3)$ to $(q_1q_2q_4)$ and
$(s_1s_2s_4)$ to $(q_1q_3q_5)$ guarantees that the matched paths
satisfy {\color{black} $\LTLsquare(a_{\pi} \mathrel{\leftrightarrow} a_{\pi'})$}.
%
However, the technique in Section~\ref{subsec:AE} cannot
differentiate the occurrences of $s_2$ in the two different cases.
\qed
\end{example}
To solve this, we incorporate the notion of {\em prophecies} to our setting.
Prophecies have been proposed as a method to aid in the verification
of hyperliveness~\cite{coenen19verifying}
(see~\cite{beutner22prophecy} for a systematic method to construct
these kind of prophecies).
For simplicity, we restrict here to prophecies expressed as safety automata.
A safety prophecy over $\mathsf{AP}$ is a Kripke structure $U=\langle S, S^0, \trans, \mathsf{AP}, L \rangle$,
such that $\textit{Traces}(U)=\mathsf{AP}^\omega$.
The product $K\times U$ of a Kripke structure $K$ with a prophecy $U$
preserves the language of $K$ (since the language of $U$ is
universal).
Recall that in the construction of the product, states
{\color{black} $(s,u)\in (\Kr \times U)$}
that have incompatible labels are removed.
The direct product can be easily processed by repeatedly removing dead states, resulting in a Kripke
structure $K'$ whose language is $\textit{Traces}(K')=\textit{Traces}(K)$.
Note that there may be multiple states in $K'$ that correspond to
different states in $K$ for different prophecies.
The prophecy-enriched Kripke structure can be directly passed to the
method in Section~\ref{subsec:AE}, so the solver can search for a
\code{SIM$_{\text{AE}}$} that takes the value of the prophecy into account.
\begin{figure}[t]
\begin{tabular}{l@{\hspace{4em}}l}
\hspace{4.5em} \includegraphics[scale=0.4]{figs/ipe/proph} &
\includegraphics[scale=0.4]{figs/ipe/KoneU}
\end{tabular}
\caption{Prophecy automaton for $\LTLcircle\Next a$ (left) and
its composition with $K_1$ (right).}
\label{fig:proph}
\end{figure}
\begin{example}
Consider the {\color{black} prophecy automaton shown in Fig.~\ref{fig:proph} (left)},
where all states are initial.
Note that for every state, either all its successors are labeled
with $a$ (or none are), and all successors of its successors are
labeled with $a$ (or none are).
In other words, this structure encodes the prophecy $\LTLcircle\Next a$.
The product $K_1'$ of $K_1$ with the prophecy automaton $U$ for
$\LTLcircle\Next a$ is shown in Fig.~\ref{fig:proph} (right).
Our method can now show that $\tupleof{K_1',K_2}\models\varphi_2$, since it
can distinguish the two copies of $s_1$ (one satisfies $\LTLcircle\Next a$
and is mapped to $(q_1q_2q_4)$, while the other is mapped to $(q_1q_3q_5)$).
\qed
\end{example}
\section{Related Work}
\label{sec:related}
Hyperproperties was first introduced by Clarkson and Schneider~\cite{cs10}, and the first algorithms for model checking HyperLTL and HyperCTL$^*$ were introduced in~\cite{frs15}, which was using alternating automata.
Automated reasoning about \code{HyperLTL} specifications has been getting a lot of progress
in many aspects
including verifying~\cite{frs15,fmsz17,fht18,cfst19} and monitoring~\cite{ab16,fhst19,bsb17,bss18,fhst18,sssb19,hst19}.
With this growing amount of research, many tools can also support \code{HyperLTL},
including \code{MCHyper}~\cite{frs15,cfst19} for model checking,
\code{EAHyper}~\cite{fhs17} and \code{MGHyper}~\cite{fhh18} for satisfiability checking,
and \code{RVHyper}~\cite{fhst18} for runtime monitoring.
However, the aforementioned tools are limited to \code{HyperLTL} formulas without quantifier alternations.
Recently, this difficulty of alternating formulas was tackled by the bounded model
checker \code{HyperQube}~\cite{hsu21bounded} using QBF solving.
However, \code{HyperQube} is lack of practical loop conditions that allows to
capture early infinite traces in finite exploration.
In this paper, we develop the simulation-based algorithm to resolve it.
Furthermore, while there are more than one approach to reason about infinite traces,
another line of work applies {\em strategy-based} approach
to deal with formulas in the form of $\forall\exists$~\cite{coenen19verifying}, and the incompleteness can be resolved by generating
a set of prophecy variables~\cite{beutner2022prophecy}.
However, in this work we capture infinity
in a more efficient manner using simulation.
We also build an applicable prototype for reasoning
\code{HyperLTL} formulas with models that contain loops.
\subsection{A SAT encoding}
As another approach, we can encode such a simulation via a SAT formula, as follows.
We assume a formula $q_i$ for every $q_i\in Q$, and we allocate a set $\{x_i\}_{i=1}^n$ for these formulas.
For every $1\leq i\leq n$, we allocate a set of variables $\{y_i^j\}_{j=1}^k$, which, intuitively, represent the set of states that are matched with $q_i$ in the simulation (if there are less than $k$ variables that are matched with $q_i$, then some of these variables will be assigned the same value in a satisfying assignment).
We also allocate a set of variables $\{y_i\}_{i=1}^k$.
We define the following formulas.
\begin{enumerate}
\item Every $x_i$ is a state in $M_1$ and every $y_i$ is a state in $M_2$:
$$\alpha_1 = \bigwedge_{i=1}^{n}Q(x_i)\wedge\bigwedge_{i=1}^{k} P(y_i)$$.
\item All the states in $M_2$ in the simulation are one of the $k$ $y$-states:
$$\alpha_2 = \bigwedge_{i=1}^{n}\bigwedge_{j=1}^{k} \bigvee_{t=1}^{k} y_i^j = y_t $$
\item All the states that are matched in the simulation are equally labeled:
$$\alpha_3 = \bigwedge_{i=1}^n\bigwedge_{j=1}^k L_1(x_i) = L_2(y_i^j)$$
\item
For every $(x,y)$ in the simulation,
every successor state of $x$ has a matching successor state of $y$.
$$\alpha_4 = \bigwedge_{i=1}^n\bigwedge_{j=1}^n R_1(x_i,x_j) \rightarrow \bigwedge_{t=1}^k\bigvee_{r=1}^k R_2(y_i^t,y_j^r)$$
\end{enumerate}
The formula $\alpha = \bigwedge_{i=1}^4\alpha_i$ is then satisfiable iff there exists a desired simulation.
\subsection{Bounded Simulation}
Let $K_1$ and $K_2$ be two Kripke structures over $AP$, and let $k\in \mathcal{N}$.
The {\em bounded simulation problem} for $K_1,K_2$ and $k$ is to decide whether there exists a simulation relation from $K_1$ to $K_2$ that uses at most $k$ states of $K_2$ (note that in any case, all of the reachable states of $K_1$ must be used in such a simulation).
We prove this problem to be \comp{NP-complete}.
\begin{theorem}
The bounded simulation problem is \comp{NP-complete}.
\end{theorem}
\begin{proof}
Let $K_1$ and $K_2$ be two Kripke structures with sets of states $Q_1$ and $Q_2$, respectively, and let $k\in \mathcal{N}$.
A nondeterministic algorithm which guesses a set $Q'_2\subseteq Q_2$ of at most $k$ states, and searches for a simulation from $K_1$ to $K_2$ reduced to $Q'_2$. Finding a simulation can be done in polynomial time, and so the problem is in \comp{NP}.
We prove \comp{NP-hardness} by a reduction from the Vertex Cover problem. Given a directed graph $G=\tuple{V,E}$ where $|E|=m$ and where $V=\{v_1,\ldots v_n\}$, and $k\in\mathcal{N}$, we construct two Kripke structures $K_1$ and $K_2$, as follows.
$K_1$ is composed of $m$ states, where for every $e\in E$ there is a state labeled $e$, and an additional initial state $q$ labeled $q$. The transitions are from $q$ to all edge states and vice versa.
$K_2$ is composed of $m$ states similarly labeled as the edge states of $K_1$, and additional $n$ states $v_1,\ldots v_n$ all labeled $q$, all initial. From every $v_i$ there are transitions to all edge states. From every edge state $(v_i,v_j)$ there are transitions to $v_i$ and $v_j$.
It is easy to see that $K_2$ can simulate $K_1$ using at most $m+k$ states iff $G$ has a vertex cover of size at most $k$.
\end{proof}
Now, let $K_1, K_2$, and $k$ be as before.
The {\em bounded $\exists\forall$-problem} for $K_1,K_2$ and $k$ is to decide whether there exists a path in $K_1$ which uses at most $k$ states, which is equivalent to all paths in $K_2$. In other words, we ask whether there exists such a path witnessing the hyper-LTL formula $\exists\pi_1\forall\pi_2 \LTLsquare \bigwedge_{q\in AP}(q_{\pi_1} \iff q_{\pi_2})$.
We prove this problem to be \comp{NP-complete}.
\begin{theorem}\label{thm:bounded_simulation_NPC}
The bounded $\exists\forall$-problem is \comp{NP-complete}.
\end{theorem}
\begin{proof}
Let $K_1$ and $K_2$ be two Kripke structures with sets of states $Q_1$ and $Q_2$, respectively, and let $k\in \mathcal{N}$.
For the upper bound, we notice that in a yes-instance of the problem, all of the paths in $K_2$ must be equally labeled. This holds iff for every state $s$ in $K_2$, all the transitions from $s$ lead to equally labeled states, a condition which can easily be checked.
Then, to check that there is a path in $K_1$ that is equal to all paths in $K_2$ which uses at most $k$ states, we can guess $k$ states of $K_1$, and check the nonemptiness of the intersection of $K'_1$ with $K_2$, where $K'_1$ is $K_1$ reduced to the $k$ chosen states. Since intersecting and checking for nonemptiness can be done in polynomial time, we are done.
We prove \comp{NP-hardness} by a reduction from the Vertex Cover problem. Given a directed graph $G=\tuple{V,E}$ where $|E|=\{e_1,e_2,\ldots e_m\}$ and where $V=\{v_1,\ldots v_n\}$, and $k\in\mathcal{N}$, we construct two Kripke structures $K_1$ and $K_2$, as follows.
$K_1$ is $K_2$ of the proof of Theorem~\ref{thm:bounded_simulation_NPC}.
$K_2$ is composed of $2m$ states $q_1,q_2,\ldots q_{2m}$ arranged in a simple cycle, where $q_1$ is initial. The states in the odd indices are all labeled $q$, and for every $1\leq i\leq m$, state $q_{2i}$ is labeled by $e_i$ .
That is, the cycle enumerates all edges.
It is easy to see that there exists a path in $K_1$ that uses at most $m+k$ states that is equivalent to (the single) path in $K_2$ iff $G$ has a vertex cover of size at most $k$.
\end{proof} | {'timestamp': '2023-01-31T02:00:37', 'yymm': '2301', 'arxiv_id': '2301.06209', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06209'} | arxiv |
\section{Introduction}\label{sec:intro}
\IEEEPARstart{C}{ollaborative} perception is an important problem for the future
of robotics. The shared understanding of the environment it provides is a
prerequisite to many applications from autonmous warehouse management to
subterranean exploration. One of the most powerful tools for robotic perception
is Simultaneous Localization And Mapping (SLAM) which tightly couples the
geometric perception of the environment with state
estimation~\cite{cadenapresentfuturesimultaneous2016}. In addition to producing
high-quality maps of the robot surroundings, it provides localization estimates
that are essential for planning and control. However, single-robot SLAM
estimates are local in the individual robot reference frame. Therefore, when
multiple robots operate in GPS-denied environments, they do not share
situational awareness unless they manage to connect, or merge, their local maps.
To solve this problem, Collaborative SLAM (C-SLAM) searches for inter-robot map
links and uses them to combine the local maps into a shared global understanding
of the environment.
One of the main practical challenges in C-SLAM is resource
management~\cite{lajoiecollaborativesimultaneouslocalization2022a}, in particular
considering the severe communication and computation limitations of mobile
robots. Those limitations need to be addressed to achieve real-time performance,
especially when a large number of robots work together. While very effective in
some scenarios, centralized C-SLAM solutions, which rely on a single server for
computation, suffer from a communication bottleneck between the robots and the
server, which limits their scalability. Besides, due to networking coverage
challenges in large indoor, subterranean or underwater environments, robots
cannot realistically maintain a stable connection to a central server. Thus,
decentralized solution relying only on sporadic and intermittent communication
between the robots are better suited for large-scale deployment.
\ExecuteMetaData[explanation_figures.tex]{overview}
While collaborative perception within small teams of autonomous robots is
currently challenging, we believe it useful to look forward to very large teams,
or swarms of robots and start tackling the problems specific to this scale of
deployment. Prior works on swarm robotics have identified a few key properties
required for swarm compatibility~\cite{brambillaswarmroboticsreview2013}
such as: communication and sensing must be local to the
robot neighborhood, and robots should not rely on a centralized
authority or global knowledge. In the specific case of
C-SLAM~\cite{kegeleirsswarmslamchallenges2021}, additional properties such as
flexibility and scalability must be considered.
In this paper, we propose novel techniques assembled in a complete
resource-efficient C-SLAM framework compliant with these key swarm compatibility
properties. Our approach is fully decentralized, supports different types of
sensors (stereo cameras, RGB-D cameras, and lidars), relies only on sporadic
connectivity, and requires significantly less communication than previous
techniques. To reduce the required data exchanges, we introduce a novel budgeted
approach to select candidate inter-robot loop closures based on algebraic
connectivity maximization, adapted from recent work on pose graph
sparsification~\cite{dohertyspectralmeasurementsparsification2022}. This
preprocessing of place recognition matches allows us to achieve accurate C-SLAM
estimates faster and using fewer communication resources. Moreover, we leverage
ROS~2~\cite{macenskirobotoperatingsystem2022} and recent advances in robotic
software engineering, to make our framework compatible with ad-hoc networks.
In summary, this paper offers the following \textbf{contributions}:
\begin{itemize}
\item A sparse budgeted inter-robot loop closure detection algorithm under
communication constraints based on algebraic connectivity maximization;
\item A decentralized approach to neighbor management and pose graph
optimization suited for sporadic inter-robot communication;
\item A swarm-compatible open-source framework based on ROS~2 which supports
lidars, as well as stereo or RGB-D cameras;
\item An extensive evaluation of the overall system performance on datasets and
in a real-world experiment.
\end{itemize}
The rest of this paper is organized as follows: \cref{sec:related_work} presents
some context and related work; \cref{sec:system_overview} provides an overview
of the system; \cref{sec:frontend} presents the front-end mechanisms including
our novel inter-robot loop closure prioritization; \cref{sec:back_end} details
the estimation process in the back-end; \cref{sec:experiments} presents
experimental results; and \cref{sec:conclusion} offers conclusions and suggests
future works.
%
\section{Background and Related Work}\label{sec:related_work}
\subsection{Collaborative SLAM}
C-SLAM systems can usually be divided into two categories: centralized and
decentralized. Centralized systems rely on a remote base station to compute the
global SLAM estimates for all the robots. The base station can be a server
cluster with computing capabilities unattainable on mobile platforms, and
transmit the optimized localization and map estimates back to the robots.
However, in those systems, the robots need a reliable permanent connection with
the base station, and the scalability is severely limited by the communication
bottleneck to the central server~\cite{saeedimultiplerobotsimultaneouslocalization2016}. Such stringent
networking constraints are often unrealistic, especially in large environments.
Decentralized approaches, relying only on sporadic communication links between
robots and without any need for a central authority, are preferred in those
scenarios. However, decentralized systems are limited by the onboard
computation and communication capabilities of the robots, and they require more
sophisticated data management and bookkeeping strategies to obtain accurate SLAM
estimates~\cite{lajoiecollaborativesimultaneouslocalization2022a}.
Similar to single robot SLAM systems, C-SLAM contains two parts commonly named
front-end and back-end. The front-end is in charge of feature extraction and
data association, while the back-end performs state and map
estimation~\cite{cadenapresentfuturesimultaneous2016}.
\subsubsection{Front-End}
One of the most important step in C-SLAM, is the detection and computation of
inter-robot loop closures. Inter-robot loop closures correspond to common
features or places previously visited by two or more robots. Those shared features
between the individual robots maps act as stitching points to merge the local
maps together and obtain a shared (global) reference frame. Similar to their
intra-robot versions, inter-robot loop closures are geometric constraints
between two pose graph vertices. By connecting vertices from different robots
pose graphs, we can merge them and compute a global estimate for all robots.
In this work, we focus on indirect loop closures in the sense that we want to
find connections anywhere between individual robot maps, rather than direct
observations of a robot by another during an
encounter~\cite{kimmultiplerelativepose2010}. Indirect loop closures have the
advantage of connecting maps in multiple points to further reduce the estimation
error, and do not require additional sensing (e.g., UWB ranging
sensor~\cite{caovirslamvisualinertial2021}). The crux of the challenge is to
find those indirect inter-robot links among large robot maps in a
resource-efficient manner.
Since the communication cost of sharing entire maps is usually prohibitive,
indirect inter-robot loop closure detection can be performed in two
stages~\cite{cieslewskidataefficientdecentralizedvisual2018,lajoiedoorslamdistributedonline2020}.
In the first stage, compact global descriptors of
images~\cite{arandjelovicnetvladcnnarchitecture2018} or lidar
scans~\cite{kimscancontextegocentric2018}, are shared between the robots for
place recognition. Similarity scores are computed between the global descriptors
from both robots to recognize places, or overlaps, between their respective
maps. Thus, recognized places correspond to candidate loop closures for the
second stage. Place recognition is followed by geometric verification to compute
the loop closures 3D constraints. For each candidate with high global
descriptors similarity, the corresponding local descriptors such as 3D keypoints
or scans are transmitted to compute the geometric registration between
the two robots frames. The resulting measurement linking a pose from both robots
is then added to their pose graph. Matching compact descriptors
first is advantageous given that local descriptors are usually larger and thus
more costly to communicate and compare~\cite{tardiolivisualdataassociation2015}.
\subsubsection{Back-End}
The role of the C-SLAM back-end is to estimate the most likely poses and map
from the noisy measurements gathered by all robots. To this end, Choudary et
al.~\cite{choudharydistributedmappingprivacy2017} propose the distributed
Gauss-Seidel (DGS) technique which allows robots to converge to a globally
consistent local pose graph by communicating only the pose estimates involved in
inter-robot loop closures, and therefore preserving the privacy of their whole
trajectories. Tian et al.~\cite{tiandistributedcertifiablycorrect2021}
significantly improve on that approach and provide a certifiably correct
distributed solver for pose graph optimization. This technique performs multiple
exchanges between the robots until they converge to globally consistent local
solutions. Tian et al.~\cite{tianasynchronousparalleldistributed2020} extend
this approach to support asynchronous updates during the iterative optimization
process, thus avoiding complex synchronization and bookkeeping. In a different
vein, recent work by Murai et al.~\cite{murairobotwebdistributed2022} laid the
foundation for larger-scale multi-robot collaborative localization based on
Gaussian Belief Propagation.
One of the main challenges in both single-robot and collaborative SLAM is the
frequent occurrence of erroneous measurements among inter-robot loop closures due
to perceptual aliasing~\cite{lajoiemodelingperceptualaliasing2019}. While many
techniques exist for the single-robot problem,
Lajoie et al.~\cite{lajoiedoorslamdistributedonline2020} first combined DGS with Pairwise
Consistency Maximization
(PCM)~\cite{mangelsonpairwiseconsistentmeasurement2018}, which computes the
maximal clique of pairwise consistent inter-robot measurements, to perform
robust and distributed pose graph optimization. More recently,
Yang et al.~\cite{yanggraduatednonconvexityrobust2020} introduced the Graduated
Non-Convexity (GNC) algorithm, a general-purpose approach for robust estimation
on various problems including pose graph optimization. GNC was integrated
with~\cite{tiandistributedcertifiablycorrect2021} in a robust distributed C-SLAM
solver (D-GNC)~\cite{tiankimeramultirobustdistributed2022}.
\ExecuteMetaData[explanation_figures.tex]{frameworks}
\subsubsection{Open-Source C-SLAM Systems}
Many open-source C-SLAM systems have been proposed in the recent years.
Ckieslewski et al.~\cite{cieslewskidataefficientdecentralizedvisual2018}
introduce DSLAM, which uses CNN-based global descriptors for distributed place
recognition, and DGS for estimation.
DOOR-SLAM~\cite{lajoiedoorslamdistributedonline2020} robustified the approach by
integrating PCM for outlier rejection and adapted it for sporadic inter-robot
communication. DiSCo-SLAM~\cite{huangdiscoslamdistributedscan2022} extends those
ideas to lidar-based C-SLAM using ScanContext global
descriptors~\cite{kimscancontextegocentric2018}.
Kimera-Multi~\cite{tiankimeramultirobustdistributed2022} integrates D-GNC and
incorporates semantic data in the resulting maps.
In an other line of work, centralized C-SLAM system have also evolved
considerably. COVINS~\cite{schmuckcovinsvisualinertialslam2021} presents an
efficient solution tailored for visual-inertial sensing, which is sparsified by
removing redundant keyframes. The lidar-based system
LAMP~2.0~\cite{changlamprobustmultirobot2022a} introduces a centralized Graph
Neural Network-based prioritization mechanism to predict the outcome of pose
graph optimization for each inter-robot loop closure candidates. The multi-modal
maplab~2.0~\cite{cramariucmaplabmodularmultimodal2022} supports heterogeneous
groups of robots with different sensor setups.
In contrast, \acronym{Swarm-SLAM} combines the latest advances from previous frameworks
and introduce a new sparse inter-robot loop closure prioritization to further reduce
communication. Additionally, unlike previous techniques, \acronym{Swarm-SLAM} leverages
recent advances with ROS~2 and robotic software to provide a seamless C-SLAM
integration with ad-hoc, sporadic, networking.
\ExecuteMetaData[remarks.tex]{ros2}
\cref{tab:frameworks} offers a
comparison of the various systems based on key desirable properties, for the supported sensors we use s for stereo cameras, l for lidar and d for RGB-D cameras.
We refer the reader
to~\cite{lajoiecollaborativesimultaneouslocalization2022a} for a thorough survey
on C-SLAM.
\subsection{Graph Sparsification for C-SLAM}
The ever-growing map and pose graph during long-term operations is an important
memory and computation efficiency challenge in both single-robot and multi-robot
SLAM~\cite{kurzgeometrybasedgraphpruning2021}. One favored solution is graph
sparsification, which aims to approximate the complete graph with as few edges
as possible, mainly by removing redundant edges that are not providing new
information during the estimation process. To this end, Doherty et
al.~\cite{dohertyspectralmeasurementsparsification2022} formulate the graph
sparsification of single robot pose graphs as a \textit{maximum algebraic
connectivity augmentation} problem, and solve it efficiently using a more
tractable convex relaxation.
In this paper, instead of sparsifying the pose graph after all the measurements
have already been computed, we aim to preemptively sparsify the inter-robot loop
closure candidates generated by the place recognition module. This way, we can
prioritize the geometric verification of inter-robot loop closures that will
approximate the full pose graph, thus avoiding wasting resources on redundant
measurements. Importantly, unlike other work maximizing the determinant of the
information matrix~\cite{tianresourceawareapproachcollaborative2021}, we
leverage the results from~\cite{dohertyspectralmeasurementsparsification2022}
and focus on the algebraic connectivity of the pose graph which has been shown
to be a key measure of estimation
accuracy~\cite{khosoussireliablegraphsslam2019,dohertyperformanceguaranteesspectral2022}
(i.e., higher algebraic connectivity is associated with lower estimation error).
Solving a similar problem, Denniston et
al.~\cite{dennistonloopclosureprioritization2022a} prioritize loop closure
candidates based on point cloud characteristics, the proximity of known beacons,
and the information gain predicted with a graph neural network. Interestingly,
Tian et al.~\cite{tianspectralsparsificationcommunicationefficient2022} explore spectral
sparsification in the C-SLAM back-end to reduce the required communication
during distributed pose graph optimization.
%
\section{System Overview}\label{sec:system_overview}
As described in \cref{fig:overview}, \acronym{Swarm-SLAM} is composed of three modules.
First, to enable decentralization, the neighbor management module continuously
tracks which robots are in communication range (i.e., neighbors that can be
reached reliably). Robots publish heartbeat messages at a fixed rate such that
network connectivity can be evaluated periodically. To make the system scalable
(see \cref{prop:scal}), the other modules query the neighbor management module
to determine which robots, if any, are available for every operation.
\ExecuteMetaData[properties.tex]{scalability}
The front-end takes as input an odometry estimates (obtained using an arbitrary
technique) along with synchronized sensor data (see \cref{prop:flex}). Upon
reception, the front-end extracts global (e.g. compact learned representation) and local
descriptors (e.g. 3D keypoints). Global descriptors allow us to identify
candidate place recognition matches (i.e., loop closures) between the robots,
then local descriptors are used for 3D registration.
\ExecuteMetaData[properties.tex]{flexibility}
This indirect inter-robot loop closure detection process, leverages inter-robot
communication to search for loop closures anywhere in the robot maps, instead of
limiting itself to direct observations. It is enabled whenever one or more other
robots are within communication range (see~\cref{assump:comm}).
\ExecuteMetaData[assumptions.tex]{inter-robot-comm}
In the back-end, the resulting intra-robot and inter-robot loop closure
measurements are combined with the odometry measurements into a pose graph.
Local pose graphs are transmitted to the robot selected to perform the
optimization
and the resulting estimates
are sent back to the respective robots. This process is decentralized (see
\cref{prop:dec}) since the robot performing the optimization is the result of a
simple negociation between the neighbors during a rendezvous.
\ExecuteMetaData[properties.tex]{decentralized} Current pose estimates,
resulting from the whole process, are made available periodically in the form of
ROS~2 messages for a minimally invasive integration into existing robotic
systems. Mapping data for planning or visualization can also be queried at the
cost of additional computation and communication. For debugging purposes, we
provide a minimal visualization tool which opportunistically collects mapping
data from robots in communication range. Overall, we divided place recognition,
geometric verification and pose graph optimization into modular and decoupled
processes (ROS~2 nodes) with clear data interfaces to enable researchers to
leverage Swarm-SLAM to easily test new ideas in each subsystems.
%
\section{Front-End}\label{sec:frontend}
The main task of the \acronym{Swarm-SLAM} front-end is indirect inter-robot loop closure
detection, which is one of the most challenging problem in C-SLAM. Similar to
many comparable techniques
(e.g.~\cite{cieslewskidataefficientdecentralizedvisual2018,lajoiedoorslamdistributedonline2020,tiankimeramultirobustdistributed2022}),
we adopt a two stage approach in which global matching generate candidate place
recognition matches that are verified using local features in the latter stage.
This approach allows us to reduce communication and computation since global
matching is done using compact descriptors that are inexpensive to transmit and
compare. Expensive local matching is performed only on the most promising
candidate matches. To further increase the front-end resource-efficiency, we
introduce a novel sparsification algorithm to select the global matching
candidates that would maximize the pose graph algebraic connectivity, and in
turn the decrease the estimation error. The proposed front-end approach leads to
better accuracy using less communication and computation (see~\cref{fig:spectral-vs-greedy}).
\subsection{Global Matching}
For each keyframe, compact descriptors, that can be compared with a similarity
score, are extracted from sensor data and broadcast to neighboring robots.
When two robots meet, we perform simple bookkeeping to determine which global
descriptors are already known by the other robot and which ones need to be
transmitted. We use ScanContext~\cite{kimscancontextegocentric2018} as global
descriptors of lidar scans and the recent CNN-based
CosPlace~\cite{bertonrethinkingvisualgeolocalization2022a} for images.
We use
nearest neighbors based on cosine similarity for descriptor matching.
We also support
NetVLAD~\cite{arandjelovicnetvladcnnarchitecture2018} and our system can be
easily extended to other compact descriptor extraction algorithms that
satisfy~\cref{assump:global-local}.
\ExecuteMetaData[assumptions.tex]{global-local}
\ExecuteMetaData[experimentation_figures.tex]{viz-spectral}
Once matches are computed, \acronym{Swarm-SLAM} offers two candidate prioritization
mechanisms: a trivial greedy prioritization algorithm, used in prior
work~\cite{cieslewskidataefficientdecentralizedvisual2018,lajoiedoorslamdistributedonline2020,tiankimeramultirobustdistributed2022,huangdiscoslamdistributedscan2022},
and a novel spectral approach.
To perfom the candidate prioritization, we define the multi-robot pose graph as:
\begin{align}
\mathcal{G} &= (V,\mathcal{E}^{\text{local}},\mathcal{E}^{\text{global}})\\
V &= (V_{1}, \dots, V_n)\\
\mathcal{E}^{\text{local}} &= (\mathcal{E}^{\text{local}}_{1}, \dots, \mathcal{E}^{\text{local}}_{n})\\
\mathcal{E}^{\text{global}} &= (\mathcal{E}_{\text{fixed}}^{\text{global}}, \mathcal{E}_{\text{candidate}}^{\text{global}})
\end{align}
where $V$ are the vertices from every $n$ robots pose graphs, each vertex
corresponding to a keyframe; $\mathcal{E}^{\text{local}}$ are the local pose graphs edges such
as odometry measurements and intra-robot loop closures; and
$\mathcal{E}^{\text{global}}$ are the global pose graph edges corresponding to
inter-robot loop closures. $\mathcal{E}^{\text{global}}$ is further divided
between $\mathcal{E}_{\text{fixed}}^{\text{global}}$ which contains the fixed measurements that have already
been computed, and the candidate inter-robot loop closures $\mathcal{E}_{\text{candidate}}^{\text{global}}$ on
which the prioritization is performed. Detailed measurements (i.e., pose
estimates) are not required for our proposed candidate prioritization mechanism.
Therefore, fixed measurements, both local and global, are undirected unweighted
edges between two vertices, and candidates edges contain an additional weight
value corresponding to their respective similarity score. This reduced
multi-robot pose graph can be built directly from the global matching
information and does not require any additional inter-robot communication.
The number of edges to select $B$ at each time step is set by the user. This
budget should reflect the communication and computation capacities of the
robots. The common candidate prioritization approach widely used prior works is
a basic \textit{greedy prioritization} in which the top $B$ candidates with the
highest similarity scores are selected.
In our proposed \textit{spectral prioritization} process, we frame pose graph sparsification as a candidate
prioritization problem, and leverage recent work on spectral sparsification~\cite{dohertyspectralmeasurementsparsification2022}. Unlike Doherty
et al.~\cite{dohertyspectralmeasurementsparsification2022}, which remove
existing, redundant, measurements from an existing single-robot pose graph while
retaining estimation accuracy, we perform sparsification on the candidate
inter-robot matches before computing the corresponding 3D measurements, reducing
resource usage for the costly inter-robot geometric verification of redundant
candidates, and achieving better accuracy (see \cref{prop:sparse}).
\ExecuteMetaData[properties.tex]{sparsity}
As shown in~\cite{dohertyperformanceguaranteesspectral2022}, the algebraic
connectivity of the pose graph controls the worst-case error of the solutions of
the \textit{Maximum Likelihood Estimation} problem (see~\cref{prob:mle}). The
pose graph algebraic connectivity corresponds to the second-smallest eigenvalue
$\lambda_2$ of the \textit{rotational weighted Laplacian} with entries for pairs
of vertices $(i,j)$ defined as:
\begin{align}
L_{ij} = \begin{cases} \sum_{e \in \delta(i)} \kappa_e,& i = j, \\
-\kappa_{ij},& \{i,j\} \in \mathcal{E}, \\
0,& \{i,j\} \notin \mathcal{E}. \end{cases}
\label{eq:laprot}
\end{align}
where $\kappa_{ij}$ denotes the edge weight and $\delta(i)$ is the set of edges
incident to vertiex $i$. In our proposed approach, we use $\kappa_e=1 \; \forall
\; e \in (\mathcal{E}^{\text{local}},\mathcal{E}_{\text{fixed}}^{\text{global}})$, and $\kappa_e=s \; \forall \; e \in
\mathcal{E}_{\text{candidate}}^{\text{global}}$ where $s \in [0,1]$ is the matching similarity score. This approach
forgoes the need to communicate additional information regarding the existing edges'
confidence.
For our purposes, we leverage the property that the Laplacian $L$ can be
expressed as the sum of subgraph Laplacians corresponding to each of its edges
to define the augmented pose graph Laplacian as follows:
\begin{align}
L(\omega) \triangleq L^{\mathcal{E}^{\text{local}}} + L^{\mathcal{E}_{\text{fixed}}^{\text{global}}} + \sum_{e \in \mathcal{E}_{\text{candidate}}^{\text{global}}}\omega_e L_e
\end{align}
where $\omega_e \in \{0,1\}$ is the binary variable which determines the
prioritization of candidate edge $e$.
Therefores, according to our previously stated goal, we aim to select the subset
$\mathcal{E}^\star \subseteq \mathcal{E}_{\text{candidate}}^{\text{global}}$ of fixed budgeted size $|
\mathcal{E}^{\star} | = B$ which maximizes the algebraic connectivity $\lambda_2
(L(\omega))$:
\begin{problem}{Candidate prioritization via Algebraic Connectivity Maximization}
\begin{align}
\begin{gathered}
\max_{\omega_e \in \{0,1\}} \lambda_2 (L(\omega))\\
|\omega| = B.
\end{gathered}
\end{align}
\label{prob:acm}
\end{problem}
\cref{prob:acm} is NP-Hard~\cite{mosk-aoyamamaximumalgebraicconnectivity2008}
due to the integrality constraint on $\omega_e$. Therefore, as in
\cite{dohertyspectralmeasurementsparsification2022}, we relax the integrality
constraints and, when necessary, we round the optimization result to the nearest
solution in the feasible set of~\cref{prob:acm}. We solve the relaxed problem
using the simple and computationally inexpensive approach developed
in~\cite{dohertyspectralmeasurementsparsification2022}. It is important to note
that this approach requires the pose graph to be connected, so we first perform
greedy prioritization up until at least one inter-robot loop closure exists
between the local pose graphs. We also use the greedy solution as initial guess
for the algebraic connectivity maximization.
In \cref{fig:viz-spectral}, we present a visualization of the approach results
in comparison of the ones obtained with the standard greedy approach. We can see
that the candidates selected using our spectral technique are more evenly
distributed along the pose graph while the greedy candidates are mostly
concentrated in high-similarity areas. Our selected candidates are therefore
less redundant and more informative to the estimation process.
\subsection{Local Matching}
Once the inter-robot loop closure candidates are selected, the next step is to
perform local matching (i.e., geometric verification). This step leverages
larger collections of local features, such as
ORB~\cite{rubleeorbefficientalternative2011} or point clouds, to compute the 3D
relative pose measurement between the candidate's two vertices. We use the
RTAB-Map library~\cite{labbertabmapopensourcelidar2019} for visual feature
extraction and geometric verification, and
TEASER++~\cite{yangteaserfastcertifiable2021} for robust pointcloud
registration. To avoid computing the same loop closure twice, the standard
approach consists of a trivial monolog~\cite{giamoutalkresourceefficientlyme2018} in which only one of the two
vertices is transmitted per candidate, and the receiving robot is in charge of
generating the relative pose measurement. Once the measurement is obtained, it
is shared back to the other robot.
\ExecuteMetaData[explanation_figures.tex]{vertex}
However, to further reduce the communication burden of geometric verification,
we follow~\cite{giamoutalkresourceefficientlyme2018} and formulate the vertices local
features sharing problem as a vertex cover problem. As illustrated
in~\cref{fig:vertex_cover}, when two or more inter-robot loop closure candidates
share a vertex in common, only the common vertex needs to be transmitted to
effectively compute all the associated relative pose measurements. Thus, by
computing the minimal vertex cover, optimally for bipartite graphs and
approximately with 3 robots or more, we obtain an exchange policy which avoids
redundant communication. The benefits of vertex cover minimization are shown
in~\cref{fig:vertex-cover-vs-monolog}. As expected, the larger the candidate
budget is (i.e., number of loop closures candidates to select in global
matching), the larger the communication savings are, since more vertices are
likely to be part of multiple loop closure candidates.
\subsection{Inter-Robot Communication}
It is worth noting, that both for the spectral matching and the vertex exchange
policy, a \textit{broker} needs to be dynamically elected among the robots in
communication range. The broker then computes the matches and sends requests for
the vertices to be transferred. In our current implementation, the broker is
simply the robot with the lowest ID, but it could be elected through a more
informed decentralized negotiation (e.g. based on the available computation
resources onboard each robots).
As mentioned above, the user of \acronym{Swarm-SLAM} can control the communication
bandwidth by setting a candidate budget. They can also specify the rate at which
the computation loops run in the different processes, allowing for example the
user to dictate the number of candidates to select per second.
%
\section{Back-End}\label{sec:back_end}
The role of the back-end is to gather the odometry, intra- and inter-robot
loop closure measurements from the front-end in a pose graph, and then estimate
the most likely map and poses based on those noisy measurements.
The \textit{Maximum Likelihood Estimation} (MLE) problem we solve is:
\begin{problem}[Pose Graph Optimization MLE on $\SE{3}$]
\label{prob:mle}
\begin{equation}
\min_{\substack{{\boldsymbol{t}_i \in \Real{3}} \\ {\M{R}_i \in \SO{3}}}} \kappa_{ij} \| \M{R}_j - \M{R}_i\bar{\M{R}}_{ij}\|^2_F + \sum_{(i,j) \in \mathcal{E}} \tau_{ij}\|\boldsymbol{t}_j - \boldsymbol{t}_i - \M{R}_i\bar{\boldsymbol{t}}_{ij}\|_2^2.
\end{equation}%
\end{problem}
where $(\M{R}_i, \boldsymbol{t}_i)$ are the rotation and translation estimate of pose $i$;
$(\bar{\M{R}}_{ij}, \bar{\boldsymbol{t}}_{ij})$ are the relative measurements between two
poses $i$ and $j$; $\kappa_{ij}$ and $\tau_{ij}$ are rotation and translation
information parameters related to each measurement confidence. The edge set for
the multi-robot pose graph estimation includes all local (intra-robot) and
global (inter-robot) measurements: $\mathcal{E} =
(\mathcal{E}^{\text{local}},\mathcal{E}^{\text{global}})$.
As mentioned above, unlike other recent
systems~\cite{lajoiedoorslamdistributedonline2020,tianresourceawareapproachcollaborative2021}
based on distributed pose graph optimization, we opt for a simpler decentralized
approach. Similar to the front-end, a robot is dynamically elected to perform
the computation among the robots in communication range. The other robots share
their current pose graph estimates with the elected robot and receive the
updated estimates once the computation is completed. Importantly, any robot can
be elected through negotiation to perform the pose graph optimization during a
sporadic encounter between the robots. \acronym{Swarm-SLAM} performs the pose graph
optimization using the Graduated
Non-Convexity~\cite{yanggraduatednonconvexityrobust2020} solver, with the robust
Truncated Least Square loss, available in the GTSAM
library~\cite{f.dellaertetal.georgiatechsmoothing}.
To ensure convergence to a single global localization estimate after multiple
sporadic rendezvous without enforcing a central authority, we introduce an
anchor selection process to keep track of the current global reference frame.
During pose graph optimization, the anchor usually corresponds to a prior which
assigns a fixed value to the first pose of the graph. This anchor then becomes
the reference frame of the resulting estimate. In the beginning, all robots are
within their own local reference frames where the origin corresponds to their
first pose (i.e., initial position and orientation). Then, when some robots meet
for the first time (e.g. robots 0, 4 and 5), we choose the first pose of the
robot with the lowest ID (e.g. robot 0) as the anchor. Therefore, as a result of
the estimation process, the involved robots estimates share the same reference
frame (e.g. robot 0's first pose). In subsequent rendezvous (e.g. robots 2, 3
and 4), the anchor is selected based on the reference frame with the lowest ID
(e.g. robot 4's first pose is selected as the anchor since its reference frame
is robot 0's). After a few rendezvous, the robots converge to a single global
reference frame without requiring rendezvous including all robots (e.g. after
the second rendezvous, robots 2 and 3 are also within robot 0's reference
frame). This means that \acronym{Swarm-SLAM} can scale to large groups of robots, through
iterative estimation among smaller groups of robots.
We motivate our preference for a decentralized approach, in terms of
communication and computation loads, with an evaluation and comparison against
state-of-the-art distributed approaches presented in~\cref{tab:backend} and
discussed in~\cref{subsec:data_exp}. In a nutshell, performing the optimization
on a single robot leads to more accurate estimates with less communication and
computation.
%
\section{Experimental Results}\label{sec:experiments}
\ExecuteMetaData[experimentation_figures.tex]{datasets}
\ExecuteMetaData[experimentation_figures.tex]{spectral-vs-greedy}
To evaluate the effectiveness of our proposed solutions for the ongoing
challenges in Collaborative Simultaneous Localization and Mapping, we conducted
extensive experiments on several public datasets, as well as in a real-world
deployment. Our experiments involved three robots exploring and mapping an
indoor environment and communicating via ad-hoc networking. We specifically
evaluated our key contributions to inter-robot loop closure detection and
decentralized C-SLAM estimation. Additionally, we present detailed statistics of
the communication and computation load during our real-world experiment,
providing insight into the system's performance and resource requirements.
\ExecuteMetaData[experimentation_figures.tex]{backend-table}
\subsection{Dataset Experiments}\label{subsec:data_exp}
As detailed in~\cref{tab:datasets}, we tested \acronym{Swarm-SLAM} on eight sequences from
five different datasets. To demonstrate the flexibility of our framework, we
used IMUs, stereo cameras, lidars, or a combination as inputs. First, we tested
on the widely known autonomous driving KITTI~00 stereo
sequence~\cite{geigerareweready2012} which we split into two parts to simulate a
two-robots exploration. Second, we split the very large ($\sim$10km) KITTI360~09
lidar sequence~\cite{liaokitti360noveldataset2022} into 5 parts that contain a
large number of loop closures, making it particularly well suited for
inter-robot loop closure detection analysis. Third, we experimented on the first
three overlapping lidar sequences of the very recent GrAco
dataset~\cite{zhugracomultimodaldataset2023} acquired with custom ground
robots on a college campus. Fourth, we evaluate our system on the three lidar
Gate sequences of the M2DGR dataset~\cite{yinm2dgrmultisensormultiscenario2022}.
Fifth, we tested on four sequences of the recent C-SLAM-focused S3E
dataset~\cite{fengs3elargescalemultimodal2022}. To avoid tracking failures and
obtain more robust results on S3E sequences, we combined lidar-IMU odometry and
stereo camera-based inter-robot loop closure detection, highlighting the
versatility of \acronym{Swarm-SLAM}. Overall, we chose the sequences with the most
trajectory overlaps to obtain more loop closures, and with available GPS ground
truth (except for S3E Laboratory). For simplicity and robustness, we used
off-the-shelf RTAB-Map~\cite{labbertabmapopensourcelidar2019} modules to
compute and provide the required odometry input to \acronym{Swarm-SLAM}, but this could be
replaced by any other odometry software.
To better evaluate the inter-robot loop closure detection, we consider the
worst-case scenario in which the robots are within communication range only at
the end of their trajectories, such that they have to find loop closures between
their whole maps at once instead of processing them incrementally. This
scenario, analog to multiple robots exploring different parts of an environment
and meeting back at the end, is among the most challenging in terms of
communication and computation load, and therefore benefits the most from our
novel spectral candidate prioritization mechanism. We refer the reader to our
open-source implementation for all the parameters and configuration details of
the experiments.
\subsubsection{Inter-Robot Loop Closure Detection Evaluation}
In~\cref{fig:spectral-vs-greedy}, we compare the greedy and spectral inter-robot
loop closure candidate prioritization techniques with respect to algebraic
connectivity, PGO objective value, and Absolute Translation Error (ATE).
Each approach is
used to prioritize the computation of loop closures from the same set of
candidates with a budget of 1. We plot each metric against the percentage of
loop closures computed within the set of candidate (x-axis). Given enough time,
both techniques will go through all the possible matches (i.e., 100\% of loop
closures computed). We expect that a better prioritization will need to select
fewer candidates to converge to the best possible accuracy. We compute the ATE
in~\cref{fig:spectral-vs-greedy} with the evo package~\cite{grupp2017evo},
against the final pose graph estimate containing all possible inter-robot loop
closures, and thus constitutes the best estimate we can achieve.
On the first row, we can see that, as intended, our spectral prioritization is
correctly maximizing the algebraic connectivity of the pose graph. On the second
row, we can see that PGO objective value converges faster to its final value
using our approach. On the third row, as expected, we can see that our spectral
prioritization decreases the error faster than the greedy prioritization. In
summary, our experiments show that our technique requires the computation of
fewer inter-robot loop closures to significantly reduce the estimation error
(ATE), and thus approximate the final pose graph. This result also confirms our
hypothesis that algebraic connectivity is a relevant metric for inter-robot loop
closure candidates prioritization.
\subsubsection{Decentralized C-SLAM Evaluation}
\ExecuteMetaData[experimentation_figures.tex]{rendezvous}
In~\cref{tab:backend}, we present the estimates computed in the back-end on all
the sequences for which GPS latitude and longitude data is available as ground
truth. We report the computation time on a AMD Ryzen 7 CPU and the total
communication required in kB. We compared against two state-of-the-art
approaches: the Distributed Gauss-Seidel (DGS) pose graph
optimization~\cite{choudharydistributedmappingprivacy2017} combined with
Pairwise Consistency Maximization
(PCM)~\cite{mangelsonpairwiseconsistentmeasurement2018} for outlier rejection as
used in~\cite{lajoiedoorslamdistributedonline2020}; and a distributed
implementation of Graduated Non-Convexity
(D-GNC)~\cite{tiankimeramultirobustdistributed2022} based on the RCBD
solver~\cite{tiandistributedcertifiablycorrect2021}. Our approach systematically
obtains the most accurate ATE while the other methods often fail to obtain
reasonable estimates. \acronym{Swarm-SLAM} also consistently outperforms the distributed
optimization approaches in terms of required communication and computation time.
Interestingly, on KITTI-360 09 which is our largest dataset, DGS+PCM and D-GNC
require less computation time than our approach, but fail to obtain a comparable
accuracy and require over 20x more data transmission. While distributed
approaches should benefit from the division of labour on large problems, more
research is required to obtain the same levels of accuracy, robustness, and
communication bandwidth as our simpler approach.
\ExecuteMetaData[experimentation_figures.tex]{other-graphs}
In~\cref{fig:rendezvous}, we show the \acronym{Swarm-SLAM} resulting estimates on the
KITTI360 09 sequence from four different rendezvous, defined as a sporadic
encounter in which a subset of robots are within communication range of each
other. Our simple anchor selection scheme ensures that by choosing the current
first pose estimate from the robot with the lowest reference frame ID (i.e.,
first poses of (a) robot 0, (b) robot 2, (c) robot 3), we can propagate the
global reference frame among the team of robots. In other words, we are able to
converge to a single global reference frame through successive estimations
between subsets of robots, without enforcing connectivity maintenance or a
central authority. This decentralized approach improves the scalability of the
system by relying only on local interactions among neighboring robots. We present the
visualization of the \acronym{Swarm-SLAM} solutions on the remaining dataset sequences
in~\cref{fig:other-graphs}.
\ExecuteMetaData[explanation_figures.tex]{real}
\subsection{Real-World Experiments}\label{subsec:real_exp}
To assess the viability of \acronym{Swarm-SLAM} on resource-constrained platforms, we
deployed the system in an indoor parking lot and gathered statistics regarding
the computation time and communication load. As shown in~\cref{fig:top}, we
performed an online real-world demonstration with 3 different robots (Boston
Dynamics Spot, Agilex Scout, and Agilex Scout Mini), all equipped with an NVIDIA
Jetson AGX Xavier onboard computer, an Intel Realsense D455 camera, an Ouster
lidar OS0-64, a VectorNav VN100 IMU, and a GL-iNet GL-S1300 OpenWrt gateway for
ad hoc networking. We used lidars and IMUs for odometry and the RGB-D cameras
for inter-robot loop closure detection. We started the exploration with the
first two robots, and the third robot, which was initially out of range, joined
the experiment later. Upon arrival within communication range, the third robot
was dynamically discovered by the first two robots via ROS~2, and included in
the estimation process. At the cost of extra communication, our minimal
visualization tool, running on a laptop connected to the ad hoc network,
gathered the resulting estimates from the robots in real time, along with
mapping data that would not be transmitted otherwise.
\ExecuteMetaData[experimentation_figures.tex]{real-exp}
As stated in~\cref{tab:real_exp}, our robots travelled a total of 475~meters
during the experiment and produced a total of 3103~keyframes that needed to be
matches and verified in the search for inter-robot loop closures. The process
resulted in 67~loop closures, including 10 that were rejected by the GNC
optimizer (i.e., due to high residual factors). The large number of outliers is
attributable to the many similar-looking sections of the parking lot. Keyframe
images from different parts of the parking lot are erroneously matched by the
place recognition system leading to spurious loop closure measurements (i.e.,
perceptual aliasing). In total, \acronym{Swarm-SLAM} required the transmission of only
94.95~MB of data between the robots, not including the visualization. The
communication load is mostly attributable to the front-end and thus dependent on
the number of keyframes. In~\cref{tab:real_exp}, we also report the average
sparsification and pose graph optimization times. We can observe that the
sparsification time, while being non-negligible, is lower than the pose graph
optimization. To mitigate the PGO computation time, we implemented it within a
separate thread such that we can continue to accumulate additional global and
local measurements while waiting for the next estimate. Also, we continuously
provide to users an up-to-date pose estimate, published at a fixed rate, completing PGO estimates with the latest odometry measurements.
%
\section{Conclusions And Future Work}\label{sec:conclusion}
In this paper, we presented Swarm-SLAM, a comprehensive open-source C-SLAM
framework that is designed to comply with essential properties of swarm
robotics. We have introduced a novel inter-robot loop closure prioritization
technique based on algebraic connectivity maximization that reduces
communication and speed-up convergence. Our system has been rigorously evaluated
on five different public datasets, as well as in a real-world experiment,
demonstrating its effectiveness and suitability for multi-robot operations in
environments without an external positioning system. By leveraging ROS~2, we
have shown that Swarm-SLAM is adapted to ad-hoc networking with sporadic or
intermittent local communication between neighboring robots. While our
framework's scalability is still limited by the underlying single-robot SLAM
efficiency and onboard resource constraints, our decentralized framework can
scale to large groups of robots by performing successive C-SLAM estimation with
smaller subsets of robots and still converge to globally consistent estimates.
In future work, we plan to extend Swarm-SLAM to support additional sensing
modes, beyond lidar, stereo and RGB-D, such as higher-level data representations
(e.g. topological or semantic maps). We also aim to investigate collaborative
domain calibration and/or uncertainty estimation in place
recognition~\cite{lajoieselfsup2022} to reduce the prevalence of measurement
outliers among inter-robot loop closures, and therefore increase the overall
accuracy and resilience of C-SLAM. Additionally, we aim to integrate and deploy
a Swarm-SLAM-enabled autonomous exploration system in large unknown environments
and improve our visualization tools for better human-multi-robot interactions.
Finally, we hope that our open-source framework will be useful as a testbed for
the research and development of new methods and techniques in place recognition,
inter-robot loop closure detection, multi-robot pose graph optimization, and
other challenging open-problems in C-SLAM.
\bibliographystyle{IEEEtran}
| {'timestamp': '2023-02-01T02:16:21', 'yymm': '2301', 'arxiv_id': '2301.06230', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06230'} | arxiv |
\subsubsection{Learning interpretable truncation errors and nonlinear flux corrections}
\label{sec:learn_trunc}
\textcolor{black}
{\emph{Training: NN architecture, data, and loss function.}}
First, we only consider a Markovian closure term based on a library composed of second-degree combinations of $u$, $\frac{\partial u}{\partial x}$, and $\frac{\partial^2 u}{\partial x^2}$.
The library explicitly omits $u\frac{\partial u}{\partial x}$ because it is already known as part of the governing equation, and $u^2$ because it cannot be part of truncation error due to the absence of any derivative.
Hence, the Markovian closure term is assumed to be a linear combination of $\left\{\right. \Delta x \left( \frac{\partial u}{\partial x} \right)^2, \allowbreak \Delta x^3 \left( \frac{\partial^2 u}{\partial x^2} \right)^2, \allowbreak \Delta x^2 \left(\frac{\partial u}{\partial x} \frac{\partial^2 u}{\partial x^2} \right), \allowbreak \Delta x \left( u \frac{\partial^2 u}{\partial x^2} \right) \left.\right\}$, of which the fourth term is true but unknown leading order truncation error term itself.
Each of the terms is multiplied with appropriate powers of $\Delta x$, such that the closure terms are dimensionally consistent with the other terms of the Burgers equation.
The $4^{th}$ order accurate central and upwind finite-difference schemes \cite{rahul2006one} are used to compute the spatial derivatives in the Markovian closure, so as to eliminate additional sources of truncation error from our analysis.
The training data consists of the analytical solution up until $T=4.0$ solved in a domain of length $L=1.25$ and saved at every 0.01 time-intervals, for three different combinations of $N_x$ (number of grid points in $x-$direction) and $Re$. The chosen ($N_x$, $Re$) pairs, $\{(100, 50), (150, 750), ~\text{and} ~ (200, 1250) \}$, are such that the $-\frac{\Delta x}{2} u \frac{\partial^2 u}{\partial x^2}$ term is really the leading source of error. In every epoch, we parse through the training data of each of these pairs, selected in random order by sampling without replacement. We tune the hyperparameters based on performance in the training period ($0.0 \leq t \leq 4.0$) and the validation period ($4.0 \leq t \leq 6.0$), and these are provided in Section \ref{sec: Hyperparameters}.
The Markovian closure model is a simple neural network with no hidden layers and only linear activation in the output layer, in-effect equivalent to a linear combination of the inputs. Given the analytical solution, $\{u^{true}(x, T_i), \; 0 \leq x \leq L \}_{i=1}^M$, the loss function is once again the time and space averaged mean-absolute-error (MAE), $\mathcal{L}= \frac{1}{M} \sum_{i=1}^M \int_{0}^L \frac{1}{L} |u^{pred}(x, T_i) - u^{true}(x, T_i)| dx$, where $M=400$ is the number of high-fidelity solution states at different times available for training.
\textcolor{black}{\emph{Learning results.}}
We perform 8 repeats of the same experiment with the tuned hyperparameters. The resulting learned model with the mean and standard deviation of the coefficients is as follows,
\begin{equation}
\begin{split}
& \mathcal{F}_{NN} \left( \Delta x \left( \frac{\partial u}{\partial x} \right)^2, \Delta x^3 \left( \frac{\partial^2 u}{\partial x^2} \right)^2, \Delta x^2 \left(\frac{\partial u}{\partial x} \frac{\partial^2 u}{\partial x^2} \right), \Delta x \left( u \frac{\partial^2 u}{\partial x^2} \right); \phi \right) \\
& \hspace{0.15\textwidth}= (0.133 \pm 0.017) \Delta x \left( \frac{\partial u}{\partial x} \right)^2 + (0.009 \pm 0.023)\Delta x^3 \left( \frac{\partial^2 u}{\partial x^2} \right)^2 \\
& \hspace{0.25\textwidth} - (0.323 \pm 0.022) \Delta x \left( u \frac{\partial^2 u}{\partial x^2} \right) \,.
\end{split}
\label{eq: Leaned Markovian closure Burger's equation}
\end{equation}
For evaluation, we first compare the performance of this learned \textit{g}nCM w.r.t.\ using the true leading truncation error term ($-\frac{\Delta x}{2} u \frac{\partial^2 u}{\partial x^2}$) as the closure itself.
For both cases, we evolve the Burgers equation with the respective closure terms up until $T=8.0$ (beyond training and validation time-periods), for 35
$(N_x, Re)$ pairs in the 2D domain spanned by $50 \leq N_x \leq 200$ and $50 \leq Re \leq 1500$.
In Figure \ref{fig: NxvsRe plots} we provide the RMSE$(>2\%)$ error (see Figure \ref{fig: Exp1b_Analy_vs_LowRes_Nx50_Re1000_NBC} for description).
When the true leading truncation error term is used as the closure, we find that increasing $Re$ and lowering $N_x$ values leads to instabilities in the solution which causes it to explode.
On the contrary, in the learned \textit{g}nCM case, even though it was not shown any training data in the high $Re$ and low $N_x$ regime, it still provides a stable solution, and, on average, performs better than its counterpart in the other regions of the $(N_x, Re)$ domain.
To interpret the learned closure further, we rewrite it by substituting, $\frac{\partial }{\partial x}\left( u\frac{\partial u}{\partial x} \right) = \left( \frac{\partial u}{\partial x} \right)^2 + \left( u \frac{\partial^2 u}{\partial x^2} \right)$ in equation \ref{eq: Leaned Markovian closure Burger's equation},
\begin{equation}
\begin{split}
& \mathcal{F}_{NN} \left( \Delta x \left( \frac{\partial u}{\partial x} \right)^2, \Delta x^3 \left( \frac{\partial^2 u}{\partial x^2} \right)^2, \Delta x^2 \left(\frac{\partial u}{\partial x} \frac{\partial^2 u}{\partial x^2} \right), \Delta x \left( u \frac{\partial^2 u}{\partial x^2} \right); \phi \right) \\
& \hspace{0.15\textwidth} = (0.133 \pm 0.017) \Delta x \frac{\partial }{\partial x}\left( u\frac{\partial u}{\partial x} \right) + (0.009 \pm 0.023)\Delta x^3 \left( \frac{\partial^2 u}{\partial x^2} \right)^2 \\
& \hspace{0.25\textwidth} - (0.456 \pm 0.012) \Delta x \left( u \frac{\partial^2 u}{\partial x^2} \right) \,.
\end{split}
\end{equation}
Thus, the learned \textit{g}nCM contains the $\Delta x \left( u \frac{\partial^2 u}{\partial x^2} \right)$ term with a coefficient of correct sign but slightly smaller value -- in absolute value -- in comparison to that of the true leading truncation error term. Along with that, the other significant term, $\Delta x \frac{\partial }{\partial x}\left( u\frac{\partial u}{\partial x} \right)$, corresponds to a first-order Taylor series correction to the non-linear advection term, and can help with mitigating the resolution error highlighted earlier.
\begin{figure}[h]
\centering
\subfloat[][Leading truncation error term as closure]{\includegraphics[width=0.45\textwidth]{Figures/gnCM/Exp1b/Exp1b_DE_RMSE_2p_NxvsRe.png}} \qquad
\subfloat[][\textit{g}nCM with only Markovian closure term]{\includegraphics[width=0.45\textwidth]{Figures/gnCM/Exp1b/Exp1b_MarkClsr_RMSE_2p_NxvsRe.png}} \\
\subfloat[][Smagorinsky closure]{\includegraphics[width=0.45\textwidth]{Figures/gnCM/Exp1b/Exp1b_SmgClsr_RMSE_2p_NxvsRe.png}} \qquad
\subfloat[][\textit{g}nCM]{\includegraphics[width=0.45\textwidth]{Figures/gnCM/Exp1b/Exp1b_nonMarkClsr_RMSE_2p_NxvsRe.png}}
\caption{Performance of four closure models for the Burgers equation (equations \ref{eq: classic Burger's eq} \& \ref{eq: classic Burger's eq ICs and BCs}) evaluated for various $(N_x, Re)$ pairs in the 2D domain spanned by $50 \leq N_x \leq 200$ and $50 \leq Re \leq 1500$.
The error provided is the $RMSE(>2\%)$ (see Figure \ref{fig: Exp1b_Analy_vs_LowRes_Nx50_Re1000_NBC} for description) computed w.r.t.\ the corresponding analytical solutions (equation \ref{eq: Analytical solution for Burger's}) for $0.0\leq t \leq 8.0$ in a domain of length $L = 1.25$.
\textit{(a):} Leading truncation error term, $-\frac{\Delta x}{2} u \frac{\partial^2 u}{\partial x^2}$, as closure. The \textit{white} region in the top-left denotes an unconverged numerical solution; \textit{(b):} Learned \textit{g}nCM with only the Markovian term; \textit{(c):} Smagorinsky LES model with $C_s = 1.0$; \textit{(d):} Learned \textit{g}nCM with both Markovian and non-Markovian closure terms. The \textit{red} $\star$'s mark the four ($N_x, Re$) pairs used as training data.}
\label{fig: NxvsRe plots}
\end{figure}
\subsubsection{Learning generalizable and interpretable closures}
\textcolor{black}
{\emph{Training: NN architecture, data, and loss function.}}
Keeping the Markovian closure term formulation of Section \ref{sec: Hyperparameters}, we now add the non-Markovian closure term with inputs, $\{u, \frac{\partial u}{\partial x}, \frac{\partial^2 u}{\partial x^2}, \nu, \Delta x\}$, discretized using $4^{th}$ order finite-difference schemes, and the NN architecture given in Table \ref{table: All architecture}.
The output of the NN is multiplied with $|u|$ to ensure that the contribution of the non-Markovian closure term is zero in the right-hand parts of the domain where the shock is yet to reach.
As the non-Markovian closure term is nonlinear, we do not explicitly make the inputs dimensionally consistent with other terms in the Burgers equation. The overall training and evaluation setup are as in Section \ref{sec:learn_trunc}, however, this time four pairs of $(N_x, Re)$ are used such that all four combinations of high and low $N_x$ and $Re$ are contained in the training data. The chosen pairs were, $\{(50, 750), (200, 750), (50, 1250), (200, 1250)\}$.
The tuned set of hyperparameters is provided in Section \ref{sec: Hyperparameters}. The time-delay, $\tau = 0.075$, is based on the optimal-time delay established for the Burgers equation experiments in \cite{gupta_lermusiaux_PRSA2021}.
\textcolor{black}
{\emph{Learning results.}}
We perform 7 repeats of the experiment with exactly the same set of tuned hyperparameters. The learned coefficients for the Markovian term are different than those in equation \ref{eq: Leaned Markovian closure Burger's equation} due to the presence of the non-Markovian term, however, once again, the most weightage is given to the $\Delta x \left( \frac{\partial u}{\partial x} \right)^2$ and $\Delta x \left( u \frac{\partial^2 u}{\partial x^2} \right)$ terms.
Upon inspection, the weights of the input layer of the NN in the non-Markovian term being multiplied with $\nu$ were consistently found to be particularly small ($\mathcal{O}(10^{-4})$), indicating that the learned closure is independent of $\nu$.
For one of the experiment runs,
we show in Figure \ref{fig: NxvsRe plots} the performance for $(N_x, Re)$ pairs in the 2D domain spanned by $50 \leq N_x \leq 200$ and $50 \leq Re \leq 1500$, and compare it with that of the popular Smagorinsky model used for subgrid-scale turbulence closure in large eddy simulations (LES). To the Burgers equation (\ref{eq: classic Burger's eq}), this model introduces a dynamic turbulent eddy viscosity ($\nu_e$) resulting in,
\begin{equation}
\label{eq: classic Burger's eq with smagorinsky}
\begin{split}
\frac{\p u}{\p t} = -u\frac{\p u}{\p x} + \nu\frac{\p^2 u}{\p x^2} + \frac{\partial}{\partial x}\left(\nu_e\frac{\partial u}{\partial x}\right)\;,
\end{split}
\end{equation}
where $\nu_e = (C_s \Delta x)^2 \big| \frac{\partial u}{\partial x}\big|$ and $C_s$ is the Smagorinsky constant.
As the rectangle formed by the training $(N_x, Re)$ pairs is only a subset of the rectangle in which we evaluate the learned closure, we are testing both interpolation and extrapolation performance w.r.t.\ changing the physical parameter governing the model and grid resolution.
We find that the learned \textit{g}nCM clearly outperforms the Smagorinsky model.
As claimed earlier, we expect the learned \textit{g}nCM to be also generalizable over different boundary conditions. We tested this by modifying the boundary conditions. The analytical solution (equation \ref{eq: Analytical solution for Burger's}) used in training corresponded to Neumann boundary conditions on the right edge of the domain. This was changed to a zero Dirichlet boundary condition. Furthermore, the length of the domain was decreased to $L=1$, and $N_x = 50$ number of equally-spaced grid points were used in our low-fidelity model with $Re=1000$. Since no closed-form analytical solution exists for the Dirichlet boundary conditions case, we solve the system with $N_x = 1000$ grid points and use that as the true solution for comparing the performance of our learned closure.
In Figure \ref{fig: LowRes_Nx50_Re1000_DBC}, we find that the learned \textit{g}nCM is able to keep the errors remarkably low throughout the time period encompassing training, testing, and prediction.
\begin{figure}[h]
\centering
\subfloat[][No closure]{\includegraphics[width=0.75\textwidth]{Figures/gnCM/Exp1b/Exp1b_HighRes_Nx1000_vs_LowRes_Nx50_Re1000_DBC.png}} \\
\subfloat[][\textit{g}nCM]{\includegraphics[width=0.75\textwidth]{Figures/gnCM/Exp1b/Exp1b_HighRes_Nx1000_vs_nDistDDE_Nx50_Re1000_DBC.png}}
\caption{Solution of the Burgers equation with and without the learned generalized neural closure model (\textit{g}nCM) for $Re = 1000$, a low-resolution grid ($N_x = 50$), and zero Dirichlet boundary condition on the right edge. For each case, we also provide the pair of time-averaged errors (see Figure \ref{fig: Exp1b_Analy_vs_LowRes_Nx50_Re1000_NBC} for description).}
\label{fig: LowRes_Nx50_Re1000_DBC}
\end{figure}
\textcolor{black}
{\emph{Sensitivity.}}
In general, the quality of learning was less sensitive to the batch-time hyperparameter, however, higher values led to more interpretable closures. Using lower-order finite-difference schemes for the closure inputs did not compromise the performance of the learned closures, however, it did lead to a decrease in interpretability. Sensitivity to other hyperparameters was similar to that observed in Experiments-1a.
\subsection{Architectures}
The architectures used to generate the results corresponding to different experiments are provided in table \ref{table: All architecture}. The implementation details of the various biological and carbonate constraints imposed on the neural closure terms in experiments 2a \& 2b are also provided.
\subsection{Hyperparameters}
\label{sec: Hyperparameters}
The values of the tuned training hyperparameters corresponding to different experiments are listed next. In all the experiments, the number of iterations per epoch is calculated by dividing the number of time-steps in the training period by the batch-size multiplied by the length of short time-sequences, adding 1, and rounding up to the next integer.
\subsubsection{Experiments-1a:}
For training, we randomly select short time-sequences spanning 3 time-steps (batch-time) and extract data at every time-step to form batches of size 16; 4 iterations per epoch are used; an exponentially decaying learning rate (LR) schedule is used with an initial LR of 0.075, the decay rate of 0.97, and 4 decay steps; the RMSprop optimizer is employed; training is for a total of 150 epochs. $\mathcal{L}_1$ and $\mathcal{L}_2$ regularization with factors of $1.5\times 10^{-3}$ and $1\times 10^{-5}$, respectively, is used; the weights are pruned if the value drops below $5\times 10^{-3}$.
\subsubsection{Experiments-1b:}
\textbf{Only Markovian closure case:} We randomly select short time-sequences spanning 30 time-steps (batch-time) and extract data at every other time-step to form batches of size 2. In total 24 iterations per epoch are used, with every 8 of them belonging to one of the $(N_x, Re)$ pairs. An exponentially decaying learning rate (LR) schedule with an initial LR of 0.025, a decay rate of 0.95, and 24 decay steps are used; the RMSprop optimizer is used; we train for a total of 30 epochs. We also use both $\mathcal{L}_1$ and $\mathcal{L}_2$ regularization for the weights of the neural network with factors of $5 \times 10^{-4}$ and $5\times 10^{-4}$, respectively, along with pruning of the weights if their value drops below $5 \times 10^{-3}$.
\noindent\textbf{Both Markovian and non-Markovian closures case:} A batch-time of 30 time-steps is used with data extracted at every other time-step to form batches of size 2; 32 iterations per epoch are used, with every 8 of them belonging to one of the $(N_x, Re)$ pairs; an exponentially decaying learning rate (LR) schedule is employed with an initial LR of 0.01, the decay rate of 0.95, and 32 decay steps; the RMSprop optimizer is used; we train for a total of 30 epochs. We also use both $\mathcal{L}_1$ and $\mathcal{L}_2$ regularization for the weights of the neural network with factors of $1.5 \times 10^{-3}$ and $1\times 10^{-5}$, respectively, along with pruning of the weights if their value drops below $5 \times 10^{-3}$.
\subsubsection{Experiments-2a:}
Parameter values used in the ocean acidification model are (adopted from \cite{tian2015model, eknes2002ensemble}): $g_{max} = 0.7~day^{-1}$; $k_W = 0.08~m^{-1}$; $K_N = 0.5~mmol~N~m^{-3}$; $K_P = 0.25~mmol~N~m^{-3}$; $m_P = 0.08~day^{-1}(mmol~N~m^{-3})^{-1}$; $m_Z = 0.030~day^{-1}(mmol~N~m^{-3})^{-1}$; $\mu_{max} = 2.808~day^{-1}$; $ \alpha = 0.14~(W~m^{-2}~day)^{-1}$; $ \beta = 0.0028~(W~m^{-2}~day)^{-1}$; $\epsilon = 0.015~day^{-1}$; $\lambda = 0.3$; $\gamma = 0.4$; a sinusoidal variation in $I_o(t)$; linear vertical variation in total biomass $T_{bio}(z)$ from $10~mmol~N~m^{-3}$ at the surface to $20~mmol~N~m^{-3}$ at $z = 100~m$; $K_{z_b} = 0.0864~(m^2/day)$; $K_{z_0} = 8.64~(m^2/day)$; $\gamma_t = 0.1~m^{-1}$; $D_z = -100~m$; and $\rho_w = 1000~kg/m^3$. For training, we randomly select short time-sequences spanning 3 time-steps (batch-time) and extract data at every other time-step to form batches of size 4; we use 26 iterations per epoch; an exponentially decaying learning rate (LR) schedule is used with an initial LR of 0.075, the decay rate of 0.97, and 26 decay steps; the RMSprop optimizer is adopted; training is terminated at 200 epochs. We also use both $\mathcal{L}_1$ and $\mathcal{L}_2$ regularization for the weights of the neural network with factors of $1.5 \times 10^{-3}$ and $1\times 10^{-3}$, respectively, along with pruning of the weights if their value drops below $5 \times 10^{-3}$.
\subsubsection{Experiments-2b:}
We use a batch-time of 3 time-steps with data extracted at every other time-step to form batches of size 8; we use 26 iterations per epoch; an exponentially decaying learning rate (LR) schedule is applied with an initial LR of 0.075, the decay rate of 0.97, and 26 decay steps; the RMSprop optimizer is employed; training is terminated at 200 epochs. We also use both $\mathcal{L}_1$ and $\mathcal{L}_2$ regularization for the weights of the Markovian closure with factors of $1.5 \times 10^{-3}$ and $1\times 10^{-3}$, respectively, along with pruning of the weights if their value drops below $5 \times 10^{-3}$. For the neural network in the non-Markovian closure term, only $\mathcal{L}_2$ regularization with a factor of $1\times 10^{-5}$ is used.
Finally, for all the experiments and their multiple repeats with the exact same tuned hyperparameters, we provide variation of training and validation error as training progresses (figure \ref{fig: gnCM Loss plots}).
\input{Tables/Table_gnCM_architectures}
\begin{figure}[]
\centering
\subfloat[][Experiments-1a]{\includegraphics[width=0.85\textwidth]{Figures/gnCM/Exp1a/Exp1a_train_val_loss.png}} \\
\subfloat[][Experiments-1b (\textit{g}nCM with only Markovian closure term)]{\includegraphics[width=0.85\textwidth]{Figures/gnCM/Exp1b/Exp1b_train_val_loss_only_mark.png}} \\
\subfloat[][Experiments-1b (\textit{g}nCM with both Markovian and non-Markovian closure terms)]{\includegraphics[width=0.85\textwidth]{Figures/gnCM/Exp1b/Exp1b_train_val_loss_both_mark_and_nonmark.png}}
\caption{Variation of training (left column) and validation (right column) loss with epochs, for each of the experiments-1a, 1b, 2a, and 2b. We use boxplots to provide statistical summaries for multiple training repeats done for each set of experiments. The box and its whiskers provide a five-number summary: minimum, first quartile (Q1), median (orange solid line), third quartile (Q3), and maximum, along with outliers (black circles) if any. These results accompany the architectures detailed in table \ref{table: All architecture}. \emph{(cont.)}}
\label{fig: gnCM Loss plots}
\end{figure}
\begin{figure}[]
\ContinuedFloat
\centering
\subfloat[][Experiments-2a]{\includegraphics[width=0.85\textwidth]{Figures/gnCM/Exp2a/Exp2a_train_val_loss.png}} \\
\subfloat[][Experiments-2b]{\includegraphics[width=0.85\textwidth]{Figures/gnCM/Exp2b/Exp2b_train_val_loss.png}}
\caption{Variation of training (left column) and validation (right column) loss with epochs, for each of the experiments-1a, 1b, 2a, and 2b. We use boxplots to provide statistical summaries for multiple training repeats done for each set of experiments. The box and its whiskers provide a five-number summary: minimum, first quartile (Q1), median (orange solid line), third quartile (Q3), and maximum, along with outliers (black circles) if any. These results accompany the architectures detailed in table \ref{table: All architecture}.}
\end{figure}
\subsection{Experiments 1a: Nonlinear Waves - Interpretable Model Discrimination}
\input{Experiments/Exp_gnCM_advecting_shock_model_ambiguity}
\subsection{Experiments 1b: Advecting Shock - Model Discovery and Generalization}
\input{Experiments/Exp_gnCM_advecting_shock_subgrid_scale_processes}
\subsection{Experiments 2a: Ocean Acidification - Interpretable Model Discrimination}
\label{sec: Experiments 2a}
\input{Experiments/Exp_gnCM_OA_model_ambiguity}
\subsection{Experiments 2b: Ocean Acidification - Model Complexity}
\input{Experiments/Exp_gnCM_OA_model_simplification}
\subsection{Computational Advantages}
\input{Sections/Sec_gnCM_computational_advantage}
\subsection{Neural Partial Delay Differential Equations}
We now obtain ML schemes that learn PDDEs parameterized using NNs. They are referred to as \textit{neural} partial delay differential equations (\textit{n}PDDEs). Without loss of generality, and for brevity, we limit ourselves to \textit{n}PDDEs with only a Markovian term and a non-Markovian term with distributed delays. The low-fidelity model can be considered to be absorbed in the Markovian closure term. Hence, the \textit{n}PDDE is of the form,
\begin{equation}
\begin{split}
\frac{\partial u(x, t)}{\partial t} &= \mathcal{F}_{NN}\left(u(x, t), \frac{\partial u(x, t)}{\partial x}, \frac{\partial^2 u(x, t)}{\partial x^2}, ..., \frac{\partial^d u(x, t)}{\partial x^d}, x, t; \phi \right) \\
& + \int_{t-\tau}^t \mathcal{D}_{NN}\left(u(x, s), \frac{\partial u(x, s)}{\partial x}, \frac{\partial^2 u(x, s)}{\partial x^2}, ..., \frac{\partial^d u(x, s)}{\partial x^d}, x, s; \theta\right)ds \,, \\
& \hspace{0.6\textwidth} x\in \Omega, \; t \geq 0, \\
u(x, t) &= h(x, t), \; -\tau \leq t \leq 0 \quad \text{and} \quad \mathcal{B}(u(x, t)) = g(x, t) \, \quad x \in \partial \Omega, \; t \geq 0 \;.
\end{split}
\label{eq: nPDDE in original form}
\end{equation}
The two NNs, instantaneous
$\mathcal{F}_{NN}(\bu; \phi)$ and delayed $\mathcal{D}_{NN}(\bu; \theta)$, remain
parameterized by $\phi$ and $\theta$, and for generality, they are considered to be functions of an arbitrary number of spatial derivatives, with the highest order defined by $d \in \mathbb{Z}^+$.
We can rewrite equation \ref{eq: nPDDE in original form} as an equivalent system of coupled PDDEs with discrete delays,
\begin{equation}
\begin{split}
\frac{\partial u(x, t)}{\partial t} &= \mathcal{F}_{NN}\left(u(x, t), \frac{\partial u(x, t)}{\partial x}, \frac{\partial^2 u(x, t)}{\partial x^2}, ..., \frac{\partial^d u(x, t)}{\partial x^d}, x, t; \phi \right) + y(x, t) \;, \\
& \hspace{0.6\textwidth} x\in \Omega, \; t \geq 0 \,, \\
\frac{\partial y(x, t)}{\partial t} &= \mathcal{D}_{NN}\left(u(x, t), \frac{\partial u(x, t)}{\partial x}, \frac{\partial^2 u(x, t)}{\partial x^2}, ..., \frac{\partial^d u(x, t)}{\partial x^d}, x, t; \theta\right) \\
& - \mathcal{D}_{NN}\left(u(x, t-\tau), \frac{\partial u(x, t-\tau)}{\partial x}, \frac{\partial^2 u(x, t-\tau)}{\partial x^2}, ..., \frac{\partial^d u(x, t-\tau)}{\partial x^d}, x, t-\tau; \theta\right) \;, \\
& \hspace{0.6\textwidth} x\in \Omega, \; t \geq 0 \,,\\
u(x, t) &= h(x, t), \; -\tau \leq t \leq 0 \quad \text{and} \quad\mathcal{B}(u(x, t)) = g(x, t), \; x \in \partial \Omega, \; t \geq 0 \,, \\
y(x, 0) &= \int_{-\tau}^0 \mathcal{D}_{NN}\left(h(x, s), \frac{\partial h(x, s)}{\partial x}, \frac{\partial^2 h(x, s)}{\partial x^2}, ..., \frac{\partial^d h(x, s)}{\partial x^d}, x, s; \theta\right)ds \,.
\end{split}
\label{eq: nPDDE in the split form}
\end{equation}
Let us assume that high-fidelity data is available at $M$ discrete times, $T_1 < ...<T_M \leq T$, and at $N(T_i)$ spatial locations ($x_{k}^{T_i} \in \Omega, \forall k \in {1, ..., N(T_i)}$) for each of the times. Thus, we define the scalar loss function as, $L = \frac{1}{M} \sum_{i=1}^{M} \frac{1}{N(T_i)}\sum_{k=1}^{N(T_i)} l(u(x^{T_i}_k, T_i)) \equiv \int_0^T \frac{1}{M} \sum_{i=1}^{M} \int_{\Omega} \frac{1}{N(T_i)}\sum_{k=1}^{N(T_i)} l(u(x, t))\delta(x - x^{T_i}_k) \delta(t - T_i)dxdt \allowbreak \equiv \int_0^T \frac{1}{M} \sum_{i=1}^{M} \frac{1}{|\Omega|} \int_{\Omega} \hat{l}(u(x, t))\delta(t - T_i) dxdt$, where $l(\bu)$ are scalar loss functions such as mean-absolute-error (MAE), and $\delta(\bu)$ is the Kronecker delta function.
In order to derive the adjoint PDEs, we start with the Lagrangian corresponding to the above system,
\begin{equation}
\begin{split}
\mathbb{L} &= L(u(x, t)) + \iw \lt(x, t) \left(\p_t u(x, t) - \mathcal{F}_{NN}(\bu, t; \phi) - y(x, t)\right) dxdt \\
& + \iw \mt(x, t) \left(\p_t y(x, t) - \mathcal{D}_{NN}(\bu, t;\theta) + \mathcal{D}_{NN}(\bu, t-\tau; \theta)\right) dxdt \\
& + \int_{\Omega} \alpha^T(x) \left(y(x, 0) - \int_{-\tau}^0 \mathcal{D}_{NN}(h(x, t), \p_x h(x, t), \p_{x^2} h(x, t), ..., \p_{x^d} h(x, t), x, t; \theta)dt\right)dx \,,
\end{split}
\end{equation}
where $\lambda(x, t)$, $\mu(x, t)$ and $\alpha(x)$ are the Lagrangian variables. To find the gradients of $\mathbb{L}$ w.r.t. $\phi$ and $\theta$, we first solve the following adjoint PDEs (for brevity we denote, $\partial / \partial (\bu) \equiv \partial_{(\bu)}$, and $d / d (\bu) \equiv d_{(\bu)}$),
\begin{equation}
\label{eq: gnCM adjoint PDEs}
\begin{split}
0 &= \frac{1}{M}\frac{1}{|\Omega|} \sum_{k=1}^M \p_{u(x, t)} \hat{l}(u(x, t)) \delta(t - T_k) \\
%
& - \p_t \lt(x, t) - \lt(x, t)\p_{u(x, t)}\mathcal{F}_{NN}(\bu, t)
%
+ \sum_{i=1}^d (-1)^{i+1} \p_{x^i} \left(\lt(x, t) \p_{\p_{x^i} u(x, t)} \mathcal{F}_{NN}(\bu, t) \right)
\\
%
& - \mt(x, t) \p_{u(x, t)} \mathcal{D}_{NN}(\bu, t; \theta)
%
+ \sum_{i=1}^d (-1)^{i+1} \p_{x^i} \left(\mt(x, t) \p_{\p_{x^i} u(x, t)} \mathcal{D}_{NN}(\bu, t; \theta) \right)
\\
%
& + \mt(x, t+\tau) \p_{u(x, t)} \mathcal{D}_{NN}(\bu, t; \theta)
%
- \sum_{i=1}^d (-1)^{i+1} \p_{x^i} \left(\mt(x, t+\tau) \p_{\p_{x^i} u(x, t)} \mathcal{D}_{NN}(\bu, t; \theta) \right) \;, \\
& \hspace{0.6\textwidth} x \in \Omega \;, \; t \in [0, T) \,,
\\
%
0 & = -\lt(x, t) - \p_t \mt (x, t) \;, \quad x \in \Omega \;, \; t \in [0, T) \,,
\end{split}
\end{equation}
with initial conditions, $\lambda(x, t) =\mu (x, t) = 0, \; t \geq T$. The boundary conditions are derived based on those of the forward PDDE and they satisfy,
\begin{equation}
\begin{split}
0 &= \sum_{i = 0}^d \sum_{j=0}^{d-i-1} (-1)^{j+1} \p_{x^{j}} \left(\lt(x, t)\p_{\p_{x^{j+i+1}} u(x, t)} \mathcal{F}_{NN}(\bu, t)\right)\dt \p_{x^{i}}u(x, t)
%
\\
%
& +\sum_{i = 0}^d\sum_{j=0}^{d-i-1} (-1)^{j+1} \p_{x^{j}} \left(\mt(x, t)\p_{\p_{x^{j+i+1}} u(x, t)} \mathcal{D}_{NN}(\bu, t)\right)\dt \p_{x^{i}}u(x, t) \\
%
& - \sum_{i = 0}^d\sum_{j=0}^{d-i-1} (-1)^{j+1} \p_{x^{j}} \left(\mt(x, t+\tau)\p_{\p_{x^{j+i+1}} u(x, t)} \mathcal{D}_{NN}(\bu, t)\right)\dt \p_{x^{i}}u(x, t) \;, \\
& \hspace{0.6\textwidth} x \in \partial \Omega, \; t \in [t, T) \,.
\end{split}
\end{equation}
Details of the derivation of the above adjoint PDEs are in section \ref{sec: gnCM Adjoint Equations in supp info}. As the adjoint PDEs are solved backward in time, one would require access to $u(x, t), \forall x \in \Omega, \; 0 \leq t \leq T$. In our current implementation, we create and continuously update an interpolation function using the $u$ obtained at every time-step as we solve the forward model (equation \ref{eq: nPDDE in original form}). For memory efficiency, we can use the method of \textit{checkpointing} \cite{griewank1992achieving}. After solving for the Lagrangian variables, $\lambda(x, t)$ and $\mu(x, t)$, we compute the required gradients as,
\begin{equation}
\begin{split}
\dt\mathcal{L} &= - \iw \mt(x, t) \pth \mathcal{D}_{NN}(\bu, t; \theta) dxdt + \iw \mt(x, t) \pth \mathcal{D}_{NN}(\bu, t-\tau; \theta) dxdt \\
& - \int_{\Omega} \mt(x, 0) \int_{-\tau}^0 \pth \mathcal{D}_{NN}(h(x, t), \p_x h(x, t), \p_{xx} h(x, t), x, t; \theta)dt dx \,, \\
d_{\phi}\mathcal{L} &= - \iw \lt(x, t) \pp \mathcal{F}_{NN}(\bu, t; \phi) dxdt \,.
\end{split}
\end{equation}
Finally, using a stochastic gradient descent algorithm, we find the optimal values of the weights $\phi$ and $\theta$.
For interpretability -- especially for the Markovian closure term -- we can use a simple NN architecture with no hidden layers and linear activation. Nonlinearity can still be introduced by having input features that are nonlinear combinations of the states and their derivatives belonging to a function library.
The result is a linear combination of these nonlinear input features.
Along with this, a $L_1$ regularization on the NN weights and pruning below a threshold helps promote sparsity.
Although this approach may seem similar to SINDy \cite{brunton2016discovering, rudy2019data, kulkarni_et_al_DDDAS2020}, it is significantly different.
SINDy requires training data to be rich enough to allow for the computation of temporal and spatial derivatives, and solves a regression problem to discover the governing dynamical system.
The \textit{g}nCM method however accounts for the accumulation of time-integration errors during training by numerically solving the PDE augmented with the Markovian closure term and its corresponding adjoint PDE. It does not require using the training data to compute any temporal and spatial derivatives.
It also seamlessly incorporates and simultaneously learns a non-Markovian closure term.
The forward model (equation \ref{eq: low-fid with closure terms} or \ref{eq: nPDDE in original form}) and the adjoint PDEs (equation \ref{eq: gnCM adjoint PDEs}) are discretized and integrated using numerical schemes \cite{chapra2011numerical}, such as, finite differences, finite volumes, collocation methods, etc.
This new approach, where we augment the PDEs with the NN-based
Markovian and non-Markovian closures first, before numerical discretization, ensures that the burden of generalization over boundary conditions, domain geometry, and computational grid resolution, along with computing the relevant spatial derivatives is handled by the numerical schemes, and not by the learned NNs. This also automatically makes the learning only dependent on local features and affine equivariant, similar to numerical schemes.
The overall \textit{g}nCM framework is schematized in Figure \ref{fig: framework overview}.
\begin{figure}[h]
\centering
\includegraphics[width=1\textwidth]{Figures/gnCM/framework_overview.png}
\caption{Overview of the \textit{generalized} neural closure models (\textit{g}nCM) framework. The blocks labeled \textit{DNN} represent any deep neural-network architectures. The block labeled $\int$ symbolizes any time-integration scheme. DDE stands for delay differential equation.
}
\label{fig: framework overview}
\end{figure}
\section{Introduction} \label{sec:intro}
\input{Sections/Sec_gnCM_Introduction}
\section{Theory and Methodology}
\label{sec: Methodology}
\input{Sections/Sec_gnCM_Theory_and_Methodology}
\section{Application Results and Discussion}
\label{sec: results and discussions}
\input{Sections/Sec_gnCM_Application_and_Results}
\section{Conclusions}
\label{sec: conclusions}
\input{Sections/Sec_gnCM_Conclusions}
\vspace{0.75cm}
\noindent\textbf{Data Accessibility. }{The codes and data used in this work are available in the GitHub repository: \url{https://github.com/mit-mseas/generalized_nCMs.git}}
\vspace{0.25cm}
\noindent\textbf{Author's Contributions. }{A.G.\ conceived the idea of extending the existing neural closure models using neural partial delay differential equations; augmentation of closure terms in the continuous spatio-temporal space followed with numerical discretization for generalizability and interpretability; derived the adjoint PDE; implemented the neural network architectures and the simulation experiments; interpreted the computational results; and wrote a first draft of the manuscript. P.F.J.L.\ supervised the work; provided ideas; interpreted the results; and edited and wrote significant parts of the manuscript.}
\vspace{0.25cm}
\noindent\textbf{Competing Interests. }{We declare we have no competing interests.}
\vspace{0.25cm}
\noindent\textbf{Funding. }{We are grateful to the Office of Naval Research for partial support under
grant N00014-20-1-2023 (MURI ML-SCOPE) to the
Massachusetts Institute of Technology.}
\vspace{0.25cm}
\noindent\textbf{Acknowledgement. }{We thank the members of our MSEAS group for their collaboration and insights, especially Mr. Aman Jalan. We also thank our ML-SCOPE team for many useful discussions.
}
\bibliographystyle{abbrvnat}
\section{Adjoint Equations for Neural Partial Delay Differential Equations}
\label{sec: gnCM Adjoint Equations in supp info}
\input{Sections/Sec_gnCM_adjoint_eqns_for_nPDDEs}
\section{Experimental Setup}
\label{sec: gnCM Experimental Setup}
\input{Sections/Sec_gnCM_experimental_setup}
\bibliographystyle{unsrtnat}
| {'timestamp': '2023-01-18T02:15:30', 'yymm': '2301', 'arxiv_id': '2301.06198', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06198'} | arxiv |
\section{Introduction}
Applications in several fields, such as ecology \citep{saito2015should}, biology \citep{rohlf1990extensions}, analytical chemometrics \citep{andrade2004procrustes}, psychometrics \citep{green1952orthogonal,mccrae1996evaluating}, and neuroscience \citep{Haxby} need to compare information described by matrices expressed in an arbitrary coordinate system. The dimension of the matrices corresponding to this arbitrary coordinate system results to be a functional misalignment. In this context, the statistical shape analysis \citep{dryden2016statistical} called \emph{Procrustes} analysis \citep{Gower} can be helpful. Briefly, the \emph{Procrustes} analysis aligns the matrices into a common reference space by similarity transformations (i.e., rotation, reflection, translation, and scaling transformations). The optimal similarity transformations are those that minimize the squared distance between the matrices.
Several \emph{Procrustes}-based functional alignment approaches can be found in the literature; two of the most used ones are the orthogonal \emph{Procrustes} problem (OPP) \citep{Jos} and the generalized \emph{Procrustes} analysis (GPA) \citep{gower1975generalized}. The first deals with the alignment of two matrices, while the second finds optimal similarity transformations when more than two matrices are analyzed. OPP has a closed-form solution, while GPA is based on an iterative algorithm proposed by \cite{gower1975generalized}. Since the \emph{Procrustes} problem can be seen as a least squares problem, \cite{Goodall} translated it into a statistical model, i.e., the perturbation model, where the error terms follow a matrix normal distribution \citep{gupta2018matrix}.
Neuroscience is one of the fields where \emph{Procrustes}-based methods are most widely used. In particular, functional magnetic resonance imaging (fMRI) is the most widely used technique for studying the neural underpinnings of human cognition. Brain activation is expressed as the correlation between the sequence of cognitive stimuli and the sequence of measured blood oxygenation levels (BOLD). In response to neural activity, changes in brain hemodynamics affect the local intensity of the magnetic resonance signal, that is, the voxel intensity (single-volume elements). However, various criticalities arise when analysis (e.g., classification analysis, inference analysis) between subjects is performed. The anatomical and functional structures of the brain greatly vary between subjects, even if time-synchronized stimuli are proposed to the participants \citep{Watson, Tootell, Hasson}. For that, the alignment step is an essential part of the preprocessing procedure in fMRI group-level analysis. Anatomical normalization (e.g., \cite{talairach1988co, jenkinson2002improved, Fischl}) fixes the anatomical misalignment through affine transformations, where brain images are aligned to a standard anatomical template (e.g., Talairach template \citep{talairach1988co}, Montreal Imaging Institute (MNI) template \citep{collins1994automatic}). However, the anatomical alignment does not capture the functional variability between subjects, which is a well-known problem in the neuroscience literature \citep{Watson, Hasson, Tootell}.
The brain activation of one subject can be described by a matrix where the rows represent the time points/stimuli and the columns the voxels. Therefore, each row shows the response activation to one stimulus across all voxels, and each column expresses the time series of activation for each voxel. The functional misalignment can be focused on the columns between matrices, i.e., the time series of activations are not in correspondence between subjects, while the response activations are since the stimuli are generally time-synchronized \citep{Haxby, andreella2022procrustes}.
In the context of fMRI data, one of the most popular \emph{Procrustes}-based functional alignment methods is the \emph{hyperalignment} technique proposed by \cite{Haxby}, which is a sequential approach to OPP. However, both OPP and GPA and \emph{hyperalignment} suffer from low interpretability of aligned matrices (i.e., fMRI images) and related results (e.g., statistical t-tests, classifier coefficients) as well as in-applicability in high-dimensional data. In particular, in fMRI data analysis, the first problem leads to losing the anatomical interpretation of the final aligned images, and the second one makes it impossible to apply the alignment method to the whole brain. The low interpretability is caused by the ill-posed structure of the \emph{Procrustes}-based approaches: they do not return a unique solution for the optimal orthogonal transformation. For further details about the functional alignment problem in the fMRI data analysis framework, please see \cite{andreella2022enhanced}.
For that, \cite{andreella2022procrustes} proposed an extension, i.e., the ProMises model, of the perturbation model developed by \cite{Goodall}. In particular, the perturbation model rephrases the \emph{Procrustes} problem as a statistical model. The extension of \cite{andreella2022procrustes} is focused on inserting a penalization in the orthogonal matrix's estimation process, specifying a proper prior distribution for the orthogonal matrix parameter. The von Mises-Fisher distribution \citep{downs1972orientation} is used to insert prior information about the final structure of the common space. Thanks to that, the no-uniqueness problem of the \emph{Procrustes}-based methods is solved, getting an interpretable estimator for the orthogonal matrix transformations. This permits to have unique aligned matrices as well as related statistical inference results. The alignment process does not affect the type I error since the ProMises model can be seen as a procedure that sorts the null hypotheses based on a priori information \citep{andreella2022valid}.
The computation of the maximum a posteriori estimate is straightforward; in fact, the von Mises-Fisher distribution is a conjugate prior to the matrix normal distribution \citep{gupta2018matrix}, which is the distribution of the error terms in the ProMises and perturbation models.
In this work, we present a method that exploits the information coming from the functional misalignment resulting from \emph{Procrustes}-based methods (e.g., GPA, \emph{hyperlalignment} and ProMises model). We propose here two distance metrics \citep{deza2006dictionary} that capture different perspectives of similarity/dissimilarity between matrices, e.g., subjects in the fMRI cases. The minimization problem solved by \emph{Procrustes}'s methods can also be defined as distance among objects \citep{dryden2016statistical}. The first distance metric presented here is based on the residuals coming from the solution of a Procrustes problem. The \emph{residual-based} distance expresses then how the matrices/subjects are different/similar after functional alignment. In this case, the distance metric captures the dissimilarity/similarity in terms of noise since the matrices have the same orientations after functional alignment. Instead, the second distance exploits the orthogonal matrix parameters solution of the \emph{Procrustes} problem. The \emph{rotational-based} distance computes the squared distance between these estimated orthogonal matrices. As we will see, this metric measures the level of dissimilarity/similarity in orientation between matrices/subjects before functional alignment.
In the paper, we show how these metrics can be used in distance-based techniques such as the multidimensional scaling method \citep{carroll1998multidimensional}, hierarchical clustering \citep{murtagh2012algorithms} and t-distributed stochastic neighbor embedding (t-SNE) \citep{van2008visualizing} in order to visualize and quantify patterns and shared characteristics between matrices (i.e., individuals described by multiple dimensions).
The paper is organized as follows. Section
\ref{promisesmodel} introduces the \emph{Procrustes}-based methods. The core of the manuscript is contained in Section \ref{rotations}, where the \emph{residual-based} and \emph{rotation-based} distances are proposed. Finally, we explain how to use the distances between rotations and residuals as a tool to understand the underlying clusters between subjects in the fMRI data analysis framework in Section \ref{application}. The analyses of this manuscript are performed using the \texttt{R} package \texttt{alignProMises} available at \url{https://github.com/angeella/alignProMises} for the functional alignment part, and using the \texttt{R} package \texttt{rotoDistance} available at \url{https://github.com/angeella/rotoDistance} for the computation of the \emph{rotational-based} and \emph{residual-based} distances.
\section{Procrustes analysis}\label{promisesmodel}
Let $\{\boldsymbol{X}_i \in \mathbb{R}^{n \times m}\}_{i = 1,\dots, N}$ be a set of matrices to be aligned. The Procrustes analysis uses similarity transformations \citep{gower1975generalized}, i.e., scaling, rotation/ reflection, and translation, to map $\{\boldsymbol{X}_i \in \mathbb{R}^{n \times m}\}_{i = 1,\dots, N}$ into a common reference space.
If only two matrices are analyzed, i.e., $N=2$, we can consider one of the two matrices as a common reference matrix. The orthogonal \emph{Procrustes} problem (OPP) is then applied and defined as:
\begin{equation}\label{eq:opp}
\min_{\boldsymbol{R}_i, \alpha_i, t_i} || \alpha (X_i - 1_n t) R - X_j||_{F}^2 \quad \text{subject to } R_i \in \mathcal{O}(m)
\end{equation}
where $\mathcal{O}(m)$ is the orthogonal group in dimension $m$, $|| \cdot||_{F}$ is the Frobenius norm, $\alpha \in \mathbb{R}^{+}$ is the isotropic scaling, $t \in \mathbb{R}^{1 \times m}$
defines the translation vector, and $1_n \in \mathbb{R}^{1 \times n}$ is a vector of ones.
The optimal translation results to be the column-centering, while $\boldsymbol{R}$ and $\alpha$ equal
\begin{equation}\label{eq:svd}
\hat{R} = \boldsymbol{U} \boldsymbol{V}^\top; \quad \hat{\alpha}_{\hat{R}} = \frac{\text{tr}(D)}{|| \hat{R}^\top X_i^\top||^2_{\text{F}}}
\end{equation}
where $U D V^\top$ is the singular value decomposition of $\boldsymbol{X}_i^\top \boldsymbol{X}_j$.
If more than two matrices are analyzed, i.e., $N>2$, the generalized \emph{Procrustes} analysis (GPA) must be applied. In this case, the set of matrices $\{\boldsymbol{X}_i \in \mathbb{R}^{n \times m}\}_{i = 1,\dots, N}$ are mapped by similarity transformations into a common reference matrix $\boldsymbol{M} \in \mathbb{R}^{n \times m}$. This common reference matrix can be defined in several ways, e.g., element-wise arithmetic mean. The GPA is defined as
\begin{equation}\label{eq:gpa}
\min_{\boldsymbol{R}_i, \alpha_i, t_i} \sum_{i=1}^{N} || \alpha_i (X_i - 1_n t_i) R_i - M||_{F}^2 \quad \text{subject to } R_i \in \mathcal{O}(m).
\end{equation}
Unlike OPP, GPA does not have a closed-form solution for $R_i$ and $\alpha_i$, and an iterative algorithm must be used where at each step, the reference matrix is updated \citep{gower1975generalized}.
Another approach is the perturbation model proposed by \cite{Goodall}, where the least squares problem defined in Equation \ref{eq:gpa} is translated as a statistical model assuming that $\{\boldsymbol{X}_i\}_{i = 1,\dots, N}$ are noisy rotations of a common space $\boldsymbol{M}$.
The perturbation model is then defined as follows:
\begin{equation}\label{promises}
\boldsymbol{X}_i = \alpha_i(\boldsymbol{M} + \boldsymbol{E}_i) \boldsymbol{R}_i^\top +\boldsymbol{1}^\top_n t_i
\end{equation}
where $\boldsymbol{E}_i$ is the random error matrix following a normal matrix distribution \citep{gupta2018matrix} $\boldsymbol{E}_i \sim \mathcal{MN}_{nm}(0, \boldsymbol{\Sigma}_n, \boldsymbol{\Sigma}_m)$, with $\boldsymbol{\Sigma}_n \in \mathbb{R}^{n \times n}$ and $\boldsymbol{\Sigma}_m \in \mathbb{R}^{m \times m}$. The similarity transformations are represented by the following parameters $\boldsymbol{R}_i$, $\alpha_i$, and $t_i$ that must be estimated for each $i = 1, \dots, N$. The optimal similarity transformations $\hat{R}_i$ and $\hat{\alpha_i}_{\hat{R}_i}$ are slight modifications of the ones found by OPP and GPA:
\begin{equation}\label{eq:svd2}
\hat{R}_i\ = \{\boldsymbol{U}_i \boldsymbol{V}_i^\top\}_{i = 1,\dots, N}; \quad \hat{\alpha_i}_{\hat{R}_i} = \frac{\text{tr}(D_i)}{|| \Sigma_m^{-1/2} \hat{R}_i^\top X_i^\top \Sigma_n^{-1/2}||^2_{\text{F}}} \quad \forall i \in \{1,\dots, N\}
\end{equation}
where $U_i D_i V_i^\top$ is the singular value decomposition of $\boldsymbol{X}_i^\top \Sigma_n^{-1} \boldsymbol{X}_j \Sigma_m^{-1}$.
The extension of the perturbation model is proposed by \cite{andreella2022procrustes}, where the orthogonal matrix parameter $\boldsymbol{R}_i$ follows a von Mises-Fisher distribution \citep{downs1972orientation}:
\begin{equation*}
f(\boldsymbol{R}_i) \sim C(\boldsymbol{F},k) \exp(k \boldsymbol{F} \boldsymbol{R}_i)
\end{equation*}
where $\boldsymbol{F} \in \mathbb{R}^{m \times m}$ is the location matrix parameter, $k \in \mathbb{R}^{+}$ represents the regularization parameter and $C(\boldsymbol{F},k)$ is the normalizing constant. \cite{andreella2022procrustes} found that the maximum a posteriori estimates are slight modifications of the perturbation model proposed by \cite{Goodall} (i.e., without imposing the von Mises-Fisher prior distribution for $\boldsymbol{R}_i$). The estimators for the sets of parameters $\{\boldsymbol{R}_i\}_{i = 1,\dots, N}$ and $\{\boldsymbol{\alpha}_i\}_{i = 1,\dots, N}$ are essentially the same but decomposing $\boldsymbol{X}_i^\top \Sigma_n^{-1} \boldsymbol{M} \Sigma_m^{-1} + k \boldsymbol{F}$ instead of $\boldsymbol{X}_i^\top \Sigma_n^{-1} \boldsymbol{M} \Sigma_m^{-1}$. The straightforward solutions are due to the conjugacy of the von Mises–Fisher distribution to the matrix normal distribution \citep{green2006bayesian, andreella2022procrustes}. Therefore, the prior information enters directly into the singular value decomposition step of the estimation process.
The motivation to impose an a priori distribution to the orthogonal matrix parameter $\boldsymbol{R}_i$ stems from the assumption that ``the anatomical alignment is not so far from the truth". The information of the three-dimensional spatial coordinates of the voxels is then inserted into the estimation process thanks to a proper definition of the prior location parameter $\boldsymbol{F} \in \mathbb{R}^{m \times m}$. \cite{andreella2022procrustes} define $\boldsymbol{F}$ as a similarity Euclidean distance. In this way, the rotation loadings that combine closer voxels are higher than the ones that combine voxels that are far apart. In addition, defining $\boldsymbol{F}$ as a similarity Euclidean matrix leads to $\boldsymbol{X}_i^\top \Sigma_n^{-1} \boldsymbol{M} \Sigma_m^{-1} + k \boldsymbol{F}$ having full rank, i.e., unique solution for $\boldsymbol{R}_i$.
Finally, \cite{andreella2022procrustes} proposed an efficient version of the ProMises model in the case of high-dimensional data. The problem when $m >> n$ arises since the ProMises model, and also the perturbation model, must compute $N$ singular value decompositions of matrices with dimensions $m \times m$. \cite{andreella2022procrustes} use specific semi-orthogonal transformations to project the matrices $\boldsymbol{X}_i \in \mathbb{R}^{n \times m}$ into the lower dimensional space $\mathbb{R}^{n \times n}$. In particular, if we consider as $m\times n$ semi-orthogonal transformation $\boldsymbol{Q}_i$ the ones coming from the thin singular value decomposition \citep{bai2000templates} of $\boldsymbol{X}_i$ we reach the same fit of data but reducing the time complexity from $\mathcal{O}(m^3)$ to $\mathcal{O}(m n^2)$, and the space complexity from $\mathcal{O}(m^2)$ to $\mathcal{O}(mn)$.
Briefly, the Efficient ProMises applies the semi-orthogonal transformation $\boldsymbol{Q}_i$ to $\boldsymbol{X}_i$ and then applies the ProMises model on the set of lower dimensional matrices $\{\boldsymbol{X}_i \boldsymbol{Q}_i \in \mathbb{R}^{n \times n}\}$. The efficient ProMises model allows the alignment of high-dimensional data such as fMRI data where the dimension $m$ (i.e., the number of voxels) equals approximately $200,000$.
For further details about the ProMises model and its Efficient version, please see \cite{andreella2022procrustes}.
\section{Procrustes-based distances}\label{rotations}
\emph{Procrustes}-based methods (i.e., OPP, GPA, perturbation model, or ProMises model) find the orthogonal matrices that, applied to the original matrices, minimize the Frobenius distance among resulting matrices. It is, therefore, natural to define a distance that is based on this quantity: the squared residuals among aligned matrices. In this case, we measure how different two matrices are beyond rotation. Two matrices can look very different, while they may result to be very similar after rotation. \emph{Residual-based} distance succeeds in capturing this aspect, thus evaluating only the distance between matrices net of rotations.
The second kind of distance that we will define is based on the \emph{rotational effort} that is taken to align one matrix $\boldsymbol{X}_i$ to another matrix $\boldsymbol{X}_j$. This effort is measured as the distance between the orthogonal matrix that solves the Procrustes problem $\hat{\boldsymbol{R}}_i$ and $\boldsymbol{I}_m$ (i.e., the matrix that does not operate any rotation): the larger the distance between the $\hat{\boldsymbol{R}}_i$ and $\boldsymbol{I}_m$, the bigger the effort to align $\boldsymbol{X}_i$ to $\boldsymbol{X}_j$.
In the following, we give the formal definitions of \emph{residual-based} and \emph{rotational-based} distances:
\begin{definition}\label{distance2}
Consider a set of matrices $\{\boldsymbol{\hat{X}}_i \in \mathbb{R}^{n \times m}\}_{i=1, \dots, N}$ functionally aligned by some \emph{Procrustes}-based method presented in Section \ref{promisesmodel}, i.e.,
\begin{equation*}
\boldsymbol{\hat{X}}_i = \hat{\alpha_i}_{\boldsymbol{\hat{R}_i}}\boldsymbol{X}_i \boldsymbol{\hat{R}_i}.
\end{equation*}
The \emph{residual-based} distance is defined as:
\begin{equation}\label{eq:res}
d_{Re}(\boldsymbol{\hat{X}}_i, \boldsymbol{\hat{X}}_j) = || \boldsymbol{\hat{X}}_i - \boldsymbol{\hat{X}}_j||_{F}^2.
\end{equation}
\end{definition}
We can note that the \emph{residual-based} distance defined in Equation \ref{eq:res} is directly related to the GPA defined in Equation \ref{eq:gpa}. If we consider two matrices, the distance is simply the pair's contribution within the GPA minimization problem, precisely the optimization's residuals.
\begin{definition}\label{distance}
Consider a set of orthogonal matrices $\{\hat{\boldsymbol{R}}_i \in \mathcal{O}(m)\}_{i=1, \dots, N}$ estimated by some \emph{Procrustes}-based method presented in Section \ref{promisesmodel}. The \emph{rotational-based} distance is defined as:
\begin{equation}
d_{Ro}(\hat{\boldsymbol{R}}_i, \hat{\boldsymbol{R}}_j) = || \hat{\boldsymbol{R}}_i - \hat{\boldsymbol{R}}_j||_{F}^2.
\end{equation}
\end{definition}
Since both distances are based on the matrix Frobenius norm, this implies that $d_{Re} (\cdot)$ and $d_{Ro} (\cdot)$ can be considered directly as a valid metric, i.e., distance functions $d_{Re}: \mathbb{R}^{n \times m} \times \mathbb{R}^{n \times m} \rightarrow \mathbb{R}^{\ge 0}$ and $d_{Ro}: \mathcal{O}(m)\times \mathcal{O}(m) \rightarrow \mathbb{R}^{\ge 0}$.
Therefore, if $d_{Re}=0$, the two matrices are functionally similar without considering the orientation characteristics. In the same way, as $d_{Re}$ increases, dissimilarity in functional terms increases without considering orientation again. Instead, if $d_{Ro}=0$, we have two images sharing the same orientation, i.e., functional (mis)alignment concerning the reference matrix $\boldsymbol{M}$. In the same way, if $d_{Ro} >0$, the two matrices have different orientations in terms of column dimension.
Indeed, the definition of \emph{rotational-based} distance can be significantly simplified, thus simplifying both the computational calculation and the interpretation of distance itself. This is formalized in the following:
\begin{prop}
The \emph{rotational-based} distance defined in Definition \ref{distance} can be expressed as:
\begin{equation*}
d_{Ro}(\hat{\boldsymbol{R}}_i, \hat{\boldsymbol{R}}_j) = 2m -2tr( \hat{\boldsymbol{R}}_i^\top \hat{\boldsymbol{R}}_j)
\end{equation*}
and takes values in $[0, 4m]$. The same result can be obtained using the \emph{residual-based} distance $d_{Re}$ defined in Equation \ref{eq:res} when $\boldsymbol{\hat{X}}_i, \boldsymbol{\hat{X}}_j \in \mathcal{O}(m)$.
\end{prop}
\begin{proof}
\begin{align*}
d(\hat{\boldsymbol{R}}_i, \hat{\boldsymbol{R}}_j) &= ||\hat{\boldsymbol{R}}_i - \hat{\boldsymbol{R}}_j||_{F}^2 = tr[(\hat{\boldsymbol{R}}_i - \hat{\boldsymbol{R}}_j)^\top (\hat{\boldsymbol{R}}_i - \hat{\boldsymbol{R}}_j)] \\
&= tr(\hat{\boldsymbol{R}}_i^\top \hat{\boldsymbol{R}}_i - \hat{\boldsymbol{R}}_i^\top \hat{\boldsymbol{R}}_j - \hat{\boldsymbol{R}}_j^\top \hat{\boldsymbol{R}}_i + \hat{\boldsymbol{R}}_j^\top \hat{\boldsymbol{R}}_j) = 2m -2tr( \hat{\boldsymbol{R}}_i^\top \hat{\boldsymbol{R}}_j).
\end{align*}
Considering the \emph{rotational}-based distance, the trace of the product between the two orthogonal matrices $\hat{\boldsymbol{R}}_i$ and $\hat{\boldsymbol{R}}_j$ can take only values between $m$ and $-m$ since the eigenvalues of an orthogonal matrix lie on the unit circle (i.e., they have module equal to $1$). If $tr( \hat{\boldsymbol{R}}_i^\top \hat{\boldsymbol{R}}_j) = m$, this means that $ \hat{\boldsymbol{R}}_i = \hat{\boldsymbol{R}}_j$ since the only way for an orthogonal matrix to have all the eigenvalues equal to $1$ is being an identity matrix. In the same way, if the trace equals $-m$, this means that $ \hat{\boldsymbol{R}}_i^\top \hat{\boldsymbol{R}}_j = - I_m$, i.e., $ \hat{\boldsymbol{R}}_i = - \hat{\boldsymbol{R}}_j$.
\end{proof}
The \emph{residual-based} distance and the \emph{rotational-based} distance are then computed for each pair of aligned matrices $\{\hat{\boldsymbol{X}}_i \}_{i = 1, \dots, N}$ and for each pair of orthogonal matrices $\{\hat{\boldsymbol{R}}_i \}_{i = 1, \dots, N}$, resulting in a the global distance matrix $D \in \mathbb{R}^{N \times N}$. Information from different matrices with large dimensions can be summarized through the proposed distance matrix, which will turn out to be of lower dimension, i.e., of dimension $N \times N$. These distance matrices can be handy in various applications, particularly when handling big data. In the literature, various statistical methods are based on the distance matrix. However, they generally focus on analyzing the distances of several covariates described by a single matrix or on analyzing multiple distance matrices (e.g., the INDSCAL method proposed by \cite{carroll1998multidimensional}). In contrast, the distance matrix proposed in this manuscript directly summarizes several large matrices' similarity and dissimilarity characteristics.
This matrix $D$ can then be used inside a dissimilarity-based algorithm such as the multidimensional scaling technique \citep{carroll1998multidimensional}, hierarchical clustering \citep{murtagh2012algorithms} and t-distributed stochastic neighbor embedding (t-SNE) \citep{van2008visualizing}.
\section{Application}\label{application}
We analyze $24$ subjects passively looking at food and no-food (office utensils) images collected by \cite{smeets2013allured}. The food/no-food images are proposed to the participants alternately (24 seconds of food images and 24 seconds of no-food images) with a rest block of 12 seconds on average showing a crosshair. The food stimulus is a collection of attractive foods to capture brain activations concerning self-regulation in response to viewing images of tempting (i.e., palatable high-caloric) food \citep{smeets2013allured}.
The dataset was preprocessed using the Functional MRI of the Brain Software Library (FSL) \citep{jenkinson2012fsl} following a standard processing pipeline. The registration step to standard space images was computed using FLIRT \citep{jenkinson2001global}, the motion correction using MCFLIRT \citep{jenkinson2002improved}, the non-brain removal using BET \citep{jenkinson2002improved}, and spatial smoothing using a Gaussian Kernel FWHM ($6$mm). Finally, the intensity normalization of the entire four-dimensional dataset was computed by a single multiplicative factor, and the high-pass temporal filtering (Gaussian-weighted least-squares straight line fitting, with sigma=$64.0$s) was applied. The raw dataset is available at \url{https://openneuro.org/datasets/ds000157/versions/00001}, while the preprocessed one is available in the \texttt{R} package \texttt{rotoDistance} (\url{https://github.com/
angeella/rotoDistance}). For details about the experimental design and data acquisition, please see \cite{smeets2013allured}.
We analyze the right calcarine sulcus composed of $237$ voxels being an area involved in processing visual information and related to regions involved in the regulation of food intake \citep{smeets2013allured}. However, the whole brain can be analyzed instead of only a region of interest (e.g., right calcarine sulcus). In fact, the distances proposed permit to resume complex high-dimensional data, like the fMRI ones, that are generally composed by $N$ matrices having dimensions $300 \times 200,000$ (i.e., $300$ time points and $200,000$ voxels), through a matrix of low $N\times N$ dimensions.
The ProMises model is fitted on preprocessed data, and aligned images are then used to compute the distance matrix $\boldsymbol{D}_{Re} \in \mathbb{R}^{24 \times 24}$ (i.e., \emph{residual}-based distances), while
the corresponding optimal rotation matrices are used to compute $\boldsymbol{D}_{Ro} \in \mathbb{R}^{24 \times 24}$ (i.e., \emph{rotational}-based distances) as described in Section \ref{rotations}.
These two types of \emph{Procrustes}-based distance capture different information, i.e., the between-subjects dissimilarity in terms of brain activations before and after functional alignment. Figure \ref{fig:scatterplot} shows the distances $\boldsymbol{D}_{Re}$ and $\boldsymbol{D}_{Ro}$ for each pair of subjects. The correlation between them is very low, i.e., $\approx 0.03$, as we can note from Figure \ref{fig:scatterplot}, i.e., $\boldsymbol{D}_{Re}$ and $\boldsymbol{D}_{Ro}$ return two distinct insights regarding the between-subjects dissimilarity brain activations.
\begin{figure}
\centering
\includegraphics[width=.8\textwidth]{scatter_distance.pdf}
\caption{Scatterplot between $\boldsymbol{D}_{Re}$ and $\boldsymbol{D}_{Ro}$.}
\label{fig:scatterplot}
\end{figure}
The multidimensional scaling (MDS) technique \citep{carroll1998multidimensional} is now applied considering $\boldsymbol{D}_{Ro}$ as distance matrix. A second analysis is run using $\boldsymbol{D}_{Re}$. For comparison porposes, we also computed the Euclidean distances between images that are not functionally aligned. We denote the corresponding distance matrix as $D_{raw}(\boldsymbol{X}_i, \boldsymbol{X}_j) = || X_i - X_j||_{F}^2$. We used the \texttt{smacof} \texttt{R} package \citep{de2009multidimensional} for applying the multidimensional scaling technique. We decided to apply the spline MDS (monotone spline transformation) with as much flexibility as possible. See \cite{de2009multidimensional} for more details.
Furthermore, we have some covariates for each subject to analyze, briefly described in Table \ref{tab:cov} together with age, body mass index (BMI), and other information. We then analyze these covariates with the matrix of fitted configurations computed by the multidimensional scaling approach. Please see \cite{smeets2013allured} for more details.
\begin{table}[]
\centering
\begin{tabular}{l|l}
\textbf{COVARIATE} & \textbf{DESCRIPTION} \\
\toprule
Diet importance & Importance to dieting on a $5$ point scale\\
\rowcolor[gray]{.9}
Diet success & Success in the diet on a $5$ point scale\\
Appetite pre-experiment & Appetite before the scan on a $5$ point scale with $3$ items\\
&(Cronbach’s $\alpha= 0.84$)\\
\rowcolor[gray]{.9}
Appetite post-experiment & Appetite after the scan on a $5$ point scale with $3$ items \\
\rowcolor[gray]{.9}
&(Cronbach’s $\alpha= 0.91$)\\
Cycle phase & Date of their last menstrual period \\
&(follicular and ovulation, luteal and menstrual phases)
\end{tabular}
\caption{Description of the covariates concerning the dataset from \citep{smeets2013allured}}
\label{tab:cov}
\end{table}
Focusing firstly on the distance matrix $D_{Ro}$, Figure \ref{fig:stress} shows the stress value considering several numbers of dimensions $K = \{1, \dots, 20\}$ into the multidimensional scaling method. We evaluated that $K = 11$ is a good value corresponding to stress $\approx 0.05$.
\begin{figure}
\centering
\includegraphics[width=.8\textwidth]{stress.pdf}
\caption{$D_{Ro}$ analysis: Stress values considering several numbers of dimensions in the multidimensional scaling method. The dotted red lines refer to stress equal to $0.05$, and a number of dimensions equal to $11$.}
\label{fig:stress}
\end{figure}
We then performed simple generalized linear regressions with the covariates as dependent variables and the $11$ configurations fitted by MDS as explanatory variables. We found a significant relationship between the covariate diet success and $6$ dimension ($t = -4.171$, $p = 0.0065$) in accordance with the results found by \cite{smeets2013allured}.
The p-value reported was adjusted for multiple testing using the Bonferroni method \citep{goeman2014multiple}. Therefore, Figure \ref{fig:distance} shows the $1$ and $6$ fitted configurations along with the main covariate (diet success) and cycle phase covariate.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{mds_R.pdf}
\caption{$D_{Ro}$ analysis: The $x$-axis represents the $1$th fitted configuration computed by the multidimensional scaling approach, while the $y$-axis shows the $6$th fitted configuration. The color gradient describes the diet success covariate (scaled), while the size of the points specifies the phase of the cycle.}
\label{fig:distance}
\end{figure}
At first look, we can note how the $y$ axis represents the success in a diet, where negative values correspond to low success and positive values high success in a diet. We can also note, for example, that subjects $16$ and $18$ share the same functional misalignment with similar diet success values and the same cycle phase.
However, if we instead apply multidimensional scaling on the matrix of \emph{residual-based} distances, we do not find patterns as clear as those found using \emph{rotation-based} distances, as can be seen from Figure \ref{fig:distance_res}. In this case, we automatically set the number of dimensions equal to $11$ (which is equivalent to a stress of $0.05$). The generalized linear regressions did not show any significant features, unlike the first analysis based on the distances of the rotations.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{mds_Xaligned.pdf}
\caption{$D_{Re}$ analysis: The $x$-axis represents the $1$th fitted configuration computed by the multidimensional scaling approach, while the $y$-axis shows the $6$th fitted configuration. The color gradient describes the appetite post covariate (scaled) while the size of the points specifies the phase of the cycle.
}
\label{fig:distance_res}
\end{figure}
Finally, we would have the same situation found using $D_{Re}$ (or even worse) if we used as distance matrix $D_{raw}$ (i.e., using images not functionally aligned). The stress value equals $0.02$ considering $11$ dimensions, and no significant dimensions were found from the generalized linear regressions. Figure \ref{fig:distance_raw} represents the multidimensional scaling results using $D_{raw}$. The two dimensions do not capture the subject-level features analyzed.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{mds_Xraw.pdf}
\caption{$D_{raw}$ analysis: The $x$-axis represents the $1$th fitted configuration computed by the multidimensional scaling approach, while the $y$-axis shows the $6$th fitted configuration. The color gradient describes the appetite post covariate (scaled), while the size of the points specifies the phase of the cycle.}
\label{fig:distance_raw}
\end{figure}
To sum up, the \emph{rotational}-based distance $D_{Ro}$ allows capturing the functional variability in neural response in terms of \emph{rotational effort}. The subjects' neural activation then differs in terms of orientation. However, these differences are lessened after and before the application of functional alignment, i.e., considering the \emph{residual}-based distance $D_{Re}$ and the \emph{raw}-based distance $D_{raw}$ when some subject-specific covariates are analyzed in the same time.
\section{Conclusions}
In this manuscript, we proposed \emph{Procrustes}-based distances based on the aligned images and orthogonal transformations estimated by \emph{Procrustes}-based methods. These distances permit the exploration of the dissimilarity between matrices from two independent points of view. The \emph{residual}-based distance expresses the dissimilarity in terms of functional columns net to rotations, i.e., eliminating the orientation component. Instead, the \emph{rotation}-based distance describes the dissimilarity in terms of functional (mis)alignment of the matrices' columns, i.e., how the matrices have similar column orientations. The method is helpful when the research aim is to analyze matrices expressed in an arbitrary coordinate system. In addition, the proposed distances can also be advantageous when the focus is exploring the distances between big data matrices, e.g., fMRI application. In this framework, each subject is represented by a vast matrix with approximately $300 \times 200,000$ dimensions. The \emph{Procrustes}-based distances permit the exploration of these matrices in a space with dimensions equal to the number of matrices/subjects analyzed. In the fMRI application, we found that these metrics result in reliable measures of individual differences. In fact, the \emph{Procrustes}-based functional alignments permit reducing confounds from topographic idiosyncrasies and capturing variation around shared functional and anatomical responses across individuals. The distances proposed in this manuscript allowed to find groups of individuals sharing patterns of neural brain activation. In conclusion, the \emph{Procrustes}-based distances thus add valuable exploratory and visualization tools to the world of Procrustes' methods.
\section*{Acknowledgment}
Angela Andreella gratefully acknowledges funding from the grant BIRD2020 /SCAR ASSEGNIBIRD2020\_01 of the University of Padova, Italy, and PON 2014-2020/DM 1062 of the Ca’ Foscari University of Venice, Italy. Some of the computational analyses done in this manuscript were carried out using the University of Padova Strategic Research Infrastructure Grant 2017: "CAPRI: Calcolo ad Alte Prestazioni per la Ricerca e l’Innovazione", \url{http://capri.dei.unipd.it}.
\section*{Author contributions}
\textbf{Angela Andreella}: conceptualization, software, data curation, formal analysis, investigation, and writing of the original draft, review \& editing. \textbf{Riccardo De Santis}: Conceptualization, methodology, writing the original draft, review \& editing. \textbf{Anna Vesely}: Conceptualization, methodology, writing the original draft, review \& editing. \textbf{Livio Finos}: Conceptualization, methodology, writing the
original draft, and supervision.
\section*{Declaration of Competing Interest}
The authors declare no competing interests.
\newpage
\bibliographystyle{apalike}
| {'timestamp': '2023-01-18T02:14:34', 'yymm': '2301', 'arxiv_id': '2301.06164', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06164'} | arxiv |
\section{Introduction}
\DeclareDocumentCommand\lc{m}{\mathop{lc}_{#1}}
\DeclareDocumentCommand\G{}{\mathcal{G}}
\DeclareDocumentCommand\B{}{\mathcal{B}}
\DeclareDocumentCommand\C{}{\mathcal{C}}
\DeclareDocumentCommand\M{}{\mathcal{M}}
\DeclareDocumentCommand\V{}{\mathcal{V}}
We consider functions $f : \{0,1\} \to \R$, which are often called \emph{pseudo-Boolean functions}.
The corresponding \emph{pseudo-Boolean optimization problem} of minimizing $f$ over $\{0,1\}^n$ is known to be NP-hard since it subsumes the maximum cut problem~\cite{BorosH02,Karp72}.
One way of tackling the problem is to linearize the objective function using auxiliary variables and then applying integer linear programming techniques.
A \emph{linearization} of $f$ is defined by functions $g_1,g_2,\dotsc,g_k : \{0,1\}^n \to \R$ such that
\begin{equation}
f(x) = \transpose{a}x + \beta + \sum_{i=1}^k b_i g_i(x) \label{eq_linearization}
\end{equation}
holds for all $x \in \{0,1\}^n$.
Its \emph{size} is the number $k$ of such functions.
The \emph{linearization complexity of $f$ with respect to a family $\G$} of functions is defined as the minimum size of a linearization with $g_i \in \G$ for all $i$, and is denoted by $\lc{\G}(f)$.
In this paper we focus on \emph{binary} linearizations, which are those where each function $g \in \G$ is Boolean, i.e., $g : \{0,1\}^n \to \{0,1\}$ holds.
For a binary linearization of size $k$ there exists an integer linear programming (IP) formulation with $n+k$ variables which works as follows.
In addition to the variables $x \in \{0,1\}^n$ we introduce the binary variables $y \in \{0,1\}^k$ that shall represent the values $g_i(x)$.
By construction, $f(x)$ is affine in $(x,y)$.
The following constraints ensure that $y_i = g_i(x)$ holds:
\begin{subequations}
\label{eq_no_good}
\begin{alignat}{7}
\sum_{j : \bar{x}_j = 0} x_j &\;+\;& \sum_{j : \bar{x}_j = 1} (1-x_j) &\;+\;& y_i &\geq 1 &\quad& \forall \bar{x} \in g_i^{-1}(1), \\
\sum_{j : \bar{x}_j = 0} x_j &\;+\;& \sum_{j : \bar{x}_j = 1} (1-x_j) &\;+\;& (1-y_i) &\geq 1 &\quad& \forall \bar{x} \in g_i^{-1}(0),
\end{alignat}
\end{subequations}
where $g^{-1}(y) \coloneqq \{ x \in \{0,1\}^n : g(x) = y \}$ denotes the pre-image of $y$.
Note that~\eqref{eq_no_good} consists of $2^n$ inequalities.
We denote by $\B$ the set of all Boolean functions.
An interesting constrained subclass is the family $\C \subseteq \B$ of functions of the form
\begin{equation}
g_{I,J}(x) \coloneqq \prod_{i \in I} x_i \cdot \prod_{j \in J} (1-x_j), \label{eq_complement_products}
\end{equation}
i.e., products of potentially complemented variables.
Even more restricted is the family $\M \subseteq \C$ of \emph{monomials}, i.e., functions $g_{I,\varnothing}$ for all $I$.
There often exist smaller and stronger formulations than~\eqref{eq_no_good}, e.g., if $g_i(x)$ does not depend on all $x$-variables.
For instance, for each function $g_{I,J} \in \C$, a perfect IP formulation is known, which is due to Fortet~\cite{Fortet60}, namely
\begin{subequations}
\label{eq_complement_linearization}
\begin{alignat}{7}
y_{I,J} &\leq x_i &\quad& \forall i \in I, \\
y_{I,J} &\leq 1-x_j &\quad& \forall j \in J, \\
1-y_{I,J} &\leq \sum_{i \in I} (1-x_i) + \sum_{j \in J} x_j, \\
y_{I,J} &\geq 0.
\end{alignat}
\end{subequations}
Here, perfect means that the convex hull of $\{ (x,g_{I,J}(x)) : x \in \{0,1\}^n \}$ is described by~\eqref{eq_complement_linearization} and $0 \leq x_i \leq 1$ for $i=1,2,\dotsc,n$.
The interplay of multiple simultaneous linearizations has been investigated by many researchers.
However, we are not aware of any research about their size.
Hence, besides establishing first results we showcase the use of alternative linearizations for an application.
Most importantly, we present open problems and interesting research questions to stimulate further research in this direction.
\paragraph{Outline.}
The paper is structured as folllows.
In \cref{sec_basic_results} we present theoretical results about the linearization complexity for various families $\G$ of Boolean functions.
\Cref{sec_auto_correlation} is about the low auto-correlation binary sequences problem, which is an optimization problem that arises in theoretical physics, and for which we present a new linearization and evaluate it computationally.
We conclude the paper with several open problems in \cref{sec_open_problems} and hope that some of them will be addressed by researchers in the future.
\section{Basic results}
\label{sec_basic_results}
\paragraph{Nonlinear part of a function.}
We first introduce an auxiliary function with the purpose of removing the linear part of a given function.
For a function $f : \{0,1\}^n \to \R$ we denote by $\widetilde{f}$ the function defined by
\[
\widetilde{f}(x) \coloneqq f(x) - f(\zerovec) + \sum_{i=1}^n \big( f(\unitvec{i}) - f(\zerovec) \big) x_i,
\]
which we call \emph{the nonlinear part of $f$}.
Here, $\zerovec$ and $\unitvec{i}$ denote the zero vector and the $i$-th standard unit vector, respectively.
The following proposition makes clear why the nonlinear portion is useful.
\begin{proposition}
\label{thm_nonlinear_part}
Let $f : \in \{0,1\}^n \to \R$.
Then its nonlinear part satisfies the following properties.
\begin{enumerate}
\item
$\widetilde{f}(\zerovec) = 0$ and $\widetilde{f}(\unitvec{i}) = 0$ holds for $i=1,2,\dotsc,n$.
\item
$\lc{\G}(\widetilde{f}) = \lc{\G}(f)$ holds for any family $\G$ of functions.
\end{enumerate}
\end{proposition}
\begin{proof}
To verify the first property it suffices to plug in the zero vector and the unit vectors.
Now observe that
$\widetilde{f} = \transpose{a}x + \beta + f(x)$ where $a_i = f(\unitvec{i}) - f(\zerovec)$ and $\beta = - f(\zerovec)$ holds.
With this in mind, the second property follows readily from the definition of linearization complexity.
\end{proof}
The result implies that we only need to analyze linearization complexities of functions $f$ with $f(\zerovec) = f(\unitvec{i}) = 0$ for $i=1,2,\dotsc,n$.
\paragraph{Linearization complexity.}
We continue with simple properties of the linearization complexity.
Our first observation is that for arbitrary $\G \subseteq \B$, $\lc{\G}(f) > 0$ indicates that $f$ is actually nonlinear over $\{0,1\}^n$.
\begin{proposition}
\label{thm_zero_affine}
For $\G \subseteq \B$, a function $f$ has $\lc{\G}(f) = 0$ if and only if $f$ is affine.
\end{proposition}
We can rephrase the result in terms of the nonlinear part of $f$ as follows. It holds $\lc{\G}(\widetilde{f}) = 0$ if and only if $\widetilde{f}$ is the zero function.
The second property is the monotonicity of $\lc{\G}(f)$ with respect to the family $\G$, which also follows from the definition.
\begin{proposition}
\label{thm_monotone}
Let $\G' \subseteq \G$ and consider $f : \{0,1\}^n \to \R$.
Then $\lc{\G'}(f) \geq \lc{\G}(f)$.
\end{proposition}
The third property is an easy upper bound.
\begin{proposition}
\label{thm_trivial_upper}
Every function $f : \{0,1\}^n \to \R$ satisfies $\lc{\M}(f) \leq 2^n - n - 1$.
\end{proposition}
\begin{proof}
Let $f : \{0,1\}^n \to \R$ and consider the polynomial
\begin{equation*}
g(x) \coloneqq \sum_{X \subseteq [n]} f(\chi(X)) \cdot \prod_{i \in X} x_i \cdot \prod_{i \notin X} (1-x_i),
\end{equation*}
where $\chi(X) \in \{0,1\}^n$ denotes the characteristic vector of $X$, defined via $\chi(X)_i = 1 \iff i \in X$.
Note that $g$ has degree at most $n$ and hence is the sum of $\transpose{a}x + \beta$ (for suitable $a \in \R^n$ and $\beta \in \R$) and at most $2^n-n-1$ monomials of degree greater than $1$.
By construction, we have $f(x) = g(x)$ for each $x \in \{0,1\}^n$.
\end{proof}
\paragraph{Random polynomials.}
Our first larger result essentially states that having a small linearization complexity is an exceptional property in a probabilistic sense.
\begin{theorem}
\label{thm_null_set}
Consider a family $\G$ of functions with $\M \subseteq \G \subseteq \B$.
Then the subset of functions $f : \{0,1\}^n \to \R$ with $\lc{\G}(f) < 2^n - n - 1$ is a null set (in the set of arbitrary functions $f : \{0,1\}^n \to \R$).
\end{theorem}
\begin{proof}
Consider a fixed number $n$ of variables and the subset $\G_n \subseteq \G$ of functions that map from $\{0,1\}^n$.
We consider the system of equations
\begin{equation}
\transpose{\bar{x}} a + \beta + \sum_{g \in G_n :\, g(\bar{x}) = 1} c_g = f(\bar{x}) \qquad \forall \bar{x} \in \{0,1\}^n \label{eq_system}
\end{equation}
in variables $a_i \in \R$ (for $i = 1,2,\dotsc,n$), $\beta \in \R$ and $c_g \in \R$ for all $g \in \G_n$.
On the one hand, every solution $(a,\beta,c)$ yields a linearization by letting $g_1,g_2,\dotsc,g_k$ be those $g \in \G_n$ for which $c_g \neq 0$ and letting $b_i \coloneqq c_{g_i}$ for $i=1,2,\dotsc,k$.
Note that its size $k$ is equal to the number of nonzero components of the $c$-vector.
On the other hand, every linearization, say with $a \in \R^n$, $\beta \in \R$, $b \in \R^k$ and $g_1,g_2,\dotsc,g_k \in \G_n$, corresponds to a solution $(a,\beta,c)$, where $c_{g_i} \coloneqq b_i$ for $i=1,2,\dotsc,k$ and $c_g \coloneqq 0$ for all $g \in \G_n \setminus \{ g_1,g_2,\dotsc,g_k \}$.
Note that by \cref{thm_trivial_upper}, every function $f$ has a solution to~\eqref{eq_system}, which implies that the system has full row rank $2^n$.
Hence, the solutions $(a, \beta, c)$ with the smallest number of nonzeros in the $c$-vector arise as solutions of a $2^n$-by-$2^n$ subsystem $D \transpose{(\transpose{a},\beta,\transpose{c})} = e$ of~\eqref{eq_system}, where $e$ contains as entries the values $f(\bar{x})$ for all $\bar{x} \in \{0,1\}^n$ and $D$ is some invertible submatrix of the coefficient matrix of~\eqref{eq_system}.
Now note that the linearization has size less than $2^n-n-1$ if and only if $D^{-1} e$ has a $0$-entry.
However, the set of right-hand side vectors $e$ having such a property is a null set (i.e., it has Lebesque-measure $0$), which concludes the proof.
\end{proof}
\begin{corollary}
\label{thm_random_polynomial}
Consider a family $\G$ of functions with $\M \subseteq \G \subseteq \B$.
A polynomial $p : \{0,1\}^n \to \R$ whose coefficients are chosen randomly according to any absolutely continuous probability distribution has $\lc{\G}(f) = 2^n - n - 1$ with probability~$1$.
\end{corollary}
\paragraph{Products of variables.}
\cref{thm_monotone} implies that the worst results for $\lc{\G}(f)$ will be obtained if the family $\G$ of functions $g$ is small.
A minimal choice that still guarantees finiteness of $\lc{\G}$ is $\G = \M$.
For this choice we characterize the linearization complexity in case a polynomial representing $f$ is known.
\begin{theorem}
Let $f : \{0,1\}^n \to \R$.
Then $\lc{\M}(f)$ is equal to the number of monomials (with a nonzero coefficient) of degree at least $2$ of a polynomial $p$ with $p(x) = f(x)$ for all $x \in \{0,1\}^n$.
\end{theorem}
\begin{proof}
First, consider $f : \{0,1\}^n \to \R$ with $\lc{\M}(f) = k$.
This means that there exist $a \in \R^n$, $\beta \in \R$, $b \in \R^k$ and sets $I_1,I_2,\dotsc,I_k \subseteq [n]$ such that $f(x) = \transpose{a}x + \beta + \sum_{\ell=1}^k b_\ell g_{I_\ell,\varnothing}(x)$ for all $x \in \{0,1\}^n$.
Now let $p(x)$ be the polynomial defined by the right-hand side of this equation (in variables $x$) and observe that it has $k$ non-linear monomials.
Second, consider $f,p : \{0,1\}^n \to \R$ with $f(x) = p(x)$ for all $x \in \{0,1\}^n$ and with $p$ being a polynomial of the form $p(x) = \transpose{a} x + \beta + \sum_{\ell=1}^k b_\ell \prod_{i \in I_\ell} x_i$.
Then $f(x) = p(x) = \transpose{a} x + \beta + \sum_{\ell=1}^k b_\ell g_{I_\ell,\varnothing}(x)$ holds for all $x \in \{0,1\}^n$ and $g_{I_\ell,\varnothing} \in \M$.
Hence, $\lc{\M}(f) \leq k$, which concludes the proof.
\end{proof}
\DeclareDocumentCommand\partialSumSet{}{\mathop{pss}}
\paragraph{Arbitrary functions.}
We already observed that $\lc{\B}(f) \leq 2^n - n - 1$ holds for any function $f : \{0,1\}^n \to \R$.
It turns out that the family $\B$ is so general that the corresponding linearization complexity only depends on the range of $\widetilde{f}$.
To make this precise, we define for a vector $w \in \R^k$ its \emph{partial sum set $\partialSumSet(w)$} as the set of partial sums $\sum_{i \in I} w_i$ over all subsets $I \subseteq \{1,2,\dotsc,k\}$.
We also allow for $k = 0$ and define $\partialSumSet(w) = \{ 0 \}$ in this case.
\begin{theorem}
\label{thm_arbitrary}
Let $f : \{0,1\}^n \to \R$ and let $Y \coloneqq \{ \widetilde{f}(x) : x \in \{0,1\}^n \}$ be the range of its nonlinear part.
Then $\lc{\B}(f)$ is equal to the smallest dimension $k$ of a vector $w \in \R^k$ with $\partialSumSet(w) \supseteq Y$.
\end{theorem}
\begin{proof}
Let $f$ and $Y$ be as in the theorem and consider a vector $w \in \R^k$ (for some $k$) with $\partialSumSet(w) \supseteq Y$.
We now construct a linearization of $f$ of size $k$.
For each $x \in \{0,1\}^n$ we have $\widetilde{f}(x) \in Y \subseteq \partialSumSet(w)$, which implies that there must be a subset $I_x \subseteq \{1,2,\dotsc,k\}$ with $\sum_{i \in I_x} w_i = \widetilde{f}(x)$.
We now define, for $i=1,2,\dotsc,k$, the function $g_i : \{0,1\}^n \to \{0,1\}$ such that
\[
g_i(x) = 1 \iff i \in I_x
\]
holds.
Moreover, we use $b \coloneqq w$ and observe
$
\sum_{i=1}^k b_i g_i(x)
= \sum_{i \in I_x}^k w_i
= \widetilde{f}(x)
$
for each $x \in \{0,1\}^n$, which establishes $\lc{\B}(\widetilde{f}) \leq k$ and by \cref{thm_nonlinear_part} also $\lc{\B}(f) \leq k$.
For the reverse direction, suppose $\lc{\B}(f) = k$.
Again by \cref{thm_nonlinear_part} there exist vectors $a \in \R^n$, $b \in \R^k$, scalar $\beta \in \R$ and functions $g_1,g_2, \dotsc, g_k : \{0,1\}^n \to \R$ such that
\[
f(x) = \transpose{a}x + \beta + \sum_{i=1}^k b_i g_i(x)
\]
holds for all $x \in \{0,1\}^n$.
For the nonlinear part we obtain
\[
\widetilde{f}(x) = \sum_{i=1}^k b_i \widetilde{g}_i(x).
\]
Now consider a $y \in Y$, i.e., the function value $y = \widetilde{f}(x)$ for some $x \in \{0,1\}^n$.
By using the set $I \coloneqq \{ i \in \{1,2,\dotsc,k\} : \widetilde{g}_i(x) = 1 \}$ we obtain that $y \in \partialSumSet(b)$ holds.
This implies $\partialSumSet(b) \supseteq Y$, and hence the choice $w \coloneqq b$ concludes the proof.
\end{proof}
The intuition behind \cref{thm_arbitrary} is the following: since there are no restrictions on the structure of the functions $g$ used, the fact that the possible arguments $x$ to $f$ are actually (binary) vectors is not relevant, i.e., one can think of just $2^n$ different inputs without any structure.
\paragraph{Example.}
Consider $f(x) = x_1x_2 + x_1x_3 + x_2x_3 -x_1x_2x_3$.
Since it is the sum of four binary (non-affine) terms it has $\lc{\C}(f) \leq \lc{\M} = 4$.
However, it turns out that $\lc{\C}(f) = 1$ holds:
consider $g_1(x) = (1-x_1) (1-x_2) (1-x_3)$ and observe that $f(x) = x_1 + x_2 + x_3 - 1 + g_1(x)$, which yields $\lc{\C}(f) \leq 1$.
Moreover, by \cref{thm_zero_affine} we have $\lc{\C}(f) \geq 1$ and hence $\lc{\C}(f) = 1$.
Clearly, this example can be extended to an arbitrary degree, showing that the $\lc{\M}(f)$ can be exponentially larger (in $n$) than $\lc{\C}(f)$.
\section{Linearizing with value indicators}
\label{sec_auto_correlation}
In this section we consider the low auto-correlation binary sequences problem, which arises in theoretical physics when studying ground states of the Bernasconi model~\cite{Bernasconi87,Golay82}.
An extension of the problem was considered in~\cite{LiersMPRS10}, which involves two parameters to specify a problem instance.
In the Bernasconi model, both parameters are equal, leading to the following formulation.
\begin{subequations}
\label{model_bernasconi}
\begin{alignat}{7}
& \text{min } ~\mathrlap{ \sum_{d=1}^{N-1} \left( \sum_{i=1}^{N-d} s_i s_{i+d} \right)^2 } \label{model_bernasconi_obj} \\
& \text{s.t. }
& s_i \in \{-1,+1\} &\quad& \forall i \in \{1,2,\dotsc,N\} \label{model_bernasconi_domain}
\end{alignat}
\end{subequations}
The state-of-the-art method for solving this problem is a highly parallelized combinatorial branch-and-bound algorithm~\cite{PackebuschM16} which builds upon earlier work~\cite{Mertens96,MertensB98}.
The optima for the problem are known for all $N \leq 66$.
In this section we investigate IP models based on binary linearizations for this problem.
To this end, let us first rephrase the problem by substituting $s_i \in \{-1,+1\}$ with $2x_i - 1$ for $x_i \in \{0,1\}$ for all $i \in \{1,2,\dotsc,N\}$.
We obtain
\begin{subequations}
\label{minlp_bernasconi}
\begin{alignat}{7}
& \text{min } ~\mathrlap{ f^{\text{bern}}_N(x) \coloneqq \sum_{d=1}^{N-1} \left( \sum_{i=1}^{N-d} (4x_ix_{i+d} - 2x_i - 2x_{i+d} + 1) \right)^2 } \label{minlp_bernasconi_obj} \\
& \text{s.t. }
& x_i \in \{0,1\} &\quad& \forall i \in \{1,2,\dotsc,N\}. \label{minlp_bernasconi_domain}
\end{alignat}
\end{subequations}
Let $f^{\text{bern}}(N)(x) = \sum_{m=1}^t a_m g_{I_m,\varnothing}(x)$ be the decomposition of $f^{\text{bern}}$ into its $t$ monomials.
With this notation, the standard IP reformulation~\eqref{eq_complement_linearization} applied to $f^{\text{bern}}_N$ reads as follows.
\begin{subequations}
\label{ip_bernasconi_standard}
\begin{alignat}{7}
& \text{min } ~\mathrlap{ \sum_{m=1}^t a_m z_{I_m} } \\
& \text{s.t. }
& z_I &\leq x_i &\quad& \forall i \in I_m,~ m =1,2,\dotsc,t \\
& & 1-z_{I_m} &\leq \sum_{i \in I_m} (1-x_i) &\quad& m=1,2,\dotsc,t \\
& & z_{I_m} &\in \{0,1\} &\quad& m=1,2,\dotsc,t \\
& & x_i &\in \{0,1\} &\quad& i=1,2,\dotsc,N
\end{alignat}
\end{subequations}
Since it has one auxiliary variable and several constraints per monomial, its size grows in a cubic fashion.
\begin{proposition}
\label{thm_labs_monomials_cubic}
For $N \geq 3$, the number of monomials of $f^{\text{bern}}(x)$ is cubic, model~\eqref{ip_bernasconi_standard} has $\orderTheta(N^3)$ variables and constraints.
\end{proposition}
\begin{proof}
The polynomial $f^{\text{bern}}(x)$ has degree~4.
Since there are at most $\orderO(N^3)$ monomials of degree at most $3$, it suffices to prove that the number of nonzero degree~4 monomials of $f^{\text{bern}}(x)$ is cubic.
Since a monomial of degree~4 arises only as a product of $x_ix_{i+d}$ and $x_{i'}x_{i'+d}$ and such terms only have positive coefficients, there are no cancellations.
Consider such a monomial, i.e., $x_px_qx_rx_s$ for $p < q < r < s$.
It occurs if and only if either $q = p + d$ and $s = r + d$ holds (where $d$ is the loop index in~\eqref{minlp_bernasconi_obj}) or $r = p + d$ and $s = q + d$.
This condition is equivalent to $p + s = q + r$.
Clearly, the number of such tuples $(p,q,r,s)$ is cubic in $N$.
\end{proof}
\paragraph{Model with value indicators.}
Proposition~\ref{thm_labs_monomials_cubic} indicates that solving the problem as an IP seems to be hopeless because of its shear size.
However, the next theorem suggests that one can do better:
\begin{theorem}
\label{thm_bernasconi_lc}
For $N \geq 3$ we have $\lc{\B}(f^{\text{bern}}_N) \leq \orderO(N^2)$.
\end{theorem}
\begin{proof}
We define the set $L_d \coloneqq \left\{ \sum\limits_{i=1}^{N-d} s_i s_{i+d} \right\}$ of distinct function values of the inner sum.
Since $s_i \cdot s_{i+d} \in \{-1,+1\}$ holds, we have
$$L_d \leq \{ -(N-d), -(N-d) + 2, \dotsc, (N-d)-2, (N-d) \}.$$
We obtain $|L_d| \leq N-d+1$ for all $d \in \{1,2,\dotsc,N-1\}$.
Now we consider, for each $d \in \{1,2,\dotsc,N-1\}$ and each $\ell \in L_d$, the function $g_{d,\ell} : \{0,1\}^N \to \{0,1\}$ that indicates whether the inner sum for some $d$ is equal to $\ell$.
More precisely, it shall satisfy $g_{d,\ell}(x) = 1$ if and only if $\sum\limits_{i=1}^{N-d} (2x_i-1)(2x_{i+d}-1) = \ell$.
Since for each $d$ and each $x \in \{0,1\}^n$, precisely one of the functions $g_{d,\ell}(x)$ is equal to $1$, we obtain
$$f^{\text{bern}}_N(x) = \sum_{d=1}^{N-1} \sum_{\ell \in L_d} \ell^2 g_{d,\ell}(x).$$
Since these are only $\orderO(N^2)$ pairs $(d,\ell)$ to consider, the result follows.
\end{proof}
We immediately obtain the existence of an IP formulation with only $\orderO(N^2)$ variables, but without a polynomial bound on the number of constraints.
However, using more auxiliary variables (in addition to those for each $g_{d,\ell}$), one can construct one with a quadratic number of variables and constraints.
We denote the corresponding family of linearization functions (that indicate whether an expression attains a certain value or not) by $\V$.
The idea is to introduce variables $y_{i,j}$ that indicate for all $i,j$ (with $i \neq j$) whether the product $s_i s_j$ is $+1$ or $-1$.
\begin{subequations}
\label{ip_indicators}
\begin{alignat}{7}
& \text{min } ~\mathrlap{\sum_{d=1}^{N-1} \sum_{\ell \in L_d} \ell^2 z_d^\ell } \label{ip_indicators_obj} \\
& \text{s.t. }
& x_i + x_j &\geq 1 - y_{i,j} &\quad& \forall i,j \in \{1,2,\dotsc,N\} : i < j \label{ip_indicators_quad1} \\
& & x_i - x_j &\geq y_{i,j} - 1 &\quad& \forall i,j \in \{1,2,\dotsc,N\} : i < j \label{ip_indicators_quad2}\\
& & -x_i + x_j &\geq y_{i,j} - 1 &\quad& \forall i,j \in \{1,2,\dotsc,N\} : i < j \label{ip_indicators_quad3}\\
& & x_i + x_j &\leq y_{i,j} + 1 &\quad& \forall i,j \in \{1,2,\dotsc,N\} : i < j \label{ip_indicators_quad4}\\
& & \sum_{\ell \in L_d} z_{d,\ell} &=1 &\quad& \forall d \in \{1,2,\dotsc,N-1\} \label{ip_indicators_convexity} \\
& & \sum_{i=1}^{N-d} (2y_{i,i+d}-1) &=\sum_{\ell \in L_d} \ell z_{d,\ell} &\quad& \forall d \in \{1,2,\dotsc,N-1\} \label{ip_indicators_indicate} \\
& & x_i &\in \{0,1\} &\quad& \forall i \in \{1,2,\dotsc,N\} \label{ip_indicators_domain_x}\\
& & y_{i,j} &\in \{0,1\} &\quad& \forall i,j \in \{1,2,\dotsc,N\} : i < j \label{ip_indicators_domain_y}\\
& & z_{d,\ell} &\in \{0,1\} &\quad& \forall d \in \{1,2,\dotsc,N-1\},~ \forall \ell \in L_d \label{ip_indicators_domain_z}
\end{alignat}
\end{subequations}
\begin{corollary}
\label{thm_indicators_ip}
For $N \geq 3$, the integer program~\eqref{ip_indicators} correctly models the low auto-correlation binary sequences problem~\eqref{model_bernasconi} and has $\orderO(N^2)$ variables and constraints.
\end{corollary}
\begin{proof}
Similar to~\eqref{minlp_bernasconi} we model $s_i \in \{-1,+1\}$ by $s_i = 2x_i - 1$, i.e., $x_i = 1$ if and only if $s_i = 1$.
Constraints~\eqref{ip_indicators_quad1}--\eqref{ip_indicators_quad4} enforces that $2y_{i,j} - 1 = s_i \cdot s_j = (2x_i-1)(2x_j-1)$ holds, i.e., $y_{i,j} = 1$ if and only if $x_i = x_j$ holds.
For each $d \in \{1,2,\dotsc,N-1\}$, equation~\eqref{ip_indicators_convexity} implies that $z_{d,\ell} = 1$ holds for exactly one $\ell \in L_d$.
Since the left-hand side of~\eqref{ip_indicators_indicate} is equal to the inner sum of~\eqref{model_bernasconi_obj}.
Hence, the right-hand side of~\eqref{ip_indicators_indicate} is the corresponding $\ell \in L_d$.
This implies that the contribution of all $z_{d,\ell}$ for some $d \in \{1,2,\dotsc,N-1\}$ to the objective~\eqref{ip_indicators_obj} is equal to $\ell^2$, where $\ell$ is the value of the inner sum of~\eqref{model_bernasconi_obj}.
We conclude that~\eqref{model_bernasconi_obj} is indeed equal to $f^{\text{bern}}_N(x)$.
\end{proof}
\paragraph{Experimental evaluation.}
The numbers of variables and constraints are only one factor that has impact on the solution time of an IP.
For instance, the quality of the dual (in our case lower) bounds on the optimum and the ability to find good primal solutions is extremely important.
Hence, we compare the new IP model~\eqref{ip_indicators} to the standard formulation~\eqref{ip_bernasconi_standard}.
We tried to solve the low auto-correlation binary sequences problem with both models using the SCIP solver framework~\cite{SCIP8}\footnote{The code for generating the instances can be found at \href{https://github.com/discopt/multilinear-instance-generators}{github.com/discopt/multilinear-instance-generators}.}.
Note that both approaches are too slow to compete with the most recent state-of-the-art approach that is based on combinatorial branch-and-bound with which the problem could be solved to optimality up to $N = 66$~\cite{PackebuschM16}.
More precisely, we only report about instances that can be solved by at least one of the models to optimality within \SI{1}{\hour} using version~8.0.2 of SCIP using SoPlex as an LP solver.
Also note that we ran our experiments only on a single core (with an Intel CPU on \SI{2.1}{\giga\hertz}) while the computations for $N=66$ were done using 248 cores and took about 55 days~\cite{PackebuschM16}.
Moreover, we strengthened none of the two models to keep the comparison fair.
\cref{table_bernasconi_ips} shows our results.
Note that for $N > 22$, SCIP could not solve the standard formulation~\eqref{ip_bernasconi_standard} within one hour.
In fact, the lower bound obtained after that time was still a negative number.
Note that by construction, model~\eqref{ip_indicators} only provides positive bounds.
We conclude that our new formulation outperforms the standard formulation, not only by means of size, but also by means of quality of the bound obtained from the LP relaxation.
\DeclareDocumentCommand\timelimit{}{\faClockO}
\begin{table}[htpb]
\caption{%
Comparison of IP models~\eqref{ip_bernasconi_standard} and~\eqref{ip_indicators}.
For each model, the number of variables and constraints, the number of solved branch-and-bound nodes as well as the total solution time are reported.
The symbol \faClockO{} indicates that the computation reached the timeout of \SI{3600}{\second}.
}
\label{table_bernasconi_ips}
\begin{center}
\begin{tabular}{r|rrrr|rrrr}
& \multicolumn{4}{c|}{\textbf{Standard IP~(\ref{ip_bernasconi_standard})}} & \multicolumn{4}{c}{\textbf{Value indicator IP~(\ref{ip_indicators})}} \\
\textbf{N}
& \textbf{Vars} & \textbf{Constrs} & \textbf{Nodes} & \textbf{Time}
& \textbf{Vars} & \textbf{Constrs} & \textbf{Nodes} & \textbf{Time} \\
\hline
3
& 5 & 4 & 0 & \SI{0.01}{\second}
& 17 & 16 & 1 & \SI{0.0}{\second} \\
4
& 16 & 40 & 1 & \SI{0.03}{\second}
& 31 & 30 & 1 & \SI{0.01}{\second} \\
5
& 28 & 82 & 1 & \SI{0.04}{\second}
& 49 & 48 & 1 & \SI{0.01}{\second} \\
6
& 47 & 153 & 5 & \SI{0.12}{\second}
& 71 & 70 & 1 & \SI{0.04}{\second} \\
7
& 75 & 261 & 23 & \SI{0.31}{\second}
& 97 & 96 & 1 & \SI{0.06}{\second} \\
8
& 113 & 411 & 35 & \SI{0.43}{\second}
& 127 & 126 & 1 & \SI{0.08}{\second} \\
9
& 160 & 599 & 89 & \SI{0.81}{\second}
& 161 & 160 & 1 & \SI{0.22}{\second} \\
10
& 222 & 850 & 191 & \SI{1.59}{\second}
& 199 & 198 & 19 & \SI{0.27}{\second} \\
11
& 297 & 1156 & 425 & \SI{2.79}{\second}
& 241 & 240 & 1 & \SI{0.42}{\second} \\
12
& 388 & 1530 & 881 & \SI{5.63}{\second}
& 287 & 286 & 70 & \SI{0.98}{\second} \\
13
& 496 & 1976 & 1622 & \SI{14.73}{\second}
& 337 & 336 & 4 & \SI{0.35}{\second} \\
14
& 623 & 2503 & 2173 & \SI{30.88}{\second}
& 391 & 390 & 732 & \SI{5.01}{\second} \\
15
& 769 & 3111 & \SI{4049}{} & \SI{72.4}{\second}
& 449 & 448 & \SI{1113}{} & \SI{4.35}{\second} \\
16
& 939 & 3821 & \SI{9372}{} & \SI{152.62}{\second}
& 511 & 510 & \SI{1452}{} & \SI{10.45}{\second} \\
17
& 1130 & 4621 & \SI{19265}{} & \SI{317.73}{\second}
& 577 & 576 & \SI{5551}{} & \SI{36.73}{\second} \\
18
& 1346 & 5528 & \SI{41235}{} & \SI{565.69}{\second}
& 647 & 646 & \SI{12379}{} & \SI{54.87}{\second} \\
19
& 1589 & 6550 & \SI{92657}{} & \SI{1042.12}{\second}
& 721 & 720 & \SI{14396}{} & \SI{64.73}{\second} \\
20
& 1860 & 7692 & \SI{206383}{} & \SI{1964.38}{\second}
& 799 & 798 & \SI{9751}{} & \SI{58.45}{\second} \\
21
& 2158 & 8950 & -- & \timelimit{}
& 881 & 880 & \SI{22949}{} & \SI{122.93}{\second} \\
22
& 2489 & \SI{10349}{} & -- & \timelimit{}
& 967 & 966 & \SI{41491}{} & \SI{202.87}{\second} \\
23
& 2851 & \SI{11881}{} & -- & \timelimit{}
& 1057 & 1056 & \SI{106590}{} & \SI{415.89}{\second} \\
24
& 3247 & \SI{13559}{} & -- & \timelimit{}
& 1151 & 1150 & \SI{115220}{} & \SI{445.95}{\second} \\
25
& 3678 & \SI{15387}{} & -- & \timelimit{}
& 1249 & 1248 & \SI{88708}{} & \SI{414.45}{\second} \\
26
& 4146 & \SI{17374}{} & -- & \timelimit{}
& 1351 & 1350 & \SI{386737}{} & \SI{1716.33}{\second} \\
27
& 4651 & \SI{19520}{} & -- & \timelimit{}
& 1457 & 1456 & \SI{266951}{} & \SI{1412.36}{\second} \\
28
& 5198 & \SI{21846}{} & -- & \timelimit{}
& 1567 & 1566 & \SI{611390}{} & \SI{3078.0}{\second} \\
29
& 5784 & \SI{24340}{} & -- & \timelimit{}
& 1681 & 1680 & -- & \timelimit{}
\end{tabular}
\end{center}
\end{table}
Our results show that a monomial-wise IP is not necessarily the best modeling approach to tackle a binary polynomial optimization problem.
We also tried to determine a small formulation for problem~\eqref{model_bernasconi} for $\G = \C$, i.e., for the family of potentially complemented products of variables.
To this end, system~\eqref{eq_system} can be augmented by binary variables to indicate whether a $g \in \G$ is used (that is, has a nonzero multiplier).
The minimization of the sum of these binary variables yields $\lc{\G}(f)$.
Clearly, this approach only works for small sizes $|\G|$.
Our results for $N \in \{3,4,5,6\}$ were quite disappointing -- at least when considering only functions $g \in \C$ of degree at most $5$, the linearization complexity is minimized by the linearization that just uses monomials.
Hence, we do not expect that one can gain much by allowing complements of variables for the low auto-correlation problem.
\section{Open Problems}
\label{sec_open_problems}
We hope to have convinced the reader that the linearization complexity is a useful concept.
Nevertheless, many unsolved problems remain, and we use the rest of the paper to present them.
\paragraph{More families.}
We discussed various families of functions $g$ to use for linearization, namely the products of variables $\M$, the potentially complemented products of variables $\C$, arbitrary Boolean functions $\B$, and finally value indicator functions $\V$.
We believe that there are more such interesting families.
\paragraph{Formulations.}
Perfect formulations are known for the first two considered linearizations when considering every linearization variables separately.
Strengthening the joint formulation for multiple linearization variables from $\C$ is subject of current research, e.g., by means of studying multilinear polytopes~\cite{BuchheimCR19,CramaR17,DelPiaD21,DelPiaK17,DelPiaK18,DelPiaK18a,DelPiaK21,DelPiaW22,Rodriguez-Heck18}.
For $\B$ we cannot hope to identify perfect formulations since this encompasses arbitrary binary sets.
However, for other functions it is interesting to investigate which inequalities are best to add in order to apply such a function.
For instance, our model~\eqref{ip_indicators} worked well because we did not model the meaning of each $z$-variable individually, but because we considered multiple of them in a combined fashion in constraints~\eqref{ip_indicators_convexity} and~\eqref{ip_indicators_indicate}.
\paragraph{Bounding techniques.}
While we could interpret the linearization complexities for $\M$ and for $\B$, little is known about $\C$ and $\V$.
The first natural question is which properties of a polynomial allow to recast it as a sum of only few products of potentially complemented variables.
\paragraph{Algorithmic questions.}
After settling how $f$ could be encoded (expressing it as a polynomial is only one possibility), there are many algorithmic problems related to linearization complexity.
Most importantly, the complexity of the computation or approximation of $\lc{\C}(f)$ or of $\lc{\B}(f)$ is open.
For practical purposes it would be very interesting to find small linearizations based on $\C$ because the actual formulations are essentially the same as those for $\M$ which are reasonably well understood.
\paragraph{Approximations.}
While \cref{thm_null_set} and \cref{thm_random_polynomial} indicate that linearizations with small linearization complexity are rare, one may still consider approximate linearizations, i.e., small linearizations of a function $f'$ that is very close to $f$.
Instead of abandoning exactness one can also try to pursue a related approach by finding a linearization that may not be small but for which only few of the weights $b_i$ in~\eqref{eq_linearization} are large (in absolute value).
While the resulting IP formulation would still have many variables, one could apply strengthening techniques only on those few linearizations that are most important for the value of $f$.
Then, relaxation errors for the remaining variables (with small $|b_i|$) will not have a big impact on the overall objective value, which would yield better bounds.
\bibliographystyle{plainurl}
| {'timestamp': '2023-01-18T02:15:42', 'yymm': '2301', 'arxiv_id': '2301.06207', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06207'} | arxiv |
\section*{Checklist}
\begin{enumerate}
\item For all authors...
\begin{enumerate}
\item Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope?
\answerYes{}
\item Did you describe the limitations of your work?
\answerYes{}
\item Did you discuss any potential negative societal impacts of your work?
\answerNA{}
\item Have you read the ethics review guidelines and ensured that your paper conforms to them?
\answerYes{}
\end{enumerate}
\item If you are including theoretical results...
\begin{enumerate}
\item Did you state the full set of assumptions of all theoretical results?
\answerYes{}
\item Did you include complete proofs of all theoretical results?
\answerYes{}
\end{enumerate}
\item If you ran experiments...
\begin{enumerate}
\item Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
\answerYes{}
\item Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
\answerYes{}
\item Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
\answerYes{}
\item Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?
\answerNo{}
\end{enumerate}
\item If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
\begin{enumerate}
\item If your work uses existing assets, did you cite the creators?
\answerYes{}
\item Did you mention the license of the assets?
\answerNA{}
\item Did you include any new assets either in the supplemental material or as a URL?
\answerNA{}
\item Did you discuss whether and how consent was obtained from people whose data you're using/curating?
\answerNA{}
\item Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?
\answerNA{}
\end{enumerate}
\item If you used crowdsourcing or conducted research with human subjects...
\begin{enumerate}
\item Did you include the full text of instructions given to participants and screenshots, if applicable?
\answerNA{}
\item Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?
\answerNA{}
\item Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
\answerNA{}
\end{enumerate}
\end{enumerate}
\clearpage
\section{Proofs of Theorem \ref{thm:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction} and Corollary \ref{cor:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction}}
\label{sec:proofs-for-section-2}
Note that Theorem \ref{thm:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction} implies Theorem \ref{thm:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction} and Corollary \ref{cor:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction} implies Corollary \ref{cor:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction} by letting $K = 1$. Therefore, it is sufficient to prove Theorem \ref{thm:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction} and Corollary \ref{cor:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}, whose proofs can be found in Appendix \ref{sec:proof-thm-3.1} and \ref{sec:proof-cor-3.2} respectively. \hfill $\square$
\section{Proof of Theorem \ref{thm:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}}
\label{sec:proof-thm-3.1}
Consider a stochastic optimization problem with $K$ expected value constraints
\begin{equation*}\label{eq:problem-population}
(\mathcal{P}_0):\quad\theta^\star \in {\arg\min}_{\theta \in \Theta} \left\{ \mathbb{E}_{Z\sim P_0} \left[f(\theta; Z)\right]: \mathbb{E}_{Z\sim P_0} \left[g_k(\theta; Z)\right]\leq 0, k\in[K]\right\}.
\end{equation*}
Our proposed robust constraint method solves
\begin{equation*}\label{eq:problem-dro}
(\mathcal{P}_n):\quad\widehat{\theta}_{n,{\boldsymbol\rho}} \in {\arg\min}_{\theta \in \Theta} \left\{ \mathbb{E}_{Z\sim P_n} \left[f(\theta; Z)\right]: \sup_{D_\varphi (Q\|P_n)\leq \rho_k/n} \mathbb{E}_{Z\sim Q} \left[g_k(\theta; Z)\right]\leq 0, k\in[K]\right\},
\end{equation*}
where ${\boldsymbol\rho} = (\rho_1,\ldots,\rho_K)^\top$ is the collection of critical radii of uncertainty sets. Here we denote the empirical distribution $\widehat{P}_n$ by $P_n$ for notation simplicity.
As a special case of our robust method, the sample average approximation (SAA) or empirical risk minimization (ERM) solves
\begin{equation*}\label{eq:problem-saa}
\widehat{\theta}_{n,\boldsymbol{0}_K} \in {\arg\min}_{\theta \in \Theta} \left\{ \mathbb{E}_{Z\sim P_n} \left[f(\theta; Z)\right]: \mathbb{E}_{Z\sim P_n} \left[g_k(\theta; Z)\right]\leq 0, k\in[K]\right\}.
\end{equation*}
We denote
\begin{equation*}
F(\theta) = \mathbb{E}_{Z\sim P_0} \left[f(\theta; Z)\right]\quad\text{and}\quad \widehat{F}_n(\theta) = \mathbb{E}_{Z\sim P_n} \left[f(\theta; Z)\right],
\end{equation*}
\begin{equation*}
G_k(\theta) = \mathbb{E}_{Z\sim P_n} \left[g_k(\theta; Z)\right]\quad\text{and}\quad \widehat{G}_{kn}(\theta) = \sup_{D_\varphi (Q\|P_n)\leq \rho_k/n} \mathbb{E}_{Z\sim Q} \left[g_k(\theta; Z)\right]\quad\text{for}\quad k\in[K],
\end{equation*}
and
\begin{equation*}
\boldsymbol{G}(\theta) = \left(\begin{array}{c}
G_1(\theta) \\
\vdots \\
G_K(\theta)
\end{array}\right)\quad\text{and}\quad
\widehat{\boldsymbol{G}}_n(\theta) = \left(\begin{array}{c}
\widehat{G}_{1n}(\theta) \\
\vdots \\
\widehat{G}_{Kn}(\theta)
\end{array}\right).
\end{equation*}
Note that $\widehat{F}_n(\cdot)$ and $\widehat{G}_{kn}(\cdot)$'s are random functions serving as approximations to $F(\cdot)$ and $G_k(\cdot)$'s. Consider the Lagrangian functions
\begin{equation*}
L(\theta, {\boldsymbol\lambda}) = F(\theta) + {\boldsymbol\lambda}^\top \boldsymbol{G}(\theta) = F(\theta) + \sum_{k=1}^K \lambda_k G_k(\theta)
\end{equation*}
and
\begin{equation*}
\widehat{L}_n(\theta, {\boldsymbol\lambda}) = \widehat{F}_n(\theta) + {\boldsymbol\lambda}^\top \widehat{\boldsymbol{G}}_n(\theta) = \widehat{F}_n(\theta) + \sum_{k=1}^K \lambda_k \widehat{G}_{kn}(\theta)
\end{equation*}
of the programs $(\mathcal{P}_0)$ and $(\mathcal{P}_n)$ respectively.
\begin{lemma}[Theorem 6.6.2 in \cite{rubinstein1993discrete}]\label{thm:RS-6.6.2}
Suppose that:
\begin{enumerate}[label=(\roman*)]
\item The functions $F(\theta)$ and $G_k(\theta)$, $k\in[K]$, are twice continuously differentiable.
\item The true program $(\mathcal{P}_0)$ has a unique optimal solution $\theta^\star$ and a unique vector ${\boldsymbol\lambda}^\star$ of the Lagrange multipliers with $\theta^\star$ being an interior point of $\Theta$.
\item The Hessian matrix $\nabla^2 L(\theta^\star, {\boldsymbol\lambda}^\star)$ is positive definite.
\item The random functions $\widehat{G}_{kn}(\theta)$,$k\in[K]$, are Lipschitz continuous in a neighborhood of $\theta^\star$ and differentiable at $\theta^\star$ with probability 1.
\item \begin{equation*}
\|\Delta_{in}(\theta^\star)\|_2 = O_p(n^{-1/2}),\quad i = 1,2,3
\end{equation*}
and there is a neighborhood $U$ of $\theta^\star$ such that
\begin{equation*}
\sup_{\theta\in U} \frac{\|\Delta_{in}(\theta) - \Delta_{in}(\theta^\star)\|_2}{n^{-1/2} + \|\theta - \theta^\star\|_2} = o_p(1),\quad i = 1,2,3.
\end{equation*}
Here we define random mappings $\Delta_{1n}(\theta) = \nabla \widehat{F}_n(\theta) - \nabla F(\theta)$, $\Delta_{2n}(\theta) = \widehat{\boldsymbol{G}}_n(\theta) - \boldsymbol{G}(\theta)$, and $\Delta_{3n}(\theta) = \nabla \widehat{\boldsymbol{G}}_n(\theta) - \nabla \boldsymbol{G}(\theta)$.
\item Random vectors $\sqrt{n}(\nabla \widehat{L}_n(\theta^\star, {\boldsymbol\lambda}^\star), \widehat{\boldsymbol{G}}_n(\theta^\star))$ converge in distribution as $n\to\infty$ to a random vector $\boldsymbol{Y} = (\boldsymbol{Y}_1, \boldsymbol{Y}_2)$.
\end{enumerate}
Let $\widehat{\theta}_n$ be an optimal solution of $(\mathcal{P}_n)$ converging in probability as $n\to\infty$ to $\theta^\star$. Then
\begin{equation*}
\sqrt{n}(\widehat{\theta}_n - \theta^\star) \overset{d}{\longrightarrow} \bar{\boldsymbol{x}}(\boldsymbol{Y})
\end{equation*}
where $\bar{\boldsymbol{x}} = \bar{\boldsymbol{x}}(\boldsymbol{Y})$ is the optimal solution to the quadratic programming problem
\begin{equation*}
\begin{array}{ll}
\underset{\boldsymbol{x}}{\operatorname{minimize}} & \boldsymbol{x}^\top \boldsymbol{Y}_1 + \frac{1}{2} \boldsymbol{x}^\top \nabla^2 L(\theta^\star, {\boldsymbol\lambda}^\star) \boldsymbol{x} \\
\operatorname{subject~to} & \nabla \boldsymbol{G}(\theta^\star)^\top \boldsymbol{x} + \boldsymbol{Y}_2 = \boldsymbol{0}
\end{array}.
\end{equation*}
\end{lemma}
From now on, we use $\varphi(t) = (t-1)^2$, which gives the $\chi^2$-divergence. Lemma \ref{thm:RS-6.6.2} is adapted from Theorem 6.6.2 in \cite{rubinstein1993discrete} under the strict complementarity assumption. Recall the standing assumptions, \emph{(i)}, \emph{(iv)}, \emph{(v)} are guaranteed by the smoothness and concentration assumption, \emph{(ii)} is postulated by the uniqueness assumption, and \emph{(iii)} is ensured by the positive definiteness assumption. Now we derive the limiting distribution required in \emph{(vi)}.
Let $\mathbb{B}$ denote the $\ell_2$-ball of radius $1$ in $\mathbb{R}^d$. According to Lemma 24 in \cite{duchi2016Variancebased}, for each $k\in[K]$ there exists $\epsilon_k > 0$ such that, with probability 1, there exists an $N_k$ such that $n\geq N_k$ implies
\begin{equation*}
\widehat{G}_{kn}(\theta) = \mathbb{E}_{P_n}[g_k(\theta; Z)] + \sqrt{\frac{\rho_k \operatorname{Var}_{P_n}[g_k(\theta;Z)]}{n}}~\text{for all}~\theta \in \theta^\star + \epsilon_k \mathbb{B}.
\end{equation*}
Taking $\epsilon_0 = \min\{\epsilon_k:k\in[K]\}$ and $N_0 = \max\{N_k:k\in[K]\}$, we have the following uniform expansion holds, that is,
\begin{equation*}
\widehat{G}_{kn}(\theta) = \mathbb{E}_{P_n}[g_k(\theta; Z)] + \sqrt{\frac{\rho_k}{n}\operatorname{Var}_{P_n}[g_k(\theta;Z)]}~\text{for all}~k\in[K]~\text{and}~\theta \in \theta^\star + \epsilon_0 \mathbb{B}
\end{equation*}
$P_0$-almost surely given $n\geq N_0$.
Therefore, for sufficiently large $n$, for $k \in [K]$ we have
\begin{align*}
\widehat{G}_{kn}(\theta^\star) &= \mathbb{E}_{P_n}[g_k(\theta^\star; Z)] + \sqrt{\frac{\rho_k}{n}\operatorname{Var}_{P_n}[g_k(\theta;Z)]}\\
&= \mathbb{E}_{P}[g_k(\theta^\star; Z)] + \{\mathbb{E}_{P_n}[g_k(\theta^\star; Z)] - \mathbb{E}_{P_0}[g_k(\theta^\star; Z)]\} + \sqrt{\frac{\rho_k}{n}\left(\operatorname{Var}_{P_0}[g_k(\theta^\star;Z)]+ o_P(1)\right)} \\
&= G_k(\theta^\star) + \{\mathbb{E}_{P_n}[g_k(\theta^\star; Z)] - \mathbb{E}_{P_0}[g_k(\theta^\star; Z)]\} + \sqrt{\frac{\rho_k}{n}\operatorname{Var}_{P_0}[g_k(\theta^\star;Z)]} + o_P(n^{-1/2})
\end{align*}
and
\begin{align*}
\nabla \widehat{G}_{kn}(\theta^\star) =& \mathbb{E}_{P_n}[\nabla g_k(\theta^\star; Z)] + \nabla \sqrt{\frac{\rho_k}{n}\operatorname{Var}_{P_n}[g_k(\theta;Z)]}\\
=& \mathbb{E}_{P}[\nabla g_k(\theta^\star; Z)] + \{\mathbb{E}_{P_n}[\nabla g_k(\theta^\star; Z)] - \mathbb{E}_{P_0}[\nabla g_k(\theta^\star; Z)]\} + \\
&\sqrt{\frac{\rho_k}{n}} \frac{\mathbb{E}_{P_n}[\left(\nabla g_k(\theta^\star, X)-\mathbb{E}_{P_n}[\nabla g_k(\theta^\star;Z)]\right)\left(g_k(\theta^\star;Z)-\mathbb{E}_{P_n}[g_k(\theta^\star;Z)]\right)]}{\sqrt{\operatorname{Var}_{P_n}[g_k(\theta^\star;Z)]}}\\
=& \nabla \mathbb{E}_{P_0}[g_k(\theta^\star; Z)] + \{\mathbb{E}_{P_n}[\nabla g_k(\theta^\star; Z)] - \mathbb{E}_{P_0}[\nabla g_k(\theta^\star; Z)]\} + \\
&\sqrt{\frac{\rho_k}{n}}\left(\frac{\operatorname{Cov}_{P_0}(\nabla g_k(\theta^\star;Z), g_k(\theta^\star;Z))}{\sqrt{\operatorname{Var}_{P_0}[g_k(\theta^\star;Z)]}} + o_P(1)\right) \\
=& \nabla G_k(\theta^\star) + \{\mathbb{E}_{P_n}[\nabla g_k(\theta^\star; Z)] - \mathbb{E}_{P_0}[\nabla g_k(\theta^\star; Z)]\} +\\
&\sqrt{\frac{\rho_k}{n}} \frac{\operatorname{Cov}_{P_0}(\nabla g_k(\theta^\star;Z), g_k(\theta^\star;Z))}{\sqrt{\operatorname{Var}_{P_0}[g_k(\theta^\star;Z)]}} + o_P(n^{-1/2}).
\end{align*}
For the objective function and its empirical counterpart, we have
\begin{equation*}
\widehat{F}(\theta^\star) = \mathbb{E}_{P_n}[f(\theta^\star; Z)] = F(\theta^\star) + \{\mathbb{E}_{P_n}[f(\theta^\star; Z)] - \mathbb{E}_{P_0}[f(\theta^\star; Z)]\}
\end{equation*}
and
\begin{equation*}
\nabla\widehat{F}(\theta^\star) = \mathbb{E}_{P_n}[\nabla f(\theta^\star; Z)] = \nabla F(\theta^\star) + \{\mathbb{E}_{P_n}[\nabla f(\theta^\star; Z)] - \mathbb{E}_{P_0}[\nabla f(\theta^\star; Z)]\}.
\end{equation*}
Now we derive the the limiting distribution of random vectors $\sqrt{n}(\nabla \widehat{L}_n(\theta^\star, {\boldsymbol\lambda}^\star), \widehat{\boldsymbol{G}}_n(\theta^\star))$. For simplicity of notations, we denote $P_n m = \mathbb{E}_{P_n} [m (\theta^\star;Z)]$ and $P_0 m = \mathbb{E}_{P_0} [m(\theta^\star;Z)]$ for any random function $m(\theta; Z)$, $ \operatorname{Cov}(\nabla g_k, g_k) = \operatorname{Cov}_{P_0}(\nabla g_k(\theta^\star;Z), g_k(\theta^\star;Z))$ and $\operatorname{Var}[g_k] = \operatorname{Var}_{P_0}[g_k(\theta^\star;Z)]$. Then we have
\begin{align*}
&\begin{bmatrix}
\nabla \widehat{L}_n(\theta^\star, {\boldsymbol\lambda}^\star)\\
\widehat{\boldsymbol{G}}_n(\theta^\star)
\end{bmatrix} \\
=& \begin{bmatrix}
\nabla\widehat{F}_n(\theta^\star) + \sum_{k=1}^K \lambda_k^\star \nabla\widehat{G}_{kn}(\theta^\star)\\
\vdots \\
\widehat{G}_{kn}(\theta^\star) \\
\vdots
\end{bmatrix} \\
=& \begin{bmatrix}
\underbrace{\nabla F(\theta^\star) + \sum_{k=1}^K \lambda_k^\star \nabla G_{k}(\theta^\star)}_{=0~\text{due to KKT condition}} + (P_n\nabla f - P_0\nabla f) + \sum_{k=1}^K \lambda_k^\star (P_n\nabla g_k - P_0\nabla g_k) + \frac{1}{\sqrt{n}}\sum_{k=1}^K \frac{\lambda_k^\star \sqrt{\rho_k}\operatorname{Cov}(\nabla g_k, g_k)}{\sqrt{\operatorname{Var}[g_k]}} \\
\vdots \\
\underbrace{G_k(\theta^\star)}_{=0~\text{due to active constraint}} + (P_n g_k - P_0 g_k) + \sqrt{\frac{\rho_k}{n}\operatorname{Var}[g_k]}\\
\vdots
\end{bmatrix} \\
&+ o_P\left(\frac{1}{\sqrt{n}}\right) \\
=& \frac{1}{\sqrt{n}} \begin{bmatrix}
\sum_{k=1}^K \frac{\lambda_k^\star \sqrt{\rho_k}\operatorname{Cov}(\nabla g_k, g_k)}{\sqrt{\operatorname{Var}[g_k]}} \\
\vdots \\
\sqrt{\rho_k \operatorname{Var}[g_k]}\\
\vdots
\end{bmatrix} + \left\{P_n\begin{bmatrix}
\nabla f + \sum_{k=1}^K \lambda_k^\star \nabla g_k \\
\vdots \\
g_k\\
\vdots
\end{bmatrix} - P_0\begin{bmatrix}
\nabla f + \sum_{k=1}^K \lambda_k^\star \nabla g_k \\
\vdots \\
g_k\\
\vdots
\end{bmatrix}\right\} + o_P\left(\frac{1}{\sqrt{n}}\right).
\end{align*}
By central limit theorem,
\begin{equation*}
\sqrt{n}\left\{P_n\begin{bmatrix}
\nabla f + \sum_{k=1}^K \lambda_k^\star \nabla g_k \\
\vdots \\
g_k\\
\vdots
\end{bmatrix} - P_0\begin{bmatrix}
\nabla f + \sum_{k=1}^K \lambda_k^\star \nabla g_k \\
\vdots \\
g_k\\
\vdots
\end{bmatrix}\right\} \overset{d}{\longrightarrow} \mathcal{N}\left(\boldsymbol{0}, \begin{bmatrix}
\Sigma_{11} & \Sigma_{12} \\
\Sigma_{21} & \Sigma_{22}
\end{bmatrix}\right),
\end{equation*}
where
\begin{align*}
\Sigma_{11} &= \operatorname{Var}_{P_0}\left[\nabla f(\theta^\star;Z) + \sum_{k=1}^K \lambda_k^\star \nabla g_k(\theta^\star;Z)\right] \in \mathbb{R}^{d\times d}, \\
\Sigma_{12} &= \operatorname{Cov}_{P_0}\left(\nabla f(\theta^\star;Z) + \sum_{k=1}^K \lambda_k^\star \nabla g_k(\theta^\star;Z), \boldsymbol{G}(\theta^\star;Z)\right) \in \mathbb{R}^{d\times K}, \\
\Sigma_{21} &= \Sigma_{12}^\top, \\
\Sigma_{22} &= \operatorname{Var}_{P_0} [\boldsymbol{G}(\theta^\star;Z)] \in \mathbb{R}^{K \times K}.
\end{align*}
By Slutsky's theorem,
\begin{align*}
&\sqrt{n} \begin{bmatrix}
\nabla \widehat{L}_n(\theta^\star, {\boldsymbol\lambda}^\star)\\
\widehat{\boldsymbol{G}}_n(\theta^\star)
\end{bmatrix} \\
=& \begin{bmatrix}
\sum_{k=1}^K \frac{\lambda_k^\star \sqrt{\rho_k}\operatorname{Cov}(\nabla g_k, g_k)}{\sqrt{\operatorname{Var}[g_k]}} \\
\vdots \\
\sqrt{\rho_k \operatorname{Var}[g_k]}\\
\vdots
\end{bmatrix} + \sqrt{n}\left\{P_n\begin{bmatrix}
\nabla f + \sum_{k=1}^K \lambda_k^\star \nabla g_k \\
\vdots \\
g_k\\
\vdots
\end{bmatrix} - P_0\begin{bmatrix}
\nabla f + \sum_{k=1}^K \lambda_k^\star \nabla g_k \\
\vdots \\
g_k\\
\vdots
\end{bmatrix}\right\} + o_P(1) \\
\overset{d}{\to}& \mathcal{N}\left(\begin{bmatrix}
\mu_1 \\
\mu_2
\end{bmatrix}, \begin{bmatrix}
\Sigma_{11} & \Sigma_{12} \\
\Sigma_{21} & \Sigma_{22}
\end{bmatrix}\right),
\end{align*}
where
\begin{align*}
\mu_1 &= \sum_{k=1}^K \frac{\lambda_k^\star \sqrt{\rho_k} \operatorname{Cov}_{P_0}(\nabla g_k(\theta^\star;Z), g_k(\theta^\star;Z))}{\sqrt{\operatorname{Var}_{P_0}[g_k(\theta^\star;Z)]}} \in \mathbb{R}^{d},\\
\mu_2 &= \begin{bmatrix}
\sqrt{\rho_1\operatorname{Var}_{P_0}[g_1(\theta^\star;Z)]} \\
\vdots \\
\sqrt{\rho_K\operatorname{Var}_{P_0}[g_K(\theta^\star;Z)]}
\end{bmatrix} \in \mathbb{R}^{K}.
\end{align*}
Therefore, we conclude that the limiting distribution of $\sqrt{n}(\nabla \widehat{L}_n(\theta^\star, {\boldsymbol\lambda}^\star), \widehat{\boldsymbol{G}}_n(\theta^\star))$ is
\begin{equation*}
(\boldsymbol{Y}_1, \boldsymbol{Y}_2) \sim \mathcal{N}\left(\begin{bmatrix}
\mu_1 \\
\mu_2
\end{bmatrix}, \begin{bmatrix}
\Sigma_{11} & \Sigma_{12} \\
\Sigma_{21} & \Sigma_{22}
\end{bmatrix}\right).
\end{equation*}
By Lemma \eqref{thm:RS-6.6.2}, we have
\begin{equation*}
\sqrt{n}(\widehat{\theta}_n - \theta^\star) \overset{d}{\longrightarrow} \bar{\boldsymbol{x}},
\end{equation*}
where $\bar{\boldsymbol{x}}$ is given by the linear system
\begin{equation*}
\underbrace{\begin{bmatrix}
\nabla^2 L(\theta^\star, {\boldsymbol\lambda}^\star) & \nabla \boldsymbol{G}(\theta^\star)\\
\nabla \boldsymbol{G}(\theta^\star)^\top & \boldsymbol{0}
\end{bmatrix}}_{\triangleq B} \begin{bmatrix}
\bar{\boldsymbol{x}}\\
\bar{{\boldsymbol\lambda}}
\end{bmatrix} = - \begin{bmatrix}
\boldsymbol{Y}_1\\
\boldsymbol{Y}_2
\end{bmatrix} \sim \mathcal{N}\left(- \begin{bmatrix}
\mu_1 \\
\mu_2
\end{bmatrix}, \begin{bmatrix}
\Sigma_{11} & \Sigma_{12} \\
\Sigma_{21} & \Sigma_{22}
\end{bmatrix}\right),
\end{equation*}
or
\begin{equation}\label{eq:solve-linear-system}
\begin{bmatrix}
\bar{\boldsymbol{x}}\\
\bar{{\boldsymbol\lambda}}
\end{bmatrix} \sim \mathcal{N}\left(- B^{-1}\begin{bmatrix}
\mu_1 \\
\mu_2
\end{bmatrix}, B^{-1} \begin{bmatrix}
\Sigma_{11} & \Sigma_{12} \\
\Sigma_{21} & \Sigma_{22}
\end{bmatrix} B^{-1}\right),
\end{equation}
which implies $\sqrt{n}(\widehat{\theta}_n - \theta^\star) \overset{d}{\longrightarrow} \bar{\boldsymbol{x}} \sim \mathcal{N}(\bar{\mu}, \bar{\Sigma})$ for some $\bar{\mu}$ and $\bar{\Sigma}$ determined by \eqref{eq:solve-linear-system}.
By delta method, we have
\begin{equation*}
\sqrt{n}
\begin{bmatrix}
\mathbb{E}_{P_0}[g_1(\widehat{\theta}_n;Z)]\\
\vdots \\
\mathbb{E}_{P_0}[g_K(\widehat{\theta}_n;Z)]
\end{bmatrix} = \sqrt{n}\boldsymbol{G}(\widehat{\theta}_n) = \sqrt{n}\{\boldsymbol{G}(\widehat{\theta}_n) - \underbrace{\boldsymbol{G}(\theta^\star)}_{=0}\} \overset{d}{\longrightarrow} \mathcal{N}(\nabla \boldsymbol{G}(\theta^\star)^\top \bar{\mu}, \nabla\boldsymbol{G}(\theta^\star)^\top \bar{\Sigma} \nabla\boldsymbol{G}(\theta^\star)).
\end{equation*}
Now we calculate $\nabla \boldsymbol{G}(\theta^\star)^\top \bar{\mu}$ and $\nabla\boldsymbol{G}(\theta^\star)^\top \bar{\Sigma} \nabla\boldsymbol{G}(\theta^\star))$.
For notation simplicity, we denote $\nabla^2 L = \nabla^2 L(\theta^\star, {\boldsymbol\lambda}^\star), \nabla \boldsymbol{G} = \nabla \boldsymbol{G}(\theta^\star)$ and $H = (\nabla^2 L)^{-1} \nabla \boldsymbol{G} [\nabla \boldsymbol{G}^\top (\nabla^2 L)^{-1} \nabla \boldsymbol{G}]^{-1}$. By block matrix inversion, we have
\[
B^{-1} = \begin{bmatrix}
(\nabla^2 L)^{-1} - H \nabla \boldsymbol{G}^\top (\nabla^2 L)^{-1} & H \\
H^\top & -[\nabla \boldsymbol{G}^\top (\nabla^2 L)^{-1} \nabla \boldsymbol{G}]^{-1}.
\end{bmatrix}
\]
By \eqref{eq:solve-linear-system}, we have
\[
\bar{\mu} = -\left\{(\nabla^2 L)^{-1} - H \nabla \boldsymbol{G}^\top (\nabla^2 L)^{-1}\right\} \mu_1 - H \mu_2.
\]
Note that $\nabla \boldsymbol{G}^\top H = \boldsymbol{I}_K$ and $\nabla \boldsymbol{G}^\top \left\{(\nabla^2 L)^{-1} - H \nabla \boldsymbol{G}^\top (\nabla^2 L)^{-1}\right\} = \boldsymbol{0}_{K\times K}$. We have
\[
\nabla \boldsymbol{G}(\theta^\star)^\top \bar{\mu} = -\nabla \boldsymbol{G}^\top \left\{(\nabla^2 L)^{-1} - H \nabla \boldsymbol{G}^\top (\nabla^2 L)^{-1}\right\} \mu_1 - \nabla \boldsymbol{G} H \mu_2 = -\mu_2
\]
and
\begin{align*}
&\nabla\boldsymbol{G}(\theta^\star)^\top \bar{\Sigma} \nabla\boldsymbol{G}(\theta^\star) \\
=& \nabla \boldsymbol{G}^\top \left[\left\{(\nabla^2 L)^{-1} - H \nabla \boldsymbol{G}^\top (\nabla^2 L)^{-1}\right\} \Sigma_{11} + H\Sigma_{21}\right]\underbrace{\left\{(\nabla^2 L)^{-1} - (\nabla^2 L)^{-1} \nabla \boldsymbol{G} H^\top\right\} \nabla \boldsymbol{G}}_{=\boldsymbol{0}_{K\times K}} \\
&+ \underbrace{\nabla \boldsymbol{G}^\top \left\{(\nabla^2 L)^{-1} - H \nabla \boldsymbol{G}^\top (\nabla^2 L)^{-1}\right\}}_{=\boldsymbol{0}_{K\times K}} \Sigma_{12} H^\top \nabla \boldsymbol{G} + \nabla \boldsymbol{G}^\top H \Sigma_{22} H^\top \nabla \boldsymbol{G} \\
=& \Sigma_{22}.
\end{align*}
Therefore, we conclude that
\begin{equation*}
\sqrt{n}
\begin{bmatrix}
\mathbb{E}_{P_0}[g_1(\widehat{\theta}_n;Z)]\\
\vdots \\
\mathbb{E}_{P_0}[g_K(\widehat{\theta}_n;Z)]
\end{bmatrix} \overset{d}{\to} \mathcal{N}(-\mu_2, \Sigma_{22}) \overset{d}{=\joinrel=} \mathcal{N}\left(-\begin{bmatrix}\sqrt{\rho_1\operatorname{Var}_{P_0}[g_1(\theta^\star;Z)]} \\ \vdots \\ \sqrt{\rho_K\operatorname{Var}_{P_0}[g_K(\theta^\star;Z)]}\end{bmatrix},\operatorname{Var}_{P_0}\begin{bmatrix}g_1(\theta^\star;Z)\\ \vdots \\ g_K(\theta^\star;Z)\end{bmatrix}\right).
\end{equation*}
Hence we complete the proof of Theorem \ref{thm:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}. \hfill $\square$
\section{Proof of Corollary \ref{cor:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}}
\label{sec:proof-cor-3.2}
Recall that $D = \operatorname{diag}(\operatorname{Var}_{P_0}[g_1(\theta^\star;Z)], \ldots, \operatorname{Var}_{P_0}[g_K(\theta^\star;Z)])$. According to Theorem \ref{thm:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}, we have
\begin{align*}
&\lim_{n\to\infty}\mathbb{P}\left\{\widehat{\theta}_n~\text{is feasible}\right\} \\
=& \lim_{n\to\infty}\mathbb{P}\left\{\begin{bmatrix}
\mathbb{E}_{P_0}[g_1(\widehat{\theta}_n;Z)]\\
\vdots \\
\mathbb{E}_{P_0}[g_K(\widehat{\theta}_n;Z)]
\end{bmatrix} \in -\mathbb{R}_+^K \right\} \\
=& \lim_{n\to\infty}\mathbb{P}\left\{\sqrt{n}\begin{bmatrix}
\mathbb{E}_{P_0}[g_1(\widehat{\theta}_n;Z)]\\
\vdots \\
\mathbb{E}_{P_0}[g_K(\widehat{\theta}_n;Z)]
\end{bmatrix} \leq \boldsymbol{0}_K \right\} \\
=& \mathbb{P}\left\{\mathcal{N}\left(-\begin{bmatrix}\left(\rho_1\operatorname{Var}_{P_0}[g_1(\theta^\star;Z)]\right)^{\frac12} \\ \vdots \\ \left(\rho_K\operatorname{Var}_{P_0}[g_K(\theta^\star;Z)]\right)^{\frac12}\end{bmatrix},\operatorname{Var}_{P_0}\begin{bmatrix}g_1(\theta^\star;Z)\\ \vdots \\ g_K(\theta^\star;Z)\end{bmatrix}\right) \leq \boldsymbol{0}_K\right\} \\
=& \mathbb{P}\left\{\mathcal{N}\left(-D^{-\frac12}\begin{bmatrix}\left(\rho_1\operatorname{Var}_{P_0}[g_1(\theta^\star;Z)]\right)^{\frac12} \\ \vdots \\ \left(\rho_K\operatorname{Var}_{P_0}[g_K(\theta^\star;Z)]\right)^{\frac12}\end{bmatrix},D^{-\frac12}\operatorname{Var}\begin{bmatrix}g_1(\theta^\star;Z)\\ \vdots \\ g_K(\theta^\star;Z)\end{bmatrix}D^{-\frac12}\right) \leq D^{-\frac12}\boldsymbol{0}_K\right\} \\
=& \mathbb{P}\left\{\mathcal{N}\left(-\begin{bmatrix}\sqrt{\rho_1} \\ \vdots \\ \sqrt{\rho_K}\end{bmatrix},\operatorname{Corr}_{P_0}\begin{bmatrix}g_1(\theta^\star;Z)\\ \vdots \\ g_K(\theta^\star;Z)\end{bmatrix}\right) \leq \boldsymbol{0}_K\right\} \\
=& \mathbb{P}\left\{\mathcal{N}\left(\boldsymbol{0}_K,\operatorname{Corr}_{P_0}\begin{bmatrix}g_1(\theta^\star;Z)\\ \vdots \\ g_K(\theta^\star;Z)\end{bmatrix}\right) \leq \begin{bmatrix}\sqrt{\rho_1} \\ \vdots \\ \sqrt{\rho_K}\end{bmatrix}\right\}.
\end{align*}
Hence we complete the proof of Corollary \ref{cor:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}. \hfill $\square$
\section{Dual ascent algorithm for \eqref{eq:robust-SAA-multiple-expected-value-constraint}}
\label{sec:dual-ascent-multiple-constraints}
We summarize the dual ascent algorithm for solving \eqref{eq:robust-SAA-multiple-expected-value-constraint} in Algorithm \ref{alg:robust-SAA-multiple-expected-value-constraint}. Similar to Algorithm \ref{alg:robust-SAA-single-expected-value-constraint}, the main cost of Algorithm \ref{alg:robust-SAA-multiple-expected-value-constraint} is incurred in the evaluation of dual function. The dual function evaluation step is still suitable for stochastic approximation. Therefore, the total cost of Algorithm \ref{alg:robust-SAA-multiple-expected-value-constraint} is comparable to that of a standard distributionally robust optimization problem.
\begin{algorithm*}
\caption{Dual ascent algorithm for \eqref{eq:robust-SAA-multiple-expected-value-constraint}}
\label{alg:robust-SAA-multiple-expected-value-constraint}
\begin{algorithmic}[1]
\State {\bfseries Input:} starting dual iterate ${\boldsymbol\lambda}_0 = (\lambda_{01},\ldots,\lambda_{0K})^\top\in\mathbb{R}^K_+$
\Repeat
\State Evaluate dual function: \[\textstyle\quad~~(\theta_t,{\boldsymbol\mu}_t,{\boldsymbol\nu}_t) \gets {\arg\min}_{\theta,{\boldsymbol\mu}\in\mathbb{R}^K_+,{\boldsymbol\nu}}\frac1n\sum_{i=1}^n f(\theta;Z_i) + \textstyle\sum_{k=1}^K\lambda_{tk}\left\{\frac1n\sum_{i=1}^n\mu_{tk}\varphi^*(\frac{g_{k}(\theta;Z_i) - \nu_{tk}}{\mu_{tk}}) + \mu_{tk}\frac{\rho_k}{n} + \nu_{tk}\right\}\]
\State Dual ascent update: \[\textstyle\lambda_{t+1,k} \gets \left[\lambda_{tk} + \eta_t\left\{\textstyle\frac1n\sum_{i=1}^n\mu_{tk}\varphi^*(\frac{g_{k}(\theta_t;Z_i) - \nu_{tk}}{\mu_{tk}}) + \mu_{tk}\frac{\rho_\alpha}{n} + \nu_{tk}\right\}\right]_+, k\in[K]\quad\quad\]
\Until{converged}
\end{algorithmic}
\end{algorithm*}
\section{Simulations: details and more}
\label{sec:details-simulations}
In this section, we provide details for simulations on the multi-item newsvendor problem with independent constraints (which we present in the main text), and conduct more simulations on: (1) multi-item newsvendor problem with dependent constraints, and (2) single-item newsvendor problem with a single constraint.
\subsection{Multi-item newsvendor problem}
First recall that in Section \ref{sec:simulation}, we simulate the frequency of constraint satisfaction for the following multi-item newsvendor problem:
\begin{equation}
\label{eq:maximization-problem-multi-item-newsvendor-appendix}
\begin{array}{ll}
\max_{\theta\in\Theta} & \mathbb{E}_{P_0} \big[p^\top \min \{Z, \theta\}- c^\top\theta\big] \\
\textrm{subject to} & \mathbb{E}_{P_0}[(\|Z^{(1)}\|_2^2-\|\theta^{(1)}\|_2^2)_{+}] \leq \varepsilon_1 \\
& \mathbb{E}_{P_0}[(\|Z^{(2)}\|_2^2-\|\theta^{(2)}\|_2^2)_{+}] \leq \varepsilon_2 \\
\end{array}
\end{equation}
where $c \in \mathbb{R}^d_{+}$ is the manufacturing cost, $p \in \mathbb{R}^d_{+}$ is the sell price, $\theta \in \Theta = [0,100]^d$ is the number of items in stock, $Z\in\mathbb{R}^d$ is a random variable with probability distribution $P_0$ representing the demand, and there are $d$ items in total. The distribution $P_0$ is unknown but we observe IID samples $Z_1,\ldots,Z_n$ from $P_0$. All of the items have been partitioned into two groups so that the corresponding demand and stock can be written as $Z = (Z^{(1)}, Z^{(2)})$ and $\theta = (\theta^{(1)}, \theta^{(2)})$. The constraints in the problem exclude stock levels that underestimate the demand too much for each group of items, where $\varepsilon_1,\varepsilon_2 > 0$ indicate tolerance level of such underestimation. The target of the problem is to maximize the profit while satisfying the constraints.
We can rewrite the maximization problem \eqref{eq:maximization-problem-multi-item-newsvendor-appendix} as a minimization problem with expected value constraints in the form of \eqref{eq:multiple-expected-value-constraint}, that is,
\begin{equation}
\label{eq:minimization-problem-multi-item-newsvendor-appendix}
\begin{array}{ll}
\min_{\theta\in\Theta} & \mathbb{E}_{P_0} \big[c^\top\theta - p^\top \min \{Z, \theta\}\big] \\
\textrm{subject to} & \mathbb{E}_{P_0}[(\|Z^{(1)}\|_2^2-\|\theta^{(1)}\|_2^2)_{+} - \varepsilon_1] \leq 0 \\
& \mathbb{E}_{P_0}[(\|Z^{(2)}\|_2^2-\|\theta^{(2)}\|_2^2)_{+} - \varepsilon_2] \leq 0 \\
\end{array}
\end{equation}
so that we can apply our method \eqref{eq:robust-SAA-multiple-expected-value-constraint}.
We generate $Z_1,\ldots,Z_n$ IID from multivariate normal distribution $\mathcal{N}(\mu, \Sigma)$. In addition, we set the number of items $d = 4$, the mean of the normal distribution $\mu = (10, 10, 10, 10)^\top$, the cost $c = (1, 1, 1, 1)^\top$, the price $p = (2, 2, 2, 2)^\top$, and the tolerance level of underestimation $(\varepsilon_1, \varepsilon_2) = (1, 1)$. Moreover, we partition the items into the group of the first two items and the group of the last two items. We solve the empirical problem with robust constraint:
\begin{equation}
\label{eq:robust-minimization-problem-multi-item-newsvendor-appendix}
\begin{array}{ll}
\min_{\theta\in\Theta} & \mathbb{E}_{\widehat{P}_n} \big[c^\top\theta - p^\top \min \{Z, \theta\}\big] \\
\textrm{subject to} & \sup_{D_\varphi (P\|\widehat{P}_n)\leq \rho/n} \mathbb{E}_{P}[(\|Z^{(1)}\|_2^2-\|\theta^{(1)}\|_2^2)_{+} - \varepsilon_1] \leq 0\\
& \sup_{D_\varphi (P\|\widehat{P}_n)\leq \rho/n} \mathbb{E}_{P}[(\|Z^{(2)}\|_2^2-\|\theta^{(2)}\|_2^2)_{+} - \varepsilon_2] \leq 0\\
\end{array}
\end{equation}
using samples of size $n \in \{30, 300, 3000\}$.
For the covariance of the multivariate normal distribution, we consider a exchangeable correlation structure
\begin{equation*}
\Sigma = 9\times\begin{bmatrix}
1 & r & r & r \\
r & 1 & r & r \\
r & r & 1 & r \\
r & r & r & 1
\end{bmatrix}
\end{equation*}
We solve \eqref{eq:robust-minimization-problem-multi-item-newsvendor-appendix} with ${\boldsymbol\rho} = (\rho,\rho)^\top = (z_\alpha, z_\alpha)^\top$ for $\alpha \in \{0.4, 0.25, 0.1, 0.05, 0.005\}$, of which the corresponding $\sqrt{\rho}\in\{0.253, 0.674, 1.281, 1.644, 2.575\}$.
\paragraph{Independent constraints} In Section \ref{sec:simulation}, we consider $r = 0$ so that the two constraints are generally uncorrelated with each other. As suggested by the asymptotic theory in Section \ref{sec:multiple-expected-value-constraints}, the nominal probability of constraint satisfaction is $1-\alpha$ for each constraint and $(1-\alpha)^2$ for both constraints due to the independence of two constraints. The results are discussed in Section \ref{sec:simulation}.
\paragraph{Dependent constraints} Now we consider $r = 0.6$ so that the two constraints are generally correlated with each other. As suggested by the asymptotic theory in Section \ref{sec:multiple-expected-value-constraints}, the nominal probability of constraint satisfaction is $1-\alpha$ for each constraint. The nominal probability of constraint satisfaction for both constraints is no longer $(1-\alpha)^2$ due to the dependence of two constraints, but the probability is given by
\begin{equation*}
\mathbb{P}\left\{\mathcal{N}\left(\begin{bmatrix}
0 \\
0
\end{bmatrix}, \begin{bmatrix}
1 & \operatorname{Corr}_{P_0}(g_1(\theta^\star;Z), g_2(\theta^\star;Z)) \\
\operatorname{Corr}_{P_0}(g_1(\theta^\star;Z), g_2(\theta^\star;Z)) & 1
\end{bmatrix}\right) \leq_{\mathbb{R}^2} \begin{bmatrix}
\sqrt{\rho} \\
\sqrt{\rho}
\end{bmatrix}\right\}.
\end{equation*}
In Figure \ref{fig:3}, we plot frequencies of constraint satisfaction for each constraint and both constraints, all of which are averaged over $1000$ replicates. As the sample size $n$ grows, the frequency versus probability curve converges to the theoretical dashed line of limiting probability of constraint satisfaction, validating our theory in the large sample regime. We note that in this example, the frequency of constraint satisfaction is higher than that of the experiments with independent constraints, for each ${\boldsymbol\rho}$.
\begin{figure}[h]
\centering
\begin{minipage}{0.32\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/multi_qq_4.pdf}
\end{minipage}
\begin{minipage}{0.32\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/multi_qq_5.pdf}
\end{minipage}
\begin{minipage}{0.32\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/multi_qq_6.pdf}
\end{minipage}
\caption{Frequency versus limiting probability of constraint satisfaction of the first constraint (left), the second constraint (middle), and both of the constraints (right). }
\label{fig:3}
\end{figure}
\subsection{Single-item newsvendor problem}
In this subsection, we consider the following single-item newsvendor problem:
\begin{equation*}
\begin{array}{ll}
\max_{\theta \in \Theta} & \mathbb{E}_{P_0}\big[p \min \{Z, \theta\}- c\theta\big] \\
\textrm{subject to} & \mathbb{E}_{P_0}\big[(Z-\theta)_{+}\big] \leq \varepsilon
\end{array}
\end{equation*}
where $c > 0$ is the manufacturing cost, $p \geq c$ is the sell price, $\theta \in \Theta = [0,100]$ is the number of items in stock, and $Z$ is a random variable with probability distribution $P_0$ representing the demand. The distribution $P_0$ is unknown but instead we observe IID samples $Z_1,\ldots,Z_n$ from $P$. The constraint in the problem excludes stocking levels that underestimate the demand too much, where $\varepsilon> 0$ indicates tolerance level of such underestimation. The target of the problem is to maximize the profit while satisfying the constraint. Note that the problem is equivalent to
\begin{equation*}
\begin{array}{ll}
\min_{\theta \in \Theta} & \mathbb{E}_{P_0}\big[c\theta - p \min \{Z, \theta\}\big] \\
\textrm{subject to} & \mathbb{E}_{P_0}\big[(Z-\theta)_{+} - \varepsilon\big] \leq 0
\end{array}
\end{equation*}
which is a particular case of \eqref{eq:single-expected-value-constraint}.
We generate $Z_1,\ldots,Z_n$ IID from exponential distribution with mean $10$. In addition, we set the cost $c = 1$, the price $p = 2$, and the tolerance level of underestimation $\varepsilon = 1$. We solve the empirical problem with robust constraint:
\begin{equation*}
\begin{array}{ll}
\min_{\theta \in \Theta} & \mathbb{E}_{\widehat{P}_n}\big[c\theta - p \min \{Z, \theta\}\big] \\
\textrm{subject to} & \sup_{D_\varphi (P\|\widehat{P}_n)\leq \rho/n} \mathbb{E}_{P}\big[(Z-\theta)_{+} - \varepsilon\big] \leq 0
\end{array}
\end{equation*}
using samples of size $n \in \{300, 3000, 30000\}$.
In Figure \ref{fig:4}, we plot frequencies of constraint satisfaction which are averaged over $1000$ replicates. As the sample size $n$ grows, the frequency versus probability curve converges to the theoretical dashed line of limiting probability of constraint satisfaction, validating our theory in the large sample regime.
\begin{figure}[h]
\centering
\includegraphics[width=0.32\columnwidth]{figures/single_qq.pdf}
\caption{Frequency versus limiting probability of constraint satisfaction.}
\label{fig:4}
\end{figure}
\section{Application of our method to $\varepsilon$-equality of opportunity}
\label{sec:instantiate-EO}
Continuing with Section \ref{sec:unknown-active-set}, we demonstrate how to apply our method to enforce $\varepsilon$-equality of opportunity. To keep things simple, we assume there are only two demographic groups; {\it i.e.}\ $|\mathcal{A}| = 2$. Without loss of generality, we refer to one group as advantaged ($A=1$) and the other as disadvantaged ($A=0$). First we estimate rates $\mathbb{P}\left\{A = 1, Y = 1\right\}$ and $\mathbb{P}\left\{A = 0, Y = 1\right\}$ consistently by
\begin{equation*}
\textstyle\widehat{p}_1 = \frac{1}{n}\sum_{i=1}^n \mathbf{1}\left\{A_i = 1, Y_i = 1\right\}\quad\text{and}\quad\widehat{p}_0 = \frac{1}{n}\sum_{i=1}^n \mathbf{1}\left\{A_i = 0, Y_i = 1\right\}.
\end{equation*}
Then, we construct a robust constraint
\begin{equation*}
\textstyle\sup_{P:D_\varphi (P\|\widehat{P}_n)\leq \rho/n} \mathbb{E}_{(X,A,Y)\sim P}\left[\frac{\mathbf{1}\{\widehat{Y} = 1, A = 1, Y = 1\}}{\widehat{p}_1} - \frac{\mathbf{1}\{\widehat{Y} = 1, A = 0, Y = 1\}}{\widehat{p}_0} -\varepsilon\right] \leq 0,
\end{equation*}
or equivalently
\begin{equation*}
\textstyle\sup_{\boldsymbol{p}:\sum_{i=1}^n \varphi(np_i)\leq \rho} \sum_{i=1}^n p_i\left[\frac{\mathbf{1}\{f_\theta(X_i) = 1, A_i = 1, Y_i = 1\}}{\widehat{p}_1} - \frac{\mathbf{1}\{f_\theta(X_i) = 1, A_i = 0, Y_i = 1\}}{\widehat{p}_0} -\varepsilon\right] \leq 0.
\end{equation*}
\section{Two-stage method for unknown active set}
\label{sec:details-unknown-active-set}
In this section, we show that the two-stage method in Section \ref{sec:unknown-active-set} also has the calibration property (similar to Theorem \ref{thm:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction} and Corollary \ref{cor:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}) if the true program $(\mathcal{P}_0)$, {\it i.e.}\ \eqref{eq:multiple-expected-value-constraint}, is not ill-behaved.
First we recall the two-stage method:
\begin{enumerate}
\item At the first stage, we solve the program $(\mathcal{P}_n)$ with ${\boldsymbol\rho} = \boldsymbol{0}_K$, that is, the sample average approximation (SAA) problem. We identify that $\widehat{J}_{+,n}\subset [K]$ is the active set of the SAA problem, that is, the $j$-th constraint of the SAA problem is active if and only if $j\in\widehat{J}_{+,n}$.
\item At the second stage, we solve the program $(\mathcal{P}_n)$ with ${\boldsymbol\rho}$ such that $\rho_j$ is some positive number if $j \in \widehat{J}_{+,n}$. This means that at the second stage we replace the sample mean approximation to the constraint by its distributionally robust counterpart if such constraint was identified as active at the first stage.
\end{enumerate}
The index set $[K]$ can be partitioned into three parts:
\begin{align*}
J_{+}(\theta^\star, {\boldsymbol\lambda}^\star) &= \{k\in[K]:
\mathbb{E}_{P_0}[g_k(\theta^\star; Z)] = 0, \lambda^\star_k > 0\}, \\
J_{0}(\theta^\star, {\boldsymbol\lambda}^\star) &= \{k\in[K]:
\mathbb{E}_{P_0}[g_k(\theta^\star; Z)] = 0, \lambda^\star_k = 0\}, \\
J_{-}(\theta^\star, {\boldsymbol\lambda}^\star) &= \{k\in[K]:
\mathbb{E}_{P_0}[g_k(\theta^\star; Z)] < 0, \lambda_k^\star = 0\},
\end{align*}
where $J_+$ is the active set with positive Lagrange multipliers, $J_0$ is the active set with zero Lagrange multipliers, and $J_-$ is the inactive set. We assume the \emph{strict complementarity} holds in the sense that $J_0(\theta^\star, {\boldsymbol\lambda}^\star) = \varnothing$.
\begin{proposition}[Preservance of active constraints]
\label{prop:preservance-of-active-constraints}
Assume the strict complementarity holds. We have $\widehat{J}_{+,n} = J_+(\theta^\star, {\boldsymbol\lambda}^\star)$ with probability converging to $1$ as $n\to\infty$.
\end{proposition}
\emph{Proof of Proposition \ref{prop:preservance-of-active-constraints}.} Let $\widehat{\theta}_n^{(\operatorname{SAA})}$ be a solution to the sample average approximation problem at the first stage. Let $\widehat{{\boldsymbol\lambda}}_n$ be the associated Lagrange multiplier. It is known by the consistency of SAA \cite{rubinstein1993discrete} that
\begin{equation*}
\widehat{\lambda}_{k,n} = \lambda^\star_k + o_p(1)~\text{for}~k\in J_+(\theta^\star, {\boldsymbol\lambda}^\star)
\end{equation*}
and
\begin{equation*}
\mathbb{E}_P[g_k(\widehat{\theta}_n^{(\operatorname{SAA})}; Z)] = \mathbb{E}_P[g_k(\theta^\star; Z)] + o_p(1)~\text{for}~k\in J_{-}(\theta^\star, {\boldsymbol\lambda}^\star)
\end{equation*}
Therefore, with probability converging to $1$, $\widehat{\lambda}_{k,n} > 0$, $k \in J_+(\theta^\star, {\boldsymbol\lambda}^\star)$ and $\mathbb{E}_P[g_k(\widehat{\theta}_n^{(\operatorname{SAA})}; Z)] < 0$, $k \in J_{-}(\theta^\star, {\boldsymbol\lambda}^\star)$. Hence we complete the proof of Proposition \ref{prop:preservance-of-active-constraints}. \hfill $\square$
\begin{theorem}
\label{thm:unknown-active-set}
Suppose the true program $(\mathcal{P}_0)$ has $m$ active constraints with positive Lagrange multipliers and $K-m$ inactive constraints (without loss of generality we let $J_+ = \{1,\ldots, m\}$ and $J_{-} = \{m+1, \ldots, K\}$). Let $\widehat{\theta}_n$ be the two-stage estimator. Under the standing assumptions, we have
\begin{equation*}
\lim_{n\to\infty}\mathbb{P}\left\{\begin{bmatrix}
\mathbb{E}_{P_0}[g_1(\widehat{\theta}_n;Z)]\\
\vdots \\
\mathbb{E}_{P_0}[g_K(\widehat{\theta}_n;Z)]
\end{bmatrix} \in -\mathbb{R}_+^K \right\} = \mathbb{P}\left\{\mathcal{N}\left(\boldsymbol{0}_m,\operatorname{Corr}_{P_0}\begin{bmatrix}g_1(\theta^\star;Z)\\ \vdots \\ g_m(\theta^\star;Z)\end{bmatrix}\right) \leq \begin{bmatrix}\sqrt{\rho_1} \\ \vdots \\ \sqrt{\rho_m}\end{bmatrix}\right\}.
\end{equation*}
\end{theorem}
This result shows that the limiting probability of satisfying the true constraints only depends on the correlation structure between active constraints and the uncertainty set radii for the active constraints.
\emph{Proof of Theorem \ref{thm:unknown-active-set}.} At the first stage, we identify $J \subset[K]$ as active set with probability $p_J$. Here the randomness is introduced by the data samples $Z_1,\ldots,Z_n$. Let $2^{[K]}$ be the power set of $[K]$. We have
\[
\sum_{J\in2^{[K]}} p_J = 1.
\]
By Proposition \ref{prop:preservance-of-active-constraints}, as $n\to\infty$ we have
\[
p_{J_+} \to 1
\]
and
\[
p_J \to 0~\text{for any}~J\in 2^{[K]}~\text{and}~J \neq J_+.
\]
By Corollary \ref{cor:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}, we have
\begin{equation*}
\lim_{n\to\infty}\mathbb{P}\left\{\widehat{\theta}_n~\text{is feasible}\mid \text{identify}~J_+~\text{as active set}\right\} = \mathbb{P}\left\{\mathcal{N}\left(\boldsymbol{0}_m,\operatorname{Corr}_{P_0}\begin{bmatrix}g_1(\theta^\star;Z)\\ \vdots \\ g_m(\theta^\star;Z)\end{bmatrix}\right) \leq \begin{bmatrix}\sqrt{\rho_1} \\ \vdots \\ \sqrt{\rho_m}\end{bmatrix}\right\}.
\end{equation*}
Therefore,
\begin{align*}
&\mathbb{P}\left\{\widehat{\theta}_n~\text{is feasible}\right\} \\
=& \sum_{J\in 2^{[K]}} \mathbb{P}\left\{\widehat{\theta}_n~\text{is feasible}\mid \text{identify}~J~\text{as active set}\right\} \mathbb{P}\left\{\text{identify}~J~\text{as active set}\right\} \\
=& \underbrace{p_{J_+}}_{\to 1} \mathbb{P}\left\{\widehat{\theta}_n~\text{is feasible}\mid \text{identify}~J_+~\text{as active set}\right\} + \sum_{J\neq J_+} \underbrace{p_J \mathbb{P}\left\{\widehat{\theta}_n~\text{is feasible}\mid \text{identify}~J~\text{as active set}\right\}}_{\to 0} \\
\to& \mathbb{P}\left\{\mathcal{N}\left(\boldsymbol{0}_m,\operatorname{Corr}_{P_0}\begin{bmatrix}g_1(\theta^\star;Z)\\ \vdots \\ g_m(\theta^\star;Z)\end{bmatrix}\right) \leq \begin{bmatrix}\sqrt{\rho_1} \\ \vdots \\ \sqrt{\rho_m}\end{bmatrix}\right\}.
\end{align*}
Hence we complete the proof of Theorem \ref{thm:unknown-active-set}. \hfill $\square$
\section{Proxy dual ascent algorithm for non-differentiable constraints}
\label{sec:proxy-dual-ascent-algorithm}
We summarize in Algorithm \ref{alg:proxy-dual-ascent-single-constraints} the proxy dual ascent algorithm for solving a stochastic optimization problem with single non-differentiable constraint. The difference between Algorithm \ref{alg:proxy-dual-ascent-single-constraints} and \ref{alg:robust-SAA-single-expected-value-constraint} is in the step of evaluating (proxy) dual function: Algorithm \ref{alg:proxy-dual-ascent-single-constraints} uses a differentiable surrogate $\Tilde{g}$ (highlighted in \color{orange}orange\color{black}) instead of the non-differentiable $g$ in Algorithm \ref{alg:robust-SAA-single-expected-value-constraint} in this step.
\begin{algorithm*}
\caption{Proxy dual ascent algorithm for single non-differentiable constraint}
\label{alg:proxy-dual-ascent-single-constraints}
\begin{algorithmic}[1]
\State {\bfseries Input:} starting dual iterate $\lambda_0 \ge 0$
\Repeat
\State Evaluate proxy dual function: \[\textstyle\quad~~(\theta_t,\mu_t,\nu_t) \gets {\arg\min}_{\theta,\mu\ge 0,\nu}\frac1n\sum_{i=1}^n f(\theta;Z_i) + \lambda_t\left\{\textstyle\frac1n\sum_{i=1}^n\mu\varphi^*\big(\frac{\color{orange}\Tilde{g}\color{black}(\theta;Z_i) - \nu}{\mu}\big) + \mu\frac{\rho_\alpha}{n} + \nu\right\}\]
\State Dual ascent update: $\lambda_{t+1} \gets \left[\lambda_t + \eta_t\left\{\textstyle\frac1n\sum_{i=1}^n\mu_t\varphi^*(\frac{g(\theta_t;Z_i) - \nu_t}{\mu_t}) + \mu_t\frac{\rho_\alpha}{n} + \nu_t\right\}\right]_+$
\Until{converged}
\end{algorithmic}
\end{algorithm*}
Algorithm \ref{alg:proxy-dual-ascent-multiple-constraints} summarizes the proxy dual ascent algorithm for solving a stochastic optimization problem with multiple non-differentiable constraints. In contrast to Algorithm \ref{alg:robust-SAA-multiple-expected-value-constraint}, Algorithm \ref{alg:proxy-dual-ascent-multiple-constraints} replaces the non-differentiable functions $g_k$'s by their differentiable surrogates $\Tilde{g}_k$'s (highlighted in \color{orange}orange\color{black}) in the (proxy) dual function evaluation step.
\begin{algorithm*}
\caption{Proxy dual ascent algorithm for multiple non-differentiable constraints}
\label{alg:proxy-dual-ascent-multiple-constraints}
\begin{algorithmic}[1]
\State {\bfseries Input:} starting dual iterate ${\boldsymbol\lambda}_0 = (\lambda_{01},\ldots,\lambda_{0K})^\top\in\mathbb{R}^K_+$
\Repeat
\State Evaluate proxy dual function: \[\textstyle\quad~~(\theta_t,{\boldsymbol\mu}_t,{\boldsymbol\nu}_t) \gets {\arg\min}_{\theta,{\boldsymbol\mu}\in\mathbb{R}^K_+,{\boldsymbol\nu}}\frac1n\sum_{i=1}^n f(\theta;Z_i) + \textstyle\sum_{k=1}^K\lambda_{tk}\left\{\frac1n\sum_{i=1}^n\mu_{tk}\varphi^*(\frac{\color{orange}\Tilde{g}_{k}\color{black}(\theta;Z_i) - \nu_{tk}}{\mu_{tk}}) + \mu_{tk}\frac{\rho_k}{n} + \nu_{tk}\right\}\]
\State Dual ascent update: \[\textstyle\lambda_{t+1,k} \gets \left[\lambda_{tk} + \eta_t\left\{\textstyle\frac1n\sum_{i=1}^n\mu_{tk}\varphi^*(\frac{g_{k}(\theta_t;Z_i) - \nu_{tk}}{\mu_{tk}}) + \mu_{tk}\frac{\rho_\alpha}{n} + \nu_{tk}\right\}\right]_+, k\in[K]\quad\quad\]
\Until{converged}
\end{algorithmic}
\end{algorithm*}
\section{Real data experiments: details and more}
\label{sec:details-experiments}
In this section, we provide details for experiments on Adult dataset with $\varepsilon$-demographic parity as the fairness goal (which we present in the main text), and conduct additional experiments on Adult dataset with $\varepsilon$-false positive rate parity as the fairness goal.
\subsection{Adult with $\varepsilon$-demographic parity}
\label{sec:adult-DP}
Recall that in Section \ref{sec:adult} the fairness goal is $\varepsilon$-demographic parity ($\varepsilon$-DP):
\[
\big|\mathbb{P}(\widehat{Y} = 1\mid A = 1) - \mathbb{P}(\widehat{Y} = 1\mid A = 0)\big|\leq \varepsilon,
\]
where $A = 1$ for male is the advantaged group and $A = 0$ for female is the disadvantaged group. We use a logistic regression model for classification by predicting $\widehat{Y} = \mathbf{1}\{\theta^\top X \geq 0\}$ and training such model parameterized in $\theta$ by logistic loss. We implement the two-stage method and proxy dual ascent algorithm by replacing indicator function by the sigmoidal function $h_1(t) = (1 + e^{-at})^{-1}$ for $a = 2$. We do bootstrap evaluation by treating the full dataset as the true probability measure and sample such probability measure with replacement as the training distribution (with sampling rate $50\%$).
\subsection{Adult with $\varepsilon$-false positive rate parity}
\label{sec:adult-FPR}
Similar to the preceding subsection, now we consider the fairness goal to be $\varepsilon$-false positive rate parity:
\[
\big|\mathbb{P}(\widehat{Y} = 1\mid Y = 0, A = 1) - \mathbb{P}(\widehat{Y} = 1\mid Y = 0, A = 0)\big|\leq \varepsilon,
\]
where $A = 1$ for male is the advantaged group and $A = 0$ for female is the disadvantaged group.
In Figure \ref{fig:5}, we have line plots for frequency of constraint satisfaction and box plots for classification error rate, all of which are summarized over $100$ replicates. The patterns shown in the left and right panels are similar to that in Figure \ref{fig:2}. We observe more variation in frequencies of constraint satisfaction across different false positive rate tolerance designs due to the label and demographic attribute imbalance of Adult dataset.
\begin{figure}[h]
\centering
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Adult_FPR_1.pdf}
\end{minipage}
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Adult_FPR_2.pdf}
\end{minipage}
\caption{Frequency of constraint satisfaction (left) and classification error rate (right) for different false positive rate parity tolerance $\varepsilon \in \{0.01, 0.02, 0.03, 0.04, 0.05\}$. Baseline (sample average approximation, SAA) and our methods (with nominal probability $0.60, 0.75, 0.90,0.95$) are compared.}
\label{fig:5}
\end{figure}
\section{Dual form of the robust constraint function \eqref{eq:robust-expected-value-constraint-dual-form}}
\label{sec:standard-dro-dual}
In this section, we provide a standard derivation for the dual form of the robust constraint function \eqref{eq:robust-expected-value-constraint-dual-form}.
We introduce the likelihood ratio $L(Z) = dP(Z)/d\widehat{P}_n(Z)$. By change of variable, we can rewrite the robust constraint function \eqref{eq:robust-expected-value-constraint-dual-form} as
\[
\sup\nolimits_{P:D_\varphi(P\| \widehat{P}_n)\leq\rho}\mathbb{E}_P\big[g(\theta;Z)\big] \textstyle=\sup_{L\geq 0}\{\mathbb{E}_{\widehat{P}_n}\big[L(Z)g(\theta;Z)\big]\mid\mathbb{E}_{\widehat{P}_n}\big[\varphi(L(Z))\big]\leq\rho, \mathbb{E}_{\widehat{P}_n}\big[L(Z)\big] = 1\},
\]
where the supremum takes over measurable functions. This gives us a constrained optimization problem. Let $\mu\geq 0$ be the Lagrange multiplier for $\mathbb{E}_{\widehat{P}_n}\big[\varphi(L(Z))\big]\leq\rho$ and $\nu\in\mathbb{R}$ be the Lagrange multiplier for $\mathbb{E}_{\widehat{P}_n}\big[L(Z)\big] = 1$. The corresponding Lagrangian is
\begin{equation*}
\mathcal{L}(L,\mu,\nu) = \mathbb{E}_{\widehat{P}_n}\big[(g(\theta;Z) -\nu)L(Z) - \mu\varphi(L(Z))\big] + \mu\rho + \nu.
\end{equation*}
For regular $\varphi$-divergence, we have
\begin{align*}
&\sup\nolimits_{P:D_\varphi(P\| \widehat{P}_n)\leq\rho}\mathbb{E}_P\big[g(\theta;Z)\big] \\
=& \inf_{\mu\geq 0, \nu\in\mathbb{R}} \sup_{L\geq 0} \mathcal{L}(L,\mu,\nu) \\
=& \inf_{\mu\geq 0, \nu\in\mathbb{R}} \sup_{L\geq 0} \left\{\sum_{i=1}^n\big[(g(\theta;Z_i) - \nu) L(Z_i) - \mu \varphi(L(Z_i))\big] + \mu\rho + \nu\right\} \\
=& \inf_{\mu\geq 0, \nu\in\mathbb{R}} \sup_{L\geq 0} \left\{\sum_{i=1}^n\mu\left[\frac{g(\theta;Z_i) - \nu}{\mu} L(Z_i) - \varphi(L(Z_i))\right] + \mu\rho + \nu\right\} \\
=& \inf_{\mu\geq 0, \nu\in\mathbb{R}} \left\{\sum_{i=1}^n \mu \sup_{t_i\geq 0}\left\{\frac{g(\theta;Z_i) - \nu}{\mu} t_i - \varphi(t_i)\right\} + \mu\rho + \nu\right\} \\
&= \inf_{\mu\geq 0, \nu\in\mathbb{R}} \left\{\sum_{i=1}^n \mu \varphi^*\left(\frac{g(\theta;Z_i) - \nu}{\mu}\right) + \mu\rho + \nu\right\}.
\end{align*}
Here the last equality holds according to the definition of the convex conjugate $\varphi^*(\cdot)$.
\section{Experiments on additional baseline and dataset}
\label{sec:more-baseline}
In this section, we conduct more experiments using two-dataset approach of \citep{cotter2019training} as an additional baseline and default of credit card clients dataset from UCI \citep{Dua:2019} as an additional dataset.
\subsection{Adult with $\varepsilon$-demographic parity (continued)}
We continue the experiments on Adult dataset with $\varepsilon$-demographic parity in Section \ref{sec:adult} and \ref{sec:adult-DP} by adding two-dataset approach of \citep{cotter2019training} as an additional baseline.
The two dataset approach of \citep{cotter2019training} splits the training set into two parts, one for updating the model parameters and the other for updating the Lagrangian multipliers, with the goal to improve the generalization of fairness constraints.
Figure \ref{fig:6} demonstrates that the two-dataset approach marginally improves the frequency of constraint satisfaction over the SAA.
The cost of such an improvement is increased variation in classification error rate.
Due to the fact that the two-dataset approach does not use the entire training set to update the model parameters, statistical efficiency is sacrificed.
Although the two-dataset approach outperforms the SAA in terms of constraint satisfaction frequency, both are inferior to our methods, which achieve the user-prescribed level of frequency.
\begin{figure}[h]
\centering
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Adult_DP_1_supp.pdf}
\end{minipage}
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Adult_DP_2_supp.pdf}
\end{minipage}
\caption{Frequency of constraint satisfaction (left) and classification error rate (right) for different demographic parity tolerance $\varepsilon \in \{0.01, 0.02, 0.03, 0.04, 0.05\}$. Baseline (sample average approximation, SAA), our methods (with nominal probability $0.60, 0.75, 0.90,0.95$), and two-dataset approach \citep{cotter2019training} are compared.}
\label{fig:6}
\end{figure}
\subsection{Adult with $\varepsilon$-false positive rate parity (continued)}
We continue the experiments on Adult dataset with $\varepsilon$-false positive rate parity in Section \ref{sec:adult-FPR} by adding two-dataset approach of \citep{cotter2019training} as an additional baseline.
Figure \ref{fig:7} demonstrates similar patterns as Figure \ref{fig:6}. The two-dataset approach improves constraint satisfaction frequency over the SAA, but has a worse classification error rate or one comparable to it. Our methods achieve desired frequency of constraint satisfaction at the user-prescribed level.
\begin{figure}[h]
\centering
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Adult_FPR_1_supp.pdf}
\end{minipage}
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Adult_FPR_2_supp.pdf}
\end{minipage}
\caption{Frequency of constraint satisfaction (left) and classification error rate (right) for different false positive rate parity tolerance $\varepsilon \in \{0.01, 0.02, 0.03, 0.04, 0.05\}$. Baseline (sample average approximation, SAA), our methods (with nominal probability $0.60, 0.75, 0.90,0.95$), and two-dataset approach \citep{cotter2019training} are compared.}
\label{fig:7}
\end{figure}
\subsection{Credit with $\varepsilon$-demographic parity}
Predicting whether or not an individual defaulted on a loan is the classification task of the UCI default of credit card clients (Credit) dataset. Membership in the demographic group is determined by an individual's level of education: $A = 1$ if a person has earned a graduate degree; otherwise, $A = 0$.
We consider the fairness goal to be $\varepsilon$-demographic parity:
\[
\big|\mathbb{P}(\widehat{Y} = 1\mid A = 1) - \mathbb{P}(\widehat{Y} = 1\mid A = 0)\big|\leq \varepsilon,
\]
where $A = 1$ for individuals with a graduate degree is the advantaged group.
As depicted in Figure \ref{fig:8}, our methods achieve the level of constraint satisfaction frequency specified by the user at the expense of a slight increase in classification error.
\begin{figure}[h]
\centering
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Credit_DP_1.pdf}
\end{minipage}
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Credit_DP_2.pdf}
\end{minipage}
\caption{Frequency of constraint satisfaction (left) and classification error rate (right) for different demographic parity tolerance $\varepsilon \in \{0.01, 0.02, 0.03, 0.04, 0.05\}$. Our methods (with nominal probability $0.75, 0.90,0.95$), sample average approximation (SAA) and two-dataset approach \citep{cotter2019training} are compared.}
\label{fig:8}
\end{figure}
\subsection{Credit with $\varepsilon$-true positive rate parity}
Similar to the preceding subsection, now we consider the fairness goal to be $\varepsilon$-true positive rate parity:
\[
\big|\mathbb{P}(\widehat{Y} = 1\mid Y = 1, A = 1) - \mathbb{P}(\widehat{Y} = 1\mid Y = 1, A = 0)\big|\leq \varepsilon,
\]
where $A = 1$ for individuals with a graduate degree is the advantaged group.
The patterns shown in Figure \ref{fig:9} are similar to that in Figure \ref{fig:8}. The SAA has the lowest error rate but the worst generalization of constraint satisfaction. The two-dataset approach increases the SAA's frequency of constraint satisfaction at the cost of an increase in classification error rates. Our methods can achieve the desired high probability of constraint satisfaction, whereas neither of the two baselines can.
\begin{figure}[h]
\centering
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Credit_TPR_1.pdf}
\end{minipage}
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Credit_TPR_2.pdf}
\end{minipage}
\caption{Frequency of constraint satisfaction (left) and classification error rate (right) for different true positive rate parity tolerance $\varepsilon \in \{0.01, 0.02, 0.03, 0.04, 0.05\}$. Our methods (with nominal probability $0.75, 0.90,0.95$), sample average approximation (SAA) and two-dataset approach \citep{cotter2019training} are compared.}
\label{fig:9}
\end{figure}
\section{Application to fair machine learning}
\label{sec:fairness}
As ML models are deployed in high-stakes decision making and decision support roles, the fairness of the models has come under increased scrutiny. In response, there is a flurry of recent work on mathematical definitions of algorithmic fairness \cite{dwork2011Fairness,hardt2016Equality,kusner2018Counterfactual} and algorithms to enforce the definitions \cite{agarwal2018Reductions,cotter2019TwoPlayer,yurochkin2020SenSeI}.
A prominent class of fairness definitions is \emph{group fairness}; such definitions require equality of certain metrics ({\it e.g.}\ false/true positive rates) among demographic groups. For example, consider a fair binary classification problem. Let $\mathcal{X}\subset\mathbb{R}^d$ be the input space, $\{0,1\}$ be the set of possible labels, and $\mathcal{A}$ be the set of possible values of the protected/sensitive attribute. In this setup, training and test examples are tuples of the form $(X,A,Y)\in\mathcal{X}\times\mathcal{A}\times\mathcal{Y}$, and a classifier is a map $f:\mathcal{X}\to\{0,1\}$.
A popular definition of algorithmic fairness for binary classification is \emph{equality of opportunity} \cite{hardt2016Equality}.
\begin{definition}[equality of opportunity]
\label{def:equal-opportunity}
Let $Y=1$ be the advantaged label that is associated with a positive outcome and $\widehat{Y} \triangleq f(X)$ be the output of the classifier. Equality of opportunity entails $\mathbb{P}\{\widehat{Y}=1\mid A=a,Y=1\} = \mathbb{P}\{\widehat{Y}=1\mid A=a^\prime,Y=1\}$ for all $a,a^\prime\in\mathcal{A}$.
\end{definition}
Equality of opportunity, or true positive rate parity, means that the prediction $\widehat{Y} = h(X)$ conditioned on the advantaged label $Y=1$ is statistically independent of the protected attribute $A$.
Furthermore, an approximate version of equality of opportunity can be readily defined. We say that $\widehat{Y} = h(X)$ satisfies \emph{$\varepsilon$-equality of opportunity} if $\mathbb{P}\{\widehat{Y}=1\mid A=a,Y=1\} - \mathbb{P}\{\widehat{Y}=1\mid A=a^\prime,Y=1\} \leq \varepsilon$ for for all $a,a'\in\mathcal{A}$. In this case, $\varepsilon>0$ represents a practitioner's \emph{tolerance} for fairness violations.
Given a parametric model space $\mathcal{H} = \{f_\theta(\cdot): \theta \in \Theta\}$ and loss function $\ell: \Theta\times\mathcal{X}\times\mathcal{Y} \to \mathbb{R}_+$, an in-processing fair ML routine is to minimize the (empirical) risk $\mathbb{E} \left[\ell(\theta; X, Y)\right]$ while satisfying some fairness constraints. Most commonly, definitions of group fairness (including equality of opportunity, demographic parity, and more) can be written as a special example of a general set of linear constraints \cite{agarwal2018Reductions, agarwal2019Fair} of the form $\mathbf{M}\boldsymbol{\mu}(\theta)\leq\mathbf{c}$, where matrix $\mathbf{M}\in\mathbb{R}^{K \times T}$ and vector $\mathbf{c} \in \mathbb{R}^{K}$ encode the constraints; $\boldsymbol{\mu}(\theta): \Theta \to \mathbb{R}^T$ is a vector of (conditional) moments
$\mu_t(\theta) = \mathbb{E}\left[h_t(X, A, Y, \theta)\mid \mathcal{E}_t\right]$ for $t\in[T]$; $g_t:\mathcal{X}\times\mathcal{A}\times\mathcal{Y}\times\Theta\to\mathbb{R}$; event $\mathcal{E}_t$ is defined with respect to $(X, A, Y)$.
This framework fits to our methodology if we note that each (conditional) moment can be written as
\begin{equation}\label{eq:ratio-of-expected-values}
\mu_t(\theta) = \frac{\mathbb{E}_{(X,A,Y)\sim P_0}\big[h_t(X,A,Y,\theta)\times \mathbf{1}\left\{\mathcal{E}_t(X,Y,A)\right\}\big]}{\mathbb{E}_{(X,A,Y)\sim P_0}\big[ \mathbf{1}\left\{\mathcal{E}_t(X,Y,A)\right\}\big]}.
\end{equation}
Here the indicator $\mathbf{1}\left\{\mathcal{E}_t\right\}$ takes value $1$ if the event $\mathcal{E}_t$ happens, and $0$ otherwise. Moreover, we use $\mathcal{E}_t(X, A, Y)$ to emphasize that $\mathcal{E}_t$ only depends on $(X, Y, A)$ but not on $\theta$ in any way.
Note that \eqref{eq:ratio-of-expected-values} is a ratio of expected values, which is a non-linear statistical functional of $P_0$. To use our method, we first replace the denominator of $\mu_t(\theta)$ with an estimator, such as the unbiased estimator $\widehat{\mathbb{P}}(\mathcal{E}_t) = \frac{1}{n}\sum_{i=1}^n \mathbf{1}\left\{\mathcal{E}_t(X_i,A_i,Y_i)\right\}$. The resulting plug-in estimation of $\mu_t(\theta)$ then becomes linear in $P_0$, allowing us to apply our method (see similar tricks in \cite{cotter2019training}).
We describe the application of our method to $\varepsilon$-equality of opportunity in Appendix \ref{sec:instantiate-EO}.
\subsection{A two-stage method for unknown active set}
\label{sec:unknown-active-set}
In practice, it is probable that only a subset of the constraints are active. Furthermore, we do not know beforehand whether or not a constraint is active in the true population problem. To handle this scenario, we propose a two-stage method:
\begin{enumerate}
\item At the first stage, we solve the sample average approximation (SAA) problem \eqref{eq:robust-SAA-multiple-expected-value-constraint} with ${\boldsymbol\rho} = \boldsymbol{0}_K$. By doing so, we identify the active set of the SAA problem.
\item At the second stage, we solve \eqref{eq:robust-SAA-multiple-expected-value-constraint} with ${\boldsymbol\rho}$ such that $\rho_k$ is a positive number only if the $k$-th constraint, $k \in [K]$, was identified as active at the first stage.
\end{enumerate}
In Appendix \ref{sec:details-unknown-active-set}, we show that the two-stage method also enjoys the calibration property (similar to Theorem \ref{thm:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction} and Corollary \ref{cor:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}) under standard assumptions ({\it i.e.}, strict complementarity). At a high level, the limiting probability of satisfying the true constraints depends solely on the correlation structure between active constraints and the uncertainty set radii for active constraints, as long as the SAA problem identifies active constraints with probability tending to $1$.
\subsection{Proxy dual function for non-differentiable constraints}
Constraint functions in fair ML are often non-differentiable. For instance, fairness metrics are typically linear combinations of indicators that result in non-differentiable rate constraints \citep{cotter2019training,cotter2019Optimization,cotter2019TwoPlayer}.
This prevents the use of any gradient-based optimization algorithms.
Fortunately, only the dual function evaluation step in Algorithm \ref{alg:robust-SAA-single-expected-value-constraint} requires access to gradients.
Therefore, we can modify the algorithm by: (1) introducing proxy dual function, which uses a differentiable surrogate $\Tilde{g}$ instead of the non-differentiable $g$ in the dual function evaluation step; (2) keeping $g$ in the dual ascent step. For an indicator function $h(t) = \mathbf{1}\{t > 0\}$, one can replace it by sigmoidal function $h_1(t) = (1 + e^{-at})^{-1}$ or hinge upper bound $h_2(t) = \max\{0, t+1\}$ to produce smooth surrogates for non-differentiable rate constraints \citep{davenport2010tuning, eban2017scalable, cotter2019Optimization}. We summarize the proxy dual ascent algorithm in Appendix \ref{sec:proxy-dual-ascent-algorithm}.
\subsection{Adult experiments}
\label{sec:adult}
We compare the frequency of constraint satisfaction (at test time) of the sample average approximation and our methods with nominal probability $0.60, 0.75, 0.90, 0.95$ using the Adult dataset from UCI \citep{Dua:2019}. The classification task is to predict whether an individual's income per year is higher than $\$50$K. The fairness goal is $\varepsilon$-demographic parity ($\varepsilon$-DP): $|\mathbb{P}(\widehat{Y} = 1\mid A = 1) - \mathbb{P}(\widehat{Y} = 1\mid A = 0)|\leq \varepsilon$, where $A = 1$ for male is the advantaged group and $A = 0$ for female is the disadvantaged group. We use a logistic regression model for classification and techniques in this section for implementation.
In Figure \ref{fig:2}, we have line plots for frequency of constraint satisfaction and box plots for classification error rate, all of which are summarized over $100$ replicates. The left panel shows that solving \eqref{eq:multiple-expected-value-constraint} directly leads to one half chance of constraint violation, while our method's constraint satisfaction frequency matches its nominal value. The price of a higher chance of test-time fairness satisfaction is an increase in classification error rate as shown in the right panel. From the baseline to $95\%$ chance of fairness satisfaction, we basically trade off $2\%$ increase in error rate. We refer to Appendix \ref{sec:details-experiments} and \ref{sec:more-baseline} for details and more experiments.
\begin{figure}[h]
\centering
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Adult_DP_1.pdf}
\end{minipage}
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/Adult_DP_2.pdf}
\end{minipage}
\caption{Frequency of constraint satisfaction (left) and classification error rate (right) for different demographic parity tolerance $\varepsilon \in \{0.01, 0.02, 0.03, 0.04, 0.05\}$. Baseline (sample average approximation, SAA) and our methods (with nominal probability $0.60, 0.75, 0.90,0.95$) are compared.}
\label{fig:2}
\end{figure}
\section{Motivation}
\label{sec:intro}
In machine learning (ML) practice, accuracy is often only one of many training objectives. For example, algorithmic fairness considerations may require a credit scoring system to perform comparably on men and women.
Here are a few other examples.
\paragraph{Churn rate and stability} The churn rate of an ML model compared to another model is the fraction of samples on which the predictions of the two models differ \cite{goh2016Satisfying,milanifard2016Launch}. In ML practice, one may wish to control the churn rate between a new model and its predecessor because a high churn rate can disorient users and downstream system components. One way of training models with small churn is to enforce a churn rate constraint during training.
\paragraph{Precision, recall, {\it etc.}} Classification and information retrieval models must often balance precision and recall. To train such models, practitioners carefully trade off one metric for the other by optimizing for one metric subject to constraints on the other.
\paragraph{Resource constraints} Practitioners sometimes wish to control how often a classifier predicts a certain class due to budget or resource constraints. For example, a company that uses ML to select customers for a targeted offer may wish to constrain the fraction of customers selected for the offer.
Another prominent example of a stochastic optimization problem with resource constraints is the newsvendor problem, which we come back to in section \ref{sec:simulation}.
Unlike constraints on the structure of model parameters ({\it e.g.}, sparsity), the constraints encoding the preceding training objectives are \emph{data-dependent}. This leads to the issue of \emph{constraint generalization}: whether the constraints \emph{generalize} out-of-sample. For example, if a classifier is trained to have comparable accuracy on two subpopulations in the training data, will it also have comparable accuracy on samples from the two subpopulations at test time?
In this paper, we consider the out-of-sample generalization of \emph{expected-value} constraints. To keep things simple, consider a stochastic optimization problem with a single \emph{expected-value} constraint:
\begin{equation}
\theta^\star\in\left\{\begin{aligned}
&{\arg\min}_{\theta\in\Theta} &&\mathbb{E}_{P_0}\big[f(\theta;Z)\big] = \textstyle\int_\mathcal{Z} f(\theta;z)dP_0(z) \\
&\textrm{subject to} &&\mathbb{E}_{P_0}\big[g(\theta;Z)\big] = \textstyle\int_\mathcal{Z} g(\theta;z)dP_0(z) \leq 0
\end{aligned}\right\},
\label{eq:single-expected-value-constraint}
\end{equation}
where $\Theta$ is a (finite-dimensional) parameter space, $f, g:\Theta\times\mathcal{Z}\to\mathbb{R}$ are (known) cost and constraint functions, and $Z\in\mathcal{Z}$ is a random variable that represents a sample. The distribution of $Z$ is unknown, so we cannot solve \eqref{eq:single-expected-value-constraint} directly. Instead, we obtain IID training samples $\{Z_i\}_{i=1}^n$ from the true underlying distribution $P_0$ and solve the empirical version of \eqref{eq:single-expected-value-constraint}:
\begin{equation}
\widehat{\theta}_n\in\left\{\begin{aligned}
&{\arg\min}_{\theta\in\Theta} &&\textstyle\frac1n\sum_{i=1}^n f(\theta;Z_i) \\
&\textrm{subject to} &&\textstyle\frac1n\sum_{i=1}^n g(\theta;Z_i) \leq 0
\end{aligned}\right\}.
\label{eq:SAA-single-expected-value-constraint}
\end{equation}
The estimator $\widehat{\theta}_n$ (of $\theta^\star$) is guaranteed to satisfy the empirical constraint ({\it i.e.}, $\frac1n\sum_{i=1}^n g(\widehat{\theta}_n;Z_i) \leq 0$), but it is unclear whether $\widehat{\theta}_n$ satisfies the actual (population) constraint $\mathbb{E}_{P_0}\big[g(\theta;Z)\big] \leq 0$. As we shall see, under standard assumptions on \eqref{eq:single-expected-value-constraint}, $\widehat{\theta}_n$ only satisfies the actual constraint with probability approaching $\frac12$ (see corollary \ref{cor:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction}). This is especially problematic for constraints that encode algorithmic fairness goals. For example, the 80\% rule published by the US Equal Employment Opportunity Commission, interpreted in the machine learning context, requires the rate at which a classifier predicts the advantaged label in minority groups to be at least 80\% of the rate at which the classifier predicts the advantaged label in the majority group \cite{barocas2019Fairness}.
In this paper, we propose a distributionally robust version of \eqref{eq:SAA-single-expected-value-constraint} that \emph{guarantees} the actual constraint $\mathbb{E}_{P_0}\big[g(\theta;Z)\big] \leq 0$ will be satisfied with probability $1-\alpha$:
\begin{equation}
\widehat{\theta}_n\in\left\{\begin{aligned}
&{\arg\min}_{\theta\in\Theta} &&\textstyle\frac1n\sum_{i=1}^nf(\theta;Z_i) \\
&\textrm{subject to} &&\sup\nolimits_{P:D_\varphi(P\|\widehat{P}_n)\leq\frac{\rho_\alpha}{n}}\mathbb{E}_{P}\big[g(\theta;Z)\big] \leq 0
\end{aligned}\right\},
\label{eq:robust-SAA-single-expected-value-constraint}
\end{equation}
where $D_\varphi$ is a $\varphi$-divergence (see section \ref{sec:single-expected-value-constraint} for details), $\widehat{P}_n$ is the empirical distribution of the training samples, and $\sqrt{\rho_\alpha}$ is the $1-\alpha$ quantile of a standard normal random variable. More concretely, we show that $\widehat{\theta}_n$ achieves \emph{asymptotically exact constraint satisfaction}
\begin{equation}
\lim_{n\to\infty}\mathbb{P}\left\{\mathbb{E}_{P_0}\big[g(\widehat{\theta}_n;Z)\big] \leq 0\right\} = 1-\alpha.
\label{eq:asymptotically-exact-constraint-satisfaction}
\end{equation}
Here the inner expectation is with respect to $Z$; the outer probability is with respect to the training samples $\{Z_i\}_{i=1}^n$. Three desirable properties of \eqref{eq:robust-SAA-single-expected-value-constraint} are
\begin{enumerate}
\item \textbf{exact constraint satisfaction:} If the actual probability of constraint satisfaction exceeds $1-\alpha$, then the method is too conservative. This may (unnecessarily) increase the cost of the model. By picking $\rho_\alpha$ in \eqref{eq:robust-SAA-single-expected-value-constraint} carefully, constraints are satisfied with asymptotically exact probability $1-\alpha$.
\item \textbf{computationally efficient:} As we shall see, the computational cost of solving \eqref{eq:robust-SAA-single-expected-value-constraint} is comparable to the cost of solving distributionally robust sample average approximation (SAA) problems.
\item \textbf{pivotal:} There are no nuisance parameters to estimate ({\it e.g.}, asymptotic variances) in \eqref{eq:robust-SAA-single-expected-value-constraint}. The user merely needs to look up the correct quantile of the standard normal distribution for their desired level of constraint generalization.
\end{enumerate}
The rest of this paper is organized as follows.
In Section \ref{sec:single-expected-value-constraint}, we develop method, theory, and algorithm for stochastic optimization problems with single constraint. In Section \ref{sec:multiple-expected-value-constraints}, we extend our method, theory, and algorithm to stochastic optimization problems with multiple constraints.
In Section \ref{sec:simulation}, we validate our theory by simulating a resource-constrained newsvendor problem.
In Section \ref{sec:fairness}, we demonstrate the efficacy of our method by using it to train an algorithmically fair income classifier.
In addition, we show how to apply our method to a fairness constrained learning problem and discuss two practical considerations for fair ML application scenarios.
Finally, we summarize our work in Section \ref{sec:summary} and point out an interesting avenue of future work.
\subsection{Related work}
The closest work to our work is \cite{lam2019Recovering}.
They seek to pick a (data-dependent) \emph{uncertainty set} $\mathcal{U}$ such that
\begin{equation}
\lim_{n\to\infty}\mathbb{P}\left\{\sup\nolimits_\theta\left\{\mathbb{E}_{P_0}\big[g(\theta;Z)\big] - \sup\nolimits_{P\in\mathcal{U}}\mathbb{E}_P\big[g(\theta;Z)\big]\right\} \leq 0\right\} = 1-\alpha.
\label{eq:uniform-converage}
\end{equation}
This condition is stronger than necessary: we only require
\begin{equation}
\lim_{n\to\infty}\mathbb{P}\left\{\mathbb{E}_{P_0}\big[g(\widehat{\theta}_n;Z)\big] - \sup\nolimits_{P\in\mathcal{U}}\mathbb{E}_P\big[g(\widehat{\theta}_n;Z)\big] \leq 0\right\} =1-\alpha
\end{equation}
where $\widehat{\theta}_n$ is a (data-dependent) estimator (not necessarily \eqref{eq:SAA-single-expected-value-constraint} or \eqref{eq:robust-SAA-single-expected-value-constraint}).
\cite{lam2019Recovering} study (asymptotic) constraint satisfaction \eqref{eq:asymptotically-exact-constraint-satisfaction} for all deterministic objective functions (see \cite{lam2019Recovering}, \S 1.1 for details).
They advocate picking a KL divergence ball with radius that depends on the excursion probability of a certain $\chi^2$ process.
Another closely related line of work is on data-splitting approaches for ensuring constraint generalization \cite{woodworth2017Learning,cotter2018Training}. At a high level, they split the training data into a training and validation subsets and use the validation subset to tune models trained on the training subset so that they satisfy the constraints. Although (computationally) simple and intuitive, their approach does not allow users to precisely control the constraint violation probability.
\cite{lam2019Recovering} is the latest in a line of work on distributionally robust optimization (DRO) that show the optimal value of DRO problems
\begin{equation}
\min\nolimits_{\theta\in\Theta}\sup\nolimits_{P\in\mathcal{U}}\mathbb{E}_P\big[g(\theta;Z)\big],
\label{eq:DRO}
\end{equation}
where $\mathcal{U}$ is a (data-dependent) uncertainty set of probability distributions, are upper confidence bounds for the optimal values of stochastic optimization problems. Common choices of uncertainty sets in DRO include uncertainty sets defined by moment or support constraints \cite{chen2007Robust,delage2010Distributionally,goh2010Distributionally}, $\varphi$-divergences \cite{ben-tal2012Robust,lam2015Quantifying,namkoong2016Stochastic}, and Wasserstein distances \cite{shafieezadeh-abadeh2015Distributionally,blanchet2016Robust,esfahani2015Datadriven,lee2017Minimax,sinha2017Certifying}. This line of work is motivated by Owen's seminal work on empirical likelihood \cite{owen1990Empirical}. In recent work, \cite{lam2015Quantifying,duchi2016Statistics} show that the optimal value of DRO problems with empirical likelihood uncertainty sets leads to asymptotically exact upper confidence bounds for the optimal value of stochastic optimization problems (\cite{duchi2016Statistics} consider more general $\varphi$-divergence uncertainty sets). \cite{blanchet2016Robust} establish similar coverage results for Wasserstein uncertainty sets.
Our work is also closely related to the work on the variance regularization properties of DRO \cite{namkoong2016Stochastic}, which uses DRO to approximate the variance regularization cost function (see \eqref{eq:variance-regularization-DRO-approximation}). \cite{gao2017Robust} establish similar results for Wasserstein DRO.
Lastly, we relate our work to the literature on chance constrained optimization (see \cite{jiang2016data} and the references therein). The general goal of chance constrained optimization is to minimize a loss function subject to the probability of satisfying uncertain constraints is above a prescribed level. While our methods reformulate expected value constraints and we show that the solution of the reformulated problem enjoys an asymptotically exact probabilistic guarantees of constraint satisfaction. In addition, the data-dependent constraints in our work are also unknown in practice, which differs from the common setup in the chance constrained optimization literature.
\section{Single expected value constraint}
\label{sec:single-expected-value-constraint}
We motivate \eqref{eq:robust-SAA-single-expected-value-constraint} by considering a few alternatives. First, we note that the results later in this section show that \eqref{eq:SAA-single-expected-value-constraint} violates the actual constraint in \eqref{eq:single-expected-value-constraint} approximately half the time (see corollary \ref{cor:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction}). The most straightforward modification of \eqref{eq:SAA-single-expected-value-constraint} to ensure $\widehat{\theta}_n$ satisfies the (actual) constraint $\mathbb{E}_{P_0}\big[g(\theta;Z)\big] \leq 0$ is to add a ``margin'' in \eqref{eq:robust-SAA-single-expected-value-constraint}; {\it i.e.}\ enforce the constraint
\begin{equation}\textstyle
\frac1n\sum_{i=1}^n g(\theta;Z_i) + {\epsilon}_n\le 0
\label{eq:uniform-margin-constraint}
\end{equation}
in \eqref{eq:SAA-single-expected-value-constraint}. If we pick the slack term ${\epsilon}_n$ such that
\[\textstyle
\mathbb{P}\left\{\sup\nolimits_{\theta\in\Theta}\left\{\mathbb{E}_{P_0}\big[g(\theta;Z)\big] - \frac1n\sum_{i=1}^n g(\theta;Z_i)\right\} > {\epsilon}_n\right\} \leq \alpha,
\]
then it is not hard to check that the resulting $\widehat{\theta}_n$ satisfies the (actual) constraint with probability greater than $1-\alpha$ \cite{wang2008Sample,luedtke2008Sample}. However, this approach is most likely conservative because the constraint is unnecessarily stringent for $\theta$'s such that $\frac1n\sum_{i=1}^ng(\theta;Z_i)$ is less variable. It is also not pivotal: ${\epsilon}_n$ is often set using bounds from (uniform) concentration inequalities, which typically depend on unknown problem parameters.
To relax the empirical constraint in a way that adapts to the variability of the empirical constraints, we replace the uniform margin in \eqref{eq:uniform-margin-constraint} with a parameter-dependent margin:
\begin{equation}\textstyle
\frac1n\sum_{i=1}^n g(\theta;Z_i) + z_\alpha\frac{\widehat{\bsigma}(\theta)}{\sqrt{n}}\le 0,
\label{eq:parameter-dependent-margin-constraint}
\end{equation}
where $z_\alpha$ is the $1-\alpha$ quantile of a standard normal random variable and $\widehat{\bsigma}^2(\theta)$ is an estimate of the asymptotic variance of $g(\theta;Z)$. We recognize the (parameter-dependent) margin as (a multiple of) the standard error of the empirical constraint. It is possible to show that enforcing \eqref{eq:parameter-dependent-margin-constraint} achieves asymptotically exact constraint generalization \eqref{eq:asymptotically-exact-constraint-satisfaction} \cite{lam2019Recovering}.
The main issue with this method is it is not amenable to standard stochastic optimization algorithms. In particular, even if the original constraint in \eqref{eq:SAA-single-expected-value-constraint} is convex, \eqref{eq:parameter-dependent-margin-constraint} is generally non-convex.
Another issue is that it is not pivotal: the user must estimate the asymptotic variance of $g(\theta;Z)$.
To overcome these two issues, we consider a distributionally robust version of \eqref{eq:SAA-single-expected-value-constraint}; {\it i.e.}\ enforcing
\begin{equation}
\sup\nolimits_{P:D_\varphi(P\| \widehat{P}_n)\leq\frac{\rho_\alpha}{n}}\mathbb{E}_P\big[g(\theta;Z)\big] \leq 0,
\label{eq:DRO-constraint}
\end{equation}
where $D_\varphi(P\|Q) \triangleq \int\varphi(\frac{dP}{dQ})dQ$ is a $\varphi$-divergence. Common choices of $\varphi$ include $\varphi(t) = (t-1)^2$ (which leads to the $\chi^2$-divergence) and $\varphi(t) = -\log t + t-1$ (which leads to the Kullback-Leibler divergence).
Although there are many other choices for the uncertainty set in \eqref{eq:DRO-constraint}, we pick an $\varphi$-divergence ball because (i) \eqref{eq:DRO-constraint} with an $\varphi$-divergence ball is asymptotically equivalent to \eqref{eq:parameter-dependent-margin-constraint}:
\begin{equation}
\sup\nolimits_{P:D_\varphi(P\| \widehat{P}_n)\le\frac{\rho_\alpha}{n}}\mathbb{E}_P\big[g(\theta;Z)\big] \textstyle\approx \frac1n\sum_{i=1}^n g(\theta;Z_i) + z_{\alpha}\frac{\widehat{\bsigma}(\theta)}{\sqrt{n}},
\label{eq:variance-regularization-DRO-approximation}
\end{equation}
and (ii) it leads to pivotal uncertainty sets. For theoretical analysis, we always use $\varphi(t) = (t-1)^2$ and $\chi^2$-divergence in the remainder of this paper.
Before we state the asymptotically exact constraint satisfaction property of \eqref{eq:robust-SAA-single-expected-value-constraint} rigorously, we describe our assumptions on the problem.
\begin{enumerate}
\item \textbf{smoothness and concentration:} $f$ and $g$ are twice continuously differentiable with respect to $\theta$, and $f(\theta^\star;Z)$, $\nabla f(\theta^\star;Z)$, $g(\theta^\star;Z)$, $\nabla g(\theta^\star;Z)$ are sub-Gaussian random variables.
\item \textbf{uniqueness:} the stochastic optimization problem with a single expected value constraint \eqref{eq:single-expected-value-constraint} has a unique optimal primal-dual pair $(\theta^\star,\lambda^\star)$, and $\theta^\star$ belongs to the interior of the compact set $\Theta$.
\item \textbf{strict complementarity:} $\lambda^\star > 0$.
\item \textbf{positive definiteness:} The Hessian of the Lagrangian evaluated at $(\theta^\star,\lambda^\star)$ is positive definite.
\end{enumerate}
The preceding assumptions are not the most general, but they are easy to interpret. The smoothness conditions on $f$ and $g$ with respect to $\theta$, the concentration conditions of $f(\theta^\star;Z)$ and $g(\theta^\star;Z)$, and the uniqueness condition facilitate the use of standard tools from asymptotic statistics to study the large sample properties of the constraint value. The strict complementarity condition rules out problems in which the constraint is extraneous; {\it i.e.}\ problems in which the unconstrained minimum coincides with the constrained minimum.
We are ready to state the asymptotically exact constraint satisfaction property of \eqref{eq:robust-SAA-single-expected-value-constraint} rigorously. The main technical result characterizes the limiting distribution of the constraint value.
\begin{theorem}
\label{thm:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction}
Let $\widehat{\theta}_n$ be an optimal solution of \eqref{eq:robust-SAA-single-expected-value-constraint} converging in probability as $n\to\infty$ to $\theta^\star$. Under the standing assumptions, we have
\begin{equation*}
\sqrt{n}\left(\mathbb{E}_{P_0}\big[g(\widehat{\theta}_n;Z)\big] - \cancel{\mathbb{E}_{P_0}\big[g(\theta^\star;Z)\big]}\right) \overset{d}{\to} \mathcal{N}\left(-\sqrt{\rho_\alpha\operatorname{Var}_{P_0}[g(\theta^\star;Z)]},\operatorname{Var}_{P_0}[g(\theta^\star;Z)]\right).
\end{equation*}
\end{theorem}
We translate this result on the constraint value to a result on constraint generalization.
\begin{corollary}
\label{cor:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction}
Let $\sqrt{\rho_\alpha}$ be the $1-\alpha$ quantile of a standard normal random variable. Under the conditions of theorem \ref{thm:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction}, we have
\[
\lim_{n\to\infty}\mathbb{P}\left\{\mathbb{E}_{P_0}\big[g(\widehat{\theta}_n;Z)\big] \leq 0\right\} = \mathbb{P}\left\{U \leq \sqrt{\rho_\alpha}\right\} = 1-\alpha,
\]
where $U\sim\mathcal{N}(0,1)$ is a standard Gaussian random variable.
\end{corollary}
From theorem \ref{thm:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction} and corollary \ref{cor:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction} (see proofs in Appendix \ref{sec:proofs-for-section-2}), we find that \begin{enumerate}
\item picking $\rho_\alpha = 0$ ({\it i.e.}, equivalently solving \eqref{eq:SAA-single-expected-value-constraint}) leads to a constraint violation probability that approaches $\frac12$ in the large sample limit.
\item the relation between the mean and variance of the limiting distribution of the constraint value in Theorem \ref{thm:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction} allows us to pick $\rho_\alpha$ in a pivotal way ({\it i.e.}\ does not depend on nuisance parameters).
\end{enumerate}
\subsection{Stochastic approximation for \eqref{eq:robust-SAA-single-expected-value-constraint}}
In the rest of this section, we derive a stochastic optimization algorithm to solve \eqref{eq:robust-SAA-single-expected-value-constraint} efficiently. As we shall see, the computational cost of this algorithm is comparable to the cost of solving a DRO problem. The key insight is that the robust constraint function has a dual form (see Appendix \ref{sec:standard-dro-dual}):
\begin{equation}
\sup\nolimits_{P:D_\varphi(P\| \widehat{P}_n)\leq\rho}\mathbb{E}_P\big[g(\theta;Z)\big] \textstyle=\inf\nolimits_{\mu\ge 0,\nu\in\mathbb{R}}\left\{\frac1n\sum_{i=1}^n \mu\varphi^*\big(\frac{g(\theta;Z_i) - \nu}{\mu}\big) + \mu\rho + \nu\right\},
\label{eq:robust-expected-value-constraint-dual-form}
\end{equation}
where $\varphi^*(s) \triangleq \sup\nolimits_t \{st - \varphi(t)\}$ is the convex conjugate of $\varphi$. As we use $\chi^2$-squared divergence and $\varphi(t) = (t-1)^2$, the corresponding $\varphi^*(s) = \frac{s^2}{4} + s$. The Lagrangian of \eqref{eq:robust-SAA-single-expected-value-constraint} is
\[
\begin{aligned}
L(\theta,\lambda) &\textstyle\triangleq \frac1n\sum_{i=1}^n f(\theta;Z_i) + \lambda \sup\nolimits_{P:D_\varphi(P\| \widehat{P}_n)\leq\frac{\rho_\alpha}{n}}\mathbb{E}_P\big[g(\theta;Z)\big] \\
&\textstyle=\frac1n\sum_{i=1}^n f(\theta;Z_i) + \lambda\textstyle\inf\nolimits_{\mu\ge 0,\nu\in\mathbb{R}}\left\{\frac1n\sum_{i=1}^n\mu\varphi^*\big(\frac{g(\theta;Z_i) - \nu}{\mu}\big) + \mu\frac{\rho_\alpha}{n} + \nu\right\}.
\end{aligned}
\]
We see that evaluating the dual function $\inf_\theta L(\theta,\lambda)$ (at a fixed $\lambda$) entails solving a stochastic optimization problem that is suitable for stochastic approximation.
This suggests a dual ascent algorithm for solving \eqref{eq:robust-SAA-single-expected-value-constraint}:
\begin{enumerate}
\item evaluate the dual function at $\lambda_t$ by solving a stochastic optimization problem.
\item update $\lambda_t$ with a dual ascent step.
\end{enumerate}
We summarize this algorithm in Algorithm \ref{alg:robust-SAA-single-expected-value-constraint}. The main cost of Algorithm \ref{alg:robust-SAA-single-expected-value-constraint} is incurred in the third line: evaluating the dual function. Fortunately, this step is suitable for stochastic approximation, so we can leverage recent advances in the literature to reduce the (computational) cost of this step. The total cost of this algorithm is comparable to that of distributionally robust optimization.
\begin{algorithm*}
\caption{Dual ascent algorithm for \eqref{eq:robust-SAA-single-expected-value-constraint}}
\label{alg:robust-SAA-single-expected-value-constraint}
\begin{algorithmic}[1]
\State {\bfseries Input:} starting dual iterate $\lambda_0 \ge 0$
\Repeat
\State Evaluate dual function: \[\textstyle\quad~~(\theta_t,\mu_t,\nu_t) \gets {\arg\min}_{\theta,\mu\ge 0,\nu}\frac1n\sum_{i=1}^n f(\theta;Z_i) + \lambda_t\left\{\textstyle\frac1n\sum_{i=1}^n\mu\varphi^*\big(\frac{g(\theta;Z_i) - \nu}{\mu}\big) + \mu\frac{\rho_\alpha}{n} + \nu\right\}\]
\State Dual ascent update: $\lambda_{t+1} \gets \left[\lambda_t + \eta_t\left\{\textstyle\frac1n\sum_{i=1}^n\mu_t\varphi^*(\frac{g(\theta_t;Z_i) - \nu_t}{\mu_t}) + \mu_t\frac{\rho_\alpha}{n} + \nu_t\right\}\right]_+$
\Until{converged}
\end{algorithmic}
\end{algorithm*}
\section{Multiple expected value constraints}
\label{sec:multiple-expected-value-constraints}
In this section, we extend the results from the preceding section to stochastic optimization problems with multiple data-dependent constraints. Consider a stochastic optimization problem with $K$ expected value constraints
\begin{equation}
\theta^\star\in\left\{\begin{aligned}
&{\arg\min}_{\theta\in\Theta} &&\mathbb{E}_{P_0}\big[f(\theta;Z)\big] \\
&\textrm{subject to} &&\left\{\mathbb{E}_{P_0}\big[g_k(\theta;Z)\big] \leq 0\right\}_{k=1}^K
\end{aligned}\right\},
\label{eq:multiple-expected-value-constraint}
\end{equation}
Following the development in Section \ref{sec:single-expected-value-constraint}, we enforce the expected value constraints with robust versions of the sample average constraints:
\begin{equation}
\widehat{\theta}_n\in\left\{\begin{aligned}
&{\arg\min}_{\theta\in\Theta} &&\textstyle\frac1n\sum_{i=1}^nf(\theta;Z_i) \\
&\textrm{subject to} &&\left\{\sup\nolimits_{P:D_\varphi(P\| \widehat{P}_n)\le\frac{\rho_k}{n}}\mathbb{E}_P\big[g_k(\theta;Z)\big] \le 0\right\}_{k=1}^K
\end{aligned}\right\},
\label{eq:robust-SAA-multiple-expected-value-constraint}
\end{equation}
where ${\boldsymbol\rho} = (\rho_1,\dots,\rho_K)^\top$ are uncertainty set radii for the constraints.
There are other approaches to enforcing multiple constraints that result in constraint generalization; we focus on \eqref{eq:robust-SAA-multiple-expected-value-constraint} here because it allows the user to adjust the constraint generalization probability for different constraints.
First, we extend theorem \ref{thm:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction} and corollary \ref{cor:robust-SAA-single-expected-value-constraint-asymptotically-exact-constraint-satisfaction} to problems with multiple (expected value) constraints.
We assume
\begin{enumerate}
\item \textbf{smoothness and concentration:} for $k\in [K]$, $f, g_k$ are twice continuously differentiable with respect to $\theta$, and $f(\theta^\star;Z), \nabla f(\theta^\star;Z)$, $g_k(\theta^\star;Z),\nabla g_k(\theta^\star;Z)$ are sub-Gaussian random variables.
\item \textbf{uniqueness:} the stochastic optimization problem with $K$ expected value constraints \eqref{eq:multiple-expected-value-constraint} has a unique optimal primal-dual pair $(\theta^\star,{\boldsymbol\lambda}^
\star)$, and $\theta^\star$ belongs to the interior of the compact set $\Theta$.
\item \textbf{strict complementarity:} ${\boldsymbol\lambda}^\star\in\operatorname{int}(\mathbb{R}_+^K)$, {\it i.e.}, each component of ${\boldsymbol\lambda}^\star$ is strictly positive.
\item \textbf{positive definiteness:} The Hessian of the Lagrangian evaluated at $(\theta^\star,{\boldsymbol\lambda}^\star)$ is positive definite.
\end{enumerate}
The strict complementarity constraint seems especially strong here because it requires all the constraints to be active. It is possible (with extra notational overhead) to state the result in terms of just the active constraints.
We refer to Section \ref{sec:unknown-active-set} for more information about the unknown active set.
Further, as long as the sample size is large enough, the active constraints in \eqref{eq:robust-SAA-multiple-expected-value-constraint} coincide with the active constraints in \eqref{eq:multiple-expected-value-constraint}. To keep things simple, we assume all the constraints are active.
\begin{theorem}
\label{thm:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}
Let $\widehat{\theta}_n$ be an optimal solution of \eqref{eq:robust-SAA-multiple-expected-value-constraint} converging in probability as $n\to\infty$ to $\theta^\star$. Under the standing assumptions, we have
\[
\sqrt{n}\begin{bmatrix}\mathbb{E}_{P_0}\big[g_1(\widehat{\theta}_n;Z)\big] \\ \vdots \\ \mathbb{E}_{P_0}\big[g_K(\widehat{\theta}_n;Z)\big]\end{bmatrix} \overset{d}{\to} \mathcal{N}\left(-\begin{bmatrix}\sqrt{\rho_1\operatorname{Var}_{P_0}[g_1(\theta^\star;Z)]} \\ \vdots \\ \sqrt{\rho_K\operatorname{Var}_{P_0}[g_K(\theta^\star;Z)]}\end{bmatrix},\operatorname{Var}_{P_0}\begin{bmatrix}g_1(\theta^\star;Z)\\ \vdots \\ g_K(\theta^\star;Z)\end{bmatrix}\right).
\]
\end{theorem}
\begin{corollary}
\label{cor:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}
Under the conditions of theorem \ref{thm:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction}, we have
\[
\lim_{n\to\infty}\mathbb{P}\left\{\begin{bmatrix}\mathbb{E}_{P_0}\big[g_1(\widehat{\theta}_n;Z)\big] \\ \vdots \\ \mathbb{E}_{P_0}\big[g_K(\widehat{\theta}_n;Z)\big]\end{bmatrix} \in -\mathbb{R}_+^K\right\} = \mathbb{P}\{\boldsymbol{U} \le \sqrt{{\boldsymbol\rho}}\},
\]
where $\sqrt{{\boldsymbol\rho}} = (\sqrt{\rho_1}, \ldots, \sqrt{\rho_K})^\top$, and $\boldsymbol{U}$ is a Gaussian random vector with mean zero and covariance
\begin{equation}
\begin{aligned}
\operatorname{Corr}_{P_0}\begin{bmatrix}g_1(\theta^\star;Z)\\ \vdots \\ g_K(\theta^\star;Z)\end{bmatrix} \triangleq D^{-\frac12}\operatorname{Cov}_{P_0}\begin{bmatrix}g_1(\theta^\star;Z)\\ \vdots \\ g_K(\theta^\star;Z)\end{bmatrix}D^{-\frac12}, \\
D \triangleq \operatorname{diag}\left(\{\operatorname{Var}_{P_0}[g_k(\theta^\star,Z)]\}_{k=1}^K\right).
\end{aligned}
\label{eq:constraint-correlation}
\end{equation}
\end{corollary}
From theorem \ref{thm:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction} and corollary \ref{cor:robust-SAA-multiple-expected-value-constraint-asymptotically-exact-constraint-satisfaction} (see proofs in Appendix \ref{sec:proof-thm-3.1} and \ref{sec:proof-cor-3.2}), we find that the probability of constraint satisfaction decreases \emph{exponentially} as the number of constraints increases. We also see that our method is no longer pivotal for multiple expected value constraints: the uncertainty set radii depends on the (unknown) correlation structure among the constraint values.
Fortunately, it is not hard to estimate this correlation structure. The most straightforward way is with the empirical correlation matrix. Let $\widehat{\Sigma}_n$ be the empirical covariance matrix of the constraint values.
The empirical correlation matrix is then given by $\widehat{R}_n \triangleq \operatorname{diag}(\widehat{\Sigma}_n)^{-\frac12}\widehat{\Sigma}_n\operatorname{diag}(\widehat{\Sigma}_n)^{-\frac12}$.
Finally, it is straightforward to extend the algorithm for solving
\eqref{eq:robust-SAA-single-expected-value-constraint} to \eqref{eq:robust-SAA-multiple-expected-value-constraint}. The Lagrangian of \eqref{eq:robust-SAA-multiple-expected-value-constraint} is
\[
\begin{aligned}
L(\theta,{\boldsymbol\lambda}) &\textstyle\triangleq \frac1n\sum_{i=1}^n f(\theta;Z_i) + \sum_{k=1}^K\lambda_k\sup\nolimits_{P:D_\varphi(P\| P_n)\leq\frac{\rho_k}{n}}\mathbb{E}_P\big[g_k(\theta;Z)\big] \\
&\textstyle=\frac1n\sum_{i=1}^nf(\theta;Z_i) + \sum_{k=1}^K\lambda_k\textstyle\inf\nolimits_{\mu_k\ge 0,\nu_k\in\mathbb{R}}\left\{\frac1n\sum_{i=1}^n\mu_k\varphi^*(\frac{g_k(\theta;Z_i) - \nu_k}{\mu_k}) + \mu_k\frac{\rho_k}{n} + \nu_k\right\},
\end{aligned}
\]
where we recalled the dual form of the robust constraint function \eqref{eq:robust-expected-value-constraint-dual-form} in the second step. We see that evaluating the dual function $\inf_\theta L(\theta,{\boldsymbol\lambda})$ (at a fixed ${\boldsymbol\lambda}$) entails solving a stochastic optimization problem that is suitable for stochastic approximation. This suggests a similar dual ascent algorithm for solving \eqref{eq:robust-SAA-single-expected-value-constraint}; we skip the details here (see Algorithm \ref{alg:robust-SAA-multiple-expected-value-constraint} in Appendix \ref{sec:dual-ascent-multiple-constraints}).
\section{Simulations}
\label{sec:simulation}
We simulate the frequency of constraint satisfaction for the following multi-item newsvendor problem:
\begin{equation}
\label{eq:maximization-problem-multi-item-newsvendor}
\begin{array}{ll}
\max_{\theta\in\Theta} & \mathbb{E}_{P_0} \big[p^\top \min \{Z, \theta\}- c^\top\theta\big] \\
\textrm{subject to} & \mathbb{E}_{P_0}[(\|Z^{(1)}\|_2^2-\|\theta^{(1)}\|_2^2)_{+}] \leq \varepsilon_1 \\
& \mathbb{E}_{P_0}[(\|Z^{(2)}\|_2^2-\|\theta^{(2)}\|_2^2)_{+}] \leq \varepsilon_2 \\
\end{array}
\end{equation}
where $c \in \mathbb{R}^d_{+}$ is the manufacturing cost, $p \in \mathbb{R}^d_{+}$ is the sell price, $\theta \in \Theta = [0,100]^d$ is the number of items in stock, $Z\in\mathbb{R}^d$ is a random variable with probability distribution $P_0$ representing the demand, and there are $d$ items in total. The distribution $P_0$ is unknown but we observe IID samples $Z_1,\ldots,Z_n$ from $P_0$. All of the items have been partitioned into two groups so that the corresponding demand and stock can be written as $Z = (Z^{(1)}, Z^{(2)})$ and $\theta = (\theta^{(1)}, \theta^{(2)})$. The constraints in the problem exclude stock levels that underestimate the demand too much for each group of items, where $\varepsilon_1,\varepsilon_2 > 0$ indicate tolerance level of such underestimation. The target of the problem is to maximize the profit while satisfying the constraints. It is easy to rewrite the maximization problem \eqref{eq:maximization-problem-multi-item-newsvendor} as a minimization problem with expected value constraints in the form of \eqref{eq:multiple-expected-value-constraint} so that we can apply our method \eqref{eq:robust-SAA-multiple-expected-value-constraint}. We pick $P_0$ as multivariate Gaussian with independent components so that the two constraints are generally uncorrelated with each other (see Appendix \ref{sec:details-simulations} for details).
Throughout the simulations, we solve \eqref{eq:robust-SAA-multiple-expected-value-constraint} with ${\boldsymbol\rho} = (z_\alpha, z_\alpha)^\top$ for $\alpha \in \{0.4, 0.25, 0.1, 0.05, 0.005\}$. As suggested by our asymptotic theory in Section \ref{sec:multiple-expected-value-constraints}, the nominal probability of constraint satisfaction is $1-\alpha$ for each constraint and $(1-\alpha)^2$ for both constraints due to the independence setup.
In Figure \ref{fig:1}, we plot frequencies of constraint satisfaction for each constraint and both constraints, all of which are averaged over $1000$ replicates. As the sample size $n$ grows, the frequency versus probability curve converges to the theoretical dashed line of limiting probability of constraint satisfaction, validating our theory in the large sample regime. For more simulations ({\it e.g.}, single constraint, two dependent constraints) we refer to Appendix \ref{sec:details-simulations}.
\begin{figure}[h]
\centering
\begin{minipage}{0.32\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/multi_qq_1.pdf}
\end{minipage}
\begin{minipage}{0.32\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/multi_qq_2.pdf}
\end{minipage}
\begin{minipage}{0.32\textwidth}
\centering
\includegraphics[width=1\linewidth]{figures/multi_qq_3.pdf}
\end{minipage}
\caption{Frequency versus limiting probability of constraint satisfaction of the first constraint (left), the second constraint (middle), and both of the constraints (right). }
\label{fig:1}
\end{figure}
\section{Summary and discussion}
\label{sec:summary}
We explore the problem of exact constraint satisfaction probability in stochastic optimization with expected-value constraints.
We propose a distributionally robust reformulation of data-dependent constraints and provide a theoretical guarantee of constraint satisfaction with an asymptotically exact probability specified by the user.
For solving the reformulated problem, a scalable dual ascent algorithm and its variants are proposed.
The computational cost of our algorithm is comparable to that of a standard distributionally robust optimization problem.
Our theory on exact constraint satisfaction probability is validated via simulations on the resource-constrained newsvendor problem.
The efficacy of our methods is empirically demonstrated on fair machine learning applications.
Some data-dependent constraints are by nature \emph{non-linear} in the underlying probability measure.
For example, \eqref{eq:ratio-of-expected-values} is a ratio of expected values.
An intriguing direction for future research is to generalize the methods and theory developed in this work to constraints on non-linear functions of expected values.
Such forms of constraints are known as \emph{statistical functionals} in statistics literature \citep{fernholz2012mises}.
The non-linear dependence of the constraint function on the probability measure precludes the stochastic approximation as a general way of evaluating the dual function, as the constraint function no longer admits a dual form \eqref{eq:robust-expected-value-constraint-dual-form}, calling for the development of a new algorithm.
| {'timestamp': '2023-01-18T02:15:25', 'yymm': '2301', 'arxiv_id': '2301.06195', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06195'} | arxiv |
\section{Introduction}\label{sec:introduction}}
\else
\section{Introduction}
\label{sec:introduction}
\fi
\IEEEPARstart{T}{he} rich spectral
information of hyperspectral (HS) images towards real-world scenes/objects has facilitated applications
in numerous fields, such as military \cite{shimoni2019hypersectral}, agriculture \cite{park2015hyperspectral}, and marine monitoring \cite{Zhong2005Absorption}.
In recent years,
owing to the powerful representational ability, a considerable number of deep learning-based methods for HS image processing and analysis have been proposed,
where one fundamental and crucial issue is \textit{how to embed the high-dimensional spatial-spectral information of HS images effectively and efficiently}.
Generally, most of existing works extract spatial-spectral features of HS images by applying 2-D conventional filters with multiple channels on each cube slice separately \cite{Chang2019HSI,Jiang2020Learning,Cao2021Deep}, 3-D conventional filters to simultaneously convolve in spatial and spectral domains \cite{Mei2017Hyperspectral,Zhang2019Hybrid,hamida20183}, or a 2-D and 3-D conventional filters combined network \cite{Yuan2019Hyperspectral,wang2021hyperspectral}.
However, these empirically designed feature extraction/embedding modules are hard to provide quantitative instructions for network designing and may be not optimal, thus limiting performance.
Besides, most of them tend to stack off-the-shelf modules to build complicated and large-capacity networks for pursuing high performance, such as multi-scale strategy \cite{Yuan2019Hyperspectral,he2019feature,Zhang2019Hybrid,Shi2021Hyperspectral,wan2022a}, attention mechanism \cite{Shi2021Hyperspectral,zhu2021residual,paoletti2022multiple}, and atrous convolution \cite{Liu2019A,Shi2021Hyperspectral}.
Unlike existing works, we tackle this fundamental problem from the perspective of
enhancing feature diversity that has demonstrated the importance to the performance of downstream applications \cite{zhang2018diverse,yang2022diversity}.
Specifically, starting from 3D convolution, the intuitive choice for modeling HS images, we theoretically quantify the diversity of features with the rank of the 2-D matrix,
enabling us to boil the problem of learning diverse spatio-spectral representations down to boosting the upper bound of the rank of the matrix formed by the convolution kernels.
We then ingeniously modify the network topology, naturally yielding our rank-enhanced spatial-spectral symmetrical convolution set (ReS$^3$-ConvSet)
which is able to learn diverse spatial-spectral features and further save network parameters.
Besides, we also propose a novel diversity-aware regularization (DA-Reg)
term, which directly optimizes the distribution of the singular values of the 2-D matrix formed by features
for promoting diversity.
\if 0
In contrast to existing works, we address this issue \JHdel{aim to embed the high-dimensional spatial-spectral information of HS images both efficiently and effectively} via theoretical analysis.
Specifically, we first figure out the bottleneck that limits feature diversity by means of matrix rank analysis.
Under the guidance of the theoretical analysis, motivating us to propose ReS$^3$-ConvSet, which separately performs 1-D convolution along the three dimensions of an HS image side-by-side, and then aggregates the resulting spatial-spectral embeddings via a compression layer. During feature extraction process, such a manner improves the upper bound of the rank of the matrix formed by the convolution kernels involved in ReS$^3$-ConvSet to promote diverse features which are expected to be beneficial to HS image-based tasks. Meanwhile, ReS$^3$-ConvSet reduces the number of network parameters.
In addition to explicitly promoting the upper limit rank of kernel matrix at network-level, we further introduce a novel feature diversity promotion regularization term \JHdel{, named DA-Reg,} to encourage the feature diversity via balancing the singular values of corresponding feature matrix.
\fi
Finally, based on the proposed ReS$^3$-ConvSet and DA-Reg,
we construct three learning-based frameworks for
HS image denoising, spatial super-resolution, and classification to demonstrate their significance.
\if 0
\JHNOTE{Simplify the following three paragraphs into a short paragraph or remove the three paragraphs}
\emph{HS image denoising.}
Due to the limitations of hardware and environment effects (e.g., water absorption and terrible atmosphere), the captured HS images are inevitably corrupted by various noises, which will degrade the performance of downstream HS image-based applications. Therefore, HS image denoising, an ill-posed inverse problem in high-dimensional space, turns to be highly desirable.
To tackle this challenging problem, we realize an \textit{efficient}, \textit{concise}, and \textit{compact} denoising method by incorporating the proposed ReS$^3$-ConvSet and DA-Reg into the widely-used U-Net \cite{ronneberger2015u} architecture.
\emph{HS image spatial super-resolution.}
Due to limited sensor resolution of single-shot HS imaging devices, as well as the inevitable trade-off between the spatial and spectral resolution, the recorded HS images always suffer from lower spatial resolution than traditional RGB images. HS image spatial super-resolution thus becomes another highly desirable task in HS image processing. To tackle such an ill-posed reconstruction
problem, we incorporate our ReS$^3$-ConvSet and DA-Reg into the residual dense network \cite{zhang2021residual} architecture for constructing the HS image spatial super-resolution method.
\emph{HS image classification.}
Land use and land cover classification employing the earth observation data, such as HS images, and synthetic aperture radar, is a very important but challenging topic in remote sensing field.
Due to the high-dimensional characteristic and high spectral mixing between materials, it is difficult for HS classification methods to extract discriminative features from HS data.
To tackle this task, we introduce our ReS$^3$-ConvSet and DA-Reg into the existing HS image classification method \cite{hamida20183}.
\fi
Extensive experiments on commonly used HS image benchmark datasets
demonstrate the significant superiority of the proposed methods over state-of-the-art ones.
In summary, the main contributions of this paper are four-fold:\vspace{-0.3cm
\begin{itemize}
\item
an efficient and effective spatial-spectral feature representation module based on theoretical analysis;
\item a simple yet effective loss promoting feature diversity;
\item comprehensive and quantitative investigations on various
convolution manners for HS images;
\item
new learning-based methods for HS image processing, including HS image denoising, spatial super-resolution, and classification, producing state-of-the-art performance.
\item revealing the importance of feature extraction, which may shed light on deep learning-based HS image processing and analysis.
\end{itemize}
The remainder of the paper is organized as follows. Section~\ref{sec:Re} reviews the existing related works, including HS image denoising, HS image spatial super-resolution, and HS image classification. Section~\ref{sec:proposed} describes our proposed ReS$^3$-ConvSet in detail, which is further incorporated into various HS image processing tasks in Section \ref{sec:application}, including HS image denoising, spatial super-resolution, and classification. In Section~\ref{sec:experiments}, we conduct extensive experiments and comparisons to demonstrate the advantages of the proposed methods, as well as comprehensive ablation studies.
Finally, Section~\ref{sec:con} concludes this paper.
\section{Related Work}
\label{sec:Re}
In this section, we briefly review deep learning-based methods for HS image processing and analysis,
including HS image denoising, spatial super-resolution, and classification. We also refer readers to \cite{Ghamisi2017Advances,li2019deep,peng2022low} for the comprehensive survey on these topics.
\subsection{HS Image Denoising}
\if 0
\JHNOTE{I am thinking whether it is better to remove optimization-based methods to keep consistency with the other two tasks.} We divide existing HS image denoising methods into two categories, i.e., traditional optimization-based methods and deep learning-based methods.
The optimization-based methods generally formulate the HS image denoising as complex optimization problems, relying on the well-designed handcrafted priors, such as non-local similarity \cite{Maggioni2013Nonlocal,Qian2013Hyperspectral,Peng2014Decomposable}, total variation \cite{He2016Total,Wang2018Hyperspectral} and low-rank priors \cite{Zhang2014Hyperspectral,Xie2016Multispectral,Cao2016Robust,Chang2017Hyper,Fan2017Hyperspectral,Chen2018Denoising}. To be specific, Qian \emph{et al.} \cite{Qian2013Hyperspectral} proposed a sparse representation-based method by introducing the nonlocal similarity and spectral-spatial structure of HS imagery. Peng \emph{et al.} \cite{Peng2014Decomposable} presented a novel tensor dictionary learning (TDL) model by taking the non-local similarity in space and global correlation in spectrum into account. He \emph{et al.} \cite{He2016Total} proposed a total variation regularized low-rank matrix factorization (LRTV) method.
Xie \emph{et al.} \cite{Xie2016Multispectral} proposed an intrinsic tensor sparsity regularization (ITSReg) model.
Chang \emph{et al.} \cite{Chang2017Hyper} designed a hyper-Laplacian regularized unidirectional low-rank tensor recovery (LLRT) model.
He \emph{et al.} \cite{he2022non} provided a unified paradigm to fuse spatial non-local similarity and global spectral low-rank properties.
\fi
Recently, a considerable number of deep learning-based methods for HS image denoising have been presented, which improve the restoration quality of traditional optimization-based methods dramatically. For example,
Chang \emph{et al.} \cite{Chang2019HSI} first tackled HS image denoising by a deep neural network, in which the learned 2-D filters with multiple channels were utilized.
Yuan \emph{et al.} \cite{Yuan2019Hyperspectral} designed a novel spatial-spectral network with both 2-D and 3-D convolutional kernels to fully exploit spatial and spectral features.
Liu \emph{et al.} \cite{Liu2019A} presented a 3-D atrous denoising convolution neural network by integrating the atrous convolution operation to enlarge the receptive fields in the spatial and spectral dimensions simultaneously.
Inspired by the separable 3-D spatial-temporal convolution\cite{Qiu2017Learning}, Dong \emph{et al.} \cite{Dong2019Deep} proposed a separable 3-D convolution network to explore spatial-spectral correlations by decomposing 3-D convolution into the concatenation of 2-D spatial convolution and 1-D spectral convolution.
Wei \emph{et al.} \cite{Wei20213D} proposed a 3-D quasi-recurrent neural network (QRNN3D) to simultaneously explore the structural spatio-spectral correlation and global correlation along spectral. Besides, an alternating directional structure was integrated to alleviate the spatiospectral dependence modeling.
Zhang \emph{et al.} \cite{zhang2021lr} constructed a framework by combining the low-rank physical property into a deep convolutional neural network.
Shi \emph{et al.} \cite{Shi2021Hyperspectral} designed a 3-D attention denoising network with two parallel branches, including spatial branch with the position attention module and spectral branch with the channel attention module.
Cao \emph{et al.} \cite{Cao2021Deep} designed a deep spatial-spectral global reasoning network (GRN) to explore the contextual information by combining the local and global spatial-spectral information of HS images.
Rui \emph{et al.} \cite{Rui2021CVPR} presented a data-driven method to capture the general weighting principle of HS image denoising model.
Bodrito \emph{et al.} \cite{Bodrito2021a} proposed a trainable spectral-spatial sparse coding (T3SC) model by employing sparse coding and deep learning.
\subsection{HS Image Spatial Super-resolution}
In recent years, many HS image spatial super-resolution methods \cite{Yuan2017Hyperspectral,Mei2017Hyperspectral,
Jiang2020Learning,Li2020Hyperspectral,Hu2020Hyperspectral,Li2021Exploring,
wang2021hyperspectral,li2022hyperspectral,wang2022hyperspectral,hou2022deep} has been proposed by introducing deep learning techniques in this task, leading to a significant process.
Yuan \emph{et al.} \cite{Yuan2017Hyperspectral} proposed a transfer learning framework for recovering high-spatial-resolution HS images via propagating the knowledge from nature images.
Mei \emph{et al.} \cite{Mei2017Hyperspectral} designed a 3-D full convolution neural network (3DFCNN) to explore the spatial context in adjacent areas and the spectral correlation in adjacent bands simultaneously.
Jiang \emph{et al.} \cite{Jiang2020Learning} proposed a spatial-spectral prior framework, called SSPSR, equipped with grouped convolutions and progressive upsampling strategies.
Li \textit{et al}. \cite{Li2020Hyperspectral} introduced a generative adversarial network into HS image super-resolution, in which 3-D CNN and band attention mechanism were adopted.
Wang \textit{et al}. \cite{wang2021hyperspectral} designed a dual-channel network, where 2-D and 3-D CNN were combined to jointly learn spectrum and feature context.
Hu \textit{et al} \cite{Hu2020Hyperspectral} proposed an intrafusion network with spectral difference, parallel convolution, and intrafusion modules.
In \cite{Li2021Exploring}, the relationship between 2-D and 3-D convolution was explored for enhancing HS image super-resolution.
Li \textit{et al} \cite{li2022hyperspectral} proposed a novel multi-task learning network to jointly tackle the main task (i.e., HS image super-resolution) and the auxiliary task (i.e., RGB image super-resolution).
Wang \textit{et al} \cite{wang2022hyperspectral} presented a recurrent feedback network for capturing the consecutive information among spectral bands via modeling the HS bands in the sequential way.
Hou \textit{et al} \cite{hou2022deep} designed a novel deep posterior distribution-based embedding framework with a set of carefully-defined HS embedding events to extract the high-dimensional spatial-spectral information from the probabilistic perspective.
\subsection{HS Image Classification}
The early works tackle HS image classification by applying conventional machine learning methods, such as support vector machines (SVMs) \cite{melgani2004classification}, random forest (RF) \cite{ham2005investigation}, Gaussian process \cite{bazi2009gaussian}, K-nearest neighbors (KNNs) \cite{ma2010local}, linear discriminant analysis \cite{bandos2009classification}, and principal component analysis (PCA) \cite{licciardi2012linear}. Owing to limited representation capability, these methods are insufficient to handle the complex spatial-spectral information of HS images.
Benefiting from the rapid development of deep learning techniques, many deep learning-based methods for HS image classification have been proposed. Primarily, a considerable number of advanced networks, e.g., stacked autoencoders (SAEs) \cite{chen2014deep}, convolutional neural networks (CNNs) \cite{hu2015deep,chen2016deep,hamida20183,paoletti2019deep}, recurrent neural networks (RNNs) \cite{mou2017deep}, graph convolutional networks (GCNs) \cite{hong2021graph}, generative adversarial networks (GANs) \cite{hang2021classification}, Transformer \cite{hong2022spectralformer}, were employed to improve the HS image classification accuracy. To be specific,
Hu \emph{et al.} \cite{hu2015deep} adopted 1-D CNN.
Chen \emph{et al.} \cite{chen2016deep} and Hamida \emph{et al.} \cite{hamida20183} applied 3-D CNN to extract the spectral-spatial features of HS images.
Paoletti \emph{et al.} \cite{paoletti2019deep} proposed a deep pyramidal residual network to obtain accurate HS image classification utilizing spectral and spatial information.
Mou \emph{et al.} \cite{mou2017deep} presented a novel RNN model for HS image classification by regarding the HS pixels as sequential data.
Hong \emph{et al.} \cite{hong2021graph} introduced a minibatch GCN and investigated CNN and GCN with different fusion approaches.
Hang \emph{et al.} \cite{hang2021classification} designed a multi-task GAN by undertaking reconstruction and classification tasks.
Hong \emph{et al.} \cite{hong2022spectralformer}
proposed a new backbone network based on transformer, named SpectralFormer, focusing on extracting spectral information of HS images.
In addition, many deep learning strategies, e.g., multi-scale \cite{he2019feature,wan2022a}, attention mechanism \cite{zhu2021residual,paoletti2022multiple}, were adopted for pursuing high classification performance.
Wan \emph{et al.} \cite{wan2022a} proposed a unified multi-scale learning framework equipped with a multi-scale spatial-channel attention mechanism and a multi-scale shuffle block.
Paoletti \emph{et al.} \cite{paoletti2022multiple} presented a novel multiple attention-guided capsule network for HS image classification.
\section{Proposed Method}
\label{sec:proposed}
Despite the HS image contains rich information that facilitates subsequent applications, its high-dimensional characteristic enables various possibilities of the feature representation process, thus posing challenges in determining the optimal
one.
Previous studies \cite{Chen2017TrainingGO,wang2020orthogonal} show that improving feature diversity is one of the most promising solutions to overcome network redundancy, thus fully utilizing the model capacity. Thus, we tackle such a fundamental issue from the perspective of promoting the diversity of features via quantitative modeling,
which further guides us to design the efficient yet powerful feature embedding module.
\begin{figure*}[!t]
\centering
\includegraphics[width=1\linewidth]{figures/filter-rank.pdf}\vspace{-0.35cm}
\caption{Illustration of re-permuting the 3-D convolutional kernel set (a) into rank-enhanced spatial-spectral symmetrical patterns with different rank upper-bounds in (\textbf{b}), (\textbf{c}), and (\textbf{d}). Specifically, The colored cubes symbolize the kernel weights, whereas the blank ones represent replenished zeros. (\textbf{a}) the unrolled 3-D convolutional kernel matrix with the kernel size of 3. Meanwhile, (\textbf{b}), (\textbf{c}), and (\textbf{d}) represent to re-permute 3-D convolutional kernel matrix in our rank-enhanced spatial-spectral symmetrical manner with the kernel size of $3\times 3$, $1\times 3$, and $1\times 3$, of which the scaling factors are $3$, $9$, and $3$, individually. }
\label{fig:filter-rank}
\end{figure*}
\subsection{Quantitative Modeling of Feature Diversity}
\label{Sec:diversity}
Let $\mathcal{A}\in\mathbb{R}^{M\times C\times k\times k\times k}$ be the kernel tensor of a typical 3-D convolutional layer with $M$ 3-D kernels of size $k\times k\times k$, where $C$ is the number of input feature channels. By feeding an HS feature map $\mathcal{I}\in \mathbb{R}^{C\times B\times H\times W}$, the 3-D convolutional layer outputs feature map
$\mathcal{F}\in \mathbb{R}^{M\times B'\times H'\times W'}$.
We can equivalently express
the 3-D convolution process in the form of 2-D matrix multiplication \cite{heide2015fast,yanai2016efficient}, i.e.,
\begin{equation}
\label{equ:convmatrix}
\mathbf{F} = \mathbf{A} \cdot \mathbf{I},
\end{equation}
where $\mathbf{F} \in \mathbb{R}^{M \times B'H'W'}$ is the matrix form of
$\mathcal{F}$, $\mathbf{A} \in \mathbb{R}^{M \times k^3C}$ is the kernel matrix derived by flattening each of the 3-D kernels as a row vector and then vertically stacking them together (as illustrated in Fig. \ref{fig:filter-rank}(\textcolor{red}{a})), and $\mathbf{I} \in \mathbb{R}^{k^3C \times B'H'W'}$ denotes the matrix form of $\mathcal{I}$ obtained by iteratively unrolling it along the spatial-spectral directions.
Considering that the rank of a 2-D matrix indicates the independence/freedom of its elements, we analyze the rank of the feature matrix $\mathbf{F}$ to quantitatively measure its diversity.
Specifically, based on the property of matrix multiplication, from Eq. (\ref{equ:convmatrix}), we have
\begin{equation}
\texttt{Rank}(\mathbf{F}) \leq \texttt{min}\{\texttt{Rank}(\mathbf{A}), \texttt{Rank}(\mathbf{I})\},
\end{equation}
where $\texttt{Rank}(\cdot)$ returns the rank of an input 2-D matrix. As the values of $M$ and $C$ are usually at the same level,
we have $M \ll k^3C \ll B'H'W'$, resulting in
$\texttt{Rank}(\mathbf{F})\leq M$.
Therefore, relieving the upper bound of $\texttt{Rank}(\mathbf{F})$, which is fundamentally limited by that of $\texttt{Rank}(\mathbf{A})$,
is the prerequisites to promote the learning of diverse and powerful features.
To this end, we propose to raise the upper bound of $\texttt{Rank}(\mathbf{A})$ by altering the network topology directly, i.e., structure-level feature diversity enhancement (Section \ref{Sec:ReConv}).
Besides, considering that a large proportion of kernel weights tend to converge to a marginal set of principal components during back-propagation \cite{denil2013predicting,shang2016understanding,Lin2020HRank},
we further explicitly regularize the feature matrix $\mathbf{F}$ to make it deviate from an approximately low-rank one, i.e., content-level feature diversity enhancement (Section \ref{Sec:Rankloss}).
\subsection{Structure-level Feature Diversity Enhancement} %
\label{Sec:ReConv}
As shown in Fig. \ref{fig:filter-rank} (\textcolor{red}{a}), the convolutional kernels contained in a typical 3-D convolutional layer is flattened into a fat 2-D matrix
$\mathbf{A} \in \mathbb{R}^{M \times k^3C}$,
the rank of which is upper bounded by $M$.
Generally, we relieve such a limitation by permuting the elements of $\mathbf{A}$ into a larger 2-D matrix with a higher rank upper bound, which can be further realized by a typical convolution manner.
Note that as the three dimensions of HS images are equally essential \cite{Liu2019A,zhang2016simultaneous}, we process the three dimensions indiscriminately to ensure that an identical convolution pattern could be finally applied to the three dimensions (i.e., the symmetry property).
Technically, we first construct a larger kernel matrix $\mathbf{A}_{a} \in \mathbb{R}^{3LM \times k^3C}$ by scaling up the number of channels by $3L$ ($L$ is a positive integer), i.e., each of the three dimensions is equipped with $LM$ channels. Accordingly, we can rewrite the convolution process as
\begin{equation}
\begin{split}
\label{equ:rankenchance-conv}
\mathbf{F}_{a} = \mathbf{A}_{a} \cdot \mathbf{I}~~~{\rm with}~~
\mathbf{A}_{a} = [\mathbf{A}_{a}^{1};\mathbf{A}_{a}^{2};\mathbf{A}_{a}^{3}],
\end{split}
\end{equation}
where $\mathbf{F}_{a}\in \mathbb{R}^{3LM \times B'H'W'}$ denotes the resulting feature volume, and $\{\mathbf{A}_{a}^{i}\in \mathbb{R}^{LM \times k^3C}\}_{i=1}^3$ are the kernel matrices corresponding to the three dimensions of HS images.
We expect that $\mathbf{A}_a$ corresponds a typical convolution manner with the number of parameters not exceeding that of 3D convolution (i.e., the number of elements in $\mathbf{A}$), which requires that $\mathbf{A}_a$ has to be replenished with a certain number of zeros. Moreover, we obtain that the maximum number of parameters involved in each convolutional kernel is $\frac{k^3C}{3L}$.
Besides, we expect that resulting kernel matrix $\mathbf{A}_a$ can be easily realized by commonly used convolution patterns. More specifically, we select the widely disseminated \textit{regular} 1-D/2-D convolution as the desired alternatives.
In the following we take the case that $k=3$ ($k^3=27$ and $\frac{k^3C}{3L}=\frac{9C}{L}$) as an example for convenience. A larger convolutional kernel could be approximated by sequentially aggregating multiple layers with small kernels.
\if 0
(\textbf{1})
the permuted kernel matrix can be easily realized by commonly used convolution patterns.
\fi
\if 0
and (\textbf{2}) no extra network parameters will be introduced.
Besides, since a larger convolutional kernel could be approximated by sequentially aggregating multiple layers with small kernels, here we only discuss the case that $k$ is equal to 3 ($k^3=27$).
Technically, we scale up the number of channels with a factor of $3L$ ($L$ is a positive integer), producing totally $3LM$ channels, which can be equally partitioned and allocated to the three dimensions.
\JHdel{Let $\mathbf{A}_{a} \in \mathbb{R}^{3LM \times 27C}$ be the resulting upscaled sparse kernel matrix, composed of convolutional weights replenished with zeros.}
We can re-write the convolution process as
\begin{equation}
\begin{split}
\label{equ:rankenchance-conv}
\mathbf{F}_{a} = \mathbf{A}_{a} \cdot \mathbf{I}~~~{\rm with}~~
\mathbf{A}_{a} = [\mathbf{A}_{a}^{1};\mathbf{A}_{a}^{2};\mathbf{A}_{a}^{3}],
\end{split}
\end{equation}
where $\mathbf{F}_{a}\in \mathbb{R}^{3LM \times B'H'W'}$ denotes the resulting feature volume, and $\{\mathbf{A}_{a}^{i}\in \mathbb{R}^{LM \times 27C}\}_{i=1}^3$ are the kernel matrices corresponding to the three dimensions of HS images.
Regarding the first criterion, we select the widely disseminated regular 1-D/2-D convolution as the desired alternatives, and also restrict that $\{\mathbf{A}_{a}^{i}\}_{i=1}^3$ are derived from an identical kernel shape.
To meet the second criterion, we obtain that the maximum number of parameters for each convolutional kernel is $\frac{9}{L}$.
\fi
Based on the above conditions, when $L=1$, we can deduce one feasible $\mathbf{A}_a$
with the rank upper bound \textit{minimally} raised to $3M$, as depicted in Fig. \ref{fig:filter-rank} (\textcolor{red}{b}), where the colored blocks indicate the distribution of network parameters. And such a kernel matrix can be realized by separately applying 2-D convolution of size $3 \times 3$ along the three dimensions.
When $L=3$, as illustrated in Fig. \ref{fig:filter-rank} (\textcolor{red}{c}), we can construct a feasible $\mathbf{A}_a$ with the rank upper bound \textit{maximally} boosted to $9M$, which corresponds to the process of performing three 1-D convolution of size $3$ in each of the three dimensions.
For the above two feasible solutions, the number of kernel weights in $\mathbf{A}_a$ is equal to that in $\mathbf{A}$. Alternatively, we can also construct feasible $\mathbf{A}_a$ with a higher rank upper bound but fewer parameters to save computational costs. Specifically, as shown in Fig. \ref{fig:filter-rank} (\textcolor{red}{d}), when $L=1$ (resp. $L=2$), we can build $\mathbf{A}_a$ with the rank upper bound equal to $3M$ (resp. $6M$), which can be achieved by separately applying a single (resp. two) 1-D convolution of size $3$ to each dimension.
\if 0
and 1-D convolution with the kernel of size $3 \times 3$ (for $L=1$) and $3$ ($L=1,~2$, or $3$), respectively. For example, Fig. \ref{fig:filter-rank} (\textcolor{red}{b}) illustrates one of the plausible solutions for the former case, in which each $\mathbf{A}_{a}^{i}$ consists of 2-D convolution with kernels of size $3\times 3$, resulting in totally $3M$ channels.
For the latter case, Figs. \ref{fig:filter-rank} (\textcolor{red}{c}) and (\textcolor{red}{d}) depict the plausible solutions with the maximum and minimum channel amplifications, i.e., $9M$ and $3M$, respectively,
where $\mathbf{A}_{a}^{i}$ comprises of one and three 1-D convolutional kernels convolving on the specific dimension, respectively.
\fi
Based on the above analyses,
we can construct $\mathbf{A}_a$, whose rank upper bound varies from
$3M$ to
$9M$ without introducing extra parameters, thus potentially promoting the diversity of $\mathbf{F}_a$.
Moreover,
in light of the observation that the convolutional kernels for realizing $\mathbf{A}_a$ with the rank upper bound equal to $6M$ or $9M$
share a similar pattern and receptive field to that for the case in Fig. \ref{fig:filter-rank} (\textcolor{red}{d}),
they may only result in homogeneous feature content and a minor increase in feature diversity, which is also experimentally demonstrated,
i.e., a larger rank upper bound than $3M$ only brings marginal performance improvement (see Table \ref{tab:diff-rub}).
Thus, we finally adopt the
permutation manner
in Fig. \ref{fig:filter-rank} (\textcolor{red}{d}), i.e., separately performing 1-D convolution along the three dimensions, which can not only learn diverse spatial-spectral feature representations but also save network parameters.
\if 0
\textcolor{blue}{This module aims to strictly promote the upper bound of feature matrix rank via re-permuting the original dense 3D-kernel matrix $\mathbf{A} \in \mathbb{R}^{M \times k^3C}$ into a larger but sparser form $\mathbf{A}_{a} \in \mathbb{R}^{N \times k^3C}, (N>M)$. Assuming that the three dimensions of HS images are equally important, we could divide $\mathbf{A}_{a}$ into three sub-groups $\{ \mathbf{A}_{a}^{i}\in \mathbb{R}^{n \times k^3C}, i\in[1,3] \}$ \footnote{Since there is $N = 3n > M$, we set the hyperparameter $n$ to be same as $M$.}, where each learning module $\mathbf{A}_{a}^{i}$ should also have symmetrical convolutional pattern with others. Furthermore, to minimize the possible similarity and boost the feature diversity, we design to permute the weights of different $\mathbf{A}_{a}^{i}$ on distinct columns.
Fig. \ref{fig:filter-rank} (b) shows one of the plausible solutions, where each $\mathbf{A}_{a}^{i}$ consists of a 1-D convolutional kernel convolving on a specific dimension.
Thus, we can re-write the convolution process as
\begin{equation}
\begin{split}
\label{equ:rankenchance-conv}
\mathbf{F}_{a} = \mathbf{A}_{a} \cdot \mathbf{I}~~~{\rm with}~~
\mathbf{A}_{a} = [\mathbf{A}_{a}^{1};\mathbf{A}_{a}^{2};\mathbf{A}_{a}^{3}],
\end{split}
\end{equation}
where
$\mathbf{F}_{a}\in \mathbb{R}^{N \times B'H'W'}$ denotes the resulted feature volume. Meanwhile, we also have to keep the total number of convolutional weights for maintaining the computational consumption. Therefore, the upper bound of size for each convolutional kernel under the current permutation format is $\frac{k^3}{3}$. Moreover, since the larger convolutional kernel could be approximated by sequentially aggregated multiple layers with small kernels, in this paper we only discuss the circumstance that $k$ is equal to 3. Thus, under the upper bound number of $\frac{k^3}{3}$, there are typically three convolutional patterns, i.e., 2D convolution with kernel size $3 \times 3$, 2D convolution with kernel size $2 \times 3$, and 1D convolution with kernel size of $3$ (detailed architecture is shown as Fig. \ref{fig:low-rank-filters}).}
\if 0
Furthermore, we can at least employ the elements of $\mathbf{A}$ located at the principal components to fill the larger zero matrix, forming another new kernel matrix $\mathbf{A}_{b} \in \mathbb{R}^{3M \times k^3C}$, which is shown in \ref{fig:filter-rank} (c), leading to a ReS$^3$-ConvSet with one 1-D convolution kernel per dimension. The matrix form can be written as
\begin{equation}
\begin{split}
\label{equ:rankenchance-conv}
\mathbf{F}_{b} = \mathbf{A}_{b} \cdot \mathbf{I}~~~{\rm with}~~
\mathbf{A}_{b} = [\mathbf{A}_{b1};\mathbf{A}_{b2};\mathbf{A}_{b3}],
\end{split}
\end{equation}
where $\mathbf{F}_{b}\in \mathbb{R}^{3M \times B'H'W'}$ is the matrix form of the output feature volume extracted by our ReS$^3$-ConvSet.
Based on the above analysis, the problem boils down to
how to utilize the same or fewer elements shown in Fig. \ref{fig:filter-rank} (a) to form a kernel matrix with a higher rank upper bound. To realize the goal, we can make the row-column sparse via filling these elements into different rows and columns of a larger zero matrix.
Moreover, considering that the principal components of the 3-D kernel play a crucial role during the feature embedding process, we only employ the elements of $\mathbf{A}$ located at the principal components to fill the larger zero matrix, forming a new kernel matrix $\mathbf{A}_{rc} \in \mathbb{R}^{3M \times k^3C}$.
Formally, we can write the matrix form of ReS$^3$-ConvSet as
\begin{equation}
\begin{split}
\label{equ:rankenchance-conv}
\mathbf{F}_{rc} = \mathbf{A}_{rc} \cdot \mathbf{I}~~~{\rm with}~~
\mathbf{A}_{rc} = [\mathbf{A}_{rc1};\mathbf{A}_{rc2};\mathbf{A}_{rc3}],
\end{split}
\end{equation}
where
$\mathbf{F}_{rc}\in \mathbb{R}^{3M \times B'H'W'}$ is the matrix form of the output feature volume extracted by our ReS$^3$-ConvSet,
and $\mathbf{A}_{rc1}$, $\mathbf{A}_{rc2}$, and $\mathbf{A}_{rc3} \in \mathbb{R}^{M \times k^3C}$ are the augmented matrix representations of low-dimensional kernels with zeros in various spatial-spectral domains, corresponding to the kernels of size $1\times 1\times k$, $1\times k\times 1$, and $k\times 1\times 1$, respectively.
As illustrated in Fig. \ref{fig:filter-rank} (b) and (c), $\mathbf{A}_{a}$ and $\mathbf{A}_{b}$ are filled with many elements equal to zero, resulting in $12C$ and $7C$ valid columns. Due to $9M < 12C$ and $3M < 7C$ in practical implementations, we generally have $\mathsf{Rank}(\mathbf{A}_{a})\leq 9M$ and $\mathsf{Rank}(\mathbf{A}_{b})\leq 3M$, and thus $\mathsf{Rank}(\mathbf{F}_{a})\leq 9M$ and $\mathsf{Rank}(\mathbf{F}_{b})\leq 3M$.
Compared with the original kernel matrix $\mathbf{A}$, our ReS$^3$-ConvSet boosts the rank upper bound from $M$ to $3M$ at least, and from $M$ to $9M$ at most, thus potentially promoting more diverse features.
\fi
\emph{Discussion.} We compared different rank upper bounds that can be achieved by our ReS$^3$-ConvSet in Table \ref{tab:diff-rub}. It can be observed that all the ReS$^3$-ConvSets can obtain better performance than 3-D convolution. In addition, although the performance (especially for SAM) of our method can be improved as the rank upper bound increases, it consumes more and more \# Params compared to the ReS$^3$-ConvSet with the rank upper bound of $3M$ (ReS$^3$-ConvSet-3M). As a trade-off, we suggest the ReS$^3$-ConvSet-3M as our final ReS$^3$-ConvSet for constructing the efficient and effective spatial-spectral feature representation module, which not only learns the diverse spatial-spectral features of HS image, but also reduces the parameter size of the network.
\fi
\begin{figure*}[t]
\centering
\includegraphics[width=0.9\linewidth]{figures/low-rank-filters.pdf}\vspace{-0.35cm}
\caption{Illustration of various feature extraction manners for HS images.
(a) 3-D convolution, (b) Sequential 1-D and 2-D convolution, (c) Sequential 1-D convolution, (d) 1-D + 2-D convolution, and (e) Proposed ReS$^3$-ConvSet.}
\label{fig:low-rank-filters}
\end{figure*}
\subsection{Content-level Feature Diversity Enhancement}
\label{Sec:Rankloss}
Despite that the upper-bound of $\texttt{Rank}(\mathbf{F})$ has been raised via kernel matrix re-permutation, it is still theoretically potential that the diversity of the resulting features $\mathbf{F}_a$ may not be fully enhanced. Specifically, previous studies \cite{denil2013predicting,shang2016understanding,Lin2020HRank} demonstrate that a large proportion of kernel weights tend to converge to a marginal set of principal components during back-propagation.
Thus, given a 2-D feature matrix with singular values of $\{a_i\}_{i=1}^{d}$ that have been boosted to $\{b_i\}_{i=1}^{nd}$,
the following case, i.e., a long-tail distribution of singular values, may exist:
$b_i \approx a_i \hspace{0.5em} (i\in [1,d])$, and $ a_i \gg b_j > 0 \hspace{0.5em} (i\in [1,d], j\in [d+1,nd])$. The marginal magnitudes of the additional singular values $\{b_j\}_{j=d+1}^{nd}$ are insufficient to bring remarkable merits, even though the re-permuted feature matrix has a much higher rank. In other words, the resulting $\mathbf{F}_a$ may be approximately low-rank.
In view of this issue, we further regularize the feature matrix $\mathbf{F}_a$ directly to enhance its diversity by minimizing the following loss:
\begin{equation}
\label{equ:fecloss}
\mathcal{L}_{p} = - \|~\texttt{SVD}(\mathbf{F}_a)~\|_1,
\end{equation}
where $\texttt{SVD}(\cdot)$ returns a vector of singular values of an input 2-D matrix, and $\|\cdot\|_1$ is the $\ell_1$ norm.
Such a regularization term will narrow the gaps between large singular values and small ones to promote them to be uniformly distributed, which prevents $\mathbf{F}_a$ from being an approximately low-rank matrix and likewise increases the freedom (or diversity) of its elements. Note that we only apply this regularization term at the last layer of the network before the final output to avoid introducing excessively high computational costs.
\subsection{More Analysis}
\label{sec:discussion}
We also analyze existing feature extraction methods for HS images
by using our formulation to get a thorough understanding of them from the perspective of feature diversity, including ``Sequential 1-D and 2-D convolution" in Fig. \ref{fig:low-rank-filters} (\textcolor{red}{b}), ``Sequential 1-D convolution" in Fig. \ref{fig:low-rank-filters} (\textcolor{red}{c}), and ``1-D + 2-D convolution" in Fig. \ref{fig:low-rank-filters} (\textcolor{red}{d}).
\textbf{1}) We can write the process of ``Sequential 1-D and 2-D convolution" in the form of matrix multiplication:
\begin{equation}
\begin{split}
\label{equ:seq1d2d}
\mathbf{F}_{s1d2d} = \mathbf{A}_{2d} \cdot \mathbf{I}_{1d}, ~~
\mathbf{F}_{1d} = \mathbf{A}_{1d} \cdot \mathbf{I},
\end{split}
\end{equation}
where $\mathbf{F}_{s1d2d}\in \mathbb{R}^{M \times B'H'W'}$ is the 2-D matrix form of the output feature maps;
$\mathbf{F}_{1d} \in \mathbb{R}^{M \times B'H'W'}$ denotes the matrix form of the intermediate feature maps by 1-D convolution; $\mathbf{I}_{1d} \in \mathbb{R}^{k^3M \times B'H'W'}$ symbolizes the local patches via sliding 2-D kernels over $\mathbf{F}_{1d}$; and $\mathbf{A}_{1d}$ and $\mathbf{A}_{2d} \in \mathbb{R}^{M \times k^3M}$ are the matrices of 1-D and 2-D kernels, respectively.
\textbf{2}) The convolution process of ``Sequential 1-D convolution" can be phrased as
\begin{equation}
\begin{split}
\label{equ:seq1d}
\mathbf{F}_{s1d} = \mathbf{A}_{1d_3} \cdot \mathbf{I}_{1d_2}, ~
\mathbf{F}_{1d_2} = \mathbf{A}_{1d_2} \cdot \mathbf{I}_{1d_1}, ~
\mathbf{F}_{1d_1} = \mathbf{A}_{1d_1} \cdot \mathbf{I},
\end{split}
\end{equation}
Here, $\mathbf{F}_{1d_1}, \mathbf{F}_{1d_2}, \mathbf{F}_{s1d}\in \mathbb{R}^{M \times B'H'W'}$ indicate the output feature maps of three sequentially aggregated convolutional layers, $\mathbf{I}_{1d_1}, \mathbf{I}_{1d_2} \in \mathbb{R}^{k^3M \times B'H'W'}$ represent local patch of corresponding feature maps in matrix forms, $\mathbf{A}_{1d_1}, \mathbf{A}_{1d_2}, \mathbf{A}_{1d_3} \in \mathbb{R}^{M \times k^3M}$ are the matrices of corresponding 1-D kernels, respectively.
\textbf{3}) The convolution process of ``1-D + 2-D convolution" can be written as
\begin{equation}
\begin{split}
\label{equ:1d2d}
\mathbf{F}_{1d2d} = \mathbf{A}_{1d2d} \cdot \mathbf{I}, ~~~{\rm with}~~
\mathbf{A}_{1d2d} = [\mathbf{A}_{2d};\mathbf{A}_{1d}],
\end{split}
\end{equation}
where $\mathbf{F}_{1d2d}\in \mathbb{R}^{2M \times B'H'W'}$ encodes the output feature maps;
$\mathbf{A}_{1d2d}\in \mathbb{R}^{2M \times k^3M}$ denotes the matrix of combined 1-D and 2-D kernels.
According to Eqs. (\ref{equ:seq1d2d}), (\ref{equ:seq1d}) and (\ref{equ:1d2d}),
we have $\texttt{Rank}(\mathbf{F}_{s1d2d})\leq M$, $\texttt{Rank}(\mathbf{F}_{s1d})\leq M$, and $\texttt{Rank}(\mathbf{F}_{1d2d})\leq 2M$. That is, these feature extraction manners expand the rank upper bound from $M$ to $2M$ at most, which is still limited. We refer the readers to Tables \ref{tab:d-ab-comb-icvl}, \ref{tab:sr-ab-comb-cave}, and \ref{tab:cls-ab-comb-ip} for the quantitative results of all the variants illustrated in Fig. \ref{fig:low-rank-filters}.\\
\noindent\textbf{Remarks.}
For the feature extraction manner involving parallel branches, e.g., Figs. \ref{fig:low-rank-filters} (\textcolor{red}{d}) and (\textcolor{red}{e}), we utilize a $1\times 1\times 1$ convolutional layer to compress the multiple output feature volumes before feeding it into the subsequent layer in order to avoid channel explosion.
Thus, the feature volumes extracted by different convolution manners are finally with the equal size, i.e., the rank upper bounds of finally-output feature matrices are equal.
However, our ReS$^3$-ConvSet can boost the rank upper bound of feature matrix $\mathbf{F}$ from $M$ to $3M$ during the feature extraction process, thus potentially promoting more diverse features.
We refer the readers to Fig. \ref{fig:d-sr-cls-ab-sv-comparison} for the comparison of singular value distributions of the feature maps extracted by various convolution manners,
where it can be clearly seen that the singular values of the feature matrix by our ReS$^3$-ConvSet decrease more slowly than those of other schemes,
indicating that our ReS$^3$-ConvSet can balance the singular values to avoid only a few large ones dominating the feature space (i.e., the degree of freedom of entries of the feature matrix that is approximately low-rank is limited), thus promoting feature diversity.
\if 0
\subsection{Feature Diversity Promotion Loss}
\label{Sec:Rankloss}
As discussed above, the degree of freedom of elements of the feature matrix (i.e., feature diversity) can be improved via avoiding the feature space being represented by only a few large singular values, we thus design a novel feature diversity promotion loss, named FDP loss, which explicitly encourages feature diversity by shortening the distances between large singular values and small ones.
By conducting a Singular Value Decomposition (SVD) for $\mathbf{F}$, the proposed FDP loss can be formulated as
\begin{equation}
\begin{split}
\label{equ:fecloss}
\mathcal{L}_{p} = \|~\mathsf{SVD}(\mathbf{F})~\|_1,
\end{split}
\end{equation}
where $\mathsf{SVD}(\cdot)$ returns the singular values of a matrix. During training, we can maximize $\mathcal{L}_{p}$ loss for increasing all the singular values, so as to relatively narrow the gaps between large singular values and small ones, thus achieving the feature diversity promotion. In addition, to avoid introducing too heavy computation cost, we only adopt the proposed $\mathcal{L}_{p}$ loss at the last layer of network before the final output.
\fi
\section{Applications}
\label{sec:application}
In this section, to demonstrate the advantages of the proposed ReS$^3$-ConvSet and DA-Reg, we construct three learning-based methods for HS image denosing, spatial super-resolution, and classification. Note that we mainly incorporate ReS$^3$-ConvSet into existing frameworks to directly demonstrate their advantages.
\begin{figure}[!t]
\centering
\includegraphics[width=1\linewidth]{figures/hsid_framework.pdf}
\caption{Illustration of our HS image denoising framework, which is constructed by incorporating the proposed ReS$^3$-ConvSet into a residual U-Net architecture.
}
\label{fig:hsid-framework}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=1\linewidth]{figures/sr_framework.pdf}\vspace{-0.35cm}
\caption{Illustration of our HS image super-resolution framework, which is constructed by incorporating the proposed ReS$^3$-ConvSet into a residual-dense architecture.
}
\label{fig:hsisr-framework}
\end{figure}
\subsection{HS Image Denoising}
Let $\mathcal{X}_{n}\in\mathbb{R}^{B\times H\times W}$ be a noisy HS image, and $\mathcal{Y}\in\mathbb{R}^{B\times H\times W}$ the corresponding noise-free one, where $H$ and $W$ are the spatial dimensions, and $B$ is the number of spectral bands. The degradation process of $\mathcal{Y}$ to $\mathcal{X}_{n}$ could be generally formulated as
\begin{equation}
\label{equ:1}
\mathcal{X}_{n} = \mathcal{Y} + \mathcal{N}_{z},
\end{equation}
where $\mathcal{N}_{z}\in \mathbb{R}^{B\times H \times W}$ denotes the additive noise.
We incorporate the proposed ReS$^3$-ConvSet into the widely-used U-Net \cite{ronneberger2015u} architecture for constructing an efficient and compact HS image denoising method.
As illustrated in Fig.~\ref{fig:hsid-framework}, the denoising framework is composed of multiple ReS$^3$ blocks. In each block, ReS$^3$-ConvSet separately performs 1-D convolution along the three dimensions of an HS image, and a compression layer and an aggregation layer are adopted to aggregate the resulting spatial-spectral embeddings.
We train the denoising network by jointly minimizing the $\ell_1$ distance between the recovered HS image $\mathcal{\widehat{Y}}_{d}$ and
$\mathcal{Y}$ and
\if 0
\begin{equation}
\label{equ:l1loss}
\mathcal{L}_1(\mathcal{\widehat{Y}}_{d}, \mathcal{Y}) = \frac{1}{B\times HW}\left\|\mathcal{\widehat{Y}}_{d} - \mathcal{Y} \right\|_1.
\end{equation}
Together with
\fi
the proposed DA-Reg:
\begin{equation}
\label{equ:dnoise-lossoverall}
\mathcal{L}_{d} = \mathcal{L}_1(\mathcal{\widehat{Y}}_{d}, \mathcal{Y}) + \lambda \mathcal{L}_{p},
\end{equation}
where the hyper-parameter $\lambda$ is
empirically set to $1\times 10^{-4}$.
\subsection{HS Image Spatial Super-resolution}
Given a low-spatial-resolution HS image denoted as $\mathcal{X}_{lr}$ $\in\mathbb{R}^{B\times h\times w}$ with $h \times w$ being the spatial dimensions, we aim to recover a high-spatial-resolution HS image denoted as $\mathcal{Y}$ $\in\mathbb{R}^{B\times H\times W}$, in which $H=\alpha h$ and $W=\alpha w$ ($\alpha>1$ is the scale factor).
The degradation process of $\mathcal{X}_{lr}$ from $\mathcal{Y}$ can be generally formulated as
\begin{equation}
\label{equ:sr_degradation}
\mathcal{X}_{lr} = \mathscr{D}(\mathcal{Y}) + \mathcal{N}_{z},
\end{equation}
where $\mathscr{D}(\cdot)$
is the degeneration operator,
consisting of the down-sampling and blurring operations.
For HS image spatial super-resolution, as shown in Fig.~\ref{fig:hsisr-framework}, we embed the proposed method into the popular residual dense architecture \cite{zhang2018residual} to construct an HS image super-resolution framework that includes several ReS$^3$ blocks. Each block is devised utilizing residual learning, containing a ReS$^3$-ConvSet, a compression layer, and an aggregation layer.
We train the super-resolution framework by simultaneously minimizing the $\ell_1$ distance between the super-resolved HS image $\mathcal{\widehat{Y}}_{sr}$ and
$\mathcal{Y}$, and the proposed DA-Reg. The overall loss function is written as
\begin{equation}
\label{equ:sr-lossoverall}
\mathcal{L}_{sr} = \mathcal{L}_1(\mathcal{\widehat{Y}}_{sr}, \mathcal{Y}) + \lambda \mathcal{L}_{p},
\end{equation}
where the value of $\lambda$ is empirically set to $1\times 10^{-7}$.
\begin{figure}[!t]
\centering
\includegraphics[width=1\linewidth]{figures/cls_framework.pdf}\vspace{-0.35cm}
\caption{Illustration of our HS image classification framework, which is constructed by incorporating the proposed ReS$^3$-ConvSet into the existing method \cite{hamida20183}.
}
\label{fig:cls-framework}
\end{figure}
\subsection{HS Image Classification}
For HS image classification, we incorporate the proposed method into the existing method \cite{hamida20183} to construct the classification framework, as shown in Fig.~\ref{fig:cls-framework},
it consists of one ReS$^3$ block and three conventional filters, i.e., a 3-D convolution for obtaining the basic HS features, and two 1-D convolutions for pooling in the spectral domain.
We train the classification network by simultaneously optimizing the cross entropy loss between predicted labels and ground-truth ones and our DA-Reg, i.e.,
\begin{equation}
\label{equ:classification-lossoverall}
\mathcal{L}_{c} = \mathcal{L}_{ce} + \lambda \mathcal{L}_{p},
\end{equation}
where the value of $\lambda$ is empirically set to $1\times 10^{-4}$.
\section{Experiments}
\label{sec:experiments}
\begin{table*}[t]
\caption{Quantitative comparisons of different methods under several noise levels over the ICVL dataset. The best and second best results are highlighted in bold and underline, respectively. ``$\uparrow$" (resp. ``$\downarrow$") means the larger (resp. smaller), the better.}\vspace{-0.35cm}
\centering
\begin{spacing}{1.05}
\label{tab:icvlgaussianresults}
\resizebox{0.9\textwidth}{!}{
\begin{tabu}{c|c|c|c|c|c|c|c|c|c|c|c}
\tabucline[0.5pt]{*}
\hline
\multirow{3}{*}{$\sigma$} &\multirow{3}{*}{Metrics} &\multicolumn{9}{c}{Methods} \\ \cline{3-12}
~ &~ &Noisy &LRMR &NMoG &LRTDTV &ITSReg &GRN &QRNN3D &NG-Meet &T3SC & ReS$^3$Net \\
~ &~ &~ &\cite{Zhang2014Hyperspectral} &\cite{Chen2018Denoising} &\cite{Wang2018Hyperspectral} &\cite{Xie2016Multispectral} &\cite{Cao2021Deep} &\cite{Wei20213D} &\cite{he2022non} &\cite{Bodrito2021a} &~ \\ \hline\hline
\multirow{3}{*}{30} &MPSNR$\uparrow$ &18.59 &32.96 &33.24 &38.43 &41.53 &41.83 &42.28 &43.09 &\underline{43.19} &\textbf{43.76} \\
&MSSIM$\uparrow$ &0.1034 &0.7247 &0.7464 &0.9365 &0.9571 &0.9653 &0.9701 &0.9709 &\underline{0.9718} &\textbf{0.9750} \\
&SAM$\downarrow$ &0.7269 &0.2298 &0.1537 &0.0835 &0.0929 &0.0541 &0.0617 &\underline{0.0491} &0.0616 &\textbf{0.0449} \\ \hline
\multirow{3}{*}{50} &MPSNR$\uparrow$ &14.15 &28.98 &29.98 &36.47 &39.19 &38.84 &40.22 &40.35 &\underline{40.81} &\textbf{41.48} \\
&MSSIM$\uparrow$ &0.0429 &0.5400 &0.5900 &0.9159 &0.9350 &0.9422 &0.9544 &0.9541 &\underline{0.9567} &\textbf{0.9611} \\
&SAM$\downarrow$ &0.9096 &0.3223 &0.1895 &0.1043 &0.0841 &0.1010 &0.0733 &\underline{0.0582} &0.0720 &\textbf{0.0538} \\ \hline
\multirow{3}{*}{70} &MPSNR$\uparrow$ &11.23 &26.38 &27.80 &34.97 &37.48 &37.22 &38.29 &38.71 &\underline{39.27} &\textbf{39.93} \\
&MSSIM$\uparrow$ &0.0228 &0.4160 &0.4836 &0.8971 &0.9192 &0.9264 &0.9326 &0.9414 &\underline{0.9431} &\textbf{0.9484} \\
&SAM$\downarrow$ &1.0273 &0.3955 &0.2200 &0.1201 &0.1144 &0.0853 &0.0943 &\underline{0.0639} &0.0810 &\textbf{0.0611} \\ \hline
\multirow{3}{*}{Blind} &MPSNR$\uparrow$ &14.83 &29.57 &30.48 &36.76 &39.52 &39.21 &40.48 &40.89 &\underline{40.98} &\textbf{41.81} \\
&MSSIM$\uparrow$ &0.0534 &0.5674 &0.6146 &0.9190 &0.9389 &0.9452 &0.9559 &\underline{0.9579} &\underline{0.9579} &\textbf{0.9630} \\
&SAM$\downarrow$ &0.8800 &0.3060 &0.1823 &0.1012 &0.1037 &0.0717 &0.0737 &\underline{0.0568} &0.0723 &\textbf{0.0531} \\ \hline
\tabucline[0.5pt]{*}
\end{tabu}}
\end{spacing}
\end{table*}
\begin{table*}[t]
\caption{Quantitative comparisons of different methods under five complex noise cases over the \textbf{ICVL} dataset.
The best and second best results are highlighted in bold and underline, respectively. ``$\uparrow$" (resp. ``$\downarrow$") means the larger (resp. smaller), the better. \vspace{-0.35cm}
}
\centering
\begin{spacing}{1.05}
\label{tab:icvlcomplexresults}
\resizebox{0.9\textwidth}{!}{
\begin{tabu}{c|c|c|c|c|c|c|c|c|c|c|c}
\tabucline[0.5pt]{*}
\hline
\multirow{3}{*}{Case} &\multirow{3}{*}{Metrics} &\multicolumn{9}{c}{Methods} \\ \cline{3-12}
~ &~ &Noisy &NG-Meet &LRMR &NMoG &ITSReg &LRTDTV &GRN &QRNN3D &T3SC &ReS$^3$Net \\
~ &~ &~ &\cite{he2022non} &\cite{Zhang2014Hyperspectral} &\cite{Chen2018Denoising} &\cite{Xie2016Multispectral} &\cite{Wang2018Hyperspectral} &\cite{Cao2021Deep} &\cite{Wei20213D} &\cite{Bodrito2021a} &~ \\ \hline\hline
\multirow{3}{*}{1} &MPSNR$\uparrow$ &17.80 &28.62 &28.64 &34.96 &36.02 &37.95 &39.97 &42.79 &\underline{43.51} &\textbf{44.33} \\
&MSSIM$\uparrow$ &0.1516 &0.5764 &0.5153 &0.8279 &0.8451 &0.9377 &0.9587 &0.9752 &\underline{0.9776} &\textbf{0.9800} \\
&SAM$\downarrow$ &0.7911 &0.4301 &0.3235 &0.1260 &0.1408 &0.0671 &0.0685 &\underline{0.0430} &0.0441 &\textbf{0.0327} \\ \hline
\multirow{3}{*}{2} &MPSNR$\uparrow$ &17.77 &28.15 &28.52 &34.60 &35.35 &37.65 &39.90 &42.64 &\underline{43.20} &\textbf{44.35} \\
&MSSIM$\uparrow$ &0.1545 &0.5576 &0.5155 &0.8184 &0.8210 &0.9348 &0.9598 &0.9750 &\underline{0.9770} &\textbf{0.9805} \\
&SAM$\downarrow$ &0.7895 &0.4401 &0.3250 &0.1793 &0.1525 &0.0731 &0.0672 &\underline{0.0437} &0.0488 &\textbf{0.0331} \\ \hline
\multirow{3}{*}{3} &MPSNR$\uparrow$ &17.36 &27.69 &27.78 &33.60 &32.68 &35.67 &38.74 &\underline{42.31} &41.42 &\textbf{44.33} \\
&MSSIM$\uparrow$ &0.1473 &0.5703 &0.5075 &0.8212 &0.7879 &0.9181 &0.9548 &\underline{0.9735} &0.9724 &\textbf{0.9802} \\
&SAM$\downarrow$ &0.8109 &0.4443 &0.3398 &0.1885 &0.1812 &0.0937 &0.0702 &\underline{0.0455} &0.0639 &\textbf{0.0330} \\ \hline
\multirow{3}{*}{4} &MPSNR$\uparrow$ &14.86 &25.32 &24.19 &29.09 &26.47 &36.60 &37.63 &\underline{40.49} &37.93 &\textbf{42.59} \\
&MSSIM$\uparrow$ &0.1118 &0.5211 &0.3805 &0.6751 &0.5019 &0.9265 &0.9410 &\underline{0.9533} &0.9353 &\textbf{0.9668} \\
&SAM$\downarrow$ &0.8480 &0.5814 &0.4681 &0.4510 &0.4818 &0.0874 &0.0952 &\underline{0.0762} &0.1669 &\textbf{0.0595} \\ \hline
\multirow{3}{*}{5} &MPSNR$\uparrow$ &14.07 &24.33 &23.79 &28.45 &25.02 &34.51 &38.01 &\underline{39.42} &35.84 &\textbf{41.94} \\
&MSSIM$\uparrow$ &0.0936 &0.4964 &0.3817 &0.6746 &0.4871 &0.9076 &\underline{0.9473} &0.9448 &0.9248 &\textbf{0.9644} \\
&SAM$\downarrow$ &0.8587 &0.5874 &0.4668 &0.4568 &0.4830 &0.1063 &0.0904 &\underline{0.0809} &0.1804 &\textbf{0.0622} \\ \hline
\tabucline[0.5pt]{*}
\end{tabu}}
\end{spacing}
\end{table*}
\begin{figure*}[!t]
\centering
\includegraphics[width=0.95\linewidth]{figures/d-icvl-complex-visualcomparison.pdf}\vspace{-0.35cm}
\caption{Visual comparison of different methods on \textit{ICVL} with Gaussian and deadline, and mixture noise, from top to bottom. Here, we selected the $5^{th}$, $16^{th}$,
and $30^{th}$, and $10^{th}$, $17^{th}$, and $30^{th}$) bands to form a pseudo RGB image to enable the visualization under Gaussian and deadline noise (resp. mixture noise).
}
\label{fig:icvl-complex}
\end{figure*}
\begin{figure*}[!t]
\centering
\includegraphics[width=0.95\linewidth]{figures/d-urban-visualcomparison.pdf}\vspace{-0.35cm}
\caption{Visual comparison of different methods on \textit{Urban} with real unknown noise. Here we selected the $38^{th}$, $112^{nd}$, and $128^{th}$ bands to form a pseudo RGB image to enable the visualization.
}
\label{fig:urban}
\end{figure*}
\subsection{Evaluation on HS Image Denoising}
\subsubsection{Experiment settings
\textbf{Datasets.}
We employed two commonly-used HS image benchmark datasets for evaluation, including one natural HS image dataset, i.e., ICVL\footnote{http://icvl.cs.bgu.ac.il/hyperspectral/} \cite{Arad2016Sparse},
and one remote sensing HS image, i.e.,
Urban\footnote{https://rslab.ut.ac.ir/data}. Specifically,
ICVL consists of 201 HS images of spatial dimensions $1392\times1300$ and spectral dimension 31 covering the wavelength in the range of 400 to 700 nm, acquired by a Specim PS Kappa DX4 HS camera. We utilized 100 HS images as the training set, and the rest as the testing set.
Urban contains $307\times307$ pixels and 210 spectral bands collected by the HYDICE hyperspectral system. This image is corrupted by \textit{real unknown noise} and widely used for real HS image denoising testing.
Following previous works \cite{Wei20213D,Cao2021Deep}, we considered two types of noise settings, i.e., the Gaussian noise and the complex noise, which were applied to ICVL dataset to simulate noisy HS images. Specifically, for the Gaussian noise,
we set various noise levels, i.e., $\sigma=30$, $50$, $70$, and ``Blind (the value of $\sigma$ is in the range of 30 to 70 but unknown)".
We generated five types of complex noises to imitate the real-world noise cases, including Non-i.i.d. Gaussian Noise, Gaussian and Stripe Noise, Gaussian and Deadline Noise, Gaussian and Impulse Noise, and Mixture Noise, referred as ``Case 1" to ``Case 5". We refer the readers to \cite{Wei20213D,Cao2021Deep} for more details about the noise settings.\\
\noindent \textbf{Implementation details.}
We implemented all the experiments with PyTorch on a PC with NVIDIA GeForce RTX 3080 GPU, Intel(R) Core(TM) i7-10700 CPU of 2.90GHz and 64-GB RAM.
We employed the ADAM optimizer \cite{kingma2014adam} with the exponential decay rates $\beta_1=0.9$ and $\beta_2=0.999$. The total training process was 25 epochs for both two kinds of noise experiments. We initialized the learning rate as $5\times10^{-4}$, which was halved every 5 epochs. We set the batch size to 4 in all experiments.
\begin{table}[t]
\caption{Comparisons of \#Param, \#FLOPs, and inference time of deep learning-based HS image denoising methods on the ICVL dataset. Since T3SC \cite{Bodrito2021a} was built based on sparse coding and deep learning, we could not calculate the \#FLOPs like other pure deep learning-based methods.
}\vspace{-0.35cm}
\centering
\begin{spacing}{1.05}
\label{tab:denoising-flops-time}
\resizebox{0.46\textwidth}{!}{
\begin{tabu}{c|c|c|c|c}
\tabucline[0.5pt]{*}
\hline
Methods &~GRN~ &~QRNN3D~ &~T3SC~ &~~ReS$^3$Net~~ \\ \hline\hline
\#Param (M) &1.07 &0.86 &0.83 &0.66 \\
\#FLOPs (T) &0.22 &1.26 & - &0.95 \\
Inference time (s) &0.23 &0.52 &1.93 &0.77 \\ \hline
\tabucline[0.5pt]{*}
\end{tabu}}
\end{spacing}
\end{table}
\begin{figure*}[!t]
\centering
\includegraphics[width=1\linewidth]{figures/sr_vasual_cave.pdf}\vspace{-0.35cm}
\caption{Visual comparisons of different methods with $\alpha=4$ over CAVE dataset. For ease of comparison, we visualized the reconstructed HS images in the form of RGB images, which were generated via employing the commonly-used spectral response function of Nikon-D700 \cite{jiang2013space}.
}
\label{fig:sr-vasual-cave}
\end{figure*}
\subsubsection{Comparison with state-of-the-art methods}
We compared the proposed denoising method with three state-of-the-art deep learning-based methods, i.e., QRNN3D \cite{Wei20213D}, GRN \cite{Cao2021Deep}, and T3SC \cite{Bodrito2021a}, and five representative non-learning-based methods, including LRMR \cite{Zhang2014Hyperspectral}, ITSReg \cite{Xie2016Multispectral}, NMoG \cite{Chen2018Denoising}, LRTDTV \cite{Wang2018Hyperspectral}, NG-Meet \cite{he2022non}. Note that for QRNN3D \cite{Wei20213D}, GRN \cite{Cao2021Deep}, and our method, only a single network was trained for each noise setting, i.e., a single network for handling noisy HS images with different Gaussian noise levels (or complex noises);
while for T3SC \cite{Bodrito2021a}, a network was trained for each case of the two types of noise settings, i.e., nine networks for the four Gaussian noises and five complex noises. In other words, the comparison setting is more favorable for T3SC.\\
\noindent \textbf{Quantitative comparison.}
We adopted three commonly used quantitative metrics to evaluate the quality of the denoised HS images, i.e., Mean Peak Signal-to-Noise Ratio (MPSNR), Mean Structural Similarity Index (MSSIM) \cite{wang2004image}, and Spectral Angle Mapper (SAM) \cite{Yuhas1992Discrimination}.
Tables \ref{tab:icvlgaussianresults} and \ref{tab:icvlcomplexresults} show the quantitative results of different methods
, where it can be observed that
our method consistently achieves the best performance in terms of all the three metrics under all noise scenarios.
Particularly, our method improves the MPSNR of the second best methods by $0.57$ dB, $0.67$ dB, $0.66$ dB, and $0.83$ dB under four Gaussian noise levels, and $0.82$ dB, $1.15$ dB, $2.02$ dB, $2.10$ dB, and $2.52$ dB under five types of complex noises, respectively.
Besides, the impressive performance of our method under
both the blind Gaussian noise and all the complex noise scenarios demonstrates
that it has better resilience on severely corrupted HS images; and
\noindent \textbf{Visual comparison.}
Fig. \ref{fig:icvl-complex} shows the visual comparisons of denoising results by different methods on ICVL, where we can observe that the denoised images by our method is cleaner and retain the original high-frequency details better.
In addition, Fig. \ref{fig:urban} provides the visual comparisons of denoised HS images by different methods on Urban, a real-world noisy HS image, where we can see that most of the compared methods fail to remove the unknown noise completely.
By contrast, our method successfully tackles this unknown noise and produces a clearer and visually pleasing image. \\
\noindent \textbf{Computational efficiency.}
We compared the number of network parameters (\#Param), floating point of operations (\#FLOPs), and inference time of deep learning-based methods in Table \ref{tab:denoising-flops-time}, where it can be observed that our method consumes fewer network parameters and has comparable \#FLOPs, and inference time, compared with state-of-the-art methods, demonstrating that the excellent performance of our method does not come at the cost of a larger capacity and higher computational complexity but is credited to the proposed ReS$^3$-ConvSet and DA-Reg.
\begin{table}[t]
\caption{Quantitative comparisons of different methods over the CAVE dataset. The best and second best results are highlighted in bold and underline, respectively.``$\uparrow$" (resp. ``$\downarrow$") means the larger (resp. smaller), the better.}
\vspace{-0.2cm}
\centering
\label{tab:srcaveresults}
\resizebox{0.48\textwidth}{!}{
\begin{tabu}{c|c|c|c|c|c}
\tabucline[1pt]{*}
Methods &Scale &\#Params &MPSNR$\uparrow$ &MSSIM$\uparrow$ &SAM$\downarrow$ \\ \hline\hline
BI &4 &- &36.533 &0.9479 &4.230 \\
3DFCNN\cite{Mei2017Hyperspectral} &4 &0.04M &38.061 &0.9565 &3.912 \\
3DGAN\cite{Li2020Hyperspectral} &4 &0.59M &39.947 &0.9645 &3.702 \\
SSPSR\cite{Jiang2020Learning} &4 &26.08M &40.104 &0.9645 &3.623 \\
ERCSR\cite{Li2021Exploring} &4 &1.59M &40.701 &\underline{0.9662} &3.491 \\
PDE-Net \cite{hou2022deep} &4 &2.30M &\underline{41.236} &\textbf{0.9672} &\underline{3.455} \\ \hline
Ours &4 &2.11M &\textbf{41.443} &\textbf{0.9672} &\textbf{3.412} \\ \hline\hline
BI &8 &- &32.283 &0.8993 &5.412 \\
3DFCNN\cite{Mei2017Hyperspectral} &8 &0.04M &33.194 &0.9131 &5.019 \\
3DGAN\cite{Li2020Hyperspectral} &8 &0.66M &34.930 &0.9293 &4.888 \\
SSPSR\cite{Jiang2020Learning} &8 &28.44M &34.992 &0.9273 &4.680 \\
ERCSR\cite{Li2021Exploring} &8 &2.38M &35.519 &0.9338 &4.498 \\
PDE-Net \cite{hou2022deep} &8 &2.33M &\underline{36.021} &\underline{0.9363} &\underline{4.312} \\ \hline
Ours &8 &2.31M &\textbf{36.257} &\textbf{0.9377} &\textbf{4.242} \\
\tabucline[1pt]{*}
\end{tabu}}
\end{table}
\if 0
\subsubsection{Ablation study}
\textbf{The number of ReS$^3$ blocks.}
We conducted ablation studies to explore how the number of ReS$^3$ block involved in our constructed denoising framework affects the performance.
We varied the number of ReS$^3$ block in the range from 1 to 7.
As shown in Fig. \ref{fig:d-sr-ab-num-reblock} (\textcolor{red}{a}), it can be observed that increasing the number of ReS$^3$ block is able to improve denoising performance.
Observing that when the number of ReS$^3$ block goes up to 5, the denoising performance tends to be stable and even drops slightly, we hence set the number of ReS$^3$ block to 5 in all the remaining experiments on HS image denoising task.\\
\noindent \textbf{The effectiveness of ReS$^3$-ConvSet and DA-Reg.}
Table \ref{tab:d-ab-loss-icvl} lists the denoising results of our constructed denoising framework with or without the proposed ReS$^3$-ConvSet and DA-Reg. It can be observed that both ReS$^3$-ConvSet and DA-Reg make contributions to the satisfactory denoising performance.
\\
\noindent \textbf{Quantitative comparisons of the convolution manners in Fig. \ref{fig:low-rank-filters}.}
For fair comparisons, we built various denoising methods by only replacing the 1-D convolutional kernels in our ReS$^3$ block with the variants and retaining all the other settings (e.g., connections, aggregation, etc.). Besides, we also provided the results of 3-D convolution for reference.
As listed in Table \ref{tab:d-ab-comb-icvl}, it can be seen that compared with the 3-D convolution, all the convolution variants show their advantages on either quantitative performance or network compactness (\#Params) and complexity (\#FLOPs).
Generally, a higher upper bound of the rank produces better reconstruction quality, which is consistent with our theoretical analysis.
Particularly, our ReS$^3$-ConvSet equipped with the second fewest number of network parameters has the highest rank upper bound during the feature extraction process and thus achieves the best quantitative performance, convincingly demonstrating its superiority and the importance of filter diversity in designing feature extraction module.\\
\noindent \textbf{The distribution of singular values.}
We compared the distributions of the singular values of the feature matrices learned by different convolution manners.
Specifically, we unfolded the feature embeddings from different convolution patterns (i.e., 3-D, Sequential 1-D, Sequential 1-D and 2-D, 1-D + 2-D, and the proposed ReS$^3$-ConvSet) into feature matrices via the manner of $\mathbf{F}$ in Eq. \eqref{equ:rankenchance-conv}. Then, we computed the singular values of these feature matrices via singular value decomposition (SVD). Note that we selected those feature embeddings from the layers at the same depth for a fair comparison. As shown in Fig. \ref{fig:d-sr-cls-ab-sv-comparison} (\textcolor{red}{a}), it can be clearly seen that the singular values of the feature matrix by our methods
decrease more slowly than those of other schemes, demonstrating that the proposed methods can avoid only a few large singular values dominating the feature space, thus promoting feature diversity. \\
\noindent \textbf{The symmetry property of our ReS$^3$-ConvSet.}
We validated the importance of symmetry property of our ReS$^3$-ConvSet. As listed in Table \ref{tab:ab-symm-den-cave}, it can be seen that our ReS$^3$-ConvSet equipped with the symmetry property shows its advantage in denoising performance.
\fi
\subsection{Evaluation on HS Image Spatial SR}
\subsubsection{Experiment settings}
\textbf{Datasets.}
We employed the commonly-used HS image benchmark dataset for evaluation, i.e., CAVE\footnote{http://www.cs.columbia.edu/CAVE/databases/} \cite{Yasuma2010CAVE},
which contains 32 HS images of spatial dimensions $512\times512$ and spectral dimension 31 covering the wavelength in the range of 400 to 700 nm, collected by a generalized assorted pixel camera. We randomly selected 20 HS images for training, and the remaining 12 HS images for testing.\\
\noindent \textbf{Implementation details.}
We employed the ADAM optimizer \cite{kingma2014adam} with the exponential decay rates $\beta_1=0.9$ and $\beta_2=0.999$.
We initialized the learning rate as $5\times10^{-4}$, which was halved every 25 epochs. We set the batch size to 4.
The total training process contained 50 warm-ups and 50 training epochs.
During the warm-up phase, we trained our model by only minimizing the $\ell_1$ loss, i.e., $\lambda=0$.
\begin{table}[t]
\caption{Comparisons of the computational efficiency of different HS spatial SR methods on the CAVE dataset.}\vspace{-0.35cm}
\centering
\label{tab:sr-flops-times}
\resizebox{0.49\textwidth}{!}{
\begin{tabu}{c|c|c|c|c|c|c} \tabucline[1pt]{*}
Methods &Scale
&Inference time &\#FLOPs &Scale &Inference time &\#FLOPs \\ \hline
3DFCNN\cite{Mei2017Hyperspectral} &4 &0.088s &0.321T &8 &0.080s &0.321T \\
3DGAN\cite{Li2020Hyperspectral} &4 &0.369s &1.300T &8 &0.332s &1.233T \\
SSPSR\cite{Jiang2020Learning} &4 &0.429s &3.029T &8 &0.302s &1.818T \\
ERCSR\cite{Li2021Exploring} &4 &0.380s &4.463T &8 &0.283s &10.429T \\
PDE-Net \cite{hou2022deep} &4 &0.526s &6.375T &8 &0.207s &3.020T \\ \hline
Ours &4 &0.463s &1.917T &8 &0.195s &2.752T \\
\tabucline[1pt]{*}
\end{tabu}}
\end{table}
\begin{table}[t]
\caption{Quantitative performance of different classification methods in terms of OA, AA, and Kappa, as well as the accuracies for each class on the Indian Pines dataset. The best results are highlighted in bold.}\vspace{-0.35cm}
\centering
\label{tab:cls-quantt-ip}
\resizebox{0.48\textwidth}{!}{
\begin{tabu}{c|c|c|c|c}
\tabucline[1pt]{*}
Class No. &3-D CNN\cite{hamida20183} &FuNet-C\cite{hong2021graph} &SpectralFormer\cite{hong2022spectralformer} &Ours \\ \hline \hline
1 &\textbf{89.67} &67.19 &68.64 &86.92 \\
2 &82.02 &78.70 &\textbf{87.50} &85.20 \\
3 &86.96 &\textbf{99.46} &85.33 &92.39 \\
4 &\textbf{96.64} &95.75 &95.75 &95.75 \\
5 &91.82 &93.69 &85.80 &\textbf{98.28} \\
6 &98.17 &\textbf{99.32} &97.49 &\textbf{99.32} \\
7 &80.39 &79.19 &\textbf{85.29} &63.51 \\
8 &61.49 &69.77 &76.92 &\textbf{84.86} \\
9 &80.85 &70.57 &78.90 &\textbf{82.09} \\
10 &\textbf{100.00} &99.38 &99.38 &\textbf{100.00} \\
11 &93.41 &89.79 &93.25 &\textbf{93.41} \\
12 &96.96 &94.24 &81.82 &\textbf{97.27} \\
13 &97.78 &\textbf{100.00} &\textbf{100.00} &97.78 \\
14 &89.74 &87.18 &71.79 &\textbf{94.87} \\
15 &\textbf{100.00} &\textbf{100.00} &\textbf{100.00} &\textbf{100.00} \\
16 &\textbf{100.00} &\textbf{100.00} &\textbf{100.00} &\textbf{100.00} \\ \hline \hline
OA &82.38 &80.06 &82.88 &\textbf{87.17} \\
AA &90.37 &89.01 &87.99 &\textbf{91.98} \\
Kappa &0.8004 &0.7736 &0.8047 &\textbf{0.8524} \\ \hline
\tabucline[1pt]{*}
\end{tabu}}
\end{table}
\begin{table}[t]
\caption{Quantitative performance of different classification methods in terms of OA, AA, and Kappa, as well as the accuracies for each class on the Pavia University dataset. The best results are highlighted in bold.}\vspace{-0.35cm}
\centering
\label{tab:cls-quantt-pu}
\resizebox{0.48\textwidth}{!}{
\begin{tabu}{c|c|c|c|c}
\tabucline[1pt]{*}
Class No. &3-D CNN\cite{hamida20183} &FuNet-C\cite{hong2021graph} &SpectralFormer\cite{hong2022spectralformer} &Ours \\ \hline \hline
1 &79.71 &80.08 &\textbf{82.73} &82.09 \\
2 &95.69 &94.28 &94.03 &\textbf{98.15} \\
3 &\textbf{80.39} &67.66 &73.66 &77.74 \\
4 &\textbf{98.52} &97.80 &93.75 &96.35 \\
5 &99.82 &99.19 &99.28 &\textbf{100.0} \\
6 &85.89 &91.49 &\textbf{90.75} &82.17 \\
7 &84.91 &85.93 &87.56 &\textbf{93.78} \\
8 &97.24 &96.64 &95.81 &\textbf{97.68} \\
9 &94.88 &\textbf{95.22} &94.21 &94.09 \\ \hline \hline
OA &91.51 &90.92 &91.07 &\textbf{92.56} \\
AA &90.70 &89.81 &90.20 &\textbf{91.34} \\
Kappa &0.8858 &0.8787 &0.8805 &\textbf{0.8994} \\ \hline
\tabucline[1pt]{*}
\end{tabu}}
\end{table}
\begin{table}[t]
\caption{Results of the ablation study towards different rank upper bounds of our ReS$^3$-ConvSet over HS image super-resolution with $\alpha=4$ over CAVE dataset.}\vspace{-0.35cm}
\centering
\label{tab:diff-rub}
\resizebox{0.48\textwidth}{!}{
\begin{tabu}{c|c|c|c|c|c|c}
\tabucline[1pt]{*}
\hline
Methods &Rank upper bound &Kernel &\# Params &MPSNR$\uparrow$ &MSSIM$\uparrow$ &SAM$\downarrow$ \\ \hline\hline
3-D &1$M$ &3-D &3.59 M &40.98 &0.9664 &3.452 \\
ReS$^3$-ConvSet &3$M$ &2-D &3.73 M &41.28 &0.9669 &3.423 \\
ReS$^3$-ConvSet &3$M$ &1-D &2.11 M &41.35 &0.9671 &3.418 \\
ReS$^3$-ConvSet &6$M$ &1-D &3.06 M &41.29 &0.9671 &3.415 \\
ReS$^3$-ConvSet &9$M$ &1-D &4.00 M &41.32 &0.9672 &3.394 \\ \hline
\tabucline[1pt]{*}
\end{tabu}}
\end{table}
\begin{figure}[t]
\centering
\includegraphics[width=1\linewidth]{figures/cls_vasual_ip.pdf}\vspace{-0.35cm}
\caption{Visual comparisons of the classification maps obtained by different methods on the Indian Pines dataset. Selected regions have been zoomed in for better comparison.
}
\label{fig:cls-vasual-ip}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=1\linewidth]{figures/cls_vasual_pu.pdf}\vspace{-0.35cm}
\caption{Visual comparisons of the classification maps obtained by different methods on the Pavia University dataset. Selected regions have been zoomed in for better comparison.
}
\label{fig:cls-vasual-pu}
\end{figure}
\subsubsection{Comparison with state-of-the-art methods}
We compared our HS image spatial super-resolution method with six state-of-the-art deep learning-based methods, i.e., 3DFCNN \cite{Mei2017Hyperspectral}, 3DGAN \cite{Li2020Hyperspectral}, SSPSR \cite{Jiang2020Learning}, ERCSR \cite{Li2021Exploring}, and PDE-Net \cite{hou2022deep}. We also provided the results of bi-cubic interpolation (BI) as a baseline.\\
\noindent \textbf{Quantitative comparison.}
Table \ref{tab:srcaveresults} shows the quantitative results of different methods,
where it can be observed that
our method consistently achieves the best values in terms of all the three metrics under $4\times$ and $8\times$ spatial super-resolution tasks, validating the superiority of our proposed method. Besides, the network size of our method, validating that the satisfactory performance of our method is not achieved by piling up larger capacity but credited to elegant feature extraction technique. \\
\noindent \textbf{Visual comparison.} Fig. \ref{fig:sr-vasual-cave} visually compares the results of different methods, where it can be observed that the super-resolved images by our method present sharper and clearer textures and are closer to the ground truth ones, which further demonstrates its advantage.\\
\noindent \textbf{Computational efficiency.}
Table \ref{tab:sr-flops-times} compares the computational efficiency of different approaches measured with the \#FLOPs and inference time, where it can be observed that the proposed method consumes much fewer \#FLOPs and less inference times than most compared methods.
\begin{table*}[t]
\caption{Results of the ablation study towards different convolution manners used for HS image denoising on the ICVL dataset with the Gaussian noise ($\sigma=70$).\vspace{-0.35cm}
}
\centering
\label{tab:d-ab-comb-icvl}
\resizebox{0.9\textwidth}{!}{
\begin{tabu}{c|c|c|c|c|c|c} %
\tabucline[1pt]{*}
Methods &\#Params (M) &\#FLOPs (T) &Rank upper bound &MPSNR$\uparrow$ &MSSIM$\uparrow$ &SAM$\downarrow$ \\ \hline\hline
3-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{a})) &1.201 &1.562 &$M$ &39.34 &0.9430 &0.0693 \\
Seq. 1-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{c})) &0.614 &0.765 &$M$ &39.42 &0.9430 &0.0658 \\
Seq. 1-D and 2-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{b})) &0.717 &0.889 &$M$ &39.58 &0.9445 &0.0652 \\
1-D + 2-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{d})) &0.740 &1.082 &$2M$ &39.71 &0.9459 &0.0610 \\
ReS$^3$-ConvSet &0.658 &0.953 &$3M$ &39.85 &0.9478 &0.0606 \\ \hline
\tabucline[1pt]{*}
\end{tabu}}
\end{table*}
\begin{table*}[t]
\caption{Results of the ablation study towards different convolution manners used for $4\times$ HS image spatial super-resolution on the CAVE dataset.}\vspace{-0.35cm}
\centering
\label{tab:sr-ab-comb-cave}
\resizebox{0.9\textwidth}{!}{
\begin{tabu}{c|c|c|c|c|c|c} %
\tabucline[1pt]{*}
Methods &\#Params (M) &\#FLOPs (T) &Rank upper bound &MPSNR$\uparrow$ &MSSIM$\uparrow$ &SAM$\downarrow$ \\ \hline\hline
3-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{a})) &3.586 &2.668 &$M$ &40.98 &0.9664 &3.452 \\
Seq. 1-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{c})) &1.987 &1.853 &$M$ &41.00 &0.9668 &3.430 \\
Seq. 1-D and 2-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{b})) &2.269 &1.997 &$M$ &41.10 &0.9666 &3.426 \\
1-D + 2-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{d})) &2.332 &2.029 &$2M$ &41.17 &0.9667 &3.418 \\
ReS$^3$-ConvSet &2.110 &1.917 &$3M$ &41.35 &0.9671 &3.418 \\ \hline
\tabucline[1pt]{*}
\end{tabu}}
\end{table*}
\begin{table*}[t]
\caption{Results of the ablation study towards different convolution manners
used for HS image classification on \textit{Indian Pines}.} \vspace{-0.35cm}
\centering
\label{tab:cls-ab-comb-ip}
\resizebox{0.9\textwidth}{!}{
\begin{tabu}{c|c|c|c|c|c|c} %
\tabucline[1pt]{*}
Methods &\#Params (M) &\#FLOPs (G) &Rank upper bound &OA &AA &Kappa \\ \hline\hline
3-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{a})) &0.395 &0.0639 &$M$ &82.38 &90.37 &0.8004 \\
Seq. 1-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{c})) &0.385 &0.0406 &$M$ &82.61 &90.09 &0.8023 \\
Seq. 1-D and 2-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{b})) &0.386 &0.0419 &$M$ &82.94 &89.51 &0.8056 \\
1-D + 2-D conv. (Fig. \ref{fig:low-rank-filters} (\textcolor{red}{d})) &0.387 &0.0442 &$2M$ &83.83 &90.97 &0.8152 \\
ReS$^3$-ConvSet &0.386 &0.0421 &$3M$ &85.32 &91.86 &0.8324 \\ \hline
\tabucline[1pt]{*}
\end{tabu}}
\end{table*}
\if 0
\subsubsection{Ablation study}
\textbf{The number of ReS$^3$ block.}
To explore how the number of ReS$^3$ block involved in our constructed super-resolution framework affects performance, we evaluated our framework with
various numbers of ReS$^3$ block, i.e., 1, 4, 9, 11, and 13. As shown in Fig. \ref{fig:d-sr-ab-num-reblock} (\textcolor{red}{b}), we can see that with the number of ReS$^3$ block increasing,
the quality of HS super-resolved image improves. Observing that when the number of ReS$^3$ block goes up to 11, the performance of our method starts to drop slightly,
we thus chose the number of ReS$^3$ block to 11 in all the remaining experiments of HS image super-resolution task.\\
\noindent \textbf{The effectiveness of ReS$^3$-ConvSet and DA-Reg.}
We experimentally validated the effectiveness of the proposed ReS$^3$-ConvSet and DA-Reg. As shown in Table \ref{tab:ab-loss-sr-cave}, it can be seen that the super-resolution performance drops after removing any of ReS$^3$-ConvSet and DA-Reg operations, compared with the complete model, indicating that both ReS$^3$-ConvSet and DA-Reg can contribute to improving the reconstruction quality.\\
\noindent \textbf{Quantitative comparisons of the convolution manners in Fig. \ref{fig:low-rank-filters}.}
For fair comparisons, we constructed different super-resolution methods based on these variants with the same settings done in the experiments of HS image denoising task.
As listed in Table \ref{tab:sr-ab-comb-cave}, we can observe that all the convolution variants surpass the 3-D convolution on either the super-resolution performance, network compactness (\#Params), or complexity (\#FLOPs).
Particularly, our ReS$^3$-ConvSet has the highest rank upper bound during the feature extraction process and obtains the best performance, which is consistent with our theoretical analysis that a higher upper bound of the rank shows great potential in generating better reconstruction quality. \\
\noindent \textbf{The distribution of singular values.}
We also compared the distributions of the singular values of the feature matrices learned by different convolution patterns (i.e., 3-D, Sequential 1-D, Sequential 1-D and 2-D, 1-D + 2-D, and the proposed ReS$^3$-ConvSet) on HS image super-resolution.
To be specific, we unfolded the feature embeddings, that from the layers at the same depth, into feature matrices via the manner of $\mathbf{F}$ in Eq. \eqref{equ:rankenchance-conv}. Then, we conducted SVD for these feature matrices. As shown in Fig. \ref{fig:d-sr-cls-ab-sv-comparison} (\textcolor{red}{b}), we can clearly observe that the singular values obtained by our approaches decrease more slowly than those of other schemes, indicating again that our approaches can balance the singular values to avoid only a few large ones dominating the feature space, thus achieving feature diversity promotion. \\
\noindent \textbf{The symmetry property of our ReS$^3$-ConvSet.}
Table \ref{tab:ab-symm-sr-cave} lists the reconstruction quality of
our ReS$^3$-ConvSet with and without symmetry property, where it can be observed that the reconstruction quality declines when our ReS$^3$-ConvSet loses its symmetry property, revealing the importance of the symmetry property of our ReS$^3$-ConvSet.
\fi
\subsection{Evaluation on HS Image Classification}
\subsubsection{Experiment settings}
\textbf{Datasets.}
We employed the two commonly-used HS image classification benchmarks for evaluation, i.e., Indian Pines\footnote{https://rslab.ut.ac.ir/data}, and Pavia University\footnote{http://www.ehu.eus/ccwintco/index.php/Hyperspectral\_Remote\_\\Sensing\_Scenes/}. Specifically,
Indian Pines is of spatial dimensions $145\times145$ and spectral dimension 220 covering the wavelength in the range of 400 to 2500 nm, collected by the Airborne Visible/Infrared Imaging Spectrometer (AVIRIS) sensor. There are 16 mainly investigated categories in this studied scene. Following \cite{hong2021graph,hong2022spectralformer}, we employed 695 samples for training and 9671 samples for testing.
Pavia University was gathered by the ROSIS sensor, consisting of $610\times 340$ pixels and $103$ spectral bands from the range of 430 to 860 nm. There are 9 land cover categories. The number of samples utilized for training and testing is 3921 and 40002, respectively.\\
\noindent \textbf{Implementation details.}
We employed the ADAM optimizer \cite{kingma2014adam} with the exponential decay rates $\beta_1=0.9$ and $\beta_2=0.999$.
The total training process contained 1000 epochs for Indian Pines, and 150 epochs for Pavia University. We set the batch size to 64 and initialized the learning rate as $1\times10^{-3}$. We set the patch size as $7\times 7$ during training.
\subsubsection{Comparison with state-of-the-art methods}
We compared our method with three state-of-the-art deep learning-based HS image classification methods named 3-D CNN \cite{hamida20183}, FuNet-C \cite{hong2021graph}, and SpectralFormer \cite{hong2022spectralformer}. Following existing methods, we adopted three widely-used metrics, i.e., Overall Accuracy (OA), Average Accuracy (AA), and Kappa Coefficient, to evaluate the HS image classification performance.
As listed in Tables \ref{tab:cls-quantt-ip} and \ref{tab:cls-quantt-pu},
it can be seen that our method consistently achieves the highest accuracy in terms of OA, AA, and Kappa metrics on both Indian Pines and Pavia University,
although some of the compared methods adopt more advanced deep learning strategies, such as, the fusion of CNN and GCN, and Transformer \cite{vaswani2017attention}.
Besides, from Figs. \ref{fig:cls-vasual-ip} and \ref{fig:cls-vasual-pu}, it can be seen that our method produces more accurate classification maps,
again demonstrating its advantage.
\if 0
\subsubsection{Ablation study}
\textbf{The effectiveness of ReS$^3$-ConvSet and DA-Reg.}
As the ReS$^3$-ConvSet and DA-Reg are two key operations to determine the performance of our method, we conducted ablation studies to validate their effectiveness. As illustrated in Table \ref{tab:cls-ab-loss-ip}, we can observe that the performance of baseline (i.e., the method using 3-D convolution) can be improved by introducing any of the ReS$^3$-ConvSet and DA-Reg operations, and it achieves the best performance when equipped with these two operations simultaneously, demonstrating the advantage of the proposed methods. \\
\noindent \textbf{Quantitative comparisons of the convolution manners in Fig. \ref{fig:low-rank-filters}.}
As listed in Table \ref{tab:cls-ab-comb-ip}, it can be observed that
although all the other convolution manners consume comparable \#Params compared with 3-D convolution, they show the advantages in both classification accuracies and network complexity (\#FLOPs).
In addition, our ReS$^3$-ConvSet equipped with the highest rank upper bound during the feature extraction process achieves the best accuracy, which is consistent with our theoretical analysis. \\
\noindent \textbf{The distribution of singular values.}
Fig. \ref{fig:d-sr-cls-ab-sv-comparison} (\textcolor{red}{c}) shows the comparison of the singular value distributions of the feature matrices learned by different convolutional patterns. We conducted the computation of singular values with the same way utilized on the experiments of HS image denoising and super-resolution. It can be clearly observed that most singular values are close to zero on all the methods, however, for those far from zero, the singular values obtained by our methods drop more slowly than other approaches, demonstrating that our methods has greater potential in promoting feature diversity compared with other methods.
\fi
\begin{figure}[t]
\centering
\includegraphics[width=1\linewidth]{figures/d_sr_ab_num_reblock.pdf}\vspace{-0.35cm}
\caption{Illustration of the effect of the number of ReS$^3$ block on the quantitative performance of (\textbf{a}) our HS image denoising method on the ICVL dataset with the Gaussian noise ($\sigma=70$), and (\textbf{b}) our $4\times$ spatial SR method on the CAVE dataset.}
\label{fig:d-sr-ab-num-reblock}
\end{figure}
\vspace{-0.3cm}
\begin{figure*}[t]
\centering
\includegraphics[width=0.8\linewidth]{figures/d_sr_cls_ab_sv_comparison.pdf}
\vspace{-0.5cm}
\caption{Comparison of the distribution of the singular values of the feature maps extracted by different convolution manners used in the applications of (\textbf{a}) HS image denoising on the ICVL dataset with the Gaussian noise ($\sigma=70$), (\textbf{b}) HS image $4\times$ spatial super-resolution on the CAVE dataset, and (\textbf{c}) HS image classification on Indian Pines. The singular values of each convolution scheme is normalized by its largest value.
}
\label{fig:d-sr-cls-ab-sv-comparison}
\end{figure*}
\begin{table}[t]
\caption{Results of the ablation study towards our ReS$^3$-ConvSet and DA-Reg over HS image denoising on the ICVL dataset with the Gaussian noise ($\sigma=70$). For the first two settings, we replaced ReS$^3$-ConvSet with 3-D convolution with an identical number of layers.} \vspace{-0.35cm}
\centering
\label{tab:d-ab-loss-icvl}
\resizebox{0.4\textwidth}{!}{
\begin{tabu}{cc|c|c|c}
\tabucline[1pt]{*}
ReS$^3$-ConvSet &DA-Reg &MPSNR$\uparrow$ &MSSIM$\uparrow$ &SAM$\downarrow$ \\ \hline
$\times$ & $\times$ &39.34 &0.9430 &0.0693 \\
$\times$ &\checkmark &39.44 &0.9435 &0.0684 \\
\checkmark & $\times$ &39.85 &0.9478 &0.0606 \\
\checkmark &\checkmark &39.93 &0.9484 &0.0611 \\ \hline
\tabucline[1pt]{*}
\end{tabu}}
\end{table}
\begin{table}[t]
\caption{Results of the ablation study towards our ReS$^3$-ConvSet and DA-Reg over HS image super-resolution with $\alpha=4$ on the CAVE dataset. For the first two settings, we replaced ReS$^3$-ConvSet with 3-D convolution with an identical number of layers.}\vspace{-0.35cm}
\centering
\label{tab:ab-loss-sr-cave}
\resizebox{0.4\textwidth}{!}{
\begin{tabu}{cc|c|c|c}
\tabucline[1pt]{*}
ReS$^3$-ConvSet &DA-Reg &MPSNR$\uparrow$ &MSSIM$\uparrow$ &SAM$\downarrow$ \\ \hline
$\times$ & $\times$ &40.98 &0.9664 &3.452 \\
$\times$ &\checkmark &41.08 &0.9664 &3.450 \\
\checkmark & $\times$ &41.35 &0.9671 &3.418 \\
\checkmark &\checkmark &41.44 &0.9672 &3.412 \\ \hline
\tabucline[1pt]{*}
\end{tabu}}
\end{table}
\begin{table}[t]
\caption{Results of the ablation study towards our rank loss over HS image classification on \textit{Indian Pines}. For the first two settings, we replaced ReS$^3$-ConvSet with 3-D convolution with an identical number of layers.} \vspace{-0.35cm}
\centering
\label{tab:cls-ab-loss-ip}
\resizebox{0.4\textwidth}{!}{
\begin{tabu}{cc|c|c|c}
\tabucline[1pt]{*}
ReS$^3$-ConvSet &DA-Reg &OA &AA &Kappa \\ \hline
$\times$ & $\times$ &82.38 &90.37 &0.8004 \\
$\times$ &\checkmark &83.66 &90.36 &0.8136 \\
\checkmark &$\times$ &85.32 &91.86 &0.8324 \\
\checkmark &\checkmark &87.17 &91.98 &0.8524 \\ \hline
\tabucline[1pt]{*}
\end{tabu}}
\end{table}
\begin{table}[t]
\caption{Results of the ablation study towards the symmetry property of our ReS$^3$-ConvSet over HS image denoising on the ICVL dataset with the Gaussian noise ($\sigma=70$). For the ReS$^3$-ConvSet w/o symmetry, we utilized different numbers of channels for each 1-D convolution in ReS$^3$-ConvSet, i.e., the three dimensions of the HS image are unequally essential in this setting.}\vspace{-0.35cm}
\centering
\label{tab:ab-symm-den-cave}
\resizebox{0.45\textwidth}{!}{
\begin{tabu}{c|c|c|c}
\tabucline[1pt]{*}
Methods &MPSNR$\uparrow$ &MSSIM$\uparrow$ &SAM$\downarrow$ \\ \hline
ReS$^3$-ConvSet w/o symmetry &39.68 &0.9471 &0.0616 \\
ReS$^3$-ConvSet &39.85 &0.9478 &0.0606 \\ \hline
\tabucline[1pt]{*}
\end{tabu}}
\end{table}
\begin{table}[t]
\caption{Results of the ablation study towards the symmetry property of our ReS$^3$-ConvSet over HS image super-resolution with $\alpha=4$ on the CAVE dataset. For the ReS$^3$-ConvSet w/o symmetry, we utilized different numbers of channels for each 1-D convolution in ReS$^3$-ConvSet, i.e., the three dimensions of the HS image are unequally essential in this setting.}\vspace{-0.35cm}
\centering
\label{tab:ab-symm-sr-cave}
\resizebox{0.45\textwidth}{!}{
\begin{tabu}{c|c|c|c}
\tabucline[1pt]{*}
Methods &MPSNR$\uparrow$ &MSSIM$\uparrow$ &SAM$\downarrow$ \\ \hline
ReS$^3$-ConvSet w/o symmetry &41.20 &0.9670 &3.427 \\
ReS$^3$-ConvSet &41.35 &0.9671 &3.418 \\ \hline
\tabucline[1pt]{*}
\end{tabu}}
\end{table}
\subsection{Ablation Study}
\label{ab-study}
\subsubsection{ReS$^3$-ConvSet with different rank upper bounds}
We compared our ReS$^3$-ConvSet with different rank upper bounds in Table \ref{tab:diff-rub}, where it can be observed that all cases
obtain better performance than the original 3-D convolution. When the rank upper bound exceeds $3M$, it only provides modest performance improvement. We thus adopt the ReS$^3$-ConvSet with the rank upper bound of $3M$, i.e., Fig. \ref{fig:filter-rank}(\textcolor{red}{d}), in all the remaining experiments.
\subsubsection{The number of ReS$^3$ blocks}
We conducted ablation studies to explore how the number of ReS$^3$ blocks involved in our constructed denoising and super-resolution frameworks affects the performance.
For denoising, we varied the number of ReS$^3$ blocks in the range from 1 to 7. As shown in Fig. \ref{fig:d-sr-ab-num-reblock} (\textcolor{red}{a}), it can be observed that increasing the number of ReS$^3$ blocks is able to improve denoising performance.
Observing that when the number of ReS$^3$ block goes up to 5, the denoising performance tends to be stable and even drops slightly, we hence set the number of ReS$^3$ blocks to 5 in all the remaining experiments of HS image denoising task.
For super-resolution, we evaluated with various numbers of ReS$^3$ blocks, i.e., 1, 4, 9, 11, and 13. As shown in Fig. \ref{fig:d-sr-ab-num-reblock} (\textcolor{red}{b}), it can be observed that with the number of ReS$^3$ blocks increasing,
the quality of HS super-resolved image improves. However, when the number of ReS$^3$ block goes up to 11, the performance of our method starts to drop slightly, we thus chose the number of ReS$^3$ blocks to 11 in all the remaining experiments of HS image spatial super-resolution task.
\subsubsection{Contributions of ReS$^3$-ConvSet and DA-Reg}
Tables \ref{tab:d-ab-loss-icvl}, \ref{tab:ab-loss-sr-cave}, and \ref{tab:cls-ab-loss-ip} list the results of our constructed denoising, super-resolution, and classification frameworks with or without the proposed ReS$^3$-ConvSet and DA-Reg. It can be observed that both ReS$^3$-ConvSet and DA-Reg make contributions to the satisfactory performance.
\subsubsection{Quantitative comparisons of various convolution manners}
For fair comparisons, we built various denoising, super-resolution, and classification methods by only replacing the 1-D convolutional kernels in our ReS$^3$ block with the variants and retaining all the other settings (e.g., connections, aggregation, etc.). Besides, we also provided the results of 3-D convolution for reference.
As listed in Tables \ref{tab:d-ab-comb-icvl}, \ref{tab:sr-ab-comb-cave}, and \ref{tab:cls-ab-comb-ip}, it can be seen that compared with the 3-D convolution, all the convolution variants show their advantages on either quantitative performance or network compactness (\#Params) and complexity (\#FLOPs).
Generally, a higher upper bound of the rank produces better performance, which is consistent with our theoretical analysis.
Particularly, our ReS$^3$-ConvSet equipped with the second fewest number of network parameters has the highest rank upper bound during the feature extraction process and thus achieves the best quantitative performance, convincingly demonstrating its superiority and the importance of filter diversity in designing feature extraction module.
\subsubsection{Distribution of singular values of the feature matrix}
We compared the distributions of the singular values of the feature matrices learned by different convolution manners.
Specifically, we unfolded the feature embeddings from different convolution patterns (i.e., 3-D, Sequential 1-D, Sequential 1-D and 2-D, 1-D + 2-D, and the proposed ReS$^3$-ConvSet) into feature matrices. Then, we computed the singular values of these feature matrices via singular value decomposition (SVD). Note that we selected those feature embeddings from the layers at the same depth for a fair comparison. As shown in Fig. \ref{fig:d-sr-cls-ab-sv-comparison}, it can be clearly seen that the singular values of the feature matrix by our methods
decrease more slowly than those of other schemes, demonstrating that the proposed methods can avoid only a few large singular values dominating the feature space, thus promoting feature diversity.
\subsubsection{The symmetry property of our ReS$^3$-ConvSet.}
We validated the importance of symmetry property of our ReS$^3$-ConvSet. As listed in Tables \ref{tab:ab-symm-den-cave} and \ref{tab:ab-symm-sr-cave}, it can be seen that our ReS$^3$-ConvSet equipped with the symmetry property shows its advantage in reconstruction performance.
\section{Conclusion}
\label{sec:con}
In this paper, we first proposed an efficient and effective feature embedding module, named ReS$^3$-ConvSet, under the theoretical analysis that improving the rank of the matrix formed by unfolded convolutional filters can promote feature diversity. Specifically, originating from the altering the topology of 3-D convolution, ReS$^3$-ConvSet promoted the rank upper-bound via separately performing 1-D convolution along the three dimensions of HS images side-by-side, thus making it not only well embed the high-dimensional spatio-spectral information of HS images but also reduce the computational complexity. In addition, we also designed a novel diversity-aware regularization term, named DA-Reg, to explicitly enhance feature diversity by regularizing the singular value distribution of unfolded feature volumes. We demonstrated the significant advantages of the proposed ReS$^3$-ConvSet and DA-Reg by applying them to HS image denoising, spatial super-resolution, and classification.
\if 0
In this paper, we first proposed ReS$^3$-ConvSet, an efficient and effective module for extracting high-dimensional spatial-spectral information of HS images. Specifically,
based on the theoretical analysis that improving the rank of the matrix formed by unfolded convolutional filters can promote feature diversity,
we designed ReS$^3$-ConvSet by separately performing 1-D convolution along the three dimensions of HS images side-by-side and then aggregating the output, thus making it not only well capture the high-dimensional spatial-spectral information of HS images but also reduce the computational complexity.
In addition, a novel feature diversity promotion loss was introduced to incorporate with the proposed ReS$^3$-ConvSet for explicitly promoting feature diversity.
We conducted extensive experiments on various HS-based tasks, i.e., HS image denoising, spatial super-resolution, and classification, demonstrating the significant superiority of such a concise method over state-of-the-art methods both quantitatively and visually.
\fi
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2023-01-18T02:13:41', 'yymm': '2301', 'arxiv_id': '2301.06132', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06132'} | arxiv |
\section{Introduction}\label{sec-intro}
Jamming attacks are severe security threats to wireless systems owing to the broadcast nature of radios~\cite{Zou2016,Amuru2015, yuan2019Secrecy, yuan20}. Many techniques have been adopted to defend against jamming attacks, such as beamforming, frequency hopping, and power control~\cite{Gao2018Game, Hanawal2016, Zhou2017Jamsa}.
Reprogrammable metasurfaces, also known as reconfigurable smart surfaces (RISs), are one of the emerging technologies for wireless systems that have been proposed to combat interference~\cite{Yang2021Intelligent,Renzo2020Smart,Basar2019Wireless}.
For example, RIS was considered to empower smart radio environments \cite{Renzo2020Smart} and facilitate wireless communications \cite{Basar2019Wireless}.
An RIS is typically composed of densely placed, low-cost, passive meta-atoms, and can reconfigure the radio propagation environments between a transmitter-receiver pair, by fine-tuning the phase shifts of the passive meta-atoms to produce favorable scatterings and reflections~\cite{Renzo2020Smart,Basar2019Wireless,Wu2019Intelligent,Li2021Intelligent}.
Fig.~\ref{fig-sysmodel} depicts a generic downlink scenario of a multiuser Orthogonal Frequency Division Multiple Access (OFDMA) system under a jamming attack.
An RIS is deployed to help the users reject the jamming signals and enhance the desired signals.
It is crucial to holistically design the user selection, channel allocation, modulation-coding, and RIS configuration by comprehensively considering discrete modulation-coding modes and potentially multiple data streams with diverse quality-of-service (QoS) per user.
It is also critical that the design does not rely on the assumed availability of channel knowledge, especially the channels involving the jammer, as opposed to many existing studies~\cite{Shen2019Secrecy, Chu2020, Cui2019Secure}.
The user and modulation-coding selection, channel allocation, and RIS configuration are expected to be optimized by exploration and exploitation in the absence of channel knowledge.
The motivation of this paper is to design a practical approach to user scheduling, subchannel assignment, power allocation, and RIS configuration for an emerging RIS-assisted, downlink, multiuser OFDMA system, under prominent practical constraints arising from the difficulty in estimating the channels to and from the RIS, and from the mixed integer programming nature of the problem.
Considering a generic scenario, we assume that each user can have multiple data streams with different quality requirements (e.g., the base and enhancement layers of video traffic). We also assume that there can be an intentional jamming device (or an unintentional interference source) in the system.
The problem is new and challenging.
To the best of our knowledge, the problem has never been studied in the existing literature.
\begin{figure}[ht]
\centering
\includegraphics[width=0.9\columnwidth]{IRS_sysModel_v1.pdf}
\caption{An illustration on an RIS-assisted, downlink multiuser OFDMA system under a jamming attack.}
\label{fig-sysmodel}
\end{figure}
\subsection{Related Work}
Many existing studies on RIS-assisted, secure wireless systems have assumed that the base station (BS) possesses perfect and instantaneous CSI of individual channels, including those involving the RISs, and jammers or eavesdroppers~\cite{Shen2019Secrecy, Chu2020, Cui2019Secure}.
Typical solvers, such as alternating optimization~(AO), semidefinite relaxation (SDR), fixed-point iteration method, and block-coordinate descent (BCD), have been applied to obtain approximate solutions~\cite{Shen2019Secrecy, Chu2020, Cui2019Secure, Hong2021Artificial}.
AO was used to devise the beamformer of the BS and the phase shifts of the RIS, to optimize the secrecy rate of an RIS-assisted, secure MISO system~\cite{Shen2019Secrecy}.
SDR was used to optimally configure the RIS and allocate the power of the BS to enhance the secrecy rate in the existence of an eavesdropper~\cite{Chu2020}.
In~\cite{Cui2019Secure}, both AO and SDR were adopted to improve the secrecy rate by optimally assigning the transmit beamformer and configuring the RIS.
In~\cite{Hong2021Artificial}, BCD was used to optimize the beamformer and artificial noise~(AN) covariance matrix of the BS and the phase shifts of the RIS, thereby maximizing the sum rate of AN-aided multiple-input multiple-output (MIMO) systems.
Considering imperfect CSI, the authors of \cite{Yu2020Robust, Ge2021Robust, Wang2021Distributionally,Sun2021Intelligent}
provided robust designs of the RIS and the BS's beamformers in the presence of jammers or eavesdroppers.
In~\cite{Yu2020Robust}, the imperfect CSI was exploited to optimize the transmit beamformer and AN covariance matrix of the BS, and the phase shifts of the RIS, under the constraint of the maximum allowed information leakage.
In~\cite{Ge2021Robust}, active and passive secure beamforming techniques were developed under a deterministic CSI error model.
In~\cite{Wang2021Distributionally}, a moment-based random error model was used to model CSI errors, followed by optimizing the secure beamformer of the BS and the RIS configuration.
The authors of~\cite{Sun2021Intelligent} maximized the sum rate by jointly designing the BS's transmit beamformer and configuring the RIS without knowing the jammer's transmit beamformer, when there is a jammer and an eavesdropper.
The bounded CSI error model of a third-party node was assumed over each link. The error bounds were known to the BS.
These methods~\cite{Yu2020Robust, Ge2021Robust, Wang2021Distributionally,Sun2021Intelligent} all needed the statistical CSI.
Despite deep reinforcement learning (DRL) has been increasingly applied to wireless communication systems, e.g., spectrum sensing~\cite{Chang2022DEQN}, mobile edge computing~\cite{2020XiaoReinforcement}, and resource allocation~\cite{2022HazarikaDRL}, only a few works have adopted DRL for RIS-assisted secure communications, i.e.,~\cite{Yang2021Intelligent} and~\cite{Yang2021Deep}. The phase shifts of the RIS were also discretized to produce a discrete action space in the few studies~\cite{Yang2021Intelligent, Yang2021Deep}.
Unfortunately, none of these existing studies can apply to the problem at hand,
due to the complex and mixed integer programming nature of the problem (with the continuous RIS configuration and discrete selection of the user, data stream, subchannel, and modulation-coding mode).
In~\cite{2020XiaoReinforcement}, a DRL-based mobile offloading scheme was proposed for edge computing against jamming. In the scheme, an actor network chooses continuous offloading policies. A critic network updates the actor network weights to improve the computational performance without knowing the task generation model, edge computing model, and jamming model. Although the continuous action spaces were considered, the problem studied in [R6] did not consider an RIS and is substantially different from this paper.
As found in~\cite{Choi2011Implementation}, adaptive modulations of grouped subcarriers can improve OFDM performance in millimeter wave (mmWave) frequencies.
In \cite{Jian2021Baseband}, waveform and modulation-coding were designed to lower the peak-to-average-power ratio of terahertz transmissions.
In~\cite{morales2021adapt}, modulation-coding was adapted to the received power of terahertz signals.
In \cite{Zhang2020Augmenting}, an adaptive modulation-coding mechanism was developed for a tunable reflector-assisted mmWave system. The outage probability and throughput of the mechanism
were analyzed using stochastic geometry.
However, these studies~\cite{Choi2011Implementation, Jian2021Baseband, morales2021adapt, Zhang2020Augmenting} were restricted to a single-user setting, and cannot apply to the new multiuser scenario considered in this paper.
\subsection{Contribution and Organization}
In this paper, we jointly optimize the user selection, channel allocation,
modulation-coding, and RIS configuration for an RIS-assisted downlink multiuser OFDMA system under a jamming attack.
A new DRL-based approach is developed, which does not require the CSI knowledge of individual links and learns only through the changes in the readily available received data rates of the users to configure the RIS, reject the jamming signals, support diverse data qualities, and maximize the sum rate of the system.
The key contributions of this paper are listed, as follows.
\begin{itemize}
\item A new problem is considered to comprehensively optimize the user and modulation-coding selection, channel allocation, and RIS configuration in a downlink multiuser OFDMA system under a jamming attack. The RIS is configured to diffuse the jamming signals and direct the desired signals to the intended recipients.
\item
We decouple the continuous RIS configuration from the discrete user and modulation-coding selection and channel allocation. A new twin delayed deep deterministic policy gradient (TD3) model is designed to adaptively configure the RIS by learning only from the changes in the received data rates of the users, hence eliminating the need of CSI knowledge.
\item
A winner-takes-all strategy is designed to deliver the almost surely optimal user and modulation-coding selection, and channel allocation, hence reducing the action space and contributing to the fast and reliable convergence of the TD3 model.
\end{itemize}
Extensive simulations confirm that the proposed TD3-based framework significantly outperforms its non-learning alternatives in terms of sum rate.
The gain of a meticulously configured RIS is demonstrated, as the system with 40, 60, or 80 reflecting elements at the RIS provides 16.50\%, 32.91\%, or 51.86\% higher sum rates than the system without the RIS, respectively.
Eliminating the need of CSI, the proposed framework is of significant practical value.
The remainder of this paper is arranged as follows.
Section \ref{sec-model} sets forth the system model.
Section \ref{sec-ddpg} articulates with the new TD3-based framework for joint user and modulation-coding selection, channel allocation, and RIS configuration.
In Section~\ref{sec-sim}, the new framework is numerically evaluated,
followed by conclusions in Section~\ref{sec-con}.
Notations used in the rest of the paper are collated in Table~\ref{table_notations}.
\begin{table}[t
\caption{Notation and Definition}
\renewcommand\tabcolsep{1.2pt}
\begin{center}
\begin{tabular}{ll}
\toprule[1.5pt]
Notation & Definition \\
\hline
$M$ & Number of users \\
$\cal M$ & Set of users \\
$N$ & Number of the reflecting elements of the RIS\\
${\cal N}$ & Set of the reflecting elements of the RIS\\
$K$ & Number of subchannels\\
${\cal K}$ & Set of subchannels\\
$L$ & Number of modulation-coding modes\\
${\cal L}$ & Set of modulation-coding modes\\
$Q$ & Number of data streams\\
${\cal Q}$ & Set of data streams\\
$\mathbf{x}_k$ & Transmit symbols in the $k$-th subchannel\\
$h^{d}_{m,k}$ & Channel coefficient from BS to the $m$-th user in the $k$-th \\ & subchannel\\
$\mathbf{h}^{ru}_{m,k}$ & Channel vector from RIS to the $m$-th user in the $k$-th\\ & subchannel\\
$\mathbf{h}^{br}_k$ & Channel matrix from BS to RIS in the $k$-th subchannel\\
$h^{br}_{k} (n)$ & Channel coefficient from BS to the $n$-th \\ &reflecting element of the RIS\\
$\mathbf{h}^{Jr}_k$ & Channel matrix from jammer to RIS in the $k$-th \\ & subchannel\\
$h^{Jr}_{k} (n)$ & Channel coefficient from jammer to the $n$-th reflecting\\ & element of the RIS\\
$\mathbf{\Phi}$ & The RIS's reflection matrix $\mathbf{\Phi} \triangleq \text{diag}\{\phi_{1},\cdots,\phi_{N}\}$\\
$\phi_{n}$ & Reflection coefficient of the $n$-th reflecting element \\ & of the RIS \\
$\theta_{n}$ & Phase shift of the $n$-th reflecting element of the RIS\\
$h^{Jd}_{m,k}$ & Channel coefficient from the jammer to the $m$-th user\\ & in the $k$-th subchannel\\
$h_{m,k}$ & Effective channel from the BS to the $m$-th user in \\ & the $k$-th subchannel\\
$h^J_{m,k}$ & Effective channel from the jammer to the $m$-th user \\ & in the $k$-th subchannel\\
${n}_{m,k}$ & CSCG noise with zero mean and variance $\sigma^2$\\
$\eta^{(q)}_{m,k,l}\left(|h_{m,k}|^2\right)$ & Indicator for the selection of the $k$-th subchannel and \\ & the $l$-th modulation-coding mode to deliver the $q$-th\\ & data stream of the $m$-th user \\
$r_l$ & Transmit rate of the $l$-th modulation-coding mode\\
$p^{(q)}_{m,k,l}\left(|h_{m,k}|^2\right)$ & Minimum transmit power required for the BS to deliver\\ & the $q$-th data stream of the $m$-th user in $k$-th subchannel\\ & the using the $l$-th modulation-coding mode \\
$P_{\max}$ & Maximum transmit power of the BS\\
$P_J$ & Transmit power of the jammer \\
$\varrho_{m,k,l}$ & Bit error rate (BER) of the $m$-th user in the $k$-th \\ & subchannel using the $l$-th modulation-coding mode\\
$\varrho_0$ & BER requirement for all data streams of all users\\
\toprule[1.5pt]
\end{tabular}
\end{center}
\label{table_notations}
\end{table}
\section{System Model}\label{sec-model}
We study an RIS-assisted downlink multiuser OFDMA system, where a single-antenna BS serves $M$ single-antenna users via $K$ orthogonal subchannels, as illustrated in Fig.~\ref{fig-sysmodel}.
A malicious single-antenna jammer is located near the users and
sends jamming signals in an attempt
to block the legitimate receptions of the users.
An RIS comprising a uniform rectangle array (URA) of $N = N_y \times N_z$ reflecting elements is installed on the facade of a building, which is controlled by the BS to help reject/diffuse the jamming signals and enhance the legitimate communications.
Here, $N_y$ and $N_z$ are the numbers of reflecting elements in each row and column of the RIS, respectively.
The phase shifts of the RIS's reflecting elements are individually adjustable with a smart controller.
Denote by ${\cal M} = \{1,\cdots,M\}$, ${\cal K} = \{1,\cdots,K\}$, and ${\cal N} = \{1,\cdots,N\}$ the sets of users, subchannels, and RIS's reflecting elements, respectively.
We consider that the BS configures the RIS and sends pilot signals at the beginning of every block. The users estimate their effective channels, and feed back their achievable rates to the BS.
The BS selects users, and allocates subchannels and modulation-coding modes for delivery of different data streams to the users in the rest of the block, only based on the users' feedback of their achievable data rates. No explicit CSI of the channels is needed.
This consideration is practically interesting, due to the difficulty and significant overhead needed to estimate the individual channels involving the RIS or the jammer~\cite{Hu2021Two}. In contrast, the received data rates can be readily measured and reported by the users~\cite{Lin2020Deep}.
Let ${\mathbf{x}}_k \triangleq \left[x_{1,k},\cdots,x_{M,k}\right]^T \in {\mathbb{C}^{M \times 1}}$ denote the transmit symbols for the $M$ users in the $k$-th subchannel, and $\mathbf{x}_k^J \triangleq \left[x^J_{1},\cdots,x^J_{K} \right]^T \in {\mathbb{C}^{K \times 1}} $ denote the jamming signals on the $K$ subchannels.
The jamming signals follow the zero-mean circularly symmetric complex Gaussian (CSCG)
distribution with variance $P_J$ \cite{Amuru2015}.
The received signal at the $m$-th user in the $k$-th subchannel is
\begin{equation}\label{eq-ym}
\begin{aligned}
y_{m,k} &= \left[\left(\mathbf{h}^{ru}_{m,k} \right)^H \mathbf{\Phi} \mathbf{h}^{br}_k + h^d_{m,k} \right] \sqrt{p_{m,k}} x_{m,k} \\
&\quad+ \left[\left(\mathbf{h}^{ru}_{m,k} \right)^H \mathbf{\Phi} \mathbf{h}^{Jr}_k + h^{Jd}_{m,k} \right] \sqrt{p_{k}^{J}} x^{J}_{k} + n_{m,k}, \forall m,k,
\end{aligned}
\end{equation}
where $h^{d}_{m,k}$ is the channel coefficient from BS to the $m$-th user in the $k$-th subchannel; $\mathbf{h}^{ru}_{m,k} = \left[ h^{ru}_{m,k} (1),\cdots, h^{ru}_{m,k} (N) \right]^T \in \mathbb{C}^{N \times 1}$ is the channel vector from RIS to the $m$-th user in the $k$-th subchannel;
$\mathbf{h}^{br}_k= \left[h^{br}_{k} (1),\cdots, h^{br}_{k} (N)\right]^T \in \mathbb{C}^{N \times 1}$ is the channel matrix from BS to RIS in the $k$-th subchannel, and $h^{br}_{k} (n), \;n \in {\cal N}$ is the channel coefficient from BS to the $n$-th RIS's reflecting element;
$p_{m,k}$ is the BS's transmit power for the $m$-th user in the $k$-th subchannel;
$h^{Jd}_{m,k}$ is the channel coefficient from the jammer to the $m$-th user in the $k$-th subchannel;
$\mathbf{h}^{Jr}_k = \left[h^{Jr}_{k} (1),\cdots, h^{Jr}_{k} (N)\right]^T \in \mathbb{C}^{N \times 1}$ is the channel matrix from the jammer to RIS in the $k$-th subchannel, with $h^{Jr}_{k} (n), \;n \in {\cal N}$ being the channel coefficient from the jammer to the $n$-th RIS's reflecting element;
$p^J_{k}$ is the transmit power of the jammer in the $k$-th subchannel;
${n}_{m,k} \in {\cal CN}\left(0,\sigma^2 \right), \forall m \in {\cal M},\;k \in {\cal K}$ is the zero-mean CSCG noise with variance $\sigma^2$;
and $\mathbf{\Phi} \triangleq \text{diag}\{\phi_{1},\cdots,\phi_{N}\}$ is the RIS's reflection matrix.
$\phi_{n} = e^{j\theta_{n}}$ is the reflection coefficient of the $n$-th reflecting element of the RIS with
$\theta_{n} \in [0,2\pi)$ being the phase shift of the reflecting element, and $\left|\phi_{n} \right| \leq 1$.
Being a transmitting device, the jammer can be hardly aware of the user selection at each subchannel. It is reasonable for the jammer to transmit its full power across the spectrum to block the users.
The effective channel coefficients from the BS or jammer to the $m$-th user in the $k$-th subchannel are given by
\begin{equation}
h_{m,k} = \left(\mathbf{h}^{br}_k \right)^H \mathbf{\Phi}^H \mathbf{h}^{ru}_{m,k} + h^d_{m,k}, \; \forall m \in {\cal M},\; k \in {\cal K};
\end{equation}
\begin{equation}
h^J_{m,k} = \left(\mathbf{h}^{Jr}_k \right)^H \mathbf{\Phi}^H \mathbf{h}^{ru}_{m,k} + h^{Jd}_{m,k}, \; \forall m \in {\cal M},\; k \in {\cal K}.
\end{equation}
Suppose that the channels undergo block fading, i.e., the channels are unchanged within a block and vary independently between blocks~\cite{Viswanathan1999Capacity}.
The received signal-to-interference-plus-noise ratio (SINR) at the $m$-th user in the $k$-th subchannel is
\begin{equation}
\gamma_{m,k} = \frac{ p_{m,k}|h_{m,k}|^2}{p^J_{k}|h^J_{m,k}|^2 + \sigma^2}.
\end{equation}
The BS can select the $l$-th modulation-coding mode from a discrete set of modulation-coding modes ${\cal L}$, and the corresponding transmit rate is $r_l, \;l \in {\cal L} = \{0, 1, \cdots, L\}$. The number of available modulation-coding modes is $L=|\mathcal{L}|$, where $|\cdot|$ stands for cardinality.
Note that $l = 0$ indicates no transmission, i.e., $r_0 =0$.
By employing the $l$-th modulation-coding mode, the BER at the $m$-th user in the $k$-th subchannel is~\cite{Goldsmith1998}
\begin{equation}\label{eq-ber}
\varrho_{m,k,l} = \beta_1 \exp\left(\frac{\beta_2 \gamma_{m,k}}{2^{r_l} - 1} \right),
\end{equation}
where $\beta_1$ and $\beta_2$ are constants depending on the modulation-coding scheme.
We also consider $Q$ data streams with different BER requirements for each user. The index to the data streams is $q\in {\cal Q} = \{1,\cdots,Q\}$. For illustration convenience, we set $Q =2$, where $q=1$ indicates high-quality (HQ) data streams and $q=2$ indicates low-quality~(LQ) data streams.
To meet the BER requirements $\varrho^{(q)}_0, q \in {\cal Q}$ (or in other words, the QoS requirements) of the $q$-th data stream, the minimum transmit power required for the BS to deliver the $q$-th data stream of the $m$-th user in the $k$-th subchannel using the $l$-th modulation-coding mode is~\cite{Malik2018Interference}
\begin{equation}\label{eq-power}
p^{(q)}_{m,k,l}\left(|h_{m,k}|^2, |h^J_{m,k}|^2\right) = \frac{\left(2^{r_l} -1 \right) \ln\left(\frac{\beta_1}{\varrho^{(q)}_0} \right)\left(p^J_{k}|h^J_{m,k}|^2 + \sigma^2 \right) }{\beta_2 \left|h_{m,k}\right|^2}.
\end{equation}
\section{Proposed Channel Allocation, Modulation-coding selection, and RIS Configuration}\label{sec-ddpg}
The BS assigns the subchannels for the users, select the modulation-coding modes, and configures the RIS.
Let $\eta^{(q)}_{m,k,l}(|h_{m,k}|^2, |h^J_{m,k}|^2 ) = 1$ indicate the selection of the $k$-th subchannel and the $l$-th modulation-coding mode for transmitting the $q$-th data stream of the $m$-th user, given $|h_{m,k}|^2$ and $|h^J_{m,k}|^2$; and $\eta^{(q)}_{m,k,l} = 0$ indicates otherwise.
Let $\bm{\eta} := \left\lbrace \eta^{(q)}_{m,k,l}(|h_{m,k}|^2, |h^J_{m,k}|^2), \;\forall m \in {\cal M},\;k \in {\cal K},\;l \in {\cal L},\;q \in {\cal Q}\right\rbrace $ collect all indicators.
The transmit rate for delivering the $q$-th data stream of the $m$-th user in the $k$-th subchannel is
\begin{equation}
R^{(q)}_{m,k}\left(\bm{\eta}\right) = \sum_{l=0}^{L} \eta^{(q)}_{m,k,l}\left(|h_{m,k}|^2,|h^J_{m,k}|^2 \right) r_l.
\end{equation}
The sum rate of the system is given by
\begin{equation}\label{eq-sum_rate}
\begin{aligned}
R_{\rm{tot}}\left(\bm{\eta}\right) = \!\sum_{m = 1}^{M}\! R_m \left(\bm{\eta}\right)
= \!\sum_{m = 1}^{M} \sum_{k = 1}^{K}\sum_{l=0}^{L}\sum_{q=1}^{Q}\! \eta^{(q)}_{m,k,l}\left(|h_{m,k}|^2, |h^J_{m,k}|^2 \right) r_l,
\end{aligned}
\end{equation}
where $R_m \left(\bm{\eta}\right) = \sum_{k = 1}^{K}\sum_{l=0}^{L}\sum_{q=1}^{Q} \eta^{(q)}_{m,k,l}\left(|h_{m,k}|^2, |h^J_{m,k}|^2 \right) r_l$ is the data rate received at the $m$-th user.
The total transmit power of the BS for the $m$-th user is
\begin{equation}
P_m\left({\bm{\eta}}\right) = \!\sum_{k = 1}^K \sum_{l=0}^{L}\sum_{q=1}^{Q}\! \eta^{(q)}_{m,k,l}\left(|h_{m,k}|^2, |h^J_{m,k}|^2 \right) p^{(q)}_{m,k,l}\left(|h_{m,k}|^2, |h^J_{m,k}|^2 \right),\forall m.
\end{equation}
The total transmit power of the BS is
\begin{equation}
P\left({\bm{\eta}}\right) = \!\sum_{m = 1}^M \sum_{k = 1}^K \sum_{l=0}^{L}\sum_{q=1}^{Q}\! \eta^{(q)}_{m,k,l}\left(|h_{m,k}|^2, |h^J_{m,k}|^2 \right) p^{(q)}_{m,k,l}\left(|h_{m,k}|^2, |h^J_{m,k}|^2 \right).
\end{equation}
We jointly design the selection of channels, user and modulation-coding modes, $\bm{\eta}$, and the configuration of the reflection matrix of the RIS, $\mathbf{\Phi} \in \mathbb{C}^{N \times N}$, to maximize the sum rate of the system while meeting the BER requirements of the users, $\varrho_0^{(q)},\,\forall q\in \mathcal{Q}$. The transmit power of the BS is upper bounded by $P_{\max}$.
The problem is cast as
\begin{subequations}\label{eq-P1}
\begin{align}
\textbf{P1}:\;\max_{\{\mathbf{\Phi}, \bm{\eta} \}}\;\; & R_{\rm{tot}}\left({\bm{\eta}} \right) \\
{\text{s.t.}}\; & P\left({\bm{\eta}}\right) \leq P_{\max},\label{eq-P1 b}\\
& \theta_{n} \in [0,2\pi), \forall n \in {\cal N}, \label{eq-P1 c}\\
&\sum_{k=1}^{K}\left\lbrace \sum_{m = 1}^M\sum_{l=0}^{L}\sum_{q=1}^{Q} \eta^{(q)}_{m,k,l} \left(|h_{m,k}|^2, |h^J_{m,k}|^2\right)\right\rbrace \leq K,\label{eq-P1 d}\\
&\sum_{m = 1}^M\sum_{l=0}^{L}\sum_{q=1}^{Q} \eta^{(q)}_{m,k,l} \left(|h_{m,k}|^2, |h^J_{m,k}|^2\right) \leq 1,\label{eq-P1 e}\\
& \eta^{(q)}_{m,k,l} \left(|h_{m,k}|^2, |h^J_{m,k}|^2\right) \in \{0,1\}, \label{eq-P1 f}\\
& R^{(1)}_m\left(\bm{\eta}\right) = \chi R^{(2)}_m\left(\bm{\eta}\right). \label{eq-P1 g}
\end{align}
\end{subequations}
Constraint~\eqref{eq-P1 c} specifies the range of the RIS's phase shifts;
\eqref{eq-P1 d} indicates the number of subchannels assigned to all users is no larger than~$K$;
\eqref{eq-P1 e} indicates that each subchannel is assigned to no more than one user to prevent inter-user interference. Once $\eta^{(q)}_{m,k,l}$ is determined, the transmit power for the $m$-th user in the $k$-th subchannel using the $l$-th modulation-coding mode, i.e., \eqref{eq-power}, is specified to meet the BER requirement.
In~\eqref{eq-P1 g}, $\chi$ is the ratio of the HQ and LQ data streams, which needs to be maintained between the streams, e.g., for streaming videos with layered coding~\cite{He2014Optimal}.
\begin{figure*}[tb]
\centering
\includegraphics[width=1.6\columnwidth]{images/psd_td3.pdf}
\caption{An overview of the proposed TD3-based framework for jointly optimizing the user selection, channel allocation, modulation-coding, and RIS configuration. The top of the figure optimizes the discrete user and modulation-coding selection and channel allocation using primal-dual subgradient descent, given the RIS configuration. The bottom optimizes the RIS configuration using TD3, given the outcome of the top. }
\label{fig-algorithm}
\end{figure*}
Problem \textbf{P1} is a non-convex combinatorial problem, and intractable for conventional optimization techniques.
We design a new framework to solve the problem, which configures the RIS by using DRL. Given a possible configuration of the RIS, we rely on primal-dual subgradient descent (PSD) to optimize the allocations of subchannels and modulation-coding modes by using a winner-takes-all strategy.
By iteratively configuring the RIS and optimizing the allocations, the framework can substantially reduce the state and action spaces of the DRL and quickly converge to a superb solution.
\subsection{Twin Delayed DDPG (TD3)-based RIS Configuration}\label{subsec-ddpg}
Problem \textbf{P1} can be decoupled into sequential decisions of the RIS configuration, the channel allocation, and the user and modulation-coding selection. Specifically, given an RIS configuration, the received data rates of the users are readily available. The channel allocation, user and modulation-coding selection only depend on the received data rates. The RIS configuration involves $N$ constant-modulus variables, i.e., $\theta_n,\,\forall n\in \mathcal{N}$. The extensively adopted solver, SDR, requires the CSI knowledge of all channels, including those involving the RIS; and can only configure the RIS approximately and suboptimally, due to the need of rank randomization~\cite{Wang2020Robust}.
The benefit of this decoupled learning and optimization structure of the proposed algorithm is two-fold.
\begin{itemize}
\item On the one hand, the need for the instantaneous CSI to and from the IRS is eliminated. The users only need to estimate their effective end-to-end channels based on the pilot signals of the BS, e.g., by using the minimum mean square estimation (MMSE), as done in typical wireless communication systems, e.g., 3GPP LTE. By this means, we can circumvent the impasse of estimating the CSI to and from the RIS.
\item On the other hand, the primary subgradient descent-based selections of the user, data stream, subchannel, and modulation-coding mode, and power allocation evaluate precisely the maximum reward that can be offered by a given IRS configuration. Under the given RIS configuration, the optimality of the selections is proved rigorously by showing that the selections follow an almost surely unique and optimal ``winner-takes-all'' strategy; see Section \ref{subsec-optimization}. Not only do the optimal selections reduce the state and action spaces of the DRL (which is conducive to the convergence and reliability of the DRL), but ensure the quality of the solution produced by our approach.
\end{itemize}
DRL is an effective dynamic programming tool to solve a sequential decision-making problem by learning optimal solutions in a dynamic environment. In this paper, we employ the DRL to configure the RIS.
Let the BS serve as the agent. The key elements of the DRL model are specified below.
{\textbf{\emph{State Space ${\cal S}$: }}}At the $t$-th learning step, the system state $s_t \in {\cal S}$ is defined as
\begin{equation}\label{eq-state space}
s_t = \left\lbrace R_m,\forall m \in {\cal M} \right\rbrace.
\end{equation}
{\textbf{\emph{Action Space $\cal A$: }}} The action space collects all possible actions, i.e., $\mathcal A:=\{a_t, \forall t =1, \cdots, N\}$. At the $t$-th learning step, action $a_t$ includes the reflecting coefficients $\{\theta_{n}\}_{n \in {\cal N}}$, i.e.,
\begin{equation}\label{eq-action}
a_t = \left\lbrace \theta^{(t)}_{n} \in [0, 2\pi), \forall n \in {\cal N}\right\rbrace.
\end{equation}
{\textbf{\emph{Transition probability: }}}Under action $a_t$, the transition probability from state $s$ to state $s'$ is given by
\begin{equation}\label{eq-transition probability}
P_{a_t}\left(s, s'\right) = \Pr \left( s_{t+1}=s' | s_{t}=s,a_t = a\right).
\end{equation}
{\textbf{\emph{Policy: }}}The mapping from the state space, ${\cal S}$, to the action
space, ${\cal A}$, is known as a policy, $\pi: {\cal S} \to {\cal A}$, which is a distribution
${\pi}(a | s) = \Pr\left(a_t = a | s_t =s \right)$
over state $s \in~{\cal S}$.
{\textbf{\emph{Reward: }}}The reward function provides positive rewards
at each learning step, denoted by $r_t$, for executing action $a_t$, and is defined as
\begin{equation}\label{eq-reward}
r_t = \sum_{m \in {\cal M}} R_{m}\left({\bm{\eta}}\right),
\end{equation}
where $R_m = \sum_{k \in {\cal K}} R_{m,k}$ is the total transmit rate for the $m$-th user.
With a discount coefficient $\gamma\in (0,1)$, the cumulative discounted reward is given by
\begin{equation}\label{eq-reward-dis}
G_t = \sum_{t=0}^{\infty} \gamma^t r_t.
\end{equation}
{\textbf{\emph{Experience: }}}The history experience is defined as $e_t = \left( s_t,a_t,r_t,s_{t+1} \right) $, and memorized in an experience replay buffer, denoted by ${\bm{R}}$.
The agent perceives the current system state $s_t$, picks an available action $a_t$,
obtains a reward $r_t$, and transits to a new state $s_{t+1}$.
A policy, $a_t = \pi(s_t)$, projects the state $s_t$ to a feasible action.
The agent selects the policy maximizing the accumulated reward $G_t$.
Given state $s_t$, action $a_t$, and reward $r_t$, an action-value function, i.e., Q-function, is exploited to evaluate $G_t$, as
$Q_{\pi}(s_t, a_t)=\mathbb E_{\pi}[G_t | s_t, a_t]$.
It satisfies the Bellman Expectation Equation:
\begin{equation}\label{eq-bellman}
\begin{aligned}
Q_{\pi}\left(s_t,a_t \right) & = \mathbb{E}_{r_t, s_{t+1} \sim {\rm\cal E} }\left[r_t + \gamma \mathbb{E}_{a_{t+1}\sim \pi} \left[Q_{\pi}\left(s_{t+1},a_{t+1} \right) \right] \right],
\end{aligned}
\end{equation}
where ${\cal E}$ denotes the environment that the agent interacts with.
It is difficult to apply RL directly to obtain the Q-value, $Q(s_t, a_t)$, owing to the continuous state and action spaces.
Being one of the latest DRL models, TD3 is designed for continuous state and action spaces. To address the Q-value overestimation issue of the deep deterministic policy gradient~(DDPG) algorithm,
TD3 introduces \emph{three improvements} over DDPG, i.e., \emph{clipped double-Q learning with two critics}, \emph{target policy smoothing}, and
\emph{delayed policy update}~\cite{dankwa2019twin}.
\begin{itemize}
\item {\emph{Clipped double-Q learning with two critics: }}TD3 has two critics (i.e., to produce two Q-values), and admits the smaller of the two Q-values to evaluate the target Q-values in the Bellman error loss functions.
\item {\emph{Target policy smoothing: }}TD3 adds noises to the target action and smooths the Q-function value of the actions to make the policy less likely to exploit the errors in the Q-function.
\item {\emph{``Delayed'' policy updates: }}The actors (i.e., policies) are updated less frequently than the critics.
For example, it was recommended in \cite{dankwa2019twin} that the actors are updated after the critics are updated twice.
\end{itemize}
The TD3-based framework is made up of an actor network and a critic network, where the actor network comprises an actor and a target-actor, and the critic network comprises two critics and two target-critics, as shown in Fig.~\ref{fig-algorithm}.
Six deep neural network (DNN) approximators are used in the TD3-based network.
The actor with parameters $\theta_a$, denoted by $\mu\left(s_t; \theta_a \right)$, approximates the policy function of the agent and produces the actions.
The two critics with parameters $\theta_1$ and $\theta_2$, denoted by $Q_{1}(s_t,a_t;\theta_1)$ and $Q_{2}(s_t,a_t;\theta_2)$, estimate two action-value functions of the actions produced by the actor, and output the smaller as the action-value function of the actions~\cite{Silver2014ddpg}.
The target-actor with parameter $\theta'_a$, denoted by $\mu'\left(s_t; \theta'_a \right)$, produces the target policy.
The two target-critics with parameters $\theta'_1$ and $\theta'_2$, denoted by $Q'_{1}(s_t,a_t;\theta'_1)$ and $Q'_{2}(s_t,a_t;\theta'_2)$,
generate two Q-values, of which the smaller is taken as the target Q-value.
Based on the actor-critic setting, the TD3 network follows the deterministic policy gradient (DPG) theorem~\cite{Silver2014ddpg}
to update the parameters, $\theta_a$, $\theta_1$, $\theta_2$, $\theta'_a$, $\theta'_1$ and $\theta'_2$, and optimize the actions.
The use of the target network (comprising a target-actor and two target-critics) prevents unstable learning arising from using only an actor-critic network (with a single actor and critic)~\cite{Hou2017}.
The BS (i.e., the agent) takes the received data rates of
the users as the current state $s_t$, and passes it to the actor.
Following the DPG theorem~\cite{Silver2014ddpg}, the actor produces the current strategy
by deterministically mapping a state to an action.
The actor approximates the policy function of the agent and chooses an action $a_t$.
A random exploration noise is appended to the action to poise the exploration of new actions and the exploitation of known actions.
The output action is
\begin{equation}
a_t = {\text{clip}}\Big(\mu\left(s_t; \theta_a \right) + \epsilon, a_{\min}, a_{\max} \Big),
\end{equation}
where the noise $\epsilon$ is randomly sampled from a zero-mean Gaussian distribution (GN)
with variance $\sigma_e^2$, i.e., $\epsilon \sim {\cal N}(0,\sigma_e^2)$;
$\text{clip}(\cdot)$ is a clipping function to limit the actions within $\left[a_{\min}, a_{\max} \right]$
with $a_{\max}$ and $a_{\min}$ being the upper and lower bounds of the actions, respectively.
As the result of action~$a_t$, the agent is rewarded with~$r_t$ and transits to the state $s_{t+1}$.
The agent perceives the state $s_{t+1}$ and reserves the transition $(s_t, a_t, r_t, s_{t+1})$ in its experience replay buffer ${\bm R}$.
With the input $(s_t, a_t)$, the two critics evaluate the action-value functions of the selected action~$a_t$, i.e., $Q_{1}\left(s_t, a_t;\theta_1 \right)$ and $Q_{2}\left(s_t, a_t;\theta_2 \right)$.
By randomly drawing a sampled transition $(s_i, a_i, r_i,s_{i+1})$ from the experience replay buffer $\bm R$, the action-value functions produced by the two critics are approximated by $Q_{1}\left(s_i, a_i;\theta_1 \right)$ and $Q_{2}\left(s_i, a_i;\theta_2 \right)$.
The lesser of these two approximate action-value functions is chosen as the Q-value of the next state, i.e.,
$Q_{\mu}(s_i, a_i) = \min \left\{Q_{1}\left(s_i, a_i;\theta_1 \right), Q_{2}\left(s_i, a_i;\theta_2 \right) \right\} $.
Given the probability distribution of the parameter $\theta_a$, i.e., $J(\theta_a)$,
the actor network is updated towards the direction in which the estimation improves the strategy fastest.
In other words, $\theta_a$ is updated towards the direction specified by the gradient of $J(\theta_a)$,
which is given by~\cite{Silver2014ddpg}
\begin{subequations}\label{eq-gradient}
\begin{align}
\nabla_{\theta_a} J(\theta_a) & = \mathbb{E}_{s \sim \rho^{\mu}} \left[\nabla_{\theta_a} {{Q}}_{\mu}(s_t,\mu(s_t;\theta_a);\theta_k) \right]\label{eq-gradient a}\\
& = \mathbb{E}_{s \sim \rho^{\mu}} \left[\nabla_{\theta_a} \mu(s_t;\theta_a) \nabla_{a} {{Q}}_{\mu}(s_t,\mu(s_t;\theta_a);\theta_k) \right],\label{eq-gradient b}
\end{align}
\end{subequations}
where $ k= 1$ or $2$; \eqref{eq-gradient b} is derived from the chain rule;
$\rho^{\mu}$ is a discounted state distribution of policy $\mu(s_t;\theta_a)$~\cite{Timothy2016Continuous};
$\nabla_{\theta_a} \mu(s)$ is the gradient of the actor $\mu(s)$ with respect to (w.r.t.) the parameter $\theta_a$; and $\nabla_{a} {{Q}}_{\mu}(s_t,a;\theta_a)$ is the gradient of ${{Q}}_{\mu}(s_t,a;\theta_a)$ w.r.t. action $a$.
By randomly sampling $N_{batch}$ historical transitions from the experience replay buffer ${\bm R}$,
$\nabla_{\theta_a} J(\theta_a)$ is approximated by
\begin{equation}\label{eq-gradient-approx}
\nabla_{\theta_a} J(\theta_a)
\!\approx\! \frac{1}{N_{batch}} \!\sum_{i = 1}^{N_{batch}}\!\left[\!\nabla_{\theta_a} \mu(s_i) \nabla_{a} {{Q}}_{\mu}(s_i,a;\theta_c)|_{a = \mu(s_i)} \!\right].
\end{equation}
The parameter of the actor, i.e., $\theta_a$, is updated by using the gradient descent method~\cite{sutton1999policy}
\begin{equation}\label{eq-policy-ascent}
\begin{aligned}
\theta_a & \leftarrow \theta_a + \eta_a \nabla_{\theta_a} J(\theta_a)\theta_a \\
& \quad+ \frac{\eta_a}{N_{batch}} \!\sum_{i = 1}^{N_{batch}}\!\left[\nabla_{\theta_a} \mu(s_i) \nabla_{a} {{Q}}_{\mu}(s_i,a;\theta_c)|_{a = \mu(s_i)} \!\right],
\end{aligned}
\end{equation}
where $\eta_a$ is the learning rate of the actor network.
One issue of deterministic policies is that they can cause overfitting and shrink the peaks used to produce Q-value estimates~\cite{Silver2014ddpg}.
Specifically, when updating the critics in the DDPG model, the target Q-value produced by the deterministic policies are susceptible to the inaccuracies caused by the Q-function estimation errors.
\emph{Target policy smoothing}, a regularization strategy for Q-function value learning~\cite{fujimoto2018addressing}, is used to reduce the inaccuracies.
Based on the randomly sampled $N_{batch}$ past transitions from the experience replay buffer ${\bm R}$, the target action after target policy smoothing is given by
\begin{equation}
a'_{t} = {\text{clip}}\Big( \mu'\left(s_{t+1}; \theta'_a \right) + {\text{clip}\left( \epsilon', -\sigma_m^2, \sigma_m^2\right)},
a_{\min}, a_{\max}\Big),
\end{equation}
where the noise $\epsilon'$ is randomly sampled from a zero-mean GN
with variance $\sigma_a^2$, i.e., $\epsilon' \sim {\cal N}(0,\sigma_a^2)$;
and $\sigma_m^2$ is the maximum exploration noise supported by the environment.
The mean square error (MSE)-based losses coming from the two critics are evaluated as
\begin{equation}\label{eq-loss}
\begin{aligned}
L_k(\theta_k) & = \mathbb{E}_{s_t \sim \rho^{\mu}, a_t \sim \mu(s_t;{\theta_a})}\left[\left( Q_{k}\left(s_t, a_t;\theta_k \right) - y_t \right)^2\right],
\end{aligned}
\end{equation}
where $k= 1$ or $2$; $y_t = r_t + \gamma \min \{Q'_{1}(s_{t+1},a'_{t};\theta'_1),$ $Q'_{2}(s_{t+1},a'_{t};\theta'_2) \}$
is the target Q-value produced by the two target-critics based on the current transition $(s_t, a_t,r_t, s_{t+1})$;
and $\theta'_1$ and $\theta'_2$ are decayed copies of $\theta_1$ and $\theta_2$, respectively.
The smaller Q-value produced by the two target-critics is taken as the target Q-value.
With $N_{batch}$ randomly sampled transitions, the loss function, $L_k(\theta_k)$, is approximated by
\begin{equation}\label{eq-loss 2}
\begin{aligned}
L_k(\theta_k) \approx \frac{1}{N_{batch}} \sum_{i = 1}^{N_{batch}}\left[\left( Q_{k}\left(s_i, a_i\right) - y_i \right)^2\right], \; k= 1,2,
\end{aligned}
\end{equation}
where $y_i = r_i + \gamma \min\Big(Q'_{1}(s_{i+1},a'_{i};\theta'_1), Q'_{2}(s_{i+1},a'_{i};\theta'_2) \Big)$ is the approximate target Q-value produced by the target network based on the $N_{batch}$ randomly sampled transitions.
The smaller approximate target Q-value produced by the two target-critics is taken as the approximate target Q-value.
By differentiating $L_k(\theta_k)$ w.r.t. $\theta_k$, we obtain the gradient as
\begin{equation}\label{eq-critic-update}
\begin{aligned}
\nabla_{\theta_k} L_k(\theta_k)
&\!\approx\! \frac{1}{N_{batch}} \!\sum_{i = 1}^{N_{batch}}\!\Big[\left( Q_{\mu}\left(s_i, \mu(s_i; \theta_a);\theta_k \right) - y_i \right) \\
&\quad\nabla_{\theta_k} {{Q}}_{\mu}(s_i,\mu(s_i; \theta_a);\theta_k)\Big], \; k= 1,2.
\end{aligned}
\end{equation}
The parameters of the two critics, i.e., $\theta_1$ and $\theta_2$, are updated by utilizing the stochastic gradient descent method~\cite{sutton1999policy}.
According to the \emph{``delayed'' policy updates},
the target-actor and the two target-critics evolving from the actor and critics are updated every two iterations by running the Polyak Averaging~\cite{dankwa2019twin}:
\begin{equation}\label{eq-Polyak}
\begin{aligned}
\theta'_a &\leftarrow \rho_{\tau} \theta_a + (1-\rho_{\tau})\theta'_a,\;\\
\theta'_k &\leftarrow \rho_{\tau} \theta_k + (1-\rho_{\tau})\theta'_k,\; k =1,2,
\end{aligned}
\end{equation}
where $\rho_{\tau}$ is the decaying rate of both the actor and critic networks.
\subsection{Optimal Channel Allocation and Rate Adaptation}\label{subsec-optimization}
Given the reflection matrix of the RIS, $\mathbf{\Phi}$, from the TD3 network, the effective channel gains of the BS and jammer to the $m$-th user in the $k$-th subchannel, $|h_{m,k}|^2 $ and $|h^J_{m,k}|^2 $, are readily measurable. We can rewrite problem \textbf{P1} as
\begin{equation}\label{eq-P2}
\textbf{P2}:\;\max_{\bm{\eta}}\;\; R_{\rm{tot}}\left({\bm{\eta}} \right),\;\;
{\text{s.t.}}\;
\eqref{eq-P1 b},\,\eqref{eq-P1 d} - \eqref{eq-P1 g}.
\end{equation}
By defining $\lambda$ as the Lagrange multiplier w.r.t~\eqref{eq-P1 b},
and ${\bm{\nu}} = \{\nu_m,\forall m\}$ as the Lagrange multipliers w.r.t \eqref{eq-P1 g},
the Lagrange function of~\eqref{eq-P2} is
\begin{equation}\label{eq-lagrange}
L\left(\bm{\eta}, \lambda, {\bm{\nu}} \right) \!=\! R_{\rm{tot}} \left(\bm{\eta}\right) - \lambda \left( P\left({\bm{\eta}}\right) - P_{\max} \right) -\! \sum_{m=1}^{M}\!\nu_m\left(\!R^{(1)}_m\left(\bm{\eta}\right) - \! \chi R^{(2)}_m\left(\bm{\eta}\right)\!\right) .
\end{equation}
Further define
\begin{equation}\label{eq-varpi}
\varpi^{(q)}_{m,k,l}\left(\lambda,\nu_m, |h_{m,k}|^2,|h^J_{m,k}|^2 \right) = \left\{
\begin{aligned}
& - \lambda p^{(q)}_{m,k,l}\left(|h_{m,k}|^2,|h^J_{m,k}|^2 \right) \\
& \;\; + \left(1- \nu_m \right) r_l, {\text{if}}\,q=1;\\
& -\lambda p^{(q)}_{m,k,l}\left(|h_{m,k}|^2,|h^J_{m,k}|^2 \right)\\
& \;\; + \left(1+ \nu_m \chi \right) r_l,{\text{if}}\,q=2.
\end{aligned}
\right.
\end{equation}
Then, \eqref{eq-lagrange} is rewritten as
\begin{equation}
\begin{aligned}
&L\left(\bm{\eta}, \lambda, {\bm{\nu}} \right)
= \lambda P_{\max} \!+\! \sum_{k = 1}^K \!\Bigg\lbrace \!\sum_{m = 1}^M \sum_{l=0}^{L}\sum_{q=1}^{Q}\! \eta^{(q)}_{m,k,l}\left(|h_{m,k}|^2, |h^J_{m,k}|^2\right) \\
& \qquad\qquad\qquad\qquad\qquad \times\varpi^{(q)}_{m,k,l}\left(\lambda,\nu_m, |h_{m,k}|^2, |h^J_{m,k}|^2 \right)\!\Bigg\rbrace\!.
\end{aligned}
\end{equation}
The Lagrange dual function is
\begin{equation}\label{eq-lagrange dual}
D\left(\lambda \right) = \max_{\bm{\eta}} L\left(\bm{\eta}, \lambda, {\bm{\nu}}\right).
\end{equation}
The dual problem of \eqref{eq-P2} is given by
\begin{equation}\label{eq-dual}
\min_{\lambda, {\bm{\nu}}} D\left(\lambda, {\bm{\nu}} \right).
\end{equation}
Given $\lambda$ and ${\bm{\nu}}$, the primary variable $\bm{\eta} $ is obtained by solving
\begin{equation}
\begin{aligned}
\max_{\bm{\eta}}\! & \sum_{k = 1}^K \!\Bigg\lbrace \!\sum_{m = 1}^M \sum_{l=0}^{L} \sum_{q=1}^{Q}\! \eta^{(q)}_{m,k,l}\left(|h_{m,k}|^2,|h^J_{m,k}|^2 \right)\\
&\quad\; \times\varpi^{(q)}_{m,k,l}\left(\lambda,\nu_m, |h_{m,k}|^2, |h^J_{m,k}|^2 \right)\!\Bigg\rbrace,\,{\text{s.t.}} \,\eqref{eq-P1 e},~\eqref{eq-P1 f}.
\end{aligned}
\end{equation}
The optimal channel allocation and modulation-coding selection take a ``winner-takes-all'' strategy~\cite{He2014Optimal}. As per the $k$-th subchannel, the $m_k^*$-th user and the $l_k^*$-th modulation-coding mode are selected to deliver the $q^{\ast}$-th data stream:
\begin{equation}\label{eq-pair}
\left\lbrace m^{\ast}_k, l^{\ast}_k, q^{\ast}_k \right\rbrace = \arg \max_{m,l,q}\!\; \varpi^{(q)}_{m,k,l}\left(\!\lambda,\nu_m, |h_{m,k}|^2,|h^J_{m,k}|^2\!\right),\; \forall k \in {\cal K}.
\end{equation}
A greedy strategy can be taken to optimize $\bm{\eta}$:
\begin{equation}\label{eq-opt-eta}
\left\lbrace
\begin{aligned}
&\eta^{(q)\ast}_{m,k,l} \left(\! \lambda,\nu_m ,|h_{m,k}|^2, |h^J_{m,k}|^2\!\right) = 1,\, {\rm{if}}\, \left\lbrace m, l, q \right\rbrace = \left\lbrace m^{\ast}_k, l^{\ast}_k, q^{\ast}_k \right\rbrace;\\
&\eta^{(q)\ast}_{m,k,l} \left(\! \lambda,\nu_m ,|h_{m,k}|^2, |h^J_{m,k}|^2\!\right) = 0,\, {\rm{otherwise}}.
\end{aligned}\right.
\end{equation}
With ${\bm{\eta}^{\ast}\left(\lambda, {\bm{\nu}} \right)}$ obtained in \eqref{eq-opt-eta}, the sub-gradient descent method is taken to update $\lambda$ and ${\bm{\nu}}$ by solving the dual problem~\eqref{eq-dual}.
$\lambda$ and ${\bm{\nu}}$ are updated by~\cite{boyd2004convex}
\begin{subequations}\label{eq-sub-gradient}
\begin{align}
\lambda\left(\tau +1 \right) & = \left[ \lambda(\tau ) + \varepsilon\left(P\left({\bm{\eta}}^{\ast} \left(\lambda\left(\tau \right),{\bm{\nu}}(\tau ) \right) \right) - P_{\max}\right) \right]^+,\\
\nu_m\left(\tau +1 \right)
& = \left[ \nu_m (\tau ) + \varepsilon\left(R^{(1)}_m \left({\bm{\eta}}^{\ast} \left(\lambda\left(\tau \right),{\bm{\nu}}(\tau ) \right)\right) \right.\right.\notag\\
&\left.\left.\qquad\quad\;\,- \chi R^{(2)}_m \left({\bm{\eta}}^{\ast} \left(\lambda\left(\tau \right),{\bm{\nu}}(\tau ) \right)\right)\right) \right]^+,\; \forall m,
\end{align}
\end{subequations}
where $\varepsilon$ is the step size, $\tau$ is the index to the iterations, and $\left[x \right]^+ = \max\left(0,x \right)$. At initialization, $\lambda$ and $\bm{\nu}$ are non-negative, i.e., $\lambda(0) \geq 0$ and $\nu_m(0) \geq 0, \forall m$, to ensure \eqref{eq-sub-gradient} converges.
It is prudent to analyze the optimality of the solution obtained iteratively by~\eqref{eq-opt-eta} and \eqref{eq-sub-gradient}, since problem \eqref{eq-P2} is a non-convex mixed-integer program.
We assert that when the gains of the channels, $|h_{m,k}|^2$ and $|h^J_{m,k}|^2, \forall m\in {\cal M},\, k\in {\cal K}$, have a continuous cumulative distribution function (CDF).
$\eta^{(q)\ast}_{m,k,l} \left( \lambda^{\ast},\nu^{\ast}_m,|h_{m,k}|^2, |h^J_{m,k}|^2\right), \forall m,k$, is the almost surely optimal solution to problem \textbf{P2} (i.e., with probability 1), where $\lambda^{\ast}$ is obtained in \eqref{eq-sub-gradient} with any initial $\lambda(0) > 0$ and $\nu_m(0) > 0$.
The proof can be referred to~\cite{He2014Optimal}. For the completeness of this paper, a sketch of the proof is provided below.
The proof starts by confirming the almost sure uniqueness of the ``winner-takes-all'' strategy ${\bm{\eta}}^{\ast}(\lambda, {\bm{\nu}})$ in all three possible cases. $(a)$ If $\max_{m,l,q} \varpi^{(q)}_{m,k,l}\left(\lambda, \nu_m, |h_{m,k}|^2, |h^J_{m,k}|^2\right) =0$, all users undergo a deep fade in the $k$-th subchannel.
Even if user $m$ is selected for the subchannel, $l^{\ast}_k(\lambda, \nu_m, |h_{m,k}|^2, |h^J_{m,k}|^2) = 0$, the optimal decision of the BS is to not transmit in the subchannel; see~\eqref{eq-opt-eta}.
$(b)$ If $\max_{m,l,q} \varpi^{(q)}_{m,k,l}\left(\lambda,\nu_m, |h_{m,k}|^2, |h^J_{m,k}|^2\right) > 0$ and a single ``winner'' wins the $k$-th subchannel, the optimal strategy in \eqref{eq-opt-eta} is unique.
$(c)$ If $\max_{m,l,q} \varpi^{(q)}_{m,k,l}\left(\lambda, \nu_m, |h_{m,k}|^2, |h^J_{m,k}|^2 \right) > 0$ and multiple $\{m,l,q\}$ triplets can win the $k$-th subchannel with one triplet selected at random, the strategy is non-unique.
This is a Lebesgue measure zero event~\cite{lenz2002singular} under the continuous CDF of the random channel gain.
The non-unique ``winner'' has the ``measure zero'' effect, i.e., the probability of the non-unique ``winner'' is almost zero.
Given its almost sure uniqueness, the ``winner-takes-all" strategy maximizes the Lagrangian function \eqref{eq-lagrange dual}, even if~\textbf{P2} is relaxed to a linear program (LP), i.e., ${\bm{\eta}}^{\ast}(\lambda, {\bm{\nu}})$ can take a continuous value within $[0,1]$. Since the LP has a zero-duality gap,
${\bm{\eta}}^{\ast}(\lambda, {\bm{\nu}})$ is almost surely optimal for~\textbf{P2}.
\begin{algorithm}[t]\small
\DontPrintSemicolon
\caption{Proposed PSD-TD3 to solve problem~\textbf{P1}.}
\label{algo_TD3}
{\bf Initialization:}
Randomly initialize the actor $\mu$ and the two critics ${Q}_{1}$ and ${Q}_{2}$ with parameters $\theta_a$, $\theta_1$, and $\theta_2$, the target-actor $\mu'$ and two target-critics ${Q}'_{1}$ and ${Q}'_{2}$ with parameters $\theta'_a \leftarrow \theta_a$, $\theta'_1 \leftarrow \theta_1$, and $\theta'_2 \leftarrow \theta_2$, the experience replay buffer ${\bm{R}}$, and the channel allocation and modulation-coding selection~${\bm \eta}_0$.\\
Measure the received data rates of all users and ${\bm \eta}_0$ as the initial state $s_0$.\\
\For{$t= 1,\cdots,T_s$}{
Pick action $a_t = {\text{clip}}\Big(\mu\left(s_t; \theta_a \right) + \epsilon, a_{\min}, a_{\max} \Big)$, and update $\mathbf{\Phi}$.\\
Obtain the dual problem of \textbf{P2} based on the updated $\mathbf{\Phi}$: $\min_{\lambda, {\bm{\nu}}}\max_{\bm{\eta}} L\left(\bm{\eta}, \lambda, {\bm{\nu}} \right)$.\\
Initialize $I = 0$, the maximum iteration number $I_{\max}$, $\lambda (0) \geq 0$, $\nu_m (0) \geq 0, \forall m$, and $\bm{\eta}_0$.\\
\While{$L\left(\bm{\eta}, \lambda, {\bm{\nu}} \right)$ is yet to converge, and $I < I_{\max}$}{
Obtain $\bm{\eta}^\ast$ by maximizing $L\left(\bm{\eta}, \lambda, {\bm{\nu}} \right)$ given $\lambda$ using a greedy strategy.\\
Initialize $J = 0$ and the maximum iteration number $J_{\max}$: \\
\While{$P\left({\bm{\eta}^\ast}\right)$ is yet to converge, and $J < J_{\max}$}{
Update $\lambda$ and $\nu_m, \forall m$ according to \eqref{eq-sub-gradient}.\\
$J \leftarrow J + 1$.}
$I \leftarrow I + 1$.
}
Output the optimal channel allocation and modulation-coding selection ${\bm \eta}_t = \bm{\eta}^{\ast}$.\\
Receive the reward $r_t$, perceive a new state $s_{t+1}$, and reserve transition $(s_t, a_t, r_t, s_{t+1})$ in ${\bm{R}}$.\\
Randomly sample $N_{batch}$ historical transitions $(s_i, a_i, r_i, s_{i+1})$ from ${\bm{R}}$.\\
Update the target action after target policy smoothing based on the sampled transitions:
$a'_{t} = {\text{clip}}\Big( \mu'\left(s_{t+1}; \theta'_a \right) + {\text{clip}\left( \epsilon', -\sigma_m^2, \sigma_m^2\right)},
a_{\min}, a_{\max}\Big)$.\\
Update the target Q-value: $y_i = r_i + \gamma \min\Big(Q'_{1}(s_{i+1},a'_{i};\theta'_1), Q'_{2}(s_{i+1},a'_{i};\theta'_2) \Big)$.\\
Calculate the loss function based on~\eqref{eq-loss 2}, and
update the two critics by~\eqref{eq-critic-update}.\\
\If{$\mod(t,2) = 0$}{Update the actor based on~\eqref{eq-policy-ascent}, and the target-actor and the two target-critics by~\eqref{eq-Polyak}.\\
}
}
\end{algorithm}
\subsection{Algorithm Description}
Algorithm~\ref{algo_TD3} summarizes the proposed algorithm, referred to as PSD-TD3.
The agent collects the received data rates of the users
at the start of every learning step (i.e., the $t$-th step), and takes them as the state of the algorithm (i.e., state $s_t$) to train the actor. A continuous action $a_t$ is produced by the actor to update the reflection matrix of the RIS using TD3; see Section~\ref{subsec-ddpg}.
Given the reflection matrix, the algorithm optimizes the channel and modulation-coding selection, i.e.,~$\bm{\eta}_t$, using PSD; see Section~\ref{subsec-optimization}.
Based on the selection,
the agent evaluates the reward~$r_t$, transits to the state $s_{t+1}$, and reserves transition $(s_t, a_t, r_t, s_{t+1})$ in the experience replay buffer ${\bm R}$.
The parameters of the six DNNs are updated with randomly sampled past transitions in the experience replay buffer ${\bm R}$ until the cumulative reward converges.
It is noted that our proposed framework can be readily extended to a multi-antenna setting where
both the BS and users can have multiple antennas.
In this case, space-time block coding (STBC) and maximal ratio combining (MRC) can be carried out at the BS and users, respectively. Given an RIS configuration, each user can individually measure its effective channel matrix from the BS, denoted by {${\mathbf{H}}_{m,k} = \left(\mathbf{H}^{br}_k \right)^H \mathbf{\Phi}^H \mathbf{H}^{ru}_{m,k} + \mathbf{H}^d_{m,k}\in \mathbb{C}^{N_t \times N_r}, \; \forall m \in {\cal M},\; \forall k \in {\cal K}$}, and evaluate and report its effective channel gain of each subchannel, i.e.,
$\gamma_{m,k}^{\rm{mrc}} = \frac{p_{m,k} \left(\| {\mathbf{H}}_{m,k}\|^2/ N_t N_r R_c\right)}{p^J_{k}(\|\mathbf{h}^J_{m,k}\|^2/N_r R_c) + \sigma^2}$~\cite{Yang2021Intelligent,Yang2021Deep,2004MaarefAdaptive}, where $R_c$ is the information code rate of the STBC, and $N_t$ and $N_r$ are the numbers of antennas at the BS and users, respectively. Accordingly, the BS can optimize the selections of the user, data stream (with a quality requirement), and modulation-coding scheme, and the allocation of its transmit power for each subchannel in the same way as it does under the single-antenna setting.
\subsection{Complexity and Convergence Analyses}
The computational complexity of the proposed PSD-TD3 algorithm accounts for both the PSD and the TD3 model.
As of the PSD, the BS incurs a linear complexity of $O(KMLQ)$ to evaluate the net rewards
$\varpi_{m,k,l}^{(q)}\left(\lambda, \nu_m, |h_{m,k}|^2, |h^{J}_{m,k}|^2 \right)$ for all $M$ users with $Q$ data streams per user, $K$ channels, and $L$ modulation-coding modes. Moreover, the greedy strategy, i.e.,~\eqref{eq-opt-eta}, used to decide the 3-tuple $\left\lbrace m^{\ast}_k, l^{\ast}_k, q^{\ast}_k \right\rbrace$
per subchannel $k$ incurs a complexity of ${\cal O}(K\log(MLQ))$. As a result, all required operations of a time step incurs a linear
computational complexity of ${\cal O}(KMLQ)$~\cite{He2014Optimal}.
As of the TD3 model, we separately evaluate the complexities of the actor and critic networks.
Suppose that the actor network has $L_a$ layers with $J_m$ neurons in the $m$-th layer ($m\leq L_a$). The complexity of the $m$-th layer is ${\cal O}(J_{m-1}J_m + J_mJ_{m+1})$~\cite{Gao2020DeepComfort}. The complexity of the actor network is ${\cal O}\left(\sum_{m=2}^{L_a-1}(J_{m-1}J_m + J_mJ_{m+1})\right)$.
Suppose that the critic network has $L_c$ layers with $G_n$ neurons in the $n$-th layer ($n\leq L_c$). The complexity of the $n$-th layer is ${\cal O}(G_{n-1}G_n + G_nG_{n+1})$~\cite{Gao2020DeepComfort}. The complexity of the critic network is ${\cal O}\left(\sum_{n=2}^{L_c-1}(G_{n-1}G_n + G_nG_{n+1})\right) $.
As a result, the overall computational complexity of the TD3 model is ${\cal O}\left( \sum_{m=2}^{L_a-1}(J_{m-1}J_m + J_mJ_{m+1}) + \sum_{n=2}^{L_c-1}(G_{n-1}G_n + G_nG_{n+1})\right) $~\cite{Gao2020DeepComfort}.
We further analyze the convergence of the proposed PSD-TD3 algorithm.
Specifically, the algorithm satisfies the following conditions:
(i) the network parameters $\theta$ and $\theta'$ (of which the subscripts are suppressed for brevity) are upper bounded since they are sequentially compact following the Arzela-Ascoli theorem \cite{billingsley2013convergence};
(ii) the state and action spaces are compact as the sampled states and actions are bounded by the maximum transmit power of the BS and the phase shifts of the RIS;
(iii) the reward function, i.e., \eqref{eq-reward}, is continuous;
and (iv) the training networks are feedforward FCNNs with twice continuously differentiable activation functions, such as Rectified Linear Units (ReLUs) and sigmoid.
According to \cite[Lemma~2]{redder2022asymptotic}, the proposed algorithm can asymptotically converge
if we adopt a sequence of square summable learning rates, i.e., $\sum_t \eta_a (t) = \infty$
and $\sum_t \eta_a (t)^2 < \infty$. Here, $t$ is the time step, and $\eta_a (t)$ is a time-varying learning rate of the actor network.
\section{Simulation Results}\label{sec-sim}
In the considered system, the BS is placed at $(D_0,0,H_b)$, the jammer is placed at $(x_J,y_J,0)$, and the first element of the RIS has the coordinates $(0,\delta,\delta+H_r)$, as depicted in Fig.~\ref{fig-sysmodel}.
We set $D_0 = 2$ m, $H_b = 10$ m, $H_r =10$ m, $x_J =50$ m, and $y_J = 150$ m.
The RIS is a URA with element spacing of $\delta$. We assume $d_0 = \delta = \frac{\lambda}{2}$.
We use $(\iota,\kappa)$ to index the RIS elements. $\iota \in \{1,\cdots,{N_y}\}\;{\text{and}}\;\kappa \in \{1,\cdots,{N_z}\}$.
The coordinates of the $(\iota,\kappa)$-th reflecting element are $(0,\iota\times\delta,\kappa\times\delta+H_r)$.
The users are uniformly scattered within a square area centered at $(100, 100, 0)$~m with the side length of 100~m.
The sides of the area are parallel to the $x$- and $y$-axes.
The location of the $m$-th user is $(x_{m},y_{m},0)$, $\forall {m} \in {\cal M}$.
By default, $M=4$.
We consider Rayleigh fading for the BS-user (BS-UE) and the jammer-UE links, and Rician fading for the BS-RIS, jammer-UE and RIS-UE links. The channel gains of the BS-UE (or jammer-UE), BS-RIS (or jammer-RIS), and RIS-UE links are given by
\begin{align}\label{eq-bs-ue}
\!h^{d}_{m,k}& =\! \sqrt{\epsilon_o \left(d^{d}_{m} \right)^{-\alpha_{d}}} \tilde{h}^d, \forall m,k,&\\
\!h^{br}_{\iota,\kappa}& = \!\sqrt{\epsilon_o \left(d^{br}_{\iota,\kappa} \right)^{-\alpha_{br}}}\left(\! \sqrt{\frac{K_1}{1\!+\!K_1}} h^{br}_{los} \!+\! \sqrt{\frac{1}{1\!+\!K_1}}h^{br}_{nlos} \!\right), \forall \iota,\kappa, & \label{eq-bs-irs}\\
\!h^{ru}_{\iota,\kappa,m} &=\! \sqrt{\epsilon_o \left(d^{ru}_{\iota,\kappa,m} \right)^{-\alpha_{ru}}}\left(\! \sqrt{\frac{K_2}{1\!+\!K_2}} h^{ru}_{los} \!+\! \sqrt{\frac{1}{1\!+\!K_2}}{h}^{ru}_{nlos} \!\right), \forall \iota,\kappa,m, & \label{eq-irs-ue}\\
\!h^{Jd}_{m,k}& =\! \sqrt{\epsilon_o \left(d^{Jd}_{m} \right)^{-\alpha_{Jd}}} \tilde{h}^{Jd}, \forall m,k,& \label{eq-jammer-ue}\\
\!h^{Jr}_{\iota,\kappa}& = \!\sqrt{\epsilon_o \left(d^{Jr}_{\iota,\kappa} \right)^{-\alpha_{Jr}}}\left(\! \sqrt{\frac{K_3}{1\!+\!K_3}} h^{Jr}_{los} \!+\! \sqrt{\frac{1}{1\!+\!K_3}}h^{Jr}_{nlos} \!\right), \forall \iota,\kappa, & \label{eq-jammer-irs}
\end{align}
where $\epsilon_o$ is the path loss at the reference distance $d_0 =1$ m with $\alpha_{d}$, $\alpha_{br}$, $\alpha_{ru}$, $\alpha_{Jd}$, and $\alpha_{Jr}$ being the path loss exponents of the BS-RIS, BS-UE, RIS-UE, jammer-UE, and jammer-RIS links, respectively; $d^{br}_{\iota,\kappa} = \sqrt{\left(H_r+\kappa\delta -H_b \right)^2+\iota^2\delta^2+D_0^2}$ is the distance from the BS to the $(\iota,\kappa)$-th reflecting element of the RIS, and $d^{d}_{m} = \sqrt{\left(D_0 - x_{m}\right)^2 + y_{m}^2 + H_b^2}$ is the distance from the BS to the $m$-th user, and $d^{ru}_{\iota,\kappa,m} = \sqrt{x_m^2 + \left(H_r + \kappa\delta \right)^2 +(y_m -\iota\delta)^2}$ is the distance from the $(\iota,\kappa)$-th reflecting element of the RIS to the $m$-th user,
$d^{Jr}_{\iota,\kappa} = \sqrt{\left(H_r+\kappa\delta \right)^2+\left(\iota\delta - y_J\right)^2+x_J^2}$ is the distance from the jammer to the $(\iota,\kappa)$-th reflecting element of the RIS, $d^{Jd}_{m} = \sqrt{\left(x_J - x_{m}\right)^2 +\left(y_J - y_{m}\right)^2}$ is the distance from the jammer to the $m$-th user.
In \eqref{eq-bs-irs},~\eqref{eq-irs-ue}, and \eqref{eq-jammer-irs}, $K_1$, $K_2$ and $K_3$ are the Rician factors of the BS-RIS, RIS-UE, and jammer-RIS links.
$h^{br}_{los} = e^{-j \frac{2\pi \delta}{\lambda}\phi^{br}_{\iota, \kappa}}$, $h^{ru}_{los} = e^{-j \frac{2\pi \delta}{\lambda}\phi^{ru}_{\iota, \kappa, m}}$, and $h^{Jr}_{los} = e^{-j \frac{2\pi \delta}{\lambda}\phi^{Jr}_{\iota, \kappa}}$ are the deterministic Line-of-Sight (LoS) components of the BS-RIS, RIS-UE, and jammer-RIS links, respectively,
where $\phi^{br}_{\iota, \kappa} = \arccos\left(\frac{\iota \delta}{d^{br}_{\iota, \kappa}} \right) $ is the angle-of-arrival (AoA) of the signal from the BS to the $(\iota, \kappa)$-th reflecting element of the RIS,
$\phi_{ru} = \arccos\left(\frac{y_m - \iota \delta}{d^{ru}_{\iota,\kappa,m}} \right) $ is the angle-of-departure (AoD) of the signal from the $(\iota, \kappa)$-th reflecting element of the RIS to the $m$-th user,
and $\phi^{Jr}_{\iota, \kappa} = \arccos\left(\frac{y_J - \iota \delta}{d^{Jr}_{\iota, \kappa}} \right) $ is the AoA of the signal from the jammer to the $(\iota, \kappa)$-th reflecting element of the RIS.
$\tilde{h}^d$, $h^{br}_{nlos}$, $h^{ru}_{nlos}$, $\tilde{h}^{Jd}$, and $h^{Jr}_{nlos}$ are random scattering components modeled by zero-mean and unit-variance CSCG variables.
The other parameters of the considered system are provided in Table \ref{tab.pm}.
\begin{table}[t
\caption{The parameters of the considered system}
\begin{center}
\begin{tabular}{ll}
\toprule[1.5pt]
Parameters & Values \\ \hline
Maximum transmit power of the BS, $P_{\max}$ & 5 -- 35 dBm \\
Transmit power of the jammer, $P_J$ & 10 dBm \\
Number of subchannels, $K$ & 16, 32 \\
Number of users, $M$ & 4 \\
Number of modulation levels, $L$ & 4 \\
Set of modulation-coding rate & \{0,2,4,6\} bits/symbol\\
Path loss at $d_0 =1$ m, $\epsilon_o$ &-30 dB \\
Path loss exponents, $\alpha_{br}$, $\alpha_{d}$, $\alpha_{ru}$ & 2.5, 3.0, 2.2 \\
Rician factors, $K_1$, $K_2$, $K_3$ & 1, 3, 1 \\
Noise power density, $\sigma^2$ & -169 dBm/Hz \\
Bandwidth, $B_w$ & 100~MHz \\
BER requirements, $\{\varrho_0^{(1)},\varrho_0^{(2)}\}$ & $\{10^{-6}, 10^{-2}\}$ \\
Coefficients of modulation and coding, $\beta_1$, $\beta_2$ &0.2, -1.6~\cite{Goldsmith1998} \\
\toprule[1.5pt]
\end{tabular}
\end{center}
\label{tab.pm}
\end{table}
The TD3-based network is implemented by a two-layer feedforward neural network with 128 and 64 hidden nodes in the two layers.
Rectified Linear Units (ReLUs) are used as the activation functions between the layers of the actor and critic networks.
The output layers of the actor use the sigmoid($\cdot$) to bound the output actions within $[0, 2\pi)$ for the RIS configuration.
The state and action are taken as the input to the first layer of the critic networks.
The learning rates of both the actor and critic networks are $10^{-3}$.
The exploration noise used to train the TD3 actor, and the policy noise used to smooth the target-actor are both generated from the zero-mean GN with variance $0.2$.
The maximum value of the exploration noise is $0.5$. The update frequency of the actor networks is $2$.
The TD3-based network is trained on a server with an Nvidia Tesla P100 SXM2 16GB GPU.
The network hyperparameters are summarized in Table~\ref{table_hyper_td3}.
\begin{table}[t
\renewcommand{\arraystretch}{1.0}
\caption{The hyperparameters of the TD3-based algorithm}
\begin{center}
\begin{tabular}{ll}
\toprule[1.5pt]
Parameters & Values \\
\hline
Discounting factor for future reward, $\gamma$ & 0.99 \\
Learning rate for actor and critic networks, $\eta_a$, $\eta_c$ & $1 \times 10^{-3}$ \\
Decaying rate for actor and critic networks, $\rho_{\tau}$ & $5 \times 10^{-3}$\\
Size of experience replay buffer & $1 \times 10^5$\\
Number of episodes, $T_{ep}$ & 400 \\
Total number of steps in each episode, $T_s$ & 200 \\
Mini-batch size, $N_{batch}$ & 16\\
Policy delay update frequency & 2 \\
Maximum value of the Gaussian noise, $\sigma_m^2$ & 0.5 \\
Variance of the exploration noise, $\sigma_e^2$ & 0.2 \\
Variance of the policy noise, $\sigma_a^2$ & 0.2 \\
\toprule[1.5pt]
\end{tabular}
\end{center} \label{table_hyper_td3}
\end{table}
As discussed earlier,
no existing algorithm is directly comparable to the proposed PSD-TD3 algorithm.
We come up with a DDPG-based alternative to the PSD-TD3 algorithm, referred to as PSD-DDPG, where the DDPG is employed to configure the RIS. We also develop a DQN-TD3 algorithm, where the selections of the user, subchannel, and modulation-coding mode are done using a DQN, and the TD3 is used to configure the RIS.
Moreover, we consider the case where the RIS is randomly configured, while the selections of the user, data stream, subchannel, and modulation-coding mode are optimized, as described in Section~\ref{subsec-optimization}.
These three benchmarks are used to evaluate the proposed PSD-TDS algorithm.
\begin{figure}[!t]
\centering
\includegraphics[width=1\columnwidth]{fig_reward.pdf}
\caption{The per-episode and average rewards of the proposed PSD-TD3 algorithm and its DDPG-based alternative under $N=40$, 60, and 80 (the top three subfigures), and the rewards and the BS transmit power of the DQN-TD3 algorithm under $N=40$ (the bottom two subfigures).}
\label{fig-reward}
\end{figure}
We train the proposed algorithm only for one value of the maximum BS transmit power $P_{\max}$, i.e., $P_{\max} =30$ dBm, and test the resulting model under other $P_{\max}$ values to show the generalizability of the algorithm. Likewise, we train the algorithm only for one value of the transmit power of the jammer $P_J$, and test it under other $P_J$ values.
In the top three subfigures of Fig.~\ref{fig-reward}, we plot both the per-episode reward and the average reward of the proposed PSD-TD3 under different~$N$.
We also plot the per-episode reward and the
average reward of the alternative PSD-DDPG algorithm.
The average reward over the $i$-th training episode is $\bar r = \frac{1}{T_{s}}\sum_{j=t}^{T_{s}} r_t^i$, where $r_t^i$ is the step reward for the episode; see~\eqref{eq-reward}.
The top three subfigures of Fig.~\ref{fig-reward} show that the rewards of the two algorithms generally improve with the learning steps, and grow with $N$.
Moreover, the DDPG-based alternative approach also demonstrates its viability, despite DDPG is known to be susceptible to overfitting (compared to TD3). The conclusion drawn is that the small action space of the new framework, resulting from the decoupling of the discrete and continuous actions, allows even the DDPG model to sufficiently exploit the action space and converge fast.
In the bottom two subfigures of Fig.~\ref{fig-reward}, we see that the rewards of the DQN-TD3 algorithm do not converge to a feasible solution even after 3,500 training episodes since the total transmit power at the BS cannot satisfy the maximum power constraints. In contrast, PSD-DDPG and PSD-TD3 converge within a few episodes. The convergent solutions of PSD-DDPG and PSD-TD3 are inherently feasible, since the transmit power is pre-evaluated before an selection of the user, data stream, subchannel, and modulation-coding mode.
\begin{figure}[t]
\centering
\includegraphics[width=1\columnwidth]{fig_rate_opt.pdf}
\caption{Sum rate vs. the number of RIS's reflecting elements.}
\label{fig-rate-vs-N}
\end{figure}
Next, we examine the proposed PSD-TD3 algorithm and its alternatives under different parameters of the considered system.
Each testing episode has 200 steps.
During a testing process, no exploration noise is added.
Fig.~\ref{fig-rate-vs-N} plots the sum rate of the $M$ users against the number of reflecting elements at the RIS, $N$, under $K = 16$ and 32 subchannels.
We also plot the case with the RIS randomly configured and the case without the RIS for comparison.
We see that both PSD-TD3 and PSD-DDPG are effective and can benefit from the increase of $N$.
The usefulness of the RIS and the importance of meticulous RIS configuration are demonstrated by comparing the proposed PSD-TD3 to the cases without the RIS and with the RIS randomly configured.
Particularly, the case with the RIS randomly configured can only marginally outperform the case without the RIS, as will also be shown in Fig.~\ref{fig_rate_vs_user}.
\begin{figure}[t]
\centering
\includegraphics[width=1\columnwidth]{fig_rate_vs_power.pdf}
\caption{Sum rate vs. $P_{\max}$, where the jamming power is 10~dBm.}
\label{fig-rate-vs-pmax}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=1\columnwidth]{fig_rate_vs_PJ.pdf}
\caption{Sum rate vs. the transmit power of Jammer, $P_J$, where the proposed PSD-TD3 is plotted under different sizes of the RIS and compared with the case without the RIS.}
\label{fig_rate_vs_PJ}
\end{figure}
Fig.~\ref{fig-rate-vs-pmax} plots the sum rate with the increasing maximum transmit power of the BS, $P_{\max}$, under different $N$ and $K$.
We observe that the proposed PSD-TD3 attains the higher sum rate than the case without the RIS.
The sum rate grows with $P_{\max}$ under all the considered algorithms and parameter settings.
The usefulness of the RIS is also validated, since the sum rate grows with $N$.
We also plot the sum rate with the growing transmit power of the jammer, $P_J$, under $K = 16$ in Fig.~\ref{fig_rate_vs_PJ}. We see that the sum rate declines as $P_J$ grows. When $P_J \geq 35$~dBm, the sum rate approaches zero under the proposed PSD-TD3, while it approaches zero when $P_J \geq 25$~dBm in the case without the RIS. In other words, the RIS strengthens the anti-jamming capability significantly by augmenting the radio propagation environment.
\begin{figure}[!t]
\centering
\includegraphics[width=1\columnwidth]{images/fig_rate_vs_PJ_alpha_1.pdf}
\caption{Sum rate vs. the shaping parameter $\alpha_j$ (or $\beta_j$). The average jamming power $P_J$ ranges from 10 dBm to 30 dBm. The jamming powers are equal across the subchannels when $\alpha_j = \beta_j = 5.0$. }
\label{fig_rate_vs_PJ_alpha}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=1\columnwidth]{images/fig_PJ_bar_1.pdf}
\caption{Examples of the unequal allocation of the jamming power $P_J$ in the subchannels under different values of $\alpha_j$ (and $\beta_j$).}
\label{fig_PJ}
\end{figure}
To quantify the impact of unequal allocation of the jamming power on the sum-rate of the users, we project the jamming power of each subchannel using the Beta distribution, i.e., $f(x, \alpha_j,\beta_j) = x^{\alpha_j-1}(1-x)^{\beta_j-1}/B(\alpha_j,\beta_j)$,
where $B(\alpha_j,\beta_j)$ is the Beta function with $\alpha_j = \beta_j$ being the shape parameters related to the variance of generated data.
The larger $\alpha_j $ and $ \beta_j$ are, the most consistent the jamming power is across different subchannels. When $\alpha_j = \beta_j = 5.0$, the jamming powers are equal across the subchannels.
Fig.~\ref{fig_rate_vs_PJ_alpha} plots the sum rate against the shaping parameters $\alpha_j$ (or $\beta_j$) under different settings of the average jamming power $P_J$.
We see that the sum rate declines with the increase of $\alpha_j$ (and $\beta_j$), since the difference of the jamming power among the subchannels decreases; see Fig.~\ref{fig_PJ}.
The reason is that the unbalanced jamming powers allow the BS to avoid severely jammed subchannels and efficiently utilize those less jammed.
\begin{figure}[t]
\centering
\includegraphics[width=1\columnwidth]{fig_rate_vs_user.pdf}
\caption{Sum rate vs. $M$, where each value is the average of 200 independent tests.}
\label{fig_rate_vs_user}
\end{figure}
Fig.~\ref{fig_rate_vs_user} plots the sum rate with the increasing number of users $M$, where $N=40$, 60, and 80.
We also plot the case where the RIS is randomly configured and the case without the RIS for comparison.
It is observed that the sum rate grows with $M$ in all three cases, and the proposed PSD-TD3 outperforms the other two cases.
The gain of the meticulously configured RIS is confirmed by showing the gain of the proposed PSD-TD3 over the case with the RIS randomly configured.
\begin{figure}[t]
\centering
\includegraphics[width=0.8\columnwidth]{distance_illstribution_v1.pdf}
\caption{The bird view of the simulated system, where we assess the influence of the network deployment by moving the BS and RIS along the $x$- and $y$-axes in Figs.~\ref{fig-illustration-move}(a) and~\ref{fig-illustration-move}(b), respectively, and moving the jammer in the directions of the $x$- and $y$-axes in Figs.~\ref{fig-illustration-move}(c) and \ref{fig-illustration-move}(d).}
\label{fig-illustration-move}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=1\columnwidth]{fig_rate_vs_BS_RIS.pdf}
\caption{Sum rate vs. the horizontal and vertical distances between the BS and RIS, where we move the BS and RIS along the $x$- and $y$-axes, respectively; see Figs.~\ref{fig-illustration-move}(a) and~\ref{fig-illustration-move}(b).}
\label{fig_rate_vs_dis}
\end{figure}
We proceed to assess the influence of the network deployment on the sum rate of the proposed PSD-TD3, by separately varying the positions of the BS, the RIS, and the jammer,
as shown in Fig.~\ref{fig-illustration-move}.
We first move the BS along the $x$-axis; see Fig.~\ref{fig-illustration-move}(a).
Then, we move the RIS along the $y$-axis; see Fig.~\ref{fig-illustration-move}(b).
We also move the jammer along the directions parallel to the $x$- and $y$-axes; see Figs.~\ref{fig-illustration-move}(c) and~\ref{fig-illustration-move}(d).
The results of these four cases are provided in Figs.~\ref{fig_rate_vs_dis} and \ref{fig_rate_vs_jammer}.
Fig.~\ref{fig_rate_vs_dis}(a) reveals that the sum rate of the proposed PSD-TD3 first declines quickly, then rises to its peak, and finally drops, with the increasing horizontal distance from the BS to the RIS.
This is because less signals are reflected from the RIS, and consequently the sum rate drops rapidly as the distance starts to increase.
By further moving the BS along the $x$-axis, the BS gets increasingly close to the users. The powers that the users receive directly from the BS increase, hence improving the sum rate.
When the BS is moved away from the users, the received powers at the users decrease and so does the sum rate.
We also see that when the BS is in close proximity to the RIS (e.g., $D_0 \leq 5$ m), the larger number of reflecting elements at the RIS induces a higher sum rate. Nonetheless, the gain pertaining to the RIS declines when the BS is moved farther from the RIS.
Fig.~\ref{fig_rate_vs_dis}(b) shows that the sum rate declines when the RIS is moved farther from the BS along the $y$-axis (and the RIS remains far from the users). This is because the contribution of the RIS to the sum rate is increasingly negligible when the RIS is moved farther from the BS, and finally overshadowed by the contribution of the direct paths from the BS to users.
\begin{figure}[t]
\centering
\includegraphics[width=1\columnwidth]{fig_rate_vs_jammer.pdf}
\caption{Sum rate vs. the vertical distance from Jammer to RIS, where we move the jammer away from the BS and RIS in the directions of the $x$- and $y$-axes; see Figs.~\ref{fig-illustration-move}(c) and \ref{fig-illustration-move}(d).}
\label{fig_rate_vs_jammer}
\end{figure}
Figs.~\ref{fig_rate_vs_jammer}(a) and \ref{fig_rate_vs_jammer}(b) show that the sum rate of the proposed PSD-TD3 first declines and then grows with the increasing vertical distances from the jammer to the RIS and the BS, respectively.
As the jammer is moved along the directions parallel to the $x$- and $y$-axes, it gets closer to the users. The received SINR at the users degrades, and hence first decreases the sum rate.
By further moving the jammer away from the users, the jamming signal strength reduces and the sum rate increases.
We also see that the RIS-assisted system has a more powerful anti-jamming capability than the system without the RIS.
Moreover, the anti-jamming capability becomes stronger, as the number of reflecting elements increases at the RIS.
\begin{figure}[t]
\centering
\includegraphics[width=1\columnwidth]{fig_bar_chi.pdf}
\caption{Sum rate vs. the ratio of the HQ and LQ data streams, where $P_{\max} = 30$~dBm. (a) The jamming power is 10~dBm. (b) The jamming power is 20~dBm.}
\label{fig_rate_vs_chi}
\end{figure}
Finally, we assess the influence of the ratio of the high- and LQ data streams, $\chi$, on the proposed PSD-TD3 under the jammer power $P_J =10$ and 20 dBm, as shown in Fig.~\ref{fig_rate_vs_chi}.
We notice that the proposed PSD-TD3 achieves greater HQ data rates, LQ data rates, and sum rates than the case without the RIS.
With the growth of $\chi$, the HQ data rates first grow and then decline, while the LQ data rates decrease under the proposed PSD-TD3. This is because more HQ data streams need to be delivered under a larger value of $\chi$.
To satisfy the BER requirement (i.e., $10^{-6}$ here) of these HQ data streams, more transmit powers and channels are needed, resulting in the smaller LQ data rates and sum rates.
On the other hand, it is increasingly difficult to satisfy the BER requirement when $\chi > 2$, owing to the unbalanced HQ and LQ data streams, and hence decreasing the HQ data rates, especially in the presence of strong jamming signals, as seen in Fig.~\ref{fig_rate_vs_chi}(b).
\section{Conclusion}\label{sec-con}
This paper proposed the new PSD-TD3 algorithm to jointly optimize user selection, channel allocation, modulation-coding adaptation, and RIS configuration for an RIS-assisted downlink multiuser OFDMA system under a jamming attack.
A TD3 model was designed to learn the RIS configuration. The PSD was employed to optimize the user selection, channel allocation and modulation-coding adaptation.
Both were based on the readily measurable received data rates of the users.
Consequently, the algorithm learns to maximize the sum rate of the system through changes in the received data rates of the users, and eliminates the need of CSI.
As validated by extensive simulations, the proposed anti-jamming PSD-TD3 framework significantly outperforms its non-learning alternatives in terms of sum rate.
The new framework with 40, 60, or 80 reflecting elements at the RIS provides 16.50\%, 32.91\%, or 51.86\% higher sum rates than the system without the RIS.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2023-01-18T02:15:58', 'yymm': '2301', 'arxiv_id': '2301.06223', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06223'} | arxiv |
\section{Introduction}
Bicycling is a means of transportation and exercise that can reduce greenhouse gas emissions and improve public health. For instance, increasing pedestrian and bicycling trips, with a corresponding decrease in automobile trip lengths, by as little as one to three miles on average, can significantly affect both emissions and fuel consumption~\cite{gotschi2008active}. Moreover, bicycling could reduce CO2 by six to fourteen million tons and reduce fuel consumption by 700 million to 1.6 billion gallons~\cite{gotschi2008active}. Bicycling can also provide health benefits such as reducing cardiovascular risk factors, the likelihood of coronary heart disease, general morbidity, mortality risk, cancer risk, and obesity~\cite{oja2011health}. Unfortunately, people's perception of cycling---which can be influenced by how the news and social media portray cyclists---might impact both the number of cyclists and investment in cycling infrastructure by the community~\cite{daley2011perspectives}. Hence, in this paper, we introduce a new dataset ``Bike Frames'', novel methods, and a case study that extracts explicit and implicit information from headlines about how bicyclists---and motorcyclists as a comparison group---are portrayed.
\begin{wrapfigure}{r}{8cm}
\centering
\includegraphics[width=\linewidth]{lrec-fig.pdf}
\caption{Understanding and explaining implicit views of cyclists and motorcyclists requires reasoning. Hence, our ``Bike Frames'' aim to (1.) detect accident-related headlines, (2.) identify implicit suggestions of ``who was at fault'', and (3.) measure sentiment towards cyclists.}
\label{fig:overview}
\end{wrapfigure}
There has been extensive research in the transportation and urban science communities on topics from cycling infrastructure to the public's perception of bicyclists. For instance, \citet{macmillan2017understanding} found that increasing cycling in cities is good for health and addressing climate change. Likewise, regarding media and public perception, \citet{aldred2019barriers} found that media and public opposition were not reported as major issues for communities not considering new bicycling infrastructure. However, they found that media and public opposition can substantially affect the release of funding for new cities that begin considering new infrastructure.
\citet{macmillan2016trends} show that while cycling trips doubled in London between 1992 and 2012, yet the proportion of cyclist fatalities covered by media rose 13-fold over this period. They compare this coverage to motorcyclists, showing that the increase in motorcyclist-related coverage did not see the same increase by the media. They argue that such coverage may create complex feedback loops, inhibiting bicycling growth. However, the relative strength of such feedback loops is likely to vary between cities. Hence, measuring public perception through the news (e.g., local news agencies) is essential for gauging how bicyclists are portrayed and combating negative views. However, much of the prior work has been limited to surveys and general qualitative analysis~\cite{aasvik2021cyclists}. Therefore, measuring perception at scale is important and challenging, particularly if we want to compare different communities.
Previous research has also found that gender interacts with individual factors such as safety perception and home obligations, which, in turn, impacts bicycle behavior. For example, female-identifying cyclists may be more concerned about road safety and more likely to be influenced by news broadcasts than male-identifying cyclists~\cite{emond2009explaining}. Additionally, \citet{harris2006gender} discovered that people that identify as female tend to be more risk-averse and feel more negative consequences of sharing the road with automobiles or other vehicles than men. These findings suggest that female-identifying cyclists may be more likely to favor off-road bike lanes separated from traffic ~\citet{garrard2012women}. Understanding these gender differences can help planners and policymakers develop strategies to promote cycling, particularly among women.
We introduce a novel dataset and models that can extract the perception portrayed by news headlines using machine learning algorithms. We summarize the task our dataset addresses in Figure~\ref{fig:overview}. Specifically, we measure two aspects, the perceived view of ``how'' the writer feels about the bicyclist and information about whether or not the bicyclist was in an accident. In the example ``Drunk-driver plowed into the cyclist,'' we can understand that the headline is related to a driver-bicyclist accident and that the driver was probably at fault. We may perceive that the writer expresses sympathy towards the cyclist (i.e., sees the cyclist in a positive light) given their explicit remark about the driver's initial condition (intoxicated) and through the strong verb ``plowed.'' In contrast, if the headline said ``Cyclist allegedly hit by a driver,'' the text would still discuss an accident. However, we may perceive the writer as having a more positive perception of the driver, reducing the positive perception of the bicyclist. Therefore, we developed the dataset to measure the perception of bicyclists and motorcyclists for direct comparison, similar to the work by \citet{macmillan2016trends}.
This work is essential in three ways. First, as mentioned by \citet{macmillan2016trends} some news agencies may focus more on bicycling-related accidents (compared to motorcycling), showing that the roads are more dangerous for cyclists, thus reducing growth in new bicycling infrastructure. Our dataset will directly facilitate measuring and analyzing this hypothesis at scale. Second, how headlines are stated might indicate the news agency's bias against bicycling as transportation. Hence, understanding these biases at scale will allow users to filter their news better and help news agencies write less biased headlines. Third, there may be differences in how news agencies report about cycling with regard to gender-related information. Hence, our solution will facilitate measuring such biases.
In summary, the major contributions of this paper are summarized as follows:
\begin{enumerate}
\item We introduce a new dataset for understanding the perception of bicyclists and motorcyclists in the news.
\item We provide several baselines (e.g., Linear SVM and Neural Network Models) on the dataset, which can serve as a starting point for researchers to develop better algorithms.
\item We propose a novel multi-task learning approach that effectively leverages the relationships between the different categories in our dataset to improve the performance of our model, producing a strong baseline that future researchers can build
\item Finally, using our models, we perform an important case study of news headlines comparing differences in news headlines about bicyclists vs. motorcyclists as well as comparing male vs. female-related headlines.
\end{enumerate}
\section{Related Work}
In this section, we describe four main areas of research related to this paper: Bicycling and general Infrastructure research, gender differences in bicycling and motorcycling, NLP methods to understand the news, and research on semantic analysis. Specifically, we introduce the methods we introduce to develop accurate classifiers. Furthermore, we discuss the broader social items related to cycling.
\subsection{Bicycling, Transportation, and Infrastructure Research}
There has been substantial research into bicycling infrastructure and the public's perception of bicyclists using various methods (e.g., surveys, crowd-sourcing, and content analysis). For example, \citet{macmillan2014societal} and \citet{macmillan2017understanding} used dynamics modeling to show a feedback loop between political will, environmental views, perception towards bicyclists, and bicycling growth. For example, growing numbers of people cycling will improve the environment; cycling safety in numbers drives further growth, and more cycling can be normalized. ~\citet{aldred2019barriers} used survey methods to find that media and public opposition were not reported as major issues for communities that are not considering new bicycling infrastructure. Yet, media and public opposition can substantially impact the release of funding for new cities that begin considering new infrastructure. \citet{ferster2021advocacy} performed content analysis showing that attitudes associated with a change in bicycling infrastructure may be cyclical, with initial negative responses to change, followed by an uptick in positive attitudes. \citet{barajas2021biking} found that bike infrastructure is disproportionately absent from Black and Latino neighborhoods. Moreover, cycling citations are issued disproportionately in Black and Latino neighborhoods. Hence, social groups can target areas to push for better infrastructure if we can understand perception---particularly via local news---towards bicyclists in these areas.
\citet{boufous2016reporting} states that the newspaper report cycling-related accidents tend to focus on dramatic, out-of-the-ordinary, and frequently quite unusual situations. This style of reporting differs from public health reporting, which focuses on common trends and is more likely to mislead the public and overstate the risk of death connected with riding. The media's emphasis on the uncommon and newsworthy is also evident in that crashes covered by more than one newspaper item were more likely to involve public individuals and result in lengthy legal proceedings. On the contrary, cycling advocates should collaborate with journalists to increase the quality of coverage. Better communication between cycling advocates and journalists may positively impact community cycling safety and use~\citet{boufous2016reporting}. \citet{macmillan2016trends} analyzed local newspaper reporting on London cyclist fatalities from 1992 to 2012. Overall, \citet{macmillan2016trends} finds that the proportion of cyclist fatalities covered by media rose 13-fold over this period, while motorbikes accident coverage stayed steady. However, the increased coverage was specific to cyclists and not to motorcyclists.
Their work involved manual analysis of police reports and accidents reported in news stories. We expand on their work by providing a new dataset and models that can extract bicycling-specific accident-related information at scale. Moreover, we extract additional information, such as the news writer's implicit view of the bicyclist mentioned in the story. Using our new toolset, we address the research question
\begin{quote}
\textbf{RQ 1}: Are there differences between bicycling and motorcycling-related news content?
\end{quote}
in our case study, we use motorcycles as a control group to examine the association between changes in media coverage of motorcyclist fatalities and the rise in motorcycle popularity. By comparing the patterns of media coverage for both motorcycles and bicycles, we gain a better understanding of the factors that influence how the media reports on accidents involving these two modes of transportation. This analysis can provide valuable insights into the potential biases in media coverage and the role of the media in shaping public perceptions of cycling and motorcycle safety
\subsection{Semantic Analysis and Understanding the News.} Semantic analysis is an essential area of research in the field of NLP. Hence, there has been a wide range of research on the semantic understanding of the text. For example, the FrameNet knowledge base was introduced as an extensive linguistic resource in which the meaning of the text is represented using Frame Semantics (frames)~\cite{baker1998berkeley,fillmore2003background}. The data that FrameNet has analyzed show that the sentence "John sold a car to Mary" essentially describes the same basic situation (semantic frame) as ``Mary bought a car from John'', just from a different perspective. A semantic frame is a conceptual structure describing an event, relation, or object and its participants. Recently, \citet{sap2020social} explored frame semantics-related frameworks to understand social bias, i.e., creating social bias frames. Their framework introduces a new way of categorizing language to measure implied biases and offensiveness by combining structured pragmatic inference with commonsense reasoning on social implications. There has also been substantial research using NLP tools and techniques to understand the news better, particularly using frame semantics. Moreover, new tools have been developed to help news writers. For example, \citet{liu2021visual} introduced a novel multi-modal feature fusion method to caption news story images. \citet{spinde2021neural} introduced a new dataset for detecting biased news. \citet{ang-lim-2022-guided} developed a multi-modal model to extract inter-organization relationships from the news using global and local information from various modalities and dynamic inter-company links.
Most similar to our work is the work by ~\citet{gabriel-etal-2022-misinfo} that creates ``perceived'' news frames from headlines regarding how people think about misinformation. They argued that an effective way to predict how news headlines will influence readers requires understanding how readers perceive the intent behind the news. Likewise, ~\citet{tourni2021detecting} introduced the Gun Violence Frame Corpus (GVFC). \citet{tourni2021detecting} discuss how different news articles may discuss the same topic but from different points of view (e.g., one article might emphasize gun control, while another might promote 2nd Amendment rights). This is like how we try to understand semantic differences in how bicyclists are mentioned in news headlines. However, our work differs in two direct ways. First, we focus on bicycling, an important and timely topic impacting many urban areas (i.e., contributing to the broad area of urban informatics). Second, \citet{tourni2021detecting} focused more on direct textual categories within the text. In this work, we also explore implicit items within the text, e.g., estimating implicit sentiment towards the cyclist mentioned in the headline from the writer's perspective. Our framework builds upon the work of ~\cite{fillmore1976frame,gabriel-etal-2022-misinfo,tourni2021detecting} by integrating their key insights into a hierarchical framework for analyzing the pragmatic meaning of news headlines. Our framework will allow us to assess the ways in which news organizations structure their coverage of events or subjects and to evaluate the impact of this coverage on public attitudes and perceptions. For example, we can use our framework to examine whether widespread coverage of cycling accidents leads to public bias or fear of cycling. By systematically organizing and distilling the meaning of news headlines, our framework will provide a valuable tool to understand the role of the media in shaping public opinion and detect potential bias in media coverage.
\subsection{Gender and Bicycling}
Previous research~\cite{sener2009bicyclists,emond2009explaining} has shown that female- and male-identifying cyclists have different perceptions of safety and trip needs. This means that the impact of social media on their attitudes and behavior may also differ. People identifying as female cyclists may be more influenced by news addressing their specific concerns and needs. In contrast, male-identifying cyclists may be more influenced by news that aligns with their attitudes and perceptions. Policymakers and advertisers need to consider these differences when creating social media campaigns to promote cycling and encourage more people to choose this mode of transportation. For example, \citet{harris2006gender} found that women tend to be more risk-averse than men and are more likely to perceive the negative consequences of sharing roads with vehicular traffic. \citet{garrard2008promoting} also found that female cyclists preferred off-road paths that were separated from traffic.
Males and females may have different motivations when choosing to ride a bicycle. According to \citet{singleton2016cycling}, gender-based differences in attitudes, preferences, and social norms may play a role. For instance, women who live alone and face financial or logistical barriers may be less likely to hop on a bike than males with similar characteristics. These findings suggest the need to reevaluate bicycle-promoting policies and interventions to better support and encourage women to cycle.
According to \citet{prati2019gender}, women reported higher discomfort when cycling in mixed traffic, higher risk perception, and lower risk of having a bicycle crash. In contrast, men reported higher exposure to severe crashes. Furthermore, \citet{bouaoun2015road} found that males have higher death rates from bicycle injuries than females due to their higher exposure rates and case fatality rates. However, when exposure is measured by the number of bicycle trips taken, males are at a slightly lower risk of injury than females. \citet{aitbihiouali2022inclusive} showed that the addition of bike infrastructure increases both the number and the share of women cycling in a city, with dedicated cycling infrastructure increasing women's participation by 4-6\%.
Therefore, it is important to evaluate the determinants of bicyclists' perception of safety and quality, as their perceptions can vary depending on their demographic and work characteristics, as well as the bicycle amenities and facilities on their commute route and at their workplace. Gender gaps exist in several aspects of riding, and perceived danger may be an important contributing factor, as shown in~\citet{emond2009explaining, garrard2008promoting}.
In this paper, we investigate whether there are gender differences in news coverage of cycling-related stories and accidents. We specifically address the following research question:
\begin{quote}
\textbf{RQ 2}: Do news agencies report on accidents involving male and female cyclists in proportion to the number of male and female cyclists and the number of male and female accidents?
\end{quote}
Suppose news coverage is based on the overall number of accidents and the total number of cyclists randomly sampled across all genders. In that case, we expect to see similar proportions of mentions in news articles reported as the statistics recorded in public health data. However, it is possible that other factors, such as gender stereotypes and biases, may influence the way these incidents are reported in the media.
\subsection{Label Correlations and Multi-label Text Classification}
Our task is a multi-label classification task. There have been multiple methods proposed for multi-label classification. For instance, a common approach is binary relevance ~\cite{tsoumakas2009mining}, which involves training independent binary classification models without considering the correlations between labels. Recent attempts in multi-label classification also consider label correlations~\cite{read2011classifier} when building a model for multi-label data. To capture label correlations, the Label Powerset (LP) problem transformation maps multi-label problems into a multi-class classification problem by training a classifier to predict label combinations directly as a single class~\cite{read2008pruned}. Likewise, \citet{read2011classifier} introduces Classifier Chains which builds a sequential set of classifiers where each classifier in the sequence takes the prior classifier's predictions as an additional feature. More recently, \citet{nam2017maximizing} uses a Seq2Seq framework where they transform classification tasks to sequence generation. However, both CC and Seq2Seq-based methods heavily rely on a predefined ordering of labels and perform sensitively to the label order.
Most of the prior work has focused on complex multi-label problems, sometimes with thousands of labels~\cite{rios2018few}. In our case, we have a highly structured output space with only a few categories. Hence, to incorporate label correlation information, we explore combining multi-task learning with traditional work with label correlations (e.g., LP) to transformers.
The most similar method to our proposed approach is by \citet{zhang2021enhancing}, which introduces auxiliary prediction tasks in a multi-task setting. Their method can handle large label spaces that do not match our setting. However, since our task only has a few labels, we can better use prior work (i.e., LP), but we still need to avoid some of its issues. For example, LP can not predict sets of labels that did not appear in the training data and introduces data sparsity. Hence, we use the LP transformation as an auxiliary task for multi-task learning. This is multiple advantages. First, it can be applied to standard neural network architecture without modification (i.e., only the loss function changes). Furthermore, contrary to recent prior work, our method does not have issues with label ordering in a Seq2Seq framework~\cite{nam2017maximizing}, nor does it require embedding the labels~\cite{zhang2021enhancing}.
\subsection{Connection with CSCW Research}
There has also been substantial CSCW-related research with regard to transportation and infrastructure~\cite{le2015planning,dillahunt2018getting,kameswaran2018we,almoqbel2019individual}. For example, \citet{brewer2019stories} examine the interactions between ridesharing drivers and passengers with vision impairments, by interviewing 18 drivers who have experience with driving such passengers. The study found that drivers engage in various forms of labor to support passengers with disabilities and do not see it as a burden, and also discussed ethical considerations for the process of disability disclosure. \cite{harding2019maintainer} present fieldwork findings on the maintenance of drainage infrastructure by transport maintainers, with a focus on the recent use of data-driven technologies and maintainer's perception of the potential role of the Internet-of-Things in future design and implementation. \citet{jones2021construction}
presents a description of how operators in a city department of transportation's transportation management center develop and maintain situational awareness for themselves and key recipients of their critical information outputs. \citet{kumar2018uber} present a qualitative study of Uber's introduction in Dhaka, Bangladesh, and how it affected transportation experiences and practices. It highlights how Uber reinforces existing forms of oppression and calls for a stronger connection between technology and policy, emphasizing the potential oppression caused by the opacity of algorithms. Simiarly, \citet{haque2021exploring} examines the relationship between car owners and drivers in ridesharing apps in the Global South and how it shapes the experience of using these apps. It is based on a study in Dhaka, Bangladesh and identifies the tensions, contract models and reasons for leaving Uber. The analysis shows how the local adoption of sharing economy amplifies existing inequalities and disrupts social dynamics, and has implications for design and policy.
There is also a lot of interest in the CSCW community around the news and semantic analysis, including but not limited to new datasets, models to analyze news headings for misinformation or polarization, analysis of reactions to news stories, and methods to help journalists write~\cite{rho2019hashtag,castillo2014characterizing,rho2018fostering,roth2020evaluating}. For example, \citet{liu2021transformer} proposes a computer-aided solution to combat extreme political polarization by reversing or neutralizing the political polarity of news headlines and articles. The proposed framework uses a transformer-based language model to identify polar sentences and then reverses the polarity through a generative adversarial neural network. The framework was tested on a benchmark dataset and it was found to improve the success rate of reversing/neutralizing polarity of headlines by 3\%-10\% compared to existing models. \citet{spezzano2021s} investigates how users identify real and fake news based on elements such as news title, image, source bias, and excerpt. It finds that automated techniques are more accurate than human participants in identifying fake news and that the best performance is not from the article text itself but from focusing on some elements of meta-data. There are also relations between ``clickbait'' and strategies used to in news headlines. \citet{chakraborty2017tabloids} examines the social sharing patterns of clickbait and non-clickbait tweets on Twitter to determine the reach of these tweets and the users who engage with them. It also compares the impact of clickbaiting with the rise of tabloidization of news, providing insights about news consumers and media organizations promoting news stories on Twitter. Finally, \citet{diakopoulos2021towards} This paper describes a news discovery tool, Algorithm Tips, that uses data-driven algorithmic analysis to help journalists identify newsworthy events and patterns related to algorithmic decision-making systems in government. The tool combines algorithmic, crowdsourced and expert evaluations in a user-friendly interface. The paper presents findings from an evaluation of the tool with 8 professional journalists, which offers insight on how such tools can enhance and transform news gathering practices.
Overall, our work adds to existing CSCW literature in three ways. First, this work explores a new transportation modality under explored in prior research (bicycling). Second, it combines two important and commonly discussed areas in CSCW, transportation and news, generating new tools and datasets to expand for future studies by CSCW researchers. Third, our work expands on prior issues of power and bias with an analysis of the interaction of gender differences in reporting in the news, particularly as related to cycling-related accidents that can generate potentially unwaranted fear that will limit the number of future cyclists.
\section{Data Collection and Annotation}
In this section, we describe our task, data collection, and data annotation procedures.
\subsection{Data Collection}
We use Google News to collect cyclists' and accident-related news headlines from 2001 to 2021. Google News is a popular news aggregation service that has been available on Google for a long time. It aggregates the latest news across multiple news sources and categorizes them based on trends, regions, and topics. We use Google News XML RSS Feed API~\footnote{\url{https://news.google.com/news/rss.}}. The API limits the number of articles we can receive each month. We use the keywords ``cycling'', ``motorcycling'', ``cyclist'', ``bike'', and ``motorcycle'' to pull headlines. Overall, we scrape a total of 81,746 articles, representing 32,980 and 48,266 for cyclist and motorcyclist-related headlines, respectively. For annotation, we randomly sample 50\% of the headlines with the keywords ``crash'', ``death'', ``killed'', and ``dead'' and 50\% without. Annotators are provided a random sample generated from the entire dataset and the sub-sampled subset uniformly. We use the second set of keywords to guarantee that accident-related posts are annotated. However, it is important to note that accident-related posts can also appear without the sub-sampled keywords.
\subsection{Annotation Guidelines}
\begin{comment}
\begin{figure}
\centering
\includegraphics[width=0.8\linewidth]{Screen Shot 2022-01-17 at 11.09.23 AM.png}
\caption{Example news headline that appeared on KSAT.com---a local news station for the San Antonio metropolitan area. ME stands for ``Medical Examiner.''}
\label{fig:my_label}
\end{figure}
\end{comment}
We annotate two major categories for each news headline: Perception and Accident categories. Each category is useful in understanding how people interpret the writer's sentiment towards the cyclists in the headline, whether the article is about an accident, and the readers perceived opinion about who caused the accident.
\subsubsection{Perception Categories}
Perception is used to analyze and measure how readers perceive how readers interpret the writer's sentiment towards the (Motor)cyclists in the headline. Specifically, we ask annotators to label perception into three categories: Negative, Positive, and Neutral.
\paragraph{Negative.} The negative class is used if the reader interprets the writer's perception as a negative sentiment toward the cyclist. Negative perceptions can come in many forms. For example, the headline
\begin{quote}
{\textbf{Example}: Cyclist harasses motorists at Serangoon roundabout, smacks vehicles while hurling vulgarities---The~Independent}
\end{quote}
provides an example where a cyclist is actively harming vehicles. Likewise, negative perception can be caused because of explicit mentions of breaking traffic laws, for example, the headline
\begin{quote}
\textbf{Example:} Dashcam sees bus \& cyclist ignore red light in Norwich - Norwich Evening News
\end{quote}
discusses a cyclist running a red light. Generally, annotators agreed that it is negative when a cyclist is portrayed as committing a traffic crime. Upon inspection of the article, someone submitted a video because of the danger that can be caused by a bus running a red light, which can be perceived as a much higher danger than a cyclist running a red light. However, the writer found it equally important to mention the cyclist because their appearance in the video was interesting and relevant to the writer's implicit viewpoint. Thus, we argue that the writer is implicitly reporting the cyclist negatively by equating their actions with the more severe actions of the bus driver.
\paragraph{Positive.} A positive perception is meant to reflect the reader's interpretation of the writer's headline as being positive about the cyclist. This can manifest in multiple ways. For example, the headline
\begin{quote}
\textbf{Example:} A Plover man donated a kidney to save a stranger. Now he's cycling cross-country to raise awareness. - Stevens Point Journal
\end{quote}
discusses how a cyclist is raising awareness for organ donation. On the other hand, there are many examples where an accident is discussed where direct mention of severe injuries is described by the cyclist. For instance, the headline
\begin{quote}
\textbf{Example:} Speeding taxi drags cyclist to his death, leaves another injured - DispatchLIVE
\end{quote}
describes a cyclist being killed in an accident. In such gruesome (i.e., descriptive) descriptions, annotators assumed that the writer was expressing negative sentiment towards the driver. Yet, the writer's perception of the cyclist is positive, i.e., the writer would not write such a descriptive narrative of the accident if they thought negatively about the cyclist. Hence, even though the writer is reporting a gruesome event, it is perceived to be to raise awareness about the driver's actions. Less descriptive headlines were labeled as neutral. This has been shown to be the case in prior work by \citet{joye2015domesticating} where establishing an emotional bond (e.g., ``panic and chaos everywhere'') can be a tactic to get the audience to care. Finally, in
\begin{quote}
\textbf{Example:} Remorseful taxi driver keeps license after cyclist crash - alloaadvertiser.com
\end{quote}
\paragraph{Neutral.} There are many headlines where it is unclear whether the writer views the cyclists with positive or negative perceptions. We label such headlines as Neutral. For example, the headline
\begin{quote}
\textbf{Example:} French cyclist Brunel signs two-year deal with UAE Team Emirates - Gulf Today
\end{quote}
provides a simple fact about an athlete. There is little emotional expression in the text, and it is impossible to determine whether the writer is a fan of the athlete. On the other hand, the headline
\begin{quote}
\textbf{Example:} SH 183 reopened in Cedar Park after cyclist-vehicle crash - KXAN.com
\end{quote}
reports a crash similar to the positive headline discussed above. However, the description of this headline is not directly about the accident---it is focused on the reopening of a highway. Hence, it is difficult to determine how the writer feels about the cyclist.
\begin{table}[t]
\centering
\begin{tabular}{lllll}
\toprule
& & \multicolumn{1}{c}{\textbf{Motor Cyclists}} & \multicolumn{1}{c}{\textbf{Cyclists} } & \textbf{Total} \\ \cmidrule(lr){3-3} \cmidrule(lr){4-4} \cmidrule(lr){5-5}
\multirow{2}{*}{\textbf{Related}} & Yes & 1347 & 683 & 2030 \\
& No & 653 & 817 & 1470 \\ \midrule
\multirow{3}{*}{\textbf{Fault}} & Cyclist. & 192 & 57 & 249 \\
& Neu. & 879 & 295 & 1174 \\
& Other. & 281 & 335 &616 \\ \midrule
\multirow{3}{*}{\textbf{Perception}} & Neg. & 142 & 93 & 235 \\
& Neu. & 1705 & 657 & 2362 \\
& Pos. & 153 & 750 & 903 \\ \bottomrule
\end{tabular}%
\caption{Dataset Statistics for the annotations of the labeled data.}
\label{tab:stats}
\end{table}
\subsubsection{Accident-Related Categories}
We annotate headlines into two major classes: Related to an Accident (Yes/No) and Accident Fault (Cyclists, Unknown, Driver).
\paragraph{Related to Accident (Yes/No).} A headline is related to an accident if it is directly discussed in the headline. For instance, the headline
\begin{quote}
\textbf{Example:} Caught On Camera: Passenger Opens SUV Door, Seriously Injuring Cyclist in Lincoln Park
\end{quote}
directly mentions a crash involving cyclists (we use the same criteria for motorcyclists). Likewise, we annotate headlines that involve an ``attack'' of some kind (e.g., a fight, assault, etc.) as being related to an accident. For example, the headline
\begin{quote}
\textbf{Example:} Cyclist attacked by two unknown tracksuited men on Boothferry Road --- Hull Live
\end{quote}
mentions cyclists actually getting attacked by two track-suited men.
The ``Not Related'' category is used for headlines that do not mention anything related to an accident. For instance, the headline
\begin{quote}
\textbf{Example:} Gallery: A Paris-Roubaix for the ages --- Cyclist
\end{quote}
discusses a race, not an accident or attack.
\paragraph{Fault.}
If a headline is related to an accident, we annotate it with who is perceived to be at fault by readers, i.e, who caused the accident. Specifically, annotators will label each headline as ``Cyclists'', ``Unknown'' or ``Other''. For instance, the ``\textbf{Cyclists}'' fault headline
\begin{quote}
\textbf{Example:} Blame entirely on the cyclist. Cyclist collided with truck
\end{quote}
directly puts the blame \textit{entirely} on the cyclist; hence it is labeled as being the cyclist's fault.
As an example of the ``\textbf{Unknown}'' class, the headline
\begin{quote}
\textbf{Example:} SH 183 reopened in Cedar Park after cyclist-vehicle crash - KXAN.com
\end{quote}
shows a fact and does not provide details about who caused the accident. Finally, for the ``\textbf{Other}'' class, in the headline
\begin{quote}
\textbf{Example:} Alludes to hit and run on the vehicle owner’s part.
\end{quote}
we see an example where a driver was involved in a hit-and-run. In this case, someone ``Other'' (i.e., the driver) is at fault.
\subsection{Agreement and Dataset Statistics}
\begin{table}[t]
\centering
\begin{tabular}{llll}
\toprule
& \textbf{Related} & \textbf{Fault} & \textbf{Perception} \\ \midrule
Cohen's Kappa & .90 & .71 & .52 \\ \bottomrule
\end{tabular}%
\caption{Cohen's Kappa between the two annotators for each category for all of our labeled data (cyclist + motorcyclist).}
\label{tab:agreement}
\end{table}
We followed a two-stage annotation procedure. First, two annotators completed the process independently of one another. One-on-one interviews were conducted with annotators to identify dataset issues versus annotator errors. The information gained from the discussions was then used to improve the guidelines. Next, the two annotators completed a total of 3,000 additional headlines for a total dataset size of 3,500 examples. The agreement results are shown in Table~\ref{tab:agreement}. The Cohen's Kappa agreement scores ranged from .52 to .90, representing ``moderate agreement'' and ``almost perfect agreement,'' respectively~\cite{landis1977measurement}. Determining whether something is related to an accident was easiest for the annotators, while Perception had the lowest agreement. However, .52 is still quite high for measuring Perception and is in line with similar work in the area of sentiment analysis~\cite{bobicev2017inter}. Second, to further improve data annotation, we again met with the annotators and reviewed and discussed disagreements among the annotated headlines to form the final gold standard dataset. The final dataset statistics can be found in Table~\ref{tab:stats}.
\section{Methodology}
We evaluate a total of six baseline models: a Linear Support Vector Machine (SVM), a Convolutional Neural Network (CNN), RoBERTa, and three random/simple baselines.
Likewise, we experiment with two multi-task learning methods to incorporate co-occurrence information into the model: Multi-Task RoBERTa (MTR) and Multi-Task RoBERTa using the Labeled Powerset Transformation (MTRLP).
\paragraph{Linear SVM.} We trained a Linear SVM using the frequency-inverse document frequency-weighting (TF-IDF) of unigrams, bigrams, and L2 regularization. TF-IDF is a statistical technique that assigns a weight to each word in a corpus (a collection of texts) based on how important the word is in that particular collection of texts. Furthermore, we searched for the best C value from the set \{0.0001, 0.001, 0.01, 0.1, 1, 10\} using a validation dataset. The SVM is implemented using the LinearSVC classifier in scikit-learn~\cite{pedregosa2011scikit}.
\begin{comment}
\paragraph{Covolutional Neural Networks (CNN).} We use the model proposed by \citet{kim2014convolutional}. Essentially, the model is a shallow CNN with
max-over-time pooling, followed by a sigmoid output layer. Let $\mathbf{x}_i \in \mathbb{R}^d$ represent a $d$-dimensional embedding of the $i$-th word in a document. The CNN learns to extract ngrams from text that are predictive of the downstream task. Formally, each span of $s$ words are concatenated, $[\mathbf{x}_{i-s+1}; \dots ; \mathbf{x}_i]$, into a contextual vector $\mathbf{c}_j \in \mathbb{R}^{s(d+2e)}$. Next, using a rectified linear unit~\cite{nair2010rectified} $f()$, the convolution operation is applied to each vector,
\begin{equation*}
\hat{\mathbf{c}}_j = f(\mathbf{W} \mathbf{c_j} + \mathbf{b}),
\end{equation*}
where $\mathbf{b} \in \mathbb{R}^q$. Next, given the convolved context vectors $[\hat{\mathbf{c}}_1, \hat{\mathbf{c}}_2, \ldots, \hat{\mathbf{c}}_{n+s-1}]$, the CNN map them into a fixed sized vector using max-over-time pooling
\begin{equation*}
\mathbf{g} = [\hat{c}^1_{max}, \hat{c}^2_{max}, \ldots, \hat{c}^q_{max}], \quad \text{where}
\end{equation*}
\begin{equation*}
\hat{c}^j_{max} = max(\hat{c}^j_1, \hat{c}^j_2, \ldots, \hat{c}^j_{n+s-1}),
\end{equation*}
such that $\hat{c}^j_{max}$ represents the max value across the $j$-th feature map. Finally, $\mathbf{g}$ is passed to a sigmoid output layer. We train the CNN with filter sizes that span three, four, and five words. Furthermore, we use a total of 300 filters for each size, and the Adam optimizer~\cite{kingma2014adam}.
\end{comment}
\paragraph{RoBERTa.} We fine-tuned RoBERTa~\cite{liu2019roberta} from the Huggingface libary~\cite{wolf2019huggingface}, specifically the roberta-base variant. Moreover, following success in related work~\cite{ganesan2021empirical}, we average the second-to-last layer's token embeddings which are passed to a softmax layer that is fine-tuned for up to 25 epochs. The model was checkpointed after each epoch, and the best version was chosen using the validation data. We used the cross-entropy loss as the objective function, a mini-batch size of 8, and a learning rate of 2e-5 (other hyper-parameters same as \cite{liu2019roberta}). Finally, we used the Adam optimizer~\cite{kingma2014adam} with a Cosine linear learning rate scheduler~\cite{gotmare2018closer} with no warm-up steps.
\paragraph{Random Baselines.} We use two random baselines from the scikit-learn package~\cite{pedregosa2011scikit}: Uniform and Stratified. The Uniform baseline makes predictions for each class with equal proportions. The stratified random baseline makes predictions based on the class proportions in the training dataset.
\paragraph{Multi-Task RoBERTa (MT RoBERTa).} We employ a standard method of multi-task learning approach that has been shown to be successful in similar text classification tasks~\cite{kochkina2018all}. Specifically, let $\mathbf{h} \in \mathbb{R}^k$ be the representation returned using RoBERTa where $k$ is the size of the hidden layer. Given $\mathbf{h}$, we jointly train the two output layers for Perception and Accident information (Related to an Accident and Fault). The RoBERTa parameters are shared for each task. To train the model, we simply perform a weighted average of the Cross-Entropy losses defined as
\begin{equation*}
L = \sum_{i=1}^T w_i CE(\mathbf{y}_i, \mathbf{\hat y}_i)
\end{equation*}
where $T$ is the number of Tasks, $\mathbf{y}_i$ is the ground-truth classes for task $i$, $\mathbf{\hat y}_i$ are the predictions, $CE()$ is the Cross Entropy loss, and $w_i$ is a weight for task $i$. After experimenting with various weights for $w_i \in [0,1]$ we found weights of 1 to perform the best on our validation data.
\begin{table*}[t]
\centering
\resizebox{\linewidth}{!}{%
\begin{tabular}{llllllll}
\toprule
& \multicolumn{3}{c}{\textbf{Perception Categories}} & \multicolumn{3}{c}{\textbf{Accident Categories}} \\ \cmidrule(lr){2-4} \cmidrule(lr){5-8}
& \textbf{Negative} & \textbf{Neutral} & \textbf{Positive} & \multicolumn{1}{c}{\textbf{Not Accident}} & \multicolumn{1}{c}{\textbf{Cyclist}} & \multicolumn{1}{c}{\textbf{Unknown}} & \multicolumn{1}{c}{\textbf{Other}} \\ \midrule
\textbf{Uniform} & .110 & .444 & .306 & .290 &.114 & .304 & .186 \\
\textbf{Stratified} & .090 & .663 & .218 & .430 & .066 & .370 & .150 \\ \midrule \midrule
\textbf{Linear SVM} & .381 & .829 & .625 & .902 & .462 & .834 & .741 \\
\textbf{RoBERTa} & .612 & .850 & .691& .929 & .574 & .853 & .809 \\ \midrule
\textbf{MT RoBERTa} & \textbf{.650} & .860 & \textbf{.713} & .933 & .588 & .851 & .803 \\
\textbf{MTLPT RoBERTa} & .639 & \textbf{.861} & .699 & .934 & .584 & .863& .805 \\
\textbf{MT + MTLPT RoBERTa} & .629 & .855 & .696 & \textbf{.935} & \textbf{.610} & \textbf{.860} & \textbf{.814} \\ \bottomrule
\end{tabular}%
}
\caption{F1 scores for all classes. The best scores are \textbf{bolded} for each column.}
\label{tab:accident}
\end{table*}
\paragraph{Multi-Task RoBERTa using the Labeled Powerset Transformation (MTLPT RoBERTa).} While MT RoBERTa implicitly incorporates label co-occurrence information by jointly training each class, it does not explicitly capture the information which can limit co-occurrence knowledge acquisition for infrequently co-occurring classes. For multi-label classification, methods have been proposed to take advantage of class co-occurrence~\cite{tsoumakas2009mining}. Particularly, the Labeled Powerset (LP) Transformation is a common approach~\cite{read2008pruned}. We combine the LP transformation to create an auxiliary output layer that is trained in a multi-task setting. The auxiliary output layer is not used for inference.
Intuitively, instead of training an output layer that predicts each class independently, e.g., ``Positive Perception'' and ``Cyclist-Fault'', a new class is created that combines all of the classes assigned to each instance. In this example, if the Perception is Positive and the Fault is assigned to the Cyclist, the new class would be ``Positive-Perception\_Cyclist-Fault'', which consists of transforming a multi-label problem into a single-label multi-class problem. In the transformed problem, each combination of labels presented in the original dataset is transformed into a single class. Despite the disadvantage of being the worst-case computational complexity (involving $2^L$ classes in the transformed multi-class problem where $L$ is the total classes), the LP transformation is simple, considers label correlations, and after transformation, any multi-class algorithm can be used for classification. However, many of the newly generated classes appear to infrequently make adequate predictions. Hence, we use this task as an additional multi-task regularizer.
Formally, we define the new multi-task classification task as
\begin{equation*}
L_i = CE(\mathbf{y}_i, \mathbf{y}_i) + \alpha CE(\mathbf{y}_p, \mathbf{\hat y}_p)
\end{equation*}
where $\alpha$ is a hyperparameter for the weight of the LP transformed loss, $\mathbf{y}_p$ is the vector of ground-truth for the LP transformed classes, and $\mathbf{\hat y}_p$ represents the predictions. We train a model for each class independently (i.e., $L_i$ is a loss function for task $i$) where the LP transformation outputs are used as a regularizer. We also experiment with combining the LP transformation loss with the MT RoBERTa model described above. Overall, the final loss is defined as
\begin{equation*}
L = \alpha CE(\mathbf{y}_p, \mathbf{\hat y}_p) + \sum_{i=1}^T w_i CE(\mathbf{y}_i, \mathbf{\hat y}_i)
\end{equation*}
where, again, $\alpha$ is a hyperparameter and $w_i$ is the weight of each of the individual task losses. Empirically, we found setting everything to one (i.e., $\alpha$ and $w_i$) resulted in the best performance on the validation dataset.
\begin{comment}
\begin{table}[t]
\centering
\resizebox{\linewidth}{!}{%
\begin{tabular}{llllllllll}
\toprule
& \multicolumn{3}{c}{\textbf{Negative}} & \multicolumn{3}{c}{\textbf{Neutral}} & \multicolumn{3}{c}{\textbf{Positive}} \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-10}
& \textbf{P} & \textbf{R} & \textbf{F1} & \textbf{P} & \textbf{R} & \textbf{F1} & \textbf{P} & \textbf{R} & \textbf{F1} \\ \midrulehttps://www.overleaf.com/project/62d71ac30e69f66301895a07
\textbf{Uniform} & & & & & & & & & \\
\textbf{Stratified} & & & & & & & & & \\ \midrule \midrule
\textbf{Linear SVM} & & & & & & & & & \\
\textbf{RoBERTa} & & & & & & & & & \\ \midrule
\textbf{MT RoBERTa} & & & & & & & & & \\
\textbf{MTLPT RoBERTa} & & & & & & & & & \\
\textbf{MT + MTLPT RoBERTa} & & & & & & & & & \\ \bottomrule
\end{tabular}%
}
\caption{Perception Results here}
\end{table}
\end{comment}
\begin{comment}
\begin{table}[t]
\centering
\resizebox{\linewidth}{!}{%
\begin{tabular}{llllllllll}
\toprule
& \multicolumn{3}{c}{\textbf{Yes}} & \multicolumn{3}{c}{\textbf{No}} \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7}
& \textbf{P} & \textbf{R} & \textbf{F1} & \textbf{P} & \textbf{R} & \textbf{F1} \\ \midrule
\textbf{Uniform} & .6033 & .5421 & .5711 & .4510 & .5135 & .4803 \\
\textbf{Stratified} & .5897 & .5941 & .5919 & .4403 & .4358 & .4380 \\ \midrule \midrule
\textbf{Linear SVM} & .9260 & .9604 & .9429 & .9431 & .8953 & .9185 \\
\textbf{RoBERTa} & & & & & & \\ \midrule
\textbf{MT RoBERTa} & & & & & & \\
\textbf{MTLPT RoBERTa} & & & & & & \\
\textbf{MT + MTLPT RoBERTa} & & & & & & \\ \bottomrule
\end{tabular}%
}
\caption{Related to an Accident Results Here.}
\end{table}
\end{comment}
\begin{comment}
\begin{table*}[t]
\centering
\resizebox{0.8\textwidth}{!}{%
\begin{tabular}{ll}
\toprule
\textbf{Category} & \textbf{Words} \\ \midrule
\multicolumn{2}{c}{\textbf{Related to Accident}} \\ \midrule
Yes & XXX, XXXXX, XXXXXX, XX, XX XX, XX, XX XXX, X, XXX, XXXXX XXXX \\
No & XXX, XXXXX, XXXXXX, XX, XX XX, XX, XX XXX, X, XXX, XXXXX XXXX \\ \midrule \midrule
\multicolumn{2}{c}{\textbf{Cause}} \\ \midrule
Cyclist & XXX, XXXXX, XXXXXX, XX, XX XX, XX, XX XXX, X, XXX, XXXXX XXXX \\
Neutral & XXX, XXXXX, XXXXXX, XX, XX XX, XX, XX XXX, X, XXX, XXXXX XXXX \\
Other & XXX, XXXXX, XXXXXX, XX, XX XX, XX, XX XXX, X, XXX, XXXXX XXXX \\ \midrule \midrule
\multicolumn{2}{c}{\textbf{Perception}} \\ \midrule
Negative & XXX, XXXXX, XXXXXX, XX, XX XX, XX, XX XXX, X, XXX, XXXXX XXXX \\
Neutral & XXX, XXXXX, XXXXXX, XX, XX XX, XX, XX XXX, X, XXX, XXXXX XXXX \\
Positive & XXX, XXXXX, XXXXXX, XX, XX XX, XX, XX XXX, X, XXX, XXXXX XXXX \\
\bottomrule
\end{tabular}%
}
\caption{Most predictive words are found by the Linear SVM model for each Intent and Support category. The words are ranked based on predictive power, e.g., the first word is the most predictive, the second word is the second most predictive, etc.}
\label{tab:phrase}
\end{table*}
\end{comment}
\section{Experiments}
This section describes the experimental setup and evaluation metrics used in our experiments.
\subsection{Experimental Setup.}
For evaluation, We train multiple models on our dataset using a 5-fold shuffle-split cross-validation procedure. Specifically, a model is trained on each training split of the dataset. Then it is applied to the test dataset to calculate each class's F1 score. A 10\% portion of the training split for each fold is used for hyperparameter selection. This procedure has been used in prior work to ensure robust results in similar social media-related NLP studies~\cite{yin2017power,elejalde2017nature,samory2020characterizing}.
\subsection{Evaluation Metrics}
For multi-label classification, micro and macro F1-score are widely used~\citep{multieval}.
For each label $l_j$ in the set of labels $\mathbf{l}$ being considered, we have label-based precision $P(l_j)$, recall $R(l_j)$, and
F-score $F(l_j)$ defined as
\begin{equation*}
P(l_j) = \frac{TP_j}{TP_j + FP_j}, \qquad R(l_j) = \frac{TP_j}{TP_j + FN_j},
\end{equation*}
\begin{equation}
\label{eq:labelfscore}
\mbox{and} \,\, F(l_j) = \frac{2P(l_j) R(l_j)}{P(l_j) +R(l_j) },
\end{equation}
where $TP_j$, $FP_j$, and $FN_j$ are true positives, false positives, and false negatives for label $l_j$, respectively. Precision is the fraction of predicted relevant labels among all predicted labels, while recall is the fraction of predicted relevant labels among all relevant labels. Then F() is simply the harmonic mean between precision and recall for the $j$-th label.
\subsection{Results.} In Table~\ref{tab:accident} we report the F1 score for each of the Accident-related classes. We find that RoBERTa outperforms both the Linear and Random baselines substantially. Likewise, MT RoBERTa outperforms the standard RoBERTa model for every class except for the ``Unknown'' and ``Other'' classes. When comparing MTLPT RoBERTa to MT RoBERTa, we find that it improves the performance in four of the seven classes. However, many of the improvements are not substantial. The largest improvements are seen for many of the classes with the ML + MTLPT RoBERTa model, particularly for the Accident-related classes. The model under performs slightly for the Perception-related classes. We hypothesize that this is caused by the data sparsity for the Accident-related class. Particularly, the Accident-related classes are limited to 2030 examples, while the Perception classes have access to all 3500 examples---before splitting off the test/dev sets. Hence, the extra information given via the MTLPT component is better used by sparse classes.
\subsection{Error Analysis}
\begin{figure}[t]
\centering
\includegraphics[width=.8\linewidth]{confusion.pdf}
\caption{Confusion Matrix for the Accident-related categories: ``Not an Accident'', ``Cyclists'' fault, ``Unknown'' fault, and ``Other'' fault.}
\label{fig:confusion}
\end{figure}
In Figure~\ref{fig:confusion} we report the confusion matrix from one of the test sets from the cross-validation shuffle-split evaluation process. Overall, we can make two major observations. First, there are many errors where the Cyclists or Other was at fault, but the model predicts neutral.
When analyzing the data and working with the annotators, this type of error makes sense because the large degree of uncertainty during the annotation process was for the Unknown class. However, it is important to note that because of the ordinal nature of the classes, it is better to have errors between the Unknown and Cyclist/Other classes. If most of the errors were between the Cyclist and Other classes, this would be a major concern. As an example, the headline
\begin{quote}
\textbf{Example:} Motorcyclist killed in Hesperia after U-turn crash - VVdailypress.com
\end{quote}
was classified as being the Cyclist's fault, but the annotators labeled it was ``Unknown''. In this case, the model may associate ``U-turn crash'' with the cyclist doing something wrong. However, this may or may not be the case. As another example, the headline
\begin{quote}
\textbf{Example:} Motorcyclist killed in crash on 405 Freeway in Long Beach • Long Beach Post News - Long Beach Post
\end{quote}
was classified as being the ``Other's'' fault. However, the headline provides no details about the actual fault of the accident.
Second, we also find quite a few errors between the ``Not an Accident'' class and the Unknown and Other classes.
Next, we provide an example where the ground truth is ``Not an Accident'', but the model predicted ``Other''. We can see from the headline
\begin{quote}
\textbf{Example:} Drivers targeted in Inverurie and Peterhead over cyclist issues - Grampian Online
\end{quote}
where the model incorrectly identified ``Other'' because of the phrase ``Drivers targeted'' which caused the error. Likewise, in the example
\begin{quote}
\textbf{Example:} East Liverpool police say motorcyclist led officer on chase, dropped small bag of marijuana - WKBN.com
\end{quote}
the model incorrectly identifies the headline as the Cyclist's fault where the ground truth is ``Not an Accident''. This error is potentially caused by incorrectly analyzing the drug-use.
\subsection{Analysis and Discussion.}
In this section, we use our model to perform a case study using all of our data. Specifically, we analyze differences in reporting, comparing cyclist articles to motorcyclist articles, comparing general news websites to domain-specific websites (e.g., bicycling.com), and comparing differences when gender-related names are mentioned.
\begin{figure}[t]
\centering
\includegraphics[width=.8\linewidth]{motor.pdf}
\caption{The proportion of accident-related headlines in the domain-specific (e.g., bicycling.com and motorcyclistonline.com) and general news websites (e.g., nypost.com and chicagotribune.com) for bicyclists and motorcyclists. }
\label{fig:groups}
\end{figure}
\subsubsection{RQ 1: Are there differences between bicycling and motorcycling-related news content?}
We apply our model to all 81,746 news headlines pulled during our initial data collection procedure.
Next, we count the total number of accident-related headlines (i.e., headlines where our model did not predict ``Not an Accident'') for each website that appears more than 100 times in both the cycling and motorcycling-related data. In total, we found 40 and 42 websites for cyclists and motorcyclists, respectively. The average number of times each website appeared was more than 300 for both groups. For each website, we manually classify each website as being dedicated to cycling or automobiles/motorcycles (i.e., domain-specific websites such as bicycling.com and www.motorcyclistonline.com) or as a general news website (e.g., nytimes.com and washingtonpost.com). Finally, we calculate the proportion of accident-related headlines for domain-specific and general news websites for the cycling and motorcycle datasets.
The proportions are reported in Figure~\ref{fig:groups}. Overall, we find that general news websites are much more likely to report accident-related stories than domain-specific websites. However, we see significant differences between reports about motorcyclists and cyclists. Automobile and motorcycling-specific websites (e.g., motorcyclecruiser.com and motorcyclistonline.com) are significantly less likely (p-value < .00001 using Z-test) to make accident-related headlines when compared to cycling-specific websites (e.g., road.cc and bicycling.com). Yet, for general news websites, the pattern reverses. General news websites are making significantly more when discussing cyclists and motorcyclists (p-value < .00001 using Z-test). Yet, motorcycling is more likely to result in fatal injuries~\cite{factsmoto,factscycle}, which can impact perceived dangers. This difference can potentially provide motorcyclists with more of a sense of safety than what is portrayed on cycling-specific websites. This finding suggests many interesting future lines of research. For example, should cyclist-specific websites reduce the proportion of accident-related posts? Would this increase the number of riders, or would this be dangerous to hide? Should motorcycle-specific websites discuss the dangers of riding more? We believe these findings can also cause feedback loops as reported by \citet{macmillan2017understanding}, where reporting patterns can reduce riders, which can reduce government spending, and which in turn can reduce riders again. Answering these questions can potentially impact future cycling growth.
\begin{figure}[t]
\centering
\includegraphics[width=.8\linewidth]{fmotor.pdf}
\caption{The proportion of headlines in domain-specific websites (e.g., bicycling.com and motorcyclistonline.com) vs. general news-based websites (e.g., nytimes.com and washingtonpost.com) on who is perceived to be at-fault for the accident, the *Cyclists (bicyclists or motorcyclists), or other entities in the headline (Other). }
\label{fig:groups2}
\end{figure}
In Figure~\ref{fig:groups2}, we report the proportion of headlines in the domain-specific and general news categories that state that the *cyclists (bicyclists or motorcyclists) are at fault for the accident or the ``Other'' person being at fault. This figure answers the question, which websites are more likely to report negative stories about cyclists? We see the highest proportion of at-fault stories are made by general news websites. However, cycling-related headlines are more likely to be related to an accident in all cases except for the general news domain, where the fault is being put on the cyclists. Specifically, a larger proportion of motorcycling-specific headlines in the general news domain portray the motorcyclist as being at fault (.09) than cyclists are portrayed as being at fault (.04) with p-value < .00001 using a Z-test.
\begin{table}[]
\centering
\begin{tabular}{@{}llll@{}}
\toprule
\textbf{URL} & \textbf{Cycling} & \textbf{Motorcycling} & \textbf{p-value} \\ \midrule
stuff.co.nz & .317 & .606 & .000 \\
timesofmalta.com & .582 & .955 & .000 \\
walesonline.co.uk & .428 & .865 & .000 \\
bernews.com & .182 & .685 & .000 \\
nzherald.co.nz & .448 & .763 & .000 \\
stabroeknews.com & .565 & .861 & .000 \\
bbc.com & .578 & .888 & .000 \\
cbc.ca & .470 & .637 & .000 \\
mercurynews.com & .333 & .775 & .000 \\
manchestereveningnews.co.uk & .642 & .900 & .000 \\
toronto.ctvnews.ca & .714 & .970 & .000 \\
washingtonpost.com & .260 & .530 & .000 \\
dailyrecord.co.uk & .486 & .747 & .000 \\
nydailynews.com & .535 & .84 & .000 \\
independent.ie & .419 & .775 & .000 \\
chicagotribune.com & .297 & .671 & .000 \\
denverpost.com & .404 & .733 & .001 \\
patch.com & .679 & .860 & .002 \\
bbc.co.uk & .467 & .691 & .003 \\
globalnews.ca & .611 & .734 & .011 \\
cp24.com & .784 & .949 & .013 \\
birminghammail.co.uk & .638 & .865 & .013 \\
mylondon.news & .795 & .957 & .021 \\
abc.net.au & .377 & .520 & .024 \\
nypost.com & .546 & .685 & .045 \\
getsurrey.co.uk & .781 & .905 & .046 \\ \bottomrule
\end{tabular}%
\caption{Websites with significant differences (Cycling vs. Motorcycling Headlines) in the proportion of accident-related posts. P-value is calculated using the two-sample Z-score test for proportions The websites have been sorted based on their respective p-values.}
\label{tab:sig}
\end{table}
In Table~\ref{tab:sig}, we list all websites that appear more than 30 times in both the 32,980 and 48,266 cycling and motorcycling headlines, respectively, and have a p-value less than 0.05 using the Z-score test for proportions. Overall, we find that all websites with statistically significant differences have greater proportions of headlines about motorcyclist-related accidents. This means that they are more likely to discuss non-accident-related content about cyclists when compared to motorcyclists. However, we do see great variation in the absolute differences in proportions. For instance, the difference in cyclist and motorcyclist-related accidents on nypost.com is .138. In contrast, the difference for the chicagotribune.com is .3736, indicating that the chicagotribune.com may treat motorcycling and cycling-related posts substantially differently than the nypost.com.
It is important to note that while these websites may have a greater proportion of headlines about motorcyclist-related accidents, this does not necessarily mean that they are biased against cyclists or motorcyclists. It is possible that the content on these websites reflects the overall prevalence of accidents involving motorcyclists compared to cyclists. It is also possible that there are other factors at play, such as the types of stories that these websites tend to cover or the locations in which they are based. In order to better understand the reasons behind these differences in proportions, it would be necessary to perform further analysis and consider a wider range of factors. This could include looking at the language used in the headlines, the tone of the articles, and the types of sources cited. It could also be useful to examine the demographics of the readership for these websites and consider whether there may be any biases in the types of stories that they are interested in.
\subsubsection{RQ2: Do news agencies report on accidents involving male and female cyclists in proportion to the number of male and female cyclists and the number of male and female accidents?}
As mentioned before, female cyclists may be more influenced by news that addresses their specific concerns and needs, while male cyclists may be more influenced by news that aligns with their attitudes and perceptions~\cite{emond2009explaining}.
It is also important to consider the potential gender differences of individuals involved in cycling and motorcycling accidents, as research has shown that fatalities among women are more likely to be covered in the news, which may be due to the perception of women as more vulnerable road users compared to men. Therefore female-related accident is more newsworthy~\cite{mindell2012exposure}. In general, male cyclists have higher injury risks compared to female cyclists. According to \citet{centers2003web}, male cyclists have death rates that are six times higher and injury rates that are five times higher than females. Therefore, if the media reported accidents equally, we would expect male-related news headlines to be around six times more numerous than female accidents.
In this work, we look at grammatical gender via gendered pronouns. Specifically, we search for male-related pronouns (he, his, him) and female-related pronouns (her, she, hers) in each headline. The headline is then categorized into either a male-related or female-related group depending on what is matched. In this work, we do not use gender-related names because names provide a weak signal about gender. Whereas pronoun usage at least provides insight into how the writer interprets the gender of the people mentioned in the headline.
Using the grammatical gender classifications, we report our analysis in Figure~\ref{fig:not-accident}. The results suggest that the proportion of headlines not about an accident is lower for male cyclists compared to female cyclists (.50 vs. .59), which is statistically significant( p-value <.0001). The same pattern is observed for motorcyclists, with the proportion of headlines not about an accident being lower for males (.25) compared to females (.35). The finding that there are more male-related accident posts compared to female-related posts matches public health statistics about cycling-related accidents for men vs. women~\cite{prati2019gender}. But the difference in the number of accident reports for males is only 2.14 times higher than for females, which is much lower than the expected level based on the higher accident rates for males. Specifically, the CDC reports that men are six times more likely to have a fatal crash and five times more likely to be involved in an injury-causing crash~\cite{cdc}.
\begin{figure}[t]
\centering
\includegraphics[width=.8\linewidth]{ch1.pdf}
\caption{The proportion of male/female headlines that are not related to an accident for bicyclists and motorcyclists, where the ratio of male- and female-related headlines are .3118 and .1456, respectively.}
\label{fig:not-accident}
\end{figure}
Overall, the results suggest that the media may be biased in its coverage of cycling and motorcycling accidents involving males and females. While there are more male-related accidents overall, the media may be more likely to cover accidents involving females (at least as measured by grammatical gender). Suppose the media considers female-related accidents to be more newsworthy. In that case, they will report a higher proportion of such accidents, leading to an increase in the number of headlines about female-related accidents. Unfortunately, according to \citet{prati2019gender}, women report a higher discomfort when cycling in mixed traffic, as well as higher risk perception and lower risk of having a bicycle crash. Hence, if the media is more likely to report on female-related accidents than what actually happens based on traditional statistics, this can reinforce existing inequalities in cycling. These findings indicate the potential for feedback loops~\cite{macmillan2017understanding} that can keep female-identifying riders from becoming cyclists. Therefore, future research should expand on this to understand how to better report about male and female cyclists and address any potential biases in media coverage. Policymakers and advertisers should also consider these differences when creating social media campaigns to promote cycling and encourage more people to use this mode of transportation.
\begin{figure}[t]
\centering
\includegraphics[width=.8\linewidth]{ch2.pdf}
\caption{The proportion of Not at Fault headlines in the Male and Female for bicyclists and motorcyclists. }
\label{fig:at-fault}
\end{figure}
Figure~\ref{fig:at-fault} shows that in accident-related headlines, the perception tends to be that male cyclists are less at fault compared to female cyclists (.36 vs .26). This may be due to stereotypes about female cyclists being more likely to be novel bike users. While for motorcycling, the proportion of headlines about male drivers not being at fault is lower than for female drivers (.32 vs .36). This could be influenced by differences in driving behavior between males and females with high-speed motorcycling. Female drivers may be more likely to drive at lower speeds and overtake more carefully, while male drivers may be more skilled, able to perform difficult maneuvers, and more likely to risk driving under the influence of alcohol~\cite{al2003role}.
\begin{comment}
\section{Design Implications}
Our framework provides new ways to study public perceptions of road traffic risks and safety, as well as any potential biases in media coverage of gender-specific accidents. Through this research, we may uncover any imbalances in the promotion of cycling among men and women. For example, by analyzing media coverage of gender-specific accidents, we may discover if certain groups, such as female-related accidents, are given more attention or are considered more newsworthy. If this is the case, it could lead to overreporting and reinforce women's perceptions of road risks, potentially reducing their interest in cycling in the future. This information could be valuable for policymakers and advertisers as they seek to create more balanced and accurate media coverage of cycling and promote this mode of transportation to all genders.
Furthermore, our proposed methodology offers a wide range of potential applications and research opportunities. This framework can be applied to different topics or news sources, such as social media, to assess public opinion at scale on specific events to support policymakers in making decisions about media strategy that aim to reduce disparities for minority groups.
Our headline framework is very important as it can detect the public perception at scale. In this work, we provides new ways to study public perceptions of road traffic risks and safety, as well as any potential biases in media coverage of gender-specific accidents. We study the ability of a Multi-Task Nural Network (MT RoBERTa) classifier to detect the . We also find that a classifier can be deployed to detect news headline in future social media, albeit with a drop in performance. We find that simple linguistic deatures perform best in this classifcation task, and that ... The results of our experiments show great promise in terms of frame detection。。。
Additionally, we believe the news headline frameworks are useful for predicting other topics of news.
The results of this work have implications for improving existing the public opinion prediction. For example, the policymaker can better understand the effect of online news on the public through our framework, they will be able to better collaborate with the local News Agencies to design... On the other hand, the results can be used...This article opens the doors for several areas of future work. First, designing classifiers that
ref: Identifying Framing Bias in Online News
\end{comment}
\subsubsection{Interesting Examples}
Several interesting examples appear within our dataset. For instance, sometimes, a new story is portrayed differently on various websites, even when discussing the same event. For example, the headline
\begin{quote}
\textbf{Example:} Pregnant Hit-and-Run Suspect Killed After Striking Motorcyclist, Getting Gun From Home: Cops
\end{quote}
describes an event where a person (A pregnant woman) was involved in a hit-and-run. However, it then jumps directly to the woman being killed and it is unclear who was getting the gun from home. Our annotators annotated this headline with ``Unknown'' as the cause of the accident. On the contrary, for the same event, the headline
\begin{quote}
\textbf{Example:} Florida librarian killed by motorcyclist after starting fight, police say
\end{quote}
describes the event completely differently, where it is unclear whether the librarian or motorcyclists started the fight. Our annotators ended up describing this event as being caused by the ``Motorcyclists''. Overall, the news story involved a woman who was involved in a hit-and-run. Bystanders and the person involved in the accident called the police and followed the woman home to wait for the police to arrive. The woman exited the house with a gun and was shot by the person who was originally hit by the woman. The person who was hit had a license for concealed carry. Overall, this example provides a useful test case for a better understanding of how slight differences (and sometimes confusing descriptions of an event) can impact how people perceive the headline/accident.
\section{Limitations and Ethical Considerations}
As we consider the potential future directions for our model, it's important to acknowledge several key limitations that must be addressed. One limitation is that our model only analyzes news headlines, which may not provide the full context of a story. The intent of a headline may differ from the intent of the corresponding article, particularly on social media. Headlines may be more ``click-bait'' optimized for improving click-through rate. Future work could also explore extending the analysis to short news articles, such as tweets, to provide a more comprehensive understanding of public perceptions.
Another limitation is that our English-centric model may not accurately reflect public perceptions in other languages and cultures. Additionally, our model is based on data annotated by annotators in the US, which could introduce cultural biases. These considerations highlight the need for caution when applying our model to real-world use cases. While our model offers a valuable starting point for understanding audience perceptions, it should not be viewed as a one-size-fits-all solution to this complex and multifaceted issue.
Finally, we focused on grammatical gender in cycling-related news headlines by analyzing the appearance of the pronouns. We did not use self-disclosed gender. The assumption of a binary conceptualization of gender, meaning that individuals are referred to as male or female, does not directly relate to all people. This is because the binary conceptualization of gender oversimplifies the complexity of gender identity and fails to adequately represent individuals who do not fit into the male or female category. For example, transgender cyclists may not be accurately identified using this method. We recognize the limitations of this approach and the importance of future approaches that can be developed to be more inclusive and equitable in understanding and addressing gender bias. By embracing the diversity of gender identity, we can create more ethical and inclusive NLP systems that better serve and support all cycling community members.
\section{Conclusion and Future Work}
In this paper, we make several contributions. First, we developed a new dataset with use cases in urban informatics to better understand how news headlines portray cyclists. Second, we introduced a novel multi-task learning framework that shows promise in a data-sparse setting. Our method was able to outperform several baselines showing its utility. Third, we comprehensively analyzed how cyclists are portrayed in the news compared to motorcyclists. We make several important findings. For example, general websites are much more likely to report accidents than cycling-specific websites. What is interesting, motorcycling-specific websites are unlikely to report accidents, which is much more common for cycling-specific sites. Yet, motorcycling is more likely to result in fatal injuries~\cite{factsmoto,factscycle}, which can impact perceived dangers. We also make important findings regarding reporting and the use of gender-specific pronouns. For instance, we find that there is only a slight difference in the proportion of gender-specific posts that report accidents between male- and female- pronoun mentioning posts (~20\% relative difference). Yet, the differences in accident rates are actually much higher (i.e., >700\% relative difference)~\cite{factscycle}, which can exaggerate the dangers of cycling for women and potentially limit the number of female cyclists.
In future work, we will explore temporal patterns of news framing of cyclists. Specifically, how have these patterns changed over time? Are news agencies becoming more ``positive'' or ``negative''? Moreover, it is important to analyze headlines geographically. Do specific regions differ in how the news portrays cyclists? Are these differences related to potential political differences between the regions? Overall, our dataset and models provide a path forward toward answering these questions. Unfortunately, the Google News API limited the amount of data we could collect for temporally and geographically-specific analysis. However, large-scale scraping procedures may provide a path forward. Overall, exploring urban informatics-related projects that can directly impact communities is important. Finally, we plan to explore how multi-label transformation-based auxiliary loss (for multi-task learning) improves model performance for other datasets. Moreover, we wish to evaluate them in a subsequent study because the method is generalizable to other architectures besides transformers.
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2023-01-18T02:14:51', 'yymm': '2301', 'arxiv_id': '2301.06178', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06178'} | arxiv |
\section{Introduction}
\label{sec:introduction}
On October 11, 2020, a special directive banning Special Anti-Robbery Squad (SARS) was issued via the Twitter handle\footnote{\url{https://twitter.com/NGRPresident/status/1315273093221318656}} of the Presidency Nigeria (see Figure~\ref{fig:SARS-ban}). The SARS is a special police unit under the Nigeria Police Force, responsible for fighting violent crimes such as robbery and kidnapping. The unit has been accused of various atrocities and human rights abuse including torture and murder across the nation. In a report compiled by Amnesty International, there are various cases of torture, ill-treatment extortion, and extrajudicial executions carried out by officers of the SARS \cite{amnesty-sars2020}. According to the report, between January 2017 and May 2020, 82 cases of police brutality have been committed. The tipping point of the protest is attributed to the period when a video of a man being killed went viral.
This and confounding allegations of police brutality led to an intense spate of protests against the activities of SARS. Despite the Presidential directive, the protest continues because the protesters view the details of the disbandment to be insufficient.
The dissatisfaction led to intense protests demanding reforms beyond SARS, but the Nigeria Police Force. As a result, there were many incidences of clashes between the police and protesters. The infamous Lekki bridge has been widely reported, especially online. Prior to these events, the protest has been ongoing on Twitter for a very long time. We were able to trace one of the earliest tweets about the movement (see Figure~\ref{fig:FirstENDSARSTweet}), and the hashtag \#EndSARS appears to be the trademark of the online protest to draw attention to human rights violations labelled against the SARS police unit. Many studies analysing the attitudes of the public towards the police have been published in the past \cite{brandl1994global,weitzer2004race,warren2011perceptions,kane2002social,mastrofski2002police}. Most of these studies preceded modern social networks such as Twitter\footnote{\url{https://twitter.com/}} and Facebook\footnote{\url{https://facebook.com/}}. With the arrival of online social networks, among other things, citizens are empowered to express and report their experiences with law enforcement officers. An earlier study reported how vicarious experiences result in negative perceptions about the police \cite{warren2011perceptions}. With online social networks, rich information about primary and secondary encounters with the police can be easily retrieved. This makes it easier to track public attitudes towards the activities of the police. Public dissatisfaction and demand for social justice often result in social movements with the potential of bringing drastic social reforms \cite{jones2013march}. Online platforms facilitate social activism that attracts the attention of diverse individuals. A case in point is the \#BlackLivesMatter online movement \cite{ince2017social,buggs2017dating,byrd2017vitality,haffner2019place} and the \#EndSARS protest \cite{ohia2020covid,uwazuruike2020endsars,ajisafe2021impacts,dambo2021office,ekoh2021role,iwuoha2022protests,aidonojie2022legality,dambo2022nigeria}.
While discourse about \#EndSARS has been ongoing on Twitter, it was the early October 2020 incidence of the police shooting that triggered public anger leading to the protest \cite{amaza2020}. Of interest to this study is to explore the following aspects in relation to the online protest:
\begin{enumerate}
\item \textit{How does the protest escalate and how engaging is the protest theme?} In this question, we are interested in studying activity trends during the \#EndSARS movement.
\item \textit{Who are the key online players during the \#EndSARS protest?} This question is geared towards identifying and characterising the influential stakeholders during the protest. Essentially, we are interested in determining whether the promoters of the protest reside within or outside the country (the diaspora community). It has been reported that the diaspora community is a strong player in this kind of movement \cite{olabode2016veterans,dambo2021office}. This study will focus on a different approach to offer a high-level categorisation of the users based on devices used to tweet about the protest and the location information.
\item \textit{Is the online protest purely about \#EndSARS?} This is crucial because, at some point, the protest has transformed from opposition to police brutality to a movement for social justice and government reforms.
\item \textit{What are the main themes in the protest and public perception about the movement?}
The goal of this question is to identify topical themes in the protest and how the online public responds to the protest.
\end{enumerate}
The remaining part of the paper is structured as follows. Section~\ref{sec:related-work} presents some related work and Section~\ref{sec:methodology} offers a detailed description of the data collection and preliminary analysis. Section~\ref{sec:result-and-discussion} offers the results and discussion and Section~\ref{sec:conclusion} concludes the study and discusses some future work.
\section{Related work}
\label{sec:related-work}
In this section, we provide some related studies within the areas of public attitudes towards police \cite{brandl1994global,weitzer2004race,warren2011perceptions,kane2002social,mastrofski2002police}, social activism \cite{miller2000geography,sewell2001space,mccaughey2003cyberactivism,jones2013march,graham2016content,ince2017social,buggs2017dating,haffner2019place}, and the \#EndSARS movement \cite{ohia2020covid,uwazuruike2020endsars,ajisafe2021impacts,dambo2021office,ekoh2021role,iwuoha2022protests,aidonojie2022legality,dambo2022nigeria}.
\subsection{Public Attitudes Towards Police}
There is mixed reaction and perception about the relationship between police and the public. The attitudes of citizens towards the police have been investigated long before online social media platforms. For instance, the work of \cite{brandl1994global} is focused on the satisfaction of the citizens towards the role of police in precipitating civil disorder. Many factors have been attributed to the tense relationship between police and the public. In the USA, race is considered to be one of the most salient predictors of attitudes towards the police with African Americans expressing more dissatisfaction than Whites \cite{warren2011perceptions}. Using survey data, the work of \cite{weitzer2004race} examines the public perceptions of misconduct, such as verbal abuse, excessive force, unwarranted stops, and corruption, involving police in the United States \cite{weitzer2005racially}.
In lower-class and high-crime communities, police officers were more likely to be verbally and physically abusive towards citizens \cite{kane2002social}. In another study, citizens who initiate disrespect towards the police were more likely to be treated disrespectfully by the police officer \cite{mastrofski2002police}. Vicarious experiences also result in negative perceptions about the police \cite{warren2011perceptions}. This could be a key player during the \#EndSARS protest since some of the protesters are angry because they have an indirect negative encounter with police brutality. Online social media platforms make it easier to track public perception or satisfaction with the activities of police and mobilise for social activism.
\subsection{Social Activism}
Social movements have been influential in framing and shaping social discourse by making it clearer for the affected individuals or communities to understand societal issues in a specific way \cite{miller2000geography,sewell2001space}. The quest for social movements have resulted in various societal reforms. For instance, the popular \textit{March on Washington} for jobs and freedom advocating for the civil and economic rights of African-Americans \cite{jones2013march}.
With the growing interconnectivity, social activism is becoming widespread on various online social media platforms. The challenges affecting marginalised communities and movements can be brought to the limelight by leveraging online social media platforms. Through the Twitter platform, the \#BlackLivesMatter movement has resulted in effecting change and injecting uniquely black concerns and perspectives into the national discourse \cite{graham2016content}. Past studies have explored various dimensions and impact of the \#BlackLivesMatter (or BLM) online movement \cite{ince2017social,buggs2017dating,byrd2017vitality,haffner2019place}. In the work of \cite{ince2017social}, the focus is on how social media users interact with the BLM movement and how online communities influence the framing of the movement. The authors found that the discourse is centred around solidarity or counter-movement sentiments towards the movement. The manifestation of the movement on Twitter has been studied in \cite{haffner2019place}. The BLM movement has been used by daters use to explain their responses to social justice movements around race and racism in the United States \cite{buggs2017dating}. Online activism tends to be effective via social media platforms because of the rate at which a large audience gets to be aware of the issue.
\subsubsection{Online Social Networks}
The Internet has been instrumental for research involving minority voices \cite{kennedy2006beyond}. By enabling interconnectivity among various devices, the Internet is one of the inventions that change the world \cite{warf2018sage}. The advancement in digital social networks has provided the opportunity for huge datasets to be used to examine the actions and behaviour of users at different levels. Access to online services or the Internet via smartphones and other digital devices makes it possible to present and amplify societal challenges that will rather go unnoticed. Data from social media platforms are quite popular for various research across domains \cite{miller2010data,haffner2018spatial}. With social media, the breadth of available data sources has expanded rapidly, making it possible to add more value to the traditional modes of generating and utilising research data. The suitability and relevance of data from Twitter have been assessed for biases inherent in social media usage in social research \cite{longley2015geotemporal}.
Today, a large proportion of the populace relies on social media for various purposes. For instance, according to \cite{sheet2018social}, around 7 out of 10 Americans use social media to connect, engage with news content, share information and entertain themselves. While young adults were among the earliest adopters, the social media user base is growing more representative of the broader population \cite{sheet2018social}.
Social networking sites gain the highest number of users around the world in which they provide their information, thoughts and opinions through various means, such as mobile phones, laptops, and tablets \cite{kumar2014twitter}. Social media platforms such as Twitter permit instantaneous conversation and participation at any time making them suitable for bringing societal issues to the surface. Such platforms have been instrumental in reshaping social discourse and movements by attracting diverse individuals to engage in direct or indirect communication. For research purposes, Twitter is useful in both organising and protesting. Users engage using various means - posting (tweeting), reposting or sharing (retweeting), liking, etc. A hashtag or group of hashtags are used to denote a topical discourse on Twitter. Such discourse may emanate from individuals or communities of users interested in promoting or expressing dissatisfaction. Similar to the \#ENDSARS protest, hashtags have been used to speak out against the activities of the police handling the SARS initiative.
\subsection{\#EndSARS-related Studies}
As noted earlier, in early October 2020, a video surfaced on social media of police officers struggling and the subsequent shooting of a young man. This incidence was identified to involve the SARS unit of the Nigeria Police Force\footnote{\url{https://www.npf.gov.ng/aboutus/History_Nigeria_Police.php}} and triggered a heightened spate of the \#EndSARS protest \cite{amaza2020}. Since the incident, many studies have been published around the protest theme \cite{ohia2020covid,uwazuruike2020endsars,ajisafe2021impacts,dambo2021office,ekoh2021role,iwuoha2022protests,aidonojie2022legality,dambo2022nigeria}. The circumstances that led to the emergence of the \#EndSARS protest, and the impact of the mass action on policing and law enforcement in Nigeria have been examined in \cite{ojedokun2021mass}. While the focus in \cite{ochi2021effect} is on how the protest affects the Nigerian economy, the work of \cite{aidonojie2022legality} is geared towards ascertaining the reasons behind the \#EndSARS protest in the hope of proffering some useful solutions. From the legal point of view, the work of \cite{iwuoha2022protests} examines how the police action (SARS unit) implicates Nigeria and the impact on democracy concerning civil and human rights. The study points to the lack of mutual trust between the government and the citizens. For online activism, Nigerians in the diaspora have played a crucial role in influencing social reforms \cite{olabode2016veterans}. This is in line with recent findings \cite{dambo2021office,abimbade2022millennial}. The online activities and characterisation of the protest have been examined to understand how the movement is promoted. The strategies used by the protesters include calling-out celebrities, unfollowing political leaders, sharing stories, fundraising and hacktivism \cite{abimbade2022millennial}. Also, the role of influencers within the movement has been analysed in a related study. It was found that users relied more on foreign media than local media for coverage while Nigerians in the diaspora promote information propagation about the protest \cite{dambo2021office}. The top 10 influencers are scored based on the connection of each user to disconnected users within the network structure \cite{dambo2021office}. This construct results in Nigeria’s president and Lagos state governor (and other media houses) being ranked high on the list. We focus on a different approach to identifying top influencers based on their online activity vis-a-vis the protest.
\section{Methodology}
\label{sec:methodology}
To answer the questions raised in Section~\ref{sec:introduction}, our approach is centred around the following (1) collecting \#EndSARS-related data from Twitter (2) performing a preliminary analysis of the data (3) identifying relevant stakeholders, performing trend, discourse and engagement analyses.
We describe these processes in this section.
\subsection{Data Collection}
This study utilises data from Twitter, which offers an essential mixture of diverse user groups that are suitable for research purposes. Through the platform's application programming interface (API), we developed a Python application to retrieve relevant tweets based on the terms in Table~\ref{tab:data-collection} for analysis. A \textit{tweet object} is a complex data object consisting of many descriptive fields that enables the extraction of various features related to a post on Twitter. With the aid of the API, numerous fields can be pulled out from the tweet object. Accordingly, we leverage the API to retrieve both historical and live tweets related to the \#EndSARS protest from 2017 to 2021. Table~\ref{tab:data-collection} shows a summary of the terms used for collection. In line with Twitter's regulation\footnote{\url{https://developer.twitter.com/en/developer-terms/display-requirements}}, we ensured that best practices have been followed in collecting and using the data for our research purposes. Table~\ref{tab:data-summary} shows basic statistics about the collected data.
\begin{table}[t]
\small
\caption{Hashtags used in collecting the research data from Twitter}
\label{tab:data-collection}
\begin{tabular}{p{2.15cm} p{11cm}}
\hline
\textbf{Tweets} & \textit{based on keywords and hashtags related to the protest} \\
\textbf{Description} & collection of \#EndSARS-related tweets via Twitter's API \\
\textbf{Hashtags} &
\#EndSARS (using a variation of the hashtag), police brutality, stop the killing, Nigeria Police, SARS Nigeria,
Lekki bridge,\#endpolicebrutality \\ \hline
\end{tabular}
\end{table}
\subsection{Preliminary Analysis}
Because the data collection was conducted over time, we performed some longitudinal and exploratory analyses to explore the data.
\begin{table}[t
\footnotesize
\caption{A summary of basic statistics in the collected datasets.}
\label{tab:data-summary}
\begin{tabular}{l>{\raggedright}p{3.0cm}cclp{3cm}} \hline
& Data Kind & Size & Mean Values& Description \\ \hline
\multirow{4}{*}{\rotatebox{90}{\textbf{Dataset}}}
& Raw Tweets & 3550 & 23 & average number of tokens in the tweet \\
& Retweeted Tweets & 3422 & 463 & average retweet count \\
& Replied Tweets & 1317 & 0.3 & average replies in the collection \\
& Quoted Tweets & 1107 & 0.14 & average number of quoted tweets \\ \hline
\hline
\end{tabular}
\normalsize
\end{table}
\subsubsection{Activity Trend}
The collection period covers 2017-2021, which corresponds to the period when discussion about the protest theme started. In Figure~\ref{fig:relevant-tweets-about-sars}, sub-figure~\ref{fig:FirstENDSARSTweet} appeared to be one of the earliest tweets to bring the SARS issue for open discussion on Twitter. During the early days of the protest, there were a handful of users discussing the issue. However, as the issue is debated over time, the engagement flared up, especially during the height of the protest (2020 - 2021), which coincides with a period when a video about a police shooting went viral on social media platforms.
Figure~\ref{fig:tweetovertime} depicts how the online discourse on \#EndSARS varies over time. Sub-figures \ref{fig:2012-2019-TRates} to \ref{fig:2021-TRates} depict the rate of tweet generation over time. The spike in sub-figure \ref{fig:2012-2019-TRates} coincides with the shooting incident alluded to earlier (see Figure~\ref{fig:police-shooting}). Sometime in 2020, news about the alleged killing by SARS officers was shared on social media platforms, and the incidence is attributed to the observed peak in Figure~\ref{fig:2020A-TRates}. However, the veracity of the information was denied by the Government and the individual responsible was apprehended.
Moreover, the spikes in activity in Figure~\ref{fig:2012-2019-TRates} can be attributed to self-reported encounters with the police or related traumatic experiences with the SARS officers. As time passed by, the protest recorded low online participation between January to August 2021. As shown in Figure~\ref{fig:2021-TRates}, towards the end of the same year numerous protesters increased tweeting in memory of the October 2020 incident and protest-related themes.
\begin{figure}[!ht
\centering
\begin{subfigure}[t]{.4\textwidth}
\subcaption{2012 - 2019 Period}
\centering
\includegraphics[width=\textwidth]{figures/Tweets2012-2019.pdf}
\label{fig:2012-2019-TRates}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.4\textwidth}
\centering
\subcaption{January to June 2020}
\includegraphics[width=\textwidth]{figures/January-June-2020.pdf}
\label{fig:2020A-TRates}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.4\textwidth}
\centering
\subcaption{July to December 2020}
\includegraphics[width=\textwidth]{figures/July-December-2020.pdf}
\label{fig:2020B-TRates}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.5\textwidth}
\centering
\subcaption{Year 2021} \includegraphics[width=\textwidth]{figures/Tweets2021.pdf}
\label{fig:2021-TRates}
\end{subfigure}
\caption{Frequency of tweets related to the protest from 2017-2022 showing (a) the beginning of the protest discussion on Twitter covering 2012-2019; the spike in activity can be observed towards the end of 2017 (b) tweets about the \#EndSARS protest that were generated in 2020; and (c) tweets about the \#EndSARS protest covering 2021 to early 2022. The sub-figure (d) shows the devices mostly used by the users discussing the protest themes on Twitter.}
\label{fig:tweetovertime}
\end{figure}
\paragraph{Offline Protest}
The \#EndSARS protest happened concurrently both in offline and online modes. From Figure~\ref{fig:tweetovertime} it can be observed that since the first mention of the protest theme in 2017, the activity trend has been decreasing until late 2020 when the tragic shooting incident involving SARS officers that led to the loss of life \footnote{\url{https://www.aljazeera.com/news/2020/10/22/timeline-on-nigeria-unrest}} happened. This led to a wider protest across the country. Figure~\ref{fig:map} depicts the proportion of the \#EndSARS protest according to the 36 states in Nigeria, including the Federal Capital Territory (FCT) Abuja. It can be observed from the Figure that the most active promoters of the online protest are confined to a few locations, notably Lagos and Abuja. As the protest keeps raging, it draws the attention of various national and international stakeholders. Thousands of Nigerians across the nation, especially in Lagos and Abuja, poured onto the streets protesting over the activities of the SARS unit. This led to another encounter with the police leading to some organisations expressing concerns over the handling of the incident. For instance, Amnesty International (AI-Nigeria) cautioned the authorities over the handling of the incidence (see sub-figure \ref{fig:amnesty}). Moreover, both the African Union Commission chairman and the UN High Commissioner for Human Rights have called for normalcy to be restored.
\section{Result and Discussion}
\label{sec:result-and-discussion}
In this section, we present relevant results and discussions about the main findings of the research.
\subsection{Stakeholders in the online activism}
Twitter offers unique features to understand when and where an event (tweet) happened.
The dataset we examined in this study contains information about the user's location, including the sources or devices used by the online protesters.
Although we can not ascertain the reliability of the user's reported data due to inaccuracies or false information provided by users, the objective is to analyse how the location and device information can be leveraged to understand the stakeholders involved in the online protest. Of interest is to understand the role of national and international (the diaspora community) in the protest.
\paragraph{Location} information about the users can inform whether the influential stakeholders in the protest are residents or overseas.
We acknowledge that the location feature on Twitter may not be an accurate indicator of the location, but will be useful in shading some insights and informing the analysis.
As mentioned earlier, Figure~\ref{fig:map} illustrates the level of participation in the protest across the 36 states, including the Federal Capital Territory (FCT Abuja), of the federation. The protest is more prominent in Lagos 61.5\%, FCT Abuja 7.11\%, Oyo 3.6\%, Delta 1.42\%, Ondo 1.17\%, and Rivers 1.17\% states.
Thus, the high percentage of participation from Lagos state is in line with media report of Lagos being the hub of the \#EndSARS protest\footnote{\url{https://www.washingtonpost.com/outlook/2020/10/25/roots-endsars-protests-nigeria/},}\footnote{\url{https://www.aljazeera.com/news/2020/10/22/timeline-on-nigeria-unrest}}. As seen in Figure~\ref{fig:world-map}, the diaspora community was quite active during the online protest.
\begin{figure}[!ht]
\centering{
\includegraphics[width=1.0\linewidth,height=10cm]{figures/EndSARSMap.jpg}
\caption{Proportion of the \#EndSARS online protest across the 36 states in Nigeria, including the FCT, Abuja.}
\label{fig:map}
}
\end{figure}
\begin{figure}[!ht]
\centering{
\includegraphics[width=.7\linewidth,height=8cm]{figures/W-MapAnalysis.png}
\caption{Proportion of the \#EndSARS online protest across the globe. There is a high proportion of engagement with the protest themes in the United States of America, United Kingdom and Canada. We can see some moderate engagements from South Africa, Ghana, Uganda, Liberia, Paraguay, Saudi Arabia, India, China, Indonesia, Malaysia, Cambodia, Turkey, and most of Western Europe Countries.
\label{fig:world-map}
}
\end{figure}
\paragraph{Device}
The type of device used by a user could reveal how mobile the user is. We could infer how individuals roam from one point to another to join in online protests. Suppose the device type is \textit{desktop} computer, then the user will be considered not mobile, and could point to an organisation with dedicated personnel to keep the online protest alive. Because there are numerous devices used by users in the data collection, we place the devices into 3 broad clusters consisting of third-party sources 2\%, mobile devices 88\%, and Twitter for web apps 10\%, see Figure~\ref{fig:devicesUsed}. The high proportion of mobile devices is suggestive of high mobility among the protesters and enables them to simultaneously participate in both offline and online protests.
\subsection{Protest Themes and Public Perception}
\paragraph{Protest Themes}
It is vital to understand the kind of topics associated with the \#EndSARS protest on Twitter. To achieve that, we perform topic modelling on the content of the raw tweets (see Table~\ref{tab:data-summary}) using the Latent Dirichlet Allocation (LDA) algorithm~\cite{blei2003latent} and the Continuous Dirichlet Allocation (CLDA) algorithm ~\cite{wang2012continuous} for a better understanding of the topics in the data. Before proceeding with the topic analysis, the tweets collection is subjected to a cleaning process to get rid of unwanted content often associated with data from Twitter \cite{inuwa2018detection}. The preprocessing step involves tokenisation, stopwords removal and text formatting. For normalisation, we remove \textit{urls, user mentions, emojis} from the collection. Figure~\ref{fig:Topics1} shows some of the relevant topics obtained from applying the LDA algorithm. For readability and ease of interpretation, we decompose the data into eight (8) different segments. For each segment, we limit our analysis to the ten (10) top topics to understand the meaning and context of the discussion topics. Figures~\ref{fig:Topics1} and ~\ref{fig:Topics2} show the respective topics under each segment.
\begin{figure}[tbh]
\centering{
\includegraphics[width=\linewidth,height=10cm]{figures/Topic_Analysis1.pdf}
\caption{An overview of the main topical issues related to the protest from 2017 to March 2021. From 2017 to early 2020 the discussion topics are centred around the brutality of the SARS and advocating for support to the \#EndSARS campaign.}
\label{fig:Topics1}
}
\end{figure}
\begin{figure}[tbh]
\centering{
\includegraphics[width=\linewidth,height=10cm]{figures/Topic_Analysis2.pdf}
\caption{An overview of the main topical issues related to protest from April 2021 to December 2021. This period witnessed a high volume of activity and discussion about the protest. During this period, there is an inclusion of political movements intertwined with the protest theme.}
\label{fig:Topics2}
}
\end{figure}
\paragraph{Public Perception}
Alongside the topical analysis, we are interested in knowing the nature or sentiment expressed in the online discourse on \#EndSARS. To accomplish that, we identify the most prominent topics during the period and pull out the associated tweets from our collection to analyse the sentiments or public perception of the protest's themes. To understand the intensity or polarity of the public opinions about the protest, we leverage the off-the-shelf VARDER~\cite{hutto2014vader} tool\footnote{a sentiment analysis tool for determining the sentiment associated with social media texts} to obtain the sentiment (as positive, neutral or negative) of each tweet. Figure~\ref{fig:TopicsSentiment} shows the result of the sentiment analysis consisting of positive and negative tweets about the movement. The negative tweets are mainly expressing the brutal actions of the SARS police while the positive tweets are mostly associated with rallying support for the \#EndSARS campaign. According to Figure~\ref{fig:TopicsSentiment}, the intensity of the negative sentiment in 2017-2018 is the highest. Noting how people tend to respond quicker to negative emotion~\cite{landmann2020being,bessi2016social}, this could be suggestive of using some emotional narratives or negative sentiment to generate some momentum and attract public attention towards the campaign.
\begin{figure}[tbh]
\centering{
\includegraphics[width=0.6\linewidth,height=7cm]{figures/meanSentiment.pdf}
\caption{The polarity of sentiment associated with the \#EndSARS topics from 2017 to 2021. While the positive sentiment is mostly associated with tweets garnering public support for the movement, the negative sentiment is mainly about dissatisfaction with the activities of the SARS unit.}
\label{fig:TopicsSentiment}
}
\end{figure}
\subsection{Engagement Analysis}
There are many ways to examine how users engage with each other on Twitter. What constitutes engagement and how to measure it on Twitter has been analysed in previous studies \cite{inuwa2018effect,inuwa2018lexical}.
We can capture engagement levels depending on how often a given account performs the actions of retweeting (RT), tweet liking (favourite count), replying and user mention. In this study, we focus on measuring engagement intensity concerning online activities such as the frequency of tweet generation, retweets, and replies. For the engagement analysis, we categorise an account holder as influential if the user has tweeted or posted at least 10 tweets about the \#EndSARS protest. This is to limit the number of irrelevant or insufficient tweets. Figures~\ref{fig:engagement-retweets} and ~\ref{fig:engagement-replies} show the highest engaging users based on relative retweet and reply actions. Figures~\ref{fig:engagement-tweets} show the tweet count of the most active users in the overall data collection and the collection with the highest engagement with the protest's themes. The figures also point to the possibility of using social bots to promote the online movement noting the explicit 'bot' usage in the account name. The accounts with the highest engagement with the protest themes are not influential in the literal sense of being a celebrity or known influential user. For instance, one of the most active accounts in terms of retweeting action is the \textit{@endsarsbot\_} that retweeted 429 tweets from 2021-07-31 to 2021-12-27. The main task of the account is limited to retweeting and calling out to some Twitter users as a way of attracting attention and promoting the protest. Another active account is the \textit{@psarmmiey} with 105 retweets from 2021-07-31 to 2021-12-27. Interestingly, the activity period of both \textit{@endsarsbot\_} and \textit{@psarmiey} are the same (from 2021-07-31 to 2021-12-27) and their action is limited to retweeting as a strategy to mobilise for the protest. Similarly, the \textit{@TheEndSarsBot} retweeted 38 tweets from 2021-11-30 to 2021-12-27.
\begin{figure}[tbh
\centering{
\includegraphics[width=1.0\linewidth,height=7cm]{figures/mean-values-of-accounts-engagements-by-retweets.png}
\caption{The level of engagement according to (a) accounts with the highest relative retweeting action in the overall collection (b) relative retweets in accounts with the highest engagement with the protest themes.}
\label{fig:engagement-retweets}
}
\end{figure}
\begin{figure}[tbh
\centering{
\includegraphics[width=1.0\linewidth,height=7cm]{figures/mean-values-of-accounts-engagements-by-replies.png}
\caption{The level of engagement according to (a) accounts with the highest relative replying action in the overall collection (b) relative replies in accounts with the highest engagement with the protest themes.}
\label{fig:engagement-replies}
}
\end{figure}
\subsection{From \#EndSARS to Demand for Change}
In addition to the themes and public perception of the protest, it is crucial to determine whether the protest is purely driven by the need to end the SARS unit or not. Through the topic modelling, we were able to identify relevant tweets from the collected data based on the detected themes, see Figure~\ref{fig:Topics2}. This is required in order to make sense of the topics in detail.
According to Figures~\ref{fig:Topics1} and ~\ref{fig:Topics2}, it appears that from 2017-2018, the major topics were geared towards generating some momentum for the \#EndSARS movement. Some examples during this period include:
\begin{itemize}
\item[-] \textbf{'extortion continue'}
\begin{itemize}
\item \textit{"This kind of extortion has to end, we will continue to demand \#ENDSARS. Kindly retweet so people would be aware of the kind of atrocity committed by @PoliceNG"}
\end{itemize}
\item[-] \textbf{'sure alot'}
\begin{itemize}
\item \textit{" ....kindly RT this to advice/warn our guys to be careful tonight as I am sure alot of SARs will be on the road tonight."}
\end{itemize}
\item[-] \textbf{'OAPs use'}
\begin{itemize}
\item \textit{"I will implore our OAPs to use their position to enlighten the public and not deceive them on the SARS matter. There is nothing to be politically correct about in a life and death matter. It is the same common man’s kids that is endangered. \#EndSARS.}
\end{itemize}
\end{itemize}
The last topic (\textit{'OPAs use'}), relates to the tweets calling for 'On-air Personalities (OAPs)' to support and enlighten the public about the activities of the SARS unit. Other online topical issues during the protest period include \textit{police force} and \textit{police brutality} calling for the reform of the Nigeria Police Force, which is attributed to the \textit{ Lekki toll gate} in Lagos incidence that resulted in the loss of lives and casualties in an attempt by the police to disperse protesters\footnote{https://www.bbc.co.uk/news/world-africa-59300011}.
Although the majority of the online discourse on the protest is on ending the SARS unit, we observe the emergence of different themes concerning the hashtags used and the associated content. These hashtags are about social reforms and questioning the style of governance. An example of such hashtags with a political undertone is the \textit{\#endbadgovernanceinnigeria} alluding to regime change (see Figure~\ref{fig:hashtags-calling-for-change}). This and similar hashtags have surfaced alongside the protest theme on Twitter. Also, there exists hashtags and related tweets accusing the
government in power of supporting \textit{boko haram}, and demanding for the president to resign. Overall, the \#EndSARS discussions in 2021 seem to revolve around the demand for justice for the protesters, ending bad governance and change of government.
\section{Conclusion}
\label{sec:conclusion}
The Special Anti-Robbery Squad (SARS) is a special police unit under the Nigeria Police Force tasked with the responsibility of fighting violent crimes. Over the years, the unit has been accused of various human rights abuse across the nation leading to one of the major protests in the country. Due to the demographics of the protesters, the protest was quite popular on various online social networks. Using the popular \textit{\#EndSARS} hashtag on Twitter to draw attention to human rights violations labelled against the SARS unit, the protest received huge attention within and outside the country. In this study, we critically examined the evolution of the protest on Twitter, the nature of engagement with the protest themes, the factors influencing the protest and public perceptions about the online movement.
We have examined how social media users interact with the \#EndSARS movement and how online communities respond to the protest. Based on examining public perception, we found that the \#EndSARS-related hashtags have been used to report ill-treatment by the SARS unit and to rally support for the protest. Needless to say, the themes in the online discourse are heavily on ending SARS and vicarious experience, however, there are topics around reforming the police and demand for regime change. Injecting a political undertone could lead to setbacks in social activism as it will likely deviate from the main objective of the movement or provoke counter protest.
In line with previous findings \cite{abimbade2022millennial}, the following mobilisation strategies of calling-out celebrities, and sharing direct stories and vicarious experiences have been used to promote the protest. Based on the explicit 'bot' suffix, there is some evidence that suggests the use of automated accounts to promote the course of the protest.
Through location and device analysis, we studied the degree of participation in the protest and how the protesters engage with the \#EndSARS themes. Over 70\% of the protest is confined within a few states in Nigeria. The diaspora communities also lent their voices to the issue. The most active users are not those with high followership. The majority of the protesters utilised mobile devices, accounting for 88\% to mobilise and report on the protest. Our future study will explore the possibility of mapping out how the online protest translated into physical violence or confrontation. Also, we will examine how information, including misinformation, propagates within the network of the protesters.
\newpage
| {'timestamp': '2023-01-18T02:14:46', 'yymm': '2301', 'arxiv_id': '2301.06176', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06176'} | arxiv |
\section{Introduction}\label{sec:intro}
Iteration is fundamental in many areas of computer science, such as semantics,
verification, theorem proving, automata theory, formal languages, computability theory,
compiler optimisation, etc. An early effort to identifying a generic notion of iteration
is due to Elgot~\cite{Elgot75}, who proposed to consider an algebraic theory induced
by a notion of abstract machine (motivated by \emph{Turing machines}, and their
variants) and regard iteration as an operator over this algebraic theory.
Roughly speaking, an algebraic theory carries composable spaces of
morphisms~$L(n,m)$, indexed by natural numbers $n$ and $m$ and including
all functions from $n$ to $m$\footnote{Here we
identify numbers $n\in\mathbb{N}$ with finite ordinals $\{0,\ldots,n-1\}$.}, called \emph{base morphisms}.
For example, following Elgot, one can consider as $L(n,m)$ the
space of all functions $n\times S\to m\times S$ representing transitions from a
machine state ranging over $n$ to a machine state ranging over~$m$, and updating the background store
over $S$ (e.g.\ with $S$ being the Turing tape) in the meanwhile. In modern speech, $L(n,m)$ is
essentially the space of Kleisli morphisms $n\to Tm$ of the \emph{state monad} $T=(\argument\times S)^S$.
Then a machine over $m$ halting states and $n$ non-halting states is represented
by a morphism in $L(n,{m+n})$, and the iteration operator is meant to compute
a morphism in~$L(n,m)$, representing a run of the machine, obtained by feedbacking
all non-halting states. This perspective has been extensively
elaborated by Bloom and Esik~\cite{BloomEsik93} who identified the ultimate equational
theory of Elgot iteration together with plenty other examples of algebraic theories
induced by existing semantic models, for which the theory turned out to be sound
and complete.
By replacing natural numbers with arbitrary objects of a category
with finite coproducts and by moving from purely equational to a closely related and practically appealing quasi-equational
theory of iteration, one arrives at \emph{(complete) Elgot monads}~\cite{AdamekMiliusEtAl10,GoncharovRauchEtAl15},
which are monads $T$, equipped with an iteration operator
\begin{align}\label{eq:elg-iter}\tag{$\istar$}
\lrule{}{f\c X\to T(Y+X)}{f^\istar\c X\to TY}
\end{align}
In view of the connection between computational effects and monads, pioneered by
Moggi~\cite{Moggi91}, Elgot monads provide arguably the most general model of
iteration w.r.t.\ functions carrying computational effects, such as mutable store,
non-determinism, probability, exceptional and abnormal termination, input-output
actions of process algebra. The standard way of semantics via \emph{domain theory}
yields a general (least) fixpoint operator, which sidelines Elgot iteration and
overshadows its fundamental role. This becomes visible again when it comes to
the cases when the standard scenario cannot be applied or is difficult to
apply, e.g.\ in constructive setting~\cite{Goncharov21}, for deterministic hybrid system
semantics~\cite{GoncharovJakobEtAl18}, infinite trace semantics~\cite{LevyGoncharov19}, in the context of automatic differentiation~\cite{Vakar20},~etc.
In contrast to Elgot iteration, \emph{Kleene iteration}, manifested by \emph{Kleene
algebra}, is rooted in logic and automata theory~\cite{Kleene56}, and crucially relies on
non-determinism. The laws of Kleene algebra are from the outset determined by a rather
conservative observation model, describing discrete events, coming one after another
in linear order and in finite quantities. Nevertheless,
Kleene algebra and thus Kleene iteration proved to be extremely successful (especially
after the celebrated complete algebraic axiomatization of Kleene algebra by Kozen~\cite{Kozen94})
and have been accommodated in various formalizations and verification frameworks from those
for concurrency~\cite{HoareMollerEtAl09} to those for modelling hybrid
systems~\cite{Platzer08}. A significant competitive advantage of Kleene iteration is
that it needs no (even very rudimental) type grammar for governing well-definedness
of syntactic constructs, although this cannot be avoided when extending Kleene
algebra with standard programming features~\cite{Kozen02,Aboul-HosnKozen06,KozenMamouras13}.
Semantically, just as Elgot iteration, Kleene iteration can be reconciled with
computational effects, leading to \emph{Kleene monads}~\cite{Goncharov10}, which
postulate Kleene iteration with the type profile:
\begin{align}\label{eq:kle-iter}\tag{$\rstar$}
\lrule{}{f\c X\to TX}{f^\rstar\c X\to TX}
\end{align}
Given $f$, $f^\rstar$ self-composes it non-deterministically indefinitely many times.
In contrast to Elgot monads, the stock of computational effects modelled by
Kleene monads is rather limited, which is due to the fact that many computational
effects are subject to laws, which contradict the Kleene algebra laws. For a simple
example, consider the computational effect of exception raising, constrained by the
law, stating that postcomposing an exception raising program by another program
is ineffective. Together with the Kleene algebra laws, we obtain a havoc:
\begin{align*}
\oname{raise} e_1 = \oname{raise} e_1;\ \bot = \bot = \oname{raise} e_2;\ \bot = \oname{raise} e_2,
\end{align*}
where $\bot$ is the unit of non-deterministic choice.
This and similar issues led to a number of proposals to weaken Kleene
algebra laws~\cite{FokkinkZantema94,Moller07,McIverRabehajaEtAl11,GomesMadeiraEtAl17}
(potentially leading to other classes of monads, somewhere between Elgot and Kleene), although
not attempting to identify the weakest set of such laws from the foundational
perspective. At the same time, it seems undebatable that Kleene iteration and
the Kleene algebra laws yield the most restricted notion of iteration.
We thus obtain a spectrum of potential notions of iteration between Elgot monads and Kleene monads.
The goal of the present work is, on the one hand to explore this spectrum,
and on the other hand to contribute into closing the conceptual gap between Kleene iteration
and Elgot iteration. To that end, we introduce \emph{while-monads}, which capture
iteration in the conventional form of while-loops, and show that while-monads
are essentially equivalent to Elgot monads.
\section{Preliminaries}\label{sec:prelim}
We rely on rudimentary notions and facts of category theory, as used in semantics, most
notably \emph{monads}~\cite{Awodey10}. %
For a (locally small) category $\BC$ we denote by~$|\BC|$ the class of its objects and
by~$\BC(X,Y)$ the set of morphisms from $X\in |\BC|$ to~$Y\in|\BC|$. We often omit
indices at components of natural transformations to avoid clutter.~$\catname{Set}$ will
denote the category of classical sets and functions, i.e.\ sets and functions
formalized in a classical logic with the law of excluded middle (we will make no use of the axiom of choice).
By $\brks{f,g}\c X\to Y\times Z$ we will denote the \emph{pairing} of two morphisms $f\c X\to Y$
and $g\c X\to Z$ (in a category with binary products), and dually, by $[f,g]\c X+Y\to Z$
we will denote the \emph{copairing} of $f\c X\to Z$ and $g\c Y\to Z$ (in a category with
binary coproducts). By $\bang\c X\to 1$ we will denote initial morphisms (if $1$ is
an initial object).
An ($F$-)algebra for an endofunctor $F\c\BC\to\BC$ is a pair $(A,a\c FA\to A)$.
Algebras form a category under the following notion of morphism: $f\c A\to B$
if a morphism from $(A,a)$ to $(B,b)$ if $b f = (Ff)a$. The \emph{initial algebra}
is an initial object of this category (which may or may not exit). We denote this
object~$(\mu F,\ins)$. ($F$-)coalgebras are defined dually as pairs of the form
$(A\comma a\c {A\to FA})$. The final coalgebra will be denoted~$(\nu F\comma\out)$.
By Lambek's Lemma~\cite{Lambek68}, both $\ins$ and $\out$ are isomorphism, and we
commonly make use of their inverses $\ins^\mone$ and $\tuo$.
\section{Monads for Computation}\label{sec:mona}
We work with monads represented by \emph{Kleisli triples} $(T,\eta,(\argument)^\klstar)$ where~$T$ is
a map~$|\BC|\to |\BC|$, $\eta$ is the family $(\eta_X\c X\to TX)_{X\in |\BC|}$ and
$(\argument)^\klstar$ sends $f\c X\to TY$ to $f^\klstar\c TX\to TY$ in such a way that
the standard \emph{monad laws}
\begin{align*}
\eta^{\klstar}=\id, &&
f^{\klstar}\eta=f, &&
(f^{\klstar} g)^{\klstar}=f^{\klstar}g^{\klstar} %
\end{align*}
hold true. It is then provable that $T$ extends to a
functor with $Tf = (\eta f)^\klstar$ and~$\eta$ to a \emph{unit} natural transformation.
Additionally, we can define the \emph{multiplication} natural transformation $\mu\c TT\to T$
with $\mu_X = \id^\klstar$
(thus extending $T$ to a monoid in the category of endufunctors).
We preferably use bold letters, e.g.~$\BBT$, for monads, to contrast with
the underlying functor $T$. The axioms of monads entail that the morphisms of the
form $X\to TY$ determine a category, called \emph{Kleisli category}, and denoted $\BC_{\BBT}$,
under \emph{Kleisli composition} $f\cdot g = f^\klstar g$ with~$\eta$ as the
identity morphism. Intuitively, Kleisli category is the category of (generalized)
effectful programs w.r.t.\ $\BC$ as the category of ``pure'', or effectless, programs.
We thus use diagrammatic composition $g;f$ alongside and equivalently to functional
composition $f\cdot g$, as the former fits with the sequential composition operators of
traditional programming languages.
A monad $\BBT$ is \emph{strong} if it comes with
a natural transformation $\tau_{X,Y}\c X\times TY\to T(X\times Y)$ called \emph{strength}
and satisfying a number of coherence conditions~\cite{Moggi91}. Any monad on $\catname{Set}$
is canonically strong~\cite{Kock72}.
\begin{example}[Monads]\label{exa:mon}
Recall some computationally relevant monads on~$\catname{Set}$ %
(all monads on $\catname{Set}$ are strong \cite{Moggi91}).
\begin{enumerate}[wide]
\item\label{it:may} \emph{Maybe-monad}: $TX = X + 1$, $\eta(x) = \inl x$, $f^\klstar(\inl x) = f(x)$,
${f^\klstar(\inr\star) = \inr\star}$.
\item\label{it:pow}\emph{Powerset monad}: $TX = \PSet X$, $\eta(x) = \{x\}$, $f(S\subseteq X) = \{y\in f(x)\mid x\in S\}$.
\item\label{it:plo} $TX = \{S\mid S\in\PSet^\mplus (X + 1), \text{if $S$ is infinite then~} \inr\star\in S\}$ where $\PSet^\mplus$ is the non-empty powerset functor,
${\eta(x) = \{\inl x\}}$, $f^\klstar(S\subseteq X) = \{y\in f(x)\mid{\inl x\in S}\}\cup(\{\inr\star\}\cap S)$.
\item\label{it:exc}\emph{Exception monad}: $TX=X+E$ where $E$ is a fixed (unstructured) non-empty
set of exceptions, $\eta(x) = \inl x$, $f^\klstar(\inl x) = f(x)$, ${f^\klstar(\inr e) = \inr e}$.
\item\label{it:wri}\emph{Non-deterministic writer monad}: $TX = \PSet(M\times X)$
where~$(M\comma\eps\comma\bullet)$ is any monoid, $\eta(x) = \{(e,x)\}$,
$f^\klstar(S\subseteq M\times X) = \{(n\bullet m,y) \mid (m,x)\in S\comma
(n,y)\in f(x)\}$.
\item\label{it:dis}\emph{Discrete sub-distribution monad}: $TX = {\{d\c
[0,1]\to X\mid\sum_{x\in X} d(x)\leq 1\}}$ (the \emph{supports} of $d$,
$\{x\in X\mid d(x)>0\}$ are necessarily countable -- otherwise the sum~$\sum_{x\in X} d(x)$ would
diverge), $\eta(x)$ is the \emph{Dirac distribution} $\delta_x$, centred
in~$x$, i.e.\ $\delta_x(y) = 1$ if $x=y$, $\delta_x(y) = 0$ otherwise, $({f\c
X\to\mathcal{D} Y)^\klstar}(d)(y)={\sum_{x\in X} f(x)(y)\cdot d(x)}$.
%
\item%
\emph{Partial state monad:}\label{it:sta}
$TX=(X\times S+1)^S$, where $S$ is a fixed set of global states, $\eta(x)(s) = \inl(x,s)$,
$f^\klstar(g\c S\to X\times S+1)(s) = \inr\star$ if $g(s) = \inr\star$
and $f^\klstar(g\c S\to Y\times S+1)(s) = f(x)(s')$ if $g(s) = \inl(x,s')$.
\item\emph{Partial interactive input:}\label{it:in}
$TX=\nu\gamma.\,((X+\gamma^I)+1)$, where $I$ is a set of input values, $\eta(x) = \tuo(\inl\inl x)$,
$(f\c X\to TY)^\klstar$ is the unique such morphism $f^\klstar\c TX\to TY$ that (eliding
the isomorphisms $T\iso (\argument+T^I)+1$)
\begin{align*}
f^\klstar(\inl\inl x) =\;& f(x),&
f^\klstar(\inl\inr h) =\;& \inl\inr (f^\klstar\comp h),&
f^\klstar(\inr\star) =\;& \inr\star.&
\end{align*}
Intuitively, $p\in TX$ is a computation that either finishes and gives a result
in $X$, or takes an input from $I$ and continues recursively, or (unproductively)
diverges.
\item\emph{Partial interactive output:}\label{it:out}
$TX=\nu\gamma.\,((X+\gamma\times O)+1)$, where $O$ is a set of output values,
$\eta(x) = \tuo(\inl\inl x)$, $(f\c X\to TY)^\klstar$ is the unique such morphism $f^\klstar\c TX\to TY$ that (eliding
the isomorphisms $T\iso (\argument+T\times O)+1$)
\begin{align*}
f^\klstar(\inl\inl x) =\;& f(x),&
f^\klstar(\inl\inr (p,o)) =\;& \inl\inr (f^\klstar(p),o),&
f^\klstar(\inr\star) =\;& \inr\star.&
\end{align*}
The behaviour of $p\in TX$ is as in the previous case, except that it outputs
to $O$ instead of expecting an input from $I$ in the relevant branch.
\end{enumerate}
Kleisli categories are often equivalent to categories with more familiar independent
descriptions. For example, the Kleisli category of the maybe-monad
is equivalent to the category of partial functions and the Kleisli category of the
powerset monad is equivalent to the category of relations. Under the monads-as-effects
metaphor, partial functions can thus be regarded as possibly non-terminating
functions and relations as non-deterministic functions.
The above examples can often be combined. E.g.\ non-deterministic stateful
computations are obtained as $TA=S\to\PSet(A\times S)$.
The Java monad of~\cite{JacobsPoll03},
\begin{displaymath}
TX=S\to (X\times S + E\times S)+1
\end{displaymath}
with $S$ the set of states and $E$ the set of exceptions.
\end{example}
\section{Kleene Monads}\label{sec:klee} %
\begin{figure*}[t]
\begin{flalign*}
\intertext{\itshape Idempotent semiring laws:}\\[-2ex]
\hspace{4em}&\textit{idempotence:} &\qquad& f\lor f = f&\\
\quad&\textit{commutativity:} && f\lor g = g\lor f &\\
\quad&\textit{neutrality of $\bot$:} && f\lor\bot = f &\\
&\textit{associativity of $\lor$:} && f\lor (g\lor h) = (f\lor g)\lor h &\\
&\textit{associativity of $;$~:} && f; (g; h) = (f; g); h &
\\[2ex]
\quad&\textit{right strictness:} && f;\bot =\bot&\\
&\textit{right neutrality of~$\eta$:} && f;\eta =f\\
&\textit{right distributivity:} && (f\lor g); h =f; h\lor g; h\hspace{7em}
\\[2ex]
&\textit{left strictness:} && \bot; f = \bot\\
&\textit{left neutrality of~$\eta$:} && \eta; f = f\\
&\textit{left distributivity:} && f; (g\lor h)=f; g\lor f; h
\\[2ex]
\intertext{\itshape Iteration laws:}
&\textit{right unfolding:} && f^\rstar = \eta\lor f;f^\rstar\\
&\textit{right induction:} && f; g\leq f\implies f; g^\rstar\leq f
\\[2ex]
&\textit{left unfolding:} && f^\rstar = \eta\lor f^\rstar;f\\
&\textit{left induction:} && f; g\leq g\implies f^\rstar; g\leq g
\end{flalign*}
\caption{Axioms Kleene algebras/monads.}
\label{fig:klee-ax}
\end{figure*}
A Kleene algebra can be concisely defined as an idempotent semiring $(S\comma\bot\comma\eta\comma\lor\comma\,;\,)$
equipped with an operator $(\argument)^\rstar\c S\to S$,
such that $g; f^\rstar$ is the least (pre-)fixpoint of $g\lor (\argument); f$
and $f^\rstar; h$ is the least fixpoint of $h\lor f;(\argument)$ where the
order is induced by $\lor$: $f\leq g$ if $f\lor g = g$. More concretely, a Kleene
algebra is an algebraic structure, $(S\comma\bot\comma\eta\comma\lor\comma\,;\,,(\argument)^\rstar)$,
satisfying the laws in~\autoref{fig:klee-ax}.
A categorical version of Kleene algebra emerges
as a class of monads, called~\emph{Kleene monads}~\cite{GoncharovSchroderEtAl09},
which can be used for interpreting effectful languages with iteration and
non-determinism.
\begin{definition}[Kleene-Kozen Category/Kleene Monad]
We say that a category $\BC$ is a \emph{Kleene-Kozen category} if $\BC$ is
enriched over bounded (i.e.\ possessing a least element) join-semilattices
and strict join-preserving morphisms, and there is \emph{Kleene iteration} operator
\begin{displaymath}
(\argument)^\rstar\c\BC(X,X)\to\BC(X,X),
\end{displaymath}
such that, given $f\c Y\to Y$, $g\c Y\to Z$
and ${h\c X\to Y}$, $g\comp f^\rstar$ is the least (pre\dash)fixpoint of $g\lor (\argument)\comp f$
and $f^\rstar\comp h$ is the least (pre\dash)fixpoint of $h\lor f\comp(\argument)$.
A monad $\BBT$ is a \emph{Kleene monad} if $\BC_{\BBT}$ is a Kleene-Kozen
category.
\end{definition}
Recall that a monoid is nothing but a single-object category, whose morphisms
are identified with monoid elements, and whose unit and composition are identified
with monoidal unit an composition. This suggests a connection between Kleene-Kozen
categories and Kleene algebras.
\begin{proposition}\label{pro:monad-alg}
A Kleene algebra is precisely a Kleene-Kozen category with one object.
\end{proposition}
The axioms of Kleene monads thus do not in fact need a monad, and can be interpreted
in any category. We stick to Kleisli categories for two reasons: (i)~in practice,
Kleene-Kozen categories are often realized as Kleisli categories, and
monads provide a compositional mechanism for constructing more Kleene-Kozen
categories by generalities; (ii) we will relate Kleene monads and Elgot monads,
and the latter are defined by axioms, which do involve both general Kleisli morphisms
and the morphisms of the base category.
\begin{example}\label{exa:kle}
Let us revisit~\autoref{exa:mon}. Many monads therein fail to be Kleene simply
because they fail to support binary non-determinism. \autoref{exa:mon}.\itref{it:dis} is an interesting
case, since we can define the operation of probabilistic choice
$+_p\c\BC(X,TY)\times\BC(X,TY)\to\BC(X,TY)$ indexed by $p\in [0,1]$, meaning that
$x+_p y$ is resolved to $x$ with probability $p$ and to $y$ with probability $1-p$.
For every ${x\in X}$, $f(x)+_p g(x)$ is a \emph{convex sum} of the distributions $f(x)$ and $g(x)$. This
operation satisfies the axioms of \emph{barycentric algebras} (or, \emph{abstract convex sets}~\cite{Stone49}),
which are somewhat similar to those of a monoid, but with the multiplication operator indexed over
$[0,1]$. To get rid of this indexing, one can remove the requirement that probabilities
sum up to at most $1$ and thus obtain spaces of \emph{valuations}~\cite{VaraccaWinskel06}
instead of probability distributions. Valuations can be conveniently added pointwise,
and thus defined addition satisfies monoidal laws, but fails idempotence, hence
still does not yield a Kleene monad. Given two valuations $v$
and $w$, we also can define $v\lor w$ as the pointwise maximum. This
satisfies the axioms of semilattices, but fails both distributivity laws.
\autoref{exa:mon}.\itref{it:plo} is the $\catname{Set}$-reduct
or \emph{Plotkin powerdomain}~\cite{Plotkin76} over a flat domain. It supports
proper non-deterministic choice, but the only candidate for $\bot$ is not a unit
for it.
Kleene monads of~\autoref{exa:mon} are only~\itref{it:pow} and~\itref{it:wri}.
The non-deterministic state monad over $TX=(\PSet(X\times S))^S$ obtained by
adapting~\autoref{exa:mon}.\itref{it:sta} in the obvious way is also~Kleene.
\end{example}
Except for the powerset monad, our examples of Kleene monads are in fact obtained
by generic patterns.
\begin{proposition}\label{pro:klee}
Let $\BBT$ be a Kleene monad. Then so are
\begin{enumerate}[wide]
\item the state monad transformer $(T(\argument\times S))^S$ for every $S$;
\item the writer monad transformer $T(M\times\argument)$ for every monoid $(M,\eps,\bullet)$
if $\BBT$ is strong and strength $\tau_{X,Y}\c X\times TX\to T(X\times Y)$ respects the
Kleene monad structure, as follows:
\begin{align}\label{eq:str-klee}
\begin{gathered}
\tau\comp (\id\times\bot) = \bot,\qquad
\tau\comp (\id\times f^\rstar) = (\tau\comp (\id\times f))^\rstar,\\[1ex]
\tau\comp (\id\times (f\lor g)) = \tau\comp (\id\times f)\lor \tau\comp (\id\times g).
\end{gathered}
\end{align}
\end{enumerate}
\end{proposition}
\begin{example}
Note that the powerset monad $\PSet$ is a Kleene monad with~$f^\rstar$
calculated as a least fixpoint of $\eta\lor(\argument)\cdot f$.
\begin{enumerate}[wide]
\item By~\autoref{pro:klee}.1, $(\PSet(\argument\times S))^S$ is a Kleene monad.
\item By applying \autoref{pro:klee}.2, to the free monoid $A^\star$ of finite strings over an alphabet $A$
we obtain that $\PSet(A^\star\times\argument)$.
\end{enumerate}
\begin{figure*}[t]
\hyperref[it:fix]{\axname{\normalcolor Fixpoint}}\xspace %
\vspace{-2ex}
\begin{center}
\includegraphics[scale=1]{standalone/elgot-fix.pdf}
\end{center}
\hyperref[it:nat]{\axname{\normalcolor Naturality}}\xspace %
\vspace{-2ex}
\begin{center}
\includegraphics[scale=1]{standalone/elgot-nat.pdf}
\end{center}
\bigskip
\hyperref[it:cod]{\axname{\normalcolor Codiagonal}}\xspace %
\vspace{-2ex}
\begin{center}
\includegraphics[scale=1]{standalone/elgot-cod.pdf}
\end{center}
\bigskip
\hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace %
\vspace{-2ex}
\begin{center}
\includegraphics[scale=1]{standalone/elgot-uni.pdf}
\end{center}
\caption{Axioms of Elgot monads.}
\label{fig:elg-ax}
\end{figure*}
It is easy to see that for every Kleene monad $\BBT$, $\Hom(1,T1)$ is a Kleene
algebra. By applying this to the above clauses we obtain correspondingly the standard
\emph{relational} and \emph{language-theoretic} models of Kleene algebra~\cite{KozenSmith96}.
\end{example}
\section{Elgot Monads}\label{sec:elg}
A general approach to monad-based iteration is provided by Elgot monads.
We continue under the assumption that $\BC$ supports finite coproducts. This,
in particular, yields an if-the-else operator sending $b\in\BC(X,X+X)$ and
$f,g\in\BC(X,Y)$ to $\ift{b}{p}{q} = [q,p]\cdot b\in\BC(X,Y)$. Note that for any
monad $\BBT$ on $\BC$, $\BC_{\BBT}$ inherits finite coproducts.
\begin{definition}[Elgot monad]\label{defn:elgot}
An \emph{Elgot monad} in a category with binary coproducts is a monad $\BBT$ equipped with an
\emph{Elgot iteration} operator
\begin{displaymath}
(\argument)^\istar\c\BC(X,T(Y+X))\to\BC(X,TY),
\end{displaymath}
subject to the following principles:
\begin{flalign}
&\label{it:fix}\tag*{}\axname{Fixpoint}: [\eta, f^{\istar}] \cdot f = f^{\istar} & (f\c X\to T(Y+X))\\[1ex]
&\label{it:nat}\tag*{}\axname{Naturality}: g\cdot f^{\istar} = ([\eta\inl\cdot g, \eta\inr] \cdot f)^{\istar} & (g\c Y \to TZ, f\c X\to T(Y+X))\\[1ex]
&\label{it:cod}\tag*{}\axname{Codiagonal}: ([\eta,\eta\inr] \cdot f)^{\istar} = f^{\istar\istar} & (f\c X \to T((Y + X) + X))\\
&\label{it:uni}\tag*{}\axname{Uniformity}: \lrule{}{g \cdot \eta h = \eta(\id+h)\cdot f}{g^{\istar} \cdot \eta h = f^{\istar}} & ({h\c X\to Z}, g\c Z\to T(Y + Z),\\[-1ex]&& f\c X \to T(Y + X))\notag
\end{flalign}
\end{definition}
\noindent
These laws are easier to grasp by depicting them graphically (\autoref{fig:elg-ax}),
more precisely speaking, as \emph{string diagrams}~(cf.~\cite{JoyalStreetEtAl96,Hasegawa03}
for a rigorous treatment in terms of monoidal categories).
Iterating $f$ is depicted as a feedback loop. It is
then easy to see that while~\hyperref[it:fix]{\axname{\normalcolor Fixpoint}}\xspace expresses the basic fixpoint property of iteration,
\hyperref[it:nat]{\axname{\normalcolor Naturality}}\xspace and~\hyperref[it:cod]{\axname{\normalcolor Codiagonal}}\xspace are essentially rearrangements of wires. The~\hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace law is a form of
induction: the premise states that $\eta h$ can be pushed over $g$, so that at the same
time~$g$ is replaced by $f$, and the conclusion is essentially the result of
closing this transformation under iteration. \hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace is therefore the only law, which alludes
to morphisms that factor through $\eta$. Intuitively, the morphisms $f$ and $g$
can be seen as programs operating correspondingly on $X$ and $Y$ as their state
spaces, and $h\c X\to Y$ is a map between these state spaces. \hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace thus ensures that
the behaviour of iteration does not depend on the shape of the state
space.
It is critical
for this view that~$h$ is sufficiently ``harmless'', i.e.\ does not trigger any side-effects.
\begin{remark}[Divergence]\label{rem:div}
Every Elgot monad comes together with the definable (unproductive) divergence
constant $\delta = (\eta\inr)^\istar$. Graphically, $\delta\c X\to T\iobj$ will be depicted as
\makebox
{
\begin{tikzpicture} [cprop]
\draw [sigma line, thick] (0,0) to ++(6.5ex,0) node[circle,draw,fill=white,inner sep=0pt,minimum size=4pt] {};
\end{tikzpicture}
}, symmetrically to the depiction of the initial morphism $\bang\c\iobj\to TX$ as
\makebox
{
\begin{tikzpicture} [cprop]
\draw [sigma line, thick] (0,0) to ++(-6.5ex,0) node[bullet] {};
\end{tikzpicture}
}.
\end{remark}
\begin{example}[Elgot Monads]\label{exa:elg}
Clauses~\itref{it:may}--\itref{it:out} of~\autoref{exa:mon} all define
Elgot monads. A standard way of introducing Elgot iteration is enriching the Kleisli category
over pointed complete partial orders and defining $(f\c X\to T(Y+X))^\istar$ as
a least fixpoint of the map $[\eta,\argument]\cdot f\c\BC(X,TY)\to\BC(X,TY)$ by
the \emph{Kleene fixpoint theorem}. This scenario covers~\itref{it:may}--\itref{it:sta}.
In all these cases, we inherit complete partial order structures on $\catname{Set}(X,TY)$
by extending canonical complete partial order structures from $TY$ pointwise.
In particular, in~\itref{it:exc}, we need to chose the divergence element $\delta\in E$. This
choice induces a \emph{flat domain} structure on $X+E$: $x\appr y$ if $x=y$ or $x=\delta$.
The induced divergence constant in the sense of \autoref{rem:div} then coincides with
$\delta$, and hence there are at least as many distinct Elgot monad structures on the
exception monad as exceptions.
Clauses~\itref{it:in} and~\itref{it:out} fit a different pattern.
For every Elgot monad~$\BBT$ and every endofunctor $H$, if all final coalgebras
$T_HX = \nu\gamma.\,T(X+H\gamma)$ exist then $T_H$ extends to an Elgot monad~\cite{GoncharovJakobEtAl18},
called the \emph{coalgebraic generalized resumption transform} of $\BBT$.
This yields~\itref{it:in} and~\itref{it:out} by taking $\BBT$ to be the maybe-monad
in both cases and $HX=X^I$ and $HX=O\times X$ respectively.
\end{example}
\begin{remark}[Dinaturality]\label{rem:din}
A classical law of iteration, which is not included in~\autoref{defn:elgot},
is the \hyperref[rem:din]{\axname{\normalcolor Dinaturality}}\xspace law, which has the following graphical representation:
\begin{center}
\includegraphics[scale=1]{standalone/elgot-din.pdf}
\end{center}
This law
has been used in one of the equivalent axiomatization
of iteration theories~\cite{BloomEsik93} (under the name \emph{``composition identity''})
and thus was initially inherited in the definition of Elgot monads~\cite{AdamekMiliusEtAl10,GoncharovRauchEtAl15}.
However, \'Esik and Goncharov~\cite{EsikGoncharov16} latter discovered that
\hyperref[rem:din]{\axname{\normalcolor Dinaturality}}\xspace is derivable in presence of \hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace.
\end{remark}
\autoref{rem:din} poses the question, if the present axiomatization of Elgot
monads possibly contains further derivable laws. Here, we resolve it in the negative.
\begin{proposition}
The axiomatization in~\autoref{defn:elgot} is minimal.
\end{proposition}
\begin{proof}
For every axiom, we construct a separating example that fails that axiom, but
satisfies the other three. Every example is a monad on $\catname{Set}$.
\begin{itemize}[wide]
\item\hyperref[it:fix]{\axname{\normalcolor Fixpoint}}\xspace: For any monad $\BBT$, equipped with a natural transformation
$\delta\c 1\to TX$, we can define $f^\istar = [\eta\inl,\delta\bang]\cdot f$ for a
given $f\c X\to {T(Y+X)}$. It is easy to see that~\hyperref[it:nat]{\axname{\normalcolor Naturality}}\xspace,~\hyperref[it:cod]{\axname{\normalcolor Codiagonal}}\xspace and~\hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace are satisfied,
but~\hyperref[it:fix]{\axname{\normalcolor Fixpoint}}\xspace need not to, e.g.\ with $T$ being the non-deterministic writer monad
(\autoref{exa:mon}.\ref{it:wri}) over the additive monoid of natural numbers~$\mathbb{N}$.
\item\hyperref[it:nat]{\axname{\normalcolor Naturality}}\xspace: Let $\BBT=\PSet$ and let $f^\istar(x) = Y$
for every $f\c X\to T(Y+X)$ and every $x\in X$. Note that every $f\c X\to T(Y+Z)$
is equivalent to a pair $(f_1\c X\to TY,f_2\c X\to TZ)$ and $[g,h]\cdot f= g\cdot f_1\cup h\cdot f_2$
for any $g\c Y\to TV$, $h\c Z\to TV$. This helps one to see that all the axioms, except \hyperref[it:nat]{\axname{\normalcolor Naturality}}\xspace hold true, e.g.\
$([\eta,f^\istar]\cdot f)(x) = f_1(x)\cup Y = Y = f^\istar(x)$.
\hyperref[it:nat]{\axname{\normalcolor Naturality}}\xspace fails, because $g\cdot\delta = g\cdot (\eta\inr)^\istar \neq ([\eta\inl\cdot g, \eta\inr] \cdot \eta\inr)^{\istar} = \delta$,
since the image of $\delta\c X\to TY$ is $\{Y\}$, while the image of $g\cdot\delta$,
aka the image of $g$, need not be~$\{Y\}$.
\item\hyperref[it:cod]{\axname{\normalcolor Codiagonal}}\xspace: Consider the exception monad transform of the non-deterministic writer monad $TX = {\PSet(2^\star\times X\cup 2^\omega)}$
over the free monoid $2^\star$. This is canonically an Elgot monad, and let us
denote by $(\argument)^\iistar$ the corresponding iteration operator. Every
$f\c X\to T(Y+X)$, using the isomorphism $T(Y+X)\iso\PSet(2^\star\times Y\cup 2^\omega)\times\PSet(2^\star\times X)$,
induces a map $\hat f\c X\to \PSet(2^\star\times X)$. Let $f^\istar\c X\to TY$
be as follows:~$f^\istar(x)$ is the union of $f^\iistar(x)$ and the set
\begin{align*}
\{w\in 2^\omega\mid \exists u\in 2^\star.\,uw = w_1w_2\ldots,(w_1,x_1)\in\hat f(x), (w_2,x_2)\in\hat f(x_1),\ldots\}.
\end{align*}
That $(\argument)^\istar$ satisfies \hyperref[it:fix]{\axname{\normalcolor Fixpoint}}\xspace, \hyperref[it:nat]{\axname{\normalcolor Naturality}}\xspace
and \hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace follows essentially from the fact that so does $(\argument)^\iistar$. To show
that $(\argument)^\istar$ fails \hyperref[it:cod]{\axname{\normalcolor Codiagonal}}\xspace, consider $g\c 1\to \PSet((2^\star+2^\star)\cup 2^\omega)$,
with $g(\star) = \{\inl 0,\inr 1\}$. Let $f$ be the composition of~$g$ with
the obvious isomorphism $\PSet((2^\star+2^\star)\cup 2^\omega)\iso T((0+1)+1)$.
Now $(T[\id,\inr]\comp f)^\istar(\star) = 2^\omega\neq \{0^\omega,1^\omega\}
= f^{\istar\istar}$.
\item\hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace: Consider the exception monad on $TX = X + \{0,1\}$. This can be
made into an Elgot monad in two ways: by regarding either $0$ or $1$ as the divergence
element. Given $f\c X\to T(Y+X)$, we let $f^\istar$ be computed according to the first
choice if $X$ is a singleton and according to the second choice otherwise. The
axioms except \hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace are clearly satisfied. To show that \hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace fails, let $|X|>2$,
$|Z|=1$, $g=\eta\inr$, $f=\eta\inr$, $h=\bang$. The premise of \hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace is thus satisfied,
while the conclusion is not, since $f^\istar$ is constantly $1$ and $g^\istar$
is constantly $0$.%
\qed
\end{itemize}
\noqed\end{proof}
Although we cannot lift any of the Elgot monad laws, \hyperref[it:nat]{\axname{\normalcolor Naturality}}\xspace can be significantly reduced.
\begin{lemma}\label{lem:nat}
In the definition of Elgot monad, \hyperref[it:nat]{\axname{\normalcolor Naturality}}\xspace can be equivalently replaced by its instance
with $g$ of the form $\eta\inr\c Y\to T(Y'+Y)$.
\end{lemma}
\section{While-Monads}\label{sec:while}
We proceed to develop a novel alternative characterization of Elgot monads in more
conventional for computer science terms of while-loops.
\begin{definition}[Decisions]
Given a monad $\BBT$ on~$\BC$, we call any family
$(\BC_\BBT^{\mathsf d}(X)\subseteq\BC(X,T(X+X)))_{X\in|\BC|}$, a family of \emph{decisions}
if every $\BC_\BBT^{\mathsf d}(X)$ contains~$\eta\inl$, $\eta\inr$, and is closed
under~$\oname{if}$-$\oname{then}$-$\oname{else}$.
\end{definition}
We encode logical operations on decisions as follows:
\begin{flalign*}
&&\oname{ff} &\,= \eta\inl, & b\mathrel{\texttt{\upshape\&\kern-.5pt\&}} c =\,& \ift{b}{c}{\oname{ff}}, & \mathrel{\texttt{\upshape{\raisebox{0.5ex}{\texttildelow}}}}\kern-1.5pt b =\,& \ift{b}{\oname{ff}}{\tt},\qquad\\
&&\oname{ff} &\,= \eta\inr, & b\mathrel{\texttt{\upshape|\kern-2.5pt|}} c =\,& \ift{b}{\tt}{c}.
\end{flalign*}
By definition, decisions can range from the smallest family with $\BC_\BBT^{\mathsf d}(X) =
\{\oname{ff},\tt\}$, to the greatest one with $\BC_\BBT^{\mathsf d}(X)=\BC(X,T(X+X))$.
\begin{remark}%
Our notion of decision is maximally simple and general. An
alternative are morphisms of the form $b\c X\to T2$, from which we can
obtain $X\xto{\brks{\id,b}} X\times T2\xto{\tau} T(X\times 2)\iso T(X+X)$ if $\BBT$
is strong, whose strength is~$\tau$. The resulting
decision $d$ would satisfy many properties, we are not assuming generally, e.g.\
$\ift{d}{\tt}{\oname{ff}} = \eta$. Both morphisms
of the form $X\to T2$ and $X\to T(X+X)$ are relevant in semantics as decision making
devices -- this is explained in detail from the perspective of categorical logic
by Jacobs~\cite{Jacobs16}, who uses the names \emph{predicates} and \emph{instruments}
correspondingly (alluding to physical, in particular, quantum experiments).
\end{remark}
Elgot monads are precisely the semantic gadgets for effectful while-languages. In fact,
we can introduce a semantic $\oname{while}$-operator and express it via Elgot iteration.
Given $b\in\BC_\BBT^{\mathsf d}(X)$ and $p\in\BC(X,TX)$, let
\begin{align}\label{eq:while-as-it}
\while{b}{p} = (\ift{b}{p;\oname{ff}}{\oname{ff}})^\istar,
\end{align}
or diagrammatically, $\while{b}{p}$ is expressed as
\begin{center}
\includegraphics[scale=1]{standalone/while-as-it.pdf}
\end{center}
It is much less obvious that, conversely, Elgot iteration can be defined via~$\oname{while}$,
and moreover that the entire class of Elgot monads can be rebased on~$\oname{while}$.
We dub the corresponding class of monad \emph{while-monads}.
\begin{definition}[While-Monad]
A \emph{while-monad} is a monad $\BBT$, equipped with an operator
\begin{align*}
\oname{while}\c\BC_\BBT^{\mathsf d}(X)\times\BC(X,TX)\to\BC(X,TX),
\end{align*}
such that the following axioms are satisfied
\begin{flalign}
\hspace{-5em} &&\axname{W-Fix} &\hspace{1em}\while{b}{p} = \ift{b}{p; (\while{b}{p})}{\eta}\tag*{}\label{it:wfix}\\[1ex]
\hspace{-5em} &&\axname{W-Or} &\hspace{1em}\while{(b\mathrel{\texttt{\upshape|\kern-2.5pt|}} c)}{p} = (\while{b}{p});\while{c}{(p;\while{b}{p})}\tag*{}\label{it:wor}\\[2ex]
\hspace{-5em} &&\axname{W-And} &\hspace{.5em}\lrule{}{\eta h;b = \eta u;\oname{ff}}{
\while{(b\mathrel{\texttt{\upshape\&\kern-.5pt\&}} (c\mathrel{\texttt{\upshape|\kern-2.5pt|}}\eta u;\oname{ff}))}{p} = \while{b}{(\ift{c}{p}{\eta h})}}\tag*{}\label{it:wand}\\*[1.5ex]
\hspace{-5em} &&\axname{W-Uni} &\hspace{.5em}\lrule{}{\eta h; b = \ift{c}{\eta h';\tt}{\eta u;\oname{ff}}\qquad \eta h';p = q;\eta h}
{\eta h;\while{b}{p} = (\while{c}{q});\eta u}\tag*{}\label{it:wuni}
\end{flalign}
\end{definition}
The laws of while-monads roughly correspond to~\hyperref[it:fix]{\axname{\normalcolor Fixpoint}}\xspace, \hyperref[it:cod]{\axname{\normalcolor Codiagonal}}\xspace, \hyperref[it:nat]{\axname{\normalcolor Naturality}}\xspace and~\hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace
respectively. This correspondence is somewhat allusive for~\hyperref[it:wand]{\axname{\normalcolor W-And}}\xspace,
which under $u=\id$ instantiates to the nicer looking one:
\begin{displaymath}
\lrule{}{\eta h;b = \oname{ff}}{
\while{(b\mathrel{\texttt{\upshape\&\kern-.5pt\&}} c)}{p} = \while{b}{(\ift{c}{p}{\eta h})}}
\end{displaymath}
However, this instance generally seems to be insufficient. Let us still consider
it in more detail.
The while-loop $\while{(b\mathrel{\texttt{\upshape\&\kern-.5pt\&}} c)}{p}$ repeats $p$ as long as both~$b$ and $c$
are satisfied, and $\while{b}{(\ift{c}{p}{\eta h})}$ repeats $(\ift{c}{p}{\eta h})$
as long as $b$ is satisfied, but the latter program still checks $c$ before running $p$
and triggers $\eta h$ if $c$ fails. The equality in the conclusion of the rule is thus due to
the premise, which ensures that once $\eta h$ is triggered, the loop is existed
at the beginning of the next iteration.
Note that using the following equations
\begin{align}
\dw{p}{b} =&\; p;\while{b}{p}\label{eq:do-wh}\\*
\while{b}{p} =&\; \ift{b}{(\dw{p}{b})}{\eta}\label{eq:wh-do}
\end{align}
we can define $(\dw{p}{b})$ from $(\while{b}{p})$ and conversely obtain the latter
from the former. Unsurprisingly, while-monads can be equivalently defined in terms
of~$\oname{do-while}$.
\begin{lemma}\label{lem:dowhile}
Giving a while-monad structure on $\BBT$ is equivalent to equipping~$\BBT$ with
an operator, sending every $b\in\BC_\BBT^{\mathsf d}(X)$ and every $p\in\BC(X,TX)$ to
$(\dw{p}{b})\in\BC(X,TX)$, such that the following principles hold true:
\begin{flalign}
\hspace{-2em}&&\axname{DW-Fix} &\hspace{1em}\dw{p}{b} = p;\ift{b}{(\dw{p}{b})}{\eta}\tag*{}\label{it:dwfix}&\\[1ex]
\hspace{-2em}&&\axname{DW-Or} &\hspace{1em}\dw{p}{(b\mathrel{\texttt{\upshape|\kern-2.5pt|}} c)} = \dw{(\dw{p}{b})}{c}\tag*{}\label{it:dwor}\\[2ex]
\hspace{-2em}&&\axname{DW-And} &\hspace{.5em}\lrule{}{\eta h;b = \eta u;\oname{ff}}{
\begin{array}{rl}\ift{c}{\dw{p&}{(b\mathrel{\texttt{\upshape\&\kern-.5pt\&}} (c\mathrel{\texttt{\upshape|\kern-2.5pt|}}\eta u;\oname{ff}))}}{\eta u}\\[1ex] &\quad = \dw{(\ift{c}{p}{\eta h})}{b}\end{array}
}\tag*{}\label{it:dwand}\\[1.5ex]
\hspace{-2em}&&\axname{DW-Uni} &\hspace{.5em}\lrule{}{
\eta h;p = q;\eta h'\qquad\eta h'; b = \ift{c}{\eta h;\tt}{\eta u;\oname{ff}}
}{
\eta h;\dw{p}{b} = (\dw{q}{c});\eta u
}\tag*{}\label{it:dwuni}
\end{flalign}
The relevant equivalence is witnessed by the equations~\eqref{eq:do-wh} and~\eqref{eq:wh-do}.
\end{lemma}
Finally, we can prove the equivalence of while-monads and Elgot monads.
\begin{theorem}\label{thm:main}
Suppose that for all $X,Y\in |\BC|$, $\eta(\inl+\inr)\in\BC_\BBT^{\mathsf d}(X+Y)$. Then~$\BBT$ is
and Elgot monad iff it is a while-monad w.r.t.~$\BC_\BBT^{\mathsf d}$. The equivalence is witnessed
by mutual translations:~\eqref{eq:while-as-it} and
\begin{align}\label{eq:it-as-while}
f^\istar = \eta\inr; (\while{\eta(\inl+\inr)}{[\eta\inl,f]}); [\eta,\delta].
\end{align}
Diagrammatically, $f^\istar$ is expressed as
\begin{center}
\includegraphics[scale=1]{standalone/it-as-while-old.pdf}
\end{center}
for $f\c X\to T(Y+X)$.
\end{theorem}
\begin{proof}[Sketch]
Note that~\eqref{eq:it-as-while} is equivalent to
\begin{align}\label{eq:it-as-dow}
f^\istar = \eta\inr; \bigl(\dw{[\eta\inl,f]}{\eta(\inl+\inr)}\bigr); [\eta,\delta].
\end{align}
The proof consists of four parts:
\medskip\noindent
(i)~ The composite translation $(\argument)^\istar\to\oname{while}\to (\argument)^\istar$
yields an identity w.r.t.\ the Elgot monad laws, i.e.\
\begin{displaymath}
\eta\inr; (\ift{(\inl+\inr)}{[\eta\inl,f]; \eta\inr}{\eta\inl})^\istar; [\eta,\delta] = f^\istar.
\end{displaymath}
for every $f\c X\to T(Y+X)$.
\medskip\noindent
(ii)~ The composite translation $\oname{while}\to(\argument)^\istar\to\oname{while}$
yields an identity w.r.t.\ the while-monad laws, i.e.\
\begin{align*}%
\eta\inr; \bigl(\while{\eta(\inl+\inr)}{[\eta\inl,\ift{b}{p;\tt}{\oname{ff}}]}\bigr); [\eta,\delta] = \while{b}{p}.
\end{align*}
for every $p\c X\to TX$ and $b\in\BC_\BBT^{\mathsf d}(X)$.
\medskip\noindent
(iii)~ The laws of Elgot monads follow from those of while-monads. Thanks to
\autoref{lem:nat}, it suffices to prove only a restricted version of \hyperref[it:nat]{\axname{\normalcolor Naturality}}\xspace. The
verification of \hyperref[it:cod]{\axname{\normalcolor Codiagonal}}\xspace is facilitated by using~\eqref{eq:it-as-dow} instead
of~\eqref{eq:it-as-while}.
\medskip\noindent
(iv)~ The laws of while-monads follow from those of Elgot monads. This is
done by verifying the equivalent characterization from~\autoref{lem:dowhile},
after proving that the identity $\dw{p}{b} = (b\cdot p)^\istar$ follows
from~\eqref{eq:while-as-it}.
\end{proof}
\section{Kleene Monads as Elgot Monads}\label{sec:kleene-elgot}
If hom-sets of the Kleisli category of a while-monad $\BBT$ are equipped with a
semilattice structure and every $\BC_\BBT^{\mathsf d}(X)$ is closed under that structure, we can
define a Kleene iteration as follows:
\begin{align*}
p^\rstar = \while{(\oname{ff}\lor\tt)}{p}.
\end{align*}
That is, at each iteration we non-deterministically decide to finish or to continue.
Given a decision $b\in\BC_\BBT^{\mathsf d}(X)$, let $b? = (\ift{b}{\eta}{\delta})\in\BC(X,TX)$.
Then a standard way to express while-loops via Kleene iteration is as follows:
\begin{align*}
\while{b}{p} = (b?; p)^\rstar; (\mathrel{\texttt{\upshape{\raisebox{0.5ex}{\texttildelow}}}}\kern-1.5pt b)?
\end{align*}
If the composite translation $\oname{while}\to (\argument)^\rstar\to\oname{while}$
was a provable identity, this would essentially mean equivalence of Kleene iteration
and $\oname{while}$ with non-determinism. This is generally not true,
unless we postulate more properties that connect $\oname{while}$ and nondeterminism.
We leave for future work the problem of establishing a minimal set of such laws.
Here, we only establish the equivalence for the case when the induced Kleene iteration
satisfies Kleene monad laws.
To start off, we record the following novel characterization of Kleene monads
(hence, also of Kleene algebras by~\autoref{pro:monad-alg}).
\begin{proposition}\label{pro:klee-eq}
A monad $\BBT$ is a Kleene monad iff
\begin{itemize}[wide]
\item the Kleisli category of $\BBT$ is enriched
over bounded join-semilattices and strict join-preserving morphisms;
\item there is an operator $(\argument)^\rstar\c\BC(X,TX)\to\BC(X,TX)$,
such that
\begin{enumerate}[leftmargin=10ex, labelindent=12ex]
\item\label{it:klee-eq1} $f^\rstar = \eta\lor f; f^\rstar$;
\item\label{it:klee-eq2} $\eta^\rstar = \eta$;
\item\label{it:klee-eq4} $f^\rstar = (f\lor \eta)^\rstar$;
\item\label{it:klee-eq3} $f; h = g; f$ ~implies~ $f; h^\rstar = g^\rstar; f$.
\end{enumerate}
\end{itemize}
\end{proposition}
\begin{proof}
Let us show \emph{necessity}.
\begin{enumerate}[wide]
\item The law $f^\rstar = \eta\lor f; f^\rstar$ holds by assumption.
\item Since $\eta = \eta\lor\eta;\eta$, $\eta$ is a
fixpoint of $f\mto\eta\lor\eta; f$, and thus $\eta^\rstar\leq\eta$. Also
$\eta^\rstar = \eta\lor\eta;\eta^\rstar\geq\eta$. Hence $\eta = \eta^\rstar$ by
mutual inequality.
\item To show that $f^\rstar\leq (f\lor \eta)^\rstar$, note that
$f^\rstar = \eta\lor f; f^\rstar = \eta\lor f; f^\rstar\lor f^\rstar =\eta\lor (f\lor\eta);f^\rstar$,
and use the fact that $(\eta\lor f)^\rstar$ is the least fixpoint. The opposite
inequality is shown analogously.
\item Suppose that $f; h = g; f$,
and show that $f; h^\rstar = g^\rstar; f$. Note that
\begin{displaymath}
f\lor g; (f; h^\rstar) = f\lor g; f; h^\rstar
= f\lor f; h; h^\rstar
= f\cdot h^\rstar,
\end{displaymath}
i.e.\ $f\cdot h^\rstar$ satisfies the fixpoint equation for $g^\rstar; f$,
and therefore $f\cdot h^\rstar\geq g^\rstar; f$. By a symmetric argument,
$f\cdot h^\rstar\leq g^\rstar; f$, hence $f\cdot h^\rstar=g^\rstar; f$.
\end{enumerate}
We proceed with \emph{sufficiency}. Suppose that $(\argument)^\rstar$ is as described
in the second clause of the lemma. Observe that by combining assumptions~\itref{it:klee-eq1}
and~\itref{it:klee-eq3} we immediately obtain the dual version of~\itref{it:klee-eq1},
which is $f^\rstar = \eta\lor f^\rstar; f$.
Now, fix $f\c Y\to TY$ and $g\c Y\to TZ$, and show that
$g; f^\rstar$ is the least fixpoint of $g\lor (\argument); f$ -- we omit
proving the dual property, since it follows by a dual argument. From
$f^\rstar = \eta\lor f; f^\rstar$ we obtain $g; f^\rstar = g\lor (g; f^\rstar); f$,
i.e.\ $g; f^\rstar$ is a fixpoint. We are left to show that it is the least
one. Suppose that $h = g\lor h; f$ for some $h$, which entails
\begin{displaymath}
h; (\eta\lor f) = h\lor h; f = g\lor h; f\lor h; f = h = \eta; h.
\end{displaymath}
Since $g\leq h$, using assumptions~\itref{it:klee-eq2},~\itref{it:klee-eq4}~and~\itref{it:klee-eq3}, we obtain
\begin{displaymath}
g; f^\rstar\leq g; (\eta\lor f)^\rstar \leq h; (\eta\lor f)^\rstar = \eta^\rstar; h = h,
\end{displaymath}
as desired.
\end{proof}
\begin{definition}[Strong Uniformity]
Given an Elgot monad $\BBT$, the \emph{strong uniformity} law is as follows:
\begin{flalign}
\label{it:suni}\tag*{}\axname{Uniformity$^\bigstar$}:\qquad \lrule{}{\delta\cdot h =\delta \qquad g \cdot h = [\eta\inl,\eta\inr\cdot h]\cdot f}{g^{\istar} \cdot h = f^{\istar}} &&
\end{flalign}
where $h\c X\to TZ$, $g\c Z\to T(Y + Z)$, and $f\c X \to T(Y + X)$.
\end{definition}
Clearly, \hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace is an instance of \hyperref[it:suni]{\axname{\normalcolor Uniformity$^\bigstar$}}\xspace.
\begin{example}
An example of Elgot monad that fails \hyperref[it:suni]{\axname{\normalcolor Uniformity$^\bigstar$}}\xspace can be constructed as
follows. Let $\BBS$ be the reader monad transform of the maybe-monad on $\catname{Set}$:
$S(X) = (X+1)^2$, which is an Elgot monad, since the maybe-monad is so and Elgotness
is preserved by the reader monad transformer. Let $TX=X\times (X+1) + 1$ and note that $T$ is a retract of
$S$ under
\begin{align*}
\rho\c (X+1)\times (X+1)\iso X\times (X+1) + (X+1)\xto{\id+\bang} X\times (X+1) + 1.
\end{align*}
It is easy to check that $\rho$ is a congruence w.r.t.\ the Elgot monad structure,
and it thus induces an Elgot monad structure on $\BBT$~\cite[Theorem~20]{GoncharovSchroderEtAl17}.
Now, let $T_{E} = T(\argument+E)$ for some non-empty $E$. The Elgot monad structure of
$\BBT$ induced an Elgot monad structure on $\BBT_E$. However, $\BBT_E$
fails \hyperref[it:suni]{\axname{\normalcolor Uniformity$^\bigstar$}}\xspace. Indeed, let $h\c X\to (X+E)\times ((X+E)+1) + 1$ and
$f\c X\to ((1+X)+E)\times (((1+X)+E)+1) + 1$ be as follows:
\begin{align*}
h(x) = \inl(\inl x,\inl\inr e)&&
f(x) = \inl (\inr e, \inl\inl\inr x)
\end{align*}
where $e\in E$. Then $h\cdot\delta=\delta$, $f^\istar(x) = \inl (\inr e, \inr\star)$, and
$f\cdot h = [\eta\inl,\eta\inr\cdot h]\cdot f$, but $(f^\istar\cdot h)(x)=\inl(\inr e,\inl\inr e)\neq \inl (\inr e, \inr\star) = f^\istar(x)$.
\end{example}
We are in a position to relate Kleene monads and Elgot monads.
\begin{theorem}\label{thm:elg-klee}
A monad $\BBT$ is a Kleene monad iff
\begin{enumerate}
\item $\BBT$ is an Elgot monad;
\item the Kleisli category of $\BBT$ is enriched over join-semilattices
(without least elements) and join-preserving morphisms;
\item $\BBT$ satisfies $(\eta\inl\lor\eta\inr)^\istar = \eta$;
\item $\BBT$ satisfies \hyperref[it:suni]{\axname{\normalcolor Uniformity$^\bigstar$}}\xspace.
\end{enumerate}
\end{theorem}
In presence of assumptions~\itref{it:klee-eq1}.--\itref{it:klee-eq4}., the distinction
between \hyperref[it:uni]{\axname{\normalcolor Uniformity}}\xspace and \hyperref[it:suni]{\axname{\normalcolor Uniformity$^\bigstar$}}\xspace becomes even more subtle.
\begin{example}
There is an Elgot monad $\BBT$, whose Kleisli category is enriched over bounded semilattices,
$(\eta\inl\lor\eta\inr)^\istar = \eta$, but $\BBT$ fails strong uniformity.
To construct $\BBT$, we adapt Kozen's separating example for left-handed and right-handed Kleene
algebras~\cite{Kozen90}.
\begin{enumerate}[wide]
\item Let $\BBT$ be the submonad of the \emph{continuation monad} (aka neighbourhood monad,
dualization monad) $\PSet\PSet$, formed by those $f$ that preserve finite unions:
%
\begin{align*}
f\{\,\} = \{\,\},\qquad\qquad f(A\cup B) = f(A)\cup f(B).
\end{align*}
\item Using the fact that every $TX$ is a complete lattice, define $f^\istar$
as a least fixpoint, using the \emph{Knaster-Tarski theorem}. This entails
both $(\eta\inl\lor\eta\inr)^\istar \leq \eta$ and $(\eta\inl\lor\eta\inr)^\istar \geq \eta$,
hence $(\eta\inl\lor\eta\inr)^\istar = \eta$.
\item Enrichment in semilattices follows by definition
\item The remaining Elgot monad laws follow by \emph{transfinite induction}.
\item If $\BBT$ was a Kleene monad, any $\BC(X,TX)$ would be a Kleene algebra,
but Kozen showed that it is not, hence $\BBT$ is not a Kleene monad.
\item By \autoref{thm:elg-klee}, $\BBT$ fails \hyperref[it:suni]{\axname{\normalcolor Uniformity$^\bigstar$}}\xspace.
\end{enumerate}
\end{example}
\section{Conclusions}\label{sec:conc}
When it comes to modelling and semantics, many issues can be framed and treated
in terms of universal algebra and coalgebra. However, certain phenomena, such
as recursion, partiality, extensionality, require additional structures, often
imported from the theory of complete partial orders, by enriching categories and
functors, and devising suitable structures, such as recursion and more specifically
iteration. In many settings though, iteration is sufficient, and can be treated as a self-contained
ingredient whose properties matter, while a particular construction behind it
does not.
From this perspective, Elgot monads present a base fundamental
building block in semantics.
We formally compared Elgot monads with Kleene monads, which are
a modest generalization of Kleene algebras. In contrast to inherently categorical
Elgot monads, Kleene algebra is a simple notion, couched in traditional algebraic terms.
The price of this simplicity is a tight pack of laws, which must be accepted altogether, but
which are well-known to be conflicting with many models of iteration. We proposed a novel notion of \emph{while-monad},
which in the categorical context are essentially equivalent to Elgot monads,
and yet while-monads are essentially a three-sorted algebra over (Boolean)
decisions, programs and certain well-behaved ``pure'' programs (figuring in the
so-called uniformity principle). This is somewhat similar to the extension
of Kleene algebra with \emph{tests}~\cite{KozenSmith96}. The resulting \emph{Kleene algebra
with tests} is two-sorted, with tests being a subsort of programs,
and forming a Boolean algebra. Our \emph{decisions} unlike tests do not form
a subsort of programs, but they do support operations of Boolean algebra, without
however complying with all the Boolean algebra laws.
We have then related Elgot monads (and while-monads)
with Kleene monads, and as a side-effect produced a novel axiomatization of Kleene
algebra (\autoref{pro:klee-eq}), based on a version of the uniformity principle. We regard the present
work as a step towards bringing the gap between Elgot iteration and Kleene iteration,
not only in technical sense, but also in the sense of concrete usage scenarios.
We plan to further explore algebraic axiomatizations of iteration, based on the
current axiomatization of while-monads.
\bibliographystyle{plain}
| {'timestamp': '2023-01-18T02:15:36', 'yymm': '2301', 'arxiv_id': '2301.06202', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06202'} | arxiv |
\section{INTRODUCTION}
Hyperledger Fabric is a popular permissionless system that allows the development of blockchain applications in a variety of domains such as finance, healthcare, and supply chain management. Compared to Ethereum \cite{Buterin2014} and Bitcoin \cite{Kornmesser2008}, Fabric offers superior performance, due to the consensus algorithm used and the small number of peers on the network compared to public blockchains. Furthermore, Fabric provides a flexible framework for managing responsibilities across parties using the MSP (membership service provider) which is an abstract component that maintains the identities and roles of all nodes that belong to the same organization.
Most existing blockchain platforms such as Ethereum and Hyperledger Fabric allow Turing-complete computations by executing a smart contract for a given transaction \cite{Zheng2020AnPlatforms}.
To guarantee consistency across the network, peers execute transactions to generate the next state of the blockchain after the content of the next block is known (which transactions to execute, and in what order): this is called the Order-Execute (OX) transaction flow \cite{Androulaki2018}. The weaknesses of the OX pattern is that the sequential execution of the transactions within each block limits the throughput of the system. Furthermore, each peer requires knowledge of all smart contracts to compute the next state of the blockchain, which may present confidentiality and privacy issues.
Instead, Fabric employs the Execute-Order-Validate (EOV) pattern, where the transactions are executed in a sandbox called endorsing peers to generate the read-write sets including the versions of the used keys for the transaction's simulation, then the transactions are ordered by the ordering services into blocks, and at the end validated and committed to the ledger. EOV overcomes the limitations of OX by providing parallelism of transactions execution on different endorsing peers.
The drawback of the EOV pattern is that a read-write lock is used to synchronize the execution and validation phases. To solve this issue, Hyperledger Fabric implements a Multi-Version Concurrency Control mechanism to guarantee the consistency of the blockchain. When validating transactions by the validating peers, the versions of the generated read-write sets are compared to the keys’ versions of the ledger to avoid that two transactions attempt to modify/read the same key/value pairs at the same time. A transaction will be rejected if its read set contains an old version of a key and the client has to resubmit it.
The aforementioned MVCC (Multiversion Concurrency Control) conflict problem is a well-documented limitation of Hyperledger Fabric as it decreases the effective throughput of the system (also known as goodput). This is because the blocks could contain aborted transactions which still count against the size limit, thereby wasting valuable block space. These aborted transactions must also be retried by their respective clients as brand new transactions, which generates additional load on the system. In practice, the MVCC problem can have a serious impact on the performance of the blockchain, as recent studies show that in realistic scenarios such as electronic health records, 40\% of the transactions failed due to concurrency conflict \cite{Chacko2021WhyVersion}. Prior works seek to address or mitigate the MVCC problem by using a lockless approach to provide transaction isolation \cite{Meir2019} or reordering transactions at the ordering phase to minimize the conflict rate when validating and committing transactions to the ledger \cite{Sharma2019} \cite{Ruan2020}.
In our paper, we present a novel approach to solve the MVCC problem called \textit{Early Detection of MVCC Conflicts} (EMVCC). We introduce an EMVCC detection mechanism that aims to reduce the number of conflicts between transactions which increases the overall system goodput. The advantage of our solution over existing works is that the MVCC conflict is detected at the first contact of the transaction with the blockchain network at the endorsement policy allowing to improve the network performances.
The contributions of our paper are as follows:
\begin{enumerate}
\item We provide the formulation of the problem of early detection of conflicting transactions at the endorsement phase, rather the traditional approach of handling MVCC conflicts at the validation phase (Section \ref{sec:pbform}).
\item We propose a novel solution called Early Detection of MVCC Conflicts using local caching at endorsing nodes (Section \ref{sec:propsol}). We provide a theoretical analysis of our solution to calculate the expected effectiveness of the solution depending on parameters such as the endorsement policy, number of organisations, etc. (Section \ref{sec:thAnalysis}).
\item We present three reference implementations of our solution: SyncMap, Lock-Free, and Mutex Lock, their main difference is the data structure used for information storing (Section \ref{sec:datastruc}).
\item We evaluate our solution and compare it to the baseline and we did a sensitivity analysis to study the impact of different network and load parameters on the performances (Section \ref{EXPERIMENTS}).
\end{enumerate}
The paper now continues with Section \ref{BACKGROUND} that gives an overview of the Hyperledger Fabric. This is followed by Section \ref{RELATEDWORK} where we describe prior works related to the MVCC problem.
\section{BACKGROUND}\label{BACKGROUND}
In this section, we give an overview of Hyperledger Fabric Components, we detail the transaction flow and we present the endorsement policies and Multi-Version Concurrency Control Read-Write Conflict (MVCC).
\subsection{Hyperledger Fabric Components}
Hyperledger Fabric is a permissioned distributed ledger system specialized for business applications. Its modular architecture makes blockchain solutions confidential, resilient, and flexible. Hyperledger Fabric has multiple fundamental components such as the client and the peers which are the endorsing peers and the committing peers. In this paper, we will focus on these components as they are the only components affected by our solutions.
\subsubsection{Clients}
Clients are applications or software that operate on behalf of a user to submit transactions on the Fabric network through the Hyperledger Fabric SDK.
\subsubsection{Peers}
Peers are a fundamental component of the network because they keep records of the network’s state and a copy of the ledger. Each peer on the network belongs to an organization that may have one or more peers. The administrator can create, start, stop or reconfigure the peer. To be part of the network, the node should join the shared channel between all the participants. There are two types of peers, endorsing peers and validating/committing peers. In a typical scenario, every Fabric peer typically fulfill both roles of endorsing and validating.
\textbf{Endorsing peers}: this type of node hosts the smart contract executed to simulate transactions and endorse them using the peer signature. When installing the chaincode (smart contract), the administrator specifies which peers will endorse the transactions by defining the endorsement policy rules.
\textbf{Validating/Committing peers}: they are responsible for the VSCC (Validation System Chaincode) used to validate the endorsement policies and the MultiVersion Concurrency Control (MVCC) validation to ensure that the version of the keys read during the endorsement phase is still the same in the ledger to guarantee the deterministic execution of the transaction. Then the committing peers add blocks to the shared ledger and update the blockchain world state.
\subsection{Transaction Flow}
\begin{figure*}[ht]
\centering
\includegraphics[width=\textwidth]{Transaction_Flow.png}
\caption{Transaction Flow}\label{fig:Figure1}
\end{figure*}
Fig.\ref{fig:Figure1} shows the basic transaction flow in Hyperledger Fabric. It consists of five steps:
\begin{itemize}
\item \textbf{Step 1}: A client who wants to make a transaction sends a transaction proposal containing the chaincode function and arguments that the client wants to invoke, to the endorsing peer according to the chaincode endorsement policies (see the next Section \ref{sec:epolicy}).
\item \textbf{Step 2}: An endorser receives the transaction proposal, executes the chaincode, and generates the read/write sets which are the sets containing the values and versions of the keys which are read or written while executing the transaction, then the peer creates the proposal response, signs it and sends the response to the client.
\item \textbf{Step 3}: Once the client collects the required number of endorsements as defined in the endorsement policies, he sends the transaction to the ordering services, this operation contains details about the initial proposal as well as all peer endorsements and read/write sets. The ordering services order transactions received from clients into a block considering the block BatchSize and block BatchTimeout, then the block is created and delivered to the validating peer.
\item \textbf{Step 4}: Upon receiving the block, the committing peer iterates over all the transactions within the block to perform the syntax validation of each transaction, the VSCC validation, and the MVCC validation (see the next Section \ref{sec:mvcc}).
\item \textbf{Step 5}: If a transaction is marked as valid after passing the three checks, it will be added to the new block and the ledger is updated by applying the transaction write sets, else invalid transactions will be rejected.
\end{itemize}
\subsection{Endorsements Policies} \label{sec:epolicy}
Hyperledger Fabric allows developers to set policies at the chaincode level. The endorsement policies are rules which specify which peers can agree on the transaction execution before it is added to the ledger. In general, endorsement policies are configured while installing the chaincode and can be modified only during a chaincode upgrade. Once the client creates the transaction, it sends a transaction proposal to all endorsing peers that satisfy the endorsement policy \cite{Manevich2018ServiceFabric} and waits for the proposal responses. When the client receives enough responses and signatures to satisfy the endorsement policy of the chaincode, it can submit the transaction with the endorsement signatures to the ordering services. Endorsement policies can be defined as follow:
\begin{itemize}
\item \texttt{AND('Org1.member','Org2.member')}: the client needs one signature from each organization to be able to submit a transaction
\item \texttt {OR('Org1.member','Org2.member')}: the client needs one signature from either one of the two organization to be able to submit a transaction
\item \texttt{OR('Org1.member',AND('Org2.member' ,'Org3.member'))}: the client needs either one signature from a member of the Organization1 or one signature from a member of the Organization2 and one signature from a member of the Organization3
\item \texttt {Out-Of(2,'Org1.member', 'Org2.member','Org3.member')}: At least two of the three organization must endorse the transaction to be valid. It is equivalent to \texttt{OR(AND('Org1.member','Org2.member') ,AND('Org1.member','Org3.member'), AND('Org2.member','Org3.member'))}
\end{itemize}
In the scope of this paper, we study the first two examples (AND, OR) for our solution, however types 3 and 4 have been studied but are not included in this paper due to lack of space. Furthermore, we assume that each client will select endorsing peers randomly if given the choice in accordance to the policy.
\begin{figure*}[htbp]
\centering
\includegraphics[width=0.6\textwidth]{MVCC.png}
\caption{MVCC Read-Write Conflict Example} \label{fig:Figure2}
\label{fig}
\end{figure*}
\subsection{Multi-Version Concurrency Control Read-Write Conflict (MVCC)} \label{sec:mvcc}
Hyperledger Fabric uses a Multi-version concurrency control system to ensure the consistency of the ledger. This mechanism validates that the versions of keys read at the endorsement time of the transaction are still the same at the validation phase \cite{Larson2012High-PerformanceDatabases}. This process guarantees that there are no reads of old values that have been changed by another concurrent transaction. During the time period between the endorsement and the validation phase, if another transaction has updated the version of the keys listed in the read set, the transaction will fail at the MVCC validation.
The multi-version concurrency control read-write conflict is a problem that occurs when two clients try to update and read the same key at the same time. Fig.\ref{fig:Figure2} shows an example of this conflict. Let’s assume that \textit{user1} submits \textit{TX1}, and at the same time \textit{user2} submits \textit{TX2}, the two transactions will read and update the same value \textit{Value1} of \textit{Key1}. After endorsing and ordering simultaneously the transactions, \textit{TX1} will be validated and its write set will be applied to the ledger resulting in the modification of the value and version associated with \textit{Key1} to \textit{value1} and \textit{version1}. However, when \textit{TX2} underwent the MVCC validation, it fails because the version of \textit{Key1} in the read set of the transaction is not the same in the ledger. Therefore, the MVCC validation detects the inconsistency between the ledger and the endorsement result and return an MVCC error.
\section{RELATED WORKS}\label{RELATEDWORK}
Hyperledger Fabric is a relatively new system that is already experiencing some major architectural improvements. The majority of related work aims to improve the throughput and minimize the latency of the network, but there is a lack of effective solutions to deal with the MVCC problem and in most cases, the transaction conflict factor is not considered in the evaluation results. In this section, we review recent research on techniques to improve the Hyperledger Fabric performances. We will review this works along three categories: works that optimize endorsement phase, works that improve the ordering phase, and works that enhance the validation phase.
\subsection{Endorsement Phase Optimization}
The work done by \cite{Kwon2019} is aiming to improve the read transaction processing by distinguishing between reading and writing transactions during the endorsement process. As a result, the transaction endorsement latency is reduced by 60\% compared to the traditional fabric network. This approach is complementary to our own solution since early detection can still be applied to further reduce the latency of failed transactions.
\subsection{Ordering Phase Optimization}
For the ordering phase, \cite{Istvan2018} propose the elimination of the concept of blocks in favor of processing transactions in streaming to decrease the batching overhead. Also, the authors implement an FPGA-based (Field Programmable Gate Array) consensus for the ordering service that decreases the commit latency below a millisecond by cutting latency in half compared to the Raft-based ordering service.
The authors of Fast Fabric \cite{Gorenflo2019} redesign the fabric ordering service to work with only the transaction IDs by Separating the transaction header from the payload to decide the transaction order only with the transaction’s IDs which makes transaction processing in the ordering services faster which increase the throughput.
\cite{Sharma2019} propose Fabric++ a solution that aims to reduce the MVCC failure rate by reordering transactions at the ordering phase using a conflict graph to abort the transaction that cannot be serialized.
\cite{Ruan2020} designed an optimized extension of Fabric++ that can handle both inter-block and intra-block MVCC read conflicts.
Our solutions detect the MVCC conflict at the endorsement phase, however, Fabric++ and FabricSharp aim to reorder transactions in the ordering phase to avoid the maximum number of conflicts.
\subsection{Validation Phase Optimization}
Multiple articles propose the parallel execution of the validation process (syntax verification, endorsement policy verification, MVCC validation) to accelerate the block validation \cite{Gorenflo2019a,Gorenflo2019,Istvan2018,Javaid2019,Thakkar2018}.
FabricCRDT focuses on automatically merging the conflicting transactions using CRDT techniques without rejecting them~\cite{Nasirifard}.
\cite{Istvan2018} introduce a disk writes batching mechanism by using a local batcher that accumulates the ledger update operations until reaching a batch size or batch time out to write to the database.
Finally, \cite{Meir2019} presented a lock-free solution for providing transaction isolation, this approach allows the removal of the shared lock while ensuring transaction isolation.
The proposed improvements of the validation phase are based on the parallelization of validation processes or the optimization of reading and writing operations on the databases. All of these works offer useful insights into various techniques that can improve the Hyperledger Fabric performance and represent a complementary improvement to our proposed solution.
\subsection{MVCC in database systems}
MVCC is one of the most studied problems in the database community which is reused in blockchain systems. This problem is addressed by several works such as the work of \cite{Larson2012High-PerformanceDatabases} who propose two optimized MVCC mechanisms for in-memory databases. Compared to single-version locking, the proposed schemes have higher overhead but are much less sensitive to hotspots and the presence of long-running transactions. Also, \cite{Faleiro2015} introduce the BOHM, a concurrency control mechanism for main-memory multi-versioned database systems ensuring that reads operations never block writes. These proposed solutions can serve to improve the databases-based blockchain systems. However, our proposed solution is preventive because it deals with the MVCC problem before it occurs at the validation phase.
\section{EMVCC Detection \& Solution}\label{OURSOLUTION}
\begin{figure*}[t]
\centering
\includegraphics[width=1\textwidth]{EMVCC_FLow.png}
\caption{EMVCC Detection Mechanism} \label{fig:Figure3}
\label{fig}
\end{figure*}
In this section, we formulate the problem of MVCC detection at the endorsement phase. We then describe our proposed solutions called early MVCC detection, and present the different possible caching data structures. Also, we present a theoretical analysis of different endorsement policies.
\subsection{System Model}
In this section, we will use the following model: given an Hyperledger Fabric\footnote{Our solution has been tested with Fabric version 2.0 and higher.} network containing $N$ organizations where each organization has $M$ peers and $M_i$ is the number of peers for organisation $i$. The system uses $Nb_{Tx/Block}$ as the number of transactions per block. The ordering services of the system can use any consensus protocol available in Hyperledger Fabric (e.g., Raft, Kafka, Solo). The chaincode executed by the application generates $\%cfct$ as the conflict rate representing the percentage of transactions which abort due to an MVCC conflict error. Intuitively speaking, a chaincode where transactions read and write to a few shared keys will have a higher conflict rate than that of a chaincode where transactions are independently working on disjoint keys. In order to store chain state, the system can be implemented using any of the available databases compatible with Hyperledger Fabric (CouchDB, LevelDB, etc.).
\subsection{Problem Formulation} \label{sec:pbform}
The problem we are solving is detecting MVCC conflict by filtering the transactions at the \textit{endorsement phase} based on the endorsed transactions history of each endorsing peer. This is in contrast to the current problem resolved by Fabric, which is that of detecting MVCC conflicts at the \textit{validation phase}, which occurs later in the transaction flow.
We start by defining some basic terms that we will use later:
\begin{itemize}
\item \textbf{Probability of non-detection:} This is a metric to evaluate the performance of our solution. A perfect solution would have a $\mathcal{P}(ND)=0$. It represents the probability that our proposed solution does not detect a conflicting transaction at the endorsement phase, even though it has a conflict with another transaction, such that the MVCC conflict is only detected later at the validation phase.
\item \textbf{False positives:} We call a false positive a transaction which is wrongly declared invalid using our solution, but would have been successfully confirmed using the standard approach. This can occur if our solution is overly aggressive in detecting conflicts and will prematurely abort transactions which have a chance to be successful, which would force the client to retry the entire endorsement process with a new transaction. The false positive rate can be calculated as follows:
\begin{equation}\label{eq1}
\resizebox{0.8\hsize}{!}{$%
FP= \frac{Tx/Block \times \%cfct^2 \times \mathcal{P}(ND) \times (1-\mathcal{P}(ND))} {\%cfct \times \mathcal{P}(ND) - \%cfct + 1}
$%
}%
\end{equation}
where ${Tx/Block}$ is the number of transactions per block, $\mathcal{P}(ND)$ is the probability of non-detection and $\%cfct$ is the conflict rate
\item \textbf{False negatives:} It is the opposite error where a transaction is declared valid at the EMVCC validation stage while it has conflicts with another transaction resulting in its failure later on. Ideally, the number of false negatives should be equal to zero.
\begin{equation}\label{eq2}
FN= TX\_rate \times \%cfct \times \mathcal{P}(ND)
\end{equation}
\item \textbf{Goodput}\cite{Yu2018CoinExpress:Networks} is the rate of successful transactions that the network can write into the blockchain. In contrast, the throughput of the network is the rate of total transactions which passed through the ordering phase, including transactions which will be aborted due to MVCC conflicts. Ideally the goodput should be equal to the throughput. In a standard Fabric implementation, the goodput is directly impacted by the MVCC conflict rate, since any aborted transaction is still part of a proposed block. Our solution can prevent such conflicts from being reflected inside the blockchain by detecting them prior to the ordering phase and thus improve the goodput.
We can calculate it as follows:
\begin{equation}\label{eq3}
\resizebox{0.7\hsize}{!}{$%
goodput=\frac{Nb\_valid\_TX}{Nb\_TX} \times Throughput
$%
}%
\end{equation}
\end{itemize}
\subsection{Proposed Solution}\label{sec:propsol}
In the current implementation of Fabric, a conflicting transaction passes through the network and eventually fails, thereby consuming unnecessary resources. In our proposed solution, we add a layer to filter transactions at the endorsement phase to abort any detected conflicting transactions. We call our approach Early Multi-Version Concurrency Control (EMVCC).
As described in Fig.\ref{fig:Figure3}, our EMVCC solution operates after Fabric executes the chaincode and generates the read/write sets, and before an endorsement response is sent back to the client. Our EMVCC solution will compare the read set to a list of pending transactions stored in the peer’s local cache. This cache is populated with transactions currently in progress this peer has previously endorsed which have not yet been confirmed (or aborted).
If a transaction reads a key that is stored in the cache, the transaction will be aborted since an instance of early MVCC conflict was detected. If not, the transaction is stored in the local cache and an endorsement is sent as usual back to the client. Once the transaction is validated or rejected at the validating phase, the cache is updated by removing the keys of the write set of this transaction.
Note that the usual MVCC phase is still performed during the validation phase, since our EMVCC does not detect conflicts perfectly (see Section~\ref{sec:thAnalysis}). This allows the regular validation phase to catch any MVCC conflicts that are not detected through our EMVCC solution, thereby maintaining correctness of the EOV (Execute-Order-Validate) execution flow.
\begin{figure}[t]
\centering
\includegraphics[width=0.48\textwidth]{pic0.png}
\caption{EMVCC Detection Example} \label{fig:EMVCCExample}
\label{fig}
\end{figure}
Fig.\ref{fig:EMVCCExample} shows an example of how EMVCC detection works. Suppose that we have a Fabric network composed of two organizations, each organization having two peers. The chaincode endorsement policy is AND (Org1,Org2). Suppose that \textit{client1} submits \textit{TX1} which writes on \textit{Key1} and \textit{Key2}. This transaction is endorsed by \textit{Peer0.ORG1} and \textit{Peer0.ORG2}. Now suppose we have a transaction \textit{TX2} which reads \textit{Key2} and writes on \textit{Key3}. If this transaction is endorsed by \textit{Peer0.ORG1} or \textit{Peer0.ORG2}, it will be aborted at the endorsement phase because \textit{TX1} is in the EMVCC cache of \textit{Peer0.ORG1} or \textit{Peer0.ORG2}. Suppose another transaction \textit{TX3} arrives which writes on \textit{Key1} and reads \textit{Key2}. If it is endorsed by \textit{Peer1.ORG1} and \textit{Peer1.ORG2}, it will not be detected by the EMVCC detection mechanism because these peers does not have any conflict with this keys in their EMVCC cache. However, it will still fail later on at the MVCC validation phase.
\subsection{Theoretical Analysis of Non-Detection}\label{sec:thAnalysis}
Since our approach is lightweight in nature and only uses local caching without resorting to any synchronization, it is possible for a conflicting transaction to pass the EMVCC phase undetected. This can happen if the subset of peers chosen to endorse the current transaction have not previously endorsed a pending transaction which conflicts with it. Thus, the endorsement policy, as well as the number of peers and the number of organisations, have a direct impact on the probability of non-detection of our proposed EMVCC solution.
In order to assess the performance of our solution, we present a analytical model which calculates the expected probability of non-detection for our solution using the AND and OR endorsement policies. These theoretical results will be compared to the real results in Section \ref{EXPERIMENTS} to validate the correctness of our implementation. For this analysis, we assume the selection of peers (and organisations) is done uniformly at random when a client is presented with a choice of multiple peers (or organisations) to satisfy the endorsement policy, as it is currently implemented in Hyperledger Fabric \cite{Manevich2018ServiceFabric}. Due to the lack of space, we defer the full details of our mathematical formulas derived here to our extended report.
\subsubsection{Non-Detection in the AND Endorsement Policy}
Using the AND endorsement policy, the probability of non-detection can be calculated as follows:
\begin{equation}\label{eq4}
\mathcal{P}(ND) = \prod_{n=1}^{N} \frac{(M_i-1)}{M_i}
\end{equation}
where N is the number of organizations and $M_i$ is the number of peers per organization
Fig.\ref{fig:FigureAND} plots the theoretical evolution of the probability of non-detection of the EMVCC solution for various organizations and peer numbers using AND endorsement policy. We observe that the probability of non-detection decreases when the number of organizations increases, however, it increases when the number of peers per organization increases.
\begin{figure}[t]
\includegraphics[width=0.45\textwidth]{AND.png}
\caption{Probability of Non-Detection using AND} \label{fig:FigureAND}
\label{fig}
\end{figure}
\subsubsection{Non-Detection in the OR Endorsement Policy}
We also analyze the evolution of the probability of non-detection using the OR endorsement policy, it can be calculated using the following formula:
\begin{equation}\label{eq5}
\mathcal{P}(ND)=\left\lbrace
\begin{array}{ll}
\frac{NM-1}{NM}& \mbox{if $M_i$=$M_{i+1}$}\\
\frac{1}{N} {\sum\limits_{i=1}^N \frac{1}{M_i}} & \mbox{else}
\end{array}
\right.
\end{equation}
where N is the number of organizations and $M_i$ is the number of peers per organization
Fig.\ref{fig:FigureOR} illustrates the theoretical evolution of the probability of non-detection for different organizations and peers’ numbers using OR endorsement policy. We identify that the probability of non-detection increases when the number of organizations or the number of peers increases due to the lack of synchronization between nodes caches.
\begin{figure}[t]
\includegraphics[width=0.45\textwidth]{OR.png}
\caption{Probability of Non-Detection using OR} \label{fig:FigureOR}
\label{fig}
\end{figure}
\subsection{Choice of Caching Data Structure} \label{sec:datastruc}
For the local cache maintained by each peer, we propose three different techniques in our reference implementation:
\textbf{MutexLock}: In this implementation, we are using a lock-based data structure to ensure cache consistency while using a multithreaded system \cite{Alexandrescu2007Lock-FreeStructures}. For example, when an endorser reads or writes on the cache, it will be locked and the validator cannot update this entry in the cache. The main disadvantage of this approach is that the locking system adds a delay to the read and write operations since some threads have to wait until a lock is released.
\textbf{LockFree}: With this approach, more than one thread can access the cache concurrently. The read and writes operations are stored in a buffer then once the buffer threshold is reached, the batch is applied to the cache which guarantees that the majority of threads make progress at each step \cite{Alexandrescu2007Lock-FreeStructures}. This technique is useful to decrease the number of times a lock is acquired or released.
\textbf{SyncMap}: Sync Map is an optimized and safe data structure, which is part of the sync package since Golang 1.9. It uses a dirty map to write new values or updates allowing the read operation to be done without a lock. However, the Mutex locking is essential if numerous concurrent threads (\textit{goroutines}) are writing concurrently in the dirty map and the read-only map is updated by a batch of operations from the dirty map.
\section{BENCHMARKING RESULTS}\label{EXPERIMENTS}
In this section, we evaluate the effectiveness of our proposed EMVCC solution using three different cache implementations: Mutex Lock, LockFree, and SyncMap. We first compare our three different implementations against the standard Fabric implementation as a baseline. We then perform a sensitivity analysis to study the influence of certain system parameters and workload characteristics on the system performance. Table \ref{tab:tab1} shows the default used parameters for our experiment. We use 500 transactions per block as the block size and a block time of 2 seconds which are the ordering parameters that lead to the highest throughput from our experiential testing (see Section~\ref{subsec:sa}). Furthermore, we use a conflict rate of 40\% because in realistic scenarios it represents the percentage of failed transactions due to concurrency conflict \cite{Chacko2021WhyVersion}. We chose the Raft consensus over the the two alternative ordering services because the solo mode is recommended only for development and testing purposes \cite{Wang2020PerformanceFabric} and Kafka is deprecated in versions 2.x of Fabric. We also chose 3 ordering services nodes to satisfy the trade-off between the cost of the network and its performance.
\subsection{Test Environment Characteristic}
Our cluster consists of six E2 virtual machines hosted on the Google Cloud Platform. Two machines serve as two peers and three machines running the ordering services with a raft consensus algorithm. The other virtual machine serves as clients by running the Hyperledger Caliper \cite{Wickboldt2019BenchmarkingSystem} benchmarking tool. Each virtual machine has 8 vCPUs (Virtual Central Processing Unit) and 32 GB of RAM. All the virtual machines are running Ubuntu 16.04 as an operating system. The Fabric peers are set up to use our modified version of Hyperledger 2.3 images and CouchDB as the state database. For the chaincode, we use the Fabcar chaincode which allows us to create a car on the blockchain and modify its owner.
\subsection{Performances Metrics}
The main metrics for our benchmarking are:
\begin{enumerate}
\item \textbf{Goodput}: the effective throughput of committed transactions written to the blockchain excluding the aborted ones (Section \ref{sec:pbform}).
\item \textbf{Latency}: the time between the initial request by the client of the transaction and its final commit to the ledger.
\item \textbf{EMVVC vs. MVCC rate}: the percentage of rejected transactions due to an EMVCC error versus the percentage of rejected transactions due to an MVCC error.
\item \textbf{TD EMVCC and TD MVCC}: the time-to-detect is the total time duration between the submission of the transaction by the client and its rejection by an MVCC or EMVCC error.
\end{enumerate}
\begin{figure*}
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\linewidth]{pic1.png}
\caption{Throughput Comparison With The Baseline Solution}
\label{fig:Comparaison}
\end{subfigure}
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\linewidth]{pic2.png}
\caption{Latency Comparison With The Baseline Solution}
\label{fig:latency}
\end{subfigure}
\caption{Comparison With The Baseline Solution}
\end{figure*}
\subsection{Comparison With The Baseline Solution}
In this section, we compare our proposed solutions with version 2.3 of Hyperledger Fabric. The throughput and transaction latency are averaged over ten runs.
\begin{table}[]
\centering
\caption{Default Evaluation Parameters} \label{tab:tab1}
\begin{tabular}{|l|l|}
\hline
\textbf{Parameters} & \textbf{Values} \\ \hline
\textbf{Block size} & 500 TXs \\ \hline
\textbf{Block time} & 2 seconds \\ \hline
\textbf{Number of organizations} & 2 \\ \hline
\textbf{Number of peers per organization} & 2 \\ \hline
\textbf{Ordering Consensus} & Raft (3 Orderers) \\ \hline
\textbf{MVCC Conflict rate} & 40\% \\ \hline
\textbf{Endorsement Policy} & AND(Org1,Org2) \\ \hline
\end{tabular}
\end{table}
Fig.\ref{fig:Comparaison} plots the average throughput for three implementations and the Hyperledger Fabric. The three proposed solutions are better than the Fabric baseline, the best solution being SyncMap with a 23.2\% of goodput improvement compared to Fabric. For Mutex Lock and LockFree, the percentage of improvement is 20.4\% and 21.2\%, respectively. Also, Fig.\ref{fig:latency} plots the average latency for the three implementations and the baseline. Similarly, the three implementations reduce latency compared to the baseline: for SyncMap and LockFree, the latency is reduced by 80\%, and for MutexLock by 69\%. This is due to the early detection of the conflicting transaction at the endorsement instead of going until the validation phase to be aborted. We thus conclude that SyncMap is the best data structure for our early MVCC cache implementation because it is the best for read operations when the the peer has multiple vcPUs.
\subsection{Sensitivity Analysis}
\label{subsec:sa}
In this section, we analyse the impact of various network and workload parameters on the performance metrics such as the conflict rate, endorsement policies, and compute resources per peer, etc.
\subsubsection{Impact of Conflict Rate}
The conflict rate is the most important parameter that can show us the utility of our proposed solution. In Fig. \ref{fig:conflict}, we plot the average goodput for Fabric and our different solutions over different values of conflict rates. As expected, with an increase in the conflict rate, the goodput decreases because we are increasing the number of failed transactions until we reach a 100\% conflict rate where the goodput becomes zero. Also, we can see that the three proposed solutions perform better than Fabric for different values of the conflict rate. SyncMap is the best one, since it is improving the goodput by 10\% when the conflict is around 20\% and its impact is more important by exceeding 20\% to reach an improvement of 23\% at a conflict rate of 40\%. The relative performance of this solution increases over the baseline as the conflict rate increases for an application.
\subsubsection{Impact of Compute Resources per Peer}
In this part, we will analyze the impact of adding or removing vCPUs to each peer. We vary the number of CPU from 2 vCPUs to 8 vCPUs. Fig.\ref{fig:figA} plots the average throughput and goodput and Fig.\ref{fig:figB} plots the average latency for our three implementations and the Hyperledger Fabric baseline for various vCPU numbers per peer. With an increase in the number of vCPUs per peer, the goodput increases and the latency decreases. Our three solutions are better than the baseline at varying numbers of vCPUs. However, we observe that with 8 vCPUs, there is a significant improvement of 23\% for goodput and 65\% for latency between SyncMap and the baseline. Thus, we conclude that our solutions are able to better leverage additional computational resources than the Fabric baseline.
\begin{figure*}[h!]
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic3.png}
\caption{MVCC Conflict Rate vs. Goodput}
\label{fig:conflict}
\end{subfigure}
\centering
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic7.png}
\caption{vCPUs vs. Throughput}
\label{fig:figA}
\end{subfigure}
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic6.png}
\caption{vCPUs vs. Latency}
\label{fig:figB}
\end{subfigure}
\centering
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic4.png}
\caption{Block Size vs. Throughput}
\label{fig:figC}
\end{subfigure}
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic5.png}
\caption{Block Size vs. Conflict Rate}
\label{fig:figD}
\end{subfigure}
\centering
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic8.png}
\caption{Impact of AND Policy}
\label{fig:figE}
\end{subfigure}
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic9.png}
\caption{Impact of OR Policy}
\label{fig:figF}
\end{subfigure}
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic10.png}
\caption{Time To Detect EMVCC/MVCC}
\label{fig:figX}
\end{subfigure}
\centering
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic11.png}
\caption{Conflict Skewness}
\label{fig:zipf}
\end{subfigure}
\caption{Sensitivity Analysis Results}
\end{figure*}
\subsubsection{Impact of Block Size}
We analyse the impact of the block size by varing the block size from 100 transactions per block to 500 transactions per block. Fig.\ref{fig:figC} plots the average throughput and goodput for Fabric and our three implementations over various block sizes. Increasing the block size increases the throughput and goodput for all solutions because the use of larger blocks will cause less overhead and fewer network communications. The SyncMap method is offering an average improvement of 12\% compared to Fabric over different block sizes which confirms that our proposed solutions are scalable with different block sizes. Fig.\ref{fig:figD} plots the conflict rate for Fabric and our three methods over various block sizes. We can observe that with an increase in the block size the conflict rate increases: this is due to the increase of the number of intra-block conflicts when the block contains a higher number of transactions. One other observation that can be made is that the conflict rate for Fabric is less than our proposed implementation: this is because there are some false positives and negatives caused by the early MVCC detector.
\subsubsection{Impact of Endorsement Policies and Network Topology}
For this experiment, we use different network topologies by varying the number of peers per organization from one peer to three peers. Fig.\ref{fig:figE} and Fig.\ref{fig:figF} plot the average throughput and goodput, as well as the percentage of transaction failure, caused by EMVCC and MVCC validation for different network topologies using AND (Org1, Org2) and OR (Org1, Org2) endorsement policies for the Fabric baseline and SyncMap solutions. We observe that the type of endorsement policy impacts the network performances. As shown in the two figures, the throughput for the OR endorsement policy is higher than the throughput using the AND policy because using OR the transaction needs less peer endorsement than the AND. For the percentage of non-detection, these experimental results confirm the theoretical results presented in Section \ref{OURSOLUTION}. For example, with AND Policy and using a network with two organizations each one has two peers, we have 22\% of conflicting transactions that were not detected at the EMVCC and were aborted at the MVCC validation (false negative). We can also see that increasing the number of peers increases throughput and goodput for both endorsement policies as the organizations have more resources to process transactions. We can also observe that the increase in the number of peers per organization increases the rate of false positives. The improvement when the AND policy is used is more important compared to Fabric. However, with OR policy, the number of false positives increases which impacts the solution’s performance. We can conclude that with an increase in the number of endorsers our solution becomes more efficient.
Fig.\ref{fig:figX} plots the average time to detect EMVCC/MVCC over different network topologies using OR and AND endorsement policies. The duration of the transaction execution is reduced by 95\% between aborting a conflicting transaction at the EMVCC phase and processing it until reaching the MVCC validation phase to be rejected that is why our solutions reduce significantly the transaction latency. We note that when the number of peers per organization increases, the time to detect MVCC decreases due to the availability of computational resources.
\subsubsection{Impact of Chaincode Implementation}
To simulate another chaincode behavior, we use the Zipf distribution, which allows us to choose the keys used to simulate transactions by varying the parameter \textit{s} of the distribution from 0 to 2. By increasing \textit{s}, we are increasing the preference to use certain same keys which increase the conflict rate. Fig.\ref{fig:zipf} plots the average goodput for the Fabric, SyncMap, LockFree, and MutexLock solutions over different values of the parameter \textit{s} of the Zipf distribution. We can see that when \textit{s} increases the conflict rate increases causing the goodput to decrease. As expected, when the s parameter increases our solutions perform better than Fabric. For example, SyncMap improves the goodput by 24\% for \textit{s} equal to 1 and 35\% for \textit{s} equal 1.5.
\subsection{Summary and Discussions of Findings}
Our three proposed solutions perform better than the Fabric baseline. SyncMap is the best data structure to implement the cache for keys storing. The improvement rate compared to Fabric is mostly determined by the used endorsement policies, the network design, and the chaincode implementation (conflict rate). In realistic scenarios, where 40\% of the transactions failed due to MVCC conflict, the SyncMap solution improves the throughput by 23\% and reduces the latency by 80\%.
When using our solution, we recommend developers to use the AND endorsement policy with a maximum number of organizations and the minimum number of peers per organization if the business logic allows that. However, when they have to use the OR endorsement policy, we recommend that they use the minimum number of organizations and number of peers per organization. The block size should be adjusted carefully to minimize the inter-block and intra-block transactions conflict in order to maximize the goodput. For the chaincode implementation, it is important to write a chaincode that ensures a conflict rate lower than 40\%. This solutions can be useful to optimize the performances of other blockchain using the EOV approach.
\section{CONCLUSIONS}\label{CONCLUSIONS}
In this work, we propose a mechanism to improve Hyperledger Fabric performances aiming to early abort transactions that have no chance to be validated and committed to the ledger using different caching techniques. In an experimental evaluation, we compare SyncMap, LockFree, and MutexLock to the basic version of Fabric. We also did a sensitivity analysis by varying configurable parameters such as block size, endorsement policies, and resource allocation. We show that the proposed solutions outperform Fabric and SyncMap which is the best-proposed method that improves the throughput by up to 20\% and reduces the latency by up to 80\% compared to Fabric.
\bibliographystyle{unsrt}
\section{INTRODUCTION}
Hyperledger Fabric is a popular permissionless system that allows the development of blockchain applications in a variety of domains such as finance, healthcare, and supply chain management. Compared to Ethereum \cite{Buterin2014} and Bitcoin \cite{Kornmesser2008}, Fabric offers superior performance, due to the consensus algorithm used and the small number of peers on the network compared to public blockchains. Furthermore, Fabric provides a flexible framework for managing responsibilities across parties using the MSP (membership service provider) which is an abstract component that maintains the identities and roles of all nodes that belong to the same organization.
Most existing blockchain platforms such as Ethereum and Hyperledger Fabric allow Turing-complete computations by executing a smart contract for a given transaction \cite{Zheng2020AnPlatforms}.
To guarantee consistency across the network, peers execute transactions to generate the next state of the blockchain after the content of the next block is known (which transactions to execute, and in what order): this is called the Order-Execute (OX) transaction flow \cite{Androulaki2018}. The weaknesses of the OX pattern is that the sequential execution of the transactions within each block limits the throughput of the system. Furthermore, each peer requires knowledge of all smart contracts to compute the next state of the blockchain, which may present confidentiality and privacy issues.
Instead, Fabric employs the Execute-Order-Validate (EOV) pattern, where the transactions are executed in a sandbox called endorsing peers to generate the read-write sets including the versions of the used keys for the transaction's simulation, then the transactions are ordered by the ordering services into blocks, and at the end validated and committed to the ledger. EOV overcomes the limitations of OX by providing parallelism of transactions execution on different endorsing peers.
The drawback of the EOV pattern is that a read-write lock is used to synchronize the execution and validation phases. To solve this issue, Hyperledger Fabric implements a Multi-Version Concurrency Control mechanism to guarantee the consistency of the blockchain. When validating transactions by the validating peers, the versions of the generated read-write sets are compared to the keys’ versions of the ledger to avoid that two transactions attempt to modify/read the same key/value pairs at the same time. A transaction will be rejected if its read set contains an old version of a key and the client has to resubmit it.
The aforementioned MVCC (Multiversion Concurrency Control) conflict problem is a well-documented limitation of Hyperledger Fabric as it decreases the effective throughput of the system (also known as goodput). This is because the blocks could contain aborted transactions which still count against the size limit, thereby wasting valuable block space. These aborted transactions must also be retried by their respective clients as brand new transactions, which generates additional load on the system. In practice, the MVCC problem can have a serious impact on the performance of the blockchain, as recent studies show that in realistic scenarios such as electronic health records, 40\% of the transactions failed due to concurrency conflict \cite{Chacko2021WhyVersion}. Prior works seek to address or mitigate the MVCC problem by using a lockless approach to provide transaction isolation \cite{Meir2019} or reordering transactions at the ordering phase to minimize the conflict rate when validating and committing transactions to the ledger \cite{Sharma2019} \cite{Ruan2020}.
In our paper, we present a novel approach to solve the MVCC problem called \textit{Early Detection of MVCC Conflicts} (EMVCC). We introduce an EMVCC detection mechanism that aims to reduce the number of conflicts between transactions which increases the overall system goodput. The advantage of our solution over existing works is that the MVCC conflict is detected at the first contact of the transaction with the blockchain network at the endorsement policy allowing to improve the network performances.
The contributions of our paper are as follows:
\begin{enumerate}
\item We provide the formulation of the problem of early detection of conflicting transactions at the endorsement phase, rather the traditional approach of handling MVCC conflicts at the validation phase (Section \ref{sec:pbform}).
\item We propose a novel solution called Early Detection of MVCC Conflicts using local caching at endorsing nodes (Section \ref{sec:propsol}). We provide a theoretical analysis of our solution to calculate the expected effectiveness of the solution depending on parameters such as the endorsement policy, number of organisations, etc. (Section \ref{sec:thAnalysis}).
\item We present three reference implementations of our solution: SyncMap, Lock-Free, and Mutex Lock, their main difference is the data structure used for information storing (Section \ref{sec:datastruc}).
\item We evaluate our solution and compare it to the baseline and we did a sensitivity analysis to study the impact of different network and load parameters on the performances (Section \ref{EXPERIMENTS}).
\end{enumerate}
The paper now continues with Section \ref{BACKGROUND} that gives an overview of the Hyperledger Fabric. This is followed by Section \ref{RELATEDWORK} where we describe prior works related to the MVCC problem.
\section{BACKGROUND}\label{BACKGROUND}
In this section, we give an overview of Hyperledger Fabric Components, we detail the transaction flow and we present the endorsement policies and Multi-Version Concurrency Control Read-Write Conflict (MVCC).
\subsection{Hyperledger Fabric Components}
Hyperledger Fabric is a permissioned distributed ledger system specialized for business applications. Its modular architecture makes blockchain solutions confidential, resilient, and flexible. Hyperledger Fabric has multiple fundamental components such as the client and the peers which are the endorsing peers and the committing peers. In this paper, we will focus on these components as they are the only components affected by our solutions.
\subsubsection{Clients}
Clients are applications or software that operate on behalf of a user to submit transactions on the Fabric network through the Hyperledger Fabric SDK.
\subsubsection{Peers}
Peers are a fundamental component of the network because they keep records of the network’s state and a copy of the ledger. Each peer on the network belongs to an organization that may have one or more peers. The administrator can create, start, stop or reconfigure the peer. To be part of the network, the node should join the shared channel between all the participants. There are two types of peers, endorsing peers and validating/committing peers. In a typical scenario, every Fabric peer typically fulfill both roles of endorsing and validating.
\textbf{Endorsing peers}: this type of node hosts the smart contract executed to simulate transactions and endorse them using the peer signature. When installing the chaincode (smart contract), the administrator specifies which peers will endorse the transactions by defining the endorsement policy rules.
\textbf{Validating/Committing peers}: they are responsible for the VSCC (Validation System Chaincode) used to validate the endorsement policies and the MultiVersion Concurrency Control (MVCC) validation to ensure that the version of the keys read during the endorsement phase is still the same in the ledger to guarantee the deterministic execution of the transaction. Then the committing peers add blocks to the shared ledger and update the blockchain world state.
\subsection{Transaction Flow}
\begin{figure*}[ht]
\centering
\includegraphics[width=\textwidth]{Transaction_Flow.png}
\caption{Transaction Flow}\label{fig:Figure1}
\end{figure*}
Fig.\ref{fig:Figure1} shows the basic transaction flow in Hyperledger Fabric. It consists of five steps:
\begin{itemize}
\item \textbf{Step 1}: A client who wants to make a transaction sends a transaction proposal containing the chaincode function and arguments that the client wants to invoke, to the endorsing peer according to the chaincode endorsement policies (see the next Section \ref{sec:epolicy}).
\item \textbf{Step 2}: An endorser receives the transaction proposal, executes the chaincode, and generates the read/write sets which are the sets containing the values and versions of the keys which are read or written while executing the transaction, then the peer creates the proposal response, signs it and sends the response to the client.
\item \textbf{Step 3}: Once the client collects the required number of endorsements as defined in the endorsement policies, he sends the transaction to the ordering services, this operation contains details about the initial proposal as well as all peer endorsements and read/write sets. The ordering services order transactions received from clients into a block considering the block BatchSize and block BatchTimeout, then the block is created and delivered to the validating peer.
\item \textbf{Step 4}: Upon receiving the block, the committing peer iterates over all the transactions within the block to perform the syntax validation of each transaction, the VSCC validation, and the MVCC validation (see the next Section \ref{sec:mvcc}).
\item \textbf{Step 5}: If a transaction is marked as valid after passing the three checks, it will be added to the new block and the ledger is updated by applying the transaction write sets, else invalid transactions will be rejected.
\end{itemize}
\subsection{Endorsements Policies} \label{sec:epolicy}
Hyperledger Fabric allows developers to set policies at the chaincode level. The endorsement policies are rules which specify which peers can agree on the transaction execution before it is added to the ledger. In general, endorsement policies are configured while installing the chaincode and can be modified only during a chaincode upgrade. Once the client creates the transaction, it sends a transaction proposal to all endorsing peers that satisfy the endorsement policy \cite{Manevich2018ServiceFabric} and waits for the proposal responses. When the client receives enough responses and signatures to satisfy the endorsement policy of the chaincode, it can submit the transaction with the endorsement signatures to the ordering services. Endorsement policies can be defined as follow:
\begin{itemize}
\item \texttt{AND('Org1.member','Org2.member')}: the client needs one signature from each organization to be able to submit a transaction
\item \texttt {OR('Org1.member','Org2.member')}: the client needs one signature from either one of the two organization to be able to submit a transaction
\item \texttt{OR('Org1.member',AND('Org2.member' ,'Org3.member'))}: the client needs either one signature from a member of the Organization1 or one signature from a member of the Organization2 and one signature from a member of the Organization3
\item \texttt {Out-Of(2,'Org1.member', 'Org2.member','Org3.member')}: At least two of the three organization must endorse the transaction to be valid. It is equivalent to \texttt{OR(AND('Org1.member','Org2.member') ,AND('Org1.member','Org3.member'), AND('Org2.member','Org3.member'))}
\end{itemize}
In the scope of this paper, we study the first two examples (AND, OR) for our solution, however types 3 and 4 have been studied but are not included in this paper due to lack of space. Furthermore, we assume that each client will select endorsing peers randomly if given the choice in accordance to the policy.
\begin{figure*}[htbp]
\centering
\includegraphics[width=0.6\textwidth]{MVCC.png}
\caption{MVCC Read-Write Conflict Example} \label{fig:Figure2}
\label{fig}
\end{figure*}
\subsection{Multi-Version Concurrency Control Read-Write Conflict (MVCC)} \label{sec:mvcc}
Hyperledger Fabric uses a Multi-version concurrency control system to ensure the consistency of the ledger. This mechanism validates that the versions of keys read at the endorsement time of the transaction are still the same at the validation phase \cite{Larson2012High-PerformanceDatabases}. This process guarantees that there are no reads of old values that have been changed by another concurrent transaction. During the time period between the endorsement and the validation phase, if another transaction has updated the version of the keys listed in the read set, the transaction will fail at the MVCC validation.
The multi-version concurrency control read-write conflict is a problem that occurs when two clients try to update and read the same key at the same time. Fig.\ref{fig:Figure2} shows an example of this conflict. Let’s assume that \textit{user1} submits \textit{TX1}, and at the same time \textit{user2} submits \textit{TX2}, the two transactions will read and update the same value \textit{Value1} of \textit{Key1}. After endorsing and ordering simultaneously the transactions, \textit{TX1} will be validated and its write set will be applied to the ledger resulting in the modification of the value and version associated with \textit{Key1} to \textit{value1} and \textit{version1}. However, when \textit{TX2} underwent the MVCC validation, it fails because the version of \textit{Key1} in the read set of the transaction is not the same in the ledger. Therefore, the MVCC validation detects the inconsistency between the ledger and the endorsement result and return an MVCC error.
\section{RELATED WORKS}\label{RELATEDWORK}
Hyperledger Fabric is a relatively new system that is already experiencing some major architectural improvements. The majority of related work aims to improve the throughput and minimize the latency of the network, but there is a lack of effective solutions to deal with the MVCC problem and in most cases, the transaction conflict factor is not considered in the evaluation results. In this section, we review recent research on techniques to improve the Hyperledger Fabric performances. We will review this works along three categories: works that optimize endorsement phase, works that improve the ordering phase, and works that enhance the validation phase.
\subsection{Endorsement Phase Optimization}
The work done by \cite{Kwon2019} is aiming to improve the read transaction processing by distinguishing between reading and writing transactions during the endorsement process. As a result, the transaction endorsement latency is reduced by 60\% compared to the traditional fabric network. This approach is complementary to our own solution since early detection can still be applied to further reduce the latency of failed transactions.
\subsection{Ordering Phase Optimization}
For the ordering phase, \cite{Istvan2018} propose the elimination of the concept of blocks in favor of processing transactions in streaming to decrease the batching overhead. Also, the authors implement an FPGA-based (Field Programmable Gate Array) consensus for the ordering service that decreases the commit latency below a millisecond by cutting latency in half compared to the Raft-based ordering service.
The authors of Fast Fabric \cite{Gorenflo2019} redesign the fabric ordering service to work with only the transaction IDs by Separating the transaction header from the payload to decide the transaction order only with the transaction’s IDs which makes transaction processing in the ordering services faster which increase the throughput.
\cite{Sharma2019} propose Fabric++ a solution that aims to reduce the MVCC failure rate by reordering transactions at the ordering phase using a conflict graph to abort the transaction that cannot be serialized.
\cite{Ruan2020} designed an optimized extension of Fabric++ that can handle both inter-block and intra-block MVCC read conflicts.
Our solutions detect the MVCC conflict at the endorsement phase, however, Fabric++ and FabricSharp aim to reorder transactions in the ordering phase to avoid the maximum number of conflicts.
\subsection{Validation Phase Optimization}
Multiple articles propose the parallel execution of the validation process (syntax verification, endorsement policy verification, MVCC validation) to accelerate the block validation \cite{Gorenflo2019a,Gorenflo2019,Istvan2018,Javaid2019,Thakkar2018}.
FabricCRDT focuses on automatically merging the conflicting transactions using CRDT techniques without rejecting them~\cite{Nasirifard}.
\cite{Istvan2018} introduce a disk writes batching mechanism by using a local batcher that accumulates the ledger update operations until reaching a batch size or batch time out to write to the database.
Finally, \cite{Meir2019} presented a lock-free solution for providing transaction isolation, this approach allows the removal of the shared lock while ensuring transaction isolation.
The proposed improvements of the validation phase are based on the parallelization of validation processes or the optimization of reading and writing operations on the databases. All of these works offer useful insights into various techniques that can improve the Hyperledger Fabric performance and represent a complementary improvement to our proposed solution.
\subsection{MVCC in database systems}
MVCC is one of the most studied problems in the database community which is reused in blockchain systems. This problem is addressed by several works such as the work of \cite{Larson2012High-PerformanceDatabases} who propose two optimized MVCC mechanisms for in-memory databases. Compared to single-version locking, the proposed schemes have higher overhead but are much less sensitive to hotspots and the presence of long-running transactions. Also, \cite{Faleiro2015} introduce the BOHM, a concurrency control mechanism for main-memory multi-versioned database systems ensuring that reads operations never block writes. These proposed solutions can serve to improve the databases-based blockchain systems. However, our proposed solution is preventive because it deals with the MVCC problem before it occurs at the validation phase.
\section{EMVCC Detection \& Solution}\label{OURSOLUTION}
\begin{figure*}[t]
\centering
\includegraphics[width=1\textwidth]{EMVCC_FLow.png}
\caption{EMVCC Detection Mechanism} \label{fig:Figure3}
\label{fig}
\end{figure*}
In this section, we formulate the problem of MVCC detection at the endorsement phase. We then describe our proposed solutions called early MVCC detection, and present the different possible caching data structures. Also, we present a theoretical analysis of different endorsement policies.
\subsection{System Model}
In this section, we will use the following model: given an Hyperledger Fabric\footnote{Our solution has been tested with Fabric version 2.0 and higher.} network containing $N$ organizations where each organization has $M$ peers and $M_i$ is the number of peers for organisation $i$. The system uses $Nb_{Tx/Block}$ as the number of transactions per block. The ordering services of the system can use any consensus protocol available in Hyperledger Fabric (e.g., Raft, Kafka, Solo). The chaincode executed by the application generates $\%cfct$ as the conflict rate representing the percentage of transactions which abort due to an MVCC conflict error. Intuitively speaking, a chaincode where transactions read and write to a few shared keys will have a higher conflict rate than that of a chaincode where transactions are independently working on disjoint keys. In order to store chain state, the system can be implemented using any of the available databases compatible with Hyperledger Fabric (CouchDB, LevelDB, etc.).
\subsection{Problem Formulation} \label{sec:pbform}
The problem we are solving is detecting MVCC conflict by filtering the transactions at the \textit{endorsement phase} based on the endorsed transactions history of each endorsing peer. This is in contrast to the current problem resolved by Fabric, which is that of detecting MVCC conflicts at the \textit{validation phase}, which occurs later in the transaction flow.
We start by defining some basic terms that we will use later:
\begin{itemize}
\item \textbf{Probability of non-detection:} This is a metric to evaluate the performance of our solution. A perfect solution would have a $\mathcal{P}(ND)=0$. It represents the probability that our proposed solution does not detect a conflicting transaction at the endorsement phase, even though it has a conflict with another transaction, such that the MVCC conflict is only detected later at the validation phase.
\item \textbf{False positives:} We call a false positive a transaction which is wrongly declared invalid using our solution, but would have been successfully confirmed using the standard approach. This can occur if our solution is overly aggressive in detecting conflicts and will prematurely abort transactions which have a chance to be successful, which would force the client to retry the entire endorsement process with a new transaction. The false positive rate can be calculated as follows:
\begin{equation}\label{eq1}
\resizebox{0.8\hsize}{!}{$%
FP= \frac{Tx/Block \times \%cfct^2 \times \mathcal{P}(ND) \times (1-\mathcal{P}(ND))} {\%cfct \times \mathcal{P}(ND) - \%cfct + 1}
$%
}%
\end{equation}
where ${Tx/Block}$ is the number of transactions per block, $\mathcal{P}(ND)$ is the probability of non-detection and $\%cfct$ is the conflict rate
\item \textbf{False negatives:} It is the opposite error where a transaction is declared valid at the EMVCC validation stage while it has conflicts with another transaction resulting in its failure later on. Ideally, the number of false negatives should be equal to zero.
\begin{equation}\label{eq2}
FN= TX\_rate \times \%cfct \times \mathcal{P}(ND)
\end{equation}
\item \textbf{Goodput}\cite{Yu2018CoinExpress:Networks} is the rate of successful transactions that the network can write into the blockchain. In contrast, the throughput of the network is the rate of total transactions which passed through the ordering phase, including transactions which will be aborted due to MVCC conflicts. Ideally the goodput should be equal to the throughput. In a standard Fabric implementation, the goodput is directly impacted by the MVCC conflict rate, since any aborted transaction is still part of a proposed block. Our solution can prevent such conflicts from being reflected inside the blockchain by detecting them prior to the ordering phase and thus improve the goodput.
We can calculate it as follows:
\begin{equation}\label{eq3}
\resizebox{0.7\hsize}{!}{$%
goodput=\frac{Nb\_valid\_TX}{Nb\_TX} \times Throughput
$%
}%
\end{equation}
\end{itemize}
\subsection{Proposed Solution}\label{sec:propsol}
In the current implementation of Fabric, a conflicting transaction passes through the network and eventually fails, thereby consuming unnecessary resources. In our proposed solution, we add a layer to filter transactions at the endorsement phase to abort any detected conflicting transactions. We call our approach Early Multi-Version Concurrency Control (EMVCC).
As described in Fig.\ref{fig:Figure3}, our EMVCC solution operates after Fabric executes the chaincode and generates the read/write sets, and before an endorsement response is sent back to the client. Our EMVCC solution will compare the read set to a list of pending transactions stored in the peer’s local cache. This cache is populated with transactions currently in progress this peer has previously endorsed which have not yet been confirmed (or aborted).
If a transaction reads a key that is stored in the cache, the transaction will be aborted since an instance of early MVCC conflict was detected. If not, the transaction is stored in the local cache and an endorsement is sent as usual back to the client. Once the transaction is validated or rejected at the validating phase, the cache is updated by removing the keys of the write set of this transaction.
Note that the usual MVCC phase is still performed during the validation phase, since our EMVCC does not detect conflicts perfectly (see Section~\ref{sec:thAnalysis}). This allows the regular validation phase to catch any MVCC conflicts that are not detected through our EMVCC solution, thereby maintaining correctness of the EOV (Execute-Order-Validate) execution flow.
\begin{figure}[t]
\centering
\includegraphics[width=0.48\textwidth]{pic0.png}
\caption{EMVCC Detection Example} \label{fig:EMVCCExample}
\label{fig}
\end{figure}
Fig.\ref{fig:EMVCCExample} shows an example of how EMVCC detection works. Suppose that we have a Fabric network composed of two organizations, each organization having two peers. The chaincode endorsement policy is AND (Org1,Org2). Suppose that \textit{client1} submits \textit{TX1} which writes on \textit{Key1} and \textit{Key2}. This transaction is endorsed by \textit{Peer0.ORG1} and \textit{Peer0.ORG2}. Now suppose we have a transaction \textit{TX2} which reads \textit{Key2} and writes on \textit{Key3}. If this transaction is endorsed by \textit{Peer0.ORG1} or \textit{Peer0.ORG2}, it will be aborted at the endorsement phase because \textit{TX1} is in the EMVCC cache of \textit{Peer0.ORG1} or \textit{Peer0.ORG2}. Suppose another transaction \textit{TX3} arrives which writes on \textit{Key1} and reads \textit{Key2}. If it is endorsed by \textit{Peer1.ORG1} and \textit{Peer1.ORG2}, it will not be detected by the EMVCC detection mechanism because these peers does not have any conflict with this keys in their EMVCC cache. However, it will still fail later on at the MVCC validation phase.
\subsection{Theoretical Analysis of Non-Detection}\label{sec:thAnalysis}
Since our approach is lightweight in nature and only uses local caching without resorting to any synchronization, it is possible for a conflicting transaction to pass the EMVCC phase undetected. This can happen if the subset of peers chosen to endorse the current transaction have not previously endorsed a pending transaction which conflicts with it. Thus, the endorsement policy, as well as the number of peers and the number of organisations, have a direct impact on the probability of non-detection of our proposed EMVCC solution.
In order to assess the performance of our solution, we present a analytical model which calculates the expected probability of non-detection for our solution using the AND and OR endorsement policies. These theoretical results will be compared to the real results in Section \ref{EXPERIMENTS} to validate the correctness of our implementation. For this analysis, we assume the selection of peers (and organisations) is done uniformly at random when a client is presented with a choice of multiple peers (or organisations) to satisfy the endorsement policy, as it is currently implemented in Hyperledger Fabric \cite{Manevich2018ServiceFabric}. Due to the lack of space, we defer the full details of our mathematical formulas derived here to our extended report.
\subsubsection{Non-Detection in the AND Endorsement Policy}
Using the AND endorsement policy, the probability of non-detection can be calculated as follows:
\begin{equation}\label{eq4}
\mathcal{P}(ND) = \prod_{n=1}^{N} \frac{(M_i-1)}{M_i}
\end{equation}
where N is the number of organizations and $M_i$ is the number of peers per organization
Fig.\ref{fig:FigureAND} plots the theoretical evolution of the probability of non-detection of the EMVCC solution for various organizations and peer numbers using AND endorsement policy. We observe that the probability of non-detection decreases when the number of organizations increases, however, it increases when the number of peers per organization increases.
\begin{figure}[t]
\includegraphics[width=0.45\textwidth]{AND.png}
\caption{Probability of Non-Detection using AND} \label{fig:FigureAND}
\label{fig}
\end{figure}
\subsubsection{Non-Detection in the OR Endorsement Policy}
We also analyze the evolution of the probability of non-detection using the OR endorsement policy, it can be calculated using the following formula:
\begin{equation}\label{eq5}
\mathcal{P}(ND)=\left\lbrace
\begin{array}{ll}
\frac{NM-1}{NM}& \mbox{if $M_i$=$M_{i+1}$}\\
\frac{1}{N} {\sum\limits_{i=1}^N \frac{1}{M_i}} & \mbox{else}
\end{array}
\right.
\end{equation}
where N is the number of organizations and $M_i$ is the number of peers per organization
Fig.\ref{fig:FigureOR} illustrates the theoretical evolution of the probability of non-detection for different organizations and peers’ numbers using OR endorsement policy. We identify that the probability of non-detection increases when the number of organizations or the number of peers increases due to the lack of synchronization between nodes caches.
\begin{figure}[t]
\includegraphics[width=0.45\textwidth]{OR.png}
\caption{Probability of Non-Detection using OR} \label{fig:FigureOR}
\label{fig}
\end{figure}
\subsection{Choice of Caching Data Structure} \label{sec:datastruc}
For the local cache maintained by each peer, we propose three different techniques in our reference implementation:
\textbf{MutexLock}: In this implementation, we are using a lock-based data structure to ensure cache consistency while using a multithreaded system \cite{Alexandrescu2007Lock-FreeStructures}. For example, when an endorser reads or writes on the cache, it will be locked and the validator cannot update this entry in the cache. The main disadvantage of this approach is that the locking system adds a delay to the read and write operations since some threads have to wait until a lock is released.
\textbf{LockFree}: With this approach, more than one thread can access the cache concurrently. The read and writes operations are stored in a buffer then once the buffer threshold is reached, the batch is applied to the cache which guarantees that the majority of threads make progress at each step \cite{Alexandrescu2007Lock-FreeStructures}. This technique is useful to decrease the number of times a lock is acquired or released.
\textbf{SyncMap}: Sync Map is an optimized and safe data structure, which is part of the sync package since Golang 1.9. It uses a dirty map to write new values or updates allowing the read operation to be done without a lock. However, the Mutex locking is essential if numerous concurrent threads (\textit{goroutines}) are writing concurrently in the dirty map and the read-only map is updated by a batch of operations from the dirty map.
\section{BENCHMARKING RESULTS}\label{EXPERIMENTS}
In this section, we evaluate the effectiveness of our proposed EMVCC solution using three different cache implementations: Mutex Lock, LockFree, and SyncMap. We first compare our three different implementations against the standard Fabric implementation as a baseline. We then perform a sensitivity analysis to study the influence of certain system parameters and workload characteristics on the system performance. Table \ref{tab:tab1} shows the default used parameters for our experiment. We use 500 transactions per block as the block size and a block time of 2 seconds which are the ordering parameters that lead to the highest throughput from our experiential testing (see Section~\ref{subsec:sa}). Furthermore, we use a conflict rate of 40\% because in realistic scenarios it represents the percentage of failed transactions due to concurrency conflict \cite{Chacko2021WhyVersion}. We chose the Raft consensus over the the two alternative ordering services because the solo mode is recommended only for development and testing purposes \cite{Wang2020PerformanceFabric} and Kafka is deprecated in versions 2.x of Fabric. We also chose 3 ordering services nodes to satisfy the trade-off between the cost of the network and its performance.
\subsection{Test Environment Characteristic}
Our cluster consists of six E2 virtual machines hosted on the Google Cloud Platform. Two machines serve as two peers and three machines running the ordering services with a raft consensus algorithm. The other virtual machine serves as clients by running the Hyperledger Caliper \cite{Wickboldt2019BenchmarkingSystem} benchmarking tool. Each virtual machine has 8 vCPUs (Virtual Central Processing Unit) and 32 GB of RAM. All the virtual machines are running Ubuntu 16.04 as an operating system. The Fabric peers are set up to use our modified version of Hyperledger 2.3 images and CouchDB as the state database. For the chaincode, we use the Fabcar chaincode which allows us to create a car on the blockchain and modify its owner.
\subsection{Performances Metrics}
The main metrics for our benchmarking are:
\begin{enumerate}
\item \textbf{Goodput}: the effective throughput of committed transactions written to the blockchain excluding the aborted ones (Section \ref{sec:pbform}).
\item \textbf{Latency}: the time between the initial request by the client of the transaction and its final commit to the ledger.
\item \textbf{EMVVC vs. MVCC rate}: the percentage of rejected transactions due to an EMVCC error versus the percentage of rejected transactions due to an MVCC error.
\item \textbf{TD EMVCC and TD MVCC}: the time-to-detect is the total time duration between the submission of the transaction by the client and its rejection by an MVCC or EMVCC error.
\end{enumerate}
\begin{figure*}
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\linewidth]{pic1.png}
\caption{Throughput Comparison With The Baseline Solution}
\label{fig:Comparaison}
\end{subfigure}
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\linewidth]{pic2.png}
\caption{Latency Comparison With The Baseline Solution}
\label{fig:latency}
\end{subfigure}
\caption{Comparison With The Baseline Solution}
\end{figure*}
\subsection{Comparison With The Baseline Solution}
In this section, we compare our proposed solutions with version 2.3 of Hyperledger Fabric. The throughput and transaction latency are averaged over ten runs.
\begin{table}[]
\centering
\caption{Default Evaluation Parameters} \label{tab:tab1}
\begin{tabular}{|l|l|}
\hline
\textbf{Parameters} & \textbf{Values} \\ \hline
\textbf{Block size} & 500 TXs \\ \hline
\textbf{Block time} & 2 seconds \\ \hline
\textbf{Number of organizations} & 2 \\ \hline
\textbf{Number of peers per organization} & 2 \\ \hline
\textbf{Ordering Consensus} & Raft (3 Orderers) \\ \hline
\textbf{MVCC Conflict rate} & 40\% \\ \hline
\textbf{Endorsement Policy} & AND(Org1,Org2) \\ \hline
\end{tabular}
\end{table}
Fig.\ref{fig:Comparaison} plots the average throughput for three implementations and the Hyperledger Fabric. The three proposed solutions are better than the Fabric baseline, the best solution being SyncMap with a 23.2\% of goodput improvement compared to Fabric. For Mutex Lock and LockFree, the percentage of improvement is 20.4\% and 21.2\%, respectively. Also, Fig.\ref{fig:latency} plots the average latency for the three implementations and the baseline. Similarly, the three implementations reduce latency compared to the baseline: for SyncMap and LockFree, the latency is reduced by 80\%, and for MutexLock by 69\%. This is due to the early detection of the conflicting transaction at the endorsement instead of going until the validation phase to be aborted. We thus conclude that SyncMap is the best data structure for our early MVCC cache implementation because it is the best for read operations when the the peer has multiple vcPUs.
\subsection{Sensitivity Analysis}
\label{subsec:sa}
In this section, we analyse the impact of various network and workload parameters on the performance metrics such as the conflict rate, endorsement policies, and compute resources per peer, etc.
\subsubsection{Impact of Conflict Rate}
The conflict rate is the most important parameter that can show us the utility of our proposed solution. In Fig. \ref{fig:conflict}, we plot the average goodput for Fabric and our different solutions over different values of conflict rates. As expected, with an increase in the conflict rate, the goodput decreases because we are increasing the number of failed transactions until we reach a 100\% conflict rate where the goodput becomes zero. Also, we can see that the three proposed solutions perform better than Fabric for different values of the conflict rate. SyncMap is the best one, since it is improving the goodput by 10\% when the conflict is around 20\% and its impact is more important by exceeding 20\% to reach an improvement of 23\% at a conflict rate of 40\%. The relative performance of this solution increases over the baseline as the conflict rate increases for an application.
\subsubsection{Impact of Compute Resources per Peer}
In this part, we will analyze the impact of adding or removing vCPUs to each peer. We vary the number of CPU from 2 vCPUs to 8 vCPUs. Fig.\ref{fig:figA} plots the average throughput and goodput and Fig.\ref{fig:figB} plots the average latency for our three implementations and the Hyperledger Fabric baseline for various vCPU numbers per peer. With an increase in the number of vCPUs per peer, the goodput increases and the latency decreases. Our three solutions are better than the baseline at varying numbers of vCPUs. However, we observe that with 8 vCPUs, there is a significant improvement of 23\% for goodput and 65\% for latency between SyncMap and the baseline. Thus, we conclude that our solutions are able to better leverage additional computational resources than the Fabric baseline.
\begin{figure*}[h!]
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic3.png}
\caption{MVCC Conflict Rate vs. Goodput}
\label{fig:conflict}
\end{subfigure}
\centering
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic7.png}
\caption{vCPUs vs. Throughput}
\label{fig:figA}
\end{subfigure}
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic6.png}
\caption{vCPUs vs. Latency}
\label{fig:figB}
\end{subfigure}
\centering
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic4.png}
\caption{Block Size vs. Throughput}
\label{fig:figC}
\end{subfigure}
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic5.png}
\caption{Block Size vs. Conflict Rate}
\label{fig:figD}
\end{subfigure}
\centering
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic8.png}
\caption{Impact of AND Policy}
\label{fig:figE}
\end{subfigure}
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic9.png}
\caption{Impact of OR Policy}
\label{fig:figF}
\end{subfigure}
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic10.png}
\caption{Time To Detect EMVCC/MVCC}
\label{fig:figX}
\end{subfigure}
\centering
\begin{subfigure}[t]{0.30\textwidth}
\centering
\includegraphics[width=\linewidth]{pic11.png}
\caption{Conflict Skewness}
\label{fig:zipf}
\end{subfigure}
\caption{Sensitivity Analysis Results}
\end{figure*}
\subsubsection{Impact of Block Size}
We analyse the impact of the block size by varing the block size from 100 transactions per block to 500 transactions per block. Fig.\ref{fig:figC} plots the average throughput and goodput for Fabric and our three implementations over various block sizes. Increasing the block size increases the throughput and goodput for all solutions because the use of larger blocks will cause less overhead and fewer network communications. The SyncMap method is offering an average improvement of 12\% compared to Fabric over different block sizes which confirms that our proposed solutions are scalable with different block sizes. Fig.\ref{fig:figD} plots the conflict rate for Fabric and our three methods over various block sizes. We can observe that with an increase in the block size the conflict rate increases: this is due to the increase of the number of intra-block conflicts when the block contains a higher number of transactions. One other observation that can be made is that the conflict rate for Fabric is less than our proposed implementation: this is because there are some false positives and negatives caused by the early MVCC detector.
\subsubsection{Impact of Endorsement Policies and Network Topology}
For this experiment, we use different network topologies by varying the number of peers per organization from one peer to three peers. Fig.\ref{fig:figE} and Fig.\ref{fig:figF} plot the average throughput and goodput, as well as the percentage of transaction failure, caused by EMVCC and MVCC validation for different network topologies using AND (Org1, Org2) and OR (Org1, Org2) endorsement policies for the Fabric baseline and SyncMap solutions. We observe that the type of endorsement policy impacts the network performances. As shown in the two figures, the throughput for the OR endorsement policy is higher than the throughput using the AND policy because using OR the transaction needs less peer endorsement than the AND. For the percentage of non-detection, these experimental results confirm the theoretical results presented in Section \ref{OURSOLUTION}. For example, with AND Policy and using a network with two organizations each one has two peers, we have 22\% of conflicting transactions that were not detected at the EMVCC and were aborted at the MVCC validation (false negative). We can also see that increasing the number of peers increases throughput and goodput for both endorsement policies as the organizations have more resources to process transactions. We can also observe that the increase in the number of peers per organization increases the rate of false positives. The improvement when the AND policy is used is more important compared to Fabric. However, with OR policy, the number of false positives increases which impacts the solution’s performance. We can conclude that with an increase in the number of endorsers our solution becomes more efficient.
Fig.\ref{fig:figX} plots the average time to detect EMVCC/MVCC over different network topologies using OR and AND endorsement policies. The duration of the transaction execution is reduced by 95\% between aborting a conflicting transaction at the EMVCC phase and processing it until reaching the MVCC validation phase to be rejected that is why our solutions reduce significantly the transaction latency. We note that when the number of peers per organization increases, the time to detect MVCC decreases due to the availability of computational resources.
\subsubsection{Impact of Chaincode Implementation}
To simulate another chaincode behavior, we use the Zipf distribution, which allows us to choose the keys used to simulate transactions by varying the parameter \textit{s} of the distribution from 0 to 2. By increasing \textit{s}, we are increasing the preference to use certain same keys which increase the conflict rate. Fig.\ref{fig:zipf} plots the average goodput for the Fabric, SyncMap, LockFree, and MutexLock solutions over different values of the parameter \textit{s} of the Zipf distribution. We can see that when \textit{s} increases the conflict rate increases causing the goodput to decrease. As expected, when the s parameter increases our solutions perform better than Fabric. For example, SyncMap improves the goodput by 24\% for \textit{s} equal to 1 and 35\% for \textit{s} equal 1.5.
\subsection{Summary and Discussions of Findings}
Our three proposed solutions perform better than the Fabric baseline. SyncMap is the best data structure to implement the cache for keys storing. The improvement rate compared to Fabric is mostly determined by the used endorsement policies, the network design, and the chaincode implementation (conflict rate). In realistic scenarios, where 40\% of the transactions failed due to MVCC conflict, the SyncMap solution improves the throughput by 23\% and reduces the latency by 80\%.
When using our solution, we recommend developers to use the AND endorsement policy with a maximum number of organizations and the minimum number of peers per organization if the business logic allows that. However, when they have to use the OR endorsement policy, we recommend that they use the minimum number of organizations and number of peers per organization. The block size should be adjusted carefully to minimize the inter-block and intra-block transactions conflict in order to maximize the goodput. For the chaincode implementation, it is important to write a chaincode that ensures a conflict rate lower than 40\%. This solutions can be useful to optimize the performances of other blockchain using the EOV approach.
\section{CONCLUSIONS}\label{CONCLUSIONS}
In this work, we propose a mechanism to improve Hyperledger Fabric performances aiming to early abort transactions that have no chance to be validated and committed to the ledger using different caching techniques. In an experimental evaluation, we compare SyncMap, LockFree, and MutexLock to the basic version of Fabric. We also did a sensitivity analysis by varying configurable parameters such as block size, endorsement policies, and resource allocation. We show that the proposed solutions outperform Fabric and SyncMap which is the best-proposed method that improves the throughput by up to 20\% and reduces the latency by up to 80\% compared to Fabric.
\bibliographystyle{unsrt}
| {'timestamp': '2023-01-18T02:15:00', 'yymm': '2301', 'arxiv_id': '2301.06181', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06181'} | arxiv |
\section{Introduction}
In recent years, graph theories have been widely used in chemical, biological, physical, social, and computer sciences. This is because graphs are useful for representing and analyzing a wide range of practical problems. In molecular modeling, graph representation is widely used since it is a natural way to model their structures, in which graph vertices represent atoms and graph edges represent possible interactions between them. In general, graph theories can be divided into three categories: geometric graph theory, algebraic graph theory, and topological graph theory. Geometric graph theory studies a graph's geometric connectivity, which refers to the pairwise relations among graph nodes or vertices \cite{nguyen2017rigidity}. Algebraic graph theory concerns the algebraic connectivity via the characteristic polynomial, eigenvalues, and eigenvectors of matrices associated with the graph, such as the adjacency matrix or the Laplacian matrix \cite{nguyen2019agl, chen2021algebraic}. In topological graph theory, embedding and immersion of graphs are studied along with their association with topological spaces, such as abstract simplicial complexes \cite{wang2020persistent,meng2021persistent}.
There are numerous applications of graphs in chemical analysis and biomolecular modeling \cite{trinajstic2018chemical, schultz1989topological, janezic2015graph, angeleska2009dna}, such as normal-mode analysis (NMA) \cite{Go:1983, Tasumi:1982,brooks1983charmm,levitt1985protein} and elastic network model (ENM) \cite{bahar1997direct,flory1976statistical,bahar1998vibrational,atilgan2001anisotropy, hinsen1998analysis, tama2001conformational} used to study protein B--factor prediction. Algebraic graph theory has been utilized in some of the most popular elastic network models (ENMs) such as the Gaussian network model (GNM) and the anisotropic network model (ANM). However, due to the matrix-diagonalization procedure, these methods have a computational complexity of $\mathcal{O}(N^3)$, with $N$ being the number of matrix elements. Furthermore, these methods suffer from limited accuracy in protein B--factor prediction, with average Pearson correlation coefficients less than 0.6 in all datasets. A geometric graph theory-based weighted graph approach, called flexibility-rigidity index (FRI), was introduced to bypass matrix diagonalization in GNM \cite{xia2013multiscale, opron2014fast, opron2016flexibility, nguyen2016generalized}. FRI assumes that protein interactions, including interactions with its environment, completely determine its structure in a given environment, which in turn, fully determines protein flexibility and functions. Therefore, it is not necessary to invoke a high-dimensional protein interaction Hamiltonian as in spectral graph theory to analyze protein flexibility when the accurate structure of the protein and its environment are known. While the computational complexity of earlier FRI \cite{xia2013multiscale} is of $\mathcal{O}(N^2)$, the fast FRI \cite{opron2014fast} is of $\mathcal{O}(N)$. In order to capture multiscale interactions in macromolecules, multiscale FRI (mFRI) was introduced \cite{opron2015communication}, resulting in a number of graphs with parallel edges, i.e. multiple graphs. Despite the fact that mFRI is about $20\%$ more accurate than the GNM on a set of 364 proteins, the average Pearson's correlation coefficient in B--factor prediction falls below 0.7, which is insufficient to provide a reliable assessment of protein flexibility. The limited accuracy of these graph-based models is due to the fact that they do not distinguish different chemical element types in a molecule or biomolecule, resulting in a severe loss of important chemical and biological information.
To address the aforementioned problem, a multiscale weighted colored graph (MWCG) model was introduced for protein flexibility analysis \cite{bramer2018multiscale}. In MWCG, the graph of a protein structure is colored according to the type of interaction between nodes in the graph, and subgraphs are defined according to colors. This process is commonly referred to as graph coloring, which is an important technique in graph theory that allows graph vertices or edges to be treated differently.
MWCG weights the importance of graph edges by scaling their Euclidean distances in radial basis functions so that the nearest neighbors have the strongest edges in the sense of the Euclidean metric. Mathematical properties of MWCGs include low dimensionality, simplicity, robustness, and invariance of rotations, translations, and reflections. Subgraphs constructed from vertex-labeled and edge-labeled graphs provide powerful representations of intermolecular and intramolecular interactions, such as hydrogen bonds, electrostatics, van der Waals interactions, hydrophilicity, hydrophobicity, etc \cite{nguyen2017rigidity, bramer2018multiscale}. The MWCG models offer 40\% more accuracy than the GNM in protein B--factor prediction \cite{bramer2018multiscale}.
Molecular interactions between proteins and substrate molecules (ligands) are the principal determinant of many vital processes, such as cellular signaling, transcription, metabolism, and immunity. Therefore, understanding protein-ligand interactions is a central issue in biochemistry, biophysics, and molecular biology. Moreover, an accurate prediction of protein-ligand binding affinity plays a critical role in computational drug design, particularly in virtual screening and lead optimization. Various scoring functions (SFs) have been developed over the past few decades to evaluate protein-ligand interactions in structure-based drug design. These SFs can be classified mainly into four categories: force-field-based or physics-based SF, empirical SF, knowledge-based SF, and machine-learning-based SF. Force-field-based SFs offer physical insight and are not dependent on existing data. Empirical SFs utilizes a number of physical sub-models and use regression to fit existing data.
The knowledge-based SF uses available datasets to derive binding patterns for proteins and ligands without requiring further training.
Finally, machine learning-based SFs are data-driven, and are capable of capturing non-linear and complex relationships in the data. They can also easily handle large and diverse datasets.
The performance of machine learning-based SFs strongly depends on the training set, in addition to their descriptors and machine learning algorithms.
These scoring functions often take the top place in several standard benchmarks and community-wide competitions \cite{nguyen2019mathematical,nguyen2020mathdl,gaieb2018d3r,gaieb2018d3rGC3,parks2020d3r}.
In recent years, due to the increasing availability of structural and binding affinity data for protein-ligand complexes, machine-learning SFs have become increasingly popular for binding affinity prediction. The RF--Score \cite{ballester2010machine} is considered one of the first machine-learning-based SFs to outperform other SFs in the CASF--2007 benchmark dataset. The model uses the random forest algorithm and employs element--type pair counts as features to describe protein-ligand complexes. The model was later extended to incorporate a more precise chemical description, including SYBYL atom-type pair counts features \cite{ballester2014does}. Including SYBYL atom types into the model permits deconvoluting the element into a hybridization state and bonding environment. For example, instead of having a single Carbon (C) element atom type, the SYBYL scheme allows the following subtypes: C.1, C.2 C.3, C.ar, and C.cat. A number of SYBYL atom-type-based models have been developed in the past years \cite{cheng2009comparative}, including SYBYL::ChemScore , SYBYL::G-Score , and SYBYL::D-Score. In a separate study, it has been shown that the connectivity of the atoms \cite{wojcikowski2019development} can improve the performance of a machine learning model in the binding affinity prediction task \cite{sanchez2021extended}. In \cite{sanchez2021extended}, the authors used a set of protein-ligand atom-type pair counts features, called the extended connectivity interactive features (ECIF), that considers each atom's connectivity to define the atoms involved in the pairs. The atom definition in ECIF is based on the atom environment concept initially introduced in the development of Extended Connectivity Fingerprints (ECFP) \cite{rogers2010extended}. Paired with a machine learning algorithm, the ECIF model significantly improves the performance of the binding affinity prediction with Pearson's correlation of 0.866 for the CASF--2016 benchmark.
A number of machine-learning-based SF with different types of descriptors including differential geometry \cite{nguyen2019dg, rana2022eisa}, persistent homology \cite{cang2018integration, meng2021persistent}, and graph theory \cite{nguyen2017rigidity, nguyen2019agl} have emerged in the past few years for protein-ligand binding affinity prediction. Among them, the element-type graph coloring-based MWCG descriptors have particularly been successful in the task \cite{nguyen2017rigidity, nguyen2019agl}.
In the present work, we propose a geometric graph theory-based multiscale weighted colored graph (MWCG) descriptors for the protein-ligand complex where the graph coloring is based on SYBYL atom-type and ECIF atom-type connectivity. By pairing with the advanced machine learning architectures, our approach results in two different methods, namely $^\text{sybyl}\text{GGL}$-Score and $^\text{ecif}\text{GGL}$-Score. We verify the scoring power of our proposed model against three commonly used benchmarks in drug design, namely CASF-2007 \cite{cheng2009comparative}, CASF-2013 \cite{li2014comparative}, and CASF-2016 \cite{su2018comparative}. Several experiments confirm that both of our models achieve state-of-the-art results and outperform other models by a wide margin.
\section{Methods and Materials}\label{sec2}
\subsection{Multiscale Weighted Colored Geometric Subgraphs}
A graph $\mathcal{G}$ of a biomolecule consists of a set of vertices $\mathcal{V}$ and edges $\mathcal{E}$ and can be used to describe the noncovalent interaction of atoms in the molecule. In recent years, graph theory descriptors of protein-ligand binding interactions have been developed for massive and diverse datasets \cite{nguyen2019agl, jiang2021ggl}. To improve the graph theory representation, different types of elements are labeled, which is known as graph coloring. A colored graph is used to encode different types of interactions between atoms and gives rise to a basis for the collective coarse-grained description of the dataset. Labeled atoms of a molecule are classified into subgraphs where colored edges correspond to element-specific interactions.
To account for details of physical interactions in protein-ligand complexes such as hydrophobic, hydrophilic, etc., we are interested in constructing the subgraphs in an atomic interactive manner. In our previous work \cite{nguyen2017rigidity, nguyen2019agl}, we used the combination of the element symbols of the interacting protein-ligand atoms to classify the interaction, e.g., C--C or N--O. In the present work, instead of the element symbol, we consider the following two schemes to classify the atomic interaction.
In the first approach, we consider atom name (excluding hydrogen) for protein and SYBYL atom type for the ligand to define a range of protein-ligand atom pairs, e.g CD1--C.2, CG--C.ar, OE1--N.am, etc. In the second scheme, we consider the extended connectivity interaction features (ECIF) described in \cite{sanchez2021extended} to extract the protein-ligand atom-type pair that takes each atom's connectivity into account. The ECIF atom type in a molecule is defined by considering six atomic features: atom symbol, explicit valence, number of attached heavy atoms, number of attached hydrogens, aromaticity, and ring membership. Each of these properties can be represented textually where each property is separated by a semicolon. For example, the ECIF atom type for the $\alpha$ carbon CA is C;4;3;1;0;0.
For convenience, let $\mathcal{T}$ be the set of all interested atom types in a given biomolecular dataset for either of the two schemes described above. To reduce the notation complexity, we denote the atom type at the $i$th position in the set $\mathcal{T}$ as $\mathcal{T}_i$. Assuming that a biomolecule has $N$ atoms of interest, we denote
\begin{equation}
\mathcal{V}=\{ (\mathbf{r}_i,\alpha_i)| \mathbf{r}_i\in \mathbb{R}^3; \alpha_i\in \mathcal{T}; i=1,2,\cdots,N\}
\end{equation}
a subset of $N$ atoms (i.e. subgraph vertices) that are members of $\mathcal{T}$. Note that the $i$th atom is labeled by both its coordinate $\mathbf{r}_i$ and atom type $\alpha_i$. We assume that all the pairwise non-covalent interactions between atom types $\mathcal{T}_k$ and $\mathcal{T}_{k'}$ in a molecule or molecular complex can be represented by fast-decay weight functions
\begin{align}
\mathcal{E} &= \{ \Phi(\norm{\mathbf{r}_i-\mathbf{r}_j};\eta_{kk'})| \alpha_i=\mathcal{T}_k,\, \alpha_j = \mathcal{T}_{k'}; \nonumber \\
&\quad i,j=1,2,\cdots,N;\, \norm{\mathbf{r}_i-\mathbf{r}_j}\leq c \},
\end{align}
where $\lVert \mathbf{r}_i-\mathbf{r}_j \rVert$ is the Euclidean distance between the $i$th and $j$th atom and $c$ is a predefined cutoff distance that defines the binding site of the atom type $\mathcal{T}_k$ and $\mathcal{T}_{k'}$. Here $\eta_{kk'}$ is a characteristic distance between the atoms, and $\Phi$ is a subgraph weight that satisfies the following admissibility conditions
\begin{align}
\Phi(\norm{\mathbf{r}_i-\mathbf{r}_j};\eta_{kk'}) &=1, \quad \mathrm{as}\; \norm{\mathbf{r}_i-\mathbf{r}_j}\rightarrow 0,\\
\Phi(\norm{\mathbf{r}_i-\mathbf{r}_j};\eta_{kk'}) &=0, \quad \mathrm{as}\; \norm{\mathbf{r}_i-\mathbf{r}_j}\rightarrow \infty, \nonumber \\
&\alpha_i=\mathcal{T}_k,\, \alpha_j = \mathcal{T}_{k'}.
\end{align}
Although most radial basis functions can be used as the subgraph weight, the generalized exponential function
\begin{equation*}
\Phi_E(\norm{\mathbf{r}_i-\mathbf{r}_j};\eta_{kk'}) = e^{-(\norm{\mathbf{r}_i-\mathbf{r}_j}/\eta_{kk'})^\kappa}, \quad \kappa>0,
\end{equation*}
and the generalized Lorentz function
\begin{equation*}
\Phi_L(\norm{\mathbf{r}_i-\mathbf{r}_j};\eta_{kk'}) = \frac{1}{1+\left(\norm{\mathbf{r}_i-\mathbf{r}_j}/\eta_{kk'}\right)^\kappa}, \quad \kappa>0,
\end{equation*}
were shown to work very well for biomolecules \cite{opron2014fast}. Now, we have a weighted colored subgraph $G(\mathcal{V}, \mathcal{E})$ for a molecule or a molecular complex and we can use it to construct atomic-level collective molecular descriptors. We define the multiscale weighted colored geometric subgraph (MWCGS) interaction between $k$th atom type $\mathcal{T}_k$ and $k'$th atom type $\mathcal{T}_{k'}$ by
\begin{align}\label{MWCGS_rigidity}
\mu^G(\eta_{kk'}) &=\sum_i \mu_i^G(\eta_{kk'})=\sum_i \sum_j \Phi(\norm{\mathbf{r}_i-\mathbf{r}_j};\eta_{kk'}),\nonumber \\
&\quad \alpha_i = \mathcal{T}_{k},\, \alpha_j = \mathcal{T}_{k'},
\end{align}
where $\mu_i^G(\eta_{kk'})$ is the geometric subgraph centrality for the $i$th atom of type $\mathcal{T}_k$ and all atoms of type $\mathcal{T}_{k'}$. The summation over the geometric centrality $\mu_i^G(\eta_{kk'})$ in equation \eqref{MWCGS_rigidity} can be interpreted as the total interaction strength for the selected atom type pair $\mathcal{T}_k$ and $\mathcal{T}_{k'}$, which provides the atomic-level coarse-grained description of the molecular properties.
The equation \eqref{MWCGS_rigidity} is a generalization of a bipartite subgraph discussed in \cite{nguyen2017rigidity} for the predictions of protein-ligand binding affinities and free energy ranking. A bipartite subgraph of a protein-ligand complex is a graph in which each of its edges connects one atom in the protein and another in the ligand. We intend to capture the hydrogen bonds, polarization, electrostatics, van der Waals interactions, hydrophilicity, hydrophobicity, etc. of a protein-ligand complex through the bipartite graph coloring, i.e., atom-specific descriptions and subgraph weight.
The multiscale behavior of the MWCGS arises when a different selection of the characteristic distance $\eta_{kk'}$ for a pair of atom types $k$ and $k'$ are considered. Therefore, for a molecule or a biomolecule, the MWCGS allows us to systematically construct a family of collective, scalable, multiscale graph-based descriptors by an appropriate selection of atom types pair $k$ and $k'$, characteristic distance $\eta_{kk'}$, and subgraph weight $\Phi$. An illustration of the weighted colored subgraph under the SYBYL atom-type system for the molecule xanthine ($\text{C}_5\text{H}_4\text{N}_4\text{O}_2$) is presented in Figure \ref{fig:graph_cartoon}.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.7\textwidth]{xanthine_subgraph_cartoon}
\caption{Illustration of the weighted colored subgraph. Part (a) is a diagram of the structure of the xanthine molecule ($\text{C}_5\text{H}_4\text{N}_4\text{O}_2$; ligand name: XAN; PDB ID: 2uz9), and (b) the weighted colored subgraphs, from left to right, $\text{G}_{\text{N.am--O.2}}$, $\text{G}_{\text{N.pl3--O.2}}$, and $\text{G}_{\text{N.2--O.2}}$ consisting of SYBYL atom-type pair N.am--O.2, N.pl3--O.2, and N.2--O.2, respectively. The dashed line in (b) represents the edges of the graph.}
\label{fig:graph_cartoon}
\end{figure}
\subsection{Geometric Graph Learning}
The multiscale weighted colored geometric subgraph (MWCGS) descriptors for a molecule or molecular complex can be paired with any machine learning or deep learning algorithm to predict molecular properties. In a supervised machine learning algorithm (either classification or regression), the labeled dataset is divided into two parts: a training set and a test set. Let $\mathcal{X}_i$ be a labeled dataset for the $i$th molecule or molecular complex in the training set. Furthermore, suppose $\mathcal{G}(\mathcal{X}_i, \lambda)$ be a function that encodes the geometric information of the molecule or molecular complex into suitable graph representations with a set of parameters $\lambda$. The training of a machine learning model can be translated into a minimization problem,
\begin{equation}
\min_{\lambda, \theta} \sum_{i\in I} \mathcal{L}(\mathbf{y}_i,\mathcal{G}(\mathcal{X}_i, \lambda); \theta)
\end{equation}
where $\mathcal{L}$ is a scalar loss function to be minimized and $\mathbf{y}_i$ is the labels of the $i$th sample in the training set $I$. Here, $\theta$ is the set of hyperparameters that depends on the chosen machine learning algorithm and typically be optimized for optimal performance. A wide range of machine learning algorithms, such as support vector machines, random forests, gradient boosting trees, artificial neural networks, and convolution neural networks, can be implemented in conjugation with the present geometric subgraph descriptors. However, to focus on the descriptive power of the proposed geometric subgraph features, we only employ gradient boosting decision trees (GBDT) in the present work and avoid optimizing machine learning algorithm selections. Although relatively simple, GBDT is still powerful, robust against overfitting, and a widely used ensemble algorithm.
An illustration of the proposed geometric graph learning strategy is presented in Figure \ref{fig:ggl_strategy}.
We use GBDT module in scikit-learn v0.24.1 package with the following parameters: $\texttt{n\_estimators}=20 000$, $\texttt{max\_depth} = 8$, \texttt{min\_samples\_split} = 2, \texttt{learning\_rate} = 0.005, \texttt{loss} = ls, \texttt{subsample} = 0.7, and \texttt{max\_features} = sqrt. These
parameter values are selected from the extensive tests on PDBbind datasets and are uniformly used in all our validation
tasks in this work.
\begin{figure}[htbp]
\centering
\includegraphics[width=\textwidth]{ML_Flowchart}
\caption{Illustration of the geometric graph learning strategy using the molecular complex with PDBID: 5bwc (first column). The second column represents the protein-ligand atom-type pair CA--O.3, OE1--N.pl3, and NE1--C.2, respectively from top to bottom. The corresponding weighted colored geometric subgraphs are shown in the third column. The fourth column presents the statistics of the subgraph rigidity. In the final column, the advanced machine learning models such as the gradient boosting trees integrate these statistical features for training and prediction.}
\label{fig:ggl_strategy}
\end{figure}
\subsection{Dataset}
For protein-ligand binding affinity prediction, the most commonly used benchmarks are the PDBbind datasets. In this work, we use the three most popular PDBbind benchmark datasets, CASF--2007, CASF--2013, and CASF--2016, to test the performance of our model. The PDBbind datasets consist of a general set, a refined set, and a core set, where the latter set is a subset of the previous one. In the present work, we explore two different training sets to build predictive models for the binding affinity of the complexes in the test set, which is the core set of the corresponding benchmark. The first training set, denoted by $S_R$, is the refined set excluding the core set of the corresponding benchmark. As a second training set, denoted by $S_G$, we use the general set excluding the core set of the corresponding benchmark.
More information about these datasets is offered on the PDBbind website \url{http://pdbbind.org.cn/}. A summary of the dataset is provided in Table \ref{tab:PDBbind_dataset}.
\begin{table}[htbp]
\begin{center}
\caption{Summary of PDBbind datasets used in the present work.\Bstrut}
\begin{tabular}{llll}
\hline
Dataset & $\lvert S_G\rvert$ & $\lvert S_R \rvert$ & $\lvert S_C \rvert$\Tstrut\Bstrut\\
\hline
CASF--2007 benchmark & {2852} & 1105 & 195\Tstrut\Bstrut\\
CASF--2013 benchmark & {11713} & 3516 & 195\Tstrut\Bstrut\\
CASF--2016 benchmark & 12998 & 3772 & 285\Tstrut\Bstrut\\
\hline
\end{tabular}
\label{tab:PDBbind_dataset}
\end{center}
\begin{tablenotes}
\item $\lvert S_G \rvert$: Number of complexes in the general set excluding the core set of the corresponding benchmark.
\item $\lvert S_R \rvert$: Number of complexes in the refined set excluding the core set of the corresponding benchmark.
\item $\lvert S_C \rvert$: Number of complexes in the core set of the corresponding benchmark.
\end{tablenotes}
\end{table}
\subsection{Model Parametrization}
For the sake of convenience, we use the notation $\text{GGL}_{\kappa, \tau}^{\alpha}$ to indicate the geometric graph learning features generated by using kernel type $\alpha$ and corresponding kernel parameters $\kappa$ and $\tau$. Here, $\alpha=E$ and $\alpha=L$ refer to the generalized exponential and generalized Lorentz kernels, respectively.
And $\tau$ is used such that $\eta_{kk'}=\tau (\bar{r}_k + \bar{r}_{k'})$, where $\bar{r}_k$ and
$\bar{r}_{k'}$ are the van der Waals radii of atom type $k$ and atom type $k'$, respectively. Kernel parameters $\kappa$ and $\tau$ are selected
based on the cross-validation with a random split of the training data.
We propose a GGL representation in which multiple kernels are parametrized at different scale ($\eta$) values. In this work, we
consider at most two kernels. As a straightforward notation extension, two kernels can be parametrized by $\mathrm{GGL}_{\kappa_1,\tau_1;\kappa_2,\tau_2}^{\alpha_1,\alpha_2}$.
Each of these kernels gives rise to one set of features. Finally, as we consider two different schemes to extract the protein-ligand atom-type pair, we introduce the following two notations $^\text{sybyl}\text{GGL}_{\kappa_1,\tau_1;\kappa_2,\tau_2}^{\alpha_1,\alpha_2}$ and $^\text{ecif}\text{GGL}_{\kappa_1,\tau_1;\kappa_2,\tau_2}^{\alpha_1,\alpha_2}$.
\section{Results and Discussion}
In this section, we present the scoring power of our proposed geometric graph learning (GGL) model for the benchmark datasets discussed above.
\subsection{Hyperparameter Optimization and Model Performance}
It is a well-known fact that the performance of a machine-learning model depends on the optimization of its essential parameters. To achieve the best performance of our GGL model on each benchmark, we optimize the kernel parameters $\kappa$ and $\tau$. We use five-fold cross-validation (CV) and a grid search method to find the optimal parameters $\tau$ in the range $[0.5,10]$ and $\kappa$ in the range $[0.5,20]$ with an increment of 0.5 for both parameter ranges. The high values of the power parameter $\kappa$ are considered to approximate the ideal low--pass filter (ILF) \cite{xia2015multiscale}.
As a general strategy to optimize the model hyperparameters on each benchmark, we carry out a five-fold CV on the training set $S_R$ which is the refined set excluding the core set of the corresponding benchmark. Once we find the best model for each benchmark dataset, we test the performance of the model on the test set $S_C$ (i.e., the core set of the corresponding benchmark). For the prediction task, our first strategy is to train the model using the training set $S_R$ (i.e., the refined set excluding the core set) and observe the performance on the test set. And secondly, we train the best model using the training set $S_G$ (i.e., the general set excluding the core set) and test the performance on the test set. As the general set of each benchmark contains more diverse complexes than the refined set, we expect our model performs better when trained with the training set $S_G$.
Below we discuss the optimization of our model hyperparameters $\tau$ and $\kappa$ and the model's performance on each benchmark.
\subsubsection{CASF--2016}
The first benchmark we consider is the CASF--2016, the latest of the three benchmark datasets in the PDBbind database. We carry out five-fold cross-validation (CV) on the first training set which is the refined set excluding the core set of this benchmark. The CV results for both the single-scale and two-scale SYBYL atom-type GGL models are presented in Figure \ref{fig:v2016_multitypes_kernel_params}. The parameter set $(\kappa, \tau)=(2.5, 1.5)$ gives the best median Pearson's correlation coefficient $R_p$=0.795 for the single-scale exponential kernel (Figure \ref{fig:v2016_multitypes_kernel_params}a). For the single-scale Lorentz kernel model the parameters are $(\kappa, \tau)=(14.0, 1.5)$ with median $R_p$=0.795 (Figure \ref{fig:v2016_multitypes_kernel_params}b). The two-scale kernel model is built on top of the previously optimized single-scale kernel parameters, so we only optimize the parameters for the second kernel. Figure \ref{fig:v2016_multitypes_kernel_params}c and Figure \ref{fig:v2016_multitypes_kernel_params}d plots the CV results for the second kernel parameters $\kappa_2$ and $\tau_2$ of the two-scale kernel SYBYL atom-type model $^\text{sybyl}\text{GGL}_{\kappa_1,\tau_1;\kappa_2,\tau_2}^{\alpha_1,\alpha_2}$ with $\kappa_1$ and $\tau_1$ fixed at the optimal value from single-scale model. We observe that the best two-scale exponential kernel model is $^\text{sybyl}\text{GGL}_{2.5,1.5;15.0,8.5}^{\mathrm{E},\mathrm{E}}$ with median $R_p$=0.796 (Figure \ref{fig:v2016_multitypes_kernel_params}c) and the best two-scale Lorentz kernel model is $^\text{sybyl}\text{GGL}_{14.0,1.5;16.0,0.5}^{\mathrm{L},\mathrm{L}}$ with median $R_p$=0.797 (Figure \ref{fig:v2016_multitypes_kernel_params}d).
To find the optimal parameters for the ECIF atom-type models, we carry out a similar process discussed above. Figure \ref{fig:v2016_ecif_kernel_params} plots the CV performance of the single-scale kernel ECIF atom-type model $^\text{ecif}\text{GGL}_{\kappa,\tau}^{\alpha}$. We find that the best parameters for the single-scale exponential kernel model are $\kappa$=13.0 and $\tau$=2.5 with median $R_p$=0.790 (Figure \ref{fig:v2016_ecif_kernel_params}a) and the best parameters for the single-scale Lorentz kernel model are $\kappa$=14.0 and $\tau$=1.5 with median $R_p$=0.789 (Figure \ref{fig:v2016_ecif_kernel_params}b). The optimal parameters for the two-scale kernel model are also explored in a similar fashion as above. The CV results of each combination of the second kernel parameters are presented in Figure \ref{fig:v2016_ecif_kernel_params}. The figure confirms that the best two-scale exponential kernel model is $^\text{ecif}\text{GGL}_{13.0,2.5;15.0,9.0}^{\mathrm{E},\mathrm{E}}$ with median $R_p$=0.792 (Figure \ref{fig:v2016_ecif_kernel_params}c) and the best two-scale Lorentz kernel model is $^\text{ecif}\text{GGL}_{14.0,1.5;13.5,9.0}^{\mathrm{L},\mathrm{L}}$ with median $R_p$=0.791 (Figure \ref{fig:v2016_ecif_kernel_params}d).
After finding the best models for this benchmark, we are interested in validating their performance on the test set, i.e., the CASF--2016 core set. The performance is measured using the Pearson\textquotesingle s correlation coefficient between the predicted and the experimental binding affinities of the test set complexes. First, we train each model with the smaller training set $S_R$, i.e., the PDBbind v2016 refined set excluding the CASF--2016 core set. Then we use the trained model to predict the test set. To this end, we repeat the model up to 50 times and use the average of all predicted values as the final predicted set. As a second approach, we train the model with the bigger training set $S_G$, i.e., the PDBbind v2016 general set excluding the CASF--2016 core set. For the prediction task, we again repeat the trained model 50 times and use the average of all predictions.
The performance of the best models (both SYBYL atom-type and ECIF atom-type) on the test set are listed in Table \ref{tab:v2016_results}. We find that the performance of all models significantly improved when the model is trained with the bigger training data $S_G$. The results in Table \ref{tab:v2016_results} indicate that the two-scale models perform slightly better than their single-scale counterparts as expected. We also observe that the SYBYL atom-type models, both single-scale and two-scale, outperform their ECIF atom-type counterparts. The best model for this benchmark is the two-scale Lorentz kernel SYBYL atom-type model $^\text{sybyl}\text{GGL}_{14.0,1.5;16.0,0.5}^{\mathrm{L},\mathrm{L}}$ with reported Pearson\textquotesingle s correlation $R_p$=0.873. In addition, we compare the scoring power of our proposed GGL-Score against various state-of-the-art scoring functions in the literature \cite{cheng2009comparative,ballester2010machine,li2013id,li2015improving,li2014substituting,cao2014improved}. Figure \ref{fig:CASF_scoring_power}c illustrates such a comparison for CASF--2016 benchmark and clearly our model stands in the top. The second best is the TopBP-DL with reported $R_p$=0.848. It must be stressed that the base geometric and algebraic graph learning models that consider the element-specific interactions instead of the atom-type interactions have a comparatively lower performance with $R_p$=0.815 \cite{nguyen2017rigidity} and $R_p$=0.835 \cite{nguyen2019agl} respectively. The above comparison and Figure \ref{fig:CASF_scoring_power}c confirm the scoring power and the effectiveness of considering atom-type pair interactions in the present model.
Moreover, to highlight that the current model's impressive performance is due to the incorporation of the atom-type pair interactions and not because of the use of larger training data $S_G$, we explore the performance of the base GGL models with element-specific interactions that are trained on the set $S_G$. The details of this experiment and results are presented in Appendix \ref{appendix}. While the use of the bigger training data improves the performance of the base GGL model, our extended atom-type models still outperform them by a big margin (see Table \ref{tab:standard_atom_type_results}).
\begin{figure}[htbp]
\centering
\includegraphics[width=1\linewidth]{CASF2016_multitypes_parameters}
\caption{Optimized parameters for $^\text{sybyl}\text{GGL}$ model for CASF--2016 benchmark. The best parameters locations are marked by ``x''. The optimal parameters for, (a) single-scale exponential kernel model are $(\kappa,\tau)=(2.5,1.5)$ with the corresponding median $R_p=0.795$ and (b) single-scale Lorentz kernel model are $(\kappa,\tau)=(14.0,1.5)$ with corresponding median $R_p=0.795$. The optimal second kernel parameters for (c) two-scale exponential kernel model are $(\kappa,\tau)=(15.0,8.5)$ with the corresponding median $R_p=0.796$ and (d) two-scale Lorentz kernel model are $(\kappa,\tau)=(16.0,0.5)$ with the corresponding median $R_p=0.797$. }
\label{fig:v2016_multitypes_kernel_params}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[width=1\linewidth]{CASF2016_ecif_parameters}
\caption{Optimized parameters for $^\text{ecif}\text{GGL}$ model for CASF--2016 benchmark. The best parameters locations are marked by ``x''. The optimal parameters for (a) single-scale exponential kernel model are $(\kappa,\tau)=(13.0,2.5)$ with the corresponding median $R_p=0.790$ and (b) single-scale Lorentz kernel model are $(\kappa,\tau)=(14.0,1.5)$ with corresponding median $R_p=0.789$. The optimal second kernel parameters for (c) two-scale exponential kernel model are $(\kappa,\tau)=(15.0,9.0)$ with the corresponding median $R_p=0.792$ and (d) two-scale Lorentz kernel model are $(\kappa,\tau)=(13.5,9.0)$ with the corresponding median $R_p=0.791$.}
\label{fig:v2016_ecif_kernel_params}
\end{figure}
\begin{table}[htbp]
\begin{center}
\caption{Performance of various GGL models on CASF--2016 test set. \Bstrut}
\begin{tabular}{lcclc}
\multicolumn{3}{@{}c@{}}{Pearson\textquotesingle s $R_p$ of single-scale Model} &
\multicolumn{2}{@{}c@{}}{Pearson\textquotesingle s $R_p$ of two-scale Model}\Tstrut\Bstrut\\
\cline{1-3}\cline{4-5}
Model & Trained with $S_R$ & Trained with $S_G$ & Model & Trained with $S_G$ \Tstrut\Bstrut\\
\hline
$^\text{sybyl}\text{GGL}_{2.5,1.5}^{\mathrm{E}}$ & 0.838 & 0.872 & $^\text{sybyl}\text{GGL}_{2.5,1.5;15.0,8.5}^{\mathrm{E},\mathrm{E}}$ & 0.872\Tstrut\Bstrut\\
$^\text{sybyl}\text{GGL}_{14.0,1.5}^{\mathrm{L}}$ & 0.832 & 0.872 & $^\text{sybyl}\text{GGL}_{14.0,1.5;16.0,0.5}^{\mathrm{L},\mathrm{L}}$ & 0.873\Tstrut\Bstrut\\
\hline
$^\text{ecif}\text{GGL}_{13.0,2.5}^{\mathrm{E}}$ & 0.824 & 0.867 & $^\text{ecif}\text{GGL}_{13.0,2.5;15.0,9.0}^{\mathrm{E},\mathrm{E}}$ & 0.868\Tstrut\Bstrut\\
$^\text{ecif}\text{GGL}_{14.0,1.5}^{\mathrm{L}}$ & 0.822 & 0.865 & $^\text{ecif}\text{GGL}_{14.0,1.5;13.5,9.0}^{\mathrm{L},\mathrm{L}}$ & 0.868\Tstrut\Bstrut\\
\hline
\end{tabular}
\label{tab:v2016_results}
\end{center}
\end{table}
\subsubsection{CASF--2013}
As a second benchmark dataset among the CASF family, we consider the CASF--2013 benchmark. For both SYBYL atom-type and ECIF atom-type models, we carry out a similar hyperparameter optimization to that of the CASF--2016 benchmark. We use the smaller training set $S_R$ of this benchmark which is the PDBbind v2015 refined set excluding the CASF--2013 core set for the cross-validation process. Figure \ref{fig:v2013_multitypes_params} reveals the optimal parameters for the SYBYL atom-type model. The best parameters for the single-scale exponential kernel are found to be $\kappa$=5.5 and $\tau$=2.0 with median $R_p$=0.796 (Figure \ref{fig:v2013_multitypes_params}a) and the best parameters for the single-scale Lorentz kernel are $\kappa$=5.5 and $\tau$=0.5 with median $R_p$=0.795 (Figure \ref{fig:v2013_multitypes_params}b). For the two-scale kernel models, we fix the first kernel parameters at their optimal value and optimize the second kernel parameter. Figure \ref{fig:v2013_multitypes_params}c shows that the best two-scale exponential kernel model is $^\text{sybyl}\text{GGL}_{5.5,2.0;4.0,0.5}^{\mathrm{E},\mathrm{E}}$ with median $R_p$=0.798 and Figure \ref{fig:v2013_multitypes_params}d shows that the best two-scale Lorentz kernel model is $^\text{sybyl}\text{GGL}_{5.5,0.5;12.0,9.5}^{\mathrm{L},\mathrm{L}}$ with median $R_p$=0.798.
For the ECIF atom-type model hyperparameter optimization, we follow the same procedure as above. We found that the best single-scale exponential kernel model is $^\text{ecif}\text{GGL}_{12.0,2.5}^{\mathrm{E}}$ with median $R_p$=0.792 (Figure \ref{fig:v2013_ecif_params}a) and the best single-scale Lorentz kernel model is found to be $^\text{ecif}\text{GGL}_{18.0,2.0}^{\mathrm{L}}$ with median $R_p$=0.791 (Figure \ref{fig:v2013_ecif_params}b). For the two-scale kernel model, the best two-scale exponential kernel model is found to be $^\text{ecif}\text{GGL}_{12.0,2.5;15.0,8.5}^{\mathrm{E},\mathrm{E}}$ with median $R_p$=0.795 (Figure \ref{fig:v2013_ecif_params}c). Finally, from Figure \ref{fig:v2013_ecif_params}d, we found that the best two-scale Lorentz kernel model is $^\text{ecif}\text{GGL}_{18.0,2.0;15.0,8.5}^{\mathrm{L},\mathrm{L}}$ with median $R_p$=0.795.
Furthermore, we utilize the best models of this benchmark to predict the binding affinity of the 195 complexes in the CASF--2013 test set. Like the CASF--2016 benchmark, we first train each model using the smaller training set of this benchmark, i.e., the PDBbind v2015 refined set excluding the CASF--2013 core set, and then we generate a prediction for the test set from the average of 50 runs. Secondly, we use the more extensive training set, PDBbind v2015 general set, excluding the CASF--2013 core set to train the model and use it to get the prediction for the test set.
The performance of all models on the CASF--2013 test set is reported in Table \ref{tab:v2013_results}. It is interesting to see a similar trend that the performance of all models improved significantly when the model is trained on the bigger training data $S_G$. We also observe that the SYBYL atom-type models consistently outperform their ECIF atom-type counterparts. With the two-scale kernel model performing slightly better than the single-scale kernel model, the best-performing model for this benchmark is the two-scale exponential kernel SYBYL atom-type model $^\text{ecif}\text{GGL}_{12.0,2.5;15.0,8.5}^{\mathrm{E},\mathrm{E}}$ with reported Pearson\textquotesingle s correlation coefficient $R_p$=0.848. Additionally, Figure \ref{fig:CASF_scoring_power}b proves the dominance of our model in the scoring power over other published models for this benchmark. The reported $R_p$=0.848 of our best model is significantly higher than the $R_p$=0.808 of the runner-up model TopBP. Furthermore, Table \ref{tab:standard_atom_type_results} in Appendix \ref{appendix} confirms that the outstanding performance of our model is due to the incorporation of the atom-type interactions in the model.
\begin{figure}[htbp]
\centering
\includegraphics[width=1\linewidth]{CASF2013_multitypes_parameters}
\caption{Optimized parameters for $^\text{sybyl}\text{GGL}$ model for CASF--2013 benchmark. The best parameters locations are marked by ``x''. The optimal parameters for (a) single-scale exponential kernel model are $(\kappa,\tau)=(5.5,2.0)$ with the corresponding median $R_p=0.796$ and (b) single-scale Lorentz kernel model are $(\kappa,\tau)=(5.5,0.5)$ with corresponding median $R_p=0.795$. The optimal second kernel parameters for (c) two-scale exponential kernel model are $(\kappa,\tau)=(4.0,0.5)$ with the corresponding median $R_p=0.798$ and (d) two-scale Lorentz kernel model are $(\kappa,\tau)=(12.0,9.5)$ with the corresponding median $R_p=0.798$.}
\label{fig:v2013_multitypes_params}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[width=1\linewidth]{CASF2013_ecif_parameters}
\caption{Optimized parameters for $^\text{ecif}\text{GGL}$ model for CASF--2013 benchmark. The best parameters locations are marked by ``x''. The optimal parameters for (a) single-scale exponential kernel model are $(\kappa,\tau)=(12.0,2.5)$ with the corresponding median $R_p=0.792$ and (b) single-scale Lorentz kernel model are $(\kappa,\tau)=(18.0,2.0)$ with corresponding median $R_p=0.791$. The optimal second kernel parameters for (c) two-scale exponential kernel model are $(\kappa,\tau)=(15.0,8.5)$ with the corresponding median $R_p=0.795$ and (d) two-scale Lorentz kernel model are $(\kappa,\tau)=(15.0,8.5)$ with the corresponding median $R_p=0.795$.}
\label{fig:v2013_ecif_params}
\end{figure}
\begin{table}[htbp]
\begin{center}
\caption{Performance of various GGL models on CASF--2013 test set. \Bstrut}
\begin{tabular}{lcclc}
\multicolumn{3}{@{}c@{}}{Pearson\textquotesingle s $R_p$ of single-scale Model} &
\multicolumn{2}{@{}c@{}}{Pearson\textquotesingle s $R_p$ of two-scale Model}\Tstrut\Bstrut\\
\cline{1-3}\cline{4-5}
Model & Trained with $S_R$ & Trained with $S_G$ & Model & Trained with $S_G$ \Tstrut\Bstrut\\
\hline
$^\text{sybyl}\text{GGL}_{5.5,2.0}^{\mathrm{E}}$ & 0.797 & 0.846 & $^\text{sybyl}\text{GGL}_{5.5,2.0;4.0,0.5}^{\mathrm{E},\mathrm{E}}$ & 0.848\Tstrut\Bstrut\\
$^\text{sybyl}\text{GGL}_{5.5,0.5}^{\mathrm{L}}$ & 0.812 & 0.841 & $^\text{sybyl}\text{GGL}_{5.5,0.5;12.0,9.5}^{\mathrm{L},\mathrm{L}}$ & 0.844\Tstrut\Bstrut\\
\hline
$^\text{ecif}\text{GGL}_{12.0,2.5}^{\mathrm{E}}$ & 0.797 & 0.826 & $^\text{ecif}\text{GGL}_{12.0,2.5;15.0,8.5}^{\mathrm{E},\mathrm{E}}$ & 0.829\Tstrut\Bstrut\\
$^\text{ecif}\text{GGL}_{18.0,2.0}^{\mathrm{L}}$ & 0.801 & 0.829 & $^\text{ecif}\text{GGL}_{18.0,2.0;15.0,8.5}^{\mathrm{L},\mathrm{L}}$ & 0.833\Tstrut\Bstrut\\
\hline
\end{tabular}
\label{tab:v2013_results}
\end{center}
\end{table}
\subsubsection{CASF--2007}
Our last benchmark is the CASF--2007. The hyperparameter optimization for this benchmark is similar to the previous two benchmarks. The smaller training set $S_R$, which is the PDBbind v2007 refined set excluding the CASF-2007 core set, is used for the five-fold CV. The CV performances of the SYBYL atom-type models are plotted in Figure \ref{fig:v2007_multitypes_params}. The optimal kernel parameters for the single-scale exponential model are $\kappa$=2.5 and $\tau$=0.5 (Figure \ref{fig:v2007_multitypes_params}a) with median $R_p$=0.745. For the single-scale Lorentz kernel, Figure \ref{fig:v2007_multitypes_params}b, the best parameters are $\kappa$=13.5 and $\tau$=0.5 with median $R_p$=0.746. The two-scale models are built on top of the optimized single-scale model, we only search for the optimal second kernel parameters. Figure \ref{fig:v2007_multitypes_params}c shows that the two-scale exponential model $^\text{sybyl}\text{GGL}_{2.5,0.5;19.0,9.0}^{\mathrm{E},\mathrm{E}}$ gives the best median $R_p$=0.747 while Figure \ref{fig:v2007_multitypes_params}d reveals that the best two-scale Lorentz kernel model is $^\text{sybyl}\text{GGL}_{13.5,0.5;13.0,9.5}^{\mathrm{L},\mathrm{L}}$ with median $R_p$ being 0.747.
The hyperparameter optimization for the ECIF atom-type models is carried out in a similar fashion. Figure \ref{fig:v2007_ecif_params} displays the best parameters and the CV performance. We found that the best single-scale exponential model is $^\text{ecif}\text{GGL}_{17.5,1.5}^{\mathrm{E}}$ with median $R_p$=0.739 (Figure \ref{fig:v2007_ecif_params}a) and the best single-scale Lorentz kernel model is $^\text{ecif}\text{GGL}_{15.5,1.5}^{\mathrm{L}}$ with median $R_p$=0.738 (Figure \ref{fig:v2007_ecif_params}b). The best two-scale exponential kernel model is found to be $^\text{ecif}\text{GGL}_{17.5,1.5;16.5,8.5}^{\mathrm{E},\mathrm{E}}$ with median $R_p$=0.741 (Figure \ref{fig:v2007_ecif_params}c). Finally, (Figure \ref{fig:v2007_ecif_params}d), shows that the best two-scale Lorentz kernel model is $^\text{ecif}\text{GGL}_{15.5,1.5;15.0,7.5}^{\mathrm{L},\mathrm{L}}$ with median $R_p$=0.742.
Having optimized the models' hyperparameters, we now predict the binding affinity of the 195 complexes in the CASF-2007 test set. Just like in the previous two benchmarks, we first train each model using the smaller training set $S_R$ and produce a prediction for the test set from the average of 50 runs. Secondly, we use the bigger training set $S_G$ of this benchmark, which is the PDBbind v2007 general set excluding the CASF-2007 core set, to train the model and use the trained model to predict the binding affinity of the test set.
The performance of all our selected models for this benchmark is reported in Table \ref{tab:v2007_results}. We observe that all of these models perform significantly better when trained with the bigger training set $S_G$. Following a similar trend as in the previous two benchmarks, the SYBYL atom-type models of this benchmark consistently perform better than their ECIF atom-type counterparts. Also, the two-scale kernel model improves the performance compared to their single-scale versions. The best-performing model for this benchmark is the two-scale Lorentz kernel SYBYL atom-type model $^\text{sybyl}\text{GGL}_{13.5,0.5;13.0,9.5}^{\mathrm{L},\mathrm{L}}$ with Pearson\textquotesingle s correlation coefficient $R_p$=0.834. Moreover, Figure \ref{fig:CASF_scoring_power}a reveals the scoring power of our model in this benchmark. Our proposed GGL model stands at the top with reported $R_p$=0.834 while AGL-Score is the runner-up with $R_p$=0.830.
\begin{figure}[htbp]
\centering
\includegraphics[width=1\linewidth]{CASF2007_multitypes_parameters}
\caption{Optimized parameters for $^\text{sybyl}\text{GGL}$ model for CASF--2007 benchmark. The best parameters locations are marked by ``x''. The optimal parameters for (a) single-scale exponential kernel model are $(\kappa,\tau)=(2.5,0.5)$ with the corresponding median $R_p=0.745$ and (b) single-scale Lorentz kernel model are $(\kappa,\tau)=(13.5,0.5)$ with corresponding median $R_p=0.746$. The optimal second kernel parameters for (c) two-scale exponential kernel model are $(\kappa,\tau)=(19.0,9.0)$ with the corresponding median $R_p=0.747$ and (d) two-scale Lorentz kernel model are $(\kappa,\tau)=(13.0,9.5)$ with the corresponding median $R_p=0.747$.}
\label{fig:v2007_multitypes_params}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[width=1\linewidth]{CASF2007_ecif_parameters}
\caption{Optimized parameters for $^\text{ecif}\text{GGL}$ model for CASF--2007 benchmark. The best parameters locations are marked by ``x''. The optimal parameters for (a) single-scale exponential kernel model are $(\kappa,\tau)=(17.5,1.5)$ with the corresponding median $R_p=0.739$ and (b) single-scale Lorentz kernel model are $(\kappa,\tau)=(15.5,1.5)$ with corresponding median $R_p=0.738$. The optimal second kernel parameters for (c) two-scale exponential kernel model are $(\kappa,\tau)=(16.5,8.5)$ with the corresponding median $R_p=0.741$ and (d) two-scale Lorentz kernel model are $(\kappa,\tau)=(15.0,7.5)$ with the corresponding median $R_p=0.742$.}
\label{fig:v2007_ecif_params}
\end{figure}
\begin{table}[htbp]
\begin{center}
\caption{Performance of various GGL models on CASF--2007 test set. \Bstrut}
\begin{tabular}{lcclc}
\multicolumn{3}{@{}c@{}}{Pearson\textquotesingle s $R_p$ of single-scale Model} &
\multicolumn{2}{@{}c@{}}{Pearson\textquotesingle s $R_p$ of two-scale Model}\Tstrut\Bstrut\\
\cline{1-3}\cline{4-5}
Model & Trained with $S_R$ & Trained with $S_G$ & Model & Trained with $S_G$ \Tstrut\Bstrut\\
\hline
$^\text{sybyl}\text{GGL}_{2.5,0.5}^{\mathrm{E}}$ &0.803 & 0.824 & $^\text{sybyl}\text{GGL}_{2.5,0.5;19.0,9.0}^{\mathrm{E},\mathrm{E}}$ & 0.833\Tstrut\Bstrut\\
$^\text{sybyl}\text{GGL}_{13.5,0.5}^{\mathrm{L}}$ &0.807 & 0.827 & $^\text{sybyl}\text{GGL}_{13.5,0.5;13.0,9.5}^{\mathrm{L},\mathrm{L}}$ & 0.834\Tstrut\Bstrut\\
\hline
$^\text{ecif}\text{GGL}_{17.5,1.5}^{\mathrm{E}}$ &0.794 & 0.807 & $^\text{ecif}\text{GGL}_{17.5,1.5;16.5,8.5}^{\mathrm{E},\mathrm{E}}$ & 0.811\Tstrut\Bstrut\\
$^\text{ecif}\text{GGL}_{15.5,1.5}^{\mathrm{L}}$ & 0.792 & 0.805 & $^\text{ecif}\text{GGL}_{15.5,1.5;15.0,7.5}^{\mathrm{L},\mathrm{L}}$ & 0.809\Tstrut\Bstrut\\
\hline
\end{tabular}
\label{tab:v2007_results}
\end{center}
\end{table}
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=0.95\textwidth]{CASF_scoring_power}
\caption{Performance comparison of different scoring functions on CASF benchmarks. Our proposed model in this work, GGL-Score, is highlighted in red, and the rest is in purple. a) CASF--2007: the performances of other methods taken from previous studies \cite{cheng2009comparative,ballester2010machine,li2013id,li2015improving,li2014substituting,cao2014improved,wang2017improving}. Our $^\text{sybyl}\text{GGL-Score}$ achieves $R_p$=0.834 b) CASF--2013: the other results are extracted from \cite{wang2017improving,li2014comparative,li2015improving}. Our $^\text{sybyl}\text{GGL-Score}$ achieves $R_p$=0.848. c) CASF--2016: our $^\text{sybyl}\text{GGL-Score}$ achieves $R_p$=0.873, other scoring functions are discussed in \cite{su2018comparative,stepniewska2018development,wang2017improving}.}
\label{fig:CASF_scoring_power}
\end{center}
\end{figure}
\section{Conclusion}
The binding affinity between a ligand and its receptor protein is a key component in structure-based drug design. Although significant progress has been made over the past decades, an accurate prediction of protein-ligand binding affinity remains a challenging task. Geometric graph theories are widely used in the study of molecular and biomolecular systems. Furthermore, the element-type graph coloring-based multiscale weighted colored graph (MWCG) approaches have particularly shown success in the task of binding affinity prediction \cite{nguyen2017rigidity, nguyen2019agl}. On the other hand, SYBYL atom-type interaction and extended connectivity interactive features (ECIF) have enjoyed their success in molecular property prediction \cite{ballester2014does,sanchez2021extended}. Therefore, with an aim to develop robust and reliable scoring functions for large and diverse protein-ligand datasets, the present work combines the graph learning model and extended atom types to give rise to novel geometric graph theory-based multiscale weighted colored graph (MWCG) descriptors for the protein-ligand complex where the graph coloring is based on SYBYL atom-type and ECIF atom-type interactions. By pairing with the gradient boosting decision tree (GBDT) machine learning algorithm, our approach results in two different methods, namely $^\text{sybyl}\text{GGL}$-Score and $^\text{ecif}\text{GGL}$-Score. We explore the optimal hyperparameters of our models using a five-fold cross-validation on the training set of three commonly used benchmarks in drug design area, namely CASF-2007 \cite{cheng2009comparative}, CASF-2013 \cite{li2014comparative}, and CASF-2016 \cite{su2018comparative}. For the binding affinity prediction task of each benchmark's test set complexes, we consider two training sets-- the refined set excluding the core set and the general set excluding the core set. Our model performs significantly better in each benchmark when trained with the larger training set. It is also found that the SYBYL atom-type models $^\text{sybyl}\text{GGL}$-Score outperform the ECIF atom-type models $^\text{ecif}\text{GGL}$-Score in most cases.
To demonstrate the scoring power of the proposed models, many state-of-the-art scoring functions are considered in each benchmark.
Impressively, our $^\text{sybyl}\text{GGL}$-Score outperforms other models by a wide margin in all three PDBbind benchmarks. In addition to the accuracy and robustness, our model is computationally inexpensive-- the only required structural input is the atom types and coordinates. Moreover, our model can be applied in a vast majority of molecular property predictions such as toxicity, solubility, protein mutation, protein folding, and protein-nucleic acid interactions.
\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
\setcounter{figure}{0}
\renewcommand\thefigure{A\arabic{figure}}
\section{Appendix A}\label{appendix}
In this section, we explore the performance of the basic geometric graph approach model that considers element-type interactions presented in \cite{nguyen2017rigidity} using the bigger training set $S_G$, i.e. the general set excluding the core set of each benchmark. We carry out a similar experiment as we did for our present model. For simplicity, we use the notation $\text{GGL}_{\kappa,\tau}^{\alpha}$ for a single-scale kernel and $\text{GGL}_{\kappa_1,\tau_1;\kappa_2,\tau_2}^{\alpha_1, \alpha_2}$ for a two-scale kernel basic element-type geometric graph learning model. To find the optimized parameters for each benchmark, we carry out a five-fold CV on the training set $S_R$ i.e. the refined set excluding the core set of the corresponding benchmark. For CASF--2016 benchmark, the best single kernel models are found to be $\text{GGL}_{3.5,2.0}^{\mathrm{E}}$ (Figure \ref{fig:v2016_element_type_kernel_params}a)and $\text{GGL}_{16.0,2.0}^{\mathrm{L}}$ (Figure \ref{fig:v2016_element_type_kernel_params}b) with median Pearson correlation $R_p$=0.769 for both models. The best two kernel models for CASF--2016 are $\text{GGL}_{3.5,2.0;16.0,3.0}^{\mathrm{E},\mathrm{E}}$ (Figure \ref{fig:v2016_element_type_kernel_params}c) and $\text{GGL}_{16.0,2.0;12.0,1.5}^{\mathrm{L},\mathrm{L}}$ (Figure \ref{fig:v2016_element_type_kernel_params}d) with median $R_p$=0.773 for both models. The performance of all models on the test set of CASF--2016 benchmark are reported in Table \ref{tab:standard_atom_type_results}. It is interesting to find that the performance of each model improved significantly when trained with the bigger training data $S_G$ i.e. PDBbind v2016 general set excluding the core set. The best performing model for this benchmark is the two-scale exponential kernel model $\text{GGL}_{3.5,2.0;16.0,3.0}^{\mathrm{E},\mathrm{E}}$ with $R_p$=0.859. We note that both of our proposed GGL models, SYBYL atom-type and ECIF atom-type model, perform promisingly better (with reported $R_p$=0.873 and 0.868 respectively) than the basic element-type model.
The CV performance of CASF--2013 benchmark (Figure \ref{fig:v2013_element_type_kernel_params}), reveals that the best models for this benchmark are $\text{GGL}_{5.0,2.0}^{\mathrm{E}}$ and $\text{GGL}_{16.0,2.0}^{\mathrm{L}}$ for the single kernel, and $\text{GGL}_{5.0,2.0;15.0,3.0}^{\mathrm{E},\mathrm{E}}$ and $\text{GGL}_{16.0,2.0;11.5,1.5}^{\mathrm{L},\mathrm{L}}$ for two kernels, with median $R_p$= 0.774, 0.773, 0.778, and 0.776, respectively. Table \ref{tab:standard_atom_type_results} indicates that the use of the bigger training set $S_G$ improved the performance of these models. The best performing model for this benchmark is the single-scale exponential model $\text{GGL}_{5.0,2.0}^{\mathrm{E}}$ with reported $R_p$=0.821. However, our proposed SYBYL atom-type GGL model outperforms the basic GGL model by a huge margin with reported $R_p$=0.848 for this benchmark.
Figure \ref{fig:v2007_element_type_kernel_params} plots the CV performance for CASF--2007 benchmark. The best models for this benchmark are $\text{GGL}_{17.0,1.5}^{\mathrm{E}}$ and $\text{GGL}_{17.0,1.5}^{\mathrm{L}}$ for the single kernel, and $\text{GGL}_{17.0,1.5;16.5,3.0}^{\mathrm{E},\mathrm{E}}$ and $\text{GGL}_{17.0,1.5;6.5,10.0}^{\mathrm{L},\mathrm{L}}$ for two kernels, with median $R_p$= 0.724, 0.724, 0.733, and 0.730, respectively. The performance of these models is presented in Table \ref{tab:standard_atom_type_results}. We observe that the use of the bigger training data significantly improves the performance of each model for this benchmark as well. While the best performing basic GGL model for this benchmark is the two-scale exponential kernel model $\text{GGL}_{17.0,1.5;16.5,3.0}^{\mathrm{E},\mathrm{E}}$ with Pearson's $R_p$=0.833, our proposed SYBYL atom-type GGL model for this benchmark perform slightly better with $R_p$=0.834.
\begin{figure}[htbp]
\centering
\includegraphics[width=1\linewidth]{CASF2016_element_type_parameters}
\caption{Optimized parameters for basic $\text{GGL}$ model for CASF--2016 benchmark. The best parameters locations are marked by ``x''. The optimal parameters for (a) single-scale exponential kernel model are $(\kappa,\tau)=(3.5,2.0)$ with the corresponding median $R_p=0.769$ and (b) single-scale Lorentz kernel model are $(\kappa,\tau)=(16.0,2.0)$ with corresponding median $R_p=0.769$. The optimal second kernel parameters for (c) two-scale exponential kernel model are $(\kappa,\tau)=(16.0,3.0)$ with the corresponding median $R_p=0.773$ and (d) two-scale Lorentz kernel model are $(\kappa,\tau)=(12.0,1.5)$ with the corresponding median $R_p=0.773$.}
\label{fig:v2016_element_type_kernel_params}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[width=1\linewidth]{CASF2013_element_type_parameters}
\caption{Optimized parameters for basic $\text{GGL}$ model for CASF--2013 benchmark. The best parameters locations are marked by ``x''. The optimal parameters for (a) single-scale exponential kernel model are $(\kappa,\tau)=(5.0,2.0)$ with the corresponding median $R_p=0.774$ and (b) single-scale Lorentz kernel model are $(\kappa,\tau)=(16.0,2.0)$ with corresponding median $R_p=0.773$. The optimal second kernel parameters for (c) two-scale exponential kernel model are $(\kappa,\tau)=(15.0,3.0)$ with the corresponding median $R_p=0.778$ and (d) two-scale Lorentz kernel model are $(\kappa,\tau)=(11.5,1.5)$ with the corresponding median $R_p=0.776$.}
\label{fig:v2013_element_type_kernel_params}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[width=1\linewidth]{CASF2007_element_type_parameters}
\caption{Optimized parameters for basic $\text{GGL}$ model for CASF--2007 benchmark. The best parameters locations are marked by ``x''. The optimal parameters for (a) single-scale exponential kernel model are $(\kappa,\tau)=(17.0,1.5)$ with the corresponding median $R_p=0.724$ and (b) single-scale Lorentz kernel model are $(\kappa,\tau)=(17.0,1.5)$ with corresponding median $R_p=0.724$. The optimal second kernel parameters for (c) two-scale exponential kernel model are $(\kappa,\tau)=(16.5,3.0)$ with the corresponding median $R_p=0.733$ and (d) two-scale Lorentz kernel model are $(\kappa,\tau)=(6.5,10.0)$ with the corresponding median $R_p=0.730$.}
\label{fig:v2007_element_type_kernel_params}
\end{figure}
\begin{table}[htbp]
\begin{center}
\caption{Performance of various basic GGL models on all benchmark test sets. \Bstrut}
\begin{tabular}{l|lcclc}
\multicolumn{1}{c}{} & \multicolumn{3}{@{}c@{}}{Pearson\textquotesingle s $R_p$ of single-scale Model} &
\multicolumn{2}{@{}c@{}}{Pearson\textquotesingle s $R_p$ of two-scale Model}\Tstrut\Bstrut\\
\cline{2-4}\cline{5-6}
\multicolumn{1}{c}{} & Model & Trained with $S_R$ & Trained with $S_G$ & Model & Trained with $S_G$ \Tstrut\Bstrut\\
\hline
\multirow{2}{*}{CASF--2016}
& $\text{GGL}_{3.5,2.0}^{\mathrm{E}}$ & 0.843 & 0.856 & $\text{GGL}_{3.5,2.0;16.0,3.0}^{\mathrm{E},\mathrm{E}}$ & 0.859\Tstrut\Bstrut\\
& $\text{GGL}_{16.0,2.0}^{\mathrm{L}}$ & 0.839 & 0.848 & $\text{GGL}_{16.0,2.0;12.0,1.5}^{\mathrm{L},\mathrm{L}}$ & 0.856\Tstrut\Bstrut\\
\hline
\multirow{2}{*}{CASF--2013}
& $\text{GGL}_{5.0,2.0}^{\mathrm{E}}$ & 0.794 & 0.821 & $\text{GGL}_{5.0,2.0;15.0,3.0}^{\mathrm{E},\mathrm{E}}$ & 0.818\Tstrut\Bstrut\\
& $\text{GGL}_{16.0,2.0}^{\mathrm{L}}$ & 0.793 & 0.809 & $\text{GGL}_{16.0,2.0;11.5,1.5}^{\mathrm{L},\mathrm{L}}$ & 0.818\Tstrut\Bstrut\\
\hline
\multirow{2}{*}{CASF--2007}
& $\text{GGL}_{17.0,1.5}^{\mathrm{E}}$ & 0.809 & 0.828 & $\text{GGL}_{17.0,1.5;16.5,3.0}^{\mathrm{E},\mathrm{E}}$ & 0.833\Tstrut\Bstrut\\
& $\text{GGL}_{17.0,1.5}^{\mathrm{L}}$ & 0.815 & 0.830 & $\text{GGL}_{17.0,1.5;6.5,10.0}^{\mathrm{L},\mathrm{L}}$ & 0.830\Tstrut\Bstrut\\
\hline
\end{tabular}
\label{tab:standard_atom_type_results}
\end{center}
\end{table}
\section{Data and Software Availability}
The source code is available at Github: \url{https://github.com/NguyenLabUKY/GGL-ETA-Score}.
\section{Competing interests}
No competing interest is declared.
\section{Acknowledgments}
This work is supported in part by funds from the National Science Foundation (NSF: \# 2053284 and \# 2151802), and University of Kentucky Startup Fund.
| {'timestamp': '2023-01-18T02:15:24', 'yymm': '2301', 'arxiv_id': '2301.06194', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06194'} | arxiv |
\section{Introduction}
The classical separation logic proposed by Reynolds\cite{reynolds2002separation} is widely used to describe and verify various properties on heap-manipulated programs. It has evolved in many versions: object-oriented separation logic\cite{parkinson2008separation}, quantitative separation logic \cite{batz2019quantitative}, higher-order separation logic\cite{biering2007bi}, separation logic with inductive predicates\cite{brotherston2014decision}, etc. Its separating conjunction $*$ and separating implication $-*$ provides much succincter expressions on mutable data structures.
Sequences are also widely used in programs. Many data structures can be abstracted to sequences, including $\mathtt{vector}$ in C++, and $\mathtt{ArrayList}$ in Java. There are many string solvers on sequences, such as CVC4\cite{barrett2011cvc4} and Z3str3\cite{berzish2017z3str3}. Sequence predicate logic\cite{kutsia2004predicate} introduces sequence variables and sequence functions, and allows quantifiers over sequence variables. With sequence variables, sort function can be defined elegantly.
However, to our best knowledge, there is no integral formal systems on logical reasoning of programs with both heap and sequence. The example proposed in \cite{reynolds2002separation} provides a way to formally verify whether a program implements list reversal. The program aims to reverse the sequence $\alpha_0$ in $x$ and put it into $y$. The invariant of this program is written as follows:
\begin{align}\label{eg:sequence}
\exists \alpha \exists \beta.\;\bigl((\mathtt{ls}(x, \alpha) * \mathtt{ls}(y, \beta)) \land \alpha_0^{\dag} == \alpha^{\dag} \circ \beta\bigr),
\end{align}
where $\alpha^{\dag}$ denotes reversal of the sequence $\alpha$, and the term $\alpha \circ \beta$ denotes the concatenation of the two sequences $\alpha$ and $\beta$. The predicate $\mathtt{ls}(x,\alpha)$ denotes a singly-linked list starting from $x$, which can be inductively defined as follows:
\begin{equation}\label{eq:def_ls}
\begin{aligned}
\mathtt{ls}(x,\varepsilon) &\quad\overset{\triangle}{=}\quad x = \mathbf{nil}, \\
\mathtt{ls}(x,n \circ \alpha) &\quad\overset{\triangle}{=}\quad \exists y.\; x |-> y \circ n * \mathtt{ls}(y,\alpha).
\end{aligned}
\end{equation}
The property defined in \Cref{eg:sequence} can be attributed to properties on variable-length sequences in pointer programs. These properties can be found in many commonly-used mutable data structures, such as in stacks, queues, and graphs. Besides, variable-length sequences also appear in multilevel data structures, such as paging on operating systems, and file systems. It is necessary to introduce a logic to describe and verify these kind of properties.
In this paper, we aim to establish a logical foundation for \textbf{variable-length sequences} and \textbf{multilevel data structures} in pointer programs, especially on definition, expressiveness and decidability. We propose sequence-heap separation logic to \textbf{integrate sequences into logical reasoning in pointer programs}. The logic is an extension of both classical separation logic proposed in \cite{reynolds2002separation}, and sequence predicate logic proposed in \cite{kutsia2004predicate}.
Sequence-heap separation logic can be seen as a fragment of higher-order separation logic proposed in \cite{biering2007bi}. Quantifiers over sequences can be reduced to those over predicates (or over sets). Sequence-heap separation logic is less expressive than higher-order separation logic, but can be used in many scenarios on sequences in pointer programs, and has better deciability results.
In terms of definition for sequence-heap separation logic, we define the heap model as a finite partial mapping from locations to sequences, which is similar to the block model $\mathrm{Heap}_B$ defined in \cite{jin2022reasoning}. The model can be written as $h: \text{Loc} \overset{\mathrm{fin}}{\rightharpoonup} (\text{Loc} \cup \text{Val})^*$, compared to the model $h: \text{Loc} \overset{\mathrm{fin}}{\rightharpoonup} \text{Loc} \cup \text{Val}$ defined in the classical separation logic.
We also \textbf{define sequence singleton heap} as the term $x |-> \alpha$ to adapt more scenarios on variable-length sequences. The term can be used to denote stack, queue, variadic arguments, trees with variable-length branches, graphs with unbounded out-degree, etc. We take stack as an example.
In the classical separation logic, one has to describe stack with the inductive predicate $\mathtt{ls}(x,\alpha)$ defined in \Cref{eq:def_ls}, where $x$ and $\alpha$ denote the top pointer and contents of the stack respectively. However, with sequence singleton heap $x |-> \alpha$ defined in sequence-heap separation logic, one can use this formula to denote stack without inductive predicate.
The definition of sequence singleton heap can help us to get a decidable result. We prove that the $\Sigma_1$ fragment with sequence singleton heap is decidable, compared to the undecidable result on $\Sigma_1$ fragment in \cite{demri2018effects} where the list predicate $\mathtt{ls}(x,y)$, separating conjunctions, and separating implications are defined.
Besides, properly defining the form of $\alpha$ can help the logic to describe \textbf{multilevel data structures}. For example, if $\alpha$ is of the form $\alpha\#\beta$ (where $\alpha$ denotes the sequence of locations, $\beta$ denotes the sequence of contents, and $\#$ separates these two sequences), one can describe two-tier data structures\cite{jin2022reasoning} in block-based cloud storage systems in the following way.
\begin{align}\label{eq:multi}
(x |-> \alpha\#\varepsilon) * \forall y\exists \beta.\; \bigl(y \overline{\in} \alpha => (y \hookrightarrow \varepsilon\#\beta)\bigr),
\end{align}
where $x$ denotes the block location, $\alpha$ denotes the sequence of content location, and $\beta$ denotes contents in each location of $\alpha$. The term $y \overline{\in} \alpha$ denotes $y$ appears in $\alpha$, which is defined as follows:
\begin{align*}
y \overline{\in} \alpha \overset{\triangle}{=} \exists \alpha_1\exists \alpha_2.\; \alpha == \alpha_1 \circ y \circ \alpha_2.
\end{align*}
\Cref{eq:multi} can be illustrated by Fig. (\ref{fig:two_tier}).
\begin{figure}[!ht]
\centering
\includegraphics[width=0.4\textwidth]{img/Two-tier_data_structure.png}
\caption{Representation of two-tier data structure}
\label{fig:two_tier}
\end{figure}
We notice that sequence predicate logic proposed in \cite{kutsia2004predicate} is also capable of describing various properties on variable-length sequences. However, the logic cannot be directly used to describe sequences in pointer programs. sequence-heap separation logic is more than just the combination of sequence predicate logic and separation logic. The logic enriches the composition of the two.
We also notice that the model of sequence-heap separation logic is similar to that of block-based separation logic proposed in \cite{jin2022reasoning}. However, the sequence singleton heap and quantifiers over sequences in sequence-heap separation logic provide more abstraction, and can be used for wider application scenarios, not just for block-based cloud storage systems.
For example, the combined logic can simplify expressions on describing stack. Besides, sequence predicate logic and separation logic alone cannot describe multilevel data structures shown in \Cref{eq:multi}, but the combined one can do this.
We also study decidability problems of sequence-heap separation logic fragments. This can help us to find algorithms for decidable fragments, as well as to understand expressiveness of the logic intensively. We get the following two main fragments on satisfiability problems. One is a decidable fragment which lays between $\Sigma_1$ fragment of the classical separation logic, and the logic involving list predicate. The other is an undecidable fragment where there are two alternations on quantifiers over program variables, and one alternation on quantifiers over sequence variables.
The paper is organized as follows. In Section \rom{2}, we introduce some basic concepts of separation logic and sequence predicate logic. In Section \rom{3}, we define sequence-heap separation logic and explore its expressiveness. In Section \rom{4}, we prove that the satisfiability problem of $\Sigma_1$ fragment is decidable. In Section \rom{5}, we prove that the satisfiability problem of the fragment with the prenex normal form $\forall^*\forall^*\cap \forall^*\exists^*\exists^*$ is undecidable. In addition, we explore boundaries between decidable and undecidable fragments. In Section \rom{6}, we conclude our work, and propose future work on sequence-heap separation logic.
\textbf{Related work.} Separation logic can express properties on heaps, such as dangling pointers, non-circularity, and memory leakages.\cite{berdine2004decidable} However, the logic itself is proved to be undecidable\cite{brochenin2012almighty}. We investigate the following two categories of fragments: basic fragments without inductive predicates and $\Sigma_1$ fragments with inductive predicates.
In basic fragments, there are no user-defined predicates or hard-corded predicates. It is known that the validity problem of $\Pi_1$ fragment $\mathrm{SL}(*, -*)$ is decidable\cite{calcagno2001computability}, and that of basic fragment $\mathrm{SL}(\forall, \hookrightarrow)$ with quantifiers and no separation implications is undecidable\cite{calcagno2001computability}. If we restrict the size of the heap satisfying $\varphi_1$ in the formulae $\varphi_1 -* \varphi_2$ to be bounded (namely $n$), then we can get a decidable basic fragment $\mathrm{SL}(*,-*^n,\exists)$\cite{brochenin2012almighty}. To get decidable fragments, one can either restrict quantifier alternations in the formulae of prenex normal form, or number of quantified variables. For quantifier alternations, the fragment $\mathrm{SL}(\exists^*\forall^*)$ with 2 quantifier alternations is decidable\cite{reynolds2017reasoning}, while the fragment $\mathrm{SL}(\exists^*\forall^*\exists^*)$ with 3 is undecidable\cite{reynolds2017reasoning}. For quantified variables, the fragment $1\SL1$ with 1 quantified variable is decidable \cite{demri2017separation}, while the fragment $1\SL2$ with 2 quantified variables is undecidable \cite{demri2015two}.
In $\Sigma_1$ fragments, it contains separation implications (or its variants) and inductive predicates describing data structures. One basic result is that the satisfiability problem of $\Sigma_1$ fragment $\mathrm{SL}(*,-*,\mathtt{ls})$ with lists is undecidable\cite{demri2018effects}. However, if list predicates are restricted to the list with length at most 2, one can get a decidable fragment $\mathrm{SL}(*,-*,\mathtt{reach}_2)$\cite{demri2018effects}. Besides, if we further restrict heap unions in separation model, one can get strong-separation logic\cite{pagel2022strong}. It is proved that the strong-separation fragment $\mathrm{SSL}(*,\mathrel{\sepimp \mkern-15mu^{\lnot}},\mathtt{ls})$ with list predicates is decidable.
All fragments mentioned above can be found in TABLE \ref{table:decidability}.
\begin{table*}
\centering
\normalsize
\caption{Decidability of separation logic fragments}
\begin{tabular}{cccc}
\toprule
Fragment & Model & \makecell{Key connectives\\and predicates} & Decidability \\
\midrule
$\mathrm{SL}(*,-*)$
& \multirow{7}{*}{\makecell{separation\\model}}
& $\lnot, |->, *,- *$
& decidable
\\
$\mathrm{SL}(\forall, \hookrightarrow)$
&
& $\lnot, \forall, \hookrightarrow$
& undecidable
\\
$\mathrm{SL}(*,-*^n,\exists)$
&
& $*\lnot,,-*^n,\exists$
& decidable
\\
$\mathrm{SL}(\exists^*\forall^*)$
&
& prenex $\exists^*\forall^*$
& decidable
\\
$\mathrm{SL}(\exists^*\forall^*\exists^*)$
&
& prenex $\exists^*\forall^*\exists^*$
& undecidable
\\
$1\SL1$
&
& 1 quantified variable
& decidable
\\
$1\SL2$
&
& 2 quantified variables
& undecidable
\\
\midrule
$\mathrm{SL}(*,-*,\mathtt{ls})$
& separation model
& $\lnot, *, -*, \mathtt{ls}(x,y)$
& undecidable
\\
$\mathrm{SL}(*,-*,\mathtt{reach}_2)$
& separation model
& $\lnot, *, -*, \mathtt{reach}_2(x,y)$
& decidable
\\
$\mathrm{SSL}(*,\mathrel{\sepimp \mkern-15mu^{\lnot}}, \mathtt{ls})$
& \makecell{strong-separation\\model}
& $\lnot, *, \mathrel{\sepimp \mkern-15mu^{\lnot}}, \mathtt{ls}$
& decidable
\\
\bottomrule
\end{tabular}
\label{table:decidability}
\end{table*}
Sequence predicate logic is an extension of word equation. Specifically, word equations are $\Sigma_1$ fragment or $\Pi_1$ fragment of sequence predicate logic, where there are only quantifiers over sequence variables. It can express many properties on sequences, such as conjugates, and lexicographic ordering on words\cite{karhumaki2000expressibility}. On the other hand, it cannot express properties such as "the primitiveness" and "the equal length". It is shown that every Boolean combinations of word equations on free semigroup can be reduced to a single word equation\cite{makanin1977problem}.
Different from the classical predicate logic, sequence variables, sequence predicates and sequence functions are defined in sequence predicate logic\cite{kutsia2004predicate}. The problem of whether there is a solution for word equation is decidable\cite{makanin1977problem}. Namely, the truth of $\Sigma_1$ fragment of sequence predicate logic is decidable. Further researches show that the truth of positive formulae (where there is no negations or inequalities) which is of the form $\forall^*\exists^*$\cite{durnev1995undecidability}, $\exists^*\forall^*$\cite{day2018satisfiability} or $\exists^*\forall^*\exists^*$\cite{vavzenin1983decidability} is shown to be undecidable. To get a decidable fragment, one can restrict the formulae of the form $\exists^*\forall^*$ to the positive one\cite{vavzenin1983decidability}.
There are some works which combine separation logic and sequences. When formalizing cloud storage systems, one can construct a modeling language $\textbf{IMDSS}$\cite{jing2017modeling}, and a proof system based on separation logic\cite{jin2022reasoning}. These papers define values of heaps as finite sequences, and describe properties on blocks without using sequence singleton heap. Coq-based proof assistant\cite{zhang2022tool} is implemented based on the logic defined in \cite{jin2022reasoning}.
\section{Preliminaries}
In this section, we introduce some basic concepts on separation logic and sequence predicate logic.
\subsection{Separation logic}
In this subsection, we mainly focus on definitions and expressiveness of separation logic.
\begin{definition}[Definition of separation logic]
The syntax of separation logic\cite{reynolds2000intuitionistic} with 1 records is defined as follows:
\vspace{-1em}
\small
\begin{align*}
t \quad::=&\quad \mathbf{nil} \mid n \mid x \mid \mathtt{f}^n(t,\dots,t) \\
p \quad::=&\quad t = t \mid \mathbf{emp} \mid t |-> t \mid \mathtt{P}^n(t,\dots,t) \\
\varphi \quad::=&\quad p \mid \lnot \varphi \mid \varphi \land \varphi \mid \varphi \lor \varphi \mid \varphi => \varphi \mid \varphi * \varphi \mid \varphi -* \varphi \mid \exists x.\varphi,
\end{align*}
\normalsize
where $n$ denotes constants, $x$ denotes variables, $\mathtt{f}^n$ denotes $n$-ary functions mapping $\mathbb{N}^n$ to $\mathbb{N}$, and $\mathtt{P}^n$ denotes $n$-ary predicates mapping $\mathbb{N}^n$ to $\{0,1\}$.
The underlying model $\sigma=(s,h)$ of separation logic consists of a stack $s$ and a heap $h$. The set $\mathrm{Loc}$ comprises locations excluding $\mathbf{nil}$. The set $\mathrm{Var}$ comprises symbols of variables, including $x,y,z,\dots$. The set $\mathrm{Val}$ comprises integer values. The model is defined as follows:
\begin{table}[htbp]
\centering
\label{table1}
\tabcolsep=0.5cm
\renewcommand\arraystretch{1.2}
\normalsize
\begin{tabular}{ll}
$\text{Loc}, \text{Val} \subseteq \mathbb{N}$ &
$\mathbf{nil} \in \text{Atoms}$ \\
$s: \text{Var} -> \text{Loc} \cup \text{Val}$ &
$h: \text{Loc} \overset{\mathrm{fin}}{\rightharpoonup} (\text{Loc} \cup \text{Val})^*$.
\end{tabular}
\end{table}
\vspace{-0.5em}
The semantics of the term $\mathtt{f}^n(t_1,\dots,t_n)$ can be defined as follows, where $\mathtt{f}_\sigma^n$ is the interpretation of $\mathtt{f}^n$.
\begin{align*}
|[\mathtt{f}^n(t_1,\dots,t_n)|]\sigma = \mathtt{f}_\sigma^n(|[t_1|]\sigma,\dots,|[t_n|]\sigma).
\end{align*}
The semantics of formulae is inductively defined as follows:
\begin{align*}
& \sigma |= t_1 = t_2
&\text{iff}&\quad
|[t_1|]\sigma = |[t_2|]\sigma. \\
& \sigma |= \mathbf{emp}
&\text{iff}&\quad
\mathtt{dom}(h) = \varnothing. \\
& \sigma |= t_1 |-> t_2
&\text{iff}&\quad
|[t_1|]\sigma != \mathbf{nil} \text{ and } \mathtt{dom}(h) = \{|[t_1|]\sigma\} \\
& & & \quad \text{ and } h(|[t_1|]\sigma) = |[t_2|]\sigma. \\
& \sigma |= \mathtt{P}^n(t_1,\dots,t_n)
&\text{iff}&\quad
\mathtt{P}_\sigma^n(|[t_1|]\sigma,\dots,|[t_n|]\sigma) \text{ holds.} \\
& \sigma |= \lnot \varphi
&\text{iff}&\quad
\sigma \nvDash \varphi. \\
& \sigma |= \varphi_1 \land \varphi_2
&\text{iff}&\quad
\sigma |= \varphi_1 \text{ and } \sigma |= \varphi_2. \\
& \sigma |= \varphi_1 \lor \varphi_2
&\text{iff}&\quad
\sigma |= \varphi_1 \text{ or } \sigma |= \varphi_2. \\
& \sigma |= \varphi_1 => \varphi_2
&\text{iff}&\quad
\text{if } \sigma |= \varphi_1 \text{, then } \sigma |= \varphi_2. \\
& \sigma \;|=\; \varphi_1 * \varphi_2
&\text{iff} &\quad
\text{there exists heap } h_1 \text{ and } h_2, \\
& & & \quad \text{such that } \mathtt{dom}(h_1) \cap \mathtt{dom}(h_2) = \varnothing, \\
& & & \quad \text{and } h = h_1 \uplus h_2, \text{ and } (s,h_1) \;|=\; \varphi_1 , \\
& & & \quad \text{and } (s,h_2) \;|=\; \varphi_2. \\
& \sigma \;|=\; \varphi_1 -* \varphi_2 &
\text{iff} &
\quad \text{for all heaps } h_1, \\
& & & \quad \text{if } \mathtt{dom}(h_1) \cap \mathtt{dom}(h) = \varnothing \text{,} \\
& & & \quad \text{and } (s,h_1) \;|=\; \varphi_1, \\
& & & \quad \text{then } (s,h_1 \uplus h) \;|=\; \varphi_2. \\
& \sigma \;|=\; \exists x.\varphi &
\text{iff} &
\quad \text{there exists } x_0 \text{ in Loc} \cup \text{Val,} \\
& & & \quad \text{such that } (s[x -> x_0], h) \;|=\; \varphi,
\end{align*}
where $\mathtt{P}_\sigma^n$ denotes the interpretation of $\mathtt{P}^n$.
\end{definition}
For convenience, we have the following notation\cite{reynolds2000intuitionistic} denoting that $t$ points to $t_1,\dots,t_n$ with some fixed $n$.
\begin{align}\label{eq:singleton}
t |-> t_1,\dots,t_n \overset{\triangle}{=} (t |-> t_1) * \dots * (t + n - 1 |-> t_n).
\end{align}
In some fragments of separation logic, the heap model is defined as $h: \text{Loc} \overset{\text{fin}}{\rightharpoonup} \text{Val}^n$ with some fixed $n$\cite{reynolds2000intuitionistic}\cite{berdine2005symbolic}. In this case, \Cref{eq:singleton} will no longer hold. The semantics of the notation is defined as follows:
\begin{align*}
& \sigma |= t |-> t_1,\dots,t_n &\text{iff}\quad& |[t|]\sigma != \mathbf{nil} \text{ and } \mathtt{dom}(h) = \{|[t|]\sigma\}, \\
& & & \text{ and } h(|[t|]\sigma) = (|[t_1|]\sigma,\dots,|[t_n|]\sigma).
\end{align*}
We notice that in either separation logic or one of its fragments (symbolic heap\cite{berdine2004decidable}\cite{berdine2005symbolic}, strong-separation logic\cite{pagel2022strong}, etc.), the singleton heap is defined with some fixed number $n$. It may not be suitable for describing properties on blocks, or graphs where each node is of unbounded out-degrees.
The paper \cite{jin2022reasoning} introduces sequence into separation logic to describe properties on block-based cloud storage systems. The model of the logic is defined as a quintuple of the form $(s_F, s_B, s_V, h_B, h_V)$, where $s_F, s_B, s_V$ are assignments of file variables, block variables and location variables respectively, $h_B, h_V$ are heaps of blocks and heaps of values respectively. The file stack $s_F$ is a mapping from file variables to a sequence of block addresses, which is denoted as $s_F \overset{\triangle}{=} \text{FVar} -> \text{BLoc}^*$, and $h_B$ is a finite partial mapping from blocks to sequences of locations, which is denoted as $h_B \overset{\triangle}{=} \text{BLoc} \overset{\text{fin}}{\rightharpoonup} \text{Loc}^*$. Although $s_F$ and $h_B$ both range over sequences, the logic does not introduce sequence variables, sequence functions, or sequence singleton heap. The logic visits these sequences by existential quantifiers on block variables, and by equality over values of block variables.
\subsection{Word equations and sequence predicate logic}
Word equation can be seen as a special case of sequence predicate logic. It can be defined as follows:
\begin{definition}[Word equation]
Suppose $X^*$ is a free semigroup satisfying $X = \{n_1,\dots,n_k\}$ with unknowns $\alpha_1,\dots,\alpha_m \in X^*$, where $n_1,\dots,n_k$ are generators. Word equation is an equality of the form:
\begin{align*}
U(n_1,\dots,n_k,\alpha_1,\dots,\alpha_m) == V(n_1,\dots,n_k,\alpha_1,\dots,\alpha_m),
\end{align*}
where $==$ is the equality between two concatenations of sequences. If there is a solution for $U == V$, then the word equation is satisfied.
\end{definition}
The definition of word equation can be enhanced with Boolean combination, as is shown in \Cref{def:Boolcomb}.
\begin{definition}[Boolean combination of word equations]\label{def:Boolcomb}
Boolean combination of word equations is defined as follows:
\begin{align*}
t &\quad::=\quad n \mid \alpha \mid t \circ t \\
\varphi &\quad::=\quad t == t \mid \lnot \varphi \mid \varphi \land \varphi \mid \varphi \lor \varphi,
\end{align*}
where $n$ denotes constants, $\alpha$ denotes sequence variables, and $t_1 \circ t_2$ denotes the concatentation of two sequences $t_1$ and $t_2$.
\end{definition}
Word equation is capable of describing many properties on sequences. Every Boolean combinations of word equations can be reduced to a single word equation followed by \Cref{thm:Boolean comb}\cite{karhumaki2000expressibility}.
\begin{theorem}\label{thm:Boolean comb}
For every Boolean combinations $\varphi$ defined above, there exists a single word equation $T(\varphi) \overset{\triangle}{=} U == V$, which is equivalent to $\varphi$. The proof sketch of the theorem can be found in Appendix.
\end{theorem}
If word equation is enhanced with sequence function, and quantifiers over variables and sequences, then one can get the following definition of sequence predicate logic.
\begin{definition}[Sequence predicate logic]\label{def:seqPredLogic}
The syntax of sequence predicate logic\cite{kutsia2004predicate} can be defined as follows:
\begin{align*}
t &\quad::=&& n \mid x \mid \alpha \mid t \circ t \mid \mathtt{f}(t,\dots,t) \mid \overline{\mathtt{f}}(t,\dots,t) \\
\varphi &\quad::=&& t == t \mid \mathtt{P}(t,\dots,t) \mid \lnot \varphi \mid \varphi \land \varphi \mid \varphi \lor \varphi \\
&&& \mid \varphi => \varphi \mid \exists x.\varphi \mid \exists \alpha.\varphi.
\end{align*}
The variable $x$ denotes individual variables, and $\alpha$ denotes sequence variables. The arity of $\mathtt{f}$, $\overline{\mathtt{f}}$, and $\mathtt{P}$ can be either fixed or flexible. When it is fixed, there is no sequence variables on parameters. When it is flexible, it may contain sequence variables.
The structure of the logic is defined as $(\mathrm{Val},I)$, where $\mathrm{Val}$ is the domain, and $I$ is the interpretation on individual and sequence constants, functions and predicates. The assignment of the logic can be defined as $(s_x,s_{\alpha})$, where $s_x: \mathrm{IVar} -> \mathrm{Val}$, $s_{\alpha}: \mathrm{SVar} -> \mathrm{Val}^*$, and $\mathrm{IVar} = \{x,y,z,\dots\}$, $\mathrm{SVar} = \{\alpha,\beta,\gamma,\dots\}$.
In sequence predicate logic, $t_1 \circ t_2$ denotes the concatenation between two sequences $t_1$ and $t_2$, $t_1 == t_2$ denotes that two equations $t_1$ and $t_2$ are equal. Due to space limitations, we do not list the semantics of the logic. The details can be found in \cite{kutsia2004predicate}\cite{kutsia2007solving}.
\end{definition}
\subsection{Expressiveness of sequence predicate logic}
We recall properties which can be expressed by sequence predicate logic. They are useful for describing properties with sequence-heap separation logic.
\noindent\textbf{Length}. Sequence predicate logic can be used to get the length of a sequence. The function $\mathtt{length}(\alpha)$ denotes the length of the sequence $\alpha$, which can be inductively defined as follows:
\begin{align*}
\mathtt{length}&(\varepsilon) \overset{\triangle}{=} 0 \\
\mathtt{length}&(n \circ \alpha) \overset{\triangle}{=} 1 + \mathtt{length}(\alpha).
\end{align*}
For convenience, we define $|\alpha|$ to denote $\mathtt{length}(\alpha)$.
\noindent\textbf{Statistics}. Sequence predicate logic can be used to get occurrences of specific terms. The function $\mathtt{find}(\alpha, x)$ denotes the occurrences of $x$ in sequence $\alpha$, which can be inductively defined as follows:
\begin{align*}
\mathtt{find}&(\varepsilon, x) \overset{\triangle}{=} 0 & \\
\mathtt{find}&(n \circ \alpha, x) \overset{\triangle}{=} 1 + \mathtt{find}(\alpha, x), & n = x \\
\mathtt{find}&(n \circ \alpha, x) \overset{\triangle}{=} \mathtt{find}(\alpha, x), & n \neq x
\end{align*}
For convenience, we define $|\alpha|_{x}$ to denote $\mathtt{find}(\alpha, x)$.
\noindent\textbf{Lookups}. The predicate $\mathtt{eq}(x_1, \alpha, x_2)$ denotes the $x_2$-th item of sequence $\alpha$ is $x_1$, which can be expressed as follows:
\begin{align*}
\mathtt{eq}(x_1, \alpha, x_2) \overset{\triangle}{=} \exists \alpha_1 \exists \alpha_2.\; \alpha == \alpha_1 \circ x_1 \circ \alpha_2 \land |\alpha_1 \circ x_1| = x_2.
\end{align*}
Note that $\alpha(x)$ does not appear as a term in \Cref{def:seqPredLogic}. If so, consider the case where $x$ exceeds the length of sequence $\alpha$. A new value $\perp$ should be introduced to denote illegal term, which may complicate the logic. We take $x_1 = \alpha(x_2)$ to denote $\mathtt{eq}(x_1,\alpha,x_2)$ for convenience:
\begin{align*}
x_1 = \alpha(x_2) \overset{\triangle}{=} \mathtt{eq}(x_1,\alpha,x_2).
\end{align*}
Other properties can be expressed with lookups. We list some of them below.
The relationships between items and sequences can be defined as $x \;\bar{\in}\; \alpha$, which means $x$ can be found in the sequence $\alpha$:
\begin{align*}
x \;\bar{\in}\; \alpha \overset{\triangle}{=} \exists x_1.\; x = \alpha(x_1).
\end{align*}
The $x_1$-th item of the sequence $\alpha_1$ is equal to the $x_2$-th item of the sequence $\alpha_2$:
\begin{equation*}
\mathtt{eq}(\alpha_1, x_1, \alpha_2, x_2) \overset{\triangle}{=} \exists x_3.\; x_3 = \alpha_1(x_1) \land x_3 = \alpha_2(x_2).
\end{equation*}
\noindent\textbf{Unary property}. All items in the sequence $\alpha$ satisfies the unary property $\mathtt{P}^1(x)$:
\begin{align*}
\forall x \forall \alpha_1 \forall \alpha_2.\; \alpha == \alpha_1 \circ x \circ \alpha_2 => \mathtt{P}^1(x).
\end{align*}
\noindent\textbf{Binary property}. Each two items with different indices in the sequence $\alpha$ satisfies the binary property $\mathtt{P}^2(x_1,x_2)$ :
\begin{align*}
\forall x_1 \forall x_2 \forall \alpha_1 \forall \alpha_2 \forall \alpha_3.\;& \alpha == \alpha_1 \circ x_1 \circ \alpha_1 \circ x_2 \circ \alpha_3 \\
& => \mathtt{P}^2(x_1,x_2).
\end{align*}
Increment and set-like defined bellow are binary properties.
\noindent\textbf{Increment}. The sequence $\alpha$ is strictly increasing:
\begin{align*}
\mathtt{Inc}(\alpha) \overset{\triangle}{=} \;& \forall x_1 \forall x_2 \forall \alpha_1 \forall \alpha_2 \forall \alpha_3.\\
& \alpha == \alpha_1 \circ x_1 \circ \alpha_2 \circ x_2 \circ \alpha_3 => x_1 < x_2.
\end{align*}
\noindent\textbf{Set-like}. Each two items in sequence $\alpha$ are distinct:
\begin{align*}
\mathtt{Diff}(\alpha) \overset{\triangle}{=} \;& \forall x_1 \forall x_2 \forall \alpha_1 \forall \alpha_2 \forall \alpha_3. \\
& \alpha == \alpha_1 \circ x_1 \circ \alpha_1 \circ x_2 \circ \alpha_3 => x_1 != x_2.
\end{align*}
\noindent\textbf{Segment}. The sequence $\alpha_2$ is the consecutive sub-sequence of $\alpha_1$:
\begin{equation*}
\alpha_2 \;\in\; \mathtt{Seg}(\alpha_1) \overset{\triangle}{=} \exists \alpha_3 \exists \alpha_4.\\ \alpha_1 == \alpha_3 \circ \alpha_2 \circ \alpha_4.
\end{equation*}
\noindent\textbf{Truncation}. The sequence $\alpha_2$ is the consecutive sub-sequence of $\alpha_1$ with indices ranging over $[x_1, x_2)$ :
\begin{align*}
&\alpha_2 ==\;
\mathtt{Trunc}(\alpha_1,x_1,x_2) \\
\overset{\triangle}{=} \quad& \exists \alpha_3 \exists \alpha_4.\; \alpha_1 == \alpha_3 \circ \alpha_2 \circ \alpha_4 \\
& \hspace{4em} \land |\alpha_3| = x_1 - 1 \land |\alpha_3 \circ \alpha_2| = x_2 - 1.
\end{align*}
\section{sequence-heap separation logic}
sequence-heap separation logic is an extension of both classical separation logic and sequence predicate logic. It can describe properties on variable-length sequences, and multilevel data structures. Some properties cannot be expressed easily by the classical separation logic or sequence predicate logic alone.
In this section, we present the definition and expressiveness of sequence-heap separation logic (SeqSL).
\subsection{Definition of sequence-heap separation logic}
\begin{definition}[Syntax of sequence-heap separation logic]\label{def:syntaxSeqSL}
The syntax of the logic can be defined as follows:
\begin{align*}
t_x &\quad::= \quad \mathbf{nil} \mid \# \mid n \mid x \\
t_{\alpha} &\quad::= \quad \varepsilon \mid t_x \mid \alpha \mid t_{\alpha} \circ t_{\alpha} \\
\varphi &\quad::= \quad t_x = t_x \mid t_{\alpha} == t_{\alpha} \mid \lnot \varphi \mid \varphi \land \varphi \mid \varphi \lor \varphi \mid \varphi => \varphi \\
& \hspace{3.5em} \mid \mathbf{emp} \mid t_x |-> t_\alpha \mid \varphi * \varphi \mid \varphi -* \varphi \mid \exists x.\varphi \mid \exists \alpha.\varphi.
\end{align*}
\end{definition}
Note that other functions and predicates can be defined in SeqSL following the definition in \cite{kutsia2004predicate}, such as comparison between sequence, and picking up an item from a sequence. Most commonly-used predicates and functions can be expressed by the logic defined above.
\begin{definition}[Model of sequence-heap separation logic]\label{def:modelSeqSL}
There are three types of variables in the signature of SeqSL: program variables $\text{PVar} = \{x, y, z, \dots\}$, sequence variables $\text{SVar} = \{\alpha, \beta, \gamma, \dots\}$. These sets are all countable. The model $\sigma = (s_x,s_{\alpha},h)$ can be defined as follows:
\begin{table}[H]
\centering
\label{table1}
\tabcolsep=0.5cm
\renewcommand\arraystretch{1.2}
\normalsize
\begin{tabular}{ll}
$\text{Loc}, \text{Val} \subseteq \mathbb{N}$ &
$\mathbf{nil}, \# \in \text{Atoms}$ \\
$\text{Loc} \cap \text{Atoms} = \varnothing$ &
$s_x: \text{PVar} -> \text{Loc} \cup \text{Val}$ \\
$s_{\alpha}: \text{SVar} -> (\text{Loc} \cup \text{Val})^*$ &
$h: \text{Loc} \overset{\text{fin}}{\rightharpoonup} (\text{Loc} \cup \text{Val})^*$,
\end{tabular}
\end{table}
\vspace{-0.5em}
where Loc is the set of locations, Val is the set of values, Atoms is the set of reserved words, $s_x$ denotes the stack, $s_{\alpha}$ denotes the assignment on sequence variables, and $h$ denotes the heap which stores sequence of locations, values, or atoms.
\end{definition}
\begin{definition}[Semantics of terms]\label{def:smtsTerms}
The symbol $t_x$ denotes \textbf{individual term}, whose value ranges over Val. The denotational semantics of the term can be inductively defined as follows:
\begin{align*}
|[&\mathbf{nil}|]\sigma = \mathbf{nil} &
|[&\#|]\sigma = \# \\
|[&n|]\sigma = n &
|[&x|]\sigma = s_x(x),
\end{align*}
where $\mathbf{nil}, \#$ in Atoms cannot be used as a location, and $\#$ is used to describe multilevel data structures.
The symbol $t_{\alpha}$ denotes \textbf{sequence term}, whose value ranges over $(\text{Loc} \cup \text{Val})^*$ . The denotational semantics of the term can be inductively defined as follows:
\begin{align*}
|[&\varepsilon|]\sigma = \varepsilon &
|[&t_x|]\sigma \text{ is defined above} \\
|[&\alpha|]\sigma = s_{\alpha}(\alpha) &
|[&t_{\alpha_1} \circ t_{\alpha_2}|]\sigma = |[t_{\alpha_1}|]\sigma \circ |[t_{\alpha_2}|]\sigma,
\end{align*}
where $|[t_{\alpha_1}|]\sigma \circ |[t_{\alpha_2}|]\sigma$ denotes the concatenation of two sequences $|[t_{\alpha_1}|]\sigma$ and $|[t_{\alpha_2}|]\sigma$.
\end{definition}
\begin{definition}[Semantics of sequence-heap separation logic]\label{def:semanticsSeqSL}
In SeqSL, the indices of sequence items start from 1. We set $\text{Values} = \text{Val} \; \cup\; \text{Loc}$ for convenience. The semantics of SeqSL can be defined as follows:
\begin{align*}
& \sigma \;|=\; t_{x_1} = t_{x_2} &
\text{iff} &
\quad |[t_{x_1}|]\sigma = |[t_{x_2}|]\sigma. \\
& \sigma \;|=\; t_{\alpha_1} == t_{\alpha_2} &
\text{iff} &
\quad |[t_{\alpha_1}|]\sigma == |[t_{\alpha_2}|]\sigma. \\
& \sigma \;|=\; \lnot \varphi &
\text{iff} &
\quad \sigma \;\nvDash\; \varphi. \\
& \sigma \;|=\; \varphi_1 \land \varphi_2 &
\text{iff} &
\quad \sigma \;|=\; \varphi_1 \text {, and } \sigma \;|=\; \varphi_2. \\
& \sigma \;|=\; \varphi_1 \lor \varphi_2 &
\text{iff} &
\quad \sigma \;|=\; \varphi_1 \text {, or } \sigma \;|=\; \varphi_2. \\
& \sigma \;|=\; \varphi_1 => \varphi_2 &
\text{iff} &
\quad \text{if } \sigma \;|=\; \varphi_1 \text {, then } \sigma \;|=\; \varphi_2. \\
& \sigma \;|=\; \textbf{emp} &
\text{iff} &
\quad \mathtt{dom}(h) = \varnothing. \\
& \sigma \;|=\; t_x |-> t_\alpha &
\text{iff} &
\quad |[t_x|]\sigma \notin \mathrm{Atom}, \; \mathtt{dom}(h) = \{|[t_x|]\sigma\},\\
& & & \quad \text{ and } h(|[t_x|]\sigma) = |[t_{\alpha}|]\sigma \\
& \sigma \;|=\; \varphi_1 * \varphi_2 &
\text{iff} &
\quad \text{there exist heap } h_1 \text{ and } h_2, \\
& & & \quad \text{such that } \mathtt{dom}(h_1) \cap \mathtt{dom}(h_2) = \varnothing \;, \\
& & & \quad \text{and } h = h_1 \uplus h_2,\; (s_x,s_{\alpha},h_1) \;|=\; \varphi_1, \\
& & & \quad \text{and } (s_x,s_{\alpha},h_2) \;|=\; \varphi_2. \\
& \sigma \;|=\; \varphi_1 -* \varphi_2 &
\text{iff} &
\quad \text{for all heaps } h_1, \\
& & & \quad \text{if } \mathtt{dom}(h_1) \cap \mathtt{dom}(h) = \varnothing \text{ ,} \\
& & & \quad \text{and } (s_x,s_{\alpha},h_1) \;|=\; \varphi_1, \\
& & & \quad \text{then } (s_x,s_{\alpha},h_1 \uplus h) \;|=\; \varphi_2. \\
& \sigma \;|=\; \exists x.\varphi &
\text{iff} &
\quad \text{there exists } x_0 \text{ in Values,} \\
& & & \quad \text{such that } (s_x[x -> x_0], s_{\alpha}, h) \;|=\; \varphi. \\
& \sigma \;|=\; \exists \alpha.\varphi &
\text{iff} &
\quad \text{there exists } \alpha_0 \text{ in Values}^*, \\
& & & \quad \text{such that } (s_x, s_{\alpha}[\alpha -> \alpha_0], h) \;|=\; \varphi,
\end{align*}
where $s_x[x -> x_0]$ and $s_{\alpha}[\alpha -> \alpha_0]$ denote substitution of program variable and sequence variable respectively. They are defined as follows.
\begin{align*}
s_x[x -> x_0](x') = \begin{cases}
s_x(x_0), & x' = x \\
s_x(x), & \text{otherwise}
\end{cases}
\end{align*}
\begin{align*}
s_{\alpha}[\alpha -> \alpha_0](\alpha') = \begin{cases}
s_{\alpha}(\alpha_0), & \alpha' == \alpha \\
s_{\alpha}(\alpha), & \text{otherwise}
\end{cases}
\end{align*}
\end{definition}
For convenience, we write $\exists x.\varphi$ to denote $\exists x.\varphi$, and $\exists \alpha.\varphi$ to denote $\exists \alpha.\varphi$.
SeqSL can express properties which is widely used in logic reasoning on pointer programs. We list some of them. These notations will be used in this paper.
\begin{align*}
& \text{septraction} &&\quad \varphi_1 \mathrel{\sepimp \mkern-15mu^{\lnot}} \varphi_2 \overset{\triangle}{=} \lnot (\varphi_1 -* \lnot \varphi_2) \\
& \text{universal quantifier} &&\quad \forall \alpha.\varphi \overset{\triangle}{=} \lnot \exists \alpha.\; \lnot \varphi \\
& \alpha \text{ is stored in } x &&\quad x \hookrightarrow \alpha \overset{\triangle}{=} x |-> \alpha * \mathbf{true} \\
& x \text{ has been allocated } &&\quad \mathtt{alloc}(x) \overset{\triangle}{=} \exists \alpha.\; x \hookrightarrow \alpha \\
& \alpha_2 \text{ is stored in } \alpha_1(x_1) && \quad \alpha(x_1) \hookrightarrow \alpha_2 \\
&&& \hspace{-0.5em}\overset{\triangle}{=}\; \exists x.\; x = \alpha_1(x_1) \land x \hookrightarrow \alpha_2.
\end{align*}
\subsection{Expressiveness of sequence-heap separation logic}
In this subsection, we list few examples to show expressiveness of SeqSL. We divide examples into 2 categories: properties on variable-length sequence in programs, and properties on multilevel data structures.
Similar to the classical separation logic, sequence-heap separation logic does not make differences between locations and values in formulae. To adjust more scenarios in practice, we use the atom $\#$ to manually separate locations and values. The sequence singleton heap can thus be written as $x |-> \alpha_l \circ \# \circ \alpha_x$, where $\alpha_l$ denotes sequence of locations, and $\alpha_x$ denotes sequence of values.
\subsubsection{Properties on variable-length sequences in programs}
we list some properties on graphs to show the expressiveness of SeqSL on describing variable-length sequences in programs. These properties include: out-degree and reachability.
\noindent\textbf{Out-degree}. The out-degree of node $x$ can be denoted as $\mathtt{Outdeg}(x)$ . The formula $\mathtt{Outdeg}(x) = n$ means the out-degree of node $x$ is $n_x$. It is defined as follows:
\begin{equation}\label{eq:out_degree}
\begin{aligned}
&\mathtt{Outdeg}(x) = n_x \\
\overset{\triangle}{=} \quad& \exists \alpha_l \exists \alpha_x.\;x \hookrightarrow \alpha_l \circ \# \circ \alpha_x \land |\alpha_l| = n_x.
\end{aligned}
\end{equation}
Note that the reserved word $\textbf{nil}$ might be in $\alpha_l$. It does not affect the truth of the definition, because $\textbf{nil}$ can be viewed as location 0. Its out-degree is 0, and in-degree is not necessarily be 0.
\noindent\textbf{Reachability}. First, we define one-step reachability $x_1 \leadsto x_2$ , which means there exists an edge from $x_1$ to $x_2$.
\begin{equation*}
x_1 \leadsto x_2 \overset{\triangle}{=} \exists \alpha_{l_1} \exists \alpha_{l_2} \exists \alpha_x.\; l_1 \hookrightarrow \alpha_{l_1} \circ l_2 \circ \alpha_{l_2} \circ \# \circ \alpha_x.
\end{equation*}
Then we define $\mathtt{reach}^n(x_1,x_2)$, which means there exists a path from $x_1$ to $x_2$. The length of the path is $n$ ($n >= 0$).
\begin{align*}
\mathtt{reach}^0(x_1,x_2) &\quad\overset{\triangle}{=}\quad x_1 = x_2 \\
\mathtt{reach}^{n+1}(x_1,x_2) &\quad\overset{\triangle}{=}\quad \exists x_3.\; x_1 \leadsto x_3 * \mathtt{reach}^{n}(x_3,x_2)
\end{align*}
Finally we define $\mathtt{reach}(x_1,x_2)$, which means there exists a path from $x_1$ to $x_2$, whose length is larger or equal than 0.
\begin{align*}
\mathtt{reach}(x_1,x_2) \overset{\triangle}{=} \exists n.\; n >= 0 \land \mathtt{reach}^{n}(x_1,x_2).
\end{align*}
Note that $\mathtt{reach}(x_1,x_2)$ defined in SeqSL is different from $\mathtt{ls}(x_1,x_2)$ defined in the separation logic fragments on shape analysis. The former can describe reachability on graphs without restrictions on out-degree of each nodes, while the latter can only describe reachability on linked lists.
\subsubsection{Properties on multilevel data structures}
we list some properties on two kinds of storage systems to show expressiveness of SeqSL on describing multilevel data structures.
Different from SeqSL, the model $\sigma = (s_x,s_\alpha, h)$ of SeqSL describing storage systems should be interpreted in disk, not in memory.
\noindent\textbf{Properties on Windows storage systems}. The structure of Windows storage systems based on trees can be expressed by SeqSL. The indices $\alpha_l$ of files are stored in the location $l$. The file $\alpha_x$ is stored in the location $l_1$.
\begin{equation}\label{eq:multi_level}
\begin{aligned}
& l \hookrightarrow \alpha_l \circ \# \circ \varepsilon \;* \\
& \forall l_1 \exists \alpha_x.\; (l_1 \overline{\in} \alpha_l => l_1 \hookrightarrow \varepsilon \circ \# \circ \alpha_{x}).
\end{aligned}
\end{equation}
Note that the sub-formula $\forall l_1 \exists \alpha_x.\; (l_1 \overline{\in} \alpha_l => l_1 \hookrightarrow \varepsilon \circ \# \circ \alpha_x)$ can not be replaced by $\forall x.\; \alpha_l(x) \hookrightarrow \varepsilon \circ \# \circ \alpha_x$. The reason is that, $\alpha_l$ is a \textit{finite} sequence. When $x$ exceeds the length of $\alpha_l$, it falsifies $\forall x.\; \alpha_l(x) \hookrightarrow \varepsilon \circ \# \circ \alpha_x$. So we have to restrict $l_1$ with $l_1 \overline{\in} \alpha_l$.
We apply $\#$ in \Cref{eq:multi_level} to describe two-tier data structures. The first tier merely stores locations $\alpha_l$, while the second tier merely stores data $\alpha_x$. These two different forms of contents prevent the location $l_1$ in the second tier from pointing to the location $l$ in the first tier.
With \Cref{eq:multi_level} in hand, we can describe properties of files. We list two of them.
A file can be found by its index $x_1$:
\begin{align*}
\exists \alpha_x.\; \alpha_l(x_1) \hookrightarrow \varepsilon \circ \# \circ \alpha_x.
\end{align*}
The content $x_1$ can be found in the file $\alpha_x$:
\begin{align*}
\exists x_2.\; x_1 = \alpha_x(x_2).
\end{align*}
In addition, we can apply $x |-> \alpha_l \circ \#^n \circ \alpha_x$ to describe n-th tier of multilevel data structure. This is useful for describing multilevel pointers in C++, multilevel paging, multilevel addressing, etc.
\noindent\textbf{Properties on block-based cloud storage systems}. SeqSL can be used to describe blocks in cloud storage systems. Generally speaking, the sequence $\alpha$ in the formula $x \hookrightarrow \alpha$ can be viewed as a block. With a relative address $l$, the content $\alpha(l)$ can be found.
For convenience, we define the predicate $\mathtt{IncIndex}(\alpha_0, n)$, which means $\alpha_0$ with length $n+1$ is strictly increasing. The first item of $\alpha$ is 1, and the last is $n + 1$.
\vspace{-1em}
\begin{align*}
\mathtt{IncIndex}(\alpha_0, n) \;\overset{\triangle}{=} \; & \mathtt{Inc}(\alpha_0) \land |\alpha_0| = n + 1 \\
& \land 1 = \alpha_0(1) \land n + 1 = \alpha_0(n+1).
\end{align*}
A big file $\alpha$ stored in location $l$ is divided into $n$ smaller blocks and is stored in disk. The indices $\alpha_l$ of the file are stored in location $l$. The function $\mathtt{Trunc}(\alpha,x_1,x_2)$ can be used to locate these blocks. The sequence variable $\alpha_0$ in the following formula represents the sequence of division points, which should make the predicate $\mathtt{IncIndex}(\alpha_l,n)$ to be true. The length of each block $\alpha_x$ can be additionally fixed to 64 by tahe formula $|\alpha_x| = 64$.
\begin{align*}
& \exists \alpha_0.\; \Bigl( \mathtt{IncIndex}(\alpha_l,n) \land l \hookrightarrow \alpha_l \circ \# \circ \varepsilon \\
& * \bigl(\forall l_1 \exists x.\; (l_1 = \alpha_l(x) \land \alpha_x == \mathtt{Trunc}(\alpha, \alpha_0(x), \alpha_0(x+1))) \\
& => l_1 \hookrightarrow \varepsilon \circ \# \circ \alpha_x \Bigr).
\end{align*}
The formula defined above can be illustrated by Fig. (\ref{fig:bcss}).
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{img/Structure_of_BCSS.png}
\caption{Structure of block-based cloud storage system}
\label{fig:bcss}
\end{figure}
\section{Decidable fragments}
In this section, we consider a decidable $\Sigma_1$ fragment of SeqSL. It contains sequence singleton heap, separating conjunction, separating implication, equality and concatenation on sequences. We present the following main result of this section.
\begin{theorem}[Decidable fragment of SeqSL\label{decidable_fragment_of_SeqSL}]\label{theorem:decidable_fragment}
The satisfiability problem of the language is decidable when it is restricted as follows:
\begin{align*}
t_x \quad::=& \quad \mathbf{nil} \mid \# \mid x \\
t_{\alpha} \quad::=& \quad \varepsilon \mid t_x \mid \alpha \mid t_{\alpha} \circ t_{\alpha} \\
\varphi \quad::=& \quad t_x = t_x \mid t_\alpha == t_\alpha \mid \mathbf{false} \mid \varphi => \varphi \mid \mathbf{emp} \\
& \quad \mid x |-> t_{\alpha} \mid \varphi * \varphi \mid \varphi -* \varphi.
\end{align*}
The model of the fragment is the same as that of SeqSL, which is defined in \Cref{def:modelSeqSL}.
\end{theorem}
We call the above fragment the $\Sigma_1$ fragment of separation logic \;(PSeqSL, where the alphabet 'P' means propositional). PSeqSL is a non-trivial fragment for the following reasons:
\begin{itemize}
\item The expressiveness of PSeqSL is stronger than that of the $\Sigma_1$ fragment of the classical separation logic proposed in \cite{reynolds2002separation}, because the former can express properties on variable-length sequences and on multilevel data structures.
\item The heap stores variable-length sequences in PSeqSL. The models of a formula in PSeqSL may have more possibilities than that of a formula in the classical separation logic.
\item Sequences and heap operations in the fragment are not independent. Their satisfiability may affect each other. For instance, to decide whether the formula $x_1 |-> \alpha_1 \land x_1 |-> \alpha_2$ is true, we need to consider both conditions on heap, and the implicit condition $\alpha_1 == \alpha_2$ on sequences. To decide whether the formula $(x_1 |-> \alpha_1 * x_2 |-> \alpha_2) \land (x_1 |-> \alpha_3 * x_2 |-> \alpha_4) \land x_1 != x_2$ is true, we need to consider the implicit condition $\alpha_1 == \alpha_3 \land \alpha_2 == \alpha_4$.
\item PSeqSL can describe some of the formulae consisting of existential quantifiers in SeqSL. The property $\mathtt{alloc}(x) \overset{\triangle}{=} \exists \alpha.\; x \hookrightarrow \alpha$ in SeqSL can be expressed in PSeqSL as:
\begin{align*}
\mathtt{alloc}(x) \overset{\triangle}{=} (x |-> \mathbf{nil}) -* \mathbf{false}.
\end{align*}
\end{itemize}
We prove \Cref{decidable_fragment_of_SeqSL} following these three steps:
\begin{enumerate}
\item prove the following problem is decidable: given the formula $\varphi$ in PSeqSL, and a part of the model $s_x, h$, decide whether there exists $s_{\alpha}$, such that $(s_x,s_{\alpha},h) |= \varphi$.
\item prove the following problem is decidable: given the formula $\varphi$ in PSeqSL, and a part of the model $s_x$, decide whether there exists $s_{\alpha},h$, such that $(s_x,s_{\alpha},h) |= \varphi$.
\item prove the following problem is decidable: given the formula $\varphi$ in PSeqSL, decide whether there exists $s_x, s_{\alpha}, h$, such that $(s_x,s_{\alpha},h) |= \varphi$. (\Cref{decidable_fragment_of_SeqSL})
\end{enumerate}
The first step is the main part of the proof. The result on the fragment without separating implications is trivial, because the finiteness of $h$ leads to finite possibilities of models satisfying the formula $\varphi$.
Similar to the paper \cite{calcagno2001computability}, we define the size of the formula $\varphi$ as $\mathtt{sz}(\varphi)$ to represent the maximum heap size for deciding whether the formula $\varphi$ is true or its negation is true.
\begin{definition}[Size of formula]
The size of the formula $\varphi$, $\mathtt{sz}(\varphi)$ can be inductively defined as follows:
\begin{table}[htbp]
\centering
\label{table1}
\tabcolsep=0.5cm
\renewcommand\arraystretch{1.2}
\normalsize
\begin{tabular}{ll}
$\mathtt{sz}(t_{x_1} = t_{x_2}) = 0$ &
$\mathtt{sz}(t_{\alpha_1} == t_{\alpha_2}) = 0$ \\
$\mathtt{sz}(\mathbf{false}) = 0$ &
$\mathtt{sz}(\mathbf{emp}) = 1$ \\
$\mathtt{sz}(x |-> t_\alpha) = 1$ &
$\mathtt{sz}(\varphi_1 -* \varphi_2) = \mathtt{sz}(\varphi_2)$ \\
\multicolumn{2}{l}{$\mathtt{sz}(\varphi_1 => \varphi_2) = \mathtt{max}(\mathtt{sz}(\varphi_1), \mathtt{sz}(\varphi_2))$} \\
\multicolumn{2}{l}{$\mathtt{sz}(\varphi_1 * \varphi_2) = \mathtt{sz}(\varphi_1) + \mathtt{sz}(\varphi_2)$.}
\end{tabular}
\end{table}
\end{definition}
We define free program variables as follows.
\begin{definition}[Free program variables in PSeqSL]
In PSeqSL, free program variables $\mathrm{FV}_{t,x}(t_x)$ in the term $t_x$ and free program variables $\mathrm{FV}_{t,x}(t_\alpha)$ in the term $t_\alpha$ can be inductively defined as follows:
\begin{table}[htbp]
\centering
\label{table1}
\tabcolsep=0.5cm
\renewcommand\arraystretch{1.2}
\small
\begin{tabular}{lll}
$\mathrm{FV}_{t,x}(\mathbf{nil}) = \{\}$ &
$\mathrm{FV}_{t,x}(\#) = \{\}$ &
$\mathrm{FV}_{t,x}(x) = \{x\}$ \\
$\mathrm{FV}_{t,x}(\alpha) = \{\}$ &
$\mathrm{FV}_{t,x}(\varepsilon) = \{\}$ &
\\
\multicolumn{3}{l}{$\mathrm{FV}_{t,x}(t_{\alpha_{x_1}} \circ t_{\alpha_{x_2}}) = \mathrm{FV}_{t,x}(t_{\alpha_{x_1}}) \cup \mathrm{FV}_{t,x}(t_{\alpha_{x_2}})$.}
\end{tabular}
\vspace{-0.5em}
\end{table}
Free program variables $\mathrm{FV}_x(\varphi)$ in the formula $\varphi$ can be inductively defined as follows:
\begin{align*}
\FV_{x}&(t_{x_1} = t_{x_2}) = \mathrm{FV}_{t,x}(t_{x_1}) \cup \mathrm{FV}_{t,x}(t_{x_2}) \\
\FV_{x}&(t_{\alpha_1} == t_{\alpha_2}) = \mathrm{FV}_{t,x}(t_{\alpha_1}) \cup \mathrm{FV}_{t,x}(t_{\alpha_2}) \\
\FV_{x}&(\mathbf{false}) = \{\} \\
\FV_{x}&(\varphi_1 => \varphi_2) = \FV_{x}(\varphi_1) \cup \FV_{x}(\varphi_2) \\
\FV_{x}&(\mathbf{emp}) = \{\} \\
\FV_{x}&(x |-> t_\alpha) = \{x\} \cup \mathrm{FV}_{t,x}(t_\alpha) \\
\FV_{x}&(\varphi_1 * \varphi_2) = \FV_{x}(\varphi_1) \cup \FV_{x}(\varphi_2) \\
\FV_{x}&(\varphi_1 -* \varphi_2) = \FV_{x}(\varphi_1) \cup \FV_{x}(\varphi_2).
\end{align*}
\end{definition}
We define the set of sequence terms to collect the terms appearing in the formula. It helps us to get a finite set of all possible heap models which may satisfy the formula.
\begin{definition}[Set of sequence terms]
The set of sequence terms $\mathtt{SeqTerms}(\varphi)$ appearing in the formula $\varphi$ can be inductively defined as:
\begin{align*}
\mathtt{SeqTerms}&(t_{l_1} = t_{l_2}) = \{t_{l_1}, t_{l_2}\} \\
\mathtt{SeqTerms}&(t_{\alpha_1} == t_{\alpha_2}) = \{t_{\alpha_1}, t_{\alpha_2}\} \\
\mathtt{SeqTerms}&(\mathbf{false}) = \{\} \\
\mathtt{SeqTerms}&(\mathbf{emp}) = \{\} \\
\mathtt{SeqTerms}&(x |-> t_\alpha) = \{x, t_\alpha\} && \\
\mathtt{SeqTerms}&(\varphi_1 => \varphi_2) = \mathtt{SeqTerms}(\varphi_1) \cup \mathtt{SeqTerms}(\varphi_2) && \\
\mathtt{SeqTerms}&(\varphi_1 * \varphi_2) = \mathtt{SeqTerms}(\varphi_1) \cup \mathtt{SeqTerms}(\varphi_2) \\ \mathtt{SeqTerms}&(\varphi_1 -* \varphi_2) = \mathtt{SeqTerms}(\varphi_1) \cup \mathtt{SeqTerms}(\varphi_2).
\end{align*}
\end{definition}
Separating implication involves universal quantifiers over heaps. The paper \cite{calcagno2001computability} presents a solution on searching all possible models of the formula in the classical $\Sigma_1$ separation logic fragment. They restrict the domain and the range of the heap $h$ to finite sets. To deal with sequences, we come up with a different restriction on the range of $h$. The range of $h$ involves the set of all sequence terms appearing in the formula, empty sequence $\varepsilon$, and a fresh sequence term whose value is different from all sequence terms in the formula. Thus, universal quantifiers over heaps can be reduced to those over finite heaps. The reduction preserves satisfiability.
We present the following lemma to show small model property on the formula $\varphi_1 -* \varphi_2$.
\begin{lemma}\label{small_model_property_of_si}
Given the model $\sigma = (s_x,s_{\alpha},h)$ and formulae $\varphi, \; \varphi_1 \text{ and } \varphi_2$ satisfying $\varphi = \varphi_1 -* \varphi_2$, the set $L = \FV_{x}(\varphi_1) \cup \FV_{x}(\varphi_2)$, the set $B$ which contains the first $\mathtt{max}(\mathtt{sz}(\varphi_1), \mathtt{sz}(\varphi_2))$ values in $\mathrm{Loc} \setminus (\mathtt{dom}(h) \cup s(L))$, the fresh sequence variable $\overline{\beta}$ satisfying $|[\overline{\beta}|]\sigma' \notin \{|[t_\alpha|]\sigma' \mid t_\alpha \in \mathtt{SeqTerms}(\alpha)\}$. We define $\sigma' = (s_x,s_{\alpha}',h)$ where $s_{\alpha}'$ contains a new assignment for $\overline{\beta}$. Let $\mathcal{D} = B \cup s(L)$, and $\mathcal{R} = \{|[t_\alpha|]\sigma' \mid t_\alpha \in \mathtt{SeqTerms}(\varphi)\} \cup \{\varepsilon, |[\overline{\beta}|]\sigma'\}$. Then, $(s_x,s_{\alpha},h) |= \varphi_1 -* \varphi_2$ holds, if and only if for all $h'$ satisfying:
\begin{itemize}
\item $\mathtt{dom}(h') \cap \mathtt{dom}(h) = \varnothing$ and $(s_x,s_{\alpha}',h') |= \varphi_1$,
\item $\mathtt{dom}(h') \subseteq \mathcal{D}$,
\item $\mathtt{rng}(h') \subseteq \mathcal{R}$,
\end{itemize}
the proposition $(s_x,s_{\alpha}',h \uplus h') |= \varphi_2$ holds, where $\mathtt{rng}(h')$ denotes the range of $h'$.
\end{lemma}
According to \Cref{small_model_property_of_si}, we define the reduction function as follows.
\begin{definition}\label{reduction_function}
The reduction function $T(s_x,h,\varphi)$ is a mapping from stack $s_x$, heap $h$, and the PSeqSL formula $\varphi$, to the formula in $\Sigma_1$ sequence predicate logic. The reduction can be inductively defined in Fig. (\ref{figeq:redfunc}),
\stripsep+2pt
\begin{figure*}[h]
\begin{align*}
T(s_x,h,t_{x_1} = t_{x_2}) &\quad\overset{\triangle}{=}\quad t_{x_1} == t_{x_2} \\
T(s_x,h,t_{\alpha_1} == t_{\alpha_2}) &\quad\overset{\triangle}{=}\quad t_{\alpha_1} == t_{\alpha_2} \\
T(s_x,h,\mathbf{false}) &\quad\overset{\triangle}{=}\quad \mathbf{false} \\
T(s_x,h,\varphi_1 => \varphi_2) &\quad\overset{\triangle}{=}\quad T(s_x,h,\varphi_1) => T(s_x,h,\varphi_2) \\
T(s_x,h,\mathbf{emp}) &\quad\overset{\triangle}{=}\quad \mathtt{dom}(h) = \varnothing \\
T(s_x,h,x|->t_\alpha) &\quad\overset{\triangle}{=}\quad \mathtt{dom}(h)=\{s_x(x)\} \land s_x(x) \notin \mathrm{Atom} \land h(s_x(x)) == t_\alpha \\
T(s_x,h,\varphi_1 * \varphi_2) &\quad\overset{\triangle}{=}\quad \bigvee_{h = h_1 \uplus h_2} (T(s_x,h_1,\varphi_1) \land T(s_x,h_2,\varphi_2)) \\
T(s_x,h,\varphi_1 -* \varphi_2) &\quad\overset{\triangle}{=}\quad \bigwedge_{
\mbox{ \tiny
$\begin{array}{c}
\mathtt{dom}(h_\varphi) \cap \mathtt{dom}(h) = \varnothing\\
\mathtt{dom}(h_\varphi) \subseteq \mathcal{D} \\
\mathtt{rng}(h_\varphi) \subseteq \mathcal{R}
\end{array}
$
}
} (T(s_x,h_\varphi,\varphi_1) => T(s_x,h_\varphi \uplus h,\varphi_2)),
\end{align*}
\captionof{figure}{The reduction function $T(s_x,h,\varphi)$}
\label{figeq:redfunc}
\end{figure*}
where $\varphi = \varphi_1 -* \varphi_2$.
\end{definition}
Given $s_x$ and $h$, the formula $T(s_x,h,\varphi_1 * \varphi_2)$ consists of finitely many terms of the form $T(s_x,h,\varphi)$, because the implicit existential quantifier in separating conjunction does not create new heaps. The formula $T(s_x,h,\varphi_1 -* \varphi_2)$ also consists of finitely many terms of the form $T(s_x,h,\varphi)$ according to \Cref{small_model_property_of_si}. Moreover, the truth values of the following three formulae $\mathtt{dom}(h) = \varnothing$, $\mathtt{dom}(h) = {s_x(x)}$, and $s_x(x) \notin \mathrm{Atom}$ can be determined, as well as the value of $h(s_x(x))$ (which is a sequence). So $T(s_x,h,\varphi)$ consists of only $t_{\alpha_1} == t_{\alpha_2}$ and its conjunctions, disjunctions and negations. It can be further reduced to a single word equation followed by \Cref{thm:Boolean comb}. PSeqSL is thus reduced to the satisfiability problem of $\Sigma_1$ sequence predicate logic. The $\Sigma_1$ fragment of sequence predicate logic is shown to be decidable in \cite{makanin1977problem}.
\begin{lemma}\label{lemma:part1}
Given stack $s_x$ and heap $h$. For all assignment $s_{\alpha}$ and formula $\varphi$, the proposition $(s_x,s_{\alpha},h) |= \varphi$ holds if and only if there exist assignments $(s_x', s_{\alpha}')$, such that $(s_x', s_{\alpha}') |= T(s_x,h,\varphi)$ holds, where $s_x'$ and $s_{\alpha}'$ are assignments of program variables and sequence variables respectively, $T(s_x,h,\varphi)$ is the reduction from PSeqSL to $\Sigma_1$ sequence predicate logic defined by \Cref{reduction_function}.
\end{lemma}
Note that after doing reductions in \Cref{reduction_function} and applying \Cref{thm:Boolean comb}, one can get a single word equation $U == V$ with constants ($k$ contents for example) and sequence variables ($k'$ variables for example). It is easy to show the following fact: there is a solution for $U == V$ if and only if there is a solution for $U == V$ on the free monoid with $k+k'$ generators, where the first $k$ generators coincide with $k$ constants, and the other $k'$ generators are fresh in $\mathbb{N}$.
To give readers some intuitions for \Cref{lemma:part1}, we list two examples below.
\begin{example}
Consider whether the formula $\varphi = (x_1 |-> \alpha_1 \circ x_3) * \big(
(x_1 |-> \alpha_1 \lor x_1 |-> \alpha_2) -*
(x_1 |-> \alpha_2 * x_2 |-> \alpha_3)
\big)$ can be satisfied, given the stack satisfying $\{(x_1,n_1),(x_2,n_2),(x_3,n_3)\} \subseteq s$ where $n_1,n_2$ and $n_3$ are distinct integer numbers and the heap $h = \{(n_1,n_1 \circ n_3), (n_2,n_2 \circ n_3)\}$. The assignment $s_{\alpha}$ is pending.
Suppose $\varphi = \varphi_1 * \varphi_2$, where $\varphi_1 = x_1 |-> \alpha_1 \circ x_3$, $\varphi_2 =
(x_1 |-> \alpha_1 \lor x_1 |-> \alpha_2) -*
(x_1 |-> \alpha_2 * x_2 |-> \alpha_3)$. We have the formula in Fig. (\ref{figeq:cons_ex1}).
\stripsep+0.5em
\begin{figure*}[h]
\begin{align*}
T(s_x,h,\varphi) \quad=\quad& \bigvee_{h = h_1 \uplus h_2}(T(s_x,h_1,\varphi_1) \land T(s_x,h_2,\varphi_2)) \\
\quad=\quad& \; \big( T(s_x,\{\},\varphi_1) \land T(s_x,\{(n_1,n_1 \circ n_3), (n_2,n_2 \circ n_3)\},\varphi_2) \big) \\
& \lor \big( T(s_x,\{(n_1,n_1 \circ n_3)\},\varphi_1) \land T(s_x,\{(n_2,n_2 \circ n_3)\},\varphi_2) \big) \\
& \lor \big( T(s_x,\{(n_2,n_2 \circ n_3)\},\varphi_1) \land T(s_x,\{(n_1,n_1 \circ n_3)\},\varphi_2) \big) \\
& \lor \big( T(s_x,\{(n_1,n_1 \circ n_3),(n_2,n_2 \circ n_3)\},\varphi_1) \land T(s_x,\{\},\varphi_2) \big) \\
\quad=\quad& \; T(s_x,\{(n_1,n_1 \circ n_3)\},\varphi_1) \land T(s_x,\{(n_2,n_2 \circ n_3)\},\varphi_2).
\end{align*}
\caption{Construction in Example 1}
\label{figeq:cons_ex1}
\end{figure*}
Suppose $\varphi_2 = \varphi_{21} -* \varphi_{22}$, where $\varphi_{21} = x_1 |-> \alpha_1 \lor x_1 |-> \alpha_2$, and $\varphi_{22} = x_1 |-> \alpha_2 * x_2 |-> \alpha_3$. We have:
\vspace{-1em}
\begin{equation*}
\begin{aligned}
& T(s_x,\{(n_2,n_2 \circ n_3)\},\varphi_2) \\
=\quad &\bigwedge_{
\mbox{ \tiny
$\begin{array}{c}
\mathtt{dom}(h_{\varphi_2}) \cap \{n_2\} = \varnothing\\
\mathtt{dom}(h_{\varphi_2}) \subseteq \mathcal{D} \\
\mathtt{rng}(h_{\varphi_2}) \subseteq \mathcal{R}
\end{array}
$
}
} \bigl(T(s_x,h_{\varphi_2},\varphi_{21}) \\
& => T(s_x,h_{\varphi_2} \uplus \{(n_2,n_2 \circ n_3)\},\varphi_{22})\bigr),
\end{aligned}
\vspace{-1em}
\end{equation*}
where
\vspace{-0.5em}
\begin{equation*}
\begin{aligned}
\mathcal{D} &= B \;\cup\; \{n_1,n_2,n_3\}, \quad B = \{m_1,m_2,m_3\}, \\
\mathcal{R} &= \{|[\alpha_1 \circ x_3|]\sigma', |[\alpha_1|]\sigma',|[\alpha_2|]\sigma', |[\alpha_3|]\sigma'\} \cup \{\varepsilon, |[\overline{\beta}|]\sigma'\},
\end{aligned}
\vspace{-1em}
\end{equation*}
and $m_1,m_2,m_3$ are the first three values in $\mathrm{Loc} \setminus (\mathtt{dom}(h) \cup s(L))$, the term $\overline{\beta}$ satisfies:
\begin{equation*}
\begin{aligned}
|[\overline{\beta}|]\sigma' \notin \{|[\alpha_1 \circ x_3|]\sigma', |[\alpha_1|]\sigma',|[\alpha_2|]\sigma', |[\alpha_3|]\sigma'\}.
\end{aligned}
\end{equation*}
The domain $\mathtt{dom}(h_{\varphi_2})$ consists of many finite possibilities. However, there are only two possibilities $h_{\varphi_2} = \{(n_1,s_{\alpha}'(\alpha_1))\}$ and $h_{\varphi_2} = \{(n_1,s_{\alpha}'(\alpha_2))\}$ which may satisfy the formula. So,
\begin{equation*}
\begin{aligned}
& T(s_x,\{(n_2,n_2 \circ n_3)\},\varphi_2) \\
=\quad& \; (T(s_x,\{(n_1,s_{\alpha}'(\alpha_1)\},\varphi_{21}) \\
& => T(s_x,\{(n_1,s_{\alpha}'(\alpha_1)), (n_2,n_2 \circ n_3)\},\varphi_{22})) \\
& \land (T(s_x,\{(n_1,n_2 \circ n_3)\},\varphi_{21}) \\
& => T(s_x,\{(n_1,n_2 \circ n_3), (n_2,n_2 \circ n_3)\},\varphi_{22})) \\
=\quad& \; T(s_x,\{(n_1,s_{\alpha}'(\alpha_1)), (n_2,n_2 \circ n_3)\},\varphi_{22}) \\
& \land T(s_x,\{(n_1,n_2 \circ n_3), (n_2,n_2 \circ n_3)\},\varphi_{22}).
\end{aligned}
\end{equation*}
Similarly, we discuss possibilities of models satisfying the formula $\varphi_{22}$. Then we have:
\begin{align*}
&T(s_x,\{(n_1,s_{\alpha}'(\alpha_1)), (n_2,n_2 \circ n_3)\},\varphi_{22}) \\
=\quad& \alpha_1 == \alpha_2 \land n_2 \circ n_3 == \alpha_3,\\
&T(s_x,\{(n_1,n_2 \circ n_3), (n_2,n_2 \circ n_3)\},\varphi_{22}) \\
= \quad& \alpha_2 == \alpha_2 \land n_2 \circ n_3 == \alpha_3.
\end{align*}
So,
\begin{align*}
&T(s_x,h,\varphi) \\
=\quad& (n_1 \circ n_3 == \alpha_1 \circ n_3) \land (\alpha_1 == \alpha_2 \land n_2 \circ n_3 == \alpha_3) \\
& \land (\alpha_2 == \alpha_2 \land n_2 \circ n_3 == \alpha_3).
\end{align*}
We observe that $T(s_x,h,\varphi)$ can be satisfied. Hence given $s_x,h$, there exists $s_{\alpha}$ such that $(s_x,s_{\alpha},h) |= \varphi$ holds.
\end{example}
\begin{example}
Consider whether the formula $\varphi = x_1 |-> \alpha_1 \circ x_3 \land \big(
(x_2 |-> \alpha_1 \lor x_2 |-> \alpha_2) -*
(x_1 |-> \alpha_1 * x_2 |-> \alpha_3)
\big)$ can be satisfied, given $s = \{(x_1,n_1), (x_2,n_2), (x_3,n_3)\}, h = \{(x_1,n_1 \circ n_3)\}$.
Following definition Definition 4.4, we have:
\begin{align*}
&T(s_x,h,\varphi) \\
=\quad& n_1 \circ n_3 == \alpha_1 \circ n_3 \land \big(
(\alpha_1 == \alpha_3 \land \alpha_1 == n_1 \circ n_3) \\
& \land (\alpha_2 == \alpha_3 \land \alpha_1 == n_1 \circ n_3)
\big).
\end{align*}
We observe that $T(s_x,h,\varphi)$ cannot be satisified. Hence given $s_x,h$, there does not exist $s_{\alpha}$ such that $(s_x,s_{\alpha},h) |= \varphi$ holds. We omit the details here.
\end{example}
For the second step of the proof, heap $h$ is not given beforehand. The satisfiability problem of the formula in PSeqSL can be reduced to the problem in the first step by the following lemma.
\begin{lemma}\label{cor:sat}
Given stack $s_x$ and the PSeqSL formula $\varphi$, the following problem is decidable: whether there exists $s_{\alpha}$ and $h$ such that $(s_x,s_{\alpha},h) |= \varphi$.
\end{lemma}
The above problem is equivalent to the following problem: given $s_x$, whether there exists $s_{\alpha}$ such that $(s_x,s_{\alpha},\{\}) |= \varphi \mathrel{\sepimp \mkern-15mu^{\lnot}} \mathbf{true}$ holds. Thus we can conclude \Cref{cor:sat}.
For the third step, stack $s_x$ is not given. Similar to the paper\cite{calcagno2001computability}, we need to figure out a finite range of $s_x$, such that the formula is true on the range if and only if the formula is true on infinite range of $s_x$.
\begin{definition}
Given two models $(s_x,s_{\alpha},h), (s_x',s_{\alpha}',h')$, the set $P \subseteq \mathrm{PVar}$, and the set $S \subseteq \mathrm{SVar}$. The relation $(s_x,s_{\alpha},h) \approx_P (s_x',s_{\alpha}',h')$ holds, if and only if there exists an isomorphism $r:\; (\mathrm{Loc}^*, \circ) -> (\mathrm{Loc}^*, \circ)$, such that the following conditions are satisfied:
\begin{itemize}
\item for each $\alpha_1,\alpha_2 \in S$, we have $r(s_{\alpha}(\alpha_1) \circ s_{\alpha}(\alpha_2)) = r(s_{\alpha}(\alpha_1)) \circ r(s_{\alpha}(\alpha_2))$,
\item $r(\mathbf{nil}) = \mathbf{nil}$, $r(\#) = \#$, and for each $x \in P$, we have $r(s_x(x)) = s_x'(x)$,
\item for each $x \in P$, we have $r(h(x)) = h'(r(x))$,
\item for each $\alpha \in S $, we have $r(s_{\alpha}(\alpha)) = s_{\alpha}'(\alpha)$.
\end{itemize}
\end{definition}
\begin{proposition}
Given two models $(s_x,s_{\alpha},h), (s_x',s_{\alpha}',h')$, and the formula $\varphi$ satisfying $(s_x,s_{\alpha},h) \approx_{\FV_{x}(\varphi)} (s_x',s_{\alpha}',h')$. If $(s_x,s_{\alpha},h) |= \varphi$, then $(s_x',s_{\alpha}',h') |= \varphi$.
\end{proposition}
\begin{lemma}\label{lemma:part3}
Given the model $(s_x,s_{\alpha},h)$ and the formula $\varphi$. Let $B$ be the first $|\FV_{x}(\varphi)|$ locations in $\mathrm{Loc}$. There exists $(s_x',s_{\alpha}',h')$ such that $s_x'(\mathrm{PVar} \setminus \FV_{x}(\varphi)) \subseteq \{\mathbf{nil},\#\}, s_x'(\FV_{x}(\varphi)) \subseteq B \cup \{\mathbf{nil},\#\}$, and $(s_x,s_{\alpha},h) \approx_{\FV_{x}(\varphi)} (s_x',s_{\alpha}',h')$.
\end{lemma}
With \Cref{lemma:part1,cor:sat,lemma:part3}, we can conclude that the satisfiability problem of PSeqSL is decidable, that is \Cref{theorem:decidable_fragment} holds.
As we know, the truth of $\Sigma_1$ fragment of sequence predicate logic is decidable\cite{makanin1977problem}. As the fragment consists of negations without any restrictions, there is a one-to-one mapping from instances in $\Sigma_1$ fragment of sequence predicate logic and those in $\Pi_1$ fragment of sequence predicate logic. Thus we have \Cref{cor:seq}.
\begin{corollary}\label{cor:seq}
The theory of $\Pi_1$ fragment of sequence predicate logic is decidable.
\end{corollary}
The proof of \Cref{theorem:decidable_fragment} shows that PSeqSL has small model property. The satisfiability of a formula in PseqSL can be reduced to that of the formula with finite length in $\Sigma_1$ fragment sequence logic. According to small model property of PSeqSL and \Cref{cor:seq}, we have \Cref{cor:p1_frag}.
\begin{corollary}\label{cor:p1_frag}
The satisfiability and validity problem of $\Pi_1$ fragment of PSeqSL is decidable, where $\Pi_1$ fragment of PSeqSL is of the form $\forall^*\forall^*.\varphi$, and $\varphi$ is quantifier-free.
\end{corollary}
\section{Undecidable fragments}
In this section, we mainly focus on an undecidable fragment of the form
$(\forall^*\forall^*\cap \forall^*\exists^*\exists^*)\text{SeqSL}(*)$. It is the conjunction of formula in $(\forall^* \forall^*)\text{SeqSL}(*)$ and formula $(\forall^*\exists^*\exists^*)\text{SeqSL}(*)$, where $\exists^*$ denotes there are 0 or more existential quantifiers over sequence variables, and $\exists^*$ denotes there are 0 or more existential quantifiers over program variables. The meaning of $\forall_\alpha^*$ and $\forall_\alpha^*$ are similar. We present the following main result of this section.
\begin{theorem}[Undecidable fragment of SeqSL]\label{thm:und}
The satisfiability problem of the language is undecidable when it is restricted as follows:
\begin{align*}
t_x \quad::=\quad& \mathbf{nil} \mid \# \mid x \\
t_\alpha \quad::=\quad& \varepsilon \mid t_x \mid \alpha \mid t_\alpha \circ t_\alpha \\
\psi \quad::=\quad& t_x = t_x \mid t_\alpha == t_\alpha \mid x \hookrightarrow t_\alpha \mid \mathbf{false} \mid \psi => \psi \\
& \mid \mathbf{emp} \mid \psi * \psi \\
\varphi \quad::=\quad& \forall^* \forall^*. \psi \land \forall^*\exists^*\exists^*. \psi,
\end{align*}
where $\varphi$ is a sentence.
The model of the fragment is defined in \Cref{def:modelSeqSL}.
\end{theorem}
We reduce the problem from halting problem of two-counter Minsky machine. Before getting into details of the reduction, we recall the definition of two-counter Minsky machine.
\begin{definition}[Two-counter Minsky machine]\label{def_Minsky}
Let $M$ be a Minsky machine with $n >= 1$ instructions. The machine $M$ has two counters $C_1$ and $C_2$. The instructions are defined as follows:
\begin{enumerate}[]
\item $I:\; C_j := C_j + 1;$ goto $k$,
\item $I:$ if $C_j = 0$, then goto $k_1$, else ($C_j := C_j - 1$; goto $k_2$),
\item $n:$ halt,
\end{enumerate}
where $j \in [1,2],\; I \in [1, n-1],$ and $k,k_1,k_2 \in [1, n]$. Machine $M$ halts if there is a run of the form
\begin{align*}
(I_0, c_0^1, c_0^2),\; (I_1, c_1^1, c_1^2),\dots, (I_m, c_m^1, c_m^2),
\end{align*}
such that $(I_i, c_i^1, c_i^2) \in [1,n] \times \mathbb{N}^2\; (i \in [1,m])$, $I_0 = 1,\; I_m = n$, and $c_0^1 = c_0^2 = 0$. The run follows the instructions defined above.
The set of instructions with type 1 (denoted by $\mathcal{I}_1$) consists of tuples $(k_0,c_j,c_j',k)$, and those with type 2 (denoted by $\mathcal{I}_2$) consists of tuples $(k_0,c_j,c_j',k_1,k_2)$, where $k_0$ denotes the current pointer, $c_j,c_j' \in [1,2]$ denote two counters ($c_j != c_j'$), and $k,k_1,k_2$ denote the next pointers.
\end{definition}
The problem of deciding whether a machine $M$ halts is known to be undecidable\cite{minsky1968computation}.
We first show the undecidable fragment defined in \Cref{thm:und} is not that easy to get. In general, decidability results of both sequence logic fragments and separation logic fragments restrict the form of undecidable fragments of SeqSL.
Decidability results in free semigroup show that, the theory of $\Sigma_2$ fragment\cite{day2018satisfiability}, the positive theory of $\Pi_2$ fragment\cite{durnev1995undecidability} and $\Sigma_3$ fragment\cite{durnev1995undecidability} of word equations are undecidable. The results in separation logic show that, the satisfiability problem of $\Sigma_3$ fragment of separation logic is undecidable. In this case, We can get \Cref{fact:trival_und_fragments}.
\begin{fact}\label{fact:trival_und_fragments}
In the fragment of SeqSL with prenex normal form, if there are 3 or more alternations of quantifiers over program variables, or 2 or more over sequence variables, then the satisfiability problems of resulting fragments are undecidable. For instance, the satisfiability problems of $(\exists^*\exists^*\forall^*)\mathrm{SeqSL}$, $(\exists^*\forall^*\exists^*)\mathrm{SeqSL}$, $(\exists^*\forall^*\forall^*\exists^*)\mathrm{SeqSL}$ are undecidable.
\end{fact}
In order to get a non-trivial undecidable fragment of SeqSL with negations, we have to restrict the alternations of quantifiers over program variables to be less than 3, and those over sequence variables to be less than 2.
To prove \Cref{thm:und}, we first discuss the encoding of the reduction. The general structure is sapling, which is shown in Fig. (\ref{fig:sapling}).
\begin{figure}[h]
\centering
\includegraphics[width=0.45\textwidth]{img/Structure_of_sapling.png}
\captionof{figure}{Structure of sapling}
\label{fig:sapling}
\end{figure}
We consider the encoding for sapling. Sapling is a fishbone-like structure with 'bones' going in opposite directions. Sapling consists of a master branch and several slave branches attached to nodes in the master branch. The depth of each slave branch is 1, and the end points of them does not point to any nodes in master branch. Similar to the encoding for the list $x \overset{\circlearrowleft}{\longrightarrow}^+ y$ defined in \cite{brochenin2012almighty} and fishbone heap defined in \cite{demri2015two}, we encode the sapling in the following ways:
\begin{enumerate}
\item There are smaller or equal than 1 predecessor of each node. It is denoted by the formula $\varPsi_1$,
\item There is no predecessor on the first master node. It is denoted by the formula $\varPsi_2$,
\item The first master node is allocated, and the last node does not point to the next master node. It is denoted by the formula $\varPsi_3$ (it is not necessary to make the predecessor of the last node to be 1),
\item For each node except for the last node, there is another allocated node which follows the node. It is denoted by the formula $\varPsi_4$.
\end{enumerate}
The sapling from node $x_0$ to node $x_0'$ (assume here that $x_0 != x_0'$) can be expressed by
\begin{align}\label{eq:sap}
\mathtt{sapling}(x_0,x_0') &\overset{\triangle}{=} \varPsi_1 \land \varPsi_2 \land \varPsi_3 \land \varPsi_4.
\end{align}
where $\varPsi_1, \varPsi_2, \varPsi_3$, and $\varPsi_4$ are defined in Fig. (\ref{figeq:cons_ex1}).
\stripsep+0.5em
\begin{figure*}[h]
\begin{equation*}
\begin{aligned}
\varPsi_1 &\quad\overset{\triangle}{=}\quad \forall x_1\forall x_2\forall x_3\forall x_4 \forall \alpha_1\forall \alpha_2.\; (x_1 \hookrightarrow x_3 \circ \alpha_1 * x_2 \hookrightarrow x_4 \circ \alpha_2 => x_3 != x_4) \\
\varPsi_2 &\quad\overset{\triangle}{=}\quad \forall x_1\forall \alpha.\; \lnot (x_1 \hookrightarrow x_0 \circ \alpha) \\
\varPsi_3 &\quad\overset{\triangle}{=}\quad (\exists x_1.\; x_0 \hookrightarrow x_1 \circ \varepsilon) \land (\exists \alpha.\; x_0' \hookrightarrow \varepsilon \circ \alpha) \\
\varPsi_4 &\quad\overset{\triangle}{=}\quad \forall x_1\forall x_2\exists x_3\exists \alpha_1\exists \alpha_2.\; \bigl((x_1 \hookrightarrow x_2 \circ \alpha_1 \land x_2 != x_0') => x_2 \hookrightarrow x_3 \circ \alpha_2\bigr).
\end{aligned}
\end{equation*}
\caption{Definition of $\varPsi_1, \varPsi_2, \varPsi_3$, and $\varPsi_4$}
\label{key}
\end{figure*}
It can be easily shown that the predicate $\mathtt{sapling}(x_0,x_0')$ is of the form $(\forall^* \forall^* \cap \forall^* \exists^* \exists^*)\varPsi$.
Note that the encoding in \Cref{eq:sap} is just a general idea. It does not prevent contents in slave nodes from pointing to other nodes. However, this does not have impacts on the main result, because these contents only consist of $\mathbf{nil}$ which will be shown in \Cref{formula_und_1}.
Note also that the predicate $\mathtt{Sapling}$ not only encodes the graph consisting of only one sapling, but also graphs consisting of both one sapling and circles. It is not necessary to remove all these circles, because it does not have impacts on correctness of the reduction. It is shown in \Cref{lemma:sap}.
\begin{lemma}\label{lemma:sap}
Given the predicate $\mathtt{sapling}(x_0,x_0')$ defined in \Cref{eq:sap}, it can be satisfied by a model $\sigma$ if and only if there exists a model $\sigma'$ that satisfies $\mathtt{sapling}(x_0,x_0')$, and there are no circles in $\sigma'$.
\end{lemma}
The proof of \Cref{lemma:sap} can be found in Appendix. Now we prove \Cref{thm:und}.
\begin{proof}[of \Cref{thm:und}]
We go into details of the reduction, which is shown in Fig. (\ref{fig:reduction}).
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{img/Structure_of_reduction.png}
\caption{Structure of reduction}
\label{fig:reduction}
\end{figure}
The master branch is the longest path from the beginning master node to the end master node. Each master node points to 0 or more slave nodes $\mathbf{nil}^*$. The master nodes have the period of 4. Each period represents a state of the run. In the $i$-th period ($1 <= i <= m$), the first master node represents a deliminator which separates each state of the run. There is no slave node attached to it. The second to the fourth master nodes represent the $i$-th triple $(I,C_1,C_2)$ satisfying $I = k_i,\; C_1 = c_i^1 +1, \text{ and } C_2 = c_i^2 + 1$. The slave nodes pointed from these 3 nodes are $\mathbf{nil}^{k_i},\; \mathbf{nil}^{c_i^1 + 1}, \text{ and } \mathbf{nil}^{c_i^2 + 1}$ respectively. The first period represents the initial state, while the last represents the final state.
We observe that the values of two counters in the sapling are greater than the real values of the counters in the run by 1. It is because we need to distinguish these nodes from the first node of each period, to which there is no slave nodes attached.
In general, The reduction formula consists of the following three parts.
\begin{enumerate}
\item Construct the basic structure of sapling, which is denoted by the formula $\varPhi_1 = \forall^*\forall^*.\varPhi_1'$.
\item Initialize the initial and the final state, which is denoted by the formula $\varPhi_2 = \exists^*\exists^*.\varPhi_2'$.
\item Encode the transition from one state to the other following the current instruction, which is denoted by the formula $\varPhi_3 = \forall^*\exists^*\exists^*.\varPhi_3'$.
\end{enumerate}
The formula is of the form
\begin{equation}\label{formula_und_1}
\begin{aligned}
\varPhi \quad=\quad& \varPhi_1 \land \varPhi_2 \land \varPhi_3 \\
\quad=\quad& \forall^*\forall^*.\varPhi_1' \land \exists^*\exists^*.\varPhi_2' \land \forall^*\exists^*\exists^*.\varPhi_3',
\end{aligned}
\end{equation}
or
\begin{align*}
\varPhi \quad=\quad \forall^*\forall^*.\varPhi_1' \land \forall^*\exists^*\exists^*.(\varPhi_2' \land \varPhi_3').
\end{align*}
The detailed construction can be found in Appendix.
For each two-counter Minsky machine M, let $\varPhi$ be the formula of the form defined in \Cref{formula_und_1}. If the machine M halts, then there is a finite run. It can be easily shown that there is a finite sapling from the first period encoding the first state to the final one encoding the final state, and each state except for the final state can be transformed to the next state by the corresponding instruction.
For the other side of the proof, we suppose that the formula $\varPhi$ of the form defined in \Cref{formula_und_1} is satisfied. The model $\sigma$ of $\varPhi$ may consist of circles. We can get a model $\sigma'$ satisfying $\varPhi$ in which there is no circles according to \Cref{lemma:sap}.
\end{proof}
\section{Conclusion}
In this paper, we propose sequence-heap separation logic which combines sequence predicate logic and separation logic. It is capable of describing the following properties which sequence predicate logic or separation logic alone cannot describe or cannot easily describe.
\begin{itemize}
\item sequence operations in programs, such as list reversal, and lookups.
\item properties corresponding to variable-length sequences in programs, such as stack, queue, and graphs with unbounded out-degree.
\item multilevel data structures in programs, such as data structure in Windows storage systems, and in block-based cloud storage systems.
\end{itemize}
Besides, we find a boundary between decidable and undecidable SeqSL fragments, which are both of the prenex normal form. We prove the following two decidable results: the satisfiability problem of $\Sigma_1$ fragment and $\Pi_1$ fragment is decidable, and that of $(\forall^*\forall^*\cap \forall^*\exists^*\exists^*)\text{SeqSL}(*)$ is undecidable. As corollaries, fragments with either 3 quantifier alternations over program variables or 2 quantifier alternations over sequence variables are undecidable.
We will do the following work in the future.
\begin{itemize}
\item Find other boundaries between decidable and undecidable fragments of sequence-heap separation logic, such as boundaries on numbers of quantified variables, and on inductive predicates.
\item Investigate deeply on expressiveness of sequence-heap separation logic.
\item Construct a proof system for sequence-heap separation logic.
\item Implement formal verification tools for sequence-heap separation logic fragments.
\end{itemize}
\bibliographystyle{IEEEtran}
\section{Introduction}
The classical separation logic proposed by Reynolds\cite{reynolds2002separation} is widely used to describe and verify various properties on heap-manipulated programs. It has evolved in many versions: object-oriented separation logic\cite{parkinson2008separation}, quantitative separation logic \cite{batz2019quantitative}, higher-order separation logic\cite{biering2007bi}, separation logic with inductive predicates\cite{brotherston2014decision}, etc. Its separating conjunction $*$ and separating implication $-*$ provides much succincter expressions on mutable data structures.
Sequences are also widely used in programs. Many data structures can be abstracted to sequences, including $\mathtt{vector}$ in C++, and $\mathtt{ArrayList}$ in Java. There are many string solvers on sequences, such as CVC4\cite{barrett2011cvc4} and Z3str3\cite{berzish2017z3str3}. Sequence predicate logic\cite{kutsia2004predicate} introduces sequence variables and sequence functions, and allows quantifiers over sequence variables. With sequence variables, sort function can be defined elegantly.
However, to our best knowledge, there is no integral formal systems on logical reasoning of programs with both heap and sequence. The example proposed in \cite{reynolds2002separation} provides a way to formally verify whether a program implements list reversal. The program aims to reverse the sequence $\alpha_0$ in $x$ and put it into $y$. The invariant of this program is written as follows:
\begin{align}\label{eg:sequence}
\exists \alpha \exists \beta.\;\bigl((\mathtt{ls}(x, \alpha) * \mathtt{ls}(y, \beta)) \land \alpha_0^{\dag} == \alpha^{\dag} \circ \beta\bigr),
\end{align}
where $\alpha^{\dag}$ denotes reversal of the sequence $\alpha$, and the term $\alpha \circ \beta$ denotes the concatenation of the two sequences $\alpha$ and $\beta$. The predicate $\mathtt{ls}(x,\alpha)$ denotes a singly-linked list starting from $x$, which can be inductively defined as follows:
\begin{equation}\label{eq:def_ls}
\begin{aligned}
\mathtt{ls}(x,\varepsilon) &\quad\overset{\triangle}{=}\quad x = \mathbf{nil}, \\
\mathtt{ls}(x,n \circ \alpha) &\quad\overset{\triangle}{=}\quad \exists y.\; x |-> y \circ n * \mathtt{ls}(y,\alpha).
\end{aligned}
\end{equation}
The property defined in \Cref{eg:sequence} can be attributed to properties on variable-length sequences in pointer programs. These properties can be found in many commonly-used mutable data structures, such as in stacks, queues, and graphs. Besides, variable-length sequences also appear in multilevel data structures, such as paging on operating systems, and file systems. It is necessary to introduce a logic to describe and verify these kind of properties.
In this paper, we aim to establish a logical foundation for \textbf{variable-length sequences} and \textbf{multilevel data structures} in pointer programs, especially on definition, expressiveness and decidability. We propose sequence-heap separation logic to \textbf{integrate sequences into logical reasoning in pointer programs}. The logic is an extension of both classical separation logic proposed in \cite{reynolds2002separation}, and sequence predicate logic proposed in \cite{kutsia2004predicate}.
Sequence-heap separation logic can be seen as a fragment of higher-order separation logic proposed in \cite{biering2007bi}. Quantifiers over sequences can be reduced to those over predicates (or over sets). Sequence-heap separation logic is less expressive than higher-order separation logic, but can be used in many scenarios on sequences in pointer programs, and has better deciability results.
In terms of definition for sequence-heap separation logic, we define the heap model as a finite partial mapping from locations to sequences, which is similar to the block model $\mathrm{Heap}_B$ defined in \cite{jin2022reasoning}. The model can be written as $h: \text{Loc} \overset{\mathrm{fin}}{\rightharpoonup} (\text{Loc} \cup \text{Val})^*$, compared to the model $h: \text{Loc} \overset{\mathrm{fin}}{\rightharpoonup} \text{Loc} \cup \text{Val}$ defined in the classical separation logic.
We also \textbf{define sequence singleton heap} as the term $x |-> \alpha$ to adapt more scenarios on variable-length sequences. The term can be used to denote stack, queue, variadic arguments, trees with variable-length branches, graphs with unbounded out-degree, etc. We take stack as an example.
In the classical separation logic, one has to describe stack with the inductive predicate $\mathtt{ls}(x,\alpha)$ defined in \Cref{eq:def_ls}, where $x$ and $\alpha$ denote the top pointer and contents of the stack respectively. However, with sequence singleton heap $x |-> \alpha$ defined in sequence-heap separation logic, one can use this formula to denote stack without inductive predicate.
The definition of sequence singleton heap can help us to get a decidable result. We prove that the $\Sigma_1$ fragment with sequence singleton heap is decidable, compared to the undecidable result on $\Sigma_1$ fragment in \cite{demri2018effects} where the list predicate $\mathtt{ls}(x,y)$, separating conjunctions, and separating implications are defined.
Besides, properly defining the form of $\alpha$ can help the logic to describe \textbf{multilevel data structures}. For example, if $\alpha$ is of the form $\alpha\#\beta$ (where $\alpha$ denotes the sequence of locations, $\beta$ denotes the sequence of contents, and $\#$ separates these two sequences), one can describe two-tier data structures\cite{jin2022reasoning} in block-based cloud storage systems in the following way.
\begin{align}\label{eq:multi}
(x |-> \alpha\#\varepsilon) * \forall y\exists \beta.\; \bigl(y \overline{\in} \alpha => (y \hookrightarrow \varepsilon\#\beta)\bigr),
\end{align}
where $x$ denotes the block location, $\alpha$ denotes the sequence of content location, and $\beta$ denotes contents in each location of $\alpha$. The term $y \overline{\in} \alpha$ denotes $y$ appears in $\alpha$, which is defined as follows:
\begin{align*}
y \overline{\in} \alpha \overset{\triangle}{=} \exists \alpha_1\exists \alpha_2.\; \alpha == \alpha_1 \circ y \circ \alpha_2.
\end{align*}
\Cref{eq:multi} can be illustrated by Fig. (\ref{fig:two_tier}).
\begin{figure}[!ht]
\centering
\includegraphics[width=0.4\textwidth]{img/Two-tier_data_structure.png}
\caption{Representation of two-tier data structure}
\label{fig:two_tier}
\end{figure}
We notice that sequence predicate logic proposed in \cite{kutsia2004predicate} is also capable of describing various properties on variable-length sequences. However, the logic cannot be directly used to describe sequences in pointer programs. sequence-heap separation logic is more than just the combination of sequence predicate logic and separation logic. The logic enriches the composition of the two.
We also notice that the model of sequence-heap separation logic is similar to that of block-based separation logic proposed in \cite{jin2022reasoning}. However, the sequence singleton heap and quantifiers over sequences in sequence-heap separation logic provide more abstraction, and can be used for wider application scenarios, not just for block-based cloud storage systems.
For example, the combined logic can simplify expressions on describing stack. Besides, sequence predicate logic and separation logic alone cannot describe multilevel data structures shown in \Cref{eq:multi}, but the combined one can do this.
We also study decidability problems of sequence-heap separation logic fragments. This can help us to find algorithms for decidable fragments, as well as to understand expressiveness of the logic intensively. We get the following two main fragments on satisfiability problems. One is a decidable fragment which lays between $\Sigma_1$ fragment of the classical separation logic, and the logic involving list predicate. The other is an undecidable fragment where there are two alternations on quantifiers over program variables, and one alternation on quantifiers over sequence variables.
The paper is organized as follows. In Section \rom{2}, we introduce some basic concepts of separation logic and sequence predicate logic. In Section \rom{3}, we define sequence-heap separation logic and explore its expressiveness. In Section \rom{4}, we prove that the satisfiability problem of $\Sigma_1$ fragment is decidable. In Section \rom{5}, we prove that the satisfiability problem of the fragment with the prenex normal form $\forall^*\forall^*\cap \forall^*\exists^*\exists^*$ is undecidable. In addition, we explore boundaries between decidable and undecidable fragments. In Section \rom{6}, we conclude our work, and propose future work on sequence-heap separation logic.
\textbf{Related work.} Separation logic can express properties on heaps, such as dangling pointers, non-circularity, and memory leakages.\cite{berdine2004decidable} However, the logic itself is proved to be undecidable\cite{brochenin2012almighty}. We investigate the following two categories of fragments: basic fragments without inductive predicates and $\Sigma_1$ fragments with inductive predicates.
In basic fragments, there are no user-defined predicates or hard-corded predicates. It is known that the validity problem of $\Pi_1$ fragment $\mathrm{SL}(*, -*)$ is decidable\cite{calcagno2001computability}, and that of basic fragment $\mathrm{SL}(\forall, \hookrightarrow)$ with quantifiers and no separation implications is undecidable\cite{calcagno2001computability}. If we restrict the size of the heap satisfying $\varphi_1$ in the formulae $\varphi_1 -* \varphi_2$ to be bounded (namely $n$), then we can get a decidable basic fragment $\mathrm{SL}(*,-*^n,\exists)$\cite{brochenin2012almighty}. To get decidable fragments, one can either restrict quantifier alternations in the formulae of prenex normal form, or number of quantified variables. For quantifier alternations, the fragment $\mathrm{SL}(\exists^*\forall^*)$ with 2 quantifier alternations is decidable\cite{reynolds2017reasoning}, while the fragment $\mathrm{SL}(\exists^*\forall^*\exists^*)$ with 3 is undecidable\cite{reynolds2017reasoning}. For quantified variables, the fragment $1\SL1$ with 1 quantified variable is decidable \cite{demri2017separation}, while the fragment $1\SL2$ with 2 quantified variables is undecidable \cite{demri2015two}.
In $\Sigma_1$ fragments, it contains separation implications (or its variants) and inductive predicates describing data structures. One basic result is that the satisfiability problem of $\Sigma_1$ fragment $\mathrm{SL}(*,-*,\mathtt{ls})$ with lists is undecidable\cite{demri2018effects}. However, if list predicates are restricted to the list with length at most 2, one can get a decidable fragment $\mathrm{SL}(*,-*,\mathtt{reach}_2)$\cite{demri2018effects}. Besides, if we further restrict heap unions in separation model, one can get strong-separation logic\cite{pagel2022strong}. It is proved that the strong-separation fragment $\mathrm{SSL}(*,\mathrel{\sepimp \mkern-15mu^{\lnot}},\mathtt{ls})$ with list predicates is decidable.
All fragments mentioned above can be found in TABLE \ref{table:decidability}.
\begin{table*}
\centering
\normalsize
\caption{Decidability of separation logic fragments}
\begin{tabular}{cccc}
\toprule
Fragment & Model & \makecell{Key connectives\\and predicates} & Decidability \\
\midrule
$\mathrm{SL}(*,-*)$
& \multirow{7}{*}{\makecell{separation\\model}}
& $\lnot, |->, *,- *$
& decidable
\\
$\mathrm{SL}(\forall, \hookrightarrow)$
&
& $\lnot, \forall, \hookrightarrow$
& undecidable
\\
$\mathrm{SL}(*,-*^n,\exists)$
&
& $*\lnot,,-*^n,\exists$
& decidable
\\
$\mathrm{SL}(\exists^*\forall^*)$
&
& prenex $\exists^*\forall^*$
& decidable
\\
$\mathrm{SL}(\exists^*\forall^*\exists^*)$
&
& prenex $\exists^*\forall^*\exists^*$
& undecidable
\\
$1\SL1$
&
& 1 quantified variable
& decidable
\\
$1\SL2$
&
& 2 quantified variables
& undecidable
\\
\midrule
$\mathrm{SL}(*,-*,\mathtt{ls})$
& separation model
& $\lnot, *, -*, \mathtt{ls}(x,y)$
& undecidable
\\
$\mathrm{SL}(*,-*,\mathtt{reach}_2)$
& separation model
& $\lnot, *, -*, \mathtt{reach}_2(x,y)$
& decidable
\\
$\mathrm{SSL}(*,\mathrel{\sepimp \mkern-15mu^{\lnot}}, \mathtt{ls})$
& \makecell{strong-separation\\model}
& $\lnot, *, \mathrel{\sepimp \mkern-15mu^{\lnot}}, \mathtt{ls}$
& decidable
\\
\bottomrule
\end{tabular}
\label{table:decidability}
\end{table*}
Sequence predicate logic is an extension of word equation. Specifically, word equations are $\Sigma_1$ fragment or $\Pi_1$ fragment of sequence predicate logic, where there are only quantifiers over sequence variables. It can express many properties on sequences, such as conjugates, and lexicographic ordering on words\cite{karhumaki2000expressibility}. On the other hand, it cannot express properties such as "the primitiveness" and "the equal length". It is shown that every Boolean combinations of word equations on free semigroup can be reduced to a single word equation\cite{makanin1977problem}.
Different from the classical predicate logic, sequence variables, sequence predicates and sequence functions are defined in sequence predicate logic\cite{kutsia2004predicate}. The problem of whether there is a solution for word equation is decidable\cite{makanin1977problem}. Namely, the truth of $\Sigma_1$ fragment of sequence predicate logic is decidable. Further researches show that the truth of positive formulae (where there is no negations or inequalities) which is of the form $\forall^*\exists^*$\cite{durnev1995undecidability}, $\exists^*\forall^*$\cite{day2018satisfiability} or $\exists^*\forall^*\exists^*$\cite{vavzenin1983decidability} is shown to be undecidable. To get a decidable fragment, one can restrict the formulae of the form $\exists^*\forall^*$ to the positive one\cite{vavzenin1983decidability}.
There are some works which combine separation logic and sequences. When formalizing cloud storage systems, one can construct a modeling language $\textbf{IMDSS}$\cite{jing2017modeling}, and a proof system based on separation logic\cite{jin2022reasoning}. These papers define values of heaps as finite sequences, and describe properties on blocks without using sequence singleton heap. Coq-based proof assistant\cite{zhang2022tool} is implemented based on the logic defined in \cite{jin2022reasoning}.
\section{Preliminaries}
In this section, we introduce some basic concepts on separation logic and sequence predicate logic.
\subsection{Separation logic}
In this subsection, we mainly focus on definitions and expressiveness of separation logic.
\begin{definition}[Definition of separation logic]
The syntax of separation logic\cite{reynolds2000intuitionistic} with 1 records is defined as follows:
\vspace{-1em}
\small
\begin{align*}
t \quad::=&\quad \mathbf{nil} \mid n \mid x \mid \mathtt{f}^n(t,\dots,t) \\
p \quad::=&\quad t = t \mid \mathbf{emp} \mid t |-> t \mid \mathtt{P}^n(t,\dots,t) \\
\varphi \quad::=&\quad p \mid \lnot \varphi \mid \varphi \land \varphi \mid \varphi \lor \varphi \mid \varphi => \varphi \mid \varphi * \varphi \mid \varphi -* \varphi \mid \exists x.\varphi,
\end{align*}
\normalsize
where $n$ denotes constants, $x$ denotes variables, $\mathtt{f}^n$ denotes $n$-ary functions mapping $\mathbb{N}^n$ to $\mathbb{N}$, and $\mathtt{P}^n$ denotes $n$-ary predicates mapping $\mathbb{N}^n$ to $\{0,1\}$.
The underlying model $\sigma=(s,h)$ of separation logic consists of a stack $s$ and a heap $h$. The set $\mathrm{Loc}$ comprises locations excluding $\mathbf{nil}$. The set $\mathrm{Var}$ comprises symbols of variables, including $x,y,z,\dots$. The set $\mathrm{Val}$ comprises integer values. The model is defined as follows:
\begin{table}[htbp]
\centering
\label{table1}
\tabcolsep=0.5cm
\renewcommand\arraystretch{1.2}
\normalsize
\begin{tabular}{ll}
$\text{Loc}, \text{Val} \subseteq \mathbb{N}$ &
$\mathbf{nil} \in \text{Atoms}$ \\
$s: \text{Var} -> \text{Loc} \cup \text{Val}$ &
$h: \text{Loc} \overset{\mathrm{fin}}{\rightharpoonup} (\text{Loc} \cup \text{Val})^*$.
\end{tabular}
\end{table}
\vspace{-0.5em}
The semantics of the term $\mathtt{f}^n(t_1,\dots,t_n)$ can be defined as follows, where $\mathtt{f}_\sigma^n$ is the interpretation of $\mathtt{f}^n$.
\begin{align*}
|[\mathtt{f}^n(t_1,\dots,t_n)|]\sigma = \mathtt{f}_\sigma^n(|[t_1|]\sigma,\dots,|[t_n|]\sigma).
\end{align*}
The semantics of formulae is inductively defined as follows:
\begin{align*}
& \sigma |= t_1 = t_2
&\text{iff}&\quad
|[t_1|]\sigma = |[t_2|]\sigma. \\
& \sigma |= \mathbf{emp}
&\text{iff}&\quad
\mathtt{dom}(h) = \varnothing. \\
& \sigma |= t_1 |-> t_2
&\text{iff}&\quad
|[t_1|]\sigma != \mathbf{nil} \text{ and } \mathtt{dom}(h) = \{|[t_1|]\sigma\} \\
& & & \quad \text{ and } h(|[t_1|]\sigma) = |[t_2|]\sigma. \\
& \sigma |= \mathtt{P}^n(t_1,\dots,t_n)
&\text{iff}&\quad
\mathtt{P}_\sigma^n(|[t_1|]\sigma,\dots,|[t_n|]\sigma) \text{ holds.} \\
& \sigma |= \lnot \varphi
&\text{iff}&\quad
\sigma \nvDash \varphi. \\
& \sigma |= \varphi_1 \land \varphi_2
&\text{iff}&\quad
\sigma |= \varphi_1 \text{ and } \sigma |= \varphi_2. \\
& \sigma |= \varphi_1 \lor \varphi_2
&\text{iff}&\quad
\sigma |= \varphi_1 \text{ or } \sigma |= \varphi_2. \\
& \sigma |= \varphi_1 => \varphi_2
&\text{iff}&\quad
\text{if } \sigma |= \varphi_1 \text{, then } \sigma |= \varphi_2. \\
& \sigma \;|=\; \varphi_1 * \varphi_2
&\text{iff} &\quad
\text{there exists heap } h_1 \text{ and } h_2, \\
& & & \quad \text{such that } \mathtt{dom}(h_1) \cap \mathtt{dom}(h_2) = \varnothing, \\
& & & \quad \text{and } h = h_1 \uplus h_2, \text{ and } (s,h_1) \;|=\; \varphi_1 , \\
& & & \quad \text{and } (s,h_2) \;|=\; \varphi_2. \\
& \sigma \;|=\; \varphi_1 -* \varphi_2 &
\text{iff} &
\quad \text{for all heaps } h_1, \\
& & & \quad \text{if } \mathtt{dom}(h_1) \cap \mathtt{dom}(h) = \varnothing \text{,} \\
& & & \quad \text{and } (s,h_1) \;|=\; \varphi_1, \\
& & & \quad \text{then } (s,h_1 \uplus h) \;|=\; \varphi_2. \\
& \sigma \;|=\; \exists x.\varphi &
\text{iff} &
\quad \text{there exists } x_0 \text{ in Loc} \cup \text{Val,} \\
& & & \quad \text{such that } (s[x -> x_0], h) \;|=\; \varphi,
\end{align*}
where $\mathtt{P}_\sigma^n$ denotes the interpretation of $\mathtt{P}^n$.
\end{definition}
For convenience, we have the following notation\cite{reynolds2000intuitionistic} denoting that $t$ points to $t_1,\dots,t_n$ with some fixed $n$.
\begin{align}\label{eq:singleton}
t |-> t_1,\dots,t_n \overset{\triangle}{=} (t |-> t_1) * \dots * (t + n - 1 |-> t_n).
\end{align}
In some fragments of separation logic, the heap model is defined as $h: \text{Loc} \overset{\text{fin}}{\rightharpoonup} \text{Val}^n$ with some fixed $n$\cite{reynolds2000intuitionistic}\cite{berdine2005symbolic}. In this case, \Cref{eq:singleton} will no longer hold. The semantics of the notation is defined as follows:
\begin{align*}
& \sigma |= t |-> t_1,\dots,t_n &\text{iff}\quad& |[t|]\sigma != \mathbf{nil} \text{ and } \mathtt{dom}(h) = \{|[t|]\sigma\}, \\
& & & \text{ and } h(|[t|]\sigma) = (|[t_1|]\sigma,\dots,|[t_n|]\sigma).
\end{align*}
We notice that in either separation logic or one of its fragments (symbolic heap\cite{berdine2004decidable}\cite{berdine2005symbolic}, strong-separation logic\cite{pagel2022strong}, etc.), the singleton heap is defined with some fixed number $n$. It may not be suitable for describing properties on blocks, or graphs where each node is of unbounded out-degrees.
The paper \cite{jin2022reasoning} introduces sequence into separation logic to describe properties on block-based cloud storage systems. The model of the logic is defined as a quintuple of the form $(s_F, s_B, s_V, h_B, h_V)$, where $s_F, s_B, s_V$ are assignments of file variables, block variables and location variables respectively, $h_B, h_V$ are heaps of blocks and heaps of values respectively. The file stack $s_F$ is a mapping from file variables to a sequence of block addresses, which is denoted as $s_F \overset{\triangle}{=} \text{FVar} -> \text{BLoc}^*$, and $h_B$ is a finite partial mapping from blocks to sequences of locations, which is denoted as $h_B \overset{\triangle}{=} \text{BLoc} \overset{\text{fin}}{\rightharpoonup} \text{Loc}^*$. Although $s_F$ and $h_B$ both range over sequences, the logic does not introduce sequence variables, sequence functions, or sequence singleton heap. The logic visits these sequences by existential quantifiers on block variables, and by equality over values of block variables.
\subsection{Word equations and sequence predicate logic}
Word equation can be seen as a special case of sequence predicate logic. It can be defined as follows:
\begin{definition}[Word equation]
Suppose $X^*$ is a free semigroup satisfying $X = \{n_1,\dots,n_k\}$ with unknowns $\alpha_1,\dots,\alpha_m \in X^*$, where $n_1,\dots,n_k$ are generators. Word equation is an equality of the form:
\begin{align*}
U(n_1,\dots,n_k,\alpha_1,\dots,\alpha_m) == V(n_1,\dots,n_k,\alpha_1,\dots,\alpha_m),
\end{align*}
where $==$ is the equality between two concatenations of sequences. If there is a solution for $U == V$, then the word equation is satisfied.
\end{definition}
The definition of word equation can be enhanced with Boolean combination, as is shown in \Cref{def:Boolcomb}.
\begin{definition}[Boolean combination of word equations]\label{def:Boolcomb}
Boolean combination of word equations is defined as follows:
\begin{align*}
t &\quad::=\quad n \mid \alpha \mid t \circ t \\
\varphi &\quad::=\quad t == t \mid \lnot \varphi \mid \varphi \land \varphi \mid \varphi \lor \varphi,
\end{align*}
where $n$ denotes constants, $\alpha$ denotes sequence variables, and $t_1 \circ t_2$ denotes the concatentation of two sequences $t_1$ and $t_2$.
\end{definition}
Word equation is capable of describing many properties on sequences. Every Boolean combinations of word equations can be reduced to a single word equation followed by \Cref{thm:Boolean comb}\cite{karhumaki2000expressibility}.
\begin{theorem}\label{thm:Boolean comb}
For every Boolean combinations $\varphi$ defined above, there exists a single word equation $T(\varphi) \overset{\triangle}{=} U == V$, which is equivalent to $\varphi$. The proof sketch of the theorem can be found in Appendix.
\end{theorem}
If word equation is enhanced with sequence function, and quantifiers over variables and sequences, then one can get the following definition of sequence predicate logic.
\begin{definition}[Sequence predicate logic]\label{def:seqPredLogic}
The syntax of sequence predicate logic\cite{kutsia2004predicate} can be defined as follows:
\begin{align*}
t &\quad::=&& n \mid x \mid \alpha \mid t \circ t \mid \mathtt{f}(t,\dots,t) \mid \overline{\mathtt{f}}(t,\dots,t) \\
\varphi &\quad::=&& t == t \mid \mathtt{P}(t,\dots,t) \mid \lnot \varphi \mid \varphi \land \varphi \mid \varphi \lor \varphi \\
&&& \mid \varphi => \varphi \mid \exists x.\varphi \mid \exists \alpha.\varphi.
\end{align*}
The variable $x$ denotes individual variables, and $\alpha$ denotes sequence variables. The arity of $\mathtt{f}$, $\overline{\mathtt{f}}$, and $\mathtt{P}$ can be either fixed or flexible. When it is fixed, there is no sequence variables on parameters. When it is flexible, it may contain sequence variables.
The structure of the logic is defined as $(\mathrm{Val},I)$, where $\mathrm{Val}$ is the domain, and $I$ is the interpretation on individual and sequence constants, functions and predicates. The assignment of the logic can be defined as $(s_x,s_{\alpha})$, where $s_x: \mathrm{IVar} -> \mathrm{Val}$, $s_{\alpha}: \mathrm{SVar} -> \mathrm{Val}^*$, and $\mathrm{IVar} = \{x,y,z,\dots\}$, $\mathrm{SVar} = \{\alpha,\beta,\gamma,\dots\}$.
In sequence predicate logic, $t_1 \circ t_2$ denotes the concatenation between two sequences $t_1$ and $t_2$, $t_1 == t_2$ denotes that two equations $t_1$ and $t_2$ are equal. Due to space limitations, we do not list the semantics of the logic. The details can be found in \cite{kutsia2004predicate}\cite{kutsia2007solving}.
\end{definition}
\subsection{Expressiveness of sequence predicate logic}
We recall properties which can be expressed by sequence predicate logic. They are useful for describing properties with sequence-heap separation logic.
\noindent\textbf{Length}. Sequence predicate logic can be used to get the length of a sequence. The function $\mathtt{length}(\alpha)$ denotes the length of the sequence $\alpha$, which can be inductively defined as follows:
\begin{align*}
\mathtt{length}&(\varepsilon) \overset{\triangle}{=} 0 \\
\mathtt{length}&(n \circ \alpha) \overset{\triangle}{=} 1 + \mathtt{length}(\alpha).
\end{align*}
For convenience, we define $|\alpha|$ to denote $\mathtt{length}(\alpha)$.
\noindent\textbf{Statistics}. Sequence predicate logic can be used to get occurrences of specific terms. The function $\mathtt{find}(\alpha, x)$ denotes the occurrences of $x$ in sequence $\alpha$, which can be inductively defined as follows:
\begin{align*}
\mathtt{find}&(\varepsilon, x) \overset{\triangle}{=} 0 & \\
\mathtt{find}&(n \circ \alpha, x) \overset{\triangle}{=} 1 + \mathtt{find}(\alpha, x), & n = x \\
\mathtt{find}&(n \circ \alpha, x) \overset{\triangle}{=} \mathtt{find}(\alpha, x), & n \neq x
\end{align*}
For convenience, we define $|\alpha|_{x}$ to denote $\mathtt{find}(\alpha, x)$.
\noindent\textbf{Lookups}. The predicate $\mathtt{eq}(x_1, \alpha, x_2)$ denotes the $x_2$-th item of sequence $\alpha$ is $x_1$, which can be expressed as follows:
\begin{align*}
\mathtt{eq}(x_1, \alpha, x_2) \overset{\triangle}{=} \exists \alpha_1 \exists \alpha_2.\; \alpha == \alpha_1 \circ x_1 \circ \alpha_2 \land |\alpha_1 \circ x_1| = x_2.
\end{align*}
Note that $\alpha(x)$ does not appear as a term in \Cref{def:seqPredLogic}. If so, consider the case where $x$ exceeds the length of sequence $\alpha$. A new value $\perp$ should be introduced to denote illegal term, which may complicate the logic. We take $x_1 = \alpha(x_2)$ to denote $\mathtt{eq}(x_1,\alpha,x_2)$ for convenience:
\begin{align*}
x_1 = \alpha(x_2) \overset{\triangle}{=} \mathtt{eq}(x_1,\alpha,x_2).
\end{align*}
Other properties can be expressed with lookups. We list some of them below.
The relationships between items and sequences can be defined as $x \;\bar{\in}\; \alpha$, which means $x$ can be found in the sequence $\alpha$:
\begin{align*}
x \;\bar{\in}\; \alpha \overset{\triangle}{=} \exists x_1.\; x = \alpha(x_1).
\end{align*}
The $x_1$-th item of the sequence $\alpha_1$ is equal to the $x_2$-th item of the sequence $\alpha_2$:
\begin{equation*}
\mathtt{eq}(\alpha_1, x_1, \alpha_2, x_2) \overset{\triangle}{=} \exists x_3.\; x_3 = \alpha_1(x_1) \land x_3 = \alpha_2(x_2).
\end{equation*}
\noindent\textbf{Unary property}. All items in the sequence $\alpha$ satisfies the unary property $\mathtt{P}^1(x)$:
\begin{align*}
\forall x \forall \alpha_1 \forall \alpha_2.\; \alpha == \alpha_1 \circ x \circ \alpha_2 => \mathtt{P}^1(x).
\end{align*}
\noindent\textbf{Binary property}. Each two items with different indices in the sequence $\alpha$ satisfies the binary property $\mathtt{P}^2(x_1,x_2)$ :
\begin{align*}
\forall x_1 \forall x_2 \forall \alpha_1 \forall \alpha_2 \forall \alpha_3.\;& \alpha == \alpha_1 \circ x_1 \circ \alpha_1 \circ x_2 \circ \alpha_3 \\
& => \mathtt{P}^2(x_1,x_2).
\end{align*}
Increment and set-like defined bellow are binary properties.
\noindent\textbf{Increment}. The sequence $\alpha$ is strictly increasing:
\begin{align*}
\mathtt{Inc}(\alpha) \overset{\triangle}{=} \;& \forall x_1 \forall x_2 \forall \alpha_1 \forall \alpha_2 \forall \alpha_3.\\
& \alpha == \alpha_1 \circ x_1 \circ \alpha_2 \circ x_2 \circ \alpha_3 => x_1 < x_2.
\end{align*}
\noindent\textbf{Set-like}. Each two items in sequence $\alpha$ are distinct:
\begin{align*}
\mathtt{Diff}(\alpha) \overset{\triangle}{=} \;& \forall x_1 \forall x_2 \forall \alpha_1 \forall \alpha_2 \forall \alpha_3. \\
& \alpha == \alpha_1 \circ x_1 \circ \alpha_1 \circ x_2 \circ \alpha_3 => x_1 != x_2.
\end{align*}
\noindent\textbf{Segment}. The sequence $\alpha_2$ is the consecutive sub-sequence of $\alpha_1$:
\begin{equation*}
\alpha_2 \;\in\; \mathtt{Seg}(\alpha_1) \overset{\triangle}{=} \exists \alpha_3 \exists \alpha_4.\\ \alpha_1 == \alpha_3 \circ \alpha_2 \circ \alpha_4.
\end{equation*}
\noindent\textbf{Truncation}. The sequence $\alpha_2$ is the consecutive sub-sequence of $\alpha_1$ with indices ranging over $[x_1, x_2)$ :
\begin{align*}
&\alpha_2 ==\;
\mathtt{Trunc}(\alpha_1,x_1,x_2) \\
\overset{\triangle}{=} \quad& \exists \alpha_3 \exists \alpha_4.\; \alpha_1 == \alpha_3 \circ \alpha_2 \circ \alpha_4 \\
& \hspace{4em} \land |\alpha_3| = x_1 - 1 \land |\alpha_3 \circ \alpha_2| = x_2 - 1.
\end{align*}
\section{sequence-heap separation logic}
sequence-heap separation logic is an extension of both classical separation logic and sequence predicate logic. It can describe properties on variable-length sequences, and multilevel data structures. Some properties cannot be expressed easily by the classical separation logic or sequence predicate logic alone.
In this section, we present the definition and expressiveness of sequence-heap separation logic (SeqSL).
\subsection{Definition of sequence-heap separation logic}
\begin{definition}[Syntax of sequence-heap separation logic]\label{def:syntaxSeqSL}
The syntax of the logic can be defined as follows:
\begin{align*}
t_x &\quad::= \quad \mathbf{nil} \mid \# \mid n \mid x \\
t_{\alpha} &\quad::= \quad \varepsilon \mid t_x \mid \alpha \mid t_{\alpha} \circ t_{\alpha} \\
\varphi &\quad::= \quad t_x = t_x \mid t_{\alpha} == t_{\alpha} \mid \lnot \varphi \mid \varphi \land \varphi \mid \varphi \lor \varphi \mid \varphi => \varphi \\
& \hspace{3.5em} \mid \mathbf{emp} \mid t_x |-> t_\alpha \mid \varphi * \varphi \mid \varphi -* \varphi \mid \exists x.\varphi \mid \exists \alpha.\varphi.
\end{align*}
\end{definition}
Note that other functions and predicates can be defined in SeqSL following the definition in \cite{kutsia2004predicate}, such as comparison between sequence, and picking up an item from a sequence. Most commonly-used predicates and functions can be expressed by the logic defined above.
\begin{definition}[Model of sequence-heap separation logic]\label{def:modelSeqSL}
There are three types of variables in the signature of SeqSL: program variables $\text{PVar} = \{x, y, z, \dots\}$, sequence variables $\text{SVar} = \{\alpha, \beta, \gamma, \dots\}$. These sets are all countable. The model $\sigma = (s_x,s_{\alpha},h)$ can be defined as follows:
\begin{table}[H]
\centering
\label{table1}
\tabcolsep=0.5cm
\renewcommand\arraystretch{1.2}
\normalsize
\begin{tabular}{ll}
$\text{Loc}, \text{Val} \subseteq \mathbb{N}$ &
$\mathbf{nil}, \# \in \text{Atoms}$ \\
$\text{Loc} \cap \text{Atoms} = \varnothing$ &
$s_x: \text{PVar} -> \text{Loc} \cup \text{Val}$ \\
$s_{\alpha}: \text{SVar} -> (\text{Loc} \cup \text{Val})^*$ &
$h: \text{Loc} \overset{\text{fin}}{\rightharpoonup} (\text{Loc} \cup \text{Val})^*$,
\end{tabular}
\end{table}
\vspace{-0.5em}
where Loc is the set of locations, Val is the set of values, Atoms is the set of reserved words, $s_x$ denotes the stack, $s_{\alpha}$ denotes the assignment on sequence variables, and $h$ denotes the heap which stores sequence of locations, values, or atoms.
\end{definition}
\begin{definition}[Semantics of terms]\label{def:smtsTerms}
The symbol $t_x$ denotes \textbf{individual term}, whose value ranges over Val. The denotational semantics of the term can be inductively defined as follows:
\begin{align*}
|[&\mathbf{nil}|]\sigma = \mathbf{nil} &
|[&\#|]\sigma = \# \\
|[&n|]\sigma = n &
|[&x|]\sigma = s_x(x),
\end{align*}
where $\mathbf{nil}, \#$ in Atoms cannot be used as a location, and $\#$ is used to describe multilevel data structures.
The symbol $t_{\alpha}$ denotes \textbf{sequence term}, whose value ranges over $(\text{Loc} \cup \text{Val})^*$ . The denotational semantics of the term can be inductively defined as follows:
\begin{align*}
|[&\varepsilon|]\sigma = \varepsilon &
|[&t_x|]\sigma \text{ is defined above} \\
|[&\alpha|]\sigma = s_{\alpha}(\alpha) &
|[&t_{\alpha_1} \circ t_{\alpha_2}|]\sigma = |[t_{\alpha_1}|]\sigma \circ |[t_{\alpha_2}|]\sigma,
\end{align*}
where $|[t_{\alpha_1}|]\sigma \circ |[t_{\alpha_2}|]\sigma$ denotes the concatenation of two sequences $|[t_{\alpha_1}|]\sigma$ and $|[t_{\alpha_2}|]\sigma$.
\end{definition}
\begin{definition}[Semantics of sequence-heap separation logic]\label{def:semanticsSeqSL}
In SeqSL, the indices of sequence items start from 1. We set $\text{Values} = \text{Val} \; \cup\; \text{Loc}$ for convenience. The semantics of SeqSL can be defined as follows:
\begin{align*}
& \sigma \;|=\; t_{x_1} = t_{x_2} &
\text{iff} &
\quad |[t_{x_1}|]\sigma = |[t_{x_2}|]\sigma. \\
& \sigma \;|=\; t_{\alpha_1} == t_{\alpha_2} &
\text{iff} &
\quad |[t_{\alpha_1}|]\sigma == |[t_{\alpha_2}|]\sigma. \\
& \sigma \;|=\; \lnot \varphi &
\text{iff} &
\quad \sigma \;\nvDash\; \varphi. \\
& \sigma \;|=\; \varphi_1 \land \varphi_2 &
\text{iff} &
\quad \sigma \;|=\; \varphi_1 \text {, and } \sigma \;|=\; \varphi_2. \\
& \sigma \;|=\; \varphi_1 \lor \varphi_2 &
\text{iff} &
\quad \sigma \;|=\; \varphi_1 \text {, or } \sigma \;|=\; \varphi_2. \\
& \sigma \;|=\; \varphi_1 => \varphi_2 &
\text{iff} &
\quad \text{if } \sigma \;|=\; \varphi_1 \text {, then } \sigma \;|=\; \varphi_2. \\
& \sigma \;|=\; \textbf{emp} &
\text{iff} &
\quad \mathtt{dom}(h) = \varnothing. \\
& \sigma \;|=\; t_x |-> t_\alpha &
\text{iff} &
\quad |[t_x|]\sigma \notin \mathrm{Atom}, \; \mathtt{dom}(h) = \{|[t_x|]\sigma\},\\
& & & \quad \text{ and } h(|[t_x|]\sigma) = |[t_{\alpha}|]\sigma \\
& \sigma \;|=\; \varphi_1 * \varphi_2 &
\text{iff} &
\quad \text{there exist heap } h_1 \text{ and } h_2, \\
& & & \quad \text{such that } \mathtt{dom}(h_1) \cap \mathtt{dom}(h_2) = \varnothing \;, \\
& & & \quad \text{and } h = h_1 \uplus h_2,\; (s_x,s_{\alpha},h_1) \;|=\; \varphi_1, \\
& & & \quad \text{and } (s_x,s_{\alpha},h_2) \;|=\; \varphi_2. \\
& \sigma \;|=\; \varphi_1 -* \varphi_2 &
\text{iff} &
\quad \text{for all heaps } h_1, \\
& & & \quad \text{if } \mathtt{dom}(h_1) \cap \mathtt{dom}(h) = \varnothing \text{ ,} \\
& & & \quad \text{and } (s_x,s_{\alpha},h_1) \;|=\; \varphi_1, \\
& & & \quad \text{then } (s_x,s_{\alpha},h_1 \uplus h) \;|=\; \varphi_2. \\
& \sigma \;|=\; \exists x.\varphi &
\text{iff} &
\quad \text{there exists } x_0 \text{ in Values,} \\
& & & \quad \text{such that } (s_x[x -> x_0], s_{\alpha}, h) \;|=\; \varphi. \\
& \sigma \;|=\; \exists \alpha.\varphi &
\text{iff} &
\quad \text{there exists } \alpha_0 \text{ in Values}^*, \\
& & & \quad \text{such that } (s_x, s_{\alpha}[\alpha -> \alpha_0], h) \;|=\; \varphi,
\end{align*}
where $s_x[x -> x_0]$ and $s_{\alpha}[\alpha -> \alpha_0]$ denote substitution of program variable and sequence variable respectively. They are defined as follows.
\begin{align*}
s_x[x -> x_0](x') = \begin{cases}
s_x(x_0), & x' = x \\
s_x(x), & \text{otherwise}
\end{cases}
\end{align*}
\begin{align*}
s_{\alpha}[\alpha -> \alpha_0](\alpha') = \begin{cases}
s_{\alpha}(\alpha_0), & \alpha' == \alpha \\
s_{\alpha}(\alpha), & \text{otherwise}
\end{cases}
\end{align*}
\end{definition}
For convenience, we write $\exists x.\varphi$ to denote $\exists x.\varphi$, and $\exists \alpha.\varphi$ to denote $\exists \alpha.\varphi$.
SeqSL can express properties which is widely used in logic reasoning on pointer programs. We list some of them. These notations will be used in this paper.
\begin{align*}
& \text{septraction} &&\quad \varphi_1 \mathrel{\sepimp \mkern-15mu^{\lnot}} \varphi_2 \overset{\triangle}{=} \lnot (\varphi_1 -* \lnot \varphi_2) \\
& \text{universal quantifier} &&\quad \forall \alpha.\varphi \overset{\triangle}{=} \lnot \exists \alpha.\; \lnot \varphi \\
& \alpha \text{ is stored in } x &&\quad x \hookrightarrow \alpha \overset{\triangle}{=} x |-> \alpha * \mathbf{true} \\
& x \text{ has been allocated } &&\quad \mathtt{alloc}(x) \overset{\triangle}{=} \exists \alpha.\; x \hookrightarrow \alpha \\
& \alpha_2 \text{ is stored in } \alpha_1(x_1) && \quad \alpha(x_1) \hookrightarrow \alpha_2 \\
&&& \hspace{-0.5em}\overset{\triangle}{=}\; \exists x.\; x = \alpha_1(x_1) \land x \hookrightarrow \alpha_2.
\end{align*}
\subsection{Expressiveness of sequence-heap separation logic}
In this subsection, we list few examples to show expressiveness of SeqSL. We divide examples into 2 categories: properties on variable-length sequence in programs, and properties on multilevel data structures.
Similar to the classical separation logic, sequence-heap separation logic does not make differences between locations and values in formulae. To adjust more scenarios in practice, we use the atom $\#$ to manually separate locations and values. The sequence singleton heap can thus be written as $x |-> \alpha_l \circ \# \circ \alpha_x$, where $\alpha_l$ denotes sequence of locations, and $\alpha_x$ denotes sequence of values.
\subsubsection{Properties on variable-length sequences in programs}
we list some properties on graphs to show the expressiveness of SeqSL on describing variable-length sequences in programs. These properties include: out-degree and reachability.
\noindent\textbf{Out-degree}. The out-degree of node $x$ can be denoted as $\mathtt{Outdeg}(x)$ . The formula $\mathtt{Outdeg}(x) = n$ means the out-degree of node $x$ is $n_x$. It is defined as follows:
\begin{equation}\label{eq:out_degree}
\begin{aligned}
&\mathtt{Outdeg}(x) = n_x \\
\overset{\triangle}{=} \quad& \exists \alpha_l \exists \alpha_x.\;x \hookrightarrow \alpha_l \circ \# \circ \alpha_x \land |\alpha_l| = n_x.
\end{aligned}
\end{equation}
Note that the reserved word $\textbf{nil}$ might be in $\alpha_l$. It does not affect the truth of the definition, because $\textbf{nil}$ can be viewed as location 0. Its out-degree is 0, and in-degree is not necessarily be 0.
\noindent\textbf{Reachability}. First, we define one-step reachability $x_1 \leadsto x_2$ , which means there exists an edge from $x_1$ to $x_2$.
\begin{equation*}
x_1 \leadsto x_2 \overset{\triangle}{=} \exists \alpha_{l_1} \exists \alpha_{l_2} \exists \alpha_x.\; l_1 \hookrightarrow \alpha_{l_1} \circ l_2 \circ \alpha_{l_2} \circ \# \circ \alpha_x.
\end{equation*}
Then we define $\mathtt{reach}^n(x_1,x_2)$, which means there exists a path from $x_1$ to $x_2$. The length of the path is $n$ ($n >= 0$).
\begin{align*}
\mathtt{reach}^0(x_1,x_2) &\quad\overset{\triangle}{=}\quad x_1 = x_2 \\
\mathtt{reach}^{n+1}(x_1,x_2) &\quad\overset{\triangle}{=}\quad \exists x_3.\; x_1 \leadsto x_3 * \mathtt{reach}^{n}(x_3,x_2)
\end{align*}
Finally we define $\mathtt{reach}(x_1,x_2)$, which means there exists a path from $x_1$ to $x_2$, whose length is larger or equal than 0.
\begin{align*}
\mathtt{reach}(x_1,x_2) \overset{\triangle}{=} \exists n.\; n >= 0 \land \mathtt{reach}^{n}(x_1,x_2).
\end{align*}
Note that $\mathtt{reach}(x_1,x_2)$ defined in SeqSL is different from $\mathtt{ls}(x_1,x_2)$ defined in the separation logic fragments on shape analysis. The former can describe reachability on graphs without restrictions on out-degree of each nodes, while the latter can only describe reachability on linked lists.
\subsubsection{Properties on multilevel data structures}
we list some properties on two kinds of storage systems to show expressiveness of SeqSL on describing multilevel data structures.
Different from SeqSL, the model $\sigma = (s_x,s_\alpha, h)$ of SeqSL describing storage systems should be interpreted in disk, not in memory.
\noindent\textbf{Properties on Windows storage systems}. The structure of Windows storage systems based on trees can be expressed by SeqSL. The indices $\alpha_l$ of files are stored in the location $l$. The file $\alpha_x$ is stored in the location $l_1$.
\begin{equation}\label{eq:multi_level}
\begin{aligned}
& l \hookrightarrow \alpha_l \circ \# \circ \varepsilon \;* \\
& \forall l_1 \exists \alpha_x.\; (l_1 \overline{\in} \alpha_l => l_1 \hookrightarrow \varepsilon \circ \# \circ \alpha_{x}).
\end{aligned}
\end{equation}
Note that the sub-formula $\forall l_1 \exists \alpha_x.\; (l_1 \overline{\in} \alpha_l => l_1 \hookrightarrow \varepsilon \circ \# \circ \alpha_x)$ can not be replaced by $\forall x.\; \alpha_l(x) \hookrightarrow \varepsilon \circ \# \circ \alpha_x$. The reason is that, $\alpha_l$ is a \textit{finite} sequence. When $x$ exceeds the length of $\alpha_l$, it falsifies $\forall x.\; \alpha_l(x) \hookrightarrow \varepsilon \circ \# \circ \alpha_x$. So we have to restrict $l_1$ with $l_1 \overline{\in} \alpha_l$.
We apply $\#$ in \Cref{eq:multi_level} to describe two-tier data structures. The first tier merely stores locations $\alpha_l$, while the second tier merely stores data $\alpha_x$. These two different forms of contents prevent the location $l_1$ in the second tier from pointing to the location $l$ in the first tier.
With \Cref{eq:multi_level} in hand, we can describe properties of files. We list two of them.
A file can be found by its index $x_1$:
\begin{align*}
\exists \alpha_x.\; \alpha_l(x_1) \hookrightarrow \varepsilon \circ \# \circ \alpha_x.
\end{align*}
The content $x_1$ can be found in the file $\alpha_x$:
\begin{align*}
\exists x_2.\; x_1 = \alpha_x(x_2).
\end{align*}
In addition, we can apply $x |-> \alpha_l \circ \#^n \circ \alpha_x$ to describe n-th tier of multilevel data structure. This is useful for describing multilevel pointers in C++, multilevel paging, multilevel addressing, etc.
\noindent\textbf{Properties on block-based cloud storage systems}. SeqSL can be used to describe blocks in cloud storage systems. Generally speaking, the sequence $\alpha$ in the formula $x \hookrightarrow \alpha$ can be viewed as a block. With a relative address $l$, the content $\alpha(l)$ can be found.
For convenience, we define the predicate $\mathtt{IncIndex}(\alpha_0, n)$, which means $\alpha_0$ with length $n+1$ is strictly increasing. The first item of $\alpha$ is 1, and the last is $n + 1$.
\vspace{-1em}
\begin{align*}
\mathtt{IncIndex}(\alpha_0, n) \;\overset{\triangle}{=} \; & \mathtt{Inc}(\alpha_0) \land |\alpha_0| = n + 1 \\
& \land 1 = \alpha_0(1) \land n + 1 = \alpha_0(n+1).
\end{align*}
A big file $\alpha$ stored in location $l$ is divided into $n$ smaller blocks and is stored in disk. The indices $\alpha_l$ of the file are stored in location $l$. The function $\mathtt{Trunc}(\alpha,x_1,x_2)$ can be used to locate these blocks. The sequence variable $\alpha_0$ in the following formula represents the sequence of division points, which should make the predicate $\mathtt{IncIndex}(\alpha_l,n)$ to be true. The length of each block $\alpha_x$ can be additionally fixed to 64 by tahe formula $|\alpha_x| = 64$.
\begin{align*}
& \exists \alpha_0.\; \Bigl( \mathtt{IncIndex}(\alpha_l,n) \land l \hookrightarrow \alpha_l \circ \# \circ \varepsilon \\
& * \bigl(\forall l_1 \exists x.\; (l_1 = \alpha_l(x) \land \alpha_x == \mathtt{Trunc}(\alpha, \alpha_0(x), \alpha_0(x+1))) \\
& => l_1 \hookrightarrow \varepsilon \circ \# \circ \alpha_x \Bigr).
\end{align*}
The formula defined above can be illustrated by Fig. (\ref{fig:bcss}).
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{img/Structure_of_BCSS.png}
\caption{Structure of block-based cloud storage system}
\label{fig:bcss}
\end{figure}
\section{Decidable fragments}
In this section, we consider a decidable $\Sigma_1$ fragment of SeqSL. It contains sequence singleton heap, separating conjunction, separating implication, equality and concatenation on sequences. We present the following main result of this section.
\begin{theorem}[Decidable fragment of SeqSL\label{decidable_fragment_of_SeqSL}]\label{theorem:decidable_fragment}
The satisfiability problem of the language is decidable when it is restricted as follows:
\begin{align*}
t_x \quad::=& \quad \mathbf{nil} \mid \# \mid x \\
t_{\alpha} \quad::=& \quad \varepsilon \mid t_x \mid \alpha \mid t_{\alpha} \circ t_{\alpha} \\
\varphi \quad::=& \quad t_x = t_x \mid t_\alpha == t_\alpha \mid \mathbf{false} \mid \varphi => \varphi \mid \mathbf{emp} \\
& \quad \mid x |-> t_{\alpha} \mid \varphi * \varphi \mid \varphi -* \varphi.
\end{align*}
The model of the fragment is the same as that of SeqSL, which is defined in \Cref{def:modelSeqSL}.
\end{theorem}
We call the above fragment the $\Sigma_1$ fragment of separation logic \;(PSeqSL, where the alphabet 'P' means propositional). PSeqSL is a non-trivial fragment for the following reasons:
\begin{itemize}
\item The expressiveness of PSeqSL is stronger than that of the $\Sigma_1$ fragment of the classical separation logic proposed in \cite{reynolds2002separation}, because the former can express properties on variable-length sequences and on multilevel data structures.
\item The heap stores variable-length sequences in PSeqSL. The models of a formula in PSeqSL may have more possibilities than that of a formula in the classical separation logic.
\item Sequences and heap operations in the fragment are not independent. Their satisfiability may affect each other. For instance, to decide whether the formula $x_1 |-> \alpha_1 \land x_1 |-> \alpha_2$ is true, we need to consider both conditions on heap, and the implicit condition $\alpha_1 == \alpha_2$ on sequences. To decide whether the formula $(x_1 |-> \alpha_1 * x_2 |-> \alpha_2) \land (x_1 |-> \alpha_3 * x_2 |-> \alpha_4) \land x_1 != x_2$ is true, we need to consider the implicit condition $\alpha_1 == \alpha_3 \land \alpha_2 == \alpha_4$.
\item PSeqSL can describe some of the formulae consisting of existential quantifiers in SeqSL. The property $\mathtt{alloc}(x) \overset{\triangle}{=} \exists \alpha.\; x \hookrightarrow \alpha$ in SeqSL can be expressed in PSeqSL as:
\begin{align*}
\mathtt{alloc}(x) \overset{\triangle}{=} (x |-> \mathbf{nil}) -* \mathbf{false}.
\end{align*}
\end{itemize}
We prove \Cref{decidable_fragment_of_SeqSL} following these three steps:
\begin{enumerate}
\item prove the following problem is decidable: given the formula $\varphi$ in PSeqSL, and a part of the model $s_x, h$, decide whether there exists $s_{\alpha}$, such that $(s_x,s_{\alpha},h) |= \varphi$.
\item prove the following problem is decidable: given the formula $\varphi$ in PSeqSL, and a part of the model $s_x$, decide whether there exists $s_{\alpha},h$, such that $(s_x,s_{\alpha},h) |= \varphi$.
\item prove the following problem is decidable: given the formula $\varphi$ in PSeqSL, decide whether there exists $s_x, s_{\alpha}, h$, such that $(s_x,s_{\alpha},h) |= \varphi$. (\Cref{decidable_fragment_of_SeqSL})
\end{enumerate}
The first step is the main part of the proof. The result on the fragment without separating implications is trivial, because the finiteness of $h$ leads to finite possibilities of models satisfying the formula $\varphi$.
Similar to the paper \cite{calcagno2001computability}, we define the size of the formula $\varphi$ as $\mathtt{sz}(\varphi)$ to represent the maximum heap size for deciding whether the formula $\varphi$ is true or its negation is true.
\begin{definition}[Size of formula]
The size of the formula $\varphi$, $\mathtt{sz}(\varphi)$ can be inductively defined as follows:
\begin{table}[htbp]
\centering
\label{table1}
\tabcolsep=0.5cm
\renewcommand\arraystretch{1.2}
\normalsize
\begin{tabular}{ll}
$\mathtt{sz}(t_{x_1} = t_{x_2}) = 0$ &
$\mathtt{sz}(t_{\alpha_1} == t_{\alpha_2}) = 0$ \\
$\mathtt{sz}(\mathbf{false}) = 0$ &
$\mathtt{sz}(\mathbf{emp}) = 1$ \\
$\mathtt{sz}(x |-> t_\alpha) = 1$ &
$\mathtt{sz}(\varphi_1 -* \varphi_2) = \mathtt{sz}(\varphi_2)$ \\
\multicolumn{2}{l}{$\mathtt{sz}(\varphi_1 => \varphi_2) = \mathtt{max}(\mathtt{sz}(\varphi_1), \mathtt{sz}(\varphi_2))$} \\
\multicolumn{2}{l}{$\mathtt{sz}(\varphi_1 * \varphi_2) = \mathtt{sz}(\varphi_1) + \mathtt{sz}(\varphi_2)$.}
\end{tabular}
\end{table}
\end{definition}
We define free program variables as follows.
\begin{definition}[Free program variables in PSeqSL]
In PSeqSL, free program variables $\mathrm{FV}_{t,x}(t_x)$ in the term $t_x$ and free program variables $\mathrm{FV}_{t,x}(t_\alpha)$ in the term $t_\alpha$ can be inductively defined as follows:
\begin{table}[htbp]
\centering
\label{table1}
\tabcolsep=0.5cm
\renewcommand\arraystretch{1.2}
\small
\begin{tabular}{lll}
$\mathrm{FV}_{t,x}(\mathbf{nil}) = \{\}$ &
$\mathrm{FV}_{t,x}(\#) = \{\}$ &
$\mathrm{FV}_{t,x}(x) = \{x\}$ \\
$\mathrm{FV}_{t,x}(\alpha) = \{\}$ &
$\mathrm{FV}_{t,x}(\varepsilon) = \{\}$ &
\\
\multicolumn{3}{l}{$\mathrm{FV}_{t,x}(t_{\alpha_{x_1}} \circ t_{\alpha_{x_2}}) = \mathrm{FV}_{t,x}(t_{\alpha_{x_1}}) \cup \mathrm{FV}_{t,x}(t_{\alpha_{x_2}})$.}
\end{tabular}
\vspace{-0.5em}
\end{table}
Free program variables $\mathrm{FV}_x(\varphi)$ in the formula $\varphi$ can be inductively defined as follows:
\begin{align*}
\FV_{x}&(t_{x_1} = t_{x_2}) = \mathrm{FV}_{t,x}(t_{x_1}) \cup \mathrm{FV}_{t,x}(t_{x_2}) \\
\FV_{x}&(t_{\alpha_1} == t_{\alpha_2}) = \mathrm{FV}_{t,x}(t_{\alpha_1}) \cup \mathrm{FV}_{t,x}(t_{\alpha_2}) \\
\FV_{x}&(\mathbf{false}) = \{\} \\
\FV_{x}&(\varphi_1 => \varphi_2) = \FV_{x}(\varphi_1) \cup \FV_{x}(\varphi_2) \\
\FV_{x}&(\mathbf{emp}) = \{\} \\
\FV_{x}&(x |-> t_\alpha) = \{x\} \cup \mathrm{FV}_{t,x}(t_\alpha) \\
\FV_{x}&(\varphi_1 * \varphi_2) = \FV_{x}(\varphi_1) \cup \FV_{x}(\varphi_2) \\
\FV_{x}&(\varphi_1 -* \varphi_2) = \FV_{x}(\varphi_1) \cup \FV_{x}(\varphi_2).
\end{align*}
\end{definition}
We define the set of sequence terms to collect the terms appearing in the formula. It helps us to get a finite set of all possible heap models which may satisfy the formula.
\begin{definition}[Set of sequence terms]
The set of sequence terms $\mathtt{SeqTerms}(\varphi)$ appearing in the formula $\varphi$ can be inductively defined as:
\begin{align*}
\mathtt{SeqTerms}&(t_{l_1} = t_{l_2}) = \{t_{l_1}, t_{l_2}\} \\
\mathtt{SeqTerms}&(t_{\alpha_1} == t_{\alpha_2}) = \{t_{\alpha_1}, t_{\alpha_2}\} \\
\mathtt{SeqTerms}&(\mathbf{false}) = \{\} \\
\mathtt{SeqTerms}&(\mathbf{emp}) = \{\} \\
\mathtt{SeqTerms}&(x |-> t_\alpha) = \{x, t_\alpha\} && \\
\mathtt{SeqTerms}&(\varphi_1 => \varphi_2) = \mathtt{SeqTerms}(\varphi_1) \cup \mathtt{SeqTerms}(\varphi_2) && \\
\mathtt{SeqTerms}&(\varphi_1 * \varphi_2) = \mathtt{SeqTerms}(\varphi_1) \cup \mathtt{SeqTerms}(\varphi_2) \\ \mathtt{SeqTerms}&(\varphi_1 -* \varphi_2) = \mathtt{SeqTerms}(\varphi_1) \cup \mathtt{SeqTerms}(\varphi_2).
\end{align*}
\end{definition}
Separating implication involves universal quantifiers over heaps. The paper \cite{calcagno2001computability} presents a solution on searching all possible models of the formula in the classical $\Sigma_1$ separation logic fragment. They restrict the domain and the range of the heap $h$ to finite sets. To deal with sequences, we come up with a different restriction on the range of $h$. The range of $h$ involves the set of all sequence terms appearing in the formula, empty sequence $\varepsilon$, and a fresh sequence term whose value is different from all sequence terms in the formula. Thus, universal quantifiers over heaps can be reduced to those over finite heaps. The reduction preserves satisfiability.
We present the following lemma to show small model property on the formula $\varphi_1 -* \varphi_2$.
\begin{lemma}\label{small_model_property_of_si}
Given the model $\sigma = (s_x,s_{\alpha},h)$ and formulae $\varphi, \; \varphi_1 \text{ and } \varphi_2$ satisfying $\varphi = \varphi_1 -* \varphi_2$, the set $L = \FV_{x}(\varphi_1) \cup \FV_{x}(\varphi_2)$, the set $B$ which contains the first $\mathtt{max}(\mathtt{sz}(\varphi_1), \mathtt{sz}(\varphi_2))$ values in $\mathrm{Loc} \setminus (\mathtt{dom}(h) \cup s(L))$, the fresh sequence variable $\overline{\beta}$ satisfying $|[\overline{\beta}|]\sigma' \notin \{|[t_\alpha|]\sigma' \mid t_\alpha \in \mathtt{SeqTerms}(\alpha)\}$. We define $\sigma' = (s_x,s_{\alpha}',h)$ where $s_{\alpha}'$ contains a new assignment for $\overline{\beta}$. Let $\mathcal{D} = B \cup s(L)$, and $\mathcal{R} = \{|[t_\alpha|]\sigma' \mid t_\alpha \in \mathtt{SeqTerms}(\varphi)\} \cup \{\varepsilon, |[\overline{\beta}|]\sigma'\}$. Then, $(s_x,s_{\alpha},h) |= \varphi_1 -* \varphi_2$ holds, if and only if for all $h'$ satisfying:
\begin{itemize}
\item $\mathtt{dom}(h') \cap \mathtt{dom}(h) = \varnothing$ and $(s_x,s_{\alpha}',h') |= \varphi_1$,
\item $\mathtt{dom}(h') \subseteq \mathcal{D}$,
\item $\mathtt{rng}(h') \subseteq \mathcal{R}$,
\end{itemize}
the proposition $(s_x,s_{\alpha}',h \uplus h') |= \varphi_2$ holds, where $\mathtt{rng}(h')$ denotes the range of $h'$.
\end{lemma}
According to \Cref{small_model_property_of_si}, we define the reduction function as follows.
\begin{definition}\label{reduction_function}
The reduction function $T(s_x,h,\varphi)$ is a mapping from stack $s_x$, heap $h$, and the PSeqSL formula $\varphi$, to the formula in $\Sigma_1$ sequence predicate logic. The reduction can be inductively defined in Fig. (\ref{figeq:redfunc}),
\stripsep+2pt
\begin{figure*}[h]
\begin{align*}
T(s_x,h,t_{x_1} = t_{x_2}) &\quad\overset{\triangle}{=}\quad t_{x_1} == t_{x_2} \\
T(s_x,h,t_{\alpha_1} == t_{\alpha_2}) &\quad\overset{\triangle}{=}\quad t_{\alpha_1} == t_{\alpha_2} \\
T(s_x,h,\mathbf{false}) &\quad\overset{\triangle}{=}\quad \mathbf{false} \\
T(s_x,h,\varphi_1 => \varphi_2) &\quad\overset{\triangle}{=}\quad T(s_x,h,\varphi_1) => T(s_x,h,\varphi_2) \\
T(s_x,h,\mathbf{emp}) &\quad\overset{\triangle}{=}\quad \mathtt{dom}(h) = \varnothing \\
T(s_x,h,x|->t_\alpha) &\quad\overset{\triangle}{=}\quad \mathtt{dom}(h)=\{s_x(x)\} \land s_x(x) \notin \mathrm{Atom} \land h(s_x(x)) == t_\alpha \\
T(s_x,h,\varphi_1 * \varphi_2) &\quad\overset{\triangle}{=}\quad \bigvee_{h = h_1 \uplus h_2} (T(s_x,h_1,\varphi_1) \land T(s_x,h_2,\varphi_2)) \\
T(s_x,h,\varphi_1 -* \varphi_2) &\quad\overset{\triangle}{=}\quad \bigwedge_{
\mbox{ \tiny
$\begin{array}{c}
\mathtt{dom}(h_\varphi) \cap \mathtt{dom}(h) = \varnothing\\
\mathtt{dom}(h_\varphi) \subseteq \mathcal{D} \\
\mathtt{rng}(h_\varphi) \subseteq \mathcal{R}
\end{array}
$
}
} (T(s_x,h_\varphi,\varphi_1) => T(s_x,h_\varphi \uplus h,\varphi_2)),
\end{align*}
\captionof{figure}{The reduction function $T(s_x,h,\varphi)$}
\label{figeq:redfunc}
\end{figure*}
where $\varphi = \varphi_1 -* \varphi_2$.
\end{definition}
Given $s_x$ and $h$, the formula $T(s_x,h,\varphi_1 * \varphi_2)$ consists of finitely many terms of the form $T(s_x,h,\varphi)$, because the implicit existential quantifier in separating conjunction does not create new heaps. The formula $T(s_x,h,\varphi_1 -* \varphi_2)$ also consists of finitely many terms of the form $T(s_x,h,\varphi)$ according to \Cref{small_model_property_of_si}. Moreover, the truth values of the following three formulae $\mathtt{dom}(h) = \varnothing$, $\mathtt{dom}(h) = {s_x(x)}$, and $s_x(x) \notin \mathrm{Atom}$ can be determined, as well as the value of $h(s_x(x))$ (which is a sequence). So $T(s_x,h,\varphi)$ consists of only $t_{\alpha_1} == t_{\alpha_2}$ and its conjunctions, disjunctions and negations. It can be further reduced to a single word equation followed by \Cref{thm:Boolean comb}. PSeqSL is thus reduced to the satisfiability problem of $\Sigma_1$ sequence predicate logic. The $\Sigma_1$ fragment of sequence predicate logic is shown to be decidable in \cite{makanin1977problem}.
\begin{lemma}\label{lemma:part1}
Given stack $s_x$ and heap $h$. For all assignment $s_{\alpha}$ and formula $\varphi$, the proposition $(s_x,s_{\alpha},h) |= \varphi$ holds if and only if there exist assignments $(s_x', s_{\alpha}')$, such that $(s_x', s_{\alpha}') |= T(s_x,h,\varphi)$ holds, where $s_x'$ and $s_{\alpha}'$ are assignments of program variables and sequence variables respectively, $T(s_x,h,\varphi)$ is the reduction from PSeqSL to $\Sigma_1$ sequence predicate logic defined by \Cref{reduction_function}.
\end{lemma}
Note that after doing reductions in \Cref{reduction_function} and applying \Cref{thm:Boolean comb}, one can get a single word equation $U == V$ with constants ($k$ contents for example) and sequence variables ($k'$ variables for example). It is easy to show the following fact: there is a solution for $U == V$ if and only if there is a solution for $U == V$ on the free monoid with $k+k'$ generators, where the first $k$ generators coincide with $k$ constants, and the other $k'$ generators are fresh in $\mathbb{N}$.
To give readers some intuitions for \Cref{lemma:part1}, we list two examples below.
\begin{example}
Consider whether the formula $\varphi = (x_1 |-> \alpha_1 \circ x_3) * \big(
(x_1 |-> \alpha_1 \lor x_1 |-> \alpha_2) -*
(x_1 |-> \alpha_2 * x_2 |-> \alpha_3)
\big)$ can be satisfied, given the stack satisfying $\{(x_1,n_1),(x_2,n_2),(x_3,n_3)\} \subseteq s$ where $n_1,n_2$ and $n_3$ are distinct integer numbers and the heap $h = \{(n_1,n_1 \circ n_3), (n_2,n_2 \circ n_3)\}$. The assignment $s_{\alpha}$ is pending.
Suppose $\varphi = \varphi_1 * \varphi_2$, where $\varphi_1 = x_1 |-> \alpha_1 \circ x_3$, $\varphi_2 =
(x_1 |-> \alpha_1 \lor x_1 |-> \alpha_2) -*
(x_1 |-> \alpha_2 * x_2 |-> \alpha_3)$. We have the formula in Fig. (\ref{figeq:cons_ex1}).
\stripsep+0.5em
\begin{figure*}[h]
\begin{align*}
T(s_x,h,\varphi) \quad=\quad& \bigvee_{h = h_1 \uplus h_2}(T(s_x,h_1,\varphi_1) \land T(s_x,h_2,\varphi_2)) \\
\quad=\quad& \; \big( T(s_x,\{\},\varphi_1) \land T(s_x,\{(n_1,n_1 \circ n_3), (n_2,n_2 \circ n_3)\},\varphi_2) \big) \\
& \lor \big( T(s_x,\{(n_1,n_1 \circ n_3)\},\varphi_1) \land T(s_x,\{(n_2,n_2 \circ n_3)\},\varphi_2) \big) \\
& \lor \big( T(s_x,\{(n_2,n_2 \circ n_3)\},\varphi_1) \land T(s_x,\{(n_1,n_1 \circ n_3)\},\varphi_2) \big) \\
& \lor \big( T(s_x,\{(n_1,n_1 \circ n_3),(n_2,n_2 \circ n_3)\},\varphi_1) \land T(s_x,\{\},\varphi_2) \big) \\
\quad=\quad& \; T(s_x,\{(n_1,n_1 \circ n_3)\},\varphi_1) \land T(s_x,\{(n_2,n_2 \circ n_3)\},\varphi_2).
\end{align*}
\caption{Construction in Example 1}
\label{figeq:cons_ex1}
\end{figure*}
Suppose $\varphi_2 = \varphi_{21} -* \varphi_{22}$, where $\varphi_{21} = x_1 |-> \alpha_1 \lor x_1 |-> \alpha_2$, and $\varphi_{22} = x_1 |-> \alpha_2 * x_2 |-> \alpha_3$. We have:
\vspace{-1em}
\begin{equation*}
\begin{aligned}
& T(s_x,\{(n_2,n_2 \circ n_3)\},\varphi_2) \\
=\quad &\bigwedge_{
\mbox{ \tiny
$\begin{array}{c}
\mathtt{dom}(h_{\varphi_2}) \cap \{n_2\} = \varnothing\\
\mathtt{dom}(h_{\varphi_2}) \subseteq \mathcal{D} \\
\mathtt{rng}(h_{\varphi_2}) \subseteq \mathcal{R}
\end{array}
$
}
} \bigl(T(s_x,h_{\varphi_2},\varphi_{21}) \\
& => T(s_x,h_{\varphi_2} \uplus \{(n_2,n_2 \circ n_3)\},\varphi_{22})\bigr),
\end{aligned}
\vspace{-1em}
\end{equation*}
where
\vspace{-0.5em}
\begin{equation*}
\begin{aligned}
\mathcal{D} &= B \;\cup\; \{n_1,n_2,n_3\}, \quad B = \{m_1,m_2,m_3\}, \\
\mathcal{R} &= \{|[\alpha_1 \circ x_3|]\sigma', |[\alpha_1|]\sigma',|[\alpha_2|]\sigma', |[\alpha_3|]\sigma'\} \cup \{\varepsilon, |[\overline{\beta}|]\sigma'\},
\end{aligned}
\vspace{-1em}
\end{equation*}
and $m_1,m_2,m_3$ are the first three values in $\mathrm{Loc} \setminus (\mathtt{dom}(h) \cup s(L))$, the term $\overline{\beta}$ satisfies:
\begin{equation*}
\begin{aligned}
|[\overline{\beta}|]\sigma' \notin \{|[\alpha_1 \circ x_3|]\sigma', |[\alpha_1|]\sigma',|[\alpha_2|]\sigma', |[\alpha_3|]\sigma'\}.
\end{aligned}
\end{equation*}
The domain $\mathtt{dom}(h_{\varphi_2})$ consists of many finite possibilities. However, there are only two possibilities $h_{\varphi_2} = \{(n_1,s_{\alpha}'(\alpha_1))\}$ and $h_{\varphi_2} = \{(n_1,s_{\alpha}'(\alpha_2))\}$ which may satisfy the formula. So,
\begin{equation*}
\begin{aligned}
& T(s_x,\{(n_2,n_2 \circ n_3)\},\varphi_2) \\
=\quad& \; (T(s_x,\{(n_1,s_{\alpha}'(\alpha_1)\},\varphi_{21}) \\
& => T(s_x,\{(n_1,s_{\alpha}'(\alpha_1)), (n_2,n_2 \circ n_3)\},\varphi_{22})) \\
& \land (T(s_x,\{(n_1,n_2 \circ n_3)\},\varphi_{21}) \\
& => T(s_x,\{(n_1,n_2 \circ n_3), (n_2,n_2 \circ n_3)\},\varphi_{22})) \\
=\quad& \; T(s_x,\{(n_1,s_{\alpha}'(\alpha_1)), (n_2,n_2 \circ n_3)\},\varphi_{22}) \\
& \land T(s_x,\{(n_1,n_2 \circ n_3), (n_2,n_2 \circ n_3)\},\varphi_{22}).
\end{aligned}
\end{equation*}
Similarly, we discuss possibilities of models satisfying the formula $\varphi_{22}$. Then we have:
\begin{align*}
&T(s_x,\{(n_1,s_{\alpha}'(\alpha_1)), (n_2,n_2 \circ n_3)\},\varphi_{22}) \\
=\quad& \alpha_1 == \alpha_2 \land n_2 \circ n_3 == \alpha_3,\\
&T(s_x,\{(n_1,n_2 \circ n_3), (n_2,n_2 \circ n_3)\},\varphi_{22}) \\
= \quad& \alpha_2 == \alpha_2 \land n_2 \circ n_3 == \alpha_3.
\end{align*}
So,
\begin{align*}
&T(s_x,h,\varphi) \\
=\quad& (n_1 \circ n_3 == \alpha_1 \circ n_3) \land (\alpha_1 == \alpha_2 \land n_2 \circ n_3 == \alpha_3) \\
& \land (\alpha_2 == \alpha_2 \land n_2 \circ n_3 == \alpha_3).
\end{align*}
We observe that $T(s_x,h,\varphi)$ can be satisfied. Hence given $s_x,h$, there exists $s_{\alpha}$ such that $(s_x,s_{\alpha},h) |= \varphi$ holds.
\end{example}
\begin{example}
Consider whether the formula $\varphi = x_1 |-> \alpha_1 \circ x_3 \land \big(
(x_2 |-> \alpha_1 \lor x_2 |-> \alpha_2) -*
(x_1 |-> \alpha_1 * x_2 |-> \alpha_3)
\big)$ can be satisfied, given $s = \{(x_1,n_1), (x_2,n_2), (x_3,n_3)\}, h = \{(x_1,n_1 \circ n_3)\}$.
Following definition Definition 4.4, we have:
\begin{align*}
&T(s_x,h,\varphi) \\
=\quad& n_1 \circ n_3 == \alpha_1 \circ n_3 \land \big(
(\alpha_1 == \alpha_3 \land \alpha_1 == n_1 \circ n_3) \\
& \land (\alpha_2 == \alpha_3 \land \alpha_1 == n_1 \circ n_3)
\big).
\end{align*}
We observe that $T(s_x,h,\varphi)$ cannot be satisified. Hence given $s_x,h$, there does not exist $s_{\alpha}$ such that $(s_x,s_{\alpha},h) |= \varphi$ holds. We omit the details here.
\end{example}
For the second step of the proof, heap $h$ is not given beforehand. The satisfiability problem of the formula in PSeqSL can be reduced to the problem in the first step by the following lemma.
\begin{lemma}\label{cor:sat}
Given stack $s_x$ and the PSeqSL formula $\varphi$, the following problem is decidable: whether there exists $s_{\alpha}$ and $h$ such that $(s_x,s_{\alpha},h) |= \varphi$.
\end{lemma}
The above problem is equivalent to the following problem: given $s_x$, whether there exists $s_{\alpha}$ such that $(s_x,s_{\alpha},\{\}) |= \varphi \mathrel{\sepimp \mkern-15mu^{\lnot}} \mathbf{true}$ holds. Thus we can conclude \Cref{cor:sat}.
For the third step, stack $s_x$ is not given. Similar to the paper\cite{calcagno2001computability}, we need to figure out a finite range of $s_x$, such that the formula is true on the range if and only if the formula is true on infinite range of $s_x$.
\begin{definition}
Given two models $(s_x,s_{\alpha},h), (s_x',s_{\alpha}',h')$, the set $P \subseteq \mathrm{PVar}$, and the set $S \subseteq \mathrm{SVar}$. The relation $(s_x,s_{\alpha},h) \approx_P (s_x',s_{\alpha}',h')$ holds, if and only if there exists an isomorphism $r:\; (\mathrm{Loc}^*, \circ) -> (\mathrm{Loc}^*, \circ)$, such that the following conditions are satisfied:
\begin{itemize}
\item for each $\alpha_1,\alpha_2 \in S$, we have $r(s_{\alpha}(\alpha_1) \circ s_{\alpha}(\alpha_2)) = r(s_{\alpha}(\alpha_1)) \circ r(s_{\alpha}(\alpha_2))$,
\item $r(\mathbf{nil}) = \mathbf{nil}$, $r(\#) = \#$, and for each $x \in P$, we have $r(s_x(x)) = s_x'(x)$,
\item for each $x \in P$, we have $r(h(x)) = h'(r(x))$,
\item for each $\alpha \in S $, we have $r(s_{\alpha}(\alpha)) = s_{\alpha}'(\alpha)$.
\end{itemize}
\end{definition}
\begin{proposition}
Given two models $(s_x,s_{\alpha},h), (s_x',s_{\alpha}',h')$, and the formula $\varphi$ satisfying $(s_x,s_{\alpha},h) \approx_{\FV_{x}(\varphi)} (s_x',s_{\alpha}',h')$. If $(s_x,s_{\alpha},h) |= \varphi$, then $(s_x',s_{\alpha}',h') |= \varphi$.
\end{proposition}
\begin{lemma}\label{lemma:part3}
Given the model $(s_x,s_{\alpha},h)$ and the formula $\varphi$. Let $B$ be the first $|\FV_{x}(\varphi)|$ locations in $\mathrm{Loc}$. There exists $(s_x',s_{\alpha}',h')$ such that $s_x'(\mathrm{PVar} \setminus \FV_{x}(\varphi)) \subseteq \{\mathbf{nil},\#\}, s_x'(\FV_{x}(\varphi)) \subseteq B \cup \{\mathbf{nil},\#\}$, and $(s_x,s_{\alpha},h) \approx_{\FV_{x}(\varphi)} (s_x',s_{\alpha}',h')$.
\end{lemma}
With \Cref{lemma:part1,cor:sat,lemma:part3}, we can conclude that the satisfiability problem of PSeqSL is decidable, that is \Cref{theorem:decidable_fragment} holds.
As we know, the truth of $\Sigma_1$ fragment of sequence predicate logic is decidable\cite{makanin1977problem}. As the fragment consists of negations without any restrictions, there is a one-to-one mapping from instances in $\Sigma_1$ fragment of sequence predicate logic and those in $\Pi_1$ fragment of sequence predicate logic. Thus we have \Cref{cor:seq}.
\begin{corollary}\label{cor:seq}
The theory of $\Pi_1$ fragment of sequence predicate logic is decidable.
\end{corollary}
The proof of \Cref{theorem:decidable_fragment} shows that PSeqSL has small model property. The satisfiability of a formula in PseqSL can be reduced to that of the formula with finite length in $\Sigma_1$ fragment sequence logic. According to small model property of PSeqSL and \Cref{cor:seq}, we have \Cref{cor:p1_frag}.
\begin{corollary}\label{cor:p1_frag}
The satisfiability and validity problem of $\Pi_1$ fragment of PSeqSL is decidable, where $\Pi_1$ fragment of PSeqSL is of the form $\forall^*\forall^*.\varphi$, and $\varphi$ is quantifier-free.
\end{corollary}
\section{Undecidable fragments}
In this section, we mainly focus on an undecidable fragment of the form
$(\forall^*\forall^*\cap \forall^*\exists^*\exists^*)\text{SeqSL}(*)$. It is the conjunction of formula in $(\forall^* \forall^*)\text{SeqSL}(*)$ and formula $(\forall^*\exists^*\exists^*)\text{SeqSL}(*)$, where $\exists^*$ denotes there are 0 or more existential quantifiers over sequence variables, and $\exists^*$ denotes there are 0 or more existential quantifiers over program variables. The meaning of $\forall_\alpha^*$ and $\forall_\alpha^*$ are similar. We present the following main result of this section.
\begin{theorem}[Undecidable fragment of SeqSL]\label{thm:und}
The satisfiability problem of the language is undecidable when it is restricted as follows:
\begin{align*}
t_x \quad::=\quad& \mathbf{nil} \mid \# \mid x \\
t_\alpha \quad::=\quad& \varepsilon \mid t_x \mid \alpha \mid t_\alpha \circ t_\alpha \\
\psi \quad::=\quad& t_x = t_x \mid t_\alpha == t_\alpha \mid x \hookrightarrow t_\alpha \mid \mathbf{false} \mid \psi => \psi \\
& \mid \mathbf{emp} \mid \psi * \psi \\
\varphi \quad::=\quad& \forall^* \forall^*. \psi \land \forall^*\exists^*\exists^*. \psi,
\end{align*}
where $\varphi$ is a sentence.
The model of the fragment is defined in \Cref{def:modelSeqSL}.
\end{theorem}
We reduce the problem from halting problem of two-counter Minsky machine. Before getting into details of the reduction, we recall the definition of two-counter Minsky machine.
\begin{definition}[Two-counter Minsky machine]\label{def_Minsky}
Let $M$ be a Minsky machine with $n >= 1$ instructions. The machine $M$ has two counters $C_1$ and $C_2$. The instructions are defined as follows:
\begin{enumerate}[]
\item $I:\; C_j := C_j + 1;$ goto $k$,
\item $I:$ if $C_j = 0$, then goto $k_1$, else ($C_j := C_j - 1$; goto $k_2$),
\item $n:$ halt,
\end{enumerate}
where $j \in [1,2],\; I \in [1, n-1],$ and $k,k_1,k_2 \in [1, n]$. Machine $M$ halts if there is a run of the form
\begin{align*}
(I_0, c_0^1, c_0^2),\; (I_1, c_1^1, c_1^2),\dots, (I_m, c_m^1, c_m^2),
\end{align*}
such that $(I_i, c_i^1, c_i^2) \in [1,n] \times \mathbb{N}^2\; (i \in [1,m])$, $I_0 = 1,\; I_m = n$, and $c_0^1 = c_0^2 = 0$. The run follows the instructions defined above.
The set of instructions with type 1 (denoted by $\mathcal{I}_1$) consists of tuples $(k_0,c_j,c_j',k)$, and those with type 2 (denoted by $\mathcal{I}_2$) consists of tuples $(k_0,c_j,c_j',k_1,k_2)$, where $k_0$ denotes the current pointer, $c_j,c_j' \in [1,2]$ denote two counters ($c_j != c_j'$), and $k,k_1,k_2$ denote the next pointers.
\end{definition}
The problem of deciding whether a machine $M$ halts is known to be undecidable\cite{minsky1968computation}.
We first show the undecidable fragment defined in \Cref{thm:und} is not that easy to get. In general, decidability results of both sequence logic fragments and separation logic fragments restrict the form of undecidable fragments of SeqSL.
Decidability results in free semigroup show that, the theory of $\Sigma_2$ fragment\cite{day2018satisfiability}, the positive theory of $\Pi_2$ fragment\cite{durnev1995undecidability} and $\Sigma_3$ fragment\cite{durnev1995undecidability} of word equations are undecidable. The results in separation logic show that, the satisfiability problem of $\Sigma_3$ fragment of separation logic is undecidable. In this case, We can get \Cref{fact:trival_und_fragments}.
\begin{fact}\label{fact:trival_und_fragments}
In the fragment of SeqSL with prenex normal form, if there are 3 or more alternations of quantifiers over program variables, or 2 or more over sequence variables, then the satisfiability problems of resulting fragments are undecidable. For instance, the satisfiability problems of $(\exists^*\exists^*\forall^*)\mathrm{SeqSL}$, $(\exists^*\forall^*\exists^*)\mathrm{SeqSL}$, $(\exists^*\forall^*\forall^*\exists^*)\mathrm{SeqSL}$ are undecidable.
\end{fact}
In order to get a non-trivial undecidable fragment of SeqSL with negations, we have to restrict the alternations of quantifiers over program variables to be less than 3, and those over sequence variables to be less than 2.
To prove \Cref{thm:und}, we first discuss the encoding of the reduction. The general structure is sapling, which is shown in Fig. (\ref{fig:sapling}).
\begin{figure}[h]
\centering
\includegraphics[width=0.45\textwidth]{img/Structure_of_sapling.png}
\captionof{figure}{Structure of sapling}
\label{fig:sapling}
\end{figure}
We consider the encoding for sapling. Sapling is a fishbone-like structure with 'bones' going in opposite directions. Sapling consists of a master branch and several slave branches attached to nodes in the master branch. The depth of each slave branch is 1, and the end points of them does not point to any nodes in master branch. Similar to the encoding for the list $x \overset{\circlearrowleft}{\longrightarrow}^+ y$ defined in \cite{brochenin2012almighty} and fishbone heap defined in \cite{demri2015two}, we encode the sapling in the following ways:
\begin{enumerate}
\item There are smaller or equal than 1 predecessor of each node. It is denoted by the formula $\varPsi_1$,
\item There is no predecessor on the first master node. It is denoted by the formula $\varPsi_2$,
\item The first master node is allocated, and the last node does not point to the next master node. It is denoted by the formula $\varPsi_3$ (it is not necessary to make the predecessor of the last node to be 1),
\item For each node except for the last node, there is another allocated node which follows the node. It is denoted by the formula $\varPsi_4$.
\end{enumerate}
The sapling from node $x_0$ to node $x_0'$ (assume here that $x_0 != x_0'$) can be expressed by
\begin{align}\label{eq:sap}
\mathtt{sapling}(x_0,x_0') &\overset{\triangle}{=} \varPsi_1 \land \varPsi_2 \land \varPsi_3 \land \varPsi_4.
\end{align}
where $\varPsi_1, \varPsi_2, \varPsi_3$, and $\varPsi_4$ are defined in Fig. (\ref{figeq:cons_ex1}).
\stripsep+0.5em
\begin{figure*}[h]
\begin{equation*}
\begin{aligned}
\varPsi_1 &\quad\overset{\triangle}{=}\quad \forall x_1\forall x_2\forall x_3\forall x_4 \forall \alpha_1\forall \alpha_2.\; (x_1 \hookrightarrow x_3 \circ \alpha_1 * x_2 \hookrightarrow x_4 \circ \alpha_2 => x_3 != x_4) \\
\varPsi_2 &\quad\overset{\triangle}{=}\quad \forall x_1\forall \alpha.\; \lnot (x_1 \hookrightarrow x_0 \circ \alpha) \\
\varPsi_3 &\quad\overset{\triangle}{=}\quad (\exists x_1.\; x_0 \hookrightarrow x_1 \circ \varepsilon) \land (\exists \alpha.\; x_0' \hookrightarrow \varepsilon \circ \alpha) \\
\varPsi_4 &\quad\overset{\triangle}{=}\quad \forall x_1\forall x_2\exists x_3\exists \alpha_1\exists \alpha_2.\; \bigl((x_1 \hookrightarrow x_2 \circ \alpha_1 \land x_2 != x_0') => x_2 \hookrightarrow x_3 \circ \alpha_2\bigr).
\end{aligned}
\end{equation*}
\caption{Definition of $\varPsi_1, \varPsi_2, \varPsi_3$, and $\varPsi_4$}
\label{key}
\end{figure*}
It can be easily shown that the predicate $\mathtt{sapling}(x_0,x_0')$ is of the form $(\forall^* \forall^* \cap \forall^* \exists^* \exists^*)\varPsi$.
Note that the encoding in \Cref{eq:sap} is just a general idea. It does not prevent contents in slave nodes from pointing to other nodes. However, this does not have impacts on the main result, because these contents only consist of $\mathbf{nil}$ which will be shown in \Cref{formula_und_1}.
Note also that the predicate $\mathtt{Sapling}$ not only encodes the graph consisting of only one sapling, but also graphs consisting of both one sapling and circles. It is not necessary to remove all these circles, because it does not have impacts on correctness of the reduction. It is shown in \Cref{lemma:sap}.
\begin{lemma}\label{lemma:sap}
Given the predicate $\mathtt{sapling}(x_0,x_0')$ defined in \Cref{eq:sap}, it can be satisfied by a model $\sigma$ if and only if there exists a model $\sigma'$ that satisfies $\mathtt{sapling}(x_0,x_0')$, and there are no circles in $\sigma'$.
\end{lemma}
The proof of \Cref{lemma:sap} can be found in Appendix. Now we prove \Cref{thm:und}.
\begin{proof}[of \Cref{thm:und}]
We go into details of the reduction, which is shown in Fig. (\ref{fig:reduction}).
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{img/Structure_of_reduction.png}
\caption{Structure of reduction}
\label{fig:reduction}
\end{figure}
The master branch is the longest path from the beginning master node to the end master node. Each master node points to 0 or more slave nodes $\mathbf{nil}^*$. The master nodes have the period of 4. Each period represents a state of the run. In the $i$-th period ($1 <= i <= m$), the first master node represents a deliminator which separates each state of the run. There is no slave node attached to it. The second to the fourth master nodes represent the $i$-th triple $(I,C_1,C_2)$ satisfying $I = k_i,\; C_1 = c_i^1 +1, \text{ and } C_2 = c_i^2 + 1$. The slave nodes pointed from these 3 nodes are $\mathbf{nil}^{k_i},\; \mathbf{nil}^{c_i^1 + 1}, \text{ and } \mathbf{nil}^{c_i^2 + 1}$ respectively. The first period represents the initial state, while the last represents the final state.
We observe that the values of two counters in the sapling are greater than the real values of the counters in the run by 1. It is because we need to distinguish these nodes from the first node of each period, to which there is no slave nodes attached.
In general, The reduction formula consists of the following three parts.
\begin{enumerate}
\item Construct the basic structure of sapling, which is denoted by the formula $\varPhi_1 = \forall^*\forall^*.\varPhi_1'$.
\item Initialize the initial and the final state, which is denoted by the formula $\varPhi_2 = \exists^*\exists^*.\varPhi_2'$.
\item Encode the transition from one state to the other following the current instruction, which is denoted by the formula $\varPhi_3 = \forall^*\exists^*\exists^*.\varPhi_3'$.
\end{enumerate}
The formula is of the form
\begin{equation}\label{formula_und_1}
\begin{aligned}
\varPhi \quad=\quad& \varPhi_1 \land \varPhi_2 \land \varPhi_3 \\
\quad=\quad& \forall^*\forall^*.\varPhi_1' \land \exists^*\exists^*.\varPhi_2' \land \forall^*\exists^*\exists^*.\varPhi_3',
\end{aligned}
\end{equation}
or
\begin{align*}
\varPhi \quad=\quad \forall^*\forall^*.\varPhi_1' \land \forall^*\exists^*\exists^*.(\varPhi_2' \land \varPhi_3').
\end{align*}
The detailed construction can be found in Appendix.
For each two-counter Minsky machine M, let $\varPhi$ be the formula of the form defined in \Cref{formula_und_1}. If the machine M halts, then there is a finite run. It can be easily shown that there is a finite sapling from the first period encoding the first state to the final one encoding the final state, and each state except for the final state can be transformed to the next state by the corresponding instruction.
For the other side of the proof, we suppose that the formula $\varPhi$ of the form defined in \Cref{formula_und_1} is satisfied. The model $\sigma$ of $\varPhi$ may consist of circles. We can get a model $\sigma'$ satisfying $\varPhi$ in which there is no circles according to \Cref{lemma:sap}.
\end{proof}
\section{Conclusion}
In this paper, we propose sequence-heap separation logic which combines sequence predicate logic and separation logic. It is capable of describing the following properties which sequence predicate logic or separation logic alone cannot describe or cannot easily describe.
\begin{itemize}
\item sequence operations in programs, such as list reversal, and lookups.
\item properties corresponding to variable-length sequences in programs, such as stack, queue, and graphs with unbounded out-degree.
\item multilevel data structures in programs, such as data structure in Windows storage systems, and in block-based cloud storage systems.
\end{itemize}
Besides, we find a boundary between decidable and undecidable SeqSL fragments, which are both of the prenex normal form. We prove the following two decidable results: the satisfiability problem of $\Sigma_1$ fragment and $\Pi_1$ fragment is decidable, and that of $(\forall^*\forall^*\cap \forall^*\exists^*\exists^*)\text{SeqSL}(*)$ is undecidable. As corollaries, fragments with either 3 quantifier alternations over program variables or 2 quantifier alternations over sequence variables are undecidable.
We will do the following work in the future.
\begin{itemize}
\item Find other boundaries between decidable and undecidable fragments of sequence-heap separation logic, such as boundaries on numbers of quantified variables, and on inductive predicates.
\item Investigate deeply on expressiveness of sequence-heap separation logic.
\item Construct a proof system for sequence-heap separation logic.
\item Implement formal verification tools for sequence-heap separation logic fragments.
\end{itemize}
\bibliographystyle{IEEEtran}
| {'timestamp': '2023-01-18T02:16:30', 'yymm': '2301', 'arxiv_id': '2301.06237', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06237'} | arxiv |
\section{Introduction}
\label{sec:1}
In the past few years, it has become increasingly important to be able to solve problems with a very large number of training samples and predictors.
Typically, such big datasets cannot be stored or analyzed on a single machine.
Distributed frameworks are widely used when dealing with big datasets spread over multiple machines \cite{bekkerman2011scaling,bertsekas2015parallel}.
One of the simplest and most popular approaches in this framework is ``divide-and-conquer", which is also known as ``split-and-merge" or a ``one-shot" approach;
see for example the early work by \cite{mcdonald2009efficient,zinkevich2010parallelized,zhang2012communication}.
Most of these approaches use only one round of communication.
Each local machine estimates the unknown parameter, using its subset of the training data, and communicates the estimator to a central machine which merges the local estimators to obtain a global estimator.
In our paper, we focus on a sparse regression setting where only a few of the measured predictors affect the response.
The goal in this setup is usually two-fold: (i) select the relevant predictors, and model the response by using the estimated sparsity, (ii) provide uncertainties or conduct hypothesis testing for the selected regression parameters, and all this while, respect the distributed nature of data.
Substantial progress has been made on the first goal for useful classes of sparse problems.
For example, \citet{lee2015communication} average locally computed, debiased LASSO estimators, and show that the averaged estimator achieves the same estimation rate as the full-sample LASSO, as long as the number of machines is not too large;
\citet{chen2014split} prove that the models aggregated via majority voting, based on variables selected by local machines, are consistent under some conditions.
We, however, note that the distributed literature lacks formal tools to conduct inference in selected models.
Few options allow us to test hypotheses in a distributed fashion, e.g., see recent work by \citet{battey2018distributed}.
But, these options are limited to models that are fixed before the selection of relevant predictors, and do not offer inference in models that are formed only after selection with distributed data.
As a result, we note that the communication cost in prior work scales with the number of predictors, which can be prohibitive if the number of possible predictors is large.
We introduce a new procedure for selective inference with distributed data.
Selective inference is a rigorous approach that accounts for the fact that the same data, used to select models, is re-used when providing confidence intervals and p-values.
Ingenious tools in the classical regression context have been developed by \cite{benjamini2005false, berk2013valid, belloni2015uniform, lee2016exact, tian2018selective, charkhi2018asymptotic, bachoc2019valid, panigrahi2021integrative}.
In this paper, our procedure re-uses data from all machines to base approximately-valid selective inference on an asymptotic ``selective likelihood".
Having identified relevant predictors at different machines, we describe the relationship between our response and predictors through a generalized linear model (GLM).
At the same time, our procedure only requires some aggregated information from each machine to deliver inference in a GLM with selected predictors.
For this reason, the developed techniques are also applicable when datasets are distributed across different sites due to security, privacy, or ethical concerns, as encountered in the areas of differential privacy \cite{balcan2012distributed}, and federated learning \cite{mcmahan2017communication}.
More precisely, these sites can now merge aggregated information—without having to share their individual data—to infer in the selected GLM.
The communication cost of our inferential procedure is only linear in the dimension of the selected model, which is relatively smaller than the initial dimension of the problem (before selection).
Finally, our procedure can be easily adapted to address the ``p-value lottery" problem, which arises frequently with model selection on random splits of data.
The proposal serves as an efficient alternative to multi-splitting in \cite{dezeure2015high}, and multi-carving in \cite{schultheiss2021multicarving}.
Multi-carving is a more powerful version of multi-splitting, and is based on techniques that are known as carving \cite{fithian2014optimal, panigrahi2018carving}.
Closely aligned with the conceptual framework of multi-carving, our asymptotic selective likelihood uses more data than multi-spitting.
At the same time, our procedure is significantly faster than multi-carving without recourse to Markov chain Monte Carlo (MCMC) sampling.
The remaining paper is structured as follows.
We provide a slightly more technical account of our contributions after outlining the problem setup, and review related work in Section \ref{sec:2}.
In Section \ref{sec:3}, we describe our procedure for selective inference with distributed data.
In Section \ref{sec:4}, we provide an asymptotic justification for our selective likelihood in a GLM with selected predictors.
We discuss an adaptation of our procedure to solve the p-value lottery problem in Section \ref{sec:5}.
Section \ref{sec: experiments} illustrates an application of our method on simulated datasets and on a publicly available, medical dataset on intensive care unit (ICU) admissions.
We conclude the paper with a discussion in Section \ref{sec: conclusion}.
Proofs of our technical results are collected in the Appendix.
\section{Problem setup and background}
\label{sec:2}
In this section, we describe the distributed setup and introduce some background on selective inference with a single machine.
\subsection{Setup}
We consider a very popular distributed setup with $K$ local machines, all connected to a central machine.
Suppose that we observe $n$ i.i.d. observations
$$(y_i, x_{i,1}, \ldots, x_{i,p}),\ i\in \{1,2,\ldots,n\}=[n] .$$
Let
$$\left\{\calC^{(k)} \subset [n]: k\in [K]\right\}$$
denote disjoint index sets for $K$ subsamples that have been drawn independently of data, and let $|\calC^{(k)}|=n_k$ be the cardinality of $\calC^{(k)}$ for each $k$.
In the matrix form, $Y^{(k)}$ represents a response vector with
$\left\{y_i: i \in \calC^{(k)}\right\}$
as its $n_k$ entries.
Similarly, $X^{(k)}$ represents a predictor matrix with
$\left\{(x_{i,1}, \ldots, x_{i,p}): i \in \calC^{(k)}\right\}$
in its $n_k$ rows. Let $D^{(k)}=\left(Y^{(k)},X^{(k)}\right)$.
We let
$$\rho_k = \dfrac{n_k}{n}$$
be the proportion of samples processed by local machine $k$, and let
$$n_0 = n- \underset{k\in [K]}{\sum} n_k,\quad \rho_0=\dfrac{n_0}{n} .$$
In our setup, $\calC^{(0)}$ denotes the index set of observations that were not allocated to any of the local machines; we call the corresponding data $D^{(0)}$.
We assume that the $n_0$ observations in $\calC^{(0)}$ can be accessed by the central machine at any given point of time.
Suppose that the $K$ local machines solve (in parallel) a generalized linear regression with the LASSO penalty.
The loss function in our problem is derived from the log-likelihood of a distribution in the exponential family
$$
f(y_i\mid \theta)= \exp\left( \frac{y_i \theta - A(\theta)}{\sigma^2}\right)\cdot c(y_i;\sigma),
$$
where the canonical mean parameter $\theta$ is linked to the $p$ predictors as
$$\theta= x_i\tran\beta,$$
and $\sigma^2$ is the dispersion parameter.
We assume that $\sigma$ is either known, or can be consistently estimated using our data.
The loss function, for machine $k$, is given by
\begin{align*}
\ell^{(k)}(\beta; D^{(k)}) = \frac{1}{\sqrt{n}\rho_k} \sum_{i\in\calC^{(k)}} \left\{A(x_i\tran\beta)-y_ix_i\tran\beta \right\}.
\end{align*}
Let $\Lambda^{(k)} = \text{diag}\left(\lambda^{(k)}_1, \ldots, \lambda^{(k)}_p\right)$ be a diagonal matrix with the tuning parameters
$$\left\{\lambda^{(k)}_j \in \R^{+} \text{ for } j\in [p]\right\}$$
in its diagonal entries.
Machine $k$ solves
\begin{equation}
\underset{\beta \in \R^p}{\text{minimize}} \; \ell^{(k)}(\beta; D^{(k)})+ \|\Lambda^{(k)}\beta\|_1.
\label{GL:regression}
\end{equation}
To simplify notations, we let $\Lambda^{(k)}= \Lambda$ for all $k\in [K]$.
But, our procedure works when $\Lambda^{(k)}$ are not the same across machines.
Denote by $\widehat\beta^{\Lambda,(k)}$ the LASSO estimator, i.e. the solution of problem~\eqref{GL:regression}, and
denote by
$$\widehat{E}^{(k)}=\left\{j\in [p]: \widehat\beta^{\Lambda,(k)}_j\neq 0\right\}$$
the indices of the selected predictors.
We use the symbol $E^{(k)}$ to denote the value of $\widehat{E}^{(k)}$ which we observe for our specific data $D^{(k)}$.
Fix $|E^{(k)}|=d^{(k)}$.
\subsection{Problem}
As described above, the $K$ local machines return as output the set $\{E^{(k)},k\in[K]\}$, which are communicated to the central machine.
The central machine aggregates the selected sets of predictors as
\begin{equation}
\label{aggregate}
\widehat{E}=\texttt{Aggregate}\left(\left\{\widehat{E}^{(k)}, k\in [K]\right\}\right).
\end{equation}
Suppose, a local machine $k'$ (or its output) was discarded while forming the aggregated set $\widehat{E}$.
Our setup allows us to simply combine the data $D^{(k')}$ with $D^{(0)}$ in this situation, and proceed with our prescription.
For now, we focus on aggregation rules that satisfy
$\widehat{E} \supseteq \widehat{E}_k$ for $k \in [K]$.
As a concrete example, we may consider
$$\widehat{E}=\underset{k\in [K]}{\bigcup} \widehat{E}^{(k)}.$$
Consistent with our notations, we let $E$ be the observed value of $\widehat{E}$, and let $|E|=d$.
The central machine models our real-valued response as a generalized linear model (GLM) with the following density
\begin{equation}
f(y\mid x_{E},\beta_E) = \exp\left( \frac{y x_{E}\tran\beta_E - A(x_{E}\tran\beta_E)}{\sigma^2}\right)\cdot c(y;\sigma).
\label{sel:model}
\end{equation}
Here, for a vector $x$ and $E\subset[p]$, $x_E$ denotes the subvector of $x$ with indices in $E$. Similarly, for a matrix $X$, $X_E$ consists of the columns of $X$ with indices in $E$.
Equivalently, we may summarize the modeling workflow as follows.
Having selected a subset of important predictors, each local machine communicates a base GLM to the central machine.
The central machine combines these base models, through $E$, to form the selected generalized linear model (GLM) in \eqref{sel:model}.
Some key questions arise when we seek inference in the selected GLM.
\begin{enumerate}
\item Can the central machine re-use data from the local machines to deliver selective inference?
Of course, na\"{i}ve inference, which uses all the data without adjusting for selection bias in the selected GLM, fails to have coverage guarantees, as illustrated on one of our simulated instances in Figure~\ref{fig: naive}\footnote{See Section~\ref{sec: experiments} for details of this simulation.}.
\item Selective inference must respect the distributed nature of data, as done at the time of selection.
What information does the central machine seek from the local machines for selective inference?
How many exchanges of communication does it take to compute selective inference with distributed data?
\end{enumerate}
\begin{figure}
\centering
\includegraphics[width=.5\textwidth]{naive_K_3_n0_1000_n1_4000_p_100_s_5_signal_0.1_ntune_1000}
\caption{Coverage probabilities of ``Dist-SI" (our procedure), ``Splitting", and ``Na\"{i}ve" methods for a Gaussian linear model, with $2$ local machines and a central machine. The $2$ local machines and the central machine each have $1000$ samples. The pre-specified level of coverage is $0.9$ which is indicated by the dotted horizontal line at $0.9$.}
\label{fig: naive}
\end{figure}
\subsection{Background}
We provide some background in a rather simple setup with $K=1$, and consider the special case of a linear model.
Machine $1$ solves the standard Gaussian regression with a LASSO penalty
\begin{equation}
\underset{\beta \in \mathbb{R}^p}{\text{minimize}} \; \frac{1}{\sqrt{n}\rho_1} \sum_{i\in\calC^{(1)}} \frac{1}{2}(y_i - x_i\tran\beta)^2 + \lambda \|\beta\|_1,
\label{Lasso:subsample}
\end{equation}
on a subsample of the full dataset, $D^{(1)}$.
After observing $\widehat{E}=E$, each observation in our response vector is modeled independently as
\begin{equation*}
y\mid x_E, \beta_E \sim \mathcal{N}( x_E\tran \beta_E, \sigma^2).
\end{equation*}
Note, this linear model is equivalent to fixing
$$A(x_E\tran \beta_E)= \frac{1}{2} (x_E\tran \beta_E)^2, \; c(y;\sigma)= -\frac{1}{2\sigma^2} y^2$$
in \eqref{sel:model}.
Can we re-use data from machine $1$, and combine it with $D^{(0)}$ to base inference in the selected linear model?
Recent work in selective inference solves an asymptotically related problem by forming a ``selective likelihood", which we review very briefly below.
First, we note that the Gaussian regression in \eqref{Lasso:subsample} can be re-written as
\begin{equation}
\underset{\beta \in \mathbb{R}^p}{\text{minimize}} \; \frac{1}{\sqrt{n}} \sum_{i\in [n]} \frac{1}{2}(y_i - x_i\tran\beta)^2+ \lambda \|\beta\|_1-\sqrt{n}\omega_n\tran\beta,
\label{randomized:Lasso}
\end{equation}
where
\begin{align*}
\omega_n = \frac{1}{n_k} \sum_{i\in\calC^{(1)}} \frac{1}{2}x_i(y_i - x_i\tran \widehat\beta^{\lambda,(1)})-\frac{1}{n} \sum_{i\in [n]} \frac{1}{2}x_i(y_i - x_i\tran \widehat\beta^{\lambda,(1)}).
\label{equ: def omega}
\end{align*}
Regression of the form \eqref{randomized:Lasso}, with an added randomization variable $\omega_n$, is called the randomized LASSO in \cite{harris2016selective}, and is motivated by the randomized-response approach in \cite{tian2018selective}.
\citet{panigrahi2021integrative} show that
$$\sqrt{n}\omega_n \convdis \mathcal{N}(0_p, \Sigma_\Omega)$$ where
$\Sigma_\Omega= \dfrac{\rho_0 \sigma^2}{\rho_1}\mathbb{E}[x_i x_i\tran],$
and $\omega_n$ is independent of other data variables involved during selection.
By casting selection into the randomized framework, a selective likelihood can be obtained by conditioning the usual likelihood on a subset of the selection event
$$\left\{\widehat{E}=E\right\}.$$
In principle, conditioning on the above event or a subset of the same event yields us valid selective inference, and simultaneously permits us to re-use data from the selection steps.
Suppose now, the $n$ observations in our response vector are drawn as independent Gaussian variables with the same variance, and say, we solve \eqref{randomized:Lasso} with $\omega_n \sim \mathcal{N}(0_p, \Sigma_\Omega)$.
A recent procedure by \cite{panigrahi2022approximate} uses the selective likelihood to construct inference in the selected linear model: it centers interval estimates around the maximum likelihood estimator (MLE) of the selective likelihood, and estimates its variance by using the observed Fisher information matrix.
A major obstruction to make the procedure operational is the intractability of the selective likelihood.
The afore-mentioned paper provides tractable, approximately-valid selective inference by solving a convex optimization problem, which yields a direct approximation to the selective likelihood function for Gaussian data.
Let $\widehat{\beta}^{(S)}_{E}$ and $\widehat{I}^{(S)}_{E,E}$ be the selective MLE and the observed Fisher information matrix respectively, derived from the score and curvature of the approximate likelihood.
For a prespecified value $\alpha$, (two-sided) $100\cdot(1-\alpha)\%$ confidence intervals are now given by
$$\widehat{\beta}^{(S)}_{E,j} \pm z_{1-\alpha/2}\cdot \frac{\widehat\sigma_j^{(S)}}{\sqrt{n}} \text{ for } j\in [E], $$
where $$\widehat\sigma_j^{(S)}=\sqrt{ \left(\widehat{I}^{(S)}_{E,E}\right)^{-1}_{j,j} }$$
is the estimated variance of $\sqrt{n}\widehat\beta^{(S)}_{E,j}$, the $j^{\text{th}}$ entry of $\sqrt{n}\widehat\beta^{(S)}_{E}$, and $z_{1-\alpha/2}$ is the $(1-\alpha/2)$-th quantile of a standard normal distribution.
The procedure closely resembles classical inference based on maximum likelihood, except that the standard estimators are replaced by their selective analogs.
\subsection{Contributions and other related work}
Our paper develops a new procedure to deliver approximately-valid selective inference with distributed data.
We make three main contributions.
Re-using data from machines through a conditional approach is challenging in the distributed setup.
This is because the conditional approach proceeds by deriving an explicit representation of selection which is unavailable for distributed data.
As a first contribution, we identify a simple representation for selection by developing a randomized framework in our problem.
Even with this representation, adopting the conditional approach is not immediate.
As reviewed in the preceding discussion, approximately-valid selective inference has been developed for linear Gaussian models.
Not only does our paper provide an asymptotic selective likelihood for distributed data, but also establishes consistency of the likelihood function for a large class of generalized linear regression problems.
Second, our algorithm for selective inference simply requires aggregated information from each machine.
To be precise, our procedure is based on exactly two exchanges between the central machine and local machines:
\begin{enumerate}
\item[] In exchange 1: \ the central machine sends the aggregated set of predictors, $E$, to each local machine;
\item[] In exchange 2: \ each local machine communicates back some aggregated information, in relatively low dimensions, to the central machine.
\end{enumerate}
To infer under the selected GLM in \eqref{sel:model}, the central machine solves a straightforward, convex optimization after merging information from exchange 2.
As a result, our techniques apply in situations when direct data-sharing between sites is not possible, or communication across sites is expensive.
Third, p-values computed under our asymptotic selective likelihood can be easily adapted to address the p-value lottery problem.
In this sense, our procedure is related to the multi-carving approach for improved replication \cite{schultheiss2021multicarving}, but yields us a much faster, sampling-free solution to the same problem.
We conclude this section with some more related work.
Within the distributed setting, much work has been devoted to the averaged M-estimator \cite{mcdonald2009efficient,zinkevich2010parallelized,zhang2012communication,rosenblatt2016optimality}.
\citet{rosenblatt2016optimality} show that the averaged M-estimator is first-order equivalent to the centralized M-estimator in the fixed-dimension setting; \citet{dobriban2021distributed} study the efficiency of an estimator based on weighted average in the linear regression setting, as dimensions grow with sample sizes.
Some methods have taken a likelihood-centric approach, e.g., \citet{jordan2016} propose a surrogate likelihood where higher-order derivatives in a Taylor-series expansion of the full log-likelihood are replaced by local approximations;
\citet{lin2011aggregated} propose an aggregated estimator for generalized linear models (GLM), where the locally computed MLE and Hessian of the likelihood are merged for efficiency gains.
In work by \cite{huang2005sampling,neiswanger2013asymptotically,wang2013parallelizing,scott2016bayes,minsker2017robust,srivastava2018scalable}, distributed MCMC algorithms combine local posterior samples to obtain a global posterior distribution.
In the selective inference literature, a selective likelihood was appended to priors for Bayesian inference post selection in \cite{panigrahi2018scalable, panigrahi2021integrative}.
The focus in these settings was on a category of variable selection rules that can be written as a set of polyhedral constraints on data.
For the same category of selection rules, a separate section of papers \cite{lee2016exact, hyun2018exact, le2022more} construct an exact pivot to form confidence intervals and p-values.
We, however, note that exact selective inference is only available for Gaussian models.
Moving beyond Gaussian models, \cite{taylor2018post} provide an asymptotic scheme to base selective inference on a GLM, within the usual regression context.
We take a different approach in the distributed setup by casting the problem into a randomized framework, and provide an asymptotic likelihood function for the selected GLM.
A randomized framework for selective inference has been considered for better power in \cite{harris2016selective, panigrahi2017mcmc}, for a more efficient use of data in \cite{rasines2021splitting, panigrahi2022treatment}, and for stability in \cite{zrnic2020post}.
\section{Selective inference with distributed data}
\label{sec:3}
Before proceeding further, we fix some notations.
Recall, $|E^{(k)}|=d^{(k)}$, and $|E|=d$.
Let $\bar d=\underset{k\in [K]}{\sum}d^{(k)}$.
For $k\in [K]$, the vector $\widehat{B}^{(k)}\in \R^{d^{(k)}}$ collects the nonzero components of the LASSO estimator $\widehat\beta^{\Lambda,(k)}$, and $\widehat{S}^{(k)}=\sign(\widehat{B}^{(k)})\in \R^{d^{(k)}}$ is the vector of signs for predictors that are selected by machine $k$.
As before, we will use the symbols $B^{(k)}$, $S^{(k)}$ and $Z^{(k)}$ for the observed values of $\widehat{B}^{(k)}$, $\widehat{S}^{(k)}$ and $\widehat{Z}^{(k)}$ respectively, and use
$$\gamma^{(k)}= \Lambda\begin{pmatrix} S^{(k)} \\ Z^{(k)}\end{pmatrix}$$
to denote the $\real^p$-valued subgradient of the LASSO penalty, at the solution.
Assuming that active predictors are stacked before the inactive ones in the gradient of the loss functions, we have
$$
-\nabla \ell^{(k)}(\widehat\beta^{\Lambda,(k)}; D^{(k)}) = \gamma^{(k)},
$$
and
$$\|Z^{(k)}\|_\infty \leq 1, \quad \diag(S^{(k)})B^{(k)}>0, \text{ for } k\in [K].$$
We let
$$\widehat{B} =\begin{pmatrix} \widehat{B}^{(1)} & \widehat{B}^{(2)} & \ldots & \widehat{B}^{(K)} \end{pmatrix}$$
Similarly, let the symbols $\widehat{S}$, $\widehat{Z}$ denote vectors that stack the corresponding quantities. Let $B$, $S$, and $Z$ represent their observed values.
\subsection{Communication with central machine}
We begin by describing the two exchanges of communication, between the local machines and the central machine.
In exchange 1, the central machine sends the aggregated set of predictors $E$ to every local machine.
After receiving $E$, local machine $k$ computes on $D^{(k)}$:
\begin{enumerate}
\item[(i)] the standard MLE in the selected GLM as
\begin{align*}
\widehat\beta_E^{(k)}=\underset{\beta\in\R^d}{\argmin} \frac1{\sqrt n \rho_k}\sum_{i\in\calC_k} A(x_{i,E}\tran\beta)-y_ix_{i,E}\tran\beta;
\end{align*}
\item[(ii)] the observed Fisher information (obs-FI) matrix at the MLE as
\[
\widehat\calI^{(k)}_{E,E}=\frac{1}{n_k} (X_E^{(k)})^{\intercal} \widehat{W}^k X_E^{(k)},\quad \text{where } \widehat{W}^{(k)}=\diag\left(\nabla^2 A(X^{(k)}_E \widehat\beta^{(k)}_E )\right).
\]
\end{enumerate}
Similarly, the central machine computes $\widehat\beta_E^{(0)}$ and $\widehat\calI^{(0)}_{E,E}$, using $D^{(0)}$.
In exchange 2, each local machine passes on these two quantities, $\widehat\beta_E^{(k)}$ and $\widehat\calI^{(k)}_{E,E}$, to the central machine.
Suppose, $E$ were a fixed subset of predictors with no dependence on data.
It is well known in this situation that aggregating the standard MLE and observed Fisher information from each local machine delivers asymptotically valid inference; e.g., see the work by \cite{lin2011aggregated}.
Because the choice of model is data-dependent, each machine must now return some extra information, aside from returning the usual estimators.
Specifically, our procedure requires a part of the subgradient vector $\gamma^{(k)}$ after solving \eqref{GL:regression}, that is,
\begin{enumerate}
\item[] local machine $k$ sends $\gamma^{(k)}_{E}$ to the central machine, alongside the standard MLE and corresponding obs-FI matrix in the selected GLM.
\end{enumerate}
Relative to standard inference in the selected GLM, this extra information, per machine, does not come at any additional communication cost.
In fact, we note that the communication cost for selective inference is only $O(d^2)$ per machine.
\subsection{Merging information from local machines}
\label{sec: algorithm}
At the outset, the central machine forms the estimator
\begin{align}
\widehat\beta_E =\widehat\calI_{E,E}^{-1} \sum_{k\in \{0\} \cup [K]} \widehat\calI_{E,E}^{(k)} \widehat\beta^{(k)}_E.
\label{equ: aggregated MLE}
\end{align}
where
$$
\widehat\calI_{E,E}= \sum_{k\in \{0\} \cup [K]} \widehat\calI^{(k)}_{E,E}.
$$
The estimator in \eqref{equ: aggregated MLE}, proposed previously by \cite{lin2011aggregated}, merges the local MLE and the obs-FI matrix, computed by each machine.
Given some regularity conditions, this estimator is asymptotically equivalent to the MLE using the full data, for a fixed $E\subset [p]$.
In the next step, the central machine takes into account the data-dependent nature of our model by computing the selective MLE and the selective obs-FI.
We obtain both these values from an asymptotic selective likelihood.
Deferring details of the selective likelihood and a theoretical justification of our procedure to the next section, we outline our algorithm for selective inference here.
We define some matrices for this purpose.
For an index set $E\subset[p]$, define $J_{E}\in\R^{|E|\times p}$ as the matrix that selects the elements in $E$, i.e., $J_E[i,j]$ is 1 if the $i$-th element of $E$ is the $j$-th element in $[p]$.
Let $g^{(k)}_j=J_{E^{(j)}} \gamma^{(k)} $ and $g^{(k)}=J_E \gamma^{(k)}$
collect components of $\gamma^{(k)}$, the subgradient from machine $k$, in the sets $E^{(j)}$ and $E$, respectively.
We compute the matrices $\widehat\Gamma$, $\widehat\Psi$, $\widehat\tau$, $\widehat\Theta$, $\widehat\Pi$, and $\widehat\kappa$ as follows.
The $(j,k)$ block of $\widehat\Gamma^{-1}$ is a $d^{(j)}\times d^{(k)}$ matrix given by
$$
\left\{\widehat\Gamma^{-1}\right\}_{j,k} = \begin{cases}
\left(\rho_k+\dfrac{\rho_k^2}{\rho_0}\right)\widehat\calI_{ E^{(k)},E^{(k)}} & \text{ if } j=k, \\[1.2em]
\dfrac{\rho_j\rho_k}{\rho_0}\widehat\calI_{E^{(j)},E^{(k)}} & \text{ if } j\neq k
\end{cases}.
$$
The $(k,1)$ block of $\widehat\Gamma^{-1}\widehat\Psi$ and $\widehat\Gamma^{-1}\widehat\tau$ are given by
\begin{align*}
\left\{\widehat\Gamma^{-1} \widehat\Psi\right\}_{k} &= \dfrac{\rho_k}{\rho_0} \widehat\calI_{E^{(k)},E}; \quad
\left\{\widehat\Gamma^{-1}\widehat\tau\right\}_{k}=-\rho_k g^{(k)}_{k} - \dfrac{\rho_k}{\rho_0} \sum_{j=1}^K \rho_j g^{(j)}_{k}.
\end{align*}
Finally, define $\Theta$, $\Pi$, $\kappa$ as
\begin{align*}
\widehat\Theta^{-1} ={\frac{1}{\rho_0}} \widehat\calI_{E,E}-\widehat\Psi\tran \widehat\Gamma^{-1}\widehat\Psi;\quad \widehat\Theta^{-1}\widehat\Pi &= \widehat\calI_{E,E}; \quad \widehat\Theta^{-1} \widehat\kappa=\widehat\Psi\tran\widehat\Gamma^{-1}\widehat\tau+{\sum_{k=1}^K\frac{\rho_k}{\rho_0} g^{(k)} }.
\end{align*}
The central machine delivers selective inference by solving the following interior-point algorithm
\begin{equation}
\label{optimization:inference}
\widehat{V}_{\widehat\beta_E}^{\star}= \underset{V\in\R^{\bar d}}{\argmin}\; \frac{1}{2}(\sqrt{n}V - \widehat\Psi \sqrt{n}\widehat\beta_E -\widehat\tau)\tran \widehat\Gamma^{-1}(\sqrt{n}V - \widehat\Psi \sqrt{n}\widehat\beta_E -\widehat\tau) + \text{Barr}_{\mathcal{O}_S}(\sqrt{n}V),
\end{equation}
where
$$\mathcal{O}_S=\left\{\left(V^{(1)}, V^{(2)},\ldots, V^{(K)}\right): V^{(k)}\in \mathbb{R}^{d^{(k)}}, \ \sign(V^{(k)})= S^{(k)} \text{ for } k\in [K]\right\}\subset \mathbb{R}^{\bar d},$$
and $\text{Barr}_{\mathcal{O}_S}(V)$ is a barrier penalty that takes the value $\infty$ if $V= \left(V^{(1)}, V^{(2)},\ldots, V^{(K)}\right) \notin \mathcal{O}_S$.
The selective MLE and the selective obs-FI are equal to
\begin{equation}
\label{selective:MLE}
\sqrt{n}\widehat\beta^{(S)}_E = \sqrt{n} \widehat\Pi^{-1}\widehat\beta_E - \widehat\Pi^{-1}\widehat\kappa + \widehat\calI_{E,E}^{-1}\widehat\Psi\tran \widehat\Theta^{-1}(\widehat\Psi \sqrt{n}\widehat\beta_E +\widehat\tau -\sqrt{n}\widehat{V}_{\widehat\beta_E}^{\star}),
\end{equation}
\begin{equation}
\label{obs:FI}
\widehat\calI^{(S)}_{E,E} = \widehat\calI_{E,E}\left(\widehat\Theta^{-1}+ \widehat\Psi\tran \widehat\Gamma^{-1}\widehat\Psi - \widehat\Psi\tran \widehat\Gamma^{-1} \left(\widehat\Gamma^{-1} + \nabla^2\text{Barr}_{\mathcal{O}_S}\left(\sqrt{n}\widehat{V}_{\widehat\beta_E}^{\star}\right)\right)^{-1}\widehat\Gamma^{-1} \widehat\Psi\right)^{-1} \widehat\calI_{E,E},
\end{equation}
respectively.
Algorithm~\ref{algo} summarizes our procedure for selective inference under the selected GLM in \eqref{sel:model}.
\begin{algorithm}
\setstretch{1.2}
\caption{Selective inference with Distributed Data}
\label{algo}
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\vspace{2mm}
\algorithmicrequire{ \textbf{1:} Variable Selection at Local Machines}
Machine $k$ solves \eqref{GL:regression} and sends $E^{(k)} =\text{Support}(\widehat\beta^{\Lambda,(k)})$ to the central machine.
\vspace{2mm}
\algorithmicrequire{ \textbf{2:} Modeling with selected predictors}
Central Machine aggregates $E^{(k)}$ and forms the selected GLM in \eqref{sel:model}.
\vspace{2mm}
\algorithmicrequire{ \textbf{3:} Communication with Central Machine}
\hspace*{0.2cm} Exchange 1: Central machine sends the set $E$ to the local machines.
\hspace*{0.2cm} Exchange 2: Local machine $k$ sends back the following information
\begin{align*}
&\text{local estimators: } \ \widehat\beta_{E}^{(k)}, \; \widehat\calI_{E,E}^{(k)};
&\text{subgradient at $\widehat\beta^{\Lambda,(k)}$: } \ \gamma^{(k)}_E
\end{align*}
\algorithmicrequire{ \textbf{4:} Selective Inference at Central Machine}
\hspace*{0.2cm} (A) Compute the aggregated MLE $\widehat\beta_E$ defined by Equation~\eqref{equ: aggregated MLE}.
\hspace*{0.2cm} (B) Solve the $\bar d$-dimensional convex optimization in \eqref{optimization:inference}.
\hspace*{0.2cm} (C) Compute $\widehat\beta^{(S)}_E$ and $\widehat\calI^{(S)}_{E,E}$ as stated in \eqref{selective:MLE} and \eqref{obs:FI}.
\hspace*{0.2cm}
Let
$$\widehat\sigma_j^{(S)}=\sqrt{ \left(\widehat{I}^{(S)}_{E,E}\right)^{-1}_{j,j} }$$
\vspace{2mm}
\hspace*{0.2cm} Compute two-sided p-values at level $\alpha$ as
$$ 2\text{min}\left( \Phi\left(\frac{\sqrt{n}}{\widehat\sigma_j^{(S)}}\widehat{\beta}^{(S)}_{E,j}\right), \bar\Phi\left(\frac{\sqrt{n}}{\widehat\sigma_j^{(S)}}\widehat{\beta}^{(S)}_{E,j}\right)\right)$$
\vspace{2mm}
\hspace*{0.2cm} Compute two-sided $100\cdot(1-\alpha)\%$ confidence intervals as
$$\widehat{\beta}^{(S)}_{E,j} \pm z_{1-\alpha/2} \cdot \frac{\widehat\sigma_j^{(S)}}{\sqrt{n}} \text{ for } j\in [E].$$
\end{algorithm}
\section{Theory}
\label{sec:4}
We provide an asymptotic justification for our procedure in this section.
\subsection{A randomized representation of selection}
\label{sec: randomization}
We obtain our asymptotic selective likelihood from a conditional distribution of the aggregated MLE.
As a first step in this direction, we develop a randomized framework which yields us a representation of selection with distributed data.
Define the randomization variables
\begin{equation}
\Omega=\left({\omega_n^{(1)}}\tran,\ldots,{\omega_n^{(K)}}\tran\right)\tran,
\label{randomization:distributed}
\end{equation}
where
\begin{align*}
\omega_n^{(k)}&=
\frac{1}{ n} X\tran(A'(X\hat\beta^{\Lambda,(k)}) - Y) - \frac{1}{ n_k} X^{(k),\intercal}(A'(X^{(k)} \hat\beta^{\Lambda,(k)}) - Y^{(k)}),
\end{align*}
and $X$ and $Y$ are obtained by stacking $X^{(k)}$ and $Y^{(k)}$, for $k\in [K]$.
We can re-formulate the generalized linear regression in \eqref{GL:regression} as
\begin{equation}
\underset{\beta \in \R^p}{\text{minimize}} \; \frac{1}{\sqrt{n}} \sum_{i\in [n]} \left\{A(x_i\tran\beta)-y_ix_i\tran\beta \right\}+ \|\Lambda\beta\|_1 -(\sqrt{n}{\omega^{(k)}_n})\tran\beta.
\label{GL:regression:randomized}
\end{equation}
Consider the following assumptions.
\begin{assumption}
\label{assump: missed variables}
For $k\in [K]$, let $\widetilde{E}^{(k)}= E\setminus E^{(k)}$.
Suppose that $\beta_j=O(n^{-1/2})$, or $X_{E^{(k)}}\calI_{E^{(k)},E^{(k)}}^{-1} \calI_{E^{(k)},j} = X_j$ for $j\in \widetilde{E}^{(k)}$.
\end{assumption}
\begin{assumption}
\label{assump: glm regularity}
The aggregated MLE \eqref{equ: aggregated MLE}, in the selected GLM, can be written as
\begin{align*}
\sqrt n(\widehat\beta_E-\beta_E)=-\calI_{E,E}^{-1} \nabla\ell(\beta_E)+o_p(1),
\end{align*}
where $\calI_{E,E}$ is the Fisher information in the same model.
\end{assumption}
Theorem \ref{thm: normality of omega} provides the asymptotic distribution for the randomization variables in \eqref{randomization:distributed}, and Proposition \ref{prop: asymp indep} finds their joint distribution with other variables involved in selection.
Note, Assumption \ref{assump: missed variables} states conditions on predictors that are present in the selected GLM, but are not selected by machine $k$.
The conditions imply that our asymptotic assertions hold as long as such predictors are either weak in strength, or have a high partial correlation with a predictor in the selected set $E^{(k)}$.
The regularity condition in Assumption \ref{assump: glm regularity} states that the aggregated MLE admits an asymptotically linear representation.
This condition is satisfied when the standard MLE, based on the full data, admits the same linear representation, and when the aggregated MLE is asymptotically equivalent to the standard MLE; the latter fact has been shown to hold under some regularity conditions in \cite{lin2011aggregated}.
\begin{theorem}
\label{thm: normality of omega}
Let $U=\diag(\rho_1^{-1},\ldots,\rho_{K}^{-1})-\mathbf{1}_{K\times K}$, and let $W=\diag(\nabla^2 A(X_E\beta_E ) )$.
Suppose
\begin{align*}
\calI=\EE{\frac1n X\tran WX }
\end{align*}
is the full Fisher information matrix at $\beta_E$.
Define
\begin{align*}
\Sigma_{\Omega}=U\otimes \calI,
\end{align*}
the Kronecker product of $U$ and $\calI$.
We have
\begin{align*}
\sqrt n\, \Omega \convdis \N_{pK}\left(\mathbf{0},\Sigma_{\Omega} \right).
\end{align*}
\end{theorem}
The proof is detailed out in Appendix \ref{prf: normality of omega}.
\begin{proposition}
\label{prop: asymp indep}
Define the estimator
\begin{align*}
\widehat \beta_E^\perp=\frac1{ n} X_{-E}\tran(\nabla A(X_E\widehat\beta_E ) - Y).
\end{align*}
Then,
\begin{align*}
\sqrt n
\begin{pmatrix}
\widehat\beta_{E}-\beta_{E,n} \\ \widehat\beta_E^\perp \\ \Omega
\end{pmatrix}
\convdis \N_{p(K+1)}\left(\mathbf{0},\begin{pmatrix}
\calI_{E,E}^{-1} &\mathbf{0} &\mathbf{0} \\
\mathbf{0} & \calI/\calI_{E,E} & \mathbf{0}\\
\mathbf{0} &\mathbf{0} & \Sigma_{\Omega}
\end{pmatrix}\right),
\end{align*}
where $\calI/\calI_{E,E}=\calI_{-E,-E}-\calI_{-E,E}\calI_{E,E}^{-1}\calI_{E,-E} $ is the Schur complement of $\calI_{E,E}$.
\end{proposition}
The proof is provided in Appendix \ref{prf: asymp indep}.
Our next result, Theorem \ref{sel:event:rep}, makes two contributions.
One, we identify a straightforward representation for (a subset of) our selection event.
We proceed by conditioning on this event to form a selective likelihood.
But, before conditioning, we must characterize the (unconditional) distribution of variables in this representation.
Two, the next result gives us the asymptotic (unconditional) likelihood, using the limiting law of variables in Theorem \ref{thm: normality of omega} and Proposition \ref{prop: asymp indep}.
Hereafter, we let $\Pi= \mathbb{E}[\ \widehat\Pi \ ]$, and similarly, $\kappa,\Theta,\Psi,\tau,\Gamma$ are the population versions of the matrices $\widehat\kappa,\widehat\Theta,\widehat\Psi,\widehat\tau,\widehat\Gamma$ that we defined in Section~\ref{sec:3}.
\begin{theorem}
\label{sel:event:rep}
The following assertions hold.
\begin{enumerate}[(i)]
\item $\left\{\widehat{E}^{(k)}=E^{(k)}, \ \widehat{S}^{(k)}=S^{(k)}, \ \widehat{Z}^{(k)} = Z^{(k)} \text{ for } k\in [K]\right\} = \left\{ \text{\normalfont sign}(\sqrt{n}\widehat{B})= S, \ \ \widehat{Z} = Z\right\}$.
\item The asymptotic distribution of
$$\sqrt{n}\begin{pmatrix} \widehat\beta_{E} & \widehat \beta_E^\perp & \widehat{B} \end{pmatrix} \Big\lvert \widehat{Z}=Z$$
leads us to the following asymptotic likelihood function
\begin{align*}
p_{Z}\left(\beta_{E,n}; \widehat\beta_{E}, \widehat\beta_{E}^\perp, \widehat{B}\right) \propto \varphi(\sqrt n\widehat\beta_E; \Pi \sqrt n\beta_{E,n} + \kappa; \Theta)\cdot \varphi(\sqrt n\widehat B; \Psi \sqrt n\widehat\beta_E + \tau;\Gamma).
\end{align*}
\end{enumerate}
\end{theorem}
The proof is provided in Appendix \ref{prf: sel:event:rep}.
\subsection{Asymptotic selective likelihood}
\label{sec: asymp sel likelihood}
Now, we turn to obtain a conditional distribution for the aggregated MLE.
We begin with the the distribution of
$$\sqrt{n}\begin{pmatrix} \widehat\beta_{E} & \widehat \beta_E^\perp & \widehat{B} \end{pmatrix} \Big\lvert \widehat{Z}=Z,$$
which gives us the likelihood function $p_{n, Z}\left(\beta_{E,n}; \widehat\beta_{E}, \widehat\beta_E^\perp, \widehat{B}\right)$.
Because of the representation of selection in Theorem \ref{sel:event:rep}, inference conditional on this event proceeds by truncating $p_{n, Z}\left(\beta_{E,n}; \widehat\beta_{E}, \widehat\beta_E^\perp, \widehat{B}\right)$
to the event $\{\sqrt{n}\widehat{B}\in \mathcal{O}_S\}$.
Formally, we can base conditional inference on
\begin{equation}
\begin{aligned}
& \dfrac{p_{n, Z}\left(\beta_{E,n}; \widehat\beta_{E}, \widehat\beta_E^\perp, \widehat{B}\right) }{\int p_{n, Z}\left(\beta_{n,E}; b_{E}, b_E^\perp, B\right) 1_{\mathcal{O}_S}(\sqrt{n}B)db_{E} db_E^\perp dB} 1_{\mathcal{O}_S}(\sqrt{n}\widehat{B})\\
&=\dfrac{p_{n, Z}\left(\beta_{E,n}; \widehat\beta_{E}, \widehat\beta_E^\perp, \widehat{B}\right) }{\mathbb{P}\left[\text{sign}(\sqrt{n}\widehat{B})= S \; \Big\lvert \; \widehat{Z}=Z\right]} 1_{\mathcal{O}_S}(\sqrt{n}\widehat{B}).
\label{likelihood:n}
\end{aligned}
\end{equation}
The log-likelihood, based on \eqref{likelihood:n}, is equal to
$$
\log p_{n, Z}\left(\beta_{E,n}; \widehat\beta_{E}, \widehat\beta_E^\perp, \widehat{B}\right) -\log \mathbb{P}\left[\text{sign}(\sqrt{n}\widehat{B})= S \; \Big\lvert \; \widehat{Z}=Z\right].
$$
Note, the first term in the log-likelihood can be replaced with its asymptotic counterpart $p_{Z}\left(\beta_{E,n}; \widehat\beta_{E}, \widehat\beta_E^\perp, \widehat{B}\right)$, which was derived in Theorem \ref{sel:event:rep}.
To obtain an expression for our asymptotic selective likelihood, we are left to find the limiting value of the log-probability, in the second term of this log-likelihood.
The main result in this section gives us a large-deviation limit for the log-probability, under some moment and regularity conditions that are usually made to ensure existence of the limit.
Consider a real-valued sequence $a_n$ that goes to infinity as $n\to \infty$, and $a_n = o(n^{1/2})$.
Assume that $\sqrt{n}\beta_{E,n} = a_n\beta_E\in {\mathbb{R}^{|E|}}$, where $\beta_E$ does not depend on $n$.
\begin{assumption}[Moment condition and convergence of remainder]
\label{as:1}
Based on our proof for Proposition \ref{prop: asymp indep}, we have
\begin{align}
\sqrt n
\begin{pmatrix}
\widehat\beta_{E}-\beta_{E,n} \\ \widehat\beta_E^\perp \\ \Omega
\end{pmatrix} =
\sqrt n \bar E_n + R_n,
\label{linear:rep}
\end{align}
where $\bar E_n= \frac{1}{n}\sum_{i=1}^n e_{i,n}$ is the average of $n$ i.i.d. observations, and $R_n=o_p(1)$.
Assume that
$$\mathbb{E}\left[\exp(\lambda\|e_{1,n}\|_2)\right]<\infty$$
for some $\lambda\in \mathbb{R}^{+}$,
and that
\begin{equation*}
\displaystyle\lim_{n\to \infty} \frac{1}{a_n^{2}}\log \mathbb{P}\left[\frac{1}{a_n}\| R_n \|_2 > \epsilon \right] =- \infty
\end{equation*}
for any $\epsilon >0$, where $e_{i,n}$ and $R_n$ are based on the linear representation in \eqref{linear:rep}.
\end{assumption}
\begin{assumption}[]
\label{as:2}
Consider the asymptotically linear representation in \eqref{linear:rep}.
For a fixed convex set $\mathcal{R}_0\subseteq \mathbb{R}^{p(K+1)}$, and for $O=o_p(1)$, we impose the condition that
\begin{equation*}
\begin{aligned}
& \displaystyle\lim_{n\to \infty} \dfrac{1}{a_n^2} \left\{ \log \mathbb{P}\left[ \frac{1}{a_n}\begin{pmatrix}\sqrt{n}\widehat{\beta}_E \\ \sqrt{n}\widehat{\beta}^\perp_E \\ \sqrt{n}\Omega \end{pmatrix} \in \mathcal{R}_0\right] - \log \mathbb{P}\left[ \frac{1}{a_n} \begin{pmatrix}\sqrt{n}\widehat{\beta}_E \\ \sqrt{n}\widehat{\beta}^\perp_E \\ \sqrt{n}\Omega \end{pmatrix} + \frac{1}{a_n}O\in \mathcal{R}_0 \right]\right\}=0.
\end{aligned}
\end{equation*}
\end{assumption}
\begin{theorem}
Suppose that the conditions in Assumption \ref{as:1} and Assumption \ref{as:2} are met.
Define
\begin{equation*}
\begin{aligned}
& L_n = \inf_{b, B} \Bigg\{\frac{1}{2}\left(b- \Pi \beta_E - \frac{1}{a_n}\kappa\right)\tran \Theta^{-1}\left(b- \Pi \beta_E - \frac{1}{a_n}\kappa\right) \\
&\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;+ \frac{1}{2}\left(B- \Psi b -\frac{1}{a_n}\tau\right)\tran \Gamma^{-1}\left(B- \Psi b -\frac{1}{a_n}\tau\right) + \frac{1}{a_n^2}\text{\normalfont Barr}_{\mathcal{O}_S}(a_n B)\Bigg\}.
\label{lim:convx}
\end{aligned}
\end{equation*}
Then, we have
\begin{align*}
& \displaystyle\lim_{n\to \infty} \dfrac{1}{a_n^2} \log \mathbb{P}\left[ \sqrt{n} \widehat{B}\in \mathcal{O}_S \; \Big\lvert \; \widehat{Z}= Z\right] + L_n = C,
\end{align*}
where $C$ is a constant that does not depend on $\beta_E$.
\label{thm:consistency}
\end{theorem}
As a consequence of Theorem \ref{thm:consistency}, we can substitute the log-probability in the denominator of \eqref{likelihood:n} by the optimization
\begin{equation}
\begin{aligned}
&-\inf_{b, B} \Bigg\{\frac{1}{2}\left(a_n b- a_n\Pi \beta_{E} - \kappa\right)\tran \Theta^{-1}\left(a_n b-a_n \Pi \beta_{E} - \kappa\right) \\
&\;\;\;\;\;\;\;\;\;\;\;\;+ \frac{1}{2}\left(a_n B- a_n\Psi b -\tau\right)\tran \Gamma^{-1}\left(a_nB-a_n \Psi b -\tau\right) + \text{Barr}_{\mathcal{O}}(a_n B)\Bigg\},
\label{opt:a}
\end{aligned}
\end{equation}
after we ignore the additive constant in the limit.
Finally, the optimization in the above display can be written as
\begin{equation*}
\begin{aligned}
p_n(\beta_{E,n}) &=-\inf_{v, V} \Bigg\{\frac{1}{2}\left(\sqrt{n} v- \sqrt{n}\Pi \beta_{E,n} - \kappa\right)\tran \Theta^{-1}\left(\sqrt{n} v- \sqrt{n}\Pi \beta_{E,n} - \kappa\right) \\
&\;\;\;\;\;\;\;\;\;\;\;+ \frac{1}{2}\left(\sqrt{n} V- \sqrt{n}\Psi v -\tau\right)\tran \Gamma^{-1}\left(\sqrt{n}V- \sqrt{n}\Psi v -\tau\right) + \text{Barr}_{\mathcal{O}}(\sqrt{n} V)\Bigg\},
\end{aligned}
\end{equation*}
by reparameterizing $a_n b$ and $a_n B$ in \eqref{opt:a} as $\sqrt{n}v$ and $ \sqrt{n}V$, respectively.
This yields us an asymptotic selective likelihood with log-value equal to
\begin{equation}
\begin{aligned}
& \log\varphi(\sqrt{n}\widehat\beta_E;\Pi\sqrt{n}\beta_{E, n}+\kappa,\Theta) - p_n(\beta_{E,n}).
\label{asym:lik}
\end{aligned}
\end{equation}
The score and curvature of the asymptotic selective likelihood in \eqref{asym:lik} give us the selective MLE and the selective obs-FI matrix in Section \ref{sec:3}.
Note, the derivation of the two estimators follows the steps in \cite{panigrahi2022approximate} for the standard Gaussian regression problem.
We provide this result below in the interest of completeness.
\begin{theorem}
Consider solving the optimization problem
\begin{equation}
\label{optimization:inference:popn}
\widehat{V}_{\widehat\beta_E}^{\star}= \underset{V\in\R^{\bar d}}{\argmin}\; \frac{1}{2}(\sqrt{n}V - \Psi \sqrt{n}\widehat\beta_E -\tau)\tran \Gamma^{-1}(\sqrt{n}V - \Psi \sqrt{n}\widehat\beta_E -\tau) + \text{\normalfont Barr}_{\mathcal{O}_S}(\sqrt{n}V).
\end{equation}
The maximizer of the approximate selective likelihood and the observed Fisher information matrix are equal to
$$
\Pi^{-1}\widehat\beta_E - \frac{1}{\sqrt{n}}\Pi^{-1}\kappa + \widehat\calI_{E,E}^{-1}\Psi\tran \Theta^{-1}\left(\Psi \widehat\beta_E +\frac{1}{\sqrt{n}}\tau -\widehat{V}_{\widehat\beta_E}^{\star}\right),
$$
$$
\widehat\calI_{E,E}\left(\Theta^{-1}+ \Psi\tran \Gamma^{-1}\Psi - \Psi\tran \Gamma^{-1} \left(\Gamma^{-1} + \nabla^2\text{\normalfont Barr}_{\mathcal{O}_S}\left(\sqrt{n}\widehat{V}_{\widehat\beta_E}^{\star}\right)\right)^{-1}\Gamma^{-1} \Psi\right)^{-1} \widehat\calI_{E,E},
$$
respectively
\label{est:eqns}.
\end{theorem}
In practice, we use the empirical estimates of the matrices $\Pi,\kappa,\Theta,\Psi,\tau,\Gamma$ which yields us the expressions for the selective MLE and the selective obs-FI in \eqref{selective:MLE} and \eqref{obs:FI}, respectively.
\section{Addressing p-value lotteries}
\label{sec:5}
In sparse regression, construction of p-values is more feasible after the number of variables is reduced to a manageable size.
Sample-splitting, e.g., \cite{wasserman2009high}, is often a simple way to first select variables on a subsample of the full data, and then report the corresponding p-values, using classical least squares estimation on the remaining samples.
Variables that do not appear in the selected set are assigned a p-value equal to $1$.
More recently, a more powerful alternative to sample-splitting has been introduced in \cite{fithian2014optimal} via conditioning, which is called carving.
However, results produced by a single round of sample splitting or carving are overly sensitive, which comes from how one splits the data into two subsamples, leading to widely different p-values.
This problem has been reported in literature as the p-value lottery problem.
See, for example, the paper by \cite{meinshausen2009p}.
To address the p-value lottery problem, \citet{dezeure2015high} aggregate p-values from repeated splitting, and more recently, \citet{schultheiss2021multicarving} propose to aggregate p-values after repeated carving on random splits of data.
We refer to the former procedure as multi-splitting, and the latter procedure as multi-carving.
With increasing numbers of replicates, the results are expected to be less sensitive to the randomness introduced by the splits.
Suppose one conducts multi-splitting or multi-carving $B$ times, and obtains the p-values $p_j^{(b)}$, for $b\in[B]$, and $j \in [p]$.
This is followed by aggregating the $B$ p-values through their empirical quantiles
\begin{align*}
Q_j(\gamma):=q_{\gamma}\left(\left\{\frac{1}{\gamma}p_j^{(b)} ,\,b\in[B] \right\} \right)\wedge 1 ,
\end{align*}
where $q_\gamma$ denotes the $\gamma$-th empirical quantile.
One can also minimize over $\gamma$ and use
\begin{align}
P_j:=\left[(1-\log(\gamma_{\min})) \inf_{\gamma\in(\gamma_{\min},1)} Q_j(\gamma)\right] \wedge 1.
\label{equ: gamma min}
\end{align}
The aggregation scheme produces valid p-values as long as p-values in each replicate are valid.
Below, we show that our procedure can be easily adapted to address the p-value lottery problem without recourse to MCMC sampling.
We proceed as multi-splitting and multi-carving, i.e., we use a subsample of size $n_1$ for variable selection.
For inference, we re-use data from selection by conditioning on the event of selection.
We repeat this procedure $B$ times and aggregate the p-values as above.
Moreover, in each replicate, we can draw $K$ random subsets of size $n_1$ with replacement.
A base model is selected using each subset, and the $K$ base models are aggregated as done in~\eqref{aggregate}.
To computed p-values for the variables in our selected GLM, we can apply the same procedure as described in Section~\ref{sec:3}, with the matrices
\begin{align*}
&\{\widehat\Gamma^{-1}\}_{j,k}=\delta_{j,k}\frac{\rho}{1-\rho}\widehat\calI_{E^{(j)},E^{(j)}};\quad\{\widehat\Gamma^{-1}\widehat\tau \}_k=-\frac{\rho}{1-\rho} g_k^{(k)};\\
&\widehat\Theta^{-1}=\left(1+\frac{K\rho}{1-\rho}\right) \widehat\calI_{E,E}-\widehat\Psi\tran\widehat\Gamma^{-1}\widehat\Psi.
\end{align*}
Other matrices take the form that we provided in Section~\ref{sec:3}, with $\rho_k=\rho=\frac{n_1}{n}$ and $\rho_0=1-\rho_1$.
Specially now, the distribution of the randomization variable in \eqref{randomization:distributed} is slightly different, which results in different expressions for $\widehat\Gamma$, $\widehat\tau$, and $\widehat\Theta$.
A derivation of the asymptotic distribution for randomization is deferred to Lemma \ref{prop: w r} in Appendix~\ref{sec: with replacement}.
\section{Experiments}
\label{sec: experiments}
This section provides numerical results by applying our proposed procedure.
\subsection{Experiments with distributed datasets}
We simulate our data according to two main models.
For $i\in [n]$, we draw $x_i\sim\N_p(0,\Sigma)$, where $\Sigma_{ij}=\rho^{|i-j|}$ with $\rho=0.9$, $p=100$.
In our first model, we draw a real-valued response from a linear model as $y_i\sim\N(x_i\tran\beta,1)$.
In our second model, we draw a binary response from a logistic-linear model as
$y_i\sim \text{Bernoulli}(1/(1+e^{-x_i\tran\beta}))$.
Observation $i$ is independent of all the other observations in our dataset.
There are 5 non-zero coefficients in our model; each non-zero $\beta_j$ is equal to $\pm\sqrt{2c\log p}$, where the sign is randomly determined in both models.
In the remaining section, we call parameter $c$ as the ``signal strength".
In every round of simulation, we partition the full dataset into $K+1$ disjoint subsets
$$\left\{D^{(k)} \text{ for } k\in \{0\}\cup [K]\right\}.$$
Subsets 1 through $K$ are used for variable selection, and subset 0 is used only at the time of selective inference.
Equivalently, in our setup, $D^{(k)}$ is allocated to a local machine, for $k\in [K]$, and $D^{(0)}$ is accessed only by the central machine for selective inference.
We use an extra dataset to tune the regularization parameter $\lambda$ for model selection by sweeping over a grid of values $\left\{t \sqrt{2\log p} \cdot \text{sd}(Y)\mid t=0.5,1,\ldots,5\right\}$; we do not use this dataset further, either to select predictors through a generalized linear regression, or to infer for the selected predictors.
In the first model, we run the usual linear regression with the quadratic loss function, and infer in the selected linear model.
In the second model, we run a logistic regression on each local machine, and base inference on the selected logistic-linear model.
We design three different scenarios to investigate the performance of our procedure over $500$ rounds of simulations.
\begin{enumerate}[(I)]
\item In Scenario 1, we vary the number of distributed datasets $K\in\{2,4,6,8\}$. Each local machine uses $n_k=[8000/K]$ samples, and the central machine has access to $1000$ samples. We fix the signal strength at $c=0.1$.
\item In Scenario 2, we consider $3$ distributed datasets.
The central machine has $2000$ samples, and each of the two local machines has $4000$ samples.
We investigate four signal regimes by varying $c\in \{0.3,0.5,0.7,0.9\}$; we number these regimes as $1-4$.
\item In Scenario 3, we vary the number of samples that are reserved only for selective inference at the central machine; this number takes a value in the set \sloppy{$\{250,500,1000,2000\}$}. Each of the three local machines has $2000$ samples, and the signal strength is fixed at $c=0.5$ in this setting.
\end{enumerate}
Figures \ref{fig: linear} and \ref{fig: logistic} summarize the results of our simulations, in a linear and logistic regression problem.
We begin by evaluating the coverage of $90\%$ confidence intervals that are centered around the selective MLE, and with variance estimated by the entries of the selective obs-FI matrix.
We call our method ``Dist-SI" in the plots.
As a baseline for comparison, we consider ``Splitting" which means that we simply use the samples at the central machine to infer in the GLM selected by the local machines, using the standard Wald confidence intervals.
For the selected GLM in \eqref{sel:model}, we note that our parameter of interest is
$$\beta^{E}=\underset{b}{\argmin} \; \EE{A(x_{i,E}\tran b)-y_ix_{i,E}\tran b},$$
the minimizer of the generalized linear regression problem with the selected predictors.
A comparison of power is provided next.
We compute the lengths of confidence intervals, which indicate the power associated with selective inference for $\beta^E$.
We follow this up by calculating the power of correctly detecting a true signal in $\beta$.
A signal is detected if it is selected in our model, and the selective confidence intervals do not cover $0$.
\textbf{Observations}. Across all scenarios, the confidence intervals produced by ``Dist-SI" (approximately) attain the desired coverage probability.
``Splitting" produces valid confidence intervals, but discards samples used by the local machines.
The advantages of re-using data from the local machines are quite evident in the plots for the lengths of the confidence intervals, and in the plots for the fraction of times that they detect a true signal.
As expected, ``Dist-SI" yields tighter confidence intervals and achieves higher power than the baseline procedure based on ``Splitting" in all three scenarios.
More specifically, we observe that interval lengths for both methods increase with $K$ in Scenario 1.
This is because the final model, which is the union of the $K$ models selected by local machines, is likely to be larger for larger $K$. In this case, the variance of $\widehat\beta_j$ tends to be larger.
Consistent with standard expectations, the power, for both methods, has an increasing trend as signal strength $c$ increases in Scenario 2.
In Scenario 3, we see that both methods produce longer intervals when $n_0$ decreases, and as expected, the gap between the baseline and ``Dist-SI" is more pronounced with fewer samples at the central machine.
\begin{figure}
\centering
\begin{subfigure}{.8\textwidth}
\centering
\includegraphics[width=\textwidth]{vary_K_n0_1000_n1_1000_p_100_s_5_signal_0.1_ntune_1000.pdf}
\caption{Varying $K$. Each local machine has $[8000/K]$ data points for each $K$.
}
\label{fig: linear vary K}
\end{subfigure}
\begin{subfigure}{.8\textwidth}
\centering
\includegraphics[width=\textwidth]{vary_signal_n0_2000_n1_4000_p_100_s_5_K_3_ntune_1000.pdf}
\caption{Varying signal strength. The nonzero $\beta_j$ equals $\pm\sqrt{2c\log p}$ with random signs for $c=0.3,0.5,0.7,0.9$ in the four signal regimes.}
\label{fig: linear vary signal}
\end{subfigure}
\begin{subfigure}{.8\textwidth}
\centering
\includegraphics[width=\textwidth]{vary_n0_n1_2000_p_100_s_5_K_4_signa_0.5_ntune_1000.pdf}
\caption{Varying $n_0$, the sample size in the central machine.}
\label{fig: linear vary n0}
\end{subfigure}
\caption{Results for linear regression.}
\label{fig: linear}
\end{figure}
\begin{figure}
\centering
\begin{subfigure}{.8\textwidth}
\centering
\includegraphics[width=\textwidth]{vary_K_n0_1000_n1_1000_p_100_s_5_signal_0.1_ntune_1000_logistic.pdf}
\caption{Varying $K$. Each local machine has $[8000/K]$ data points for each $K$. }
\end{subfigure}
\begin{subfigure}{.8\textwidth}
\centering
\includegraphics[width=\textwidth]{vary_signal_n0_2000_n1_4000_p_100_s_5_K_3_ntune_1000_logistic.pdf}
\caption{Varying signal strength. The nonzero $\beta_j=\pm\sqrt{2c\log p}$ with random signs for $c=0.3,0.5,0.7,0.9$.}
\end{subfigure}
\begin{subfigure}{.8\textwidth}
\centering
\includegraphics[width=\textwidth]{vary_n0_n1_2000_p_100_s_5_K_4_signa_0.5_ntune_1000_logistic.pdf}
\caption{Varying $n_0$, the sample size in the central machine.}
\end{subfigure}
\caption{Results for logistic regression.}
\label{fig: logistic}
\end{figure}
\subsection{Experiments on P-value lotteries}
In this section, we apply the suitable adaptation of our procedure to solve the p-value lottery problem, as described in Section \ref{sec:5}.
We compare our procedure with ``Multi-carving" and ``Multi-splitting" as proposed by \cite{schultheiss2021multicarving} and \cite{dezeure2015high}, respectively.
For the latter two algorithms, we use the implementation provided by \cite{schultheiss2021multicarving} with code available on GitHub\footnote{\url{https://github.com/cschultheiss/Multicarving}.
The original code is written in R, and we load them into Python when running our simulations, which might have contributed to slightly longer running times as reported in our findings.}.
To avoid any confusion, we continue to refer our procedure as ``Dist-SI", though we are no longer simulating distributed datasets.
We generate our data from the same linear model as described before, but now we use the sample size, dimension and sparsity regime that was discussed in \cite{schultheiss2021multicarving}.
That is, we fix $n=100$ and $p=200$, and consider $20$ nonzero coefficients with $\beta_j=\pm 2\sqrt{\log p}$.
We use $B=5$ replicates, and aggregate the p-values using formula~\eqref{equ: gamma min} with $\gamma_{\min}=0.05$.
The proportion of samples used for variable selection is varied in the set $\{0.5,0.6,\ldots,0.9\}$.
We fix the significance level at $0.10$.
A coefficient $\beta_j$ is predicted to be nonzero if $P_j<0.1$.
To compare the quality of p-values, we measure their accuracy in terms of the diagnostic odds ratio (DOR), which is defined as:
\begin{align*}
\text{DOR}:=\frac{\text{True positive}\cdot \text{True negative}}{\text{False positive}\cdot \text{False negative}}.
\end{align*}
Besides computing the DOR, we compare the average run time for ``Dist-SI" and ``Multi-carving".
The results are shown in Figure~\ref{fig: multisplit}.
In the left panel, we plot the diagnostic odds ratio of the three methods with varying proportions.
The error bars are once again reported for $500$ random repetitions.
In the right panel, we plot the average log-run times of ``Dist-SI" and ``Multi-carving".
\textbf{Observations}.
We find that our procedure has larger DOR than the two previously proposed alternatives, ``Multi-carving", and ``Multi-splitting", for all values of sample proportion.
Especially, a p-value in every replicate uses the full data after carefully discarding information that was used up for selecting predictors.
The re-use of data from selection results in larger power over ``Multi-splitting".
Our procedure aligns with ``Multi-carving", which also deploys conditional techniques to re-use data for hypothesis testing.
However, a key distinction of our procedure with ``Multi-carving" lies in how we use the randomization framework to represent selection, and subsequently marginalize over this randomness to construct our p-values.
In particular, we note that ``Multi-carving" conditions on the randomization that is involved during variable selection on a random split of the data, whereas our procedure explicitly characterizes the distribution of randomization instead of simply conditioning on $\Omega$.
We believe that this difference between the two procedures shows up in our simulated findings as we note larger values of DOR with ``Dist-SI".
Unsurprisingly, our proposal is also faster than ``Multi-carving" by about $100$ times.
From a computing perspective, our procedure solves a convex optimization problem to deliver p-values; the latter procedure uses MCMC sampling from a conditional distribution for the same problem.
\begin{figure}
\centering
\includegraphics[width=.9\textwidth]{multisplit_n_100_B_5_p_200_s_20_signal_2.0_gammamin_0.05.pdf}
\caption{Compare Dist-SI with multi-carving and multi-splitting. The left panel shows the DOR when using different proportions of samples for selection. The right panel shows the average running time.}
\label{fig: multisplit}
\end{figure}
\subsection{Experiments on medical dataset}
We illustrate an application of our procedure on a real dataset that is publicly available on MIT's GOSSIS database \cite{raffa2022global}.
This dataset contains records on intensive care unit (ICU) admissions from $192$ hospitals, including patients' demographic information, and various medical measurements, and lab results.
We only use the datasets from the four largest hospitals, among which three datasets are used for variable and the remaining one is reserved for selective inference.
We focus on a regression problem with data from the first 24 hours of intensive care.
The response in this problem is binary, and takes the value $1$ if a patient admitted to an ICU has been diagnosed with Diabetes Mellitus, and is $0$ otherwise.
The same problem appeared in the 2021 Women in Data Science Datathon \footnote{\url{https://www.kaggle.com/competitions/widsdatathon2021/data}. Accessed on on Dec. 17, 2022.}.
We remove variables with more than half missing values, and also remove rows with missing values.
After preprocessing, we end up with 81 predictors.
The three datasets used for variable selection have sample sizes ranging from $1633$ to $1788$, and the dataset reserved for inference has $2000$ samples.
For model selection, we run the logistic regression with LASSO penalty.
Consistent with our simulated experiments, the regularization parameter is tuned with one extra dataset with $893$ samples.
The selected GLM has 58 predictors.
To construct confidence intervals for the 58 selected variables, we apply the proposed ``Dist-SI" algorithm and ``Splitting" as done in simulations.
The significance level is set to be $0.1$.
``Dist-SI" reports 21 significant variables, while ``Splitting" reports 13 significant variables.
In Figure~\ref{fig: real data}, we plot the confidence intervals for the regression coefficients that are rejected by either of the two procedures.
The boxplot for the lengths of these intervals, in Figure~\ref{fig: diabete lengths}, show that the median length of the ``Dist-SI" intervals is smaller than the ``Splitting" intervals by $67\%$.
Additionally, the coefficient of variation is $1.8$ and $3.9$ for ``Dist-SI" and "Splitting", respectively.
This indicates that the dispersion of interval lengths for ``Dist-SI" is smaller than ``Splitting".
On this instance, we see that ``Splitting" yields a few very wide intervals.
This is because the Hessian matrix based on data present at the central machine (reserved dataset) is ill-conditioned.
``Dist-SI" does not have this issue because it re-uses data from the three hospitals
for more powerful selective inference.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{CI_K_4_level_0.9}
\caption{Confidence intervals for the coefficients that are rejected by either Dist-SI or sample splitting.}
\label{fig: real data}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=.5\textwidth]{length_boxplot_K_4_outliers.pdf}
\caption{Boxplot of confidence interval lengths produced by Dist-SI and sample splitting. The y-axis is on the logarithmic scale. }
\label{fig: diabete lengths}
\end{figure}
\section{Conclusion}
\label{sec: conclusion}
Model selection appears to be routine practice when analyzing big datasets.
Inference for data-dependent models and parameters is a very challenging goal, because sound procedures must rigorously account for randomness from the selection process.
To the best of our knowledge, this is the first contribution that addresses selective inference with distributed data.
We provide a procedure to construct confidence intervals and p-values when inference is sought in a generalized linear model with selected predictors.
We identify a representation for selection in a common distributed setup, and provide an asymptotic selective likelihood by developing a randomized framework for our problem.
Approximately-valid selective inference, based on our selective likelihood, takes a very simple form: our confidence intervals for the selected regression coefficients are centered around the MLE of the selective likelihood, and the variance of the MLE is estimated by the observed Fisher information matrix.
An appealing feature of our procedure is that we only require some aggregated information, with relatively low communication cost, from each machine.
This feature allows an adaptation of our procedure to settings where various data-sites may not be willing to share their individual datasets.
But, we note that there is room for improvement here, specially if various sites have not measured the same set of predictors.
Our paper also provides an efficient solution for the p-value lottery problem without relying on MCMC samplers.
Our procedure bypasses the primary computational bottleneck in the earlier proposal \cite{schultheiss2021multicarving} by reducing selective inference to the solution of an optimization problem.
\section{Acknowledgements}
S. Panigrahi's research is supported in part by NSF grants: NSF-DMS 1951980 and NSF-DMS 2113342.
S. Liu's research is partially supported by the Stanford Data Science Scholars program.
\bibliographystyle{apalike}
| {'timestamp': '2023-01-18T02:14:29', 'yymm': '2301', 'arxiv_id': '2301.06162', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06162'} | arxiv |
\section{Detailed Proofs}\label{sec:proofs}
\subsection{Proof of Lemma~\ref{lem:standard-lemma}}\label{sec:proof-standard-lemma}
From measurability of the transition kernel and \cite[Lem.~1]{c} we have that
\begin{align*}
\mathbb{P}[Reach_{{t+1}}^{s_0}(A)]
&=
\mathbf{1}_{\mathbb{R}^n \setminus A}(s_0)
\cdot
\int_{\mathbb{R}^n}
\mathbb{P}[Reach_{{t}}^{s_1}(A)] ~T(s_0, \mathrm{d}s_1)
&\text{By \cite[Lem.~1]{c}} \\
&=
\mathbf{1}_{\mathbb{R}^n \setminus A}(s_0)
\cdot
\mathbb{X}[\lambda s_1 \mathpunct{.}
\mathbb{P}[Reach_{{t}}^{s_1}(A)]
]
&\text{By \eqref{eqn:postex}}
\end{align*}
Case $t = 0$ follows from the definition of
the reachability event in \eqref{eqn:reach1}.
\subsection{Proof of Lemma~\ref{lem:reachstep}}\label{sec:proof-reachstep}
Since the sets in the family $\{ Reach^{s_0}_{t} \colon t \in \mathbb{N}\}$ are disjoint, we note that the union in \eqref{eqn:reach-union} that defines $Reach^{s_0}_{\leq t}$ is a union of disjoint sets. By countable additivity of measure and disjointness of the union in \eqref{eqn:reach-union}, we see that:
\begin{equation}\label{eqn:reach-sum}
\mathbb{P}[Reach_{\leq t}^{s_0}(A)] =
\sum_{i=0}^t \mathbb{P}[Reach_{t}^{s_0}(A)]
\end{equation}
By Lem.~\ref{lem:standard-lemma}, we have that
\begingroup
\allowdisplaybreaks
\begin{align*}
\mathbb{P}[Reach_{\leq {t+1}}^{s_0}(A)]
&= \mathbb{P}[Reach_{{0}}^{s_0}(A)] + \sum_{i = 1}^{t + 1} \mathbb{P}[Reach_{{i}}^{s_0}(A)]
&\text{By~\eqref{eqn:reach-sum}}\\
&= \mathbf{1}_{A}(s_0) + \sum_{i = 1}^{t + 1} \mathbb{P}[Reach_{{i}}^{s_0}(A)] &\text{By~\eqref{eqn:standard-result-zero}}\\
&= \mathbf{1}_{A}(s_0) + \sum_{i = 0}^{t} \mathbb{P}[Reach_{{i + 1}}^{s_0}(A)]\\
&=
\mathbf{1}_{A}(s_0) + \sum_{i = 0}^{t}
\mathbf{1}_{\mathbb{R}^n \setminus A}(s_0) \cdot
\mathbb{X}[\lambda s_1 \mathpunct{.}
\mathbb{P}[Reach_{{t}}^{s_1}(A)]](s_0)
&\text{By \eqref{eqn:standard-result-reach}}\\
&=
\mathbf{1}_{A}(s_0) + \sum_{i = 0}^{t}\left(
\mathbf{1}_{\mathbb{R}^n \setminus A}(s_0) \cdot
\int_{\mathbb{R}^n}
\mathbb{P}[Reach_{{t}}^{s_1}(A)] ~T(s_0, \mathrm{d}s_1)
\right) &\text{By \eqref{eqn:postex}}\\
&=
\mathbf{1}_{A}(s_0) +
\mathbf{1}_{\mathbb{R}^n \setminus A}(s_0) \cdot
\int_{\mathbb{R}^n}
\left( \sum_{i = 0}^{t} \mathbb{P}[Reach_{{t}}^{s_1}(A)] \right) ~T(s_0, \mathrm{d}s_1)
\\
&=
\mathbf{1}_{A}(s_0) +
\mathbf{1}_{\mathbb{R}^n \setminus A}(s_0) \cdot
\int_{\mathbb{R}^n}
\mathbb{P}[Reach_{{\leq t}}^{s_1}(A)] ~T(s_0, \mathrm{d}s_1)
&\text{By~\eqref{eqn:reach-sum}}\\
&=\mathbf{1}_A(s_0)
+
\mathbf{1}_{\mathbb{R}^n \setminus A}(s_0)
\cdot
\mathbb{X}[\lambda s_1 \mathpunct{.}
\mathbb{P}[Reach_{{\leq t}}^{s_1}(A)]](s_0)
&\text{By~\eqref{eqn:postex}}
\end{align*}\endgroup
Furthermore, we have that
\begin{align}
\mathbb{P}[Reach_{\leq 0}^{s_0}(A)]
&= \mathbb{P}[Reach_{0}^{s_0}(A)]
= \mathbf{1}_{A}(s_0)
&\text{By~\eqref{eqn:reach-sum} and \eqref{eqn:standard-result-zero}}
\end{align}
\subsection{Proof of Theorem~\ref{thm:V-of-s}}\label{sec:proof-V-of-s}
We adapt the soundness proof of non-negative repulsing supermartingales \cite{DBLP:journals/toplas/TakisakaOUH21} to neural certificates (which do not require a externally-provided deterministic invariant to restrict their domain) in our setting of probabilistic systems (i.e.\ we do not consider non-deterministic transition dynamics).
We consider the set of Borel measurable functions
\begin{equation}
\mathcal{V} = \mathbb{R}^n \to \mathbb{R}_{\geq 0} \cup \{ \infty \}
\end{equation}
and give it the structure of a complete partially ordered set (CPO), \cite[p.~175]{davey_priestley_2002}:
\begin{itemize}
\item we extend the natural ordering relation on $\mathbb{R}_{\geq 0} \cup \{ \infty \}$ to the pointwise partial order over functions:
\begin{equation}\label{eqn:order}
U \sqsubseteq V \Leftrightarrow \forall s \in \mathbb{R}^n \mathpunct{.} U(s) \leq V(s)
\end{equation}
\item we define the bottom element $\bot$ as the function that always returns zero,
\begin{equation}
\bot(x) = 0,\label{eqn:bot}
\end{equation}
\item for a countable increasing chain of functions $\{ V_i \}_{i \in \mathbb{N}}$ we define its least upper bound (lub) $\sqcup \{ V_i \colon i \in \mathbb{N}\}$ argumentwise:
\begin{equation}\label{eqn:lubfunc}
\left(\sqcup \left \{ V_i \colon i \in \mathbb{N} \right \}\right) (s) = \sqcup \left \{ V_i(s) \colon i \in \mathbb{N} \right \}
\end{equation}
\end{itemize}
We introduce a higher-order function $\Phi : \mathcal{V} \to \mathcal{V}$ defined as
\begin{equation}\label{def:phi}
\Phi(V)(s) =
\mathbf{1}_{A}(s) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s) \cdot \mathbb{X}[V](s)
\end{equation}
We now show that if a $V \in \mathcal{V}$ satisfies
conditions \eqref{eq:spec_ind} and \eqref{eq:spec-dec}
then it is a pre-fixpoint of $\Phi$, namely that:
\begin{equation}\label{eqn:prefixed}
\Phi(V) \sqsubseteq V
\end{equation}
Let us recall that $\Phi(V)(s) = \mathbf{1}_{A}(s) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s) \cdot \mathbb{X}[V](s)$ by definition \eqref{def:phi}. Then, we let $s \in \mathbb{R}^n$ be arbitrary, and proceed by cases.
\begin{align*}
&\text{Case $s \in A$: }~\Phi(V)(s)=
\mathbf{1}_{A}(s) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s) \cdot \mathbb{X}[V](s) = 1 \leq V(s) &\text{By \eqref{eq:spec_ind}}\\
&\text{Case $s \notin A$: }~
\Phi(V)(s)=
\mathbf{1}_{A}(s) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s) \cdot \mathbb{X}[V](s)
= \mathbb{X}[V](s)
\leq V(s) &\text{By \eqref{eq:spec-dec}}
\end{align*}
We now aim to show that the function $\lambda s_0 \in \mathbb{R}^n \mathpunct{.} \mathbb{P}[Reach_{\mathrm{fin}}^{s_0}(A)]$ is the least fixpoint of $\Phi$, using Kleene's Fixpoint Theorem~\cite[CPO Fixpoint Theorem 1, Theorem 8.15, p.~183]{davey_priestley_2002}, and to do this we have to show that $\Phi$ is continuous, that is,
\begin{itemize}
\item $\Phi$ is monotone, that is, $U \sqsubseteq V$ implies $\Phi(U) \sqsubseteq \Phi(V)$ and
\item $\Phi$ preserves least upper bounds, that is,
$\Phi(\sqcup \{V_i \colon i \in \mathbb{N} \})
=
\sqcup \{\Phi(V_i) \colon i \in \mathbb{N} \}$
\end{itemize}
\paragraph{Monotonicity}
To show that that $\Phi$ is monotone,
let $s \in \mathbb{R}^n$ be arbitrary and assume $U \sqsubseteq V$:
\begin{align*}
\Phi(U)(s) &=
\mathbf{1}_{A}(s) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s) \cdot \mathbb{X}[U](s)\\
&=
\mathbf{1}_{A}(s) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s) \cdot
\int_{\mathbb{R}^n} U(s') ~T(s, \mathrm{d}s') &\text{By \eqref{eqn:postex}}\\
&\leq
\mathbf{1}_{A}(s) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s) \cdot
\int_{\mathbb{R}^n} V(s') ~T(s, \mathrm{d}s') &\text{By } U \sqsubseteq V \text{ and \eqref{eqn:order}}\\
&
=\mathbf{1}_{A}(s) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s) \cdot \mathbb{X}[V](s) &\text{By~\eqref{eqn:postex}}\\
&= \Phi(V)(s)
\end{align*}
therefore $\Phi(U) \sqsubseteq \Phi(V)$.
\paragraph{Least upper bound preservation}
We first note that $\{ \Phi(V_i) : i \in \mathbb{N} \}$ is a countable increasing chain because $\Phi$ is monotone. Then, to show that $\Phi$ preserves least upper bounds,
we show that for any countable increasing chain $\{ V_i : i \in \mathbb{N} \}$:
\begin{equation}\label{def:continuityphi}
\Phi(\sqcup \{V_i \colon i \in \mathbb{N} \})
=
\sqcup \{\Phi(V_i) \colon i \in \mathbb{N} \}
\end{equation}
To this end, we first note that by Eq.~\ref{eqn:lubfunc},
and properties of monotone increasing real sequences in the extended non-negative reals \cite[Theorem 15, p.21]{royden2010real},
for arbitrary $s \in \mathbb{R}^n$ we have:
\begin{equation}\label{eqn:lublim}
(\sqcup \{V_i \colon i \in \mathbb{N} \})(s)
= \sqcup \{ V_i(s) : i \in \mathbb{N} \}
= \lim_{i \to \infty} V_i(s)
\end{equation}
Then, we show that \eqref{eqn:lublim} implies \eqref{eqn:xcont} defined as
\begin{equation}\label{eqn:xcont}
\mathbb{X}[\sqcup \{ V_i : i \in \mathbb{N} \} ](s)
= (\sqcup \{ \mathbb{X}[V_i] : i \in \mathbb{N} \})(s)
\end{equation}
which holds because
\begin{align*}
\mathbb{X}[\sqcup \{ V_i : i \in \mathbb{N} \} ](s)
&= \int_{\mathbb{R}^n} (\sqcup \{ V_i : i \in \mathbb{N} \})(s') ~T(s, \mathrm{d}s') &\text{By~\eqref{eqn:postex}}\\
&=
\int_{\mathbb{R}^n} \left( \lim_{i \to \infty} V_i(s') \right) ~T(s, \mathrm{d}s')
&\text{By \eqref{eqn:lublim}}\\
&=
\lim_{i \to \infty} \int_{\mathbb{R}^n} V_i(s')~T(s, \mathrm{d}s') &\text{By MCT}\label{step:mct}\\
&= \lim_{i \to \infty} \mathbb{X}[V_i](s) &\text{By~\eqref{eqn:postex}}\\
&= (\sqcup \{ \mathbb{X}[V_i] : i \in \mathbb{N} \})(s) &\text{By \eqref{eqn:lublim}}
\end{align*}
This is an application of the Monotone Convergence Theorem (MCT) \cite[p.78]{axler2019measure} because $\{V_i\}_{i\in \mathbb{N}}$ is a countable increasing chain of non-negative functions.
We now use \eqref{eqn:xcont} to show that $\Phi$ preserves least upper bounds. Let $s \in \mathbb{R}^n$ be arbitrary:
\begin{align*}
\Phi(\sqcup \{V_i \colon i \in \mathbb{N} \})(s)
&=
\mathbf{1}_{A}(s) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s) \cdot \mathbb{X}[
\sqcup \{V_i \colon i \in \mathbb{N} \}
](s) &\text{By \eqref{def:phi}}\\
&=
\mathbf{1}_{A}(s) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s) \cdot
\sqcup \{\mathbb{X}[V_i](s) \colon i \in \mathbb{N} \} &\text{By \eqref{eqn:xcont} and \eqref{eqn:lubfunc}}\\
&=
\sqcup \{
\mathbf{1}_{A}(s) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s)
\cdot \mathbb{X}[V_i](s) \colon i \in \mathbb{N}
\}\\
&= \left(\sqcup \{ \Phi(V_i) \colon i \in \mathbb{N} \}\right)(s)
&\text{By \eqref{eqn:lubfunc} and \eqref{def:phi}}
\end{align*}
\paragraph{Least fixpoint of $\Phi$}
Next, we define
$\Phi^0(V) = V$ and $\Phi^{t+1}(V) = \Phi(\Phi^{t}(V))$,
and
show that the function that maps a state to its finite time reachability probability is equal to a particular least upper bound
\begin{equation}\label{eqn:reachlublambda}
\lambda s_0 \in \mathbb{R}^n \mathpunct{.} \mathbb{P}[Reach_{\mathrm{fin}}^{s_0}(A)]
= \sqcup \{ \Phi^t(\bot) \colon t \in \mathbb{N}\}
\end{equation}
which by Kleene's Fixpoint Theorem is the least fixpoint of $\Phi$. To achieve this, we show that
\begin{align}
&\text{for all $t \in \mathbb{N}$ and $s_0 \in \mathbb{R}^n$, we have}
&&\mathbb{P}[Reach_{\leq t}^{s_0}(A)]
= \Phi^{t+1}(\bot)(s_0);\label{eqn:kleene-1}\\
&\text{for all $s_0 \in \mathbb{R}^n$, we have} &&\mathbb{P}[Reach_{\mathrm{fin}}^{s_0}(A)]
= (\sqcup \{ \Phi^{t}(\bot) \colon t \in \mathbb{N} \})(s_0) \label{eqn:reachfinlub}
\end{align}
\paragraph{Proof of \eqref{eqn:kleene-1}}
We proceed by induction on $t \in \mathbb{N}$, that is, we show
\begin{itemize}
\item $\mathbb{P}[Reach_{\leq 0}^{s_0}(A)]
= \Phi^{1}(\bot)(s_0)$,
\item and, assuming
$\mathbb{P}[Reach_{\leq t}^{s_0}(A)]
= \Phi^{t+1}(\bot)(s_0)$
we show that
$\mathbb{P}[Reach_{\leq t+1}^{s_0}(A)]
= \Phi^{t+2}(\bot)(s_0)$
\end{itemize}
For the base case, we recall that $\forall s \mathpunct{.} \bot(s) = 0$ and therefore $\mathbb{X}[\bot](s_0) = 0$. Then, we have
\begin{align*}
\mathbb{P}[Reach_{\leq 0}^{s_0}(A)]
&= \mathbf{1}_A(s_0) &\text{By \eqref{eqn:reachbeforezero}}\\
&= \mathbf{1}_A(s_0) + \mathbf{1}_{\mathbb{R}^n \setminus A}(s_0) \cdot \mathbb{X}[\bot](s_0)
&\text{By \eqref{eqn:bot} and \eqref{eqn:postex}}\\
&= \Phi^1(\bot)(s_0)
\end{align*}
For the inductive case, we leverage Lem.~\ref{lem:reachstep} as follows:
\begin{align*}
\mathbb{P}[Reach_{\leq t + 1}^{s_0}(A)]
&=
\mathbf{1}_A(s_0)
+
\mathbf{1}_{\mathbb{R}^n \setminus A}(s_0)
\cdot
\mathbb{X}[
\lambda s_1 .
\mathbb{P}[Reach_{\leq t}^{s_1}(A)]
](s_0)
&\text{By \eqref{eqn:reachafterzero}} \\
&= \Phi(\lambda s_1 . \mathbb{P}[Reach_{\leq t}^{s_1}(A)])(s_0) &\text{By \eqref{def:phi}}\\
&= \Phi(\Phi^{t+1}(\bot))(s_0)&\text{By IH}\\
&= \Phi^{t+2}(\bot)(s_0)
\end{align*}
\paragraph{Proof of \eqref{eqn:reachfinlub}}
We leverage Lem.~\ref{lem:reachfinlimit} and \eqref{eqn:kleene-1}:
\begin{align*}
\mathbb{P}[Reach_{\mathrm{fin}}^{s_0}(A)] &= \lim_{t \to \infty} \mathbb{P}[Reach_{\leq t}^{s_0}(A)] &\text{By \eqref{eqn:reachfinlim}}\\
&= \lim_{t \to \infty} \Phi^{t + 1}(\bot)(s_0) &\text{By \eqref{eqn:kleene-1}}\\
&= \lim_{t \to \infty} \Phi^{t}(\bot)(s_0) \\
&= (\sqcup \{ \Phi^{t}(\bot) \colon t \in \mathbb{N} \})(s_0) &\text{By \eqref{eqn:lublim}}
\end{align*}
\paragraph{Conclusion}
By \eqref{eqn:reachfinlub} we conclude \eqref{eqn:reachlublambda}.
By \eqref{eqn:reachlublambda},
and continuity of $\Phi$,
we invoke Kleene's Fixpoint Theorem \cite[CPO Fixpoint Theorem 1, Theorem 8.15, p.~183]{davey_priestley_2002} to conclude that $\lambda s_0 \in \mathbb{R}^n \mathpunct{.} \mathbb{P}[Reach_{\mathrm{fin}}^{s_0}(A)]$ is the least fixpoint of $\Phi$.
Therefore, $\lambda s_0 \in \mathbb{R}^n \mathpunct{.} \mathbb{P}[Reach_{\mathrm{fin}}^{s_0}(A)]$ is also the least pre-fixpoint of $\Phi$.
This implies that
$\left(\lambda s_0 \in \mathbb{R}^n \mathpunct{.} \mathbb{P}[Reach_{\mathrm{fin}}^{s_0}(A)]\right) \sqsubseteq V$
and therefore
$V(s) \geq \mathbb{P}[Reach_{\mathrm{fin}}^{s}(A)]$
follows.
\section{Introduction}
\paragraph{Probabilistic Programs}
Probabilistic programs extend imperative programs with the ability to sample from probability distributions \cite{semantics,GordonHNR14,Kozen81,McIverM05}, which provide an expressive language for modelling applications such as randomised algorithms \cite{BatzKKM18,DBLP:conf/esop/FosterKMR016}, robot motion planning \cite{Thrun_2000}, cryptographic protocols \cite{DBLP:conf/popl/BartheFGSSB14}, and more generally for modelling and simulation of discrete-time stochastic processes \cite{katoenProbabilisticModelChecking2016}.
\paragraph{Quantitative Reachability Analysis}
A fundamental problem in the formal verification of probabilistic programs is to compute \textit{reachability probabilities} \citep{DBLP:journals/toplas/TakisakaOUH21, DBLP:conf/popl/ChatterjeeNZ17, DBLP:conf/cav/ChatterjeeGMZ22, DBLP:books/daglib/0020348}. More concretely, this requires us to compute the probability that an execution of a probabilistic program will reach a given subset of program configurations. By selecting the appropriate set of program configurations, we can express a variety of interesting quantitative verification questions in terms of computing reachability probabilities, such as computing the probability that a probabilistic loop terminates or violates an assertion \cite{DBLP:conf/lics/KobayashiLG19,FioritiH15,KaminskiKM19,DBLP:conf/pldi/WangS0CG21,DBLP:conf/pldi/SankaranarayananCG13}, and computing the probability that a discrete-time stochastic system, such as a robot moving across an environment, remains within a set of its safe configurations \cite{DBLP:conf/pldi/WangS0CG21,chakarovProbabilisticProgramAnalysis2013,DBLP:conf/popl/ChatterjeeNZ17}. However, as we might expect for a question of such generality, the problem of determining exact reachability probabilities for probabilistic loops over infinite state spaces is an uncomputable problem, as it can be instantiated to the decision problem of (deterministic) termination. Therefore, algorithmic methods for reachability analysis of probabilistic programs consider the problem of \textit{bounding} the probability of reaching a predetermined subset of states.
\paragraph{Supermartingale Certificates for Quantitative Reachability Analysis}
A recent framework for bounding reachability probabilities for probabilistic programs is to provide a supermartingale that decreases in expectation outside of the \textit{target set}, and serves as an indicator function for when the program state is in the target set. In previous literature, this is referred to as a \textit{non-negative repulsing supermartingale} \cite{DBLP:journals/toplas/TakisakaOUH21}, or \textit{stochastic invariant indicator} \cite{DBLP:conf/cav/ChatterjeeGMZ22}, but here which we name \textit{indicating supermartingale} (ISM) for clarity. The approach taken by state-of-the-art tools for bounding reachability probabilities for probabilistic programs is to assume a template for the certificate (such as a linear or polynomial function over the variables in the program state), and then to reduce the synthesis problem to linear programming (for linear templates), or semi-definite programming (for polynomial templates). However, we note it is possible to construct simple programs that lack linear or polynomial indicating supermartingales, and that, even when they exist, they may yield a probability bound on the reachability probability that is too conservative.
\paragraph{Neural Certificates in Verification}
To overcome these limitations related to template-based synthesis of indicating supermartingales, we consider neural certificates for quantitative reachability. That is, we consider indicating supermartingales expressed as neural networks, which we refer to as \textit{neural indicating supermartingales}.
Widely applied in many areas of artificial intelligence, neural networks are increasingly used as representations of formal certificates for the correctness of systems.
Previous work has applied machine learning to the formal verification of computer programs \cite{abateLearningProbabilisticTermination2021,giacobbe2022,DBLP:conf/cav/LeeWY12,LeAFKN20,Nori013,Kura2021CAV,UrbanGK16}, and of dynamical and control systems
\cite{DBLP:journals/csysl/AbateAGP21,DBLP:conf/nips/ChangRG19,DBLP:conf/aaai/LechnerZCH22, kapinski2014simulation, richards2018lyapunov,9990576}.
\smallskip
Our contribution is threefold.
\begin{description}
\item[Theory] We define the neural indicating supermartingale as a function of program state that allows
deriving an upper bound for the probability of
reachability. This neural certificate exclusively relies on knowledge of the post-expectation
of the program and does not require additional pure invariants. Unlike previous approaches which rely on compact invariants for the formal synthesis of reachability certificates, we show our model exploits neural architectures with non-negative output
to guarantee soundness without using invariants.
\item[Methods] We design an approach for synthesising neural indicating supermartingales that decouples the task of finding a certificate, for which we use machine learning, from that of checking a certificate, for which we use SMT solving. We provide a
program-aware approach which exploits a symbolic description of the post-expectation to train neural indicating supermartingales~\cite{gehr2016psi}, and a
program-agnostic learning approach which
estimates the post-expectation statistically.
We instantiate our machine learning approach in a CEGIS loop that guarantees soundness.
\item[Experiments] We build a prototype implementation of our method and compare the efficacy of neural indicating supermartingales with a
state-of-the-art method for the synthesis of indicating supermartingales entirely based on symbolic reasoning~\cite{DBLP:conf/cav/ChatterjeeGMZ22}. We demonstrate the advantage of using machine learning and neural indicating supermartingales certificates: they allow one to verify programs that lack polynomial certificates, and provide greater flexibility that attains tighter probability bounds.
\end{description}
\section{Quantitative Verification of Probabilistic Programs}
\subsection{Infinitely Running Probabilistic Programs}
\begin{figure}[t]
\begin{align*}
v &\in \mbox{Vars} & \text{(variables)}\\
N &\in \mathbb{R} & \text{(numerals)}
\\E &::= v \mid N \mid \texttt{-}E \mid E+E \mid E-E \mid E*E \mid \dots
&\text{(arithmetic expressions)}
\\P &::= {\tt Bernoulli}\texttt{(}\,E\,\texttt{)} \mid
{\tt Gaussian}\texttt{(}\,E\texttt{, }E\,\texttt{)} \mid \dots
&\text{(probability distributions)}
\\B &::= {\tt true} \mid {\tt !}B \mid B \,\texttt{\&\&}\, B \mid B\texttt{||}B \mid E\,\texttt{==}\,E \mid E\,\texttt{<}\,E \mid E\,\texttt{<=}\,E \mid \dots & \text{(Boolean expressions)}
\\C &::= \keyword{skip} &\text{(update commands)}
\\&\quad\mid v\,\texttt{=}\,E&\text{(deterministic assignment)}
\\&\quad\mid v\,\bm{\sim}\,P&\text{(probabilistic assignment)}
\\&\quad\mid C~{\tt ;}~C &\text{(sequential composition)}
\\&\quad\mid \keyword{if}~B~\keyword{then}~C~\keyword{else}~C~\keyword{fi}&\text{(conditional composition)}
\end{align*}
\caption{Grammar of update commands, Boolean and arithmetic expressions.}
\label{fig:syntax}
\end{figure}
We consider quantitative verification questions for probabilistic programs that operate over real-valued variables and that are defined in terms of the grammar in Fig.~\ref{fig:syntax}. Specifically, our probabilistic programs consist of the following components:
\begin{description}
\item[Variables] An ordered set $\Vars$ of real-valued variables with $n = |\Vars|$,
which in turn defines the state space $\mathbb{R}^n$.
Under this definition, a state $s \in \mathbb{R}^n$ is an $n$-dimensional tuple of reals.
\item[Initial Condition] A Boolean expression $B_0$, which in turn defines the initial set $S_0 \subseteq \mathbb{R}^n$, as the set of states for which expression $B_0$ evaluates to true.
\item[Update Command] An update command $C_U$ generated by the grammar of Fig.~\ref{fig:syntax}, where we consider every distribution associated with a probabilistic assignment as being obtained by applying the appropriate inverse transformation to a random variable uniformly distributed in the interval $[0, 1]$.
This defines the update function $f \colon \mathbb{R}^n \times [0,1]^k \to \mathbb{R}^n$, where $k$ is the number of syntactic probabilistic assignment statements occurring in $C_U$.
\end{description}
Altogether, our probabilistic program defines a stochastic process, whose
behavior is determined by the update equations
\begin{equation}
s_{t+1} = f(s_t, r_t), \quad r_t \sim \mathbb{U}^k, \qquad s_0 \in S_0,
\label{eq:sys}
\end{equation}
where $\mathbb{U}^k$ denotes the uniform distribution over the
$k$-dimensional hypercube $[0,1]^k$.
The state at time 0 is determined by the initial condition,
and each subsequent state is determined by the previous state and
$k$ random numbers sampled from the uniform distribution over $[0,1]$.
We remark that our model of infinitely running probabilistic programs
encompasses state-dependent distributions (cf. Fig.~\ref{fig:syntax}, probability distributions).
Probability distributions can be either discrete or continuous and may depend not only on constant parameters,
but also on parameters that are determined from the system state.
As such, parameters may depend on other distributions and thus define joint, multi-variate and hierarchically-structured distributions.
To formalise our quantitative verification questions, we first describe the semantics of our probabilistic programs as a Markov chain over the probability space of infinite words of random samples.
Namely, this is the probability space defined as $(\Omega, \mathcal{F}, \mathbb{P})$, where
\begin{itemize}
\item $\Omega$ is the set of infinite sequences $\left([0, 1]^k\right)^\omega$ of $k$-dimensional tuples of values in $[0,1]$, where $k$ is the number of probabilistic assignments that occur in the update command;
\item $\mathcal{F}$ is the extension of the Borel $\sigma$-algebra over the unit interval $\mathcal B([0, 1])$ to $\Omega$;
\item $\mathbb{P}$ is the extension of the Lebesgue measure on $[0, 1]$ to $\Omega$.
\end{itemize}
This extension of the Borel $\sigma$-algebra and Lebesgue measure to infinite sequences is a standard construction \cite{BS96,hll1996}.
Every state $s \in \mathbb{R}^n$, when used as initial state, induces a stochastic
process $\{ X_t^{s}(\omega) \}_{t \in \mathbb{N}}$ over the state space $\mathbb{R}^n$.
Let $\omega = r_0r_1r_2\dots$ be an infinite sequence of random samples in $[0,1]^k$,
then the stochastic process is defined by the sequence of random variables
\begin{equation}\label{eqn:stochprocess}
X_{t + 1}^{s}(\omega) =
f(X_{t}^{s}(\omega), r_t),
\qquad X_0^{s}(\omega) = s,
\end{equation}
This defines the natural filtration $\{ \mathcal{F}_t \}_{t \in \mathbb{N}}$ which is the smallest filtration to which the stochastic process $X^s_t$ is adapted.
In other words \cite{kallenberg}, this can be seen as a Markov chain with state space $\mathbb{R}^n$ and transition kernel
\begin{equation}
T(s, S') = \Leb\left( \left\{r \in [0, 1]^k \mid f(s,r) \in S'\right\} \right).
\end{equation}
where Leb refers to the Lebesgue measure of a measurable subset of $[0, 1]^k$. The transition kernel defines
the {\em next time operator} $\mathbb X$ \cite[Definition 2.16]{DBLP:journals/toplas/TakisakaOUH21} which can be applied to
an arbitrary Borel-measurable function $h \colon \mathbb{R}^n \to \mathbb{R}$ as
\begin{equation}\label{eqn:postex}
\mathbb{X}[h](s)= \int
h(s') T(s, \mathrm{d}s').
\end{equation}
The next time operator applied to the function $h$ defines the \textit{post-expectation} $\mathbb{X}[h]$ of $h$.
\subsection{Quantitative Reachability Verification}\label{sec:reachability}
We treat the general question of computing an upper bound on the probability that our stochastic process
reaches a state in a target set $A \in \mathcal B(\mathbb{R}^n)$.
This is the {\em reachability verification} question. We define the event of reaching the target set, starting from state $s \in \mathbb{R}^n$ after exactly $t$ time steps as
\begin{equation}\label{eqn:reach1}
Reach_t^{s}(A) = \left\{ \omega \in \Omega \mid X_0^{s}(\omega) \not\in A , \ldots, X_{t-1}^{s}(\omega) \not\in A , X_{t}^{s}(\omega) \in A \right\}.
\end{equation}
Note that, under this definition,
the special case $t = 0$ is defined as
$Reach_0^{s}(A) = \Omega$ when $s \in A$ and
$Reach_0^{s}(A) = \emptyset$ when $s \not\in A$.
Henceforth, we use $\mathbf{1}_S$ to denote the {\em indicator function} of $S \subseteq \mathbb{R}^n$, namely
$\mathbf{1}_S(s) = 1$ if $s \in S$ and $\mathbf{1}_S(s) = 0$ if $s \not\in S$. Below, we
express the probability measure of the reachability event in exactly $t$ steps, and at most $t$ steps, in terms of indicator functions and the next time operator $\mathbb X$.
\begin{lemma}\label{lem:standard-lemma}
$Reach_t^{s_0}(A)$ is measurable for every $A \in \mathcal B (\mathbb{R}^n)$, $s_0 \in \mathcal \mathbb{R}^n$ and $t \in \mathbb{N}$, and
\begin{subequations}
\begin{align}
\mathbb{P}[Reach_{{t+1}}^{s_0}(A)]
&=
\mathbf{1}_{\mathbb{R}^n \setminus A}(s_0)
\cdot
\mathbb{X}[\lambda s_1 \mathpunct{.}
\mathbb{P}[Reach_{{t}}^{s_1}(A)]
](s_0),
\label{eqn:standard-result-reach}\\
\mathbb{P}[Reach_{0}^{s_0}(A)]
&= \mathbf{1}_A(s_0).
\label{eqn:standard-result-zero}
\end{align}
\end{subequations}
\end{lemma}
\begin{proof}
Measurability of $Reach_t^{s_0}(A)$ is a standard result~\cite[Sect.~10.1.1]{DBLP:books/daglib/0020348}. Eq.~\eqref{eqn:standard-result-reach} follows from the measurability of the transition kernel \cite[Lem.~1]{c}, cf. Appendix~\ref{sec:proof-standard-lemma}.
\end{proof}
Our theory builds upon the relation between reachability in exactly $t$ time steps, at most $t$ time steps,
and finitely many steps. We define the reachability event in at most $t$ steps as
\begin{equation}\label{eqn:reach-union}
Reach_{\leq t}^{s}(A) = \cup \{~Reach_{i}^{s}(A) \colon 0 \leq i \leq t~\}.
\end{equation}
\begin{lemma}\label{lem:reachstep}
$Reach_{\leq t}^{s_0}(A)$ is measurable for every $A \in \mathcal B (\mathbb{R}^n)$, $s_0 \in \mathcal \mathbb{R}^n$ and $t \in \mathbb{N}$, and
\begin{subequations}
\begin{align}
\mathbb{P}[Reach_{\leq t + 1}^{s_0}(A)]
&=
\mathbf{1}_A(s_0)
+
\mathbf{1}_{\mathbb{R}^n \setminus A}(s_0)
\cdot
\mathbb{X}[\lambda s_1 \mathpunct{.}
\mathbb{P}[Reach_{\leq t}^{s_1}(A)]](s_0),
\label{eqn:reachafterzero}\\
\mathbb{P}[
Reach_{\leq 0}^{s_0}(A)
] &= \mathbf{1}_A(s_0).
\label{eqn:reachbeforezero}
\end{align}
\end{subequations}
\end{lemma}
\begin{proof}
$Reach_{\leq t}^{s_0}(A)$ is measurable because it is a countable union of measurable sets.
Equations \eqref{eqn:reachafterzero} and \eqref{eqn:reachbeforezero} follow from Lem.~\ref{lem:standard-lemma}, cf. Appendix~\ref{sec:proof-reachstep}.
\end{proof}
Finally, we define the event associated with reachability in finite time:
\begin{equation}\label{eqn:reachfin}
Reach_{\mathrm{fin}}^s(A) = \cup \left\{Reach_{ t}^{s}(A) \colon t \in \mathbb{N}\right\} =
\cup \left\{Reach_{\leq t}^{s}(A) \colon t \in \mathbb{N}\right\}.
\end{equation}
\begin{lemma}\label{lem:reachfinlimit}
$Reach_{\mathrm{fin}}^s(A)$ is measurable for every $A \in \mathcal B (\mathbb{R}^n)$
and $s \in \mathcal \mathbb{R}^n$, and
\begin{equation}\label{eqn:reachfinlim}
\mathbb P [Reach_{\mathrm{fin}}^s(A)] = \lim_{t \to \infty}\mathbb P [Reach_{\leq t}^s(A)].
\end{equation}
\end{lemma}
\begin{proof}
$Reach^s_\mathrm{fin}$ is measurable because it is a countable union of measurable sets. Furthermore, \eqref{eqn:reachfinlim} follows from \eqref{eqn:reachfin} and the properties of the measure of an increasing union \cite[Prop.~2.59]{axler2019measure}.
\end{proof}
As we show in Sect.~\ref{sec:neuralism}, our method computes an upper bound
for $\mathbb P [Reach_{\mathrm{fin}}^{s}(A)]$ over the initial states $s \in S_0$.
Reachability verification subsumes several important verification questions, and infinitely running probabilistic programs generalise a wide variety of systems.
\subsection{Quantitative Verification of Probabilistic Loops}
Infinitely running probabilistic programs are generalised models that subsume a wide variety of other probabilistic models.
A common example are \textit{probabilistic loops}~\citep{DBLP:conf/qest/KofnovMSBB22}, which refer to probabilistic programs with a single while-loop, a Boolean expression $B_G$ that denotes the guard condition of the loop, and an update command $C_L$ that denotes the body of the loop:
\begin{equation}
{\keyword{while}}~B_G~{\keyword{do}}~C_L~{\keyword{od}} \label{eq:probloop}
\end{equation}
Since our model is infinitely running, we express probabilistic loops as infinitely running
probabilistic programs with the initial condition $B_0$ defined as $B_G$, and the update command $C_U$ defined as
${{\keyword{if}}~B_G~{\keyword{then}}~C_L~{\keyword{else}~\keyword{skip}}~\keyword{fi}}$.
This implies that the program executes $C_L$ as long as $B_G$ is satisfied, while it leaves all variables unchanged after leaving the loop. We remark that this model is restricted to single
loops in isolation, without nesting.
Common verification problems for probabilistic loops
are the analysis of termination and of assertion-violation,
which we express as follows.
\begin{description}
\item[Termination Analysis] Let $G \in \mathcal B (\mathbb{R}^n)$ be the guard
set of a probabilistic loop, i.e., the set of states of states
for which the guard condition evaluates to true. Then, the termination event is characterised
by $Reach_{\mathrm{fin}}^s(\mathbb{R}^n \setminus G)$. Our method computes an upper bound for the probability of
termination $\mathbb P[Reach_{\mathrm{fin}}^s(\mathbb{R}^n \setminus G)]$ over every state $s \in G$ or,
dually, a lower bound for the probability of non-termination.
\item[Assertion-violation Analysis] Let $G \in \mathcal B (\mathbb{R}^n)$ the guard set of a single-loop probabilistic program and let $A \in \mathcal B (\mathbb{R}^n)$ be the satisfying set of an assertion at the beginning of the loop body. The assertion violation event
is characterized by $Reach_{\mathrm{fin}}^s(G \setminus A)$.
Our method computes an upper bound for the probability of assertion violation or, dually, a lower bound for its satisfaction. Note that multiple assertions can be modelled similarly by adding variables.
\end{description}
\subsection{Quantitative Verification of Discrete-time Stochastic Systems}
Instances of probabilistic systems that are subsumed by our definition of infinitely running probabilistic programs include stochastic (autonomous) dynamical systems in discrete time,
which are widely studied in control theory~\cite{BS96,c}.
Below, we instantiate these exemplars within our modeling framework. Discrete-time stochastic systems can be defined in terms of stochastic difference equations given a possibly nonlinear vector field $g \colon \mathbb{R}^{n_x} \times \mathbb{R}^{n_w} \to \mathbb{R}^{n_x}$,
a time-invariant input disturbance over $\mathbb{R}^{n_w}$ with arbitrary distribution $\mathcal{W}$,
and an initial condition $x_0 \in \mathbb{R}^{n_x}$:
\begin{equation}
x_{t+1} = g(x_t, w_t), \quad w_t \sim \mathcal{W}. \label{eq:dynsys}
\end{equation}
Under the assumption that $g$ and the distribution $\mathcal W$ can be defined as an update command generated by our program grammar, this is an infinitely running probabilistic program with $n = {n_x} + n_w$ variables,
where $C_U$ encodes $g$ as a composition of deterministic assignments, sampling from $\mathcal W$
as probabilistic assignments from distributions with the respective constant parameters.
Autonomous systems are naturally infinitely running and typical questions are the reachability analysis question (cf.~Sect.~\ref{sec:reachability}), the safety verification question, and the dual invariant verification question, which we phrase as follows.
\begin{description}
\item[Safety Verification] Let $B \in \mathcal B (\mathbb{R}^n)$ be a set of bad states.
Then $\Omega \setminus Reach_{\mathrm{fin}}^{s}(B)$ characterises the event
that the system never reaches a bad state when initialised in $s$.
Our method computes a lower bound over $s \in S_0$ for the probability of safety, that is, $1 - \mathbb P [Reach_{\mathrm{fin}}^{s}(B)]$.
\item[Invariant Verification] Let $I \in \mathcal B (\mathbb{R}^n)$ be a candidate invariant,
then $\Omega \setminus Reach_{\mathrm{fin}}^{s}(\mathbb{R}^n \setminus I)$ characterises the event
that $I$ is an invariant, when the system is initialised in $s$.
Our method computes a lower bound over $s \in S_0$ for the
probability that $I$ is invariant.
\end{description}
\section{Neural Indicating Supermartingales}\label{sec:neuralism}
We provide the criteria for
a certificate to ensure that the
probability that a system, with update function $f$, reaches a state
in a target set $A \in \mathcal B(\mathbb{R}^n)$
from state in an initial set $S_0 \in \mathcal B(\mathbb{R}^n)$
is bounded from above by a given value $p \in [0,1]$.
We call this certificate a {\em neural indicating supermartingale}. This we define as a neural network with $n$ input neurons, an arbitrary number of hidden layers, and one output neuron, which encodes a function of type
$V \colon \mathbb{R}^n \to \mathbb{R}_{\geq 0} \cup \{ \infty \}$, whose output is guaranteed to be non-negative over the entire domain and satisfies the following three conditions:
\begin{subequations}
\label{eq:spec}
\begin{flalign}
&\text{(indicating condition)} &&\forall s \in A \colon V(s) \geq 1, && \label{eq:spec_ind}\\
&\text{(non-increasing condition)} &&\forall s \not\in A \colon \mathbb{X}[V](s) \leq V(s),&&\phantom{aaaaaaaa} \label{eq:spec-dec}\\
&\text{(bounding condition)} &&\forall s \in S_0 \colon V(s) < p. && \label{eq:spec-bound}
\end{flalign}
\end{subequations}
\begin{theorem}\label{thm:V-of-s}
Let $A \in \mathcal{B}(\mathbb{R}^n)$ be a target set and $s \in \mathbb{R}^n$ be an arbitrary initial state. Let $V \colon \mathbb{R}^n \to \mathbb{R}_{\geq 0} \cup \{\infty\}$ be a non-negative function that satisfies \eqref{eq:spec_ind} and \eqref{eq:spec-dec}. Then
$V(s) \geq \mathbb P [Reach_{\mathrm{fin}}^{s}(A)]$.
\end{theorem}
\begin{proof}
It follows from Lem.~\ref{lem:reachstep} and \ref{lem:reachfinlimit} and Kleene's fixpoint theorem over a CPO defined over the space of Borel measurable non-negative functions that satisfy \eqref{eq:spec_ind} and \eqref{eq:spec-dec}, cf. Appendix~\ref{sec:proof-V-of-s}. We discard the requirement of an externally provided invariant from the soundness proof for non-negative repulsing supermartingales~\cite{DBLP:journals/toplas/TakisakaOUH21}.
\end{proof}
\begin{corollary}
Let $A \in \mathcal{B}(\mathbb{R}^n)$ be a target set. Let $V \colon \mathbb{R}^n \to \mathbb{R}_{\geq 0} \cup \{\infty\}$ be a non-negative function that satisfies
conditions \eqref{eq:spec_ind}, \eqref{eq:spec-dec} and \eqref{eq:spec-bound}.
Then $p \geq \sup \left\{ \mathbb P [Reach_{\mathrm{fin}}^{s}(A)] \colon s \in S_0 \right \}$.
\end{corollary}
\begin{proof}
It follows from Thm.~\ref{thm:V-of-s} and condition \eqref{eq:spec-bound}.
\end{proof}
Our criteria rely on two facts about target set $A$ and system $f$, namely, a certificate $V$ should both behave as an indicator
on $A$ and have non-increasing post-expectation everywhere else. As $V$ is also bounded from above by $p$ over $S_0$,
then the probability of reaching $A$ from every state in $S_0$ is bounded from above by $p$. Notably, this result strictly holds for non-negative functions.
We ensure non-negativity using the following architecture with $l$ layers and $h_1, \dots h_l$ neurons in every layer, respectively:
\begin{equation}
\label{eq:net}
V(x) = \operatorname{sum} \left( \sigma_l \circ \dots \circ \sigma_1(x) \right), \qquad
\sigma_i(z) =
(\relu(\mathbf{w}^T_{i,1} z + \mathbf{b}_{i,1}), \dots, \relu(\mathbf{w}^T_{i,h_i} z + \mathbf{b}_{i,h_i}))
\end{equation}
where $\operatorname{sum}(z_{l, 1}, \ldots, z_{l, h_l}) = \sum_{k = 1}^{h_l} z_{l, k}$ and $\mathbf{w}^T_{i,j} \in \mathbb{Q}^{h_{i-1}}$ and
$\mathbf{b}_{i,j} \in \mathbb{Q}$ are respectively the weight vector and the bias parameter for the inputs to neuron $j$ at layer $i$.
By using neural networks as indicating supermartingales we provide an expressive function template that does not rely on supporting invariants. This is in contrast to methods that entirely rely on symbolic techniques.
As we show in the following section,
our approach trains neural indicating supermartingales from sample observations of the system and requires symbolic reasoning only for checking their validity, without
relying on invariants. Moreover, as we show in our experimental results, this approach yields probability bounds that are comparable or better than existing methods, and further succeeds on a wider range of probabilistic programs than previously possible.
\subsection{Training of Neural ISMs From Sample Observations}
As previously stated, in the present work a neural ISM consists of a neural network with $\relu$ activation functions, with an arbitrary number of hidden layers. As with any $\relu$-based neural network, we can train it using gradient descent and a finite set of states $d$ sampled over $\mathbb{R}^n$, which we denote as the finite sampling of the state space $D = \{ d^{(1)}, \dots , d^{(m)}\}$.
We seek to construct a loss function that guides the neural network to satisfy the specification set out Eq. \eqref{eq:spec}.
We therefore consider a loss function consisting of the summation of multiple terms, with each term corresponding to a condition for the ISM:
\begin{equation}
\label{eq:loss}
\mathcal{L}(V) = \beta_{1}\mathcal{L}_\text{ind}(V) + \beta_{2} \mathcal{L}_{\text{bnd}}(V) + \beta_3\mathcal{L}_\text{non-inc}(V).
\end{equation}
Here, $\beta_{j} > 0, j\in\{1,2,3\}$, denotes a constant coefficient for scaling the terms of each constituent loss.
This reduces the task of learning a neural ISM to constructing a suitable loss function.
The proposed loss function in Eq. \eqref{eq:loss} consists of three separate components, one for each condition in Eq. \eqref{eq:spec}. Notably, we satisfy a typical non-negativity condition by construction (cf. Eq. \eqref{eq:net}). Next, we consider each component in turn and provide a suitable loss that will encourage satisfaction of Eqs. \eqref{eq:spec_ind}, \eqref{eq:spec-bound} and \eqref{eq:spec-dec}.
\subsubsection{Indicating Loss}
First, consider the condition in Eq. \eqref{eq:spec_ind}, which we refer to as the indicating condition. For this, we use the following loss function:
\begin{equation}
\label{eq:ind-loss}
\mathcal{L}_\text{ind}(V) = \mathbb E_{d \in D \cap A}[\relu(1 - V(d))].
\end{equation}
This penalises all points not within the bad states which fail to satisfy the indicating condition, whilst ignoring any states which already satisfy it. In particular, we take the expectation of this over our finite data set $S$.
\subsubsection{Bounding Loss}
Secondly, we turn to the bounding condition, given by equation \eqref{eq:spec-bound}. This condition determines the `quality' of the ISM, as it provides the upper-bound $p$. We can encourage to synthesis better ISMs by including a term in the loss that encourages
\begin{equation}
\label{eq:bound-loss}
\mathcal{L}_\text{bnd}(V) = \mathbb E_{d \in D \cap S_0}[V(d))].
\end{equation}
Finally, we consider the non-increasing condition, Eq. \eqref{eq:spec-dec}, which relies on computing the post-expectation of the martingale. We consider two alternative approaches to this calculation: one which assumes information about the program, by leveraging a symbolic inference engine, and one which does not, relying instead on a data-driven approach to perform approximate inference. We label these approaches as \emph{program-aware} and \emph{program-agnostic} synthesis, and treat them next.
\subsubsection{Program-aware Non-increasing Loss}
We begin by considering program-aware synthesis, which leverages knowledge of the program within the loss function itself. In particular, we implement the algorithm used by the exact symbolic inference engine PSI \cite{gehr2016psi, gehr2020lpsi}, along with symbolic representations of the program and candidate martingale $V$ to calculate the post-expectation $\mathbb{X}[V]$ of the martingale. This can then be used to construct a loss function which penalises samples for which the non-increasing condition is unsatisfied
\begin{equation}
\label{eq:dec-loss}
\mathcal{L}_\text{non-inc}(V) = \mathbb E_{d \in D \setminus A}[\ReLU(\mathbb{X}[V](d) - V(d))].
\end{equation}
\subsubsection{Program-agnostic Non-increasing Loss}
While it is advantageous to incorporate as much knowledge of the program into the loss function as possible, the program-aware approach relies on a symbolic formula representing the program. For large programs this formula becomes more complex and possibly intractable. Furthermore, it relies on the smoothness of $\mathbb{X}[V]$. We therefore consider an alternative formulation of the loss function which does not require knowledge of the program---rather, solely access to traces of it---and therefore is likely to perform better for more complex programs.
Ultimately, a program-agnostic approach differs from a program-aware one in that it does not exactly calculate the post-expectation of the ISM $\mathbb{X}[V]$; instead, this is now approximately calculated using a data-driven approach. We can then use the same loss function as the program-aware case, Eq. \eqref{eq:dec-loss}, but using this approximation for the post-expectation. We emphasise that this does not impact the soundness of our scheme as an exact symbolic calculation of the post-expectation is used during verification. However we expect the probability bounds associated to the certificates to be less tight than those distilled from the program-aware ones.
In practice, we utilise a Monte Carlo based approach to estimate the post-expectation.
For each state, we sample its successor states by executing the program $f$. To obtain an estimate of the post-expectation of $V$ we extend every element $d^{(i)}$ in our data set with a set of $m'$ randomly sampled successor states $D'^{(i)} =\{d^{(i, 1)}, \ldots, d^{(i, m')} \}$. Then $\mathbb{X}[V](d)$ is estimated as:
\begin{equation}
\label{eq:approx-postex}
\mathbb{X}[V](d) \approx \mathbb E_{d' \in D'}[V(d')].
\end{equation}
\subsubsection{Smoothness of Activation Functions} Finally, we note that since $\relu$ is a non-smooth function, we found that in practice it is preferable to substitute it with a smooth approximation, $\softplus$, which takes the form
\begin{equation}
\label{eq:softplus}
\softplus(s) = \log(1 + \exp(s)).
\end{equation}
However, $\softplus$ can be a poor approximation to $\relu$ over the required $[0,1]$ interval for probabilities. Therefore, in practice we learn a function that instead represents a scaled probability $\alpha p$, with the value $\alpha > 0$ being fixed to some large integer. As a result of this, the indicating component of the loss, Eq. \eqref{eq:ind-loss} becomes $\mathcal{L}_\text{ind}(V) = \mathbb E_{d \in D \cap A}[\relu(\alpha - V(d))]$.
It is important to note that while $\softplus$ is used as activation in the learning stage, during the verification stage we still verify using $\relu$ activation functions, ensuring soundness of the generated neural ISM.
\subsection{Verification of Neural ISMs Using SMT Solving}
The purpose of the verification stage is to ensure that for no possible program trace are the conditions described in Eq. \eqref{eq:spec} violated. For this purpose, we rely on SMT solving. This involves providing an SMT solver with the negation of the specification described by Eq. \eqref{eq:spec}.
However, since the non-negativity condition is satisfied by construction of the networks, this part can be disregarded. Furthermore, the bounding condition does not impact the validity of the ISM, but instead its quality. The probability bound $p$ is first optimised by the $\mathcal L_\text{bnd}$ component in our loss function, then estimated using a binary search over $[0, 1]$ and then checked over $S_0$ as part of the verification step. The conditions given in Eq. \eqref{eq:spec} become
\begin{equation}
\label{eq:val-q}
\forall s \in \mathbb{R}^n: \underbrace{(s \in A \rightarrow V(s) \geq 1 )}_{\varphi_\text{ind}} \wedge \underbrace{(s \notin A \rightarrow \mathbb{X}[V](s) \leq V(s))}_{\varphi_\text{non-inc}}
\wedge \underbrace{(s \in {S}_0 \rightarrow V(s) < p)}_{\varphi_\text{bnd}}.
\end{equation}
Therefore, the SMT solver is provided with the negation of Eq. \eqref{eq:val-q}, namely
\begin{equation}
\label{eq:smt-spec}
\exists s \in \mathbb{R}^n: \underbrace{(s \in A \wedge V(s) < 1 )}_{\lnot \varphi_\text{ind}} \vee \underbrace{(s \notin A \wedge \mathbb{X}[V](s) > V(s))}_{\lnot \varphi_\text{non-inc}}
\vee \underbrace{(s \in {S}_0 \wedge V(s) \geq p)}_{\lnot\varphi_\text{bnd}}.
\end{equation}
The verifier seeks any assignment $d_\text{cex}$ of $s$ such that any of the formulae $\lnot\varphi_\text{ind}$, $\lnot\varphi_\text{non-inc}$ and $\lnot\varphi_\text{bnd}$ are satisfiable (this check can be run in parallel over the three formulae). SMT solving is \emph{sound}: if an assignment for $s$ exists such that any of the provided formulae $\lnot\varphi_\text{ind}$, $\lnot\varphi_\text{non-inc}$ and $\lnot\varphi_\text{bnd}$ are satisfiable then it will be found. Crucially, this means that if no counterexample is found, then the conditions in Eq. \eqref{eq:spec} are satisfied and the neural ISM is valid.
Alternatively, an assignment that satisfies any of $\lnot\varphi_\text{ind}$, $\lnot\varphi_\text{non-inc}$ or $\lnot\varphi_\text{non-inc}$ is a counterexample $d_\text{cex}$: this represents a state for which the required conditions are invalidated and thus the candidate ISM is incorrect. The counterexample is then added to the data set $D$ for synthesis to resume. Furthermore, we can determine which condition is invalidated
by evaluating the clauses $\lnot\varphi_\text{ind}$, $\lnot\varphi_\text{non-inc}$ and $\lnot\varphi_\text{bnd}$ separately at $d_\text{cex}$ and determining which of these are satisfied.
\subsection{Counterexample-guided Inductive Synthesis}
In this section we have detailed an inductive synthesis procedure to generate neural ISMs which utilises counterexamples. This procedure is known as counter-example guided inductive synthesis (CEGIS) \cite{solar-lezama2008ProgramSynthesisSketching, DBLP:conf/asplos/Solar-LezamaTBSS06} (cf. Fig.~\ref{fig:CEGIS}), and consists of of two components:
a learner and a verifier. These components work in opposition to each other.
On the one hand, the learner seeks to synthesise a candidate neural ISM that meets the desired specification (cf. Eq. \eqref{eq:spec})
over a finite set of samples from the state space.
On the other, the verifier seeks to disprove the candidate generated by the learner by searching for counterexamples, i.e., instances of invalidation of the desired specification, over the original state space. If the verifier shows that no such counterexample exists, then the desired specification is met by the program and synthesis terminates successfully.
In this work, the learner takes the form of a $\ReLU$-based neural network, trained over finite samples; meanwhile, the role of the verifier is assumed by the SMT solver. Several options exist for the latter choice, under the condition that the SMT solver can reason over nonlinear real arithmetic: in this work, we use Z3 \cite{z3-solver}.
\begin{figure}
\centering
\input{Figures/cegis}
\caption{Overview of the counterexample-guided inductive synthesis procedure used to synthesise neural ISMs. Inputs to the procedure include a probabilistic program $f$, initial set {$S_0$} and target set $A$. The procedure generates an neural indicating supermartingale $V(s)$ alongside a probability bound $p$.}
\label{fig:CEGIS}
\end{figure}
\subsubsection{Generation of Additional Counterexamples}
In order to better facilitate counterexample-guided synthesis, it is desirable to generate multiple counterexamples (if they exist). This can be achieved by calling the verifier with the condition $\lnot\varphi_\text{ind} \wedge \lnot\varphi_\text{non-inc} \wedge \lnot\varphi_\text{bnd} \wedge s \not= d_\text{cex}$, i.e. we now seek an assignment to $\lnot\varphi_\text{ind} \wedge \lnot\varphi_\text{non-inc} \wedge \lnot\varphi_\text{bnd}$ that is different to the one already obtained.
However, in practice more useful counterexamples exist outside the neighbourhood of our current one. Suppose we have $N$ counterexamples $d_\text{cex}^{(1)}, \ldots, d_\text{cex}^{(N)}$; we can instead construct
\begin{equation}
\label{eq:smt-cex}
\lnot\varphi_\text{ind} \wedge \lnot\varphi_\text{non-inc} \wedge \lnot\varphi_\text{bnd} \wedge \bigwedge_{1 \leq i \leq N} (||d_\text{cex}^{(i)} - s|| \geq \gamma),
\end{equation}
where $\gamma \in \mathbb{R}^+$ and $||\cdot||$ denotes any norm of its input, to find further counterexamples that are at least $\gamma$ from all current counterexamples (according to the chosen norm).
\section{Experimental Evaluation}
The previous section develops a method for synthesising neural ISMs. This section presents an empirical evaluation of the method, by testing it against a series of benchmarks. Each benchmark is tested ten times. A test is successful if a valid ISM is synthesised, and the proportion of successful tests is recorded. Further, the average bound from the valid ISMs is also recorded, along with the average time taken by learning and verification. This procedure is applied separately for program-aware and program-agnostic synthesis. To compare our method against existing work, we perform template-based synthesis of linear ISMs using Farkas' Lemma.
It should be noted that our method is inherently stochastic. One source of randomness is the initialisation of template parameters in learning. In program-agnostic synthesis, an additional source of randomness is sampling successor states. So that the results accurately reflect the performance of our method, the random seed for these sources of randomness is different for each test. An additional source of randomness arises from the SMT solver Z3, when generating counterexamples. This cannot be controlled externally. Benchmarks are run on a machine with an Nvidia A40 GPU.
\begin{figure}
\begin{minipage}[t]{0.48\linewidth}
\begin{lstlisting}[caption={faulty\_loop}, label={lst:faulty}]
error = 0;
i = 0;
while i < 10 do
assert(error == 0);
p ~ Bernoulli(0.999);
if p == 1 then
q ~ Bernoulli(0.5);
if q == 1 then
i += 1
fi
else
error = 1
fi
od
\end{lstlisting}
\end{minipage}
\begin{minipage}[t]{0.48\linewidth}
\begin{lstlisting}[caption={repulse}, label={lst:repulse}]
x = 10;
while x >= 0 do
assert(x <= 100);
p ~ Bernoulli(0.5);
if p == 1 then
x -= 2
else
x += 1
fi
od
\end{lstlisting}
\end{minipage
\end{figure}
The benchmarks in this report are created using two patterns.
\begin{description}
\item[Unreliable Hardware] The first pattern models a program that executes on unreliable hardware. The goal is to upper bound the probability that the program fails to terminate due to a hardware fault. A simple example of such a program is \texttt{faulty\_loop}, whose source code is presented in \Cref{lst:faulty}. In this program, a variable \texttt{i} is initialised to 0. In each successful iteration, it is incremented by 1 with probability 0.5. A hardware fault is modelled with the \texttt{error} flag being set to 1.
\item[Robot Motion]The second pattern models an agent that is moving through a physical environment. In these benchmarks, the uncertainty in control and sensing is modelled probabilistically. Part of the environment is designated as the target region, and part of the environment is designated as a hazardous region. The goal is to upper bound the probability that the robot enters the hazardous region. A simple example of such a program is \texttt{repulse}, whose source code is presented in \Cref{lst:repulse}. The program starts at co-ordinate 10, in a one-dimensional environment. The target region is where $x < 0$, and hazardous region is where $x > 100$. In each iteration, there is an equal probability of $x$ being decremented by 2, and $x$ being incremented by 1.
\end{description}
Several of the programs are based on benchmarks used in prior work focusing on other types of supermartingales \citep{mdranking, chakarovProbabilisticProgramAnalysis2013}. Additionally, there are several benchmarks that are entirely new.
\subsection{Results}
\newcommand{\bmname}[1]{{\ttfamily #1}}
\begin{table}
\caption{Results comparing neural ISMs with Farkas Lemma for different benchmarks. Here, $p$ is the average probability bound generated by the certificate; success ratio is the number of successful experiments, out of 10 repeats, generated by CEGIS with neural ISM; `-' means no result was obtained. We also denote the architecture of the network: $(h_1, h_2)$ denotes a network with 2 hidden layers consisting of $h_1$ and $h_2$ neurons respectively.
\label{tab:results}
\scalebox{0.88}{\begin{tabular}{lcccccc}\toprule
\textbf{Benchmark}& \textbf{Farkas'} & \multicolumn{4}{c}{\textbf{Quantitative Neural Certificates}} & \textbf{Network} \\ \cmidrule(lr){3-6}
& \textbf{Lemma} & \multicolumn{2}{c}{Program-Agnostic} & \multicolumn{2}{c}{Program-Aware} &
\textbf{Arch.}\\ \cmidrule(lr){3-4} \cmidrule(lr){5-6}
& & $p$ & Success Ratio & $p$ & Success Ratio \\
\midrule
\bmname{persist\_2d} & - & $\leq 0.1026$ & 0.9 & $\leq 0.1175$ & 0.9 & (3, 1) \\
\bmname{faulty\_marbles} & - & $\leq 0.0739$ & 0.9 & $\leq 0.0649$ & 0.8 & 3 \\
\bmname{faulty\_unreliable} & - & $\leq 0.0553$ & 0.9 & $\leq 0.0536$ & 1.0 & 3 \\
\bmname{faulty\_regions} & - & $\leq 0.0473$ & 0.9 & $\leq 0.0411$ & 0.9 & (3, 1) \\\midrule
\bmname{cliff\_crossing} & $\leq 0.4546$ & $\leq 0.0553$ & 0.9 & $\leq 0.0591$ & 0.8 & 4 \\
\bmname{repulse} & $\leq 0.0991$ & $\leq 0.0288$ & 1.0 & $\leq 0.0268$ & 1.0 & 3 \\
\bmname{repulse\_uniform} & $\leq 0.0991$ & $\leq 0.0344$ & 1.0 & - & - & 2 \\
\bmname{repulse\_2d} & $\leq 0.0991$ & $\leq 0.0568$ & 1.0 & $\leq 0.0541$ & 1.0 & 3 \\
\bmname{faulty\_varying} & $\leq 0.1819$ & $\leq 0.0864$ & 1.0 & $\leq 0.0865$ & 1.0 & 2 \\
\bmname{faulty\_concave} & $\leq 0.1819$ & $\leq 0.1399$ & 1.0 & $\leq 0.1356$ & 0.9 & (3, 1) \\ \midrule
\bmname{fixed\_loop} & $\leq 0.0091$ & $\leq 0.0095$ & 1.0 & $\leq 0.0094$ & 1.0 & 1 \\
\bmname{faulty\_loop} & $\leq 0.0181$ & $\leq 0.0195$ & 1.0 & $\leq 0.0184$ & 1.0 & 1 \\
\bmname{faulty\_uniform} & $\leq 0.0181$ & $\leq 0.0233$ & 1.0 & $\leq 0.0221$ & 1.0 & 1 \\
\bmname{faulty\_rare} & $\leq 0.0019$ & $\leq 0.0022$ & 1.0 & $\leq 0.0022$ & 1.0 & 1 \\
\bmname{faulty\_easy1} & $\leq 0.0801$ & $\leq 0.1007$ & 1.0 & $\leq 0.0865$ & 1.0 & 1 \\
\bmname{faulty\_ndecr} & $\leq 0.0561$ & $\leq 0.0723$ & 1.0 & $\leq 0.0630$ & 1.0 & 1 \\
\bmname{faulty\_walk} & $\leq 0.0121$ & $\leq 0.0173$ & 1.0 & $\leq 0.0166$ & 1.0 & 1 \\
\bottomrule
\end{tabular}}
\vspace{0.5cm}
\caption{Results showing the time taken in seconds to synthesise ISMs by our method and Farkas' Lemma. For our method, we show the time taken during learning and verification.}
\label{tab:timings}
\scalebox{0.88}{\begin{tabular}{lccccc}\toprule
\textbf{Benchmark}& \textbf{Farkas'} & \multicolumn{4}{c}{\textbf{Quantitative Neural Certificates}} \\ \cmidrule(lr){3-6}
& \textbf{Lemma} & \multicolumn{2}{c}{Program-Agnostic} & \multicolumn{2}{c}{Program-Aware} \\ \cmidrule(lr){3-4} \cmidrule(lr){5-6}
& & Learn Time & Verify Time & Learn Time & Verify Time \\
\midrule
\bmname{persist\_2d} & - & 169.14 & 85.31 & 44.96 & 74.90 \\
\bmname{faulty\_marbles} & - & 114.24 & 29.23 & 15.86 & 28.68 \\
\bmname{faulty\_unreliable} & - & 123.85 & 45.48 & 18.34 & 33.97 \\
\bmname{faulty\_regions} & - & 17.92 & 35.85 & 17.55 & 32.38 \\\midrule
\bmname{cliff\_crossing} & 0.11 & 134.61 & 19.02 & 21.27 & 29.07 \\
\bmname{repulse} & 0.19 & 16.65 & 5.00 & 6.49 & 3.74 \\
\bmname{repulse\_uniform} & 0.19 & 21.28 & 14.18 & - & - \\
\bmname{repulse\_2d} & 0.12 & 122.92 & 64.54 & 15.75 & 47.70 \\
\bmname{faulty\_varying} & 0.36 & 21.74 & 5.06 & 4.71 & 3.28 \\
\bmname{faulty\_concave} & 0.39 & 49.12 & 13.37 & 13.49 & 7.82 \\ \midrule
\bmname{fixed\_loop} & 0.15 & 14.16 & 3.14 & 3.34 & 2.43 \\
\bmname{faulty\_loop} & 0.16 & 25.52 & 3.81 & 3.73 & 2.66 \\
\bmname{faulty\_uniform} & 0.34 & 20.20 & 1.91 & 6.75 & 1.33 \\
\bmname{faulty\_rare} & 0.27 & 25.52 & 4.27 & 3.71 & 2.96 \\
\bmname{faulty\_easy1} & 0.31 & 104.20 & 12.78 & 4.95 & 7.51 \\
\bmname{faulty\_ndecr} & 0.33 & 104.89 & 9.06 & 5.37 & 4.66 \\
\bmname{faulty\_walk} & 0.32 & 15.08 & 4.00 & 6.97 & 3.33 \\
\bottomrule
\end{tabular}}
\end{table}
The results are reported in Table~\ref{tab:results}. The table is divided into three sections. The first section shows the benchmarks where Farkas' Lemma can not be applied, and only our method is capable of producing a bound. The second section shows examples where both methods are able to produce a bound, but our method produces a notably better bound. The third section shows benchmarks where both methods produce comparable bounds.
The table has a column which describes the structure of the neural ISM that was trained. A single number $h$ indicates that the ISM has a single hidden layer with $h$ neurons. A pair $(h_1, h_2)$ indicates that there are two hidden layers with $h_1$ and $h_2$ neurons respectively.
Dashes in the table indicate experiments where a valid ISM could not be obtained. In the case of Farkas' Lemma, there are several cases, where there is no linear ISM for the benchmark. By contrast, program-agnostic and program-aware synthesis could be applied to almost all benchmarks. The one exception is \texttt{repulse\_uniform} where only program-aware verification was unsuccessful. This is due to indicator functions in the post-expectation. These functions are not smooth expressions which posed a problem for the optimiser. This benchmark underscores the value of program-agnostic synthesis, since it does not require embedding the post-expectation in the loss function.
The first section of the benchmarks demonstrates that our method is capable of producing useful results on programs that are out-of-scope for previous methods. Furthermore, it is encouraging that the success ratio is high on all benchmarks. The second and third sections show benchmarks in which Farkas' Lemma can be applied. For these sections, the success ratio of our method is mostly 1.0. A high success ratio is to be expected, since these programs can also be solved by Farkas' Lemma.
The second section shows more complex benchmarks where our method was able to significantly improve upon Farkas' Lemma. The smallest improvement was over 0.04, and the largest improvement was over 0.39. The intuition here is that the neural structure allows more sophisticated ISMs to be learnt, that can better approximate how the reachability probability varies across the state space than is possible with linear templates, and thereby yield tighter probability bounds.
The third section shows relatively simple benchmarks. Here our method produces results that are marginally less tight in comparison to Farkas' Lemma. This is not surprising since our method uses neural networks consisting of a single neuron for these examples, owing to their simplicity. The expressive power of these networks is therefore similar to linear templates.
In summary, the results show our method does significantly better on more complex examples, and marginally worse on very simple examples. This is highlighted in \Cref{fig:farkas_vs_ism}. Each point represents a benchmark. The position on the $x$-axis shows the probability bound obtained by our program-agnostic method, and the $y$-axis shows the probability bound obtained by Farkas' Lemma. Points above the line indicate benchmarks where neural ISMs outperform Farkas' Lemma, and vice versa. The scale is logarithmic to emphasise order-of-magnitude differences.
It is also worth considering the difference between the two loss functions used. Notice that the program-aware algorithm usually performs better than the program-agnostic algorithm, but the improvement is mostly marginal. This is in fact a strength of our method: our data-driven approach performs almost as well as one dependent on symbolic representations, which is promising in light of questions of scalability to more complex programs.
The time taken to run the benchmarks are shown in \Cref{tab:timings}. This is separated into the time taken for learning and the time taken for verification. Unsurprisingly, the time taken for synthesis varies, depending the complexity of the program. Time taken for verification is similar for both program-aware and program-agnostic synthesis. However, time taken for learning is significantly higher in the program-agnostic algorithm. This is not surprising, since the ISM needs to be evaluated many times for each state in program-agnostic synthesis, whereas the post-expectation needs to be evaluated once for each state in program-aware synthesis.
Also, note that Farkas' Lemma is faster than our method. This is expected, as when the ISM certificate is instantiated to the setting of linear templates and programs, the conditions give rise to a convex optimisation problem that can be solved by linear programming \cite{chakarovProbabilisticProgramAnalysis2013}. By contrast, learning neural certificates is a non-convex optimisation problem for which we must resort to gradient descent.
\begin{figure}
\centering
\input{graphs/farkas_vs_program_agnostic}
\caption{Probability bounds generated using program-agnostic neural ISMs and using Farkas' Lemma. We also show the line $y=x$ to indicate which approach outperforms and by how much: above the line indicates that neural ISMs outperform Farkas' Lemma, below the line for the opposite. This demonstrates that neural ISMs can significantly outperform linear templates when a better bound exists, but otherwise is able to achieve similar results.
Note that our approach with program-aware neural ISMs provides even better outcomes, compared with Farkas' Lemma.
}
\label{fig:farkas_vs_ism}
\end{figure}
\subsection{Case Studies}
Having presented the experimental results, we shall look at some benchmarks in more detail.
Recall the \texttt{repulse} program introduced earlier (\Cref{lst:repulse}). While this is a small program, our method is still able to produce a significantly better result than Farkas' Lemma. The linear and neural ISMs are illustrated in \Cref{graph:repulse}. This neural ISM has a single hidden layer consisting of three ReLU components that are summed together. This allows a convex piecewise linear function to be learnt.
\begin{figure}
\begin{minipage}[t]{0.48\linewidth}
\begin{lstlisting}[caption={cliff\_crossing},label={lst:cliff}]
x = 0;
y = 0;
while x <= 50 do
assert(y <= 10);
p ~ Bernoulli(0.9);
x += 1;
if p == 0 then
y += 1
else
if y >= 1 then
y -= 1
fi
fi
od
\end{lstlisting}
\end{minipage}
\begin{minipage}[t]{0.48\linewidth}
\begin{lstlisting}[caption={faulty\_concave},label={lst:concave}]
i = 1;
error = 0;
while i < 10 do
assert(error == 0);
if i < 4 then
p ~ Bernoulli(0.999)
else
p ~ Bernoulli(0.99)
fi;
if p == 1 then
q ~ Bernoulli(0.5);
if q == 1 then
i += 1
fi
else
error = 1
fi
od
\end{lstlisting}
\end{minipage}
\end{figure}
The \texttt{cliff\_crossing} program (\Cref{lst:cliff}) is an interesting benchmark, for which our method is capable of producing a significantly better bound. This program models a robot crossing a road that is adjacent to a cliff. The x-coordinate models how far along the road the robot is, with $x = 0$ being the beginning, and $x = 50$ being the end. Then the y-coordinate models how close to the cliff the robot is, with $y = 0$ being the furthest point away from the cliff, and $y = 10$ being the closest point to the cliff still on the road. Here the neural ISM consists of four ReLU components, and the benefits of a piecewise linear function occur in two dimensions, leading to a clear improvement compared to the linear ISM. These two ISMs are illustrated in \Cref{graph:cliff}. Notice the probability bound at the initial state $(0, 0)$ is significantly lower in the neural ISM.
So far, these examples have used neural ISMs with a single hidden layer. An example that uses two hidden layers is \texttt{faulty\_concave}. The source code can be found in \Cref{lst:concave}. Two hidden layers are necessary in order to obtain performance that is superior to Farkas' Lemma. The benchmark \texttt{faulty\_concave} is similar to \texttt{faulty\_loop}, which has already been introduced. The variable $i$ is initialised to 1. In each successful iteration, it is incremented with probability 0.5 until 10 is reached. In each iteration, there is a small probability of a hardware fault. Unlike \texttt{faulty\_loop}, the probability of failure changes depending on the value of $i$. When $1 \leq i \leq 3$, the probability of failure is 0.001. However, when $4 \leq i \leq 9$, the probability of failure is 0.01, an order of magnitude higher. A linear template cannot account for this conditional behaviour, so Farkas' Lemma produces an overly conservative ISM, which behaves as if the probability of failure were 0.01 in every iteration. Indeed, a neural ISM with a single hidden layer also cannot account for this branching behaviour. This is because such an ISM would always be convex. A concave ISM is needed, which requires at least two hidden layers. This is illustrated in \Cref{graph:concave}.
\begin{figure}
\begin{subfigure}[b]{0.49\textwidth}
\centering
\input{graphs/repulse_ism}
\caption{ISMs for \texttt{repulse}.}
\label{graph:repulse}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\centering
\input{graphs/faulty_concave}
\caption{ISMs for \texttt{faulty\_concave}.}
\label{graph:concave}
\end{subfigure}
\caption{Indicating supermartingales for the \texttt{repulse} benchmark and \texttt{faulty\_concave} as generated using Farkas' Lemma and using neural ISMs. The initial state (dashed line) shows that tighter upper bounds are generated using neural ISMs compared to Farkas' Lemma.
}
\label{graph:cliff}
\end{figure}
\begin{figure}
\begin{subfigure}[b]{0.49\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[mesh/ordering=y varies,colormap/greenyellow,width=3in]
\addplot3 [surf,mesh/rows=11] file {graphs/cliff_crossing_linear.dat};
\end{axis}
\end{tikzpicture}
\caption{The linear ISM for cliff\_crossing.}
\label{fig:cliff-lin}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[mesh/ordering=y varies,colormap/cool,width=3in]
\addplot3 [surf,mesh/rows=11] file {graphs/cliff_crossing_neural.dat};
\end{axis}
\end{tikzpicture}
\caption{The neural ISM for cliff\_crossing.}
\label{fig:cliff-nueral}
\end{subfigure}
\caption{Indicating supermartingales for the \texttt{cliff\_crossing} benchmark as generated using Farkas' Lemma (\ref{fig:cliff-lin}) and using neural ISMs (\ref{fig:cliff-nueral}). The right hand figure illustrates the tighter bounds obtainable through the use of neural templates.
}
\end{figure}
\section{Related Work}
\subsection{Martingales}
Martingales have already been applied extensively in the context of verifying probabilistic programs.
\paragraph{Ranking supermartingales} RSMs have previously been studied to prove positive almost-sure termination \citep{chakarovProbabilisticProgramAnalysis2013}. This is a qualitative reachability property, in contrast to the quantitative properties studied here. In particular, \cite{abateLearningProbabilisticTermination2021} use a CEGIS-based approach to synthesise neural RSMs.
\paragraph{Repulsing supermartingales} RepSMs are another kind of martingale used to prove quantitative reachability properties \citep{DBLP:conf/popl/ChatterjeeNZ17}. They produce a bound using Azuma's inequality. A weakness of RepSMs is that they can only be applied to a narrow range of problems \cite{DBLP:journals/toplas/TakisakaOUH21}. In many other cases, a valid RepSM does not exist, or such a RepSM produces a trivial bound. By contrast, ISMs can be applied to a broad range of probabilistic problems.
\paragraph{Indicating supermartingales} This work introduces ISMs to verify quantitative reachability properties. Similar certificates have been introduced earlier under the names {\em non-negative repulsive supermartingales} and {\em stochastic invariant indicators}~\cite{DBLP:conf/atva/TakisakaOUH18,DBLP:journals/toplas/TakisakaOUH21,DBLP:conf/cav/ChatterjeeGMZ22}. However, existing methods rely on symbolic synthesis approaches which impose further, strong conditions.
Specifically, they require the identification of deterministic invariants that are stronger than $\mathbb{R}^n$. Invariants are required by methods for the synthesis of linear certificates based on Farkas' Lemma to enforce non-negativity, and it is required for the synthesis of polynomial certificates, which additionally imposes compactness to leverage Putinar’s Positivstellensatz.
By contrast, neural ISMs do not rely on further conditions beyond \eqref{eq:spec_ind}, \eqref{eq:spec-dec}, and \eqref{eq:spec-bound}, and leverage the expressivity of neural networks to represent certificates without requiring a deterministic invariant to restrict the domain of the function. While we ensure the soundness of our approach, this additional expressive power limits its theoretical completeness. Still, we have experimentally shown that our method is highly likely to succeed in practice over a broad variety of benchmarks.
\paragraph{Cost martingales} Previous work has used martingales and similar structures to bound the expected value of a variable in program state, when a probabilistic program terminates. This variable can be interpreted as a reward or a cost \citep{ngoBoundedExpectationsResource2018, wangCostAnalysisNondeterministic2019b}. This work has been extended to higher moments \citep{wangCentralMomentAnalysis2021}. These techniques uses linear and semidefinite programming for synthesis, unlike this work which uses learning in a CEGIS architecture for synthesis.
\subsection{Probabilistic Model Checking}
A well-developed approach to reasoning about probabilistic systems is probabilistic model checking \citep{kwiatkowskaAdvancesChallengesProbabilistic2010a, katoenProbabilisticModelChecking2016}. A well established probabilistic model checking tool is PRISM \citep{kwiatkowskaPRISMVerificationProbabilistic2011a}. This approach encodes properties using probabilistic extensions to temporal logics such as LTL and CTL. Verification occurs through a combination of graph analysis and numerical approximation. They can be applied to systems modelled as discrete-time Markov chains (DTMCs), continuous-time Markov chains (CTMCs) and Markov decision processes (MDPs). Probabilistic model checking is usually applied to finite state spaces, whereas this work looks at programs with infinite state spaces, and programs that combine discrete and continuous variables.
\subsection{Pre-Expectation Calculus}
The weakest pre-expectation calculus is a formalism for reasoning about probabilistic programs \citep{kozenProbabilisticPDL1985, morganProbabilisticPredicateTransformers1996, mciverAbstractionRefinementProof2004}. It is an extension of predicate transformer semantics for classical programs \citep{dijkstraGuardedCommandsNondeterminacy1975}. The calculus relates expressions to their expected values after a program runs. The pre-expectation calculus is connected to martingales, and this is studied in \cite{harkAimingLowHarder2020}. In order to reason about the weakest pre-expectations of loops, invariants are used.
Recent work concentrates on automatically finding weakest pre-expectations. \cite{gretzPrinsysQuestProbabilistic2013} present a method where finding an invariant from a template is reduced to first-order logic constraints, that are given to a constraint solver to handle. \cite{chenCounterexampleGuidedPolynomialLoop2015} use counterexample refinement and Lagrange interpolation to find polynomial invariants. \cite{wangPMAFAlgebraicFramework2018} introduce a method for the static analysis of probabilistic programs, based on algebraic structures. This method was applied to generate linear invariants.
Most recently, a CEGIS-like method has been used to learn invariants \citep{baoDataDrivenInvariantLearning2022}. This work is similar to the work presented here in that it is a data-driven approach using learning, uses a computer algebra system, and uses counterexamples to explore the state space. One difference is that the work uses regression trees as models, as opposed to neural networks. A limitation of this work is that it only supports discrete distributions, whereas this work also looks at probabilistic programs, that sample from continuous distributions.
\subsection{Dynamical Systems}
While our work looks at discrete-time stochastic systems, CEGIS-based methods have also been used to verify continuous-time systems, specified with differential equations. CEGIS has been used to verify stability for such systems by synthesising Lyapunov functions with polynomial and neural templates \citep{ahmedAutomatedSoundSynthesis2020, abateFOSSILSoftwareTool2021, DBLP:journals/csysl/AbateAGP21}. Further, safety has been verified with barrier certificates \citep{jagtapFormalSynthesisStochastic2019, peruffoAutomatedFormalSynthesis2020}.
\section{Conclusion}
Our method is the first to use neural networks as certificates for quantitative reachability analysis of probabilistic programs, to upper bound the probability that a target set is reached in finitely many steps. We exploit the expressive power of neural networks as templates for indicating supermartingales to obtain tight approximations of the reachability probability, without the need for supporting deterministic invariants. Our program-agnostic synthesis method uses gradient descent optimisation of a loss function defined over program executions to discover neural certificates, whose soundness we verify using satisfiability modulo theories in a counterexample-guided inductive synthesis loop. We provide a prototype implementation, and show the advantages of neural certificates over a diverse set of benchmarks, including their applicability to programs that lack linear/polynomial certificates, and their ability to attain tighter probability bounds on reachability. Our approach is suited to extension to further quantitative verification questions, such as obtaining probability bounds on a wider range of temporal properties beyond reachability \cite{DBLP:books/daglib/0020348}, and bounds on other types of quantities such as expected accrued costs \citep{ngoBoundedExpectationsResource2018, wangCostAnalysisNondeterministic2019b, wangCentralMomentAnalysis2021}.
| {'timestamp': '2023-01-18T02:13:47', 'yymm': '2301', 'arxiv_id': '2301.06136', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06136'} | arxiv |
\section{Introduction}
In recent years, novelty detection, or the identification of unusual, unknown, and out-of-distribution data, has attracted a considerable amount of attention across various disciplines. This concept is deeply rooted in neurophysiology and seeks to model the way human brains learn from, categorize, and adapt to new stimuli.
In the cybersecurity domain, for example, intrusion detection systems (IDS) aim to identify if a network is under attack by detecting anomalies in network flows. Anomaly detection approaches label behavior that deviates from a normal model as anomalous, often making an implicit assumption that anomalies correspond to intrusive or problematic events. However, the conflation between anomalous events and intrusive events often accounts for higher than average false positive rates of anomaly-based IDS.
On the other hand, novelty detection is the task of classifying test data (at inference time) that differ in some respect from the data that are available during training of a machine learning classifier for some specific task. This may be seen as “one-class classification,” in which a model is constructed to describe normal training data. The novelty detection approach is typically used when the quantity of available abnormal data is insufficient to construct explicit models for non-normal classes \cite{Pimentel}.
In this paper, we present a novel approach to feature identification in support of novelty detection in the IDS setting using survival analysis techniques. We first train various machine learning classifiers to identify both benign traffic and known attack types using representative network flows of both traffic types. Then, we inject unknown attack type data and examine how the classifier identifies these attacks based on the features of the novel network flows. To this end, we use key concepts from survival analysis to analyze the features of the flow that are most influential in novelty detection.
The outline of the paper is structured as follows. In Section \ref{RelWorks}, we discuss relevant literature on similar research in this domain. In Section \ref{Methods}, we discuss our methodology and give an overview of the performed experiments including how classifiers are chosen, trained, and injected with novel attack type data. In Section \ref{Results}, we discuss the resulting observations with emphasis on the application of survival analysis to assess feature identification and the interpretation of the different coefficients therein. In Section \ref{DisLim}, we give a brief description of the limitations of such an implementation, and we mention some potential directions for future work in Section \ref{Conc}.
\section{Related Works}\label{RelWorks}
Novelty detection, which is often also referred to as out-of-distribution (OOD) detection, is a task of identifying whether a test input is drawn far from the training distribution (in-distribution) or not. In general, the novelty detection problem aims to detect OOD samples where a detector is allowed access only to training data. Novelty detection is a classic yet essential problem in machine learning, with a broad range of applications, including medical diagnosis \cite{caruana2015intelligible}, fraud detection \cite{phua2010comprehensive}, and autonomous driving \cite{eykholt2018robust}.
Traditional machine learning techniques such as Support Vector Machine (SVM), Random Forest \cite{zhang2008random} and Adaptive Boosting \cite{hu2013online} have been used by researchers for constructing machine learning classifiers for the problem of network intrusion detection \cite{9006122}. However, the downside of these approaches, in general, is that they suffer from high false positive rate and low detection rate. These approaches are often not scalable to large datasets and the validation accuracy rarely scales as the size of the data increases.
Deep learning techniques are increasingly growing in popularity to address these problems. The CNN-BiLSTM model \cite{sinha2020efficient} presents an effective approach which stacks convolutional neural networks and bi-directional long short-term memory (LSTM) layers to learn and detect attacks in network flows. The DL-IDS model \cite{sun2020dl} is a hybrid approach to extract the spatial and temporal features of network flows and to provide a better intrusion detection system. The HAST-IDS model \cite{wang2017hast} learns the low-level spatial features of network flows using deep convolutional neural networks and then learns high-level temporal features using long short-term memory networks. Several additional models exist in the literature such as LuNet \cite{wu2019lunet} and DANTE \cite{ma2020dante}, and recent work shows success in using one-dimensional convolutional neural networks for detecting attacks in raw network packet captures rather than network flows (\textcite{mlnet}.
Survival analysis \cite{ref67} is a subfield of statistics that aims to model data where the outcome is the time until the occurrence of an event of interest. It was originally used in health data analysis and has since been employed in many applications, such as predicting student dropout time \cite{ameri2016survival} and insider threat detection \cite{alhajjar2021survival}. We extend these lines of effort here and devise yet another use case where survival analysis deems very useful for the task of analyzing a classifier's response when introduced to OOD data samples.
\section{Methodology}\label{Methods}
In this section, we describe the computational experiments performed for feature identification.
\subsection{Dataset Description}
In what follows, we adopt the Canadian Institute for Cybersecurity's Intrusion Detection Evaluation Dataset (CIC-IDS2017). CIC-IDS2017 is a comprehensive dataset containing both benign and up-to-date network attack data in the form of Wireshark PCAP files. The traffic is representative of naturalistic human behavior as it generates background traffic from the routine behaviors of 25 typical users interacting with common protocols such as HTTP, HTTPS, FTP, email, etc. \cite{Sharafaldin2018}. The data also covers a diverse set of cyber attack scenarios by recreating and executing network attack types from a list of common attack families using various open-source tools and code such as Patator, GoldenEye, Metasploit, etc. The attack profiles include \textbf{}
In what follows, we adopt the Canadian Institute for Cybersecurity's Intrusion Detection Evaluation Dataset (CIC-IDS2017). CIC-IDS2017 is a comprehensive dataset containing both benign and up-to-date network attack data in the form of Wireshark PCAP files. The traffic is representative of naturalistic human behavior as it generates background traffic from the routine behaviors of 25 typical users interacting with common protocols such as HTTP, HTTPS, FTP, email, etc. \cite{Sharafaldin2018}. The data also covers a diverse set of cyber attack scenarios by recreating and executing network attack types from a list of common attack families using various open-source tools and code such as Patator, GoldenEye, Metasploit, etc. The attack profiles include Brute Force Attack, Heartbleed Attack, Botnet Attack, DoS Attack, DDoS Attack, Web Attack and Infiltration Attacks.
Each of these broad attack families also consists of specific attack types using various tools and techniques. For example, the web attack class contains three individual attack types: brute force web attack, cross-site scripting, and SQL injection. For the experiments below, we focus on these individual attack types to get a more consistent training distribution.
The dataset also includes network traffic analysis data in the form of labeled flows extracted using the CICFlowMeter, a network traffic flow generation tool. CICFlowMeter analyzes raw network traffic based on time stamp, source/destination IP's, source/destination ports, protocols, and attack type to generate 84 network traffic features \cite{Lashkari2018}. These features include details about a particular communication such as flow duration, packet size statistics, various flag counts, flow length metrics, number of packets/bytes sent in a particular time window, etc. For our experiments, we chose to focus strictly on the network flow components of the CIC-IDS dataset since these features are a representative summary of a particular network communication. This allowed us to properly analyze the features of a network communication that are most influential in novelty detection.
In this study, we train multiple machine learning classification models to detect instances of novelty in network flows. Specifically, we make use of the Random Forest Regressor, Bayesian Ridge, and Linear Support Vector Regression. We first split the CIC-IDS data up by individual attack type and tool such as DoS Hulk, FTP-Patator, SQL Injection, etc. Next, we train each of our three models using flows from both benign traffic and one single attack type. After training, we test the accuracy of the model's predictions to ensure that it has been adequately trained to distinguish between benign traffic and the corresponding attack type. We then inject unknown, or novel, attack type flows and assess how the model classifies this data. Since we use regression models, the continuous output variable represents how close the classifier considers this data is to each of the known classes. For example, if a predicted value of 0.45 is returned, this means that the classifier believes this flow to be ``benign" with very low confidence since it is a closer match to 0 than 1 but lies around the middle point. We define this classifier confusion within a given interval as ``novelty detection".
\subsection{Survival Analysis}
Survival analysis is a subfield of statistics that focuses on estimating the time until, and frequency of, a particular event of interest. One of the most common applications is the context of medical studies, in which survival analysis techniques are used to predict a patient's survival time based on various features such as sex, age, and disease stage. However, the use of these statistical models stretches far beyond medicine. Survival analysis has particularly relevant applications in various technology disciplines for purposes such as estimating the time until a system failure, insider threat instance, or data breach occurs \cite{alhajjar2021survival}. These techniques also deal with the issue of censoring, which occurs when the event of interest is never observed due to withdrawal from the study or the study ending prior to that event's potential occurrence. In any case, our observation, $Y$, is either survival time, $T$, or censoring time, $C$. Using the status indicator $\delta$, if $\delta=1$, we observe true survival time, otherwise if $\delta=0$, we observe censoring time \cite{JamesBook}.
\begin{equation}Y = \text{min}(T,C),\end{equation}
\begin{equation}\delta = \begin{cases}1 & \text{if } T\leq C\\ 0 & \text{if } T>C.\end{cases}\end{equation}
There are three main functions used in survival analysis:
\begin{itemize}
\item Survival function: $S(t) = Pr(T \geq t)$
\item Cumulative death distribution function: $F(t) = 1 - S(t)$
\item Death density function: $f(t) = F'(t)$ or $f(t) = \frac{dF}{dt}$
\item Hazard function: $\frac{f(t)}{S(t)}$
\end{itemize}
\subsubsection{Cox Proportional Hazards Model. }
The Cox proportional hazards model is commonly used to investigate the association between survival time and one or more predictor variables. Since this model requires no knowledge of the underlying distribution, the baseline hazard functions of individuals are assumed to be the same. For each data point in the Cox model, the hazard function can be defined by:
\begin{equation} \label{eq1}
h(t) = h_0(t)e^{\beta.X_i},
\end{equation}
\noindent where $h_0(t)$ represents the baseline hazard function, $X_i$ is the feature vector (where $i$ runs over the size of the dataset), $\beta$ is the corresponding coefficient vector, and $\beta .X_i$ is the vector scalar product. In this equation, the baseline hazard function can be an arbitrary non-negative function since the baseline hazard is assumed to be the same for every data point. From this equation, it follows that the survival function can be computed as:
\begin{equation}
S(t) = S_0(t)e^{\beta.X_i}.
\end{equation}
Cox model parameters are estimated by maximizing the partial likelihood with respect to $\beta$. This partial likelihood is simply a product of the probabilities over all uncensored observations and can be constructed as:
\begin{equation}
PL(\beta) = \prod_{\delta_i=1}\frac{e^{\beta.X_i}}{\sum_{t_j\geq t_i}e^{\beta.X_j}}.
\end{equation}
This calculation is valid regardless of the true baseline hazard value, making this a very flexible and reliable model. In addition to coefficient estimates, we can also use this model to obtain other valuable model outputs such as associated p-values and confidence intervals \cite{JamesBook}.
\subsubsection{Kaplan-Meier Estimates. }
The Kaplan-Meier curve is a visual representation of the survival function that represents the probability of survival after time $t$. This estimate is based on the quantity of event occurrences in the actual length of observed time. While Kaplan-Meier estimates offer a simplistic way to estimate the survival function, this estimate becomes slightly more complex in the presence of censored data. To overcome this, we let $T_1 < T_2 < ... < T_k$ represent a set of ordered event times among $N$ non-censored instances, where $k \leq N$ meaning that there are $N-k$ censored times. For each $i = 1,2,...,k$, we let $d_i$ represent the number of actual observed events in the time $T_i$, and $r_i$ represent the number of instances whose actual survival time $T$ or censored time $C$ is greater than or equal to $T_i$. We let $c_{i-1}$ represent the number of censored instances that occurred between the time period $T_{i-1}$ and $T_i$ which allows us relate the terms with the recursion $r_i = r_{i-1} - d_{i-1} - c_{i-1}$.
This setting allows us to overcome the issue of censoring by allowing the conditional probability of surviving beyond time $T_i$ to be defined as:
\begin{equation} \label{eqn: 7}
Pr(T_i) = \frac{r_i - d_i}{r_i} = 1-\frac{d_i}{r_i}.
\end{equation}
The conditional property represented in Equation 7 leads to the Kaplan-Meier estimator of the survival curve:
\begin{equation} \label{eq:8}
\widehat{S}(t) = \prod_{T_i < t} Pr(T_i) = \prod_{T_i < t} (1-\frac{d_i}{r_i}).
\end{equation}
\subsection{Experimental Design}
We seek to investigate the features that would be of most influence to a novelty detection agent. From here on, we call $D_{pre}$ the pre-novelty distribution, which consists of flows from a single known attack type as well as benign traffic. Similarly, we call $D_{post}$ the post-novelty distribution, which consists of flows from a new attack type \cite{Pinto2022}.
For the proposed experiments, we set an arbitrary prediction threshold of 40-60\%, or 0.40 to 0.60, to indicate that a classifier has detected novelty. In this case, we define the ``death", or event of interest, as a classifier's prediction of injected $D_{post}$ data in that range. After training each classifier on flows from $D_{pre}$, we assess its predictions of unknown attack data. To do this, we first create a sequence of novel network activity by selecting a random sample of 100 network flows of a new attack type from the $D_{post}$ data. Each of these sequences is equivalent to one ``patient" in the context of survival analysis. Next, we create a dataset of 500 sequences, each containing 100 $D_{post}$ network flows, and feed each sequence to the classifier individually. Each flow's value is then predicted by the classifier as a decimal number between $0$ and $1$. If the predicted label falls within the defined range, we consider that sequence ``dead", meaning that the classifier at hand detected novelty as defined above. If it falls outside of that range on either side, the classifier moves on to the next flow in the sequence.
While we understand that misclassification of novel, malicious traffic as benign has greater consequences than the reverse case where a unknown attack is classified as a known attack, examining cases of misclassification is not the objective of the current work. Instead, we are analyzing cases of classifier confusion when faced with OOD samples. Survival time, or the index in the sequence at which the novelty was detected, for each of the 500 sequences is recorded. If novelty is not detected in any of the 100 flows, the instance is considered censored and survival time is set to be the length of the sequence. We repeat 10 iterations of this experimental procedure for each combination of $D_{pre}$ and $D_{post}$ attack data to create the corresponding Kaplan-Meier curves and Cox coefficient estimates.
\begin{table}[thb]
\centering
\begin{center}
\resizebox{\columnwidth}{!}{
\begin{tabular}{ |c|c|c| }
\hline
Combination & Training Data Types & Novel Attack Type \\
\hline
1 & Benign, DoS Hulk & Brute-Force Web \\
2 & Benign, DoS Hulk & FTP-Patator \\
3 & Benign, Portscan & Web XSS \\
4 & Benign, Portscan & DoS GoldenEye \\
\hline
\end{tabular}}
\end{center}
\caption{Data combinations used for training and injection.}
\label{fig: table1a}
\end{table}
To analyze the features in the $D_{post}$ data that contributed to classifier confusion in each experimental iteration, we compare the feature values of the specific flow that was classified in novelty range to the mean of the corresponding feature values in the $D_{pre}$ data. This allows us to examine how heavily a feature's distance from the known distribution influences the confusion of the classifier.
\begin{equation}
x_i = [f_1^i, f_2^i, f_3^i, ..., f_{84}^i],
\end{equation}
\begin{equation}
\overline{x_{pre}} = [\bar{f_1}, \bar{f_2}, \bar{f_3}, ..., \bar{f_{84}}],
\end{equation}
\begin{equation}
y = |x_i - \overline{x_{pre}}|.
\end{equation}
Here, $x_i$ represents the feature vector of the detected novel flow, $\overline{x_{pre}}$ is the vector of the mean feature values for the entirety of the $D_{pre}$ dataset, $f_i$ represents the flow's 84 individual feature values, and $y$ represents the absolute difference between the feature value of the detected novel flow, to the mean of the corresponding feature value in the $D_{pre}$ data.
Next, we analyze the results of this experiment using both the Cox model and Kaplan-Meier estimate. To generate the Kaplan-Meier curves, we use the $D_{pre}$ flow indices to represent time. We divide the $D_{pre}$ flow indices into intervals, $t_0 < t_1 < ... < t_m$, where $t_0$ and $t_m$ are the starting and ending indices, respectively. In the terminology of Section 2, we define $d_j$ as the number of sequences in which novelty is detected by the classifier at index $t_j$ and $n_j$ as the number of sequences where novelty is not yet detected at index $t_j$. Using Equations 7 and 8, we can estimate the survival function as:
\begin{equation}
S(i_{j+1}) = S(i_j) * (1-\frac{d_j}{n_j}).
\end{equation}
To apply the Cox proportional hazards model, we label each of the 500 sequences in the experiment as having detected novelty or not using binary indicators, 1 or 0, respectively. We use the 84 features of the $D_{post}$ flows for identification of risk factors associated with novelty detection. After maximizing the partial likelihood in Equation 5, we can set the derivative of that equation with respect to $\beta$ equal to zero. This allows us to estimate the coefficients for each feature and, as a result, the baseline hazard function.
\begin{equation}
ln(\frac{h(t)}{h_0(t)}) = \beta.X_i = \beta_1.X_{i1} + \beta_2.X_{i2} + ... + \beta_{84}.X_{i84}.
\end{equation}
\section{Results}\label{Results}
The mean resulting Cox proportional hazard coefficient estimates, $\beta$, from each of the 10 trials for each classifier and attack combination are shown in \Cref{fig: table1}. These results shed light on which network flow characteristics have the greatest impact on novelty detection for each classifier and attack combination, since coefficient estimates, $\beta$, measure the impact of each feature on the probability of novelty detection. For interpretability, we also compute the hazard ratios ($HR$) for each feature by exponentiating the parameter estimates ($\beta$) using the technique $e^\beta$. For any parameter estimate, if $HR<1$, the predictor is said to be protective, or associated with improved survival. In this case, this means that the individual flow feature is less likely to confuse the classifier and instead leads to classification in one of the two known categories. Conversely, if $HR>1$, the predictor is associated with increased risk, and therefore decreased survival. In the context of network systems, this means that the individual flow feature is more likely to confuse the classifier and lead to novelty detection.
\begin{table}[thb]
\centering
\begin{center}
\resizebox{\columnwidth}{!}{
\begin{tabular}{ |c|c|c|c| }
\hline
Classifier & Feature & $\beta$ & HR \\
\hline
Random Forest & PSH Flag Count & 0.157 & 1.170\\
& ACK Flag Count & -0.580 & 0.560\\
& URG Flag Count & -0.105 & 0.900\\
& Down/Up Ratio & 1.506 & 4.509\\
\hline
Bayesian Ridge & PSH Flag Count & 31.401 & $4.3x10^{13}$\\
& ACK Flag Count & -128.528 & $1.5x10^{-56}$\\
& URG Flag Count & -23.333 & $7.4x10^{-11}$\\
& Down/Up Ratio & 8.811 & $6.7x10^{3}$\\
\hline
Linear SVR & PSH Flag Count & 0.194 & 1.121\\
& ACK Flag Count & -0.813 & 0.444\\
& URG Flag Count & -0.144 & 0.866\\
& Down/Up Ratio & 0.682 & 1.978\\
\hline
\end{tabular}}
\end{center}
\caption{Cox model results for classifiers trained on DoS Hulk data and injected with Brute-Force web attack flows. }
\label{fig: table1}
\end{table}
The resulting Kaplan-Meier curves for each attack combination and classifier allow us to estimate the probability of the classifier detecting novelty at sequence index or time $t$ and are shown in \Cref{fig:rf}.
\begin{figure}
\centering
\includegraphics[width=240pt]{images/RF_allattacks.png}
\caption{Kaplan-Meier curves for Random Forest classifier with each attack combination.}
\label{fig:rf}
\end{figure}
\section{Discussion and Limitations}\label{DisLim}
The results for the Cox model shown in \Cref{fig: table1} highlight the impact of the network features on the likelihood of novelty detection for each classifier. After applying the Cox model, we found four consistently non-zero coefficients across all classifiers and attack types which allowed us to narrow down the most influential features. For example, holding all other factors constant, there is a 17\% increase in the likelihood of novelty detection relative to a one unit increase in the number of packets with a PSH flag contained in the flow. Conversely, there is a 48\% decrease in the likelihood of novelty detection per one unit increase in the flow's URG flag count.
Given that the signs of the coefficients remain the same regardless of the classifier type, we summarize the findings as follow:
\begin{enumerate}
\item Higher PSH flag counts are positively correlated with novelty detection for this attack combination. One way to justify such a relationship is that PSH flags are used to indicate that data should be pushed to the receiving host immediately. They are typically used in TCP connections to inform the receiver that the sender has no data left to send. Because of their purpose, they are typically not used in large quantities in DoS attacks, therefore they are unfamiliar to the classifier and more likely to indicate a novel network attack.
\item Higher ACK flag counts are negatively correlated with novelty detection. This can be explained by the fact that this DoS attack floods the target system with an abundance of connection initiation requests so it is probable that the target sends many ACK replies before becoming overwhelmed and losing availability. Since DoS data was used for training, the classifier is very familiar with ACK flags. When it recognizes higher ACK flag counts in the injected brute-force web attack data, it is more likely to misclassify it as a known instance.
\item Similarly to ACK flags, the higher the URG flag count, the less likely the flow is to confuse the classifier and indicate novelty. Since URG flags are commonly used in DoS attacks to quickly overwhelm the server by indicating that the requests should be prioritized, this again means that the classifier is familiar with these types of flags, so higher counts would lead to misclassification.
\item Higher file download/upload ratios are positively correlated with novelty detection. This is due to the fact that the DoS Hulk attack did not include downloads or uploads of any kind. Therefore, these types of packets are likely deemed unknown, unfamiliar, and ultimately correspond to a novel attack type.
\end{enumerate}
Using the Kaplan-Meier curves shown in \Cref{fig:rf}, we see each classifier's success at detecting novelty with each attack combination presented in \Cref{fig: table1a}. To better understand this observation, we examine Figure 1. From these curves, we can draw a few conclusions about the Random Forest classifier:
\begin{enumerate}
\item The Random Forest classifier detects novelty the quickest for attack combination 1, with 100\% detection, or ``death", by flow index 5. This included 80\% detection at index 0.
\item For attack combination 2, the Random Forest classifier only detects novelty in approximately 5\% of the flows by index 100, making the other 95\% of these instances censored.
\item For attack combination 3, the classifier detects approximately 98\% novelty by index 100.
\item Lastly, for attack combination 4, the classifier reaches 100\% detection by index 14 which includes approximately 35\% detection at index 0.
\end{enumerate}
While these results shed light on the various features of network flows that can assist in novelty detection, there are a few limitations to this study. Firstly, our experiments do not directly account for misclassifications of novel attack types as benign. Since we focus specifically on novelty detection, we saved these results for future analysis in an upcoming paper. Secondly, we found that many other types of classifiers actually do not detect novelty at all with any combination of attack types. This could lend itself to future work in investigation of the various classifier decision making processes that lead to the classification of these novel attacks as known. Lastly, our experiments do not represent the entirety of the CIC-IDS dataset. This is because many attack types are severely underrepresented which may skew the results and draw statistically insignificant conclusions. For example, there are only 11 labeled Heartbleed flows in the entirety of CIC-IDS dataset, making it difficult to train or test on this particular attack type.
\section{Conclusion}\label{Conc}
With the growing importance of machine learning for use in the cybersecurity world, the concept of novelty detection is more important than ever. Given the underexplored nature of this issue, it is important to examine how commonly used classifiers may be adapted to detect novelty. Hence, understanding and gaining insight into the features that may help IDS increase their effectiveness against zero-day attacks is an essential task. In this paper, we introduced a survival analysis based approach to discovering the most influential network flow features in various classifiers' novelty detection ability. We used the CIC-IDS dataset to train classifiers, inject unknown attack types, assess the classifiers ability to detect novelty, and as a result, the features that play the greatest role in that detection. Our results showed that PSH, URG and ACK flag counts, as well as download/upload ratios, play a role in novelty detection across all classifiers and attack combinations.
There remain many challenges in the field of IDS development and resilience. First, there are not many publicly available and easily accessible solutions to novelty detection, making them much more difficult to implement. Second, there is a vast misunderstanding of the difference between novelty detection and anomaly detection and their implementations. This often causes these techniques to be overlooked by IDS developers. It is impractical to train any given system on every single attack that has ever happened, along with every normal behavior. In addition to this, balancing the distributions of the many classes in a training dataset poses a significant challenge moving forward. Lastly, there is a lack of realistic datasets that represent up-to-date attack type data. This makes it impossible to train robust IDS, as these systems rely on known attack signatures that must be continually updated to detect the latest attacks. Moreover, it severely limits the test bed for novelty detection agents in this domain.
\section*{Acknowledgements}
This work is supported in part by the National Security Agency Laboratory for Advanced Cybersecurity Research under Interagency Agreement No. USMA 21035 and the U.S. Army Combat Capabilities Development Command (DEVCOM) Army Research Laboratory under Support Agreement No. USMA 21050. The views expressed in this paper are those of the authors and do not reflect the official policy or position of the United States Military Academy, the United States Army, the Department of Defense, or the United States Government.
\printbibliography
\end{document}
| {'timestamp': '2023-01-18T02:16:08', 'yymm': '2301', 'arxiv_id': '2301.06229', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06229'} | arxiv |
\section{Introduction} \label{intro}
\begin{figure}[t]
\begin{center}
\includegraphics[width=\linewidth]{img-cnn-arch-relationship.eps}
\caption{CNN-based Animal Behavior Classification Frameworks and Animal Pose Estimation and Tracking Methods Organized by the Neural Network Architectures They Build Upon. Representative Examples Shown.}
\label{fig:venndiagram}
\end{center}
\end{figure}
This survey presents a comprehensive overview of CNN architectures for human action recognition and human pose estimation from videos. The paper traces the development and adaptations of the subset of networks that have been extended for animal behavior classification. Action recognition aims to identify and classify the activity in a trimmed video. The output of an action recognition algorithm is a set of class labels for each trimmed video. When the class label is one of a set of pre-defined expressions that occur in response to a stimuli (behavior) ~\cite{coria2022neurobiology}, the task is behavior classification. Pose estimation is the task of determining a subject's position and orientation in an image frame. Pose-based action recognition methods use pose estimation predictions (image frame coordinates) to classify body movements. Pose estimation may be used to identify joint positions before classifying behavior. Action recognition is critical for analyzing motion in videos for disciplines such as robotics, security, and biomedical engineering. These methods use labels. Because manual labeling is time consuming, and introduces human bias and reproducibility issues, there is a growing interest in developing action recognition methods for fully unsupervised behavior classification that have less complex systems. A fully unsupervised method would not require labels, hand-crafted features, or additional pose estimation steps. This survey reviews CNN-based human action recognition and pose estimation methods and their extensions to animal behavior classification with a particular focus on open problems with unsupervised animal behavior classification in neuroscience.
\vspace{10pt}
\noindent\textbf{Our contributions include:}
\begin{enumerate}
\item A review of \hbox{2D}, two stream and \hbox{3D} CNNs that detect and analyze spatio-temporal features in videos for action recognition and pose estimation (Sections~\ref{sec:hpe} and~\ref{sec:actionrecognition}), including open challenges, design decisions, key contributions, and performance on benchmark datasets (Tables~\ref{tab:pose-estimation-summary-table} and~\ref{tab:action-recognition-summary-table}). The review focuses on the subset of methods that have extensions for classifying animal behavior.
\item An organizational strategy for categorizing a representative set of animal behavior classification frameworks by the level of supervision they require, considering their dependency on handcrafted features, labels, pose estimation and learning strategies (Section~\ref{sec:taxonomy}). Key contributions and performance on benchmark datasets are summarized (Tables~\ref{tab:poseaccuracy},~\ref{tab:table-animal-pose-estimation}, and~\ref{tab:table-animal-action}).
\item Illustrations that permit visual comparison of animal behavior classification frameworks, including system components like pose estimation techniques, neural network architectures and dimensionality reduction and clustering algorithms (Figures~\ref{fig:posebased},~\ref{fig:SNoPE}~\ref{fig:USNoPE}). Diagrams that show commonalities between underlying CNN architectures (Figures~\ref{fig:venndiagram},~\ref{fig:actionrecognition}), and relationships with the human action recognition and pose estimation methods they build upon (Figure~\ref{fig:animalbehaviormodelaction}).
\item A discussion of opportunities to develop or extend action recognition methods motivated by open problems with unsupervised animal behavior classification.
\end{enumerate}
\subsection{Motivation}\label{sec:motivation}
Action recognition is an important research area in computer vision that continues to experience significant growth. This is due in part to its broad application in fields such as robotics, security, and biomedical engineering for tasks such as human-robot collaboration~\cite{Li2021d}, surveillance~\cite{Babiker17}, and behavior analysis~\cite{Segalin2021,Arac2019,coria2022neurobiology}. Large publicly available video datasets~\cite{Karpathy2014} with high inter-class variability have facilitated the development of deep learning algorithms for video classification that are more robust and effective. However, open problems remain.
This paper focuses on action recognition methods that use CNNs to learn spatio-temporal features from videos. Spatio-temporal features are key points that exhibit spatial variations in color intensities within a frame, and temporal variation between frames. Neural networks detect these features and use them to classify video clips. Such features may be learned through network architectures that have both a spatial stream that operates on individual frames, and a temporal stream that operates on motion information. Other modifications add a temporal dimension to the filters and pooling kernels to create \hbox{3D} CNNs.
Action recognition algorithms operate on trimmed videos. These trimmed videos contain one action instance. Untrimmed videos are long unsegmented videos, containing multiple action instances~\cite{Vahdani2022} (Figure~\ref{fig:trimmedanduntrimmed}). Action detection (localization, or spotting) is a related research area that locates actions of interest in space and (or) time in both trimmed and untrimmed videos. Before classifying the actions in an untrimmed video, the start and end time of each action is determined. Many classification frameworks we review in Section~\ref{sec:taxonomy} operate on untrimmed videos. A small number may even incorporate networks inspired by action detection. However, they generally produce per-frame labels, without the complexities of an additional temporal action detection~\cite{Vahdani2022} step to segment videos. For this reason, we do not include action detection in our review. DeepEthogram~\cite{Bohnslav2021} is an interesting example that demonstrates that action recognition and action detection are highly related. The pipeline uses a CNN developed for action recognition to estimate motion features, and then classifies the spatial and motion features in each frame using a network designed for action detection. The result is a per-frame set of behavior class labels.
\begin{figure}[t]
\begin{center}
\includegraphics[width=1\linewidth]{img-trimmed_and_untrimmed.eps}
\caption{Trimmed and Untrimmed Videos: (top row) The first and last frames from clipped videos of (left) a basketball dunk and (right) a basketball shot from UCF101~\cite{Soomro2012}. (middle row) Four frames $60$ frames apart from an untrimmed video from THUMOS14~\cite{Jiang2014}. (bottom row) Four frames $60$ frames apart from a untrimmed animal behavior dataset~\cite{Jhuang2010}.}
\label{fig:trimmedanduntrimmed}
\end{center}
\end{figure}
Our review includes three types of learning models, categorized by the training data they operate on: \emph{supervised} that require labeled data, \emph{semi-supervised} that use both labeled and unlabeled data, and \emph{unsupervised} that operate on unstructured data without labels.
Figure~\ref{fig:trimmedanduntrimmed} (top row) shows class labels for \emph{shot} and \emph{dunk}. Figure~\ref{fig:trimmedanduntrimmed} (bottom row, left to right) shows animal behavior classification labels for \emph{rear}, \emph{walk} , \emph{walk} , \emph{walk}. The label \emph{rear} indicates that the animal stands on hind legs.
Most methods presented in this review require some level of supervision. However, using predefined labels is limiting, as micro-scale actions that are not in the labeled dataset but exist in the unstructured data, may go undetected. Direct processing on raw pixels would enable fewer processing steps, without the need for hand-crafted features to produce consistent poses for different subjects.
There are many challenges with action recognition from videos. It is challenging to trace the motion of body parts which are occluded in intermittent frames. Artifacts from variations in lighting or varying parameters from camera or devices (that have different imaging quality and frame rates) add additional challenges. Many pose-based systems do not generalize well to \emph{in-the-wild} conditions.
Behavior analysis is important~\cite{MATHIS20201,Anderson2014} with many real-world applications. Recent projects extend human action recognition for detecting and interpreting behavior in small animals. Additional challenges exist in this domain~\cite{Anderson2014}. Tracking multiple subjects that have identical appearance is challenging, often requiring specialized tracking devices that are distracting. Many systems incorporate several machine learning tasks such as object detection, pixelwise segmentation, and dimensionality reduction. Thus, classification systems are often complex, requiring many processing steps. We present an organizational strategy for animal behavior classification that considers system components and learning strategies in addition to inputs.
There is a significant number of CNN-based action recognition and pose estimation methods for both human and animal activity recognition. This enables a thorough review of the subject.
\vspace{10pt}
\noindent\textbf{Relation to Other Surveys:} To our knowledge, this is the only survey with an organizational structure for examining commonalities between the neural network architectures of the related tasks of human action recognition and pose estimation (Figure~\ref{fig:venndiagram}) in the context of their extensions for animal behavior classification (Figure~\ref{fig:animalbehaviormodelaction}). Our survey presents a novel taxonomy for animal behavior classification frameworks that is more detailed and provides a broader range of supervision levels that are not considered in other work~\cite{Berman2018}. We also include recent work with unsupervised animal behavior classification systems which are not expounded upon in other reviews.
Surveys on human pose estimation~\cite{Chen2020a,Zheng2020} and action recognition are generally handled separately, and often cover a broad range of network architectures. Zheng et. al.~\cite{Zheng2020} provide a systematic review of deep learning-based \hbox{2D} and \hbox{3D} human pose estimation methods since $2014$, while Zhu and colleagues~\cite{Zhu2020} offer a comprehensive survey of deep learning methods for video action recognition. Other reviews on these topics target specific network architectures. Recently, transformers~\cite{Zhu2020,Li2021} have become the model of choice for processing sequential data. The following surveys cover transformers for action recognition~\cite{Zhu2020} and pose estimation~\cite{Li2021}.
A related body of work reviews animal behavior classification models in neuroscience and computational ethology which is the study of animal behavior~\cite{Anderson2014}. These reviews cover many topics including measuring animal behavior across scales~\cite{Berman2018}, machine learning for animal activity recognition~\cite{Kleanthous2022}, advances in \hbox{3D} behavioral tracking~\cite{Marshall2022} for full pose measurements, monitoring with wearable devices~\cite{Kleanthous2022}, and behavior profiling~\cite{VonZiegler2021}. We focus on small laboratory animals in methods that do not require wearable tracking devices.
Many surveys in neuroscience focus on the usability of these methods as tools in a lab~\cite{MATHIS20201}. A $2021$ review~\cite{VonZiegler2021} evaluates behavior analysis approaches. We trace the technical development of the underlying neural network architectures.
Other surveys have proposed a taxonomy for animal behavior classification systems. One proposal~\cite{Berman2018} uses a dynamical representation of behavior that describes how the measured postural time-series are changing. Straightforward approaches~\cite{Jhuang2010, Vogelstein2014, Berman2014} manually create features which are fed to a supervised classifier or a clustering algorithm. The author argues that a dynamical representation should be produced naturally from pose dynamics in an unsupervised manner~\cite{Berman2018}.
\section{Background}\label{sec:background}
We begin with definitions, terms, and background information that support the paper discussion.
\vspace{10pt}
\noindent\textbf{Neural networks} are integral to most frameworks in our review. Here we describe basic operations of a feedforward neural network. Given a function, $y = f^*(\bm{x})$ that maps an input vector $\bm{x}$ to an output label $y$, a feedforward neural network defines a mapping $\bm{y} = f(\bm{x}, \bm{\theta})$, and learns the values of $\bm{\theta}$ that yield the best approximation of $f^*$. Activation functions are computed at each node using function outputs from nodes at lower levels in an acyclic graph. Activation functions introduce non-linearities to improve performance on complex datasets. The rectified linear unit (ReLU)~\cite{Xu2015arxiv} function, $f(x) = \max(0,x)$ is the default activation in feedforward networks. During training, input observations $\bm{x}$ propagate forward through network layers, producing an output prediction $\bm{\hat{y}}$ and a scalar cost $J(\bm{\theta)}$. Backpropagation allows cost information to flow backwards through the network for use in optimization methods (like stochastic gradient descent) that minimize $J(\bm{\theta})$. Activation functions should avoid linearities, saturation and vanishing gradients. The leaky ReLU function~\cite{Maas2013} is a modified ReLU function with a small slope for negative values that permits non-zero gradients, even when the unit is inactive. This avoids vanishing gradients that inhibit learning.
\vspace{8pt}
\noindent Optimizations can improve network efficiency, increase classification accuracy, and reduce adverse effects like overfitting. Architectural improvements also provide regularization within a network to address issues like vanishing gradients.
\vspace{8pt}
\noindent \textbf{Advantages of Deep Networks:} It has been shown empirically that, although deeper networks are harder to optimize, they require fewer parameters and generalize better than shallow networks~\cite{Goodfellow2016}.
\vspace{8pt}
\noindent \textbf{Regularization} is a technique that modifies a learning algorithm to reduce generalization error so that the model performs well on unseen data distributions.
\vspace{8pt}
\noindent \textbf {Batch normalization} scales and centers inputs to normalize them for faster, more stable training.
\vspace{8pt}
\noindent \textbf {Ensemble Methods} combine predictions of several neural networks to reduce test error at the expense of some additional computation costs.
\subsection{Network Architectures}
\vspace{8pt}
\noindent \textbf{Convolutional Neural Networks (CNNs):}~\cite{LeCun1989} use convolution (rather than matrix operations) in at least one layer. CNNs are regularized multi-layer perceptrons~\cite{Mcculloch1943} that leverage the spatial structure inherent in grid-like structures (like images) for regularization, through local filters, convolutions, and max-pooling layers. Advancements in GPU hardware have allowed CNNs to scale to networks with millions of parameters, improving state-of-the-art image classification and object recognition. AlexNet~\cite{Krizhevsky2012} was the first CNN to achieve state-of-the-art results on the ImageNet~\cite{Deng2009} dataset, a benchmark dataset used for a of variety deep learning challenges. The network is based on LeNet-5~\cite{LeCun1998}. VGGNet~\cite{Simonyan2015} improves upon AlexNet by using smaller convolutional filters ($3 \times 3$) and increased network depth to support between $16$ to $19$ layers.
\vspace{8pt}
\noindent \textbf{Inception}~\cite{Szegedy2015} was designed to improve utilization of computing resources within a network by using $1 \times 1$ convolutions and improved multi-scale processing. The process connects auxiliary networks to intermediate layers to encourage discrimination in the lower layers of a CNN. The auxiliary networks are discarded at test time. The GoogLeNet $22$-layer network is a notable example that won the $2014$ ImageNet challenge. Other examples like Inception-v3~\cite{Szegedy2016} improve upon the original Inception architecture by factorizing $5 \times 5$ and $7 \times 7$ convolutions into multiple smaller, more efficient convolutional operations and incorporating batch normalization.
\vspace{8pt}
\noindent\textbf{Fast R-CNN} is a deep CNN designed for object recognition that extends the Region-Based Convolutional Neural Network (RCNN).
\vspace{8pt}
\noindent \textbf{Autoencoder:} A neural network designed for dimensionality reduction in which an encoder learns a compressed feature representation from unlabeled data. The decoder validates the representation by attempting to reconstruct the original data from the features.
\vspace{8pt}
\noindent \textbf{Residual Neural Networks (ResNets)}~\cite{He2016} utilize residual blocks with skip connections to jump over layers that are not updated to allow for better gradient to flow, mitigating the vanishing gradient problem. These architectural modifications permit deeper networks. The results improved upon VGGNet in the ImageNet challenge using a network with up to $152$ layers.
\vspace{8pt}
\noindent \textbf{YOLOv3} (You Only Look Once)~\cite{Redmon2018arxiv} is a CNN architecture designed for fast object detection that has $53$ convolutional layers and uses residual blocks~\cite{He2016}. The YOLO family of models is not proposal-based and frames object detection as a regression problem that predicts bounding box coordinates and class probabilities given image pixels.
\vspace{8pt}
\noindent \textbf{Recurrent Neural Networks (RNNs):} These methods process sequential or time-series data. Cycles in the graph allow output from one layer to be fed back as input to another layer.
\vspace{8pt}
\noindent \textbf{Transformers}~\cite{Zhu2020,Li2021} are neural networks with self-attention~\cite{Vaswani2017} that operate on sequential data in parallel, without the need for recurrence (found in RNN-based models~\cite{Belagiannis2017,Luo2018}).
\subsection{General Classification and Training Methods}
\vspace{4pt}
\noindent \textbf{Temporal Random Forest Classifier} An extension of a random forest to the multi-frame case.
\vspace{8pt}
\noindent\textbf{Hand-crafted Features} are created by manual feature engineering. They are usually dataset dependent and do not generalize well. Neural networks, on the other hand, detect features automatically from unstructured data.
\vspace{8pt}
\noindent\textbf{Active Learning:} Semi-supervised classification of pose features as behavior labels employs unsupervised and supervised learning to minimize the number of behavioral labels while maximizing accuracy. Active learning approaches aim to systematically choose which samples should be labeled so that the number of samples is minimized, and the accuracy is maximized.
\vspace{8pt}
\noindent \textbf{Contrastive Learning:} A technique that increases the performance of vision tasks by \emph{contrasting} samples against each other. The goal is to learn attributes that are common between data classes, and attributes that make data classes different. The approach learns representations by minimizing the distance between positive data and maximizing the distance between negative data.
\vspace{8pt}
\noindent \textbf{Transfer learning} is a mechanism for training neural networks when there is insufficient data in the target domain. Transfer learning uses knowledge gained from one domain to improve generalization in a related domain. For example, in a supervised learning context, a model may be trained to classify images of one object category, and then used to classify images of another (training on cats and dogs and testing on horses and cows for example). This is useful because visual categories often share low-level features like edges and shapes. Another transfer learning technique trains a model on a large unlabeled dataset using an unsupervised learning algorithm, then fine-tunes the model on a labeled dataset with a supervised algorithm. This unsupervised pretraining is helpful as large, labeled datasets are hard to collect.
\vspace{8pt}
\noindent \textbf{ImageNet Pre-Training:} ImageNet is a benchmark dataset used for a variety of deep learning challenges including transfer learning experiments. It contains $1,431,167$ images that correspond to $1,000$ classes and large networks trained on this dataset have shown state-of-the-art results in the image domain. The full ImageNet dataset contains $22,000$ classes, but in experiments and the ImageNet challenge $1,000$ high-level categories are used. Transfer learning methods~\cite{Oquab2014} that use ImageNet as a source domain have been effective for improving state-of-the-art classification results in related target domains. For example, a network trained on ImageNet was used~\cite{Oquab2014} for the PASCAL Visual Objects Classes challenge~\cite{Everingham2009}. Through transfer learning, deep CNNs pre-trained on ImageNet were also used for other tasks like scene recognition~\cite{Donahue2014} and object recognition~\cite{Girshick2014}. In Section~\ref{sec:actionrecognition}, we discuss transfer learning on video datasets.
\subsection{Action Recognition: Terms}
\vspace{8pt}
\noindent \textbf{Spatio-temporal Features} are used to analyze changes in image structure that vary with time. Spatial interest points occur at positions of significant local variation in image intensities~\cite{Laptev2003}. Spatio-temporal interest points are extensions of spatial interest points as they record significant local variation of the pixel intensity in the spatio-temporal domain of the video volume~\cite{Li2017SurveyOS}.
\subsection{Graphical Models}
\vspace{8pt}
\noindent \textbf{Hidden Markov Model (HMM):} A graphical model that represents probability distributions over sequences of observations that are produced by a stochastic process. The states of the process are hidden. The state $Z_t$ at time $t$ satisfies \emph{Markov properties} and depends only on the previous state, $Z_{t-1}$ at time $t-1$.
\vspace{8pt}
\noindent \textbf{Autoregressive Hidden Markov model (AR-HMM):} A combination of autoregressive time-series and Hidden Markov Models.
\vspace{8pt}
\noindent \textbf{Graph Convolution Networks} extend convolution from images to graphs and have been used successfully in pose-based action recognition.
\vspace{8pt}
\noindent\textbf{Belief Propagation} is a message-passing algorithm for performing inference in graphical models.
\vspace{8pt}
\noindent \textbf{Graphical Models for Joint Detection:} Pose estimation methods may use graphical models with nodes that represent joints and edges that represent pairwise relationships between joints. Each final joint distribution is a product of unary terms which model the joint's appearance cues, and pairwise terms which model local joint inter-connectivites. These methods examine local image patches around a joint to detect it, and to estimate the relative position of neighboring joints.
\subsection{Pose Estimation: Terms}
\vspace{8pt}
\noindent \textbf{Part Affinity Fields} are a set of \hbox{2D} vector fields that represent the location and orientation of limbs in an image.
\subsection{Pose Estimation: Evaluation Metrics}
\noindent \textbf{Percentage of Correct Parts (PCP)} evaluates limb detection. A limb is detected if the distance between the prediction and the true limb location is within a threshold: half the limb length.
\vspace{8pt}
\noindent \textbf{Percent of Detected Joints (PDJ)} evaluates joint detection. A joint is detected if the distance between the prediction and the true joint location is within a threshold: a specified fraction of the torso diameter.
\vspace{8pt}
\noindent \textbf{Percent of Correct Keypoints (PCK)} is an accuracy metric that determines whether the distance between the predicted keypoint and the true joint location lies within a varying threshold.
\section{Human Pose Estimation} \label{sec:hpe}
\noindent In this section, we review CNN-based human pose estimation techniques that operate on images (Section~\ref{hpi-from-images}) and videos (Section~\ref{hpi-from-videos}). The methods presented contribute to animal behavior classification frameworks presented in Section~\ref{sec:animalbehavior}. Table~\ref{tab:image-datasets-table} summarizes common benchmark image datasets used in deep learning, with pose estimation datasets indicated with bold text. The key contributions of the methods discussed are summarized in Table \ref{tab:pose-estimation-summary-table}.
Human pose estimation methods generate a set of $(x, y)$ coordinates that correspond to the position of body joints within an image frame. These predictions are used as input to pose-based action recognition methods. Using taxonomy from deep learning-based human pose estimation~\cite{Zheng2020}, we categorize these approaches as \hbox{2D} or \hbox{3D}, and single-person or multi-person. The \hbox{2D} single-person methods are regression-based or detection-based. Regression-based methods regress an image to find joint locations, while detection-based methods detect body parts using heat maps. The \hbox{2D} multi-person methods use top-down or bottom-up pipeline approaches. Top-down pipeline approaches use person detectors to obtain a set of bounding boxes for each person in the image before applying single-person pose estimation techniques to each bounding box to obtain the multi-person pose estimation. Bottom-up pipeline approaches first locate all the joints of all people in an image, and then assign them to individuals. We cover \hbox{3D} pose estimation from image or video input, and categorize methods as single-view/single-person, single-view/multi-person or multi-view.
\begin{table} [h]
\begin{center}
\begin{tabular}{|m{0.3\columnwidth} | m{0.075\columnwidth} | m{0.15\columnwidth} | m{0.1\columnwidth} | m{0.1\columnwidth} |}
\hline
Dataset & Year & Size & Classes & Joints \\
\hline
MNIST \cite{LeCun1998} & $1998$ & $70,000$ & $10$ & - \\ \hline
ImageNet \cite{Deng2009} & $2009$ & $1,431,167$ & $1,000$ & - \\ \hline
CIFAR-10 \cite{Krizhevsky2009} & $2009$ & $60,000$ & $10$ & - \\ \hline
\textbf{HumanEva \cite{Sigal2010}} & $2009$ & $40,000$ & - & $15$ \\ \hline
\textbf{LSP \cite{Johnson2010}} & $2010$ & $2,000$ & - & $14$ \\ \hline
TFD~\cite{Susskind2010} & $2010$ & $112,234$ & $7$ & - \\ \hline
Cropped SVHN~\cite{Netzer2011} & $2011$ & $630,420$ & $10$ & - \\ \hline
\textbf{\hbox{LSP-extended~\cite{Johnson2011}}} & $2011$ & $10,000$ & - & $14$\\
\hline
\textbf{FLIC \cite{Sapp2013}} & $2013$ & $5,003$ & - & $10$ \\
\hline
\textbf{FLIC-motion \cite{JainTL2015}} & $2015$ & $5,003$ & - & $10$ \\ \hline
\textbf{MPII human pose} \cite{Andriluka2014} & $2014$ & $40,522$ & - & $16$\\ \hline
\textbf{Human3.6M} \cite{Ionescu2014} & $2014$ & $3.6M$ & - & $24$\\ \hline
\textbf{MPI-INF-3DHP \cite{Mehta2017}} & $2017$ & $1.3M$ & - & $24$ \\
\hline
\end{tabular}
\end{center}
\vspace{5pt}
\caption{Common Benchmark datasets for Image Classification and Pose Estimation from Images. The right columns indicate whether the data has class or joint labels.} \label{tab:image-datasets-table}
\end{table}
\begin{table} [h]
\begin{center}
\begin{tabular}{| m{1.6cm} | m{0.5cm} | m{1.2cm} | m{1cm} | m{1.1cm} | m{.8cm}|}
\hline
Dataset & Year & Trimmed & Size & Average Length (sec.) & \hspace{-2pt} Classes \\
\hline
CCV \cite{Jiang2011} & $2011$ & \cmark & $9,317$ & $80$ & $20$ \\
\hline
HMDB51 \cite{Kuehne2011} & $2011$ & \cmark & $7,000$ & $\sim5$ & $51$ \\
\hline
UCF101 \cite{Soomro2012} & $2012$ & \cmark & $13.3K$ & $\sim6$ & $101$ \\
\hline
Sports-1M \cite{Karpathy2014} & $2014$ & \cmark & $1.1M$ & $\sim330$ & $487$ \\
\hline
THUMOS14 \cite{Jiang2014} & $2014$ & \xmark & $5,084$ & $233$ & $101$ \\
\hline
ActivityNet \cite{Heilbron2015} & $2015$ & \xmark & $9,682$ & $[300, 600]$ & $203$ \\
\hline
Kinetics-400 \cite{Kay2017} & $2017$ & \cmark & $306K$ & $10$ & $400$ \\
\hline
Kinetics-600 \cite{Carreira2018}& $2018$ & \cmark & $482K$ & $10$ & $600$ \\
\hline
\end{tabular}
\end{center}
\vspace{5pt}
\caption{Common Video Benchmark Datasets}
\label{video-datasets-table}
\end{table}
\subsection{Pose Estimation from Images} \label{hpi-from-images}
\begin{table}
\begin{center}
\begin{tabular}{|c|}
\hline
Input $64 \times 64$ color image \\
\hline
$5 \times 5$ conv. RELU. $2 \times 2$ MaxPool. $\mathbb{R}^{16 \times 32 \times 32}$ \\
\hline
$5 \times 5$ conv. RELU. $2 \times 2$ MaxPool. $\mathbb{R}^{32 \times 16 \times 16}$ \\
\hline
$5 \times 5$ conv. RELU. now $\mathbb{R}^{16 \times 32 \times 32}$. flatten to $\mathbb{R}^{8192}$\\
\hline
FC. RELU. $\mathbb{R}^{500}$\\
\hline
FC. RELU. $\mathbb{R}^{100}$\\
\hline
FC. logistic unit. $\mathbb{R}^{1}$\\
\hline
\end{tabular}
\end{center}
\vspace{5pt}
\caption{Body Part Detector Architecture~\cite{JainTA2014} for Human Pose Estimation }
\label{tab:jointdetector}
\end{table}
\vspace{10pt}
\textbf{\hbox{2D} Single-Person Pose Estimation}
\vspace{10pt}
\noindent\textbf{Detection-Based:} One of the first pose estimation techniques to apply a CNN was a two-stage filtering approach~\cite{JainTA2014} for finding joint positions. The first stage generates a binary response map for each joint, applying multiple CNNs as sliding windows on overlapping areas of an image. The response map is a unary distribution representing the confidence of the joint's presence over all pixel positions. Denoising in the second stage removes false positives by passing the CNN output through a higher-level spatial model with body pose priors computed on the training set. Prior conditional distributions for two joints $(a, b)$ are calculated as a histogram of joint $a$ locations given that joint $b$ is at the image center. Similarly, a global position prior for the face is calculated using a histogram of face positions. A process similar to sum-product belief propagation~\cite{Pearl1982} generates the filtered distributions for each joint given unary distributions produced by the CNNs and the prior conditional distributions.
This non-linear mapping from pixels to vector representations of articulated pose is challenging. Data loss during pooling, and high numbers of invalid poses in the training data make valid poses difficult to learn. To avoid this, a performance improvement trained multiple CNNs for independent binary joint detection, using one network for each feature. Each CNN (shown in Table \ref{tab:jointdetector}) has a single output unit representing the probability of a joint being present in the image patch. Results were evaluated on the FLIC~\cite{Sapp2013} dataset, which consists of images of Hollywood actors in front-facing poses. The percentage of correct joint predictions within a given precision radius (in pixels) is used as a quantitative metric for pose estimation accuracy. The model outperformed state-of-the-art estimation methods available at the time.
OpenPose uses a convolutional pose machine~\cite{Wei2016} to predict keypoint coordinates, and part affinity fields to determine correspondences between keypoints and subjects in the image. Convolutional Pose Machines are a sequence of CNNs that produce increasingly refined belief maps for estimating \hbox{2D} pose, without a graphical model. This design enforces intermediate supervision and limits vanishing gradients. Transfer learning with pre-training on ImageNet improves performance. Predefined rules are used to determine if pose features represent specific behaviors.
\vspace{10pt}
\noindent\textbf{Regression-based:} Human pose estimation may be formulated as a continuous regression problem. DeepPose~\cite{Toshev2014} regresses an image to a normalized pose vector representing body joint locations. The network input is ($\bm{X}$, $\bm{y}$), where $\bm{X}$ is a labeled image and $\bm{y} = \{..., y_i^T, ...\}^T$ is the true pose vector. Each $\bm{y}_i$ is the absolute image coordinates of the $i$th joint, where $i \in \{1,...,k\}$ and $k$ is the number of joints. Each joint position must be normalized with respect to a bounding box, $b$, centered around the human subject to produce a normalized pose vector $N(\bm{y}; b) = (..., N(\bm{y}_i; b)^T, ...)^T$.
The DeepPose CNN architecture $\psi$ is based on AlexNet~\cite{Krizhevsky2012}. However, rather than formulate a classification problem, a linear regressor is trained to learn the parameters $\bm{\theta}$ of a function $\psi(\bm{X}; \bm{\theta}) \in \mathbb{R}^{2k}$ such that an image $\bm{X}$ regresses to a pose prediction $\bm{y}^*$ in absolute image coordinates:
\begin{equation}
\bm{y}^* = N^{-1} (\psi (N(\bm{X}); \bm{\theta}))
\end{equation}
The linear regressor is trained on the last network layer to predict a pose vector by minimizing the $L_2$ distance between the prediction and ground truth pose vector. The training set is first normalized as explained, yielding the following optimization problem:
\begin{equation}
\underset{\bm{\theta}}{\mathrm{argmin}} \sum_{(\bm{X}, \bm{y}) \in D_N} \sum^k_{i = 1} \| \bm{y}_i - \psi_i ((\bm{X}, \bm{\theta}) \|^2_2,
\end{equation}
\noindent where $D_N$ is the normalized training set:
\begin{equation}
D_N = \{(N(\bm{X}), N(\bm{y})) \vert (\bm{X}, \bm{y}) \in D)\}.
\end{equation}
DeepPose CNNs operate on coarse scale images at a fixed resolution ($220 \times 220$ pixels), making it difficult to analyze fine image detail at the level required for precise joint localization. To address this, a cascade of pose regressors was introduced after the first stage to predict the displacement of the predicted joint locations (from prior states) to the true joint locations. Relevant parts of the image are targeted at higher resolutions for higher precision without increasing computation costs. The model was evaluated on datasets that include a variety of poses including the aforementioned FLIC dataset~\cite{Sapp2013}, the Leeds Sports Poses dataset (LSP)~\cite{Johnson2010} of athletes participating in sports, and its extension~\cite{Johnson2011}. Limb detection rates evaluated using PCP and PDJ produced state-of-the-art or better results on both metrics.
\vspace{10pt}
\noindent\textbf{Joint Training with A Graphical Model:} Hybrid methods that combine multiresolution CNNs and joint training with graphical models produce higher accuracy rates than DeepPose. These models address limitations with network capacity, overfitting, and inefficiencies caused by nonlinear mappings from image to vector space. CNNs~\cite{Zhang2020} that operate on multi-resolution input, can identify a broad range of feature sizes in a single forward pass by adapting the effective receptive field within CNN layers.
Tompson et. al.~\cite{TompsonJ2014} combined a CNN with a Markov Random Field, an undirected graph with Markov properties~\cite{Murphy2012}. A multi-resolution feature representation with overlapping receptive fields was used to perform heat-map likelihood regression. Starting with an input image, a sliding window CNN generates a per-pixel heat-map of likelihoods for joint locations. The CNN was trained jointly with a graphical model. In later stages, a spatial model predicts which heat-maps contain false positives and incorrect poses. This is done by constraining joint inter-connectivity and enforcing global pose consistency. The graph is learned implicitly without hand-crafted pose priors or graph structure~\cite{JainTA2014}. The results showed improved accuracy compared to the previous state-of-the-art~\cite{JainTA2014,Toshev2014} in human body pose recognition using the FLIC and LSP-extended datasets with PDJ as the evaluation metric.
A later extension~\cite{TompsonG2015} improved localization accuracy by recovering the precision lost due to pooling. The input image was first passed through a CNN for coarse-level pose estimation to produce initial heat maps with per-pixel likelihoods of joint positions. The heat-maps were then passed through a position refinement model to refine the pose prediction. This modification outperformed the previous state-of-the-art on the FLIC and MPII human pose~\cite{Andriluka2014} benchmarks. The MPII human pose dataset is comprised of $24,520$ images of humans performing everyday activities collected from YouTube videos. This method outperformed previous state-of-the-art pose estimation methods~\cite{JainTA2014,Toshev2014,TompsonJ2014} on the FLIC dataset using PCK scores. Another method uses a \emph{Graphical Model with Image Dependent Pairwise Relations}~\cite{Chen2014} to generate input for both the unary and pairwise terms from image patches. Experiments performed on the FLIC and LSP datasets showed that this formulation improves upon DeepPose according to multiple metrics.
\begin{table*} [b]
\begin{center}
\begin{tabular}{| m{1.25cm} | m{0.5cm} | m{0.75cm} | m{13cm} |}
\hline
Method & Year & 2D/3D & Key Contribution(s) \\
\hline
\cite{JainTA2014} & 2014 & 2D &
\begin{itemize}
\item The development of a deep CNN architecture to learn low-level features and a higher-level spatial model.
\end{itemize} \\
\hline
\cite{TompsonJ2014} & 2014 & 2D &
\begin{itemize}
\item The development of a hybrid architecture that incorporates a deep CNN and a Markov Random Field that can exploit geometric constraints between body joint locations.
\end{itemize} \\
\hline
\cite{Chen2014} & 2014 & 2D &
\begin{itemize}
\item The development of a graphical model that uses pairwise relations to exploit how local image measurements can be used to predict joint locations and relationships.
\item The use of a deep CNN to learn conditional probabilities for the presence of joints and their spatial relationships in image patches.
\end{itemize} \\
\hline
\cite{Li2015} & 2015 & 3D &
\begin{itemize}
\item The application of a deep CNN to 3D pose estimation from monocular images.
\item The joint training of pose regression and body part detectors.
\end{itemize} \\
\hline
\cite{Pfister2015pose} & 2015 & 2D &
\begin{itemize}
\item The use of a deep CNN for estimating human pose in videos.
\item The use of temporal information between frames to improve performance.
\end{itemize} \\
\hline
DeepPose \cite{Toshev2014} & 2014 & 2D &
\begin{itemize}
\item The formulation of human pose estimation as a deep CNN-based regression problem.
\item The use of a cascade of regressors to increase precision.
\end{itemize}\\
\hline
MoDeep \cite{JainTL2015} & 2015 & 2D &
\begin{itemize}
\item The use of motion features for human pose estimation.
\end{itemize} \\
\hline
\cite{TompsonG2015} & 2015 & 2D &
\begin{itemize}
\item The introduction of a position refinement model that is trained to estimate the joint offset location in a local image region in order to improve joint localization accuracy.
\end{itemize} \\
\hline
DeepCut \cite{Pishchulin2016deepcut} & 2016 & 2D &
\begin{itemize}
\item The development of a partitioning and labeling formulation of body-part predictions produced by CNN-based joint detectors.
\item This formulation infers the number people in images, identifies occlusions, and differentiates between overlapping body parts of nearby people.
\end{itemize} \\
\hline
\cite{Li2017} & 2017 & 3D &
\begin{itemize}
\item The modeling of dependencies between joints using a max-margin structured learning framework for monocular 3D pose estimation.
\end{itemize} \\
\hline
\cite{Tekin2016a} & 2016 & 3D &
\begin{itemize}
\item The use of an overcomplete autoencoder for monocular 3D pose estimation that learns a latent pose representation and models joint dependencies.
\end{itemize} \\
\hline
\cite{Tekin2016b} & 2016 & 3D &
\begin{itemize}
\item The use of motion information from video clips for 3D pose estimation and the direct regression from clips to pose in the center frame.
\end{itemize} \\
\hline
\cite{Pavlakos2017} & 2017 & 3D &
\begin{itemize}
\item The discretization of 3D space around a subject for monocular 3D pose estimation.
\item The use of a CNN to predict per voxel likelihoods for each joint.
\end{itemize} \\
\hline
DeeperCut \cite{Insafutdinov2016} & 2016 & 2D &
\begin{itemize}
\item The design of very deep body part detectors by building upon the ResNet architecture.
\item The use of image conditioned pairwise terms between body parts to improve performance for images with multiple people.
\item The development of an incremental optimization procedure that leads to speed and performance boosts.
\end{itemize} \\
\hline
\end{tabular}
\end{center}
\vspace{5pt}
\caption{Summary of Pose Estimation Approaches}
\label{tab:pose-estimation-summary-table}
\end{table*}
\begin{table*} [h]
\begin{center}
\begin{tabular}{| m{0.5cm} | m{2cm} | m{0.5cm} | m{1.8cm} | m{10cm} |}
\hline
CNN Arch. & Method & Year & Classification Accuracy & Key Contribution(s) \\
\hline
\rotatebox[origin=c]{90}{2D} &\hbox{Slow Fusion} \cite{Karpathy2014} & $2014$ & $65.4\%$ &
\begin{itemize}
\item The release of the Sports-1M dataset.
\item The evaluation of CNNs for video classification and the development of slow fusion, late fusion, and early fusion.
\end{itemize} \\
\hline
\rotatebox[origin=c]{90}{Two-Stream} & Two-Stream CNN \cite{Simonyan2014} & $2014$ & $88.0\%$ &
\begin{itemize}
\item The development of the two-stream architecture that incorporates spatial and temporal networks.
\item The usage of optical flow to model movement in videos for action recognition.
\end{itemize} \\
\cline{2-5}
& MotionNet \cite{Zhu2019} & $2019$ & $89.82\%$ &
\begin{itemize}
\item The development of the MotionNet CNN that implicitly calculates optical flow between frames as a part of a two-stream architecture.
\end{itemize} \\
\hline
\rotatebox[origin=c]{90}{3D}& C3D \cite{Tran2015} & $2015$ & $86.7\%$ &
\begin{itemize}
\item The development of an $8$-layer 3D CNN that operates over $16$ frames and uses filters of size $3 \times 3 \times 3$.
\end{itemize} \\
\cline{2-5}
& $R(2+1)D$ \cite{Tran2018} & $2018$ & $97.3\%$ &
\begin{itemize}
\item The factorization of 3D convolution into 2D spatial convolution followed by 1D temporal convolution.
\end{itemize} \\
\hline
\rotatebox[origin=c]{90}{Two-Stream/3D} & Two-Stream \hbox{CNN Fusion} \cite{Feichtenhofer2016} & $2016$ & $93.5\%$ &
\begin{itemize}
\item The development of a two-stream architecture that uses 3D convolutional fusion and 3D pooling.
\end{itemize} \\
\cline{2-5}
& I3D \cite{Carreira2017} & $2017$ & $98.0\%$ &
\begin{itemize}
\item The usage of the Kinetics-400 dataset \cite{Carreira2017}.
\item The development of two-stream inflated 3D CNNs that expand the filters and pooling kernels of very deep image CNNs into 3D.
\end{itemize} \\
\hline
\end{tabular}
\end{center}
\vspace{5pt}
\caption{Summary of Discriminative Action Recognition Approaches and their Performance on UCF101~\cite{Soomro2012}}
\label{tab:action-recognition-summary-table}
\end{table*}
\vspace{10pt}
\textbf{\hbox{2D} Multi-Person}
\vspace{10pt}
There are additional challenges with pose estimation when multiple subjects interact in a video. Most early strategies for multi-person pose estimation used a two-stage inference process to first detect and then independently estimate poses. However, this method is less effective when multiple people have overlapping body parts because the same body part candidates are often assigned to multiple people.
A proposed solution, DeepCut~\cite{Pishchulin2016deepcut}, casts the joint detection and pose estimation problems as integer linear programs. DeepCut's formulation is a Joint Subset Partitioning and Labeling Problem (SPLP) that jointly infers the number of people and poses, the spatial proximity, and areas of occlusion. The solution jointly estimates the poses of all people in an image by minimizing a joint objective. A set of joint candidates is partitioned and labeled into subsets that correspond to mutually consistent joint candidates that satisfy certain constraints. Even though the problem is NP-hard, this formulation allows feasible solutions to be computed within a certain optimality gap. DeepCut adapts two CNN architectures, Fast R-CNN~\cite{Girshick2015} and VGGNet~\cite{Simonyan2015}, to generate body part candidates. Significant improvement was shown over previous methods~\cite{TompsonJ2014,Chen2014,TompsonG2015} for both single and multi-person pose estimation according to multiple evaluation metrics on the LSP, LSP-extended, and MPII human pose datasets.
DeeperCut~\cite{Insafutdinov2016} doubled the pose estimation accuracy of DeepCut while reducing the running time by $2$-$3$ orders of magnitude. Contributions included novel image conditioned pairwise terms between body parts that improved performance for images with multiple people, and a novel optimization method that decreased runtime while improving pose estimation accuracy. DeeperCut adapted ResNet~\cite{He2016}, which is $8 \times$ deeper than VGGNet. Experiments were conducted on both single and multiple person human pose datasets: LSP, LSP-extended, and MPII using the PCK evaluation metric. Results yielded a new state-of-the-art in multi-person~\hbox{2D} pose estimation.
\vspace{10pt}
\textbf{\hbox{3D} Pose Estimation}
\vspace{10pt}
Estimating a~\hbox{3D} human pose from a single RGB image is a challenging problem in computer vision because it requires solving two ambiguous tasks~\cite{Tome2017}.
The first task is finding the \hbox{2D} location of human joints in the image. This is hard due to different camera viewpoints, occlusions, complex body shapes, and varying illumination. The second, converting the coordinates of \hbox{2D} landmarks into \hbox{3D} coordinates, is an ill-posed problem that requires additional information such as \hbox{3D} geometric priors and other constraints. Methods for \hbox{3D} pose inference from images either regress the \hbox{3D} pose directly from images, or first estimate the~\hbox{2D} pose and then lift the coordinates into \hbox{3D} using a pipeline approach. Three-dimensional human pose estimation approaches presented in the remainder of this subsection are single-view/single-person.
\vspace{10pt}
\noindent\textbf{Regression-based:} CNNs can directly regress~\hbox{3D} poses from images. One method, \emph{\hbox{3D} Human Pose Estimation from Monocular Images}~\cite{Li2015}, jointly trains the pose regression task with a set of recognition tasks in a heterogeneous multi-task learning framework. The network was pre-trained using the recognition tasks, then refined using only the pose regression task. A \emph{Maximum-Margin Structured Learning} technique~\cite{Li2017} takes an image and a \hbox{3D} pose as input, and produces a score that indicates whether the pose is depicted. During training a maximum-margin cost function is used to enforce a re-scaling margin between the score values of the ground truth image-pose pair and the rest of the pairs. The results showed improved performance. Overcomplete autoencoders~\cite{Tekin2016a} have been used to learn a high-dimensional latent pose representation. This method accounts for joint dependencies that predict \hbox{3D} human poses from monocular images. The problem was also posed as a key point localization problem in a discretized \hbox{3D} space~\cite{Pavlakos2017}. In this case, a CNN is trained to predict per voxel likelihoods for each joint in the volume.
At the time, among pipeline approaches, it was unclear whether the remaining error in state-of-the-art methods was due to a limited~\hbox{2D} pose understanding, or from a failure to map~\hbox{2D} poses to~\hbox{3D} positions. To better understand the sources of error, the~\hbox{3D} human pose estimation problem was decoupled into the well-studied problems of~\hbox{2D} pose estimation from images and~\hbox{3D} pose estimation from~\hbox{2D} joint detections.
\vspace{10pt}
\noindent\textbf{\hbox{2D} to \hbox{3D} Lifting:} By focusing on the latter problem, ground truth~\hbox{2D} joint locations can be~\emph{lifted} to ~\hbox{3D} space using a relatively simple deep CNN. This yielded state-of-the-art results on the Human3.6M dataset~\cite{Ionescu2014} which consists of $3.6$ million~\hbox{3D} human poses. The findings indicated that the remaining error in pipeline approaches for~\hbox{3D} pose estimation techniques stem from~\hbox{2D} pose analysis. Another pipeline approach~\cite{Tome2017} used a pre-learned~\hbox{3D} human pose model as part of the CNN architecture itself. The architecture learned to use physically plausible~\hbox{3D} reconstructions in its search for better~\hbox{2D} landmark locations. The process obtained state-of-the-art~\hbox{2D} and~\hbox{3D} results on Human3.6M, and demonstrated the importance of considering~\hbox{3D}, even when solving~\hbox{2D} pose estimation problems.
\vspace{10pt}
\noindent \textbf{Generalization to in-the-wild conditions:}
The previous pose estimation methods had low generalization to in-the-wild conditions. This is due to inherent limitations in the training datasets. A \emph{Monocular \hbox{3D} Human Pose Estimation} method~\cite{Mehta2017} used transfer learning to leverage the mid and high-level features learned on existing~\hbox{2D} and~\hbox{3D} pose datasets, yielding improved performance. State-of-the-art results were obtained on the Human3.6M dataset and the HumanEva pose estimation benchmark,~\cite{Sigal2010}. A new benchmark dataset, MPI-INF-3DHP \cite{Mehta2017}, of indoor and outdoor scenes was presented. Transfer learning with MPI-INF-3DHP and~\hbox{2D} pose data yielded the best generalization to in-the-wild conditions, confirming that transfer learning is beneficial for~\hbox{3D} pose estimation.
\subsection{Human Pose Estimation from Video}\label{hpi-from-videos}
Human pose estimation approaches that operate on videos handle temporal information using techniques similar to those we cover in our discussion of human action recognition methods (Section~\ref{sec:actionrecognition}). CNNs used for action recognition initially incorporated temporal information using optical flow~\cite{Brox2004} as an input motion feature~\cite{Simonyan2014} to a two-stream network architecture (Sections~\ref{sec:motivation} and~\ref{sec:actionrecognition}). An optical flow~\cite{Brox2004} (shown in Figure~\ref{fig:trimmed-figure2}), is a set of displacement vector fields $\bf{d}_t$ between pairs of consecutive frames $t$ and $t + 1$. Figure~\ref{flow-figure} (top row) shows an example of the optical flow between two consecutive frames in a video of a person diving. Figure~\ref{flow-figure} (bottom row) shows a mouse walking.
Two \hbox{2D} single-view/single-person pose estimation methods~\cite{Pfister2015pose,JainTA2014}, one that is detection-based and another that is regression-based, extended this idea using optical-flow maps from multiple nearby frames to predict the pose in the current frame. In a related work, \emph{Flowing ConvNets for Human Pose Estimation}~\cite{Pfister2015flow}, when performing inference for one frame, joint positions for all neighboring frames are explicitly predicted and aligned to the corresponding frames. This is done using a dense optical flow to warp backward or forward in time. Evaluation performed on three large pose estimation datasets showed that this method outperforms the previous state-of-the-art.
MoDeep~\cite{JainTL2015}, and similar variants~\cite{Pfister2015pose}, improved upon DeepPose by exploiting motion as a cue for body part localization. This single-view/single-person method uses optical flow and color from multiple nearby frames as input to a multi-resolution CNN. The multi-resolution CNN was designed for estimating a human's pose in a video given an image and a set of motion features. Accuracy in high-precision regions was improved (compared to DeepPose) by incorporating motion features, and using a translation-invariant model. Optical flow was one of several formulations considered. The FLIC-motion \cite{JainTL2015} dataset which consists of the original FLIC dataset \cite{Sapp2013} augmented with motion features, was created. MoDeep performed best on FLIC-motion compared to other state-of-the-art pose estimation methods. A related technique by Tekin et. al. ~\cite{Tekin2016a} extended a CNN architecture for pose estimation on still images~\cite{Tekin2016b} to operate on video. It included temporal information in the joint predictions by extracting spatio-temporal information from a sequence of frames.
\section{Human Action Recognition}\label{sec:actionrecognition}
Now that we have introduced CNN-based pose estimation techniques, we turn our attention to action recognition methods that track motion across video frames. Figure~\ref{fig:actionrecognition} illustrates the CNN architectures discussed in this section in green. Rectangles denote architecture categories and rounded rectangles denote architectures. Architecture we discuss have been extended for animal behavior classification systems (shown in brown), that we review in Section~\ref{sec:animalbehavior}.
\textbf{Standard Action Recognition Methods} extract features, sparse \cite{Laptev2003} or dense~\cite{Wang2011} spatio-temporal interest points, for example, and then track their displacement through frame sequences using techniques like optical flow. Improved Dense Trajectories (iDT)~\cite{Wang2013} is an example that represents motion as feature trajectories, fixed-sized descriptors computed along the paths of feature points. In this case, quantization using a k-means dictionary~\cite{Laptev2008} is used to combine features. A sparse vector with stored occurrence counts of a vocabulary of local image features (bag of visual words), is then accumulated across the video. A support vector machine (SVM), or other classifier, is trained to classify the bag of visual words to discriminate video-level classes.
\textbf{CNN-Based Temporal Learning:} Modern deep learning methods use neural networks to detect spatio-temporal features. In our survey, we focus on CNN-based examples. While images can be scaled and cropped, and are easily processed with fixed-sized CNNs, videos are difficult to work with because they vary in temporal content. According to Karpathy et. al.~\cite{Karpathy2014}, compared to traditional machine learning approaches for action recognition~\cite{Laptev2003,Wang2011,Wang2013}, CNN-based solutions shift the engineering from feature design and extraction, to network architecture design and hyperparameter tuning.
\begin{figure}[ht]
\centering
\includegraphics[width=0.4\textwidth]{img-optical-flow-diagram.eps}
\caption{(top row) Two consecutive frames and a close-up from a video of a person diving from the UCF101~\cite{Soomro2012}. (bottom row) Two consecutive frames and a close-up from a video of a mouse with a close-up from a published~\cite{Jhuang2010} animal behavior dataset. In each case, optical flow between the frames was calculated using MATLAB and superimposed on the second frame and close-up.}
\label{flow-figure}
\label{fig:trimmed-figure2}
\end{figure}
We begin with a seminal paper by Karpathy et. al.~\cite{Karpathy2014} that extended the connectivity of a CNN to operate in the temporal domain for video classification. The solution treats the input data as a bag of fixed-sized clips where one hundred half-second clips were randomly sampled from each video. Fusion operations are then used to extend the CNNs over the time dimension so that they operate on multiple frames and have the ability to learn spatiotemporal features from the clips. The team proposed three novel CNN connectivity patterns to fuse temporal information: Late fusion places two single-frame networks some time apart, then fuses their outputs later. Early fusion modifies the first layer to use a convolutional filter that extends in time. Slow fusion is a balance between early and late fusion (Figure \ref{fig:Karpathy-fig}). A baseline single-frame architecture was also used to analyze the contribution of static appearance to classification accuracy.
\begin{figure}[h]
\begin{center}
\includegraphics[width=\linewidth]{img-action-recognition.eps}
\caption{CNN-based Action Recognition Architectures for Human Actions (green) and Animal Behavior Classification (brown). Rectangles denote architecture categories and rounded rectangles denote architectures.}
\label{fig:actionrecognition}
\end{center}
\end{figure}
High volume video datasets with high class variation are essential for training and testing these new architectures. The largest video datasets available at the time were CCV~\cite{Jiang2011} which contains $9,317$ videos and $20$ classes, and UCF101~\cite{Soomro2012} which contains $13,320$ videos and $101$ classes. Though effective for generating early action recognition benchmarks, the scale and variety of these video datasets were not equivalent to large image datasets like ImageNet \cite{Deng2009} (Section~\ref{sec:background}). To address this issue, the paper introduced a new benchmark action recognition dataset, the Sports-1M dataset~\cite{Karpathy2014} with one million trimmed YouTube videos belonging to $487$ classes of sports. Each video is five minutes and $36$ seconds long on average. One hundred half-second clips were randomly sampled from each video in the Sports-1M dataset. To produce video-level predictions, $20$ clips from a video were randomly sampled and presented to each CNN individually and class predictions for each clip were averaged.
\begin{figure}[h!]
\begin{center}
\includegraphics[width=\linewidth]{img-Karpathy.eps}
\caption{Approaches~\cite{Karpathy2014} tested for fusing information in the temporal domain. Red, green, blue, and yellow layers denote convolution, normalization, pooling, and fully connected layers, respectively. Zoom in to see details. Adapted from~\cite{Karpathy2014}.} \label{fig:Karpathy-fig}
\end{center}
\end{figure}
Slow fusion was the best fusion method for video classification on Sports-1M. Interestingly, the single-frame connectivity pattern performed similarly to the other patterns, which showed that learning from a series of frames showed no improvement compared to learning from a static image. The CNN's learned feature representation trained on Sports-1M was shown to generalize to different action classes and datasets. One transfer learning experiment using UCF101 compared the accuracy of training the CNN from scratch with the accuracies of fine-tuning the top layer, top three layers, and all layers. Fine-tuning the top three layers performed the best, demonstrating that the layers near the top learn dataset-specific features and the lower layers learn more generic features.
\textbf{Two-stream CNNs}~\cite{Simonyan2014} capture motion by decomposing videos into a spatial component, which has information about objects and scenes, and a temporal component, which describes the movement of objects and the camera. This approach is based on the two-streams hypothesis from neuroscience~\cite{Goodale1992} which posits that the human visual cortex has a ventral stream that performs object recognition, and a dorsal stream that recognizes motion.
The authors of a new two-stream CNN approach \cite{Simonyan2014} for video classification suggested that features learned through slow fusion in the prior example~\cite{Karpathy2014} are not optimal for capturing motion because there is no significant difference between CNN performance on static images, and CNN performance using fusion. In addition, slow fusion was $20\%$ less accurate than the best trajectory-based shallow representation at the time~\cite{Peng2016}. The team proposed a solution that combined spatial and temporal recognition streams using late fusion. The temporal stream input is formed by stacking the optical flow displacement fields between a sequence of consecutive frames. Two input configurations were considered. One method does not sample optical flow at the same location across frames, but instead samples the optical flow along the motion trajectories. The other, more successful option, treats the horizontal and vertical components of the optical flow vector field $\bf{d}^x_t$ and $\bf{d}^y_t$, respectively, at frame $t$, as image channels. The optical flow channels of $L$ consecutive frames are stacked to form $2L$ input channels.
The CNN input volume $I_{\tau} \in \mathbb{R}^{w \times h \times 2L}$ for a frame $\tau$ is defined as:
\begin{equation}
I_\tau(u, v, 2k - 1) = d^x_{\tau + k - 1}(u, v),
\label{equ:twostream-inputconfig1}
\end{equation}
\begin{equation*}
I_\tau(u, v, 2k) = d^y_{\tau + k - 1}(u, v),
\end{equation*}
\noindent where $w$ and $h$ are the width and height of the video, and the displacement vector at point $(u, v)$ in frame $t$ is $\bf{d_t}$$(u, v)$ with $u = [1;w]$ and $v = [1;h]$. The frame and channel indices are $k = [1;L]$ and $c = [1;2L]$, respectively. The channels $I_\tau(u, v, c)$ represent the horizontal and vertical components of motion of a point $(u, v)$ over $L$ frames. From each displacement field $\bm{d}$, the mean vector is subtracted to perform zero-centering of the network input so that the optical flow between frames is not dominated by a particular displacement caused by camera motion.
This method was evaluated using two datasets: UCF101 and the Human Motion Database (HMDB51)~\cite{Kuehne2011}. HMDB51 has $6,766$ labeled video clips with $51$ classes. The spatial stream CNN was pre-trained on ImageNet. The best performance was recorded when stacking $L = 10$ horizontal and vertical flow fields and using mean subtraction. This method is not end-to-end trainable because a preprocessing step is required to compute optical flow~\cite{Brox2004} before training. The results established a new state-of-the-art for action recognition.
Even with these improvements, two challenges remained. Two stream approaches developed thus far did not leverage correspondences between spatial cues and temporal cues (optical flow) in videos because fusion is only applied to classification scores. They also had a restricted temporal scale because the temporal CNN operates on a stack of $L$ consecutive optical flow frames. An improved two-stream architecture by Feichtenhofer et. al.~\cite{Feichtenhofer2016} addresses these issues by fusing spatial and temporal information more effectively across different levels of feature abstraction granularity. For example, the system fuses components like motion (recognized by the temporal network), and location (recognized by the spatial network) to discriminate between actions like brushing teeth and brushing hair. The network is not able to distinguish between these actions when motion or location information is considered separately. The architecture was able to fuse the spatial and temporal networks so that temporal and spatial features correspond (spatial registration). The second limitation is addressed by capturing short-scale optical flow features using the temporal network and putting the features into context over a longer temporal scale at a higher layer.
Fusion functions can be applied at different points in a traditional or two-stream CNN network to implement the fusion approaches we have described. For two feature maps $\bm{x}^a_t \in \mathbb{R}^{H \times W \times D}$ and $\bm{x}^b_t \in \mathbb{R}^{H' \times W' \times D'}$ at time $t$, a fusion function $f : \bm{x}^a_t, \bm{x}^b_t \rightarrow \bm{y}_t$ produces an output feature map $\bm{y}^t \in \mathbb{R}^{H'' \times W'' \times D''}$, where $H$, $W$ and $D$ are the height, width and number of channels. The one constraint is that $\bm{x}^a_t$ and $\bm{x}^b_t$ have the same spatial dimensions, so we assume $H = H' = H''$, $W = W' = W''$, $D = D'$.
The following functions were proposed to register corresponding pixels in the spatial and temporal stream networks. \textbf{\emph{Sum fusion}} computes the sum of the feature maps at the same spatial locations and channels. \textbf{\emph{Max fusion}} computes the maximum of the feature maps. \emph{\emph{Concatenation fusion}} stacks the feature maps at the same spatial locations across different channels using Equation~\ref{equ:concatenation-fusion}, where $\bm{y} = \mathbb{R}^{H \times W \times 2D}$. \textbf{\emph{Convolutional fusion}} first stacks the feature maps using concatenation fusion, then convolves the stacked data with a bank of filters $\bm{f} \in \mathbb{R}^{1 \times 1 \times 2D \times D}$ accounting for biases $b \in \mathbb{R}^{D}$. When used as a trainable filter kernel, $\bm{f}$ learns correspondences of feature maps that minimize a joint loss function. We include the formulation for convolutional fusion in Equation~\ref{equ:convolution-fusion} (with the intermediate concatenation step Equation~\ref{equ:concatenation-fusion}) as it has been found to be the most effective of these fusion methods.
\begin{equation}
y^{cat}_{i, j, 2d} = x^{a}_{i, j, d} \ \ y^{cat}_{i, j, 2d - 1} = x^{b}_{i, j, d}
\label{equ:concatenation-fusion}
\end{equation}
\begin{equation}
\bm{y}^{conv} = \bm{y}^{cat} * \bm{f} + b.
\label{equ:convolution-fusion}
\end{equation}
\noindent \textbf{\emph{Bilinear fusion}} computes a matrix outer product of the feature maps at each pixel, then performs a summation over the pixels. The result captures multiplicative interactions between pixels in a high dimensional space. For this reason, in practice, bilinear fusion is applied after the fifth ReLU activation function and fully connected layers are removed. Ultimately each channel of the spatial network is combined multiplicatively with each channel of the temporal network.
As previously mentioned, convolution fusion was the best approach. When evaluating this fusion method, it was determined that additional computation speed-ups could be achieved by first combining feature maps over time using pooling methods before convolving with the filter bank. This effectively reduced the parameter space by reducing the feature map size. Two pooling scenarios were considered. Network predictions were averaged over time (\hbox{2D} pooling), or max pooling was applied to stacked data in a~\hbox{3D} cube (~\hbox{3D} pooling). Three-dimensional pooling increased performance more than~\hbox{2D} pooling. The network was fused spatially and truncated after the fourth convolutional layer to find a balance between maximizing classification accuracy and minimizing the total number of parameters. The fused architecture showed improvement upon previous state-of-the-art action recognition methods~\cite{Simonyan2014,Tran2015} on UCF101 and HMDB51.
Another challenge with two-stream approaches developed thus far, is the increased time and storage requirements due to their reliance on pre-computed optical flow before CNN training~\cite{Simonyan2014}. MotionNet~\cite{Zhu2019} introduced new time and storage efficiencies with a CNN that produced optical flow from video clips on-the-fly. The results were similar to the optical flow generated by one of the best traditional methods~\cite{ Zach2007}. Optical flow estimation was framed as an image reconstruction problem. Using two consecutive frames $\bm{I}_1$ and $\bm{I}_2$ as input, MotionNet generated a flow field $\bm{V}$ which was used with $\bm{I}_2$ to create a reconstructed frame $\bm{I}_1'$ using the inverse warping function~\cite{Jaderberg2015}.
MotionNet aims to minimize the photometric error between $\bm{I}_1$ and $\bm{I}_1'$. Assuming $\bm{I}_1$ and $\bm{I}_1'$ are related by a parametric transformation, the minimization function finds the parameters of the transformation $\bm{p}$ that minimize the squared intensity error:
\begin{equation} \label{photo-loss}
\underset{\bm{p}}{\mathrm{argmin}} \sum_{\bm{u} \in \alpha_1 }\frac{1}{2} \| \bm{I}_1(\bm{u}) - \bm{I}_1'(w(\bm{u}; \bm{p})) \|^2
\end{equation}
where $\bm{u} \in \alpha_1$ is a subset of pixel coordinates in image $\bm{I}_1$ and $w$ is the warping function~\cite{Baker2004}.
Traditionally the Lucas-Kanade algorithm~\cite{Lucas1981,Baker2004} solves Equation \ref{photo-loss} and is used to calculate optical flow. MotionNet produces optical flow using three novel unsupervised loss functions which we describe below.
A \textbf{pixelwise reconstruction error function} is used to measure the difference in pixel values between the frames:
\begin{equation}
L_{pixel} = \frac{1}{hw} \sum_i^h \sum_j^w \rho(\bm{I}_1(i, j) - \bm{I}_2(i + \bm{V}_{i, j}^x, j + \bm{V}_{i, j}^y))
\label{equ:pixelreconstruction}
\end{equation}
\noindent where $h$ and $w$ are the height and width of images $\bm{I}_1$ and $\bm{I}_2$. The horizontal and vertical components of the estimated optical flow are denoted as $\bm{V}^x$ and $\bm{V}^y$. The term $\rho(x) = (x^2 + \epsilon^2)^{\alpha}$ denotes the generalized Charbonnier loss function which is a differentiable version of the $L_1$ norm used to decrease the influence of outliers, where $\epsilon$ determines how closely it resembles the $L_1$ norm. The arbitrary power $\alpha$ is non-convex when $\alpha < 0.5$.
A \textbf{smoothness loss function} resolves ambiguities that occur when estimating motion in non-textured local regions (aperture problem). It is difficult to detect motion on local image patches using convolution if patches are not textured. Let $\nabla \bm{V}_x^y$ and $\nabla \bm{V}_y^y$ be the gradients of the vertical component of the estimated flow field, and $\nabla \bm{V}_x^x$ and $\nabla \bm{V}_y^x$ be the gradients of the horizontal component. Smoothness loss is defined as:
\begin{equation}
L_{smooth} = \rho (\nabla V_x^x) + \rho (\nabla V_y^x) + \rho (\nabla V_x^y) + \rho (\nabla V_y^y)
\label{equ:smooth}
\end{equation}
The \textbf{structural similarity loss function} helps the network learn frame structure. A sliding window approach is used to partition $\bm{I}_1$ and $\bm{I}_1'$ into local patches for comparison. Let $N$ denote the number of patches that can be extracted from the image using a sliding window with stride $8$, let $n$ denote the patch index, and let $I_{1n}$ and $I'_{1n}$ denote two image patches from the original image $I_1$ and its reconstruction $I'_1$:
\begin{equation}
L_{ssim} = \frac{1}{N} \sum_n^N (1 - SSIM(\bm{I}_{1n}, \bm{I}'_{1n})),
\end{equation}
\noindent where SSIM measures the perceptual quality of frames computed as:
\begin{equation} \label{equ:ssim}
SSIM(\bm{I}_{p1}, \bm{I}_{p2}) = \frac{(2 \mu_{p1} \mu_{p2} + c_1)(2 \sigma_{p1p2} + c_2)}{(\mu^2_{p1} + \mu^2_{p2} + c_1)(\sigma^2_{p1} + \sigma^2_{p2} + c_2)}.
\end{equation}
\noindent SSIM determines the average dissimilarity between images by examining the means $\mu_{p1}$ and $\mu_{p2}$, variances $\sigma_{p1}$ and $\sigma_{p2}$, and covariance $\sigma_{p1p2}$ of the pairs of image patches. Two constants $c_1$, and $c_2$ are used to stabilize the division.
Loss was computed at each scale $s$ as a weighted sum of the three loss functions, where $\lambda_1$, $\lambda_2$, and $\lambda_3$ weigh the importance of each loss function:
\begin{equation}
L_{s} = \lambda_1 L_{pixel} + \lambda_2 L_{smooth} + \lambda_3 L_{ssim}
\end{equation}
MotionNet was combined with a temporal stream CNN which learned to map the generated optical flow to class labels for action recognition. Two methods for combining models were explored. Stacking simply concatenated the two networks with MotionNet placed in front. Branching used a single network for optical flow extraction and action classification, and then shared features between the two tasks. Stacking proved more space efficient than branching. Multiple strategies were explored for fine-tuning the stacked CNN for action recognition. The strategy with the highest performance fine-tuned both networks (MotionNet and the temporal CNN) utilizing all three loss functions. Long-term motion dependencies were represented using a sequence of $11$ frames which yielded multiple ($10$) optical flow fields.
The proposed method~\cite{Zhu2019} outperformed real-time action recognition methods at the time (~\cite{Kantorov2014,Zhang2016,Tran2015,Ng2018,Diba2016,Wang2016}) on four benchmarks datasets; UCF101, HMDB51, THUMOS14~\cite{Jiang2014}, and ActivityNet~\cite{Heilbron2015}. THUMOS14 and ActivityNet are large datasets of long, untrimmed videos. MotionNet was shown to be flexible as it may be concatenated to deeper CNN architectures to improve their recognition accuracy. Such frameworks are still real-time due to the on-the-fly optical flow calculation.
\textbf{~\hbox{3D} CNNs} use spatio-temporal convolutions that model both spatial structure and temporal information in sequences. They operate on the premise that~\hbox{3D} convolutions preserve temporal information from input signals while~\hbox{2D} convolutions collapse temporal information.
\begin{figure}
\begin{center}
\includegraphics[width=\linewidth]{img-Two-Stream.eps}
\caption{Two-Stream Video Classification Architecture (left)~\cite{Simonyan2014} and C3D Architecture (right)~\cite{Tran2015}. Red, green, blue, and yellow layers denote convolution, normalization, pooling, and fully connected layers, respectively. Zoom in to see details. Adapted from~\cite{Simonyan2014} and~\cite{Tran2015}.} \label{fig:twostream-fig}
\end{center}
\end{figure}
C3D~\cite{Tran2015} is a~\hbox{3D} CNN that achieved a new state-of-the-art in object recognition and scene classification in videos. The approach found that the homogenous setting of $3\times 3 \times 3$ kernels in all convolutional layers is the best option for \hbox{3D} CNNs which is consistent with VGGNet (Figure \ref{fig:twostream-fig}, right). The architecture has $8$ convolutional layers with $3 \times 3 \times 3$ convolutional filters, $5$ max pooling layers and $2$ fully connected layers followed by a softmax output layer. Pooling layers are $2 \times 2 \times 2$, except for the first layer which is $1 \times 2 \times 2$ to help preserve temporal information. The stride is $1$ for pooling and convolution. Video clips each consisting of $16$ frames were the network inputs. The architecture was designed to be as deep as possible while accounting for training on a large dataset, GPU memory, and computation affordability.
The C3D network is trained from scratch on the Sports-1M dataset. The trained network was used as a feature extractor for different tasks including action recognition on UCF-101, action similarity labeling, scene and object recognition. The learned features were evaluated for action recognition and showed $5\%$ improvement compared to slow fusion~\cite{Karpathy2014} . Evaluation on UCF101 produced an $11\%$ improvement over the slow fusion model~\cite{Karpathy2014} for action recognition.
Three-dimensional CNNs like C3D have several advantages. The performance of C3D was similar to the original two-stream approach \cite{Simonyan2014}, but with a lower runtime. C3D does not use optical flow as input like the two-stream architecture~\cite{Simonyan2014} does, and instead extracts motion features directly from videos. There are still some drawbacks. Three-dimensional CNNs are harder to train than \hbox{2D} CNNs because they have many more parameters from the extra filter dimension. In addition, C3D did not benefit from performance improvements from ImageNet pre-training~\cite{Deng2009} because it is a relatively shallow architecture trained from scratch.
A novel two-stream \emph{Inflated}~\cite{Kay2017}~\hbox{3D} CNN, I3D~\cite{Carreira2017}, improved upon the previous state-of-the-art in action recognition~\cite{Simonyan2014,Feichtenhofer2016,Tran2015} by inflating~\hbox{2D} CNN image classification models into~\hbox{3D} CNNs. This inflation process adds a temporal dimension to the filters and pooling kernels in a~\hbox{2D} CNN.
\textbf{Transfer Learning on Video Datasets:} Originally, it was unclear whether transfer learning was as useful for videos. A new dataset, the Kinetics-400 Human Action Video Dataset~\cite{Kay2017}, was collected to evaluate this. This dataset contains about $306,245$ videos that correspond to $400$ human action classes, with over $400$ clips for each class. The dataset is split into training, test and validation sets. Several architectures including the original two-stream approach~\cite{Simonyan2014}, C3D~\cite{Tran2015}, the~\hbox{3D} fused two-stream approach~\cite{Feichtenhofer2016}, and I3D~\cite{Carreira2017}, were compared by first pre-training on the Kinetics-400 dataset, then fine-tuning on HMDB51 and UCF101. The difference between the performances of the best deep network, I3D~\cite{Carreira2017}, and the best hand-crafted approach, iDT~\cite{Wang2013}, for video action recognition was smaller than the difference between that of the best deep learning-based and hand-crafted image recognition approaches. Additionally, a~\hbox{2D} CNN applied to individual frames of a video performed comparably to I3D on the Sports-1M dataset. This work~\cite{Carreira2017} demonstrated that there is considerable benefit to transfer learning in videos. Kinetics-600~\cite{ Carreira2018}, the second iteration of the Kinetics dataset contains about $500,000$ $10$-second long videos sourced from YouTube that correspond to $600$ classes.
The aforementioned transfer learning results inspired a subsequent work~\cite{Tran2018} that reconsidered~\hbox{3D} CNNs in the context of residual learning. ResNets use skip connections to speed up network learning and permit substantially deeper networks that can learn more complex functions. \hbox{3D} ResNets have additional dimensions, \hbox{3D} convolutions and \hbox{3D} pooling. Three-dimensional ResNets outperformed~\hbox{2D} ResNets in action recognition. The team also investigated several forms of spatio-temporal convolution:~\hbox{2D} convolution on frames,~\hbox{2D} convolution on clips,~\hbox{3D} convolution, \hbox{2D-3D} convolution, and a factorization of~\hbox{3D} convolution into~\hbox{2D} spatial convolution followed by~\hbox{1D} temporal convolution ($R(2+1)D$ convolution). Using $R(2+1)D$ convolution doubled the number of nonlinearities in the network. This facilitated gradient optimization and enabled more complex function representations. During evaluation experiments, the $R(2+1)D$ convolutional block achieved state-of-the-art accuracy on the Kinetics-400 and Sports-1M datasets. The team also investigated whether the model supported transfer learning by pre-training on Kinetics-400 and Sports-1M and then fine-tuning on UCF101 and HMDB51. In the transfer learning experiment $R(2+1)D$ outperformed all other methods except for I3D, which uses Kinetics-400 and ImageNet for pre-training. Table \ref{tab:action-recognition-summary-table} summarizes the action recognition approaches discussed in this section, and their performance on UCF101.
\noindent \textbf{Improving Computational Cost of \hbox{3D} CNNs:}
MF-Net uses an ensemble of lightweight networks (fibers) instead of one complex network to improve performance while reducing computation cost. The \hbox{3D} Multi-Fiber architecture was designed for human action recognition and achieved better accuracy on Kinetics-400, UCF101, and HMDB51 compared to other \hbox{3D} CNNs like $I3D$~\cite{Carreira2017} and $R(2+1)D$~\cite{Tran2018} while using fewer FLOPs.
\section{Animal Behavior Classification} \label{sec:animalbehavior}
This section reviews adaptations of the learning models presented in Sections~\ref{sec:hpe} and~\ref{sec:actionrecognition} for animal behavior classification. We focus on models that analyze small laboratory animals in neuroscience. Figure~\ref{fig:venndiagram} gives a graphical overview of the classification frameworks, pose estimation and tracking methods organized by the CNN networks they use. Figure~\ref{fig:actionrecognition} shows the relationship of several animal classification approaches to spatio-temporal infrastructures for human action recognition. Figure~\ref{fig:animalbehaviormodelaction} shows the relationship of techniques reviewed in this section to human action recognition and human pose estimation methods. We include systems that are significantly different so that important developments in the underlying deep learning architectures are represented. We also indicate validation animal types, social interaction support, and whether depth cameras are required. Optical flow methods are identified. Human pose estimation taxonomy categories~\cite{Zheng2020} (Section~\ref{sec:hpe}) are shown.
We begin with background information on manual scoring for labeling videos, with a brief overview of the challenges with traditional vision approaches that lead to breakthroughs in deep learning-based classification solutions. In Sections~\ref{sec:ape2d} and~\ref{sec:ape3d}, we review animal pose estimation as many frameworks require a pose estimation before presenting our taxonomy for organizing these frameworks in Section~\ref{sec:taxonomy}.
\textbf{Manual Behavior Scoring:} Quantification of animal behavior is important in ethology and behavioral neuroscience~\cite{gulinello2019rigor}. However, it is well known that manual scoring of animal behavior videos is time-intensive, costly, and subjective~\cite{gulinello2019rigor}. Subtle fine-level behaviors may go undetected as behaviors must be pre-defined~\cite{reynolds2013effects}. Manual behavioral scoring is also subject to human bias as results can vary between different research labs and between researchers within the same lab~\cite{gulinello2019rigor, Bohnslav2021,Segalin2021}. Moreover, individual scorers themselves may drift over time as they gain experience~\cite{koncz2017measuring}. Thus, scoring by the same individual may change across different sessions.
\textbf{Traditional Methods} use automated software to facilitate manual behavior scoring. There are several challenges with the application of these methods across research labs. Early automated methods often relied on specialized equipment like depth cameras~\cite{Wiltschko2015} which may be costly or require expertise to operate. Some methods require that markers are placed on animals~\cite{Mathis2018} for motion tracking. The use of markers is less desirable because they can be intrusive, and their locations must be determined a priori. Markers can also distract the animal in a way that alters its behavior and skews experimental results. It is common for traditional systems to use older computer vision processing techniques~\cite{Datta2019} without incorporating neural networks. These methods require supervision in the form of pre-selected labels specified by the researcher. They also require highly controlled laboratory environments and have limited ability to track multiple animals. Commercial software and other solutions that do not offer publicly available open-source code are harder to reuse and adapt for different experiments.
\textbf{The Promise of Deep Learning Solutions:} Deep learning methods are better suited for these problems~\cite{Graving2019,Nath2019} as they permit multiple unmarked animals to be tracked in almost any context, including in-the-wild. These techniques are widely applicable because they generally operate using RGB cameras and are often developed as open-source platforms. Some open-source solutions outperform commercial software with added flexibility for customization which can facilitate adoption. Pose-based approaches are relatively subjective and may not generalize across labs and experiments if animals vary in size or camera frame rates are different~\cite{Hsu2021}. Approaches that classify behavior directly from raw pixel values without estimating pose mitigate this issue and simplify the behavior classification pipeline~\cite{Bohnslav2021}. Data dependent factors make systems difficult to generalize pipelines(frame-rate, intensities)~\cite{ Berman2018}. We now review several deep learning algorithms that have led to advancements in behavior analysis in neuroscience.
\subsection{\hbox{2D} Animal Pose Estimation}\label{sec:ape2d}
This section reviews CNN network architectures for \hbox{2D} animal pose estimation that leverage methods discussed in Sections~\ref{sec:hpe} and~\ref{sec:actionrecognition}. We cover \hbox{3D} techniques in the next section. Table~\ref{tab:table-animal-pose-estimation} summarizes the key contributions of \hbox{2D} and \hbox{3D} animal pose estimation methods, indicating validation animal types, method type, and the number of cameras required. Coarse level supervision is indicated (pink: supervised, blue: unsupervised). Common animal behavior video datasets are found in Table~\ref{tab:behavior-video-datasets-table}.
An early deep learning-based approach for \hbox{2D} animal pose~\cite{Wiltschko2015} classified sub-second structure in mice behavior using unsupervised learning. The approach first compressed videos of freely moving mice using principal component analysis (PCA). It then used an auto regressive hidden Markov model to segment the compressed representation into discrete behavioral syllables, identifiable modules (like grooming and rearing) whose sequence is governed by definable transition statistics. The technique requires special depth cameras. These are limiting because they may not detect very small laboratory animals and reconstructing full \hbox{3D} poses is challenging without multiple camera viewpoints.
DeepLabCut~\cite{Mathis2018} was the first tool to extend human pose estimation techniques to the animal pose estimation problem~\cite{MATHIS20201}. The approach modified the feature detector architecture in DeeperCut~\cite{Insafutdinov2016} which builds upon ResNet (Section~\ref{hpi-from-images} and Figure~\ref{fig:venndiagram}). The toolkit tracks multiple animals' \hbox{3D} poses in \hbox{2D} images. Camera calibration with one or more cameras is used to find \hbox{3D} keypoint locations. DeepLabCut requires $200$ labeled frames because it uses a model pretrained on ImageNet. Multi-animal DeepLabCut~\cite{Lauer2022} extends DeepLabCut to the multi-animal setting. The authors achieve this by adopting aspects of three CNN architectures~\cite{He2016,Tan2019,Cao2021} and using a transformer~\cite{Zhu2020,Li2021} architecture to reidentify animals when they leave the field of view.
\begin{figure}[ht]
\begin{center}
\includegraphics[width=\linewidth]{img-PE-relationship-AR.eps}
\caption{Animal Behavior Classification Frameworks and the Action Recognition, Pose Estimation and Tracking Methods they Use or Build Upon.}
\label{fig:animalbehaviormodelaction}
\end{center}
\end{figure}
\begin{table} [h]
\begin{center}
\begin{tabular}{| m{0.25\columnwidth} | m{0.05\columnwidth} | m{0.12\columnwidth} | m{0.07\columnwidth} | m{0.12\columnwidth} | m{0.12\columnwidth} |}
\hline
Dataset & Year & Trimmed & Size & Social & Classes \\
\hline
Clipped Mouse \cite{Jhuang2010} & $2010$ & \cmark & $4,268$ & \xmark & $8$ \\
\hline
Full Mouse \cite{Jhuang2010} & $2010$ & \xmark & $12$ & \xmark & $8$ \\
\hline
CRIM13 \cite{BurgosArtizzu2012} & $2012$ & \xmark & $474$ & \cmark & $13$ \\
\hline
Sturman -- EPM \cite{Sturman2020} & $2020$ & \xmark & $24$ & \xmark & $6$ \\
\hline
Sturman -- FST \cite{Sturman2020} & $2020$ & \xmark & $29$ & \xmark & $2$ \\
\hline
Sturman -- OFT \cite{Sturman2020} & $2020$ & \xmark & $20$ & \xmark & $4$ \\
\hline
Mouse -- \hbox{Ventral1} \cite{Bohnslav2021} & $2021$ & \xmark & $14$ & \xmark & $28$ \\
\hline
Mouse -- \hbox{Ventral2} \cite{Bohnslav2021} & $2021$ & \xmark & $14$ & \xmark & $16$ \\
\hline
Mouse --\hbox{OpenField} \cite{Bohnslav2021} & $2021$ & \xmark & $20$ & \xmark & $6$ \\
\hline
\hbox{Mouse --} HomeCage \cite{Bohnslav2021} & $2021$ & \xmark & $11$ & \xmark & $8$ \\
\hline
Mouse -- Social \cite{Bohnslav2021} & $2021$ & \xmark & $12$ & \cmark & $6$ \\
\hline
Fly \cite{Bohnslav2021} & $2021$ & \xmark & $19$ & \xmark & $2$ \\
\hline
\end{tabular}
\end{center}
\vspace{5pt}
\caption{Common Animal Behavior Video Datasets}
\label{tab:behavior-video-datasets-table}
\end{table}
LEAP~\cite{Pereira2019} was designed to estimate poses in videos of individual mice and fruit flies. It adapts three CNNs originally developed for human pose estimation~\cite{TompsonJ2014,Wei2016,Newell2016} into a fully convolutional architecture that predicts heat-maps for body parts from frames. The solution uses an active learning (Section~\ref{sec:background}) approach that requires at least $10$ labeled frames. Two-dimensional pose is estimated at each time step. A spectrogram is computed for the time-series of each joint using a continuous wavelet transform. Spectrograms are then concatenated and embedded in a~\hbox{2D} manifold (behavior space) where each video is represented as a feature vector that captures \hbox{2D} pose dynamics across time. The behavior space distribution is then clustered to identify classes of behaviors. The complete pipeline from pose estimation to behavioral clustering for behavior recognition is semi-supervised. The output of LEAP was used for unsupervised analysis of the fly behavior repertoire.
SLEAP (Social LEAP)~\cite{Pereira2022}, the successor to LEAP, is a general framework for multi-animal pose estimation. It implements bottom-up and top-down pipelines, identity tracking using motion and appearance models, and over $30$ neural network architectures. Our graphical overview (Figure~\ref{fig:venndiagram}) uses the default architecture used in SLEAP, a version of UNet~\cite{Ronneberger2015}. UNet is an encoder-decoder architecture designed for segmentation of biomedical images. SLEAP is designed to be flexible to allow the comparison of part grouping approaches, identity tracking approaches, and neural network architecture properties. SLEAP achieves comparable or improved accuracy when compared to DeepPoseKit, LEAP, and DeepLabCut for single-animal pose estimation with faster inference speed.
DeepPoseKit~\cite{Graving2019} is a single-animal \hbox{2D} pose estimation method. The project evaluates two models: a new stacked DenseNet CNN~\cite{Jegou2017} network, and a modified stacked hourglass network~\cite{Newell2016} that has origins in human pose estimation. In DenseNets~\cite{Huang2017dense}, each layer is connected to every other layer in a feed-forward fashion to mitigate the vanishing gradient problem and decrease parameterization. The stacked hourglass architecture~\cite{Newell2016} is an encoder-decoder network with several pooling and upsampling layers. Each hourglass module processes features to a low resolution then upscales and combines the features from multiple scales. This design captures information at every scale and allows intermediate supervision. Of the two methods, the stacked DenseNet was found to perform better.
Previous pose estimation methods like DeepLabCut have not been effective in tracking multiple identical animals. AlphaTracker~\cite{Chen2020} is a recently developed tool for multiple-animal tracking that adapts a human pose estimation algorithm, AlphaPose, for animal pose estimation. The positions of animals in each frame are detected using YOLOv3~\cite{Redmon2018arxiv}. The resulting bounding boxes are cropped and fed to a Squeeze-and-Excitation network (SE-Net)~\cite{Hu2018} to estimate pose, and the identities of mice are tracked across frames. Squeeze-and-Excitation (SE) networks~\cite{Hu2018} use SE blocks to improve a CNNs representational capacity by explicitly modeling the interdependencies between convolutional feature channels. Training requires labels, though features extracted from the keypoints are clustered into individual or social behaviors using hierarchical clustering in an unsupervised manner. Calibration is automated.
\vspace{10pt}
\noindent\textbf{Speed Accuracy Trade-Off}
When choosing a pose estimation architecture, the speed-accuracy trade-off must be considered~\cite{Huang2017speed}. DeepLabCut prioritizes accuracy over speed by using a large over-parameterized model (ResNet). This overparameterization leads to relatively slow inference but maintains accurate predictions. The LEAP system \cite{Pereira2019} prioritizes speed by using a smaller less-robust model. Although it has a faster inference time, it is less robust to data variance and less likely to generalize to different environments. DeepPoseKit aims to improve processing speed without sacrificing accuracy, and reports that the approach is about three times as accurate as LEAP, as accurate as DeepLabCut~\cite{Mathis2018}, and twice as fast as both (Table \ref{tab:poseaccuracy}).
\begin{table}[h]
\begin{center}
\begin{tabular}{|c | c | c|}
\hline
Approach & Mean Accuracy & Inference Speed (Hz) \\
\hline
DeepLabCut~\cite{Mathis2018} & $0.33$ & $520$ \\
\hline
LEAP~\cite{Pereira2019} & $0.13$ & $560$ \\
\hline
DeepPoseKit~\cite{Graving2019} & $0.35$ & $1000$ \\
\hline
\end{tabular}
\end{center}
\vspace{5pt}
\caption{Inference Speed and Posterior Mean Accuracy for \hbox{2D} Animal Pose Estimation Approaches. Data sourced from~\cite{Graving2019}.}
\label{tab:poseaccuracy}
\end{table}
\subsection{\hbox{3D} Animal Pose Estimation}\label{sec:ape3d}
A two-dimensional pose is an incomplete representation of an animal's behavior as occlusions (that hide limbs) result in loss of important information. Camera viewing parameters also affect how movement is quantified. DeepLabCut used a printed checkerboard target to calibrate cameras for~\hbox{3D} pose estimation. This type of target would not work well for analyzing small animals like flies (the Drosophila melanogaster fly is $2.5$ mm long). Calibration patterns would have to be extremely small, and color would introduce imaging artifacts at translucent body parts. DeepFly3D~\cite{Gunel2019} adapted the stacked hourglass network architecture~\cite{Newell2016} and added tools to compute the accurate~\hbox{3D} pose of Drosophila melanogaster using the fly itself as the camera calibration target. Although the approach can be used for any animal type or species, it requires multiple camera views. Like LEAP,~\hbox{2D} pose data and~\hbox{3D} joint angles are used for unsupervised behavioral classification by clustering after~\hbox{3D} pose estimation. When the two data sources were compared, classification using \hbox{3D} joint angles resulted in clearer clusters of behaviors. LiftPose3D~\cite{Gosztolai2021} only requires one camera view, a prism mirror, and $1,000 - 10,000$ training images. The approach is based on a CNN architecture developed for mapping~\hbox{2D} human poses to~\hbox{3D} poses using a single camera view~\cite{Martinez2017} (Section ~\ref{sec:hpe}). Another method, Anipose~\cite{Karashchuk2021}, built on DeepLabCut, allows \hbox{3D} reconstruction from multiple cameras using a wider variety of methods.
MouseVenue3D~\cite{Han2022} contributed an automated \hbox{3D} behavioral capture system that uses multi-view cameras to estimate \hbox{3D} pose in marker-less rodents. This work showed that \hbox{3D} behavioral data yields improved performance in behavior recognition tasks compared to \hbox{2D} behavioral data.
\subsection{Tracking} \label{sec:tracking}
Here, we review two tracking methods used by the animal behavior classification frameworks we discuss.
CTrax~\cite{Branson2009} is a computer vision system designed to identify the position and orientation of multiple flies in a 2D arena in each frame of input videos. Flies are detected first through background subtraction and then fitting an ellipse to each fly by fitting a Gaussian to each fly's pixel locations. Next, flies are assigned identities using the Hungarian algorithm for minimum-weight perfect bipartite matching.
MoTr (Mouse Tracker)~\cite{Ohayon2013} is a computer vision system similar to CTrax~\cite{Branson2009} designed for tracking multiple mice in a 2D arena. Flies are detected through background subtraction and fitting ellipses to mice using the expectation-maximization algorithm. Then a hidden Markov model is used to associate mouse identities with trajectories. Multiple mice are recognized in overhead videos by applying distinct patterns to the back of each mouse and training a classifier on histogram of oriented gradients (HOG)~\cite{Dalal2005} features extracted from image patches containing individual mice.
\subsection{Taxonomy for Animal Behavior Classification} \label{sec:taxonomy}
This section provides a high-level overview of animal behavior classification frameworks for small laboratory animals. We outline a general taxonomy that organizes methods as supervised or unsupervised at a coarse level, and with varying degrees of supervision influenced by inputs, framework components and learning strategies. Supervised methods require manual labels for classification while unsupervised methods automatically cluster the data and assign labels. Within these groups we consider the influence of hand-crafted features, labels (Pose or Behavior), pose estimation (PE), optical flow, and residual learning. We focus on optical flow and residual learning as a study~\cite{Nguyen2019} showed improvement when using \hbox{3D} CNNs pre-trained to recognize human behaviors, then fine-tuned on mouse behavior datasets. This study used two-stream fusion with I3D and R(2+1)D by calculating optical flow on a dataset of solitary mice videos~\cite{Jhuang2010}. R(2+1)D uses residual learning. Table~\ref{tab:table-animal-action} summarizes key contributions of these frameworks with coarse level of supervision indicated (pink: supervised, blue: unsupervised). The table also indicates whether pose estimation or depth cameras are required, the type of animal used for validation, and whether there is support for individual or social interactions. Figures~\ref{fig:posebased},~\ref{fig:SNoPE} and ~\ref{fig:USNoPE} diagram a representative set of systems (posed-based, supervised without pose estimation, and unsupervised without pose estimation respectively).
\begin{figure*}
\begin{center}
\begin{tabular}{ |l|l| }
\hline
\multicolumn{2}{ |c| }{Taxonomy for Animal Behavior Classification} \\
\hline
\rowcolor{lightPink}
\multicolumn{2}{ |c| }{Supervised Classification} \\
\hline
\rowcolor{lightPink}
Hand-crafted Features, Behavior Labels & \cite{Rousseau2000}, \cite{Dankert2009}, \cite{Jhuang2010}, \cite{BurgosArtizzu2012}, \cite{Giancardo2013}, \cite{Kabra2013}, \cite{Hong2015}, \cite{Lorbach2018}, \cite{DeChaumont2019}, \cite{Gabriel2022} \\
\hline
\rowcolor{lightPink}
Behavior Labels & \cite{Le2019}, \cite{VanDam2020}, \cite{Hu2022}\\
\hline
\rowcolor{lightPink}
\hbox{Hand-crafted Features, Pose and Behavior Labels, PE} & \cite{Segalin2021}, \cite{Stewart2016}, \cite{Sturman2020}, \cite{Arac2019}, \cite{Li2022}, \cite{Nilsson2020} \\
\hline
\rowcolor{lightPink}
Pose and Behavior Labels, PE & \cite{Zhou2022b} \\
\hline
\rowcolor{lightPink}
Optical Flow, Hand-crafted Features, Behavior Labels & \cite{VanDam2013}\\
\hline
\rowcolor{lightPink}
\hbox{Residual Learning, Optical Flow, Behavior Labels} & \cite{Bohnslav2021}\\
\hline
\rowcolor{lightPink}
\hbox{Residual Learning, Pose and Behavior Labels, PE} & \cite{Zhou2022}\\
\hline
\rowcolor{lightPink}
Residual Learning, Optical Flow, Behavior Labels & \cite{Marks2022}\\
\hline
\rowcolor{lightBlue}
\multicolumn{2}{ |c| }{Unsupervised Classification} \\
\hline
\rowcolor{lightBlue}
Hand-crafted Features, Pose Labels, PE & \cite{Hsu2021}\\
\hline
\rowcolor{lightBlue}
Fully Unsupervised & \cite{Stephens2008}, \cite{Berman2014}, \cite {Wiltschko2015}, \cite{Batty2019}, \cite{Brattoli2021}, \cite{Jia2022}\\
\hline
\end{tabular}
\caption{Taxonomy for Animal Behavior Classification.Pink: supervised, Blue: unsupervised}
\label{tab:taxonomy}
\end{center}
\end{figure*}
\vspace{10pt}
\noindent\textbf{Supervised Classification} requires behavior labels.
\begin{itemize}
\vspace{6pt}
\item \textbf{Hand-crafted Features, Behavior Labels:} These examples use computer vision processing methods to fit shapes (ellipses) to the animal body, extract features, and apply neural networks to classify learned features to behaviors.
\begin{description}
\vspace{6pt}
\item [\textbf{--}]One of the first works to apply neural networks to animal behavior analysis~\cite{Rousseau2000} trained a three-layer feed-forward neural network on $3$ parameters that describe a rat's position, achieving a $63\%$ accuracy over nine behaviors.
\vspace{6pt}
\item [--] Caltech Automated Drosophila Aggression-Courtship Behavioral Repertoire Analysis (CADABRA)~\cite{Dankert2009} measured social behaviors from overhead videos of fly pairs. Fly bodies were localized~\cite{Bishop2006}, and fitted with ellipses before calculating features (size, position and velocity). K-nearest-neighbors was used to classify actions from the features.
\vspace{6pt}
\item [\textbf{--}]A later study~\cite{Jhuang2010} extracted per-frame features of a rodent and used a SVM hidden Markov model (SVMHMM)~\cite{Altun2003} to output behavioral labels. The primary dataset was a single black mouse with a white background. A dataset with per-frame labels of eight solitary behaviors of a mouse in a standard enclosure over ten hours was also released.
\vspace{6pt}
\item [\textbf{--}] The next development~\cite{BurgosArtizzu2012} focused on social interaction between two mice with unconstrained colors. The algorithm tracks rodents, calculates features, and applies AdaBoost to classify trajectory and spatiotemporal context features. The Caltech Resident-Intruder Mouse (CRIM13) dataset \cite{BurgosArtizzu2012} was released with $13$ action classes and $237$ $10$-minute videos ($8$ million frames, over $88$ hours) of top and side views of mice pairs engaging in social behavior. A $2013$ study~\cite{Giancardo2013} generalized this framework to support more mice and different experimental settings using a temporal random forest classifier.
\vspace{6pt}
\item [\textbf{--}]Janelia Automatic Animal Behavior Annotator (JAABA) system \cite{Kabra2013} (Figure~\ref{fig:SNoPE}) fits ellipses to body outlines using CTrax (Section~\ref{sec:tracking}), and then calculates per-frame features from the trajectory. A Gentleboost algorithm~\cite{Friedman2000} classifies behaviors using per-frame \emph{window} features and manually collected behavior labels.
\vspace{6pt}
\item [\textbf{--}] Later Hong et. al.~\cite{Hong2015} trained a random forest classifier on location, appearance, and movement features extracted from egocentric depth maps, and five learned pose parameters to identify social rodent behaviors. A social behavior analysis project~\cite{Lorbach2018} used GMM and EM algorithms (like CTrax) to track features.
\vspace{6pt}
\item [\textbf{--}]LiveMouseTracker~\cite{DeChaumont2019} is a method for real-time tracking of rodent trajectories for behavior analysis of up to four mice. An infrared-depth camera segments and removes the background from frames, and a random forest algorithm identifies rodents and their orientations (shape and posture) from labels. Individual and social behavioral traits were extracted.
\vspace{6pt}
\item [\textbf{--}] DEcoding Behavior Based on Positional Tracking (BehaviorDEPOT) \cite{Gabriel2022} is a software program for behavior recognition in videos. It uses heuristics to measure human-defined behaviors from pose estimation data (from DeepLabCut) that are easier to interpret than traditional supervised machine learning methods.
\end{description}
\end{itemize}
\begin{itemize}
\vspace{6pt}
\item \textbf{Behavior Labels:} These approaches use labels but avoid hand-crafted features as they must be defined a priori and may not generalize to different behaviors~\cite{Hu2022}.
\begin{description}
\vspace{6pt}
\item [\textbf{--}] A \hbox{3D} CNN~\cite{Le2019} similar to C3D was used to extract short-term spatio-temporal features from clips. These features are fed to an RNN with LSTM blocks to produce long-term features. A SoftMax layer outputs the probabilities of behaviors in each clip. This approach slightly underperformed when compared to an approach that used handcrafted features~\cite{Jhuang2010}.
\vspace{6pt}
\item [\textbf{--}] A multi-fiber neural network (MF-Net)~\cite{VanDam2020,Chen2018} (Figure~\ref{fig:SNoPE}) has been used to classify videos for rat behavior recognition (RBR). The architecture has one \hbox{3D} convolutional layer followed by four multifiber convolutional blocks. Results outperformed the prior work of this team~\cite{VanDam2013} when tested on the same dataset (see discussion of EthoVision XT RBR). However, MF-Net uses data augmentation which did not generalize to different set-ups or animals. Note one less successful option in the paper used optical flow.
\vspace{6pt}
\item [\textbf{--}]The LabGym~\cite{Hu2022} framework provides customizable combinations of neural networks to assess spatiotemporal information in videos. It runs easily on a common laptop, without the need for powerful GPUs required by DeepEthogram~\cite{Bohnslav2021} and SIPEC~\cite{Marks2022} (which we describe later). It is not optimized for social behavior analysis but is effective for invertebrate and mammal behavior analysis.
\end{description}
\end{itemize}
\begin{itemize}
\vspace{6pt}
\item \textbf{Hand-crafted Features, Pose and Behavior Labels, PE:}
\begin{description}
\vspace{6pt}
\item [\textbf{--}] The Mouse Action Recognition
System (MARS)~\cite{Segalin2021} (Figure~\ref{fig:posebased}) focuses on social behaviors between a black and white mouse. It adapts a stacked hourglass architecture (Section~\ref{sec:ape2d}) with eight hourglass subunits to estimate pose. The rolling feature-window method from JAABA is used to calculate handcrafted features over a time window. XGBoost~\cite{Chen2016b} is trained to predict behaviors given the window features.
\vspace{6pt}
\item [\textbf{--}]The DeepBehavior toolbox~\cite{Arac2019} (Figure~\ref{fig:posebased}) uses a version of GoogLeNet~\cite{Stewart2016} or OpenPose~\cite{Cao2021} (depending on the species) for kinematic analysis of three rodent behaviors in~\hbox{3D}. Stewart and colleagues designed an architecture~\cite{Stewart2016} for multiple object detection using GoogLeNet to encode images into high level descriptors before decoding the representation into a set of bounding boxes using an LSTM layer. Experiments were conducted using one or two cameras.
\vspace{6pt}
\item [\textbf{--}]Simple Behavior Analysis (SimBA)~\cite{Nilsson2020} (Figure~\ref{fig:posebased}) classifies behaviors based on the locations of certain key points, or joint locations, obtained from~\hbox{2D} pose estimation methods (like DeepLabCut, LEAP and DeepPoseKit). After detecting poses, outliers are identified and corrected. There are $498$ metrics calculated from corrected pose data over rolling windows (like JAABA). Random forest classifiers are trained to predict behavior classes given the calculated features. In a related approach~\cite{Sturman2020}, DeepLabCut is used for per-frame pose estimation, before applying a feedforward neural network to classify pose features as behaviors. Sturman et al.~\cite{Sturman2020} released three video datasets of mice behavioral tests, including the open field test (OFT), elevated plus maze (EPM), and forced swim test (FST).
\vspace{6pt}
\item [\textbf{--}] OpenLabCluster~\cite{Li2022} contributed unsupervised clustering (Section~\ref{sec:background}) of pose features using a deep recurrent encoder-decoder architecture and an active learning approach (Section~\ref{sec:background}). In the latter approach, at each iteration, one sample is labeled, and the cluster map is refined. A fully-connected network is appended to the encoder to perform classification trained on labeled samples. The results produce fast and accurate classification in four animal behavior datasets with sparse labels.
\end{description}
\end{itemize}
\begin{itemize}
\vspace{6pt}
\item \textbf{Pose and Behavior Labels, PE:}
\begin{description}
\vspace{6pt}
\item [\textbf{--}] ConstrastivePose~\cite{Zhou2022b} uses contrastive learning to reduce differences in pose estimation features and its random augmented version, while increasing differences with other examples. These features have a similar structure as handcrafted features and perform comparably on semi-supervised behavior classification.
\end{description}
\end{itemize}
\begin{itemize}
\vspace{6pt}
\item \textbf{Optical Flow, Hand-crafted Features, Behavior Labels:}
\begin{description}
\vspace{6pt}
\item [\textbf{--}] The EthoVision XT RBR~\cite{ethovisionXT8,VanDam2013} is commercial software that tracks features using optical flow estimated with the Lucas-Kanade algorithm~\cite{Lucas1981,Baker2004}. Features are reduced to a low-dimensional space using the Fisher linear discriminant analysis~\cite{Fukunaga2013} before applying a quadratic discriminant for classification. The testing dataset (solitary rats with per-frame labels of $13$ behaviors) is not public.
\end{description}
\end{itemize}
\begin{itemize}
\vspace{6pt}
\item \textbf{Residual Learning, Optical Flow, Behavior Labels:}
\begin{description}
\vspace{6pt}
\item [\textbf{--}] DeepEthogram~\cite{Bohnslav2021} (Figure~\ref{fig:SNoPE}) generates an ethogram (a set of user defined behaviors of interest). The system builds upon a two-stream approach that computes optical flow on the fly. First the flow generator is trained on unlabeled videos, while the user labels each frame of some videos in parallel. ResNet models extract per-frame flow and spatial features. A CNN with Temporal Gaussian Mixture (TGM) layers \cite{Piergiovanni2018} learns a latent hierarchy of sub-event intervals from untrimmed videos for temporal action detection. The TGM has a large temporal receptive field, and outputs the final probabilities that indicate whether the behavior exists at each frame. Thus, this method integrates aspects of action detection methods (Section~\ref{sec:motivation}) as information from seconds ago helps classify current behaviors. Five benchmark datasets of mice in different arenas were released, including one with social interaction, and one with flies to test if the system generalized to other species.
\end{description}
\end{itemize}
\begin{itemize}
\vspace{6pt}
\item \textbf{Residual Learning, Pose and Behavior Labels, PE:}
\begin{description}
\vspace{6pt}
\item [\textbf{--}] A recent work~\cite{Zhou2022} models interactions between mice using a Cross-Skeleton Interaction Graph Aggregation Network (CS-IGANet). A Cross-Skeleton Node-level Interaction (CS-NLI) models multi-level interactions between mice and fuses multi-order features. An Interaction-Aware Transformer for the dynamic graph updates, and node-level representations, was proposed. DeepLabCut is used to estimate pose for datasets without pose labels. A self-supervised task for measuring the similarity of cross-skeleton nodes was also proposed. This approach outperforms other approaches on the CRIM13 dataset.
\end{description}
\end{itemize}
\begin{itemize}
\vspace{6pt}
\item \textbf{Residual Learning, Optical Flow, Behavior Labels:}
\begin{description}
\vspace{6pt}
\item [\textbf{--}]Segmentation, Identification, Pose-Estimation and Classification (SIPEC)~\cite{Marks2022} contributed multiple deep neural network architectures for individual and social animal behavior analysis in complex environments. These networks operate on pixels. SegNet~\cite{Badrinarayanan2017} is a well-known CNN architecture for pixel-wise segmentation of images on which SIPEC:SegNet is built. SIPEC:IdNet uses DenseNet to produce visual features that are integrated over time through a gated recurrent unit network~\cite{Chung2014} to reidentify animals when they enter or exit the scene. SIPEC:PoseNet performs top-down multi-animal pose estimation. SIPEC:BehaveNet uses an Xception network~\cite{Chollet2017} and a Temporal Convolution Network~\cite{Oord2016} to classify behaviors from raw pixels. This system was the first to classify social behaviors in primates without pose estimation. Note that the classification pipeline (which is our focus) is not pose-based.
\end{description}
\end{itemize}
\vspace{10pt}
\noindent \textbf{Unsupervised Classification:} These methods do not require behavior labels for the classification step. The learning process may require input from a supervised pose estimation system (that requires labels). However, the final classification is determined by an automated process that generates and assigns labels (like numeric values) to the output of a clustering system.
\begin{itemize}
\vspace{6pt}
\item \textbf{Hand-crafted Features, Pose Labels, PE:}
\begin{description}
\vspace{6pt}
\item [\textbf{--}] Behavioral Segmentation of Open-field in DeepLabCut (B-SoiD)~\cite{Hsu2021} (Figure~\ref{fig:posebased}), uses DeepLabCut (Section~\ref{sec:ape2d}), to obtain six joint locations (snout, four paws, tail base) per-frame, then calculates spatiotemporal relationships (speed, angular change, and distance between joints). Features (like speed) are projected from a High-dimensional space to a low-dimensional space using UMAP~\cite{McInnes2018}. HDBScan~\cite{Campello2015} clusters the results, and a random forest classifier is trained to predict behaviors directly from high-dimensional features without the computationally expensive clustering step. The need to evaluate and transfer non-linearities from dimensionality reduction is also avoided.
\end{description}
\end{itemize}
\begin{itemize}
\vspace{6pt}
\item \textbf{Fully Unsupervised:}
\begin{description}
\vspace{6pt}
\item [\textbf{--}] PCA has been applied to a worm's centerline (which describes most of a worm's behavior) to represent the \emph{eigenworm}~\cite{Stephens2008} as three values. Unsupervised learning has been used to detect behaviors as sequences of eigenworm positions~\cite{Brown2013}, before clustering using affinity propagation~\cite{Frey2007}.
\vspace{6pt}
\item [\textbf{--}] MotionMapper~\cite{Berman2014} (Figure~\ref{fig:USNoPE}) classifies fruit fly behaviors. The system shows that fruit fly posture can be captured by a low dimensional subspace of eigenmodes. PCA analysis projects a processed (segmented, resized and aligned) frame (to a set of 50-dimensional time-series. A Morlet wavelet transform~\cite{Goupillaud1984} is then applied to create a spectrogram for each postural mode. The wavelet's multi-resolution time-frequency trade-off reflects postural dynamics at different time scales. Then, t-SNE~\cite{VanDerMaaten2008} is used to embed the spectrograms to a \hbox{2D} space and preserve the local structure of clusters. Finally, a watershed transform~\cite{Meyer1994} segments the embedding and identifies individual behavior peaks. In a related approach~\cite{Vogelstein2014}, a type of hierarchical clustering is used to describe the behaviors of Drosophila larvae. This experiment characterized behavior through the identification of $29$ atomic movements and four movement categories. MotionMapper~\cite{Klibaite2017} was later extended to classify paired fruit-fly behaviors by first segmenting the two flies in each frame.
\vspace{6pt}
\item [\textbf{--}] Motion Sequencing (MoSeq)~\cite{Wiltschko2015, Wiltschko2020}, (Figure~\ref{fig:USNoPE}), embeds a depth video of an animal into a ten-dimensional space using PCA. An AR-HMM is then fit to the principal components to generate behavioral syllables, producing a dynamical and behavioral representation. The need for a parameter that controls the time scale of transitions between behavioral states can be eliminated by finding motifs of varied lengths~\cite{Brown2013} or using time-frequency analysis like a wavelet transform~\cite{Berman2014,Klibaite2017}. Wavelet transforms can capture multi-scale postural dynamics.
\vspace{6pt}
\item [\textbf{--}] BehaveNet~\cite{Batty2019} (Figure~\ref{fig:USNoPE}) builds upon MoSeq~\cite{Wiltschko2015}. It uses convolutional autoencoders (CAEs) instead of PCA to generate a low-dimensional continuous representation of behavior. An AR-HMM is used to segment the representation into behavioral syllables.
\vspace{6pt}
\item [\textbf{--}] Unsupervised behavior analysis and magnification (uBAM) \cite{Brattoli2021} introduces a neural network designed to compare behaviors, and another designed to magnify differences in behavior. This allows classification behavior extraction and analysis of small behavioral differences, without using any pose or behavior labels.
\vspace{6pt}
\item [\textbf{--}] Self-supervised Feature Extraction (Selfee)~\cite{Jia2022} (Figure~\ref{fig:USNoPE}), trains a network to extract suitable classification features from unlabeled videos (about $5$ million). Two Siamese CNNs based on ResNet-50 learn a discriminative feature representation of behavior with a training rate that is faster ($8$ hours on one GPU) than modern self-supervised models. Note that this paper also included a classification example that used labels.
\end{description}
\end{itemize}
\begin{table*}[t]
\begin{center}
\begin{tabular}{| m{2cm} | m{0.5cm} | m{1.3cm} | m{1.8cm} | m{0.75cm} | m{1.2cm} | m{7.5cm} |}
\hline
Method & Year & Multiple Animals & Validated & 2D/3D & Multiple Cameras & Key Contribution(s) \\
\hline
\rowcolor{lightPink}
DeepLabCut \cite{Mathis2018} & $2018$ & \xmark & \hbox{Mice, Flies,} Humans, Horses, Fish & 2D/3D & \cmark &
\begin{itemize}[leftmargin=*]
\item The application of the DeeperCut \cite{Insafutdinov2016} feature detector architecture, that was originally designed for human pose estimation, to animal pose estimation.
\end{itemize}\\
\hline
\rowcolor{lightPink}
LEAP \cite{Pereira2019} & $2019$ & \xmark & Mice, Flies & 2D & \xmark &
\begin{itemize}[leftmargin=*]
\item The design of a CNN architecture inspired by three human pose estimation architectures~\cite{TompsonJ2014,Wei2016, Newell2016}. The CNN is shallow and is trained from scratch to improve inference speed compared to DeepLabCut at the expense of less robustness and requiring more training data to achieve the same performance.
\end{itemize}\\ \hline
\rowcolor{lightPink}
DeepPoseKit \cite{Graving2019} & $2019$ & \cmark \hbox{(if not} occluded) & \hbox{Flies, Locusts,} Zebras & 2D & \xmark &
\begin{itemize}[leftmargin=*]
\item The development of a stacked DenseNet architecture \cite{Newell2016} \cite{Jegou2017}~\cite{Huang2017dense} to improve speed and robustness.
\end{itemize} \\
\hline
\rowcolor{lightPink}
DeepFly3D \cite{Gunel2019} & $2019$ & \xmark & Flies, \hbox{Humans} & 3D & \cmark &
\begin{itemize} [leftmargin=*]
\item The adaptation of a stacked hourglass architecture \cite{Newell2016} to permit 3D pose estimation using multiple cameras.
\end{itemize} \\
\hline
\rowcolor{lightPink}
Anipose \cite{Karashchuk2021} & $2021$ & \xmark & \hbox{Flies, Mice,} \hbox{Humans} & 3D & \cmark &
\begin{itemize}[leftmargin=*]
\item The introduction of filters to improve 2D tracking and a novel triangulation procedure for 3D pose estimation using multiple cameras.
\end{itemize}\\
\hline
\rowcolor{lightPink}
LiftPose3D \cite{Gosztolai2021} & $2021$ & \xmark & \hbox{Flies, Mice,} Monkeys & 3D & \xmark &
\begin{itemize}[leftmargin=*]
\item The adaptation of an architecture designed for lifting 2D human pose into 3D~\cite{Martinez2017} for monocular 3D animal pose estimation.
\end{itemize}\\
\hline
\rowcolor{lightPink}
Multi-animal DeepLabCut \cite{Lauer2022} & $2022$ & \cmark & Mice, \hbox{Monkeys,} Fish & 2D/3D & \cmark &
\begin{itemize} [leftmargin=*]
\item The development of a multi-task architecture which identifies keypoints, assembles them to predict limbs, then assigns them to individuals. This formulation allows for the tracking of multiple animals in one scene.
\end{itemize} \\
\hline
\rowcolor{lightPink}
SLEAP \cite{Pereira2022} & $2022$ & \cmark & \hbox{Mice, Flies,} Bees, Gerbils & 2D & \xmark &
\begin{itemize}[leftmargin=*]
\item The design of a novel multi-animal pose tracking system that incorporates multiple CNN architectures and approaches for part grouping and identity tracking.
\end{itemize} \\
\hline
\end{tabular}
\end{center}
\vspace{5pt}
\caption{Animal Pose Estimation Methods. Pink: supervised.}
\label{tab:table-animal-pose-estimation}
\end{table*}
\begin{table*}
\begin{center}
\begin{tabular}{| m{2cm} | m{0.5cm} | m{0.7cm} | m{0.7cm} | m{1.2cm} | m{0.7cm} | m{8cm} |}
\hline
Method & Year & Pose Based & Social & Validated & Depth Cam. & Key Contribution(s) \\
\hline
\rowcolor{lightPink}
JAABA \cite{Kabra2013} & $2013$ & \cmark & \cmark & Mice, Flies & \xmark &
\begin{itemize} [leftmargin=*]
\item The development of a supervised behavior classification system usable by biologists.
\item A set of per-frame features are computed from the pose trajectories that are input to an optimized GentleBoost learning algorithm~\cite{Friedman2000}.
\end{itemize} \\
\hline
\rowcolor{lightBlue}
MotionMapper \cite{Berman2014} & $2014$ & \xmark & \cmark & Flies & \xmark &
\begin{itemize} [leftmargin=*]
\item The design of an unsupervised behavior classification pipeline in invertebrates in which frames are segmented, scaled, aligned, then decomposed via PCA.
\item A spectrogram is created for each postural mode, then each point in time is mapped to a 2D plane using t-SNE. Peaks are identified after the application of a watershed transform.
\end{itemize} \\
\hline
\rowcolor{lightBlue}
MoSeq \cite{Wiltschko2015, Wiltschko2020} & 2015 & \xmark & \xmark & Mice & \cmark &
\begin{itemize} [leftmargin=*]
\item The design of an unsupervised approach to identify behavioral modules in vertebrates.
\item After compressing mice videos using PCA, an AR-HMM is used to segment the representation into discrete behavioral syllables.
\end{itemize} \\
\hline
\rowcolor{lightPink}
DeepBehavior \cite{Arac2019} & $2019$ & \cmark & \cmark & Mice, \hbox{Humans} & \xmark &
\begin{itemize} [leftmargin=*]
\item The adaptation of GoogLeNet~\cite{Szegedy2015} and YOLO-v3 \cite{Redmon2018arxiv} CNN architectures to identify rodent behaviors individually and socially, respectively.
\end{itemize} \\
\hline
\rowcolor{lightBlue}
BehaveNet \cite{Batty2019} & $2019$ & \xmark & \xmark & Mice & \xmark &
\begin{itemize} [leftmargin=*]
\item The introduction of a probabilistic framework for the unsupervised analysis of behavioral videos and neural activity.
\item The use of a CAE to compress videos before they are segmented into discrete behavioral syllables using an AR-HMM.
\item A generative model that can be used to simulate behavioral videos given neural activity.
\end{itemize} \\
\hline
\rowcolor{lightBlue}
B-SoiD \cite{Hsu2021} & $2021$ & \cmark & \xmark & Mice & \xmark &
\begin{itemize} [leftmargin=*]
\item The dimensionality reduction of pose features produced by DeepLabCut \cite{Mathis2018} using UMAP.
\item The use of HDBScan to cluster the embedded features and the subsequent training of a random forest classifier to predict behaviors directly from high-dimensional pose features.
\end{itemize} \\
\hline
\rowcolor{lightPink}
SimBA \cite{Nilsson2020} & $2020$ & \cmark & \cmark & Mice, Rats & \xmark &
\begin{itemize}[leftmargin=*]
\item The design of a pose-based approach to rodent social behavior analysis with tools to increase ease-of-use for behavioral neuroscientists.
\item The classification of behaviors based on positions of recognized joints.
\end{itemize} \\
\hline
\rowcolor{lightPink}
MARS \cite{Segalin2021} & $2021$ & \cmark & \cmark & Mice & \xmark &
\begin{itemize} [leftmargin=*]
\item The development of a pose-based approach to recognize social behaviors between a black and white mouse.
\end{itemize} \\
\hline
\rowcolor{lightPink}
DeepEthogram \cite{Bohnslav2021} & $2021$ & \xmark & \cmark & Mice, Flies & \xmark &
\begin{itemize} [leftmargin=*]
\item The design of a novel supervised approach that operates on raw pixel values.
\item Optical flow is estimated from video clips using MotionNet \cite{Zhu2019}, flow and spatial features are compressed, and then a sequence model estimates the probability of each behavior in each frame.
\end{itemize} \\
\hline
\end{tabular}
\end{center}
\vspace{5pt}
\caption{Animal Behavior Classification Frameworks. Pink: supervised, Blue: unsupervised} \label{tab:table-animal-action}
\end{table*}
\begin{figure*}
\begin{center}
\begin{tabular}{ c }
\includegraphics[width=\textwidth]{img-deepBehavior.eps}\\
DeepBehavior~\cite{Arac2019} \\
\includegraphics[width=\textwidth]{img-bsoid.eps}\\
Behavioral Segmentation of Open Field in DeepLabCut (B-SOiD)~\cite{Hsu2021} \\
\includegraphics[width=\textwidth]{img-simBA.eps}\\
Simple Behavior Analysis (SimBA)~\cite{Nilsson2020} \\
\includegraphics[width=\textwidth]{img-mars.eps}\\
Mouse Action Recognition System (MARS)~\cite{Segalin2021} \\
\end{tabular}
\end{center}
\caption{Pose-based Animal Behavior Classification Frameworks}
\label{fig:posebased}
\end{figure*}
\begin{figure*}
\begin{center}
\setlength\tabcolsep{0.5pt}
\begin{tabular}{ p{0.5\textwidth} p{0.5\textwidth} }
\includegraphics[width=0.5\textwidth]{img-jaaba.eps} &
\includegraphics[width=0.5\textwidth]{img-mfnet.eps} \\
\centering{Janelia Automatic Animal Behavior Annotator (JAABA)~\cite{Kabra2013}} &
\centering{Multi-fiber Network (Van Dam et al., 2020)} \\
\end{tabular}
\begin{tabular}{ c }
\includegraphics[width=\textwidth]{img-deepEthogram.eps} \\
DeepEthogram~\cite{Bohnslav2021} \\
\end{tabular}
\caption{Supervised Animal Behavior Classification Frameworks that Operate on Pixel Values without Pose Estimation}
\label{fig:SNoPE}
\end{center}
\end{figure*}
\begin{figure*}[h]
\begin{center}
\begin{tabular}{ c }
\includegraphics[width=\textwidth]{img-motionMapper.eps} \\
MotionMapper~\cite{Berman2014} \\
\end{tabular}
\setlength\tabcolsep{0.5pt}
\begin{tabular}{ p{0.5\textwidth} p{0.5\textwidth} }
\includegraphics[width=0.5\textwidth]{img-moSeq.eps} &
\includegraphics[width=0.5\textwidth]{img-behaveNet.eps} \\
\centering{Motion Sequencing (MoSeq)~\cite{Wiltschko2015,Wiltschko2020}}&
\centering{BehaveNet~\cite{Batty2019}} \\
\end{tabular}
\begin{tabular}{ c }
\includegraphics[width=\textwidth]{img-selfee.eps} \\
Selfee (Jia et al., 2022) \\
\end{tabular}
\caption{Unsupervised Animal Behavior Classification Frameworks that Operate on Pixel Values without Pose Estimation.}
\label{fig:USNoPE}
\end{center}
\end{figure*}
\section{Discussion and Future Directions}\label{sec:discussion}
\noindent This section discusses future research that investigates adaptations of action recognition for animal behavior classification.
\vspace{10pt}
\noindent Action recognition has many practical applications as many professions use automated methods to interpret motion from publicly available or privately acquired videos. Although we are motivated by problems with behavior analysis in neuroscience, these research topics are relevant to several application spaces. Recognizing player movements in gaming~\cite{Bloom2012}, monitoring infants~\cite{Moccia2019}, preventative healthcare for the elderly, and hand-object pose estimation in augmented and virtual reality environments~\cite{Doosti2020} are examples.
\vspace{10pt}
\noindent There are opportunities to further evaluate human action recognition methods on animal behavior classification problems. Human action recognition methods are mature compared to emerging developments in animal behavior classification~\cite{JIANG2022103483}. Adapting CNN-based action recognition methods not yet considered in this domain would be beneficial to address domain specific problems like occlusion from hidden limbs on small subjects, as well as historical challenges like processing high-resolution videos. Action recognition methods work on trimmed videos while many animal behavior methods operate on untrimmed videos with labeled frames. Frames with a broad range of non-class activities may be indicated by a single background class. Accurate evaluation of new methods on existing benchmark datasets will require special handling when the data varies between these domains. Many CNN architectures operate on low resolution videos. Higher resolution data, or increased kernel sizes (for detecting long range dependencies) increase computation time. There is a need to consider CNN-based systems that are customized to address the speed accuracy trade-off. The following research topics are relevant:
\vspace{10pt}
\noindent\textbf{Fully Unsupervised Behavior Classification:} Behavior analysis is important for diagnosing and treating neurological disorders~\cite{MATHIS20201}. The human action recognition techniques we reviewed were supervised or semi-supervised, requiring labeled videos. Manual labeling of videos is time consuming and inconsistent~\cite{gulinello2019rigor}. Unsupervised animal behavior classification systems~\cite{Berman2014,Wiltschko2015,Wiltschko2020,Batty2019,Jia2022} are few, and open challenges remain. Our taxonomy (Section~\ref{sec:taxonomy}) shows that many methods that are broadly classified as unsupervised are discriminative and pose-based. Many steps still require hand-crafted features, or labels in complex systems. Unsupervised classification systems would remove manual scoring and inconsistencies that might skew results~\cite{gulinello2019rigor,Bohnslav2021,Segalin2021}. In addition, new micro-scale behaviors that are not pre-defined in a behavior collection may be discovered. Approaches that operate on unstructured data should be able to identify behaviors at different time scales and organize behavior in a hierarchical structure.
\vspace{10pt}
\noindent \textbf{Action Recognition in Crowds and Complex Social Environments:} Many behavioral studies aim to understand complex social behaviors of multiple subjects in intricate environments. In these scenarios, identifying the behavior of multiple subjects performing individual actions in the same frame is challenging. Pose-based action recognition systems that use two-stage inference are more prone to errors when there are multiple overlapping body parts. A common error is the assignment of the same limbs to multiple subjects. In the domain of animal behavior classification, CS-IGANet and other works~\cite{BurgosArtizzu2012} can classify multi-subject behaviors in social datasets like the CRIM13 resident-intruder mouse~\cite{BurgosArtizzu2012} dataset. However, these approaches do not predict individual actions of each subject. SIPEC~\cite{Marks2022} is one of the first examples to have success identifying behaviors of individual subjects in a social setting. There is a need to investigate networks that evaluate dense activity (swarms) in \emph{in-the-wild} conditions.
\vspace{10pt}
\noindent \textbf{Robust Multi-modal Action Recognition:} Multimodal data capture has been used to describe an animal's dynamics in social interactions. Multi-modal sensing for behavior recognition is important as a more complete behavior representation may be achieved by combining heterogenous information from different sensory devices. However, it is a challenge to fuse and work with motion information across different sensory devices, and when there are significant variations in environmental lighting conditions. Networks that operate on multimodal data from different imaging modalities would be effective for interoperability.
\section{Conclusion} \label{sec:conclusion}
Automated classification of activity performed by humans in videos is an important problem in computer vision with applications in many fields. We presented a thorough and detailed review of CNN architectures developed for two related tasks: human action recognition, and human pose estimation. We traced the development of these network architectures, examining design decisions that increased performance on benchmark image and video datasets. We focused our paper on techniques that have been modified for animal behavior classification tasks. Our taxonomy for animal behavior classification frameworks is more comprehensive than others because we consider model inputs and system components that influence more varied levels of supervision. We discussed and compared the components of several of these behavior classification systems, highlighting challenges and future research directions. We believe this survey will inspire future work in action recognition, its adaptation for animal behavior classification, and new evaluation metrics that compare neural network performance across different levels of supervision.
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2023-01-18T02:15:14', 'yymm': '2301', 'arxiv_id': '2301.06187', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06187'} | arxiv |
\section{Introduction}
\label{sec:Introduction}
Lower-limb exoskeletons are used to assist impaired individuals in their daily life and as a tool for physical rehabilitation in clinical settings~\cite{Moreno2018, 6930719}. They are also increasingly used to augment the abilities of healthy individuals~\cite{Sawicki2020}.
In each of these applications, the exoskeleton must be capable of regulating the interaction forces and torques between the user and the exoskeleton, both for the safety of the user and the effectiveness of the control mode.
As an example, the \emph{transparent} control mode attempts to zero the interaction forces between the user and the exoskeleton. Transparency is useful for comparison when evaluating new rehabilitation control strategies~\cite{Marchal-Crespo2019-zo} and for allowing users to move freely when wearing assistive devices~\cite{Lee2017}. Other control modes, used in rehabilitation, include ``assist as needed'' (AAN) and resistive control for robot-aided gait therapy~\cite{Hobbs2020}. With AAN, the robot provides only as much assistance force as needed to complete a given task~\cite{Baud2021}. In resistive and error-augmentation methods, force is applied to make the task more challenging, which accelerates the relearning of motor tasks~\cite{Marchal-Crespo2009, Marchal-Crespo2019-zo}.
An important part of controlling interaction forces is compensating the weight of the lower-limb exoskeleton. How the weight of the exoskeleton is transferred to the ground or the user depends on its design. There are three main categories of design:
\paragraph{Grounded trunk}
The trunk of the exoskeleton is fixed relative to a treadmill structure~\cite{colombo2000treadmill, Banala2007, Veneman2007}. Due to the grounded trunk, only the masses of the individual leg links are felt by the user, and these masses can be compensated with active control.
\paragraph{Floating base (trunk) without feet}
These exoskeletons are designed for unrestricted overground walking and do not contact the ground~\cite{MurraySA2015Anstroke, Tsukahara2018, Mayag2022}. Partial gravity compensation can be achieved for the swing leg, but it is not possible for the robot to completely carry its own weight since there is no contact with the ground. Such exoskeletons are designed to be as light as possible, which limits their maximum assistance/resistance and battery life.
\paragraph{Floating base with feet}
These exoskeletons are designed for unrestricted overground walking and have feet that contact the ground~\cite{Camardella2021, VantiltJ2019Model-basedmovements, Andrade2019, Andrade2021, Tu2020, Sharifi2021, Kazerooni2006}. The weight of the exoskeleton can be transferred to the ground through the exoskeleton's foot contact. While this allows for stronger actuators and larger batteries, it comes at the cost of more complicated controllers or diminished haptic transparency.
In this paper we focus on floating base lower-limb exoskeletons with feet, for which controlling interaction forces remains an open problem~\cite{TRO_Special}.
Solving this challenging problem will allow more natural overground therapy by rehabilitation robots and larger assistive forces by assistive devices.
Due to the high torque requirements of floating base exoskeletons with feet, high reduction ratios are used, which results in high friction and apparent inertia of motor rotors~\cite{Andrade2021Role}. Also, these exoskeletons are heavy due to powerful actuators and large batteries. Therefore, it is essential to compensate for these factors to accurately control the interaction forces and torques between the user and the robot.
Another challenge is measuring the interaction torques between the human and the exoskeleton. Grounded exoskeletons typically have a small number of contacts with the user, and interaction forces can be directly measured by force sensors implemented at the contacts~\cite{Banala2007, ZanottoD2013Improvingcuffs, vanDijkW2013Improvingwalking}. In contrast, floating base exoskeletons have broadly distributed contact with the user, including at the trunk and foot. This makes it impractical to implement force/torque sensors at all contacts.
Therefore, it is required to indirectly estimate the interaction forces and torques through other sensory information.
In this paper, we present a novel whole-exoskeleton closed-loop compensation (WECC) controller to estimate and control user-exoskeleton interaction torques during the complete gait cycle of a floating-base hip-knee exoskeleton with feet. The controller, which is based on constrained optimization, outperforms the state of the art in achieving transparency (zero impedance) and nonzero impedances in the user-exoskeleton interaction behavior.
The context of the contribution of this paper is established by the related work below.
\subsection{Related Work}
\label{sec:Related_Work}
\begin{table*}
\centering
\caption{Selected features of the interaction force/torque control studies. Note that this paper focuses on floating-base lower-limb exoskeletons with feet. Therefore, this table does not include studies with grounded exoskeletons and floating-base lower-limb exoskeletons without feet.}
\begin{tabular}{c c c c c c c}
\cline{1-6}
\rule{0pt}{2ex}
Reference & Model & \makecell{Interaction force\\ feedback} & \makecell{User\\dependent} & \makecell{Instrumentation\\ on user} & \makecell{Physical/safety \\limit implementation} \\ \cline{1-6}
\makecell{Camardella et al.,\\ 2021 \cite{Camardella2021}} & Whole-body & No & Yes & No & No \\
\cline{1-6}
\makecell{Vantilt et al.,\\ 2019 \cite{VantiltJ2019Model-basedmovements}} & Whole-body & No & No & No & No \\
\cline{1-6}
\makecell{Andrade et al.,\\ 2019-21 \cite{Andrade2019, Andrade2021}} & \makecell{Independent\\ double pendulums} & \makecell{PD\\ controller} & No & No & No \\
\cline{1-6}
\makecell{Tu et al.,\\ 2020 \cite{Tu2020}} & \makecell{Independent\\ double pendulums} & \makecell{Admittance\\ controller} & No & No & No \\
\cline{1-6}
\makecell{Sharifi et al.,\\ 2021 \cite{Sharifi2021}} & \makecell{Whole-body\\(learnt by NN)} & No & Yes & No & No \\
\cline{1-6}
\makecell{Kazerooni et al., \\ 2006 \cite{Kazerooni2006}} & \makecell{3-link for swing\\no model for stance\\(position control)} & \makecell{Sensitivity\\Amplification} & \makecell{No (transparency)\\Yes (non-zero reference)} & Yes & No \\
\cline{1-6}
\makecell{Our proposed\\method (WECC)} & Whole-body & \makecell{Admittance\\ controller} & No & No & Yes \\
\hline
\hline
\end{tabular}
\label{tab:related_work}
\end{table*}
Previous studies on controlling interaction forces with floating base lower-limb exoskeletons with feet can be divided into three main categories.
\subsubsection{Whole-body dynamics compensation with no interaction force feedback}
A lower-limb exoskeleton can be modeled as a floating base system considering all links and joints together, similar to a bipedal robot~\cite{Pratt1997, Mistry2020}. While bipedal robots are only in contact with the ground, lower-limb exoskeletons are also in contact with the user through multiple connection points.
Vantilt et al.~\cite{VantiltJ2019Model-basedmovements} implemented a whole-body floating base model while considering external contact constraints such as ground contact or contact with a stool. They estimated the contact forces based on a complementary energy method~\cite{Vantilt2018} using the stiffness values of the exoskeleton parts together. However, this method does not allow the calculation of interaction torques between the human and robot, as the contact points between the human and exoskeleton are not static. Camardella et al.~\cite{Camardella2021} similarly modeled the full-body dynamics but constituted the equation of motion based only on a model of a single foot in contact with the ground. Even though only left and right stance models were used, they interpolated the dynamics during double stance between left and right stance models based on a user-dependent continuous gait state estimation.
These studies compensated for the gravitational and Coriolis torques calculated using the whole-body model. However, modeling errors were not corrected with interaction force feedback, and desired interaction torques were used only as a feedforward term. The use of series elastic actuation \cite{VantiltJ2019Model-basedmovements, Vantilt2018} or torque motors with tendon-based transmission \cite{Camardella2021} results in low friction and high joint torque control capabilities, which reduces modeling errors. However, these solutions
are not typically used in commercially-available devices like the ExoMotus-X2 exoskeleton studied in this paper.
\subsubsection{Simplified double pendulum model with interaction force feedback}
Andrade et al.~\cite{Andrade2019, Andrade2021}, and Tue et al.~\cite{Tu2020} employ a simpler, non-whole-body model of the exoskeleton to help estimate interaction torques. In this simplified model, each leg is modeled as an independent double pendulum 2R robot. When the leg is swinging, the hip joint is assumed to be fixed. When the leg is in contact with the ground, the ankle joint is assumed to be pinned. This model is used to calculate the feedforward compensation torques, which consist of inertial, gravitational, and Coriolis forces. These terms are subtracted from the joint torque measurements to estimate the interaction torques between the human and exoskeleton. Interaction torque estimation is used as the input of a proportional-derivative (PD) or admittance controller.
Since the backpack is not modeled and the legs are modeled independently, the dynamic compensation torques and interaction torque estimates are not accurate for the stance leg. With this approach, the stance leg carries only its own weight instead of the weight of the entire exoskeleton. While this might be acceptable for light or grounded exoskeletons, it is not accurate for exoskeletons designed for overground walking that provide a high level of support and long battery life.
\subsubsection{User-dependent or user-instrumented approaches}
Since physical parameters and walking gaits vary from user to user, some interaction force controllers require additional sensors to be affixed to the user and/or custom tuning for each user.
Sharifi et al.~\cite{Sharifi2021} implemented a neural network scheme to learn the whole-body dynamics of the exoskeleton together with the user. In the learning phase, the user is asked to relax while the exoskeleton applies predefined torque patterns. The learned passive dynamics are subtracted from the actual motor torques to estimate the human-robot interaction torque. Because the dynamics are learned based on the motor torque recordings, frictional effects are included in the model. Therefore, this method does not require additional sensors to measure the joint torques, and motor current measurements are enough. On the other hand, the main drawback of this method is that the learned dynamics is user-dependent, and a training phase is required for each user.
Kazerooni et al.~\cite{Kazerooni2006} implemented a hybrid controller where the exoskeleton's stance leg follows the joint positions of the user to provide haptic transparency. The joint positions of the user's leg are measured by inclinometers attached to it. For the swing leg, a sensitivity amplification controller was implemented, which compensates for the dynamics of the swing leg and reacts to the disturbances applied by the user to minimize the interaction torques. One drawback of this method is the required additional instrumentation on the user that increases the time to don and doff the exoskeleton. Moreover, if it is required to provide nonzero desired interaction torques, this would require a model of the user-dependent interaction properties to calculate desired joint positions of the stance leg.
\subsubsection{Summary}
Selected features of interaction force/torque control studies on floating base lower-limb exoskeletons that contact the ground are presented in Table~\ref{tab:related_work}. These studies can be categorized into three main groups. First, there are studies where the whole-body dynamics of the exoskeleton are compensated with no interaction force feedback~\cite{Camardella2021, VantiltJ2019Model-basedmovements, Sharifi2021}. Second, some studies modeled the exoskeleton as two independent legs with no consideration of the backpack~\cite{Andrade2019, Andrade2021, Tu2020}. These studies implemented PD or admittance controllers based on the interaction force/torque error. Third, there are methods that require additional instrumentation on the user~\cite{Kazerooni2006} or user-dependent learning for model or gait state estimation~\cite{Sharifi2021, Camardella2021}. None of the proposed control methods considers actuation limits or other safety requirements such as velocity limits.
To the best of our knowledge, there is no study that calculates interaction forces with full body dynamics during the whole gait cycle and uses this estimation in a closed-loop control for a floating-base lower-limb exoskeleton that is in contact with the ground.
\subsection{Contributions}
In this paper, we propose a novel subject-independent method to calculate interaction forces during both single and double stance configurations based on a whole-body dynamic model. Moreover, we propose constrained optimization combined with a virtual model controller to achieve desired interaction torques while considering physical and safety constraints.
We evaluated the transparency and spring-damper haptic-rendering performance of our proposed whole-exoskeleton closed-loop compensation (WECC) controller on treadmill walking. We compared the performance of WECC controller to a control approach based on a simplified dynamic model of the exoskeleton, where the legs are modeled as double pendulums independent of one another and the backpack is ignored~\cite{Andrade2021Role, Andrade2019, Andrade2021, Tu2020}.
For transparency evaluations, we also tested the performance of a passive version of the exoskeleton with disassembled drives.
We observed that the transparency of the swing leg was similar under the three conditions (WECC, Simplified, and No-drive), but our proposed WECC method outperformed the simplified controller and the no-drive condition for the stance leg. In nonzero impedance haptic rendering, WECC and simplified controllers performed similarly for the swing leg, but our WECC controller tracked the desired interaction torques better for the stance leg.
The core contributions of this article are as follows:
\begin{enumerate}
\item A continuous whole-body forward dynamical model for the whole gait cycle is developed based on the ratios of the vertical ground reaction forces at the feet.
\item A novel method to estimate the interaction forces during both single and double stance configurations is proposed.
\item A constrained-optimization-based virtual mass controller is implemented that considers the underactuation of the exoskeleton and its physical/safety constraints to control the interaction torques.
\item The transparency and haptic rendering performance of our proposed WECC controller is compared to a state-of-the-art controller based on a simplified dynamic model.
\end{enumerate}
\section{System Description and Modeling }
\subsection{Lower-limb Exoskeleton: X2}
\label{ssec:X2}
A four degrees-of-freedom (DoF) lower limb exoskeleton (ExoMotus-X2, Fourier Intelligence, Singapore), shown in Figure~\ref{fig:x2}, was adapted and used as a platform to test the proposed interaction torque controller. The X2 robot has four total active degrees of freedom at the hip and knee joints, and passively allows motion at the ankle joints. Each active joint is driven by a Maxon EC60 100~W motor with a 1:122.5 reduction ratio obtained via harmonic gearing and a belt. Copley Accelnet ACK-055-06 motor drivers are used to control the motors. A peak torque of 80~Nm and a peak velocity of 3.2~rad/s can be obtained at each joint.
Due to the high friction caused by the large reduction ratio, it is not feasible to estimate the joint torques by only measuring the current through the motors. Therefore we modified the X2 robot to add joint torque sensors at each driven joint. Each torque sensor consists of a full Wheatstone bridge with four strain gauges on the limb just distal to the joint, similar to the method presented by Claros et al.~\cite{Claros2016}. These custom joint torque sensors provide measurements with a resolution of 0.3~Nm and 0.1~Nm at the hip and knee joints, respectively. Furthermore, to have a tighter connection with the upper body, an additional trunk brace was adopted from another lower-limb exoskeleton (Exo-H3, Technaid S.L.).
An inertial measurement unit (IMU) (Tech-IMU V4 by Technaid S.L.) is mounted on the backpack to measure the orientation and angular velocity of that link. Using the encoder measurements from each motor and orientation estimation of the backpack, the orientation of each link in the sagittal plane with respect to the gravity vector is estimated. In addition, eight 3-DoF force plates (9047B, Kistler) under a custom instrumented split-belt treadmill are used to measure ground reaction forces at each foot.
Communication with motors and onboard sensors was established over a CAN bus using the CANOpen communication protocol. To minimize communication delay and allow real-time visualization and tuning capabilities, an external PC is connected to the exoskeleton by a tether. Analog force plate readings are acquired with an Arduino Mega board connected to the same PC. The controllers and applications were implemented on a ROS and C++ based open-source software stack called CANOpen Robot Controller (CORC)~\cite{FongCanOpenDevelopment}. High-level controller commands and sensor measurements were updated at 333~Hz, while the low-level current controller of the motors ran at 15~kHz.
\begin{figure}[t!]
\centering
\includegraphics[width = 1\columnwidth]{figures/x2_with_and_wo_user_no_background.png}
\caption{ExoMotus-X2 lower-limb exoskeleton (left) and its modified version with a user (right).}
\label{fig:x2}
\end{figure}
\subsection{Dynamic Model}
Our proposed WECC control method is based on a whole-body model where we incorporate the saggital plane dynamics of every link of the exoskeleton, including the backpack.
\subsubsection{Whole-body dynamics}
The exoskeleton is modeled as a floating base, a five-link mechanism with four active joints. The dynamics of the human user are not modeled but incorporated into the exoskeleton dynamics as a source of external torque at each joint. For each gait state, the constraints on the system and the equations of motion are modified accordingly. These gait states are no ground contact (\emph{flight}), contact by a single foot (\emph{single stance}), and contact by two feet (\emph{double stance}).
\begin{figure}
\centering
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
semithick]
\tikzstyle{every state}=[draw=black, text=black, minimum size=1cm, align=center]
\node[state] (ls) {Left\\stance};
\node[state] (fly) [above right of=ls] {Flight};
\node[state] (ds) [below right of=ls] {Double\\stance};
\node[state] (rs) [below right of=fly] {Right\\stance};
\path (ls) edge [bend left] node[sloped] {${F_{\text{l}}} < F_{\text{lim}}$} (fly)
edge node[sloped] {${F_{\text{r}}} \geq F_{\text{lim}}$} (ds)
edge [loop left] node[below,pos=0.2] {${F_{\text{l}}} \geq F_{\text{lim}}$} (ls)
(fly) edge [loop above] node[left,pos=0.2] {${F_{\text{l}}}, {F_{\text{r}}} < F_{\text{lim}}$} (fly)
edge [bend left] node[sloped] {${F_{\text{r}}} \geq F_{\text{lim}}$} (rs)
edge node[sloped, below] {${F_{\text{l}}} \geq F_{\text{lim}}$} (ls)
(rs) edge [bend left] node[sloped, below] {${F_{\text{l}}} \geq F_{\text{lim}}$} (ds)
edge node[sloped, below] {${F_{\text{r}}} < F_{\text{lim}}$} (fly)
edge [loop right] node[above,pos=0.2] {${F_{\text{r}}} \geq F_{\text{lim}}$} (rs)
(ds) edge [loop below] node[right,pos=0.2] {${F_{\text{l}}}, {F_{\text{r}}} \geq F_{\text{lim}}$} (ds)
edge [bend left] node[sloped, below] {${F_{\text{r}}} < F_{\text{lim}}$} (ls)
edge node[sloped] {${F_{\text{l}}} < F_{\text{lim}}$} (rs);
\end{tikzpicture}
\caption{Gait state machine used in real-time estimation and control. The variables ${F_{\text{l}}}$ and ${F_{\text{r}}}$ are left and right vertical force readings, respectively. The threshold force that triggers state change is represented by $F_{\text{lim}}$. States are not allowed to change more than once every 150 ms for robustness to noise.}
\label{fig:gait_state}
\end{figure}
Gait states were estimated using the force plates placed under the split-belt treadmill. Figure~\ref{fig:gait_state} presents the state machine structure on gait state estimation.
\paragraph{Flight}
In the flight state, the only external forces on the exoskeleton are due to interaction with the user. The equation of motion in generalized coordinates is
\begin{equation}
\mt{M}_\text{fly}(\mt{q}_\text{fly})\ddot{\mt{q}}_\text{fly} + \mt{b}_\text{fly}(\mt{q}_\text{fly},\dot{\mt{q}}_\text{fly}) + \mt{g}_\text{fly}(\mt{q}_\text{fly}) = S^T\mt{\tau}_\text{joint} + \mt{\tau}_\text{int},
\label{eq:FlyingEoM}
\end{equation}
where $\mt{q_\text{fly}} = [x_0, y_0, \theta_0, \theta_1, \theta_2, \theta_3, \theta_4]$ is a vector of generalized coordinates corresponding to the linear and angular positions of the backpack and the hip and knee joint angles, as shown in Figure~\ref{fig:flight}. The variable $\mt{M}_\text{fly} \in \mathbb{R}^{7\times 7}$ is the mass matrix, $\mt{b}_\text{fly} \in \mathbb{R}^7$ is a vector of Coriolis and centrifugal forces, and $\mt{g}_\text{fly} \in \mathbb{R}^7$ a vector of gravitational forces. The vector $\mt{\tau}_\text{joint} \in \mathbb{R}^4$ corresponds to joint torques, $S = [0_{4\times 3}, \mathbb{I}_{4\times 4}]$ is a selection matrix of actuated joints, and $\mt{\tau}_\text{int} \in \mathbb{R}^7$ is a vector of interaction forces and torques applied to the exoskeleton by the user.
\paragraph{Single stance}
In single stance, the ankle of the stance leg is assumed to be hinged to the ground. With this assumption, the exoskeleton has five degrees of freedom. The generalized coordinates and equations of motion are
\begin{equation}
\mt{M}_i(\mt{q})\ddot{\mt{q}} + \mt{b}_i(\mt{q},\dot{\mt{q}}) + \mt{g}_i(\mt{q}) = S^T\mt{\tau}_\text{joint} + \mt{\tau}_\text{int}, \;\: i\in \{\text{ls}, \text{rs}\},
\label{eq:SSEoM}
\end{equation}
where $\mt{q} = [\theta_0, \theta_1, \theta_2, \theta_3, \theta_4]$ are the generalized coordinates corresponding to the backpack, hip, and knee angles, as shown in Figure~\ref{fig:ss}. The matrix and vectors $\mt{M}_i \in \mathbb{R}^{5\times 5}, \mt{b}_i \in \mathbb{R}^5, \mt{g}_i \in \mathbb{R}^5$, are the mass matrix, Coriolis and centrifugal torques, and gravitational torques respectively during left stance ($i = \text{ls}$) and right stance ($i = \text{rs}$). The variable $\mt{\tau}_\text{joint} \in \mathbb{R}^4$ corresponds to joint torques, $S = [0_{4\times 1}, \mathbb{I}_{4\times 4}]$ is a selection matrix of actuated joints, and $\mt{\tau}_\text{int} \in \mathbb{R}^5$ is a vector of interaction torques applied to the exoskeleton by the user.
\paragraph{Double stance}
This state can be expressed as the single stance state with additional external forces on the swing foot as expressed in Equation~\eqref{eq:DS1},
\begin{equation}
\begin{split}
&\mt{M}_i(\mt{q})\ddot{\mt{q}} + \mt{b}_i(\mt{q},\dot{\mt{q}}) + \mt{g}_i(\mt{q}) = S^T\mt{\tau}_\text{joint} + \mt{\tau}_\text{int} + J_j^T\Gamma_j, \\ &(i,j)\in \{(\text{ls}, \text{r}), (\text{rs}, \text{l})\},
\label{eq:DS1}
\end{split}
\end{equation}
where $J_j$ and $\Gamma_j$ corresponds to the contact Jacobian of the left ($j$ = l) or right ($j$ = r) ankle and the external forces at that point, respectively. Multiplying Equation~\eqref{eq:DS1} by the transpose of the constraint matrix, $H \in \mathbb{R}^{5\times 3}$, where $JH = 0$, results in the following equation of motion.
\begin{equation}
\begin{split}
&H_j^T(\mt{M}_i(\mt{q})\ddot{\mt{q}} + \mt{b}_i(\mt{q},\dot{\mt{q}}) + \mt{g}_i(\mt{q}) - \mt{\tau}_\text{int}) = H_j^TS^T\mt{\tau}_\text{joint}, \\ &(i,j)\in \{(\text{ls}, \text{r}), (\text{rs}, \text{l})\}.
\label{eq:DS2}
\end{split}
\end{equation}
Interested readers may refer to~\cite{Li2021} for the details of the constraint matrix $H$ and Equations~\eqref{eq:DS1}--\eqref{eq:DS2}. It is worth noting that Equation~\eqref{eq:DS2} is three-dimensional, which means the system is overactuated during the double stance state. This results in discontinuity in the equation of motion and the dynamic compensation torques during the transitions between single and double stance states. Moreover, the overactuated nature of this state brings additional challenges to the interaction torque estimation, as discussed in Section~\ref{sec:int_torque_control}.
Due to these challenges, we approximate the double stance state as a transition phase from left stance to right stance or vice versa. The approximated equation of motion at this state is
\begin{equation}
\mt{M}_\text{ds}(\mt{q})\ddot{\mt{q}} + \mt{b}_\text{ds}(\mt{q},\dot{\mt{q}}) + \mt{g}_\text{ds}(\mt{q}) = S^T\mt{\tau}_\text{joint} + \mt{\tau}_\text{int} ,
\label{eq:DSEoM}
\end{equation}
where
\begin{align}
\mt{M}_\text{ds} &= \alpha\mt{M}_\text{ls} + (1-\alpha)\mt{M}_\text{rs},
\label{eq:DSEoM1} \\
\mt{b}_\text{ds} &= \alpha\mt{b}_\text{ls} + (1-\alpha)\mt{b}_\text{rs},
\label{eq:DSEoM2} \\
\mt{g}_\text{ds} &= \alpha\mt{g}_\text{ls} + (1-\alpha)\mt{g}_\text{rs}.
\label{eq:DSEoM3}
\end{align}
The variable $\alpha$ in Equations~\eqref{eq:DSEoM1}--\eqref{eq:DSEoM3} corresponds to the interpolation factor from left stance dynamics to right stance dynamics and is calculated based on the ratio of the left vertical ground reaction force to the sum of both vertical ground reaction forces,
\begin{equation}
\alpha = \frac{{F_{\text{l,y}}^\text{treadmill}}}{{F_{\text{l,y}}^\text{treadmill}} + {F_{\text{r,y}}^\text{treadmill}}},
\label{eq:interpolationFactor}
\end{equation}
where ${F_{\text{l,y}}^\text{treadmill}}$ and ${F_{\text{r,y}}^\text{treadmill}}$ are left and right vertical ground reaction forces, respectively. Interpolating the equation of motion from left stance dynamics to right stance dynamics allows smooth continuous modeling of the whole gait cycle during walking. The difference of this method from the work of Camardella et al.~\cite{Camardella2021} is that their kinematic-based gait segmentation is user-dependent and requires a training procedure.
\begin{figure}
\centering
\begin{subfigure}{0.25\textwidth}
\centering
\includegraphics[height=\textwidth]{figures/flying_v3.png}
\caption{Flight}
\label{fig:flight}
\end{subfigure}%
\begin{subfigure}{0.25\textwidth}
\centering
\includegraphics[height=\textwidth]{figures/single_stance_v3.png}
\caption{Single stance}
\label{fig:ss}
\end{subfigure}
\\
\begin{subfigure}{0.25\textwidth}
\centering
\includegraphics[height=\textwidth]{figures/double_stance_v3.png}
\caption{Double stance}
\label{fig:double_stance}
\end{subfigure}%
\begin{subfigure}{0.25\textwidth}
\centering
\includegraphics[height=\textwidth]{figures/simplified_v2.png}
\caption{Simplified}
\label{fig:simplfied}
\end{subfigure}
\caption{Different gait states and representation of the generalized coordinates. Whole-body model representations are shown in sub-figures (a), (b), and (c). Sub-figure (d) corresponds to the stance and swing phases of the simplified model.}
\label{fig:state_figures}
\end{figure}
\subsubsection{Simplified dynamics}
Modeling each leg of the lower-limb exoskeleton as a double pendulum~\cite{Hwang2015, Andrade2021Role, Mayag2022, vanDijkW2013Improvingwalking, Tu2020, ZanottoD2013Improvingcuffs} is a simpler and commonly used method in the literature. We use this model for comparison to our approach. In this simplified model, each leg is modeled independently from the other and the backpack is not considered. The hip joint is considered grounded for a swing leg, and the ankle joint is considered fixed to the ground for a stance leg, as shown in Figure~\ref{fig:simplfied}.
The equation of motion can be written
\begin{equation}
\mt{M}_i(\mt{q})\ddot{\mt{q}} + \mt{b}_i(\mt{q},\dot{\mt{q}}) + \mt{g}_i(\mt{q}) = \mt{\tau}_\text{joint} + \mt{\tau}_\text{int},
\;\: i\in \{\text{st}, \text{sw}\},
\label{eq:simpleEoM}
\end{equation}
where $\mt{q} = [\theta_1, \theta_2]$ and $\mt{\tau}_\text{joint}$ are the hip and knee joint positions and torques, respectively. The variables $\mt{M}_i \in \mathbb{R}^{2\times 2}, \mt{b}_i \in \mathbb{R}^2, \mt{g}_i \in \mathbb{R}^2$, are the mass matrix, Coriolis and centrifugal torques, and gravitational torques, respectively, during stance ($i = \text{st}$) and swing ($i = \text{sw}$).
\subsection{Parameter Estimation}
Inertial parameters such as mass, mass moment of inertia, and center of mass (CoM) locations of each link were estimated from the CAD model of the X2 exoskeleton. Some of these parameters are presented in Table~\ref{tab:x2_params}. Note that the largest inertias come from the apparent inertia of the motor rotors due to the high gear reduction ratios.
\begin{table}
\centering
\caption{Estimated masses and inertias (about axes through the center of mass and perpendicular to the saggital plane) of links and motor rotors of the X2 exoskeleton.}
\begin{tabular}{c| c c}
\cline{1-3}
\rule{0pt}{2ex}
Link & $m$ [kg] & $L$ [kgm\textsuperscript{2}] \\ \cline{1-3}
Backpack & 10.3 & 0.201 \\
Upper thigh & 0.7 & 0.002197 \\
Lower thigh & 2.14 & 0.005901 \\
Upper shank & 0.64 & 0.002346 \\
Lower shank & 0.47 & 0.0007941 \\
Foot & 1.25 & 0.004441 \\
Rotor (apparent) & - & $1.246 10^{-4} \times 122.5^2 = 1.87$ \\ \cline{1-3}
\end{tabular}
\label{tab:x2_params}
\end{table}
The high gear ratios also result in significant friction at each joint. Friction at the joints is modeled as viscous friction combined with Coulomb friction as a function of joint speed,
\begin{equation}
\mt{\tau}_\text{friction} = \mt{c_0}\sign{\dot{\mt{\theta}}} + \mt{c_1}\dot{\mt{\theta}}.
\label{eq:friction_model}
\end{equation}
To estimate the frictional parameters, the exoskeleton was suspended by backpack attachment points and the motors were driven with sinusoidal torques at varying amplitudes up to 15~Nm and frequencies between 0 and 3~Hz. All joint states were recorded.
As there was no contact with the ground at this configuration, the equation of motion of the flight state was used to estimate the frictional parameters. Equation~\eqref{eq:FlyingEoM} can be rewritten to include viscous and Coulomb friction constants,
\begin{equation}
\begin{split}
\mt{M}_\text{fly}(\mt{q}_\text{fly})\ddot{\mt{q}}_\text{fly} + \mt{b}_\text{fly}(\mt{q}_\text{fly},\dot{\mt{q}}_\text{fly}) + \mt{g}_\text{fly}(\mt{q}_\text{fly}) = \\ S^T(\mt{\tau}_\text{motor} + \mt{c_0}\sign{\dot\theta} + \mt{c_1}\dot\theta) + \mt{\tau}_\text{int}.
\label{eq:FlyingEoMFriction}
\end{split}
\end{equation}
Recorded backpack and joint angular positions, joint angular velocities, joint angular accelerations, and CAD-based inertial parameters were used to calculate the $\mt{M}_\text{fly}$, $\mt{b}_\text{fly}$, and $\mt{g}_\text{fly}$ at each time instant. Since the exoskeleton was hung from the backpack at a fixed location, $\ddot{x}$ and $\ddot{y}$ were negligible. Also, as there was no user in the exoskeleton, rotational components of $\mt{\tau}_\text{int}$ were zero. The coefficients $\mt{c_0}$ and $\mt{c_1}$ were solved using least-square minimization based on the recorded motor torques and joint states. Estimated friction parameters for each joint and the $R^2$ value of the fit are presented in Table~\ref{tab:friction_params}.
\begin{table}
\centering
\caption{Estimated friction parameters of the X2 exoskeleton and R\textsuperscript{2} of the fit.}
\begin{tabular}{c| c c c}
\cline{1-4}
\rule{0pt}{2ex}
Joint & $c_0$ [Nm] & $c_1$[Nms] & R\textsuperscript{2} \\ \cline{1-4}
Left hip & 5.01 & 4.58 & 0.96 \\
Right hip & 3.26 & 4.67 & 0.94 \\
Left knee & 4.30 & 3.25 & 0.96 \\
Right knee & 4.45 & 5.16 & 0.96 \\ \cline{1-4}
\end{tabular}
\label{tab:friction_params}
\end{table}
\section{Interaction Torque Controller}
\label{sec:int_torque_control}
\subsection{Interaction Torque Estimation}
Estimating the interaction torques between the human and exoskeleton plays a significant role in the transparency and haptic rendering capabilities of the robot. Placing 6 DoF force/torque sensors at every contact point between the human and exoskeleton would theoretically be ideal for measuring the interaction.
However, due to the practical challenges of this approach, we chose to estimate the interaction torques through joint torque measurements. Joint torques were measured using our custom joint-torque sensors mentioned in Section~\ref{ssec:X2}.
Because the X2 robot was designed for individuals with sensorimotor impairments and therefore limited walking ability, we estimated the interaction torque during single and double stance only, excluding the flight state.
\subsubsection{Single stance interaction torque estimation}
We estimate the interaction torque during single stance by subtracting the gravitational and Coriolis forces from the joint torque readings:
\begin{equation}
\mt{\tau}_\text{int} = -S^T\mt{\tau}_\text{joint} + \mt{b}_i(\mt{q},\dot{\mt{q}}) + \mt{g}_i(\mt{q}), \;\: i\in \{\text{ls}, \text{rs}\}.
\label{eq:SS_interaction_estimation}
\end{equation}
The acceleration-dependent inertial component $\mt{M}_i\ddot{\mt{q}}$ is not subtracted to prevent delays in the estimation as the derivative of the joint velocities needs to be heavily filtered to be used in the estimation.
It is worth noting that $\mt{\tau}_\text{int} \in \mathbb{R}^5$, including the interaction torque on the backpack link in addition to the four leg segments.
\subsubsection{Double stance interaction torque estimation}
In the double stance state, with constraints on the ankles hinged to a constant position, the robot has three DoF, while $\mt{\tau}_\text{int} \in \mathbb{R}^5$. Therefore, additional information other than the joint torque measurements is needed to uniquely solve for the interaction torques.
Interaction torque estimation based on left and right stance estimation can be rewritten with the addition of the external ground reaction force at the right and left foot, respectively:
\begin{align}
\mt{\tau}_\text{int} &= -S^T\mt{\tau}_\text{joint} + \mt{b}_{\text{ls}}(\mt{q},\dot{\mt{q}}) + \mt{g}_{\text{ls}}(\mt{q}) - J_{\text{r}}^\top \mt{F_{\text{r}}^\text{exo}}
\label{eq:DS_interaction_estimation_1} \\
\mt{\tau}_\text{int} &= -S^T\mt{\tau}_\text{joint} + \mt{b}_{\text{rs}}(\mt{q},\dot{\mt{q}}) + \mt{g}_{\text{rs}}(\mt{q}) - J_{\text{l}}^\top \mt{F_{\text{l}}^\text{exo}},
\label{eq:DS_interaction_estimation_2}
\end{align}
where $J$ is the ground contact Jacobian and $F^\text{exo}$ is the ground reaction force acting on the exoskeleton. Subscripts l and r correspond to left and right, respectively.
Combining Equations~\ref{eq:DS_interaction_estimation_1} and~\ref{eq:DS_interaction_estimation_2} results in ten equations with rank seven. Nine unknowns in these equations are the five-dimensional interaction torque vector and two dimensional ground reaction forces at left ($\mt{F_{\text{l}}^\text{exo}}$) and right ($\mt{F_{\text{r}}^\text{exo}}$) foot. Since there are seven independent equations and nine unknowns, it is not possible to uniquely solve for the interaction torque vector without additional information.
To have a unique interaction torque solution, force sensors under the treadmill are used to provide additional information about $\mt{F_{\text{l}}^\text{exo}}$ and $\mt{F_{\text{r}}^\text{exo}}$. It is important to distinguish the difference between $\mt{F^\text{exo}}$ and the measured ground reaction forces at the treadmill, $\mt{F^\text{treadmill}}$. The foot of the exoskeleton has contact with both the ground and user's shoe. Therefore, $\mt{F^\text{exo}}$ equals to the vector sum of the force applied by the human to the exoskeleton's foot ($\mt{F^\text{h,foot}}$) and the ground reaction force,
\begin{equation}
\mt{F^\text{exo}}_i = \mt{F^\text{h,foot}}_i + \mt{F^\text{treadmill}}_i,
\;\: i\in \{\text{l}, \text{r}\},
\label{eq:grf}
\end{equation}
where l and r correspond to left and right side, respectively.
The following assumptions are added to solve the interaction torque vector uniquely:
\begin{align}
\frac{F_{\text{l,y}}^\text{exo}}{F_{\text{r,y}}^\text{exo}} &= \frac{F_{\text{l,y}}^\text{treadmill}}{F_{\text{r,y}}^\text{treadmill}}
\label{eq:ds_assumption1} \\
\frac{F_{\text{l,x}}^\text{exo}}{F_{\text{l,y}}^\text{exo}} &= \frac{F_{\text{l,x}}^\text{treadmill}}{F_{\text{l,y}}^\text{treadmill}}, \label{eq:ds_assumption2}
\end{align}
where $F^\text{treadmill}$ correspond to the force measured by the split belt treadmill, and subscripts x and y corresponds to the horizontal and vertical component of the force, respectively.
With the addition of Equations~\ref{eq:ds_assumption1} and~\ref{eq:ds_assumption2} to Equations~\ref{eq:DS_interaction_estimation_1} and~\ref{eq:DS_interaction_estimation_2}, interaction torque between the human and the exoskeleton can be uniquely solved during double stance.
\subsubsection{Simplified interaction torque estimation}
With the simplified double pendulum model, interaction torques at the hip and knee joints can be estimated by subtracting the dynamical effects from the joint torque measurements:
\begin{equation}
\mt{\tau}_\text{int} = \mt{\tau}_\text{joint} + \mt{b}_i(\mt{q},\dot{\mt{q}}) + \mt{g}_i(\mt{q}), \;\: i\in \{\text{st}, \text{sw}\}.
\label{eq:simplified_interaction_estimation}
\end{equation}
It is important to note that with the simplified method, $\mt{\tau}_\text{int} \in \mathbb{R}^{2}$ does not include the interaction torque at the backpack. Moreover, because the backpack link is not incorporated into the dynamic model, the backpack's weight is not subtracted, resulting in inaccurate interaction torque estimation for exoskeletons with heavy backpacks.
\subsection{Control}
\subsubsection{Virtual mass controller}
\begin{figure*}
\centering
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
semithick]
\tikzstyle{block}=[rectangle, draw=black, text=black, minimum size=1cm, align=center]
\tikzstyle{node}=[circle, draw=black, text=black, align=center]
\tikzstyle{empty}=[text=black, align=center]
\node[block] (MV) {$\mt{M}_\text{virt}^{-1}$};
\node[node] (refCircle) [left = 1 cm of MV] {-};
\node[block] (HO) [right = 1.5 cm of MV] {
$\displaystyle \mathop{\mathrm{argmin}}_{\textbf{x}} \lVert f(\textbf{x})\rVert = (\ddot{\mt{q}}, \mt{\tau}_{\text{motor}})$\\ s.t. \\
$\textbf{A} \textbf{x} = \textbf{b} $ \\
$ \textbf{D} \textbf{x} \leq \textbf{f} $
};
\node[empty] (HO_empty) [above = -0.05 cm of HO] {Constrained Optimization};
\node[block] (HR) [right = 2 cm of HO] {
\includegraphics[width=.1\textwidth]{figures/X2_cartoon.png}
};
\node[empty] (HR_empty) [above = -0.05 cm of HR] {Coupled Human-Robot};
\node[empty] (HR_right) [right = 0.5 cm of HR] {};
\node[block] (GS) [below = 0.75 cm of HO] {
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
semithick]
\tikzstyle{every state}=[draw=black, text=black, minimum size=1cm, align=center]
\node[state] (ls) {LS\\ $\alpha = 0$};
\node[state] (ds) [below right = 0.5 cm of ls] {DS\\ $\alpha = [0 \ 1]$};
\node[state] (rs) [above right = 0.5 cm of ds] {RS\\ $\alpha = 1$};
\path (ls)
edge node[sloped] {} (ds)
(rs)
edge [bend left] node[sloped, below] {} (ds)
(ds)
edge [bend left] node[sloped, below] {} (ls)
edge node[sloped] {} (rs);
\end{tikzpicture}
};
\node[empty] (GS_right) [right = 4.3 cm of GS] {};
\node[block] (FE) [below = 0.5 cm of GS] {Interaction Torque Estimator};
\node[empty] (FE_right) [right = 4.63 cm of FE] {};
\node[empty] (FE_left) [left = 3.53 cm of FE] {};
\node[empty] (tau_des) [left = 1 cm of refCircle] {};
\path (MV) edge node[] {$\ddot{\mt{q}}^*$} (HO);
\path (HO) edge node[] {$(\ddot{\mt{q}}, \mt{\tau}_{\text{motor}})$} (HR);
\path (GS) edge node[] {$\alpha$} (HO);
\path (GS) edge node[] {$\alpha$} (FE);
\draw [-] (HR.east) -| node[pos=0.5] {} (GS_right.center);
\draw [->] (GS_right.center) -- node[above, pos=0.5] {$\mt{F}^\text{grf}$} (GS);
\draw [->] (GS.west) -| node[near end] {$\alpha$} (MV.south);
\draw [-] (GS_right.center) -- node[pos=0.5] {} (FE_right.center);
\draw [->] (FE_right.center) -- node[above, pos=0.5] {$[\mt{q},\dot{\mt{q}}, \mt{\tau}_\text{joint}, \mt{F}^\text{grf}]$} (FE);
\draw [->] (FE.west) -| node[pos = 0.9] {$\mt{\tau}_\text{int}$} (refCircle.south);
\draw [->] (refCircle) -- node[pos=0.5] {$\mt{\tau}_\text{int}^{\text{err}}$} (MV);
\draw [->] (tau_des) -- node[pos=0.5] {$\mt{\tau}_\text{int}^{\text{*}}$} (refCircle);
\end{tikzpicture}
\caption{Schematic of the interaction force controller.}
\label{fig:control_diagram}
\end{figure*}
To control the interaction torques between the human and the exoskeleton, we implemented a \emph{virtual mass controller}~\cite{Fumagalli2013, Zimmermann2020} to simulate a desired mass or inertia, and no damping, of each generalized coordinate of the exoskeleton. This can be achieved by setting the desired generalized acceleration to
\begin{equation}
\ddot{\mt{q}}^* = \mt{M}_\text{virt}^{-1}(\mt{\tau}_\text{int} - \mt{\tau}_\text{int}^*),
\label{eq:desired_acc}
\end{equation}
where $\mt{\tau}_\text{int}^*$ is the desired interaction torque, e.g., zero for transparency or nonzero for other desired impedances.
Under the assumptions of perfect control of the generalized accelerations and accurate interaction torque estimation with little delay, this equation shows that the interaction torque error is proportional to the chosen virtual mass matrix $\mt{M}_\text{virt}$ and joint accelerations. Therefore, lowering $\mt{M}_\text{virt}$ results in better interaction torque tracking. Obviously, $\mt{M}_\text{virt}$ cannot be decreased below a certain limit due to the actuation limits, modeling errors, and communication delays. We used a diagonal $\mt{M}_\text{virt}$ and tuned the virtual mass parameter for each generalized coordinate independently, reducing each virtual mass as much as possible before compromising the stability of the control. This process resulted in different virtual mass parameters for single stance and double stance, as shown in Table~\ref{tab:vm_values}. The virtual inertia of the backpack is relatively large to allow better control performance at the leg segments.
\begin{table}
\begin{center}
\caption{Virtual mass values for each link.}\vspace{1ex}
\label{tab:vm_values}
\begin{tabular}{cc|c}
\cline{1-3}
\rule{0pt}{2ex}
Link & Gait State & Virtual Mass [kgm\textsuperscript{2}] \\ \cline{1-3}
Backpack & Single Stance & 2 \\
Backpack & Double Stance & 3.5 \\
Thigh & Single Stance & 0.7 \\
Thigh & Double Stance & 1.2 \\
Shank & Single Stance & 0.5 \\
Shank & Double Stance & 0.87 \\ \cline{1-3}
\end{tabular}
\end{center}
\end{table}
\subsubsection{Constrained optimization}
While the desired acceleration $\ddot{\mt{q}}^*$ in Equation~\eqref{eq:desired_acc} is a five-dimensional vector, the robot has only four actuated joints. Therefore, it is not possible to perfectly track the desired generalized accelerations calculated by the virtual mass controller. Moreover, the maximum torque, power, and velocity of the motors bring additional limitations. To track the desired generalized acceleration as accurately as possible under physical and safety constraints, we use real-time constrained optimization with OSQP~\cite{osqp} to solve for $\textbf{x} = (\ddot{\mt{q}}, \mt{\tau}_{\text{motor}}) \in \mathbb{R}^9$, where $\mt{\tau}_{\text{motor}}$ is a vector of torques sent to the drivers:
\begin{equation}
\begin{split}
\min_\textbf{x} \qquad &\lVert f(\textbf{x})\rVert \\
s.t. \qquad &\textbf{A} \textbf{x} = \textbf{b} \\
& \textbf{D} \textbf{x} \leq \textbf{f}.
\end{split}
\label{eq:const_opt}
\end{equation}
The objective function $\lVert f(\textbf{x}) \rVert$ is the 2-norm of the difference between the actual and desired generalized accelerations,
\begin{equation}
f(\textbf{x}) = [\mathbb{I}_{5\times5},\; 0_{5\times4}]\textbf{x} - \ddot{\mt{q}}^*.
\label{eq:obj_function}
\end{equation}
The equality constraint ensures that optimized variables satisfy the equation of motion of the corresponding gait state under physical limits.
\begin{equation} \label{eq:task_EOM}
\begin{split}
\textbf{A} = \textbf{A}_{\text{EOM}} &= [\mt{M}_i,\: -S^\top], \\
\textbf{b} =\textbf{b}_{\text{EOM}} &= [-\mt{b}_i -\mt{g}_i + \mt{\tau}_{\text{int}} + S^\top(\mt{c_0}\sign{\dot{\mt{\theta}}} + \mt{c_1}\dot{\mt{\theta}})],
\end{split}
\end{equation}
where $i \in \{\text{ls}, \text{rs}, \text{ds}\}$.
Inequality constraints arise from physical and safety constraints on motor torque, power, and velocity.
Motor torque and power constraints are presented in Equations~\eqref{eq:task_torque} and~\eqref{eq:task_power}, respectively:
\begin{equation}
\begin{split}
\textbf{D}_{\mt{\tau}_{\text{max}}^+} = [0_{4 \times 5},\: \mathbb{I}_{4\times4}], \; \textbf{f}_{\mt{\tau}_{\text{max}}^+} &= \mt{\tau}_{\text{max}} \\
\textbf{D}_{\mt{\tau}_{\text{max}}^-} = [0_{4 \times 5},\: -\mathbb{I}_{4\times4}], \; \textbf{f}_{\mt{\tau}_{\text{max}}^-} &= \mt{\tau}_{\text{max}},
\label{eq:task_torque}
\end{split}
\end{equation}
\begin{equation}
\begin{split}
\textbf{D}_{\mt{\mathcal{P}}_{\text{max}}^+} = [0_{4 \times 5},\: \mathbb{I}_{4\times4}], \; \textbf{f}_{\mt{\mathcal{P}}_{\text{max}}^+} &= \frac{\mt{\mathcal{P}}_{\text{max}}}{|\dot{\mt{q}}|} \\
\textbf{D}_{\mt{\mathcal{P}}_{\text{max}}^-} = [0_{4 \times 5},\: -\mathbb{I}_{4\times4}], \; \textbf{f}_{\mt{\mathcal{P}}_{\text{max}}^-} &= \frac{\mt{\mathcal{P}}_{\text{max}}}{|\dot{\mt{q}}|},
\label{eq:task_power}
\end{split}
\end{equation}
where $\mt{\tau}_{\text{max}} = 80~\text{Nm}$ and $\mt{\mathcal{P}}_{\text{max}} = 100~\text{W}$ are the maximum allowable torque and power of the motors, respectively.
The joint velocity constraint is converted to an acceleration constraint such that the velocity at the next time step will not exceed maximum velocity limits,
\begin{equation}
\begin{split}
\textbf{D}_{\ddot{\mt{q}}^+} = [0_{4\times1},\: \mathbb{I}_{4\times4},\: 0_{4\times4}], \; \textbf{f}_{\ddot{\mt{q}}^+} &= \frac{\dot{\mt{q}}_{\text{max}} - \dot{\mt{q}}}{\Delta t} \\ \textbf{D}_{\ddot{\mt{q}}^-} = [0_{4\times1},\: -\mathbb{I}_{4\times4},\: 0_{4\times4}], \; \textbf{f}_{\ddot{\mt{q}}^-} &= \frac{\dot{\mt{q}}_{\text{max}} + \dot{\mt{q}}}{\Delta t},
\label{eq:task_vel}
\end{split}
\end{equation}
where $\dot{\mt{q}}_{\text{max}} = 3.0~\text{rad/s}$ and $\Delta t = 0.003~\text{s}$ is the control loop period. Individual $\textbf{D}$ matrices and $\textbf{f}$ vectors in Equations~\eqref{eq:task_torque}--\eqref{eq:task_vel} are vertically stacked to obtain the overall $\textbf{D}$ matrix and $\textbf{f}$ vector in Equation~\eqref{eq:const_opt}.
The controller is illustrated in Figure~\ref{fig:control_diagram}.
Because we have only a single objective function for this task, a constrained optimization suffices. In the case of multiple objectives with different priorities, a hierarchical optimization framework could be applied~\cite{DarioBellicoso2016, Zimmermann2019}. This allows optimization of lower-priority tasks using freedoms in the design vector that do not affect the objective functions of higher-priority tasks.
\section{Experimental Validation}
Three healthy subjects (one male, two female, 71.6$\pm$12.9~kg, 174$\pm$1.7~cm, 29$\pm$2.6~years) participated in this study to test the proposed interaction torque controller. The link lengths of the exoskeletons were adjusted for each participant so that they were comfortable and their joints were aligned with the exoskeleton's. None of the subjects had used a lower-limb exoskeleton before this study. At the beginning of the experiment, subjects were allowed about two minutes of walking with the exoskeleton on a treadmill for familiarization. We tested the haptic rendering capabilities for zero desired interaction torque under three conditions and nonzero desired interaction torques under two different conditions. In addition to the proposed controller (WECC), the following two conditions were tested:
\paragraph {No-drive} A passive exoskeleton with disassembled drives was used. This allowed us to eliminate the main sources of friction and inertia, which are the apparent rotor inertias Subjects still felt the weight of the exoskeleton, however.
\paragraph {Simplified} Legs are modeled and controlled as independent double pendulums.
Interaction torques are calculated with the simplified model as in Equation~\eqref{eq:simplified_interaction_estimation}. Furthermore, Equation~\eqref{eq:simpleEoM} is used as the forward model to track the desired acceleration commands sent by the virtual mass controller (Equation~\eqref{eq:desired_acc}). The simplified interaction torque estimation is used in the control loop; however, the presented interaction torque results are calculated using the whole-body model to compare the results between conditions.
The institutional review board (IRB) of Northwestern University approved this study (STU00212684), and all procedures were in accordance with the Declaration of Helsinki.
\subsection{Evaluation of Transparency}
Haptic transparency was tested for our proposed WECC method, double-pendulum based simplified controller, and passive no-drive condition. For the WECC and simplified controllers with actuation, zero desired interaction torque was commanded for each generalized coordinate. Each condition was tested for three trials of one-minute walking on a treadmill with a speed of 1.1~km/h.
A relatively slow speed was selected due to usual walking training speeds in physical rehabilitation settings and the joint velocity limitation of 3.2~rad/s of the ExoMotus-X2 exoskeleton.
Trials of the WECC and simplified controllers were performed in a randomized order for each subject. All trials of the passive no-drive condition were performed consecutively for practical reasons, as this condition requires a different exoskeleton with disassembled drives.
A metronome was played at 40~bpm, and subjects were asked to synchronize their heel strikes with the beats of the metronome to have similar step lengths between subjects and trials.
Human-exoskeleton interaction torques and muscle activity were used to assess the transparency performance.
\subsection{Evaluation of Haptic Rendering}
We tested the interaction torque rendering capabilities of the proposed WECC controller and the simplified controller when the desired interaction torques are generated by virtual springs and dampers at the joints,
\begin{equation}
\mt{\tau}_\text{int}^* = \mt{K}(\mt{q} - \mt{q^*}) + \mt{C}\dot{\mt{q}},
\label{eq:tau_int_des}
\end{equation}
where $\mt{q^*}$ is the neutral position vector of the virtual springs and $\mt{K}$ and $\mt{C}$ are diagonal stiffness and damping matrices, respectively. A constant $\mt{q^*}_i$ was used at each joint $i$, and the desired interaction torque at backpack was set to zero. Since the motion of a leg during stance is slower and has a smaller range, larger stiffness and damping constants were used for a leg's stance phase than for its swing phase. The diagonal values of the stiffness ($k_i$) and damping ($c_i$) matrices, as well as $\mt{q^*}$, are presented in Table~\ref{tab:rendering_params}. To avoid discontinuities in the desired interaction torque during stance to swing transitions, the desired interaction torque was low-pass filtered with a cutoff frequency of 5~Hz.
\begin{table}
\begin{center}
\caption{Virtual stiffness and damping values used for haptic rendering evaluation.}\vspace{1ex}
\label{tab:rendering_params}
\begin{tabular}{cc|ccc}
\cline{1-5}
\rule{0pt}{2ex}
Joint & Leg Phase & $k_i$ [Nm/rad] & $c_i$ [Nms/rad] & ${q_i}^*$ [degrees] \\
\cline{1-5}
Hip & Stance & 50 & 10 & 25 \\
Hip & Swing & 30 & 6 & 25 \\
Knee & Stance & 30 & 6 & -45 \\
Knee & Swing & 25 & 5 & -45 \\ \cline{1-5}
\end{tabular}
\end{center}
\end{table}
\subsection{Data Recording and Analysis}
Joint positions, velocities, and interaction torques were recorded during all trials. The exoskeleton without drives is instrumented with IMUs (Tech-IMU V4, Technaid, Spain) at each link to measure joint kinematics, which is used in interaction torque calculation. All exoskeleton data were collected at 333~Hz.
Nine bipolar electromyography (EMG) electrodes (MA400 EMG Systems, Motion Lab Systems, USA) were placed on the belly of the following muscles for the evaluation of transparency experiments: rectus femoris (RF), vastus lateralis (VL), vastus medialis (VM), biceps femoris (BF), semitendinosus (ST), medial gastrocnemius (MG), lateral gastrocnemius (LG), and soleus (SOL). The electrodes were placed only on the left leg. EMG data were recorded at 1500~Hz. The raw EMG signals were first bandpass filtered between 20 and 500~Hz with a sixth-order Butterworth filter. Then, a notch filter between 59 and 61~Hz was applied to reduce noise due to power line interference. Finally, the signals were low-pass filtered at 10~Hz after full-wave rectification. Processed EMG signals were normalized with respect to the mean of the no-drive condition for each subject independently. For one subject, RF recordings were not successfully collected due to sensor failure.
Exoskeleton-based measurements and processed EMG readings were windowed between the heel strikes of the corresponding leg. Windowed data from the same joint on both legs and three subjects were lumped together for each condition. The mean absolute value of the whole cycle and only stance or swing phases for each gait cycle were used as sample points and visualized in the corresponding box plots in the Results section. Three-way ANOVA analysis with the condition, subjects, and trial number of a subject as random variables was applied to test statistical significance between the means of each condition for each measure (i.e., interaction torque, muscle activity). A p-value of $p = 0.05$ was used to accept or reject null hypotheses.
\section{Results}
\subsection{Transparency}
\begin{figure*}
\centering
\includegraphics[height=0.65\textwidth]{figures/transparency_torques_v4.pdf}
\caption{Interaction torques between the human and robot during transparency trials. The figures on the top row show the interaction torques vs. normalized gait duration. The data includes every step of both legs of all three subjects and the shaded area represents one standard deviation. On the bottom row, the box and whisker plots of the mean absolute interaction torques during the stance phase, swing phase, and the whole gait cycle are presented. Mean absolute values of the corresponding phase at each step of both legs of all three subjects are used as a data point in box and whisker plots (N$\approx320$).}
\label{fig:trans_torque}
\end{figure*}
Interaction torques during the transparency trials, normalized by the body mass of each subject (units of Nm/kg), are presented in Figure~\ref{fig:trans_torque} and Table~\ref{tab:trans_torque_result}.
Below we describe the interaction torques during a leg's swing phase, its stance phase (both single stance and double stance unless otherwise noted), and its entire cycle.
For both hip and knee joints, interaction torques with the proposed WECC controller were mostly bounded to the range $\pm$0.13~Nm/kg, with little difference between stance and swing phases. In contrast, the simplified controller resulted in hip and knee peak torques of 0.5~Nm/kg and 0.4~Nm/kg, respectively, at the end of the single stance state. Similarly, the no-drive condition resulted in peak torques of 0.4~Nm/kg and 0.5~Nm/kg at the hip and knee joints, respectively.
The performance of the proposed WECC controller was consistent throughout the whole gait cycle with a mean absolute interaction torque around $0.07~\pm~0.02$~Nm/kg both at the hip and knee joints during both stance and swing phases. The simplified controller resulted in a similar mean absolute interaction torque during the swing phase ($\Delta \leq$ 0.01~Nm/kg) but significantly higher mean absolute interaction torque at the hip and knee joints, respectively, during the stance phase ($\Delta \geq$ 0.13~Nm/kg, $p < 0.01$). During the stance phase, higher interaction torques were observed for the no-drive condition than for WECC at both the hip ($\Delta \geq$ 0.12~Nm, $p < 0.01$) and knee ($\Delta \geq$ 0.24~Nm/kg, $p < 0.01$) joints. During the swing phase, the no-drive condition resulted in significantly higher interaction torques at the hip joint ($\Delta \geq$ 0.10~Nm/kg, $p < 0.01$) and similar interaction torques at the knee joint ($\Delta \approx$ 0.01~Nm/kg) compared to the proposed WECC method. Average transparency performance during the whole cycle was best for the WECC controller, with mean absolute interaction torques of 0.076$\pm$0.020~Nm/kg and 0.071$\pm$0.021~Nm/kg at the hip and knee joints, respectively. The simplified controller achieved better mean absolute interaction torque than the no-drive condition at the knee joint ($\Delta \approx$ 0.07~Nm/kg) averaged over the whole gait cycle. At the hip joint, both performances were similar with a mean interaction torque difference around 0.01~Nm/kg.
\begin{table}
\begin{center}
\caption{Mean and standard deviation of the interaction torques between the human and robot at hip and knee joints during transparency experiments. All values are expressed in Nm/kg.}\vspace{1ex}
\label{tab:trans_torque_result}
\begin{tabular}{cc|ccc}
\hline
Joint & Leg Phase & No-drive & Simplified & WECC (ours) \\
\hline
Hip & Stance & 0.13 $\pm$ 0.033 & 0.16 $\pm$ 0.036 & 0.077 $\pm$ 0.021 \\
Hip & Swing & 0.11 $\pm$ 0.023 & 0.062 $\pm$ 0.019 & 0.072$\pm$ 0.020 \\
Hip & \makecell{Whole\\cycle} & 0.13 $\pm$ 0.025 & 0.14 $\pm$ 0.031& 0.076 $\pm$ 0.020 \\
Knee & Stance & 0.25 $\pm$ 0.034 & 0.14 $\pm$ 0.033 & 0.072 $\pm$ 0.020 \\
Knee & Swing & 0.052 $\pm$ 0.015 & 0.074 $\pm$ 0.028 & 0.068 $\pm$ 0.026 \\
Knee &\makecell{Whole\\cycle} & 0.19 $\pm$ 0.028 & 0.12 $\pm$ 0.029 & 0.071 $\pm$ 0.021 \\ \cline{1-5}
\end{tabular}
\end{center}
\end{table}
\begin{table}
\begin{center}
\caption{Mean and standard deviation of muscle activities during transparency experiments, normalized with respect to the mean of the no-drive condition.}\vspace{1ex}
\label{tab:trans_emg_result}
\begin{tabular}{c|cc}
\hline
Muscle & Simplified & WECC (ours) \\
\hline
RF & 0.83 $\pm$ 0.18 & 0.77 $\pm$ 0.18 \\
VL & 0.64 $\pm$ 0.21 & 0.59 $\pm$ 0.15 \\
VM & 0.59 $\pm$ 0.16 & 0.56 $\pm$ 0.10 \\
BF & 1.32 $\pm$ 0.46 & 1.94 $\pm$ 0.76 \\
ST & 1.57 $\pm$ 0.58 & 2.51 $\pm$ 0.7 \\
TA & 0.97 $\pm$ 0.24 & 1.06 $\pm$ 0.31 \\
LG & 1.56 $\pm$ 0.35 & 1.91 $\pm$ 0.39 \\
MG & 1.58 $\pm$ 0.39 & 1.95 $\pm$ 0.49 \\
SOL & 0.76 $\pm$ 0.19 & 0.72 $\pm$ 0.12 \\
\cline{1-3}
\end{tabular}
\end{center}
\end{table}
\begin{figure*}
\centering
\includegraphics[height=0.45\textwidth]{figures/transparency_emg_v2.pdf}
\caption{Muscle activity during transparency experiments. Data are normalized with respect to the mean of the no-drive condition. Mean absolute values of the filtered EMG data averaged over the whole cycle at each step of all subjects are used as a data point in bar plots (N$\approx160$).}
\label{fig:trans_emg}
\end{figure*}
Figure 6 and Table \ref{tab:trans_emg_result} show the muscle activity of the various muscles during the transparency trials. It is seen that muscles responsible for hip flexion (RF) and knee extension (RF, VL, VM) had the lowest activation with our WECC controller and highest with the passive no-drive condition. On the other hand, our controller resulted in the most activity, and no-drive condition resulted in the least activity, for the muscles responsible for hip extension and knee flexion (BF, ST). Furthermore, the SOL muscle, responsible for ankle plantarflexion, was used the least with our WECC controller and the most under the no-drive condition. In contrast, LG and MG muscles, responsible for knee flexion and ankle plantarflexion, had the highest activation with our WECC controller and the lowest under the no-drive condition.
\begin{table}
\begin{center}
\caption{Mean and standard deviation of the interaction torque error between the human and robot at hip and knee joints during haptic rendering experiments. All values are expressed in Nm/kg.}\vspace{1ex}
\label{tab:rendering_torque_result}
\begin{tabular}{cc|cc}
\hline
Joint & Leg Phase & Simplified & WECC (ours) \\
\hline
Hip & Stance & 0.120 $\pm$ 0.032 & 0.048 $\pm$ 0.014 \\
Hip & Swing & 0.038 $\pm$ 0.092 & 0.039 $\pm$ 0.010 \\
Hip & Whole cycle & 0.096 $\pm$ 0.026 & 0.046 $\pm$ 0.012 \\
Knee & Stance & 0.210 $\pm$ 0.039 & 0.051 $\pm$ 0.014 \\
Knee & Swing & 0.041 $\pm$ 0.013 & 0.049 $\pm$ 0.014 \\
Knee & Whole cycle & 0.170 $\pm$ 0.032 & 0.050 $\pm$ 0.013 \\ \cline{1-4}
\end{tabular}
\end{center}
\end{table}
\subsection{Haptic Rendering}
Properties of the rendered virtual spring-damper elements shown in Table~\ref{tab:rendering_params} resulted in the desired interaction torques presented in Figure~\ref{fig:render_desired_torques}. The figure includes data from the joints of both legs and three subjects. Desired interaction torques vary in the range $\pm$15~Nm during the gait cycle for all subjects.
\begin{figure}
\centering
\includegraphics[height=0.25\textwidth]{figures/rendering_desired_torque_v3.pdf}
\caption{Desired interaction torque due to the rendered spring damper elements.}
\label{fig:render_desired_torques}
\end{figure}
\begin{figure*}
\centering
\includegraphics[height=0.65\textwidth]{figures/rendering_torques_v5.pdf}
\caption{Interaction torque error during haptic rendering trials. The figures on the top row show the interaction torque error vs. normalized gait duration. The data includes every step of both legs of all three subjects and the shaded area represents one standard deviation. On the bottom row, the box and whisker plots of the mean absolute interaction torque error during the stance phase, swing phase, and the whole gait cycle are presented. Mean absolute values of the corresponding phase at each step of both legs of all three subjects are used as a data point in box and whisker plots (N$\approx 370$).}
\label{fig:render_torques}
\end{figure*}
The rendering performance of our proposed WECC controller and the simplified controller are shown in Figure~\ref{fig:render_torques} and Table~\ref{tab:rendering_torque_result}.
Similar to the performance of transparency trials, our controller's interaction torque tracking error was mostly bounded between $\pm$0.1~Nm/kg during the whole gait cycle. On the other hand, the simplified controller resulted in peak normalized interaction torque errors of 0.3~Nm/kg and 0.45~Nm/kg at the hip and knee joints, respectively, near the end of the single stance state.
Our WECC controller resulted in normalized mean absolute interaction torque error of 0.049$\pm$0.014~Nm/kg and 0.039$\pm$0.010~Nm/kg at the hip joint during the stance and swing phases, respectively. The simplified controller resulted in a similar mean absolute error during the swing phase both at the hip and knee joints ($\Delta < 0.01$~Nm/kg). On the other hand, the average absolute interaction torque error was significantly larger during the stance phase both at the hip ($\Delta > 0.1$~Nm/kg, $p<0.05$) and knee ($\Delta > 0.2$~Nm/kg, $p<0.05$) joints. Averaged over the whole cycle, our WECC controller resulted in an error of 0.050$\pm$0.012~Nm/kg for both hip and knee joints. The errors of the simplified controller were significantly larger both at the hip ($\Delta > 0.05$~Nm/kg, $p<0.05$) and knee joints ($\Delta > 0.1$~Nm/kg, $p<0.05$).
\section{Discussion}
\subsection{Interaction Torque Tracking}
The simplified controller and the proposed WECC controller performed similarly during the swing phase for both joints in the transparency and haptic rendering trials, as shown in Figures~\ref{fig:trans_torque} and~\ref{fig:render_torques}. Since the swing leg is not affected by the weight of the backpack and the other leg, the two-link simplified model is sufficient and results in accurate interaction torque estimation and motor torque calculation for the swing leg. On the other hand, the simplified controller failed to render the desired interaction torques for the stance leg. This is because the model does not consider whole-body dynamics, resulting in incorrect interaction torque estimation for the stance leg. For the simplified controller, subjects feel additional torques on their joints due to the uncompensated weight of the robot.
As the proposed WECC controller uses whole-body dynamics and considers physical limitations, the interaction torque tracking performance was consistent throughout the entire gait cycle.
The most transparent performance at the knee joint was obtained during the swing phase of the no-drive condition. This is because the weight of the shank is insignificant, and there is low friction and no apparent rotor inertia. As the weight of the whole leg becomes more significant, the no-drive condition results in more interaction torque at the hip joint compared to active controllers, where the weight of the leg is compensated. The highest amount of torque was observed for the stance leg under the no-drive condition as the stance leg of the subject needs to overcome the torques appearing due to the weight of the robot's stance leg, swing leg, and backpack.
\subsection{Muscle Activity}
The muscles responsible for hip flexion (RF) and knee extension (RF, VL, VM) were activated the least with the proposed WECC controller and the most with the passive no-drive condition during the transparency trials. This is mainly due to the accurate compensation of the exoskeleton dynamics for the WECC controller.
The opposite trend was observed for the muscles responsible for hip extension and knee flexion (BF, ST). These muscles were activated more with the WECC controller and less with the no-drive condition.
Figure~\ref{fig:power} shows the interaction power for all conditions with respect to the normalized gait duration. The simplified controller and no-drive exoskeleton actually assist the hip extension motion during the single stance state. At first glance, it might be surprising that the passive exoskeleton provides assistance in some instances; however, this is due to the weight of the exoskeleton, which results in torques driving hip extension and knee flexion. These results are also in line with the findings of MacLean et al.~\cite{MacLean2021}, who observed higher BF activity with increasing weight support while walking at a similar speed as in our setup.
\begin{figure}
\centering
\includegraphics[height=0.35\textwidth]{figures/power_vs_gait_v2.pdf}
\caption{Hip interaction power during transparency experiments. Positive and negative values indicate resistance and assistance to the human, respectively.}
\label{fig:power}
\end{figure}
The gastrocnemius muscles (LG, MG), which are responsible for ankle plantarflexion and knee flexion, were activated most with the WECC controller and least with the no-drive condition. On the other hand, an opposite trend was observed for the SOL muscle, which is responsible for ankle plantarflexion. High interaction torques towards the knee-flexion direction (positive direction in Figure ~\ref{fig:trans_torque}) for the simplified and no-drive conditions leads to less gastrocnemius activity in these conditions. This explains the different trend between gastrocnemius and SOL muscles.
\section{Conclusion}
We have presented the whole-exoskeleton closed-loop compensation (WECC) controller to measure and control the interaction torques between a user and a floating base hip-knee exoskeleton that contacts the ground. WECC controller calculates the interaction torques using joint torque measurements and gait state information. The desired joint interaction torques are achieved by using a virtual mass controller together with a constrained optimization scheme that considers the whole-exoskeleton dynamics, physical limits, and safety constraints. The performance of WECC controller was compared in terms of transparency and spring-damper haptic rendering with a commonly used simplified double-pendulum model where the legs are modeled independent of one another. WECC control resulted in consistent interaction torque tracking during the whole gait cycle for both zero and nonzero desired interaction torques, while the simplified controller failed to track desired interaction torques during the stance phase.
Future improvements to WECC control could include explicit modeling of joint limits in the dynamic model especially since the knee joint gets close to the physical limit during the gait cycle. This will improve the accuracy of the forward model and therefore the tracking of the optimized accelerations. Moreover, an inner acceleration loop to compensate for the modeling inaccuracies, using additional IMUs or reinforcement-based strategies~\cite{WenOnline2020} for online optimization of system parameters, may be an option to improve the current results. Additional IMUs or pressure insoles can also be used to substitute the sensorized treadmill to estimate the continuous gate state.
WECC controller can be used to adjust the interaction torques to assist a user in overground walking, to resist for training in a clinical setting, or to provide haptic transparency. WECC control is especially beneficial for heavy lower-limb exoskeletons where the whole-body dynamics need to be compensated. In future studies, this infrastructure will be used to investigate the effects of dyadic haptic interaction on performance and learning for complex multi-DOF lower-limb motions~\cite{Kucuktabak2021, Kim2020, Kim2022}.
\section*{Appendix}
\subsection{Simplified Controller}
For the simplified controller condition (SIM) the legs are modeled as 2-link independent chains from each other. This model is used to estimate interaction torques as in Equation~\ref{eq:simplified_interaction_estimation}. Furthermore, Equation~\ref{eq:simpleEoM} is used as the forward model to track the desired acceleration commands sent by the virtual mass controller. The simplified interaction torque estimation is used in the control loop; however, the presented interaction torque results are calculated using the whole-body model to compare the results between conditions. The overall control structure and the representation of the generalized coordinates are presented in Figure~\ref{fig:simp_control_diagram} and~\ref{fig:simplified}, respectively. The control structure runs independently for each leg.
\begin{figure*}
\centering
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
semithick]
\tikzstyle{block}=[rectangle, draw=black, text=black, minimum size=1cm, align=center]
\tikzstyle{node}=[circle, draw=black, text=black, align=center]
\tikzstyle{empty}=[text=black, align=center]
\node[block] (MV) {$\mt{M}_\text{virt}^{-1}$};
\node[node] (refCircle) [left = 1 cm of MV] {-};
\node[block] (HO) [right = 1.5 cm of MV] {
\includegraphics[width=.2\textwidth]{figures/simplified.pdf}
};
\node[empty] (HO_empty) [above = -0.05 cm of HO] {2-link feed-forward model (Eq. \ref{eq:simpleEoM})};
\node[block] (HR) [right = 2 cm of HO] {
\includegraphics[width=.1\textwidth]{figures/X2_cartoon.png}
};
\node[empty] (HR_empty) [above = -0.05 cm of HR] {Coupled Human-Robot};
\node[empty] (HR_right) [right = 0.5 cm of HR] {};
\node[block] (GS) [below = 0.75 cm of HO] {
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
semithick]
\tikzstyle{every state}=[draw=black, text=black, minimum size=1cm, align=center]
\node[state] (ls) {LS\\ $\alpha = 0$};
\node[state] (ds) [below right = 0.5 cm of ls] {DS\\ $\alpha = [0 \ 1]$};
\node[state] (rs) [above right = 0.5 cm of ds] {RS\\ $\alpha = 1$};
\path (ls)
edge node[sloped] {} (ds)
(rs)
edge [bend left] node[sloped, below] {} (ds)
(ds)
edge [bend left] node[sloped, below] {} (ls)
edge node[sloped] {} (rs);
\end{tikzpicture}
};
\node[empty] (GS_right) [right = 4.3 cm of GS] {};
\node[block] (FE) [below = 0.5 cm of GS] {Simplified Interaction Torque Estimator (Eq. \ref{eq:simplified_interaction_estimation})};
\node[block] (FE_wb) [below = 0.9 cm of FE] {Whole-Body Interaction Torque Estimator};
\node[empty] (FE_wb_left) [left = 1 cm of FE_wb] {};
\node[empty] (FE_wb_top_left) [above = 0.5 cm of FE_wb_left] {};
\node[empty] (FE_right) [right = 3.18 cm of FE] {};
\node[empty] (FE_left) [left = 3.53 cm of FE] {};
\node[empty] (FE_wb_right) [right = 3.65 cm of FE_wb] {};
\node[empty] (tau_des) [left = 1 cm of refCircle] {};
\node[block] (plot) [left = 1.7 cm of FE_wb] {
\includegraphics[width=0.05\textwidth]{figures/plot_representation.pdf}
};
\node[empty] (plot_empty) [above = -0.05 cm of plot] {Visualization};
\path (MV) edge node[] {$\ddot{\mt{q}}^*$} (HO);
\path (HO) edge node[] {$(\ddot{\mt{q}}, \mt{\tau}_{\text{motor}})$} (HR);
\path (GS) edge node[] {$\alpha$} (HO);
\path (GS) edge node[] {$\alpha$} (FE);
\draw [-] (HR.east) -| node[pos=0.5] {} (GS_right.center);
\draw [->] (GS_right.center) -- node[above, pos=0.5] {$\mt{F}^\text{grf}$} (GS);
\draw [->] (GS.west) -| node[near end] {$\alpha$} (MV.south);
\draw [-] (GS_right.center) -- node[pos=0.5] {} (FE_right.center);
\draw [->] (FE_right.center) -- node[above, pos=0.5] {$[\mt{q},\dot{\mt{q}}, \mt{\tau}_\text{joint}]$} (FE);
\draw [-] (FE_right.center) -- node[above, pos=0.5] {} (FE_wb_right.center);
\draw [->] (FE_wb_right.center) -- node[above, pos=0.5] {$[\mt{q},\dot{\mt{q}}, \mt{\tau}_\text{joint}, \mt{F}^\text{grf}]$} (FE_wb.east);
\draw [->, name path=tau_int] (FE.west) -| node[pos = 0.9] {$\mt{\tau}_\text{int}$} (refCircle.south);
\draw [->] (refCircle) -- node[pos=0.5] {$\mt{\tau}_\text{int}^{\text{err}}$} (MV);
\draw [->] (tau_des) -- node[pos=0.5] {$\mt{\tau}_\text{int}^{\text{*}}$} (refCircle);
\draw [->] (FE_wb.west) -> node[pos=0.5] {} (plot.east);
\path [name path=GStoFE_wb_top_left] (GS.200) -| (FE_wb_top_left);
\path [name intersections={of = tau_int and GStoFE_wb_top_left}];
\coordinate (S) at (intersection-1);
\path[name path=circle] (S) circle(2mm);
\path [name intersections={of = circle and GStoFE_wb_top_left}];
\coordinate (I1) at (intersection-1);
\coordinate (I2) at (intersection-2);
\node[empty] (I1_node) [below = 0.5 mm of I1] {};
\draw [-] (GS.200) -| node[pos=0.5](GStoFE_wb_top_left) {} (I1_node);
\draw [-] (I2) -| node[pos=0.5] {} (FE_wb_top_left);
\draw[-] (I1.north) arc (90:278:2mm);
\draw [->] (FE_wb_top_left.north) -| node[pos = 0.5] {$\alpha$} (FE_wb.north);
\end{tikzpicture}
\caption{Schematic of the interaction force controller used in the SIMP condition.}
\label{fig:simp_control_diagram}
\end{figure*}
\begin{figure}
\centering
\begin{subfigure}{0.24\textwidth}
\centering
\includegraphics[height=\textwidth]{figures/simplified_stance.pdf}
\caption{Stance}
\label{fig:simplified_stance}
\end{subfigure}
\begin{subfigure}{0.24\textwidth}
\centering
\includegraphics[height=\textwidth]{figures/simplified_swing.pdf}
\caption{Swing}
\label{fig:simplified_swing}
\end{subfigure}
\caption{Generalized coordinates used in the simplified model for stance and swing phases.}
\label{fig:simplified}
\end{figure}
\section*{Acknowledgment}
We would like to thank Tim Haswell for his technical support on the hardware improvements of the ExoMotus-X2 exoskeleton.
| {'timestamp': '2023-01-18T02:16:39', 'yymm': '2301', 'arxiv_id': '2301.06244', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06244'} | arxiv |
\section{Appendix}
\subsection{Details of Backdoor Attacks and Datasets/Models} \label{sec:append_setup}
BadNets~\cite{badnet} uses a small patch at the corner as an universal trigger.
TrojNN~\cite{trojnn} uses a watermark.
Dynamic~\cite{dynamic} places different patches based on different input images to inject input-specific backdoor.
Reflection~\cite{reflection} leverages an universal reflection image as the trigger.
Blend~\cite{blend} performs a static random perturbation on the input image to inject a backdoor.
SIG~\cite{sig} produces some strip-like effects on input images.
Invisible~\cite{invisible} leverages an encoder-decoder structure to perform a complex input transformation.
WaNet~\cite{wanet} uses complex wrapping functions.
Gotham~\cite{ABS} uses the Gotham instagram filter to transform input images.
DFST~\cite{dfst} leverages a GAN-based generator to inject some visual effects to input images.
\smallskip \noindent
\textbf{ImageNet}~\cite{ILSVRC15} is a popular, large scale object classification dataset with 1,281,167 images of 1,000 classes. The task is to predict the correct class label for an image.
We resize the images to $224\times224$ for evaluation.
Two different networks are utilized for ImageNet: VGG-16~\cite{vgg16} and ResNet-50~\cite{he2016deep}.
\smallskip \noindent
\textbf{CelebA}~\cite{celeba} is a face attributes dataset that contains 10,177 identities with 202,599 face images, each image with 40 attribute annotations.
We resize the images to $128\times128$ for evaluation.
Three networks are used for this dataset: VGG-13~\cite{vgg16}, ResNet-18~\cite{he2016deep} and ResNet-34~\cite{he2016deep}.
\smallskip \noindent
\textbf{CIFAR-10}~\cite{cifar10} is an object recognition dataset with 10 classes. It consists of 60,000 images and is divided into a training set (48,000 images), a validation set (2,000 images), and a test set (10,000 images).
CIFAR-10 images are all $32\times32$ and we don't need to resize them.
We leverage four networks for this dataset: VGG-11~\cite{vgg16}, VGG-13~\cite{vgg16}, ResNet-18~\cite{he2016deep} and ResNet-34~\cite{he2016deep}.
\smallskip \noindent
\textbf{GTSRB}~\cite{gtsrb} is a German traffic sign recognition dataset with 51,840 images of road signs in 43 classes. The set contains images of more than 1700 traffic sign instances. We split the dataset into a training set, validation set, and a test set.
All the images are resized to $32\times32$ before evaluation.
We leverage the same four networks for GTSRB as CIFAR-10.
\smallskip \noindent
\textbf{TrojAI}~\cite{trojai} rounds 2 and 3 consist of 1104 and 1008 pre-trained image classification models, respectively. The models were trained on synthetic images, of size $224\times224$, containing artificial traffic signs and realistic street view background from KITTI dataset~\cite{kitti}, Cityscapes dataset~\cite{cityscapes} and Swedish Roads dataset~\cite{swedish}.
Random transformation, e.g., shifting, rotating, lighting, blurring, weather effects, are applied for data augmentation.
This raises the difficulty in the decomposition process of {{\sc Beagle}{}}{} since the collected trojaned images or validation images can be diverse.
Altogether 22 network are leveraged for training the models including several complex structures with a large number of parameters, e.g., DenseNet121~\cite{densenet}, InceptionV3~\cite{inception}, and MobileNetV2~\cite{mobilenet}.
Half of the models have been poisoned with some backdoor which causes model misclassification. These backdoors include polygon patches and filters.
Some are universal (causing any images with trigger to be misclassified to the target label) and the others are label-specific (only causing images of a victim class to be misclassified).
Compared to round 2, round 3 models leverage adversarial training to suppress natural trojans.
\subsection{Details of Backdoor Scanners}
\label{sec:scanner_appendix}
\noindent \textbf{Tabor}~\cite{Tabor} formulates trojan detection as a non-convex optimization problem, guided by explainable AI and other heuristics to increase detection accuracy. Similar to NC, it only supports universal patch backdoors.
\noindent \textbf{K-Arm}~\cite{karm} leverages K-Arm bandit originally proposed in Reinforcement Learning to iteratively and stochastically select the most promising labels for trigger inversion.
Its stochastic selection ensures that even if the true target label is not selected for the current round, it still has a good chance to be selected later. It supports both universal and label-specific patch backdoors.
\noindent \textbf{SRI Trinity}~\cite{sri}.
This is a technique from TrojAI that
can scan both patch and filter backdoors. It has two components, trigger inversion and backdoor classification that classifies a given model to clean or trojaned based on inversion results. We only use its trigger inversion component as the other component is orthogonal.
\subsection{Function Selection During Attack Decomposition} \label{sec:select_func}
\input{tables/select_func.tex}
Given a model for forensics, since {{\sc Beagle}{}}{} doesn't know which function to use during decomposition, it first decomposes the attack samples using both functions (patching and transforming) for a few steps and then choose the one with better performance, as discussed in Section~\ref{sec:decomposition}.
We apply two functions and two distributions for patching and transforming parameters, altogether four types to perform attack decomposition on trojaned instances of BadNets, Reflection, Instagram filter, and WaNet.
The results are shown in Table~\ref{tab:select_func}, where the first column denotes the attack and the following columns denote the ASR of decomposed trigger on clean validation images by different functions.
Observe that for each attack, one of the functions stands out with an obviously higher ASR compared with others. For instance, binomial patching achieves 99\% ASR, outperforming uniform patching and transforming by at least 12\%.
This is reasonable and expected because {{\sc Beagle}{}}{}'s functions are summarized based on existing backdoor injection functions, and different functions have little overlapping.
For example, a complex transformation function is designed to approximate the localized pixel warping of WaNet, which is hard to realize leveraging patch functions or simple transformation. Therefore, only the complex transformation function achieves a high ASR of decomposed trigger.
\subsection{Generalization to State-of-the-art Attacks} \label{sec:new_attack}
\input{tables/new_attack}
There are some state-of-the-art backdoor attacks that introduce new trigger types, e.g., semantic and hidden backdoors.
Semantic backdoors~\cite{composite} leverage semantic features as secret triggers.
For example, the composite backdoor attack~\cite{composite} uses the co-presence of natural features as the trigger. For example, the presence of an airplane in a truck image causes the truck to be misclassified as a bird.
Hidden backdoors~\cite{lira, doan2021backdoor, li2019invisible, li2020invisible} inject invisible patterns into input images as backdoor trigger by constrained optimization or using a network.
For example, LIRA~\cite{lira} trains a trigger injection network and the trojaned classifier simultaneously. In addition, the trigger perturbation is constrained to a small range to ensure invisibility.
We conduct experiments following the setup in Section~\ref{sec:scan} and evaluate {{\sc Beagle}{}}{}'s effectiveness against the composite attack and LIRA.
We train 20 trojaned models for each attack and use 20 additional clean models (half VGG-11 and half ResNet18) on CIFAR-10 for the experiments.
We assume {{\sc Beagle}{}}{} has access to 3 additional trojaned models for attack decomposition and utilize ABS as the base scanner during synthesis.
Table~\ref{tab:new_attack_decomp} shows the results of attack decomposition.
Observe that for both attacks, the decomposed clean images resemble the source images and the decomposed trigger is similar to the injected one, with low $L^1$ error and high PSNR and SSIM scores.
Besides, the decomposed clean images are correctly classified as the ground-truth label, with 100\% accuracy, and the decomposed trigger achieves high ASR on clean validation images (higher than 90\%).
These results are consistent with the existing attacks shown in Table~\ref{tab:decomposition}.
Moreover, Table~\ref{tab:new_attack_scan} shows the scanning results of the vanilla base scanner and {{\sc Beagle}{}}{}'s synthesized scanner.
Observe that {{\sc Beagle}{}}{}'s synthesized scanner outperforms the original version by 25\% on the composite attack and by 38\% on LIRA.
This delineates that {{\sc Beagle}{}}{} is effective against state-of-the-art backdoor attacks.
Specifically, the composite backdoor falls into the patching category, which is defined as $x \oplus t = x \cdot (1 - m) + t \cdot m$, where $x$ is the source image, $t$ is the trigger pattern, and $m$ is the region that the attacker stamps the trigger.
Although it leverages semantic information as the trigger, these triggers are directly stamped on victim images.
For example, assume the attacker stamps a piece of green clothing on a source image to attack the frog class, {{\sc Beagle}{}}{} can recognize the region $m$ where the attacker stamps the garment and $t$ the garment itself.
In addition, LIRA and some other hidden backdoors~\cite{doan2021backdoor, li2019invisible, li2020invisible} are similar to Invisible and WaNet discussed in Section~\ref{sec:decomposition} which inject hidden/invisible perturbation into images and {{\sc Beagle}{}}{} is effective in approximating their trigger injection algorithm using a transformation function. Hence {{\sc Beagle}{}}{} decomposes triggers from trojaned samples and detects backdoors well.
\section{Conclusions}
We propose a novel DL backdoor forensics technique. It can decompose attack samples to clean inputs and triggers. It can automatically synthesize scanners from the forensics results such that other instantiations of the same type of backdoor can be identified (without the trojaned inputs). Our results show that the technique substantially outperforms the state-of-the-art.
\section{Design}
Figure~\ref{fig:overview} illustrates the overview of our technique.
It consists of three steps.
The first step is {\em attack sample decomposition} that decomposes an image with trigger to a clean image and a trigger.
The second step is {\em attack summarization} that extracts key distributions describing multiple attack samples, which may be from multiple models with various backdoors. Such distributions include trigger size and shape distributions, transformation coefficient distributions, and so on.
Note that we do not require the attack instances belong to a single backdoor type (as {{\sc Beagle}{}}{} will cluster and summarize them), although we assume most trojaned inputs of a particular instance exploit the same backdoor.
The third step is {\em scanner synthesis} that synthesizes loss function terms that can regulate the trigger inversion procedure to detect backdoors of the same kinds.
We will discuss the details of these steps in the following.
\subsection{Attack Sample Decomposition} \label{sec:decomposition}
\begin{figure*}[t]
\centering
\includegraphics[width=1.0\textwidth]{figures/v7.pdf}
\caption{Attack decomposition pipeline}
\label{fig:decompose}
\end{figure*}
This step aims to decompose given attack samples, namely, inputs with triggers, to their clean versions and the triggers. It assumes the trojaned model, a few attack samples for the model (10 in this paper), a set of clean samples for the validation purpose (100 per model in this paper, that is, 10 per class for CIFAR10, and 2-5 per class for other datasets),
a GAN denoting the input distribution, e.g., a general purpose GAN trained on ImageNet, the victim class labels, and the target class label.
Note that the clean samples are different from the clean versions of the attack samples, which are unknown according to our threat model.
The decomposition leverages a few key observations: (1) the clean versions of attack samples largely resemble victim class samples and they may be effectively generated using the GAN (when regulated by a cross-entropy loss on the subject model); (2) the decomposed trigger should be valid for the given validation clean samples, namely, causing them to be misclassified; (3) the decomposed trigger should be valid for the decomposed clean versions of attack samples; (4) {\em unstamping} the decomposed trigger from the attack sample should yield an image resembling the decomposed clean version (generated by the GAN);
(5) {\em unstamping} the decomposed clean version of an attack sample from the sample itself should yield an image resembling the decomposed trigger; and
(6) an attack sample should be similar to its decomposed clean version stamped with the decomposed trigger.
We will formally define stamping and unstamping later.
\smallskip
\noindent
{\bf Decomposition Pipeline.}
We devise a cyclic optimization based decomposition pipeline according to the above observations, as illustrated in Figure~\ref{fig:decompose}.
To concretize our discussion, we use reflection attack as an example.
Reflection attack~\cite{reflection} merges a clean input with another image to create a reflection effect (e.g., through glass).
Here the trojaned sample (on the left of Figure~\ref{fig:decompose}) is a dog with the reflection of a hallway, where the dog is the victim and the hallway is the trigger.
In the stage A \textit{ unstamping}, {{\sc Beagle}{}}{} decomposes a trojaned sample into its clean versions and the trigger.
At step \circled{1}, {{\sc Beagle}{}}{} initializes the decomposed trigger $\tilde{t}$, {\em unstamps} it from the trojaned sample, and derives an unstamped version $\hat{x}$ which is raw and noisy. To improve quality, at step \circled{2}, {{\sc Beagle}{}}{} reconstructs the decomposed clean version using a pre-trained GAN, which can be considered a filter that removes the out-of-distribution noises from $\hat{x}$ and yields $\tilde{x}$. At step \circled{3}, {{\sc Beagle}{}}{} {\em unstamps} $\tilde{x}$ from the trojaned sample and updates the decomposed trigger.
In stage B {\em stamping}, {{\sc Beagle}{}}{} ensures the effectiveness of decomposed clean version and trigger through multiple constraints.
At step \circled{4}, {{\sc Beagle}{}}{} re-stamps the decomposed trigger $\tilde{t}$ on the decomposed clean version $\tilde{x}$. The result should resemble the given trojaned sample. Their similarity is denoted by the bluish dotted line.
At step \circled{5}, {{\sc Beagle}{}}{} stamps the decomposed trigger to a set of clean samples.
At step \circled{6}, {{\sc Beagle}{}}{} ensures that the samples generated from the previous two steps (with the decomposed trigger) are misclassified to the target label.
At step \circled{7}, {{\sc Beagle}{}}{} ensures the decomposed clean version $\tilde{x}$ is correctly classified to the victim label.
Specifically, step \circled{2} corresponds to the aforementioned observation (1); \circled{5} to observation (2); \circled{4} to observations (3) and (6); \circled{1} to observation (4); and \circled{3} to observation (5).
\smallskip
\noindent
{\bf Formal Definition.}
Next, we formally define the decomposition process. For discussion clarity, we use the following symbols, $x$ denoting the (unknown) ground-truth clean sample, $t$ the (unknown) ground-truth trigger, $x_v$ a validation clean sample, $\tilde{x}$ the decomposed clean version of an attack sample, $\tilde{t}$ the decomposed trigger, $x \oplus t$ denotes stamping $t$ to $x$ and the stamping operation may vary across attacks (explained later), and $x_1 \ominus x_2$ denotes unstamping an image $x_2$ (which could be $\tilde{t}$ or $\tilde{x}$) from an image $x_1$.
We define three cross-entropy losses corresponding to steps \circled{6} and \circled{7} in Figure~\ref{fig:decompose}.
\begin{equation}
Loss_{CE} = \mathcal{L}(M(\tilde{x} \oplus \tilde{t}), y_{t}) + \mathcal{L}(M(x_{v} \oplus \tilde{t}), y_{t}) + \mathcal{L}(M(\tilde{x}), y_{v}),
\end{equation}
\noindent where $\mathcal{L}$ denotes the cross-entropy calculation, $M$ the trojaned model, $y_{t}$ the attack target label and $y_{v}$ the victim labels.
The first term in the loss means that the decomposed trigger is effective for the decomposed clean image. In other words, if we re-stamp the decomposed trigger $\tilde{t}$ to the decomposed clean image $\tilde{x}$ and feed it to the trojaned model, the model should output the target label.
The second term means that the decomposed trigger is effective for the clean validation images.
The third term means that the decomposed clean image has the trigger removed. In other words, the trojaned model should predict the decomposed clean image $\tilde{x}$ to its ground-truth label.
We also define two reconstruction losses, corresponding to steps \circled{2} and \circled{4} in Figure~\ref{fig:decompose}.
\begin{equation}
Loss_{recon} = LPIPS(\hat{x}, \tilde{x}) + L^2(x \oplus t, \tilde{x} \oplus \tilde{t}),
\end{equation}
\noindent $LPIPS$() denotes the LPIPS loss~\cite{lpips}, which is commonly used as a constraint in GAN based input reconstruction~\cite{mentzer2020high,zhu2017unpaired,jo2020investigating}, and $L^2$ denotes the $L^2$ norm, which calculates the Euclidean distance of two inputs.
The first term of $Loss_{recon}$ means that the decomposed (reconstructed) clean image $\tilde{x}$ should be similar to the unstamped clean image $\hat{x}$, while the GAN ensures that the former is in distribution.
The second term means that the restamped image $\tilde{x} \oplus \tilde{t}$ should be similar to the original trojaned image $x \oplus t$.
\noindent
The overall decomposition procedure can be defined as an optimization problem in the following.
\begin{equation} \label{e:loss}
\argmin_{\tilde{x}, \tilde{t}}\;\;\; Loss_{CE} + \alpha \cdot Loss_{recon},
\end{equation}
where $\alpha$ controls the trade-off between the two losses. Typically we set $\alpha = 10^2$.
\smallskip
\noindent
{\bf Modeling Stamping Operations in Different Backdoor Attacks.}
In the previous discussion, we have not defined the stamping/unstamping operations, which vary across different attacks.
Although there are many different types of backdoors, most of them can be abstracted to two forms.
They differ by their ways of injecting triggers.
The core challenge is hence to model these injection methods.
We consider there are two types of trigger injection methods: {\em patching} and {\em transforming}.
In the former, a trigger is injected to a clean sample by merging their pixel values.
There are different ways of merging, for instance, completely replacing the original pixels and adding/subtracting the original pixel values with the trigger pixel values. We use the masking function proposed in NC~\cite{nc} to model these different methods.
\begin{equation}
x\oplus t = x\cdot (1-m) + t\cdot m
\end{equation}
Here, $m$ is a mask with values in [0,1].
BadNets~\cite{badnet}, TrojNN~\cite{trojnn}, reflection attack~\cite{reflection}, and composite attack~\cite{composite} that place additional object(s) in a victim sample can be modeled by this function with different $m$ distributions.
The additional objects can be static patterns, e.g., a yellow flower placed at the top-left in BadNets, or semantic features, e.g., a truck image replacing half of the image in composite attack.
For example, pixel replacing means that all the $m$ values in the trigger area are 1.0 and the rest 0, following a binomial distribution.
Accordingly, we define the {\em unstamping} operation.
\begin{equation}
x\ominus t = \frac{x - t\cdot m}{1-m}
\end{equation}
We hence have $(x\oplus t) \ominus \tilde{t}\ \approx\ \tilde{x}$ and $(x\oplus t) \ominus \tilde{x}\ \approx\ \tilde{t}$.
Note that the definition does not mean we know $x$, $t$, $m$ beforehand. During forensics, we use their approximation $\tilde{x}$, $\tilde{t}$, and $\tilde{m}$ instead.
\begin{figure}[t]
\centering
\begin{subfigure}{.2\textwidth}
\centering
\includegraphics[width=0.6\textwidth]{figures/gen_clean_wo_norm.png}
\caption{Without Normalization}
\end{subfigure}
%
\begin{subfigure}{.2\textwidth}
\centering
\includegraphics[width=0.6\textwidth]{figures/gen_clean.png}
\caption{With Normalization}
\end{subfigure}
%
\caption{Effectiveness of normalization}
\label{fig:decompose_trick}
\end{figure}
\smallskip
\noindent
{\em Normalization.}
In the first few steps of optimization we do not have a good approximation of the $m$ value, the unstamping operation tends to aggressively reduce pixel values (in order to reduce the loss value with an inappropriate $\tilde{m}$), and hence the decomposed image tends to be dark and noisy, as shown in Figure~\ref{fig:decompose_trick} (a). We use a normalization step to calibrate the unstamped image values to be within the distributions denoted by clean validation images. Hence the decomposed images become vivid and clear, as shown in (b). They also substantially speedup convergence.
Specifically, the normalization step is defined as follows.
\begin{equation} \label{equ:normalization}
x_{norm} = \frac{x - mean(x)}{std(x)} \cdot std(x_{v}) + mean(x_{v}),
\end{equation}
\noindent where $x$ denotes the images to normalize, $x_{norm}$ the normalized versions, $x_{v}$ the given set of clean validation images, $mean$ and $std$ the mean and the standard deviation, respectively.
It is performed at step \circled{1} in Figure~\ref{fig:decompose} after we unstamp the trigger. $\Box$
\smallskip
In the second type of injection, the transforming type (e.g., Invisible~\cite{invisible}, WaNet~\cite{wanet}, and Instagram filter~\cite{ABS} attacks), a trigger is injected using a transformation function in the form of an algorithm or a pre-trained network.
\begin{equation}
x \oplus t = \mathcal{F} (x; t)
\end{equation}
Observe that we use the coefficients of transformation function $\mathcal{F}$ to denote the trigger $t$ because such coefficients indeed uniquely define a trigger.
During forensics, we leverage a piece-wise linear function to approximate $\mathcal{F}$.
Compared to the patching form of backdoors, defining the unstamping operation here is more challenging because there is not a simple inverse function of $\mathcal{F}$.
The pervasive perturbations injected by these attacks cannot be easily removed by simple mutations.
We hence leverage the reconstruction and denoising ability of GAN to perform the unstamping function.
\begin{equation}
x\ominus t = GAN(normalize(x \oplus t))
\end{equation}
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{figures/complex_linear.pdf}
\caption{Modeling transforming backdoors}
\label{fig:method_linear}
\end{figure}
Different pervasive backdoors may have substantially different $\mathcal{F}$. In order to have a uniform modeling of these functions, we propose to use a piece-wide linear function, leveraging the observation that {\em pervasive backdoors usually do not change human perception of an input such that a pixel in a trojaned input tends to be closely related to its neighboring pixels in the clean version}.
Specifically, as shown in Figure~\ref{fig:method_linear}, for each pixel in the clean input (e.g., pixel 3 highlighted in red on the left), we introduce a $3 \times 3$ trainable grid (e.g., the blue grid in the middle). A pixel in the injected/transformed image is the sum of the element-wise product of the $3 \times 3$ neighbors in the original input and the trainable grid, adding a trainable bias. It is formally defined as follows.
\begin{equation} \label{equ:complex}
(x \oplus t)_{[i, j, k]} = \sum\limits_{p=-1}^{1} \sum\limits_{q=-1}^{1} (x_{[i+p, j+q, k]} \cdot t_{[3i-1+p, 3j-1+q, k]}^{w}) + t_{i, j, k}^{b}
\end{equation}
\noindent where $i, j, k$ denote the coordinates of width $W$, height $H$ and channel $C$ of the input image. Intuitively, $x_{[i,j,k]}$ denotes the pixel value at the $i^{th}$ column, $j^{th}$ row and $k^{th}$ channel. $p$ and $q$ are used to traverse the $3 \times 3$ neighborhood of this pixel. Trigger $t$ consists of $t^{w}$ and $t^{b}$, with the former the trainable weights
and the latter the biases of the piece-wise linear functions. The blue matrix in Figure~\ref{fig:method_linear} with shape $(3H, 3W, C)$ denotes $t^w$ since we have a $3 \times 3$ grid for each pixel.
For example in Figure~\ref{fig:method_linear} assume $x_{[i, j, k]}$ is the middle element ``3'' in the first column.
Then $x_{[i+p,j+q,k]}$ where $p, q \in \{-1, 0, 1\}$ traverses the $3 \times 3$ neighborhood of $x_{[i, j, k]}=3$, e.g., $x_{[i-1, j-1, k]}=5$.
$t_{[3i-1+p, 3j-1+q, k]}^{w}$ where $p, q \in \{-1, 0, 1\}$ denotes the trainable $3 \times 3$ grid for pixel $x_{[i, j, k]}$.
For example, $t_{[3i-1, 3j-1, k]}^{w}=0.9$ in the second column of Figure~\ref{fig:method_linear} is the weight value corresponding to $x_{[i, j, k]}=3$,
and $t_{[3i-2, 3j-2, k]}^{w}=0.2$ is the weight value corresponding to $x_{[i-1, j-1, k]}=5$.
Finally, we add up the element-wise product for the new pixel value $(x \oplus t)_{[i, j, k]}$.
Assume bias $t^{b}_{i, j, k} = 0$. The new value of the middle ``3'' is computed as follows.
\begin{align}\scriptsize
& 5 \times 0.2 + 1 \times 0.5 + 8 \times 0.1 + 2 \times 0.5 + 3 \times 0.9 \\ \nonumber
& + 16 \times 0.0 + 4 \times 0.1 + 0 \times 0.7 + 7 \times 0.2 + 0 = 7.8 \nonumber
\end{align}
\noindent which is highlighted in yellow in the third column.
The goal of decomposition is hence to update the trainable grids so that the loss in Eq.~\ref{e:loss} is minimized.
For instance, the Nashville filter backdoor can be precisely formulated by trainable grids with a non-zero central value surrounded by 8 zero values.
After injection, the new value of a pixel is just a linear transformation of its original value.
Moreover, if one considers each grid for a pixel denotes some local transformation, the grids for close-by pixels share a lot of similarity in order to ensure transformation smoothness.
For example, all the trainable grids for a Nashville filter backdoor are the same.
To leverage this observation, we introduce a smoothing loss Eq.~\ref{equ:smooth} to regulate the differences between close-by grids.
\begin{equation} \label{equ:smooth}
Loss_{smooth} = L^2(Resize(Avgpool(\tilde{t})), \tilde{t}),
\end{equation}
\noindent where $Avgpool()$ denotes the average pooling operation and $Resize()$ resizes the result after average pooling to the original shape.
Average pooling helps reduce the differences between close-by grids.
The two images on the right of Figure~\ref{fig:method_linear} show the transformations by a WaNet backdoor trigger and the decomposed trigger by {{\sc Beagle}{}}. The two share similarity and the latter has a close-to 1.0 ASR.
Given a model for forensics, since we do not know if it has a patching or transformation form of backdoor, we try to decompose the attack samples using both forms and then choose the one with better performance. Details can be found in Appendix~\ref{sec:select_func}.
\subsection{Attack Samples Clustering and Summarization} \label{sec:design_summarize}
In the previous step, we decompose each attack sample $x\oplus t$ to its clean version $\tilde{x}$ and trigger $\tilde{t}$.
For example in Figure~\ref{fig:decompose}, we decompose an input attack sample $x\oplus t$, which is a dog $x$ stamped with a hallway reflection $t$, into its clean version $\tilde{x} \approx x$ which is the reconstructed dog and trigger $\tilde{t} \approx t$, the generated hallway.
In this step, we first extract an attack feature vector $v$ from the decomposition of each attack sample.
We then cluster these vectors based on their values. The vectors in a cluster are summarized by Gaussian distributions.
\noindent
\textbf{Attack Feature Extraction.}
For an attack sample of the patching form of backdoors, its attack features include both the decomposed mask $\tilde{m}$ and the decomposed trigger $\tilde{t}$. Therefore,
\begin{equation}
v = (\tilde{m}, \tilde{t})
\end{equation}
In many cases, $\tilde{m}$ values have special distributions.
For example, $\tilde{m}$ tends to have a binomial distribution for attack samples of a simple patch backdoor, namely, stamping a patch trigger on an input (by replacing its pixels).
In this case, we simplify the features to the mask size $s$ (e.g., denoting patch size) and the position of mask center $(i,j)$ (e.g., denoting patch position). Hence, the property vector $v = (i,j,s,\tilde{t})$ with $s$ = {\it sum}($\tilde{m}$) , and ($i$, $j$) = {\it mean}($\tilde{m}$).
For backdoors that mix images with some ratio like reflection attack, e.g., a pixel after injection is 0.7 of the original pixel plus 0.3 of the trigger pixel, values in $\tilde{m}$ tend to be constant. For such cases, we simplify the attack feature value to $v = \tilde{t}$.
For transforming backdoors, we extract the coefficients of the piece-wise linear function as the features.
\begin{equation}
v = (\widetilde{t^w}, \widetilde{t^b})
\end{equation}
with $\widetilde{t^w}$ the (reverse engineered) weights and $\widetilde{t^b}$ the biases (in Eq.~\ref{equ:complex}).
\noindent
\textbf{Clustering.}
Given the set of feature vectors of $n$ attack samples, i.e., $\mathbb{V}=\{v_1,\ ...,\ v_n\}$
we partition it to $k$ disjoint subsets $\mathbb{V}_1$, ... $\mathbb{V}_k$, based on their different forms and their values, using a number of standard clustering algorithms, e.g., Kmeans~\cite{kmeans}, GMM~\cite{gmm}, and DNSCAN~\cite{dbscan}.
\smallskip
\noindent
\textbf{Summarization.}
We consider each cluster $\mathbb{V}_i$ denotes a type of backdoor attack and we summarize it by modeling values in individual dimensions of $\mathbb{V}_i$ using Gaussian distributions.
Formally, we say the $i$th type of backdoor attack
\begin{equation} \label{e:attack}
\textit{backdoor}_i \sim \mathcal{N}(\mu_i,\,\sigma_i^{2}),
\end{equation}
with $\mu_i$ and $\sigma_i^{2}$ the mean (vector) and the variance (vector) of $\mathbb{V}_i$.
We choose to use Gaussian distributions because of their generality~\cite{rasmussen2003gaussian,lu2005clustering,raissi2017machine}.
The central limit theorem~\cite{kwak2017central,schatte1988strong,hoeffding1948central} states that when a distribution is complex and affected by a large number of independent random variables (like physical world distributions),
it tends to be Gaussian.
\begin{figure}[t]
\begin{minipage}[t]{0.44\columnwidth}
\centering
\includegraphics[width=1.6in]{figures/3D_GMM_distribution_polygon_round2.pdf}
\caption{Clustering TrojAI polygon attack samples}
\label{fig:polygon_cluster}
\end{minipage}
~
\begin{minipage}[t]{0.44\columnwidth}
\centering
\includegraphics[width=1.6in]{figures/poly_size_dist.pdf}
\caption{Trigger size distribution}
\label{fig:polygon_size_dist}
\end{minipage}
\end{figure}
\subsection{Scanner Synthesis} \label{sec:synthesis}
In the previous step, we summarize the attack decomposition based on different backdoor types, e.g., patch attack. For each backdoor type $\textit{backdoor}_i$, we model its coefficient distribution, e.g., patch size, color, and position.
In this step, we synthesize a scanner for each backdoor type, namely, $\textit{backdor}_i$ in Eq.~\ref{e:attack}, from its distribution coefficients.
These scanners are based on trigger inversion.
We consider all trigger inversion methods use a general loss function template as follows.
\begin{equation}
Loss = Loss_{ce} + Loss_{reg}
\end{equation}
with the first the cross-entropy loss and the second the regularization loss (e.g., Eq.~\ref{eq:inversion}).
{{\sc Beagle}{}}{} synthesizes scanners by {\em synthesizing the regularization term}. We want to point out this loss function is used in scanning a model (to determine if it has an backdoor) and hence different from that in decomposition (i.e., Eq.~\ref{e:loss}).
Specifically, for each attack feature $f$, such as $\tilde{m}$ and $\tilde{t}$ in the patching form of backdoors and $\widetilde{t^w}$ and $\widetilde{t^b}$ in transforming backdoors,
assume it has been summarized to $ f \sim \mathcal{N}(\mu_f,\,\sigma_f^{2})$.
We introduce a regularization term as follows.
\begin{equation} \label{equ:distrib}
Loss_{reg}^{f} =
\begin{cases}
0 & \text{if } f \in [\mu_{f} - z \cdot \sigma_{f}, \mu_{f} + z \cdot \sigma_{f}] \\
\delta \cdot |f - \mu_{f}| & \text{otherwise.}
\end{cases}
\end{equation}
Intuitively, during inversion, we aim to keep the $f$ value within the 15th-85th percentile. This is enforced by having the parameter $z=1.04$ in Eq.~\ref{equ:distrib}. In other words, penalty is introduced when it is beyond the range.
\smallskip
\noindent
\textbf{Example.}
We show how we summarize TrojAI polygon patch backdoors and synthesize a scanner.
First we sample 20 trojaned models and perform attack decomposition and summarization.
Figure~\ref{fig:polygon_cluster} shows the clustering result, where {{\sc Beagle}{}}{} partitions them into one cluster due to their cohesive behaviors.
Moreover, the decomposed masks $\tilde{m}$ follow binomial distributions.
According to the discussion in Section~\ref{sec:design_summarize},
in such cases {{\sc Beagle}{}}{} extracts attack feature as ($i$, $j$, $s$, $\tilde{t}$) with ($i$, $j$) the center of mask and $s$ its size.
Figure~\ref{fig:polygon_size_dist} illustrates the distribution of trigger size, with $\mu_{s} = 1316.83$ and $\sigma_s = 283.58$.
Then {{\sc Beagle}{}}{} synthesize a regularization term as follows, with $s=\sum m$ the size of mask during inversion.
\begin{equation}
Loss_{s} =
\begin{cases}
0 &\text{ if } \sum m \in [1033.25, 1600.41] \\
100 \cdot |\sum m - 1316.83| &\text{ otherwise.}
\end{cases}
\end{equation}
Similarly, we have other regularization losses for $i$ and $j$.
In Section~\ref{sec:scan}, we will show that {{\sc Beagle}{}}{} can automatically synthesize 6 scanners for all the different types of backdoors in TrojAI and achieves over 0.9 detection accuracy, which existing scanners cannot achieve without substantial manual reconfiguration based on attack specifics.
\section{Evaluation}
This section evaluates how {{\sc Beagle}{}}{} enhances the performance of various downstream scanners in detecting trojaned models (Section~\ref{sec:scan}) and eliminates identified injected backdoors through model unlearning (Section~\ref{sec:remove}). {{\sc Beagle}{}}{} has two key components: attack decomposition and attack summarization.
For attack decomposition, we evaluate the quality of decomposed clean versions (of trojaned samples) and the attack effectiveness of decomposed triggers in Section~\ref{sec:visual}. For attack summarization, we validate the performance of automatic attack clustering in Section~\ref{sec:summarize}. As {{\sc Beagle}{}}{} summarizes the attack knowledge from a small set of trojaned models and inputs, it is interesting to study the effect of biases on sampled models as well as inputs, which will be discussed in Section~\ref{sec:sample}. We also investigate three attack scenarios aiming to counter {{\sc Beagle}{}}{} in Section~\ref{sec:adaptive}. Finally, a set of ablation studies are carried out to understand different design choices (Section~\ref{sec:ablation}).
Our experiments are conducted on 10 well-known backdoor attacks including static, dynamic, and complex backdoors on 2,532 models in total, consisting of 22 network architectures with 6 datasets. {{\sc Beagle}{}}{} is compared with 9 baselines in various experiments.
\subsection{Experiment Setup}
\smallskip
\noindent
\textbf{Attack Setup.}
We evaluate on 10 existing backdoor attacks, namely, BadNets~\cite{badnet}, TrojNN~\cite{trojnn}, Dynamic~\cite{dynamic}, Reflection~\cite{reflection}, Blend~\cite{blend}, SIG~\cite{sig}, Invisible~\cite{invisible}, WaNet~\cite{wanet}, Gotham~\cite{ABS}, and DFST~\cite{dfst}. Widely used datasets such as ImageNet~\cite{ILSVRC15}, CelebA~\cite{celeba}, CIFAR-10~\cite{cifar10}, GTSRB~\cite{gtsrb} are utilized to construct trojaned and benign models. We also make use of 2,112 pre-trained models from TrojAI~\cite{trojai} rounds 2 and 3, half benign and half poisoned. Please see details of these backdoor attacks and datasets/models in Appendix~\ref{sec:append_setup}.
For the 10 aforementioned backdoor attacks, we use a poisoning rate of 10\%. Most of these backdoors are universal (by their default settings) where inputs from all the classes (except the target class) stamped with the trigger will be misclassified to the target label by the subject model.
Some of the TrojAI models are label specific (only causing images of a victim class to be misclassified).
We use the same adversarial training strategies to make the backdoor robust for WaNet and DFST according to their original papers~\cite{wanet,dfst}.
\noindent
\textbf{Setup of {{\sc Beagle}{}}{}.}
For attack decomposition, we assume 10 trojaned images and 100 clean images per model, where the original images of trojaned samples are different from those clean images.
We leverage the state-of-the-art StyleGAN~\cite{styleganv2} to recover the clean version of a trojaned image. We download pre-trained GANs from GenForce Lib~\cite{genforce} to handle different datasets.
\input{tables/trojai_eval}
\input{tables/trojai_eval2}
\input{tables/trojai_eval3}
\input{tables/trojai_eval4}
\subsection{Forensics-aided Defense against Injected Backdoors}
\subsubsection{Backdoor Scanning} \label{sec:scan}
We integrate {{\sc Beagle}{}}{} with 5 state-of-the-art trigger-inversion based backdoor scanners that determine if a model contains a backdoor by inverting a (small) trigger that can induce misclassification for a small set of clean samples. Besides NC and ABS discussed in Section~\ref{sec:motivation}, we integrate with
Tabor~\cite{Tabor}, K-Arm~\cite{karm}, and SRI Trinity~\cite{sri} as well (see detailed descriptions of these scanners in Appendix~\ref{sec:scanner_appendix}).
NC only supports universal patch type of backdoors. ABS supports universal
and label-specific patch backdoors and filter backdoors.
\input{tables/enhance_abs}
While Table~\ref{tab:moti_nc_abs} in Section~\ref{sec:motivation}
already shows that existing scanners cannot be generally effective and only work for the types of backdoors that they focus on, whereas {{\sc Beagle}{}}{} can effectively and fully automatically scan all kinds of backdoors. In this study, we further show that using the loss functions automatically synthesized by {{\sc Beagle}{}}{}, we can substantially improve these scanners even for their targeted backdoor types.
Specifically, we use the models from TrojAI rounds 2 and 3. The models of round 3 are adversarial trained while the round 2 models not.
We evaluate NC and Tabor on trojaned models with universal polygon backdoors, K-Arm, ABS, SRI Trinity on trojaned models with universal and label-specifc polygon backdoors, and ABS and SRI Trinity on trojaned models with filter triggers.
Trojaned models are always mixed with equal number of benign models during scanning.
Besides, we evaluate ABS and SRI Trinity on the entire set of models (with all sorts of backdoors).
For each setting, we assume we have access to only 20 random (< 10\%) trojaned models for attack decomposition and summarization.
While there may be sampling biases, we study the effects of such biases later in this section.
Table~\ref{tab:eval_universal_polygon} shows the results of NC and Tabor on universal polygon backdoors. We can see that there is roughly a 10\% accuracy improvement on each setting. Note that the number of FPs (False Positives) is largely reduced while the number of FNs (False Negatives) slightly increases. This is because we regulate the inversion within certain distributions.
Table~\ref{tab:eval_specific_polygon} shows the results of K-Arm, ABS and SRI Trinity on universal and label-specific polygon backdoors. For K-Arm and ABS, we report the performance of original settings on their Github and their customized versions for TrojAI in which the configurations are changed based on the released attack information. Observe that {{\sc Beagle}{}}{} improves the scanning accuracy by 10\%-15\% compared to the original settings. {{\sc Beagle}{}}{} can even improve the customized versions by 1.5\%.
Note that the customized versions had undergone intensive manual tuning and added regularization specific to the TrojAI attacks. For example, the customized ABS adds a constraint that all pixels in an inverted trigger area have the same color, as the round specifications state that a polygon trigger is always filled with the same color.
Note that the performance of SRI Trinity is not as high as the other two because we only use its upstream inversion technique.
Table~\ref{tab:eval_filter} shows the results of ABS and SRI Trinity on instagram filter backdoors. {{\sc Beagle}{}}{} achieves an overall improvement from 6\% to 27\% and largely reduces both FPs and FNs in most cases. ABS was not customized for filter backdoors.
Table~\ref{tab:eval_whole} shows the results of ABS and SRI Trinity on the entire model sets.
In this case, {{\sc Beagle}{}}{} automatically clusters the provided instances and synthesizes the corresponding inversion loss functions.
Observe that the improvement is around 15\%, and both FPs and FNs are reduced in most cases.
As the customized ABS does not handle filter backdoors, we use the original ABS in this experiment.
Besides, we create multiple model sets to evaluate complex attacks, including Dynamic, Reflection, SIG, Blend, Invisible, WaNet and DFST.
We train 30 clean models and 30 trojaned models for each complex attack on CIFAR-10 and GTSRB to compose the subject model sets.
We train 20 clean models and 20 trojaned models on ImageNet.
We assume for each attack, we have access to 5 trojaned models other than the subject model sets, on which we perform attack decomposition and summarization. We leverage ABS as the downstream scanner.
Here we also assume the sampled models cover all the backdoor types in the subject models sets.
Table~\ref{tab:eval_abs_complex} shows the results. The first column denotes the datasets and the attacks. The second and third large columns denote the performance of original ABS and {{\sc Beagle}{}}{}-enhanced one.
Following the original ABS setup, if the inverted trigger can achieve 0.88 ASR on the validation images, we consider a model trojaned.
In each large column, there are 5 columns, PN-REASRs show the average REASR (ASR of reverse-engineered trigger by ABS) on poisoned models, while CL-REASRs show the REASRs on clean models. FP, FN, ACC denote the number of false positives, false negatives and the scanning accuracy. We also report the scanning time.
Observe that in most cases, The {{\sc Beagle}{}}{}-equipped ABS can improve the scanning accuracy by a large extent, especially for WaNet, Invisible and DFST.
Note that sometimes the {{\sc Beagle}{}}{}-equipped ABS may induce a few FPs, which is reasonable because {{\sc Beagle}{}}{}'s piece-wise linear transformation function is expressive and tends to generate some adversarial perturbations leading to high ASR. This is also evidenced by the nontrivial CL-REASRs in Invisible, WaNet and DFST.
Nonetheless, we can still find a clear separation between clean and trojaned models as shown in Figure~\ref{fig:enh_abs_complex}, much better than without {{\sc Beagle}{}}{}.
In addition, we observe {{\sc Beagle}{}}{}-equipped ABS spends similar time compared to the original version, which means the overhead is small.
\begin{figure}[t]
\centering
\includegraphics[width=0.48\textwidth]{figures/abs_scatter.pdf}
\caption{Separation of clean and trojaned models. The first column shows the data points by the original ABS while the second column shows those by the {{\sc Beagle}{}}{} equipped ABS. Observe {{\sc Beagle}{}}{} allows better separation.}
\label{fig:enh_abs_complex}
\end{figure}
\subsubsection{Backdoor Removal} \label{sec:remove}
\input{tables/model_hardening}
Backdoor removal aims to eliminate injected backdoors in models. In Section~\ref{sec:decomposition}, we have demonstrated that our decomposed triggers closely resemble the original injected triggers and are highly effective to induce the same attack effects (as the original triggers). The idea is hence to leverage our decomposed triggers in model unlearning to remove injected backdoors.
We use the CIFAR-10 dataset and the VGG-11 network and conduct the experiments on 10 backdoor attacks. We assume 1\% of the original training dataset is available for retraining the model. The same data augmentations as in NAD~\cite{li2021neural} are leveraged, including random crop, random cutoff, and horizontal flipping. Our model unlearning is carried out by stamping decomposed triggers on training samples and using the original ground truth labels during training. Several existing backdoor removal techniques are considered for comparison, such as Finetune, NAD~\cite{li2021neural}, and ANP~\cite{wu2021adversarial}. The final results are obtained by constraining the accuracy degradation to be within 5\%.
Table~\ref{tab:model_harden} shows the results. The first column presents different backdoor attacks. The following columns show the results for the original poisoned models and the models cleansed by different techniques. We report both the clean accuracy (ACC) and attack success rate (ASR) in the table. Observe that in most cases, {{\sc Beagle}{}}{} can effectively eliminate injected backdoors, especially for Reflection, Invisible, and DFST, outperforming baselines. On average, {{\sc Beagle}{}}{} reduces 10\%-20\% more ASR than the state-of-the-art methods.
This also demonstrates that the decomposed trigger by {{\sc Beagle}{}}{} is very similar to the original trigger. A simple model unlearning can already remove most of those injected backdoors.
\subsection{Validating Decomposed Clean Inputs and Triggers} \label{sec:visual}
\begin{figure*}
\centering
\includegraphics[width=1.0\textwidth]{figures/decompose_imagenet.pdf}
\caption{Decomposition quality on ImageNet}
\label{fig:decompose_imagenet}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[width=1.0\textwidth]{figures/decompose_celeba.pdf}
\caption{Decomposition quality on CelebA \vspace{-7pt}}
\label{fig:decompose_celebA}
\end{figure*}
We qualitatively and quantitatively validate the decomposed clean inputs and triggers by assessing their visual quality and classification accuracy.
The visual quality of decomposed clean inputs is measured by comparing them with their original versions (before trojaned).
The validation of decomposed triggers is carried out by comparing clean images stamped with the ground-truth trigger and with the decomposed trigger. Three widely-used metrics, $L^1$ distance, Peak Signal-to-Noise Ratio (PSNR), Structural Similarity Index Measure (SSIM), are utilized to quantify the differences between aforementioned pairs. A good decomposition result shall have a small $L^1$ distance, a high PSNR, and a large SSIM.
For decomposed clean inputs, the subject model shall correctly classify them with a high standard accuracy. For decomposed triggers, the subject model shall produce the target label when they are stamped onto clean images, which corresponds to the attack success rate.
We compare a state-of-the-art technique \textit{Februus}~\cite{februus}, which removes backdoor triggers in trojaned images, with {{\sc Beagle}{}}{} and show the results in Figure~\ref{fig:decompose_imagenet} and Figure~\ref{fig:decompose_celebA}.
All the trojaned models are well-trained with performance on par with state-of-the-arts. Specifically, the top-1 accuracy is $>73\%$ for ImageNet, $>78\%$ for CelebA, $>91\%$ for CIFAR-10, and $>94\%$ for GTSRB. The ASRs are all $>97\%$, except for Reflection and SIG whose ASRs are $>88\%$, consistent with the original papers~\cite{reflection, sig}.
Figure~\ref{fig:decompose_imagenet} shows the result for ImageNet and Figure~\ref{fig:decompose_celebA} for CelebA.
The detailed numbers and other results for CIFAR-10 and GTSRB can be found in the supplementary document Section A~\cite{beagle}.
In each figure, there are two rows, row (A) denoting the quality of decomposed clean images and row (B) the quality of decomposed triggers.
In each row, four bar charts recording the $L^1$ distance, PSNR, SSIM, and ACC/ASR, respectively, for the five attacks are displayed.
Since for the $L^1$ distance, lower bars denote better performance while higher bars are better for other metrics, we use different colors to present the bar charts of $L^1$ distance.
In the $L^1$, PSNR, and SSIM bar charts, there are two bars for each attack, where the left bar shows the difference between original clean images and decomposed images by Februus and the right bar the difference by {{\sc Beagle}{}}.
Each bar presents the average value for the given 10 trojaned images and 100 additional clean test images.
For the ACC/ASR bar charts, the left bar is for Februus and the right for ${{\sc Beagle}{}}{}$. Each ACC bar denotes the average clean accuracy for the decomposed clean images from the given 10 trojaned samples. As the 100 validation clean images have been used in optimization, we use the images from the test set and stamp the decomposed trigger to calculate the ASR.
Observe that in most cases, {{\sc Beagle}{}}{} outperforms Februus in visual quality, classification accuracy, and ASR.
As Februus is designed to handle patch attacks, we can see for BadNets and TrojNN on ImageNet and CelebA, in some cases, Februus outperforms ours with slightly better visual quality for decomposed triggers. While Februus directly removes the trigger area, we optimize a trigger mask, which may potentially induce some noise as the mask is continuous ranging from 0 to 1, causing some trigger pixels not fully extracted.
Figure~\ref{fig:decomposition} (A) shows a case for BadNets. The first row shows the decomposition results for a trojaned sample. Subfigure (a) is the trojaned sample, (b) the ground-truth clean version of the trojaned sample, (c) the decomposed clean image by Februus, and (d) the decomposed clean image by {{\sc Beagle}{}}{}. The second row shows the quality of the decomposed trigger. Subfigure (e) is a clean image, (f) the clean image with the ground-truth trigger, (g) the clean image with Februus's decomposed trigger, and (h) the clean image with our decomposed trigger. Observe that the trigger extracted by Februus contains part of the ground-truth trigger. Observe that {{\sc Beagle}{}}{} captures almost all the trigger features. However, using the metrics in Figure~\ref{fig:decompose_imagenet} on this case shows that Februus outperforms {{\sc Beagle}{}}{}. This is because the trigger extracted by {{\sc Beagle}{}}{} contains some (imperceptible) noise, degrading the measured values.
For Invisible and WaNet, Februus has better visual quality on decomposed clean images than ours. This is because we apply adaptive normalization to trojaned images before reconstruction, which may induce a slightly different distribution compared to the original one. It is reasonable as we have no knowledge of the original distribution. Besides, note that the difference between trojaned samples and their clean counterparts is small (invisible perturbation). Februus removes the entire area and directly reconstructs the input using GAN, which leads to unfaithful decomposed inputs and triggers. This is evidenced by that the ACC of decomposed clean images and the ASR of the decomposed triggers are both low for Februus. {{\sc Beagle}{}}{}, on the other hand, faithfully reconstructs the clean images and approximates the trigger injection functions, achieving the ACC of 100\% and the ASR of larger than 90\%.
Figure~\ref{fig:decomposition} (B) shows a case for Invisible attack. Our recovered image is only slightly different from the source image and the decomposed trigger is similar to the original injected one.
For other attacks, such as Reflection, SIG, and Gotham, {{\sc Beagle}{}}{} significantly outperforms Februus in both visual quality and classification results in Figure~\ref{fig:decompose_celebA}.
Figure~\ref{fig:decomposition} (C) shows a case of the reflection attack. {{\sc Beagle}{}}{} is able to achieve high visual quality in reconstructing the clean image and extracting the trigger, whereas Februus fails.
\begin{figure}[!h]
\centering
\begin{minipage}{0.5\textwidth}
\centering
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_badnet/pur/trojan.png}
\caption*{(a) $x \oplus t$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_badnet/pur/source.png}
\caption*{(b) $x$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_badnet/pur/februus.png}
\caption*{(c) Fb. $\tilde{x}$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_badnet/pur/forensic.png}
\caption*{(d) {\sc Bg.} $\tilde{x}$}
\end{minipage}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\centering
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_badnet/seg/clean.png}
\caption*{(e) $x_{v}$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_badnet/seg/inject.png}
\caption*{(f) $x_{v} \oplus t$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_badnet/seg/februus.png}
\caption*{(g) Fb. $x_{v} \oplus \tilde{t}$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_badnet/seg/forensic.png}
\caption*{(h) {\sc Bg.} $x_{v} \oplus \tilde{t}$}
\end{minipage}
\caption*{(A) Decomposition of BadNets}
\label{fig:decomp_badnet}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\centering
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_invisible/pur/trojan.png}
\caption*{(a) $x \oplus t$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_invisible/pur/source.png}
\caption*{(b) $x$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_invisible/pur/februus.png}
\caption*{(c) Fb. $\tilde{x}$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_invisible/pur/forensic.png}
\caption*{(d) {\sc Bg.} $\tilde{x}$}
\end{minipage}
\end{minipage}
\begin{minipage}{0.50\textwidth}
\centering
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_invisible/seg/clean.png}
\caption*{(e) $x_{v}$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_invisible/seg/inject.png}
\caption*{(f) $x_{v} \oplus t - x_v$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_invisible/seg/februus.png}
\captionsetup{font=footnotesize}
\caption*{(g) Fb. $x_{v} \oplus \tilde{t} - x_{v}$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_invisible/seg/forensic.png}
\captionsetup{font=footnotesize}
\caption*{(h) {\sc Bg.}\! $x_{v}\! \oplus \tilde{t}\! - x_{v}$}
\end{minipage}
\caption*{(B) Decomposition of Invisible}
\label{fig:decomp_invisible}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\centering
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_reflection/pur/trojan.png}
\caption*{(a) $x \oplus t$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_reflection/pur/source.png}
\caption*{(b) $x$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_reflection/pur/februus.png}
\caption*{(c) Fb. $\tilde{x}$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_reflection/pur/forensic.png}
\caption*{(d) {\sc Bg.} $\tilde{x}$}
\end{minipage}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\centering
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_reflection/seg/clean.png}
\caption*{(e) $x_{v}$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_reflection/seg/inject.png}
\caption*{(f) $x_{v} \oplus t$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_reflection/seg/februus.png}
\caption*{(g) Fb. $x_{v} \oplus \tilde{t}$}
\end{minipage}
%
\begin{minipage}[t]{.22\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/demo_reflection/seg/forensic.png}
\caption*{(h) {\sc Bg.} $x_{v} \oplus \tilde{t}$}
\end{minipage}
%
\caption*{(C) Decomposition of Reflection}
\label{fig:decomp_reflection}
\end{minipage}
\caption{
Attack Decomposition. The decomposition of each attack is visualized in a block of 2 $\times$ 4 images. Image (a) shows the given trojaned image $x \oplus t$, (b) its ground-truth clean version $x$, (c) the decomposed clean version $\tilde{x}$ of Februus (Fb.), and (d) the decomposed clean version $\tilde{x}$ of {{\sc Beagle}{}}{} ({\sc Bg.}) respectively. Image (e) shows a validation clean image $x_{v}$, (f) its ground-truth trojaned version $x_{v} \oplus t$, (g) the trojaned version stamped with the decomposed trigger $x_{v} \oplus \tilde{t}$ by Februus (Fb.), (h) and the trojaned version stamped with the decomposed trigger $x_{v} \oplus \tilde{t}$ by {{\sc Beagle}{}}{} ({\sc Bg.}) respectively. For Invisible attack, we visualize the difference between the clean version and trigger-stamped one ($x_v \oplus t - x_v$) as the trigger effect is invisible.}
\label{fig:decomposition}
\end{figure}
\subsection{Evaluation on Attack Clustering and Summarization} \label{sec:summarize}
A critical assumption of {{\sc Beagle}{}}{} is that we are able to model existing backdoors by two mathematical forms (see Section~\ref{sec:decomposition}):
patching and transforming. Here we validate this assumption.
We conduct an experiment on CIFAR-10 with VGG-11 for seven backdoor attacks: BadNets, Dynamic, Reflection, SIG, Invisible, WaNet, and Gotham. We train 30 trojaned models for each attack and then randomly sample 5 from each attack to form a pool of attack instances. We then use {{\sc Beagle}{}}{} to cluster these instances. {{\sc Beagle}{}}{} generates 11 clusters, 3 for the reflection attack corresponding to the three trigger images used, 3 for SIG (due to the 3 different trigger images), and one for each of the remaining attack types.
Table~\ref{tab:trigger_type} shows the summarization results.
The first row shows the attacks. The second row describes the clusters including their forms (patching or transforming) and coefficient distributions (e.g., binomial and constant).
The third row shows the ASR of the decomposd triggers.
Observe that BadNets and Dynamic belong to the patching category and their masks have a binomial distribution, indicating that they replace pixel values. Reflection and SIG belong to the patching category with constant mask values, meaning that they merge images. Gotham belongs to the transforming type and the coefficients are simple (mostly 0). Invisible and WaNet on the other hand have complex grid coefficients.
Observe that all the decomposed triggers have high ASRs, supporting that our backdoor modeling can cover all these backdoors.
We also validate our assumption on TrojAI rounds 2 and 3. Details can be found in the supplementary document Section B~\cite{beagle}.
\subsection{Impact of Attack Sample Bias} \label{sec:sample}
As {{\sc Beagle}{}}{} leverages a small set of inputs (clean and trojaned) and trojaned models, we study the impact of sampling biases in such data. For sampled inputs, we include a few naturally misclassified inputs without any injected backdoors. This simulates the real world scenario where classification models do not usually achieve 100\% accuracy. For sampled models, we intentionally introduce biases to the number of trojaned models with different attack types.
Our experiments show that {{\sc Beagle}{}}{} is robust to sample biases. Details can found in the supplementary document Section C~\cite{beagle}.
\begin{table}[t]
\centering
\scriptsize
\tabcolsep=3.0pt
\caption{Summarization of different attacks}
\begin{tabular}{cccccccc}
\toprule
\textbf{Attack} & BadNets & Dynamic & Reflection(3) & SIG(3) & Invisible & WaNet & Gotham \\
\toprule
\textbf{Cluster} & P(binm) & P(binm) & P(cnst) & P(cnst) & T(cmplx) & T(cmplx) & T(smpl) \\
\midrule
\textbf{ASR} & 1.00 & 1.00 & 0.98 & 0.94 & 0.97 & 0.91 & 1.00 \\
\bottomrule
\end{tabular}
\label{tab:trigger_type}
\end{table}
\subsection{Adaptive Attack} \label{sec:adaptive}
We study three attack scenarios where the adversary has the knowledge of {{\sc Beagle}{}}{}.
Our results show that {{\sc Beagle}{}}{} does not have performance degradation in most cases. For those that it does degrade, the adaptive attack is not effective. Details can be found in the supplementary document Section D~\cite{beagle}.
\subsection{Ablation Study} \label{sec:ablation}
This section studies different design choices of {{\sc Beagle}{}}{} in attack sample decomposition and scanner synthesis. The results show that {{\sc Beagle}{}}{} has a robust design. Details can be found in the supplementary document Section E~\cite{beagle}.
\section{Introduction} \label{sec:intro}
Deep Learning (DL) backdoor attacks~\cite{badnet,trojnn} leverage vulnerabilities in pre-trained models such that inputs stamped with a specific (small) input pattern (e.g., a polygon patch) or undergone some fixed transformation (e.g., applying a filter) induce intended model misbehaviors, such as misclassification to a {\em target label}. The misbehavior-inducing input patterns/transformations are called {\em backdoor triggers}. The vulnerabilities are usually injected through various data poisoning methods~\cite{dynamic,inputaware,composite,blend,invisible,wanet,saha2020hidden}. Some even naturally exist in normally trained models~\cite{moth,deck}.
The attack model of DL backdoors becomes increasingly similar to that of traditional cyber attacks (on software), and in the meantime DL models have more and more applications in critical tasks such as autonomous driving and ID recognition (for access control).
Defending model backdoors hence becomes a pressing need. Figure~\ref{fig:trad_attack} shows the traditional cyber attack model. Vulnerabilities exist in applications (e.g., due to implementation bugs).
The adversary exploits a vulnerability by crafting a special input, e.g., an extremely long input to exploit a buffer overflow vulnerability.
The exploit could lead to a wide range of damage (e.g., hijacking a system, leaking information, and corrupting services).
The adversary has no control of the execution environment of application on the user side (the dotted box in Figure~\ref{fig:trad_attack}).
He can only manipulate the input to achieve his goal. Many inputs can be easily crafted to exploit the same vulnerability. And vulnerabilities can be patched by fixing bugs.
\begin{figure}[t]
\centering
\begin{tabular}{lcr}
\begin{minipage}[b]{.133\textwidth}
\includegraphics[height=45mm]{figures/traditional_attack.pdf}
\captionsetup{width=1.2\textwidth}
\caption{Cyber attack}
\label{fig:trad_attack}
\end{minipage}
&&
\begin{minipage}[b]{.337\textwidth}
\includegraphics[height=45mm]{figures/traditional_forensic.pdf}
\caption{Forensics}
\label{fig:trad_forensic}
\end{minipage}
\end{tabular}
\end{figure}
Analogously in DL backdoor attacks, vulnerabilities are model properties such that (any) inputs can be transformed in a specific way to exploit them. The process of crafting inputs does not require access to model execution (on the user side). The input crafting efforts are minimal as triggers are known by the adversary beforehand (because he injected them). In contrast, traditional adversarial attack~\cite{carlini2017towards,madry2018towards,brendel2018decision} usually requires much more computing efforts to generate exploit perturbations. Some even do that on-the-fly.
Moreover, backdoors can be effectively removed by model hardening with negligible model accuracy degradation~\cite{li2021neural,wu2021adversarial,liu2018fine,zhao2020bridging}. Model misbehaviors can have a lot of downstream ramifications. For example, misclassifying a stop sign to something else could have catastrophic consequences in an auto-driving system.
Forensics~\cite{mpi,nodoze,clarion,omega,alchemist} is an important countermeasure for traditional cyber attacks. As shown in Figure~\ref{fig:trad_forensic}, given attack instances (including the application and a small set of exploit inputs), forensics techniques aim to identify their root causes (e.g., the bug), assess damage, and provide critical information to build vulnerability/malware scanners to identify similar attack instances and similar bugs.
They also greatly facilitate attack prevention and program repair~\cite{liu2019tbar, nguyen2013semfix, le2012systematic, wen2018context}.
Due to the similarity of DL backdoor attacks and traditional
cyber attacks, we argue that forensics is an important step in
fighting against DL backdoor attacks as well.
There are existing efforts in detecting inputs that contain backdoor triggers~\cite{februus,huang2020one} and recognizing, cleansing poisonous inputs from training data using evidence collected from a few attack instances~\cite{strip,chen2018detecting}. The former aims to decide if a given input contains any backdoor trigger. Existing techniques usually leverage the observation that such inputs manifest themselves by having out-of-distribution values in the input or feature space~\cite{tran2018spectral,februus}.
The latter searches for a subset of training samples such that training on the subset reduces the {\em attack success rate} (ASR) to almost 0 without causing model accuracy degradation.
\textit{Februus}~\cite{februus} aims to cleanse individual trojaned inputs by removing stamped triggers. It first identifies the trigger in a given input using GradCAM~\cite{gradcam} based on the assumption that the classification output is dominated by the trigger area. It then removes the entire trigger area and uses GAN to fill in the space.
These existing works focus on specific sub-problems in forensics, inspiring a more comprehensive forensics workflow.
For example, backdoor input detection techniques can be used to capture attack instances for downstream forensics analysis.
In this work, we propose a novel DL backdoor forensics method {{\sc Beagle}{}}{} ({\it Forensics of
\underline{\sc B}ackdoor attack on deep l\underline{\sc EA}rnin\underline{\sc G} mode\underline{\sc L}s for better defens\underline{\sc E}}). Given a few attack instances, each including the model and a few inputs likely containing backdoor triggers, {{\sc Beagle}{}}{} automatically decomposes each trojaned input to a clean input and a trigger. The trigger could be a patch-like input pattern or an input space transformation function. The decomposed clean input should closely resemble the original clean input (which is unknown to {{\sc Beagle}{}}{}), and the decomposed trigger should be very similar to the injected trigger (which is also unknown to {{\sc Beagle}{}}{}). The decomposed trigger will be able to flip a large set of clean inputs to the same target label, if applied.
This is analogous to the root cause analysis stage in traditional cyber attack fornensics.
More importantly, {{\sc Beagle}{}}{} will automatically cluster these attack instances leveraging the decomposition results such that each cluster denotes a specific type of backdoor. It further summarizes each cluster to a set of distributions, and automatically synthesizes a corresponding scanner to find the same type of backdoor {\em in other models}.
Note that the instantiations of a type of backdoor on different models are largely different. For example, different patch attack instances (on different models) may have different patch shapes, sizes, pixel patterns, and different positions to stamp the patches. It is unlikely
that we can detect other instances of the same type of attack by simply stamping the raw decomposed triggers produced by the forensics analysis. Instead, {{\sc Beagle}{}}{} abstracts the given instances such that other instantiations can be detected. This is analogous to building vulnerability and malware detection tools based on forensics results in traditional cyber security.
Our method formulates the attack decomposition step as a cyclic optimization problem. At the beginning, the decomposed clean input and the decomposed trigger are of very low quality, for instance, some random disintegration of the trojaned input. The cyclic optimization ensures that any improvement on the decomposed clean input leads to improvement of the decomposed trigger, and vice versa. High quality decomposition can be achieved when the process converges.
We formulate backdoor attacks in two mathematical forms: {\em patching attacks} that induce localized input perturbations and {\em transforming attacks} that induce pervasive perturbations. As such, the existing wide range of different attacks can be modeled by different coefficient distributions for the mathematical forms, allowing us to achieve automatic categorization.
The formulas and their coefficient distributions are then used to synthesize loss functions for scanners.
A scanner determines if a model contains any backdoor, without requiring any trojaned inputs, analogous to a traditional malware/vulnerability scanner, which scans without (exploit) inputs.
Given a model to scan, the synthesized loss functions are used to invert a backdoor trigger for the model. If such inversion succeeds, the model is considered trojaned.
The inversion process essentially generates small input perturbation patterns or transformation functions by gradient descent based on the synthesized loss functions such that the generated perturbation/transformation (i.e., trigger) can induce model misclassification.
Our contributions are summarized in the following.
\begin{itemize}
\item We propose a novel model backdoor attack forensics technique that contains automatic attack root cause analysis, attack summarization, and scanner synthesis.
\item Our root cause analysis features a new cyclic optimization pipeline that can decompose a trojaned input to its clean version and the trigger.
\item We propose to formulate existing attacks using two mathematical forms such that different attacks become different distributions of coefficients of the two forms, enabling automatic attack categorization, and scanner synthesis.
\item We evaluate our prototype {{\sc Beagle}{}}{} on 10 popular backdoor attacks, including BadNets~\cite{badnet}, TrojNN~\cite{trojnn}, Dynamic~\cite{dynamic}, Reflection~\cite{reflection}, SIG~\cite{sig}, Blend~\cite{blend}, Invisible~\cite{invisible}, WaNet~\cite{wanet}, Instagram filter~\cite{ABS}, DFST~\cite{dfst}, and on 2,532 pre-trained models. We demonstrate the benefits of forensics analysis by enhancing five existing backdoor scanning techniques and comparing with an existing trojaned input decomposition method.
Our results show that existing scanners have substantial performance degradation when they are used to scan attacks that they are not designed for (e.g., from over 0.9 scanning accuracy down to lower than 0.55), whereas the scanners synthesized by {{\sc Beagle}{}}{} can achieve 0.9 detection accuracy for all these attacks, when only 10 trojaned input instances are assumed for each attack during forensics and the models under scanning are completely different from the ones used in forensics.
We also show that {{\sc Beagle}{}}{} can even improve existing scanners' performance on their targeted attacks by 9\%-27\% because although they are fined-tuned for the targeted attacks, the fine-tunings were done manually by their original developers, whereas {{\sc Beagle}{}}{} automatically synthesizes scanners.
Our experiments also show that the trojaned input decomposition produces high-quality results. The decomposed clean images are 22\% more similar to the ground truth than a baseline method Februus~\cite{februus}. And 100\% of them are correctly classified by the models, compared to 38\% by the baseline. Our decomposed triggers achieve 96\% ASR whereas those by the baseline can only achieve 45\%.
Our ablation study, sensitivity study, and adaptive attack show that {{\sc Beagle}{}}{} has a robust design.
\end{itemize}
\smallskip
\noindent
{\bf Threat Model.} Our threat model is similar to that in data poisoning~\cite{badnet,trojnn,blend,reflection,wanet}, in which the adversary has access to (and even own) the training dataset. Hence, we do not focus on cleansing the training data. Instead, we focus on the following scenario.
Users observe a few unusual misclassifications (through manual inspection or using trojaned input detection tools).
For example, when there is a new type of backdoor attack, the attackers may use it to attack many models (just like buffer-overflow is leveraged to attack many software applications). We assume some attacker exploits one of these vulnerable models and the attack samples are detected and saved for forensics (analogous to the first time a buffer-overflow exploit is detected). These samples, together with the model, are submitted to security analysts that are equipped with {{\sc Beagle}{}}.
In the meantime, the users provide a small set of clean inputs (e.g., 100 per model) to facilitate the process, which is consistent with the literature~\cite{nc,Tabor,dltnd,guo2020towards,huang2019neuroninspect}. Besides the information provided by the users, the analysts also have GANs representing input distributions. This is a reasonable assumption (consistent with the literature~\cite{goodfellow2014generative,brock2018large,karras2019style}) as models used in real world applications follow physical world distributions and there are high quality pre-trained GANs representing such distributions. The analysts use {{\sc Beagle}{}}{} to analyze and summarize the reported attacks and automatically construct scanners (analogous to synthesizing a buffer overflow bug detector) that can scan other models to find other instances of the same type of attack (e.g., patch attack). These scanners can be used by any user on any model. Note that the same type of backdoor may have largely different instantiations on different models.
One cannot directly determine if an unknown model has a similar backdoor by directly stamping the decomposed trigger by {{\sc Beagle}{}}{}. It is possible that the adversary injects backdoors that flip class A samples to class B, and the two classes are very similar in humans' eyes such that attack instances cannot be correctly recognized in the first place. Although it is debatable whether injecting backdoors in these classes can benefit the adverary as their decision bounday is already confusing, dealing with such attacks is beyond the scope of our paper.
A model may have multiple injected backdoors. We assume all the trojaned inputs in an attack instance (used in forensics) are exploiting the same backdoor.
\section{Limitation} \label{sec:limitation}
\input{tables/transfer.tex}
One limitation of {{\sc Beagle}{}}{} is lack of transferability.
The goal of BEAGLE is to synthesize scanners based on seen attack instances and detect attacks of the same type, with which existing scanners have difficulties.
BEAGLE is likely ineffective if a new attack is categorically quite different from those it has seen.
We conduct an experiment to evaluate the transferability of {{\sc Beagle}{}}{} in Table~\ref{tab:transfer}, which shows a limitation of {{\sc Beagle}{}}{} mentioned in Section~\ref{sec:limitation}.
We leverage two scanners synthesized based on patch and filter attack samples in Section~\ref{sec:scan}, and evaluate on 20 trojaned models by WaNet mixed with 20 clean models. The patch scanner achieves 50\% accuracy and the filter scanner achieves 53\%, much lower than BEAGLE's WaNet scanner that achieves 93\% accuracy.
Scanning attacks of unseen categories is a hard challenge and we will leave this as the future work.
\section*{Acknowledgements}
We thank the anonymous reviewers for their constructive comments. This research was supported, in part by IARPA TrojAI W911NF-19-S-0012, NSF 1901242 and 1910300, ONR N000141712045, N000141410468 and N000141712947. Any opinions, findings, and conclusions in this paper are those of the authors only and do not necessarily reflect the views of our sponsors.
\bibliographystyle{IEEEtranS}
\section{Motivation} \label{sec:motivation}
\begin{figure}[t]
\centering
\begin{subfigure}{.1\textwidth}
\includegraphics[width=1.0\textwidth]{figures/trojai_demo/victim.png}
\caption{Victim}
\end{subfigure}
%
\begin{subfigure}{.1\textwidth}
\includegraphics[width=1.0\textwidth]{figures/trojai_demo/polygon.png}
\caption{Trojaned}
\end{subfigure}
%
\begin{subfigure}{.1\textwidth}
\includegraphics[width=1.0\textwidth]{figures/trojai_demo/target.png}
\caption{Target}
\end{subfigure}
%
\begin{subfigure}{.1\textwidth}
\includegraphics[width=1.0\textwidth]{figures/trojai_demo/nashille.png}
\caption{Nashville}
\end{subfigure}
\begin{subfigure}{.1\textwidth}
\includegraphics[width=1.0\textwidth]{figures/trojai_demo/lomo.png}
\caption{Lomo}
\end{subfigure}
%
\begin{subfigure}{.1\textwidth}
\includegraphics[width=1.0\textwidth]{figures/trojai_demo/kelvin.png}
\caption{Kelvin}
\end{subfigure}
%
\begin{subfigure}{.1\textwidth}
\includegraphics[width=1.0\textwidth]{figures/trojai_demo/gotham.png}
\caption{Gotham}
\end{subfigure}
%
\begin{subfigure}{.1\textwidth}
\includegraphics[width=1.0\textwidth]{figures/trojai_demo/toaster.png}
\caption{Toaster}
\end{subfigure}
\caption{Examples of different attacks in TrojAI
}
\label{fig:troj_exp}
\end{figure}
We use a number of attacks to illustrate that backdoor scanning using trigger inversion becomes ineffective if attack specifics are unknown, in order to motivate backdoor forensics.
\noindent
{\bf Trigger Inversion (Background).}
Trigger inversion is an effective method in backdoor scanning.
Readers familiar with such techniques can skip this subject. Given a model and a few clean images, trigger inversion uses optimization to identify universal input perturbations that can flip the classification results of the clean images to a target class. In Neural Cleanse (NC)~\cite{nc}, the optimization aims to generate two vectors, a perturbation vector and a mask vector. The former describes value changes for individual pixels and the latter (i.e., values in a range of [0,1]) describes if the changes should be applied and how much is applied. For instance, a value 1.0 in the mask vector means the corresponding pixel is fully replaced by the value in the perturbation vector, a value 0 means that the pixel in the original input is intact, and a value in (0,1) means that the resulted pixel is a mix of the original and the perturbation. Trigger inversion is hence described as the following optimization problem.
\vspace{-2pt}
\begin{equation}
\label{eq:inversion}
\argmin_{m,\; t}\;\;\; \mathcal{L}(M((1 - m) \cdot x + m \cdot t), y_{t}) + \sigma \cdot \sum m, \vspace{-3pt}
\end{equation}
\noindent where $m$ denotes the mask vector and $t$ the perturbation vector. $M$ is the model, and $y_{t}$ a (potential) target label.
The loss function consists of two terms, the cross entropy loss and the regularization loss.
The cross entropy loss ($\mathcal{L}$) aims to achieve a high attack success rate (ASR) while the regularization loss aims to reduce the mask size. Coefficient
$\sigma$ controls the trade-off of the two.
At the beginning, $\sigma$ is small to ensure a high ASR of the inverted pattern. Then NC gradually increases $\sigma$ to find a small trigger.
NC decides that a model is trojaned if an exceptionally small trigger (whose size can be computed from the mask) is found for some target label to achieve a high ASR.
ABS~\cite{ABS} further enhances NC by adding a term to the loss function that aims to achieve large activation values for a few neurons that are determined to be compromised by the backdoor through an offline analysis. There are other trigger inversion techniques such as K-Arm~\cite{karm}, Tabor~\cite{Tabor}, DLTND~\cite{dltnd}, and DualTanh~\cite{tao2022better}.
They differ from each other by having different loss function designs (for the specific attacks they focus on).
While they are all highly effective for the attacks they tackle,
{\em they usually require the knowledge of attack specifics for crafting the corresponding loss functions and selecting the proper hyper parameters.}
In the following, we show that inversion techniques effective for an attack may not be effective for another attack.
\begin{figure}[t]
\centering
\begin{subfigure}{.13\textwidth}
\centering
\includegraphics[width=0.8\textwidth]{figures/trojai_demo/victim.png}
\caption{Victim}
\end{subfigure}
%
\begin{subfigure}{.13\textwidth}
\centering
\includegraphics[width=0.8\textwidth]{figures/trojai_demo/NC_invert.png}
\caption{Inverted by NC}\label{fig:inverted_NC}
\end{subfigure}
%
\begin{subfigure}{.13\textwidth}
\centering
\includegraphics[width=0.8\textwidth]{figures/trojai_demo/polygon.png}
\caption{Ground-truth}
\label{fig:groundtruth}
\end{subfigure}
\caption{NC inversion of a universal polygon backdoor}
\label{fig:NC_polygon}
\end{figure}
\begin{figure}[t]
\centering
\begin{subfigure}[t]{0.11\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/complex/victim.pdf}
\caption{Victim}
\end{subfigure}
\begin{subfigure}[t]{.11\textwidth}
\includegraphics[width=1.0\textwidth]{figures/complex/wanet.pdf}
\caption{Trojaned}
\end{subfigure}
%
\begin{subfigure}[t]{.11\textwidth}
\includegraphics[width=1.0\textwidth]{figures/complex/NC.pdf}
\captionsetup{font=footnotesize}
\caption{Victim + NC trigger}
\end{subfigure}
%
\begin{subfigure}[t]{.11\textwidth}
\includegraphics[width=1.0\textwidth]{figures/complex/ABS.pdf}
\captionsetup{font=footnotesize}
\caption{Victim + ABS-filter trigger
}
\end{subfigure}
\begin{subfigure}[t]{0.11\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/complex/target.pdf}
\caption{Target}
\end{subfigure}
\begin{subfigure}[t]{.11\textwidth}
\includegraphics[width=1.0\textwidth]{figures/complex/wanet_diff.pdf}
\caption{$|$(b)-(a)$|$}
\end{subfigure}
%
\begin{subfigure}[t]{.11\textwidth}
\includegraphics[width=1.0\textwidth]{figures/complex/NC_diff.pdf}
\caption{$|$(c)-(a)$|$}
\end{subfigure}
%
\begin{subfigure}[t]{.11\textwidth}
\includegraphics[width=1.0\textwidth]{figures/complex/ABS_diff.pdf}
\caption{$|$(d)-(a)$|$}
\end{subfigure}
\caption{WaNet backdoor and its scanning results}
\label{fig:complex}
\end{figure}
\noindent
{\bf Attacks.}
To demonstrate the challenge, we use the attacks in the computer vision rounds of TrojAI and additionally the WaNet attack~\cite{wanet} representing complex backdoors whose triggers are hardly human perceptible.
TrojAI is an ongoing multi-year and multi-round backdoor scanning competition for Deep Learning models, organized by IARPA~\cite{trojai}. It has finished nine rounds by the time of submission, with rounds 1-4 for CV models and rounds 5-9 for NLP models.
In each round, benign models (e.g., 500) are mixed with trojaned models (e.g., 500) and the performer is supposed to detect the trojaned ones. A cross-entropy loss lower than 0.348 (usually corresponding to 0.91 accuracy) is considered reaching the round target.
It has 3 different types of attacks in the CV rounds.
The first type is the simple universal patch attack similar to BadNet~\cite{badnet}, nin which triggers are usually small polygons with solid colors.
Figure~\ref{fig:troj_exp} (a) and (b) show a clean image of speed limit sign and its trojaned version which is classified to a lock sign in (c). TrojAI models are mostly models classifying traffic signs. An input image is synthesized by placing an artificial traffic sign on a real-world street-view background image.
Different models are trained with different sets of signs and images. The images have a high resolution 224$\times$224.
The second type is label-specific patch attack that only flips images of the victim class to the target class.
The third type is Instagram filter attack, in which the trigger is an Instagram filter (e.g., Nashville filter as shown in Figure~\ref{fig:troj_exp} (d)). There are also Lomo (e), Kelvin (f), Gotham (g), and Toaster (h)
filters.
Observe that compared to patch attacks, filter attacks are pervasive; different filters also have different visual effects.
Figure~\ref{fig:complex} shows a VGG16 model~\cite{vgg16} trained on ImageNet trojaned by WaNet~\cite{wanet}.
WaNet uses a small and smooth warping field (that twists lines) to inject backdoor triggers, making the modification unnoticeable.
Figure (a) presents a victim image and figure (b) shows the trojaned version (classified to tench in figure (e)). It is hard for humans to tell the difference between the two images. We highlight the difference ($\times 3$) in figure (f).
Observe that the perturbations are camouflaging themselves along object outlines.
\input{tables/moti_NC_ABS_trojai}
\noindent
{\bf Trigger Inversion Effective for One Attack May Not Be Effective for Another.}
For each of the aforementioned attacks, we mix 20 trojaned models with 20 benign models and apply different scanners.
The first row of Table~\ref{tab:moti_nc_abs} shows the results of the original NC (for the different attacks).
Observe that it only works well for the universal patch attack, achieving 0.88 detection accuracy.
Figure~\ref{fig:NC_polygon} (b) shows the inverted trigger for the universal attack in Figure~\ref{fig:troj_exp} (b). Observe that it is very similar to the ground-truth trigger, explaining its effectiveness. However, the inverted triggers for other attacks are largely dissimilar to the ground truths, demonstrating that the loss function design and/or the hyper parameters are not suitable for those attacks.
The second row of Table~\ref{tab:moti_nc_abs} shows the results of the original ABS.
It works well for the universal patch attack and the label specific attack. This is because it scans each label pair.
ABS has special support for filter type of triggers. Specifically, it models filter as a linear transformation layer. Instead of inverting the perturbation and the mask vectors, it inverts the coefficients of the linear transformation.
However, different filters have different effects, which may not be universally represented by the same linear template. The third row of Table~\ref{tab:moti_nc_abs} shows the results of ABS-filter. Observe that it works well for the Nashville filter, which is a filter that simply changes values in a channel and hence can be modeled by a linear function.
In contrast, with the filter setting, ABS cannot detect patch backdoors.
None of these three scanners can handle the complex WaNet backdoor.
Figure~\ref{fig:complex} (g) shows the inverted trigger by NC for the model with the WaNet backdoor and (c) shows the input after applying the trigger.
Observe that they are quite different from the ground truth. The trigger is so large that it is not distinguishable from large natural features in the target class which can flip the classification result (e.g., stamping a cat to any image likely flips that image to the cat class). As such, NC does not consider the model trojaned.
Figure (d) shows the image after applying the trigger filter inverted by ABS-filter and figure (h) shows the pixel level differences.
The inverted trigger has only 0.2 ASR such that ABS-filter does not consider the model trojaned.
Other trigger inversion based scanners such as~\cite{karm, liu2021ex, Tabor, dltnd, huang2019neuroninspect, guo2020towards} have similar problems, as shown in Section~\ref{sec:scan}.
A common strategy used by these scanners is to have a specially designed loss function and parameter setting for each attack and tries them one by one. A model is considered trojaned if any of the setting yields an effective trigger~\cite{trojai,karm,ABS,liu2021ex,zheng2021topological,kiourti2021online,zhang2021tad,sri}.
Such a strategy is valid only if attack specifics are known beforehand. {\bf In the finished TrojAI rounds, the attack details are given before each round of competition~\cite{trojai}, such as trigger size range, type of triggers, the possible locations they are stamped, etc. However, this assumption may not hold in real-world zero-day attacks}.
\begin{figure}[t]
\centering
\begin{minipage}[t]{.23\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/landscape_origin.pdf}
\caption*{(a) Landscape of cross entropy}
\end{minipage}
\begin{minipage}[t]{.23\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/landscape_forensic.pdf}
\caption*{(b) Landscape with synthesized loss term}
\end{minipage}
\caption{Inversion loss landscape illustration with (a) the landscape of cross entropy and (b) the landscape with the additional synthesized loss term.
The $x$-$y$ plane denotes an input feature space and the $z$ axis the loss value.
The areas with the red plummets represent the input areas of the target class.
In (a), the large plummet denotes the clean target samples and the small one the victim samples with the trigger. The blue areas denote the clean victim samples.}
\label{fig:landscape}
\end{figure}
\begin{figure*}[h]
\centering
\begin{minipage}{.32\textwidth}
\centering
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/polygon_exp/poison_0.png}
\includegraphics[width=1.0\textwidth]{figures/polygon_exp/poison_1.png}
\caption*{(a) Trojaned}
\end{minipage}
%
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/polygon_exp/clean_0.png}
\includegraphics[width=1.0\textwidth]{figures/polygon_exp/clean_1.png}
\caption*{(b) Clean}
\end{minipage}
%
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/polygon_exp/trigger_0.png}
\includegraphics[width=1.0\textwidth]{figures/polygon_exp/trigger_1.png}
\caption*{(c) Trigger}
\end{minipage}
%
\caption*{(A) Forensics of patch attack}
\end{minipage}
%
\begin{minipage}{.32\textwidth}
\centering
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/filter_exp/poison_0.png}
\includegraphics[width=1.0\textwidth]{figures/filter_exp/poison_1.png}
\caption*{(d) Trojaned}
\end{minipage}
%
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/filter_exp/clean_0.png}
\includegraphics[width=1.0\textwidth]{figures/filter_exp/clean_1.png}
\caption*{(e) Clean}
\end{minipage}
%
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/filter_exp/trigger_0.png}
\includegraphics[width=1.0\textwidth]{figures/filter_exp/trigger_1.png}
\caption*{(f) Trigger}
\end{minipage}
%
\caption*{(B) Forensics of pervasive attack}
\end{minipage}
%
\begin{minipage}{.32\textwidth}
\centering
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/complex_exp/poison_0.png}
\includegraphics[width=1.0\textwidth]{figures/complex_exp/poison_1.png}
\caption*{(g) Trojaned}
\end{minipage}
%
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/complex_exp/clean_0.png}
\includegraphics[width=1.0\textwidth]{figures/complex_exp/clean_1.png}
\caption*{(h) Clean}
\end{minipage}
%
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figures/complex_exp/trigger_0.png}
\includegraphics[width=1.0\textwidth]{figures/complex_exp/trigger_1.png}
\caption*{(i) Trigger}
\end{minipage}
%
\caption*{(C) Forensics of WaNet attack}
\end{minipage}
\caption{Forensics of different attacks}
\label{fig:moti_forensic}
\end{figure*}
\noindent
{\bf Our Solution - Attack Forensics.}
The main challenge is that different attacks compromise different parts of input space. Such subspaces may be very small. Trigger inversion is largely driven by the gradients of the cross-entropy loss function. When the compromised subspaces are small and isolated, starting from the clean input space, the gradients may not be able to provide valid directions to the compromised subspaces.
{\em The overarching idea of our solution is to leverage attack forensics to reverse engineer attack specifics from a few attack instances (e.g., a few inputs with triggers causing misclassification), such as what the trigger looks like and how it is injected. Additional loss terms can be synthesized based on the specifics to change the landscape of the loss function such that gradients (of the new loss) can guide trigger inversion to the compromised subspace.}
Figure~\ref{fig:landscape} illustrates the concept.
It shows the landscapes of two inversion loss functions with the $x$-$y$ plane denoting input features (e.g., encodings by some feature extraction model) and $z$ the loss value. The left one is for the cross-entropy loss term in Eq.~\ref{eq:inversion} and the right one is for the synthesized loss term by {{\sc Beagle}{}}.
Observe that when cross-entropy is used, from a clean sample $x$ in the blue area in (a), it is very difficult to find the universal perturbation (i.e., the trigger) that can move the sample to the small red area due to the rugged landscape. The gradients point to the larger red area instead.
In (b), by performing forensics on a few given attack samples $x_1\oplus t$, $x_2 \oplus t$, and $x_3 \oplus t$, a new loss term is synthesized that changes the loss landscape.
Specifically, {{\sc Beagle}{}}{} can reverse engineer $x_1$, $x_2$, and $x_3$, from the attack instances $x_1\oplus t$, $x_2 \oplus t$, and $x_3 \oplus t$.
Our synthesized loss term hence aims to have a very small loss value for
$x_1\oplus t$, $x_2 \oplus t$, and $x_3 \oplus t$, much smaller than the loss values for clean target samples (i.e., those in the larger red area in (a)), making their area the optimization goal.
Furthermore, the loss is synthesized in such a way that it ensures the gradients at the reverse engineered $x_1$, $x_2$, and $x_3$
pointing to the target area.
As such when scanning a {\em different} model for the similar type of backdoor, the new loss term can provide clear direction to find the trigger $t$.
Figure~\ref{fig:moti_forensic} (A) shows the forensics of a patch attack in TrojAI. From left to right, starting from two images stamped with the triggers (at different places), that is, attack instances, our technique decomposes them to the clean images and the triggers. Note that the original clean images are unknown.
From the decomposed instances, the attack can be summarized as distributions of trigger position, size, and pixel values (inside the trigger area).
A loss function is automatically synthesized using these distributions to detect backdoors of the same type.
Figure~\ref{fig:moti_forensic} (B) shows the forensics of pervasive attacks.
From left to right, starting from a few attack instances, our technique decomposes each to a clean image and a transformation function $\mathcal{F}$ over the clean image $x$. Note that the image to the right of the clean image denotes $\mathcal{F}(x)$.
The attack can be summarized as coefficient distributions of the transformation function.
As such, a scanner again can be synthesized to detect this kind of attacks.
Figure~\ref{fig:moti_forensic} (C) shows the forensics of WaNet attacks.
We will show in Section~\ref{sec:visual} that the decomposed clean images closely resemble the ground-truth clean images and the decomposed triggers resemble the ground-truth triggers as well.
The last row of Table~\ref{tab:moti_nc_abs} shows the scanning results using scanners automatically synthesized by {{\sc Beagle}{}}.
Here, we use 3 trojaned models for each type of attack in forensics.
They are disjoint from the ones used in the scanning evaluation.
Observe that the scanners can now accurately detect the trojaned models.
In addition, directly using triggers reverse engineered by {{\sc Beagle}{}}{} to determine if a model has similar backdoors is ineffective (due to different models have unique instantiations), as shown in row 4 of Table~\ref{tab:moti_nc_abs}.
\section{Related Work}
\smallskip
\noindent
\textbf{Backdoor Attack.}
There are a large number of existing backdoor attacks.
Some attach small patches/watermarks~\cite{badnet, trojnn, dynamic, inputaware, saha2020hidden, tao2022backdoor} as the trigger. Some blend the input image with another image~\cite{blend, sig, reflection, composite}. Others leverage an input transformation function to directly inject the trigger into the input image~\cite{invisible, wanet, dfst}.
\smallskip
\noindent
\textbf{Backdoor Defense.} Backdoor detection aims to determine whether a model is trojaned~\cite{kolouri2020universal,xu2019detecting,qiao2019defending,guo2020towards,huang2019neuroninspect}.
Scanners such as TABOR~\cite{guo2020towards} are based on NC and inherit similar limitations.
Some leverage NC's method to invert a trigger~\cite{karm}, and others use more complex input transformation function~\cite{ABS,liu2021ex}.
We have discussed and enhanced both techniques.
Another type of defenses focuses on detecting poisoned data instead of models~\cite{ma2019nic,tang2019demon,strip,chen2018detecting,li2020rethinking,liu2017neural,chou2020sentinet,tran2018spectral,fu2020detecting,chan2019poison,du2019robust,veldanda2020nnoculation}.
AC~\cite{chen2018detecting} and STRIP~\cite{strip}.
There are also backdoor elimination~\cite{liu2018fine,borgnia2020strong,zeng2020deepsweep,li2021neural,deck,zhang2022flip} and certified robustness against backdoors~\cite{mccoyd2020minority,xiang2021patchguard,xiang2021patchcleanser,jia2020certified}.
\smallskip
\noindent
\textbf{Traceback of data-poisoning attack.}
Researchers have proposed a traceback technique on data-poisoning attack~\cite{traceback}. It mainly focuses on separating trojaned data from clean data given the whole training dataset. Its goal is different from ours.
\section{Supplementary Document}
\subsection{More Results on Validating Decomposed Clean Inputs and Triggers}
\label{sec:append_decomp}
\input{tables/input_purification}
We provide additional results in Table~\ref{tab:decomposition} to validate decomposed clean inputs and triggers in Section~\ref{sec:decomposition}.
The first column denotes the dataset, the second column the network structure, and the third column the backdoor attack type.
There are two large column blocks, presenting the decomposition results of clean inputs and triggers, respectively.
In each block, we show the $L^1$ distance, PSNR, SSIM, and ACC/ASR. For $L^1$, PSNR, and SSIM, the first column denotes the difference between trojaned images and their clean counterparts. The second column shows the difference between original clean images and decomposed images by Februus (Fb) and the third column the difference by {{\sc Beagle}{}}{} (Bg).
Each entry presents the average value for the given 10 trojaned images and 100 additional clean test images.
For ACC/ASR, the first column is for Februus and the second for ${{\sc Beagle}{}}{}$. Each entry in the ACC columns denotes the average clean accuracy for the decomposed clean images from the given 10 trojaned samples. As the 100 validation clean images have been used in optimization, we use the images from the test set and stamp the decomposed trigger to calculate the ASR.
The last row in Table~\ref{tab:decomposition} shows the average results. Better results between Februus and {{\sc Beagle}{}}{} are highlighted with the bold font.
\smallskip
\noindent
\textbf{Validating Decomposed Triggers Across Datasets/Models.}
In the previous experiments, the triggers are decomposed and validated on the same dataset and model. {{\sc Beagle}{}}{} can effectively extract the trigger with high visual quality and classification accuracy.
In real-world scenarios, the trojaned model and its dataset that are available for forensics might be different from the subject model/dataset. Here, we study the performance of {{\sc Beagle}{}}{} in decomposing triggers across different datasets and model architectures.
Particularly, we use the same injected trigger to poison a VGG-11 model on CIFAR-10 and a ResNet-18 model on GTSRB. We apply {{\sc Beagle}{}}{} to extract the trigger from the trojaned VGG-11 model and then test it on the ResNet-18 (CV-GR) and vice versa.
Figure~\ref{fig:diff_dataset} shows the results. The x-axis denotes the different backdoor attacks, and the y-axis the ASR of the decomposed trigger on the other model. Observe that almost all the ASRs are high for 10 different attacks, meaning the decomposed triggers are highly effective even when applied on a different dataset/model. This demonstrates the decomposition of {{\sc Beagle}{}}{} is general and does not overfit on specific datasets/models.
\begin{figure}[h]
\centering
\begin{minipage}[t]{.3\textwidth}
\includegraphics[width=0.9\textwidth]{figures/diff_dataset.pdf}
\captionsetup{width=0.8\textwidth}
\caption{Validation on decomposed triggers across datasets/models}
\label{fig:diff_dataset}
\end{minipage}\kern-0.2em
\begin{minipage}[t]{.20\textwidth}
\includegraphics[width=.9\textwidth]{figures/trojai_auto_type.pdf}
\captionsetup{width=0.85\textwidth}
\caption{Summarization of different attacks in TrojAI}
\label{fig:auto_trigger_type_trojai}
\end{minipage}
\end{figure}
\subsection{More Results of Evaluation on Attack Clustering and Summarization}
\label{sec:appendix_summary}
In Section~\ref{sec:summarize}, we evaluate {{\sc Beagle}{}}{}'s attack clustering and summarization performance on CIFAR-10 for seven backdoor attacks.
Here, we evaluate on TrojAI rounds 2 and 3. Specifically, we randomly sample 50 trojaned models (out of 1000 total) that are injected with polygon or (one of the 5 types of) filter triggers and apply {{\sc Beagle}{}}{} to identify the attack types. We conduct the experiment for five times (trials) and report the results in Figure~\ref{fig:auto_trigger_type_trojai}. The x-axis denotes the trial ID and the y-axis the accuracy of correctly identifying the attack type. Observe that the recognition accuracies are nearly 100\% for both rounds across the five random trials. We make use of four well-known clustering methods: (1) K-means~\cite{kmeans} equipped with Silhouette Score~\cite{silhouette}, abbreviated as K-means-S; (2) K-means~\cite{kmeans} equipped with Elbow method~\cite{elbow}, abbreviated as K-means-E; (3) Gaussian Mixture Model (GMM)~\cite{gmm} equipped with Silhouette Score~\cite{silhouette}, abbreviated as GMM-S; and (4) DBSCAN~\cite{dbscan}.
Since K-means and GMM require to pre-set the number of clusters, we test different numbers of clusters, and leverage the Silhouette Score and Elbow methods to determine the optimal number (with the highest score). DBSCAN can automatically determine the optimal number of clusters. Their clustering results have negligible differences (all having 4-6 clusters). The downstream synthesized scanners have similar performance too (see Table~\ref{tab:diff_cluster}).
\subsection{Impact of Attack Sample Bias} \label{sec:sample_appendix}
As {{\sc Beagle}{}}{} leverages a small set of inputs (clean and trojaned) and trojaned models, we study the impact of sampling biases in such data. For sampled inputs, we include a few naturally misclassified inputs without any injected backdoors. This simulates the real world scenario where classification models do not usually achieve 100\% accuracy. For sampled models, we intentionally introduce biases to the number of trojaned models with different attack types.
\begin{figure}[t]
\centering
\includegraphics[height=38mm]{figures/num_mis_stdx5.pdf}
\caption{Impact of including naturally miclassified images}
\label{fig:num_mis}
\end{figure}
\smallskip \noindent \textbf{Attack Samples including Naturally Misclassified Images.}
We mix different numbers of misclassified images with trojaned samples and then measure the ASRs of the decomposed triggers (extracted from these inputs) on the test set. A high ASR means the decomposed trigger is effectively decomposed and hence useful to synthesize scanners. We conduct the experiments on CIFAR-10 with VGG-11 and three attacks: BadNets, Reflection, and WaNet. We randomly select 1, 3 and 5 misclassified images and mix them with 9, 7 and 5 trojaned samples, respectively.
We run the experiment of each setting for five times and show the results in Figure~\ref{fig:num_mis}. The x-axis denotes different attacks and the y-axis the ASR. Each bar shows the ASR of the decomposed trigger and the whisker denotes the variance. Observe that the ASR decreases with the increase of the number of misclassified images, which is expected. But with half of the inputs being naturally misclassified ones (5 out of 10), the ASR of the decomposed trigger is still around 90\%, delineating the robustness of {{\sc Beagle}{}}{} in attack decomposition.
The reason is that the natural samples unlikely have consistent misclassification-inducing features and hence they hardly affect the decomposition results.
\smallskip \noindent \textbf{Biases in Attack Types.}
We leverage five filter attacks in TrojAI round 3 and study three different sampling settings:
(1) \textit{uniform} sampling that samples the same number of trojaned models from each attack type;
(2) \textit{highly-biased} sampling that samples a large number of models for some attack type;
(3) \textit{missing} sampling that does not include some attack type. We then apply {{\sc Beagle}{}}{} to partition the sampled trojaned models.
Figure~\ref{fig:sample_bias_model} shows the partitioning results using K-means-S. Each point denotes the reduced attack features for each trojaned model. Observe that in Figure~\ref{fig:sample_bias_model} (b) with the majority of models trojaned by the Lomo filter, {{\sc Beagle}{}}{} can still accurately partition them. Similar observation can be made in Figure~\ref{fig:sample_bias_model} (c).
We also evaluate the detection accuracy of the synthesized scanners and report the results in Table~\ref{tab:sample_bias_model}. Observe that the scanning accuracies are more than 90\% for the uniform and highly-biased cases. The accuracy for the missing attack setting is slightly lower (87\%) as {{\sc Beagle}{}}{} could not synthesize the scanner for the unseen attack.
\begin{figure}[t]
\centering
\begin{minipage}[b]{0.23\textwidth}
\includegraphics[width=1.0\textwidth]{figures/3d_cluster/3D_cluster_uniform.pdf}
\caption*{(a) Uniform}
\end{minipage}
\begin{minipage}[b]{0.23\textwidth}
\includegraphics[width=1.0\textwidth]{figures/3d_cluster/3D_cluster_bias.pdf}
\caption*{(b) Highly Biased}
\end{minipage}
\begin{minipage}[b]{0.23\textwidth}
\includegraphics[width=1.0\textwidth]{figures/3d_cluster/3D_cluster_lack.pdf}
\caption*{(c) Missing}
\end{minipage}
%
\caption{Partitioning results under different sampling settings}
\label{fig:sample_bias_model}
\end{figure}
\input{tables/sample_bias_model}
\subsection{Adaptive Attack} \label{sec:adaptive_appendix}
\input{tables/adaptive}
\input{tables/targeted_adv.tex}
We study three attack scenarios where the adversary has the knowledge of {{\sc Beagle}{}}{}.
\smallskip
\noindent
\textbf{Robust Trigger Injection.}
Particularly, the adversary first trains a trojaned model that has high clean accuracy and ASR. He then follows {{\sc Beagle}{}}{} to extract the injected trigger and stamps the decomposed trigger on clean samples with their original labels. Poisoned in such a way, the trojaned model is not sensitive to the decomposed trigger and has a more robust injected backdoor.
We apply {{\sc Beagle}{}}{} on those trojaned models and present the results in Table~\ref{tab:adaptive}. Column 1 denotes the attacks. Columns 2-3 show the clean accuracy (ACC) and attack success rate (ASR). The remaining columns show the results on visual quality and classification accuracy as introduced in Section~\ref{sec:visual}. For each attack in the table, we report the results on the original trojaned models and on the models by the adaptive attack in the first and the second rows, respectively.
Observe that for most attacks, the adaptive attack induces slight degradation on clean accuracy and ASR.
For those cases, {{\sc Beagle}{}}{} can still decompose high quality clean images and triggers.
In contrast for Reflection, SIG, and WaNet, the decomposed triggers' ASRs have nontrivial degradation,
indicating that {{\sc Beagle}{}}{} becomes less effective. However, observe that the ASRs of the injected triggers also degrade a lot, suggesting the adaptive attack is ineffective either.
The reason is that the decomposed triggers are so similar to the injected ones that they cancel each others out.
\smallskip
\noindent
\textbf{Mixing Targeted Adversarial Examples.}
The adversary in this scenario mixes targeted adversarial examples (i.e., adversarial examples misclassified to the target class)
with the collected trojaned instances to affect the decomposition process of {{\sc Beagle}{}}{}.
There are two cases.
First given a clean model, the adversary provides 10 targeted adversarial examples. In this case, we evaluate whether {{\sc Beagle}{}}{} can still correctly classify clean models.
We generate a set of targeted adversarial samples using PGD with a reasonable bound $L_{\infty}=16/256$ and feed them to {{\sc Beagle}{}}{}. {{\sc Beagle}{}}{} can only decompose a trigger that achieves 69.7\% ASR on the clean validation samples.
We use the synthesized scanner to scan 10 clean models, and the scanning accuracy is 100\%, which means no model is considered trojaned.
The reason is that targeted adversarial attack, not like backdoor attack, does not have a universal secret trigger.
Therefore, {{\sc Beagle}{}}{} cannot summarize a trigger with a high ASR, and hence the synthesized scanner will not classify clean models as trojaned.
In the second case, the adversary mixes targeted adversarial examples with real trojaned samples to affect {{\sc Beagle}{}}{}'s decomposition process, which is similarly to that of mixing naturally misclassified samples~\ref{sec:sample_appendix}.
We conduct experiments on CIFAR-10 with VGG-11 and three attacks, BadNets, Reflection, and WaNet. We randomly mix 1, 3, and 5 targeted adversarial examples with 9, 7, and 5 real trojaned samples respectively.
Table~\ref{tab:target_adv} shows the results where the numbers in the table denote the ASR of decomposed trigger.
Observe that the ASR slightly decreases with the increase of the
number of targeted adversarial examples as expected.
However, even when half of the given samples are adversarial examples, {{\sc Beagle}{}}{} can still synthesize effective triggers.
\smallskip
\noindent
\textbf{Injecting Multiple Trojans.}
The adversary may inject multiple backdoors into a subject model to affect the decomposition process of {{\sc Beagle}{}}{}.
Although this scenario is beyond our threat model~\ref{sec:intro}, where we assume all the trojaned inputs in an attack instance used in forensics are exploiting the same backdoor, we conduct the experiment to evaluate {{\sc Beagle}{}}{} in this extreme scenario.
We suppose the subject model is injected with three backdoors, BadNets, Instagram filter, and WaNet.
There are two cases for this multiple trojan scenario.
In the first case, the three backdoors aim to attack three different classes. Then it is not much different from the model having only one backdoor, because it is easy to distinguish the trojaned samples of the three backdoors by checking their output labels.
In the second case, the three backdoors aim to attack the same class. The problem is hence reduced to whether {{\sc Beagle}{}}{} can decompose a trigger from a set of mixed trojaned samples.
We have trained 10 trojaned models with 3 backdoors and 10 clean VGG-11 models on CIFAR-10.
We assume {{\sc Beagle}{}}{} has access to 3 additional trojaned models for decomposition and scanner synthesis using ABS.
For each trojaned model, we use 10 trojaned samples with 4 BadNets, 3 Instagram filter and 3 WaNet. We leverage the patching function to decompose a trigger from these trojaned images. Note that the decomposed patch trigger achieves an average ASR of 91.7\%, outperforming the decomposed transforming trigger with an ASR of 87.3\%.
The result shows that {{\sc Beagle}{}}{}'s synthesized scanner detects the backdoor well with 100\% accuracy and no FP or FN.
Although injecting multiple backdoors affects the decomposition process, it causes the trigger features to be more distinguishable and thus easy to detect by the scanner.
\input{tables/ablation_number}
\input{tables/diff_cluster}
\subsection{Ablation Study} \label{sec:ablation_study}
\input{tables/ablation_trick}
\smallskip \noindent \textbf{Effect of Normalization in Attack Decomposition.}
Normalization helps ensure the values of decomposed clean images are within the distribution of clean validation images as defined in Eq.~\ref{equ:normalization}.
We conduct the experiments on CIFAR-10 with VGG-11. Similar to Table~\ref{tab:decomposition}, we report the visual quality using $L^1$ distance, PSNR, SSIM, and classification accuracy using ACC, ASR for decomposed clean images and triggers. The top half of Table~\ref{tab:ablation} shows the results. For each evaluation metric, we show the results without the normalization on the left and the results with normalization on the right. Observe that for most cases, using normalization can effectively improve the performance of the decomposition.
\smallskip \noindent \textbf{Comparison with Trigger Inversion Methods.}
In this study, we compare the quality of the decomposed triggers by {{\sc Beagle}{}}{} with those directly inverted from trojaned models using existing trigger inversion techniques.
The comparison is not to claim our results are better as {{\sc Beagle}{}}{} leverages attack samples, but rather to provide a reference.
Specifically, we compare with NC on patching attacks and ABS-filter on transforming attacks.
The bottom half of Table~\ref{tab:ablation} presents the results. Observe that {{\sc Beagle}{}}{} outperforms NC on visual quality for patching backdoors and ABS-filter for transforming backdoors, especially for complex triggers such as Invisible, WaNet, and DFST. The decomposed triggers by {{\sc Beagle}{}}{} can achieve >90\% ASR, while those by ABS-filter can only achieve 20-70\% ASR. This demonstrates that {{\sc Beagle}{}}{} can effectively approximate the trigger injection function comparing to existing works.
\begin{figure}[t]
\centering
\includegraphics[width=0.48\textwidth]{figures/abl-sample-all.pdf}
\caption{Effect of different numbers of available inputs}
\label{fig:ablation_number}
\end{figure}
\smallskip
\noindent
\textbf{Effect of Different Numbers of Available Inputs.}
We study the effect of using different numbers of trojaned and clean samples. We evaluate on using 2, 5, 10 trojaned images, and 10, 20, 50, 100 clean images. The other settings are kept the same and five attacks are used in the experiments.
Figure~\ref{fig:ablation_number} shows the results (details can be found in Table~\ref{tab:ablation_number}). The x-axis in each subfigure denotes different attacks and the y-axis the value of the corresponding evaluation metric. The green bars are for the decomposed clean images and the orange bars for the decomposed triggers.
The bars present the results for the original setting (10 trojaned images + 100 clean images), and the whiskers denote the results of using other settings. Observe that the variance is normally small in most cases, except for Reflection and WaNet.
As {{\sc Beagle}{}}{} leverages normalization for attack decomposition, the number of images may affect the approximation of trojaned and clean distributions and hence the final decomposition. The experiments show the number of available inputs has minor impact on {{\sc Beagle}{}}{}.
\input{tables/ablation_percentile.tex}
\input{tables/ablation_gan.tex}
\input{tables/ablation_alpha.tex}
\smallskip
\noindent
\textbf{Effect of Different Choices of Percentile of Distribution.}
We study the effect of different choices of percentile of distribution in the regularization term in Eq.~\ref{equ:distrib} of the synthesized scanner.
Take TrojAI round 3 as an example. We randomly select 100 clean models and 100 models attacked by polygon triggers, where the random seed is 1024.
We follow the experiment setup presented in Section~\ref{sec:scan} and use ABS as {{\sc Beagle}{}}{}'s downstream scanner.
Besides the default choice of percentile range 15\%-85\%, we conduct two more experiments with percentile range 2\%-98\% and 30\%-70\%.
Table~\ref{tab:percentile} shows the results.
Observe that in all cases, {{\sc Beagle}{}}{} can achieve high accuracy over 93\%, and the choice of percentile is a trade-off between low false negative rate and low false positive rate.
When the percentile is set at a large extent, e.g., 2\%-98\%, {{\sc Beagle}{}}{} has a slightly high false positive rate 10\%, and a low false negative rate 5\%.
On the other hand, when the percentile is constrained in a small extent, e.g., 30\%-70\%, the false positive rate is reduced to 4\% while the false negative rate increases to 9\%.
This is reasonable as a large percentile range poses less regularization penalty on trigger inversion and thus more corner case triggers can be inverted. However, a small percentile range penalizes more on trigger inversion and hence fewer natural trojans (false positive cases) are induced.
The trade-off here is that whether the user prefers a low false positive rate or a low false negative rate.
Typically, we set the default percentile as 15\%-85\% for a balanced performance.
\smallskip
\noindent
\textbf{Effect of Using Different Pre-trained GANs in Attack Decomposition.}
In this study, we aim to show that {{\sc Beagle}{}}{}'s decomposition process may not require that the GAN is well-trained on the model input domain.
We conduct an experiment in which we leverage a pre-trained GAN on CIFAR-10 to decompose 10 Reflection attack instances whose source images come from CIFAR-10, GTSRB and CelebA.
Note that GTSRB and CelebA have no overlapping classes with CIFAR-10.
Table~\ref{tab:gan} shows the results.
The first column denotes the dataset and the following columns measure the decomposition performance, same as Table~\ref{tab:decomposition}.
The first row shows the result when the decomposition process leverages the GAN pre-trained on CIFAR-10, the model input domain. Observe that the decomposition performance is very good with a small $L^1$ error, high PSNR, SSIM scores and high accuracy/ASR for both decomposed clean images and triggers.
The second row illustrates the decomposition performance of GTSRB instances using the same GAN. We can see that there is a medium degradation on the decomposed clean images, with -0.23 SSIM score difference, and a small degradation on the decomposed trigger, with -0.13 SSIM score difference.
In a more extreme case that we use the GAN trained on CIFAR-10 with an input size 32$\times$32 to generate high-resolution images from CelebA with an input size 128$\times$128.
The decomposition performance is further reduced, with -0.39 SSIM score difference on the decomposed clean images and -0.26 on the decomposed trigger, compared to the results on CIFAR-10 instances.
However, in both cases, the decomposed clean images can achieve 100\% accuracy and the decomposed triggers can achieve > 95\% ASR.
We argue that the degradation on visual quality of decomposed clean images is acceptable as finally the decomposed trigger is used for scanner synthesis.
Besides, since the decomposed triggers achieve a high ASR, they are sufficient for further attack summarization.
\smallskip
\noindent
\textbf{Effect of Different Choices of Parameter $\alpha$ in Attack Decomposition.}
Parameter $\alpha$ in Eq.~\ref{e:loss} controls the trade-off between the reconstruction quality and the trigger effectiveness (Accuracy/ASR) during attack decomposition.
We take the decomposition of Reflection backdoor on CIFAR-10 as an example to study the effect of setting different values of $\alpha$.
Table~\ref{tab:alpha} shows the results.
The first column denotes the choice of $\alpha$ and the following columns show the decomposition performance.
Observe that when $\alpha$ is small, e.g., 0.1, the reconstruction quality is low, achieving near 0.3 SSIM score while the ASR of decomposed trigger is high, reaching nearly 100\%.
On the other hand, when $\alpha$ is large, e.g., $10^5$, the reconstruction quality tends to be high, increasing to an SSIM score of 0.8. However, the trigger effectiveness is reduced, i.e., 0.16 ASR degradation.
Overall, we find that $\alpha=1e^{2}$ provides the best trade-offs between the visual reconstruction quality and accuracy/ASR. Hence, we set $\alpha=1e^2$ for Eq.~\ref{e:loss}.
| {'timestamp': '2023-01-18T02:16:34', 'yymm': '2301', 'arxiv_id': '2301.06241', 'language': 'en', 'url': 'https://arxiv.org/abs/2301.06241'} | arxiv |
\section{Introduction}
In recent years, deep learning \cite{ref_proc1} model have shown significant improvement on natural language processing(NLP), computer vision and speech processing technologies. However, the model performance is limited by the human labeled data quality. The main reason is that the human labeled data has a certain number of noisy data. Previous work \cite{ref_proc2} has propose the simple idea to find the noisy data and correct the noisy data. In this paper, we first review the way we achieve more than 90 score in classification task, then we further illustrate our idea for sequence tagging, object detection, sequence generation, click-through rate (CTR) prediction.
\section{Background}
In previous work \cite{ref_proc2}, we illustrate our idea in these steps:
1. It is a text classification task. We have a human labeled dataset-v1.
2. We train a BERT-based \cite{ref_proc3} deep model upon dataset-v1 and get model-v1.
3. Using model-v1 to predict the classification label for dataset-v1.
4. If the predicted labels of dataset-v1 do not equal to the human labels of dataset-v1, we think they are the noisy data.
5. We label the noisy data again by human, while given the labels of model and last label by human as reference. Then we get dataset-v2.
6. We loop this re-labeling noisy data steps and get the final dataset. Then we get model-v2. We can further loop this steps to get model-v3.
\section{Same Idea and More Applications}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{fig1.png}
\caption{Re-label method applying to any machine learning application. } \label{fig1}
\end{figure}
\subsection{sequence tagging}
We take named entity recognition(NER) as example for the sequence tagging like tasks. In NER task, we extract several classes of key phrase from a sentence. Follow our idea, we view each class of NER task as a classification task. Then our steps are:
1. It is a NER task. We have a human labeled dataset-v1.
2. We train a BERT-based \cite{ref_proc3} deep model upon dataset-v1 and get model-v1.
3. Using model-v1 to predict the sequence labels of one class for dataset-v1.
4. If the predicted labels of dataset-v1 do not equal to the human labels of dataset-v1, we think they are the noisy data.
5. We label the noisy data again by human, while given the labels of model and last label by human as reference. Then we get dataset-v2.
6. We loop this re-labeling noisy data steps for all the classes of NER and get the final dataset. Then we get model-v2.
\subsection{object detection}
Object detection is a computer vision technique that allows us to identify and locate objects in an image or video. Follow our idea, we view each kind of bounding box as a classification task. Then our steps are:
1. It is a object detection task. We have a human labeled dataset-v1.
2. We train a Swin Transformer\cite{ref_proc4} upon dataset-v1 and get model-v1.
3. Using model-v1 to predict the bounding boxes of one class for dataset-v1.
4. If the predicted bounding box of dataset-v1 is far from the human labeled bounding box of dataset-v1, we think they are the noisy data.
5. We label the noisy data again by human, while given the bounding boxes of model and last label by human as reference. Then we get dataset-v2.
6. We loop this re-labeling noisy data steps for all the classes of object detection and get the final dataset. Then we get model-v2.
\subsection{sequence generation}
The key step of our idea is about how to judge the noisy data. For sequence generation, we can use BLEU score or other sequence similarity evaluation method. Then our steps are:
1. We take text generation task as example. We have a human labeled dataset-v1.
2. We train a Encoder-Decoder Transformer\cite{ref_proc5} upon dataset-v1 and get model-v1.
3. Using model-v1 to predict the generated sentences for dataset-v1.
4. If the BLEU score of generated sentences of dataset-v1 is far from the human labeled generated sentences of dataset-v1, we think they are the noisy data.
5. We label the noisy data again by human, while given the generated sentences of model and last label by human as reference. Then we get dataset-v2.
6. We loop this re-labeling noisy data steps and get the final dataset. Then we get model-v2.
\subsection{click-through rate prediction}
For CTR task, we use the method of \cite{ref_proc6} that automatically set the label again for the noisy data. CTR task is a click-or-not prediction task, we choose a threshold between the predicted score and the 0/1 online label score to judge whether the data is the noisy data. In this way, we could improve the AUC in dev dataset but the online performance should test online.
\section{Experimental Results}
We do the experiments of text classification and NER to verify our idea. The results is shown in Table 1 and Table 2. We also do a lot of other classification task and NER task of other dataset. The improvement is also significant and we do not list the detail results.
\begin{table}
\caption{The experiment result of text classification. The model-v1 and model-v2 are corresponding to the previous section}\label{tab1}
\centering
\begin{tabular}{|l|l|l|}
\hline
model & Dev Dataset Accuracy & Human Evaluation Accuracy \\
\hline
model-v1 & 83.3\% & 88.0\% \\
\hline
model-v2 & 91.7\% & 97.2\% \\
\hline
model-v3 & 93.8\% & 97.5\% \\
\hline
\end{tabular}
\end{table}
\begin{table}
\caption{The experiment result of NER. The model-v1 and model-v2 are corresponding to the previous section}\label{tab1}
\centering
\begin{tabular}{|l|l|l|}
\hline
model & Dev Dataset F1 & Human Evaluation Precision \\
\hline
model-v1 & 73.7\% & 86.0\% \\
\hline
model-v2 & 88.7\% & 97.0\% \\
\hline
\end{tabular}
\end{table}
\section{Analysis}
Why re-label method work? Because deep learning is statistic-based. Take classification as example. (In a broad sense, all the machine learning tasks can be viewed as classification.) If there are three \textbf{very similar} data (data-1/data-2/data-3) in total, which labels are class-A/class-A/class-B, Then the trained model will probably predict class-A for data-3. We assume that data-3 is wrong labeled to class-B by human, because more people label its similar data to class-A.
The improvement reason is also based on the better and better understanding for the specific task's labeling rule/knowledge of labeling human once by once. Human-in-the-loop here means that in each loop the labeling human leader should learn and summarize the corrected rule/knowledge based on the last loop.
\section{Related Work}
\subsection{Pseudo-label-based method}
The work\cite{ref7} proposes pseudo-label-based method to improve data quality without human re-label, which is different from our method. Our method is to improve the data quality for model of 97\% accuracy/precision/recall/BLEU/AUC by human re-label.
The work\cite{ref8} proposes label-guess-based method to improve data quality without human re-label, which is different from our method. Our method get the guess-label as reference for human re-label.
\subsection{ChatGPT}
The work\cite{ref9} of OpenAI also use model predictions for human as references to label. The work\cite{ref9} use the new human-labeled data from model predictions to train the reward model, which is named as reinforcement learning from human feedback(RLHF).
Our work do not have the reward model of RLHF, the differnce between RLHF and our re-label method is that RLHF focus on using the model predictions as training dataset of reward model, and our re-label method focus on correcting the origin training dataset of policy model. Also in RLHF, the new human-labeled data from model predictions do not conflict to our method, because the new data can be simply merged to the whole dataset of policy model, and then to re-label/re-correct by our method.
Also, the correction for policy by the reward model of RLHF is same to correct all the related data/labels that found by the patterns or substrings of the badcases. The detail pattern-based human-correct method is illustrated at \cite{ref10}.
\section{Conclusion}
We argue that the key point to improve the industry deep learning application performance is to correct the noisy data. We propose a simple method to achieve our idea and show the experimental results to verify our idea.
| {'timestamp': '2023-02-10T02:03:58', 'yymm': '2302', 'arxiv_id': '2302.04391', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04391'} | arxiv |
\section{Introduction}
\subsection{Motivation}
Massive multiple-input multiple-output (MIMO) is a promising technology for achieving high spectral efficiency in future cellular networks, as demonstrated by its extensive study in time-division-duplexing (TDD) massive MIMO \cite{marzetta2010noncooperative,ngo2013energy}. Channel reciprocity is a key aspect in TDD that enables the acquisition of downlink channel state information at the transmitter without additional training or feedback, resulting in substantial gains in energy and spectral efficiencies. However, in frequency-division-duplexing (FDD), the non-reciprocal nature of the downlink and uplink channels requires additional training and feedback, leading to significant spectral efficiency losses and underrating of FDD massive MIMO in practice \cite{jindal2006mimo,love2005limited,maddah2012completely,yang2012degrees,gou2012optimal,lee2012not,lee2013space,bjornson2016massive}.
Significant progress has been made in recent years in reducing CSI feedback overhead in FDD massive MIMO using i) compressive sensing (CS) techniques \cite{gao2015structured,han2017compressed,liang2020deep}, ii) two-stage precoding methods exploiting channel spatial correlation effects \cite{adhikary2013joint,el2014spatially,alkhateeb2014channel}, and iii) DL channel extrapolation with UL pilots \cite{wang2018deep,alrabeiah2019deep,alrabeiah2020deep,yang2020deep}.
In particular, estimating DL channel using UL pilots is a attracting solution that can completely eliminate the tremendous signaling overhead associated with DL channel training and CSI feedback \cite{vasisht2016eliminating,khalilsarai2018fdd}. However, accurately estimating DL channels from UL pilots is extremely challenging due to the dearth of channel reciprocity.
Notwithstanding the absence of explicit channel reciprocity, some channel parameters, including angle of arrivals (AoAs) and path gains, are still useful. This is because they are frequency-invariant, so that reciprocity partially holds for these parameters in UL and DL channels \cite{vasisht2016eliminating,khalilsarai2018fdd}.
Consequently, it is possible to reconstruct the DL channels with a certain level of accuracy from
UL pilots by exploiting these frequency-invariant channel parameters. In this paper, we make progress in this direction. In particular, our key finding is that a robust DL precoding harnessing these frequency-invariant channel parameters can provide the substantial spectral efficiency gains of the FDD massive MIMO with perfect CSIT when the number of antenna at the BS is infinite.
\subsection{Related Works}
Traditionally, in FDD multi-user MIMO, much work in the literature has focused on characterizing the required CSI feedback overhead to attain multiplexing gains \cite{jindal2006mimo}. In a vector broadcast channel, it was shown that the feedback rate to obtain full-multiplexing gains scales with both the number of antennas at the BS and the signal-to-noise ratio (SNR) at receivers in dB \cite{jindal2006mimo}. This result has been extended in the context of multi-cell MU-MIMO settings \cite{lee2010adaptive,bhagavatula2010adaptive,park2016optimal,park2018feedback}. The conclusion drawn from these prior studies was that the CSI feedback overhead to mitigate interference effects scales with the number of antennas; thereby, this tremendous CSI feedback overhead is a significant hindrance for FDD massive MIMO.
CSI compression is necessary to diminish the feedback overhead in FDD massive MIMO. Exploiting the sparse representation of the channel in the beam domain \cite{loyka2001channel,sayeed2002deconstructing,3gpp2003spatial,brady2013beamspace}, the prior work has applied compressive sensing (CS) methods \cite{gao2015structured,han2017compressed,liang2020deep,bajwa2010compressed,alkhateeb2014mimo}. Thanks to CS theory \cite{candes2008introduction}, this approach possibly reduces the size of the effective channel vector for CSI feedback. For instance, a low-complexity sparse signal recovery algorithm \cite{tropp2007signal} allows to compress the channel vector size to the product of the log of the number of BS antennas and the sparsity level. Recently, this CS-based feedback strategy has been extended with deep learning to attain the enhanced CSI compression gain \cite{liang2020deep}. Leveraging the image compression techniques developed in deep-learning, a compressed feature of a channel matrix is obtained using convolutional neural networks (CNNs). Then, the BS rebuilds the channel matrix received from the feature matrix via feedback links. This deep-learning-aided CSI matrix compression technique can diminish the amount of CSI without an explicit sparse representation of the channel. However, it requires a large number of training samples to optimize the DNNs, and the CSI reconstruction performance is limited when the data distributions for training and testing are distinct, which is the common bottleneck of the deep-learning approach for wireless systems. These CS-based and deep-learning-aided methods can compress CSI feedback amount considerably compared to the traditional limited feedback approaches using vector quantization. However, it still requires a noticeable feedback overhead for an extremely large array size envisioned in the recent eXtreme massive MIMO 6G \cite{nokia2011extreme}, or the channel sparsity is not sufficiently advocated.
Combined with precoding strategy, a reduced DL training and CSI feedback stategy was proposed in \cite{adhikary2013joint}. Harnessing the structure of the spatial correlation of DL channels, a two-stage precoding method called joint spatial division multiplexing (JSDM) was presented, which sequentially uses the second-order channel statistics and the instantaneous CSI in the reduced dimensional space. It turned out that JSDM can achieve the optimal spectral efficiency attained with full CSIT under some mild conditions. This idea has also been extended in the context of mmWave massive MIMO, in which hybrid precoding that concatenates analog precoding with digital precoding can reduce both DL channel training and CSI feedback overhead from the two-stage precoding architecture \cite{el2014spatially,alkhateeb2014channel}.
The most relevant prior work to this paper is to use UL pilots to acquire DL CSIT in FDD massive MIMO \cite{vasisht2016eliminating, khalilsarai2018fdd}. Using the fact that the angular scattering functions between UL and DL channels are identical over frequency, i.e., frequency-invariant, a BS can accurately estimate the DL channel covariance matrix from UL pilots. The DL transmission method using the covariance matrix was proposed in \cite{khalilsarai2018fdd} and showed the spectral efficiency gain over the CS-aided CSI feedback strategy. The DL channel reconstruction algorithm was proposed using UL pilots in generic FDD wireless systems \cite{vasisht2016eliminating}. The idea was to reconstruct DL channels using frequency-invariant channel parameters, including AoAs and path gains, between UL and DL channels. This frequency extrapolation method has been further extended in \cite{rottenberg2019channel,rottenberg2020performance}, where a high-resolution channel estimation technique was presented with a theoretical lower bound of the extrapolated channel. To reduce the beam training overhead in mmWave systems, it has been shown that exploiting channel knowledge of sub-6GHz bands is useful \cite{ali2017millimeter,maschietti2019coordinated}. Recently, with the power of deep learning to identify a non-linear transform mapping, the DL channel reconstruction problem from UL pilots has been extensively tackled in \cite{wang2018deep,alrabeiah2019deep,alrabeiah2020deep,yang2020deep}. For instance, a DL channel estimation technique was presented in \cite{alkhateeb2019deepmimo} using DeepMIMO datasets. The deep-learning-aided approach has opened a new opportunity to find the complicated non-linear mapping function for the DL channel reconstruction. This approach, however, is vulnerable to changing channel distributions between training and testing. The frequency extrapolation methods \cite{vasisht2016eliminating,rottenberg2019channel,rottenberg2020performance,ali2017millimeter,maschietti2019coordinated} are also limited to accurately estimating frequency-variant parameters such as the phase information of individual channel paths. These parameters with uncertainty hinders to accurately estimate instantaneous DL CSIT. In addition, all aforementioned works do not show how to optimally exploit the partial channel reciprocity of frequency-invariant parameters for DL precoding.
\subsection{Contributions}
\begin{itemize}
\item We present a DL channel reconstruction method that utilizes UL pilots. Our DL reconstruction method consists of three steps. Firstly, the BS performs UL channel estimation on each user through the use of orthogonal UL pilots assigned to the users. In the second stage, the BS estimates frequency-invariant channel parameters, including AoAs and path gains. Finally, the BS joinlty uses the estimated UL channel information, along with the AoAs and path gains, and the uniform linear array (ULA) structure at the BS to reconstruct the DL channel vector with unknown phase information for each channel path. Based on the assumption of a uniform phase distribution, the worst-case scenario, we present the MSE-optimal DL channel reconstruction methods. We highlight that our approach differs from previous works in \cite{vasisht2016eliminating,rottenberg2019channel}. Our methods utilize the UL channel knowledge along with the channel parameters jointly to minimize the DL channel reconstruction error.
\item To gauge the exactness of the proposed DL channel reconstruction method, we derive the MSE matrix in closed form. From the derived MSE matrix, we elucidate that the reconstruction error is a function of the ratio between UL and DL frequencies; a larger ratio makes more reconstruction error, which confirms our intuition. More importantly, from the MSE analysis, we prove that the outer product between the actual instantaneous DL channel can be tightly approximated as the sum of the outer product of the reconstructed DL channels and the MSE matrix in the infinite number of antennas.
\item We also propose a robust DL precoding algorithm that takes into account both the reconstructed DL channels and the reconstruction error covariance matrix. This robust precoding method is an extension of our previous work in \cite{choi2019joint}, which guarantees to find a local optiaml solution for a joint user selection, power control, and beamforming to maximize the downlink sum spectral efficiency with incomplete CSIT. The key difference in our current work is that we have derived the second order local optimality condition for the sum spectral efficiency maximization problem to ensure the local optimality of the general power iteration precoding (GPIP) algorithm.
\item System level simulation results reveal that the proposed DL precoding algorithm with the DL channel reconstruction can achieve the comparable ergodic DL spectral efficiency to the zero-forcing (ZF) precoding with perfect CSIT, even with not-so-many BS antennas. This result confirms that the the FDD massive MIMO gains can be achieved using UL pilots, provided that the AoAs and path gains of the channel are available.
\end{itemize}
\subsection{Paper Organization and Notations}
This paper is organized as follows: Section \rom{2} covers the network topology and channel model. Section \rom{3} outlines the proposed DL channel reconstruction framework with partial geometric parameters. Section \rom{4} details the robust DL data transmission framework. Section \rom{5} establishes local optimality conditions for the formulated optimization problems. Section \rom{6} presents an efficient algorithm for finding local optimal solutions. Numerical results are in Section \rom{7}. Conclusion in Section \rom{8}.
In this paper, we use the following notations: $\mathbb{C}$ represents the set of complex numbers, $\mathbb{R}$ represents the set of real numbers, $\otimes$ denotes the Kronecker product, $\odot$ denotes the Hadamard product, and ${\sf Tr}\left\{\cdot\right\}$ is the matrix trace operation. The expectation of a random vector ${\bf x}$ is represented by $\mathbb{E}\left[{\bf x}\right]$. The real part of a complex scalar $x$ is denoted by ${\rm Re}\left[ x \right]$. The minimum and maximum eigenvalues of a matrix ${\bf A}$ are represented by $\rho_{\sf min}\left({\bf A}\right)$ and $\rho_{\sf max}\left({\bf A}\right)$, respectively. An $N\times N$ identity matrix is represented by ${\bf I}_N$. A complex Gaussian distribution with mean vector ${\bf m}$ and covariance matrix ${\bf R}$ is represented by ${\bf x}\sim\mathcal{CN\left({\bf m},{\bf R}\right)}$. The column vectors of matrix ${\bf A}\in\mathbb{C}^{N\times N}$ are represented by $\left\{ {\bf a}_1,\cdots,{\bf a}_N\right\}$, and column vector ${\bf a}\in\mathbb{C}^{N\times 1}$ consists of elements $\left\{{a}_1,\cdots,{a}_N\right\}$.
\section{System Model}
In this section, we explain an FDD massive MIMO system model where the BS has $N$ antennas and there are $K$ users each with a single receive antenna. For ease of exposition, we shall focus on a single-cell network to clearly explain the proposed methods. Nonetheless, our method can be readily applicable to multi-cell networks by incorporating pilot contamination effects with a minor modification. We will verify the effectiveness of the proposed methods in both single-cell and multi-cell networks in Section \ref{sec:Simulation_Results}.
\subsection{UL and DL Channel Models}
\begin{figure}[t]
\centering
\includegraphics[width=0.5\linewidth]{fig/fig_System_Model.pdf}
\caption{The UL and DL multi-path channel models with ULA at the BS.} \label{fig_System_Model}
\end{figure}
{\bf UL channel model:} We commence with defining the UL channel from user $k\in [K]$ to the BS. Let ${\bf h}_k^{{\sf ul}}\in \mathbb{C}^N$ be the UL channel vector defined as the sum of array response vectors. Assuming uniform-linear-array (ULA) antenna elements at the BS, the narrowband UL channel model is
\begin{align}
{\bf h}_k^{{\sf ul}} = \sum_{\ell=1}^{L_k^{\sf ul}}g_{k,\ell}^{\sf ul}{\bf a}\left(\theta_{k,\ell}^{\sf ul}, \lambda^{\sf ul}\right),
\label{eq:UL_Channel}
\end{align}
where $L_{k}^{\sf ul}\in \mathbb{Z}^{+}$ and $g_{k,\ell}^{\sf ul}\in\mathbb{C}$ denote the number of multi-paths and the complex coefficient for fading. Under the far-field assumption, the array response vector is defined as a function of angle of arrivals (AoAs) $\theta_{k,\ell}^{\sf ul}$ as
\begin{align}
{\bf a}(\theta_{k,\ell}^{\sf ul}, \lambda^{\sf ul})=\left[1,e^{-j\frac{2\pi}{\lambda^{\sf ul}}d\sin{\theta_{k,\ell}^{\sf ul}}},\hdots,e^{-j\frac{2\pi}{\lambda^{\sf ul}}(N-1)d\sin{\theta_{k,\ell}^{\sf ul}}}\right]^{\sf T},
\end{align}
where $\lambda^{\sf ul}$ is the wavelength and $d$ is the inter-antenna spacing. The narrowband channel of signal traversing the $\ell$th path is given by \cite{tse2005fundamentals}:
\begin{align}
g_{k,\ell}^{\sf ul} = b_{\ell,k}^{\sf ul}e^{-j\frac{2\pi}{\lambda^{\sf ul}}r_{k,\ell}+\phi_{k,\ell}^{\sf ul}},
\end{align}
where $b_{\ell,k}^{\sf ul}\in \mathbb{R}^{+}$ is the $\ell$th path attenuation of the UL channel from user $k$ to the BS, $r_{\ell,k}$ is the path distance, and $\phi_{\ell,k}^{\sf ul}$ is a random phase which is independent of wavelength, and it is uniformly distributed over $\left[0,2\pi\right)$ to capture small-scale fading effects by path reflections.
{\bf DL channel model:} Analogy to the UL channel model in \eqref{eq:UL_Channel}, the DL channel from the BS to user $k$ is modeled by the sum of the complex channel gains $g_{k,\ell}^{\sf dl}$ and array response vectors ${\bf a}(\theta_{k,\ell}^{\sf dl},\lambda^{\sf dl})$ representing the array phase profile corresponding to angle of departure (AoD) $\theta_{k,\ell}^{\sf dl}$ as
\begin{align}
{\bf h}_k^{{\sf dl}} = \sum_{\ell=1}^{L_k^{\sf dl}}g_{k,\ell}^{\sf dl}{\bf a}(\theta_{k,\ell}^{\sf dl}, \lambda^{\sf dl}),
\label{eq:DL_Channel}
\end{align}
where $L_k^{\sf dl}$ is the number of multi-paths for the DL channel and the array response vector ${\bf a}(\theta_{k,\ell}^{\sf dl},\lambda^{\sf dl})$ is defined as
\begin{align}
{\bf a}(\theta_{k,\ell}^{\sf dl}, \lambda^{\sf dl})=\left[1,e^{-j\frac{2\pi}{\lambda^{\sf dl}}d\sin{\theta_{k,\ell}^{\sf dl}}},\hdots,e^{-j\frac{2\pi}{\lambda^{\sf dl}}(N-1)d\sin{\theta_{k,\ell}^{\sf dl}}}\right],
\end{align}
where $\lambda^{\sf dl}$ is the DL wavelength. The complex channel coefficient of the $\ell$th path is similarly defined as
\begin{align}
g_{k,\ell}^{\sf dl} = b_{\ell,k}^{\sf dl}e^{-j\frac{2\pi}{\lambda^{\sf dl}}r_{k,\ell}+\phi_{k,\ell}^{\sf dl}}.
\end{align}
where $b_{\ell,k}^{\sf dl}\in \mathbb{R}^{+}$ is the $\ell$th path attenuation of the DL channel from the BS to user $k$. We also assume that random phase of the DL channel path $\phi_{k,\ell}^{\sf dl}$ is uniformly distributed over $[0,2\pi)$.
Our simplified single-cluster channel models, represented in \eqref{eq:UL_Channel} and \eqref{eq:DL_Channel}, capture the scattering effects from diffuse reflections within a cluster through multiple paths. These multi-path channel models have widely used in the literature {\cite{3gpp2003spatial}}. Our model assumes that the cluster has multiple dominant paths displaying macro-level channel propagation effect, with angle spreads concentrated at the AoA and AoD in each path. This channel model has empirically proven accurate especially in high frequencies, where scattering from diffuse reflections is less pronounced.
\subsection{Frequency-invariant channel parameters}
It is clear that the UL and DL channels, which operate at different wavelengths, $\lambda^{\sf ul}$ and $\lambda^{\sf dl}$, are not reciprocal. This is due to the fact that the channel coefficients, $ g_{k,\ell}^{\sf ul} $ and $ g_{k,\ell}^{\sf dl} $, and array response vectors, ${\bf a}(\theta_{k,\ell}^{\sf ul},\lambda^{\sf ul})$ and ${\bf a}(\theta_{k,\ell}^{\sf dl},\lambda^{\sf dl})$, vary with the wavelength. However, a significant observation is that some critical geometric parameters in the UL and DL channels are commonly frequency-invariant. These frequency-invariant parameters include:
\begin{itemize}
\item The angles of arrival (AoAs), denoted by $\theta_{k,\ell}^{\sf ul}$, and angles of departure (AoDs), represented by $\theta_{k,\ell}^{\sf dl}$, are fundamental parameters in the wave propagation. These parameters are often assumed to be identical, due to the inherent symmetry of the antenna and path geometry.
\item The channel attenuation parameters, $ b_{k,\ell}^{\sf ul}$ and $ b_{k,\ell}^{\sf dl}$, are frequency-dependent as modeled in \cite{maccartney2017rural,samimi2015probabilistic}. This is due to the fact that the path loss with omni-directional antennas is modeled as follows:
\begin{align}
-10\log{b_{k,\ell}^{\sf ul}}=20\log{\left(\frac{4\pi r_0}{\lambda^{\sf ul}}\right)}+m\log{\left(\frac{r_{k,\ell}}{r_0}\right)}+X_{k,\ell}.
\end{align}
The parameters $r_0$, $m$, and $X_{k,\ell}$ denote the reference distance, path-loss exponent, and shadowing parameter, respectively. As the path distance $r_{k,\ell}$ is shared between the UL and DL channels, the dominant term, $m\log{\left(\frac{r_{k,\ell}}{r_0}\right)}$, becomes identical in both channels. Hence, the path attenuation terms in the UL and DL channels can be considered frequency-invariant, as stated in \cite{vasisht2016eliminating}. Thus, we can assume $ b_{k,\ell}^{\sf ul}\simeq b_{k,\ell}^{\sf dl}$.
\item The phase variations, $\phi_{k,\ell}^{\sf ul}$ and $\phi_{k,\ell}^{\sf dl}$, arise from phenomena such as reflection and refraction. As a result, these parameters are consistent between the UL and DL so long as the physical environment remains unchanged.
\end{itemize}
In this paper, we utilize the frequency-invariant channel parameters to recreate the DL channels through uplink pilot signals. For ease of notation, we simplify the AoAs and DoAs by removing the superscript, $\theta_{k,\ell} = \theta_{k,\ell}^{\sf ul} = \theta_{k,\ell}^{\sf dl}$. The same holds for the path attenuation $b_{k,\ell}=b_{k,\ell}^{\sf ul}=b_{k,\ell}^{\sf dl}$ and the phase variation $\phi_{k,\ell}=\phi_{k,\ell}^{\sf ul}=\phi_{k,\ell}^{\sf dl}$. It is also important to note that we assume that the number of channel paths in the UL and DL are equal, i.e., $L_k=L_{k}^{\sf ul}= L_{k}^{\sf dl}$.
\section{MSE-Optimal DL Channel Reconstruction}
In this section, we present the MSE-optimal channel reconstruction algorithms for the DL channel, assuming perfect knowledge of both the UL channels ${\bf h}_{k}^{\sf ul}$ and partial frequency-invariant channel parameters $\left\{\theta_{k,\ell}, b_{k,\ell}\right\}_{\ell=1}^{L_k}$ for each user $k\in[K]$ for ease of exposition. We will show the effect of imperfect knowledge of UL channel and the parameters on the DL performance in Section V-A. We further analyze the DL channel reconstruction error covariance matrix to quantify the accuracy of the DL channel reconstruction as a function of the UL and DL carrier frequencies.
\subsection{MSE-Optimal DL Channel Reconstruction}
We commence by introducing a useful lemma that to derive the MSE-optimal DL channel reconstruction.
\begin{lem} \label{lem1}
Suppose the phases of UL and DL channel paths are uniformly distributed, i.e., $\angle{g_{k,\ell}^{\sf ul}} =\frac{2\pi}{\lambda^{\sf ul}}r_{k,\ell}-\phi_{k,\ell} \in\left[0,2\pi\right)$ for $\ell\in L_k$ and $\angle{g_{k,\ell}^{\sf dl}} =\frac{2\pi}{\lambda^{\sf dl}}r_{k,\ell}-\phi_{k,\ell} \in\left[0,2\pi\right)$ for $\ell\in L_k$. Then, the correlation between ${\bf g}_k^{\sf ul}$ and ${\bf g}_k^{\sf dl}$ conditioned on $ b_{k,1},\ldots, b_{k,L_k}$ is given by
\begin{align}
\mathbb{E}\left[ {\bf g}_k^{\sf dl}\left({\bf g}_k^{\sf ul}\right)^{\sf H} | b_{k,1},\ldots, b_{k,L_k}\right] = \eta{\bf \Sigma}_k,\quad\forall k\in[K], \label{eq:Corr_UL_DL}
\end{align}
where
\begin{align}
{\bf \Sigma}_k &= {\sf diag}\left(\left[b_{k,1}^2,\cdots,b_{k,L_k}^2\right]\right) ,\nonumber\\
\eta&=\frac{1}{2\pi(\frac{\lambda^{\sf ul}}{\lambda^{\sf dl}}-1)}\left(\sin\left(2\pi\frac{\lambda^{\sf ul}}{\lambda^{\sf dl}}\right)-2j\sin^2\left(\pi\frac{\lambda^{\sf ul}}{\lambda^{\sf dl}}\right)\right).\label{eq:eta}
\end{align}
\end{lem}
\begin{IEEEproof}
See the Appendix \ref{Proof_for_Corr_UL_DL}.
\end{IEEEproof}
\vspace{0.1cm}
Lemma \ref{lem1} implies that the correlation matrix $\eta{\bf \Sigma}_k$ is a scaled version of ${\bf \Sigma}_k$ by a factor of $\eta$. To understand the effect of $\eta$, we need to analyze its behavior with the changes in the carrier frequency gap between UL and DL. For instance, if the carrier frequency in UL and DL are equal, i.e., $f_c^{\sf ul} = f_c^{\sf dl}$, the correlation simplifies to the path attenuation power ${\bf \Sigma}_k$ since $\eta=1$. On the other hand, if $f_c^{\sf ul} \ne f_c^{\sf dl}$, $\eta$ reflects the deviation as the ratio of $\frac{\lambda^{\sf ul}}{\lambda^{\sf dl}}$.
Using this property, we show how to recreate the DL channels through the utilization of the UL channels and partial geometric parameters. We first assume that the BS has a perfect knowledge of the UL channels and partial geometric parameters, represented as $\left\{{\bf h}_k^{\sf ul},{\bf\Theta}_k,{\bf \Sigma}_k\right\}$ for ${k\in[K]}$.
\begin{thm}\label{thm:OptimalDlChannelEstimator}
The MSE-optimal DL channel estimate is given by
\begin{align}
{\bf\hat h}_k^{\sf dl, MMSE}
&= \eta{\bf A}_k^{\sf dl}{\bf \Sigma}_k^{\frac{1}{2}}\left({\bf \Sigma}_k^{-\frac{1}{2}}\left({\bf A}_k^{\sf ul}\right)^{\dagger}{\bf h}_k^{\sf ul}\right)^{\frac{\lambda^{\sf ul}}{\lambda^{\sf dl}}},\label{eq: Optimal_Estimator}
\end{align}
where ${\bf A}_k^{\sf ul}=\left[{\bf a}(\theta_{k,1},\lambda^{\sf ul}), \ldots , {\bf a}(\theta_{k,L_k},\lambda^{\sf ul})\right]\in \mathbb{C}^{N\times L_k}$ and ${\bf A}_k^{\sf dl}=\left[{\bf a}(\theta_{k,1},\lambda^{\sf dl}), \ldots , {\bf a}(\theta_{k,L_k},\lambda^{\sf dl})\right]\in \mathbb{C}^{N\times L_k}$ are the UL and DL array response matrices, respectively.
\end{thm}
\begin{IEEEproof}
See Appendix \ref{Proof_for_OptimalDlChannelEstimator}.
\end{IEEEproof}
\vspace{0.1cm}
Theorem \ref{thm:OptimalDlChannelEstimator} demonstrates that the MSE-optimal DL channel estimate is derived from a combination of four elements: the UL channel ${\bf h}_k^{\sf ul}$, the UL array response matrix ${\bf A}_k^{\sf ul}$, the correlation matrix from Lemma 1 ($\eta {\bf \Sigma}_k$), and the DL array response matrix ${\bf A}_k^{\sf dl}$. The estimation process starts with the estimation of the UL channel ${\bf h}_k^{\sf ul}$. Then, it undergoes a transformation using $\frac{\lambda^{\sf ul}}{\lambda^{\sf dl}}$ as the exponent and ${\bf \Sigma}_k^{-\frac{1}{2}}\left({\bf A}_k^{\sf ul}\right)^{\dagger}$. Finally, the DL channel estimate is obtained by projecting the result onto the DL array matrix through multiplication with the normalization matrix $\eta{\bf A}_k^{\sf dl}{\bf \Sigma}_k^{\frac{1}{2}}$.
Next, we present a linear-MMSE (L-MMSE) DL channel estimation in the following corollary.
\begin{cor}\label{thm:LinearDlChannelEstimator}
The MSE-optimal DL channel estimate under the linear map constraint is given by
\begin{align}
{\hat{\bf h}}_{k}^{\sf dl, L-MMSE}
={\rm Re}\{\eta\}{\bf A}_k^{\sf dl}\left({\bf A}_k^{\sf ul}\right)^{\dagger} {\bf h}_k^{\sf ul}.\label{eq:col1}
\end{align}
where ${\rm Re}\{\eta\}= \frac{1}{2\pi(\frac{\lambda^{\sf ul}}{\lambda^{\sf dl}}-1)} \sin\left(2\pi\frac{\lambda^{\sf ul}}{\lambda^{\sf dl}}\right). $
\end{cor}
\begin{IEEEproof}
See Appendix \ref{Proof_for_Corr1}.
\end{IEEEproof}
The L-MMSE DL channel estimation method differs from the MSE-optimal DL channel estimate in \eqref{eq: Optimal_Estimator} as it requires information about the UL array response matrix ${\bf A}_k^{\sf ul}$, the DL array response matrix ${\bf A}_k^{\sf dl}$, the real part of the carrier normalization constant ${\rm Re}\{{\eta}\}$, and the UL channel ${\bf h}_k^{\sf ul}$. However, the channel path gain information ${\bf \Sigma}_k$ is not necessary for the L-MMSE estimation, simplifying the DL channel reconstruction process. Furthermore, the L-MMSE estimation uses the real part of $\eta$ in \eqref{eq:eta} as its carrier normalization term.
\subsection{MSE Analysis}
To evaluate the precision of the DL channel reconstruction, we assess the MSE performance of the proposed DL channel reconstruction method in \eqref{eq: Optimal_Estimator} and \eqref{eq:col1}. We first construct the MSE matrix of each estimator and derive the MSE by using MSE matrix.
\begin{thm}\label{thm:MseMatrxOfOptimal}
Let ${\bf e}_k={\bf h}_k^{\sf dl}-{\bf\hat h}_k^{\sf dl, MMSE}$ be the DL channel reconstruction error. Then, the error covariance matrix with knowledge of ${\bf h}_k^{\sf ul},{\bf\Theta}_k$, and ${\bf \Sigma}_k$ is given by is
\begin{align}
{\bf \Phi}_k^{\sf MMSE}&=\mathbb{E}\left[\left.{\bf e}_k{\bf e}_k^{\sf H}\right|{\bf h}_k^{\sf ul},{\bf\Theta}_k,{\bf \Sigma}_k\right]\nonumber\\
&=\left(1-|\eta|^2\right){\bf A}_k^{\sf dl}{\bf \Sigma}_k\left({\bf A}_k^{\sf dl}\right)^{\sf H}.
\end{align}
\end{thm}
\begin{IEEEproof}
See Appendix \ref{ProofForThm2}.
\end{IEEEproof}
The following corollary states the MSE matrix when using the L-MMSE DL channel reconstruction method in \eqref{eq:col1}.
\begin{cor}\label{thm:MseMatrixOfLMSE}
Let ${\bf \tilde e}_k={\bf h}_k^{\sf dl}-{\bf\hat h}_k^{\sf dl, L-MMSE}$ be the DL channel reconstruction error. Then, the error covariance matrix with knowledge of ${\bf h}_k^{\sf ul},{\bf\Theta}_k$, and ${\bf \Sigma}_k$ is given by is
\begin{align}
{\bf \Phi}_k^{\sf L-MMSE}
&=\mathbb{E}\left[\left. {\bf \tilde e}_k{\bf \tilde e}_k^{\sf H}\right|{\bf h}_k^{\sf ul},{\bf\Theta}_k,{\bf \Sigma}_k\right]\nonumber\\
&=\left(1-{\rm Re}\{\eta\}^2\right){\bf A}_k^{\sf dl}{\bf \Sigma}_k\left({\bf A}_k^{\sf dl}\right)^{\sf H}.
\end{align}
\end{cor}
\begin{IEEEproof}
The proof is straight from Appendix \ref{ProofForThm2}.
\end{IEEEproof}
Theorems \ref{thm:MseMatrxOfOptimal} and Corollary \ref{thm:MseMatrixOfLMSE} demonstrate that the MSE matrix is influenced by two elements: i) the DL array response matrix ${\bf A}_k^{\sf dl}$ and ii) the correlation matrix of the UL and DL path gain, $\eta{\bf \Sigma}_k$, as stated in Lemma \ref{lem1}. It is important to note that the MSE matrix changes based on the UL and DL frequency ratio $\frac{\lambda^{\sf ul}}{\lambda^{\sf dl}}$ as $\eta$ in \eqref{eq:eta}. To further comprehend this impact, we calculate the asymptotic MSE values for the proposed DL reconstruction algorithms, as stated in the following corollary.
\begin{cor}\label{cor:MMSE_Derivation} When using the MSE-optimal DL channel estimator in \eqref{eq: Optimal_Estimator}, the corresponding MSE is given by
\begin{align}
{\sf MSE}
&=\lim_{N\rightarrow \infty}\frac{1}{N}{\rm Tr}\left[ {\bf \Phi}_k^{\sf MMSE}\right] /{\rm Tr}\left[ {\bf \Sigma}_k\right]\nonumber\\
&=1-|\eta|^2.\label{eq:MSE_OptimalEstimator}
\end{align}
In addition, when using the linear MSE-optimal DL channel estimator in \eqref{eq:col1}, the corresponding MSE is given by
\begin{align}
{\sf L\text{-}MSE}
&=\lim_{N\rightarrow \infty}\frac{1}{N}{\rm Tr}\left[ {\bf \Phi}_k^{\sf L-MMSE}\right] /{\rm Tr}\left[ {\bf \Sigma}_k\right]\nonumber\\
&=1-{\rm Re}\{\eta\}^2.\label{eq:MSE_LinearEstimator}
\end{align}
\end{cor}
\begin{IEEEproof}
See Appendix \ref{Proof_for_Cor2}.
\end{IEEEproof}
Corollary \ref{cor:MMSE_Derivation} shows that both MSE and L-MSE deteriorate as the frequency gap increases. Fig. \ref{fig_Normalized_MSE_upper_mid_bands_Optimal} shows both the MSE (solid lines) and L-MSE (dotted lines) for different carrier frequencies in the upper-mid bands (7-23 GHz). In the simulation, the UL carrier frequency was fixed at 7.125, 10, 14.3, 17.7, or 21.2 GHz, and the DL carrier frequency was varied. Our results demonsrate that both MSE and L-MSE increase with the frequency gap, indicating that DL channel reconstruction from UL channel information is limited as the frequency gap grows.
\begin{figure}[t]
\subfigure[]{
\includegraphics[width=0.49\linewidth]{fig/fig_Normalized_MSE_upper_mid_bands_Optimal.eps}%
\label{fig_Normalized_MSE_upper_mid_bands_Optimal}
}
\subfigure[]{
\includegraphics[width=0.49\linewidth]{fig/fig_Normalized_MSE_Gap_with_Optimal.eps}%
\label{fig_Normalized_MSE_Gap_with_Optimal}
}
\caption{(a) The MSE with increasing DL carrier frequency over upper-mid bands and (b) the normalized MSE gap between the nonlinear MMSE and the L-MMSE estimators in terms of the carrier frequency ratio $\frac{f_c^{\sf ul}}{f_c^{\sf dl}}$.
}
\label{fig_Normalized_MSE}
\end{figure}
We also compute the difference between L-MSE and MSE in terms of the
carrier frequency ratio $\kappa$ as
\begin{align}
{\Delta{\sf MSE}}&=\left|\eta\right|^2-{\rm Re}\{\eta\}^2\nonumber\\&=\frac{\sin^4\left(\pi\kappa\right)}{\pi^2\left(1-\kappa\right)^2}.
\end{align}
The results shown in Fig. \ref{fig_Normalized_MSE_Gap_with_Optimal} indicate that within a 10$\%$ frequency deviation of $0.9\le\frac{f_c^{\sf ul}}{f_c^{\sf dl}}\le1.1$, the linear MSE-optimal DL channel estimator only causes a slight decrease in MSE compared to the optimal estimator. This deviation, which is commonly observed in practice, means that the use of the linear MSE-optimal DL channel estimator allows for a simplified implementation without sacrificing performance. We shall focus on the L-MMSE DL channel estimator in \eqref{eq:col1} in the sequel. For the national simplicity, we will replace ${\bf \hat h}_k^{\sf dl, L-MMSE}$ ${\bf\Phi}_k^{\sf L-MMSE}$ by ${\bf \hat h}_k^{\sf dl}$ and ${\bf \Phi}_k$, respectively hereafter.
\section{Robust DL Precoding}
In this section, we present a robust precoding algorithm that maximizes the sum-spectral efficiency using the DL channel reconstructed from the UL channel, ${\bf \hat h}_k^{\sf dl}$, and its MSE matrix, ${\bf \Phi}_k$. The algorithm begins by reviewing the sum-spectral efficiency maximization problem with imperfect CSIT (as introduced in \cite{choi2019joint}) and then presents a modified version taking into account ${\bf \hat h}_k^{\sf dl}$ and ${\bf \Phi}_k$ for robust DL precoding.
\subsection{Sum Spectral Efficiency Maximization}
Let us denote the downlink data symbol for user $k$ as $s_k\in\mathbb{C}$, and the corresponding precoding vector as ${\bf f}_k\in\mathbb{C}^{N\times 1}$. Under the assumption of Gaussian signaling, where $s_k$ follows a complex Gaussian distribution with mean 0 and variance $P$, the downlink transmit signal ${\bf x}\in\mathbb{C}^{N\times 1}$ can be expressed as a linear combination of $s_k$ and ${\bf f}_k$. That is,
\begin{align}
{\bf x}=\sum_{k=1}^{K}{\bf f}_ks_k.
\end{align}
The received signal at user $k$ is,
\begin{align}
y_k = \left({\bf h}_k^{\sf dl}\right)^{\sf H}{\bf f}_ks_k
+\left({\bf h}_k^{\sf dl}\right)^{\sf H}\sum_{i\ne k}{\bf f}_is_i
+z_k,
\end{align}
where $z_k\sim\mathcal{CN}(0,\sigma_k^2)$ is the complex Gaussian noise. Then, the signal-to-interference-plus-noise ratio (SINR) of user $k$ is given by
\begin{align}
{\sf SINR}_k
&= \frac{\left|\left({\bf h}_k^{\sf dl}\right)^{\sf H}{\bf f}_k\right|^2}{\sum_{i\ne k}\left|\left({\bf h}_k^{\sf dl}\right)^{\sf H}{\bf f}_i\right|^2+\sigma_k^2/P}=\frac{\sum_{i=1}^{K}{\bf f}_{i}^{\sf H}{\bf h}_{k}^{\sf dl}\left({\bf h}_k^{\sf dl}\right)^{\sf H}{\bf f}_{i}+{\sigma}_k^2/P}{\sum_{i\ne k}^{K}{\bf f}_{i}^{\sf H}{\bf h}_{k}^{\sf dl}\left({\bf h}_k^{\sf dl}\right)^{\sf H}{\bf f}_{i}+{\sigma}_k^2/P}.
\end{align}
With perfect CSIT, the DL sum-spectral efficiency is defined as
\begin{align}
R({\bf f}_1,\ldots, {\bf f}_K) &= \sum_{k=1}^K\log_2\left(1+{\sf SINR}_k\right) \nonumber\\
&=\log_2\left( \prod_{k=1}^{K}\frac{\sum_{i=1}^{K}{\bf f}_{i}^{\sf H}{\bf h}_{k}^{\sf dl}\left({\bf h}_k^{\sf dl}\right)^{\sf H}{\bf f}_{i}+{\sigma}_k^2/P}{\sum_{i\ne k}^{K}{\bf f}_{i}^{\sf H}{\bf h}_{k}^{\sf dl}\left({\bf h}_k^{\sf dl}\right)^{\sf H}{\bf f}_{i}+{\sigma}_k^2/P}\right). \label{eq:sumrate}
\end{align}
Under the sum-power constraint $\sum_{k=1}^{K}\left\|{\bf f}_k\right\|_2^2 = 1$, the sum-spectral efficiency maximization problem is given by
\begin{align}
\mathscr{P}^1:~&{\underset{\left\{{\bf f}_k\right\}_{k=1}^K\in \mathbb{C}^{N\times 1}}{\text{arg~max}}}~
R({\bf f}_1,\ldots, {\bf f}_K)\nonumber\\
&~\text{subject to} \sum_{k=1}^{K}\left\|{\bf f}_k\right\|_2^2 = 1.\label{eq:opt1}
\end{align}
\subsection{ Imperfect CSIT for Robust Precoding}
To solve the sum-spectral maximization problem in \eqref{eq:opt1}, either the DL channel ${\bf h}_{k}^{\sf dl}$ or its outer-product ${\bf h}_{k}^{\sf dl}\left({\bf h}_{k}^{\sf dl}\right)^{\sf H}$ must be known for each $k\in[K]$. However, in FDD, the exact outer-product ${\bf h}_{k}^{\sf dl}\left({\bf h}_{k}^{\sf dl}\right)^{\sf H}$ is unavailable and an approximation must be used for DL precoding. The following theorem shows the asymptotic error between ${\bf h}_{k}^{\sf dl}\left({\bf h}_{k}^{\sf dl}\right)^{\sf H}$ and the reconstructed CSIT using ${\bf \hat h}_{k}^{\sf dl}$ and ${\bf \Phi}_{k}$.
\begin{thm}\label{thm3}
Using the reconstructed DL CSIT, ${\bf \hat h}_{k}^{\sf dl}$ and ${\bf \Phi}_{k}$, the exact outer-product ${\bf h}_{k}^{\sf dl}\left({\bf h}_{k}^{\sf dl}\right)^{\sf H}$ is approximated by ${\bf\hat h}_k^{\sf dl}\left({\bf\hat h}_k^{\sf dl}\right)^{\sf H}+{\bf \Phi}_k$ with error matrix ${\bf \Delta}_k={\bf h}_k^{\sf dl}\left({\bf h}_k^{\sf dl}\right)^{\sf H}
-\left({\bf\hat h}_k^{\sf dl}\left({\bf\hat h}_k^{\sf dl}\right)^{\sf H}+{\bf \Phi}_k\right)$. Then, the asymptotic error in the number of antennas is
\begin{align}
&\lim_{N \to \infty}
\frac{1}{N^2}\left\|{\bf \Delta}_k\right\|_F^2 =\sum_{\ell\ne\ell'}2(1+{\rm Re}\{\eta\}^4)\left|{b}_{k,\ell}{b}_{k,\ell'}\right|^2-\sum_{\ell\ne\ell'}4{\rm Re}\{\eta\}^2{\rm Re}\left\{{g}_{k,\ell}^{\sf dl}\left({g}_{k,\ell'}^{\sf dl}\right)^*{g}_{k,\ell}^{\sf ul}\left({g}_{k,\ell'}^{\sf ul}\right)^*\right\}.
\end{align}
\end{thm}
\begin{IEEEproof}
See Appendix \ref{Proof_for_CovConvergence}.
\end{IEEEproof}
We provide our intuition for the proposed approximation in Theorem \ref{thm3}. The outer product of the DL channel is identical to our approximation in the average sense, i.e.,
\begin{align}
\mathbb{E}\left[{\bf h}_k^{\sf dl}\left({\bf h}_k^{\sf dl}\right)^{\sf H}\right]=\mathbb{E}\left[\hat{{\bf h}}_k^{\sf dl}\left(\hat{{\bf h}}_k^{\sf dl}\right)^{\sf H}+{\bf\Phi}_k\right],\quad\forall k\in[K].
\end{align}
This claim is true because
\begin{align}
&\mathbb{E}\left[\mathbb{E}\left[\left.{\bf h}_k^{\sf dl}\left({\bf h}_k^{\sf dl}\right)^{\sf H}-\hat{{\bf h}}_k^{\sf dl}\left(\hat{{\bf h}}_k^{\sf dl}\right)^{\sf H}~\right|~{\bf h}_k^{\sf ul},{\bf\Theta}_k,{\bf \Sigma}_k\right]\right]\nonumber\\
&=\mathbb{E}_{{\bf h}_k^{\sf ul},{\bf\Theta}_k,{\bf \Sigma}_k}\left[\left(1-{\rm Re}\{\eta\}^2\right){\bf A}_k^{\sf dl}{\bf \Sigma}_k\left({\bf A}_k^{\sf dl}\right)^{\sf H}\right]\nonumber\\
&=\mathbb{E}_{{\bf h}_k^{\sf ul},{\bf\Theta}_k,{\bf \Sigma}_k}\left[ {\bf \Phi}_k\right].
\end{align}
Consequently, our approximation is an unbiased estimator for ${\bf h}_k^{\sf dl}\left({\bf h}_k^{\sf dl}\right)^{\sf H}$. Furthermore, for the single-path scenario, our approximation becomes exact asymptotically, which is stated in the following corollary.
\begin{cor}\label{cor:Outer_Product_Convergence_LOS}
Under the LOS scenario, i.e., $L=1$, our approximation is tight, namely,
\begin{align}
\lim_{N \to \infty} \frac{1}{N^2}\left\|{\bf \Delta}_k\right\|_F^2 =0.
\label{eq:Outer_Product_Convergence_LOS}
\end{align}
\end{cor}
\begin{IEEEproof}
The proof is direct from the definition.
\end{IEEEproof}
\begin{figure}[t]
\centering
\includegraphics[width=0.5\linewidth]{fig/fig_FrobeniusNormAnalysis.eps}
\caption{The approximation error as function of the ratio of UL and DL channels according to the number of channel paths $L\in \{1,2,4,8,16\}$.} \label{fig_FrobeniusNormAnalysis}
\end{figure}
To validate the CSIT approximation accuracy, we plot the normalized error as the carrier frequency ratio changes. Fig. \ref{fig_FrobeniusNormAnalysis} shows that with increasing number of channel paths, the normalized error increases, meaning the accuracy of our DL channel reconstruction method decreases. However, as long as the UL and DL frequency difference is small, the error remains negligible, indicating accurate estimation of DL channel outer product with minimal error.
From Theorem \ref{thm3}, we reformulate the DL sum-spectral efficiency in \eqref{eq:sumrate} as
\begin{align}
{\hat R}({\bf f}_1,\ldots, {\bf f}_K)
&=\log_2\left( \prod_{k=1}^{K}\frac{\sum_{i=1}^{K}{\bf f}_{i}^{\sf H} \left(\hat{{\bf h}}_k^{\sf dl}\left(\hat{{\bf h}}_k^{\sf dl}\right)^{\sf H}+{\bf\Phi}_k \right){\bf f}_{i}+\frac{{\sigma}_k^2}{P}}{\sum_{i\ne k}^{K}{\bf f}_{i}^{\sf H}\left(\hat{{\bf h}}_k^{\sf dl}\left(\hat{{\bf h}}_k^{\sf dl}\right)^{\sf H}+{\bf\Phi}_k\right){\bf f}_{i}+\frac{{\sigma}_k^2}{P}}\right), \label{eq:sumrate2}
\end{align}
where $ {\hat{\bf h}}_{k}^{\sf dl} ={\rm Re}\{{\eta}\}{\bf A}_k^{\sf dl}\left({\bf A}_k^{\sf ul}\right)^{\dagger} {\bf h}_k^{\sf ul}$ represents the reconstructed DL channel, and ${\bf \Phi}_k=\left(1-{\rm Re}\{{\eta}\}^2\right)\cdot$ ${\bf A}_k{\bf \Sigma}_k{\bf A}_k^{\sf H}$ is the error covariance matrix. The DL sum-spectral efficiency in \eqref{eq:sumrate2} is an approximation that takes into account imperfect channel state information at the BS. The BS optimizes this rate function for the DL transmission.
The sum-spectral efficiency maximization is a well-known NP-hard problem \cite{luo2008dynamic}. The weighted MMSE algorithm is a widely used approach to tackle this optimization \cite{christensen2008weighted}. Recently, the GPIP algorithm was introduced, offering a comprehensive solution for joint user-selection, beamforming, and power allocation, and has shown to be the most effective solution for sum-spectral efficiency maximization in MU-MIMO systems, regardless of the number of antennas $N$ and users $K$ \cite{choi2019joint,han2020distributed,han2021sparse}. We take this approach for the robust DL precoding.
\subsection{Robust Precoding via GPIP }
The key idea of GPIP is to joinly optimize the precoding vectors $\left\{{\bf f}_1,\ldots, {\bf f}_K\right\}$. To accomplish this, we concatenate them into a high-dimensional optimization variable, i.e.,
\begin{align}
{\bf{f}} = [{\bf{f}}_{1}^{\sf{H}} ,\cdots, {\bf{f}}_{k}^{\sf{H}} ,\cdots, {\bf{f}}_{K}^{\sf{H}} ]^{\sf {H}}\in \mathbb{C}^{NK\times 1}. \label{eq:Large_BF}
\end{align}
By utilizing the high-dimensional optimization variable, the expression of the sum-spectral efficiency in \eqref{eq:sumrate2} can be reformulated as a product of Rayleigh quotients, thus providing a more compact representation:
\begin{subequations}
\label{eq:P_Proposed_PCA}
\begin{align}
\mathscr{P}^2:~&{\underset{{\bf f}\in \mathbb{C}^{NK\times 1}}{\text{arg~max}}}~ \prod_{k=1}^{K}\frac{{{\bf f}^{\sf H}{\bf A}_{k}{\bf f}}}{{{\bf f}^{\sf H}{\bf B}_{k}{\bf f}}},\label{eq:P_Proposed_PCA_1}\\
&\text{subject to } \|{\bf f}\|_2^2=1,\label{eq:P_Proposed_PCA_2}
\end{align}
\end{subequations}
where ${\bf A}_k\in\mathbb{C}^{NK\times NK}$ and ${\bf \Sigma}_k\in\mathbb{C}^{NK\times NK}$ are positive semi-definite block diagonal matrices defined as
\begin{align}
{\bf A}_{k}&={\bf I}_K \otimes \left({\bf \hat h}_k^{\sf dl}\left({\bf \hat h}_k^{\sf dl}\right)^{\sf H}+{\bf \Phi}_k\right) + \frac{\sigma_k^2}{P}{\bf I}_{NK},\label{eq:A}\\
{\bf B}_{k}&={\bf A}_{k}-{\bf 1}_k{\bf 1}_k^{\sf T}\otimes \left({\bf \hat h}_k^{\sf dl}\left({\bf \hat h}_k^{\sf dl}\right)^{\sf H}+{\bf \Phi}_k\right). \label{eq:B}
\end{align}
As shown in \cite{choi2019joint}, the objective function in \eqref{eq:P_Proposed_PCA_1} is scale invariant, we can drop the power constraint in \eqref{eq:P_Proposed_PCA_2}, which boils down to
\begin{align}
\mathscr{P}^3:~{\underset{{\bf f}\in \mathbb{C}^{NK\times 1}}{\text{arg~max}}}~\prod_{k=1}^{K}\frac{{{\bf f}^{\sf H}{\bf A}_{k}{\bf f}}}{{{\bf f}^{\sf H}{\bf B}_{k}{\bf f}}}.\label{eq:P_Proposed_Final}
\end{align}
Extending the result in \cite{choi2019joint}, we identify the local optimal solution for the sum-spectral efficiency maximization problem in \eqref{eq:P_Proposed_Final}. The following theorems state the first- and second-order optimality conditions.
\begin{thm}\label{thm4}
Let $\gamma({\bf f})=\prod_{k=1}^{K}\frac{{{\bf f}^{\sf H}{\bf A}_{k}{\bf f}}}{{{\bf f}^{\sf H}{\bf B}_{k}{\bf f}}}$. A stationary point ${\bf f}\in \mathbb{C}^{NK\times 1}$ for problem \eqref{eq:P_Proposed_Final} is an eigenvector of the following functional generalized eigenvalue problem:
\begin{align}
{\bf \bar A}\left({\bf f}\right){\bf f}
=\gamma({\bf f}){\bf \bar B}\left({\bf f}\right){\bf f},\label{eq:Generalized_Eigenvalue_Problem}
\end{align}
where
\begin{align}
{\bf \bar A}\left({\bf f}\right) = \sum_{i=1}^{K}
\left
\prod_{k\ne i}{\bf f}^{\sf H}{\bf A}_{k}{\bf f}
\right){\bf A}_{i}
~and~{\bf \bar B}\left({\bf f}\right) = \sum_{i=1}^{K}
\left
\prod_{k\ne i}{\bf f}^{\sf H}{\bf B}_{k}{\bf f}
\right){\bf B}_{i}.
\end{align}
\end{thm}
\begin{IEEEproof}
See Appendix \ref{Proof_for_LOC_First}.
\end{IEEEproof}
Theorem 4 shows that the stationary point of optimization problem in \eqref{eq:P_Proposed_Final} can be found by identifying the ${\bf f}$ that satisfies condition in \eqref{eq:Generalized_Eigenvalue_Problem}. This condition can be represented as a generalized eigenvalue problem: $\left[{\bf \bar B}\left({\bf f}\right)\right]^{-1}{\bf \bar A}\left({\bf f}\right){\bf f}=\gamma({\bf f}){\bf f}$, where $\gamma({\bf f})$ is the eigenvalue of $\left[{\bf \bar B}\left({\bf f}\right)\right]^{-1}{\bf \bar A}\left({\bf f}\right)$ and ${\bf f}$ is the corresponding eigenvector. The eigenvalue $\gamma({\bf f})$ also represents the objective function in \eqref{eq:P_Proposed_Final}. To maximize this function, we must find the first eigenvector of $\left[{\bf \bar B}\left({\bf f}\right)\right]^{-1}{\bf \bar A}\left({\bf f}\right)$.
\begin{thm} \label{thm5}
Let ${\bf f}^{\star}$ be the solution of Theorem \ref{thm4}. This stationary point ${\bf f}^{\star}$ is a local-optimum, provided that
\begin{align}
&\rho_{\sf min}\left(\sum_{i=1}^{K} \frac{{\bf A}_i^{\sf H}{\bf f}^{\star}({\bf f}^{\star})^{\sf H}{\bf A}_i}{\left(({\bf f}^{\star})^{\sf H}{\bf A}_i{\bf f}^{\star}\right)^2} \right) >
\rho_{\sf max}\left(\sum_{i=1}^{K} \frac{{\bf B}_i^{\sf H}{\bf f}^{\star}({\bf f}^{\star})^{\sf H}{\bf B}_i}{\left(({\bf f}^{\star})^{\sf H}{\bf B}_i{\bf f}^{\star}\right)^2}\right). \label{eq:Sub_Opt_Condition}
\end{align}
\end{thm}
\begin{IEEEproof}
See Appendix \ref{Proof_for_LOC_Second}.
\end{IEEEproof}
According to Theorem \ref{thm5}, if the minimum eigenvalue of $\sum_{i=1}^{K} \frac{{\bf A}_i^{\sf H}{\bf f}^{\star}({\bf f}^{\star})^{\sf H}{\bf A}_i}{\left(({\bf f}^{\star})^{\sf H}{\bf A}i{\bf f}^{\star}\right)^2}$ is greater than the maximum eigenvalue of $\sum_{i=1}^{K} \frac{{\bf B}_i^{\sf H}{\bf f}^{\star}({\bf f}^{\star})^{\sf H}{\bf B}_i}{\left(({\bf f}^{\star})^{\sf H}{\bf B}_i{\bf f}^{\star}\right)^2}$, then the stationary point ${\bf f}^{\star}$ has a direction of strictly negative curvature. This eigenvalue test allows us to determine if a stationary point ${\bf f}^{\star}$ is the local optimal solution for a non-convex optimization problem. The maximum and minimum eigenvalues can be calculated using either power iteration or inverse power iteration algorithms.
\begin{algorithm}[t]
\caption{Proposed Robust DL Precoding}
Initialization: $t=1,~ {\bf f}^{(1)}={\sf ZF},~ {\bf f}^{(0)}={\bf 0},~{\text{and }} \epsilon$\;
\While{$t\ne 0$}
{ $t\gets t+1$;\;
\eIf{$\left|\gamma\left({\bf f}^{(t-1)}\right)-\gamma\left({\bf f}^{(t)}\right)\right|/\gamma\left({\bf f}^{(t-1)}\right)\ge\epsilon$}
{
${\bf f}^{(t)} \gets \left[{\bf \bar B}\left({\bf f}^{(t-1)}\right)\right]^{-1}{\bf \bar A}\left({\bf f}^{(t-1)}\right){\bf f}^{(t-1)}$;\;
${\bf f}^{(t)} \gets \frac{{\bf f}^{(t)}}{\left\|{\bf f}^{(t)}\right\|_2}$;\;
}{
\eIf{Theorem \ref{thm5} holds}
{
Break;
}{
$t=1 \text{ and }{\bf f}^{(1)} = $ Random beamforming;\;
Continue;
}
}
}
\label{alg:Proposed}
\end{algorithm}
We present a computationally efficient algorithm that identifies the solution satisfying the first and second order optimality conditions derived in Theorem \ref{thm4} and \ref{thm5}, as introduced in our companion paper \cite{choi2019joint,han2020distributed,han2021sparse}. The proposed algorithm iteratively finds the local-optimum ${\bf f}^{\star}$. At each iteration, it starts by constructing the functional matrices ${\bf \bar A}\left({\bf f}^{(t-1)}\right)$ and $ {\bf \bar B}\left({\bf f}^{(t-1)}\right)$ based on the precoding vector ${\bf f}^{(t-1)}$ obtained in the previous iteration. Next, the first eigenvector of $\left[ {\bf \bar B}\left({\bf f}^{(t-1)}\right) \right]^{-1}
{\bf \bar A}\left({\bf f}^{(t-1)}\right)$ is found through a power-iteration process \cite{lee2008achievable}. The updated ${\bf f}^{(t)}$ is then obtained using the equation: ${\bf f}^{(t)}=\left[ {\bf \bar B}\left({\bf f}^{(t-1)}\right) \right]^{-1}
{\bf \bar A}\left({\bf f}^{(t-1)}\right){\bf f}^{(t-1)}$ and normalized to have a unit length.
The iteration continues until the objective function converges, with the stopping criteria being $\left|\gamma\left({\bf f}^{(t-1)}\right)-\gamma\left({\bf f}^{(t)}\right)\right|/\gamma\left({\bf f}^{(t-1)}\right)\le\epsilon$, where $\epsilon$ is a small positive value. After the algorithm reaches convergence at $t=T$, the solution ${\bf f}^{(T)}$ is checked against the second-order necessary optimality condition of Theorem \ref{thm5}. If it satisfies the condition, the algorithm ends with ${\bf f}^{(T)}$. Otherwise, it restarts with a new starting vector. The entire process is summarized in Algorithm \ref{alg:Proposed}.
\begin {table}[t]
\footnotesize
\caption {System-Level Simulation Parameters} \vspace{-0.1cm}\label{tab:Sys_Assumption}
\begin{center}
\begin{tabular}{ l c }
\hline\hline
Parameters & Value \\ \hline
BS topology & Single hexagonal cell with ISD 500m \\
User distribution & Uniform per cell \\
UL carrier frequency & 10 GHz \\
DL carrier frequency & 12 GHz ($f_c^{\sf dl}/f_c^{\sf ul}=1.2$)\\
The number of users $K$ & $16$\\
Noise power & -113dB\\
Path-loss model & Standard model at TR 38.901\\
BS/UE height & 32m/1.5m\\ \hline
\end{tabular}
\end{center}\vspace{-0.3cm}
\end {table}
\begin{rem}[Computational complexity of the proposed precoding framework]
The computational complexity of our precoding algorithm is of the order of $\mathcal{O}(JN^2K)$, as reported in various studies including \cite{choi2019joint,han2020distributed,han2021sparse,park2022rate}. This is a significant improvement over the WMMSE method \cite{christensen2008weighted} whose complexity order is $\mathcal{O}\left(J(KN)^{3.5}\right)$. Our algorithm demonstrates more computational efficiency compared to the WMMSE approach.
\end{rem}
\section{Simulations Results}\label{sec:Simulation_Results}
In this section, we present a comprehensive comparison of the ergodic sum-spectral efficiency achieved by our proposed algorithm with existing precoding schemes \cite{christensen2008weighted} using system-level simulations. The simulation parameters and network topology are outlined in detail in Table \ref{tab:Sys_Assumption}. Our simulations consider a fixed base station location, with randomly distributed user locations for each scenario. This ensures a fair evaluation of the algorithm's performance under various network conditions.
\begin{figure}[t]
\centering
\includegraphics[width=0.5\linewidth]{fig/fig_K16R250L3UpperMid.eps}
\caption{The ergodic sum-spectral efficiency with $(L,K)=(3,16)$ as increasing the number of antennas.} \label{fig_K16R250L3UpperMid}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=0.5\linewidth]{fig/fig_K16R250L3UpperMid_GainAnalysis.eps}
\caption{The ergodic sum-spectral efficiency with $(L,K)=(3,16)$ according to channel knowledge and precoding strategies. } \label{fig_K16R250L3UpperMid_GainAnalysis}
\end{figure}
\subsection{Effects of Geometric Parameter Estimation Error}
Fig. \ref{fig_K16R250L3UpperMid} shows the growth of the ergodic sum-spectral efficiency as the number of antennas increases. The proposed algorithm is evaluated in two scenarios: with perfect knowledge of the geometry parameters $\left\{{\bf h}_k^{\sf ul},{\bf\Theta}_k,{\bf \Sigma}_k\right\}$ and with imperfect knowledge estimated via spatial smoothing and least-squared estimation $\left\{{\bf \hat h}_k^{\sf ul},{\bf \hat \Theta}_k,{\bf \hat \Sigma}_k\right\}$. The results show that the proposed algorithm attains the ergodic sum-spectral efficiency of ZF and WMMSE when evaluated with perfect DL CSIT. When evaluated with estimated geometry parameters, the degradation caused by estimation error is minimal.
\subsection{Effects of CSIT Knowledge and Precoding}
Fig. \ref{fig_K16R250L3UpperMid_GainAnalysis} compares the achievable ergodic sum-spectral efficiency gains based on CSIT knowledge and precoding strategies. ZF precoding with perfect UL channel knowledge is plotted as a benchmark, followed by ZF precoding with DL channel reconstructed from UL channel. The improvement in performance is significant, demonstrating the effectiveness of the DL reconstruction method. The proposed GPI precoding outperforms ZF precoding when both uses the DL reconstructed channel knowledge, due to precoding optimization. When using both DL channel knowledge and DL channel covariance, the proposed GPIP improves the sum-spectral efficiency greatly and the performance gap with WMMSE decreases with increasing antenna numbers.
\begin{figure}[t]
\centering
\includegraphics[width=0.5\linewidth]{fig/fig_K16R250L24816UpperMid.eps}
\caption{The ergodic sum-spectral efficiency as increasing the number of channel paths $L$. The number of users is set to be $K=16$.} \label{fig_K16R250L24816UpperMid}
\end{figure}
\subsection{Effects of the Number of Channel Paths}
Fig. \ref{fig_K16R250L24816UpperMid} demonstrates the deterioration of ergodic sum-spectral efficiency as the number of paths increases. The simulations were conducted with $L$ values of 2, 4, 8, and 16. As the number of paths increases, two algorithmic issues arise: 1) an increase in the estimation error of geometric parameters, leading to a decline in DL channel reconstruction, and 2) a reduction in orthogonality in the spatial domain, resulting in a decrease in robust precoding gain. These simulation results highlight the robustness of the proposed framework to both channel reconstruction error and moderate values of $N/L$. As seen in Fig. \ref{fig_K16R250L24816UpperMid}, the proposed algorithm remains robust even when $N/L$ exceeds 16, which is equivalent to 256 divided by 16.
\begin{figure}[t]
\centering
\includegraphics[width=0.5\linewidth]{fig/fig_CovergenceSpeed.eps}
\caption{The convergence rate of the proposed GPIP when $\epsilon=0.1$ and $\epsilon=0.01$.} \label{fig_CovergenceSpeed}
\end{figure}
\subsection{Convergence Property}
Fig. \ref{fig_CovergenceSpeed} illustrates the convergence rate of Algorithm \ref{alg:Proposed}. Our investigation focuses on determining the number of iterations required to meet the stopping criteria as we increase the number of BS antennas, i.e., $N\in\left\{16,64,256\right\}$. As depicted in Fig. \ref{fig_CovergenceSpeed}, the proposed algorithm requires only five iterations to reach the desired precision of $\epsilon=0.1$. The maximum number of iterations necessary to achieve $\epsilon=0.01$ is ten, indicating a fast convergence rate for the proposed algorithm.
\section{Conclusion}
We introduced a novel robust DL data transmission framework that provides substantial sum-spectral efficiency gains in FDD massive MIMO systems without CSI feedback. Our approach leverages the geometric reciprocity between UL and DL channels to reconstruct the DL channel. Using these reconstructed DL channel and the corresponding error covariance matrix, we developed a robust DL precoding method that maximizes sum-spectral efficiency. Our major finding was that the FDD massive MIMO gains is still attainable without CSI training and feedback. Throughout the system-level simulations, we verified our results.
| {'timestamp': '2023-02-10T02:04:16', 'yymm': '2302', 'arxiv_id': '2302.04398', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04398'} | arxiv |
\section{Introduction}
\label{intro}
Motivated by a real-world problem faced by the company Sportradar, which provides betting odds on sports matches, we study a complex personnel scheduling problem. Workers are assigned tasks for supervision.
Each worker has a specific set of skills that allows them to cover different tasks with varying levels of difficulty. Workers may work on multiple tasks in parallel, with their personal skill determining the limit for parallel tasks. Furthermore, each worker provides their availabilities, within which their shifts can be scheduled. Each worker has requirements for break as well as rest times, depending on the legal requirements at the worker's location. Breaks may be split into parts, however each break incurs a preparation time that is required before resuming work following the break.
The number of tasks exceeds the
capacity for coverage. Each task has a given
priority score
and asks for a specific skill level in the corresponding task group. The objective is to maximize the total priority score of all assigned tasks, while minimizing the penalty incurred for assigning operators with a skill level lower than the one desired for the assigned tasks.
We propose a mixed integer linear programming (MIP) formulation for the considered problem and we develop an adaptive large neighborhood search (ALNS) algorithm to solve large-scale instances in a short amount of time. We compare the solutions obtained by the heuristic approach with optimal solutions obtained from solving the developed MIP model
with CPLEX. Furthermore, the proposed ALNS
is applied to large-scale real-world data provided by Sportradar. We note that the ideas proposed in this paper
are not limited to the application to the considered problem, but may
be used in solution approaches to other personnel scheduling, rostering and timetabling problems. Their main focus is the requirement of task selection and assignment based on priority scores. Similar problems can be found in aviation and railway traffic like flight cancellations due to general staff shortages or strikes, as well as medical triage.
The remainder of the paper is structured
as follows. In Section \ref{rel}, we provide an overview of related work and we present, in Section \ref{def},
the developed mathematical model.
Section \ref{method} is devoted to the description of the proposed adaptive large neighborhood search algorithm.
In Sections \ref{results} and \ref{study}, computational results are presented,
including information on the
proposed test instances, comparison to optimal and to company solutions
as well as managerial insights derived from changes in the weights of the objective function. Section \ref{conc} concludes the paper and provides possible directions for future research.
\section{Related Work}
\label{rel}
To the best of our knowledge, the problem proposed in this paper has not been considered in the literature before. However, it shares characteristics with a number of well-studied problems. Therefore,
we review the literature in each of these different areas and point to the main differences and similarities between the reviewed work and the problem considered in this paper.
First and foremost, the problem proposed in this paper belongs to the field of personnel scheduling and rostering problems. With the main goal of the problem being the construction of a schedule for available operators by assigning tasks that already have starting and ending times, the problem is related to
staff scheduling problems arising in the airline industry, in (public) transportation, or hospitals.
A main difference between the problem addressed in this paper and those staff scheduling problems
is the possibility to carry out multiple tasks in parallel.
\cite{chu2007generating}, e.g., propose a goal programming approach for scheduling and rostering airport personnel and \cite{maenhout2010hybrid} develop a hybrid scatter search approach for the
airline crew rostering problem.
\cite{yunes2005hybrid} consider the crew scheduling and rostering problem in an urban bus transit problem and solve it by means of hybrid column generation approaches. A nurse rostering problem, considering shift assignments and rest times, is, e.g., solved by \citet{solos2013generic} using variable neighborhood search.
Differing from the problem addressed in this paper, a majority of the research on personnel rostering specifically requires to cover all tasks, with objectives often targeting minimization of (assignment) costs. However, also alternative objectives are addressed, such as, e.g., equity in terms of workload targets \citep{prot2015two}.
From a methodological point of view, \cite{barrena2013fast} as well as \cite{dong2020integrated} successfully implement ALNS for train scheduling and timetabling problems, while \cite{mansini2019optimizing} use ALNS to schedule physicians in a hospital ward and \cite{sorensen2012international} apply ALNS to high school timetabling.
A subfield of personnel scheduling that is
relevant for the problem addressed in this paper, is the field of multi-skilling problems,
where each worker has a set of predefined skills that enable them to carry out a certain subset of the available
tasks. \cite{cuevas2016mixed}, e.g., propose a mixed integer program for the short-term multi-skilled workforce tour scheduling problem,
where workers' shifts and days off are planned while assigning activities to shifts.
\cite{de2018three} propose a three stage MIP approach for optimizing skill mix and training schedules for aircraft maintenance personnel. Furthermore, \cite{KPDH10} use ALNS to solve the problem of service technician routing and scheduling to minimize coverage cost, while also taking skill levels of technicians into account.
The problem considered in this paper
also features the aspect of task selection:
tasks need to be chosen from a large pool of available tasks with the goal of maximizing the total benefit of covered tasks. While \cite{vijaykumar1998task} already considered the problem of task selection for a multiscalar processor in the last millennium, the field only recently received more attention. \cite{song2010novel}, e.g., consider task selection and allocation for collaborative cloud service platforms and solve the problem using an adaptive filter in combination with a heuristic algorithm. Related problems are often considered in the context of crowd-sourcing. \cite{abououf2019multi} consider multi-worker multi-task selection in mobile crowd sourcing using a genetic as well as a tabu search algorithm, while \cite{deng2016task} consider task selection for spatial crowd-sourcing with the help of dynamic programming and branch-and-bound. \cite{li2018task} propose a game theoretical approach to solve the problem of task selection and scheduling for food delivery and \cite{shaghaghi2017task} consider task selection and scheduling for multifunction radar systems and solve the problem to optimality using branch-and-bound.
Due to the requirement of
task selection and assignment to build shifts that contain the highest-value tasks, the problem can also be seen
as a generalization of the bin packing problem.
Reformulations of scheduling problems as bin packing problems have been proposed going back as far as the 1970s \citep{garey1976resource,coffman1978application}.
\cite{leinberger1999multi} consider multi-capacity bin packing with application to job scheduling problems and \cite{vijayakumar2013dual} formulate a dual bin packing approach in order to schedule surgical cases in a hospital. More recently,
\cite{li2018single} have considered a single bin packing machine scheduling problem with two-dimensional bin packing constraints and \cite{witteman2021bin} address
aircraft maintenance task allocation from a bin packing perspective. Using a hybrid genetic based approach, \cite{su2021hybrid} consider the problem of unrelated parallel workgroup scheduling from a bin packing perspective. Related to the approach considered in this paper, ALNS has been successful at solving bin packing problems. \cite{he2021adaptive} use ALNS to solve the circle bin packing problem and \cite{zeng2021adaptive} propose an ALNS approach for single machine batch processing with two-dimensional bin packing constraints while \cite{zeng2021adaptive2} apply ALNS to a two-dimensional packing problem with conflict penalties.
The problem considered in this paper is also related to resource-constrained project scheduling problems (RCPSPs) in that the assignment of tasks to workers must take capacity restrictions on each worker into account. In contrast to general RCPSPs however, tasks are independent of one another and have fixed starting and ending times. The goal is therefore to use the available resources (worker capacity) as efficiently as possible by choosing the most valuable tasks. Recent research on RCPSPs has, e.g., addressed
resource leveling
to keep the use of a scarce resource as balanced as possible \citep{li2018effective} and flexible resource profiles in which resource usage may vary at different times \citep{naber2014mip}.
Alternative activity chains are, e.g., considered by \cite{tao2017scheduling} and \cite{hauder2020resource}.
\cite{lova2000multicriteria} address
RCPSPs with objectives differing from the usual minimization of the makespan as well as multiple projects running in parallel.
Heuristic approaches related to the approach developed in our paper have been used for RCPSPs to great success, for example by \cite{palpant2004lssper} as well as by \cite{muller2009adaptive,muller2011adaptive}.
Based on the personnel scheduling
literature review of
\cite{van2013personnel}, the problem we address falls into the class
of personnel task scheduling problems, which is defined as follows \citep{krishnamoorthy2001personnel}: a set of tasks with fixed start and end times have to be assigned to a workforce with different qualifications allowing them to carry out only a subset of the available tasks within predefined shifts. In the shift minimization task scheduling problem (SMTSP), the objective is to minimize the total number of employees. The SMTSP relates to list coloring on interval graphs \citep{smet2014shift}, which is NP-complete \citep{bonomo2009exploring}.
We introduce several new aspects
not considered in the original definition, most important of which is the required task selection. We therefore refer to the proposed problem as personnel task scheduling problem with task selection (PTSP-TS).
The PTSP-TS generalizes the interval scheduling problem with given machines, where a set of tasks with given start and end times is to be scheduled on a given set of machines and the objective is to maximize the (weighted) number of assigned tasks \citep{kolen2007interval}. The variant where tasks may only be carried out by a subset of the machines (which relates to the skill requirements considered in this paper), is known to be NP-hard \citep{kolen2007interval,arkin1987scheduling}.
\section{Problem Definition}
\label{def}
\allowdisplaybreaks
In the PTSP-TS, tasks are to be assigned to operators to maximize the benefit of covered tasks, while minimizing the penalty incurred from assigning lower-skilled operators. In Figure \ref{figure:1}, we show the solution obtained for a toy example using three operators and a total of 996 assignable tasks. Each operator has given skills to cover different tasks. In our application, these skills concern the supervision of different types of sports games.
In the considered planning horizon of 34 hours, shifts are to be constructed within five availabilities. In the figure, each of these availabilities is represented by a rectangle coloured in teal. The planned shift within the availability is depicted by a blue frame.
In addition, we give its starting and ending times. Within each shift, each assigned task is represented by a purple rectangle. Its length represents the actual length of the task. The provided floating point value represents the amount of an operator's attention a task requires, later referred to as required bandwidth. The gray bars within a shift give the operator's bandwidth usage. Their heights vary depending on the total bandwidth currently required. Gray bars reaching the top of the shift frame indicate that the bandwidth is fully used. This is, e.g., the case for Operator A with only two tasks in the beginning of the second shift, while six parallel tasks can be feasibly assigned towards the end of the shift. Below each operator, we display the total assignment score of all the tasks assigned to an operator and the total penalty from assignments below the operator's provided skill level. In this toy example, no tasks below the operators' skill levels are assigned. Therefore, this value is zero.
\begin{figure}
\caption{Graphical display of the assignment of tasks to operators for a toy example} \label{figure:1}
\includegraphics[width=\textwidth, frame]{toy.PNG}
\centering
\end{figure}
In order to more formally state the problem,
we define a set of tasks $V$ and a set of operators $O$. Each task $i$ has a given priority $p_i$, as well as known requirements for working capacity $b_{is}$ (referred to as bandwidth) depending on
the shift $s$ it is assigned to. We note that we do not explicitly model operators but shifts of operators where the bandwidth requirement depends on the operator $o$ the shift $s$ belongs to. The set $S_o$ contains the shifts of operator $o$. Each task requires a specific skill level. Assignments to shifts of lower skilled operators incur a penalty of $d_{is}$. Operators which do not dispose of a certain skill at all cannot be assigned tasks requiring the respective skill. Each task belongs to one task group $\sigma$ out of the set of task groups $P$. The set of all tasks $V$ is composed of a set of mandatory tasks $U$ that have to be assigned and a set of optional tasks $W$ ($V = U \cup W$).
We consider time to be discrete with an available number of time buckets $|T|$.
Each operator defines a set of availability periods (referred to as availabilities). Within each availability at most one shift can be planned.
As such, each shift is limited by its corresponding availability given by earliest starting time $e_s$ and latest ending time $l_s$; $T_s$ provides the set of time buckets in which shift $s$ can be planned. Likewise, each task $i$ has a set of time buckets $R_i$ it occupies. Then, the set $V_{st}$ gives the set of tasks that can be assigned to shift $s$ in time bucket $t$.
In addition, a minimum shift length $\alpha_s$ and a maximum shift length $\omega_s$ is specified. Every shift has requirements specific to each operator $o$ for break length $\gamma_o$ as soon as the maximum duration of a shift without break $\chi_s$ is exceeded, as well as rest length $\delta_o$ in between shifts of operator $o$. This implies that there may be availabilities in which no shifts are planned. The total break length may be consumed over multiple smaller breaks. However, each partial break has to have a minimum length $\beta_o$, depending on the operator $o$, and each separate break requires a preparation time $\rho$, during which an operator cannot perform any tasks. This preparation time does not count towards the length of the break. Each shift has further limitations on breaks by only allowing breaks after $\nu_s$ hours and only up until $\lambda_s$ hours into the shift.
The complete list of notation used for parameters and variables is given in Table \ref{tbl:params}. Using this notation,
we formulate the PTSP-TS as the following binary linear program:
\begin{table}[t!b]
\caption{Notation \label{tbl:params}}
\centering
\small
\begin{tabular}{lll}
\toprule
Sets and parameters && \\
\midrule
$T$ & set of time buckets \\
$U$ & set of mandatory tasks \\
$W$ & set of optional tasks \\
$V = U \cup W$ & set of all tasks \\
$O$ & set of operators \\
$S$ & set of shifts \\
$S_o$ & set of shifts of operator $o$ \\
$S_i$ & set of shifts that can cover task $i$ \\
$T_s$ & set of time buckets of availability period in which shift
$s$ can be planned\\
$R_i$ & set of time buckets of task $i$ \\
$V_{st}$ & set of tasks that can be assigned to shift $s$ in time bucket $t$ \\
$P$ & set of task groups \\
\\
$[e_s,l_s]$ & earliest starting time and latest ending time of shift $s$ (availability)\\
$b_{is}$ & required bandwidth of task $i$ in shift $s$ \\
$p_i$ & priority score of task $i$ \\
$d_{is}$ & skill deviation of task $i$ if assigned to shift $s$ \\
$\alpha_s$ & minimum duration of shift $s$ \\
$\omega_s$ & maximum duration of shift $s$ \\
$\chi_s$ & maximum duration of shift $s$ without requiring a break \\
$\rho$ & preparation time \\
$\beta_o$ & minimum partial break duration of operator $o$ \\
$\gamma_o$ & minimum total break duration of operator $o$ \\
$\delta_o$ & minimum rest duration of operator $o$\\
$[\nu_s,\lambda_s]$ & time window of break for shift $s$\\
$w_1$,$w_2$ & weights of objectives in the objective function \\
$k$ & upper limit on the number of different groups for parallel tasks \\
\toprule
Decision variables && \\
\midrule
\multicolumn{2}{l}{$x_{is}$=
$\begin{cases}
1, & \text{if task $i$ is assigned to shift $s$}\ \\
0, & \text{otherwise}
\end{cases}$}\\
\multicolumn{2}{l}{$u_{st}$=
$\begin{cases}
1, & \text{if shift $s$ is activated in time bucket $t$}\ \\
0, & \text{otherwise}
\end{cases}$} \\
\multicolumn{2}{l}{$r_{st}$=
$\begin{cases}
1, & \text{if shift $s$ deactivated in time bucket $t$}\ \\
0, & \text{otherwise}
\end{cases}$} \\
\multicolumn{2}{l}{$v_{st}$=
$\begin{cases}
1, & \text{if time bucket $t$ in shift $s$ counts as break}\ \\
0, & \text{otherwise}
\end{cases}$} \\
\multicolumn{2}{l}{$a_{ts\sigma}$=
$\begin{cases}
1, & \text{if task of group $\sigma$ is assigned in time bucket $t$ in shift $s$}\ \\
0, & \text{otherwise}
\end{cases}$} \\
\multicolumn{2}{l}{$z_s$=
$\begin{cases}
1, & \text{if shift $s$ is enabled}\ \\
0, & \text{otherwise}
\end{cases}$} \\
\multicolumn{2}{l}{$\hat{z}_s$=
$\begin{cases}
1, & \text{if shift $s$ requires a break} \\
0, & \text{otherwise}
\end{cases}$} \\
\bottomrule
\end{tabular}
\end{table}
\allowdisplaybreaks
\begin{align}
\max \hspace{2mm} w_1 \sum_{i\in V} \sum_{s \in S_i} p_i x_{is} - w_2 \sum_{i \in V} \sum_{s \in S_i} d_{is} x_{is} \label{objf}
\end{align}
subject to:
\begin{align}
\sum_{s \in S_i} x_{is} & = 1 && \forall i \in U \label{eq1}\\
\sum_{s\in S_i} x_{is} & \leq 1 && \forall i \in W \label{eq2}\\
x_{is} & \leq z_s && \forall i \in V, s \in S_i \label{eq3}\\
\sum_{i \in V_{st}} x_{is} b_{is} & \leq u_{st} && \forall s \in S, t \in T_s \label{eq4}\\
u_{st+1} & \geq u_{st} && \forall s \in S, t \in T_s, t \leq |T_s|-1 \label{eq5}\\
\sum_{t=e_s}^{l_s} u_{st}& \leq z_sM && \forall s \in S \label{eq6}\\
r_{st+1}& \geq r_{st} && \forall s \in S, t \in T_s, t \leq |T_s|-1\label{eq7}\\
\sum_{i \in V_{st}} x_{is} b_{is} & \leq 1-r_{st} && \forall s \in S, t \in T_s \label{eq8}\\
\sum_{t=e_s}^{l_s} r_{st} & \leq z_sM && \forall s \in S \label{eq9}\\
\sum_{t=e_s}^{l_s} (u_{st} - r_{st}) & \geq \alpha_s z_s && \forall s \in S\label{eq10}\\
\sum_{t=e_s}^{l_s} (u_{st} - r_{st}) & \leq \chi_s z_s + (\omega_s - \chi_s) \hat{z}_s && \forall s \in S\label{eq10b}\\
\sum_{t'=t+1}^{t+\rho} \sum_{i \in V_{st'}} x_{is}b_{is} & \leq \rho - \rho v_{st} && \forall s \in S, t \in T_s, t \leq l_s-\rho \label{eq11}\\
\sum_{i \in V_{st}} x_{is} b_{is} & \leq 1 - v_{st} && \forall s \in S, t \in T_s \label{eq12}\\
\sum_{t=e_s}^{l_s} v_{st} & \geq \gamma_o\hat{z}_s && \forall o \in O, s \in S_o \label{eq13} \\
v_{st} & \leq u_{st} - r_{st} && \forall s \in S, t \in T_s \label{eq14} \\
v_{st} & \leq u_{s,t-\nu_s} && \forall s \in S, t \in T_s, t \geq \nu_s \label{eq15}\\
v_{st} & \leq 1-u_{s,t-\lambda_s+1} && \forall s \in S, t \in T_s, t \geq \lambda_s \label{eq16}\\
\sum_{t' = t+1}^{t + \beta_o -1} v_{st'} &\leq \beta_o (v_{st} + v_{s,t+\beta_o}) && \forall o \in O, s \in S_o, t \in T_s, t \leq |T_s|-\beta_o \label{eq17}\\
a_{ts\sigma} & \geq x_{is} && \forall s \in S, i \in V, t \in R_i, \sigma \in P, \label{eq18}\\
\sum_{\sigma \in P} a_{ts\sigma} & \leq k && \forall s \in S, t \in T_s \label{eq19}\\
\sum_{t'=t+1}^{t+\delta_o} u_{s't'} & \leq (1-u_{st}+r_{st})\delta_o && \forall o \in O, s \in S_o, s' \in {S_o|s' \neq s}, t \in T_s \label{eq20}\\
x_{is} & \in \{0,1\} &&\forall i \in V, S \in S_i \label{eq23}\\
u_{st} & \in \{0,1\} &&\forall s \in S, t \in T_s\\
r_{st} & \in \{0,1\} &&\forall s \in S, t \in T_s\\
v_{st} &\in \{0,1\} &&\forall s \in S, t \in T_s\\
a_{ts\sigma} &\in \{0,1\} && \forall s \in S, t \in T_s, \sigma \in P \\
z_s & \in \{0,1\} &&\forall s \in S \\
\hat{z}_s & \in \{0,1\} &&\forall s \in S \label{eq29}
\end{align}
The objective function \eqref{objf} consists of two parts: the sum of all assigned tasks
weighted by their corresponding priority $p_i$ and the sum of all penalties that occur due to the assignment of tasks to operators with a lower than optimal skill level for the corresponding task group $d_{is}$. The overall function maximizes the difference between the total priority and the total penalty, each of which are individually weighted using $\mathnormal{w_1}$ and $\mathnormal{w_2}$.
The first groups of constraints \eqref{eq1}, \eqref{eq2}, and \eqref{eq3} ensure the limits for the assignments of tasks. Tasks are split into mandatory tasks $U$ and optional tasks $W$. All mandatory tasks have to be assigned to exactly one single shift, while for all other tasks assignment is optional. Furthermore, constraints \eqref{eq3} require that a task may only be assigned to a shift if that shift has been enabled using the binary variable $z_s$.
Constraints \eqref{eq4}, \eqref{eq5}, and \eqref{eq6} set the limits for the binary variable $u_{st}$ depicting whether a given shift $s$ is active during the time bucket $t$. In constraints \eqref{eq4} the limit for the bandwidth usage is given. Each task requires a certain amount of an operator's attention referred to as bandwidth $b_{is}$. This bandwidth depends on the operator's skill as well as the task's complexity. The bandwidth used at any given time may only exceed zero if the shift is indeed active. Furthermore, as time is considered discrete, once a shift has been activated, the binary variables associated with the following time buckets will be $1$ until the final time bucket. Finally, constraints \eqref{eq6} ensure that the whole shift needs to be enabled using $z_s$ in order to be activated. If there is a surplus in operator capacity, an operator's shift can stay disabled, meaning he or she will not be working that shift.
Similar to the last four constraints, the shift deactivator $r_{st}$ has to be constrained. Constraints \eqref{eq7} ensure that once a shift $s$ has been deactivated, it will stay deactivated. In constraints \eqref{eq8} the limit for used bandwidth is set to zero once the shift $s$ has been deactivated. Constraints \eqref{eq9} state that a shift $s$ may only be deactivated if it is actually enabled.
Constraints \eqref{eq10} and \eqref{eq10b} ensure that the required minimum and maximum lengths per shift $(\alpha_s$ and $\omega_s)$ are respected and break requirements are met.
The following seven constraints ensure that each shift $s$ includes the required break times. Constraints \eqref{eq11} ensure that a preparation time for booting up to work after any break is considered. For an operator $o$ a time bucket $t$ can only be counted towards the required break time $\gamma_o$ if there are no assignments made after it for the length of the preparation time $\rho$. Constraints \eqref{eq12} ensure that the time bucket $t$ may only be counted as a break as long as the bandwidth is zero. Constraints \eqref{eq13} require that the sum of the break times has to be at least the minimum length if the shift length exceeds a certain limit. The next three sets of constraints $($\eqref{eq14} through \eqref{eq16}$)$ set the limits for whenever a time bucket may actually be counted as break. Constraints \eqref{eq14} require that only if a shift $s$ has been turned on, but not yet off, a break may be counted. Constraints \eqref{eq15} and \eqref{eq16} require all breaks to consider the earliest break starting time $\nu_s$ and the latest break end $\lambda_s$. Finally, constraints \eqref{eq17} require that for each operator $o$ any minimum break length requirements $\beta_o$ are respected.
Furthermore, the number of allowed task groups $P$ covered in a shift $s$ in a time bucket $t$ is restricted to $k$. Constraints \eqref{eq18} require that for each task group $\sigma$ the task group limit $a_{ts\sigma}$ is set to one if at least one task of that group is assigned at the time. Constraints \eqref{eq19} ensure that the total number of task group counting variables set to one at any time does not exceed the limit of $k$.
Between shifts covered by the same operator $o$, a rest time $\delta_o$ has to be maintained for legal reasons. Constraints \eqref{eq20} ensure that this rest time is respected in-between all shifts $S_o$ for each operator $o$.
The domains of the variables are defined in \eqref{eq23}-\eqref{eq29}.\\
\section{Adaptive Large Neighborhood Search}
\label{method}
In order to solve the PTSP-TS, an adaptive large neighborhood search type algorithm is designed. Large neighborhood search (LNS) is a metaheuristic search concept proposed by \cite{shaw1998} and it is related to the ``ruin and recreate'' principle by \cite{schrimpf2000record}. It was then further developed for routing and scheduling problems by \cite{RP06a} with the introduction of an adaptive layer which changes the selection probability of repair and destroy operators based on their past performance.
Since then it has become one of the most popular heuristic search schemes in the routing and scheduling field \citep{pisinger2010large}.
ALNS works as follows (see Algorithm \ref{alg:lns-allg}). In a first step, a feasible solution $s$ is generated. In every iteration, a removal operator $d$ and a repair operator $r$ are chosen based on their weights that change due to performance. In a next step, tasks are removed from $s$ using the chosen removal operator $d$ and put into the pool of not assigned tasks. Then, using the chosen repair operator $r$, tasks are (re-)inserted into the shift plan. In the case where the resulting solution $s$ meets the acceptance criteria, it replaces $s$. In the case where it is better than the best solution found so far, it replaces $s_{best}$. This is repeated until some stopping criterion is met.
\begin{algorithm}[H]
\caption{ALNS \label{alg:lns-allg}}
\begin{algorithmic}[1]
\STATE generate a starting solution $s$;
\STATE set $s_{best} := s$
\REPEAT
\STATE choose a removal operator $d$ and a repair $r$ operator
\STATE apply $d$ to $s$ yielding $s'$
\STATE apply $r$ to $s'$ yielding $s''$
\STATE decide if $s''$ is accepted as new incumbent solution; if yes $s \leftarrow s''$
\STATE check if $s''$ is better than $s_{best}$; if yes, $s_{best} \leftarrow s''$
\STATE update the scores and weights of the operators
\UNTIL a given stopping criterion is met
\STATE return $s_{best}$
\end{algorithmic}
\end{algorithm}
In the following we describe the different ingredients in further detail: the deployed destroy and repair heuristics, the developed randomization approach, the acceptance scheme as well as the adaptive mechanism.
\subsection{Destroy Heuristics}
We employ four different removal heuristics. .
Three of these heuristics - random, worst, and operator removal - are based on existing work \citep[e.g.,][]{KPDH10,RP06a} and tailored to the characteristics of
the PTSP-TS.
The fourth operator, named time-based removal, exploits the fact that in our problem, tasks have fixed starting and ending times.
\subsubsection{Random Removal}
\label{sec:randRem}
Random removal randomly chooses assigned tasks, removes them from the solution and adds them to the pool of unassigned tasks.
It is implemented as follows. In a first step, a random number $l$ is drawn from the range \tt{chancelimits}. Then, for every currently assigned task, a random number $r$ is drawn and if $r \leq l$, the respective task is removed from the schedule.
\subsubsection{Worst Removal}
Worst removal completely removes the shifts that contribute the lowest to the objective. It is specifically designed to select shifts that contribute unnecessarily high penalties, as well as shifts that are low on assignment density. The number of shifts destroyed is chosen randomly as follows: a random number $l$ is drawn from \tt{chancelimits} and let $N$ denote the number of currently planned shifts, then the worst $N l$ shifts are removed from the solution.
\subsubsection{Operator Removal}
The operator removal algorithm removes all shifts of a given operator. It follows a similar logic as the random removal heuristic. Instead of removing individual tasks from the solution, a random number $r$ is drawn for each operator and in the case where $r \leq l$ (see Section \ref{sec:randRem}), all shifts of the respective operator are removed from the solution.
\subsubsection{Time-based Removal}
The time-based removal heuristic makes a vertical slice through the entire solution. The idea is to enable the switch of tasks between different shifts that would fit similar time slots. This removal method randomly selects a start time $t \in T$ as well as a length $l$ in the range \tt{widthlimits}, removing all assigned tasks $i$ for which $R_i \cap \{t, ..., t+l\} \neq \emptyset$, i.e., even if the task falls only partially into the time interval, it is removed.
\subsection{Repair Heuristics}
All repair heuristics rely on sorting all possible task to operator assignments according to different criteria and then performing all feasible task to operator assignments in this order. The first three heuristics (A,B,C) rely on penalty and priority based sorting, the next heuristic (D) takes into account the objective function, and finally, the last heuristic (E) considers the value of assigning a task to an operator based on the time and bandwidth it will occupy. The heuristics are described in further detail in the following.
\subsubsection{Penalty and Priority Sorting}
The first three repair heuristics rely on sorting all task to operator assignments according to task $Priority$ $p_i$ and assignment $Penalty$ $d_{is}$. We ensure deterministic sorting of assignments by using a number of sequential sorting criteria. We use $Penalty$ as the main sorting factor in order to maximize the number of assignments to operators that have the desired skill level. $Priority$ is used as the second sorting value, with assignments with higher priority being preferred. The first repair heuristics both start sorting according to $Penalty$ ahead of $Priority$ and introduce the following additional tie breakers:
\begin{itemize}
\item $A$: \{$Penalty,Priority,skillFitting$\}
\item $B$: \{$Penalty,Priority,skillFitting*(-1)$\}
\item $C$: \{$Penalty,Priority,Bandwidth*(-1),skillFitting$\}
\end{itemize}
As the first additional tie breaker we use a value called $skillFitting$. The calculation of this value differs depending on whether the operator fulfills the desired skill level of the considered task. If they do, we calculate the value of $skillFitting$ to be equal to $DesiredSkill - ActualSkill$. This gives preference to assigning tasks to operators that fulfill the skill requirement as closely as possible, in order to make sure that the capacities of our highest-skilled operators are kept for the most difficult tasks. If the operator's skill level is lower than the desired level, then this value is equal to the $Penalty$ $d_{is}$. For our repair operators $A$ and $B$ we take $skillFitting$ as the third tie breaker, however for operator $B$ the value is inverted. This usage of the tie breaker has different objectives: While regular usage of the $skillFitting$ value tries to retain as much capacity of higher-skilled operators as possible, using the inverted value tries to fill up the shifts of the higher-skilled operators by using the tasks with the highest $Priority$. For sorting operator $C$ we introduce another differentiation value $Bandwidth$. $Bandwidth$ is the capacity a task occupies when assigned to a specific shift (denoted as $b_{is}$ above). As our problem allows for the assignment of multiple tasks in parallel, this value ranges from 1 (full capacity) down to $\frac{1}{6}$. The value of $Bandwidth$ for a specific assignment is dependent on the task as well as the operator's skill for parallel coverage. We use the inverted value as assignments using a smaller amount of capacity are generally preferred.
\subsubsection{Objective Sorting}
Sorting operator $D$ now combines the usage of $Penalty$ and $Priority$ into the value $Objective=w_1*p_i - w_2*d_{is}$ which is the actual value an assignment contributes to the objective function.
\begin{itemize}
\item $D$: \{$Objective,Bandwidth,skillFitting$\}
\end{itemize}
Similar to sorting operator $C$ we use $Bandwidth$ and $skillFitting$ as subsequent tie breakers.
\subsubsection{Efficiency Sorting}\label{eff}
\allowdisplaybreaks
For our fifth and final sorting operator $E$ we introduce a new value called $Efficiency$. This value is calculated using the following formula: $Efficiency = Objective$ $/(Bandwidth*Length)$. $Efficiency$ therefore gives us the contribution per occupied capacity of an operator. The $Efficiency$ of an assignment of tasks with the same priority grows the lower the occupied $Bandwidth$ of an operator and the shorter the task in general.
\begin{itemize}
\item $E$: \{$Efficiency,Priority,Bandwidth*(-1),Groups*(-1)$\}
\end{itemize}
As first and second tie breaker we use the previously introduced values for $Priority$ and $Bandwidth$. However, due to the structure of the $Efficiency$ value, we require a tie breaker that is different from $skillFitting$. Here, we give preference to operators that have the least flexibility of covering different task groups. The value $Groups$ chosen as tie breaker is defined as the number of different task groups that an operator is skilled in. The skill levels are not considered here. As we aim at prioritizing assigning staff with low flexibility, the value of $Groups$ is inverted.
\subsection{Starting Solution}
To obtain a starting solution, we employ the repair operator Efficiency Sorting (described in \ref{eff}) to sort all tasks of the instance. We then construct an assignment by "repairing" the initially empty assignment, inserting tasks in the order provided by the sorting mechanism. Only feasible task assignments are considered.
\subsection{Acceptance Criteria}
For our implementation of ALNS, we consider three possibilities of handling a newly created solution. New solutions achieving a globally best objective value are immediately accepted and stored for further use. If a new solution has an objective value that is at maximum .5\% lower than the current incumbent solution, then the solution is accepted as new incumbent solution for the next iteration. All solutions more than .5\% worse than the current solution are discarded. In this case, the next iteration starts using the assignments of the incumbent solution.
\subsection{Choice of Destroy and Repair Heuristics}
In accordance with \cite{RP06a}, we use separate weights $\eta_{h}$ for every possible repair and destroy heuristic $h$. Ahead of each iteration of the ALNS, destroy and repair heuristics are randomly chosen based on their weights. The result of each iteration (overall improvement, temporary improvement and rejection) is stored for the chosen heuristics. After a given amount of iterations $SegLen$, referred to as segment, the weights of all heuristics are updated based on their performance in the past segment. For the following segment, these updated values are used for randomized selection. The weights are updated periodically during the search, with the length of each segment staying the same.
The probability $\phi_{h}$ for a repair heuristic to be chosen for an iteration is calculated as follows:
\begin{align}
\phi_{h} = \frac{\eta_{h}}{\sum_{{h}'=1}^{n_{h}}\eta_{{h}'}}
\end{align}
The choice of destroy heuristic is made in the same way.
For updating the weights of the heuristics after each segment we use an approach that is based on \cite{RP06a}. Every repair and destroy heuristic receives an initial score $\sigma$ that increases in each iteration a heuristic was used, based on its performance. Scores are updated as follows:
\begin{align}
\sigma = &
\begin{cases}
\sigma + \epsilon_1, &\text{if $s''$ improves the global best solution } s_{best}, \\
\sigma + \epsilon_2, &\text{if $s''$ improves the incumbent solution } s, \\
\sigma + \epsilon_3, &\text{if $s''$ is accepted as new incumbent $s$ although it is worse},\\
\sigma, &\text{otherwise. } \notag
\end{cases}
\end{align}
In our computational study, we evaluate this approach, using different parameter settings and we also consider keeping $\epsilon_3 = 0$, which results in no reward for solutions that are worse than the current incumbent, even if they were accepted.
Each segment consists of a total of 100 iterations. At the end of each segment, the weight of each destroy and repair heuristic is updated using the following formula:
\begin{align}
\eta_h = (1-p_{react})\eta_{h}+p_{react}\frac{\sigma_{h}}{\max(1,\Omega_{h})}
\end{align}
where $\Omega_{h}$ denotes the number of times the considered repair heuristic was used and $p_{react}$ is a predetermined weight controlling the influence of the new score on the historic weight.
\subsection{Task Stacking}
To improve bandwidth usage, we introduce task stacking into our repair heuristics.
$Stacking$ causes the repair algorithm to try to build stacks of similar tasks (the seed tasks being the one that is supposed to be inserted) and to insert all stacked tasks at once. Tasks are considered for stacking if they share starting and ending times and belong to the same task group as the seed task.
Since stackable tasks are assigned in parallel, in the best case, an operator's capacity is fully used by the chosen tasks.
\subsection{Slice Shuffling}
In order to introduce some randomization into our repair heuristics, we develop a slice shuffling mechanism. As all possible assignments are always sorted in the same way whenever a given repair heuristic is applied, we introduce a semi-random shuffling operator in order to prevent the algorithm from generating the same solutions over and over. Slice shuffling takes the sorted list of possible assignments and divides it into slices of length $\mu$.
The order of the assignments within a given slices is then shuffled. Preliminary experiments with different parameter settings have led to the definition of the set $sl$. The set $sl$ contains all possible values $\mu$ may take for a given iteration: at the start of each repair step, the value for $\mu$ is randomly chosen out of $sl$. Making sure that the slices are not too large allows us to explore different options for assignments, while ensuring that the initial sorting done by the repair heuristic does not become pointless. Too small slices may produce very similar results due to the potentially large number of tasks that do not differ in their sorting value.
\section{Computational Results}
\label{results}
The ALNS algorithm as well as the MIP model were implemented in Python, with the MIP model using the CPLEX 12.8 as MIP-solver. All tests are conducted on a computing cluster with 64 nodes consisting of 2 Intel Xeon X5570 CPUs with 4 cores as well as 48 GB of RAM each. Each run uses a single thread. All ALNS results are based on ten random runs per instance and we use a run time limit of 6 hours for the MIP-solver.
Each time-bucket in the MIP represents five minutes.
\subsection{Data Sets}
The test instances used in this paper are based on information from our company partner Sportradar as well as on real-world sports data. Sportradar's operators reside in four different countries giving rise to different working and break length regulations. The preparation time $\rho$ is assumed to be 20 minutes irrespective of the working location. Tasks are sports matches and belong to one out of 22 different task groups and may require a maximum skill level of 100. In terms of bandwidth, a task may require the complete bandwidth (1) of an operator or only a fraction of the bandwidth. The minimum is $\frac{1}{6}$. This implies that the maximum number of parallel tasks is six. Furthermore, at most tasks from two different task groups may be scheduled in parallel.
The generated test instances are divided into four different groups with ten instances each. Small instances contain only a handful of workers with around 100 tasks to be chosen for assignment and the considered planning horizon is limited to 8 hours. Medium-sized instances contain up to ten workers, between 400 and 700 tasks and a total planning horizon of 18 hours.
The set of large instances contains a higher number of operators and is set to reflect the assignments for an entire day with a considered planning horizon of 24 hours and between 600 and 1100 tasks. Finally, ten very large-scale instances include shifts and tasks for a time span of 72 hours, this results in data sets with between 180 and 230 shifts and between 2000 and 3300 tasks. The length of the planning horizon corresponds roughly to the requirement of Sportradar which schedules their shifts three days in advance.
Instance names are given in the following format: $|T|$\_$|S|$\_$|V|$ providing the planning horizon of the instance in hours ($|T|$), the number of possible shifts ($|S|$), and the number of available tasks ($|V|$).
\subsection{Results for Benchmark Instances}
In a first step, we evaluate the performance of the developed ALNS on those instances that can also be tackled by the MIP-solver.
Based on preliminary tests, all ALNS parameters have been set. The set of parameters is \{\tt{chancelimits}, \tt{widthlimits}, $sl$, $\rho$, $\epsilon_1$, $\epsilon_2$, $\epsilon_3$, $p_{react}$\}.
The range \tt{chancelimits} which is used to define the probability for a task to be removed from the solution in the random removal operator, and the probability of an operator's shifts to be deleted from the solution is set to $(0.1,0.5)$. The range \tt{widthlimits} from which the value of the slice length in the time based removal operator is drawn is set to [180,300] (minutes).
The set $sl$ contains all possible values for the length of the slice $\mu$ which is used in the slice shuffling step. This set is defined to be \{0,4,8,16\}.
The parameters used to reward destroy and repair operators for good performance \{$\epsilon_1$, $\epsilon_2$, $\epsilon_3$\} are initially set to \{40,25,8\}. However, in the following we also test the setting \{40,25,0\}, i.e., no reward for deteriorating solutions that are accepted as new incumbent solutions. The value of $p_{react}$ is set to 0.1 for all computations.
The base setting of the weights in the objective function is $w_1 = 1$ and $w_2 = 1$.
Table~\ref{tbl:mipcomp} reports average values over small and medium-sized instances and the average average gap (AGap) as well as the average best gap (BGap) with respect to the MIP solution for setting $\epsilon_3 = 8$ and setting $\epsilon_3 = 0$ and different ALNS iteration limits (Iterations).
\begin{table}[tbh]
\setlength{\tabcolsep}{2ex}
\caption{Comparison of average solutions obtained by the ALNS using different values for $\epsilon_3$ in comparison to the best solution values obtained by the MIP-solver for small and medium-sized instances.\label{tbl:mipcomp}}
\centering
\begin{tabular}{lrrrr}
\toprule
\multicolumn{5}{l}{ALNS}\\
\midrule
Setting & Iterations & AGap & BGap & Avg \\
\midrule
$\epsilon_3 = 8$ & 1,000& 3.27 & 1.78 & 5123.4\\
&10,000& 1.57 & 0.63 & 5226.2 \\
&25,000& 1.14 & 0.39 & 5252.5 \\
&100,000& 0.67 & 0.09 & 5286.1 \\
\midrule
$\epsilon_3 = 0$ & 1,000& 3.22 & 1.98 & 5127.2\\
&10,000& 1.48 & 0.52 & 5231.7\\
&25,000& 1.19 & 0.34 & 5249.8\\
&100,000& 0.91 & 0.22 & 5269.2\\
\bottomrule
\end{tabular}
\end{table}
Detailed results on a per instance level, can be found in the appendix in Tables \ref{tablestart} to \ref{tableend}, where Tables \ref{tablestart} to \ref{firstend} contain the results for setting $\epsilon_3 = 8$ and Tables \ref{secondstart} to \ref{tableend} those of setting $\epsilon_3 = 0$. All tables are structured as follows:
for each instance, we provide the average objective value ($Avg$), the best objective value ($Best$), the average run time ($Time$) in seconds as well as the average ($AGap$) and the best gap ($BGap$) of the objective value computed by the ALNS to the objective value obtained with the MIP-solver in percent. Furthermore, we provide the average number of tasks assigned ($|M|$). For the solutions obtained with the MIP-solver, we give the best obtained lower bound ($LB$) and the run time ($Time$) in seconds. For instances that the MIP-solver did not solve within the time limit of six hours, we report the optimality gap ($MIPGap$) given by CPLEX at the end of the run time. In the final column we provide the number of tasks assigned in the best solution obtained by the MIP-solver ($|M|$). For each set of benchmark instances, we give the results for 1,000, 10,000, 25,000 as well as 100,000 iterations in separate tables. In each table, we add a summary line that provides the average of the average gaps as well as the average of the best gaps achieved over the instances of the benchmark set.
As the solutions obtained by the MIP-solver (given in Table \ref{tablestart} and repeated in Tables \ref{table10Tits} to \ref{tableend} for comparison purposes) show, most problems of the smallest size with a planning horizon of eight hours can be solved to optimality within the time limit. However, even for medium-sized instances that consider a planning horizon of 18 hours, the MIP-solver already reaches its limits. For large instances considering a planning horizon of a full day, the MIP implementation already fails at the root node. Therefore,
in this initial set of experiments, we only report results for small and medium-sized instances.
Overall, setting $\epsilon_3=8$
performs slightly better than setting $\epsilon_3=0$. This difference
mainly
becomes visible for the highest number of iterations when comparing the best objective values found. For the highest number of iterations tested, the best solutions obtained using $\epsilon_3=8$ are within less than 0.1 percent of the solution obtained by the MIP-solver. However, we note that this average consists of solutions where the heuristic significantly outperforms the solution of the MIP as well as some solutions where it falls off slightly. The maximum percentage difference of the heuristic beating the MIP implementation and vice versa is at about 1.5 percent. We note that while the MIP-solver was given an upper limit of six hours to calculate the solution, we chose the limit of 100,000 iterations for our longest comparison to stay considerably below 30 minutes of run time for the heuristic. We also note that our implementation was made in Python 3. Speed-ups of a factor of 10 may be achieved when using a different programming language \citep{tricoire2021broute}.
In the following, all reported ALNS results use the setting $\epsilon_3 = 8$.
\subsection{Additional Objectives and Trade-off Analysis \label{addobj}}
In addition to the two components of the objective function considered in the PTSP-TS, Sportradar was interested in optimizing an additional three objectives introduced in detail in the following paragraphs. We name them $Groups$, $Consec$, and $Workload$.
Tasks can be grouped according to their similarity. When similar tasks are performed within the same shift, the quality of the service increases. Adversely, the more different tasks from different groups a worker is assigned during a shift, the lower the quality the worker will be able to provide. The third objective is therefore to minimize the number of different task groups assigned to a full shift and is named $Groups$. While there is an upper limit to the number of tasks of different groups for concurrent tasks, this objective seeks to minimize the number for the whole shift.
The fourth objective introduces the idea of consecutive tasks $Consec$ and adds a bonus if they are scheduled in the same shift. As some groups of tasks may feature tasks that should start back-to-back, it is generally helpful to assign these consecutive tasks to the same shift. This information is not directly exploited in the base setting of our ALNS. We explain below, how this information can be incorporated into the ALNS, so as to increase the number of consecutive tasks assigned to the same shift.
The final objective is to minimize the amount of employee idleness by maximizing the workload in percent of total available time. We name this measure $Workload$. This objective was omitted in the model proposed in this paper, as it is generally considered to be optimized through the choice of the most valuable tasks. Introducing this objective might incur assignments of lower priority tasks in order to reduce employee idle time.
In order to evaluate the impact of considering these additional objectives, we evaluate different weight settings. Let \{$Priority$, $Penalty$, $Groups$, $Consec$, $Workload$\} denote the set of considered objectives. We combine them into a weighted sum where each objective receives a different weight, depending on the chosen focus. Weight setting \tt{Control} is the benchmark setting. It uses the same weights as above, i.e., \{1,1,0,0,0\}. Weight setting \tt{Priority} focuses on the first objective only, using weight set \{1,0,0,0,0\}. Setting \tt{Penalty} puts a comparably high weight on the second objective, using weight set \{1,100,0,0,0\}. The weights for setting \tt{TaskGroups}, where emphasis is put on grouping similar tasks together, are \{1,1,-10,0,0\}. We note that the $Groups$ and $Penalty$ objectives are only considered as secondary objectives, as obviously without optimization of $Priority$, the value of the $Groups$ objective would be 1 for solutions without parallel tasks of different groups and 0 (the best possible value) for solutions without any tasks assigned. The latter also holds for the $Penalty$ objective. The employed weights for the maximization of the $Workload$ objective (setting \tt{Workload}) are \{1,1,0,0,10000\}.
Finally, we analyze a setting where all five objectives considered by the company receive a weight, so as to roughly reflect their importance from the company perspective: $Priority$ is the main objective, $Penalty$ and $Workload$ are secondary objectives, while $Groups$ and $Consec$ are the least important objectives. In this experiment, we introduce the concept of successor matching into the proposed ALNS: we add the possibility upon assigning a match to assign its direct predecessor/successor at the same time and to the same shift (if feasible). This is an additional step taken to improve the number of consecutive matches that are assigned to the same operator. Furthermore, in the destruction step of the ALNS, we introduce successor destruction, which allows us to destroy any assigned successors and predecessors of a destroyed match, even if they are assigned to different shifts in the current solution. Successor destruction is randomly turned on or off at the beginning of a new destroy step. These final tests are made using weights for the five objectives of \{1,1,-1,1,1000\}. We denote the ALNS with these additional ingredients ALNS+ and the weight setting \tt{AllObjectives}.
\begin{table}[tbh]
\setlength{\tabcolsep}{1.2ex}
\caption{Comparison of average solutions across all instances, obtained with 100,000 ALNS iterations using different weight settings. For setting \tt{AllObjectives} ALNS+ is used. \label{tbl:comparison}}
\small
\centering
\begin{tabular}{lp{3pt}rrrrrrr}
\toprule
&& \multicolumn{5}{l}{Average individual objective values}\\
\cmidrule{3-7}
Weight setting && $Priority$ & $Penalty$ & $Groups$ & $Consec$ & $Workload$ & $OF$ & $OFsmall$\\
\midrule
\tt{Control} && 44733.6 & -206.55 & 2.34 & 11.05 & 0.86 & 44527.05 & 5286.10\\
\midrule
\tt{Priority} && 44875.28 & -482.92 & 2.34 & 11.00 & 0.86 & 44392.35 & 5264.68\\
\tt{Penalty} && 43998.70 & -0.00 & 2.32 & 10.70 & 0.86 & 43998.70 & 5234.90\\
\tt{TaskGroups} && 44728.35 & -206.06 & 2.28 & 11.18 & 0.86 & 44522.29 & 5288.38\\
\tt{Workload} && 44576.25 & -195.04 & 2.38 & 10.89 & 0.88 & 44381.21 & 5168.35\\
\midrule
\tt{AllObjectives} && 44751.4 & -202.16 & 2.32 & 23.55 & 0.87 & 44549.24 & 5288.87\\
\bottomrule
\end{tabular}
\end{table}
We summarize the results of the different weight settings in Table \ref{tbl:comparison}. Average results per instance can be found in Tables \ref{tbl:priority}--\ref{tbl:allobj} in the appendix.
In Table \ref{tbl:comparison}, in addition to the average values for every single objective, we report the average values obtained for the original objective function ($OF$) as well as the average value of the original objective function considering only the small and medium-sized instances ($OFsmall$). The values given in the table show, that each of the four specialized settings reaches the best value for the considered objective among all approaches tested. Furthermore, the \tt{Control} setting, taking into account only priority and penalty, provides the best average value of the original objective function, considering all test instances. When considering small and medium-sized instances only, additional weight on the minimization of task groups (setting \tt{Taskgroups}) has a positive side effect on the penalty objective.
Finally, setting \tt{AllObjectives}
obtains slightly better solutions on average for the original objective function, which indicates that the additional ingredients, focusing on consecutive matches, help the ALNS in finding even slightly better solutions for the original objective function by planning more consecutive matches together.
The results obtained for the different weight settings allow us to derive some managerial insights and pointers towards further use and practical applications. First, they
indicate that secondary objectives may be considered at a comparatively small price when regarding the two main objectives. All results considering focused objective functions share a significant improvement in the focused objective over the baseline or control setting.
Second, additional ingredients focusing on the planning of consecutive matches together with weights on all objectives (setting \tt{AllObjectives}) has a positive impact. It returns solutions that improve all three secondary objectives
and even slightly improve the values on the two main objectives on average. This implies that additional information (in our case, the information relating to matches that can and should be planned consecutively) should be used and exploited in the design of the algorithm.
In the following case study, where the proposed algorithm is tested on company data, ALNS+, as deployed in the \tt{AllObjectives} setting, is used, and compared to ALNS with the setting \tt{Control}.
\section{Case Study}
\label{study}
The considered problem was brought to us by Sportradar. Operators are to be assigned sports matches to supervise and determine whether provided betting odds reflect reality. The considered problem includes all five of the previously presented objectives. Furthermore, Sportradar requires a time horizon of three days to be planned at once. The comparison made in this section is only performed between the solutions obtained with ALNS+ with the setting \tt{AllObjectives}, ALNS with the setting \tt{Control} and the assignments the company has made.
\begin{table}[tbh]
\setlength{\tabcolsep}{2ex}
\caption{Comparison of original company assignments with average solutions obtained with ALNS+ using weight setting \tt{AllObjectives} on case study data,
as well as weighting the two main objectives only (\tt{Control}) using ALNS \label{tbl:rw}}
\centering
\begin{tabular}{lp{3pt}rrr}
\toprule
Objective && Company & \tt{AllObjectives} &
\tt{Control}\\
\midrule
Total Priority ($Priority$) && 111390 & 179902.0 & 179865.0\\
\\
Total Penalty ($Penalty$) && -10577 & -752.6 & -816.7\\
\\
Average sports ($Groups$) && 1.982 & 2.553 & 2.515\\
Maximum sports && 5 & 6.2 & 6.1\\
\\
Consecutive same ($Consec$) && 12 & 23.2 & 18.7\\
Consecutive different && 16 & 82.4 & 82.9\\
Consecutive scheduled && 22 & 82.6 & 83.0\\
Consecutive available && 83 & 83.0 & 83.0\\
\\
Ratio workingtime/total ($Workload$)&& 0.822 & 0.841 & 0.841\\
\\
Scheduled matches && 1584 & 2684.8 & 2696.6\\
Total matches && 5266 & 5266.0 & 5266.0\\
\\
Objective Value ($OF$) && 100813 & 179149.4 & 179048.3\\
\bottomrule
\end{tabular}
\end{table}
As the basis for the comparison between the performance of our solution method and the original company assignments, we use company data spanning a total of five days. The resulting data set comprises a total of 6706 matches assignable to a total of 379 potential shifts which belong to 124 operators. To increase the comparability between test assignments and original assignments, as well as to simulate the continuity of the real world problem, we choose to exclude assignments made for the first and the final of these five days from contributing to the objective function. This leaves a total of 5266 matches available for assignment within the time frame of three days. Table \ref{tbl:rw} provides this comparison on real-world data using the proposed ALNS+ algorithm, the ALNS algorithm and the assignments made by the company.
ALNS is run
only considering the two main objectives (weight setting \tt{Control}) while
ALNS+ uses weights for all five objectives (weight setting \tt{AllObjectives}). The values provided in the table are obtained for an iteration limit of 100,000 iterations for both weight settings.
The comparison shows that assignments made using the proposed method significantly outperform past company assignments when regarding the two main objectives. The third objective $Groups$ shows that our ALNS+ assigns more tasks of different task groups than the company solution, which is only treated as a secondary objective. The same holds true for the highest value ("Maximum Sports") over all shifts. Comparison for the objective of assigning consecutive matches $Consec$ shows that the generated assignments include many more consecutive matches than the company solution. In addition to the actual objective of consecutive matches assigned to the same shift, we further report the values for consecutive matches assigned to any shift ("Consecutive different"), including same and different shifts, as well as consecutive matches where at least one of the two matches is assigned in the overall solution ("Consecutive scheduled"). The reported ratio of working time to total time ($Workload$) shows that our assignments achieve an average of 0.841 for both settings, which is significantly higher than the value of the company assignments. Finally, we report the number of scheduled matches in the solutions, as well as the value obtained for the objective function ($OF$) used in the \tt{Control} setting.
Summarizing the above, the proposed heuristic significantly outperforms a comparable assignment made by Sportradar in all considered performance measures but one ($Groups$). The large gap in the objective value of the main two objectives can partially be explained by the limit of the scale of importance of each of the considered matches. As the matches are generally assigned a priority between 0 and 100, the company solution considered a direct approach to this goal. A task with a higher priority was therefore assigned as early as possible. However, long matches with a high value for priority may be inferior to short matches with an average value due to the amount of working capacity they require from a given worker. This is very clearly displayed in the comparison when regarding the values for the fifth objective, minimizing worker idle time and the total number of scheduled matches in the solutions. While our solutions assign more than 1,000 additional matches, the ratio of working time to total time on average is only around two percent higher than in the company solution.
\section{Conclusions}
\label{conc}
In this paper we have modeled and solved a personnel task scheduling problem with task selection (PTSP-TS). We have developed a tailored adaptive large neighborhood search algorithm. Repair and destroy operators previously used in the literature have been adapted to fit the proposed problem. Additionally, we propose new and tailored operators. Furthermore, we have proposed a mathematical model of the considered problem and benchmark the ALNS algorithm against solving the MIP formulation with CPLEX. The required run time of CPLEX is long even for medium-sized instances and cannot be used for time horizons interesting for real-world application. The proposed ALNS has proven very competitive compared to the previous planning at Sportradar
and has since been implemented for regular use.\\
Future research will focus on further analyzing the trade-off between the different objectives, e.g., by considering a subset of the objectives concurrently in a multi-objective approach which can produce (an approximation of) the Pareto frontier.
\section*{Acknowledgements}
This research was funded in whole, or in part, by the Austrian Science Fund (FWF) [P 31366]. For the purpose of open access, the author has applied a CC BY public copyright licence to any Author Accepted Manuscript version arising from this submission.
We also wish to thank Sportradar for having provided us with the real-world data.
\bibliographystyle{apalike}
| {'timestamp': '2023-02-10T02:08:28', 'yymm': '2302', 'arxiv_id': '2302.04494', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04494'} | arxiv |
\subsection{Piecewise constant parameters}
In a first extension of the SDE model, we assume that malware and bonware have an activity rate of 0 until they activate at time points $t^{m}$ and $t^{b}$, respectively. After activation, both activity rates are constant. Additionally, both efficiency parameters are assumed to be constant in time. Specifically, $\theta^{\malwareSuper}(t) = \theta^{m} u\!\left(t-t^{m}\right)$, $\theta^{\bonwareSuper}(t) = \theta^{b} u\!\left(t-t^{b}\right)$, ${{\gamma}^{\malwareSuper}}(t) = \gamma^{m}$, and ${{\gamma}^{\bonwareSuper}}(t) = \gamma^{b}$.
Here $u(\cdot)$ is the unit step function.
The piecewise constant formulation here is particularly apposite for our experiments, in which the timing of malware attacks is known. The analyst can then choose between considering $t^{m}$ and $t^{b}$ as known, and retain the parsimony of a four-parameter model, or considering them unknown and estimate them from data in a six-parameter model. The difference between the known onset time of an attack and the estimated $t^m$ may then be interpreted as the time it takes for an attack to take effect. Similarly, the difference between that onset time and the estimated $t^b$ may be interpreted as the delay until bonware begins to restore functionality after an attack.
\section{Prior work}\label{sec:prior-work}
A growing body of literature explores quantification of resilience in general and cyber resilience in particular. Very approximately, the literature can be divided into two categories:
(1) qualitative assessments of a system (actually existing or its design) by subject matter experts (SMEs) \cite{alexeev}, \cite{henshel} and
(2) quantitative measurements based on empirical or experimental observations of how a system (or its high-fidelity model; \cite{kott2017assessing}) responds to a cyber compromise \cite{kott2019cyber,ligo2021how}.
In the first category, a well-cited example is the approach called the cyber-resilience matrix \cite{linkov2013resilience}. In this approach, a system is considered as spanning four domains: (1) physical (i.e., the physical resources of the system, and the design, capabilities, features and characteristics of those resources); (2) informational (i.e., the system's availability, storage, and use of information); (3) cognitive (i.e., the ways in which informational and physical resources are used to comprehend the situation and make pertinent decisions); and (4) social (i.e., structure, relations, and communications of social nature within and around the system). For each of these domains of the system, SMEs are asked to assess, and to express in metrics, the extent to which the system exhibits the ability to (1) plan and prepare for an adverse cyber incident; (2) absorb the impact of the adverse cyber incident; (3) recover from the effects of the adverse cyber incident; and (4) adapt to the ramifications of the adverse cyber incident. In this way, the approach defines a 4-by-4 matrix that serves as a framework for structured assessments by SMEs.
Another example within the same category (i.e., qualitative assessments of a system by SMEs) is a recent, elaborate approach proposed by \cite{beling2021developmental}. The approach is called Framework for Operational Resilience in Engineering and System Test (FOREST), and a key methodology within FOREST is called Testable Resilience Efficacy Elements (TREE). For a given system or subsystem, the methodology requires SMEs to assess, among others, how well the resilience solution is able to (1) sense or discover a successful cyber-attack; (2) identify the part of the system that has been successfully attacked; (3) reconfigure the system in order to mitigate and contain the consequences of the attack. Assessment may include tests of the system, although the methodology does not prescribe the tests.
Undoubtedly, such methodologies can be very valuable in finding opportunities in improvements of cyber-resilience in a system that is either at the design stage or is already constructed. Still, these are essentially qualitative assessments, not quantitative measurements derived from an experiment.
In the second category (i.e., quantitative measurements based on empirical or experimental observations of how a system, or its high-fidelity model, responds to a cyber compromise), most approaches tend to revolve around a common idea we call here the area under the curve (AUC) method \cite{hosseini2016review,kott2021to}. The general idea is depicted in Figure~\ref{fig:auc}. In an experiment/test, a system is engaged into a performance of a representative mission, and then is subjected to an ensemble or sequence of representative cyber attacks. A mission-relevant quantitative functionality of the system is observed and recorded. The resulting average functionality, divided by normal functionality, can be used as a measure of resilience.
\begin{figure}[t]
\centering
\aaa{attacks_and_defenses.pdf}
\caption{Resilience can be measured by subjecting a system to cyber attacks and measuring the fraction of functionality lost due to cyber attack, as compared to normal functionality.}
\label{fig:auc}
\end{figure}
Brtis \cite{brtis2016how} performed a structured evaluation and comparison of multiple resilience metrics and concluded that the AUC-based approaches are superior to others. He wrote, ``We evaluated 23 candidate metrics against 19 evaluation criteria. From this analysis we conclude that the best single metric for resiliency is the expected availability of the required capability.'' Parenthetically, our research did not find a reason to disagree with Brtis's position.
However, AUC-based resilience measures are inherently cumulative, aggregate measures, and do not tell us much about the underlying processes. For example, is it possible to quantify the resilience \impact{} of the bonware of the given system? Similarly, is it possible to quantify the \impact{} of malware? In addition, is it possible to gain insights into how these values of \impact{fulness} vary over time during an incident? We offer steps toward answering such questions.
\subsection{Accomplishment and functionality}
Every mission has a goal, and we postulate that for a given mission, there exists a function $\ma(t)$ that represents accomplishment and is cumulative from the mission start time up until the present time $t$. We define functionality, ${{F}}(t)$, to be the time derivative of mission accomplishment. Thus,
\begin{equation}
\label{eq:ma}
{{F}}(t) = \frac{d \ma }{dt}, \quad \ma(t) = \int_{t_0}^t {{F}}(\tau) \, d\tau.
\end{equation}
The normal functionality, when the system performs normally and does not experience effects of a cyber attack, may, in general, vary with time. For simplicity, throughout this paper, we assume the normal functionality to be constant in time, $\Fnominal(t)=\Fnominal$. Thus, the functionality of our system prior to an attack or other malfunction is normal at the start time:
${{F}}(t_0)=\Fnominal$.
\section{An application of the model}
\subsection{Obtaining model parameters}
\label{sec:parameters}
Given notional data that represents a typical curve of functionality
over the course of an incident where malware and bonware are active,
we develop a fast method to estimate the continuous model parameters
for a curve that approximates the data, and use these parameters to
generate further realizations based on this model. In Figure
\ref{fig:notional} an example of such notional data is plotted (in
light blue). In this section, we illustrate our method to
extract the model parameters from this curve.
The set $P=\{t_0, \hdots, t_K\}$ partitions the mission timeline and
malware and bonware are constant in each interval $(t_{i-1},t_i), \,\,
i=1, \hdots, K. \,\,$ In each interval,
$\Qware_i=\malware_i+\bonware_i$ and the differential equation
governing Continuous Model I is $\frac{dF(t)}{dt}+\Qware_i F(t) =
\Fnominal (t) \bonware_i.$ Thus, in each interval $(t_{i-1},t_i),$
the solution is
\begin{equation*}
{{F}}(t) =
\left[{{F}}(t_{i-1}) - \frac{\Fnominal \bonware_i}{
\Qware_i } \right] e^{-\Qware_i (t-t_{i-1})} + \frac{\Fnominal \bonware_i}{\Qware_i}.
\end{equation*}
We compute the effectiveness, ${\effectiveness}^{\malwareSuper}$, and activity, ${\activity}^{\malwareSuper}$, of malware
and of bonware (${\effectiveness}^{\bonwareSuper}, {\activity}^{\bonwareSuper}$), in each interval:
$\malware_i = {\effectiveness}^{\malwareSuper}_i {\activity}^{\malwareSuper}_i$, $\bonware_i = {\effectiveness}^{\bonwareSuper}_i {\activity}^{\bonwareSuper}_i$.
We observe that there is a unique switching time $\tchange$ where the
functionality's trend reverses, and thus we take $K=2.$ Before the
switch, the impact of malware is greater than that of bonware. From
the time of the switch until the end of the mission, bonware is
stronger. To estimate the switching time $\tchange$, we find the
minimum of the data to occur over the interval from 64 s to 75 s.
There, the minimum value of the data curve is $m=0.27$. Taking the
midpoint, our estimate for $\tchange$ is 69.5 s. We estimate the
activity of malware before switching to be the number of times the
data curve decreases divided by the switching time. Similarly, our
estimate of bonware activity is the number of times the data curve
increases prior to the switching time. We thus have
${\activity}^{\malwareSuper}_1~\approx~\sfrac{7}{69.5}~\approx 0.101$ and
${\activity}^{\bonwareSuper}_1 \approx \sfrac{2}{69.5} \approx 0.014$.
To determine the remaining parameters, we numerically solve this
system of equations:
\begin{align*}
\alpha m &= \Fnominal \bonQone,\\
m &= {{F}}(0) -\Fnominal \bonQone e^{-\Qware_1 \tchange}+\Fnominal \bonQone.
\end{align*}
The first equation says that where the curve meets the minimum of the data, it has experienced exponential decay of $\alpha$ toward the asymptotic minimum. We take $\alpha$ to be $\alpha=1-\sfrac{1}{e}$. The second equation says that the minimum occurs at the switching time (the time when the model switches from malware dominating bonware, to bonware dominating malware. Solving this system of equations yields (with $\malware_1=\Qware_1-\bonware_1$), $\malware_1 \approx 0.025$ and $\bonware_1 \approx 0.005$, so that ${\effectiveness}^{\malwareSuper}_1 = \sfrac{\malware_1}{{\activity}^{\malwareSuper}_1} \approx 0.503$ and ${\effectiveness}^{\bonwareSuper}_1 = \sfrac{\bonware_1}{{\activity}^{\bonwareSuper}_1}\approx 0.362$.
To the right of $t^\star$, we fit an exponentially increasing function. Similar to before the switching time, we compute the activities of the malware and bonware: ${\activity}^{\malwareSuper}_2 \approx \frac{1}{100-69.5} \approx 0.033$ and ${\activity}^{\bonwareSuper}_2 \approx \frac{4}{100-69.5} \approx 0.131$.
\newcommand\FBonQtwo[1]{\frac{#1 \bonware_2}{\Qware_2}}
To determine the remaining parameters, we numerically solve this system of equations:
\begin{align*}
\zeta &= \FBonQtwo{F(0)},\\
\tilde{\alpha} \zeta &= \left(m- \FBonQtwo{\Fnominal}\right)
\!\! \left(e^{-\Qware_2 (125-t^\star)}+\FBonQtwo{\Fnominal}\right).
\end{align*}
We have found that $\tilde{\alpha}=1-e^{-4}$ and $\zeta=0.95$ are
satisfactory values to use for these hyperparameters.
We compute $\malware_2 \approx 0.005$ and $\bonware_2 \approx 0.088$,
so that
${\effectiveness}^{\malwareSuper}_1 =
\sfrac{\malware_1}{{\activity}^{\malwareSuper}_1} \approx 0.201$ and
${\effectiveness}^{\bonwareSuper}_1 =
\sfrac{\bonware_1}{{\activity}^{\bonwareSuper}_1}\approx 0.957$.
\subsection{Generating stochastic realizations}
Using the parameters found in Section~\ref{sec:parameters}, we can now
generate stochastic realizations. In Section~\ref{sec:proposition},
we showed that for large sample sizes, the average of our ensemble
will approach the solution to the continuous ODE model. We show
empirically that this is indeed the case. To illustrate, we generated
five realizations (Figure \ref{fig:five:realizations}) of the
stochastic model with parameters found from the notional data of
Section~\ref{sec:parameters}.
By averaging $n$ curves when
$n \in \{5,50,500,5000\}$ we see how the ensemble average approaches
the solution of the corresponding differential equation as predicted
in the Theorem of Section~\ref{sec:proposition}.
\begin{figure}[t]
\begin{center}
\pppp{five_realizations_reduced.pdf}
\ppp{stochastic_averaging_reduced.pdf}
\caption{ (Top) Five realizations of the stochastic model generated with the
parameters obtained by fitting the notional data shown in Figure
\ref{fig:notional}. Each realization is different but each roughly follows
an exponential decay when $t<t^\star=69.5$ s and an
exponential recovery for $t\ge t^\star$. (Bottom) Averages of $n$ stochastic runs for $n\in \{5,50,500,5000\}.$ As $n$ increases, the average of the ensemble approaches the fitted curve as predicted in the theorem of Section \ref{sec:proposition}.}
\label{fig:five:realizations}
\label{fig:average}
\end{center}
\end{figure}
\section{Prior work}\label{sec:prior-work}
A growing body of literature explores quantification of resilience in general and cyber resilience in particular. Very approximately, the literature can be divided into two categories:
(1) qualitative assessments of a system (actually existing or its design) by subject matter experts (SMEs) \cite{alexeev}, \cite{henshel} and
(2) quantitative measurements based on empirical or experimental observations of how a system (or its high-fidelity model; \cite{kott2017assessing}) responds to a cyber compromise \cite{kott2019cyber,ligo2021how}.
In the first category, a well-cited example is the approach called the cyber-resilience matrix \cite{linkov2013resilience}. In this approach, a system is considered as spanning four domains: (1) physical (i.e., the physical resources of the system, and the design, capabilities, features and characteristics of those resources); (2) informational (i.e., the system's availability, storage, and use of information); (3) cognitive (i.e., the ways in which informational and physical resources are used to comprehend the situation and make pertinent decisions); and (4) social (i.e., structure, relations, and communications of social nature within and around the system). For each of these domains of the system, SMEs are asked to assess, and to express in metrics, the extent to which the system exhibits the ability to (1) plan and prepare for an adverse cyber incident; (2) absorb the impact of the adverse cyber incident; (3) recover from the effects of the adverse cyber incident; and (4) adapt to the ramifications of the adverse cyber incident. In this way, the approach defines a 4-by-4 matrix that serves as a framework for structured assessments by SMEs.
Another example within the same category (i.e., qualitative assessments of a system by SMEs) is a recent, elaborate approach proposed by \cite{beling2021developmental}. The approach is called Framework for Operational Resilience in Engineering and System Test (FOREST), and a key methodology within FOREST is called Testable Resilience Efficacy Elements (TREE). For a given system or subsystem, the methodology requires SMEs to assess, among others, how well the resilience solution is able to (1) sense or discover a successful cyber-attack; (2) identify the part of the system that has been successfully attacked; (3) reconfigure the system in order to mitigate and contain the consequences of the attack. Assessment may include tests of the system, although the methodology does not prescribe the tests.
Undoubtedly, such methodologies can be very valuable in finding opportunities in improvements of cyber-resilience in a system that is either at the design stage or is already constructed. Still, these are essentially qualitative assessments, not quantitative measurements derived from an experiment.
In the second category (i.e., quantitative measurements based on empirical or experimental observations of how a system, or its high-fidelity model, responds to a cyber compromise), most approaches tend to revolve around a common idea we call here the area under the curve (AUC) method \cite{hosseini2016review,kott2021to}.
In an experiment/test, a system is engaged into a performance of a representative mission, and then is subjected to an ensemble or sequence of representative cyber attacks. A mission-relevant quantitative functionality of the system is observed and recorded. The resulting average functionality, divided by normal functionality, can be used as a measure of resilience.
Brtis \cite{brtis2016how} performed a structured evaluation and comparison of multiple resilience metrics and concluded that the AUC-based approaches are superior to others. He wrote, ``We evaluated 23 candidate metrics against 19 evaluation criteria. From this analysis we conclude that the best single metric for resiliency is the expected availability of the required capability.'' Parenthetically, our research did not find a reason to disagree with Brtis's position.
However, AUC-based resilience measures are inherently cumulative, aggregate measures, and do not tell us much about the underlying processes. For example, is it possible to quantify the resilience \impact{} of the bonware of the given system? Similarly, is it possible to quantify the \impact{} of malware? In addition, is it possible to gain insights into how these values of \impact{fulness} vary over time during an incident? We offer steps toward answering such questions.
\subsection{Constant model}
Assuming $\malware, \bonware,$ and $\Qware$ are constant, we have
\begin{equation} \label{eq:1}
\frac{d{{F}}}{dt} + \Qware {{F}}(t) = \Fnominal \bonware.
\end{equation}
\subsubsection{No bonware}
If $\bonware=0$, then Equation~\ref{eq:1} reduces to $\frac{d{{F}}}{dt} + \malware {{F}}(t) = 0$ and ${{F}}(t) = {{F}}(0) e^{-\malware t}$. If also $\malware=0$ (no bonware and no malware), then $\frac{d{{F}}}{dt}=0$ and ${{F}}(t)={{F}}(0)$.
\subsubsection{Bonware}\label{sec:4.2}
With bonware present,
the solution is
\begin{equation} \label{eq:3}
{{F}}(t) = \left[{{F}}(0) - \frac{\Fnominal \bonware}{ \Qware } \right] e^{-\Qware t} + \frac{\Fnominal \bonware}{\Qware}.
\end{equation}
\begin{figure}[th]
\centering
\aaa{figure_2_rescaled.pdf}
\caption{Normalized functionality, ${{F}}(t)/\Fnominal$, is shown for various values of $\malware$ (malware attacking) and $\bonware$ (bonware defending) and at initial conditions ${{F}}(0)/\Fnominal \in\{0.0, 0.5, 1.0 \}$. The functionality over time depends on the relative strengths of bonware and malware and on the intial condition. When the system initially is at normal functionality and when malware overpowers bonware, functionality exhibits exponential decay. When functionality initially is low, and when bonware overpowers malware, the system recovers (via Eq.~\ref{eq:3}) to $\frac{\Fnominal \bonware}{\malware+\bonware}$.}
\label{fig:2}
\end{figure}
If ${{F}}(0)>\sfrac{\Fnominal\bonware}{\Qware},$ then ${{F}}(t)$ will initially, at time $t=0$, be at ${{F}}(0)$ and decrease to $\sfrac{\Fnominal\bonware}{\Qware}$. If ${{F}}(0)>\sfrac{\Fnominal\bonware}{\Qware},$ then the function ${{F}}(t) = {{F}}(0)$ will be constant. If ${{F}}(0)<\sfrac{\Fnominal \bonware}{\Qware},$ the function will start at ${{F}}={{F}}(0)$ and increase to $\sfrac{\Fnominal \bonware}{\Qware}.$ Examples of these situations are shown in Figure~\ref{fig:2}. The plot of $(\malware>0)$ in Figure~\ref{fig:2} shows that even in the presence of bonware, malware will still have an impact on the system. \blue{The steady-state of the system is obtained either by setting $\frac{d{{F}}}{dt}=0$ in Equation~\ref{eq:1} or letting $t\to\infty:$}
\begin{equation} \label{eq:5}
{{F}}_\infty= \lim_{t\to\infty} {{F}}(t) =\Fnominal\frac{\bonware}{\malware+\bonware}
\end{equation}
so that the antidote to malware is to overwhelm it with bonware. \blue{The exponent, $-\Qware t = (-\malware-\bonware)t$ in the solution given by Equation $\ref{eq:3}$ indicates that increasing the \impact{} of either malware or bonware will cause the system to more quickly approach steady-state.}{} At steady-state,
\begin{equation}\label{eq:5a}
\begin{aligned}
\frac{ \Fnominal -{{F}}_\infty}{{{F}}_\infty} = \frac{\malware}{\malware+\bonware}.
\end{aligned}
\end{equation}
Equation~\ref{eq:5a} gives us further insight into the trade-off between impacts of both malware and bonware. The relative decrease of the function from normal functionality is equal to the ratio of malware \impact{} to the sum of malware and bonware \impact{}s.
\subsection{Linear model} \label{sec:linear}
\newcommand{\Omega(t)}{\Omega(t)}
\newcommand{\Lambda}{\Lambda}
The \impact{}s of malware and bonware may also be linear functions of $t$, so that $\malware(t) = \nu - \mu t$, $\bonware(t) = \alpha-\beta t$, and $\Qware(t) = \lambda - \omega t$, where $\lambda = \alpha + \nu$ and $\omega = \beta + \mu$. Under this linear model, Equation~\ref{eq:00} becomes
\begin{equation}
\frac{d{{F}}}{dt} + (\lambda - \omega t) {{F}}(t) = \Fnominal (\alpha - \beta t)
\label{eq:linear:model}
\end{equation}
The solution can be expressed in terms of the error function
$\blue{\erf(z)=\frac{2}{\sqrt{\pi }}\int_0^z e^{-\tau^2}\,d\tau}$:
\begin{equation}
\label{eq:6}
\begin{aligned}
\frac{{{F}}(t)}{\Fnominal} &= \frac{1}{\Omega(t)} \left\{
\frac{{{F}}(0)}{\Fnominal}
-\frac{\beta}{\omega}\left(1-{\Omega(t)}\right) +(\alpha \omega
-\beta \lambda )
\right.\\
\times&\left. \frac{\sqrt{\frac{\pi }{2}} e^{\Lambda^2} }{\omega
^{3/2}}\left[\erf\left(\Lambda\right)+\erf\left(\frac{\omega
t}{\sqrt{2 \omega }}-\Lambda\right)\right] \right\}
\end{aligned}
\end{equation}
\normalsize
where $\Omega(t) = e^{\lambda t-\frac{1}{2}\omega t^2}$, and $\Lambda = \sfrac{\lambda}{\sqrt{2 \omega }}$.
\section{Continuous model}\label{sec:continuous}
For the first set of models, we make the assumption that mission accomplishment is twice continuously differentiable: $\ma\in C^2$, and thus ${{F}} \in C^1$.
As a first approximation, we let the \impact{} of malware on the
derivative of functionality be linear.
The \impact{} of bonware is similarly defined and proportional to the
level of functionality below normal.
Malware degrades the system while bonware aims to increase
functionality over time. Malware \impact{} and bonware \impact{} are
assumed to be continuous functions of time,
$\malware, \bonware \in C^0.$ The \impact{} on functionality is the sum
of the \impact{s} of malware and bonware, and
\begin{equation}
\frac{d{{F}}}{dt} + \Qware(t) {{F}}(t) = \Fnominal \bonware (t),
\label{eq:00}
\end{equation}
where $\Qware(t)=\malware(t)+\bonware(t).$
Since we expect bonware to help (or at least not harm) and malware to
not help, we assume $\bonware(t) \ge 0$ and $\malware(t) \ge 0$. We also assume normal
functionality is positive, ${{F}}_0 > 0,$ and functionality
is always nonnegative and less than or equal to normal functionality,
$0 \le {{F}}(t) \le \Fnominal.$
This first-order linear differential equation has the following solution:
\small
\begin{equation}
F(t) = e^{-\int_0^t \Qware(p) \, dp } \left( F(0) + \bintegral \right).
\end{equation}
\normalsize
To help us understand how the model works, we find explicit solutions for a number of examples.
\subsection{Piecewise linear model}
\newcommand{\Omega_j(t)}{\Omega_j(t)}
\newcommand{\Lambda}{\Lambda}
Both malware and bonware \impact{}s may initially be linear, but if
the situation changes and a different linear model holds after a time,
the model should be able to account for it. In particular, if malware
\impact{} is decreasing over time, at some point we will reach
$\malware=0$ and the model switches to a new linear model.
Equation~\ref{eq:linear:model} can be written
\begin{equation*}
\frac{d{{F}}}{dt} = \sum_{j=0}^{N-1} \left[ (\lambda_j - \omega_j t) {{F}}(t) - \Fnominal (\alpha_j - \beta_j t) \right]. \label{eq:piecewise:linear}
\end{equation*}
The solution follows from Equation~\ref{eq:6}.
Example realizations of the piecewise linear models are shown in
Figure~\ref{fig:piecewise:linear}. The shapes of the curves resemble experimental data discussed in \cite{ellis2022experimental}.
\begin{figure}[t]
\centering
\aaa{figure_3_simplified.pdf}
\caption{Normalized functionality, ${{F}}(t)/\Fnominal$,
for piecewise linear models. \Impact{}s of malware and bonware
are linear functions of time.}
\label{fig:piecewise:linear}
\end{figure}
\subsection{Interaction between bonware and malware}
In all previous models, bonware and malware have acted independently from one another, increasing and decreasing functionality respectively. In the next version of the model, we additionally allow bonware to act on malware rather than only on functionality directly. This requires the introduction of an interaction term $\blue{I(t)}$ incorporated in the generic model of Equation~\ref{eq:sde:generic}:
$$\frac{d {{F}}}{d t}
= \left(1-{{F}}(t)\right) {\activity}^{\bonwareSuper}(t) {\effectiveness}^{\bonwareSuper}(t)\nonumber-{{F}}(t) {\activity}^{\malwareSuper}(t) {\effectiveness}^{\malwareSuper}(t) \blue{I(t)}.$$
To complete the interaction model, we may specify that $\blue{I(t)} = u\!\left(\blue{t^{\text{i}}}-t\right)$, so that the malware has its regular effect until some time $\blue{t^{\text{i}}}$, when the malware retreats or is disabled by the bonware. Figure~\ref{fig:psdel} (left) shows simulated data from this model with $\theta^{\bonwareSuper}=0.12$, ${{\gamma}^{\bonwareSuper}}=0.71$, $\theta^{\malwareSuper}=0.08$, and ${{\gamma}^{\malwareSuper}}=0.34$.
\section{Introduction}
Resilience continues to gain attention as a key property of cyber and cyber-physical systems, for the purposes of cyber defense. Although definitions vary, it is generally agreed that cyber resilience refers to the ability of a system to resist and recover from a cyber compromise that degrades the mission-relevant performance of the system \cite{kott2019cyber}. Resilience should not be conflated with risk or security \cite{linkov2018risk}.
To make the discussion more concrete, consider the example of a military ground logistics vehicle, possibly unmanned, which performs a mission of delivering heavy supplies along a difficult route. The adversary's malware successfully gains access to the Controller Area Network (CAN bus) of the vehicle \cite{bozdal2018august}. Then, the malware executes cyber attacks by sending a combination of messages intended to degrade the vehicle's performance and diminish its ability to complete its delivery mission. We assume that the malware is at least partly successful, and the vehicle indeed begins to experience a degradation of its mission-relevant performance.
At this point, we expect the vehicle's resilience-relevant elements to resist the degradation and then to recover its performance to a satisfactory level, within an acceptably short time period. These ``resilience-relevant elements'' might be of several kinds. First, because the vehicle is a cyber-physical system, certain physical characteristics of the vehicles mechanisms will provide a degree of resilience. For example, the cooling system of the vehicle will exhibit a significant resistance to overheating even if the malware succeeds in misrepresenting the temperature sensors data. Second, appropriate defensive software residing on the vehicle continually monitors and analyzes the information passing through the CAN bus \cite{kott2018}. When the situation appears suspicious, it may take actions such as blocking or correcting potentially malicious messages. Third, it is possible that a remote monitoring center, staffed with experienced human cyber defenders, will detect a cyber compromise and will provide corrective actions remotely \cite{kott2021cyber}.
For the purposes of this paper, we assume that the remote monitoring and resilience via external intervention is impossible \cite{kott2020doers}. This may be the case if the vehicle must maintain radio silence for survivability purposes, or if the malware spoofs or blocks communication channels of the vehicle. Therefore, in this paper we assume that resilience is provided by the first two classes of resilience-relevant elements. Here, by analogy with malware, we call these ``bonware'' -- a combination of physical and cyber features of the vehicle that serve to resist and recover from a cyber compromise.
A key challenge in the field of cyber resilience is quantifying or measuring resilience. Indeed, no engineering discipline achieved significant maturity without being able to measure the properties of phenomena relevant to the discipline \cite{kott2021cyber}. Developers of systems like the notional vehicle in our example must be able to quantify the resilience of the vehicle under development in order to know whether the features they introduce in the vehicle improve its cyber resilience, or make it worse.
Similarly, buyers of the vehicle need to know how to quantitatively specify and test resilience in order to determine whether the product meets their specifications.
In this paper, we report some of the results of a project called \textit{Quantitative Measurement of Cyber Resilience} (QMoCR) in which our research team seeks to identify quantitative characteristics of systems' responses to cyber compromises that can be derived from repeatable, systematic experiments. Briefly, we have constructed a test-bed in which a surrogate vehicle is subjected to controlled cyber attacks produced by malware. The vehicle is equipped with an autonomous cyber-defense system \cite{kott2020doers,kott2018} and also has some inherent physical resilience features. This ensemble of cyber-physical features (i.e., ``bonware'') strives to resist and recover from the performance degradation caused by the malware's attack. The test bed is instrumented in such a way that we can measure observable manifestations of this battle between the malware and bonware, especially the mission-relevant performance parameters of the vehicle.
The details of the test bed and the experiment are given in a companion paper \cite{ellis2022experimental}. The focus of this paper is different -– here we concentrate on constructing mathematical models that can be used to describe the dynamics of the malware-bonware battle. We seek models that are parsimonious in the number of empirical parameters and allow us to easily derive parameters of the model from experimental data.
The remainder of the paper is organized as follows. In the next section, we briefly describe prior work related to quantification of cyber resilience. We provide formal definitions of accomplishment and functionality. We propose a class of parsimonious models in which effects of both malware and bonware are approximated as deterministic, continuous differentiable variables, and we explore several variations of such models. In the following section we propose a different class of models – stochastic models, and we show how this class is related to the previously proposed class of deterministic models. Then we show how these models are used to approximate experimental data obtained with our surrogate vehicle. We show how to determine the parameters of the models from experimental data. We discuss whether these parameters might be considered quantitative characteristics (i.e., measurements) of the bonware's cyber resilience.
\subsection{Applying the SDE model}
\subsection{Parameter expansion of the SDE model}
The SDE model can be conveniently stated as a hidden Markov model and implemented as a directed acyclic graph \cite{griffiths2008bayesian} for efficient parameter estimation with a general-purpose Bayesian inference engine (e.g., JAGS; \cite{plummer2003jags}). Our implementation relied on a sequential definition for the likelihood function:
$\left({{F}}(t+1) \mid {{F}}(t), \ldots\right) \sim \dunif{L(t)}{U(t)}$, with $L(t) = {{F}}(t)-{\activity}^{\malwareSuper}(t){\effectiveness}^{\malwareSuper}(t){{F}}(t)$ and $U(t) = {{F}}(t)+{\activity}^{\bonwareSuper}(t){\effectiveness}^{\bonwareSuper}(t)\left(1-{{F}}(t)\right)$.
Since this likelihood function depends on the unknown stochastic parameters ${\activity}^{\malwareSuper}(t)$, ${\activity}^{\bonwareSuper}(t)$, ${\effectiveness}^{\malwareSuper}(t)$, and ${\effectiveness}^{\bonwareSuper}(t)$, we applied a parameter expansion approach \cite{liu1998parameter,gelman2004parameterization} using Equations~\ref{eq:sde:mwa}--\ref{eq:sde:bwe}.
\section{Quantitative measures of cyber resilience}\label{sec:qmocr}
\section{Continuous model}\label{sec:continuous}
For the first set of models, we make the assumption that mission accomplishment is twice continuously differentiable: $\ma\in C^2$, and thus ${{F}} \in C^1$.
As a first approximation, we let the \impact{} of malware on the
derivative of functionality be linear:
$\frac{d{{F}}_m(t)}{dt} = - {{F}}(t) \malware(t)$.
The \impact{} of bonware is similarly defined and proportional to the
level of functionality below normal.
$\frac{d{{F}}_b(t) } {dt} = (\Fnominal-F(t)) \bonware(t)$.
Malware degrades the system while bonware aims to increase
functionality over time. Malware \impact{} and bonware \impact{} are
assumed to be continuous functions of time,
$\malware, \bonware \in C^0.$ The \impact{} on functionality is the sum
of the \impact{s} of malware and bonware:
$\frac{d{{F}}(t)}{dt} = \frac{d{{F}}_m(t)}{dt} +
\frac{d{{F}}_b(t)}{dt}$. Then
\begin{equation}
\frac{d{{F}}}{dt} = (\Fnominal-{{F}}(t)) \bonware(t) - {{F}}(t) \malware(t).
\label{eq:0}
\end{equation}
Since we expect bonware to help (or at least not harm) and malware to
not help, we assume $\bonware(t) \ge 0$ and $\malware(t) \ge 0$ and we
let $\Qware(t)=\malware(t)+\bonware(t).$ We also assume normal
functionality is positive, ${{F}}_0 > 0,$ and functionality
is always nonnegative and less than or equal to normal functionality,
$0 \le {{F}}(t) \le \Fnominal.$ Equation~\ref{eq:0} can be
written as
\begin{equation}
\frac{d{{F}}}{dt} + \Qware(t) {{F}}(t) = \Fnominal \bonware (t).
\label{eq:00}
\end{equation}
This first-order linear differential equation has the following solution:
\begin{equation}
F(t) = e^{-\int_0^t \Qware(p) \, dp } \left( F(0) + \bintegral \right).
\end{equation}
To help us understand how the model works, we find explicit solutions for a number of examples. We start with a piecewise constant malware \impact{}, piecewise constant bonware \impact{}, and also look at a piecewise linear model.
\section{An application of the model}
\subsection{Obtaining model parameters}
\label{sec:parameters}
Given notional data that represents a typical curve of functionality
over the course of an incident where malware and bonware are active,
we develop a fast method to estimate the continuous model parameters
for a curve that approximates the data, and use these parameters to
generate further realizations based on this model. In Figure
\ref{fig:notional} an example of such notional data is plotted (in
light blue/gray). In this section, we illustrate our method to
extract the model parameters from this curve.
The set $P=\{t_0, \hdots, t_K\}$ partitions the mission timeline and
malware and bonware are constant in each interval $(t_{i-1},t_i), \,\,
i=1, \hdots, K. \,\,$ In each interval,
$\Qware_i=\malware_i+\bonware_i$ and the differential equation
governing Continuous Model I is $\frac{dF(t)}{dt}+\Qware_i F(t) =
\Fnominal (t) \bonware_i.$ Thus, in each interval $(t_{i-1},t_i),$
the solution is
\begin{equation*}
{{F}}(t) =
\left[{{F}}(t_{i-1}) - \frac{\Fnominal \bonware_i}{
\Qware_i } \right] e^{-\Qware_i (t-t_{i-1})} + \frac{\Fnominal \bonware_i}{\Qware_i}.
\end{equation*}
We compute the effectiveness, ${\effectiveness}^{\malwareSuper}$, and activity, ${\activity}^{\malwareSuper}$, of malware
and of bonware (${\effectiveness}^{\bonwareSuper}, {\activity}^{\bonwareSuper}$), in each interval:
$\malware_i = {\effectiveness}^{\malwareSuper}_i {\activity}^{\malwareSuper}_i$, $\bonware_i = {\effectiveness}^{\bonwareSuper}_i {\activity}^{\bonwareSuper}_i$.
We observe that there is a unique switching time $\tchange$ where the
functionality's trend reverses, and thus we take $K=2.$ Before the
switch, the impact of malware is greater than that of bonware. From
the time of the switch until the end of the mission, bonware is
stronger. To estimate the switching time $\tchange$, we find the
minimum of the data to occur over the interval from 64 s to 75 s.
There, the minimum value of the data curve is $m=0.27$. Taking the
midpoint, our estimate for $\tchange$ is 69.5 s. We estimate the
activity of malware before switching to be the number of times the
data curve decreases divided by the switching time. Similarly, our
estimate of bonware activity is the number of times the data curve
increases prior to the switching time. We thus have
${\activity}^{\malwareSuper}_1~\approx~\sfrac{7}{69.5}~\approx 0.101$ and
${\activity}^{\bonwareSuper}_1 \approx \sfrac{2}{69.5} \approx 0.014$.
To determine the remaining parameters, we numerically solve this system of equations:
\begin{align*}
\alpha m & = \Fnominal \bonQone,\\
m & = {{F}}(0) -\Fnominal \bonQone e^{-\Qware_1 \tchange}+\Fnominal \bonQone.
\end{align*}
The first equation says that where the curve meets the minimum of the data, it has experienced exponential decay of $\alpha$ toward the asymptotic minimum. We take $\alpha$ to be $\alpha=1-\sfrac{1}{e}$. The second equation says that the minimum occurs at the switching time (the time when the model switches from malware dominating bonware, to bonware dominating malware. Solving this system of equations yields (with $\malware_1=\Qware_1-\bonware_1$), $\malware_1 \approx 0.025$ and $\bonware_1 \approx 0.005$, so that ${\effectiveness}^{\malwareSuper}_1 = \sfrac{\malware_1}{{\activity}^{\malwareSuper}_1} \approx 0.503$ and ${\effectiveness}^{\bonwareSuper}_1 = \sfrac{\bonware_1}{{\activity}^{\bonwareSuper}_1}\approx 0.362$.
To the right of $t^\star$, we fit an exponentially increasing function. Similar to before the switching time, we compute the activities of the malware and bonware: ${\activity}^{\malwareSuper}_2 \approx \frac{1}{100-69.5} \approx 0.033$ and ${\activity}^{\bonwareSuper}_2 \approx \frac{4}{100-69.5} \approx 0.131$.
To determine the remaining parameters, we numerically solve this system of equations:
\begin{align*}
\zeta & = F(0) \bonQtwo,\\
\tilde{\alpha} \zeta & = \left(m-\Fnominal
\bonQtwo\right)\left(e^{-\Qware_2 (125-t^\star)}+\Fnominal \bonQtwo\right).
\end{align*}
We have found that $\tilde{\alpha}=1-e^{-4}$ and $\zeta=0.95$ are
satisfactory values to use for these hyperparameters.
We compute $\malware_2 \approx 0.005$ and $\bonware_2 \approx 0.088$, so that ${\effectiveness}^{\malwareSuper}_1 = \sfrac{\malware_1}{{\activity}^{\malwareSuper}_1} \approx 0.201$ and ${\effectiveness}^{\bonwareSuper}_1 = \sfrac{\bonware_1}{{\activity}^{\bonwareSuper}_1}\approx 0.957$.
\subsection{Generating stochastic realizations}
Using the parameters found in Section~\ref{sec:parameters}, we can now
generate stochastic realizations. In Section~\ref{sec:proposition},
we showed that for large sample sizes, the average of our ensemble
will approach the solution to the continuous ODE model. We show
empirically that this is indeed the case. To illustrate, we generated
five realizations (Figure \ref{fig:five:realizations}) of the
stochastic model with parameters found from the notional data of
Section~\ref{sec:parameters}. We averaged these curves to obtain the
$n=5$ curve in Figure~\ref{fig:average}. By averaging $n$ curves when
$n \in \{5,50,500,5000\}$ we see how the ensemble average approaches
the solution of the corresponding differential equation as predicted
in the Theorem of Section~\ref{sec:proposition}.
\begin{figure}[ht]
\begin{center}
\aaa{five_realizations_reduced.pdf}
\caption{Five realizations of the stochastic model generated with the
parameters obtained by fitting the notional data shown in Figure
\ref{fig:notional}. Each realization is different but each roughly follows
an exponential decay when $t<t^\star=69.5$ s and an
exponential recovery for $t\ge t^\star$. }
\label{fig:five:realizations}
\end{center}
\end{figure}
\begin{figure}[ht]
\centering
\aaa{stochastic_averaging_reduced.pdf}
\caption{Averages of $n$ stochastic runs for $n\in \{5,50,500,5000\}.$ As $n$ increases, the average of the ensemble approaches the fitted curve as predicted in the theorem of Section \ref{sec:proposition}. }
\label{fig:average}
\end{figure}
\subsection{Relationship between continuous and SDE model}\label{sec:proposition}
With the parameters of the stochastic model selected appropriately, we show that as the number of stochastic realizations increases, the expectation of the solution to the stochastic differential equation model approaches that of the ODE model. We show this for the simple constant parameter case. The general result follows by extension.
\newtheorem*{theorem}{Theorem}
\begin{theorem}
Let $y^m_k \sim \dbern{2\malware}$, $y^b_k \sim
\dbern{2\bonware}$, $z^m_{k} \sim \dunif{0}{{{F}}_{k}}$, $z^b_{k} \sim \dunif{0}{\Fnominal-{{F}}_{k}}$, and
\begin{equation} \label{eq:stochastic:diff}
{{F}}_{k+1} = {{F}}_{k}
- y^m_{k} z^m_{k}
+ y^b_{k} z^b_{k}, \quad (k=1,\hdots,K).
\end{equation}
Let ${\mathcal{F}_k}_n=\frac{{{{F}}_k}_j}{n}$, $(j=1,\hdots,n)$, then\\
\blue{$\mathcal{F}_k~=~\mathbb{E} ({{F}}_k)~=~\lim_{n\to\infty}
{\mathcal{F}_k}_n$ and $\mathcal{F}_k\approx {{F}}(k),$ for
large $k$,
where ${{F}}(t)$ is the solution to the initial value problem
given by Equation~\ref{eq:1} with $F(0)=\mathcal{F}_0.$}
\end{theorem}
\begin{proof}
\blue{Take the expectation of Equation~\ref{eq:stochastic:diff}. Then
$\mathcal{F}_k~-~\mathcal{F}_{k-1}+ (\malware+\bonware)
\mathcal{F}_{k-1}=\Fnominal \bonware$. With
${\mathcal{F}_0}_n=\mathcal{F}_0,$
the~solution~is
$\mathcal{F}_k = \left[\mathcal{F}_0 - \frac{\Fnominal
\bonware}{ \Qware } \right] (1-\Qware)^k + \frac{\Fnominal
\bonware}{\Qware},$ which approximates Equation~\ref{eq:3} for large
$k$.}
\end{proof}
\subsection{Piecewise linear model}
\newcommand{\Omega_j(t)}{\Omega_j(t)}
\newcommand{\Lambda}{\Lambda}
Both malware and bonware \impact{}s may initially be linear, but if
the situation changes and a different linear model holds after a time,
the model should be able to account for it. In particular, if malware
\impact{} is decreasing over time, at some point we will reach
$\malware=0$ and the model switches to a new linear model.
Equation~\ref{eq:linear:model} can be written
\begin{equation*}
\frac{d{{F}}}{dt} = \sum_{j=0}^{N-1} \left[ (\lambda_j - \omega_j t) {{F}}(t) - \Fnominal (\alpha_j - \beta_j t) \right]. \label{eq:piecewise:linear}
\end{equation*}
The solution follows from Equation~\ref{eq:6}:
\begin{align*} \label{eq:piecewise:linear:solution}
\frac{{{F}}(t)}{\Fnominal} &= \frac{1}{\Omega_j(t)}
\left\{
\frac{{{F}}(t_j)}{\Fnominal}-\frac{\beta_j}{\omega_j }\left(1-\Omega_j(t)\right) +(\alpha_j \omega_j -\beta_j \lambda_j )\right.\\
\times & \left. \frac{\sqrt{\frac{\pi }{2}} e^{\Lambda_j^2 }}{\omega_j^{3/2}} \left[\text{erf}\left(\Lambda_j\right)+\text{erf}\left(\frac{\omega_j (t-t_j) }{\sqrt{2 \omega_j }}-\Lambda_j\right)\right] \right\},\\
& \quad (t_j \le t < t_{j+1}), \quad (j=0,\cdots, N-1)
\end{align*}
where $\Omega_j(t)=e^{\lambda_j (t-t_j)-\frac{1}{2}\omega_j (t-t_j)^2 }$ and $\Lambda_j=\sfrac{\lambda_j }{\sqrt{2 \omega_j }}$.
Example realizations of the piecewise linear models are shown in Figure~\ref{fig:piecewise:linear}.
\begin{figure}[th]
\centering
\aaa{figure_3_rescaled.pdf}
\caption{Normalized functionality, ${{F}}(t)/\Fnominal$, is shown for piecewise linear models. Both malware and bonware \impact{}s are initially linear functions of time. When malware \impact{} reaches $\malware=0$, then malware \impact{} is zero but bonware \impact{} continues to increase.}
\label{fig:piecewise:linear}
\end{figure}
\subsection{Piecewise constant model}
If either malware's or bonware's impact diminishes at some point in the incident, the model may switch from one set of constants defining malware and bonware to another set of constants. The differential equation (Eq.~\ref{eq:0}) may now be expressed as
\begin{equation}
\frac{d{{F}}}{dt} = \sum_{j=0}^{N-1}(\Fnominal-{{F}}(t)) \bonware_j(t) - {{F}}(t) \malware_j (t),
\label{eq:000}
\end{equation}
where the vectors $\boldsymbol{\malware} =( {\malware}_0, {\malware}_1, \cdots {\malware}_{N-1} )$ and $\boldsymbol{\bonware} =( {\bonware}_0, {\bonware}_1,\cdots, {\bonware}_{N-1})$ contain the malware \impact{} and bonware \impact{}s within time windows whose end points are defined by $\{t_0, t_1, \cdots, t_N \}$. The solution will be a function which, in each time interval, is the solution found in Equation~\ref{eq:3}:
\begin{align*} \label{eq:piecewise:constant}
{{F}}(t) = \left[{{F}}(t_j) - \frac{\Fnominal \bonware_j}{ \Qware_j }
\right] e^{-\Qware_j\cdot (t-t_j)} + \frac{\Fnominal \bonware_j}{\Qware_j},\\
\quad (t_j \le t < t_{j+1}), \quad (j=0,\cdots, N-1)
\end{align*}
where $\Qware_j = \malware_j + \bonware_j$. The smooth line in Figure~\ref{fig:notional} is an example realization of this model.
\begin{figure}[h]
\centering
\aaa{curves_rescaled.pdf}
\caption{The smooth line is an example functionality curve with piecewise constant malware and bonware impacts. The notional data and piecewise constant model fit are described below in Section \ref{sec:parameters}.}
\label{fig:notional}
\end{figure}
\section{Prior work}\label{sec:prior-work}
A growing body of literature explores quantification of resilience in general and cyber resilience in particular. Very approximately, the literature can be divided into two categories:
(1) qualitative assessments of a system (actually existing or its design) by subject matter experts (SMEs) \cite{alexeev}, \cite{henshel} and
(2) quantitative measurements based on empirical or experimental observations of how a system (or its high-fidelity model; \cite{kott2017assessing}) responds to a cyber compromise \cite{kott2019cyber,ligo2021how}.
In the first category, a well-cited example is the approach called the cyber-resilience matrix \cite{linkov2013resilience}. In this approach, a system is considered as spanning four domains: (1) physical (i.e., the physical resources of the system, and the design, capabilities, features and characteristics of those resources); (2) informational (i.e., the system's availability, storage, and use of information); (3) cognitive (i.e., the ways in which informational and physical resources are used to comprehend the situation and make pertinent decisions); and (4) social (i.e., structure, relations, and communications of social nature within and around the system). For each of these domains of the system, SMEs are asked to assess, and to express in metrics, the extent to which the system exhibits the ability to (1) plan and prepare for an adverse cyber incident; (2) absorb the impact of the adverse cyber incident; (3) recover from the effects of the adverse cyber incident; and (4) adapt to the ramifications of the adverse cyber incident. In this way, the approach defines a 4-by-4 matrix that serves as a framework for structured assessments by SMEs.
Another example within the same category (i.e., qualitative assessments of a system by SMEs) is a recent, elaborate approach proposed by \cite{beling2021developmental}. The approach is called Framework for Operational Resilience in Engineering and System Test (FOREST), and a key methodology within FOREST is called Testable Resilience Efficacy Elements (TREE). For a given system or subsystem, the methodology requires SMEs to assess, among others, how well the resilience solution is able to (1) sense or discover a successful cyber-attack; (2) identify the part of the system that has been successfully attacked; (3) reconfigure the system in order to mitigate and contain the consequences of the attack. Assessment may include tests of the system, although the methodology does not prescribe the tests.
Undoubtedly, such methodologies can be very valuable in finding opportunities in improvements of cyber-resilience in a system that is either at the design stage or is already constructed. Still, these are essentially qualitative assessments, not quantitative measurements derived from an experiment.
In the second category (i.e., quantitative measurements based on empirical or experimental observations of how a system, or its high-fidelity model, responds to a cyber compromise), most approaches tend to revolve around a common idea we call here the area under the curve (AUC) method \cite{hosseini2016review,kott2021to}.
In an experiment/test, a system is engaged into a performance of a representative mission, and then is subjected to an ensemble or sequence of representative cyber attacks. A mission-relevant quantitative functionality of the system is observed and recorded. The resulting average functionality, divided by normal functionality, can be used as a measure of resilience.
However, AUC-based resilience measures are inherently cumulative, aggregate measures, and do not tell us much about the underlying processes. For example, is it possible to quantify the resilience \impact{} of the bonware of the given system? Similarly, is it possible to quantify the \impact{} of malware? In addition, is it possible to gain insights into how these values of \impact{fulness} vary over time during an incident? We offer steps toward answering such questions.
\subsection{Constant parameters}
In the simplest version of the SDE model, we assume that the rate of malware attacks and their maximum efficiency are constant in time, and that the rate of bonware restoration and its maximum efficiency are both constant in time. Specifically, under this model it is assumed that $\theta^{\malwareSuper}(t) = \theta^{m}$, $\theta^{\bonwareSuper}(t) = \theta^{b}$, ${{\gamma}^{\malwareSuper}}(t) = \gamma^{m}$, and ${{\gamma}^{\bonwareSuper}}(t) = \gamma^{b}$ (cf.\ Eqs.~\ref{eq:sde:mwa}--\ref{eq:sde:bwe}).
This version of the model is parsimonious, with only four free parameters, each with a useful interpretation.
\section{Discussion and conclusion}
We have presented a broadly applicable framework for the analysis of the cyber resilience of military artifacts. Our framework relies on the construction of a custom differential equation time series model that shows good qualitative correspondence to the functionality of vehicles performing missions. Seeking to move beyond the use of area-under-the-curve quantifications of cyber resilience, our proposed models have the advantage that their parameters have domain-relevant interpretations such as \textit{the activity of malware} and \textit{the effectiveness of bonware}. Such interpretable parameters can provide a more nuanced interpretation of cyber resilience data
being experimentally obtained in our lab.
Our formal models come in two families with complementary advantages. A series of continuous models is parsimonious, mathematically convenient, and easy to fit. A series of discrete, stochastic models shows greater verisimilitude but is slightly less parsimonious and requires more computationally onerous parameter estimation techniques.
Both types of models can be extended to a large variety of custom circumstances, including the case where model parameters change gradually, abruptly, or predictably as a result of experimental manipulation. Future work will include an extension to the cases of multiple simultaneous objectives and to the case of multiple vehicles to be analyzed jointly.
\subsection{Cyber resilience}
In Section~\ref{sec:prior-work} we discussed a measure of cyber resilience, the area under the functionality curve, which is precisely the mission accomplishment $\ma(T)$ evaluated at the final time of the mission. To be able to compare measures of cyber resilience for multiple missions, we normalize the measure by dividing by the total mission time.
\begin{equation*}
R= \frac{1}{T-t_0} \int_{t_0}^T {{F}}(\tau) \, d\tau =
\frac{\ma(T)}{T-t_0}.
\end{equation*}
Often there are multiple objectives to a mission. Given a vector of resiliences, $\mathbf{R} =(R_1,R_2, \hdots, R_n),$ we define the overall cyber resilence to be the
root-mean-square resilience of our mission:
\begin{eqnarray*}
R= ||\mathbf{R}||_2
=
\frac{1}{T-t_0}
\sqrt{
\sum_{j=1}^n
\left( \int_{t_0}^T {{F}}_j(\tau) \, d\tau \right)^2}.
\end{eqnarray*}
\normalsize
Because each mission accomplishment may have a different relative importance, we may account for this by weighting the normal functionalities ${\Fnominal}_j$. To enforce an overall mission resilience in the range $[0,1]$, we renormalize to obtain normalized resilience $\mathcal{R}$.
\begin{equation*}
\mathcal{R} = \frac{R}{\left( \sum_{j=1}^n {\Fnominal}_j^2\right)^{1/2} }.
\end{equation*}
\subsection{Gradually changing parameters}\label{sec:sde:gradual}
In a final variation of the SDE model, we allow parameters ${\activity}^{\bonwareSuper}(t)$ and ${\activity}^{\malwareSuper}(t)$ to evolve gradually over time. A possible application of such a model is the scenario in which malware and bonware actively explore weaknesses and their probability of success may increase over time. A simulated example of a functionality curve in such a scenario is give in Figure~\ref{fig:psdel} (right). The functionality shows a period of decrease during the initial period of attack, then a period of high variability as both malware and bonware are active, and a period of recovery after the conclusion of the attack.
Underlying this pattern is the bonware activity that gradually increases, ${\activity}^{\bonwareSuper}(t) = \Phi(at+b)$, and malware activity that gradually increases until it is turned off at time $\blue{t^{\text{i}}}$, ${\activity}^{\malwareSuper}(t) = \Phi(ct+d)u(\blue{t^{\text{i}}}-t)$, where
\blue{$\Phi(z)=\frac{1}{2}+\frac{1}{2} \erf{(\frac{z}{\sqrt{2}})}$}{} is the cumulative density function of the standard normal distribution.
\begin{figure*}[ht]
\centering
\ppp{figures/piecewise_stochastic_step_with_interaction-sim-small.pdf}
\qqq{figures/piecewise_stochastic_step_linear_parameters-sim-small.pdf}
\caption{\textbf{Left:} Simulated data from the SDE model with interaction between bonware and malware. The angular blue-grey line depicts functionality over mission time. Changes in functionality occur at random intervals and random step sizes. The red line and downward pointing marker indicate the period during which malware is active. This period permits downward steps in functionality. The green line and upward pointing marker indicate period during which bonware is active. This period permits upward steps in functionality. The red marker indicates the onset of a cyber attack and the green marker indicates its conclusion. \textbf{Right:} Simulated data from the SDE model with gradually changing parameters. Here, the probability that an attack will harm functionality is depicted as a smooth orange curve. The probability increases over mission time until the attack is repelled. The smooth purple curve indicates the probability that a bonware attempt to restore functionality is successful. As the smooth curves rise, the rate of steps in the functionality curve increases. Data were simulated from the equations in Section~\ref{sec:sde:gradual} with $a=0.063$, $b=-6.0$, $c=0.025$, $d=-1.5$.}
\label{fig:psdel}
\end{figure*}
\section{Stochastic differential equation model}
In this section, we extend the previously defined differential equation (DE) model to a \textit{stochastic} differential equation (SDE) model. The extension is motivated by the discontinuous nature of the notional data in Figure~\ref{fig:notional}. Whereas the DE model assumed a smooth functionality curve, our stochastic version allows for a more punctuated attack-and-restoration pattern.
In the SDE model, both malware and bonware may be active at random (or a priori unknown) times with random (or a priori unknown) effectiveness. Let malware activity ${\activity}^{\malwareSuper}(t) \in \{0,1\}$ indicate whether malware was successful at time $t$, bonware activity ${\activity}^{\bonwareSuper}(t) \in \{0,1\}$ indicate whether bonware was successful at time $t$, malware effectiveness ${\effectiveness}^{\malwareSuper}(t) \in [0,1)$ express the proportion of functionality reduced by the malware's success at time $t$, and bonware effectiveness ${\effectiveness}^{\bonwareSuper}(t) \in [0,1)$ express the proportion of damage undone by the bonware's success at time $t$. The SDE analog to Equation~\ref{eq:00} is then
\begin{equation}\label{eq:sde:generic}
\frac{d {{F}}}{d t}
= \left(\Fnominal-{{F}}(t)\right) {\activity}^{\bonwareSuper}(t) {\effectiveness}^{\bonwareSuper}(t) - {{F}}(t) {\activity}^{\malwareSuper}(t) {\effectiveness}^{\malwareSuper}(t).
\end{equation}
Rather than changing deterministically over time, these model parameters are assumed to vary stochastically according to these distributions:
\begin{eqnarray}
{\activity}^{\malwareSuper}(t) &\sim& \dbern{\theta^{\malwareSuper}(t)}\label{eq:sde:mwa}, \\
{\activity}^{\bonwareSuper}(t) &\sim& \dbern{\theta^{\bonwareSuper}(t)}\label{eq:sde:bwa}, \\
{\effectiveness}^{\malwareSuper}(t) &\sim& \dunif{0}{{{\gamma}^{\malwareSuper}}(t)}\label{eq:sde:mwe},\\
{\effectiveness}^{\bonwareSuper}(t) &\sim& \dunif{0}{{{\gamma}^{\bonwareSuper}}(t)}\label{eq:sde:bwe},
\end{eqnarray}
where $\dbern{\theta}$ indicates the Bernoulli distribution with rate $\theta$ and $\dunif{0}{\gamma}$ indicates a uniform distribution with lower bound $0$ and upper bound $\gamma$. Hence, $\theta^{\malwareSuper}(t) \in {[0,1]}$ is the probability that malware is successful at time $t$, $\theta^{\bonwareSuper}(t) \in {[0,1]}$ is the probability that bonware is successful at time $t$, ${{\gamma}^{\malwareSuper}}(t) \in {(0,1]}$ is the maximum fraction of damage inflicted by malware, and ${{\gamma}^{\bonwareSuper}}(t) \in {(0,1]}$ is the maximum fraction of damage undone by bonware.
Like the ordinary differential equation (ODE) model, the SDE model allows for a number of interesting variants. In the remainder of this section, we introduce some useful simplifications and extensions.
\subsection{Piecewise constant model}
If either malware's or bonware's impact diminishes at some point in the incident, the model may switch from one set of constants defining malware and bonware to another set of constants. The differential equation (Eq.~\ref{eq:00}) may now be expressed as
\begin{equation}
\frac{d{{F}}}{dt} = \sum_{j=0}^{N-1}(\Fnominal-{{F}}(t)) \bonware_j(t) - {{F}}(t) \malware_j (t),
\label{eq:000}
\end{equation}
where the vectors $\boldsymbol{\malware} =( {\malware}_0,
{\malware}_1, \cdots {\malware}_{N-1} )$ and $\boldsymbol{\bonware} =(
{\bonware}_0, {\bonware}_1,\cdots, {\bonware}_{N-1})$ contain the
malware \impact{} and bonware \impact{}s within time windows whose end
points are defined by $\{t_0, t_1, \cdots, t_N \}$. The solution will
be a function which, in each time interval, is the solution found in
Equation~\ref{eq:3}. The purple curve in Figure \ref{fig:notional} is
a realization of this model.
\begin{figure}[t]
\centering
\aaa{curves_rescaled.pdf}
\caption{The smooth line is an example functionality curve with piecewise constant malware and bonware impacts. The notional data and piecewise constant model fit are described below in Section \ref{sec:parameters}.}
\label{fig:notional}
\end{figure}
| {'timestamp': '2023-03-03T02:00:06', 'yymm': '2302', 'arxiv_id': '2302.04413', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04413'} | arxiv |
\section{Introduction}\label{sec:introduction}
\IEEEPARstart{M}{o}del quantization has attracted increasing attention recently as an effective solution that improves the computation and memory efficiency for deep neural networks (DNN), thus enabling the deployment of deep models on resource-constrained edge devices~\cite{wang2022survey,post,HAWQ-v2,deep,dorefa,pact,Lu2019Lip,zhang2018deepvoice}. Specifically, the lower description bit-width of DNN can bring about significant benefits in terms of inference acceleration and model compression rate, for example, Int8/Int4 quantization and binary neural networks~\cite{irnet}. However, it inevitably causes a greater accuracy drop than higher description bit-width models due to unavoidably more information loss.
To maximally excavate the description redundancy and learn the compressed model for a given training domain, mixed-precision quantization~\cite{HAWQ-v2,hawq,HAWQ-V3,daam,FracBits,post,AutoQ} has been proposed to explore a better balance between task performance and model description length.
It allows network components, e.g., layers~\cite{haq} or kernels~\cite{AutoQ}, to be quantized with lower bit-widths instead of full precision bit-widths if they have less contribution to model accuracy, wherein, more sensitive components are quantized with relatively higher bit-widths to avoid large accuracy degradation and vice versa.
Despite the more balanced compression power, the mixed bit-widths can bring about unique challenges for the quantization setting exploration and model training. Concretely, the search space for determining a sufficiently good mixed-precision quantization setting can grow exponentially with increasing number of layers and bit-width choices.
For example, when a ResNet-152 is quantized layer-wisely with 4 possible bit-widths, the search space can easily reach $4^{152}$ times. Worse still, the inherently discrete and non-differentiable bit-width decision-making (or sampling process) makes it hard to learn the bit-width policy jointly with quantization training.
To deal with the above challenges, existing state-of-the-art (SOTA) works usually decouple the non-derivable bit-width sampling process from the end-to-end supervised training, i.e., consisting of two mutually independent precision decision-making stage and quantization training stage.
Some representative methods include state-of-the-art HAWQ series~\cite{HAWQ-v2,hawq,HAWQ-V3}, DMBQ~\cite{daam}, FracBits~\cite{FracBits}, AutoQ~\cite{AutoQ}, etc.
For example, The HAWQ series~\cite{HAWQ-v2,hawq,HAWQ-V3} measure the relative sensitivity of layers via layer-wise hessian information and develop a Pareto frontier based method to make hessian-based bit-width decisions before model quantization.
Differently, DMBQ~\cite{daam} tries to search for an optimal bit-width setting over the distribution space beforehand and quickly selects one setting via this prepared fast lookup table during training.
In general, previous
These state-of-the-arts make satisfying bit-width decisions under the guidance of hardware feedback~\cite{haq} or gradient-based information~\cite{hawq} before the actual quantization training, as well as the practical inference, while all their bit-width selection and quantization training are done in the given narrow data domain with quality-consistent training setting. \par
In real-world application, such decoupled training process can inevitably lead to the data isolation issue between three stages of precision decision-making, quantization training, and practical inference, which can result in sub-optimal performance.
Besides, the static quality-consistent training setting is not robust against data quality changes in practice, which may further deteriorate the effect of the prior bit-width decision and obtain poor robustness of the quantized models.
Notably, our observation suggests a non-negligible view that the data quality can have a significant impact on the quantization setting decision due to the changing of relative layer sensitivities to quantization in networks.
As demonstrated in Fig.~\ref{losss}, we show a demo case of the loss changing on different data qualities, where `level\_0' denotes the quantized model trained on standard CIFAR-10 dataset. The input images are getting blurrier from `level\_0' to `level\_2'.
To augment images with various qualities, we apply random quantization perturbations to the original quantization model along the direction of the Hessian matrix at the convergence point.
Assume the data quality does not alter the optimal quantization settings, the minimum task loss should occur when the perturbation is 0.
However, we get the opposite result. The loss-curve is as expected only if the quality of the test image is the same as the training image. The optimal model description bit-widths can change when the quality of the test image varies, i.e., more specifically, the greater the difference of qualities, the larger the deviation of the model parameters w.r.t the minimum loss point.
Horizontally, we can also observe that as the image noise increases, the deviation of the quantization convergence point from the original parameters becomes larger.
In summary, the above findings indicate a huge contradiction between previous quantization works and the need to infer on environment-sensitive devices with unpredictably and dynamically changing input qualities.
\begin{figure}[t]
\centering
\includegraphics[width = 0.87\columnwidth]{losss.png}
\caption{Loss changing of quantization model with different data qualities. `level' denotes the degree of Gaussian blur, i.e., the larger the value, the blurrier the image. }
\label{losss}
\end{figure}
In this paper, our interest is to explore the optimal compressed model by mixed-precision quantization from a new perspective, \textit{i.e., data rather than the model}, and to improve both the generalization and robustness of quantized models. The motivation stems from the fact that, in real-world applications, it is usually impossible to control the source distribution of data, such as camera blur, transmission noise, etc.
To deal with such issues, we propose a Data Quality-aware Mixed-precision Quantization method, dubbed DQMQ, consisting of two lightweight plug-ins to facilitate data quality-aware bit-width decision-making and one-shot quantization model training, respectively.
First, the Precision Decision Agent (PDA) plug-in can automatically generate the current optimal layer-wise quantization bit-widths setting during forward propagation.
Then, the Quantization Auxiliary Computer (QAC) plug-in is used to eliminate the accumulation of quantization biases due to the undetermined precision decision policy.
Moreover, by feeding mixed-quality samples, the discrete bit-width sampling distribution can be learned jointly with model parameters in a one-shot and continuous scheme.
Being small and light, our plug-ins also hold the following features: 1) be deployed in the training phase and can be removed flexibly during other phases; and 2) can be easily applied to most mainstream neural networks.
Our contributions are summarized as follows:
\begin{itemize}
\item We first indicate that the data quality can significantly affect the layer-wise quantization sensitivity, and upon which, we propose a novel data quality-aware mixed-precision quantization method to address such issues.
\item We incorporate the previously decoupled bit-width precision decision-making model parameter training into a one-shot scheme, which significantly improves the efficiency and resolves the data isolation. Moreover, we also provide a theoretical derivation to prove its feasibility.
\item Experiments on various datasets and mainstream networks demonstrate the effectiveness of our method. In particular, our DQMQ outperforms the SOTA HAWQ-v2 by 12.7$\%$ in MAP and 7.30$\times$ in model compression rate, respectively.
\end{itemize}
\section{Related Works}
\subsection{Mixed-Precision Quantization}
An intractable issue in conventional fixed-precision model quantization is that high bit-width quantization can ensure high precision, while the memory footprint and calculation cost are also sufficient large. On the contrary, the memory usage and calculation cost can be smaller with lower quantization precision, while this unavoidably leads to significant quantization accuracy degradation. This essential dilemma makes quantization under fixed bit-width can hardly achieve a fine-grained trade-off between accuracy and FLOPs.
To fully exploit the model redundancy and obtain more balanced compression power, mixed-precision is proposed.
It achieves further efficient compression of the model and brings better quantization benefits due to precision flexibility~\cite{DBLP:journals/corr/abs-1812-00090, post}. For example, DMBQ~\cite{daam} searches the optimal quantization scheme over the distribution space beforehand and selects the quantization scheme during training using a fast lookup table-based strategy. Wang \textit{et al.}~\cite{haq} estimate layer-wise resource cost by simulators, and combine the hardware indicators to constrain the bit-widths search for each layer. Later, offline bit-widths decision-making based on the layer-wise Hessian Spectrum is enabled in HAWQ serious~\citep{hawq, HAWQ-v2, HAWQ-V3}.
These studies have produced outstanding results when compared to single-precision quantization.
However, the majority of them decouple the actual quantization training and quantization bitwidth selection due to the discrete mixed bitwidth selection procedure.
In other words, even when the quality and distribution of the input data are expected to change throughout quantization training, they consistently believe the pre-selected bit width to be the best option.
And our experimental results in the previous section have proved that this is wrong.
\subsection{Quantization Aware Training}
Quantization Aware Training (QAT) fits feature inputs to quantized parameters that are as low as possible in bit-width while minimizing the loss in optimization target jointly in the training process. Specifically, a typical QAT pipeline simulates a quantization procedure by introducing fake quantization operations to model weights and activations during the forward propagation, while the gradient update is still performed on vanilla float parameters during the backpropagation as if the quantification never happened \cite{Jacob_2018_CVPR}. However, because of the inherently discrete and non-derivative quantization operations, QAT cannot calculate accurate gradients like a standard smooth neural network in backpropagation. A common practice is to use a gradient straight-through estimator (STE)~\cite{ste1}, which fits the parameters of a discontinuous function to an approximately continuous function and ignores the impact of quantization. Esser \textit{et al.}~\cite{esser} introduces a novel means to estimate and scale the task loss gradient for each weight and activation and enable it to be learned in conjunction with other network parameters. Although these methods under QAT schemes achieve excellent performance, most of them require great resource cost and significant time on re-training and hyper-parameter tuning \cite{updown}. Our work removes these redundancies through one-shot training and a lightweight quantizer.
\subsection{Post-training Quantization}
Post-training Quantization (PTA) quantizes neural networks during practical deployment after the standard model training stage. In the quantization process, it selects appropriate quantization and/or calibration operations for the pre-trained network to minimize quantization loss. Without re-training, PTA is simpler to use and allows for quantization with limited data conditions. For example, many PTA works need only a small calibration set: Fang~\textit{et al.}~\cite{fang2020post} proposed Piecewise Linear Quantization (PWLQ) to solve the great accuracy drop in uniform quantization with lower bit-width. It finds optimal segmentation breakpoints to obtain lower quantization errors and only needs a small amount of calibration data.
Furthermore, there are even some PTA works that are data-free during the quantization process. DFQ \cite{1} does not require re-training, nor does it require calibration data to determine quantitative parameters. It uses the mathematical properties of the activation function ReLU to balance the data range of each channel of the adjacent two layers of weights to compensate for the quantization errors. However,
although PTQ is easier to use, when deployed on moving edge models with dynamically changing data quality, the isolation of data information at training time and at quantization time may lead to an obvious degradation of the generalization of quantized models.
\section{Optimization Theory}
\subsection{Quantization Preliminaries}
Given a dataset with $N$ labeled samples as $X = \left \{ x_i \right \}_{i=1}^{N}$, $Y = \left \{ y_i \right \}_{i=1}^{N} $.
For a CNN with $L$ convolution layers, we define $\Theta$ as the learnable parameters set, and $\omega_l\in \Theta$ as the vanilla full precision weight parameters of layer $l$.
A typical quantization-aware training CNN structure can be described as an intertwined pipeline including quantization $\rightarrow$ convolution $\rightarrow$ dequantization.
\begin{figure*}[htp]
\centering
\includegraphics[width = 0.97\textwidth]{quantization.png}
\caption{The quantization of convolution architecture. }
\label{quantization}
\end{figure*}
As shown in Fig.~\ref{quantization}, the left tangle shows the process of the quantization of the convolutional input, wherein the $\omega_l$ and the $x_l$ are the full precision model weight and activations respectively. $s$ is the minimum scale that can be represented after fixed-point quantization, and $z$ represents the quantized fixed-point value corresponding to the full-precision 0 floating-point value (For brevity, the following Eq. (\ref{1}), Eq. (\ref{1}), and Eq. (\ref{3}) only show the computing of $\omega$, and the activation calculation is the same):
\begin{equation}
\begin{aligned}
s=\frac{\omega^l_{max} - \omega^l_{min}}{\bar{\omega}^l_{max}-\bar{\omega}^l_{min}},~~~z=\bar{\omega}^l_{max}- \frac{\omega^l_{max}}{s}.
\end{aligned}
\label{1}
\end{equation}
The quantization formula from floating point to fixed point is as follows:
\begin{equation}
\begin{aligned}
\bar{\omega}_l = \frac{\omega_l}{s}+z.
\end{aligned}
\label{2}
\end{equation}
Note that the weight quantization is completed before inference, and the activation quantization needs to be performed during inference. After $Q$ (the quantization operation), the $\bar{\omega}_l$ and $\bar{x}_l$ represent the quantized values for actual convolution calculation. \par
The right tangle represents the dequantization operation, and $\hat{\omega}_l$ and $\hat{x}_l$ represent the dequantized weight and activations respectively.
The dequantization formula from fixed point to floating point is as follows:
\begin{equation}
\begin{aligned}
\hat{\omega}_l=(\bar{\omega}_l-z)*s.
\end{aligned}
\label{3}
\end{equation}
Previous works only aim to train model parameters with statically predetermined bit-width settings, for what most of them perform indefinite pseudo-quantization attempts depending on the quantization ability of the next operator.
Differently, DQMQ can not only to train model parameters to shorter bit-widths for the current data domain, but also learn to sense the changes in data quality and dynamically make optimal bit-width decisions to cope with uncontrollable test distribution shifts in the real world ( such as additive blur, transmission noise or compression aberration).
Thus, in our work, the $DQ$ (dequantization) is inserted after each convolution layer for the data aware mixed precision pseudo quantization.
not only produces full precision inputs for the subsequent layer, but also need to return the convolution layer to an unquantized state in preparation for bit-width sampling in the next iteration (preventing the accumulation of quantization errors).
1) Symbols for PDA: For any layer $l$, PDA inserted before $l$, named $Agent_{l}$, is the RL agent for precision-decision making. Define $h_l$ as the hessian trace of layer $l$ indicating the sensitivity of layer $l$ and $x_l$ as the originally unbiased full precision input features for layer $l$. Thus, for layer $l$, input $x_l$ and $h_l$, PDA is trained to give the optimal quantization precision $a_l$. \\
2) Symbols for QAC: The quantizer and dequantizer in QAC are defined as $Q$ and $DQ$, respectively.
Thus, we can use parameters with bars for the ones quantized by $Q$,
and parameters with hats for full-precision ones dequantized by $DQ$. For brevity, we still use $x_l$ and $\omega_l$ to represent the input features and weights of $l_{th}$ layer in the context).
\par
\subsection{Minimum Description Bit-width Sampling}
Model quantization follows the principle of minimum description length in information theory, which is defined as conveying the sum of complexity and misfit of models in the least number of bits. Thus, we define the skeleton of the optimization target for DQMQ as the hybrid minimization of both model errors and memory complexity.
More specifically, the model errors is targeted as supervised learning and the model size reduction can be defined as the reward in policy optimization problem. High model bit-widths obtains better task performance with low memory reward, while ultra low bit-width lead to
significant accuracy degradation with more memory benefit.
As a mixed precision method, DQMQ samples the optimal precision for each convolution layer in the confrontation between task accuracy and memory gain. Bit-width sampling is defined as an inherently discrete and therefore non-differentiable decision process based on several possible bit-widths like Int2, Int4, Int8, etc. It is encoded as a probability distribution function mapping feature input and layer quantization sensitivity to the layer-wise quantization bit-width.
Note that the bit-width sampling should be done before the parameters quantization and the convolution forward propagation. Thus, in our work, the $Q$ (quantization) is inserted before each convolution layer to make data-aware bit-width decisions.
We will provide the details of the optimization formulation of DQMQ in the next subsection.
\subsection{Optimization Objective}
Define $\textbf{a}=\{a_1, a_2, ... , a_L\}$ as the set of quantization precision decisions and $\textbf{h}=\{h_1, h_2, ... , h_L\}$ as the set of relative quantization sensitivities for all layers. According to the above discussions, the optimization target of DQMQ can be defined as:
\begin{equation}
\begin{aligned}
\min J(\Theta) &= \min E_{\textbf{a}|X, \textbf{h}} L_{\Theta}(X,\textbf{a},\textbf{h})\\
&= \min E_{\textbf{a}|X, \textbf{h}}
\left[\mathcal{L}(\hat{Y}(\bar{X}, \bar{\Theta}, \textbf{a}), Y) - \alpha\sum_{l=1}^{L}R_l\right] \\
&= \min P(\textbf{a}|X,\textbf{h}) \left(\mathcal{L}_{\Theta} - \alpha\sum_{l=1}^{L}R_l\right),
\label{4}
\end{aligned}
\end{equation}
where $\mathcal{L}_{\Theta}=\mathcal{L}(\hat{Y}(\bar{X}, \bar{\Theta}, a), Y)$, $\Theta$ is the learnable parameters set and $\mathcal{L}$ is the loss function. $\hat{Y}(\bar{X}, \bar{\Theta})$ means that model outputs are actually dequantized values of the convolution results on quantized weights and activations.
$R_{l}$ is defined as the benefit brought by $a_l$-bits quantization of layer $l$, which is defined as model size reduction in our work. Finally, $\alpha$ is the weighting factor that allows us to trade-off the opposite optimization target of minimizing empirical risk loss and maximizing quantization reward. \par
The learnable key elements (policy $\pi$ and future cumulative reward $r_l$) for $Agent_l$ are defined as follows:
\begin{equation}
\begin{aligned}
\mathrm{Bitwidth~Policy}:\\
&\pi(x_l, h_l) = P_{\Theta}(a_l|x_l, h_l),\\
\mathrm{Future~Reward}:\\
&r_l = \alpha \sum_{i=l}^{L}R_i - \mathcal{L}_{\Theta}.
\label{5}
\end{aligned}
\end{equation}
To jointly optimize Eq. (\ref{4}) and Eq. (\ref{5}) by gradient descent, the gradients of Eq. (\ref{4}) can be derived as:
\begin{equation}
\begin{aligned}
&\frac{\partial J(\Theta)}{\partial \Theta} = \bigtriangledown_\Theta P_\Theta(\textbf{a}|X, \textbf{h}) L_{\Theta}(X,\textbf{a}, \textbf{h}) \\
&= P_\Theta(\textbf{a}|X, \textbf{h}) \bigtriangledown_\Theta \mathcal{L}
+ L_{\Theta}(X,\textbf{a}, \textbf{h}) \bigtriangledown_\Theta \prod_{l=1}^{L} P_{\Theta}(a_l|x_l, h_l) \\
&=E_{\textbf{a}|X, \textbf{h}}\left\{\bigtriangledown_\Theta \mathcal{L}_\Theta + {\bigtriangledown_\Theta \log P_\Theta(\textbf{a}|X, \textbf{h}) L_{\Theta}(X, \textbf{a}, \textbf{h})}\right\}.
\label{6}
\end{aligned}
\end{equation}
\section{Methodology}\label{sec3}
In this section, we describe the proposed DQMQ in details from three main aspects including an architecture overview, the components' details and the deployment workflows in the real-world.
Specifically, DQMQ is a one-shot quantization system which includes two intertwined pipelines: bit-widths decision-making and model parameters updating. DQMQ is modeled as a hybrid reinforcement learning task via two plug-ins: Precision Decision Agent (PDA) and Quantization Auxiliary Computer (QAC). Being small and general, they can be inserted into most of the popular CNNs. We introduce the overview of the architecture of DQMQ in subsection. \ref{section:4.1} . Then, we detail the details of both plug-ins to explain why DQMQ has to be carefully designed like this in subsection. \ref{section:4.2} and subsection. \ref{section:4.3}. Finally, we show the deployment workflow in practice in subsection. \ref{section:4.4}.
\subsection{DQMQ: An Overview}{\label{section:4.1}}
To jointly learn dynamical data quality-aware bit-widths and model quantization parameters in one-shot training, it is necessary to make the inherently discrete and therefore non-differentiable decision process learnable.
Moreover, during the training stage of DQMQ, the bit-width decisions across iterations are different due to the dynamically changing input quality. Suppose that the bit-width decision module in this round gives the answer of Int4, and in the next round, the unconverged bit-width decision module gives another decision of Int8 bits. If layer-wise dequantization is not performed in each round as in previous mixed-precision SOTAs, the training error of model parameters brought by each quantization attempt will gradually accumulate and seriously affect the training accuracy. Therefore, DQMQ should take into account how to isolate different quantization attempts on dynamically changing data so that the training in each round would not affect each other.\par
First, in order to cope with the dynamically changing data quality and make the corresponding optimal quantization bit-width decision, we first carefully encode PDA to simulate the discrete probability distribution over the bit-widths candidates. We solve the non-differentiable training of PDA by regarding it as an agent in RL paradigm, and learn the policy of making optimal bit-width decisions in a policy optimization framework.
After being trained, PDA generates the most likely bit-width action for each layer according to the current input features and layer quantization sensitivities. The details about PDA will be discussed in Sect.~\textit{PDA: Bit-width Decision-making}.
Afterward, the quantizer and the dequantizer of QAC will work together to make fake quantization attempts to compute the current quantization reward. Receiving the most ideal bit-widths from PDA, the quantizer in QAC outputs the quantized model weights and activations with ideal bit-width, which would be the actual convolutional operators to generate feature maps for the next layer.
The dequantization operation just follows the convolution operation. It not only makes sure that the next layer receives the correct full-precision activations to eliminate the quantization error accumulation layer by layer in one forward pass, but also stores the full-precision weights of the network to avoid the accumulation of quantization parameters updating biases due to different bit-widths actions from two nearby iterations. The algorithm details and proof of QAC will be shown in Sect.~\textit{QAC: One-shot Training}.
\begin{figure*}[t]
\centering
\includegraphics[width=0.92\textwidth]{architecture.png}
\caption{Overall architecture design of DQMQ.}
\label{fig2}
\end{figure*}
More specifically, Fig.~\ref{fig2} shows how to integrate the proposed plug-ins with the existing training pipeline.
For a specific layer (e.g., $l$), the orange rectangle $Agent_{l}$ corresponds the above-mentioned PDA module. Encoded by a tiny four-layers CNN, PDA maps the input $x_{l}$ and sensitivity indicator $h_l$ to a bit-width decision $a_l$, of which $a_l$ is actually a candidate in the action pool of layer $l$ determined by $h_l$.
More specifically, for quantization-sensitive layers with large $h_l$ values, the drop in model accuracy due to quantization disturbance is even greater. Therefore, the bit-width values in the candidate pools of these layers tend to be relatively large, trading a smaller loss of memory gain for a smaller loss of model accuracy. Conversely, for quantization-insensitive layers with small values of h, quantization with lower bits does not bring about a significant change in model accuracy, which means that these layers can be quantized with ultra-low bits. Quantization-insensitive layers will be the main source of DQMQ's quantized memory gains.
The yellow cube in Fig.~\ref{fig2} represents the convolutional layer with the added QAC module. The two grey circles represent the quantizer and the dequantizer, which together make up the QAC. The lower yellow box in Fig.~\ref{fig2} shows the workflow of QAC.
Specifically, the quantizer $Q_l$ in QAC of layer $l$ quantizes the full-precision weights $\omega_{l}$ and activations $x_{l}$ of this layer to $\bar{\omega_{l}}$ and $\bar{x_{l}}$ with $a_l$-bits. As shown by the training rectangle in Fig.~\ref{fig2}, convolution operation is conducted on the quantized operators $\bar{\omega_{l}}$ and $\bar{\omega_{l}}$ to simulate the effect of $a_l$-bits quantization on final model performance. After that, the dequantizer $DQ_{l}$ inserted behind $l$ converts the quantized weight $\bar{\omega_{l}}$ and convolution results back to full-precision weights $\hat{\omega_l}$ and activations $\hat{x_{l+1}}$.
\subsection{PDA: Bit-width Decision-making}{\label{section:4.2}}
During quantization, the most likely bit-widths are taken from the probability distributions encoded by PDA. It is a four-layer CNN that maps the feature input to a four-class decision.
To handle this discrete and therefore non-differentiable decision process, we reference the training method used in SkipNet~\cite{skip}. Regarding the bit-width decision-making module as the \emph{$agent$}, the backbone neural network as \emph{environment} giving feedback, the layer-wise bit-width decision as the \emph{action}, the memory reduction $\sum_{l=1}^N{R_l}$ in Eq. (\ref{1}) as \emph{rewards}. We define the cumulative future reward in Eq. (\ref{3}) and learn the policy defined in Eq. (\ref{2}). \par
To learn this RL based bit-width policy synchronously with the normal supervised learning, we use a hybrid learning algorithm ~\cite{skip} which combines empirical risk minimization and cumulative reward maximization.
Specifically, in the first soft training stage, the output of the PDA is relaxed to continuous probability outputs over different quantization bit-width decisions to train fake-quantized model end-to-end by gradient descent to reduce task loss. Then, to reduce the approximation errors of the optimal quantization setting caused by relaxation, we perform hard training in the second stage to further optimize PDA by RL with respect to model quantization benefit maximization on discrete bit-width decision actions. In more detail, the bit-width decision-making module PDA is modeled as a \textbf{$agent$} in DQMQ, with the backbone neural network as \textbf{environment} giving feedback, the layer-wise bit-width decision as \textbf{action}, the memory reduction $\sum_{l=1}^{L}{R_l}$ in Eq. (\ref{4}) as \textbf{rewards}, and also the \textbf{cumulative future reward} and \textbf{policy} in Eq. (\ref{5}).\par
To address the huge RL search space of previous RL quantization works, we assign different action pools to different layers based on the hessian trace information, which has been proved as an effective quantization sensitivity indicator~\cite{HAWQ-v2}. Specifically, there may be only ultra-low bit-width candidates like Int2 or Int4 in the action pools of layers with lower quantization sensitivity. For more sensitive layers, their bit-width candidates are relatively higher like Int8 or Int16. In our work, there are three kinds of action pools $[0,1,2]$, $[2,4,8]$ and $[8,16,32]$.\par
\subsection{QAC: One-shot Training}{\label{section:4.3}}
Most state-of-the-art approaches for mixed-precision quantization start from a decoupled bit-widths search stage. They find the optimal quantization bit-width setting before actual quantization training instead of dynamically learning it. However, invariant data prior during quantization training makes the learned quantized model only a local optimum within this data quality region and loses generalization ability on data of different quality.
This is not consistent with variational data qualities in real-world and may cause serious problems when the lightweight quantized models are practically deployed in edge applications.
To solve the data isolation problem, we incorporate the previously decoupled bit-width setting search and model parameters training into one-shot training. This creates challenges as follows. \textbf{Between layers:} Different layers have a high probability of being quantized to different bit-widths. As the inputs of the next layer, the quantized activations of the current layer would affect the joint convolution and quantization of the next layer. \textbf{Between iterations:} The optimal bit-widths settings in each forward propagation would be different due to the undetermined precision decision policy. This brings different optimization precision in each iteration, and further results in the accumulation of optimization biases, which may lead to training crushing.\par
To facilitate one-shot training, we creatively propose a method named QAC that could optimize the backbone network with different bit-widths without biases accumulation. QAC is composed by the quantizer $Q$ and a the dequantizer $DQ$. The detailed plug-ins design and the optimization process and are shown in Algorithm.\ref{alg1:Framwork} and \ref{alg2:Framwork}.
\begin{algorithm}[tb]
\caption{ The forward process of training stage of DQMQ. }
\label{alg1:Framwork}
\begin{algorithmic}[1]
\REQUIRE ~~\\
The hessian trace of the $l_{th}$ layer: $h_l$ ;\\
The number of layers to be quantized: $L$;\\
The weights and inputs of the $l_{th}$ layer: $\omega_l$, $x_l$;\\
Parameters with bars are quantized rounded integer values by $Q$; \\
Parameters with hats are dequantized full precision values by $DQ$;\\
The PDA, quantizer and dequantizer of QAC: $Agent_{l}$, $Q_{l}(·)$ and $DQ_{l}(·)$;\\
The policy, reward and action of RL: $\pi_l$, $r_l$, and $a_l$;\\
The classifier layer: $fc$;\\
Loss function: $f(·)$;
\ENSURE ~~\\
The trained DQMQ;
\FOR{$l=1$ to $L$}
\STATE $a_l = \pi_l(h_l, x_l)$ ;
\STATE $\bar{x}_l = Q_l(x_l,a_l)$, $\bar{\omega}_{l} = Q_l(\omega_l,a_l)$;
\STATE $\bar{x}_{l+1} = \bar{x}_l \otimes \bar{\omega}_{l}$;
\STATE $\hat{x}_{l+1} = DQ_{l}(\bar{x}_{l+1}), \hat{\omega}_l = DQ_{l}(\bar{\omega}_{l})$;
\ENDFOR
\STATE $\hat{y}_{pre} = DQ_{L}(fc(\hat{x}_L))$;
\STATE Compute the optimization target defined in Eq. (\ref{1})
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[htb]
\caption{The backward process of DQMQ training.}
\label{alg2:Framwork}
\begin{algorithmic}[1]
\REQUIRE ~~\\
$net(x,\omega)$ represents the backbone of DQMQ with input $x$ and convolution weight $\omega$;\\
$\otimes$ represents the convolution operation;\\
$Q(x) = Round(\frac{x}{s_1}+z)$, $Q(w) = Round(\frac{\omega}{s_2}+z)$;\\
$DQ(x) = (x-z)*s_1$, $DQ(w) = (\omega-z)*s_2$, \\
$DQ(y) = y*s_1*s_2$;\\
where $s_1=\frac{2^\textbf{a}-1}{\max_x-\min_x}$,
$s_2=\frac{2^\textbf{a}-1}{\max_{\omega}-\min_{\omega}}$, and $z=0$ in our work;\\
\ENSURE ~~\\
The trained DQMQ;
\STATE Algorithm 1: $\hat{y}_{pre}(fc(\hat{x}_L))$ ;
\STATE $\hat{y}_{pre} = DQ(fc(\hat{x}_L))
= fc(net(\hat{x}\otimes\hat{\omega})*s_1*s_2
= fc(net(\frac{x}{s_1}),\frac{\omega}{s_2}))*s_1*s_2
= \frac{1}{s_11}\frac{1}{s_2}fc(net(x,\omega))*s_1*s_2
= fc(net(x,\omega))$;
\STATE $\Delta \omega=\frac{\delta T}{\delta y}*\frac{\delta y}{\delta \omega}$;\\
\STATE This indicates the variables being optimized in training stage are the full-precision ones, which makes the quantization decisions between multi-iterations to be independent.\\
\end{algorithmic}
\end{algorithm}
\subsection{Practical Deployment}{\label{section:4.4}}
\begin{figure*}[t]
\centering
\includegraphics[width=0.90\textwidth]{deploy.png}
\caption{Coping mechanisms for partially deployed and skeleton-deployed DQMQs when encountering data quality excursions exceeding a threshold.}
\label{fig4}
\end{figure*}
Despite the limited resources, such as storage, computing units, power, network, etc., the booming embedded devices at the edge provide a vast platform for the deployment of intelligent applications around humans. Model quantization aims to compress deep models into lightweight intelligent applications, reducing the memory and computational complexity of intelligent applications so that they can be deployed on resource-constrained embedded devices.
But are these lightweight predictive architectures robust enough for real-world inference? Discarding part of the network structure has led to a more or less decrease in the accuracy of these lightweight models. Another potential risk stems from the fact that lightweight intelligent models are faced with real-world inference tasks. , the source distribution of the input data is beyond control. For example, camera blur, transmission noise, image compression, viewpoint changes, etc. can cause the test distribution to shift relative to the static training data. As analyzed in the introduction, dynamically changing test data quality leads to different optimal quantization bit-width settings, despite the same model and the same data class distribution.\par
DQMQ is the first work to quantify the shift in the quality distribution of test data. We have analyzed how DQMQ trains the model at specific times to obtain the perception of dynamic quality in the above subsections.
Although DQMQ adds an additional quantization auxiliary module to the skeleton of a deep neural network, this does not increase the computational or memory overhead of the quantized model he generates during inference. On the contrary, due to data quality-aware quantization, it can maximize model redundancy according to the current data distribution to generate deep quantized models with minimal description length while maintaining task accuracy. Note that the extra quantization auxiliary module is very lightweight (a four-layer fully connected network, two multiplication and division operations and two addition and subtraction operations) compared to the bulky backbone neural network. Also, these quantization-assisted models are not necessarily deployed on actual mobile edge devices. DQMQ will dynamically decide to deploy the entire quantitative model (including PDA and QAC), partial quantitative model (including only PDA and part of QAC), or only the quantized model backbone (excluding any component). We will detail the workflow of DQMQ in practical deployment in this subsection to illustrate the wide applicability of DQMQ in the real world.\par
As shown in Fig.~\ref{fig4}, the deployment of DQMQ can be divided into three situations: \textbf{full deployment}, \textbf{partial deployment} and \textbf{skeleton deployment} according to the resource situation of edge mobile devices. Full deployment refers to deploying the entire DQMQ framework to the edge when the resources of edge mobile devices are sufficient to obtain all the capabilities of DQMQ, including quality-aware bit-width selection, model quantization, and model retraining. Partial deployment is defined as choosing only the data quality perception module (e.g. computing disparity), bit-width decision module (PDA) and quantization module (quantizer in QAC) with the backbone of the quantization model when the resources of the mobile device are not sufficient. They are deployed on edge devices together, so that edge devices can obtain data-aware bit-width selection and model requantization functions. Backbone deployment refers to deploying only the quality perception module and the quantized neural network backbone to the edge when the resources of edge mobile devices are extremely scarce. At this time, the data-aware bit-width selection is jointly completed by the edge side and the server side. When the edge side detects that the data quality has a large deviation (such as day and night, changing the environment), the edge side initiates the server to re-select the bit-width And quantify model application and report current data quality. The server will reselect the quantization bit-width according to the current data quality, and return the new quantization model parameters to the edge device.
To be specific, for data-sensitive mobile applications with relatively adequate memory, such as laptop, workstation and smart phones, etc., PDA and the quantizer of QAC mentioned before are deployed with the backbone of the neural network to make timely adjustments in the face of changing data quality, and it follows the above-mentioned workflow.
For extremely resource-constrained devices like smart watches and Google glasses, all plug-ins would be removed in actual deployment to obtain the most lightweight DQMQ. The necessary adjustments of quantization models when facing unacceptable data quality changes (i.e., image pixel error exceeds a predefined threshold.) will be done by triggering a command to request a new model from the server. The details are as follows:
\ding{182} By setting a very small data quality-aware module at the forefront of the deployed backbone, an unacceptable changing of inputs quality would be detected.
In details, the data quality-aware module is a resolution-based image-quality detector. Once the resolution deviation exceeds the threshold, for example, a change of shooting scene, the model-request command would be triggered instantly.
\ding{183} Edge devices send the request together with the quality of inputs which triggered the model-request to the edge server.
\ding{184} Receiving a specific quality, the most likely bit-width setting is made through the trained PDA and the quantization is done jointly.
\ding{185} The new lightweight quantization model is sent to the devices.
\section{Experiments}
We compare the proposed DQMQ with a range of state-of-the-art (SOTA) quantization works and evaluate them on three benchmarks: ImageNet, CIFAR-10, and SVHN. We construct the DQMQ of ResNet-18 models by sandwiching layers with quantization and dequantization modules and inserting a decision CNN on each residual block. In Sec. 4.1, we decipher the essence of layer sensitivity to quantization and study its correlation with data quality. In Sec. 4.2, we evaluate the performance of DQMQ and compare it with popular approaches, including mixed precision quantization works DQ, AutoQ, HAWQ~\cite{dq,AutoQ,hawq}, and fixed precision quantization PACT, LQNet, DNAS, US, SAT, TQT networks~\cite{pact,lqnet,dnas,us,sat,tqt}. We also compare our approach with a full precision network to demonstrate the effectiveness of the data quality-aware decision policy.
\subsection{Benchmark}
\label{section:4.1}
\subsubsection{Dataset}
Extensive experiments are conducted on three popular datasets for model quantization including ImageNet, CIFAR-10, and SVHN. The diversity of data patterns more effectively reflects the generality of our proposed method.
For ImageNet, it has greater scale and diversity, thus providing more reliable evaluations of the proposed vision methods. Specifically, ImageNet is currently the largest database for image recognition in the world. Over 14 million images were manually annotated by ImageNet to indicate objects in the picture. In at least one million images, bounding boxes are also provided. ImageNet contains more than 20,000 categories. In this work, we use the lightweight ISLVRC2012 dataset with 1000 categories. Each class contains hundreds of images. Among them, the training subset contains more than 1.2 million natural images, and the validation subset contains 50,000 images. We process the image size as 224 $\times$ 224.
CIFAR-10 is a color image dataset that approximates ubiquitous objects. It contains a total of 10 categories of RGB color pictures and the size of each image is 32 × 32 There are 6000 images in each category, and there are a total of 50000 training images and 10000 testing images in the dataset. Note that we have enhanced the image quality of CIFAR-10. Specifically, to simulate the dynamically changing data quality on mobile devices, we first processed CIFAR-10 with a low-pass filter with Gaussian blur radius of 1, 3, and 5 to represent varying degrees of low-quality input.
After that, we perform image sharpening by enhancing the edge position based on second-order differential to represent high-quality input that is easier to identify. Fig. \ref{fig5} provides an intuitive illustration of the above processing results.
We use `level 1' to `level 5' to name the five different picture qualities, the bigger the number, the blurrier the image. `level 1' denotes the sharpening image and `level 2' denotes the raw data. We select 10000 images from each of the above five scales respectively and ensure each selection is done with uniform data label distribution. These images with 5 different qualities are mixed together to form a new dataset named `CIFAR-10 (Mixed)'.
The Street View House Numbers (SVHN) dataset is a collection of house numbers taken from Google Street View imagery and contains more than 600,000 labeled data of digit images for identifying alphanumeric characters in natural scene images. The dataset contains ten categories, of which the training set contains 73,257 images and the test set contains 26,032 images. Each image size is 32 $\times$ 32. Note that SVHN undergoes the same mixed-quality treatment as CIFAR-10.
\begin{figure}[t]
\centering
\subfloat[Original image.]{
\includegraphics[width=0.4\linewidth]{rawfig.png}}
\subfloat[Edge-sharpened image.]{
\includegraphics[width=0.4\linewidth]{rh.png}}\\
\subfloat[Image after Gaussian blur with radius 1.]{
\includegraphics[width=0.4\columnwidth]{gau1.png}}
\subfloat[Image after Gaussian blur with radius 2.]{
\includegraphics[width=0.4\linewidth]{gau2.png}}
\caption{CIFAR-10 images of different qualities.}
\label{fig5}
\end{figure}
\subsubsection{Models}
Based on multiple datasets with diverse image patterns and uneven data qualities, we explore the effectiveness of the proposed DQMQ on ResNet-18 for it is the most commonly used network by state-of-the-art quantization works.
To be specific, ResNet-18 has 4 residual blocks and 2 convolution layers in each block.
Note that the skeleton neural network is improved based on the design concept of DQMQ. To be specific, each convolutional layer is sandwiched by a data-aware module PDA and a quantization auxiliary module QAC.
The detailed implementation is as follows. Before each convolution layer, a tiny four-layer CNN (PDA) that maps the feature input to four-class bit-widths is first inserted. Following PDA, it is a quantizer containing two division and addition operators, and finally, the dequantizer in QAC closely follows behind each convolution operator.\par
\subsubsection{Training Details}
The proposed DQMQ is trained on 1 Nvidia GTX 3090TI GPU. For ImageNet dataset, the framework is trained with 120 epochs. For CIFAR-10 and SVHN, DQMQ is converged in 60 epochs. The batch size is 512 in each training and testing process, and the learning rate starts from 0.1 and is uniformly reduced to 0.001. The hyperparameter $\alpha$, which adjusts the training weight between supervised learning optimization and policy optimization, is empirically set as 0.5 in this work. \par
\begin{table}[tbp]
\renewcommand\arraystretch{1.5}
\centering
\caption{Comparison of Top-1 accuracy of DQMQ with popular Fixed-Precision Quantization methods. Results are of ResNet-18 on ImageNet. `FP' means full-precision training, and $\delta_{acc}$ means the accuracy difference between quantization model and full-precision model. `W-Comp' is the weight compression rate.
}
\scalebox{1}[0.9]{
\begin{tabular}{lccccc}
\bottomrule \hline
& \multicolumn{4}{c}{\textbf{Fixed-Precision Quantization}} & \\\hline
\textbf{Method} & \multicolumn{2}{|c}{3-bit} & \multicolumn{2}{c|}{4-bit} & \textbf{W-Comp}\\ \hline
& \multicolumn{1}{|c}{Acc($\%$)} & $\delta_{acc}$ & Acc($\%$) & \multicolumn{1}{c|}{{$\delta_{acc}$} } & \\ \hline
\multicolumn{1}{c|}{PACT} & 68.30 & -1.90 & 69.20 & \multicolumn{1}{c|}{-1.00} & \\
\multicolumn{1}{c|}{LQNet} & 68.20 & -2.10 & 69.30 & \multicolumn{1}{c|}{-1.00} & \\
\multicolumn{1}{c|}{DNAS} & 68.70 & -2.30 & 70.60 & \multicolumn{1}{c|}{-0.40} & 4.00X/2.00X \\
\multicolumn{1}{c|}{US} & 69.40 & -1.50 & 70.50 & \multicolumn{1}{c|}{-0.40} & \\
\multicolumn{1}{c|}{SAT} & 69.30 &-1.90 & 70.30 & \multicolumn{1}{c|}{0.10} & \\
\multicolumn{1}{c|}{TQT} & * & * & 69.51 & \multicolumn{1}{c|}{-0.77 } & \\ \hline
\multicolumn{1}{c|}{\textbf{DQMQ (ours)}} &\multicolumn{4}{c|}{\underline{\textbf{71.47}}} & \underline{\textbf{5.69X}} \\ \hline
\multicolumn{1}{c|}{FP($\%$)} &\multicolumn{4}{c|}{70.28} & 1.00X \\ \hline
\multicolumn{1}{c|}{Size(MB)} & \multicolumn{2}{c}{13.28 v.s. {\underline{\textbf{7.83}}}} &\multicolumn{2}{c|}{24.42 v.s. {\underline{\textbf{7.83}}}} &
\\\bottomrule \hline
\end{tabular}
}
\label{table1}
\end{table}
\begin{table}[tbp]
\renewcommand\arraystretch{1.5}
\centering
\caption{Comparison of Top-1 accuracy of DQMQ with other popular Mixed-Precision Quantization methods. Results are of ResNet-18 on ImageNet. Data with a `*' refers to certain constrained conditions (Details can be found in the references).}
\scalebox{1}[0.9]{
\begin{tabular}{ccccc}
\bottomrule \hline
& \multicolumn{3}{c}{\textbf{Mixed-Precision Quantization}} & \\\hline
\multicolumn{1}{c}{\textbf{Method}} & Acc($\%$) & $\delta_{acc}$ &Size(MB) &W-Comp \\ \hline
DQ & 70.08 & -0.20 &$7.54^*$ & 5.90X \\
AutoQ & $68.20^*$ &$-0.70^*$ &$5.19^*$ & 8.58X \\
HAWQ & 70.22 & -1.25 &$8.24^*$ &5.40X \\
\textbf{DQMQ (ours)} & \underline{\textbf{71.47}} & \underline{\textbf{1.19}} &\underline{\textbf{7.83}} &\underline{\textbf{5.69X}} \\
\multicolumn{1}{c}{FP($\%$)} & 70.28 & 0.00 &$8.24^*$ &1.00X \\
\bottomrule
\end{tabular}
}
\label{table2}
\end{table}
\begin{table}[]
\renewcommand\arraystretch{1.5}
\centering
\caption{Quantization results on CIFAR-10 (Mixed) and SVHN. `W/A' are the weights' and activations' bit-widths respectively. `MP' refers to mixed-precision quantization.}
\scalebox{1}[0.9]{
\begin{tabular}{cccc}
\bottomrule
\textbf{Dataset} & \textbf{Bits(W/A)} & \textbf{Method} & \textbf{Acc (Top-1)($\%$)} \\ \bottomrule
& 32/32 & FP & 76.56 \\
CIFAR-10 & MP & HAWQ & 81.9 \\
& MP & \textbf{DQMQ (ours)} & \underline{\textbf{82.03}} \\ \hline
& 32/32 & FP & 76.56 \\
CIFAR-10 & MP & HAWQ & 69.76 \\
(Mixed) & MP & \textbf{DQMQ (ours)} & \underline{\textbf{81.43}} \\ \hline
& 32/32 & FP & * \\
SVHN & MP & HAWQ & 74.32\\ (Mixed)
& MP &\textbf{DQMQ (ours)} & \underline{\textbf{79.02}} \\ \hline
& 32/32 & FP & * \\
SVHN & MP & HAWQ & 78.13 \\
& MP &\textbf{DQMQ (ours)} & \underline{\textbf{78.91}} \\ \bottomrule
\end{tabular}}
\label{table3}
\end{table}
\subsection{Performance Comparison with SOTA}
In this section, we compare the task performance of our data-aware mixed-precision quantization method with various SOTA methods including both fixed-precision and mixed-precision. More specifically, for fixed-precision quantization, we compare DQMQ with various works including PACT, LQNet, DNAS, US, SAT, TQT networks~\cite{pact,lqnet,dnas,us,sat,tqt}. For mixed-precision quantization works, DQMQ is compared with some of the most representative works including DQ, AutoQ, HAWQ~\cite{dq,AutoQ,hawq}.
All methods in this section are evaluated on the ImageNet dataset and ResNet-18 architecture, and we use task accuracy and model size reduction as the evaluation measurements for performance comparisons.
Table.\ref{table1} shows the results of the comparison between DQMQ and fixed-precision quantization works. Note that in the last line named `Size', the 13.28M and 24.42M are the model sizes under fixed-precision quantization with 3-bits and 4-bits, respectively, and 7.83 is the size of the quantized model from DQMQ with mixed bit-widths.
It can be clearly seen that for fixed-precision quantization, nearly all methods suffer from the accuracy drop caused by model quantization except SAT, which has a small accuracy gain of $0.1\%$ on 4-bit quantization. Conversely, DQMQ shows greater accuracy gains with $1.19\%$ accuracy improvement.
What's more, for fixed methods, the compression rate of model size is limited by the integer bit-width division. Excluding binary and tertiary quantization that bring a large drop in accuracy, the highest model compression rate in most fixed-precision methods does not exceed 4 times.
The comparison results with mixed-precision are shown in Table.\ref{table2}.
Similar to the static quantization result, nearly all existing mixed methods show accuracy degradation after quantization except AutoQ, which has a small accuracy benefit of $0.7\%$.
Regarding model quantization as a perturbation to the original model parameters, the drop in accuracy in most previous works reveals their poor perturbation adversarial.
Conversely, the reward scheme in data quality-aware quantization helps learn the optimal quantitative policy when facing diverse samples, greatly reducing the parameters entropy and improving the quantization robustness~\cite{lottery}.
Finally, we compare the task performance of HAWQ and DQMQ based on CIFAR-10 (Mixed) and SVHN (Mixed) with ResNet-18 architecture. We test both the quantized models on various data qualities to demonstrate if the proposed DQMQ has the ability to adapt itself to different test distributions. The results are listed in Table.~\ref{table3}. In CIFAR-10 (Mixed) and SVHN (Mixed), the data quality ranges from the worst Gaussian blur to better image sharpening widely. It is obvious that our DQMQ can achieve higher test accuracy than HAWQ on all dataset. To be specific, on the original CIFAR-10 and SVHN with uniform data quality, as predicted, due to the lack of rich data quality knowledge in training stage, the performance of DQMQ and HAWQ is almost equal. However, in data domains where the data distribution changes drastically (mixed datasets), DQMQ can make better quantization decisions and reap higher accuracy and robustness than HAWQ.
\begin{figure}[ht]
\centering
\subfloat[Blurred data]{
\includegraphics[width =0.8\columnwidth]{hawq_dqmq.png}
}\\
\subfloat[Standard data]{
\includegraphics[width =0.8\columnwidth]{raw_hawq_dqmq.png}
}\\
\subfloat[Sharpened data]{
\includegraphics[width =0.8\columnwidth]{rh_hawq_dqmq.png}
}
\caption{Comparison of accuracy (Top-1)($\%$) of DQMQ and HAWQ of ResNet-18 on CIFAR-10 with different image qualities.}
\label{fig3}
\end{figure}
\subsection{Correlation Exploration Between Data Quality and Quantization Sensitivity}
In this subsection, we would prove the strong correlation between data quality with layer quantization sensitivity to emphasize the strong necessity of our research.
The underlying motivation origins from the fact that mobile devices are most likely working in edge environments with dynamically changing contexts. The uncontrollable data qualities in running time could have a large distribution deviation from that of training time and cause the vanilla quantization to suffer significant performance degradation.
In order to find a more robust model quantization in the face of changing data quality, it is important to explore the relationship between data quality and optimal quantization bit-width.
\begin{figure}[t]
\centering
\subfloat[ResNet-18: Layer sensitivity under different data qualities.]{
\includegraphics[width =0.92\columnwidth]{old2d.png}
}\\
\subfloat[ResNet-18: Enlarged view of the last eight layers.]{
\includegraphics[width =0.8\columnwidth]{0908.png}
}\\
\subfloat[ResNet-20: Layer sensitivity under different data qualities.]{
\includegraphics[width =0.92\columnwidth]{hessianinfo.png}
}
\caption{Comparison of the layer-wise quantization sensitivities of DQMQ on ResNet-18 under CIFAR-10 with five different data qualities.}
\label{hessianinfo}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width =0.92\columnwidth]{skip_dif.png}
\caption{The quantization precision decisions made by DQMQ under different data qualities and ResNet-18. The horizontal axis is the index of the convolutional network in the network, and the vertical axis is the quantization accuracy of this layer determined by DQMQ. Yellow arrows represent the maximum difference of quantization bit-widths for each layer under three different data qualities.}
\label{fig4}
\end{figure}
\begin{table}[]
\renewcommand\arraystretch{1.5}
\centering
\caption{Comparison of Top-1 accuracy between mixed-precision quantization methods HAWQ and DQMQ under three data qualities.Results are of ResNet-18 on specially processed CIFAR-10.}
\scalebox{1}[0.9]{
\begin{tabular}{cccc}
\bottomrule
\textbf{Method} & \textbf{Data Quality} & \textbf{Acc (Top-1)(\%)} \\ \bottomrule
& blurring & 67.19 \\
HAWQ & standard & 81.90 \\
& sharpening & 80.31 \\ \hline
& blurring & \underline{\textbf{76.50}} \\
\textbf{DQMQ (ours)} & standard & \underline{\textbf{82.03}} \\
& sharpening & \underline{\textbf{82.34}} \\ \bottomrule
\end{tabular}}
\label{table4}
\end{table}
Thus, extensive experiments are conduct on datasets with mixed data qualities and the results are shown in Fig.~\ref{hessianinfo} and Fig.~\ref{fig4}.
As shown in Fig.~\ref{hessianinfo}, since the trace of the Hessian matrix is positively correlated with the relative quantization sensitivities between layers~\cite{HAWQ-v2}, we compare layers' hessian trace under five data qualities to observe the changes in the optimal quantization precision for each layer on both ResNet-18 and ResNet-20.
In ResNet-18, as data quality gets worse, sensitivities of deeper layers begin to increase, while the layer-wise sensitivity differences show a downward trend.
In ResNet-20, the results show that with increasing image noise, the degree of the turbulence of hessian curve gradually increases, which confirms the fact that as data quality changing, layer-wise relative quantization sensitivity should fluctuate dynamically rather than remain static as existing methods. Data quality would be a unavoidable factor in quantization settings searching.
What's more, as shown in Fig.~\ref{fig4}, the yellow arrows represent the maximum quantization bit-width difference for each layer under three data qualities. It is clearly that the layers in the middle and closer to the classifier are more sensitive to the changing of data quality. These layers make totally different quantization bit-width decisions when data quality changes.
At this point, we can claim that: \textit{under ambiguous test distributions about data quality, DQMQ could dynamically make the model quantization adapt to the data variation and thus lead to better robustness at diverse data qualities}.
To be more precise, we also compare the accuracy of the proposed DQMQ with HAWQ under three different data qualities. Both methods are conducted on ResNet-18 and CIFAR-10 (Mixed). Results are shown in Table.~\ref{table4}. For HAWQ, when data quality increases from standard quality(unprocessed CIFAR-10) to better quality(Sharpening CIFAR-10),
contrary to expectations, there is a slight drop in model accuracy even with better data quality.
The disordered relationship between the accuracy and input data qualities of HAWQ
illustrates that for the same bit-width, the performance of the quantized model is not simply proportional to the data quality. In the relationship chain of "data quality $\rightarrow$ quantization settings $\rightarrow$ quantization performance", the first and last items are not directly related and lost the expected consistency.
HAWQ takes only model information into consideration when make quantization decisions and ignores changes in data. Different from that, DQMQ uses both model and data information to dynamically make the quantization bit-width decision. DQMQ not only shows a higher prediction accuracy than SOTA under the same quality, but also keeps showing an accuracy ascension as data quality gets better. DQMQ restores the positive relationship between model performance and data quality in quantitative scenarios, which also demonstrates its data quality-adaptive ability from one-shot quantization training.
\section{Conclusion}
In this paper, we proposed a novel data-quality aware model quantization method (DQMQ) to achieve more robust compressed models in the edge environment.
Our method is the first attempt that focuses on the perspective of data rather than the model architecture or algorithm, to improve both the generalization and robustness of quantized models.
Our method can dynamically adapt the quantization precision to different data qualities with layer-wise multiple bit-widths synchronously with task performance. Moreover, we also incorporate the decoupled bit-width decision-making and quantization training into a much more efficient and coherent one-shot training scheme.
Extensive experiments verified the effectiveness of the proposed method.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
\section{Introduction}\label{sec:introduction}
\IEEEPARstart{M}{o}del quantization has attracted increasing attention recently as an effective solution that improves the computation and memory efficiency for deep neural networks (DNN), thus enabling the deployment of deep models on resource-constrained edge devices~\cite{wang2022survey,post,HAWQ-v2,deep,dorefa,pact,Lu2019Lip,zhang2018deepvoice}. Specifically, the lower description bit-width of DNN can bring about significant benefits in terms of inference acceleration and model compression rate, for example, Int8/Int4 quantization and binary neural networks~\cite{irnet}. However, it inevitably causes a greater accuracy drop than higher description bit-width models due to unavoidably more information loss.
To maximally excavate the description redundancy and learn the compressed model for a given training domain, mixed-precision quantization~\cite{HAWQ-v2,hawq,HAWQ-V3,daam,FracBits,post,AutoQ} has been proposed to explore a better balance between task performance and model description length.
It allows network components, e.g., layers~\cite{haq} or kernels~\cite{AutoQ}, to be quantized with lower bit-widths instead of full precision bit-widths if they have less contribution to model accuracy, wherein, more sensitive components are quantized with relatively higher bit-widths to avoid large accuracy degradation and vice versa.
Despite the more balanced compression power, the mixed bit-widths can bring about unique challenges for the quantization setting exploration and model training. Concretely, the search space for determining a sufficiently good mixed-precision quantization setting can grow exponentially with increasing number of layers and bit-width choices.
For example, when a ResNet-152 is quantized layer-wisely with 4 possible bit-widths, the search space can easily reach $4^{152}$ times. Worse still, the inherently discrete and non-differentiable bit-width decision-making (or sampling process) makes it hard to learn the bit-width policy jointly with quantization training.
To deal with the above challenges, existing state-of-the-art (SOTA) works usually decouple the non-derivable bit-width sampling process from the end-to-end supervised training, i.e., consisting of two mutually independent precision decision-making stage and quantization training stage.
Some representative methods include state-of-the-art HAWQ series~\cite{HAWQ-v2,hawq,HAWQ-V3}, DMBQ~\cite{daam}, FracBits~\cite{FracBits}, AutoQ~\cite{AutoQ}, etc.
For example, The HAWQ series~\cite{HAWQ-v2,hawq,HAWQ-V3} measure the relative sensitivity of layers via layer-wise hessian information and develop a Pareto frontier based method to make hessian-based bit-width decisions before model quantization.
Differently, DMBQ~\cite{daam} tries to search for an optimal bit-width setting over the distribution space beforehand and quickly selects one setting via this prepared fast lookup table during training.
In general, previous
These state-of-the-arts make satisfying bit-width decisions under the guidance of hardware feedback~\cite{haq} or gradient-based information~\cite{hawq} before the actual quantization training, as well as the practical inference, while all their bit-width selection and quantization training are done in the given narrow data domain with quality-consistent training setting. \par
In real-world application, such decoupled training process can inevitably lead to the data isolation issue between three stages of precision decision-making, quantization training, and practical inference, which can result in sub-optimal performance.
Besides, the static quality-consistent training setting is not robust against data quality changes in practice, which may further deteriorate the effect of the prior bit-width decision and obtain poor robustness of the quantized models.
Notably, our observation suggests a non-negligible view that the data quality can have a significant impact on the quantization setting decision due to the changing of relative layer sensitivities to quantization in networks.
As demonstrated in Fig.~\ref{losss}, we show a demo case of the loss changing on different data qualities, where `level\_0' denotes the quantized model trained on standard CIFAR-10 dataset. The input images are getting blurrier from `level\_0' to `level\_2'.
To augment images with various qualities, we apply random quantization perturbations to the original quantization model along the direction of the Hessian matrix at the convergence point.
Assume the data quality does not alter the optimal quantization settings, the minimum task loss should occur when the perturbation is 0.
However, we get the opposite result. The loss-curve is as expected only if the quality of the test image is the same as the training image. The optimal model description bit-widths can change when the quality of the test image varies, i.e., more specifically, the greater the difference of qualities, the larger the deviation of the model parameters w.r.t the minimum loss point.
Horizontally, we can also observe that as the image noise increases, the deviation of the quantization convergence point from the original parameters becomes larger.
In summary, the above findings indicate a huge contradiction between previous quantization works and the need to infer on environment-sensitive devices with unpredictably and dynamically changing input qualities.
\begin{figure}[t]
\centering
\includegraphics[width = 0.87\columnwidth]{losss.png}
\caption{Loss changing of quantization model with different data qualities. `level' denotes the degree of Gaussian blur, i.e., the larger the value, the blurrier the image. }
\label{losss}
\end{figure}
In this paper, our interest is to explore the optimal compressed model by mixed-precision quantization from a new perspective, \textit{i.e., data rather than the model}, and to improve both the generalization and robustness of quantized models. The motivation stems from the fact that, in real-world applications, it is usually impossible to control the source distribution of data, such as camera blur, transmission noise, etc.
To deal with such issues, we propose a Data Quality-aware Mixed-precision Quantization method, dubbed DQMQ, consisting of two lightweight plug-ins to facilitate data quality-aware bit-width decision-making and one-shot quantization model training, respectively.
First, the Precision Decision Agent (PDA) plug-in can automatically generate the current optimal layer-wise quantization bit-widths setting during forward propagation.
Then, the Quantization Auxiliary Computer (QAC) plug-in is used to eliminate the accumulation of quantization biases due to the undetermined precision decision policy.
Moreover, by feeding mixed-quality samples, the discrete bit-width sampling distribution can be learned jointly with model parameters in a one-shot and continuous scheme.
Being small and light, our plug-ins also hold the following features: 1) be deployed in the training phase and can be removed flexibly during other phases; and 2) can be easily applied to most mainstream neural networks.
Our contributions are summarized as follows:
\begin{itemize}
\item We first indicate that the data quality can significantly affect the layer-wise quantization sensitivity, and upon which, we propose a novel data quality-aware mixed-precision quantization method to address such issues.
\item We incorporate the previously decoupled bit-width precision decision-making model parameter training into a one-shot scheme, which significantly improves the efficiency and resolves the data isolation. Moreover, we also provide a theoretical derivation to prove its feasibility.
\item Experiments on various datasets and mainstream networks demonstrate the effectiveness of our method. In particular, our DQMQ outperforms the SOTA HAWQ-v2 by 12.7$\%$ in MAP and 7.30$\times$ in model compression rate, respectively.
\end{itemize}
\section{Related Works}
\subsection{Mixed-Precision Quantization}
An intractable issue in conventional fixed-precision model quantization is that high bit-width quantization can ensure high precision, while the memory footprint and calculation cost are also sufficient large. On the contrary, the memory usage and calculation cost can be smaller with lower quantization precision, while this unavoidably leads to significant quantization accuracy degradation. This essential dilemma makes quantization under fixed bit-width can hardly achieve a fine-grained trade-off between accuracy and FLOPs.
To fully exploit the model redundancy and obtain more balanced compression power, mixed-precision is proposed.
It achieves further efficient compression of the model and brings better quantization benefits due to precision flexibility~\cite{DBLP:journals/corr/abs-1812-00090, post}. For example, DMBQ~\cite{daam} searches the optimal quantization scheme over the distribution space beforehand and selects the quantization scheme during training using a fast lookup table-based strategy. Wang \textit{et al.}~\cite{haq} estimate layer-wise resource cost by simulators, and combine the hardware indicators to constrain the bit-widths search for each layer. Later, offline bit-widths decision-making based on the layer-wise Hessian Spectrum is enabled in HAWQ serious~\citep{hawq, HAWQ-v2, HAWQ-V3}.
These studies have produced outstanding results when compared to single-precision quantization.
However, the majority of them decouple the actual quantization training and quantization bitwidth selection due to the discrete mixed bitwidth selection procedure.
In other words, even when the quality and distribution of the input data are expected to change throughout quantization training, they consistently believe the pre-selected bit width to be the best option.
And our experimental results in the previous section have proved that this is wrong.
\subsection{Quantization Aware Training}
Quantization Aware Training (QAT) fits feature inputs to quantized parameters that are as low as possible in bit-width while minimizing the loss in optimization target jointly in the training process. Specifically, a typical QAT pipeline simulates a quantization procedure by introducing fake quantization operations to model weights and activations during the forward propagation, while the gradient update is still performed on vanilla float parameters during the backpropagation as if the quantification never happened \cite{Jacob_2018_CVPR}. However, because of the inherently discrete and non-derivative quantization operations, QAT cannot calculate accurate gradients like a standard smooth neural network in backpropagation. A common practice is to use a gradient straight-through estimator (STE)~\cite{ste1}, which fits the parameters of a discontinuous function to an approximately continuous function and ignores the impact of quantization. Esser \textit{et al.}~\cite{esser} introduces a novel means to estimate and scale the task loss gradient for each weight and activation and enable it to be learned in conjunction with other network parameters. Although these methods under QAT schemes achieve excellent performance, most of them require great resource cost and significant time on re-training and hyper-parameter tuning \cite{updown}. Our work removes these redundancies through one-shot training and a lightweight quantizer.
\subsection{Post-training Quantization}
Post-training Quantization (PTA) quantizes neural networks during practical deployment after the standard model training stage. In the quantization process, it selects appropriate quantization and/or calibration operations for the pre-trained network to minimize quantization loss. Without re-training, PTA is simpler to use and allows for quantization with limited data conditions. For example, many PTA works need only a small calibration set: Fang~\textit{et al.}~\cite{fang2020post} proposed Piecewise Linear Quantization (PWLQ) to solve the great accuracy drop in uniform quantization with lower bit-width. It finds optimal segmentation breakpoints to obtain lower quantization errors and only needs a small amount of calibration data.
Furthermore, there are even some PTA works that are data-free during the quantization process. DFQ \cite{1} does not require re-training, nor does it require calibration data to determine quantitative parameters. It uses the mathematical properties of the activation function ReLU to balance the data range of each channel of the adjacent two layers of weights to compensate for the quantization errors. However,
although PTQ is easier to use, when deployed on moving edge models with dynamically changing data quality, the isolation of data information at training time and at quantization time may lead to an obvious degradation of the generalization of quantized models.
\section{Optimization Theory}
\subsection{Quantization Preliminaries}
Given a dataset with $N$ labeled samples as $X = \left \{ x_i \right \}_{i=1}^{N}$, $Y = \left \{ y_i \right \}_{i=1}^{N} $.
For a CNN with $L$ convolution layers, we define $\Theta$ as the learnable parameters set, and $\omega_l\in \Theta$ as the vanilla full precision weight parameters of layer $l$.
A typical quantization-aware training CNN structure can be described as an intertwined pipeline including quantization $\rightarrow$ convolution $\rightarrow$ dequantization.
\begin{figure*}[htp]
\centering
\includegraphics[width = 0.97\textwidth]{quantization.png}
\caption{The quantization of convolution architecture. }
\label{quantization}
\end{figure*}
As shown in Fig.~\ref{quantization}, the left tangle shows the process of the quantization of the convolutional input, wherein the $\omega_l$ and the $x_l$ are the full precision model weight and activations respectively. $s$ is the minimum scale that can be represented after fixed-point quantization, and $z$ represents the quantized fixed-point value corresponding to the full-precision 0 floating-point value (For brevity, the following Eq. (\ref{1}), Eq. (\ref{1}), and Eq. (\ref{3}) only show the computing of $\omega$, and the activation calculation is the same):
\begin{equation}
\begin{aligned}
s=\frac{\omega^l_{max} - \omega^l_{min}}{\bar{\omega}^l_{max}-\bar{\omega}^l_{min}},~~~z=\bar{\omega}^l_{max}- \frac{\omega^l_{max}}{s}.
\end{aligned}
\label{1}
\end{equation}
The quantization formula from floating point to fixed point is as follows:
\begin{equation}
\begin{aligned}
\bar{\omega}_l = \frac{\omega_l}{s}+z.
\end{aligned}
\label{2}
\end{equation}
Note that the weight quantization is completed before inference, and the activation quantization needs to be performed during inference. After $Q$ (the quantization operation), the $\bar{\omega}_l$ and $\bar{x}_l$ represent the quantized values for actual convolution calculation. \par
The right tangle represents the dequantization operation, and $\hat{\omega}_l$ and $\hat{x}_l$ represent the dequantized weight and activations respectively.
The dequantization formula from fixed point to floating point is as follows:
\begin{equation}
\begin{aligned}
\hat{\omega}_l=(\bar{\omega}_l-z)*s.
\end{aligned}
\label{3}
\end{equation}
Previous works only aim to train model parameters with statically predetermined bit-width settings, for what most of them perform indefinite pseudo-quantization attempts depending on the quantization ability of the next operator.
Differently, DQMQ can not only to train model parameters to shorter bit-widths for the current data domain, but also learn to sense the changes in data quality and dynamically make optimal bit-width decisions to cope with uncontrollable test distribution shifts in the real world ( such as additive blur, transmission noise or compression aberration).
Thus, in our work, the $DQ$ (dequantization) is inserted after each convolution layer for the data aware mixed precision pseudo quantization.
not only produces full precision inputs for the subsequent layer, but also need to return the convolution layer to an unquantized state in preparation for bit-width sampling in the next iteration (preventing the accumulation of quantization errors).
1) Symbols for PDA: For any layer $l$, PDA inserted before $l$, named $Agent_{l}$, is the RL agent for precision-decision making. Define $h_l$ as the hessian trace of layer $l$ indicating the sensitivity of layer $l$ and $x_l$ as the originally unbiased full precision input features for layer $l$. Thus, for layer $l$, input $x_l$ and $h_l$, PDA is trained to give the optimal quantization precision $a_l$. \\
2) Symbols for QAC: The quantizer and dequantizer in QAC are defined as $Q$ and $DQ$, respectively.
Thus, we can use parameters with bars for the ones quantized by $Q$,
and parameters with hats for full-precision ones dequantized by $DQ$. For brevity, we still use $x_l$ and $\omega_l$ to represent the input features and weights of $l_{th}$ layer in the context).
\par
\subsection{Minimum Description Bit-width Sampling}
Model quantization follows the principle of minimum description length in information theory, which is defined as conveying the sum of complexity and misfit of models in the least number of bits. Thus, we define the skeleton of the optimization target for DQMQ as the hybrid minimization of both model errors and memory complexity.
More specifically, the model errors is targeted as supervised learning and the model size reduction can be defined as the reward in policy optimization problem. High model bit-widths obtains better task performance with low memory reward, while ultra low bit-width lead to
significant accuracy degradation with more memory benefit.
As a mixed precision method, DQMQ samples the optimal precision for each convolution layer in the confrontation between task accuracy and memory gain. Bit-width sampling is defined as an inherently discrete and therefore non-differentiable decision process based on several possible bit-widths like Int2, Int4, Int8, etc. It is encoded as a probability distribution function mapping feature input and layer quantization sensitivity to the layer-wise quantization bit-width.
Note that the bit-width sampling should be done before the parameters quantization and the convolution forward propagation. Thus, in our work, the $Q$ (quantization) is inserted before each convolution layer to make data-aware bit-width decisions.
We will provide the details of the optimization formulation of DQMQ in the next subsection.
\subsection{Optimization Objective}
Define $\textbf{a}=\{a_1, a_2, ... , a_L\}$ as the set of quantization precision decisions and $\textbf{h}=\{h_1, h_2, ... , h_L\}$ as the set of relative quantization sensitivities for all layers. According to the above discussions, the optimization target of DQMQ can be defined as:
\begin{equation}
\begin{aligned}
\min J(\Theta) &= \min E_{\textbf{a}|X, \textbf{h}} L_{\Theta}(X,\textbf{a},\textbf{h})\\
&= \min E_{\textbf{a}|X, \textbf{h}}
\left[\mathcal{L}(\hat{Y}(\bar{X}, \bar{\Theta}, \textbf{a}), Y) - \alpha\sum_{l=1}^{L}R_l\right] \\
&= \min P(\textbf{a}|X,\textbf{h}) \left(\mathcal{L}_{\Theta} - \alpha\sum_{l=1}^{L}R_l\right),
\label{4}
\end{aligned}
\end{equation}
where $\mathcal{L}_{\Theta}=\mathcal{L}(\hat{Y}(\bar{X}, \bar{\Theta}, a), Y)$, $\Theta$ is the learnable parameters set and $\mathcal{L}$ is the loss function. $\hat{Y}(\bar{X}, \bar{\Theta})$ means that model outputs are actually dequantized values of the convolution results on quantized weights and activations.
$R_{l}$ is defined as the benefit brought by $a_l$-bits quantization of layer $l$, which is defined as model size reduction in our work. Finally, $\alpha$ is the weighting factor that allows us to trade-off the opposite optimization target of minimizing empirical risk loss and maximizing quantization reward. \par
The learnable key elements (policy $\pi$ and future cumulative reward $r_l$) for $Agent_l$ are defined as follows:
\begin{equation}
\begin{aligned}
\mathrm{Bitwidth~Policy}:\\
&\pi(x_l, h_l) = P_{\Theta}(a_l|x_l, h_l),\\
\mathrm{Future~Reward}:\\
&r_l = \alpha \sum_{i=l}^{L}R_i - \mathcal{L}_{\Theta}.
\label{5}
\end{aligned}
\end{equation}
To jointly optimize Eq. (\ref{4}) and Eq. (\ref{5}) by gradient descent, the gradients of Eq. (\ref{4}) can be derived as:
\begin{equation}
\begin{aligned}
&\frac{\partial J(\Theta)}{\partial \Theta} = \bigtriangledown_\Theta P_\Theta(\textbf{a}|X, \textbf{h}) L_{\Theta}(X,\textbf{a}, \textbf{h}) \\
&= P_\Theta(\textbf{a}|X, \textbf{h}) \bigtriangledown_\Theta \mathcal{L}
+ L_{\Theta}(X,\textbf{a}, \textbf{h}) \bigtriangledown_\Theta \prod_{l=1}^{L} P_{\Theta}(a_l|x_l, h_l) \\
&=E_{\textbf{a}|X, \textbf{h}}\left\{\bigtriangledown_\Theta \mathcal{L}_\Theta + {\bigtriangledown_\Theta \log P_\Theta(\textbf{a}|X, \textbf{h}) L_{\Theta}(X, \textbf{a}, \textbf{h})}\right\}.
\label{6}
\end{aligned}
\end{equation}
\section{Methodology}\label{sec3}
In this section, we describe the proposed DQMQ in details from three main aspects including an architecture overview, the components' details and the deployment workflows in the real-world.
Specifically, DQMQ is a one-shot quantization system which includes two intertwined pipelines: bit-widths decision-making and model parameters updating. DQMQ is modeled as a hybrid reinforcement learning task via two plug-ins: Precision Decision Agent (PDA) and Quantization Auxiliary Computer (QAC). Being small and general, they can be inserted into most of the popular CNNs. We introduce the overview of the architecture of DQMQ in subsection. \ref{section:4.1} . Then, we detail the details of both plug-ins to explain why DQMQ has to be carefully designed like this in subsection. \ref{section:4.2} and subsection. \ref{section:4.3}. Finally, we show the deployment workflow in practice in subsection. \ref{section:4.4}.
\subsection{DQMQ: An Overview}{\label{section:4.1}}
To jointly learn dynamical data quality-aware bit-widths and model quantization parameters in one-shot training, it is necessary to make the inherently discrete and therefore non-differentiable decision process learnable.
Moreover, during the training stage of DQMQ, the bit-width decisions across iterations are different due to the dynamically changing input quality. Suppose that the bit-width decision module in this round gives the answer of Int4, and in the next round, the unconverged bit-width decision module gives another decision of Int8 bits. If layer-wise dequantization is not performed in each round as in previous mixed-precision SOTAs, the training error of model parameters brought by each quantization attempt will gradually accumulate and seriously affect the training accuracy. Therefore, DQMQ should take into account how to isolate different quantization attempts on dynamically changing data so that the training in each round would not affect each other.\par
First, in order to cope with the dynamically changing data quality and make the corresponding optimal quantization bit-width decision, we first carefully encode PDA to simulate the discrete probability distribution over the bit-widths candidates. We solve the non-differentiable training of PDA by regarding it as an agent in RL paradigm, and learn the policy of making optimal bit-width decisions in a policy optimization framework.
After being trained, PDA generates the most likely bit-width action for each layer according to the current input features and layer quantization sensitivities. The details about PDA will be discussed in Sect.~\textit{PDA: Bit-width Decision-making}.
Afterward, the quantizer and the dequantizer of QAC will work together to make fake quantization attempts to compute the current quantization reward. Receiving the most ideal bit-widths from PDA, the quantizer in QAC outputs the quantized model weights and activations with ideal bit-width, which would be the actual convolutional operators to generate feature maps for the next layer.
The dequantization operation just follows the convolution operation. It not only makes sure that the next layer receives the correct full-precision activations to eliminate the quantization error accumulation layer by layer in one forward pass, but also stores the full-precision weights of the network to avoid the accumulation of quantization parameters updating biases due to different bit-widths actions from two nearby iterations. The algorithm details and proof of QAC will be shown in Sect.~\textit{QAC: One-shot Training}.
\begin{figure*}[t]
\centering
\includegraphics[width=0.92\textwidth]{architecture.png}
\caption{Overall architecture design of DQMQ.}
\label{fig2}
\end{figure*}
More specifically, Fig.~\ref{fig2} shows how to integrate the proposed plug-ins with the existing training pipeline.
For a specific layer (e.g., $l$), the orange rectangle $Agent_{l}$ corresponds the above-mentioned PDA module. Encoded by a tiny four-layers CNN, PDA maps the input $x_{l}$ and sensitivity indicator $h_l$ to a bit-width decision $a_l$, of which $a_l$ is actually a candidate in the action pool of layer $l$ determined by $h_l$.
More specifically, for quantization-sensitive layers with large $h_l$ values, the drop in model accuracy due to quantization disturbance is even greater. Therefore, the bit-width values in the candidate pools of these layers tend to be relatively large, trading a smaller loss of memory gain for a smaller loss of model accuracy. Conversely, for quantization-insensitive layers with small values of h, quantization with lower bits does not bring about a significant change in model accuracy, which means that these layers can be quantized with ultra-low bits. Quantization-insensitive layers will be the main source of DQMQ's quantized memory gains.
The yellow cube in Fig.~\ref{fig2} represents the convolutional layer with the added QAC module. The two grey circles represent the quantizer and the dequantizer, which together make up the QAC. The lower yellow box in Fig.~\ref{fig2} shows the workflow of QAC.
Specifically, the quantizer $Q_l$ in QAC of layer $l$ quantizes the full-precision weights $\omega_{l}$ and activations $x_{l}$ of this layer to $\bar{\omega_{l}}$ and $\bar{x_{l}}$ with $a_l$-bits. As shown by the training rectangle in Fig.~\ref{fig2}, convolution operation is conducted on the quantized operators $\bar{\omega_{l}}$ and $\bar{\omega_{l}}$ to simulate the effect of $a_l$-bits quantization on final model performance. After that, the dequantizer $DQ_{l}$ inserted behind $l$ converts the quantized weight $\bar{\omega_{l}}$ and convolution results back to full-precision weights $\hat{\omega_l}$ and activations $\hat{x_{l+1}}$.
\subsection{PDA: Bit-width Decision-making}{\label{section:4.2}}
During quantization, the most likely bit-widths are taken from the probability distributions encoded by PDA. It is a four-layer CNN that maps the feature input to a four-class decision.
To handle this discrete and therefore non-differentiable decision process, we reference the training method used in SkipNet~\cite{skip}. Regarding the bit-width decision-making module as the \emph{$agent$}, the backbone neural network as \emph{environment} giving feedback, the layer-wise bit-width decision as the \emph{action}, the memory reduction $\sum_{l=1}^N{R_l}$ in Eq. (\ref{1}) as \emph{rewards}. We define the cumulative future reward in Eq. (\ref{3}) and learn the policy defined in Eq. (\ref{2}). \par
To learn this RL based bit-width policy synchronously with the normal supervised learning, we use a hybrid learning algorithm ~\cite{skip} which combines empirical risk minimization and cumulative reward maximization.
Specifically, in the first soft training stage, the output of the PDA is relaxed to continuous probability outputs over different quantization bit-width decisions to train fake-quantized model end-to-end by gradient descent to reduce task loss. Then, to reduce the approximation errors of the optimal quantization setting caused by relaxation, we perform hard training in the second stage to further optimize PDA by RL with respect to model quantization benefit maximization on discrete bit-width decision actions. In more detail, the bit-width decision-making module PDA is modeled as a \textbf{$agent$} in DQMQ, with the backbone neural network as \textbf{environment} giving feedback, the layer-wise bit-width decision as \textbf{action}, the memory reduction $\sum_{l=1}^{L}{R_l}$ in Eq. (\ref{4}) as \textbf{rewards}, and also the \textbf{cumulative future reward} and \textbf{policy} in Eq. (\ref{5}).\par
To address the huge RL search space of previous RL quantization works, we assign different action pools to different layers based on the hessian trace information, which has been proved as an effective quantization sensitivity indicator~\cite{HAWQ-v2}. Specifically, there may be only ultra-low bit-width candidates like Int2 or Int4 in the action pools of layers with lower quantization sensitivity. For more sensitive layers, their bit-width candidates are relatively higher like Int8 or Int16. In our work, there are three kinds of action pools $[0,1,2]$, $[2,4,8]$ and $[8,16,32]$.\par
\subsection{QAC: One-shot Training}{\label{section:4.3}}
Most state-of-the-art approaches for mixed-precision quantization start from a decoupled bit-widths search stage. They find the optimal quantization bit-width setting before actual quantization training instead of dynamically learning it. However, invariant data prior during quantization training makes the learned quantized model only a local optimum within this data quality region and loses generalization ability on data of different quality.
This is not consistent with variational data qualities in real-world and may cause serious problems when the lightweight quantized models are practically deployed in edge applications.
To solve the data isolation problem, we incorporate the previously decoupled bit-width setting search and model parameters training into one-shot training. This creates challenges as follows. \textbf{Between layers:} Different layers have a high probability of being quantized to different bit-widths. As the inputs of the next layer, the quantized activations of the current layer would affect the joint convolution and quantization of the next layer. \textbf{Between iterations:} The optimal bit-widths settings in each forward propagation would be different due to the undetermined precision decision policy. This brings different optimization precision in each iteration, and further results in the accumulation of optimization biases, which may lead to training crushing.\par
To facilitate one-shot training, we creatively propose a method named QAC that could optimize the backbone network with different bit-widths without biases accumulation. QAC is composed by the quantizer $Q$ and a the dequantizer $DQ$. The detailed plug-ins design and the optimization process and are shown in Algorithm.\ref{alg1:Framwork} and \ref{alg2:Framwork}.
\begin{algorithm}[tb]
\caption{ The forward process of training stage of DQMQ. }
\label{alg1:Framwork}
\begin{algorithmic}[1]
\REQUIRE ~~\\
The hessian trace of the $l_{th}$ layer: $h_l$ ;\\
The number of layers to be quantized: $L$;\\
The weights and inputs of the $l_{th}$ layer: $\omega_l$, $x_l$;\\
Parameters with bars are quantized rounded integer values by $Q$; \\
Parameters with hats are dequantized full precision values by $DQ$;\\
The PDA, quantizer and dequantizer of QAC: $Agent_{l}$, $Q_{l}(·)$ and $DQ_{l}(·)$;\\
The policy, reward and action of RL: $\pi_l$, $r_l$, and $a_l$;\\
The classifier layer: $fc$;\\
Loss function: $f(·)$;
\ENSURE ~~\\
The trained DQMQ;
\FOR{$l=1$ to $L$}
\STATE $a_l = \pi_l(h_l, x_l)$ ;
\STATE $\bar{x}_l = Q_l(x_l,a_l)$, $\bar{\omega}_{l} = Q_l(\omega_l,a_l)$;
\STATE $\bar{x}_{l+1} = \bar{x}_l \otimes \bar{\omega}_{l}$;
\STATE $\hat{x}_{l+1} = DQ_{l}(\bar{x}_{l+1}), \hat{\omega}_l = DQ_{l}(\bar{\omega}_{l})$;
\ENDFOR
\STATE $\hat{y}_{pre} = DQ_{L}(fc(\hat{x}_L))$;
\STATE Compute the optimization target defined in Eq. (\ref{1})
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[htb]
\caption{The backward process of DQMQ training.}
\label{alg2:Framwork}
\begin{algorithmic}[1]
\REQUIRE ~~\\
$net(x,\omega)$ represents the backbone of DQMQ with input $x$ and convolution weight $\omega$;\\
$\otimes$ represents the convolution operation;\\
$Q(x) = Round(\frac{x}{s_1}+z)$, $Q(w) = Round(\frac{\omega}{s_2}+z)$;\\
$DQ(x) = (x-z)*s_1$, $DQ(w) = (\omega-z)*s_2$, \\
$DQ(y) = y*s_1*s_2$;\\
where $s_1=\frac{2^\textbf{a}-1}{\max_x-\min_x}$,
$s_2=\frac{2^\textbf{a}-1}{\max_{\omega}-\min_{\omega}}$, and $z=0$ in our work;\\
\ENSURE ~~\\
The trained DQMQ;
\STATE Algorithm 1: $\hat{y}_{pre}(fc(\hat{x}_L))$ ;
\STATE $\hat{y}_{pre} = DQ(fc(\hat{x}_L))
= fc(net(\hat{x}\otimes\hat{\omega})*s_1*s_2
= fc(net(\frac{x}{s_1}),\frac{\omega}{s_2}))*s_1*s_2
= \frac{1}{s_11}\frac{1}{s_2}fc(net(x,\omega))*s_1*s_2
= fc(net(x,\omega))$;
\STATE $\Delta \omega=\frac{\delta T}{\delta y}*\frac{\delta y}{\delta \omega}$;\\
\STATE This indicates the variables being optimized in training stage are the full-precision ones, which makes the quantization decisions between multi-iterations to be independent.\\
\end{algorithmic}
\end{algorithm}
\subsection{Practical Deployment}{\label{section:4.4}}
\begin{figure*}[t]
\centering
\includegraphics[width=0.90\textwidth]{deploy.png}
\caption{Coping mechanisms for partially deployed and skeleton-deployed DQMQs when encountering data quality excursions exceeding a threshold.}
\label{fig4}
\end{figure*}
Despite the limited resources, such as storage, computing units, power, network, etc., the booming embedded devices at the edge provide a vast platform for the deployment of intelligent applications around humans. Model quantization aims to compress deep models into lightweight intelligent applications, reducing the memory and computational complexity of intelligent applications so that they can be deployed on resource-constrained embedded devices.
But are these lightweight predictive architectures robust enough for real-world inference? Discarding part of the network structure has led to a more or less decrease in the accuracy of these lightweight models. Another potential risk stems from the fact that lightweight intelligent models are faced with real-world inference tasks. , the source distribution of the input data is beyond control. For example, camera blur, transmission noise, image compression, viewpoint changes, etc. can cause the test distribution to shift relative to the static training data. As analyzed in the introduction, dynamically changing test data quality leads to different optimal quantization bit-width settings, despite the same model and the same data class distribution.\par
DQMQ is the first work to quantify the shift in the quality distribution of test data. We have analyzed how DQMQ trains the model at specific times to obtain the perception of dynamic quality in the above subsections.
Although DQMQ adds an additional quantization auxiliary module to the skeleton of a deep neural network, this does not increase the computational or memory overhead of the quantized model he generates during inference. On the contrary, due to data quality-aware quantization, it can maximize model redundancy according to the current data distribution to generate deep quantized models with minimal description length while maintaining task accuracy. Note that the extra quantization auxiliary module is very lightweight (a four-layer fully connected network, two multiplication and division operations and two addition and subtraction operations) compared to the bulky backbone neural network. Also, these quantization-assisted models are not necessarily deployed on actual mobile edge devices. DQMQ will dynamically decide to deploy the entire quantitative model (including PDA and QAC), partial quantitative model (including only PDA and part of QAC), or only the quantized model backbone (excluding any component). We will detail the workflow of DQMQ in practical deployment in this subsection to illustrate the wide applicability of DQMQ in the real world.\par
As shown in Fig.~\ref{fig4}, the deployment of DQMQ can be divided into three situations: \textbf{full deployment}, \textbf{partial deployment} and \textbf{skeleton deployment} according to the resource situation of edge mobile devices. Full deployment refers to deploying the entire DQMQ framework to the edge when the resources of edge mobile devices are sufficient to obtain all the capabilities of DQMQ, including quality-aware bit-width selection, model quantization, and model retraining. Partial deployment is defined as choosing only the data quality perception module (e.g. computing disparity), bit-width decision module (PDA) and quantization module (quantizer in QAC) with the backbone of the quantization model when the resources of the mobile device are not sufficient. They are deployed on edge devices together, so that edge devices can obtain data-aware bit-width selection and model requantization functions. Backbone deployment refers to deploying only the quality perception module and the quantized neural network backbone to the edge when the resources of edge mobile devices are extremely scarce. At this time, the data-aware bit-width selection is jointly completed by the edge side and the server side. When the edge side detects that the data quality has a large deviation (such as day and night, changing the environment), the edge side initiates the server to re-select the bit-width And quantify model application and report current data quality. The server will reselect the quantization bit-width according to the current data quality, and return the new quantization model parameters to the edge device.
To be specific, for data-sensitive mobile applications with relatively adequate memory, such as laptop, workstation and smart phones, etc., PDA and the quantizer of QAC mentioned before are deployed with the backbone of the neural network to make timely adjustments in the face of changing data quality, and it follows the above-mentioned workflow.
For extremely resource-constrained devices like smart watches and Google glasses, all plug-ins would be removed in actual deployment to obtain the most lightweight DQMQ. The necessary adjustments of quantization models when facing unacceptable data quality changes (i.e., image pixel error exceeds a predefined threshold.) will be done by triggering a command to request a new model from the server. The details are as follows:
\ding{182} By setting a very small data quality-aware module at the forefront of the deployed backbone, an unacceptable changing of inputs quality would be detected.
In details, the data quality-aware module is a resolution-based image-quality detector. Once the resolution deviation exceeds the threshold, for example, a change of shooting scene, the model-request command would be triggered instantly.
\ding{183} Edge devices send the request together with the quality of inputs which triggered the model-request to the edge server.
\ding{184} Receiving a specific quality, the most likely bit-width setting is made through the trained PDA and the quantization is done jointly.
\ding{185} The new lightweight quantization model is sent to the devices.
\section{Experiments}
We compare the proposed DQMQ with a range of state-of-the-art (SOTA) quantization works and evaluate them on three benchmarks: ImageNet, CIFAR-10, and SVHN. We construct the DQMQ of ResNet-18 models by sandwiching layers with quantization and dequantization modules and inserting a decision CNN on each residual block. In Sec. 4.1, we decipher the essence of layer sensitivity to quantization and study its correlation with data quality. In Sec. 4.2, we evaluate the performance of DQMQ and compare it with popular approaches, including mixed precision quantization works DQ, AutoQ, HAWQ~\cite{dq,AutoQ,hawq}, and fixed precision quantization PACT, LQNet, DNAS, US, SAT, TQT networks~\cite{pact,lqnet,dnas,us,sat,tqt}. We also compare our approach with a full precision network to demonstrate the effectiveness of the data quality-aware decision policy.
\subsection{Benchmark}
\label{section:4.1}
\subsubsection{Dataset}
Extensive experiments are conducted on three popular datasets for model quantization including ImageNet, CIFAR-10, and SVHN. The diversity of data patterns more effectively reflects the generality of our proposed method.
For ImageNet, it has greater scale and diversity, thus providing more reliable evaluations of the proposed vision methods. Specifically, ImageNet is currently the largest database for image recognition in the world. Over 14 million images were manually annotated by ImageNet to indicate objects in the picture. In at least one million images, bounding boxes are also provided. ImageNet contains more than 20,000 categories. In this work, we use the lightweight ISLVRC2012 dataset with 1000 categories. Each class contains hundreds of images. Among them, the training subset contains more than 1.2 million natural images, and the validation subset contains 50,000 images. We process the image size as 224 $\times$ 224.
CIFAR-10 is a color image dataset that approximates ubiquitous objects. It contains a total of 10 categories of RGB color pictures and the size of each image is 32 × 32 There are 6000 images in each category, and there are a total of 50000 training images and 10000 testing images in the dataset. Note that we have enhanced the image quality of CIFAR-10. Specifically, to simulate the dynamically changing data quality on mobile devices, we first processed CIFAR-10 with a low-pass filter with Gaussian blur radius of 1, 3, and 5 to represent varying degrees of low-quality input.
After that, we perform image sharpening by enhancing the edge position based on second-order differential to represent high-quality input that is easier to identify. Fig. \ref{fig5} provides an intuitive illustration of the above processing results.
We use `level 1' to `level 5' to name the five different picture qualities, the bigger the number, the blurrier the image. `level 1' denotes the sharpening image and `level 2' denotes the raw data. We select 10000 images from each of the above five scales respectively and ensure each selection is done with uniform data label distribution. These images with 5 different qualities are mixed together to form a new dataset named `CIFAR-10 (Mixed)'.
The Street View House Numbers (SVHN) dataset is a collection of house numbers taken from Google Street View imagery and contains more than 600,000 labeled data of digit images for identifying alphanumeric characters in natural scene images. The dataset contains ten categories, of which the training set contains 73,257 images and the test set contains 26,032 images. Each image size is 32 $\times$ 32. Note that SVHN undergoes the same mixed-quality treatment as CIFAR-10.
\begin{figure}[t]
\centering
\subfloat[Original image.]{
\includegraphics[width=0.4\linewidth]{rawfig.png}}
\subfloat[Edge-sharpened image.]{
\includegraphics[width=0.4\linewidth]{rh.png}}\\
\subfloat[Image after Gaussian blur with radius 1.]{
\includegraphics[width=0.4\columnwidth]{gau1.png}}
\subfloat[Image after Gaussian blur with radius 2.]{
\includegraphics[width=0.4\linewidth]{gau2.png}}
\caption{CIFAR-10 images of different qualities.}
\label{fig5}
\end{figure}
\subsubsection{Models}
Based on multiple datasets with diverse image patterns and uneven data qualities, we explore the effectiveness of the proposed DQMQ on ResNet-18 for it is the most commonly used network by state-of-the-art quantization works.
To be specific, ResNet-18 has 4 residual blocks and 2 convolution layers in each block.
Note that the skeleton neural network is improved based on the design concept of DQMQ. To be specific, each convolutional layer is sandwiched by a data-aware module PDA and a quantization auxiliary module QAC.
The detailed implementation is as follows. Before each convolution layer, a tiny four-layer CNN (PDA) that maps the feature input to four-class bit-widths is first inserted. Following PDA, it is a quantizer containing two division and addition operators, and finally, the dequantizer in QAC closely follows behind each convolution operator.\par
\subsubsection{Training Details}
The proposed DQMQ is trained on 1 Nvidia GTX 3090TI GPU. For ImageNet dataset, the framework is trained with 120 epochs. For CIFAR-10 and SVHN, DQMQ is converged in 60 epochs. The batch size is 512 in each training and testing process, and the learning rate starts from 0.1 and is uniformly reduced to 0.001. The hyperparameter $\alpha$, which adjusts the training weight between supervised learning optimization and policy optimization, is empirically set as 0.5 in this work. \par
\begin{table}[tbp]
\renewcommand\arraystretch{1.5}
\centering
\caption{Comparison of Top-1 accuracy of DQMQ with popular Fixed-Precision Quantization methods. Results are of ResNet-18 on ImageNet. `FP' means full-precision training, and $\delta_{acc}$ means the accuracy difference between quantization model and full-precision model. `W-Comp' is the weight compression rate.
}
\scalebox{1}[0.9]{
\begin{tabular}{lccccc}
\bottomrule \hline
& \multicolumn{4}{c}{\textbf{Fixed-Precision Quantization}} & \\\hline
\textbf{Method} & \multicolumn{2}{|c}{3-bit} & \multicolumn{2}{c|}{4-bit} & \textbf{W-Comp}\\ \hline
& \multicolumn{1}{|c}{Acc($\%$)} & $\delta_{acc}$ & Acc($\%$) & \multicolumn{1}{c|}{{$\delta_{acc}$} } & \\ \hline
\multicolumn{1}{c|}{PACT} & 68.30 & -1.90 & 69.20 & \multicolumn{1}{c|}{-1.00} & \\
\multicolumn{1}{c|}{LQNet} & 68.20 & -2.10 & 69.30 & \multicolumn{1}{c|}{-1.00} & \\
\multicolumn{1}{c|}{DNAS} & 68.70 & -2.30 & 70.60 & \multicolumn{1}{c|}{-0.40} & 4.00X/2.00X \\
\multicolumn{1}{c|}{US} & 69.40 & -1.50 & 70.50 & \multicolumn{1}{c|}{-0.40} & \\
\multicolumn{1}{c|}{SAT} & 69.30 &-1.90 & 70.30 & \multicolumn{1}{c|}{0.10} & \\
\multicolumn{1}{c|}{TQT} & * & * & 69.51 & \multicolumn{1}{c|}{-0.77 } & \\ \hline
\multicolumn{1}{c|}{\textbf{DQMQ (ours)}} &\multicolumn{4}{c|}{\underline{\textbf{71.47}}} & \underline{\textbf{5.69X}} \\ \hline
\multicolumn{1}{c|}{FP($\%$)} &\multicolumn{4}{c|}{70.28} & 1.00X \\ \hline
\multicolumn{1}{c|}{Size(MB)} & \multicolumn{2}{c}{13.28 v.s. {\underline{\textbf{7.83}}}} &\multicolumn{2}{c|}{24.42 v.s. {\underline{\textbf{7.83}}}} &
\\\bottomrule \hline
\end{tabular}
}
\label{table1}
\end{table}
\begin{table}[tbp]
\renewcommand\arraystretch{1.5}
\centering
\caption{Comparison of Top-1 accuracy of DQMQ with other popular Mixed-Precision Quantization methods. Results are of ResNet-18 on ImageNet. Data with a `*' refers to certain constrained conditions (Details can be found in the references).}
\scalebox{1}[0.9]{
\begin{tabular}{ccccc}
\bottomrule \hline
& \multicolumn{3}{c}{\textbf{Mixed-Precision Quantization}} & \\\hline
\multicolumn{1}{c}{\textbf{Method}} & Acc($\%$) & $\delta_{acc}$ &Size(MB) &W-Comp \\ \hline
DQ & 70.08 & -0.20 &$7.54^*$ & 5.90X \\
AutoQ & $68.20^*$ &$-0.70^*$ &$5.19^*$ & 8.58X \\
HAWQ & 70.22 & -1.25 &$8.24^*$ &5.40X \\
\textbf{DQMQ (ours)} & \underline{\textbf{71.47}} & \underline{\textbf{1.19}} &\underline{\textbf{7.83}} &\underline{\textbf{5.69X}} \\
\multicolumn{1}{c}{FP($\%$)} & 70.28 & 0.00 &$8.24^*$ &1.00X \\
\bottomrule
\end{tabular}
}
\label{table2}
\end{table}
\begin{table}[]
\renewcommand\arraystretch{1.5}
\centering
\caption{Quantization results on CIFAR-10 (Mixed) and SVHN. `W/A' are the weights' and activations' bit-widths respectively. `MP' refers to mixed-precision quantization.}
\scalebox{1}[0.9]{
\begin{tabular}{cccc}
\bottomrule
\textbf{Dataset} & \textbf{Bits(W/A)} & \textbf{Method} & \textbf{Acc (Top-1)($\%$)} \\ \bottomrule
& 32/32 & FP & 76.56 \\
CIFAR-10 & MP & HAWQ & 81.9 \\
& MP & \textbf{DQMQ (ours)} & \underline{\textbf{82.03}} \\ \hline
& 32/32 & FP & 76.56 \\
CIFAR-10 & MP & HAWQ & 69.76 \\
(Mixed) & MP & \textbf{DQMQ (ours)} & \underline{\textbf{81.43}} \\ \hline
& 32/32 & FP & * \\
SVHN & MP & HAWQ & 74.32\\ (Mixed)
& MP &\textbf{DQMQ (ours)} & \underline{\textbf{79.02}} \\ \hline
& 32/32 & FP & * \\
SVHN & MP & HAWQ & 78.13 \\
& MP &\textbf{DQMQ (ours)} & \underline{\textbf{78.91}} \\ \bottomrule
\end{tabular}}
\label{table3}
\end{table}
\subsection{Performance Comparison with SOTA}
In this section, we compare the task performance of our data-aware mixed-precision quantization method with various SOTA methods including both fixed-precision and mixed-precision. More specifically, for fixed-precision quantization, we compare DQMQ with various works including PACT, LQNet, DNAS, US, SAT, TQT networks~\cite{pact,lqnet,dnas,us,sat,tqt}. For mixed-precision quantization works, DQMQ is compared with some of the most representative works including DQ, AutoQ, HAWQ~\cite{dq,AutoQ,hawq}.
All methods in this section are evaluated on the ImageNet dataset and ResNet-18 architecture, and we use task accuracy and model size reduction as the evaluation measurements for performance comparisons.
Table.\ref{table1} shows the results of the comparison between DQMQ and fixed-precision quantization works. Note that in the last line named `Size', the 13.28M and 24.42M are the model sizes under fixed-precision quantization with 3-bits and 4-bits, respectively, and 7.83 is the size of the quantized model from DQMQ with mixed bit-widths.
It can be clearly seen that for fixed-precision quantization, nearly all methods suffer from the accuracy drop caused by model quantization except SAT, which has a small accuracy gain of $0.1\%$ on 4-bit quantization. Conversely, DQMQ shows greater accuracy gains with $1.19\%$ accuracy improvement.
What's more, for fixed methods, the compression rate of model size is limited by the integer bit-width division. Excluding binary and tertiary quantization that bring a large drop in accuracy, the highest model compression rate in most fixed-precision methods does not exceed 4 times.
The comparison results with mixed-precision are shown in Table.\ref{table2}.
Similar to the static quantization result, nearly all existing mixed methods show accuracy degradation after quantization except AutoQ, which has a small accuracy benefit of $0.7\%$.
Regarding model quantization as a perturbation to the original model parameters, the drop in accuracy in most previous works reveals their poor perturbation adversarial.
Conversely, the reward scheme in data quality-aware quantization helps learn the optimal quantitative policy when facing diverse samples, greatly reducing the parameters entropy and improving the quantization robustness~\cite{lottery}.
Finally, we compare the task performance of HAWQ and DQMQ based on CIFAR-10 (Mixed) and SVHN (Mixed) with ResNet-18 architecture. We test both the quantized models on various data qualities to demonstrate if the proposed DQMQ has the ability to adapt itself to different test distributions. The results are listed in Table.~\ref{table3}. In CIFAR-10 (Mixed) and SVHN (Mixed), the data quality ranges from the worst Gaussian blur to better image sharpening widely. It is obvious that our DQMQ can achieve higher test accuracy than HAWQ on all dataset. To be specific, on the original CIFAR-10 and SVHN with uniform data quality, as predicted, due to the lack of rich data quality knowledge in training stage, the performance of DQMQ and HAWQ is almost equal. However, in data domains where the data distribution changes drastically (mixed datasets), DQMQ can make better quantization decisions and reap higher accuracy and robustness than HAWQ.
\begin{figure}[ht]
\centering
\subfloat[Blurred data]{
\includegraphics[width =0.8\columnwidth]{hawq_dqmq.png}
}\\
\subfloat[Standard data]{
\includegraphics[width =0.8\columnwidth]{raw_hawq_dqmq.png}
}\\
\subfloat[Sharpened data]{
\includegraphics[width =0.8\columnwidth]{rh_hawq_dqmq.png}
}
\caption{Comparison of accuracy (Top-1)($\%$) of DQMQ and HAWQ of ResNet-18 on CIFAR-10 with different image qualities.}
\label{fig3}
\end{figure}
\subsection{Correlation Exploration Between Data Quality and Quantization Sensitivity}
In this subsection, we would prove the strong correlation between data quality with layer quantization sensitivity to emphasize the strong necessity of our research.
The underlying motivation origins from the fact that mobile devices are most likely working in edge environments with dynamically changing contexts. The uncontrollable data qualities in running time could have a large distribution deviation from that of training time and cause the vanilla quantization to suffer significant performance degradation.
In order to find a more robust model quantization in the face of changing data quality, it is important to explore the relationship between data quality and optimal quantization bit-width.
\begin{figure}[t]
\centering
\subfloat[ResNet-18: Layer sensitivity under different data qualities.]{
\includegraphics[width =0.92\columnwidth]{old2d.png}
}\\
\subfloat[ResNet-18: Enlarged view of the last eight layers.]{
\includegraphics[width =0.8\columnwidth]{0908.png}
}\\
\subfloat[ResNet-20: Layer sensitivity under different data qualities.]{
\includegraphics[width =0.92\columnwidth]{hessianinfo.png}
}
\caption{Comparison of the layer-wise quantization sensitivities of DQMQ on ResNet-18 under CIFAR-10 with five different data qualities.}
\label{hessianinfo}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width =0.92\columnwidth]{skip_dif.png}
\caption{The quantization precision decisions made by DQMQ under different data qualities and ResNet-18. The horizontal axis is the index of the convolutional network in the network, and the vertical axis is the quantization accuracy of this layer determined by DQMQ. Yellow arrows represent the maximum difference of quantization bit-widths for each layer under three different data qualities.}
\label{fig4}
\end{figure}
\begin{table}[]
\renewcommand\arraystretch{1.5}
\centering
\caption{Comparison of Top-1 accuracy between mixed-precision quantization methods HAWQ and DQMQ under three data qualities.Results are of ResNet-18 on specially processed CIFAR-10.}
\scalebox{1}[0.9]{
\begin{tabular}{cccc}
\bottomrule
\textbf{Method} & \textbf{Data Quality} & \textbf{Acc (Top-1)(\%)} \\ \bottomrule
& blurring & 67.19 \\
HAWQ & standard & 81.90 \\
& sharpening & 80.31 \\ \hline
& blurring & \underline{\textbf{76.50}} \\
\textbf{DQMQ (ours)} & standard & \underline{\textbf{82.03}} \\
& sharpening & \underline{\textbf{82.34}} \\ \bottomrule
\end{tabular}}
\label{table4}
\end{table}
Thus, extensive experiments are conduct on datasets with mixed data qualities and the results are shown in Fig.~\ref{hessianinfo} and Fig.~\ref{fig4}.
As shown in Fig.~\ref{hessianinfo}, since the trace of the Hessian matrix is positively correlated with the relative quantization sensitivities between layers~\cite{HAWQ-v2}, we compare layers' hessian trace under five data qualities to observe the changes in the optimal quantization precision for each layer on both ResNet-18 and ResNet-20.
In ResNet-18, as data quality gets worse, sensitivities of deeper layers begin to increase, while the layer-wise sensitivity differences show a downward trend.
In ResNet-20, the results show that with increasing image noise, the degree of the turbulence of hessian curve gradually increases, which confirms the fact that as data quality changing, layer-wise relative quantization sensitivity should fluctuate dynamically rather than remain static as existing methods. Data quality would be a unavoidable factor in quantization settings searching.
What's more, as shown in Fig.~\ref{fig4}, the yellow arrows represent the maximum quantization bit-width difference for each layer under three data qualities. It is clearly that the layers in the middle and closer to the classifier are more sensitive to the changing of data quality. These layers make totally different quantization bit-width decisions when data quality changes.
At this point, we can claim that: \textit{under ambiguous test distributions about data quality, DQMQ could dynamically make the model quantization adapt to the data variation and thus lead to better robustness at diverse data qualities}.
To be more precise, we also compare the accuracy of the proposed DQMQ with HAWQ under three different data qualities. Both methods are conducted on ResNet-18 and CIFAR-10 (Mixed). Results are shown in Table.~\ref{table4}. For HAWQ, when data quality increases from standard quality(unprocessed CIFAR-10) to better quality(Sharpening CIFAR-10),
contrary to expectations, there is a slight drop in model accuracy even with better data quality.
The disordered relationship between the accuracy and input data qualities of HAWQ
illustrates that for the same bit-width, the performance of the quantized model is not simply proportional to the data quality. In the relationship chain of "data quality $\rightarrow$ quantization settings $\rightarrow$ quantization performance", the first and last items are not directly related and lost the expected consistency.
HAWQ takes only model information into consideration when make quantization decisions and ignores changes in data. Different from that, DQMQ uses both model and data information to dynamically make the quantization bit-width decision. DQMQ not only shows a higher prediction accuracy than SOTA under the same quality, but also keeps showing an accuracy ascension as data quality gets better. DQMQ restores the positive relationship between model performance and data quality in quantitative scenarios, which also demonstrates its data quality-adaptive ability from one-shot quantization training.
\section{Conclusion}
In this paper, we proposed a novel data-quality aware model quantization method (DQMQ) to achieve more robust compressed models in the edge environment.
Our method is the first attempt that focuses on the perspective of data rather than the model architecture or algorithm, to improve both the generalization and robustness of quantized models.
Our method can dynamically adapt the quantization precision to different data qualities with layer-wise multiple bit-widths synchronously with task performance. Moreover, we also incorporate the decoupled bit-width decision-making and quantization training into a much more efficient and coherent one-shot training scheme.
Extensive experiments verified the effectiveness of the proposed method.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2023-02-10T02:07:10', 'yymm': '2302', 'arxiv_id': '2302.04453', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04453'} | arxiv |
\section{Introduction} \label{sec:intro}
Learning to perform algorithmic-like computation is a core
problem in machine learning that has been widely studied from different perspectives,
such as learning to reason \citep{khardon1997learning}, program interpreters \citep{reed2015neural} and automated
theorem proving \citep{rocktaschel2017end}. As a matter of fact, enabling reasoning
capabilities of neural networks might drastically increase {\it generalisation}, i.e.
the ability of neural networks to generalise beyond the support of the training data,
which is usually a difficult challenge with current neural models
\citep{neyshabur2017exploring}.
Neural Algorithmic Reasoning \citep{DBLP:journals/patterns/VelickovicB21} is a recent
response to this long-standing question, attempting to train neural networks to exhibit
some degrees of {\it algorithmic reasoning} by learning to execute classical algorithms.
Arguably, algorithms are designed to be general, being able to be executed and return
``optimal'' answers for any inputs that meet a set of strict pre-conditions. On the other hand,
neural networks are more flexible, i.e. can adapt to virtually any input. Hence, the
fundamental question is whether neural models may inherit some of the positive algorithmic properties and use them to solve potentially challenging real-world problems.
Historically, learning algorithms has been tackled as a simple
supervised learning problem \citep{graves2014neural,
DBLP:conf/nips/VinyalsFJ15}, i.e. by learning an input-output mapping,
or through the lens of reinforcement learning \citep{DBLP:conf/iclr/KoolHW19}.
However, more recent works build upon the notion
of {\it algorithmic alignment} \citep{DBLP:conf/iclr/XuLZDKJ20} stating that there must be an ``alignment'' between the learning model structure and the target algorithm in order
to ease optimisation. Much focus has been placed on Graph Neural
Networks (GNNs) \citep{DBLP:journals/nn/BacciuEMP20} learning graph
algorithms, i.e Bellman-Ford \citep{bellman1958routing}.
\cite{DBLP:conf/iclr/VelickovicYPHB20} show that it is
indeed possible to train GNNs to execute classical
graph algorithms. Furthermore, they show that optimisation must occur
on all the intermediate steps of a graph algorithm, letting the
network learn to replicate step-wise transformations of the input
rather than learning a map from graphs to desired outputs. Since
then, algorithmic reasoning has been applied with success in
reinforcement learning \citep{DBLP:conf/nips/DeacVMBTN21}, physics
simulation
\citep{DBLP:journals/corr/reasoning-repr} and bipartite matching
\citep{DBLP:journals/corr/GeorgievNBM}.
Moreover, \citet{DBLP:conf/nips/XhonneuxDVT21} verify the importance of training
on multiple ``similar'' algorithms at once ({\it multi-task learning}).
The rationale is that many classical algorithms share sub-routines,
i.e. Bellman-Ford and Breadth-First Search (BFS),
which help the network learn more effectively and be able to transfer knowledge
among the target algorithms.
\citet{pmlr-v198-ibarz22a} expand on this concept by building a generalist neural algorithmic learner that can effectively learn to execute even a set of unrelated algorithms.
However, learning some specific algorithms might require learning of very specific properties of the input data, for which multi-task learning may
not help.
For instance, learning the {\it Ford-Fulkerson algorithm}
\citep{ford1956maximal} for {\it maximum flow} entails learning to identify the
set of {\it critical} (bottleneck) edges of the flow network, i.e. edges for which a decrease
in the {\it edge capacity} would decrease the maximum flow.
Furthermore, in the single-task regime, i.e. when we are interested in learning only one single algorithm, relying on multi-task learning can unnecessarily increase the computational burden on the training phase.
Motivated by these requirements, we seek alternative learning setups to
alleviate the need for training on multiple algorithms and enable better
reasoning abilities of our algorithmic reasoners.
We find a potentially good candidate in the {\it duality} information of the target
algorithmic problem. The concept of duality fundamentally enables
an algorithmic problem, e.g. linear program,
to be viewed from two perspectives, that
of a {\it primal} and a {\it dual} problem. These two problems
are usually complementary, i.e. the solution of one might lead to
the solution of the other. Hence, we propose to incorporate duality
information directly in the learning model both as an additional
supervision signal and input feature (by letting the network
reuse its dual prediction in subsequent steps of the algorithm),
an approach we refer to as Dual Algorithmic Reasoning (DAR). To the best of our knowledge, there exists no prior work targeting
the usage of duality in algorithmic reasoning.
We show that by training an {\it
algorithmic reasoner} on both learning of an algorithm and
optimisation of the dual problem we can relax the assumption of having multiple algorithms to train on
while retaining all the benefits of multi-task learning. We demonstrate clear performance gain in both synthetically generated algorithmic tasks and real-world predictive graph learning problems.
\section{Problem statement} \label{sec:background}
We study the problem of neural algorithmic reasoning on
graphs. Specifically, we target learning of graph algorithms $A: {\mathbb{G}}
\rightarrow {\mathbb{Y}}$ that take in graph-structured inputs $G = (V, E, {\bm{x}}_i, {\bm{e}}_{ij})$, with $V$ being the set of nodes and $E$ the set of edges with node features ${\bm{x}}_i$ and edge features
${\bm{e}}_{ij}$, and compute a desired output ${\bm{y}} \in {\mathbb{Y}}$.
Usually, the output space of an algorithm $A$ depends on its scope. In the most general cases, it can either
be $\mathbb{R}^{|V|}$ (node-level output), $\mathbb{R}^{|V| \times |V|}$ (edge-level
output) or $\mathbb{R}$ (graph-level output). We mainly consider the class of
algorithms outputting node-level and edge-level outputs, which
includes many of the most well-known graph problems,
e.g. reachability, shortest path and maximum flow. From a neural
algorithmic reasoning perspective, we are particularly interested in
learning a sequence of transformations ({\it steps} of the
algorithm). Hence, we consider a sequence of graphs $\{G^{(0)}, \dots,
G^{(T-1)}\}$ where each element
represents the intermediate
state of the target algorithm we aim to learn. At each step $t$ we
have access to intermediate node and edge features,
i.e. ${\bm{x}}^{(t)}_i, {\bm{e}}^{(t)}_{ij}$, called {\it hints} as well as
intermediate targets ${\bm{y}}^{(t)}$. As it is common in classical algorithms, some of the intermediate targets may be used as node/edge features in the subsequent step of the algorithm. Such hints
are thus incorporated in training as additional features/learning targets,
effectively learning the whole sequence of steps ({\it algorithm
trajectory}).
In particular, we focus on learning {\it maximum flow} via the neural
execution of the {\it Ford-Fulkerson algorithm}. Differently
from \citet{DBLP:journals/corr/GeorgievNBM}, who learn Ford-Fulkerson
to find the independent set of edges in bipartite graphs, we aim to
learn Ford-Fulkerson for general graphs. We report the
pseudo-code of Ford-Fulkerson in the appendix. Ford-Fulkerson poses two key challenges: (i) it comprises two sub-routines, i.e. finding augmenting paths from $s$ to $t$, and updating
the flow assignment ${\bm{F}}^{(t)} \in {\mathbb{R}}^{|V| \times |V|}$ at each step
$t$; (ii) ${\bm{F}}$ must obey a set of strict constraints, namely the
{\it edge-capacity constraint} and {\it conservation of flows}. The
former states that a scalar value $c_{ij}$ (capacity) is assigned to
every $(i, j) \in E$ and ${\bm{F}}$ must satisfy:
\begin{equation} \label{eq:cap-cons}
\forall (i, j) \in E \;.\; {\bm{F}}_{ij} \leq c_{ij},
\end{equation}
i.e. flow assignment to an edge must not exceed its capacity. The
latter states that the assignment needs to satisfy:
\begin{align} \label{eq:flow-cons}
\forall i \in V \setminus \{s, t\} : \sum_{(i,j) \in E} {\bm{F}}_{ij} + \sum_{(j,i) \in E} {\bm{F}}_{ji} =
0 \quad
\land \sum_{(s, j) \in E} {\bm{F}}_{sj} = -\sum_{(j, t) \in E} {\bm{F}}_{jt}
\end{align}
i.e. the flow sent out from the source is not lost nor created by
intermediate nodes. This also leads to ${\bm{F}} = -{\bm{F}}^T$,
i.e. antisymmetry. An optimal solution ${\bm{F}}^*$ to the max flow problem
is the one maximising the total flow in the network, i.e.
$\sum_{(s, j) \in E} {\bm{F}}_{sj}$.
We show how we address both challenge (i) and (ii)
directly in the model architecture, through the concept of {\it
algorithmic alignment} and by carefully adjusting and rescaling
the model predictions.
\section{Methodology}\label{sec:methodology}
\subsection{Leveraging duality in algorithmic reasoning}
\label{sec:duality}
We leverage the concept of {\it duality} when learning to neurally
execute classical graph algorithms. In particular, most of the problems
solved by
classical algorithms (including maximum flow) can be expressed in the
form of constrained optimisation problems such as {\it linear
programming} or {\it integer linear programming}. In mathematical
optimisation, the duality principle ensures that any optimisation
problem may be viewed from two perspectives: the ``direct'' interpretation
(called the {\it primal} problem) and the {\it dual} problem, which is
usually derived from the {\it Lagrangian} of the primal problem.
The duality principle ensures that the solutions of the two problems
are either linked by an upper-bound/lower-bound relation
({\it weak duality}) or equal ({\it strong duality})
\citep{boyd2004convex}. Hence, the two problems are interconnected.
In the context of neural algorithmic reasoning, we identify several
reasons why primal-dual information might be useful to
consider. First, by incorporating {\it primal-dual}
objectives, we let the network reason on the task from two different and complementary perspectives. This can substantially simplify learning of algorithms which require identifying and reasoning on properties which are not explicitly encoded in input data.
For instance, to effectively solve max-flow problems, the network needs the ability to identify and reason on {\it critical edges}. By the {\it max-flow min-cut theorem} \citep{ford2015flows}, this set of edges corresponds to the {\it minimum cut}, i.e. dual problem, that separates the source node $s$ from the sink $t$. Hence, correctly identifying the minimum cut
is highly relevant for producing a relevant max-flow solution.
Second, being able to output a better step-wise solution means that there is less chance for error propagation throughout the trajectory of the neurally executed algorithm.
This is especially true for more complex algorithms, such as Ford-Fulkerson, consisting of multiple interlocked sub-routines. There, an imprecise approximation of one sub-routine can negatively cascade on the results of the following ones.
Finally, learning jointly on the primal-dual can be seen as an instance of {\it multi-task learning}, but relaxing the assumption of having multiple algorithms to train on.
In the following, we study dual algorithmic reasoning on the max-flow primal complemented with min-cut dual information.
Note that graph neural networks have been formally proven to be able to learn minimum cut, even under uninformative input features \citep{DBLP:journals/corr/Fereydounian}. This also implies that solving min-cut can be a useful ``milestone'' for a network learning to solve max-flow.
\subsection{architecture} \label{sec:architecture}
\begin{figure}
\centering
\includegraphics[width=.85\linewidth]{img/archv2.png}
\caption{High-level architecture of the Dual Algorithmic Reasoner (DAR) for the Ford-Fulkerson algorithm.
Refer to the text for a comprehensive explanation.}
\label{fig:architecture}
\end{figure}
We rely on the neural algorithmic reasoning blueprint
\citep{DBLP:journals/patterns/VelickovicB21}, building on the encode-process-decode framework \citep{DBLP:conf/cogsci/HamrickABZMTB18}.
The abstract architecture
of the Dual Algorithmic Reasoner (DAR) is depicted in
\autoref{fig:architecture} for the Ford-Fulkerson algorithm. Since the latter is composed of two sub-routines, we introduce two processors to align neural execution with the dynamics of the algorithm. The first processor $P_{BF}$ learns
to retrieve augmenting paths, while $P_F$ learns to perform flow-update operations ${\bm{F}}^{(t)}$.
Both $P_{BF}$ and $P_F$ are implemented as graph networks with Message-Passing Neural Network (MPNN) convolution \citep{DBLP:conf/icml/GilmerSRVD17}:
\begin{equation} \label{eq:conv}
{\bm{h}}_i^{(t+1)} = \psi_\theta\left({\bm{h}}_i^{(t)}, \bigoplus_{(j, i)\in
E}\phi_\theta\left({\bm{h}}_i^{(t)}, {\bm{h}}_j^{(t)}, {\bm{e}}_{ij}^{(t)}\right)\right),
\end{equation}
where $\psi_\theta$ and $\phi_\theta$ are neural networks with ReLU
activations and $\bigoplus$ is a permutation-invariant function,
i.e. summation, mean or max.
Intuitively, the encode-process-decode architecture allows
{\it decoupling} learning of the algorithmic steps from the use of specific input features. Through the learned processor, the algorithm can be neurally executed on a latent-space which is a learnt representation of the input features required by the original algorithm. We will show how we can exploit this property to perform steps of the Ford-Fulkerson algorithm even with missing input features.
More in detail, the DAR computational flow comprises two {\it linear} encoders, $f_v$ and $f_e$, which are applied respectively
to node features ${\bm{x}}^{(t)}_i$ and edge features ${\bm{e}}^{(t)}_{ij}$ to produce encoded node-level and edge-level features:
\begin{equation*}
{\bm{Z}}^{(t)}_V = \{{\bm{z}}_{i}^{(t)} = f_v({\bm{x}}_{i}^{(t-1)}) \mid \forall
i \in V\} \quad , \quad {\bm{Z}}^{(t)}_E = \{{\bm{z}}_{ij}^{(t)} =
f_e({\bm{e}}_{ij}^{(t-1)}) \mid \forall (i, j) \in E\}.
\end{equation*}
These encoded representations are used as inputs for the processor network $P_{BF}$ which computes the latent node representations ${\bm{H}}^{(t)}$ as:
\begin{equation*}
{\bm{H}}^{(t)} = P_{BF}({\bm{Z}}^{(t)}_V, {\bm{Z}}^{(t)}_E, {\bm{H}}^{(t-1)})
\end{equation*}
with ${\bm{H}}^{(0)} = \{{\bm{0}} \mid \forall i \in V\}$. In our DAR instance, this processor performs Bellman-Ford steps to retrieve the shortest augmenting path from $s$ to $t$, following \citet{DBLP:journals/corr/GeorgievNBM}.
${\bm{H}}^{(t)}$ is then passed to a decoder network $g$
producing the augmenting path ${\bm{p}}^{(t)}$:
\begin{equation}
{p}_i^{(t)} = g_{BF}({\bm{z}}^{(t)}_{i}, {\bm{h}}^{(t)}_i).
\end{equation}
The augmenting path is represented as a vector of predecessors for all
nodes in the graph, i.e. each entry ${p}^{(t)}_i$ is a pointer to
another node $j$ in the graph. This way, we are able to reconstruct a
path from any node (included $t$) back to the source node $s$. The
augmenting path ${\bm{p}}^{(t)}$ is then passed to $P_F$ as an input
feature. The target quantities of the algorithm, i.e. flow assignment
${\bm{F}}$ and minimum cut ${\bm{c}}$, are finally predicted as:
\begin{equation*}
\{{\bm{F}}^{(t)}, {\bm{c}} \} = g_F\big(P_F( {\bm{Z}}^{(t)}_V \cup
\{{\bm{p}}^{(t)}\}, {\bm{Z}}^{(t)}_E, {\bm{H}}^{(t)} )\big).
\end{equation*}
W.l.o.g. we choose to represent the minimum {\it s-t} cut ${\bm{c}}$ as node-level
features, where ${c}_i = 0$ indicates that $i$ is in the cluster of nodes of $s$, and ${c}_i = 1$ otherwise. Note that the minimum
{\it s-t} cut includes all edges $(i,j)$ for which ${c}_i = 0$ and ${c}_j = 1$. Furthermore, ${\bm{F}}^{(t)}$ is reused as an input feature in the next step of the algorithm (${\bm{F}}^{(0)} = {\bm{0}}$).
We pay additional attention to the prediction of the flow assignment
matrix ${\bm{F}}^{(t)}$, in order to be compliant with the maximum flow
problem constraints described in \autoref{sec:duality}. In particular, we transform ${\bm{F}}$ to ensure compliance with anti-symmetry, i.e. ${\bm{F}}' = {\bm{F}} - {\bm{F}}^{T}$. To satisfy edge-capacity constraints we
further rescale the matrix according to the hyperbolic tangent and the
actual value of the capacity $c_{ij}$ for each $(i,j) \in E$, as such:
\begin{equation} \label{eq:F}
{\bm{F}} = \tanh({\bm{F}}) \odot C,
\end{equation}
where $C_{i,j} = c_{ij}$ for all edges in the graph. We note that this
only satisfies the box constraint on the edge capacities, however the
conservation of flows might still be violated, i.e. nodes in the path
from the source to the target may either retain some amount of in-flow
(sending out less than what is received) or vice versa.
To address
this last constraint, we simulate the entire neural algorithm until
termination and apply a corrective procedure in order to correct all
the flow conservation error. We report the pseudocode of this procedure in the Appendix, along with additional details and results.
\section{Experiments}
To assess the benefits of the dual algorithmic reasoning approach, we
test the learning model in two specific scenarios. First, we train and
test the DAR pipeline on synthetic-generated
graphs, to evaluate the benefits in the key task of algorithmic
learning (section \ref{sec:synthetic}). Then, to evaluate the
generality of the model we test it on a real-world graph learning task. Specifically, we compare our model with several graph
learning baselines on a biologically relevant {\it vessel}
classification task \citep{DBLP:conf/nips/PaetzoldMSEBPST21},
comprehending large-scale vessel graphs (section
\ref{sec:predictive}). We stress that
our neural reasoners are not further
re-trained on real-world data, thus forcing
the model to use the algorithmic knowledge
attained on synthetic data to solve the new
task.
\subsection{Synthetic graphs}
\label{sec:synthetic}
\begin{figure}
\centering
\subfigure[Ford-Fulkerson validation loss]{
\centering
\includegraphics[width=.46\linewidth]{img/valid.png}
\label{fig:valid-synthetic}
}
\subfigure[Ford-Fulkerson reconstruction loss]{
\centering
\includegraphics[width=.46\linewidth]{img/reconstruction.png}
\label{fig:loss-reconstruction}
}
\caption{{\bf (a)} Ford-Fulkerson validation loss on synthetic data for PGNs.
{\bf (b)} normalised loss curve of reconstructing Ford-Fulkerson with new encoders
for $l_{ij}, d_{ij}, \rho_{ij}$, with both the primal and dual PGN-max. It applies to BVG data.}
\end{figure}
\begin{table}
\caption{Mean Absolute Error (MAE) and accuracy of predicting
the final ${\bm{F}}$ and intermediate flow $\bar{{\bm{F}}}^{(t)}$, and min-cut ${\bm{c}}$ (if applicable) on
{\it 2-community} and {\it bipartite} graphs. {\it (primal)}
corresponds to training on max-flow only.
{\it (dual)} corresponds to training with both primal-dual
heads. {\it (pipeline)} corresponds to learning min-cut first. {\it (no-algo)} corresponds to optimising directly max-flow, without learning Ford-Fulkerson.}
\centering
\setlength{\tabcolsep}{4.2pt}
\footnotesizev2
\begin{tabular}{l c c c c c c}
\toprule
& \multicolumn{3}{c}{2-Community {\it (out-of-distribution)}} & \multicolumn{3}{c}{Bipartite {\it \it (out-of-family)}}\\
\midrule
{\bf Model} & ${\bm{F}}$ & $\bar{{\bm{F}}}^{(t)}$& ${\bm{c}}$ & ${\bm{F}}$ & $\bar{{\bm{F}}}^{(t)}$ & ${\bm{c}}$ \\
PGN-max {\it (primal)} & $0.266_{\pm 0.001}$ & $0.294_{\pm 0.002}$ & -
& $0.56_{\pm 0.23}$ & $0.82_{\pm 0.17}$ & - \\
PGN-mean {\it (primal)} & $0.274_{\pm 0.001}$ & $0.311_{\pm 0.004}$ & -
& $1.09_{\pm 0.47}$ & $1.13_{\pm 0.18}$ & - \\
MPNN-max {\it (primal)} & $0.263_{\pm 0.008}$ & $0.289_{\pm 0.004}$ & -
& $0.75_{\pm 0.47}$ & $0.78_{\pm 0.11}$ & -\\
MPNN-mean {\it (primal)} & $0.278_{\pm 0.008}$ & $0.313_{\pm 0.003}$ & -
& $0.75_{\pm 0.47}$ & $0.92_{\pm 0.22}$ & -\\
\midrule
PGN-max {(\it dual)} & $\mathbf{0.234_{\pm 0.002}}$ & $\mathbf{0.269_{\pm 0.001}}$ & $100\%_{\pm 0.0}$
& $0.49_{\pm 0.22}$ & $\mathbf{0.78_{\pm 0.29}}$ & $100\%_{\pm 0.0}$ \\
PGN-mean {(\it dual)} & $0.240_{\pm 0.004}$ & $0.285_{\pm 0.004}$ & $100\%_{\pm 0.0}$
& $1.10_{\pm 0.30}$ & $1.05_{\pm 0.12}$ & $99\%_{\pm 0.7}$ \\
MPNN-max {(\it dual)} & $0.236_{\pm 0.002}$ & $0.288_{\pm 0.005}$ & $100\%_{\pm 0.0}$
& $0.71_{\pm 0.32}$ & $0.98_{\pm 0.22}$ & $100\%_{\pm 0.0}$ \\
MPNN-mean {(\it dual)} & $0.258_{\pm 0.008}$ & $\mathbf{0.268_{\pm 0.002}}$ & $100\%_{\pm 0.0}$
& $0.81_{\pm 0.09}$ & $1.06_{\pm 0.35}$ & $100\%_{\pm 0.0}$\\
\midrule
PGN-max {(\it pipeline)} & $0.256_{\pm 0.001}$ & $0.293_{\pm 0.003}$ & $61\%_{\pm 0.1}$
& $\mathbf{0.45_{\pm 0.18}}$ & $\mathbf{0.77_{\pm 0.26}}$ & $95\%_{\pm 0.1}$ \\
PGN-mean {\it (pipeline)} & $0.244_{\pm 0.001}$ & $0.304_{\pm 0.001}$ & $100\%_{\pm 0.0}$
& $0.98_{\pm 0.44}$ & $1.03_{\pm 0.32}$ & $99\%_{\pm 0.8}$ \\
MPNN-max {\it (pipeline)} & $0.261_{\pm 0.002}$ & $0.312_{\pm 0.005}$ & $61\%_{\pm 0.3}$
& $\mathbf{0.47_{\pm 0.23}}$ & $0.95_{\pm 0.34}$ & $90\%_{\pm 1.1}$\\
MPNN-mean {\it (pipeline)} & $0.255_{\pm 0.002}$ & $0.292_{\pm 0.002}$ & $100\%_{\pm 0.0}$
& $0.64_{\pm 0.35}$ & $0.92_{\pm 0.20}$ & $100\%_{\pm 0.0}$\\
\midrule
Random & $0.740_{\pm 0.002}$ & - & $50\%_{\pm 0.0}$ & $1.00_{\pm 0.00}$ & - & $50\%_{\pm 0.0}$ \\
PGN-max {\it (no-algo)} & $0.314_{\pm 0.013}$ & - & - & $0.78_{\pm 0.02}$ & - & - \\\bottomrule
\end{tabular}
\label{tab:syn-res}
\end{table}
\paragraph{Data generation}
We consider two different families of graphs: (i) {\it 2-community}
graphs, in which communities are sampled from the {\it Erdős–Rényi}
distributions with probability 0.75 and their nodes are interconnected
with probability 0.05; (ii) {\it bipartite} graphs. To thoroughly assess the generalisation capabilities of our algorithmic reasoners, we exclusively trained all models on small {\it 2-community} graphs and tested on 4x larger
{\it 2-community} graphs ({\it out-of-distribution}) and 4x larger {\it bipartite} graphs ({\it out-of-family}). We highlight that bipartite graphs are solely used for testing purposes and no further training occurs on them.
To generate train, validation and test sets we follow the
standard CLRS benchmark \citep{deepmind2022clrs} setup.
Specifically, we sample 1000 {\it 2-community} training graphs
with 16 nodes each. The validation set is used to assess
in-distribution performance, thus comprising 128 {\it 2-community} graphs with still
16 nodes. To assess out-of-distribution and out-of-family generalisation we consider respectively 128
test 2-community samples and 128 bipartite samples, both of size of 64 nodes. Furthermore, we generate data of all intermediate steps of
the Ford-Fulkerson algorithm to be used as {\it hints} and additional
training targets, in order to train the network on all intermediate
data manipulations. Algorithm features are once again generated following the CLRS-30 standard and they comprise: (i) {\it inputs}:
source node $s$, sink node $t$, edge-capacity matrix $C \in {\mathbb{N}}^{|V|
\times |V|}$ and additional weights $W \in [0,1]^{|V| \times |V|}$
for the Bellman-Ford processor; (ii) {\it hints} (algorithm steps):
augmenting paths ${\bm{p}}^{(t)}$ and intermediate flow assignments
${\bm{F}}^{(t)}$; (iii) {\it outputs} (learning targets): final flow matrix
${\bm{F}}$ and minimum cut ${\bm{c}}$. Lastly, capacities are sampled as
integers from $U(0, 10)$ and then rescaled via a min-max normalisation
for {\it 2-community} graphs, while they are sampled as either 0 or 1
for {\it bipartite} graphs.
\paragraph{Ablation \& neural architectures} We performed an ablation study to assess the contribution from the dual, by training
the same DAR architecture without the
additional {\it min-cut head} (consequently the dual information does
not flow back in $P_F$ in \autoref{fig:architecture}). To deepen our analysis, we also consider a neural architecture where the minimum cut is learnt prior the
Ford-Fulkerson algorithm. Specifically, we introduce a third processor
that is trained solely on minimum cut, whose output is then used as an
additional feature for the architecture presented in
\autoref{fig:architecture}. Furthermore, we compare two different
types of processors: (i) a fully-connected Message-Passing Neural Network (MPNN)
\citep{DBLP:conf/icml/GilmerSRVD17}, which implements \eqref{eq:conv}
and exchanges messages between all pairs of nodes; (ii) Pointer-Graph
Network (PGN) \citep{DBLP:conf/nips/VelickovicBOPVB20}, which instead
exchanges messages only between a node and its neighbours defined
by the {\it inputs} and {\it hints} of the algorithm.
For all processors, we try different aggregation operators in
\eqref{eq:conv}, namely $\bigoplus = \{\max, \mean, \sumt \}$. We
train all models for 20,000 epochs with the SGD optimiser and we average the results across 5 runs.
We also use {\it teacher
forcing} with a decaying factor of 0.999. This has the effect of
providing the network with ground-truth {\it hints} for the early stage of
the training phase, while letting the network predictions flow in for
the majority of training. To choose optimal hyperparameters, e.g.
learning rate, hidden dimension, we employ a bi-level random search
scheme, where the first level samples values of hyperparameters in a
large range of values, while the second one ``refines'' the search based
on the first level results. We choose the best hyperparameters based
on the validation error on ${\bm{F}}$. Aggregated validation loss curves are shown in Figure \ref{fig:valid-synthetic}.
For further details on the model selection, refer to the appendix.
\paragraph{Results analysis} We report results on Ford-Fulkerson
simulation in \autoref{tab:syn-res}. Specifically, we use the Mean
Absolute Error (MAE) as a metric for assessing the predictions of
the final flow assignment ${\bm{F}}$, obtained as in \eqref{eq:F}. Similarly, we measure average
performance on all the intermediate flow assignment
$\bar{{\bm{F}}}^{(t)}$ in order to show how well the algorithm is imitated
across all steps, which is referred to as $\bar{{\bm{F}}}^{(t)}$ in
\autoref{tab:syn-res}. Where applicable, we report
accuracy on the minimum cut as well, i.e. for {\it dual} and
{\it pipeline} models. To better evaluate all models, we include a random baseline which samples ${\bm{F}}$ at random and rescales it following \eqref{eq:F} and a GNN trained to directly output the flow matrix ${\bm{F}}$ without learning Ford-Fulkerson (marked as {\it no-algo}). First,
\autoref{tab:syn-res} shows clear performance advantage with respect to the two baselines, indicating that learning {\it max-flow} with the support of algorithmic reasoning, i.e. learning of Ford-Fulkerson, is more effective.
More importantly, we notice how models incorporating
the prediction of the dual problem consistently outperform the
{\it primal} baselines on both {\it 2-community} and {\it bipartite}
graphs. Dual architectures also better imitate the algorithm
across all intermediate steps compared to primal, as testified
by lower $\bar{{\bm{F}}}^{(t)}$. This suggests that the dual min-cut information, despite being easy to learn \citep{DBLP:journals/corr/Fereydounian}, helps
the model achieve a lower prediction error. This finding is also
strengthened by the observation that whenever the min-cut prediction is
imprecise, e.g. \{PGN, MPNN\}-max pipeline for {\it 2-community},
the prediction of ${\bm{F}}$ and ${\bm{F}}^{(t)}$ become consequently worse. From our
experiments, the {\it dual} PGN architecture with max aggregator
emerges as the best-performing model,
at least for what concerns {\it 2-community} graphs, being able to
perfectly predict also the minimum cuts of all the graphs in the
test set. Contrastingly, learning min-cut first is less stable
(while still outperforming the primal baseline) confirming
prior work findings on the effectiveness of multi-task learning.
The performance gap also increases when testing {\it out-of-family}
on bipartite graphs, where {\it dual} and {\it pipeline} with
max aggregator are both very competitive. We note that for
bipartite graphs we record higher mean and standard deviations.
While this behaviour is emphasised by the fact that capacities
are sampled as either 0 or 1, i.e. leaving more chances for prediction
errors, this testifies that generalisation to arbitrary graph
distributions is still a challenging task.
\paragraph{Qualitative analysis}
\begin{table}
\caption{Qualitative analysis on the prediction of ${\bm{F}}$.
Mean Absolute Error (MAE) is used as the regression error from
the ground truth maximum flow value. For simplicity, we only report results of the best-performing models (PGNs).}
\begin{center}
\footnotesizev2
\begin{tabular}{l c c c c c c}
\toprule
& \multicolumn{2}{c}{\it primal}
& \multicolumn{2}{c}{\it dual}
& \multicolumn{2}{c}{\it pipeline}\\
{\bf Metric}
& {\bf PGN-max} & {\bf PGN-mean}
& {\bf PGN-max} & {\bf PGN-mean}
& {\bf PGN-max} & {\bf PGN-mean}\\
\midrule
$|{\bm{F}} - {\bm{F}}^*|$ & $7.86 \pm 0.47$ & $8.68 \pm 0.21$
& $\mathbf{0.34 \pm 0.04}$ & $0.41 \pm 0.01$
& $7.58 \pm 0.10$
& $0.38 \pm 0.08$ \\
\bottomrule
\end{tabular}
\end{center}
\label{tab:qualitative}
\end{table}
To further evaluate the performance of DAR, we perform a qualitative
study, whose results are presented in \autoref{tab:qualitative}. For {\it 2-community} graphs
we assess how close the predicted flow matrix ${\bm{F}}$ is
to the optimal max-flow solution without considering errors for
intermediate nodes. This gives a measure of how well the network
can predict the maximal flow value in the graphs and use it in the
predicted solution. To achieve that, we ignore intermediate errors and
only measures flow signal exiting the source node $s$ and entering
the sink node $t$, i.e. $\sum_{(s, j) \in E} {\bm{F}}_{sj}$ and
$\sum_{(j, t) \in E} {\bm{F}}_{jt}$. Thus, we take the maximum (absolute value)
between the two and compare this value to the ground truth
maximum flow value ${\bm{F}}^*$. From \autoref{tab:qualitative} we observe that
all the dual architectures exhibit a solution which reflects the true
maximum flow quantity in the input graphs, i.e. $\approx 0.30$ of MAE
from the optimum on average. This analysis further solidifies
our claim that a DAR model can positively transfer knowledge from the dual to the primal problem resulting in more accurate and qualitatively superior solutions. This claim is also supported by the
fact that both primal architectures and dual architectures for which
min-cut results are worse miss the optimal solution by a large margin (compare PGN-max {\it pipeline} min-cut results in \autoref{tab:syn-res}
and higher MAE in \autoref{tab:qualitative}).
\subsection{Real-world graphs} \label{sec:predictive}
\paragraph{Benchmark description} We assess generality and potential impact of the DAR pipeline by considering a real-world
edge classification task, for which prior knowledge of the concept of
{\it max-flow} might be helpful. We test both the primal and the DAR
architectures on the Brain Vessel Graphs (BVG) benchmark
\citep{DBLP:conf/nips/PaetzoldMSEBPST21}. This benchmark contains 9
large-scale real-world graphs, where edges represent vessels and nodes represent
bifurcation of the vessel branches in a brain network. The task is to
classify each edge in three categories: {\it capillaries}, {\it veins}
and {\it arteries} based on the following features: vessel length
$l_{ij}$; shortest distance between bifurcation points $d_{ij}$;
and curvature $\rho_{ij}$. Note that the three classes can be
distinguished by the radius of the vessel, or equivalently, by the
amount of blood flow that can traverse the vessel. Hence, being able
to simulate the blood flow in the entire brain network is likely to be advantageous to effectively solve the task. As an additional challenge, note that the classification task is highly imbalanced, i.e. 95\% of samples are capillaries, 4\% veins and only 1\% arteries.
We test the models on three BVG graphs, namely CD1-E-1 (the largest, with 5,791,309 edges), CD1-E-2 (2,150,326 edges) and CD1-E-3 (3,130,650 edges). BVG data also include
a synthetic brain vessel graph for validation purposes, comprising 3159 nodes and 3234 edges.
\paragraph{Algorithm reconstruction}
The main difference with our synthetic tasks is that here we need to
estimate the vessel diameter/radius which is a quantity that can
be related with the vessel {\it capacity}, i.e. how much blood (flow)
can traverse the edge. Therefore, the {\it capacity} is a learning
target rather than one of the features to feed our algorithmic reasoner with.
Here, we exploit the generality of the encode-process-decode architecture
and learn to {\it reconstruct} the Ford-Fulkerson neural execution.
Specifically, we reuse PGN-max networks pre-trained on {\it 2-community}
graphs (section \ref{sec:synthetic}).
As the {\it capacity} is no longer an input
feature, we drop the {\it capacity} encoder from $f_v$ and introduce three new
encoder layers in $f_v$, one for each feature of the vessel graph benchmark,
i.e. $l_{ij}, d_{ij}, \rho_{ij}$. Thus, we freeze all the parameters in the
pre-trained models apart from the introduced encoder layers. Hence,
we only train the weights of $l_{ij}, d_{ij}, \rho_{ij}$ to learn
Ford-Fulkerson steps
in absence of input information about capacity.
In other words, the model learns to use $l_{ij}, d_{ij}, \rho_{ij}$ to estimate
the edge flows in the network, which act as proxy information for
edge capacities, i.e. our primary objective in the BVG task.
We perform these learning steps of algorithm reconstruction on the synthetic
vessel graph provided by the BVG benchmark. Source and sink nodes $s, t$ are chosen as two random nodes whose
shortest distance is equal to the diameter of the graph. We train to reconstruct the algorithm for 15000 epochs, with Adam optimiser
\citep{DBLP:journals/corr/KingmaB14} and learning
rate 1e-5. Figure \ref{fig:loss-reconstruction} compares the loss curves for the primal and DAR models, on the task.
Thus, we simulate one single step of Ford-Fulkerson on CD1-E-{\it X} through PGN-max {\it primal} and {\it dual} models and extract hidden learnt representations for each node, which are then summed together to get edge
embeddings. These edge embeddings will be used as additional input
features for the graph neural networks (described below) which we train to solve brain vessel classification. Finally, we highlight how this approach allows us to easily dump the embeddings, as the reconstructed encoders and processors will not be training further on real-data.
\paragraph{Neural architectures}
We consider graph neural networks from the BVG benchmark
paper as our baselines, namely Graph Convolutional Networks (GCNs)
\citep{DBLP:conf/iclr/KipfW17}, GraphSAGE
\citep{DBLP:conf/nips/HamiltonYL17} and ClusterGCN
\citep{DBLP:conf/kdd/ChiangLSLBH19} with GraphSAGE convolution
(C--SAGE).
The general architecture consists of several graph convolutional layers with ReLU activations
followed by a linear module.
Additionally, we use the embeddings extracted by
PGN-max {\it (primal)} and PGN-max {\it (dual)} to train a
simple linear classifier (LC) to assess how much
information these embedding add with respect to the original
$l_{ij}, d_{ij}, \rho_{ij}$ features.
We also use those representations in combination with GraphSAGE and C--SAGE. Specifically, our embeddings are concatenated together with the GraphSAGE's and C--SAGE's learnt embeddings prior the final linear layer. As an additional sanity check, we also train
Node2Vec \citep{DBLP:conf/kdd/GroverL16} on each of the three datasets
and concatenate its learnt embeddings the same way.
All models are trained with early stopping of 300 epochs and optimal hyperparameters
taken from the BVG paper, which we report in the appendix for completeness. Finally, we average
the results across 3 trials.
\paragraph{Results analysis}
\begin{table}
\caption{Balanced accuracy (Bal. Acc.) and area under the ROC curve (ROC) performance metrics on large-scale brain vessel graphs. LC refers to a linear classifier. In addition to
the standard architectures, we consider variants where
the final linear classification layer takes in
additional Node2Vec
\citep{DBLP:conf/kdd/GroverL16} learnt embeddings
and embeddings extracted from PGN-max
primal and dual architectures.}
\centering
\footnotesizev2
\setlength{\tabcolsep}{5pt}
\begin{tabular}{l c c c c c c}
\toprule
& \multicolumn{2}{c}{CD1-E-3} & \multicolumn{2}{c}{CD1-E-2} & \multicolumn{2}{c}{CD1-E-1} \\
{\bf Model} & {\bf Bal. Acc.} & {\bf ROC}
& {\bf Bal. Acc.} & {\bf ROC}
& {\bf Bal. Acc.} & {\bf ROC}\\
\midrule
LC & $39.3\%_{\pm 0.2}$ & $52.3\%_{\pm 0.6}$ & $36.9\%_{\pm 0.5}$ & $55.9\%_{\pm 0.1}$ & $45.5\%_{\pm 0.1}$ & $61.7\%_{\pm 0.0}$\\
LC {\it (N2V)} & $43.9\%_{\pm 0.2}$ & $55.5\%_{\pm 0.1}$ & $71.9\%_{\pm 0.1}$ & $62.6\%_{\pm 0.0}$ & $46.1\%_{\pm 0.1}$ & $60.0\%_{\pm 0.0}$\\
LC {\it (primal)} & $48.6\%_{\pm 0.4}$ & $59.4\%_{\pm 0.4}$ & $58.7\%_{\pm 0.1}$ & $63.8\%_{\pm 0.2}$ & $45.3\%_{\pm 0.1}$ & $59.9\%_{\pm 0.1}$\\
LC {\it (dual)} & $53.8\%_{\pm 0.3}$ & $66.2\%_{\pm 0.2}$ & $67.3\%_{\pm 0.1}$ & $71.8\%_{\pm 0.0}$ & $48.1\%_{\pm 0.5}$ & $62.1\%_{\pm 0.3}$\\
\midrule
GCN & $58.1\%_{\pm 0.5}$ & $67.9\%_{\pm 0.2}$ & $74.6\%_{\pm 1.7}$ & $78.7\%_{\pm 0.1}$ & $59.0\%_{\pm 0.2}$ & $67.9\%_{\pm 0.2}$ \\
\midrule
SAGE & $63.5\%_{\pm 0.2}$ & $70.9\%_{\pm 0.3}$ & $73.9\%_{\pm 0.6}$ & $82.5\%_{\pm 0.2}$ & $64.7\%_{\pm 0.7}$ & $74.2\%_{\pm 0.2}$\\
SAGE {\it (N2V)} & $65.0\%_{\pm 0.1}$ & $71.9\%_{\pm 0.1}$ & $84.1\%_{\pm 1.9}$ & $82.5\%_{\pm 0.4}$ & $65.9\%_{\pm 0.1}$ & $74.8\%_{\pm 0.1}$ \\
SAGE {\it (primal)} & $64.5\%_{\pm 0.2}$ & $72.0\%_{\pm 0.2}$ & $83.8\%_{\pm 0.4}$ & $83.7\%_{\pm 0.4}$ & $66.2\%_{\pm 0.5}$ & $74.8\%_{\pm 0.3}$ \\
SAGE {\it (dual)} & $66.7\%_{\pm 0.4}$ & $75.0\%_{\pm 0.2}$ & $85.2\%_{\pm 0.1}$ & $85.5\%_{\pm 0.2}$ & $66.4\%_{\pm 0.3}$ & $74.8\%_{\pm 0.1}$ \\
\midrule
C--SAGE & $68.6\%_{\pm 0.8}$ & $74.2\%_{\pm 0.5}$ & $81.8\%_{\pm 0.5}$ & $85.6\%_{\pm 0.2}$ & $59.3\%_{\pm 0.9}$ & $68.3\%_{\pm 0.5}$\\
C--SAGE {\it (N2V)} & $68.6\%_{\pm 0.2}$ & $74.1\%_{\pm 0.1}$ & $84.8\%_{\pm 0.2}$ & $84.8\%_{\pm 0.5}$ & $67.4\%_{\pm 0.6}$ & $\mathbf{75.9\%_{\pm 0.2}}$\\
C--SAGE {\it (primal)} & $67.3\%_{\pm 0.2}$ & $73.6\%_{\pm 1.9}$ & $82.5\%_{\pm 1.9}$ & $84.0\%_{\pm 1.5}$ & $67.7\%_{\pm 0.1}$ & $\mathbf{75.8\%_{\pm 0.2}}$\\
C--SAGE {\it (dual)} & $\mathbf{70.2\%_{\pm 0.2}}$ & $\mathbf{76.3\%_{\pm 0.1}}$ & $\mathbf{85.6\%_{\pm 0.2}}$ & $\mathbf{86.7\%_{\pm 0.3}}$ & $\mathbf{68.1\%_{\pm 0.2}}$ & $\mathbf{75.8\%_{\pm 0.1}}$\\
\bottomrule
\end{tabular}
\label{tab:bvg-res}
\end{table}
Results on the BVG benchmark are reported in \autoref{tab:bvg-res}.
As the learning problem is highly imbalanced, we use the balanced
accuracy score (average of recall for each class)
and the area under the ROC curve as metrics to evaluate the performance.
Looking at LC performance, we see that the algorithmic reasoner embeddings (both primal and dual) are informative, resulting in an average 16.6\% increase in
balanced accuracy and 10.5\% in ROC across the three datasets when compared to simple features. Dual embeddings also show superior
performance compared to primal embeddings, as testified by consistent increments in both metrics. Figure \ref{fig:loss-reconstruction} hints that this might be due to a better algorithm reconstruction in the dual, which results in more informative representations. LC performance also gives a clear indication of how well the algorithmic reasoner is able to positively transfer knowledge acquired on synthetic algorithmic tasks to unseen real-world predictive graph learning ones.
When considering the use of learnt embedding in combination with GNN architecture, we note significant performance improvements over vanilla (i.e. non algorithmically enhanced) GNNs. C--SAGE with {\it dual} embeddings achieves
the best performance on all three datasets with a consistent
performance gap for CD1-E-3 and CD1-E-2. Interestingly,
dual embeddings consistently outperform Node2Vec embeddings.
This is remarkable, considering that Node2Vec is trained directly on the CD1-E-{\it X} data, whereas DAR only performs inference on them. A reason to this performance gap might be that Node2Vec essentially widens the local perceptive field of graph neural networks with random walks as an attempt to capture global graph features. On the contrary, DAR utilises a more principled approach based on the simulation of graph flow. This means that the learnt latent space encodes the information necessary to reconstruct the flow assignment and consequently edge capacities, these being more informative for the specific task. DAR models also exhibit very good generalisation capabilities. In fact, we recall that the networks are only trained on graphs with 16 nodes and extract meaningful representations for graphs with millions of nodes, being able to provide a clear performance advantage over baselines. This might also indicate a way worth
pursuing to realise sustainable {\it data-efficient} learning models for graphs.
\section{Conclusion}
We have presented {\bf dual algorithmic reasoning} (DAR), a neural
algorithmic reasoning approach that leverages
duality information when learning classical algorithms. Unlike other approaches,
we relax the assumption of having multiple algorithms to be learnt jointly and
show that incorporating the dual of the problem targeted by algorithms
represents a valuable source of information for learnt algorithmic reasoners.
We showed that learning together the primal-dual max-flow-min-cut problem can substantially
improve the quality of the predictions, as testified by the quantitative and qualitative evaluations of the models. Furthermore, dual algorithmic reasoners have demonstrated to generalise better, showing positive knowledge transfer across different families of graph distributions and extracting informative representations for large-scale graphs while only being trained on toy-synthetic graphs.
In this context, we also demonstrated for the first time how more
classical graph learning tasks can be tackled through exploitation of algorithmic reasoning, via {\it algorithm reconstruction}. On a final note, we identify several problems and algorithms that may benefit from a dual reasoning approach. First, max-flow and min-cut may be representative for a wide class of primal/dual pairs, for which {\it strong duality} holds. There, the dual solution can be used to recover the primal optimum (and vice versa), equivalently to max-flow and min-cut. Examples of such problems are {\it shortest path} and {\it min-cost flow} problems. More interestingly, we may generalise this approach to target also {\it weak} primal-dual problems, in which the dual objective is an approximation of the primal objective. Even in the case of weak duality, dual information is valuable, as testified by the numerous algorithms exploiting primal-dual relations \citep{balinski1986competitive, pourhassan2017use}. Particularly interesting problems to target may be the {\it Travelling Salesman Problem} \citep{cormen2009}, for which a dual formulation includes learning to output a 1-tree \citep{bazaraa1977traveling}, and the {\it Weighted Vertex Cover} problem, for which the dual can effectively be used to develop 2-approximation heuristics \citep{pourhassan2017use}.
We believe that results showed in this manuscript should strongly motivate further work in this direction, extending the analysis to other pairs of primal-dual problems, such as the ones suggested in this section.
\subsubsection*{Acknowledgments}
This research was partially supported by TAILOR, a project funded by EU Horizon 2020 research and innovation programme under GA No 952215.
| {'timestamp': '2023-02-10T02:08:31', 'yymm': '2302', 'arxiv_id': '2302.04496', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04496'} | arxiv |
\section{Introduction}
Physical and engineering systems are governed by certain conservation laws, which are deeply rooted in the underlying symmetries of natural laws. The theories laid by Emmy Noether provide us with a profound understanding of the connections between conservation laws and underlying symmetries \cite{sardanashvily2016noether}. In works by Noether, the role of Lagrangian formalism (systems described by a Lagrangian) is overwhelming since most of the proof of the theorem is taken care of by the Lagrangian. The Lagrangian of a physical system encodes succinctly all the important information
needed for discovering the underlying physics \cite{calkin1996lagrangian} and conservation law and has application in different disciplines ranging from quantum field theory to electromagnetism, to continuum mechanics, to the general theory of relativity \cite{landau2013course,landau2013classical}. In this paper, we propose an algorithm that can discover interpretable Lagrangian from data and use it for discovering governing physics and conservation laws.
Learning the Lagrangian of systems from data has gained some popularity in recent times. Due to the significant developments in data-driven \cite{rudy2017data,wu2020data,TRIPURA2023115783}, and physics-informed \cite{raissi2019physics,goswami2020transfer,tartakovsky2020physics,chakraborty2021transfer} neural network algorithms, researchers have suggested using neural network to extract Lagrangian from data. Initial works related to the discovery of Lagrangian can be linked to Hamiltonian Neural Networks (HNN) \cite{greydanus2019hamiltonian,toth2019hamiltonian}. Learning Hamiltonian from data using graph neural network can be found in \cite{sanchez2019hamiltonian}. In these approaches, the Hamiltonian is parameterized through the neural network, and a physics-informed neural network is constituted to learn the Hamiltonian from data. The limitation behind these networks was that Hamiltonian formalism requires that the coordinates of the system must be canonical, which is often restrictive for real-life systems. As an alternative, the Deep Lagrangian Networks (DeLaN) was proposed in \cite{lutter2019deep}. For learning the Hamiltonian and Lagrangian directly in Cartesian coordinates, Constrained Hamiltonian Neural Networks (CHNNs) and Constrained Lagrangian Neural Networks (CLNNs) were proposed in \cite{gruver2022deconstructing}. Motivated by the recent developments in graph neural networks, the Lagrangian graph neural network (LGNN) for learning the Lagrangian of rigid body dynamics was proposed in \cite{bhattoolearning}. However, these works were mostly limited to rigid body dynamics. Another elegant approach for discovering the Lagrangian of non-rigid body motions was proposed in \cite{cranmer2020lagrangian}. For a brief comparison of the similarities, differences, and the theory behind all the above frameworks, readers can further refer to \cite{zhong2021benchmarking}. The application of Hamiltonian and Lagrangian formalism for robotic control can also be found in \cite{gupta2019general,duong2021hamiltonian}.
One issue that arises in the above neural network-based frameworks is that the discovered Lagrangian models are not interpretable, and this significantly reduces its reusability. For instance, it is not possible to discover the governing equation from the discovered Lagrangian. Another issue with such frameworks resides in the fact that to learn the Lagrangian accurately multiple-time history of system responses is required, which is prohibitive from a practical point of view. From here, we deviate ourselves and focus on the recently published Sparse Identification of Nonlinear Dynamics (SINDy) algorithm \cite{brunton2016discovering}. The SINDy is a sparse system identification algorithm that automates the discovery of governing equations of motion from data. The advantage of the SINDy algorithm over its neural network counterparts \cite{rudy2019deep,raissi2018deep} is that it provides an interpretable form of the exact governing dynamics. The exact physics helps in the generalization of the discovered model to unseen environmental conditions. To discover the exact interpretable physics, it employs a sequential threshold least-square regression. Further, SINDy is computationally efficient and scalable with an increase in the dimension of the measurement states. The Bayesian approach for discovering governing physics from data can also be found in \cite{nayek2021spike,tripura2022model,tripura2023sparse}. These approaches, although robust to noise, are computationally demanding as compared to SINDy.
We hereby propose a data-driven framework for systematic, automatic, and accelerated discovery of Lagrangian from data. In particular, we leverage the well-established Lagrangian formalism to discover exact physics and the sequential threshold least-squares to discover the exact sparse Lagrangian of systems from data. The proposed framework is more informative than identifying the ordinary and partial differential equations (ODE/PDE) from data \cite{rudy2017data,rudy2019deep}. In comparison to ODE/PDE discovery, the proposed framework can also be automated using Legendre transformation through symbolic derivatives to automatically discover the conservation laws. In terms of data requirement, the proposed framework needs only a single observation of the system responses to accurately distills the Lagrangian of the underlying physical system.
The proposed approach has several key features that can be encapsulated into the following four points:
\begin{itemize}
\item \textbf{Automated discovery of an exact interpretable form of Lagrangian}: The proposed approach discovers the exact interpretable form of Lagrangian of systems from data alone. Since the discovered Lagrangian is exact, therefore upon application of Noether's theorem and Legendre transformation, it provides the underlying conservation laws. From the discovery of Lagrangian to conservation laws, the proposed framework utilizes only a single observation of system responses.
\item \textbf{Automated discovery of governing equations}: The proposed framework constrains the discovery of Lagrangian using the principle of minimal action. As a result, the discovered Lagrangian automatically satisfies the Euler-Lagrangian equations. Thus, the governing equations of motion of underlying systems are simultaneously discovered without human intervention.
\item \textbf{Generalization to high-dimensional systems}: In the case of interaction between degrees-of-freedom in a high-dimensional system, the proposed approach learns the Lagrangian from the interaction of a relatively small subset of the system and can generalize the learned physics to the complete domain.
\item \textbf{Zero-shot generalization and perpetual predictive ability}: The discovered Lagrangian satisfy the exact physics of the underlying systems. Therefore, the discovered equations of motion share the same predictive ability as the actual system. Thus in unseen environmental conditions, the discovered physics can be used to predict an infinite period of duration without affecting accuracy.
\end{itemize}
The remainder of the paper is arranged as follows: in section \ref{sec:problem}, the problem statement is given. In section \ref{sec:methods}, the proposed data-driven framework for the discovery of the Lagrangian from data is briefly presented. In section \ref{sec:numerical}, numerical experiments are undertaken to showcase the novelty of the proposed data-driven framework. In section \ref{sec:conclusion}, the salient features of the proposed framework are revisited, and finally, the paper is concluded.
\section{Problem formulation}\label{sec:problem}
In this section, we formally define the problem statement of our proposed work.
Consider an $m$ degrees of freedom dynamical system with generalized coordinates $\{X_i; i=1, \ldots, m \}$, where the generalized coordinates refer to any set of independent coordinates. Further, we denote the kinetic and potential energy of this system by $T \in \mathbb{R}$ and $U \in \mathbb{R}$, respectively. The potential energy $U$ typically depends on the position of the system described by the generalized coordinates $\{X_i; i=1, \ldots, m \}$, whereas the kinetic energy $T$ can depend on both generalized displacement and velocity $\{\dot{X}_i; i=1, \ldots, m \}$. With this preliminary description, the scalar notion of kinetic energy $T$ and potential energy $U$ is expressed as $T \triangleq T(X_1, \ldots, X_m, \dot{X}_1, \ldots, \dot{X}_m)$, and $U \triangleq U(X_1, \ldots, X_m)$.
If a system is conservative, the differential $d(T+U)$ of the sum of kinetic energy $T$ and potential energy $U$ will be equal to zero, which is basically a statement of the principle of conservation of energy \cite{calkin1996lagrangian,brizard2014introduction}. When differentials of the sum of the kinetic energy $T$ and the potential energy $U$ over all the generalized coordinates are taken, we get the following representation of $T$ and $U$,
\begin{subequations}
\begin{equation}\label{eq:dT}
dT \triangleq \sum_{i=1}^m \frac{\partial}{\partial {X}_i} T\left(X_1, \ldots, X_m, \dot{X}_1, \ldots, \dot{X}_m\right) d {X}_i + \sum_{i=1}^m \frac{\partial}{\partial \dot{X}_i} T\left(X_1, \ldots, X_m, \dot{X}_1, \ldots, \dot{X}_m\right) d \dot{X}_i
\end{equation}
\begin{equation}\label{eq:dU}
dU \triangleq \sum_{i=1}^m \frac{\partial}{\partial X_i} U\left(X_1, X_2, \ldots, X_m\right) d X_i .
\end{equation}
\end{subequations}
In the above equations, the differentials of the kinetic energy $T$ and the potential energy $U$ depend on the perturbations $d \dot{X}_i$ and $d X_i$. The dependence on the perturbations $d X_i$ can be relaxed by writing the equation of kinetic energy in generalized coordinates.
\begin{equation}
T= \frac{1}{2} \sum_{i=1}^{n} \sum_{j=1}^{n} m_{ij} \dot{X}_i\dot{X}_j = \frac{1}{2} \sum_{i=1}^n \frac{\partial T}{\partial \dot{X}_i} \dot{X}_i,
\end{equation}
where $m_{ij} = \sum _k^n m_k (\partial r_k / \partial X_j) \cdot (\partial r_k / \partial X_j)$ is the coefficients of generalized mass matrix and $r_k \in \mathbb{R}^{n}$ is the position vector of each degree of freedom. Note that at the material level, the $n$-degrees of freedom system can be represented using an $n$-particle system. Applying the product rule in the above equation, one can get,
\begin{equation}\label{eq:product}
dT= \frac{1}{2}\sum_{i=1}^m d\left(\frac{\partial T}{\partial \dot{X}_i}\right) \dot{X}_i + \frac{1}{2}\sum_{i=1}^m \frac{\partial T}{\partial \dot{X}_i} d \dot{X}_i .
\end{equation}
Subtracting the above equation from Eq. \eqref{eq:dT} yields,
\begin{equation}\label{eq:dT_final}
d T=\sum_{i=1}^m \frac{d}{d t}\left(\frac{\partial T}{\partial \dot{X}_i}\right) d X_i - \sum_{i=1}^m \frac{\partial T}{\partial {X}_i} d {X}_i .
\end{equation}
From Eq. \eqref{eq:dT_final} and \eqref{eq:dU}, the differential $d(T+U)$ of the kinetic energy and potential energy can be obtained as follows,
\begin{equation}
d(T+U)=\sum_{i=1}^m\left[\frac{d}{d t}\left(\frac{\partial T}{\partial \dot{X}_i}\right) - \frac{\partial T}{\partial {X}_i} + \frac{\partial U}{\partial X_i}\right] d X_i .
\end{equation}
Since the differential $d(T+U)$ must be zero, the only way it is possible is if the sum inside the square bracket is zero, i.e.,
\begin{equation}
\frac{d}{d t}\left(\frac{\partial T}{\partial \dot{X}_i}\right) - \frac{\partial T}{\partial {X}_i} + \frac{\partial U}{\partial X_i}=0; \quad i=1,2, \ldots, m .
\end{equation}
We can further note that ${\partial U}/{\partial \dot{X}_i} =0$. Using these results, we can straightforwardly obtain Lagrange's equation as follows,
\begin{equation}\label{eq:lagrange_hom}
\frac{d}{d t}\left(\frac{\partial \mathcal{L}}{\partial \dot{X}_i}\right)-\frac{\partial \mathcal{L}}{\partial X_i} = 0, \quad i=1,2, \ldots, m ,
\end{equation}
where $\mathcal{L}({{X}_i}, \dot{X}_i ) \in \mathbb{R} \triangleq T({X}_i, \dot{X}_i) -U({X}_i)$ is the Lagrangian. Equation \eqref{eq:lagrange_hom} represents Lagrange's equation for a conservative system, i.e., systems with constant energy. For nonconservative systems, Lagrange's equation is generalized by including a constraining potential $V_i$ as follows,
\begin{equation}\label{eq:lagrange_nonhom}
\frac{d}{d t}\left(\frac{\partial \mathcal{L}}{\partial \dot{X}_i}\right)-\frac{\partial \mathcal{L}}{\partial X_i}=V_i, \quad i=1,2, \ldots, m .
\end{equation}
With this setup, given that we can obtain the measurements for system states $\mathbf{X} = [ {\bm{X}}, \dot{\bm{X}} ]$, we aim (i) to automate the discovery of the exact analytical form of the Lagrangian $\mathcal{L}({\bm{X}}, \dot{\bm{X}} )$ by constraining the Lagrangian to satisfy Eqs. \eqref{eq:lagrange_hom} and \eqref{eq:lagrange_nonhom}, (ii) to automate the discovery of the governing equations of motion using the discovered Lagrangian $\mathcal{L}({\bm{X}}, \dot{\bm{X}} )$, which will have perpetual prediction capability, and (iii) to automate the discovery of conservation laws using the principle of energy conservation on discovered Lagrangian $\mathcal{L}({\bm{X}}, \dot{\bm{X}} )$. To achieve tasks (i)--(iii), we restrict our access to a single trajectory of the system states ${\bm{X}} \in \mathbb{R}^{m}$ and $\dot{\bm{X}} \in \mathbb{R}^{m}$ only.
\section{Learning of Lagrangian of physical systems from state measurement}\label{sec:methods}
The expression of the Lagrangian defined in the previous section entirely depends on the form of internal and external energy potentials. The typical forms of these potentials are sparse in
nature, i.e., the resulting analytical expression of the Lagrangian will contain only a few most relevant physical terms. We embed this information in the proposed framework and leverage the concept of sparse regression \cite{brunton2016discovering,boninsegna2018sparse} to automate the discovery of the Lagrangian from field observation data.
Towards discovering the Lagrangian from data, we first gather the time history of displacement and velocity states for $t \in [0,T]$ at some discrete time step $\Delta t$, where $T$ is the total duration of the measurement period. Note that the states can also be angular displacement and angular velocities.
Assuming that the filtration of states $\mathcal{F}^{X}$ contains $N$-time steps, and there are $m$-system states, we construct a matrix structure of the measurements as follows,
\begin{equation}\label{eq:measurement}
\mathbf{X} = \left[ {\begin{array}{*{20}{c}}
{X_{1_1}} & {X_{2_1}} & \cdots & {X_{m_1}}\\
{X_{1_2}} & {X_{2_2}} & \cdots & {X_{m_2}}\\
\vdots & \vdots & \ddots & \vdots \\
{X_{1_N}} & {X_{2_N}} & \cdots & {X_{m_N}}\\
\end{array}} \right]; \quad
\dot{\mathbf{X}} = \left[ {\begin{array}{*{20}{c}}
{\dot{X}_{1_1}} & {\dot{X}_{2_1}} & \cdots & {\dot{X}_{m_1}}\\
{\dot{X}_{1_2}} & {\dot{X}_{2_2}} & \cdots & {\dot{X}_{m_2}}\\
\vdots & \vdots & \ddots & \vdots \\
{\dot{X}_{1_N}} & {\dot{X}_{2_N}} & \cdots & {\dot{X}_{m_N}}\\
\end{array}} \right].
\end{equation}
Next, we assume that the Lagrangian $\mathcal{L}({\mathbf{X}}, \dot{\mathbf{X}} )$ can be expressed as a weighted linear superposition of certain candidate basis functions \cite{brunton2016discovering,nayek2021spike}. Since the choice of candidate functions can be arbitrary, we construct a symbolic dictionary $\mathbf{D}(\mathbf{X}, \dot{\mathbf{X}})$ of all the possible choices of energy potentials. The possible choices for candidate potential functions can be polynomials of states, harmonics of states, differences of states, polynomials of differences of states, harmonics of differences of states, etc. The functions of $\mathbf{D}(\mathbf{X}, \dot{\mathbf{X}})$ are mapping of each column of $\mathbf{X}$ and $\dot{\mathbf{X}}$. A demonstration of the dictionary employed in this work is given below,
\begin{equation}\label{eq:library}
\mathbf{D}(\mathbf{X}, \dot{\mathbf{X}}) = \left[ {\begin{array}{*{20}{c}}
{\bf{1}} & {{{\rm P}^{\rho}} \left({\mathbf{X}}, \dot{\mathbf{X}}\right)} & \cdots & {\mathop{\rm sin}\left({\mathbf{X}}, \dot{\mathbf{X}}\right)} & \cdots & {{{\rm P}^{\rho}}\left(\left|{\mathbf{X}}- \dot{\mathbf{X}} \right| \right)} & \cdots & {\mathop{\rm sin}\left(\left|{\mathbf{X}}- \dot{\mathbf{X}} \right| \right)} & \cdots
\end{array}} \right],
\end{equation}
where $\rho$ denotes the degree of polynomials. We then evaluate the above symbolic dictionary on the state measurements in \eqref{eq:measurement}, where each column of the $\mathbf{D}(\mathbf{X}, \dot{\mathbf{X}})$ represents a possible candidate to be included in the final model of the $\mathcal{L}({\mathbf{X}}, \dot{\mathbf{X}} )$. For upcoming discussions, we assume that there are a total $K$-basis functions and represent the dictionary functions by $\ell_k; k=1,\ldots, K$. Using the above description, we express the Lagrangian ($\mathcal{L}$) for $i^{th}$-DOF as,
\begin{equation}\label{eq:lagrange_lib}
\mathcal{L}({\bm{X}_i}, \dot{\bm{X}}_i ) = \theta_1 \ell_1({\bm{X}_i}, \dot{\bm{X}}_i ) + \theta_2 \ell_2({\bm{X}_i}, \dot{\bm{X}}_i ) + \ldots + \theta_K \ell_K({\bm{X}_i}, \dot{\bm{X}}_i ) ,
\end{equation}
where $\{\theta_{i_k} \in \bm{\theta}_i;k=1,\ldots,K\}$ are the parameters of the Lagrangian, possibly denoting the coefficients of the energy potentials. In a compact matrix, form the above equation can be written as, $\mathcal{L}({\bm{X}_i}, \dot{\bm{X}}_i ) = \mathbf{D}({\bm{X}_i}, \dot{\bm{X}}_i ) \bm{\theta}_i$.
In the remainder of the discussion, we drop the arguments of the $\mathcal{L}(\cdot, \cdot)$ and $\mathbf{D}(\cdot, \cdot)$. To discover the Lagrangian that provides the stationary action, we constrain the Lagrangian to satisfy \eqref{eq:lagrange_hom} and \eqref{eq:lagrange_nonhom}, whichever is applicable. Since the following procedure is indistinguishable for both the conservative and non-conservative systems, we demonstrate the proposed work using the Lagrangian equation for a conservative system. Thus, we substitute \eqref{eq:lagrange_lib} in to \eqref{eq:lagrange_hom}, and obtain,
\begin{equation}\label{eq:lagrange_motion}
\frac{d}{d t}\left(\frac{\partial \mathbf{D}}{\partial \dot{X}_i}\right) {\bm \theta}_i -\frac{\partial \mathbf{D}}{\partial X_i}{\bm \theta}_i = \bm{0}, \quad i=1,2, \ldots, m .
\end{equation}
The above equation can be recast in the form of a linear regression problem, which is,
\begin{equation}\label{eq:regression}
\bm{Y}_i = \hat{\mathbf{D}}\bm{\theta}_i + {\bm{\epsilon}}, \quad i=1,2, \ldots, m ,
\end{equation}
where $\bm{Y}_i \in \mathbb{R}^{N}$ is the zero target vector, $\hat{\mathbf{D}} \in \mathbb{R}^{N \times K}$ is the resulting dictionary matrix when the Euler-Lagrangian operator is evaluated on $\mathbf{D} \in \mathbb{R}^{N \times K}$, and $\bm{\epsilon} \in \mathbb{R}^{N}$ is the model miss-match error. The error $\bm{\epsilon}$ ideally should vanish if the model constructed from the dictionary matches the actual model. Due to the presence of noise in the measurements, the error will not be zero. We seek to find a sparse solution for $\bm{\theta}_i$ by minimizing the error ${\bm{\epsilon}}$. However, when solved, the \eqref{eq:regression} yields a trivial solution, i.e., $\{\theta_{i_j}, j=1,\ldots,K \}$=0.
\begin{figure}[!ht]
\centering
\includegraphics[width=\textwidth]{Methodology_Lagrange.pdf}
\caption{Schematic of the proposed Lagrange discovery algorithm, demonstrated on a triatomic molecule. State observation data (displacement and velocity) are collected from the system. First, the Lagrange is expressed in terms of a dictionary of nonlinear functions of the states. Then the Euler-Lagrange equation is applied to the Library. Next, a target vector is constructed from the column corresponding to the basis $\dot{X}^2$ from the Euler-Lagrange dictionary. A sparse regression is performed between the Euler-Lagrange dictionary and the target vector. Finally, the Lagrangian is discovered by augmenting back the basis $\dot{X}^2$ to the Euler-Lagrange dictionary. The discovered Lagrangian facilitates the direct discovery of Hamiltonian and equations of motion. It also has the potential to generalize to high-dimensional systems, allowing us to learn the desired Lagrangian from a small subset of data.}
\label{fig:method}
\end{figure}
To obtain the non-trivial solution for the model parameters $\bm{\theta}$, we model the label/target vector of the regression as the vector of $\dot{X}^2$. In particular, we identify the column index of the basis function $\dot{\bm{X}}_i^2$ from the library $\mathbf{D}$ and set the label $\bm{Y}_i$ as the corresponding column from the differentiated library $\hat{\mathbf{D}}$. This results in the following regression equation,
\begin{equation}\label{eq:motion_opt2}
\hat{\bm{D}}_{\dot{X}_i^2} = \hat{\mathbf{D}}_{(-\dot{X}_i^2)} {\bm{\theta}_i} + {\bm{\epsilon}} , \quad i=1,2, \ldots, m ,
\end{equation}
where $\bm{Y}_i = \hat{\bm{D}}_{\dot{X}_i^2}$ and $\hat{\mathbf{D}}_{(-\dot{X}_i^2)} \in \mathbb{R}^{N \times (K-1)}$ is the $\dot{\bm{X}}_i^2$ removed library. In this way, the proposed candidate library can incorporate all the energy potentials, including kinetic energy functions that are dependent on both displacement and velocities. The above multivariate regression equation can be represented as follows,
\begin{equation}
\left[ {\begin{array}{*{20}{c}}
\vert & \vert & & \vert \\
\hat{\bm{D}}_{\dot{X}_1^2}& \hat{\bm{D}}_{\dot{X}_2^2}& \ldots &\hat{\bm{D}}_{\dot{X}_m^2}\\
\vert & \vert & & \vert
\end{array}} \right] = \underbrace {\left[ {\begin{array}{*{20}{c}}
1 &{{\hat{\ell} _1}({\bm{X}_{1}}) }&{{\hat{\ell} _2}({\dot{\bm{X}}_{1}})}& \cdots &{{\hat{\ell} _K}({\bm{X}_{1}}, {\dot{\bm{X}}_{1}})}\\
1 &{{\hat{\ell} _1}({\bm{X}_{2}}) }&{{\hat{\ell} _2}({\dot{\bm{X_{2}}}})}& \cdots &{{\hat{\ell} _K}({\bm{X}_{2}}, {\dot{\bm{X}}_{2}})}\\
\vdots & \vdots & \ddots & \vdots \\
1 &{{\hat{\ell} _1}({\bm{X}_{N}}) }&{{\hat{\ell} _2}({\dot{\bm{X_{N}}}})}& \cdots &{{\hat{\ell} _K}({\bm{X}_{N}}, {\dot{\bm{X}}_{N}})}
\end{array}} \right]}_{{\bf{L}} \in {\mathbb{R}^{N \times K}}}\underbrace {\left[ {\begin{array}{*{20}{c}}
{{\theta _{1_1}}}&{{\theta _{2_1}}}& \cdots &{{\theta _{m_1}}}\\
{{\theta _{1_2}}}&{{\theta _{2_2}}}& \cdots &{{\theta _{m_2}}}\\
\vdots & \vdots & \ddots & \vdots \\
{{\theta _{1_k}}}&{{\theta _{2_k}}}& \cdots &{{\theta _{m_k}}}
\end{array}} \right]}_{{\bf{\theta }} \in {\mathbb{R}^{K \times m}}}.
\end{equation}
Here,
\begin{equation}
\hat{\ell}(\cdot) = \left[ \frac{d}{d t}\left( \frac{\partial }{\partial \dot{X}_i} \right) - \frac{\partial }{\partial {X}_i} \right] \ell (\cdot) .
\end{equation}
The degree of accuracy of the discovered Lagrangian entirely depends on the choice and versatility of the dictionary functions. In the absence of prior information, the dictionary may contain a large number of candidate functions. However, from our knowledge, we know for sure that only a few of the candidate potential functions will be active in the final model of Lagrangian potential. This is to say that most of the entries $\theta_k \in \bm{\theta}_i$ will take a zero value. To find the sparse solution vector $\{\theta_{i_1}, \ldots, \theta_{i_K} \}$, we employ the sequential threshold least-square regression proposed in \cite{brunton2016discovering}.
The sparse algorithm computes a least-squares solution for $\bm{\theta}_i$ and then thresholds solution vector using a sparsity constant $\lambda$. The degree of sparsity is controlled by the constant $\lambda$. This procedure is repeated for several iterations on the remaining non-zero entries of $\bm{\theta}_i$, where the cardinality of non-zero coefficients decreases with each iteration. The procedure is stopped when the non-zero coefficients converge. At each iteration, the sparsity is achieved by penalizing the solution with its $L^1$-norm as follows,
\begin{equation}\label{eq:sparse_reg}
{\bm{\theta}}_i = \underset{{\bm{\theta}}_i^{*}}{\arg \mathop{\rm min}} \| \hat{\mathbf{D}}_{(-\dot{X}_i^2)} {\bm{\theta}_i^{*}} - \ddot{\bm{X}}_i \|_2 + \lambda \|{\bm{\theta}}_i^{*} \|_1, \quad i=1,2, \ldots, m ,
\end{equation}
where $\|\cdot \|_1$ and $\|\cdot \|_2$ denote the $L^1$ and $L^2$ norms, respectively. The superscript denotes the solution vector from the previous iteration. Note that it requires a $m$-distinct search to obtain the sparse matrix $\boldsymbol{\theta} = [\bm{\theta}_1, \ldots, \bm{\theta}_m]$, where each column $\bm{\theta}_i$ represents the sparse vector associated with $i^{th}$-DOF. The above sequential threshold least-square regression is a modification of the Least Absolute Shrinkage and Selection Operator (LASSO) \cite{hastie2009elements}. The algorithm is useful for large-scale problems as compared to brute-force combinational alternatives. More details are available in \cite{brunton2016discovering}. It is simple to use and, when used, converges to the sparse solution within a few iterations. More use of the sequential threshold sparse algorithm can be found in biology \cite{mangan2016inferring}, chemistry \cite{hoffmann2019reactive}, fluid mechanics \cite{loiseau2018constrained}, system identification \cite{li2019discovering}, etc.
We recall that the dictionary ${\mathbf{D}}_{(-\dot{X}_i^2)} \in \mathbb{R}^{N \times (K-1)}$ contains the symbolic functions of potential candidates of the Lagrangian. However, note that the kinetic energy function $\dot{X}_i^2$ is removed from the ${\mathbf{D}} \in \mathbb{R}^{N \times K}$ to obtain the non-trivial solution. Once the coefficient vector $\bm{\theta}_i$ is determined, the exact analytical form of the Lagrangian $\mathcal{L}$ can be obtained from the symbolic library as,
\begin{equation}\label{eq:lagrangian}
\mathcal{L} \left(\bm{X}_i, \dot{\bm{X}}_i \right) = {\mathbf{D}}_{(-\dot{X}_i^2)} \bm{\theta}_i + \theta_{\dot{X}_i^2} {\dot{X}_i^2},
\end{equation}
where $\theta_{\dot{X}_i^2}$ = 1 and the addition of the second term on the right-hand side is to compensate for the removal of kinetic energy function $\dot{X}_i^2$ from the original dictionary $\mathbf{D}$. The Lagrangian of the $n$-DOF system is then found by summing all the Lagrangians of each element, which is essentially the difference between the total kinetic energy and the total potential energy. For the implementation, follow the Algorithm \ref{algo_wno}. Once the Lagrangian is discovered, the conservation laws can be directly derived using Noether's theorem and Hamiltonian principles.
An additional feature of the proposed framework (see \eqref{eq:motion_opt2}) directly provides us with the governing motion equation in addition to the Lagrangian. In recent years, an increase in research has been seen on the distillation of the governing physics from data. Since the proposed framework provides a unified framework for discovering both the Lagrangian and governing equations of motion, it may cater to the needs of the discovery of the physics of data. In the results section, we will demonstrate the robustness and application of the proposed framework.
\begin{algorithm}[ht!]
\caption{Algorithm for discovering Lagrangian from data}\label{algo_wno}
\begin{algorithmic}[1]
\Require{Observations $\{ \mathbf{X} \in \mathbb{R}^{N \times m}, \dot{\mathbf{X}} \in \mathbb{R}^{N \times m} \}$, and hyperparameter $\lambda$.}
\State{Construct a symbolic dictionary $\mathbf{D}(\cdot, \cdot)$.}\Comment{Eq. \eqref{eq:library}}
\State{Evaluate the dictionary over states $\mathbf{D}(\mathbf{X}, \dot{\mathbf{X}})$.}
\For{$i$ in $m$}
\State{Compute $\partial \mathbf{D}/ \partial X_i$.}
\State{Compute $(d/dt)(\partial \mathbf{D}/ \partial \dot{X}_i)$.}
\State{Difference $\hat{D} = (d/dt)(\partial \mathbf{D}/ \partial \dot{X}_i - \partial \mathbf{D}/ \partial X_i)$.}
\State{Locate the column with $\dot{\bm{X}}^2_i$ from the dictionary $\mathbf{D}(\bm{X}_i, \dot{\bm{X}}_i)$.}
\State{Construct the target vector with $ \bm{Y}_i = \hat{\bm{D}}_{\dot{\bm{X}}^2_i}$.} \Comment{Eq. \eqref{eq:motion_opt2}}
\State{Perform a sequentially threshold least-squares between $\bm{Y}_i$ and $\hat{\mathbf{D}}_{(-\dot{X}_i^2)}$.} \Comment{Eq. \eqref{eq:sparse_reg}}
\State{Obtain the Lagrangian $\mathcal{L}(\bm{X}_i, \dot{\bm{X}}_i )$.} \Comment{Eq. \eqref{eq:lagrangian}}
\EndFor
\Ensure{Obtain the total Lagrangian $\mathcal{L}(\mathbf{X}, \dot{\mathbf{X}}) = \sum_i \mathcal{L}(\bm{X}_i, \dot{\bm{X}}_i ); i=1,\ldots,m$.}
\end{algorithmic}
\end{algorithm}
\noindent \textbf{Remark 1} Often, the physical systems of interest are mathematically represented using high-dimensional ordinary (ODE) and partial differential equations (PDE). In the case of ODEs, the data are collected at each DOFs, and in the case of PDEs, the data are observed at discrete spatial locations. In both cases, the proposed framework provides a scalar approach, where the Lagrangian is discovered at each discrete location and then summed to obtain the final Lagrangian density of the system.
\noindent \textbf{Remark 2} Independent of numerical discretization or experimental measurements, if data are collected on a large number of discrete locations (DOFs for the system of ODE and spatial grid of PDEs), then the state dimension-$m$ may be prohibitively large. For example, one can think of the number of molecules in the atomic chain and spatial variables in fluid simulation. Since the cardinality of the dictionary $\mathbf{D}$ increases exponentially with an increase in state dimension-$m$, the proposed framework may become very inefficient. Fortunately, the proposed framework can be applied to a subset of the state dimension to obtain the basic structure of the Lagrangian, which can be generalized to $m$-dimension to obtain the system's Lagrangian density. In the results section, we will provide evidence using a problem on the discovery of Lagrangian for an atomic chain.
\section{Results}\label{sec:numerical}
We showcase the performance of the proposed framework by discovering the Lagrangian of several benchmark problems. Examples include simple linear oscillators, atomic chains, and the movement of transversal waves in solids. We assume that we have access to only a single observation of system states. For the discovery of the Lagrangian of the forced oscillator, it is assumed that both input-output measurements are available. Here, input means the excitation, and output means the state observations. The parameters used during the simulation are provided in Table \ref{table_param}. In all the examples, the measurements are arranged in a matrix form (i.e., $\mathbf{X}$, $\dot{\mathbf{X}}$) where the row represents time-snapshots of the dynamics, and the columns represent the degrees of freedom. Then each column of the dictionary (see \eqref{eq:library}) is evaluated on the measurement matrices. Reiterating, we want to discover a sparse representation of the Lagrangian. We utilize the sparse regression in \eqref{eq:sparse_reg} to discover the active basis function from the dictionary. Later, we employ the Hamiltonian principle to discover the underlying conservation laws from the discovered Lagrangian. For each example, we further compare the discovered governing equations with their actual counterparts. Towards the end of this section, we explore additional features of the proposed framework, such as zero-shot generalization, perpetual predictive capability, and generalization to high-dimensional systems.
\begin{table}[ht]
\centering
\caption{Simulation parameters of the example problems.}
\label{table_param}
\begin{threeparttable}
\begin{tabular}{p{8cm}l}
\toprule
\textbf{Systems} & \textbf{Parameters} \\
\midrule
Harmonic oscillator$^{ (\ref{example_harmonic})}$ & $m$=10kg, $k$=5000N/m$^2$, $A$=10 \\
Pendulum$^{ (\ref{example_3})}$ & $m$=1kg, $l$=2m, $g$=9.81m/s$^2$ \\
Undamped MDOF vibration$^{ (\ref{example_4})}$ & $m_i$ = 10, $k_i$ = 5000; $i=1,2,3$ \\
Vibration of a Linear Triatomic Molecule$^{ (\ref{example_5})}$ & $m_{1,2}$=1AMU, $m_2$=2AMU$^{\dagger}$, $k_i$=1870N/m$^2$; $i=1,2,3$ \\
Elastic Transversal Waves in a Solid$^{ (\ref{example_6})}$ & $c$=25 ($\rho=960kg/m^3$, $\delta$=0.01, $\mu$=4GPa) \\
Flexion Vibration of a Blade$^{ (\ref{example_7})}$ & $c$=1 ($\rho$=1, $E$=1, $S$=1, $I$=1, $\delta$=0.01) \\
\midrule
\end{tabular}
\begin{tablenotes}
\item \textbf{Note}: $\dagger$ AMU = atomic mass unit. For all the demonstrations in this work, a single set of system states are simulated using the fourth-order Runge-Kutta scheme. The noise in the measurements is modeled as $N$-dimensional sequence of zero-mean Gaussian white noise with a standard deviation equal to 5\% of the standard deviation of the simulated quantities.
\end{tablenotes}
\end{threeparttable}
\end{table}
\subsection{Harmonic oscillator}\label{example_harmonic}
As a first example, we consider the undamped vibration of a mass attached to a spring. We consider both the free and forced vibration of the harmonic oscillator. The corresponding governing equations for the free and forced vibration cases are as follows,
\begin{subequations}
\begin{equation}\label{eq:free}
m\ddot{X}(t) + kX(t) = 0; \quad X(t=0)=X_0, \quad t \in [0,T]
\end{equation}
\begin{equation}\label{eq:forced}
m\ddot{X}(t) + kX(t) = F(t); \quad X(t=0)=X_0, \; F(t)>0, \quad t \in [0,T]
\end{equation}
\end{subequations}
where $m$ and $k$ are the mass and associated spring stiffness, respectively. For the forced vibration equation, the excitation is modeled as $F(t) = A{\rm{sin}}(2 \pi t)$. The associated Lagrangian for the free and forced vibration cases are $\mathcal{L}$=$\frac{1}{2}m\dot{X}^2 - \frac{1}{2}kX^2$, and $\mathcal{L}$=$\frac{1}{2}m\dot{X}^2 - \frac{1}{2}kX^2 + XF(t)$, respectively. An initial condition of $\{X, \dot{X}\}_{(t=0)}$=\{1,0\} is used to simulate the data. The sampling frequency and total duration of time $T$ are taken as \{1000Hz, 1s\} for \eqref{eq:free} and \{2000Hz, 2s\} for \eqref{eq:forced}. We construct the differentiated library $\hat{\mathbf{D}}$ and then obtain the regression equation in \eqref{eq:motion_opt2} by constructing the target vector as the column of $\dot{X}^2$ from $\hat{\mathbf{D}}$. Finally, \eqref{eq:lagrangian} is used to obtain the underlying Lagrangian in mass-normalized form.
\textbf{Results}: The discovery results are summarized in Fig. \ref{fig:spy_linear} and \ref{fig:spy_forced}. As depicted in Fig. \ref{fig:spy_linear} and \ref{fig:spy_forced}, it can be concluded that the proposed framework is able to distill the correct basis functions for the harmonic oscillator. The identified parameter of the potential energy is given in Table \ref{tab:ident_param}, from which we can also ascertain that the proposed framework can discover the near-exact system parameters.
\begin{table}[ht]
\centering
\caption{Identification of the parameters of the system}
\begin{tabular}{lllll}
\toprule
& Parameters & Actual values & Identified values & Relative Error (\%) \\
\midrule
Ex. (\ref{example_harmonic}\eqref{eq:free}) & k/m & 500 & 500.14 & 0.028 \\
Ex. (\ref{example_harmonic}\eqref{eq:forced}) & \{k/m, F/m\} & \{500,1\} & \{499.99, 1.01\} & \{0.198, 1\} \\
Ex. (\ref{example_3}) & g/l & 9.81 & 9.82 & 0.101 \\
Ex. (\ref{example_4}) & $k_i$/$m_i$ & 500 & 499.87 & 0.026 \\
Ex. (\ref{example_5}) & $k_i$/$m_i$ & 1870 & 1870.67 & 0.036 \\
Ex. (\ref{example_6}) & $c$ & 25 & 24.98 & 0.08 \\
Ex. (\ref{example_7}) & $c$ & 1$\times 10^{8}$ & 1.018$\times 10^{8}$ & 1.81 \\
\midrule
\end{tabular}
\label{tab:ident_param}
\end{table}
\begin{table}[ht]
\centering
\caption{Lagrangian of the undertaken examples.}
\label{table_lagrange}
\begin{tabular}{p{2.5cm}p{4cm}l}
\hline
\textbf{Systems} & \textbf{Motion equation} & \textbf{Lagrangian} \\
\hline
Ex. (\ref{example_harmonic}\eqref{eq:free}) & $m\ddot{X}(t) + kX(t) = 0$ & $\mathcal{L}$=$\frac{1}{2}m\dot{X}^2 - \frac{1}{2}kX^2$ \\
Ex. (\ref{example_harmonic}\eqref{eq:forced}) & $m\ddot{X}(t) + kX(t) = F(t)$ & $\mathcal{L}$=$\frac{1}{2}m\dot{X}^2 - \frac{1}{2}kX^2 + XF(t)$ \\
Ex. (\ref{example_3}) & $m l^2 \ddot{\theta}(t) + mgl {\rm{sin}} \theta(t) = 0$ & $\mathcal{L}$=$\frac{1}{2}m{l^2}\dot{\theta}^2 - mgl{\rm{cos}}\theta$ \\
Ex. (\ref{example_4}) & $\mathbf{M}\ddot{\bm{X}}(t) + \mathbf{K} \bm{X}(t) = 0$ & $\mathcal{L}$=$\frac{1}{2} \sum_{k=1}^{3} m_k \dot{X}_k^2 - \left( \frac{1}{2}k_1 X_1^2 + \frac{1}{2}k_2(X_2-X_1)^2 + \frac{1}{2}k_3(X_3-X_2)^2 \right)$ \\
Ex. (\ref{example_5}) & $\mathbf{M}\ddot{\bm{X}}(t) + \mathbf{K} \bm{X}(t) = 0$ & $\mathcal{L}$=$\frac{1}{2} \sum_{k=1}^{3} m_k \dot{X}_k^2 - \left( \frac{1}{2}k_2(X_2-X_1)^2 + \frac{1}{2}k_3(X_3-X_2)^2 \right)$ \\
Ex. (\ref{example_6}) & ${\partial^2_t u(X,t)} = c^2 {\partial^2_x u(X,t)}$ & $\mathcal{L}$=$\frac{1}{2}\sum_{i} \rho S \delta \dot{u}_i^2 - \sum_i {\mu S}{\delta}^{-1} \left(u_{i+1}-u_{i} \right)^2$ \\
Ex. (\ref{example_7}) & ${\partial^2_t u(X,t)} = c^2 {\partial^4_x u(X,t)}$ & $\mathcal{L}$=$\frac{1}{2} \mu \delta \sum_{i} \dot{u}_i^2 - {EI}({2 \delta^3})^{-1} \sum_i \left(u_{i+1}-2u_{i}+u_{i-1} \right)^2$ \\
\hline
\end{tabular}
\end{table}
\subsection{Simple pendulum}\label{example_3}
Next, we consider the motion of a simple pendulum with a mass $m$ under the action of gravity. The purpose of this example is to demonstrate the performance of the proposed framework for the discovery of the Lagrangian from angular measurements. The governing equation of motion of a simple pendulum is given as follows,
\begin{equation}
m l^2 \ddot{\theta}(t) + mgl {\rm{sin}} \theta(t) = 0; \quad \theta(t=0)=\theta_0, \quad t \in [0,T]
\end{equation}
where $l$ is the length of the suspension. For the simulation of the data, we use a sampling frequency of 1000Hz and a total duration of $T$=10s. The initial angular displacement and velocity are considered as $\{\theta, \dot{\theta}\}_{(t=0)}$=\{0.5,0\}. The associated Lagrangian is $\mathcal{L}$=$\frac{1}{2}m{l^2}\dot{\theta}^2 - mgl{\rm{cos}}\theta$. Here again, we have used the column $\dot{\theta}^2$ from the library $\hat{\mathbf{D}}$ as the target vector for the regression problem in \eqref{eq:motion_opt2} to discover the underlying Lagrangian successfully.
\textbf{Results}: The results are summarized in Fig. \ref{fig:spy_pendulam}. From the figure, we see that the proposed framework has correctly identified the kinetic energy function $\dot{\theta}^2$ and the harmonic function $cos(\cdot)$. The associated parameters are provided in Table \ref{tab:ident_param}. Note that the parameters are discovered in their mass-normalized form.
\subsection{Undamped MDOF vibration}\label{example_4}
We consider an oscillator with three degrees of freedom in this example to demonstrate the applicability of the proposed framework for systems represented using a system of ODEs. Let the mass and stiffness of the three DOF systems be denoted as $m_i$ and $k_i$ for $i=1,\ldots,3$. The equations of motion for this 3DOF can be derived as follows,
\begin{equation}\label{eq:mdof}
\mathbf{M} \ddot{\bm{X}}(t) + \mathbf{K} \bm{X}(t) = 0
\end{equation}
where
\begin{equation}
\mathbf{M} = \left[ { \begin{array}{ccc}
m_1 & 0 & 0 \\
0 & m_2 & 0 \\
0 & 0 & m_3
\end{array} } \right], \; \text{and,} \;
\mathbf{K} = \left[ { \begin{array}{ccc}
k_1+k_2 & -k_2 & 0 \\
-k_2 & k_2+k_3 & -k_3 \\
0 & -k_3 & k_3
\end{array} } \right]
\end{equation}
Similar to previous examples, we aim to discover the mass-normalized Lagrangian for this example. However, instead of directly discovering the Lagrangian of the whole system, we discover the Lagrangian of each DOF and then sum over all the DOF to obtain the Lagrangian of the complete system. For data simulation, we use the initial conditions $\bm{X} = \{1,0,0,0,0,0\}$. A sampling frequency of 1000Hz and $T$=1s is used. The actual Lagrangian for this systems is $\mathcal{L}$=$\frac{1}{2} \sum_{k=1}^{3} m_k \dot{X}_k^2 - \left( \frac{1}{2}k_1 X_1^2 + \frac{1}{2}k_2(X_2-X_1)^2 + \frac{1}{2}k_3(X_3-X_2)^2 \right)$. To discover the Lagrangian of each DOF, we use a similar procedure as mentioned in previous examples.
\textbf{Results}: The results are summarized in Fig. \ref{fig:spy_3dof}. In Fig. \ref{fig:spy_3dof}, the active dictionary functions for each DOF are portrayed. A value of 1 (black color) means the dictionary function is active, and a value of 0 (white color) means the dictionary function is not active. The true Lagrangian for the 3DOF system is discovered by a scalar approach, where Lagrangian for each DOF is discovered and then summed to obtain the system's Lagrangian. In the first DOF, the bases $X_1^2$ and $(X_2-X_1)^2$, for the second DOF, the bases $(X_2-X_1)^2$ and $(X_3-X_2)^2$, and for the third DOF the basis $(X_3-X_2)^2$ are found to active. When the Lagrangian obtained from each DOFs is summed, we obtain the actual Lagrangian for the system.
\begin{figure}[th!]
\centering
\begin{subfigure}[b]{0.75\textwidth}
\centering
\includegraphics[width=\textwidth]{Spy_linear.pdf}
\caption{Harmonic oscillator}
\label{fig:spy_linear}
\end{subfigure}
\begin{subfigure}[b]{0.75\textwidth}
\centering
\includegraphics[width=\textwidth]{Spy_force.pdf}
\caption{Forced oscillator}
\label{fig:spy_forced}
\end{subfigure}
\begin{subfigure}[b]{0.75\textwidth}
\centering
\includegraphics[width=\textwidth]{Spy_pendulum.pdf}
\caption{Pendulum}
\label{fig:spy_pendulam}
\end{subfigure}
\begin{subfigure}[b]{0.4\textwidth}
\centering
\includegraphics[width=\textwidth]{Spy_3DOF.pdf}
\caption{3DOF dynamical system}
\label{fig:spy_3dof}
\end{subfigure}
\begin{subfigure}[b]{0.4\textwidth}
\centering
\includegraphics[width=\textwidth]{Spy_atom.pdf}
\caption{Triatomic molecular chain}
\label{fig:spy_atom}
\end{subfigure}
\caption{\textbf{Identification of the active basis functions from the library}. The identified basis functions are shown. (a) Harmonic oscillator: the potential and the kinetic energy basis functions $X^2$ and $\dot{X}^2$ are found to be active from $\mathbf{D}\in \mathbb{R}^{25}$. (b) Forced oscillator: the potential, the kinetic and forced potential functions $X^2$ and $\dot{X}^2$ and $XF(t)$ are found to be active $\mathbf{D}\in \mathbb{R}^{26}$. (c) Pendulum: the Lagrangian bases $\dot{\theta}^2$ and $\cos(X)$ is found to be active $\mathbf{D}\in \mathbb{R}^{25}$. (d) 3DOF dynamical system: the library has $\mathbf{D}\in \mathbb{R}^{52}$ 52 basis functions. For the first DOF, the bases $X_1^2$, $\dot{X}_1^2$, and $(X_2-X_1)^2$; for the second DOF, the bases $\dot{X}_2^2$, $(X_2-X_1)^2$, and $(X_3-X_2)^2$, and for the third DOF the bases $\dot{X}_3^2$ and $(X_3-X_2)^2$ are identified to be active. (e) Triatomic molecular chain: for the first DOF, the basis functions $\dot{X}_1^2$ and $(X_2-X_1)^2$, for the second DOF, the basis functions $\dot{X}_2^2$, $(X_2-X_1)^2$ and $(X_3-X_2)^2$, and for the third DOF, the bases $\dot{X}_3^2$ and $(X_3-X_2)^2$ are active from $\mathbf{D}\in \mathbb{R}^{52}$.}
\label{fig:spy_ode}
\end{figure}
\subsection{Vibration of a Triatomic Molecule}\label{example_5}
In this example, we are interested in learning the Lagrangian associated with longitudinal vibrations of a triatomic molecule. The molecule is composed of two different types of atoms, disposed of in an alternate way. We employ a simple linear and symmetric model for the triatomic chain with respective point-like masses $m-\tilde{m}-m$, where $\tilde{m}$ denotes the mass of the heavy atom and $m$ denotes the mass of light ones. The mass of the light atom is expressed in terms of the heavy atom as $\tilde{m} = rm$, with $r<1$. The attractive forces between these masses are modeled by two identical springs of constant $k$. We further assume that the deviation from the equilibrium position is small; thus, the harmonic approximation remains valid during the interaction. The interaction between the atoms is governed by \eqref{eq:mdof}, where
\begin{equation}
\mathbf{M} = m\left[ { \begin{array}{ccc}
1 & 0 & 0 \\
0 & r & 0 \\
0 & 0 & 1
\end{array} } \right], \; \text{and,} \;
\mathbf{K} = k\left[ { \begin{array}{ccc}
1 & -2 & 0 \\
2 & 2 & -3 \\
0 & -2 & 3
\end{array} } \right]
\end{equation}
where $r=M/m$. The data are obtained for $T$=1s using a sampling rate 1000Hz. An initial condition of $\bm{X}=[1,0,0,0,0,0]$ is used. The parameters for the triatomic chain are given in Table \ref{table_param}. Similar to the previous MDOF example, we aim to discover the Lagrangian for the triatomic chain by discovering the individual Lagrangian of each molecule and then summing up them. For each molecule, we use the procedure described in \eqref{eq:motion_opt2} and \eqref{eq:lagrangian}. The actual Lagrangian of the triatomic molecule is given as $\mathcal{L}$=$\frac{1}{2} \left( \sum_{k=1}^{2} m_k \dot{X}_k^2 + \tilde{m} \dot{X}_{\tilde{m}}^3\right) - \left( \frac{1}{2}k_2(X_2-X_1)^2 + \frac{1}{2}k_3(X_3-X_2)^2 \right)$.
\textbf{Results}: The results ate summarized in Fig. \ref{fig:spy_atom}. In the figure, we see that the discovered Lagrangian for the first DOF is a function of the basis $(X_2-X_1)^2$. For the second DOF, the bases are $(X_2-X_1)^2$ and $(X_3-X_2)^2$, and for the third DOF, the basis is $(X_3-X_2)^2$. By performing a weighted sum (the parameters are given in Table \ref{tab:ident_param}) of the basis functions, we eventually obtain the actual Lagrangian of the triatomic molecule.
\begin{figure}[ht!]
\centering
\begin{subfigure}[b]{0.4\textwidth}
\centering
\includegraphics[width=\textwidth]{Spy_string.pdf}
\caption{Elastic Transversal Waves in a Solid}
\label{fig:spy_string}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{Spy_beam.pdf}
\caption{Flexion Vibration of a Blade}
\label{fig:spy_beam}
\end{subfigure}
\caption{\textbf{Identification of the kinetic energy bases from the library for PDEs}. The weights of the dictionary functions are portrayed. (a) Elastic Transversal Waves in a Solid: for the $i^{th}$-discretization, the kinetic energy bases are found as $\left(u_{i+1}-u_{i} \right)^2$. (b) Flexion Vibration of a Blade: for the $i^{th}$-discretization, the kinetic energy bases $\left(u_{i+1}-2u_{i}+u_{i-1} \right)^2$ are found to be active.}
\label{fig:spy_pde}
\end{figure}
\subsection{Elastic Transversal Waves in a Solid}\label{example_6}
In this example, we extend the proposed framework for discovering Lagrangian for PDE problems. We consider a string with section $S$ and with mass density $\rho$ that is deformed transversely. This example can also be related to the transmission of longitudinal waves (often known as S waves) in fluids. We aim to discover the Lagrangian that will govern the time evolution of deformation in the string. The motion in the string is described by the following partial differential equation,
\begin{equation}
\frac{\partial^2 u(X,t)}{\partial t^2} = c^2 \frac{\partial^2 u(X,t)}{\partial X^2}
\end{equation}
where $c=\sqrt{\mu / \rho}$ is the speed of elastic transversal wave, $\mu$ is the shearing modulus, and $\rho$ is the mass density of the material. It can be noticed that the governing equation is exactly the one-dimensional wave equation. Let the length of the string be $l$. For data simulation, we virtually cut the string length $l$ into $N+1$ slices with thickness $\delta$. We refer to each slice as a node and place an identical mass at the center of each slice. During deformation, these nodes move transversely by an amount of $u_i$ with respect to an equilibrium condition. The total kinetic $T$ and potential energy $V$ of the system are given as,
\begin{equation}
T = \frac{1}{2} \rho S \delta \sum_i \dot{u}_i^2, \; V = \frac{\mu S}{\delta} \sum_i \left(u_{i+1}-u_{i} \right)^2
\end{equation}
The associated Lagrangian is given by $\mathcal{L}$=$\frac{1}{2}\sum_{i} \rho S \delta \dot{u}_i^2 - \sum_i {\mu S}{\delta}^{-1} \left(u_{i+1}-u_{i} \right)^2$. More details are given in \cite{gignoux2009solved}. For data simulation, an initial profile of ${\rm{cos}}(2\pi l)$ is applied to the string. A finite difference code is written for the simulation of the data. The parameters for the simulation are provided in Table \ref{table_param}. To discover the Lagrangian, we treat the problem as a high-dimensional extension of the previous MDOF examples. The Lagrangian at discretized spatial locations is discovered and then summed to obtain the Lagrangian of waves. A 50-dimensional spatial grid is created to balance the accuracy and computational time. To simulate the data, we used $\delta$=0.01, $\Delta t$=0.0001s, $T$=1s.
\textbf{Results}: The weights of the dictionary functions are shown in Fig. \ref{fig:spy_string}, where a value of 1 means the dictionary function is active in discovered Lagrangian, and a value of 0 means not-active. Similar to previous examples, the results are shown for the identification of the Lagrangian functions. The active energy functions are also displayed in the figure. It can be seen that out of $\mathbf{R}^{2451}$-basis functions, only one basis is active at each discretized spatial location. This indicates the highly sparse nature of the identified Lagrangian model. By summing the Lagrangian at each spatial location using the parameters in Table \ref{tab:ident_param}, we obtain the actual Lagrangian.
\begin{table}[ht]
\centering
\begin{threeparttable}
\centering
\caption{Discovery of Lagrangian and Energy conservation (Hamiltonian) in the example problems}
\label{table:identify}
\begin{tabular}{p{2.5cm}p{10cm}ll}
\toprule
\textbf{Systems} & \textbf{Lagrangian/Hamiltonian} & \textbf{Discovery} & \textbf{$^{\dagger}$Error} (\%) \\
\midrule
Ex. (\ref{example_harmonic}\eqref{eq:free}) & $\mathcal{L}$=$\frac{1}{2}\dot{X}^2 - \frac{1}{2}({k}/{m})X^2$ & \textcolor{blue}{Yes} & $\approx$ 0.0146 \\
& $\mathcal{H}$=$\frac{1}{2}\dot{X}^2 + \frac{1}{2}({k}/{m})X^2$ & \textcolor{blue}{Yes} & $\approx$ 0.0986 \\
\hdashline
Ex. (\ref{example_harmonic}\eqref{eq:forced}) & $\mathcal{L}$=$\frac{1}{2}\dot{X}^2 - \frac{1}{2}({k}/{m})X^2 + X({F(t)}/{m})$ & \textcolor{blue}{Yes} & $\approx$ 0.0028 \\
& $\mathcal{H}$=$\frac{1}{2}\dot{X}^2 + \frac{1}{2}({k}/{m})X^2 + X({F(t)}/{m})$ & \textcolor{blue}{Yes} & $\approx$ 0.0006 \\
\hdashline
Ex. (\ref{example_3}) & $\mathcal{L}$=$\frac{1}{2}\dot{\theta}^2 - ({g}/{l}){\rm{cos}}\theta$ & \textcolor{blue}{Yes} & $\approx$ 0.0683 \\
& $\mathcal{H}$=$\frac{1}{2}\dot{\theta}^2 + ({g}/{l}){\rm{cos}}\theta$ & \textcolor{blue}{Yes} & $\approx$ 0.0776 \\
\hdashline
Ex. (\ref{example_4}) & $\mathcal{L}$= $\frac{1}{2} \sum_{k=1}^{3} m_k \dot{X}_k^2 - \left( \frac{1}{2}k_1 X_1^2 + \frac{1}{2}k_2(X_2-X_1)^2 + \frac{1}{2}k_3(X_3-X_2)^2 \right)$ & \textcolor{blue}{Yes} & $\approx$ 0.1554 \\
& $\mathcal{H}$= $\frac{1}{2} \sum_{k=1}^{3} m_k \dot{X}_k^2 + \left( \frac{1}{2}k_1 x_1^2 + \frac{1}{2}k_2(X_2-X_1)^2 + \frac{1}{2}k_3(X_3-X_2)^2 \right)$ & \textcolor{blue}{Yes} & $\approx$ 0.0101 \\
\hdashline
Ex. (\ref{example_5}) & $\mathcal{L}$= $\frac{1}{2} \sum_{k=1}^{3} m_k \dot{X}_k^2 - \left( \frac{1}{2}k_2(X_2-X_1)^2 + \frac{1}{2}k_3(X_3-X_2)^2 \right)$ & \textcolor{blue}{Yes} & $\approx$ 0.3916 \\
& $\mathcal{H}$= $\frac{1}{2} \sum_{k=1}^{3} m_k \dot{X}_k^2 + \left( \frac{1}{2}k_2(X_2-X_1)^2 + \frac{1}{2}k_3(X_3-X_2)^2 \right)$ & \textcolor{blue}{Yes} & $\approx$ 0.0127 \\
\hdashline
Ex. (\ref{example_6}) & $\mathcal{L}$=$\frac{1}{2}\sum_{i} \rho S \delta \dot{u}_i^2 - \sum_i ({\mu S}/{\delta}) \left(u_{i+1}-u_{i} \right)^2$ & \textcolor{blue}{Yes} & $\approx$ 1.0092 \\
& $\mathcal{H}$=$\frac{1}{2}\sum_{i} \rho S \delta \dot{u}_i^2 + \sum_i ({\mu S}/{\delta}) \left(u_{i+1}-u_{i} \right)^2$ & \textcolor{blue}{Yes} & $\approx$ 0.0645 \\
\hdashline
Ex. (\ref{example_7}) & $\mathcal{L}$=$\frac{1}{2} \mu \delta \sum_{i} \dot{u}_i^2 - ({EI}/{2 \delta^3}) \sum_i \left(u_{i+1}-2u_{i}+u_{i-1} \right)^2$ & \textcolor{blue}{Yes} & $\approx$ 4.9482 \\
& $\mathcal{H}$=$\frac{1}{2} \mu \delta \sum_{i} \dot{u}_i^2 + ({EI}/{2 \delta^3}) \sum_i \left(u_{i+1}-2u_{i}+u_{i-1} \right)^2$ & \textcolor{blue}{Yes} & $\approx$ 1.8730 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item $^{\dagger}$Here, the error denotes the mean absolute relative error between the actual and discovered parameter.
\end{tablenotes}
\end{threeparttable}
\end{table}
\subsection{Flexion Vibration of a Blade}\label{example_7}
In the last example, we consider a homogeneous, uniform, thin blade having the mass $M$, length $l$, and linear mass $\mu$. At rest, the blade lies in a horizontal position. When this blade is subjected to deformation, it attempts to return to its equilibrium state by transforming its elastic potential energy into kinetic energy. This phenomenon causes vibration in the blade. We intend to discover the Lagrangian (by neglecting the effect of gravity) associated with the vibration of this blade. The motion equation for the vibration in the blade is given by the following differential equation,
\begin{equation}
\frac{\partial^2 u(X,t)}{\partial t^2} = c^2 \frac{\partial^4 u(X,t)}{\partial X^2}
\end{equation}
with $c= {EI}/{\mu}$. Here, $E$ is the modulus of elasticity of blade material, and $I$ is the moment-of-inertia. For data simulation, we first constructed the discontinuous model of the blade by discretizing the blade length $l$ into $N$ segments of length $\delta$ and mass $\mu \delta$. We refer to these segments as nodes. In the field, these nodes can be related to the sensor locations. We assume the absence of torsion, i.e., only the blade motion in the vertical plane, is considered. Further, we assume that the deformation is weak, which allows making the hypothesis that each segment has a fixed length $\delta$. Under these assumptions the total kinetic ($T$) and potential energy ($V$) are given as,
\begin{equation}
T = \frac{1}{2} \mu \delta \sum_{i} \dot{u}_i^2, \; V = \frac{EI}{2 \delta^3}\left(u_{i+1}-2u_{i}+u_{i-1}\right)^2
\end{equation}
where $\mu = M/l$ is the mass per unit length. Here, $u_{i}$, $u_{i+1}$, and $u_{i-1}$ denote the deviations at the center of mass, right end, and left end of the $i^{th}$ node from the equilibrium point, respectively. The corresponding Lagrangian is
$\mathcal{L}$=$\frac{1}{2} \mu \delta \sum_{i} \dot{u}_i^2 - {EI}({2 \delta^3})^{-1} \sum_i \left(u_{i+1}-2u_{i}+u_{i-1} \right)^2$. For more information, readers are referred to \cite{gignoux2009solved}. To obtain the data, the blade is excited using its fundamental frequency (i.e., the first frequency of a cantilever beam). The data are obtained using the finite element method. The simulation parameters are given in Table \ref{table_param}. The Spatio-temporal parameters are $\delta$=0.01, $\Delta t$=0.001s, and $T$=2s.
\textbf{Results}: A total of $\mathbb{R}^{5347}$-basis functions are used. The weights of the basis function at all the spatial locations are shown in Fig. \ref{fig:spy_beam}. The notion of identification is the same as in previous examples. It can be seen the weight matrix is highly sparse. The active functions are also portrayed in the figure. The associated parameters are given in Table \ref{tab:ident_param}. The error in the parameters are negligible, and when used for the weighted sum of the Lagrangian at each spatial location, we obtain the actual Lagrangian of the system.
\subsection{Discovery of Hamiltonian from the identified Lagrangian}
Conservation laws are very important in physical and engineering systems. They are associated with underlying symmetries, and therefore they provide fundamental knowledge about physical systems. Examples of conservation laws include the conservation of energy, conservation of momentum, conservation of mass and etc. In this section, we aim to derive the associated conservation laws from the identified Lagrangian. In particular, we compare the associated Hamiltonian from the actual system with the identified Lagrangian system and prove that our proposed approach can successfully discover new conservation laws directly from data. To derive the Hamiltonian from discovered Lagrangian, we used the following equation,
\begin{equation}
\mathcal{H}(\bm{X}, \dot{\bm{X}}) = \sum^m_{i=1} \frac{\partial \mathcal{L}(X_i, \dot{X}_i)}{\partial \dot{X}_{i}} \dot{X}_{i} - \mathcal{L}(X_i, \dot{X}_i)
\end{equation}
\begin{figure}[ht!]
\centering
\includegraphics[width=0.8\textwidth]{Hamiltonian.pdf}
\caption{\textbf{Conservation of energy in the example problems}. The solid lines represent the actual energy of the underlying systems, and the dotted lines denote the Hamiltonian of the identified systems. In all the examples, the conservation of energy is discovered. The total energy discovered using the proposed framework matches the Hamiltonian of the actual system.}
\label{fig:energy}
\end{figure}
The identified Hamiltonian is then compared with the actual Hamiltonian of the system, i.e., the total energy of the system, which is given as $\mathcal{H} = T + V$. The identified Hamiltonians are provided in Table \ref{table:identify}. One can verify that the identified Hamiltonians perfectly match the true ones. For better visualization, we have also portrayed the Hamiltonian, i.e., the conservation of energy in Fig. \ref{fig:energy}. Firstly, we can comment that the energy is conserved in the identified systems. Secondly, we can conclude that the identified energy in the systems is the same as the actual system. This proves our claim that the proposed framework can successfully discover the Lagrangian as well as the conservation laws from only a single observation of systems states.
\subsection{Discovery of equations of motion from identified Lagrangian}
Lagrange’s equations provide a systematic approach to formulate the governing equations of motion of mechanical and structural systems. Instead of force balance, a scalar outlook is taken in the Lagrange approach by expressing the scalar quantities of kinetic and potential energy in terms of generalized coordinates. In this section, we provide enough evidence for the superiority of the proposed framework by constructing the equations of motion from the discovered Lagrangian and then comparing the solutions with their true counterparts. To arrive at the equations of motion, we have applied the \eqref{eq:lagrange_hom} on the identified Lagrangian. It is to be noted that the exact analytical expressions for the Lagrangian are known (see Table \ref{table:identify}). Thus, when \ref{eq:lagrange_hom} is applied to the identified Lagrangian, it yields the interpretable equations of motion. This confirms that the proposed framework can not only identify the Lagrangian and conservation laws but is capable of discovering explainable analytical equations of motion from data. The solutions to the derived equations of motion from discovered Lagrangian and actual systems are portrayed in Fig. \ref{fig:response} and \ref{fig:Response_pde}.
\begin{figure}[ht!]
\centering
\begin{subfigure}[b]{0.31\textwidth}
\centering
\includegraphics[width=\textwidth]{Response_linear.pdf}
\caption{Harmonic oscillator}
\label{fig:response_linear}
\end{subfigure}
\begin{subfigure}[b]{0.31\textwidth}
\centering
\includegraphics[width=\textwidth]{Response_forced.pdf}
\caption{Forced oscillator}
\label{fig:response_forced}
\end{subfigure}
\begin{subfigure}[b]{0.31\textwidth}
\centering
\includegraphics[width=\textwidth]{Response_pendulum.pdf}
\caption{Pendulum}
\label{fig:response_pendulam}
\end{subfigure}
\begin{subfigure}[b]{\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{Response_3dof.pdf}
\caption{3DOF dynamical system}
\label{fig:response_3dof}
\end{subfigure}
\begin{subfigure}[b]{\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{Response_tri.pdf}
\caption{Triatomic molecular chain}
\label{fig:response_atom}
\end{subfigure}
\caption{\textbf{Response of the Lagrangian equation of motion}. The true responses of the actual systems are compared with the responses of the identified Lagrangian equation of motion. In all cases, the solution of identified equation motion completely overlaps the ground truth.}
\label{fig:response}
\end{figure}
In Fig. \ref{fig:response}, the prediction results for ODEs using the identified systems for different initial conditions are portrayed. The solid red lines denote the true solution, and the blue dotted lines represent the solutions of the identified systems. From Fig. \ref{fig:response}(a), \ref{fig:response}(b), and \ref{fig:response}(c) it is evident that the identified systems from the discovered Lagrangian almost exactly overlap the true solutions. Further, from \ref{fig:response}(d) and \ref{fig:response}(e), it can be referred that the identified systems can also approximate the highly complex behavior of the true systems. Similarly, in Fig. \ref{fig:Response_pde}, the predictions on different initial conditions for PDEs are illustrated. The error plots reveal that the discovered systems from the identified Lagrangian can very accurately predict the behavior of actual systems.
\begin{figure}[ht!]
\centering
\includegraphics[width=\textwidth]{Response_pde.pdf}
\caption{\textbf{Response of the Lagrangian equation of motion of the PDEs}. The solutions of the actual PDEs and the identified Lagrangian PDEs are compared. The error between actual and identified PDEs' solutions is less than 0.25\% in both examples. This indicates that the identified Lagrangians and the derived Lagrangian equations of motion are highly accurate.}
\label{fig:Response_pde}
\end{figure}
\subsection{Zero shot generalization}
When the governing physics of an underlying physical system is discovered, the purpose is not only limited to the identification of the system. It is often useful to reuse the governing physics for a variety of other purposes, for e.g., testing the stability of the system, prediction on a different condition, numerical modeling, etc. In such cases, the accuracy of the identified system plays an important role. In this section, we consider the motion equation of the traveling wave in the blade (the derived equation from the corresponding discovered Lagrangian) and demonstrate that the motion equation generalizes to other vibrational modes. In particular, we excite the blade using its third natural frequency (note that during the discovery phase, the data are generated by exciting the blade with its first natural frequency) and compare the responses with the actual system. The result is displayed in Fig. \ref{fig:zero_shot}. We see that the error between the responses of the identified and true systems ($\ll 1\%$) is quite negligible.
\begin{figure}[ht!]
\centering
\begin{subfigure}[b]{0.49\textwidth}
\centering
\includegraphics[width=\textwidth]{zero_shot.pdf}
\caption{Zero shot generalization}
\label{fig:zero_shot}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\centering
\includegraphics[width=\textwidth]{Perpetual.pdf}
\caption{Perpetual predictive capability}
\label{fig:perpetual}
\end{subfigure}
\caption{\textbf{Predictive performance of the proposed framework}. (a) For the discovery of the governing physics of the flexion motion of the blade, the blade is excited using its first natural frequency. In this case, the identified blade physics is solved in its third natural frequency. (b) The governing physics of the transversal motion of the string is identified from 1s of data (recorded at 1000Hz). The identified system is then solved for 100s at the same sampling frequency. In both studies, the responses of the true and identified systems are plotted. In addition, the absolute errors between the solutions are also shown. In both cases, the absolute error is $\ll 1\%$.}
\label{fig:case1}
\end{figure}
\subsection{Perpetual predictive capability}
In all the governing physics discovery problems, the prime focus is to capture the actual dynamics of the underlying system rather than to predict the given data. When the actual physics of a physical system is captured, maybe in intrinsic coordinates \cite{tripura2023sparse}, it ensures the underlying system dynamics and allows us to predict for an infinite duration of time with high accuracy. This is particularly important for chaotic systems where small deviations in the governing model cause the system to diverge exponentially. In this section, we consider the identified system of the transversal motion of the string and perform a prediction upto 100s. Note that the Lagrangian was identified using a single observation of system response recorded for 1s (with sampling frequency 10000Hz). The result is compared with the actual response in Fig. \ref{fig:perpetual}. It can be seen that the motion equation derived from the identified sparse Lagrangian not only reproduces the actual system but maintains accuracy below $\ll 1\%$. This clearly indicates the perpetual predictive ability of the proposed framework.
\subsection{Generalization to high-dimensional domains}
As stated in Remark 1, when data are collected from a large number of sensor locations (e.g., spatial discretization of PDEs, where the dimension of the discretized system may become in the order of tens of thousands to billions of variables), the state dimension $m$ becomes prohibitively large. In these cases, the physics discovery of underlying systems may become computationally heavy due to the exponential growth of the dictionary dimension. However, the proposed framework provides a remedy in which we can identify the underlying Lagrangian from a subset of the measurements and then can analytically extend to $m$-dimensions. In this section, we demonstrate the ability of the proposed framework to generalize the Lagrangian identified from a relatively small domain to the Lagrangian density of the whole domain. In particular, we consider the Lagrangian of the triatomic molecule and aim to generalize it to an $m$-link atomic chain (see Table \ref{tab:ident_param} and \ref{table:identify}).
\begin{figure}[!ht]
\centering
\includegraphics[width=\textwidth]{Generalization.pdf}
\caption{\textbf{High-dimensional generalization ability of the proposed framework}. An atomic chain with 30 molecules is generated from the Lagrangian of the triatomic molecule. The responses for a few atoms of the identified chain are plotted. The generalized system accurately identifies the correct vibrational modes of the atomic chain.}
\label{fig:case_general}
\end{figure}
In the $n$-link chain, we consider an elementary chain consisting of light atoms with mass $m$ and heavy atoms with mass $\tilde{m}$. Let the associated displacements be $X_j$ and $\tilde{X}_j$, respectively. Then the kinetic energy of the elementary chain is $T_j=\frac{1}{2} (m\dot{X}_j^2+ \tilde{m}\dot{X}_j^2 )$.
From the triatomic chain, we can find that the net elongation between the $j^{th}$ light and heavy atom is $(\tilde{X}_j - X_j)$. The corresponding potential energy is $\frac{1}{2} k(\tilde{X}_j-X_j)^2$. Also, between the heavy atom $j$ and the light atom $j+1$, the net elongation is $(X_{j+1}-\tilde{X}_j)$ to which corresponds a potential energy $\frac{1}{2} k(X_{j+1}-\tilde{X}_j)^2$. The Lagrangian of the chain is then found by computing the difference between the total kinetic energy and total potential energy as follows,
\begin{equation}
\mathcal{L}(\bm{X}, \dot{\bm{X}}) = \sum_j^n{\left[\frac{1}{2} m\dot{X}_j^2 + \frac{1}{2} \tilde{m}\dot{\tilde{X}}_j^2 - \frac{1}{2} k\left(\tilde{X}_j-X_j\right)^2-\frac{1}{2} k\left(X_{j+1}-\tilde{X}_j\right)^2\right]} .
\end{equation}
For this study, we use a chain of $m=30$ and keep the same parameters of the system. The results are summarized in Fig. \ref{fig:case_general}. It is evident that the responses of the generalized chain and the actual system are indistinguishable. The generalized system reproduced the dynamics of the actual system very well.
\subsection{Noise sensitivity}
In this section, we test the performance of the proposed framework against the measurement noise. In this investigation, we corrupt the single observation of data with zero mean Gaussian noise. For brevity, we limit this study to the (i) Harmonic oscillator (Ex. \ref{eq:free}), (ii) 3DOF dynamical system (Ex. \ref{example_4}), and Triatomic molecule (Ex. \ref{example_5}). A total of 5 levels of noise are considered, where each level indicates a certain percentage of the standard deviation of the actual data. For the sake of comparison, we first check whether the correct dictionary basses are identified. In the presence of any other functions (even if the correct basses are identified), we discard the identified models since, in the presence of false basses, the generalization ability of discovered model decreases. If the identified sparse model exactly matches with the actual system, we compute an error $e_{\mathcal{L}} = \|\mathcal{L}_a - \mathcal{L}^* \|_2 / \|\mathcal{L}_a\|_2$ to test the accuracy of the model. Here $\mathcal{L}_a$ and $\mathcal{L}^*$ represent the actual and identified Lagrangian, respectively. The corresponding results are illustrated in Table \ref{tab:noise}. We observe that the proposed framework failed to identify the exact analytical model of the Lagrangian of the triatomic molecule and 3DOF system when noise $\zeta \ge 4$ and $\zeta \ge 5$, respectively. From the study, we conclude that the proposed framework works successfully when the data are corrupted with noise levels between $3-4\%$.
\begin{table}[!ht]
\centering
\caption{Noise sensitivity of the proposed framework}
\begin{tabular}{llllllll}
\toprule
\multirow{2}{*}{ Noise level-$\zeta$ (\%)}& \multicolumn{3}{c}{Discovery of correct basis} && \multicolumn{3}{c}{Relative Error, $e_{\mathcal{L}}$ (\%)} \\ \cline{2-4} \cline{6-8}
& Harmonic OSC. & Triatomic mol. & 3DOF && Harmonic OSC. & Triatomic mol. & 3DOF \\
\midrule
No noise & \textcolor{blue}{Yes} & \textcolor{blue}{Yes} & \textcolor{blue}{Yes} && 0.0280 & 0.3916 & 0.1554 \\
\hdashline
1 & \textcolor{blue}{Yes} & \textcolor{blue}{Yes} & \textcolor{blue}{Yes} && 0.0096 & 0.4756 & 0.2139 \\
2 & \textcolor{blue}{Yes} & \textcolor{blue}{Yes} & \textcolor{blue}{Yes} && 0.0245 & 0.5574 & 0.9455 \\
3 & \textcolor{blue}{Yes} & \textcolor{blue}{Yes} & \textcolor{blue}{Yes} && 0.1956 & 1.1649 & 1.6566 \\
4 & \textcolor{blue}{Yes} & \textcolor{red}{No} & \textcolor{blue}{Yes} && 0.5076 & -- & 3.1050 \\
5 & \textcolor{blue}{Yes} & \textcolor{red}{No} & \textcolor{red}{No} && 1.1394 & -- & -- \\
\bottomrule
\end{tabular}
\label{tab:noise}
\end{table}
\section{Discussions}\label{sec:conclusion}
We have proposed a novel framework for the discovery of Lagrangian of systems from a single observation of data using sparse least-squares regression. In particular, we combine the Lagrangian formalism with sequential threshold least-squares to discover the Lagrangian. Briefly, we collected several candidate functions for the Lagrangian inside a dictionary and then utilized the sparse regression to identify a combination of candidate functions that satisfy the principle of minimal action. We have shown that the resulting framework is highly robust and can learn exact sparse forms of the Lagrangian of systems (both rigid and flexible systems) from data alone, whereas the available Lagrangian discovery schemes are black-box in nature. We have also shown that the proposed framework can recover the governing equations of motion (for systems described by ODEs and PDEs) without extra effort. Through the Legendre transformation, it is also possible to derive conservation laws from the proposed framework. From the discovery of Lagrangian to the identification of hidden conservation laws to distilling governing equations of motion, the proposed framework utilizes only a single set of observations of data. The robustness of the proposed framework also lies in its ability to generalize to different initial conditions and the ability to predict the actual system dynamics for an infinite duration of time. When the underlying observation states are humongous, the proposed framework also provides a way to learn the Lagrangian from a relatively small subset of the observations. The fidelity is demonstrated on a sufficient number of systems of ODEs and PDEs, including various case studies. The results are highly encouraging.
To our knowledge, there is only one major limitation of the proposed work. We note that in our proposed framework, the accuracy of the discovered Lagrangian depends on the right choice of candidate function in the dictionary. However, in the presence of dissipative forces \cite{zhong2020dissipative}, the candidate function may be entangled between states in a very complicated fashion. In such cases, choosing the right basis function may not be possible, and the discovered Lagrangian may generalize beyond some time frame. However, having prior knowledge may alleviate the problem to some degree.
Considering the above limitation, we believe the proposed framework can automate, accelerate, and guide the discovery of new physics and associated conservation the way a human would discover, especially where the human cognitive capabilities are met limits. The discovery of the exact analytical form of Lagrangian rather than a direct discovery of governing equations of motion will also enable the knowledge-based design of future technologies. An immediate application would include the integration of the proposed approach for learning and control of dynamical systems \cite{gupta2019general,lutter2019deep}.
| {'timestamp': '2023-02-10T02:04:23', 'yymm': '2302', 'arxiv_id': '2302.04400', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04400'} | arxiv |
\section{Introduction}\label{introduction} Mobile manipulators (def: a mobile platform \textcolor{black}{carrying} a robot arm) have attracted much interest in universities and industry because of \textcolor{black}{the combination of} flexible locomotion and dexterous manipulation~\citep{survey_application_mobile_manipulator_2022,survey_mobile_manipulator_2019}. A mobile manipulator is able to \textcolor{black}{undertake} multiple different industrial tasks in a large workspace (rather than at a fixed work station), and can be widely used in many flexible manufacturing tasks, such as quality inspection in factories, workpiece loading and unloading in workshops, and painting. It is cumbersome and time-consuming to reprogram for each robot application. Thus, it is vital for flexible manufacturing to minimize the human effort spent on teaching the robot, and \textcolor{black}{to} ensure the mobile manipulator is able to automate and redo multiple desired industrial tasks in a large workspace flexibly with \textcolor{black}{one-shot teaching} from a human operator. This one-shot teaching and automation pipeline of a mobile manipulator for flexible manufacturing is referred to as Mobile Manipulator Process Automation with One-shot Teaching (MMPA)\footnote{\textcolor{black}{All the abbreviations in this manuscript are listed in Appendix~\ref{Abbreviations}. List of Abbreviations.}}.
Current mobile manipulator process automation approaches consist of two stages: in the first stage the mobile base's location and the robot arm's path are recorded; in the second stage the mobile manipulator will park at the same location and replay the arm's path as recorded in the first stage. Such approaches rely heavily on precise parking of the robot base and are easily affected by harsh industrial conditions. As the robot arm's path is replayed in the exact same manner as recorded in the teaching stage, a minor error of the parking \textcolor{black}{position} will lead to an incorrect robot arm manipulation.
However, parking precisely is hard to achieve in a real harsh industrial environment. For example, a rough, cratered, slippery ground will affect robot control accuracy\footnote{ Note: on the market, a mobile base with high control accuracy (millimeter level) is 10+ times more expensive than a regular mobile base (centimeter level) we use.} definitely~\citep{terrain-parameter1-2018,terrain-parameter2-2021,fuzzy-control-2021,impedance-control-2022}. Additionally, the localization accuracy from SLAM (\textcolor{black}{Simultaneous Localization And Mapping})~\citep{preintegration-gnss-imu-in-vehicle-2021, calibration-IMU-Odometer-2022,gmapping2007, cartographer2016, slam-survey1-2021, multi-sensor-fusion-2022,slam-survey2-2021} is not high enough for precise parking in MMPA. Matching the 2D template marker's images from the teaching and automation stages~\citep{iterative-learning-error-compensation2021} could provide a relative 3D pose for parking error compensation but can only be used to move the robot base on a 2D plane rather than a 3D surface. Lastly, there is no existing 6D pose recovery algorithm~\citep{survey-point-cloud-matching-2021,GO-ICP2015,ICP-1-2022,ICP-2-2022,colored-point-cloud-registration-2017,3DMatch-2017, point-cloud-matching-descriptor-2021,point-cloud-matching-descriptor2-2021,fast-global-registration2016, CPD, CPD2,DUGMA, GMM-point-cloud-matching} that provides an accurate and robust 6D pose estimation (\textcolor{black}{The 6D pose is [translation on $x$ axis, translation on $y$ axis, translation on $z$ axis, roll, pitch, yaw]}) for parking pose error compensation to meet the requirement of MMPA. As described above, Figure~\ref{fig:scene} shows a real typical workshop example with a harsh industrial environment where our developed robot is working. \textcolor{black}{The two articles~\citep{robotics_design_for_harsh_environment1,robotics_design_for_harsh_environment2} gives a good overview of the design of the autonomous robotics system against the harsh environment in the real-life setting. }
\begin{figure}
\begin{center}
\subfloat{\includegraphics[width=1\linewidth]{figure/fig1_2column_1000dpi.jpg}}
\end{center}
\caption[scene-and-application]{A typical workshop example with harsh industrial conditions and our mobile manipulator. 1 The mobile manipulator is required to perform complex manipulation in 3D space with priori knowledge such as how to switch the valve rather than simple workpiece loading and unloading. 2 The ground consists of not only 2D plane but also 3D speed bump where a working robot parks on. 3 The guard bars and pipes are not suitable to stick any marker for error compensation.
\label{fig:scene}
\end{figure}
The proposed MMPA method is capable of dealing with the problem of bad ground conditions with a novel iterative pose estimation approach to compensate for the error introduced by imprecise parking. The proposed MMPA framework has two stages, a one-shot teaching stage and an automation stage. In the one-shot teaching stage, a human teaches the mobile manipulator to perform a specific tasks. Information such as the location of the robot base, working environment information and the path of the robot arm's end-effector are collected, to allow for the reproduction of the task in the automation stage. In the automation stage, the robot first navigates to the specified location without the need of precise parking. Then, based on the global colored point cloud registration, the proposed IPE (Iterative Pose Estimation by Eye \& Hand) algorithm provides an accurate relative 6D parking pose without the need of any marker. Finally, the mobile manipulator uses the relative 6D parking pose to calibrate and adjust the path of the robot arm's end-effector for performing complex tasks taught by the human operator during the one-shot learning stage. In this work, hundreds of trials have been conducted with a real mobile manipulator to show that our proposed MMPA framework and IPE algorithm are capable of calibrating and adjusting the path of the robot arm end-effector to compensate for the parking error and guarantee the robustness of the system and the accuracy of the process automation without worrying about ground conditions and parking precision.
\textcolor{black}{
The proposed MMPA could bring much benefit to robot developers and customers who need the joint automation of flexible locomotion and dexterous manipulation. Currently, robot developers need to spend much time in programming robots for various tasks, which limits the robot application development efficiency and increases the development fee drastically. With the proposed MMPA, robot developers could develop simple robot automation tasks with human demonstration, which is also important to the customers without professional knowledge of robotics. The customers could adapt the mobile manipulator flexibly to a new task by themselves without the need of professional on-the-spot service, which reduces the maintenance fee and waiting time. With the proposed MMPA technique, one mobile manipulator could replace at least three workers\footnote{\textcolor{black}{The robot could work 24 hours a day while a human worker only works for 8 hours a day}} day and night, which decreases the labor cost. Additionally, compared to human workers, robot workers do not require human resource management and can work in hazardous environments, reducing the management burden for managers. Currently the proposed MMPA technique could be used to develop many real applications in various areas (e.g.: material handling and logistics~\citep{AMR}). The mobile manipulator could be used to load or unload the workpiece or electronical components and convey them to different designated places in some semi-conductor factories or mechanical companies. In an e-commerce warehouse, the mobile manipulator could be used to pick different goods on the shelves, pack them and deliver them to the postmen. In a hospital, the mobile manipulator could be used to take out the harmful medical waste and convey it to an appointed place without any intervention of human. Much more real applications are being developed on the way.
}
The remainder of this paper is structured as follows. Section~\ref{related-works} presents previous research about MMPA's progress, MMPA's impact factors, and 6D pose recovery algorithms. Section~\ref{methodology} presents the proposed algorithm for mobile manipulator process automation by one-shot teaching. Section~\ref{Experiment} demonstrates the robustness of the system and assesses the accuracy of the process automation regardless of the ground conditions and parking precision based on hundreds of trials using the real mobile manipulator. Section~\ref{Conclusion} presents a summary of the work.
\textbf{Contributions in this paper:}
(1) An accurate 6D pose estimation algorithm: IPE (Iterative Pose Estimation by Eye \& Hand);
(2) An adaptive online path learning method to calibrate the end-effector's trial in 3D space effectively;
(3) An effective and robust MMPA framework that is able to compensate for the errors caused by ground conditions and low parking precision;
\section{Related Works}\label{related-works}
Mobile manipulators combine the advantages of both the mobile base's mobility~\citep{AMR} and the articulated arm's dexterity, which makes it an ideal tool to perform multiple manipulation tasks that cover different locations in a large workspace. Research \textcolor{black}{into} mobile manipulators has a long history, dating back to \textcolor{black}{the last century}~\citep{mobile-manipulator1996,mobile-manipulator1999, mobile-manipulator1992}. \textcolor{black}{The most recent surveys~\citep{survey_application_mobile_manipulator_2022,survey_mobile_manipulator_2019} give an explicit progress overview of the mobile manipulator's hardware system, software system and the new applications.} One of the interesting advanced technique is mobile manipulator process automation \textcolor{black}{because it requires the robot to autonomously reproduce the work taught by humans.} Currently, the main ideas to realize mobile manipulator process automation in a large workspace \textcolor{black}{are}: (1) In the teaching stage, record the mobile base's location data and the arm's manipulation path data into the database. (2) In automation stage, let the mobile base navigate and park at the location from the teaching stage with high accuracy (e.g.: position accuracy on the $x$, $y$ axis < 0.2 $cm$, orientation accuracy < $0.1^{\circ}$) first; then let the robot arm replay the previously recorded manipulation path data from the database to reproduce the work that humans taught. Given the actuation accuracy of most economic collaborative robot arms is not above 0.1 $mm$, parking the mobile platform extremely accurately is the key for mobile manipulator process automation.
To make the robot base park precisely, the researchers have to deal with many aspects within the robot system, such as: sensor calibration~\citep{calibration-odometer-2018,calibration-IMU-Odometer-2022,preintegration-gnss-imu-in-vehicle-2021,sensor-fusion-2019}, localization~\citep{slam-survey1-2021,slam-survey2-2021,gmapping2007, cartographer2016, multi-sensor-fusion-2022, calibration-IMU-Odometer-2022,preintegration-gnss-imu-in-vehicle-2021}, control accuracy~\citep{terrain-parameter1-2018,terrain-parameter2-2021,fuzzy-control-2021,impedance-control-2022}, error compensation~\citep{robust-learning-control-2019,iterative-learning-error-compensation2021}. Single sensor calibration could rectify the output value by using a noise model to make it more accurate. For example, \textcolor{black}{the researchers~\citep{calibration-odometer-2018}} improve the accuracy of the odometer (which can provide the velocity or mileage of a vehicle) through use of Coriolis effects from three perspectives (scale factor, misalignment and level arm with inertial measurement unit). \textcolor{black}{Multiple sensor calibration~\citep{sensor-fusion-2019,preintegration-gnss-imu-in-vehicle-2021, calibration-IMU-Odometer-2022}} provides the relative pose among multiple different sensors for sensor fusion to improve the accuracy, such as using preintegration theory for IMU (\textcolor{black}{Inertial Measurement Unit}) and odometer self-calibration~\citep{calibration-IMU-Odometer-2022,preintegration-gnss-imu-in-vehicle-2021}, calibrating gyroscope and magnetometer for data fusion~\citep{sensor-fusion-2019}. However, sensor calibration could slightly reduce the error given the sensor's inherent properties or mounting positions. \textcolor{black}{Thus, it contributes little to precise parking.} In order to park accurately, mobile base localization is important. Currently there are many popular SLAM algorithms, especially, the Lidar-based SLAM~\citep{gmapping2007, cartographer2016}. \textcolor{black}{ The main feauture of the Lidar-based SLAM~\citep{slam-survey1-2021,slam-survey2-2021} is that it uses Lidar scanner to input the position data for mapping and localization. The Lidar-based SLAM consists of two main categories: 2D Lidar SLAM (e.g.: Gmapping~\citep{gmapping2007}, Cartographer~\citep{cartographer2016}) to generate a 2D map for localization (usually) indoors and 3D Lidar SLAM (e.g.: Lego-loam~\citep{Lego-loam}) to generate a 3D map for localization (usually) outdoors.
} In order to get a more robust and accurate localization, it is a trend to fuse data from multiple sensors (e.g.: lidar, odometer, imu, etc.) using Kalman Filter~\citep{Kalman-Filter-1995,Kalman-Filter-in-robotics-2021}, Graph-based methods~\citep{multi-sensor-fusion-2022, calibration-IMU-Odometer-2022,preintegration-gnss-imu-in-vehicle-2021} etc. . Nevertheless, their final localization accuracy is still limited to centimetre-level, which is still too large to meet the requirements of mobile manipulator process automation. Besides the above sensor calibration and localization, the mobile platform's control accuracy in the workspace is vital as well. Much research~\citep{terrain-parameter1-2018,terrain-parameter2-2021,fuzzy-control-2021,impedance-control-2022} about it has been done in recent years. For example, some researchers studied the terrain property~\citep{terrain-parameter1-2018,terrain-parameter2-2021} for the robot's control to handle the robot's slide etc. Some researchers proposed different improved control methods, such as fuzzy control~\citep{fuzzy-control-2021}, impedance control~\citep{impedance-control-2022}, etc. However, it is challenging to model the errors of the driving mobile base on different unknown terrain in a uniform way to ensure a robust and accurate control accuracy. Thus, parking precisely is hard in real-world scenarios where the environmental situation is unknown, which limits the mobile manipulator process automation's reliability.
Even if the mobile manipulator drives on a well known plane with high control accuracy, the localization accuracy still might not meet the requirements of the mobile manipulator process automation. In order to detect the localization's system error, iterative-learning error compensation methods~\citep{robust-learning-control-2019,iterative-learning-error-compensation2021} have been proposed recently. In this research~\citep{iterative-learning-error-compensation2021}, the researchers developed an extra eye-in-hand vision system to assist the mobile platform's localization. More specifically, they put an RGB camera at the end of the robot arm for perception and attached a QR (\textcolor{black}{Quick Response}) code on the workbench. In the teaching stage, the eye-in-hand vision system (the RGB camera on the arm) takes a photo of QR code using a fixed arm pose. In the automation stage, the mobile manipulator reaches the workbench and takes a photo of the previous QR code again using the previous same fixed arm pose. By matching those 2D QR code templates, the mobile base's relative 3D pose (position bias on the x, y axis and orientation angle) could be estimated. Then, the new relative 3D pose was used to rectify the mobile base's parking pose to make it park more precisely. Matching 2D QR code templates and rectifying the parking pose in an iterative way could make the mobile manipulator park precisely enough for a process automation. However, this method~\citep{iterative-learning-error-compensation2021} suffers from two big problems. Given the pose from 2D QR code template matching has only 3 degrees of freedom, the mobile manipulators could only be moved on a good 2D plane terrain rather than a cratered 3D surface. The second problem is that the condition of the 2D plane for robot base moving should be good enough for accurate robot base control in order to park precisely.
To solve the two problems mentioned above~\citep{iterative-learning-error-compensation2021}, we use a \textcolor{black}{depth sensor (stereo vision camera)} on the arm to estimate the relative 6D pose of the mobile base by point cloud matching~\citep{survey-point-cloud-matching-2021}, which enables the estimation of the robot's pose, even on a rough 3D surface. By changing the robot arm end-effector's working path based on the relative 6D pose of the mobile base, our method does not require the robot base to park precisely, which eliminates the need of high control accuracy of the robot base and good quality ground condition.
Currently, there are three categories of point cloud registration algorithms for estimating the relative 6D pose. \textcolor{black}{The recent survey~\citep{survey-point-cloud-matching-2021} introduces the taxonomy of the point cloud registration methods and their progress. A new cross-source point cloud benchmark~\citep{survey-point-cloud-matching-2021} is developed to evaluate the point cloud registration algorithms to solve cross-source challenges.}
The first category of methods(e.g.:~\citep{GO-ICP2015,ICP-1-2022,ICP-2-2022,colored-point-cloud-registration-2017}) is based on ICP (\textcolor{black}{Iterative Closest Point})~\citep{ICP1992}, which estimates the rigid relative 3D pose between two point clouds in different views by minimizing the Euclidean distance between the corresponding points. Exact point-to-point correspondences seldom exist, which leads to the low accuracy of the ICP-based methods. The second category is feature-based methods~\citep{3DMatch-2017, point-cloud-matching-descriptor-2021,point-cloud-matching-descriptor2-2021,fast-global-registration2016}, which extract the local descriptors from two point clouds first and then match them to recover the relative pose of the two point clouds. These methods are sensitive to strong noise and low density of the point clouds. That is, the noise and density of
the point cloud influences the local descriptors' extraction and can even cause the algorithm to crash if the noise is too strong or the density is too low. The third class uses probabilistic models~\citep{CPD, CPD2,DUGMA,GMM-point-cloud-matching} for point cloud registration. The probabilistic models are used to represent the structure of the point cloud, encoding the geometry distribution of the point cloud in 3D space. By calculating the maximum likelihood of the two probabilistic models, the relative pose can be estimated. This category of methods is more robust and accurate than the first and second category but its computation efficiency is low and limits many real-time applications.
Although those three categories of point cloud registration algorithm can estimate the relative pose from different views, accuracy and robustness decreases with the increase of the initial rotation and translation error between the two point clouds, which might not be able to meet the requirement for the high accuracy in the mobile manipulator process automation. In order to solve this problem, we propose a method called IPE:Iterative pose estimation by eye \& hand in Section~\ref{iterative-pose-estimation}.
\textcolor{black}{
Path planning, also known as motion planning, is an optimization problem that aims to find a valid collision-free trajectory to move the robot end-effector from a start point to an end point while satisfying certain constraints. Path planning problems are commonly solved using probabilistic sampling based algorithms such as rapidly exploring random tree (RRT*)~\citep{RRT2011}, probabilistic roadmap (PRM)~\citep{PRM1996}. Advance in path planning algorithms has allowed robotic arms to perform more complex and flexible tasks \citep{sucan2012openMotion, schulman2014motionPlanning}. Traditionally, the operation path of industrial robot arms within a factory is manually taught or programmed by a human with a dedicated teach pendant, which is tedious and time-consuming. In recent years, there has been an increase in interest on applying path planning algorithms to eliminate the time consuming manual teaching process. Path planning is typically used for manufacturing applications that involve processing industrial products with complex 3D geometry. Such applications include welding\citep{zhou2022onlineObstacle}, painting\citep{chen2020trajectoryPlanning}, grinding\citep{lv2020adaptiveTrajectory}, polishing\citep{mohsin2017roboticPolishing}, \textcolor{black}{cutting\citep{van2019accessibilityFor}, and inspection\citep{alexis2016aerialRobotic}. Coverage path planning is a type of path planning problem, which aims to determine a collision-free trajectory that uniformly passes through all points of an area or volume of interest while minimizing travel time, energy, and other costs\citep{galceran2013surveyOn}.}
} Manufacturing applications that require coverage over a specific area of interest include painting\citep{chen2020trajectoryPlanning}, grinding\citep{lv2020adaptiveTrajectory}, and inspection\citep{engemann2021robotAssisted}.
\section{Methodology}\label{methodology}
\textcolor{black}{The main goal of our proposed MMPA is to ensure that the robot arm's end-effector repeats the same path recorded during the teaching stage in the world coordinate system to reproduce the desired task even if the parking precision is low. \textbf{A simple practical demo video to show the pipeline (teaching stage and automation stage) is available: \url{https://youtu.be/n6D9T9GdqzI}.}
The whole pipeline consists of two stages: (1) data collection by one-shot teaching (Section \ref{one-shot-teaching}) to make the robot learn to perform a specific task; (2) replaying the newly-learned data by the mobile manipulator process automation (Section \ref{mobile-manipulator-process-automation}) to enable the robot to finish the task successfully and flexibly on its own.}
Figure~\ref{fig:coordinate} shows different coordinate systems\footnote{\textcolor{black}{All the symbols in this manuscript are listed in Appendix~\ref{symbols}. List of Symbols.}}: mobile base coordinate system $XYZO_{MB}$, robot arm base coordinate system $XYZO_{B}$, depth camera coordinate system $XYZO_{C}$, world coordinate system $XYZO_{W}$, the joint coordinate system from $XYZO_{1}$ to $XYZO_{6}$.
\subsection{One-shot Teaching} \label{one-shot-teaching}
To realize mobile manipulator process automation in the automation stage, the mobile platform's location information in the pre-built map, the working environment information (colored 3D point cloud of the workbench, tools, etc.) and the robot arm's end-effector path information are collected in real-time through one-shot teaching in this stage \textcolor{black}{in this sub section}.
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{figure/fig2_1column_1000dpi.JPG}
\caption{The figure shows the various coordinate frames in a mobile manipulator.}
\label{fig:coordinate}
\end{figure}
In a known workspace (that is, the navigation map has been built beforehand by some SLAM algorithm, such as Gmapping~\citep{gmapping2007}, Cartographer~\citep{cartographer2016} and so on), the mobile manipulator is controlled to finish a task denoted by $tk_{i} (i=1,2,3, ...)$ . Each task $tk_{i}$ contains the mobile platform location information $L_{i}(vehicle) $, the initial working environment information - a colored 3D point cloud $X_{i}(O)$ and the robot end-effector's path $Path_{i}(O)$ when performing the task $tk_{i}$.
The location information $L_{i}(vehicle) $ is recorded only once, which consists of the position and Euler angle of the mobile platform in the world coordinate system $XYZO_{W}$.
The colored 3D point cloud $X_{i}(O)$ is acquired by the depth sensor mounted on the robot arm in its depth sensor coordinate system $XYZO_{C}$.
The recorded path information\footnote{We perform one-shot teaching of the desired path by having a human operator manually guiding and applying force on the end-effector on the robot arm. Collaborative robot arms have a zero gravity compensation mode, where the robot exerts just enough torque to compensate for the force applied by gravity. Under this mode, a human operator is able to move and guide a robot by applying force directly on the robot body.} $Path_{i}(O)$ consists of multiple sample points containing information of the pose of the end-effector. The path is recorded with a time frequency of $f_{i}(O)$ Hz. The position and Euler angles of the end-effector are recorded in the robot arm's base coordinate frame $XYZO_{B}$.
After collecting the above data for task $tk_{i}$ only once, the one-shot teaching comes to an end.
\subsection{Mobile manipulator process automation}\label{mobile-manipulator-process-automation}
In the current stage, to finish the task $tk_{i}$, the mobile manipulator process automation needs to accomplish the following four steps: (1) Firstly, the mobile platform navigates to the location $L_{i}(vehicle)$ and finally parks at the location $\tilde{L}_{i}(vehicle)$ autonomously (\textcolor{black}{Section~\ref{robot-navigation}}). (2) Then, the IPE algorithm calculates the relative 6D parking pose between the location $L_{i}(vehicle)$ and $\tilde{L}_{i}(vehicle)$ in the robot arm's base coordinate frame (\textcolor{black}{Section~\ref{iterative-pose-estimation}}). (3) Next, the adaptive online path learning part learns the difference in pose and modifies the initial robot end-effector path information $Path_{i}(O)$ into the new one $\widetilde{Path}_{i}(arm)$ in the robot arm's base coordinate frame\footnote{$Path_{i}(O)$ and $\widetilde{Path}_{i}(arm)$ are nearly the same in the world coordinate system.} (\textcolor{black}{Section~\ref{subsubsection:adaptive-online-path-learning}}). (4) Finally, the mobile manipulator carries out the task $tk_{i}$ using the newly-learned path $\widetilde{Path}_{i}(arm)$ (\textcolor{black}{Section~\ref{subsubsection:task-excution}}).
\subsubsection{Robot navigation}\label{robot-navigation}
During the automation stage, the mobile manipulator will attempt to navigate to the desired parking location autonomously $L_{i}(vehicle)$. However due to errors within the system, the robot will eventually park at a different location $\tilde{L}_{i}(vehicle)$ that is close to $L_{i}(vehicle)$. Due to the uneven ground, slippery floor, dynamic obstacles or some other random factors in the real working environment, the mobile platform usually cannot park precisely at the location $L_{i}(vehicle)$. Previous work using the 2D QR code template matching~\citep{iterative-learning-error-compensation2021} could only provide the mobile platform's relative 3D parking pose between the location $L_{i}(vehicle)$ and $\tilde{L}_{i}(vehicle)$. Given the acquired pose from the 2D QR code template matching has only three degrees of freedom, the pose could only be applied to the mobile platform to move on the 2D plane, which couldn't be used to calibrate the robot arm's path in 3D space. To get the extremely-accurate robot arm base's relative 6D pose between the location $L_{i}(vehicle)$ and $\tilde{L}_{i}(vehicle)$, the iterative 6D pose estimation by eye \& hand interaction will be proposed in the following part.
\subsubsection{IPE:Iterative pose estimation by eye \& hand}\label{iterative-pose-estimation}
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{figure/fig3_1column_1000dpi.JPG}
\caption{The iterative process by eye-hand interaction to search for the same sampling pose in the teaching stage in world frame.}
\label{fig:IPE}
\end{figure}
Figure~\ref{fig:IPE} shows the iterative process when performing the IPE algorithm. The robot arm's base coordinate system is $XYZO_{B_i}$ when reaching the location $\tilde{L}_{i}(vehicle)$. The robot arm will move the mounted depth camera iteratively to search for the initial sampling pose from the teaching stage. After $k^{th}$ movement of the robot arm, the camera coordinate system becomes $XYZO_{C_k}$. Figure~\ref{fig:flowchart} illustrates the flowchart of the proposed IPE algorithm. When the mobile manipulator reaches the working place in the automation mode, the IPE algorithm starts. The robot arm's new sampling pose is set to the initial one in the robot arm base coordinate frame when sampling the working environment's colored 3D point cloud in the one-shot teaching stage. Taking the system safety into account, if the new sampling pose of the end-effector is unreachable by the robot arm, the IPE algorithm will exit with the "False" execution flag. If the new sampling pose of the end-effector is available, the robot arm will move the end-effector to the new sampling pose to sample the working environment's colored point cloud $X_{i}(k), k=1,2,3,...$ ($k$ represents the $k^{th}$ movement of the robot arm in IPE). Then we calculate the relative 6D pose [$\Delta R_{C_{k}}$, $\Delta t_{C_{k}}$] between the sampled point cloud $X_{i}(O)$ from teaching stage and the sampled point cloud $X_{i}(k)$ in the current view in the automation stage through the colored point cloud global registration algorithm (See \textbf{\uppercase\expandafter{\romannumeral2}\quad Method: colored point cloud global registration} for more details). Then we will update the relative 6D parking pose [$\Delta R_{B}(k)$, $\Delta t_{B}(k)$] of the robot arm's base (For more details, see \textbf{\uppercase\expandafter{\romannumeral1}\quad \textcolor{black}{Justification}: dynamic pose update in different coordinate systems}). According to the updated relative parking pose [$\Delta R_{B}(k)$, $\Delta t_{B}(k)$], the next new sampling pose is set. If the pose difference [$\Delta R_{C_{k}}$, $\Delta t_{C_{k}}$] is below the threshold $\boldsymbol{\alpha}$, IPE will exit and return the relative 6D pose [$\Delta R_{B}(k)$, $\Delta t_{B}(k)$] in the robot arm's base coordinate system with a ``True" execution flag. If the pose difference [$\Delta R_{C_{k}}$, $\Delta t_{C_{k}}$] is above the threshold $\boldsymbol{\alpha}$ and the loop count is below the threshold $\beta$, IPE will run into the next loop and check if the new sampling pose is reachable or not. If the loop count is above the threshold $\beta$, the IPE algorithm will exit with the "False" execution flag.
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{figure/fig4_1column_1000dpi.jpg}
\caption{Flowchart of the proposed iterative pose estimation by eye-hand interaction approach (IPE).}
\label{fig:flowchart}
\end{figure}
\noindent \textbf{\uppercase\expandafter{\romannumeral1}\quad \textcolor{black}{Justification}: dynamic pose update in different coordinate systems}
IPE performs iterative pose estimation multiple times, which adjusts the sampling pose of the mounted depth camera incrementally by moving the robot arm to match the initial sampling pose of the camera in the one-shot teaching stage in the world frame. IPE relies on a unique property, that is, if the new sampling pose of the depth camera in the automation stage is closer to the initial sampling pose of the depth camera in one-shot teaching stage in the world frame, the newly sampled point cloud in automation stage will be more similar to the initial sampled point cloud in the one-shot teaching stage. It means there will be more common features for the colored point cloud registration to match thus to get a higher matching accuracy. Thus, in IPE algorithm, the robot arm tends to move the depth camera in an eye-hand iterative style\footnote{Eye-hand iterative style means doing registration and moving the mounted camera by the robot arm iteratively.} for multiple times to position the depth camera in its initial sampling pose in the one-shot teaching stage. \textcolor{black}{Experiments (see Figure~\ref{fig:IPE-performance-against-iteration}) show that with each iteration, the IPE rotation and translation errors gradually decrease. The result from the final iteration is more accurate than the result obtained from the first iteration. }
Due to the eye-hand dynamic iteration process, the robot arm has to change its configuration to reposition the depth camera constantly, therefore the spatial relationship between the depth camera and robot arm's base is constantly changing. In this part, given the dynamic camera pose and robot arm's dynamic movement, we will deduce the robot arm's base relative 6D pose between the teaching stage and the current automation stage.
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{figure/fig5_1column_1000dpi.JPG}
\caption{The figure illustrates how the relative parking pose of the robot arm's base can be calculated given the spacial relationship of the camera and base and the relationship between different camera poses.}
\label{fig:naviation-in-automation}
\end{figure}
Figure~\ref{fig:naviation-in-automation} shows the relative 6D pose between different coordinate systems.
$R^{C_o}_{B_o}$ and $t^{C_o}_{B_o}$ \textcolor{black}{represent} the rotation and translation matrix from the camera coordinate system to the robot arm's base coordinate system when sampling the working environment's colored point cloud in the one-shot teaching stage in task $tk_{i}$. $R^{C_k}_{B_k}$ and $t^{C_k}_{B_k}$ \textcolor{black}{represent} the rotation and translation matrix from camera coordinate system to robot arm's base coordinate system after the $k^{th}, k=1,2,3, ...$ movement of the robot arm in IPE. $S_{C_o}$ represents one 3D point in camera coordinate system, which corresponds to the 3D point $S_{B_{o}}$ in the robot arm's base coordinate system, in one-shot teaching stage. $S_{C_k}$ represents one 3D point in camera coordinate system, which corresponds to the 3D point $S_{B_{k}}$ in robot arm's base coordinate system, after the $k^{th}$ movement of the robot arm in the automation stage. $\Delta R_{C_k}$ and $\Delta t_{C_k}$ \textcolor{black}{represent} the camera's relative rotation and translation matrix between the teaching stage and the current automation stage after the $k^{th}$ movement of the robot arm. $\Delta R_{B_k}$ and $\Delta t_{B_k}$ \textcolor{black}{represent} the robot arm base's estimated relative rotation and translation matrix when sampling working environment's point cloud in one-shot teaching stage and after the $k^{th}$ movement of the robot arm during the iterative adjustment process.
\begin{align}
R^{C_o}_{B_o}S_{C_o}+t^{C_o}_{B_o}&=S_{B_o} \label{eq:11} \\
R^{C_k}_{B_k}S_{C_k}+t^{C_k}_{B_k}&=S_{B_k} \label{eq:12} \\
\Delta R_{C_k}S_{C_o}+\Delta t_{C_k} &= S_{Ck} \label{eq:13}\\
\Delta R_{B_k}S_{B_o}+\Delta t_{B_k} &= S_{B_k} \label{eq:14}
\end{align}
From equation \eqref{eq:11} and \eqref{eq:12} we get
\begin{align}
S_{C_o} &= R^{C_o-1}_{B_o}S_{B_o}- R^{C_o-1}_{B_o}t^{C_o}_{B_o} \label{eq:15}\\
S_{C_k} &= R^{C_k-1}_{B_k}S_{B_k}-R^{C_k-1}_{B_k}t^{C_k}_{B_k} \label{eq:16}
\end{align}
Substitute $S_{C_o}$ and $S_{C_k}$ in equation \eqref{eq:13} with equation \eqref{eq:15} and \eqref{eq:16}. We get
\begin{equation}
\begin{split}
&\Delta R_{C_k}\left( R^{C_o-1}_{B_o}S_{B_o}-R^{C_o-1}_{B_o}t^{C_o}_{B_o}\right)+\Delta t_{C_k} =\\
&R^{C_k-1}_{B_k}S_{B_k}-R^{C_k-1}_{B_k}t^{C_k}_{B_k}
\end{split} \label{eq:17}
\end{equation}
Reformulating the equation~\eqref{eq:17} by multiplying $R^{C_k}_{B_k}$ on the both sides, we get:
\begin{equation}
\begin{split}
&R^{C_k}_{B_k}\Delta R_{C_k}R^{C_o-1}_{B_o}S_{B_o}+ (-R^{C_k}_{B_k}\Delta R_{C_k}R^{C_o-1}_{B_o}t^{C_o}_{B_o}\\
&+R^{C_k}_{B_k}\Delta t_{C_k}+t^{C_k}_{B_k}) = S_{B_k}
\end{split} \label{eq:18}
\end{equation}
Comparing equation~\eqref{eq:18} and equation~\eqref{eq:14}, we get:
\begin{equation}
\Delta R_{B_k} = R^{C_k}_{B_k}\Delta R_{C_k}R^{C_o-1}_{B_o} \label{eq:19}
\end{equation}
\begin{equation}
\Delta t_{B_k} = -R^{C_k}_{B_k}\Delta R_{C_k}R^{C_o-1}_{B_o}t^{C_o}_{B_o}+R^{C_k}_{B_k}\Delta t_{C_k}+t^{C_k}_{B_k}
\label{eq:20}
\end{equation}
\noindent \textbf{\uppercase\expandafter{\romannumeral2}\quad Method: colored point cloud global registration}
In order to get the mounted camera's relative rotation matrix $\Delta R_{C_k}$ and translation matrix $\Delta t_{C_k}$, the colored point cloud global registration method\footnote{Readers could also use other 3D point cloud registration algorithms to replace the colored point cloud global registration in this part as well.} is proposed in this part by simply combining the fast global registration~\citep{fast-global-registration2016} and the local colored point cloud registration~\citep{colored-point-cloud-registration-2017} with some improved engineering techniques (e.g.: point cloud pre-processing, parameter fine-tuning, multi-scale matching, etc.). More specifically, the coarse global pose from the fast global registration~\citep{fast-global-registration2016} is fed into the colored point cloud registration~\citep{colored-point-cloud-registration-2017} algorithm to avoid the local minimum during the registration. The local algorithm~\citep{colored-point-cloud-registration-2017} takes not only the geometry information but also the color information into the account to achieve a better registration accuracy. The proposed method with the simple strategy above provides a robust and accurate 6D pose estimation for IPE framework, which meets the mobile manipulator process automation's localization requirement.
\subsubsection{Adaptive online path learning} \label{subsubsection:adaptive-online-path-learning}
The robot end-effector's path for performing task $tk_{i}$ is recorded in the robot arm's base frame during one-shot teaching. When the robot reaches the same working place again in the automation stage, the robot arm base's pose will differ from that of the one-shot teaching stage because of motion or system errors or some other random factors. To ensure the robot end-effector follows the desired path in the world frame to finish the manipulation task $tk_{i}$, the robot has to learn to adjust the reference path ${Path}_{i}(O)$ obtained in teaching stage to the new path $\widetilde{Path}_{i}(arm)$ in the robot arm's base coordinate frame in the automation stage.
Considering a sampled point $S_{B_o}$ from the recorded path ${Path}_{i}(O)$ in the teaching stage, the position of the end-effector is transferred from the teaching stage to the automation stage in the robot arm's base coordinate system using the following equation
\begin{align}
\Delta R_{B_k}S_{B_o}+\Delta t_{B_k} &= S_{B_k} \label{eq:21}
\end{align}
where $\Delta R_{B_k}$ and $\Delta t_{B_k}$ could be calculated using equation~\eqref{eq:19} and equation~\eqref{eq:20}. The sampled point $S_{B_k}$ is from the new execution path $\widetilde{Path}_{i}(arm)$ in automation stage.
\subsubsection{Task Execution} \label{subsubsection:task-excution}
After obtaining the newly-adjusted robot end-effector path $\widetilde{Path}_{i}(arm)$, some motion planning algorithm (e.g.: RRT*~\citep{RRT2011}, PRM~\citep{PRM1996}) could be used to compute the trajectory containing the target joint angles which are used to control the robot joints during execution. The acceleration, torque, velocity, and position limit of the robot joints are taken into account by the motion planning algorithm. \textcolor{black}{If the motion planing algorithm could compute a valid trajectory, the robot will execute the task. If not, the robot will abandon this task.}
\section{Experiment}\label{Experiment}
\subsection{Experiment Configuration}\label{experiment-configuration}
\begin{figure*}
\begin{center}
\subfloat{\includegraphics[width=1\linewidth]{figure/fig6_2column_1000dpi.jpg}}
\end{center}
\caption{Experiment configuration. (a) shows the experiment environment. The mobile manipulator will conduct experiments at site 0, site 1, site 2, site 2' (site 2 and site2' are in the same location). (b) shows the robot executing a task. (c) shows the executed path's accuracy test using a needle. (d) shows a speed bump installed at the parking place to emulate uneven terrain. (e) shows the pre-built map for robot navigation. \textcolor{black}{The black lines or dots in the occupancy map represent obstacles ("occupied"). The red lines or dots represent the laser scan which is used for localization. '0', '1' and '2' represent site 0, site 1 and site 2.}}
\label{fig:experiment-scene}
\end{figure*}
The mobile manipulator "Gagabot DR-03"\footnote{For more details, please refer to \url{http://www.amigaga.com/en/index.php?id=111}} is the platform to demonstrate the performance of the proposed method. Gagabot DR-03 consists of a two-wheeled differential mobile platform and a 6-DOF (\textcolor{black}{Degree of Freedom}) robot arm. A depth camera \textcolor{black}{"Intel Realsense D435"} is mounted at the end of the robot arm to perceive the environment. Inside Gagabot DR-03, an integrated industrial computer (Nvidia AGX Xavier) is used for the complex computation (e.g.: navigation, perception, planning, control, etc.). The Nvidia AGX Xavier (105 mm x 105 mm x 65 mm) is equipped with a 512-core Volta GPU, a 8-core ARM v8.2 64-bit CPU and 32GB memory. All the experiments in this paper were conducted with the Nvidia AGX Xavier (See Figure~\ref{fig:experiment-scene}). Figure~\ref{fig:experiment-scene}, (a) shows an image of the lab where we conduct the experiments. The robot will navigate from Site 0 to Site 1, Site 2, Site 2' to perform the experiments (Site 2 and Site2' are in the same location). (b) shows an example of the robot executing a task. (c) shows the executed path's accuracy test by using a needle. (d) shows a speed bump installed on the parking position to emulate uneven terrain. (e) shows the pre-built map from Gmapping~\citep{gmapping2007} for the robot navigation.
The experiments are divided into 3 groups given different working sites (Site 1, Site 2, Site 2'). Three different kinds of experiments and analysis are conducted for each group: 1) parking pose accuracy in Section~\ref{parking-pose-accuracy}, 2) IPE performance in Section~\ref{IPE-performance} and 3) executed path's accuracy in Section~\ref{excuted-path-accuracy}. Site 1\footnote{\textcolor{black}{Site 1 consists of cups, big liquid containers with valves, small bottles containing different liquid, desks, logo and letters printed on the tape.}} emulates a plant extract workshop to make the robot perform complex manipulation with a flat floor, such as switching the valve, fetching and returning the cup. Site 2\footnote{\textcolor{black}{Site 2 consists of glass and plastic reagent bottles (containing sodium hydroxide, hydrochloric acid, phenolphthalein, ferrum, seperately) , droppers, a waste disposal container, test tubes, a test tube stand, a desk, logo and letters printed on the tape.}} emulates a quality inspection center in a factory with a flat floor to test the liquid products by chemical reaction. Site 1 and Site 2 consists of only flat floor. However, in the real world, there are many harsh working environments where the floor is uneven. Taking real-world floor conditions into consideration, a speed bump\footnote{\textcolor{black}{The speed bump's shape is a triangular prism, with the size $1000mm * 350mm * 50mm $ ($length * width * height$). It weighs 11 $kg$ and has a surface with uneven 3D texture for increased friction. }} is installed at site 2 to emulate uneven terrain. The new site is denoted as site 2'.
Thus, we could get various 6D parking poses on a 3D surface for the experiments. We define this group of experiments with a speed bump to park on (see Figure~\ref{fig:experiment-scene} d) are at Site 2'. Each experiment is conducted 30 times. For an explicit overview of all the experiments, please see Table~\ref{table:count-experiments}. We have used two formats to describe the 6D pose. The first way is using a 6D vector $[tx, ty, tz, r, p, y]$ (short for [translation on $x$ axis, translation on $y$ axis, translation on $z$ axis, $roll$, $pitch$, $yaw$]). The unit is meter for $tx$, $ty$, $tz$ and degree for $r$, $p$, $y$. We use the difference between the estimated 6D vector and the ground truth to describe the 6D pose's error. The second way is using rotation matrix $\boldsymbol{R}$ and translation matrix $\boldsymbol{t}$. The equations for estimating the accuracy of the 6D poses are from~\citep{Metrics_3D_Rotation_huynh2009}:
\begin{align}
E_R = ||\boldsymbol{I-R_{gt}R_{est}^{-1}}||_{F} \label{eq:23}
\end{align}
\begin{align}
E_t = ||\boldsymbol{t_{gt}-t_{est}}||_{F}
\label{eq:24}
\end{align}
where $\boldsymbol{t_{est}, R_{est}}$ are the estimated values and $\boldsymbol{t_{gt}, R_{gt}}$ are the ground truth respectively. $|| \bullet || _{F}$ is the Frobenius norm. Readers should know that: Although the error estimation methods and their error value for the two formats above are different, they all could describe the 6D pose's accuracy.
\begin{table}[h!]
\centering
\caption{Number of Different Experiment Trials} \label{table:count-experiments}
\begin{tabular}{|p{1.5cm}|| p{1.5cm}| p{1.5cm}| p{1.5cm}|}
\hline
\textit{Factor} & \textit{Site 1} & \textit{Site 2} & \textit{Site 2'}\\
\hline
parking pose accuracy & 30 times & 30 times & 30 times \\
\hline
IPE performance & 30 times & 30 times & 30 times \\
\hline
executed path's accuracy & 30 times & 30 times & 30 times\\
\hline
\end{tabular}
\end{table}
\subsection{Parking Pose Accuracy}\label{parking-pose-accuracy}
Analysis is performed to observe if there is any relationship between the parking pose's accuracy and IPE performance. In each experiment, the robot will be required to navigate to a specified location. To get the ground truth of the relative parking pose, the end-effector is pointed to a fixed point with a fixed pose when the mobile base parks at the specified location. The transformation matrix from the robot arm's base to the fixed point is $T_0$. When the mobile base navigates to the specified location again, we let the end-effector point to that fixed same point with that same pose. The current transformation matrix from the robot arm's base to the fixed point is $T_1$. Given the robot arm is extremely accurate with a repeatability of 0.1mm, we use the product of those transformation matrixes $T_0 T^{-1}_{1}$ to represent the ground truth of the relative parking pose.
We designate the position (2.0415, -1.375, 0.0) with orientation (0.0, 0.0, -0.2970, 0.9548) (represented by \textcolor{black}{unit} quaternion) as Site 1 in the map ( See Figure~\ref{fig:experiment-scene} e ). We specify the position (0.1251, -0.7638, 0.0) with orientation (0.0, 0.0, -0.8785, 0.4776) (represented by \textcolor{black}{unit} quaternion) as Site 2. The starting point's position (site 0) is (-0.3498, 0.9449, 0.0) with a orientation (0.0, 0.0, -0.5367, 0.8437). The mean and standard deviation of the relative parking pose are listed in Table~\ref{table:parking-pose-accuracy} by using the 6D vector $[tx, ty, tz, r, p, y]$ format.
If we use Equation~\eqref{eq:23} and Equation~\eqref{eq:24} to describe the error,
the mean rotation error is 0.0617 at Site 1, 0.0614 at Site 2, 0.2910 at Site 2'. The standard deviation of the rotation error is 0.0418 at Site 1, 0.0433 at Site 2, 0.2213 at Site 2'. The mean translation error is 0.1018 m at Site 1, 0.0799 m at Site 2, 0.1304 m at Site 2'. The standard deviation of the translation error is 0.0176 m at Site 1, 0.0316 m at Site 2, 0.0594 m at Site 2'.
Note that this is the uncorrected initial base positioning error.
\begin{table}[h!]
\centering
\caption{Initial Parking Pose Accuracy} \label{table:parking-pose-accuracy}
\begin{tabular}{|p{1.5cm}|| p{1.5cm}| p{1.5cm}| p{1.5cm}|}
\hline
\textit{Factor} & \textit{Site 1} & \textit{Site 2} & \textit{Site 2'}\\
\hline
$\overline{tx}$ / (m) & 0.0011 & 0.0505 & 0.0779 \\
\hline
$\sigma_{tx}$ / (m) & 0.0281 & 0.0287 & 0.0569 \\
\hline
$\overline{ty}$ / (m) & -0.0995 & 0.0539 & 0.0261\\
\hline
$\sigma_{ty}$ / (m) & 0.0179 & 0.0287 & 0.1060 \\
\hline
$\overline{tz}$ / (m) & -0.0012 & -0.0011 & -0.0042 \\
\hline
$\sigma_{tz}$ / (m) & 0.0013 & 0.0014 & 0.0054\\
\hline
$\overline{r}$ / (deg) & 0.2151 & 0.1155 & 0.0079 \\
\hline
$\sigma_{r}$ / (deg) & 0.1593 & 0.0784 & 1.2595 \\
\hline
$\overline{p}$ / (deg) & -0.0036 & -0.1733 & 0.7932\\
\hline
$\sigma_{p}$ / (deg) & 0.1439 & 0.1295 & 2.6967 \\
\hline
$\overline{y}$ / (deg) & 0.0023 & 1.6706 & -1.9701 \\
\hline
$\sigma_{y}$ / (deg) & 2.9214 & 2.7079 & 14.7211\\
\hline
\end{tabular}
\end{table}
\subsection{IPE Performance}\label{IPE-performance}
From Equation~\ref{eq:19} and Equation~\ref{eq:20}, the relative parking pose ($\Delta R_{B_k}$, $\Delta t_{B_k}$) and the relative camera pose ($\Delta R_{C_k}$, $\Delta t_{C_k}$) could be deduced or calculated from each other. Thus, we will only test the accuracy of the relative parking pose ($\Delta R_{B_k}$, $\Delta t_{B_k}$) in this part. The method for obtaining the ground truth of relative parking pose is the same in Section~\ref{parking-pose-accuracy}. A threshold has to be set to indicate convergence. We set the convergence threshold $\boldsymbol{\alpha}$ of the sampling pose difference $(x, y, z, roll, pitch, yaw)$ as (0.002m, 0.002m, 0.002m, $0.5^\circ$, $0.5^\circ$, $0.5^\circ$). The maximum iteration number $\beta$ is set as 5 for Site 1, Site 2 and 10 for Site 2' because the situation at Site 2' is harder than those at Site 1, Site 2. This is because the uneven terrain emulated by the speed bump will introduce more changes for point cloud matching in the $z$ axis, roll and pitch orientation, compared to the flat terrain case of Site 1 and Site 2.
Figure~\ref{fig:IPE-process-point-cloud} shows one example of the IPE matching. In Figure~\ref{fig:IPE-process-point-cloud}, (a) - (c) show the point clouds (from the depth camera) after $k^{th}$ movement of the robot arm in IPE. (d) is the point cloud sampled during teaching stage. (e) shows the scene before matching the point cloud (a) and (d). (f) shows the scene before matching point cloud (b) and (d). (g) shows the scene before matching the point cloud (c) and (d). Note the improved alignment. (h) is the RGB image of the scene. (i) - (l) are the local \textcolor{black}{patches} from (e) - (h). With each iteration $k$, the scene [(a), (b) (c)] gets closer to the original (d). That is, the current depth camera pose gets closer iteratively to the sampling pose from the teaching stage. With each additional iteration of the IPE, the registration result [(e),(f),(g)] gradually improves. (i) - (k) shows the details of the registration's accuracy. Compare the word "AMIGAGA TECHNOLOGY" in (j) and (k), some parts are missing in (j).
\begin{figure}
\begin{center}
\subfloat{\includegraphics[width=1\linewidth]{figure/fig7_2column_1000dpi.jpg}}
\end{center}
\caption{IPE process. (a) - (c) show the point clouds (from the depth camera) after $k^{th}$ movement of the robot arm in IPE. (d) is the point cloud sampled during teaching stage. (e) shows the scene before matching the point cloud (a) and (d). (f) shows the scene before matching point cloud (b) and (d). (g) shows the scene before matching the point cloud (c) and (d).
(h) is the RGB image of the scene. (i) - (l) are the local \textcolor{black}{pathes} from (e) - (h).\textcolor{black}{(Readers are encouraged to view the electronic version of the paper for clearer visual details.)}}
\label{fig:IPE-process-point-cloud}
\end{figure}
In Table~\ref{table:IPE-accuracy}, the mean
$[\overline{\Delta{tx}}, \overline{\Delta{ty}}, \overline{\Delta{tz}}, \overline{\Delta{r}}, \overline{\Delta{p}}, \overline{\Delta{y}}]$ and standard deviation
$[\sigma_{{\Delta{tx}}}, \sigma_{{\Delta{ty}}}, \sigma_{{\Delta{tz}}}, \sigma_{{\Delta{r}}}, \sigma_{{\Delta{p}}}, \sigma_{{\Delta{y}}}]$ of the error between the IPE estimation ($\Delta R_{B_k}$, $\Delta t_{B_k}$) and ground truth are given. While using the rotation matrix and translation matrix criteria shown in Equation \eqref{eq:23} and Equation \eqref{eq:24} as error measures, the mean rotation error between IPE estimation and ground truth is 0.0169 at Site 1, 0.0183 at Site 2, 0.0225 at Site 2'. The standard deviation of the rotation error is 0.0074 at Site 1, 0.0063 at Site 2, 0.0103 at Site 2'. The mean translation error is 0.0049 m at Site 1, 0.0054 m at Site 2, 0.0089 m at Site 2'. The standard deviation of the translation error is 0.0025 m at Site 1, 0.0019 m at Site 2, 0.0044 m at Site 2'. From the results above, it can be seen that IPE exhibits high accuracy.
\begin{table}[h!]
\centering
\caption{The error of IPE's estimation ($\Delta R_{B_k}$, $\Delta t_{B_k}$) } \label{table:IPE-accuracy}
\begin{tabular}{|p{1.5cm}|| p{1.5cm}| p{1.5cm}| p{1.5cm}|}
\hline
\textit{Factor} & \textit{Site 1} & \textit{Site 2} & \textit{Site 2'}\\
\hline
$\overline{\Delta{tx}}$ / (m) & 0.0001 & 0.0000 & -0.0004 \\
\hline
$\sigma_{{\Delta{tx}}}$ / (m) & 0.0004 & 0.0002 & 0.0005 \\
\hline
$\overline{\Delta{ty}}$ / (m) & 0.0009 & 0.0010 & -0.0005\\
\hline
$\sigma_{{\Delta{ty}}}$ / (m) & 0.0010 & 0.0009 & 0.0007 \\
\hline
$\overline{\Delta{tz}}$ / (m) & 0.0007 & -0.0009 & -0.0010 \\
\hline
$\sigma_{{\Delta{tz}}}$ / (m) & 0.0012 & 0.0008 & 0.0010 \\
\hline
$\overline{\Delta{r}}$ / (deg) & 0.0190 & -0.0106 & 0.0088 \\
\hline
$\sigma_{{\Delta{r}}}$ / (deg) & 0.1472 & 0.0123 & 0.0469 \\
\hline
$\overline{\Delta{p}}$ / (deg) & 0.0495 & -0.1218 & -0.1046\\
\hline
$\sigma_{{\Delta{p}}}$ / (deg) & 0.1317 & 0.1119 & 0.1090 \\
\hline
$\overline{\Delta{y}}$ / (deg) & -0.1338 & -0.1423 & 0.0311 \\
\hline
$\sigma_{{\Delta{y}}}$ / (deg) & 0.1413 & 0.1221 & 0.0744 \\
\hline
\end{tabular}
\end{table}
\begin{figure*}
\begin{center}
\subfloat{\includegraphics[width=1\linewidth]{figure/fig8_2column_1000dpi.jpg}}
\end{center}
\caption{Error Relationship between Parking and IPE.}
\label{fig:error-relationship-between-parking-and-IPE}
\end{figure*}
Figure~\ref{fig:error-relationship-between-parking-and-IPE} shows the error relationship between the actual parking pose and IPE's estimation. Figure~\ref{fig:error-relationship-between-parking-and-IPE} (a) shows the error relationship between the actual parking's rotation and the estimated rotation from IPE. Figure~\ref{fig:error-relationship-between-parking-and-IPE} (b) shows the error relationship between the actual parking's rotation and the estimated translation (unit: m) from IPE.
Figure~\ref{fig:error-relationship-between-parking-and-IPE} (c) shows the error relationship between the actual parking's translation (unit: m) and the estimated rotation from IPE.
Figure~\ref{fig:error-relationship-between-parking-and-IPE} (d) shows the error relationship between the actual parking's translation (unit: m) and the estimated translation (unit: m) from IPE.
Generally, when doing point cloud registration, with every increment of the initial rotation and translation misalignment, the 6D pose estimation error will increase as well. However, with IPE, this is not the case. From Figure~\ref{fig:error-relationship-between-parking-and-IPE}, we find that the initial rotation and translation change resulting from the parking pose doesn't influence the IPE estimation (i.e. no linear relationship). No matter what the initial rotation and translation is, the IPE's translation estimation error is always below 0.02m and its rotation estimation error is always below 0.02. Note that the IPE error is considerably smaller than the `Parking' error in the Section~\ref{parking-pose-accuracy}. The reason is that IPE has used an iterative way to move the robot arm to sample multiple point clouds at different views until the sampling pose is nearly the same with that at the teaching stage.
The final accuracy of IPE will be influenced by the 6D pose estimation method inside IPE (e.g.: we use the colored point cloud registration in this paper). Given that the colored point cloud global registration is proposed in other work~\citep{colored-point-cloud-registration-2017,fast-global-registration2016} and is not the contribution of this paper, experiments for testing the performance of the global colored point cloud registration are omitted. Readers could be directed to the original two papers~\citep{colored-point-cloud-registration-2017,fast-global-registration2016} for more information.
From this part, the experiment shows the IPE's strong robustness and accuracy, which is not influenced by the initial rotation and translation.
\begin{figure*}
\begin{center}
\subfloat{\includegraphics[width=1\linewidth]{figure/fig9_2column_1000dpi.jpg}}
\end{center}
\caption{IPE performance within each iteration.}
\label{fig:IPE-performance-against-iteration}
\end{figure*}
Figure~\ref{fig:IPE-performance-against-iteration} shows the performance of the IPE algorithm at each iteration. Figure~\ref{fig:IPE-performance-against-iteration} (a) - (c) shows the IPE's estimated rotation error at each iteration for Site 1, Site 2, Site 2'. (d) - (f) shows the IPE's estimated translation error at each iteration for Site 1, Site 2, Site 2'. (g) - (i) shows the distribution of the number of iterations to convergence at Site 1, Site 2, Site 2'. (j) - (l) shows the average running time for registration at $k^{th}$ iteration. From (a) - (f), we find that with every increasing iteration, both the mean and standard deviation of the rotation error and translation error gradually decreases, indicating an increase in accuracy and robustness.
\textcolor{black}{
The reason is that IPE adjusts the sampling pose of the mounted depth camera incrementally by moving the robot arm to match the initial sampling pose of the camera in the one-shot teaching stage in the world frame. Thus, the newly sampled point cloud in the latest iteration in the automation stage will be more similar to the initial sampled point cloud in the one-shot teaching stage. It means there will be more common features for the colored point cloud registration to match to get a higher matching accuracy.
}
From (g) - (i), we find that IPE needs at least 2 iterations to converge and the majority of the experiments converge by iteration 3-5.
\textcolor{black}{The result from the final iteration (in which IPE converges) is more accurate than the result obtained from the first iteration.
It proves that the eye-hand iterative strategy in IPE could efficiently reduce the pose estimation error by incrementally positioning the depth camera closer to its initial sampling pose in the one-shot teaching stage.
}
From (j) to (l), we find that the average running time of each registration is stable, usually ranging from 1.5s - 1.7s.
\textcolor{black}{It shows IPE's strong robustness against the rotation and translation perturbation.}
In future work, GPU-based acceleration could be implemented to \textcolor{black}{speed up the point cloud registration algorithm inside IPE in each iteration}.
All the experiments on Site 1, Site 2, Site2' are successful and don't exit from IPE algorithm with failure (see Figure~\ref{fig:flowchart}, "Execution flag = False" ) because the robot arm's operating range (radius = 0.8 m) is big enough to compensate for the parking error. If the robot parks too far away from the taught position (e.g. > 0.8 meter) and the robot arm fails to find a feasible solution to move the depth camera to the desired pose in the next iteration, IPE will abort with failure definitely. If the colored point cloud global registration could not get converged to make the pose difference fall below the threshold $\boldsymbol{\alpha}$ even when the IPE's loop count exceeds the maximum iteration number $\beta$, IPE will abort with failure as well. Given that the colored point cloud global registration is proposed in other work~\citep{colored-point-cloud-registration-2017,fast-global-registration2016} and is not the contribution of this paper, experiments for testing the performance of the global colored point cloud registration are omitted. \textcolor{black}{The two original papers~\citep{colored-point-cloud-registration-2017,fast-global-registration2016} have given their performance (robustness and accuracy) against noise, density, occlusion, overlapping rate, rotation and translation perturbation of the input point clouds.}
\subsection{Executed Path's Accuracy}\label{excuted-path-accuracy}
In this part, the position accuracy of the end-effector's path $\widetilde{Path}_{i}(arm)$ will be tested. A needle is attached to the end-effector (See Figure~\ref{fig:experiment-scene} c). The needle tip is pointed at a specified point on the paper (recorded by a red dot) during the teaching stage and the needle tip is required to point to the same point during the automation stage. The bias of the needle tip's position (recorded by a black dot at each trial) from the specified target point (recorded by a red dot) over 30 trials during automation stage is used to show the accuracy of the executed path's position. Figure~\ref{fig:needle-tip} records the needle tip's positions in different trials.
Because the recorded dots crowd in a very small area (e.g.: a small circle with 2 - 3 mm radius) it is not easy to calculate the distance between each black dot and the red dot accurately enough. Thus, we only measure the maximum distance bias, the mean distance bias and its standard deviation to describe the position accuracy of the point on the executed path in a rough and approximated manner. According to the experiment results (maximum distance bias is 2.0 mm at Site 1, 2.4 mm at Site 2, 2.8 mm at at Site 2'; mean distance bias is 1.0 mm at Site 1, 1.1 mm at Site 2, 1.2 mm at at Site 2'; standard deviation of the distance bias is 0.5 mm at Site 1, 0.5 mm at Site 2, 0.6 mm at at Site 2'), the end-effector's position accuracy could meet the accuracy requirement of the most applications in daily life.
\textcolor{black}{The factors that contributes to the executed path's high accuracy are the high pose estimation accuracy of IPE and the high repeatability of the collaborative robot arm ($\pm 0.1$mm).}
This experiment only measures the position accuracy of the executed path, because the orientation of the end-effector\footnote{Except the position of the end-effector, the rest parameters of the robot arm's joints are not fixed and calculated by some motion planning algorithm (e.g.: RRT*~\citep{RRT2011}, PRM~\citep{PRM1996}).} is not as important as the position for many manipulation tasks.
\begin{figure*}
\begin{center}
\includegraphics[width=\linewidth]{figure/fig10_2column_1000dpi.jpg}
\end{center}
\caption{The record of needle tip's positions at different sites. (10x magnification) \textcolor{black}{(Readers are encouraged to view the electronic version of the paper for clearer visual details.)}}
\label{fig:needle-tip}
\end{figure*}
\section{\textcolor{black}{Discussion}} \label{Discussion}
\textcolor{black}
In this work, we collect human demonstration data for one-shot teaching through kinesthetic guidance, i.e. guiding the robot through physical contact~\citep{zhu2018robotLearning}. Recent advance in deep learning and imitation learning has allowed the robot arm to learn to perform manipulation tasks by extracting knowledge from human demonstration within videos, eliminating the need of a human to teach the robot through physical contact, thus increasing efficiency and safety \citep{yu2018oneShot, yang2019learningActions}. In the future, we will further improve our one-shot teaching procedure by exploring state-of-the-art deep learning and imitation learning approaches.
}
\textcolor{black}{
The colored point cloud registration used in the proposed IPE algorithm for recovering 6D parking pose is accurate but slow. Furthermore, the cheap "Intel Realsense D435" depth sensor used in the paper is sensitive to the ambient lighting and temperature, which will have a negative impact on the retrieved point cloud's quality, resulting in bad point cloud registration results. In future work, a faster and more robust 6D pose estimation algorithm will be explored. Depth fusion algorithms (e.g.~\citep{sdf-man,UDFNet}) will be explored using a cheap depth sensor (e.g.: Intel Realsense D435) rather than the expensive sensors (e.g.: Pickit 3D, Zivid) to improve the input point cloud's quality as well. Additionally, the proposed framework in this paper will be further tested in more realistic environments that accurately resemble real-world scenarios such as factory manufacturing, food servicing, quality inspection, etc..
}
\textcolor{black}{
Obstacle avoidance is necessary for the robot arm to work in unpredictable dynamic environments where safety is crucial, such as environments with constant human-robot interaction\citep{lin2017realTime}. The work in this paper focuses on industrial environments such as automated factories. Considering that there is little human interaction within automated factories, the environment remains unchanged throughout the operation. As long as the trajectory is planned and executed properly, it is unlikely for collisions to happen. Thus, collision avoidance was not necessary and therefore not the focus of this work. Additionally, the robot arm has collision detection functionality built-in within the controller as a safety mechanism by the robot arm manufacturer. Whenever the robot arm senses a collision with an object, it will perform an emergency stop to prevent damage \citep{haddadin2017robotCollisions}. For future work, collision avoidance can be implemented to allow the mobile manipulator to operate in environments that have uncertain changes over time due to human interactions, such as restaurants. Further hardware upgrades will be done to include more depth cameras, as the current depth camera mounted on the robot arm is not able to construct the real-time $360^{\circ}$ 3D map of the surroundings needed for collision avoidance algorithms.
}
\textcolor{black}{
A proper physical gripper is important for a successful manipulation of the rigid or non-rigid items. In the real-life setting, the engineers have to design the proper grippers for different kinds of items which need to be manipulated. The manual design process is time-consuming and expensive. In future work, we will explore the possibility of developing algorithms to autonomously design the physical grippers given the 3D model of the target items.
}
\section{Conclusions}\label{Conclusion}
This paper presents a framework for flexible manufacturing that allows a robot to redo multiple industrial tasks at different sites in a hostile industrial environment, after one-shot teaching by a human operator. The framework consists of two stages: the teaching stage and the automation stage. During the teaching stage, the location of the robot base and the path of the robot arm's end-effector have been recorded. During automation stage, the aim is to make the robot arm's end-effector repeat a path as same as the reference path in the world frame. The key for mobile manipulator process automation is the accurate estimation of the relative 6D parking pose between the teaching stage and the automation stage, which is used to adjust the path of the robot arm end-effector. Thus, we propose the IPE algorithm to estimate an accurate relative 6D pose by registering to the camera's initial sampling pose (at teaching stage) in the world coordinate system iteratively.
\printcredits
\section*{Declaration of Competing Interest}
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
\section*{Acknowledgement}
The research funding is from Shenzhen Amigaga Technology Co. Ltd. by the Gagabot2022 project (Grant Agreement No. P987001), from the Human Resources and Social Security Administration of Shenzhen Municipality by Overseas High-Caliber Personnel project (Grant NO. 202102222X, Grant NO. 202107124X) and from Human Resources Bureau of Shenzhen Baoan District by High-Level Talents in Shenzhen Baoan project (Grant No. 20210400X, Grant No. 20210402X) .
| {'timestamp': '2023-02-10T02:08:09', 'yymm': '2302', 'arxiv_id': '2302.04486', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04486'} | arxiv |
\section{Introduction}
Initialization of parameters has long been identified as playing a critical role in improving both the convergence and generalization performance of deep neural networks \citep{glorot2010understanding, erhan2010does, he2015delving}. In recent years, however, various normalization techniques, such as batch normalization \citep{ioffe2015batch}, layer normalization \citep{ba2016layer}, and weight normalization \citep{salimans2016weight}, have been found to somewhat reduce this heavy reliance on the initialization of parameters.
The normalization techniques have done so by preserving some of the conditions that motivated various initialization schemes throughout training more explicitly. For instance, batch normalization normalizes each neuron to have zero mean and unit variance across examples within a minibatch, which is what Xavier initialization \citep{glorot2010understanding} and He initialization \citep{he2015delving} aim to achieve in an ideal situation.
Although batch normalization has been widely used for training deep neural networks \citep{he2016deep,tan2019efficientnet}, there are a small number of studies about why it helps training \citep{santurkar2018does}. Rather than revealing its theoretical effect, several researchers studied whether batch normalization is really necessary by training deep neural networks without batch normalization. \citet{zhang2019fixup} have proposed Fixup initialization replacing batch normalization in ResNet \citep{he2016deep} by adding additional parameters to each residual block. \citet{brock2021high} have also succeeded to train ResNet with adaptive gradient clipping that adjusts unit-wise ratio of gradient norms to parameter norms during training. The similarity among their algorithms and batch normalization is that they add their own schemes to adaptively supervise optimization of the deep neural networks.
We suspect that the necessity for such adaptation comes from some neighborhood properties of an initial parameter configuration. Training is an optimization process finding an optimal parameter configuration which well-approximates a particular task derived from input data in the parameter space. It means that each parameter configuration corresponds to each task but this is not necessarily one-to-one. We hypothesize that training encourages the current parameter configuration to converge to the nearest optimal parameter configuration from the initial one. If there is no optimal solution near the initial parameter configuration, then the current parameter configuration either deviates from the initial parameter configuration (exploding gradient) or stays around it (vanishing gradient). We thus propose an algorithm to find a initial parameter configuration that can solve various tasks in their neighborhood.
Before finding such initial parameter configuration, we first need to check whether a given network solves any task derived from the input data. \citet{zhang2016understanding} empirically showed that over-parametrization of deep neural networks enables them to memorize the entire dataset so that they can be fitted to its arbitrary target task. Based on this, \citet{pondenkandath2018leveraging} have empirically demonstrated that pre-training on random labels can accelerate training on downstream tasks. However, \citet{maennel2020neural} has shown that the random label pre-training sometimes hurts the convergence of fine-tuning on the downstream tasks. They also presented that the pre-trained model generalizes worse than randomly initialized networks even if the random label pre-training promotes learning on the downstream task. For these studies, we further conjecture that a given over-parametrized network can solve any task in its parameter space, but it cannot do this at a single parameter configuration.
We therefore decide to utilize a set of parameter configurations, where we can find an optimal parameter configuration for any target task. If this set can be accumulated to the vicinity of one parameter configuration, we view this configuration as a good initial parameter configuration. To do this, we first restrict possible downstream tasks to $d$-way classification to make the model output domain be the same as a $(d-1)$-dimensional unit simplex defined in \eqref{def:simplex}. We then define a neighbor of the initial parameter configuration as small perturbation to this. Our unsupervised algorithm encourages each neighbor to solve a different task so that optimizers based on stochastic gradient descent such as Adam \citep{kingma2014adam} can easily find a solution near our initial parameter configuration.
We offer the mathematical statement for our conjecture in \S\ref{sec:uniform}, and propose an optimization problem to satisfy our claim for a given input. In doing so, we observe two possible degenerate cases to achieve our goal. In \S\ref{sec:under-class} and \S\ref{sec:input_ignoring}, we present how to avoid these unwanted situations. We validate our algorithm by various binary tasks derived from MNIST \citep{lecun1998gradient}
in \S\ref{sec:main_exp}. From these experiments, we observe that fine-tuning deep neural networks from our initial parameters improves average test accuracy across the various binary tasks, and this gain is greater when the number of labelled examples is small.
\section{Preliminaries and notations}
\paragraph{Norms}
Unless explicitly stated, a norm $\|\cdot\|$ refers to $L^2$ norm. We denote the Frobenius norm of a matrix ${\bm{A}}\in\mathbb{R}^{m\times n}$ by
$\|{\bm{A}}\|_F=\sqrt{\sum_{i=1}^m\sum_{j=1}^n A_{ij}^2}$,
where $A_{ij}$ is the $(i,j)$-th entry of ${\bm{A}}$. We write the $L^2$ operator norm of ${\bm{A}}$ as
$\|{\bm{A}}\|^*=\sup_{\|{\bm{x}}\|=1} \|{\bm{A}}{\bm{x}}\|$,
where ${\bm{x}}\in\mathbb{R}^n$.
\paragraph{Supports} For a distribution $p({\bm{x}})$, we write its support as
$\texttt{supp}(p({\bm{x}}))=\{{\bm{x}}\in\mathbb{R}^n\mid p({\bm{x}})>0\}.$
\paragraph{Model prediction}
A model prediction for $d$-way classification is a point in the $(d-1)$-dimensional unit simplex $\Delta^{d-1}\subset\mathbb{R}^d$ defined by
\begin{align}
\label{def:simplex}
\Delta^{d-1}=\left\{(p_1,p_2,\cdots,p_d)\in\mathbb{R}_{{\geq}0}^{d} :\sum_{i=1}^{d} p_i = 1\right\},
\end{align}
where $\mathbb{R}_{\geq0}$ is the set of non-negative real numbers. We refer to a prediction of the model parametrized by ${\bm{\theta}}$ for an input ${\bm{x}}$, as ${\bm{f}}_{\bm{\theta}}({\bm{x}})\in\Delta^{d-1}$.
\paragraph{Uniform distribution over $\Delta^{d-1}$}
In this paper, we mainly deal with the uniform distribution over $\Delta^{d-1}$, $\mathcal{U}(\Delta^{d-1})$. We can generate its random sample ${\bm{u}}$ by
\begin{align}
\label{eq:sampling_uniform_simplex}
{\bm{u}}=\left(\frac{{\bm{e}}_1}{\sum_{i=1}^d {\bm{e}}_i},\frac{{\bm{e}}_2}{\sum_{i=1}^d {\bm{e}}_i},\cdots,\frac{{\bm{e}}_d}{\sum_{i=1}^d {\bm{e}}_i}\right),
\end{align}
where each ${\bm{e}}_i$ is independently drawn from $\texttt{exponential}(1)$ \citep{marsaglia1961uniform}.
\paragraph{Maximum mean discrepancy (MMD)}
The MMD \citep{gretton2012kernel} is a framework for comparing two distributions $p({\bm{x}})$ and $q({\bm{y}})$ when we have samples from both distributions. The kernel MMD is defined by
\begin{align}
\label{def:mmd}
\texttt{MMD}(p({\bm{x}}),q({\bm{y}});\gamma) =&\mathbb{E}_{{\bm{x}}\sim p({\bm{x}})}\mathbb{E}_{{\bm{x}}'\sim p({\bm{x}})}[k_\gamma({\bm{x}}, {\bm{x}}')]
\\
&-2\mathbb{E}_{{\bm{x}}\sim p({\bm{x}})}\mathbb{E}_{{\bm{y}}\sim q({\bm{y}})}[k_\gamma({\bm{x}}, {\bm{y}})]
\nonumber
\\
&+\mathbb{E}_{{\bm{y}}\sim q({\bm{y}})}\mathbb{E}_{{\bm{y}}'\sim q({\bm{y}})}[k_\gamma({\bm{y}}, {\bm{y}}')],
\nonumber
\end{align}
where $k$ is a kernel function. A Gaussian kernel is often used, i.e., $k_\gamma({\bm{x}},{\bm{y}})=\exp\left(-\frac{\|{\bm{x}}-{\bm{y}}\|^2}{2\gamma^2}\right)$. \citet{gretton2012kernel} showed that $p({\bm{x}})=q({\bm{y}})$ in distribution if and only if $\texttt{MMD}(p({\bm{x}}),q({\bm{y}});\gamma)=0$.
\section{Unsupervised learning of initialization}
\label{sec:theory}
We start by conjecturing that the parameter configuration for any $d$-way classification must be in the vicinity of {\it good} initial parameters. In other words, a parameter configuration, that solves any $d$-way classification task, is near the initial parameter configuration, so that such configuration can be readily found by stochastic gradient descent using labelled examples. The question we answer here is then how we can identify such an initial parameter configuration given a set of unlabelled examples.
\subsection{Uniformity over all mappings}
\label{sec:uniform}
Let ${\bm{f}}_{\bm{\theta}}({\bm{x}})\in \mathbb{R}^d$ be an output of a deep neural network parametrized by ${\bm{\theta}}\in\mathbb{R}^m$ given an input ${\bm{x}}\in \mathbb{R}^n$ sampled from an input distribution $p({\bm{x}})$. In supervised learning, there is a target mapping ${\bm{f}}^*$
defined on $\texttt{supp}(p({\bm{x}}))$, and we want to find ${\bm{\theta}}^*$ that
\begin{align}
\label{eq:general_supervised_learning}
\min_{{\bm{\theta}}\in\mathbb{R}^m} l({\bm{f}}_{\bm{\theta}}, {\bm{f}}^*),
\end{align}
for a given loss function $l$. For example, we often use $l({\bm{f}}_{\bm{\theta}}, {\bm{f}}^*)=\mathbb{E}_{{\bm{x}}\sim p({\bm{x}})}[\|{\bm{f}}_{\bm{\theta}}({\bm{x}})-{\bm{f}}^*({\bm{x}})\|^2]$ for regression and $l({\bm{f}}_{\bm{\theta}}, {\bm{f}}^*)=\mathbb{E}_{{\bm{x}}\sim p({\bm{x}})}[\texttt{KL}({\bm{f}}^*({\bm{x}})||{\bm{f}}_{\bm{\theta}}({\bm{x}}))]$ for classification task, where $\texttt{KL}({\bm{f}}^*({\bm{x}})||{\bm{f}}_{\bm{\theta}}({\bm{x}}))$ is the Kullback-Leibler (KL) divergence from ${\bm{f}}_{\bm{\theta}}({\bm{x}})$ to ${\bm{f}}^*({\bm{x}})$.
In deep learning, it is usual to search for an optimal solution ${\bm{\theta}}^*$ from \eqref{eq:general_supervised_learning} in the full parameter space $\mathbb{R}^m$ by using a first-order optimizer, such as SGD and Adam \citep{kingma2014adam}. In this process, \citet{hoffer2017train} have demonstrated however that
\begin{align}
\label{eq:ultra_slow_diffusion}
\|{\bm{\theta}}_t - {\bm{\theta}}_0\| \sim \log t,
\end{align}
where ${\bm{\theta}}_t$ is a vector of parameters at the $t$-th optimization step and ${\bm{\theta}}_0$ is that of initial parameters.
In other words,
the rate of deviation from ${\bm{\theta}}_0$ decreases as training progresses. It means that the first order optimizer tends to find an optimal solution near the initial point. We thus rewrite \eqref{eq:general_supervised_learning} as
\begin{talign}
\label{eq:nbd_supervised_learning}
{\bm{\theta}}^* = \argmin_{{\bm{\theta}}\in {\mathbb{B}}_r({\bm{\theta}}_0)} l({\bm{f}}_{\bm{\theta}}, {\bm{f}}^*),
\end{talign}
where ${\mathbb{B}}_r({\bm{\theta}}_0)$ is a $r$-ball centered at ${\bm{\theta}}_0$, ${\mathbb{B}}_r({\bm{\theta}}_0)=\{{\bm{\theta}}\in\mathbb{R}^d:\|{\bm{\theta}}-{\bm{\theta}}_0\|<r\}$.
With this in our mind, what is the good initialization ${\bm{\theta}}_0$ for \eqref{eq:nbd_supervised_learning}? To answer this question, we look at what kind of classifiers we have within ${\mathbb{B}}_r({\bm{\theta}}_0)$. If ${\bm{x}}$ is an example randomly drawn from the input distribution $p({\bm{x}})$, the set of all possible model outputs from ${\bm{x}}$ in ${\mathbb{B}}_r({\bm{\theta}}_0)$ is
\[
{\mathbb{F}}({\bm{x}};{\bm{\theta}}_0)=\{{\bm{f}}_{\bm{\theta}}({\bm{x}}):{\bm{\theta}}\in{\mathbb{B}}_r({\bm{\theta}}_0)\}.
\]
We define the collection of all possible target mappings from the input space into the $(d-1)$-dimensional unit simplex $\Delta^{d-1}$ defined in \eqref{def:simplex} as
\[
\mathcal{F} = \{{\bm{f}}^*\mid {\bm{f}}^*:\texttt{supp}(p({\bm{x}}))\rightarrow \Delta^{d-1} \subset \mathbb{R}^d\}.
\]
If ${\bm{\theta}}_0$ is a good initial configuration, ${\mathbb{F}}({\bm{x}};{\bm{\theta}}_0)$ has to be $\Delta^{d-1}$. Otherwise, our model cannot approximate ${\bm{f}}^*\in\mathcal{F}$ such that ${\bm{f}}^*({\bm{x}})\in\Delta^{d-1}\setminus{\mathbb{F}}({\bm{x}};{\bm{\theta}}_0)$ in ${\mathbb{B}}_r({\bm{\theta}}_0)$.
To approximate all target mappings in $\mathcal{F}$ by ${\bm{f}}_{\bm{\theta}}$ near ${\bm{\theta}}_0$ for ${\bm{x}}$, there must be ${\bm{\theta}}\in{\mathbb{B}}_r({\bm{\theta}}_0)$ satisfying ${\bm{f}}_{\bm{\theta}}({\bm{x}})={\bm{s}}$ for arbitrary ${\bm{s}}\in\Delta^{d-1}$.
In other words, if we randomly pick ${\bm{\theta}}$ in ${\mathbb{B}}_r({\bm{\theta}}_0)$, the probability density of ${\bm{f}}_{\bm{\theta}}({\bm{x}})={\bm{s}}$ for any ${\bm{s}}\in\Delta^{d-1}$ is positive and should be the same over $\Delta^{d-1}$ without prior knowledge of target mappings.
\begin{claim}
\label{claim:uniformity}
Denote the distribution of ${\bm{y}}={\bm{f}}_{{\bm{\theta}}}({\bm{x}})$ given ${\bm{x}} \sim p({\bm{x}})$ over ${\bm{\theta}}\sim\mathcal{U}({\mathbb{B}}_r({\bm{\theta}}_0))$ as $q_{{\bm{x}}}({\bm{y}};{\bm{\theta}}_0,r)$.\footnote{
Although ${\bm{x}}$ is given, ${\bm{f}}_{\bm{\theta}}({\bm{x}})$ is random due to the randomness of ${\bm{\theta}}$.
}
Then, ${\bm{\theta}}_0$ is a good initialization if and only if $\texttt{supp}(q_{{\bm{x}}}({\bm{y}};{\bm{\theta}}_0,r))=\Delta^{d-1}$ and $q_{{\bm{x}}}({\bm{y}};{\bm{\theta}}_0,r)$ is equal to $\mathcal{U}(\Delta^{d-1})$ in distribution, because we do not know which ${\bm{s}}\in\Delta^{d-1}$ is more likely.
\end{claim}
To obtain ${\bm{\theta}}_0$ satisfying Claim~\ref{claim:uniformity}, we build an optimization problem that makes $q_{{\bm{x}}}({\bm{y}};{\bm{\theta}}_0,r)$ converge to $\mathcal{U}(\Delta^{d-1})$ in distribution for a given ${\bm{x}}\sim p({\bm{x}})$.
The first step toward this goal is to use
the maximum mean discrepancy (MMD) \citep{gretton2012kernel} from \eqref{def:mmd}. We define an example specific loss as
\begin{align}
\label{eq:mmd_uniform_nbd}
\mathcal{L}_{{\bm{x}}}^{uni}({\bm{\theta}}_0;r,\Delta^{d-1},\gamma)
=
\texttt{MMD}(q_{{\bm{x}}}({\bm{y}};{\bm{\theta}}_0,r),\mathcal{U}(\Delta^{d-1});\gamma).
\end{align}
According to \citet{gretton2012kernel}, \eqref{eq:mmd_uniform_nbd} is equal to $0$ if and only if $q_{{\bm{x}}}({\bm{y}};{\bm{\theta}}_0,r)$ is equal to $\mathcal{U}(\Delta^{d-1})$ in distribution.
We can therefore find ${\bm{\theta}}_0$ that satisfies Claim~\ref{claim:uniformity}, by minimizing \eqref{eq:mmd_uniform_nbd} with respect to ${\bm{\theta}}_0$.
The minimization of \eqref{eq:mmd_uniform_nbd} with respect to ${\bm{\theta}}_0$ needs samples from both $\mathcal{U}(\Delta^{d-1})$ and $\mathcal{U}({\mathbb{B}}_r({\bm{\theta}}_0))$. In the case of $\mathcal{U}(\Delta^{d-1})$,
we draw samples using \eqref{eq:sampling_uniform_simplex}. For $\mathcal{U}({\mathbb{B}}_r({\bm{\theta}}_0))$, we relax it to $\mathcal{N}({\bm{\theta}}_0,{\bm{\Sigma}})$ where ${\bm{\Sigma}}=\texttt{diag}(\sigma_1^2,\sigma_2^2,\cdots,\sigma_m^2)$ for two reasons: i)
this applies the same with uniform, since we can change the value range for each parameter separately; ii) the normal distribution allows us to use the reparametrization trick to compute $\nabla_{{\bm{\theta}}_0}\mathcal{L}_{{\bm{x}}}^{uni}({\bm{\theta}}_0;r,\Delta^{d-1},\gamma)$ from \eqref{eq:mmd_uniform_nbd} \citep{kingma2013auto}. Furthermore, as shown in Theorem~\ref{thm:prob_out_of_nbd} below, a proper choice of the covariance matrix makes Gaussian perturbation have similar effect as uniform perturbation:
\begin{theorem}
\label{thm:prob_out_of_nbd}
Let ${\bm{\theta}}\sim\mathcal{N}({\bm{\theta}}_0, \texttt{diag}(\sigma_1^2,\sigma_2^2,\cdots,\sigma_m^2))$ and $\alpha_* =\max_{i=1,2,\cdots,m} \sigma_i^2$. If $r^2$ is greater than $m\alpha_*$, then we have
\begin{align}\label{eq:prob_out_of_nbd}
{\mathbb{P}}\left(\|{\bm{\theta}}-{\bm{\theta}}_0\|\geq\ r \right) \leq \exp\left(-\frac{1}{8}\min\left\{\eta^2,m\eta\right\}\right),
\end{align}
where $\eta=\frac{r^2}{m\alpha_*}-1$ (proved in \S\ref{a_sec:thm1_proof}).
\end{theorem}
Theorem~\ref{thm:prob_out_of_nbd} implies that if we add a Gaussian perturbation $\boldsymbol{\epsilon}\sim\mathcal{N}({\bm{0}},{\bm{\Sigma}})$ to ${\bm{\theta}}_0$, then the perturbed parameter configuration, ${\bm{\theta}}={\bm{\theta}}_0+\boldsymbol{\epsilon}$, is enough closed to ${\bm{\theta}}_0$ with a high probability, when $\alpha^*=\max_i\sigma_i^2$ is sufficiently small. In other words, although $\mathcal{N}({\bm{\theta}}_0,{\bm{\Sigma}})$ is not exactly equivalent to $\mathcal{U}({\mathbb{B}}_r({\bm{\theta}}_0))$ in distribution, these two distributions play a similar role in the view of generating random parameter configurations near ${\bm{\theta}}_0$. We therefore rewrite \eqref{eq:mmd_uniform_nbd} to
enable reparametrization trick, as below:
\begin{align}
\label{eq:mmd_normal_nbd}
\mathcal{L}_{{\bm{x}}}^{uni}({\bm{\theta}}_0;{\bm{\Sigma}},\Delta^{d-1},\gamma)=
&\mathbb{E}_{\boldsymbol{\epsilon}\sim\mathcal{N}({\bm{0}},{\bm{\Sigma}})}\mathbb{E}_{\boldsymbol{\epsilon}'\sim\mathcal{N}({\bm{0}},{\bm{\Sigma}})}[k_\gamma({\bm{f}}_{{\bm{\theta}}_0+\boldsymbol{\epsilon}}({\bm{x}}), {\bm{f}}_{{\bm{\theta}}_0+\boldsymbol{\epsilon}'}({\bm{x}}))]
\\
&-2\mathbb{E}_{\boldsymbol{\epsilon}\sim\mathcal{N}({\bm{0}},{\bm{\Sigma}})}\mathbb{E}_{{\bm{u}}\sim \mathcal{U}(\Delta^{d-1})}[k_\gamma({\bm{f}}_{{\bm{\theta}}_0+\boldsymbol{\epsilon}}({\bm{x}}), {\bm{u}})]
\nonumber
\\
&+\mathbb{E}_{{\bm{u}}\sim \mathcal{U}(\Delta^{d-1})}\mathbb{E}_{{\bm{u}}'\sim \mathcal{U}(\Delta^{d-1})}[k_\gamma({\bm{u}}, {\bm{u}}')],
\nonumber
\end{align}
where $q_{{\bm{x}}}({\bm{y}};{\bm{\theta}}_0,{\bm{\Sigma}})$ is the distribution of ${\bm{f}}_{\bm{\theta}}({\bm{x}})$ given ${\bm{x}}$ with ${\bm{\theta}}\sim\mathcal{N}({\bm{\theta}}_0,{\bm{\Sigma}})$.
In other words, we add Gaussian noise to each parameter and encourage prediction for ${\bm{x}}$ based on such perturbed parameter configuration to be well spread out over $\Delta^{d-1}$.
From now on, we use ${\bm{\theta}}_0+\boldsymbol{\epsilon}$ to denote the perturbed parameter configuration, with $\boldsymbol{\epsilon}\sim\mathcal{N}({\bm{0}},{\bm{\Sigma}})$, to be more explicit about our use of reparametrization trick.
\Eqref{eq:mmd_normal_nbd} is an example specific loss, and minimizing this with respect to ${\bm{\theta}}_0$ only guarantees the existence of ${\bm{\theta}}^*$
near ${\bm{\theta}}_0$
satisfying ${\bm{f}}^*={\bm{f}}_{{\bm{\theta}}^*}$ for a single ${\bm{x}}$. Hence, we take the expectation of \eqref{eq:mmd_normal_nbd} over the input distribution $p({\bm{x}})$:
\begin{align}
\label{eq:uniformity_loss}
\mathcal{L}^{uni}({\bm{\theta}}_0;{\bm{\Sigma}},\Delta^{d-1},\gamma,p({\bm{x}}))
=
\mathbb{E}_{{\bm{x}}\sim p({\bm{x}})}[\mathcal{L}_{\bm{x}}^{uni}({\bm{\theta}}_0;{\bm{\Sigma}},\Delta^{d-1},\gamma)].
\end{align}
We minimize this expected loss to find an initial parameter configuration ${\bm{\theta}}_0^*$ that satisfies Claim~\ref{claim:uniformity} for the input data on average.
When done so, we can find ${\bm{f}}_{\bm{\theta}}$ within the close proximity of ${\bm{\theta}}_0^*$ that approximates any $d$-way target mapping ${\bm{f}}^*$, given $p({\bm{x}})$.
\subsection{Degeneracies and remedies}
\label{sec:degenerate_remedy}
Let ${\bm{x}}_1,{\bm{x}}_2,\cdots,{\bm{x}}_M$ be random samples drawn from $p({\bm{x}})$, $\boldsymbol{\epsilon}_1, \boldsymbol{\epsilon}_2,\cdots, \boldsymbol{\epsilon}_N$ be random perturbations from $\mathcal{N}({\bm{0}},{\bm{\Sigma}})$, and ${\bm{c}}_1,{\bm{c}}_2,\cdots, {\bm{c}}_N$ from $\mathcal{U}(\Delta^{d-1})$. If ${\bm{\theta}}_0^{1}$ satisfies
\begin{align}
\label{eq:degenerate_ex}
{\bm{c}}_j
=
{\bm{f}}_{{\bm{\theta}}_0^{1}+\boldsymbol{\epsilon}_j}({\bm{x}}_1)
=
{\bm{f}}_{{\bm{\theta}}_0^{1}+\boldsymbol{\epsilon}_j}({\bm{x}}_2)
=
\cdots
=
{\bm{f}}_{{\bm{\theta}}_0^{1}+\boldsymbol{\epsilon}_j}({\bm{x}}_M),
\end{align}
for each $j$, then $\mathcal{L}_{{\bm{x}}_i}^{uni}({\bm{\theta}}_0^{1};{\bm{\Sigma}},\Delta^{d-1},\gamma)=0$ for all $i$. Hence, ${\bm{\theta}}_0^{1}$ is one of the optimal solutions for \eqref{eq:uniformity_loss}.
In the case of ${\bm{\theta}}_0^{1}$, each perturbed model near ${\bm{\theta}}_0^{1}$ is a constant function, to which we refer as {\it input-output detachment}.
Furthermore,
each of these constant functions may output a {\it degenerate} categorical distribution whose support does not cover all $d$ classes, for which we refer to this phenomenon as {\it degenerate softmax}. We empirically demonstrate that both degeneracies indeed occur when we train a fully connected network by minimizing $\mathcal{L}^{uni}$ in \S\ref{a_sec:degenerate_cases_exp}.
In this section, we present two regularization terms, to be added to \eqref{eq:uniformity_loss}, to avoid these two unwanted cases, respectively.
\subsubsection{Degenerate softmax}
\label{sec:under-class}
We first address the latter issue of degenerate softmax. Since we have specified that the task of our interest is $d$-way classification, we prefer models that can classify inputs into all $d$ classes in the neighborhood of ${\bm{\theta}}_0^*$. We thus impose a condition that there exists at least one example categorized into each and every class. We first define a set of the points ${\mathbb{A}}_i$ classified into the $i$-th class as
\begin{align}
\label{def:ith_part_simplex}
{\mathbb{A}}_i
=
\left\{{\bm{a}}=(a_1,a_2,\cdots,a_d)\in\Delta^{d-1}:
a_i\geq a_j\textrm{ for all } j=1,2,\cdots,d \right\}.
\end{align}
Given $\boldsymbol{\epsilon}\sim\mathcal{N}({\bm{0}},{\bm{\Sigma}})$, the probability of \textit{`the model at ${\bm{\theta}}_0^*+\boldsymbol{\epsilon}$ classifies ${\bm{x}}$ into the $i$-th class'} is ${\mathbb{P}}_{{\bm{x}}\sim p({\bm{x}})}({\bm{f}}_{{\bm{\theta}}_0^*+\boldsymbol{\epsilon}}({\bm{x}})\in{\mathbb{A}}_i)$. This probability should be positive for all $i=1,2,\cdots,d$ to avoid degenerate softmax at ${\bm{\theta}}_0^*$. To satisfy this, we use Theorem~\ref{thm:prob_each_class} which offers a lower bound of ${\mathbb{P}}_{{\bm{x}}\sim p({\bm{x}})}({\bm{f}}_{{\bm{\theta}}_0^*+\boldsymbol{\epsilon}}({\bm{x}})\in{\mathbb{A}}_i)$ using the distance from the $i$-th vertex ${\bm{v}}^{(i)}$:
\begin{theorem}
\label{thm:prob_each_class}
Let ${\bm{v}}^{(i)}=\left(v^{(i)}_1,v^{(i)}_2,\cdots,v^{(i)}_d\right)\in\Delta^{d-1}$, where $v^{(i)}_i=1$ and ${\mathbb{A}}_i$ be a subset of $\Delta^{d-1}$, as defined in \eqref{def:ith_part_simplex}. Then,
\begin{align}
\label{eq:lower_prob_each_class}
{\mathbb{P}}_{{\bm{x}}\sim p({\bm{x}})}({\bm{f}}_{{\bm{\theta}}_0^*+\boldsymbol{\epsilon}}({\bm{x}})\in{\mathbb{A}}_i) \geq 1-\sqrt{d}\mathbb{E}_{{\bm{x}}\sim p({\bm{x}})}[\|{\bm{v}}^{(i)}-{\bm{f}}_{{\bm{\theta}}_0^*+\boldsymbol{\epsilon}}({\bm{x}})\|],
\end{align}
for a given $\boldsymbol{\epsilon}\sim\mathcal{N}({\bm{0}},{\bm{\Sigma}})$ (proved in \S\ref{a_sec:thm2_proof}).
\end{theorem}
According to \eqref{eq:lower_prob_each_class},
$\mathbb{E}_{{\bm{x}}\sim p({\bm{x}})}[\|{\bm{v}}^{(i)}-{\bm{f}}_{{\bm{\theta}}_0^*+\boldsymbol{\epsilon}}({\bm{x}})\|]<\frac{1}{\sqrt{d}}$ implies ${\mathbb{P}}_{{\bm{x}}\sim p({\bm{x}})}({\bm{f}}_{{\bm{\theta}}_0^*+\boldsymbol{\epsilon}}({\bm{x}})\in{\mathbb{A}}_i)>0$ for each $i$, given $\boldsymbol{\epsilon}\sim\mathcal{N}({\bm{0}},{\bm{\Sigma}})$. This means that we can avoid degenerate softmax by minimizing
\begin{align}
\label{eq:underclass_loss}
\mathcal{L}^{sd}({\bm{\theta}}_0;{\bm{\Sigma}},d,p({\bm{x}}))= \mathbb{E}_{\boldsymbol{\epsilon}\sim\mathcal{N}({\bm{0}},{\bm{\Sigma}})}\left[\max\left\{\max_{i=1,2,\cdots,d}\mathbb{E}_{{\bm{x}}\sim p({\bm{x}})}[\|{\bm{v}}^{(i)}-{\bm{f}}_{{\bm{\theta}}_0^*+\boldsymbol{\epsilon}}({\bm{x}})\|],\frac{1}{\sqrt{d}}\right\}-\frac{1}{\sqrt{d}}\right].
\end{align}
This minimization pulls the softmax output toward the furthest vertex for each $\boldsymbol{\epsilon}\sim\mathcal{N}({\bm{0}},{\bm{\Sigma}})$,
eventually avoiding the issue of degenerate softmax.
\subsubsection{Input-output detachment}
\label{sec:input_ignoring}
Here, let us go back to the first issue of input-output detachment we identified in \eqref{eq:degenerate_ex}. This issue happens when each perturbed model near ${\bm{\theta}}_0^{1}$ is a constant function. In other words, the Jacobian of the model's output with respect to the input is zero, and in the case of multi-layered neural networks, the Jacobian of the model's output with respect to one of the intermediate layers is zero. This largely prevents learning from ${\bm{\theta}}_0^{1}$, because ${\bm{\theta}}_0^{1}$ is surrounded by the parameter configurations from which learning cannot happen.
We thus design an additional loss that regularizes the Jacobian of model prediction with respect to its input and hidden neurons to prevent the input-output detachment.
In the rest of this section, we consider ${\bm{f}}$ as the logits instead of the values after applying softmax, in order to avoid an issue of saturation caused by softmax \citep{varga2017gradient}. Let ${\bm{x}}_l\in \mathbb{R}^{n_l}$, for $l \in \left\{ 0,1,\cdots,L \right\}$, be a vector of pre-activated neurons at the $(l+1)$-th layer parametrized by ${\bm{\theta}}^{(l+1)}_0$, where ${\bm{x}}_0\in\mathbb{R}^{n_0}$ and ${\bm{x}}_L\in\mathbb{R}^{n_L}=\mathbb{R}^d$ are an input vector and its corresponding output vector, respectively. ${\bm{f}}_{{\bm{\theta}}_0^{(l:L)}}$ is the function from $\mathbb{R}^{n_l}$ to $\mathbb{R}^d$, parametrized by ${\bm{\theta}}_0^{(l+1)},{\bm{\theta}}_0^{(l+2)},\cdots,{\bm{\theta}}_0^{(L)}$. Let us now consider the effect of perturbing the input to such a function:
\begin{align}
\label{eq:jacobian_perturbation}
{\bm{f}}_{{\bm{\theta}}_0^{(l:L)}}({\bm{x}}_l+\boldsymbol{\xi}_l)
\approx
{\bm{f}}_{{\bm{\theta}}_0^{(l:L)}}({\bm{x}}_l)+{\bm{J}}_{{\bm{\theta}}_0^{(l:L)}}({\bm{x}}_l)\boldsymbol{\xi}_l,
\end{align}
where ${\bm{J}}_{{\bm{\theta}}_0^{(l:L)}}({\bm{x}}_l)\in\mathbb{R}^{d\times n_l}$ is the Jacobian matrix of ${\bm{f}}_{{\bm{\theta}}_0^{(l:L)}}$ with respect to ${\bm{x}}_l$.
We then look at \eqref{eq:jacobian_perturbation} entry-wise:
\begin{align}
\label{eq:jacobian_perturbation_entry}
f_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l+\boldsymbol{\xi}_l)
\approx
f_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)+J_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)\boldsymbol{\xi}_l,
\end{align}
where $f_{{\bm{\theta}}_0^{(l:L)}}^{(i)}$ is the $i$-th entry of ${\bm{f}}_{{\bm{\theta}}_0^{(l:L)}}$, and $J_{{\bm{\theta}}_0^{(l:L)}}^{(i)}$ is the $i$-th row of ${\bm{J}}_{{\bm{\theta}}_0^{(l:L)}}$ for $i=1,2,\cdots,d$. From \eqref{eq:jacobian_perturbation_entry}, we can see that the absolute difference between $f_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)$ and $f_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l+\boldsymbol{\xi}_l)$ can be well approximated by the absolute value of the gradient-perturbation product:
\begin{align}
\label{eq:jacobian_abs_change}
\left|f_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l+\boldsymbol{\xi}_l)-f_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)\right|
\approx
\left|J_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)\boldsymbol{\xi}_l\right|.
\end{align}
Assuming the perturbation's norm to be unit, we can bound this quantity by the operator norm of the $i$-th row of Jacobian:
\begin{align}
\label{eq:jacobian_operator}
\sup_{\|\boldsymbol{\xi}_l\|=1}\left|f_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l+\boldsymbol{\xi}_l)-f_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)\right|
\approx
\sup_{\|\boldsymbol{\xi}_l\|_2=1}\left|J_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)\boldsymbol{\xi}_l\right|
=
\left\|J_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)\right\|^*.
\end{align}
Since $J_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)$ is a row vector, i.e., a matrix of rank 1, the Frobenius norm
$\|\cdot\|_F$ is equivalent to the operator norm $\|\cdot\|^*$. This allows us to rewrite \eqref{eq:jacobian_operator} as
\begin{align}
\label{eq:jacobian_frobenius}
\sup_{\|\boldsymbol{\xi}_l\|_2=1}\left|f_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l+\boldsymbol{\xi}_l)-f_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)\right|
\approx
\left\|J_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)\right\|_F.
\end{align}
According to \Eqref{eq:jacobian_frobenius},
if $\|J_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)\|_F$ is positive, our initial model ${\bm{f}}_{{\bm{\theta}}_0}$ is sensitive to the change in ${\bm{x}}_l$. That is, it is not a constant function.
Per the derivation above, in order to avoid the input-output detachment,
we can for instance impose that, for all $i=1,2,\cdots,d$,
\begin{align}
\label{eq:const_jaco}
c
=
\left\|J_{{\bm{\theta}}_0^{(0:L)}}^{(i)}({\bm{x}}_0)\right\|_F
=
\left\|J_{{\bm{\theta}}_0^{(1:L)}}^{(i)}({\bm{x}}_1)\right\|_F
=
\cdots
=
\left\|J_{{\bm{\theta}}_0^{(L-1:L)}}^{(i)}({\bm{x}}_{L-1})\right\|_F,
\end{align}
where $c>0$ is a constant. Here, we set $c=1$ which has an equivalent effect of setting the parameters using the so-called He initialization \citep{he2015delving}, as shown in the following theorem:
\begin{theorem}
\label{thm:he_init}
Let ${\bm{f}}_{{\bm{\theta}}_0}$ be a fully connected network with ReLU \citep{nair2010rectified} non-linearity. We write the layerwise non-linear transformation from ${\bm{x}}_l$ to ${\bm{x}}_{l+1}$ for $l\neq 0$ as
\begin{align*}
{\bm{f}}_{{\bm{\theta}}_0^{(l:l+1)}}({\bm{x}}_l)
=
{\bm{W}}^{(l+1)}\texttt{ReLU}({\bm{x}}_l)+{\bm{b}}^{(l+1)},
\end{align*}
where ${\bm{W}}^{(l+1)}\in\mathbb{R}^{n_{l+1}\times n_l}$ is the weight matrix and ${\bm{b}}\in\mathbb{R}^{n_{l+1}}$ is the bias vector.
Assume that each element of ${\bm{x}}_l$ has a symmetric distribution at $0$ and all elements of ${\bm{x}}_l$ are mutually independent. If the $(i,j)$-th entry of ${\bm{W}}^{(l+1)}$, $W_{ij}^{(l+1)}$, is a random sample from $\mathcal{N}(0,\sigma_l^2)$ and ${\bm{b}}^{(l+1)}$ is ${\bm{0}}$, then the following equality holds for all $k=1,2,\cdots, n_{l+1}$ when $\sigma_l=\sqrt{\frac{2}{n_l}}$ with sufficiently large $n_l$:
\begin{align}
\label{eq:he_jaco_condition}
1\approx\left\|J_{{\bm{\theta}}_0^{(l:l+1)}}^{(k)}({\bm{x}}_l)\right\|_F
=
\|{\bm{W}}^{(l+1)} \mathds{1}({\bm{x}}_l > 0)\|_F,
\end{align}
where $\mathds{1}({\bm{x}}_l >0)$ turns each positive entry in ${\bm{x}}_l$ to $1$ and $0$ otherwise (proved in \S\ref{a_sec:thm3_proof}).
\end{theorem}
In order to prevent input-output detachment, we thus
introduce an additional regularization term:
\begin{align}
\label{eq:ignore_loss}
\mathcal{L}^{iod}({\bm{\theta}}_0;p({\bm{x}}))
=
\mathbb{E}_{{\bm{x}}\sim p({\bm{x}})}\left[\frac{1}{d}\sum_{i=1}^d \left\{\max_{l\in\{0,1,\cdots,L-1\}}\left(1-\left\|J_{{\bm{\theta}}_0^{(l:L)}}^{(i)}({\bm{x}}_l)\right\|_F\right)^2\right\}\right],
\end{align}
where ${\bm{x}}_l$ is a vector of pre-activated neurons at the $l$-th layer and ${\bm{x}}_0$ is an input vector. By minimizing \eqref{eq:ignore_loss} with respect to ${\bm{\theta}}_0$, we prevent ${\bm{\theta}}_0$ from being constant, and consequently all nearby models as well, which we demonstrate empirically in \S\ref{a_sec:nearby_jaco_exp}.
\subsection{Hyperparameters and our recommendation}
\label{sec:final_loss}
We designed three loss functions to find a good initial parameter configuration ${\bm{\theta}}_0^*$ for $d$-way classification, using only unlabelled examples; i) $\mathcal{L}^{uni}({\bm{\theta}}_0;{\bm{\Sigma}},\Delta^{d-1},\gamma)$ in \S\ref{sec:uniform}; ii) $\mathcal{L}^{sd}({\bm{\theta}}_0;{\bm{\Sigma}},d)$ in \S\ref{sec:under-class}; iii) $\mathcal{L}^{iod}({\bm{\theta}}_0)$ in \S\ref{sec:input_ignoring}.
$\mathcal{L}^{uni}({\bm{\theta}}_0;{\bm{\Sigma}},\Delta^{d-1},\gamma)$ makes our model predictions be evenly spread over $\Delta^{d-1}$ centered on ${\bm{\theta}}_0$. $\mathcal{L}^{sd}({\bm{\theta}}_0;{\bm{\Sigma}},d)$ encourages the neighborhood of ${\bm{\theta}}_0$ to have solutions specialized for $d$-way classification by preventing {\it degenerate softmax}. $\mathcal{L}^{iod}({\bm{\theta}}_0)$ avoids the issue of {\it input-output detachment}. We additively combine all these to form the final loss function:
\begin{align}
\label{eq:final_loss}
\mathcal{L}({\bm{\theta}}_0;{\bm{\Sigma}},\Delta^{d-1},\gamma, p({\bm{x}}),\lambda,\xi)=&\mathcal{L}^{uni}({\bm{\theta}}_0;{\bm{\Sigma}},\Delta^{d-1},\gamma,p({\bm{x}}))
\\
& + \lambda\mathcal{L}^{sd}({\bm{\theta}}_0;{\bm{\Sigma}},d,p({\bm{x}}))
\nonumber
\\
&+\xi\mathcal{L}^{iod}({\bm{\theta}}_0;p({\bm{x}})).
\nonumber
\end{align}
In \S\ref{a_sec:need_all_exp}, we empirically present that $\mathcal{L}^{sd}$ and $\mathcal{L}^{iod}$ indeed prevent the degenerate softmax and the input-output detachment, and all these three loss functions in \eqref{eq:final_loss} are necessary to find a good initial parameter configuration.
In the rest of this section, we provide guidelines on how to choose some of the hyperparameters.
We select the bandwidth of MMD in $\mathcal{L}^{uni}$, $\gamma$, based on the median heuristic \citep{smola1998learning}. It uses the median of all pairwise distances for the Gaussian kernel in \eqref{eq:mmd_normal_nbd}. This technique is commonly used in many unsupervised learning based on the Gaussian kernel \citet{garreau2017large} such as kernel CCA \citep{bach2002kernel} and kernel two-sample test \citep{gretton2012kernel}. For more detailed description of the median heuristic in our experiments, see \S\ref{a_sec:med_heuristic}.
For ${\bm{\Sigma}}=\texttt{diag}(\sigma_1^2,\sigma_2^2,\cdots,\sigma_m^2$) of both $\mathcal{L}^{uni}$ and $\mathcal{L}^{sd}$, each $\sigma_i^2$ corresponding to $\theta_{0,i}$ is set based on the number of neurons connected to $\theta_{0,i}$. For instance, if $\theta_{0,i}$ is the entry of either ${\bm{W}}\in\mathbb{R}^{n_{out}\times n_{in}}$ or ${\bm{b}}\in\mathbb{R}^{n_{out}}$ (i.e., a parameter in a fully-connected layer), we set $\sigma_i$ to $\sqrt{s^2/n_{in}}$ for ${\bm{W}}$ and $\sqrt{s^2/n_{out}}$ for ${\bm{b}}$ where $s$ is a hyperparameter shared across all $i$'s.
For all the experiments in \S\ref{sec:main_exp}, we set $s=\sqrt{0.5}$, based on the preliminary experiments in \S\ref{a_sec:perturbation_std}.
In the cases of $\lambda$ and $\xi$, we mainly focus on selecting $\lambda$ while fixing $\xi$ to $1$, because these two loss functions, $\mathcal{L}^{uni}$ and $\mathcal{L}^{iod}$, are intertwined.
We use $\lambda=0.4$ for all the experiments in \S\ref{sec:main_exp}. With $\lambda=0.4$, we observed in the preliminary experiments that both $\mathcal{L}^{uni}$ and $\mathcal{L}^{sd}$ decrease. See \S\ref{a_sec:lambda_underclass}
for more details.
\section{Experimental Settings}
\label{sec:exp_setup}
To evaluate our algorithm, we fine-tune deep neural networks on the various binary downstream tasks synthetically created out of existing dataset. Here, we describe the experimental setup.
\paragraph{Datasets and tasks}
We derive binary tasks from MNIST \citep{lecun1998gradient}
, using the original labels. For example,
we can create a binary classification problem, distinguishing odd and even numbers from MNIST which originally has 10 classes (0-9 digits). In this way, we can create $2^{10}-2$ tasks from
MNIST
. After we define how to convert the original labels to either 0 or 1, we randomly select $N$ (for training) + $0.2N$ (for validation) instances, which allows us to test the impact of the size of labelled set.
We standardize each image to have zero-mean and unit variance across all the examples. We do not use any data augmentation.
\paragraph{Models}
We train a multi-layer perceptron with fully-connected layers, $\texttt{FCN}$, on MNIST
. $\texttt{FCN}$ has three hidden layers with ReLU \citep{nair2010rectified} nonlinearity.
$+\texttt{BN}$ refers to the addition of batch normalization \citep{ioffe2015batch} to all hidden layers before ReLU. Additional details about the network architectures are included in \S\ref{a_sec:model_archi}.
\paragraph{Baselines}
In order to assess the effectiveness of the proposed approach, we compare it against more conventional approaches to initialization. First, we compare our approach against data-agnostic initialization schemes, including Xavier initialization \citep{glorot2010understanding} and He initialization \citep{he2015delving}.
We also compare it to \textit{R.label} which refers to a data-dependent initialization scheme proposed by \citet{pondenkandath2018leveraging}. In the case of R.label, we randomly assign labels to the examples in each mini-batch and minimize the cross entropy loss. Both our initial parameter configuration and R.label's initial parameter configuration are pre-trained on the same number of unlabelled examples for the same maximum number of epochs. For each pre-training run, we choose the parameter configuration based on the pre-training loss.
See \S\ref{a_sec:pretrain}
for more details about the baselines and our pre-training setup.
Orthogonal to these initialization schemes, we also test adding batch normalization to these baseline approaches. It has been observed by some that batch normalization makes learning less sensitive to initialization \citep{ioffe2015batch}.
\paragraph{Training and evaluation}
For each initialization scheme, we fine-tune the network by minimizing the cross entropy loss, using Adam \citep{kingma2014adam} with a fixed learning rate of $10^{-3}$ and momentum parameters set to $(\beta_1,\beta_2)=(0.9,0.999)$. We use mini-batches of size 50 and train the network for up to 10 epochs without any regularization. For each binary task, we monitor the validation loss over the epochs and calculate the test accuracy (\%) on 10,000 test examples when the validation loss is at its minimum. We then report the mean and standard deviation of the test accuracy (\%) across 20 random binary tasks. We repeat this whole set of experiments four times, for each setup.
\section{Results}
\label{sec:main_exp}
\begin{table}[t]
\caption{We present the average ($\pm$stdev)
test scores on MNIST across four random experiments by varying the number of labelled examples ($10N$ for training and $2N$ for validation). We denote the random label pre-training by \textit{R.label}. \textbf{Bold} marks the best score within each column. For all $N$, our initialization approximates various tasks better than the others do. Especially, when the number of labelled examples is small, the improvement is significant. Although both R.label and our initialization use 60,000 unlabelled data, our pre-training is superior to R.label. The positive effect of batch normalization ($+\texttt{BN}$) can be observed with $N=40$, but its effect does not match that of our approach. Compared to $\texttt{FCN}$ trained from scratch, we observe that $+\texttt{BN}$ negatively impacts on the test score when the number of labelled instances is small ($N=5$) while our initialization improves the test score regardless of $N$.
}
\label{tab:mnist_binary}
\begin{center}
\begin{tabular}{ccc|cccc}
\hline
\multicolumn{1}{c}{\bf Model}&\multicolumn{1}{c}{\bf Init}& \multicolumn{1}{c|}{\bf Pre-trained} &\multicolumn{1}{c}{\bf N=5} &\multicolumn{1}{c}{\bf N=10} &\multicolumn{1}{c}{\bf N=20} &\multicolumn{1}{c}{\bf N=40}
\\
\hline
\hline
\texttt{FCN}&Xavier&Ours&\textbf{82.42}$\pm$0.72&85.98$\pm$0.65&\textbf{90.07}$\pm$0.17&92.48$\pm$0.57
\\
\texttt{FCN}&Xavier&-&79.63$\pm$0.78&83.70$\pm$0.59&87.54$\pm$0.67&90.91$\pm$0.53
\\
\texttt{FCN}&Xavier&R.label&76.81$\pm$2.13&83.34$\pm$0.79&87.53$\pm$0.91&90.88$\pm$0.52
\\
\texttt{FCN}+\texttt{BN}&Xavier&-&77.09$\pm$1.22&83.50$\pm$0.44&88.00$\pm$0.60&91.48$\pm$0.53
\\
\texttt{FCN}+\texttt{BN}&Xavier&R.label&78.87$\pm$1.75&84.38$\pm$0.97&88.71$\pm$0.53&91.57$\pm$0.59
\\
\hline
\texttt{FCN}&He&Ours&82.27$\pm$0.78&\textbf{86.46}$\pm$0.37&89.69$\pm$0.28&\textbf{92.61}$\pm$0.51
\\
\texttt{FCN}&He&-&79.17$\pm$1.21&83.41$\pm$0.92&87.96$\pm$0.64&91.34$\pm$0.37
\\
\texttt{FCN}&He&R.label&77.41$\pm$2.09&83.52$\pm$0.77&87.31$\pm$0.68&90.66$\pm$0.41
\\
\texttt{FCN}+\texttt{BN}&He&-&76.89$\pm$1.48&83.01$\pm$0.98&88.01$\pm$0.66&91.55$\pm$0.57
\\
\texttt{FCN}+\texttt{BN}&He&R.label&78.82$\pm$0.78&85.33$\pm$0.62&89.15$\pm$0.68&92.14$\pm$0.67
\\
\hline
\end{tabular}
\end{center}
\end{table}
\begin{table}[t]
\caption{We additionally demonstrate the standard deviation of test scores across 20 binary random tasks derived from MNIST by varying the number of labelled examples ($10N$ for training and $2N$ for validation). This metric measures the ability to solve most of tasks well (lower is better). We perform four random runs and report the average standard deviation. Here, ($\pm$stdev) means the standard deviation across four random experiments. We denote the random label pre-training by \textit{R.label}. \textbf{Bold} marks the best score within each column. Similar to Table \ref{tab:mnist_binary}, our initialization solves most of tasks well even if there are a small number of labelled examples. Both $+\texttt{BN}$ and R.label can hurts the performance to approximate various tasks when the number of labelled instances is small (N=5).
}
\label{tab:mnist_binary_std}
\begin{center}
\begin{tabular}{ccc|cccc}
\hline
\multicolumn{1}{c}{\bf Model}&\multicolumn{1}{c}{\bf Init}& \multicolumn{1}{c|}{\bf Pre-trained} &\multicolumn{1}{c}{\bf N=5} &\multicolumn{1}{c}{\bf N=10} &\multicolumn{1}{c}{\bf N=20} &\multicolumn{1}{c}{\bf N=40}
\\
\hline
\hline
\texttt{FCN}&Xavier&Ours&\textbf{4.76}$\pm$0.88 & 4.54$\pm$0.52 & \textbf{3.01}$\pm$0.71 & 2.26$\pm$0.40
\\
\texttt{FCN}&Xavier&-&6.62$\pm$1.29&5.55$\pm$0.62&3.54$\pm$0.27&2.65$\pm$0.53
\\
\texttt{FCN}&Xavier&R.label&6.08$\pm$0.92&5.02$\pm$1.16&3.82$\pm$0.23&2.78$\pm$0.49
\\
\texttt{FCN}+\texttt{BN}&Xavier&-&7.47$\pm$1.70&5.53$\pm$0.69&3.72$\pm$0.78&2.72$\pm$0.32
\\
\texttt{FCN}+\texttt{BN}&Xavier&R.label&6.62$\pm$1.50&5.44$\pm$0.33&3.20$\pm$0.41&2.40$\pm$0.37
\\
\hline
\texttt{FCN}&He&Ours&5.26$\pm$0.87&\textbf{4.04}$\pm$0.80 & 3.25$\pm$0.42 & \textbf{2.16}$\pm$0.40
\\
\texttt{FCN}&He&-&5.74$\pm$0.81&5.32$\pm$0.45&3.31$\pm$0.48&2.47$\pm$0.31
\\
\texttt{FCN}&He&R.label&6.37$\pm$1.10&4.84$\pm$1.02&3.98$\pm$0.44&3.03$\pm$0.85
\\
\texttt{FCN}+\texttt{BN}&He&-&7.52$\pm$0.76&6.50$\pm$1.76&3.59$\pm$0.80&2.74$\pm$0.41
\\
\texttt{FCN}+\texttt{BN}&He&R.label&7.33$\pm$1.10&4.95$\pm$1.08&3.18$\pm$0.55&2.30$\pm$0.28
\\
\hline
\end{tabular}
\end{center}
\end{table}
Table~\ref{tab:mnist_binary} shows that the average test scores on 20 random binary tasks across 4 random runs. The 20 binary tasks for each run is the same regardless of model, initialization, and pre-training. Pre-training $\texttt{FCN}$ with 60,000 unlabelled examples by our algorithm improves average test accuracy across 20 random tasks compared to that of training $\texttt{FCN}$ from scratch, and this improvement is greater than the number of labelled instances is small. Furthermore, our test scores are better than all the schemes applied to $\texttt{FCN}+\texttt{BN}$ which has more parameters than $\texttt{FCN}$. Both R.label and $+\texttt{BN}$ bring the positive effect when the number of labelled examples is sufficient (N=40). However, for $N=5$, both hurt the test performance of the randomly initialized plain network.
We also present the standard deviation of test scores across 20 binary random tasks created from MNIST in Table \ref{tab:mnist_binary_std}. Similar to Table \ref{tab:mnist_binary}, our initialization improves the ability to solve most of downstream tasks, and this improvement is greater when the number of labelled instances is small. We also observe R.label and $+\texttt{BN}$ can hurt this ability in terms of the standard deviation for $N=5$.
\section{Conclusion}
\label{sec:conclusion}
In this paper we proposed a novel criterion for identifying good initialization of parameters in deep neural networks. This criterion looks at the distribution over models derived from parameter configurations in the vicinity of an initial parameter configuration. If this distribution is close to a uniform distribution, the initial parameters are considered good, since we can easily reach any possible solution rapidly from there on.
We then derived an unsupervised initialization algorithm based on this criterion. In addition to maximizing this uniformity,
our algorithm
prevents two degenerate cases; (1) degenerate softmax and (2) input-output detachment.
Our experiments reveal that
the model initialized by our algorithm can be trained better than the one trained from scratch, in terms of average test accuracy across a diverse set of tasks. This improvement was found to be comparable to or better than random label pre-training \citep{pondenkandath2018leveraging, maennel2020neural} and batch normalization \citep{ioffe2015batch} combined with typical initialization strategies.
The effectiveness of the proposed approach leaves us with one puzzling question. The proposed algorithm does not take into account the use of gradient-based optimization, unlike model-agnostic meta-learning \citep{finn2017model}, and it could still find initial parameters that were amenable to gradient-based fine-tuning. This raises a question on the relative importance between initialization and the choice of optimizer in deep learning. We leave this question for the future.
\subsubsection*{Acknowledgments}
This work was supported by 42dot, Hyundai Motor Company (under the project Uncertainty in Neural Sequence Modeling), Samsung Advanced Institute of Technology (under the project Next Generation Deep Learning: From Pattern Recognition to AI), and NSF Award 1922658 NRT-HDR: FUTURE Foundations, Translation, and Responsibility for Data Science. This work was supported in part through the NYU IT High Performance Computing resources, services, and staff expertise.
| {'timestamp': '2023-02-10T02:03:29', 'yymm': '2302', 'arxiv_id': '2302.04369', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04369'} | arxiv |
\section{$TP^{3}$ approach}
In this section we present the
main mechanisms of the $TP^{3}$ system: a) we first build mobility profiles using the theory of \emph{coresets}, that provides a guaranteed approximation sample of the original geolocated data reports stored on-device,
b) we formulate our \emph{multi-objective optimization problem},
c) we present \emph{our algorithm for estimating the set of all the non-dominated solutions}, which constitute a Pareto frontier, and d) we apply a set of \emph{serverless privacy operations} at the last stage of the $TP^{3}$ system that aim at minimizing the social strength of the user with any kind of social relationships, ({\it i.e.,} friends or users with similar behavior) to preserve his privacy.
\subsection{Building Mobility Profiles}\label{sec:mobiprof}
$TP^3$ is built based on the observation that people show strong regularities in their behavior while using trajectory-based apps. For example, during weekdays they typically follow specific movement patterns between primary (e.g., "home") and secondary (e.g., "work") locations, while on weekends they present different mobility behavior that alternates between "home" and various social locations. We model the users' movement patterns using \emph{coresets}, a data reduction technique that allows us to significantly reduce the trajectories size while providing a guaranteed approximating sample of the original trajectory stored on-device.
\noindent
{\bf Theoretical Background.}
We utilize a sampling technique in order to generate a representative set of reports that approximates well the trajectory of a user over space and time rather than keeping all his spatio-temporal reports. In the literature, many different sampling techniques have been proposed such as ~\cite{ohlsson1998sequential}.
The sampling technique should be designed with the following properties: \textit{i) provide {\bf guaranteed approximation} of the initial dataset}, \textit{ii) provide {\bf a sample set of minimal size with bounded loss of information}}, and finally, \textit{iii) have {\bf small algorithmic complexity} that can be executed in memory-constrained environments, such as users' mobile phones in our setting}. In $TP^{3}$'s services, we exploit the theory of coresets\cite{agarwal2005geometric}, which fits our setting and has been recently used to address geometric and graph problems\cite{feldman2017coresets}, such as k-means, k-median, etc. Our approach differs from the above works, since: (1) we consider user trajectories rather than single geospatial reports, and (2) address different privacy goals.
The benefit of coresets is that they constitute a small set which approximates well the original data, and running queries on the coreset produces similar results to the original data. Thus, in our approach: (1) we keep only the reports of the generated coreset when compiling and storing a user's trajectory, (2) this results in significant performance benefits, as the number of reports kept locally on a user's phone is significantly reduced, as extensively evaluated in \cite{Boutsis2016a}.
In computational geometry, a coreset $CS$ of a point set $X$ is a sample that can efficiently approximate the initial set of points $X$.
Given a set of user shared spatio-temporal reports $C$, we assume that $C$ can be approximated by a factor $1\pm \epsilon$ from a smaller subset $C^{*}$ of the user's shared spatio-temporal reports.
More formally,
for the given point set $C$ and a class of queries $Q$, the following property holds for the coreset $C^{*}$ and for a given $\epsilon$:
$
(1-\epsilon)Q(C) \leq Q(C^{*}) \leq (1+\epsilon)Q(C)
$
\noindent
{\bf Trajectory Coresets.}
We build the coreset of the user's $u$ trajectory $tr_{u}^{l}$ by selecting the appropriate spatio-temporal reports that will comprise the coreset as follows:
Without loss of generality, we apply a well-known compression mechanism\cite{Boutsis2016a} on the user's $u$ trajectory to generate a set of spatio-temporal reports that preserve the shape of the user's trajectory but with fewer number of reports. The generated set of reports after applying this scheme is the coreset of the user's trajectory.
In our work, we apply a procedure similar to \cite{Boutsis2016a}. This procedure generates a trajectory that preserves the sequence in space and time but approximates the original user trajectory with fewer data reports. In order to decide whether a new trajectory shared by the user can be described by a coreset, we evaluate its reports. Specifically, the algorithm evaluates, for two consecutive reports $p_{u,i}^{\tau}$ \& $p_{u,i+1}^{\tau+1}$, if the percentage change of the tangent is over a predefined threshold $\theta$. More formally,
$ \label{eq:form1}\small
|\frac{tan(p_{u,i+1}^{\tau+1})-tan(p_{u,i}^{\tau})}{tan(p_{u,i}^{\tau})}|\geq \theta \normalsize
$.
High values of $\theta$ ($\theta > 0.0005$) define a stricter sampling (and a smaller size of coreset) compared to values close to zero.
\noindent
\subsection{ Our multi-objective optimization problem}
\subsubsection{Social Strength Minimization}
Assume a user trajectory $tr_{u}^{l}$ comprising a list of data reports shared by user $u$.
Then assume that a user wishes to share a new trajectory.
The question is whether it is safe for the user to issue a query sharing this trajectory.
The role of $TP^3$ is to evaluate the safety for the user to issue it and then apply appropriate privacy measures.
Thus, given a set $\mathcal{B}$ of MPs $\mathcal{G}_{u_{k}}$ that belong to possible social user ties and a threshold $\delta$, we compute the social strength of the user's trajectory $tr_{u}^{l}$, compared to the users represented by the MPs, using a score function as follows:
$ score(tr_{u}^{l},\mathcal{B})=\frac{1}{|\mathcal{B}|}\cdot \sum_{\forall \mathcal{G}_{u_{k}}\in \mathcal{B}}\mathcal{S}(tr_{u}^{l},\mathcal{G}_{u_{k}})
$
\subsubsection{Performance Maximization}
The second metric we consider in our multi-objective problem is the requests success rate(RSR). The RSR has been introduced in recent works \cite{palade2019evaluation} as a performance metric of serverless functions. For a given memory allocation $m\in M$ from a set $M$ of possible memory allocations, the requests success rate $\lambda_{m}$ is defined as the ratio of the number of user requests successfully served by this memory allocation $m$, $sucreq_{m}$, to the overall number of the requests submitted by the users to the system, $total_{m}$. In our work, our goal is to maximize the execution performance for all possible given memory allocations $m\in M$. Thus, our objective can be formulated as follows:
$
EP(m) = \max (\lambda_{m})=\max (\frac{\# sucreq_{m}}{\#total_{m}}),\forall m\in M
$.
\subsubsection{Spending Budget minimization}
The third metric we consider in our multi-objective problem is the spending budget $SB$. To compute this metric, we applied a pricing model similar to the one used by popular cloud providers like IBM (https://cloud.ibm.com/functions/learn/pricing). The metric considers a basic rate $c_{r}$ which denotes the amount of monetary units to pay per GB of data per sec, the average execution time of the serverless privacy preserving operation $avgT_{\mathcal{F}(\bullet)}$, the memory allocation $m\in M$ allocated for the execution of the function and the number of successful requests served by the system, $sucreq_{m}$. More formally,
$
SB_{m}= c_{r} \cdot avgT_{\mathcal{F}(\bullet)} \cdot m \cdot sucreq_{m}
$.
Thus, for a finite cloud operator budget $\mathcal{C}_{b}$ monetary units, our goal is to maximize the difference $\mathcal{W}(m)$ between $\mathcal{C}_{b}$ and $SB_{m}$. More formally,
$
\mathcal{W}(m)= \mathcal{C}_{b} - SB_{m}
$.
\noindent
{\bf Problem Definition.} More formally, our problem can be formulated as a maximization problem as follows:
\begin{align}
\max \mathcal{T}(EP(m),\mathcal{W}(m))\\
s.t.\min \ score(\mathcal{F}(tr_{u}^{l}),\mathcal{B}) < \delta \\
\mathcal{W}(m) > 0
\end{align}
where $\mathcal{T}(\bullet,\bullet)$ is our objective function that considers both the execution performance and the spending budget.
\subsection{Pareto Frontier Search Algorithm}
In $TP^{3}$, we solve a multi-objective optimization problem where we aim to balance the trade-off between the performance maximization and the required budget, while preserving privacy for the user trajectories. One of the most common ways of detecting appropriate solutions in such problems is constructing the Pareto frontier. In order to detect the optimal solutions in the examining search space, we need to define the notion of dominance \cite{ben2012expert}. Given two memory allocations $m_{1}$ and $m_{2}$, $m_{2}$ \textit{dominates} $m_{1}$($m_{2}\succeq m_{1}$) if one of the following criteria is met: (1) the spending budget for $m_{2}$ is less than equal than the one required for $m_{1}$ and the performance of $m_{2}$ is greater than equal to the performance of $m_{1}$ or (2) $m_{2}$ requires strictly smaller budget than $m_{1}$ and also the performance of $m_{2}$ is greater than or equal to the performance of $m_{1}$.
However, computing the Pareto frontier is a computationally costly process. A naive approach is to enumerate all possible combinations of memory allocations, performance the spending budget. Such an exhaustive search algorithm has exponential complexity $O(m^{|\mathcal{K}|})$ as it generates all these $m^{|\mathcal{K}|}$ possible allocations. We propose a novel approach that detects near-optimal memory allocations in an efficient and fast way without enumerating all the solutions. Our greedy algorithm approximates the Pareto-optimal frontier by selecting the appropriate memory allocation for the serverless privacy function that is affected the most in its performance by memory allocation. Starting with the memory allocation that helps maximize the performance, we traverse the frontier to select the most appropriate one that minimizes the spending budget. By doing so, it is not required to enumerate all possible solutions.
\subsection{Serverless Privacy-Preserving Operations $\mathcal{F}(\bullet)$}
$TP^{3}$ aims for social strength minimization against a set of MPs that it has already compiled and appropriately stored.
This is achieved by applying privacy-preserving operations that distort the users' trajectories and therefore minimize the social strength with any social ties. Such techniques include \textit{\bf spatial-location cloaking} approaches \cite{SiksnysTSY10}, \textit{\bf temporal cloaking} methods \cite{Gruteser2003}, addition of redundant \textit{\bf dummy locations} \cite{Cho2009} and \textit{{\bf path confusion}} techniques \cite{Hoh2010}.
Depending on the user's required level for privacy, $TP^{3}$ applies the appropriate privacy operation each time the user wishes to publish new trajectory data to minimize the social strength below the $\delta$-threshold.
\noindent{\bf Cloaking. } In the \textit{Spatial-location cloaking} privacy model \cite{SiksnysTSY10}, the exact location of the user is replaced by a broader spatial region termed \textit{cloaking region} (CR).
This privacy-preserving operation takes as input a spatio-temporal data report and returns a region cell $\widehat{rc}_{p_{u,i}^{\tau}}$
(rather than the exact spatio-temporal location)
that includes the spatio-temporal data report $p_{u,i}^{\tau}$ the user wants to publish.
This technique simply blurs a user spatio-temporal report into an uncertainty region.
A larger region size indicates a more strict privacy requirement, at the expense of not providing useful information for the system.
\noindent {\bf TempCloaking. } Compared to the Spatial Cloaking model, this privacy-preserving model \cite{Gruteser2003} uses time transformation and delays the user's response by a time period. That is, for two consecutive time instances $\tau_{1}, \tau_{2}$, the time instance $\tau_{2}$ of a new report $\widehat{p_{u,i}^{\tau_{2}}}$ is set to the time $\tau_{1}$ plus a random cloaking factor.
In $TP^{3}$, the timestamp value of the trajectory's data reports is changed accordingly by a specific amount of time, which consequently leads to a different trajectory, thus reducing the similarity with the compiled MPs.
\noindent {\bf Dummy Locations. } An alternative approach to applying time or spatial transformations is this privacy-preserving model \cite{Cho2009} where a number of \textit{dummy locations} is generated. The user, instead of reporting the actual location, reports one or more locations which are very close to the actual one. Thus, for a given spatio-temporal data report $p_{u,i}^{\tau}$, a list of one or more dummy spatio-temporal data reports $\widehat{p_{u,ii}^{\tau}}$ is generated.
Instead of publishing the trajectory with only the actual spatio-temporal reports $p_{u,i}^{\tau}$, $TP^{3}$ publishes the list of the dummy spatio-temporal reports generated, including the original ones.
\noindent {\bf Path Confusion. } This privacy model \cite{Hoh2010} differs from the previous models, since perturbations of the previous locations are applied in order to obfuscate and reduce the similarity with the MPs. Given a set of spatio-temporal reports $p_{u,i}^{\tau}$ the user wants to share, the goal is to apply a perturbation technique $pert()$ that changes the actual trajectory of the user (i.e. publish another report instead of the actual one), which results to a different user trajectory. The perturbation process considers up to $q$ sequential spatio-temporal reports to perturb and changes their sequence.
\begin{figure}[t!]\centering
\begin{minipage}{0.7\linewidth}\centering
\includegraphics[width=\linewidth]{architecture.eps}
\caption{Architecture Overview.}\label{fig:architecture}
\end{minipage}\hfill
\end{figure}
\section{Implementation}
\begin{figure*}[htp]
\begin{minipage}{0.215\linewidth}
\centering
\includegraphics[width=0.58\linewidth,angle=270]{dataset/timewindow.eps}
\caption{Num. of considered trajectories per timewindow}\label{fig:considertraj}
\end{minipage}\hfill
\begin{minipage}{0.215\linewidth}
\centering
\includegraphics[width=0.58\linewidth,angle=270]{dataset/avgLength.eps}
\caption{Average length of trajectories considered}\label{fig:avgchain}
\end{minipage}\hfill
\begin{minipage}{0.215\linewidth}
\centering
\includegraphics[width=0.87\linewidth]{results/coverageRate.eps}
\caption{Cov. Rate vs Traj. Similarity}\label{fig:covRate}
\end{minipage}\hfill
\begin{minipage}{0.215\linewidth}
\centering
\includegraphics[width=0.87\linewidth]{results/coverageRateAbs.eps}
\caption{Captured Users By MPs.}\label{fig:covRateAbs}
\end{minipage}
\end{figure*}
\noindent
{\bf On-device $TP^{3}$ service.} For the on-device service of $TP^{3}$ on the Android devices we utilized the Android Development Framework. We implemented an Android Service that works in concert with the Waze (https://www.waze.com/) and CrowdAlert (http://crowdalert.aueb.gr) and allows for the secure sharing of trajectories. Currently, it provides an API to those apps from which calls to trajectory-publishing methods are redirected through the Data Delivery Service of $TP^{3}$.
If the user is willing to share a trajectory or a list of past trajectories with a data analyst, the Android Service of $TP^{3}$ system is triggered and prepares appropriately the trajectory or the list of trajectories for delivering through the Data Delivery Service of $TP^{3}$, in order to be evaluated based on his personal privacy preferences.
{\bf Data Delivery service.} The Data Delivery service in $TP^{3}$ is responsible for processing trajectory shared from the Android Service. The Data Delivery service employs Apache Kafka as its fundamental building block. Apache Kafka is one of the most popular pub/sub systems and it is used for propagating millions of messages per second between a set of producers and consumers or across different services. Apache Kafka, apart from its ultra high throughput, uses replication, thus guarantying zero lost messages. Each user's on-device service acts as a Kafka Producer and sends trajectories in specific topics, based to the user's personal privacy preferences. Kafka Consumers constantly poll trajectories from these topics and send them through appropriate HTTP endpoints to the OpenFaaS Gateway to invoke the respective Serverless Privacy Function. Afterwards, the sanitized output is provided through appropriate HTTP endpoints to the data analyst.
{\bf Serverless Privacy Functions.} This component sanitizes the user's trajectory before being publishing it to the data analyst. $TP^{3}$ comprises three different modes of privacy models (loose, moderate and strict), in which different privacy operations are applied in order to distort the users' trajectories. The \textit{loose privacy mode} corresponds to the application of the Dummy Location or Path Confusion privacy function, depending on the type of trajectory app ({\it i.e.,} Path Confusion is suitable for applications where the perturbation of the reports in a trajectory is preferred rather than suppressing them, such as venue recommendation applications), which is encapsulated in the message received from the on-device $TP^3$ service.
The \textit{moderate privacy mode} corresponds to the Cloaking function and finally, the \textit{strict privacy mode} refers to the TempCloaking function, which changes the nature of the user's trajectory. Finally, the sanitized trajectory is forwarded through the appropriate HTTP endpoints to the data analyst, preserving user's privacy and utility. Our architecture overview is given in Figure \ref{fig:architecture}.
\section{Conclusions}
In this paper we presented $TP^{3}$, a privacy preservation system for trajectory analytics. We have modeled a new type of attack considering how social ties shape human mobility. Our proposed system employs the serverless paradigm and manages to balance the trade-off between maximizing the overall performance and minimizing the operational costs, while requiring low maintenance and administration from the cloud provider. $TP^{3}$ runs in concert with state-of-the-art trajectory analytics apps. Our experimental evaluation, compared to state of the art schemes, illustrates a reduction of at least 47\% in user privacy exposure, providing a tunable degree of privacy preservation with high system performance for users and low costs for cloud providers.
\section{Experimental Evaluation}\label{sec:evaluation}
\begin{figure*}[htp]
\begin{minipage}{\linewidth}
\centering
\subfigure[Path Confusion]{
\includegraphics[width=0.215\linewidth]{results/srvless/avg_req_path.eps}\label{fig:pathconfavgrec}}
\hfill
\subfigure[Dummy Locations]{
\includegraphics[width=0.215\linewidth]{results/srvless/avg_req_dummy.eps}\label{fig:dummyavgrec}}
\hfill
\subfigure[TempCloaking]{
\includegraphics[width=0.215\linewidth]{results/srvless/avg_req_temp.eps}\label{fig:tempcloakavgrec}}
\hfill
\subfigure[Cloaking]{
\includegraphics[width=0.215\linewidth]{results/srvless/avg_req_cloak.eps}\label{fig:spatcloakavgrec}}
\hfill
\caption{Average response time per privacy operation}
\end{minipage}
\end{figure*}
We conducted series of experiments to identify the effect of different parameters on the efficiency of each privacy operation in minimizing the social strength among the users and to show the benefits of employing a serverless model to maximize the system's performance and minimize the cost.
We answer the following questions: 1) how memory allocations affect the average response time,
2) how the memory allocations affect the throughput in terms of request/sec in each privacy operation, 3) how the different memory allocations affect the RSR, 4) what is the effect of the trajectories' length to the social strength minimization, 5) how the stored report size is affected by each privacy operation, 6) how the memory allocations affect the spending budget of the system operator, 7) what is the effect of the percentage of trajectories that the data analyst has in his possession, 8) how the percentage of the sanitized trajectories affects the utility and finally 9) how $TP^{3}$ performs compared to state-of-the-art techniques.
\subsection{Experimental Setting}
\begin{figure*}[htp]
\begin{minipage}{\linewidth}
\centering
\subfigure[Path Confusion]{
\includegraphics[width=0.215\linewidth]{results/srvless/rec_sec_path.eps}\label{fig:pathconreqsec}}
\hfill
\subfigure[Dummy Locations]{
\includegraphics[width=0.215\linewidth]{results/srvless/rec_sec_dummy.eps}\label{fig:dummyreqsec}}
\hfill
\subfigure[TempCloaking]{
\includegraphics[width=0.215\linewidth]{results/srvless/rec_sec_temp.eps}\label{fig:tempcloakreqsec}}
\hfill
\subfigure[Cloaking]{
\includegraphics[width=0.215\linewidth]{results/srvless/rec_sec_cloak.eps}\label{fig:spatcloakreqsec}}
\hfill
\caption{Requests / sec per privacy operation}
\end{minipage}
\end{figure*}
{\bf Data Description. }
To validate our analysis we utilized a real-world dataset from the Foursquare location-based service. The Foursquare dataset includes check-in data in New York city collected from Foursquare from 12 April 2012 to 16 February 2013 \cite{yang2014modeling}. The dataset contains 227428 check-ins and 1083 users, where the users were anonymized for privacy reasons. We selected 60\% of the dataset's users to train the appropriate MPs and the remaining 40\% users as the test set.
This represents a range of cases in a real system where
a data analyst can have a range of knowledge about users and their respective trajectories, but it is not possible at all times to have a global view of the users.
\begin{figure*}[htp]
\begin{minipage}{\linewidth}
\centering
\subfigure[Path Confusion]{
\includegraphics[width=0.215\linewidth]{results/srvless/rsr_path.eps}\label{fig:pathconfsucc}}
\hfill
\subfigure[Dummy Locations]{
\includegraphics[width=0.215\linewidth]{results/srvless/rsr_dummy.eps}\label{fig:dummysucc}}
\hfill
\subfigure[TempCloaking]{
\includegraphics[width=0.215\linewidth]{results/srvless/rsr_temp.eps}\label{fig:tempcloaksucc}}
\hfill
\subfigure[Cloaking]{
\includegraphics[width=0.215\linewidth]{results/srvless/rsr_cloak.eps}\label{fig:spatcloaksucc}}
\hfill
\caption{Requests Success Rate ($\lambda_{m}$) per privacy operation}
\end{minipage}
\end{figure*}
{\bf Setup. }
We deployed OpenFaaS in our cluster, which consists of 5 nodes (Intel(R) Core(TM) i7 3770 CPU @3.40GHz, 16GB RAM, Ubuntu 16.04 LTS). We used Docker Swarm as the orchestrator and we deactivated Prometheus AlertManager in order to deactivate autoscaling of functions. We used $Hey$ (https://github.com/rakyll/hey) for traffic measurements. We tested three different workload scenarios with five different memory allocation setups: (512, 1024, 1536, 2048 and 2560 (in MB)). In OpenFaaS, we setup our images to allocate 512MB of memory and we used replication in order to increase the total allocated memory. That is, each machine will host a container of each function with 512MB of allocated memory (so 1024MB means 2 replicas in 2 machines, 1536MB 3 replicas in 3 machines etc.).
{\bf Mobility Profile Coverage Rate.}
We introduce a novel metric, namely mobility profile coverage rate, for capturing the percentage of users that are associated with compiled mobility profiles. The metric considers how similar the trajectory of a user is compared to the compiled mobility profiles. Formally,
$
CR(score(\forall tr_{u}^{l},\mathcal{B}) \geq \delta)=\frac{\#users(score(tr_{u}^{l},\mathcal{B}) \geq \delta)}{TotalUsers}
$
where $\forall tr_{u}^{l}$ denotes every user that has $score(tr_{u}^{l},\mathcal{B})$ above the threshold $\delta$ and \# denotes the number of users.
{\bf Analysis. }
Figures \ref{fig:considertraj} \& \ref{fig:avgchain} illustrate the number of trajectories considered and what is the average length of the training trajectories. As we may conclude, selecting an $8-hour$ time window length is reasonable for selecting the trajectories, since it provides a good balance between the length of trajectories to explore and the number of trajectories.
In Figure \ref{fig:covRate} we draw the coverage rate for different degrees of trajectory similarity. As we may observe, as we set higher levels of similarity with the mobility profiles, the coverage rate decreases. However, even for only 30\% of trajectory similarity over 60\% of users are captured by the mobility profiles. In Figure \ref{fig:covRateAbs} we draw the number of users captured by the mobility profiles. We observe that even for the case of 50\% similarity, the number of captured users is 200 out of the 1084 users, which consists a considerable number of users. Thus, we conclude that mobility profiles may expose the privacy of a large number of users even with low mobility pattern similarity.
{\bf Baselines. }
We evaluated the performance of $TP^{3}$'s privacy operations compared to a state-of-the-art technique, namely SmartMask \cite{li2016privacy}, which applies a location obfuscation technique that assigns a spatio-temporal data report(a check-in), to the nearest, in terms of distance, point-of-interest.
\subsection{Experimental Workloads}
To show the benefits of employing the serverless model for the privacy functions and different user inputs, we used Hey to generate 20000 HTTP requests using as a payload either single trajectories or mobility profiles, without any rate limitation to stress $TP^3$ to its limits and test each privacy function independently. We setup three real-world scenarios, in which, each user of the test set, is willing to share either a single trajectory or the whole set of the trajectories that consist his mobility profile. The experimental results draw the average value for each one of the examined metrics from all the users in the test set.
{\bf One-vs-One Scenario - (OvO).} In the first scenario, we examine the performance of the system when each user shares a single trajectory in the serverless system, evaluated against the most frequent mobility profile encountered in our system.
{\bf One-vs-Many Scenario - (OvM).} Second, we examine the case in which the user shares a single trajectory which is evaluated against the whole set of mobility profiles compiled by our system. The goal is to capture the possible set of users with whom he may have similar mobility patterns with his trajectory.
\begin{figure*}[htp]
\begin{minipage}{\linewidth}
\centering
\subfigure[Path Confusion]{
\includegraphics[width=0.215\linewidth]{results/kap/path_kappa}\label{fig:pathconfsimkappa}}
\hfill
\subfigure[Dummy Locations]{
\includegraphics[width=0.215\linewidth]{results/kap/dummy_kappa}\label{fig:dummysimkappa}}
\hfill
\subfigure[TempCloaking]{
\includegraphics[width=0.215\linewidth]{results/kap/temp_kappa}\label{fig:tempcloaksimkappa}}
\hfill
\subfigure[Cloaking]{
\includegraphics[width=0.215\linewidth]{results/kap/cloak_kappa}\label{fig:spatcloaksimkappa}}
\hfill
\caption{Social Strength of privacy operations (per length of trajectory)}
\end{minipage}
\end{figure*}
{\bf Many-vs-Many Scenario - (MvM).} Last, we evaluate the case where the user shares his whole set of trajectories, {\it i.e.,} his entire mobility profile, against the whole set of mobility profiles compiled by our $TP^3$ system. Compared to the previous scenario, in this one we aim at capturing all possible users with similar MPs, considering the entire MP of the user.
\subsection{Parameters Examined}
\begin{figure*}[htp]
\begin{minipage}{0.215\linewidth}
\centering
\includegraphics[width=\linewidth]{results/reductionCoresets.eps}
\caption{Reduction (\%) in size of stored reports}\label{fig:reductionpercent}
\end{minipage}\hfill
\begin{minipage}{0.215\linewidth}
\centering
\includegraphics[width=\linewidth]{results/reductionAbsoluteCoresets.eps}
\caption{Reduction in (MB) of stored reports}\label{fig:reductionabsolut}
\end{minipage}\hfill
\begin{minipage}{0.215\linewidth}
\centering
\includegraphics[width=\linewidth]{results/srvless/allCost.eps}
\caption{Spending Budget for all privacy functions in MvM scenario}\label{fig:allcost}
\end{minipage}\hfill
\begin{minipage}{0.215\linewidth}
\centering
\includegraphics[width=\linewidth]{results/percentageOfUsers.eps}
\caption{Similarity vs Users in possession of the data analyst app}\label{fig:adverpos}
\end{minipage}\hfill
\end{figure*}
{\bf 1)Average Response Time vs Memory.}
In Figures \ref{fig:pathconfavgrec}, \ref{fig:dummyavgrec}, \ref{fig:tempcloakavgrec} and \ref{fig:spatcloakavgrec} we illustrate the Average Response Time of our system which denotes the flexibility of the serverless model with respect to the memory allocation. Our results depict the impact of having flexible memory allocations in the amount of time required to respond to a request. An interesting finding that we observe, is that, increasing the total amount of allocated memory, this results to a \emph{significant} decrease of the average response time for all the privacy functions in all scenarios.
\begin{figure}[htp]
\begin{minipage}{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{results/utility/utility.eps}
\caption{Utility vs Percentage of shared trajectory}\label{fig:util}
\end{minipage}\hfill
\begin{minipage}{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{results/comparison.eps}
\caption{Comparison with state-of-the-art}\label{fig:comparisons}
\end{minipage}
\end{figure}
{\bf 2) Requests/sec vs Memory.}
Figures \ref{fig:pathconreqsec}, \ref{fig:dummyreqsec}, \ref{fig:tempcloakreqsec} and \ref{fig:spatcloakreqsec} depict our initial intuition that, by having flexible memory allocations using a serverless model, we should expect high increase in the number of requests served per sec. We reason these results to the fact that with higher memory the system can handle more concurrent HTTP requests and we can safely conclude that it is beneficial to employ a serverless model for serving multiple concurrent requests.
{\bf 3) Requests Success Rate vs Memory.}
In Figures \ref{fig:pathconfsucc}, \ref{fig:dummysucc}, \ref{fig:tempcloaksucc} and \ref{fig:spatcloaksucc}, we draw the ratio of successful requests served using a serverless model towards the total number of requests received for a specific memory allocation. The results show that as we increase the allocated memory, and consequently the number of replicas, the ratio increases to a value equal to one, meaning all user requests are successfully served by $TP^3$. This result is expected due to our setup, since the Docker Swarm load balances the traffic across all active replicas.
Overall, the results show that it is beneficial to employ a serverless model for maximizing the system's performance.
{\bf 4) Trajectory length vs Social Strength. } We evaluated the performance of each privacy operation for reducing the social strength considering trajectories of different length. We considered trajectories with length equal or greater than a varying trajectories length parameter. Figures \ref{fig:pathconfsimkappa}, \ref{fig:dummysimkappa}, \ref{fig:tempcloaksimkappa} \& \ref{fig:spatcloaksimkappa} illustrate the social strength in logarithmic scale observed after applying each privacy operation for different values of trajectory length. An interesting finding is that the Dummy Locations technique outperforms the Cloaking technique for a trajectory length equal to 3. This is due to the fact that the Dummy Locations technique better obfuscates the user trajectory, since the random points inserted for this trajectory length, change it significantly. Overall, the TempCloaking and Cloaking privacy operations outperform the other techniques in terms of social strength minimization.
{\bf 5) Coreset size vs Stored Reports.} We investigated the effect of the size of the coresets on the size of stored reports when each privacy operation is applied. From our experimental analysis, we considered a value of $\theta=0.0005$ which is reflected on a moderate level of sampling (and is the default settig in our implementation). Figures \ref{fig:reductionpercent} and \ref{fig:reductionabsolut} illustrate the performance in terms of stored reports size reduction for each privacy operation. The results depict that the privacy operations allow for reducing the number of stored reports in the users phones significantly. We observe that TempCloaking (76\% size reduction) still outperforms the privacy operations having Path Confusion and Cloaking as runner ups.
{\bf 6) Spending Budget vs Memory.} We examined the spending budget performance against different memory allocations and for every workload scenario. In Figure \ref{fig:allcost}, we draw the spending budget performance for the many-to-many scenario, which is the most heavy in terms of performance, for the different privacy operations and memory allocations. We observe that the spending budget is relatively low compared to having a fixed budget. In addition, we observe that we can vary the spending budget with regards to the serverless privacy function we want to execute, thus providing a tunable-degree of privacy with regard to the execution costs.
{\bf 7) Percentage of data analyst trajectories. }
In Figure \ref{fig:adverpos} we draw the percentage of trajectories captured by the percentage of users for whom the data analyst has compiled MPs, with no privacy technique applied and after using $TP^{3}$'s privacy operations. We observe that as the percentage of users in possession of the data analyst increases, the percentage of trajectories captured also increases for all the privacy operations but still remains under 50\%. That is, since the data analyst has the 100\% of the users, only $\sim$45\% of user trajectories can be detected if only Cloaking technique is selected from all users to be applied. We also observe that TempCloaking technique totally minimizes the similarity of user trajectories with a MP due to the fact that it totally changes the nature of the user's trajectories. Path Confusion and Dummy Locations methods also present good performance and so, we can conclude that $TP^{3}$ can successfully trade-off between different levels of privacy and desired accuracy of results.
{\bf 8) Utility vs Percentage of Shared Trajectory. } We investigated the balance between data quality and privacy, when each one of $TP^{3}$'s privacy operations is applied.
Once a privacy operation has been selected, the goal is to apply it while preserving as much data utility as possible.
In Figure \ref{fig:util} we draw the utility for the different privacy operations applied. The x-axis denotes the percentage of the trajectory that has already been published without applying any privacy operation. The published data are considered useful when the utility equals 100\%. Path Confusion and Temporal Cloaking have utility 100\%, since in the Foursquare location-based application they affect only the times of the reports rather than the corresponding locations.
Overall, we safely conclude that $TP^{3}$ succeeds in maintaining a balance between the data accuracy and privacy.
{\bf 9) Comparison with state-of-the-art. } In Figure \ref{fig:comparisons} we draw the percentage of similarity for the different privacy operations applied. We observe that $TP^{3}$ outperforms SmartMask, since for every provided privacy operation by $TP^{3}$, it results in lower similarity (it performs 47\% better than SmartMask). This implies that $TP^{3}$ is practical and efficient for protecting against social link exploitation attacks.
\section*{Acknowledgment}
This research has been supported by the H2020 LAMBDA Project 734242, the EU ICT-48 2020 project TAILOR (No. 952215) and the H2020 AutoFair project (No. 101070568).
\bibliographystyle{IEEEtran}
\section{Introduction}
The proliferation of smartphone devices has opened up a new era of collaboration and sharing. With the advent of the Internet of Things (IoT), the paradigm shift towards interconnected devices and platforms has allowed the gathering of more information about the environment from heterogeneous sources and the exchange of information with the real world. The IoT paradigm allows for a renewed form of context-aware computing,
where applications interact with the user, and adapt their services based on the prevailing user context.
For instance, trajectory-based systems such as Uber (https://www.uber.com), Foursquare's Swarm (https://www.swarmapp.com/) and DiDi (https://www.didiglobal.com/)
have enabled users to systematically share updates about their activities and whereabouts.
In these systems, users often contribute their user IDs and timestamped locations in real-time, possibly enriched with multimedia content, such as images, videos or text, in order to track family members and friends, get rewards, or receive recommendations about places of interest.
For the vast majority of the individuals, there are several benefits from sharing their whereabouts
(e.g., friends trying to find each other in busy places such as shopping centers or parks, parents tracking their children locations for safety purposes or citizens earning free parking time in smart cities\footnote{http://www.vavel-project.eu/}).
{\bf Trajectory Analytics.}
It has been shown that users issue various types of \emph{queries} to trajectory analytics applications while taking private leisure walks in public places or while strolling with friends around the city, asking for recommendations or other types of services, e.g. querying for available taxis, which are performed by sharing their own trajectories.
The majority of these state-of-the-art works aim at capturing human movement, dynamics, regularities \cite{backstrom2010find} and provide secure analytics \cite{beck2017privapprox} observing mobility patterns in data streams, providing answers to questions regarding the geographic movement of people ({\it "where do they move?"}) or aiming to understand how social ties impact mobility patterns, answering questions such as {\it "what the friends of a user can reveal about the user's mobility patterns"} and {\it "how similar users are based on their mobility"} \cite{pham2013ebm,backes2017walk2friends}.
A fundamental insight in these works is that people exhibit strong periodic behavior in their mobility patterns
as they move back and forth between their homes and workplaces \cite{Cho2011,Boutsis2016a}, and
that user mobility is shaped by our social relationships as we are more likely to visit places that our friends
and people with similar interests have visited in the past or have shared common activities with,
a phenomenon known as social homophily \cite{tang2014mining}.
{\bf Trajectory Privacy Preservation.}
Current trajectory analytics applications are crude, since users are asked to "opt-in" (thus allowing for disclosing possible sensitive data to them) in order to receive higher accuracy, whereas in others they may "opt-out" and accept generic recommendations but with much lower quality and accuracy.
A typical operating scenario of such applications employs a system for delivering trajectories from users to data analysts, in order to be further processed and returns a set of beneficial services for the users. In the current big data ecosystem, it is typical to have direct access to users’ private data, and they must be trusted not to abuse it. However, this trust has been violated in the past\footnote{https://www.eff.org/deeplinks/2015/01/healthcare.gov-sends-personal-data}.
Additionally, as privacy preferences are subjective by nature, only a small percentage of the users of these systems realize the serious privacy implications that may arise and their extent.
An adversary, or third party, can extract social trajectory-based data to identify social ties among the users of these systems.
The adversary can further exploit the extracted information to target \emph{individual users} for marketing campaigns,
monitor their movements to compromise one's personal safety, or even act on behalf of a third company ({\it i.e.}, an insurance company that aims to extract personal biometric characteristics from fitness applications, evaluate the
health status of the users and appropriately adjust their insurance rates \cite{fereidooni2017fitness}).
The adversary can also target \emph{groups of users with similar mobility patterns}.
For example, it is known that location and mobility data are examined by NSA to identify new (or unknown) members of criminal gangs or terrorist cells
of targets that already knows about\footnote{https://www.expressvpn.com/internet-privacy/guides/nsa-spying/}.
Or finally, groups of users can be exploited for targeted advertising:
advertising companies create targeted ad groups, based on interests, lifestyles, demographics, geo-location or mobility patterns.
Similar examples can be found in mobile alerting systems or social transportation systems \cite{zheng2016big} where mobility groups are utilized for ride-sharing or to react to disruptions of transportation services in real-time.
{\bf The serverless computing model.}
Recently, a new privacy-preserving model for trajectories in Mobile Cloud Environments(MCEs) has been proposed,
referred to as on-device public-private TPP model \cite{epasto2019device},
where user data is partitioned into two parts: (a) a public part that can be shared with a data analyst, and (b) a private part (on-device data) that is protected from disclosure.
The model conducts computations using both private and public data on the user's phone. However, storing all the user trajectories in the phones is impossible due to storage limitations and therefore, unavoidably, they must be conducted through a \emph{mobile cloud service provider} before being disclosed to the data analyst. The advent of cloud computing has enabled providing low-latency trajectory analytics and has enabled many service providers to move their hardware infrastructure from on-premise deployments into large-scale shared cloud resources \cite{lin2020serverless}. The \emph{Serverless Computing} has been introduced recently in the literature \cite{lin2020serverless} as a scheme to enable Mobile Cloud providers balance the \emph{trade-off} between the computational costs for users (i.e. provide results with low-latency) and the provisioning costs (i.e resource allocation costs), compared to traditional on-premises deployments. While marrying these two paradigms, we face two challenges: the first is how to detect social ties between users based on the trajectories, in real-time. The question is whether the estimation of privacy exposure can utilize only a subset (sample) of the user's trajectories. The second challenge is, since the Serverless Computing paradigm enables for a \textit{pay-as-you-use} service, how we can exploit it to balance the trade-off between providing trajectory analytics with low-latency and minimizing the costs associated with using such a service, while considering the different privacy perspectives of the individual users.
The goal of the work is to present a cost-effective and practical system for MCEs enhanced with a user-tunable degree of privacy preservation, that provide solutions to these two major challenges: (1) minimize the volume of mobility patterns required for the privacy estimation analysis to enable on-device storage, and (2) utilize the serverless computing paradigm for trajectory analytics,
to balance the trade-off between low-latency computations and minimization of provisioning costs, preserving at the same time the privacy of the trajectories.
{\bf Contributions.} In this work we make the following contributions:
\begin{itemize}
\item We propose {\bf $TP^{3}$}, a Practical Privacy preservation system for trajectory analytics in MCEs.
$TP^{3}$ adopts an on-device model that \textit{reduces the volume of the examined mobility patterns} using the theory of coresets and allows the system to obtain guaranteed, fast and accurate approximations of user trajectory data.
\item We model a new type of attack, namely \textit{social link exploitation attack}, where a third party data analyst can infer information about the user and the user's behavior by associating the user's patterns with groups of similar users while sharing trajectory data.
\item We exploit the Serverless Computing paradigm for providing a balance between high performance trajectory analytics
and low provisioning costs, utilizing a Pareto-Frontier search algorithm.
We apply four different privacy operations achieving a good balance between accuracy and privacy of the disclosed trajectories.
\item We have implemented the $TP^{3}$ system to support trajectory analytics apps on top of Android devices and the OpenFaaS serverless platform, and evaluated its performance.
We illustrate
that $TP^{3}$ is a cost-effective approach and can achieve at least 47\% reduction of the risk of privacy exposure while users are able to contribute data to trajectory analytics apps.
\end{itemize}
\section{Model and Threat Definition}
\subsection{On-device Model}
{\bf Users. } Users $\mathcal{U}$ in the $TP^{3}$ system are characterized by the tuple $\langle id_{u}, \{p_{u,i}^{\tau}\}\rangle$, where $id_{u}$ is the unique id of user $u$ and $\{p_{u,i}^{\tau}\}$ is a list of all the contributed publicly available data reports made by the user through the trajectory analytics apps. Typically, these reports are coupled with location and timestamps and
illustrate the user's presence activity.
The $i$-th spatio-temporal data report issued by a user $u$, $p_{u,i}^{\tau}$, is a tuple $\langle lat_{i}, lon_{i} , \tau, dat_{u,i,\tau} \rangle$, where $lat_{i}, lon_{i}$ are the \textit{geospatial coordinates}, $\tau$ a \textit{timestamp} value annotating the time when the user $u$ issued the specific report and $dat_{u,i,\tau}$ denotes the data associated with the spatio-temporal report. In the case of a traffic monitoring application e.g., the data can represent \textit{the traffic state} (e.g. "traffic jam", "road closure" etc.), whereas in location-based recommendation apps it can reveal \textit{the location semantics} of a place where a user has checked-in.
{\bf Trajectories. } Users share reports to trajectory analytics apps which are represented in the form of trajectories. That is, users maintain locally their spatio-temporal data reports which form their mobility patterns. Each user $u$ trajectory $tr_{u}^{l}$ has a unique identity $l$ and a sequence of spatio-temporal data reports $p_{u,i}^{\tau}$; these denote the route the user was following while issuing the spatio-temporal data reports.
{\bf Mobility Profiles.} The Mobility Profile (MP) of a user $u$,
$\mathcal{G}_{u}$, is represented through the user's trajectories,
$ \mathcal{G}_{u}=\langle \{tr_{u}^{l_{1}},tr_{u}^{l_{2}},...,tr_{u}^{l_{\kappa}}\}\rangle$.
We discuss in detail how mobility profiles are compiled in our $TP^3$ system in section \ref{sec:mobiprof}.
{\bf Utility.} The notion of utility has been introduced in recent works\cite{gursoy2018utility,xiao2015protecting} as a performance metric of location privacy protection systems in order to capture the trade-off between data quality and user privacy preservation.
The goal is to preserve data utility as much as possible
(in terms of how useful and accurate the data report is)
while preserving the users' privacy.
In $TP^{3}$, our aim is to measure the utility $UT$ of a perturbed trajectory $\hat{tr}_{u}^{l}$ , thus we define it as the inverted distance between each one true report $p_{u,i}^{\tau}\in tr_{u}^{l}$ and the corresponding released report $\hat{p}_{u,i}^{\tau}\in \hat{tr}_{u}^{l}$. More formally,
$
UT(\hat{tr}_{u}^{l},tr_{u}^{l}) = \sum_{\substack{\forall p_{u,i}^{\tau}\in tr_{u}^{l} \\ \forall \hat{p}_{u,i}^{\hat{\tau}}\in \hat{tr}_{u}^{l}}}\frac{1}{\sqrt{E \parallel\hat{p}_{u,i}^{\hat{\tau}}-p_{u,i}^{\tau}\parallel_{2}^{2}}}
$,
where $E\parallel \bullet \parallel$ denotes the difference between the reports (also called "correctness" \cite{shokri2011quantifying}). In the case of \textit{trajectory analytics applications} the aforementioned formula considers \textit{the geographical distance} between the reports, whereas in the case of \textit{emergency response trajectory analytics applications}, for which time is a critical parameter, the equation also considers \textit{the difference in the timestamps} among the original and the released reports.
{\bf Social Graph. } The set of users $\mathcal{U}$ form an undirected social graph $G=(V,E,\mathcal{S})$, where each node $v_{u}\in V$ denotes user $u$, each edge $e_{mn}\in E$ annotates the social tie between users $u_{m}$ and $u_{n}$, and finally $\mathcal{S}(u_{m},u_{n})\in \mathcal{S}$ is a value that represents the strength of the social tie between users $u_{m}$ and $u_{n}$.
\subsection{Serverless Model}
We chose to deploy $TP^3$ on a Serverless environment rather than a traditional hosting solution in a cloud provider.
Choosing the Serverless computing model \cite{lin2020serverless}, we have a lower operational and deployment cost due to its unique pricing policy based on a \emph{pay-as-you-use} model.
This model allows for using ephemeral containers that are utilized only during our workload. During long periods of inactivity, containers stop running automatically (scale to zero) to keep the operational cost low, since it provides a seamless method for autoscaling the resources.
That is the number of active instances can adapt dynamically according to the number of requests, e.g., if 3 active instances are typically employed, these can increase to 10 during data bursts and can go back to normal levels when
the number of requests decreases.
Apart from the aforementioned benefits, it allows developers to build simpler software by designing their services as functions. In our approach we use OpenFaaS (https://www.openfaas.com/) as our Serverless environment, but our system works inline with existing state-of-the art Serverless systems such as AWS, GCF, IBM Cloud, etc.
\begin{figure*}[t!]\centering
\begin{minipage}{0.725\linewidth}\centering
\includegraphics[width=\linewidth]{dataset/icdcs_scenario.eps}
\caption{Social Strength Exploitation Attack Example.}\label{fig:example}
\end{minipage}\hfill
\end{figure*}
\subsection{Threat Model}
{\bf Social Strength. } To infer whether a pair of individuals are socially connected, recent works \cite{pham2013ebm,backes2017walk2friends} have attempted to model the relationship between the users' mobility patterns and their social ties.
One approach is to use a graph model \cite{backes2017walk2friends} where learning the users' mobility features and evaluating the users' mobility similarity, the social tie between two users can be captured.
A similar model was introduced in \cite{pham2013ebm} where they aim at recording the diversity of the locations visited by the users. However, both approaches are not appropriate for our setting as they focus on single locations rather than trajectories, and thus cannot encapsulate the users' movement regularity, dependencies or transitions among different locations.
Trajectory-based modeling, on the other hand, allows us to meet with high accuracy the requirements of applications
with spatiotemporal correlations among queries issued by the users for trajectory analytics apps \cite{zang2011anonymization}.
We use an entropy-based model to capture the social strength among two users of the system, given their mobility profiles. Our metric captures the diversity of the users (i.e. in terms of the number of different places they visit) by evaluating the similarity of their mobility profiles.
Thus, the social strength $\mathcal{S}(\mathcal{G}_{u_{1}},\mathcal{G}_{u_{2}})$ among two users $u_{1},u_{2}$ given their mobility profiles $\mathcal{G}_{u_{1}}$, $\mathcal{G}_{u_{2}}$, is defined
as:
$
\mathcal{S}(\mathcal{G}_{u_{1}},\mathcal{G}_{u_{2}})=\alpha \cdot e^{\mathcal{H}(\mathcal{G}_{u_{1}}|\mathcal{G}_{u_{2}})}
$
where
$ \mathcal{H}(\mathcal{G}_{u_{1}}|\mathcal{G}_{u_{2}})=-\sum_{\substack{1 \leq z \leq |\mathcal{G}_{u_{1}}|\\ 1 \leq y \leq |\mathcal{G}_{u_{2}}|}}\mathcal{P}(tr_{u_{1}}^{l_{z}}|tr_{u_{2}}^{l_{y}})\cdot log \mathcal{P}(tr_{u_{1}}^{l_{z}}|tr_{u_{2}}^{l_{y}})
$
\noindent
where $\alpha \in (0,1]$ is a parameter to tune the degree of privacy preservation tailored to the user's personal needs (explained in detail in the next section). For instance, a value of ($\alpha = 1$) indicates that the user is highly concerned about the privacy. Additionally, $\mathcal{S}(\mathcal{G}_{u_{1}},\mathcal{G}_{u_{2}})\in (0,1]$; a value of $\mathcal{S}(\mathcal{G}_{u_{1}},\mathcal{G}_{u_{2}})$ equal to 1 indicates that the two users are highly socially connected and have identical mobility behavior, while a value close to 0 indicates that there is little social connection among the users.
The probability function $\mathcal{P}(tr_{u_{1}}^{l_{z}}|tr_{u_{2}}^{l_{y}})$ evaluates the similarity between the trajectories $tr_{u_{1}}^{l_{z}}$, $tr_{u_{2}}^{l_{y}}$ of users $u_{1}$,$u_{2}$.
To perform this computation, we utilize the notion of \textit{expected edit distance metric \cite{cotterell2014stochastic}, which characterizes the similarity between trajectories with a respective probability to show up.} That is, given the trajectory $tr_{u_{2}}^{l_{y}}$, the function captures what is the probability to find the trajectory $tr_{u_{1}}^{l_{z}}$, as implied by the metric. Therefore, the probability function $\mathcal{P}(tr_{u_{1}}^{l_{z}}|tr_{u_{2}}^{l_{y}})$ is defined formally as:
$ \mathcal{P}(tr_{u_{1}}^{l_{z}}|tr_{u_{2}}^{l_{y}})=\frac{LCS(tr_{u_{1}}^{l_{z}}, tr_{u_{2}}^{l_{y}})}{|tr_{u_{1}}^{l_{z}}|}
$
where $LCS(\bullet,\bullet)$ denotes the longest common consecutive subsequence between two trajectories. We assume a third party data analyst that aims at exploiting the social ties among mobile users. The data analyst has compiled a list $\mathcal{D}$ of mobility profiles (MPs) for all users that have shared trajectories with the trajectory analytics apps.
The MPs are compiled from the users' mobility patterns using most frequent subset pattern mining procedure\cite{fournier2013tks}.
{\bf Social Link Exploitation Attack}.
We introduce a novel type of attack, namely the \emph{social link exploitation attack}, where the a data analyst attempts to exploit the social relationships through trajectory analytics apps in order to predict the movement patterns of a particular user. In our setting, the analyst has already compiled
a model of human mobility based on the geospatial movements of the users.
By estimating the social strength between a user and the set of compiled mobility profiles, the attacker is able to associate the user with other users with the same behavior and estimate the user's mobility pattern \cite{kong2015privacy}.
The attacker can exploit this information not only to compromise one's safety but also for marketing purposes to predict the most likely venue that a user will visit and
select an appropriate ad to pop-up in the user's phone.
{\bf Example.}
In Figure \ref{fig:example} we illustrate a scenario of how a curious data analyst can associate a user $u$ with one of the MPs of the set $\mathcal{D}$ that has already been compiled.
The left part of the figure illustrates three users of a specific trajectory analytics app. In a real world scenario, the users typically provide direct access of their trajectories to the data analyst.
The right part of the figure shows a small sample of the MPs compiled from our Fousquare dataset (described in section \ref{sec:evaluation}) for various users utilizing this app.
We show 6 different trajectories that correspond to three users, based on the Foursquare data.
The bottom of the figure illustrates the trajectory of the user $u$ that is evaluated, which consists of the following report sequence: Train Station, Cafe, Clothing Store, Bookstore and finally the user enjoys a burger in a Burger Shop.
We may observe that there is a common pattern among user $u$ and the third trajectory which belongs to user $id_{u'}=2$ who has probably visited a "Mall".
The data analyst computes the social strength of user's $u$ trajectory (up to the 5th report) and the MPs that have been compiled.
The computed social strength
reveals, with high probability, that user $u$ is very likely to visit an "Ice-cream Shop" in one of the next moves. Subsequently, after associating those users two users as more highly socially connected, the data analyst can infer the next probable visit of the user in order to provide for e.g. targeted advertisements for "Ice Cream Shops" or related ads.
\section{Related Work}
{\bf Privacy Models.} Privacy preservation is not a new area and approaches have been proposed in the literature\cite{backes2017walk2friends,pham2013ebm,AhujaGS19,yao2019publishing,kalnis2007preventing}. However, these works have several limitations.
In \cite{backes2017walk2friends}, they propose an attack that predicts social links between users, but it does not consider trajectories nor focuses on how a user associates to a group of users based on his mobility patterns. The authors of \cite{pham2013ebm} aim at understanding the significance of a location visited by a user, which is encapsulated in the number of visits to a specific location. However, it is limited since the focus is on single locations rather than trajectories. In \cite{yao2019publishing}, the authors focus on securing the sensitive attributes of each location visited by applying l-diversity whereas in our approach we provide different privacy operations tailored to user needs. The authors of \cite{AhujaGS19} focus on Geo-Indistinguishability for single locations than trajectories as we do in our work.
Finally, in \cite{kalnis2007preventing}, the authors proposed transformations based on the K-anonymity concept for user locations, without considering the users' mobility patterns nor possible social ties, which is the focus of our work.
| {'timestamp': '2023-02-13T02:08:26', 'yymm': '2302', 'arxiv_id': '2302.04463', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04463'} | arxiv |
\section{Introduction}\label{sec:introduction}
Reinforcement learning (RL) recently arises as a compelling paradigm for modeling machine learning applications with sequential decision making. In such a problem, an online learner interacts with the environment sequentially over Markov decision processes (MDPs), and aims to find a desirable policy for achieving an accumulated loss (or reward). Various algorithms have been developed for RL problems and have been shown theoretically to achieve polynomial sample efficiency in~\cite{zimin2013online,azar2017minimax,jin2018q,agarwal2019reinforcement,bai2019provably,jin2020learning,jin2020provably,cai2020provably,gao2021provably,lykouris2021corruption,qiao2022sample}, etc.
In addition to the metric of losses, {\bf switching costs}, which capture the costs for changing policies during the execution of RL algorithms, are also attracting increasing attention. This is motivated by many practical scenarios where the online learners cannot change their policies for free. For example, in recommendation systems, each change of the recommendation involves the processing of a huge amount of data and additional computational costs~\cite{theocharous2015personalized}. Similarly, in healthcare, each change of the medical treatment requires substantial human efforts and time-consuming tests and trials~\cite{yu2021reinforcement}. Such switching costs are also required to be considered in many other areas, e.g., robotics applications~\cite{kober2013reinforcement}, education software~\cite{bennane2013adaptive}, computer networking~\cite{xu2018experience}, and database optimization~\cite{krishnan2018learning}.
Switching costs have been studied in various problems
(please see Sec.~\ref{sec:introrelatedwork} for some examples). Among these studies, a relevant line of research is along bandit learning~\cite{geulen2010regret,dekel2014bandits,arora2019bandits,shi2022power}. More recently, switching costs have received considerable attention in more general RL settings~\cite{bai2019provably,gao2021provably,wang2021provably,qiao2022sample}. However, these studies have mainly focused on \emph{static} RL, where the loss distribution is assumed to be fixed during the learning process. Thus, practical scenarios where the loss distribution could be non-stationary or even adversarial are not characterized or considered.
While \textbf{adversarial RL} better models the non-stationary or adversarial changes of the loss distribution, to the best of our knowledge, an open problem remains: \emph{how to develop a provably efficient algorithm for adversarial RL with switching costs?} Intuitively, in adversarial RL, since much more often policy switches would be needed to adapt to the time-varying environment, it would be much more difficult to achieve a low regret (including both the standard loss regret and the switching costs, please see (\ref{eq:defineregret})). Indeed, without a special design to reduce switching, existing algorithms for adversarial RL with $T$ episodes, such as those in~\cite{zimin2013online,jin2020learning,lee2020bias} and~\cite{lykouris2021corruption}, could yield poor performance of linear-to-$T$ number of policy switches. \emph{Thus, the goal of this paper is to make the first effort along this open direction.}
Our first aim is to develop provably efficient algorithms that enjoy low regrets in adversarial RL with switching costs. This requires a careful reduction of switching under non-stationary or adversarial loss distributions. It turns out that previous approaches to reduce switching in \emph{static} RL (e.g., those in~\cite{bai2019provably} and ~\cite{qiao2022sample}) are not applicable here. Specifically, the high-level idea in static RL is to switch faster at the beginning, while switch slower and slower for later episodes. Such a method performs well in static RL, mainly because after learning enough information about losses at the beginning (by switching faster), the learner can estimate the assumed \emph{fixed} loss-distribution accurately enough with high probability in later episodes. Thus, even though the learner switches slower and slower, a low regret is still achievable with high probability. In contrast, when the loss distribution could change arbitrarily, this method does not work. This is mainly because what the learner learned in the past may not be that useful for the future. For example, when the loss distribution is adversarial, a state-action pair with small losses in the past may incur large losses in the future. Thus, new ideas are required for addressing switching costs in adversarial RL.
Our second aim is to understand fundamentally whether the new challenge of switching costs in adversarial RL significantly increases the regret. This requires a converse result, i.e., a lower bound on the regret, that holds for any RL algorithm. Further, we aim to understand fundamentally whether the adversarial nature of RL indeed requires much more policy switches to achieve a low loss regret.
\subsection{Our Contributions}\label{subsec:introcontribution}
In this paper, we achieve the aforementioned goals and make the following three main contributions. (We use $\tilde{\Omega}$, $\tilde{\Theta}$ and $\tilde{O}$ to hide constants and logarithmic terms.)
\textbf{First}, we provide a lower bound (in Theorem~\ref{theorem:lowerbound}) that shows that, for adversarial RL with switching costs, the regret of any algorithm must be larger than $\tilde{\Omega}( ( H S A )^{1/3} T^{2/3} )$, where $T$, $S$, $A$ and $H$ are the number of episodes, states, actions and layers in each episode, respectively. Our lower bound indicates that, due to the fundamental challenge of switching costs in adversarial RL, the best achieved regret (whose dependency on $T$ is $\tilde{O}(\sqrt{T})$) in static RL with switching costs is no longer achievable. Further, we characterize precisely the new trade-off (in Theorem~\ref{theorem:lossswitchingtradeoff}) between the standard loss regret and the switching costs due to the adversarial nature of RL.
\textbf{Second}, we develop the first-known near-optimal algorithms for adversarial RL with switching costs. As we discussed above, the idea for reducing switching in static RL does not work well here. To handle the losses that can change arbitrarily, our design is inspired by the approach in~\cite{shi2022power} for bandit learning, but with two novel ideas. (a) We delay each switch by a fixed (but {\em tunable}) number of episodes, which ensures that switch occurs only every $\tilde{O}(T^{1/3})$ episodes. (b) The idea in (a) results in consistently long intervals of not switching. Since the bias in estimating losses from such a long interval tends to increase the regret, it is important to construct an unbiased estimate of losses for each interval. To achieve this, the idea in bandit learning is to consider all time-slots in each interval as one time-slot, which necessarily requires a \emph{single} chosen action in each interval. Such an approach is not applicable to our more general MDP setting, since there is no guarantee to visit a \emph{single} state-action pair due to state transitions. To resolve this issue, our novel idea is to decompose each interval, and then combine the losses of each state-action pair only from the episodes in which such a state-action pair is visited. Interestingly, although this combination is random and the loss is adversarial, the expectation of the estimated losses is (almost) unbiased.
\textbf{Third}, we establish the regret bounds for our new algorithms. For the case with a \textit{known} transition function, we show that our algorithm achieves an $\tilde{O}( (HSA)^{1/3} T^{2/3} )$ regret, which matches our lower bound. For the case with an \textit{unknown} transition function, we show that, with probability $1-\delta$, our algorithm achieves an $\tilde{O}\left( H^{2/3} (SA)^{1/3} T^{2/3} ( \ln\frac{TSA}{\delta})^{1/2} \right)$ regret, which matches our lower bound on the dependency of $T$, $S$ and $A$, except with a small factor of $\tilde{O}(H^{1/3})$. Therefore, the regrets of our new algorithms are near-optimal. Moreover, because of our novel ideas for estimating losses and delaying switching discussed above in a state-transition case, our proofs for the regrets involve several new analytical ideas. For example, in Lemma~\ref{lemma:knownexpectedlossunbias} and Lemma~\ref{lemma:unknownexpectedlossunbias}, we show that our new way of estimating losses is (almost) unbiased so that its effect on the regret is controllable. Moreover, to capture the effect of the delayed switching, our new analytical idea is to first bound the regret across intervals between adjacent switching events, and then relate the regret inside episodes of each interval to this bound (please see \textit{Step-2} of the proofs in Appendix~\ref{appendix:proofofthmknowntranprobregret} and Appendix~\ref{appendix:proofofthmunknowntranprobregret}).
\section{Related Work}\label{sec:introrelatedwork}
\textbf{Switching costs:}
Switching costs have already received considerable attention in various online problems. For example, online convex optimization with switching costs has been studied in~\cite{lin2012online,bansal20152,chen2016using,goel2019beyond,shi2021competitive,shi2021combining}, etc. Convex body chasing with switching costs has been studied in~\cite{friedman1993convex,sellke2020chasing,bubeck2021online}, etc. Switching costs have also been studied in metrical task systems~\cite{borodin2005online}, online set covering~\cite{buchbinder2014competitive}, $k$-server problem~\cite{lin2020online}, online control~\cite{goel2019online,li2020online,lin2021perturbation}, etc. Moreover, switching costs have been studied in adversarial bandit learning, e.g., in~\cite{geulen2010regret,dekel2014bandits,arora2019bandits,shi2022power}. Our work in this paper can be viewed as a non-trivial generalization of these studies on bandit learning to adversarial MDP, where state transitions and multiple layers in each episode require new developments in both the algorithm design and regret analysis.
\textbf{Static MDP:} There have been recent studies on static RL with switching costs. Specifically, for tabular MDP, \cite{bai2019provably} and~\cite{zhang2020almost} proposed RL algorithms that attain an $\tilde{O}\left( \sqrt{H^{\alpha}SAT} \cdot\ln\frac{TSA}{\delta} \right)$ regret with probability $1-\delta$, by incurring $O\left(H^{\alpha}SA \ln T\right)$ switching costs, where $\alpha=3$ and $2$, respectively. Recently,~\cite{qiao2022sample} obtained a similar $\tilde{O}(\sqrt{T})$ regret with probability $1-\delta$, by incurring $O\left( HSA \ln\ln T \right)$ switching costs. Moreover, for linear MDP (with $d$-dimensional feature space),~\cite{gao2021provably} and \cite{wang2021provably} obtained an $\tilde{O}\left( \sqrt{ d^3 H^3 T } \cdot (\ln \frac{dT}{\delta})^{1/2} \right)$ regret with probability $1-\delta$, by incurring $O\left( dH\ln T \right)$ switching costs.
\textbf{Adversarial MDPs:} Adversarial RL better models scenarios where the loss distributions and/or the transition functions of MDPs could change over time. Specifically, in tabular MDP with a known transition function,~\cite{zimin2013online} proposed an RL algorithm that attains an $\tilde{O}(\sqrt{HSAT})$ regret. In the case with an unknown transition function,~\cite{jin2020learning} and~\cite{lee2020bias} obtained an $\tilde{O}\left(HS\sqrt{AT \ln \frac{TSA}{\delta}}\right)$ regret with probability $1-\delta$. These studies assume that the state spaces of layers in an episode are non-overlapping. Moreover,~\cite{rosenberg2019online} studied the case with full-information feedback. Adversarial linear MDP has also been studied recently, e.g., in~\cite{cai2020provably,luo2021policy}. In addition,~\cite{yu2009arbitrarily,cheung2019reinforcement} and~\cite{lykouris2021corruption} studied the case when both the loss distribution and transition function change arbitrarily. More studies on various adversarial RL settings have been done by~\cite{rosenberg2019onlinenips,lee2021achieving,zhao2021linear,jin2021best,he2022nearly}, etc.
To the best of our knowledge, no study in the literature has addressed the challenge due to \emph{switching costs in adversarial RL}, which is the focus of this paper.
\section{Problem Formulation}\label{sec:problemformulation}
We consider adversarial reinforcement learning (RL) with switching costs in episodic Markov decision processes (MDPs). Suppose there are $T$ episodes, each of which consists of $H$ layers. We use $\mathcal{S}_{h}$ to denote the state space of layer $h$. For ease of elaboration, as in previous work (e.g.,~\cite{zimin2013online,jin2020learning} and~\cite{lee2020bias}), we assume that the $H$ layers are non-intersecting, i.e., $\mathcal{S}_{h'} \cap \mathcal{S}_{h''} = \phi$ for any $h'\neq h''$; $\mathcal{S}_{0} = \{s_{0}\}$ is a singleton; and each episode ends at state $\mathcal{S}_{H} = \{s_{H}\}$. Thus, the entire state space is $\mathcal{S} = \cup_{h=0}^{H} \mathcal{S}_{h}$ with size $S = \sum_{h=0}^{H} S_{h}$, where $S_{h}$ denotes the size of $\mathcal{S}_{h}$. Moreover, we use $\mathcal{A}$ to denote the action space with size $A$. Then, the MDP is defined by a tuple $\left( \mathcal{S}, \mathcal{A}, P, \left\{l_{t}\right\}_{t=1}^{T}, H \right)$, where $P$ is the transition function with $P_{h}:~\mathcal{S}_{h+1} \times \mathcal{S}_{h} \times \mathcal{A} \rightarrow [0,1]$ denoting the transition probability measure at layer $h$, and $l_{t}:~\mathcal{S} \times \mathcal{A} \rightarrow [0,1]$ represents the loss function for episode $t$.
The online learner interacts with the Markov environment episode-by-episode as follows. At the beginning of each episode $t=1$, ..., $T$, the online learner starts from state $s_{0}$ and follows an algorithm that (possibly randomly) chooses a \emph{deterministic} policy $\pi_{t}: \mathcal{S} \rightarrow \mathcal{A}$. Next, at each layer $h=0$, ..., $H-1$, after observing the current sate $s_{t,h}$, the learner chooses an action $a_{t,h} = \pi_{t}(s_{t,h})$. Then, the learner incurs a loss $l_{t}(s_{t,h},a_{t,h})$. Finally, the next state $s_{t,h+1} \in \mathcal{S}_{h+1}$ is drawn according to the transition probability $P(\cdot|s_{t,h},a_{t,h})$. (For simplicity, we drop the index $h$ of $P_{h}$ in this paper when it is clear from the context.) These steps repeat until the learner arrives at the last state $s_{H}$. At the end of episode~$t$, only the losses of visited state-action pairs in the episode are observed by the learner, whereas the losses of non-visited state-action pairs are unknown. As in~\cite{zimin2013online,jin2020learning,lee2020bias,cai2020provably}, this is called ``\textbf{bandit feedback}'', which is more practical than full-information feedback~\cite{rosenberg2019online} that assumes the losses of all state-action pairs (no matter visited or not) are known for free.
\textbf{Adversarial losses:} Different from static RL that assumes the loss distribution is fixed for all episodes, in the adversarial setting we consider here, we do not need any assumption on the underlying loss distribution. That is, the loss function $l_{t}$ could change arbitrarily across episodes.
\textbf{Switching costs:} As we mentioned in the introduction, in adversarial RL, addressing switching costs remains an open problem. The switching cost refers to the cost needed for changing the policy~$\pi_{t}$. It is equal to $\beta \cdot \mathbf{1}_{\{\pi_{t+1}\neq \pi_{t}\}}$, where $\beta$ is the switching-cost coefficient ($\beta$ is strictly positive and is independent of $T$) and $\mathbf{1}_{\mathcal{E}}$ is a indicator function (i.e., $\mathbf{1}_{\mathcal{E}} = 1$ if the event $\mathcal{E}$ occurs, and $\mathbf{1}_{\mathcal{E}} = 0$ otherwise).
Therefore, the total cost of executing an RL algorithm $\pi$ over $T$ episodes is given by
\begin{align}
\text{Cost}^{\pi}(1:T) \triangleq \mathbb{E} \left[ \sum\limits_{t=1}^{T} \sum\limits_{h=0}^{H-1} l_{t}(s_{t,h}^{\pi},a_{t,h}^{\pi}) + \sum\limits_{t=1}^{T-1} \beta \cdot \mathbf{1}_{\{\pi_{t+1} \neq \pi_{t}\}} \Big | \pi,P \right], \label{eq:definetotalonlinecost}
\end{align}
where the expectation is taken with respect to the randomness of the state-action pairs $(s_{t,h}^{\pi},a_{t,h}^{\pi})$ visited by $\pi$, and the possible randomness of changing the policy $\pi_{t}$.
Next, we introduce a concept called ``occupancy measure''~\cite{zimin2013online,jin2020learning}. Specifically, the occupancy measure $q_{t}^{\pi,P}(s,a) = Pr[s_{t,h}^{\pi}=s,a_{t,h}^{\pi}=a | \pi,P] \geq 0$ is the probability of visiting the state-action pair~$(s,a)$ by the algorithm $\pi$ at layer $h$ of episode $t$ under the transition function $P$. In addition (with slight abuse of notation), the occupancy measure $q_{t}^{\pi,P}(s',s,a) = Pr[s_{t,h+1}^{\pi}=s', s_{t,h}^{\pi}=s,a_{t,h}^{\pi}=a | \pi,P] \geq 0$ is the probability of visiting the state-action triple $(s',s,a)$ by the algorithm~$\pi$ at layers $h$ and $h+1$ of episode $t$ under the transition function $P$. In order to be feasible, the occupancy measures need to satisfy some conditions at layer $h$ of episode~$t$. First, according to probability theory, they need to satisfy the conditions that,
\begin{align}
q_{t}^{\pi,P}(s,a) = \sum\limits_{s' \in \mathcal{S}_{h+1}} q_{t}^{\pi,P}(s',s,a), \text{ for all } (s,a) \in \mathcal{S}_{h}\times \mathcal{A}, \text{ and }
\sum\limits_{s\in\mathcal{S}_{h}} \sum\limits_{a\in\mathcal{A}} q_{t}^{\pi,P}(s,a) = 1. \label{eq:defineconstraintoccupancymeasure1}
\end{align}
Second, since the probability of transferring to a state $s$ from the previous layer $h-1$ must be equal to the probability of transferring from this state $s$ to the next layer $h+1$, we have
\begin{align}
\sum_{s'\in\mathcal{S}_{h-1}} \sum_{a\in \mathcal{A}} q_{t}^{\pi,P}(s,s',a) = \sum_{s'\in\mathcal{S}_{h+1}} \sum_{a\in \mathcal{A}} q_{t}^{\pi,P}(s',s,a), \text{ for all } s\in \mathcal{S}_{h}. \label{eq:defineconstraintoccupancymeasure2}
\end{align}
Third, the occupancy measure should generate the true transition function $P$, i.e.,
\begin{align}
\frac{q_{t}^{\pi,P}(s',s,a)}{\sum_{b\in\mathcal{A}} q_{t}^{\pi,P}(s',s,b)} = P_{h}(s'|s,a), \text{ for all } (s',s,a)\in \mathcal{S}_{h+1} \times \mathcal{S}_{h} \times \mathcal{A}. \label{eq:defineconstraintoccupancymeasure3}
\end{align}
We use $\mathbb{C}(P)$ to denote the set of all occupancy measures that satisfy conditions (\ref{eq:defineconstraintoccupancymeasure1})-(\ref{eq:defineconstraintoccupancymeasure3}). Moreover, at the beginning of each episode $t$, the algorithm $\pi$ associated with the occupancy measure~$q_{t}^{\pi,P}$ chooses a \emph{deterministic} policy $\pi_{t}$ by assigning an action $a\in\mathcal{A}$ to each state $s\in \mathcal{S}$ according to the probability
\begin{align}
Pr[a | s] = \frac{q_{t}^{\pi,P}(s,a)}{\sum_{b\in\mathcal{A}} q_{t}^{\pi,P}(s,b)}. \label{eq:definerelationpolicyoccupancy}
\end{align}
Then, it is not hard to show that the expected total loss, i.e., the first term in (\ref{eq:definetotalonlinecost}), can be expressed as $\text{loss}^{\pi}(1:T) \triangleq \mathbb{E} \left[ \sum_{t=1}^{T} \langle q_{t}^{\pi,P},l_{t} \rangle \Big| \pi,P \right]$. Finally, the regret of an RL algorithm~$\pi$ is defined to be the sum of the loss regret $R_{\text{loss}}^{\pi}(T)$ and the switching costs of as follows:
\begin{align}
R^{\pi}(T) \triangleq \underbrace{\max_{q\in \mathbb{C}(P)} \mathbb{E}\left[ \left. \sum_{t=1}^{T} \langle q_{t}^{\pi,P} - q,l_{t} \rangle \right| \pi,P \right]}_{\text{loss regret:}\; R_{\text{loss}}^{\pi}(T)}+\underbrace{ \mathbb{E}\left[ \sum_{t=1}^{T-1} \beta \cdot \mathbf{1}_{\{\pi_{t+1} \neq \pi_{t}\}} \Big| \pi,P \right]}_\text{switching costs}. \label{eq:defineregret}
\end{align}
Therefore, our goal in this paper is to design RL algorithms that achieve as low regret as possible against any possible sequence of loss functions $\left\{l_{t}\right\}_{t=1}^{T}$ and state transition function $P$.
\section{A Lower Bound} \label{sec:lowerbound}
In this section, we will develop a lower bound on the regret for adversarial RL with switching costs. Such a lower bound will quantify how difficult it is to control the regret with switching costs under adversarial RL. In Theorem~\ref{theorem:lowerbound} below, we provide this lower bound, the proof of which is given in Appendix~\ref{appendix:proofoftheoremlowerbound}. (In Sec.~\ref{sec:knowntransitionprob} and Sec.~\ref{sec:unknowntransitionprob}, we will provide two near-optimal RL algorithms to achieve this lower bound.)
\begin{theorem}\label{theorem:lowerbound}
For adversarial RL with switching costs and $T\geq\max{\{6H^2 SA,\beta\}}$, the regret of any RL algorithm $\pi$ can be lower-bounded as follows,
\begin{align}
R^{\pi}(T) \geq \tilde{\Omega}\left( \beta^{1/3} \left( H S A \right)^{1/3} T^{2/3} \right). \label{eq:theoremlowerbound}
\end{align}
\end{theorem}
Theorem~\ref{theorem:lowerbound} shows that in adversarial RL with switching costs, the dependency on $T$ of the best achievable regret is at least $\tilde{\Omega}( T^{2/3} )$. Thus, the best achieved regret (whose dependency on $T$ is $\tilde{O}(\sqrt{T})$) in {\em static} RL with switching costs (in~\cite{bai2019provably,qiao2022sample}, etc) as well as adversarial RL \emph{without} switching costs (in~\cite{zimin2013online,jin2018q}, etc) is no longer achievable. This demonstrates the fundamental challenge of switching costs in adversarial RL, and it is expected that new challenges will arise when developing provably efficient algorithms.
Further, in Theorem~\ref{theorem:lossswitchingtradeoff} below, we characterize precisely the new trade-off between the loss regret and switching costs defined in (\ref{eq:defineregret}). The proof is provided in Appendix~\ref{appendix:proofoftheoremlossswitchingtradeoff}. Intuitively, by switching more, the online RL algorithm can adapt more flexibly to the new information learned, and thus achieves a lower loss regret. On the other hand, if fewer switches are allowed, the online RL algorithm is less flexible to adapt to the new information learned, which will incur a larger loss regret.
\begin{theorem}\label{theorem:lossswitchingtradeoff}
For adversarial RL with switching costs, with the switching costs equal to $O\left( \beta\cdot \mathcal{N}^{\text{swi}} \right)$, the loss regret can be lower-bounded by $\tilde{\Omega}\left( \sqrt{\frac{HSA}{\mathcal{N}^{\text{swi}}}}\cdot T \right)$. Alternatively, to achieve a loss regret equal to $\tilde{O}\left( \sqrt{\frac{HSA}{\mathcal{N}^{\text{swi}}}}\cdot T \right)$, the switching costs incurred have to be larger than $\Omega\left( \beta\cdot \mathcal{N}^{\text{swi}} \right)$.
\end{theorem}
Theorem~\ref{theorem:lossswitchingtradeoff} provides an interesting and necessary trade-off between the loss regret and switching costs. We further elaborate this result in three cases. \textbf{First}, in order to achieve a loss regret $\tilde{O} ( H\sqrt{SAT} )$, Theorem~\ref{theorem:lossswitchingtradeoff} shows that the number of switches $\mathcal{N}^{\text{swi}}$ (and thus the switching costs incurred) must be linear in $T$, i.e., essentially switching at almost all episodes. This is consistent with the regret achieved in adversarial RL \emph{without} switching costs, i.e., allowing switching linear-to-$T$ number of times for free. But our result further implies that, without linear-to-$T$ switches of the policy, it is impossible to achieve an $\tilde{O}( \sqrt{T} )$ loss regret. \textbf{Second}, Theorem~\ref{theorem:lossswitchingtradeoff} shows that, if only a constant or $O(\ln\ln T)$ number of switches are allowed, the loss regret must be linear in~$T$. In contrast, in \emph{static} RL, an $\tilde{O}(\sqrt{T})$ loss regret is achieved with only $O(\ln\ln T)$ switches~\cite{qiao2022sample}. This indicates that the adversarial nature of RL necessarily requires significantly more policy switches to achieve a low loss regret. \textbf{Third}, Theorem~\ref{theorem:lossswitchingtradeoff} suggests that the loss regret and switching costs can be balanced at the order of $\tilde{O}\left( T^{2/3} \right)$. That is, to achieve the $\tilde{O}\left( T^{2/3} \right)$ loss regret, the switching costs incurred have to be $\tilde{\Omega}\left( T^{2/3} \right)$. This is consistent with Theorem~\ref{theorem:lowerbound}, where the regret (including both the loss regret and switching costs) is lowered-bound by $\tilde{\Omega}\left( T^{2/3} \right)$.
\section{The Case when the Transition Function is Known}\label{sec:knowntransitionprob}
In this section, we study the case when the transition function is \emph{known}, and we will further explore the more challenging case when the transition function is \emph{unknown} in Sec.~\ref{sec:unknowntransitionprob}. We propose a novel algorithm (please see Algorithm~\ref{alg:ereps}) with a regret that matches the lower bound in (\ref{eq:theoremlowerbound}). Our algorithm is called Switching rEduced EpisoDic relative entropy policy Search (\text{SEEDS}).
\text{SEEDS}~is inspired by the episodic method in bandit learning~\cite{shi2022power}. In bandit learning, the idea is to divide the time horizon into $\Theta(T^{2/3})$ episodes, and pull one \emph{single} Exp3-arm in an episode. By doing so, the total switching cost is trivially $O(T^{2/3})$. Meanwhile, the loss regret in an episode is $\Theta(\eta \cdot (T^{1/3})^2)$, which is proportional to the loss variance in an episode. The final $O(T^{2/3})$ regret is then achieved by taking the sum of all these costs and tuning the parameter $\eta=\Theta(T^{-2/3})$. However, in the adversarial MDP setting that we consider, there is a key difference due to random state-action visitations that cause several new challenges as we discuss in the rest of this section.
\begin{algorithm}[t]
\caption{Switching rEduced EpisoDic relative entropy policy Search (\text{SEEDS})}
\begin{algorithmic}
\STATE \textbf{Parameters:} $\eta = \tilde{\Theta}\left( \beta^{-1/3} H^{2/3} (SA)^{-1/3} T^{-2/3} \right)$ and $\tau = \tilde{\Theta}\left( \beta^{2/3} (HSA)^{-1/3} T^{1/3} \right)$.
\STATE \textbf{Initialization:} $Pr[a|s]= \frac{1}{A}$ for all $(s,a) \in \mathcal{S}\times \mathcal{A}$. Choose $\pi_{[1]}^{\text{SEEDS}}$ according to (\ref{eq:definerelationpolicyoccupancy}).
\FOR{$u = 1 : \left\lceil \frac{T}{\tau} \right\rceil$}
\FOR{$t = (u-1)\tau+1 : \min\{u \tau, T\}$}
\STATE \textit{Step 1:} Execute the updated policy $\pi_{[u]}^{\text{SEEDS}} = \pi^{\hat{q}_{[u]}^{\text{SEEDS},P}}$.
\ENDFOR
\STATE At the end of super-episode $u$,
\STATE \textit{Step 2:} Estimate the losses $\hat{l}_{[u]}^{\text{SEEDS}}(s,a)$ for all $(s,a)$ according to (\ref{eq:knowntpupdateloss}).
\STATE \textit{Step 3:} Update the occupancy measure $\hat{q}_{[u+1]}^{\text{SEEDS},P}(s,a)$ according to (\ref{eq:knowntpupdateom}). Update the deterministic policy $\pi^{\hat{q}_{[u+1]}^{\text{SEEDS},P}}$ according to (\ref{eq:definerelationpolicyoccupancy}).
\ENDFOR
\end{algorithmic}
\label{alg:ereps}
\end{algorithm}
\textbf{Super-episode-based policy search:} \text{SEEDS}~divides the episodes into $\mathcal{U} = \left\lceil \frac{T}{\tau} \right\rceil$ super-episodes, where $\tau\in \mathbb{Z}_{++}$ is a tunable parameter and a strictly positive integer. Each super-episode includes $\tau$ consecutive episodes. For all episodes in each super-episode $u=1$, $...$, $\mathcal{U}$, \text{SEEDS}~uses the same policy $\pi^{\hat{q}_{[u]}^{\text{SEEDS},P}}$ (\textit{Step-1} in Algorithm~\ref{alg:ereps}) that was updated at the end of the last super-episode $u-1$, where $\hat{q}_{[u]}^{\text{SEEDS},P}$ is the updated occupancy measure (that we will introduce soon) of \text{SEEDS}~for super-episode $u$. Thus, \text{SEEDS}~switches the policy at most once in each super-episode.
\textbf{A novel idea for estimating the losses:} At the end of super-episode $u$, \text{SEEDS}~estimates the losses $l_{[u]}(s,a)$ of all state-action pairs in super-episode $u$. Here, it is instructive to see why the episodic importance-estimating method in adversarial bandit learning (i.e., without state transitions) does not apply to our problem. Note that due to state transitions in our more general MDP setting, we are not guaranteed to visit a \emph{single} state-action pair for the whole super-episode. A naive but intuitive solution may be pretending that each state-action pair visited in super-episode $u$ was the \emph{single} one visited. Then, we can let the estimated loss of each state-action pair $(s,a)$ to be $\hat{l}_{[u]}(s,a) = \frac{\bar{l}_{[u]}(s,a)}{1-(1-\hat{q}_{[u]}^{\text{SEEDS},P}(s,a))^{\tau}} \mathbf{1}_{\{(s,a)\text{ was visited in super-episode }u\}}$, where the numerator $\bar{l}_{[u]}(s,a) = \sum_{t=(u-1)\tau+1}^{u\tau} l_{t}(s,a) / \tau$ is the average loss of $(s,a)$. If we assume that the loss $l_{t}$ for all episodes $t$ in super-episode~$u$ were the same, according to the analysis in bandit learning and the inequality $1-(1-x)^{\tau} \geq x$ for all $0\leq x\leq 1$, this idea would have worked. However, the problem is that, inside super-episode $u$, the loss function $l_{t}$ for each episode $t$ could change arbitrarily. Thus, the estimated loss $\hat{l}_{[u]}(s,a)$ above is actually unknown and an ill-defined value.
To resolve the aforementioned difficulty due to randomly-visited state-action pairs and arbitrarily-changing loss functions, \text{SEEDS}~estimates the loss as follows (\textit{Step-2} in Algorithm~\ref{alg:ereps}),
\begin{equation}
\hat{l}_{[u]}^{\text{SEEDS}}(s,a) = \sum\limits_{j=1}^{J_{[\uu]}} \frac{l_{t_{j}(s,a)}(s,a)}{\hat{q}_{[u]}^{\text{SEEDS},P}(s,a)} \mathbf{1}_{\{(s,a)\text{ was visited in episodes }t_{1}(s,a), ..., t_{J_{[\uu]}}(s,a)\text{ of super-episode }u\}}, \label{eq:knowntpupdateloss}
\end{equation}
where $J_{[\uu]}$ is the maximum number of episodes that the state-action pair $(s,a)$ was visited in super-episode $u$. In other words, in super-episode $u$, this state-action pair $(s,a)$ was not visited in any other episode $t$, such that $t\in \{(u-1)\tau+1,...,u\tau\} / \{t_{1}(s,a), ..., t_{J_{[\uu]}}(s,a)\}$. Thus, \text{SEEDS}~estimates the losses based on the observable true losses in super-episode $u$. In this way, \text{SEEDS}~elegantly resolves the aforementioned difficulty due to the random state transitions and adversarial losses.
Our novel idea in (\ref{eq:knowntpupdateloss}) may be of independent interest for other problems with state transitions and non-stationary or adversarial losses. Indeed, in Sec.~\ref{sec:unknowntransitionprob}, we will apply this idea to the case when the transition function is unknown.
In Lemma~\ref{lemma:knownexpectedlossunbias} below, we show that the estimated loss in (\ref{eq:knowntpupdateloss}) is an unbiased estimation of the true loss in super-episode $u$. This is an important property that we will exploit in our regret analysis. The proof of Lemma~\ref{lemma:knownexpectedlossunbias} is provided in Appendix~\ref{appendix:proofoflemmaknownexpectedlossunbias}. We use $\mathcal{F}_{[u]}$ to denote the $\sigma$-algebra generated by the observation of \text{SEEDS}~before super-episode $u$.
\begin{lemma}\label{lemma:knownexpectedlossunbias}
The conditional expectation of the estimated loss designed in (\ref{eq:knowntpupdateloss}) is equal to
\begin{align}
\mathbb{E} \left[ \hat{l}_{[u]}^{\text{SEEDS}}(s,a) \Big| \mathcal{F}_{[u]} \right] = l_{[u]}(s,a), \text{ for all } (s,a), \label{eq:knownexpectedlossunbias}
\end{align}
where the expectation is taken with respect to the randomness of the episodes $t_{1}(s,a)$, ..., $t_{J_{[\uu]}}(s,a)$, in which the state-action pair $(s,a)$ was visited, and $l_{[u]}(s,a) = \sum_{t=(u-1)\tau+1}^{\min\{u\tau,T\}} l_{t}(s,a)$ is the true loss of $(s,a)$ in super-episode~$u$.
\end{lemma}
\textbf{Updating the occupancy measure:} Finally, according to online mirror descent~\cite{rakhlin2009lecture,zimin2013online}, \text{SEEDS}~updates the occupancy measure $\hat{q}_{[u+1]}^{\text{SEEDS},P}(s,a)$ for all state-action pairs $(s,a) \in \mathcal{S}\times \mathcal{A}$ as follows (\textit{Step-3} in Algorithm~\ref{alg:ereps}),
\begin{align}
\hat{q}_{[u+1]}^{\text{SEEDS},P} = \argmin_{q\in \mathbb{C}(P)} \left\{ \eta \cdot \left\langle q, \hat{l}_{[u]}^{\text{SEEDS}} \right\rangle + D_{\text{KL}}\left( q \left\| \hat{q}_{[u]}^{\text{SEEDS},P} \right. \right) \right\}, \label{eq:knowntpupdateom}
\end{align}
where $D_{\text{KL}}(q\|q') \triangleq \sum\limits_{s\in\mathcal{S},a\in\mathcal{A}} q(s,a) \ln \frac{q(s,a)}{q'(s,a)} - \sum\limits_{s\in\mathcal{S},a\in\mathcal{A}} \left[ q(s,a) - q'(s,a) \right]$ is the unnormalized relative entropy between two occupancy measures $q$ and $q'$ on the space $\mathcal{S} \times \mathcal{A}$. Recall that $\mathbb{C}(P)$ is formulated by (\ref{eq:defineconstraintoccupancymeasure1})-(\ref{eq:defineconstraintoccupancymeasure3}). Note that the term $\langle q, \hat{l}_{[u]}^{\text{SEEDS}} \rangle$ represents the expected loss in super-episode $u$, with respect to the newly-estimated loss function $\hat{l}_{[u]}^{\text{SEEDS}}$. Thus, it captures how \text{SEEDS}~adapts to and explores the newly-estimated loss function. In addition, the term $D_{\text{KL}}(q\|\hat{q}_{[u]}^{\text{SEEDS},P})$ serves as a regularizer to ensure that the updated occupancy measure in (\ref{eq:knowntpupdateom}) stays close to $\hat{q}_{[u]}^{\text{SEEDS},P}$. Thus, it captures how \text{SEEDS}~exploits the previously-estimated loss functions before super-episode~$u$. As a result, by tuning the parameter $\eta$ in (\ref{eq:knowntpupdateom}), the updated occupancy measure strikes a balance between exploration and exploitation.
We characterize the regret of \text{SEEDS}~in Theorem~\ref{thm:knowntranprobregret} below.
\begin{theorem}\label{thm:knowntranprobregret}
Consider adversarial RL with switching costs introduced in Sec.~\ref{sec:problemformulation}. When the transition function $P$ is known, the regret of \text{SEEDS}~is upper-bounded as follows,
\begin{align}
R^{\text{SEEDS}}(T) \leq \tilde{O}\left( \beta^{1/3} \left( H S A \right)^{1/3} T^{2/3} \right). \label{eq:knowntranprobregret}
\end{align}
\end{theorem}
Theorem~\ref{thm:knowntranprobregret} shows that the regret of \text{SEEDS}~matches the lower bound in (\ref{eq:theoremlowerbound}) in terms of the dependency on all the parameters $T$, $S$, $A$, $H$ and $\beta$. Thus, the regret of \text{SEEDS}~is order-wise optimal. \emph{To the best of our knowledge, this is the first regret result for adversarial RL with switching costs.} To prove Theorem~\ref{thm:knowntranprobregret}, the main difficulty lies in capturing the effects of the arbitrarily-changing losses and multiple random visitations of each state-action pair in a super-episode. To overcome this difficulty, our new idea is to first upper-bound the loss regret based on the correlated loss feedback in a super-episode, and then relate these upper bounds across all super-episodes to the final regret. The first step relies on the proof of Lemma~\ref{lemma:knownexpectedlossunbias}, and the second step relies on another lemma in Appendix~\ref{subsec:proofofthmknowntranprobregret} that transfers the original regret formulation to a form based on the losses from the entire super-episode. Please see Appendix~\ref{appendix:proofofthmknowntranprobregret} for details and the proof of Theorem~\ref{thm:knowntranprobregret}.
Further, in Theorem~\ref{thm:seedstradeofflossswitch} below, we show that \text{SEEDS}~attains a trade-off between the loss regret and switching costs that matches the trade-off in Theorem~\ref{theorem:lossswitchingtradeoff}. The proof of Theorem~\ref{thm:seedstradeofflossswitch} follows the loss-regret bound of \text{SEEDS}~proved in Appendix~\ref{appendix:proofofthmknowntranprobregret} and the trivial switching-cost bound $\beta \cdot \left\lceil \frac{T}{\tau} \right\rceil$. Please see the end of Appendix~\ref{appendix:proofofthmknowntranprobregret} for details.
\begin{theorem}\label{thm:seedstradeofflossswitch}
Let $\mathcal{N}^{\text{SEEDS}} \triangleq \left\lceil \frac{T}{\tau} \right\rceil$. Then, with the switching costs equal to $O\left( \beta\cdot \mathcal{N}^{\text{SEEDS}} \right)$, \text{SEEDS}~can achieve a loss regret upper-bounded by $\tilde{O}\left( \sqrt{\frac{HSA}{\mathcal{N}^{\text{SEEDS}}}}\cdot T \right)$.
\end{theorem}
\section{The Case when the Transition Function is Unknown}\label{sec:unknowntransitionprob}
\begin{algorithm}[t]
\caption{\text{SEEDS}-Unknown Transition (\text{SEEDS-UT})}
\begin{algorithmic}
\STATE \textbf{Parameters:} $\eta = \tilde{\Theta}\left( \beta^{-1/3} H^{1/3} (SA)^{-1/3} T^{-2/3} \right)$, $\tau = \tilde{\Theta}\left( \beta^{2/3} H^{-2/3} (SA)^{-1/3} T^{1/3} \right)$, $\gamma = \tilde{\Theta}\left( \beta^{1/3} H^{2/3} (SA)^{-2/3} T^{-1/2} \right)$, and $0< \delta < 1$.
\STATE \textbf{Initialization:} $\hat{q}_{[1]}^{\text{SEEDS-UT},\mathcal{P}}(s',s,a) = \frac{1}{S_{h+1} S_{h} A}$ and $M_{[1]}(s',s,a) = N_{[1]}(s,a) = 0$, for all $(s',s,a) \in \mathcal{S}_{h+1} \times \mathcal{S}_{h} \times \mathcal{A}$ and all $h$. $\mathcal{P}_{[1]}$ contains all possible transition functions. Choose $\pi_{[1]}^{\text{SEEDS-UT}} = \pi^{\hat{q}_{[1]}^{\text{SEEDS-UT},\mathcal{P}}}$ according to (\ref{eq:defineconstraintoccupancymeasure1}) and (\ref{eq:definerelationpolicyoccupancy}).
\FOR{$u = 1 : \left\lceil \frac{T}{\tau} \right\rceil$}
\FOR{$t = (u-1)\tau+1 : \min\{u \tau, T\}$}
\STATE \textit{Step 1:} Execute the updated policy $\pi_{[u]}^{\text{SEEDS-UT}} = \pi^{\hat{q}_{[u]}^{\text{SEEDS-UT},\mathcal{P}}}$.
\ENDFOR
\STATE At the end of super-episode $u$,
\STATE \textit{Step 2:} Estimate the losses $\hat{l}_{[u]}^{\text{SEEDS-UT}}(s,a)$ for all $(s,a)$ according to (\ref{eq:unknowntpupdateloss}).
\STATE \textit{Step 3:} Estimate the transition-function set $\mathcal{P}_{[u+1]}$ according to (\ref{eq:unknowntpupdatetransition}).
\STATE \textit{Step 4:} Update the occupancy measure $\hat{q}_{[u+1]}^{\text{SEEDS-UT},\mathcal{P}}(s',s,a)$ according to (\ref{eq:knowntpupdateom}), but subject to a different constraint $q\in \mathbb{C}\left(\mathcal{P}_{[u+1]}\right)$. Update the deterministic policy $\pi^{\hat{q}_{[u+1]}^{\text{SEEDS-UT},\mathcal{P}}}$ according to (\ref{eq:defineconstraintoccupancymeasure1}) and (\ref{eq:definerelationpolicyoccupancy}).
\ENDFOR
\end{algorithmic}
\label{alg:erepss}
\end{algorithm}
In this section, we study a more challenging case when the transition function is \emph{unknown}. We propose a novel algorithm (please see Algorithm~\ref{alg:erepss}) with a regret that matches the lower bound in (\ref{eq:theoremlowerbound}) in terms of the dependency on all parameters, except with a small factor of $\tilde{O}(H^{1/3})$. Specifically, to address the new difficulty due to the \emph{unknown} transition function $P$ in this case, we advance SEEDS into SEEDS-UT (where UT stands for ``unknown transition") with three new components as we explain below.
1. Since the transition function $P$ is unknown, updating the occupancy measure $\hat{q}(s,a)$ (as in \text{SEEDS}) is not good enough. Instead, \text{SEEDS-UT}~updates the occupancy measure $\hat{q}(s',s,a)$ to take state transitions into consideration.
2. Since the transition function $P$ is unknown, the updated occupancy measure could be different from the true one. To resolve this issue, we generalize the method in~\cite{neu2015explore}, with a key difference to handle the random sequence of the state-action pairs visited in each super-episode. Specifically, \text{SEEDS-UT}~estimates the loss for each super-episode $u$ as follows (\textit{Step-2} in Algorithm~\ref{alg:erepss}),
\begin{align}
\hat{l}_{[u]}^{\text{SEEDS-UT}}(s,a) = \sum\limits_{j=1}^{J_{[\uu]}} \frac{l_{t_{j}(s,a)}(s,a)}{\mathcal{Q}_{[u]}^{\gamma}(s,a)} \mathbf{1}_{\{(s,a)\text{ was visited in episodes }t_{1}(s,a), ..., t_{J_{[\uu]}}(s,a)\text{ of super-episode }u\}}, \label{eq:unknowntpupdateloss}
\end{align}
where $\mathcal{Q}_{[u]}^{\gamma}(s,a) \triangleq \max_{q\in \mathbb{C}(\mathcal{P}_{[u]})} q(s,a) + \gamma$ is the sum of the largest probability of visiting $(s,a)$ among all occupancy measures in $\mathbb{C}(\mathcal{P}_{[u]})$ and a tunable parameter $\gamma>0$, and $\mathcal{P}_{[u]}$ is a transition-function set that we will introduce soon. Note that (\ref{eq:unknowntpupdateloss}) is another application of our idea in (\ref{eq:knowntpupdateloss}) for estimating losses in a problem with state transitions and adversarial losses.
In Lemma~\ref{lemma:unknownexpectedlossunbias} below, we show that the gap between the expectation of the estimated loss and the true loss is controlled by the parameter $\gamma$. The proof of Lemma~\ref{lemma:unknownexpectedlossunbias} is provided in Appendix~\ref{appendix:proofoflemmaunknownexpectedlossunbias}. We use $\mathcal{F}_{[u]}$ to denote the $\sigma$-algebra generated by the observation of \text{SEEDS-UT}~before super-episode $u$.
\begin{lemma}\label{lemma:unknownexpectedlossunbias}
The conditional expectation of the estimated loss designed in (\ref{eq:unknowntpupdateloss}) is equal to
\begin{align}
\mathbb{E} \left[ \left. \hat{l}_{[u]}^{\text{SEEDS-UT}}(s,a) \right| \mathcal{F}_{[u]} \right] = \frac{q_{[u]}^{\text{SEEDS-UT},P}(s,a)}{\max_{q\in \mathbb{C}(\mathcal{P}_{[u]})} q(s,a) + \gamma} \cdot l_{[u]}(s,a), \text{ for all } (s,a), \label{eq:unknownexpectedlossunbias}
\end{align}
where the expectation is taken with respect to the randomness of the episodes $t_{1}(s,a)$, ..., $t_{J_{[\uu]}}(s,a)$, in which $(s,a)$ was visited, $q_{[u]}^{\text{SEEDS-UT},P}(s,a)$ is the true occupancy measure of \text{SEEDS-UT}~conditioned on $\mathcal{F}_{[u]}$, and $l_{[u]}(s,a) = \sum_{t=(u-1)\tau+1}^{\min\{u\tau,T\}} l_{t}(s,a)$ is the true loss of $(s,a)$ in super-episode~$u$.
\end{lemma}
Lemma~\ref{lemma:unknownexpectedlossunbias} shows that, as long as $\mathcal{P}_{[u]}$ is sufficiently good for estimating the true transition function $P$ (we will show how to construct such a $\mathcal{P}_{[u]}$ below), by carefully tuning $\gamma$, the bias caused by $ \max_{q\in \mathbb{C}(\mathcal{P}_{[u]})} q(s,a) + \gamma$ (i.e., $\mathcal{Q}_{[u]}^{\gamma}(s,a)$) should be sufficiently small, so that the estimated loss is still sufficiently accurate.
3. Since the transition function $P$ is unknown, the constraint in (\ref{eq:knowntpupdateom}) is no longer known. To resolve this issue, we generalize the method in~\cite{jin2020learning}, with a difference to handle the samples from the whole super-episode. Specifically, at the end of each super-episode, \text{SEEDS-UT}~collects the samples from the whole super-episode to update the empirical transition probability $\bar{P}_{[u+1]}(s'|s,a) = \frac{M_{[u+1]}(s',s,a)}{\max\left\{N_{[u+1]}(s,a),1\right\}}$, where $M_{[u+1]}(s',s,a)$ and $N_{[u+1]}(s,a)$ denote the number of times visiting $(s',s,a)$ and $(s,a)$ before super-episode $u+1$, respectively. Then, based on the empirical Bernstein bound~\cite{maurer2009empirical}, \text{SEEDS-UT}~constructs a transition-function set $\mathcal{P}$ as follows (\textit{Step-3} in Algorithm~\ref{alg:erepss}),
\begin{align}
\mathcal{P}_{[u+1]} = \left\{ \hat{P}_{[u+1]}: \left| \hat{P}_{[u+1]}(s'|s,a) - \bar{P}_{[u+1]}(s'|s,a) \right| \leq \epsilon_{[u+1]}(s',s,a), \text{ for all } (s',s,a) \right\}, \label{eq:unknowntpupdatetransition}
\end{align}
where $\epsilon_{[u+1]}(s',s,a) = 2\sqrt{\frac{\bar{P}_{[u+1]}(s',s,a)\ln\frac{TSA}{\delta}}{\max\left\{N_{[u+1]}(s,a)-1,1\right\}}} + \frac{14\ln\frac{TSA}{\delta}}{3\max\left\{N_{[u+1]}(s,a)-1,1\right\}}$, and $\delta \in (0,1)$ is the confidence parameter. Finally, the occupancy measure $\hat{q}_{[u+1]}^{\text{SEEDS-UT},\mathcal{P}}(s',s,a)$ is updated according to (\ref{eq:knowntpupdateom}), but subject to a different constraint $q\in \mathbb{C}\left(\mathcal{P}_{[u+1]}\right)$ (\textit{Step-4} in Algorithm~\ref{alg:erepss}).
We characterize the regret of \text{SEEDS-UT}~in Theorem~\ref{thm:unknowntranprobregret} below.
\begin{theorem}\label{thm:unknowntranprobregret}
Consider adversarial RL with switching costs introduced in Sec.~\ref{sec:problemformulation}. When the transition function $P$ is unknown, with probability $1-\delta$, the regret of \text{SEEDS-UT}~is upper-bounded as follows,
\begin{align}
R^{\text{SEEDS-UT}}(T) \leq \tilde{O}\left( \beta^{1/3} H^{2/3} \left( S A \right)^{1/3} T^{2/3} \left(\ln\frac{TSA}{\delta}\right)^{1/2} \right). \label{eq:unknowntranprobregret}
\end{align}
\end{theorem}
Theorem~\ref{thm:unknowntranprobregret} shows that the regret of \text{SEEDS-UT}~matches the lower bound in (\ref{eq:theoremlowerbound}) in terms of the dependency on $T$, $S$, $A$, and $\beta$, except with a small factor of $\tilde{O}(H^{1/3})$. That is, the regret of \text{SEEDS-UT}~is near-optimal. \emph{To the best of our knowledge, this is the first regret result for adversarial RL with switching cost when the transition function is unknown.} To prove Theorem~\ref{thm:unknowntranprobregret}, the main difficulty is that, due to the delayed switching and unknown transition function, the losses of \text{SEEDS-UT}~in the episodes of any super-episode are highly-correlated and the true occupancy measure is unknown. As a result, the existing analytical ideas in adversarial RL without switching costs and adversarial bandit learning with switching costs do not work here. To overcome these new difficulties, our analysis involves several new ideas, e.g., we construct a series in (\ref{eq:sketchproofunknownregretdecompose2ii8}) to handle multiple random visitations of each state-action pairs, and we establish a super-episodic version of concentration in \textit{Step-2-iii} of Appendix~\ref{appendix:proofofthmunknowntranprobregret} by relating the second-order moment of the estimated loss that we design to the true loss and the length $\tau$ of a super-episode. Please see Appendix~\ref{appendix:proofofthmunknowntranprobregret} for the detailed proof of Theorem~\ref{thm:unknowntranprobregret}.
\section{Conclusion and Future Work}\label{sec:conclusion}
In this paper, we make the first effort towards addressing the challenge of switching costs in adversarial RL. First, we provide a lower bound that shows that the best achieved regret in static RL with switching costs (as well as adversarial RL without switching costs) is no longer achievable. In addition, we characterize precisely the new trade-off between the loss regret and switching costs, which shows that the adversarial nature of RL necessarily requires more switches to achieve a low loss regret. Moreover, we propose two novel switching-reduced algorithms with regrets that match our lower bound when the transition function is known, and match our lower bound within a small factor of $\tilde{O}(H^{1/3})$ when the transition function is unknown.
Several future directions are worth pursuing. First, it is important to study adversarial RL with switching costs in linear and more general MDP settings. Another interesting future work is to extend our study to the dynamic regret, which allows the optimal policy to change over time.
| {'timestamp': '2023-02-10T02:03:33', 'yymm': '2302', 'arxiv_id': '2302.04374', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04374'} | arxiv |
\section{Introduction}
Deep neural network (DNN) has been successfully applied in many fields, such as image classification, speech recognition and natural language processing. Although DNN has excellent performance in these fields, researchers found that in the entire model life cycle from model training to inference, it is vulnerable to various attacks~\citep{ref3,ref2}. In the model prediction stage, adversarial example attack adds subtle perturbations to the input to fool the model. In the model training stage, poisoning attack modifies the training set to affect the model function, which can insert backdoor to the model.
Backdoor attack is one of the most insidious attack occurred in the DNN training phase~\citep{ref1,gao2020backdoor}. The attacker only needs to poison a small fraction of training samples to inject backdoors into the model. For samples with triggers added, the backdoored model will output the target label pre-specified by the attacker.
The backdoored model functions normally in predicting benign samples in the absence of the trigger.
Therefore, backdoor attack can be immune to some effective defense methods against general poisoning attacks that aim to degrade the overall accuracy performance of the infected model. For example, poisoning attack but not backdoor attack can be detected by model performance on a hold-out set. Thus, the trigger mode of backdoor attack is more insidious than poisoning attack.
Since backdoor attack was introduced into DNN, many attack methods~\citep{r2,blend,wanet,sig} have been proposed, but these methods suffer from two main limitations: the trigger pattern of the backdoor is fixed or universal and the human eye can recognize the trigger presented in the abnormal image. The trigger mode is exemplified in Figure~\ref{fig1}. Therefore, many defense methods~\citep{r6,r9,nc} are designed against universal triggers. They are effective to capture universal trigger backdoor due to the same and strong universal pattern. For the visibility of triggers, when the data curator checks the training set, the suspected samples can be identified and eliminated.
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.1cm}
\centering
\scalebox{0.8}{\includegraphics[width=\linewidth]{Pic/fig1small.pdf}}
\caption{Comparison between backdoor examples generated by our method and existing backdoor attacks.}
\label{fig1}
\end{figure}
Recently, few advanced backdoor trigger crafting methods have been proposed\citep{r4,ISSBA}. In their approach, the generation pattern of backdoor triggers obviates the shortcomings of conventional trigger generation methods. More specifically, triggers are dynamic and change for different inputs. Such sample-specific triggers can trivially evade most mainstream backdoor detections that rely on the assumption of universal trigger patterns.
Nonetheless, these works still have deficiencies: triggers are not often exclusive~\citep{r4}, or the trigger generator is not transferable across specific trained models and tasks~\citep{ISSBA}.
To resolve the shortcomings of the above backdoor attack methods, this work proposes a backdoor attack whose triggers vary with input and are imperceptible to human eyes, which can thus resist the mainstream backdoor defense methods~\citep{nc,fp,strip,sentinet}. At the same time, as shown in Table \ref{t1}, compared with the existing dynamic backdoor attacks, the triggers generated by our method exhibit high exclusiveness, and the trigger generator is transferable.
Generally, we first inject a sample-specific feature (i.e., visible edge pattern) into an incoming image and then transform this feature into an imperceptible backdoor trigger through the denoising autoencoder, whilst altering the label to the target label. Such transformed images will be regarded as poisoned samples, which will be mixed with benign samples at the training phase to train the victim model. In contrast to~\citep{r4} where a trigger generator has to be trained jointly with a targeted model, our attack does not require any knowledge of the victim model (i.e., architecture, training loss). Our attack only needs to poison a small fraction of training samples provided to the data curator, which does not need to control or have knowledge of model training (e.g., model loss function and model structure) performed by the victim user. As exemplified in Figure~\ref{fig1}, in addition to sample-specific, the trigger of our attack is imperceptible, which cannot be visually recognized.
\begin{table}[t]
\centering
\scalebox{0.65}{
\begin{tabular}{ccccc}
\toprule
\textbf{Work} &
\textbf{\makecell[c]{No \\ training \\ control}} &
\textbf{Imperceptibility}& \textbf{Transferability} & \textbf{Exclusivity} \\
\midrule
\cite{r4}& × & × & × & \checkmark \\
\cite{ISSBA}& \checkmark & \checkmark & \checkmark & ×\\
Ours & \checkmark & \checkmark & \checkmark & \checkmark \\
\bottomrule
\end{tabular}}
\caption{A comparison of dynamic (sample-specific) backdoor attacks}
\label{t1}
\end{table}
\vspace{0.05cm}
\noindent{\bf Our Contributions.} Main contributions of this work are threefold:
\begin{itemize}[leftmargin=*]
\item We propose a backdoor attack framework based on denoising autoencoder, which generates trigger samples by denoising the injected (perceptible) image-specific feature. Therefore, the generated triggers are imperceptible and sample-specific. A small fraction (i.e., 1\%) of trigger samples is able to successfully implant the backdoor without any prior knowledge or control of the victim model.
\item We propose diverse feature injection means to be compatible with the denoising autoencoder. The triggers generated by our method are also exclusive. The trigger generator (i.e., denoising autoencoder) trained for a given model of a given task is transferable to not only other models of the same task but also to other tasks.
\item We validate the effeciency of our method on large-scaled ImageNet and MS-Celeb-1M datasets. On the premise of not deteriorating the accuracy of the model, our method can achieve 99.8\% attack success rate. At the same time, our method bypasses a number of diverse mainstream backdoor defenses of Neural Cleanse, STRIP, SentiNet and Fine-Pruning.
\end{itemize}
\section{Related Work}
\subsection{Backdoor Attacks}
Backdoor is a newly revealed security threat that injects hidden malicious functions into the artificial intelligent system.
Recently, a large number of studies have shown that diverse DNNs are vulnerable to backdoor attacks. According to the characteristics of triggers, existing backdoor attacks can be generally divided into two categories: (1) universal (sample-agnostic) backdoor; (2) dynamic (sample-specific) backdoor.
\noindent{\bf Universal (sample-agnostic) backdoor.}
A trigger pattern stamped on different samples is fixed, which is easy to be captured by mainstream backdoor defenses.
\citet{badnet} proposed BadNets, which works in the way of data poisoning attack. In the model training stage, the attacker modifies small partial training set by stamping the universal trigger into samples, and corresponding changing the sample label to the target label.
In the prediction stage, the input of the added trigger can activate the backdoor.
After that, \cite{r2} proposed a Trojan attack, which generates triggers by manipulating specific neurons in the clean model, and then fine-tunes the clean model with poisoned data to inject backdoor.
\cite{blend} blended the original image and trigger to get poisoned images, which is different from the patch injection method in BadNets. Poisoned images generated by this method have a certain degree of concealment, but the concealment decreases with the increase of the image blending ratio.
\cite{sig} proposed a clean-label backdoor attack with a sinusoidal signal (SIG) as a trigger. However, more perturbation is required for high-resolution images, which significantly degrades image quality.
The triggers mentioned above are also belong to the visible backdoor attacks, and humans can easily identify abnormal trigger patterns.
\noindent{\bf Dynamic (sample-specific) backdoor. }
In contrast to the universal backdoor above, dynamic backdoor has a flexible trigger pattern, making its generated triggers changeable upon input samples.
\cite{r4} proposed a perceptible
but dynamic trigger generation mode. During the training of a backdoored classification model, they jointly train a trigger generation network, which can generate different triggers for different inputs. However, the trigger generation network is bounded to a specific backdoored model, each backdoored model needs a different trigger generation network, which reduces its real threat due to lack of e.g., transferability to different models.
\cite{ISSBA} proposed to embed the trigger into the DNN through image steganography, making it difficult to distinguish the poisonous image from the benign image visually. The triggers generated by their method are not always sample-specific. That is, a trigger of a sample can still be used to activate a different sample when it is stamped, exhibiting low exclusiveness.
Such a low exclusiveness is obviated by our attack.
\cite{wanet} defined the sampling position of the reverse warping for each point in the target image through the image warping function, thereby generating a covert backdoor image. However, in order to bypass the mainstream defense methods, this method needs to poison 30\% of the training set. In their attack methods, in addition to poisoning 10\% of the data, they also need 20\% of the noise data to bypass the defense methods. Such a high attack budget is hard to be achieved in practice, especially in the data outsourcing scenario. Our attack requires only 1\% poison rate to succeed.
In the clean-label backdoor attack proposed by \cite{r11}, the poisoned image is made close to the image of the target class in pixel space by a constraint function, while close to the source image patched with triggers in feature space. This attack method requires a strong assumption: the attacker has knowledge of the victim model structure or even weights~\citep{ma2022macab}.
In this paper, our proposed imperceptible backdoor attack does not require the attacker to have any knowledge of the training process including the used model structure.
\subsection{Backdoor Defenses}
With an in-depth study of backdoor attack methods, various backdoor defenses have been proposed. According to different defensive objectives, backdoor defenses can be generally divided into two categories: model-based defense and data-based defense~\citep{gao2020backdoor}.
\noindent{\bf Model-based Defenses. } Model-based defenses aim to identify backdoored models, and then remove backdoors or avoid its afterward usage. In the Fine-pruning proposed by \cite{fp}, the pruning and fine tuning of the model are combined. They first prune the dormant neurons in the model when benign samples are inputs, and then fine tune the model to reduce the degrade of clean data accuracy.
\cite{nc} detected whether the model was implanted a backdoor by reversing the trigger and identifying the attacker target label, and then weakened the backdoor success rate through the usage of the reversed trigger to perform backdoor unlearning.
\cite{abs} scanned each neuron in the model and directly modify the activation value, observe the difference of the model output to find the backdoor neuron and reverse the backdoor trigger.
\noindent{\bf Data-based Defenses. } Data-based defenses aim to identify abnormal data and eliminate the possibility of backdoor implantation and activation at the data level. \cite{strip} proposed the STRIP, they found that backdoor samples were insensitive to strong perturbations while benign samples were sensitive. Based on this characteristic, they detected trigger samples in the testing phase of the model---the STRIP can also be used during offline when the training set is accessible. \cite{sentinet} also performed backdoor detection on the samples, they adopted a saliency map (Grad-CAM~\citep{gradcam1}) to locate trigger regions and filter out trigger samples.
Existing defense methods are generally designed for universal triggers, and thus fail for dynamic triggers. Moreover, the size of the trigger also affects the defense effect (e.g.,~\citep{nc,sentinet}). The computational cost of some defense methods is proportional to the number of labels, and when the number of labels is large, the computational cost will be high (e.g.,~\citep{nc}). In our attack, the generated triggers are dynamic and cover the whole image, so they are evasive against mainstream defenses.
\section{Imperceptible Sample-Specific Trigger with Denoising Autoencoder}\label{OVERVIEW}
In this section, we first introduce the pipeline of a backdoor attack, and then define the threat model, followed by an elaboration of our proposed attack.
\subsection{Pipeline of Backdoor Attacks}
For an image-classification task, a DNN model $f(\cdot)$ maps a feature vector $x$ from input image space $X$ to a label $y$ from output category space $Y$, that is, $f: x \mapsto y (x \in X, y \in Y)$. If a backdoor is injected into the model, for a benign input $ x_c $ with no trigger, the model outputs a correct classification result $y_c=f(x_c) $. For a poisoned input $x_p $ with a trigger carried, the trigger will activate the backdoor, making the model output an attacker-targeted label $y_t\in Y $.
In the backdoor attack, the attacker modifies part of the training set to achieve the purpose of injecting the backdoor, that is, the benign sample $(x,y)$ is modified by the trigger generation mode $p(\cdot)$ to gain a trigger sample and the target label generation mode $h(\cdot)$ to obtain poisoned samples $(x_p, y_t)=(p(x), h(y)) \in D_{poison}$. The training set is now a mixture of clean and poisonous samples, which can be expressed as:
\begin{equation}
D_{train}= D_{clean}\cup D_{poison},
\end{equation}
where the poisoning ratio $\rho$ is the ratio of the number of elements in the poisoned dataset $D_{poison}$ to the training set $D_{train}$, which is expressed as:
\begin{equation}
\rho=\frac{|D_{poison}|}{|D_{train} |}.
\end{equation}
\subsection{Threat Model}
\noindent{\bf Knowledge and Capability.} We assume that the attacker can only access and tamper with part of the model training data, but cannot obtain any model information, nor participate in the model training process.
In addition, in the model inference stage, the attacker can only obtain the inference result $y$ of the model for the input $x$, and cannot manipulate the inference process of the model. Moreover, the attacker should reduce its attack budget, e.g., using a small poison rate.
\noindent{\bf Attacker Goals.} The attacker goals are as follows:
\begin{itemize}
\item The backdoored model should have high probability of classifying a trigger image into an attacker-targeted label;
\item For benign input, the classification accuracy of the backdoored model should be close to its clean model counterpart. That is, the model needs to behave normally when the trigger is not present;
\item The content of a trigger image should be almost the same to its clean counterpart to evade human inspection in the training and inference stage;
\item The backdoor attack is evasive against backdoor defenses as much as possible.
\end{itemize}
\subsection{Our Proposed Attack}
In order to achieve the attacker goals, we propose imperceptible sample-specific trigger backdoor attack based on denoising autoencoder. Specifically, the attack process is divided into two steps:
1) Training a denoising autoencoder to convert specific injected features (i.e., edge pattern, corner points) into imperceptible triggers;
2) According to the attack budge---poisoning ratio $\rho$, poison corresponding fractional clean images with imperceptible sample-specific triggers assisted by the above trained denoising autoencoder and modify their labels as the target label.
Then the victim user may train the DNN according to the standard procedure using the curated data that has the poisoned images. The poisoned image content generated by the denoising autoencoder is visually similar to the original image, but retains part of the injected feature information. The human eye is insensitive to this injected feature, but DNNs can capture it during the training process and respond to this backdoor feature during the inference stage.
\vspace{0.05cm}
\noindent{\bf Feature Injection Mode. }
As shown in Figure \ref{figfi}, this work considers three modes of feature injection:
\begin{itemize}
\item Image mixing, which mixes a clean image with a noise image in a certain proportion;
\item Corner points, which extract corner points of a clean image by an algorithm (e.g., Harris~\cite{harris} and Shi-Tomasi~\cite{goodfeature}) and fill them with a specific color;
\item Edge, which extracts the edge of a clean image and fills them with a specific color using an edge detection algorithm (e.g., Sobel~\cite{sobel}).
\end{itemize}
Though we specifically use three modes of feature injection in this work, the attacker can in fact select other feature injection modes through snowflake noise, streak noise, etc, following the same framework.
However, for the sake of ensuring the denoising autoencoder works properly, there are preferable criteria.
Firstly, the coverage of image modification when injecting features is preferred to be the entire image, because the denoising autoencoder will reconstruct the entire image. Secondly, when injecting features, the semantic information of the image should not be modified, such as patched a sticker.
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.1cm}
\centering
\scalebox{0.75}{
\includegraphics[width=\linewidth]{Pic/figfeatureInjectedsmall.pdf}}
\caption{Examples of three feature injection modes and images after feature injection and denoising autoencoder reconstruction.}
\label{figfi}
\end{figure}
\vspace{0.05cm}
\noindent{\bf Training of Denoising Autoencoder.} We denote the denoising autoencoder as $E(\cdot)$, the feature injection mode as $I(\cdot)$, then the process of generating a trigger image can be expressed as $E(I(x))$. We record the data used to train the denoising autoencoder that does not overlap with the model training set as $D_{benign}$, then the training set of denoising autoencoder $E$ is denoted as $ \{(I(x),x) | x \in D_{benign}\}$. The training process of the denoising autoencoder is shown in Figure \ref{fig2}. In order to meet the third attacker goal, the distance between the reconstructed image $E(I(x))$ and the original image $x$ should be as small as possible, so we use the $L_2$ norm as the loss function:
\begin{equation}
L(I(x),x)=\frac{1}{m}\sum_{i=0}^n (I(x)-x)^2.
\end{equation}
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.1cm}
\centering
\includegraphics[width=\linewidth]{Pic/fig2.pdf}
\caption{The training process of the denoising autoencoder.}
\label{fig2}
\end{figure}
\noindent{\bf Poisoned Dataset Generation.} Our proposed method for generating covert trigger-carrying image is as follows. First, a specific feature is injected into a clean image, which feature is then converted into invisible trigger of the image
through the denoising autoencoder. The attacker modifies the label of poisoned images to $y_t\in Y$ to obtain the poisoned trainging dataset expressed as:
\begin{equation}
D_{poison}=\{(x_p,y_t)|x_p=E(I(x)),(x,y) \in D_{benign}\}.
\end{equation}
Examples of the poisoned images are shown in the third row in Figure~\ref{figfi}. Triggers in poisoned images are imperceptible to the human eye.
\vspace{0.05cm}
\noindent{\bf Attack Pipeline.} The backdoor attack pipeline is shown in Figure \ref{fig3}. In the model training stage, the attacker generates a poisoned dataset, which is mixed with the clean dataset by the victim user as the training set $D_{train}$. The victim trains the model, which is inserted in a backdoor.
During the inference stage, the backdoored model gives correct classification results for benign inputs, while for input containing the trigger, its classification result will be the target label.
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.1cm}
\centering
\includegraphics[width=\linewidth]{Pic/fig3new.pdf}
\caption{Attack pipeline.}
\label{fig3}
\end{figure}
\section{Experimental Analysis}\label{Experimental Analysis}
\subsection{\bf Experimental Setup}
\noindent{\bf Dataset.} We consider two popular classification tasks, general image classification and face recognition. For the first task, we conduct experiments on the ImageNet~\cite{ImageNet} dataset. We randomly selected a subset of 200 classes with 125,000 images, and the split ratio of training and testing sets is set to 8:2. The image size is $256\times 256 \times 3$. For the second task, we conduct experiments on the MS-Celeb-1M~\cite{ms1m} dataset. We randomly selected a subset of 155 classes, with 43,400 images for training and 10,850 images for testing. The image size is $112\times 112 \times 3$.
\vspace{0.05cm}
\noindent{\bf DNN Structure.} For the DNN structure used by the victim user, we consider two popular networks: ResNet-18~\cite{res18} and VGG-16~\cite{vgg16}, which are used as training models for image classification and face recognition tasks, respectively.
\vspace{0.05cm}
\noindent{\bf Evaluation Metric.} We use Attack Success Rate (ASR) and Clean Data Accuracy (CDA) to evaluate backdoor attack performance. Specifically, ASR is defined as the ratio between the successfully attacked poisoned samples and the total poisoned samples. CDA is the performance on the clean test set (i.e., the accuracy on non-trigger carrying test images). The “×” represents the percentage of the backdoor model’s CDA relative to its clean model counterpart. In addition, we use Mean Squared Error (MSE)\cite{mse}, Peak Signal-to-Noise Ratio (PSNR)\cite{psnr}and Structure Metric (SSIM)\cite{ssim} to evaluate the stealthiness of the poisoned images.
\vspace{0.05cm}
\noindent{\bf Default Settings for Attacking.} When we inject features through noise mixing mode, we randomly generate a noisy image and blend it to clean images at a ratio of 20\%. When we inject features through corner points, we select Shi-Tomas corner detection algorithm to extract corner points of an image and modify their colors (R: 139, G: 0, B: 0). When we inject features through edge pattern, we select the Sobel operator to extract edges of an image and modify their colors (R: 139, G: 0, B: 0). Figure~\ref{figfi} shows examples of images after feature injection (i.e., artifacts can be visible) and denoising autoencoder reconstruction (i.e., artifacts are imperceptible). We set the poisoning ratio $\rho=10\%$ in all attacks (i.e., small poison ration is studied later).
In the attack comparison experiment, the $\rho$ of BadNets and Blend is 10\%. Since SIG only needs to poison the data of the target class, we poisoned up to 70\% of the target class data\footnote{We have tried lower poison rates for this SIG attack, but resulted in a quite low ASR.}, despite the $\rho$ to the entire dataset is 0.35\% in ImageNet and 0.45\% in MS-Celeb-1M. The target label is $y_t=0$ in all attacks.
We use the \texttt{SGD} optimizer with a momentum of 0.9 for training classifier $f$. For ImageNet, we set the training batch to 128, the epoch number is 70 and the learning rate is initially 0.001, which is further set as 0.0001 and 0.00001 at epoch 15 and epoch 35, respectively. For MS-Celeb-1M, we set the training batch to 32, the epoch number is 70, and the learning rate is 0.001. We use the \texttt{Adam} optimizer for training the denoising autoencoder, and set the batch size to 32, the epoch number is set to 300, and the learning rate is set to 0.0003.
\vspace{0.05cm}
\noindent{\bf Machine Configuration.} All experiments were conducted on a server equipped with an Intel Xeon(R) Cold 5218R 2.1GHz processor, a 64GB RAM and a NVIDIA GeForce RTX 3080 GPU.
\subsection{\bf Attack Performance}
In this section, we evaluate backdoor attacks based on denoising autoencoders in terms of both attack effectiveness and attack concealment, and compare it with the typical visible trigger attack of BadNets~\citep{badnet} and invisible trigger attacks of Blend~\citep{blend} and SIG~\citep{sig}.
\vspace{0.05cm}
\noindent{\bf Attack Effectiveness.} We conduct backdoor attack experiments on the ResNet-18 model trained on the ImageNet dataset and the VGG-16 model trained on the MS-Celeb-1M dataset. The experimental results of the effectiveness comparison of different attack methods are shown in Table \ref{table1}. All three of our feature injection modes can achieve up to 99.8\% ASR with negligible impact on CDA of the backdoored model. In most cases, our methods have higher ASR and smaller CDA than BadNet, Blend, and SIG. In Section \ref{Ablation Studies}, we further discuss the effect of reducing the poisoning ratio on the CDA and ASR. The results show that when the poisoning ratio is 1\%, the ASR is still as high as 94\% on the ImageNet dataset and higher than 99\% on the MS-Celeb-1M dataset, while the CDA degradation is less than 1\%. This affirms that our method can complete an effective backdoor attack with a negligible CDA cost.
\begin{table}[t]
\centering
\scalebox{0.8}{
\begin{tabular}{c|cc|cc}
\toprule
\multirow{2}*{\textbf{Methods}}&
\multicolumn{2}{c|}{\textbf{ImageNet}}&
\multicolumn{2}{c}{\textbf{MS-Celeb-1M}}\\
\cline{2-5}
~& \textbf{CDA} & \textbf{ASR} & \textbf{CDA} & \textbf{ASR} \\
\midrule
Benchmark & 86.26 & - & 98.30 & - \\
BadNets & 85.47 (99.08×) & 99.71 & 97.96 (99.65×)& \textbf{100.00} \\
Blend & 85.46 (99.07×) & 98.27 & 97.97 (99.66×)& 99.97 \\
SIG & 84.77 (98.27×) & 77.73 & 97.04 (98.72×) & 74.40 \\
Mix(ours) & \textbf{85.94 (99.63×)} & \textbf{99.87} & 98.13 (99.83×)& 99.94 \\
Corner(ours) & 85.92 (99.61×) & 99.83 & \textbf{98.14 (99.84×)}& 99.94 \\
Edge(ours) & 85.78 (99.44×) & 99.83 & 98.08 (99.78×) & 99.98 \\
\bottomrule
\end{tabular}}
\caption{Comparison of different attack effects (CDA/ASR)}
\label{table1}
\end{table}
\vspace{0.05cm}
\noindent{\bf Attack Concealment.} Table \ref{tableconcealment} presents the MSE, PSNR and SSIM performance of different backdoor attacks. All our three feature injection modes outperform BadNets, Blend, and SIG on both MSE and PSNR on both datasets. The SSIM of our method outperforms Blend and SIG on the MS-Celeb-1M dataset and SIG on the ImageNet dataset. The reason why our method scores worse than BadNets on PSNR is that BadNets only modifies the color of \textit{few pixels} in a large-sized image, but the trigger of BadNets is unnatural and easier to be recognized by human eyes.
Overall, the results affirm that the triggers generated by our method are stealthier.
\begin{table}[t]
\centering
\begin{threeparttable}\scalebox{0.75}{
\begin{tabular}{c|ccc|ccc}
\toprule
\multirow{2}*{\textbf{Methods}}&
\multicolumn{3}{c|}{\textbf{ImageNet}}&
\multicolumn{3}{c}{\textbf{MS-Celeb-1M}}\\
\cline{2-7}
~& \textbf{MSE$\downarrow$} & \textbf{PSNR$\uparrow$} & \textbf{SSIM$\uparrow$} & \textbf{MSE$\downarrow$} & \textbf{PSNR$\uparrow$} & \textbf{SSIM$\uparrow$} \\
\midrule
BadNets & 268.58 & 24.14 & \textbf{0.98}\tnote{*} & 301.45 & 23.73 & \textbf{0.98}\tnote{*}\\
Blend & 468.13 & 21.69 & 0.84 & 466.61 & 21.63 & 0.79\\
SIG & 714.97 & 19.55 & 0.71 & 714.97 & 19.60 & 0.53\\
Mix(ours) & 245.86 & 24.82 & 0.73 & 175.84 & 26.04 & 0.82 \\
Corner(ours) & \textbf{233.28} & \textbf{25.06} & 0.74 & \textbf{160.84} & \textbf{26.41} & 0.83 \\
Edge(ours) & 263.78 & 24.50 & 0.73 & 181.91 & 25.93 & 0.82 \\
\bottomrule
\end{tabular}}
\begin{tablenotes}
\footnotesize
\item[*] The reason SSIM is high on BadNets is that the trigger only\\modifies 1\% of the pixels in the original image.
\end{tablenotes}
\caption{Trigger concealment comparison of different backdoor attacks}
\label{tableconcealment}
\end{threeparttable}
\end{table}
\vspace{0.05cm}
\noindent{\bf Time Overhead.}
We measured the average time to train the denoising autoencoder and the time to generate poisoned data.
The time to train the denoising autoencoder is less than 3 minutes in our experiments, which is efficient in the offline phase. The time to produce an imperceptible sample-specific trigger image through the trained denoising autoencoder is no more than 26ms, which can be done in real-time during the online attack phase.
\subsection{\bf Evasiveness Against Backdoor Defenses}
In this part, we evaluate the ability of the backdoored model to resist several mainstream defense technologies. For model-based defense methods, we evaluate Fine-Pruning~\citep{fp} and Neural Cleanse~\citep{nc}. For data-based defense methods, we evaluate STRIP~\citep{strip} and SentiNet~\citep{sentinet}.
\vspace{0.05cm}
\noindent{\bf Fine-Pruning.} In the process of model prediction, clean samples, and trigger samples will activate different neurons, Fine-Pruning records the average activation of each neuron under clean samples, and iteratively prunes dormant DNN neurons in order to remove compromised neurons. To remedy CDA drop, a later fine-tuning is taken through held-out clean data.
We compare our method with BadNets, Blend, and SIG attacks, which results are shown in Figure \ref{figFP}. When the pruning ratio reaches 30\%, BadNets fail on both ImageNet and MS-Celeb-1M datasets. The ASR of Blend is reduced by 32\% and 83\% respectively, and the ASR of SIG is not more than 70\%, while the ASR of our method is only reduced by 4.82\% on the ImageNet dataset on average, and the lowest is still 91.08\%. On the MS-Celeb-1M dataset, the ASR is reduced by 14.15\% on average, and the lowest is still up to 81.01\%.
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.1cm}
\centering
\scalebox{0.85}{\includegraphics[width=\linewidth]{Pic/FinePruning.pdf}}
\caption{The effect of different attack methods against Fine-Pruning defense method.}
\label{figFP}
\end{figure}
\vspace{0.05cm}
\noindent{\bf Neural Cleanse.} Since the trigger corresponding to the backdoored model is much smaller than the trigger generated by the normal model, Neural Cleanse reversely constructs the triggers of each category and compares their anomaly index to determine whether the model is backdoored. We compare our method with BadNets, Blend, and SIG against Neural Cleanse defenses, which results are shown in Figure \ref{figNC}. As for the ImageNet dataset, the anomaly indexes of our feature injection modes are all lower than that of the clean model, and the anomaly indexes of BadNets, Blend, and SIG are all higher than that of the clean model.
As for the MS-Celeb-1M dataset, the anomaly index of the clean model has exceeded the threshold 2 set by Neural Cleanse, which is falsely recognized as backdoored. Despite the Neural Cleanse recognizing our models as backdoored, it should be noted that the anomaly index of the model trained on our poisoned data is close to that of the clean model. However, the anomaly indexes of BadNets and Blend are significantly higher than that of the clean model, indicating that our method is superior to BadNets and Blend.
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.1cm}
\centering
\scalebox{0.85}{\includegraphics[width=\linewidth]{Pic/NeuralCleanse.pdf}}
\caption{The effect of different attack methods against Neural Cleanse defense method.}
\label{figNC}
\end{figure}
\vspace{0.05cm}
\noindent{\bf STRIP.} It utilizes the backdoor characteristic that any input containing a trigger will be classified as the target category. It mixes an input image with a set of clean images from different classes to inject strong perturbation and filters out trigger samples by comparing the information entropy of the model output classification result. As shown in Figure \ref{figstrip}, the entropy distribution of our attack model is very similar to that of the clean model. Thus STRIP fails to detect trigger samples of our attack.
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.1cm}
\centering
\includegraphics[width=\linewidth]{Pic/strip2_small.pdf}
\caption{Entropy distribution of clean and backdoor inputs for different attacks.}
\label{figstrip}
\end{figure}
\vspace{0.05cm}
\noindent{\bf SentiNet.} SentiNet identifies trigger regions by the similarity of Grad-CAM of different samples. As shown in Figure \ref{figcam}, in both ImageNet and MS-Celeb-1M datasets, the Grad-CAM of the poisoned images produced by BadNets, Blend and SIG is significantly different from the clean images. While the Grad-CAM of the poisoned images generated by our three feature injection modes is similar to the clean images. Therefore, SentiNet is ineffective to our attacks.
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.1cm}
\centering
\scalebox{0.95}{
\includegraphics[width=\linewidth]{Pic/gradcam_small.pdf}}
\caption{The Grad-CAM of poisoned samples generated by different attacks.}
\label{figcam}
\end{figure}
\subsection{\bf Ablation Studies}\label{Ablation Studies}
\noindent{\bf Trigger Generator Transferability.}
In this part, we consider that in order to further reduce the attack overhead, the attacker uses the denoising autoencoder trained by dataset $D_A$ to generate poisoned dataset $D_B$ ($D_A$ and $D_B$ are for different classification tasks, and the image sizes of the two can be inconsistent).
The experimental results are shown in Tables \ref{transfer}, after the task transfer, our method basically has no effect on the CDA and ASR of the model, and has some effect on the concealment of poisoned images, but overall it is still better than BadNets, Blend and SIG.
\begin{table}[t]
\centering
\scalebox{0.7}{
\begin{tabular}{c|cc|cc}
\toprule
\multirow{2}*{\textbf{Methods}}&
\multicolumn{2}{c|}{\textbf{\makecell[c]{MS-Celeb-1M for Encoder \\ImageNet for Classifer}}}&
\multicolumn{2}{c}{\textbf{\makecell[c]{ImageNet for Encoder \\MS-Celeb-1M for Classifer}}}\\
\cline{2-5}
~& \textbf{CDA} & \textbf{ASR} & \textbf{CDA} & \textbf{ASR} \\
\midrule
Mix & 85.81 (99.48×) & 99.98 & 98.25 (99.95×) & 99.98 \\
Corner & 85.76 (99.42×) & 99.85 & 98.12 (99.82×) & 99.97\\
Edge & 85.71 (99.36×) & 99.89 & 98.00 (99.69×) & 99.98 \\
\bottomrule
\end{tabular}}
\caption{The effect of task transfer on model accuracy (CDA/ASR)}
\label{transfer}
\end{table}
\begin{table}[!t]
\centering
\scalebox{0.7}{
\begin{tabular}{c|ccc|ccc}
\toprule
\multirow{2}*{\textbf{Methods}}&
\multicolumn{3}{c|}{\textbf{\makecell[c]{MS-Celeb-1M for Encoder \\ImageNet for Classifer}}}&
\multicolumn{3}{c}{\textbf{\makecell[c]{ImageNet for Encoder \\MS-Celeb-1M for Classifer}}}\\
\cline{2-7}
~& \textbf{MSE$\downarrow$} & \textbf{PSNR$\uparrow$} & \textbf{SSIM$\uparrow$} & \textbf{MSE$\downarrow$} & \textbf{PSNR$\uparrow$} & \textbf{SSIM$\uparrow$} \\
\midrule
Mix & 290.95 & 24.16 & 0.70 & 244.25 & 24.50 & 0.78 \\
Corner& 321.22 & 23.85 & 0.70 & 205.03 & 25.30 & 0.80 \\
Edge & 268.87 & 24.55 & 0.72 & 235.23 & 24.66 & 0.79\\
\bottomrule
\end{tabular}}
\caption{The effect of task transfer on trigger concealment}
\label{transfer2}
\end{table}
\vspace{0.05cm}
\noindent{\bf Trigger Exclusivity.}
In this part, we measure whether the triggers generated by our method are exclusive, that is, whether a trigger generated based on image $x_1$ can still activate the backdoor after being added to a different image $x_2$. Ideally, sample-specific triggers should have high exclusivity.
For each testing image, we add a trigger generated from a randomly selected differing image and test its effectiveness. The results are shown in Tabel \ref{exclusive}, the trigger of our method is highly exclusive. Because the ASR is no more than 2\% among all cases.
\begin{table}[!t]
\centering
\scalebox{0.7}{
\begin{tabular}{c|c|c}
\toprule
\textbf{Feature Injection Mode} & \textbf{ImageNet} & \textbf{MS-Celeb-1M} \\
\midrule
Mix & 0.21 & 0.54 \\
Corner & 0.08 & 0.91 \\
Edge & 0.24 & 1.52\\
\bottomrule
\end{tabular}}
\caption{ASR for models under inconsistent triggers (\%)}
\label{exclusive}
\end{table}
\vspace{0.05cm}
\noindent{\bf The Effect of Poisoning Ratio $\rho$.} In previous experiments, we set the poisoning ratio $\rho$ to 10\%. We now compare the effects of different $\rho$ on the CDA and ASR of the infected model. As shown in Table \ref{tablePoisoningRatio}, the reduction of $\rho$ hardly affects the CDA of the model, because the poisoned data only occupies a small part of the training set, and the CDA is mainly affected by the dominant clean dataset.
The reduction of $\rho$ mainly affects the ASR of the model. When it is reduced to 1\%, the degradation of ASR on the ImageNet dataset is about 6\%, while the loss on the MS-Celeb-1M dataset is negligible that is only 0.5\%. Overall, our method performs well in terms of robustness even with a small poisoning ratio.
\begin{table}[!t]
\renewcommand\arraystretch{1.2}
\centering
\scalebox{0.58}{
\begin{tabular}{c|ccc|ccc}
\toprule
\multirow{2}*{\textbf{ \makecell[c]{Poisoning\\ratio} }}&
\multicolumn{3}{c|}{\textbf{ImageNet}}&
\multicolumn{3}{c}{\textbf{MS-Celeb-1M}}\\
\cline{2-7}
~& \textbf{Mix} & \textbf{Corner} & \textbf{Edge} & \textbf{Mix} & \textbf{Corner} & \textbf{Edge} \\
\midrule
1\% & 85.71/93.74 & 85.65/95.08 & 85.88/94.63 & 97.75/99.84 & 97.94/99.58 & 97.91/99.53\\
5\% & 85.84/99.64 & 85.73/99.67 & 85.82/99.74 & 98.01/99.90 & 98.05/99.94 & 97.88/99.99\\
\bottomrule
\end{tabular}}
\caption{The effect of different poisoning ratios on the backdoored model (CDA/ASR)}
\label{tablePoisoningRatio}
\end{table}
\section{Conclusion}\label{Conclusion}
This work constructively incorporates denoising autoencoder with dedicated feature inject mode selection to create imperceptible sample-specific triggers for backdoor attacks.
The denoising autoencoder denoises images injected with a specific (visible) feature to generate trigger images that are almost visually the same as the original clean image content.
This method does not require the attacker to know the structure of the victim model, and its trigger generator owns preferable task-transferability. Comprehensive experiments have validated the effectiveness of the method without affecting the accuracy of the model while achieving a high attack success rate, and high exclusivity. Moreover, it has successfully evaded four diverse mainstream defenses.
\bibliographystyle{named}
| {'timestamp': '2023-02-10T02:07:20', 'yymm': '2302', 'arxiv_id': '2302.04457', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04457'} | arxiv |
\section{Introduction}
\label{sec:intorduction}
The first officially known outbreak of the Covid-19 was initiated in Wuhan, China, at the end of 2019 \citep{site:who2021}. According to the rapid dissemination of Coronavirus and the number of lost lives from this infection, the Covid-19 pandemic has massively impacted our daily lives, interactions, behaviors, and routines. Although upcoming breakouts are potential and the future of the Covid-19 pandemic is uncertain \citep{Bonnevie2021}, currently, there are several vaccines which act as controlling measures for the disease outbreak.
As mentioned by \cite{ThanhLe2020}, controlling factors other than the quality of the vaccines, such as public support and trust towards authorities, are essential to ensure the efficiency of vaccination programs. However, these types of treatments, particularly those offered as an emergency response to a rapidly spreading pandemic, are sometimes looked upon with reservation and reluctance \citep{TROIANO2021245}. Therefore, with respect to the overall aim of global immunization and prevention of social consequences of the pandemic, there exists great potential and need for studies that analyze both supportive and critical viewpoints related to mass vaccination of the population. Understanding critical viewpoints and their rationales is helpful to convince a wider proportion of society into getting vaccinated and increasing the success rate of such programs worldwide.
Nowadays, social media platforms play a significant role in our lives. People communicate, express their feelings and passions, and inform or get informed about the latest news via these platforms. Investigating social media can shed light on measuring people's attitudes toward any discussed topic and recognizing how their opinions evolve over time. In recent years, Twitter has been a key source of information dissemination as one of the most powerful social networks. Each user on Twitter can broadcast a message that may contain any desired content, as long as he/she abides by the platform's safety, privacy, and authenticity rules\footnote{\url{https://help.twitter.com/en/rules-and-policies/twitter-rules}}.
Despite the fact that content on Twitter is publicly accessible, conducting research on tweets requires a detailed plan for acquiring and analyzing relevant data. This paper presents a practical approach for mining and classification of Persian tweets and users regarding Coronavirus vaccination, leading to a detailed analysis of public supportive and critical attitudes on vaccination in Iran. Moreover, our study is focused on Persian, which is a resource-limited language that has received scant levels of attention from social studies compared to English. In addition, this research provides insights into the relationship between different events and social media reactions to them.
The contribution of this paper can be summarized as follows:
\begin{itemize}
\item We describe a topic modeling approach combined with a keyword-based method for extracting Persian tweets related to vaccination.
\item We apply transformer-based machine learning techniques for tweet classification.
\item We conduct an emotion analysis using the labelled dataset for happiness and anger emotions in Persian words.
\item We quantify different supportive and critical vaccination themes extracted from tweets.
\item We investigate users' connections before and after the initiation of vaccination.
\end{itemize}
The remainder of this paper is organized as follows: Section \ref{sec:related-work} gives a brief synopsis of the previous related works. Afterwards, Section \ref{sec:data} explains how Persian tweets relevant to Covid-19 have been collected. In Section \ref{sec:methods}, we present the preprocessing methodologies as well as our approaches for obtaining tweets related to vaccination, and introduce a strategy to classify the tweets into three classes: negative, positive, and neutral. Techniques used for emotion analysis and further evaluations, such as extracting vaccine themes and user study, are also explored in this section. Section \ref{sec:results} analyzes classified tweets and extracted themes. Furthermore, multiple pieces of analysis about the Covid-19 timeline, user groups and influential users, and overall emotion analysis results are included in this section. Finally, Section \ref{sec:conclusion} concludes the paper and outlines future research directions.
\section{Related Work}
\label{sec:related-work}
Considering the diversity, richness, and availability of Twitter data, several pieces of research are conducted utilizing tweets to analyze the impact of Covid-19 on societies and social media platforms. According to Covid-19 Data Explorer \footnote{\url{https://ourworldindata.org/explorers/coronavirus-data-explorer}}, Iran was one of the first countries got infected by Covid-19; nevertheless, there are only a few analyses carried out to investigate Iranians' opinions toward Coronavirus and vaccination. \cite{HOSSEINI2020} has performed one of the early studies conducted to gauge responses to ongoing events by categorizing Persian tweets into different classes and demonstrating how the reactions evolved over time. Besides, \cite{SHOKROLLAHI2021} provides a Post-structuralist Discourse Analysis (PDA) of the Covid-19 phenomenon in Persian society using social network graphs to cluster and explore influencers. Moreover, sentiment analysis of Persian tweets related to Covid-19 has been conducted in this piece of research. Lastly, \cite{NEZHAD2022} presented a sentiment analysis approach to assess Persian community's position toward domestic and imported Coronavirus vaccines.
Generally, topic detection can help structure an extensive data collection by grouping records into different classes. In order to achieve a reliable classification, many topic modeling techniques are available. \cite{LYE2021E24435} aims to identify the topics of tweets related to Covid-19, fetched with relevant keywords, using Latent Dirichlet Allocation (LDA) topic modeling developed by \cite{LDA2003993}. Similarly, \cite{WICKE2021} employs LDA to illustrate how the subjects linked with the pandemic growth change over time. On the other hand, we compared LDA with Gibbs Sampling for Dirichlet Multinomial Mixture (GSDMM) from \cite{GSDMM2014233} as the first-step in classifying Persian tweets. GSDMM is a modified LDA technique mainly used for short text topic modeling (STTM) tasks, assuming only one topic for each document rather than a probability distribution on all the potential topics from the original LDA. We have considered both LDA and GSDMM models and compared their results to extract the most relevant topics.
One important factor for analyzing public opinions toward vaccination is to explore trends and reactions during the pandemic. According to the temporal evolution study of different emotional categories and influencing factors implemented in \cite{CHOPRA2021}, expressing doubt about vaccination attracts the highest health-related conversations in all the countries studied during the research. Furthermore, \cite{Thelwall_Kousha_Thelwall_2021} applies a manual content analysis on a small portion of vaccine-hesitant Coronavirus tweets in English to extract major themes discussed regarding hesitancy. Likewise, quantifications introduced in \cite{BONNEVIE202112} compare vaccine-critical posts on Twitter before and after the Covid-19 spread in the United States, which depicts a significant increase in vaccine disapproval, especially in areas related to health authorities, vaccine ingredients, and research trials. Moreover, in \cite{BONNEVIE2020S326}, vaccine opposition themes are manually coded, and afterward, misinformation in each theme, as well as top influencers, are identified. The results show that prominent influencers appear to be well coordinated in misinformation dissemination. Apart from vaccine trends, another direction of our study is to classify vaccine-related tweets into three categories and discuss the evolution of each position (critical, supportive, and neutral) during the pandemic.
In addition to vaccination topics, there are pieces of research conducted on sentiment analysis of tweets with respect to the Covid-19 vaccination. One example is \cite{WICKE2021} that performs sentiment analysis based on the Pattern library, which uses a dictionary of manually-tagged adjectives with values for sentiment polarity in tweets \cite{JMLR:v13}. Similarly, \cite{YOUSEFINAGHANI2021256} utilizes Valence Aware Dictionary and sEntiment Reasoner (VADER), a Python lexicon and rule-based sentiment analysis tool, to assign sentiment polarity to every tweet \cite{Hutto_Gilbert_2014}. Furthermore, in a recent study, \cite{NEZHAD2022} applies a deep learning model reinforced with a sarcasm detection approach to achieve high accuracy for Persian tweets.
Although several projects were carried out for vaccine themes identification and sentiment analysis, many plausible analyses in these areas received less attention, especially in Persian, which is a low-resource language. In previous studies, the main concentration has been usually on vaccine-opposition themes, while we explore themes both for support and opposition themes and demonstrate how they develop throughout time using a grounded theory methodology devised by \cite{grounded2014}. Furthermore, we performed emotion analysis over different prominent vaccination opinions, i.e., positive, negative, and neutral, using our tagged Persian words emotion dataset.
As for the focus on studying users involved in Covid-19 related conversations, one of the first studies was carried out by \cite{BONNEVIE2020S326}. By analyzing "Top Authors" and user engagement, they found that vaccine opposition and misinformation does not come from a diverse distribution of users. Additionally, \cite{YOUSEFINAGHANI2021256} has classified Twitter users into three categories, namely pro-vaccine, anti-vaccine, and neutral and determined how each user belongs to each group. A similar study for the Turkish Twitter has been conducted by \cite{durmaz2022}. A key point to their work is that they have identified anti-vaccine influencers both before and after the pandemic. As for the study at hand, we have used a robust method to categorize each user into the positions mentioned above and study user interactions after and before the public vaccination in Iran.
\section{Data}
\label{sec:data}
As previously stated, this study aims to analyze Persian tweets about vaccination to give insight into the public opinion toward Coronavirus vaccines in Iran. In order to fulfill this goal, we first need to collect relevant data for processing. The data acquisition and preprocessing procedures are fully explored in the following according to the workflow shown in Figure \ref{fig:data_procedure}.
\begin{figure}[ht]
\centering
\includegraphics[scale=.45]{pics/data_procedure1.png}
\caption{Data Acquisition and Preprocessing}
\label{fig:data_procedure}
\end{figure}
\subsection{Data Acquisition}
To collect Persian tweets and their respective users, we did not just focus on our task at hand; instead, we gathered a comprehensive dataset to be potentially utilized for further studies. This dataset contains 709,460,922 tweets and 6,661,480 active users from Jan. 2012 to Dec. 2021.
In this endeavor, we used Twitter Intelligence Tool (TWINT), which is an advanced Twitter scraping tool developed by \cite{site:TWINT}, allowing us to gather Twitter users' profiles and tweets. We modified TWINT so that we could extract users' and tweets' information for every hour and saved them in Elasticsearch. We chose Elasticsearch as our database and search engine because of its robustness and scalable architecture.
In the next step and in order to separate Covid-19-related tweets, we extracted tweets from Feb. 2020, when the first infected case in Iran was publicly announced, up until Dec. 2021, based on at least one of the following keywords in Persian: \textbf{Corona, Covid, vaccine, and quarantine}. More information on the number of tweets for each keyword is provided in Table \ref{tab:covid_tweets}.
\begin{table}[ht]
\caption{Keywords and Related Tweets}
\centering
\begin{tabular}{|c|c|}
\hline\hline
Keywords & \ Tweet Count \\ [0.25ex]
\hline
Corona & 2,673,287 \\
Covid & 72,987 \\
Vaccine & 958,250 \\
Quarantine & 398,142 \\
\hline
At least one keyword & 3,825,742 \\
\hline\hline
\end{tabular}
\label{tab:covid_tweets}
\end{table}
Extracted information contains features for users and tweets. We store the list of mentioned users in a tweet and whether a tweet is a reply to another one, along with the count of users' interactions with the tweet. For example, we only save the number of likes per tweet, not the list of users who liked the tweet, since we were only interested in the quantity of this statistic. Similarly, the number of followers and followings are gathered for each user, but the list of the followers or followings is not available. Table \ref{tab:tweet_features} and Table \ref{tab:user_features} describe further details regarding the main properties of tweets and users datasets, respectively.
\begin{table}[ht]
\caption{Description of Tweet Features}
\centering
\begin{tabular}{|p{0.23\linewidth} | p{0.67\linewidth}|}
\hline\hline
Feature Name & \ Description \\ [0.25ex]
\hline
Tweet ID & Unique ID for every tweet \\
User ID & Unique ID employed by Twitter for the owner of the tweet \\
Conversation ID & ID employed by Twitter for the conversation \\
Retweet Count & Number of retweets \\
Reply Count & Number of replies \\
Like Count & Number of likes \\
Reply to & This field contains the User ID of the replied tweet if the current tweet is a reply to another tweet \\
Mentions & List of mentioned user IDs \\
Created at & Creation time of the tweet \\
Source & Twitter Source (Android, iPhone, iPad, Web App) \\
Hashtags & List of hashtags in the tweet \\
URLs & List of URLs in the tweet \\
Tweet & Tweet content \\
\hline\hline
\end{tabular}
\label{tab:tweet_features}
\end{table}
\begin{table}[ht]
\caption{Description of User Features}
\centering
\begin{tabular}{|p{0.23\linewidth} | p{0.67\linewidth}|}
\hline\hline
Feature Name & \ Description \\ [0.25ex]
\hline
ID & Unique ID employed by Twitter for every user \\
Username & The name that identifies the user \\
Bio & Biography of the user \\
Location & Location of the user \\
URL & Link in the user account \\
Joined Time & Time of account creation \\
Tweet Count & Number of tweets \\
Like Count & Number of total likes\\
Followers & Number of followers\\
Followings & Number of followings\\
Private & Whether user account is private\\
Verified & Whether user account is verified\\
\hline\hline
\end{tabular}
\label{tab:user_features}
\end{table}
\subsection{Data Preprocessing}
\label{subsec:dp}
With inspiration from \cite{Philippines2021}, which has performed a comprehensive data preprocessing over tweets in the Philippines, we improved the procedure of data analytics by devising a pipeline for cleaning and preprocessing, consisting of multiple states. The scheme of preprocessing is shown in Figure \ref{fig:data_procedure}. Further details are aptly explained in the following:
\medbreak
\subsubsection{Removing Duplicates}
Repeated characters are abundant, notably in emojis, vowels, and stress letters within a word. To rectify this discrepancy, we replaced any repeated characters with more than two instances in a row with only one character of that type. For instance, the word "Helloooo!" will be replaced with "Hello!" during this phase. Furthermore, we substituted similar in-a-row emojis with only one. Apart from handling the discrepancy mentioned above, this action would affect emotion analyses methodologies, as we were aware that, for example, the negative stance coming from "I haaattee this!" is probably much higher than "I hate this!", however, due to our word-based emotion analysis approach, this technique did not impacted our analysis.
Afterward, we removed duplicate records with similar tweet content and one-word tweets because these tweets often do not imply any meaningful concepts. After this phase, 286,546 records were eliminated.
\medbreak
\subsubsection{Text Cleaning}
We used the Clean-Text library in python \citep{site:CLEAN_TEXT} in addition to our customized techniques for data cleaning. Clean-Text is used for providing a better text representation. We employ this library to fix various Unicode errors and remove URLs, phone numbers, emails, and currency symbols. Moreover, we also removed HTML tags as well as meaningless characters and punctuation.
\medbreak
\subsubsection{Normalization}
For this purpose, we utilized the Hazm library, which is implemented for digesting Persian text \citep{site:HAZM}. We used Hazm Normalizer to unify different classes of terms.
\medbreak
\subsubsection{Removing Stopwords}
We defined a set of Persian stopwords to be removed from tweets using a combination of the Hazm stopwords dataset and Persian stopwords defined in \cite{site:PERSIAN_STOPWORDS}. Afterward, we investigated every word in these two sets and removed those that might be relevant to Covid-19 and vaccination. Finally, we evaluated top-appearing words in Covid-19-related tweets and checked whether they refer to any meaningful notion; if not, we appended them into our stopwords set.
\medbreak
\subsubsection{Lemmatization}
We also performed lemmatization for our Persian dataset using the Hazm lemmatizer in order to reduce inflections and variant forms to the base form. Referring to the fact that lemmatization can change or even inverse the meaning of the words (especially in turning negative form verbs into infinitives), to compare the effect of lemmatization in the topic modeling results and subsequent steps, we created two datasets, one with lemmatization (LEM) and the other without it (N-LEM).
\section{Methods}
\label{sec:methods}
In order to figure out a way to filter tweets relevant to vaccination, we used a topic modeling approach combined with a keyword-based search. We also applied a transformer-based machine learning technique to classify vaccine-related tweets into three major groups (vaccine-critical, vaccine-supportive, and neutral).
Additional details about the exploited research methodology is shown in Figure \ref{fig:method_workflow}.
\begin{figure}[ht]
\centering
\includegraphics[scale=.5]{pics/method-workflow2.png}
\caption{Workflow of Twitter Analysis toward Covid-19 Vaccination}
\label{fig:method_workflow}
\end{figure}
\subsection{Topic Modeling}
Topic modeling, which is also referred to as probabilistic clustering, is an approach to structuring a large dataset and classifying it into smaller, more interpretable, and spatially separated clusters. There are many topic modeling methodologies available, of which we chose LDA, which is an unsupervised machine learning algorithm and the most widely used technique, and GSDMM, an approach for short-text classification tasks. We applied these two topic modeling techniques to our dataset and compared their results to see which one performs better.
We used a combination of two criteria to assess the performance of our topic modeling algorithms:
\begin{enumerate}
\item Coherence measure ($C_v$) by \cite{CV2010100}: topic coherence measures calculate the degree of semantic similarity between high-scoring terms in a topic to determine its score. These metrics aid in distinguishing between semantically and non-semantically interpretable issues.
\item Human judgment: similar to what \cite{NIPS2009_f92586a2} has proposed, we carried out the word and topic intrusion tasks, focusing on the meaning of the words in subjects to examine topics and assess the interpretability of each group.
\end{enumerate}
In order to achieve the most reasonable topic models, we evaluated several factors over a sample of 100,000 tweets. First, we compared the LEM dataset with N-LEM based on the coherence value over the changes of multiple hyper-parameters and word representations. LEM dataset outperforms N-LEM on an average of 2.3\% in $C_v$ score over 25 executions. Because of the mentioned reason, we opted to use LEM dataset for the rest of the topic modeling process.
Next, we compared Bag-of-Words (BoW) and Term Frequency/Inverse Document Frequency (TF-IDF) word representation techniques. For this purpose, we filtered out extreme tokens that appeared in less than 15 tweets or more than 50\% of all tweets and kept only the top 100,000 tokens for topic modeling execution. On an average of 20 executions, BoW results were 2.2\% better than TF-IDF.
Finally, we tuned LDA and GSDMM hyper-parameters to find the best results for each method. The parameters giving the best results are described below.
LDA parameters:
\begin{itemize}
\item $NT$: The number of themes to be retrieved from the training corpus.
\item $NP$: Number of passes through the corpus during training.
\item $\alpha$: A number for a symmetric prior over document-topic distribution.
\item $CS$: Number of documents/tweets in each training chunk.
\end{itemize}
GSDMM parameters:
\begin{itemize}
\item $NT_G$: The upper limit for the number of topics.
\item $NI$: The upper limit for the number of iterations to perform.
\item $\alpha_G$: A parameter ranging from 0 to 1, controlling records' affinity for a larger cluster.
\item $\beta_G$: A parameter ranging from 0 to 1, controlling records' affinity for a more homogeneous cluster.
\end{itemize}
We evaluated results for $NT$ (and $NT_G$) between 5 and 10 and $NS$ (and $NI$) between 6 and 12 for LDA and GSDMM models. Based on the $C_v$ coherence measures shown in Table \ref{tab:lda_gsdmm_coherences} and human judgments, LDA model outperforms GSDMM on our dataset.
\begin{table}[ht]
\caption{Best Results Gained from Topic Modeling}
\centering
\begin{tabular}{|c|c|c|}
\hline\hline
Topic model & \ Number of Topics & \ Coherence (C\_v) \\ [0.25ex]
\hline
LDA & 10 & 52.72\% \\
GSDMM & 9 & 42.46\% \\
\hline\hline
\end{tabular}
\label{tab:lda_gsdmm_coherences}
\end{table}
After finding the best model for the tweets using the LDA technique, we manually labeled each group according to the concept perceived from each cluster. More information about these topics is provided in Table \ref{tab:lda_topic_details}.
\begin{table}[ht]
\caption{Final Topics}
\centering
\begin{tabular}{|c|c|c|}
\hline\hline
Topic description & \ Number of Tweets & \ \% of all tweets \\ [0.25ex]
\hline
Religious and governmental & 257,314 & 7.27\% \\
Relatives and mourning & 370,644 & 10.47\% \\
Vaccination opinions & 527,294 & 14.90\% \\
Regional news & 293,378 & 8.29\% \\
Reports and statistics & 188,088 & 5.31\% \\
Symptoms & 501,034 & 14.16\% \\
Political and dissatisfaction & 161,774 & 4.57\% \\
quarantine and education & 456,551 & 12.90\% \\
Vaccination (news, reports) & 424,406 & 12.00\% \\
Political and financial & 358,713 & 10.13\% \\
\hline\hline
\end{tabular}
\label{tab:lda_topic_details}
\end{table}
\subsection{Vaccine-related Tweets}
Keyword-based search is usually practical for providing a required subset; however, it only relies on the presence of a list of words. Thereby, there is a lack of implication and sentence meaning when utilizing keywords to provide data. In order to deal with this challenge and obtain the most relevant tweets to Covid-19 vaccination, we developed a hybrid approach and merged the results gained from the keyword-based technique with our topic modeling outcomes.
According to our topic modeling results, two groups were related to vaccination, i.e., vaccination opinions and vaccination news and reports. First, we extracted tweets with a high probability of belonging to one of these two clusters, defining a more than or equal to 0.5 as a high probability. Based on this criteria, 499,228 tweets were extracted from the dataset.
Then, we defined a series of vaccine-related keywords, which their translations to English are as follows: \textbf{vaccine, vaccination, Astra, AstraZeneca, Pfizer, Moderna, Sputnik, Covaxin, Sinopharm}. The rest of the Covid-19-related tweets were checked by these words. 538,212 tweets contained at least one of these keywords. Consequently, we stored 1,037,440 tweets related to vaccination for further studies.
\subsection{Vaccine-related Tweets Classification}
After providing vaccine-related tweets, we aimed to classify them into three major groups: vaccine-critical, neutral, and vaccine-supportive. To achieve this, first, we manually labeled 6000 tweets using the grounded theory approach. For the first 1000 items of the extracted dataset, the first two authors separately labeled the tweets into the three categories mentioned above. Then, the two labeled datasets were compared against each other using Cohen's Kappa metric, having a consistency of 78 percent. After a discussion over the tweets that did not get the same label, the consistency of 90 percent was reached over the first 1000 labeled tweets. Afterward, the remaining part was split into two datasets of length 2500; each one labeled by only one person. The results are mentioned in Table \ref{tab:polar_dist}:
\begin{table}[ht]
\caption{Polarity Distribution of Hand-Labeled Dataset}
\centering
\begin{tabular}{|c|c|c|}
\hline\hline
Position & \ Count & \ Percentage \\ [0.25ex]
\hline
Vaccine-Critical & 1735 & 28.9\% \\
Neutral & 2611 & 43.5\% \\
Vaccine-Support & 1654 & 27.5\% \\
\hline\hline
\end{tabular}
\label{tab:polar_dist}
\end{table}
Subsequently, manually labeled data were utilized for vaccine opinion classification. We applied a combination of 5 different factors for data preprocessing demonstrated in Table \ref{tab:dataset_extensions}. For text cleaning and removing stopwords, we considered three different criteria, i.e., extreme, moderate, and no filtering. The details of these three criteria are as follows:
\begin{itemize}
\item Extreme: Applying all the methods mentioned in Section \ref{subsec:dp}.
\item Moderate: Allowing the presence of vaccine-related words, for which we reduced the size of the stopwords set by 30\%. Also, for the text cleaning part, punctuations, numbers, and conversational forms were kept in tweets.
\item No Filtering: Keeping tweet contents intact.
\end{itemize}
On the other hand, we assumed only two possibilities for duplicate removal and lemmatization, whether or not to apply them. We created 36 different datasets from our original vaccine-related tweets in this stage.
\begin{table}[ht]
\caption{Dataset Extension Criteria}
\centering
\begin{tabular}{|c|c|c|}
\hline\hline
Criteria & \ States & \ \# of States \\ [0.25ex]
\hline
Duplicate Removal & Keep / Remove & 2 \\
Text Cleaning & Extreme / Moderate / No Filter & 3 \\
Lemmatization & Apply / Ignore & 2 \\
Stopword Elimination & Extreme / Moderate / No Filter & 3 \\
\hline\hline
\end{tabular}
\label{tab:dataset_extensions}
\end{table}
Finally, we employed transformer-based machine learning techniques to accomplish our vaccine-related tweets classification. We fine-tuned and compared a series of these approaches with pre-trained models that use a masked language modeling (MLM) objective to find the best result. Utilized strategies are discussed in the following:
\medbreak
\subsubsection{Bidirectional Encoder Representations from Transformers (BERT)}
BERT, introduced in \cite{BERT2018}, applies the bidirectional training of transformer, a popular attention model, to language modeling. This method contrasts with previous endeavors, since it viewed a text sequence from left to right or combined left-to-right and right-to-left training mode. We employed BERT-base and BERT-large models initially. Then, we utilized ParsBERT from \cite{ParsBERT}, a monolingual language model based on Google’s BERT architecture, pre-trained on large Persian corpora with more than 3.9M documents, 73M sentences, and 1.3B words. Similar to previous models, we fine-tuned ParsBERT v3.0 and compared the results with BERT-base and BERT-large.
\medbreak
\subsubsection{Robustly Optimized BERT Pretraining Approach (RoBERTa)}
\cite{ROBERTA2019} trained BERT with more input data and epochs and came up with RoBERTa, showing that both techniques help in achieving better results. Furthermore, this approach slightly improved masking and data pretraining processes. Firstly, we used RoBERTa-base and large models, like the method used with the pre-trained BERT models. Next, we utilized Twitter-RoBERTa-base for sentiment analysis which is trained on about 58M tweets and fine-tuned for sentiment analysis with the TweetEval benchmark from \cite{TWEETEVAL2020}. Finally, we assessed Persian RoBERTa, which is a model similar to ParsBERT's idea but based on RoBERTa architecture.
\medbreak
\subsubsection{Lite BERT for Self-supervised Learning of Language Representations (ALBERT)}
ALBERT, introduced by \cite{ALBERT2019}, brought up two significant innovations over BERT. First, it factorized embedding parameterization. ALBERT uses a small embedding size and then projects it to the transformer hidden size. Moreover, ALBERT shares all parameters between transformer layers too. For our classification task, we employed the Persian ALBERT v3.0 model, which is provided in ParsBERT.
\medbreak
\subsubsection{Distilled Version of BERT (DistilBERT)}
Distillation, as mentioned by \cite{DISTILLATION2015}, is the procedure of training a small student model to mimic a larger teacher model as close as possible, and DistilBERT was introduced based on this concept \citep{DISTILBERT2019}. To incorporate DistilBERT into the study, we utilized Persian DistilBERT v3.0 model implemented by ParsBERT.
\medbreak
\subsubsection{Generalized Auto-regressive Pretraining for Language Understanding (XLNet)}
BERT has two main limitations. It distorts the input with masks and suffers from dissimilarity of pretraining and fine-tuning. In addition, BERT ignores the dependency between masked positions. To address these issues, \cite{XLNET2019} used a permutation language modeling idea to create XLNET. Furthermore, they employed some techniques for masking and using the position of the prediction token. We used XLNet-base and XLNet-large pre-trained models to assess this architecture, evaluate the results, and compare them with other transformer-based models.
\medbreak
\subsubsection{Unsupervised Cross-lingual Representation Learning at Scale (XLM-R)}
In addition to monolingual models, we also fine-tuned and evaluated XLM-RoBERTa (XLM-R) from \cite{XLMR2019}, a transformer-based multilingual masked language model pre-trained on text in 100 languages. We used XLM-RoBERTa-large model for this direction.
\subsection{Emotion Analysis}
To analyze the emotion of vaccine-related tweets during the Covid-19 pandemic, we used a proprietary dataset, which provides the level of happiness and anger for a lexicon of 8,375 common Persian words found on Twitter. Six individuals participated in evaluating and labeling this dataset. Every word in the lexicon was assigned two numbers between 1 to 9, indicating the intensity of happiness and anger. 5 Refers to a neutral state, and higher numbers refer to more extreme emotions. This method is similar to Hedonometer, proposed by \cite{HEDONOMETER2011}, approach for measuring expressed happiness in other languages. We calculated an average happiness and anger weight for each word in the dataset. Then we fitted the inverse of the normal distribution function to assign weights to each number between 1 and 9. The purpose of using this function was to highlight the effect of extremely emotional words.
Afterward, we used the dataset to scale up the emotion analysis from individual words to texts. In order to evaluate the weighted average level of anger and happiness, we used an algorithm (H-AVG), based on Hedonometer's proposal, which is as follows:
$$
h_{\mathrm{avg}}(T)=\frac{\sum_{i=1}^{N} h_{\mathrm{avg}}\left (w_{i}\right) \times freq_{i}}{\sum_{i=1}^{N} freq_{i}}
$$
$$
a_{\mathrm{avg}}(T)=\frac{\sum_{i=1}^{N} a_{\mathrm{avg}}\left (w_{i}\right) \times freq_{i}}{\sum_{i=1}^{N} freq_{i}}
$$
where $freq_{i}$ is the frequency of the word $w_{i}$ ($i$th word) in text $T$, and $N$ is the number of words present in $T$.
Before calculating the averages, we dropped every word not found in the emotion dataset. Furthermore, we removed all neutral words to focus more on the sheer level of happiness and anger in tweets. Next. We calculated average happiness and anger of each tweet while disregarding every word not found in our initial emotion dataset. To have more robust results, we chose to consider average happiness and anger scores for missing words as shown below:
$$
h_{\mathrm{avg}}(w)=\frac{\sum_{i=1}^{M} h_{\mathrm{avg}}\left (T_{i}\right)}{\sum_{i=1}^{M} freq_{i}}
$$
$$
a_{\mathrm{avg}}(w)=\frac{\sum_{i=1}^{M} a_{\mathrm{avg}}\left (T_{i}\right)}{\sum_{i=1}^{M} freq_{i}}
$$
where $T_{i}$ is the $i$th text containing word $w$, and $M$ is the number of texts containing $w$.
Later, we utilized H-AVG again to compute the average happiness and anger per day during the Covid-19 pandemic and compared the results with Covid-19-related events in Iran. The results are reported in Section \ref{sec:results}.
\subsection{Vaccine Themes}
Upon achieving an acceptable result (mentioned in details in Section \ref{subsec:vaccine-classification}) for vaccine-related tweets classification, the main subjects in vaccine opposition and support were extracted. At first, 500 randomly selected tweets, from the two groups combined, were considered. Next, we used a grounded theoretical approach and inductive analysis to identify the main themes manually. We analyzed and assigned related themes to each tweet and extracted essential keywords relevant to each theme using the content of the tweets. In order to focus only on the principal matters of each tweet, at most three relevant themes were considered for each tweet. Afterward, for each theme found in vaccine opposition and support groups, we established a set of keywords identifying the concept of the subject. Finally, these keywords were used to categorize the rest of the tweets in each vaccine-related group. The aim was to find one or more themes for at least 85\% of tweets (except for neutral ones). For this goal, we continued grouping tweets while adding extra categories. Upon reaching this purpose, 15 distinct themes, each with their unique set of keywords, were found for the vaccine opposition group. This count was 16 for the vaccine-supportive group of tweets; Meaning that the core topic of 85\% of vaccine opposition and support tweets were identified using 31 themes. Remaining 15\% had vague or unknown overall topics. Most of the short tweets (less than four words) fitted into this group. Since we utilized a keyword-based approach, having insufficient number of words was the most significant reason not to be categorized into any pre-defined themes. For instance, \textit{How about Vaccination?}, is a good example that does not convey any meaningful or subjective opinion over the subjects.
\subsection{User Interaction Analysis}
Evaluating user activities, especially for influencers (users with high interaction rate), can give us insight into user attitudes and changes in trends that are not perceivable via assessing tweets.
In order to evaluate users' behavior toward the Covid-19 vaccination, first, we categorized users, monthly from February 2020 to December 2021, into four different groups, i.e., anti-vaccination, neutral, pro-vaccination, and mixed. If 60\% or more of a user's tweets about vaccination in a month belonged to the vaccine opposition group, the user was categorized in the anti-vaccination group for that specific month. In a similar fashion, we classified pro-vaccination and neutral groups. Based on these criteria and the mentioned threshold, if a user could not be fitted into any specific group in a month, we considered him/her as mixed, the full details of the method exploited for user classification is presented in algorithm \ref{alg:cap}.
\begin{algorithm}
\caption{Single User Classification Algorithm}\label{alg:cap}
\begin{algorithmic}
\State $a \gets$ percentage of anti-vaccination tweets in a month
\State $p \gets$ percentage of pro-vaccination tweets in a month
\State $n \gets$ percentage of neutral tweets in a month
\If{Any of the representative variables is greater than $60$}
\State User is categorized accordingly
\ElsIf{$a == 0$} \Comment{40 $\leq$ p, n $\leq$ 60}
\State User is classified as pro-vaccination
\ElsIf{$p == 0$} \Comment{40 $\leq$ a, n $\leq$ 60}
\State User is classified as anti-vaccination
\Else
\State User is classified as mixed
\EndIf
\end{algorithmic}
\end{algorithm}
In the next step, we assessed influencers' activities and interactions. We made a user interaction graph where there is an edge between two users if one is mentioned or has replied to the other. The total number of a user's connections (degree of a node) is stored as the metric for analyzing the influence of a person. By computing the number of connections each user had per month, we considered the top 40 users with the highest degree for each of the 23 available months as the influencers (top 0.2 percent of each month's users). Then, we studied the distribution of influencers with respect to the four categories mentioned before. Lastly, to have an overview of the overall interactions and the effect of vaccine program, we created two social networks out of the users. One before the public vaccination in Iran, 1 June 2021, and the other one after that date.
\section{Results}
\label{sec:results}
\subsection{Vaccine-related Tweets}
We gathered 3,539,196 tweets relevant to Covid-19, and 1,037,440 of them were categorized as vaccine-related tweets (Shown in Figure \ref{fig:vaccine-tweets-timeline}) based on our hybrid approach described in Section \ref{sec:methods}.
From February 2020 to December 2021, an average of 37.65\% (median 42.09\%) of Covid-19 tweets per day were related to vaccination. To delve deeper into this analysis, we assessed our data concerning two important dates, the introduction of Coronavirus vaccines (9 February 2021) and the beginning of the public vaccination in Iran (1 June 2021).
According to our evaluations shown in Table \ref{tab:tweets-over-pandemic}, a greater proportion of the tweets after 9 February 2021 were related to vaccination in comparison to the previous period of the Covid-19 pandemic. Similarly, after the beginning of the public vaccination, the rate of vaccine-related tweets was significantly higher than before that date. We found that subsequent to the official introduction of vaccines and public vaccination, vaccine-related tweets increased enormously, referring to the new subjects arising from vaccine matters, such as side effects, effectiveness, and general opinions toward taking vaccines.
\begin{table}[ht]
\caption{Vaccine-related Tweets over Covid-19 Pandemic}
\centering
\begin{tabular}{|c|c|}
\hline\hline
Pandemic Period & \ Daily Avg. Vaccine-related Tweets \\ [0.25ex]
\hline
Before 9 Feb. 2021 & 21.11\%\\
After 9 Feb. 2021 & 54.43\%\\
\hline
Before 1 Jun. 2021 & 27.29\%\\
After 1 Jun. 2021 & 58.71\%\\
\hline\hline
\end{tabular}
\label{tab:tweets-over-pandemic}
\end{table}
\begin{figure*}
\centering
\includegraphics[width=\textwidth]{pics/vaccine-tweets-timeline3.png}
\caption{Relative Percentage of Vaccine Tweets Over Time}
\label{fig:vaccine-tweets-timeline}
\end{figure*}
\subsection{Vaccine-related Tweets Classification}
\label{subsec:vaccine-classification}
For classifying our vaccine-related tweets into vaccine-opposition, neutral, and vaccine-support groups, after labeling 6000 tweets, we randomly split our tagged data into train and validation sets. 5000 tweets were considered as the training set, and the rest for the validation. Further details of the partition are provided in Table \ref{tab:train_eval_sets}.
\begin{table}[ht]
\caption{Polarity Distribution in Training and Validation Sets}
\centering
\begin{tabular}{|c|c|c|c|}
\hline\hline
Sets & \ Critical & \ Neutral & \ Supportive \\ [0.25ex]
\hline
Training & 1467 & 2167 & 1366 \\
Validation & 268 & 444 & 288 \\
\hline\hline
\end{tabular}
\label{tab:train_eval_sets}
\end{table}
Based on the dataset extension method described in Section \ref{sec:methods}, where we had four hyperparameters to tune, the best average result belonged to the dataset with no duplicate removal, a moderate odd pattern removal, no lemmatization, and no stopword elimination. We called this dataset the final dataset. We continued by fine-tuning our transformer-based models on the final dataset and compared their results to find the best model for our classification task. Table \ref{tab:classification-results} displays more information about the top results of our classification. As it can be seen, our fine-tuned Pars-BERT model outperforms all the other approaches with 62.03\% F1-Score. Other models such as BERT, RoBERTa, Twitter-RoBERTa, XLM-R, and XLNET did not reach an F1-Score of more than 30\%.
\begin{table}[ht]
\caption{Vaccine-related Tweets Classification Results}
\centering
\begin{tabular}{|c|c|c|c|}
\hline\hline
Models & \ F1-Score & \ Accuracy (O, N, S) \\ [0.25ex]
\hline
Persian ALBERT & 39.9 & 77.22, 50.34, 4.24 \\
Persian RoBERTa & 53.78 & 48.40, 61.78, 46.64 \\
Persian DistilBERT & 58.45 & 51.25, 69.57, 49.12 \\
\textbf{Pars-BERT} & \textbf{62.03} & \textbf{63.06, 60.81, 61.81} \\
\hline\hline
\end{tabular}
\label{tab:classification-results}
\end{table}
\subsection{Emotion Analysis}
The results of tweet emotion detection are presented in Figures \ref{fig:hap-emo} and \ref{fig:ang-emo}. In these time series, several important dates (peaks and valleys) exist for each emotion type (shown by black triangles). We cross-referenced these dates with the introduction of vaccines and two available time series, namely, the daily number of new cases and the number of deaths. We found several interesting correlations, including:
\begin{itemize}
\item March 2020 - April 2020: The first peak of the pandemic (First happiness valley and anger peak): Regarding the first Covid-19 worldwide shock, in addition to the unavailability of vaccines and other treatments, there was a huge public panic concerning the Coronavirus consequences.
\item June 2020 - July 2020: The recovery from the first peak (First happiness peak and anger valley): Although no vaccination methodology was discovered, the overall downward rate of the Covid-19 infections gave rise to the thought that the public is less susceptible to the disease.
\item October 2020 - November 2020: The start of the third epidemic (Second anger peak): Concerning the initiation of vaccination in other countries and the reports referring to the effectiveness of vaccines, in addition to the critical situation and high rate of infection in Iran, made a huge dissatisfaction and outrage against public status toward Covid-19.
\item July 2021 - September 2021: The period of Delta variant infection (Third happiness valley and anger peak): The Delta variant of the Coronavirus was one of the most significant eras in terms of daily new cases and deaths. As a result, albeit vaccination effectively controlled sad and angry opinions, the last anger peak and happiness valley are more considerable compared to other important dates.
\end{itemize}
\begin{figure}
\centering
\includegraphics[scale=0.3]{pics/happiness_emotion4.png}
\caption{Happiness Trend of Vaccine-Related Tweets during Covid-19 Pandemic}
\label{fig:hap-emo}
\end{figure}
\begin{figure}
\centering
\includegraphics[scale=0.3]{pics/anger_emotion5.png}
\caption{Anger Trend of Vaccine-Related Tweets during Covid-19 Pandemic}
\label{fig:ang-emo}
\end{figure}
Furthermore, looking at the entire happiness time series, we observe an overall rising tendency. This upward trend is apparent when we compare the before and after the introduction of vaccines (February 2021) periods. Conversely, the anger time series is the opposite. We see a declining tendency when comparing the averages before and later vaccines. We used Spearman's rho and Pearson's coefficients to evaluate the correlation between the happiness and anger trends. The coefficient for both measures was -0.965 with p-value $<$ 0.001, showing a high negative correlation between these two trends.
As the results show, vaccination significantly affected public happiness and anger toward Coronavirus. Due to vaccines' effectiveness, people trust vaccination more as a remedy for Coronavirus; hence, they tend to tweet less sad or angry tweets around the Covid-19 subject. Furthermore, we figured out that there is a high correlation between sadness and anger regarding the Covid-19 vaccination, which could be an example of how different emotions are being affected in a similar manner by an external factor such as a pandemic. It might also explain that the same negative or same positive emotions could significantly strengthen each other if they are aligned.
\subsection{Vaccine Themes}
Classified data were analyzed to extract themes for both vaccine-critical and supportive tweets. Based on the extraction methods mentioned before, 219,646 tweets were labeled as having vaccine-opposition content. These tweets belonged to 15 distinct categories (and one category named $other$). The same approach was adopted for the vaccine-supportive tweets, which consisted of 339,351 distinct Tweets in 16 different themes. Just like the critical side, a category called $other$ was also considered. The details of both themes are available in table \ref{tab:vaccine-themes}. Since we utilized a keyword-based approach, it is possible that a single tweet belongs to more than one category (in both themes). Therefore, the sum of frequencies for vaccine supportive and critical are larger than 100\%.
\begin{table}[ht]
\caption{Brief Description of Vaccine Themes}
\centering
\begin{tabular}{|p{0.23\linewidth}|p{0.37\linewidth}|p{0.12\linewidth}|p{0.14\linewidth}|}
\hline\hline
Theme Name & \ Description & \ Critical & \ Supportive \\ [0.25ex]
\hline
Side Effects & Mentions of health impacts caused by vaccines & 43,608 (19.85\%) & 46,551 (13.72\%) \\
\hline
Pharmaceuticals & Talks about vaccine names and companies making vaccines & 34,398 (15.66\%) & 47,506 (14.00\%) \\
\hline
Political / Governmental & Conversations on governmental actions towards mass vaccination & 94,748 (43.14\%) & 135,095 (39.81\%) \\
\hline
Vaccine Ingredients & Related to how vaccines are created and their materials & 10,293 (4.69\%) & 7,991 (2.35\%) \\
\hline
Research Trials & References to experiments and lab works & 26,394 (12.02\%) & 62,252 (18.42\%) \\
\hline
Religion & Topics on faith and religious practices & 9,793 (4.46\%) & 18,971 (5.59\%) \\
\hline
Ineffectiveness / Hesitancy & Conversations on low vaccine impression and incapability to fight Covid-19 & 50,639 (23.05\%) & - \\
\hline
Safety / Sufficiency & References to vaccine performance and ability & - & 88,627 (26.12\%) \\
\hline
Disease Prevalence & Mentions of virus mutations over time & 4,756 (2.17\%) & 20,843 (6.14\%) \\
\hline
Family & Expression of the concern for family members and relatives & 15,278 (6.96\%) & 28,253 (8.33\%) \\
\hline
Foreign Countries & Talks of pandemic state in other countries and imported vaccines & 93,478 (42.56\%) & 79,794 (23.51\%) \\
\hline
Lockdown Denial & Related to ignoring the pandemic and worldwide crisis & 5,602 (2.55\%) & - \\
\hline
Pandemic Confirmation & Relevant to accepting the pandemic & - & 88,913 (26.20\%) \\
\hline
Mandatory vaccination & Criticism of forced vaccination and encouragements & 15,616 (7.11\%) & - \\
\hline
Influential Users & Mentions of influencers and their actions towards vaccination & 15,334 (6.98\%) & 31,970 (9.42\%) \\
\hline
Vaccine Alternatives & Other vaccine substitutes, their advantages and disadvantages & 4,914 (2.24\%) & 2,406 (0.71\%) \\
\hline
Medics and Hospitals & Relevant to doctors and other treatment staff & 37,053 (16.87\%) & 48,472 (14.28\%) \\
\hline
Hope / Envy & Expressions of impatience towards receiving vaccination & - & 37,142 (10.95\%) \\
\hline
Availability & Demanding public vaccination from authorities & - & 9,467 (2.79\%) \\
\hline
Others & Not categorized in any of themes & 31,953 (14.53\%) & 45,659 (13.45\%) \\
\hline\hline
\end{tabular}
\label{tab:vaccine-themes}
\end{table}
Figure \ref{fig:co-occ} illustrates the correlation of themes for both supportive and critical groups. The left correlation matrix belongs to supportive themes, and the right one represents the critical side. There are several strong relationships that are worth mentioning, which are as follows:
\begin{itemize}
\item Influencers and Political (Both supportive and critical): Most of the tweets concerning influencers like actors and officials regard their reaction and decisions toward the Covid-19 based on the political situation in Iran.
\item Prevalence and Pandemic Confirmation (Supportive): As the Covid-19 prevalence and mutations affect people increasingly, there is a higher rate of widespread pandemic acceptance and supportive opinions regarding taking vaccines.
\item Ingredients and Side Effects (Supportive): It seems that talking about vaccine ingredients usually infers the matters impacting human health for a long or short time. That is why most of the contexts discussing ingredients also refer to the side effects in humans.
\item Denial and Ineffectiveness (Critical): Ignoring the pandemic is alongside disregarding the Covid-19 crisis. On the one hand, people denying Coronavirus might also tend to deny vaccines and their effectiveness; on the other hand, they might consider both Covid-19 and vaccines a delusion.
\item Religious and Political (Critical): Tweets containing spiritual concepts, Talk about Covid-19 from the religious viewpoint. According to the results, these tweets seem to relate the political decisions toward vaccination in Iran to religious instructions.
\end{itemize}
\begin{figure}
\centering
\includegraphics[scale=0.51]{pics/co-occurrences-ann6.png}
\caption{Support (a) and Opposition (b) Themes Correlation}
\label{fig:co-occ}
\end{figure}
\subsection{User Interaction Analysis}
Assessing users' mindsets behind their tweets led us to categorize them into four different groups: anti-vaccination, pro-vaccination, neutral, and mixed. Figure \ref{fig:user-classification} presents the flow of changes in anti, pro, and mixed classes based on the relative percent of monthly coverage for each group during the Covid-19 pandemic.
\begin{figure}
\centering
\includegraphics[scale=0.4]{pics/user_classification7.png}
\caption{User Classes During Covid-19 Pandemic}
\label{fig:user-classification}
\end{figure}
As it is shown, between the introduction of Coronavirus vaccines in Iran and the beginning of the public vaccination (February to June 2021), the percentage of anti-vaccination users is 4.18\% lower compared to the months that vaccination was in progress. Similarly, the ratio of anti-vaccination users between February and June 2021 was 2.78\% lower than the months prior to vaccine introduction. On the other hand, analyzing the pro-vaccination users demonstrated that in a period that lasted from vaccine introduction up to the end of 2021, the percentage of vaccination supporters increased by 9.67\% compared to the time before February 2021.
By analyzing the results, we observed that vaccination and its results helped reduce criticism about vaccines. However, to evaluate the activity of each group, we calculated ratio of the number of tweets to the number of users for both supportive and critical groups. According to Figure \ref{fig:tweet-user-ratio} the average ratio for critical group is 0.2 (15.7 \%) higher than the supportive. This difference is even more considerable during the time between introduction of vaccines and the start of public vaccination. According to the results, we can infer that during this period, people understood that the vaccination was inevitable; hence their opposition and hesitancy are even more expressed. On the other side, those who agreed with vaccination represented their thoughts more widely than before.
After the initiation of public vaccination, there was a considerable fall in the rate of the critical group, showing that the recovery results convinced some critics to accept the efficiency of Covid-19 vaccines. However, inferring from the slight decline in the supportive group, it appears that the vaccination results were not as promising as they expected.
\begin{figure}
\centering
\includegraphics[scale=0.39]{pics/tweet_to_user_ratio8.png}
\caption{Tweet to User Ratio}
\label{fig:tweet-user-ratio}
\end{figure}
In the next step, we evaluated influencers by considering user interactions, which includes replies and mentions. As previously mentioned, the top 40 users with the highest rate of interaction for each month were labeled as influencers. Figure \ref{fig:influencer-results} shows the classification of such users during the pandemic. By looking at the number of influencers categorized as pro-vaccination and anti-vaccination, we discovered that vaccine critical influencers made up 7.91\% of the whole influencer population before the introduction of Covid-19 vaccines in Iran. However, this share changed to 8.63\% afterwards. As for the other side, vaccine supporters' coverage increased from 16.04\% to 18.18\%. From these observations, we can infer that the dissemination of vaccines resulted in more non-neutral tweets and conversations from influencers, as factors such as efficiency and side effects became much more apparent than before and users became extra opinionated.
\begin{figure}
\centering
\includegraphics[scale=0.25]{pics/influencers_per_month9.png}
\caption{Top Influencers Per Month}
\label{fig:influencer-results}
\end{figure}
In order to have a summary of the overall interactions and the impact of the vaccination program, we created two networks. One for before ($BV$) and the other after ($AV$) the public vaccination (June 2021) in Iran, represented in Figure \ref{fig:before-after-vaccination}. We excluded users who had less than 350 interactions in each of the two mentioned periods for these networks. Green nodes represent pro-vaccination and red ones illustrate anti-vaccination. Neutral and mixed users appear as blue and gray nodes, respectively. Furthermore, some users are not found in our separately-gathered dataset of users, which might be non-Persian users mentioned or replied to by others; we specified them in black. Moreover, the number of connections is demonstrated with node diameter.
\begin{figure*}
\centering
\includegraphics[width=\textwidth]{pics/before_after_vaccination_ann10.png}
\caption{User Interactions before (a) and after (b) Public Vaccination in Iran. Red nodes showing anti-vaccinations, green ones for pro-vaccination, blue nodes representing neutral, mixed users are shown in gray, and black ones demonstrating unclassified users.}
\label{fig:before-after-vaccination}
\end{figure*}
According to our evaluations, before June 2021, anti-vaccination users constituted 7.11\% of all users, while they formed only 4.73\% after that time. Likewise, pro-vaccination members accounted for 12.44\% before June 2021, whereas they made up for 9.82\% afterward. These two trends disagree with what we have observed for the influencers, meaning that normal users from both sides of the argument became less fixated on their positions and, on average, decided to either post fewer amounts of content or take relatively neutral stands toward the vaccination.
Table \ref{tab:networks-measures} shows the overall statistics of both networks. Based on the in-degree and density measures, we observed that users tend to receive fewer mentions and replies after the public vaccination compared to the previous period. Similarly, the rate of contribution to vaccine-related tweets decreased. These results show that after public vaccination and its observable effects, the level of Covid reactions in tweets decreased significantly. Nevertheless, the rate of top influencers (denoted with a large diameter) increased, especially for anti-vaccination and pro-vaccination users, showing that logical discussions among prominent members enhanced.
\begin{table}[ht]
\caption{User Interaction Network Measures}
\centering
\begin{tabular}{|c|c|c|}
\hline\hline
Measures & \ BV & \ AV \\ [0.25ex]
\hline
Average in-degree & 25.88 & 21.52 \\
Clustering Coefficient & 0.237 & 0.230 \\
Density & 0.107 & 0.062 \\
Homophily & 0.083 & -0.097 \\
Average Path Length & 2.07 & 2.41 \\
\hline\hline
\end{tabular}
\label{tab:networks-measures}
\end{table}
Furthermore, consistent with the attachment of similar nodes demonstrated with homophily measure, we observed that before vaccination, the argument between those with similar thoughts, affected by the influencers such as news accounts, was bold. On the other side, as the vaccination brought about healing outcome and side-effects, the controversy among different groups with different viewpoints was raised after the vaccination.
\section{Conclusion}
\label{sec:conclusion}
In this study, using a keyword-based method, we extracted Covid-19-related tweets and performed a topic modeling to specify the main subjects discussed around the Covid-19 matter. Utilizing the topic modeling results combined with a keyword-based search, we achieved vaccine-related tweets during Coronavirus pandemics up to the end of 2021 in Iran. Later, we classified vaccine-related tweets into vaccine-critical, neutral, and vaccine-supportive groups and extracted the main themes discussed around the Covid-19 vaccination.
Moreover, we carried out a happiness and anger analysis to further evaluate public opinion toward vaccination. Afterwards, we performed a range of analyses to assess how users reacted to the evolution of vaccines for the Covid-19. The results demonstrate the immense potential of online platforms to provide insight into people's reactions to crisis and how their behavior evolves. Although utilizing data from such platforms to understand Covid-19's public response has been explored to a certain degree, this study is among the first to address the issue in the Persian language. The future work can be attributed to the directions of a more comprehensive analysis of network properties and structures, such as community detection, to have a richer understanding of influential users and their connections. Furthermore, we did not segregate real accounts from fake users and bots. An accurate methodology to exclude bots from the user base would be beneficial for more robust insights into user behavior. Another important topic related to the bots is their influence in steering society's way of thinking about vaccination and social matters in general. Studying their presence, attributes or features that separates them from normal users, and the content they're spreading can be explored in future so that more cohesive and reliable content can be handed over the people searching for information.
| {'timestamp': '2023-02-10T02:08:55', 'yymm': '2302', 'arxiv_id': '2302.04511', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04511'} | arxiv |
\section{Introduction}
\label{intro}
The human visual system is used to seeing incomplete outlines. Our brains can effortlessly group visual elements and fragmented contours that seem to be connected to each other. This power enables us to make shapes, organize disconnected visual features, and even properties of 3D surfaces when projected on 2D planes.
\cite{rensink1998early} demonstrated how early vision may quickly complete partially-occluded objects using monocular signals.
This capability of perceptual grouping has been studied in vision science for decades \cite{witkin1983role, lowe1985visual, sarkar1993perceptual, goodnow_childrens_1980}. Although there has been some work on perceptual grouping \cite{rezanejad2020medial,levinshtein2013multiscale, lee2015learning, rezanejad2019gestalt} in the past couple of years, it has been less studied in the past decade due to the enormous progress of deep neural networks and their success in dealing with the pixel-by-pixel inference of images.
Different types of lines and curves have been studied to maximize the connectivity of two broken ends in the planer contour completion problem \cite{rutkowski1979shape, ullman1976filling, brady1980shape}. Different types of lines and curves have been studied to maximize the connectivity of two broken ends in the planer contour completion problem. Geometry-based constraints can be utilized to address some challenges of contour completion problems, such as smoothness and curvature consistency \cite{horn1983curve, mumford1994elastica, sharon2000completion, mio2006contour}. However, such approaches only work for simple, smooth contours and usually fail in more complex settings.
On the other hand, we currently have deep models that could easily take an incomplete image and complete the missing regions using enough training data \cite{yu2018generative, elharrouss2020image, qin2021image}. The amazing capability of such models especially those that are trained on different modalities with millions or billions of training data \cite{brown2020language,ramesh2022hierarchical, saharia2022photorealistic} raises the question of whether we need such a large amount of training to perceive all the visual cues that are present in an image, which underlies visual perception by humans.
In human vision, Gestalt psychology \cite{koffka1922perception} suggests that our brain is designed to perceive structures and patterns that are grouped by some known rules.
In this work, we show that some perceptual structures can also be learned from the image itself directly using architectures that enable such learning. Earlier work has shown that some forms of perceptual grouping can be achieved using computational models, such as stochastic completion fields \cite{williams1996local,williams1997local,DBLP:conf/bmvc/RezanejadGGMWGW21}. This type of learning resonates with some of the Gestalt perceptual grouping principles including ``proximity'', ``good continuation'' and ``similarity''. In scenarios where color and/or texture are present, the cue of ``similarity'' helps us group regions with consistent patterns \cite{camaro2020appearance}. When color and texture are present, they provide a collection of rich information for such cues. In the present article, we probe convolutional neural networks in a scenario where both are absent, and the neural network is dealing with just forms and shapes.
Specifically, we explore whether the convolutional neural network architecture itself can give rise to some of these grouping cues when they are fed just contours and shapes alone. For years, neural networks have been treated as black boxes that can generalize images very well to multiple classes when there are enough training exemplars. One of the reasons that neural networks are trained on many exemplars is to avoid the problem of overfitting. On the other hand, we know that CNNs that generalize well to large classes of exemplars can easily overfit when those class labels are randomly permuted \cite{zhang2021understanding}. Inspired by this observation, \cite{ulyanov2018deep} suggest that image priors can be learned to a large extent through a generator network architecture \cite{goodfellow2020generative} that is solely trained on a single image. This encouraged us to take a deeper look at what structural information can be learned from a single-shape image and whether we can reconstruct some of those perceptual grouping capabilities using a generator network.
Inspired by \cite{zhang2021understanding,ulyanov2018deep}, in this work, we adopt a novel training regime to complete shapes and contours where we use a UNet architecture \cite{ronneberger2015u} with random initial weights and try to complete the contours within a single image without any training data. In our model, we imagine that the input image (i.e., the only image used to update the model's weights) is an image of fragmented contours. In this work, instead of training the model on multiple images fetched from a big image dataset, we imagine a random fixed tensor noise image as input to this model. At each iteration, the random noise tensor is inferred through our generative network and the network produces an outcome image. We introduce a novel loss function that enables this network to complete contours. This process repeats, and the weights of our network are updated gradually based on this loss function, which is an energy term defined based on the input image and the output of the network.
\begin{figure}[!t]
\centering
\begin{tabular}{cc}
\multicolumn{2}{c}{\includegraphics[width = 0.4\textwidth]{figures/illusive.pdf}} \\
\hspace{15mm} \textbf{(a)} & \hspace{15mm} \textbf{(b)}
\end{tabular}
\label{figure_kaniza}
\caption{Just by looking at subfigure \textbf{(a)}, we, as humans, can easily perceive a shape like the one in subfigure \textbf{(b)}. This is an extraordinary capability of our human brain and in this paper, we tried to see whether convolutional neural networks can show such capabilities. }
\end{figure}
The model will reconstruct the missing structures i.e., group fragmented contours that perceptually seem to be connected, before it fully overfits to the incomplete input image.
Contributions of our work are summarized as follows:
\begin{enumerate}
\item In our pipeline, we propose a novel algorithm that enables us to complete contours that appear to be connected to each other in an illusory form.
\item Our model is trained on just one single query image and does not need any training data.
\item Our model does not need to know which regions of the image are masked or occluded, i.e., we remove the dependency of the algorithm on the guiding mask (a guiding mask is a mask that informs the model on where the missing regions are located at).
\item We also introduce two metrics to produce a stopping criterion to know when to stop training before the model fully overfits to the incomplete image, i.e., we guide the model to stop when the completed image is produced.
\end{enumerate}
\begin{figure}[!b]
\centering
\includegraphics[width = 0.45\linewidth]{figures/figure1.pdf}
\caption{The trajectory from random noise $X_{N}$ to the incomplete image $X_{I}$ in image space. The network will pass a completed version of the image, $X_{C}$, throughout this trajectory.}
\label{fig:figure_path}
\end{figure}
\section{Methods}
\label{methods}
Our eyes are trained to predict a missing region of an occluded object within a scene. We can easily perceive or make guesses about parts of objects or shapes that we do not necessarily see. Even when we are looking at an image, we might guess about the shape, property, or other attributes of an unknown object within a scene. Such capability extends beyond just known objects or shapes. We can look at a disconnected set of contours and guess what the connected form may look like. This capability is rooted in our prior knowledge about the world. (see Figure \ref{figure_kaniza}).
\begin{figure*}[!t]
\centering
\includegraphics[width = 0.95\textwidth]{figures/architecture-v3.pdf}
\caption{This figure shows the architecture of our model, which is based on the UNet-like hourglass architecture with skip-connection used in \cite{ulyanov2018deep}.}
\label{figure3}
\end{figure*}
In this work, we aim to achieve a similar capability using deep generative networks.
Most neural networks that we work with these days are trained with a massive amount of data and one might think that this is the only way that a neural network can obtain prior information. Authors of Deep Image Prior (DIP) \cite{ulyanov2018deep} suggest that the convolutional architecture can capture a fair amount of information about image distribution. They show that the hourglass architectures like {UNet \cite{ronneberger2015u} can show some good performances in some inverse problems such as image denoising, super-resolution, and inpainting.
\begin{figure}[!b]
\centering
\includegraphics[width = 0.5\linewidth]{figures/fig_iterative_process.pdf}
\caption{This figure shows our iterative process to complete the fragmented contours of an image given as input to our pipeline.}
\label{fig:figure_iterative}
\end{figure}
In this work, we focus on completing fragmented contours end-to-end just by using a single image. To be able to address this problem, we first look at a similar problem in image editing, known as image inpainting. Image inpainting is the task of completing an image where some regions of that image are covered or filtered by a mask. In image inpainting, the generative model receives a masked image with the mask that guides the algorithm to fill in those missing regions. Although in the problem of contour completion, we have a very similar goal, the additional challenge that we suffer from is that we do not necessarily have a mask that covers the regions of interest for us. For example, when we look at Figure \ref{figure_kaniza} (left), we are not provided that which regions of the image are incomplete by a guiding mask. Our brain figures this out just by looking at the form and predicting those missing regions.
Inspired by the image inpainting work of DIP \cite{ulyanov2018deep}, we propose a novel algorithm for the contour completion problem (see Figure \ref{figure3}), where, unlike DIP, we do not have a guiding mask to know where to fill in the missing regions of our disconnected contours.
Let us assume that we are given a degraded image $x_{I}$ containing a fragmented contour. We propose an iterative process (see Figure \ref{fig:figure_iterative}) that can connect those discontinuities and glue those fragmented pieces together as follows. We propose an hour-glass model structure ($f$) that is initially set up with completely random parameters ($\theta_0$) at first. Through an iterative process, we start feeding our network with a fixed random tensor noise $z$ signal and obtain the inferred output ($f(z)$) from that network. We then back-propagate the difference between the inferred output and the incomplete image to the network. We then repeat this process until the difference between the generated outcome of the network ($f_\theta(z)$) and the incomplete image ($x_I$) gets smaller and smaller and finally overfits the incomplete image ($x_I$). In this work, we propose a novel error metric to backpropagate in the model and update its weights. we set the metric in a way that enables us to complete the incomplete image before it overfits the incomplete image. This is where the magic of our algorithm happens. We also propose a stopping criterion, so that when the image is complete, we no longer overfit the outcome of the model and instead produce a plausible connected set of fragmented contour pieces. As illustrated in Figure \ref{fig:figure_path}, this trajectory will pass through a complete version of the image in image space, which is close to the actual connected ground truth $x_{gt}$, which we do not have access to directly.
\subsection{Energy Function}
We can model this iterative process mathematically by maximizing a posterior distribution. Let us assume that the optimal image $x^*$ that we want to achieve is on a path that connects a random tensor noise $z$ to the incomplete image $x_I$. With this assumption, we can eventually overfit any random tensor noise to the incomplete image $x_{I}$, and we can formulate the posterior distribution of our wanted optimal image $x^*$ as follows:
\begin{equation*}
x^{*} = \argmax_x p(x|x_I),
\end{equation*}
To better recapitulate what we want to achieve using our generative model, we solve an energy minimization problem on the parameter space of the model, rather than explicitly working with probability distributions and optimizing on $x$ (image space). Thus, we solve an energy minimization problem that incorporates the incomplete image ($x_I$) and model parameters ($f_\theta(z)$):
\begin{equation*}
\theta^{*} = \argmin_\theta E(f_{\theta}(z);x_{I}),\qquad x^{*}=f_{\theta^{*}}(z)
\end{equation*}
As shown in Figure \ref{fig:figure_iterative}, the pipeline starts from a random initialized set of parameters $\theta$ and updates those weights until it reaches a local minimum $\theta^{*}$. The only information provided for the network is the incomplete image $x_I$.
When we reach the optimal $\theta^{*}$, the completed image is obtained as $x^{*} = f_{\theta^{*}}(z)$ where $z$ is random tensor noise. In this work, we use a U-Net architecture with skip connections as the generator model.
As we mentioned previously, in this work we were inspired by an earlier work known as Deep Image Prior (DIP) \cite{ulyanov2018deep}. In this work, the authors suggested a mean-squared-error loss term that enables the network to compare the output of the generator to the incomplete input image:
\begin{equation}
E(x;x_{I})=\left \|(x-x_{I})\odot m \right \|\ ^{2}
\label{eq:base}
\end{equation}
where $ x_{I} $ is the incomplete image with missing pixels in correspondence of a binary mask $m \in \left \{ 0,1 \right \}^{H \times W}$ and $\odot$ operator is for point-wise multiplication of two image matrices. In the inpainting tasks, the existence of a mask is essential as the algorithm needs to know where to fill in the missing area, whereas, in our work, we wanted to know whether the network can perform completion on its own without the need for the mask. In other words, is it possible for the network to predict where to fill in at the same time that it is trying to reconstruct the incomplete image through the iterative process? To answer this question, we tried to solve a much harder problem in which the mask is not provided to the model and the model is agnostic to it. To better understand how a solution could be hypothesized for this problem, we first imagine that we want to consider all the available regions in our image that could be potential places to fill in, i.e., we set the mask in the previous formula \ref{eq:base} to be equal to the incomplete image $x_I$. This is problematic as the model quickly tries to fill in all white space and quickly reconstructs the incomplete image by doing so. On the other hand, we can take the inverse problem of the current problem, where the model tries to just fill in the regions that fragmented contour lives in. Taking these two at the same time, we came up with a novel loss term for energy minimization term that helps us remove the need for the mask in the case of the contour completion problem:
\begin{multline} \label{eq:2}
E(x;x_{I}) = \alpha \times \overbrace{\|(x-x_{I})\odot x_{I} \|\ ^{2}}^{\text{missing region reconstruction loss}}
+ (1-\alpha) \times \overbrace{\left \| (1-x)\odot(1-x_{I}) - (1-x_{I})\odot(1-x_{I}) \right \|\ ^{2}}^{\text{original contour reconstruction regularization term} }
\end{multline}
In this term, we introduce a linear combination of the two loss terms, where one focuses on reconstructing the missing regions in the foreground, and one focuses on avoiding inpainting regions in the background. The logic behind this is that, if we assume the original image to be representative of the mask, then the model tries to reconstruct in all white regions (the foreground), and in the inverse problem we just want to reconstruct the regions that are already part of the ground truth.
\subsection{Stopping Criteria}
As shown in Figure \ref{fig:figure_path}, knowing when to stop iterating to the over-fitted model is a key to obtaining a completed shape. Therefore, we equipped our model with a criterion that uses two individual novel terms to know when to stop and output the result of the network. These two metrics expand the capability of the generator network beyond what it does currently and achieve a full end-to-end contour completion model that trains and infers on a single image of divided contour fragments. These new terms are: \textit{reconstruction\_score} ($\rho$) and \textit{overfit\_score} ($\omega$).
\subsubsection{Reconstruction Score}
The first score that this paper suggests is the reconstruction score, i. e., we have to make sure that the model is trained enough that it can reconstruct at least the entire set of fragmented contours within the image. This is a trivial score and to compute the \textit{reconstruction\_score} ($\rho$), we apply a $k$-dimensional tree (KDTree) nearest-neighbor lookup to find the ratio of points in the original incomplete image ($x_0$). This score ranges from $[0 - 100]$.
\subsubsection{Overfit Score}
It is evident that the model overfits the fragmented contours. This is due to the fact that the error in our loss term is minimized as the $x$ overfits to $x_I$, i. e., replacing $x$ with $x_I$ in the loss term would give us zero. As we hypothesize iterative process also produces the complete image before it overfits to the incomplete image, we can imagine that at some point the image is complete ($x_C$) and does not need to be fine-tuned any more to overfit to $x_I$. We suggest a new score called \textit{overfit\_score}. \textit{overfit\_score} determines how much of the reconstructed outcome is over the number of pixels that are already in the incomplete image ($x_I$). To compute the \textit{overfit\_score} ($\omega$), we apply a $k$-dimensional tree (KDTree) nearest-neighbor lookup of points in the outcome of the input image and see what portions of those points are novel and not already in the incomplete image ($x_I$). Similar to \textit{reconstruction\_score}, the \textit{overfit\_score} also ranges from $[0-100]$.
\subsubsection{Combined Score}
To be able to find the best possible set of completed contours, we combine the two and have a loop that tries to achieve close to full reconstruction and avoids over-fitting at the same time. This is what we call an "ideal" stopping point in the contour completion problem. In each run throughout all iterations, we pick an output of the network that minimizes a dissimilarity term:
\begin{equation}
\delta = \sqrt{(\rho- 100)^{2} + (\omega - \gamma)^{2}}
\end{equation}
where $\delta$ represents our dissimilarity score. The \textit{reconstruction\_score} and \textit{overfit\_score} are obtainable given network output and the incomplete image. Ideally, we want to achieve an output image that has a \textit{reconstruction\_score} equal to 100 and an \textit{overfit\_score} of $\gamma$ which is a hyperparameter that is dependent on the image and complexity of the shape. Empirically, we observed that this value is highly correlated with the distance between gaps that are observed in fragmented contours, i. e., the larger the gap results in a larger $\gamma$ value. We will discuss this in more detail in the next section (see Section \ref{exp}).
\begin{figure}[t]
\centering
\includegraphics[width = 0.35\linewidth]{figures/values_fig.pdf}
\caption{
This example shows how different scores change throughout a single run. All three scores change in the range of $[0,100]$. Our goal is to maximize \textit{reconstruction\_score} and minimize the \textit{overfit\_score}, but we should consider that the minimization lower bound is data dependent and is not zero.}
\label{figure6}\vspace{-4mm}
\end{figure}
For one sample image, we computed the two metrics \textit{reconstruction\_score} and \textit{overfit\_score} and the combined value of dissimilarity ($\delta$) and showed how these values change (see Figure \ref{figure6}). Our initial observations show that the \textit{reconstruction\_score} will increase to 100 quickly for the incomplete image indicating that the already existing fragments of the contours have been reconstructed in the output.
However, as mentioned previously, we cannot solely rely on this score since we also want to minimize the overfitting. Remember that our goal is to produce an output that: a) preserves the original contours in the incomplete image and b) fills in the gaps between the fragmented contours.
It is evident that \textit{overfit\_score} decreases throughout an iterative run of our process until it reaches zero. The \textit{dissimilarity} will also decrease along with the overfit to a point, then it will increase, as the model tries to reproduce the incomplete image. This is where an ideal $\gamma$ value can be picked, i.e., where to stop when the reconstruction is good but we have not done a full overfit to the incomplete image.
Thus, one should pick the value of $\gamma$ empirically in the scenario that the ground truth is not available, whereas, assuming that the ground truth is available, we can easily compute the best $\gamma$ value.
In our experiments, we tried two datasets of images with different gap sizes. We observed that the best the $\gamma$ for one set of samples is $\sim 5$ (the set with shorter gaps) while it is $\sim 23$ for samples from the other set, i. e, the set with longer gaps (see Figure \ref{fig:examples} for some completed examples).
\begin{figure*}[!b]
\centering
\begin{tabular}{c@{\hskip 1pt}c@{\hskip 1pt}c@{\hskip 1pt}c@{\hskip 1pt}c@{\hskip 1pt}c@{\hskip 1pt}c@{\hskip 1pt}c}
\fbox{\includegraphics[width = 0.107\textwidth]{figures/ex1/frame-001.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex1/frame-010.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex1/frame-020.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex1/frame-030.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex1/frame-038.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex1/frame-050.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex1/frame-160.pdf}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex1/circle_303.pdf}} \\
\fbox{\includegraphics[width = 0.107\textwidth]{figures/ex2/frame-001.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex2/frame-010.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex2/frame-020.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex2/frame-030.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex2/frame-040.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex2/frame-050.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex2/frame-176.pdf}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex2/parallelogram_405.pdf}} \\
\fbox{\includegraphics[width = 0.107\textwidth]{figures/ex3/frame-001.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex3/frame-015.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex3/frame-025.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex3/frame-035.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex3/frame-045.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex3/frame-055.png}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex3/frame-125.pdf}} & \fbox{\includegraphics[width = 0.107\textwidth]{figures/ex3/rhombus_028.pdf}}
\end{tabular}
\caption{Evolutionary process of the deep structure prior. The right column shows the incomplete shapes given to the model and the rest of the columns show how the model is overfitting gradually to produce the incomplete shapes. In each column, we are showing an intermediate iteration of this process. The loss-term setup enables our pipeline to let the completed image appears during this iterative process. }
\label{fig:examples}
\end{figure*}
\section{Experiments and Results}
\label{exp}
Performing unsupervised contour completion is a difficult task to benchmark as one can never know what fragments exactly are connected to each other in a real-world scenario. This makes the problem of contour completion a hard problem to solve. In this paper, we tried to create artificial shapes that are occluded by some masks and then tried to see if our model can regenerate the missing pieces and glue those divided contours together. To demonstrate our model's behavior, we will conduct experiments on datasets created for this task and will report on them in this section. To compare network results in different settings, we will use pixel-wise Mean Squared Error (MSE) and Intersection over Union (IoU) between the produced result of the network and unmasked ground truth data and the reconstructed image on black pixels (where contours live).
\subsection{Data}
We prepared two datasets, one labeled ``Simple" and one ``Complex", in accordance with the number of gaps in each shape. Both datasets contain nine different categories of shapes. In order to generate the \textit{Complex dataset}, we used FlatShapeNet \cite{reevald2022} which is a dataset for the educational game Ariga. The dataset includes the following categories: Circle, Kite, Parallelogram, Rectangle, Rhombus, Square, Trapezoid, Triangle and Overlap. The ``overlap" category contains images that are made as a mixture of two shapes that are overlapping from the previous categories. These are some standard shapes with a few gaps in \textit{simple dataset}, while the \textit{complex dataset} has some hand-drawn shapes with fragmented lines and more gaps that produce more variety in general. For each instance, a ground truth image is available for comparison.
Most of our experiments have been conducted using the \textit{complex dataset} in order to evaluate the generalization of our approach. For the analysis of how $\gamma$ values should be set for each shape, we used the \textit{simple dataset} as a reference.
\subsection{Evaluation}
In this section, we compare our model to the original Deep Image Prior (DIP) \cite{ulyanov2018deep} inpainting model. DIP's inpainting module accepts a degraded image and a binary mask corresponding to that image. In order to make a fair comparison, instead of providing a binary mask, we used the incomplete images both as input and as a mask in order to see whether it can produce a result similar to ours.
For DIP, we run the iterative process for a maximum number of 2500 iterations with the U-net backbone.
We used the exact same architecture and setting in our model for a fair comparison. Using our ground truth dataset images, we calculate the MSE loss between the network output and ground truth during each iteration instead of relying on our stopping mechanism described in the previous section. We then store the output with minimal loss throughout all the iterations. Finally, we select the best output among all iterations, report the MSE and IoU with the ground truth, and save the iteration number which resulted in the lowest MSE. Table \ref{table1} compares the results that are obtained using the DIP method, the DSP method (ours), and the difference between raw images and the ground truth. We have presented the average MSE-loss, average IoU, and the average number of iterations for the best output for different methods. As can be seen from the table, our model improves both MSE and IoU between the incomplete image and ground truth in fewer iterations. The DIP method can neither generate a better result than the raw image nor provide stopping criteria to prevent overfitting.
We provide a more detailed analysis of this result in Figure \ref{figure7}. As results show, our algorithm not only provides a much faster convergence but also consistently provides a better-completed image (consistently less MSE loss and better IoU), whereas it is challenging for the DIP method to accomplish better results without a guiding mask.
\begin{figure*}
\centering
\begin{tabular}{c@{\hskip 0pt}c@{\hskip 0pt}c}
\includegraphics[width=0.33\textwidth]{figures/mse_fig.pdf} & \includegraphics[width=0.33\textwidth]{figures/iou_fig.pdf} &
\includegraphics[width=0.33\textwidth]{figures/iter_fig.pdf}\\
\textbf{(a)} & \textbf{(b)} & \textbf{(c)}
\end{tabular}
\caption{In this Figure, we compare the completed images from our algorithm, DSP, (shown in green) with the best obtained completed images from the DIP method (shown in red). We compare MSE loss between the degraded raw images that these algorithms started with (shown in blue) \textbf{(a)} Mean Squared Error Loss: we clearly see that for almost all images, DSP (green) achieves a lower MSE than the incomplete images (blue) whereas, the DIP completed images either do not improve the MSE or even worsen that for the incomplete images. Note that, the MSE is computed to an available ground truth image hidden from our methods (the lower is better). \textbf{(b)} Intersection Over Union: here, we are looking at the IoU metric that specifies the amount of intersection over the union between the obtained images and the ground truth data. Again, we see that DSP produces images that are much closer to the ground truth (in most cases) whereas the DIP can not achieve a similar result. While we see few DIP completed images produce a better IoU than the degraded images (in terms of IoU), most of them are worse than the starting image (the higher is better). \textbf{(c)} The number of iterations that are needed for each algorithm to obtain its best results. Here, we see that DSP can quickly produce the best outcome with the least MSE loss whereas the DIP algorithm's best results are when we run the iterative process for more iterations (the lower is better). }
\label{figure7}
\end{figure*}
\begin{table}[!t]
\caption{Average MSE and IoU values between the incomplete (Raw) images, the output of DIP and DSP methods, and ground truth for each image are provided in this table.}
\label{table1}
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{lcccc}
\toprule
Method & MSE & IoU & Iterations & Time (s)\\
\midrule
Raw & 829.01 & 0.65 & 0 & 0\\
DIP & 2027.52 & 0.29 & 2013 & 54.68\\
DSP (Ours) & \textbf{490.84} & \textbf{0.74} & \textbf{359} & \textbf{9.55}\\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
\subsection{Correlation of $\gamma$ with the Gap Size}
To better understand the $\gamma$ parameter of our combined score, we conducted the following experiment. A total of 12000 samples were obtained by merging all of our images from the two datasets, \textit{simple} and \textit{complex}. As we have access to the ground truth for each degraded image in the combined dataset, we can easily calculate \textit{reconstruction\_score} and \textit{overfit\_score} for each degraded-ground truth pair. As expected, we obtain a \textit{reconstruction\_score} of 100 for all samples, but the \textit{overfit\_score} varies among them.
Intuitively, we hypothesized that an optimal value of overfit score should be intertwined with the total area of gaps. To test this hypothesis, we did the following experiment. We first define a function $\phi(x)$ which takes a binary, black and white image $x$ and returns the number of black pixels in it. Then we define a \textit{gap} term as follows:
\begin{equation}
gap = \frac{\phi(x_{gt}) - \phi(x_{I})}{\phi(x_{gt})}
\end{equation}
where $x_{I}$ is the incomplete image and $x_{gt}$ is the ground truth. In this case, \textit{gap} indicates the total area of the gap with respect to the whole shape. We found out that this term and the best result have a correlation of $\mathbf{97.43\%}$. This indicates that the value of $\gamma$ is highly correlated with the gap size, that is something expected in a way.
\subsection{Effect of $\alpha$}
\label{further}
We conducted additional experiments concerning how $\alpha$ affects the quality of reconstruction. In the previous section, we defined Equation \ref{eq:2} as the loss term that guides our iterative process. The term $\alpha$ specifies the amount of emphasis the model should place on reconstructing missing regions, rather than filling in fragmented contours. A lower $\alpha$ indicates a better grouping quality, as shown in Equation \ref{table2}. However, we will not achieve completion if we remove the first term completely from the loss by setting $\alpha=0$. Therefore, the first term should be kept, but its weight should be very low in order to achieve a good completion. On the other hand, if we set $\alpha=1$ and omit the second term, we lose the contour completion regularization term and obtain the same output as a vanilla deep image prior, which does not complete shapes.
\begin{table}[!h]
\caption{
For this experiment, we ran the model over a subset of \textit{complex} dataset with 500 incomplete images at various levels of alpha for 250 iterations. After the image completion is done, we compared the evaluation metrics between the completed image and the ground truth to examine the performance of the model for different values of alpha.\\}
\centering
\begin{tabular}{c c c c c}
\toprule
Alpha & MSE & IoU & Iterations & Time (s)\\ [0.25ex]
\hline\hline
0 & 17240.44 & 0.04 & 0 & 0\\
0.05 & 619.82 & 0.71 & 221 & 7.75\\
0.1 & 456.77 & \textbf{0.76} & 210 & 7.35 \\
0.15 & \textbf{456.52} & 0.75 & 184 & 6.37 \\
0.2 & 485.53 & 0.74 & 157 & 5.44 \\
0.25 & 527.35 & 0.73 & 151 & 5.25 \\
0.3 & 551.23 & 0.72 & 151 & 5.25 \\
0.35 & 602.57 & 0.71 & 155 & 5.31 \\
0.4 & 644.36 & 0.69 & 160 & 5.34 \\
0.45 & 682.33 & 0.68 & 172 & 5.77 \\
0.5 & 749.29 & 0.66 & 183 & 6.13 \\
0.55 & 825.89 & 0.63 & 197 & 6.80 \\
0.6 & 906.45 & 0.60 & 206 & 7.10 \\
0.65 & 996.34 & 0.57 & 222 & 7.70 \\
0.7 & 1132.19 & 0.52 & 228 & 7.91 \\
0.75 & 1294.25 & 0.48 & 228 & 7.92 \\
0.8 & 1546.86 & 0.43 & 225 & 7.78 \\
0.85 & 2111.38 & 0.36 & 216 & 7.40 \\
0.9 & 4031.41 & 0.29 & 185 & 6.32 \\
0.95 & 7772.83 & 0.16 & 107 & 3.70 \\
1 & 12258.55 & 0.06 & 11 & 0.36 \\
\hline
Raw & 843.23 & 0.65 & 0 & 0\\
\bottomrule
\end{tabular}
\label{table2}
\end{table}
\subsection{Effect of Receptive Field Size}
To better understand the effect of receptive field size on our algorithm, we test the following hypothesis: can models with bigger receptive field size complete shapes with bigger gaps? In Table \ref{tab:receptive_field}, we report showing the results of this experiment. As we can see, the bigger the receptive field size, the more complete shapes we can reconstruct using DSP.
{\renewcommand{\arraystretch}{1.05}\begin{table}[!h]
\caption{In this table, we show the effect of the receptive filter size on our algorithm's capability to fill in bigger gap sizes. The numbers in this table are showing the percentage of the time that DIP was successful to complete shapes with each gap size and corresponding receptive field size. As predicted, the bigger the filter size, the more successful the algorithm is in filling in the gaps. \vspace{1mm} }
\centering
\begin{tabular}{c|cccc}
\toprule
Receptive & \multicolumn{4}{c}{Gap Size}\\
\cline{2-5}
Filter size & 8 & 10 & 12 & 15 \\\hline\hline
3 & 66.66\% & 56.0\% & 26.13 \% & 20.26\%\\\hline
5 & 85.33\% & 66.66\% & 54.13\% & 26.13\%\\\hline
7 & \textbf{85.33}\% & \textbf{76.0} \% & \textbf{54.66}\% & \textbf{26.93}\%\\
\bottomrule
\end{tabular}
\vskip -2.5mm
\label{tab:receptive_field}
\end{table}}
\section{Implementation Details}
As shown in Figure \ref{figure3}, we use a model with 5 layers and 128 channels for downsampling and upsampling convolutions, and 64 channels for skip convolutions. The upsampling and downsampling modules use $3\times3$ filters, while the skip module uses $1\times1$ filters. In the upsample part of the network, the nearest neighbor algorithm is used. We used $256\times256$ images with three channels in all of our experiments. In training, we use the MSE loss between the degraded image and the output of the network, and we optimize the loss using the ADAM optimizer and a learning rate equal to 0.01 .
In our experiments, we also used $\alpha=0.15$ as an optimal proportion coefficient for reconstruction loss.
\section{Conclusion}
In this work, we introduced a novel framework for contour completion using deep structure priors (DSP). This work offers a novel notion of a maskless grouping of fragmented contours. In our proposed framework, we introduced a novel loss metric that does not require a strict definition of the mask. Instead, it lets the model learn the perceivable illusory contours and connects those fragmented pieces using a generator network that is solely trained on just the single incomplete input image. Our model does not require any pre-training which demonstrates that the convolutional architecture of the hour-glass model is able to connect disconnected contours. We present an extended set of experiments that show the capability of our algorithm. We investigate the effect of each parameter introduced in our algorithm separately and show how one could possibly achieve the best result for their problem using this model. In future work, we plan to extend this model and try to see how it performs with real images. In particular, we want to determine whether we can inpaint real-world photographs while retaining perceptually aware scene structures. The importance of shape in perception by deep neural networks has been highlighted in many adversarial examples to appearance-based networks \cite{baker2020local}. The outcome of this work has strong potential to impact the designing and implementation of models that are robust to such perturbations.
\bibliographystyle{unsrt}
| {'timestamp': '2023-02-10T02:06:59', 'yymm': '2302', 'arxiv_id': '2302.04447', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04447'} | arxiv |
\section{Introduction}
\paragraph{Sequential balanced allocations.} In the sequential balanced allocations framework, there are $m$ tasks (balls) to be allocated into $n$ servers (bins). It is well-known that allocating the balls into bins sampled uniformly at random (a.k.a.~\OneChoice) leads \Whp\footnote{In general, with high probability refers to probability of at least $1 - n^{-c}$ for some constant $c > 0$.}~to a maximum load of $\Theta(\log n/\log \log n)$ for $m = n$ and a gap (maximum load minus average load) of $\Theta\big(\sqrt{(m/n) \cdot \log n}\big)$ for $m \geq n \log n$.
An improvement over \OneChoice is the \DChoice process~\cite{KLM96,ABKU99,BCSV06}, where for each ball $d$ bins are sampled uniformly at random and the ball is allocated to the least loaded of the sampled bins. For any $m \geq n$, this process achieves \Whp~an $\log_d \log n + \Theta(1)$ gap, i.e., a gap that does not depend on $m$. For $d = 2$, this great improvement is known as ``power-of-two-choices'' (see also surveys~\cite{MRS01,W17} for more details). Despite the simplistic nature of the balanced allocation framework, the \TwoChoice process has had a significant impact on practical applications such as load balancing and distributed storage systems, which was also acknowledged by the ``\emph{ACM Paris Kanellakis Theory and Practice Award 2020}''~\cite{award20}.
Several variants of \TwoChoice have been studied. Of particular importance to this work is the \OnePlusBeta process, where for each ball we run \TwoChoice with probability $\beta \in (0, 1]$ and \OneChoice otherwise. Mitzenmacher~\cite{M96} introduced this process as a model of~\TwoChoice with erroneous comparisons. Peres, Talwar and Wieder~\cite{PTW15} showed that for $\beta := \beta(n) \ll 1$, it achieves \Whp~a $\Theta((\log n)/\beta)$ gap (see also~\cite{LS22Batched}), which becomes worse for smaller $\beta$, but still remains independent of $m$. An additional reason of the significance of \OnePlusBeta is the application to the analysis of \TwoChoice in the popular \emph{graphical setting}~ \cite{KP06,BF21,PTW15}, where bins are organized as vertices in a graph, and each ball samples an edge uniformly at random.
Another variant of \TwoChoice that has received some attention recently is the family of \TwoThinning processes~\cite{FG18,FL20}, where the ball is allocated to the second sample only if the first one does not meet a certain criterion, e.g., based on a threshold or quantile.
It should be noted that the analyses of all these processes strongly rely on the fact that the load information of each bin is updated after each allocation. In effect that means balls can only be allocated sequentially, which is a downside in distributed and parallel environments.
\paragraph{Outdated information settings.} In this work, we demonstrate that in outdated information settings by choosing an appropriately small $\beta$, \OnePlusBeta achieves the asymptotically optimal gap among a large class of processes, including not only \TwoChoice (and \OneChoice), but even adaptive processes that may allocate with a different scheme after each batch. It has been long observed that the performance of the \TwoChoice process deteriorates under outdated information and delays~\cite{W86,M00,D00,OWZS13,FGCBG97}. %
Berenbrink, Czumaj, Englert, Friedetzky and Nagel~\cite{BCEFN12} studied the \Batched setting where balls are allocated in batches of size $b$. That means, every batch of $b$ consecutive balls can be allocated in parallel, as the decision where to place the ball only depends on the load configuration after that batch of balls arrived. For $b = n$, they proved that \TwoChoice achieves \Whp~an $\Oh(\log n)$ gap. This bound was recently improved to $\Theta(\log n/\log \log n)$ in~\cite{LS22Noise}, and in the same work, it was shown that \TwoChoice has a gap that matches the maximum load of \OneChoice for $b$ balls, for any batch size $b \in [n \cdot e^{-\log^{\Theta(1)} n}, n \log n]$, and so it is asymptotically optimal. In contrast, for $b \geq n \log n$, \TwoChoice (and a family of other processes) have \Whp~a $\Theta(b/n)$ gap~\cite{LS22Batched}, a bound which was shown to hold even in the presence of weights and on graphs. This analysis also demonstrates that increasing $d$ in the \DChoice process, does not always improve the gap, which is in sharp contrast to the sequential setting.
Outdated information settings have been also studied in the queuing setting~\cite{W86,AN92,KK95,FGCBG97,M00}. In particular, Mitzenmacher~\cite{M00} studied an equivalent version of the \Batched setting, called the \textit{bulletin board model with periodic updates}, showing that some processes requiring centralized coordination can outperform \TwoChoice, but no explicit rigorous bounds were proven. This shortcoming of \TwoChoice was characterized as \textit{herd behavior}, meaning that some of the initially lighter bins receive disproportionately many balls, turning them into heavy bins. In another empirical study, Dahlin~\cite{D00} also empirically observed the herd behavior and suggested similar centralized strategies to improve upon \DChoice.
\paragraph{Weighted settings.} Several works study balanced allocation processes with weights~\cite{TW07,BFHM08,PTW15,LS22Batched}. We will be focusing on weights sampled independently from probability distributions with bounded moment generating functions as in~\cite{PTW15} and~\cite{LS22Batched}.
\paragraph{Our Results.} In this work we show that a family of processes satisfying a technical condition achieve the asymptotically optimal gap\footnote{By \textit{optimal} we mean over all processes that choose a probability vector $p$ at the beginning of the batch and this stays the same throughout the batch (see \cref{thm:lower}).} of $\Oh\big(\sqrt{(b/n) \cdot \log n} \big)$ in the \Weighted \Batched setting for $b \in [2n \log n, n^3]$,\footnote{For $b = \Theta(n \log n)$, the $\Oh(\log n)$ bound also follows from~\cite[Theorem 4.2]{LS22Batched}} leading to roughly a quadratic improvement over the gap of the \TwoChoice process. This family of processes includes the \OnePlusBeta process, which is a process that can be implemented in a decentralized manner, and demonstrates that by setting $\beta = \sqrt{(n \log n)/b}$ we attain this asymptotically optimal gap. %
We also provide lower bounds establishing the tightness of our upper bounds. Interestingly, the lower bound of $\Omega(\sqrt{(n \log n)/b} )$ even applies to a much more powerful class of allocation processes, where the allocation rule can be tailored at the beginning of each batch to the current load configuration.
The intuition for these optimal processes relates to the herd behavior observed in~\cite{M00}; similarly, \cite{D00} calls this a ``too aggressive'' load interpretation. For the \DChoice process, the maximum probability of allocating to a bin is $\max_{i \in [n]} p_i \approx d/n$. This means that, for example, in \TwoChoice in a batch of $b$ balls there are some bins that receive $\approx 2b/n$ balls and so a gap of $\approx b/n$ arises. This becomes worse as $d$ grows. Here the processes we consider have $\max_{i \in [n]} p_i = (1 + o(1))/n$, which means that no bin receives too many balls in any particular batch. For example, the \OnePlusBeta process has $\max_{i \in [n]} p_i \approx (1 + \beta)/n$, which means that this mixing of \OneChoice steps with \TwoChoice steps circumvents the herd behavior (\cref{fig:two_choie_vs_batch_visual}). The different gap bounds and performances among \OneChoice, \TwoChoice and \OnePlusBeta depending on the batched setting are summarized in \cref{fig:table}.
\begin{figure}
\centering
\begin{minipage}[t]{0.3\textwidth}
\begin{center}
\includegraphics[scale=0.17]{figs/tc_load_vector.pdf} \\
\TwoChoice
\end{center}
\end{minipage}
\begin{minipage}[t]{0.3\textwidth}
\begin{center}
\includegraphics[scale=0.17]{figs/opb_load_vector.pdf} \\
\OnePlusBeta process
\end{center}
\end{minipage}
\caption{The balls allocated in the latest batch shown in red for \TwoChoice (left) and \OnePlusBeta with $\beta = 1/2$ (right). Observe that \TwoChoice allocates more aggressively on the bins that are lightly loaded at the beginning of the batch, while \OnePlusBeta spreads the allocations more evenly.}
\label{fig:two_choie_vs_batch_visual}
\end{figure}
\begin{table*}
\centering
\resizebox{\textwidth}{!}{
\renewcommand{\arraystretch}{1.75}
\begin{tabular}{ccccc}
\textbf{Process} & \textbf{Gap in Sequential Setting } & \textbf{Gap in Batched Setting} & \textbf{Constraints for Batching} \\ \hline
\OneChoice & $\Theta \left(\sqrt{ (m/n) \cdot \log n} \right)$~\cite{RS98} & $\Theta \left(\sqrt{ (m/n) \cdot \log n} \right)$~\cite{RS98} & none \\ \hline
\multirow{2}{*}{\TwoChoice} & \multirow{2}{*}{$\log_2 \log n + \Oh(1)$~\cite{ABKU99,BCSV06} } & $\Omega\left( b/n \right)$~\cite{LS22Batched} & none \\
& & $\Oh\left( b/n \right)$~\cite{LS22Batched} & $b \geq n \log n$ \\ \hline
\multirow{4}{*}{$(1+\beta)$} & \multirow{4}{*}{$\Theta( (1/\beta) \cdot \log n )$ ~\cite{PTW15}} & $\Omega\left( \sqrt{ (b/n) \cdot \log n} \right)$~\cref{thm:lower} & \multirow{2}{*}{$b \in [2n \log n,n^3]$, $\beta = \sqrt{(n \log n)/b}$} \\
& & $\Oh\left( \sqrt{ (b/n) \cdot \log n} \right)$~\cref{thm:batching_strong_gap_bound} & \\
& & $\Omega \left( \sqrt{ (b/n ) \cdot \log n} \right)$~\cref{thm:lower} & \multirow{2}{*}{$b \geq n^3$, $\beta = \sqrt{n/b}$} \\
& & $\Oh\left( \sqrt{ b/n } \cdot \log n \right)$~\cref{cor:weak_bound} &
\\ \hline
\end{tabular}
}
~\vspace{1em}~
\caption{For the sequential setting (i.e., the setting without batching), all gap bounds hold for any $m \geq n \cdot \log n$. For the sake of simplicity, we focus on the unweighted setting and only list results in batching for the \OnePlusBeta process, and where $b \geq n \log n$. Among all those processes, \OneChoice produces the worst gap in both settings, even though the gap does not change between the batched and sequential setting. For \TwoChoice, the gap becomes $b/n$ in the batched setting, whereas for $(1+\beta)$ the gap is only $\sqrt{(b/n) \cdot \log n}$ (for a suitable $\beta$), which leads to a better performance than \TwoChoice.}
\label{fig:table}
\end{table*}
\paragraph{Our Techniques.} Our techniques build on and refine those in~\cite{LS22Batched}, making use of the hyperbolic cosine potential function~\cite{PTW15} and variants. More specifically, a slightly weaker version of our tight upper bound is based on \cite[Theorem 3.1]{LS22Batched} and a refinement of \cite[Lemma 4.1]{LS22Batched}. For our tight gap bound, our approach uses an interplay between two hyperbolic cosine potential functions to prove concentration and then an exponential potential with a larger smoothing parameter to deduce the refined gap.
A similar method was used in \cite[Section 5]{LS22Batched}, but one crucial novelty here is that we consider allocation processes whose probability allocation vector have a small $\ell_{\infty}$ distance from the uniform distribution. We believe that relating and comparing different allocation processes based on their $\ell_{\infty}$ distance (or other metrics) could be a promising idea for future work. This can be also seen as a natural relaxation of the \emph{majorization technique}, which has been the dominant tool to relate different allocation processes \cite{PTW15,LS22Queries}.
\paragraph{Organization.} In \cref{sec:notation}, we introduce the balanced allocation framework and its notation, and define the processes and settings that we will be working with. In particular, in \cref{sec:conditions} we define general conditions on the probability allocation vector used by the processes, under which our upper bounds on the gap apply. In \cref{sec:weak_gap}, we prove the $\Oh\big(\sqrt{b/n} \cdot \log n\big)$ bound on the gap for a family of processes in the \Weighted \Batched setting. In \cref{sec:strong_gap}, we perform a refined analysis and improve this gap bound to $\Oh\big(\sqrt{(b/n) \cdot \log n}\big)$.
In \cref{sec:lower_bounds}, we show that this achieved gap is asymptotically optimal, and in~\cref{sec:experiments}, we present some empirical results on the gap of some specific processes.
Finally, in \cref{sec:conclusions}, we summarize the results and conclude with some open problems.
\section{Notation, Processes and Settings} \label{sec:notation}
In this section, we introduce notation, processes and settings used throughout this work. %
\subsection{Basic Notation} \label{sec:basic_notation}
We consider the allocation of $m$ balls into $n$ bins, which are labeled $[n]:=\{1,2,\ldots,n\}$. For the moment, the $m$ balls are unweighted (or equivalently, all balls have weight $1$). For any step $t \geq 0$, $x^{t}$ is the $n$-dimensional \emph{load vector}, where $x_i^{t}$ is the number of balls allocated into bin $i$ in the first $t$ allocations. In particular, $x_i^{0}=0$ for every $i \in [n]$. Finally, the \emph{gap} is defined as
\[
\Gap(t) = \max_{i \in [n]} x_i^{t} - \frac{t}{n}.
\]
It will be also convenient to keep the load vector $x$ sorted. To this end, let $\tilde{x}^t:=x^t-\frac{t}{n}$. Then, relabel the bins such that $y^{t}$ is a permutation of $\tilde{x}^t$ and $y_1^{t} \geq y_2^{t} \geq \cdots \geq y_n^{t}$. Note that $\sum_{i \in [n]} y_i^t=0$ and $\Gap(t)=y_1^t$. We will call a bin $i \in [n]$ \emph{overloaded}, if $y_i^t \geq 0$ and \emph{underloaded} otherwise.
Following~\cite{PTW15}, many allocation processes can be described by a time-invariant \emph{probability allocation vector} $p_i$, $1 \leq i \leq n$, such that at each step $t \geq 0$, $p_i$ is the probability of allocating a ball into the $i$-th most heavily loaded bin (or equivalently, incrementing $y_i^t$ by one).
By $\mathfrak{F}^t$ we denote the filtration of the process until step $t$, which in particular reveals the load vector $x^t$.
\subsection{Processes} \label{sec:processes}
We start with a formal description of the \OneChoice process.
\begin{samepage}
\begin{framed}
\vspace{-.45em} \noindent
\underline{\OneChoice Process:} \\
\textsf{Iteration:} For each $t \geq 0$, sample one bin $i$, independently and uniformly at random. Then update:
\begin{equation*}
x_{i}^{t+1} = x_{i}^{t} + 1.
\end{equation*}\vspace{-1.5em}
\end{framed}
\end{samepage}
\noindent We continue with a formal description of the \TwoChoice process.
\begin{samepage}
\begin{framed}
\vspace{-.45em} \noindent
\underline{\TwoChoice Process:} \\
\textsf{Iteration:} For each $t \geq 0$, sample two bins $i_1$ and $i_2$, independently and uniformly at random. Let $i \in \big\{i_1, i_2 \big\}$ be such that $x_{i}^{t} = \min\{ x_{i_1}^t,x_{i_2}^t\}$, breaking ties randomly. Then update:
\begin{equation*}
x_{i}^{t+1} = x_{i}^{t} + 1.
\end{equation*}\vspace{-1.5em}
\end{framed}
\end{samepage}
It is immediate that the probability vector of \TwoChoice is
\begin{equation*}
p_{i} = \frac{2i-1}{n^2}, \qquad \mbox{ for all $i \in [n]$.}
\end{equation*}
Following~\cite{PTW15}, we recall the definition of $(1+\beta)$ which is a process interpolating between \OneChoice and \TwoChoice:
\begin{samepage}
\begin{framed}
\vspace{-.45em} \noindent
\underline{($1+\beta$) Process:}\\
\textsf{Parameter:} A mixing factor $\beta \in (0,1]$.\\
\textsf{Iteration:} For each $t \geq 0$, sample two bins $i_1$ and $i_2$, independently and uniformly at random. Let $i \in \{ i_1, i_2 \}$ be such that $x_{i}^{t} = \min\big\{ x_{i_1}^t,x_{i_2}^t \big\}$, breaking ties randomly. Then update:
\begin{equation*}
\begin{cases}
x_{i}^{t+1} = x_{i}^{t} + 1 & \mbox{with probability $\beta$}, \\
x_{i_1}^{t+1} = x_{i_1}^{t} + 1 & \mbox{otherwise}.
\end{cases}
\end{equation*}\vspace{-1.em}
\end{framed}
\end{samepage}
In other words at each step, the $(1+\beta)$ process allocates the ball following the \TwoChoice rule with probability $\beta$, and otherwise allocates the ball following the \OneChoice rule. Therefore, the probability vector is given by~\cite{PTW15}:
\begin{equation*}
p_{i} =
(1-\beta) \cdot \frac{1}{n} + \beta \cdot \frac{2i-1}{n^2}, \qquad \mbox{ for all $i \in [n]$.}
\end{equation*}
Recall that in \cite{PTW15}, it was shown that $\Gap(m) = \Oh(\frac{\log n}{\beta})$ for any $m \geq n$ and $\beta \in (0, 1]$; so in particular, this gap (bound) does not grow with $m$.
The next process is another relaxation of \TwoChoice.
\begin{samepage}
\begin{framed}
\vspace{-.45em} \noindent
\underline{$\Quantile(\delta)$ Process:}\\
\textsf{Parameter:} A quantile $\delta \in \{1/n, 2/n, \ldots, 1 \}$.\\
\textsf{Iteration:} For each $t \geq 0$, sample two bins $i_1$ and $i_2$, independently and uniformly at random, and update:
\begin{equation*}
\begin{cases}
x_{i_2}^{t+1} = x_{i_2}^{t} + 1 & \mbox{if $i_1$ is among the $\delta \cdot n$ most loaded bins}, \\
x_{i_1}^{t+1} = x_{i_1}^{t} + 1 & \mbox{otherwise}.
\end{cases}
\end{equation*}\vspace{-1.em}
\end{framed}
\end{samepage}
Note that the $\Quantile(\delta)$ processes can be implemented as a two-phase procedure: First probe the bin $i_1$ and place the ball there if $i_1$ is not among the $\delta \cdot n$ heaviest bins. Otherwise, take a second sample $i_2$ and place the ball there. Since we only need to know whether a bin's rank is above or below a value, the response by a bin can be encoded as a single bit (at the cost of knowing the rank of each bin). The probability vector of $\Quantile(\delta)$ is given by:
\begin{equation*}
p_{i} =
\begin{cases}
\frac{\delta}{n} & \mbox{ if $1 \leq i \leq \delta \cdot n$}, \\
\frac{1+\delta}{n} & \mbox{ if $\delta \cdot n < i \leq n$}.
\end{cases}
\end{equation*}
Another, equivalent description of $\Quantile(\delta)$ is that we perform \TwoChoice, but only get to know whether a sampled bin's rank is below or above $\delta \cdot n$ and break ties randomly.
\subsection{Conditions on Probability Vectors}\label{sec:conditions}
In \cite{LS22Batched}, the \Weighted \Batched setting was analyzed for probability allocation vectors satisfying the following two conditions. The first condition says that the process has a small $\eps/n$ bias to place away from overloaded and towards underloaded bins; and the second condition says that no bin has too high probability of being allocated.
\label{sec:c1_and_c2_conditions}
\begin{itemize}\itemsep0pt
\item \textbf{Condition $\mathcal{C}_1$}: There exist constant\footnote{Here constant means that the quantile satisfies $\delta \in (\delta_1, \delta_2)$ for constant $\delta_1, \delta_2 \in (0, 1)$.} $\delta \in (0, 1)$ and (not necessarily constant) $\eps \in (0, 1)$, such that for any $1 \leq k \leq \delta \cdot n$,
\[
\sum_{i=1}^{k} p_{i} \leq (1 - \epsilon) \cdot \frac{k}{n},
\]
and similarly for any $\delta \cdot n +1 \leq k \leq n$,
\[
\sum_{i=k}^{n} p_i \geq \left(1 + \epsilon \cdot \frac{\delta}{1-\delta} \right) \cdot \frac{n-k+1}{n}.
\]
\item \textbf{Condition $\mathcal{C}_2$}: For some $C > 1$, $\max_{i \in [n]} p_i \leq \frac{C}{n}$.
\end{itemize}
In the same paper~\cite{LS22Batched} it was shown that any process with $\max_{i \in [n]} p_i \geq \frac{1+\eps}{n}$ for $\eps = \Omega(1)$ also has $\Gap(m) = \Omega(b/n)$ for any $b = \Omega(n \log n)$. Therefore, to improve on this gap, we have to consider processes with $\max_{i\in [n]} p_i = \frac{1 + o(1)}{n}$. In our analysis in \cref{sec:weak_gap,sec:strong_gap} we will make use of the following condition based on the $\ell_\infty$-distance between the probability allocation vector $p$ and the uniform distribution (i.e., \OneChoice):%
\begin{itemize}
\item \textbf{Condition $\mathcal{C}_3$}: There exists a $C > 1$, such that for any bin $i \in [n]$,
\[
\left| p_i - \frac{1}{n}\right| \leq \frac{C - 1}{n}.
\]
\end{itemize}
\noindent Note that this condition implies condition $\mathcal{C}_2$ for the same $C > 1$, but unline $\mathcal{C}_2$ it imposes both an upper and a lower bound on the $p_i$'s. It is easy to verify that \OnePlusBeta satisfies these three conditions.
\begin{lem} \label{lem:one_plus_beta_c123}
For any $\beta \in (0,1]$, the $(1+\beta)$ process satisfies condition $\mathcal{C}_1$ with $\delta=\frac{1}{4}$ and $\epsilon=\frac{\beta}{2}$, condition $\mathcal{C}_2$ with $C= 1+\beta$ and condition $\mathcal{C}_3$ with $C = 1 + \beta$.
\end{lem}
\begin{proof}
For any $i \in [n]$,
\[
p_i = (1-\beta) \cdot \frac{1}{n} + \beta \cdot \frac{2i-1}{n^2}.
\]
This shows that $p_i$ is increasing in $i \in [n]$, and thus also $\max_{i \in [n]} p_i \leq \frac{1+\beta}{n}$ (condition $\mathcal{C}_2$). Further, for $\delta=1/4$,
\[
\sum_{i = 1}^{\delta n} p_{i} \leq p_{\delta n} \cdot (\delta n) \leq (1-\beta) \cdot \delta + \beta \cdot \frac{\delta}{2} = \left(1 - \frac{\beta}{2}\right) \cdot \delta,
\]
proving that $\mathcal{C}_1$ holds with $\epsilon = \beta/2$. For the suffix sums,
\begin{align*}
\sum_{i = k}^n p_i
& \stackrel{(a)}{=} \frac{n - k + 1}{n} \cdot (1-\beta) + \frac{\beta}{n^2} \cdot (n^2 - (k-1)^2) \\
& = \frac{n - k + 1}{n} \cdot (1-\beta) + \frac{\beta}{n^2} \cdot (n - k + 1) \cdot (n + k - 1) \\
& = \frac{n - k + 1}{n} \cdot \left(1 + \frac{\beta}{n} \cdot (k - 1) \right) \\
& \stackrel{(b)}{\geq} \frac{n - k + 1}{n} \cdot (1 + \beta \cdot \delta ) \\
& \stackrel{(c)}{\geq} \frac{n - k + 1}{n} \cdot \left(1 + \eps \cdot \frac{\delta}{1-\delta} \right),
\end{align*}
using in $(a)$ that $\sum_{i = 1}^u (2i - 1) = u^2$, in $(b)$ that $k \geq \delta \cdot n + 1$ and in $(c)$ that $\delta = 1/4$ and $\eps = \beta/2$.
Condition $\mathcal{C}_3$ is verified as follows. As $p_i$ is increasing in $i \in [n]$,
\[
\left\vert p_i - \frac{1}{n}\right\vert
\leq \max\left\{ \frac{1}{n} - p_1, p_n - \frac{1}{n} \right\}
= \frac{\beta}{n} - \frac{\beta}{n^2}
\leq \frac{\beta}{n}. \qedhere
\]
\end{proof}
Note that in contrast to \TwoChoice which satisfies $\mathcal{C}_3$ for $C = 2 - \frac{1}{n}$, by choosing $\beta$ small enough we can make the probability vector arbitrarily close to uniform.
We also note that for any process $\mathcal{P}$ satisfying condition $\mathcal{C}_3$ for some $C > 1$, we can define a process $\mathcal{P}'$ satisfying condition $\mathcal{C}_3$ for $C' < C$ by mixing the probability vector of $\mathcal{P}$ with that of \OneChoice with probability $\eta = \frac{C' - 1}{C - 1}$.
For instance, the $\Quantile(1/2)$ process satisfies condition $\mathcal{C}_3$ for $C = 1 + 1/2$ (since$\min_{i\in [n]} p_i = \frac{1}{2n}$ and $\max_{i \in [n]} p_i = \frac{3}{2n}$). Therefore, mixing the $\Quantile(1/2)$ with \OneChoice with probability $\eta \in [0, 1]$, gives the following probability vector satisfying condition $\mathcal{C}_3$ for $C = 1 + \eta/2$,
\[
p_i = \begin{cases}
\frac{1}{n} \cdot (1 - \eta) + \frac{1}{2n} \cdot \eta = \frac{1}{n} - \frac{\eta}{2n} & \text{if } i \leq \frac{1}{2}n, \\
\frac{1}{n} \cdot (1 - \eta) + \frac{3}{2n} \cdot \eta = \frac{1}{n} + \frac{\eta}{2n} & \text{otherwise}.
\end{cases}
\]
\begin{obs}
The process obtained by mixing $\Quantile(1/2)$ with \OneChoice satisfies condition $\mathcal{C}_1$ with $\delta = 1/2$ and $\eps = \eta/2$, condition $\mathcal{C}_2$ with $C = 1 + \eta/2$ and condition $\mathcal{C}_3$ with $C = 1 + \eta/2$.
\end{obs}
\subsection{Batched Setting and Weights}\label{sec:batched_model}
As in \cite{LS22Batched}, we now extend the definitions of \cref{sec:basic_notation} and \cref{sec:processes} to \emph{weighted balls} into bins and later to the \emph{batched setting}. To this end, let
$w^t \geq 0$ be the weight of the $t$-th ball to be allocated for $t \geq 1$. By $W^{t}$ we denote the total weights of all balls allocated after the first $t \geq 0$ allocations, so $W^t := \sum_{i=1}^n x_i^{t} = \sum_{s=1}^t w^s$. The normalized loads are $\tilde{x}_i^{t} := x_i^t - \frac{W^t}{n}$, and with $y_i^t$ being again the decreasingly sorted, normalized load vector, we have $\Gap(t)=y_1^t$.
The weight of each ball will be drawn independently from a fixed distribution $\mathcal{W}$ over $[0,\infty)$. Following~\cite{PTW15}, we assume that the distribution $\mathcal{W}$ satisfies:
\begin{itemize}
\item $\ex{\mathcal{W}} = 1$.
\item $\ex{e^{\zeta \mathcal{W}} } < \infty $ for some constant $\zeta > 0$.
\end{itemize}
Specific examples of distributions satisfying above conditions (after scaling) are the geometric, exponential, binomial and Poisson distributions.
In the analysis we will be using the following property (see also \cite{PTW15}) and refer to these distributions as $\FiniteMgf(\zeta)$ (or $\FiniteMgf(S)$):
\begin{lem}[{\cite[Lemma 2.4]{LS22Batched}}] \label{lem:bounded_weight_moment}
There exists $S := S(\zeta) \geq \max(1, 1/\zeta)$, such that for any $\alpha \in (0, \min(\zeta/2, 1))$ and any $\kappa \in [-1,1]$,
\[
\Ex{e^{\alpha \cdot \kappa \cdot \mathcal{W}}} \leq 1 + \alpha \cdot \kappa + S \alpha^2 \cdot \kappa^2.
\]
\end{lem}
We will now describe the allocation of weighted balls into bins using a batch size of $ b \geq n$. For the sake of concreteness, let us first describe the batched model if the allocation is done using \TwoChoice. For a given batch size consisting of $b$ consecutive balls, each ball of the batch performs the following. First, it samples two bins $i_1$ and $i_2$ and compares the load the two bins had at the beginning of the batch (let us denote the bin which has less load by $i_{\min}$). Secondly, a weight is sampled from the distribution $W$. Then a weighted ball is added to bin $i_{\min}$. Recall that since the load information is only updated at the beginning of the batch, all allocations of the $b$ balls within the same batch can be performed in parallel.
In the following, we will use a more general framework, where the process of sampling (one or more) bins and then deciding where to allocate the ball to is described by a probability vector $p$ over the $n$ bins (\cref{sec:basic_notation} and \cref{sec:processes}). Also for the analysis, it will be convenient to focus on the normalized and sorted load vector $y$, which is why the definition below is based on $y$ rather than the actual load vector $x$.
\begin{samepage}
\begin{framed}
\vspace{-.45em} \noindent
\underline{Batched Allocation with Weights}\\
\textsf{Parameters:} Batch size $b \geq n$, probability vector $p$, weight distribution $\mathcal{W}$.
\\
\textsf{Iteration:} For each $t = 0 \cdot b, 1 \cdot b, 2 \cdot b, \ldots$:
\begin{enumerate}\itemsep0pt
\item Sample $b$ bins $i_1,i_2,\ldots,i_b$ from $[n]$ following $p$.
\item Sample $b$ weights $w^{t+1},w^{t+2},\ldots,w^{t+b}$ from $\mathcal{W}$.
\item Update for each bin $i \in [n]$,
\[
z_{i}^{t+b}=y_{i}^{t} + \sum_{j=1}^b w^{t+j} \cdot \mathbf{1}_{i_j=i} - \frac{1}{n} \cdot \sum_{j=1}^b w^{t+j}.
\]
\item Let $y^{t+b}$ be the vector $z^{t+b}$, sorted decreasingly.
\end{enumerate}
\end{framed}
\end{samepage}
We also look at the version of the processes that perform random tie-breaking between bins of the same load. For $b = 1$, this makes no observable difference to the process, but for multiple steps, this effectively averages out the probability over (possibly) multiple bins that have the same load. This would, for instance, correspond to \TwoChoice, randomly deciding between the two bins if they have the same load. In particular, if $p$ is the original probability vector, then the one with random tie-breaking is $\tilde{p}(y^t)$ (for $t$ being the beginning of the batch), where
\begin{equation} \label{eq:averaging_pi}
\tilde{p}_i(y^t) := \frac{1}{|\{ j \in [n] : y_j^t = y_i^t \}|} \cdot \sum_{j \in [n] : y_j^t = y_i^t} p_j, \quad \text{for }i \in [n].
\end{equation}
\begin{samepage}
\begin{framed}
\vspace{-.45em} \noindent
\underline{Batched Allocation with Weights and Random Tie-Breaking}\\
\textsf{Parameters:} Batch size $b \geq n$, probability vector $p$, weight distribution $\mathcal{W}$.
\\
\textsf{Iteration:} For each $t = 0 \cdot b, 1 \cdot b, 2 \cdot b, \ldots$:
\begin{enumerate}\itemsep0pt
\item Let $\tilde{p} := \tilde{p}(y^t)$ be the probability vector accounting for random tie-breaking.
\item Sample $b$ bins $i_1,i_2,\ldots,i_b$ from $[n]$ following $\tilde{p}$.
\item Sample $b$ weights $w^{t+1},w^{t+2},\ldots,w^{t+b}$ from $W$.
\item Update for each bin $i \in [n]$,
\[
z_{i}^{t+b}=y_{i}^{t} + \sum_{j=1}^b w^{t+j} \cdot \mathbf{1}_{i_j=i} - \frac{1}{n} \cdot \sum_{j=1}^b w^{t+j}.
\]
\item Let $y^{t+b}$ be the vector $z^{t+b}$, sorted decreasingly.
\end{enumerate}
\end{framed}
\end{samepage}
\section{Warm-up: \texorpdfstring{$\Oh(\sqrt{b/n} \cdot \log n)$}{O(sqrt(b/n) log n} gap} \label{sec:weak_gap}
In this section, we will refine the analysis of \cite[Section 4]{LS22Batched} to prove an $\Oh(\sqrt{(b/n)} \cdot \log n)$ bound on the gap for a family of processes. This will be used as a starting point for the analysis in \cref{sec:strong_gap}. The main theorem that we prove is the following.
\begin{thm} \label{thm:herd_weak_gap_bound}
Consider any sequential allocation process with probability allocation vector $p^t$ satisfying conditions $\mathcal{C}_1$ for constant $\delta \in (0, 1)$ and (not necessarily constant) $\eps \in (0,1)$ as well as condition $\mathcal{C}_3$ for some $C > 1$, at every step $t \geq 0$. Further, consider the \Weighted \Batched setting with weights from a $\FiniteMgf(S)$ distribution with $S \geq 1$ and a batch size $b \geq \frac{2CS}{(C-1)^2} \cdot n$.
Then, there exists a constant $k := k(\delta) > 0$, such that for any step $m \geq 0$ being a multiple of $b$,
\[
\Pro{\max_{i \in [n]} |y_i^m| \leq k \cdot \frac{(C-1)^2}{\epsilon} \cdot \frac{b}{n} \cdot \log n } \geq 1 - n^{-2}.
\]
\end{thm}
Recall that by \cref{lem:one_plus_beta_c123} the \OnePlusBeta process satisfies condition $\mathcal{C}_1$ with $\eps = \frac{\beta}{4}$ and $\delta = \frac{1}{4}$, and conditions $\mathcal{C}_2$ and $\mathcal{C}_3$ with $C = 1 + \beta$.
In particular, by choosing $\beta = \Theta\big(\sqrt{n/b}\big)$ we get a process that is asymptotically better than \TwoChoice and which is within just a $\sqrt{\log n}$ multiplicative factor from the optimal bound for the unweighted case proven in \cref{sec:lower_bounds}.
\begin{cor}\label{cor:weak_bound}
Let $b \geq n \log n$ and consider the \Weighted \Batched setting with weights from a $\FiniteMgf(S)$ distribution with $S \geq 1$. Then, there exists a constant $k > 0$ such that for the \OnePlusBeta process with $\beta = \sqrt{4S \cdot \frac{n}{b}}$ and for any step $m \geq 0$ being a multiple of $b$,
\[
\Pro{\Gap(m) \leq k \cdot \sqrt{\frac{Sb}{n}} \cdot \log n} \geq 1 - n^{-2}.
\]
\end{cor}
The analysis is based on the \textit{hyperbolic cosine potential} which is defined for smoothing parameter $\alpha > 0$ as
\begin{align}
\Gamma^t := \Gamma^t(\alpha) := \Phi^t + \Psi^t := \sum_{i = 1}^n e^{\alpha y_i^t} + \sum_{i = 1}^n e^{-\alpha y_i^t}. \label{eq:hyperbolic}
\end{align}
We also decompose $\Gamma^t$ by defining
\[
\Gamma_i^t := \Phi_i^t + \Psi_i^t = e^{\alpha y_i^t} + e^{-\alpha y_i^t}, \quad \text{for any bin $i \in [n]$}.
\]
Further, we use the following shorthands to denote the changes in the potentials over one step $\Delta\Phi_i^{t+1} := \Phi_i^{t+1} - \Phi_i^t$, $\Delta\Psi_i^{t+1} := \Psi_i^{t+1} - \Psi_i^{t}$ and $\Delta\Gamma_i^{t+1} := \Gamma_i^{t+1} - \Gamma_i^{t}$.
We will make use of the following drift theorem shown in \cite{LS22Batched}. Note that in the following rounds could consist of multiple single-step allocations.
\newcommand{\MainHyperbolicCosineExpectation}{
Consider any allocation process $\mathcal{P}$ and a probability vector $p^t$ satisfying condition $\mathcal{C}_1$ for some constant $\delta \in (0, 1)$ and some $\eps \in (0, 1)$ at every round $t \geq 0$. Further assume that there exist $K > 0$, $\alpha \in \big(0, \min\big\{1, \frac{\eps\delta}{8K}\big\} \big]$ and $\kappa > 0$, such that for any round $t \geq 0$, process $\mathcal{P}$ satisfies for potentials $\Phi := \Phi(\alpha)$ and $\Psi := \Psi(\alpha)$ that,
\[
\sum_{i = 1}^n \Ex{\left. \Delta\Phi_i^{t+1} \,\right|\, \mathfrak{F}^t} \leq \sum_{i = 1}^n \Phi_i^t \cdot \left(\left(p_i^t - \frac{1}{n}\right) \cdot \kappa \cdot \alpha + K \cdot \kappa \cdot \frac{\alpha^2}{n}\right),
\]
and
\[
\sum_{i = 1}^n \Ex{\left.\Delta\Psi_i^{t+1} \,\right|\, \mathfrak{F}^t} \leq \sum_{i = 1}^n \Psi_i^t \cdot \left(\left(\frac{1}{n} - p_i^t\right) \cdot \kappa \cdot \alpha + K \cdot \kappa \cdot \frac{\alpha^2}{n}\right).
\]
Then, there exists a constant $c := c(\delta) > 0$, such that for $\Gamma := \Gamma(\alpha)$ and any round $t \geq 0$,
\[
\Ex{\left. \Delta\Gamma^{t+1} \,\right|\, \mathfrak{F}^t} \leq - \Gamma^t \cdot \kappa \cdot \frac{\alpha\eps\delta}{8n} + \kappa \cdot c\alpha\eps,
\]
and
\[
\Ex{\Gamma^t} \leq \frac{8c}{\delta} \cdot n.
\]}
\begin{thm}[{cf.~\cite[Theorem 3.1]{LS22Batched}}] \label{thm:hyperbolic_cosine_expectation}
\MainHyperbolicCosineExpectation
\end{thm}
Now we will show that any process satisfying condition $\mathcal{C}_3$, also satisfies the preconditions of \cref{thm:hyperbolic_cosine_expectation} for the expected change of the potential functions $\Phi$ and $\Psi$ over one batch.
\begin{lem} \label{lem:herd_batching_pot_changes}
Consider any sequential allocation process with probability allocation vector $p^t$ satisfying condition $\mathcal{C}_3$ for some $C \in (1, 1.9)$ at every step $t \geq 0$. Further, consider the \Weighted \Batched setting with weights from a $\FiniteMgf(S)$ distribution with constant $S \geq 1$ and a batch size $b \geq \frac{2CS}{(C-1)^2} \cdot n$. Then for $\Phi := \Phi(\alpha)$ and $\Psi := \Psi(\alpha)$ with any smoothing parameter $0 <\alpha \leq \frac{n}{2(C-1) \cdot b}$ and any step $t \geq 0$ being a multiple of $b$,
\[
\Ex{\left. \Phi^{t+b} \,\right|\, \mathfrak{F}^t} \leq \sum_{i = 1}^n \Phi_i^t \cdot \left(1 + \Big(p_i^t -\frac{1}{n}\Big) \cdot b \cdot \alpha + \frac{5(C-1)^2b}{n} \cdot b \cdot \frac{\alpha^2}{n} \right),
\]
and
\[
\Ex{\left. \Psi^{t+b} \,\right|\, \mathfrak{F}^t} \leq \sum_{i = 1}^n \Psi_i^t \cdot \left(1 + \Big(\frac{1}{n} - p_i^t \Big) \cdot b \cdot \alpha + \frac{5(C-1)^2b}{n} \cdot b \cdot \frac{\alpha^2}{n} \right).
\]
\end{lem}
The proof proceeds in a similar manner to \cite[Lemma 4.1]{LS22Batched}, but we bound the terms in \cref{eq:u_definition} and \cref{eq:tile_u_definition} more tightly using condition $\mathcal{C}_3$.
\begin{proof}
Consider an arbitrary step $t \geq 0$ being a multiple of $b$ and for convenience let $p = p^t$. First note that the given assumptions $\alpha \leq \frac{n}{2(C-1) \cdot b}$ and $b \geq \frac{2CS}{(C-1)^2} \cdot n$ imply that
\begin{align} \label{eq:alpha_second_bound}
\alpha \leq \frac{n}{2(C-1) \cdot b} \leq \frac{C-1}{4CS}.
\end{align}
Consider an arbitrary bin $i \in [n]$. Let $Z \in \{0,1 \}^b$ be the indicator vector, where $Z_j$ indicates whether the $j$-th ball was allocated to bin $i$. The expected change for the overload potential $\Phi_i^t$, is given by
\begin{align}
\Ex{\left. \Phi_i^{t+b} \,\right|\, \mathfrak{F}^t}
& = \Phi_i^t \cdot \sum_{z \in \{0,1 \}^b} \Pro{Z = z} \cdot \Ex{\left. e^{\alpha \sum_{j = 1}^b \left(z_j w^{t+j} - \frac{w^{t+j}}{n} \right)} \, \right\vert \, \mathfrak{F}^t, Z = z} \notag .
\end{align}
In the following, let us upper bound the factor of $\Phi_i^t$:
\begin{align}
& \sum_{z \in \{0,1 \}^b} \Pro{Z = z} \cdot \Ex{\left. e^{\alpha \sum_{j = 1}^b \left(z_j w^{t+j} - \frac{w^{t+j}}{n}\right)} \, \right\vert \, \mathfrak{F}^t, Z = z} \notag \\
& \qquad \stackrel{(a)}{=} \!\!\! \sum_{z \in \{0,1 \}^b} \prod_{j = 1}^b (p_i)^{z_j} (1 - p_i)^{1 - z_j} (\ex{e^{\alpha W (1 - \frac{1}{n})}})^{z_j} (\ex{e^{-\alpha W/n}})^{1- z_j} \notag \\
& \qquad \stackrel{(b)}{\leq}\!\!\! \sum_{z \in \{0,1 \}^b} \prod_{j = 1}^b \left(p_i \cdot \left(1 + \alpha \cdot \left(1 - \frac{1}{n}\right) + S\alpha^2 \right)\right)^{z_j} %
\cdot \left((1 - p_i) \cdot \left(1 - \frac{\alpha}{n} + \frac{S\alpha^2}{n^2}\right) \right)^{1 - z_j} \notag \\
& \qquad \stackrel{(c)}{=} \left( p_i \cdot \left(1 + \alpha \cdot \left(1 - \frac{1}{n}\right) + S\alpha^2 \right) + (1 - p_i) \cdot \left(1 - \frac{\alpha}{n} + \frac{S\alpha^2}{n^2}\right) \right)^b \notag \\
& \qquad = \left( 1 + \alpha \cdot \left(p_i - \frac{1}{n}\right) + p_i \cdot S\alpha^2 + (1-p_i) \cdot \frac{S\alpha^2}{n^2} \right)^b \notag \\
& \qquad \stackrel{(d)}{\leq} \left( 1 + \alpha \cdot \left(p_i - \frac{1}{n}\right) + 2 \cdot p_i \cdot S\alpha^2 \right)^b, \label{eq:phi_batched_i}
\end{align}
using in $(a)$ that the weights are independent given $\mathfrak{F}^t$, in $(b)$ \cref{lem:bounded_weight_moment} twice with $\kappa = 1 - \frac{1}{n}$ and with $\kappa = -\frac{1}{n}$ respectively (and that $(1 - 1/n)^2 \leq 1$), in $(c)$ the binomial theorem and in $(d)$ that $p_i \geq \frac{1}{n^2}$ by condition $\mathcal{C}_3$ for $C \in (1, 1.9)$.
Let us define
\begin{align} \label{eq:u_definition}
u := \left(p_i - \frac{1}{n}\right) \cdot \alpha + 2 \cdot p_i \cdot S\alpha^2.
\end{align}
We will now show that $|u \cdot b| \leq 2(C-1) \cdot b \cdot \frac{\alpha}{n} \leq 1$, which holds indeed since
\begin{align}
|u \cdot b| &= \left\lvert \left(p_i -\frac{1}{n}\right) \cdot b \cdot \alpha + 2 \cdot p_i \cdot b \cdot S\alpha^2 \right\vert \notag \\
& \leq \left\lvert \left(p_i -\frac{1}{n}\right) \cdot b \cdot \alpha\right\vert + 2 \cdot p_i \cdot b \cdot S\alpha^2 \notag \\
& \stackrel{(a)}{\leq} \frac{C-1}{n} \cdot b \cdot \alpha + 2 \cdot \frac{C}{n} \cdot b \cdot S \alpha^2 \notag \\
& = ( C-1 + 2CS\alpha) \cdot b \cdot \frac{\alpha}{n} \notag \\
& \stackrel{(b)}{\leq} 2(C-1) \cdot b \cdot \frac{\alpha}{n} \label{eq:yb_bounded_1} \\
& \stackrel{(c)}{\leq} 1, \label{eq:yb_bounded_2}
\end{align}
using in $(a)$ that $\big|p_i - \frac{1}{n}\big| \leq \frac{C-1}{n}$ by condition $\mathcal{C}_3$, in $(b)$ that $\alpha \leq \frac{C-1}{2CS}$ and in $(c)$ that $\alpha \leq \frac{n}{2(C-1) \cdot b}$.
Then,
\begin{align*}
\Ex{\left. \Phi_i^{t+b} \,\right|\, \mathfrak{F}^t}
& \stackrel{(a)}{\leq} \Phi_i^t \cdot e^{u \cdot b} \\
& \stackrel{(b)}{\leq} \Phi_i^t \cdot \left( 1 + u \cdot b + (u \cdot b)^2 \right) \\
& \!\! \stackrel{(\ref{eq:u_definition})}{=} \Phi_i^t \cdot \left( 1 + \left(p_i - \frac{1}{n}\right) \cdot b \cdot \alpha + 2 \cdot p_i \cdot b \cdot S\alpha^2 + (u \cdot b)^2 \right) \\
& \!\! \stackrel{(\ref{eq:yb_bounded_1})}{\leq} \Phi_i^t \cdot \left(1 + \left(p_i -\frac{1}{n}\right) \cdot b \cdot \alpha + 2 \cdot p_i \cdot b \cdot S\alpha^2 + \left(2(C-1) \cdot b \cdot \frac{\alpha}{n} \right)^2 \right) \\
& \stackrel{(c)}{\leq} \Phi_i^t \cdot \left(1 + \left(p_i -\frac{1}{n}\right) \cdot b \cdot \alpha + \frac{5(C-1)^2b}{n} \cdot b \cdot \frac{\alpha^2}{n} \right),
\end{align*}
using in $(a)$ that $1 + v \leq e^v$ for any $v$, in $(b)$ that $e^v \leq 1 + v + v^2$ for $v \leq 1.75$ and \cref{eq:yb_bounded_2}, and in $(c)$ that $\frac{(C-1)^2b}{n} \cdot b \cdot \frac{\alpha^2}{n} \geq 2 \cdot \frac{C}{n} \cdot b \cdot S \alpha^2 \geq 2 \cdot p_i \cdot b \cdot S \alpha^2$, since $b \geq \frac{2CS}{(C-1)^2} \cdot n$.
Similarly, for the underloaded potential $\Psi^t$, for any bin $i \in [n]$,
\begin{align*}
\Ex{\left. \Psi_i^{t+b} \,\right|\, \mathfrak{F}^t} = \Psi_i^t \cdot \sum_{z \in \{0,1 \}^b} \Pro{Z = z} \cdot \Ex{\left. e^{-\alpha \sum_{j = 1}^b \left(z_j w^{t+j} - \frac{w^{t+j}}{n} \right)} \, \right\vert \, \mathfrak{F}^t, Z = z}.
\end{align*}
As before, we will upper bound the factor of $\Psi_i^t$:
\begin{align}
& \sum_{z \in \{0,1 \}^b} \Pro{Z = z} \cdot \Ex{\left. e^{-\alpha \sum_{j = 1}^b \left(z_j w^{t+j} - \frac{w^{t+j}}{n} \right)} \, \right\vert \, \mathfrak{F}^t, Z = z} \notag \\
& \qquad \stackrel{(a)}{=} \!\!\! \sum_{z \in \{0,1 \}^b} \prod_{j = 1}^b (p_i)^{z_j} (1 - p_i)^{1 - z_j} (\ex{e^{-\alpha W \cdot (1 - \frac{1}{n})}})^{z_j} (\ex{e^{\alpha W/n}})^{1- z_j} \notag \\
& \qquad \stackrel{(b)}{\leq} \!\!\! \sum_{z \in \{0,1 \}^b} \prod_{j = 1}^b \left(p_i \cdot \left(1 - \alpha \cdot \left(1 - \frac{1}{n}\right) + S\alpha^2 \right)\right)^{z_j} \notag %
\cdot \left((1 - p_i) \cdot \left(1 + \frac{\alpha}{n} + \frac{S\alpha^2}{n^2}\right) \right)^{1 - z_j} \notag \\
& \qquad \stackrel{(c)}{=} \left( p_i \cdot \left(1 - \alpha \cdot \left(1 - \frac{1}{n}\right) + S\alpha^2 \right) + (1 - p_i) \cdot \left(1 + \frac{\alpha}{n} + \frac{S\alpha^2}{n^2}\right) \right)^b \notag \\
& \qquad = \left( 1 + \left(\frac{1}{n}- p_i\right) \cdot \alpha + p_i \cdot S\alpha^2 + (1-p_i) \cdot \frac{S\alpha^2}{n^2} \right)^b \notag \\
& \qquad \stackrel{(d)}{\leq} \left( 1 + \left( \frac{1}{n} - p_i\right) \cdot \alpha + 2 \cdot p_i \cdot S\alpha^2 \right)^b \label{eq:psi_batched_i},
\end{align}
using in $(a)$ that the weights $W$ are independent given $\mathfrak{F}^t$, in $(b)$ \cref{lem:bounded_weight_moment} twice with $\kappa = -\big(1 - \frac{1}{n}\big)$ and with $\kappa = \frac{1}{n}$ respectively, in $(c)$ the binomial theorem and in $(d)$ that $p_i \geq \frac{1}{n^2}$ by condition $\mathcal{C}_3$ for $C \in (1, 1.9)$.
Let us define
\begin{align} \label{eq:tile_u_definition}
\tilde{u} := \left(\frac{1}{n} - p_i\right) \cdot \alpha + 2 \cdot p_i \cdot S\alpha^2.
\end{align}
Similarly, to \cref{eq:yb_bounded_2}, we get that
\begin{align}
|\tilde{u} b|
& \leq \left\lvert \left(\frac{1}{n} - p_i\right) \cdot b \cdot \alpha\right\vert + 2 \cdot p_i \cdot b \cdot S\alpha^2 \leq 2(C-1) \cdot b \cdot \frac{\alpha}{n} \label{eq:tilde_u_b_1} \\
& \leq 1. \label{eq:tilde_u_b_2}
\end{align}
So,
\begin{align*}
\Ex{\left. \Psi_i^{t+b} \,\right|\, \mathfrak{F}^t}
& \stackrel{(a)}{\leq} \Psi_i^t \cdot e^{\tilde{u} b} \\
& \stackrel{(b)}{\leq} \Psi_i^t \cdot \left( 1 + \tilde{u} b + (\tilde{u} b)^2 \right) \\
& \!\!\stackrel{(\ref{eq:tile_u_definition})}{=} \Psi_i^t \cdot \left(1 + \left(\frac{1}{n} - p_i\right) \cdot b \cdot \alpha + 2 \cdot p_i \cdot S \alpha^2 \cdot b + (\tilde{u} \cdot b)^2 \right) \\
& \!\!\stackrel{(\ref{eq:tilde_u_b_1})}{\leq} \Psi_i^t \cdot \left(1 + \left(\frac{1}{n} - p_i\right) \cdot b \cdot \alpha + 2 \cdot p_i \cdot b \cdot \alpha^2 + \left(2(C-1) \cdot b \cdot \frac{\alpha}{n} \right)^2 \right) \\
& \stackrel{(c)}{\leq} \Psi_i^t \cdot \left(1 + \left(\frac{1}{n} - p_i\right) \cdot b \cdot \alpha + \frac{5 (C-1)^2 b}{n} \cdot b \cdot \frac{\alpha^2}{n} \right),
\end{align*}
using in $(a)$ that $1 + v \leq e^v$ for any $v$, in $(b)$ that $e^v \leq 1 + v + v^2$ for $v \leq 1.75$ and \cref{eq:tilde_u_b_2}, and in $(c)$ that $\frac{(C-1)^2b}{n} \cdot b \cdot \frac{\alpha^2}{n} \geq 2 \cdot \frac{C}{n} \cdot b \cdot S \alpha^2 \geq 2 \cdot p_i \cdot b \cdot S \alpha^2$, since $b \geq \frac{2CS}{(C-1)^2} \cdot n$.
\end{proof}
Having verified the preconditions for \cref{thm:hyperbolic_cosine_expectation}, we are now ready to prove the bound on the gap for this family of processes.
\begin{rem}
The same upper bound in \cref{thm:herd_weak_gap_bound} also holds for processes with tie breaks. The reason for this is that $(i)$ averaging probabilities in \cref{eq:averaging_pi} can only reduce the maximum entry (and increase the minimum) in the allocation vector $\tilde{p}^t$, i.e. $\max_{i \in [n]} \tilde{p}_i^t(x^t) \leq \max_{i \in [n]} p_i$, so it still satisfies $\mathcal{C}_3$ and $(ii)$ moving probability between bins $i, j$ with $x_i^t = x_j^t$ (and thus $\Phi_i^t = \Phi_j^t$ and $\Psi_i^t = \Psi_j^t$), implies that the aggregate upper bounds in \cref{lem:herd_batching_pot_changes} remain the same.
\end{rem}
\begin{proof}[Proof of \cref{thm:herd_weak_gap_bound}]
Consider the \Batched setting at steps that are a multiple of $b$ and rounds consisting of $b$ allocations. By \cref{lem:herd_batching_pot_changes}, the preconditions of \cref{thm:hyperbolic_cosine_expectation} are satisfied for $K := 5 \cdot (C-1)^2 \cdot \frac{b}{n}$, $\kappa := b$ and $\alpha := \frac{\eps\delta}{8K} = \frac{\eps\delta}{40 \cdot (C-1)^2 \cdot \frac{b}{n}} \leq \frac{n}{2(C-1) \cdot b}$, since $\eps \leq C - 1$ and also $\alpha \leq 1$ since $b \geq \frac{2CS}{(C-1)^2} \cdot n$, $C > 1$ and $S \geq 1$. Hence, there exists a constant $c := c(\delta) > 0$ such that for any step $m \geq 0$ which is a multiple of $b$,
\[
\Ex{\Gamma^m} \leq \frac{8c}{\delta} \cdot n.
\]
Therefore, by Markov's inequality
\[
\Pro{\Gamma^m \leq \frac{8c}{\delta} \cdot n^3} \geq 1 - n^{-2}.
\]
To prove the claim, note that when $\big\{ \Gamma^m \leq \frac{8c}{\delta} \cdot n^3 \big\}$ holds, then also,
\[
\max_{i \in [n]} |y_i^m| \leq \frac{1}{\alpha} \cdot \left( \log \left( \frac{8c}{\delta}\right) + 3 \cdot \log n \right) \leq 4 \cdot \frac{8 \cdot 5 \cdot (C-1)^2}{\eps \delta} \cdot \frac{b}{n} \cdot \log n. \qedhere
\]
\end{proof}
\section{Tight Bound: \texorpdfstring{$\Oh(\sqrt{(b/n) \cdot \log n})$}{O(sqrt((b/n) log n))} gap} \label{sec:strong_gap}
In this section, we will prove the stronger $\Oh\big(\sqrt{(b/n) \log n}\big)$ bound on the gap for a family of processes in the \Weighted \Batched setting (with $b \in [2n \log n, n^3]$). More specifically these processes are a subset of the ones analyzed in \cref{sec:weak_gap} and include the \OnePlusBeta process with $\beta = \sqrt{(n/b) \log n}$, as well as $\Quantile(1/2)$ mixed with \OneChoice. As we will show in \cref{sec:lower_bounds}, these processes achieve the asymptotically optimal bound.
\newcommand{\BatchingStrongGapBound}{
Consider the \Weighted \Batched setting with any $b \in [2n \log n, n^3]$ and weights from a $\FiniteMgf(S)$ distribution with constant $S \geq 1$. Further let $\eps = \sqrt{(n/b) \log n}$.
Consider any process with probability allocation vector $p^t$ satisfying condition $\mathcal{C}_1$ for constant $\delta \in (0, 1)$ and $\eps$ as well as condition $\mathcal{C}_3$ for $C = 1 + \eps$, at every step $t \geq 0$.
Then, there exists a constant $\kappa := \kappa(\delta, S) > 0$, such that for any step $m \geq 0$ being a multiple of $b$,
\[
\Pro{ \max_{i \in [n]} y_i^m \leq \kappa \cdot \sqrt{\frac{b}{n} \cdot \log n} } \geq 1 - n^{-2}.
\]
}
\begin{thm}\label{thm:batching_strong_gap_bound}
\BatchingStrongGapBound
\end{thm}
There are two key steps in the proof:
\textbf{Step 1:} Similarly to the analysis in \cite{LS22Queries}, we will use two instances of the hyperbolic cosine potential, in order to show that it is concentrated at $\Oh(n)$. More specifically, we will be using $\Gamma_1 := \Gamma_1(\alpha_1)$ (defined in \cref{eq:hyperbolic}) with the smoothing parameter $\alpha_1 := \frac{\delta}{40S} \cdot \sqrt{n/(b \log n)}$ and $\Gamma_2 := \Gamma_2(\alpha_2)$ with $\alpha_2 := \frac{\alpha_1}{8 \cdot 30}$, i.e., with a smoothing parameter which is a large constant factor smaller than $\alpha_1$. So, in particular $\Gamma_2^t \leq \Gamma_1^t$ at any step $t \geq 0$.
In the following lemma, proven in \cref{sec:batching_gamma_linear_whp}, we show that \Whp~$\Gamma_2 = \Oh(n)$ for $\log^3 n$ batches.
\newcommand{\BatchingGammaLinearWhp}{
Consider any process satisfying the conditions in \cref{thm:batching_strong_gap_bound}. Let $\tilde{c} := 2 \cdot \frac{8c}{\delta}$ where $c := c(\delta) > 0$ is the constant from \cref{thm:hyperbolic_cosine_expectation}. Then, for any step $t \geq 0$ being a multiple of $b$,
\[
\Pro{ \bigcap_{j \in [0, \log^3 n]} \left\lbrace \Gamma_2^{t + j \cdot b} \leq \tilde{c} \cdot n \right\rbrace } \geq 1 - n^{-3}.
\]
}
\begin{lem} \label{lem:batching_gamma_linear_whp}
\BatchingGammaLinearWhp
\end{lem}
The proof follows the usual interplay between the two hyperbolic cosine potentials, in that conditioning on $\Gamma_1^t = \poly(n)$ (which follows \Whp~by the analysis in \cref{sec:weak_gap}) implies that $\big|\Delta\Gamma_2^{t+1}\big| \leq n^{1/4} \cdot \sqrt{(n/b) \cdot \log n}$ (\cref{lem:batched_gamma_1_poly_implies}~$(ii)$). This in turn allows us to apply a bounded difference inequality to prove concentration for $\Gamma_2$. In contrast to \cite{LS22Queries} and \cite{LS22Noise}, here we need a slightly different concentration inequality \cref{lem:kutlin_3_3} (also used in \cite{LS22Batched}), as in a single batch the load of a bin may change by a large amount (with small probability).
The complete proof is given in \cref{sec:batching_gamma_linear_whp}.
\textbf{Step 2:} Consider an arbitrary step $s = t + j \cdot b$ where $\{ \Gamma_2^{s} \leq \tilde{c} \cdot n \}$ holds. Then, the number of bins $i$ with load $y_i^s$ at least $z := \frac{1}{\alpha_2} \cdot \log(\tilde{c} / \delta) = \Theta(\sqrt{(b/n) \cdot \log n})$ is at most $\tilde{c}n \cdot e^{-\alpha_2 z} = \delta n$. With this in mind, we define the following potential function for any step $t \geq 0$, which only takes into account bins that are overloaded by at least $z$ balls:
\[
\Lambda^t := \Lambda^t(\lambda, z) := \sum_{i : y_i^t \geq z} \Lambda_i^t := \sum_{i : y_i^t \geq z} e^{\lambda \cdot (y_i^t - z)},
\]
where $\lambda := \frac{\eps}{4CS} = \Theta(\sqrt{(n/b) \cdot \log n})$ and we define $\Lambda_i^t = 0$ for the rest of the bins $i$. This means that when $\{ \Gamma_2^{s} \leq \tilde{c} \cdot n \}$ holds, the probability of allocating to one of these bins is $p_i^{s} \leq \frac{1-\eps}{n}$, because of the condition $\mathcal{C}_1$. Hence, the potential drops in expectation over one batch (\cref{lem:lambda_drops}) and this means that \Whp~$\Lambda^m = \poly(n)$, which implies that $\Gap(m) = \Oh(z + \lambda^{-1} \cdot \log n) = \Oh(\sqrt{(b/n) \cdot \log n})$ gap.
\subsection{Step 1: Concentration of the \texorpdfstring{$\Gamma$}{Gamma} Potential} \label{sec:batching_gamma_linear_whp}
Recall that in \cref{thm:batching_strong_gap_bound}, we considered the \Weighted \Batched setting with any $b \in [2n \log n, n^3]$ and weights sampled independently from a $\FiniteMgf(S)$ distribution with constant $S \geq 1$, for any allocation process with probability allocation vector $p^t$ satisfying condition $\mathcal{C}_1$ for constant $\delta \in (0, 1)$ and $\eps \in (0,1)$ as well as condition $\mathcal{C}_3$ for some $C > 1$, at every step $t \geq 0$.
{\renewcommand{\thelem}{\ref{lem:batching_gamma_linear_whp}}
\begin{lem}[Restated, page~\pageref{lem:batching_gamma_linear_whp}]
\BatchingGammaLinearWhp
\end{lem} }
\addtocounter{lem}{-1}
The proof of this lemma is similar to the proofs in \cite[Section 5]{LS22Batched} and \cite[Section 5]{LS22Queries}, in that we use the interplay between two instances of the hyperbolic cosine potential $\Gamma_1 := \Gamma_1 (\alpha_1)$ and $\Gamma_2 := \Gamma_2(\alpha_2)$ with smoothing parameter $\alpha_2$ being a large constant factor smaller than $\alpha_1$. More specifically, we will be working with $\alpha_1 := \frac{\delta}{40S} \cdot \sqrt{n/(b \log n)}$ and $\alpha_2 := \frac{\alpha_1}{8 \cdot 30}$.
The rest of this section is organized as follows. In \cref{sec:step_1_preliminaries}, we establish some basic properties for the potentials $\Gamma_1$ and $\Gamma_2$ and in \cref{sec:gamma_linear_whp_complete} we use these to show that \Whp~$\Gamma_2^t = \Oh(n)$ for at least $\log^3 n$ batches, and complete the proof of \cref{lem:batching_gamma_linear_whp}.
\subsubsection{Preliminaries} \label{sec:step_1_preliminaries}
We define the following event, for any step $t \geq 0$\[
\mathcal{H}^t := \left\lbrace w^t \leq \frac{15}{\zeta} \cdot \log n \right\rbrace,
\]
which means that the weight of the ball sampled in step $t$ is $\Oh(\log n)$ (since by assumption $\zeta > 0$ is constant). By a simple Chernoff bound and a union bound, we can deduce that this holds for a $\poly(n)$-long interval.
\begin{lem}[{cf.~\cite[Lemma 5.4]{LS22Batched}}] \label{lem:many_h_i}
Consider any $\FiniteMgf(\zeta)$ distribution $\mathcal{W}$ with constant $\zeta > 0$. Then, for any steps $t_0 \geq 0$ and $t_1 \in [t_0, t_0 + n^3 \log^3 n]$, we have that
\[
\Pro{\bigcap_{s \in [t_0, t_1]} \mathcal{H}^s} \geq 1 - n^{-10}
\]
\end{lem}
We will now show that when $\Gamma_1^t = \poly(n)$ and $\mathcal{H}^t$ holds, then $\Delta\Gamma_2^{t+1}$ is small.
\begin{lem} \label{lem:batched_gamma_1_poly_implies}
Consider any process satisfying the conditions in \cref{lem:batching_gamma_linear_whp} and any step $t \geq 0$, such that $\Gamma_1^{t} \leq 2\tilde{c} \cdot n^{26}$ and $\mathcal{H}^t$ holds. Then, we have that
\begin{align*}
(i) & \qquad \Gamma_2^t \leq n^{5/4}, \\
(ii) & \qquad |\Gamma_2^{t+1} - \Gamma_2^{t} | \leq n^{1/4} \cdot \sqrt{\frac{n}{b} \cdot \log n}.
\end{align*}
Further, let $\widehat{x}^t$ be the load vector obtained by moving the $t$-th ball of the load vector $x^t$ to some other bin, then
\begin{align*}
(iii) & \qquad \Gamma_1^t(\widehat{x}^t) \leq 2 \cdot \Gamma_1^t(x^t).
\end{align*}
\end{lem}
\begin{proof}
Recall that $\alpha_1 := \frac{\delta}{40S} \cdot \sqrt{n/(b \log n)}$ and $\alpha_2 := \frac{\alpha_1}{8 \cdot 30}$. Consider any step $t \geq 0$, such that $\Gamma_1^{t} \leq 2\tilde{c} \cdot n^{26}$ and $\mathcal{H}^t$ holds. We start by bounding the load of any bin. For any bin $i \in [n]$,
\begin{align} \label{eq:batching_gamma2_load_bound}
\Gamma_1^{t} \leq 2\tilde{c} \cdot n^{26}
& \Rightarrow e^{\alpha_1\cdot y_i^{t}} + e^{-\alpha_1 \cdot y_i^{t}} \leq \tilde{c} \cdot n^{26} \notag \\
& \Rightarrow
y_i^t \leq \frac{27}{\alpha_1} \log n \, \wedge \,
-y_i^t \leq \frac{27}{\alpha_1} \log n,
\end{align}
where in the second implication we used $\log (2\tilde{c}) + \frac{26}{\alpha_1} \log n \leq \frac{27}{\alpha_1} \log n$, for sufficiently large $n$.
\textit{First statement.} Using \cref{eq:batching_gamma2_load_bound}, we can bound the contribution of any bin $i \in [n]$ to $\Gamma_2^t$ as follows,
\begin{equation} \label{eq:gamma_i_bound}
\Gamma_{2i}^t = e^{\alpha_2 y_i^t} + e^{-\alpha_2 y_i^t} \leq 2 \cdot e^{\alpha_2 \cdot \frac{27}{\alpha_1} \log n} \leq 2 \cdot n^{1/8},
\end{equation}
using that $\alpha_2 := \frac{\alpha_1}{8 \cdot 30}$. By aggregating, we get the first claim $\Gamma_1^t = \sum_{i = 1}^n \Gamma_{1i}^t \leq 2 \cdot n \cdot n^{1/8} \leq n^{5/4}$.
\textit{Second statement}. Consider the change for the bin $j \in [n]$ where the ball was allocated.
Since $\alpha_2 < \frac{1}{40\cdot S \cdot \log n}$ and $S > \frac{1}{\zeta}$, we have $\alpha_2 \cdot \frac{15}{\zeta} \cdot \log n \leq 1$ and so by a Taylor estimate, $e^{\alpha_2 \cdot \frac{15}{\zeta} \cdot \log n} \leq 1 + 2 \cdot \alpha_2 \cdot \frac{15}{\zeta} \cdot \log n$. If $j \in [n]$ is an overloaded bin ($y_j^t \geq 0$), then
\begin{align*}
\left|\Delta\Gamma_{2j}^{t+1} \right| & \leq \Gamma_{2j}^t \cdot e^{\alpha_2 \cdot \frac{15}{\zeta} \cdot \log n}- \Gamma_{2j}^t \leq \Gamma_{2j}^t \cdot \Big( 1 + \alpha_2 \cdot \frac{30}{\zeta} \cdot \log n \Big)- \Gamma_{2j}^t \\
& = \Gamma_{2j}^t \cdot \alpha_2 \cdot \frac{30}{\zeta} \cdot \log n \leq n^{1/8} \cdot \sqrt{\frac{n}{b} \cdot \log n},
\end{align*}
using \cref{eq:gamma_i_bound}, $\alpha_2 \leq \frac{\delta}{40S} \cdot \sqrt{\frac{n}{b\log n}}$ and $S \geq 1/\lambda$.
Similarly, if $j$ is underloaded ($y_j^t < 0$), then
\begin{align*}
\left|\Delta\Gamma_{2j}^{t+1}\right| & \leq \Gamma_{2j}^t - \Gamma_{2j}^t \cdot e^{-\alpha_2 \cdot \frac{15}{\zeta} \cdot \log n} \leq \Gamma_{2j}^t - \Gamma_{2j}^t \cdot \Big( 1 - \alpha_2 \cdot \frac{30}{\zeta} \cdot \log n\Big) \\
& = \Gamma_{2j}^t \cdot \alpha_2 \cdot \frac{30}{\zeta} \cdot \log n
\leq n^{1/8} \cdot \sqrt{\frac{n}{b} \cdot \log n}.
\end{align*}
The contribution of the rest of the bins is due to the change in the average load. More specifically, for any overloaded bin $i \in [n] \setminus \{ j \}$,
\begin{align*}
\left|\Delta\Gamma_{2i}^{t+1}\right|
& \leq \Gamma_{2i}^t \cdot e^{ \alpha_2 \cdot \frac{15}{\zeta} \cdot \frac{\log n}{n}}- \Gamma_{2i}^t \leq \Gamma_{2i}^t \cdot \Big( 1 + 2 \cdot \alpha_2 \cdot \frac{15}{\zeta} \cdot \frac{\log n}{n}\Big)- \Gamma_{2i}^t \\
& = \Gamma_{2i}^t \cdot \alpha_2 \cdot \frac{30}{\zeta} \cdot \frac{\log n}{n}
\leq \sqrt{\frac{\log n}{bn}} \cdot n^{1/8}.
\end{align*}
Similarly, for any underloaded bin $i \in [n] \setminus \{ j \}$,
\begin{align*}
\left|\Delta\Gamma_{2i}^{t+1}\right|
& \leq \Gamma_{2i}^t - \Gamma_{2i}^t \cdot e^{-\alpha_2 \cdot \frac{15}{\zeta} \cdot \frac{\log n}{n}} \\
& \leq \Gamma_{2i}^t - \Gamma_{2i}^t \cdot \Big( 1 - 2 \cdot \alpha_2 \cdot \frac{15}{\zeta} \cdot \frac{\log n}{n}\Big) \\
& = \Gamma_{2i}^t \cdot \alpha_2 \cdot \frac{30}{\zeta} \cdot \frac{\log n}{n}
\leq \sqrt{\frac{\log n}{bn}} \cdot n^{1/8}.
\end{align*}
Hence, aggregating over all bins\begin{align*}
\left|\Delta\Gamma_2^{t+1}\right|
& \leq \left|\Delta\Gamma_{2j}^{t+1} \right| + \sum_{i \in [n] \setminus \{ j \}} \left|\Delta\Gamma_{2i}^{t+1} \right| \\
& \leq 2 \cdot n^{1/8} \cdot \sqrt{\frac{n}{b} \cdot \log n} + n \cdot \sqrt{\frac{\log n}{bn}} \cdot n^{1/8} \\
& \leq n^{1/4} \cdot \sqrt{\frac{n}{b} \cdot \log n},
\end{align*}
for sufficiently large $n$.
\textit{Third statement.} Let $i, j \in [n]$ be the differing bins between $x^t$ and $\widehat{x}^t$. Then since $\mathcal{H}^t$ holds, $w^t \leq \frac{15}{\zeta} \cdot \log n$, so for bin $i$,
\[
\Gamma_{1i}(\widehat{x}^t) \leq e^{\alpha_1 w^t} \cdot \Gamma_{1i}^t(x^t) \leq 2 \cdot \Gamma_{1i}^t(x^t),
\]
since $\alpha_1 < \frac{1}{40 \cdot S \cdot \log n}$ and $S > 1/\zeta$. Similarly, for bin $j$,
\[
\Gamma_{1j}(\widehat{x}^t) \leq e^{\alpha_1 w^t} \cdot \Gamma_{1j}^t(x^t) \leq 2 \cdot \Gamma_{1j}^t(x^t),
\]
Hence,
\[
\Gamma_1^t(\widehat{x}^t) = \sum_{k = 1}^n \Gamma_{1k}^t(\widehat{x}^t) \leq \sum_{k = 1}^n 2 \cdot \Gamma_{1k}^t(x^t) = 2 \cdot \Gamma_1^t(x^t). \qedhere
\]
\end{proof}
Next, we will show that $\ex{\Gamma_2} = \Oh(n)$ and that when $\Gamma_2$ is sufficiently large, it drops in expectation over the next batch.
\begin{lem}
\label{lem:large_gamma_exponential_drop}
Consider any process satisfying the conditions in \cref{lem:batching_gamma_linear_whp}. Then, there exists a constant $\tilde{c} := \tilde{c}(\delta)$ such that for any step $t\geq 0$ being a multiple of $b$, \[
(i) \quad \ex{\Gamma_1^t} \leq \frac{\tilde{c}}{2} \cdot n,
\quad \text{ and } \quad (ii) \quad \ex{\Gamma_2^t} \leq \frac{\tilde{c}}{2} \cdot n.
\]
Further, \[
(iii) \quad \Ex{\Gamma_2^{t+b} \,\, \Big\vert\,\, \mathfrak{F}^{t},\Gamma_2^t \geq \tilde{c} \cdot n} \leq
\Gamma_2^{t} \cdot \Big(1-\frac{1}{\log n}\Big),
\]
and
\[
(iv) \quad \Ex{\Gamma_2^{t+b} \,\,\Big\vert\,\, \mathfrak{F}^{t},\Gamma_2^t \leq \tilde{c} \cdot n} \leq
\tilde{c} \cdot n - \frac{n}{\log^2 n}.
\]
\end{lem}
\begin{proof}
\textit{First/Second statement.} By \cref{lem:herd_batching_pot_changes} and \cref{thm:hyperbolic_cosine_expectation} with $K := 5 \cdot (C - 1)^2 \cdot \frac{b}{n}$, $\alpha_1 = \frac{\delta}{40S} \cdot \sqrt{\frac{n}{b \log n}} \leq \frac{\eps\delta}{8K}$, since $\alpha_1 \leq \frac{1}{2} \cdot \sqrt{\frac{n}{b \log n}} = \frac{n}{2 \cdot (C-1) \cdot b}$ and $\frac{2CS}{(C-1)^2} \cdot n = 2CS \cdot \frac{b}{\log n} \leq b$, we get the conclusion by setting $\tilde{c} := 16 c/\delta$, for $c := c(\delta) > 0$ the constant in \cref{thm:hyperbolic_cosine_expectation}.
Similarly for the potential $\Gamma_2$ since $\alpha_2 \leq \alpha_1$.
\textit{Third statement.} Furthermore, by \cref{lem:herd_batching_pot_changes} and \cref{thm:hyperbolic_cosine_expectation}, we also get that for any $t \geq 0$,
\begin{equation} \label{eq:tilde_gamma_drop}
\Ex{\left. \Gamma_2^{t+b} \,\,\right|\,\, \mathfrak{F}^t} \leq \Gamma_2^t \cdot \Big(1 - b \cdot \frac{\eps\delta}{8n} \cdot \alpha_2\Big) + b \cdot c\alpha_2\eps.
\end{equation}
We define the constant
\begin{align*}
\tilde{c}_1
& := \frac{1}{2} \cdot b \cdot \frac{\eps\delta}{8n} \cdot \alpha_2
= b \cdot \frac{\delta^2}{16 \cdot 8 \cdot 30 \cdot 40S \cdot n} \cdot \sqrt{\frac{n}{b \log n}} \cdot \sqrt{\frac{n \log n}{b}} \\
& = \frac{\delta^2}{16 \cdot 8 \cdot 30 \cdot 40 \cdot S}.
\end{align*}
When $\big\{ \Gamma_2^{t} \geq \tilde{c} \cdot n\big \}$ holds, then \cref{eq:tilde_gamma_drop} yields,
\begin{align*}
\Ex{\Gamma_2^{t+b} \,\Big\vert\, \mathfrak{F}^t, \Gamma_2^{t} \geq \tilde{c} \cdot n}
& \leq \Gamma_2^{t} \cdot \Big(1 - 2 \cdot \tilde{c}_1 \Big) + b \cdot c\alpha_2\eps \\
& = \Gamma_2^{t} - \tilde{c}_1 \cdot \Gamma_2^{t} + \Big(b \cdot c\alpha_2\eps - \tilde{c}_1 \cdot \Gamma_2^{t}\Big)
\\
& = \Gamma_2^{t} - \tilde{c}_1 \cdot \Gamma_2^{t} + \Big(b \cdot c\alpha_2\eps- \frac{1}{2} \cdot b \cdot \frac{\eps\delta}{8n} \cdot \alpha_2 \cdot \frac{16 c}{\delta} \cdot n \Big) \\
& \leq \Big(1-\frac{1}{\log n} \Big) \cdot \Gamma_2^{t}.
\end{align*}
\textit{Fourth statement.} Similarly, when $\Gamma_1^t < \tilde{c} \cdot n$, \cref{eq:tilde_gamma_drop} yields,
\begin{align*}
\Ex{\Gamma_2^{t+b} \,\Big\vert\, \mathfrak{F}^t, \Gamma_2^{t} < \tilde{c} \cdot n}
& \leq \tilde{c} \cdot n \cdot \Big(1 - 2 \cdot \tilde{c}_1\Big) + b \cdot c\alpha_2\eps \\
& = \tilde{c} \cdot n - \tilde{c} \cdot \tilde{c}_1 \cdot n + \Big(b \cdot c\alpha_2\eps- \tilde{c} \cdot \tilde{c}_1 \cdot n \Big)
\\
&= \tilde{c} \cdot n - \frac{\tilde{c}}{\log n} \cdot n \leq \tilde{c} \cdot n - \frac{n}{\log^2 n}. \qedhere
\end{align*}
\end{proof}
In the next lemma, we show that \Whp~$\Gamma_1$ is $\poly(n)$ for every step in an interval of length $2 b \log^3 n$.
\begin{lem} \label{lem:gamma_continuous}
Let $\tilde{c} := 2 \cdot \frac{8c}{\delta}$ be the constant defined in \cref{lem:large_gamma_exponential_drop}. For any $2n \log n \leq b \leq n^3$ and for any step $t \geq 0$ being a multiple of $b$,
\[
\Pro{ \bigcap_{s \in [t, t + 2b \log^ 3 n]} \left\{ \Gamma_1^{s} \leq \tilde{c} \cdot n^{26} \right\} } \geq 1 - n^{-10}.
\]
\end{lem}
\begin{proof}
We will start by bounding $\Gamma_1^s$ at steps $s$ being a multiple of $b$. Using \cref{lem:large_gamma_exponential_drop}~$(i)$, Markov's inequality and the union bound, we have for any $t \geq 0$,
\begin{equation} \label{eq:base_union_bound}
\Pro{ \bigcap_{s \in [0, 2 \log^ 3 n]} \left\{ \Gamma_1^{t + s \cdot b} \leq \tilde{c} \cdot n^{12} \right\} } \geq 1 - \frac{2\log^3 n}{n^{11}}.
\end{equation}
Now, given that $\Gamma_1^{t + s \cdot b} \leq \tilde{c} \cdot n^{12}$, we will upper bound $\Gamma_1$ for the steps in between, i.e., for $\Gamma_1^{t + s \cdot b + r}$ for any $r \in [0, b)$. To this end, recalling that $\Gamma_{1i}^{t + s \cdot b + r} := \Phi_{1i}^{t + s \cdot b + r} + \Psi_{1i}^{t + s \cdot b + r}$, we will upper bound for each bin $i \in [n]$ the terms $\Phi_{1i}^{t + s \cdot b + r}$ and $\Psi_{1i}^{t + s \cdot b + r}$ separately. Proceeding using \cref{eq:phi_batched_i} in \cref{lem:herd_batching_pot_changes} (since $\alpha_1 \leq 1$ and $p$ satisfies condition $\mathcal{C}_3$),
\begin{align*}
\Ex{\left. \Phi_{1i}^{t + s \cdot b + r} \,\right|\, \mathfrak{F}^{t + s \cdot b}, \Phi_{1i}^{t + s \cdot b}}
& \leq \Phi_{1i}^{t + s \cdot b} \cdot \left( 1 + \left(p_i - \frac{1}{n}\right) \cdot \alpha_1 + 2 \cdot p_i \cdot S\alpha_1^2 \right)^r \\
& \stackrel{(a)}{\leq} \Phi_{1i}^{t + s \cdot b} \cdot \left( 1 + \frac{C-1}{n} \cdot \alpha_1 + 2 \cdot \frac{C}{n} \cdot S\alpha_1^2 \right)^r \\
& \stackrel{(b)}{\leq} \Phi_{1i}^{t + s \cdot b} \cdot \left( 1 + 2 \cdot \frac{C-1}{n} \cdot \alpha_1 \right)^r \\
& \leq \Phi_{1i}^{t + s \cdot b} \cdot e^{2\alpha_1 (C-1) \cdot \frac{r}{n}} \leq \Phi_{1i}^{t + s \cdot b} \cdot e^{2\alpha_1 (C-1) \cdot \frac{b}{n}} \\
& \stackrel{(c)}{\leq} 2 \cdot \Phi_{1i}^{t + s \cdot b},
\end{align*}
using in $(a)$ that $p_i - \frac{1}{n} \leq \frac{C - 1}{n}$ by condition $\mathcal{C}_3$, $(b)$ that $\alpha_1 \leq \frac{C-1}{2CS}$ (as in \cref{eq:alpha_second_bound}) and in $(c)$~that $\alpha_1 \leq \frac{\delta}{40} \cdot \sqrt{\frac{n}{b \log n}}$ and $C - 1 = \sqrt{\frac{n \log n}{b}}$. Similarly, using \cref{eq:psi_batched_i} in \cref{lem:herd_batching_pot_changes},
\begin{align*}
\Ex{\left. \Psi_{1i}^{t + s \cdot b + r} \,\right|\, \mathfrak{F}^{t + s \cdot b}, \Phi_{1i}^{t + s \cdot b}}
& \leq \Psi_{1i}^{t + s \cdot b} \cdot \left( 1 + \left( \frac{1}{n} - p_i\right) \cdot \alpha_1 + 2 \cdot p_i \cdot S\alpha_1^2 \right)^r \\
& \stackrel{(a)}{\leq} \Psi_{1i}^{t + s \cdot b} \cdot \left( 1 + \frac{C-1}{n} \cdot \alpha_1 + 2 \cdot \frac{C}{\alpha_1} \cdot S\alpha_1^2 \right)^r \\
& \stackrel{(b)}{\leq} \Psi_{1i}^{t + s \cdot b} \cdot \left( 1 + 2 \cdot \frac{C - 1}{n} \cdot \alpha_1 \right)^r \\
& \leq \Psi_{1i}^{t + s \cdot b} \cdot e^{2\alpha (C-1) \cdot \frac{r}{n}} \leq \Psi_{1i}^{t + s \cdot b} \cdot e^{2\alpha_1 (C-1) \cdot \frac{b}{n}} \\
& \stackrel{(c)}{\leq} 2 \cdot \Psi_{1i}^{t + s \cdot b},
\end{align*}
using in $(a)$ that $\frac{1}{n} - p_i \leq \frac{C - 1}{n}$ by condition $\mathcal{C}_3$, $(b)$ that $\alpha_1 \leq \frac{C - 1}{2CS}$ and in $(c)$ that $\alpha_1 \leq \frac{\delta}{40} \cdot \sqrt{\frac{n}{b \log n}}$ and $C - 1 = \sqrt{\frac{n \log n}{b}}$. Hence, combining and aggregating over the bins,
\[
\Ex{\left. \Gamma_1^{t + s \cdot b + r} \, \right| \, \mathfrak{F}^{t + s \cdot b}, \Gamma_1^{t + s \cdot b}} \leq 2 \cdot \Gamma_1^{t + s \cdot b}.
\]
Applying Markov's inequality, for any $r \in [0, b)$,
\[
\Pro{\Gamma_1^{t + s \cdot b + r} \leq n^{14} \cdot \Gamma_1^{t + s \cdot b}} \geq 1 - 2 \cdot n^{-14}.
\]
Hence, by a union bound over the $2b \cdot \log^3 n \leq 2 \cdot n^3 \cdot \log^3 n$ possible rounds (since $b \leq n^3$) for $s \in [0, 2\log^3 n]$ and $r \in [0, b)$,%
\begin{align}
\Pro{ \bigcap_{r \in [0, b]}\bigcap_{s\in [0, 2\log^3 n]} \left\{ \Gamma_1^{t + s \cdot b + r} \leq n^{14} \cdot \Gamma_1^{t + s \cdot b} \right\} }
\geq 1 - 2 \cdot n^{-14} \cdot 2 b \log^3 n \geq 1 - \frac{1}{2} \cdot n^{-10}. \label{eq:double_intersection_lb}
\end{align}
Finally, taking the union bound of \cref{eq:base_union_bound} and \cref{eq:double_intersection_lb}, we conclude
\begin{align*}
\Pro{ \bigcap_{s \in [t, t + 2b \log^ 3 n]} \left\{ \Gamma_1^{s} \leq \tilde{c} \cdot n^{26} \right\} }
& \geq \Pr\Bigg[ \bigcap_{r \in [0, b]}\bigcap_{s\in [0, 2\log^3 n]} \left\{ \Gamma_1^{t + s \cdot b + r} \leq n^{14} \cdot \Gamma_1^{t + s \cdot b} \right\} \\
& \qquad \qquad \cap \bigcap_{s \in [0, 2 \log^ 3 n]} \left\{ \Gamma_1^{t + s \cdot b} \leq \tilde{c} \cdot n^{12} \right\} \Bigg]\\
& \geq 1 - \frac{1}{2} \cdot n^{-10} - \frac{2\log^3 n}{n^{11}} \geq 1 - n^{-10}. \qedhere
\end{align*}
\end{proof}
We will now show that \Whp~there is a step every $b\log^3 n$ steps, such that the exponential potential $\Gamma_2$ becomes $\Oh(n)$. We call this the \textit{recovery} phase.
\begin{lem}[Recovery] \label{lem:batched_gamma_1_poly_n_implies_gamma_2_linear_whp}
Consider any process satisfying the conditions in \cref{lem:batching_gamma_linear_whp}. Let $\tilde{c} := 2 \cdot \frac{8c}{\delta}$ be the constant defined in \cref{lem:large_gamma_exponential_drop}. For any step $t \geq 0$ being a multiple of $b$,
\[
\Pro{\bigcup_{s \in [0, b \log^3 n]} \left\lbrace \Gamma_2^{t + s \cdot b} \leq \tilde{c} \cdot n \right\rbrace} \geq 1 - 2 \cdot n^{-8}.
\]
\end{lem}
\begin{proof}
By \cref{lem:large_gamma_exponential_drop}~$(ii)$, using Markov's inequality at step $t$ being a multiple of $b$, we have
\begin{equation} \label{eq:basic_markov_tilde_gamma}
\Pro{\Gamma_2^{t} \leq \tilde{c} \cdot n^9} \geq 1 - n^{-8}.
\end{equation}
We will be assuming $\Gamma_2^{t} \leq \tilde{c} \cdot n^9$. By \cref{lem:large_gamma_exponential_drop}~$(iii)$, for any step $r \geq 0$, then \[
\Ex{\left. \Gamma_2^{r+1} \,\right|\, \mathfrak{F}^{r}, \Gamma_2^{r} > \tilde{c} \cdot n} \leq
\Gamma_2^{r} \cdot \Big(1-\frac{1}{\log n}\Big).
\]
In order to prove that $\Gamma_2^{t + s \cdot b}$ is small for some $s \in [0, b \log^3 n]$, we define the ``killed'' potential function for any $r \in [0, \log^3 n]$,
\[
\widehat{\Gamma}_2^{t + r\cdot b} := \Gamma_2^{t + r \cdot b} \cdot \mathbf{1}_{\bigcap_{ s \in [0, r]} \{ \Gamma_2^{t + s \cdot b} > \tilde{c} \cdot n\} }.
\]
Note that $\widehat{\Gamma}_2^{t + r \cdot b} \leq \Gamma_2^{t + r \cdot b}$ and that $\big\{ \widehat{\Gamma}_2^{t + r \cdot b} = 0 \big\}$ implies that $\big\{ \widehat{\Gamma}_2^{t + r \cdot b + 1} = 0 \big\}$. Hence, the $\widehat{\Gamma}$ potential satisfies unconditionally the drop inequality of \cref{lem:large_gamma_exponential_drop}~$(iii)$, that is,
\[
\Ex{\left. \widehat{\Gamma}_2^{t + (r+1) \cdot b} \,\right|\, \mathfrak{F}^{t + r \cdot b}, \widehat{\Gamma}_2^{t + r \cdot b}}
\leq \widehat{\Gamma}_2^{t + r \cdot b} \cdot \Big(1-\frac{1}{\log n}\Big).
\]
Inductively applying this for $\log^3 n$ batches, %
\[
\Ex{\left. \widehat{\Gamma}_2^{t + (\log^3 n) \cdot b} \,\, \right\vert \,\, \mathfrak{F}^{t}, \Gamma_2^{t} \leq \tilde{c} \cdot n^9}
\leq \Gamma_2^{t} \cdot \Big(1-\frac{1}{\log n}\Big)^{\log^3 n}
\leq e^{-\log^2 n} \cdot \tilde{c} \cdot n^{9} < n^{-7}.
\]
So by Markov's inequality, \[
\Pro{\left. \widehat{\Gamma}_2^{t + (\log^3 n) \cdot b} < n \,\,\right|\,\, \Gamma_2^{t} \leq \tilde{c} \cdot n^9} \geq 1 - n^{-{8}}
\]
By combining with \cref{eq:basic_markov_tilde_gamma},
\begin{align*}
\Pro{\widehat{\Gamma}_2^{t + (\log^3 n) \cdot b} < n}
& \geq \left( 1 - n^{_8}\right) \cdot \left( 1 - n^{_8}\right) \geq 1 - 2\cdot n^{-8}.
\end{align*}
Due to the definition of $\Gamma_2$, at any step $t \geq 0$, deterministically $\Gamma_2^t \geq 2n$. So,
we conclude that~w.p.~at least $1 - 2 \cdot n^{-8}$, we have that $\widehat{\Gamma}_2^{t + (\log^3 n) \cdot b} = 0$ or equivalently the event
\[
\neg\bigcap_{ s \in [0, \log^3 n]} \left\{ \Gamma_2^{t + s \cdot b} > \tilde{c} \cdot n \right\},
\]
holds, which implies the conclusion.
\end{proof}
\subsubsection{Completing the Proof of Lemma~\ref{lem:batching_gamma_linear_whp}}\label{sec:gamma_linear_whp_complete}
We are now ready to prove \cref{lem:batching_gamma_linear_whp}, using a method of bounded differences with a bad event \cref{lem:kutlin_3_3} (\cite[Theorem 3.3]{K02}).
\begin{proof}[Proof of \cref{lem:batching_gamma_linear_whp}]
Our starting point is to apply
\cref{lem:batched_gamma_1_poly_n_implies_gamma_2_linear_whp}, which proves that there is at least one step $t + \rho \cdot b \in [t - b\log^3 n, t]$ with $\rho \in [-\log^3 n, 0]$ such that the potential $\Gamma_2$ is small,
\begin{align} \label{eq:starting_point}
\Pro{\bigcup_{\rho \in [- \log^3 n, 0]} \left\lbrace \Gamma_2^{t + \rho \cdot b} \leq \tilde{c} \cdot n \right\rbrace } &\geq 1 - 2 \cdot n^{-8}.
\end{align}
Note that if $t < b \cdot \log^3 n$, then deterministically $\Gamma_2^0 = 2n \leq \tilde{c} \cdot n$ (which corresponds to $\rho = -t/b$).
We are now going to apply the concentration inequality \cref{lem:kutlin_3_3} to each of the batches starting at $t + \rho \cdot b, \ldots, t + (\log^3 n) \cdot b$ and show that the potential remains $ \leq \tilde{c} \cdot n$ at the last step of each batch. More specifically, we will show that for any $\tilde{r} \in [\rho, \log^3 n]$, for $r = t + b \cdot \tilde{r}$,
\[
\Pro{\left. \Gamma_2^{r+b} > \tilde{c} \cdot n \,\right|\, \mathfrak{F}^r, \Gamma_2^r \leq \tilde{c} \cdot n} \leq 3 \cdot n^{-4}.
\]
We will show this by applying \cref{lem:kutlin_3_3} for all steps of the batch $[r, r + b]$. We define the good event \[
\mathcal{G}_r := \mathcal{G}_r^{r+b} := \bigcap_{s \in [r, r + b]} \left( \left\{ \Gamma_1^s \leq \tilde{c} \cdot n^{26} \right\} \cap \mathcal{H}^s \right),
\]
and the bad event $\mathcal{B}_r := (\mathcal{G}_r)^c$. Using a union bound over \cref{lem:many_h_i} and \cref{lem:gamma_continuous},
\begin{align} \label{eq:bad_event_union_bound}
\Pro{ \bigcap_{s \in [t-b \log^3 n, t+ b \log^ 3 n]} \left( \left\{ \Gamma_1^{s} \leq \tilde{c} \cdot n^{26} \right\} \cap \mathcal{H}^s \right) } \geq 1 - 2n^{-10}.
\end{align}
Consider any $u \in [r, r + b]$. Further, we define the slightly weaker good event, $\tilde{\mathcal{G}}_r^u := \bigcap_{s \in [r, u]} \left( \left\{ \Gamma_1^s \leq 2\tilde{c} \cdot n^{26} \right\} \cap \mathcal{H}^s \right)$ and the ``killed'' potential, %
\[
\widehat{\Gamma}_r^u := \Gamma_2^u \cdot \mathbf{1}_{\tilde{\mathcal{G}}_r^u}.
\]
We will show that the sequence $\widehat{\Gamma}_r^r, \ldots , \widehat{\Gamma}_r^{r + b}$ is strongly difference-bounded by $(n^{5/4}, n^{1/4} \cdot \sqrt{(n/b) \cdot \log n}, 2 \cdot n^{-10})$ (\cref{def:strongly_dif_bounded}).
Let $\omega \in [n]^{b}$ be an allocation vector encoding the allocations made in $[r, r + b]$. Let $\omega'$ be an allocating vector resulting from $\omega$ by changing one arbitrary allocation. It follows that,
\begin{align*}
\left| \widehat{\Gamma}_r^{r+b}(\omega) - \widehat{\Gamma}_r^{r+b}(\omega') \right| &\leq \max_{\tilde{\omega}} \widehat{\Gamma}_r^{r+b}(\tilde{\omega}) - \min_{\tilde{\omega}} \widehat{\Gamma}_r^{r+b}(\tilde{\omega}) \\
&\leq \max_{\tilde{\omega} \in \tilde{\mathcal{G}}_{r}^{r+b}} \Gamma_{2}^{r+b}(\tilde{\omega}) -0
\\ & \leq n^{5/4},
\end{align*}
where in the last inequality we used \cref{lem:batched_gamma_1_poly_implies}~$(i)$ that for any $\tilde{\omega} \in \tilde{\mathcal{G}}_r^{r+b}$, we have $\widehat{\Gamma}_r^{r+b}(\tilde{\omega}) \leq \Gamma_{2}^{r+b}(\tilde{\omega}) \leq n^{5/4}$.
We will now derive a refined bound by additionally assuming that $\omega \in \mathcal{G}_r$. Then, for any $u \in [r, r + b]$,
\[
\Gamma_1^{r+u}(\omega') \leq 2 \cdot \Gamma_1^{r+u}(\omega) \leq 2 \tilde{c} \cdot n^{26},
\]
where the first inequality is by \cref{lem:batched_gamma_1_poly_implies}~$(iii)$.
Hence $\omega' \in \tilde{\mathcal{G}}_r^{r+b}$, so $\mathbf{1}_{\tilde{\mathcal{G}}_r^{r+b}(\omega')} = 1$ and $\widehat{\Gamma}_r^{r+b}(\omega')
= \Gamma_{2r}^{r+b}(\omega')$. Similarly, for $\omega \in \mathcal{G}_r \subseteq \tilde{\mathcal{G}}_r^{r+b}$, we have $\widehat{\Gamma}_r^{r+b}(\omega)
= \Gamma_{2r}^{r+b}(\omega)$ and by \cref{lem:batched_gamma_1_poly_implies}~$(ii)$,
\[
\left|\widehat{\Gamma}_r^{r+b}(\omega) - \widehat{\Gamma}_r^{r+b}(\omega')\right| = \left| \Gamma_2^{r+b}(\omega) - \Gamma_2^{r+b}(\omega') \right| \leq n^{1/4} \cdot \sqrt{\frac{n}{b} \cdot \log n}.
\]
Within a single batch all allocations are independent, so we apply \cref{lem:kutlin_3_3}, choosing $\gamma_k := \frac{1}{b}$ and $N := b$, which states that for any $T > 0$ and $\mu := \Ex{\left. \widehat{\Gamma}_r^{r + b} > \mu + T \,\right|\, \mathfrak{F}^r, \Gamma_2^r \leq \tilde{c} \cdot n}$,
\begin{align*}
& \Pro{\left. \widehat{\Gamma}_r^{r + b} > \mu + T \, \right|\, \mathfrak{F}^r, \Gamma_2^r \leq \tilde{c} \cdot n} \\
& \quad \leq \exp\left( - \frac{T^2}{2 \cdot \sum_{k = 1}^{b} (n^{1/4} \cdot \sqrt{\frac{n}{b} \cdot \log n} + n^{5/4} \cdot \frac{1}{b})^2 }\right) + 2 \cdot n^{-10} \cdot \sum_{k = 1}^b b.
\end{align*}
By \cref{lem:large_gamma_exponential_drop}~$(iv)$, we have $\mu \leq \ex{\widehat{\Gamma}_r^{r+b} \mid \Gamma_2^r < \tilde{c} \cdot n} \leq \ex{\Gamma_{2}^{r+b} \mid \Gamma_2^r < \tilde{c} \cdot n} \leq \tilde{c} \cdot n - n/\log^2 n$. Hence, for $T := n / \log^2 n$, since $2n \log n \leq b \leq n^3$, we have
\begin{align*}
\Pro{\left. \widehat{\Gamma}_r^{r+b} > \tilde{c} \cdot n \, \right|\, \mathfrak{F}^r, \Gamma_2^r \leq \tilde{c} \cdot n}
& \leq \exp\left( - \frac{n^2/\log^4 n}{2 \cdot b \cdot (2 \cdot n^{1/4} \cdot \sqrt{\frac{n}{b} \cdot \log n})^2 }\right) + 2n^{-10} \cdot b^2 \\
& \leq \exp\left( - \frac{n^{1/2}}{8 \cdot \log^5 n} \right) + 2n^{-10} \cdot n^6 \leq 3 \cdot n^{-4}.
\end{align*}
Let $\mathcal{K}_{\rho}^{\tilde{r}} := \mathcal{G}_{\rho}^{t + \tilde{r} \cdot b} \cap \{ \Gamma_2^{t + \rho \cdot b} \leq \tilde{c} \cdot n \}$ for $\tilde{r} \in [\rho, \log^3 n]$. For any $\tilde{r} \geq \rho$, since $\mathcal{K}_\rho^{\tilde{r}+1} \subseteq \mathcal{K}_\rho^{\tilde{r}}$, we have%
\begin{align} \label{eq:k_killed}
\Pro{\left. \widehat{\Gamma}_r^{t + (\tilde{r}+1) \cdot b} \cdot \mathbf{1}_{\mathcal{K}_\rho^{\tilde{r}+1}} > \tilde{c} \cdot n \,\right|\, \mathfrak{F}^r, \widehat{\Gamma}_r^{t + \tilde{r} \cdot b} \cdot \mathbf{1}_{\mathcal{K}_\rho^{\tilde{r}}} \leq \tilde{c} \cdot n} \leq 3 \cdot n^{-4}.
\end{align}
By union bound of \cref{eq:starting_point} and \cref{eq:bad_event_union_bound},
\begin{align}
\Pro{\bigcup_{\rho \in [-\log^3 n]} \mathcal{K}_{\rho}^{\log^3 n}}
& \geq \Pro{\mathcal{G}_{-\log^3 n}^{\log^3 n} \cap \bigcup_{\rho \in [- \log^3 n, 0]} \left\lbrace \Gamma_2^{t + \rho \cdot b} \leq \tilde{c} \cdot n \right\rbrace} \notag \\
& \geq 1 - 2 \cdot n^{-8} - 2\cdot n^{-10} \geq 1 - 3 \cdot n^{-8}.\label{eq:exists_k_event}
\end{align}
Let \[
\mathcal{A} := \bigcap_{\tilde{r} \in [0, \log^3 n]} \left\lbrace \Gamma_2^{t + \tilde{r} \cdot b} \leq \tilde{c} \cdot n \right\rbrace\] and \[\mathcal{A}_{\rho} := \bigcap_{\tilde{r} \in [\rho, \log^3 n]} \left\lbrace \widehat{\Gamma}_r^{t + \tilde{r} \cdot b} \cdot \mathbf{1}_{\mathcal{K}_\rho^{\tilde{r}}} \leq \tilde{c} \cdot n \right\rbrace\]. Then,
\begin{align*}
\Pro{\mathcal{A}_\rho \,\,\left|\,\, \Gamma_2^{t + \rho \cdot b} \leq \tilde{c} \cdot n \right.}
& \geq \prod_{\tilde{r} \in [\rho, \log^3 n - 1]} \mathbf{Pr} \left[ \bigcap_{\tilde{s} \in [\rho+1, \tilde{r}+1]} \left\lbrace \widehat{\Gamma}_r^{t + \tilde{s} \cdot b} \cdot \mathbf{1}_{\mathcal{K}_\rho^{\tilde{s}}} \leq \tilde{c} \cdot n \right\rbrace \right. \\
& \qquad \qquad \left. \bigg\vert \, \bigcap_{\tilde{s} \in [\rho+1, \tilde{r} - 1]} \left\lbrace \widehat{\Gamma}_r^{t + \tilde{s} \cdot b} \cdot \mathbf{1}_{\mathcal{K}_\rho^{\tilde{s}}} \leq \tilde{c} \cdot n \right\rbrace, \widehat{\Gamma}_r^{t + \tilde{r} \cdot b} \cdot \mathbf{1}_{\mathcal{K}_\rho^{\tilde{s}}} \leq \tilde{c} \cdot n\right] \\
& \geq \prod_{\tilde{r} \in [\rho, \log^3 n - 1]} \Pro{\left. \widehat{\Gamma}_r^{\tilde{r}+b} \cdot \mathbf{1}_{\mathcal{K}_\rho^{\tilde{r}+1}} > \tilde{c} \cdot n \,\right|\, \mathfrak{F}^{t + \tilde{r} \cdot b}, \widehat{\Gamma}_r^{t + \tilde{r} \cdot b} \cdot \mathbf{1}_{\mathcal{K}_\rho^{\tilde{r}}} \leq \tilde{c} \cdot n} \\
& \geq (1 - 3n^{-4})^{2\log^3 n} \geq 1 - 6 \cdot n^{-4} \cdot \log^3 n,
\end{align*}
where in the last inequality we have used \cref{eq:k_killed} and the fact $\rho \geq -\log^3 n$. So,
\begin{align}
\Pro{\mathcal{A}_\rho}
& = \Pro{\mathcal{A}_\rho \,\left|\,\, \Gamma_2^{t + \rho \cdot b} \leq \tilde{c} \cdot n \right.} \cdot \Pro{\Gamma_2^{t + \rho \cdot b} \leq \tilde{c} \cdot n} + 1 \cdot \Pro{\neg \left\{ \Gamma_2^{t + \rho \cdot b} \leq \tilde{c} \cdot n \right\}} \notag \\
& \geq 1 - 6 \cdot n^{-4} \cdot \log^3 n. \label{eq:event_a_rho}
\end{align}
Note that for any $\rho \in [-\log^3 n, 0]$, we have that $\mathcal{A}_\rho \cap \mathcal{K}_\rho^{\log^3 n} \subseteq \mathcal{A}$. Hence we conclude by the union bound of \cref{eq:exists_k_event} and \cref{eq:event_a_rho}, that
\begin{align*}
\Pro{\mathcal{A}}
& \geq \Pro{\bigcup_{\rho \in [-\log^3 n, 0]} \mathcal{K}_{\rho}^{\log^3 n} \cap \bigcap_{\rho \in [-\log^3 n, 0]} \mathcal{A}_\rho} \geq 1 - 3 \cdot n^{-8} - 6 \cdot n^{-4} \cdot \log^6 n \geq 1- n^{-3}. \qedhere
\end{align*}
\end{proof}
\subsection{Step 2: Completing the proof of Theorem~\ref{thm:batching_strong_gap_bound}}\label{sec:step_two}
We will now show that when $\Gamma_2^t = \Oh(n)$, the stronger potential function $\Lambda^t$ drops in expectation over the next batch. This will allow us to prove that $\Lambda^m = \poly(n)$ and deduce that \Whp~$\Gap(m) = \Oh\big(\sqrt{(b/n) \cdot \log n}\big)$.
\begin{lem} \label{lem:lambda_drops}
Consider any process satisfying the conditions in \cref{thm:batching_strong_gap_bound}. Let $\tilde{c} := 2 \cdot \frac{8c}{\delta}$ where $c := c(\delta) > 0$ is the constant from \cref{thm:hyperbolic_cosine_expectation}. For any step $t \geq 0$ being a multiple of $b$,
\[
\Ex{\Lambda^{t+b} \,\left|\, \mathfrak{F}^t, \Gamma_2^t \leq \tilde{c} \cdot n \right.} \leq \Lambda^t \cdot e^{-\frac{\lambda\eps}{2n} \cdot b} + n^2.
\]
\end{lem}
\begin{proof}
Consider an arbitrary step $t \geq 0$ being a multiple of $b$ and consider a labeling of the bins so that they are sorted by load. Assuming that $\{ \Gamma_2^t \leq \tilde{c} \cdot n \}$ holds, the number of bins with load $y_i^t \geq z$ is at most
\[
\tilde{c} \cdot n \cdot e^{- \alpha_2 \cdot z} = \tilde{c} \cdot n \cdot e^{-\log(\tilde{c}/\delta)} = \delta \cdot n.
\]
For any bin $i \in [n]$ with $y_i^t \geq z$, we get as in \cref{eq:phi_batched_i} (using that $\lambda \leq 1$ and that $p$ satisfies $\mathcal{C}_3$ for $C \in (1, 1.9)$),%
\begin{align*}
\Ex{\left. \Lambda_i^{t + b} \,\,\right|\,\, \mathfrak{F}^t}
& \leq \Lambda_i^t \cdot \left( 1 + \Big(p_i^t - \frac{1}{n}\Big) \cdot \lambda + 2 \cdot p_i^t \cdot S\lambda^2 \right)^b.
\end{align*}
Since there are at most $\delta n$ such bins (i.e., $i \leq \delta n$), $p$ satisfies condition $\mathcal{C}_1$ and the normalised vector $y^t$ is sorted, the upper bound on $\Ex{\Lambda^{t+b} \mid \mathfrak{F}^t, \Gamma_2^t \leq \tilde{c} \cdot n}$ is maximized when $p_i^t = \frac{1 - \eps}{n}$, so
\begin{align*}
\sum_{i : y_i^t \geq z} \Ex{\left. \Lambda_i^{t + b} \,\,\right|\,\, \mathfrak{F}^t, \Gamma_2^t \leq \tilde{c} \cdot n}
& \stackrel{(a)}{\leq} \sum_{i : y_i^t \geq z} \Lambda_i^t \cdot \left( 1 - \frac{\lambda\eps}{n} + 2CS \cdot \frac{\lambda^2}{n} \right)^b \\
& \stackrel{(b)}{\leq} \sum_{i : y_i^t \geq z} \Lambda_i^t \cdot \left( 1 - \frac{\lambda\eps}{2n}\right)^b
\stackrel{(c)}{\leq} \sum_{i : y_i^t \geq z} \Lambda_i^t \cdot e^{-\frac{\lambda\eps}{2n} \cdot b},
\end{align*}
using in $(a)$ that $p_i^t \leq \frac{C}{n}$, in $(b)$ that $\lambda = \frac{\eps}{4CS}$ and in $(c)$ that $1 + v \leq e^v$ for any $v$. For the rest of the bins with $i > \delta n$,
\begin{align*}
\Ex{\left. \Lambda_i^{t + b} \,\right|\, \mathfrak{F}^t}
& \leq \Lambda_i^t \cdot \left( 1 + \left(p_i^t - \frac{1}{n}\right) \cdot \lambda + 2 \cdot p_i^t \cdot S\lambda^2 \right)^b \\
& \stackrel{(a)}{\leq} \Lambda_i^t \cdot \left( 1 + \frac{C - 1}{n} \cdot \lambda + 2CS \cdot \frac{\lambda^2}{n} \right)^b \\
& \stackrel{(b)}{\leq} \Lambda_i^t \cdot \left( 1 + \frac{C-1}{n} \cdot \lambda\right)^b \\
& \stackrel{(c)}{\leq} \left( 1 + 2 \cdot \frac{C-1}{n} \cdot \lambda\right)^b \\
& \stackrel{(d)}{\leq} e^{2 \cdot \frac{C-1}{n} \cdot \lambda b} \stackrel{(e)}{\leq} n,
\end{align*}
using in $(a)$ that $p_i^t \leq \frac{C}{n}$, in $(b)$ that $2CS \cdot \frac{\lambda^2}{n} = \frac{\eps}{2n} \cdot \lambda \leq \frac{C-1}{2n} \cdot \lambda$ since $\lambda = \frac{\eps}{4CS}$ and $\eps = C - 1$, in $(c)$ that $\Lambda_i^t \leq 1$, in $(d)$ that $1 + v \leq e^v$ for any $v$ and in $(e)$ that $2 \cdot \frac{C-1}{n} \cdot \lambda b \leq \frac{\eps^2}{2CS} \cdot \frac{b}{n} \leq \log n$ (since $C > 1$ and $S \geq 1$).
Aggregating the contributions over all bins,
\begin{align*}
\Ex{\left. \Lambda^{t+b} \,\right|\, \mathfrak{F}^t, \Gamma_2^t \leq \tilde{c} \cdot n }
& \leq \sum_{ i : y_i^t \geq z} \Lambda_i^t \cdot e^{-\frac{\lambda\eps}{2n} \cdot b} + \sum_{ i : y_i^t < z} n
\leq \Lambda^t \cdot e^{-\frac{\lambda\eps}{2n} \cdot b} + n^2.\qedhere
\end{align*}
\end{proof}
Now we are ready to complete the proof of \cref{thm:batching_strong_gap_bound}.
\begin{proof}[Proof of \cref{thm:batching_strong_gap_bound}]
First consider the case when $m \geq b \cdot \log^3 n$. Let $t_0 = m - b \cdot \log^3 n$. Let $\mathcal{E}^t := \big\{ \Gamma_2^{t} \leq \tilde{c} \cdot n \big\}$. Then using \cref{lem:batching_gamma_linear_whp},
\begin{equation} \label{eq:eps_interval}
\Pro{ \bigcap_{j \in [0, \log^3 n]} \mathcal{E}^{t_0 + j \cdot b} } \geq 1 - n^{-3}.
\end{equation}
We define the killed potential $\tilde{\Lambda}$, with $\tilde{\Lambda}^{t_0} := \Lambda^{t_0}$ and for $j > 0$,
\[
\tilde{\Lambda}^{t_0 + j \cdot b} := \Lambda^{t_0 + j \cdot b} \cdot \mathbf{1}_{\cap_{s \in [0, j]} \mathcal{E}^{t_0 + s \cdot b}}.
\]
By \cref{lem:lambda_drops} for $t = t_0 + j \cdot b$, we have that
\begin{align*}
\Ex{\Lambda^{t_0+(j+1)\cdot b} \,\,\left|\,\, \mathfrak{F}^{t_0+j \cdot b}, \Gamma_2^{t_0+j \cdot b} \leq \tilde{c} \cdot n \right.} \leq \tilde{\Lambda}^{t_0 + j \cdot b} \cdot e^{-\frac{\lambda\eps}{2n} \cdot b} + n^2.
\end{align*}
When $\mathcal{E}^{t_0 + j \cdot b}$ does not hold, then deterministically $\tilde{\Lambda}^{t_0 + (j+1) \cdot b} = \tilde{\Lambda}^{t_0 + j \cdot b} = 0$. Hence, we have the following unconditional drop inequality
\begin{align} \label{eq:lambda_drop}
\Ex{\tilde{\Lambda}^{t_0+(j+1)\cdot b} \,\,\left|\,\, \mathfrak{F}^{t_0+j \cdot b} \right.} \leq \tilde{\Lambda}^{t_0 + j \cdot b} \cdot e^{-\frac{\lambda\eps}{2n} \cdot b} + n^2.
\end{align}
Assuming $\mathcal{E}^{t_0}$ holds, we have %
\[
\max_{i \in [n]} y_i^{t_0}
\leq \frac{1}{\alpha_2} \cdot \left( \log \tilde{c} + \log n \right)
\leq \frac{2}{\alpha_2} \cdot \log n,
\]
for sufficiently large $n$. Recalling that $\alpha_2 = \Theta(\lambda \cdot \log n)$, there exists a constant $\kappa_1 > 0$ such that
\[
\tilde{\Lambda}^{t_0} \leq n \cdot e^{\lambda \cdot y_1^{t_0}} \leq e^{\kappa_1 \log^2 n}.
\]
Applying \cref{lem:geometric_arithmetic} to \cref{eq:lambda_drop} with $a := e^{-\frac{\lambda\eps}{2n} \cdot b}$ and $b := n^2$ for $\log^3 n$ steps, %
\begin{align}
\Ex{\tilde{\Lambda}^{m} \,\,\left|\,\, \mathfrak{F}^{t_0}, \tilde{\Lambda}^{t_0} \leq e^{\kappa_1 \log^2 n} \right.}
& \leq e^{\kappa_1 \log^2 n} \cdot a^{\log^3 n} + \frac{b}{1 - a} \stackrel{(a)}{\leq} 1 + 1.5 \cdot b \leq 2n^2 \label{eq:poly_n_expectation}.
\end{align}
using in $(a)$ that $\frac{\lambda\eps}{2n} \cdot b = \Omega(\log n)$, since $\lambda = \frac{\eps}{4CS}$ and $\eps = \sqrt{(n/b) \cdot \log n}$.
By Markov's inequality, we have
\begin{align*}
\Pro{\tilde{\Lambda}^{m} \leq 2n^{5} \,\left|\, \mathfrak{F}^{t_0}, \tilde{\Lambda}^{t_0} \leq e^{\kappa_1 \log^2 n} \right.} \geq 1 - n^{-3}.
\end{align*}
Hence, by \cref{eq:eps_interval},
\begin{align} \label{eq:tilde_lambda_poly_n}
\Pro{\tilde{\Lambda}^{m} \leq 2n^{5}}
& = \Pro{\left. \tilde{\Lambda}^{m} \leq 2n^{5} \,\right|\, \mathcal{E}^{t_0}} \cdot \Pro{\mathcal{E}^{t_0}}
\geq (1 - n^{-3}) \cdot (1 - n^{-3}) \geq 1 - 2n^{-3}.
\end{align}
Combining \cref{eq:eps_interval} and \cref{eq:tilde_lambda_poly_n}, we have
\begin{align*}
\Pro{\Lambda^{m} \leq 2n^{5}}
&\geq \Pro{\left\lbrace\tilde{\Lambda}^{m} \leq 2n^{5} \right\rbrace \cap \bigcap_{j \in [0, \log^3 n]} \mathcal{E}^{t_0 + j \cdot b}} \geq 1 - 2n^{-3} - n^{-3} \geq 1 - n^{-2}.
\end{align*}
Finally, $\{ \Lambda^{m} \leq 2 \cdot n^{5} \}$ implies that
\[
\max_{i \in [n]} y_i^{m} \leq z + \frac{\log 2}{\lambda} + \frac{5\log n}{\lambda} = \Oh\left(\sqrt{\frac{b}{n} \cdot \log n} \right),
\]
since $\lambda = \frac{\eps}{4CS} = \Theta(\sqrt{(n \log n)/b})$, so the claim follows.
For the case when $m < b \cdot \log^3 n$, it deterministically holds that $\tilde{\Lambda}^{t_0} \leq n$, which is a stronger starting point in \cref{eq:poly_n_expectation} to prove that $\ex{\Lambda^m} \leq 2n^{5}$, which in turn implies the gap bound.
\end{proof}
\section{Lower Bounds on the Gap} \label{sec:lower_bounds}
In this section, we prove two lower bounds of $\Omega( \sqrt{ (b/n) \cdot \log n})$ on the gap. Both lower bounds even hold in the unweighted setting.
\begin{obs}\label{obs:simple_lower}
Consider the \Batched setting with any $b \geq n \log n$, and assume all balls are unweighted. Then, for any process which uses the same probability vector within each batch with random tie breaking, we have that
\[
\Pro{\Gap(b) \geq \frac{1}{10} \cdot \sqrt{\frac{b}{n} \cdot \log n}} \geq 1 - n^{-2}.
\]
\end{obs}
\begin{proof}
In the first batch, any such process behaves exactly like \OneChoice. Hence the result follows immediately from a known lower bound for \OneChoice for $b$ balls into $n$ bins (cf.~\cite{RS98} and~\cite[Lemma A.2]{LS23RBB}).
\end{proof}
The next lower bound is more involved. This bound even applies to processes which are allowed to adjust the probability allocation vector from one batch to another arbitrarily; e.g., the probability for a heavily underloaded bin might be set close to (or even equal to) $1$, and similarly, the probability for a heavily overloaded bin might be set close to (or equal to) $0$. Additionally, the lower bound below applies to any two consecutive batches, and not only to the end of the first batch as in \cref{obs:simple_lower}.
\begin{thm}\label{thm:lower}
Consider the \Batched setting with any $b = \Omega(n \log n)$, and assume all balls are unweighted. Furthermore, consider an allocation process which may adaptively change the probability vector for each batch. Then there is a constant $\kappa > 0$ such that for any allocation process (which may adaptively change the probability for each batch) it holds that for every $t \geq 0$ being a multiple of $b$,
\[
\Pro{ \max \left\{ \Gap(t), \Gap(t+b) \right\} \geq \kappa \cdot \sqrt{ \frac{b}{n} \cdot \log n} } \geq 1/2.
\]
\end{thm}
\begin{proof}
In the proof, we shall prove a slightly stronger statement:
\[
\Pro{ \max \left\{ \Gap(t), \Gap(t+b) \right\} \geq \kappa \cdot \sqrt{ \frac{b}{n} \cdot \log n} ~~\Bigg|~~ \mathfrak{F}^t } \geq 1/2.
\]
That is, there is no load configuration and no probability allocation vector (depending on $\mathfrak{F}^t$) such that the gap is small, both before and at the end of an arbitrary batch.
For notational convenience, we will prove this statement by assuming that $t=0$, and $x^{0}$ is an arbitrary load vector satisfying $\sum_{i \in [n]} x_i^0=0$ (in other words, we shift time backwards by $t$ steps) and $p = p^0$ is the probability allocation vector used by the process.
Consider one arbitrary bin $j \in [n]$. Then,
\begin{align}
\Ex{ x_j^b - \frac{b}{n} + z_j} = b \cdot p_j - \frac{b}{n} + z_j =: \varphi_j \label{eq:optimised}
\end{align}
For a sufficiently large constant $C > 0$, let us now assume $\max_{j \in [n]} z_j \leq C/2 \cdot \sqrt{(b/n) \cdot \log n}$; clearly, if this is not the case, we already have a large gap already before the next batch.
Next consider a bin $j \in [n]$ with
\[
p_j \leq \frac{1}{n} + \frac{1}{b} \cdot \left( -10 C \cdot \sqrt{(b/n) \cdot \log n} \right).
\]
We will now apply a Chernoff bound (\cref{lem:chernoff}) for $x_j^b \sim \mathsf{Bin}(b,p_j)$,
with $\delta := C \cdot \sqrt{(n/b) \cdot \log n}$, $\mu := b \cdot p_j$ and $\mu_H := \frac{b}{n} - 10 C \cdot \sqrt{(b/n) \cdot \log n} \geq \mu$ to get that
\[
\Pro{ x_j^b \geq \frac{b}{n} - C \cdot \sqrt{(b/n) \cdot \log n}}
\leq \Pro{ x_j^b \geq \mu_H \cdot (1 + \delta) }
\leq e^{-\delta^2\mu_H/3} = e^{-\frac{C^2}{3} \cdot \log n} \leq n^{-4}.
\]
using that $C \geq 4$.
If $\left\{ x_j^b \leq \frac{b}{n} - C \cdot \sqrt{(b/n) \cdot \log n} \right\}$ occurs, then
\[
x_j^b - \frac{b}{n} + z_j \leq -C \cdot \sqrt{(b/n) \cdot \log n} + z_j \leq -C/ 2 \cdot \sqrt{(b/n) \cdot \log n} \leq 0,
\]
and thus bin $j$ will not contribute to the gap at step $b$.
Hence in the remainder of the proof, we would like to assume that for all bins $j \in [n]$,
\[
p_j \geq \frac{1}{n} + \frac{1}{b} \cdot \left( -10 C \cdot \sqrt{(b/n) \cdot \log n} \right) =: p_{\operatorname{low}}
\]
Note $p_{\operatorname{low}} \leq 1/n$.
Consider now a transformation of the probability vector $(p_i)_{i \in [n]}$ into $(\tilde{p}_i)_{i \in [n]}$, where $\tilde{p}$ satisfies for all $j \in [n]$,
\[
p_{\operatorname{low}} \leq \tilde{p}_j \leq \max \left\{ p_{\operatorname{low}}, p_j \right\}.
\]
In other words, in $\tilde{p}$ we only increase probabilities of bins $j \in [n]$, for which $p_j < p_{\operatorname{low}}$. Let us define $\mathcal{J} := \left\{ j \in [n] \colon p_j < p_{\operatorname{low}} \right\}$. For $b \geq (20C^2) n \log n$, this implies $\tilde{p}_j \geq \frac{1}{2n}$ for all $j \in [n]$.
Further,
let $(x_i^b)_{i \in [n]}$ be a load vector where the locations of the next $b$ balls are sampled according to $p$, and $(\tilde{x}_i^b)_{i \in [n]}$ be a load vector where these locations are sampled according to $\tilde{p}$. Clearly, there is a coupling so that for every $j \in [n] \setminus \mathcal{J}$, $x_j^b \geq \tilde{x}_j^b$ (since $p_j^b \geq \tilde{p}_j^b$). Further, for any $j \in \mathcal{J}$, by a union bound,
\[
\Pro{ \max_{j \in \mathcal{J}} x_j^b > 0 } \leq | \mathcal{J} | \cdot n^{-4} \leq n^{-3}.
\]
Hence it follows that, for any threshold $T > 0$,
\begin{align*}
\Pro{ \max_{j \in [n]} x_j^b \geq T } &\geq
\Pro{ \max_{j \in [n]} \tilde{x}_j^b \geq T} - \Pro{ \max_{j \in \mathcal{J}} x_j^b \geq T}
\geq \Pro{ \max_{j \in [n]} \tilde{x}_j^b \geq T} - n^{-3}.
\end{align*}
Therefore, in the remainder of the proof, we will lower bound $\Pro{ \max_{j \in [n] \setminus \mathcal{J}} \tilde{x}_j^b \geq T}$ for a suitable value of $T=\Omega( \sqrt{b / n \cdot \log n})$. We will also use the definition
\[
\tilde{\varphi}_j := b \cdot \tilde{p}_j - \frac{b}{n} + z_j.
\]
Finally, we define $\gamma=0.1$ as a (sufficiently) small constant.
\textbf{Case 1:} We have at least $n-n^{\gamma}$ bins for which $\tilde{\varphi}_j \leq - C \sqrt{b/n}$. Since $\sum_{i \in [n]} \tilde{\varphi}_i = 0$, this implies that there must be at least one bin with $j \in [n]$ with
$
\tilde{\varphi}_j \geq \frac{n-n^{\gamma}}{n^{\gamma}} \cdot C \cdot \sqrt{b/n} \geq 1/2 \cdot n^{1-\gamma} \cdot \sqrt{b/n}.
$
Further, using that the median of a $\mathsf{Bin}(N, q)$ r.v.~is either $\lfloor Nq \rfloor$ or $\lceil Nq \rceil$, then
\[
\Pro{ x_j^b \geq \Ex{ x_j^b } - \frac{1}{4} n^{1-\gamma} } \geq \Pro{ x_j^b \geq \left\lfloor \Ex{ x_j^b }\right\rfloor }
\geq 1/2, \] it follows that with probability at least $1/2$ we will have a large gap.
\textbf{Case 2:} We have at least $n^{\gamma}$ bins with $\tilde{\varphi}_j \geq - C \sqrt{b/n}$; call this set $\mathcal{B}$. We further know that, due to the definition of $\tilde{p}$, we have for all bins $j \in [n]$ that $\tilde{p}_j \geq \frac{1}{2n}$. Hence, we set $T:= b \cdot \tilde{p}_j + \kappa \cdot \sqrt{ b \cdot \tilde{p}_j \cdot \log n}$, and applying \cref{lem:binomial} yields for any bin $j \in \mathcal{B}$,
$
\Pro{ \tilde{x}_j^{b} \geq T } \geq n^{-\gamma/2}.
$
Since $\tilde{p}_j \geq \frac{1}{2n}$, $|\mathcal{B}| \geq n^{\gamma}$, the claim follows.\end{proof}
\section{Experiments} \label{sec:experiments}
In this section, we complement our theoretical analysis with some empirical results for the unweighted setting. In \cref{fig:beta_vs_batch_size}, we plot the gap of the \OnePlusBeta process for various batch sizes and different values of $\beta \in (0, 1]$ (where $\beta = 1$ corresponds to \TwoChoice). The plot strongly suggests the existence of a sweet spot for the optimal choice of $\beta$, which increases in the batch size $b$.
\begin{figure}[H]
\centering
\vspace{-0.2cm}
\includegraphics[scale=1]{figs/one_plus_beta_vs_batch.pdf}
\vspace{-0.4cm}
\caption{Empirical results for the unweighted \Batched setting for the \OnePlusBeta process for $n = 1.000$ bins and various batch sizes (averaged over $25$ runs).}
\label{fig:beta_vs_batch_size}
\end{figure}
In \cref{fig:eta_vs_batch_size}, we present the corresponding results of \cref{fig:beta_vs_batch_size} for
the \Quantile process (mixed with \OneChoice). As with the \OnePlusBeta process, the larger the batch size, the smaller the optimal mixing factor $\eta$. The \Quantile with the optimized mixing factor seems to perform slightly worse than the optimized \OnePlusBeta process.
\begin{figure}[H]
\centering
\vspace{-0.2cm}
\includegraphics[scale=1]{figs/quantile_vs_batch.pdf}
\vspace{-0.4cm}
\caption{Empirical gap for the unweighted \Batched setting for the \Quantile process (mixed with \OneChoice with probability $\eta \in (0, 1]$) for $n = 1.000$ bins and various batch sizes (averaged over $25$ runs).}
\label{fig:eta_vs_batch_size}
\end{figure}
In \cref{fig:process_comparison}, we plot the gap of \TwoChoice, \ThreeChoice and \OnePlusBeta versus the batch size. As expected, for small values of $b$, the gap of \TwoChoice and \ThreeChoice is small, but soon grows rapidly, diverging from the asymptotically optimal \OnePlusBeta processes.
\begin{figure}[H]
\centering
\includegraphics[scale=1]{figs/process_comparisons.pdf}
\vspace{-0.4cm}
\caption{Empirical gap for the unweighted \Batched setting for the gap of the \ThreeChoice, \TwoChoice and \OnePlusBeta with $\beta = 0.5$, $\beta = 0.7 \cdot \sqrt{(n\log n)/b}$ and $\beta = \sqrt{(n\log n)/b}$ for $n = 1.000$ bins vs batch size (averaged over $100$ runs).}
\label{fig:process_comparison}
\end{figure}
Finally, in \cref{tab:batch_large_values}, we show the performance of the \OnePlusBeta and \Quantile compared to \TwoChoice and \OneChoice with $b$ balls (which is the theoretically optimal attainable value), for $n \in \{ 10^4, 10^5 \}$. The for large $b$, the \OnePlusBeta has roughly half the gap of \TwoChoice and is close to the optimal value of \OneChoice.
\begin{table}[H]
\centering
\begin{tabular}{cc|c|c|c|c|}
\cline{3-6}
& & \TwoChoice & \Quantile & \OnePlusBeta & \OneChoice for $m = b$ \\ \hline
\multirow{3}{*}{\rotatebox{90}{$n=10^4$}}
& \multicolumn{1}{|c|}{$b = 20n$} & 36.45 & 30.15 & 26.60 & 19.00 \\ \cline{2-6}
& \multicolumn{1}{|c|}{$b = 50n$} & 70.10 & 45.75 & 39.00 & 29.75 \\ \cline{2-6}
& \multicolumn{1}{|c|}{$b = 80n$} & 100.85 & 55.65 & 46.80 & 35.80 \\ \hline
\multirow{3}{*}{\rotatebox{90}{$n=10^5$}}
& \multicolumn{1}{|c|}{$b = 20n$} & 39.90 & 34.1 & 29.95 & 22.40 \\ \cline{2-6}
& \multicolumn{1}{|c|}{$b = 50n$} & 75.55 & 50.3 & 44.20 & 34.30 \\ \cline{2-6}
& \multicolumn{1}{|c|}{$b = 80n$} & 111.10 & 64.9 & 55.20 & 41.95 \\ \hline
\end{tabular}
\caption{Empirical gap for \TwoChoice, \Quantile (with $\eta = \sqrt{(n \log n)/b}$) and \OnePlusBeta (with $\beta = 0.7 \sqrt{(n \log n)/b}$) for the \Batched setting with $b \in \{ 20n, 50n, 80n \}$ and $n \in \{ 10^3, 10^4 \}$ (averaged over $20$ runs).}
\label{tab:batch_large_values}
\end{table}
\section{Conclusions} \label{sec:conclusions}
In this work, we revisited the outdated information setting of \cite{BCEFN12}, where balls are allocated to bins in batches of sizes $b$, and only then the load information is updated. We established that by defining the mixing factor $\beta$ carefully as a function of the batch size $b$, $(1+\beta)$ achieves the asymptotically optimal gap for any $b \leq n \log n$. That is, by having $\beta$ chosen not too large, $(1+\beta)$ circumvents the ``herd behavior'' (as called in \cite{M00}), where some of the previously underloaded bins are chosen too frequently, turning them into heavily overloaded bins in the next batch. Similarly, $\beta$ should also not be too small, as otherwise the pocess would be too close to \OneChoice.
There are several directions for future work. First, recall that our lower bounds apply to a large class of processes which allocate all balls within the \emph{same batch} independently. However, there are processes which allocate multiple balls in a coordinated way. For example, the process of Park~\cite{P11} draws $d$ samples, and then places into each of the $k$ least loaded bins one ball. It would be interesting to explore the gap of this type of processes in the batched setting. A second avenue is to analyze \TwoThinning processes (and in particular processes that use a fixed load threshold relative to the average) in outdated information settings. An experimental study of threshold processes with outdated information was already conducted in 1989~\cite[Figure 8]{MTS89}, but no rigorous bounds were proven. Finally, one could study models where the load information of bins is updated at different rates, depending on the specific bin. In such a setting, when deciding between sampled bins, both their reported load estimates and update rates should be taken into account.
\clearpage
\bibliographystyle{ACM-Reference-Format-CAM}
| {'timestamp': '2023-02-10T02:04:17', 'yymm': '2302', 'arxiv_id': '2302.04399', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04399'} | arxiv |
\section{Introduction}
As defined by the National Highway Traffic Safety Administration in the United States (NHTSA), distracted driving is ``any activity that diverts attention from driving''~\cite{national20162015,resalat2015practical}, such as drinking, talking to passengers, etc. Nowadays, distracted driving has become a huge threat to modern society. For example, as reported by the NHTSA, in the United States, traffic accidents caused by distracted driving led to 3,142 or 8.7 percent of all accidents in 2019~\cite{national2019}.
Recently, Advanced Driver Assistance Systems (ADAS) are being developed to provide technologies that alert the driver to potential problems for preventing accidents. As one of the basic and most important technologies of ADAS, distracted driver recognition (DDR) has attracted much interest from the academic society~\cite{iranmanesh2018adaptive,petermeijer2015vibrotactile,7053946,nemcova2021multimodal}. Many approaches have been developed to use the images taken by a dashcam to recognize whether the driver is driving safely or behaving some categories of distracted driving actions~\cite{abouelnaga2017real,5732698,ai2019double,6518125,baheti2018detection,dhakate2020distracted}. With the effort of the researchers, the recognition accuracy of the DDR task has been increasing, especially when convolutional neural networks (CNNs) are employed in this field~\cite{abouelnaga2017real,ai2019double,zhang_2016}, following the success of CNNs in many other fields. However, the accuracy improvement is generally brought by increased CNN parameter size. The huge parameter size becomes a big problem for real-world applications because of the limitation of vehicle-mounted computing equipment. The purpose of this paper is to design a lightweight and fast network for DDR with high DDR accuracy, which will be very useful for intelligent transportation system (ITS) applications. In the remainder of this section, we start with a review of the existing DDR methods and then briefly present a general overview of our approach.\IEEEpubidadjcol
\subsection{Existing Distracted Driver Recognition Approaches}
Recently, with the success of CNNs in the computer vision field, it has become common to use deep learning models to solve distracted driver recognition (DDR) tasks~\cite{9405644,yan2016driving,abouelnaga2017real}. For example, Yan \textit{et al}.~\cite{yan2016driving} embedded local neighborhood operations and trainable feature selectors within a deep CNN, and by doing so, meaningful features could be selected automatically to recognize distracted drivers.
However, the introduction of CNNs causes the problem of huge parameter size. There are some recent lightweight networks designed for general-purpose computer vision, such as MobileNet~\cite{howard2017mobilenets}, MobileNetV2~\cite{8578572} and SqueezeNet~\cite{iandola2016squeezenet}. However, these lightweight networks are not specifically designed for DDR, and therefore is still room for improvement regarding DDR accuracy and the number of parameters.
There are now also some lightweight networks designed specifically for DDR by hand. For example, Baheti \textit{et al}.~\cite{baheti2020towards} propose the MobileVGG, which reduces the number of parameters by replacing the traditional convolution in the classical VGG structure with depth-wise convolution and point-wise convolution. D-HCNN~\cite{qin2021distracted} is another example, which uses an architecture containing four convolution blocks with the filters of rather large spatial sizes and achieves high performance with small number of filters. However, these networks were designed entirely by hand based on experience with networks used for general-purpose computer vision tasks, so the potential of the network structure could not be reached to the maximum extent possible. Moreover, D-HCNN requires histogram of oriented gradients (HOG)~\cite{dalal2005histograms} in addition to RGB image as the input. HOG counts occurrences of gradient orientation in localized portions of an image and describes the appearance and shape of the local objects. The computation of HOG requires extra processing effort and is not favorable for real-world applications.
In this work, we search for an optimal architecture for the DDR task, which has less parameter size and higher accuracy than the above studies. Our approach is designed by NAS rather than totally by hand and only requires RGB images as inputs.
\subsection{A Brief Overview of the Proposed Approach}
To solve this problem, we propose a distillation-based neural architecture search and knowledge transfer framework. Overall, the proposed framework is based on knowledge distillation~\cite{gou2021knowledge}, which refers to the process of transferring knowledge from a large model (teacher network) to a smaller one (student network). The proposed framework includes three steps: (\romannumeral1) constructing a strong teacher network; (\romannumeral2) searching and define the architecture of a student network under the supervision of the teacher network; (\romannumeral3) transferring the knowledge from the teacher network to the student network.
\begin{figure}[t!]
\centering\includegraphics[width=\linewidth]{images/illumination.PNG}
\caption{Examples of images taken by a camera monitoring the driver's behavior under different illumination conditions. The ground-truth label of the images is ``Drink''. The images are from the AUC Distracted Driver Dataset~\cite{alotaibi2019distracted}.}
\label{fig:illumination}
\end{figure}
\textbf{Teacher Network.} The teacher network is built based on progressive learning (PL). PL is a training strategy that starts the training from shallow layers and then progressively deepens the model by adding new layers to the model~\cite{9405644,yan2016driving,abouelnaga2017real}. In some studies, PL is also regarded as partitioning a network into several segments and progressively training the segments from shallow to deep~\cite{du2020fine,zhao2021pmg}. Progressive learning (PL) was originally proposed for generative adversarial networks~\cite{ahn2018image}. It started with low-resolution images, and then progressively increased the resolution by adding layers to the networks. For example, Wang \textit{et al}.~\cite{wang2018fully} proposed to progressively cascade residual blocks to increase the stability of processing extremely low-resolution images with very deep CNNs. Shaham \textit{et al}.~\cite{shaham2019singan} proposed to reconstruct high-resolution images by a progressive multi-scale approach that progressively up-sample the output from the previous level. Recently, PL has been also applied in fine-grained image classification tasks. For example, Du \textit{et al}.~\cite{du2020fine} and Zhao \textit{et al}.~\cite{zhao2021pmg} used PL to fuse information from previous levels of granularity and aggregate the complementary information across different granularities.
In this work, we introduce PL into DDR to solve the problem caused by various illumination conditions, such as sunlight and shadow. As shown in Figure~\ref{fig:illumination}, in the real world, the dashcam commonly records the driver's behavior in different illuminations, while the color itself is susceptible to the influence of illumination. RGB information changes considerably under different illuminations, which causes strong intra-class variance in the DDR task. Such intra-class variance affects CNNs from shallow to deep layers. The shallow layers of CNN tend to learn basic patterns, such as different orientations, parallel lines, curves, circles, etc., while the deep layers tend to encode the patterns learned by shallow layers to capture more semantically meaningful information, such as hands, body, etc~\cite{zeiler2014visualizing}. Following the experience learned with bright illumination on what basic patterns are discriminative, the shallow layers of a CNN might fail to find enough discriminative basic patterns in the shadows.
In this work, we progressively train the teacher network for several stages. During the stages, the training starts from shallow layers and progressively goes deeper with random brightness augmentation~\cite{imgaug} to increase the robustness to the illumination of the layers from shallow to deep. Thereafter, we use the original image to train the aggregation of the models of all stages, considering that the random brightness augmentation might lose some visual information.
\textbf{Student Network.}
The student network is a compact network that should be able to achieve high recognition performance. This leads to a research question: how to define the architecture of the student network to make it compact, lightweight, yet powerful for DDR, by utilizing the knowledge of the teacher network as supervision?
To answer this question, we turn our eyes to neural architecture search (NAS). NAS refers to the process of automating architecture engineering to learn a network topology that can achieve best performance on a certain task~\cite{elsken2019neural,zoph2018learning,bashivan2019teacher}.
The major components of NAS includs searching space, searching algorithm, and evaluation strategy~\cite{elsken2019neural}. With the prior knowledge about typical properties of architectures, NAS approaches commonly define the searching space as a large set of operations (e.g., convolution, fully-connected, and pooling). Each possible architecture in the searching space is evaluated by a certain evaluation strategy~\cite{elsken2019neural,zoph2018learning} and the searching process is controlled by certain searching algorithms, such as reinforcement learning~\cite{zoph2018learning,liu2018progressive,pham2018efficient}, evolutionary search~\cite{real2019regularized}, differentiable search~\cite{DARTS}, or other learning algorithms~\cite{Kirthevasan2018,bashivan2019teacher,wang2021teacher,NEURIPS2018_933670f1}. NAS commonly defines a searching space at first and then uses a certain policy to generate a sequence of actions in the searching space to specify the architecture.
In this work, we propose a new searching approach for DDR based on the characteristics of the images in the DDR task. We introduce how we define the searching space and the searching strategy as described below.
\textbf{Searching Space.} The images in the DDR task have less diversity and much stronger inter-class similarity than those in many other image recognition tasks. For example, in the fine-grained image recognition task of CUB Birds~\cite{WelinderEtal2010}, the images contain the birds of different species, the background of different habitats, etc. However, in the DDR task, almost all the images can be roughly described as ``a human is driving.'' Thousands of images showing different driving behaviors might be performed by the same person, and the backgrounds of all the images are actually the interior of the same car.
Due to the above reason, a large proportion of the visual information does not provide discriminative clues in the DDR task. For example, in CUB Birds, the color of wings, the shape of heads, etc. all provide useful information. Sometimes, even the background provides useful information as a bird image with the sea as the background highly likely shows a certain sea bird. In contrast, in the DDR task, the color of the driver's clothes, the shape of the driver's glasses or hat, almost all the background, etc. are useless information.
Consequently, the models for the DDR task do not need a huge number of object detectors. The key is to explore some discriminative objects, which are quite universal among different driving behaviors, such as hands, body pose, steering wheel, etc. In CNNs, depth influences the flexibility, and each channel of the filters acts as an object detector~\cite{zeiler2014visualizing}. Thus, the architecture for DDR does not require a very deep structure and a huge number of channels. The above claim is backed up by some earlier observations that the architecture of a decreased number of layers and channels can achieve good results in DDR~\cite{baheti2020towards,qin2021distracted}.
On the other hand, the architecture for DDR must be able to effectively find and capture useful clues from the limited discriminative objects, which is very difficult because: (\romannumeral1) the inter-similarity is strong; (\romannumeral2) the key objects vary largely in size (e.g., hands and body). In this work, we introduce pyramidal convolution (PyConv)~\cite{duta2020pyramidal} into the DDR task. In a standard convolution layer, all the filters have the same spatial size. In contrast, a PyConv layer uses convolution filters of different spatial sizes, and the filters are possible to divide into several groups. Thus, PyConv has very flexible receptive fields, which is beneficial to capture key objects of different sizes. Also, due to its flexibility, PyConv provides a large pool of potential network architectures. In this work, the main searching space is defined as the candidate combinations of filters' spatial sizes and the number of groups. Moreover, the pooling method applied in the model also influences the performance of capturing key objects~\cite{yu2014mixed}. We also search whether to use max pooling or average pooling in the layers.
\textbf{Searching Strategy.} Most of the NAS methods train the possible candidate networks one by one, and evaluate the performance of the trained candidate networks on a validation set~\cite{elsken2019neural,9352235}. The evaluation results are used as metrics to update the architecture searching process. However, the process of candidate evaluation could be very expensive in terms of time, memory, computation, etc. In this work, since we have already constructed a powerful teacher network, we directly use the teacher network to guide the searching. Specifically, we first build a super student network that aggregates all the candidates with a weighted sum, whose weights are regarded as the possibility of choosing each candidate. Then the super student network is trained to learn from the teacher network by knowledge distillation. After the training, the candidates with the maximum weight are chosen to build the architecture of the student network.
After defining the architecture of the student network, the teacher network is utilized again to transfer knowledge to the student network.
Our contributions are summarized as follows:
\begin{itemize}
\item[-] We propose a novel framework for solving the DDR task with high accuracy and a small number of parameters. The research question is solved by the proposed searching strategy.
\item[-] We mainly carried out the experiments of training the teacher network, defining the student network, and evaluating the performance of the teacher and student networks on two image-based DDR datasets, namely the AUC Distracted Driver Dataset (AUCD2)~\cite{alotaibi2019distracted} and Statefarm Distracted Driver Detection Dataset (SFD3)~\cite{statefarm}. The experimental results show that the teacher network achieves 96.35\% on the AUCD2 and 99.86\%--99.91\% in different splitting settings on the SFD3 with 44.62M parameters, which outperforms the previous state-of-the-art approaches on both datasets. Note that the previous best approach on AUCD2 requires 140M parameters.
\item[-] The student network achieves 95.64\% on the AUCD2 and 99.86\%--99.91\% in different splitting settings on the SFD3 with only 0.42M parameters.
\item[-] The student network architecture can be extended into a spatial-temporal 3D convolutional neural network by replacing the 2D layers with spatial-temporal 3D layers~\cite{hara2018can,tran2015learning,qiu2017learning,carreira2017quo}. We carried out comprehensive experiments in all the tasks of the Drive\&Act Dataset (DAD)~\cite{drive_and_act_2019_iccv}, which is a video-based DDR dataset. The 3D student network is 0.89\%--29.00\% higher than the previous best accuracy in the validation set and 2.05\%--30.88\% higher than the previous best accuracy in the test set. The 3D student network requires only 2.03M parameters.
\end{itemize}
\section{Details of the Proposed Approach}
\begin{algorithm}[t!]
\caption{Building the teacher network based on progressive learning}
\label{alg:algorithm1}
\textbf{Require}: Given a dataset $\mathcal{D}=\{({\rm input}^i,~p_{\rm truth}^i)\}_{i=1}^{I}$ ($I$ is the total number of images in $\mathcal{D}$), and $N$ stages $\{s_1, s_2, ..., s_n, ..., s_N\}$ of the backbone feature extractor $E$.
\begin{algorithmic}[1]
\FOR{epoch $\in$ [1, num\_of\_epoch]}
\FOR{($\rm input$, $p_{\rm truth}$) in $\mathcal{D}$}
\FOR{$n$ $\in$ [1, $N$]}
\STATE ${\rm input_n} = {\rm Brightness\_augmentor}({\rm input})$
\STATE $x_n$ = $s_n({\rm input}_n)$
\STATE $v_n$ = $\phi_n(x_n)$
\STATE $p_n$ = $\psi_n(v_n)$
\STATE $\mathcal{L}_n$ = $\mathcal{L}_{\rm cls}(p_n,p_{\rm truth})$
\STATE \textbf{BACKPROP}($\mathcal{L}_n$)
\ENDFOR
\FOR{$n$ $\in$ [1, $N$]}
\STATE ${\rm input}_n = {\rm input}$
\STATE $x_n$ = $s_n({\rm input}_n)$
\STATE $v_n$ = $\phi_n(x_n)$
\ENDFOR
\STATE $v_{N+1}$ = $f^{\rm concat}$($v_1$, $v_2$, ..., $v_N$)
\STATE $p_{N+1}$ = $\psi_{N+1}(v_{N+1})$
\STATE $\mathcal{L}_{N+1}$ = $\mathcal{L}_{\rm cls}(p_{N+1},p_{\rm truth})$
\STATE $\textbf{BACKPROP}$($\mathcal{L}_{N+1}$)
\ENDFOR
\ENDFOR
\end{algorithmic}
\end{algorithm}
\subsection{Teacher Network Construction}
In this subsection, we introduce the details of the teacher network. Let $E$ be the backbone feature extractor, which can be based on any state-of-the-art models, such as SKResNeXt50~\cite{li2019selective}, etc. The layers of $E$ are divided into $N$ segments $\{m_1, m_2, ..., m_n, ..., m_N\}$. Assume $\{s_1, s_2, ..., s_n, ..., s_N\}$ be $N$ consecutive stages from shallow to deep. At each stage of $\{s_1, s_2, ..., s_n, ..., s_N\}$, the training always starts from the first layer of $E$. From $s_1$ to $s_N$, the training gradually goes deeper and covers more layers of $E$. That is, the segments under training at stage $s_n$ are $m_1+m_2+...+m_n$. Let $\{x_1, x_2, ..., x_n, ..., x_N\}$ denote the the output feature maps at $\{s_1, s_2, ..., s_n, ..., s_N\}$. Let $x_n\in\mathbb{R}^{H_n\times W_n \times C_n}$ denote the output feature map at the stage $s_n$, and $H_n$, $W_n$, and $C_n$ respectively denotes the height, width, and the number of channels of $x_n$. We use a set of operations $\{\phi_1(.), \phi_2(.), ..., \phi_n(.), ..., \phi_N(.)\}$ to respectively process $\{x_1, x_2, ..., x_n, ..., x_N\}$ into 1D vectorial descriptors $\{v_1, v_2, ..., v_n, ..., v_N\}$, where $v_n\in\mathbb{R}^{L}$. The $\phi_n(.)$ corresponding to $x_n$ is defined as:
\begin{align}
&v_n = \phi_n(x_n) = f^{\rm max\_pool}_{H\times W}(x_n''),\\
&x_n''=f^{\rm ReLU}(f^{\rm bn}(f^{\rm conv}_{3\times3\times \frac{L}{2} \times L}(x_n'))),\\
&x_n'=f^{\rm ReLU}(f^{\rm bn}(f^{\rm conv}_{1\times1\times C \times \frac{L}{2}}(x_n))),
\end{align}
where $f^{\rm max\_pool}_{H\times W}(.)$ denotes a max-pooling operation whose window size is $H\times W$. $f^{\rm conv}(.)$ illustrates the 2D convolution operation by kernel size. For example, $f^{\rm conv}_{1\times1\times C \times \frac{L}{2}}(.)$ denotes a 2D convolution operation whose kernel size is $1\times1\times C \times \frac{L}{2}$ ($1\times1$ is the spatial size, $C$ is the number of input channels, and $\frac{L}{2}$ is the number of output channels). $f^{\rm bn}(.)$ denotes the batch normalization operation~\cite{ioffe2015batch}, and $f^{\rm ReLU}(.)$ denotes the ReLU operation.
Thereafter, we use a set of operations $\{\psi_1(.)$, $\psi_2(.)$, ..., $\psi_n(.)$, ..., $\psi_N(.)\}$ to respectively process $\{v_1$, $v_2$, ..., $v_n$, ..., $v_N\}$ to predict the probability distribution $\{p_1$, $p_2$, ..., $p_n$, ..., $p_N\}$ over the classes at each stage:
\begin{align}
\begin{split}
p_n &= \psi_n(v_n)\\
&=f^{\rm fc}_{\frac{L}{2}\times K}(f^{\rm ReLU}(f^{\rm bn}(f^{\rm fc}_{L\times\frac{L}{2}}(f^{\rm bn}(v_n))))),
\end{split}
\end{align}
where $p_n\in\mathbb{R}^{K}$, and $K$ denotes the number of the classes of driving behaviors. $f^{\rm fc}_{\frac{L}{2}\times K}(.)$ denotes a fully connected layer whose input size is $\frac{L}{2}$ and the output size is $K$. $f^{\rm fc}_{L\times \frac{L}{2}}(.)$ denotes a fully connected layer whose input size is $L$ and the output size is $\frac{L}{2}$.
After the last stage $s_n$, we add an additional stage by concatenating $v_1$, $v_2$, ..., $v_N$ and generating the concatenated vector into the probability distribution over the classes as:
\begin{align}
\begin{split}
p_{N+1} &= \psi_{N+1}(v_{N+1})\\
&=f^{\rm fc}_{\frac{L}{2}\times K}(f^{\rm ReLU}(f^{\rm bn}(f^{\rm fc}_{NL\times\frac{L}{2}}(f^{\rm bn}(v_{N+1}))))),
\end{split}\\
v_{N+1} &= f^{\rm concat}(v_1,v_2, ..., v_n, ..., v_N),
\end{align}
where $f^{\rm concat}(.)$ denotes the concatenation operation. Now, we have $N+1$ prediction probability distributions $\{p_1$, $p_2$, ..., $p_n$, ..., $p_N$, $p_{N+1}\}$. The teacher network is trained by using a cross entropy loss $\mathcal{L}_{\rm cls}(.)$ to minimize the distance between ground truth label $p_{\rm truth}$ and each prediction probability distribution of $\{p_1$, $p_2$, ..., $p_n$, ..., $p_N$, $p_{N+1}\}$:
\begin{align}
\mathcal{L}_{\rm cls}(p_n,p_{\rm truth}) = -\sum^{K}_{k=1}p_{\rm truth}^{(k)} \log(p_{n}^{(k)}),
\end{align}
where $p_{n}^{(k)}$ denotes the probability that the input belongs to the category $k$ at the stage $s_n$. $p_{\rm truth}^{(k)}$ equals to 1 if it is true that the input belongs to the category $k$, and equals to 0 on the contrary.
The overall algorithm of building the teacher network is given in Algorithm~\ref{alg:algorithm1}. For the stages $s_1\sim s_n$, the input images are augmented with Imgaug~\cite{imgaug}.
\subsection{Distillation-Based Neural Architecture Search for the Student Network}
The computation overhead, including speed and parameter size, acts as an extremely crucial role for DDR. According to the experiences of previous studies~\cite{qin2021distracted,baheti2018detection}, it is much more favorable to use large convolution filters rather than deep layers because the former is able to compute in parallel to achieve a fast processing speed that satisfies the requirements of the real-world application. Thus, in this work, we design the student network to have four convolutional blocks, which are followed by a global average pooling layer (GAP) and a fully connected (FC) layer for predicting the probability distribution over the classes.
\begin{figure*}[t!]
\centering\includegraphics[width=\linewidth]{images/distillation.png}
\caption{Illustration of the searching process. ``CAND'' is the abbreviation for ``candidate''. In the super student network, there are several candidates for the convolutional architectures of each block. Besides, there are two candidates of the pooling method, namely average pooling and max pooling, in each block. The candidates of convolutional architecture and pooling methods for each block are aggregated by the weighted sum. $\alpha$ and $\beta$ are the learnable weights. ``GAP'' means global average pooling and ``FC'' means the fully-connected operation. The super student network is trained to learn from the teacher network by knowledge distillation. After the training, only the candidates with the maximum weight are kept and forms the student network.}
\label{fig:ret}
\end{figure*}
For each block, we use pyramidal convolution (PyConv)~\cite{duta2020pyramidal} rather than standard convolution. PyConv contains a pyramid of kernels, where each level involves different types of filters with varying sizes. Using PyConv for DDR has two benefits. First, PyConv can capture different levels of details in the scene. A filter of a smaller kernel size has smaller receptive fields and thus can capture more local information and more detailed clues. A filter of a bigger kernel size has bigger receptive fields and thus can ``see'' more information at once and capture relatively more global information, such as the dependencies among some local patterns, some large objects, etc. Such multi-level details are very important for recognizing driver behaviors. Second, PyConv is flexible and extensible, giving a large space of potential architecture designs. That is, PyConv gives strong potential to search for a lightweight architecture.
At the end of each block, we use a pooling layer to downsample the feature maps. Two types of pooling layers are widely used for this objective: max pooling and average pooling. We define our search space as the candidates of different designs of PyConv and different pooling types in the four convolutional blocks.
As shown in Figure~\ref{fig:ret}, the overall process of defining the architecture of the student network is given as: at first, we construct a super student network covering all the candidates of each block. In the super student network, the output feature maps of the candidates of each block are aggregated by a weighted sum to become the input of the next block. The sum weights are learnable and represent the probability of choosing the candidates. Then the super student network is trained to learn from the teacher network. Thereafter, the final architecture of the student network is derived by selecting the candidate with the maximum probability.
Specifically, let $\{b_1, b_2, b_3, b_4\}$ denote the four blocks of the student network and super student network. $\{\omega^1_{b}(.), \omega^2_{b}(.), ..., \omega^m_b(.), ..., \omega_b^M(.)\}$ denote $M$ different candidates of PyConv for the block $b$. $\{f^{\rm avg\_pool}_b(.), f^{\rm max\_pool}_b(.)\}$ denotes the candidates of using average pooling or max pooling layer at the end of the block $b$. Given the feature map $X^{\rm in}_b$ outputted by the previous block, the output feature map $X^{\rm out}_b$ of the block $b$ in the super student network is defined as:
\begin{align}
\begin{split}
X^{\rm out}_b = &\beta_b^{\rm avg} f^{\rm avg\_pool}_b(\sum_{m=1}^M \alpha^m_b \omega^m_{b} (X^{\rm in}_b))\\
&+ \beta_b^{\rm max} f^{\rm max\_pool}_b(\sum_{m=1}^M \alpha^m_b \omega^m_{b} (X^{\rm in}_b)),
\end{split}
\end{align}
where $\{\alpha^1_{b}, \alpha^2_{b}, ..., \alpha^m_b, ..., \alpha_b^M\}$ and $\{\beta_b^{\rm avg}, \beta_b^{\rm max}\}$ are the probabilities of choosing the corresponding candidates, and they are computed as:
\begin{align}
&\alpha^m_{b} = \frac{\exp(\hat{\alpha}^m_{b})}{\sum^{M}_{j=1} \exp(\hat{\alpha}^j_{b})},\\
&\beta^g_{b} = \frac{\exp(\hat{\beta}^g_{b})}{\exp(\hat{\beta}^{\rm avg}_{b})+\exp(\hat{\beta}^{\rm max}_{b})},~ g=\{\rm avg,max\},
\end{align}
where, $\{\hat{\alpha}^1_{b}, \hat{\alpha}^2_{b}, ..., \hat{\alpha}^m_b, ..., \hat{\alpha}_b^M\}$ and $\{\hat{\beta_b}^{\rm avg}, \hat{\beta_b}^{\rm max}\}$ are learnable parameters that are all initialized as 1 and optimized during the training.
All the blocks of $\{b_1, b_2, b_3, b_4\}$ of the super student network are constructed by the process introduced above. The output feature map of $b_4$ is processed by the GAP and FC layers to predict the probability distribution over the classes ($p_{\rm super}$). As mentioned above, after the training of the teacher network, we only use $p_{N+1}$ of the teacher network for category prediction. The super student network is trained with the search loss $\mathcal{L}_{\rm search}(.)$ defined as:
\begin{align}
\label{equ:loss1}
\begin{split}
&\mathcal{L}_{\rm \rm search}(p_{\rm super}, p_{N+1}, p_{\rm truth}) =\\ &\lambda \mathcal{L}_{\rm mse}(p_{\rm super},p_{N+1}) + (1-\lambda)\mathcal{L}_{\rm cls}(p_{\rm super},p_{\rm truth}),
\end{split}
\end{align}
where ${L}_{\rm mse}(.)$ denotes the mean squared error loss, and $\lambda$ is a manual hyperparameter. During the training of the super student network, the parameters of the teacher network are fixed. After the training, we only keep the candidate with the maximum probability and prune all the other candidates for each block to construct the student network.
\begin{figure*}[t!]
\centering\includegraphics[width=\linewidth]{images/SFD3.png}
\caption{Sample images of distracted driving behaviors on the Statefarm Distracted Driver Detection Dataset (SFD3)~\cite{statefarm}.}
\label{fig:sfd3}
\end{figure*}
\begin{figure*}[ht!]
\centering\includegraphics[width=\linewidth]{images/AUCD2.png}
\caption{Sample images of distracted driving behaviors on the AUC Distracted Driver Dataset (AUCD2)~\cite{alotaibi2019distracted}.}
\label{fig:aucd2}
\end{figure*}
\begin{figure*}[t!]
\centering\includegraphics[width=\linewidth]{images/drive_act.png}
\caption{Sample frames of distracted driving behaviors on the Drive\&Act Dataset (DAD)~\cite{drive_and_act_2019_iccv}. The video clips are labeled with multiple annotations, including different categories of fine-grained activities, scenarios, atomic actions, objects, locations, together with possible combinations of the atomic actions, objects, and locations.}
\label{fig:drive_act}
\end{figure*}
\subsection{Knowledge Transfer}
In the former subsection, we use the teacher network to guide the search of the student network architecture, and in this subsection, we use it to transfer knowledge to the student network. Assume that $p_{\rm student}$ is the probability distribution over the classes predicted by the student network. The student network is trained with the knowledge transfer loss $\mathcal{L}_{\rm trans}(.)$ defined as:
\begin{align}
\label{equ:loss2}
\begin{split}
&\mathcal{L}_{\rm trans}(p_{\rm student}, p_{N+1}, p_{\rm truth}) =\\ &\lambda \mathcal{L}_{\rm mse}(p_{\rm student},p_{N+1}) + (1-\lambda)\mathcal{L}_{\rm cls}(p_{\rm student},p_{\rm truth}).
\end{split}
\end{align}
\section{Datasets and Implementation Details}
\subsection{Dataset Description}
The experiments are conducted using two types of datasets: image-based DDR dataset and video-based DDR dataset. The image-based DDR task requires recognizing the driver's behavior from each given image. The video-based DDR task requires recognizing the driver's behavior from each given video clip containing several frames. We mainly carried out the experiments of training the teacher network, defining the student network, and evaluating the performance of the teacher and student networks on the image-based DDR datasets. Then, we obtained an extremely lightweight yet powerful student network for the image-based DDR task. Thereafter, following Hara \textit{et al.}~\cite{hara2018can}, we extended the student network from 2D to 3D for the video-based DDR task.
For the image-based DDR task, we carried out experiments on two standard benchmark datasets for DDR: the Statefarm Distracted Driver Detection Dataset (SFD3)~\cite{statefarm} and the AUC Distracted Driver Dataset (AUCD2)~\cite{alotaibi2019distracted}. These two datasets are the most widely used datasets, and have been used for many studies on DDR. Both of the two datasets are composed of one safe driving action and nine distracted driving actions including (\romannumeral1) text right, (\romannumeral2) talk right, (\romannumeral3) text left, (\romannumeral4) talk left, (\romannumeral5) adjust radio, (\romannumeral6) drink, (\romannumeral7) reach behind, (\romannumeral8) hair and makeup, and (\romannumeral9) talk to passenger. The images of both datasets are taken by dashboard cameras recording the driver's behavior. The sample images of the SFD3 and AUCD2 are shown in Figure~\ref{fig:sfd3} and Figure~\ref{fig:aucd2}, respectively.
SFD3 is one of the most influential public datasets in the field of DDR. There are 22,424 images for training (around 2,000 images in each category) and 79,728 unlabeled images for testing. Since SFD3 does not provide the labels for the testing images, we follow the common practice of previous studies to perform experiments on the training dataset. We randomly split the training dataset of SFD3 as training image: testing image = 7:3~\cite{dhakate2020distracted,qin2021distracted}, 7.5:2.5~\cite{masood2020detecting,hssayeni2017distracted,qin2021distracted}, 8:2~\cite{majdi2018drive,janet2020real,huang2020hcf,qin2021distracted,zhang_2016}, 9:1~\cite{okon2017detecting,qin2021distracted}. In this work, for each proportion of the train-test partition, we randomly split the images 10 times and report the average accuracy.
AUCD2 is another widely used public dataset for DDR. It has 17,308 RGB frames, of which 12,977 are for training, while the remaining 4,331 are for testing.
For the video-based DDR task, we utilized the Drive\&Act Dataset (DAD)~\cite{drive_and_act_2019_iccv}. This is a large-scale video dataset consisting of various driver activities, with more than 9.6 million frames. As shown in Figure~\ref{fig:drive_act}, the DAD provides multiple annotations for performing three types of recognition tasks on the video clips. The first task is the scenario recognition task, which requires recognizing the top-level activities (e.g., work and drink) from each given video clip. There are totally 12 different scenario categories. The second task is the fine-grained activity recognition task, which requires recognizing the specific semantic actions (e.g., open laptop, close bottle, etc.) from each video clip. There are totally 34 different categories of fine-grained activities. The third task is the atomic action unit recognition task. The atomic action units portray the lowest degree of abstraction and are basic driver interactions with the environment. The annotations of the atomic action units involve triplets of atomic action, object, and location, which are detached from long-term semantic meaning and can be regarded as building blocks for complex activities. There are five categories of atomic actions (e.g., reach for), 17 categories of objects (e.g., automation button), 14 categories of locations (e.g., center console back), and 372 possible combinations.
\begin{table*}[t!]
\centering
\caption{Candidates of each block}\label{tab:candidates}
\begin{tabular}{l|ll|ll|ll|ll}
\hline
Blocks &
\multicolumn{2}{l|}{Block 1 ($b_1$)} &
\multicolumn{2}{l|}{Block 2 ($b_2$)} &
\multicolumn{2}{l|}{Block 3 ($b_3$)} &
\multicolumn{2}{l}{Block 4 ($b_4$)} \\ \hline
Output Size &
\multicolumn{2}{l|}{112$\times$112, 32} &
\multicolumn{2}{l|}{56$\times$56, 64} &
\multicolumn{2}{l|}{28$\times$28, 128} &
\multicolumn{2}{l}{14$\times$14, 256} \\ \hline
Candidate 1 &
\begin{tabular}[c]{@{}l@{}}$\begin{bmatrix} 11\times11,16, 1\\7\times7,16, 1\end{bmatrix}$\end{tabular} &
\begin{tabular}[c]{@{}l@{}}Avg. Pool\\ $\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} &
\begin{tabular}[c]{@{}l@{}}$\begin{bmatrix} 9\times9,32, 1\\5\times5,32, 1\end{bmatrix}$\end{tabular} &
\begin{tabular}[c]{@{}l@{}}Avg. Pool\\ $\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} &
\begin{tabular}[c]{@{}l@{}}$\begin{bmatrix} 5\times5,64, 1\\3\times3,64, 1\end{bmatrix}$\end{tabular} &
\begin{tabular}[c]{@{}l@{}}Avg. Pool\\ $\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} &
\begin{tabular}[c]{@{}l@{}}$\begin{bmatrix} 3\times3,128, 1\\1\times1,128, 1\end{bmatrix}$\end{tabular} &
\begin{tabular}[c]{@{}l@{}}Avg. Pool\\ $\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} \\
Candidate 2 &
\begin{tabular}[c]{@{}l@{}}$\begin{bmatrix} 11\times11,16, 1\\5\times5,16, 1\end{bmatrix}$\end{tabular} &
\begin{tabular}[c]{@{}l@{}}Max Pool\\ $\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} &
$\begin{bmatrix} 9\times9,32, 1\\5\times5,32, 2\end{bmatrix}$ &
\begin{tabular}[c]{@{}l@{}}Max Pool\\ $\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} &
$\begin{bmatrix} 5\times5,64, 1\\3\times3,64, 2\end{bmatrix}$ &
\begin{tabular}[c]{@{}l@{}}Max Pool\\ $\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} &
$\begin{bmatrix} 3\times3,128, 1\\1\times1,128, 2\end{bmatrix}$ &
\begin{tabular}[c]{@{}l@{}}Max Pool\\ $\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} \\
Candidate 3 &
\begin{tabular}[c]{@{}l@{}}$\begin{bmatrix} 11\times11,16, 1\\3\times3,16, 1\end{bmatrix}$\end{tabular} &
- &
$\begin{bmatrix} 9\times9,16, 1\\5\times5,16, 4\end{bmatrix}$ &
- &
$\begin{bmatrix} 5\times5,64, 1\\3\times3,64, 4\end{bmatrix}$ &
- &
$\begin{bmatrix} 3\times3,128, 1\\1\times1,128, 4\end{bmatrix}$ &
- \\
Candidate 4 &
\begin{tabular}[c]{@{}l@{}}$\begin{bmatrix} 11\times11,16, 1\\1\times1,16, 1\end{bmatrix}$\end{tabular} &
- &
$\begin{bmatrix} 9\times9,32, 1\\3\times3,32, 1\end{bmatrix}$ &
- &
$\begin{bmatrix} 5\times5,64, 1\\1\times1,64, 1\end{bmatrix}$ &
- &
- &
- \\
Candidate 5 &
\begin{tabular}[c]{@{}l@{}}-\end{tabular} &
- &
$\begin{bmatrix} 9\times9,32, 1\\3\times3,32, 2\end{bmatrix}$ &
- &
$\begin{bmatrix} 5\times5,64, 1\\1\times1,64, 2\end{bmatrix}$ &
- &
- &
- \\
Candidate 6 &
- &
- &
$\begin{bmatrix} 9\times9,32, 1\\3\times3,32, 4\end{bmatrix}$ &
- &
$\begin{bmatrix} 5\times5,64, 1\\1\times1,64, 4\end{bmatrix}$ &
- &
- &
- \\
Candidate 7 &
- &
- &
$\begin{bmatrix} 9\times9,32, 1\\1\times1,32, 1\end{bmatrix}$ &
- &
- &
- &
- &
- \\
Candidate 8 &
- &
- &
$\begin{bmatrix} 9\times9,32, 1\\1\times1,32, 2\end{bmatrix}$ &
- &
- &
- &
- &
- \\
Candidate 9 &
- &
- &
$\begin{bmatrix} 9\times9,32, 1\\1\times1,32, 4\end{bmatrix}$ &
- &
- &
- &
- &
- \\ \hline
\end{tabular}
\end{table*}
\begin{table*}[t!]
\caption{Probabilities of choosing each candidate of each block} \label{tab:candidate_prob}
\centering
\setlength{\tabcolsep}{6mm}
\begin{tabular}{l|ll|ll|ll|ll}
\hline
&
\multicolumn{2}{l|}{Block 1 ($b_1$)} &
\multicolumn{2}{l|}{Block 2 ($b_2$)} &
\multicolumn{2}{l|}{Block 3 ($b_3$)} &
\multicolumn{2}{l}{Block 4 ($b_4$)} \\ \hline
Candidate 1 &
0.228 &
0.322 &
\cellcolor[HTML]{C0C0C0}0.139 &
0.201 &
\cellcolor[HTML]{C0C0C0}0.2074 &
0.043 &
\cellcolor[HTML]{C0C0C0}0.966 &
0.052 \\
Candidate 2 &
0.246 &
\cellcolor[HTML]{C0C0C0}0.678 &
0.121 &
\cellcolor[HTML]{C0C0C0}0.799 &
0.1865 &
\cellcolor[HTML]{C0C0C0}0.957 &
0.018 &
\cellcolor[HTML]{C0C0C0}0.948 \\
Candidate 3 & \cellcolor[HTML]{C0C0C0}0.264 & - & 0.127 & - & 0.1622 & - & 0.016 & - \\
Candidate 4 & 0.262 & - & 0.123 & - & 0.1504 & - & - & - \\
Candidate 5 & - & - & 0.101 & - & 0.1507 & - & - & - \\
Candidate 6 & - & - & 0.105 & - & 0.1428 & - & - & - \\
Candidate 7 & - & - & 0.097 & - & - & - & - & - \\
Candidate 8 & - & - & 0.096 & - & - & - & - & - \\
Candidate 9 & - & - & 0.091 & - & - & - & - & - \\ \hline
\end{tabular}
\end{table*}
\begin{table*}[t!]
\caption{The student network defined by distillation-based neural architecture search} \label{tab:candidate_results}
\centering
\setlength{\tabcolsep}{7mm}
\begin{threeparttable}
\begin{tabular}{l|l|l|l|l}
\hline
Block 1 ($b_1$) &
Block 2 ($b_2$) &
Block 3 ($b_3$) &
Block 4 ($b_4$) &
\multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}GAP\\ $\mathscr{N}$-D FC\!\\ Softmax\!\end{tabular}} \\ \cline{1-4}
\begin{tabular}[c]{@{}l@{}}{\!\!\fontsize{9pt}{0pt} $\begin{bmatrix} 11\times11,16, 1\\3\times3,16, 1\end{bmatrix}$}\!\\ Batch Norm.\\ ReLU\\ Max Pool\\$\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} &
\begin{tabular}[c]{@{}l@{}}{\!\!\fontsize{9pt}{0pt} $\begin{bmatrix} 9\times9,32, 1\\5\times5,32, 1\end{bmatrix}$}\!\\ Batch Norm.\\ ReLU\\ Max Pool\\$\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} &
\begin{tabular}[c]{@{}l@{}}{\!\!\fontsize{9pt}{1pt} $\begin{bmatrix} 5\times5,64, 1\\3\times3,64, 1\end{bmatrix}$}\!\\ Batch Norm.\\ ReLU\\ Max Pool\\$\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} &
\begin{tabular}[c]{@{}l@{}}{\!\!\fontsize{9pt}{1pt} $\begin{bmatrix} 3\times3,128, 1\\1\times1,128, 1\end{bmatrix}$}\!\\ Batch Norm.\\ ReLU\\ Max Pool\\$\begin{bmatrix}2\times2\end{bmatrix}$\end{tabular} &
\\ \hline
\begin{tabular}[c]{@{}l@{}}112$\times$112, 32\end{tabular} &
56$\times$56, 64 &
28$\times$28, 128 &
14$\times$14, 256 &
1$\times$1, $\mathscr{N}$ \!\\ \hline
\end{tabular}
\begin{tablenotes}
\item[*] $\mathscr{N}$ denotes the number of categories.
\end{tablenotes}
\end{threeparttable}
\end{table*}
\subsection{Implementation Details}
\textbf{Teacher Network.} We use SKResNeXt50\_32$\times$4d~\cite{li2019selective} as the backbone of the feature extractor $E$. We divide SKResNeXt50\_32$\times$4d into three segments $\{m_1,m_2,m_3\}$. $m_1$ includes the Conv1--Conv3 of SKResNeXt50\_32$\times$4d. $m_2$ and $m_3$ respectively include the Conv4 and Conv5 of SKResNeXt50\_32$\times$4d.
\textbf{Super Student Network.} As mentioned above, we define our search space as the candidates of different designs for the four convolution blocks of the student network and construct a super student network to cover all the candidates. The specific candidates are shown in Table~\ref{tab:candidates}. In Table~\ref{tab:candidates}, the design of filters are illustrated by kernel size, number of channels, and number of groups. For example, $\begin{bmatrix} 11\times11,16, 1\\7\times7,16, 1\end{bmatrix}$ denotes a PyConv layer with two types of filters: one filter has $11\times11$ kernel size and the other has $7\times7$ kernel size. Both filters have 16 channels and 1 group. The pooling layers are illustrated by the type and window size. For example, ``Avg. Pool $\begin{bmatrix}2\times2\end{bmatrix}$'' denotes an average pooling layer with $2\times2$ window size. The stride of all the convolution layers is set as 1 and the padding size is set as $\frac{\theta-1}{2}$, where $\theta$ is the spatial size of the filter. Thus, the convolution layers do not change the spatial size of feature maps. The stride of the pooling layers is set as 2, and the height and width of feature maps decrease by half after the pooling layers.
\textbf{Training Details.} For the experiments on the image-based datasets, during the training, all the learning rate are set as 0.002 with cosine annealing~\cite{cosineannealing}. Weight decay is set as $5\times10^{-4}$. The input images are resized to $256\times256$ and applied with random crop of $224\times224$ region for training, center crop of $224\times224$ region for testing. We set batch size as 32 and train each network for 300 epochs. The manual hyper parameter $\lambda$ in Equation~\ref{equ:loss1} and Equation~\ref{equ:loss2} is set as 0.7, which is a common setting for distillation. For the experiments on the video-based dataset, we follow the settings of Hara \textit{et al.}~\cite{hara2018can}. Specifically, the learning rate is set as 0.001 with plateau scheduler~\cite{hara2018can}. Weight decay is set as $1\times10^{-5}$. The batch size is set as 32, and 16 frames ($16\times3\times112\times112$) are sampled for each video clip by uniform sampling.
\begin{table*}[t!]
\setlength{\tabcolsep}{6mm}
\caption{The recognition accuracy of the teacher and student networks} \label{tab:performance}
\centering
\begin{threeparttable}
\begin{tabular}{lllll}
\hline
& \multicolumn{2}{l}{Teacher Network} & \multicolumn{2}{l}{Student Network} \\ \hline
&
\multicolumn{1}{l}{Backbone} &
\multicolumn{1}{l}{\begin{tabular}[c]{@{}l@{}}Backbone +PL\end{tabular}} &
\multicolumn{1}{l}{\begin{tabular}[c]{@{}l@{}}Train from Scratch\end{tabular}} &
\begin{tabular}[c]{@{}l@{}}Finetune after Distillation\end{tabular} \\ \hline
AUCD2 & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {95.29\%}} & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {96.35\%}} & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {95.12\%}} & \fontsize{9pt}{0pt} {95.64\%} \\ \hline
& \multicolumn{4}{c}{Train:Test=7:3} \\
& \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.75$\pm$0.12\%}} & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.87$\pm$0.03\%}} & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.81$\pm$0.09\%}} & \fontsize{9pt}{0pt} {99.87$\pm$0.03\%} \\ \cline{2-5}
& \multicolumn{4}{c}{Train:Test=7.5:2.5} \\
& \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.79$\pm$0.11\%}} & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.88$\pm$0.04\%}} & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.82$\pm$0.09\%}} & \fontsize{9pt}{0pt} {99.88$\pm$0.04\%} \\ \cline{2-5}
& \multicolumn{4}{c}{Train:Test=8:2} \\
& \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.82$\pm$0.09\%}} & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.89$\pm$0.05\%}} & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.87$\pm$0.07\%}} & \fontsize{9pt}{0pt} {99.89$\pm$0.05\%} \\ \cline{2-5}
& \multicolumn{4}{c}{Train:Test=9:1} \\
\multirow{-8}{*}{SFD3} & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.87$\pm$0.05\%}} & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.91$\pm$0.05\%}} & \multicolumn{1}{l}{\fontsize{9pt}{0pt} {99.87$\pm$0.05\%}} & \fontsize{9pt}{0pt} {99.91$\pm$0.05\%} \\ \hline
\end{tabular}
\begin{tablenotes}
\item[*] For SFD3, we illustrate the accuracy range of 10 random splits.
\end{tablenotes}
\end{threeparttable}
\end{table*}
\begin{table}[t!]
\setlength{\tabcolsep}{2mm}
\caption{The F1-score of the teacher and student networks} \label{tab:F_1_score}
\begin{tabular}{lllll}
\hline
& \multicolumn{2}{l}{Teacher Network} & \multicolumn{2}{l}{Student Network} \\ \hline
&
Backbone &
\begin{tabular}[c]{@{}l@{}}Backbone\\ +PL\end{tabular} &
\begin{tabular}[c]{@{}l@{}}Train from\\ Scratch\end{tabular} &
\begin{tabular}[c]{@{}l@{}}Finetune \\ after \\ Distillation\end{tabular} \\ \hline
Safe driving & 93.60\% & 95.14\% & 93.43\% & 94.07\% \\
Text Right & 95.24\% & 96.44\% & 95.13\% & 95.73\% \\
Talk Right & 94.74\% & 96.21\% & 94.25\% & 94.93\% \\
Text left & 95.09\% & 96.04\% & 95.09\% & 95.40\% \\
Talk left & 95.86\% & 97.35\% & 95.42\% & 95.86\% \\
Adjust Radio & 95.58\% & 96.56\% & 95.42\% & 95.60\% \\
Drink & 96.54\% & 97.29\% & 96.30\% & 97.04\% \\
Reach Behind & 95.41\% & 96.30\% & 95.41\% & 95.76\% \\
Hair \& Makeup & 95.64\% & 96.48\% & 95.64\% & 96.48\% \\
Talk to Passenger & 96.68\% & 97.00\% & 96.60\% & 96.84\% \\ \hline
Average & 95.44\% & 96.48\% & 95.27\% & 95.77\% \\ \hline
\end{tabular}
\end{table}
\begin{table}[t!]
\setlength{\tabcolsep}{1.7mm}
\caption{Comparison of the designed student networks with existing lightweight networks in terms of GFLOPs and time consumption}\label{tab:GFLOPS_TIME_COST}
\begin{tabular}{lllll}
\hline
& & GFLOPs & \multicolumn{2}{l}{Time Cost} \\ \hline
\multirow{7}{*}{Image} &
&
&
Single Image &
\begin{tabular}[c]{@{}l@{}}A Batch of \\ 32 Images\end{tabular} \\
& MobileVGG~\cite{baheti2020towards} & 2.11 & 5.19ms & 122.34ms \\
& MobileNet~\cite{howard2017mobilenets} & 0.59 & 3.54ms & 53.15ms \\
& MobileNetV2~\cite{8578572} & 0.33 & 6.94ms & 44.72ms \\
& SqueezeNet~\cite{iandola2016squeezenet} & 0.86 & 3.86ms & 48.79ms \\
& D-HCNN~\cite{qin2021distracted} & 31.10 & 7.40ms & 40.67ms \\
& \textbf{2D Student Network} & \textbf{2.25} & \textbf{2.23ms} & \textbf{35.69ms} \\ \hline
\multirow{5}{*}{\begin{tabular}[c]{@{}l@{}}Video\\ Clip\end{tabular}} &
&
&
\begin{tabular}[c]{@{}l@{}}Single Video\\ Clip\end{tabular} &
\begin{tabular}[c]{@{}l@{}}A Batch of\\ 8 Clips\end{tabular} \\
& C3D~\cite{tran2015learning} & 38.55 & 25.57ms & 1452.86ms \\
& P3D ResNet~\cite{qiu2017learning} & 18.67 & 148.04ms & 983.22ms \\
& I3D~\cite{carreira2017quo} & 27.90 & 61.86ms & 588.44ms \\
& \textbf{3D Student Network} & \textbf{37.20} & \textbf{25.35ms} & \textbf{479.83ms} \\ \hline
\end{tabular}
\end{table}
\begin{table}[t!]
\begin{center}
\caption{Comparison with state-of-the-art methods on AUCD2} \label{tab:soa:aucd2}
\begin{tabular}{lll}
\hline
\multicolumn{1}{l}{\textbf{Approach}} & \multicolumn{1}{l}{\textbf{\begin{tabular}[c]{@{}l@{}}Parameter \\ Size\end{tabular}}} & \textbf{Accuracy} \\ \hline
AlexNet on Original Scene~\cite{abouelnaga2017real} & 62M & 93.65\% \\
AlexNet on Skin Segmentation~\cite{abouelnaga2017real} & 62M & 93.60\% \\
AlexNet on Face Segmentation~\cite{abouelnaga2017real} & 62M & 86.68\% \\
AlexNet on Hand Segmentation~\cite{abouelnaga2017real} & 62M & 89.52\% \\
AlexNet on Face + Hand Segmentation~\cite{abouelnaga2017real} & 62M & 86.68\% \\
AlexNet on Original Scene~\cite{abouelnaga2017real} & 24M & 95.17\% \\
AlexNet on Skin Segmentation~\cite{abouelnaga2017real} & 24M & 94.57\% \\
AlexNet on Face Segmentation~\cite{abouelnaga2017real} & 24M & 88.82\% \\
AlexNet on Hand Segmentation~\cite{abouelnaga2017real} & 24M & 91.62\% \\
AlexNet on Face + Hand Segmentation~\cite{abouelnaga2017real} & 24M & 90.88\% \\
Majority Voting Ensemble~\cite{abouelnaga2017real} & 120M & 95.77\% \\
GA Weighted Ensemble~\cite{abouelnaga2017real} & 120M & 95.98\% \\ \hline
Original VGG-16~\cite{baheti2018detection} & 140M & 94.44\% \\
Regularized VGG-16~\cite{baheti2018detection} & 140M & 96.31\% \\
Modified VGG-16~\cite{baheti2018detection} & 15M & 95.54\% \\ \hline
\begin{tabular}[c]{@{}l@{}}Pose-guided DenseNet~\cite{behera2018latent}\end{tabular} & 8.06M & 94.20\% \\ \hline
\begin{tabular}[c]{@{}l@{}}MobileNet~\cite{howard2017mobilenets}\end{tabular} & 4.20M & 94.67\% \\ \hline
\begin{tabular}[c]{@{}l@{}}MobileNetV2~\cite{8578572}\end{tabular} & 3.50M & 94.74\% \\ \hline
\begin{tabular}[c]{@{}l@{}}NasNet Mobile~\cite{zoph2018learning}\end{tabular} & 5.30M & 94.69\% \\ \hline
\begin{tabular}[c]{@{}l@{}}SqueezeNet~\cite{iandola2016squeezenet}\end{tabular} & 1.25M & 93.21\% \\ \hline
\begin{tabular}[c]{@{}l@{}}MobileVGG~\cite{baheti2020towards}\end{tabular} & 2.20M & 95.24\% \\ \hline
VGG-one-attention~\cite{ai2019double} & \textgreater{}140M & 84.82\% \\
VGG-two-way-attention~\cite{ai2019double} & \textgreater{}140M & 87.74\% \\ \hline
\multicolumn{1}{l}{D-HCNN~\cite{qin2021distracted}} & \multicolumn{1}{l}{0.76M} & 95.59\% \\ \hline
\multicolumn{1}{l}{\textbf{Teacher Network (Ours)}} & \multicolumn{1}{l}{\textbf{44.62M}} & \textbf{96.35\%} \\ \hline
\multicolumn{1}{l}{\textbf{Student Network (Ours)}} & \multicolumn{1}{l}{\textbf{0.42M}} & \textbf{95.64\%} \\ \hline
\end{tabular}
\end{center}
\end{table}
\begin{figure}[t!]
\setlength{\fboxrule}{0.5pt}
\setlength{\fboxsep}{2pt}
\centering\includegraphics[width=\linewidth]{images/wrong_cases.PNG}
\caption{Typical sample images that are wrongly classified by the networks proposed in this work. The ground-truth labels are confusing even for humans.}
\label{fig:wrong}
\end{figure}
\begin{table}[t!]
\centering
\caption{Comparison with state-of-the-art methods on SFD3} \label{tab:soa:sfd3}
\begin{threeparttable}
\begin{tabular}{lll}
\hline
\textbf{Approach} & \textbf{\begin{tabular}[c]{@{}l@{}}Parameter\\ Size\end{tabular}} & \textbf{Accuracy} \\ \hline
\multicolumn{3}{c}{\cellcolor[HTML]{EFEFEF}Train:Test=7:3} \\ \hline
VGG-16~\cite{dhakate2020distracted} & 140M & 58.3\% \\
VGG-19~\cite{dhakate2020distracted} & 142M & 55.7\% \\
Inception-V3~\cite{dhakate2020distracted} & 25.6M & 92.90\% \\
Inception-V3+Xception~\cite{dhakate2020distracted} & 22.9M & 82.50\% \\
\begin{tabular}[c]{@{}l@{}}Inception-V3+Xception\\ +ResNet50+VGG-19~\cite{dhakate2020distracted} \end{tabular} & 46.7M & 90.00\% \\ \hline
D-HCNN~\cite{qin2021distracted} & 0.76M & 99.82\% \\ \hline
\textbf{Teacher Network (Ours)} & \textbf{44.62M} & \textbf{99.87$\pm$0.03\%} \\
\textbf{Student Network (Ours)} & \textbf{0.42M} & \textbf{99.87$\pm$0.03\%} \\ \hline
\multicolumn{3}{c}{\cellcolor[HTML]{EFEFEF}Train:Test=7.5:2.5} \\ \hline
Unpretrained VGG-16~\cite{masood2020detecting} & 140M & 99.43\% \\
Pretrained VGG-16~\cite{masood2020detecting} & 140M & 99.57\% \\
Unpretrained VGG-19~\cite{masood2020detecting} & 142M & 98.98\% \\
Pretrained VGG-19~\cite{masood2020detecting} & 142M & 99.39\% \\ \hline
MobileVGG~\cite{baheti2020towards} & 2.2M & 99.75\% \\ \hline
\begin{tabular}[c]{@{}l@{}}Transfer Learning\\ With ResNet~\cite{hssayeni2017distracted}\end{tabular} & 60M & 85.00\% \\ \hline
D-HCNN~\cite{qin2021distracted} & 0.76M & 99.84\% \\ \hline
\textbf{Teacher Network (Ours)} & \textbf{44.62M} & \textbf{99.88$\pm$0.04\%} \\
\textbf{Student Network (Ours)} & \textbf{0.42M} & \textbf{99.88$\pm$0.04\%} \\ \hline
\multicolumn{3}{c}{\cellcolor[HTML]{EFEFEF}Train:Test=8:2} \\ \hline
Pixel SVC~\cite{zhang_2016} & - & 18.3\% \\
SVC+HOG~\cite{zhang_2016} & - & 28.2\% \\
SVC+PCA~\cite{zhang_2016} & - & 34.8\% \\
SVC+Bbox+PCA~\cite{zhang_2016} & - & 40.7\% \\
Original VGG-16~\cite{zhang_2016} & 140M & 90.2\% \\
VGG-GAP~\cite{zhang_2016} & 140M & 91.3\% \\
Original VGG-16+VGG-GAP~\cite{zhang_2016} & 280M & 92.6\% \\ \hline
MLP~\cite{majdi2018drive} & - & 82.00\% \\
RNN~\cite{majdi2018drive} & - & 91.7\% \\
Drive-Net~\cite{majdi2018drive} & - & 95.00\% \\ \hline
\begin{tabular}[c]{@{}l@{}}Vanilla CNN with Data\\ Transfer Learning~\cite{janet2020real}\end{tabular} & 26.05M & 97.05\% \\
\begin{tabular}[c]{@{}l@{}}CNN with Data\\ Transfer Learning~\cite{janet2020real}\end{tabular} & 3.5M & 71.72\% \\ \hline
HCF~\cite{huang2020hcf} & \textgreater{}72.3M & 96.74\% \\ \hline
D-HCNN~\cite{qin2021distracted} & 0.76M & 99.86\% \\ \hline
\textbf{Teacher Network (Ours)} & \textbf{44.62M} & \textbf{99.89$\pm$0.05\%} \\
\textbf{Student Network (Ours)} & \textbf{0.42M} & \textbf{99.89$\pm$0.05\%} \\ \hline
\multicolumn{3}{c}{\cellcolor[HTML]{EFEFEF}Train:Test=9:1} \\ \hline
AlexNet+SoftmaxLoss~\cite{okon2017detecting} & 63.2M & 96.80\% \\
AlexNet+TripletLoss~\cite{okon2017detecting} & 63.2M & 98.70\% \\ \hline
D-HCNN~\cite{qin2021distracted} & 0.76M & 99.87\% \\ \hline
\textbf{Teacher Network (Ours)} & \textbf{44.62M} & \textbf{99.91$\pm$0.05\%} \\
\textbf{Student Network (Ours)} & \textbf{0.42M} & \textbf{99.91$\pm$0.05\%} \\ \hline
\end{tabular}
\begin{tablenotes}
\item[*] We illustrate the accuracy range of 10 random splits.
\end{tablenotes}
\end{threeparttable}
\end{table}
\section{Results and Discussions}
\subsection{Student Network Architecture Definition}
As mentioned above, we first train the super student network to approximate the prediction distribution of the teacher network. We carry out this experiment on the AUCD2, as it is a more challenging dataset than SFD3. The probability of choosing each candidate is shown in Table~\ref{tab:candidate_prob}. The candidates of the highest probability are marked in gray background. For convolutional layers, the searching guided by the teacher network chooses the third candidate for $b_1$ and the first candidate for all the other blocks. For pooling layers, the second candidate (max pooling) is selected for all the blocks. The reason might be that max pooling selects the brighter pixels or the features corresponding to the sharp pixels, and therefore more robust to illumination changes.
Referring to Table~\ref{tab:candidates} and Table~\ref{tab:candidate_prob}, we define the architecture of the student network as Table~\ref{tab:candidate_results}. This architecture only requires 0.42M parameters. In the following experiments, we use this architecture as the student network on both datasets.
\subsection{Recognition Performance of the Teacher and Student Network}
In this subsection, we compare the recognition performance of the teacher network with and without progressive learning (PL), the student network trained from scratch and finetuned after transferring the teacher network's knowledge to the student network. The results are shown in Table~\ref{tab:performance}.
On the AUCD2, PL improves the teacher network by 1.06\%, which shows the effectiveness of PL. On the SFD3, the improvement brought by PL is small, which is 0.04\%--0.11\%. It is because backbone of the teacher has already achieved a high accuracy that is 99.75\%--99.87\%. Considering the very narrow possible improvement space, we suppose PL can be still regarded as effective on the SFD3. In the following experiments, we use the teacher network with PL to guide the search of the student network architecture and transfer knowledge to the student network.
On both datasets, the student network trained from scratch already achieves a very high accuracy, which shows the architecture obtained by the proposed searching approach is effective for the DDR task. Knowledge distillation respectively improve 0.52\% and 0.03\%--0.05\% on the AUCD2 and SFD3, respectively.
Considering that the accuracy for the datasets is almost saturated, it is interesting to see there is still room for the improvement by our proposed method.
In addition, since the AUCD2 dataset is somewhat unbalanced, we also show the F1-score obtained with this dataset in Table~\ref{tab:F_1_score}. PL improves the teacher network by 0.32\%--1.54\% in different categories. Knowledge distillation respectively improve 0.17\%--0.84\% for the student network in different categories.
\begin{table*}[t!]
\centering
\caption{The recognition accuracy of the 3D student network on the three splits of different tasks of the DAD~\cite{drive_and_act_2019_iccv}}\label{tab:drive_act_performance}
\setlength{\tabcolsep}{1.6mm}
\begin{tabular}{l|ll|ll|llllllll}
\hline
\multirow{3}{*}{} &
\multicolumn{2}{c|}{\multirow{2}{*}{Fine-grained Activities}} &
\multicolumn{2}{c|}{\multirow{2}{*}{Scenarios}} &
\multicolumn{8}{c}{Atomic Action Units} \\ \cline{6-13}
&
\multicolumn{2}{c|}{} &
\multicolumn{2}{c|}{} &
\multicolumn{2}{c|}{Action} &
\multicolumn{2}{c|}{Object} &
\multicolumn{2}{c|}{Location} &
\multicolumn{2}{c}{Action-Object-Location} \\ \cline{2-13}
&
Validation &
Test &
Validation &
Test &
Validation &
\multicolumn{1}{l|}{Test} &
Validation &
\multicolumn{1}{l|}{Test} &
Validation &
\multicolumn{1}{l|}{Test} &
Validation &
Test \\
Split 1 &
72.04\% &
69.57\% &
60.24\% &
44.97\% &
79.25\% &
\multicolumn{1}{l|}{84.81\%} &
71.59\% &
\multicolumn{1}{l|}{65.50\%} &
69.90\% &
\multicolumn{1}{l|}{63.79\%} &
44.89\% &
51.22\% \\
Split 2 &
67.75\% &
66.08\% &
46.04\% &
47.68\% &
81.16\% &
\multicolumn{1}{l|}{79.77\%} &
61.13\% &
\multicolumn{1}{l|}{63.54\%} &
66.48\% &
\multicolumn{1}{l|}{61.27\%} &
47.64\% &
36.69\% \\
Split 3 &
71.59\% &
61.43\% &
58.57\% &
35.80\% &
81.78\% &
\multicolumn{1}{l|}{74.70\%} &
66.22\% &
\multicolumn{1}{l|}{46.96\%} &
50.21\% &
\multicolumn{1}{l|}{65.37\%} &
41.15\% &
41.08\% \\
Average &
70.46\% &
65.69\% &
54.95\% &
42.82\% &
80.73\% &
\multicolumn{1}{l|}{79.76\%} &
66.31\% &
\multicolumn{1}{l|}{58.67\%} &
62.20\% &
\multicolumn{1}{l|}{63.48\%} &
44.56\% &
43.00\% \\ \hline
\end{tabular}
\end{table*}
\begin{table*}[t!]
\caption{Comparison with state-of-the-art methods on the DAD~\cite{drive_and_act_2019_iccv}}\label{tab:drive_act_soa}
\setlength{\tabcolsep}{0.7mm}
\begin{tabular}{ll|l|llllllllllll}
\hline
\multicolumn{2}{l|}{\multirow{4}{*}{}} &
\multirow{4}{*}{\begin{tabular}[c]{@{}l@{}}Parameter\\ Size\end{tabular}} &
\multicolumn{12}{c}{Accuracy} \\ \cline{4-15}
\multicolumn{2}{l|}{} &
&
\multicolumn{2}{c|}{\multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Fine-grained\\ Activities\end{tabular}}} &
\multicolumn{2}{c|}{\multirow{2}{*}{Scenarios}} &
\multicolumn{8}{c}{Atomic Action Units} \\ \cline{8-15}
\multicolumn{2}{l|}{} &
&
\multicolumn{2}{c|}{} &
\multicolumn{2}{c|}{} &
\multicolumn{2}{c|}{Atomic Action} &
\multicolumn{2}{c|}{Object} &
\multicolumn{2}{c|}{Location} &
\multicolumn{2}{c}{\begin{tabular}[c]{@{}c@{}}Action-Object\\ -Location\end{tabular}} \\ \cline{4-15}
\multicolumn{2}{l|}{} &
&
Val &
\multicolumn{1}{l|}{Test} &
Val &
\multicolumn{1}{l|}{Test} &
Val &
\multicolumn{1}{l|}{Test} &
Val &
\multicolumn{1}{l|}{Test} &
Val &
\multicolumn{1}{l|}{Test} &
Val &
Test \\ \cline{1-3}
\multicolumn{1}{l|}{\multirow{4}{*}{\begin{tabular}[c]{@{}l@{}}Body Pose \\ Representation\end{tabular}}} &
Interior~\cite{drive_and_act_2019_iccv} &
- &
45.23\% &
\multicolumn{1}{l|}{40.30\%} &
35.76\% &
\multicolumn{1}{l|}{29.75\%} &
57.62\% &
\multicolumn{1}{l|}{47.74\%} &
51.45\% &
\multicolumn{1}{l|}{41.72\%} &
53.31\% &
\multicolumn{1}{l|}{52.64\%} &
9.18\% &
7.07\% \\
\multicolumn{1}{l|}{} &
Pose~\cite{drive_and_act_2019_iccv} &
- &
53.17\% &
\multicolumn{1}{l|}{44.36\%} &
37.18\% &
\multicolumn{1}{l|}{32.96\%} &
54.23\% &
\multicolumn{1}{l|}{49.03\%} &
49.90\% &
\multicolumn{1}{l|}{40.73\%} &
53.76\% &
\multicolumn{1}{l|}{53.33\%} &
8.76\% &
6.85\% \\
\multicolumn{1}{l|}{} &
Two-Stream~\cite{wang2017modeling} &
- &
53.76\% &
\multicolumn{1}{l|}{45.39\%} &
39.37\% &
\multicolumn{1}{l|}{34.81\%} &
57.86\% &
\multicolumn{1}{l|}{48.83\%} &
52.72\% &
\multicolumn{1}{l|}{42.79\%} &
53.99\% &
\multicolumn{1}{l|}{54.73\%} &
10.31\% &
7.11\% \\
\multicolumn{1}{l|}{} &
Three-Stream~\cite{martin2018body} &
- &
55.67\% &
\multicolumn{1}{l|}{46.95\%} &
41.70\% &
\multicolumn{1}{l|}{35.45\%} &
59.29\% &
\multicolumn{1}{l|}{50.65\%} &
55.59\% &
\multicolumn{1}{l|}{45.25\%} &
59.54\% &
\multicolumn{1}{l|}{56.50\%} &
11.57\% &
8.09\% \\ \hline
\multicolumn{1}{l|}{\multirow{3}{*}{End-to-end}} &
C3D~\cite{tran2015learning} &
78.14M&
49.54\% &
\multicolumn{1}{l|}{43.41\%} &
- &
\multicolumn{1}{l|}{-} &
- &
\multicolumn{1}{l|}{-} &
- &
\multicolumn{1}{l|}{-} &
- &
\multicolumn{1}{l|}{-} &
- &
- \\
\multicolumn{1}{l|}{} &
P3D ResNet~\cite{qiu2017learning} &
65.74M &
55.04\% &
\multicolumn{1}{l|}{45.32\%} &
- &
\multicolumn{1}{l|}{-} &
- &
\multicolumn{1}{l|}{-} &
- &
\multicolumn{1}{l|}{-} &
- &
\multicolumn{1}{l|}{-} &
- &
- \\
\multicolumn{1}{l|}{} &
I3D~\cite{carreira2017quo} &
12.32M &
69.57\% &
\multicolumn{1}{l|}{63.64\%} &
44.66\% &
\multicolumn{1}{l|}{31.80\%} &
62.81\% &
\multicolumn{1}{l|}{56.07\%} &
61.81\% &
\multicolumn{1}{l|}{56.15\%} &
47.70\% &
\multicolumn{1}{l|}{51.12\%} &
15.56\% &
12.12\% \\ \hline
\multicolumn{2}{l|}{\textbf{3D Student Network (Ours)}} &
\textbf{2.03M} &
\textbf{70.46\%} &
\multicolumn{1}{l|}{\textbf{65.69\%}} &
\textbf{54.95\%} &
\multicolumn{1}{l|}{\textbf{42.82\%}} &
\textbf{80.73\%} &
\multicolumn{1}{l|}{\textbf{79.76\%}} &
\textbf{66.31\%} &
\multicolumn{1}{l|}{\textbf{58.67\%}} &
\textbf{62.20\%} &
\multicolumn{1}{l|}{\textbf{63.48\%}} &
\textbf{44.56\%} &
\textbf{43.00\%} \\ \hline
\end{tabular}
\end{table*}
\subsection{Comparison with State-of-the-art Distracted Driver Recognition Approaches}
In this subsection, we compare our performance with the state-of-the-art approaches on AUCD2 and SFD3.
Table~\ref{tab:soa:aucd2} shows the results on the AUCD3. The accuracy of the teacher network (96.35\%) surpasses the best previous accuracy (96.31\%), which is achieved by Regularized VGG-16~\cite{baheti2018detection}. Regularized VGG-16 has 140M parameters, whereas the teacher network in this work has 44.62M parameters (i.e., 31.87\% of the Regularized VGG-16 parameters), which shows the effectiveness of the teacher network on this dataset. The student network achieves 95.64\% with 0.42M parameters. For comparison, the original VGG-16 achieves 94.44\% with 140M parameters (i.e., 333.33 times of the student network parameters), and the modified VGG-16 achieves 96.54\% with 15M parameters (i.e., 35.71 times of the student network parameters)~\cite{baheti2018detection}.
Table~\ref{tab:soa:sfd3} shows the results on the SFD3. Both the teacher and student network achieve 99.86\%--99.91\%, which outperforms the best previous accuracy. The student network is recommended because it requires fewer parameters.
D-HCNN~\cite{qin2021distracted} also achieves good accuracy on both datasets with small parameters. However, our student network is better because: (\romannumeral1) The student network has better accuracy than D-HCNN on both datasets; (\romannumeral2) The student network's parameters are only about 55.26\% of D-HCNN; (\romannumeral3) D-HCNN requires HOG images in addition to RGB images as input. Therefore, it needs to compute the HOG feature~\cite{dalal2005histograms} of every image when using D-HCNN, which is unfavorable for real-world applications.
Moreover, the student network has better real-time performance than other lightweight models. As shown in Table~\ref{tab:GFLOPS_TIME_COST}, for processing a single image in the test mode, the student network requires 2.25 GFLOPs takes 2.23 ms on 1080Ti + Intel i7-10700F. In comparison, MobileVGG~\cite{baheti2020towards} requires 2.11 GFLOPs and takes 5.19 ms. MobileNet~\cite{howard2017mobilenets} requires 0.59 GFLOPs and takes 3.54 ms. MobileNetV2~\cite{8578572} requires 0.33 GFLOPs and takes 6.94 ms. SqueezeNet~\cite{iandola2016squeezenet} requires 0.86 GFLOPs and takes 3.86 ms. D-HCNN~\cite{qin2021distracted} requires 31.10 GFLOPs and takes 7.40 ms. As D-HCNN requires HOG images as additional input, it takes additional 1.48ms per image to compute HOG for each image. Compared to previous lightweight networks, our network has no significant advantage in terms of GFLOPs but clearly has faster speed. It is because the parallelism of a convolutional network is mainly reflected in the calculation of each layer, and there is generally no parallelism across layers. So for convolutional neural networks used in high-speed DDR, large convolutional filter size is better than too deep layers. This fact was also pointed out by Qin~\textit{et al.}~\cite{qin2021distracted} and experimentally proved by them. Another advantage of our network is the aforementioned lower number of parameters, which allows our network to require less storage and memory space and be more easily deployed on in-vehicle devices.
Since GPUs can process multiple images in parallel, we also compare the time consumption of our network with other lightweight networks that process multiple images in parallel. For processing one batch of images (32 images) in the test mode, the student network takes 35.69 ms on 1080Ti + Intel i7-10700F. In comparison, MobileVGG~\cite{baheti2020towards} takes 122.34 ms. MobileNet~\cite{howard2017mobilenets} takes 53.15 ms. MobileNetV2~\cite{8578572} takes 44.72 ms. SqueezeNet~\cite{iandola2016squeezenet} takes 48.79 ms. D-HCNN~\cite{qin2021distracted} takes 40.67 ms.
As the proposed teacher and student networks achieve very high accuracy on both image-based DDR datasets~\cite{statefarm,alotaibi2019distracted}, it is important to know what images cause the small number of recognition failures. Figure~\ref{fig:wrong} shows the typical failure cases of the wrongly-predicted images together with their ground-truth labels and the prediction given by the proposed networks (the teacher network or student network). Those failure cases are even confusing for humans.
\subsection{Extending the Student Network to 3D for the Video-based Distracted Driver Recognition}
The above experiments have proposed a lightweight yet powerful network architecture (i.e., the student network) for image-based DDR. In this subsection, we extend the student network into a spatial-temporal 3D network to evaluate whether on the video-based DDR dataset~\cite{drive_and_act_2019_iccv}, the 3D student network can retrace the success of the student network architecture proposed for the image-based DDR. This experiment is inspired by the experiments of Hara \textit{et al.}~\cite{hara2018can}, in which the researchers replaced the 2D layers (e.g., 2D convolutional layers, 2D batch normalization layers, etc.) of the ResNet architectures~\cite{he2016deep} with 3D layers (e.g., 3D convolutional layers, 3D batch normalization layers, etc.) and proved that using 3D ResNet architectures together with Kinetics~\cite{kay2017kinetics} can retrace the successful history of 2D CNNs on ImageNet~\cite{deng2009imagenet}. Following Hara \textit{et al.}~\cite{hara2018can}, we set the size of the third dimension of each 3D convolutional kernel to be the same as the size of the first and second dimensions. For example, a 2D convolutional kernel of a $3 \times 3$ kernel size is extended to a 3D convolutional kernel of a $3 \times 3 \times3$ kernel size.
We conducted comprehensive experiments to evaluate the performance of the 3D student network for all the tasks on the DAD. The specific accuracy of each split and the average accuracy over the three splits are shown in Table~\ref{tab:drive_act_performance}. The comparison results with the state-of-the-art approaches on the DAD are shown in Table~\ref{tab:drive_act_soa}. It can be observed that the 3D student network outperforms the state-of-the-art approaches by a significantly large margin in both validation and testing sets. Our approach is 0.89\%--29.00\% higher than the previous best accuracy in the validation set and 2.05\%--30.88\% higher than the previous best accuracy in the test set. Besides, the 3D student network has only 2.03M parameters and is much more lightweight than the state-of-the-art approaches. The parameter size of the 3D student network is only 16.48\% of the parameter size of C3D~\cite{tran2015learning}, 3.09\% of the parameter size of P3D ResNet~\cite{qiu2017learning}, 2.60\% of the parameter size of I3D~\cite{carreira2017quo}. Moreover, the student network has better real-time performance than those 3D convolutional neural networks. As shown in Table~\ref{tab:GFLOPS_TIME_COST}, for processing a single video clips, 3D student network requires 37.20 GFLOPs and takes 25.35 ms on 1080Ti + Intel i7-10700F. In comparison, C3D requires 38.55 GFLOPs and takes 25.57 ms. P3D ResNet requires 18.67 GFLOPs and takes 148.04 ms. I3D 27.90 GFLOPs and takes 61.86 ms. Similar to the case of 2D student network, 3D student network does not have clear advantage in terms of GFLOPs, but has a clearly faster speed.
For processing 8 video clips ($8\times16$ frames) in the test mode, the 3D student network takes 479.83 ms on 1080Ti + Intel i7-10700F. In comparison, C3D takes 1452.86 ms. P3D ResNet takes 983.22 ms. I3D takes 588.44 ms.
\subsection{Discussion on the Implication of the Proposed Framework on the ITS
applications}
The implication of our approach to applications is as follows:
\begin{itemize}
\item[-]We construct a powerful teacher network using progressive learning to increase robustness to illumination changes from shallow to deep layers of a backbone CNN. The classification accuracy of the teacher network exceeds that of all existing approaches and is well suited for the DDR applications that do not require a particularly small computational overhead but rather high accuracy.
\item[-]Using NAS and knowledge distillation, we generate an effective student network with the guidance of the teacher network. The student network can achieve high DDR accuracy and has less parametric count and inference time than any existing lightweight DDR networks. The student network is suitable for applications with high parametric and inference time requirements.
\item[-]We extend the student network into a spatial-temporal 3D network for performing DDR based on small video clips. The 3D student network has better DDR accuracy, smaller parameter size, and faster speed than the existing approaches. The 3D student network is suitable for applications developed based on video clips.
\item[-]Our proposed framework combining knowledge distillation and NAS has the potential to become a general DDR network design framework for different applications.
\end{itemize}
\section{Additional experiments}
\begin{table}[t!]
\caption{The recognition accuracy of the teacher and student network on the three additional datasets} \label{tab:add_performance}
\begin{center}
\setlength{\tabcolsep}{1.2mm}
\begin{tabular}{lllll}
\hline
& \multicolumn{2}{l}{Teacher Network} & \multicolumn{2}{l}{Student Network} \\ \hline
&
Backbone &
\begin{tabular}[c]{@{}l@{}}Backbone\\ +PL\end{tabular} &
\begin{tabular}[c]{@{}l@{}}Train from\\ Scratch\end{tabular} &
\begin{tabular}[c]{@{}l@{}}Finetune after\\ Distillation\end{tabular} \\ \hline
SLD2~\cite{DBLP:journals/corr/abs-2011-08927} & 99.53\% & 99.74\% & 99.48\% & 99.74\% \\
Gesture2012~\cite{barczak2011new} & 100\% & 100\% & 100\% & 100\% \\
USED~\cite{4408872} & 97.91\% & 98.75\% & 89.17\% & 92.08\% \\ \hline
\end{tabular}
\end{center}
\end{table}
\begin{table}[t!]
\caption{Comparison results on the three additional datasets} \label{tab:add_SOA}
\begin{center}
\begin{tabular}{lll}
\hline
\multicolumn{1}{l}{\textbf{Approach}} &
\multicolumn{1}{l}{\textbf{\begin{tabular}[c]{@{}l@{}}Parameter\\ Size\end{tabular}}} &
\textbf{Accuracy} \\ \hline
\multicolumn{3}{c}{\cellcolor[HTML]{EFEFEF}SLD2~\cite{DBLP:journals/corr/abs-2011-08927}} \\ \hline
\begin{tabular}[c]{@{}l@{}}Contour SVM-based\\ digit-gesture recognition\end{tabular} &
- &
69.00\% \\
\begin{tabular}[c]{@{}l@{}}CNN-based digit-gesture\\ recognition\end{tabular} &
1.84M &
98.32\% \\
\multicolumn{3}{l}{\cite{saha2019bangla}} \\ \hline
Increasing Filter Size & 5.46M & 99.68\% \\
Decreasing Filter Size & 0.76M & 99.68\% \\
\multicolumn{3}{l}{\cite{qin2021distracted}} \\ \hline
\textbf{Teacher Network (Ours)} & \textbf{44.62M} & \textbf{99.74\%} \\
\textbf{Student Network (Ours)} & \textbf{0.42M} & \textbf{99.74\%} \\ \hline
\multicolumn{3}{c}{\cellcolor[HTML]{EFEFEF}Gesture2012~\cite{barczak2011new}} \\ \hline
\begin{tabular}[c]{@{}l@{}}CNN-based digit-gesture\\ recognition\\ \cite{saha2019bangla}\end{tabular} &
1.84M &
100\% \\ \hline
Increasing Filter Size & 5.46M & 96.30\% \\
Decreasing Filter Size & 0.76M & 94.10\% \\
\multicolumn{3}{l}{\cite{qin2021distracted}} \\ \hline
\textbf{Teacher Network (Ours)} & \textbf{44.62M} & \textbf{100\%} \\
\textbf{Student Network (Ours)} & \textbf{0.42M} & \textbf{100\%} \\ \hline
\multicolumn{3}{c}{\cellcolor[HTML]{EFEFEF}USED~\cite{4408872}} \\ \hline
\begin{tabular}[c]{@{}l@{}}SIFT+GGM~\cite{4408872}\end{tabular} & - & 73.4\% \\ \hline
HMP & - & 85.7\% \\
SIFT+SC & - & 82.7\% \\
\multicolumn{3}{l}{\cite{Bo2011Hierarchical}} \\ \hline
\begin{tabular}[c]{@{}l@{}}OB~\cite{li2014object}\end{tabular} & - & 76.3\% \\ \hline
\begin{tabular}[c]{@{}l@{}}Places-CNN\end{tabular} & 61M & 94.12\% \\
ImageNet-CNN & 61M & 94.42\% \\
Hybrid-CNN & 122M & 94.22\% \\
\multicolumn{3}{l}{\cite{NIPS2014_3fe94a00}} \\ \hline
\begin{tabular}[c]{@{}l@{}}TPN-FS~\cite{bai2017learning}\end{tabular} & 121M & 95.2\% \\ \hline
DTCTH(LSVM) & - & 85.16\% \\
DTCTH(HI) & - & 88.18\% \\
\multicolumn{3}{l}{\cite{rahman2017dtcth}} \\ \hline
CLGC(RGB-RGB) & - & 86.4\% \\
CLGC(RGB-HSV) & - & 90.85\% \\
\multicolumn{3}{l}{\cite{Kabbai2019image}} \\ \hline
\textbf{Teacher Network (Ours)} & \textbf{44.62M} & \textbf{98.75\%} \\
\textbf{Student Network (Ours)} & \textbf{0.42M} & \textbf{92.08\%} \\ \hline
\end{tabular}
\end{center}
\end{table}
We also evaluate our approach on three additional datasets, which are not for the DDR task but have the same characteristic: small diversity and strong inter-class similarity. The three additional datasets are Sign Language Digits Dataset (SLD2)~\cite{DBLP:journals/corr/abs-2011-08927}, Gesture Dataset 2012 (Gesture2012)~\cite{barczak2011new}, and UIUC Sports Event Dataset (USED)~\cite{4408872}. SLD2 and Gesture2012 are image datasets for hand sign language recognition, which are also used by Qin \textit{et al.}~\cite{qin2021distracted} as additional datasets to evaluate D-HCNN~\cite{qin2021distracted}. USED is an image dataset for sport event recognition.
On the three additional datasets, we compared the recognition performance of the teacher network with and without progressive learning (PL), the student network trained from scratch and finetuned after knowledge transferring. The results are shown in Table~\ref{tab:add_performance}. We also compared our approach with the state-of-the-art approaches on the three additional datasets, and the results are shown in the Table~\ref{tab:add_SOA}.
Both the teacher and student networks achieve 99.74\% on the SLD and 100\% on the Gesture2012, which reach state-of-the-art performance on the two datasets. The student network has much fewer parameters than other state-of-the-art approaches on these two datasets.
On the USED, the improvement brought by PL and knowledge transfer is obvious. PL improves the teacher network by 0.84\% and knowledge transfer improves the student network by 2.91\%. The accuracy of the teacher network is 98.75\%, which surpasses the best previous accuracy by 3.55\%. The student network achieves 92.08\% with 0.42M parameters.
\section{Conclusion}
In this paper, we proposed a novel framework for distracted driver recognition to achieve high accuracy with a small number of parameters. This framework first builds a powerful teacher network based on progressive learning and then uses the teacher network to guide the searching of an optimal architecture for a student network, which is lightweight but can achieve high accuracy. Thereafter, the teacher network is used again to transfer the knowledge to the student network. The teacher network outperforms the previous state-of-the-art approaches on the Statefarm Distracted Driver Detection Dataset and AUC Distracted Driver Dataset. The student network achieves high accuracy with extremely tiny parameters on both datasets. The student network architecture can be extended into a spatial-temporal 3D convolutional neural network for recognizing distracted driving behaviors from video clips. The 3D student network significantly outperforms the previous state-of-the-art approaches with only 2.03M parameters on the Drive\&Act Dataset.
\bibliographystyle{IEEEtran}
| {'timestamp': '2023-02-10T02:09:17', 'yymm': '2302', 'arxiv_id': '2302.04527', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04527'} | arxiv |
\section{Introduction}
In recent years, visual recognition with deep learning has made tremendous progress. Closed-set is a common assumption in deep visual recognition where the training and testing datasets have a shared label space. However, data insufficiency and unavailability in real-world applications make it difficult to satisfy and pose significant challenges to visual classifiers. To this end, Generalized Zero-Shot Learning (GZSL) and Open-Set Recognition (OSR) are proposed to extend traditional visual recognition by acknowledging the existence of unknown categories in the target dataset. Specifically, GZSL aims to recognize both seen and unseen classes given labeled semantic attributes. The goal of OSR is to classify seen samples and detect unseen ones without prior information. Unfortunately, GZSL and OSR still have limitations in practical use. For example, the notion of novel\footnote{In this paper, we use unseen and novel interchangeably. } categories in GZSL is pre-determined by the provided semantic labels. However, knowing the novel semantic attributes implies the existence of images from unseen categories. Then the problem can be simply reduced to supervised learning by collecting training samples of novel categories. In this sense, the GZSL problem is less practical as the model is expected to automatically discover novel categories on its own.
In addition, OSR recognizes unseen categories as a whole without further analysis of their intrinsic fine-grained structures. Furthermore, OSR does not consider the semantics of visual categories, failing to provide richer information for in-depth analyses and interpretation of novel categories.
In this paper, we explore a novel setting named Zero-Knowledge Zero-Shot Learning (ZK-ZSL) that addresses the aforementioned limitations of GZSL and OSR. Figure~\ref{fig:schemaicviews} illustrates the difference between GZSL, OSR, and our setting. ZK-ZSL aims to recognize both seen and unseen classes without prior knowledge of novel categories and recover their semantic attributes of the fine-grained novel categories. In this setting, only semantic labels of the seen categories are available. Compared with GZSL and OSR, the challenges of ZK-ZSL lie in the following aspects. (1) A classifier trained on the seen label space might separate seen samples from unseen samples, but cannot further separate samples in fine-grained unseen categories, and the biased embedding learned from the seen categories could potentially destroy underlying structures of unseen categories. (2) Since the semantic labels of unseen categories are unavailable, training only with seen semantics is susceptible to overfitting and leads to biased semantic predictions.
\begin{wrapfigure}[15]{R}{0.5\textwidth}
\vspace{-2mm}
\centering
\includegraphics[width=0.9 \linewidth]{figs/schematicview.jpg}\vspace{-2mm}
\caption{Schematic illustrations of GZSL, OSR, and our explored Zero-Knowledge Zero-Shot Learning (ZK-ZSL).}
\label{fig:schemaicviews}
\vspace{-5mm}
\label{sec:intro}
\end{wrapfigure}
We propose a novel framework to tackle the ZK-ZSL problem and address the above challenges. In what follows, we first discuss how our proposed method takes into account the aforementioned challenges, and then we summarize our main contributions. To recognize seen classes and discover the structures of novel categories, our method learns to cluster on the target data consisting of both seen and unseen categories. Meanwhile, the class structures of seen categories are guided by the source labels. In addition, to mitigate the unavailability problem of unseen semantic labels, we enforce a structural alignment between recovered hidden embedding and predicted semantic space to aid the semantic learning of unseen categories with their discovered clustering structures. Our main contributions can be summarized as follows:
\begin{itemize}
\vspace{-1mm}
\item \parbox[t]{\dimexpr\textwidth-\leftmargin}{We formulate and explore a new visual recognition setting named Zero-Knowledge Zero-Shot Learning (ZK-ZSL) that aims to recognize seen and unseen categories without prior knowledge and recovers unseen semantic attributes, addressing the limitations of GZSL and OSR in practical use.}
\vspace{-1mm}
\item \parbox[t]{\dimexpr\textwidth-\leftmargin}{We propose a novel method that learns to uncover clustering structures in the target dataset guided by labeled seen class structures. A novel structural alignment loss is designed to aid the learning of novel semantic attributes with recovered clustering structures.}
\vspace{-1mm}
\item \parbox[t]{\dimexpr\textwidth-\leftmargin}{We demonstrate the superiority of our method in terms of classification and semantic recovery on four benchmark datasets by comparing with five competitive baseline methods. We also provide rich in-depth explorations of our method for unseen category discovery.}
\vspace{-1mm}
\end{itemize}
\vspace{-2mm}
\section{Related Works}
\noindent\textbf{Generalized Zero-Shot Learning.} The demand to recognize novel classes not present during training without additional labeling motivates the area of Zero-Shot Learning (ZSL). In ZSL, class-level semantic attributes are provided to aid knowledge transfer from source to the target dataset. Later, due to the disjoint nature of the source and target label spaces, GZSL is hence proposed~\cite{pourpanah2022review}, where the target dataset consists of categories present in the source dataset and additional novel categories. Existing GZSL methods can be categorized into embedding-based and generative-based methods. Embedding-based methods learn to map visual features to the semantic space and make predictions based on the similarity between predicted semantics and ground truth \cite{frome2013devise, akata2015sje, romera2015eszsl, xu2020attribute, xie2019attentive, xie2020region, liu2021goal}. Generative-based methods synthesize samples from semantic attributes through Generative Adversarial Networks (GANs) \cite{goodfellow2020gan} or Variational Autoencoders (VAEs) \cite{kingma2013vae}, and reformulate the GZSL problem to a conventional supervised learning problem by training a classifier with generated samples \cite{li2019leveraging, xian2018feature, mishra2018generative, zhu2018generative, yu2020episode}.
\noindent\textbf{Open-Set Recognition.} OSR extends the traditional closed-set classification setting by assuming the target samples contain categories seen during training and additional unseen categories. Under OSR, classifiers need to be able to recognize seen samples and reject unknown samples \cite{geng2020osr}. OSR methods usually adopt a threshold-based strategy, where the threshold can be empirically chosen. Existing methods differ in how they discriminate seen categories, including SVM-based \cite{cortes1995svm, scheirer2012toward, scheirer2014probability, jain2014multi}, distance-based \cite{bendale2015towards, papa2009supervised, mendes2017nearest}, and deep learning based methods\cite{bendale2016towards, hassen2020learning, shu2017doc, hughes2017medical, kardan2017mitigating}.
In addition to GZSL and OSR, we notice the recently proposed Semantic Recovery Open-Set Domain Adaptation (SR-OSDA) \cite{jing2021taotao} and the Generalized Category Discovery (GCD) \cite{vaze2022generalized, wen2022simple, chiaroni2022mutual} are related to our setting. SR-OSDA aims to recognize both seen and unseen samples in the target dataset and recover their semantic attributes.
The goal of GCD is to automatically categorize a partially labeled dataset of images, where the unlabeled images contain both seen and novel categories, but GCD does not consider semantic recovery.
\section{Motivation and Problem Definition}\label{sec:problem}
GZSL aims to recognize categories both seen and unseen during training, given semantic attributes of all classes. However, novel categories are pre-defined with semantic labels and are known to the model, which can be impractical for some applications. OSR aims to detect unseen samples without prior information but treats them as one group, failing to explore their innate structures further. Moreover, the semantic attributes of visual categories are not utilized under OSR, which prevents in-depth analyses and interpretations of the structures of novel categories.
Due to the limitations of GZSL and OSR, we consider the \textbf{Zero-Knowledge Zero-Shot Learning (ZK-ZSL)} problem, which focuses on recognizing seen and unseen categories without prior knowledge of novel semantic labels while uncovering the partitional structures of novel categories and their missing semantic attributes. Inspired by the paradigm style in \citet{pourpanah2022review}, we illustrate the main differences among GZSL, OSR, and ZK-ZSL in Figure~\ref{fig:schemaicviews}. Compared with GZSL and OSR, ZK-ZSL is more realistic in that it does not assume prior knowledge of the unseen categories, and it can support richer analysis and interpretation of the discovered novel categories. Here we provide problem formulation of ZK-ZSL: Let $D_s = \{X_s, Y_s, A_s\}$ be the source dataset, and $D_t = \{X_t\}$ be the target dataset. Given both $D_s$ and $D_t$, ZK-ZSL aims to find $X_t$'s corresponding $Y_t$, which contains all visual categories in $Y_s$ and some additional unseen categories $Y_u = Y_t \setminus Y_s$, and recover their semantic attributes $A_t$. Table~\ref{tab:notation} summarizes the major notations used in this paper.\footnote{In the following, we might put $s/t$ in the superscript and the sample index in the subscript if needed.}
\begin{wraptable}{R}{0.5\textwidth}
\vspace{-4mm}
\centering
\caption{Notions and descriptions}\label{tab:notation}
\resizebox{.9 \linewidth}{!}{
\begin{tabular}{lll}
\toprule
Notion & Type & Description \\
\midrule
$X_s/X_t$ & Input & source/target visual features \\
$A_s/A_t$ & Input & source/target semantic attributes \\
$Y_s/Y_t$ & Input & source/target labels \\
$K_s/K_t$ & Input & source/target number of categories \\
$N_s/N_t$ & Input & source/target number of instances \\
$d$ & Input & dimension of semantic attribute \\
\hline
$z_s / z_t$ & Learnable & source/target embedding \\
$\hat{a}_s / \hat{a}_t$ & Learnable & source/target predicted semantic \\
$\Tilde{\mu}_{k}$ & Learnable & seen class prototype by pseudo label \\
$\mu_{k}$ & Learnable & class prototype \\
\bottomrule
\end{tabular} \vspace{-10mm}
}
\end{wraptable}
The challenges associated with ZK-ZSL are twofold. First, the model needs to provide partitional structures of unseen categories. However, training a visual classifier only with labeled seen samples can only help distinguish between seen/unseen categories but cannot further separate the fine-grained categories in the unseen class. In addition, due to mismatched label spaces in the source and target dataset, learning such a classifier could destroy the clustering structures of novel categories. Second, since the semantic attributes of unseen categories are unavailable, learning only with seen semantics is prone to overfitting and results in biased semantic prediction.
\section{Proposed Method}
In this section, we introduce our framework for ZK-ZSL and the objective function to train our framework.
\subsection{Framework Overview}
Figure~\ref{fig:framework} shows our proposed framework for ZK-ZSL. In order to discover and differentiate novel categories while recognizing seen classes, our method learns to recover the clustering structures of both seen and unseen categories in the target dataset, where the learning of seen class structures is guided by the source labels. In addition, to mitigate the overfitting brought about by the unavailability of unseen semantic labels, we apply a structural alignment loss to support semantic learning with the recovered structures of unseen categories. Therefore, our framework consists of three main components for source-guided clustering, semantic prediction, and structural alignment.
The source-guided clustering component learns to recover the clustering structures of both seen and unseen categories on a hidden embedding space where the learning of seen class structures is supported by labeled source data. The semantic prediction component maps the hidden embedding to the semantic space. The structural alignment component guides the semantic learning of novel categories with their recovered clustering structures.
\begin{figure}[tp]
\centering
\resizebox{.65 \linewidth}{!}{
\includegraphics[width=\linewidth]{figs/framework.png}
}
\caption{Overview of our proposed framework. The deep clustering component guided by the source class structures uncovers the clustering structures of the target dataset. The semantic prediction component maps the embedding space to the semantic space. The structural alignment component supports semantic learning of unseen categories with recovered structures. }
\label{fig:framework}
\vspace{-3mm}
\end{figure}
\subsection{Objective Function}
Our learning objective consists of three main components: source-guided clustering loss, semantic prediction loss, and structural alignment loss. We denote our encoder, decoder, and semantic predictor as $g: x \rightarrow z$, $h: z \rightarrow x$, and $f: z \rightarrow a$, where $x$, $z$, and $a$ represent visual feature, hidden embedding, and semantic attribute spaces, respectively, and we define learnable cluster centroids as $\mathcal{C} = \{ \mu_{1}, ..., \mu_{K_t} \}$.
\noindent\textbf{Source-guided Clustering Loss.} Our method learns to recover clustering structures of both seen and unseen categories guided by source labels. To achieve this, we utilize an auto-encoder to extract hidden embeddings, apply clustering regularization on the embedding space to separate both seen and unseen categories, and align seen cluster centroids with source labels. In this way, we break down the source-guided clustering loss into three parts: {{self-reconstruction}}, {{clustering regularization}}, and {{source centroid alignment}}.
\noindent{\textit{Self-reconstruction.}} Self-reconstruction loss helps the encoder and decoder extract clustering-favorable hidden embeddings with minimal information loss. It is defined as:
\begin{equation}
\mathcal{L}_{self} = \frac{1}{N_s} \sum_i^{N_s} \lVert x^s_i - h \circ g(x^s_i) \rVert^2_2 + \frac{1}{N_t} \sum_i^{N_t} \lVert x^t_i - h \circ g(x^t_i) \rVert^2_2,
\end{equation} where $\circ$ represents function composition.
\noindent{\textit{Clustering Regularization.}} Following Deep Embedding Clustering~\cite{xie2016unsupervised}, we model the cluster assignment with a probability distribution. Specifically, the similarity between an embedding instance $z_i$ to a cluster centroid $\mu_k$ is measured with a Student-t distribution:
\begin{equation}
p^{z}_{ik} = \frac{(1 + \lVert z_i - {\mu}_k \rVert^{2}_2)^{-1}}{\sum_{j=1}^{K_t}(1 + \lVert z_i - {\mu}_j \rVert^{2}_2)^{-1}}.
\label{eq:cluster}
\end{equation}
Subsequently, an auxiliary target distribution is employed to strengthen cluster prediction. The target distribution is defined by
\begin{equation}
q^{z}_{ik} = \frac{(p^{z}_{ik})^2 / \sum_j^{N_t} p^z_{jk}}{\sum_{j'}^{K_t} (p^z_{ij'})^2 / \sum_{j}^{N_t} p^z_{jj'}}.
\end{equation}
The clustering regularization loss measures the difference between the cluster assignment distribution and target distribution. By minimizing their divergence, data points are pulled toward the likely cluster centroid and pushed away from others. Mathematically, the clustering regularization loss is defined as
\begin{equation}
\mathcal{L}_{reg} = \frac{1}{N_t} \sum_{i=1}^{N_t} D_{KL}(p^{z}_i || q^{z}_i) = \frac{1}{N_t} \sum_{i=1}^{N_t} \sum_{k=1}^{K_t} p^z_{ik} \log \frac{p^z_{ik}}{q^z_{ik}}.
\end{equation}
\noindent{\textit{Source Centroid Alignment.}} The source centroid alignment loss pulls source samples toward their corresponding cluster centroids. This is achieved by optimizing the prototypical probability distribution defined by the distance between data points and cluster centroids. The prototypical probability of a data point $z_i$ given a cluster centroid $\mu_k$ is
\begin{equation}
\label{eq:prototypical}
\mathcal{P}(z_i | \mu_k) = \frac{\exp(- d(z_i, \mu_k ))}{\sum_{k' \leq K_s} \exp(- d(z_i, \mu_{k'}))},
\end{equation}
where $d$ is an Euclidean distance function and the source centroid alignment loss is
\begin{equation}
\mathcal{L}_{cent} = \frac{1}{N_s} \sum_{i=1}^{N_s}\mathcal{L}(\mathcal{P}_i, y_i),
\end{equation}
where $\mathcal{L}$ denotes the cross entropy loss. To address the potential distribution drift of seen categories between the source and target dataset, we incorporate an optional loss to reduce the gap between source and target seen class centroids. We first define the expected target seen class centroid
\begin{equation}
\Tilde{\mu}_k := \mathbb{E}_{\hat{y}^t_i = k} z^t_i,
\end{equation}
where $\hat{y}^t_i = \arg_k \max p^{z}_{ik}$ is the pseudo label obtained from cluster assignment probability. The source centroid alignment loss under distribution shift is defined as
\begin{equation}
\mathcal{L}_{cent} = \frac{1}{N_s} \sum_{i=1}^{N_s}\mathcal{L}(\mathcal{P}_i, y^i_s) + \frac{1}{K_s} \sum_{k=1}^{K_s} \lVert \Tilde{\mu}_k - \mu_k \rVert^2_2.
\end{equation}
Finally, the source-guided clustering loss combines self-reconstruction loss, clustering regularization loss, and source centroid alignment loss:
\begin{equation}
\mathcal{L}_{c} = \mathcal{L}_{self} + \mathcal{L}_{reg} + \mathcal{L}_{cent}.
\end{equation}
\noindent\textbf{Semantic Prediction Loss}. Following \citet{frome2013devise}, we use a pairwise ranking loss to learn the embedding-to-semantic mapping, where we stop penalizing false terms after the maximum margin of 0.5 is reached.
\begin{equation}
\mathcal{L}_a = \frac{1}{N_s} \sum_{i=1}^{N_s} \sum_{k \neq y_s^i} \max \{0, 0.5 - A_{y_i}^\top a^s_i + A_k^\top a^s_i \},
\end{equation}
where $A_{k}$ is the ground truth semantic label of class $k$.
\noindent\textbf{Structural Alignment Loss}. Structural alignment guides semantic learning by transferring the structural knowledge in the embedding space to the semantic space. Specifically, the structural alignment loss minimizes the divergence between embedding and semantic cluster structures modeled by the cluster assignment probability. We have defined the cluster assignment probability in the embedding space $p_{ik}^z$ in Eq.~\eqref{eq:cluster}. Similarly, the cluster assignment probability in the semantic space can be defined by $p^{a}_{ik}$, where
\begin{equation}
p^{a}_{ik} = \frac{(1 + \lVert a_i - f(\mu_k) \rVert^{2}_2)^{-1}}{\sum_{j=1}^{K_t}(1 + \lVert a_i - f(\mu_j) \rVert^{2}_2)^{-1}}.
\label{eq:semanticcluster}
\end{equation}
Based on Eq.~\eqref{eq:cluster} and Eq.~\eqref{eq:semanticcluster}, we define the structural alignment loss as
\begin{equation}
\mathcal{L}_{align} = \frac{1}{N_t} \sum_{i=1}^{N_t} \sum_{j=1}^{N_t} ( {p_i^z}^\top p_j^z - {p_i^a}^{\top} p_j^a )^2,
\end{equation}
where ${p_i^z}^\top p_j^z$ measures the probability that data points $i$ and $j$ in the embedding space belonging to the same cluster.
\noindent\textbf{Overall Objective Function}. The overall learning objective is to minimize the source-guided clustering loss, semantic prediction loss, and structural alignment loss:
\begin{equation}
\min_{g, h, f, \mathcal{C}} \mathcal{L}_{c} + \alpha \mathcal{L}_a + \beta \mathcal{L}_{align},
\end{equation} where $\alpha$ and $\beta$ are trade-off parameters.
\label{sec:method}
\section{Experiments}
\subsection{Experimental Settings}
\begin{wraptable}{R}{0.5\textwidth}
\centering
\caption{
Characteristics of four benchmark datasets.
}
\scriptsize
\resizebox{.9 \linewidth}{!}{
\begin{tabular}{c|cccccc}
\toprule
Dataset & Source & Target\_s & Target\_t & $K_s$ & $K_t$ & $d$ \\
\midrule
APY & 5932 & 7924 & 1483 & 20 & 32 & 64 \\
CUB & 8855 & 2973 & 1764 & 150 & 200 & 312 \\
AWA2 & 19832 & 5685 & 4958 & 40 & 50 & 85 \\
SUN & 12900 & 1440 & 2580 & 645 & 717 & 102 \\
\bottomrule
\end{tabular}
}
\begin{tablenotes}
\item \parbox[t]{7.5 cm}{Note: Target\_s and Target\_t denote the sample numbers of seen and unseen categories in the target domain.}
\end{tablenotes}
\label{tab:characteristic}
\vspace{-3mm}
\end{wraptable}
\noindent\textbf{Datasets}. We choose four commonly used attribute datasets: Attribute Pascal and Yahoo (APY) \cite{farhadi2009apy}, Animals with Attributes 2 (AWA2) \cite{lampert2013awa}, Caltech-UCSD-Birds 200-2011 (CUB) \cite{wah2011cub}, and SUN dataset \cite{xiao2010sun}. We split the data into the source and target sets by following the split strategy in \citet{xian2017benchmark}. All visual features are obtained from ResNet-101 \cite{he2016resnet} pre-trained on ImageNet \cite{deng2009imagenet}. Table \ref{tab:characteristic} summarizes the key characteristics of these datasets. Only the semantic attributes of seen categories are available for training. We use unit vectors as semantic representations.
\noindent\textbf{Competitive Methods}. We compare our method with established methods in Generalized Zero-Shot Learning and Semantic Recovery Open-Set Domain Adaptation. For GZSL based methods, it is noteworthy that not all established methods work under our setting, where unseen semantics are not provided. For example, generative-based methods, which require unseen semantics to synthesize samples of novel categories, are not applicable under ZK-ZSL. We compare with DEVISE \cite{frome2013devise}, ESZSL \cite{romera2015eszsl}, SJE \cite{akata2015sje} and SDGZSL \cite{chen2021sdgzsl}. In particular, DEVISE, SJE, and ESZSL aim to find a mapping from visual space to semantic space, while SDGZSL learns a hidden embedding from visual features that can be decomposed to semantic-consistent representation and semantic-unrelated representation. In the next section, we elaborate on how to tailor the above methods to the ZK-ZSL setting. In addition, we compare with \citet{jing2021taotao} as the only existing SR-OSDA-based method. Their approach progressively separates seen and unseen samples with pseudo labels obtained from prototypical probabilities and utilizes a graph neural network for semantic attribute prediction to avoid overfitting.
\noindent\textbf{Implementation}. Here we first introduce how we extend the competitive methods for novel category prediction, then elaborate on the implementation details of our method.
Since the competitive methods only predict semantic attributes or hidden embeddings, we need to extend their approaches to support novel categories prediction. To this end, we adopt a two-step procedure that first recognizes seen and unseen samples and then further separates unseen samples with K-means. We rely on the prototypical probability defined in Eq.~\eqref{eq:prototypical} for seen/unseen separation. We first define the highest prototypical probability that a data point belongs to a seen category:
\begin{equation}
\mathcal{P}^{max}_i = \max_k \mathcal{P}(z_t^i | \mu_k).
\end{equation}
Data points with higher $\mathcal{P}^{max}$ are more likely from a seen category, while unseen samples tend to have more even prototypical probability distributions, and thus lower $\mathcal{P}^{max}$. We follow \citet{jing2021taotao} to choose a threshold where the data points with $\mathcal{P}^{max}$ higher than $\tau = \frac{1}{N_t} \sum_i \mathcal{P}^{max}_i$ are recognized as seen samples, and classified by their corresponding class centroids; those with lower $\mathcal{P}^{max}$ are regarded as unseen samples and predicted by K-means implemented by Scikit-learn \cite{scikit-learn}. Let unseen class centroids predicted by K-means be $\{ \hat{\mu}_{K_s + 1}, ..., \hat{\mu}_{K_t} \}$, we define classification prediction as
\begin{equation}
\hat{y}_t^i =
\begin{cases}
\arg \max_{k \leq K_s} \mathcal{P}(z_t^i | \mu_k) & \text{if \ } \mathcal{P}^{max}_i \geq \tau \text{,} \\
\arg \min_{K_s < k \leq K_t} d(z_t^i, \hat{\mu}_k) & \text{otherwise.}
\end{cases}
\end{equation}
In our framework, the encoder and decoder constitute a de-noising autoencoder. Specifically, the encoder and decoder are 5 linear layers followed by batch normalization and Leaky ReLU activation. Their neural structures are dropout-2048-512-256-256-4096-$h$ and dropout-$h$-4096-256-256-512-2048, respectively, where $h$ is the dimension of the hidden embeddings. We set the dropout rate to $0.01$ for all experiments and choose $h = 256$ for APY and AWA2 datasets and $h = 1024$ for CUB and SUN datasets. The semantic prediction head is a linear layer with batch normalization. Our model parameters are initialized by pretraining with self-reconstruction loss and semantic prediction loss, and class centers are initialized with K-means. We use Adam optimizer \cite{kingma2014adam} with a learning rate of $1e^{-3}$ and weight decay of $1e^{-5}$ in the pretraining stage, and then learning rate is adjusted to $1e^{-4}$ for training. Learning rates are reduced by a factor of 0.1 every 200 epochs for both stages.
\noindent\textbf{Metrics}. We evaluate model performance from two perspectives: classification and semantic recovery accuracy.
\begin{table*}[t]
\centering
\caption{
Classification and Semantic Recovery Accuracy on four benchmark datasets.
}
\scriptsize
\begin{tabular}{c|c|S[table-format=2.1]S[table-format=2.1]S[table-format=2.1]|S[table-format=2.1]S[table-format=2.1]S[table-format=2.1]|S[table-format=2.1]S[table-format=2.1]S[table-format=2.1]|S[table-format=2.1]S[table-format=2.1]S[table-format=2.1]}
\toprule
& \multicolumn{1}{c}{Dataset} & \multicolumn{3}{c}{APY} & \multicolumn{3}{c}{CUB} & \multicolumn{3}{c}{AWA2} & \multicolumn{3}{c}{SUN}\\
\midrule
& \multicolumn{1}{c|}{Method} & \multicolumn{1}{c}{$Acc_s$} & \multicolumn{1}{c}{$Acc_u$} & \multicolumn{1}{c|}{$Acc_h$} & \multicolumn{1}{c}{$Acc_s$} & \multicolumn{1}{c}{$Acc_u$} & \multicolumn{1}{c|}{$Acc_h$} & \multicolumn{1}{c}{$Acc_s$} & \multicolumn{1}{c}{$Acc_u$} & \multicolumn{1}{c|}{$Acc_h$} & \multicolumn{1}{c}{$Acc_s$} & \multicolumn{1}{c}{$Acc_u$} & \multicolumn{1}{c}{$Acc_h$} \\
\cmidrule{2-14}
\multirow{6}{*}{\vspace{-10mm}\turnbox{90}{Classification}} & DEVISE$^*$ & \BlueText 76.4 & 13.0 & 22.2 & 37.1 & 15.8 & 22.2 & 69.2 & 24.5 & 36.2 & 18.4 & 21.9 & 20.0 \\
& ESZSL$^*$ & \RedText 77.2 & 17.0 & 27.8 & 35.9 & 23.8 & 28.6 & 67.5 & \BlueText 40.3 & \BlueText 50.4 & 16.6 & 18.6 & 17.6 \\
& SJE$^*$ & 74.1 & 9.2 & 16.3 & 34.1 & 9.3 & 14.6 & 57.0 & 13.2 & 21.5 & 17.2 & 17.6 & 17.4 \\
& SDGZSL$^\diamond$ & 71.1 & \BlueText 22.5 & \BlueText 34.2 & \RedText 58.0 & 33.6 & \RedText 42.5 & \BlueText 79.6 & 27.9 & 41.4 & \RedText 32.8 & \RedText 26.5 & \RedText 29.3 \\
& SR-OSDA$^*$ & 24.2 & 15.4 & 18.8 & 2.7 & 11.7 & 4.4 & 27.0 & 18.6 & 22.0 & 5.0 & 11.7 & 9.7 \\
\cmidrule{2-14}
& Ours & 48.2 & \RedText 30.6 & \RedText 37.4 & \BlueText 43.8 & \RedText 35.4 & \BlueText 39.2 & \RedText 82.8 & \RedText 47.6 & \RedText 60.5 & \BlueText 23.5 & \BlueText 24.8 & \BlueText 24.1 \\
\midrule
& \multicolumn{1}{c|}{Method} & \multicolumn{1}{c}{$SR_s$} & \multicolumn{1}{c}{$SR_u$} & \multicolumn{1}{c|}{$SR_h$} & \multicolumn{1}{c}{$SR_s$} & \multicolumn{1}{c}{$SR_u$} & \multicolumn{1}{c|}{$SR_h$} & \multicolumn{1}{c}{$SR_s$} & \multicolumn{1}{c}{$SR_u$} & \multicolumn{1}{c|}{$SR_h$} & \multicolumn{1}{c}{$SR_s$} & \multicolumn{1}{c}{$SR_u$} & \multicolumn{1}{c}{$SR_h$} \\
\cmidrule{2-14}
\multirow{6}{*}{\vspace{-12mm}\turnbox{90}{Semantic Recovery}} & DEVISE & 2.6 & \BlueText 9.7 & 4.1 & 37.8 & \BlueText 24.4 & \BlueText 29.6 & 61.1 & \BlueText 26.7 & \BlueText 37.2 & \BlueText 29.4 & 14.8 & 19.7 \\
& ESZSL & \RedText 83.6 & 1.4 & 2.8 & \RedText 55.5 & 11.5 & 19.0 & \RedText 88.5 & 2.2 & 4.3 & 27.3 & 13.1 & 17.7 \\
& SJE & 7.5 & 9.4 & \BlueText 8.3 & 0.8 & 11.6 & 1.4 & 41.8 & 20.4 & 27.4 & 27.0 & \BlueText 16.8 & \BlueText 20.7 \\
& SR-OSDA & 3.4 & 0.7 & 1.2 & 0.3 & 0.2 & 0.3 & 2.7 & 0.4 & 0.7 & 0.2 & 0.3 & 0.2 \\
\cmidrule{2-14}
& Ours & \BlueText 60.4 & \RedText 17.5 & \RedText 27.2 & \BlueText 52.4 & \RedText 25.1 & \RedText 33.9 & \BlueText 84.6 & \RedText 32.9 & \RedText 47.4 & \RedText 36.8 & \RedText 18.2 & \RedText 24.4 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item \hspace{12mm} Note: $*$ represents evaluation in semantic space, and $\diamond$ represents evaluation in embedding space.
\end{tablenotes}
\vspace{-2mm}
\label{tab:Acc}
\end{table*}
In the same spirit of the evaluation metrics proposed in \citet{xian2017benchmark}, our classification accuracy measures the class average accuracy of seen and unseen categories and their harmonic mean. We define the classification accuracy of seen categories as the average per-class accuracy:
\begin{equation}
Acc_s = \frac{1}{N_s} \sum_{k \leq K_s} \frac{\sum_i \mathds{1}_{\hat{y}_t^i = y_t^i}}{\sum_i \mathds{1}_{y_t^i = k}},
\end{equation} where $\mathds{1}$ is an indicator function. Similarly, we define the classification accuracy of unseen category as
\begin{equation}
Acc_u = \frac{1}{N_t - N_s} \sum_{K_s < k \leq K_t} \frac{\sum_i \mathds{1}_{map(\hat{y}_t^i) = y_t^i}}{\sum_i \mathds{1}_{y_t^i = k}},
\end{equation} where $map()$ is a permutation function that maps predicted unseen categories to ground-truth unseen counterparts. Finally, we evaluate the harmonic mean of seen and unseen classification accuracy:
\begin{equation}
Acc_h = 2 \times \frac{Acc_s \times Acc_u}{Acc_s + Acc_u}.
\end{equation}
\begin{figure*}[t]
\centering
\begin{subfigure}{0.2 \textwidth}
\resizebox{1 \textwidth}{!}{{\includegraphics{figs/confuse_devise_alone_draw.png}};
}
\caption{DEVISE}
\label{fig:confuse_a}
\end{subfigure}
\begin{subfigure}{0.2 \textwidth}
\resizebox{\textwidth}{!}{{\includegraphics{figs/confuse_eszsl_alone_draw.png}};
}
\caption{ESZSL}
\label{fig:confuse_b}
\end{subfigure}
\begin{subfigure}{0.2 \textwidth}
\resizebox{\textwidth}{!}{{\includegraphics{figs/confuse_sdzsl_alone_draw.png}};
}
\caption{SDGZSL}
\label{fig:confuse_b}
\end{subfigure}
\begin{subfigure}{0.38 \textwidth}
\resizebox{\textwidth}{!}{{\includegraphics{figs/ours_alone_draw.png}};
}
\caption{Ours}
\label{fig:confuse_c}
\end{subfigure}\vspace{-1mm}
\caption{Confusion matrices of seen and unseen categories on the AWA2 dataset. Recommended to zoom in for better visualization.}\vspace{-3mm}
\label{confusion matrices}
\end{figure*}
In addition to classification accuracy, we want to evaluate the model's ability to accurately uncover the target dataset's semantic attributes. Following \citet{xian2017benchmark}, we define the semantic recovery prediction as
\begin{equation}
\Tilde{y}_t^i = \arg \max_k A_k^\top a_t^i.
\end{equation}
Similarly, semantic recovery accuracies $SR_s$, $SR_u$, and $SR_h$ follow the derivation of classification accuracies.
For DEVISE, SJE, and ESZSL, we evaluate their classification accuracies with their predicted semantic attributes, where the class centroids of seen categories are ground truth semantic labels. We evaluate SDGZSL classification ability with its generated semantic-consistent representation, and because it does not have a semantic prediction component, we exclude it from semantic recovery evaluation. We use the cosine distance when calculating prototypical probability in the semantic space and use Euclidean distance in the embedding space.
\subsection{Performance}
\begin{figure*}[t]
\centering
\subcaptionbox{\label{sfig:a} Bobcat}{\includegraphics[width=3.5cm]{figs/ex_bobcat_912_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:b} Dolphin}{\includegraphics[width=3.5cm]{figs/ex_dolphine_1218_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:c} Sheep}{\includegraphics[width=3.5cm]{figs/ex_sheep_4916_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:d} Giraffe}{\includegraphics[width=3.5cm]{figs/ex_giraffe_2311_draw.png}}
\subcaptionbox{\label{sfig:e} Rat}{\includegraphics[width=3.5cm]{figs/ex_rat_3406_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:f} Seal}{\includegraphics[width=3.5cm]{figs/ex_seal_3873_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:g} Bat}{\includegraphics[width=3.5cm]{figs/ex_bat_74_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:d} Horse}
{\includegraphics[width=3.5cm]{figs/ex_horse_draw.png}}\vspace{-2mm}
\caption{Examples of novel categories and predicted semantic attributes. The predicted semantics are ordered by compatibility with ground-truth labels, where the top is the most compatible semantic attribute. \textcolor{red}{Red} indicates a wrong prediction, and \textcolor{green}{Green} indicates a wrong prediction but is consistent with the given instance. }
\vspace{-2mm}
\label{fig:examples}
\end{figure*}
\begin{figure*}[t]
\centering
\subcaptionbox{ \label{sfig:a} ResNet}
{\vspace{-2mm} \includegraphics[width=3.5cm]
{figs/ResNet_feat.png}}
\subcaptionbox{
\label{sfig:b} SJE}{\vspace{-2mm} \includegraphics[width=3.5cm]{figs/sje_att.png}
}
\subcaptionbox{\label{sfig:c} Ours (embedding)}{\vspace{-2mm} \includegraphics[width=3.5cm]{figs/Model_Hidden.png}}
\subcaptionbox{\label{sfig:d} Ours (semantic)}{\vspace{-2mm} \includegraphics[width=3.5cm]{figs/Model_att.png}}
\vspace{-2mm}
\caption{t-SNE visualization of (a) ResNet features, (b) semantic attribute predicted by SJE \cite{akata2015sje}, (c) hidden embedding generated by our method, and (d) semantic attribute predicted by our method. \textcolor{red}{Red} represents source data points. \textcolor{blue}{Blue} and \textcolor{gray}{Gray} highlight data points in the target dataset that belong to unseen and seen categories, respectively.}
\label{fig:visualization}
\vspace{-2mm}
\end{figure*}
Table \ref{tab:Acc} summarizes the classification accuracy and semantic recovery accuracy for four benchmark datasets, where red and blue highlight the highest and second highest accuracies.
For the classification accuracy measurement, we obverse that our method attains the best overall performance in APY and AWA2 while achieving the second-highest overall accuracy in CUB and SUN. It is noteworthy that for the AWA2 dataset, our method brings a 10.1\% overall accuracy improvement compared with the second-highest baseline. Our superior performance in APY and AWA2 partly results from our improved unseen category classification accuracy, which demonstrates the effectiveness of our structural alignment and source-guided clustering component. In comparison, we see a trend of overfitting on the source dataset for some baseline methods, which destroys the clustering structure of unseen samples. For example, regarding the performance on the APY dataset, DEVISE achieves 76.4\% seen classification accuracy but only attains 13.0\% for the unseen category. In addition, we observe our method does not improve overall classification accuracy in CUB and SUN, compared with the best-performing SDGZSL baseline. We hypothesize that this is due to a reduced number of samples per class in the target dataset. There are, on average, 293 and 212 samples per class in APY and AWA2, respectively, but for CUB and SUN there are only 23 and 6 samples. This leads to (1) distribution drift of seen category samples, which undermines our method's capability to classify seen samples correctly, and (2) underrepresented novel class samples, which complicates their clustering structures recovery.
For the semantic recovery accuracy measurement, our method achieves the best performance in terms of unseen category semantic recovery and overall semantic recovery accuracy. This demonstrates that our structural alignment loss can effectively prevent overfitting on the source semantic data and accurately predict the semantic attributes of unseen categories. In comparison, we observe a similar pattern in classification that some baselines can accurately recover semantics of seen categories, but not for unseen samples. For example, ESZSL achieves 83.6\% for seen semantic recovery but only 1.4\% for unseen categories.
\subsection{Factor Exploration}
To further explore our method, we explore confusion matrices of seen and unseen categories, visualize representations obtained by our method, showcase some representative samples and their associated predictions, analyze the ablation study of our model components, and visualize our predicted semantic attributes of novel categories with word clouds. Finally, we explore hyper-parameters $\alpha$ and $\beta$.
\noindent\textbf{Confusion Matrices.} We visualize confusion matrices of different methods on the AWA2 dataset, including DEVISE, ESZSL, SDGZSL, and ours in Figure \ref{confusion matrices}. We observe that our method has much fewer false predictions for novel categories. It is noteworthy that our method classifies four unseen categories with 90+\% accuracy. We also see that our method improves classification accuracy for seen categories.
\begin{wrapfigure}[17]{R}{0.5\textwidth}
\centering{\includegraphics[width=8cm]{figs/ablation.jpg}}\vspace{-2mm}
\caption{Ablation study results of our proposed method on AWA2 dataset. We report the performance of variants that are trained without structural alignment loss (SA), without source-guided clustering loss (SC), without semantic prediction loss (SP), and with our proposed method. The left shows semantic recovery accuracy, and the right shows classification accuracy.}
\label{fig:ablation}
\vspace{-4mm}
\end{wrapfigure}
\begin{figure}[t]
\centering{
\vspace{-4mm}
\includegraphics[width=0.95\textwidth]{figs/word_cloud_flat.jpeg}}\vspace{-1mm}
\caption{Word clouds of novel category semantics predicted by our model, including (a) bobcat, (b) giraffe, (c) sheep, (d) bat, and (e) whale. Recommended to zoom in for better visualization.}
\label{fig:WordCloud}
\vspace{-5mm}
\end{figure}
\noindent\textbf{Representation Visualization.}
In Figure \ref{fig:visualization}, we visualize different representations of the AWA2 dataset with t-SNE \cite{van2008tsne}, including the ResNet features, semantic attributes predicted by SJE, our method's hidden embedding, and our predicted semantic attributes. Red dots represent data points in the source dataset, while blue and gray dots represent target data points that belong to seen and unseen categories, respectively. For our hidden embedding visualization, we observe a much clearer separation among clusters compared with the ResNet input and SJE prediction, which is achieved with our source-guided clustering component. In addition, our recovered semantic attributes have similar structures of hidden embeddings, showing that our structural alignment loss is effective.
\noindent\textbf{Qualitative Analysis.} In Figure \ref{fig:examples}, we showcase some representative samples from novel categories in the AWA2 dataset, including the input image and predicted semantic attributes ordered by compatibility to the ground-truth semantic labels. The compatibility is calculated by an element-wise multiplication between the predicted semantic attribute scores and ground truth. We regard a predicted attribute with positive compatibility as a correct prediction and vice versa. The most compatible predicted semantics are discriminative for the given category. For least compatible attributes, some valid attributes are not predicted, which is indicated by red in Figure \ref{fig:examples}, and some predicted attributes (in green) are not relevant to the given category but reasonable for the given instance.
\noindent\textbf{Ablation Study.} We explore the effectiveness of our designed components with an ablation study. Specifically, we individually train variants of our framework with the AWA2 dataset that are (1) without structural alignment loss $\mathcal{L}_{align}$, (2) without source-guided clustering loss $\mathcal{L}_{c}$, and (3) without semantic prediction loss $\mathcal{L}_{a}$. In Figure \ref{fig:ablation}, we report and compare the classification accuracy and semantic recovery accuracy. We first observe that our method achieves the best overall performance when trained with all objectives. In addition, semantic recovery accuracy and seen category classification accuracy are improved with structural alignment loss, which indicates that structural alignment helps hidden embedding and semantic learning.
\noindent\textbf{Novel Category Visualization.} Figure \ref{fig:WordCloud} visualizes our predicted semantic attributes of discovered novel categories through word clouds generated by \citet{wordcloud}. We select the 50 most significant attributes ordered by their predicted scores for visualization and adjust font sizes according to their relative ranking. We observe that the most significant attributes are consistent with the corresponding category.
\noindent\textbf{Hyperparameter Analysis.} $\alpha$ and $\beta$ control the contributions of the semantic prediction loss and structural alignment loss and, by default, are set to 1.0 and 1.0. Here we explore the volatility of these parameters and verify our default choice by doing a hyperparameter analysis on the AWA2 dataset. When $\alpha$ is fixed at 1.0, and $\beta$ is explored in the range of $\{0, 0.1, 0.5, 1.0, 5.0, 10.0\}$, we observe that the classification and semantic recovery accuracy increase as $\beta$ increases, and reach the optimal values of $59.7\%$ and $50.9\%$ when $\alpha = 1.0$ and $\beta = 1.0$. As $\beta$ further increases, $Acc_u$ and $SR_u$ decline to $30.6\%$ and $45.4\%$. When $\beta$ is pinned at 1.0 and $\alpha$ is set in the range of $\{0, 0.1, 0.5, 1.0, 5.0, 10.0\}$, the $Acc_u$ and $SR_u$ form an inverted U pattern where they start at $47.0\%$ and $0.3\%$, reach the optimal combination, then reduce to $56.8\%$ and $42.1\%$. The optimal values are obtained at $\alpha = \beta = 1.0$.
\section{Conclusion}
In this work, we explore a novel and practical setting in visual recognition named Zero-Knowledge Zero-Shot Learning, addressing the limitations of GZSL and OSR. ZK-ZSL aims to recognize categories present in the source dataset as well as additional novel categories without prior knowledge and recover their semantic attributes. We consider the challenges associated with ZK-ZSL from two aspects: (1) the demand to further separate unseen categories, where training a classifier with only source labels could destroy the structures of unseen categories, and (2) the unavailability of unseen semantic labels that could cause inaccurate and biased semantic predictions. Our proposed method learns to recover the clustering structures of both seen and unseen categories in the target dataset, where the seen class centroids are guided by source labels. A novel structural alignment loss is designed to aid semantic learning of unseen categories with their recovered clustering structures. Experimental analyses show that our method achieves superior performance in terms of classification and semantic recovery on four benchmark datasets.
\clearpage
\bibliographystyle{plainnat}
\section{Introduction}
In recent years, visual recognition with deep learning has made tremendous progress. Closed-set is a common assumption in deep visual recognition where the training and testing datasets have a shared label space. However, data insufficiency and unavailability in real-world applications make it difficult to satisfy and pose significant challenges to visual classifiers. To this end, Generalized Zero-Shot Learning (GZSL) and Open-Set Recognition (OSR) are proposed to extend traditional visual recognition by acknowledging the existence of unknown categories in the target dataset. Specifically, GZSL aims to recognize both seen and unseen classes given labeled semantic attributes. The goal of OSR is to classify seen samples and detect unseen ones without prior information. Unfortunately, GZSL and OSR still have limitations in practical use. For example, the notion of novel\footnote{In this paper, we use unseen and novel interchangeably. } categories in GZSL is pre-determined by the provided semantic labels. However, knowing the novel semantic attributes implies the existence of images from unseen categories. Then the problem can be simply reduced to supervised learning by collecting training samples of novel categories. In this sense, the GZSL problem is less practical as the model is expected to automatically discover novel categories on its own.
In addition, OSR recognizes unseen categories as a whole without further analysis of their intrinsic fine-grained structures. Furthermore, OSR does not consider the semantics of visual categories, failing to provide richer information for in-depth analyses and interpretation of novel categories.
In this paper, we explore a novel setting named Zero-Knowledge Zero-Shot Learning (ZK-ZSL) that addresses the aforementioned limitations of GZSL and OSR. Figure~\ref{fig:schemaicviews} illustrates the difference between GZSL, OSR, and our setting. ZK-ZSL aims to recognize both seen and unseen classes without prior knowledge of novel categories and recover their semantic attributes of the fine-grained novel categories. In this setting, only semantic labels of the seen categories are available. Compared with GZSL and OSR, the challenges of ZK-ZSL lie in the following aspects. (1) A classifier trained on the seen label space might separate seen samples from unseen samples, but cannot further separate samples in fine-grained unseen categories, and the biased embedding learned from the seen categories could potentially destroy underlying structures of unseen categories. (2) Since the semantic labels of unseen categories are unavailable, training only with seen semantics is susceptible to overfitting and leads to biased semantic predictions.
\begin{wrapfigure}[15]{R}{0.5\textwidth}
\vspace{-2mm}
\centering
\includegraphics[width=0.9 \linewidth]{figs/schematicview.jpg}\vspace{-2mm}
\caption{Schematic illustrations of GZSL, OSR, and our explored Zero-Knowledge Zero-Shot Learning (ZK-ZSL).}
\label{fig:schemaicviews}
\vspace{-5mm}
\label{sec:intro}
\end{wrapfigure}
We propose a novel framework to tackle the ZK-ZSL problem and address the above challenges. In what follows, we first discuss how our proposed method takes into account the aforementioned challenges, and then we summarize our main contributions. To recognize seen classes and discover the structures of novel categories, our method learns to cluster on the target data consisting of both seen and unseen categories. Meanwhile, the class structures of seen categories are guided by the source labels. In addition, to mitigate the unavailability problem of unseen semantic labels, we enforce a structural alignment between recovered hidden embedding and predicted semantic space to aid the semantic learning of unseen categories with their discovered clustering structures. Our main contributions can be summarized as follows:
\begin{itemize}
\vspace{-1mm}
\item \parbox[t]{\dimexpr\textwidth-\leftmargin}{We formulate and explore a new visual recognition setting named Zero-Knowledge Zero-Shot Learning (ZK-ZSL) that aims to recognize seen and unseen categories without prior knowledge and recovers unseen semantic attributes, addressing the limitations of GZSL and OSR in practical use.}
\vspace{-1mm}
\item \parbox[t]{\dimexpr\textwidth-\leftmargin}{We propose a novel method that learns to uncover clustering structures in the target dataset guided by labeled seen class structures. A novel structural alignment loss is designed to aid the learning of novel semantic attributes with recovered clustering structures.}
\vspace{-1mm}
\item \parbox[t]{\dimexpr\textwidth-\leftmargin}{We demonstrate the superiority of our method in terms of classification and semantic recovery on four benchmark datasets by comparing with five competitive baseline methods. We also provide rich in-depth explorations of our method for unseen category discovery.}
\vspace{-1mm}
\end{itemize}
\vspace{-2mm}
\section{Related Works}
\noindent\textbf{Generalized Zero-Shot Learning.} The demand to recognize novel classes not present during training without additional labeling motivates the area of Zero-Shot Learning (ZSL). In ZSL, class-level semantic attributes are provided to aid knowledge transfer from source to the target dataset. Later, due to the disjoint nature of the source and target label spaces, GZSL is hence proposed~\cite{pourpanah2022review}, where the target dataset consists of categories present in the source dataset and additional novel categories. Existing GZSL methods can be categorized into embedding-based and generative-based methods. Embedding-based methods learn to map visual features to the semantic space and make predictions based on the similarity between predicted semantics and ground truth \cite{frome2013devise, akata2015sje, romera2015eszsl, xu2020attribute, xie2019attentive, xie2020region, liu2021goal}. Generative-based methods synthesize samples from semantic attributes through Generative Adversarial Networks (GANs) \cite{goodfellow2020gan} or Variational Autoencoders (VAEs) \cite{kingma2013vae}, and reformulate the GZSL problem to a conventional supervised learning problem by training a classifier with generated samples \cite{li2019leveraging, xian2018feature, mishra2018generative, zhu2018generative, yu2020episode}.
\noindent\textbf{Open-Set Recognition.} OSR extends the traditional closed-set classification setting by assuming the target samples contain categories seen during training and additional unseen categories. Under OSR, classifiers need to be able to recognize seen samples and reject unknown samples \cite{geng2020osr}. OSR methods usually adopt a threshold-based strategy, where the threshold can be empirically chosen. Existing methods differ in how they discriminate seen categories, including SVM-based \cite{cortes1995svm, scheirer2012toward, scheirer2014probability, jain2014multi}, distance-based \cite{bendale2015towards, papa2009supervised, mendes2017nearest}, and deep learning based methods\cite{bendale2016towards, hassen2020learning, shu2017doc, hughes2017medical, kardan2017mitigating}.
In addition to GZSL and OSR, we notice the recently proposed Semantic Recovery Open-Set Domain Adaptation (SR-OSDA) \cite{jing2021taotao} and the Generalized Category Discovery (GCD) \cite{vaze2022generalized, wen2022simple, chiaroni2022mutual} are related to our setting. SR-OSDA aims to recognize both seen and unseen samples in the target dataset and recover their semantic attributes.
The goal of GCD is to automatically categorize a partially labeled dataset of images, where the unlabeled images contain both seen and novel categories, but GCD does not consider semantic recovery.
\section{Motivation and Problem Definition}\label{sec:problem}
GZSL aims to recognize categories both seen and unseen during training, given semantic attributes of all classes. However, novel categories are pre-defined with semantic labels and are known to the model, which can be impractical for some applications. OSR aims to detect unseen samples without prior information but treats them as one group, failing to explore their innate structures further. Moreover, the semantic attributes of visual categories are not utilized under OSR, which prevents in-depth analyses and interpretations of the structures of novel categories.
Due to the limitations of GZSL and OSR, we consider the \textbf{Zero-Knowledge Zero-Shot Learning (ZK-ZSL)} problem, which focuses on recognizing seen and unseen categories without prior knowledge of novel semantic labels while uncovering the partitional structures of novel categories and their missing semantic attributes. Inspired by the paradigm style in \citet{pourpanah2022review}, we illustrate the main differences among GZSL, OSR, and ZK-ZSL in Figure~\ref{fig:schemaicviews}. Compared with GZSL and OSR, ZK-ZSL is more realistic in that it does not assume prior knowledge of the unseen categories, and it can support richer analysis and interpretation of the discovered novel categories. Here we provide problem formulation of ZK-ZSL: Let $D_s = \{X_s, Y_s, A_s\}$ be the source dataset, and $D_t = \{X_t\}$ be the target dataset. Given both $D_s$ and $D_t$, ZK-ZSL aims to find $X_t$'s corresponding $Y_t$, which contains all visual categories in $Y_s$ and some additional unseen categories $Y_u = Y_t \setminus Y_s$, and recover their semantic attributes $A_t$. Table~\ref{tab:notation} summarizes the major notations used in this paper.\footnote{In the following, we might put $s/t$ in the superscript and the sample index in the subscript if needed.}
\begin{wraptable}{R}{0.5\textwidth}
\vspace{-4mm}
\centering
\caption{Notions and descriptions}\label{tab:notation}
\resizebox{.9 \linewidth}{!}{
\begin{tabular}{lll}
\toprule
Notion & Type & Description \\
\midrule
$X_s/X_t$ & Input & source/target visual features \\
$A_s/A_t$ & Input & source/target semantic attributes \\
$Y_s/Y_t$ & Input & source/target labels \\
$K_s/K_t$ & Input & source/target number of categories \\
$N_s/N_t$ & Input & source/target number of instances \\
$d$ & Input & dimension of semantic attribute \\
\hline
$z_s / z_t$ & Learnable & source/target embedding \\
$\hat{a}_s / \hat{a}_t$ & Learnable & source/target predicted semantic \\
$\Tilde{\mu}_{k}$ & Learnable & seen class prototype by pseudo label \\
$\mu_{k}$ & Learnable & class prototype \\
\bottomrule
\end{tabular} \vspace{-10mm}
}
\end{wraptable}
The challenges associated with ZK-ZSL are twofold. First, the model needs to provide partitional structures of unseen categories. However, training a visual classifier only with labeled seen samples can only help distinguish between seen/unseen categories but cannot further separate the fine-grained categories in the unseen class. In addition, due to mismatched label spaces in the source and target dataset, learning such a classifier could destroy the clustering structures of novel categories. Second, since the semantic attributes of unseen categories are unavailable, learning only with seen semantics is prone to overfitting and results in biased semantic prediction.
\section{Proposed Method}
In this section, we introduce our framework for ZK-ZSL and the objective function to train our framework.
\subsection{Framework Overview}
Figure~\ref{fig:framework} shows our proposed framework for ZK-ZSL. In order to discover and differentiate novel categories while recognizing seen classes, our method learns to recover the clustering structures of both seen and unseen categories in the target dataset, where the learning of seen class structures is guided by the source labels. In addition, to mitigate the overfitting brought about by the unavailability of unseen semantic labels, we apply a structural alignment loss to support semantic learning with the recovered structures of unseen categories. Therefore, our framework consists of three main components for source-guided clustering, semantic prediction, and structural alignment.
The source-guided clustering component learns to recover the clustering structures of both seen and unseen categories on a hidden embedding space where the learning of seen class structures is supported by labeled source data. The semantic prediction component maps the hidden embedding to the semantic space. The structural alignment component guides the semantic learning of novel categories with their recovered clustering structures.
\begin{figure}[tp]
\centering
\resizebox{.65 \linewidth}{!}{
\includegraphics[width=\linewidth]{figs/framework.png}
}
\caption{Overview of our proposed framework. The deep clustering component guided by the source class structures uncovers the clustering structures of the target dataset. The semantic prediction component maps the embedding space to the semantic space. The structural alignment component supports semantic learning of unseen categories with recovered structures. }
\label{fig:framework}
\vspace{-3mm}
\end{figure}
\subsection{Objective Function}
Our learning objective consists of three main components: source-guided clustering loss, semantic prediction loss, and structural alignment loss. We denote our encoder, decoder, and semantic predictor as $g: x \rightarrow z$, $h: z \rightarrow x$, and $f: z \rightarrow a$, where $x$, $z$, and $a$ represent visual feature, hidden embedding, and semantic attribute spaces, respectively, and we define learnable cluster centroids as $\mathcal{C} = \{ \mu_{1}, ..., \mu_{K_t} \}$.
\noindent\textbf{Source-guided Clustering Loss.} Our method learns to recover clustering structures of both seen and unseen categories guided by source labels. To achieve this, we utilize an auto-encoder to extract hidden embeddings, apply clustering regularization on the embedding space to separate both seen and unseen categories, and align seen cluster centroids with source labels. In this way, we break down the source-guided clustering loss into three parts: {{self-reconstruction}}, {{clustering regularization}}, and {{source centroid alignment}}.
\noindent{\textit{Self-reconstruction.}} Self-reconstruction loss helps the encoder and decoder extract clustering-favorable hidden embeddings with minimal information loss. It is defined as:
\begin{equation}
\mathcal{L}_{self} = \frac{1}{N_s} \sum_i^{N_s} \lVert x^s_i - h \circ g(x^s_i) \rVert^2_2 + \frac{1}{N_t} \sum_i^{N_t} \lVert x^t_i - h \circ g(x^t_i) \rVert^2_2,
\end{equation} where $\circ$ represents function composition.
\noindent{\textit{Clustering Regularization.}} Following Deep Embedding Clustering~\cite{xie2016unsupervised}, we model the cluster assignment with a probability distribution. Specifically, the similarity between an embedding instance $z_i$ to a cluster centroid $\mu_k$ is measured with a Student-t distribution:
\begin{equation}
p^{z}_{ik} = \frac{(1 + \lVert z_i - {\mu}_k \rVert^{2}_2)^{-1}}{\sum_{j=1}^{K_t}(1 + \lVert z_i - {\mu}_j \rVert^{2}_2)^{-1}}.
\label{eq:cluster}
\end{equation}
Subsequently, an auxiliary target distribution is employed to strengthen cluster prediction. The target distribution is defined by
\begin{equation}
q^{z}_{ik} = \frac{(p^{z}_{ik})^2 / \sum_j^{N_t} p^z_{jk}}{\sum_{j'}^{K_t} (p^z_{ij'})^2 / \sum_{j}^{N_t} p^z_{jj'}}.
\end{equation}
The clustering regularization loss measures the difference between the cluster assignment distribution and target distribution. By minimizing their divergence, data points are pulled toward the likely cluster centroid and pushed away from others. Mathematically, the clustering regularization loss is defined as
\begin{equation}
\mathcal{L}_{reg} = \frac{1}{N_t} \sum_{i=1}^{N_t} D_{KL}(p^{z}_i || q^{z}_i) = \frac{1}{N_t} \sum_{i=1}^{N_t} \sum_{k=1}^{K_t} p^z_{ik} \log \frac{p^z_{ik}}{q^z_{ik}}.
\end{equation}
\noindent{\textit{Source Centroid Alignment.}} The source centroid alignment loss pulls source samples toward their corresponding cluster centroids. This is achieved by optimizing the prototypical probability distribution defined by the distance between data points and cluster centroids. The prototypical probability of a data point $z_i$ given a cluster centroid $\mu_k$ is
\begin{equation}
\label{eq:prototypical}
\mathcal{P}(z_i | \mu_k) = \frac{\exp(- d(z_i, \mu_k ))}{\sum_{k' \leq K_s} \exp(- d(z_i, \mu_{k'}))},
\end{equation}
where $d$ is an Euclidean distance function and the source centroid alignment loss is
\begin{equation}
\mathcal{L}_{cent} = \frac{1}{N_s} \sum_{i=1}^{N_s}\mathcal{L}(\mathcal{P}_i, y_i),
\end{equation}
where $\mathcal{L}$ denotes the cross entropy loss. To address the potential distribution drift of seen categories between the source and target dataset, we incorporate an optional loss to reduce the gap between source and target seen class centroids. We first define the expected target seen class centroid
\begin{equation}
\Tilde{\mu}_k := \mathbb{E}_{\hat{y}^t_i = k} z^t_i,
\end{equation}
where $\hat{y}^t_i = \arg_k \max p^{z}_{ik}$ is the pseudo label obtained from cluster assignment probability. The source centroid alignment loss under distribution shift is defined as
\begin{equation}
\mathcal{L}_{cent} = \frac{1}{N_s} \sum_{i=1}^{N_s}\mathcal{L}(\mathcal{P}_i, y^i_s) + \frac{1}{K_s} \sum_{k=1}^{K_s} \lVert \Tilde{\mu}_k - \mu_k \rVert^2_2.
\end{equation}
Finally, the source-guided clustering loss combines self-reconstruction loss, clustering regularization loss, and source centroid alignment loss:
\begin{equation}
\mathcal{L}_{c} = \mathcal{L}_{self} + \mathcal{L}_{reg} + \mathcal{L}_{cent}.
\end{equation}
\noindent\textbf{Semantic Prediction Loss}. Following \citet{frome2013devise}, we use a pairwise ranking loss to learn the embedding-to-semantic mapping, where we stop penalizing false terms after the maximum margin of 0.5 is reached.
\begin{equation}
\mathcal{L}_a = \frac{1}{N_s} \sum_{i=1}^{N_s} \sum_{k \neq y_s^i} \max \{0, 0.5 - A_{y_i}^\top a^s_i + A_k^\top a^s_i \},
\end{equation}
where $A_{k}$ is the ground truth semantic label of class $k$.
\noindent\textbf{Structural Alignment Loss}. Structural alignment guides semantic learning by transferring the structural knowledge in the embedding space to the semantic space. Specifically, the structural alignment loss minimizes the divergence between embedding and semantic cluster structures modeled by the cluster assignment probability. We have defined the cluster assignment probability in the embedding space $p_{ik}^z$ in Eq.~\eqref{eq:cluster}. Similarly, the cluster assignment probability in the semantic space can be defined by $p^{a}_{ik}$, where
\begin{equation}
p^{a}_{ik} = \frac{(1 + \lVert a_i - f(\mu_k) \rVert^{2}_2)^{-1}}{\sum_{j=1}^{K_t}(1 + \lVert a_i - f(\mu_j) \rVert^{2}_2)^{-1}}.
\label{eq:semanticcluster}
\end{equation}
Based on Eq.~\eqref{eq:cluster} and Eq.~\eqref{eq:semanticcluster}, we define the structural alignment loss as
\begin{equation}
\mathcal{L}_{align} = \frac{1}{N_t} \sum_{i=1}^{N_t} \sum_{j=1}^{N_t} ( {p_i^z}^\top p_j^z - {p_i^a}^{\top} p_j^a )^2,
\end{equation}
where ${p_i^z}^\top p_j^z$ measures the probability that data points $i$ and $j$ in the embedding space belonging to the same cluster.
\noindent\textbf{Overall Objective Function}. The overall learning objective is to minimize the source-guided clustering loss, semantic prediction loss, and structural alignment loss:
\begin{equation}
\min_{g, h, f, \mathcal{C}} \mathcal{L}_{c} + \alpha \mathcal{L}_a + \beta \mathcal{L}_{align},
\end{equation} where $\alpha$ and $\beta$ are trade-off parameters.
\label{sec:method}
\section{Experiments}
\subsection{Experimental Settings}
\begin{wraptable}{R}{0.5\textwidth}
\centering
\caption{
Characteristics of four benchmark datasets.
}
\scriptsize
\resizebox{.9 \linewidth}{!}{
\begin{tabular}{c|cccccc}
\toprule
Dataset & Source & Target\_s & Target\_t & $K_s$ & $K_t$ & $d$ \\
\midrule
APY & 5932 & 7924 & 1483 & 20 & 32 & 64 \\
CUB & 8855 & 2973 & 1764 & 150 & 200 & 312 \\
AWA2 & 19832 & 5685 & 4958 & 40 & 50 & 85 \\
SUN & 12900 & 1440 & 2580 & 645 & 717 & 102 \\
\bottomrule
\end{tabular}
}
\begin{tablenotes}
\item \parbox[t]{7.5 cm}{Note: Target\_s and Target\_t denote the sample numbers of seen and unseen categories in the target domain.}
\end{tablenotes}
\label{tab:characteristic}
\vspace{-3mm}
\end{wraptable}
\noindent\textbf{Datasets}. We choose four commonly used attribute datasets: Attribute Pascal and Yahoo (APY) \cite{farhadi2009apy}, Animals with Attributes 2 (AWA2) \cite{lampert2013awa}, Caltech-UCSD-Birds 200-2011 (CUB) \cite{wah2011cub}, and SUN dataset \cite{xiao2010sun}. We split the data into the source and target sets by following the split strategy in \citet{xian2017benchmark}. All visual features are obtained from ResNet-101 \cite{he2016resnet} pre-trained on ImageNet \cite{deng2009imagenet}. Table \ref{tab:characteristic} summarizes the key characteristics of these datasets. Only the semantic attributes of seen categories are available for training. We use unit vectors as semantic representations.
\noindent\textbf{Competitive Methods}. We compare our method with established methods in Generalized Zero-Shot Learning and Semantic Recovery Open-Set Domain Adaptation. For GZSL based methods, it is noteworthy that not all established methods work under our setting, where unseen semantics are not provided. For example, generative-based methods, which require unseen semantics to synthesize samples of novel categories, are not applicable under ZK-ZSL. We compare with DEVISE \cite{frome2013devise}, ESZSL \cite{romera2015eszsl}, SJE \cite{akata2015sje} and SDGZSL \cite{chen2021sdgzsl}. In particular, DEVISE, SJE, and ESZSL aim to find a mapping from visual space to semantic space, while SDGZSL learns a hidden embedding from visual features that can be decomposed to semantic-consistent representation and semantic-unrelated representation. In the next section, we elaborate on how to tailor the above methods to the ZK-ZSL setting. In addition, we compare with \citet{jing2021taotao} as the only existing SR-OSDA-based method. Their approach progressively separates seen and unseen samples with pseudo labels obtained from prototypical probabilities and utilizes a graph neural network for semantic attribute prediction to avoid overfitting.
\noindent\textbf{Implementation}. Here we first introduce how we extend the competitive methods for novel category prediction, then elaborate on the implementation details of our method.
Since the competitive methods only predict semantic attributes or hidden embeddings, we need to extend their approaches to support novel categories prediction. To this end, we adopt a two-step procedure that first recognizes seen and unseen samples and then further separates unseen samples with K-means. We rely on the prototypical probability defined in Eq.~\eqref{eq:prototypical} for seen/unseen separation. We first define the highest prototypical probability that a data point belongs to a seen category:
\begin{equation}
\mathcal{P}^{max}_i = \max_k \mathcal{P}(z_t^i | \mu_k).
\end{equation}
Data points with higher $\mathcal{P}^{max}$ are more likely from a seen category, while unseen samples tend to have more even prototypical probability distributions, and thus lower $\mathcal{P}^{max}$. We follow \citet{jing2021taotao} to choose a threshold where the data points with $\mathcal{P}^{max}$ higher than $\tau = \frac{1}{N_t} \sum_i \mathcal{P}^{max}_i$ are recognized as seen samples, and classified by their corresponding class centroids; those with lower $\mathcal{P}^{max}$ are regarded as unseen samples and predicted by K-means implemented by Scikit-learn \cite{scikit-learn}. Let unseen class centroids predicted by K-means be $\{ \hat{\mu}_{K_s + 1}, ..., \hat{\mu}_{K_t} \}$, we define classification prediction as
\begin{equation}
\hat{y}_t^i =
\begin{cases}
\arg \max_{k \leq K_s} \mathcal{P}(z_t^i | \mu_k) & \text{if \ } \mathcal{P}^{max}_i \geq \tau \text{,} \\
\arg \min_{K_s < k \leq K_t} d(z_t^i, \hat{\mu}_k) & \text{otherwise.}
\end{cases}
\end{equation}
In our framework, the encoder and decoder constitute a de-noising autoencoder. Specifically, the encoder and decoder are 5 linear layers followed by batch normalization and Leaky ReLU activation. Their neural structures are dropout-2048-512-256-256-4096-$h$ and dropout-$h$-4096-256-256-512-2048, respectively, where $h$ is the dimension of the hidden embeddings. We set the dropout rate to $0.01$ for all experiments and choose $h = 256$ for APY and AWA2 datasets and $h = 1024$ for CUB and SUN datasets. The semantic prediction head is a linear layer with batch normalization. Our model parameters are initialized by pretraining with self-reconstruction loss and semantic prediction loss, and class centers are initialized with K-means. We use Adam optimizer \cite{kingma2014adam} with a learning rate of $1e^{-3}$ and weight decay of $1e^{-5}$ in the pretraining stage, and then learning rate is adjusted to $1e^{-4}$ for training. Learning rates are reduced by a factor of 0.1 every 200 epochs for both stages.
\noindent\textbf{Metrics}. We evaluate model performance from two perspectives: classification and semantic recovery accuracy.
\begin{table*}[t]
\centering
\caption{
Classification and Semantic Recovery Accuracy on four benchmark datasets.
}
\scriptsize
\begin{tabular}{c|c|S[table-format=2.1]S[table-format=2.1]S[table-format=2.1]|S[table-format=2.1]S[table-format=2.1]S[table-format=2.1]|S[table-format=2.1]S[table-format=2.1]S[table-format=2.1]|S[table-format=2.1]S[table-format=2.1]S[table-format=2.1]}
\toprule
& \multicolumn{1}{c}{Dataset} & \multicolumn{3}{c}{APY} & \multicolumn{3}{c}{CUB} & \multicolumn{3}{c}{AWA2} & \multicolumn{3}{c}{SUN}\\
\midrule
& \multicolumn{1}{c|}{Method} & \multicolumn{1}{c}{$Acc_s$} & \multicolumn{1}{c}{$Acc_u$} & \multicolumn{1}{c|}{$Acc_h$} & \multicolumn{1}{c}{$Acc_s$} & \multicolumn{1}{c}{$Acc_u$} & \multicolumn{1}{c|}{$Acc_h$} & \multicolumn{1}{c}{$Acc_s$} & \multicolumn{1}{c}{$Acc_u$} & \multicolumn{1}{c|}{$Acc_h$} & \multicolumn{1}{c}{$Acc_s$} & \multicolumn{1}{c}{$Acc_u$} & \multicolumn{1}{c}{$Acc_h$} \\
\cmidrule{2-14}
\multirow{6}{*}{\vspace{-10mm}\turnbox{90}{Classification}} & DEVISE$^*$ & \BlueText 76.4 & 13.0 & 22.2 & 37.1 & 15.8 & 22.2 & 69.2 & 24.5 & 36.2 & 18.4 & 21.9 & 20.0 \\
& ESZSL$^*$ & \RedText 77.2 & 17.0 & 27.8 & 35.9 & 23.8 & 28.6 & 67.5 & \BlueText 40.3 & \BlueText 50.4 & 16.6 & 18.6 & 17.6 \\
& SJE$^*$ & 74.1 & 9.2 & 16.3 & 34.1 & 9.3 & 14.6 & 57.0 & 13.2 & 21.5 & 17.2 & 17.6 & 17.4 \\
& SDGZSL$^\diamond$ & 71.1 & \BlueText 22.5 & \BlueText 34.2 & \RedText 58.0 & 33.6 & \RedText 42.5 & \BlueText 79.6 & 27.9 & 41.4 & \RedText 32.8 & \RedText 26.5 & \RedText 29.3 \\
& SR-OSDA$^*$ & 24.2 & 15.4 & 18.8 & 2.7 & 11.7 & 4.4 & 27.0 & 18.6 & 22.0 & 5.0 & 11.7 & 9.7 \\
\cmidrule{2-14}
& Ours & 48.2 & \RedText 30.6 & \RedText 37.4 & \BlueText 43.8 & \RedText 35.4 & \BlueText 39.2 & \RedText 82.8 & \RedText 47.6 & \RedText 60.5 & \BlueText 23.5 & \BlueText 24.8 & \BlueText 24.1 \\
\midrule
& \multicolumn{1}{c|}{Method} & \multicolumn{1}{c}{$SR_s$} & \multicolumn{1}{c}{$SR_u$} & \multicolumn{1}{c|}{$SR_h$} & \multicolumn{1}{c}{$SR_s$} & \multicolumn{1}{c}{$SR_u$} & \multicolumn{1}{c|}{$SR_h$} & \multicolumn{1}{c}{$SR_s$} & \multicolumn{1}{c}{$SR_u$} & \multicolumn{1}{c|}{$SR_h$} & \multicolumn{1}{c}{$SR_s$} & \multicolumn{1}{c}{$SR_u$} & \multicolumn{1}{c}{$SR_h$} \\
\cmidrule{2-14}
\multirow{6}{*}{\vspace{-12mm}\turnbox{90}{Semantic Recovery}} & DEVISE & 2.6 & \BlueText 9.7 & 4.1 & 37.8 & \BlueText 24.4 & \BlueText 29.6 & 61.1 & \BlueText 26.7 & \BlueText 37.2 & \BlueText 29.4 & 14.8 & 19.7 \\
& ESZSL & \RedText 83.6 & 1.4 & 2.8 & \RedText 55.5 & 11.5 & 19.0 & \RedText 88.5 & 2.2 & 4.3 & 27.3 & 13.1 & 17.7 \\
& SJE & 7.5 & 9.4 & \BlueText 8.3 & 0.8 & 11.6 & 1.4 & 41.8 & 20.4 & 27.4 & 27.0 & \BlueText 16.8 & \BlueText 20.7 \\
& SR-OSDA & 3.4 & 0.7 & 1.2 & 0.3 & 0.2 & 0.3 & 2.7 & 0.4 & 0.7 & 0.2 & 0.3 & 0.2 \\
\cmidrule{2-14}
& Ours & \BlueText 60.4 & \RedText 17.5 & \RedText 27.2 & \BlueText 52.4 & \RedText 25.1 & \RedText 33.9 & \BlueText 84.6 & \RedText 32.9 & \RedText 47.4 & \RedText 36.8 & \RedText 18.2 & \RedText 24.4 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item \hspace{12mm} Note: $*$ represents evaluation in semantic space, and $\diamond$ represents evaluation in embedding space.
\end{tablenotes}
\vspace{-2mm}
\label{tab:Acc}
\end{table*}
In the same spirit of the evaluation metrics proposed in \citet{xian2017benchmark}, our classification accuracy measures the class average accuracy of seen and unseen categories and their harmonic mean. We define the classification accuracy of seen categories as the average per-class accuracy:
\begin{equation}
Acc_s = \frac{1}{N_s} \sum_{k \leq K_s} \frac{\sum_i \mathds{1}_{\hat{y}_t^i = y_t^i}}{\sum_i \mathds{1}_{y_t^i = k}},
\end{equation} where $\mathds{1}$ is an indicator function. Similarly, we define the classification accuracy of unseen category as
\begin{equation}
Acc_u = \frac{1}{N_t - N_s} \sum_{K_s < k \leq K_t} \frac{\sum_i \mathds{1}_{map(\hat{y}_t^i) = y_t^i}}{\sum_i \mathds{1}_{y_t^i = k}},
\end{equation} where $map()$ is a permutation function that maps predicted unseen categories to ground-truth unseen counterparts. Finally, we evaluate the harmonic mean of seen and unseen classification accuracy:
\begin{equation}
Acc_h = 2 \times \frac{Acc_s \times Acc_u}{Acc_s + Acc_u}.
\end{equation}
\begin{figure*}[t]
\centering
\begin{subfigure}{0.2 \textwidth}
\resizebox{1 \textwidth}{!}{{\includegraphics{figs/confuse_devise_alone_draw.png}};
}
\caption{DEVISE}
\label{fig:confuse_a}
\end{subfigure}
\begin{subfigure}{0.2 \textwidth}
\resizebox{\textwidth}{!}{{\includegraphics{figs/confuse_eszsl_alone_draw.png}};
}
\caption{ESZSL}
\label{fig:confuse_b}
\end{subfigure}
\begin{subfigure}{0.2 \textwidth}
\resizebox{\textwidth}{!}{{\includegraphics{figs/confuse_sdzsl_alone_draw.png}};
}
\caption{SDGZSL}
\label{fig:confuse_b}
\end{subfigure}
\begin{subfigure}{0.38 \textwidth}
\resizebox{\textwidth}{!}{{\includegraphics{figs/ours_alone_draw.png}};
}
\caption{Ours}
\label{fig:confuse_c}
\end{subfigure}\vspace{-1mm}
\caption{Confusion matrices of seen and unseen categories on the AWA2 dataset. Recommended to zoom in for better visualization.}\vspace{-3mm}
\label{confusion matrices}
\end{figure*}
In addition to classification accuracy, we want to evaluate the model's ability to accurately uncover the target dataset's semantic attributes. Following \citet{xian2017benchmark}, we define the semantic recovery prediction as
\begin{equation}
\Tilde{y}_t^i = \arg \max_k A_k^\top a_t^i.
\end{equation}
Similarly, semantic recovery accuracies $SR_s$, $SR_u$, and $SR_h$ follow the derivation of classification accuracies.
For DEVISE, SJE, and ESZSL, we evaluate their classification accuracies with their predicted semantic attributes, where the class centroids of seen categories are ground truth semantic labels. We evaluate SDGZSL classification ability with its generated semantic-consistent representation, and because it does not have a semantic prediction component, we exclude it from semantic recovery evaluation. We use the cosine distance when calculating prototypical probability in the semantic space and use Euclidean distance in the embedding space.
\subsection{Performance}
\begin{figure*}[t]
\centering
\subcaptionbox{\label{sfig:a} Bobcat}{\includegraphics[width=3.5cm]{figs/ex_bobcat_912_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:b} Dolphin}{\includegraphics[width=3.5cm]{figs/ex_dolphine_1218_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:c} Sheep}{\includegraphics[width=3.5cm]{figs/ex_sheep_4916_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:d} Giraffe}{\includegraphics[width=3.5cm]{figs/ex_giraffe_2311_draw.png}}
\subcaptionbox{\label{sfig:e} Rat}{\includegraphics[width=3.5cm]{figs/ex_rat_3406_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:f} Seal}{\includegraphics[width=3.5cm]{figs/ex_seal_3873_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:g} Bat}{\includegraphics[width=3.5cm]{figs/ex_bat_74_draw.png}}
\hspace*{0.1cm}
\subcaptionbox{\label{sfig:d} Horse}
{\includegraphics[width=3.5cm]{figs/ex_horse_draw.png}}\vspace{-2mm}
\caption{Examples of novel categories and predicted semantic attributes. The predicted semantics are ordered by compatibility with ground-truth labels, where the top is the most compatible semantic attribute. \textcolor{red}{Red} indicates a wrong prediction, and \textcolor{green}{Green} indicates a wrong prediction but is consistent with the given instance. }
\vspace{-2mm}
\label{fig:examples}
\end{figure*}
\begin{figure*}[t]
\centering
\subcaptionbox{ \label{sfig:a} ResNet}
{\vspace{-2mm} \includegraphics[width=3.5cm]
{figs/ResNet_feat.png}}
\subcaptionbox{
\label{sfig:b} SJE}{\vspace{-2mm} \includegraphics[width=3.5cm]{figs/sje_att.png}
}
\subcaptionbox{\label{sfig:c} Ours (embedding)}{\vspace{-2mm} \includegraphics[width=3.5cm]{figs/Model_Hidden.png}}
\subcaptionbox{\label{sfig:d} Ours (semantic)}{\vspace{-2mm} \includegraphics[width=3.5cm]{figs/Model_att.png}}
\vspace{-2mm}
\caption{t-SNE visualization of (a) ResNet features, (b) semantic attribute predicted by SJE \cite{akata2015sje}, (c) hidden embedding generated by our method, and (d) semantic attribute predicted by our method. \textcolor{red}{Red} represents source data points. \textcolor{blue}{Blue} and \textcolor{gray}{Gray} highlight data points in the target dataset that belong to unseen and seen categories, respectively.}
\label{fig:visualization}
\vspace{-2mm}
\end{figure*}
Table \ref{tab:Acc} summarizes the classification accuracy and semantic recovery accuracy for four benchmark datasets, where red and blue highlight the highest and second highest accuracies.
For the classification accuracy measurement, we obverse that our method attains the best overall performance in APY and AWA2 while achieving the second-highest overall accuracy in CUB and SUN. It is noteworthy that for the AWA2 dataset, our method brings a 10.1\% overall accuracy improvement compared with the second-highest baseline. Our superior performance in APY and AWA2 partly results from our improved unseen category classification accuracy, which demonstrates the effectiveness of our structural alignment and source-guided clustering component. In comparison, we see a trend of overfitting on the source dataset for some baseline methods, which destroys the clustering structure of unseen samples. For example, regarding the performance on the APY dataset, DEVISE achieves 76.4\% seen classification accuracy but only attains 13.0\% for the unseen category. In addition, we observe our method does not improve overall classification accuracy in CUB and SUN, compared with the best-performing SDGZSL baseline. We hypothesize that this is due to a reduced number of samples per class in the target dataset. There are, on average, 293 and 212 samples per class in APY and AWA2, respectively, but for CUB and SUN there are only 23 and 6 samples. This leads to (1) distribution drift of seen category samples, which undermines our method's capability to classify seen samples correctly, and (2) underrepresented novel class samples, which complicates their clustering structures recovery.
For the semantic recovery accuracy measurement, our method achieves the best performance in terms of unseen category semantic recovery and overall semantic recovery accuracy. This demonstrates that our structural alignment loss can effectively prevent overfitting on the source semantic data and accurately predict the semantic attributes of unseen categories. In comparison, we observe a similar pattern in classification that some baselines can accurately recover semantics of seen categories, but not for unseen samples. For example, ESZSL achieves 83.6\% for seen semantic recovery but only 1.4\% for unseen categories.
\subsection{Factor Exploration}
To further explore our method, we explore confusion matrices of seen and unseen categories, visualize representations obtained by our method, showcase some representative samples and their associated predictions, analyze the ablation study of our model components, and visualize our predicted semantic attributes of novel categories with word clouds. Finally, we explore hyper-parameters $\alpha$ and $\beta$.
\noindent\textbf{Confusion Matrices.} We visualize confusion matrices of different methods on the AWA2 dataset, including DEVISE, ESZSL, SDGZSL, and ours in Figure \ref{confusion matrices}. We observe that our method has much fewer false predictions for novel categories. It is noteworthy that our method classifies four unseen categories with 90+\% accuracy. We also see that our method improves classification accuracy for seen categories.
\begin{wrapfigure}[17]{R}{0.5\textwidth}
\centering{\includegraphics[width=8cm]{figs/ablation.jpg}}\vspace{-2mm}
\caption{Ablation study results of our proposed method on AWA2 dataset. We report the performance of variants that are trained without structural alignment loss (SA), without source-guided clustering loss (SC), without semantic prediction loss (SP), and with our proposed method. The left shows semantic recovery accuracy, and the right shows classification accuracy.}
\label{fig:ablation}
\vspace{-4mm}
\end{wrapfigure}
\begin{figure}[t]
\centering{
\vspace{-4mm}
\includegraphics[width=0.95\textwidth]{figs/word_cloud_flat.jpeg}}\vspace{-1mm}
\caption{Word clouds of novel category semantics predicted by our model, including (a) bobcat, (b) giraffe, (c) sheep, (d) bat, and (e) whale. Recommended to zoom in for better visualization.}
\label{fig:WordCloud}
\vspace{-5mm}
\end{figure}
\noindent\textbf{Representation Visualization.}
In Figure \ref{fig:visualization}, we visualize different representations of the AWA2 dataset with t-SNE \cite{van2008tsne}, including the ResNet features, semantic attributes predicted by SJE, our method's hidden embedding, and our predicted semantic attributes. Red dots represent data points in the source dataset, while blue and gray dots represent target data points that belong to seen and unseen categories, respectively. For our hidden embedding visualization, we observe a much clearer separation among clusters compared with the ResNet input and SJE prediction, which is achieved with our source-guided clustering component. In addition, our recovered semantic attributes have similar structures of hidden embeddings, showing that our structural alignment loss is effective.
\noindent\textbf{Qualitative Analysis.} In Figure \ref{fig:examples}, we showcase some representative samples from novel categories in the AWA2 dataset, including the input image and predicted semantic attributes ordered by compatibility to the ground-truth semantic labels. The compatibility is calculated by an element-wise multiplication between the predicted semantic attribute scores and ground truth. We regard a predicted attribute with positive compatibility as a correct prediction and vice versa. The most compatible predicted semantics are discriminative for the given category. For least compatible attributes, some valid attributes are not predicted, which is indicated by red in Figure \ref{fig:examples}, and some predicted attributes (in green) are not relevant to the given category but reasonable for the given instance.
\noindent\textbf{Ablation Study.} We explore the effectiveness of our designed components with an ablation study. Specifically, we individually train variants of our framework with the AWA2 dataset that are (1) without structural alignment loss $\mathcal{L}_{align}$, (2) without source-guided clustering loss $\mathcal{L}_{c}$, and (3) without semantic prediction loss $\mathcal{L}_{a}$. In Figure \ref{fig:ablation}, we report and compare the classification accuracy and semantic recovery accuracy. We first observe that our method achieves the best overall performance when trained with all objectives. In addition, semantic recovery accuracy and seen category classification accuracy are improved with structural alignment loss, which indicates that structural alignment helps hidden embedding and semantic learning.
\noindent\textbf{Novel Category Visualization.} Figure \ref{fig:WordCloud} visualizes our predicted semantic attributes of discovered novel categories through word clouds generated by \citet{wordcloud}. We select the 50 most significant attributes ordered by their predicted scores for visualization and adjust font sizes according to their relative ranking. We observe that the most significant attributes are consistent with the corresponding category.
\noindent\textbf{Hyperparameter Analysis.} $\alpha$ and $\beta$ control the contributions of the semantic prediction loss and structural alignment loss and, by default, are set to 1.0 and 1.0. Here we explore the volatility of these parameters and verify our default choice by doing a hyperparameter analysis on the AWA2 dataset. When $\alpha$ is fixed at 1.0, and $\beta$ is explored in the range of $\{0, 0.1, 0.5, 1.0, 5.0, 10.0\}$, we observe that the classification and semantic recovery accuracy increase as $\beta$ increases, and reach the optimal values of $59.7\%$ and $50.9\%$ when $\alpha = 1.0$ and $\beta = 1.0$. As $\beta$ further increases, $Acc_u$ and $SR_u$ decline to $30.6\%$ and $45.4\%$. When $\beta$ is pinned at 1.0 and $\alpha$ is set in the range of $\{0, 0.1, 0.5, 1.0, 5.0, 10.0\}$, the $Acc_u$ and $SR_u$ form an inverted U pattern where they start at $47.0\%$ and $0.3\%$, reach the optimal combination, then reduce to $56.8\%$ and $42.1\%$. The optimal values are obtained at $\alpha = \beta = 1.0$.
\section{Conclusion}
In this work, we explore a novel and practical setting in visual recognition named Zero-Knowledge Zero-Shot Learning, addressing the limitations of GZSL and OSR. ZK-ZSL aims to recognize categories present in the source dataset as well as additional novel categories without prior knowledge and recover their semantic attributes. We consider the challenges associated with ZK-ZSL from two aspects: (1) the demand to further separate unseen categories, where training a classifier with only source labels could destroy the structures of unseen categories, and (2) the unavailability of unseen semantic labels that could cause inaccurate and biased semantic predictions. Our proposed method learns to recover the clustering structures of both seen and unseen categories in the target dataset, where the seen class centroids are guided by source labels. A novel structural alignment loss is designed to aid semantic learning of unseen categories with their recovered clustering structures. Experimental analyses show that our method achieves superior performance in terms of classification and semantic recovery on four benchmark datasets.
\clearpage
\bibliographystyle{plainnat}
| {'timestamp': '2023-02-10T02:05:52', 'yymm': '2302', 'arxiv_id': '2302.04427', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04427'} | arxiv |
\section{\label{sec:mean}Mean-field equations}
\subsection{Replica partition function}
Our network, presented in \cref{sec:model}, is described by a Hamiltonian
\begin{align}
H &= -\frac{1}{2N}\sum_{\mu\nu} \sum_{i \neq j} (\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) (\eta^j_{\mu\nu} + \zeta^j_{\mu\nu}) S_i S_j + \theta \sum_i S_i \nonumber\\
&= -\frac{1}{2N}\sum_{\mu\nu} \biggl[\sum_i (\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) S_i\biggr]^2 + \frac{1}{2N}\sum_{\mu\nu} \sum_i \Bigl[(\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) S_i\Bigr]^2 + \theta \sum_i S_i.
\end{align}
We will forgo introducing external fields. Note that
\begin{equation}
\frac{1}{2N}\sum_{\mu\nu} \sum_i \Bigl[(\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) S_i\Bigr]^2
\approx \frac{\alpha s}{2} \Bigl[ (1-2\gamma)^2 a + \gamma^2 \Bigr] \sum_i S_i
\end{equation}
considering $a \ll 1$ and $N \rightarrow \infty$. If we define
\begin{equation}
\Gamma^2 \equiv (1-2\gamma)^2 a + \gamma^2,
\end{equation}
we obtain
\begin{equation}
H = -\frac{1}{2N}\sum_{\mu\nu} \biggl[\sum_i (\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) S_i\biggr]^2 + \biggl(\theta + \frac{\alpha s\Gamma^2}{2}\biggr) \sum_i S_i.
\end{equation}
Now we consider a set of replica networks $\rho = 1, \ldots, n$ with the same parameter values and stored patterns, but their neural activities $S^\rho_i$ may vary across replicas. The Hamiltonian of each replica is
\begin{equation}
H^\rho = -\frac{1}{2N}\sum_{\mu\nu} \biggl[\sum_i (\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) S^\rho_i\biggr]^2 + \biggl(\theta + \frac{\alpha s \Gamma^2}{2}\biggr) \sum_i S^\rho_i.
\end{equation}
and the partition function across replicas is
\begin{equation}
\langle Z^n \rangle = \left\langle \mathrm{Tr}_S \prod_\rho \exp \bigl[-\beta H^\rho\bigr] \right\rangle,
\end{equation}
where the average occurs over patterns $\eta^i_{\mu\nu}$ and $\zeta^i_{\mu\nu}$. We invoke the standard gaussian integral identity
\begin{equation}
\int \mathrm{d} m\,\mathrm{e}^{-a m^2 + b m}
= \sqrt{\frac{\pi}{a}} \mathrm{e}^{b^2/4a}
\end{equation}
to obtain
\begin{align}
\langle Z^n \rangle = \Biggl\langle \mathrm{Tr}_S \prod_\rho \Biggl\{
&\exp\biggl[-\beta \biggl(\theta + \frac{\alpha s \Gamma^2}{2}\biggr) \sum_i S^\rho_i\biggr] \nonumber\\
&\times \prod_{\mu\nu} \int \mathrm{d} m^\rho_{\mu\nu} \biggl(\frac{\beta N}{2\pi}\biggr)^{\!\!\frac{1}{2}} \exp\biggl[ -\frac{\beta N}{2} (m^\rho_{\mu\nu})^2 + \beta m^\rho_{\mu\nu} \sum_i (\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) S^\rho_i \biggr] \Biggr\} \Biggr\rangle.
\end{align}
\subsection{Uncondensed patterns}
We first average over the uncondensed patterns $\mu > 1$ for which $m^\rho_{\mu\nu} \ll 1$. First,
\begin{equation}
\left\langle \prod_{{\mu\nu}\rho} \exp\biggl[\beta m^\rho_{\mu\nu} \sum_i (\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) S^\rho_i\biggr] \right\rangle
= \prod_{i\mu} \left\langle \prod_\nu \exp\biggl[\beta (\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) \sum_\rho m^\rho_{\mu\nu} S^\rho_i\biggr] \right\rangle.
\end{equation}
Using
\begin{equation}
Y_\nu \equiv \beta \sum_\rho m^\rho_{\mu\nu} S^\rho_i,
\end{equation}
we note that
\begin{equation}
\biggl\langle \prod_\nu \exp\bigl[(\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) Y_\nu\bigr] \biggr\rangle_{\!\!{\mu\nu}}
= \biggl[ \prod_\nu \bigl\langle \exp[\eta^i_{\mu\nu} Y_\nu] \bigr\rangle_{\!\!{\mu\nu}} \biggr] \biggl\langle \prod_\nu \exp[\zeta^i_{\mu\nu} Y_\nu] \biggr\rangle_{\!\!{\mu\nu}}.
\end{equation}
First, using $Y \ll 1$,
\begin{equation}
\bigl\langle \exp[\eta^i_{\mu\nu} Y_\nu] \bigr\rangle_{\!{\mu\nu}}
\approx 1 + \frac{1}{2}(1-2\gamma)^2 a Y_\nu^2
\approx \exp \biggl[ \frac{1}{2}(1-2\gamma)^2 a Y_\nu^2 \biggr].
\end{equation}
The averaging is performed first over $\nu$, then over $\mu$. Continuing,
\begin{align}
\biggl\langle \prod_\nu \exp[\zeta^i_{\mu\nu} Y_\nu] \biggr\rangle_{\!\!{\mu\nu}}
&\approx \frac{1}{2}\prod_\nu \biggl\{1 + \gamma cY_\nu + \frac{\gamma^2}{2}Y_\nu^2\biggr\} + \frac{1}{2}\prod_\nu \biggl\{1 - \gamma cY_\nu + \frac{\gamma^2}{2}Y_\nu^2\biggr\} \nonumber\\
&= 1 + \frac{1}{2} \sum_{\nu\omega} \Bigl[ \gamma^2(1-c^2)\delta_{\nu\omega} + \gamma^2c^2 \Bigr] Y_\nu Y_\omega \nonumber\\
&\approx \exp\biggl\{ \frac{1}{2} \sum_{\nu\omega} \Bigl[ \gamma^2(1-c^2)\delta_{\nu\omega} + \gamma^2c^2 \Bigr] Y_\nu Y_\omega \biggr\}.
\end{align}
Thus,
\begin{align}
\left\langle \prod_{{\mu\nu}\rho} \exp\biggl[\beta m^\rho_{\mu\nu} \sum_i (\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) S^\rho_i\biggr] \right\rangle
= \prod_\mu \exp\biggl\{ \frac{\beta N}{2} \beta\Gamma^2 \sum_{{\nu\omega}{\rho\sigma}} \bigl[(1-\kappa^2)\delta_{\nu\omega} + \kappa^2\bigr] q^{\rho\sigma} m^\rho_{\mu\nu} m^\sigma_{\mu\omega} \biggr\}
\end{align}
if we define
\begin{equation}
\kappa^2 \equiv \frac{\gamma^2}{\Gamma^2}c^2
\end{equation}
and enforce
\begin{equation}
q^{\rho\sigma} = \frac{1}{N}\sum_i S^\rho_i S^\sigma_i.
\end{equation}
We will do so by introducing the following integrals over delta-function representations:
\begin{equation}
\prod_{\rho\leq\sigma} \int \mathrm{d} q^{\rho\sigma}\,\delta\bigg(q^{\rho\sigma} - \frac{1}{N}\sum_i S^\rho_i S^\sigma_i\bigg) \propto \int \biggl[\prod_{\rho<\sigma} \mathrm{d} q^{\rho\sigma}\,\mathrm{d} r^{\rho\sigma}\biggr] \exp\biggl[-\beta^2\alpha N \sum_{\rho\sigma} q^{\rho\sigma} r^{\rho\sigma} + \beta^2\alpha \sum_{i{\rho\sigma}} r^{\rho\sigma} S^\rho_i S^\sigma_i\biggr],
\end{equation}
where $r^{\rho\sigma}$ are additional auxillary variables and the factor of $\beta^2\alpha N$ is introduced for later convenience.
We can now integrate over the uncondensed overlaps $m^\rho_{\mu\nu}$:
\begin{alignat}{2}
&\mathrlap{ \left\langle \prod_{{\mu\nu}\rho} \int \mathrm{d} m^\rho_{\mu\nu} \biggl(\frac{\beta N}{2\pi}\biggr)^{\!\frac{1}{2}} \exp\biggl[-\frac{\beta N}{2} (m^\rho_{\mu\nu})^2 + \beta m^\rho_{\mu\nu} \sum_i (\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) S^\rho_i\biggr] \right\rangle } \nonumber\\
&\qquad &&{}\propto \prod_\mu \int \biggl[\prod_{\nu\rho} \mathrm{d} m^\rho_{\mu\nu} \biggl(\frac{\beta N}{2\pi}\biggr)^{\!\frac{1}{2}}\biggr] \exp\biggl[-\frac{\beta N}{2} \sum_{{\nu\omega}{\rho\sigma}} \bigl[ \delta_{\nu\omega}\delta^{\rho\sigma} - \beta\Gamma^2 \bigl( (1-\kappa^2)\delta_{\nu\omega} + \kappa^2 \bigr) q^{\rho\sigma} \bigr] m^\rho_{\mu\nu} m^\sigma_{\mu\omega}\biggr] \nonumber\\
&&&{}= \biggl(\det\bigl[ \delta_{\nu\omega}\delta^{\rho\sigma} - \beta\Gamma^2 \bigl( (1-\kappa^2)\delta_{\nu\omega} + \kappa^2 \bigr) q^{\rho\sigma} \bigr]^{-\frac{1}{2}}\biggr)^{\!p} \nonumber\\
&&&{}= \exp \biggl\{-\frac{p}{2} \mathrm{Tr}\log\Bigl[ \delta_{\nu\omega}\delta^{\rho\sigma} - \beta\Gamma^2 \bigl((1-\kappa^2)\delta_{\nu\omega} + \kappa^2\bigr) q^{\rho\sigma} \Bigr] \biggr\}.
\end{alignat}
Thus, so far, our partition function is
\begin{align}
\langle Z^n \rangle \propto \int &\biggl[\prod_{\nu\rho} \mathrm{d} m^\rho_{1\nu} \biggl(\frac{\beta N}{2\pi}\biggr)^{\frac{1}{2}}\biggr] \biggl[\prod_{\rho\leq\sigma} \mathrm{d} q^{\rho\sigma}\,\mathrm{d} r^{\rho\sigma}\biggr] \nonumber\\
&{}\times \exp\Biggl\{ -\beta N \biggl[\frac{1}{2} \sum_{\nu\rho} (m^\rho_{1\nu})^2 + \frac{\alpha}{2\beta} \mathrm{Tr}\log\bigl[ \delta_{\nu\omega}\delta^{\rho\sigma} - \beta\Gamma^2 \bigl((1-\kappa^2)\delta_{\nu\omega} + \kappa^2\bigr) q^{\rho\sigma} \bigr] + \frac{\beta\alpha}{2} \sum_{\rho\sigma} q^{\rho\sigma} r^{\rho\sigma} \biggr]\Biggr\} \nonumber\\
&{}\times \biggl\langle \mathrm{Tr}_S \exp\biggl[\beta \sum_{i\nu\rho} m^\rho_{1\nu} (\eta^i_{1\nu} + \zeta^i_{1\nu}) S^\rho_i - \beta \biggl(\theta + \frac{\alpha s\Gamma^2}{2}\biggr) \sum_{i\rho}S^\rho_i + \frac{\beta^2\alpha}{2} \sum_{i{\rho\sigma}} r^{\rho\sigma} S^\rho_i S^\sigma_i\biggr] \biggr\rangle.
\end{align}
We will consider the possibility that the network overlaps significantly with either one sparse example $\eta_{11}$ or dense examples $\zeta_{1\nu}$ of one concept. Thus, we replace
\begin{equation}
\sum_{i\nu\rho} m^\rho_{1\nu} (\eta^i_{1\nu} + \zeta^i_{1\nu}) S^\rho_i \cond{by} \sum_{i\nu\rho} m^\rho_{1\nu} \chi^i_{1\nu} S^\rho_i,
\end{equation}
where $\chi^i_{1\nu} = \eta^i_{11}\delta_{1\nu}$ or $\zeta^i_{1\nu}$ depending on whether we are considering recovery of sparse or dense patterns.
\subsection{Condensed pattern}
We now take advantage of self-averaging over the $i$ indices. For any function $F\{\chi^i, S_i\}$ that only depends on one $i$ at a time,
\begin{align}
\mathrm{Tr}_S \exp\biggl[\sum_i F\{\chi^i, S_i\}\biggr]
&= \prod_i \mathrm{Tr}_{S_i} \exp F\{\chi^i, S_i\} \nonumber\\
&= \exp\biggl[ \sum_i \log \mathrm{Tr}_{S_i} \exp F\{\chi^i, S_i\}\biggr] \nonumber\\
&= \exp\biggl[ N \langle \log \mathrm{Tr}_S \exp F\{\chi, S\} \rangle_\chi \biggr].
\end{align}
Now $\chi$ and $S$ represent the pattern entry and activity of a single neuron. This single neuron is representative of the entire network because we now average over possible pattern entries $\chi$.
With this, our partition function becomes
\begin{equation}
\langle Z^n \rangle \propto \int \biggl[\prod_{\nu\rho} \mathrm{d} m^\rho_{1\nu} \biggl(\frac{\beta N}{2\pi}\biggr)^{\!\frac{1}{2}}\biggr] \biggl[\prod_{\rho\leq\sigma} \mathrm{d} q^{\rho\sigma}\,\mathrm{d} r^{\rho\sigma}\biggr] \exp[-\beta N f],
\end{equation}
where
\begin{align}
f ={}& \frac{1}{2} \sum_{\nu\rho} (m^\rho_{1\nu})^2 + \frac{\alpha}{2\beta} \mathrm{Tr}\log\bigl[ \delta_{\nu\omega}\delta^{\rho\sigma} - \beta\Gamma^2 \bigl((1-\kappa^2)\delta_{\nu\omega} + \kappa^2\bigr) q^{\rho\sigma} \bigr] + \frac{\beta\alpha}{2} \sum_{\rho\sigma} q^{\rho\sigma} r^{\rho\sigma} \nonumber\\
&{}- \frac{1}{\beta} \left\langle \log\mathrm{Tr}_S \exp\Biggl\{ \beta \biggl[ \sum_{\nu\rho} m^\rho_{1\nu} \chi_{1\nu} S^\rho - \biggl(\theta + \frac{\alpha s \Gamma^2}{2}\biggr) \sum_\rho S^\rho + \frac{\beta\alpha}{2} \sum_{\rho\sigma} r^{\rho\sigma} S^\rho S^\sigma \biggr] \Biggr\} \right\rangle.
\end{align}
\subsection{Saddle-point approximation}
The free energy per neuron is
\begin{equation}
\frac{F}{N} = -\frac{1}{\beta N} \langle \log Z \rangle = -\frac{1}{\beta N} \lim_{n\rightarrow 0} \frac{\langle Z^n \rangle - 1}{n} = -\frac{1}{\beta N} \lim_{n\rightarrow 0} \frac{1}{n} \log \langle Z^n \rangle = \lim_{n\rightarrow 0} \frac{1}{n} \min f\{m, q, r\},
\end{equation}
where we have replaced $\langle Z^n \rangle$ with its saddle point value. To determine the saddle point location, it is helpful to revert $f$ to its expression before integrating over the uncondensed overlaps $m^\rho_{\mu\nu}$:
\begin{align}
f ={}& \frac{1}{2} \sum_{\nu\rho} (m^\rho_{1\nu})^2 + \frac{1}{2} \sum_{\mu{\nu\omega}{\rho\sigma}} \bigl[ \delta_{\nu\omega}\delta^{\rho\sigma} - \beta\Gamma^2 \bigl((1-\kappa^2)\delta_{\nu\omega} + \kappa^2\bigr) q^{\rho\sigma} \bigr] m^\rho_{\mu\nu} m^\sigma_{\mu\omega} + \frac{\beta\alpha}{2} \sum_{\rho\sigma} q^{\rho\sigma} r^{\rho\sigma} \nonumber\\
&{}- \frac{1}{\beta} \left\langle \log\mathrm{Tr}_S \exp\Biggl\{ \beta \biggl[ \sum_{\nu\rho} m^\rho_{1\nu} \chi_{1\nu} S^\rho - \biggl(\theta + \frac{\alpha s \Gamma^2}{2}\biggr) \sum_\rho S^\rho + \frac{\beta\alpha}{2} \sum_{\rho\sigma} r^{\rho\sigma} S^\rho S^\sigma \biggr] \Biggr\} \right\rangle.
\end{align}
The location of this point is determined by setting derivatives to zero. If we observe that the single neuron Hamiltonian is
\begin{equation}
\mathcal{H} \equiv - \sum_{\nu\rho} m^\rho_{1\nu} \chi_{1\nu} S^\rho + \biggl(\theta + \frac{\alpha s \Gamma^2}{2}\biggr) \sum_\rho S^\rho - \frac{\beta\alpha}{2} \sum_{\rho\sigma} r^{\rho\sigma} S^\rho S^\sigma,
\end{equation}
we obtain
\begin{align}
0 &= \parpar{f}{m^\rho_{1\nu}} = m^\rho_{1\nu} - \left\langle \frac{ \mathrm{Tr}_S\,\chi_{1\nu} S^\rho \exp[-\beta\mathcal{H}] }{ \mathrm{Tr}_S \exp[-\beta\mathcal{H}] } \right\rangle \nonumber\\
\Rightarrow m^\rho_{1\nu} &= \left\langle \chi_{1\nu} \overline{S^\rho} \right\rangle, \\
\nonumber\\
0 &= \parpar{f}{r^{\rho\sigma}} = \frac{\beta\alpha}{2} q^{\rho\sigma} - \frac{\beta\alpha}{2} \left\langle \frac{ \mathrm{Tr}_S\, S^\rho S^\sigma \exp[-\beta\mathcal{H}] }{ \mathrm{Tr}_S \exp[-\beta\mathcal{H}] } \right\rangle \nonumber\\
\Rightarrow q^{\rho\sigma} &= \left\langle \overline{S^\rho S^\sigma} \right\rangle = \begin{cases} \left\langle \overline{S^\rho} \cdot \overline{S^\sigma} \right\rangle & \rho \neq \sigma \\ \left\langle \overline{S^\rho} \right\rangle & \rho = \sigma, \end{cases} \\
\nonumber\\
0 &= \parpar{f}{q^{\rho\sigma}} = \frac{\beta\alpha}{2} r^{\rho\sigma} - \frac{\beta}{2} \sum_{\mu{\nu\omega}} \Gamma^2\bigl((1-\kappa^2)\delta_{\nu\omega} + \kappa^2\bigr) m^\rho_{\mu\nu} m^\sigma_{\mu\omega} \nonumber\\
\Rightarrow r^{\rho\sigma} &= \frac{1}{\alpha} \sum_{\mu{\nu\omega}} \Gamma^2\bigl((1-\kappa^2)\delta_{\nu\omega} + \kappa^2\bigr) m^\rho_{\mu\nu} m^\sigma_{\mu\omega}.
\end{align}
Bars over variables represent the thermodynamic ensemble average. Thus, $m$ is the overlap of the network with the condensed pattern to be recovered, $q$ is the overall neural activity, and $r$ is related to the overlap of the network with uncondensed patterns.
\subsection{Replica-symmetry ansatz}
We assume replica symmetry:
\begin{equation}
m^\rho_{\mu\nu} = m_{\mu\nu}, \qquad q^{\rho\sigma} = q, \qquad q^{\rho\rho} = q_0, \qquad r^{\rho\sigma} = r, \qquad r^{\rho\rho} = r_0.
\end{equation}
Our expression for $f$ then becomes
\begin{align}
f ={}& \frac{1}{2} n \sum_\nu (m_{1\nu})^2 + \frac{\alpha}{2\beta} \mathrm{Tr}\log\bigl[ \delta_{\nu\omega}\delta^{\rho\sigma} - \beta\Gamma^2 \bigl((1-\kappa^2)\delta_{\nu\omega} + \kappa^2\bigr) \bigl((q_0-q)\delta^{\rho\sigma} + q\bigr) \bigr] + \frac{\beta\alpha n}{2} q_0 r_0 + \frac{\beta\alpha n(n-1)}{2} qr \nonumber\\
&{}- \frac{1}{\beta} \left\langle \log\mathrm{Tr}_S \exp\Biggl\{ \beta\biggl[ \biggl(\sum_\nu m_{1\nu} \chi_{1\nu} - \theta - \frac{\alpha s\Gamma^2}{2} + \frac{\beta\alpha}{2} (r_0 - r)\biggr) \sum_\rho S^\rho + \frac{\beta\alpha}{2} r \biggl(\sum_\rho S^\rho\biggr)^{\!\!2} \biggr]\Biggr\} \right\rangle.
\end{align}
The eigenvalues of a constant $n \times n$ matrix are $n$ with multiplicity $1$ and $0$ with multiplicity $n-1$. Thus,
\begin{alignat}{3}
&\mathrlap{ \lim_{n \rightarrow 0} \frac{1}{n} \mathrm{Tr}\log\bigl[ \delta_{\nu\omega}\delta^{\rho\sigma} - \beta\Gamma^2 \bigl((1-\kappa^2)\delta_{\nu\omega} + \kappa^2\bigr) \bigl((q_0-q)\delta^{\rho\sigma} + q\bigr) \bigr] } \nonumber\\
&\qquad{}={} && \lim_{n \rightarrow 0} \frac{1}{n} \biggl\{ &&\log\bigl[ 1 - \beta\Gamma^2 (1+s\kappa^2-\kappa^2) (q_0-q+nq) \bigr] + (n-1) \log\bigl[ 1 - \beta\Gamma^2 (1+s\kappa^2-\kappa^2) (q_0-q) \bigr]\nonumber\\
&&&&& + (s-1) \log\bigl[ 1 - \beta\Gamma^2 (1-\kappa^2) (q_0-q+nq) \bigr] + (s-1)(n-1) \log\bigl[ 1 - \beta\Gamma^2 (1-\kappa^2) (q_0-q) \bigr] \biggr\}\nonumber\\
&\qquad{}={} && \mathrlap{ (s-1) \biggl[\log\bigl[1 - Q (1-\kappa^2)\bigr] - \frac{\beta q \Gamma^2 (1-\kappa^2)}{1 - Q (1-\kappa^2)}\biggr] + \log\bigl[1 - Q (1+s\kappa^2-\kappa^2)\bigr] - \frac{\beta q \Gamma^2 (1+s\kappa^2-\kappa^2)}{1 - Q (1+s\kappa^2-\kappa^2)}, }\nonumber\\
&\qquad{}\equiv{} && \Lambda[q,q_0],
\end{alignat}
where
\begin{equation}
Q \equiv \beta(q_0-q)\Gamma^2.
\end{equation}
Meanwhile, we can use another gaussian integral to perform the trace over $S$ in the limit $n \rightarrow 0$:
\begin{align}
&\left\langle \log\mathrm{Tr}_S \exp\Biggl\{ \beta \biggl[\biggl(\sum_\nu m_{1\nu} \chi_{1\nu} - \theta - \frac{\alpha s\Gamma^2}{2} + \frac{\beta\alpha}{2} (r_0-r)\biggr) \sum_\rho S^\rho + \frac{\beta\alpha}{2} r \biggl(\sum_\rho S^\rho\biggr)^{\!\!2} \biggr]\Biggr\} \right\rangle \nonumber\\
&\qquad {}= \left\langle \log\mathrm{Tr}_S \int\!\!\frac{\mathrm{d} z}{\sqrt{2\pi}} \mathrm{e}^{-z^2/2} \exp\Biggl\{ \beta \biggl[\biggl(\sum_\nu m_{1\nu} \chi_{1\nu} - \theta + \frac{\beta\alpha}{2} (r_0-r) - \frac{\alpha s\Gamma^2}{2} + \sqrt{\alpha r} z\biggr) \sum_\rho S^\rho \biggr]\Biggr\} \right\rangle \nonumber\\
&\qquad {}= \left\langle \log\int\!\!\frac{\mathrm{d} z}{\sqrt{2\pi}} \mathrm{e}^{-z^2/2} \Biggl\{1 + \exp\biggl[ \beta \biggl(\sum_\nu m_{1\nu} \chi_{1\nu} - \theta + \frac{\beta\alpha}{2} (r_0-r) - \frac{\alpha s\Gamma^2}{2} + \sqrt{\alpha r} z\biggr) \biggr] \Biggr\}^{\!n} \right\rangle \nonumber\\
&\qquad {}\approx \left\langle \log\int\!\!\frac{\mathrm{d} z}{\sqrt{2\pi}} \mathrm{e}^{-z^2/2} \Biggl\{1 + n \log \biggl\{1 + \exp\biggl[ \beta \biggl(\sum_\nu m_{1\nu} \chi_{1\nu} - \theta + \frac{\beta\alpha}{2} (r_0-r) - \frac{\alpha s\Gamma^2}{2} + \sqrt{\alpha r} z\biggr) \biggr] \biggl\} \Biggr\} \right\rangle \nonumber\\
&\qquad {}\approx n\,\left\langle \int\!\!\frac{\mathrm{d} z}{\sqrt{2\pi}} \mathrm{e}^{-z^2/2} \log \biggl\{1 + \exp\biggl[ \beta \biggl(\sum_\nu m_{1\nu} \chi_{1\nu} - \theta + \frac{\beta\alpha}{2} (r_0-r) - \frac{\alpha s\Gamma^2}{2} + \sqrt{\alpha r} z\biggr) \biggr] \biggr\} \right\rangle.
\end{align}
This gives us the free energy under replica symmetry
\begin{align}
\frac{F}{N} ={}& \frac{1}{2} \sum_\nu (m_{1\nu})^2 + \frac{\alpha}{2\beta} \Lambda[q,q_0] + \frac{\beta\alpha}{2} (q_0 r_0 - qr) \nonumber\\
&{}- \frac{1}{\beta} \left\llangle \log \biggl\{1 + \exp\biggl[ \beta \biggl(\sum_\nu m_{1\nu} \chi_{1\nu} - \theta + \frac{\beta\alpha}{2} (r_0-r) - \frac{\alpha s\Gamma^2}{2} + \sqrt{\alpha r} z\biggr) \biggr] \biggr\} \right\rrangle,
\end{align}
where now the double angle brackets also indicate an average over the gaussian variable $z$.
\subsection{Mean-field equations}
The mean-field equations arise from the saddle point approximation and are equivalent to setting derivatives of $F$ to zero. We first note that
\begin{equation}
\parpar{\Lambda}{q} = (s-1) \frac{\beta^2 q\Gamma^4 (1-\kappa^2)^2}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}} + \frac{\beta^2 q\Gamma^4 (1+s\kappa^2-\kappa^2)^2}{\bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)^{\!2}}.
\end{equation}
The combined fraction has numerator $\beta^2 q\Gamma^4$ multipled by
\begin{align}
&(s-1)\Bigl[\bigl(1-\kappa^2\bigr) \bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)\Bigr]^2 + \Bigl[\bigl(1+s\kappa^2-\kappa^2\bigr) \bigl(1 - Q(1-\kappa^2)\bigr)\Bigr]^2 \nonumber\\
&\qquad{}= s \bigl(1 - Q(1-\kappa^2)(1+s\kappa^2-\kappa^2)\bigr)^{\!2} + s(s-1)\kappa^4.
\end{align}
Meanwhile,
\begin{align}
\parpar{\Lambda}{q_0} &= (s-1)\biggl[ -\frac{\beta\Gamma^2 (1-\kappa^2)}{1 - Q(1-\kappa^2)} - \frac{\beta^2 q\Gamma^4 (1-\kappa^2)^2}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}} \biggr] - \frac{\beta (1+s\kappa^2-\kappa^2)}{1 - Q(1+s\kappa^2-\kappa^2)} - \frac{\beta^2 q\Gamma^4 (1+s\kappa^2-\kappa^2)^2}{\bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)^{\!2}} \nonumber\\
&= -\parpar{\Lambda}{q} - \beta\Gamma^2\biggl[ \frac{(s-1)(1-\kappa^2)}{1 - Q(1-\kappa^2)} + \frac{1+s\kappa^2-\kappa^2}{1 - Q(1+s\kappa^2-\kappa^2)} \biggr].
\end{align}
The combined fraction has numerator
\begin{align}
(s-1)(1-\kappa^2)\bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr) + (1+s\kappa^2-\kappa^2)\bigl(1 - Q(1-\kappa^2)\bigr)= s\bigl(1 - Q(1-\kappa^2)(1+s\kappa^2-\kappa^2)\bigr).
\end{align}
Thus, the derivatives become
\begin{align}
0 &= \parpar{F}{q} = \frac{\alpha}{2 \beta} \biggl[\beta^2 qs\Gamma^4 \frac{\bigl(1 - Q(1-\kappa^2)(1+s\kappa^2-\kappa^2)\bigr)^{\!2} + (s-1)\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)^{\!2}} \biggr] - \frac{\beta\alpha}{2} r \nonumber\\
\Rightarrow r &= qs\Gamma^4 \frac{\bigl(1 - Q(1-\kappa^2)(1+s\kappa^2-\kappa^2)\bigr)^{\!2} + (s-1)\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)^{\!2}} \\
\nonumber\\
0 &= \parpar{F}{q_0} = \frac{\alpha}{2 \beta} \biggl[ -\parpar{\Lambda}{q_0} -\beta s\Gamma^2 \frac{1 - Q(1-\kappa^2)(1+s\kappa^2-\kappa^2)}{\bigl(1 - Q(1-\kappa^2)\bigr) \bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)} \biggr] + \frac{\beta\alpha}{2} r_0 \nonumber\\
\Rightarrow r_0 &= r + \frac{s\Gamma^2}{\beta} \frac{1 - Q(1-\kappa^2)(1+s\kappa^2-\kappa^2)}{\bigl(1 - Q(1-\kappa^2)\bigr) \bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)} \\
\nonumber\\
0 &= \parpar{F}{m_{1\nu}} = m_{1\nu} - \left\llangle \chi_{1\nu} \mathop{\mathrm{sig}}\nolimits[\beta\mathcal{H}] \right\rrangle \nonumber\\
\Rightarrow m_{1\nu} &= \left\llangle \chi_{1\nu} \mathop{\mathrm{sig}}\nolimits[\beta\mathcal{H}] \right\rrangle,
\end{align}
where $\mathop{\mathrm{sig}}\nolimits[x] \equiv 1/(1+\mathrm{e}^{-x})$ and
\begin{equation}
\mathcal{H} \equiv \sum_\nu m_{1\nu} \chi_{1\nu} - \theta + \frac{\beta\alpha}{2} (r_0 - r) - \frac{\alpha s\Gamma^2}{2} + \sqrt{\alpha r} z.
\end{equation}
We can simplify
\begin{align}
&\frac{\beta\alpha}{2} (r_0 - r) - \frac{\alpha s\Gamma^2}{2} \nonumber\\
&\qquad{}= \frac{\alpha s\Gamma^2}{2} \cdot \frac{1 - Q(1-\kappa^2)(1+s\kappa^2-\kappa^2) - \bigl(1 - Q(1-\kappa^2)\bigr) \bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)}{\bigl(1 - Q(1-\kappa^2)\bigr) \bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)} \nonumber\\
&\qquad{}= \frac{\alpha s\Gamma^2}{2} \cdot \frac{Q\kappa^2(1+s\kappa^2-\kappa^2) + Q(1-\kappa^2) - Q^2(1-\kappa^2)(1+s\kappa^2-\kappa^2)}{\bigl(1 - Q(1-\kappa^2)\bigr) \bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)} \nonumber\\
&\qquad{}= \frac{Q\alpha s\Gamma^2}{2} \cdot \frac{1+s\kappa^4-\kappa^4 - Q(1-\kappa^2)(1+s\kappa^2-\kappa^2)}{\bigl(1 - Q(1-\kappa^2)\bigr) \bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)}.
\end{align}
Thus,
\begin{equation}
\mathcal{H} \equiv \sum_\nu m_{1\nu} \chi_{1\nu} - \theta + \frac{\alpha s\Gamma^2}{2} Q \frac{1+s\kappa^4-\kappa^4 - Q(1-\kappa^2)(1+s\kappa^2-\kappa^2)}{\bigl(1 - Q(1-\kappa^2)\bigr) \bigl(1 - Q(1+s\kappa^2-\kappa^2)\bigr)} + \sqrt{\alpha r} z.
\end{equation}
Continuing, and using the identities $\int \mathrm{d} z\,\mathrm{e}^{-z^2/2} z f(z) = \int \mathrm{d} z\,\mathrm{e}^{-z^2/2}\ \mathrm{d} f(z)/\mathrm{d} z$ and $\mathrm{d}\mathop{\mathrm{sig}}\nolimits(x)/\mathrm{d} x = \mathop{\mathrm{sig}}\nolimits(x) \bigl(1-\mathop{\mathrm{sig}}\nolimits(x)\bigr)$,
\begin{align}
0 &= \parpar{F}{r} = -\frac{\beta\alpha}{2} q - \frac{\sqrt{\alpha}}{2\sqrt{r}} \left\llangle z \mathop{\mathrm{sig}}\nolimits[\beta\mathcal{H}] \right\rrangle + \frac{\beta\alpha}{2} \left\llangle \mathop{\mathrm{sig}}\nolimits[\beta\mathcal{H}] \right\rrangle \nonumber\\
\Rightarrow q &= \mathrlap{ \left\llangle \mathop{\mathrm{sig}}\nolimits[\beta\mathcal{H}]^2 \right\rrangle } \\
\nonumber\\
0 &= \parpar{F}{r_0} = \frac{\beta\alpha}{2} q_0 - \frac{\beta\alpha}{2} \left\llangle \mathop{\mathrm{sig}}\nolimits[\beta\mathcal{H}] \right\rrangle \nonumber\\
\Rightarrow q_0 &= \mathrlap{ \left\llangle \mathop{\mathrm{sig}}\nolimits[\beta\mathcal{H}] \right\rrangle. }
\end{align}
With the definitions
\begin{align}
s_0 &\equiv s-1, \nonumber\\
\phi &\equiv \theta - \frac{Q\alpha s\Gamma^2}{2} \cdot \frac{1+s_0\kappa^4 - Q(1-\kappa^2)(1+s_0\kappa^2)}{\bigl(1 - Q(1-\kappa^2)\bigr) \bigl(1 - Q(1+s_0\kappa^2)\bigr)},
\end{align}
we recover the mean-field equations presented in \cref{eq:overview-meanfield}.
\subsection{Zero-temperature limit}
In the limit $\beta\rightarrow\infty$, we will define the function $\mathop{\mathrm{dsig}}\nolimits(x) = \mathop{\mathrm{sig}}\nolimits(x)[1 - \mathop{\mathrm{sig}}\nolimits(x)]$ and use the identity
\begin{align}
\int\!\!\frac{\mathrm{d} z}{\sqrt{2\pi}} \mathrm{e}^{-z^2/2} \mathop{\mathrm{dsig}}\nolimits[\beta(az+b)]
= \int\!\!\frac{\mathrm{d} z}{\sqrt{2\pi}\beta a} \mathrm{e}^{-z^2/2} \parpar{}{z}\mathop{\mathrm{sig}}\nolimits[\beta(az+b)]
\approx \int\!\!\frac{\mathrm{d} z}{\sqrt{2\pi}\beta a} \mathrm{e}^{-z^2/2} \parpar{}{z}\Theta[az+b]
= \frac{1}{\sqrt{2\pi}\beta|a|} \mathrm{e}^{-b^2/2a^2},
\end{align}
where $\Theta$ is the Heaviside step function. Now we calculate
\begin{equation}
Q \approx \beta\Gamma^2 \biggl\llangle \mathop{\mathrm{dsig}}\nolimits\biggl[\beta \biggl(\sum_\nu m_{1\nu}\chi_{1\nu}-\phi+\sqrt{\alpha r} z\biggr)\biggr] \biggr\rrangle
= \frac{\Gamma^2}{\sqrt{2\pi{\alpha r}}} \Biggl\langle\exp\Biggl[ -\frac{\bigl(\sum_\nu m_{1\nu} \chi_{1\nu} - \phi\bigr)^{\!2}}{2{\alpha r}}\Biggr]\Biggr\rangle.
\end{equation}
We then use the identity
\begin{equation}
\int\!\!\frac{\mathrm{d} z}{\sqrt{2\pi}} \mathrm{e}^{-z^2/2}\, \Theta[az+b]
= \frac{1}{2} \biggl(1 + \mathop{\mathrm{erf}}\nolimits\frac{b}{\sqrt{2}a}\biggr).
\end{equation}
We also note that $\llangle \chi_{1\nu} \rrangle = 0$ for both sparse and dense patterns. Now we calculate
\begin{align}
m_{1\nu} &\approx \biggl\llangle \chi_{1\nu} \,\Theta\biggl[\sum_\nu m_{1\nu}\chi_{1\nu}-\phi+\sqrt{\alpha r} z\biggr] \biggr\rrangle
= \frac{1}{2}\Biggl\langle \chi_{1\nu} \mathop{\mathrm{erf}}\nolimits\frac{\sum_\nu m_{1\nu} \chi_{1\nu} - \phi}{\sqrt{2{\alpha r}}} \Biggr\rangle, \\
\nonumber\\
q &\approx \biggl\llangle \Theta\biggl[\sum_\nu m_{1\nu}\chi_{1\nu}-\phi+\sqrt{\alpha r} z\biggr] \biggr\rrangle
= \frac{1}{2} \Biggl[1 + \Biggl\langle \mathop{\mathrm{erf}}\nolimits\frac{\sum_\nu m_{1\nu} \chi_{1\nu} - \phi}{\sqrt{2{\alpha r}}} \Biggr\rangle \Biggr], \\
\nonumber\\
r &= qs\Gamma^4 \frac{\bigl(1 - Q(1-\kappa^2)(1+s_0\kappa^2)\bigr)^{\!2} + s_0\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s_0\kappa^2)\bigr)^{\!2}} \nonumber\\
&= \frac{s\Gamma^4}{2} \cdot \frac{\bigl(1 - Q(1-\kappa^2)(1+s_0\kappa^2)\bigr)^{\!2} + s_0\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s_0\kappa^2)\bigr)^{\!2}} \Biggl[1 + \Biggl\langle \mathop{\mathrm{erf}}\nolimits\frac{\sum_\nu m_{1\nu} \chi_{1\nu} - \phi}{\sqrt{2{\alpha r}}} \Biggr\rangle \Biggr].
\end{align}
Here, the single angle brackets indicate an average over $\chi_{1\nu}$, with the average over $z$ performed.
\section{\label{sec:se}Capacity for sparse examples}
\subsection{Sparse mean-field equations}
Now we wish to recover the sparse pattern, so $\chi_{1\nu} = \eta_{11} \delta_{1\nu}$. We rename $m \equiv m_{11}$ and $\eta \equiv \eta_{11}$. We have
\begin{equation}
\eta =
\begin{cases} (1-2\gamma)(1-a) & \textrm{with probability } a \\
-(1-2\gamma)a & \textrm{with probability } 1-a \end{cases}
\approx \begin{cases} 1-2\gamma & \textrm{with probability } a \\
0 & \textrm{with probability } 1 \end{cases}
\end{equation}
Then,
\begin{align}
m &= \frac{1}{2}\biggl\langle \eta \mathop{\mathrm{erf}}\nolimits\frac{m\eta-\phi}{2{\alpha r}} \biggr\rangle = \frac{(1-2\gamma)a}{2} \Biggl\{\mathop{\mathrm{erf}}\nolimits\frac{\phi}{\sqrt{2{\alpha r}}} + \mathop{\mathrm{erf}}\nolimits\frac{(1-2\gamma)m-\phi}{\sqrt{2{\alpha r}}} \Biggr\}, \\
\nonumber\\
r &= \frac{s\Gamma^4}{2} \cdot \frac{\bigl(1 - Q(1-\kappa^2)(1+s_0\kappa^2)\bigr)^{\!2} + s_0\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s_0\kappa^2)\bigr)^{\!2}} \biggl[1 + \biggl\langle \mathop{\mathrm{erf}}\nolimits\frac{m\eta-\phi}{\sqrt{2{\alpha r}}} \biggr\rangle \biggr] \nonumber\\
&= \frac{s\Gamma^4}{2} \cdot \frac{\bigl(1 - Q(1-\kappa^2)(1+s_0\kappa^2)\bigr)^{\!2} + s_0\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s_0\kappa^2)\bigr)^{\!2}} \Biggl\{1 - \mathop{\mathrm{erf}}\nolimits\frac{\phi}{\sqrt{2{\alpha r}}} + a \mathop{\mathrm{erf}}\nolimits\frac{(1-2\gamma)m-\phi}{\sqrt{2{\alpha r}}} \Biggr\}, \\
\nonumber\\
Q &= \frac{\Gamma^2}{\sqrt{2\pi{\alpha r}}} \biggl\langle\exp\biggl[ -\frac{(m\eta - \phi)^2}{2{\alpha r}}\biggr]\biggr\rangle = \frac{\Gamma^2}{\sqrt{2\pi{\alpha r}}} \Biggl\{\exp\biggl[-\frac{\phi^2}{2{\alpha r}}\biggr] + a\exp\biggl[-\frac{((1-2\gamma)m - \phi)^2}{2{\alpha r}}\biggr] \Biggr\}.
\end{align}
We will see that $Q \ll 1$. In that case, the mean field equations become
\begin{align}
m &= \frac{(1-2\gamma)a}{2} \Biggl\{\mathop{\mathrm{erf}}\nolimits\frac{\phi}{\sqrt{2{\alpha r}}} + \mathop{\mathrm{erf}}\nolimits\frac{(1-2\gamma)m-\phi}{\sqrt{2{\alpha r}}} \Biggr\}, \nonumber\\
r &= \frac{s \bigl(1+(s-1)\kappa^4\bigr) \Gamma^4}{2} \Biggl\{1 - \mathop{\mathrm{erf}}\nolimits\frac{\phi}{\sqrt{2{\alpha r}}} + a \mathop{\mathrm{erf}}\nolimits\frac{(1-2\gamma)m-\phi}{\sqrt{2{\alpha r}}} \Biggr\}.
\end{align}
These are presented in \cref{eq:overview-A}.
We can map our dual input equations onto the classic sparse Hopfield equations with the rescalings
\begin{align}
m &= (1-2\gamma)a \cdot m', \nonumber\\
\phi &= (1-2\gamma)^2a \cdot \theta', \nonumber\\
r &= s \bigl(1+s_0\kappa^4\bigr) \Gamma^4 \cdot r', \nonumber\\
\alpha &= \frac{{(1-2\gamma)^4}a^2}{s \bigl(1+s_0\kappa^4\bigr)\Gamma^4} \cdot \alpha'.
\label{eq:A-rescale}
\end{align}
Then,
\begin{align}
m' &= \frac{1}{2}\biggl[\mathop{\mathrm{erf}}\nolimits\frac{\theta'}{\sqrt{2{\alpha' r'}}} + \mathop{\mathrm{erf}}\nolimits\frac{m' - \theta'}{\sqrt{2{\alpha' r'}}}\biggr] \nonumber\\
r' &= \frac{1}{2}\biggl[1 - \mathop{\mathrm{erf}}\nolimits\frac{\theta'}{\sqrt{2{\alpha' r'}}} + a \mathop{\mathrm{erf}}\nolimits\frac{m' - \theta'}{\sqrt{2{\alpha' r'}}}\biggr].
\end{align}
Successfully recovering the sparse example means that $m \rightarrow 1$, which requires $\theta'/\sqrt{2{\alpha' r'}} \gg 1$ and $(m'-\theta')/\sqrt{2{\alpha' r'}} \gg 1$. Under these limits, $0 < \theta' < 1$ and
\begin{align}
m' &= 1 - \frac{1}{\sqrt{2\pi}} \frac{\sqrt{\alpha' r'}}{\theta'}\mathrm{e}^{-\theta'^2/2{\alpha' r'}} - \frac{1}{\sqrt{2\pi}} \frac{\sqrt{\alpha' r'}}{m'-\theta'}\mathrm{e}^{-(m'-\theta')^2/2{\alpha' r'}} \nonumber\\
r' &= \frac{1}{\sqrt{2\pi}} \frac{\sqrt{\alpha' r'}}{\theta'}\mathrm{e}^{-\theta'^2/2{\alpha' r'}} + \frac{a}{2} - \frac{a}{\sqrt{2\pi}} \frac{\sqrt{\alpha' r'}}{m'-\theta'}\mathrm{e}^{-(m'-\theta')^2/2{\alpha' r'}},
\end{align}
and $Q \ll 1$ indeed.
\subsection{\texorpdfstring{$\theta' \lesssim 0.5$}{θ' ≲ 0.5} limit}
For small $\theta'$, we can simplify
\begin{align}
m' &\approx 1 - \frac{1}{\sqrt{2\pi}} \frac{\sqrt{\alpha' r'}}{\theta'}\mathrm{e}^{-\theta'^2/2{\alpha' r'}} - \frac{1}{\sqrt{2\pi}} \frac{\sqrt{\alpha' r'}}{1-\theta'}\mathrm{e}^{-(1-\theta')^2/2{\alpha' r'}} \nonumber\\
r' &\approx \frac{1}{\sqrt{2\pi}} \frac{\sqrt{\alpha' r'}}{\theta'}\mathrm{e}^{-\theta'^2/2{\alpha' r'}} + \frac{a}{2}.
\end{align}
If we take $y \equiv \theta'/\sqrt{\alpha' r'} \gg 1$, the equation for $r'$ becomes
\begin{align}
\frac{\theta'^2}{\alpha'} &= \frac{1}{\sqrt{2\pi}}y\mathrm{e}^{-y^2/2} + \frac{a}{2}y^2.
\end{align}
To maximize $\alpha'$, we want to minimize the right-hand side over $y$:
\begin{align}
0 &= \frac{1}{\sqrt{2\pi}}(1-y^2)\mathrm{e}^{-y^2/2} + ax \nonumber\\
y\mathrm{e}^{-y^2/2} &\approx \sqrt{2\pi}a \nonumber\\
y &= \sqrt{-W_{-1}(-2\pi a^2)} \approx \sqrt{2|\!\log a|},
\end{align}
where $W_{-1}$ is the negative branch of the Lambert $W$ function, which is also known as the product logarithm. Thus
\begin{align}
\frac{\theta'^2}{\alpha'_\textrm{c}} &= a \biggl(1 + \frac{1}{2}y^2\biggr)
\approx a |\!\log a| \nonumber\\
\alpha'_\textrm{c} &\sim \frac{\theta'^2}{a |\!\log a|}.
\end{align}
Then,
\begin{align}
m'_\textrm{c} &\approx 1 - \frac{1}{2\sqrt{\pi|\!\log a|}} \frac{\theta'}{1-\theta'} a^{(1-\theta')^2/\theta'^2}, \nonumber\\
r'_\textrm{c} &= \frac{\theta'^2}{\alpha'_c y^2} = \frac{a}{2}.
\end{align}
\subsection{\texorpdfstring{$\theta' \rightarrow 1$}{θ' → 1} limit}
In this case, we can simplify
\begin{align}
m' &= 1 - \frac{1}{\sqrt{2\pi}} \frac{\sqrt{\alpha' r'}}{m'-\theta'}\mathrm{e}^{-(m'-\theta')^2/2{\alpha' r'}} \nonumber\\
r' &= \frac{a}{2} - \frac{a}{\sqrt{2\pi}} \frac{\sqrt{\alpha' r'}}{m'-\theta'}\mathrm{e}^{-(m'-\theta')^2/2{\alpha' r'}}.
\end{align}
Thus,
\begin{equation}
r' = \frac{a}{2} - a(1-m') \approx \frac{a}{2}.
\end{equation}
Then, with $y \equiv (m'-\theta')/\sqrt{\alpha' r'} \gg 1$,
\begin{align}
m' - \theta' &= 1 - \theta' - \frac{1}{\sqrt{2\pi}y} \mathrm{e}^{-y^2/2} \nonumber\\
\sqrt{\frac{a\alpha'}{2}} &= \frac{1 - \theta'}{y} - \frac{1}{\sqrt{2\pi}y^2} \mathrm{e}^{-y^2/2}.
\end{align}
To maximize $\alpha'$, we want to maximize the right-hand size with respect to $y$:
\begin{align}
0 &= -\frac{1-\theta'}{y^2} + \frac{1}{\sqrt{2\pi}} \biggl(\frac{2}{y^3} + \frac{1}{y}\biggr) \mathrm{e}^{-y^2/2} \nonumber\\
y\mathrm{e}^{-y^2/2} &\approx \sqrt{2\pi}(1-\theta') \nonumber\\
y &\approx \sqrt{-W_{-1}\bigl[-2\pi (1-\theta')^2\bigr]} \approx \sqrt{2|\!\log (1-\theta')|}.
\end{align}
Thus
\begin{align}
\sqrt{\frac{a\alpha'_\textrm{c}}{2}} &= \frac{1-\theta'}{y} - \frac{1-\theta'}{y^3} \nonumber\\
\alpha'_\textrm{c} &\sim \frac{(1-\theta')^2}{a |\!\log (1-\theta')|}.
\end{align}
And
\begin{equation}
m'_\textrm{c} \approx 1 - \frac{1-\theta'}{y^2}
= 1 - \frac{1-\theta'}{2|\!\log (1-\theta')|}.
\end{equation}
\subsection{Maximizing capacity over \texorpdfstring{$\theta'$}{θ'}}
To approximately maximize $\alpha'_\textrm{c}$ over $\theta'$, we find where the following two expressions meet:
\begin{equation}
\alpha'_\textrm{c} \sim
\begin{cases}
\dfrac{\theta'^2}{a |\!\log a|} & \theta' \lesssim 0.5 \\
\dfrac{(1-\theta')^2}{a |\!\log (1-\theta')|} & \theta' \rightarrow 1.
\end{cases}
\end{equation}
We consider that $\theta'$ is sufficiently far from 1 such that $|\!\log (1-\theta')| \sim 1$. Then,
\begin{align}
\frac{\theta'^2}{a |\!\log a|} &\approx \frac{(1-\theta')^2}{a} \nonumber\\
\theta' &= \frac{\sqrt{|\!\log a|}}{1 + \sqrt{|\!\log a|}}.
\end{align}
Thus,
\begin{equation}
\alpha'_\textrm{c} \sim \frac{1}{a |\!\log a|}.
\end{equation}
By converting $\alpha'$ back to $\alpha$ with \cref{eq:A-rescale}, we recover \cref{eq:results-A1}.
\section{\label{sec:de}Capacity for dense examples}
\subsection{Dense asymmetric mean-field equations}
For dense patterns,
\begin{align}
\zeta_{1\nu} &=
\begin{cases} \zeta_1 & \textrm{with probability } \frac{1+c}{2} \\
-\zeta_1 & \textrm{with probability } \frac{1-c}{2} \end{cases} \nonumber\\
\zeta_1 &=
\begin{cases} \gamma & \textrm{with probability } \frac{1}{2} \\
-\gamma & \textrm{with probability } \frac{1}{2}. \end{cases}
\end{align}
To help us in our calculations, we note
\begin{align}
\int_{-\infty}^\infty \mathrm{d} x\,\mathrm{e}^{-(x-a)^2/\rho^2} \mathrm{e}^{-(x-b)^2/\sigma^2} &= \sqrt\frac{\pi}{\rho^{-2}+\sigma^{-2}} \exp\biggl[ -\frac{(a-b)^2}{\rho^2+\sigma^2} \biggr], \nonumber\\
\int_{-\infty}^\infty \mathrm{d} x\,\mathrm{e}^{-(x-a)^2/\rho^2} \mathop{\mathrm{erf}}\nolimits\biggl[ \frac{x-b}{\sigma} \biggr] &= \sqrt\pi \rho \mathop{\mathrm{erf}}\nolimits\biggl[ \frac{a-b}{\sqrt{\rho^2+\sigma^2}} \biggr], \nonumber\\
\int_{-\infty}^\infty \mathrm{d} x\,\mathrm{e}^{-(x-a)^2/\rho^2} x \mathop{\mathrm{erf}}\nolimits\biggl[ \frac{x-b}{\sigma} \biggr] &= \rho\,\Biggl\{ \frac{\rho^2}{\sqrt{\rho^2+\sigma^2}} \exp\biggl[ -\frac{(a-b)^2}{\rho^2+\sigma^2} \biggr] + \sqrt\pi a \mathop{\mathrm{erf}}\nolimits\biggl[ \frac{a-b}{\sqrt{\rho^2+\sigma^2}} \biggr] \Biggr\}.
\end{align}
We first consider the possibility that the network overlaps significantly with one example pattern $\zeta_{11}$. In that case,
\begin{equation}
\sum_\nu m_{1\nu}\zeta_{1\nu} = m_{11}\zeta_{11} + m_0 \sum_{\nu>1} \zeta_{1\nu} = m\zeta + s_0m_0x_0.
\end{equation}
Here, $m \equiv m_{11}$ and $\zeta \equiv \zeta_{11}$. $m_0$ indicates the average overlap with the other $s_0 \equiv s-1$ examples in concept $\mu = 1$. The average over these other examples $x_0$ follows a binomial distribution, which in the large $s$ limit can be described by a Gaussian random variable with mean $c\zeta_1$ and variance $\gamma^2(1-c^2)/s_0$. The concept pattern $\zeta_1$ has a corresponding overlap $m_1$. Thus,
\begin{align}
m &= \frac{1}{2}\Biggl\langle \zeta \mathop{\mathrm{erf}}\nolimits\frac{m\zeta+s_0m_0x_0-\phi}{\sqrt{2{\alpha r}}} \Biggr\rangle, \nonumber\\
m_0 &= \frac{1}{2}\Biggl\langle x_0 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta+s_0m_0x_0-\phi}{\sqrt{2{\alpha r}}} \Biggr\rangle, \nonumber\\
m_1 &= \frac{1}{2}\Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta+s_0m_0x_0-\phi}{\sqrt{2{\alpha r}}} \Biggr\rangle, \nonumber\\
r &= \frac{s\Gamma^4}{2} \cdot \frac{\bigl(1 - Q(1-\kappa^2)(1+s_0\kappa^2)\bigr)^{\!2} + s_0\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s_0\kappa^2)\bigr)^{\!2}} \Biggl[1 + \Biggl\langle \mathop{\mathrm{erf}}\nolimits\frac{m\zeta+s_0m_0x_0-\phi}{\sqrt{2{\alpha r}}} \Biggr\rangle \Biggr], \nonumber\\
Q &= \frac{\Gamma^2}{\sqrt{2\pi{\alpha r}}} \Biggl\langle\exp\Biggl[ -\frac{\bigl(m\zeta+s_0m_0x_0-\phi\bigr)^{\!2}}{2{\alpha r}}\Biggr]\Biggr\rangle.
\end{align}
To aid us later, we will define
\begin{align}
\sigma_0^2 &\equiv s_0\gamma^2(1-c^2)m_0^2 + {\alpha r} \nonumber\\
Y_{\pm\pm} &\equiv \frac{\gamma m \pm s_0\gamma cm_0 \pm \phi}{\sqrt{2}\sigma_0} = \frac{\gamma m \pm s_0\gamma cm_0 \pm \phi}{\sqrt{2\bigl(s_0\gamma^2(1-c^2)m_0^2 + {\alpha r}\bigr)}},
\end{align}
By performing the averages successively over $\zeta$, $x_0$, and $\zeta_1$, we find
\begin{equation}
Q = \frac{\Gamma^2}{\sqrt{2\pi{\alpha r}}} \Biggl\{ \frac{1+c}{2} \Biggl\langle\exp\Biggl[ -\frac{\bigl(m\zeta_1+s_0m_0x_0-\phi\bigr)^{\!2}}{2{\alpha r}}\Biggr]\Biggr\rangle + \frac{1-c}{2} \Biggl\langle\exp\Biggl[ -\frac{\bigl(m\zeta_1-s_0m_0x_0+\phi\bigr)^{\!2}}{2{\alpha r}}\Biggr]\Biggr\rangle \Biggr\}.
\end{equation}
Then,
\begin{align}
&\frac{1}{\sqrt{2\pi{\alpha r}}} \Biggl\langle\exp\Biggl[ -\frac{\bigl(m\zeta_1+s_0m_0 x_0-\phi\bigr)^{\!2}}{2{\alpha r}}\Biggr]\Biggr\rangle \nonumber\\
&\qquad= \frac{1}{\sqrt{2\pi{\alpha r}}} \sqrt\frac{s_0}{2\pi\gamma^2(1-c^2)} \Biggl\langle \int\mathrm{d} x_0\,\mathrm{e}^{-s_0(x_0-c\zeta_1)^2/2\gamma^2(1-c^2)} \mathrm{e}^{-s_0^2m_0^2(x_0+(m\zeta_1-\phi)/s_0m_0)^2/2{\alpha r}} \Biggr\rangle \nonumber\\
&\qquad= \frac{1}{\sqrt{2\pi\bigl(s_0\gamma^2(1-c^2)m_0^2 + {\alpha r}\bigr)}} \Biggl\langle \exp\Biggl[-\frac{(m\zeta_1+s_0cm_0\zeta_1-\phi)^2}{2\bigl(s_0\gamma^2(1-c^2)m_0^2 + {\alpha r}\bigr)}\Biggr] \Biggr\rangle \nonumber\\
&\qquad= \frac{1}{\sqrt{2\pi}\sigma_0}\cdot\frac{1}{2} \biggl\{ \mathrm{e}^{-Y_{++}^2}+\mathrm{e}^{-Y_{+-}^2} \biggr\}.
\end{align}
Thus,
\begin{equation}
Q = \frac{\Gamma^2}{\sqrt{2\pi}\sigma_0} \biggl\{ \frac{1+c}{4} \Bigl[\mathrm{e}^{-Y_{++}^2}+\mathrm{e}^{-Y_{+-}^2}\Bigr] + \frac{1-c}{4} \Bigl[\mathrm{e}^{-Y_{-+}^2}+\mathrm{e}^{-Y_{--}^2}\Bigr] \biggr\}.
\end{equation}
Next,
\begin{equation}
\Biggl\langle \mathop{\mathrm{erf}}\nolimits\frac{m\zeta+s_0m_0x_0-\phi}{\sqrt{2{\alpha r}}} \Biggr\rangle = \Biggl\{ \frac{1+c}{2} \Biggl\langle\mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1+s_0m_0x_0-\phi}{2{\alpha r}}\Biggr\rangle - \frac{1-c}{2} \Biggl\langle\mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1-s_0m_0x_0+\phi}{2{\alpha r}}\Biggr\rangle \Biggr\}.
\end{equation}
Then,
\begin{align}
&\Biggl\langle\mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1+s_0m_0x_0-\phi}{2{\alpha r}}\Biggr\rangle \nonumber\\
&\qquad= \sqrt\frac{s_0}{2\pi\gamma^2(1-c^2)} \Biggl\langle \int\mathrm{d} x_0\,\mathrm{e}^{-s_0(x_0 - c\zeta_1)^2/2\gamma^2(1-c^2)} \mathop{\mathrm{erf}}\nolimits\Biggl[\frac{s_0m_0}{\sqrt{2{\alpha r}}} \biggl(x_0+\frac{m\zeta_1-\phi}{s_0m_0}\biggr)\Biggr] \Biggr\rangle \nonumber\\
&\qquad= \Biggl\langle \mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1+s_0cm_0\zeta_1-\phi}{\sqrt{2\bigl(s_0\gamma^2(1-c^2)m_0^2 + {\alpha r}\bigr)}} \Biggr\rangle \nonumber\\
&\qquad= -\frac{1}{2} \biggl\{ \mathop{\mathrm{erf}}\nolimits Y_{++}-\mathop{\mathrm{erf}}\nolimits Y_{+-} \biggr\}.
\end{align}
Thus,
\begin{equation}
r = \frac{s\Gamma^4}{2} \cdot \frac{\bigl(1 - Q(1-\kappa^2)(1+s_0\kappa^2)\bigr)^{\!2} + s_0\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s_0\kappa^2)\bigr)^{\!2}} \biggl\{1 - \frac{1+c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{++}-\mathop{\mathrm{erf}}\nolimits Y_{+-}\Bigr] - \frac{1-c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{-+}-\mathop{\mathrm{erf}}\nolimits Y_{--}\Bigr] \biggr\}
\end{equation}
Next,
\begin{equation}
m = \frac{1}{2} \Biggl\{ \frac{1+c}{2} \Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1+s_0m_0x_0-\phi}{2{\alpha r}}\Biggr\rangle + \frac{1-c}{2} \Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1-s_0m_0x_0+\phi}{2{\alpha r}}\Biggr\rangle \Biggr\}.
\end{equation}
Then,
\begin{align}
&\Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1+s_0m_0x_0-\phi}{2{\alpha r}}\Biggr\rangle \nonumber\\
&\qquad= \sqrt\frac{s_0}{2\pi\gamma^2(1-c^2)} \Biggl\langle \zeta_1 \int\mathrm{d} x_0\,\mathrm{e}^{-s_0(x_0 - c\zeta_1)^2/2\gamma^2(1-c^2)} \mathop{\mathrm{erf}}\nolimits\Biggl[\frac{s_0m_0}{\sqrt{2{\alpha r}}} \biggl(x_0+\frac{m\zeta_1-\phi}{s_0m_0}\biggr)\Biggr] \Biggr\rangle \nonumber\\
&\qquad= \Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1+s_0cm_0\zeta_1-\phi}{\sqrt{2\bigl(s_0\gamma^2(1-c^2)m_0^2 + {\alpha r}\bigr)}} \Biggr\rangle \nonumber\\
&\qquad= \frac{\gamma}{2} \biggl\{ \mathop{\mathrm{erf}}\nolimits Y_{++}+\mathop{\mathrm{erf}}\nolimits Y_{+-} \biggr\}.
\end{align}
Thus,
\begin{equation}
m = \frac{\gamma}{2} \biggl\{\frac{1+c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{++}+\mathop{\mathrm{erf}}\nolimits Y_{+-}\Bigr] + \frac{1-c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{-+}+\mathop{\mathrm{erf}}\nolimits Y_{--}\Bigr] \biggr\}.
\end{equation}
Similarly,
\begin{align}
m_1 &= \frac{1}{2} \Biggl\{ \frac{1+c}{2} \Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1+s_0m_0x_0-\phi}{2{\alpha r}}\Biggr\rangle - \frac{1-c}{2} \Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1-s_0m_0x_0+\phi}{2{\alpha r}}\Biggr\rangle \Biggr\} \nonumber\\
&= \frac{\gamma}{2} \biggl\{\frac{1+c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{++}+\mathop{\mathrm{erf}}\nolimits Y_{+-}\Bigr] - \frac{1-c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{-+}+\mathop{\mathrm{erf}}\nolimits Y_{--}\Bigr] \biggr\}.
\end{align}
Finally,
\begin{equation}
m_0 = \frac{1}{2} \Biggl\{ \frac{1+c}{2} \Biggl\langle x_0 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1+s_0m_0x_0-\phi}{2{\alpha r}}\Biggr\rangle - \frac{1-c}{2} \Biggl\langle x_0 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1-s_0m_0x_0+\phi}{2{\alpha r}}\Biggr\rangle \Biggr\}.
\end{equation}
Then,
\begin{alignat}{2}
&\mathrlap{ \Biggl\langle x_0 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1+s_0m_0x_0-\phi}{\sqrt{2{\alpha r}}}\Biggr\rangle }\nonumber\\
&\qquad={}&& \mathrlap{ \sqrt\frac{s_0}{2\pi\gamma^2(1-c^2)} \Biggl\langle \int\mathrm{d} x_0\,\mathrm{e}^{-s_0(x_0-c\zeta_1)^2/2\gamma^2(1-c^2)} x_0 \mathop{\mathrm{erf}}\nolimits\Biggl[\frac{s_0m_0}{\sqrt{2{\alpha r}}} \biggl(x_0+\frac{m\zeta_1-\phi}{s_0m_0}\biggr)\Biggr] \Biggr\rangle }\nonumber\\
&\qquad={}&& \gamma^2(1-c^2)m_0 \sqrt\frac{2}{\pi\bigl(s_0\gamma^2(1-c^2)m_0^2 + {\alpha r}\bigr)} \Biggl\langle \exp\Biggl[-\frac{(m\zeta_1+s_0cm_0\zeta_1-\phi)^2}{2\bigl(s_0\gamma^2(1-c^2)m_0^2 + {\alpha r}\bigr)}\Biggr] \Biggr\rangle \nonumber\\*
&&&{}+ c \Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{m\zeta_1+s_0cm_0\zeta_1-\phi}{\sqrt{2\bigl(s_0\gamma^2(1-c^2)m_0^2 + {\alpha r}\bigr)}} \Biggr\rangle \nonumber\\
&\qquad={}&& \mathrlap{ \frac{\gamma^2(1-c^2)m_0}{\sqrt{2\pi}\sigma_0} \biggl\{ \mathrm{e}^{-Y_{++}^2}+\mathrm{e}^{-Y_{+-}^2} \biggr\} + \frac{\gamma c}{2} \biggl\{ \mathop{\mathrm{erf}}\nolimits Y_{++}+\mathop{\mathrm{erf}}\nolimits Y_{+-} \biggr\}. }
\end{alignat}
Thus,
\begin{align}
m_0 &= \frac{\gamma c}{2} \biggl\{ \frac{1+c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{++}+\mathop{\mathrm{erf}}\nolimits Y_{+-}\Bigr] - \frac{1-c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{-+}+\mathop{\mathrm{erf}}\nolimits Y_{--}\Bigr] \biggr\} + Q\tfrac{\gamma^2}{\Gamma^2}(1-c^2)m_0 \nonumber\\
&= \frac{\gamma c}{2\Bigl(1-Q\frac{\gamma^2}{\Gamma^2}(1-c^2)\Bigr)} \biggl\{ \frac{1+c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{++}+\mathop{\mathrm{erf}}\nolimits Y_{+-}\Bigr] - \frac{1-c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{-+}+\mathop{\mathrm{erf}}\nolimits Y_{--}\Bigr] \biggr\}.
\end{align}
These mean-field equations are presented in \cref{eq:overview-0}.
\subsection{Simplified mean-field equations with \texorpdfstring{$\phi = 0$}{φ = 0} and \texorpdfstring{$c^2 \ll 1$}{c² ≪ 1}}
To further simplify the equations, we make two assumptions. First, we assume $c^2 \ll 1$, and correspondingly $\kappa^2 \ll 1$ because $\kappa \leq c$. Second, we assume that $\phi = 0$. Numerically, we find that the maximum load of sparse examples that still admits a retrieval solution is indeed obtained at $|\phi| < 10^{-6}$ over the entire range in \cref{fig:0}. Theoretically, we will see that $Q \ll 1$, which means $\phi = \theta$, the true threshold of the network. For dense patterns in classic Hopfield network, retrieval is maximized at $\theta = 0$ \cite{Weisbuch.1985}. We also assume $s \gg 1$, so $s_0 = s$, and perform the rescalings
\begin{align}
m &= \frac{\gamma}{2} \cdot m', \nonumber\\
m_0 &= \frac{\gamma}{2} \cdot m'_0, \nonumber\\
r &= \frac{s\Gamma^4}{2} \cdot r', \nonumber\\
\alpha &= \frac{\gamma^4}{2\Gamma^4} \cdot \alpha'.
\label{eq:0-rescale}
\end{align}
The mean-field equations then become
\begin{align}
m' &= \frac{1+c}{2} \mathop{\mathrm{erf}}\nolimits Y'_+ + \frac{1-c}{2} \mathop{\mathrm{erf}}\nolimits Y'_-, \nonumber\\
m'_0 &= \frac{c}{1-Q\frac{\gamma^2}{\Gamma^2}} \biggl\{ \frac{1+c}{2} \mathop{\mathrm{erf}}\nolimits Y'_+ - \frac{1-c}{2} \mathop{\mathrm{erf}}\nolimits Y'_- \biggr\}, \nonumber\\
r' &= \frac{1}{(1 - Q)^2}, \nonumber\\
Q &= \sqrt\frac{2}{\pi} \frac{\Gamma^2}{\sigma'_0\gamma^2} \biggl\{ \frac{1+c}{2} \mathrm{e}^{-(Y'_+)^2} + \frac{1-c}{2} \mathrm{e}^{-(Y'_-)^2} \biggr\},
\end{align}
where
\begin{align}
{\sigma_0'}^{\!2} &\equiv s\bigl({m'_0}^{\!2} + {\alpha' r'}\bigr) \nonumber\\
Y'_\pm &\equiv \frac{m'}{\sqrt{2}\sigma'_0} \biggl(1 \pm \frac{scm'_0}{m'}\biggr).
\end{align}
If we desire $m' \approx 1$, which corresponds to retrieval of the dense example, we need $Y'_\pm \gg 1$. This means that $m'_0 \approx c^2$, if $Q \ll 1$. So, we replace $m'_0/m'$ by $c^2$ in $Y'_\pm$. We also define
\begin{equation}
y \equiv \frac{m'}{\sigma'_0}.
\end{equation}
Furthermore, for $m' \approx 1$, we need $sc^3$ to be small, so we expand in it. We also need $y \rightarrow \infty$, so we can expand asymptotically $\erf\frac{y}{\sqrt{2}} \approx 1 - \sqrt{\tfrac{2}{\pi}}\tfrac{1}{y}\ee^{-y^2/2}$. These simplifications yield
\begin{align}
m' &= 1 - \frac{1}{y^2}\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy, \nonumber\\
m'_0 &= \frac{c^2}{1-Q\frac{\gamma^2}{\Gamma^2}} \Biggl\{ 1 - \biggl(\frac{1}{y^2}-sc^2\biggr) \sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy \Biggr\}, \nonumber\\
\alpha' &= \biggl(\frac{{m'}^2}{sy^2} - {m'_0}^{\!2}\biggr) (1 - Q)^2, \nonumber\\
Q &= \frac{\Gamma^2}{\gamma^2m'} \biggl(1 - sc^4y^2 + \frac{1}{2}s^2c^6y^2(y^2-1)\biggr) \sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy.
\label{eq:0-simple}
\end{align}
\subsection{Capacity formula}
In \cref{eq:0-simple}, we substitute formulas for $m'$, $m'_0$, and $Q$ into the equation for $\alpha'$ and keep only leading terms in $1/y$ and $c$. After much simplification, we obtain
\begin{equation}
s(\alpha' + c^4) = \frac{1}{y^2} - \frac{\Gamma^2}{\gamma^2} \biggl(\frac{1}{y} + \frac{1}{2}s^2c^6y^3\biggr) \sqrt\frac{8}{\pi} \ee^{-y^2/2}.
\label{eq:0-y}
\end{equation}
Now, we make major simplifications for mathematical tractability. They are justified by comparing the resulting formula with numerical analysis of the full mean-field equations [\cref{fig:0}]. At the critical value of $s$ above which this equation cannot be satisfied by any $y$, the derivative of \cref{eq:0-y} with respect to $y$ must also hold. We ignore the term proportional to $s^2$ and eliminate higher orders in $1/y$ to obtain
\begin{equation}
0 = -\frac{2}{y^3} + \frac{\Gamma^2}{\gamma^2} \sqrt\frac{8}{\pi} \ee^{-y^2/2}
\label{eq:0-dy}
\end{equation}
Solving for $y$, we obtain
\begin{equation}
y = \sqrt{-3 W_{-1}\Bigl[-\tfrac{1}{3} \bigl(\tfrac{\pi}{2}\bigr)^{\!1/3} \bigl(\tfrac{\gamma}{\Gamma}\bigr)^{\!4/3} \Bigr]} \approx \sqrt{3 \log \Bigl[3\bigl(\tfrac{2}{\pi}\bigr)^{\!1/3} \bigl(\tfrac{\Gamma}{\gamma}\bigr)^{\!4/3} \Bigr]},
\end{equation}
where $W_{-1}$ is the negative branch of the Lambert $W$ function, which is also known as the product logarithm. Since this function involves a logarithm, it varies very slowly as a function of $\gamma/\Gamma$. For $\gamma = 0.1$ and $a$ between $0.001$ and $0.1$, this expression for $y$ ranges from $1.7$ and $3.3$.
We can use \cref{eq:0-dy} to simplify \cref{eq:0-y} and solve for the critical $s$:
\begin{equation}
s_\textrm{c}(\alpha' + c^4) = \frac{1}{y^2} - s_\textrm{c}^2c^6.
\end{equation}
This gives
\begin{equation}
s_\textrm{c} = \frac{\sqrt{(\alpha'+c^4)^2 + \frac{4}{y^2} c^6} - (\alpha'+c^4)}{2c^6}.
\end{equation}
To heuristically obtain a simpler equation, we note that $s_\textrm{c} \rightarrow 1/yc^3$ when $\alpha' \rightarrow 0$ and $s_\textrm{c} \rightarrow 1/y^2\alpha'$ when $\alpha' \rightarrow \infty$. We simply capture both these behaviors with
\begin{equation}
s_\textrm{c} = \frac{1}{yc^3 + y^2 \alpha'}.
\end{equation}
If we set $y = 3$ and convert $\alpha'$ back to $\alpha$ with \cref{eq:0-rescale}, we obtain \cref{eq:results-0}.
\section{\label{sec:dc}Critical load for dense concepts}
\subsection{Dense symmetric mean-field equations}
For dense patterns,
\begin{align}
\zeta_{1\nu} &=
\begin{cases} \zeta_1 & \textrm{with probability } \frac{1+c}{2} \\
-\zeta_1 & \textrm{with probability } \frac{1-c}{2} \end{cases} \nonumber\\
\zeta_1 &=
\begin{cases} \gamma & \textrm{with probability } \frac{1}{2} \\
-\gamma & \textrm{with probability } \frac{1}{2}. \end{cases}
\end{align}
To help us in our calculations, we note
\begin{align}
\int_{-\infty}^\infty \mathrm{d} x\,\mathrm{e}^{-(x-a)^2/\rho^2} \mathrm{e}^{-(x-b)^2/\sigma^2} &= \sqrt\frac{\pi}{\rho^{-2}+\sigma^{-2}} \exp\biggl[ -\frac{(a-b)^2}{\rho^2+\sigma^2} \biggr], \nonumber\\
\int_{-\infty}^\infty \mathrm{d} x\,\mathrm{e}^{-(x-a)^2/\rho^2} \mathop{\mathrm{erf}}\nolimits\biggl[ \frac{x-b}{\sigma} \biggr] &= \sqrt\pi \rho \mathop{\mathrm{erf}}\nolimits\biggl[ \frac{a-b}{\sqrt{\rho^2+\sigma^2}} \biggr], \nonumber\\
\int_{-\infty}^\infty \mathrm{d} x\,\mathrm{e}^{-(x-a)^2/\rho^2} x \mathop{\mathrm{erf}}\nolimits\biggl[ \frac{x-b}{\sigma} \biggr] &= \rho\,\Biggl\{ \frac{\rho^2}{\sqrt{\rho^2+\sigma^2}} \exp\biggl[ -\frac{(a-b)^2}{\rho^2+\sigma^2} \biggr] + \sqrt\pi a \mathop{\mathrm{erf}}\nolimits\biggl[ \frac{a-b}{\sqrt{\rho^2+\sigma^2}} \biggr] \Biggr\}.
\end{align}
We then consider the possibility that the network overlaps equally with all example patterns $\zeta_{1\nu}$. In that case,
\begin{equation}
\sum_\nu m_{1\nu}\zeta_{1\nu} = sm_\textrm{s} x_\textrm{s}.
\end{equation}
The average over examples $ x_\textrm{s}$ follows a binomial distribution, which in the large $s$ limit can be described by a Gaussian random variable with mean $c\zeta_1$ and variance $\gamma^2(1-c^2)/s$. Thus,
\begin{align}
m_\textrm{s} &= \frac{1}{2}\Biggl\langle x_\textrm{s} \mathop{\mathrm{erf}}\nolimits\frac{sm_\textrm{s} x_\textrm{s}-\phi}{\sqrt{2{\alpha r}}}\Biggr\rangle, \nonumber\\
m_1 &= \frac{1}{2}\Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{sm_\textrm{s} x_\textrm{s}-\phi}{\sqrt{2{\alpha r}}}\Biggr\rangle, \nonumber\\
r &= \frac{s\Gamma^4}{2} \cdot \frac{\bigl(1 - Q(1-\kappa^2)(1+s_0\kappa^2)\bigr)^{\!2} + s_0\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s_0\kappa^2)\bigr)^{\!2}} \Biggl[1 + \Biggl\langle \mathop{\mathrm{erf}}\nolimits\frac{sm_\textrm{s} x_\textrm{s}-\phi}{\sqrt{2{\alpha r}}} \Biggr\rangle \Biggr], \nonumber\\
Q &= \frac{\Gamma^2}{\sqrt{2\pi{\alpha r}}} \Biggl\langle\exp\Biggl[ -\frac{\bigl(sm_\textrm{s} x_\textrm{s}-\phi\bigr)^{\!2}}{2{\alpha r}}\Biggr]\Biggr\rangle.
\end{align}
To aid us later, we will define
\begin{align}
\sigma_\textrm{s}^2 &\equiv s\gamma^2(1-c^2)m_\textrm{s}^2 + {\alpha r} \nonumber\\
Y_\pm &\equiv \frac{s\gamma cm_\textrm{s} \pm \phi}{\sqrt{2}\sigma_\textrm{s}} = \frac{s\gamma cm_\textrm{s} \pm \phi}{\sqrt{2\bigl(s\gamma^2(1-c^2)m_\textrm{s}^2 + {\alpha r}\bigr)}},
\end{align}
By performing the averages successively over $ x_\textrm{s}$ and $\zeta_1$, we find
\begin{align}
Q &= \frac{\Gamma^2}{\sqrt{2\pi{\alpha r}}} \Biggl\langle\exp\Biggl[ -\frac{\bigl(sm_\textrm{s} x_\textrm{s}-\phi\bigr)^{\!2}}{2{\alpha r}}\Biggr]\Biggr\rangle \nonumber\\
&= \frac{\Gamma^2}{\sqrt{2\pi{\alpha r}}} \sqrt\frac{s}{2\pi\gamma^2(1-c^2)} \Biggl\langle \int\mathrm{d} x_\textrm{s}\,\mathrm{e}^{-s( x_\textrm{s}-c\zeta_1)^2/2\gamma^2(1-c^2)} \mathrm{e}^{-s^2m_\textrm{s}^2( x_\textrm{s}-\phi/sm_\textrm{s})^2/2{\alpha r}} \Biggr\rangle \nonumber\\
&= \frac{\Gamma^2}{\sqrt{2\pi\bigl(s\gamma^2(1-c^2)m_\textrm{s}^2 + {\alpha r}\bigr)}} \Biggl\langle \exp\Biggl[-\frac{(scm_\textrm{s}\zeta_1-\phi)^2}{2\bigl(s\gamma^2(1-c^2)m_\textrm{s}^2 + {\alpha r}\bigr)}\Biggr] \Biggr\rangle \nonumber\\
&= \frac{\Gamma^2}{\sqrt{8\pi}\sigma_\textrm{s}} \biggl\{ \mathrm{e}^{-Y_+^2}+\mathrm{e}^{-Y_-^2} \biggr\}.
\end{align}
Next,
\begin{align}
&\Biggl\langle \mathop{\mathrm{erf}}\nolimits\frac{sm_\textrm{s} x_\textrm{s}-\phi}{\sqrt{2{\alpha r}}} \Biggr\rangle \nonumber\\
&\qquad= \sqrt\frac{s}{2\pi\gamma^2(1-c^2)} \Biggl\langle \int\mathrm{d} x_\textrm{s}\,\mathrm{e}^{-s( x_\textrm{s} - c\zeta_1)^2/2\gamma^2(1-c^2)} \mathop{\mathrm{erf}}\nolimits\Biggl[\frac{sm_\textrm{s}}{\sqrt{2{\alpha r}}} \biggl( x_\textrm{s}-\frac{\phi}{sm_\textrm{s}}\biggr)\Biggr] \Biggr\rangle \nonumber\\
&\qquad= \Biggl\langle \mathop{\mathrm{erf}}\nolimits\frac{scm_\textrm{s}\zeta_1-\phi}{\sqrt{2\bigl(s\gamma^2(1-c^2)m_\textrm{s}^2 + {\alpha r}\bigr)}} \Biggr\rangle \nonumber\\
&\qquad= -\frac{1}{2} \biggl\{ \mathop{\mathrm{erf}}\nolimits Y_+-\mathop{\mathrm{erf}}\nolimits Y_- \biggr\}.
\end{align}
Thus,
\begin{equation}
r = \frac{s\Gamma^4}{2} \cdot \frac{\bigl(1 - Q(1-\kappa^2)(1+s_0\kappa^2)\bigr)^{\!2} + s_0\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s_0\kappa^2)\bigr)^{\!2}} \biggl\{ 1 - \frac{1}{2} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_+-\mathop{\mathrm{erf}}\nolimits Y_-\Bigr] \biggr\}.
\end{equation}
Next,
\begin{align}
m_1 &= \frac{1}{2} \Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{sm_\textrm{s} x_\textrm{s}-\phi}{2{\alpha r}}\Biggr\rangle \nonumber\\
&= \frac{1}{2}\sqrt\frac{s}{2\pi\gamma^2(1-c^2)} \Biggl\langle \zeta_1 \int\mathrm{d} x_\textrm{s}\,\mathrm{e}^{-s( x_\textrm{s} - c\zeta_1)^2/2\gamma^2(1-c^2)} \mathop{\mathrm{erf}}\nolimits\Biggl[\frac{sm_\textrm{s}}{\sqrt{2{\alpha r}}} \biggl( x_\textrm{s}-\frac{\phi}{sm_\textrm{s}}\biggr)\Biggr] \Biggr\rangle \nonumber\\
&= \frac{1}{2}\Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{scm_\textrm{s}\zeta_1-\phi}{\sqrt{2\bigl(s\gamma^2(1-c^2)m_\textrm{s}^2 + {\alpha r}\bigr)}} \Biggr\rangle \nonumber\\
&= \frac{\gamma}{4} \biggl\{ \mathop{\mathrm{erf}}\nolimits Y_++\mathop{\mathrm{erf}}\nolimits Y_- \biggr\}.
\end{align}
Finally,
\begin{alignat}{2}
m_\textrm{s} &={}&& \frac{1}{2} \Biggl\langle x_\textrm{s} \mathop{\mathrm{erf}}\nolimits\frac{sm_\textrm{s} x_\textrm{s}-\phi}{2{\alpha r}}\Biggr\rangle \nonumber\\
&={}&& \frac{1}{2} \sqrt\frac{s}{2\pi\gamma^2(1-c^2)} \Biggl\langle \int\mathrm{d} x_\textrm{s}\,\mathrm{e}^{-s( x_\textrm{s}-c\zeta_1)^2/2\gamma^2(1-c^2)} x_\textrm{s} \mathop{\mathrm{erf}}\nolimits\Biggl[\frac{sm_\textrm{s}}{\sqrt{2{\alpha r}}} \biggl( x_\textrm{s}-\frac{\phi}{sm_\textrm{s}}\biggr)\Biggr] \Biggr\rangle \nonumber\\
&={}&& \frac{\gamma^2(1-c^2)m_\textrm{s}}{2} \sqrt\frac{2}{\pi\bigl(s\gamma^2(1-c^2)m_\textrm{s}^2 + {\alpha r}\bigr)} \Biggl\langle \exp\Biggl[-\frac{(scm_\textrm{s}\zeta_1-\phi)^2}{2\bigl(s\gamma^2(1-c^2)m_\textrm{s}^2 + {\alpha r}\bigr)}\Biggr] \Biggr\rangle \nonumber\\*
&&&{}+ \frac{c}{2} \Biggl\langle \zeta_1 \mathop{\mathrm{erf}}\nolimits\frac{scm_\textrm{s}\zeta_1-\phi}{\sqrt{2\bigl(s\gamma^2(1-c^2)m_\textrm{s}^2 + {\alpha r}\bigr)}} \Biggr\rangle \nonumber\\
&={}&& Q\tfrac{\gamma^2}{\Gamma^2}(1-c^2)m_\textrm{s} + \frac{\gamma c}{4} \biggl\{ \mathop{\mathrm{erf}}\nolimits Y_++\mathop{\mathrm{erf}}\nolimits Y_- \biggr\} \nonumber\\
&={}&& \frac{\gamma c}{4\Bigl(1-Q\frac{\gamma^2}{\Gamma^2}(1-c^2)\Bigr)} \biggl\{ \mathop{\mathrm{erf}}\nolimits Y_++\mathop{\mathrm{erf}}\nolimits Y_- \biggr\}.
\end{alignat}
These mean-field equations are presented in \cref{eq:overview-S}.
\subsection{Simplified mean-field equations with \texorpdfstring{$\phi = 0$}{φ = 0} and \texorpdfstring{$c^2 \ll 1$}{c² ≪ 1}}
To further simplify the equations, we make two assumptions. First, we assume $c^2 \ll 1$, and correspondingly $\kappa^2 \ll 1$ because $\kappa \leq c$. Second, we assume that $\phi = 0$. Empirically, as shown in \cref{fig:S-extra}(a), we find that the capacity obtained with $\phi = 0$ is very close to that obtained by maximizing over $\phi$.
\begin{figure*}[h!]
\centering
\includegraphics{S-extra}
\caption{
\label{fig:S-extra}
(a) Capacity $s_\textrm{c}$ for dense concepts obtained through numerical analysis of \cref{eq:overview-S}. We either set $\phi = 0$ (dark, thin lines) or maximize over $\phi$ (light, thick lines).
(b) Right-hand side of \cref{eq:S-y} and its terms plotted separately.
(c) $y$ as a function of $\alpha$ for sparsity $a = 0$ obtained by numerically solving \cref{eq:Sa-alpha}.
}
\end{figure*}
We also assume $s \gg 1$, so $s_0 = s$, and perform the rescalings
\begin{align}
m_\textrm{s} &= \frac{\gamma c}{2} \cdot m'_\textrm{s}, \nonumber\\
r &= \frac{s\Gamma^4}{2} \cdot m'_\textrm{s} r', \nonumber\\
\alpha &= \frac{\gamma^4c^2}{2\Gamma^4} \cdot \alpha'.
\label{eq:S-rescale}
\end{align}
The mean-field equations then become
\begin{align}
m'_\textrm{s} - Qm'_\textrm{s} \frac{\gamma^2}{\Gamma^2} &= \mathop{\mathrm{erf}}\nolimits\sqrt\frac{sc^2}{2(1+{\alpha' r'})}, \nonumber\\
r' &= \frac{\bigl(m'_\textrm{s} - Qm'_\textrm{s}(1+s\kappa^2)\bigr)^{\!2} + (m'_\textrm{s})^2s\kappa^4}{\bigl(m'_\textrm{s} - Qm'_\textrm{s}\bigr)^{\!2}\bigl(m'_\textrm{s} - Qm'_\textrm{s}(1+s\kappa^2)\bigr)^{\!2}}, \nonumber\\
Qm'_\textrm{s} &= \frac{\Gamma^2}{\gamma^2} \sqrt\frac{2}{\pi sc^2(1+{\alpha' r'})} \exp\biggl[-\frac{sc^2}{2(1+{\alpha' r'})}\biggr].
\end{align}
We define
\begin{equation}
y \equiv \sqrt\frac{sc^2}{1+{\alpha' r'}},
\end{equation}
so the equations are now
\begin{align}
m'_\textrm{s} - Qm'_\textrm{s} \frac{\gamma^2}{\Gamma^2} &= \erf\frac{y}{\sqrt{2}}, \nonumber\\
\frac{1}{\alpha'}\biggl(\frac{sc^2}{y^2} - 1\biggr) &= \frac{\bigl(m'_\textrm{s} - Qm'_\textrm{s}(1+s\kappa^2)\bigr)^{\!2} + (m'_\textrm{s})^2s\kappa^4}{\bigl(m'_\textrm{s} - Qm'_\textrm{s}\bigr)^{\!2}\bigl(m'_\textrm{s} - Qm'_\textrm{s}(1+s\kappa^2)\bigr)^{\!2}}, \nonumber\\
Qm'_\textrm{s} &= \frac{\Gamma^2}{\gamma^2sc^2}\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy.
\label{eq:S-simple}
\end{align}
We can now substitute expressions for $m'_\textrm{s}$ and $Qm'_\textrm{s}$ into the second equation of \cref{eq:S-simple} to obtain a single equation
\begin{equation}
0 = \frac{1}{\alpha'}\biggl(\frac{sc^2}{y^2}-1\biggr) \biggl[{\textstyle\erf\frac{y}{\sqrt{2}}}-\frac{(1-2\gamma)^2a}{\gamma^2sc^2}{\textstyle\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy}\biggr]^2 - 1 - s\kappa^4 \frac{\biggl[\erf\frac{y}{\sqrt{2}}+\frac{1}{sc^2}\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\biggr]^2}{\biggl[\erf\frac{y}{\sqrt{2}}-\Bigl(\frac{(1-2\gamma)^2a}{\gamma^2sc^2} + 1\Bigr)\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\biggr]^2}.
\label{eq:S-y}
\end{equation}
The capacity $s_\textrm{c}$ is obtained when this equation and its derivative with respect to $y$ are satisfied.
\subsection{Capacity formula for \texorpdfstring{$a \gtrsim \gamma^2$}{a ≳ γ²}}
We now perform major simplifications to obtain a formula for $s_\textrm{s}$. In \cref{fig:S-extra}(b), we plot the right-hand side (RHS) of \cref{eq:S-y}, along with its first two terms and third term separately. We see that the first two terms generally capture the behavior of the RHS. The third term contributes a pole, which approximately sets the position of the local maximum of the RHS at largest $y$.
Thus, we use the first two terms to satisfy \cref{eq:S-y} and the denominator of the third term to statisfy the derivative of the equation:
\begin{align}
\alpha' &= \biggl(\frac{sc^2}{y^2}-1\biggr) \biggl[\erf\frac{y}{\sqrt{2}}-\frac{(1-2\gamma)^2a}{\gamma^2sc^2}\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\biggr]^2 \nonumber\\
0 &= \erf\frac{y}{\sqrt{2}} - \biggl(\frac{(1-2\gamma)^2a}{\gamma^2sc^2} + 1\biggr)\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy.
\end{align}
We can manipulate these equations to obtain \cref{eq:results-S1} if we convert $\alpha'$ back to $\alpha$ with \cref{eq:S-rescale}.
\subsection{Capacity formula for \texorpdfstring{$a \ll \gamma^2$}{a ≪ γ}}
For $a \rightarrow 0$, the location of the pole in \cref{eq:S-y} approaches $y = 0$. This does not correspond to a retrieval solution according to \cref{eq:S-simple} because $m'_\textrm{s} \sim 1$ requires $y \gtrsim 1$. To obtain a capacity formula in this case, we set $a = 0$ and rearrange \cref{eq:S-y} to obtain
\begin{equation}
0 = \frac{1}{\alpha'}\biggl(\frac{sc^2}{y^2}-1\biggr)\biggl[\erf\frac{y}{\sqrt{2}}\biggr]^2 \biggl[\erf\frac{y}{\sqrt{2}}-\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\biggr]^2 - \biggl[\erf\frac{y}{\sqrt{2}}-\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\biggr]^2 - sc^4 \biggl[\erf\frac{y}{\sqrt{2}} + \frac{1}{sc^2}\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\biggr]^2.
\end{equation}
We then calculate its derivative with respect to $y$, which also holds when the network is at capacity, and manipulate these two equations to obtain
\begin{align}
\alpha' &= \frac{\Bigl(\frac{sc^2}{y^2}-1\Bigr) \bigl[\erf\frac{y}{\sqrt{2}}\bigr]^2 \Bigr[\erf\frac{y}{\sqrt{2}}-\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\Bigr]^2}{\Bigr[\erf\frac{y}{\sqrt{2}}-\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\Bigr]^2 + sc^4 \Bigl[\erf\frac{y}{\sqrt{2}} + \frac{1}{sc^2}\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\Bigr]^2} \nonumber\\
\alpha'c^2 &= \frac{\erf\frac{y}{\sqrt{2}} \biggl\{\frac{sc^2}{y^2}\Bigr[\erf\frac{y}{\sqrt{2}}-\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\Bigr] + \sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\biggr\} \Bigr[\erf\frac{y}{\sqrt{2}}-\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\Bigr]^3}{(sc^2+1)\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy \Bigl[\erf\frac{y}{\sqrt{2}} + \frac{1}{sc^2}\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\Bigr] \Bigl[(y^2-1)\erf\frac{y}{\sqrt{2}} + \sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\Bigr]}.
\label{eq:Sa-alpha}
\end{align}
\Cref{eq:Sa-alpha} can be solved numerically to obtain $y$ as a function of $\alpha'c^2/2 = \alpha$ by eliminating $s$. We notice that for small $\alpha \sim 10^{-4}$, $y \sim 0.5$ [\cref{fig:S-extra}(c)]. To then find a formula for $s_\textrm{c}$, we boldly expand \cref{eq:Sa-alpha} in leading powers of $y$, but we preserve extra powers of $c^4$:
\begin{align}
\alpha' &\approx \frac{2sc^2y^4 \bigl(3sc^2 - (3+sc^2)y^2\bigr)}{3\pi\bigl(sc^2y^4 + 9c^2(1+sc^2)^2\bigr)} \nonumber\\
\alpha'c^2 &\approx \frac{sc^2 (3+sc^2) y^6}{27\pi(1+sc^2)^2}.
\end{align}
Equating these two expressions for $\alpha'$, we get
\begin{equation}
sc^2(3+sc^2)y^6 + 27(1+sc^2)^2(3+sc^2)c^2y^2 = 54sc^2(1+sc^2)^2c^2.
\end{equation}
We can solve this equation for $y$ using the cubic formula to obtain
\begin{equation}
y^2 = \bigl(\sqrt{A^3+B^2}+B\bigr)^{1/3} - \bigl(\sqrt{A^3+B^2}-B\bigr)^{1/3}, \quad\textrm{ where }\quad A = \frac{9(1+sc^2)^2c^2}{sc^2}, \quad B = \frac{27(1+sc^2)^2c^2}{3+sc^2}.
\end{equation}
We then have an equation for $\alpha'$ in terms of $s$:
\begin{align}
\alpha' &= \frac{sc^2 (3+sc^2) y^6}{27\pi(1+sc^2)^2c^2} \nonumber\\
&= \frac{sc^2}{\pi B} \Bigl\{ 2B - 3A\Bigl[ \bigl(\sqrt{A^3+B^2}+B\bigr)^{1/3} - \bigl(\sqrt{A^3+B^2}-B\bigr)^{1/3} \Bigr] \Bigr\}
\end{align}
Finally, we can solve for $s$ as a series in $\alpha'$. We keep only the leading term in $\alpha'$ and the leading term in $c$ to obtain
\begin{equation}
s_\textrm{c} \approx 3 \biggl(\frac{3\pi}{8}\biggr)^{\!\!1/4} \frac{(\alpha')^{1/4}}{c^{3/2}} + \frac{3\pi}{8} \frac{\alpha'}{c^2}.
\end{equation}
This yields \cref{eq:results-S2} if we convert $\alpha'$ back to $\alpha$ with \cref{eq:S-rescale}.
\clearpage
\end{widetext}
\section{Introduction}
Autoassociation is the ability for a neural network to store patterns of activity and to retrieve complete patterns when presented with incomplete cues. Autoassociative networks are widely used as models for neural phenomena, such as episodic memory \cite{McNaughton.1987, O'Reilly.2001, Rolls.20069yq}, and also have applications in machine learning \cite{Hopfield.1985, Barra.2012}. It is well-known that properties of the stored patterns can influence the computational capabilites of the network. Sparse patterns, in which a small fraction of the neurons are active, can be stored higher capacity compared to dense patterns \cite{Tsodyks.1988}. Correlated patterns can be merged by the network to represent shared features \cite{Fontanari.1990}. Previous autoassociative models have largely considered the storage of patterns with a single set of statistics.
We consider the possibility that an autoassociative network can store two types of patterns with different statistics, and thus, different computational roles. This idea is inspired by the architecture of the hippocampus in mammalian brains, in which CA3, the presumptive autoassociative network that stores memories of our daily experiences, receives sensory information from two parallel pathways with complementary properties \cite{Amaral.2006}. The first pathway, called the mossy fibers, presents sparser, decorrelated patterns, and the second, called the perforant path, presents denser, correlated patterns to CA3 for storage. Both pathways originate from the same upstream network, the entorhinal cortex, so they presumably represent the same sensory experiences.
We implement these ideas with a Hopfield-like model \cite{Hopfield.1982} that stores memories, each of which is an example $\mu$ of a concept $\nu$. Each example is encoded as both a sparse pattern $\ve\xi_{\mu\nu}$ and a dense pattern $\ve\psi_{\mu\nu}$. The former exhibits no correlation with other sparsely encoded examples. The latter is generated from a dense encoding $\ve\psi_\mu$ of the concept $\mu$, and correlations exist among examples within each concepts. The model is defined in \cref{sec:model}, along with an outline of the derivation of its mean-field equations. In \cref{sec:capacities}, we present our major results regarding the capacity of each type of pattern. The network can retrieve both sparse and dense patterns by tuning its activity threshold between a high value for the former, which are also more strongly stored, and a low value for the latter. The network has a high capacity for sparse examples and a low capacity for dense examples. As the number of examples stored increases beyond the dense example capacity, a critical load is reached at which the network starts retrieving dense concepts, which were never directly presented to the network. This critical load can be smaller than the sparse example capacity, which means that the network can represent distinct memories and generalizations across them.
In \cref{sec:hetero}, we show that our simple Hebbian learning rule allows for heteroassociation between sparse and dense encodings. The ability to retrieve sparse examples from dense concepts and vice versa depends critically on the relative strength with which the dense patterns are stored. Adjusting this strength changes the relative energies of sparse examples and dense concepts, which can predict if heteroassociation is possible. We discuss our results and their significance in \cref{sec:discussion}. Finally, mean-field equations describing the network overlap with various target (condensed) patterns and off-target (uncondensed) patterns are explicitly derived in \cref{sec:mean}, using substantial inspiration from Refs.~\onlinecite{Tsodyks.1988} and \onlinecite{Fontanari.1990}. The subsequent derivations of capacity and overlap formulas are provided in \cref{sec:se,sec:de,sec:dc}.
\section{\label{sec:model}The model}
\subsection{Patterns and architecture}
Consider a Hopfield network with neurons $i = 1, \ldots, N$ that can be either inactive ($S_i = 0$) or active ($S_i = 1$). The network stores $\nu = 1, \ldots, s$ examples for each of $\mu = 1, \ldots, p = \alpha N$ concepts. Examples are encoded both sparsely as $\ve\xi_{\mu\nu}$ and densely as $\ve\psi_{\mu\nu}$. Following Ref.~\onlinecite{Tsodyks.1988}, sparse examples are generated independently with sparsity $a$:
\begin{equation}
\xi^i_{\mu\nu} =
\begin{cases} 0 & \textrm{with probability } 1-a \\
1 & \textrm{with probability } a. \end{cases} \nonumber\\
\end{equation}
Following Ref.~\onlinecite{Fontanari.1990}, dense examples within a concept are correlated in the following way. Each concept corresponds to a dense pattern $\ve\psi_\mu$, generated independently with sparsity $\frac{1}{2}$:
\begin{equation}
\psi^i_\mu =
\begin{cases} 0 & \textrm{with probability } \frac{1}{2} \\
1 & \textrm{with probability } \frac{1}{2}. \end{cases}
\end{equation}
Dense examples are then generated from these concepts, with the correlation parameter $c > 0$ controlling the likelihood that example patterns match their concept:
\begin{equation}
\psi^i_{\mu\nu} =
\begin{cases} \psi^i_\mu & \textrm{with probability } \frac{1+c}{2} \\
1-\psi^i_\mu & \textrm{with probability } \frac{1-c}{2} \end{cases} \nonumber\\
\end{equation}
The average overlap, or product, between two random patterns of sparsity $\frac{1}{2}$ is $\frac{1}{4}$. The average overlap between a dense example and its corresponding dense concept exceeds this value by $\frac{c}{4}$, and the average overlap between two dense examples of the same concept exceeds it by $\frac{c^2}{4}$:
\begin{align}
\bigl\langle \psi^i_{\mu\nu} \psi^i_\mu \bigr\rangle &= \tfrac{1}{4} + \tfrac{c}{4} \nonumber\\
\bigl\langle \psi^i_{\mu\nu} \psi^i_{\mu\omega} \bigr\rangle &= \tfrac{1}{4} + \tfrac{c^2}{4}.
\end{align}
During storage, the parameter $2\gamma < \tfrac{1}{2}$ sets the relative strength of the dense encoding compared to the sparse. The factor of 2 is for theoretical convenience. The synaptic weights are
\begin{alignat}{3}
J_{ij} &={}& \frac{1}{N} \sum_{\mu\nu} & \Bigl[(1 - 2\gamma)\bigl(\xi^i_{\mu\nu} - a\bigr) + 2\gamma\bigl(\psi^i_{\mu\nu} - \tfrac{1}{2}\bigr) \Bigr] \nonumber\\
&&& {}\times \Bigl[(1 - 2\gamma)\bigl(\xi^j_{\mu\nu} - a\bigr) + 2\gamma\bigl(\psi^j_{\mu\nu} - \tfrac{1}{2}\bigr) \Bigr] \nonumber\\
&\mathrlap{ {}={} \frac{1}{N} \sum_{\mu\nu} (\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) (\eta^j_{\mu\nu} + \zeta^j_{\mu\nu}) }
\label{eq:overview-J}
\end{alignat}
for $i \neq j$, and $J_{ii} = 0$. This expression uses rescaled patterns $\eta^i_{\mu\nu} \equiv (1 - 2\gamma)\bigl(\xi^i_{\mu\nu} - a\bigr)$ and $\zeta^i_{\mu\nu} \equiv 2\gamma\bigl(\psi^i_{\mu\nu} - \tfrac{1}{2}\bigr)$.
After initializing the network with a cue, neurons are asynchronously and stochastically updated via Glauber dynamics \cite{Amit.1985mb}:
\begin{equation}
P[S_i(t+1) = 1] = \frac{1}{1 + \exp\bigl\{-\beta \bigl[\sum_j J_{ij} S_j(t) - \theta\bigr]\bigr\}}.
\end{equation}
$\beta = 1/T$ is the inverse temperature and $\theta$ is the activity threshold. We shall see that $\theta$ plays a key role in selecting between sparse and dense patterns.
\subsection{Overview of mean-field equations}
The macroscopic behavior of the network can be analyzed by introducing a series of state variables, including the overlap $m$ between the network activity and condensed (target) patterns, which serves as an order parameter for retrieval \cite{Amit.1985mb, Tsodyks.1988, Fontanari.1990}. The complete derivation of their relationships in the mean-field limit is provided in \cref{sec:mean}, but we will outline it here. The first task is calculating the replica partition function $\langle Z^n \rangle$, where the angle brackets indicate averaging over rescaled patterns $\ve\eta_{\mu\nu}$ and $\ve\zeta_{\mu\nu}$ and $n$ is the number of replica systems. By introducing auxiliary fields via Hubbard-Stratonovich transformations and self-averaging over uncondensed (off-target) patterns, we obtain
\begin{align}
\langle Z^n \rangle \propto \int &\biggl[\prod_{\nu\rho} \mathrm{d} m^\rho_{1\nu} \biggl(\frac{\beta N}{2\pi}\biggr)^{\!\frac{1}{2}}\biggr] \biggl[\prod_{\rho\leq\sigma} \mathrm{d} q^{\rho\sigma}\,\mathrm{d} r^{\rho\sigma}\biggr] \nonumber\\
& {}\times \exp[-\beta N f],
\end{align}
where
\begin{widetext}
\begin{align}
f ={}& \frac{1}{2} \sum_{\nu\rho} (m^\rho_{1\nu})^2 + \frac{\alpha}{2\beta} \mathrm{Tr}\log\bigl[ \delta_{\nu\omega}\delta^{\rho\sigma} - \beta \Gamma^2\bigl((1-\kappa^2)\delta_{\nu\omega} + \kappa^2\bigr) q^{\rho\sigma} \bigr] + \frac{\beta\alpha}{2} \sum_{\rho\sigma} q^{\rho\sigma} r^{\rho\sigma} \nonumber\\
&{}- \frac{1}{\beta} \Biggl\langle \log\mathrm{Tr}_S \exp\Biggl\{ \beta \biggl[ \sum_{\nu\rho} m^\rho_{1\nu} \chi_{1\nu} S^\rho - \biggl(\theta + \frac{\alpha s \Gamma^2}{2}\biggr) \sum_\rho S^\rho + \frac{\beta\alpha}{2} \sum_{\rho\sigma} r^{\rho\sigma} S^\rho S^\sigma \biggr] \Biggr\} \Biggr\rangle.
\label{eq:overview-f}
\end{align}
\end{widetext}
$\rho$ and $\sigma$ are replica indices, and
\begin{align}
\Gamma^2 &\equiv (1-2\gamma)^2a + \gamma^2, \nonumber\\
\kappa^2 &\equiv \frac{\gamma^2 c^2}{(1-2\gamma)^2a + \gamma^2}.
\end{align}
\Cref{eq:overview-f} assumes a successful retrieval regime in which the network overlaps significantly with either one sparse example $\ve\eta_{11}$ or dense, correlated examples $\ve\zeta_{1\nu}$ of one concept. We capture these two possibilities by introducing $\ve\chi_{1\nu}$, where $\chi^i_{1\nu} = \eta^i_{11}\delta_{1\nu}$ or $\zeta^i_{1\nu}$ respectively for retrieval of sparse or dense patterns. Through self-averaging, we have replaced averages over neurons $i$ with averages over entries $\chi_{1\nu}$ at a single neuron. Thus, the index $i$ no longer appears in \cref{eq:overview-f}. The state variables are $m^\rho_{1\nu}$, which represents the network overlap with $\ve\chi_{1\nu}$; $r^{\rho\sigma}$, which represents noise due to overlap with uncondensed patterns; and $q^{\rho\sigma}$, which is related to the overall neural activity.
Then, we use the replica symmetry ansatz and saddle-point approximation to obtain the following mean-field equations, which justify the physical interpretations of the state variables given above:
\begin{align}
m_{1\nu} &= \bigl\llangle \chi_{1\nu} \mathop{\mathrm{sig}}\nolimits[\beta\mathcal{H}] \bigr\rrangle, \nonumber\\
q &= \bigl\llangle \mathop{\mathrm{sig}}\nolimits[\beta\mathcal{H}]^2 \bigr\rrangle, \nonumber\\
q_0 &= \bigl\llangle \mathop{\mathrm{sig}}\nolimits[\beta\mathcal{H}] \bigr\rrangle, \nonumber\\
Q &\equiv \beta (q-q_0) \Gamma^2, \nonumber\\
r &= qs\Gamma^4 \frac{\bigl(1 - Q(1-\kappa^2)(1+s_0\kappa^2)\bigr)^{\!2} + s_0\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s_0\kappa^2)\bigr)^{\!2}}.
\label{eq:overview-meanfield}
\end{align}
$q$ and $q_0$ are anzatz simplifications of $q^{\rho\sigma}$ for $\rho\neq\sigma$ and $\rho = \sigma$, respectively. Also, $s_0 \equiv s-1$, $\mathop{\mathrm{sig}}\nolimits(x) \equiv 1/(1+\mathrm{e}^{-x})$, and
\begin{align}
\mathcal{H} &\equiv \sum_\nu m_{1\nu} \chi_{1\nu} - \phi + \sqrt{\alpha r} z, \nonumber\\
\phi &\equiv \theta - \frac{Q\alpha s\Gamma^2}{2} \cdot \frac{1+s_0\kappa^4 - Q(1-\kappa^2)(1+s_0\kappa^2)}{\bigl(1 - Q(1-\kappa^2)\bigr) \bigl(1 - Q(1+s_0\kappa^2)\bigr)}.
\end{align}
The double angle brackets indicate averages over $\chi_{1\nu}$ and $z$, an auxiliary random field with a standard normal distribution. Empirically, the shifted threshold $\phi$ is very similar to the original threshold $\theta$.
We take the $T = 0$ limit and attempt to recover three types of patterns, which yield different simplifications of the mean-field equations.
\begin{enumerate}
\item Sparse example $\ve\eta_{11}$: The network approaches one sparsely encoded example with overlap $m \equiv m_{11} \approx (1-2\gamma) a$. The mean-field equations become
\begin{alignat}{2}
m &\mathrlap{ {}= \frac{(1-2\gamma)a}{2} \Biggl\{\mathop{\mathrm{erf}}\nolimits\frac{\phi}{\sqrt{2{\alpha r}}} + \mathop{\mathrm{erf}}\nolimits\frac{(1-2\gamma)m-\phi}{\sqrt{2{\alpha r}}} \Biggr\}, }\nonumber\\
r &= \frac{s \bigl(1+s_0\kappa^4\bigr) \Gamma^4}{2} \Biggl\{ && 1 - \mathop{\mathrm{erf}}\nolimits\frac{\phi}{\sqrt{2{\alpha r}}} \nonumber\\
&&&{}+ a \mathop{\mathrm{erf}}\nolimits\frac{(1-2\gamma)m-\phi}{\sqrt{2{\alpha r}}} \Biggr\}.
\label{eq:overview-A}
\end{alignat}
\item Dense example $\ve\zeta_{11}$: The network approaches one densely encoded example with overlap $m \equiv m_{11} \approx \gamma/2$. Due to correlations, it also overlaps with other examples $\nu > 1$ of the same concept: $m_0 \equiv m_{1\nu} \approx \gamma c^2/2$. The mean-field equations become
\begin{align}
m &= \frac{\gamma}{2} \biggl\{\frac{1+c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{++}+\mathop{\mathrm{erf}}\nolimits Y_{+-}\Bigr] \nonumber\\
&\phantom{{}= \frac{\gamma}{2} \biggl\{} {}+ \frac{1-c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{-+}+\mathop{\mathrm{erf}}\nolimits Y_{--}\Bigr] \biggr\}, \nonumber\\
m_0 &= \frac{\gamma c}{2\Bigl(1-Q\frac{\gamma^2}{\Gamma^2}(1-c^2)\Bigr)} \nonumber\\
&\phantom{{}={}} {}\times \biggl\{ \frac{1+c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{++}+\mathop{\mathrm{erf}}\nolimits Y_{+-}\Bigr] \nonumber\\
&\phantom{{}={} {}\times \biggl\{} {}- \frac{1-c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{-+}+\mathop{\mathrm{erf}}\nolimits Y_{--}\Bigr] \biggr\}, \nonumber\\
r &= \frac{s\Gamma^4}{2} \cdot \frac{\bigl(1 - Q(1-\kappa^2)(1+s_0\kappa^2)\bigr)^{\!2} + s_0\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s_0\kappa^2)\bigr)^{\!2}} \nonumber\\
&\phantom{{}={}} {}\times \biggl\{1 - \frac{1+c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{++}-\mathop{\mathrm{erf}}\nolimits Y_{+-}\Bigr] \nonumber\\
&\phantom{{}={} {}\times \biggl\{} - \frac{1-c}{4} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_{-+}-\mathop{\mathrm{erf}}\nolimits Y_{--}\Bigr] \biggr\}, \nonumber\\
Q &= \frac{\Gamma^2}{\sqrt{2\pi}\sigma_0} \biggl\{ \frac{1+c}{4} \Bigl[\mathrm{e}^{-Y_{++}^2}+\mathrm{e}^{-Y_{+-}^2}\Bigr] \nonumber\\
&\phantom{{}= \frac{\Gamma^2}{\sqrt{2\pi}\sigma_0} \biggl\{} {}+ \frac{1-c}{4} \Bigl[\mathrm{e}^{-Y_{-+}^2}+\mathrm{e}^{-Y_{--}^2}\Bigr] \biggr\},
\label{eq:overview-0}
\end{align}
where
\begin{align}
\sigma_0^2 &\equiv s_0\gamma^2(1-c^2)m_0^2 + {\alpha r} \nonumber\\
Y_{\pm\pm} &\equiv \frac{\gamma m \pm s_0\gamma cm_0 \pm \phi}{\sqrt{2}\sigma_0}.
\end{align}
\item Dense concept $\ve\zeta_1$: The network approaches one densely encoded concept with overlap $m \equiv m_1 \approx \gamma/2$. Due to correlations, it will overlap with all examples $\nu$ of that concept: $m_\textrm{s} \equiv m_{1\nu} \approx \gamma c/2$. The mean-field equations become
\begin{align}
m ={}& \frac{\gamma}{4} \biggl\{ \mathop{\mathrm{erf}}\nolimits Y_++\mathop{\mathrm{erf}}\nolimits Y_- \biggr\}, \nonumber\\
m_\textrm{s} ={}& \frac{\gamma c}{4\Bigl(1-Q\frac{\gamma^2}{\Gamma^2}(1-c^2)\Bigr)} \biggl\{ \mathop{\mathrm{erf}}\nolimits Y_++\mathop{\mathrm{erf}}\nolimits Y_- \biggr\}, \nonumber\\
r ={}& \frac{s\Gamma^4}{2} \cdot \frac{\bigl(1 - Q(1-\kappa^2)(1+s_0\kappa^2)\bigr)^{\!2} + s_0\kappa^4}{\bigl(1 - Q(1-\kappa^2)\bigr)^{\!2}\bigl(1 - Q(1+s_0\kappa^2)\bigr)^{\!2}} \nonumber\\
&{}\times \biggl\{ 1 - \frac{1}{2} \Bigl[\mathop{\mathrm{erf}}\nolimits Y_+-\mathop{\mathrm{erf}}\nolimits Y_-\Bigr] \biggr\}, \nonumber\\
Q ={}& \frac{\Gamma^2}{\sqrt{8\pi}\sigma_\textrm{s}} \biggl\{ \mathrm{e}^{-Y_+^2}+\mathrm{e}^{-Y_-^2} \biggr\},
\label{eq:overview-S}
\end{align}
where
\begin{align}
\sigma_\textrm{s}^2 &\equiv s\gamma^2(1-c^2)m_\textrm{s}^2 + {\alpha r} \nonumber\\
Y_\pm &\equiv \frac{s\gamma cm_\textrm{s} \pm \phi}{\sqrt{2}\sigma_\textrm{s}}.
\end{align}
\end{enumerate}
\section{\label{sec:capacities}\texorpdfstring{$T=0$}{T = 0} capacities}
\subsection{Overview of capacity formulas}
\begin{figure}[t!]
\centering
\includegraphics{combined}
\caption{
\label{fig:combined}
Retrieval regimes for sparse examples, dense examples, and dense concepts. Capacities $s_\textrm{c}$ are obtained by numerically solving the mean-field equations (connected points). Shaded regions indicate successful retrieval.
(a) More examples can be stored sparsely than densely.
(b) For intermediate example loads $s$ and small enough concept loads $\alpha$, both the sparse example and the dense concept can be recovered. Sparse patterns have sparsity $a = 0.01$.
}
\end{figure}
The mean-field equations can be solved numerically to determine regimes of successful retrieval with respect to the number of concepts per neuron $\alpha$ and the number of examples stored per concept $s$. Successful retrieval is determined by $m \approx (1-2\gamma)a$ for sparse examples [\cref{eq:overview-A}], $m \approx \gamma$ for dense examples [\cref{eq:overview-0}], and $m_\textrm{s} \approx \gamma c$ for dense concepts [\cref{eq:overview-S}]. These regimes will change as a function the sparse pattern sparsity $a$, the dense pattern correlation $c$, the relative dense storage strength $\gamma$. We treat the activity threshold $\phi$ as a free parameter that can be adjusted to maximize $m$ and $m_\textrm{s}$.
\Cref{fig:combined}(a) shows that at any concept load $\alpha$, the network can retrieve sparse and dense examples below a critical example load $s_\textrm{c}$. To determine $s_\textrm{c}$, we fix $\alpha$ and increase $s$ until the mean-field equations no longer admit a solution at finite $m$. \Cref{fig:combined}(b) shows that it can retrieve dense concepts above a critical $s_\textrm{c}$, which we find by decreasing $s$ until the non-trivial solution for $m_\textrm{s}$ vanishes. Optimization over the shifted threshold $\phi$ reveals that optimal retrieval of dense patterns occurs at $\phi = 0$ and sparse patterns at $\phi/(1-2\gamma)^2a \approx 0.65$. These values which match results for classic Hopfield networks that store only dense or only sparse patterns \cite{Weisbuch.1985, Tsodyks.1988}. Note that for low enough $\alpha$, the network can recover both sparse examples and dense concepts at intermediate values of $s$. Thus, our network is capable of retrieving both example and concept representations of the same memories by tuning an activity threshold.
\begin{figure}[t!]
\centering
\includegraphics{A}
\caption{
\label{fig:A}
(a) Capacity $s_\textrm{c}$ for sparse examples. Connected points indicate numerical analysis of \cref{eq:overview-A}.
(b) Collapse of $s_\textrm{c}$ curves under rescaled variables. Gray line indicates theoretical formula \cref{eq:results-A1}.
(c) $s_\textrm{c}$ is maximized at intermediate values of sparsity $a$. Dense patterns have correlation $c = 0.1$.
}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics{0}
\caption{
\label{fig:0}
(a) Capacity $s_\textrm{c}$ for dense examples. Connected points indicate numerical analysis of \cref{eq:overview-0}.
(b) Collapse of $s_\textrm{c}$ curves under rescaled variables. Gray lines indicate theoretical formula \cref{eq:results-0}.
}
\end{figure}
\begin{figure*}[t!]
\centering
\includegraphics{S}
\caption{
\label{fig:S}
(a) Capacity, or critical example load, $s_\textrm{c}$ for dense concepts. Connected points indicate numerical analysis of \cref{eq:overview-S}.
(b)--(d) Collapse of $s_\textrm{c}$ curves under rescaled variables. Gray lines indicate theoretical formula \cref{eq:results-S1}.
(e) For the sparsest patterns, $s_\textrm{c}$ curves exhibit better collapse under differently rescaled variables. Gray line indicates theoretical formula \cref{eq:results-S2}, which better matches the numerical results. It exhibits weak dependence on dense correlation $c$, and we only show its behavior for $c = 0.02$.
}
\end{figure*}
Under various assumptions, we can simplify the mean field equations \cref{eq:overview-A,eq:overview-0,eq:overview-S} to derive formulas for the capacity, or critical example load, of each type of pattern.
\begin{enumerate}
\item For sparse examples, the capacity is given by
\begin{equation}
\frac{1}{\alpha} \sim s_\textrm{c} \bigl(1+s_\textrm{c}\kappa^4\bigr) \frac{\Gamma^4}{(1-2\gamma)^4} \frac{|\!\log a|}{a},
\label{eq:results-A1}
\end{equation}
which means that
\begin{equation}
s_\textrm{c} \sim \sqrt{ \frac{1}{4\kappa^8} + \frac{(1-2\gamma)^4}{\gamma^4c^4} \cdot \frac{a}{|\!\log a|} \cdot \frac{1}{\alpha} } - \frac{1}{2\kappa^4}.
\label{eq:results-A2}
\end{equation}
\item For dense examples, the capacity is given by
\begin{equation}
s_\textrm{c} \approx \frac{1}{3c^3+18\frac{\Gamma^4}{\gamma^4}\alpha}.
\label{eq:results-0}
\end{equation}
\item For dense concepts, there are two cases. For larger sparsities $a$, the critical example load approximately collapses as a function of $s_\textrm{c} c^2$. It can be obtained by numerically inverting the following first equation for $y$ and substituting it into the second:
\begin{align}
\frac{2\Gamma^4}{\gamma^4c^2}\alpha ={}& \frac{(1-2\gamma)^2a}{\gamma^2} \frac{\Bigl[\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\Bigr]^3}{y^2\Bigl[\erf\frac{y}{\sqrt{2}}-\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\Bigr]} \nonumber\\
& {}- \Bigl[\textstyle\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy\Bigr]^2 \nonumber\\
s_\textrm{c} c^2 \approx{}& \frac{(1-2\gamma)^2a}{\gamma^2} \frac{\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy}{\erf\frac{y}{\sqrt{2}}-\sqrt\frac{2}{\pi}y\mspace{1.5mu}\expy}.
\label{eq:results-S1}
\end{align}
For smaller $a$, the critical example load approximately collapses as a function of $s_\textrm{c} c^{3/2}$:
\begin{equation}
s_\textrm{c} c^{3/2} \approx 3 \bigl(\tfrac{3\pi}{4}\bigr)^{\!1/4} \Bigl(\tfrac{\Gamma^4}{\gamma^4c^2}\alpha\Bigr)^{\!1/4} + \tfrac{3\pi}{4} c^{-1/2} \Bigl(\tfrac{\Gamma^4}{\gamma^4c^2}\alpha\Bigr).
\label{eq:results-S2}
\end{equation}
\end{enumerate}
\Cref{fig:A,fig:0,fig:S} show that these capacity formulas match well with numerical analysis of the mean-field equations over a wide range of parameters. One noteworthy property of this model is that the capacity for sparse examples is maximized at intermediate sparsities $a$ [\cref{fig:A}(c)]. In contrast, classic Hopfield networks with only sparse patterns have capacity that scales asymptotically like $1/a|\!\log a|$, which is always higher for sparser patterns \cite{Tsodyks.1988}. In our dual encoding model, sparser patterns interfere less with each other but are also more easily disrupted by dense patterns, whose sparsity is always 0.5. The tradeoff between these two factors leads favors intermediate sparsities.
\subsection{\label{sec:sim}Simulation results}
We perform simulations to verify our capacity calculations. For each simulation condition, we construct replicate networks that store different randomly generated patterns. When generating sparse patterns of sparsity $a$, we fix the number of active neurons to $Na$ to reduce finite-size effects. Neural dynamics proceed asynchronously in cycles wherein every neuron is updated once in random order. We use $N = \num{10000}$ neurons and dense strength $\gamma = 0.1$, unless otherwise noted. Retrieval is assessed by the following definition of overlap between target pattern $\ve\chi$ and network activity $\ve S$:
\begin{equation}
\hat m = \frac{1}{N a_\chi (1-a_\chi)}\sum_i (\chi_i - a_\chi) S_i,
\end{equation}
where $a_\chi = a$ for sparse patterns and $a_\chi = 1/2$ for dense patterns. By comparing with retrieval values described in \cref{sec:capacities} and derived in \cref{sec:se,sec:de,sec:dc}, we expect $\hat m \approx 1$ to indicate successful retrieval of all pattern types $\ve\chi = \ve\xi_{\mu\nu}$, $\ve\psi_{\mu\nu}$, and $\ve\psi_\mu$.
\begin{figure}[t!]
\centering
\includegraphics{sim}
\caption{
\label{fig:sim}
Capacities $s_\textrm{c}$ for (a) sparse examples, (b) dense examples, and (c) dense concepts obtained by numerical calculations (lines) and simulations (points). For simulation data, points indicate means over 8 replicate networks, and vertical bars indicate standard deviations which are often obscured by the points. In each replicate network, 20 cues are tested with simulations lasting 10 update cycles.
}
\end{figure}
In order to obtain capacities, we set a hard threshold with $\beta \rightarrow \infty$ and use the true target patterns as cues. Thus, these simulations are assessing the $T = 0$ stability of the target patterns. For sparse examples, we optimize over the threshold $\theta$ by numerical search. For dense patterns, we use $\theta = 0$. We define successful retrieval as $\hat m > (1 + \hat m_0)/2$, where $\hat m_0$ is the overlap expected for off-target patterns within the same concept. As listed in \cref{sec:capacities} and derived in \cref{sec:se,sec:de,sec:dc}, $\hat m_0 = 0$ for sparse examples, $\hat m_0 = c^2$ for dense examples, and $\hat m_0 = c$ for dense concepts.
\Cref{fig:sim} reveals reasonable agreement between simulations and numerical analysis of the mean-field equations. This supports the validity of our derivations and the simplifications we invoked to perform them.
\section{\label{sec:hetero}Heteroassociation}
\subsection{Simulation results}
Our network stores linear combinations of sparse and dense patterns, which contain cross-terms between the two [\cref{eq:overview-J}]. Thus, we use simulations to test its ability to perform heteroassociation. We cue the network with a noisy version of the sparse example $\ve\xi_{\mu\nu}$, dense example $\ve\psi_{\mu\nu}$, or dense concept $\ve\psi_\mu$, and attempt to retrieve either of the three as the target pattern. For cases in which concepts are used as cues while examples are desired as targets, the highest overlap with any example within the cued concept is reported. We use $p = 10$ concepts and either $s = 30$ examples per concept during retrieval of sparse examples and dense concepts or $s = 3$ during retrieval of dense examples. Sparse patterns have sparsity $a = 0.01$ and dense patterns have correlation $c = 0.4$. With theoretical motivation in \cref{sec:se}, we define the rescaled parameters
\begin{equation}
\theta' = \theta/(1-2\gamma)^2a \cond{and} \beta' = \beta\cdot(1-2\gamma)^2a,
\label{eq:overview-rescaled}
\end{equation}
with rescaled temperature $T' = 1/\beta'$. To retrieve sparse examples, we apply a threshold $\theta' = 0.65$, and to retrieve dense examples and concepts, we apply $\theta' = 0$. We reintroduce noise into our simulations with inverse temperature $\beta' = 50$ and by randomly flipping a fraction 0.01 of the cue pattern between inactive and active during network initialization.
\begin{figure}[t!]
\centering
\includegraphics{hetero}
\caption{
\label{fig:hetero}
Auto- and heteroassociation among sparse and dense patterns demonstrated by network simulations. Networks are placed under various conditions compared to baseline.
Higher $p$: the number of concepts is increased from $p = 10$ to $30$.
Higher $T$: the rescaled temperature is increased from $T' = 1/50$ to $1/5$.
Higher cue noise: the fraction of the cue pattern flipped is increased from 0.01 to 0.2.
Lower $\gamma$: The dense pattern storage strength is decreased from $\gamma = 0.1$ to $0.05$.
For dense example and concept targets, we use rescaled threshold $\theta' = 0$. For sparse example targets, we use $\theta' = 0.65$. Overlaps $\hat m$ reported are averages over 10 replicate networks. In each, 10 cues are tested with simulations lasting 20 update cycles.
}
\end{figure}
\Cref{fig:hetero} shows that the network is generally capable of heteroassociation using the parameters described above, which define the baseline condition. By increasing the number of concepts, heteroassociative performance is largely preserved, but note that the retrieval of dense concepts from sparse examples is impaired. We next amplify two different sources of noise by either raising the temperature or increasing the noise introduced to cues. Different pattern types are more robust to each source. For instance, if we consider the autoassociation of example patterns, sparse encodings are more robust to higher temperature, whereas dense encodings are more robust to cue noise.
\subsection{Dense pattern strength \texorpdfstring{$\gamma$}{γ}}
Notice in the baseline condition of \cref{fig:hetero} that while dense concepts can be easily retrieved from sparse examples, the reverse is more difficult. The ability to perform bidirectional heteroassociation between a concept and its examples would have computational significance, so we seek to find network parameters that achieve it. Intuitively, lowering the storage strength of dense patterns $\gamma$ should bias the network towards retrieving sparse patterns. \Cref{fig:hetero} shows that, indeed, lowering $\gamma$ improves retrieval of sparse examples from dense concepts. Moreover, the network is still capable of the opposite process, albeit with decreased performance.
\begin{figure}[t!]
\centering
\includegraphics{hamiltonian}
\caption{
\label{fig:hamiltonian}
The dense pattern storage strength $\gamma$ controls the ability to retrieve sparse examples from dense concepts by changing their relative energies. For all results, we use rescaled threshold $\theta' = 0.65$.
(a) Hamiltonian energy of sparse examples and dense concepts [\cref{eq:results-H}]. Inset shows sparse example energy in detail.
(b) Critical dense strength $\gamma_\textrm{c}$ below which sparse examples can be successfully retrieved by dense concept cues. Theoretical predictions are the locations of energy crossovers in (a).
Sparse patterns have sparsity $a = 0.01$. For $c = 0.1$, we store $s = 150$ patterns in each of $p = 3$ cues. For $c = 0.4$, $s = 30$ and $p = 10$. For simulation data, points indicate means over 10 replicate networks, and vertical bars indicate standard deviations, which are obscured by the points. In each replicate network, 10 cues are tested with simulations lasting 20 update cycles.
}
\end{figure}
The value of $\gamma$ appears critical to the ability of the network to retrieve sparse examples from dense concepts. We hypothesize that this is related to the relative energy of these pattern types. As described in \cref{sec:mean}, the Hamiltonian of our network is
\begin{equation}
H = -\frac{1}{2N}\sum_{\mu\nu} \sum_{i \neq j} (\eta^i_{\mu\nu} + \zeta^i_{\mu\nu}) (\eta^j_{\mu\nu} + \zeta^j_{\mu\nu}) S_i S_j + \theta \sum_i S_i,
\end{equation}
where, again, $\ve\eta_{\mu\nu}$ and $\ve\zeta_{\mu\nu}$ are rescalings of sparse examples $\ve\xi_{\mu\nu}$ and dense examples $\ve\psi_{\mu\nu}$ [\cref{eq:overview-J}]. We set the network activity $\ve S$ to a sparse example $\ve\xi_{\mu\nu}$ or dense concept $\ve\psi_\mu$ and calculate the average over patterns $\langle H \rangle$:
\begin{equation}
\frac{\langle H \rangle}{N} \approx \begin{cases}
\displaystyle -\frac{1}{2} (1-2\gamma)^2 a^2 + \theta a & \textrm{sparse example}, \\
\displaystyle -\frac{1}{2} s \biggl[\frac{\gamma c}{2}\biggr]^2 + \frac{\theta}{2} & \textrm{dense concept}.
\end{cases}
\label{eq:results-H}
\end{equation}
\Cref{fig:hamiltonian}(a) shows \cref{eq:results-H}. For both sparse examples and dense concepts, use a high threshold $\theta' = 0.65$ intended to retrieve the former. First consider $c = 0.4$, which is used in \cref{fig:hetero}. For the baseline condition of $\gamma = 0.1$ in \cref{fig:hetero}, dense concepts have lower energy, even while applying a high threshold. This can explain why retrieval of sparse examples from dense concepts is difficult. For the low $\gamma$ condition of $\gamma = 0.05$ in \cref{fig:hetero}, the energy of dense concepts increases above that of sparse examples, which favors the retrieval of the latter. Thus, we predict that the energy crossover between these two pattern types defines a critical $\gamma_\textrm{c}$ above which sparse examples cannot be retrieved from dense concepts.
To test this prediction, we simulate networks at varying values of $\gamma$. We consider a successful retrieval regime to have at least 10\% of the concept cues retrieving a corresponding example with overlap $\hat m > 0.5$. \Cref{fig:hamiltonian}(b) demonstrates that the energy crossover indeed predicts $\gamma_\textrm{c}$ for $c = 0.4$. The $c = 0.1$ case shows lower quantitative agreement between simulation and theory, although the qualitative effect of a higher $\gamma_\textrm{c}$ compared to that for $c = 0.4$ is captured. The comparison of the Hamiltonian energy between sparse examples and dense concepts ignores the contribution of entropy to the free energy. Nevertheless, simulations demonstrate that temperature exerts no significant effect on $\gamma_\textrm{c}$, so our $T = 0$ predictions are equally valid at finite $T$.
\begin{figure*}[t!]
\centering
\includegraphics{gamma}
\caption{
\label{fig:gamma}
Capacities $s_\textrm{c}$ as a function of dense pattern storage strength $\gamma$.
(a), (b) Retrieval regimes. Connected points indicate numerical analysis of the mean-field equations (connected points). Shaded regions indicate successful retrieval.
Capacities $s_\textrm{c}$ for (c) sparse examples, (d) dense examples, and (e) dense concepts.
Collapse of $s_\textrm{c}$ curves for (f) sparse examples, (g) dense examples, and (e) dense concepts under rescaled variables. Gray lines indicate theoretical formulas \cref{eq:results-A1,eq:results-0,eq:results-S1}, respectively. Concept load is $\alpha = 0.001$ concepts per neuron.
}
\end{figure*}
Due to the importance of $\gamma$, we present additional capacity results in which it is varied [\cref{fig:gamma}]. For each set of parameters assessed, there is a range of intermediate $\gamma$ in which both sparse examples and dense concepts are stable [\cref{fig:gamma}(b)]. Within it should be a narrower range in which heteroassociation between the two is possible. \Cref{fig:gamma}(c)--(h) illustrates that our theoretical capacity formulas are still valid as functions over $\gamma$.
\section{\label{sec:discussion}Discussion}
In summary, we present a Hopfield-like model that stores pairs of sparse patterns with low correlation and dense patterns with high correlation. By adjusting the activity threshold, the network can retrieve patterns of either sparsity. The capacity for sparse patterns is large, so many distinct memories can be retrieved. As more dense patterns are stored, they merge according to their correlation structure such that concepts are built through the accumulation of examples. We derive mean-field equations that govern network overlap with sparse examples, dense examples, and dense concepts, and calculate capacity formulas for each type of retrieved pattern. Moreover, we explain how the network can retrieve one type of target pattern from its corresponding cue pattern of a different type.
The capability of autoassociative networks to generalize across correlated examples is well-established \cite{Fontanari.1990, Stariolo.1992, Dominguez.1998}. Another line of investigation has also shown that Hopfield-like networks can build a hierarchy of memories that obeys an ultrametric, tree-like structure \cite{Mezard.1985, Dotsenko.1985, Cortes.1987, Virasoro.1988, Gutfreund.1988, Krogh.1988}. Each pattern at one level in the structure serves as a concept-like trunk from which multiple correlated branches are generated to form the next, more example-like level. While these models are insightful and influential, they possess certain disadvantages that our network can address. The typically use an activity threshold or, equivalently, an external field to move between levels, which is also the case in this work. In one ultrametric model, the field is inhomogeneous and proportional to the pattern retrieved \cite{Gutfreund.1988}. Our activity threshold is homogeneous and does not require memory of the pattern retrieved, though implementing such a feature may improve retrieval performance. In another hierarchical model, coarser representations are stored more sparsely and retrieved at higher threshold \cite{Krogh.1988}. This arrangement prevents the network from leveraging the higher capacity of sparser patterns to store finer representations, which are more numerous. Our network follows this design principle. Moreover, ultrametric Hopfield networks often require complex storage procedures that require a priori knowledge of concepts or other examples \cite{Dotsenko.1985, Cortes.1987, Gutfreund.1988, Krogh.1988}. They do not permit the unsupervised learning of concepts through the accumulation of examples over time, which is achieved by our simple Hebbian learning rule and strengthens the biological significance of our model.
\section*{Acknowledgments}
LK is supported by JSPS KAKENHI for Early-Career Scientists (22K15209) and has been supported by the Miller Institute for Basic Research in Science and a Burroughs Wellcome Fund Collaborative Research Travel Grant. TT is supported by Brain/MINDS from AMED (JP19dm0207001) and JSPS KAKENHI (JP18H05432).
\input{Manuscript.bbl}
\input{Appendices}
\end{document}
| {'timestamp': '2023-02-10T02:07:55', 'yymm': '2302', 'arxiv_id': '2302.04481', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04481'} | arxiv |
\section{Experiment Details}\label{sec_add_exp_setup}
For our result, we measure $B$ as an upper bound on the loss value taken over the entire data distribution.
Across five datasets in our experiments, setting $B = 5.4$ suffices for all the training and testing examples in the datasets.
For comparing generalization bounds, we use two types of model architectures, including GCN \cite{kipf2016semi} and the MPGNN in \citet{liao2020pac}. Following the setup in \citet{liao2020pac}, we apply the same network weights across multiple layers in one model, i.e., $W^{(t)} = W$ and $U^{(t)} = U$ across the first $l-1$ layers. For GCNs, we set $\cU$ as zero, $\rho_t$ and $\psi_t$ as identity mappings, $\phi_t$ as ReLU function. For MPGNNs, we specify $\phi_t$ as ReLU, $\rho_t$ and $\psi_t$ as Tanh function. For both model architectures, we set the width of each layer $d_t = 128$ and vary the network depth $l$ in 2, 4, and 6.
On the three collaboration network datasets, we use one-hot encodings of node degrees as input node features.
We train the models with Adam optimizer with a learning rate of $0.01$ and set the number of epochs as $50$ and batch size as $128$ on all three datasets.
We compute the generalization bounds following the setup in \citet{liao2020pac}. We state the results with our notations in the following.
\begin{itemize}[leftmargin=15pt]
\item Theorem 3.4 from \citet{liao2020pac}:
{\small$$
\sqrt{\frac{42^2}{\gamma^2 N}
\Bigg( \max\limits_{(X, G, y) \sim \cD}\bignorms{X}^2 \Bigg)
\Big(\max \Big(\zeta^{-l+1}, (\lambda\xi)^{\frac{l+1}{l}} \Big) \Big)^2 l^2h\log(4lh) (2s_1^2r_1^2 + s_l^2r_l^2))},
$$}%
where $\zeta = \min(s_1, s_l)$, $\lambda = s_1s_l$, $\xi = \frac{(ds_1)^{l-1} - 1}{ds_1-1}$, $d$ is the max degree, $h$ is the max hidden width, and $\gamma$ is the desired margin in the margin loss. Note that $s_i = s_1$ and $r_{i}=r_1$ for $1 \leq i \leq l-1$ since the first $l-1$ layers apply the same weight.
\item Proposition 7 from \citet{garg2020generalization}:
{\small$$
48 s_l h Z\sqrt{\frac{3}{\gamma^2 N}\log\big( 24s_l\sqrt{N}
\max\big( Z, M\sqrt{h}
\max\big(
\kappa_2 s_1, \bar{R}s_1 \big) \big) \big)},
$$}%
where $M{=}\frac{(ds_1)^{l-1} - 1}{ds_1-1}$, $\bar{R}=d\cdot \min( \kappa_1 \sqrt{h}, \kappa_2 s_1 M)$, $Z = \kappa_2 s_1 + \bar{R}s_1$, $\kappa_1 = \max\limits_{x \in \real^{h}}\norm{\phi(x)}_{\infty}$, and $\kappa_2 = \max\limits_{_{_{(X, G, y) \sim \cD}}}\bignorms{X}^2$.
\end{itemize}
\section{Noise Stability Optimization for Fine-tuning GNNs}\label{sec_alg}
A common practice to apply graph and deep learning is to adopt a pretrained GNN and fine-tune it for a target problem.
Typically, only a small amount of data is available for fine-tuning.
Thus, the fine-tuned model may overfit the training data, incurring a large generalization gap. %
A central insight from our analysis is that maintaining a small perturbed loss ensures lower generalization gaps.
Motivated by this observation, we present an optimization algorithm to minimize the perturbed loss of a model.
Let $f$ denote a model and $\tilde \ell(f)$ be the perturbed loss of $f$, with noise injected inside $f$'s weight matrices.
Recall from step \eqref{eq_perturb} that $\tilde \ell(f)$ is equal to $\ell(f)$ plus several expansion terms.
In particular, minimizing the expectation of $\tilde \ell(f)$ is equivalent to minimizing $\hat\cL(f)$ plus the trace of the Hessian matrix.
To estimate this expectation, we sample several noise perturbations independently.
Because Taylor's expansion of $\tilde \ell(f)$ also involves the gradient, we cancel this out by computing the perturbed loss with the negated perturbation.
Algorithm \ref{alg_nso} describes the complete procedure.
We evaluate the above algorithm for fine-tuning pretrained GNNs.
Empirical results reveal that this algorithm achieves better test performance compared with existing regularization methods for five graph classification tasks.
\subsection{Experimental setup}
We focus on graph classification tasks, including five datasets from the MoleculeNet benchmark \cite{wu2018moleculenet}.
In each dataset, the goal is to predict whether a molecule has a certain chemical property given its graph representation.
We use pretrained GINs from \citet{hu2019strategies} and fine-tune the model on each downstream task. Following their experimental setup, we use the scaffold split for the dataset, and the model architecture is fixed for all five datasets. Each model has $5$ layers; each layer has $300$ hidden units and uses average pooling in the readout layer.
We set the parameters, such as the learning rate and the number of epochs following their setup.
\begin{algorithm}[t!]
\caption{Noise stability optimization for fine-tuning graph neural networks}\label{alg_nso}
\begin{small}
\textbf{Input}: A training dataset $\{(X_i, G_i, y_i)\}_{i=1}^{N}$ with node feature $X_i$, graph $G_i$, and graph-level label $y_i$, for $i = 1, \dots, N$.
\vspace{0.02in}%
\textbf{Require}: Number of perturbations $m$, noise variance $\sigma^2$, learning rate $\eta$, and number of epochs $T$.
\vspace{0.02in}%
\textbf{Output}: A trained model $f^{(T)}$.
\begin{algorithmic}[1]
\STATE At $t = 0$, initialize the parameters of $f^{(0)}$ with pretrained GNN weight matrices.
\vspace{0.02in}
\FOR{$1 \le t \le T$}
\FOR{$1 \le i \le m$}
\vspace{0.02in}
\STATE Add perturbation $\cE_i$ drawn from a normal distribution with mean zero and variance $\sigma^2$.
\vspace{0.02in}
\STATE Let $\tilde \cL_i(f^{(t-1)})$ be the training loss of the model $f^{(t-1)}$ with weight matrix perturbed by $\cE_i$.
\vspace{0.02in}
\STATE Let $\tilde \cL_i^{'}(f^{(t-1)})$ be the training loss of the model $f^{(t-1)}$ with weight matrix perturbed by $-\cE_i$.
\vspace{0.02in}
\ENDFOR
\STATE Use stochastic gradient descent to update $f^{(t)}$ as $f^{(t-1)} - \frac{\eta}{2m} \sum_{i=1}^m
\big(\nabla \tilde{\cL}_i\bigbrace{f^{(t-1)}}
+ \nabla \tilde{\cL}_i^{'}\bigbrace{f^{(t-1)}}\big )$.
\vspace{0.05in}
\ENDFOR
\end{algorithmic}
\end{small}
\end{algorithm}
We compare our algorithm with previous regularization methods that serve as benchmark approaches for improving generalization.
This includes early stopping, weight decay, dropout, weight averaging \cite{izmailov2018averaging}, and distance-based regularization \cite{gouk2020distance}.
For implementing our algorithm, we set the number of perturbations as $10$ and choose the noise standard deviation $\sigma$ with a grid search in $\{0.01, 0.02, 0.05, 0.1, 0.2, 0.5\}$.
\subsection{Experimental results}\label{sec_empirical}
Table \ref{tab_molecule_pred} reports the test ROC-AUC performance averaged over multiple binary prediction tasks in each dataset.
Comparing the average ranks of methods across datasets, our algorithm outperforms baselines on all five molecular property prediction datasets.
The results support our theoretical analysis that the noise stability property of GNN is a strong measure of empirical generalization performance.
Next, we provide details insights from applying our algorithm.
First, we hypothesize that our algorithm is particularly effective when the empirical generalization gap is large.
To test the hypothesis, we vary the size of the training set in the BACE dataset; we compare the performance of our algorithm with early stopping until epoch $100$.
We plot the generalization gap between the training and test losses during training, shown in Figure \ref{fig_exp_N1}-\ref{fig_exp_N2}.
As the trend shows, our algorithm consistently reduces the generalization gap, particularly when the training set size $N$ is $600$.
Second, we hypothesize that our algorithm helps reduce the trace of the Hessian matrix (associated with the loss).
We validate this by plotting the trace of the Hessian as the number of epochs progresses during training, again using the BACE dataset as an example.
Specifically, we average the trace over the training dataset.
Figure \ref{fig_exp_tr} shows the averaged trace values during the fine-tuning process.
The results confirm that noise stability optimization reduces the trace of the Hessian matrix (more significantly than early stopping).
We note that noise stability optimization also reduces the largest eigenvalue of the Hessian matrix, along with reducing the trace.
This can be seen in Figure \ref{fig_exp_eig}.
Lastly, we study the number of perturbations used in our algorithm. While more perturbations would lead to a better estimation of the noisy stability, we observe that using $10$ perturbations is sufficient for getting the most gain.
We also validate that using negated perturbations consistently performs better than not using them across five datasets.
This is because the negated perturbation cancels out the first-order term in Taylor's expansion.
In our ablation study, we find that adding the negated perturbation performs better than not using it by 1\% on average over the five datasets.
\medskip
\noindent\textbf{Remark.} %
We note that noise stability optimization is closely related to sharpness-aware minimization (SAM) \cite{foret2020sharpness}.
Noise stability optimization differs in two aspects compared with SAM.
First, SAM requires solving constrained minimax optimization, which may not even be differentiable \cite{daskalakis2021complexity}.
Our objective remains the same after perturbation.
Second, SAM reduces the largest eigenvalue of the Hessian matrix, which can be seen from Taylor's expansion of $\tilde \ell(f)$.
We reduce the trace of the Hessian matrix, which includes reducing the largest eigenvalue as part of the trace.
There is another related work that regularizes noise stability in NLP \cite{hua2021noise}.
Their approach adds noise perturbation in the input and regularizes the loss change in the output. Our approach directly adds the perturbation in the weight matrices.
\begin{table*}[!t]
\centering
\begin{footnotesize}
\caption{Test ROC-AUC (\%) score for five molecular property prediction datasets with different regularization methods. The reported results are averaged over five random seeds.}\label{tab_molecule_pred}
\begin{tabular}{@{}lcccccc@{}}
\toprule
Dataset & SIDER & ClinTox & BACE & BBBP & Tox21 & \multirow{3}{*}{Avg. Rank}\\
\# Molecule Graphs & 1,427 & 1,478 & 1,513 & 2,039 & 7,831 \\
\# Binary Prediction Tasks & 27 & 2 & 1 & 1 & 12 \\ \midrule
Early Stopping & 61.06$\pm$1.48 & 68.25$\pm$2.63 & 82.86$\pm$0.95 & 67.80$\pm$1.05 & 77.52$\pm$0.23 & 5.8\\
Weight Decay & 61.30$\pm$0.21 & 67.43$\pm$2.88 & 83.72$\pm$0.99 & 67.98$\pm$2.41 & 78.23$\pm$0.35 & 5.0\\
Dropout & 63.90$\pm$0.90 & 73.70$\pm$2.80 & 84.50$\pm$0.70 & 68.07$\pm$1.30 & 78.30$\pm$0.30 & 3.6\\
Weight Averaging & 63.67$\pm$0.34 & 78.78$\pm$1.49 & 83.93$\pm$0.36 & 70.26$\pm$0.24 & 77.59$\pm$0.11 & 3.4\\
Distance-based Reg. & 64.36$\pm$0.48 & 76.68$\pm$1.19 & 84.65$\pm$0.48 & 70.37$\pm$0.44 & 78.62$\pm$0.24 & 2.2 \\
\midrule
\textbf{Ours (Alg. \ref{alg_nso})} & \textbf{65.13$\pm$0.18} & \textbf{80.18$\pm$0.82} & \textbf{85.07$\pm$0.43} & \textbf{71.22$\pm$0.36} & \textbf{79.31$\pm$0.24} & \textbf{1.0}\\ \bottomrule
\end{tabular}
\end{footnotesize}
\end{table*}
\begin{figure*}[!t]
\centering
\caption{In Figures \ref{fig_exp_N1} and \ref{fig_exp_N2}, we show that our algorithm is particularly effective at reducing the generalization gap for small training dataset sizes $N$.
In Figures \ref{fig_exp_tr} and \ref{fig_exp_eig}, we find that both the trace and the largest eigenvalue of the loss Hessian matrix decreased during training.}
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{./figures/hessian_generalization_err_epochs_1200.pdf}
\caption{$N=1200$}\label{fig_exp_N1}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{./figures/hessian_generalization_err_epochs_600.pdf}
\caption{$N=600$}\label{fig_exp_N2}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{./figures/hessian_trace_epochs.pdf}
\caption{Trace}\label{fig_exp_tr}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{./figures/hessian_eigenvalue_epochs.pdf}
\caption{Largest Eigenvalue}\label{fig_exp_eig}
\end{subfigure}%
\label{fig_ablate_sample_size}
\end{figure*}
\section{Conclusion}\label{sec_conclude}
This work develops generalization bounds for graph neural networks with a sharp dependence on the graph diffusion matrix. The results are achieved within a unified setting that significantly extends prior works. In particular, we answer an open question mentioned in \citet{liao2020pac}: a refined PAC-Bayesian analysis can improve the generalization bounds for message-passing neural networks. These bounds are obtained by analyzing the trace of the Hessian matrix with the Lipschitz-continuity of the activation functions. Empirical findings suggest that the Hessian-based bound matches observed gaps on real-world graphs. Thus, our work also develops a practical tool to measure the generalization performance of graph neural networks. The algorithmic results with noise stability optimization further demonstrate the practical implication of our findings.
Our work opens up many interesting questions for future work. Could the new tools we have developed be used to study generalization in graph attention networks \cite{velivckovic2017graph}? Could Hessians be used for measuring out-of-distribution generalization gaps of graph neural networks?
\section*{Acknowledgement}
Thanks to Renjie Liao, Haoyu He, and the anonymous referees for providing constructive feedback on our work.
Thanks to Yang Yuan for the helpful discussions.
HJ and DL acknowledge financial support from the startup fund of Khoury College of Computer Sciences, Northeastern University.
\section{Introduction}
A central measure of success for a machine learning model is the ability to generalize well from training data to test data.
For linear and shallow models, the generalization gap between their training performance and test performance can be quantified via complexity notions such as the Vapnik–Chervonenkis dimension and Rademacher complexity.
However, formally explaining the empirical generalization performance of deep models remains a challenging problem and an active research area (see, e.g., \citet{hardt2021patterns}).
There are by now many studies for fully-connected and convolutional neural networks that provide an explanation for their superior empirical performance \cite{bartlett2017spectrally,neyshabur2018towards}.
Our work seeks to formally understand generalization in graph neural networks (GNN) \cite{scarselli2008graph}, which are commonly used for learning on graphs \cite{hamilton2017representation}.
As a concrete example for motivating the study of generalization performance, we consider the fine-tuning of pretrained graph neural networks \cite{hu2019strategies}.
Given a pretrained GNN learned on a diverse range of graphs, fine-tuning the pretrained GNN on a specific prediction task is a common approach for transfer learning on graphs.
An empirical problem with fine-tuning is that, on one hand, pretrained GNNs use lots of parameters to ensure representational power.
On the other hand, fine-tuning a large GNN would overfit the training data and suffer poor test performance without proper algorithmic intervention.
Thus, a better understanding of generalization in graph neural networks can help us identify the cause of overfitting and, consequently, inspire designing robust fine-tuning methods for graph neural networks.
A naive application of the generalization bounds from fully-connected feedforward networks \cite{bartlett2017spectrally,neyshabur2017pac} to GNNs would imply an extra term in the generalization bound that scales with $n^{l-1}$, where $n$ is the number of nodes in the graph, hence rendering the error bounds vacuous.
Besides, \citet{scarselli2018vapnik} shows that the VC dimension of GNN scales with $n$. Thus, although the VC dimension is a classical notion for deriving learning bounds, it is oblivious to the graph structure.
Recent works have taken a step towards addressing this issue with better error analysis. %
\citeay{verma2019stability} find that one-layer graph neural networks satisfy uniform stability properties \cite{verma2019stability}, following the work of \citet{hardt2016train}.
The generalization bound of \citet{verma2019stability} scales with the largest singular value of the graph diffusion matrix of the model.
However, their analysis only applies to a single layer and node prediction.
\citeay{garg2020generalization} analyze an $l$ layer message-passing neural network --- with $l-1$ graph diffusion layers and $1$ pooling layer --- for graph prediction tasks \cite{garg2020generalization}.
Their result scales with $d^{l-1}$, where $d$ is the maximum degree of the graph.
Subsequently, \citeay{liao2020pac} develop a tighter bound but still scales with $d^{l-1}$ \cite{liao2020pac}.
For both results, the graph's maximum degree is used to quantify the complexity of node aggregation in each diffusion step.
\begin{figure*}[t!]
\centering
\begin{subfigure}[b]{0.49\textwidth}
\centering
\includegraphics[width=0.98\textwidth]{./figures/graph_statistics.pdf}
\caption{Spectral norm vs. max degree for five graphs}\label{fig_intro_gcn}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.49\textwidth}
\centering
\includegraphics[width=0.98\textwidth]{./figures/generalization_corr_hessian.pdf}
\caption{Comparing generalization bounds}\label{fig_intro_graph}
\end{subfigure}
\caption{\textbf{Left}: Our spectral norm bounds for graph diffusion matrices are orders of magnitude smaller than maximum degree bounds on real-world graphs; In Figure \ref{fig_intro_gcn}, we measure the spectral norm and the max degree for five graph datasets.
\textbf{Right:} In Figure \ref{fig_intro_graph}, our Hessian-based generalization measure (plotted in green, scaled according to the \emph{left axis}) matches the empirically observed generalization gaps of graph neural networks (plotted in yellow, scaled according to the \emph{left axis}). The blue line shows a uniform-convergence bound (scaled according to the \emph{right axis}) that is orders of magnitude larger than the observed gaps.}
\label{fig_intro}
\end{figure*}
In this paper, our major contribution is to show generalization bounds for graph neural networks by reducing the max degree to the spectral norm of the graph diffusion matrix.
We analyze the stability of a graph neural network against noise injections.
Denote an $l$-layer GNN by $f$.
Based on PAC-Bayesian analysis \cite{mcallester2013pac}, the generalization gap of $f$ will be small if $f$ remains stable against noise injections; otherwise, the generalization gap of $f$ will be large.
By quantifying the noise stability of $f$ via Lipschitz-continuity properties of its activation functions, one can get PAC-Bayes bounds for feedforward networks that correlate with their observed generalization gaps \cite{arora2018stronger,ju2022robust,dziugaite2017computing,jiang2019fantastic}. %
We use a refined stability analysis of graph neural networks through Hessians and show tight generalization bounds on the graph diffusion matrix.
\medskip
\noindent\textbf{Our Contributions.}
The goal of this work is to improve the theoretical understanding of generalization in graph neural networks, and in that vein, we highlight two results below:
\begin{itemize}[leftmargin=15.0pt,topsep=2.5pt,itemsep=2.5pt] %
\item First, we prove sharp generalization bounds for message-passing neural networks \cite{dai2016discriminative,gilmer2017neural,jin2018junction}, graph convolutional networks \cite{kipf2016semi}, and graph isomorphism networks \cite{xu2018powerful}.
Our bounds scale with the spectral norm of $P_{_G}^{l-1}$ for an $l$-layer network, where $P_{_G}$ denotes a diffusion matrix on a graph $G$ and varies between different models (see Theorem \ref{thm_mpgnn} for the full statement).
We then show a matching lower bound instance where the generalization gap scales with the spectral norm of $P_{_G}^{l-1}$ (see Theorem \ref{prop_lb}).
\item Second, our stability analysis of graph neural networks provides a practical tool for measuring generalization.
Namely, we show that the noise stability of GNN can be measured by the trace of the loss Hessian matrix.
The formal statement is given in Lemma \ref{lemma_trace_hess}, and our techniques, which include a uniform convergence of the Hessian matrix, may be of independent interest.
We note that the proof applies to twice-differentiable and Lipschitz-continuous activation functions (e.g., tanh and sigmoid).
\end{itemize}
Taken together, these two results provide a sharp understanding of generalization in terms of the graph diffusion matrix for graph neural networks.
We note that the numerical value of our bounds in their dependence on the graph is much smaller than prior results \cite{garg2020generalization,liao2020pac}, as is clear from Figure \ref{fig_intro_gcn}.
Moreover, the same trend holds even after taking weight norms into account (see Figure \ref{fig_bound_measurement}, Section \ref{sec_compare}).
Further, the Hessian-based bounds (see Lemma \ref{lemma_trace_hess}, Section \ref{sec_proff_sketch}) are non-vacuous, matching the scale of empirically observed generalization gaps in Figure \ref{fig_intro_graph}.
Finally, motivated by the above analysis, we also present an algorithm that performs gradient updates on perturbed weight matrices of a graph neural network.
The key insight is that minimizing the average loss of multiple perturbed models with independent noise injections is equivalent to regularizing $f$'s Hessian in expectation. We conduct experiments on several graph classification tasks with Molecular graphs that show the benefit of this algorithm in the fine-tuning setting.
\section{Related Work}\label{sec_related}
\textbf{Generalization Bounds:}
An article by \citeay{zhang2016understanding} finds that deep nets have enough parameters to memorize real images with random labels, yet they still generalize well if trained with true labels.
This article highlights the overparametrized nature of modern deep nets (see also a recent article by \citet{arora2021technical}), motivating the need for complexity measures beyond classical notions.
In the case of two-layer ReLU networks, \citeay{neyshabur2018towards} show that (path) norm bounds better capture the ``effective number of parameters'' than VC dimension---which is the number of parameters for piecewise linear activations \cite{bartlett2019nearly}.
For multilayer networks, subsequent works have developed norm, and margin bounds, either via Rademacher complexities \cite{bartlett2017spectrally,golowich2018size,long2020generalization}, or PAC-Bayesian bounds \cite{neyshabur2017pac,arora2018stronger,li2021improved,ju2022robust}.
All of these bounds apply to the fine-tuning setting following the distance from the initialization perspective.
Our analysis approach builds on the work of \citeay{arora2018stronger} and \citeay{ju2022robust}. The latter work connects perturbed losses and Hessians for feedforward neural networks, with one limitation Hessians do not show any explicit dependence on the data.
This is a critical issue for GNN as we need to incorporate the graph structure in the generalization bound.
Our result instead shows an explicit dependence on the graph and applies to message-passing layers that involve additional nonlinear mappings.
We will compare our analysis approach and prior analysis in more detail when we present the proofs in Section \ref{sec_proff_sketch} (see Remark \ref{remark_tech}).
\medskip
\noindent\textbf{Graph Representation Learning:} Most contemporary studies of learning on graphs consider either node-level or graph-level prediction tasks.
Our result applies to graph prediction while permitting an extension to node prediction: see Remark \ref{remark_node} in Section \ref{sec_proff_sketch}.
Most graph neural networks follow an information diffusion mechanism on graphs \cite{scarselli2008graph}.
Early work takes inspiration from ConvNets and designs local convolution on graphs, e.g., spectral networks \cite{bruna2013spectral}, GCN \cite{kipf2016semi}, and GraphSAGE \cite{hamilton2017inductive} (among others).
Subsequent works have designed new architectures with graphs attention \cite{velivckovic2017graph} and isomorphism testing \cite{xu2018powerful}.
\citeay{gilmer2017neural} synthesize several models into a framework called message-passing neural networks.
Besides, one could also leverage graph structure in the pooling layer (e.g., differentiable pooling and hierarchical pooling \cite{zhang2018end,ying2018hierarchical}). It is conceivable that one can incorporate the model complexity of these approaches into our analysis.
Recent work applies pretraining to large-scale graph datasets for learning graph representations \cite{hu2019strategies}.
Despite being an effective transfer learning approach, few works have examined the generalization of graph neural nets in the fine-tuning step.
Besides learning on graphs, GNNs are also used for combinatorial optimization \cite{selsam2018learning} and causal reasoning \cite{xu2019can}.
There is another approach for graph prediction using kernels \cite{vishwanathan2010graph,du2019graph}.
There are also alternative graph diffusion processes besides GNN \cite{goel2014connectivity,goel2015note,zhang2019pruning}.
For references, see review articles \cite{hamilton2017representation,errica2019fair,wu2020comprehensive,chami2020machine}.
\medskip
\noindent\textbf{Generalization in GNN:}
Recent work explores generalization by formalizing the role of the algorithm, and the alignment between networks and tasks \cite{xu2020neural}.
\citet{esser2021learning} finds that transductive Rademacher complexity-based bound provides insights into the behavior of GNNs (e.g., under stochastic block models).
Besides, there are works about size generalization, which refer to performance degradation when models extrapolate to graphs of different sizes from the input \cite{selsam2018learning,yehudai2021local}.
It is conceivable that the new tools we have developed may be useful for studying extrapolation. %
\medskip
\noindent\textbf{Expressivity of GNN:}
The expressivity of GNN for graph classification can be related to graph isomorphism tests and has connections to one-dimensional Weisfeiler-Lehman testing of graph isomorphism \cite{morris2019weisfeiler,xu2018powerful}.
This implies limitations of GNN for expressing tasks such as counting cycles \cite{sato2019approximation,chen2020can,azizian2020expressive}.
The expressiveness view seems orthogonal to generalization, which instead concerns the sample efficiency of learning.
For further discussions and references, see a recent survey by \citet{jegelka2022theory}. %
\section{Proofs}\label{app_proof}
This section provides the complete proofs for all of our results in Section \ref{sec_theory}. First, we state several notations and facts that will be needed in the proofs. Then we provide the proof of the Hessian-based generalization bound for MPNN, which is stated in Lemma \ref{lemma_gen_error}.
After that, in Appendix \ref{app_mpgnn}, we provide the proof of Theorem \ref{thm_mpgnn}, a key step of which is the proof of Lemma \ref{lemma_trace_hess}.
Next, in Appendix \ref{app_lb}, we state the proof of the lower bound.
Lastly, in Appendix \ref{app_gin}, we will provide proof for the case of graph isomorphism networks.
First, we state several facts about graphs and provide a short proof of them.
\begin{fact}\label{fact_graph}
Let $G = (V, E)$ be an undirected graph. Let $d_{G}$ be the maximum degree of $G$. %
\begin{enumerate}[leftmargin=0.25in]
\item[a)] Let $A$ be the adjacency matrix of $G$. Then, the adjacency matrix satisfies: $\sqrt{d_G} \le \bignorms{A} \le d_G$. %
\item[b)] The symmetric and degree-normalized adjacency matrix satisfies $\bignorms{D^{-1/2} A D^{-1/2}} \le 1$.
\end{enumerate}
\end{fact}
\begin{proof}
Based on the definition of the spectral norm, we get
\begin{align*}
\bignorms{A} = \max_{\bignorm{x} = 1} x^{\top} A x = \max_{\bignorm{x} = 1} \sum_{(i,j)\in E} x_ix_j \le \max_{\bignorm{x} = 1} \sum_{(i,j)\in E} \frac{1}{2}(x_i^2 + x_j^2) \le d_G \sum_{i\in V} x_i^2 = d_G.
\end{align*}
Assume that node $i$ has the maximum degree $d_G$. Denote edges set $E_i = \{(i,i_k)\}_{k=1}^{d_G}\subseteq E$. Let $x_i = \frac{1}{\sqrt{2}}$, $x_{i_k} = \frac{1}{\sqrt{2d_G}}$ for all $k = 1,\dots,d_G$. The rest entries of $x$ are equal to zero. Thus, $x$ is a normalized vector. Next, we have
\begin{align*}
\bignorms{A} = \max_{\bignorm{x} = 1} \sum_{(i,j)\in E} x_ix_j \ge \max_{\bignorm{x} = 1} 2 \sum_{(i,j)\in E_i} x_ix_j = 2 d_G \cdot \frac{1}{\sqrt{2}} \frac{1}{\sqrt{2d_G}} = \sqrt{d_G}.
\end{align*}
An example in which $\bignorms{P_G}$ gets close to $\sqrt {d_G}$ is the star graph.
An example in which $\bignorms{P_G}$ gets close to $d_G$ is the complete graph.
\smallskip
Next, we focus on case b).
From the definition of the spectral norm, we know
\begin{align*}
\bignorms{D^{-1/2} A D^{-1/2}} = \max_{\bignorm{x} = 1} x^{\top} \bigbrace{D^{-1/2} A D^{-1/2}} x = \max_{\bignorm{x} = 1} \sum_{(i,j)\in E} \frac{x_ix_j}{\sqrt{d_id_j}} \le \max_{\bignorm{x} = 1} \sum_{(i,j)\in E} \frac{x_i^2}{2d_i} + \frac{x_j^2}{2d_j} = \sum_{i\in V} x_i^2 = 1.
\end{align*}
During the middle of the above step, we used the Cauchy-Schwartz inequality. The proof of this result is now completed.
\end{proof}
\noindent\textbf{Notations:}
For two matrices $X$ and $Y$ that are both of dimension $d_1$ by $d_2$, the Hadamard product of $X$ and $Y$, denoted as $X \odot Y$, is equal to the entrywise product of $X$ and $Y$.
\subsection{Proof of our PAC-Bayesian bound (Lemma \ref{lemma_gen_error})}\label{proof_pac_bayes}
To be precise, we will restate the conditions required in Theorem \ref{thm_mpgnn} separately below. The conditions are exactly the same as stated in Section \ref{sec_theory}.
\begin{assumption}\label{ass_1}
Assume that all the activation functions $\phi_i(\cdot),\rho_i(\cdot),\psi_i(\cdot)$ for any $1\leq i\leq l-1$ and the loss function $\ell(x, y)$ over $x$ are twice-differentiable and $\kappa_0$-Lipschitz. Their first-order derivatives are $\kappa_1$-Lipschitz and their second-order derivatives are $\kappa_2$-Lipschitz.
\end{assumption}
Based on the above assumption, we provide the precise statement for Taylor's expansion, used in equation \eqref{eq_perturb}.
\begin{proposition}\label{prop_taylor}
In the setting of Theorem \ref{thm_mpgnn}, suppose each parameter in layer $i$ is perturbed by an independent noise drawn from $\cN(0,\sigma_i^2)$.
Let $\tilde{\ell}(f(X,G),y)$ be the perturbed loss function with noise perturbation injection vector $\cE$ on all parameters $\cW$ and $\cU$.
There exist some fixed value $C_1$ that do not grow with $N$ and $1/\delta$ such that %
\begin{small}
\begin{align*}
\bigabs{\tilde \ell(f(X, G), y) - \ell(f(X, G), y) - \frac 1 2 \sum_{i=1}^l\sigma_{i}^2 \bigtr{\bH^{{(i)}}[\ell (f(X,G),y)]} }
\le C_1 \sum_{i=1}^l \sigma_{i}^3.
\end{align*}
\end{small}%
\end{proposition}
\begin{proof}
By Taylor's expansion, the following identity holds
\begin{align*}
\tilde \ell(f(X, G), y) - \ell(f(X, G), y)
= \exarg{\cE}{\cE^{\top} \nabla \ell(f) + \frac 1 2 {\cE}^{\top} \bH[\ell(f)] {\cE} + R(\ell(f),\cE)}.
\end{align*}
where $R(\ell(f),\cE)$ is the rest of the first order and the second order terms.
Since each entry in $\cE$ follows the normal distribution, we have
$\exarg{\cE}{\cE^{\top} \nabla \ell(f)} = 0$. The Hessian term turns to
\begin{align*}
{\cE}^{\top} \bH[\ell(f)] {\cE} = \sum_{i=1}^l \sigma_i^2 \bigtr{\bH^{(i)}[\ell (f(X,G),y)]}.
\end{align*}
Since the readout layer is linear, by Proposition \ref{claim_hess}, there exists a fixed constant $\bar C$ that does not grow with $N$ and $\delta^{-1}$ such that
$ |R(\ell(f),\cE)| \le \bar C \bignorm{\cE}^3$.
Based on \citet[Lemma 2]{jin2019short}, for any $x$ drawn from a normal distribution $\cN(0, \sigma^2)$, we have ${\ex{x^3}} \le 6\sigma^3$. Hence, we get
$\ex{R(\ell(f),\cE)} \le C_1 \sum_{i=1}^l {\sigma_{i}^3}$,
where $C_1 = \order{h^2 \bar C}$ is a fixed constant. Thus, we have finished the proof.
\end{proof}
Next, we state a Lipschitz-continuity upper bound of the network output at each layer.
This will be needed in the $\epsilon$-covering argument later in the proof of Theorem \ref{thm_mpgnn}.
To simplify the notation, we will abbreviate explicit constants that do not grow with $N$ and $1/\delta$ in the notation $\lesssim$; more specifically, we use $A(n) \lesssim B(n)$ to indicate that there exists a function $c$ that does not depend on $N$ and $1/\delta$ such that $A(n) \le c \cdot B(n)$ for large enough values of $n$.
\begin{proposition}\label{claim_hess}
In the setting of Theorem \ref{thm_mpgnn}, for any $j=1,\dots,l-1$, the change in the Hessian of output of the $j$ layer network $H^{(j)}$ with respect to $W_i$ and $U_i$ under perturbation on $W$ and $U$ can be bounded as follows:
\begin{align}
\bignormFro{\bH_{\cW}^{(i)}[\tilde H^{(j)}] - \bH_{\cW}^{(i)}[H^{(j)}]} &\lesssim \sum_{t=1}^j\Bigbrace{\bignorms{\Delta U^{(t)}} + \bignorms{\Delta W^{(t)}}}. \label{eq_claim_hess_1} \\
\bignormFro{\bH_{\cU}^{(i)}[\tilde H^{(j)}] - \bH_{\cU}^{(i)}[H^{(j)}]} &\lesssim \sum_{t=1}^j\Bigbrace{\bignorms{\Delta U^{(t)}} + \bignorms{\Delta W^{(t)}}}. \label{eq_claim_hess_2}
\end{align}
Above, the notation $\bH_{\cW}^{(i)}[\tilde H^{(j)}]$ is the perturbation of the Hessian matrix of $H^{(j)}$ by $\Delta \cW$ and $\Delta \cU$, specific to the variables of $\cW$; likewise, $\bH_{\cU}^{(i)}[\tilde H^{(j)}]$ is the perturbation of the Hessian matrix specific to the variables of $\cU$.
\end{proposition}
The proof of Proposition \ref{claim_hess} will be deferred until Appendix \ref{proof_prop_lip}. Based on Propositions \ref{prop_taylor} and \ref{claim_hess}, now we are ready to present the proof of Lemma \ref{lemma_gen_error}.
\begin{proof}[Proof of Lemma \ref{lemma_gen_error}]
First, we separate the gap of $\cL(f)$ and $\frac{1}{\beta}\hat{\cL}(f)$ into three parts:
\begin{align*}
\cL(f) - \frac{1}{\beta} \hat{\cL}(f) = \,& \underbrace{\exarg{(X,G,y) \sim \cD}{\ell(f(X,G),y)} - \exarg{(X,G,y) \sim \cD}{\tilde{\ell}(f(X,G),y)}}_{E_1} + \exarg{(X,G,y) \sim \cD}{\tilde{\ell}(f(X,G),y)} \\
& - \frac{1}{\beta} \Bigbrace{\frac{1}{N} \sum_{i=1}^N \tilde{\ell}(f(X_i,G_i),y_i)} + \underbrace{\frac{1}{\beta} \Bigbrace{\frac{1}{N} \sum_{i=1}^N \tilde{\ell}(f(X_i,G_i),y_i)} - \frac{1}{\beta} \Bigbrace{\frac{1}{N} \sum_{i=1}^N \ell(f(X_i,G_i),y_i)}}_{E_2}.
\end{align*}
for any $\beta \in (0,1)$.
Above, $\tilde{\ell}(f(X,G),y)$ is the perturbed loss from $\ell(f(X, G), y)$ with noise injections $\cE$ added to all the parameters in $\cW$ and $\cU$. By Taylor's expansion from Proposition \ref{prop_taylor}, we can bound the difference between $\tilde{\ell}(f(X,G), y)$ and $\ell(f(X, G)$ with the trace of the Hessian.
Therefore
\begin{align*}
\cL(f) - \frac{1}{\beta} \hat{\cL}(f) \le \,& -\exarg{(X,G,y) \sim \cD}{\frac 1 2 \sum_{i=1}^l \sigma_i^2 \bigtr{\bH^{(i)}[\ell(f(X,G),y)]}} + \sum_{i=1}^l C_1 \sigma_i^3 \tag{by Prop. \ref{prop_taylor} for $E_1$}\\
& + \Bigg( \exarg{(X,G,y) \sim \cD}{\tilde{\ell}(f(X,G),y)} - \frac{1}{\beta} \Bigbrace{\frac{1}{N} \sum_{i=1}^N \tilde{\ell}(f(X_i,G_i),y_i)} \Bigg) \\
& + \frac{1}{2\beta}\sum_{i=1}^l \sigma_i^2 \Bigbrace{\frac{1}{N} \sum_{j=1}^N \bigtr{\bH^{(i)}[\ell(f(X_j,G_j),y_j)]}} + \frac{1}{\beta}\sum_{i=1}^l C_1 \sigma_{i}^3. \tag{by Prop. \ref{prop_taylor} for $E_2$}
\end{align*}%
By rearranging the above equation, we get the following:
\begin{align*}
\cL(f) - \frac{1}{\beta} \hat{\cL}(f) \le \,& \frac 1 2 \sum_{i=1}^l \sigma_i^2 \Bigg( \underbrace{\frac{1}{N} \sum_{j=1}^N \bigtr{\bH^{(i)}[\ell(f(X_j,G_j),y_j)]} - \exarg{(X,G,y) \sim \cD}{\bigtr{\bH^{(i)}[\ell(f(X,G),y)]}}}_{E_3} \Bigg) \\
& + \frac 1 2 \Bigbrace{\frac{1}{\beta} - 1} \underbrace{\sum_{i=1}^l \frac{\sigma_i^2}{N} { \sum_{j=1}^N \bigtr{\bH^{(i)}[\ell(f(X_j,G_j),y_j)]}}}_{E_4} \\
& + \Bigbrace{1 + \frac{1}{\beta}} C_1 \sum_{i=1}^l \sigma_i^3 + \underbrace{\exarg{(X,G,y) \sim \cD}{\tilde{\ell}(f(X,G),y)} - {\frac{1}{\beta N} \sum_{i=1}^N \tilde{\ell}(f(X_i,G_i),y_i)}}_{E_5}.
\end{align*}
Based on Proposition \ref{claim_hess}, the Hessian operator $\bH^{(i)}$ is Lipschitz-continuous for some parameter that does not depend on $N$ and $1/\delta$, for any $i = 1,2\dots,l$.
Therefore, from \citet[Lemma 2.4]{ju2022robust}, there exist some fixed values $C_2$, $C_3$ that do not grow with $N$ and $1/\delta$, such that with probability at least $1 - \delta$ over the randomness of the training set. Therefore, the matrix inside the trace of $E_3$ satisfies
\begin{align}
\bignormFro{\frac 1 N \sum_{j=1}^N\bH^{(i)}[\ell(f(X_j,G_j), y_j)] - \exarg{(X,G,y)\sim\cD}{\bH^{(i)}[\ell(f(X,G), y)]}} \le \frac{C_2\sqrt{\log (C_3 N/\delta)}}{\sqrt N}, \label{eq_trace_bound}
\end{align}
for any $i = 1,\dots,l.$
Thus, by the Cauchy-Schwartz inequality, $E_3$ is less than $\sqrt{2h^2}$ times the RHS of equation \eqref{eq_trace_bound}.
Suppose the loss function $\ell(f(X,G),y)$ lies in a bounded range $[0, B]$ given any $(X,G,y) \sim \cD$. By the PAC-Bayes bound of \citet[Theorem 2]{mcallester2013pac} (see also \citet{guedj2019primer}), we choose $\cU$ as a prior distribution and $\cW + \cU$ as a posterior distribution. For any $\beta \in (0,1)$ and $\delta \in [0,1)$, with probability at least $1 - \delta$, $E_5$ satisfies:
\begin{align}
\exarg{(X,G,y) \sim \cD}{\tilde{\ell}(f(X,G),y)} - {\frac{1}{\beta N} \sum_{i=1}^N \tilde{\ell}(f(X_i,G_i),y_i)}
\le& \frac{B}{2\beta(1-\beta)N}\Bigbrace{\sum_{i=1}^l {\frac{\bignormFro{W^{(i)}}^2 + \bignormFro{U^{(i)}}^2}{2\sigma_{i}^2}} + \log \frac{1}{\delta}} \nonumber \\
\le& \frac{B}{2\beta(1-\beta)N} \Bigbrace{\sum_{i=1}^l \frac{s_i^2 r_i^2}{\sigma_i^2} + \log\frac 1 {\delta}}. \label{eq_pac_bayes}
\end{align}
The above is because ${\cW}$ and ${\cU}$ are inside the hypothesis set $\cH$.
For any $i = 1,\dots,l$, let
\[ \alpha_i = \max\limits_{(X, G, y)\sim\cD} \bigtr{\bH^{(i)}[\ell(f(X,G),y)]}. \]
Lastly, we use $\sigma_i^2 \alpha_i$ above to upper bound $E_4$.
Combined with equations \eqref{eq_trace_bound} and \eqref{eq_pac_bayes}, with probability at least $1 - 2\delta$, we get
\begin{align*}
\cL(f) - \frac{1}{\beta} \hat{\cL}(f) \le \,&
\frac{C_2\sqrt{2 h^2 \log (C_3 N/\delta)}}{\sqrt N} \sum_{i=1}^l \sigma_i^2 + \Bigbrace{1 + \frac{1}{\beta}} C_1 \sum_{i=1}^l \sigma_i^3 \\
& + {\frac 1 2 \Bigbrace{\frac{1}{\beta} - 1} \sum_{i=1}^l \alpha_i \sigma_i^2
+ \frac{B}{2\beta(1-\beta)N}\Bigg( \sum_{i=1}^l {\frac{s_i^2 r_i^2}{\sigma_{i}^2}} + \log \frac{1}{\delta} \Bigg)}.
\end{align*}
Next, we will select $\sigma_i$ to minimize the last line above.
One can verify that this is achieved when
\begin{align*}
\sigma_i^2 = \frac{s_i r_i}{1-\beta}\sqrt{\frac{B}{\alpha_i N}}, \text{ for every } i = 1,2,\dots,l.
\end{align*}
With this setting of the noise variance, the gap between $\cL(f)$ and $\hat{\cL}(f)/ {\beta}$ becomes:
\begin{align*}
\cL(f) - \frac{1}{\beta} \hat{\cL}(f) \le \frac{1}{\beta} \sum_{i=1}^l \sqrt{\frac{B \alpha_i s_i^2 r_i^2}{N}}
+ \frac{C_2\sqrt{2 h^2 \log (C_3 N/\delta)}}{\sqrt N} \sum_{i=1}^L \sigma_{i}^2 + \Bigbrace{1 + \frac{1}{\beta}} C_1\sum_{i=1}^l \sigma_i^3 + \frac{C}{2\beta(1-\beta)N}\log \frac{1}{\delta}.
\end{align*}
Let $\beta$ be a fixed value close to $1$ and independent of $N$ and $\delta^{-1}$; let $\epsilon = (1 - \beta)/\beta$. We get
\begin{align*}
&\cL(f) \le \, (1 + \epsilon) \hat{\cL}(f) + (1 + \epsilon) \sum_{i=1}^l \sqrt{\frac{B \alpha_i r_i^2 s_i^2}{N}} + \xi, \text{ where } \\
&\xi = \frac{C_2\sqrt{2 h^2 \log (C_3 N/\delta)}}{\sqrt N} \sum_{i=1}^L \sigma_{i}^2 + \Bigbrace{1 + \frac{1}{\beta}} C_1 \sum_{i=1}^l {\sigma_{i}^3} + \frac{C}{2\beta(1-\beta)N}\log \frac{1}{\delta}.
\end{align*}
Notice that $\xi$ is of order $\order{N^{-3/4}\ + \log(\delta^{-1}) N^{-1}} \le \order{\log(\delta^{-1}) / N^{3/4}}$.
Therefore, we have finished the proof of equation \eqref{eq_thm_mpgnn}.
\end{proof}
\subsubsection{Proof of Proposition \ref{claim_hess}}\label{proof_prop_lip}
For any $j = 1,2,\dots,l$, let $\tilde H^{(j)}$ be the perturbed network output after layer $j$, with perturbations given by $\Delta \cW$ and $\Delta \cU$.
We show the following Lipschitz-continuity property for $H^{(j)}$.
\begin{claim}\label{claim_perturb}
Suppose that Assumption \ref{ass_1} holds. For any $j=1,\dots,l-1$, the change in the output of the $j$ layer network $H^{(j)}$ with perturbation added to $\cW$ and $\cU$ can be bounded as follows:
\begin{align}\label{eq_claim_perturb}
\bignormFro{\tilde H^{(j)} - H^{(j)}}\lesssim \sum_{t=1}^j\Bigbrace{\bignorms{\Delta U^{(t)}}+\bignorms{\Delta W^{(t)}}}.
\end{align}
\end{claim}
\begin{proof}
We will prove using induction with respect to $j$. If $j = 1$, we have
\begin{align*}
&\bignormFro{\phi_1\Bigbrace{X \bigbrace{U^{(1)} + \Delta U^{(1)}} + \rho_1\bigbrace{P_{_G} \psi_1\bigbrace{X}} \bigbrace{W^{(1)} + \Delta W^{(1)}}} - \phi_1\Bigbrace{X U^{(1)} + \rho_1\bigbrace{P_{_G} \psi_1\bigbrace{X}} W^{(1)}}} \\
\leq & \kappa_0\bignormFro{X \Delta U^{(1)} + \rho_1\bigbrace{P_{_G} \psi_1\bigbrace{X}} \Delta W^{(1)}} \lesssim \bignorms{\Delta U^{(1)}}+\bignorms{\Delta W^{(1)}}.
\end{align*}
Hence, we know that equation \eqref{eq_claim_perturb} will be correct when $j = 1$. Assuming that equation \eqref{eq_claim_perturb} is correct for any $j \geq 1$, the perturbation of layer $j+1$'s network output $H^{(j+1)}$ is less than
{\begin{align*}
& \bignormFro{\tilde H^{(j+1)} - H^{(j+1)}} \\
\le & \, \kappa_0\bignormFro{X \Delta U^{(j+1)} + \rho_{j+1}\bigbrace{P_{_G} \psi_{j+1}\bigbrace{\tilde H^{(j)}}} \bigbrace{W^{(j+1)} + \Delta W^{(j+1)}} - \rho_{j+1}\bigbrace{P_{_G} \psi_{j+1}\bigbrace{H^{(j)}}} W^{(j+1)}} \\
\lesssim & \bignorms{\Delta U^{(j+1)}}+\bignorms{\Delta W^{(j+1)}} + \bignormFro{\tilde H^{(j)} - H^{(j)}}.
\end{align*}}%
Thus, we have finished the proof of the induction step.
\end{proof}
Next, for any $i$ and $j$, let $\frac{\partial \tilde H^{(j)}}{\partial W^{(i)}}$ be the perturbation of the partial derivative of $H^{(j)}$ with perturbations given by $\Delta \cW$ and $\Delta \cU$.
\begin{claim}\label{claim_grad}
Suppose that Assumption \ref{ass_1} holds. For any $j=1,\dots,l-1$, the change in the Jacobian of the $j$-th layer's output $H^{(j)}$ with respect to $W^{(i)}$ and $U^{(i)}$ satisfies:
\begin{align}
\bignormFro{\frac{{{\partial \tilde H}}^{(j)}}{\partial W^{(i)}} - \frac{\partial H^{(j)}}{\partial W^{(i)}}} &\lesssim \sum_{t=1}^j\Bigbrace{\bignorms{\Delta U^{(t)}} + \bignorms{\Delta W^{(t)}}}. \label{eq_claim_grad_1} \\
\bignormFro{\frac{{\partial\tilde H}^{(j)}}{\partial U^{(i)}} - \frac{\partial H^{(j)}}{\partial U^{(i)}}} &\lesssim \sum_{t=1}^j\Bigbrace{\bignorms{\Delta U^{(t)}} + \bignorms{\Delta W^{(t)}}}. \label{eq_claim_grad_2}
\end{align}
\end{claim}
\begin{proof}
We will consider a fixed $i = 1,\dots,l-1$ and take induction over $j = i, \dots, l-1$.
We focus on the proof of equation \eqref{eq_claim_grad_1}, while the proof of equation \eqref{eq_claim_grad_2} will be similar.
To simplify the derivation, we use two notations for brevity.
Let
\begin{align*}
F_j = P_{_G} \psi_{j}\bigbrace{H^{(j-1)}} W^{(j)} \text{ and }
E_j = X U^{(j)} + \rho_{j}\bigbrace{F_j}.
\end{align*}
First, we consider the base case when $j = i$.
By the chain rule, we have:
\begin{align*}
\bignormFro{\frac{\partial \tilde H^{(i)}}{\partial W^{(i)}} - \frac{\partial H^{(i)}}{\partial W^{(i)}}}
= \bignormFro{\phi'_i\bigbrace{\tilde E_i}
\odot \frac{\partial \tilde E_i} {\partial W^{(i)}} - \phi'_i\bigbrace{E_i} \odot \frac{\partial E_i} {\partial W^{(i)}} }
\lesssim \bignormFro{\phi'_i\bigbrace{\tilde E_i} - \phi'_i\bigbrace{E_i} } + \bignormFro{\frac{\partial\tilde E_i} {\partial W^{(i)}} - \frac{\partial E_i} {\partial W^{(i)}} }.
\end{align*}
From Claim \ref{claim_perturb}, we know
\begin{align*}
\bignormFro{\phi'_i\bigbrace{\tilde E_i} - \phi'_i\bigbrace{E_i}} \leq \kappa_1 \bignormFro{\tilde E_i - E_i} \lesssim \bignorms{\Delta W^{(i)}} + \bignorms{\Delta U^{(i)}}.
\end{align*}
By the chain rule again, we get:
\begin{align*}
\bignormFro{\frac{\partial \tilde E_i} {\partial W^{(i)}} - \frac{\partial E_i} {\partial W^{(i)}} }
\lesssim \bignormFro{\rho'_i\bigbrace{\tilde F_i} - \rho'_i\bigbrace{F_i}} + \bignormFro{\frac{\partial \tilde F_i} {\partial W^{(i)}} - \frac{\partial F_i} {\partial W^{(i)}}}
\lesssim {\bignorms{\Delta W^{(i)}} + \bignorms{\Delta U^{(i)}}} \tag{by Claim \ref{claim_perturb} again}.
\end{align*}
Hence, we know that equation \eqref{eq_claim_grad_1} will be correct when $j=i$. Assuming that equation \eqref{eq_claim_grad_1} will be correct for any $j$ up to $j \ge i$, we have
\begin{align*}
\bignormFro{\frac{\partial \tilde H^{(j+1)}}{\partial W^{(i)}} - \frac{\partial H^{(j+1)}}{\partial W^{(i)}}}
\lesssim & \bignormFro{\phi'_{j+1}\bigbrace{\tilde E_{j+1}} - \phi'_{j+1}\bigbrace{E_{j+1}} } + \bignormFro{\frac{\partial \tilde E_{j+1}} {\partial W^{(i)}} - \frac{\partial E_{j+1}} {\partial W^{(i)}} } \\
\lesssim & \sum_{t=1}^{j+1}\Bigbrace{\bignorms{\Delta U^{(t)}} + \bignorms{\Delta W^{(t)}}} + \bignormFro{\rho'_{j+1}\bigbrace{\tilde F_{j+1}} - \rho'_{j+1}\bigbrace{F_{j+1}}} + \bignormFro{\frac{\partial \tilde F_{j+1}} {\partial W^{(i)}} - \frac{\partial F_{j+1}} {W^{(i)}}} \\
\lesssim & \sum_{t=1}^{j+1}\Bigbrace{\bignorms{\Delta U^{(t)}}+\bignorms{\Delta W^{(t)}}} + \bignormFro{\psi'_{j+1}\bigbrace{\tilde H^{(j)}} - \psi'_{j+1}\bigbrace{H^{(j)}}} + \bignormFro{\frac{\partial \tilde H^{(j)}} {\partial W^{(i)}} - \frac{\partial H^{(j)}} {\partial W^{(i)}}} \\
\lesssim & \sum_{t=1}^{j+1}\Bigbrace{\bignorms{\Delta U^{(t)}}+\bignorms{\Delta W^{(t)}}}. \tag{by Claim \ref{claim_perturb} and the induction step}
\end{align*}
The above steps all use Claim \ref{claim_perturb}.
The last step additionally uses the induction hypothesis.
From repeatedly applying the above beginning with $j = i$ along with the base case of equation \eqref{eq_claim_grad_1}, we conclude that equation \eqref{eq_claim_grad_1} holds.
\smallskip
Next, we consider the base case for equation \eqref{eq_claim_grad_2}. For the base case $j=i$, from the chain rule, we get:
\begin{align*}
\bignormFro{\frac{\partial \tilde H^{(i)}}{\partial U^{(i)}} - \frac{\partial H^{(i)}}{\partial U^{(i)}}}
\lesssim \bignormFro{\phi'_i\bigbrace{\tilde E_i} - \phi'_i\bigbrace{E_i} } + \bignormFro{\frac{\partial \tilde E_i} {\partial U^{(i)}} - \frac{\partial E_i} {\partial U^{(i)}} }
\lesssim {\bignorms{\Delta W^{(i)}} + \bignorms{\Delta U^{(i)}}} \tag{by Claim \ref{claim_perturb}}.
\end{align*}
Hence, we know that equation \eqref{eq_claim_grad_2} will be correct when $j=i$. Assuming that equation \eqref{eq_claim_grad_2} will be correct for any $j$ up to $j \ge i$, we have
\begin{align*}
\bignormFro{\frac{\partial \tilde H^{(j+1)}}{\partial U^{(i)}} - \frac{\partial H^{(j+1)}}{\partial U^{(i)}}}
\lesssim & \bignormFro{\phi'_{j+1}\bigbrace{\tilde E_{j+1}} - \phi'_{j+1}\bigbrace{E_{j+1}}} + \bignormFro{\frac{\partial \tilde E_{j+1}} {\partial U^{(i)}} - \frac{\partial E_{j+1}} {\partial U^{(i)}} } \\
\lesssim & \sum_{t=1}^{j+1}\Bigbrace{\bignorms{\Delta U^{(t)}} + \bignorms{\Delta W^{(t)}}} + \bignormFro{\rho'_{j+1}\bigbrace{\tilde F_{j+1}} - \rho'_{j+1}\bigbrace{F_{j+1}}} + \bignormFro{\frac{\partial \tilde F_{j+1}} {\partial U^{(i)}} - \frac{\partial F_{j+1}} {\partial U^{(i)}}} \\
\lesssim & \sum_{t=1}^{j+1}\Bigbrace{\bignorms{\Delta U^{(t)}}+\bignorms{\Delta W^{(t)}}} + \bignormFro{\psi'_{j+1}\bigbrace{\tilde H^{(j)}} - \psi'_{j+1}\bigbrace{H^{(j)}}} + \bignormFro{\frac{\partial \tilde H^{(j)}} {\partial U^{(i)}} - \frac{\partial H^{(j)}} {\partial U^{(i)}}} \\
\lesssim & \sum_{t=1}^{j+1}\Bigbrace{\bignorms{\Delta U^{(t)}}+\bignorms{\Delta W^{(t)}}}. \tag{by Claim \ref{claim_perturb} and the induction step}
\end{align*}
The second and third steps are based on Claim \ref{claim_perturb}.
From repeatedly applying the above beginning with $j = i$ along with the base case of equation \eqref{eq_claim_grad_2}, we conclude that equation \eqref{eq_claim_grad_2} holds.
The proof of claim \ref{claim_grad} is complete.
\end{proof}
\begin{proof}[Proof of Proposition \ref{claim_hess}]
We will consider a fixed $i = 1,\dots,l-1$ and take induction over $j = i, \dots, l-1$.
We focus on the proof of equation \eqref{eq_claim_hess_1}, while the proof of equation \eqref{eq_claim_hess_2} will be similar.
To simplify the derivation, we use two notations for brevity.
Let
\begin{align*}
F_j = P_{_G} \psi_{j}\bigbrace{H^{(j-1)}} W^{(j)} \text{ and }
E_j = X U^{(j)} + \rho_{j}\bigbrace{F_j}.
\end{align*}
First, we consider the base case when $j = i$.
By the chain rule, we have:
We use the chain rule to get:
\begin{align*}
\frac {\partial^2 H^{(i)}} {\partial \bigbrace{W^{(i)}_{p,q}}^2}
= \phi''_{i}(E_i) \odot \frac{\partial E_i}{\partial W_{p,q}^{(i)}} \odot \frac{\partial E_i}{\partial W_{p,q}^{(i)}}
+ \phi'_{i}(E_i) \odot \rho''_{i}(F_i) \odot {\frac{\partial F_i}{\partial W_{p,q}^{(i)}}} \odot {\frac{\partial F_i}{\partial W^{(i)}_{p,q}}}.
\end{align*}
Hence, the Frobenius norm of the Hessian of $H^{(i)}$ with respect to $W_i$ under perturbation on $W$ and $U$ turns to
\begin{align*}
\bignormFro{\bH_{\cW}^{(i)} [\tilde H^{(i)}] - \bH_{\cW}^{(i)} [H^{(i)}]}
& \lesssim \bignormFro{\phi''_i\bigbrace{\tilde E_i} - \phi''_i\bigbrace{E_i} }
+ \bignormFro{\frac{\partial \tilde E_i} {\partial W^{(i)}} - \frac{\partial E_i} {\partial W^{(i)}} } + \bignormFro{\phi'_i\bigbrace{\tilde E_i} - \phi'_i\bigbrace{E_i} } \\
& + \bignormFro{\rho''_i\bigbrace{\tilde F_i} - \rho''_i\bigbrace{F_i} } + \bignormFro{\frac{\partial \tilde F_i} {\partial W^{(i)}} - \frac{\partial F_i} {\partial W^{(i)}} }.
\end{align*}
From Claim \ref{claim_perturb}, we know
\begin{align*}
\bignormFro{\phi''_i\bigbrace{\tilde E_i} - \phi''_i\bigbrace{E_i}} &\le \kappa_2 \bignormFro{\tilde E_i - E_i} \lesssim \bignorms{\Delta W^{(i)}} + \bignorms{\Delta U^{(i)}}, \\
\bignormFro{\phi'_i\bigbrace{\tilde E_i} - \phi'_i\bigbrace{E_i} } &\le \kappa_1 \bignormFro{\tilde E_i - E_i} \lesssim \bignorms{\Delta W^{(i)}} + \bignorms{\Delta U^{(i)}}, \\
\bignormFro{\rho''_i\bigbrace{\tilde F_i} - \rho''_i\bigbrace{F_i} } &\le \kappa_2 \bignormFro{\tilde F_i - F_i} \lesssim \bignorms{\Delta W^{(i)}} + \bignorms{\Delta U^{(i)}}.
\end{align*}
From Claim \ref{claim_grad}, we have
\begin{align*}
\bignormFro{\frac{\partial \tilde E_i} {\partial W^{(i)}} - \frac{\partial E_i} {\partial W^{(i)}} } & \lesssim \bignorms{\Delta W^{(i)}} + \bignorms{\Delta U^{(i)}}, \\
\bignormFro{\frac{\partial \tilde F_i} {\partial W^{(i)}} - \frac{\partial F_i} {\partial W^{(i)}} } & \lesssim \bignorms{\Delta W^{(i)}} + \bignorms{\Delta U^{(i)}}.
\end{align*}
Hence, we know that equation \eqref{eq_claim_hess_1} will be correct when $j=i$. Assuming that equation \eqref{eq_claim_hess_1} will be correct for any $j$ up to $j \ge i$, we can get the following steps, by taking another derivative of the first-order derivative, we can get the following steps:
\begin{small}
\begin{align*}
\frac {\partial^2 H^{(j+1)}} {\partial \bigbrace{W^{(i)}_{p,q}}^2}
=& \, \phi''_{j+1}(E_{j+1}) \odot \frac{\partial E_{j+1}}{\partial W_{p,q}^{(i)}} \odot \frac{\partial E_{j+1}}{\partial W_{p,q}^{(i)}}
+ \phi'_{j+1}(E_{j+1}) \odot \rho''_{j+1}(F_{j+1}) \odot \frac{\partial F_{j+1}}{\partial W_{p,q}^{(i)}} \odot \frac{\partial F_{j+1}}{\partial W_{p,q}^{(i)}} \\
& + \phi'_{j+1}(E_{j+1}) \odot \rho'_{j+1}(F_{j+1}) \odot {P_{_G} \Bigbrace{\psi''_{j+1}(H^{(j)}) \odot \frac{\partial H^{(j)}}{\partial W_{p,q}^{(i)}} \odot \frac{\partial H^{(j)}}{\partial W_{p,q}^{(i)}} + \psi'_{j+1}(H^{(j)}) \odot \frac{\partial^2 H^{(j)}}{\partial\bigbrace{W_{p,q}^{(i)}}^2}}W^{(j+1)}}.
\end{align*}
\end{small}%
Thus, the Frobenius norm of the Hessian of $H^{(j+1)}$ with respect to $W^{(i)}$ satisfies:
\begin{small}
\begin{align*}
& \bignormFro{\bH_{\cW}^{(i)} [\tilde H^{(j+1)}] - \bH_{\cW}^{(i)} [H^{(j+1)}]}
\lesssim \underbrace{\bignormFro{\phi''_{j+1}\bigbrace{\tilde E_{j+1}} - \phi''_{j+1}\bigbrace{E_{j+1}} }}_{A_1}
+ \underbrace{\bignormFro{\frac{\partial \tilde E_{j+1}} {\partial W^{(i)}} - \frac{\partial E_{j+1}} {\partial W^{(i)}} }}_{B_1} \\
+ & \underbrace{\bignormFro{\phi'_{j+1}\bigbrace{\tilde E_{j+1}} - \phi'_{j+1}\bigbrace{E_{j+1}} }}_{A_2}
+ \underbrace{\bignormFro{\rho''_{j+1}\bigbrace{\tilde F_{j+1}} - \rho''_{j+1}\bigbrace{F_{j+1}} }}_{A_3}
+ \underbrace{\bignormFro{\frac{\partial \tilde F_{j+1}} {\partial W^{(i)}} - \frac{\partial F_{j+1}} {\partial W^{(i)}} }}_{B_2}
+ \underbrace{\bignormFro{\rho'_{j+1}\bigbrace{\tilde F_{j+1}} - \rho'_{j+1}\bigbrace{F_{j+1}} }}_{A_4} \\
+ & \underbrace{\bignormFro{\psi''_{j+1}\bigbrace{\tilde H^{(j)}} - \psi''_{j+1}\bigbrace{H^{(j)}} }}_{A_5}
+ \underbrace{\bignormFro{ \frac{\partial \tilde H^{(j)}} {\partial W^{(i)}} - \frac{\partial H^{(j)}} {\partial W^{(i)}} }}_{B_3} + \underbrace{\bignormFro{\psi'_{j+1}\bigbrace{\tilde H^{(j)}} - \psi'_{j+1}\bigbrace{H^{(j)}}}}_{A_6}
+ \underbrace{\bignormFro{\bH_{\cW}^{(i)} [\tilde H^{(j)}] - \bH_{\cW}^{(i)} [H^{(j)}]}}_{C_1}.
\end{align*}
\end{small}%
Similarly, by Claim \ref{claim_perturb}, we get
\begin{align*}
A_i \lesssim \sum_{t=1}^{j+1}\Bigbrace{\bignorms{\Delta W^{(t)}} + \bignorms{\Delta U^{(t)}}}, \text{ for } 1\le i\le 6.
\end{align*}
By Claim \ref{claim_grad}, we get
\begin{align*}
B_i \lesssim \sum_{t=1}^{j+1}\Bigbrace{\bignorms{\Delta W^{(t)}} + \bignorms{\Delta U^{(t)}}}, \text{ for } 1\le i\le 3.
\end{align*}
By the induction hypothesis, $C_1$ is also less than the above quantity. %
From repeatedly applying the above beginning with $j = i$ along with the base case of equation \eqref{eq_claim_hess_1}, we conclude that equation \eqref{eq_claim_hess_1} holds.
\smallskip
Next, we consider the base case for equation \eqref{eq_claim_hess_2}. For the base case $j=i$, from the chain rule, we get:
\begin{align*}
\bignormFro{\bH_{\cU}^{(i)} [\tilde H^{(i)}] - \bH_{\cU}^{(i)} [H^{(i)}]}
\lesssim & \bignormFro{\phi''_i\bigbrace{\tilde E_i} - \phi''_i\bigbrace{E_i} } + \bignormFro{\frac{\partial \tilde E_i} {\partial U^{(i)}} - \frac{\partial E_i} {\partial U^{(i)}} } \\
\lesssim & \kappa_2 \bignormFro{\tilde E_i - E_i} + {\bignorms{\Delta W^{(i)}} + \bignorms{\Delta U^{(i)}}} \tag{by Claim \ref{claim_grad}} \\
\lesssim & {\bignorms{\Delta W^{(i)}} + \bignorms{\Delta U^{(i)}}} \tag{by Claim \ref{claim_perturb}}.
\end{align*}
Hence, we know that equation \eqref{eq_claim_hess_2} will be correct when $j=i$. Assuming that equation \eqref{eq_claim_hess_2} will be correct for any $j$ up to $j \ge i$, we obtain the induction step
%
similar to the proof of equation \eqref{eq_claim_hess_1}, by Claim \ref{claim_perturb}, Claim \ref{claim_grad}, and the induction hypothesis, we conclude that equation \eqref{eq_claim_hess_2} holds.
\end{proof}
\subsection{Proof for message passing graph neural networks}\label{app_mpgnn}
Next, we present proof for message-passing graph neural networks.
First, in Appendix \ref{proof_trace}, we derive the trace bound, which separates the trace of the Hessian matrix into each entry of the weight matrices.
Then in Appendix \ref{proof_first} and \ref{proof_second}, we provide bounds on the first-order and second-order derivatives of the Hessian matrix.
Last, in Appendix \ref{proof_theorem}, building on these results, we finish the proof of Theorem \ref{thm_mpgnn}.
\subsubsection{Proof of Lemma \ref{lemma_trace_hess}}\label{proof_trace}
\begin{proof}[Proof of Lemma \ref{lemma_trace_hess}]
Notice that $f(X, G) = H^{(l)}$.
Recall that in each layer for $1\le i\le l-1$, there are two weight matrices, a $d_{i-1}$ by $d_i$ matrix denoted as $W^{(i)}$, and a $d_0$ by $U^{(i)}$ matrix denoted as $U^{(i)}$.
To deal with the trace of the Hessian $\bH^{(i)}$, we first notice that there are two parts in the trace:
\begin{align*}
\bigabs{\tr\big[\bH^{(i)}[\ell(H^{(l)}, y)]\big]}
\le \underbrace{\bigabs{\sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i}\frac{\partial^2 \ell(H^{(l)}, y)}{\partial \big(W^{(i)}_{p,q}\big)^2}}}_{T_1}
+ \underbrace{\bigabs{\sum_{p=1}^{d_0}\sum_{q=1}^{d_i} \frac{\partial^2 \ell(H^{(l)}, y)}{\partial\bigbrace{U_{p,q}^{(i)}}^2}}}_{T_2}.
\end{align*}
We can inspect $T_1$ and $T_2$ in the above step separately.
First, we expand out the second-order derivatives in $T_1$.
This will involve two terms by the chain rule.
\begin{align}
T_1 =\,& \bigabs{\sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \Bigg\langle\frac{\partial\ell(H^{(l)},y)}{\partial H^{(l)}},\frac{\partial^2 H^{(l)}}{\partial \big(W^{(i)}_{p,q}\big)^2}\Bigg\rangle}
+ \bigabs{ \sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \Bigg\langle \frac{\partial^2 \ell(H^{(l)}, y)}{\partial \big(H^{(l)}\big)^2} \frac{\partial H^{(l)}}{\partial W^{(i)}_{p,q}}, \frac{\partial H^{(l)}}{\partial W^{(i)}_{p,q}} \Bigg\rangle} \nonumber \\
\leq\,& \sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i}\bignorm{\frac{\partial\ell(H^{(l)}, y)}{\partial H^{(l)}}}\bignorm{\frac{\partial^2 H^{(l)}}{\partial \big(W^{(i)}_{p,q}\big)^2}} + \sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignorms{\frac{\partial^2 \ell(H^{(l)}, y)}{\partial \big(H^{(l)}\big)^2}}\bignorm{\frac{\partial H^{(l)}}{\partial W^{(i)}_{p,q}}}^2 \nonumber \\
\leq\,& \kappa_0 \sqrt{k} \sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignorm{\frac{\partial^2 H^{(l)}}{\partial \big(W^{(i)}_{p,q}\big)^2}} + \kappa_1 k \sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignorm{\frac{\partial H^{(l)}}{\partial W^{(i)}_{p,q}}}^2. \label{eq_lemma_loss}
\end{align}
The last step is because $\ell(\cdot)$ is $\kappa_0$-Lipschitz continuous and $\ell'(\cdot)$ is $\kappa_1$-Lipschitz continuous, under Assumption \ref{ass_1}.
Thus, the Euclidean norm of ${\frac{\partial \ell(H^{(l)}, y)}{\partial H^{(l)}}} $ is at most $\kappa_0 \sqrt k$, since $H^{(l)}$ is a $k$-dimensional vector.
Recall from step \eqref{eq_mpgnn_readout} that $H^{(l)} = \frac{1}{n}\bm{1}_n^{\top} H^{(l-1)}W^{(l)}$. Hence, we have
\begin{align}
\bignorm{\frac{\partial H^{(l)}}{\partial W^{(i)}_{p,q}}}
&= \bignorm{\frac{1}{n} \bm{1}_n^{\top} \frac{\partial H^{(l-1)}}{\partial W^{(i)}_{p,q}}W^{(l)}} \nonumber \\
&\leq \bignorm{\frac{1}{n} \bm{1}_n^{\top}} \bignorms{\frac{\partial H^{(l-1)}}{\partial W^{(i)}_{p,q}}W^{(l)}}\leq \frac{1}{\sqrt{n}}\bignorms{\frac{\partial H^{(l-1)}}{\partial W^{(i)}_{p,q}}} \bignorms{W^{(l)}}. \label{eq_lemma_readout_1}
\end{align}
In a similar vein, the Euclidean norm of ${\frac{\partial^2 \ell(H^{(l)}, y)}{\partial (H^{(l)})^2}}$ is at most $\kappa_1 k$, since the second-order derivatives become a $k$ by $k$ matrix. Then, we get
\begin{align}
\bignorm{\frac{\partial^2 H^{(l)}}{\partial \bigbrace{W^{(i)}_{p,q}}^2}} &= \bignorm{\frac{1}{n} \bm{1}_n^{\top} \frac{\partial^2 H^{(l-1)}}{\partial \bigbrace{W^{(i)}_{p,q}}^2}W^{(l)}} \nonumber \\
&\leq \bignorm{\frac{1}{n} \bm{1}_n^{\top}} \bignorms{\frac{\partial^2 H^{(l-1)}}{\partial \bigbrace{W^{(i)}_{p,q}}^2}W^{(l)}}\leq \frac{1}{\sqrt{n}}\bignorms{\frac{\partial^2 H^{(l-1)}}{\partial \bigbrace{W^{(i)}_{p,q}}^2}} \bignorms{W^{(l)}}. \label{eq_lemma_readout_2}
\end{align}
After substituting equations \eqref{eq_lemma_readout_1} and \eqref{eq_lemma_readout_2} into equation \eqref{eq_lemma_loss}, we get:
\begin{align*}
T_1 &\leq \frac{\kappa_0 \sqrt{k}}{\sqrt{n}} \bignorms{W^{(l)}} \sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignorms{\frac{\partial^2 H^{(l-1)}}{\partial \big(W^{(i)}_{p,q}\big)^2}} + \frac {\kappa_1 k} n \bignorms{W^{(l)}}^2 \sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignorms{\frac{\partial H^{(l-1)}}{\partial W^{(i)}_{p,q}}}^2. \\
&\leq \frac{\kappa_0 \sqrt{k}}{\sqrt{n}} \bignorms{W^{(l)}} \sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignormFro{\frac{\partial^2 H^{(l-1)}}{\partial \big(W^{(i)}_{p,q}\big)^2}} + \frac {\kappa_1 k} n \bignorms{W^{(l)}}^2 \sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i}\bignormFro{\frac{\partial H^{(l-1)}}{\partial W_{p,q}^{(i)}}}^2.
\end{align*}
The proof for the case of $T_2$ concerning $U^{(i)}$ follows the same steps as above.
Without belaboring all the details, one can get that
\begin{align}
T_2 \le \frac{\kappa_0 \sqrt k}{\sqrt n} \bignorms{W^{(l)}} \sum_{p=1}^{d_{0}}\sum_{q=1}^{d_i} \bignormFro{\frac{\partial^2 H^{(l-1)}}{\partial\bigbrace{U_{p,q}^{(i)}}^2}}
+ \frac{\kappa_1 k}{n} \bignorms{W^{(l)}}^2 \sum_{p=1}^{d_0}\sum_{q=1}^{d_{i}}\bignormFro{\frac{\partial H^{(l-1)}}{\partial U_{p,q}^{(i)}}}^2.
\end{align}
This completes the proof of Lemma \ref{lemma_trace_hess}.
\end{proof}
\subsubsection{Dealing with first-order derivatives}\label{proof_first}
Based on Lemma \ref{lemma_trace_hess}, the analysis involves two parts,
one on the first-order derivatives of $H^{(j)}$ for all layers $j$,
and the other on the second-order derivatives of $H^{(j)}$ for all layers $j$.
\begin{proposition}\label{prop_first_mpgnn}
In the setting of Theorem \ref{thm_mpgnn},
the first-order derivative of $H^{(j)}$ with respect to $W^{(i)}$ and $U^{(i)}$ satisfies the following, for any $i = 1,\dots,l-1$ and $j\ge i$:
\begin{align}
\bignormFro{\frac{\partial H^{(j)}} {\partial W^{(i)}}}
\le\,& \kappa_0^{3(j-i+1)} \sqrt{d_i} \bignorms{P_{_G}}^{j-i+1} \bignormFro{H^{(i-1)}} \prod_{t=i+1}^j \bignorms{W^{(t)}}, \label{eq_deri_W} \\
\bignormFro{\frac{\partial H^{(j)}} {\partial U^{(i)}}} \le\,& \kappa_0^{3(j-i)+1} \sqrt{d_i} \bignorms{P_{_G}}^{j-i+1} \bignormFro{X} \prod_{t=i+1}^j \bignorms{W^{(t)}}. \label{eq_deri_U}
\end{align}
\end{proposition}
\begin{proof}
We will consider a fixed $i = 1,\dots,l-1$ and take induction over $j = i, \dots, l-1$.
We focus on the proof of equation \eqref{eq_deri_W}, while the proof of equation \eqref{eq_deri_U} will be similar.
First, we consider the base case when $j = i$.
Let $W^{(i)}_{p,q}$ be the $(p,q)$-th entry of $W^{(i)}$, for any valid indices $p$ and $q$.
Recall that $\phi_i(\cdot)$ is $\kappa_0$-Lipschitz continuous from Assumption \ref{ass_1}, for any $i = 1,\dots, l-1$.
Therefore,
\begin{align}
\bignormMax{\phi'_i(x)} \le \kappa_0,~~
\bignormMax{\psi'_i(x)} \le \kappa_0,~~\text{and}~~
\bignormMax{\rho'_i(x)} \le \kappa_0. \label{eq_deri}
\end{align}
For each $(p, q)$-entry of $W^{(i)}$, by the chain rule, we have:
\begin{align}
\bignormFro{\frac {\partial H^{(i)}} {\partial W^{(i)}_{p,q}}}
&= \bignormFro{\phi'_i\bigbrace{X U^{(i)} + \rho_i\bigbrace{P_{_G} \psi_i(H^{(i-1)}) W^{(i)}}}
\odot \frac{\partial \bigbrace{X U^{(i)} + \rho_i\bigbrace{P_{_G} \psi_i(H^{(i-1)}) W^{(i)}}}} {\partial W^{(i)}_{p,q}}} \label{eq_W_prime} \\
&\le \kappa_0\bignormFro{\frac{\partial \rho_i\bigbrace{P_{_G} \psi_i(H^{(i-1)}) W^{(i)}}} {\partial W^{(i)}_{p,q}}} \tag{by equation \eqref{eq_deri}} \\
&= \kappa_0\bignormFro{\rho'_i\bigbrace{P_{_G} \psi_i(H^{(i-1)}) W^{(i)}} \odot \frac{\partial\bigbrace{P_{_G} \psi_i(H^{(i-1)}) W^{(i)}}} {W^{(i)}_{p,q}}} \nonumber \\
&\le \kappa_0^2\bignormFro{\frac{\partial \bigbrace{P_{_G} \psi_i(H^{(i-1)}) W^{(i)}}} {\partial W^{(i)}_{p,q}}}. \tag{again by equation \eqref{eq_deri}}
\end{align}
Notice that only the $q$-th column of the derivative $P_{_G} \psi_i(H^{(i-1)}) W^{(i)}$ is nonzero, which is equal to the $p$'th column of $P_{_G} \psi_i(H^{(i-1)})$. Thus, the Jacobian of $H^{(i)}$ over $W^{(i)}$ satisfies:
\begin{align}
\bignormFro{\frac{\partial H^{(i)}} {\partial W^{(i)}}}
= \sqrt{\sum_{p=1}^{d_{i-1}} \sum_{q=1}^{d_i} \bignormFro{\frac {\partial H^{(i)}} {\partial W_{p,q}^{(i)}}}^2}
\le \kappa_0^2 \sqrt{\sum_{p=1}^{d_{i-1}} \sum_{q=1}^{d_i} \bignormFro{\frac {\partial\bigbrace{P_{_G} \psi_i(H^{(i-1)}) W^{(i)}}} {W_{p,q}^{(i)}}}^2}
= \kappa_0^2 \sqrt{d_i} \bignormFro{P_{_G} \psi_i(H^{(i-1)})}. \label{eq_mpgnn_base}
\end{align}
Therefore, the above equation \eqref{eq_mpgnn_base} implies that equation \eqref{eq_deri_W} holds in the base case.
Next, we consider the induction step from layer $j$ to layer $j+1$. The derivative of $H^{(j+1)}$ with respect to $W^{(i)}_{p,q}$ satisfies:
\begin{align*}
\bignormFro{\frac {\partial H^{(j+1)}} {\partial W^{(i)}_{p,q}}}
&= \bignormFro{\phi'_{j+1}\bigbrace{X U^{(j+1)} + \rho_{j+1}\bigbrace{P_{_G} \psi_{j+1}(H^{(j)}) W^{(j+1)}}}
\odot \frac{\partial \bigbrace{X U^{(j+1)} + \rho_{j+1}\bigbrace{P_{_G} \psi_{j+1}(H^{(j)}) W^{(j+1)}}}} {\partial W^{(i)}_{p,q}}} \\
&\le \kappa_0\bignormFro{\frac{\partial\rho_{j+1}\bigbrace{P_{_G} \psi_{j+1}(H^{(j)}) W^{(j+1)}}} {\partial W^{(i)}_{p,q}}} \tag{by equation \eqref{eq_deri}} \\
&\le \kappa_0\bignormFro{\rho'_{j+1}\bigbrace{P_{_G} \psi_{j+1}(H^{(j)}) W^{(j+1)}} \odot \frac{\partial\bigbrace{P_{_G} \psi_{j+1}(H^{(j)}) W^{(j+1)}}} {\partial W^{(i)}_{p,q}}} \\
&\le \kappa_0^2\bignormFro{P_{_G} \frac{\partial \psi_{j+1}(H^{(j)}) } {\partial W^{(i)}_{p,q}}W^{(j+1)}} \tag{again by equation \eqref{eq_deri}}
\end{align*}
By applying equation \eqref{eq_deri} w.r.t. $\psi'_{j+1}$, The above is less than:
\begin{align*}
\kappa_0^2\bignorms{P_{_G}}\bignormFro{\psi_{j+1}'(H^{(j)}) \odot \frac{\partial H^{(j)} } {\partial W^{(i)}_{p,q}}}\bignorms{W^{(j+1)}}
\le \kappa_0^3\bignorms{P_{_G}}\bignorms{W^{(j+1)}}\bignormFro{\frac{\partial H^{(j)} } {\partial W^{(i)}_{p,q}}}.
\end{align*}
Hence, the Jacobian of $H^{(j+1)}$ with respect to $W^{(i)}$ satisfies:
\begin{align*}
\bignormFro{\frac {\partial H^{(j+1)}} {\partial W^{(i)}}} \le \kappa_0^3\bignorms{P_{_G}}\bignorms{W^{(j+1)}}\bignormFro{\frac{\partial H^{(j)} } {\partial W^{(i)}}}.
\end{align*}
From repeatedly applying the above beginning with $j = i$ along with the base case of equation \eqref{eq_mpgnn_base}, we conclude that equation \eqref{eq_deri_W} holds.
\smallskip
Next, we consider the base case for equation \eqref{eq_deri_U}. For each $(p, q)$-th entry of $U^{(i)}$, from the chain rule we get:
\begin{align*}
\bignormFro{\frac{\partial H^{(i)}} {\partial U^{(i)}_{p, q}}}
&= \bignormFro{\phi'_i\Bigbrace{X U^{(i)} + \rho_i\bigbrace{P_{_G} \psi_i(H^{(i-1)}) W^{(i)}}} \odot \frac{\partial\Bigbrace{X U^{(i)} + \rho_i\bigbrace{P_{_G} \psi_i(H^{(i-1)}) W^{(i)}}}} {\partial U^{(i)}_{p,q}}} \\
&\le \kappa_0 \bignormFro{\frac {\partial (X U^{(i)})} {\partial U^{(i)}_{p, q}}}. \tag{by equation \eqref{eq_deri}}
\end{align*}
Therefore, by summing over $p=1,\dots,d_0$ and $q=1,\dots,d_i$, we get:
\begin{align}
\bignormFro{\frac {\partial H^{(i)}} {\partial U^{(i)}}}
&= \sqrt{\sum_{p=1}^{d_0} \sum_{q=1}^{d_i} \bignormFro{\frac {\partial H^{(i)}} {\partial U^{(i)}_{p, q}}}^2} \nonumber \\
&\le \kappa_0 \sqrt{\sum_{p=1}^{d_0} \sum_{q=1}^{d_i} \bignormFro{\frac {\partial(X U^{(i)})} {\partial U^{(i)}_{p,q}}}^2}
= \kappa_0 \sqrt{d_i} \bignormFro{X}. \label{eq_base_U}
\end{align}
Going from layer $i$ to layer $j+1$, the derivative of $H^{(j+1)}$ with respect to $U^{(i)}_{p,q}$ satisfies:
\begin{align*}
\bignormFro{\frac{\partial H^{(j+1)}} {\partial U^{(i)}_{p, q}}}
&= \bignormFro{\phi'_{j+1}\bigbrace{X U^{(j+1)} + \rho_{j+1}\bigbrace{P_{_G} \psi_{j+1}(H^{(j)}) W^{(j+1)}}} \odot \frac{\partial\bigbrace{X U^{(j+1)} + \rho_{j+1}\bigbrace{P_{_G} \psi_{j+1}(H^{(j)}) W^{(j+1)}}}} {\partial U^{(i)}_{p,q}}} \\
&\le \kappa_0 \bignormFro{\frac {\partial \rho_{j+1}\bigbrace{P_{_G} \psi_{j+1}(H^{(j)}) W^{(j+1)}}} {\partial U^{(i)}_{p, q}}} \tag{by equation \eqref{eq_deri} w.r.t. $\phi'_{j+1}$}\\
&\le \kappa_0^3\bignorms{P_{_G}}\bignorms{W^{(j+1)}}\bignormFro{\frac{\partial H^{(j)} } {\partial U^{(i)}_{p,q}}}. \tag{by equation \eqref{eq_deri} w.r.t. $\rho'_{j+1}, \psi'_{j+1}$}
\end{align*}
Hence, the Jacobian of $H^{(j+1)}$ with respect to $U^{(i)}$ satisfies:
\begin{align*}
\bignormFro{\frac {\partial H^{(j+1)}} {\partial U^{(i)}}} \le \kappa_0^3\bignorms{P_{_G}}\bignorms{W^{(j+1)}}\bignormFro{\frac{\partial H^{(j)} } {\partial U^{(i)}}}.
\end{align*}
By repeatedly applying the above step beginning with the base case of equation \eqref{eq_base_U}, we have proved that equation \eqref{eq_deri_U} holds.
The proof of Proposition \ref{prop_first_mpgnn} is complete.
\end{proof}
\subsubsection{Deal with second-order derivatives}\label{proof_second}
In the second part towards showing Theorem \ref{thm_mpgnn} for MPNNs, we look at second-order derivatives of the embeddings.
This will appear later when we deal with the trace of the Hessian.
A fact that we will use throughout the proof is
\begin{align}
\bignormMax{\phi''_i(x)} \le \kappa_1,~~
\bignormMax{\psi''_i(x)} \le \kappa_1,~~\text{and}~~
\bignormMax{\rho''_i(x)} \le \kappa_1, \label{eq_deri_sec}
\end{align}
for any $x$ and $i = 1,\dots,l-1$.
This is because $\phi'_i, \psi_i', $ and $\rho_i'$ are all $\kappa_1$-Lipschitz continuous from Assumption \ref{ass_1}.
\begin{proposition}\label{prop_second_mpgnn}
In the setting of Theorem \ref{thm_mpgnn},
the second-order derivative of $H^{(l)}$ with respect to $W^{(i)}$ and $U^{(i)}$ satisfies the following, for any $i = 1,\dots,l-1$ and any $j= i,\dots,l-1$:
{\begin{align}
\sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignormFro{\frac{\partial^2 H^{(j)}}{\bigbrace{W_{p,q}^{(i)}}^2}}
&\le C_{i,j} \kappa_1 d_i \max(\bignorms{P_{_G}}^{j-i+2}, \bignorms{P_{_G}}^{2(j-i+1)})
\bignormFro{H^{(i-1)}}^2
\prod_{t=i+1}^{j} s_t^2, \label{eq_second_W} \\
\sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignormFro{\frac{\partial^2 H^{(j)}}{\bigbrace{U_{p,q}^{(i)}}^2}}
&\le \hat{C}_{i,j} \kappa_1 d_i \max(\bignorms{P_{_G}}^{j-i}, \bignorms{P_{_G}}^{2(j-i)}) \bignormFro{X}^2 \prod_{t=i+1}^j s_t^2, \label{eq_second_U}
\end{align}}%
where $C_{i,j}$
$$ C_{i,j} = \left\{
\begin{aligned}
&\kappa_0^{3(j-i+1)}\frac{\kappa_0^{3(j-i)+2} - 1}{\kappa_0 - 1}, & \kappa_0 \neq 1, \\
&3(j - i) + 2, & \kappa_0 = 1,
\end{aligned}
\right.
$$
and $\hat{C}_{i,j}$
$$ \hat{C}_{i,j} = \left\{
\begin{aligned}
&\kappa_0^{3(j-i)}\frac{\kappa_0^{3(j-i)+1} - 1}{\kappa_0 - 1}, & \kappa_0 \neq 1, \\
&3(j - i) + 1, & \kappa_0 = 1.
\end{aligned}
\right.
$$
are fixed constants that depend on the Lipschitz-continuity of the activation mappings.
\end{proposition}
\begin{proof}
First, we will consider equation \eqref{eq_second_W}.
To simplify the derivation, we introduce two notations for brevity.
Let
\begin{align*}
F_j = P_{_G} \psi_{j}\bigbrace{H^{(j-1)}} W^{(j)} \text{ and }
E_j = X U^{(j)} + \rho_{j}\bigbrace{F_j}.
\end{align*}
In the base case when $j = i$, from the first-order derivative in equation \eqref{eq_W_prime}, we use the chain rule to get:
\begin{align}
\frac {\partial^2 H^{(i)}} {\partial \bigbrace{W^{(i)}_{p,q}}^2}
=& \phi''_{i}(E_i) \odot \frac{\partial E_i}{\partial W_{p,q}^{(i)}} \odot \frac{\partial E_i}{\partial W_{p,q}^{(i)}}
+ \phi'_{i}(E_i) \odot \rho''_{i}(F_i) \odot {\frac{\partial F_i}{\partial W_{p,q}^{(i)}}} \odot {\frac{\partial F_i}{\partial W^{(i)}_{p,q}}}. \label{eq_Hi_chain}
\end{align}
Using equation \eqref{eq_deri_sec}, the maximum entries of $\phi''_{i}(\cdot), \rho''_{i}(\cdot)$ are at most $\kappa_1$.
Using equation \eqref{eq_deri}, the maximum entry of
$\phi'_{i}(\cdot)$ is at most $\kappa_0$.
Notice that the derivative of $E_i$ can be reduced to the derivative of $F_i$ as follows:
\begin{align}
\bignormFro{\frac{\partial E_i}{\partial W_{p,q}^{(i)}}}^2
= \bignormFro{\rho'_{i}(F_i) \odot \frac{\partial F_1}{\partial W_{p,q}^{(i)}}}^2
\le \kappa_0^2 \bignormFro{\frac{\partial F_i}{\partial W_{p,q}^{(i)}}}^2. \label{eq_second_p2}
\end{align}
Therefore, based on the conditions for first- and second-order derivatives (cf. \eqref{eq_deri} and \eqref{eq_deri_sec}), the Frobenius norm of the above equation \eqref{eq_Hi_chain} is at most:
\begin{align*}
\bignormFro{\frac{\partial^2 H^{(i)}} {\partial\bigbrace{W_{p,q}^{(i)}}^2}}
\le \kappa_1 \bignormFro{\frac{\partial E_i} {\partial W_{p,q}^{(i)}}}^2 + \kappa_0\kappa_1 \bignormFro{\frac{\partial F_i}{\partial W_{p,q}^{(i)}}}^2
\le (\kappa_0 + 1)\kappa_0\kappa_1 \bignormFro{\frac{\partial F_i}{\partial W_{p,q}^{(i)}}}^2.
\end{align*}
Notice that the derivative of $F_i$ with respect to $W^{(i)}_{p,q}$ is nonzero only in the $q$-th column of $F_i$, and is equal to the $p$-th column of $P_{_G} g_{i}(H^{(i-1)})$. Therefore, by summing over $p = 1,\dots,d_{i-1}$ and $q = 1,\dots,d_i$, we get:
\begin{align*}
\sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignormFro{\frac{\partial F_{i}}{\partial\bigbrace{W_{p,q}^{(i)}}^2}}^2
\le d_i \bignormFro{P_{_G} \psi_i(H^{(i-1)})}^2.
\end{align*}
Therefore, we have derived the base case when $j = i$ as:
\begin{align}
\bignormFro{\frac{\partial^2 H^{(i)}}{\partial\bigbrace{W_{p,q}^{(i)}}^2}}
\le (\kappa_0 + 1) \kappa_0^3 \kappa_1 d_i \bignorms{P_{_G}}^2 \bignormFro{H^{(i-1)}}^2. \label{eq_second_base_W}
\end{align}
Next, we consider the induction step from layer $j$ to layer $j+1$. This step is similar to the base case but also differs since $H^{(j)}$ is now dependent on $W^{(i)}$.
Recall that the second-order derivatives satisfy equation \eqref{eq_deri_sec}.
Based on the Lipschitz-continuity conditions, the Frobenius norm of the second-order derivatives satisfies:
\begin{align}
\bignormFro{\frac{\partial^2 H^{(j+1)}}{\partial\bigbrace{W_{p,q}^{(i)}}^2}}
&\le \kappa_1 \bignormFro{\frac{\partial E_{j+1}}{\partial W_{p,q}^{(i)}}}^2
+ \kappa_0\kappa_1 \bignormFro{\frac{\partial F_{j+1}}{\partial W_{p,q}^{(i)}}}^2
+ \kappa_0^2 \bignorms{P_{_G}} \bignorms{W^{(j+1)}} \Bigbrace{\kappa_1 \bignormFro{\frac{\partial H^{(j)}}{\partial W_{p,q}^{(i)}}}^2 + \kappa_0 \bignormFro{\frac {\partial^2 H^{(j)}} {\partial \bigbrace{W_{p,q}^{(i)}}^2}}} \nonumber \\
&\le (\kappa_0 + 1)\kappa_0\kappa_1 \bignormFro{\frac {\partial F_{j+1}} {\partial W_{p,q}^{(i)}}}^2
+ \kappa_0^2\bignorms{P_{_G}} \bignorms{W^{(j+1)}} \Bigbrace{\kappa_1\bignormFro{\frac{H^{(j)}}{\partial W_{p,q}^{(i)}}}^2
+ \kappa_0\bignormFro{\frac {\partial^2 H^{(j)}} {\partial\bigbrace{W_{p,q}^{(i)}}^2}}}. \label{eq_second_p1}
\end{align}
The last step follows similarly as equation \eqref{eq_second_p2}.
For the derivative of $F_{j+1}$, using the chain rule, we get:
\begin{align*}
\bignormFro{\frac{\partial F_{j+1}}{\partial W_{p,q}^{(i)}}}^2
&= \bignormFro{P_{_G} \frac {\partial \psi_{j+1}(H^{(j)})} {\partial W_{p,q}^{(i)}} W^{(j+1)}}^2 \\
&\le \bignorms{P_{_G}}^2 \bignorms{W^{(j+1)}}^2 \bignormFro{\frac{\partial \psi_{j+1}(H^{(j)})}{\partial W_{p,q}^{(i)}}}^2 \\
&\le \bignorms{P_{_G}}^2 \bignorms{W^{(j+1)}}^2 \bignormFro{\psi'_{j+1}(H^{(j)}) \odot \frac{\partial H^{(j)}}{\partial W_{p,q}^{(i)}}}^2 \\
&\le \kappa_0^2 \bignorms{P_{_G}}^2 \bignorms{W^{(j+1)}}^2 \bignormFro{\frac {\partial H^{(j)}} {\partial W_{p,q}^{(i)}}}^2.
\end{align*}
Therefore, combining the above with equations \eqref{eq_second_p1} together, we get the following result:
\begin{align*}
\bignormFro{\frac{\partial^2 H^{(j+1)}}{\partial\bigbrace{W_{p,q}^{(i)}}^2}}
\le\,& \Bigbrace{(\kappa_0+1)\kappa_0^3\kappa_1 \bignorms{P_{_G}}^2 \bignorms{W^{(j+1)}}^2 + \kappa_0^2 \kappa_1 \bignorms{P_{_G}} \bignorms{W^{(j+1)}}} \bignormFro{\frac {\partial H^{(j)}} {\partial W_{p,q}^{(i)}}}^2 \nonumber \\
&+ \kappa_0^3 \bignorms{P_{_G}} \bignorms{W^{(j+1)}} \bignormFro{\frac {\partial^2 H^{(j)}} {\partial \bigbrace{W^{(i)}_{p,q}}^2}} \nonumber \\
\le& \max\Bigbrace{\bignorms{P_{_G}}, \bignorms{P_{_G}}^2}s_{j+1}^2
\Bigbrace{(\kappa_0^2+\kappa_0+1)\kappa_0^2\kappa_1\bignormFro{\frac {\partial H^{(j)}} {\partial W_{p,q}^{(i)}}}^2
+ \kappa_0^3 \bignormFro{\frac {\partial^2 H^{(j)}} {\partial\bigbrace{W_{p,q}^{(i)}}^2}}}. %
\end{align*}
Based on equation \eqref{eq_deri_W} of Proposition \eqref{prop_first_mpgnn}, the first-order derivative of $H^{(j)}$ satisfies:
\begin{align}
\sum_{p=1}^{d_{i-1}} \sum_{q=1}^{d_i} \bignormFro{\frac{\partial H^{(j)}} {\partial W_{p,q}^{(i)}}}^2 \le \kappa_0^{6(j-i+1)}{d_i} \bignorms{P_{_G}}^{2(j-i+1)} \bignorm{H^{(i-1)}}^2 \prod_{t=i+1}^j s_t^2. \label{eq_mpgnn_second_base}
\end{align}
Applying equation \eqref{eq_mpgnn_second_base} to
the above (and summing over $p = 1,\dots, d_{i-1}$ and $q = 1,\dots,d_i$) forms the induction step for showing equation \eqref{eq_second_W}:
{\small\begin{align*}
\sum_{p=1}^{d_{i-1}} \sum_{q=1}^{d_i} \bignormFro{\frac {\partial^2 H^{(j+1)}} {\partial \bigbrace{W_{p,q}^{(i)}}^2}}
\le\,& \frac{\kappa_0^3 - 1}{\kappa_0 - 1} \kappa_0^{6(j-i+1)+2} \kappa_1 d_i \max\Bigbrace{\bignorms{P_{_G}}^{2(j-i)+3}, \bignorms{P_{_G}}^{2(j-i)+4}} \bignormFro{H^{(i-1)}}^2 \prod_{t=i+1}^{j+1} s_t^2 \\
&+ \kappa_0^3\max\bigbrace{\bignorms{P_{_G}}, \bignorms{P_{_G}}^2} s_{j+1}^2
\sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i}\bignormFro{\frac{\partial^2 H^{(j)}}{\partial\bigbrace{W_{p,q}^{(i)}}^2}}.
\end{align*}}%
By repeatedly applying the induction step along with the base case in equation \eqref{eq_second_base_W}, we have shown that equation \eqref{eq_second_W} holds:
\begin{align}
\sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignormFro{\frac{\partial^2 H^{(j)}}{\bigbrace{W_{p,q}^{(i)}}^2}}
\le C_{i,j} \kappa_1 d_i \max(\bignorms{P_{_G}}^{j-i+2}, \bignorms{P_{_G}}^{2(j-i+1)})
\bignormFro{H^{(i-1)}}^2
\prod_{t=i+1}^{j} s_t^2, \label{eq_conclude_W}
\end{align}
where $C_{i,j}$ satisfies the following equation:
$$ C_{i,j} = \left\{
\begin{aligned}
&\kappa_0^{3(j-i+1)}\frac{\kappa_0^{3(j-i)+2} - 1}{\kappa_0 - 1}, & \kappa_0 \neq 1, \\
&3(j - i) + 2, & \kappa_0 = 1.
\end{aligned}
\right.
$$
\smallskip
In the second part of the proof, we consider equation \eqref{eq_second_U} similar to the first part.
However, the analysis will be significantly simpler.
We first consider the base case. Similar to equation \eqref{eq_Hi_chain}, the second-order derivative of $H^{(i)}$ over $W^{(i)}_{p,q}$ satisfies, for any $p = 1,\dots, d_{0}$ and $q = 1,\dots, d_i$:
\begin{align*}
\bignormFro{\frac{\partial^2 H^{(i)}}{\partial\bigbrace{U_{p,q}^{(i)}}^2}}
= \bignorm{\phi_i''(E_i) \odot \frac{\partial E_i}{\partial U^{(i)}_{p,q}} \odot \frac{\partial E_i}{\partial U^{(i)}_{p,q}}}
\le \kappa_1 \bignormFro{\frac{\partial(X U^{(i)})} {\partial U^{(i)}_{p,q}}}^2.
\end{align*}
Therefore, by summing up the above over all $p$ and $q$, we get the base case result:
\begin{align}
\sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignormFro{\frac{\partial^2 H^{(i)}}{\partial\bigbrace{U_{p,q}^{(i)}}^2}}
\le \kappa_1 d_i \bignormFro{X}^2.
\end{align}
Next, we consider the induction step from layer $j$ to layer $j+1$.
This step follows the same analysis until equation \eqref{eq_conclude_W}, from which we can similarly derive that:
\begin{align}
\sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignormFro{\frac{\partial^2 H^{(j)}}{\bigbrace{U_{p,q}^{(i)}}^2}}
\le \hat{C}_{i,j} \kappa_1 d_i \max(\bignorms{P_{_G}}^{j-i}, \bignorms{P_{_G}}^{2(j-i)}) \bignormFro{X}^2 \prod_{t=i+1}^j s_t^2.
\end{align}
where $\hat{C}_{i,j}$ satisfies the following equation:
$$ \hat{C}_{i,j} = \left\{
\begin{aligned}
&\kappa_0^{3(j-i)}\frac{\kappa_0^{3(j-i)+1} - 1}{\kappa_0 - 1}, & \kappa_0 \neq 1, \\
&3(j - i) + 1, & \kappa_0 = 1.
\end{aligned}
\right.
$$
\end{proof}
\subsubsection{Proof of Theorem \ref{thm_mpgnn}}\label{proof_theorem}
Based on Propositions \ref{prop_first_mpgnn} and \ref{prop_second_mpgnn}, we are ready to present the proof of Theorem \ref{thm_mpgnn} for message passing GNNs.
First, we will apply the bounds on the derivatives back in Lemma \ref{lemma_trace_hess}.
After getting the trace of the Hessians, we then use the PAC-Bayes bound from Lemma \ref{lemma_gen_error} to complete the proof.
\begin{proof}[Proof of Theorem \ref{thm_mpgnn}]
By applying equations \eqref{eq_deri_W} and \eqref{eq_second_W} into Lemma \ref{lemma_trace_hess}'s result, we get that the trace of $\bH^{(l)}$ with respect to $W^{(i)}$ is less than:
{\small\begin{align}
& \kappa_0 \frac{\sqrt{k}}{\sqrt n} C_{i,l-1} \kappa_1 d_i \max\big(\bignorms{P_{_G}}^{l-i+1}, \bignorms{P_{_G}}^{2(l-i)}\big) \bignormFro{H^{(i-1)}}^2\Bigbrace{\prod_{t=i+1}^l s_t^2}
+ \kappa_1 \frac{k}{n} \kappa_0^{6(l-i)} \kappa_1 d_i \bignorms{P_{_G}}^{2(l-i)}\bignormFro{H^{(i-1)}}^2 \prod_{t=i+1}^l s_t^2 \nonumber \\
\le\,& (\kappa_0 C_{i,l-1} + \kappa_0^{6(l-i)}) \sqrt{\frac{{k}}{{n}}} \kappa_1 d_i \max\Bigbrace{\bignorms{P_{_G}}^{l-i+1}, \bignorms{P_{_G}}^{2(l-i)}}
\bignormFro{H^{(i-1)}}^2 \prod_{t=i+1}^l s_t^2,\label{eq_mpgnn_pr2}
\end{align}}%
for any $i=1,2,\cdots,l-1$. Here we have
$$ \kappa_0 C_{i,l-1} + \kappa_0^{6(l-i)} = \left\{
\begin{aligned}
&\kappa_0^{3(l-i)+1}\frac{\kappa_0^{3(l-i)} - 1}{\kappa_0 - 1}, & \kappa_0 \neq 1, \\
&3(l - i) - 1, & \kappa_0 = 1.
\end{aligned}
\right.
$$
It remains to consider the Frobenius norm of $H^{(i-1)}$.
Notice that this satisfies the following:
\begin{align*}
\bignormFro{H^{(i-1)}}
&\le \kappa_0 \bignormFro{X U^{(i-1)} + \rho_{i-1}(P_{_G} \psi_{i-1}(H^{(i-2)}))W^{(i-1)}} \\
&\le \kappa_0 \bignorms{U^{(i-1)}}\bignormFro{X}
+ \kappa_0^3 \bignorms{P_{_G}} \bignorms{W^{(i-1)}} \bignormFro{H^{(i-2)}}
&\le \kappa_0 s_i \bignormFro{X} + \kappa_0^3 \bignorms{P_{_G}} s_i \bignormFro{H^{(i-2)}}.
\end{align*}
By induction over $i$ for the above step, we get that the Frobenius norm of $H^{(i-1)}$ must be less than:
\begin{align}
\bigbrace{\kappa_0^{3(i-1)} + \sum_{j=0}^{i-2} \kappa_0^{3j+1}} {\sqrt{k}} \max_{(X, G, y) \sim \cD}\bignorms{X} \max \bigbrace{1,\bignorms{P_{_G}}^{i-1}} \prod_{j=1}^{i-1} s_j. \label{eq_mpgnn_pr1}
\end{align}
By applying the above \eqref{eq_mpgnn_pr1} back in \eqref{eq_mpgnn_pr2}, we have shown that the trace of $\bH^{(l)}$ with respect to $W^{(i)}$ is less than:
\begin{align}\label{eq_mpgnn_pr3}
C' \max_{(X, G, y) \sim \cD}\bignorms{X}^2 \kappa_1 d_i k \max(1, \norm{P_{_G}}^{2(l-1)}) \prod_{t=1: t\neq i}^l s_t^2,
\end{align}
where $C'$ satisfies the following equation:
$$ C' = \left\{
\begin{aligned}
&\frac{(\kappa_0^{3l} - 1)(\kappa_0^{3(l-1)/2} - 1)^2}{(\kappa_0 - 1)^3}, & \kappa_0 \neq 1, \\
&\frac{4}{9}l^3, & \kappa_0 = 1.
\end{aligned}
\right.
$$
To be specific, when $\kappa_0 = 1$, $(3(l-i)-1)i^2\leq \frac{4}{9}l^3$ . If $\kappa_0\neq 1$ and $i \geq 2$, we have
\begin{align*}
\Bigbrace{\kappa_0^{3(l-i)+1}\frac{\kappa_0^{3(l-i)} - 1}{\kappa_0 - 1}}\bigbrace{\kappa_0^{3(i-1)} + \sum_{j=0}^{i-2} \kappa_0^{3j+1}}^2 &\le \kappa_0^{3(l-i)+3}\frac{\kappa_0^{3(l-i)} - 1}{\kappa_0 - 1}\frac{(\kappa_0^{3(i-1)} - 1)^2}{(\kappa_0 - 1)^2}\\
&= \frac{\kappa_0^{3l} - \kappa_0^{3(l-i+1)}}{(\kappa_0 - 1)^3}\Bigbrace{(\kappa_0^{3(l-i)} - 1)(\kappa_0^{3(i-1)} - 1)} \\
&\le \frac{(\kappa_0^{3l} - 1)(\kappa_0^{3(l-1)/2} - 1)^2}{(\kappa_0 - 1)^3}.
\end{align*}
If $\kappa_0\neq 1$ and $i = 1$, we obtain
\begin{align*}
\Bigbrace{\kappa_0^{3(l-i)+1}\frac{\kappa_0^{3(l-i)} - 1}{\kappa_0 - 1}}\Bigbrace{\kappa_0^{3(i-1)} + \sum_{j=0}^{i-2} \kappa_0^{3j+1}}^2 = \kappa_0^{3l - 2} \frac{\kappa_0^{3(l - 1)} - 1}{\kappa_0 - 1} \le \frac{(\kappa_0^{3l} - 1)(\kappa_0^{3(l-1)/2} - 1)^2}{(\kappa_0 - 1)^3}.
\end{align*}
The above works for the layers from the beginning until layer $l-1$.
Last, we consider the trace of $\bH^{(l)}$ with respect to $W^{(l)}$ (notice that $\cU$ is not needed in the readout layer).
Similar to equation \eqref{eq_lemma_loss}, one can prove that the trace of the Hessian with respect to $W^{(l)}$ satisfies:
\begin{align*}
\bigabs{\tr\big[\bH^{(l)}[\ell(H^{(l)}, y)]\big]}
\leq\,& \kappa_0 \sqrt{k} \sum_{p=1}^{d_{l-1}}\sum_{q=1}^{d_l} \bignorm{\frac{\partial^2 H^{(l)}}{\partial \big(W^{(l)}_{p,q}\big)^2}} + \kappa_1 k \sum_{p=1}^{d_{l-1}}\sum_{q=1}^{d_l} \bignorm{\frac{\partial H^{(l)}}{\partial W^{(l)}_{p,q}}}^2 \\
\leq\,& \kappa_0 \sqrt{k} \sum_{p=1}^{d_{l-1}}\sum_{q=1}^{d_l} \bignorm{\frac{1}{n} \bm{1}_n^{\top} H^{(l-1)}\frac{\partial^2 W^{(l)}}{\partial \big(W^{(l)}_{p,q}\big)^2}} + \kappa_1 k \sum_{p=1}^{d_{l-1}}\sum_{q=1}^{d_l} \bignorm{\frac{1}{n} \bm{1}_n^{\top} H^{(l-1)}\frac{\partial W^{(l)}}{\partial W^{(l)}_{p,q}}}^2 \\
\leq\,& \kappa_1 k \sum_{p=1}^{d_{l-1}}\sum_{q=1}^{d_l} \bignorm{\frac{1}{n}\bm{1}_n}^2 \bignorms{H^{(l-1)}\frac{\partial W^{(l)}}{\partial W^{(l)}_{p,q}}}^2 \\
=\,& \kappa_1 \frac{k}{n} {d_l \bignormFro{H^{(l-1)}}^2}
\end{align*}
By equation \eqref{eq_mpgnn_pr1}, the above is bounded by
\begin{align*}
& \kappa_1 \frac{k}{n} d_l \bigbrace{\kappa_0^{3(l-1)} + \sum_{j=0}^{l-2} \kappa_0^{3j+1}}^2 \max_{(X, G, y) \sim \cD}\bignormFro{X}^2 \max \bigbrace{1,\bignorms{P_{_G}}^{2(l-1)}} \prod_{j=1}^{l-1} s_j^2 \\
\leq~ & C_l \max_{(X, G, y) \sim \cD}\bignorms{X}^2 \kappa_1 d_l k \max\Bigbrace{1, \bignorms{P_{_G}}^{2(l-1)}} \prod_{t=1: t\neq l}^l s_t^2,
\end{align*}%
since $\frac{\bignormFro{X}^2}{n} \le \bignorms{X}^2$,
where $C_l$ satisfies the following equation:
$$ C_l = \left\{
\begin{aligned}
&\kappa_0^2\frac{(\kappa_0^{3(l-1)} - 1)^2}{(\kappa_0 - 1)^2}, & \kappa_0 \neq 1, \\
&l^2, & \kappa_0 = 1.
\end{aligned}
\right.
$$
Finally, let
\begin{align}
\tilde C &= \max(C',C_l). \label{eq_const}
\end{align}
From the value of $C'$ above and the value of $C_l$, we get that $\tilde C$ is equal to
\begin{align}
\tilde C &= \left\{
\begin{aligned}
&\frac{(\kappa_0^{3l} - 1)(\kappa_0^{3(l-1)/2} - 1)^2}{(\kappa_0 - 1)^3}, & \kappa_0 \neq 1, \nonumber \\
&\frac{1}{2}l^3, & \kappa_0 = 1. \nonumber
\end{aligned}\right.
\end{align}
Similarly by applying equations \eqref{eq_deri_U} and \eqref{eq_second_U} into Lemma \ref{lemma_trace_hess}, the trace of $\bH^{(l)}$ with respect to $U^{(i)}$ is also less than equation \eqref{eq_mpgnn_pr3}.
Therefore, we have completed the proof for message-passing neural networks.
\end{proof}
\subsection{Proof of matching lower bound (Theorem \ref{prop_lb})}\label{app_lb}
For simplicity, we will exhibit the instance for a graph ConvNet, that is, we ignore the parameters in $\cU$ and also set the mapping $\rho_t$ and $\psi_t$ as the identity mapping.
Further, we set the mapping $\phi_t(x) = x$ as the identity mapping, too, for simplifying the proof.
In the proof, we show that for an arbitrary configuration of weight matrices $W^{(1)}, W^{(2)}, \dots, W^{(l)}$, there exists a data distribution such that for this particular configuration, the generation gap with respect to the data distribution satisfies the desired equation \eqref{eq_lb}.
\begin{proof}[Proof of Theorem \ref{prop_lb}]
Recall that the underlying graph for the lower bound instance is a complete graph.
Next, we will specify the other parts of the data distribution $\cD$.
Let $Z = \prod_{i=1}^l W^{(i)}$ denote the product of the weight matrices.
We are going to construct a binary classification problem.
Thus, the dimension of $Z$ will be equal to $n$ by $2$.
Let $Z = U D V^{\top}$ be the singular value decomposition of $Z$.
Let $\lambda_{\max}(Z)$ be the largest singular value of $Z$, with corresponding left and right singular vectors $u_1$ and $v_1$, respectively.
Within the hypothesis set $\cH$, $\lambda_{\max}(Z)$ can be as large as $\prod_{i=1}^l s_i$.
Denote a random draw from $\cD$ as $X, G, y$, corresponding to node features, the graph, and the label:
\begin{enumerate}[leftmargin=15pt]
\item The feature matrix $X$ is is equal to $\bm{1}_n u_1^{\top}$;
\item The class label $y$ is drawn uniformly between $+1$ and $-1$;
\item Lastly, the diffusion matrix $P$ is the adjacency matrix of $G$, which has a value of one in every entry of $P$.
\end{enumerate}
Given the example and the weight matrices, we will use the logistic loss to evaluate $f$'s loss.
Notice that $P = \bm{1}_n \bm{1}_n^{\top}$.
Thus, one can verify $\lambda_{\max}(P) = n$.
Crucially, the network output of our GCN is equal to
\begin{align*}
H^{(l)} = \frac 1 n \bm{1}_n^{\top} P^{l-1} X W^{(1)} W^{(2)} \cdots W^{(l)}
= n^{l-1} \Bigbrace{\frac{\bm{1}_n^{\top} X}{n} Z}
= n^{l-1} \Bigbrace{u_1^{\top} U D V^{\top}}
= \bigbrace{n^{l-1} \lambda_{\max}(Z)} v_1^{\top}.
\end{align*}
Let us denote $\alpha = n^{l-1} \lambda_{\max}(Z)$---the spectral norms of the diffusion matrix and the layer weight matrices.
Let $v_{1,1}, v_{1,2}$ be the first and second coordinate of $v_1$, respectively.
Notice that $y$ is drawn uniformly between $+1$ or $-1$.
Thus, with probability $1/2$, the loss of this example is $\log(1 + \exp(- \alpha \cdot v_{1,1}))$;
with probability $1/2$, the loss of this example is $\log(1 + \exp(\alpha\cdot v_{1,2}))$.
Let $b_i$ be a random variable that indicates the logistic loss of the $i$-th example.
The generalization gap is equal to
\begin{align*}
\epsilon = {\frac 1 N \sum_{i=1}^N b_i} - \frac 1 2\Bigbrace{\log(1 + \exp(- \alpha \cdot v_{1,1})) + \log(1 + \exp(\alpha \cdot v_{1,2}))}.
\end{align*}
By the central limit theorem, as $N$ grows to infinity, the generalization gap $\epsilon$ converges to a normal random variable whose mean is zero and variance is equal to
\begin{align*}
\frac 1 {4N} \Bigbrace{\log(1 + exp(-\alpha \cdot v_{1,1})) - \log(1 + \exp(\alpha \cdot v_{1,2}))}^2 \gtrsim \frac{\alpha^2}{N},
\end{align*}
for large enough values of $n$.
As a result, with probability at least $0.1$, when $N$ is large enough, the generalization gap $\epsilon$ must be at least
\[ \bigo{\sqrt{\frac{\alpha^2} N}}, \text{ where } \alpha = \bignorms{P_{_G}}^{l-1} \lambda_{\max}\Bigg(\prod_{i=1}^l W^{(i)}\Bigg). \]
Notice that the spectral norm of the product matrix can be realized at most as $\prod_{i=1}^l s_i$.
Thus, we have completed the proof of equation \eqref{eq_lb}.
\end{proof}
\subsection{Proof for graph isomorphism networks (Corollary \ref{thm_gin})}\label{app_gin}
To be precise, we state the loss function for learning graph isomorphism networks as the averaged loss over all the classification layers:
\begin{align}\label{eq_loss_gin}
\bar{\ell}(f(X, G), y) = \frac 1 {(l-1)} \sum_{i=1}^{l-1} \ell\Bigbrace{\frac 1 n \bm{1}_n^{\top} H^{(i)} V^{(i)}, y}.
\end{align}
Thus, $\hat \cL_{GIN}(f)$ is equivalent to the empirical average of $\bar\ell$ over $N$ samples from $\cD$.
$\cL_{GIN}(f)$ is then equivalent to the expectation of $\bar\ell$ over a random sample from $\cD$.
\begin{proof}[Proof of Corollary \ref{thm_gin}]
This result follows the trace guarantee from Lemma \ref{lemma_trace_hess}.
For any $i=1,\dots,l-1$ and any $j = i,\dots,l-1$, we can derive the following result with similar arguments:
\begin{align*}
\bigabs{\tr\Big[\bH_{\cW}^{(i)}\big[\ell\Bigbrace{\frac 1 n \bm{1}_n^{\top} H^{(j)} V^{(j)}, y}\big]\Big]}
\leq \frac{\kappa_0 \sqrt{k}}{\sqrt{n}} \bignorms{V^{(j)}} \sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignormFro{\frac{\partial^2 H^{(j)}}{\partial \big(W^{(i)}_{p,q}\big)^2}} + \frac {\kappa_1 k} n \bignorms{V^{(j)}}^2 \bignormFro{\frac{\partial H^{(j)}}{\partial W^{(i)}}}^2.
\end{align*}
Next, we repeat the steps in Propositions \ref{prop_first_mpgnn} and \ref{prop_second_mpgnn}, for any $i = 1,\dots,l-1$ and any $j = i,\dots,l-1$:
\begin{align*}
\max_{(X, G, y) \sim \cD} \bigabs{\tr\big[\bH^{(i)}[\ell\bigbrace{\frac 1 n \bm{1}_n^{\top} H^{(j)} V^{(j)}, y}]\big]}
\le 2\kappa_1\tilde{C} d_i k\max_{(X, G, y) \sim \cD}\bignorms{X}^2 \max \Bigbrace{1, \bignorms{P_{_G}}^{2(j-i+1)}} \bignorms{V^{(j)}}^2 \prod_{t = 1:\, t \neq i}^j s_t^2. %
\end{align*}
Based on the above step, the trace of the Hessian matrix of the loss function with respect to $W^{(i)}, U^{(i)}$ satisfies:
{\begin{align*}
\max_{(X, G, y) \sim \cD} \bigabs{\bigtr{\bH^{(i)}\bigbracket{\bar{\ell}(f(X, G), y)}}}
=& \max_{(X, G, y) \sim \cD} \bigabs{\bigtr{\bH^{(i)}\bigbracket{\frac{1}{(l-1)} \sum_{j=1}^{l-1} \ell\bigbrace{\frac 1 n \bm{1}_n^{\top} H^{(j)} V^{(j)}, y}}}} \\
=& \frac{1}{l-1} \sum_{j=i}^{l-1} \max_{(X, G, y) \sim \cD} \bigabs{\bigtr{\bH^{(i)}\bigbracket{\ell\Bigbrace{\frac 1 n \bm{1}_n^{\top} H^{(j)} V^{(j)}, y}}}} \\
\le & 2 \kappa_1 \tilde{C} d_i k \max_{j=1}^{l-1}\bignorms{V^{(j)}}^2\Bigbrace{\max_{(X, G, y) \sim \cD}\bignorms{X}^2 \sum_{j=1}^{l-1} \frac{\max \bigbrace{1, \bignorms{P_{_G}}^{2j}}}{{l-1}}} \prod_{t = 1:\, t \neq i}^{l-1} s_t^2.
\end{align*}}%
Within the above step, the propagation matrix satisfies:
\[ \frac 1 {(l-1)} \sum_{j=1}^{l-1} \max\bigbrace{1, \bignorms{P_{_G}}^{2j}} \le \max\fullbrace{1, \bignorms{\frac 1 {l-1}\sum_{j=1}^{l-1} P_{_G}^j }^2}. \]
Notice that $P_{GIN} = \frac 1 {l-1} \sum_{j=1}^{l-1} P_{_G}^j$.
Thus, we have completed the generalization error analysis for graph isomorphism networks in equation \eqref{eq_gin_result}.
\end{proof}
\section{Sharp Generalization Bounds for Graph Neural Networks}\label{sec_theory}
We first introduce the problem setup for analyzing graph neural networks.
Then, we state our generalization bounds for graph neural networks and compare them with the prior art.
Lastly, we construct an example to argue that our bounds are tight.
\subsection{Problem setup}
Consider a graph-level prediction task.
Suppose we have $N$ examples in the training set; each example is an independent sample from a distribution denoted as $\cD$, which is jointly supported on the feature space $\cX$ times the label space $\cY$.
In each example, we have an undirected graph denoted as $G = (V, E)$, which describes the connection between $n$ entities, represented by nodes in $V$.
For example, a node could represent a molecule, and an edge between two nodes is a bond between two molecules.
Each node also has a list of $d$ features. Denote all node features as an $n$ by $d$ matrix $X$.
For graph-level prediction tasks, the goal is to predict a graph label $y$ for every example.
We will describe a few examples of such tasks later in Section \ref{sec_empirical}.
\medskip
\noindent\textbf{Message-passing neural networks (MPNN).} %
We study a model based on several prior works for graph-level prediction tasks \cite{dai2016discriminative,gilmer2017neural,garg2020generalization,liao2020pac}.
Let $l$ be the number of layers: the first $l-1$ layers are diffusion layers, and the last layer is a pooling layer.
Let $d_t$ denote the width of each layer for $t$ from $1$ up to $l$.
There are several nonlinear mappings in layer $t$, denoted as $\phi_{t}, \rho_{t}$, and $\psi_{t}$; further, they are all centered at zero.
There is a weight matrix $W^{(t)}$ of dimension $d_{t-1}$ by $d_{t}$ for transforming neighboring features, and another weight matrix $U^{(t)}$ of dimension $d$ by $d_t$ for transforming the anchor node feature.
For the first $l-1$ layers, we recursively compute the node embedding from the input features $H^{(0)} = X$:
{\small\begin{align}
H^{(t)} = \phi_t\Bigbrace{X U^{(t)} + \rho_t\bigbrace{P_{_G} \psi_t(H^{(t-1)})} W^{(t)}}. \label{eq_matrix_mpgnn}
\end{align}}%
For the last layer $l$, we aggregate the embedding of all nodes: let $\bm{1}_n$ be a vector with $n$ values of one:
{\small\begin{align}
H^{(l)} &= \frac 1 n \bm{1}_n^{\top} H^{(l-1)} W^{(l)}. \label{eq_mpgnn_readout}
\end{align}}%
Note that this setting subsumes many existing GNNs.
Several common designs for the graph diffusion matrix $P_{_G}$ would be the adjacency matrix of the graph (denoted as $A$).
$P_{_G}$ can also be the normalized adjacency matrix, $D^{-1}A$, with $D$ being the degree-diagonal matrix.
Adding an identity matrix in $A$ is equivalent to adding self-loops in $G$.
In GCN, we can set $U^{(t)}$ as zero, $\rho_t$ and $\psi_t$ as identity mappings. %
\medskip
\noindent\textbf{Notations.}
For any matrix $X$, let $\bignorms{X}$ denote the largest singular value (or spectral norm) of $X$.
Let $\bignormFro{X}$ denote the Frobenius norm of $X$.
We use the notation $f(N) \lesssim g(N)$ to indicate that there exists a fixed constant $c$ that does not grow with $N$ such that $f(N) \le c\cdot g(N)$ for large enough values of $N$.
Let $\cW$ and $\cU$ denote the union of the $W$ and $U$ matrices in a model $f$, respectively.
\subsection{Main results}
Given a message-passing neural network denoted as $f$, what can we say about its generalization performance? %
Let $f(X, G)$ denote the output of $f$, given input with graph $G$, node feature matrix $X$, and label $y$.
The loss of $f$ for this input example is denoted as $\ell(f(X, G), y)$.
Let $\hat{\cL}(f)$ denote the empirical loss of $f$ over the training set.
Let $\cL(f)$ denote the expected loss of $f$ over a random example of distribution $\cD$.
We are interested in the generalization gap of $f$, i.e., $\cL(f) - \hat{\cL}(f)$.
How would the graph diffusion matrix $P_{_G}$ affect the generalization gap of graph neural networks?
To motivate our result, we examine the effect of incorporating graph diffusion in a one-layer linear neural network.
That is, we consider $f(X, G)$ to be $\frac 1 n \bm 1_n^{\top} P_{_G} X W^{(1)}$, which does not involve any nonlinear mapping for simplicity of our discussion.
In this case, by standard spectral norm inequalities for matrices, the Euclidean norm of $f$ (which is a vector) satisfies:
{\small\begin{align}
\bignorm{f(X, G)} = & \bignorm{\frac 1 n \bm 1_n^{\top} P_{_G} X W^{(1)}} \nonumber \\
\le & \bignorms{\frac 1 n \bm 1_n^{\top}} \cdot \bignorms{P_{_G}} \cdot \bignorms{X} \cdot \bignorm{W^{(1)}} \label{eq_one_layer_gcn}
\end{align}}%
Thus, provided that the loss function $\ell(\cdot, y)$ is Lipschitz-continuous, standard arguments imply that the generalization gap of $f$ scales with the spectral norm of ${P_{_G}}$ (divided by ${\sqrt N}$) \cite{mohri2018foundations}.
Let us compare this statement with a fully-connected neural net that averages the node features, i.e., the graph diffusion matrix $P_{_G}$ is the identity matrix.
The spectral norm of $P_{_G}$ becomes one.
Together, we conclude that the graph structure affects the generalization bound of a single layer GNN by adding the spectral norm of ${P_{_G}}$.
Our main result is that incorporating the spectral norm of the \emph{graph diffusion matrix} $P_{_G}^{l-1}$ is sufficient for any $l$ layer MPNN.
We note that the dependence is a power of $l-1$ because there are $l-1$ graph diffusion layers: see equation \eqref{eq_matrix_mpgnn}.
Let $f$ be an $l$-layer network whose weights $\cW, \cU$ are defined within a hypothesis set $\cH$: For every layer $i$ from $1$ up to $l$, we have that
{\small\begin{align}
\bignorms{W^{(i)}} \le& s_i, ~~\bignormFro{W^{(i)}} \le s_i r_i, \nonumber\\
\bignorms{U^{(i)}} \le& s_i, ~~\bignormFro{U^{(i)}} \,\,\le s_i r_i,\label{eq_cH}
\end{align}}%
where $s_1, s_2, \dots, s_l$ and $r_1, r_2, \dots, r_l$ are bounds on the spectral norm and stable rank and are all greater than or equal to one, without loss of generality.
We now present the full statement.
\begin{theorem}\label{thm_mpgnn}
Suppose all of the nonlinear activations in $\set{\phi_t, \rho_t, \psi_t: \forall\, t}$ and the loss function $\ell(\cdot, y)$ (for any fixed label $y \in \cY$) are twice-differentiable, Lipschitz-continuous, and their first-order and second-order derivatives are both Lipschitz-continuous.
With probability at least $1 - \delta$ over the randomness of $N$ independent samples from $\cD$, for any $\delta > 0$, and any $\epsilon > 0$ close to zero, any model $f$ with weight matrices in the set $\cH$ satisfies:
{\small \begin{align}
\cL(f) \leq (1 + \epsilon) \hat{\cL}(f) + \bigo{\frac{\log(\delta^{-1})}{N^{3/4}}} \label{eq_thm_mpgnn} %
+ {\sum_{i=1}^l \sqrt{\frac{ C B d_i \Bigbrace{\max\limits_{(X, G, y) \sim \cD}\bignorms{X}^2 \bignorms{P_G}^{2(l-1)}} \Bigbrace{r_i^2 \prod\limits_{j=1}^l s_j^2} } {N}} }, %
\end{align}}%
where $B$ is an upper bound on the value of the loss function $\ell(x, y)$ for any $(x, y) \sim \cD$, and $C$ is a fixed Lipchitz constant depending on the activation's and the loss function's Lipschitz-continuity (see equation \eqref{eq_const}, Appendix \ref{proof_theorem}).
\end{theorem}
As a remark, prior works by \citet{garg2020generalization} and \citet{liao2020pac} consider an MPNN with $W^{(t)}$ and $U^{(t)}$ being the same for $t$ from $1$ up to $l$, motivated by practical designs \cite{gilmer2017neural,jin2018junction}.
Thus, their analysis needs to be conducted separately for GCN and MPNN with weight tying.
By contrast, our result allows $W^{(t)}$ and $U^{(t)}$ to be arbitrarily different across different layers.
This unifies GCN and MPNN without weight tying in the same framework so that we can unify their analysis.
We defer the proof sketch of our result along with a discussion to Section \ref{sec_proff_sketch}.
\subsection{Comparison with prior art}\label{sec_compare}
\begin{table*}[t!]
\caption{How does the generalization gap of graph neural networks scale with graph properties? In this work, we show spectrally-normalized bounds on $P_{_G}$ and compare our results with prior results in the following table.
We let $A$ denote the adjacency matrix, $D$ be the degree-diagonal matrix of $A$, and $l$ be the depth of the GNN.
Previous generalization bounds scale with the graph's maximum degree denoted as $d$.
Our result instead scales with the spectral norm of $P_{_G}$ and applies to new settings, including graph isomorphism networks (GIN) \cite{xu2018powerful} and GraphSAGE with mean aggregation \cite{hamilton2017inductive}.
}\label{table_theory}
\centering
{\begin{tabular}{@{} | c | c | c | c | c |@{}}
\toprule
Graph Dependence & \textbf{GCN} & \textbf{MPNN} & \textbf{GIN} & \textbf{GraphSAGE-Mean} \\
\midrule
\citeay{garg2020generalization} & $d^{l-1}$ & $d^{l-1}$ & - & - \\
\citeay{liao2020pac} & $d^{\frac{l-1} 2}$ & $d^{l-1}$ & - & -\\
\textbf{Ours (Theorems \ref{thm_mpgnn} and \ref{thm_gin})} & $1$ & $\bignorms{A}^{l-1}$ & $\sum_{i=1}^{l-1} \frac{\bignorms{A}^i}{l-1}$ & $\bignorms{D^{-1} A}^{l-1}$ \\
\bottomrule
\end{tabular}}%
\end{table*}
In Table \ref{table_theory}, we compare our result with prior results.
We first illustrate the effects of graph properties on the generalization bounds.
Then we will also show a numerical comparison to incorporate the other components of the bounds.
\begin{itemize}[leftmargin=15pt]
\item Suppose $P_{_G}$ is the adjacency matrix of $G$.
Then, one can show that for any undirected graph $G$, the spectral norm of ${P_{_G}}$ is less than the maximum degree $d$ (cf. Fact \ref{fact_graph}, Appendix \ref{app_proof} for a proof).
This explains why our result is strictly less than prior results for MPNN in Table \ref{table_theory}.
\item Suppose $P_{_G}$ is the normalized and symmetric adjacency matrix of $G$: $P_{_G} = \tilde D^{-1/2} \tilde A \tilde D^{-1/2}$, where $\tilde A$ is $A + \id$ and $\tilde D$ is the degree-diagonal matrix of $\tilde A$.
Then, the spectral norm of $P_{_G}$ is at most one (cf. Fact \ref{fact_graph}, Appendix \ref{app_proof} for a proof).
This fact explains why the graph dependence of our result for GCN is $1$ in Table \ref{table_theory}.
Thus, we can see that this provides an exponential improvement compared to the prior results.
\end{itemize}
Thus, for the above diffusion matrices, we conclude that the spectral norm of ${P_{_G}}$ is strictly smaller than the maximum degree of graph $G$ (across all graphs in the distribution $\cD$).
\paragraph{Numerical Comparison.} Next, we conduct an empirical analysis to compare our results and prior results numerically.
Following the setting of prior works, we use two types of models that share their weight matrices across different layers, including GCN \cite{kipf2016semi} and the MPNN specified in \citet{liao2020pac}.
For both models, we evaluate the generalization bounds by varying the network depth $l$ between $2, 4$, and $6$.
We consider graph prediction tasks on three collaboration networks, including IMDB-B, IMDB-M, and COLLAB \cite{yanardag2015deep}.
IMDB-B includes a collection of movie collaboration graphs. In each graph, a node represents an actor or an actress, and an edge denotes a collaboration in the same movie. The task is to classify each graph into the movie genre as Action or Romance.
The IMDB-M is a multi-class extension with the movie graph label Comedy, Romance, or Sci-Fi.
COLLAB includes a list of ego-networks of scientific researchers. Each graph includes a researcher and her collaborators as nodes. An edge in the graph indicates a collaboration between two researchers. The task is to classify each ego-network into the field of the researcher, including High Energy, Condensed Matter, and Astro Physics.
We report the numerical comparison in Figure \ref{fig_bound_measurement}.
We report the averaged result over three random seeds.
Our results are consistently smaller than previous results.
As explained in Table \ref{table_theory}, the improvement comes from the spectral norm bounds on graphs compared with the max degree bounds.
\begin{figure*}[t!]
\begin{subfigure}[b]{0.33\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{./figures/gcn_bounds_layer_2.pdf}
\caption{Two-layer GCN}
\end{subfigure}\hfill%
\begin{subfigure}[b]{0.33\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{figures/gcn_bounds_layer_4.pdf}
\caption{Four-layer GCN}
\end{subfigure}\hfill%
\begin{subfigure}[b]{0.33\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{figures/gcn_bounds_layer_6.pdf}
\caption{Six-layer GCN}
\end{subfigure}\hfill%
\begin{subfigure}[b]{0.33\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{./figures/mpgnn_bounds_layer_2.pdf}
\caption{Two-layer MPNN}
\end{subfigure}\hfill%
\begin{subfigure}[b]{0.33\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{figures/mpgnn_bounds_layer_4.pdf}
\caption{Four-layer MPNN}
\end{subfigure}\hfill%
\begin{subfigure}[b]{0.33\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{figures/mpgnn_bounds_layer_6.pdf}
\caption{Six-layer MPNN}
\end{subfigure}
\caption{Comparing our result and prior results \cite{garg2020generalization, liao2020pac} on three graph classification tasks.
\textbf{Upper}: The experiments are conducted on GCNs.
\textbf{Lower}: The experiments are conducted on MPNNs following the setup of \citet{liao2020pac}.}
\label{fig_bound_measurement}
\end{figure*}
\subsection{A matching lower bound}
Next, we show an instance with the same dependence on the graph diffusion matrix as our upper bound.
In our example:
\begin{itemize}[leftmargin=15pt]
\item The graph $G$ is the complete graph with self-loops inserted in each node.
Thus, the adjacency matrix of $G$ is precisely a square matrix with all ones.
We will set $P_{_G}$ as the adjacency matrix of $G$.
\item In the first $l-1$ graph diffusion layers, the activation functions $\phi, \rho, \psi$ are all linear functions.
Further, we fix all the parameters of $\cU$ as zero.
\item The loss function $\ell$ is the logistic loss.
\end{itemize}
Then, we demonstrate a data distribution such that there always exists some weight matrices within $\cH$ whose generalization gap must increase in proportion to the spectral norm of $P_{_G}^{l-1}$ and the product of the spectral norm of every layer $s_1, s_2, \dots, s_l$.
\smallskip
\begin{theorem}\label{prop_lb}
Let $N_0$ be a sufficiently large value.
For any norms $s_1, s_2, \dots, s_n$, there exists a data distribution $\cD$ on which with probability at least $0.1$ over the randomness of $N$ independent samples from $\cD$, for any $N \ge N_0$, the generalization gap of $f$ is greater than the following:
{\small\begin{align}
\bigabs{\cL(f) - \hat\cL(f)}
\gtrsim\sqrt \frac{\Bigbrace{\max\limits_{(X, G, y) \sim \cD}\bignorms{P_{_G}}^{2(l-1)}} \Bigbrace{\prod\limits_{i=1}^l s_i^2} }{N}. \label{eq_lb}
\end{align}}%
\end{theorem}
Notice that the lower bound in \eqref{eq_lb} exhibits the same scaling in terms of $G$---$\bignorms{P_{_G}}^{l-1}$---as our upper bound from equation \eqref{eq_thm_mpgnn}.
Therefore, we conclude that our spectral norm bound is tight for multilayer MPNN.
The proof of the lower bound can be found in Appendix \ref{app_lb}.
\smallskip
\begin{remark}\normalfont
Our results from Theorem \ref{thm_mpgnn} and \ref{prop_lb} together suggest the generalization error bound scales linearly in $l$.
To verify whether this is the case, we conducted an empirical study on three architectures (GCN, GIN-Mean, and GIN-Sum) that measured the growth of generalization errors as the network depth $l$ varies.
We find that the generalization error grows sublinearly with $l$ to $\bignorms{P_{_G}}$. We also note that this sublinear growth trend has been captured by our Hessian-based generalization bound (cf. Figure \ref{fig_intro_gcn}). It would be interesting to understand better why the sublinear trend happens and further provide insight into the behavior of GNN.
\end{remark}
\begin{remark}\normalfont
Theorem \ref{prop_lb} suggests that in the worst case, the generalization bound would have to scale with the spectral norms of the graph and the weight matrices.
Although this is vacuous for large $l$, later in Lemma \ref{lemma_gen_error}, we show a data-dependent generalization bound using the trace of the Hessians, which is non-vacuous. As shown in Figure \ref{fig_intro_gcn}, Hessian-based measurements match the scale of actual generalization errors: the green line, calculated based on the trace of the loss Hessian matrix (cf. equation \eqref{eq_main_1}), matches the scale of the actual generalization error plotted in the yellow line.
\end{remark}
\section{Proof Techniques and Extensions}\label{sec_proff_sketch}
Our analysis for dealing with the graph structure seems fundamentally different from the existing analysis.
In the margin analysis of \citet{liao2020pac}, the authors also incorporate the graph structure in the perturbation error.
For bounding the perturbation error, the authors use a triangle inequality that results in a $(1, \infty)$ norm of the matrix ${P_{_G}}$ (see Lemma 3.1 of \citet{liao2020pac} for GCN).
We note that this norm can be larger than the spectral norm by a factor of $\sqrt{n}$, where $n$ is the number of nodes in $G$: in the case of a star graph, this norm for the graph diffusion matrix of GCN is $\sqrt n$.
By comparison, the spectral norm of the same matrix is less than one (see Fact \ref{fact_graph}, Appendix \ref{app_proof}).
How can we tighten the perturbation error analysis and the dependence on $P_{_G}$ in the generalization bounds, then?
Our proof involves two parts:
\begin{itemize}[leftmargin=15pt]
\item {\bf Part I:} By expanding the perturbed loss of a GNN, we prove a bound on the generalization gap using the trace of the Hessian matrix associated with the loss.
\item {\bf Part II:} Then, we explicitly bound the trace of the Hessian matrix with the spectral norm of the graph using the Lipschitzness of the activation functions.
\end{itemize}
\medskip
\noindent\textbf{Part I:} {\itshape Measuring noise stability using the Hessian.} We first state an implicit generalization bound that measures the trace of the Hessian matrix.
Let $\bH^{(i)}$ denote the Hessian matrix of the loss $\ell(f(X, G), y)$ with respect to layer $i$'s parameters, for each $i$ from $1$ up to $l$. Particularly, $\bH^{(i)}$ is a square matrix whose dimension depends on the number of variables within layer $i$.
Let $\bH$ denote the Hessian matrix of the loss $\ell(f(X, G), y)$ over all parameters of $f$.
\begin{lemma}\label{lemma_gen_error}
In the setting of Theorem \ref{thm_mpgnn}, with probability at least $1 - \delta$ over the randomness of the $N$ training examples, for any $\delta > 0$ and $\epsilon$ close to $0$, we get:
{\small\begin{align}
\cL(f) \leq (1 + \epsilon) \hat{\cL}(f)
+ (1 + \epsilon) \sum_{i=1}^l\sqrt{\frac{B\cdot \left(\max\limits_{(X, G, y)\sim\cD}\tr\big[\bH^{(i)}[\ell(f(X, G), y)]\big]\right) s_i^2 r_i^2}{N}}
+ \bigo{\frac{\log(\delta^{-1})}{N^{3/4}}}.\label{eq_main_1}
\end{align}}%
\end{lemma}
\paragraph{Proof Sketch.} At a high level, the above result follows from Taylor's expansion of the perturbed loss.
Suppose each parameter of $f$ is perturbed by an independent noise drawn from a Gaussian distribution with mean zero and variance $\sigma^2$.
Let $\tilde \ell(f(X, G), y)$ be the perturbed loss value of an input example $X, G$ with label $y$.
Let $\cE$ denote the noise injections organized in a vector.
Using Taylor's expansion of the perturbed loss $\tilde \ell$, we get:
{\small
\begin{align}
\tilde \ell(f(X, G), y) - \ell(f(X, G), y) \label{eq_perturb}
= \cE^{\top} \nabla \ell(f(X, G), y) + \frac 1 2 {\cE}^{\top} \bH\big[\ell(f(X, G), y)\big] {\cE} + \order{\sigma^3}.
\end{align}}%
Notice that the expectation of the first-order expansion term above is equal to zero.
The expectation of the second-order expansion term becomes $\sigma^2$ times the trace of the loss Hessian.
To derive equation \eqref{eq_main_1}, we use a PAC-Bayes bound of \citet[Theorem 2]{mcallester2013pac}.
There are two parts to this PAC-Bayes bound:
\begin{itemize}[leftmargin=15pt]
\item The expectation of the noise perturbation in equation \eqref{eq_perturb}, taken over the injected noise $\cE$;
\item The KL divergence between the prior and the posterior, which is at most $s_i^2 r_i^2$ for layer $i$, for $i$ from $1$ up to $l$, within the hypothesis set $\cH$.
\end{itemize}
Thus, one can balance the two parts by adjusting the noise variance at each layer---this leads to the layerwise Hessian decomposition in equation \eqref{eq_main_1}.
A critical step is showing the uniform convergence of the Hessian matrix.
We achieve this based on the Lipschitz-continuity of the first and twice derivatives of the nonlinear activation mappings.
With these conditions, we prove the uniform convergence with a standard $\epsilon$-cover argument.
The complete proof can be found in Appendix \ref{proof_trace}.
\smallskip
\begin{remark}\label{remark_node}\normalfont
Our argument in Lemma \ref{lemma_gen_error} applies to graph-level prediction tasks, which assume an unknown distribution of graphs.
A natural question is whether the analysis applies to node-level prediction tasks, which are often treated as semi-supervised learning problems.
The issue with directly applying our analysis to semi-supervised learning is that the size of a graph is only finite.
Instead, a natural extension would be to think about our graph as a random sample from some population and then argue about generalization in expectation of the random sample.
It is conceivable that one can prove a similar spectral norm bound for node prediction in this extension. %
This would be an interesting question for future work.
\end{remark}
\medskip
\noindent\textbf{Part II:} {\itshape Spectral norm bounds of the trace of the Hessian.} Next, we explicitly analyze the trace of the Hessian at each layer.
We bound the trace of the Hessian using the spectral norm of the weight matrices and the graph based on the Lipschitz-continuity conditions from Theorem \ref{thm_mpgnn}.
Notice that the last layer is a linear pooling layer, which can be deduced from layer $l-1$. Hence, we consider the first $l-1$ layers below.
\begin{lemma}\label{lemma_trace_hess}
In the setting of Theorem \ref{thm_mpgnn},
the trace of the loss Hessian matrix $\bH^{(i)}$ taken over $W^{(i)}$ and $U^{(i)}$ satisfies the following, for any $i = 1,2,\cdots,l-1$,
{\small\begin{align}
\bigabs{\bigtr{\bH^{(i)}\bigbracket{\ell\bigbrace{f(X, G), y}}}}
\lesssim ~ & s_l^2 \Bigg(\sum_{p=1}^{d_{i-1}}\sum_{q=1}^{d_i} \bignormFro{\frac{\partial^2 H^{(l-1)}}{\partial \big(W^{(i)}_{p,q}\big)^2}} + \sum_{p=1}^{d_0}\sum_{q=1}^{d_i} \bignormFro{\frac{\partial^2 H^{(l-1)}}{\partial\bigbrace{U_{p,q}^{(i)}}^2}}
+ \bignormFro{\frac{\partial H^{(l-1)}}{\partial W^{(i)}}}^2 + \bignormFro{\frac{\partial H^{(l-1)}}{\partial U^{(i)}}}^2 \Bigg) \label{eq_loss_3} \\
\lesssim ~ & {\bignorms{X}^2\bignorms{P_{_G}}^{2(l-1)}} {\prod\nolimits_{j=1:\,j\neq i}^{l} s_j^2}. \label{eq_loss_4}
\end{align}}%
\end{lemma}
\paragraph{Proof Sketch.} Equation \eqref{eq_loss_3} uses the chain rule to expand out the trace of the Hessian and then applies the Lipschitzness of the loss function. Based on this result, equation \eqref{eq_loss_4} then bounds the first and second derivatives of $H^{(l-1)}$.
This step is achieved via an induction of $\partial H^{(j)}$ and $\partial^2 H^{(j)}$ over $W^{(i)}$ and $U^{(i)}$, for $j = 1,\dots,l-1$ and $i = 1,\dots, j$.
The induction relies on the feedforward architecture and the Lipschitzness of the first and second derivatives.
We leave out a few details, such as the constants in equations \eqref{eq_loss_3} and \eqref{eq_loss_4} that can be found in Appendix \ref{proof_first} and \ref{proof_second}.
Combining both parts together, we get equation \eqref{eq_matrix_mpgnn}.
\smallskip
\begin{remark}\label{remark_tech}\normalfont
We compare our analysis with the approach of \citet{liao2020pac}.
Both our analysis and \citet{liao2020pac} follow the PAC-Bayesian framework.
But additionally, we explore Lipschitz-continuity properties of the first and second derivatives of the activation functions (e.g., examples of such activations include tanh and sigmoid).
This allows us to measure the perturbation loss with Hessians, which captures data-dependent properties much more accurately than the margin analysis of \citet{liao2020pac}.
It would be interesting to understand if one could still achieve spectral norm bounds on graphs under weaker smoothness conditions (see, e.g., \citet{wei2019data}). This is left for future work.
\end{remark}
\subsection{Extensions}\label{sec_extension}
\textbf{Graph isomorphism networks.} This architecture concatenates every layer's embedding together for more expressiveness \cite{xu2018powerful}.
A classification layer is used after the layers.
Let $V^{(i)}$ denote a $d_i$ by $k$ matrix (recall $k$ is the output dimension).
Denote the set of these matrices by $\cV$.
We average the loss of all of the classification layers.
Let $\hat\cL_{_{GIN}}(f)$ denote the average loss of $f$ over $N$ independent samples of $\cD$.
Let ${\cL}_{_{GIN}}(f)$ denote the expected loss of $f$ over a random sample of $\cD$.
See also equation \eqref{eq_loss_gin} in Appendix \ref{app_gin} for their precise definitions.
Next, we state a generalization bound for graph isomorphism networks.
Let $f$ be any $l$-layer MPNN with weights defined in a hypothesis space $\cH$: the parameters of $f$ reside within the constraints from equation \eqref{eq_cH};
further, for every $i$ from $1$ up to $l$, the spectral norm of $V^{(i)}$ is less than $s_l$. %
Building on Lemma \ref{lemma_trace_hess}, we show a bound that scales with the spectral norm generalization of the averaged graph diffusion matrices.
Let $P_{_{GIN}}$ denote the average of $l-1$ matrices: $P_{_G}, P_{_G}^2, \dots, P_{_G}^{l-1}$.
We state the result below.
\smallskip
\begin{corollary}\label{thm_gin}
Suppose the nonlinear activation mappings and the loss function satisfy the conditions stated in Theorem \ref{thm_mpgnn}.
With probability at least $1- \delta$ for any $\delta \ge 0$, and any $\epsilon$ close to zero, any $f$ in $\cH$ satisfies:
{\small\begin{align}
{L}_{_{GIN}}(f) \le (1+\epsilon)\hat\cL_{_{GIN}}(f) \label{eq_gin_result}
+ {\sum_{i=1}^{l} \sqrt {\frac { {BC d_i \cdot \left({\max\limits_{(X, G, y) \sim \cD} \bignorms{X}^2 \bignorms{ P_{_{GIN}}}^2}\right) \Bigbrace{r_i^2 \prod\limits_{j=1}^{l} s_j^2}}} {N}}} + \bigo{\frac{\log(\delta^{-1})}{N^{3/4}}},
\end{align}}%
where $B$ is an upper bound on the value of the loss function $\ell$ across the data distribution $\cD$, and $C$ is a fixed constant that only depends on the Lipschitz-continuity of the activation mappings and the loss.
\end{corollary}
The proof can be found in Appendix \ref{app_gin}.
In particular, we apply the trace norm bound over the model output of every layer.
The classification layer, which only uses a linear transformation, can also be incorporated.
\paragraph{Fine-tuned Graph Neural Networks.} We note that all of our bounds can be applied to the fine-tuning setting, where a graph neural network is initialized with pretrained weights and then fine-tuned on the target task.
The results can be extended to this setting by setting the norm bounds within equation \eqref{eq_cH} as the distance between the pretrained and fine-tuned model. | {'timestamp': '2023-02-10T02:07:02', 'yymm': '2302', 'arxiv_id': '2302.04451', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04451'} | arxiv |
\subsubsection*{\bibname}}
\begin{document}
\runningauthor{Volodymyr Tkachuk, Seyed Alireza Bakhtiari, Johannes Kirschner, Matej Jusup, Ilija Bogunovic, Csaba Szepesvári}
\newcommand{Efficient Planning in Combinatorial Action Spaces with Applications to Cooperative Multi-Agent Reinforcement Learning}{Efficient Planning in Combinatorial Action Spaces with Applications to Cooperative Multi-Agent Reinforcement Learning}
\twocolumn[
\aistatstitle{Efficient Planning in Combinatorial Action Spaces with Applications to Cooperative Multi-Agent Reinforcement Learning}
\aistatsauthor{
Volodymyr Tkachuk$^*$ \And
Seyed Alireza Bakhtiari$^*$ \And
Johannes Kirschner}
\aistatsaddress{ University of Alberta \And University of Alberta \And University of Alberta}
\aistatsauthor{
Matej Jusup \And
Ilija Bogunovic\And
Csaba Szepesvári }
\aistatsaddress{ETH Zurich \And University College London \And University of Alberta/DeepMind } ]
\begin{abstract}
A practical challenge in reinforcement learning are combinatorial action spaces that make planning computationally demanding. For example, in cooperative multi-agent reinforcement learning, a potentially large number of agents jointly optimize a global reward function, which leads to a combinatorial blow-up in the action space by the number of agents. As a minimal requirement, we assume access to an argmax oracle that allows to efficiently compute the greedy policy for any Q-function in the model class. Building on recent work in planning with local access to a simulator and linear function approximation, we propose efficient algorithms for this setting that lead to polynomial compute and query complexity in all relevant problem parameters. For the special case where the feature decomposition is additive, we further improve the bounds and extend the results to the kernelized setting with an efficient algorithm.
\end{abstract}
\input{parts/introduction}
\input{parts/related_work}
\input{parts/notation}
\input{parts/preliminaries}
\input{parts/algorithms}
\input{parts/additive}
\input{parts/conclusion}
\subsubsection*{Acknowledgements}
Johannes Kirschner gratefully acknowledges funding from the SNSF Early Postdoc.Mobility fellowship P2EZP2\_199781.
Matej Jusup gratefully acknowledges support by the Swiss National Science Foundation under the research project DADA/181210.
Csaba Szepesv\'ari gratefully acknowledges funding from the Canada CIFAR AI Chairs Program, Amii and NSERC.
\bibliographystyle{unsrtnat}
\section{Introduction}
We consider a cooperative multi-agent reinforcement learning setting with $m \in \mathbb{N}$ agents.
Let $\mathcal{S}$ be a state space that is shared for all agents, and $\mathcal{A}^{(i)}$ the set of actions available to agent $i \in [m]$.
We use the following notation to denote the joint agent action space
$\mathcal{A}^{(1:m)} = \mathcal{A}^{(1)} \times ... \times \mathcal{A}^{(m)},$
and the following to denote an action vector
$a^{(1:m)} = (a^{(1)}, ..., a^{(m)}),$
where $\times$ is used to denote a Cartesian product and $a^{(i)} \in \mathcal{A}^{(i)}$ is the action agent $i$ took.
Denote $A^{(1:m)} = |\mathcal{A}^{(1:m)}|$ and $A^{(j)} = |\mathcal{A}^{(j)}|$ where $j \in [m]$ and we use notation $[a] = \{1, ..., a\}, \ a \in \mathbb{N}$ throughout.
There is a global transition kernel $P : \mathcal{S} \times \mathcal{A}^{(1:m)} \rightarrow \Delta_{\mathcal{S}}$, where $\Delta_{\mathcal{S}}$ denotes the set of probability measures over $\mathcal{S}$.
That is, given a state $s \in \mathcal{S}$ and action vector $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ for each agent, the system transits to a new state $s' \sim P(s, a^{(1:m)})$.
Each agent $i=1,\dots,m$ has a reward function $r_i : \mathcal{S} \times \mathcal{A}^{(i)} \rightarrow [0, 1]$. A centralized, deterministic policy $\pi :\mathcal{S} \rightarrow \mathcal{A}^{(1:m)}$ maps states to $m$ actions.
The global value of a policy $\pi$ is
\begin{align*}
V_\pi(s_0) = \EE_{\pi}[\sum_{h=1}^H \sum_{i=1}^m r_i(s_h, a_h^{(i)})|s_0] \,.
\end{align*}
The expectation is over the sequence of states $s_1, \dots, s_H$ and action tuples $(a_h^{(1:m)})_{h=1}^H$ sampled from the transition kernel $P$ and the policy $\pi$ for a given starting state $s_0$. A policy $\pi^*$ is called optimal if $V_{\pi^*} = \max_{\pi} V_{\pi}$.
The value of agent $i$ under the joint policy $\pi$ is
\begin{align*}
V_{\pi,i}(s_0) = \EE_{\pi}[\sum_{h=1}^H r_i(s_h, a_{h,i})|s_0] \,.
\end{align*}
Note that the value depends on the actions of all agents through the joint transition kernel. The Q-function for agent $i$ is defined analogously,
\begin{align*}
Q_{\pi}^{(i)}(s,a^{(1:m)}) = r_i(s,a^{(i)}) + \EE_{s' \sim P(s,a^{(1:m)})}[V_{\pi,i}(s')]
\end{align*}
and $Q_\pi(s,a^{(1:m)}) = \sum_{i=1}^m Q_{\pi,i}(s, a^{(1:m)})$.
Our goal is to find a computation and sample efficient local planner with access to a simulator.
The simulator can be used to sample transitions from the kernel $P$.
We also assume access to state-action features $\phi_i : \mathcal{S} \times \mathcal{A}^{(i)} \rightarrow \mathbb{R}^d$. We make the following realizability assumption:
\begin{assumption}
\label{ass: ass1}
For each (deterministic) policy $\pi$, there exists weight vectors $w_1, \dots w_m \in \mathbb{R}^d$ such that $Q_{\pi}^{(i)}(s,a^{(1:m)}) = \sum_{j=1}^m \phi_j(s,a^{(j)})^\top w_i$, and hence $Q_\pi(s,a^{(1:m)}) = \sum_{j=1}^m \phi_j(s,a^{(j)})^\top \sum_{i=1}^m w_i$.
\end{assumption}
This is a quite restrictive assumption that requires the $Q_{\pi}^{(i)}$ function to decompose additively.
This means the effect of an action chosen by agent $i$ on the $Q_{\pi}^{(i)}$ function is independent of actions chosen by other agents.
A slightly less restrictive assumption is the following.
Assume that we are given access to features $\phi_{i,j}(s,a) \in \mathbb{R}^d$ for each pair of agents $i,j \in [m]$.
\begin{assumption}
\label{ass: ass2}
For each (deterministic) policy $\pi$, there exists weight vectors $w_1, \dots w_m \in \mathbb{R}^d$ such that $Q_{\pi}^{(i)}(s,a^{(1:m)}) = \sum_{j=1}^m \phi_{i,j}(s,a^{(j)})^\top w_i$. Therefore,
\[Q_\pi(s,a^{(1:m)}) = \sum_{i=1}^m \sum_{j=1}^m \phi_{i,j}^\top(s,a^{(j)}) w_i= \sum_{j=1}^m \tilde \phi_j(s, a^{(j)})^\top \tilde w \,,\]
where $\tilde \phi_j(s, a) = (\phi_{1,j}(s, a), \dots, \phi_{m,j}(s,a)) \in \mathbb{R}^{md}$ and $\tilde w = (w_1, \dots, w_m) \in \mathbb{R}^{md}$ concatenates the agent specific features and weights respectively.
\end{assumption}
\paragraph{Goals} Assuming $|\mathcal{A}^{(i)}| = A, \ \forall i \in [m]$ for some constant $A$.
The objective is to find a planner with corresponding policy $\pi$ that provably satisfies $V_{\pi^*}(s) - V_{\pi}(s) \leq \epsilon$ and has sample and computation complexity $\text{poly}(H, A, m, d, 1/\epsilon)$.
The work by \citet{yin2021efficient} provides a planner that is $\text{poly}(H, A^m, d, 1/\epsilon)$, which could serve as a starting point.
The idea is to be more careful about which actions to evaluate, and using the feedback for each individual agent.
Further, we are planning to empirically evaluate different ideas on toy examples. At a later stage, we could also design a scaling solution based on neural networks, for example taking inspiration from the AlphaZero algorithm \citep{silver2018general}.
\paragraph{Motivating Application} The \emph{Flatland} environment \citep{mohanty2020flatlandrl} is a railway simulator. Provided with a rail network, the goal is to route trains from a starting point to a destination while minimizing the total delay. This is also known as the \emph{vehicle routing problem}. This setting can be modeled as a multi-agent planning problem. The state $s$ captures the railway network and the current position of all trains. Each train corresponds to one agent. The agents choose movement actions $\{\text{STOP}, \text{FORWARD}, \text{LEFT}, \text{RIGHT}\}$ as permitted by the rail network. Trains can occur stochastic malfunctions that may require replanning. The objective is to minimize overall delay, therefore the agent-specific reward function is set to the negative delay.
\paragraph{Related Work}
QMix: \cite{rashid2018qmix}
Local Utility functions: \cite{zohar2021locality}
Potential Games: \cite{leonardos2021global}
\section{MDP Setting Analysis}
For ease of reference we include the naive ($O(\Pi_{i=1}^m |A^{(i)}|, ...)$ computation) multi-agent implementation of Algorithm 1, Confident Rollout, from \cite{yin2021efficient}.
Unlike in the original algorithm, we will use $n$ to denote the number of samples and $H$ to denote the length of the trajectory. This change is made so that we can continue to use $m$ to represent the number of agents.
We will work under Assumption \ref{ass: ass1} for all the following subsections.
We define $w = \sum_{i=1}^m w_i$ and, $\phi(s, a^{(1:m)}) = \sum_{i=1}^m \phi_i(s, a^{(i)})$.
\begin{algorithm}
\caption{Multi-Agent Confident Rollout} \label{alg:confident rollout}
\begin{algorithmic}[1]
\State \textbf{Input:} number of rollouts $n$, length of rollouts $H$, weight vector $w \in \mathbb{R}^d$, discount $\gamma$, initial state $s_0$, initial action $a^{(1:m)}$, feature matrix $\Phi_C$, regularization coefficient $\lambda$, threshold $\tau$.
\For {$i = 1, ..., n$}
\State $s_{i, 0} \gets s_0, a_{i, 0} \gets \bar a$, query the simulator, obtain reward $r_{i, 0} \gets r(s_{i, 0}, a_{i, 0})$, and the next state $s_{i, 1}$.
\For {$t = 1, ..., H$}
\For {$a^{(1:m)} \in \mathcal{A}^{(1:m)}$}
\State Compute feature $\phi(s, a^{(1:m)})$.
\If {$\phi(s, a^{(1:m)})^\top (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \phi(s, a^{(1:m)}) > \tau$}
\State status $\gets$ uncertain, result $\gets (s, a^{(1:m)}, \phi(s, a^{(1:m)}), \text{none})$
\State \Return {status, result}
\EndIf
\EndFor
\State $a_{i, t}^{(1:m)} = \argmax_{\tilde{a}^{(1:m)} \in \mathcal{A}^{(1:m)}} w^\top \phi(s, \tilde{a}^{(1:m)})$.
\State Query the simulator with $s, a_{i, t}^{(1:m)}$, obtain reward $r_{i, t} \gets r(s, a_{i, t}^{(1:m)})$, and next state $s_{i, {t+1}}$.
\EndFor
\EndFor
\State status $\gets$ done, result $\gets \frac{1}{n} \sum_{i=1}^n \sum_{t=0}^H \gamma^t r_{i, t}$
\State \Return status, result
\end{algorithmic}
\end{algorithm}
The issue with the above naive approach is that the loop in line 5 and the argmax in line 12 will require $O(\Pi_{i=1}^m |A^{(i)}|)$ computation.
We highlight that the argmax in line 12 can be computed in $O(\sum_{i=1}^m |A^{(i)}|)$ time under Assumption \ref{ass: ass1} as
$$a_{i, t}^{(1:m)} = \left(\argmax_{\tilde{a}^{(1)} \in \mathcal{A}^{(1)}} w^\top \phi_1(s, \tilde{a}^{(1)}), ..., \argmax_{\tilde{a}^{(m)} \in \mathcal{A}^{(m)}} w^\top \phi_m(s, \tilde{a}^{(m)})\right), $$
The difficulty then lies in reducing the computation time in the loop in line 5 from $O(\Pi_{i=1}^m |A^{(i)}|) \to O(\sum_{i=1}^m |A^{(i)}|)$.
Next we present an approaches to do this.
Define $V_\mathcal{C} = \Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I$ and a weighted matrix norm as $||x||_{Y}^2 = x^\top Y x, \ x \in \mathbb{R}^d, Y \in \mathbb{R}^{d \times d}$.
Define the \textit{good set} as $\mathcal{H} = \{ \phi(s, a^{(1:m)}): ||\phi(s, a^{(1:m)})||_{V_\mathcal{C}^{-1}}^2 \le \tau, s \in \mathcal{S}, a^{(1:m)} \in \mathcal{A}^{(1:m)} \}$
Line 7 can have two cases. Case A: $||\phi(s, a^{(1:m)})||_{V_\mathcal{C}^{-1}}^2 > \tau$. Or Case B: $||\phi(s, a^{(1:m)})||_{V_\mathcal{C}^{-1}}^2 \le \tau$.
Then lines 5-11 can have two cases. Case 1: Case A holds for at least one $a^{(1:m)} \in \mathcal{A}^{(1:m)}$. Or Case 2: Case B holds for all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
The goal of lines 5-11 were to ensure that we are able identify if we are in Case 1 or Case 2. This was important for two reasons.
Reason 1: was to make sure that the virtual algorithm (VA) and main algorithm (MA) had identical trajectories, until Case A occurred for the first time.
Reason 2: was to ensure that the VA was greedy w.r.t.
\begin{equation*}
\tilde{Q}(s, a^{(1:m)})=\begin{cases}
\tilde{w}^\top \phi(s, a^{(1:m)}) \quad &\text{if} \, \phi(s, a^{(1:m)}) \in \mathcal{H} \\
Q_{\tilde{\pi}}(s, a^{(1:m)}) \quad &\text{if} \, \phi(s, a^{(1:m)}) \notin \mathcal{H} \\
\end{cases}
\end{equation*}
since $\phi(s, a^{(1:m)}) \in \mathcal{H}$ is needed for Lemma B.3 in \cite{yin2021efficient}.
\subsection{Size of the Core Set}
The upper bound on the size of the core set depends on the 2-norm of the features added to it.
We introduce what we believe is a more natural assumption on the bound of the features for the multi-agent setting (compared to a bound of $1$).
\begin{assumption}[Bounded features]
\label{ass: bounded features}
We assume that $||\phi(s, a^{(1:m)})||_2 = ||\sum_{i=1}^m \phi_i(s, a^{(i)})||_2 \le m$ for all $(s, a^{(1:m)}) \in \mathcal{S} \times \mathcal{A}^{(1:m)}$
\end{assumption}
We have the following lemma bounding the size of the core set:
\begin{theorem}
[Size of the core set]
\label{thm:size of core set}
Under Assumption \ref{ass: bounded features} the size of the core set $\mathcal{C}$ will not exceed
\begin{equation}
C_{\max} :=
\frac{m^2 d(1 + \tau)}{\lambda \tau^2}
\end{equation}
\end{theorem}
\begin{proof}
The proof is almost the same as the proof in the older version of \cite{yin2021efficient} (This is a \href{https://arxiv.org/pdf/2108.05533v2.pdf}{link} to the version) that didn't have the Politex result yet (which worked by first noting that the trace of $V_\mathcal{C}^{-1}$ must always be greater than zero since $V_\mathcal{C}^{-1}$ is positive definite for all $\mathcal{C}$ and equal to exactly $d/\lambda$ when the core set is empty, then showing that each time you add a new feature to the core set the trace of $V_\mathcal{C}^{-1}$ decreases by $\tau^2/(1+\tau)$).
The only difference is that the term $\sum_{i=1}^d \alpha_i^2 = ||\alpha||_2^2$ in equation A.7 is bounded by $m^2$ instead of $1^2$, scaling the final bound by a factor of $m^2$.
\end{proof}
\subsubsection{Logarithmic Dependence on $m$}
Using the analysis of the newer version of \cite{yin2021efficient} for the size of the core set,
we get the following upper bound for the size of the core set:
\begin{align}
\tilde{C}_{\max} := \frac{e}{e-1} \frac{1 + \tau}{\tau} d \left(
\log(1 + \frac{1}{\tau}) +
\log(1 + \frac{m}{\lambda})
\right) \label{eq:cmax-new}
\end{align}
\subsection{Policy Evaluation}
We have two different algorithms for multi-agent-confident rollout,
and each one results in a different bound for policy evaluation.
Therefore, in this section, we state these two algorithms for multi-agent rollout
alongside their theoretical guarantees and computational complexities.
In the next section, we use these results for policy improvement and obtain the final sub-optimality for these algorithms.
\subsubsection{Default Action Vector Approach (DAV)}
This approach aims to leverage our understanding of why lines 5-11 were necessary (namely Reason 1 and Reason 2) to modify Algorithm \ref{alg:confident rollout} in a clever way such that we only need to check if $O(\sum_{i=1}^m |A^{(i)}|)$ action vectors are in the good set.
We introduce the notation $(x^{(i)}, y^{(-i)}) = (y^{(1)}, ..., x^{(i)}, ..., y^{(m)})$.
We define a \textit{default action vector} $\bar a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
It is just a fixed action vector that must be selected at the beginning of Algorithm 1 from \cite{yin2021efficient} and held constant throughout.
Thus, whenever we refer to the default action vector we are always talking about the exact same vector and thus the policy does not change for different instances of Algorithm \ref{alg:confident rollout da}.
The modified algorithm is presented as Algorithm \ref{alg:confident rollout da}, where the differences between Algorithm \ref{alg:confident rollout} and Algorithm \ref{alg:confident rollout da} are in blue.
For completeness we also include Algorithm \ref{alg:confident ma mc-lspi dav} (modified Algorithm 1 from \cite{yin2021efficient}) which makes calls to Algorithm \ref{alg:confident rollout da}).
The differences between Algorithm \ref{alg:confident ma mc-lspi dav} and Algorithm 1 from \cite{yin2021efficient} are indicated in blue.
\begin{algorithm}
\caption{Multi-Agent(MA)-Confident Rollout with Default Action Vector(DAV)} \label{alg:confident rollout da}
\begin{algorithmic}[1]
\State \textbf{Input:} number of rollouts $n$, length of rollouts $H$, rollout policy $\pi$, discount $\gamma$, initial state $s_0$, initial action vector $a_0^{(1:m)}$, \textcolor{blue}{default action vector $\bar a^{(1:m)}$}, feature matrix $\Phi_C$, regularization coefficient $\lambda$, threshold $\tau$.
\For {$i = 1, ..., n$}
\State $s_{i, 0} \gets s_0, a_{i, 0} \gets a_0$, query the simulator, obtain reward $r_{i, 0} \gets r(s_{i, 0}, a_{i, 0})$, and the next state $s_{i, 1}$.
\For {$t = 1, ..., H$}
\If {\textcolor{blue}{$\phi(s_{i, t}, \bar a^{(1:m)})^\top (\Phi_C^\top \Phi_C + \lambda I)^{-1} \phi(s_{i, t}, \bar a^{(1:m)}) > \tau$}} \Comment{Ensure $\phi(s_{i, t}, \bar a^{(1:m)})$ is in the good set}
\State \textcolor{blue}{$\mathcal{C} \gets \mathcal{C} \cup \{(s_{i, t}, \bar a^{(1:m)}, \phi(s_{i, t}, \bar a^{(1:m)}), \text{none})\}$}
\EndIf
\For {\textcolor{blue}{$j \in [m]$}}
\For {\textcolor{blue}{$a^{(j)} \in \mathcal{A}^{(j)}$}}
\State \textcolor{blue}{Compute feature $\phi(s_{i,t}, (a^{(j)}, \bar a^{(-j)})$.}
\If {\textcolor{blue}{$\phi(s_{i, t}, (a^{(j)}, \bar a^{(-j)}))^\top (\Phi_C^\top \Phi_C + \lambda I)^{-1} \phi(s_{i, t}, (a^{(j)}, \bar a^{(-j)})) > \tau$}}
\State \textcolor{blue}{status $\gets$ uncertain, result $\gets (s_{i, t}, (a^{(j)}, \bar a^{(-j)}), \phi(s_{i, t}, (a^{(j)}, \bar a^{(-j)})), \text{none})$}
\State \Return {status, result}
\EndIf
\EndFor
\EndFor
\State \textcolor{blue}{$a_{i, t}^{(1:m)} \sim \pi(\cdot | s_{i,t})$}
\State Query the simulator with $s_{i, t}, a_{i, t}^{(1:m)}$, obtain reward $r_{i, t} \gets r(s_{i, t}, a_{i, t}^{(1:m)})$, and next state $s_{i, {t+1}}$.
\EndFor
\EndFor
\State status $\gets$ done, result $\gets \frac{1}{n} \sum_{i=1}^n \sum_{t=0}^H \gamma^t r_{i, t}$
\State \Return status, result
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{Confident Multi-Agent MC-LSPI DAV} \label{alg:confident ma mc-lspi dav}
\begin{algorithmic}[1]
\State \textbf{Input:} initial state $\rho$, \textcolor{blue}{default action vector $\bar a^{(1:m)}$}, initial policy $\pi_0$, number of iterations $K$, regularization coefficient $\lambda$, threshold $\tau$, discount $\gamma$, number of rollouts $n$, length of rollout $H$
\State {$\mathcal{C} \gets \emptyset$}
\If {\textcolor{blue}{$\phi(\rho, \bar a^{(1:m)})^\top (\Phi_C^\top \Phi_C + \lambda I)^{-1} \phi(\rho, \bar a^{(1:m)}) > \tau$}} \Comment{Ensure $\phi(\rho, \bar a^{(1:m)})$ is in the good set}
\State \textcolor{blue}{$\mathcal{C} \gets \mathcal{C} \cup \{(\rho, \bar a^{(1:m)}, \phi(\rho, \bar a^{(1:m)}), \text{none})\}$}
\EndIf
\For {\textcolor{blue}{$j \in [m]$}}
\For {\textcolor{blue}{$a^{(j)} \in \mathcal{A}^{(j)}$}}
\If {\textcolor{blue}{$\mathcal{C} = \emptyset \text{ or } \phi(\rho, (a^{(j)}, \bar a^{(-j)}))^\top (\Phi_C^\top \Phi_C + \lambda I)^{-1} \phi(\rho, (a^{(j)}, \bar a^{(-j)})) > \tau$}}
\State \textcolor{blue}{$\mathcal{C} \gets \mathcal{C} \cup \{(\rho, (a^{(j)}, \bar a^{(-j)}), \phi(\rho, (a^{(j)}, \bar a^{(-j)})), \text{none})\}$}
\EndIf
\EndFor
\EndFor
\State $z_q \gets \text{none}, \, \forall z \in \mathcal{C}$ \quad \Comment{Policy iteration starts $(*)$}
\For {$k \in 1, \dots, K$}
\For {$z \in \mathcal{C}$}
\State status, result $\gets \text{MA-Confident Rollout with DAV}(n, H, \pi_{k-1}, \gamma, z_s, z_{a^{(1:m)}},$\textcolor{blue}{$\bar a^{(1:m)}$}, $\Phi_\mathcal{C}, \lambda, \tau)$
\State \textbf{if} status $=$ done, \textbf{then} $z_q = \text{result}$; \textbf{else} $\mathcal{C} \gets \mathcal{C} \cup \{\text{result}\}$ and \textbf{goto} line $(*)$
\EndFor
\State $w_k \gets (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \Phi_\mathcal{C}^\top q_\mathcal{C}$
\State \textcolor{blue}{$\pi_k(a^{(1:m)}|s) \gets \mathbf{1}(a^{(1:m)} = (\argmax_{\tilde{a}^{(1)} \in \mathcal{A}^{(1)}} w^\top \phi_1(s, \tilde{a}^{(1)}), ..., \argmax_{\tilde{a}^{(m)} \in \mathcal{A}^{(m)}} w^\top \phi_m(s, \tilde{a}^{(m)})))$}
\EndFor
\State \Return $w_{K-1}$.
\end{algorithmic}
\end{algorithm}
Define the polynomial sized set of modified default action vectors as $\bar \mathcal{A}^{(1:m)} = \{ (a^{(i)}, \bar a^{(-i)}): a^{(i)} \in \mathcal{A}^{(i)}, \ i \in [m] \}$.
Define the set of states for which all the modified default action vectors are in the good set as $\bar \mathcal{S} = \{ s \in \mathcal{S}: ||\phi(s, a^{(1:m)})||_{V_\mathcal{C}^{-1}}^2 \le \tau, \forall a^{(1:m)} \in \bar \mathcal{A}^{(1:m)} \}$.
Notice that we can not satisfy Reason 2, unless we are sure $\phi(s, a^{(1:m)}) \in \mathcal{H}$ for all $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$.
In the next subsection we ensure that for a given state all $\Pi_{i=1}^m |A^{(i)}|$ feature vectors are in the good set in $\sum_{i=1}^m |A^{(i)}|$ computation time, while in this subsection we chose to redefine $\tilde Q$.
Consider iteration $k$ of policy iteration.
We redefine the VA value function as
\begin{equation*}
\tilde Q_{k-1}(s, a^{(1:m)})=\begin{cases}
\tilde w_k^\top \phi(s, a^{(1:m)}) \quad & s \in \bar \mathcal{S} \\
Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)}). \quad & s \in \mathcal{S} \backslash \bar \mathcal{S}
\end{cases}
\end{equation*}
We define the VA policy as (this definition is the same as in \cite{yin2021efficient}, but our $\tilde Q_{k-1}$ is different)
\begin{equation*}
\tilde{\pi}_k (a^{(1:m)}|s) = \mathbf{1} \left(a^{(1:m)} = \argmax_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \tilde Q_{k-1}(s, a^{(1:m)})\right)
\end{equation*}
where $\tilde w_k = V_\mathcal{C}^{-1} \Phi_\mathcal{C}^\top \tilde q_\mathcal{C}$, and $\tilde q_\mathcal{C}$, including all other details about the VA, are the same as explained in B.1 of the Appendix in \cite{yin2021efficient}.
\subsubsection*{A Bound for Policy Evaluation for all Actions}
Our goal is to ensure that $||\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})||_\infty$ is bounded.
The purpose for this is so that we can use Lemme B.3 from \cite{yin2021efficient}.
For completeness, we first state a slight modification of Lemme B.2 from \cite{yin2021efficient} that uses the fact that the approximation error $\epsilon = 0$ in our case due to Assumption \ref{ass: ass1}.
As done in \cite{yin2021efficient}, we will use $w_\pi$ to denote the parameter vector that ensures $||w_\pi^\top \phi(s, a^{(1:m)}) - Q_\pi(s, a^{(1:m)})||_\infty = 0$ (Assumption \ref{ass: ass1}).
\begin{lemma}[DAV modified Lemma B.2 from \cite{yin2021efficient}]
\label{lemma: mod b.2}
Suppose that Assumption \ref{ass: ass1} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
for any $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ pair such that $\phi(s, a^{(1:m)}) \in \mathcal{H}$, we have
$$|\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde\pi_{k-1}}^\top \phi(s, a^{(1:m)})| \le b\sqrt{\lambda \tau} + \left( \frac{\gamma^{H-1}}{1 - \gamma} + \theta \right) \sqrt{\tau C_{\text{max}}} := \bar\eta$$
\end{lemma}
\begin{proof}
The proof is identical to that of Lemme B.2 from \cite{yin2021efficient} with the triangle inequality for the approximation error step removed and then the approximation error set to zero due to our Assumption \ref{ass: ass1}.
Also $\tilde{Q}_{k-1}(s, a^{(1:m)})$ in the Lemme B.2 from \cite{yin2021efficient} was replaced with $\tilde{w}_k^\top \phi(s, a^{(1:m)})$, since Lemme B.2 only holds for features in the good set, in which case $\tilde{Q}_{k-1}(s, a^{(1:m)}) = \tilde{w}_k^\top \phi(s, a^{(1:m)})$ (where $\tilde{Q}_{k-1}$ in the last line is as defined in \cite{yin2021efficient}).
\end{proof}
We now show that $||\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})||_\infty$ can be bounded.
\begin{prop}[approximate value function bound for DAV]
\label{prop: approx value function bound for DAV}
Suppose that Assumption \ref{ass: ass1} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
we have
$$||\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})||_\infty \le \bar\eta (2m-1) := \eta_1.$$
\end{prop}
\begin{proof}
For any $(s, a^{(1:m)}) \in (\bar \mathcal{S} \times \mathcal{A}^{(1:m)})$, we have
\begin{align}
& |\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&= |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&= |\tilde{w}_k^\top \phi(s, a^{(1:m)}) \pm w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&\le |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)})| + |w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&\le |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)})| + 0 \nonumber \\
&= |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)}) \pm (m-1)\tilde{w}_k^\top \phi(s, \bar a^{(1:m)}) \pm (m-1) w_{\tilde{\pi}_{k-1}}^\top \phi(s, \bar a^{(1:m)})| \nonumber \\
&= \left|\left( \sum_{i=1}^m \tilde{w}_k^\top \phi(s, (a^{(i)}, \bar a^{(-i)})) - w_{\tilde\pi_{k-1}}^\top \phi(s, (a^{(i)}, \bar a^{(-i)})) \right) + (m-1)\left[w_{\tilde{\pi}_{k-1}}^\top \phi(s, \bar a^{(1:m)})) - \tilde{w}_k^\top \phi(s, \bar a^{(1:m)}\right]\right| \nonumber \\
&\le m \bar\eta + (m-1) \bar \eta \nonumber \\
&= \bar\eta (2m-1) \label{value function bound 1}
\end{align}
where the second last inequality holds by Lemma \ref{lemma: mod b.2} (because the features of all the state action pairs considered are in $\mathcal{H}$, since $s \in \bar \mathcal{S}$).
While for any $(s, a^{(1:m)}) \in ((\mathcal{S} \backslash \bar \mathcal{S}) \times \mathcal{A}^{(1:m)})$, we have
\begin{align}
|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})|
= |Q_{\tilde \pi_{k-1}}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})|
&= 0 \label{value function bound 2}
\end{align}
\end{proof}
\subsubsection{Efficient Good Set Search Approach (EGSS)} \label{subsec:good set search}
In this subsection we aim to satisfy Reason 2 in polynomial time.
Namely, we ensure that for a given state all $\Pi_{i=1}^m |A^{(i)}|$ feature vectors are in the good set in $O(\sum_{i=1}^m |A^{(i)}|)$ computation time.
\begin{lemma}[Efficient good set search]
\label{lemma:good set search}
With all terms as defined earlier.
One can ensure, with computation time $2 d^2 \sum_{i=1}^m |A^{(i)}|$ that either
$$\phi(s, a^{(1:m)})^\top V_\mathcal{C}^{-1} \phi(s, a^{(1:m)}) \le \sqrt{d}\tau$$
for all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ or there exists an $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ such that
$$\phi(s, a^{(1:m)})^\top V_\mathcal{C}^{-1} \phi(s, a^{(1:m)}) > \tau$$
\end{lemma}
\begin{proof}
Recall that we are able to compute $\max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle u, \phi(s, a^{(1:m)}) \rangle$ for any $u \in \mathbb{R}^d$ in $d \sum_{i=1}^m |A^{(i)}|$ time (due to the linear decomposition of the features for each agent).
Now, we make use of a bidirectional 2-norm to $\infty$-norm inequality that will take advantage of the above mentioned efficient computation.
Fix $\mathcal{C}$ and define the lower triangular matrix $L$ via the Cholesky decomposition $V_\mathcal{C}^{-1} = V^{-1} = L L^\top$.
Define $\{e_i\}_{i=1}^d$ as the standard basis vectors and
\begin{equation*}
(v^*, a_\text{max}^{(1:m)}) := \text{arg} \left(\max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle L v, \phi(s, a^{(1:m)}) \rangle \right)
\end{equation*}
Then we have that
\begin{align}
\frac{1}{\sqrt{d}} \| \phi(s, a_\text{max}^{(1:m)}) \|_{V^{-1}}
&= \frac{1}{\sqrt{d}} \sqrt{\phi(s, a_\text{max}^{(1:m)})^\top V^{-1} \phi(s, a_\text{max}^{(1:m)})} \nonumber \\
&= \frac{1}{\sqrt{d}} \sqrt{\phi(s, a_\text{max}^{(1:m)})^\top L L^\top \phi(s, a_\text{max}^{(1:m)})} \nonumber \\
&= \frac{1}{\sqrt{d}} \| L^\top \phi(s, a_\text{max}^{(1:m)}) \|_2 \nonumber \\
&\le \max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \| L^\top \phi(s, a^{(1:m)})\|_\infty \nonumber \\
&= \max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle v, L^\top \phi(s, a^{(1:m)}) \rangle \nonumber \\
&= \max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle L v, \phi(s, a^{(1:m)}) \rangle \nonumber \\
&= \langle L v^*, \phi(s, a^{(1:m)}_\text{max}) \rangle \label{inf-norm term} \\
&\le \| L^\top \phi(s, a_\text{max}^{(1:m)}) \|_2 \nonumber
\end{align}
Notice that the purpose of writing all the equalities up to equation (\ref{inf-norm term}) was to show that equation (\ref{inf-norm term}) can be computed in $2 d^2 \sum_{i=1}^m |A^{(i)}|$.
Since $\max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle L v, \phi(s, a^{(1:m)})$ can be computed in $d \sum_{i=1}^m |A^{(i)}|$ time and $\{\pm e_i\}_{i=1}^d$ contains $2d$ elements.
Also, noting that $L v = $
Also, note that $L$ can be computed with $d^2$ computation in each loop by doing a \href{https://en.wikipedia.org/wiki/Cholesky_decomposition#Rank-one_update}{rank one update to the Cholesky decomposition} of $V^{-1} = L L^\top$.
For further details see \ref{vec and eff implementation}.
If equation (\ref{inf-norm term}) is larger than $\tau$, then $\|\phi(s, a_\text{max}^{(1:m)}) \|_{V^{-1}}^2 > \tau$.
While, if equation (\ref{inf-norm term}) is less than or equal $\tau$, then $\|\phi(s, a_\text{max}^{(1:m)}) \|_{V^{-1}}^2 \le \sqrt{d}\tau$, completing the proof.
\end{proof}
We now introduce Algorithm \ref{alg:confident rollout egss}, which makes use of the result from Lemma \ref{lemma:good set search} in lines 5-11.
For completeness we also include Algorithm \ref{alg:confident ma mc-lspi egss} (modified Algorithm 1 from \cite{yin2021efficient}) which makes calls to Algorithm \ref{alg:confident rollout egss}).
Notice that Lemma \ref{lemma:good set search} provides a weaker guarantee if lines 5-11 in Algorithm \ref{alg:confident rollout egss} run without termination than if lines 5-11 in Algorithm \ref{alg:confident rollout} run without termination.
Specifically, if lines 5-11 in Algorithm \ref{alg:confident rollout egss} run without termination, then Lemma \ref{lemma:good set search} guarantees that $||\phi(s, a^{(1:m)})||_{V_\mathcal{C}^{-1}}^2 \le \sqrt{d}\tau$ for all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
While if lines 5-11 in Algorithm \ref{alg:confident rollout} run without termination, then $||\phi(s, a^{(1:m)})||_{V_\mathcal{C}^{-1}}^2 \le \tau$ for all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$, since all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ were checked.
Although the guarantee $||\phi(s, a^{(1:m)})||_{V_\mathcal{C}^{-1}}^2 \le \sqrt{d}\tau$ in Algorithm \ref{alg:confident rollout egss} introduces an extra $\sqrt{d}$ factor in the suboptimality of policy evaluation (when compared to Algorithm \ref{alg:confident rollout}, as we shall show next), it does not need to perform computation exponential in the number of agents (i.e. $\Pi_{i=1}^m |A^{(i)}|$ computation) like Algorithm \ref{alg:confident rollout}.
\begin{algorithm}
\caption{Multi-Agent(MA)-Confident Rollout with Efficient Good Set Search(EGSS)} \label{alg:confident rollout egss}
\begin{algorithmic}[1]
\State \textbf{Input:} number of rollouts $n$, length of rollouts $H$, rollout policy $\pi$, discount $\gamma$, initial state $s_0$, initial action vector $a_0^{(1:m)}$, feature matrix $\Phi_C$, regularization coefficient $\lambda$, threshold $\tau$.
\For {$i = 1, ..., n$}
\State $s_{i, 0} \gets s_0, a_{i, 0} \gets a_0$, query the simulator, obtain reward $r_{i, 0} \gets r(s_{i, 0}, a_{i, 0})$, and the next state $s_{i, 1}$.
\For {$t = 1, ..., H$}
\State \textcolor{blue}{max\_uncertainty, $a_\text{max}^{(1:m)} \gets \text{EGSS}(\rho, \lambda, \Phi_\mathcal{C})$}
\If {\textcolor{blue}{$\text{max\_uncertainty} > \tau$}}
\State \textcolor{blue}{status $\gets$ uncertain, result $\gets (s_{i, t}, a_\text{max}^{(1:m)}, \phi(s_{i, t}, a_\text{max}^{(1:m)}), \text{none})$}
\State \Return {status, result}
\EndIf
\State \textcolor{blue}{$a_{i, t}^{(1:m)} \sim \pi(\cdot | s_{i,t})$}
\State Query the simulator with $s_{i, t}, a_{i, t}^{(1:m)}$, obtain reward $r_{i, t} \gets r(s_{i, t}, a_{i, t}^{(1:m)})$, and next state $s_{i, {t+1}}$.
\EndFor
\EndFor
\State status $\gets$ done, result $\gets \frac{1}{n} \sum_{i=1}^n \sum_{t=0}^H \gamma^t r_{i, t}$
\State \Return status, result
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{Confident Multi-Agent MC-LSPI EGSS} \label{alg:confident ma mc-lspi egss}
\begin{algorithmic}[1]
\State \textbf{Input:} initial state $\rho$, initial policy $\pi_0$, number of iterations $K$, regularization coefficient $\lambda$, threshold $\tau$, discount $\gamma$, number of rollouts $n$, length of rollout $H$
\State {$\mathcal{C} \gets \emptyset$}
\State \textcolor{blue}{max\_uncertainty, $a_\text{max}^{(1:m)} \gets \text{EGSS}(\rho, \lambda, \Phi_\mathcal{C})$}
\While {\textcolor{blue}{$\mathcal{C} = \emptyset \text{ or } \text{max\_uncertainty} > \tau$}}
\State \textcolor{blue}{$\mathcal{C} \gets \mathcal{C} \cup \{(\rho, a_\text{max}^{(1:m)}, \phi(\rho, a_\text{max}^{(1:m)}), \text{none})\}$}
\State \textcolor{blue}{max\_uncertainty, $a_\text{max}^{(1:m)} \gets \text{EGSS}(\rho, \lambda, \Phi_\mathcal{C})$}
\EndWhile
\State $z_q \gets \text{none}, \, \forall z \in \mathcal{C}$ \quad \Comment{Policy iteration starts $(*)$}
\For {$k \in 1, \dots, K$}
\For {$z \in \mathcal{C}$}
\State status, result $\gets \text{MA-Confident Rollout with EGSS}(n, H, \pi_{k-1}, \gamma, z_s, z_{a^{(1:m)}},\Phi_\mathcal{C}, \lambda, \tau)$
\State \textbf{if} status $=$ done, \textbf{then} $z_q = \text{result}$; \textbf{else} $\mathcal{C} \gets \mathcal{C} \cup \{\text{result}\}$ and \textbf{goto} line $(*)$
\EndFor
\State $w_k \gets (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \Phi_\mathcal{C}^\top q_\mathcal{C}$
\State \textcolor{blue}{$\pi_k(a^{(1:m)}|s) \gets \mathbf{1}(a^{(1:m)} = (\argmax_{\tilde{a}^{(1)} \in \mathcal{A}^{(1)}} w^\top \phi_1(s, \tilde{a}^{(1)}), ..., \argmax_{\tilde{a}^{(m)} \in \mathcal{A}^{(m)}} w^\top \phi_m(s, \tilde{a}^{(m)})))$}
\EndFor
\State \Return $w_{K-1}$.
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{EGSS} \label{alg:egss}
\begin{algorithmic}[1]
\State \textbf{Input:} {\textcolor{blue}{state $s$, regularization coefficient $\lambda$, uncertainty matrix $\Phi$}}
\State {\textcolor{blue}{$L \gets \text{Cholesky}((\Phi^\top \Phi + \lambda I)^{-1})$ \Comment{where $L L^\top = (\Phi^\top \Phi + \lambda I)^{-1}$}}}
\For {\textcolor{blue}{$v \in \{\pm e_l\}_{l = 1}^d$}}
\State \textcolor{blue}{$a_\text{temp}^{(1:m)} \gets \emptyset$}
\State \textcolor{blue}{max\_uncertainty $\gets 0$}
\For {\textcolor{blue}{$j \in [m]$}}
\State \textcolor{blue}{$a_\text{temp}^{(1:m)}.\text{append}\left(\argmax_{a^{(j)} \in \mathcal{A}^{(j)}} \left[\phi(s, a^{(j)})^\top L v \right]^2 \right)$}
\EndFor
\If {\textcolor{blue}{$\left[\phi(s, a_\text{temp}^{(1:m)})^\top L v\right]^2 \ge \text{max\_uncertainty}$}}
\State {\textcolor{blue}{$a_\text{max}^{(1:m)} \gets a_\text{temp}^{(1:m)}$}}
\State {\textcolor{blue}{$\text{max\_uncertainty} \gets \left[\phi(s, a_\text{max}^{(1:m)})^\top L v\right]^2$}}
\EndIf
\EndFor
\State \Return \textcolor{blue}{max\_uncertainty, $a_\text{max}^{(1:m)}$}.
\end{algorithmic}
\end{algorithm}
We now explicitly show how the suboptimality of policy evaluation is affected by this change
\begin{lemma}[EGSS modified Lemma B.2 from \cite{yin2021efficient}]
\label{lemma: mod b.2 egss}
Suppose that Assumption \ref{ass: ass1} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
for any $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ pair such that $\phi(s, a^{(1:m)}) \in \mathcal{H}$, we have
$$|\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde\pi_{k-1}}^\top \phi(s, a^{(1:m)})| \le b\sqrt{\lambda \sqrt{d} \tau} + \left( \frac{\gamma^{H+1}}{1 - \gamma} + \theta \right) \sqrt{\sqrt{d} \tau C_{\text{max}}} := \eta_2$$
\end{lemma}
\begin{proof}
The proof is identical to that of Lemme B.2 from \cite{yin2021efficient} except $\tau$ is replaced with $\sqrt{d} \tau$ everywhere, due to the weaker guarantee by lines 5-11 of Algorithm \ref{alg:confident rollout egss} as discussed above.
\end{proof}
Since the virtual policy has access to the true value function for the elements outside of the $\mathcal{H}$,
we have the following bound on the error of policy evaluation for EGSS.
\begin{prop}[approximate value function bound for EGSS]
\label{prop: approx value function bound for EGSS}
Suppose that Assumption \ref{ass: ass1} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
we have
$$||\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})||_\infty \le \eta_2.$$
\end{prop}
\subsubsection{Vectorized and Efficient Implementation} \label{vec and eff implementation}
We describe how calculating equation (\ref{inf-norm term}) can be implemented in a vectorized way, such that it is more efficient in code.
Stacking the elements of $\{+ e_i\}_{i=1}^d$ as the rows of a matrix we can write is as the identity matrix $I \in \mathbb{R}^{d \times d}$.
Similarly stacking the elements of $\{- e_i\}_{i=1}^d$ as the rows of a matrix we can write it as the negative identity matrix $-I \in \mathbb{R}^{d \times d}$.
Hence, stacking the elements of $\{\pm e_i\}_{i=1}^d$ as the rows of a matrix we can write is as$[I, -I] \in \mathbb{R}^{d \times 2d}$.
Define $X = [LI, -LI]^\top = [L, -L]^\top$.
Fix a state $s \in \mathcal{S}$.
Then,
\begin{align*}
& \max_{v \in \{\pm e_i\}_{i=1}^d} \langle Lv, \phi(s, a^{(1:m)}) \rangle = \max_{i \in [2d]} (X \phi(s, a^{(1:m)})_i) & a^{(1:m)} \in \mathcal{A}^{(1:m)}
\end{align*}
Define $\Phi_{\mathcal{A}^{(1:m)}} = [\phi(s, a^{(1:m)})_1, ..., \phi(s, a^{(1:m)})_g]$ where $g = {\sum_{j=1}^m A_i}$ and $\{a^{(1:m)}_i\}_{j=1}^g = \mathcal{A}^{(1:m)}$.
Then,
\begin{align*}
& \max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle Lv, \phi(s, a^{(1:m)} \rangle = \max_{(i, k) \in [2d] \times [g]} (X \Phi_{\mathcal{A}^{(1:m)}})_{i, k}
\end{align*}
Since the features can be written as a linear combination of the features of each agent (i.e. $\phi(s, a^{(1:m)}) = \sum_{j=1}^m \phi_j(s, a^{(j)})$ we define $\Phi_{\mathcal{A}^{(j)}} = [\phi_j(s, a^{(j)})_1, ..., \phi_j(s, a^{(j)})_{A_j}]$ where $j \in [m]$.
Then equation (\ref{inf-norm term}) can be computed as,
\begin{align*}
& \max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle Lv, \phi(s, a^{(1:m)} \rangle = \max_{i \in [2d]} \left( \max_{k \in [A_1]}(X \Phi_{\mathcal{A}^{(1)}})_{:, k} + ... + \max_{k \in [A_m]}(X \Phi_{\mathcal{A}^{(m)}})_{:, k} \right)_i
\end{align*}
where $\max_{k \in [A_j]}(X \Phi_{\mathcal{A}^{(j)}})_{:, k} = [\max_{k \in [A_i]}(X \Phi_{\mathcal{A}^{(j)}})_{1, k}, ..., \max_{k \in [A_i]}(X \Phi_{\mathcal{A}^{(j)}})_{2d, k}]^\top$
We now mention another useful technique to speed up computation.
Notice that
\begin{align*}
\max_{k \in [g]}(X \Phi_{\mathcal{A}^{(1)}})_{:, k} = \left[\max_{k \in [A_1]}(L^\top \Phi_{\mathcal{A}^{(1)}})_{:, k}, \max_{k \in [A_1]}(-L^\top \Phi_{\mathcal{A}^{(1)}})_{:, k}\right]
\end{align*}
and that $(L^\top \Phi_{\mathcal{A}^{(j)}})_k = L^\top \phi_j(s, a^{(j)}_k)$ where $k \in [A_j]$ and $\{a^{(j)}_k\}_{k \in [A_j]} = \mathcal{A}^{(j)}$.
Define the Cholesky decomposition of $V = M M^\top$.
Then, $V^{-1} = L L^\top = (M M^\top)^{-1} = M^{-\top} M^{-1}$
Noticing that everything above would hold with $L$ replaced with $M^{-\top}$, since we only require that
$$\phi(s, a_\text{max}^{(1:m)})^\top V_\mathcal{C}^{-1} \phi(s, a_\text{max}^{(1:m)}) = \phi(s, a_\text{max}^{(1:m)})^\top L L^\top \phi(s, a_\text{max}^{(1:m)}) = \phi(s, a_\text{max}^{(1:m)})^\top M^{-\top} M^{-1} \phi(s, a_\text{max}^{(1:m)})$$
Now, $L^\top \phi_j(s, a^{(j)}_k) = M^{-\top} \phi_j(s, a^{(j)}_k)$.
Define $y = M^{-\top} \phi_j(s, a^{(j)}_k)$.
Then, $y$ can be calculated by solving for $y$ in $M^\top y = \phi_j(s, a^{(j)}_k)$ which can be done by using forward substitution since $M^\top$ is upper triangular.
Define the forward substitution function as $\text{FS}(M^\top, \phi_j(s, a^{(j)}_k)) = M^{-\top} \phi_j(s, a^{(j)}_k)$ and $\text{FS}(M^\top, \Phi_{\mathcal{A}^{(j)}}) = M^{-\top} \Phi_{\mathcal{A}^{(j)}}$
Then,
\begin{align*}
\max_{k \in [g]}(X \Phi_{\mathcal{A}^{(1)}})_{:, k} = \left[\max_{k \in [A_1]}(\text{FS}(M^\top, \Phi_{\mathcal{A}^{(j)}}))_{:, k}, \max_{k \in [A_1]}(\text{FS}(-M^\top, \Phi_{\mathcal{A}^{(j)}}))_{:, k}\right]
\end{align*}
Which only requires computing the Cholesky decomposition of $V = M M^T$ instead of $V^{-1} = L L^T$.
Thus, the inverse of $V^{-1}$ need not be computed.
Further, recall that we fixed $\mathcal{C}$, but in general $V = V_\mathcal{C}$.
Denote $\mathcal{C}^\prime$ as the core set after a new feature $\phi^\prime$ is added to it.
Then $V_{\mathcal{C}^\prime} = V_{\mathcal{C}} + \phi^\prime {\phi^\prime}^\top$ and thus, the Cholesky decomposition of $V_{\mathcal{C}^\prime}$ can be computed using a \href{https://en.wikipedia.org/wiki/Cholesky_decomposition#Rank-one_update}{rank one Cholesky update}.
\subsection{Policy Improvement}
In this section we assume that we have a high probability bound on the policy evaluation
like the ones from DAV \ref{prop: approx value function bound for DAV} and EGSS \ref{prop: approx value function bound for EGSS},
and show the sub-optimality of the policy obtained at the last iteration of policy improvement.
\begin{lemma}[approximate policy iteration]
\label{lemma:approximate policy iteration}
Suppose that we run K approximate policy iterations and generate a sequence of policies
$\pi_0, \pi_1, \pi_2, \cdots, \pi_K$.
Suppose that for every $k = 1, 2, \cdots, K$, in the k-th iteration, we obtain a function
$\tilde{Q}_{k-1}$ such that, $\| \tilde{Q}_{k - 1} - Q_{\pi_{k - 1}} \|_\infty \leq \eta$,
and choose $\pi_k$ to be greedy with respect to $\tilde{Q}_{k-1}$.
Then
\begin{align*}
\| Q^* - Q_{\pi_K} \|_\infty \leq \frac{2 \eta}{1 - \gamma} + \frac{\gamma^K}{1 - \gamma},
\end{align*}
\end{lemma}
\begin{proof}
This lemma is a direct consequence of the results in \cite{munos2003error} and \cite{farahmand2010error}.
\end{proof}
Under the same assumption as lemma \ref{lemma:approximate policy iteration}, since $\| \tilde{Q}_{K-1} - Q_{\pi_{K-1}} \| \leq \eta$,
we know that:
\begin{align}
\|Q^* - \tilde{Q}_{K-1} \|_\infty \leq \frac{3 \eta}{1 - \gamma} + \frac{\gamma^{K - 1}}{1 - \gamma} \label{eq: q function bound}
\end{align}
\begin{lemma}
[\cite{singh1994upper}]
\label{lemma: value function bound}
Let $\pi$ be greedy with respect to a function $Q$.
Then for any state s,
\begin{align*}
V^*(s) - V_\pi(s) \leq \frac{2}{1 - \gamma} \| Q^* - Q \|_\infty.
\end{align*}
\end{lemma}
Using lemma \ref{lemma: value function bound} and equation \ref{eq: q function bound}, and the fact that $\pi_K$ is greedy with respect to $\tilde{Q}_{K-1}$, we know that:
\begin{align}
V^*(s) - V_{\pi_K}(s) \leq \frac{6 \eta}{(1 - \gamma)^2} + \frac{2 \gamma^{K - 1}}{(1 - \gamma)^2}. \label{eq: v function bound}
\end{align}
We obtained the results in lemma \ref{lemma: value function bound} and \ref{lemma:approximate policy iteration}
based on having bounded policy evaluation bound in all $K$ iteration of policy improvement.
However, we can only bound policy evaluation error with high probability using propositions \ref{prop: approx value function bound for DAV} and \ref{prop: approx value function bound for EGSS}.
Therefore, we need to use another union bound over all iterations of policy improvement to be able to use inequality \ref{eq: v function bound}.
Since we have $K$ iterations of policy improvement the final bound holds with probability
\begin{align*}
1 - 2KC_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n).
\end{align*}
\subsection{Main Algorithm}
The results stated so far are true for the virtual algorithm (with the access to the true value function for $\phi(s, a^{(1:m)} \notin \mathcal{H}$).
However, using the same arguments as section B.3 of \cite{yin2021efficient}, one can show that the final sub-optimality of the corresponding main algorithm
starting at state $\rho$ with probability at least
\begin{align*}
1 - 4KC_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)
\end{align*}
we have
\begin{align}
V^*(\rho) - V_{\pi_K}(\rho) \leq \frac{8 \eta}{(1 - \gamma)^2} + \frac{2 \gamma^{K - 1}}{(1 - \gamma)^2} \label{eq: v function bound main}
\end{align}
\subsection{Optimality for DAV and EGSS}
By plugging different policy evaluations bounds from DAV \ref{prop: approx value function bound for DAV} and EGSS \ref{prop: approx value function bound for EGSS}
into the final sub-optimality bound from \ref{eq: v function bound main} we get the two following results.
\subsubsection{DAV Sub-Optimality}
By choosing appropriate parameters according to $\delta$ and $\kappa$, we can ensure that with probability of at least $1 - \delta$, we have:
\begin{align*}
V^*(\rho) - V_{\pi_K}(\rho) \leq \kappa,
\end{align*}
by the following parameter initialization (see \ref{sec:parameter DAV})
\begin{align*}
\tau &= 1\\
\lambda &= \frac{\kappa^2(1 - \gamma)^4}{1024 b^2 (2m -1)^2}\\
\theta &= \frac{\kappa(1- \gamma)^2}{32 (2m-1) \sqrt{C_{\text{max}}}}\\
H &= \frac{
\log \left ( 32 \sqrt{C_{\text{max}}} (2m - 1) \right)
- \log \left( \kappa(1 - \gamma)^3 \right)
}{
log(\frac{1}{\gamma})
} - 1\\
K &= \frac{\log\left(\frac{1}{\kappa(1 - \gamma)^2}\right) + \log(8)}{\log(\frac{1}{\gamma})} + 1 \\
n &= \frac{log(\delta) - \log(2KC_{\text{max}})}{2 \theta^2(1-\gamma)^2} \\
C_{\max} &= \frac{e}{e-1} \frac{1 + \tau}{\tau} d \left(
\log(1 + \frac{1}{\tau}) +
\log(1 + \frac{m}{\lambda})
\right)
\end{align*}
\subsubsection{EGSS Sub-Optimality}
By choosing appropriate parameters according to $\delta$ and $\kappa$, we can ensure that with probability of at least $1 - \delta$, we have:
\begin{align*}
V^*(\rho) - V_{\pi_K}(\rho) \leq \kappa,
\end{align*}
by the following parameter initialization (see \ref{sec:parameter EGSS})
\begin{align*}
\tau &= 1\\
\lambda &= \frac{\kappa^2(1 - \gamma)^4}{1024b^2 \sqrt{d}}\\
\theta &= \frac{\kappa(1- \gamma)^2}{32 d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}}}\\
H &= \frac{
\log\left (32 d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}} \right)
- \log(\kappa(1 - \gamma)^3)
}{
log(\frac{1}{\gamma})
} - 1\\
K &= \frac{\log\left(\frac{1}{\kappa(1 - \gamma)^2}\right) + \log(8)}{\log(\frac{1}{\gamma})} + 1 \\
n &= \frac{log(\delta) - \log(2KC_{\text{max}})}{2 \theta^2(1-\gamma)^2} \\
C_{\max} &= \frac{e}{e-1} \frac{1 + \tau}{\tau} d \left(
\log(1 + \frac{1}{\tau}) +
\log(1 + \frac{m}{\lambda})
\right)
\end{align*}
\subsubsection{Computational and Query costs}
Both algorithms can learn a $\kappa$-optimal policy with computational cost of $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}), \log(b), m, |\mathcal{A}|)$.
The query cost for DAV is $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}), \log(b), m)$, and for EGSS is $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}), \log(b), \log(m))$.
\begin{center}
\begin{tabular}{c c c c}
\hline
& Query($\epsilon = 0$) & Query ($\epsilon \ne 0$) & Sub-optimality ($\epsilon \ne 0)$ \\
\hline
LSPI-DAV & $\tilde{\mathcal{O}} \left( \frac{\mathbf{m^2} d^3}{\kappa^2 (1-\gamma)^8} \right)$ & $\tilde{\mathcal{O}} \left( \frac{d^2}{\epsilon^2 (1-\gamma)^4} \right)$ & $\tilde{\mathcal{O}} \left( \frac{\epsilon \sqrt{d} \mathbf{m}}{(1-\gamma)^2} \right)$\\
\hline
LSPI-EGSS & $\tilde{\mathcal{O}} \left( \frac{\mathbf{\sqrt{d}}d^3}{\kappa^2 (1-\gamma)^8} \right)$ & $\tilde{\mathcal{O}} \left( \frac{d^2}{\epsilon^2 (1-\gamma)^4} \right)$ & $\tilde{\mathcal{O}} \left( \frac{\epsilon \sqrt{d} \mathbf{d^{1/4}}}{(1-\gamma)^2} \right)$\\
\hline
LSPI-Kernel-DAV & $\tilde{\mathcal{O}} \left( \frac{\mathbf{m^2} \tilde \Gamma^3}{\kappa^2 (1-\gamma)^8} \right)$ & $\tilde{\mathcal{O}} \left( \frac{d^2}{\epsilon^2 (1-\gamma)^4} \right)$ & $\tilde{\mathcal{O}} \left( \frac{\epsilon \sqrt{\tilde \Gamma} \mathbf{m}}{(1-\gamma)^2} \right)$\\
\hline
\end{tabular}
\end{center}
\section{Kernel Setting}
The kernelized setting is a standard extension of the finite-dimensional linear setup \citep{srinivas2009gaussian,abbasi2012online}. It lifts the restriction that features and parameter vector are elements of $\mathbb{R}^d$. Instead we require that the $Q_\pi$-function is contained in a reproducing kernel Hilbert space (RKHS). This includes cases where the linear dimension of function class is infinite.
The more general setup requires us to address two main challenges: First, the scaling of the sample complexity with the dimension $d$ needs to be improved to a notion of effective dimension that can be bounded for the RKHS of interest. Second, computationally we cannot directly work with infinite dimensional features $\phi(s,a)$. Instead, we need to rely on the `kernel trick' and compute all quantities of interest in the finite-dimensional data space.
Formally\todoa{Added the assumptions for kernel case from here:}, for each agent $j \in [m]$, the function $k^{(j)} : (\mathcal{S} \times \mathcal{A}^{(1:m)})^2 \rightarrow \mathbb{R}$ is defined as
\begin{align}
k^{(j)}(s_1, a_1^{(1:m)}, s_2, a_2^{(1:m)}) = k_j(s_1, a_1^{(j)}, s_2, a_2^{(j)}), \label{eq:rkhs_j}
\end{align}
where $k_j: (\mathcal{S} \times \mathcal{A})^2 \rightarrow \mathbb{R}$ is the underlying kernel function for agent $j$,
and $\mathcal{H}_j$ is the RKHS associated with it.
Based on definition \eqref{eq:rkhs_j}, it's easy to see that $\{k^{(j)}\}_{j \in [m]}$ is a set of kernel functions too, and they share the same vector space which is $V := \mathbb{R}^{\mathcal{S} \times \mathcal{A}^{(1:m)}}$.
However, they have different inner products on this space which produce a different RKHS for every $j \in [m]$.
We denote RKHS of $k^{(j)}$ as $\mathcal{H}^{(j)}$, and its inner product follows from equation \eqref{eq:rkhs_j} as
\begin{align}
\langle k^{(j)}(s_1, a_1^{(1:m)}, \cdot, \cdot), k^{(j)}(s_2, a_2^{(1:m)}, \cdot, \cdot) \rangle_{\mathcal{H}^{(j)}} =
\langle k_j(s_1, a_1^{(j)}, \cdot, \cdot), k_j(s_2, a_2^{(j)}, \cdot, \cdot) \rangle_{\mathcal{H}_j}. \label{eq:rkhs-inner-1}
\end{align}
By defining $\phi_j(s, a) := k_j(s,a, \cdot, \cdot) \in \mathcal{H}_j$ and $\phi^{(j)}(s, a^{(1:m)}) := k^{(j)}(s, a^{(1:m)}, \cdot, \cdot) \in \mathcal{H}^{(j)}$, we can rewrite \eqref{eq:rkhs-inner-1} for fixed $s_1, s_2, a_1^{(1:m)}, a_2^{(1:m)}$ as
\begin{align}
\langle \phi^{(j)}(s_1, a_1^{(1:m)}), \phi^{(j)}(s_2, a_2^{(1:m)}) \rangle_{\mathcal{H}^{(j)}} &=
\langle \phi_j(s_1, a_1^{(j)}), \phi_j(s_2, a_2^{(j)})\rangle_{\mathcal{H}_j}.\label{eq:rkhs-inner-1-rev}
\end{align}
Intuitively, equation \eqref{eq:rkhs-inner-1-rev} suggests that the inner product $\langle \cdot, \cdot \rangle_{H^{(j)}}$ only depends on the state $s$, and the action taken by agent $j$.
Next, we define the joint additive kernel $k : (\mathcal{S} \times \mathcal{A}^{(1:m)})^2 \rightarrow \mathbb{R}$ as follows
\begin{align}
k(s_1,a_1^{(1:m)}, s_2,a_2^{(1:m)}) &= \sum_{j=1}^m k^{(j)}(s_1,a_1^{(1:m)}, s_2,a_2^{(1:m)}) \label{eq:jak-def}\\
&= \sum_{j=1}^m k_j(s_1,a_1^{(j)}, s_2,a_2^{(j)})\\
&= \sum_{j=1}^m \langle k_j(s_1,a_1^{(j)}, \cdot, \cdot), k_j(s_2,a_2^{(j)}, \cdot, \cdot) \rangle_{\mathcal{H}_j},
\end{align}
and we denote its associated RKHS as $\mathcal{H}$. Again, note that $\mathcal{H}$ uses the same vector space, namely $V$, as all the $\mathcal{H}^{(j)}$s.
Now, we can restate Assumption \todoa{I think we still want to solve the problem under assumption one for the kernel case, right?}\ref{ass: ass1}for the kernel case.
\begin{assumption}[Assumption 1 for RKHS]
\label{ass:kernel-2}
For each (deterministic) policy $\pi$, there exists
$f_\pi \in \mathcal{H}$, such that
$Q_\pi(s, a^{(1:m)}) = \langle \phi(s,a^{(1:m)}), f_\pi \rangle_{\mathcal{H}}$.
\end{assumption}
Next, we show that there exist a function $f_\pi^{(i)} \in \mathcal{H}^{(i)}$ for $i \in [m]$, such that:
\begin{align*}
Q_\pi (s, a^{(1:m)}) &= \sum_{j=1}^m Q_\pi^{(j)}(s, a^{(1:m)})\\
Q_\pi^{(i)} (s, a^{(1:m)}) &= \langle \phi^{(i)}(s,a^{(1:m)}), f_\pi^{(i)} \rangle_{\mathcal{H}^{(i)}}
\end{align*}
Or, there exist $f_{\pi, j} \in \mathcal{H}_j$ for $j \in \mathcal{H}_j$, such that:
\begin{align*}
Q_\pi (s, a^{(1:m)}) &= \sum_{j=1}^m Q_{\pi,j}(s, a^{(j)})\\
Q_\pi^{(i)} (s, a^{(1:m)}) &= \langle \phi^{(i)}(s,a^{(1:m)}), f_{\pi,j} \rangle_{\mathcal{H}^{(i)}}
\end{align*}
\begin{proof}
As $f_\pi$ is an element of $\mathcal{H}$ we know that it can be shown based on the basis vectors of $\mathcal{H}$:
\begin{align*}
f_\pi = \sum_{i=1}^{\infty} \alpha_i k(s_i, a_i, \cdot, \cdot).
\end{align*}
From the definition of the joint additive kernel and the assumption \ref{ass:kernel-2} we have:
\begin{align}
Q_\pi (s, a^{(1:m)}) &= \langle \phi(s,a^{(1:m)}), f_\pi \rangle_{\mathcal{H}} \nonumber \\
&= \langle \phi(s,a^{(1:m)}), \sum_{i=1}^{\infty} \alpha_i k(s_i, a_i, \cdot, \cdot) \rangle_{\mathcal{H}} \nonumber \\
&= \sum_{i=1}^{\infty} \alpha_i \langle k(s,a^{(1:m)}, \cdot, \cdot), k(s_i, a_i, \cdot, \cdot) \rangle_{\mathcal{H}} \nonumber \\
&= \sum_{i=1}^{\infty} \alpha_i k(s,a^{(1:m)}, s_i, a_i) \nonumber \\
&= \sum_{i=1}^{\infty} \alpha_i \sum_{j=1}^m k^{(j)}(s,a^{(1:m)}, s_i, a_i) & \text{Based on }\ref{eq:jak-def}\label{eq:checkpoint}\\
&= \sum_{j=1}^m \sum_{i=1}^{\infty} \alpha_i k^{(j)}(s,a^{(1:m)}, s_i, a_i) \nonumber \\
&= \sum_{j=1}^m \sum_{i=1}^{\infty} \alpha_i \langle \phi^{(j)}(s,a^{(1:m)}) , \phi^{(j)}(s_i, a_i) \rangle_{\mathcal{H}^{(j)}} \nonumber\\
&= \sum_{j=1}^m \langle \phi^{(j)}(s,a^{(1:m)}) , \underbrace{\sum_{i=1}^{\infty} \alpha_i \phi^{(j)}(s_i, a_i)}_{:=E^{(j)}(f_\pi) := f_\pi^{(i)}} \rangle_{\mathcal{H}^{(j)}} \nonumber \\
&= \sum_{j=1}^{m} \langle \phi^{(j)}(s,a^{(1:m)}), f_\pi^{(j)} \rangle_{\mathcal{H}^{(j)}}. \nonumber
\end{align}
or from \eqref{eq:checkpoint} we have:
\begin{align*}
Q_\pi (s, a^{(1:m)})
&= \sum_{i=1}^{\infty} \alpha_i \sum_{j=1}^m k^{(j)}(s,a^{(1:m)}, s_i, a_i) \\
&= \sum_{i=1}^{\infty} \alpha_i \sum_{j=1}^m k_j(s,a^{(j)}, s_i, a_i^{(j)}) & \text{Based on }\ref{eq:rkhs_j}\\
&= \sum_{i=1}^{\infty} \alpha_i \sum_{j=1}^m \langle \phi_j(s,a^{(j)}), \phi_j(s_i, a_i^{(j)}) \rangle_{\mathcal{H}_j}\\
&= \sum_{j=1}^m \langle
\phi_j(s,a^{(j)}),
\underbrace{
\sum_{i=1}^{\infty} \alpha_i \phi_j(s_i, a_i^{(j)})
}_{:=E_j(f_\pi) :=f_{\pi, j}}
\rangle_{\mathcal{H}_j}\\
&= \sum_{j=1}^m \langle
\phi_j(s,a^{(j)}),
f_{\pi, j}
\rangle_{\mathcal{H}_j}.
\end{align*}
We may need to show that $f_\pi^{j}$ and $f_{\pi, j}$ have finite norms in their corresponding Hilbert spaces.
\end{proof}
\paragraph{Kernelized Algorithm}
As before we can compute the ridge estimate
\begin{align}
\hat Q_t = \argmin_{Q \in \mathcal{H}} \sum_{(s,a^{(1:m)})\in\mathcal{C}_t} (Q(s,a^{(1:m)}) - q_{(s,a^{(1:m)})})^2 + \lambda \|Q\|_{\mathcal{H}}^2 = (\Phi_{\mathcal{C}_t}\Phi_{\mathcal{C}_t}^\top + \lambda \mathbf{I}_\mathcal{H})^{-1}\Phi_{\mathcal{C}_t}q_{\mathcal{C}_t}
\end{align}
Here, $\mathbf{I}_{\mathcal{H}} : \mathcal{H} \rightarrow \mathcal{H}$ is the identity mapping, and $\Phi_{\mathcal{C}}^\top$ can be formally defined as map $\Phi_\mathcal{C}^\top : \mathcal{H} \rightarrow \mathbb{R}^{|\mathcal{C}|}, f \mapsto [f(s,a^{(1:m)})]_{(s,a^{(1:m)}) \in \mathcal{C}}, \, f \in \mathcal{H}$; and $\Phi_{\mathcal{C}} : \mathbb{R}^{|\mathcal{C}|} \rightarrow \mathcal{H}$ is the adjoint of $\Phi_{\mathcal{C}}^\top$.\todoj{somewhat more natural is to transpose the definition of $\Phi_{\mathcal{C}}$ but I wanted to be consistent with the earlier notation}
Using the `kernel trick' we express the estimator as follows
\begin{align}
\hat Q_t = \Phi_{\mathcal{C}_t}(K_{\mathcal{C}_t} + \lambda \mathbf{I}_{t})^{-1}q_{\mathcal{C}_t}
\end{align}
where $K_{\mathcal{C}_t} = \Phi_{\mathcal{C}_t}^\top \Phi_{\mathcal{C}_t} \in \mathbb{R}^{t \times t}$ is the kernel matrix. Lastly, we can evaluate for any $s,a^{(1:m)}$:
\begin{align}
\hat Q_t(s,a^{(1:m)}) = k_{\mathcal{C}_t}(s,a^{(1:m)})^\top(K_{\mathcal{C}_t} + \lambda \mathbf{I}_{t})^{-1}q_{\mathcal{C}_t}
\end{align}
where we defined $k_\mathcal{C}(s,a^{(1:m)}) = [k(s,a^{(1:m)}, s',a'^{(1:m)})]_{(s',a'^{(1:m)}) \in \mathcal{C}} \in \mathbb{R}^{|\mathcal{C}|}$ (for some fixed ordering of $\mathcal{C}$). Importantly, the last display only involves finite-dimensional quantities that can be computed from kernel evaluations. Moreover, since $k(s,a^{(1:m)},s',a'^{(1:m)}) = \sum_{j=1}^m k_j(s,a^{(j)}, s', a^{(j)})$ we can write
\begin{align}
\hat Q_t(s,a^{(1:m)}) = \sum_{j=1}^m k_{j, \mathcal{C}_t}(s,a^{(j)})^\top(K_{\mathcal{C}_t} + \lambda \mathbf{I}_{t})^{-1}q_{\mathcal{C}_t}
\end{align}
where $k_{j, \mathcal{C}}(s,a^{(j)}) = [k_j(s,a^{(j)}, s^\prime , a^{\prime(j)})]_{(s^\prime, a^{\prime(1:m)}) \in \mathcal{C}} \in \mathbb{R}^{|\mathcal{C}|}$. Hence we can still compute the maximizer independently for each agent.
The second quantity required by the algorithm is the squared norm $\|\phi(s,a^{(1:m)})\|_{(\Phi_\mathcal{C} \Phi_{\mathcal{C}}^\top + \lambda \mathbf{I}_\mathcal{H})^{-1}}^2$, where now $\phi(s,a^{(1:m)}) = k(s,a^{(1:m)}, \cdot, \cdot) \in \mathcal{H}$. Using the Woodbury identity, we can write
\begin{align}
\lambda (\Phi_\mathcal{C} \Phi_{\mathcal{C}}^\top + \lambda \mathbf{I}_\mathcal{H})^{-1} = \mathbf{I}_{\mathcal{H}} - \Phi_{\mathcal{C}} (K_\mathcal{C} + \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}\Phi_{\mathcal{C}}^\top
\end{align}
Therefore the feature norm can be written using finite-dimensional quantities:
\begin{align}
\|\phi(s,a^{(1:m)})\|_{(\Phi_\mathcal{C} \Phi_{\mathcal{C}}^\top + \lambda \mathbf{I}_\mathcal{H})^{-1}}^2 = \frac{1}{\lambda} \left( k(s,a^{(1:m)},s,a^{(1:m)}) - k_\mathcal{C}(s,a^{(1:m)})^\top(K_\mathcal{C}+ \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}k_{\mathcal{C}}(s,a^{(1:m)})\right)
\end{align}
With this, we can implement the DAV version of the algorithm directly. The EGSS is more tricky to implement, but this is potentially possible using eigenfunctions from Mercer's theorem.\todoj{I haven't seen this done even for UCB on kernel bandits, but there are related works for Thompson Sampling, e.g. \cite{mutny2018efficient}}
\paragraph{Analysis}
Our goal next is to extend the analysis to the kernel case, carefully arguing that the linear dimension $d$ can be replaced by a more benign quantity. A common complexity measure is the total information gain, which we define as follows:
\begin{align}
\Gamma_{\mathcal{C}} = \log \det (\Phi_{\mathcal{C}}\Phi_{\mathcal{C}}^\top + \lambda \mathbf{I}_d) - \log \det (\lambda \mathbf{I}_d)
\end{align}\todoj{it is tempting to add a factor $\frac{1}{2}$ to the definition, to much the entropy of the Bayesian model with Gaussian prior and likelihood}
Note that we can compute $\Gamma_{\mathcal{C}}$ for any given core set $\mathcal{C}$. In the kernel case, we can compute $\Gamma_{\mathcal{C}} = \log \det (\mathbf{I}_{|\mathcal{C}|} + \lambda^{-1} K_{\mathcal{C}})$ using similar arguments as before.
The maximum information gain is $\Gamma_t = \max_{\mathcal{C} : |\mathcal{C}|=t} \Gamma_{\mathcal{C}}$. It serves as a complexity measure in the bandit literature and can be bounded for many kernels of interests \citep{srinivas2009gaussian,vakili2021information}. Following \citet{du2021bilinear}, we further define the \emph{critical information gain},
\begin{align}
\tilde \Gamma = \max \{t \geq 1 : t \leq \Gamma_t \}
\end{align}
Note that the proof of \cite[Lemma 5.1]{yin2021efficient} implies that $|C| \leq \log(1+\tau)^{-1}\Gamma_{|C|}$
Since the dimension $d$ enters our bounds only through $C_{\max}$ we can immediately get a sample complexity bound for the kernelized algorithm in terms of $\tilde\Gamma$. For the finite-dimensional case, \cite[Lemma 5.1]{yin2021efficient} shows that $\tilde \Gamma \leq \mathcal{O}(d)$, recovering the previous bound.
\paragraph{Unknown Critical Information Gain} Somewhat impractical for the algorithm is that we need to know a bound on $C_{\max}$ or $\tilde \Gamma$ respectively to set the number of episodes required for some target level of accuracy $\kappa > 0$ (roughly, $m = C_{\max}/\kappa^2$).
As a remedy, we can replace the check $\|\phi(s,a)\|_{(\Phi_\mathcal{C} \Phi_{\mathcal{C}} + \lambda \mathbf{I}_d)^{-1}}^2 > \tau$ by\todoj[inline]{this needs some more thinking, as we don't want to set $\tau$ to be too small - maybe? An easier approach could be to set $m = |\mathcal{C}|/\kappa^2$?}
\begin{align*}
\|\phi(s,a)\|_{(\Phi_\mathcal{C} \Phi_{\mathcal{C}} + \lambda \mathbf{I}_d)^{-1}}^2 > \frac{\tilde \tau}{\max(\Gamma_{\mathcal{C}},1)}
\end{align*}
Let $\mathcal{C}_1, \dots, \mathcal{C}_t$ be the sequence of core sets obtained by adding elements that satisfy the above condition. Note that $\Gamma(\mathcal{C}_t)$ is a non-decreasing sequence. Combined with \citep[Lemma 5.1]{yin2021efficient} , this implies that
\begin{align}
t \log\left(1 + \tfrac{\tilde \tau}{\max(\Gamma_t,1)}\right) \leq t \log\left(1 + \tfrac{\tilde \tau}{\max( \Gamma_{\mathcal{C}_{t}}, 1)}\right) \leq \sum_{s=1}^t \log\left(1 + \tfrac{\tilde \tau}{\max(\Gamma_{\mathcal{C}_{s}},1)}\right) \leq \Gamma_{\mathcal{C}_{t}} \leq \Gamma_t\label{eq:cmax adaptiv}
\end{align}
Hence the condition is triggered at most
\begin{align}
\tilde C_{\max}(\tilde \tau) = \max \left\{t \geq 1 : t \leq \Gamma_t \log\left(1 + \tfrac{\tilde \tau}{\max(\Gamma_t, 1)} \right)^{-1}\right\}
\end{align}
times. \todoj{Would be great to show some bounds for $\tilde C_{\max}$, e.g. in the finite-dimensional case}Moreover, we can set $\tilde \tau=1$ and $m = \frac{1}{\kappa^2}$ (i.e.~without knowing a bound on $C_{\max}$) to obtain the required target accuracy $\tilde \mathcal{O}(\kappa)$.\todoj{this requires some introspection of \citep[Lemma B.2]{yin2021efficient} and \eqref{eq:cmax adaptiv}}
\section{Bandit Setting Analysis}
Recall that $\phi_i: \mathcal{S} \times \mathcal{A}^{(i)} \to \mathbb{R}^d$.
Fix state $s \in \mathcal{S}$, and redefine $\phi_i: \mathcal{A}^{(i)} \to \mathbb{R}^d$, which reduces the problem to the bandit setting.
Under assumption \ref{ass: ass1} we know that there exist weight vectors $w_1^*, \cdots, w_m^* \in \mathbb{R}^d$, such that:
\[
\begin{aligned}
Q_{w^*}(a^{(1 : m)}) &= \sum_{j =1}^{m} \phi_j(a^{(j)})^\top
\sum_{i =1}^{m} w_j^*\\
&= \phi(a^{(1:m)})^\top w^*,
\end{aligned}
\]
where we define $\phi(a^{(1:m)})^\top = \sum_{j =1}^{m} \phi_j(a^{(j)})^\top$ and $w^* = \sum_{i =1}^{m} w_j^*$.
Next we define
$$a^{*, (1:m)} = \argmax_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} Q_{w^*}(a^{(1:m)}) $$
\begin{algorithm}
\algnewcommand{\LineComment}[1]{\State \(\triangleright\) #1}
\caption{Confident Multi-Agent Linear Bandit}\label{alg:bandit}
\begin{algorithmic}
\Require $\hat w_0 \in \mathbb{R}^d$, Default action $\bar a^{(1:m)} \in \mathcal{A}^{(1:m)}$, Number of rollouts $n$
\State $\mathcal{C} \gets \{ \bar a^{(1:m)} \}$
\LineComment{Build Core Set}
\For{$j=1,\dots m$}
\For{$a_j \in \mathcal{A}^{(j)}$}
\If{$\phi((a^{(j)}, \bar a^{(-j)}))^\top (\Phi_\mathcal{C} \Phi_\mathcal{C}^\top + \lambda \mathbf{I}_d)^{-1} \phi((a^{(j)}, \bar a^{(-j)})) > \tau$}
\State $\mathcal{C} \gets \mathcal{C} \cup \{(a^{(j)}, \bar a^{(-j)})\}$ \Comment{Add action $(a^{(j)}, \bar a^{(-j)})$ to the core set}
\EndIf
\EndFor
\EndFor
\LineComment{Perform "Roll outs" for each action in the core set}
\State Define $q_\mathcal{C} = \mathbf{0}_{|\mathcal{C}|}$
\For{$a^{(1:m)}_j \in \mathcal{C}$}
\For{$i=1,\dots,n$}
\State $y_{a^{(1:m)}_j,i} = Q_{w^*}(a^{(1:m)}_j) + \epsilon_{a^{(1:m)}_j,i}$ \Comment{Single noisy evaluation}
\EndFor
\State ${q_\mathcal{C}}_j \gets \frac{1}{n} \sum_{i=1}^n y_{a^{(1:m)}_j, i}$ \Comment{Average evaluations for each action}
\EndFor
\State Compute regularized least-squares estimator $\hat w \gets (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda \mathbf{I}_d)^{-1}\Phi_\mathcal{C}^\top q_\mathcal{C}$
\State Output best guess $\hat{a}^{(1:m)} = \argmax_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \phi(a^{(1:m)})^\top \hat w$.
\end{algorithmic}
\end{algorithm}
We propose the following Algorithm \ref{alg:bandit}.
First we iterate over the actions of each agent and build the core set with the help of a default action $\bar a^{(1:m)}$.
Then we evaluate each action in the core set $n$ times, and compute an estimator. The output action is the empirically best action.
\begin{theorem}
The output action $\hat a^{(1:m)}$ of Algorithm \ref{alg:bandit} satisfies with probability at least $1-\delta$,
\begin{align*}
Q_{w^*}(a^{*, (1:m)}) - Q_{w^*}(\hat a^{(1:m)}) \leq (2m-1) \left( \|w^*\| \sqrt{\lambda \tau} + \sqrt{\frac{2\tau}{n} \log\left(\frac{2}{\delta}\right)} \right)
\end{align*}
for $\tau \ge 1, \lambda > 0, \delta \in (0, 1)$, and $C_\text{max} := \frac{e}{e-1} \frac{1+\tau}{\tau} d \left( \log(1+1/\tau) + \log(1+1/\lambda) \right)$.
Moreover, the compute complexity is $\mathcal{O}(d^3 \sum_{j=1}^m |\mathcal{A}^{(j)}|)$.
\end{theorem}
\begin{proof}
First, we decompose the simple regret:
\begin{align*}
&Q_{w^*}(a^{*, (1:m)}) - Q_{w^*}(\hat a^{(1:m)}) \\
&= Q_{w^*}(a^{*, (1:m)}) - Q_{w^*}(\hat a^{(1:m)}) \pm Q_{\hat w_n}(\hat a^{(1:m)}) \pm Q_{\hat w_n}(a^{*, (1:m)})\\
&= Q_{w^*}(a^{*, (1:m)}) - Q_{\hat w_n}(a^{*, (1:m)}) +
\underbrace{Q_{\hat w_n}(a^{*, (1:m)})
- Q_{\hat w_n}(\hat a^{(1:m)})}_{< 0} + Q_{\hat w_n}(\hat a^{(1:m)}) - Q_{w^*}(\hat a^{(1:m)})
\end{align*}
Taking the absolute value we get
\begin{align*}
|Q_{w^*}(a^{*, (1:m)}) - Q_{w^*}(\hat a^{(1:m)})|
&\leq \underbrace{| Q_{w^*}(a^{*, (1:m)}) - Q_{\hat w}(a^{*, (1:m)}) |}_{E_1} + \underbrace{|Q_{\hat w}(\hat a^{(1:m)}) - Q_{w^*}(\hat a^{(1:m)})|}_{E_2}\\
\end{align*}
Defining $\mathcal{H} = \{\tilde a^{(1:m)}: \|\phi(\tilde a^{(1:m)})\|_{V_\mathcal{C}^{-1}} \le \tau , \tilde a^{(1:m)} \in \mathcal{A}^{(1:m)}\}$.
Comparing $w^*$ and $\hat w$ in any direction $x \in \mathcal{H}$, we have:
\begin{align*}
\left \langle x, \hat{w} - w^* \right \rangle &=
\left \langle x, (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \Phi^\top q_\mathcal{C} - w^* \right \rangle\\
&=\left \langle x, (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \sum_{t=1}^{|\mathcal{C}|} \Phi_{\mathcal{C}_t} q_{\mathcal{C}_t} - w^* \right \rangle\\
&=\left \langle x, (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \sum_{t=1}^{|\mathcal{C}|} \Phi_{\mathcal{C}_t} (\Phi_{\mathcal{C}_t}^\top w^* + \epsilon_{a_t}) - w^* \right \rangle\\
&= \left \langle x, (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \sum_{t=1}^{|\mathcal{C}|} \Phi_{\mathcal{C}_t} \Phi_{\mathcal{C}_t}^\top w^* - w^* \right \rangle +
\left \langle x, (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \sum_{t=1}^{|\mathcal{C}|} \Phi_{\mathcal{C}_t} \epsilon_{a_t} \right \rangle \\
&= \underbrace{\left \langle x, (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \Phi_{\mathcal{C}} \Phi_{\mathcal{C}}^\top w^* - w^* \right \rangle}_{e_1} +
\underbrace{\sum_{t=1}^{|\mathcal{C}|} \left \langle x, (\Phi_\mathcal{C} \Phi_\mathcal{C}^\top + \lambda I)^{-1} \Phi_{\mathcal{C}_t} \right \rangle \epsilon_{a_t}}_{e_2} \\
\end{align*}
Since $e_1$ is exactly the same expression as $E_1$ in the proof of Lemma B.2 in \cite{yin2021efficient} we can use there result to bound this term.
Giving us
$$e_1 \le ||w^*||_2 \sqrt{\lambda \tau}$$
Now we need to bound $e_2$, which
is a $\sigma_\varepsilon/\sqrt{n}$-subguassian random variable since it's a summation of $|\mathcal{C}|$ $1/\sqrt{n}$-subgaussian random variables (since we sample each action in the core set $n$ times) each multiplied by a constant, with
\begin{align*}
\sigma_\varepsilon &= \sqrt{
\sum_{t=1}^{|\mathcal{C}|} \left \langle x, (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \Phi_{\mathcal{C}_t} \right \rangle^2
}
\end{align*}
Let $\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I := V \Lambda V^\top$ be the eigendecomposition of $\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I$
with $\Lambda = \text{diag}(\lambda_1, \lambda_2, \cdots, \lambda_d)$ and $V$ being an orthonormal matrix.
Notice that for all $i$, $\lambda_i \ge \lambda$. Let $\alpha = V^\top x$, then we have
\begin{align*}
\sigma_\varepsilon^2 = \sum_{t=1}^{|\mathcal{C}|} \left \langle x, (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \Phi_{\mathcal{C}_t} \right \rangle^2 &=
\sum_{t=1}^{|\mathcal{C}|} x^\top V \Lambda^{-1} V^\top \Phi_{\mathcal{C}_t} \Phi_{\mathcal{C}_t}^\top V \Lambda^{-1} V^\top x\\
&= x^\top V \Lambda^{-1} V^\top \Phi_{\mathcal{C}} \Phi_{\mathcal{C}}^\top V \Lambda^{-1} V^\top x\\
&= x^\top V \Lambda^{-1} V^\top (V \Lambda V^\top - \lambda I) V \Lambda^{-1} V^\top x\\
&= x^\top V \Lambda^{-1} V^\top x
- \lambda \alpha^\top \Lambda^{-2} \alpha\\
&\leq \tau - \lambda \sum_{i=1}^{|\mathcal{C}|} \frac{\alpha_i^2}{\lambda_i^2}\\
&\leq \tau
\end{align*}
Using this bound, and theorem 5.3 of the bandit book, we have with probability $1 - \delta$:
\begin{align*}
|e_2| \leq \sqrt{\frac{2 \tau}{n} \log\left(\frac{2}{\delta}\right)}
\end{align*}
Putting the bounds on $e_1$ and $e_2$ together, with probability $1 - \delta$, for every $x \in \mathcal{H}$ we have
\begin{align*}
\langle x, \hat{w} - w^* \rangle \leq \|w^*\| \sqrt{\lambda \tau} + \sqrt{\frac{2\tau}{n} \log\left(\frac{2}{\delta}\right)}
\end{align*}
\todoa{We didn't even need to bound this error inside the Good set, we only needed to bound it for the modified action. If that's correct, can we get a better bound by adding all of the modified actions to the core set? (we won't have to extrapolate or ... anymore)}
Now notice that for any $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ we have
\begin{align*}
&|Q_{\hat w}(a^{(1:m)}) - Q_{w^*}(a^{(1:m)})| \\
&= \left|Q_{\hat w}(a^{(1:m)}) - Q_{w^*}(a^{(1:m)}) \pm (m-1) Q_{w^*}(\bar a^{(1:m)}) \pm (m-1) Q_{\hat w}(\bar a^{(1:m)})\right| \\
&= \left |
\sum_{j=1}^m Q_{\hat w}((a^{(j)}, \bar a^{(-j)})) -
\sum_{j=1}^m Q_{w^*}((a^{(j)}, \bar a^{(-j)}))) +
(m-1)\left(Q_{w^*}(\bar a^{(1:m)}) - Q_{\hat w}(\bar a^{(1:m)})\right)
\right |\\
&= \left |
\sum_{j=1}^m Q_{\hat w - w^*}((a^{(j)}, \bar a^{(-j)})) +
(m-1)\left(Q_{w^* - \hat w}(\bar a^{(1:m)}) \right)
\right |.\\
&\leq \sum_{j=1}^m \|\phi((a^{(j)}, \bar a^{(-j)}))\|_{V_\mathcal{C}^{-1}} \|\hat w - w^*\|_{V_\mathcal{C}} + (m-1) \|\phi(\bar a^{(1:m)})\|_{V_\mathcal{C}^{-1}} \|\hat w - w^*\|_{V_\mathcal{C}} \\
&\leq (2m-1) \left( \|w^*\| \sqrt{\lambda \tau} + \sqrt{\frac{2\tau}{n} \log\left(\frac{2}{\delta}\right)} \right)
\end{align*}
The final inequality follows from noting that $\bar a^{(1:m)}, (a^{*, (j)}, \bar a^{(-j)}) \in \{\tilde a^{(1:m)}: \|\phi(\tilde a^{(1:m)})\|_{V_\mathcal{C}^{-1}} \le \tau \}, \ \forall j \in [m]$ by algorithm design.
The claim follows by using the last display to bound $E_1$ and $E_2$.
For the compute complexity, note that the core set is of size at most $d$ (by Lemma 5.1 in \cite{yin2021efficient}).
Adding a vector to the core set and updating the inverse iteratively is $d^2$.
Computing the estimate is $d^2 \sum_{j=1}^m |\mathcal{A}^{(j)}|$ and computing the maximizer is $d \sum_{j=1}^m |\mathcal{A}^{(j)}|$.
\end{proof}
We need to prove that if we add a state-action pair to the core set, it remains in the good set in future.
\begin{theorem}
Assume that $\Phi_\mathcal{C} \in \mathbb{R}^{t \times d}$, $V_\mathcal{C} = \Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I$, and $\phi_{t+1} \in \mathbb{R}^d$. Define $\hat \Phi = [\Phi^\top \, \phi_{t+1}]^\top$,
and $\hat V_\mathcal{C} = \hat{\Phi}_\mathcal{C}^\top \hat{\Phi}_\mathcal{C} + \lambda I$.
Then we have:
\begin{align*}
\| \phi_{t+1} \|_{\hat V_\mathcal{C}^{-1}} < 1
\end{align*}
\end{theorem}
\begin{proof}
By the definition of the norm we have:
\[
\begin{aligned}
\| \phi_{t+1} \|_{\hat{V}_\mathcal{C}^{-1}} &= \phi_{t+1}^\top \hat{V}_\mathcal{C}^{-1} \phi_{t+1}\\
&= \phi_{t+1}^\top \left(
\hat{\Phi}_\mathcal{C}^\top \hat{\Phi}_\mathcal{C} + \lambda I
\right)^{-1} \phi_{t+1}\\
&= \phi_{t+1}^\top \left (
\sum_{i = 1}^{t+1} \phi_i \phi_i^\top
+ \lambda I
\right)^{-1} \phi_{t+1}\\
&= \phi_{t+1}^\top \left (
\sum_{i = 1}^{t} \phi_i \phi_i^\top
+ \lambda I
+ \phi_{t+1} \phi_{t+1}^\top
\right)^{-1} \phi_{t+1}\\
&= \phi_{t+1}^\top \left (
V_\mathcal{C}
+ \phi_{t+1} \phi_{t+1}^\top
\right)^{-1} \phi_{t+1}\\
&= \phi_{t+1}^\top \left (
V_\mathcal{C}^{-1}
- \frac{V_\mathcal{C}^{-1} \phi_{t+1} \phi_{t+1}^\top V_\mathcal{C}^{-1}}{1 + \phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1}^\top}
\right) \phi_{t+1} & \text{Sherman-Morrison}\\
&= \phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1}
- \frac{
\phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1} \phi_{t+1}^\top V_\mathcal{C}^{-1}\phi_{t+1}
}{
1 + \phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1}
}
\\
&= \frac{
\phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1}
}{
1 + \phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1}
}\\
&< 1
\\
\end{aligned}
\]
\end{proof}
Therefore, if we set $\tau \geq 1$, then none of the features that have been added to the core set can produce $V_\mathcal{C}^{-1}$-norm greater than $\tau$, so they remain in the good set.
\newpage
\section*{Appendix}
\section*{Parameter Assignment}
\subsection{DAV}
\label{sec:parameter DAV}
The total error is the following:
\begin{align}
\frac{8 \eta_1}{(1 - \gamma)^2} + \frac{2 \gamma^{K - 1}}{(1 - \gamma)^2} &\leq \kappa \label{eq:egss-main} \\
\frac{8}{(1 - \gamma)^2}
\left(
b\sqrt{\lambda \tau} + \left( \frac{\gamma^{H+1}}{1 - \gamma} + \theta \right) \sqrt{ \tau C_{\text{max}}}
\right)(2m-1) +
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2}
&\leq \kappa \nonumber \\
&\Rightarrow \nonumber \\
\frac{8(2m-1)}{(1 - \gamma)^2} b\sqrt{\lambda \tau} & \leq \frac{\kappa}{4} \label{eq:egss-lambda}\\
\frac{8\sqrt{ \tau C_{\text{max}}}(2m-1)}{(1 - \gamma)^2} \frac{\gamma^{H+1}}{1 - \gamma} & \leq \frac{\kappa}{4} \label{eq:egss-H}\\
\frac{8\sqrt{ \tau C_{\text{max}}}(2m-1)}{(1 - \gamma)^2} \theta & \leq \frac{\kappa}{4} \label{eq:egss-theta}\\
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2} & \leq \frac{\kappa}{4} \label{eq:egss-K}
\end{align}
First we assume that $\tau = 1$.
From \eqref{eq:egss-lambda} we get:
\begin{align*}
\frac{8(2m - 1)}{(1 - \gamma)^2} b\sqrt{\lambda } & \leq \frac{\kappa}{4} \\
\sqrt{\lambda } &\leq \frac{(1 - \gamma)^2\kappa}{32 b (2m -1)}\\
\lambda &\leq \frac{(1 - \gamma)^4\kappa^2}{1024 b^2 (2m -1)^2}\\
\end{align*}
From \eqref{eq:egss-H} we get:
\begin{align*}
\frac{8\sqrt{ C_{\text{max}}}(2m -1)}{(1 - \gamma)^3} \gamma^{H+1} & \leq \frac{\kappa}{4} \\
(2m -1) \sqrt{C_{\text{max}}} \gamma^{H+1} & \leq \frac{\kappa(1 - \gamma)^3}{32} \\
\gamma^{H+1} & \leq \frac{\kappa(1 - \gamma)^3}{32 \sqrt{C_{\text{max}}} (2m - 1)} \\
H & \geq \frac{\log\left (\frac{\kappa(1 - \gamma)^3}{32 \sqrt{C_{\text{max}}} (2m - 1)} \right)}{
log(\gamma)
} - 1\\
\end{align*}
From \eqref{eq:egss-theta} we get:
\begin{align*}
\frac{8\sqrt{ C_{\text{max}}}(2m-1)}{(1 - \gamma)^2} \theta & \leq \frac{\kappa}{4}\\
(2m-1) \sqrt{C_{\text{max}}} \theta & \leq \frac{\kappa(1- \gamma)^2}{32}\\
\theta & \leq \frac{\kappa(1- \gamma)^2}{32 (2m-1) \sqrt{C_{\text{max}}}}\\
\end{align*}
From \eqref{eq:egss-K} we get:
\begin{align*}
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2} & \leq \frac{\kappa}{4}\\
\gamma^{K - 1} & \leq \frac{\kappa(1 - \gamma)^2}{8}\\
K & \leq \frac{\log \left( \frac{\kappa(1 - \gamma)^2}{8} \right)}{\log(\gamma)} + 1\\
K & \leq \frac{\log\left(\kappa(1 - \gamma)^2\right) - \log(8)}{\log(\gamma)} + 1\\
\end{align*}
We know that \eqref{eq:egss-main} holds with probability at least $1 - 2KC_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$.
Therefore from that the rest of values we get:
\begin{align*}
2KC_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n) &\leq \delta\\
\exp(-2 \theta^2(1-\gamma)^2 n) &\leq \frac{\delta}{2KC_{\text{max}}}\\
-2 \theta^2(1-\gamma)^2 n &\leq log( \frac{\delta}{2KC_{\text{max}}})\\
n &\geq \frac{log(\delta) - \log(2KC_{\text{max}})}{2 \theta^2(1-\gamma)^2}\\
\end{align*}
\subsection{EGSS}
\label{sec:parameter EGSS}
The total error is the following:
\begin{align}
\frac{8 \eta_2}{(1 - \gamma)^2} + \frac{2 \gamma^{K - 1}}{(1 - \gamma)^2} &\leq \kappa \label{eq:dav-main} \\
\frac{8}{(1 - \gamma)^2}
\left(
b\sqrt{\lambda \tau} + \left( \frac{\gamma^{H+1}}{1 - \gamma} + \theta \right) \sqrt{ \tau C_{\text{max}}}
\right) +
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2}
&\leq \kappa \nonumber \\
&\Rightarrow \nonumber \\
\frac{8}{(1 - \gamma)^2} b\sqrt{\lambda \tau} & \leq \frac{\kappa}{4} \label{eq:dav-lambda}\\
\frac{8\sqrt{ \tau C_{\text{max}}}}{(1 - \gamma)^2} \frac{\gamma^{H+1}}{1 - \gamma} & \leq \frac{\kappa}{4} \label{eq:dav-H}\\
\frac{8\sqrt{ \tau C_{\text{max}}}}{(1 - \gamma)^2} \theta & \leq \frac{\kappa}{4} \label{eq:dav-theta}\\
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2} & \leq \frac{\kappa}{4} \label{eq:dav-K}
\end{align}
First we assume that $\tau = 1$.
From \eqref{eq:dav-lambda} we get:
\begin{align*}
\frac{8}{(1 - \gamma)^2} b\sqrt{\lambda } & \leq \frac{\kappa}{4} \\
\sqrt{\lambda } &\leq \frac{(1 - \gamma)^2\kappa}{32 b}\\
\lambda &\leq \frac{(1 - \gamma)^4\kappa^2}{1024 b^2 }\\
\end{align*}
From \eqref{eq:dav-H} we get:
\begin{align*}
\frac{8\sqrt{ C_{\text{max}}}}{(1 - \gamma)^3} \gamma^{H+1} & \leq \frac{\kappa}{4} \\
d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}} \gamma^{H+1} & \leq \frac{\kappa(1 - \gamma)^3}{32} \\
\gamma^{H+1} & \leq \frac{\kappa(1 - \gamma)^3}{32 d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}}} \\
H & \geq \frac{\log\left (\frac{\kappa(1 - \gamma)^3}{32 d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}}} \right)}{
log(\gamma)
} - 1\\
\end{align*}
From \eqref{eq:dav-theta} we get:
\begin{align*}
\frac{8\sqrt{C_{\text{max}}}}{(1 - \gamma)^2} \theta & \leq \frac{\kappa}{4}\\
d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}} \theta & \leq \frac{\kappa(1- \gamma)^2}{32}\\
\theta & \leq \frac{\kappa(1- \gamma)^2}{32 d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}}}\\
\end{align*}
From \eqref{eq:dav-K} we get:
\begin{align*}
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2} & \leq \frac{\kappa}{4}\\
\gamma^{K - 1} & \leq \frac{\kappa(1 - \gamma)^2}{8}\\
K & \leq \frac{\log \left( \frac{\kappa(1 - \gamma)^2}{8} \right)}{\log(\gamma)} + 1\\
K & \leq \frac{\log\left(\kappa(1 - \gamma)^2\right) - \log(8)}{\log(\gamma)} + 1\\
\end{align*}
We know that \eqref{eq:dav-main} holds with probability at least $1 - 2KC_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$.
Therefore from that the rest of values we get:
\begin{align*}
2KC_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n) &\leq \delta\\
\exp(-2 \theta^2(1-\gamma)^2 n) &\leq \frac{\delta}{2KC_{\text{max}}}\\
-2 \theta^2(1-\gamma)^2 n &\leq log( \frac{\delta}{2KC_{\text{max}}})\\
n &\geq \frac{log(\delta) - \log(2KC_{\text{max}})}{2 \theta^2(1-\gamma)^2}\\
\end{align*}
\section*{Other Attempts}
\subsection*{Approach 1}
For a given $i, t$ our goal is determine if we are in Case 1 or Case 2 in computation $O(mA)$.
\subsubsection*{Attempt 1}
We can check if Case 2 holds as follows. Notice that we can bound $f(s, a^{(1:m)})$ as follows
\begin{align*}
f(s, a^{(1:m)})
&= \phi(s, a^{(1:m)})^\top G^{-1} \phi(s, a^{(1:m)}) \\
&= ||\phi(s, a^{(1:m)})||_{G^{-1}}^2 \\
&= ||\sum_{i=1}^m \phi_i(s, a_i)||_{G^{-1}}^2\\
&\le (\sum_{i=1}^m||\phi_i(s, a_i)||_{G^{-1}})^2
\end{align*}
Notice that if we can bound $||\phi_i(s, a_i)||_{G^{-1}}$ by $\sqrt{\tau}/m$ for all $i \in [m]$, then the above expression becomes
\begin{align*}
& (\sum_{i=1}^m||\phi_i(s, a_i)||_{G^{-1}})^2 \\
&\le (\sum_{i=1}^m \sqrt{\tau}/m )^2 \\
&= \sqrt{\tau}^2 \\
&= \tau
\end{align*}
Thus, we just need to bound $||\phi_i(s, a_i)||_{G^{-1}}$ by $\sqrt{\tau}/m$ for all $i \in [m]$ to ensure that $f(s, a^{(1:m)}) \le \tau$. This can be done for action wise (i.e. for each action $a^{(i)}$ independently), which would only take $O(mA)$ computation.
\textbf{Problem:} However, it is not clear how to check Case 1 holds.
For example if $||\phi_i(s, a_i)||_{G^{-1}} > \sqrt{\tau}/m$ for some $i \in [m]$, then we can no longer claim we are in Case 2.
However, it also does not necessarily mean we in Case 1.
It is not clear how to find out if we are in Case 1 or Case 2 then.
\subsubsection*{Attempt 2}
This attempt is very crude, we're working on it. Many things could be incorrect!
We can solve the maximization problem below:
\begin{align}
\max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \quad & f(a^{(1:m)}) = \phi(s, a^{(1:m)})^\top \underbrace{(\Phi_C^\top \Phi_C + \lambda I)^{-1}}_{G} \phi(s, a^{(1:m)})
\end{align}
We know that the matrix $G$ is positive semi-definite, which allows us to write the following decomposition:
\begin{align}
G &= Q \Lambda Q^{-1}\\
\Rightarrow \phi(s, a^{(1:m)})^\top G \phi(s, a^{(1:m)}) &= \phi(s, a^{(1:m)})^\top\ Q \Lambda Q^{-1} \ \phi(s, a^{(1:m)})\\
&= \sum_{i = 1}^m \phi(s, a^i)^\top\ Q \Lambda Q^{-1} \ \sum_{i = 1}^m \phi(s, a^i)
\end{align}
Guess: Decomposition could be done in polynomial time, then by maximizing the following quantity we can solve the maximization problem:
\begin{align}
\label{eq:max1}
\sum_{i = 1}^m \phi(s, a^i)^\top\ Q \Lambda \mathbf{1}
\end{align}
This problem could be solved independently for each $i$ in polynomial time.
\paragraph{Problem} We don't know if maximizing \eqref{eq:max1} leads to maximum value of $f$ or not.
Also, we're looking for other numerical analysis methods.
\subsubsection*{Approach 1 Attempt 1}
We do this by modifying Algorithm 1 as shown in blue in Algorithm 2, where we define $x^{(i)}(y^{(1:m)}) = (y^{(1)}, ..., x^{(i)}, ..., y^{(m)})$.
\begin{algorithm}
\caption{Multi-Agent Confident Rollout Default Actions}
\label{alg:confident rollout da old}
\begin{algorithmic}[1]
\State \textbf{Input:} number of rollouts $m$, length of rollout $n$, rollout policy $\pi$ (\textcolor{green}{should change to $w$?}), discount $\gamma$, initial state $s_0$, initial action vector $a_0^{(1:m)}$, default action vector $\bar a^{(1:m)}$, feature matrix $\Phi_C$, regularization coefficient $\lambda$, threshold $\tau$.
\For {$i = 1, ..., n$}
\State $s_{i, 0} \gets s_0, a_{i, 0} \gets \bar a$, query the simulator, obtain reward $r_{i, 0} \gets r(s_{i, 0}, a_{i, 0})$, and the next state $s_{i, 1}$.
\For {$t = 1, ..., H$}
\For {\textcolor{blue}{$j \in [m]$}}
\For {\textcolor{blue}{$a^{(j)} \in \mathcal{A}^{(j)}$}}
\State \textcolor{blue}{Compute feature $\phi(s, (a^{(j)}, \bar a^{(-j)})$.}
\If {\textcolor{blue}{$\phi(s, (a^{(j)}, \bar a^{(-j)}))^\top (\Phi_C^\top \Phi_C + \lambda I)^{-1} \phi(s, (a^{(j)}, \bar a^{(-j)})) > \tau$}}
\State \textcolor{blue}{status $\gets$ uncertain, result $\gets (s, (a^{(j)}, \bar a^{(-j)}), \phi(s, (a^{(j)}, \bar a^{(-j)})), \text{none})$}
\State \Return {status, result}
\EndIf
\EndFor
\EndFor
\State \textcolor{blue}{
\begin{align*}
a_{i, t}^{(1:m)} = \Bigg(
&\argmax_{\tilde{a}^{(1)} \in \mathcal{A}^{(1)}} \left[w^\top \phi_1(s, \tilde{a}^{(1)}) +
\underbrace{\sum_{p \ne 1} w^\top \phi_p(s, \bar a^{(p)})}_{\text{\textcolor{green}{can be removed?}}}
\right], \\
&..., \\
& \argmax_{\tilde{a}^{(m)} \in \mathcal{A}^{(m)}} \left[w^\top \phi_m(s, \tilde{a}^{(m)}) + \sum_{p \ne m} w^\top \phi_p(s, \bar a^{(p)}) \right] \Bigg).
\end{align*}}
\If {\textcolor{blue}{$\phi(s, a_{i, t}^{(1:m)})^\top (\Phi_C^\top \Phi_C + \lambda I)^{-1} \phi(s, a_{i, t}^{(1:m)}) > \tau$}}
\State \textcolor{blue}{status $\gets$ uncertain, result $\gets (s, a_{i, t}^{(1:m)}, \phi(s, a_{i, t}^{(1:m)}), \text{none})$}
\State \textcolor{blue}{\Return {status, result}}
\EndIf
\State Query the simulator with $s, a_{i, t}^{(1:m)}$, obtain reward $r_{i, t} \gets r(s, a_{i, t}^{(1:m)})$, and next state $s_{i, {t+1}}$.
\EndFor
\EndFor
\State status $\gets$ done, result $\gets \frac{1}{n} \sum_{i=1}^n \sum_{t=0}^H \gamma^t r_{i, t}$
\State \Return status, result
\end{algorithmic}
\end{algorithm}
\textbf{Problem:} Algorithm 2 satisfies Reason 1; however, it does not satisfy Reason 2.
Reason 1 is satisfied because the action selected in line 14 by both the VA and MA are always the same, until the MA algorithm terminates (Case A holds for the first time).
The action is the same because the argmax taken in line 14 is only over action vectors that are in the good set since this was ensured in lines 5-13.
The reason it does not satisfy Reason 2 is because we can not ensure that the VA is greedy w.r.t $\tilde{Q}(s, a^{(1:m)})$.
This can easily be seen by considering some action vector $\tilde{a}^{(1:m)}$ that was not checked in lines 5-13 but is not in the good set.
If $\argmax_{\bar{a}^{(1:m)}} \tilde{Q}(s, \bar{a}^{(1:m)}) = Q_{\tilde{\pi}}(s, \tilde{a}^{(1:m)})$ then clearly the VA was not greedy w.r.t $\tilde{Q}(s, a^{(1:m)})$ since in line 14 it never considered $\tilde{a}^{(1:m)}$
Stated differently, the VA is greedy w.r.t. $\tilde{w} \phi(s, a^{(1:m)})$ which is not the same as being greedy w.r.t $\tilde{Q}(s, a^{(1:m)})$
\subsubsection*{Attempt 3}
This attempt has been proposed recently, we have not investigated it thoroughly yet. \todoj{RKHS is mostly equivalent to the linear setting. We can look into this later, but it will not address any challenges that are already there in the linear setting.}
we can use \textbf{reproducing kernel Hilbert space}(RKHS) to solve the maximization problem approximately, starting from an initial assignment to $a^{(1:m)}$.
We think in that case we should change the proof for policy improvement lemma.
\paragraph{Relating/Reducing to the Bandit Setting}
At a high level, the policy evaluation step can be reduced to a bandit problem.
We begin by relating terms from bandits (as introduced in Chap 19 in \cite{lattimore2020bandit}) to terms in our current RL setting.
Assume there is only one state $s$, and we are at step $k$ of policy iteration.
We can define the true parameter vector $\theta_* = w_{\pi_{k-1}}$, the feature of the optimal action $A^*_t = \phi(s, \argmax_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} w_{\pi_{k-1}}^\top \phi(s, a^{(1:m)})$, and the action taken by the policy $A_t = \phi(s, \bar \pi(s)) = \phi(s, \argmax_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \tilde Q_{k-1}(s, a^{(1:m)}))$.
Assume we are in the final loop of Algorithm 2 in \cite{yin2021efficient}, which means all the good set checks (lines 4-13 in our Algorithm 2) pass, and no further elements will be added to the core set.
Setting $H=1$ and $\gamma = 0$, notice that Algorithm \ref{alg:confident rollout da} becomes a well defined bandit algorithm (where we just need to add a final step defining the update rule for $w_k$ as line 14 of Algorithm 2 in \cite{yin2021efficient}).
It is important to clarify that the bandit algorithm is just the policy evaluation step for a specific $k$.
Notice that we only update the parameter vector once (at the very end, once all the reward data has been gathered)!
Also, the algorithm will take $N = nmA$ ($n$ samples and $mA$ good set checks each time. Assume the reward is stochastic so that the $n$ samples are actually needed.) actions.
Now we relate our analysis to the regret proof for linear bandits (Chap 19 in \cite{lattimore2020bandit}).
A critical step to the regret proof was to bound the instantaneous regret $r_t = \langle \theta_*, A^*_t - A_t \rangle$.
Notice that we are interested in PAC results which translates to the instantaneous regret at the end (after $N$ actions are taken).
\begin{equation}
\label{Pac Bandit}
r_N = \langle \theta_*, A^*_N - A_N \rangle
\end{equation}
I will now remind us how $r_t$ was bounded for linear bandits, after which I will explain how similar steps can be taken to bound equation (\ref{Pac Bandit}).
Recall that we can bound $r_t$ as follows
\begin{align*}
r_t &= \langle \theta_*, A_t^* - A_t \rangle \\
&\le \langle \tilde \theta - \theta_*, A_t \rangle \\
&\le ||A_t||_{V_{t-1}^{-1}} ||\tilde \theta - \theta_*||_{V_{t-1}}
\end{align*}
where $V_t = G = \Phi_C^\top \Phi_C + \lambda I$.
The first inequality was achieved in the bandit setting due to the definition of $A_t = \argmax_{a \in \mathcal{A}} \text{UCB}_t(a)$.
And the second inequality was achieved by using the elliptical potential lemma (Lemma 19.4 in \cite{lattimore2020bandit}), and designing the core set in a special way.
\todoj{The elliptical potential lemma is to bound $\sum_t \|A_t\|_{V_t^{-1}}^2$ (not used here). Here we are explicitly enforcing $\|\phi_a\|_{V_t^{-1}}^2 \leq \tau$ by sampling the core set and by construction of the algorithm}
Neither of these inequalities will work in our setting, since our algorithm and core set design is different.
However, we can still make things works in a sort of similar way.
\begin{align*}
r_N &= \langle \theta_*, A_N^* - A_N \rangle\\
&= \langle \theta_*, A_N^*\rangle \pm \langle w_k, A_N^*\rangle \pm \langle w_k, A_N\rangle - \langle \theta_*, A_N \rangle \\
&= \langle w_k - \theta_*, A_N^*\rangle + \langle w_k, A_N^*\rangle - \langle w_k, A_N\rangle + \langle w_k - \theta_*, A_N \rangle \\
&\le \langle w_k - \theta_*, A_N^*\rangle + \langle w_k - \theta_*, A_N \rangle \\
&\le 2 \bar \eta (2m-1)
\end{align*}
Where the second last inequality holds since $\langle w_k, A_N^*\rangle - \langle w_k, A_N\rangle \le 0$ by the definition of $A_N$.
And the last inequality holds by equation (\ref{A2A2: approx bound}).
\subsection*{Bandit case}
Recall that $\phi_i: \mathcal{S} \times \mathcal{A} \to \mathbb{R}^d$.
Fix state $s \in \mathcal{S}$, and redefine $\phi_i: \mathcal{A} \to \mathbb{R}^d$, and relax the problem to a bandit setting for now.
Under assumption 1 we know that there exist weight vectors $w_1^*, \cdots, w_m^* \in \mathbb{R}^d$, such that:
\[
\begin{aligned}
v(a_{1 : m}) &= \sum_{j =1}^{m} \phi_j(a_j)^\top
\underbrace{\sum_{i =1}^{m} w_j^*}_{:= w^*}\\
&= \sum_{j =1}^{m} \phi_j(a_j)^\top w^*,
\end{aligned}
\]
which suggests that we are interested in the $w^*$ which is the sum of $(w_i)_i$, and not their individual values(true?).
Now we can define $f_w$ and $a^*$ as:
\[
\begin{aligned}
a_{1:m}^* &= \argmax_{a_{1:m} \in \mathcal{A}^m} \left\{f_{w^*}(a_{1:m}) := \sum_{j =1}^{m} \phi_j(a_j)^\top w^* \right \}
\end{aligned}
\]
\begin{algorithm}
\algnewcommand{\LineComment}[1]{\State \(\triangleright\) #1}
\caption{Confident Multi-Agent Linear Bandit}\label{alg:bandit}
\begin{algorithmic}
\Require $n \geq 0, \hat w_0 \in \mathbb{R}^d$, Default action $a_0 \in \mathcal{A}$, Number of rollouts $M$
\State $\mathcal{C} \gets \emptyset$
\LineComment{Build Core Set}
\For{$j=1,\dots m$}
\For{$a_j \in \mathcal{A}^{(j)}$}
\If{$\phi(a_0^{(j)}(a_j))^\top (\Phi_\mathcal{C} \Phi_\mathcal{C}^\top + \lambda \mathbf{I}_d)^{-1} \phi(a_0^{(j)}(a_j)) > \tau$}
\State $\mathcal{C} \gets \mathcal{C} \cup \{a_0^{(j)}(a_j)\}$ \Comment{Add action $a_0^{(j)}(a_j)$ to the core set}
\EndIf
\EndFor
\EndFor
\LineComment{Perform "Roll outs" for each action in the core set}
\For{$a \in \mathcal{C}$}
\For{$t=1,\dots,M$}
\State $y_{a,t} = f(a) + \epsilon_{a,t}$ \Comment{Single noisy evaluation}
\EndFor
\State $y_a \gets \frac{1}{M} \sum_{t=1}^M y_{a,t}$ \Comment{Average evaluations for each action}
\EndFor
\State Compute regularized least-squares estimator $\hat w \gets (\Phi_\mathcal{C} \Phi_\mathcal{C}^\top + \lambda \mathbf{I}_d)^{-1}\Phi_\mathcal{C} y_\mathcal{C}$
\State Output best guess $\hat{a}^* = \argmax_{a \in \mathcal{A}^m} \sum_{j=1}^m\phi_j(a_j)^\top \hat w$.
\end{algorithmic}
\end{algorithm}
We propose the following Algorithm \ref{alg:bandit}. First we iterate over the actions of each agents and build the core set with the help of a default action $a_0$. Then we evaluate each action in the core set $M$ times, and compute an estimator. The output action is the empirically best action.
\begin{theorem}
The output action $\hat a^*$ of Algorithm \ref{alg:bandit} satisfies with probability at least $1-\delta$,
\begin{align*}
f(a^*) - f(\hat a^*) \leq \mathcal{O}\left(\frac{m d \sqrt{\tau \log(1/\delta)}}{\sqrt{M}}\right)
\end{align*}
Moreover, the compute complexity is $\mathcal{O}(d^3 \sum_{j=1}^m |\mathcal{A}^{(j)}|)$.
\end{theorem}
\begin{proof}
First, we decompose the simple regret:\todoj{just a sketch, I haven't checked yet super carefully}
\begin{align*}
f_{w^*}(a^*) - f_{w^*}(\hat a^*) &= f_{w^*}(a^*) - f_{w^*}(\hat a^*) \pm f_{\hat w_n}(\hat a^*) \pm f_{\hat w_n}(a^*)\\
&= f_{w^*}(a^*) - f_{\hat w_n}(a^*) +
\underbrace{f_{\hat w_n}(a^*)
- f_{\hat w_n}(\hat a^*)}_{< 0} + f_{\hat w_n}(\hat a^*) - f_{w^*}(\hat a^*)
\end{align*}
From this we get
\begin{align*}
|f_{w^*}(a^*) - f_{w^*}(\hat a^*)|
&\leq \underbrace{| f_{w^*}(a^*) - f_{\hat w_n}(a^*) |}_{E_1} + \underbrace{|f_{\hat w_n}(\hat a^*) - f_{w^*}(\hat a^*)|}_{E_2}\\
\end{align*}
Note that for each action $a \in \mathcal{A}$:
\begin{align}
|f_{\hat w}(a) - f_{w^*}(a)| \leq \sum_{j=1}^m \|\phi(a_0^{(j)}(a_j))\|_{V_\mathcal{C}^{-1}} \|\hat w_n - w^*\|_{V_\mathcal{C}} \leq m \sqrt{\tau} \cdot \mathcal{O}(d/\sqrt{M})
\end{align}
The first inequality follows by adding and subtracting $\phi(a_0)$ a total of $(m-1)$ times. The second inequalit follows from noting that $\|\phi(a_0^{(j)}(a_j))\|_{V_\mathcal{C}^{-1}} \leq \tau$ by design, and from standard linear least-squares concentration $\|\hat w_n - w^*\|_{V_\mathcal{C}} \leq \mathcal{O}(d \sqrt{\log(1/\delta)/M})$ with probability at least $1-\delta$. Note that we averaged $M$ observations for each action in the core set $\mathcal{C}$, so each observation is essentially $1/\sqrt{M}$-sub-Gaussian. The claim follows by using the last display to bound $E_1$ and $E_2$.
For the compute complexity, note that the core set is of size at most $d$. Adding a vector to the core set and updating the inverse iteratively is $d^2$. Computing the estimate is $d^2 \sum_{j=1}^m |\mathcal{A}^{(j)}|$ and computing the maximizer is $d \sum_{j=1}^m |\mathcal{A}^{(j)}|$.
\end{proof}
For now, we can define $Choose\_Action$ function as (where the argmax can be done in time poly$(A, M)$ due to the linear form of $f_{\hat{w}}$).\todoj{as Vlad wrote in the ToDos, this should be changed to match the RL algorithm}
\[
Choose\_Action(\hat w) = \argmax_{a_{1:m} \in \mathcal{A}^m} f_{\hat{w}}(a_{1:m}).
\]
We are interested in simple regret (true?) which is the following quantity:
\[
\begin{aligned}
R_n^{\text{SIMPLE}}(\pi) &= \mathbb{E}_{\pi} [
\Delta_{a^{(n)}}
]\\
\Delta_{a} &= v(a^*) - v(a)\\
&= f_{w^*}(a^*) - f_{w^*}(a).
\end{aligned}
\]
Therefore, we want to bound the following \todoj{As Vlad mentioned, we only need a one-sided bound}
\[
\begin{aligned}
f_{w^*}(a^*) - f_{w^*}(a^{(n)}) &= f_{w^*}(a^*) - f_{w^*}(a^{(n)}) \pm f_{\hat w_n}(a^{(n)}) \pm f_{\hat w_n}(a^*)\\
&= f_{w^*}(a^*) - f_{\hat w_n}(a^*) +
\underbrace{f_{\hat w_n}(a^*)
- f_{\hat w_n}(a^{(n)})}_{< 0} + f_{\hat w_n}(a^{(n)}) - f_{w^*}(a^{(n)}) \\
|f_{w^*}(a^*) - f_{w^*}(a^{(n)})|
&\leq \underbrace{| f_{w^*}(a^*) - f_{\hat w_n}(a^*) |}_{E_1} + \underbrace{|f_{\hat w_n}(a^{(n)}) - f_{w^*}(a^{(n)})|}_{E_2}\\
\end{aligned}
\]
\subsubsection*{Bounding $E_2$}
$E_2$ is our approximation error for value of action $a^{(n)}$.
For bounding $E_2$, we can use the idea of having a default action vector.
Fix an arbitrary action $b_{1:m}$. Then, we have the following:
\begin{align*}
|f_{\hat w_n}(a^{(n)}) - f_{w^*}(a^{(n)})| &=
|
f_{\hat w_n}(a^{(n)}) - f_{w^*}(a^{(n)})
\pm (m-1) f_{w^*}(b)
\pm (m-1) f_{\hat w_n}(b)
|\\
&= | \sum_{j = 1}^m \phi_j(a^{(n)}_j)^\top \hat{w}_n - \sum_{j = 1}^m \phi_j(a^{(n)}_j)^\top w^* \\
&+ (m-1) \sum_{j = 1}^m \phi_j(b_j)^\top w^* - (m-1) \sum_{j = 1}^m \phi_j(b_j)^\top w^* \\
&+ (m-1) \sum_{j = 1}^m \phi_j(b_j)^\top \hat{w}_n - (m-1) \sum_{j = 1}^m \phi_j(b_j)^\top \hat{w}_n|\\
&= | \underbrace{\sum_{j = 1}^m \phi_j(a^{(n)}_j)^\top \hat{w}_n + (m-1) \sum_{j = 1}^m \phi_j(b_j)^\top \hat{w}_n}_{A_1}\\
&- \left( \underbrace{\sum_{j = 1}^m \phi_j(a^{(n)}_j)^\top w^* + (m-1) \sum_{j = 1}^m \phi_j(b_j)^\top w^*}_{A_2} \right)\\
&+ (m-1) \sum_{j = 1}^m \phi_j(b_j)^\top w^* - (m-1) \sum_{j = 1}^m \phi_j(b_j)^\top \hat{w}_n|\\
&= \left |
A_1 - A_2 +
\underbrace{(m-1) \left(f_{w^*}(b) - f_{\hat w_n}(b)\right)}_{A_3}
\right | \tag{\theequation} \label{ineq:app-err-1}
\end{align*}
We overload the notation of $b_{j}: \mathcal{A} \to \mathcal{A}^m$ to be a function which replaces the $j$th agent's action in $b_{1:m}$ with a new action (the input of the function).
We have the following for $A_1$:
\[
\begin{aligned}
\sum_{j = 1}^m \phi_j(a^{(n)}_j)^\top \hat{w}_n + (m-1) \sum_{j = 1}^m \phi_j(b_j)^\top \hat{w}_n &=\\
&+\left(\phi_1(a^{(n)}_1)^\top \hat{w}_n + \sum_{j \in [n] - \{1\}}\phi_j(b_j)^\top \hat{w}_n\right) + \phi_1(b_1)^\top \hat{w}_n\\
&+\left(\phi_2(a^{(n)}_2)^\top \hat{w}_n + \sum_{j \in [n] - \{2\}}\phi_j(b_j)^\top \hat{w}_n\right) + \phi_2(b_2)^\top \hat{w}_n\\
&+\cdots\\
&+\left(\phi_{m-1}(a^{(n)}_{m-1})^\top \hat{w}_n + \sum_{j \in [n] - \{m-1\}}\phi_j(b_j)^\top \hat{w}_n\right) + \phi_{m-1}(b_{m-1})^\top \hat{w}_n\\
&+\phi_{m}(a^{(n)}_{m})^\top \hat{w}_n\\
&=\\
&+\left(\phi_1(a^{(n)}_1)^\top \hat{w}_n + \sum_{j \in [n] - \{1\}}\phi_j(b_j)^\top \hat{w}_n\right)\\
&+\left(\phi_2(a^{(n)}_2)^\top \hat{w}_n + \sum_{j \in [n] - \{2\}}\phi_j(b_j)^\top \hat{w}_n\right)\\
&+\cdots\\
&+\left(\phi_{m-1}(a^{(n)}_{m-1})^\top \hat{w}_n + \sum_{j \in [n] - \{m-1\}}\phi_j(b_j)^\top \hat{w}_n\right)\\
&+\left(\phi_{m}(a^{(n)}_{m})^\top \hat{w}_n + \sum_{j \in [n] - \{m\}}\phi_j(b_j)^\top \hat{w}_n\right)\\
&= \sum_{j=1}^m f_{\hat w_n}(b_j(a^{(n)}_j)).
\end{aligned}
\]
We can have a similar derivation for $A_2$, which together with \eqref{ineq:app-err-1} results in:
\begin{align*}
|f_{\hat w_n}(a^{(n)}) - f_{w^*}(a^{(n)})| &= \left |
\underbrace{
\left(
\sum_{j=1}^m f_{\hat w_n}(b_j(a^{(n)}_j)) -
\sum_{j=1}^m f_{w^*}(b_j(a^{(n)}_j))
\right)}_{A_1 - A_2}+
A_3
\right | \label{eq:} \\
&\leq | A_1 - A_2 | + |A_3|
\end{align*}
Then, we have the following:
\[
\begin{aligned}
A_1 - A_2 &= \sum_{j=1}^m \left(
f_{\hat w_n}(b_j(a^{(n)}_j)) -
f_{w^*}(b_j(a^{(n)}_j))
\right)\\
&= \sum_{j=1}^m
f_{\hat{w}_n - w^*}(b_j(a^{(n)}_j))
\\
&= \sum_{j=1}^m
\phi(b_j(a^{(n)}_j))^\top
\left(
\hat{w}_n - w^*
\right)
\\
\end{aligned}
\]
where we define $\phi(c_{1:m}) = \sum_{i=1}^m \phi_i(c_i)$.
We can write the same for $A_3$:
\begin{align*}
A_3 &= (m-1) f_{w^*}(b) - f_{\hat w_n}(b) \\
&= (m-1) f_{w^* - \hat{w}_n}(b) \\
&= (m-1) \phi(b_{1:m})^\top(w^* - \hat{w}_n) \\
\end{align*}
Similar to the linear bandits setting, we can bound the above quantities with the following:
\[
\begin{aligned}
A_1 - A_2 = \sum_{j=1}^m
\phi(b_j(a^{(n)}_j))^\top
\left(
\hat{w}_n - w^*
\right)
&\leq
\sum_{j=1}^m
\underbrace{\| \phi(b_j(a^{(n)}_j)) \|_{V_n^{-1}}}_{B_1}
\underbrace{\| \hat{w}_n - w^* \|_{V_n}}_{\text{small with high probability}}\\
A_3 &\leq (m - 1) \underbrace{\| \phi(b) \|_{V_n^{-1}}}_{B_2}
\underbrace{\| \hat{w}_n - w^* \|_{V_n}}_{\text{small with high probability}}\\
V_0 = \lambda I \qquad V_n &= V_0 + \sum_{s=1}^n \phi(b_j(a^{(s)}_j)) \phi(b_j(a^{(s)}_j))^\top\\
W_0 = \lambda I \qquad W_n &= W_0 + \sum_{s=1}^n \phi(a^{(s)}) \phi(a^{(s)})^\top
\end{aligned}
\]
For bounding $B_1$ and $B_2$, we need to introduce the idea of Core set and change the $Choose\_Action$ function.
Now we bound E1 in a similar way to E2.
\[
\begin{aligned}
|f_{\hat w_n}(a^*) - f_{w^*}(a^*)| &=
|
f_{\hat w_n}(a^*) - f_{w^*}(a^*)
\pm (m-1) f_{w^*}(b)
\pm (m-1) f_{\hat w_n}(b)
| \\
&= \left |
\underbrace{
\left(
\sum_{j=1}^m f_{\hat w_n}(b_j(a_j^*) -
\sum_{j=1}^m f_{w^*}(b_j(a^*_j))
\right)}_{C}+
(m-1)\left(f_{w^*}(b) - f_{\hat w_n}(b)\right)
\right |.\\
\end{aligned}
\]
We can of course bound $f_{w^*}(b) - f_{\hat w_n}(b)$ the exact same way as we have done earlier in $E_2$..
It is left to bound
$$C = \sum_{j=1}^m f_{\hat w_n}(b_j(a_j^*) - \sum_{j=1}^m f_{w^*}(b_j(a^*_j)) = \sum_{j=1}^m \phi(b_j(a^*_j))^\top (\hat{w}_n - w^*)$$
I'm not sure how we can do this since we don't know if $\phi(b_j(a_j^*))$ is in the Good set or not (I can't think of how we could know this at least).
\input{parts/flatland.tex}
\newpage
\bibliographystyle{unsrtnat}
\section{\uppercase{Additive Q-Functions}}\label{sec:additive}
The result in \cref{ss:mc-lspi-egss-theory} makes no restriction on the choice of features as long as the greedy policy can be computed efficiently (\cref{asm:linear-q-pi,ass: argmax oracle}).
Next, we introduce an additive feature model for which the oracle can be implemented efficiently.
With the greedy oracle (\cref{ass: argmax oracle}), one can use \textsc{Confident MC-LSPI}~combined with \textsc{UncertaintyCheck-EGSS}~and directly invoke \cref{thm:mc-lspi-egss sub-optimality}.
However, in \cref{ss:dav} we introduce a new uncertainty check algorithm, \textsc{UncertaintyCheck-DAV}, that explicitly uses the additive structure.
The additive feature structure leads to improved results in the regimes where the dimension is large, but more importantly facilitates an efficient kernelized version of the \textsc{Confident MC-LSPI}~algorithm (\cref{ss:kernel}).
The additive model also allows an efficient implementation of \textsc{Confident MC-Politex}~\citep{yin2021efficient}, which leads to an improved dependence on the suboptimality in the misspecified setting (\cref{ss:politex}).
In the following, we assume that the action space can be decomposed into a product $\mathcal{A} = \mathcal{A}^{(1:m)} := \mathcal{A}^{(1)} \times \cdots \times \mathcal{A}^{(m)}$ for $m \geq 1$ (borrowing the standard notation from the multi-agent setting).
We further assume access to feature maps $\phi_i: \mathcal{S} \times \mathcal{A}^{(i)} \to \mathbb{R}^d$ for each $i \in [m]$ and define $\phi(s, a^{(1:m)}) = \sum_{i=1}^m \phi_i(s, a^\ag{i})$.
The next assumption states that for any policy $\pi$, the $Q_\pi$-function is (approximately) linear in the feature map $\phi$ and decomposes additively across the components $\mathcal{A}^{(i)}$.
\begin{assumption}
\label{ass: feature decomposition}
For each policy $\pi$ there exists a weight vector $w_\pi \in \mathbb{R}^d, \|w_\pi\|_2 \leq b$ satisfying \looseness=-1
$\max\limits_{(s, a^{(1:m)}) \in \mathcal{S} \times \mathcal{A}} |Q_\pi(s,a^{(1:m)}) -w_\pi^\top \sum_{j=1}^m \phi_j(s,a^{(j)})| \le \epsilon$.
\end{assumption}
In the context of the multi-agent setting (\cref{ex:multi-agent}), the interpretation is that each $\phi_i(s,a^\ag{i})$ models the contribution to the $Q$-function of each agent individually.
Moreover, when \cref{ass: feature decomposition} is satisfied, then for any weight vector $w \in \mathbb{R}^d$ the greedy policy can be implemented with $\mathcal{O}(d\sum_{i=1}^m|\mathcal{A}^\ag{i}|)$ computation: \looseness=-1
\begin{align*}
&\argmax\nolimits_{a^{(1:m)} \in \mathcal{A}} w^\top \phi(s, a^{(1:m)})
\\
&=\big(\argmax_{a^{(1)} \in \mathcal{A}^{(1)}} w^\top \phi_1(s, a^{(1)}), ..., \argmax_{a^{(m)} \in \mathcal{A}^{(m)}} w^\top \phi_m(s, a^{(m)})\big)
\end{align*}
A simple example when \cref{ass: feature decomposition} holds is when $m$ agents ``live'' in $m$ separate MDPs such that in each MDP the action-value functions are linearly realizable with their respective feature-maps and the goal is to maximize the sum of the rewards across the MDPs.
In cases like this, we say that the ``large'' MDP is a \emph{product MDP}.
Note that in this setting agents only observe a joint reward after taking their actions, so an optimal policy for the joint MDP may not always be learned by simply applying single agent algorithms in each individual MDP.
In \cref{app:additive mdp example} we show that \cref{ass: feature decomposition} also captures MDPs that require cooperation between agents, and provide some empirical results.\looseness=-1
\subsection{Uncertainty Check using a Default Action Vector} \label{ss:dav}
In this section we introduce the uncertainty check with a default action vector (\textsc{UncertaintyCheck-DAV}, \cref{alg:uncertainty check dav}).
The goal of the uncertainty check is to ultimately bound the estimation error of $w_k$, i.e.
\begin{align}
|w_k^\top \phi(s, a^{(1:m)}) - Q_{\pi_{k-1}}(s, a^{(1:m)})| \le \eta \,.\label{eq:suboptimality}
\end{align}
Lemma \ref{lemma: yin lemma b.2} shows that a sufficient condition is to ensure that $\|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 \le \tau$ for all $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A})$ that are queried during policy evaluation.\looseness=-1
We show that under \cref{ass: feature decomposition}, it is possible to achieve \cref{eq:suboptimality} while running the uncertainty check for a much smaller set of actions of size $\sum_{i=1}^m |\mathcal{A}^\ag{i}|$.
Recall that \textsc{Confident MC-LSPI}~sets a \emph{default action vector} $\bar a^{(1:m)} \in \mathcal{A}$ as a global.
Define a subset of $\mathcal{A}$ as $\bar \mathcal{A}^{(1:m)} = \{(a^\ag{i}, \bar a^\ag{-i}): a^\ag{i} \in \mathcal{A}^\ag{i}, i \in [m]\}$, where we define $(a^\ag{i}, \bar a^\ag{-i}) =(\bar a^\ag{1},...,\bar a^\ag{i - 1}, a^\ag{i}, \bar a^\ag{i + 1},...,\bar a^\ag{m})$ as the action vector resulting from changing agent $i$'s default action in $\bar a^{(1:m)}$ with $a^\ag{i}$.
Then, by \cref{ass: feature decomposition} for any $a^{(1:m)} \in \mathcal{A}$ we have
\begin{align}
&w_k^\top \phi(s, a^{(1:m)}) \nonumber
= w_k^\top \sum_{i=1}^m \phi_i(s, a^{\ag{i}}) \nonumber \\
&= w_k^\top \Big(\sum_{i=1}^m \phi_i(s, a^\ag{i}) \pm (m-1) \phi_i(s, \bar a^{(1:m)}) \Big) \nonumber \\
&= w_k^\top \Big(\sum_{i=1}^m \phi_i(s, (a^\ag{i}, \bar a^\ag{-i})) - (m-1) \phi_i(s, \bar a^{(1:m)}) \Big) \nonumber
\end{align}
Notice that $\bar a^{(1:m)}, (a^\ag{i}, \bar a^\ag{-i}) \in \bar \mathcal{A}^{(1:m)}, \forall i \in [m]$.
Thus, when $\|\phi(s, \tilde a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 \le \tau$ for all $\tilde a^{(1:m)} \in \bar \mathcal{A}^{(1:m)}$ we can ensure that for all action-vectors $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ that $|w_k^\top \phi(s, a^{(1:m)}) - Q_{\pi_{k-1}}(s, a^{(1:m)})| \le (2m-1)\eta$.
In words, by checking the uncertainty of action-vectors that differ from the default action vector by at most one position $\tilde a^{(1:m)} \in \bar \mathcal{A}^{(1:m)}$ we can bound the sub-optimality of our estimate $w_k$, since the feature of any action vector can be related to the feature of the default action vector under Assumption \ref{ass: feature decomposition}.
Since $\bar \mathcal{A}^{(1:m)}$ only contains $\sum_{i=1}^m |\mathcal{A}^\ag{i}|$ elements, this procedure is $\text{poly}(d,\sum_{i=1}^m |\mathcal{A}^\ag{i}|)$.\looseness=-1
\begin{algorithm}
\caption{\textsc{UncertaintyCheck-DAV}} \label{alg:uncertainty check dav}
\begin{algorithmic}[1]
\State \textbf{Input:} state $s$, core set $\mathcal{C}$, threshold $\tau$.
\State \textbf{Globals:} number of action components $m$
\For {$j \in [m]$}
\For {$a^{(j)} \in \mathcal{A}^{(j)}$}
\State $\tilde{a} \gets (a^{(j)}, \bar a^{(-j)})$
\If {$\phi(s, \tilde{a})^\top V_\mathcal{C}^{-1} \phi(s, \tilde a) > \tau$}
\State result $\gets (s, \tilde a, \phi(s, \tilde a), \text{\textsc{none}})$
\State \Return {\textsc{uncertain}, result}
\EndIf
\EndFor
\EndFor
\State \Return \textsc{certain}, \textsc{none}
\end{algorithmic}
\end{algorithm}
The result
that characterizes the performance of
\textsc{Confident MC-LSPI}~combined with \textsc{UncertaintyCheck-DAV} ~is summarized in the next theorem.
\begin{theorem}[\textsc{Confident MC-LSPI DAV} Sub-Optimality] \label{thm:mc-lspi-dav sub-optimality}
Suppose Assumption \ref{ass: feature decomposition}, and \ref{ass: bounded features} hold.
If $\epsilon = 0$, for any $\kappa > 0$, with probability at least $1 - \delta$, the policy $\pi_{K-1}$, output by \textsc{Confident MC-LSPI}~combined with \textsc{UncertaintyCheck-DAV}~satisfies
\begin{equation*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \kappa.
\end{equation*}
The query and computation complexity are $\mathcal{O}\left(\tfrac{m^2d^3}{\kappa^2 (1-\gamma)^8} \right)$.
and $\text{poly}(\sum_{i=1}^m |\mathcal{A}^\ag{i}|, d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}))$ respectively.
If $\epsilon > 0$, then with probability at least $1 - \delta$, the output policy $\pi_{K-1}$ satisfies\looseness=-1
\begin{equation*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \tfrac{128 \epsilon \sqrt{d} m}{(1-\gamma)^2} (1 +\log(1+ b^2 \epsilon^{-2} d^{-1}))^{1/2}.
\end{equation*}
The query and computation complexity are $\mathcal{O}\left(\tfrac{d^2}{\epsilon^2 (1-\gamma)^4} \right)$.
and $\text{poly}(\sum_{i=1}^m |\mathcal{A}^\ag{i}|, d, \frac{1}{1 - \gamma}, \frac{1}{\epsilon}, \log(\frac{1}{\delta}), \log(1+b))$ respectively.
All parameter settings are in \cref{app: theorem proofs}.
\end{theorem}
When compared to the result in \citet[Theorem 5.1]{yin2021efficient} we have an extra factor of $m^2$ in the query complexity for $\epsilon = 0$, while for $\epsilon \neq 0$ we only have an extra factor of $m$ in the sub-optimality of the output policy. On the other hand, the computational complexity is improved from $\mathcal{O}(\prod_{i=1}^m |\mathcal{A}^\ag{i}|)$ for the prior work to $\mathcal{O}(\sum_{i=1}^m |\mathcal{A}^\ag{i}|)$.
When compared to \cref{thm:mc-lspi-egss sub-optimality} where \textsc{UncertaintyCheck-EGSS}~was used instead of \textsc{UncertaintyCheck-DAV}~the extra dependence on $\sqrt{d}$ changed to $m$.
\subsection{Kernelized Setting}\label{ss:kernel}
The kernelized setting is a standard extension of the finite-dimensional linear setup \citep{srinivas2009gaussian,abbasi2012online}.
It lifts the restriction that the features and parameter vector are elements of $\mathbb{R}^d$.
Formally the kernel is $\mathbf{k} : (\mathcal{S} \times \mathcal{A}^{(1:m)})^2 \rightarrow \mathbb{R}$, which gives rise to a reproducing kernel Hilbert space (RKHS) $\mathcal{H}$, defined as a vector space $V_\mathcal{H} := \mathbb{R}^{\mathcal{S} \times \mathcal{A}^{(1:m)}}$ with inner product $\langle \cdot, \cdot \rangle_\mathcal{H} : V_\mathcal{H} \times V_\mathcal{H} \to \mathbb{R}$.
We require that the $Q_\pi$-function is approximately contained in an RKHS.
This includes cases where the linear dimension of function class is infinite.
\begin{assumption}[Kernel $Q_\pi$-realizability]
\label{ass:kernel q-pi}
For each policy $\pi$ there exists a vector $\tilde Q_\pi \in \mathcal{H}, \|\tilde Q_\pi\|_\mathcal{H} \le b$ that satisfies
$\sup_{s \in \mathcal{S}, a^{(1:m)} \in \mathcal{A}^{(1:m)}} |Q_\pi(s,a^{(1:m)}) - \tilde Q_\pi (s,a^{(1:m)})| \le \epsilon$, where $\tilde Q_\pi(s,a^{(1:m)}) = \langle
\tilde Q_\pi, \mathbf{k}(s, a^{(1:m)}, \cdot, \cdot )\rangle_\mathcal{H}.$
\end{assumption}
Similar to the finite setting we assume an additive structure (on the kernel now) to allow efficient implementation.
For component $j \in [m]$, define the kernel as $\mathbf{k}_j : (\mathcal{S} \times \mathcal{A}^\ag{j})^2 \rightarrow \mathbb{R}$, which gives rise to an RKHS $\mathcal{H}_j$, defined as a vector space $V_{\mathcal{H}_j} := \mathbb{R}^{\mathcal{S} \times \mathcal{A}^\ag{j}}$ with inner product $\langle \cdot, \cdot \rangle_\mathcal{H} : V_{\mathcal{H}_j} \times V_{\mathcal{H}_j} \to \mathbb{R}$.
\begin{assumption}
\label{ass:kernel additive}
The kernel $\mathbf{k}$ can be written as $\mathbf{k}(s_1,a_1^{(1:m)}, s_2,a_2^{(1:m)}) = \sum_{j=1}^m \mathbf{k}_j(s_1,a_1^{(j)}, s_2,a_2^{(j)})$ where $s_1, s_2 \in \mathcal{S}, \ a_1^{(1:m)}, a_2^{(1:m)} \in \mathcal{A}^{(1:m)}$.
\end{assumption}
The kernel setting requires us to address two main challenges.
First, the scaling of the query complexity with the dimension $d$ needs to be improved to a notion of effective dimension.
Following \citet{du2021bilinear, huang2021short} we make use of the critical information gain $\tilde \Gamma$ (defined in \cref{eq:critical infogain}, \cref{app:kernel setting}) which can be bounded for different RKHS of interest \citep{srinivas2009gaussian,huang2021short}.
Second, computationally we cannot directly work with infinite dimensional features $\phi(s,a) = \mathbf{k}(s, a, \cdot, \cdot)$.
Instead, we rely on the `kernel trick' and compute all quantities of interest in the finite-dimensional data space \citep{scholkopf2001generalized}.
After formally arguing as stated above, one can show that a kernelized version of \textsc{Confident MC-LSPI}~and \textsc{UncertaintyCheck-DAV}~provide the following sub-optimality guarantees on the output policy (proof in \cref{app:kernel setting}).
\begin{theorem}[\textsc{Confident Kernel MC-LSPI DAV} Sub-Optimality] \label{thm:kernel mc-lspi-dav sub-optimality}
Suppose Assumption \ref{ass:kernel q-pi}, \ref{ass:kernel additive}, and \ref{ass: bounded features} hold.
Define $\tilde \Gamma := \tilde \Gamma(\lambda, \log(2))$.
If $\epsilon = 0$, for any $\kappa > 0$, with probability at least $1 - \delta$, the policy $\pi_{K-1}$, returned by \textsc{Confident Kernel MC-LSPI}~(\cref{alg:confident kernel mc-lspi/politex}) combined with \textsc{UncertaintyCheck-K-DAV}~(\cref{alg:uncertainty check k-dav}) satisfies
\begin{equation*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \kappa.
\end{equation*}
The query and computation complexity are $\mathcal{O}\left(\tfrac{m^2\tilde \Gamma^3}{\kappa^2 (1-\gamma)^8} \right)$ and $\text{poly}(\sum_{i=1}^m |\mathcal{A}^\ag{i}|, \tilde \Gamma, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}))$ respectively.
If $\epsilon > 0$, then with probability at least $1 - \delta$, the final policy $\pi_{K-1}$ satisfies
\begin{equation*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \tfrac{32 \epsilon m \sqrt{\tilde \Gamma}}{(1-\gamma)^2}.
\end{equation*}
The query and computation complexity are $\mathcal{O}\left(\tfrac{\tilde \Gamma^2}{\epsilon^2 (1-\gamma)^4} \right)$
and $\text{poly}(\sum_{i=1}^m |\mathcal{A}^\ag{i}|, \tilde \Gamma, \frac{1}{1 - \gamma}, \frac{1}{\epsilon}, \log(\frac{1}{\delta}), \log(1+b))$ respectively.
All parameter settings are in \cref{app: theorem proofs}.
\end{theorem}
The result is identical to \cref{thm:mc-lspi-dav sub-optimality} except with $d$ replaced with the critical information gain $\tilde \Gamma(\lambda, \log(2))$.
\subsection{Politex}\label{ss:politex}
The Politex algorithm has been shown to obtain better sub-optimality gaurantees than LSPI by \citet{abbasi2019politex}.
In this section we show that \textsc{Confident MC-Politex}~presented by \citet{yin2021efficient} can be extended to combinatorially large action spaces.
Although Politex is a also based on policy iteration, like LSPI, an important difference is that it uses stochastic policies based on an exponential weighting of each actions $Q$-value.
Efficiently sampling from such a policy is not always possible when the action space is combinatorially large.
We show \cref{ass: feature decomposition} is sufficient to do so (Proposition \ref{prop: efficient politex policy sampling}).
Moreover, using similar arguments as in \cref{ss:dav}, indeed, \textsc{Confident MC-Politex}~combined with \textsc{UncertaintyCheck-DAV}~achieves better sub-optimality guarantees than \textsc{Confident MC-LSPI}.
\begin{theorem}[\textsc{Confident MC-Politex} Sub-Optimality] \label{thm:mc-politex sub-optimality}
Suppose Assumption \ref{ass: feature decomposition}, and \ref{ass: bounded features} hold.
If $\epsilon > 0$, for any $\kappa > 0$, with probability at least $1 - \delta$, the policy $\bar \pi_{K-1}$, output by \textsc{Confident MC-Politex}~(\cref{alg:confident ma mc-politex}) combined with \textsc{UncertaintyCheck-DAV}~(\cref{alg:uncertainty check dav}) satisfies
\begin{equation*}
V^*(\rho) - V_{\bar \pi_{K-1}}(\rho) \leq \tfrac{64 \epsilon m \sqrt{d}}{1-\gamma} (1 +\log(1+b^2 \epsilon^{-2} d^{-1}))^{1/2}.
\end{equation*}
The query and computation complexity are $\mathcal{O}\left(\tfrac{md}{\epsilon^4 (1-\gamma)^5} \right)$
and $\text{poly}(\sum_{i=1}^m |\mathcal{A}^\ag{i}|, d, \frac{1}{1 - \gamma}, \frac{1}{\epsilon}, \log(\frac{1}{\delta}), \log(1+b))$ respectively.
All parameter settings are in \cref{app: theorem proofs}.
\end{theorem}
As expected the sub-optimality is better (scales with $1/(1-\gamma)$) than that of \textsc{Confident MC-LSPI} (\cref{thm:mc-lspi-dav sub-optimality}), which scales with $1/(1-\gamma)^2$.
However, the query complexity is worse (as is typical for Politex), and an extra factor of $m$ is introduced, since mirror descent needs to be run on the entire action space of size $\prod_{i=1}^m |\mathcal{A}^\ag{i}|$ for each state.
We also extend the result to the kernelized setting in \cref{app: theorem proofs},
and show that \textsc{UncertaintyCheck-EGSS}~can be used when \cref{ass: feature decomposition} is satisfied
\section{\uppercase{Efficient MC-LSPI}} \label{sec: algorithms}
In this section, we extend the \textsc{Confident MC-LSPI} algorithm proposed by \cite{yin2021efficient} to the combinatorial action setting.
More precisely, \cref{alg:confident ma mc-lspi} with \cref{alg:uncertainty check} used for the \textsc{UncertaintyCheck} \ is equivalent to the \textsc{Confident MC-LSPI} algorithm presented in \cite{yin2021efficient}, which relies on either enumerating the action set or solving a quadratic maximization problem, both which become infeasible for large $\mathcal{A}$ in general \citep[e.g.,][]{bhattiprolu2021framework}.
The main challenge is to come up with a procedure that uses only polynomially many calls to the greedy oracle while also scaling polynomially in all other quantities of interest.\looseness=-1
At a high level, \cref{alg:confident ma mc-lspi} alternates between policy evaluation and policy improvement.
For evaluation, a core set is constructed that holds a small but sufficiently diverse set of features corresponding to state-action pairs.
For each element of the core set, the \textsc{Rollout}~routine (\cref{alg:confident rollout ma}) returns a Monte-Carlo estimate of the Q-value.
During each rollout, the \textsc{UncertaintyCheck}~subroutine (\cref{alg:uncertainty check egss}) determines if a feature should be added to the core set.
This procedure is repeated until no more elements are added to the core set.
The Monte-Carlo returns from the rollouts are then used to construct a least-squares estimate of $Q_\pi(s,a)$, which in turn is used to improve the policy.
Formally, the outer loop aims to complete $K$ iterations of policy iteration.
The goal of each iteration $k$ is to estimate $Q_{\pi_{k-1}}$ using a weight vector $w_k \in \mathbb{R}^d$ and derive a new greedy policy $\pi_k$, w.r.t.~$w_k$.
For estimation, the algorithm maintains a \emph{core set} $\mathcal{C}$ with elements corresponding to state-action pairs. The elements of the core set $z = (z_s, z_{a}, z_\phi, z_q) \in \mathcal{C}$ are tuples containing a state $z_s \in \mathcal{S}$, an action $z_{a} \in \mathcal{A}$, the corresponding feature $z_\phi \in \mathbb{R}^d$ , and a value estimate $z_q \in \mathbb{R} \cup \{\textsc{none}\}$.
We denote the vector of all value estimates in the core set as $q_\mathcal{C} = (z_q)_{z \in \mathcal{C}} \in \mathbb{R}^{|\mathcal{C}|}$.
The weight vector $w_k$ to estimate $Q_{\pi_{k-1}}$ is computed using regularized least squares, with $q_\mathcal{C}$ as the targets (line 16).
An improved policy based on $w_k$ is then calculated by following the greedy policy with respect to $w^\top \phi(s,a)$ (line 17).
The core set is initialized in lines 3-8 by adding the initial state with a \emph{default action} $\bar a$, so that there is at least one element in the core set to rollout from (line 3).
Then we continuously run the \textsc{UncertaintyCheck}~algorithm until it stops returning a status of \textsc{uncertain}, and add the uncertain tuple to the core set each time.
This is to ensure that the final policy\footnote{The algorithm returns $\pi_{K-1}$ instead of $\pi_K$ because the proof requires that the uncertainty checks for the final policy pass. This is only ensured for $\pi_{K-1}$.} $\pi_{K-1}$ returned by the main algorithm is approximately optimal from the initial state $\rho$, and this can be insured if all the uncertain actions (from $\rho$) are added to the core set (details in Appendix \ref{app:efficient uncertainty check}).\looseness=-1
\input{parts/algo-mclspi}
\input{parts/algo-rollout}
In each iteration $k$, a Monte-Carlo estimation procedure (\textsc{Rollout}, \cref{alg:confident rollout ma}) is launched for every element $z \in \mathcal{C}$ in the core set.
An estimate (result in line 14) is obtained via taking the average return of $n$ Monte-Carlo rollouts of length $H$ while following policy $\pi_{k-1}$.
\textsc{Rollout}~is \emph{successful} if it returns a status of~\textsc{done}~and an estimate of $Q_{\pi_{k-1}}(z_s, z_{a})$, which is assigned to $z_q$.
If at iteration $k$ \textsc{Rollout}~is successful for every core set element then $z_q$ has a value estimate for all $z \in \mathcal{C}$, and the iteration is completed with the policy improvement step.
The way the core set is constructed guarantees that the features of all the elements in the core set are sufficiently different to provide good target values $q_\mathcal{C}$ for least squares (\cref{prop: approx value function bound for DAV,prop: approx value function bound for EGSS}).\looseness=-1
Each time when \textsc{Rollout}~is \emph{unsuccessful}, it returns a status of \textsc{uncertain}~and a corresponding tuple. The uncertain tuple is added to the core set and policy iteration is restarted (line 14) and the value estimates for all the core set elements are reset to \textsc{none}~(line 9).
Roughly speaking, a tuple is flagged as uncertain when during the rollout a features is observed that is sufficiently different from all the features in the core set $\{ z_\phi: z \in \mathcal{C} \}$.
Important is that adding tuples to the core set in this way ensures that the size of the core set is bounded by a $\mathcal{O}(d)$ (\cref{lemma:bound on core set size}).
Restarting policy iteration is mainly to simplify the analysis; in practice it is reasonable to continue with the same policy.\looseness=-1
It remains to specify the \textsc{UncertaintyCheck}~subroutine that is used in \cref{alg:confident ma mc-lspi,alg:confident rollout ma}.
For a fixed state $s \in \mathcal{S}$ the purpose of the uncertainty check is to search for an \emph{uncertain action} that satisfies
\begin{align}
\phi(s, a)^\top (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \phi(s, a) > \tau\label{eq:uncertainty-check}
\end{align}
Here $\Phi_\mathcal{C} \in \mathbb{R}^{|\mathcal{C}| \times d}$ is a matrix of all the features from the tuples in the core set stacked vertically. Solving \cref{eq:uncertainty-check} \emph{exactly} recovers the approach by \citet{yin2021efficient}. However, as this amounts to solving a positive-definite maximization problem, this is infeasible in general.
\subsection{Efficient Good Set Search (EGSS, \cref{alg:uncertainty check egss})}
Next, we show how to efficiently approximate the uncertainty check in \cref{eq:uncertainty-check}.
Define $V_\mathcal{C} = \Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I$ and a weighted matrix norm as $\|x\|_{B}^2 = x^\top B x, \ x \in \mathbb{R}^d, B \in \mathbb{R}^{d \times d}$.
Using this notation, \cref{eq:uncertainty-check} becomes
\begin{align*}
\phi(s, a)^\top (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \phi(s, a) = \|\phi(s, a)\|_{V_\mathcal{C}^{-1}}^2\,> \tau.
\end{align*}
We define the \textit{good set} to be the set of all features with $\| . \|_{V_\mathcal{C}^{-1}}^2$ weighted norm less than or equal to $\tau$ as follows
\begin{align*}
\mathcal{D} = \{\phi(s, a): \|\phi(s, a)\|_{V_\mathcal{C}^{-1}}^2 \le \tau\}.
\end{align*}
Fix a state $s \in \mathcal{S}$.
We want to check if there exists an action outside of the good set (i.e. $a \in \mathcal{A}$ that satisfies $\|\phi(s, a)\|_{V_\mathcal{C}^{-1}}^2 > \tau$) with computation that does not depend on $|\mathcal{A}|$.
To this end, let $L L^\top = V_\mathcal{C}^{-1}$ be a Cholesky decomposition of $V_{\mathcal{C}}^{-1}$ and define
$\hat a = \argmax_{a \in \mathcal{A}} \|L^\top \phi(s, a)\|_\infty$. Note that $\hat a$ satisfies the following norm inequalities:
$$\frac{1}{d}\|\phi(s, \hat a)\|_{V_\mathcal{C}^{-1}}^2 \le \|L^\top \phi(s, \hat a)\|_\infty^2 \le \|\phi(s, \hat a)\|_{V_\mathcal{C}^{-1}}^2$$
In other words, if $\|L^\top \phi(s, \hat a)\|_\infty^2 > \tau$ holds, then we have $\|\phi(s, \hat a)\|_{V_\mathcal{C}^{-1}}^2 > \tau$ and we have found an uncertain state-action pair.
At the same time if $\|L^\top \phi(s, \hat a)\|_\infty^2 \le \tau$ then we are sure that $\|\phi(s, a)\|_{V_\mathcal{C}^{-1}}^2 \le d \tau$ for all $a \in \mathcal{A}$.
The fact that the last inequality is still sufficient to provide bounds on the sub-optimality of policy evaluation manifests in Proposition \ref{prop: approx value function bound for EGSS}, where only an extra factor of $\sqrt{d}$ is introduced.
Finally, notice that
\begin{align}
&\max_{a \in \mathcal{A}} \|L^\top \phi(s, a)\|_\infty = \max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a \in \mathcal{A}} \langle Lv, \phi(s, a)\rangle\label{eq:infty-norm-oracle}
\end{align}
can be computed efficiently using $2d$ calls to the greedy oracle (\cref{ass: argmax oracle})
\input{parts/algo-egss}
\subsection{Theoretical Guarantees}\label{ss:mc-lspi-egss-theory}
The result that
characterizes the performance of
\textsc{Confident MC-LSPI}~combined with \textsc{UncertaintyCheck-EGSS}~is summarized in the next theorem.
\begin{theorem}[\textsc{Confident MC-LSPI EGSS} Sub-Optimality] \label{thm:mc-lspi-egss sub-optimality}
Suppose \cref{asm:linear-q-pi,ass: bounded features,ass: argmax oracle} hold.
If $\epsilon = 0$, for any $\kappa > 0$, with probability at least $1 - \delta$, the final policy $\pi_{K-1}$, returned by \textsc{Confident MC-LSPI}~combined with \textsc{UncertaintyCheck-EGSS}~satisfies
\begin{equation*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \kappa.
\end{equation*}
The query and computation complexity are $\mathcal{O}\big(\tfrac{d^4}{\kappa^2 (1-\gamma)^8} \big)$ and $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}))$ respectively.
If $\epsilon > 0$, then with probability at least $1 - \delta$, the policy $\pi_{K-1}$, output satisfies
\begin{equation*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \tfrac{64 \epsilon d}{(1-\gamma)^2} (1 +\log(1+b^2 \epsilon^{-2} d^{-1}))^{1/2}.
\end{equation*}
The query and computation complexity are $\mathcal{O}\big(\tfrac{d^2}{\epsilon^2 (1-\gamma)^4} \big)$ and $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\epsilon}, \log(\frac{1}{\delta}), \log(1+b))$, respectively.
All parameter settings are in \cref{app: theorem proofs}.
\end{theorem}
When compared to the result in \citet[Theorem 5.1]{yin2021efficient} we have an extra factor of $d$ in the query complexity for $\epsilon = 0$, while for $\epsilon \neq 0$ we only have an extra factor of $\sqrt{d}$ in the sub-optimality of the output policy.
This is similar to linear bandits, where an extra $\sqrt{d}$ is suffered in the regret for oracle-efficient methods \citep{dani2008stochastic,agrawal2013thompson,abeille2017linear}. \looseness=-1
The full proof is given in \cref{app: theorem proofs}.
The proof essentially follows the ideas in \citet{yin2021efficient} while carefully arguing how \textsc{UncertaintyCheck-EGSS}~affects the query complexity.
For the computational complexity, note that \textsc{UncertaintyCheck-EGSS}~can be implemented in $\text{poly}(d)$ by \cref{eq:infty-norm-oracle}, and linear algebra operations.
Since the core set size is bounded (\cref{lemma:bound on core set size}), policy iteration only restarts $\mathcal{O}(d)$ times.
Lastly, the policy improvement step is trivially implemented using the greedy oracle (\cref{ass: argmax oracle}). \looseness=-1
\section{\uppercase{Efficient Policy Sampling}} \label{app:efficienct policy sampling}
The policy in \citep{yin2021efficient} for \textsc{Confident MC-LSPI}~and \textsc{Confident MC-Politex}~is as follows
\begin{equation}
\pi_k(a|s) \gets
\begin{cases}
\mathds{1}\left(a = \argmax\limits_{\tilde{a} \in \mathcal{A}} w^\top \phi(s, \tilde{a})\right) & \text{LSPI} \\
\exp\left(\alpha \sum\limits_{j=0}^{k-1} Q_j(s, a)\right) / \sum\limits_{a \in \mathcal{A}} \exp\left(\alpha \sum\limits_{j=0}^{k-1} Q_k(s, a)\right) . & \text{Politex}
\end{cases} \label{eq:yin policy}
\end{equation}
with $w_k = (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \Phi_\mathcal{C}^\top q_\mathcal{C}$
and $Q_{k-1}(s, a) = \min\{\max\{w_k^\top \phi(s, a), 0\}, 1/(1-\gamma)\}$ for the Politex case only.
In this section we show that the above policy can be sampled from efficiently if \cref{ass: feature decomposition} or \cref{ass: argmax oracle} is satisfied for the LSPI case and policy $\pi_k$ can be sampled from efficiently if \cref{ass: feature decomposition} is satisfied for the Politex case.
To be precise, by efficiently we mean with computation that does not depend on $|\mathcal{A}|$.
We assume only $w \in \mathbb{R}^d$ or $w_0, ..., w_{k-1} \in \mathbb{R}^d$ (for LSPI and Politex respectively) and a feature map $\phi: \mathcal{S} \times \mathcal{A} \to \mathbb{R}^d$ are given, thus the process of sampling may require calculating the policy if necessary to accurately sample.
First we handle the LSPI case.
\begin{proposition}[Efficient LSPI Policy Sampling]
\label{prop: efficient lspi policy sampling}
Given state $s \in \mathcal{S}$, parameter vector $w \in \mathbb{R}^d$, feature map $\phi: \mathcal{S} \times \mathcal{A} \to \mathbb{R}^d$ and assumption \cref{ass: feature decomposition} or \cref{ass: argmax oracle} satisfied.
Then policy
$$\pi_k(a|s) = \mathds{1}\left(a = \argmax_{\tilde{a} \in \mathcal{A}} w^\top \phi(s, \tilde{a})\right)$$
can be sampled from in with computation that does not depend on $|\mathcal{A}|$.
\end{proposition}
\begin{proof}
One can sample from policy $\pi_k$ by simply outputting the result of $\argmax_{\tilde{a} \in \mathcal{A}} w^\top \phi(s, \tilde{a})$.
Under assumption \cref{ass: argmax oracle} $\argmax_{\tilde{a} \in \mathcal{A}} w^\top \phi(s, \tilde{a})$ can be computed in constant time by applying the oracle to $w$ and $\phi$ (i.e. $\mathcal{G}(w, \phi)$).
While, \cref{ass: feature decomposition} implies we can compute $\argmax_{\tilde{a} \in \mathcal{A}} w^\top \phi(s, \tilde{a})$ in $\text{poly}(\sum_{i=1}^m |A^\ag{i}|, d)$ time, since
\begin{align*}
&\argmax\nolimits_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} w^\top \phi(s, a^{(1:m)})
\\
&=\big(\argmax_{a^{(1)} \in \mathcal{A}^{(1)}} w^\top \phi_1(s, a^{(1)}), ..., \argmax_{a^{(m)} \in \mathcal{A}^{(m)}} w^\top \phi_m(s, a^{(m)})\big)
\end{align*}
\end{proof}
Next, we handle the Politex case.
To achieve the result below we assume \cref{ass: feature decomposition} is satisfied.
We have to modify the Politex policy in \cref{eq:yin policy} slightly, by removing the clipping of the $Q$-function at each iteration $k$ (i.e. we define the $Q$-function at iteration $k$ to be $Q_{k-1}(s, a) = w_k^\top \phi(s, a)$ instead of $Q_{k-1}(s, a) = \min\{\max\{w_k^\top \phi(s, a), 0\}, 1/(1-\gamma)\}$).
This was done since we were not aware of an efficient way to compute the clipped $Q$-function for all action-vectors in $\mathcal{A}^{(1:m)}$.
Importantly, removing the clipping does not suffer any increase in the dominating terms of the final policies sub-optimality (shown in \cref{app: theorem proofs})
\begin{proposition}[Efficient Politex Policy Sampling]
\label{prop: efficient politex policy sampling}
Given state $s \in \mathcal{S}$, parameter vectors $w_0, ..., w_{k-1} \in \mathbb{R}^d$, feature map $\phi: \mathcal{S} \times \mathcal{A}^{(1:m)} \to \mathbb{R}^d$ and \cref{ass: feature decomposition} satisfied.
Then policy
$$\pi_k(a^{(1:m)}|s) = \exp\left(\alpha \sum\nolimits_{j=0}^{k-1} w_{j}^\top \phi(s, a^{(1:m)})\right)/ \sum\nolimits_{\tilde{a}^{(1:m)} \in \mathcal{A}^{(1:m)}} \exp \left(\alpha \sum\nolimits_{j=0}^{k-1} w_{j}^\top \phi(s, \tilde{a}^{(1:m)})\right)$$
with $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ can be sampled from in time $\text{poly}(\sum_{i=1}^m |\mathcal{A}_i|, d)$.
\end{proposition}
\begin{proof}
Fix arbitrary $a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
To sample from $\pi_k$ it is sufficient to sample actions $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ proportional to $\exp(\alpha \sum_{j=0}^{k-1} Q_{j}(s, a^{(1:m)}))$.
Rearranging $\exp(\alpha \sum_{j=0}^{k-1} Q_{j}(s, a^{(1:m)}))$ and plugging in that $\phi(s, a^{(1:m)}) = \sum_{i=1}^m \phi_i(s, a^\ag{i})$ under assumption \cref{ass: feature decomposition} we have
\begin{align*}
\exp\left(\alpha \sum\nolimits_{j=0}^{k-1} w_{j}^\top \phi(s, a^{(1:m)})\right)
&= \prod_{j=0}^{k-1} \exp\left(\alpha w_{j}^\top \phi(s, a^{(1:m)})\right) \\
&= \prod_{j=0}^{k-1} \exp\left(\alpha w_{j}^\top \sum_{i=1}^m \phi_i(s, a^\ag{i})\right) \\
&= \prod_{i=1}^m \prod_{j=0}^{k-1} \exp\left(\alpha w_{j}^\top \phi_i(s, a^\ag{i})\right)
\end{align*}
Which means that the probability of sampling action $a^{(1:m)}$ is equal to the product of the probabilities of sampling $a^\ag{i}$ for $i \in [m]$ independently.
Since $a^{(1:m)}$ was arbitrary this completes the proof.
\end{proof}
\section{\uppercase{Bound on Core Set Size}}
\citet{yin2021efficient} showed that when only tuples containing state-action vectors that satisfy $\phi(s, a)^\top (\Phi^\top \Phi + \lambda I)^{-1} \phi(s, a) > \tau$ are add to the core set then it can be bounded as follows.
\begin{lemma}[Bound on Core Set Size (Lemme 5.1 in \citep{yin2021efficient})] \label{lemma:bound on core set size}
When \cref{ass: bounded features} is satisfied, and $(s, a) \in (\mathcal{S} \times \mathcal{A})$ that satisfy $\phi(s, a)^\top (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \phi(s, a) > \tau$ are added to the core set, the size of the core set can be bounded by
\begin{align}
\tilde{C}_{\max} := \frac{e}{e-1} \frac{1 + \tau}{\tau} d \left(
\log(1 + \frac{1}{\tau}) +
\log(1 + \frac{1}{\lambda})
\right). \label{eq:cmax-new}
\end{align}
\end{lemma}
\section{\uppercase{Efficient Uncertainty Check}} \label{app:efficient uncertainty check}
\label{app: efficient uncertainty check}
The \textsc{Confident MC-LSPI}~algorithm proposed by \citet{yin2021efficient} is the same as our \textsc{Confident MC-LSPI}~(\cref{alg:confident ma mc-lspi}) algorithm combined with \textsc{UncertaintyCheck}~(\cref{alg:uncertainty check}) and the policy on line 17 of \textsc{Confident MC-LSPI}~replaced with \cref{eq:yin policy}.
\begin{algorithm}
\caption{\textsc{UncertaintyCheck}} \label{alg:uncertainty check}
\begin{algorithmic}[1]
\State \textbf{Input:} state $s$, core set $\mathcal{C}$, threshold $\tau$
\For {$a \in \mathcal{A}$}
\If {$\phi(s, a)^\top (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \phi(s, a) > \tau$}
\State status $\gets$ \textsc{uncertain}, result $\gets (s, a, \phi(s, a), \textsc{none})$
\State \Return {status, result}
\EndIf
\EndFor
\State \Return \textsc{certain}, \textsc{none}
\end{algorithmic}
\end{algorithm}
Notice that \textsc{UncertaintyCheck}~requires iterating over $\mathcal{A}$ (line 2), which is computationally expensive with the action space is combinatorially large.
In this appendix we show how the loop over all actions $a \in \mathcal{A}$ in the \textsc{UncertaintyCheck}~algorithm can be avoided when either \cref{ass: feature decomposition} or \cref{ass: argmax oracle} is satisfied.
In particular, we show that \textsc{UncertaintyCheck-DAV}~and \textsc{UncertaintyCheck-EGSS}~algorithms are able to reduce the computation time of \textsc{UncertaintyCheck}~to no longer depend on $|\mathcal{A}|$, while still maintaining suitable output policy guarantees.
Since, we are extending the \textsc{Confident MC-LSPI}~algorithm proposed by \citet{yin2021efficient}, we will be borrowing much of the steps from their proof.
\citet{yin2021efficient} used a \textit{virtual algorithm} (VA) and \textit{main algorithm} (MA) to prove the sub-optimality of their \textsc{Confident MC-LSPI}~algorithm.
We give a brief summary of the VA and MA; however, avoid full details since we use the exact same definition as in \citet{yin2021efficient}.
Until the next subsection, assume \textsc{UncertaintyCheck}~is used in \textsc{Confident MC-LSPI}~and \textsc{Rollout}.
The MA is exactly \textsc{Confident MC-LSPI}.
The VA is based on the \textsc{Confident MC-LSPI}~algorithm, but has some differences, which we outline next.
The VA runs for exactly $C_\text{max}$ loops, $K$ iterations, and completes all $n$ of its rollouts of length $H$.
For each loop and iteration $k$ the VA always obtains estimates $q_\mathcal{C}$ of its policy.
The VA uses a different policy than the MA for rollouts.
We will first focus on the LSPI case and return to Politex much later.
The VA's $Q$-function at iteration $k$ is
\begin{equation*}
\tilde{Q}_{k-1}(s, a)=\begin{cases}
\tilde{w}_k^\top \phi(s, a) \quad &\text{if} \, \phi(s, a) \in \mathcal{D} \\
Q_{\tilde{\pi}_{k-1}}(s, a) \quad &\text{if} \, \phi(s, a) \notin \mathcal{D} \\
\end{cases}
\end{equation*}
where $\tilde w_k = V_\mathcal{C}^{-1} \Phi_\mathcal{C}^\top \tilde q_\mathcal{C}$, and $\tilde q_\mathcal{C}$ are the estimates obtained from running \textsc{Rollout}~on each element of the core set, and $\mathcal{D} = \{\phi(s, a): \|\phi(s, a)\|_{V_\mathcal{C}^{-1}}^2 \le \tau\}$ is the \textit{good set}.
The VA's policy is
\begin{equation*}
\tilde \pi_k(a | s) = \mathds{1} \left( a = \argmax_{\tilde a \in \mathcal{A}} \tilde Q_{k-1}(s, \tilde a) \right).
\end{equation*}
The nice thing about defining the VA's policy in this way is that we can make use of the following Lemma from \citep{yin2021efficient}.
\begin{lemma}[Lemma B.2 in \citep{yin2021efficient}]
\label{lemma: yin lemma b.2}
Suppose that Assumption \cref{ass: feature decomposition} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
for any $(s, a) \in (\mathcal{S} \times \mathcal{A})$ pair such that $\phi(s, a) \in \mathcal{D}$, we have
$$|\tilde{Q}_{k-1} (s, a) - Q_{\tilde\pi_{k-1}} (s, a)| \le b\sqrt{\lambda \tau} + \left(\epsilon + \frac{\gamma^{H-1}}{1 - \gamma} + \theta \right) \sqrt{\tau C_{\text{max}}} + \epsilon := \eta$$
\end{lemma}
Notice that for any $(s, a) \in (\mathcal{S} \times \mathcal{A})$ pair such that $\phi(s, a) \notin \mathcal{D}$, the VA's $Q$-function $\tilde Q_{k-1}$ has access to the true $Q$-function $Q_{\tilde{\pi}_{k-1}}$ of policy $\tilde \pi_{k-1}$.
Thus, we have that
\begin{equation}
\label{eq:va inf-norm bound}
\| \tilde{Q}_{k-1} (s, a) - Q_{\tilde\pi_{k-1}} (s, a) \|_\infty \le \eta
\end{equation}
Combined with the fact that $\tilde \pi_k$ is greedy w.r.t. $\tilde Q_{k-1}$ the above result turns out to be especially useful.
To understand why, we state a classic policy improvement result, which can be found as Lemma B.3 in \citet{yin2021efficient} and in other papers.
\begin{lemma}[approximate policy iteration]
\label{lemma:approximate policy iteration}
Suppose that we run K approximate policy iterations and generate a sequence of policies
$\pi_0, \pi_1, \pi_2, \cdots, \pi_K$.
Suppose that for every $k = 1, 2, \cdots, K$, in the k-th iteration, we obtain a function
$\tilde{Q}_{k-1}$ such that, $\| \tilde{Q}_{k - 1} - Q_{\pi_{k - 1}} \|_\infty \leq \eta$,
and choose $\pi_k$ to be greedy with respect to $\tilde{Q}_{k-1}$.
Then
\begin{align*}
\| Q^* - Q_{\pi_K} \|_\infty \leq \frac{2 \eta}{1 - \gamma} + \frac{\gamma^K}{1 - \gamma},
\end{align*}
\end{lemma}
In our case the VA's policy $\tilde \pi_k$ is greedy w.r.t. $\tilde Q_{k-1}$ and thus we have that
\begin{align*}
\| Q^* - Q_{\tilde \pi_K} \|_\infty \leq \frac{2 \eta}{1 - \gamma} + \frac{\gamma^K}{1 - \gamma},
\end{align*}
Now we explain how the MA can be related to the VA, and make use of the above result.
The \textsc{UncertaintyCheck}~algorithm can have two cases:
\textbf{Case 1:} $\|\phi(s, a)\|_{V_\mathcal{C}^{-1}}^2 > \tau$ holds for at least one $a \in \mathcal{A}$,
\textbf{Case 2:} $\|\phi(s, a)\|_{V_\mathcal{C}^{-1}}^2 \le \tau$ holds for all $a \in \mathcal{A}$. This is equivalent to saying $\phi(s, a) \in \mathcal{D}, \ \forall a \in \mathcal{A}$.
The VA is exactly the same at the MA algorithm, until Case 1 occurs for the first time.
This is because the MA's and VA's simulators are coupled, in the sense that at iteration $k$, rollout $i$, and step $t$, when both simulators are queried with the same state-action vector pairs, they sample the exact same next state and reward.
The VA also uses the same initial policy as the MA at the start of policy iteration for every loop.
Once Case 1 occurs the MA would restart policy iteration (else condition in line 14 of \textsc{Confident MC-LSPI}), while the VA does not.
The VA records the state-action vector pair when Case 1 occurs for the first time and adds it to the core set once it completes running policy iteration for the current loop.
In this way the core set maintained by the MA and VA are always the same.
Since the size of the core set is bounded by $C_\text{max}$ when $(s, a) \in (\mathcal{S} \times \mathcal{A})$ that satisfy $\phi(s, a)^\top (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \phi(s, a) > \tau$ are added to the core set (\cref{lemma:bound on core set size}), there will be a loop of policy iteration at which the MA and VA never encounter Case 1 for any of the $K$ iterations of policy iteration.
We call this loop the \emph{final loop}.
This is equivalent to say that all $(s, a) \in (\mathcal{S} \times \mathcal{A})$ observed during all $K$ iterations of policy iteration in the final loop are in the good set (i.e. $\phi(s, a) \in \mathcal{D}$).
Notice that this means MA and VA behaved identical in the final loop, since the VA's policy would have always been greedy w.r.t. $\tilde{w}_k^\top \phi$ and the MA and VA use the same initial policy at the start of each loop.
It turns out this relationship between the MA and VA allows us to bound the sub-optimality of the MA in the final loop, by using the result in \cref{eq:va inf-norm bound} we have for the VA.
More precisely, the following result can be extracted from \citep{yin2021efficient}
\begin{proposition}[equation (B.15) in \citet{yin2021efficient}] \label{prop:optimality of output policy}
With all terms as defined earlier.
Define $\eta \ge \|\tilde Q_{k-1}(s, a) - Q_{\tilde \pi_{k-1}}(s, a)\|_\infty$.
Suppose $\eta \ge |\tilde w_{k}^\top \phi(\rho, a) - Q_{\tilde \pi_{k-1}}(\rho, a)|, \ \forall a \in \mathcal{A}$.
Then, if the VA and MA behave identically in the final loop, with probability at least $1 - 4KC_{\text{max}}^2 \exp(-2 \theta^2(1-\gamma)^2 n)$ we have
\begin{align}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \frac{8 \eta}{(1 - \gamma)^2} + \frac{2 \gamma^{K - 1}}{(1 - \gamma)^2} \label{eq: v function bound main}
\end{align}
\end{proposition}
Notice, that we require three things to use the above result.
We need a bound on $\|\tilde Q_{k-1}(s, a) - Q_{\tilde \pi_{k-1}}(s, a)\|_\infty$.
We need a bound on $|\tilde w_{k}^\top \phi(\rho, a) - Q_{\tilde \pi_{k-1}}(\rho, a)|, \ \forall a \in \mathcal{A}$.
We need to ensure that the VA and MA behave identically in the final loop.
Then, we can get a bound on the sub-optimality of the MA's output policy $\pi_{K-1}$.
An important observation is that \textsc{UncertaintyCheck}~ensured that MA and VA behave identically in the final loop.
It did this by making sure that the VA's policy $\tilde \pi_k$ would only be able to use $\tilde{w}_k^\top \phi$ to derive its actions, since \textsc{UncertaintyCheck}~always returns a status of \textsc{certain} in the final loop, which means that $\phi(s, a) \in \mathcal{D}$ for all $s, a \in \mathcal{S} \times \mathcal{A}$ encountered in the final loop.
With this information in mind, we now show that \textsc{UncertaintyCheck-DAV}~and \textsc{UncertaintyCheck-EGSS}~only requires computation independent of $|\mathcal{A}|$, while providing only slightly worse sub-optimality guarantees when compared to the result in \citep{yin2021efficient}.
\subsection{Efficient Good Set Search Approach (EGSS)} \label{subsec:good set search}
In this section we prove some useful results for \textsc{UncertaintyCheck-EGSS}.
Fix a state $s \in \mathcal{S}$.
First, we show that with computation independent of $|\mathcal{A}|$, one can find an action vector $a \in \mathcal{A}$ that approximately maximizes $\phi(s, a)^\top V_\mathcal{C}^{-1} \phi(s, a)$.
\begin{lemma}[Efficient good set search]
\label{lemma:good set search}
Assume either \cref{ass: argmax oracle} is satisfied.
With all terms as defined earlier.
One can ensure, with $2 d$ calls to the greedy oracle that
$$\phi(s, a)^\top V_\mathcal{C}^{-1} \phi(s, a) \le d\tau$$
for all $a \in \mathcal{A}$, or there exists an $a \in \mathcal{A}$ such that
$$\phi(s, a)^\top V_\mathcal{C}^{-1} \phi(s, a) > \tau.$$
Further, if \cref{ass: feature decomposition} is satisfied, then the same guarantees hold with $2 d^2 \sum_{i=1}^m |A^\ag{i}|$ computation time.
\end{lemma}
\begin{proof}
Recall that we are able to compute $\max_{a \in \mathcal{A}} \langle u, \phi(s, a) \rangle$ for any $u \in \mathbb{R}^d$ in constant time if \cref{ass: feature decomposition} is satisfied, and in $d \sum_{i=1}^m |A^\ag{i}|$ time if \cref{ass: argmax oracle} is satisfied.
We make use of a bi-directional 2-norm to $\infty$-norm inequality that will take advantage of the above mentioned efficient computation.
Fix $\mathcal{C}$ and define the lower triangular matrix $L$ via the Cholesky decomposition $V_\mathcal{C}^{-1} = L L^\top$.
Define $\{e_i\}_{i=1}^d$ as the standard basis vectors and
\begin{equation*}
(v^*, a_\text{max}) := \text{arg} \left(\max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a \in \mathcal{A}} \langle L v, \phi(s, a) \rangle \right)
\end{equation*}
Then we have that
\begin{align}
\frac{1}{d} \| \phi(s, a_\text{max}) \|_{V_\mathcal{C}^{-1}}^2
&= \frac{1}{d} \phi(s, a_\text{max})^\top V_\mathcal{C}^{-1} \phi(s, a_\text{max}) \nonumber \\
&= \frac{1}{d} \phi(s, a_\text{max})^\top L L^\top \phi(s, a_\text{max}) \nonumber \\
&= \frac{1}{d} \| L^\top \phi(s, a_\text{max}) \|_2^2 \nonumber \\
&\le \max_{a \in \mathcal{A}} \| L^\top \phi(s, a)\|_\infty^2 \nonumber \\
&= \max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a \in \mathcal{A}} \langle v, L^\top \phi(s, a) \rangle^2 \nonumber \\
&= \max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a \in \mathcal{A}} \langle L v, \phi(s, a) \rangle^2 \label{inf-norm term} \\
&= \langle L v^*, \phi(s, a_\text{max}) \rangle^2 \nonumber \\
&\le \| L^\top \phi(s, a_\text{max}) \|_2^2 \nonumber
\end{align}
The purpose of writing all the equalities up to \cref{inf-norm term} was to show that \cref{inf-norm term} can be computed efficiently.
This is since we are able to compute $\max_{a \in \mathcal{A}} \langle L v, \phi(s, a) \rangle^2$ in constant time if \cref{ass: feature decomposition} is satisfied, and in $d \sum_{i=1}^m |A^\ag{i}|$ time if \cref{ass: argmax oracle} is satisfied, and $\{\pm e_i\}_{i=1}^d$ contains $2d$ elements.
Also, note that $L$ can be computed with at most $d^2$ computation in each loop by doing a rank one update to the Cholesky decomposition of $V_\mathcal{C}^{-1} = L L^\top$.
If equation (\cref{inf-norm term}) is larger than $\tau$, then $\|\phi(s, a_\text{max}) \|_{V^{-1}}^2 > \tau$.
While, if equation (\cref{inf-norm term}) is less than or equal $\tau$, then $\|\phi(s, a_\text{max}) \|_{V^{-1}}^2 \le d\tau$, completing the proof.
\end{proof}
\textsc{UncertaintyCheck-EGSS}~is essentially an implementation of equation (\cref{inf-norm term}), thus its computation is independent of $|\mathcal{A}|$, as stated in \cref{lemma:good set search}.
Also, since only $a \in \mathcal{A}$ that satisfy $\|\phi(s, a)\|_{V_\mathcal{C}^{-1}}^2 \ge \|\phi(s, a)\|_\infty^2 > \tau$ are added to the core set, we can still use \cref{lemma:bound on core set size} to bound the size of the core set by $C_\text{max}$.
Basically, \cref{inf-norm term} is an underestimate of $\| \phi(s, a_\text{max}) \|_{V^{-1}}^2$ and we only add elements to the core set when it is larger than $\tau$, thus the core set is no larger than it was when using \textsc{UncertaintyCheck}.
Now, we aim to ensure that the VA and MA behave identically in the final loop.
Notice that \textsc{UncertaintyCheck-EGSS}~provides a weaker guarantee than \textsc{UncertaintyCheck}, when the returned result is \textsc{certain}.
Specifically, when \textsc{UncertaintyCheck-EGSS}~returns a result of \textsc{certain}, then \cref{lemma:good set search} guarantees that $\|\phi(s, a)\|_{V_\mathcal{C}^{-1}}^2 \le d\tau$ for all $a \in \mathcal{A}$.
While when the \textsc{UncertaintyCheck}~returns a result of \textsc{certain}, then $\|\phi(s, a)\|_{V_\mathcal{C}^{-1}}^2 \le \tau$ for all $a \in \mathcal{A}$.
Thus, we define a smaller good set $\mathcal{D}_d = \{ \phi(s, a): \|\phi(s, a)\|_{V_\mathcal{C}^{-1}}^2 \le d\tau\}$.
Redefine the VA's $Q$-function at iteration $k$ as
\begin{equation*}
\tilde{Q}_{k-1}(s, a)=\begin{cases}
\tilde{w}_k^\top \phi(s, a) \quad &\text{if} \, \phi(s, a) \in \mathcal{D}_d \\
Q_{\tilde{\pi}_{k-1}}(s, a) \quad &\text{if} \, \phi(s, a) \notin \mathcal{D}_d \\
\end{cases}
\end{equation*}
and VA's policy as
\begin{equation*}
\tilde \pi_k(a | s) = \mathds{1} \left( a = \argmax_{\tilde a \in \mathcal{A}} \tilde Q_{k-1}(s, \tilde a) \right).
\end{equation*}
Notice that in the final loop \textsc{UncertaintyCheck-EGSS}~always returns a \textsc{result} of \textsc{certain}, and thus we are sure that all $a \in \mathcal{A}$ for all the states encountered in the final loop are in the smaller good set $\mathcal{D}_d$.
Thus, the VA's policy $\pi_{k}$ would always be greedy w.r.t. $\tilde w_k^\top \phi$ in the final loop.
This ensures that the VA and MA behave identically in the final loop.
Next we need show that we can bound $\|\tilde Q_{k-1}(s, a) - Q_{\tilde \pi_{k-1}}(s, a)\|_\infty$ with this new definition of $\tilde Q_{k-1}$.
First we state a slight modification of \cref{lemma: yin lemma b.2} that holds for the smaller good set $\mathcal{D}_d$
\begin{lemma}[EGSS modified Lemma B.2 from \cite{yin2021efficient}]
\label{lemma: mod b.2 egss}
Suppose that \cref{asm:linear-q-pi} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
for any $(s, a) \in (\mathcal{S} \times \mathcal{A})$ pair such that $\phi(s, a) \in \mathcal{D}_d$, we have
$$|\tilde{w}_k^\top \phi(s, a) - w_{\tilde\pi_{k-1}}^\top \phi(s, a)| \le b\sqrt{\lambda d \tau} + \left(\epsilon + \frac{\gamma^{H+1}}{1 - \gamma} + \theta \right) \sqrt{d \tau C_{\text{max}}} + \epsilon = \sqrt{d} \bar \eta:= \eta_2$$
\end{lemma}
\begin{proof}
The proof is identical to that of Lemme B.2 from \cite{yin2021efficient} except $\tau$ is replaced with $d \tau$ everywhere, due to the weaker guarantee of \textsc{UncertaintyCheck-EGSS} as discussed above.
\end{proof}
Essentially we get an extra $\sqrt{d}$ factor due to the smaller good set $\mathcal{D}_d$.
Since the VA's policy $\tilde \pi_{k}$ has access to the true $Q$-function $Q_{\tilde \pi_{k-1}}$ for all $\phi(s, a) \notin \mathcal{D}_d$,
we can show that $\|\tilde Q_{k-1}(s, a) - Q_{\tilde \pi_{k-1}}(s, a)\|_\infty$ can be bounded.
\begin{proposition}[approximate value function bound for EGSS]
\label{prop: approx value function bound for EGSS}
Suppose that \cref{asm:linear-q-pi} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
we have
$$\|\tilde Q_{k-1}(s, a) - Q_{\tilde{\pi}_{k-1}}(s, a)\|_\infty \le \eta_2.$$
\end{proposition}
\begin{proof}
For any $(s, a) \in (\mathcal{S} \times \mathcal{A})$ such that $\phi(s, a) \in \mathcal{D}_d$, we have
\begin{align}
|\tilde Q_{k-1}(s, a) - Q_{\tilde{\pi}_{k-1}}(s, a)| \le \eta_2
\end{align}
by \cref{prop: approx value function bound for EGSS}.
While for any $(s, a) \in (\mathcal{S} \times \mathcal{A})$ such that $\phi(s, a) \notin \mathcal{D}_d$, we have
\begin{align}
|\tilde Q_{k-1}(s, a) - Q_{\tilde{\pi}_{k-1}}(s, a)|
= |Q_{\tilde \pi_{k-1}}(s, a) - Q_{\tilde{\pi}_{k-1}}(s, a)|
&= 0
\end{align}
\end{proof}
Finally, it is left to show that $|\tilde w_{k}^\top \phi(\rho, a) - Q_{\tilde \pi_{k-1}}(\rho, a)|$ can be bounded for all $a \in \mathcal{A}$.
Notice that lines 4-8 in \textsc{Confident MC-LSPI}~run \textsc{UncertaintyCheck-EGSS}~with state $\rho$ as input until the returned status is \textsc{certain}.
Recall that once \textsc{UncertaintyCheck-EGSS}~returns a status of \textsc{certain}~we know that $\rho \in \mathcal{D}_d$.
Thus, we can immediately apply \cref{lemma: mod b.2 egss} to bound $\eta_2 \ge |\tilde w_{k}^\top \phi(\rho, a) - Q_{\tilde \pi_{k-1}}(\rho, a)|, \ \forall a \in \mathcal{A}$.
\subsection{Default Action Vector (DAV) Method}
In this section we prove some useful results for \textsc{UncertaintyCheck-DAV}.
Fix a state $s \in \mathcal{S}$.
As mentioned in the body, assume the action space can be decomposed as a product $\mathcal{A}^{(1:m)} = \mathcal{A}^\ag{1} \times ... \times \mathcal{A}^\ag{m}$ throughout this section.
We call elements of $\mathcal{A}^{(1:m)}$ \textit{action vectors}.
First, \textsc{UncertaintyCheck-DAV}~only iterates over $\sum_{i=1}^m |A^\ag{i}|$ action vectors instead of all the action vectors like \textsc{UncertaintyCheck}~does.
Define the $\sum_{i=1}^m A^\ag{i}$ sized set of modified default action vectors as $\bar \mathcal{A}^{(1:m)} = \{ (a^\ag{i}, \bar a^{(-i)}): a^\ag{i} \in \mathcal{A}^\ag{i}, \ i \in [m] \}$.
Notice \textsc{UncertaintyCheck-DAV}~iterates over all the actions in the set $a^{(1:m)} \in \bar \mathcal{A}^{(1:m)}$ and checks if any of them satisfy $\|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 > \tau$.
This of course achieves the goal of compute independent of $|\mathcal{A}^{(1:m)}|$, since there are only $\sum_{i=1}^m A^\ag{i}$ action vectors in $\bar \mathcal{A}^{(1:m)}$ to iterate over now.
Also, since only $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ that satisfy $\|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 > \tau$ are added to the core set, we can still use \cref{lemma:bound on core set size} to bound the size of the core set by $C_\text{max}$.
Now, we aim to ensure that the VA and MA behave identically in the final loop.
Define the set of states for which all the modified default action vectors are in the good set as $\bar \mathcal{S} = \{ s \in \mathcal{S}: \|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 \le \tau, \forall a^{(1:m)} \in \bar \mathcal{A}^{(1:m)} \}$.
Redefine the VA's $Q$-function as
\begin{equation*}
\tilde Q_{k-1}(s, a^{(1:m)})=\begin{cases}
\tilde w_k^\top \phi(s, a^{(1:m)}) \quad & s \in \bar \mathcal{S} \\
Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)}). \quad & s \in \mathcal{S} \backslash \bar \mathcal{S}
\end{cases}
\end{equation*}
The VA's policy is
\begin{equation*}
\tilde \pi_k(a^{(1:m)} | s) = \mathds{1} \left( a^{(1:m)} = \argmax_{\tilde a^{(1:m)} \in \mathcal{A}^{(1:m)}} \tilde Q_{k-1}(s, \tilde a^{(1:m)}) \right).
\end{equation*}
Notice that in the final loop the check $\phi(s, (a^{(j)}, \bar a^{(-j)}))^\top (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \phi(s, (a^{(j)}, \bar a^{(-j)})) > \tau$ in \textsc{UncertaintyCheck-DAV}~never returns \textsc{True}, and thus we are sure that all $a^{(1:m)} \in \bar \mathcal{A}^{(1:m)}$ for all the states encountered in the final loop are in the good set.
Notice that these states that satisfy this condition are state in $\bar \mathcal{S}$.
Thus, the VA's policy $\pi_{k}$ would always be greedy w.r.t. $\tilde w_k^\top \phi$ in the final loop.
This ensures that the VA and MA behave identically in the final loop.
Now we show that we can bound $\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$ with this new definition of $\tilde Q_{k-1}$.
First we state a slight modification of \cref{lemma: yin lemma b.2} for $w_{\tilde{\pi}_{k-1}}^\top \phi$ instead of $Q_{\tilde{\pi}_{k-1}}$ which excludes the $\|w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})\|_\infty \le \epsilon$ term in the proof of Lemma B.2 in \citep{yin2021efficient}.
\begin{lemma}[Lemma B.2 in \citep{yin2021efficient}]
\label{lemma: yin lemma b.2 no epsilon}
Suppose that \cref{ass: feature decomposition} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
for any $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ pair such that $\phi(s, a^{(1:m)}) \in \mathcal{D}$, we have
$$|\tilde{w}_{k} (s, a^{(1:m)}) - w_{\tilde\pi_{k-1}}^\top (s, a^{(1:m)})| \le b\sqrt{\lambda \tau} + \left(\epsilon + \frac{\gamma^{H-1}}{1 - \gamma} + \theta \right) \sqrt{\tau C_{\text{max}}}:= \bar\eta$$
\end{lemma}
The following Proposition gives us a bound on $\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$.
\begin{proposition}[approximate value function bound for DAV]
\label{prop: approx value function bound for DAV}
Suppose that \cref{ass: feature decomposition} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
we have
$$\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})\|_\infty \le \bar\eta (2m-1) + \epsilon := \eta_1.$$
\end{proposition}
\begin{proof}
For any $(s, a^{(1:m)}) \in (\bar \mathcal{S} \times \mathcal{A}^{(1:m)})$, we have
\begin{align}
& |\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&= |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&= |\tilde{w}_k^\top \phi(s, a^{(1:m)}) \pm w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&\le |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)})| + |w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&\le |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)})| + \epsilon \nonumber \\
&= |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)}) \pm (m-1)\tilde{w}_k^\top \phi(s, \bar a^{(1:m)}) \pm (m-1) w_{\tilde{\pi}_{k-1}}^\top \phi(s, \bar a^{(1:m)})| + \epsilon \nonumber \\
&= \left|\left( \sum_{i=1}^m \tilde{w}_k^\top \phi(s, (a^\ag{i}, \bar a^{(-i)})) - w_{\tilde\pi_{k-1}}^\top \phi(s, (a^\ag{i}, \bar a^{(-i)})) \right) + (m-1)\left[w_{\tilde{\pi}_{k-1}}^\top \phi(s, \bar a^{(1:m)})) - \tilde{w}_k^\top \phi(s, \bar a^{(1:m)}\right]\right| + \epsilon \nonumber \\
&\le m \bar\eta + (m-1) \bar \eta + \epsilon \nonumber \\
&= \bar\eta (2m-1) + \epsilon \label{value function bound 1}
\end{align}
where the second last inequality holds by \cref{lemma: yin lemma b.2 no epsilon} (because the features of all the state action pairs considered are in $\mathcal{D}$, since $s \in \bar \mathcal{S}$).
While for any $(s, a^{(1:m)}) \in ((\mathcal{S} \backslash \bar \mathcal{S}) \times \mathcal{A}^{(1:m)})$, we have
\begin{align}
|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})|
= |Q_{\tilde \pi_{k-1}}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})|
&= 0 \label{value function bound 2}
\end{align}
\end{proof}
Finally, it is left to show that $|\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|$ can be bounded for all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
Notice that lines 4-8 in \textsc{Confident MC-LSPI}~run \textsc{UncertaintyCheck-DAV}~with state $\rho$ as input until the returned status is \textsc{certain}.
Recall that once \textsc{UncertaintyCheck-DAV}~returns a status of \textsc{certain}~we know that $\rho \in \bar \mathcal{S}$.
Thus, we can immediately apply the result in \cref{value function bound 1} to bound $\eta_1 \ge |\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|, \ \forall a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
\subsection{Extending to Politex} \label{subsec:extending to politex}
Recall the above results where for the \textsc{Confident MC-LSPI}~algorithm.
The \textsc{Confident MC-Politex}~algorithm can be found as \cref{alg:confident ma mc-politex}.
\begin{algorithm}[t]
\caption{\textsc{Confident MC-Politex}} \label{alg:confident ma mc-politex}
\begin{algorithmic}[1]
\State \textbf{Input:} initial state $\rho$, initial policy $\pi_0$, number of iterations $K$, threshold $\tau$, number of rollouts $n$, length of rollout $H$
\State \textbf{Globals:} default action $\bar a$, regularization coefficient $\lambda$, discount $\gamma$, subroutine \textsc{UncertaintyCheck}
\State {$\mathcal{C} \gets \{(\rho, \bar a, \phi(\rho, \bar a), \textsc{none})\}$}
\State status, result $\gets \textsc{UncertaintyCheck}(\rho, \mathcal{C}, \tau)$
\While {status $=$ \textsc{uncertain}}
\State $\mathcal{C} \gets \mathcal{C} \cup \{\text{result}\}$
\State status, result $\gets \text{\textsc{UncertaintyCheck}}(\rho, \mathcal{C}, \tau)$
\EndWhile
\State $z_q \gets \textsc{none}, \, \forall z \in \mathcal{C}$ \quad \Comment{Policy iteration starts $(*)$}
\For {$k \in 1, \dots, K$}
\For {$z \in \mathcal{C}$}
\State status, result $\gets \text{\textsc{Rollout}}(n, H, \pi_{k-1}, z, \mathcal{C}, \tau)$
\State \textbf{if} status $=$ \textsc{done}, \textbf{then} $z_q = \text{result}$
\State \textbf{else} $\mathcal{C} \gets \mathcal{C} \cup \{\text{result}\}$ and \textbf{goto} line $(*)$
\EndFor
\State $w_k \gets (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \Phi_\mathcal{C}^\top q_\mathcal{C}$
\State $\pi_k(a^{(1:m)}|s) \gets \propto \prod_{i=1}^m \prod_{j=0}^{k-1} \exp\left(\alpha w_{j}^\top \phi_i(s, a^\ag{i})\right).$
\EndFor
\State \Return $\bar \pi_{K-1} \sim \text{Unif}\{\pi_k\}_{k=0}^{K-1}$
\end{algorithmic}
\end{algorithm}
It turns out the story for \textsc{Confident MC-Politex}~is extremely similar and can be argued in nearly the same way.
The main difference is that the policy used in \textsc{Confident MC-Politex}~is different than in \textsc{Confident MC-LSPI}~(line 17 in \textsc{Confident MC-Politex}~is different from line 17 in \textsc{Confident MC-LSPI}).
As such, we can no longer use \cref{lemma:approximate policy iteration} (since it relied on a greedy policy) and, thus cannot use \cref{prop:optimality of output policy} to bound the sub-optimality of the policy output by \textsc{Confident MC-Politex}.
Next, we show there is a similar Lemma and Proposition that can derived for \textsc{Confident MC-Politex}.
Recall that we do not use clipping on the $Q$-functions in \textsc{Confident MC-Politex}, so that we can sample from the policy efficiently (\cref{prop: efficient politex policy sampling}).
Importantly \cref{prop: efficient politex policy sampling} only holds when \cref{ass: feature decomposition} is satisfied.
Thus, for the remainder of this section we will be working with the product action space $\mathcal{A}^{(1:m)}$.
This means we must define the VA's $Q$-function differently from \citep{yin2021efficient}, by removing clipping from the case when $\phi(s, a^{(1:m)}) \in \mathcal{D}$.
\begin{equation*}
\tilde{Q}_{k-1}(s, a^{(1:m)})=\begin{cases}
\tilde{w}_k^\top \phi(s, a^{(1:m)}) \quad &\text{if} \, \phi(s, a^{(1:m)}) \in \mathcal{D} \\
Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)}) \quad &\text{if} \, \phi(s, a^{(1:m)}) \notin \mathcal{D} \\
\end{cases}
\end{equation*}
Then the VA's policy is
\begin{equation} \label{eq:politex virtual policy}
\tilde \pi_k(a^{(1:m)} | s) \propto \exp \left( \alpha \sum_{j=0}^{k-1} \tilde Q_{j}(s, a^{(1:m)}) \right).
\end{equation}
Also, due to no clipping, the sequence of $Q$-functions during policy iteration is now in the $[-\eta, (1-\gamma)^{-1} + \eta]$ interval, where $\eta \ge \|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$.
We now restate Lemma D.1 from \citet{yin2021efficient} which bounds the mixture policy output by Politex for an arbitrary sequence of $Q$-functions
Since we do not use clipping the theorem is slightly modified (we replace the interval $[0, (1-\gamma)^{-1}]$ with a general interval $[a, b], \ a, b \in \mathbb{R}$, which can be extracted from the calculations in \citet{szepesvari2022}).
\begin{lemma}[modified Lemma D.1 in \citet{yin2021efficient} also in \citet{szepesvari2022}] \label{lemma:politex mixture policy bound}
Given an initial policy $\pi_0$, a sequence of functions $Q_k: \mathcal{S} \times \mathcal{A}^{(1:m)} \to [a, b], \ k \in [K-1], a, b \in \mathbb{R}$, and $Q_{\pi^*} \in [0, 1/(1-\gamma)]$, construct a sequence of policies $\pi_1, ..., \pi_{K-1}$ according to (\cref{eq:politex virtual policy}) with $\alpha = 1/(b-a) \sqrt{\frac{2 \log(|\mathcal{A}^{(1:m)}|)}{K}}$, then, for any $s \in \mathcal{S}$, the mixture policy $\bar \pi_{K-1} \sim \text{Unif}\{\pi_k\}_{k=0}^{K-1}$ satisfies
\begin{equation}
V^*(s) - V_{\bar \pi_K}(s) \le \frac{b-a}{(1-\gamma)}\sqrt{\frac{2 \log(|\mathcal{A}^{(1:m)}|)}{K}} + \frac{2 \max_{0 \le k \le K-1} \|Q_k - Q_{\pi_k}\|_\infty}{1 - \gamma}
\end{equation}
\end{lemma}
Notice that the above result suggests we just need to control the term $\|Q_k - Q_{\pi_k}\|_\infty$.
For the VA this is $\|\tilde Q_k - Q_{\tilde \pi_k}\|_\infty$ and as we have already seen, this can be bounded using the high probability bound on policy evaluation for \textsc{Uncertainty Chcek with DAV} (\cref{prop: approx value function bound for DAV}) and \textsc{Uncertainty Chcek with EGSS} (Proposition \cref{prop: approx value function bound for EGSS}).
Using \cref{lemma:politex mixture policy bound} instead of Lemma D.1 in \citet{yin2021efficient}, one can extract another slightly modified result from \citet{yin2021efficient}.
\begin{proposition}[equation (D.8) in \citet{yin2021efficient}] \label{prop:politex optimality of output policy}
With all terms as defined earlier.
Define $\eta \ge \|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$.
Suppose $\eta \ge |\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|_\infty, \ \forall a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
Then, if the VA and MA behave identically in the final loop, with probability at least $1 - 4KC_{\text{max}}^2 \exp(-2 \theta^2(1-\gamma)^2 n)$ we have
\begin{align}
V^*(s) - V_{\bar \pi_{K-1}}(\rho) \le \frac{b-a}{(1-\gamma)} \sqrt{\frac{2 \log(|\mathcal{A}^{(1:m)}|)}{K}} + \frac{4 \eta}{1 - \gamma}
\end{align}
\end{proposition}
Notice, that we require the same three things as in the \textsc{Confident MC-LSPI}~case (\cref{prop:optimality of output policy}).
We need a bound on $\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$.
We need a bound on $|\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|_\infty, \ \forall a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
We need to ensure that the VA and MA behave identically in the final loop.
Then, we can get a bound on the sub-optimality of the MA's output policy $\bar \pi_{K-1}$.
Using the same steps as in the previous sections, one can verify that indeed, \textsc{Confident MC-Politex}~combined with \textsc{UncertaintyCheck-DAV}~or \textsc{UncertaintyCheck-EGSS}~does satisfy the above three conditions, with $\eta = \eta_1$ ($\eta_1$ as defined in \cref{prop: approx value function bound for DAV}) and $\eta = \eta_2$ ($\eta_2$ as defined in \cref{prop: approx value function bound for EGSS}) respectively.
We bound $|\mathcal{A}^{(1:m)}| = \prod_{i=1}^m |A^\ag{i}| \le \max_{i \in [m]} |\mathcal{A}^\ag{i}|$.
We can replace $b-a$ with $1/(1-\gamma) + 2\eta$, since $w^\top \phi(s, a^{(1:m)}) \in [-\eta, (1-\gamma)^{-1} + \eta], \ \forall (s \times a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ in the final loop for the same event which holds with probability at least $1 - 4KC_{\text{max}}^2 \exp(-2 \theta^2(1-\gamma)^2 n)$ in \cref{prop:politex optimality of output policy}.
Applying \cref{prop:politex optimality of output policy} we get with probability at least $1 - 4KC_{\text{max}}^2 \exp(-2 \theta^2(1-\gamma)^2 n)$ that
\begin{align}
V^*(s) - V_{\bar \pi_{K-1}}(\rho) \le \left(\frac{1}{(1-\gamma)^2} + \frac{2\eta}{(1-\gamma)}\right) \sqrt{\frac{2 m \log(\max_{i \in [m]} |\mathcal{A}^\ag{i}|)}{K}} + \frac{4 \eta}{1 - \gamma}. \label{eq:politex actual optimality of output policy}
\end{align}
\section{\uppercase{Kernel Setting}} \label{app:kernel setting}
Define $q_k(s,a^{(1:m)})$ as the estimated rollout value for $(s,a^{(1:m)}) \in \mathcal{C}$ in round $k \in [K]$ of policy iteration, and $q_k = [q_k(s, a^{(1:m)})]_{(s, a^{(1:m)}) \in \mathcal{C}} \in \mathbb{R}^{|\mathcal{C}|}$ as the vector containing all rollout results at round $k$, using some fixed ordering of $\mathcal{C}$.
In round $k$ of policy iteration we need to compute the ridge estimate $\hat Q_k$ using $q_k$ as least squares targets,
\begin{align}
\hat Q_k = \argmin_{Q \in \mathcal{H}} \sum_{(s,a^{(1:m)})\in\mathcal{C}} (Q(s,a^{(1:m)}) - q_k(s,a^{(1:m)}))^2 + \lambda \|Q\|_{\mathcal{H}}^2 = (\Phi_{\mathcal{C}}^\top\Phi_{\mathcal{C}} + \lambda \mathbf{I}_\mathcal{H})^{-1}\Phi_{\mathcal{C}}^\top q_k
\end{align}
Here, $\mathbf{I}_{\mathcal{H}} : \mathcal{H} \rightarrow \mathcal{H}$ is the identity mapping, $\Phi_{\mathcal{C}}$ can be formally defined as a map $\Phi_\mathcal{C} : \mathcal{H} \rightarrow \mathbb{R}^{|\mathcal{C}|}, f \mapsto [f(s,a^{(1:m)})]_{(s,a^{(1:m)}) \in \mathcal{C}}, \, f \in \mathcal{H}$; and $\Phi_{\mathcal{C}}^\top : \mathbb{R}^{|\mathcal{C}|} \rightarrow \mathcal{H}$ is the adjoint of $\Phi_{\mathcal{C}}$.
Using the `kernel trick' we express the estimator as follows
\begin{align}
\hat Q_k = \Phi_{\mathcal{C}}^\top(K_{\mathcal{C}} + \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}q_k
\end{align}
where $K_{\mathcal{C}} = \Phi_{\mathcal{C}} \Phi_{\mathcal{C}}^\top \in \mathbb{R}^{|\mathcal{C}| \times |\mathcal{C}|}$ is the kernel matrix. Lastly, we can evaluate for any $(s,a^{(1:m)}) \in \mathcal{S} \times \mathcal{A}^{(1:m)}$:
\begin{align}
\hat Q_k(s,a^{(1:m)}) = \mathbf{k}_{\mathcal{C}}(s,a^{(1:m)})^\top(K_{\mathcal{C}} + \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}q_k
\end{align}
where we defined $\mathbf{k}_\mathcal{C}(s,a^{(1:m)}) = [\mathbf{k}(s,a^{(1:m)}, s',a'^{(1:m)})]_{(s',a'^{(1:m)}) \in \mathcal{C}} \in \mathbb{R}^{|\mathcal{C}|}$ (using the same fixed ordering of $\mathcal{C}$).
Importantly, the last display only involves finite-dimensional quantities that can be computed from kernel evaluations.
Moreover, since $\mathbf{k}(s,a^{(1:m)},s',a'^{(1:m)}) = \sum_{j=1}^m \mathbf{k}_j(s,a^{(j)}, s', a'^{(j)})$ we can write
\begin{align}
\hat Q_k(s,a^{(1:m)}) &= \sum_{j=1}^m \hat{Q}_{k, j}(s, a^\ag{j})\\
\hat{Q}_{k, j}(s, a^\ag{j}) &:= \mathbf{k}_{j, \mathcal{C}}(s,a^{(j)})^\top(K_{\mathcal{C}} + \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}q_k
\label{eq:kernel agent-wise q}
\end{align}
where $\mathbf{k}_{j, \mathcal{C}}(s,a^{(j)}) = [\mathbf{k}_j(s,a^{(j)}, s^\prime , a^{\prime(j)})]_{(s^\prime, a^{\prime(1:m)}) \in \mathcal{C}} \in \mathbb{R}^{|\mathcal{C}|}$.
Since the term $(K_{\mathcal{C}} + \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}q_k$ is fixed for each $j$, we can still compute the maximizer independently for each $j \in [m]$ by iterating over all actions.
This allows us to define \textsc{Confident Kernel MC-LSPI/Politex}~(\cref{alg:confident kernel mc-lspi/politex}), which makes use of \cref{eq:kernel agent-wise q} in line 17 for calculating the policy.
\begin{algorithm}[t]
\caption{\textsc{Confident Kernel MC-LSPI/Politex}} \label{alg:confident kernel mc-lspi/politex}
\begin{algorithmic}[1]
\State \textbf{Input:} initial state $\rho$, initial policy $\pi_0$, number of iterations $K$, threshold $\tau$, number of rollouts $n$, length of rollout $H$
\State \textbf{Globals:} default action $\bar a$, regularization coefficient $\lambda$, discount $\gamma$, subroutine \textsc{UncertaintyCheck}, kernel $\mathbf{k}$
\State {$\mathcal{C} \gets \{(\rho, \bar a, \phi(\rho, \bar a), \textsc{none})\}$}
\State status, result $\gets \textsc{UncertaintyCheck}(\rho, \mathcal{C}, \tau)$
\While {status $=$ \textsc{uncertain}}
\State $\mathcal{C} \gets \mathcal{C} \cup \{\text{result}\}$
\State status, result $\gets \text{\textsc{UncertaintyCheck}}(\rho, \mathcal{C}, \tau)$
\EndWhile
\State $z_q \gets \textsc{none}, \, \forall z \in \mathcal{C}$ \quad \Comment{Policy iteration starts $(*)$}
\For {$k \in 1, \dots, K$}
\For {$z \in \mathcal{C}$}
\State status, result $\gets \text{\textsc{Rollout}}(n, H, \pi_{k-1}, z, \mathcal{C}, \tau)$
\State \textbf{if} status $=$ \textsc{done}, \textbf{then} $z_q = \text{result}$
\State \textbf{else} $\mathcal{C} \gets \mathcal{C} \cup \{\text{result}\}$ and \textbf{goto} line $(*)$
\EndFor
\State $\hat Q_k = \Phi_{\mathcal{C}}^\top(K_{\mathcal{C}} + \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}q_k$
\State {$\pi_k(a^{(1:m)}|s) \gets
\begin{cases}
\mathds{1}\left(a^{(1:m)} = \argmax\limits_{\tilde{a}^{(1:m)} \in \mathcal{A}^{(1:m)}} \hat Q_k(s,\tilde{a}^{(1:m)}) \right) & \text{LSPI} \\
\propto \prod_{i=1}^m \prod_{j=0}^{k-1} \exp\left(\alpha \hat{Q}_{j, i}(s, a^\ag{i})\right). & \text{Politex}
\end{cases}$}
\EndFor
\State \Return $\pi_{K-1}$ for LSPI, or $\bar \pi_{K-1} \sim \text{Unif}\{\pi_k\}_{k=0}^{K-1}$ for Politex
\end{algorithmic}
\end{algorithm}
The second quantity required by the algorithm is the squared norm $\|\phi(s,a^{(1:m)})\|_{(\Phi_\mathcal{C}^\top \Phi_{\mathcal{C}} + \lambda \mathbf{I}_\mathcal{H})^{-1}}^2$, where now $\phi(s,a^{(1:m)}) = \mathbf{k}(s,a^{(1:m)}, \cdot, \cdot) \in \mathcal{H}$. A direct extension of the Woodbury formula to infinite vector spaces shows that
\begin{align}
\lambda(\Phi_\mathcal{C}^\top \Phi_{\mathcal{C}} + \lambda \mathbf{I}_\mathcal{H})^{-1} = \mathbf{I}_{\mathcal{H}} - \Phi_{\mathcal{C}}^\top (K_\mathcal{C} + \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}\Phi_{\mathcal{C}}
\end{align}
Therefore the feature norm can be written using finite-dimensional quantities:
\begin{align}
\|\phi(s,a^{(1:m)})\|_{(\Phi_\mathcal{C}^\top \Phi_{\mathcal{C}} + \lambda \mathbf{I}_\mathcal{H})^{-1}}^2 = \frac{1}{\lambda} \left( \mathbf{k}(s,a^{(1:m)},s,a^{(1:m)}) - \mathbf{k}_\mathcal{C}(s,a^{(1:m)})^\top(K_\mathcal{C}+ \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}\mathbf{k}_{\mathcal{C}}(s,a^{(1:m)})\right)
\label{eq:kernel uncertainty}
\end{align}
With this, we can define \textsc{UncertaintyCheck-K-DAV}~(\cref{alg:uncertainty check k-dav}) which makes use of \cref{eq:kernel uncertainty}.
\begin{algorithm}
\caption{\textsc{Uncertainty Check with Kernel-Default Action Vector (K-DAV)}} \label{alg:uncertainty check k-dav}
\begin{algorithmic}[1]
\State \textbf{Input:} state $s$, core set $\Phi_\mathcal{C}$, threshold $\tau$.
\State \textbf{Globals:} number of action components $m$.
\For {$j \in [m]$}
\For {$a^{(j)} \in \mathcal{A}^{(j)}$}
\State $\tilde a \gets (a^\ag{j}, \bar a^\ag{-j})$
\If {$\frac{1}{\lambda} \left( \mathbf{k}(s, \tilde a,s, \tilde a) - \mathbf{k}_\mathcal{C}(s, \tilde a)^\top(\Phi_\mathcal{C} \Phi_\mathcal{C}^\top + \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}\mathbf{k}_{\mathcal{C}}(s, \tilde a)\right) > \tau$}
\State result $\gets (s, \tilde a, \phi(s, \tilde a), \textsc{none})$
\State \Return {\textsc{uncertain}, result}
\EndIf
\EndFor
\EndFor
\State \Return \textsc{certain}, \textsc{none}
\end{algorithmic}
\end{algorithm}
\paragraph{Analysis}
Our goal next is to extend the analysis used in the finite case to the kernel case, carefully arguing that the linear dimension $d$ can be replaced by a more benign quantity. A common complexity measure is the total information gain, which we define as follows:
\begin{align}
\Gamma(\lambda; \mathcal{C}) = \log \det (\Phi_{\mathcal{C}}^\top\Phi_{\mathcal{C}} + \lambda \mathbf{I}_\mathcal{H}) - \log \det (\lambda \mathbf{I}_\mathcal{H})
\end{align}
Note that we can compute $\Gamma(\lambda; \mathcal{C})$ for any given core set $\mathcal{C}$. In the kernel case, we can compute $\Gamma(\lambda; \mathcal{C}) = \log \det (\mathbf{I}_{|\mathcal{C}|} + \lambda^{-1} K_{\mathcal{C}})$ using similar arguments as before.
The maximum information gain is
$$\Gamma_t(\lambda) = \max_{\mathcal{C} : |\mathcal{C}|=t} \Gamma(\lambda; \mathcal{C}).$$
It serves as a complexity measure in the bandit literature and can be bounded for many kernels of interests \citep{srinivas2009gaussian,vakili2021information}.
Following \citet{du2021bilinear, huang2021short}, we further define the \emph{critical information gain} for any fixed constant $c > 0$,
\begin{align}
\tilde \Gamma(\lambda, c) = \max \{t \geq 1 : c t \le \Gamma_t(\lambda) \}.\label{eq:critical infogain}
\end{align}
Note that the proof of \cite[Lemma 5.1]{yin2021efficient} implies that $\log(1+\tau)|C| \leq \Gamma_{|C|}(\lambda)$
Thus, $|\mathcal{C}| \le C_\text{max} = \tilde \Gamma(\lambda, \log(1+\tau)) $
Since the dimension $d$ enters our bounds only through $C_{\max}$ we can immediately get a query complexity bound for the kernelized algorithm in terms of $\tilde\Gamma$.
For the finite-dimensional case, \cite[Lemma 5.1]{yin2021efficient} shows that $\tilde \Gamma \leq \mathcal{O}(d)$, recovering the previous bound.
\section{\uppercase{Proofs of Theorems}} \label{app: theorem proofs}
We make a remark on the query complexity of \textsc{Confident MC-LSPI}~and \textsc{Confident MC-Politex}.
From \cref{lemma:bound on core set size} we know the core set size is bounded by $C_\text{max} = \tilde \mathcal{O}(d)$.
The total number of times Policy iteration is restarted (restart means line 14 in \textsc{Confident MC-LSPI}~or \textsc{Confident MC-Politex}~is reached) is thus at most $C_\text{max}$.
Each run of policy iteration can take as much as $K$ iterations.
In each iteration \textsc{Rollout}~is run at most $C_\text{max}$ times.
\textsc{Rollout}~does $n$ rollouts of length $H$ which queries the simulator once for each step.
In total the number of queries performed by \textsc{Confident MC-LSPI}~or \textsc{Confident MC-Politex} is bounded by $C_\text{max}^2 K n H$.
This equation is used to calculate the query cost for the different variants of \textsc{Confident MC-LSPI}, once all the parameter values have been calculated.
Since, the only difference between \textsc{Confident Kernel MC-LSPI/Politex}~and \textsc{Confident MC-LSPI}~or \textsc{Confident MC-Politex}~is how the policy is calculated (lines 16-17 in each of the algorithms), thus we can use the same expression as above ($C_\text{max}^2 K n H$) to bound the query complexity of \textsc{Confident Kernel MC-LSPI/Politex}~, with $C_\text{max} = \tilde \Gamma(\lambda, c)$.
\subsection{Proof of \cref{thm:mc-lspi-egss sub-optimality}}
Plugging in $\eta=\eta_2$ ($\eta_2$ as defined in \cref{prop: approx value function bound for EGSS}) into \cref{prop:optimality of output policy}.
Suppose \cref{asm:linear-q-pi,ass: argmax oracle,ass: bounded features} are satisfied with $\epsilon=0$.
By choosing appropriate parameters according to $\delta$ and $\kappa$, we can ensure that with probability at least $1 - \delta$ that the policy output by \textsc{Confident MC-LSPI}~combined with \textsc{UncertaintyCheck-EGSS}~, $\pi_{K-1}$ satisfies:
\begin{align*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \kappa,
\end{align*}
with the following parameter settings
\begin{align*}
\tau &= 1\\
\lambda &= \frac{\kappa^2(1 - \gamma)^4}{1024 b^2 d}\\
\theta &= \frac{\kappa(1- \gamma)^2}{32 \sqrt{d} \sqrt{C_{\text{max}}}}\\
H &= \frac{
\log \left ( 32 \sqrt{C_{\text{max}}} \sqrt{d} \right)
- \log \left( \kappa(1 - \gamma)^3 \right)
}{
1-\gamma
} - 1\\
K &= \frac{\log\left(\frac{1}{\kappa(1 - \gamma)^2}\right) + \log(8)}{1-\gamma} + 1 \\
n &= \frac{\log(\delta) - \log(4KC_{\text{max}}^2)}{2 \theta^2(1-\gamma)^2} \\
C_{\max} &= \frac{e}{e-1} \frac{1 + \tau}{\tau} d \left(
\log(1 + \frac{1}{\tau}) +
\log(1 + \frac{1}{\lambda})
\right)
\end{align*}
with computational cost of $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}))$
and query cost $\mathcal{O}\left(\tfrac{d^4}{\kappa^2 (1-\gamma)^8} \right)$
If $\epsilon > 0$, then by choosing parameters as above, with $\kappa = \frac{32 \epsilon d}{(1-\gamma)^2} (1 + \log( b^2 \epsilon^{-2} d^{-1}))^{1/2}$, we can ensure that with probability of at least $1 - \delta$ that $\pi_{K-1}$ satisfies:
$$V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \frac{64 \epsilon d}{(1-\gamma)^2} (1 +\log(1+b^2 \epsilon^{-2} d^{-1}))^{1/2}$$
with computational cost of $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\epsilon}, \log(\frac{1}{\delta}), \log(1+b))$
and query cost $\mathcal{O}\left(\tfrac{d^2}{\epsilon^2 (1-\gamma)^4} \right)$
\subsection{Proof of \cref{thm:mc-lspi-dav sub-optimality}}
Plugging in $\eta=\eta_1$ ($\eta_1$ as defined in \cref{prop: approx value function bound for DAV}) into \cref{prop:optimality of output policy}.
Suppose \cref{ass: feature decomposition,ass: bounded features} are satisfied with $\epsilon=0$.
By choosing appropriate parameters according to $\delta$ and $\kappa$, we can ensure that with probability at least $1 - \delta$ that the policy output by \textsc{Confident MC-LSPI}~combined with \textsc{UncertaintyCheck-EGSS}~, $\pi_{K-1}$ satisfies:
\begin{align*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \kappa,
\end{align*}
with the following parameter settings
\begin{align*}
\tau &= 1\\
\lambda &= \frac{\kappa^2(1 - \gamma)^4}{1024 b^2 (2m-1)^2}\\
\theta &= \frac{\kappa(1- \gamma)^2}{32 (2m-1) \sqrt{C_{\text{max}}}}\\
H &= \frac{
\log \left ( 32 \sqrt{C_{\text{max}}} (2m-1) \right)
- \log \left( \kappa(1 - \gamma)^3 \right)
}{
1-\gamma
} - 1\\
K &= \frac{\log\left(\frac{1}{\kappa(1 - \gamma)^2}\right) + \log(8)}{1-\gamma} + 1 \\
n &= \frac{\log(\delta) - \log(4KC_{\text{max}}^2)}{2 \theta^2(1-\gamma)^2} \\
C_{\max} &= \frac{e}{e-1} \frac{1 + \tau}{\tau} d \left(
\log(1 + \frac{1}{\tau}) +
\log(1 + \frac{1}{\lambda})
\right)
\end{align*}
with computational cost of $\text{poly}(\sum_{i=1}^m |A^\ag{i}|, d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}))$
and query cost $\mathcal{O}\left(\tfrac{m^2 d^3}{\kappa^2 (1-\gamma)^8} \right)$
If $\epsilon > 0$, then by choosing parameters as above, with $\kappa = \frac{32 \epsilon \sqrt{d} m}{(1-\gamma)^2} (1 + \log( b^2 \epsilon^{-2} d^{-1}))^{1/2}$, we can ensure that with probability of at least $1 - \delta$ that $\pi_{K-1}$ satisfies:
$$V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \frac{128 \epsilon \sqrt{d} m}{(1-\gamma)^2} (1 +\log(1+b^2 \epsilon^{-2} d^{-1}))^{1/2}$$
with computational cost of $\text{poly}(\sum_{i=1}^m |A^\ag{i}|, d, \frac{1}{1 - \gamma}, \frac{1}{\epsilon}, \log(\frac{1}{\delta}), \log(1+b))$
and query cost $\mathcal{O}\left(\tfrac{d^2}{\epsilon^2 (1-\gamma)^4} \right)$
\subsection{Proof of \cref{thm:mc-politex sub-optimality} + \textsc{UncertaintyCheck-EGSS}~case}
Plugging in $\eta=\eta_1$ when \textsc{UncertaintyCheck-DAV}~is used ($\eta_1$ as defined in \cref{prop: approx value function bound for DAV}) and $\eta=\eta_2$ when \textsc{UncertaintyCheck-EGSS}~is used ($\eta_2$ as defined in \cref{prop: approx value function bound for EGSS}) into \cref{eq:politex actual optimality of output policy}.
Setting $\zeta=2m-1$ when \textsc{UncertaintyCheck-DAV}~is used, and $\zeta = \sqrt{d}$ when \textsc{UncertaintyCheck-EGSS}~is used.
Suppose \cref{ass: feature decomposition,ass: bounded features} are satisfied with $\epsilon=0$.
By choosing appropriate parameters according to $\delta$ and $\kappa$, we can ensure that with probability at least $1 - \delta$ that the policy output by \textsc{Confident MC-Politex}~$\bar \pi_{K-1}$ satisfies:
\begin{align*}
V^*(\rho) - V_{\bar \pi_{K-1}}(\rho) \leq \kappa,
\end{align*}
with the following parameter settings
\begin{align*}
\tau &= 1\\
\lambda &= \frac{\kappa^2(1 - \gamma)^2}{576 b^2 \zeta^2}\\
\theta &= \frac{\kappa(1- \gamma)}{24 \zeta \sqrt{C_{\text{max}}}}\\
H &= \frac{
\log \left ( 24 \sqrt{C_{\text{max}}} \zeta \right)
- \log \left( \kappa(1 - \gamma)^2 \right)
}{
1-\gamma
} - 1\\
K &= 2m \log(A) \left( \frac{4}{\kappa^2 (1-\gamma)^4} + \frac{3}{\kappa (1-\gamma)^2} + \frac{9}{16} \right)\\
n &= \frac{\log(\delta) - \log(4KC_{\text{max}}^2)}{2 \theta^2(1-\gamma)^2} \\
C_{\max} &= \frac{e}{e-1} \frac{1 + \tau}{\tau} d \left(
\log(1 + \frac{1}{\tau}) +
\log(1 + \frac{1}{\lambda})
\right)
\end{align*}
with computational cost of $\text{poly}(\sum_{i=1}^m |A^\ag{i}|, d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}))$
and query cost $\mathcal{O}\left(\tfrac{m \zeta^2 d^3}{\kappa^4 (1-\gamma)^9} \right)$
If $\epsilon > 0$, then by choosing parameters as above, with $\kappa = \frac{16 \epsilon \sqrt{d} \zeta}{(1-\gamma)} (1 + \log( b^2 \epsilon^{-2} d^{-1}))^{1/2}$, we can ensure that with probability of at least $1 - \delta$ that $\bar \pi_{K-1}$ satisfies:
$$V^*(\rho) - V_{\bar \pi_{K-1}}(\rho) \leq \frac{32 \epsilon \sqrt{d} \zeta}{1-\gamma} (1 +\log(1+ b^2 \epsilon^{-2} d^{-1}))^{1/2}$$
with computational cost of $\text{poly}(\sum_{i=1}^m |A^\ag{i}|, d, \frac{1}{1 - \gamma}, \frac{1}{\epsilon}, \log(\frac{1}{\delta}), \log(1+b))$
and query cost $\mathcal{O}\left(\tfrac{m d}{\epsilon^4 (1-\gamma)^5} \right)$
\subsection{Proof of \cref{thm:kernel mc-lspi-dav sub-optimality}}
Plugging in $\eta=\eta_1$ ($\eta_1$ as defined in \cref{prop: approx value function bound for DAV}) into \cref{prop:optimality of output policy}.
Suppose \cref{ass: bounded features,ass:kernel q-pi,ass:kernel additive} are satisfied with $\epsilon=0$.
By choosing appropriate parameters according to $\delta$ and $\kappa$, we can ensure that with probability at least $1 - \delta$ that the policy output by \textsc{Confident Kernel MC-LSPI} $\pi_{K-1}$ satisfies:
\begin{align*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \kappa,
\end{align*}
with the following parameter settings
\begin{align*}
\tau &= 1\\
\lambda &= \frac{\kappa^2(1 - \gamma)^4}{1024 b^2 (2m-1)^2}\\
\theta &= \frac{\kappa(1- \gamma)^2}{32 (2m-1) \sqrt{C_{\text{max}}}}\\
H &= \frac{
\log \left ( 32 \sqrt{C_{\text{max}}} (2m-1) \right)
- \log \left( \kappa(1 - \gamma)^3 \right)
}{
1-\gamma
} - 1\\
K &= \frac{\log\left(\frac{1}{\kappa(1 - \gamma)^2}\right) + \log(8)}{1-\gamma} + 1 \\
n &= \frac{\log(\delta) - \log(4KC_{\text{max}}^2)}{2 \theta^2(1-\gamma)^2} \\
C_{\max} &= \tilde \Gamma(\lambda, \log(2))
\end{align*}
with computational cost of $\text{poly}(\sum_{i=1}^m |A^\ag{i}|, \tilde \Gamma(\lambda, \log(2)), \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}))$
and query cost $\mathcal{O}\left(\tfrac{m^2 \tilde \Gamma(\lambda, \log(2))^3}{\kappa^2 (1-\gamma)^8} \right)$
If $\epsilon > 0$, then by choosing parameters as above, with $\kappa = \frac{16 \epsilon m \sqrt{\tilde \Gamma(\lambda, \log(2))}}{(1-\gamma)^2}$, we can ensure that with probability of at least $1 - \delta$ that $\pi_{K-1}$ satisfies:
$$V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \frac{32 \epsilon m \sqrt{\tilde \Gamma(\lambda, \log(2))}}{(1-\gamma)^2}$$
with computational cost of $\text{poly}(\sum_{i=1}^m |A^\ag{i}|, \tilde \Gamma(\lambda, \log(2)), \frac{1}{1 - \gamma}, \frac{1}{\epsilon}, \log(\frac{1}{\delta}), \log(1+b))$
and query cost $\mathcal{O}\left(\tfrac{\tilde \Gamma(\lambda, \log(2))^2}{\epsilon^2 (1-\gamma)^4} \right)$
\paragraph{Theroem for \textsc{Confident Kernel MC-Politex}~combined with \textsc{UncertaintyCheck-DAV}}
As mentioned in the body we state the theorem bounding the sub-optimality of the policy output by \textsc{Confident Kernel MC-Politex}~combined with \textsc{UncertaintyCheck-K-DAV}.
\begin{theorem}[\textsc{Confident Kernel MC-Politex DAV} Sub-Optimality] \label{thm:kernel mc-politex-dav sub-optimality}
Suppose Assumption \cref{ass:kernel q-pi,ass:kernel additive,ass: bounded features} hold.
Define $\tilde \Gamma := \tilde \Gamma(\lambda, \log(2))$.
If $\epsilon = 0$, for any $\kappa > 0$, with probability at least $1 - \delta$, the policy $\bar \pi_{K-1}$, output by \textsc{Confident Kernel MC-Politex}~combined with \textsc{UncertaintyCheck-K-DAV}~satisfies
\begin{equation*}
V^*(\rho) - V_{\bar \pi_{K-1}}(\rho) \leq \kappa.
\end{equation*}
Further, the query cost is $\mathcal{O}\left(\tfrac{m^3\tilde \Gamma^3}{\kappa^4 (1-\gamma)^9} \right)$
and computation cost is $\text{poly}(\sum_{i=1}^m |A^\ag{i}|, \tilde \Gamma, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}))$
If $\epsilon > 0$, then with probability at least $1 - \delta$, the policy $\bar \pi_{K-1}$, output satisfies
\begin{equation*}
V^*(\rho) - V_{\bar \pi_{K-1}}(\rho) \leq \frac{16 \epsilon m \sqrt{\tilde \Gamma}}{1-\gamma}
\end{equation*}
Further, the query cost is $\mathcal{O}\left(\tfrac{m \tilde \Gamma}{\epsilon^4 (1-\gamma)^5} \right)$
and computation cost is $\text{poly}(\sum_{i=1}^m |A^\ag{i}|, \tilde \Gamma, \frac{1}{1 - \gamma}, \frac{1}{\epsilon}, \log(\frac{1}{\delta}), \log(1+b))$
The parameter settings for both cases are defined below.
\end{theorem}
\subsection{Proof of \cref{thm:kernel mc-politex-dav sub-optimality}}
Plugging in $\eta=\eta_1$ ($\eta_1$ as defined in \cref{prop: approx value function bound for DAV}) into \cref{eq:politex actual optimality of output policy}.
Suppose \cref{ass:kernel additive,ass:kernel q-pi,ass: bounded features} are satisfied with $\epsilon=0$.
By choosing appropriate parameters according to $\delta$ and $\kappa$, we can ensure that with probability at least $1 - \delta$ that the policy output by \textsc{Confident Kernel MC-Politex}~combined with \textsc{UncertaintyCheck-K-DAV}~, $\bar \pi_{K-1}$ satisfies:
\begin{align*}
V^*(\rho) - V_{\bar \pi_{K-1}}(\rho) \leq \kappa,
\end{align*}
with the following parameter settings
\begin{align*}
\tau &= 1\\
\lambda &= \frac{\kappa^2(1 - \gamma)^2}{576 b^2 (2m-1)^2}\\
\theta &= \frac{\kappa(1- \gamma)}{24 (2m-1) \sqrt{C_{\text{max}}}}\\
H &= \frac{
\log \left ( 24 \sqrt{C_{\text{max}}} (2m-1) \right)
- \log \left( \kappa(1 - \gamma)^2 \right)
}{
1-\gamma
} - 1\\
K &= 2m \log(A) \left( \frac{4}{\kappa^2 (1-\gamma)^4} + \frac{3}{\kappa (1-\gamma)^2} + \frac{9}{16} \right)\\
n &= \frac{\log(\delta) - \log(4KC_{\text{max}}^2)}{2 \theta^2(1-\gamma)^2} \\
C_{\max} &= \tilde \Gamma(\lambda, \log(2))
\end{align*}
with computational cost of $\text{poly}(\sum_{i=1}^m |A^\ag{i}|, \tilde \Gamma(\lambda, \log(2)), \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}))$
and query cost $\mathcal{O}\left(\tfrac{m^3 \tilde \Gamma(\lambda, \log(2))^3}{\kappa^4 (1-\gamma)^9} \right)$
If $\epsilon > 0$, then by choosing parameters as above, with $\kappa = \frac{8 \epsilon m \sqrt{\tilde \Gamma(\lambda, \log(2))}}{(1-\gamma)} $, we can ensure that with probability of at least $1 - \delta$ that $\bar \pi_{K-1}$ satisfies:
$$V^*(\rho) - V_{\bar \pi_{K-1}}(\rho) \leq \frac{16 \epsilon m \sqrt{\tilde \Gamma(\lambda, \log(2))}}{1-\gamma}$$
with computational cost of $\text{poly}(\sum_{i=1}^m |A^\ag{i}|, \tilde \Gamma(\lambda, \log(2)), \frac{1}{1 - \gamma}, \frac{1}{\epsilon}, \log(\frac{1}{\delta}), \log(1+ b))$
and query cost $\mathcal{O}\left(\tfrac{m \tilde \Gamma(\lambda, \log(2))}{\epsilon^4 (1-\gamma)^5} \right)$
\section{\uppercase{Examples and Experiments}}\label{app:additive mdp example}
\begin{figure}[h]
\begin{center}
\begin{tikzpicture}[auto,node distance=8mm,>=latex,font=\small]
\tikzstyle{round}=[thick,draw=black,circle]
\node[round] (s1) {$s_1$};
\node[round, right=0mm and 20mm of s1] (s2) {$s_2$};
\node[round, left=0mm and 20mm of s1] (s3) {$s_3$};
\draw[->] (s1) [out=0,in=180] to node {
\tiny $\phi(s_1,(1,1))=\begin{bmatrix} 1 \\ 0 \\
\end{bmatrix}$
} node [swap] {
\tiny $\phi(s_1,(1,0))=\begin{bmatrix} 1 \\ 0 \\
\end{bmatrix}$
} node [anchor=mid, fill=white!20] {\tiny r = 0} (s2);
\draw[->] (s1) [out=180,in=0] to node {
\tiny $\phi(s_1,(0,0))=\begin{bmatrix} 0 \\ 1 \\
\end{bmatrix}$
} node [swap] {
\tiny $\phi(s_1,(0,1))=\begin{bmatrix} 0 \\ 1 \\
\end{bmatrix}$
} node [anchor=mid, fill=white!20] {\tiny r = 0} (s3);
\draw[->] (s2) [out=60,in=120,loop] to node {\tiny r = 0} node [swap] { \tiny
$\phi(s_2,(1,0))=\phi(s_2,(0,0))=\begin{bmatrix} 1 \\ 0 \\
\end{bmatrix}$
}(s2);
\draw[->] (s2) [out=-60,in=-120,loop] to node { \tiny
$\phi(s_2,(0,1))=\phi(s_2,(1,1))=\begin{bmatrix} 2 \\ 0 \\
\end{bmatrix}$
} node [swap] {\tiny r = 1} (s2);
\draw[->] (s3) [out=60,in=120,loop] to node {\tiny r = 1} node [swap] { \tiny
$\phi(s_3,(1,0))=\phi(s_3,(0,0))=\begin{bmatrix} 0 \\ 2 \\
\end{bmatrix}$
}(s3);
\draw[->] (s3) [out=-60,in=-120,loop] to node { \tiny
$\phi(s_3,(0,1))=\phi(s_3,(1,1))= \begin{bmatrix} 0 \\ 1 \\
\end{bmatrix}$
} node [swap] {\tiny r = 0} (s3);
\end{tikzpicture}
\end{center}
\caption{Illustration of \cref{ex:ski}.}\label{fig:coordination-example}
\end{figure}
\subsection{Additive MDP, Cooperation Example}
\begin{example}[Coordination]\label{ex:ski}
Consider the MDP in \cref{fig:coordination-example}, which can be verified to satisfy \cref{ass: feature decomposition} with $\gamma = 1/2$ (proof in the next subsection).
At every time step, two agents in the MDP take actions from $\mathcal{A}^{(1)}= \mathcal{A}^{(2)} = \{0, 1\}$, and move to a next state together.
The starting state is $s_1$ and by taking a joint action they move to $s_2$ or $s_3$, which
are absorbing states and the agents will remain in them once they get there.
It is easy to see that if we fix the policy for one of the agents in all states, the other agent will face a reduced MDP where the transitions only depends on the its actions.
We will show that for two different policies followed by the second agent,
the problem (the MDP) the first agent faces changes.
More specifically, the best action for the first agent in $s_1$ is different in the resulting MDPs, which suggests that
the first agent should coordinate
with the second agent to achieve a higher value.
It also shows that this example cannot be reduced to a product MDP, since in product MDPs the best action for each agent is irrespective of the behavior of the other agents.
Assume two different policies $\pi_0, \pi_1: \mathcal{S} \rightarrow \Delta_{\mathcal{A}^{(2)}}$ for the second agent,
such that $\pi_0(s_i) = \delta_0 , \pi_1(s_i) = \delta_1$ for $i \in [3]$ where $\delta_j$ for $j \in [2]$ is the Dirac delta distribution.
Policy $\pi_0$ causes the joint policy $\pi$ to get reward 1 in $s_3$ and get reward 0 in $s_2$, regardless of the policy followed by the first agent.
The effect of following $\pi_1$ is exactly the opposite, meaning getting reward 1 in $s_2$ and 0 in $s_3$.
Consequently, the optimal action for agent 1 depends on choosing $\pi_0$ or $\pi_1$ by the second agent.
Therefore, agent 1 needs to coordinate its action with the second agent's policy to get the higher reward.
This property, coordination with other agent's policy, cannot be modeled with separate MDPs
since in those cases the optimal action for each agent only depends on the agent's MDP, and does not depend
on the behavior of other agents.
This example shows that the \cref{ass: feature decomposition} is not limited
to solving multiple MDPs with joint reward observation, and can model some cases where cooperation is needed.\looseness=-1
\end{example}
\subsubsection*{Realizability}
In this section we prove that the MDP in \cref{fig:coordination-example} satisfies \cref{ass: feature decomposition}.
We start by showing that all the deterministic policies are realizable using the shown feature vectors.
We use the weight vector
$w_{(a_1^1,a_1^2),(a_2^1,a_2^2),(a_3^1,a_3^2)}$
for a deterministic policy
that takes action vector $(a^1_i, a^2_i)$ in state $s_i$ for $i \in \{1, 2, 3\}$ and $a^1_i, a^2_i \in \{0,1\}$. We also use $\cdot$ to show that the choice of an action in the respective state does not change the weight vector.
One can verify that the following vectors satisfy realizability assumption:
\begin{align*}
w_{(\cdot, \cdot),(\cdot, 0),(\cdot, 0)} = \begin{bmatrix} 0 \\ 1 \end{bmatrix},
\quad \quad
w_{(\cdot, \cdot),(\cdot, 0),(\cdot, 1)} = \begin{bmatrix} 0 \\ 0 \end{bmatrix},
\\
w_{(\cdot, \cdot),(\cdot, 1),(\cdot, 0)} = \begin{bmatrix} 1 \\ 1 \end{bmatrix},
\quad \quad
w_{(\cdot, \cdot),(\cdot, 1),(\cdot, 1)} = \begin{bmatrix} 1 \\ 0 \end{bmatrix}.
\end{align*}
It remains to show that the non-deterministic policies are also realizable.
For a policy $\pi$ that takes action $(\cdot, 1)$ at $s_2$ with probability $p_2$, and action $(\cdot, 0)$ at $s_3$ with probability $p_3$, the realizable weight vector is:
\[
w_\pi = \begin{bmatrix}
p_2\\
p_3\\
\end{bmatrix}.
\]
This holds since the choice of the action in $s_1$ does not change the weight vector in this example.
\input{parts/experiment.tex}
\section{\uppercase{Conclusion}} \label{sec:discussion}
In this work, we considered the problem of planning with a local access simulator when the action space is combinatorially large.
We introduced several algorithms that achieve polynomial computational and query complexity guarantees, while still maintaining a reasonable sub-optimality of the output policy under various assumptions. The main novelty is an efficient implementation of the uncertainty check under the mild assumption of having access to a greedy oracle. If the $Q$-functions for all policies satisfy an additive structure we provide nuanced results that show how the sample complexity can be improved in the regime where the dimension is large. Under the same additive structure our results also extend to the kernelized setting. An interesting direction for future work is to extend the results to the Factored MDP model \citep{guestrin2001multiagent} or the Confident LSVI algorithm \citep{hao2022confident}.
\subsection{Experimental Results}
\begin{wrapfigure}{r}{0.3\textwidth}
\begin{center}
\includegraphics[width=0.3\textwidth]{plots/grid.pdf}
\end{center}
\caption{Four agent grid world.}\label{fig:grid}
\end{wrapfigure}
We evaluate the performance of the proposed algorithms in a small grid world example as shown in \cref{fig:grid}.
Each of four agents is placed in a 3x3 grid world.
The agents obtain a +1 reward for reaching the goal state and a -1 reward in a `trap' state.
Reaching either the trap state or the reward state terminates the episode.
Each agent has four actions to move to a neighboring cell.
The selected action is applied with probability 0.95 while with 0.05 probability an action is chosen uniformly at random.
The global reward is the sum of the agents rewards.
Note that the individual rewards are not observed, therefore the example is different from four separate grid worlds.
We run each variant of the algorithm for 50 iterations ($K=50$) without resets (the resets are mainly for simplicity of analysis).
The discount factor is set to $\gamma = 0.8$, the regularization parameter is set to $\lambda = 10^{-5}$, for Politex we set $\alpha=1$ and the rollout length is $H=15$.
The agents' individual features are one-hot encodings of agent, agent positions and actions which results in a feature of dimension $d=4 \cdot 9 \cdot 4 = 144$.
Note, however, that the joint MDP is \emph{not} tabular, as the joint features,~i.e. the sum over the agent features, are not one-hot vectors.
In fact, the features are crucial for generalization as there are a total $9^4 = 9561$ joint states for all four agents combined.
\Cref{fig:exp} shows two experiments with $n=10$ and $n=50$ rollouts.
The plots show the performance of the policy estimate after each iteration averaged over 25 random seeds.
We run both \textsc{Confident MC-LSPI}~and \textsc{Confident MC-Politex}~with \textsc{EGSS}~(\cref{alg:uncertainty check egss}) and \textsc{DAV}~(\cref{alg:uncertainty check dav}) uncertainty checks.
In addition we compare to the \textsc{NAIVE}~uncertainty check (\cref{alg:uncertainty check}) that iterates over all $|A| = 4^4$ actions \citep{yin2021efficient}.
Note that with 50 rollouts, both the \textsc{EGSS}~and \textsc{DAV}~variants perform essentially the same as \textsc{NAIVE}, despite the relaxed uncertainty bound.
LSPI finds a good policy within at most five iterations.
With only 10 rollouts, the final policy of \textsc{Confident MC-LSPI}~ converges to a suboptimal value on average. This can be understood as the data between iterations is not shared, and the noise from the Monte-Carlo estimates sometimes leads to a deteriorating in the policy improvement step. With 50 rollouts per iteration, LSPI reliably finds the optimal policy in all MDPs.
On the other hand, \textsc{Confident MC-Politex}~is much more stable even with just 10 rollouts, but also requires more iterations to converge.
This is expected because in \textsc{Confident MC-Politex},~the policy estimates from all iterations are averaged.
\begin{figure}[t]
\includegraphics{plots/3x3-aistats.pdf}
\caption{Numerical results on a grid world with four agents.}\label{fig:exp}
\end{figure}
\section{Experiments} \label{sec:experiments}
In this section we present experiments on a cooperative multi-agent cliff-walking experiment.
We results contain algorithms: MCLSPI-EGSS, MCLSPI-DAV, Politex-EGSS, Politex-DAV
\section{Extensions}\todoj{put this here for now but this can potentially go elsewhere}
\subsection{Argmax Oracle}
\subsection{Kernelized Algorithm}
Add all the new notation for kernel setting and state the theorem.
Kernel proofs are in Appendix \ref{app:kernel setting} \todoj{if we keep it we just refer to the appendix}
\section{\uppercase{Introduction}} \label{sec: introduction}
Reinforcement learning (RL) is concerned with training data-driven agents to make optimal decisions in interactive environments.
An agent interacts with an environment by choosing actions and observing its state and a reward signal.
The goal is to learn an optimal policy that maximizes the total reward.
Efficiently computing optimal policies, also known as \emph{planning}, is therefore at the heart of any reinforcement learning algorithm.
Recent works have successfully applied reinforcement learning algorithms to complex domains including video games \citep{mnih2013playing}, tokamak plasmas control \citep{degrave2022magnetic}, robotic manipulation tasks \citep{akkaya2019solving}, to name a few. A common theme of these works is that the agent is trained on a simulated environment. This provides additional flexibility on how the agent can interact with the environment. A reasonable assumption is that the internal state of the simulator can be saved (`checkpointing') and later revisited.
\looseness=-1
In this work, we formally study \emph{efficient planning with local access to a simulator}. The local access model was recently proposed by \citet{yin2021efficient} with the goal of making the simulation access model more practical in applications. Local access means that the only states at which the planner can query the simulator are the initial state or states returned in response to previously issued queries. Efficient planning means that given an initial state, the learner outputs a near-optimal policy using polynomial compute and queries in all relevant parameters.
\input{parts/table}
Motivated by the increasing complexity of applications, we specifically study the case where the state space is large or continuous.
To avoid the query complexity scaling with the size of the state space, it is standard to introduce linear function approximation \citep[e.g.,][]{bertsekas1996temporal,lagoudakis2003least,munos2005error,lattimore2020learning}.
In particular, we assume linear $\epsilon$-realizability of joint state-action value functions for \emph{all} policies.
This is motivated by the recent realization that realizability of the optimal state-action value function alone is not sufficient to develop a query-efficient planner~\citep{weisz2021exponential}.
However, even under stronger realizability assumptions, previous approaches are not computationally efficient in the case where the action space is \emph{combinatorially large}, and direct enumeration of the action space becomes infeasible.
Therefore, we work with a minimal oracle assumption that allows us to compute the greedy policy for any Q-function in the model class (which amounts to solving a linear optimization over the feature space).
One prominent special case of this setting is multi-agent reinforcement learning.
Multi-agent reinforcement learning has been a recent research focus with multiple promising attempts at tackling complex multi-agent problems, e.g., team games \citep{baker2019emergent}, large scale traffic signal control \citep{chu2019multi}, cooperative controls in powergrids \citep{chen2021powernet} among others.
Naively applying single-agent planning algorithms fails to achieve efficiency in the multi-agent setting because the single-agent algorithms typically face an exponential blow-up of the action space in the number agents.
In many practical tasks, however, there is an inherent structure in the underlying dynamics that can be exploited to address both efficiency and scalability issues. \looseness=-1
\paragraph{Contributions} Our first contribution is a novel oracle-efficient variant of the Confident Monte-Carlo least-squares policy iteration (\textsc{Confident MC-LSPI}) algorithm by \citet{yin2021efficient}, for combinatorially large action spaces.
The key insight is an efficient implementation of the \emph{uncertainty check}, that determines the diversity of the state and action set used for estimation.
We also study a special case where the Q-function has an additive structure in the features (formally introduced in \Cref{ass: feature decomposition}), which leads to improved bounds in the regime where the dimension is large.
In the multi-agent setting, the decomposition corresponds to agent-specific features, and the proposed algorithms achieve polynomial compute and query complexity in the number of agents and other quantities of interest.
We further introduce a kernelized variant, which under the corresponding additivity assumption admits an efficient implementation.
Lastly, the additive structure leads to an efficient implementation of the \textsc{Confident MC-Politex} algorithm that admits improved bounds in the misspecified setting.
The formal results are summarized in \cref{table:2}.\looseness=-1
\section{\uppercase{Preliminaries}} \label{sec:preliminaries}
We consider reinforcement learning in an infinite-horizon Markov decision process (MDP) specified by a tuple $\mathcal{M} = \left(\mathcal{S}, \mathcal{A}, \mathbb{P}, r, \gamma\right)$.
As usual, $\mathcal{S}$ denotes the state space, $\mathcal{A}$ denotes the action space, and
$\mathbb{P} : \mathcal{S} \times \mathcal{A} \rightarrow \Delta_{\mathcal{S}}$ is the transition kernel, where $\Delta_{\mathcal{S}}$ denotes the set of probability measures over $\mathcal{S}$.
Given a state $s \in \mathcal{S}$ and action vector $a \in \mathcal{A}$, the system transits to a new state $s' \sim \mathbb{P}(s, a)$. The reward function is
$r : \mathcal{S} \times \mathcal{A} \rightarrow [0, 1]$ and
$\gamma \in [0, 1)$ is the discount factor.\looseness=-1
A stationary policy $\pi :\mathcal{S} \rightarrow \Delta_\mathcal{A}$ maps states to a distribution over $\mathcal{A}$.
The state value function $V_\pi: \mathcal{S} \to \mathbb{R}$ of a policy $\pi$ from a state {$s \in \mathcal{S}$} is
\begin{align*}
V_\pi(s) = \mathbb{E}_{\pi}\Bigg[\sum_{t=0}^\infty \gamma^t r(s_t, a_t)\Big|s_0 = s\Bigg] \,.
\end{align*}
The expectation is over the sequence of states $(s_t)_{t \in \mathbb{N}}$ and actions $(a_t)_{t \in \mathbb{N}}$ queried from the transition kernel $\mathbb{P}$ and the policy $\pi$.
A policy $\pi^*$ is \emph{optimal} if $V_{\pi^*} = \max_{\pi} V_{\pi}$.
The Q-function $Q_\pi: \mathcal{S} \times \mathcal{A} \to \mathbb{R}$ of a policy $\pi$
is defined for $s \in \mathcal{S}$ and $a \in \mathcal{A}$ as
\begin{align*}
Q_{\pi}(s,a) = r(s,a) + \gamma \mathbb{E}_{s' \sim \mathbb{P}(s,a)}\left[V_{\pi}(s')\right].
\end{align*}
In the following we assume that we are given a state-action feature map $\phi: \mathcal{S} \times \mathcal{A} \to \mathbb{R}^d$, that allows to approximate the $Q$-function of any policy as a linear function.\looseness=-1
\begin{assumption}[Linear $Q_\pi$-realizability]
\label{asm:linear-q-pi}
For each policy $\pi$ there exists a weight vector $w_\pi \in \mathbb{R}^d, \|w_\pi\|_2 \leq b $ satisfying $\max_{s,a} |Q_\pi(s,a) -w_\pi^\top \phi(s,a)| \le \epsilon$.
\end{assumption}
The assumption is commonly used in combination with policy iteration algorithms \citep{lattimore2020learning,zanette2020learning}. In particular, the assumption allows to obtain query complexity results that are independent of the number of states and actions. We remark that the linear MDP assumption \citep{jin2020provably} implies $Q_\pi$-realizability, but not vice versa. We also make the following standard boundedness assumption:
\begin{assumption}[Bounded features]
\label{ass: bounded features}
We assume that $\|\phi(s, a)\|_2 \le 1$ for all $(s, a) \in \mathcal{S} \times \mathcal{A}$.
\end{assumption}
Our main objective is to obtain query and computationally efficient algorithms for the case where the action set $\mathcal{A}$ is \emph{combinatorially} large, and direct enumeration becomes infeasible. To obtain meaningful results in this setting, we assume that the \emph{offline problem} of computing the greedy policy given a \emph{fixed} approximator $w \in \mathbb{R}^d$ can be solved efficiently. This is formally captured in the next assumption.\looseness=-1
\begin{assumption}[Greedy oracle]
\label{ass: argmax oracle}
We have access to an oracle $\mathcal{G}$ which takes as input a vector $w \in \mathbb{R}^d$, a state $s \in \mathcal{S}$ and a feature function $\phi: \mathcal{S} \times \mathcal{A} \to \mathbb{R}^d$ and returns an action that maximizes $w^\top \phi(s, a)$.
Formally
\begin{align*}
\mathcal{G}(w,\phi) = \argmax_{a \in \mathcal{A}} w^\top \phi(s, a)\,,
\end{align*}
with ties broken arbitrarily.
\end{assumption}
Combined with the linear $Q_\pi$-realizability (\cref{asm:linear-q-pi}), the greedy oracle amounts to solving a \emph{linear} optimization over the action set $\mathcal{A}$. This is a reasonable assumption, as optimized solvers are available for many settings. It is also a \emph{minimal} assumption in the sense that it is required to implement a policy iteration procedure. Note that the assumption can be relaxed to require only an $\epsilon$-approximate solution, which is essentially equivalent to misspecification (\cref{asm:linear-q-pi}). In \cref{sec:additive} we provide an additive model where the oracle can be directly implemented.
Our goal is to find a computational and query efficient algorithm that given a starting state $\rho \in \mathcal{S}$ returns a $\kappa$-optimal policy $\hat \pi$, i.e.~$V_{\pi^*}(\rho) - V_{\hat \pi}(\rho) \leq \kappa$ for $\kappa > 0$ while minimizing the number of queries needed.
To obtain queries, the learner is given \emph{local access} to a simulator of the MDP \citep{yin2021efficient}.
A simulator of the MDP takes as input a state-action pair $(s,a) \in \mathcal{S} \times \mathcal{A}$ and returns a next state $s^\prime \sim \mathbb{P}(s, a)$ and reward $r(s,a)$.
A local access simulator restricts the input state $s \in \mathcal{S}$ only to those states which have been visited previously.
An important example where the action set is typically large is cooperative multi-agent reinforcement learning.
\begin{example}[Cooperative multi-agent RL] \label{ex:multi-agent} In the multi-agent setting, $m \in \mathbb{N}$ agents act jointly on the MDP $\mathcal{M}$.
Each agent $i \in [m]$ has a set of actions $\mathcal{A}^\ag{i}$ available where $[m] := \{1,\dots,m\}$.
We denote the joint action set by $\mathcal{A} = \mathcal{A}^{(1:m)} := \mathcal{A}^{(1)} \times ... \times \mathcal{A}^{(m)}$.
The state space $\mathcal{S}$ is joint for all agents.
A centralized, stationary policy $\pi :\mathcal{S} \rightarrow \Delta_{\mathcal{A}^{(1:m)}}$ maps states to a distribution over $\mathcal{A}^{(1:m)}$. In the \emph{cooperative} setting, the agents jointly maximize a global reward function $r : \mathcal{S} \times \mathcal{A}^{(1:m)} \rightarrow [0, 1]$.
\end{example}
Note that the size of the joint action set is exponential in the number of agents, which makes approaches designed for the single agent setting computationally intractable. We will revisit this example in \cref{sec:additive} where we discuss how an additive feature decomposition leads to algorithms that scale polynomially in the number of agents $m$. We remark that prior work on multi-agent RL has focused on architectures where the greedy policy can be computed efficiently \citep[e.g.,][]{guestrin2001multiagent,rashid2018qmix,delarue2020reinforcement,zohar2021locality}. \looseness=-1
\section{\uppercase{Related Work}} \label{sec:related work}
Computing optimal policies, also known as \emph{planning}, is a central challenge in reinforcement learning \citep{sutton2018reinforcement,szepesvari2010algorithms}. The two most classical planning algorithms are value iteration \citep{bellman1957markovian} and policy iteration \citep{howard1960dynamic}. Approximate versions of value and policy iteration were analyzed by \citet{munos2003error,munos2005error,farahmand2010error}. A common setting is planning with a \emph{generative model} (also \emph{global} simulator access), where the learner can query the transition kernel at any state and action \citep{kakade2003sample}. In the corresponding tabular setting the query complexity of value and policy iteration are completely understood \citep[e.g.,][]{azar2012sample,azar2013minimax}. When combined with function approximation, the picture becomes more nuanced. A lower bound under misspecification was provided by \citet{du2019good}. Sample complexity bounds for least-squares policy iteration \citep{bertsekas1996temporal,lagoudakis2003least} are by \citet{lattimore2020learning}. The latter work combines a G-experimental design over state-action pairs with Monte-Carlo rollouts to obtain value estimates for the policies. In similar fashion, least-squares value iteration (LSVI) was analyzed in the generative model setting \citep{agarwal2020reinforcement}. Yet another approach is Politex \citep{abbasi2019politex,rltheory2022}, which uses mirror descent to improve the policy. \looseness=-1
A much larger body of work focuses on the online setting, where the learner interacts with the environment in one or multiple episodes. Early work that uses function approximation includes \citep{bradtke1996linear,melo2007q}. Recent works provide query complexity guarantees under various models \citep{osband2016generalization,yang2020function,ayoub2020model,zanette2020learning,du2021bilinear,zhou2021nearly}. This includes approaches that are computationally efficient for small action sets \citep{jin2020provably,agarwal2020pc}. We are not aware of provably query efficient algorithms with \emph{only} linear $Q_\pi$-realizability (\cref{asm:linear-q-pi}) for the online setting. \Citet{abbasi2019politex,lazic2021improved,wei2021learning} prove bounds with a \emph{feature excitation} condition, although these works do not consider large action sets. Negative results under weaker assumptions are known, e.g.~for $Q^*$-realizability \citep{weisz2021exponential} and approximate $Q_\pi$-realizability \citep{du2019good}.\looseness=-1
Recently, \citet{yin2021efficient} introduced the \emph{local access} model, in which the learner can query the simulator at the initial state or any state observed during planning. They further introduce a Monte-Carlo policy iteration algorithm that provides the basis of our work. Different to this previous work, we consider the combinatorial action set setting, and provide new algorithms that avoid scaling of the computational complexity with the size of the action set.
Least-squares value iteration with local access was analyzed by \citet{hao2022confident}. For a detailed discussion on different simulators models we refer the reader to \citep{yin2021efficient}.
Relatively few related works on computationally efficient planning in MDPs are concerned with combinatorial action spaces.
This topic has received attention in the context of factored MDPs in planning \citep{dean1998solving,geisser2020trial,raghavan2012planning}, online RL \citep{osband2014near, xu2020near, tian2020towards, chen2020efficient} and in the empirical literature \citep{delarue2020reinforcement,hubert2021learning} with applications to vehicle routing and control problems. We are not aware of prior work with query complexity guarantee for MDPs with large action sets, however there is a long line of works on combinatorial bandits \citep[e.g.,][]{cesa2012combinatorial,chen2013combinatorial,shleyfman2014combinatorial,combes2015combinatorial,jourdan2021efficient}. Relevant in this context are also kernelized bandit algorithms (Bayesian optimization) that exploit additive structure of the reward function \citep{kandasamy2015high,wang2019improving,kirschner2021bias,mutny2018efficient,rolland2018high}. We consider a similar assumption in \cref{sec:additive} as a special case.
Multi-agent reinforcement learning \citep{busoniu2008comprehensive,zhang2021multi} can be understood as a combinatorial setting, which has a large body of works on its own. Query complexity bounds focus mostly on the competitive setting, e.g. in tabular Markov games (e.g., \cite{shapley1953stochastic, song2021can,tian2021online,bai2020provable,liu2021sharp,leonardos2021global}).
One of the key challenges is the exponential blowup in the action space with the number of agents, which is sometimes refered to as `curse of multi-agents'. \Citet{jin2021v} introduce a computationally efficient algorithm for tabular Markov games. Multi-agent reinforcement learning with function approximation is studied by \cite{huang2021towards,chen2021almost,jin2020provably}. These works consider the competitive setting and focus on obtaining query efficient algorithms, while the approaches are not computationally tractable. In the limit where the number of agents becomes large, previous work uses mean-field approximations \citep{yang2018mean,pasztor2021efficient}.
Most closely related is \emph{cooperative} multi-agent learning. Early work by \citet{guestrin2001multiagent} proposes the use of factored MDPs to make planning tractable via message passing algorithms. \Citet{rashid2018qmix} propose a neural network architecture that allows to decouple the agent rewards in a way such that the greedy policy can be computed efficiently.
The goal of these works is to ensure the greedy policy can be computed efficiently. \Citet{zohar2021locality} consider a setting where a graph structure captures the reward dependencies across the agents; however the guarantees they provide apply only to the bandit setting.\looseness=-1
\section{Theoretical Results} \label{sec:theoretical results}\todoj{results from this section get distributed into section 4/5, then remove this section}
In this section we provide a theorem for each of the four variants of the main algorithm, as discussed in the previous section.
The theorems provide bounds on the computation and query complexity of the main algorithm, and the sub-optimality of the output policy's value function.
The complete proofs of all the results can be found in \cref{app: theorem proofs}.
\begin{theorem}[MA-MC-LSPI Sub-Optimality] \label{thm:ma-mc-lspi sub-optimality}
With $z=2m-1$ when \textsc{Uncertainty Check with DAV} is used, and $z = \sqrt{d}$ when \textsc{Uncertainty Check with EGSS} is used.
If \cref{ass: feature decomposition} holds and $\epsilon \neq 0$, then with probability at least $1 - \delta$, the policy $\pi_{K-1}$, output by \textsc{Confident Multi-Agent MC-LSPI} satisfies
\begin{equation*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \frac{64 \epsilon \sqrt{d} z}{(1-\gamma)^2} (1 +\log(1+m b^2 \epsilon^{-2} d^{-1}))^{1/2}.
\end{equation*}
Further on, the query cost is $\mathcal{O}\left(\tfrac{d^2}{\epsilon^2 (1-\gamma)^4} \right)$
and computation cost is $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}), \log(b), m, A)$.
While if $\epsilon = 0$, then for any $\kappa > 0$, with probability at least $1 - \delta$, the policy $\pi_{K-1}$, output by \textsc{Confident Multi-Agent MC-LSPI} satisfies
\begin{equation*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \kappa.
\end{equation*}
Further, the query cost is $\mathcal{O}\left(\tfrac{z^2 d^3}{\kappa^2 (1-\gamma)^8} \right)$
and computation cost is $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}), \log(b), m, A)$.
With parameters settings for both cases above as defined in \cref{app: theorem proofs}.
Moreover, the above results also hold under \cref{ass: argmax oracle} when \textsc{Uncertainty Check with EGSS} is used.
\end{theorem}
\begin{theorem}[MA-MC-Politex Sub-Optimality] \label{thm:ma-mc-politex sub-optimality}
With $z=2m-1$ when \textsc{Uncertainty Check with DAV} is used, and $z = \sqrt{d}$ when \textsc{Uncertainty Check with EGSS} is used.
If \cref{ass: feature decomposition} holds and $\epsilon \neq 0$, then with probability at least $1 - \delta$, the policy $\bar \pi_{K-1}$, output by \textsc{Confident Multi-Agent MC-Politex} satisfies
\begin{equation*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \frac{32 \epsilon \sqrt{d} z}{1-\gamma} (1 +\log(m b^2 \epsilon^{-2} d^{-1}))^{1/2}.
\end{equation*}
Further, the query cost is $\mathcal{O}\left(\tfrac{md}{\epsilon^4 (1-\gamma)^5} \right)$
and computation cost is $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}), \log(b), m, A)$.
While if $\epsilon = 0$, then for any $\kappa > 0$, with probability at least $1 - \delta$, the policy $\bar \pi_{K-1}$, output by \textsc{Confident Multi-Agent MC-Politex} satisfies
\begin{equation*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \kappa.
\end{equation*}
Further on, the query cost is $\mathcal{O}\left(\tfrac{mz^2 d^3}{\kappa^4 (1-\gamma)^9} \right)$
and computation cost is $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}), \log(b), m, A)$.
With parameters settings for both cases above as defined in \cref{app: theorem proofs}.
\end{theorem}
\subsubsection*{\bibname}}
\begin{document}
\onecolumn
\aistatstitle{Provably Efficient Cooperative Multi-Agent Reinforcement Learning with an Online Simulator \\
Supplementary Materials}
\section{Efficient Policy Sampling} \label{app:efficienct policy sampling}
The policy in \citep{yin2021efficient} can be extended to the multi-agent setting with action space $\mathcal{A}^{(1:m)}$ as follows
\begin{equation}
\pi_k(a^{(1:m)}|s) \gets
\begin{cases}
\mathbbm{1}\left(a^{(1:m)} = \argmax\limits_{\tilde{a}^{(1:m)} \in \mathcal{A}^{(1:m)}} w^\top \phi(s, \tilde{a}^{(1:m)})\right) & \text{LSPI} \\
\exp\left(\alpha \sum\limits_{j=0}^{k-1} w_{j}^\top \phi(s, a^{(1:m)})\right) / \sum\limits_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \exp\left(\alpha \sum\limits_{j=0}^{k-1} w_{j}^\top \phi(s, a^{(1:m)})\right) . & \text{Politex}
\end{cases} \label{eq:yin policy}
\end{equation}
with $w_k = (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \Phi_\mathcal{C}^\top q_\mathcal{C}$
and $Q_{k-1}(s, a) = \Pi_{[0, (1-\gamma)^{-1}]} (w_k^\top \phi(s, a))$ for the Politex case only.
In this appendix we show that the above policy can be sampled from efficiently if assumption \cref{ass: feature decomposition} or \cref{ass: argmax oracle} is satisfied for the LSPI case and policy $\pi_k$ can be sampled from efficiently if \cref{ass: argmax oracle} is satisfied for the Politex case.
To be precise, by efficiently we mean with computation that depends on $\text{poly}(m, A, d)$ and not $\text{poly}(A^m, d)$.
We assume only $w \in \mathbb{R}^d$ or $w_0, ..., w_{k-1} \in \mathbb{R}^d$ (for LSPI and Politex respectively) and a feature map $\phi: \mathcal{S} \times \mathcal{A}^{(1:m)} \to \mathbb{R}^d$ are given, thus the process of sampling may require calculating the policy if necessary to accurately sample.
First we handle the LSPI case.
\begin{proposition}[Efficient LSPI Policy Sampling]
\label{prop: efficient lspi policy sampling}
Given state $s \in \mathcal{S}$, parameter vector $w \in \mathbb{R}^d$, feature map $\phi: \mathcal{S} \times \mathcal{A}^{(1:m)} \to \mathbb{R}^d$ and assumption \ref{ass: feature decomposition} or \ref{ass: argmax oracle} satisfied.
Then policy
$$\pi_k(a^{(1:m)}|s) = \mathbbm{1}\left(a^{(1:m)} = \argmax_{\tilde{a}^{(1:m)} \in \mathcal{A}^{(1:m)}} w^\top \phi(s, \tilde{a}^{(1:m)})\right)$$
can be sampled from in time $\text{poly}(d, m, A)$.
\end{proposition}
\begin{proof}
One can sample from policy $\pi_k$ by simply outputting the result of $\argmax_{\tilde{a}^{(1:m)} \in \mathcal{A}^{(1:m)}} w^\top \phi(s, \tilde{a}^{(1:m)})$.
Under assumption \ref{ass: argmax oracle} $\argmax_{\tilde{a}^{(1:m)} \in \mathcal{A}^{(1:m)}} w^\top \phi(s, \tilde{a}^{(1:m)})$ can be computed in time $\text{poly}(d, m, A)$ by applying the oracle to $w$ and $\phi$ (i.e. $\mathcal{O}(w, \phi)$).
Since assumption \ref{ass: feature decomposition} implies assumption \ref{ass: argmax oracle} the result also holds under assumption \ref{ass: feature decomposition}.
\end{proof}
Next, we handle the Politex case.
To achieve the result below we had to modify the Politex algorithm slightly, by removing the clipping of the $Q$-function at each iteration $k$ (i.e. we define the $Q$-function at iteration $k$ to be $Q_{k-1}(s, a) = w_k^\top \phi(s, a^{(1:m)})$ instead of $Q_{k-1}(s, a) = \min\{\max\{w_k^\top \phi(s, a^{(1:m)}), 0\}, 1/(1-\gamma)\}$).
This was done since we were not aware of an efficient way to compute the clipped $Q$-function for all action-vectors in $\mathcal{A}^{(1:m)}$.
Removing the clipping only suffers a minor increase in the final policies sub-optimality (shown in Appendix \ref{app: theorem proofs} and in the Notes section of \citet{szepesvari2022})
\begin{proposition}[Efficient Politex Policy Sampling]
\label{prop: efficient politex policy sampling}
Given state $s \in \mathcal{S}$, parameter vectors $w_0, ..., w_{k-1} \in \mathbb{R}^d$, feature map $\phi: \mathcal{S} \times \mathcal{A}^{(1:m)} \to \mathbb{R}^d$ and assumption \ref{ass: feature decomposition} satisfied.
Then policy
$$\pi_k(a^{(1:m)}|s) = \exp\left(\alpha \sum\nolimits_{j=0}^{k-1} w_{j}^\top \phi(s, a^{(1:m)})\right)/ \sum\nolimits_{\tilde{a}^{(1:m)} \in \mathcal{A}^{(1:m)}} \exp \left(\alpha \sum\nolimits_{j=0}^{k-1} w_{j}^\top \phi(s, \tilde{a}^{(1:m)})\right)$$
can be sampled from in time $\text{poly}(d, m, A)$.
\end{proposition}
\begin{proof}
Fix arbitrary $a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
To sample from $\pi_k$ it is sufficient to sample actions $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ proportional to $\exp(\alpha \sum_{j=0}^{k-1} Q_{j}(s, a^{(1:m)}))$.
Rearranging $\exp(\alpha \sum_{j=0}^{k-1} Q_{j}(s, a^{(1:m)}))$ and plugging in that $\phi(s, a^{(1:m)}) = \sum_{i=1}^m w^\top \phi_i(s, a^\ag{i})$ under assumption \ref{ass: feature decomposition} we have
\begin{align*}
\exp\left(\alpha \sum\nolimits_{j=0}^{k-1} w_{j}^\top \phi(s, a^{(1:m)})\right)
&= \prod_{j=0}^{k-1} \exp\left(\alpha w_{j}^\top \phi(s, a^{(1:m)})\right) \\
&= \prod_{j=0}^{k-1} \exp\left(\alpha w_{j}^\top \sum_{i=1}^m \phi_i(s, a^\ag{i})\right) \\
&= \prod_{i=1}^m \prod_{j=0}^{k-1} \exp\left(\alpha w_{j}^\top \phi_i(s, a^\ag{i})\right)
\end{align*}
Which means that the probability of sampling action $a^{(1:m)}$ is equal to the product of the probabilities of sampling $a^\ag{i}$ for agents $i \in [m]$ independently.
Since $a^{(1:m)}$ was arbitrary this completes the proof.
\end{proof}
\section{{Bound on Core Set Size}}
Recall, that only tuples containing state-action vectors that satisfy $\phi(s, a^{(1:m)})^\top (\Phi^\top \Phi + \lambda I)^{-1} \phi(s, a^{(1:m)}) > \tau$ are add to the core set.
This ensures that the size of the core set can be be bounded by a $\text{poly}(d, \tau, \log(m), \log(1/\lambda))$ function.
\begin{lemma}[Bound on Core Set Size (modified Lemma 5.1 in \citep{yin2021efficient})] \label{lemma:bound on core set size}
When \cref{ass: bounded features} is satisfied, and $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ that satisfy $\phi(s, a^{(1:m)})^\top (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \phi(s, a^{(1:m)}) > \tau$ are added to the core set, the size of the core set can be bounded by
\begin{align}
\tilde{C}_{\max} := \frac{e}{e-1} \frac{1 + \tau}{\tau} d \left(
\log(1 + \frac{1}{\tau}) +
\log(1 + \frac{m}{\lambda})
\right). \label{eq:cmax-new}
\end{align}
\end{lemma}
The Lemma displayed above is borrowed directly from \citet{yin2021efficient}.
The only difference is that the features in our setting are bounded by $m$ instead of $1$ (Assumption \ref{ass: bounded features}), and thus we obtain an extra $\log(m)$ factor, which can easily be verified.
\section{Efficient Uncertainty Check} \label{app:efficient uncertainty check}
\label{app: efficient uncertainty check}
The \textsc{Uncertainty Check} algorithm is the implementation used by \citet{yin2021efficient} extended to the multi-agent setting, where the action space is $\mathcal{A}^{(1:m)}$.
The \textsc{Confident MC-LSPI/Politex} algorithm proposed by \citet{yin2021efficient} algorithm is identical to our \textsc{Confident Multi-Agent MC-LSPI/Politex} algorithm with \textsc{Uncertainty Check with (DAV/EGSS)} replaced with \textsc{Uncertainty Check} and the policy on line 15 replaced with \cref{eq:yin policy}.
\begin{algorithm}
\caption{\textsc{Uncertainty Check}} \label{alg:uncertainty check}
\begin{algorithmic}[1]
\State \textbf{Input:} state $s$, feature matrix $\Phi_\mathcal{C}$, regularization coefficient $\lambda$, threshold $\tau$.
\For {$a^{(1:m)} \in \mathcal{A}^{(1:m)}$}
\If {$\phi(s, a^{(1:m)})^\top (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \phi(s, a^{(1:m)}) > \tau$}
\State status $\gets$ uncertain, result $\gets (s, a^{(1:m)}, \phi(s, a^{(1:m)}), \text{none})$
\State \Return {status, result}
\EndIf
\EndFor
\State \Return certain, none
\end{algorithmic}
\end{algorithm}
In this appendix we show how the loop over all action vectors $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ in the \textsc{Uncertainty Check} algorithm (line 2) can be avoided when either \cref{ass: feature decomposition} or \cref{ass: argmax oracle} is satisfied.
In particular, we show that \textsc{Uncertainty Check with DAV} and \textsc{Uncertainty Check with EGSS} algorithms are able to reduce the computation time of the \textsc{Uncertainty Check} from $\text{poly}(A^m, d)$ to $\text{poly}(m, A, d)$, while still maintaining suitable output policy guarantees.
Since, we are extending the \textsc{Confident MC-LSPI/Politex} algorithm proposed by \citet{yin2021efficient}, we will be borrowing much of the steps from their proof.
\citet{yin2021efficient} used a \textit{virtual algorithm} (VA) and \textit{main algorithm} (MA) to prove the sub-optimality of their \textsc{Confident MC-LSPI/Politex} algorithm.
We give a brief summary of the VA and MA; however, avoid full details since we use the exact same definition as in \citet{yin2021efficient}.
Until the next subsection, assume \textsc{Uncertainty Check} is used in place of \textsc{Uncertainty Check with (DAV/EGSS)} in \textsc{Confident Multi-Agent MC-LSPI/Politex}.
The MA is exactly \textsc{Confident Multi-Agent MC-LSPI/Politex}.
The VA is based on the \textsc{Confident Multi-Agent MC-LSPI/Politex} algorithm, but has some differences, which we outline next.
The VA runs for exactly $C_\text{max}$ loops, $K$ iterations, and completes all $n$ of its rollouts of length $H$.
For each loop and iteration $k$ the VA always obtains estimates $q_\mathcal{C}$ of its policy.
The VA uses a different policy than the MA for rollouts.
We will first focus on the LSPI case and return to Politex much later.
The VA's $Q$-function at iteration $k$ is
\begin{equation*}
\tilde{Q}_{k-1}(s, a^{(1:m)})=\begin{cases}
\tilde{w}_k^\top \phi(s, a^{(1:m)}) \quad &\text{if} \, \phi(s, a^{(1:m)}) \in \mathcal{H} \\
Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)}) \quad &\text{if} \, \phi(s, a^{(1:m)}) \notin \mathcal{H} \\
\end{cases}
\end{equation*}
where $\tilde w_k = V_\mathcal{C}^{-1} \Phi_\mathcal{C}^\top \tilde q_\mathcal{C}$, and $\tilde q_\mathcal{C}$ are the estimates obtained from running \textsc{Multi-Agent-Confident Rollout} on each element of the core set, and $\mathcal{H} = \{\phi(s, a^{(1:m)}): \|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 \le \tau\}$ is the \textit{good set}.
The VA's policy is
\begin{equation*}
\tilde \pi_k(a^{(1:m)} | s) = \mathbbm{1} \left( a^{(1:m)} = \argmax_{\tilde a^{(1:m)} \in \mathcal{A}^{(1:m)}} \tilde Q_{k-1}(s, \tilde a^{(1:m)}) \right).
\end{equation*}
The nice thing about defining the VA's policy in this way is that we can make use of the following Lemma from \citep{yin2021efficient}.
\begin{lemma}[Lemma B.2 in \citep{yin2021efficient}]
\label{lemma: yin lemma b.2}
Suppose that Assumption \ref{ass: feature decomposition} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
for any $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ pair such that $\phi(s, a^{(1:m)}) \in \mathcal{H}$, we have
$$|\tilde{Q}_{k-1} (s, a^{(1:m)}) - Q_{\tilde\pi_{k-1}} (s, a^{(1:m)})| \le b\sqrt{\lambda \tau} + \left(\epsilon + \frac{\gamma^{H-1}}{1 - \gamma} + \theta \right) \sqrt{\tau C_{\text{max}}} + \epsilon := \eta$$
\end{lemma}
Notice that for any $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ pair such that $\phi(s, a^{(1:m)}) \notin \mathcal{H}$, the VA's $Q$-function $\tilde Q_{k-1}$ has access to the true $Q$-function $Q_{\tilde{\pi}_{k-1}}$ of policy $\tilde \pi_{k-1}$.
Thus, we have that
\begin{equation}
\label{eq:va inf-norm bound}
\| \tilde{Q}_{k-1} (s, a^{(1:m)}) - Q_{\tilde\pi_{k-1}} (s, a^{(1:m)}) \|_\infty \le \eta
\end{equation}
Combined with the fact that $\tilde \pi_k$ is greedy w.r.t. $\tilde Q_{k-1}$ the above result turns out to be especially useful.
To understand why, we state a classic policy improvement result, which can be found as Lemma B.3 in \citet{yin2021efficient} and in other papers.
\begin{lemma}[approximate policy iteration]
\label{lemma:approximate policy iteration}
Suppose that we run K approximate policy iterations and generate a sequence of policies
$\pi_0, \pi_1, \pi_2, \cdots, \pi_K$.
Suppose that for every $k = 1, 2, \cdots, K$, in the k-th iteration, we obtain a function
$\tilde{Q}_{k-1}$ such that, $\| \tilde{Q}_{k - 1} - Q_{\pi_{k - 1}} \|_\infty \leq \eta$,
and choose $\pi_k$ to be greedy with respect to $\tilde{Q}_{k-1}$.
Then
\begin{align*}
\| Q^* - Q_{\pi_K} \|_\infty \leq \frac{2 \eta}{1 - \gamma} + \frac{\gamma^K}{1 - \gamma},
\end{align*}
\end{lemma}
In our case the VA's policy $\tilde \pi_k$ is greedy w.r.t. $\tilde Q_{k-1}$ and thus we have that
\begin{align*}
\| Q^* - Q_{\tilde \pi_K} \|_\infty \leq \frac{2 \eta}{1 - \gamma} + \frac{\gamma^K}{1 - \gamma},
\end{align*}
Now we explain how the MA can be related to the VA, and make use of the above result.
The \textsc{Uncertainty Check} algorithm can have two cases:
\textbf{Case 1:} $\|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 > \tau$ holds for at least one $a^{(1:m)} \in \mathcal{A}^{(1:m)}$,
\textbf{Case 2:} $\|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 \le \tau$ holds for all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$. This is equivalent to saying $\phi(s, a^{(1:m)}) \in \mathcal{H}, \ \forall a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
The VA is exactly the same at the MA algorithm, until Case 1 occurs for the first time.
This is because the MA's and VA's simulators are coupled, in the sense that at iteration $k$, rollout $i$, and step $t$, when both simulators are queried with the same state-action vector pairs, they sample the exact same next state and reward.
The VA also uses the same initial policy as the MA at the start of policy iteration for every loop.
Once Case 1 occurs the MA would restart policy iteration (else condition in line 12 of \textsc{Confident Multi-Agent MC-LSPI/Politex}), while the VA does not.
The VA records the state-action vector pair when Case 1 occurs for the first time and adds it to the core set once it completes running policy iteration for the current loop.
In this way the core set maintained by the MA and VA are always the same.
Since the size of the core set is bounded by $C_\text{max}$ when $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ that satisfy $\phi(s, a^{(1:m)})^\top (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \phi(s, a^{(1:m)}) > \tau$ are added to the core set (\cref{lemma:bound on core set size}), there will be a loop of policy iteration at which the MA and VA never encounter Case 1 for any of the $K$ iterations of policy iteration.
We call this loop the \emph{final loop}.
This is equivalent to say that all $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ observed during all $K$ iterations of policy iteration in the final loop are in the good set (i.e. $\phi(s, a^{(1:m)}) \in \mathcal{H}$).
Notice that this means MA and VA behaved identical in the final loop, since the VA's policy would have always been greedy w.r.t. $\tilde{w}_k^\top \phi$ and the MA and VA use the same initial policy at the start of each loop.
It turns out this relationship between the MA and VA allows us to bound the sub-optimality of the MA in the final loop, by using the result in \cref{eq:va inf-norm bound} we have for the VA.
More precisely, the following result can be extracted from \citep{yin2021efficient}
\begin{proposition}[equation (B.15) in \citet{yin2021efficient}] \label{prop:optimality of output policy}
With all terms as defined earlier.
Define $\eta \ge \|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$.
Suppose $\eta \ge |\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|_\infty, \ \forall a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
Then, if the VA and MA behave identically in the final loop, with probability at least $1 - 4KC_{\text{max}}^2 \exp(-2 \theta^2(1-\gamma)^2 n)$ we have
\begin{align}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \frac{8 \eta}{(1 - \gamma)^2} + \frac{2 \gamma^{K - 1}}{(1 - \gamma)^2} \label{eq: v function bound main}
\end{align}
\end{proposition}
Notice, that we require three things to use the above result.
We need a bound on $\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$.
We need a bound on $|\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|_\infty, \ \forall a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
We need to ensure that the VA and MA behave identically in the final loop.
Then, we can get a bound on the sub-optimality of the MA's output policy $\pi_{K-1}$.
An important observation is that \textsc{Uncertainty Check} ensured that MA and VA behave identically in the final loop.
It did this by making sure that the VA's policy $\tilde \pi_k$ would only be able to use $\tilde{w}_k^\top \phi$ to derive its actions, since \textsc{Uncertainty Check} always returns a \textsc{status} of \textsc{certain} in the final loop, which means that $\phi(s, a^{(1:m)}) \in \mathcal{H}$ for all $s, a^{(1:m)} \in \mathcal{S} \times \mathcal{A}^{(1:m)}$ encountered in the final loop.
With this information in mind, we now show that \textsc{Uncertainty Check with DAV} and \textsc{Uncertainty Check with EGSS} only requires computation $\text{poly}(d, m, A)$, while providing only slightly worse sub-optimality guarantees when compared to the result in \citep{yin2021efficient}.
\subsection{Default Action Vector (DAV) Method}
In this section we prove some useful results for \textsc{Uncertainty Check with DAV}.
Fix a state $s \in \mathcal{S}$.
First, \textsc{Uncertainty Check with DAV} only iterates over $\sum_{i=1}^m |A^\ag{i}|$ action vectors instead of all the action vectors like \textsc{Uncertainty Check} does.
Define the $\sum_{i=1}^m A^\ag{i}$ sized set of modified default action vectors as $\bar \mathcal{A}^{(1:m)} = \{ (a^\ag{i}, \bar a^{(-i)}): a^\ag{i} \in \mathcal{A}^\ag{i}, \ i \in [m] \}$.
Notice \textsc{Uncertainty Check with DAV} iterates over all the actions in the set $a^{(1:m)} \in \bar \mathcal{A}^{(1:m)}$ and checks if any of them satisfy $\|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 > \tau$.
This of course achieves the goal of only $\text{poly}(d, m, A)$ computation.
Also, since only $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ that satisfy $\|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 > \tau$ are added to the core set, we can still use \cref{lemma:bound on core set size} to bound the size of the core set by $C_\text{max}$.
Now, we aim to ensure that the VA and MA behave identically in the final loop.
Define the set of states for which all the modified default action vectors are in the good set as $\bar \mathcal{S} = \{ s \in \mathcal{S}: \|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 \le \tau, \forall a^{(1:m)} \in \bar \mathcal{A}^{(1:m)} \}$.
Redefine the VA's $Q$-function as
\begin{equation*}
\tilde Q_{k-1}(s, a^{(1:m)})=\begin{cases}
\tilde w_k^\top \phi(s, a^{(1:m)}) \quad & s \in \bar \mathcal{S} \\
Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)}). \quad & s \in \mathcal{S} \backslash \bar \mathcal{S}
\end{cases}
\end{equation*}
The VA's policy is
\begin{equation*}
\tilde \pi_k(a^{(1:m)} | s) = \mathbbm{1} \left( a^{(1:m)} = \argmax_{\tilde a^{(1:m)} \in \mathcal{A}^{(1:m)}} \tilde Q_{k-1}(s, \tilde a^{(1:m)}) \right).
\end{equation*}
Notice that in the final loop the check $\phi(s, (a^{(j)}, \bar a^{(-j)}))^\top (\Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I)^{-1} \phi(s, (a^{(j)}, \bar a^{(-j)})) > \tau$ in \textsc{Uncertainty Check with DAV} never returns \textsc{True}, and thus we are sure that all $a^{(1:m)} \in \bar \mathcal{A}^{(1:m)}$ for all the states encountered in the final loop are in the good set.
Notice that these states that satisfy this condition are state in $\bar \mathcal{S}$.
Thus, the VA's policy $\pi_{k}$ would always be greedy w.r.t. $\tilde w_k^\top \phi$ in the final loop.
This ensures that the VA and MA behave identically in the final loop.
Now we show that we can bound $\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$ with this new definition of $\tilde Q_{k-1}$.
First we state a slight modification of \cref{lemma: yin lemma b.2} for $w_{\tilde{\pi}_{k-1}}^\top \phi$ instead of $Q_{\tilde{\pi}_{k-1}}$ which excludes the $\|w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})\|_\infty \le \epsilon$ term in the proof of Lemma B.2 in \citep{yin2021efficient}.
\begin{lemma}[Lemma B.2 in \citep{yin2021efficient}]
\label{lemma: yin lemma b.2 no epsilon}
Suppose that Assumption \ref{ass: feature decomposition} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
for any $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ pair such that $\phi(s, a^{(1:m)}) \in \mathcal{H}$, we have
$$|\tilde{w}_{k} (s, a^{(1:m)}) - w_{\tilde\pi_{k-1}}^\top (s, a^{(1:m)})| \le b\sqrt{\lambda \tau} + \left(\epsilon + \frac{\gamma^{H-1}}{1 - \gamma} + \theta \right) \sqrt{\tau C_{\text{max}}}:= \bar\eta$$
\end{lemma}
The following Proposition gives us a bound on $\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$.
\begin{proposition}[approximate value function bound for DAV]
\label{prop: approx value function bound for DAV}
Suppose that Assumption \ref{ass: feature decomposition} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
we have
$$\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})\|_\infty \le \bar\eta (2m-1) + \epsilon := \eta_1.$$
\end{proposition}
\begin{proof}
For any $(s, a^{(1:m)}) \in (\bar \mathcal{S} \times \mathcal{A}^{(1:m)})$, we have
\begin{align}
& |\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&= |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&= |\tilde{w}_k^\top \phi(s, a^{(1:m)}) \pm w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&\le |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)})| + |w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \nonumber \\
&\le |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)})| + \epsilon \nonumber \\
&= |\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde{\pi}_{k-1}}^\top \phi(s, a^{(1:m)}) \pm (m-1)\tilde{w}_k^\top \phi(s, \bar a^{(1:m)}) \pm (m-1) w_{\tilde{\pi}_{k-1}}^\top \phi(s, \bar a^{(1:m)})| + \epsilon \nonumber \\
&= \left|\left( \sum_{i=1}^m \tilde{w}_k^\top \phi(s, (a^\ag{i}, \bar a^{(-i)})) - w_{\tilde\pi_{k-1}}^\top \phi(s, (a^\ag{i}, \bar a^{(-i)})) \right) + (m-1)\left[w_{\tilde{\pi}_{k-1}}^\top \phi(s, \bar a^{(1:m)})) - \tilde{w}_k^\top \phi(s, \bar a^{(1:m)}\right]\right| + \epsilon \nonumber \\
&\le m \bar\eta + (m-1) \bar \eta + \epsilon \nonumber \\
&= \bar\eta (2m-1) + \epsilon \label{value function bound 1}
\end{align}
where the second last inequality holds by Lemma \ref{lemma: yin lemma b.2 no epsilon} (because the features of all the state action pairs considered are in $\mathcal{H}$, since $s \in \bar \mathcal{S}$).
While for any $(s, a^{(1:m)}) \in ((\mathcal{S} \backslash \bar \mathcal{S}) \times \mathcal{A}^{(1:m)})$, we have
\begin{align}
|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})|
= |Q_{\tilde \pi_{k-1}}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})|
&= 0 \label{value function bound 2}
\end{align}
\end{proof}
Finally, it is left to show that $|\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|$ can be bounded for all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
Notice that lines 3-6 in \textsc{Confident Multi-Agent MC-LSPI} run \textsc{Uncertainty Check with DAV} with state $\rho$ as input until the returned \textsc{status} is \textsc{certain}.
Recall that once \textsc{Uncertainty Check with DAV} returns a \textsc{status} of \textsc{certain} we know that $\rho \in \bar \mathcal{S}$.
Thus, we can immediately apply the result in \cref{value function bound 1} to bound $\eta_1 \ge |\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|, \ \forall a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
\subsection{Efficient Good Set Search Approach (EGSS)} \label{subsec:good set search}
In this section we prove some useful results for \textsc{Uncertainty Check with EGSS}.
Fix a state $s \in \mathcal{S}$.
First, we show that with $\text{poly}(d, m, A)$ computation, one can find an action vector $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ that approximately maximizes $\phi(s, a^{(1:m)})^\top V_\mathcal{C}^{-1} \phi(s, a^{(1:m)})$.
\begin{lemma}[Efficient good set search]
\label{lemma:good set search}
Assume either assumption \ref{ass: feature decomposition} or \ref{ass: argmax oracle} is satisfied.
With all terms as defined earlier.
One can ensure, with computation time $2 d^2 \sum_{i=1}^m A^\ag{i}$ that either
$$\phi(s, a^{(1:m)})^\top V_\mathcal{C}^{-1} \phi(s, a^{(1:m)}) \le d\tau$$
for all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$, or there exists an $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ such that
$$\phi(s, a^{(1:m)})^\top V_\mathcal{C}^{-1} \phi(s, a^{(1:m)}) > \tau$$
\end{lemma}
\begin{proof}
Recall that we are able to compute $\max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle u, \phi(s, a^{(1:m)}) \rangle$ for any $u \in \mathbb{R}^d$ in $\text{poly}(d ,m, A)$ time (due to assumption \ref{ass: feature decomposition} or \ref{ass: argmax oracle}).
Now, we make use of a bi-directional 2-norm to $\infty$-norm inequality that will take advantage of the above mentioned efficient computation.
Fix $\mathcal{C}$ and define the lower triangular matrix $L$ via the Cholesky decomposition $V_\mathcal{C}^{-1} = L L^\top$.
Define $\{e_i\}_{i=1}^d$ as the standard basis vectors and
\begin{equation*}
(v^*, a_\text{max}^{(1:m)}) := \text{arg} \left(\max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle L v, \phi(s, a^{(1:m)}) \rangle \right)
\end{equation*}
Then we have that
\begin{align}
\frac{1}{d} \| \phi(s, a_\text{max}^{(1:m)}) \|_{V_\mathcal{C}^{-1}}^2
&= \frac{1}{d} \phi(s, a_\text{max}^{(1:m)})^\top V_\mathcal{C}^{-1} \phi(s, a_\text{max}^{(1:m)}) \nonumber \\
&= \frac{1}{d} \phi(s, a_\text{max}^{(1:m)})^\top L L^\top \phi(s, a_\text{max}^{(1:m)}) \nonumber \\
&= \frac{1}{d} \| L^\top \phi(s, a_\text{max}^{(1:m)}) \|_2^2 \nonumber \\
&\le \max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \| L^\top \phi(s, a^{(1:m)})\|_\infty^2 \nonumber \\
&= \max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle v, L^\top \phi(s, a^{(1:m)}) \rangle^2 \nonumber \\
&= \max_{v \in \{\pm e_i\}_{i=1}^d} \max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle L v, \phi(s, a^{(1:m)}) \rangle^2 \nonumber \\
&= \langle L v^*, \phi(s, a^{(1:m)}_\text{max}) \rangle^2 \label{inf-norm term} \\
&\le \| L^\top \phi(s, a_\text{max}^{(1:m)}) \|_2^2 \nonumber
\end{align}
Notice that the purpose of writing all the equalities up to equation (\ref{inf-norm term}) was to show that equation (\ref{inf-norm term}) can be computed in $\text{poly}(d, m, A)$ time.
Since $\max_{a^{(1:m)} \in \mathcal{A}^{(1:m)}} \langle L v, \phi(s, a^{(1:m)}) \rangle^2$ can be computed in $\text{poly}(d, m, A)$ time (due to assumption \ref{ass: feature decomposition} or \ref{ass: argmax oracle}) and $\{\pm e_i\}_{i=1}^d$ contains $2d$ elements.
Also, note that $L$ can be computed with at most $d^2$ computation in each loop by doing a rank one update to the Cholesky decomposition of $V_\mathcal{C}^{-1} = L L^\top$.
If equation (\ref{inf-norm term}) is larger than $\sqrt{\tau}$, then $\|\phi(s, a_\text{max}^{(1:m)}) \|_{V^{-1}}^2 > \tau$.
While, if equation (\ref{inf-norm term}) is less than or equal $\tau$, then $\|\phi(s, a_\text{max}^{(1:m)}) \|_{V^{-1}}^2 \le d\tau$, completing the proof.
\end{proof}
\textsc{Uncertainty Check with EGSS} is essentially an implementation of equation (\ref{inf-norm term}), thus it only takes computation $\text{poly}(d, m, A)$ to run, as stated in Lemma \ref{lemma:good set search}.
Also, since only $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ that satisfy $\|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 \ge \|\phi(s, a^{(1:m)})\|_\infty^2 > \tau$ are added to the core set, we can still use \cref{lemma:bound on core set size} to bound the size of the core set by $C_\text{max}$.
Basically, \ref{inf-norm term} is an underestimate of $\| \phi(s, a_\text{max}^{(1:m)}) \|_{V^{-1}}^2$ and we only add elements to the core set when it is larger than $\tau$, thus the core set is no larger than it was when using \textsc{Uncertainty Check}.
Now, we aim to ensure that the VA and MA behave identically in the final loop.
Notice that \textsc{Uncertainty Check with EGSS} provides a weaker guarantee than \textsc{Uncertainty Check}, when the returned \textsc{result} is \textsc{certain}.
Specifically, when \textsc{Uncertainty Check with EGSS} returns a \textsc{result} of \textsc{certain}, then Lemma \ref{lemma:good set search} guarantees that $\|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 \le d\tau$ for all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
While when the \textsc{Uncertainty Check} returns a \textsc{result} of \textsc{certain}, then $\|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 \le \tau$ for all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
Thus, we define a smaller good set $\mathcal{H}_d = \{ \phi(s, a^{(1:m)}): \|\phi(s, a^{(1:m)})\|_{V_\mathcal{C}^{-1}}^2 \le d\tau\}$.
Redefine the VA's $Q$-function at iteration $k$ as
\begin{equation*}
\tilde{Q}_{k-1}(s, a^{(1:m)})=\begin{cases}
\tilde{w}_k^\top \phi(s, a^{(1:m)}) \quad &\text{if} \, \phi(s, a^{(1:m)}) \in \mathcal{H}_d \\
Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)}) \quad &\text{if} \, \phi(s, a^{(1:m)}) \notin \mathcal{H}_d \\
\end{cases}
\end{equation*}
and VA's policy as
\begin{equation*}
\tilde \pi_k(a^{(1:m)} | s) = \mathbbm{1} \left( a^{(1:m)} = \argmax_{\tilde a^{(1:m)} \in \mathcal{A}^{(1:m)}} \tilde Q_{k-1}(s, \tilde a^{(1:m)}) \right).
\end{equation*}
Notice that in the final loop \textsc{Uncertainty Check with DAV} always returns a \textsc{result} of \textsc{certain}, and thus we are sure that all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$ for all the states encountered in the final loop are in the smaller good set $\mathcal{H}_d$.
Thus, the VA's policy $\pi_{k}$ would always be greedy w.r.t. $\tilde w_k^\top \phi$ in the final loop.
This ensures that the VA and MA behave identically in the final loop.
We need show that we can bound $\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$ with this new definition of $\tilde Q_{k-1}$.
First we state a slight modification of \cref{lemma: yin lemma b.2} that holds for the smaller good set $\mathcal{H}_d$
\begin{lemma}[EGSS modified Lemma B.2 from \cite{yin2021efficient}]
\label{lemma: mod b.2 egss}
Suppose that Assumption \ref{ass: feature decomposition} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
for any $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ pair such that $\phi(s, a^{(1:m)}) \in \mathcal{H}_d$, we have
$$|\tilde{w}_k^\top \phi(s, a^{(1:m)}) - w_{\tilde\pi_{k-1}}^\top \phi(s, a^{(1:m)})| \le b\sqrt{\lambda d \tau} + \left(\epsilon + \frac{\gamma^{H+1}}{1 - \gamma} + \theta \right) \sqrt{d \tau C_{\text{max}}} + \epsilon = \sqrt{d} \bar \eta:= \eta_2$$
\end{lemma}
\begin{proof}
The proof is identical to that of Lemme B.2 from \cite{yin2021efficient} except $\tau$ is replaced with $d \tau$ everywhere, due to the weaker guarantee of algorithm \ref{alg:uncertainty check egss} as discussed above.
\end{proof}
Essentially we get an extra $\sqrt{d}$ factor due to the smaller good set $\mathcal{H}_d$.
Since the VA's policy $\tilde \pi_{k}$ has access to the true $Q$-function $Q_{\tilde \pi_{k-1}}$ for all $\phi(s, a^{(1:m)}) \notin \mathcal{H}_d$,
Now we show that $\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$ can be bounded.
\begin{proposition}[approximate value function bound for EGSS]
\label{prop: approx value function bound for EGSS}
Suppose that Assumption \ref{ass: feature decomposition} holds.
With all terms as defined earlier and $\theta > 0$.
Then, with probability at least
$$1 - 2C_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$$
we have
$$\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})\|_\infty \le \eta_2.$$
\end{proposition}
\begin{proof}
For any $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ such that $\phi(s, a^{(1:m)}) \in \mathcal{H}_d$, we have
\begin{align}
|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})| \le \eta_2
\end{align}
by \cref{prop: approx value function bound for EGSS}.
While for any $(s, a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ such that $\phi(s, a^{(1:m)}) \notin \mathcal{H}_d$, we have
\begin{align}
|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})|
= |Q_{\tilde \pi_{k-1}}(s, a^{(1:m)}) - Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)})|
&= 0
\end{align}
\end{proof}
Finally, it is left to show that $|\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|$ can be bounded for all $a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
Notice that lines 3-6 in \textsc{Confident Multi-Agent MC-LSPI} run \textsc{Uncertainty Check with EGSS} with state $\rho$ as input until the returned \textsc{status} is \textsc{certain}.
Recall that once \textsc{Uncertainty Check with EGSS} returns a \textsc{status} of \textsc{certain} we know that $\rho \in \mathcal{H}_d$.
Thus, we can immediately apply \cref{lemma: mod b.2 egss} to bound $\eta_2 \ge |\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|, \ \forall a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
\subsection{Extending to Politex} \label{subsec:extending to politex}
Recall the above results where for the \textsc{Confident Multi-Agent MC-LSPI} case.
It turns out the story for the \textsc{Confident Multi-Agent MC-Politex} is extremely similar and can be argued in nearly the same way.
The main difference is that the policy used in \textsc{Confident Multi-Agent MC-Politex} is different than in \textsc{Confident Multi-Agent MC-LSPI} (line 15).
As such, we can no longer use \cref{lemma:approximate policy iteration} (since it relied on a greedy policy) and, thus cannot use \cref{prop:optimality of output policy} to bound the sub-optimality of the policy output by \textsc{Confident Multi-Agent MC-Politex}.
Next, we show there is a similar Lemma and Proposition that can derived for \textsc{Confident Multi-Agent MC-Politex}.
Recall that we do not use clipping on the $Q$-functions in \textsc{Confident Multi-Agent MC-Politex}, so that we can sample from the policy efficiently (Proposition \ref{prop: efficient politex policy sampling}).
This means we must define the VA's $Q$-function differently from \citep{yin2021efficient}, by removing clipping from the case when $\phi(s, a^{(1:m)}) \in \mathcal{H}$.
\begin{equation*}
\tilde{Q}_{k-1}(s, a^{(1:m)})=\begin{cases}
\tilde{w}_k^\top \phi(s, a^{(1:m)}) \quad &\text{if} \, \phi(s, a^{(1:m)}) \in \mathcal{H} \\
Q_{\tilde{\pi}_{k-1}}(s, a^{(1:m)}) \quad &\text{if} \, \phi(s, a^{(1:m)}) \notin \mathcal{H} \\
\end{cases}
\end{equation*}
Then the VA's policy is
\begin{equation} \label{eq:politex virtual policy}
\tilde \pi_k(a^{(1:m)} | s) \propto \exp \left( \alpha \sum_{j=0}^{k-1} \tilde Q_{j}(s, a^{(1:m)}) \right).
\end{equation}
Also, due to no clipping, the sequence of $Q$-functions during policy iteration is now in the $[-\eta, (1-\gamma)^{-1} + \eta]$ interval, where $\eta \ge \|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$.
We now restate Lemma D.1 from \citet{yin2021efficient} which bounds the mixture policy output by Politex for an arbitrary sequence of $Q$-functions
Since we do not use clipping the theorem is slightly modified (we replace the interval $[0, (1-\gamma)^{-1}]$ with a general interval $[a, b], \ a, b \in \mathbb{R}$, which can be extracted from the calculations in \citet{szepesvari2022}).
\begin{lemma}[modified Lemma D.1 in \citet{yin2021efficient} also in \citet{szepesvari2022}] \label{lemma:politex mixture policy bound}
Given an initial policy $\pi_0$, a sequence of functions $Q_k: \mathcal{S} \times \mathcal{A}^{(1:m)} \to [a, b], \ k \in [K-1], a, b \in \mathbb{R}$, and $Q_{\pi^*} \in [0, 1/(1-\gamma)]$, construct a sequence of policies $\pi_1, ..., \pi_{K-1}$ according to (\ref{eq:politex virtual policy}) with $\alpha = 1/(b-a) \sqrt{\frac{2 \log(|\mathcal{A}^{(1:m)}|)}{K}}$, then, for any $s \in \mathcal{S}$, the mixture policy $\bar \pi_{K-1} \sim \text{Unif}\{\pi_k\}_{k=0}^{K-1}$ satisfies
\begin{equation}
V^*(s) - V_{\bar \pi_K}(s) \le \frac{b-a}{(1-\gamma)}\sqrt{\frac{2 \log(|\mathcal{A}^{(1:m)}|)}{K}} + \frac{2 \max_{0 \le k \le K-1} \|Q_k - Q_{\pi_k}\|_\infty}{1 - \gamma}
\end{equation}
\end{lemma}
Notice that the above result suggests we just need to control the term $\|Q_k - Q_{\pi_k}\|_\infty$.
For the VA this is $\|\tilde Q_k - Q_{\tilde \pi_k}\|_\infty$ and as we have already seen, this can be bounded using the high probability bound on policy evaluation for \textsc{Uncertainty Chcek with DAV} (Proposition \ref{prop: approx value function bound for DAV}) and \textsc{Uncertainty Chcek with EGSS} (Proposition \ref{prop: approx value function bound for EGSS}).
Using Lemma \ref{lemma:politex mixture policy bound} instead of Lemma D.1 in \citet{yin2021efficient}, one can extract another slightly modified result from \citet{yin2021efficient}.
\begin{proposition}[equation (D.8) in \citet{yin2021efficient}] \label{prop:politex optimality of output policy}
With all terms as defined earlier.
Define $\eta \ge \|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$.
Suppose $\eta \ge |\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|_\infty, \ \forall a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
Then, if the VA and MA behave identically in the final loop, with probability at least $1 - 4KC_{\text{max}}^2 \exp(-2 \theta^2(1-\gamma)^2 n)$ we have
\begin{align}
V^*(s) - V_{\bar \pi_{K-1}}(\rho) \le \frac{b-a}{(1-\gamma)} \sqrt{\frac{2 \log(|\mathcal{A}^{(1:m)}|)}{K}} + \frac{4 \eta}{1 - \gamma}
\end{align}
\end{proposition}
Notice, that we require the same three things as in the \textsc{Confident Multi-Agent MC-LSPI} case (Proposition \ref{prop:optimality of output policy}).
We need a bound on $\|\tilde Q_{k-1}(s, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(s, a^{(1:m)})\|_\infty$.
We need a bound on $|\tilde w_{k}^\top \phi(\rho, a^{(1:m)}) - Q_{\tilde \pi_{k-1}}(\rho, a^{(1:m)})|_\infty, \ \forall a^{(1:m)} \in \mathcal{A}^{(1:m)}$.
We need to ensure that the VA and MA behave identically in the final loop.
Then, we can get a bound on the sub-optimality of the MA's output policy $\bar \pi_{K-1}$.
Using the same steps as in the previous sections, one can verify that indeed, \textsc{Confident Multi-Agent MC-Politex} with \textsc{Uncertainty Check with DAV} or \textsc{Uncertainty Check with EGSS} does satisfy the above three conditions, with $\eta = \eta_1$ ($\eta_1$ as defined in \ref{prop: approx value function bound for DAV}) and $\eta = \eta_2$ ($\eta_2$ as defined in \ref{prop: approx value function bound for EGSS}) respectively.
We bound $|\mathcal{A}^{(1:m)}| \le A^m$.
We can replace $b-a$ with $1/(1-\gamma) + 2\eta$, since $w^\top \phi(s, a^{(1:m)}) \in [-\eta, (1-\gamma)^{-1} + \eta], \ \forall (s \times a^{(1:m)}) \in (\mathcal{S} \times \mathcal{A}^{(1:m)})$ in the final loop for the same event which holds with probability at least $1 - 4KC_{\text{max}}^2 \exp(-2 \theta^2(1-\gamma)^2 n)$ in \cref{prop:politex optimality of output policy}.
We get with probability at least $1 - 4KC_{\text{max}}^2 \exp(-2 \theta^2(1-\gamma)^2 n)$ that
\begin{align}
V^*(s) - V_{\bar \pi_{K-1}}(\rho) \le \left(\frac{1}{(1-\gamma)^2} + \frac{2\eta}{(1-\gamma)}\right) \sqrt{\frac{2 m \log(A)}{K}} + \frac{4 \eta}{1 - \gamma}. \label{eq:politex actual optimality of output policy}
\end{align}
\section{Proofs of Theorems} \label{app: theorem proofs}
We make a remark on the query complexity of \textsc{Confident Multi-Agent MC-LSPI/Politex}.
From \cref{lemma:bound on core set size} we know the core set size is bounded by $C_\text{max} = \tilde \mathcal{O}(d)$.
The total number of times Policy iteration is thus at most $C_\text{max}$.
Each run of policy iteration can take as much as $K$ iterations.
In each iteration \textsc{MA-Confident Rollout} is run at most $C_\text{max}$ times.
\textsc{MA-Confident Rollout} does $n$ rollouts of length $H$ which queries the simulator once for each step.
In total the number of queries performed by \textsc{Confident Multi-Agent MC-LSPI/Politex} is bounded by $C_\text{max}^2 K n H$.
This equation is used to calculate the query cost for the different variants of \textsc{Confident Multi-Agent MC-LSPI/Politex}, once all the parameter values have been calculated.
\subsection{Proof of \cref{thm:ma-mc-lspi sub-optimality}}
Plugging in $\eta=\eta_1$ when \textsc{Uncertainty Check with DAV} is used ($\eta_1$ as defined in \ref{prop: approx value function bound for DAV}) and $\eta=\eta_2$ when \textsc{Uncertainty Check with EGSS} is used ($\eta_2$ as defined in \ref{prop: approx value function bound for EGSS}) into Proposition \ref{prop:optimality of output policy}.
Setting $z=2m-1$ when \textsc{Uncertainty Check with DAV} is used, and $z = \sqrt{d}$ when \textsc{Uncertainty Check with EGSS} is used.
Suppose assumption \ref{ass: feature decomposition} is satisfied with $\epsilon=0$.
By choosing appropriate parameters according to $\delta$ and $\kappa$, we can ensure that with probability at least $1 - \delta$ that the policy output by \textsc{Confident Multi-Agent MC-LSPI} $\pi_{K-1}$ satisfies:
\begin{align*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \kappa,
\end{align*}
with the following parameter initialization (see \ref{sec:parameter mclsipi-dav})
\begin{align*}
\tau &= 1\\
\lambda &= \frac{\kappa^2(1 - \gamma)^4}{1024 b^2 z^2}\\
\theta &= \frac{\kappa(1- \gamma)^2}{32 z \sqrt{C_{\text{max}}}}\\
H &= \frac{
\log \left ( 32 \sqrt{C_{\text{max}}} z \right)
- \log \left( \kappa(1 - \gamma)^3 \right)
}{
1-\gamma
} - 1\\
K &= \frac{\log\left(\frac{1}{\kappa(1 - \gamma)^2}\right) + \log(8)}{1-\gamma} + 1 \\
n &= \frac{\log(\delta) - \log(4KC_{\text{max}}^2)}{2 \theta^2(1-\gamma)^2} \\
C_{\max} &= \frac{e}{e-1} \frac{1 + \tau}{\tau} d \left(
\log(1 + \frac{1}{\tau}) +
\log(1 + \frac{m}{\lambda})
\right)
\end{align*}
with computational cost of $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}), \log(b), m, |\mathcal{A}|)$.
and query cost $\mathcal{O}\left(\tfrac{z^2 d^3}{\kappa^2 (1-\gamma)^8} \right)$
Suppose assumption \ref{ass: feature decomposition} is satisfied with $\epsilon \neq 0$,
By choosing parameters as above, with $\kappa = \frac{32 \epsilon \sqrt{d} z}{(1-\gamma)^2} (1 + \log(m b^2 \epsilon^{-2} d^{-1}))^{1/2}$, we can ensure that with probability of at least $1 - \delta$ that the policy output by \textsc{Confident Multi-Agent MC-LSPI} $\pi_{K-1}$ satisfies:
$$V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \frac{64 \epsilon \sqrt{d} z}{(1-\gamma)^2} (1 +\log(1+m b^2 \epsilon^{-2} d^{-1}))^{1/2}$$
with computational cost of $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}), \log(b), m, |\mathcal{A}|)$.
and query cost $\mathcal{O}\left(\tfrac{d^2}{\epsilon^2 (1-\gamma)^4} \right)$
Moreover, the above results also holds under \cref{ass: argmax oracle} when \textsc{Uncertainty Check with EGSS} is used.
\subsection{Proof of \cref{thm:ma-mc-politex sub-optimality}}
Plugging in $\eta=\eta_1$ when \textsc{Uncertainty Check with DAV} is used ($\eta_1$ as defined in \ref{prop: approx value function bound for DAV}) and $\eta=\eta_2$ when \textsc{Uncertainty Check with EGSS} is used ($\eta_2$ as defined in \ref{prop: approx value function bound for EGSS}) into \cref{eq:politex actual optimality of output policy}.
Setting $z=2m-1$ when \textsc{Uncertainty Check with DAV} is used, and $z = \sqrt{d}$ when \textsc{Uncertainty Check with EGSS} is used.
Suppose assumption \ref{ass: feature decomposition} is satisfied with $\epsilon=0$.
By choosing appropriate parameters according to $\delta$ and $\kappa$, we can ensure that with probability at least $1 - \delta$ that the policy output by \textsc{Confident Multi-Agent MC-Politex} $\pi_{K-1}$ satisfies:
\begin{align*}
V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \kappa,
\end{align*}
with the following parameter initialization (see \ref{sec:parameter mclsipi-dav})
\begin{align*}
\tau &= 1\\
\lambda &= \frac{\kappa^2(1 - \gamma)^2}{576 b^2 z^2}\\
\theta &= \frac{\kappa(1- \gamma)}{24 z \sqrt{C_{\text{max}}}}\\
H &= \frac{
\log \left ( 24 \sqrt{C_{\text{max}}} z \right)
- \log \left( \kappa(1 - \gamma)^2 \right)
}{
1-\gamma
} - 1\\
K &= 2m \log(A) \left( \frac{4}{\kappa^2 (1-\gamma)^4} + \frac{3}{\kappa (1-\gamma)^2} + \frac{9}{16} \right)\\
n &= \frac{\log(\delta) - \log(4KC_{\text{max}}^2)}{2 \theta^2(1-\gamma)^2} \\
C_{\max} &= \frac{e}{e-1} \frac{1 + \tau}{\tau} d \left(
\log(1 + \frac{1}{\tau}) +
\log(1 + \frac{m}{\lambda})
\right)
\end{align*}
with computational cost of $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}), \log(b), m, |\mathcal{A}|)$.
and query cost $\mathcal{O}\left(\tfrac{m z^2 d^3}{\kappa^4 (1-\gamma)^9} \right)$
Suppose assumption \ref{ass: feature decomposition} is satisfied with $\epsilon \neq 0$,
By choosing parameters as above, with $\kappa = \frac{16 \epsilon \sqrt{d} z}{(1-\gamma)} (1 + \log(m b^2 \epsilon^{-2} d^{-1}))^{1/2}$, we can ensure that with probability of at least $1 - \delta$ that the policy output by \textsc{Confident Multi-Agent MC-Politex} $\pi_{K-1}$ satisfies:
$$V^*(\rho) - V_{\pi_{K-1}}(\rho) \leq \frac{32 \epsilon \sqrt{d} z}{(1-\gamma)^2} (1 +\log(1+m b^2 \epsilon^{-2} d^{-1}))^{1/2}$$
with computational cost of $\text{poly}(d, \frac{1}{1 - \gamma}, \frac{1}{\kappa}, \log(\frac{1}{\delta}), \log(b), m, |\mathcal{A}|)$.
and query cost $\mathcal{O}\left(\tfrac{m d}{\epsilon^4 (1-\gamma)^5} \right)$
\section{Kernel Setting} \label{app:kernel setting}
The kernelized setting is a standard extension of the finite-dimensional linear setup \citep{srinivas2009gaussian,abbasi2012online}. It lifts the restriction that features and parameter vector are elements of $\mathbb{R}^d$. Instead we require that the $Q_\pi$-function is contained in a reproducing kernel Hilbert space (RKHS). This includes cases where the linear dimension of function class is infinite.
The more general setup requires us to address two main challenges: First, the scaling of the sample complexity with the dimension $d$ needs to be improved to a notion of effective dimension that can be bounded for the RKHS of interest. Second, computationally we cannot directly work with infinite dimensional features $\phi(s,a)$. Instead, we need to rely on the `kernel trick' and compute all quantities of interest in the finite-dimensional data space.
Formally for each agent $j \in [m]$, the function $k^{(j)} : (\mathcal{S} \times \mathcal{A}^{(1:m)})^2 \rightarrow \mathbb{R}$ is defined as
\begin{align}
k^{(j)}(s_1, a_1^{(1:m)}, s_2, a_2^{(1:m)}) = k_j(s_1, a_1^{(j)}, s_2, a_2^{(j)}), \label{eq:rkhs_j}
\end{align}
where $k_j: (\mathcal{S} \times \mathcal{A})^2 \rightarrow \mathbb{R}$ is the underlying kernel function for agent $j$,
and $\mathcal{H}_j$ is the RKHS associated with it.
Based on definition \eqref{eq:rkhs_j}, it's easy to see that $\{k^{(j)}\}_{j \in [m]}$ is a set of kernel functions too, and they share the same vector space which is $V := \mathbb{R}^{\mathcal{S} \times \mathcal{A}^{(1:m)}}$.
However, they have different inner products on this space which produce a different RKHS for every $j \in [m]$.
We denote RKHS of $k^{(j)}$ as $\mathcal{H}^{(j)}$, and its inner product follows from equation \eqref{eq:rkhs_j} as
\begin{align}
\langle k^{(j)}(s_1, a_1^{(1:m)}, \cdot, \cdot), k^{(j)}(s_2, a_2^{(1:m)}, \cdot, \cdot) \rangle_{\mathcal{H}^{(j)}} =
\langle k_j(s_1, a_1^{(j)}, \cdot, \cdot), k_j(s_2, a_2^{(j)}, \cdot, \cdot) \rangle_{\mathcal{H}_j}. \label{eq:rkhs-inner-1}
\end{align}
By defining $\phi_j(s, a) := k_j(s,a, \cdot, \cdot) \in \mathcal{H}_j$ and $\phi^{(j)}(s, a^{(1:m)}) := k^{(j)}(s, a^{(1:m)}, \cdot, \cdot) \in \mathcal{H}^{(j)}$, we can rewrite \eqref{eq:rkhs-inner-1} for fixed $s_1, s_2, a_1^{(1:m)}, a_2^{(1:m)}$ as
\begin{align}
\langle \phi^{(j)}(s_1, a_1^{(1:m)}), \phi^{(j)}(s_2, a_2^{(1:m)}) \rangle_{\mathcal{H}^{(j)}} &=
\langle \phi_j(s_1, a_1^{(j)}), \phi_j(s_2, a_2^{(j)})\rangle_{\mathcal{H}_j}.\label{eq:rkhs-inner-1-rev}
\end{align}
Intuitively, equation \eqref{eq:rkhs-inner-1-rev} suggests that the inner product $\langle \cdot, \cdot \rangle_{H^{(j)}}$ only depends on the state $s$, and the action taken by agent $j$.
Next, we define the joint additive kernel $k : (\mathcal{S} \times \mathcal{A}^{(1:m)})^2 \rightarrow \mathbb{R}$ as follows
\begin{align}
k(s_1,a_1^{(1:m)}, s_2,a_2^{(1:m)}) &= \sum_{j=1}^m k^{(j)}(s_1,a_1^{(1:m)}, s_2,a_2^{(1:m)}) \label{eq:jak-def}\\
&= \sum_{j=1}^m k_j(s_1,a_1^{(j)}, s_2,a_2^{(j)})\\
&= \sum_{j=1}^m \langle k_j(s_1,a_1^{(j)}, \cdot, \cdot), k_j(s_2,a_2^{(j)}, \cdot, \cdot) \rangle_{\mathcal{H}_j},
\end{align}
and we denote its associated RKHS as $\mathcal{H}$. Again, note that $\mathcal{H}$ uses the same vector space, namely $V$, as all the $\mathcal{H}^{(j)}$s.
Now, we can restate Assumption for the kernel case.
TODO: I think we still want to solve the problem under assumption one for the kernel case, right?\ref{ass: feature decomposition}
\begin{assumption}[Assumption 1 for RKHS]
\label{ass:kernel-2}
For each (deterministic) policy $\pi$, there exists
$f_\pi \in \mathcal{H}$, such that
$Q_\pi(s, a^{(1:m)}) = \langle \phi(s,a^{(1:m)}), f_\pi \rangle_{\mathcal{H}}$.
\end{assumption}
Next, we show that there exist a function $f_\pi^\ag{i} \in \mathcal{H}^\ag{i}$ for $i \in [m]$, such that:
\begin{align*}
Q_\pi (s, a^{(1:m)}) &= \sum_{j=1}^m Q_\pi^{(j)}(s, a^{(1:m)})\\
Q_\pi^\ag{i} (s, a^{(1:m)}) &= \langle \phi^\ag{i}(s,a^{(1:m)}), f_\pi^\ag{i} \rangle_{\mathcal{H}^\ag{i}}
\end{align*}
Or, there exist $f_{\pi, j} \in \mathcal{H}_j$ for $j \in \mathcal{H}_j$, such that:
\begin{align*}
Q_\pi (s, a^{(1:m)}) &= \sum_{j=1}^m Q_{\pi,j}(s, a^{(j)})\\
Q_\pi^\ag{i} (s, a^{(1:m)}) &= \langle \phi^\ag{i}(s,a^{(1:m)}), f_{\pi,j} \rangle_{\mathcal{H}^\ag{i}}
\end{align*}
\begin{proof}
As $f_\pi$ is an element of $\mathcal{H}$ we know that it can be shown based on the basis vectors of $\mathcal{H}$:
\begin{align*}
f_\pi = \sum_{i=1}^{\infty} \alpha_i k(s_i, a_i, \cdot, \cdot).
\end{align*}
From the definition of the joint additive kernel and the assumption \ref{ass:kernel-2} we have:
\begin{align}
Q_\pi (s, a^{(1:m)}) &= \langle \phi(s,a^{(1:m)}), f_\pi \rangle_{\mathcal{H}} \nonumber \\
&= \langle \phi(s,a^{(1:m)}), \sum_{i=1}^{\infty} \alpha_i k(s_i, a_i, \cdot, \cdot) \rangle_{\mathcal{H}} \nonumber \\
&= \sum_{i=1}^{\infty} \alpha_i \langle k(s,a^{(1:m)}, \cdot, \cdot), k(s_i, a_i, \cdot, \cdot) \rangle_{\mathcal{H}} \nonumber \\
&= \sum_{i=1}^{\infty} \alpha_i k(s,a^{(1:m)}, s_i, a_i) \nonumber \\
&= \sum_{i=1}^{\infty} \alpha_i \sum_{j=1}^m k^{(j)}(s,a^{(1:m)}, s_i, a_i) & \text{Based on }\ref{eq:jak-def}\label{eq:checkpoint}\\
&= \sum_{j=1}^m \sum_{i=1}^{\infty} \alpha_i k^{(j)}(s,a^{(1:m)}, s_i, a_i) \nonumber \\
&= \sum_{j=1}^m \sum_{i=1}^{\infty} \alpha_i \langle \phi^{(j)}(s,a^{(1:m)}) , \phi^{(j)}(s_i, a_i) \rangle_{\mathcal{H}^{(j)}} \nonumber\\
&= \sum_{j=1}^m \langle \phi^{(j)}(s,a^{(1:m)}) , \underbrace{\sum_{i=1}^{\infty} \alpha_i \phi^{(j)}(s_i, a_i)}_{:=E^{(j)}(f_\pi) := f_\pi^\ag{i}} \rangle_{\mathcal{H}^{(j)}} \nonumber \\
&= \sum_{j=1}^{m} \langle \phi^{(j)}(s,a^{(1:m)}), f_\pi^{(j)} \rangle_{\mathcal{H}^{(j)}}. \nonumber
\end{align}
or from \eqref{eq:checkpoint} we have:
\begin{align*}
Q_\pi (s, a^{(1:m)})
&= \sum_{i=1}^{\infty} \alpha_i \sum_{j=1}^m k^{(j)}(s,a^{(1:m)}, s_i, a_i) \\
&= \sum_{i=1}^{\infty} \alpha_i \sum_{j=1}^m k_j(s,a^{(j)}, s_i, a_i^{(j)}) & \text{Based on }\ref{eq:rkhs_j}\\
&= \sum_{i=1}^{\infty} \alpha_i \sum_{j=1}^m \langle \phi_j(s,a^{(j)}), \phi_j(s_i, a_i^{(j)}) \rangle_{\mathcal{H}_j}\\
&= \sum_{j=1}^m \langle
\phi_j(s,a^{(j)}),
\underbrace{
\sum_{i=1}^{\infty} \alpha_i \phi_j(s_i, a_i^{(j)})
}_{:=E_j(f_\pi) :=f_{\pi, j}}
\rangle_{\mathcal{H}_j}\\
&= \sum_{j=1}^m \langle
\phi_j(s,a^{(j)}),
f_{\pi, j}
\rangle_{\mathcal{H}_j}.
\end{align*}
We may need to show that $f_\pi^{j}$ and $f_{\pi, j}$ have finite norms in their corresponding Hilbert spaces.
\end{proof}
\paragraph{Kernelized Algorithm}
As before we can compute the ridge estimate
\begin{align}
\hat Q_t = \argmin_{Q \in \mathcal{H}} \sum_{(s,a^{(1:m)})\in\mathcal{C}_t} (Q(s,a^{(1:m)}) - q_{(s,a^{(1:m)})})^2 + \lambda \|Q\|_{\mathcal{H}}^2 = (\Phi_{\mathcal{C}_t}\Phi_{\mathcal{C}_t}^\top + \lambda \mathbf{I}_\mathcal{H})^{-1}\Phi_{\mathcal{C}_t}q_{\mathcal{C}_t}
\end{align}
Here, $\mathbf{I}_{\mathcal{H}} : \mathcal{H} \rightarrow \mathcal{H}$ is the identity mapping, and $\Phi_{\mathcal{C}}^\top$ can be formally defined as map $\Phi_\mathcal{C}^\top : \mathcal{H} \rightarrow \mathbb{R}^{|\mathcal{C}|}, f \mapsto [f(s,a^{(1:m)})]_{(s,a^{(1:m)}) \in \mathcal{C}}, \, f \in \mathcal{H}$; and $\Phi_{\mathcal{C}} : \mathbb{R}^{|\mathcal{C}|} \rightarrow \mathcal{H}$ is the adjoint of $\Phi_{\mathcal{C}}^\top$.
Using the `kernel trick' we express the estimator as follows
\begin{align}
\hat Q_t = \Phi_{\mathcal{C}_t}(K_{\mathcal{C}_t} + \lambda \mathbf{I}_{t})^{-1}q_{\mathcal{C}_t}
\end{align}
where $K_{\mathcal{C}_t} = \Phi_{\mathcal{C}_t}^\top \Phi_{\mathcal{C}_t} \in \mathbb{R}^{t \times t}$ is the kernel matrix. Lastly, we can evaluate for any $s,a^{(1:m)}$:
\begin{align}
\hat Q_t(s,a^{(1:m)}) = k_{\mathcal{C}_t}(s,a^{(1:m)})^\top(K_{\mathcal{C}_t} + \lambda \mathbf{I}_{t})^{-1}q_{\mathcal{C}_t}
\end{align}
where we defined $k_\mathcal{C}(s,a^{(1:m)}) = [k(s,a^{(1:m)}, s',a'^{(1:m)})]_{(s',a'^{(1:m)}) \in \mathcal{C}} \in \mathbb{R}^{|\mathcal{C}|}$ (for some fixed ordering of $\mathcal{C}$). Importantly, the last display only involves finite-dimensional quantities that can be computed from kernel evaluations. Moreover, since $k(s,a^{(1:m)},s',a'^{(1:m)}) = \sum_{j=1}^m k_j(s,a^{(j)}, s', a^{(j)})$ we can write
\begin{align}
\hat Q_t(s,a^{(1:m)}) = \sum_{j=1}^m k_{j, \mathcal{C}_t}(s,a^{(j)})^\top(K_{\mathcal{C}_t} + \lambda \mathbf{I}_{t})^{-1}q_{\mathcal{C}_t}
\end{align}
where $k_{j, \mathcal{C}}(s,a^{(j)}) = [k_j(s,a^{(j)}, s^\prime , a^{\prime(j)})]_{(s^\prime, a^{\prime(1:m)}) \in \mathcal{C}} \in \mathbb{R}^{|\mathcal{C}|}$. Hence we can still compute the maximizer independently for each agent.
The second quantity required by the algorithm is the squared norm $\|\phi(s,a^{(1:m)})\|_{(\Phi_\mathcal{C} \Phi_{\mathcal{C}}^\top + \lambda \mathbf{I}_\mathcal{H})^{-1}}^2$, where now $\phi(s,a^{(1:m)}) = k(s,a^{(1:m)}, \cdot, \cdot) \in \mathcal{H}$. Using the Woodbury identity, we can write
\begin{align}
\lambda (\Phi_\mathcal{C} \Phi_{\mathcal{C}}^\top + \lambda \mathbf{I}_\mathcal{H})^{-1} = \mathbf{I}_{\mathcal{H}} - \Phi_{\mathcal{C}} (K_\mathcal{C} + \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}\Phi_{\mathcal{C}}^\top
\end{align}
Therefore the feature norm can be written using finite-dimensional quantities:
\begin{align}
\|\phi(s,a^{(1:m)})\|_{(\Phi_\mathcal{C} \Phi_{\mathcal{C}}^\top + \lambda \mathbf{I}_\mathcal{H})^{-1}}^2 = \frac{1}{\lambda} \left( k(s,a^{(1:m)},s,a^{(1:m)}) - k_\mathcal{C}(s,a^{(1:m)})^\top(K_\mathcal{C}+ \lambda \mathbf{I}_{|\mathcal{C}|})^{-1}k_{\mathcal{C}}(s,a^{(1:m)})\right)
\end{align}
With this, we can implement the DAV version of the algorithm directly. The EGSS is more tricky to implement, but this is potentially possible using eigenfunctions from Mercer's theorem.
\paragraph{Analysis}
Our goal next is to extend the analysis to the kernel case, carefully arguing that the linear dimension $d$ can be replaced by a more benign quantity. A common complexity measure is the total information gain, which we define as follows:
\begin{align}
\Gamma_{\mathcal{C}} = \log \det (\Phi_{\mathcal{C}}\Phi_{\mathcal{C}}^\top + \lambda \mathbf{I}_d) - \log \det (\lambda \mathbf{I}_d)
\end{align}
Note that we can compute $\Gamma_{\mathcal{C}}$ for any given core set $\mathcal{C}$. In the kernel case, we can compute $\Gamma_{\mathcal{C}} = \log \det (\mathbf{I}_{|\mathcal{C}|} + \lambda^{-1} K_{\mathcal{C}})$ using similar arguments as before.
The maximum information gain is $\Gamma_t = \max_{\mathcal{C} : |\mathcal{C}|=t} \Gamma_{\mathcal{C}}$. It serves as a complexity measure in the bandit literature and can be bounded for many kernels of interests \citep{srinivas2009gaussian,vakili2021information}. Following \citet{du2021bilinear}, we further define the \emph{critical information gain},
\begin{align}
\tilde \Gamma = \max \{t \geq 1 : t \leq \Gamma_t \}
\end{align}
Note that the proof of \cite[Lemma 5.1]{yin2021efficient} implies that $|C| \leq \log(1+\tau)^{-1}\Gamma_{|C|}$
Since the dimension $d$ enters our bounds only through $C_{\max}$ we can immediately get a sample complexity bound for the kernelized algorithm in terms of $\tilde\Gamma$. For the finite-dimensional case, \cite[Lemma 5.1]{yin2021efficient} shows that $\tilde \Gamma \leq \mathcal{O}(d)$, recovering the previous bound.
\paragraph{Unknown Critical Information Gain} Somewhat impractical for the algorithm is that we need to know a bound on $C_{\max}$ or $\tilde \Gamma$ respectively to set the number of episodes required for some target level of accuracy $\kappa > 0$ (roughly, $m = C_{\max}/\kappa^2$).
As a remedy, we can replace the check $\|\phi(s,a)\|_{(\Phi_\mathcal{C} \Phi_{\mathcal{C}} + \lambda \mathbf{I}_d)^{-1}}^2 > \tau$ by
TODO: this needs some more thinking, as we don't want to set $\tau$ to be too small - maybe? An easier approach could be to set $m = |\mathcal{C}|/\kappa^2$?
\begin{align*}
\|\phi(s,a)\|_{(\Phi_\mathcal{C} \Phi_{\mathcal{C}} + \lambda \mathbf{I}_d)^{-1}}^2 > \frac{\tilde \tau}{\max(\Gamma_{\mathcal{C}},1)}
\end{align*}
Let $\mathcal{C}_1, \dots, \mathcal{C}_t$ be the sequence of core sets obtained by adding elements that satisfy the above condition. Note that $\Gamma(\mathcal{C}_t)$ is a non-decreasing sequence. Combined with \citep[Lemma 5.1]{yin2021efficient} , this implies that
\begin{align}
t \log\left(1 + \tfrac{\tilde \tau}{\max(\Gamma_t,1)}\right) \leq t \log\left(1 + \tfrac{\tilde \tau}{\max( \Gamma_{\mathcal{C}_{t}}, 1)}\right) \leq \sum_{s=1}^t \log\left(1 + \tfrac{\tilde \tau}{\max(\Gamma_{\mathcal{C}_{s}},1)}\right) \leq \Gamma_{\mathcal{C}_{t}} \leq \Gamma_t\label{eq:cmax adaptiv}
\end{align}
Hence the condition is triggered at most
\begin{align}
\tilde C_{\max}(\tilde \tau) = \max \left\{t \geq 1 : t \leq \Gamma_t \log\left(1 + \tfrac{\tilde \tau}{\max(\Gamma_t, 1)} \right)^{-1}\right\}
\end{align}
times.
TODO: Would be great to show some bounds for $\tilde C_{\max}$, e.g. in the finite-dimensional case
Moreover, we can set $\tilde \tau=1$ and $m = \frac{1}{\kappa^2}$ (i.e.~without knowing a bound on $C_{\max}$) to obtain the required target accuracy $\tilde \mathcal{O}(\kappa)$.
TODO: this requires some introspection of \citep[Lemma B.2]{yin2021efficient} and \eqref{eq:cmax adaptiv}
\subsection{We need to prove that if we add a state-action pair to the core set, it remains in the good set in future.}
\begin{theorem}
Assume that $\Phi_\mathcal{C} \in \mathbb{R}^{t \times d}$, $V_\mathcal{C} = \Phi_\mathcal{C}^\top \Phi_\mathcal{C} + \lambda I$, and $\phi_{t+1} \in \mathbb{R}^d$. Define $\hat \Phi = [\Phi^\top \, \phi_{t+1}]^\top$,
and $\hat V_\mathcal{C} = \hat{\Phi}_\mathcal{C}^\top \hat{\Phi}_\mathcal{C} + \lambda I$.
Then we have:
\begin{align*}
\| \phi_{t+1} \|_{\hat V_\mathcal{C}^{-1}} < 1
\end{align*}
\end{theorem}
\begin{proof}
By the definition of the norm we have:
\[
\begin{aligned}
\| \phi_{t+1} \|_{\hat{V}_\mathcal{C}^{-1}} &= \phi_{t+1}^\top \hat{V}_\mathcal{C}^{-1} \phi_{t+1}\\
&= \phi_{t+1}^\top \left(
\hat{\Phi}_\mathcal{C}^\top \hat{\Phi}_\mathcal{C} + \lambda I
\right)^{-1} \phi_{t+1}\\
&= \phi_{t+1}^\top \left (
\sum_{i = 1}^{t+1} \phi_i \phi_i^\top
+ \lambda I
\right)^{-1} \phi_{t+1}\\
&= \phi_{t+1}^\top \left (
\sum_{i = 1}^{t} \phi_i \phi_i^\top
+ \lambda I
+ \phi_{t+1} \phi_{t+1}^\top
\right)^{-1} \phi_{t+1}\\
&= \phi_{t+1}^\top \left (
V_\mathcal{C}
+ \phi_{t+1} \phi_{t+1}^\top
\right)^{-1} \phi_{t+1}\\
&= \phi_{t+1}^\top \left (
V_\mathcal{C}^{-1}
- \frac{V_\mathcal{C}^{-1} \phi_{t+1} \phi_{t+1}^\top V_\mathcal{C}^{-1}}{1 + \phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1}^\top}
\right) \phi_{t+1} & \text{Sherman-Morrison}\\
&= \phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1}
- \frac{
\phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1} \phi_{t+1}^\top V_\mathcal{C}^{-1}\phi_{t+1}
}{
1 + \phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1}
}
\\
&= \frac{
\phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1}
}{
1 + \phi_{t+1}^\top V_\mathcal{C}^{-1} \phi_{t+1}
}\\
&< 1
\\
\end{aligned}
\]
\end{proof}
Therefore, if we set $\tau \geq 1$, then none of the features that have been added to the core set can produce $V_\mathcal{C}^{-1}$-norm greater than $\tau$, so they remain in the good set.
\section*{Parameter Assignments} \label{app:parameter assignments}
\subsection{MCLSPI-DAV}
\label{sec:parameter mclsipi-dav}
The total error is the following:
\begin{align}
\frac{8 \eta_1}{(1 - \gamma)^2} + \frac{2 \gamma^{K - 1}}{(1 - \gamma)^2} &\leq \kappa \label{eq:egss-main} \\
\frac{8}{(1 - \gamma)^2}
\left(
b\sqrt{\lambda \tau} + \left( \frac{\gamma^{H+1}}{1 - \gamma} + \theta \right) \sqrt{ \tau C_{\text{max}}}
\right)(2m-1) +
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2}
&\leq \kappa \nonumber \\
&\Rightarrow \nonumber \\
\frac{8(2m-1)}{(1 - \gamma)^2} b\sqrt{\lambda \tau} & \leq \frac{\kappa}{4} \label{eq:egss-lambda}\\
\frac{8\sqrt{ \tau C_{\text{max}}}(2m-1)}{(1 - \gamma)^2} \frac{\gamma^{H+1}}{1 - \gamma} & \leq \frac{\kappa}{4} \label{eq:egss-H}\\
\frac{8\sqrt{ \tau C_{\text{max}}}(2m-1)}{(1 - \gamma)^2} \theta & \leq \frac{\kappa}{4} \label{eq:egss-theta}\\
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2} & \leq \frac{\kappa}{4} \label{eq:egss-K}
\end{align}
First we assume that $\tau = 1$.
From \eqref{eq:egss-lambda} we get:
\begin{align*}
\frac{8(2m - 1)}{(1 - \gamma)^2} b\sqrt{\lambda } & \leq \frac{\kappa}{4} \\
\sqrt{\lambda } &\leq \frac{(1 - \gamma)^2\kappa}{32 b (2m -1)}\\
\lambda &\leq \frac{(1 - \gamma)^4\kappa^2}{1024 b^2 (2m -1)^2}\\
\end{align*}
From \eqref{eq:egss-H} we get:
\begin{align*}
\frac{8\sqrt{ C_{\text{max}}}(2m -1)}{(1 - \gamma)^3} \gamma^{H+1} & \leq \frac{\kappa}{4} \\
(2m -1) \sqrt{C_{\text{max}}} \gamma^{H+1} & \leq \frac{\kappa(1 - \gamma)^3}{32} \\
\gamma^{H+1} & \leq \frac{\kappa(1 - \gamma)^3}{32 \sqrt{C_{\text{max}}} (2m - 1)} \\
H & \geq \frac{\log\left (\frac{\kappa(1 - \gamma)^3}{32 \sqrt{C_{\text{max}}} (2m - 1)} \right)}{
\log(\gamma)
} - 1\\
\end{align*}
From \eqref{eq:egss-theta} we get:
\begin{align*}
\frac{8\sqrt{ C_{\text{max}}}(2m-1)}{(1 - \gamma)^2} \theta & \leq \frac{\kappa}{4}\\
(2m-1) \sqrt{C_{\text{max}}} \theta & \leq \frac{\kappa(1- \gamma)^2}{32}\\
\theta & \leq \frac{\kappa(1- \gamma)^2}{32 (2m-1) \sqrt{C_{\text{max}}}}\\
\end{align*}
From \eqref{eq:egss-K} we get:
\begin{align*}
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2} & \leq \frac{\kappa}{4}\\
\gamma^{K - 1} & \leq \frac{\kappa(1 - \gamma)^2}{8}\\
K & \leq \frac{\log \left( \frac{\kappa(1 - \gamma)^2}{8} \right)}{\log(\gamma)} + 1\\
K & \leq \frac{\log\left(\kappa(1 - \gamma)^2\right) - \log(8)}{\log(\gamma)} + 1\\
\end{align*}
We know that \eqref{eq:egss-main} holds with probability at least $1 - 2KC_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$.
Therefore from that the rest of values we get:
\begin{align*}
2KC_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n) &\leq \delta\\
\exp(-2 \theta^2(1-\gamma)^2 n) &\leq \frac{\delta}{2KC_{\text{max}}}\\
-2 \theta^2(1-\gamma)^2 n &\leq log( \frac{\delta}{2KC_{\text{max}}})\\
n &\geq \frac{log(\delta) - \log(2KC_{\text{max}})}{2 \theta^2(1-\gamma)^2}\\
\end{align*}
\subsection{MCLSPI-EGSS}
\label{sec:parameter mclspi-egss}
The total error is the following:
\begin{align}
\frac{8 \eta_2}{(1 - \gamma)^2} + \frac{2 \gamma^{K - 1}}{(1 - \gamma)^2} &\leq \kappa \label{eq:dav-main} \\
\frac{8}{(1 - \gamma)^2}
\left(
b\sqrt{\lambda \tau} + \left( \frac{\gamma^{H+1}}{1 - \gamma} + \theta \right) \sqrt{ \tau C_{\text{max}}}
\right) +
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2}
&\leq \kappa \nonumber \\
&\Rightarrow \nonumber \\
\frac{8}{(1 - \gamma)^2} b\sqrt{\lambda \tau} & \leq \frac{\kappa}{4} \label{eq:dav-lambda}\\
\frac{8\sqrt{ \tau C_{\text{max}}}}{(1 - \gamma)^2} \frac{\gamma^{H+1}}{1 - \gamma} & \leq \frac{\kappa}{4} \label{eq:dav-H}\\
\frac{8\sqrt{ \tau C_{\text{max}}}}{(1 - \gamma)^2} \theta & \leq \frac{\kappa}{4} \label{eq:dav-theta}\\
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2} & \leq \frac{\kappa}{4} \label{eq:dav-K}
\end{align}
First we assume that $\tau = 1$.
From \eqref{eq:dav-lambda} we get:
\begin{align*}
\frac{8}{(1 - \gamma)^2} b\sqrt{\lambda } & \leq \frac{\kappa}{4} \\
\sqrt{\lambda } &\leq \frac{(1 - \gamma)^2\kappa}{32 b}\\
\lambda &\leq \frac{(1 - \gamma)^4\kappa^2}{1024 b^2 }\\
\end{align*}
From \eqref{eq:dav-H} we get:
\begin{align*}
\frac{8\sqrt{ C_{\text{max}}}}{(1 - \gamma)^3} \gamma^{H+1} & \leq \frac{\kappa}{4} \\
d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}} \gamma^{H+1} & \leq \frac{\kappa(1 - \gamma)^3}{32} \\
\gamma^{H+1} & \leq \frac{\kappa(1 - \gamma)^3}{32 d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}}} \\
H & \geq \frac{\log\left (\frac{\kappa(1 - \gamma)^3}{32 d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}}} \right)}{
\log(\gamma)
} - 1\\
\end{align*}
From \eqref{eq:dav-theta} we get:
\begin{align*}
\frac{8\sqrt{C_{\text{max}}}}{(1 - \gamma)^2} \theta & \leq \frac{\kappa}{4}\\
d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}} \theta & \leq \frac{\kappa(1- \gamma)^2}{32}\\
\theta & \leq \frac{\kappa(1- \gamma)^2}{32 d^{\frac{1}{4}} C_{\text{max}}^{\frac{1}{2}}}\\
\end{align*}
From \eqref{eq:dav-K} we get:
\begin{align*}
\frac{2\gamma^{K - 1}}{(1 - \gamma)^2} & \leq \frac{\kappa}{4}\\
\gamma^{K - 1} & \leq \frac{\kappa(1 - \gamma)^2}{8}\\
K & \leq \frac{\log \left( \frac{\kappa(1 - \gamma)^2}{8} \right)}{\log(\gamma)} + 1\\
K & \leq \frac{\log\left(\kappa(1 - \gamma)^2\right) - \log(8)}{\log(\gamma)} + 1\\
\end{align*}
We know that \eqref{eq:dav-main} holds with probability at least $1 - 2KC_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n)$.
Therefore from that the rest of values we get:
\begin{align*}
2KC_{\text{max}} \exp(-2 \theta^2(1-\gamma)^2 n) &\leq \delta\\
\exp(-2 \theta^2(1-\gamma)^2 n) &\leq \frac{\delta}{2KC_{\text{max}}}\\
-2 \theta^2(1-\gamma)^2 n &\leq \log( \frac{\delta}{2KC_{\text{max}}})\\
n &\geq \frac{\log(\delta) - \log(2KC_{\text{max}})}{2 \theta^2(1-\gamma)^2}\\
\end{align*}
\end{document}
| {'timestamp': '2023-02-10T02:03:33', 'yymm': '2302', 'arxiv_id': '2302.04376', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04376'} | arxiv |
\section{Introduction}
\label{intro}
There is no universal definition of homelessness. In general, homelessness is the condition of lacking stable, safe, and adequate housing. In 2004, the United Nations sector of Economic and Social Affairs defined a homeless household as \textit{households without a shelter that would fall within the scope of living quarters. They carry their few possessions with them, sleeping in the streets, in doorways or on piers, or in any other space, on a more or less random basis.}\cite{UN2004}.
In 2009, at the United Nations Economic Commission for Europe Conference of European Statisticians (CES), held in Geneva, Switzerland, the Group of Experts on Population and Housing Censuses defined homelessness as follows:
In its Recommendations for the Censuses of Population and Housing, the CES identifies homeless people under two broad groups:
\begin{itemize}
\item[(a)] Primary homelessness (or rooflessness). This category includes persons living in the streets without a shelter that would fall within the scope of living quarters;
\item[(b)] Secondary homelessness. This category may include persons with no place of usual residence who frequently move between various types of accommodations (including dwellings, shelters, and institutions for the homeless or other living quarters). This category includes persons living in private dwellings but reporting ``no usual address'' on their census form.
\end{itemize}
The CES acknowledges that the above approach does not provide a full definition of the ``homeless'' \cite{UN2009}.
The problem of homelessness has attracted the attention of researchers since the 1980-s. Many researchers like \cite{Crane1998}, \cite{Avramov2001} or \cite{Collin1992} studied homelessness as primarily a housing problem. Others like \cite{Dear2014} or \cite{Wennig1991} studied homelessness among people with mental diseases attributing it to deinstitutionalizing state mental hospitals and reducing public expenditures on welfare. Many other aspects of homelessness were studied, providing various aggregate data on homelessness. There is much research on the key factors and areas that could be addressed to prevent homelessness; see, for example, \cite{Cunningham2006}, or \cite{Rukmana2010}. \cite{Oflaherty2004}, or \cite{Byrne2013} provide a meta-analysis of various previous research results and list variables negatively and positively affecting homelessness rates. For the recent meta-analysis, we address the reader to \cite{Rukmana2020}. This paper points out that many aspects of the homelessness problem and approaches to helping homeless people, as well as preventing homelessness, heavily depend on the country and local specifics.
In many developing countries, the homelessness problem is often practically addressed by charity and non-government organizations (NGOs) in parallel with the public sector. ``Nochlezhka'' charity organization is one of those helping homeless people in Moscow, Saint Petersburg, and other cities in Russia. Homeless people receive help in humanitarian and re-socialization projects. Humanitarian projects provide free overnight stay, hot food, access to a shower, hygiene products, and clothes. These services are provided to any homeless person, regardless of their intent to move into a permanent shelter, where they can get further assistance from social workers. Re-socialization projects are available for the homeless who decided to leave the street for the shelter and want to restore documents, find a job or find an independent residence.
The employees of such organizations often face a necessity to make difficult and non-obvious decisions based on noisy, incomplete and conflicting data. Recently, data analytics and machine learning started to get wider adoption in assisting such decision-making. There are examples of machine learning applications to predict homelessness in Canada \cite{Arsenault2020}, \cite{VanBerlo2020}, to improve the housing system for homeless youth in the USA \cite{Chan2017} and others.
The history of ML applications in addressing homelessness is not long. However, a fairly large amount of data has already been gathered, see, for example, data.World portal \cite{DataWorld}. Although the data from the USA, Canada or UK is relatively big, we could not find many homelessness-related datasets from other countries. Also, the datasets available at the moment mostly contain aggregated data. The dataset presented in this paper has much more detailed (albeit anonymized) information.
We have been working together with ``Nochlezhka'' charity organization on studying the data collected so far in their databases. For the last ten years, ``Nochlezhka'' has stored its clients' data in its content management system (CMS). Every new homeless client, upon registry, is informed that their data are stored and could be used for research purposes. The original CMS data was stored in multiple tables. We cleaned, preprocessed, and anonymized the data creating a dataset available for further data analysis. In this paper, we also report results obtained with this dataset. These results provide valuable insights into the process of rehabilitation of the homeless. In particular, we demonstrate that certain factors predict the outcome of the person's rehabilitation activities with a reasonable level of certainty. We are sharing this dataset, together with the insights and conclusions made, with the data science community. We hope to attract more attention and data scientists to the problem of homelessness globally.
\section{Data}
\label{data}
The gathered dataset is one of the major contributions of this paper. In this section, we describe the preprocessing of original data and document the resulting dataset to facilitate its further use by other researchers interested in the problem of homelessness.
\subsection{Data Cleaning}
\label{data:preprpcessing:cleaning}
The data was downloaded from the CMS database directly. Some of the tables contained a lot of typos, mistakes, discrepancies, HTML tags, etc.; we cleaned this data. The biggest problem was typos and errors in names and dates of birth that resulted in misidentifying the same person (\textit{client} in database terminology) from different records as two or more people. We created person representation as a concatenation of full name and date of birth for each line in the clients' table. Then, we calculated the pairwise similarity using the Levenshtein distance between the obtained strings \cite{SeatGeekFuzzyWussy}. The pairs of strings with high similarity were further checked to identify if two table lines represent the same person. These checks were done manually due to some typos and errors in the original database. We also deleted all obviously fake birth dates, for example, 1001-01-07, thus obtaining a table of clients with a unique person at each line. There was still a small possibility that some person's information might be grouped with another under an erroneous name, but we estimate the probability of such error as extremely low. HTML tags and other service data were searched for and removed by regular expressions.
\subsection{Anonymizing}
\label{data:preprocessing:anonymizing}
There are two types of clients in the database: clients of humanitarian services and clients who participated in re-socialization projects. Once the client enters the re-socialization project, a numeric ID is assigned to the client in the database. All of their further activities are logged under this issued ID. The data on the clients using humanitarian services (shelter, free shower, etc.) was entered into the database the way it was received from the client. The fields included names, dates of birth, and other sensitive information. If a homeless person was enrolled in both humanitarian and re-socialization projects, we matched their ID. We assigned IDs from a separate pool for the names listed in the humanitarian database that had no matching ID. Thus we anonymized the data while leaving a possibility to distinguish between the clients who used humanitarian services only and those who entered re-socialization projects. There is no sensitive data in the dataset we are publishing -- all personal info is replaced with numeric IDs. We address ethical concerns of this decision in Section Ethics Concerns. Here we reiterate that the data is anonymized and published under explicit consent of the partner NGO and every client of the NGO projects.
\subsection{Obtaining Features from Database Tables}
\label{data:preprocessing:tables}
\subsubsection{Contract types}
\label{data:preprocessing:tables:types}
Upon requesting help from a social worker, a homeless person signs a contract between NGO's client and the NGO. In this contract, the client specifically lists the goal they want to achieve upon the contract completion. According to the previous experience of the social workers, such explicit commitment on the client's side improves the chances for successful rehabilitation. The dataset we publish with this paper is centered around predictions of \textit{contract} completion. Every contract is an entity within the CMS of ``Nochlezhka'' database representing some specific activity during re-socialization projects. We used the same term ``contract'' in the dataset. Depending on the client's goals, there are different types of a \textit{contract} with the organization like registration, document restoration, obtaining citizenship, etc. -- 43 types in total. A single person may have several contracts of different types, or several contracts of the same type in different time periods. We represent each occurrence of any contract type for each client as a separate line in the dataset.
\begin{figure*}
\includegraphics[width=0.86\textwidth]{types.png}
\caption{Contract types distribution} \label{fig:types}
\end{figure*}
We have found that certain goals (such as restoring lost documents) are relatively easy to attain, while others (for example, rehabilitation for drug abuse) might have a lower success rate. To highlight this dependency on the type of a contract, we created a separate binary variable for each contract type -- that is, we one-hot encoded all 43 contract types. Figure~\ref{fig:types} illustrates the distribution of contract types in the dataset, with the share of successfully completed contracts of each type.
\subsubsection {Contract statuses}
\label{data:preprocessing:tables:statuses}
There are eight \textit{contract statuses}: ``in progress'', ``fulfilled'', ``partially fulfilled due to client rejection'', ``partially fulfilled due to other reasons'', ``not fulfilled due to client rejection'', ``not fulfilled due to other reasons'', ``partially fulfilled due to client absence'', ``not fulfilled due to client absence''. We used the state of the database on the date 2021-07-31, containing records for over nine years, from 2012-07-11. Fig.~\ref{fig:statuses} shows the contract statuses distribution in the resulting dataset.
\begin{figure}
\includegraphics[width=0.5\textwidth]{statuses.png}
\caption{Contract statuses distribution} \label{fig:statuses}
\end{figure}
\subsubsection{Other features}
\label{data:preprocessing:tables:other}
We added data on the client's gender and age. Age in years was calculated separately based on the client's birth date, if available, and the slice date 2021-07-31. The database also contained additional information on the clients. Depending on the client, the features could include: marital status, dependants, profession, contacts with relatives, time in confinement, disability, alcohol abuse, drug abuse, and others -- the resulting table contained 28 columns of features derived from the database tables.
\subsection{Obtaining features from comments}
\label{data:preprocessing:comments}
To obtain rich data on clients, we analyzed the fields with manual notes made by the social workers upon clients' registration. We found certain frequent remarks that could be relevant to the resulting dataset. These are remarks that social workers leave while working with a client. These comments are usually added upon the start of the \textit{contract} or during the interactions with the client along the rehabilitation process. Like other features, we publish the comment category tags for the comments added before the slice date 2021-07-31.
We removed punctuation, numbers, and other special symbols from the text of comments and extracted tokens using Natural Language Toolkit \cite{NLTK}. The resulting tokens were lemmatized using pymorphy2 \cite{pymorphy2}. The stopwords (prepositions, other auxiliary words) were removed from the resulting tokens list. The frequency dictionary was built from the received tokens list using the method proposed in \cite{rutermextract} to determine which keywords and topics appear in the manual comments more often. As a result of the analysis, 23 most frequent categories were selected.
Each of these categories was used as a tag. Some clients do not have any tags. A client may have more than one tag. The original texts of the comments made by the social workers are not included in the dataset. Thus, the dataset only includes the resulting frequent tags and does not include any client-specific personal or sensitive details.
Finally, we obtained a unique anonymized \textit{client id} and corresponding \textit{tags} for every client. The most frequent tag is the tag \textit{comments\_relatives}. It occurs 2713 times in the dataset. The least frequent tag is \textit{comments\_illiteracy} since only two clients were illiterate.
\subsection{Resulting dataset}
\label{data:dataset}
We merged the features obtained from database tables with the features obtained from comments by client ID to create the resulting dataset with a total of 6349 records and 51 features. Since contract type appeared to be an important feature worth further investigation, we also created an auxiliary dataset with all 43 contract type IDs one-hot encoded\footnote{Actually only 42 types were present, since one of the contract types was available in the database but did not occur on any record.}.
The dataset contains many NaN values -- not every record contains every feature. There are cases where some feature values for specific records are unknown. Therefore, additional preprocessing will be necessary for the machine learning models that can not work with NaN values.
We publish raw anonymized data on clients, contracts, and humanitarian projects that may help the data science community try different hypotheses, approaches, and models in studying the dataset. The data is cleaned from errors, duplicates, and discrepancies and translated into English.
Table \ref{tab:desc_dataset} shows some statistics describing the resulting dataset.
\begin{table}
\begin{center}
\begin{tabular}{|p{0.3\textwidth}|p{0.1\textwidth}|}
\hline
\bf{Description} & \bf{Quantity}\\
\hline
Total records (different contract items) & 6349\\
\hline
Different contracts & 3589\\
\hline
Different clients & 2754\\
\hline
Men & 2239\\
\hline
Women & 515\\
\hline
Age 0-20 & 7\\
\hline
Age 21-40 & 789\\
\hline
Age 41-60 & 1467\\
\hline
Age 61-80 & 476\\
\hline
Age 80+ & 14\\
\hline
Contract type 8 Temp. registration & 558\\
\hline
Contract type 17 Citizenship & 339\\
\hline
Contract type 20 Cancel fraudulent transaction, return housing & 26\\
\hline
Comments: pregnancy & 11 clients\\
\hline
Contract type 25 Military Service Card & 21\\
\hline
\end{tabular}
\caption{The description of the dataset. Contracts period of time from 2012 to 2021 (9 years).}\label{tab:desc_dataset}
\end{center}
\end{table}
\section{Models}
\label{models}
To see if the obtained dataset could provide meaningful insights into the rehabilitation of the homeless, we have trained several models to predict the probability of rehabilitation success using available data about the client.
\subsection{Target variable}
\label{models:target}
Since in the experiment described here, we make a prediction based on client data, let us consider ``\textit{fulfilled}'' status (see ``Contract statuses'' subsection above) as a positive result, while statuses other than ``\textit{fulfilled}'' and directly related to the client (``partially fulfilled due to client rejection'', ``not fulfilled due to client rejection'', ``partially fulfilled due to client absence'', ``not fulfilled due to client absence'') as negative results. We considered a total of 6349 contracts, while 923 contracts with statuses: ``in progress'', ``partially fulfilled due to other reasons'', and ``not fulfilled due to other reasons'' were not included in our consideration in the subset for the particular experiment (although this data is still available in the dataset we publish for further experiments and research). Thus, we simplified the task down to binary classification with two values of the target variable: 1 - ``contract completed successfully'' and 0 - ``contract not completed due to the client's behavior''.
\subsection{Models and Experiments}
\label{models:results}
The logistic regression model was used as a baseline. Along with logistic regression, we experimented with support vector machine (SVM), decision tree classifier, random forest classifier, k nearest neighbors algorithm, fully connected neural network (FCNN), CatBoost classifier, and XGBoost classifier. We used the train-test-split module from Python sklearn library to split the dataset into train and validation subsets. 80~\% of the records were used in the training set, 20~\% in the validation set. We kept the positive-negative ratio in both training and validation sets as in the original set (``stratify'' property of train-test-split). Then we balanced the data in the training set, sampling an equal share of successful and unsuccessful contracts to train the model. Two methods (random undersampling and random oversampling) were used to balance the training subset. The validation subset was not modified and kept the original positive-negative ratio. We have then trained several models on the train set. Table \ref{tab:model_scores} summarizes the results of the trained models on the validation subset for two different balancing techniques. Since the validation set is imbalanced, we use the weighted average of F1-score as the model quality measure.
\begin{table}
\begin{center}
\begin{tabular}{|l|l|l|}
\hline
\bf{Model} & \vtop{\hbox{\strut \bf{F1 with}}\hbox{\strut \bf{Undersampling}}} & \vtop{\hbox{\strut \bf{F1 with}}\hbox{\strut \bf{Oversampling}}}\\
\hline
Logistic Regression & 0.64 & 0.65\\
\hline
SVM & 0.64 & 0.64 \\
\hline
Decision Tree & 0.73 & 0.76 \\
\hline
k Nearest Neighbours & 0.65 & 0.65 \\
\hline
FCNN & 0.69 & 0.74 \\
\hline
CatBoost & 0.76 & 0.76 \\
\hline
Random Forest & 0.78 & 0.81 \\
\hline
XGBoost & \bf{0.80} & \bf{0.85} \\
\hline
\end{tabular}
\caption{Resulting performance of the tested models (weighted average of F1-score on the balanced training set with different balancing techniques).}\label{tab:model_scores}
\end{center}
\end{table}
Since the majority of the variables in the dataset are categoric, it is not surprising that CatBoost \cite{dorogush2018catboost} and XGBoost \cite{chen2016xgboost} perform well on the provided data. These algorithms were explicitly designed to work with categoric variables. However, what is surprising is the relatively high F-1 score (as well as a comparable accuracy) that the models demonstrate on the test. Such information could be helpful for social workers since ``Nochlezhka'' is a non-profit organization that has to function under considerable financial constraints. Using non-balanced data and adjusting for the discrepancies in the size of different data classes, one can obtain higher scores\footnote{The code of experiments is available at https://github.com/LEYADEV/homeless}.
It is also important to note that a high F-1 score also validates the obtained dataset. It shows that the provided data contains meaningful information on the nature of homelessness available on an individual's level, which makes the provided dataset unique for the field. In the next section, we discuss further insights that could be obtained with the provided dataset.
\section{Discussion}
\label{discussion}
\begin{figure*}
\includegraphics[width=0.9\textwidth]{dt_over_top20.png}
\caption{Top 20 most important features: Decision Tree Classifier with Random Oversampling} \label{fig:dt_top20}
\end{figure*}
\begin{figure*}
\includegraphics[width=0.9\textwidth]{rf_over_top20.png}
\caption{Top 20 most important features: Random Forest Classifier with Random Oversampling} \label{fig:rf_top20}
\end{figure*}
\begin{figure*}
\includegraphics[width=0.9\textwidth]{cb_over_top20.png}
\caption{Top 20 most important features: CatBoost Classifier with Random Oversampling} \label{fig:cb_top20}
\end{figure*}
\begin{figure*}
\includegraphics[width=0.9\textwidth]{xgb_over_top20.png}
\caption{Top 20 most important features: XGBoost Classifier with Random Oversampling} \label{fig:xgb_top20}
\end{figure*}
Figures~\ref{fig:dt_top20}--\ref{fig:xgb_top20} summarize the importance of various features that, according to different models, influence the contract success the most, either in ``successful'' or ``unsuccessful'' direction. All models for which the feature importance is illustrated, are tree-based. Therefore, they have similar criteria for feature importance measure calculation. In tree-based models, the importance is generally calculated for a single decision tree by the amount each feature split point improves the performance measure, weighted by the number of observations the node is responsible for. All four models above have ``feature\_importance\_'' method that was used to calculate the feature importance absolute value. The sign was taken from the correlation table and represented the sign of the correlation between a specific feature and the target variable. One sees that, although not all the models have the same features on their top-20 importance list, some features appear in most, if not all, top lists. For example, one sees that the essential feature is a registered absence of the client. This typically means the client missed one or several appointments with the social worker. Other high-impact factors include age, contact with relatives, diseases, and disability. We have discussed the results with social workers. While doing so, we made it clear to the social workers that feature importance does not, in any case, mean any cause-and-effect relationship between a specific feature and the result; just the extent to which the model regards the feature as essential for the result prediction. The feedback was that along with some expected results, there are certain surprising aspects.
The following features have the highest positive impact on XGBoost model that has shown the best results:
\begin{itemize}
\item the person seeks registration for the shelter provided by ``Nochlezhka'';
\item the person or the person's spouse is pregnant;
\item the person seeks to restore documents -- namely, the military service card or a passport;
\item the person seeks medical attention;
\item the person needs technical rehabilitation equipment;
\item the person or someone close to the person has mental problems;
\item the person wants to return to hometown, where they might have a place to live;
\item the person seeks legal support in court;
\item the person is divorced;
\item the person has disabilities;
\item the person is the citizen of Russia;
\item the person has a profession.
\end{itemize}
The following features have the highest negative impact, in accordance with the same XGBoost model:
\begin{itemize}
\item the person seeks to obtain citizenship of Russia;
\item the person seeks to return their home in court since the home was lost due to a fraudulent behavior of the third party;
\item primary source of the person's income is support from relatives;
\item the person was absent on one or more of the scheduled meetings;
\item the person is orphanage graduate;
\item the person mentions doing time in confinement;
\item the person's residence suffered from fire;
\item primary source of the person's main income was a temporary job.
\end{itemize}
While some of the factors on the list above are not surprising, others drew the attention of the social workers. First, success heavily depends on the person's goals: some goals are easier to achieve. Some of the differences are not obvious yet matter. For example, seeking a job that provides accommodation (e.g., a nightguard or a municipal caretaker) contributes to success, while pursuing an adaptation program that claims to help with future employment (although not on the list above but still relatively significant feature) contributes negatively. This insight gives a clear and helpful outcome: the currently implemented employment program has room for further improvement. For example, ``Nochlezhka'' might partner with employers who could provide accommodation for the person they hire and develop programs that could further simplify the search for employment that also provides lodging. It is well known that drug abuse and history of confinement negatively affect rehabilitation outcomes. It is also relatively well known that once gathering becomes a person's main activity, this usually signifies that the person has been ``chronically'' homeless. The social workers know from experience that the longer someone is on the street, the harder it is to achieve rehabilitation.
The real-life use cases for predictions and feature importance evaluations made by machine learning models do not imply ``only concentrate on those contracts that are likely to succeed, ignore the rest'' strategy. The ML-powered methods mostly highlight the aspects social workers need to pay more attention to if they want to achieve a successful result with a specific client. Another useful application is backing up the organization's position in discussions with state officials: the arguments based on knowledge from social workers' experiences become much more convincing when confirmed by statistics and machine learning.
We believe that further analysis of the dataset could provide deeper insights into the challenges of rehabilitation of the homeless.
\section{Ethics Concerns}
\label{sec:ethics}
Homelessness is an extremely sensitive issue. Unfortunately, to this day, social stigma is attached not only to homelessness per se but also to other issues that tend to align with the problem of losing a home: substance abuse, family violence, and mental illness are to name a few. This stigma makes quantitative research on homelessness very challenging. Most of the available datasets only include macro-level statistics on homeless people and rarely allow precise analysis of individuals. Even data on various social and demographic cohorts are rare. However, homelessness is a multifaceted issue that, in our opinion, demands rich, multidimensional datasets describing the problem on the level of individuals since every person has a unique story and a unique set of factors that affect the rehabilitation process. Working on this contribution, we tried to balance these two conflicting factors to the best of our capabilities.
Several years ago, our partnering non-government charity organization entertained the thought that detailed research of the collected data might benefit other organizations that work on rehabilitating the homeless. The social worker informed the clients that their data might help other homeless people. Upon registering a contract with the NGO, every client was asked to sign an informed consent that their data could be processed, depersonalized, and published under several constraints that we followed. We have double-checked with the NGO's social workers and volunteers the scale of potential risks for their clients upon deanonymization. They all agree that such risks are minimal since the NGO encourages their clients to share their stories and thus combat social stigmas that surround homelessness. For example, most of the clients, even in the middle of the rehabilitation process, agree to talk about their past to the journalists. The clients understand the importance of higher visibility for homeless people and try to do their share in educating society about the issue. At the same time, we did our best to preprocess the data so that we estimate the risk of deanonymization as low. Those two factors combined give us ground to conclude that the benefits of a detailed anonymized public dataset of homelessness spanning several years and thousands of clients outweigh the potential risks such publication might bring for specific individuals.
\section{Conclusion}
\label{conclusion}
This paper presents a novel large dataset of homelessness. The dataset consists of more than six thousand records. The data is anonymized yet provides many details on each client's level that used services of the rehabilitation organization. These details shed light on various factors that affect the success of rehabilitation. We publish the dataset for further research. We demonstrate that one could predict the probability of rehabilitation with an accuracy of up to 80~\% and more. The results obtained within the project are used by the non-profit organization that rehabilitates homeless people. We hope that the publication of these rich and socially vital data could attract the attention of the data science community to the problem of homelessness and provide new effective solutions that could help the homeless worldwide.
| {'timestamp': '2023-02-13T02:13:38', 'yymm': '2302', 'arxiv_id': '2302.04455', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04455'} | arxiv |
\section{Introduction}
Umanned aerial vehicles (UAVs) are gaining popularity for many applications such as autonomous infrastructure inspection, aerial transportation, photography and surveillance. In these tasks, the UAV is often required to navigate along a global reference path specified by the tasks. Meanwhile, local trajectories are generated to avoid unexpected obstacles observed by the onboard sensors. This research topic, i.e., local trajectory replanning, has been investigated by several recent works\cite{oleynikova2016continuous, fei2017iros, usenko2017real}.
Gradient-based trajectory optimization has been investigated by recent works \cite{fei2017iros}, in which trajectory generation is formulated as a non-linear optimization
problem taking smoothness, safety and kinodynamic feasibility into accounts. The safety of the trajectory depends on the Euclidean signed distance field (EDF), whose
distance and gradient information are enssential to push the trajectory away from the obstacles.
One main issue of these works is that they are very vulnerable to bad initial value. Although generating good high-quality trajectory given collision-free initial path as input\cite{},
none of them guarantee a high success rate if the initial trajectory is in collision. As a result, they have to rely on a front-end path searching to
search for a collision-free initial path for higher success rate.
Another drawback of these methods is that they often get stuck in local optimal. Gradient-based optimization refines the initial trajectory locally, during which the trajectory can not pass obstacles.
Therefore, the obtained trajectory is restricted to the same homotopy class of the initial path and can not guarantee global optimality.
\section{Related Work}
\subsection{Gradient-based Trajectory Generation}
The methods mentioned in the previous sections set hard constraints for the optimization variables that are required to be satisfied. Among other methods, however, the constraints are penalized in the objective function. CHOMP[] is a trajectory optimization method which minimize smoothness and collision costs locally on a discrete-time trajectory. With discrete waypoints as optimization variables, the planner performs gradient descent in each step. The algorithm can find smooth and collision-free trajectories from straight line initialization which might not be collision-free. However, in cluttered environments the success rate of the method is low.
STOMP [] is also based on optimization using a two-part objective function. In contrast, the optimization is solved by gradient-free candidate sampling and combining the best-scoring candidates linearly.
Inspired by CHOMP, [] presented an approach based on sequential convex optimization. The workspace are broken up into convex free regions and sequential convex optimization that penalizes collisions with a hinge loss is performed. The original non-convex optimization problem is solved by constructing and solving approximate convex subproblems repeatedly, each of which generate a step that make progress on the original problem. Since convex optimization algorithms minimize each subproblem efficiently, the proposed algorithm converges faster than the previous two methods. The main drawback of the method is that convex regions are difficult to compute online and thus requires a pre-built map with convex regions.
[] presented an online continuous time trajectory optimization method for local replanning. Unlike previous methods, continuous time trajectory representation is used because dynamic constraints can be more accurately expressed and it avoid numerical differentiation errors. The collision cost of the continuous time trajectory is formulated as the line integral of the distance penalty over the arc length along the trajectory. The integral is discretized on different time stamps for numerical calculation:
[] adopted a similar formulation with the difference of initializing the trajectory by piecewise straight line generated by an informed sampling-based path generation algorithm. Having a voxel grid map as environment representation, a random-exploring graph is generated, in which the safe volume of a given point is evaluated by using a Kd-tree to do fast nearest neighbor search. A minimum distance path can be found by the standard A* algorithm. An informed sampling scheme in which the best path and the heuristic sampling domain are updated iteratively is also utilized to improve the efficiency of the sampling and the quality of the path. Thanks to the better quality of initial path, this method enjoys significantly higher success rate compared with CHOMP [] and CT[].
Ewok [] proposed an algorithm to generate globally smooth and collision-free trajectory and do local replanning that can handle dynamic obstacles while keeping the deviation from global trajectory small. Instead of using polynomial as trajectory representation, they use uniform b-splines. Since b-spline trajectory is smooth given an arbitrary set of control points and has the property of locality, it results in fewer constraints and optimization variables. These properties make it very efficient to do local replanning.
\subsection{Topology Path Finding}
\cite{hppr} presented a variant of PRM called Homotopy Preserved Probabilitic Roadnmap(HPPR), in which some of the reducible loops are excluded through local faces collision detection.
However, it could not reduce all redundant loops, especially in constrained environments.
In constrast, \cite{btcy_search} proposed a complete method to determine 2-D homotopic paths. It showed that the H-signature based on complex analysis is a homotopy invariant and
used it for graph search-based path planning with homotopy constraints.
The H-signature is also utilized in \cite{TEB1,TEB2} to find a set of paths with distinctive topology. This method first adopt either voronoi diagram or PRM to discover several
candidate paths, which are then filtered using the H-signature so that each homotopic class contains only one path. \cite{online} presented a similar approach to \cite{TEB} operating
on the 2-D discretized voronoi diagram. However, different homotopic classes are identified using the winding angle of a trajectory. Although these methods work well in 2-D problems,
it is difficult to apply them directly to 3-D environments. \cite{topo_constraints} generalizes the concept of H-signature to 3-D space based on the theory of electromagnetism. However,
it assume that the occupied space can be decomposed into some genus 1 obstacles or infinite tube, which is usually impractical.
Beyond homotopy, \cite{PDRs} reveals that capturing the
homotopy classes in 3-D space may be insufficient to encode the set of useful paths, since homotopic paths may be too hard to deform into each other. As a result, a less general
relation called K-order deformability is defined and adopted to discover a richer set of representative paths in the environments.
\section{MATH}
Before you begin to format your paper, first write and save the content as a separate text file. Keep your text and graphic files separate until after the text has been formatted and styled. Do not use hard tabs, and limit use of hard returns to only one return at the end of a paragraph. Do not add any kind of pagination anywhere in the paper. Do not number text heads-the template will do that for you.
Finally, complete content and organizational editing before formatting. Please take note of the following items when proofreading spelling and grammar:
\subsection{Abbreviations and Acronyms} Define abbreviations and acronyms the first time they are used in the text, even after they have been defined in the abstract. Abbreviations such as IEEE, SI, MKS, CGS, sc, dc, and rms do not have to be defined. Do not use abbreviations in the title or heads unless they are unavoidable.
\subsection{Units}
t your equation should be typed using either the Times New Roman or the Symbol font (please no other font). To create multileveled equation
\subsection{Equations}
The equations are an exception to the prescribed specifications of this template. You will need to determine whether or not your equation should be typed using either the Times New Roman or the Symbol font (please no other font). To create multileveled equations, it may be necessary to treat the equation as a graphic and insert it into the text after your paper is styled. Number equations consecutively. Equation numbers, within parentheses, are to position flush right, as in (1), using a right tab stop. To make your equations more compact, you may use the solidus ( / ), the exp function, or appropriate exponents. Italicize Roman symbols for quantities and variables, but not Greek symbols. Use a long dash rather than a hyphen for a minus sign. Punctuate equations with commas or periods when they are part of a sentence, as in
$$
\alpha + \beta = \chi \eqno{(1)}
$$
\subsection{Some Common Mistakes}
\section{USING THE TEMPLATE}
Use this sample document as your LaTeX source file to create your document. Save this file as {\bf root.tex}. You have to make sure to use the cls file that came with this distribution. If you use a different style file, you cannot expect to get required margins. Note also that when you are creating your out PDF file, the source file is only part of the equation. {\it Your \TeX\ $\rightarrow$ PDF filter determines the output file size. Even if you make all the specifications to output a letter file in the source - if your filter is set to produce A4, you will only get A4 output. }
It is impossible to account for all possible situation, one would encounter using \TeX. If you are using multiple \TeX\ files you must make sure that the ``MAIN`` source file is called root.tex - this is particularly important if your conference is using PaperPlaza's built in \TeX\ to PDF conversion tool.
\subsection{Headings, etc}
It is impossible to account for all possibl
\subsection{Figures and Tables}
It is impossible to account for all possibl
\begin{table}[h]
\caption{An Example of a Table}
\label{table_example}
\begin{center}
\begin{tabular}{|c||c|}
\hline
One & Two\\
\hline
Three & Four\\
\hline
\end{tabular}
\end{center}
\end{table}
\begin{figure}[thpb]
\centering
\framebox{\parbox{3in}{We suggest that you use a text box to insert a graphic (which is ideally a 300 dpi TIFF or EPS file, with all fonts embedded) because, in an document, this method is somewhat more stable than directly inserting a picture.
}}
\caption{Inductance of oscillation winding on amorphous
magnetic core versus DC bias magnetic field}
\label{figurelabel}
\end{figure}
It is impossible to account for all possibl
\section{CONCLUSIONS}
A conclusion section is not required. Although a conclusion may review the main points of the paper, do not replicate the abstract as the conclusion. A conclusion might elaborate on the importance of the work or suggest applications and extensions.
\addtolength{\textheight}{-12cm}
\section*{APPENDIX}
Appendixes should appear before the acknowledgment.
\section*{ACKNOWLEDGMENT}
It is impossible to account for all possibl
References are important to the reader; therefore, each citation must be complete and correct. If at all possible, references should be commonly available publications.
\section{Introduction}
Recently, high-quality 3D reconstruction has been an active topic in various applications including cultural relics digitalization, AR/VR, and structural inspection.
Due to its high flexibility, the unmanned aerial vehicle (\textbf{UAV}) is ideal to achieve the fast, accurate, and complete 3D reconstruction of the target areas.
To effectively improve reconstruction quality and efficiency, a path planning framework for autonomous aerial reconstruction is essential.
Existing reconstruction planning works \cite{zhang2021continuous, hepp2018plan3d, kuang2020real, zhou2020offsite, song2021view, zhou2021fuel, song2020active} demonstrate
unsatisfactory efficiency in reconstructing the target areas. First of all, many previous methods \cite{zhang2021continuous, hepp2018plan3d, kuang2020real, zhou2020offsite}
adopt \textit{explore-then-exploit} strategy which requires two scanning trails, or rely on coarse prior models to obtain the reconstruction paths.
Such strategies present several drawbacks. 1) Two scanning trails lead to task completion inefficiency.
2) As requiring input prior model, the task cannot be fully automated. 3) They cannot guarantee accurate and complete details of the target areas owing to
planning only based on coarse or prior models, which cannot adjust flight paths in \textit{real-time} based on actual observation.
Recently, online planning methods requiring a single scanning trail and not relying on prior models have been proposed \cite{song2021view, zhou2021fuel,song2020active}, which
partially resolve the above issues. However, the efficiency is not satisfactory enough, due to the fact that the target areas are previously unknown and significant time
is distributed to explore the unknown regions. Besides, some of them demonstrate a prohibitive computation time, which usually results in undesirable stop-and-go behaviors or even requires communications with external high-end computers.
\begin{figure}[t]
\begin{center}
\includegraphics[width=0.88\columnwidth]{top.png}
\vspace{-0.5cm}
\end{center}
\caption{\label{fig:topo_traj} (a) Illustration of the proposed framework results during executing trajectory for 3D reconstruction, (b) 3D reconstruction result of the above target produced by the proposed framework.
}
\vspace{-0.9cm}
\end{figure}
To address the above issues, we propose \textbf{PredRecon}, a prediction-boosted planning framework that can efficiently reconstruct high-quality 3D models for the target areas in unknown environments with a single flight.
Our method is inspired by the fact that humans can reasonably infer those incomplete structures based on partial observations according to their knowledge and experience. The inferred structures or surfaces enable more purposeful viewpoints generation,
which in turn allows a more efficient global coverage path of the entire target without wasting significant time on exploring unknown space. Motivated by this, we introduce a learning-based surface prediction module (\textbf{SPM}),
which predicts the coarse complete surface of the target from the current partial reconstruction.
Afterwards, online volumetric mapping extracts incomplete observed surfaces from the prediction and the current reconstruction as the uncovered parts.
Then, a hierarchical planner generates motions for reconstructing the uncovered surfaces in a \textit{coarse-to-fine} manner. It first finds an efficient global path for full coverage.
Secondly, a local path segment from the current pose to the next viewpoint (NBV) is generated under the guidance of the global path while optimizing the crucial factors for MVS performance.
Then, the executable local trajectory is produced to acquire image-pose pairs of the target.
The collected database is processed by COLMAP \cite{schoenberger2016sfm, schoenberger2016mvs, schoenberger2016vote} for dense 3D reconstruction.
We compare the proposed method with the classical and \textit{state-of-the-art} methods in a realistic simulation. Results present that our method achieves higher efficiency
and better reconstruction quality in benchmark scenarios.
Moreover, benchmark experiments demonstrate the higher autonomy level of our method and our method can realize \textit{real-time}
planning on typical onboard computers.
The contributions of this paper are summarized as follows:
1) A surface prediction module (SPM), which directly infers the complete target surfaces from partial reconstruction information and facilitates efficient global coverage of the target without wasting significant time on extra exploration.
2) A hierarchical planner based on SPM, which sufficiently considers MVS-related factors on the fly and global coverage, achieving higher reconstruction quality and efficiency.
3) Benchmark comparisons that validate the performance of \textbf{PredRecon}. The source code of our implementation has been made public.
\begin{figure}[t]
\begin{center}
\includegraphics[width=0.99\columnwidth]{sys_big.png}
\vspace{-0.7cm}
\end{center}
\caption{\label{fig:overview} The overview of the proposed prediction-boosted path planning framework for 3D reconstruction. }
\vspace{-0.7cm}
\end{figure}
\section{Related Work}
\label{sec:related}
\subsection{Surface Prediction and Completion}
Surface prediction and completion have been an essential topic in 3D reconstruction.
Existing works can be roughly classified into geometry-based and learning-based methods.
The geometry-based methods predict the entire surface through geometric heuristics from partial input data. Some classical works \cite{kazhdan2013screened, davis2002filling, berger2014state, zhao2007robust} generate complete surface
models using smooth interpolations from incomplete local holes. Those approaches assume that the whole surface can be inferred directly from the geometric input structure. Thus, they cannot work well during most
of the flight time.
The learning-based methods take inputs from point clouds acquired through surface voxelization. They \cite{yuan2018pcn, xie2020grnet, pan2021variational, shi2022temporal} directly output the complete surface model with an implicit parameterized model (deep neural network),
which has better adaptiveness to complex situations. Our SPM belongs to this category. However, most existing methods suffer from unstable accuracy, primarily influenced by normalization. Hence, an extra detector is essential for predicting the scale and center of the target model.
Additionally, many apply 3D CNNs for higher accuracy, while heavy architecture leads to slower inference time.
Based on this approach \cite{yuan2018pcn}, our SPM directly uses map point cloud as input and achieves \textit{end-to-end} surface prediction without an extra detector for normalization. Moreover, we optimize the network architecture
with a more lightweight structure and more accurate performance (Sect.\ref{subs:spm_performance}).
\subsection{Path Planning for Aerial Reconstruction}
For efficient and high-quality 3D reconstruction, viewpoints path planning, which selects a minimum quantity of viewpoints while maximizing contributions to reconstruction quality, has been intensely studied for years. The fundamental problem is how to model the bridge
from viewpoints selection to quality. Several methods \cite{hornung2008image, hepp2018plan3d, vazquez2003automatic} leverage viewpoint information gain (defined as coverage of the coarse model) as the planning objectives. Furthermore, other works \cite{zhang2021continuous, roberts2017submodular}
distribute a coverage hemisphere to each surface, ensuring selected viewpoints scan whole surfaces from diverse view directions.
MVS-based methods \cite{song2020active, song2021view, smith2018aerial, peng2019adaptive} determine the optimal viewpoints considering MVS factors for better depth estimation, as this paper does.
\cite{song2021view, song2020active} formulate the problem as an \textit{information path planning problem} while \cite{smith2018aerial, peng2019adaptive} adopt a selection strategy based on
\textit{reconstructability} heuristics. They all consider the factor of stereo matching and triangulation.
In this paper, we base our hierarchical planner on MVS-based works but with a more concise formulation of MVS heuristics cost. Moreover, it fully utilizes SPM results to generate paths with high reconstruction efficiency and quality.
\section{System Overview}
\label{sys}
Fig.\ref{fig:overview} illustrates the overview of the proposed pipeline consisting of online and offline modules. The online subsystem is composed of the SPM (Sect.\ref{sec:spm}), online volumetric mapping (Sect.\ref{subs:pred_states})
and a hierarchical planner (Sect.\ref{sec:hp}).
SPM predicts both the scale and point cloud of the whole target model surfaces from the current partial map (Sect.\ref{sec:spm}).
Then, online volumetric mapping extracts the remaining uncovered surfaces with SPM results (Sect.\ref{subs:pred_states}).
After that, the hierarchical planner works to find a global path and generate a local trajectory for maximizing global coverage efficiency and MVS performance. UAV collects image-pose pairs from odometry and onboard camera (Sect.\ref{sec:hp}). The online subsystem will end the flight if mapping finds no uncovered surfaces.
Afterwards, the image-pose pairs database is processed using offline COLMAP to acquire the 3D reconstruction model of the target.
\begin{figure}[t]
\begin{center}
\vspace{0.5cm}
\includegraphics[width=0.99\columnwidth]{SPM.png}
\vspace{-0.7cm}
\end{center}
\caption{\label{fig:spm_network} The overall architecture of the proposed SPM (Sect.\ref{sec:spm}).}
\vspace{-0.8cm}
\end{figure}
\section{Surface Prediction Module}
\label{sec:spm}
SPM enables predicting the whole surfaces of the target from partial map in entirely unknown environments, as depicted in Fig.\ref{fig:spm_network}.
Surface prediction effectively decreases the redundant flight since no extra time is spent for exploring unknown environments.
Moreover, it facilitates generating fewer viewpoints with the sufficient observation of the target, which reduces the complexity of the subsequent planner.
\subsection{Data Pre-process}
\label{subs:data_pp}
The input of SPM is a down-sampling point cloud $M_{C}$ of the current partial map (Sect.\ref{subs:pred_states}) with the fixed quantity $N_{C}$. Different from previous works \cite{yuan2018pcn, xie2020grnet,pan2021variational}, we directly process each point $p_{i} \in M_{C}$ via a local transformation $T_{p}$, as follows:
\begin{equation}
T_{p}(p_{i}, C_{C}) = p_{i} - C_{C},
\end{equation}
where $C_{C}$ is the centroid of $M_{C}$. Then, each transformed point is stored in $M_{I}$, which is sent to the prediction network.
\subsection{Prediction Network Structure}
\label{subs:pred_net}
Compared with previous point cloud completion works \cite{yuan2018pcn, xie2020grnet,pan2021variational,huang2020pf}, our prediction network adopts \textit{end-to-end} manner without the extra detector for normalization. Additionally, it ensures \textit{real-time} and lightweight requirements without 3D convolutional operation in network implementation.
It consists of two headers, the scale estimation header, and the surface prediction header.
To facilitate the following surface prediction, scale estimation header is introduced to predict the coarse scale of the target. The input $M_{I}$ is represented as an $N_{C} \times 3 $ matrix containing the 3D coordinate $(x,y,z)$ of each point. Specifically, we leverage PointNet \cite{qi2017pointnet} as the backbone for its permutation invariance and effective global feature extraction.
Then, there are two multi-layer perceptrons (MLP) as output branches. Regression MLP directly gives a vector $(x_{s}, y_{s}, z_{s})$ indicating the scales in three axes. To further improve the scale estimation accuracy, the local feature map after PointNet is particularly processed through offset MLP
to acquire corresponding offset $(\Delta x_{s}, \Delta y_{s}, \Delta z_{s})$. Thus, the target scale $s_{t}$ can be formulated as:
\begin{equation}
s_{t} = max(x_{s}+\Delta x_{s}, y_{s}+\Delta y_{s}, z_{s}+\Delta z_{s}).
\end{equation}
For the training stage, we use Huber loss to supervise the scale estimations in each axis. Finally, normalization is applied on input point cloud $M_{I}$ by scaling down $s_{t}$-fold.
Surface prediction header is responsible for generating the complete surfaces of the target according to the normalized $M_{I}$. We utilize a shared MLP to encode each point in the normalized $M_{I}$ into the feature map $F$. Then, a PointPillars Feature Net \cite{lang2019pointpillars} is performed on $F$ as the encoder to aggregate geometric information in different areas
with low computation cost for its pseudo image operation. Moreover, PointPillars is eligible for this problem since we expect the network to have the space-aware capability to extend or complete partial surfaces in different areas. Similar to PCN \cite{yuan2018pcn}, a \textit{coarse-to-fine} decoder is also leveraged to generate the prediction for global and local geometry learning.
The fine prediction $Y_{fine}$ and the coarse prediction $Y_{coarse}$ both contain $N_{C}$ points. For the loss function, the permutation invariant Chamfer Distance is used to supervise the difference between the network outputs with its ground truth $Y_{gt}$, as shown:
\begin{equation}
cd(X, Y) = \frac{1}{|X|}\sum_{x \in X}\mathop{min}\limits_{y \in Y}||x-y||_{2}^{2}
+\frac{1}{|Y|}\sum_{y \in Y}\mathop{min}\limits_{x \in X}||x-y||_{2}^{2}
\end{equation}
\begin{equation}
\mathcal{L} = cd(Y_{coarse}, Y_{gt}) + cd(Y_{fine}, Y_{gt}).
\end{equation}
Afterwards, $M_{I}$ and the inverse normalized $Y_{fine}$ is concatenated into a $2N_{C} \times 3$ matrix as the predicted surfaces $M_{P}$.
To determine correct viewpoints sampling space, we adopt \textit{GHPR} \cite{katz2015visibility} to process $M_{P}$ to obtain the internal space $S_{I}$,
which is the prohibited space for viewpoints generation.
\subsection{Volumetric Mapping with Prediction}
\label{subs:pred_states}
To online evaluate the reconstructed parts of the target, we refer to \cite{han2019fiesta} to build a volumetric map, which provides partial observations for SPM. We define the surfaces that are observed from two or more different viewpoints as the complete observed surfaces.
After the inference of SPM, volumetric mapping extracts those incomplete observed surfaces from the prediction as the target uncovered areas of the hierarchical planner.
\begin{figure}[t]
\begin{center}
\vspace{0.3cm}
\includegraphics[width=0.85\columnwidth]{global.png}
\vspace{-0.5cm}
\end{center}
\caption{\label{fig:global} Global coverage path Planning: (1) Cluster the uncovered surfaces. (2) Viewpoints generation through dual sampling. (3) The global coverage path is given by the ATSP solver. (Sect.\ref{subs:global})}
\vspace{-0.7cm}
\end{figure}
\section{Hierarchical Planner}
\label{sec:hp}
With the uncovered surfaces, path planning can be formulated as generating paths to efficiently and completely cover the uncovered surfaces of the target.
To realize this objective, the proposed planner takes a hierarchical planning paradigm into two steps, global coverage path planning (Sect.\ref{subs:global}),
quality-driven local path planning for data collection and trajectory generation (Sect.\ref{subs:local}).
\subsection{Global Coverage Path Planning}
\label{subs:global}
This planning stage is to output an efficient global visit sequence of the viewpoints to cover the uncovered surfaces, as illustrated in Fig.\ref{fig:global}.
First of all, a clustering approach based on Euclidean distance and normal is performed on the uncovered surfaces to extract $N_{G}$ clusters to be visited.
Then, similar to \cite{song2021view}, we apply the dual sampling method for the \textit{4-DoF} viewpoints generation, which samples a set of coverage
viewpoints for each cluster in their own fan-shaped cylinder from its center to normal direction, as shown in Fig.\ref{fig:global}. Lastly, we choose the viewpoint
with the highest surface visibility ratio in each cluster as $V_{G} = \{ v_{g}^{1}, v_{g}^{2}, ..., v_{g}^{N_{G}} \}$,
where $v_{g}^{i} = (\textbf{\text{P}}_{g}^{i}, \theta_{g}^{i})$ indicating position and yaw angle. The surface visibility ratio of a viewpoint is defined as:
\begin{equation}
\label{equ:vis_ratio}
r(v,s) = \frac{\mathcal{N}(v)}{\mathcal{N}(s)},
\end{equation}
where $v$ as viewpoint, $s$ as the observed surface, $\mathcal{N}(v)$ as the number of visible points in $s$ that can be seen from $v$
and $\mathcal{N}(s)$ is the quantity of points in $s$.
To find the shortest path that passes each viewpoint from the current pose, we formulate this problem as the Asymmetric Traveling Salesman Problem (ATSP) \cite{meng2017two}.
The ATSP can be solved by existing proven algorithms through designing proper cost matrix $\Upsilon_{G}$.
Thus, we present the cost between two viewpoints $c_{g}(v_{g}^{i}, v_{g}^{j})$ considers the path length and yaw change, as follows:
\begin{equation}
\begin{split}
c_{g}(v_{g}^{i}, v_{g}^{j}) = \frac{L(\textbf{\text{P}}_{g}^{i}, \textbf{\text{P}}_{g}^{j})}{v_{max}} + \\
\frac{min(||\theta_{g}^{i}-\theta_{g}^{j}||_{1}, 2\pi-||\theta_{g}^{i}-\theta_{g}^{j}||_{1})}{\omega},
\end{split}
\end{equation}
where $L(\textbf{\text{P}}_{g}^{i}, \textbf{\text{P}}_{g}^{j})$ means the path length between $\textbf{\text{P}}_{g}^{i}$ and $\textbf{\text{P}}_{g}^{j}$ searched by $A^{*}$ algorithm in the free space,
$v_{max}$ and $\omega$ are the maximum velocity and angular change rate of yaw.
Sometimes, there exist several global coverage paths with similar cost that leads to unstable path optimization results,
which introduces inconsistent flight directions and low efficiency. Accordingly, global consistency should be essentially taken into account
to generate stable solutions. We define the last global planning direction (a vector from last current position $\textbf{\text{P}}_{cur}^{last}$ to last NBV $\textbf{\text{P}}_{nbv}^{last}$) $d_{g}^{last}$,
and introduce glocal consistency cost $c_{GC}(v_{g}^{i})$ by:
\begin{equation}
d_{g}^{last} = \frac{\textbf{\text{P}}_{nbv}^{last} - \textbf{\text{P}}_{cur}^{last}}{||\textbf{\text{P}}_{nbv}^{last} - \textbf{\text{P}}_{cur}^{last}||_{2}},
\end{equation}
\begin{equation}
c_{GC}(v_{g}^{i}) = arccos\frac{\textbf{\text{P}}_{g}^{i} - \textbf{\text{P}}_{cur}^{now}}{||\textbf{\text{P}}_{g}^{i} - \textbf{\text{P}}_{cur}^{now}||_{2}} \cdot d_{g}^{last}.
\end{equation}
Then, we can give the complete form of $\Upsilon_{G}$ with the viewpoints index set $ \zeta = \{1,2,...,N_{G}\}$ as:
\begin{equation}
\label{equ:cost_mat}
\Upsilon_{G}(k,h) =
\begin{cases}
0,&k==h \,or\, h=0\\
c_{g}(v_{g}^{k}, v_{g}^{h}),&k,h \in \zeta\\
[\beta_{1}c_{g}(v_{g}^{k}, v_{g}^{h}) + & k==0\,and\,h\in \zeta\\
\beta_{2}c_{GC}(v_{g}^{h})],
\end{cases}
\end{equation}
Therefore, through solving the above ATSP with $\Upsilon_{G}$, we can find the efficient global coverage path starting from the current pose to visit the whole uncovered surfaces.
\subsection{Quality-driven Local Path Planning}
\label{subs:local}
Global planning mainly focuses on fast and complete coverage of the target. To further improve the reconstruction quality,
local planning optimizes a segment path from the current pose to NBV, which fully considers MVS-related factors, as depicted in Fig.\ref{fig:local}.
Different from global planning, the cluster covered by the local segment is further subdivided into smaller clusters while viewpoints sampling space in local planning is determined by two neighboring clusters, as shown in Fig.\ref{fig:local}.
Local viewpoints set is represented as the form of $V_{L} = \{ VP_{1}:\{v_{l}^{1,1}, v_{l}^{1,2}, ..., v_{l}^{1,n} \}, ... , VP_{i}:\{v_{l}^{i,1}, v_{l}^{i,2}, ..., v_{l}^{i,k}, ... \} \}$, and clusters shown as $\mathcal{C}_{L} = \{ cls_{1}, cls_{2}, ..., cls_{j}, ... \}$.
Many previous studies \cite{schoenberger2016mvs,mendes2016next,mendez2017taking} demonstrated the high-quality MVS reconstruction thoroughly depending on the following factors, including visibility $\mathcal{S}_{vis}$,
relative distance $\mathcal{S}_{dis}$ and triangulation angle $\mathcal{S}_{ang}$, presented in Eq.\ref{equ:quality}, \ref{equ:vis}, \ref{equ:dis}, \ref{equ:ang}.
To optimize MVS performance of a local path, we decompose the MVS structure into several basic triangulation units, which is defined as each of two neighboring viewpoints in the local path with their co-visible cluster surface.
Furthermore, the MVS performance of this path can be viewed as the reconstruction quality $Q$ sum of all triangulation units in this path.
Then, $Q$ of a triangulation unit can be written as:
\begin{equation}
\label{equ:quality}
Q(v_{1}, v_{2}, s) = \mathcal{S}_{vis} \cdot \mathcal{S}_{dis} \cdot \mathcal{S}_{ang},
\end{equation}
where the cluster surface $s$ under two viewpoints $v_{1}$ and $v_{2}$.
$\mathcal{S}_{vis}$ is the score for the visibility ratio ($r \in [0,1]$) of two viewpoints, shown as:
\begin{equation}
\label{equ:vis}
\mathcal{S}_{vis}(v_{1}, v_{2}, s) = \frac{r(v_{1}, s) + r(v_{1}, s)}{2}.
\end{equation}
Let $dis_{1}$ and $dis_{2}$ be the distances from two viewpoints to the surface centroid.
We expect $\mathcal{S}_{dis}$ to be close to 1 which leads to similar resolution in two viewpoints images for better depth estimation. The formula follows:
\begin{equation}
\label{equ:dis}
\mathcal{S}_{dis}(v_{1}, v_{2}, s) = \frac{min(dis_{1}, dis_{2})}{max(dis_{1}, dis_{2})}.
\end{equation}
$\mathcal{S}_{ang}$ measures the triangulation performance, both accuracy and matchability.
Let $\epsilon$ be the angle between $vec_{1}$ and $vec_{2}$.
$\varepsilon_{1}$ is the angle between the normal $\mathcal{N}_{s}$ of $s$ and $vec_{1}$ while $\varepsilon_{2}$ is the same for $vec_{2}$.
Hence, $\mathcal{S}_{ang}$ can be written as:
\begin{equation}
\label{equ:ang}
\begin{split}
vec_{h} & = \mathcal{C}_{s} - v_{h}, \\
\mathcal{S}_{ang}(v_{1}, v_{2}, s) & = exp(-(\frac{\epsilon-\epsilon_{d}+\varepsilon_{1}-\varepsilon_{2}}{\kappa})^2),
\end{split}
\end{equation}
where $\mathcal{C}_{s}$ is the centroid of $s$, $\epsilon_{d}$ is the desired triangulation angle and $\kappa$ is a small constant value for numerical stability.
Thus, we can formulate the MVS heuristics cost $c_{MVS}$ and total cost $c_{l}$ with movement cost as:
\begin{equation}
c_{MVS}(v_{1}, v_{2}, s) = \frac{1}{Q(v_{1}, v_{2}, s)},
\end{equation}
\begin{equation}
\label{equ:local_cost}
c_{l}(v_{1}, v_{2}, s) = \alpha_{1} c_{MVS}(v_{1}, v_{2}, s) + (1-\alpha_{1})c_{g}(v_{1}, v_{2}).
\end{equation}
Assuming there are $N_{L}$ clusters totally, the number of $V_{L}$ should be $N_{L}+1$ to satisfy the $N_{L}$ defined triangulation units.
To optimize the quality-driven cost $c_{l}$ of the local path, we formulate it as a graph search problem. Then, the Dijkstra algorithm is adopted to search for the optimal local path,
$\mathcal{P}_{L} = \{ v_{l}^{1,i_1}, v_{l}^{2,i_2}, ..., v_{l}^{N_{L}+1,i_{N_{L}+1}} \} $ that minimizes the proposed cost:
\begin{equation}
\mathop{min} \sum_{k=1}^{N_{L}}c_{l}(v_{l}^{k,i_k}, v_{l}^{k+1, i_{k+1}}, cls_{k}).
\end{equation}
Lastly, through leveraging \cite{zhou2019robust}, we convert the local path $\mathcal{P}_{L}$ to the safe, smooth, dynamically feasible, and minimum-time B-spline local trajectory considering
MVS performance to realize an effective collection of image-pose pairs.
\begin{figure}[t]
\begin{center}
\includegraphics[width=0.85\columnwidth]{local.png}
\vspace{-0.5cm}
\end{center}
\caption{\label{fig:local} Quality-driven local path planning based on the graph search.
Through fully considering MVS-related factors,
a reconstruction quality-driven local path is produced with its corresponding trajectory. (Sect.\ref{subs:local})}
\vspace{-1.4cm}
\end{figure}
\begin{figure*}[t]
\begin{center}
\includegraphics[width=1.99\columnwidth]{experiment.png}
\vspace{-0.5cm}
\end{center}
\caption{\label{fig:experiment} Benchmark comparisons (Reconstructed 3D models and volumetric maps with the executed trajectories) of the proposed method, Plan3D \cite{hepp2018plan3d},
CAPP \cite{zhang2021continuous} and FUEL \cite{zhou2021fuel} in two scenarios (\textbf{\textit{Palace}} and \textbf{\textit{Village House}}).}
\vspace{-0.4cm}
\end{figure*}
\section{Experiments}
\label{sec:exp}
\subsection{Implementation Details}
\label{subs:imp}
To train our SPM, we use a synthetic CAD model set, Houses3K \cite{peralta2020next} to create a construction scene dataset containing partial and complete
point clouds. Also, we collect other types of construction models in Unreal Engine (UE4\footnote[1]{https://www.unrealengine.com/en-US/}). Specially,
we leverage Blender\footnote[2]{https://www.blender.org/} to generate partial point clouds with 12900 models from different construction categories.
Additionally, we set $N_{C} = 8192$ in the data pre-processing phase. As for training details, the SPM is trained for 200 epochs on single NVIDIA RTX 3070Ti taking 13 hours.
We choose the Adam \cite{kingma2014adam} optimizer during training with an initial learning rate of 1e-4 with a batch size of 16, decaying to 1e-5 at 150 epochs.
In hierarchical planning, we set $\beta_{1}=1.0$ and $\beta_{2}=5.0$ in Eq.\ref{equ:cost_mat}, $\epsilon_{d}=22.5^{\circ}$ and $\kappa=0.2$ in Eq.\ref{equ:ang},
and $\alpha_{1}=0.8$ in Eq.\ref{equ:local_cost}. In global coverage path planning, the ATSP is solved through a Lin-Kernighan-Helsgaun heuristic solver
\cite{helsgaun2000effective}.
In all experiments, a geometric controller \cite{lee2010geometric} is used for tracking control of the $(x,y,z,\theta)$ trajectory. SPM runs on an NVIDIA
RTX 3070 Ti (GPU Memory-Usage: \textbf{$\sim$1GB}) and other modules run on an Intel Core i9-10900K CPU.
\subsection{Benchmark Comparisons}
\label{subs:bmk}
We conduct simulation Experiments in a realistic simulator, AirSim in UE4. We benchmark it in two highly textured scenarios,
\textbf{\textit{Palace}} ($15 \times 25 \times 14m^3$) and \textbf{\textit{Village House}} ($14 \times 11 \times 12m^3$). The proposed
method is compared with three methods: Plan3D \cite{hepp2018plan3d} (\textit{explore-then-exploit}), CAPP \cite{zhang2021continuous} (prior-based)
and FUEL \cite{zhou2021fuel} (exploration-based). There is no open source code for Plan3D \cite{hepp2018plan3d} and CAPP \cite{zhang2021continuous},
so we use our implementation. A UAV mounting a forward-looking camera with FOV $[80^{\circ}, 60^{\circ}]$ is adopted as the experimental platform.
It captures images with a resolution $1280 \times 720$ px. In both scenarios, we limit the $v_{max}=0.85m/s$ and $\omega = 0.5 rad/s$.
Plan3D \cite{hepp2018plan3d} firstly executes a pre-defined flight for the coarse model, and then generates the global path using our planner.
CAPP \cite{zhang2021continuous} produces a global coverage path also by our planner according to input prior model. As for FUEL \cite{zhou2021fuel},
it collects image-pose pairs of the target while exploring the unknown environments containing the target. The collected data of each method is
processed through COLMAP to obtain reconstructed 3D models.
\begin{table}
\renewcommand\arraystretch{1.4}
\tabcolsep=1mm
\centering
\caption{Path Planning and 3D Reconstruction results in two scenarios. \label{tab:benchmark}}
\begin{tabular}{cccccccc}
\hline
& Method & \begin{tabular}[c]{@{}c@{}}Prior \\Model \end{tabular} & \begin{tabular}[c]{@{}c@{}}Path \\Length ($m$) \end{tabular} & \begin{tabular}[c]{@{}c@{}}Time \\($s$)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Recall \\(\%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Precision \\(\%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}F-score \\(\%)\end{tabular} \\
\hline
\hline
\multirow{4}{*}{\rotatebox{90}{\textit{Palace}}} & Plan3D\cite{hepp2018plan3d} & \XSolidBrush & 375.5 & 507.7 & 74.48 & 82.57 &78.32 \\
\cline{2-8}
& CAPP\cite{zhang2021continuous} & \textcolor{red}{\Checkmark} & 243.6 & 322.6 & 69.21 &85.86 &76.64 \\
\cline{2-8}
& FUEL\cite{zhou2021fuel} & \XSolidBrush & 371.1 & 469.8 & 40.31 & 38.38 & 39.32 \\
\cline{2-8}
& Ours & \XSolidBrush & \textbf{213.1} & \textbf{252.7} & \textbf{74.67} & \textbf{86.45} &\textbf{80.13} \\
\hline
\multirow{4}{*}{\rotatebox{90}{\textit{Village House}}} & Plan3D\cite{hepp2018plan3d} & \XSolidBrush & 239.3 & 310.6 & 64.28 &72.86 &68.30 \\
\cline{2-8}
& CAPP\cite{zhang2021continuous} & \textcolor{red}{\Checkmark} & 193.4 & 242.3 & 80.30 &\textbf{84.60} &82.40 \\
\cline{2-8}
& FUEL\cite{zhou2021fuel} & \XSolidBrush & 405.1 & 506.8 & 44.35 &36.46 &40.02 \\
\cline{2-8}
& Ours & \XSolidBrush & \textbf{153.2} & \textbf{184.6} & \textbf{84.54} &83.13 &\textbf{83.83} \\
\hline
\end{tabular}
\vspace{-0.7cm}
\end{table}
We evaluate their performance by two metrics, efficiency (path length and time) and reconstruction quality (\textit{F-score}).
The average comparison results are listed in Table.\ref{tab:benchmark} and Fig.\ref{fig:experiment}. Compared with the other methods, we both achieve much shorter time and path length,
primarily since our planner gives a more efficient global coverage path with the support of SPM predictions.
As for reconstruction quality, we refer to the evaluation process and metrics in \cite{knapitsch2017tanks}. First, we perform point cloud alignment between
the reconstructed model and ground truth. Then, two point clouds are uniformly resampled with a voxel size of $0.05m$, which are compared by $Precision$ and $Recall$.
$Precision$ is presented as the percentage of reconstructed points close to a ground truth point while $Recall$ is defined as the percentage of ground truth points
close to a reconstructed point. We set the distance between two points is less than $0.1m$, which are close points. Afterwards, the \textit{F-score} is formulated as
$F-score = \frac{2(Precision \times Recall)}{Precision+Recall}$.
Fig.\ref{fig:experiment} and Table.\ref{tab:benchmark} depicts the reconstruction quality in two scenarios of each reconstructed model by four methods.
Obviously, the proposed method achieves higher $Precision$, $Recall$, and \textit{F-score}, mainly because our local planning aims to optimize MVS performance,
and our method real-time replans the paths for complete details whenever predictions and map are updated.
Although our $Precision$ is slightly lower than CAPP \cite{zhang2021continuous} in \textbf{\textit{Village House}} scenario, no prior model is required in our method.
\begin{table}
\renewcommand\arraystretch{1.4}
\tabcolsep=1mm
\centering
\caption{Computation time of each module. \label{tab:real-time}}
\begin{tabular}{l|ccccc}
\hline
& SPM & \begin{tabular}[c]{@{}c@{}}Global \\Planning \end{tabular} & \begin{tabular}[c]{@{}c@{}}Local \\Planning \end{tabular} & \begin{tabular}[c]{@{}c@{}}Traj. \\Opt.\end{tabular} & \begin{tabular}[c]{@{}c@{}}Total \\Comp.\end{tabular} \\
\hline
\multirow{1}{*}{{Time ($ms$)}} &$\sim$26.8 &$\sim$93.5 & $\sim$0.5 & $\sim$3.7 & $\sim$124.7 \\
\hline
\end{tabular}
\vspace{-0.72cm}
\end{table}
As shown in Table.\ref{tab:real-time}, the proposed system can finish planning once in approximately $100ms$, which enables enough frequency for
\textit{real-time} planning on the onboard computer of a realistic UAV.
\subsection{SPM Prediction Performance}
\label{subs:spm_performance}
Compared with the point cloud completion task, the surface prediction in our system is more difficult since no exact scale and
center are given for normalization. However, under Chamfer Distance and \textit{F-score} metrics, our SPM without prior scale and center still outperforms PCN \cite{yuan2018pcn} in the above task using the generated data (Sect.\ref{subs:imp}) (\textcolor{red}{Left}) and ShapeNet dataset (\textcolor{red}{Right}), as listed in Table.\ref{tab:spm}.
Considering reconstructed surfaces, PCN \cite{yuan2018pcn} produces smoother surfaces than coarse prediction results generated by SPM.
\begin{table}
\scriptsize
\renewcommand\arraystretch{1.4}
\tabcolsep=1mm
\centering
\caption{Point cloud completion Performance Comparisons. \label{tab:spm}}
\begin{tabular}{l|cccc}
\hline
Method & $\#$Param(M) & L1\_CD (1e-3$m$) & L2\_CD (1e-4$m$) & F-score (\%) \\
\hline
\hline
our SPM & \textbf{28.20} &\textbf{13.6404} / \textbf{9.4461} &\textbf{14.7100} / \textbf{3.9368} &\textbf{52.6050} / \textbf{68.6693} \\
\hline
PCN \cite{yuan2018pcn} & 28.91 &15.5221 / 10.4897 &18.3987 / 4.7431 &50.1210 / 65.7207 \\
\hline
\end{tabular}
\vspace{-0.72cm}
\end{table}
\section{Conclusions}
\label{sec:conclusion}
In this paper, we propose a prediction-boosted planning framework for efficient high-quality 3D reconstruction with an autonomous single trail.
The proposed SPM predicts complete surfaces from the partial map to provide global information for the path planner. Based on the SPM, a hierarchical
planner sequentially plans motions for 3D reconstruction. It finds efficient global coverage paths, optimizes reconstruction quality-driven local paths to improve
MVS performance, and generates smooth corresponding local trajectories. The method significantly improves reconstruction efficiency and quality via introducing
SPM and considering MVS-related factors. Challenging benchmark in realistic simulation shows the competence of \textbf{PredRecon} compared with the existing classical and \textit{state-of-the-art} methods.
The limitation of our method is insufficient real-world tests as well as the limited generalizability and robustness of SPM. In the future, we plan to further optimize SPM architecture for better data representation and implement more challenging real-world tests.
| {'timestamp': '2023-02-10T02:08:16', 'yymm': '2302', 'arxiv_id': '2302.04488', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04488'} | arxiv |
\section{Introduction}
A crucial assumption underlying the most current theory of machine learning is that
the distribution of the training samples is identical to the distribution of the test samples.
However, it is often violated in practice where the distribution of test data
deviates from the distribution of training data,
therefore we need to develop models that work well under realistic violations of this assumption.
In this paper, we assume that the density distribution of future data, instead of being completely unknown,
is restricted to a class of distributions
and develop a method based on importance sampling and minimax principle\cite{farnia2016minimax
Although there is considerable freedom in quantizing
distribution deviation\cite{pardo2018statistical,kailath1967divergence,renyi1961measures},
Kullback–Leibler divergence\cite{kullback1951information,williams1980bayesian}
has been widely used as constraints for regularization in
bounded rationality \cite{genewein2015bounded,ortega2013thermodynamics},
policy optimization\cite{schulman2015trust,hihn2019information} and other learning problems.
In this work, we use Kullback-Leibler divergence to measure distribution deviation.
The proposed model aims to minimize the empirical risk in maximum degradation for a given deviation level
and hence the corresponding optimization problem is a minimax problem.
Inspired from the importance sampling method\cite{glynn1989importance,shi2009hierarchical,shi2009neural},
we convert the constraint between the training distribution and test distribution
to a constraint over the importance sampling weights.
Then, we use the Lagrange method to reformulate the constrained minimax optimization problem into
unconstrained minimum optimization problem which can be solved by available algorithms
like SGD, Adam, etc.
The innovation of our proposed model is that the future uncertainty is controlled by $T$,
the Lagrange multiplier in the reformulated optimization problem.
The objective function of the unconstrained optimization problem is called the Importance Sampling loss (ISloss).
A logarithmic transformation of ISloss is called the Logarithmic Importance Sampling loss (LogISloss).
We reveal that the minimization of LogISLoss is equivalent to the minimization of p-norm with $p=\frac{1}{T}$.
Our proposed importance sampling loss can be applied to many machine learning problems over different applications,
including regression, classification, clustering, etc.
In this paper, we adopt the proposed model for the face verification task.
Face verification\cite{chen2021ring} is a task used to
determine whether a pair of images belongs to the same individual.
In the training stage, the model learns a deep feature embedding for an image through the cross entropy loss.
In the test stgae, the model calculates a cosine similarity
between the two feature embeddings for a given pair of images.
We conducted experiments on Racial Faces in the Wild
datasets(RFW)\cite{Wang_2019_ICCV, MetaRFW} and had the following findings.
First, the importance sampling weights highlighted the hard classes in the training stage.
Second, the model trained under LogISloss attained better performance when there was a large distribution deviation.
Third, the model trained under LogISloss emphasized the hard pairs quantized by cosine similarity.
\textbf{Outline of the paper}
\Cref{sec:IS-model} describes our proposed data variation robust learning model
based on importance sampling and the algorithm to solve it.
The relationship between LogISloss and p-norm is also revealed in this section.
\Cref{sec:face-verification} applies the proposed model to the face verification task.
\Cref{sec:experiments} shows the experiment results on RFW datasets
with respect to distribution deviation and hard samples.
Finally, we conclude this paper in \Cref{sec:conclusion}.
\section{Proposed Method} \label{sec:IS-model}
In the learning problem considered in this paper, we have training data
$x_1,x_2,\dots, x_N$ which are generated i.i.d according to some (usually unknown) probability density function $q(x)$
and a set of loss function $L(x,\omega)$ and no future data is available for the learning system.
Our aim is to construct a learning algorithm for a population with an unknown distribution $p(x)$.
We further assume that if $p(x)$ are, instead of being completely unknown,
restricted to a class of distributions, i.e.
\begin{equation}
\Gamma=\{p(x):KL(p(x)\parallel q(x))=\int p(x)log \left(\frac{p(x)}{q(x)}\right)dx\leq C\}.
\end{equation}
Therefore, our goal becomes to minimize the worst-case expected loss over $\Gamma$.
A \textit{minimax} approach is applied through minimizing the worst-case loss restricted to this constraint.
\Cref{sec:IS-principle} gives out the principled deviation of the minimax approach
and solves the corresponding optimization problem.
\Cref{sec:log-ISLoss} presents the model under the logarithmic transformation of $L(x,\omega)$
and reveals its relationship with p-norm.
\subsection{Principle of ISloss} \label{sec:IS-principle}
The performance of a learning system for a given distribution $p(x)$ is measured by the
following the risk functional
\begin{equation}
R(\omega)=\int_x L(x,\omega)p(x)dx \label{eq:risk-functional}.
\end{equation}
First, since we don't know exactly the future data distribution $p(x)$ in $\Gamma$,
we need to find a $p(x)$ that maximizes the objective function.
Given the worst-case distribution $p(x)$,
we aim to find the $\omega$ which minimizes $R(\omega)$.
Therefore, the corresponding optimization problem becomes a minimax problem
\begin{align}
\begin{split} \label{eq:original-problem}
\min_{\omega} \max_{p(x)} \quad & R(\omega) =\int_x L(x,\omega) p(x) dx \\
\text{s.t.} \quad & KL(p(x)||q(x)) \leq C. \\
\end{split}
\end{align}
Second, we reformulate the risk functional and the distribution deviation constraint
using the idea of importance sampling method
where a mathematical expectation with respect to $p(x)$ is approximated by a weighted average of random draws
from another distribution $q(x)$.
For any probability density $q(x)$ with $q(x)>0$ whenever $p(x)>0$,
the risk functional is
\begin{equation}
R(\omega)=\int_x L(x,\omega)p(x)dx
=\int_x L(x,\omega){{p(x)\over q(x)} \over {\int_x {p(x)\over q(x)} q(x) dx} }q(x)dx, \label{eq:R-IS}
\end{equation}
and the KL-divergence between $p(x)$ and $q(x)$ is
\begin{equation}
\begin{split} \label{eq:KL-IS}
KL(p(x)\parallel q(x)) & =\int_x p(x)log \left({p(x)\over q(x)}\right) dx\\
& =\int_x {{p(x)\over q(x)} \over {\int_x {p(x)\over q(x)} q(x) dx}}
log\left({{p(x)\over q(x)} \over {\int_x {p(x)\over q(x)} q(x) dx} }\right)q(x)dx.
\end{split}
\end{equation}
Third, we derive the empirical estimation of \eqref{eq:R-IS} and \eqref{eq:KL-IS}.
A standard approach to train the models in statistical learning
is to use Empirical Risk Minimization(ERM)\cite{vapnik1999nature,farnia2016minimax}.
ERM learns the prediction rule by minimizing an approximated loss
under the empirical distribution of samples, which is defined as
\begin{equation}
R_E={1\over N} \sum_{i=1}^{N} L(x_i,\omega) \label{eq:empirical-risk}
\end{equation}
where the subscript E represents \textit{empirical}.
Suppose the observed dataset $D=\{x_1, x_2, \dots, x_N\}$ is $N$ i.i.d samples drawn from $q(x)$.
The self-normalized importance sampling weight\cite{rubinstein2016simulation} for data point $x_i$ is
\begin{equation}
w_i = w(x_i) = \frac{ \frac{p(x_i)}{q(x_i)} }{\frac{1}{N}\sum_{j=1}^{N} \frac{p(x_j)}{q(x_j)}} \label{eq:is-weights}
\end{equation}
where $\sum_{i=1}^{N} w_i=1$.
$W=[w_i]_{N\times 1}$ is called the importance sampling weight.
Therefore, the empirical estimation of \eqref{eq:R-IS} is
\begin{equation}
R_E(\omega) = \frac{1}{N} \sum_{i=1}^{N} \frac{\frac{p(x_i)}{q(x_i)}}
{\frac{1}{N} \sum_{j=1}^{N} \frac{p(x_j)}{q(x_j)}}L(x_i, \omega)
= \sum_{i=1}^{N} L(x_i, \omega) w_i \label{eq:R-IS-proof}
\end{equation}
and the empirical estimation of \eqref{eq:KL-IS} is
\begin{align}
\label{eqn:KLpq-proof}
\begin{split}
KL_E(p(x) \parallel q(x)) & = \frac{1}{N} \sum_{i=1}^{N} \frac{ \frac{p(x_i)}{q(x_i)} }{\frac{1}{N}\sum_{j=1}^{N} \frac{p(x_j)}{q(x_j)}}
log \frac{ \frac{p(x_i)}{q(x_i)} }{\frac{1}{N}\sum_{j=1}^{N} \frac{p(x_j)}{q(x_j)}} \\
& = \sum_{i=1}^{N} \frac{ \frac{p(x_i)}{q(x_i)} }{\sum_{j=1}^{N} \frac{p(x_j)}{q(x_j)}}
\left( log\big( \frac{ \frac{p(x_i)}{q(x_i)} }{\sum_{j=1}^{N} \frac{p(x_j)}{q(x_j)}} \big) - log \frac{1}{N} \right) \\
& = \sum_{i=1}^{N} w_i log \frac{w_i}{\frac{1}{N}} = KL(w_i \parallel \{ \frac{1}{N} \}) \\
& = \sum_{i=1}^{N} w_i log w_i + log N \\
\end{split}
\end{align}
where $\{ \frac{1}{N}\}$ denotes the discrete uniform distribution with $N$ samples.
Plugging \eqref{eq:R-IS-proof} and \eqref{eqn:KLpq-proof} back into \eqref{eq:original-problem},
the optimization problem \eqref{eq:original-problem} becomes
\begin{align}
\min_{\omega}\max_{W} \quad & R_E(\omega,W) =\sum_{i=1}^{N} L(x_i,\omega)w_i, \label{eq:empirical-problem}\\
\text{s. t.} \quad & \sum_{i=1}^{N} w_i log w_i + log(N) \leq C, \label{eq:wi-KL-constraint} \\
& \sum_{i=1}^{N} w_{i}=1, w_{i}\in [0,1], \quad 1\leq i \leq N. \label{eq:wi-constraint}
\end{align}
where \eqref{eq:wi-constraint} is the constraint for the importance sampling weight $W$.
Next, the constrained optimization problem in \eqref{eq:empirical-problem}
can be reformulated to the unconstrained optimization problem using the Lagrange method.
Let the Lagrange multiplier for \eqref{eq:wi-KL-constraint} and \eqref{eq:wi-constraint}
be $T$ and $\lambda$ respectively.
The max problem in \eqref{eq:empirical-problem} can be reformulated as
\begin{equation}
F_{0}(\omega,W)=\sum_{i=1}^{N} L(x_i,\omega)w_i-T\sum_{i=1}^{N} w_i log w_i-Tlog(N) -\lambda(\sum_{i=1}^{N} w_i-1).
\end{equation}
Here $T>0$ is the temperature that governs the level of randomness of $W$,
which implicitly controls the allowed distribution deviations.
Specifically, when $T \rightarrow \infty$, the distribution shift $KL(p(x)\parallel q(x))$ should be small
while for $T\rightarrow 0$, the distribution shift can be very large.
Since $T$ is a pre-defined hyperparameter, $Tlog(N)$ is a constant and can be omitted.
Then, the objective function becomes
\begin{equation}
F(\omega,W)=\sum_{i=1}^{N} L(x_i,\omega)w_i-T\sum_{i=1}^{N} w_i log w_i -\lambda(\sum_{i=1}^{N} w_i-1). \label{eq:F-lagrange}
\end{equation}
Setting the derivative of $F(\omega,W)$ with respect to $w_i$ to zero,
we obtain the optimality necessary condition for $w_i$, which is
\begin{equation}
w_i={{exp({L(x_i,\omega)\over T})}\over{\sum_{j=1}^{N}{exp({L(x_j,\omega)\over T})}}}. \label{eq:wi-necessary}
\end{equation}
Substituting \eqref{eq:wi-necessary} back into \eqref{eq:F-lagrange},
we get the effective loss functional
\begin{equation}
F^*(\omega)=T log( {\sum_{i=1}^{N}{exp({L(x_i,\omega)\over T})}}). \label{eq:isloss}
\end{equation}
The minimization of $F^*(\omega)$ with respect to $\omega$ is equivalent to min-max of $R_E(\omega,W)$
with respect to $\omega, W$.
In this paper, the objective function of the proposed model in \eqref{eq:isloss}
is named as Importance Sampling loss, \textit{ISloss} for short.
\subsection{LogISloss} \label{sec:log-ISLoss}
In this section, we use the logarithmic transformation $logL(x, \omega)$ instead of $L(x, \omega)$ as a loss measure
and derive the corresponding objective function.
The logarithmic risk functional is
\begin{equation}
R_{log}(\omega) =\int_x log L(x,\omega) p(x) dx.\\
\end{equation}
Similarly, as the derivation for ISloss, the corresponding optimization problem becomes
\begin{align}
\begin{split} \label{eq:log-problem}
\min_{\omega} \max_{p(x)} \quad & R_{log}(\omega) =\int_x logL(x,\omega) p(x) dx \\
\text{s.t.} \quad & KL(p(x)||q(x)) \leq C. \\
\end{split}
\end{align}
The optimality necessary condition for $w_{log}^{i}$ is
\begin{equation}
w_{log}^{i} = \frac{L(x_i, \omega)^{\frac{1}{T}}}{\sum_{j=1}^{N} L(x_i, \omega)^{\frac{1}{T}}} \label{eq:log-wi}
\end{equation}
and the effective empirical loss functional becomes
\begin{equation}
F^{*}_{log}(\omega) = log (\sum_{i=1}^{N} L(x_i, \omega)^{\frac{1}{T}})^{T}. \label{eq:logisloss}
\end{equation}
In this paper, \eqref{eq:logisloss} is named Logarithmic Importance Sampling loss,
\textbf{LogISloss} for short.
Equation \eqref{eq:logisloss} shows the minimization problem of
the logarithmic version $F^*$ is equivalent to the
minimization of the p-norm loss function with $ p={1\over T}$.
The objective function of ISloss\eqref{eq:isloss} involves exponential and not stable in training,
therefore we use LogISloss\eqref{eq:logisloss} in subsequent experiments.
\section{Application on face verification task} \label{sec:face-verification}
Face verification\cite{chen2021ring,bianco2017large} is one of the most popular topics
in the community of computer vision and pattern recognition.
It is a technology used to determine whether a pair of images belong to the same individual and
is widely used for identity authentication in many areas, such as attendance\cite{pss2016rfid},
finance\cite{aru2013facial}, transportation\cite{van2022intelligent},
self-service and other fields.
In the face verification community, researchers have proposed large-margin softmax variants
\cite{deng2019arcface,wang2018additive,wang2018cosface,wang2020mis,Liu2022SphereFaceR}
to enhance the inter-class discrepancy and intra-classs compactness,
ArcMargin\cite{deng2019arcface} and AddMargin\cite{wang2018additive,wang2018cosface} are two widely-used ones.
In this section, we apply the proposed model to face verification task under ArcMargin and AddMargin.
We denote the cross entropy loss under ArcMargin and AddMargin as \textit{ArcLoss} and \textit{AddLoss}
and derive the logarithmic importance sampling loss under ArcMargin and AddMargin.
\subsection{IS-ArcLoss}
To begin with, let us introduce some notations to facilitate the discussion in this section.
Suppose $N$ is the number of training samples and $C$ is the number of classes.
$x_i \in \mathcal{R}^d$ denotes the deep feature of $i$-th sample.
For $x_i$, we refer $y_i$ as the target class and $j$ as the non-target class (the label excluding the ground truth one).
$W_j \in \mathcal{R}^d$ denotes the $j$-th column of the weight $W \in \mathcal{R}^{d\times C}$
and $b_j \in \mathcal{R}^C$ is the bias term. We fix bias $b_j=0$ for simplicity.
Suppose $\theta_{j,i}$ is the angle between $W_j$ and $x_i$.
Following \cite{deng2019arcface, wang2018cosface}, we fix the weight
$\norm{W_j}=1$ by $l_2$ normalization and fix the deep feature
$\norm{x_i}$ by $l_2$ normalization and rescale it to $s$.
The feature scale $s$ is set to 64 following \cite{deng2019arcface,wang2018cosface}.
ArcFace(Additive Angular Margin Loss)\cite{deng2019arcface}
uses the arc-cosine function to calculate the angle between the feature $x_i$ and the target weight $W_{y_i}$.
The model adds an additive angular margin $m$ to the \textit{target angle}
to enhance the inter-class discrepancy and intra-class compactness.
The ArcLoss for the $i$-th sample is defined as follows
\begin{equation}
L_{i}^{Arc} = - log \frac{e^{s(cos(\theta_{y_i,i} + m))}}
{e^{s(cos(\theta_{y_i,i} + m))}+\sum_{j=1,j\neq y_i}^{C} e^{s cos(\theta_{j,i})}}. \label{eq:arc-margin}
\end{equation}
Suppose $L_{i}^{Arc}$ denote the ArcLoss for the $i$-th sample,
and $n$ denote the number of samples in each training batch,
then we name the proposed logarithmic importance sampling loss as \textit{IS-ArcLoss},
which is defined as follows
\begin{equation}
L^{IS}_{Arc} = log (\sum_{i=1}^{n}(L_{i}^{Arc})^{1\over T})^{T}. \label{eq:IS-ArcMargin}
\end{equation}
Here, the superscript \textit{IS} denotes \textbf{I}mportance \textbf{S}ampling.
In subsequent experiments for ArcLoss and IS-ArcLoss, the angular margin penalty $m$
is fixed to 0.5 as recommended by \cite{deng2019arcface}.
\subsection{IS-AddLoss}
AddMargin(Additive margin)\cite{wang2018additive},
also known as the Large-Margin Cosine Loss\cite{wang2018cosface},
calculates the angle between the feature $x_i$ and the target weight $W_{y_i}$.
The model minus an additive margin $m$ to the cosine of the target angle
to maximize inter-class variance and minimize intra-class variance.
The AddLoss for the $i$-th sample is defined as follows
\begin{equation}
L_{i}^{Add} = - log \frac{e^{s(cos(\theta_{y_i,i})-m)}}
{e^{s(cos(\theta_{y_i,i})-m)} + \sum_{j=1,j\neq y_i}^{C}e^{s cos(\theta_{j,i})}}. \label{eq:add-margin}
\end{equation}
Suppose $L_{i}^{Add}$ denote the AddLoss for the $i$-th sample,
then we name the proposed logarithmic importance sampling loss as \textit{IS-AddLoss},
which is defined as follows
\begin{equation}
L^{IS}_{Add} = log (\{\sum_{i=1}^{n}(L_{i}^{Add})^{1\over T}\})^{T}. \label{eq:IS-AddMargin}
\end{equation}
In subsequent experiments for AddLoss and IS-AddLoss, the additive margin $m$
is fixed to 0.35 as recommended by \cite{wang2018cosface}.
\section{Experiments and Results} \label{sec:experiments}
In this section, we conducted experiments to show the effectiveness of the proposed method.
\Cref{sec:datasets} introduces datasets including training datasets, test datasets and the training schedule.
\Cref{sec:weights} analyzes the importance sampling weights.
\Cref{sec:temperature} describes how the hyperparameter $T$ affects the model performance.
\Cref{sec:distributionDeviation} compares ArcLoss and IS-ArcLoss, AddLoss and IS-AddLoss with respect to distribution deviations.
\Cref{sec:Hard Pairs} compares ArcLoss and IS-ArcLoss with respect to hard examples.
\subsection{Datasets} \label{sec:datasets}
In the face verification system, training stage and test stage are different.
The training stage is used to learn the deep feature embedding for a given image through a classification task.
In the test stage, the score of a given image pair is usually calculated
by the cosine similarity between the two feature embeddings.
If the score is higher than a given threshold, the input pair is considered a positive pair.
If the score is lower than a given threshold, the input pair is considered a negative pair.
The given verification threshold is obtained from cross-validation by a pre-defined split in test datasets.
\textbf{Training Datasets}
In this paper, we uses the Racial Faces in-the-Wild(RFW) database\cite{Wang_2019_ICCV},
which includes four races, namely Caucasian, African, Asian and Indian.
We use BUPT-Equalizedface\cite{Wang_2019_ICCV} as the training dataset which
contains 27999 individuals and 1251416 images.
The number of individuals in Caucasian, African, Asian and Indian
are 7000, 7000, 7000 and 6999 respectively.
The detailed statistics of BUPT-Equalizedface are given in Appendix-A.
In later discussions, the four training subsets in BUPT-Equalizedface are denoted as
RFW-Caucasian, RFW-African, RFW-Asian and RFW-Indian.
\textbf{Test Datasets}
The RFW database has four test subsets, namely Caucasian, African, Asian and Indian.
There are about 14K positive pairs and 50M negative pairs\cite{Wang_2019_ICCV}
for each subset in the RFW-test, most of which are easy to distinguish.
In this work, the proposed model aims to emphasize large distribution deviations and hard samples.
Therefore, we use the RFW-test for evaluation, which is composed of
difficult pairs selected based on cosine similarity between embeddings of each pair\cite{Wang_2019_ICCV}.
Each subset (race) contains 3000 positive pairs and 3000 negative pairs, splited into 10 subsets in advance.
We selected the verification threshold for one split based on the remaining nine splits.
We propose RFW-extend as an extension to RFW-test and the details of the dataset are shown in \Cref{sec:Hard Pairs}.
\autoref{fig:RFW-imgs} shows selected positive pairs and negative pairs from each race.
It can be seen that some pairs are difficult even for human observers.
\begin{figure}
\begin{center}
\includegraphics[width=\linewidth]{RFW-imgs-celoss-27999.pdf}
\end{center}
\caption{Images from RFW-test.
Four rows show examples from Caucasian, African, Asian and Indian respectively.
(a) shows hard positive pairs and (b) shows hard negative pairs.}
\label{fig:RFW-imgs}
\end{figure}
\textbf{Experiment Settings}
The datasets were aligned and preprocessed in MXNet binary format
and the size of the cropped image were set to $112 \times 112$.
We set the training batch size, weight decay and momentum as 128, 5e-4 and 0.9, respectively.
The dimension of embedding feature was set to 512
following \cite{deng2019arcface,wang2018cosface}.
The initial learning rate was set to 0.1, and decreased by a factor of 10 at given epochs.
For the BUPT-Equalizedface dataset, we trained the network for 27 epochs
and decayed the learning rate at epochs 14, 20 and 24.
We used half of the suggested epochs in \cite{MetaRFW} to save training time.
We used IResNet-34\cite{deng2019arcface}, a 34-layer modified ResNet,
as the default backbone in all experiments if not otherwise specified.
We followed the Pytorch implementation of
insightface\footnote{\url{https://github.com/deepinsight/insightface/tree/master/recognition/arcface_torch}}
on one GTX 1080ti and one GTX 3090ti for training.
\subsection{Importance sampling weights} \label{sec:weights}
\begin{figure}
\begin{center}
\includegraphics[width=.8\linewidth]{weight.pdf}
\end{center}
\caption{Classification accuracy and the top-10 importance sampling weights.
X-axis represents the individual (ID) index.
Y-axis represents the average accuracy for each ID (ascending order).
The top-10 maximum importance sampling weights are marked in green points.}
\label{fig:weight}
\end{figure}
In this section, we give a heuristic example to show that
the importance sampling weights emphasize the hard samples in the training dataset.
We calculated the average classification accuracy for each individual (ID)
and highlighted the individuals with the top-10 maximum average weights.
We first calculated the cross entropy loss for each training sample
then used \eqref{eq:log-wi} to calculate the weight.
All models in \autoref{fig:weight} were trained under IS-ArcLoss($T=0.5$).
\autoref{fig:weight} shows that the individuals with maximum weights
are those with low accuracy,
especially in (c) where the top-10 maximum weights clustered around 0.
Hard samples are normally assumed to have low classification accuracy.
Therefore, this observation showed the importance sampling weight
emphasized hard training samples.
We further analyze how the importance sampling weights change over time in Appendix-B.
The experiment results indicated the importance sampling weights
gradually concentrated on hard samples as the training proceeded.
\subsection{Temperature} \label{sec:temperature}
\begin{figure}
\begin{center}
\includegraphics[width=.8\linewidth]{diffT.pdf}
\end{center}
\caption{Comparison of verification accuracy among different $T$.
X-axis represents training epochs while Y-axis represents verification accuracy.
The model was trained on RFW-Caucasian using IS-ArcLoss.}
\label{fig:diffT}
\end{figure}
In this section, we analyze how the temperature $T$ affects the model performance.
\autoref{fig:diffT} compares verification accuracy on four RFW-test datasets when $T=0.3,0.5,0.7,1.0$.
\autoref{fig:diffT} shows that $T=0.5$ achieves the best accuracy on African, Asian and Indian
while $T=0.7$ achieves the best accuracy on Caucasian.
One possible explanation is that the distribution deviation between RFW-Caucasian (training) and Caucasian(test)
is smaller than the distribution deviations between RFW-Caucasian (training) and African/Asian/Indian(test),
therefore, the test Caucasian favors a higher temperature, $T=0.7$.
This observation suggests that lower $T$ tolerates larger distribution deviations.
In this paper, we used a fixed $T=0.5$ as the default temperature in all subsequent experiments.
However, other training schedules on $T$ can be adopted.
For example, starting $T$ at a high temperature and decaying it during training.
How to choose a good schedule on $T$ for different learning problems will be explored in our future studies.
\subsection{Distribution deviations} \label{sec:distributionDeviation}
\begin{table}
\caption{\label{tab:race-arcmargin}
Verification accuracy(\%) of IResNet-34 models trained on four datasets.
``R-Cau, R-Afr, R-Asi, R-Ind'' represents RFW-Caucasian, RFW-African, RFW-Asian and RFW-Indian respectively.
\textit{Arc} represents ArcLoss and \textit{IS-Arc} represents IS-ArcLoss.
Results are in \% and a higher number indicates better performance.}
\centering
\begin{tabular}{ llllll }
\hline
Train & Loss & Cau & Afr & Asi & Ind \\
\hline
\multirow{ 2}{*}{R-Cau} &Arc & 93.55 & 82.23 & 84.70 & 88.77 \\
&IS-Arc & 94.15\tiny{(0.60)} & 83.22\tiny{(0.99)} & 85.82\tiny{(1.12)} & 89.40\tiny{(0.63)}\\
\hline
\multirow{ 2}{*}{R-Afr} &Arc & 89.23 & 92.37 & 84.02 & 88.20\\
&IS-Arc & 90.37\tiny{(1.14)} & 92.43\tiny{(0.06)} & 85.82\tiny{(1.80)} & 89.65\tiny{(1.45)}\\
\hline
\multirow{ 2}{*}{R-Asi} &Arc & 85.50 & 79.13 & 90.90 & 84.45\\
&IS-Arc & 87.20\tiny{(1.70)} & 80.30\tiny{(1.17)} & 91.17\tiny{(0.27)} & 85.32\tiny{(0.87)}\\
\hline
\multirow{ 2}{*}{R-Ind} &Arc & 87.98 & 81.47 & 83.60 & 91.50\\
&IS-Arc & 88.92\tiny{(0.94)} & 82.30\tiny{(0.83)} & 83.48\tiny{(-0.12)} & 91.80\tiny{(0.3)}\\
\hline
\end{tabular}
\end{table}
In this section, we compare the performance of LogISLoss and cross-entropy loss
with respect to distribution deviations.
\autoref{tab:race-arcmargin} compares verification accuracy between ArcLoss and IS-ArcLoss.
The models were trained on RFW-Caucasian, RFW-African, RFW-Asian, RFW-Indian
and tested on Caucasian, African, Asian, Indian.
We report the result at the epoch where the training race achieves the highest verification accuracy.
The accuracy gain (in small brackets) is the difference between our proposed IS-ArcLoss over ArcLoss.
For example, the accuracy of the model trained on RFW-Caucasian and tested on African is 82.23\%
of ArcLoss and 83.22\% of IS-ArcLoss, the accuracy gain is 0.99\%.
\autoref{tab:race-arcmargin} shows the following findings.
First, IS-ArcLoss performs better than ArcLoss in most cases.
Second, the accuracy gains in non-training races are higher compared with the training race
on three test datasets(RFW-Caucasian, RFW-African, RFW-Asian).
Take the models trained on RFW-Caucasian(first row) for example, the accuracy gain on
Caucasian, African, Asian, Indian is 0.6\%, 0.99\%, 1.12\% and 0.63\% respectively.
The accuracy gain on Caucasian(0.6\%) is the lowest.
This observation indicates that IS-ArcLoss has better generalization ability compared with ArcLoss.
If we assume the accuracy gap is a measure of the distribution shift,
then a larger accuracy gap indicates a larger distribution shift.
Next, consider the model trained on RFW-African(second row) for example,
the test accuracy on Asian, Indian and Caucasian is 84.02\%, 88.20\% and 89.23\%.
Under the previous assumption, the distribution deviations between
Asian, Indian, Caucasian and African are in increasing order.
The accuracy gain on the three datasets is 1.80\%, 1.45\% and 1.14\%, which is in decreasing order.
This observation implies that the proposed IS-ArcLoss performs better
when the distribution deviation is large.
More experiment results on IS-ArcLoss with respect to TAR@FAR
and on different backbones are shown in Appendix-C.
\begin{table}
\caption{\label{tab:race-addmargin}
Verification accuracy(\%) of IResNet-34 models trained on different training datasets.
\textit{Add} represents AddLoss and \textit{IS-Add} represents IS-AddLoss.}
\centering
\begin{tabular}{ llllll }
\hline
Train & Loss & Cau & Afr & Asi & Ind \\
\hline
\multirow{ 2}{*}{R-Cau} &Add & 94.28 & 83.27 & 85.70 & 89.45\\
&IS-Add & 93.68\tiny{(-0.60)} & 83.07\tiny{(-0.20)} & 85.97\tiny{(0.27)} & 89.68\tiny{(0.23)}\\
\hline
\multirow{ 2}{*}{R-Afr} &Add & 90.85 & 92.72 & 84.85 & 89.85\\
&IS-Add & 89.98\tiny{(-0.87)} & 92.50\tiny{(-0.22)} & 86.10\tiny{(1.25)} & 89.93\tiny{(0.08)}\\
\hline
\multirow{ 2}{*}{R-Asi} &Add & 86.75 & 79.62 & 91.17 & 85.22\\
&IS-Add & 86.87\tiny{(0.12)} & 80.63\tiny{(1.01)} & 90.28\tiny{(-0.89)} & 85.75\tiny{(0.53)}\\
\hline
\multirow{ 2}{*}{R-Ind} &Add & 88.93 & 82.78 & 83.93 & 92.13\\
&IS-Add & 88.47\tiny{(-0.46)} & 82.12\tiny{(-0.66)} & 83.02\tiny{(-0.91)} & 91.20\tiny{(-0.93)}\\
\hline
\end{tabular}
\end{table}
\autoref{tab:race-addmargin} compares verification accuracy between AddLoss and IS-AddLoss.
IS-AddLoss performs better than AddLoss on 3(RFW-Caucasian, RFW-African, RFW-Asian) out of 4 test datasets
on non-training races.
Another interesting observation is in line with the observation in \autoref{tab:race-arcmargin}.
For the models trained on RFW-African, the accuracy gain on Asian(84.85\%), Indian(89.85\%) and Caucasian(90.85\%)
is 1.25\%, 0.08\% and -0.87\%, which is in decreasing order.
For the models trained on RFW-Asian, the accuracy gain on African(79.62\%), Indian(85.22\%) and Caucasian(86.75\%)
is 1.01\%, 0.53\% and 0.12\%, which is in decreasing order.
The results also confirm our findings in \autoref{tab:race-arcmargin} that LogISloss performs better
when the distribution shift is large.
\autoref{tab:other-arcmargin} test LogISloss on several popular benchmarks,
including Labeled Faces in the Wild(LFW)\cite{huang2008labeled},
Age-DB\cite{moschoglou2017agedb},
Cross-age LFW(CALFW)\cite{zheng2017cross},
Cross-pose LFW(CPLFW)\cite{zheng2018cross} and
Celebrities in Frontal-Profile (CFP-FP and CFP-FF)\cite{sengupta2016frontal},
where LFW, AGE-DB, CALFW and CPLFW have 6000 pairs and CFP(large pose variation) has 7000 pairs.
These datasets are also split into 10 subsets in advance.
The results were evaluated on the final epoch.
\autoref{tab:other-arcmargin} shows that IS-ArcLoss performs better than ArcLoss in most cases.
To be specific, the accuracy gains on LFW and CFP-FF are low,
the accuracy gains on CALFW and CPLFW are medium,
and the accuracy gains on CFP-FP and AgeDB are high.
\begin{table*}
\caption{\label{tab:other-arcmargin}
Verification accuracy (\%) of IResNet-34 models tested on different datasets.}
\centering
\begin{tabular}{ llllllll p{8cm} }
\hline
Train & Loss & LFW & CFP-FP & CFP-FF & AgeDB & CALFW & CPLFW \\
\hline
\multirow{ 2}{*}{RFW-Caucasian} &ArcLoss & 99.30 & 86.39 & 98.90 & 94.67 & 92.28 & 84.40 \\
&IS-ArcLoss & 99.33(0.03) & 88.41(2.02) & 99.11(0.21) & 95.47(0.80)& 92.87(0.59) & 84.90(0.50) \\
\hline
\multirow{ 2}{*}{RFW-African} &ArcLoss & 99.12 & 86.03 & 98.77 & 90.68 & 91.37 & 82.82 \\
&IS-ArcLoss & 99.10(-0.02) & 87.09(1.06) & 98.97(0.20) & 92.20(1.52)& 91.77(0.40) & 83.62(0.80) \\
\hline
\multirow{ 2}{*}{RFW-Asian} &ArcLoss & 98.13 & 89.46 & 97.49 & 89.55 & 88.42 & 82.65 \\
&IS-ArcLoss & 98.62(0.49) & 91.51(2.05) & 97.37(-0.12) & 90.30(0.75)& 89.28(0.86) & 83.17(0.52) \\
\hline
\multirow{ 2}{*}{RFW-Indian} &ArcLoss & 98.62 & 92.30 & 98.27 & 89.28 & 89.32 & 84.93 \\
&IS-ArcLoss & 98.68(0.06) & 92.53(0.23) & 98.41(0.14) & 90.77(1.49)& 89.42(0.10) & 85.57(0.64) \\
\hline
\end{tabular}
\end{table*}
\subsection{Hard Pairs} \label{sec:Hard Pairs}
\textbf{RFW-test-extend Dataset}
In this experiment, we propose an extended test dataset \textit{RFW-test-extend} to include more pairs for evaluation.
The extended dataset has four subsets, namely Caucasian-extend, African-extend, Asian-extend and Indian-extend.
The number of positive pairs for the four subsets are 13650,14050,15690,13860
and the number of negative pairs are 42260,43370,54890,43120.
All positive pairs and negative pairs are randomly split into 10 folds.
The generation and statistics for RFW-extend are shown in Appendix-A
In face verification task, for positive pairs, the similarity between two images should be high,
therefore \textbf{hard positive} pairs have low similarity.
For negative pairs, the similarity between two images should be low,
therefore \textbf{hard negative} pairs have high similarity.
\autoref{fig:plotWorst} shows the similarity of top-100 hard positive and hard negative pairs.
The models were trained on the whole BUPT-Equalizedface datasets (27999 IDs) under ArcMargin.
\autoref{fig:plotWorst} shows that IS-ArcLoss has higher similarity for positive pairs
compared with ArcLoss in (a)(Caucasian-extend), (c)(Asian-extend), (d)(Indian-extend)
and it has lower similarity for negative pairs in all tested datasets.
Visualization of the top-2 hardest pairs for each race is shown in \autoref{fig:RFW-imgs}.
This observation indicates that IS-ArcLoss emphasizes the hardest pairs.
\begin{figure}
\begin{center}
\includegraphics[width=\linewidth]{plotWorst.pdf}
\end{center}
\caption{Hard pairs' similarity comparison between ArcLoss and IS-ArcLoss.
The model was trained on RFW-Equalizedface and tested on the RFW-test-extend dataset.
(a) (b) (c) (d) show positive similarity while (e) (f) (g) (h) show negative similarity.}
\label{fig:plotWorst}
\end{figure}
\section{\textbf{Conclusion}} \label{sec:conclusion}
In this paper, we develop an information-theoretic learning model derived from importance sampling to deal with
the problem of data distribution deviation between current training data and future test data.
We reveal that minimization of the objective function of LogISloss
is equivalent to the minimization of the p-norm loss function when $p=\frac{1}{T}$.
We applied the proposed model to the face verification task.
Experiments on distribution deviations showed that the learned features under LogISloss generalized well
across different races and across different datasets compared with cross-entropy loss and
experiments on the hardest pairs showed that LogISloss emphasized the hard pairs.
Applying ISloss/LogISloss to other machine learning problems
and designing a good schedule for $T$ remains to be explored in future endeavors.
\section*{\textbf{Disclosure statement}}
No potential conflict of interest was reported by the authors.
\section*{Acknowledgements}
This work is supported by the National Natural Science Foundation of China under Grants 61976174.
\bibliographystyle{elsarticle-num}
| {'timestamp': '2023-02-24T02:04:29', 'yymm': '2302', 'arxiv_id': '2302.04438', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04438'} | arxiv |
\section{Introduction}
The 2020 US Presidential Election took place against the backdrop of incumbent president Donald Trump's impeachments, the COVID-19 pandemic, and racial unrest of the Black Lives Matter movement. In such a tumultuous scenario, Donald Trump challenged the integrity of the elections by diffusing claims of an alleged, widespread voter fraud and claiming his victory despite the vote count \cite{universitythe}.
Activism from fringe groups and Trump supporters gained traction online in the months following the election, calling for violence against those who opposed Trump’s claims
\cite{pennycook_2021_research}. Following Trump's instruction (``Be there, will be wild!'') in one of his prominent tweets,\footnote{https://www.justsecurity.org/84551/important-elements-of-the-january-6th-report/} on January 6th, 2021, as Congress convened to ratify the electoral college results, his supporters attacked the US Capitol, breaching the Capitol Building and causing five deaths and multiple injuries \cite{universitythe}.
The US Capitol attack was seen as an attempted \emph{coup d'\'etat} \cite{washington_politifact}, organized and promoted online, with violent actions and repercussions offline \cite{universitythe,luceri2021social}. In the aftermath of the attack, the US House of Representatives established a Select Committee to investigate the Capitol attack, and the role of social media in relation to the “spread of misinformation, efforts to overturn the 2020 election, domestic violent extremism, and foreign influence in the 2020 election”.\footnote{https://techpolicy.press/january-6-committee-issues-subpoenas-to-social-media-platforms/} In their final report,\footnote{https://perma.cc/ZA6R-JRF2} released on December 22nd, 2022, the Select Committee examined former President Donald Trump’s conduct to invalidate the election results and foster the attack to the Capitol.\footnote{https://www.justsecurity.org/84658/insiders-view-of-the-january-6th-committees-social-media-investigation/} Besides Trump’s potentially pivotal role in driving the attack, which is out of the scope of this paper, the report highlights how Twitter, among all the subpoenaed social media platforms, served as the main channel for Trump, his supporters, and fringe groups, such as QAnon, to amplify conspiracy theories and plan the assault.
The attack ensued by large-scale deplatforming, with Twitter (until November 2022), Facebook, Instagram, and Snapchat, among the others, banning Donald Trump \cite{pennycook_2021_research} and many of his followers, who flocked together to alt-tech social media platforms.
The research community examined the effects of these interventions \cite{horta2021platform,trujillo2022make} and studied online conversations surrounding the election from different angles.
The Election Integrity Partnership (EIP) performed an observational study tracking misleading claims related to the integrity of the electoral system from the run-up to the aftermath of the election~\cite{universitythe}. \citet{ferrara_2020_characterizing} examined the
possible sources of social media manipulation before the election, focusing on two aspects: automated, inauthentic behavior and conspiracies, including
those pushed by fringe communities.
Among all the fringe groups, the QAnon conspiracy played a relevant role in steering conversations along the line of the election fraud rhetoric \cite{luceri2021social, sharma2022characterizing}. While a large body of research focused on the voting event, a longitudinal study that examines
the unfolding of conspiracy and fringe narratives leading up to the Capitol attack is still lacking.\footnote{For the sake of simplicity, we will use the terms ``fringe narratives" and ``conspiracy theories" interchangeably throughout the paper. However, in our results, we will clarify and distinguish these two distinct instances of problematic content.}
In this paper, we investigate the proliferation and potential inauthentic amplification of conspiratorial content on Twitter in the months preceding the 2020 US Election and the Capitol Hill attack.
Leveraging a dataset of over 500M election-related tweets gathered from July 2020 to January 2021, we deconstruct the \emph{Twittersphere} to investigate the temporal evolution of, and the relationship between, fringe narratives.
Further, we examine the potential use of coordinated and adversarial actions to amplify content and create an illusion of consensus around conspiracies.
In particular, we address the following research questions (RQs):
\begin{itemize}
\item[\textbf{RQ1:}] \emph{Were fringe narratives amplified employing adversarial manipulation techniques? Who were the actors responsible for the manipulation, and which stories were pushed?}
\item[\textbf{RQ2:}] \emph{What was the relationship between the various fringe narratives and conspiracy theories? How did they evolve over time and converge at the time of the Capitol attack?}
\end{itemize}
To address these RQs, we rely on and build upon computational models to chart the landscape of conspiratorial and deceptive activity surrounding the 2020 US Election, leading up to the January 6th attack, providing the following contributions:
\begin{itemize}
\item Employing existing approaches for the detection of coordinated and inauthentic activity~\cite{pacheco2021uncovering,nizzoli2021coordinated,weber2021amplifying}, we found evidence of manipulation attempts to amplify and elicit an illusion of consensus around conspiratorial content.
\item Leveraging manually curated annotations \cite{kennedy2022repeat,voterfraud2020}, we observed how the ``Stop the Steal" rhetoric was by far the most inflated narrative by the coordinated adversarial activity. Further, we uncovered and verified that the vast majority of users involved in such manipulation actions were supporting and promoting claims about voter fraud \cite{voterfraud2020}.
\item Building on prior work \cite{mit}, we map out the temporal evolution of fringe narratives and draw a broad picture of their relationships. We discovered that conspiratorial and fringe content coalesced into two distinct, yet interlaced, meta-narratives embodying the ``stolen election" rhetoric and the QAnon conspiracy.
Our results experimentally confirm the observational findings released by the EIP \cite{universitythe}.
\end{itemize}
\section{Related Work}
\subsection{Misinformation and the 2020 US Election}
The 2020 US Presidential Election saw an unprecedented number of false claims and misinformation about voter fraud, including the self-proclamation of Donald Trump as the real winner~\cite{chen2021covid,khudabukhsh2022fringe}.
In this context, many studies tracked the spread of electoral misinformation in the run-up to the election and its aftermath.
Diverse collaborative and participatory schemes were used to spread questionable narratives~\cite{universitythe}.
Some of these were \textit{bottom-up}, where influential media, political elites, and social media influencers broadcasted content produced by average users. Other times instead, the patterns of diffusion were \textit{top-down}, involving large numbers of users, automated~\cite{ferrara_2020_characterizing} or otherwise~\cite{jachim2021trollhunter2020}, that coordinated to amplify narratives proposed by influential users.
Among the plethora of intertwined false narratives, ``Stop the Steal" gave rise to an advocacy organization responsible for multiple riots across the country \cite{luceri2021social}. The ``Stop the Steal" campaign spread across multiple platforms, including Facebook and Twitter, pushing allegations that the election was stolen and inciting Trump supporters to overturn the result~\cite{benkler2020mail,universitythe}:
One year after the election, up to one-third of the US population still believed
that the electoral outcome was not to be trusted \cite{matatov2022stop,pennycook_2021_research}. The large body of work on the 2020 US Election also resulted in the collection and publication of several resources, such as social media datasets of annotated posts and users involved in the spread of election misinformation~\cite{chen_2022_2020,kennedy2022repeat,voterfraud2020}. In the present study, we leverage a combination of existing resources to provide unprecedented insights into the coordinated strategies used to amplify false narratives and how these contributed to sparking the Capitol Hill attack.
\subsection{QAnon and Fringe Conspiracy Theories}
Interest in tracing the diffusion and in identifying supporters of conspiracy theories is motivated by their detrimental effect on people's political engagement and trust in authorities~\cite{green2022online}, so much so that the interplay between the spread of conspiracy theories and major political events is long studied. QAnon was the main conspiracy theory that spread during and after the US 2020 electoral debate~\cite{sharma2022characterizing,wang2022identifying}. \citet{sharma2022characterizing} found that around 66\% of all users that were active in the online debate interacted with QAnon content and that far-right QAnon supporters actively tried to persuade left-leaning users. Among the many narratives of the QAnon umbrella conspiracy, ``Hammer and Scorecard'' and ``Dominion'' were particularly popular. Similarly to what happened for the US 2020 election misinformation, these narratives were pushed by a combination of prominent users (e.g., Donald Trump and other politicians), far-right communities (e.g., the Proud Boys), and other average users~\cite{universitythe}, including automated accounts \cite{ferrara_2020_characterizing,luceri2021down}.
Moreover, the proponents of these extremist conspiracies also endorsed the election-fraud claims, up to the point that QAnon conspiracies coalesced in and reinforced the ``Stop the Steal'' campaign, favoring the radicalization of Trump supporters~\cite{pennycook_2021_research,luceri2021social}. This intricate interplay poses inevitable challenges towards tracing the spread of conspiracies, understanding how they unfold~\cite{papasavva2022gospel}, and what leads users to adopt the theories \cite{wang2022identifying}.
\subsection{Coordinated Online Behavior}
A frequent characteristic of mis- and disinformation campaigns is the use of \textit{coordinated activity} to boost the spread of the shared messages~\cite{nizzoli2021coordinated}. A recent body of work thus focused on detecting and characterizing coordinated online behavior as a way to surface mis- and disinformation campaigns. The majority of existing approaches detect online coordination by identifying unexpected or exceptional similarities in the action sequences of two or more users. For example, many works model common user activities (e.g., co-retweets, temporal and linguistic similarities) with the goal of building user similarity networks where coordinated groups (i.e., communities) of users are highlighted~\cite{weber2021amplifying,pacheco2021uncovering,nizzoli2021coordinated,magelinski2022synchronized}. Others instead proposed to detect coordination with temporal point processes, where user activities are modeled as the realization of a stochastic process~\cite{sharma2020identifying,zhang2021vigdet}. Some methods do not only distinguish between coordinated and non-coordinated users, as in a binary classification task but also quantify the extent of coordination thus providing more nuanced results~\cite{nizzoli2021coordinated}.
The characterization of coordinated users and communities is another thriving area of research. This task is typically aimed at distinguishing between malicious (e.g., disinformation networks) and genuine (e.g., fandoms, activists) forms of online coordination~\cite{vargas2020detection,hristakieva2022spread}. To this end, some considered the structural properties of the coordination networks~\cite{vargas2020detection,nizzoli2021coordinated,cinelli2022coordinated}, the reliability of the news they shared~\cite{cao2015organic}, or their use of propagandist language~\cite{hristakieva2022spread}, to gain insights into the objectives and intent of the coordinated users. Here, we employ state-of-the-art coordination detection frameworks~\cite{weber2021amplifying,pacheco2021uncovering,nizzoli2021coordinated} to identify users that participated in coordinated activities with the goal of spreading conspiratorial content, and we leverage curated annotations \cite{kennedy2022repeat,voterfraud2020} to characterize the messages and users involved in such adversarial manipulation.
\begin{table}
\centering
\caption{Fringe hashtags analyzed in this paper.}
\label{hashtable}
\begin{tabular}{|c|c|l|}
\hline
\textbf{US Election} & \textbf{QAnon} & \multicolumn{1}{c|}{\textbf{COVID-19}} \\
\hline
\multicolumn{1}{|l|}{\#hammerandscorecard} & \#pizzagate & \multicolumn{1}{c|}{\#plandemic} \\
\hline
\#sharpiegate & \#qanon & \\
\hline
\#qsnatch & \#qarmy & \\
\hline
\#stopthesteal & \#taketheoath & \\
\hline
\#dobbs & \#wwg1wga & \\
\hline
\#dominionsoftware & \#projectveritas & \\
\hline
\#dominion & \#thegreatawakening & \\
\hline
\#hammer & \#civilwar & \\
\hline
\#scorecard & \#obamagate & \\
\hline
\end{tabular}
\end{table}
\section{Dataset \& Fringe Hashtags}
\label{eda}
For our analyses we leverage the first public Twitter dataset about the 2020 US Presidential Election \cite{chen_2022_2020}, which was collected using election-related keywords and gathering messages from a set of political figures, including the running candidates. From the list of released tweet IDs \cite{chen_2022_2020}, we applied a hydration process to collect the full tweet objects.
In this paper, we use a subset of the whole dataset considering only tweets from July 2020 to January 2021, to cover an observation period that goes from the final campaign to the Capitol attack.
This results in a longitudinal dataset that contains about 568 million tweets, consisting of 52\% of retweets, 19\% of replies, 16\% of original tweets, and 13\% of quotes.
\begin{figure}[t]
\centering
\includegraphics[trim={0 1cm -2cm 0}, width=0.9\linewidth]{download.png}
\caption{Distribution of fringe hashtags.}
\label{bars}
\end{figure}
Leveraging previous analyses on the same dataset \cite{ferrara_2020_characterizing, sharma2022characterizing, wang2022identifying,chen_2022_2020} and diverse reports on the Capitol attack \cite{pennycook_2021_research, universitythe,luceri2021social}, we identified nineteen hashtags pushed by conspiracies and fringe communities, which we will refer to as \emph{fringe hashtags}. In this body of literature, the fringe hashtags are commonly grouped in three broad categories related to \textit{(i)} QAnon -- hashtags originated from and propagated by the QAnon conspiracy; \textit{(ii)} US Election -- hashtags encompassing a diverse set of conspiracies supporting the election fraud rhetoric; and \textit{(iii)} COVID-19 -- a single hashtag related to a conspiracy theory about the pandemic. The three groups of fringe hashtags are displayed in Table \ref{hashtable} while Figure \ref{bars} depicts their distribution in our dataset. Notably, \#stopthesteal -- promoting the stolen election narrative, and \#dobbs -- supporting the former Fox News political commentator Lou Dobbs, were by far the most shared hashtags, followed by \#obamagate, \#qanon, \#wwg1wga, \#dominion, \#plandemic, and \#civilwar.
\section{Methodology}
To address the proposed RQs we leverage three methodologies. We explore suspicious coordinated activity relying on existing techniques that \textit{(i)} identify networks of \emph{rapid retweet} interactions -- generally employed to amplify content generated by targeted users \cite{mazza2019rtbust,pacheco2021uncovering}, and \textit{(ii)} discover clusters of users sharing similar tweets -- usually shared with small variations and nuances to create an illusion of consensus \cite{weber2021amplifying}. We will refer to these two network-based models as \emph{rapid retweet network} and \emph{copypasta network}. Further, we characterize \textit{(i)}
the users involved in such manipulation attempts by leveraging the annotations produced by \citet{voterfraud2020}, who classified users as either promoters or detractors of voter fraud narratives; and \textit{(ii)} the tweets shared by these coordinated accounts relying on the curated dataset from \citet{kennedy2022repeat} to label messages sowing doubts in the legitimacy of the election.
Finally, we build on the approach proposed by \citet{mit} to chart the landscape of fringe narratives by mapping out their relationship and evolution over the months leading up to the Capitol attack. We refer to this augmented model as \emph{Hashtag Temporal Evolution Mapping (HTEMap)}.
\subsection{Rapid Retweet Network}
\label{rrtmeth}
Retweets represent the fastest and easiest form of social endorsement on Twitter \cite{metaxas2015retweets}. Users can re-share others' content in a simple, \emph{one-click} operation, which can even be automated \cite{luceri2019evolution}. However, the simplicity behind this action led to its nefarious use in orchestrated manipulation campaigns and information operations \cite{bessi2016social, luceri2020detecting, badawy2018analyzing}, where retweets were collaboratively employed to spread misinformation and amplify content shared by influential users and super-spreaders \cite{mazza2019rtbust,zannettou2019let}.
Given the widespread misuse of retweets, in this work, we aim to identify networks of accounts that suspiciously employ retweets in a fast, repeated, and coordinated fashion.
Following the methodology presented by \citet{pacheco_2020_unveiling}, we define a rapid retweet as a re-share of a tweet that occurs in a narrow time window. Here we consider different sizes of the time window to assess the strength of this coordinated activity. According to this definition, we build a weighted \emph{rapid retweet network}, where the user that re-shared a tweet (\emph{source}) is connected to the user that generated the original content (\emph{target}) if the retweet occurred within the designated time window size, and the weight represents the number of rapid retweets between the source and target users.
Similarly to \citet{pacheco_2020_unveiling}, we also filter out occasional instances of rapid retweets that might happen by chance by considering only links with a weight larger than one, i.e., the rapid retweet occurred more than once.
\subsection{CopyPasta Network}
\label{cpmeth}
Similarly to retweets, content with high similarity can be used to resonate messages and elicit the idea of widespread agreement around an idea, a piece of information, or a misleading claim.
For the sake of simplicity, and leveraging the Internet jargon, we refer to tweets with high text similarity as \emph{copypasta tweets}. To identify such tweets, we carry out a pair-wise comparison of the text of original content shared in our dataset, including thus replies, quotes, and original tweets. We do not consider retweets in this subset as, by definition, they have exactly the same text and cannot be considered as an instance of \emph{copypasta tweet}.
Calculating pairwise similarity between a huge volume of tweets is, however, a significant resource and time-consuming task. Similarly to \citet{pacheco_2020_unveiling}, we sort tweets in chronological order and compare only messages shared in close time proximity, considering a sliding window of ten tweets. For each time window, we construct a 10$\times$10 matrix of tweet similarity scores, which are in turn computed using the Ratclif/Obershelp algorithm \cite{ratclif_1988_pattern}.
This computation forms the basis to build the \emph{copypasta network}, defined as an undirected network of tweets linked to each other if their similarity score is above a certain threshold.
As we thoroughly show in the following sections, this threshold is adequately selected by observing the
distribution of similarity scores of both fringe and generic tweets.
\subsection{Characterizing Users and Tweets}
\begin{figure}[t!]
\center
\includegraphics[trim={0 0 2cm 0}, width=.9\linewidth]{promdet.png}
\caption{Retweet network of detractors (blue) and promoters (green) of the voter fraud conspiracy, along with unlabeled users (black). The node size represents the in-degree, i.e., the number of times the user was retweeted.}
\label{prodet}
\end{figure}
To characterize the users involved in the spread of fringe narratives, we leverage a publicly-available annotation released by \citet{voterfraud2020}. There, the authors classify users as either \emph{detractors} or \emph{promoters} of the voter fraud rhetoric and related conspiracy theories.
Leveraging a rich set of information (shared URLs, images, and YouTube videos), they discovered five distinct communities, where \emph{detractors} sit in a unique community and \emph{promoter} populate the other four communities.
In this paper, we use the annotations of \citet{voterfraud2020} to label users as \emph{detractors} or \emph{promoters} and to understand their role in the deceptive coordinated activities described before. The overlap of users with \citet{voterfraud2020} resulted in a labeling of 63.25\% of the users in our dataset and as we could expect, the majority of those (81.5\%) represent \emph{promoters} of the voter fraud rhetoric. It is worth noting the relevant fraction of users (18.5\%) labeled as \emph{detractors} in our dataset. This is not surprising, however, given that \emph{detractors} of conspiracies also make use of controversial hashtags and quote misleading claims to attack or convert fringe users \cite{wang2022identifying}.
Figure \ref{prodet} represents the interactions between detractors and promoters with a directed, weighted retweet network, where the nodes are users, edges represent retweets, and the weight is proportional to the frequency of retweets between each pair of nodes. The network in Figure \ref{prodet} is visualized using a force-directed layout (ForceAtlas2), where nodes repulse each other, whereas edges attract their nodes. In our scenario, this means that users are spatially distributed according to the number of retweets exchanged between each other. This results in a natural split of the network into two communities entirely populated by users with the same opinion about the voter fraud rhetoric.
Unlabeled users are balanced between the community of promoters (53.23\%) and the community of detractors (45.17\%).\footnote{Note that the percentages do not sum up to 100\% as a small fraction of unlabeled nodes does not belong to any community.}
In the next sections, we will delineate the role of these two distinct communities in the manipulation attempts of amplifying fringe narratives.
Additionally, we characterize the tweets shared by the users under analysis by leveraging the annotations curated by \citet{kennedy2022repeat}, which encompasses a set of tweets pushing stories on the delegitimization of the election. Despite covering only the 21.48\% of tweets in our dataset, we will show how this set of stories was amplified in a coordinated fashion.
The top five misleading stories in our dataset are related to the ``Stop
the Steal" narrative, named \emph{Stop the Steal Pushed} (46.71\%) and \emph{Stop the Steal rallies} (4.03\%) by \citet{kennedy2022repeat}, followed by the \emph{Dominion} (38.87\%), \emph{Hammer and Scorecard} (4.52\%), and \emph{Sharpiegate} (1.54\%) conspiracy theories.
\subsection{HTEMap Model}
\label{htemap}
\begin{figure}[t!]
\centering
\includegraphics[trim={0 1cm 0 0}, width=0.5\textwidth]{tagset.png}
\caption[HTEMap Model]{The HTEMap Model.
\label{mth}
\end{figure}
To delineate the relationships between the various fringe narratives
and map out their temporal evolution, we augment the model proposed in \citet{mit} to introduce the \emph{Hashtag Temporal Evolution Mapping (HTEMap)} model and construct a temporal network of hashtags. In particular, HTEMap infers an evolutionary trajectory of hashtags by first charting the relationship between tweets and hashtags across time as in \citet{mit}, and then building a co-occurrence network of hashtags. The architecture of the model is displayed in Figure \ref{mth} and consists of four steps.
First, for every hashtag, we extract a hashtag dataset (in short \emph{tagset}), which includes the tweets embedding the target hashtag, sorted in reverse-chronological order.
Second, we perform a pairwise comparison of the tweets in the tagset. We represent each tweet with a $n$-dimensional vector (in our setting $n=19$, given that we are considering 19 fringe hashtags) whose elements, $b_k$, represent the number of occurrences of the $k$-th hashtag in the tweet.
We build a similarity matrix $S$, where every element $S_{i,j}$ represents
the cosine similarity between the $n$-dimensional representations of tweets $(i)$ and $(j)$.
\begin{figure*}[t!]
\center
\includegraphics[width=\textwidth]{rrtfinal.png}
\caption{The rapid retweet network. Node size represents the in-degree, whereas the node color characterizes users as promoters or detractors \cite{voterfraud2020}. The inset represents an instance of the rapid retweet network with a shorter time window (30sec).}
\label{rrt}
\end{figure*}
Third, we use the similarity matrix $S$ to construct a graph of tweets. Specifically, we consider only the upper-triangular matrix of $S$ to select the most similar pair of tweets and connect their corresponding nodes with a directed edge that goes from the older one to the newer one.
Once performed this operation for every tweet in the tagset, we obtain an evolutionary tree for the target hashtag. By repeating the previous steps for all the hashtags of interest, we obtain a rich suite of distinct, temporally directed \emph{tree graphs} that connects tweets containing the hashtags under analysis. It should be noted that, as tweets can have multiple hashtags, a tweet might be included in multiple tree graphs.
Finally, to infer the relationship between the hashtags, we construct a bipartite network composed of tweets and hashtags. We combine the nineteen tree graphs to get the \emph{tweet layer} of the bipartite network, where every node represents a unique tweet and edges connect tweets as in the tree graphs. The \emph{hashtag layer} comprises the examined nineteen hashtags. In the bipartite network, an edge exists between a tweet and a hashtag if the former embeds the latter.
Thereby, the topology of the diverse tree graphs modulates the connections (and their weights) in the bipartite network. From this bipartite graph, we extract a hashtag network, named \emph{HTEMap network}, based on the co-occurrence of the hashtags in the tweet layer, which encompasses both the temporal evolution and relationship between the fringe hashtags.
\section{Results}
\begin{figure*}[t]
\center
\includegraphics[trim={0 0 0 0}, width=\textwidth]{cpfigs.png}
\caption{CopyPasta Activity: (a) Distributions of similarity scores of generic tweets and fringe tweets. \linebreak (b) Distribution of sharing activities across generic, fringe, and copypasta tweets.}
\label{cptype}
\end{figure*}
We first discuss results related to the potential deceptive activity carried out by coordinated accounts to inflate and resonate conspiratorial content, and then we portray the broad picture of the relationship and temporal evolution of fringe hashtags generated by the HTEMap model.
\label{results}
\subsection{Coordinated Activity (RQ1)}
To address RQ1, we analyze here how fringe narratives were pushed employing adversarial manipulation strategies and we characterize the tweets and users involved in such deceptive activities.
\subsubsection{Rapid Retweet Network}
\label{rtres}
We commence our analysis by exploring the \emph{rapid retweet network}, which offers an \emph{interactome} of the interactions between the users that coordinately amplified fringe content by means of rapid retweets, as defined above. As a starting point, we consider a time window of 60 seconds to define a rapid retweet.
Figure \ref{rrt} portrays the (force-directed layout of the) rapid retweet network, where nodes represent users and edges indicate rapid retweets.
The node size is proportional to the in-degree (i.e., the number of times a user was retweeted), whereas nodes are colored according to the annotations from \citet{voterfraud2020}.
The thickness of the edges is proportional to the number of rapid retweets between nodes, while the color abides by the color of the source node (i.e., the author of the retweet).
From Figure \ref{rrt}, we notice that the rapid retweet network is composed of network structures exhibiting a star topology. In our scenario, this means that a single user is retweeted by a multitude of other accounts. Lowering the size of the time window to 30 seconds, from the inset in Figure \ref{rrt}, we also notice how the skeletal structure of the rapid retweet network persists, with some of the most prominent accounts still at the center of their star topology and retweeted by a non-negligible number of followers, suggesting a robust, coordinated effort to target content generated by these accounts. Notably, star-like interaction structures were found in recent literature as evidence left behind by coordinated online manipulations~\cite{nizzoli2020charting}. By manually inspecting the users sitting in the center of such amplification bubbles, we identify some prominent and influential actors, including verified accounts with millions of followers. Among the others, we recognize various Republican politicians (e.g., Dr. Kelli Ward, and Ed Martin), alt-right media outlets (e.g., RSB Network), and political commentators such as Tom Fitton -- the president of Judicial Watch, a right-leaning activist group -- and Lou Dobbs -- also known for his controversial opinion about COVID-19 vaccines and his support to the voter fraud conspiracy theory. In this regard, it is also worth noting that \#dobbs is one the most prevalent hashtags in our dataset (Figure \ref{bars}).
Further, looking at the node color, based on the annotations from \cite{voterfraud2020}, we find that 83\% of the users involved in the rapid retweet network are labeled as promoters of the voter fraud conspiracy theory, which highlights the propensity of these accounts in trusting conspiratorial content and their alleged intent of resonating such narratives in a coordinated fashion. Besides characterizing the actors responsible for this targeted amplification, we are interested in uncovering the narratives pushed through their activity. The hashtag \#stopthesteal (43.08\%) results to be the most inflated, followed by \#dobbs (31.4\%), \#obamagate (14.12\%), and \#qanon (3.6\%). Leveraging the annotations from \citet{kennedy2022repeat}, we identified only a small set of misleading stories in the tweets boosted by this coordinated action, with the ``Stop the Steal" rhetoric standing out with 15,285 tweets, followed by the \emph{Dominion} (8,663 tweets), and \emph{Hammer and Scorecard} (1,111 tweets) conspiracy theories.
\begin{figure*}[ht]
\center
\includegraphics[width=\textwidth]{cpnet.png}
\caption{Copypasta network with tweets labeled by (a) hashtags, and (b) misleading claims about the election \cite{kennedy2022repeat}.}
\label{cpt}
\end{figure*}
\subsubsection{Copypasta Network}
\label{cpres}
To build the copypasta network, we need to select an adequate threshold to identify similar tweets, which we also name \emph{copypasta tweets}. To this aim, we observe the distribution of similarity scores in the analyzed tweets.
From Figure \ref{cptype}(a), we note a bimodal distribution in the similarity scores of both fringe tweets (i.e., messages containing fringe hashtags) and a random sample of generic tweets (i.e., messages not containing fringe hashtags). This surfaces a natural threshold $=0.7$ for identifying copypasta tweets, which is also consistent with previous work \cite{pacheco_2020_unveiling, topinka2022politics}.
Interestingly, the distribution related to the sample of generic tweets shows less prevalence of copypasta tweets, indicating that this manipulation technique was mainly used to push fringe narratives.
In Figure \ref{cptype}(b), we further characterize the tweets containing fringe hashtags in contrast with generic tweets, also considering the copypasta activity. In particular, we disentangle tweets in different sharing activities (original tweets, replies, quotes) and measure their proportion for three different sets of tweets: generic tweets, fringe tweets, and fringe tweets with copypasta activity (from now on, simply \emph{copypasta tweets}). We do not consider retweets in this evaluation to carry out a fair comparison with copypasta tweets, which cannot include retweets by definition.
From Figure \ref{cptype}(b), we observe remarkably high proportions of quotes in the copypasta activity, suggesting that this sharing activity might be used to diffuse problematic content, as further indicated by the suspiciously high volume of fringe tweets.
Both fringe and copypasta tweets include a significant fraction of replies (despite being less prominent with respect to generic tweets), which resembles the activity of misbehaving users during recent geo-political events \cite{pierri2022does}.
Interestingly, the volume of copypasta tweets is limited in the shared original content, which might suggest the potential employment of automated accounts to reproduce existing content and broadcast it via replies and quotes. This investigation is, however, out of the scope of this paper.
Based on these insights, we construct a copypasta network incorporating tweets with similarity $> 0.7$. Figure \ref{cpt}(a) shows the copypasta network, where nodes represent tweets, which are connected if they have a similarity score $> 0.7$. We observe clusters of tweets independent of each other, representing chains of copypasta activity.
Each cluster represents a set of tweets sharing the same or very similar text. Nodes are colored based on the hashtag (or combination of hashtags) embedded in the tweet. We note a huge volume of copypasta tweets embedding the \#stopthesteal hashtag (76.25\%), indicating how this hashtag was heavily amplified by means of different manipulation techniques. By manually inspecting the largest clusters of tweets, we observe a large variety of
conspiratorial flavors in copypasta tweets, including calls to action, petitions, support via retweets, and trolling behavior via replies.
To have a better understanding of the narratives amplified by this coordinated activity, we leverage the annotations curated by \citet{kennedy2022repeat}. In Figure \ref{cpt}(b), we highlight the tweets that pushed claims about election delegitimization by coloring network nodes based on the specific theory shared.
It can be noticed how a relevant fraction ($\sim$60\%) of clusters contain at least one colored node, which suggests a relevant prevalence of misleading claims shared in a coordinated way through copypasta activity. Similarly to the results related to the rapid retweet network, ``Stop the Steal" represents the narrative most amplified by coordinated accounts (83\% of the tweets including misleading claims).
Focusing on the actors responsible for this deceptive activity, we find that 95\% of the users involved in the spread of copypasta tweets are labeled as promoters of the voter fraud conspiracy theory \cite{voterfraud2020}, once again highlighting their pivotal role in this manipulation action. Interestingly, this set of users has a tiny overlap with the accounts involved in the rapid retweet network, with only 48 accounts engaged in both coordinated activities, indicating that diverse groups of users exhibit different (adversarial) behaviors, similar to users engaging with the QAnon conspiracy \cite{wang2022identifying}.
\subsection{Temporal Evolution (RQ2)}
\label{resrq2}
\begin{figure}[t!]
\center
\includegraphics[width=1\linewidth]{map.png}
\caption{The HTEMap network.}
\label{l2b}
\end{figure}
\begin{figure}[ht]
\center
\includegraphics[width=0.5\textwidth]{map_001.png}
\caption{Evolutionary dendrogram of the fringe hashtags.}
\label{l2}
\end{figure}
To answer RQ2, we leverage the HTEMap model for charting the landscape of the fringe hashtags, their relationship, and temporal evolution across the seven months preceding the Capitol attack.
The HTEMap model returns a temporal network of hashtags, namely HTEMap network, which is displayed in Figure \ref{l2b}, with a force-directed layout. The node size is proportional to the eigenvector centrality, and the edge weight represents the frequency of co-occurrence between the two hashtags in the HTEMap network. Similarly to what was done in recent longitudinal analyses of information operations~\cite{kriel2019reverse}, the temporal dimension is represented by the node color. It should be noted that the HTEMap network encompasses by design the temporal aspect in the construction of the evolutionary trees. Here, for visualization purposes, we consider the median of the tweets' creation date for every set of chronologically-sorted tweets containing the hashtags under analysis.
From Figure \ref{l2b}, we observe two distinct communities,\footnote{A community extraction performed with the Louvain methodology \cite{blondel_2008_fast} confirms the observational results.} suggesting that there are two main distinct, yet interconnected narratives shared in the \emph{Twittersphere} during our period of observation. Interestingly,
each community (almost entirely) corresponds to one of the categories of hashtags detailed in Table \ref{hashtable}, reflecting election-related conspiracies and QAnon narratives. The \#plandemic hashtag sits in the QAnon cluster, allegedly because of the connection with other QAnon conspiracies.
We also recognize that the most central nodes (in terms of eigenvector centrality) are \#qanon, \#wwg1wga, \#stopthesteal, and \#dominion, which connect Election-related theories with the QAnon conspiracy.
It is also worth noting the role of \#dobbs and \#civilwar in bridging the two groups of conspiracies together. The former was amplified with the corresponding account (@LouDobbs) with a targeted amplification activity, as shown in the results related to the rapid retweet network. Instead, the latter was used by several influential spreaders to advertise the January attack and, as confirmed by our results, became viral on Twitter during the first days of November \cite{universitythe,luceri2021social}.
The interconnection of \#civilwar with the QAnon theories further confirms the involvement of the conspiracy in the organized violence behind the Capitol attack.\footnote{https://www.theguardian.com/us-news/2021/nov/17/qanon-shaman-jacob-chansley-sentenced-capitol-attack-role}
Taking the temporal dimension into account, in Figure \ref{l2b} we also observe that QAnon-related hashtags were prevalent much earlier than the election-related ones. In fact, almost all the election-related fringe hashtags got traction around Election day (November 3rd, 2020), which is in line with previous research \cite{universitythe, luceri2021social}.
To further our understanding of the relationships between these hashtags, we perform a hierarchical clustering based on the adjacency matrix of the HTEMap network. This results in the dendrogram of fringe narratives shown in Figure \ref{l2}.
To interpret the dendrogram, we focus on the width at which any two hashtags are branched together. We observe that the branch that joins \#stopthesteal and \#dominion is one of the smallest ones in the dendrogram, suggesting that they are among the most similar nodes in the HTEMap network. We recall that similarity in this context captures different dimensions embedded in the HTEMap network, i.e., the temporal evolution and topological co-occurrence of the hashtags.
From Figure \ref{l2}, we observe the emergence of two distinct branches of conspiracy theories, similar to Figure \ref{l2b}.
This further confirms a separation between the co-occurrence of election misinformation and fringe conspiracy theories.
In addition, it also surfaces the existence of two unique, yet interconnected, narratives in the tweetspace.
On the one hand, \#stopthesteal and \#dominion branch coalesce together all the election-related conspiracies, including the 2017 QAnon theory called “Hammer and Scorecard”, which gained traction again in the weeks after the 2020 election \cite{universitythe}. On the other hand, QAnon-related hashtags pivoted around the hashtags \#qanon and \#wwg1wga but also included the ``gate" and Covid-19 conspiracies.
\section{Discussion}
\subsection{Conclusions and Future Work}
We carried out a longitudinal analysis of the interplay between conspiracy theories and fringe narratives in the run-up to the US 2020 Presidential Election.
By employing an innovative combination of methods, we surfaced and analyzed two widely used adversarial manipulation techniques, i.e., rapid retweets and copypasta activity. Furthermore, we leveraged existing annotated resources to provide a characterization of the users involved in such manipulations, recognizing different groups of promoters of the voter fraud rhetoric acting in diverse deceptive efforts. Finally, we reconstructed the temporal trajectory of the fringe theories that eventually coalesced into the ``Stop the Steal" narrative, pinpointing its interconnection with QAnon and the Capitol attack, also advertised with the hashtag \#civilwar.
Among the key findings of our work is that \textit{(i)} the rapid retweet networks artificially amplified right-wing commentators and politicians that endorsed the election fraud and QAnon conspiracies; \textit{(ii)} more than 76\% of the copypasta tweets and more than 96\% of the users involved in copypasta, promoted the ``Stop the Steal" rhetoric; and \textit{(iii)} the QAnon conspiracies gained traction well before the election and quickly evolved into election fraud conspiracies as soon as the polling was done. Overall, our results provide novel and nuanced insights into the complex socio-technical phenomena that led to one of the most destabilizing attacks on US democracy.
In the future, we aim to extend our comprehensive analyses by also considering additional platforms and other forms of online manipulation. To this end, the possibility of complementing the temporal aspects of this work with multi-platform analyses represents a promising direction of research that holds the potential for shedding further light on the tactics used to organize the Capitol attack.
\subsection{Limitations}
Our work presents a few limitations. First, the hydratation process might have prevented us from gathering the original dataset collected by \citet{chen_2022_2020}, because of the potential content moderation and account banning performed by Twitter during the Election period and, in particular, after the moderation interventions against QAnon-related content \cite{wang2022identifying,sharma2022characterizing}. However, for the same reason, our findings might represent a lower bound estimate of coordinated, deceptive activity performed during the observation period. Second, this work explores only common manipulation tactics, but novel and more sophisticated strategies might have been employed. Third, we do not consider the activity of software-controlled accounts (i.e., bots), which might have played a role in the amplification of fringe content \cite{ferrara_2020_characterizing}.
Finally, a considerable amount of fringe actors have migrated from Twitter to low-moderated spaces, e.g., alt-tech platforms like Gab and Parler, during the observation period, thus potentially affecting our results, which focus only on Twitter. This calls for a broader study encompassing more diverse online platforms in the information ecosystem, which will be the objective of our next endeavors.
\subsection{Broader perspective, ethics, and competing interests}
We believe our work will have a positive broader impact on the understanding of the complex interplay between conspiracy theories and fringe narratives. These online phenomena, in turn, showed potential for developing into serious offline issues, as in the case of the Capitol attack. To this end, our work can inform future efforts for curbing these and other issues.
At the same time, however, among the conceivable ethical risks of our work is the possibility that some of our findings could be used for political reasons. Additional risks may derive from the unintended disclosure of sensitive user information contained in the datasets used in this work since such information could be exploited to carry out targeted attacks. To mitigate these risks, we relied on publicly available and pseudonymized data, and we carried out analyses at an aggregated level. Moreover, the observational and retrospective nature of our analyses implies that no users were harmed as part of this research. The authors declare no competing interests.
\subsection{Acknowledgements}
This project was partially funded by the Emergent Ventures India Grant (EV \#1802) within the project Search 4 Computational Hate (S4CH). The authors gratefully acknowledge support by the Swiss National Science Foundation through the Sinergia project (CRSII5\_209250) \textit{CAll for Regulation support In Social MediA} (CARISMA) and the SPARK project \textit{Detecting Troll Activity in Online Social Networks (CRSK-2\_195707)}. In view of scientific transparency, we make our code available on GitHub\footnote{https://github.com/psvp28/s4ch} to allow reproducibility and replicability of our work, as well as to enable further research.
| {'timestamp': '2023-02-10T02:07:02', 'yymm': '2302', 'arxiv_id': '2302.04450', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04450'} | arxiv |
\section{Introduction}
Understanding the complexity of \emph{security sharing} (hereafter referred as ``SS'') is an important task in theoretical computer science.
For general access structure, the complexity measure is often taken to be the ratio between total share size and secret size. Csirmaz \cite{csirmaz1997size} proved the best lower bounds $\Omega(\frac{n^2}{\log n})$ using information inequalities; for any access structure, Liu and Vaikuntanathan \cite{liu2018breaking} constructed a SS scheme with share size $2^{0.994n}$; The best upper bound is $2^{0.637n}$, due to Applebaum et al. \cite{applebaum2019secret, applebaum2020better}.
Through the equivalence between linear SS scheme and monotone span programs (as shown by Beimel \cite{beimel1996secure}), Babai, G{\'a}l and Wigderson \cite{babai1999superpolynomial} proved the first super-polynomial lower bound; Robere, Pitassi, Rossman and Cook \cite{robere2016exponential} proved an exponential bound for an explicit monotone function on the monotone span program size, which implies a lower bound on the total share size of any linear SS scheme realizing that access structure.
Compared with generic access structure SS, threshold SS is relatively well understood. Shamir \cite{shamir1979share} proposed a threshold SS using polynomial evaluation and interpolation, which can be implemented in time $O(n \cdot \mathrm{polylog}(n))$ if the secret length is $O(\log n)$.
One variant is \emph{near-threshold} SS scheme, where a $(\sigma, \rho)$-threshold SS requires that any set of at most $\sigma n$ parities learns nothing, and any set of at least $\rho n$ parties can recover the secret. Druk and Ishai \cite{druk2014linear} proved that, for near-threshold SS scheme, the shares are computably by linear-size logarithmic-depth circuits; the construction is based on the hash function construction by Ishai et al. \cite{ishai2008cryptography}. Later, Cramer et al. \cite{cramer2015linear} constructed a near-threshold SS scheme with both linear-time sharing and reconstruction algorithm. By studying bounded indistinguishability, Bogdanov, Ishai, Viola and Williamson \cite{bogdanov2016bounded} showed that, for any $0 < \sigma < \rho \le 1$, $(\sigma, \rho)$-threshold SS is in $\mathrm{AC^0}$. Allowing slight relaxations on error probability, Cheng, Ishai, and Li \cite{cheng2017near} constructed near threshold SS in $\mathrm{AC^0}$ with better parameters.
Besides secret sharing, researchers are interested in understanding the computational complexity of other cryptographic primitives, including pairwise-independent hashing, one-way function (OWF), pseudorandom generators (PRG), encryption, etc. In \cite{applebaum2006cryptography}, Applebaum, Ishai and Kushilevitz proved that every ``moderately easy'' OWF (resp. PRG), say computable in $\mathrm{NC}^1$, can be compiled into a OWF (resp., ``low-stretch'' PRG) in which each output bit depends on at most 4 input bits. In \cite{ishai2008cryptography}, Ishai, Kushilevitz, Ostrovsky and Sahai proved that that pairwise-independent hash functions can be computed by $O(n)$-size $O(\log n)$-depth circuits. In \cite{fan2022exact}, Fan, Li and Yang proved that pseudorandom functions can be constructed in size $2n+o(n)$ for general $B_2$ circuits, and proved an unconditional $2n-O(1)$ lower bound.
There are similarities between SS and network coding. For example, Shah, Rashmi and Ramchandran \cite{shah2013secure} studied a SS model, where the connection between the dealer and participants form a graph --- two nodes can communicate if there is an edge between them. The goal is to minimize the communication cost. Shah et al. showed a necessary condition for the graph $G$ to possess a $(t, n)$-threshold SS scheme; on the other hand, they proposed a sufficient condition, for which they designed a $(t, n)$-threshold SS algorithm with communication complexity $\Theta(n)$.
\subsection{Our results}
The computation model is \emph{unrestricted} arithmetic circuits over a finite field $\mathbb{F}$ as illustrated by Figure \ref{fig:model}. We assume the secret is represented by an element in $\mathbb{F}$, and each share is also represented by an element in $\mathbb{F}$. To realize the distribution of $n$ shares for a $(t, n)$-SS scheme, the circuit will have $\ell$ inputs and $n$ outputs, where one input is the secret, and the remaining inputs are random elements in $\mathbb{F}$. The circuit is the most unrestricted one, in the sense that each gate can compute \emph{any} function, and is of unbounded fan-in. Thus we measure the size by the number of wires instead of gates.
Our first result says, for computing the shares of some threshold SS scheme, the circuit must satisfy some superconcentrator-like connection properties. In terms of techniques, we use linear algebra to deal with linear SS schemes, and use information inequalities to prove the conditions for general SS schemes, linear or nonlinear.
\begin{theorem}
\label{thm:main_condition}
Let $C$ be an unrestricted arithmetic circuit computing $n$ shares of a $(t, n)$-SS scheme, where $C$ has $\ell$ inputs, and one input is the secret, denoted by $s$. Then, the following conditions must be satisfied:
\begin{itemize}
\item circuit $C$, viewed as a graph, is a reversed $(\ell, n, t)$-concentrator;
\item after removing the input $s$ (corresponding to the secret), the circuit, viewed as a graph, is a reversed $(\ell-1, n, t-1)$-concentrator.
\end{itemize}
\end{theorem}
Note that the connection properties are weaker than that of superconcentrators.
Our second result is a theorem in the reverse direction. We prove that any superconcentrator (in fact, any graph satisfying the aforementioned connection properties) can be turned into an arithmetic circuit computing the shares of a threshold SS scheme. The proof is inspired by network coding \cite{li2003linear}. Drucker and the author have used similar ideas to construct circuits encoding error-correcting codes \cite{Drucker2022}.
\begin{theorem}
\label{thm:main_construction}
For any directed acyclic graph with $t$ inputs and $n$ outputs satisfying the conditions in Theorem \ref{thm:main_condition}, by replacing each non-input vertex with an addition gates, and choosing the coefficients uniformly at random, with high probability, the circuit computes $n$ shares of a $(t, n)$-SS scheme, assuming the field is large enough.
\end{theorem}
For proving superlinear circuit lower bound, Valiant \cite{Val77} proposed the definition of superconcentrators, which is a directed acyclic graph satisfying ``strongest'' connection properties. Surprisingly, Valiant showed the existence of linear-size superconcentrator, thus dashed the possibility to prove superlinear circuit lower bound using connectivity properties. On the other hand, superconcentrators are highly connected graphs with no bottleneck on the information flow. We believe, superconcentrator will find more applications in computation, communication, and cryptography.
Our last result is a (non-explicit) construction of \emph{unbalanced} superconcentrators. Compared with the balanced case (i.e., the number of inputs equals the number of outputs) whose size bounds are well understood, unbalanced superconcentrators are unexplored.
\begin{theorem}
\label{thm:main_sc}
For any $m \ge n$, there exists an $(m, n)$-superconcentrator with $O(m)$ edges and in depth $\alpha(m, n) + O(1)$, where $\alpha(m, n)$ is the two-parameter inverse Ackermann function.
\end{theorem}
Combining Theorem \ref{thm:main_construction} and \ref{thm:main_sc}, we conclude that $(t, n)$-threshold SS can be computed by linear size circuit in depth $O(\alpha(t, n))$. For example, when $n > t^{2.5}$, depth 2 is enough; when $n > t \log^{1.5} t$, depth 3 is enough. In terms of the number of arithmetic operations, the complexity of realizing the distribution of threshold SS schemes is surprisingly small.
\section{Background}
\subsection{Secret sharing scheme}
A \emph{secret sharing (SS) scheme} allows a dealer to distribute a secret among a group of participants such that
\begin{itemize}
\item (Correctness) any authorized subset of participants can fully recover the secret, and
\item (Privacy) any unauthorized subset of participants learns nothing about the secret.
\end{itemize}
One type of SS scheme that has been widely studied is \emph{$(t, n)$-threshold SS scheme}, where any subset of $t$ participants (among $n$ participants) can recover the secret, while any subset of at most $t-1$ participants learns nothing.
Fix a finite field $\mathbb{F}$. Represent the secret $s$ by an element in $\mathbb{F}$. (If the secret size is larger than the field size, one can divide the secret into small pieces, and apply the SS scheme to individual pieces separately.) Let $r_1, r_2, \dots$ be random elements in $\mathbb{F}$ that are used by some SS scheme, and let $R=\{r_1, r_2, \ldots\}$. A scheme is called a \emph{linear SS scheme} if each share is a linear combination of secret $s$ and $r_1, r_2, \ldots$ over field $\mathbb{F}$.
\subsection{Entropy and information inequalities}
Let $X$ be a random variable valued in a finite set, where $p(x) = \Pr[X = x]$. The \emph{entropy} of random variable $X$ is defined by
\begin{equation}
H(X) = - \sum_x p(x) \log p(x),
\end{equation}
where $p(x) = \Pr[X = x]$. For random variables $X$ and $Y$, the \emph{conditional entropy} of $Y$ given $X$ is defined by
\begin{equation}
H(Y | X) = - \sum_{x, y} p(x, y) p(y | x),
\end{equation}
where $p(y | x) = \Pr[Y = y | X = x]$. One can verify $H(Y | X) = H(X, Y) - H(X)$ and $
H(Y | X) = \sum_x p(x) H(Y | X = x).
$
The \emph{mutual information} between $X$ and $Y$ is defined by
\[
I(X; Y) = \sum_{x, y} p(x, y) \log \frac{p(x, y)}{p(x)p(y)}.
\]
We have $I(X; Y) = I(Y;X)$ and $I(X; Y) = H(X) - H(X | Y)$. The mutual information between $X$ and $Y$ conditioning on $Z$ is defined by
\[
I(X;Y | Z) = p(x, y, z) \log \frac{p(x, y | z)}{p(x | z) p(y | z)}.
\]
We have
$I(X;Y | Z) = H(X | Z) - H(X | Y, Z)$. A useful property is that $I(X;Y | Z)$ is always nonnegative.
We refer interested readers to \cite{yeung2002first} for a treatment on entropy functions and information inequalities.
It is well-known that the requirements in a SS scheme can be reformulated using entropy functions \cite{beimel2011secret}. Denote the secret by a random variable $S$; denote $n$ shares by random variables $Y_1, Y_2, \ldots, Y_n$. The SS scheme is a $(t, n)$-threshold SS scheme if and only if
\begin{itemize}
\item (Correctness) for every $T = \{i_1, \ldots, i_t\} \subseteq [n]$ of size $t$,
\begin{equation}
\label{equ:h_cor}
H(S | Y_T) = 0,
\end{equation}
where $Y_T$ denotes the vector $(Y_{i_1}, \ldots, Y_{i_t})$.
\item (Privacy) for every $T \subseteq [n]$ of size $t-1$,
\begin{equation}
\label{equ:h_pri}
H(S | Y_T) = H(S).
\end{equation}
\end{itemize}
\subsection{Circuit model}
In the arithmetic circuit model, we assume
\begin{itemize}
\item A secret is an element in a finite field $\mathbb{F}$.
\item The distribution phase uses at most $\ell-1$ random elements (from finite field $\mathbb{F}$), denoted by inputs $r_1, \ldots, r_{\ell-1}$. For convenience, let $R = \{r_1, \ldots, r_{\ell-1}\}$. (As we will see, for the $(t, n)$-threshold SS scheme, the circuit must use at least $t-1$ random elements.)
\item $n$ shares are computed by an arithmetic circuit over $\mathbb{F}$, where the circuit has $n$ outputs, denoted by $y_1, y_2, \ldots, y_n$.
\item The fan-in of each gate is unbounded. Define the \emph{size} of the circuit to be the number of \emph{wires} instead of gates.
\item For the lower bound that we will prove, we assume the arithmetic circuit is \emph{unrestricted}, i.e., a gate with fan-in $d$ can compute \emph{any} function from $\mathbb{F}^d$ to $\mathbb{F}$, and $d$ is unbounded.
\item For linear SS scheme, the circuit computes a linear transformation $X \mapsto MX$, where $X \in \mathbb{F}^\ell$ and $M$ is a $n \times \ell$ matrix. (However, the internal gates are not necessarily linear.)
\item An arithmetic circuit is called \emph{linear} if each gate computes a linear function over $\mathbb{F}$. Obviously, a linear arithmetic circuit computes a linear transformation.
\end{itemize}
\begin{figure}[h]
\includegraphics[scale=0.4]{model.png}
\caption{unrestricted arithmetic circuit computing $n$ shares}
\label{fig:model}
\end{figure}
\subsection{Inverse Ackermann-type function}
Following Raz and Shpilka \cite{raz2001lower}, we define slowly-growing functions $\lambda_d(n)$. These are inverse Ackermann-type functions that are tailored for superconcentrators.
\begin{definition} For a function $f$, define $f^{(i)}$ to be the composition of $f$ with itself $i$ times, i.e., $f(i) = \underbrace{f\circ f\circ \ldots \circ f}_{i \text{ times}}$. Thus, $f^{(1)} = f$.
For a function $f: \mathbb{N} \to \mathbb{N}$ such that $f(n) < n$ for all $n > 1$, define
\[
f^*(n) = \min\{ i : f^{(i)}(n) \le 1 \}.
\]
\end{definition}
\begin{proposition} Let $f : \mathbb{N} \to \mathbb{N}$ be any function such that $f(n) < n$ for all $n > 1$. Then we have
\[
f^*(n) < f(n).
\]
\end{proposition}
\begin{proof}
Consider
\[
f(n), f^{(1)}(n), \ldots, f^{(i)}(n) = 1,
\]
where $i = f^*(n)$.
Since $n > f(n) > f^{(1)}(n) > \ldots > f^{(i)}(n) = 1$, we have $i \le f(n) - 1$.
\end{proof}
\begin{definition} \cite{raz2001lower} Let
\begin{eqnarray*}
\lambda_1(n) &=& \lfloor \sqrt{n} \rfloor, \\
\lambda_2(n) &=& \lceil \log(n) \rceil, \\
\lambda_d(n) & = & \lambda_{d-2}^*(n).
\end{eqnarray*}
\end{definition}
As $d$ gets larger, the function $\lambda_d(n)$ becomes extremely slow-growing. It would be an exercise to prove
\begin{itemize}
\item $\lambda_2(n) = \Theta(\log n)$,
\item $\lambda_3(n) = \Theta(\log\log n)$,
\item $\lambda_4(n), \lambda_5(n) = \Theta(\log^*(n))$.
\end{itemize}
For studying the size bounds of unbalanced superconcentrators, we would need to define the two-parameter version of the inverse Ackermann function. We have not attempted to optimize the constants in the following definition.
\begin{definition} [Inverse Ackermann function] For any $m \ge n$, let
\begin{equation}
\alpha(m, n) =
\begin{cases}
\min\{ d : \frac{m}{n} \ge \lambda_d(n) \}, & \text{if}\ m \ge 128 n, \\
\min\{ d : \lambda_d(n) \le 4 \}, & \text{otherwise.}
\end{cases}
\end{equation}
Denote $\alpha(n, n)$ by $\alpha(n)$, which is the one-parameter version of the inverse Ackermann function.
\end{definition}
In the literature there are many versions of the Ackermann function. As far as we know, different versions of the inverse Ackermann functions vary by at most a multiplicative constant factor.
For showing $\alpha(m, n)$ is well-defined and using it for the construction of unbalanced superconcentrators, we would need the following properties, whose proofs are in Appendix \ref{app:inverse_ack_properties}.
\begin{proposition}
\label{prop:u34d_ub}
1. For any $n \ge 1$,
\[
\lambda_3(n) \le \log\log n + 2.
\]
2. For any $n \ge 1$,
\[
\lambda_4(n) \le 2 \log^*n.
\]
3. For any $d \ge 1$, for all $n \ge 4$,
\[
\lambda_d(n) \le n-2.
\]
\end{proposition}
\begin{proposition}
\label{prop:alpha_well_defined}
1. For any $d \ge 1$,
\[
\lambda_d(d) \le 4.
\]
2. For any $d \ge 1$, if $\lambda_d(n) \le C$, where $C \ge 128$, then
\[
\lambda_{d+2}(n)^2 \le C.
\]
\end{proposition}
\subsection{Concentrators and superconcentrators}
An \emph{$(m, n)$-network} is a directed acyclic graph with $m$ inputs and $n$ outputs.
\begin{definition} [$(m, n)$-superconcentrator \cite{Val77}]
An $(m, n)$-network an \emph{$(m, n)$-superconcentrator} if for any equal-size $X \subseteq I$ and $Y \subseteq O$, there exist $|X| = |Y|$ vertex-disjoint paths connecting $X$ and $Y$.
\end{definition}
When $m = n$, tight bounds on the size of bounded-depth superconcentrator are known, achieved in a series of papers.
\begin{table}[h!]
\begin{center}
\begin{tabular}{ |c|c|c| }
\hline
Depth & Size \\
\hline
2 & $\Theta(n \log^2 n / \log\log n)$ \cite{AP94}, \cite{RT00} \\
3 & $\Theta(n \log\log n)$ \cite{AP94} \\
$d \ge 4$ & $\Theta(n \lambda_d(n))$ \cite{DDPW83}, \cite{Pud94} \\
$\Theta(\alpha(n))$ & $\Theta(n)$ \cite{DDPW83} \\
\hline
\end{tabular}
\caption{Superconcentrator size bounds.}
\label{table:sc_bounds}
\end{center}
\end{table}
Another relevant concept is \emph{concentrators}, which are critical building blocks for constructing superconcentrators.
\begin{definition}
\label{def:concentrator}
An \emph{$(m, n, c)$-concentrator} is an $(m, n)$-network, such that for any subset of $c$ inputs, there are $c$ vertex-disjoint paths connecting these $c$ inputs to outputs.
An $(m, n, n)$-concentrator is referred to as a full capacity concentrator, denoted as $(m, n)$-concentrator.
\end{definition}
An $(m, n)$-superconcentrator is obviously an $(m, n)$-concentrator. Concentrators are used as building blocks for the construction of superconcentrators.
Using a standard probabilistic argument, one can prove
\begin{lemma}
\label{lem:linear_concentrator} \cite{pinsker1973complexity, DDPW83} For any $n \ge m$, $n \ge 1.1k$, and $m \ge k+1$, there exists depth-1 $(m, n, k)$-concentrator of size
\[
O\left(n \cdot \frac{\log(n/k)}{\log(m/k)}\right).
\]
\end{lemma}
\section{Graph-theoretic properties}
\subsection{Linear SS scheme}
In this section, we prove any arithmetic circuit computing the distribution of a \emph{linear} secret sharing scheme must satisfy some graph-theoretic properties (similar to, but weaker than that of superconcentrators).
We will prove the arithmetic circuit must satisfy the following graph-theoretic properties:
\begin{itemize}
\item For any subset of outputs $T \subseteq [n]$ of size $t-1$, there are $t-1$ vertex-disjoint paths connecting $T$ and $R$.
\item For any subset of outputs $T \subseteq [n]$ of size $t$, there exist $t$ vertex-disjoint paths connecting $T$ and inputs.
\end{itemize}
\begin{lemma}
\label{lem:tm1_paths}
In the above model, if the circuit computes $n$ shares of some $(t, n)$-threshold secret sharing scheme, then for any subset $T$ of outputs of size $t-1$, there are $t-1$ vertex-disjoint paths connecting $T$ with ($t-1$ inputs from) $R$. Moreover, the $(t-1) \times (\ell-1)$ submatrix $M_{T, R}$ has rank $t-1$.
\end{lemma}
\begin{proof}
It suffices to prove the ``moreover'' part. Because if there do not exist $t-1$ vertex-disjoint paths, by Menger's theorem, we know there exists a subset of vertices of size at most $t-2$ whose removal will disconnect $T$ and $R$. Thus, after fixing $s$, all outputs in $T$ can be written as a function (not necessarily linear) in $R$, which implies that the number of distinct outputs $y_T$ is at most $|\mathbb{F}|^{t-2}$ (after fixing $s$). This contradicts to
$\mathrm{rank} M_{T, R} = t-1$.
Suppose for contradiction that there exists some $T \subseteq [n]$ of size $t-1$ such that $\mathrm{rank} M_{T, R} < t-1$.
\textbf{Case 1:} $M_{T, 1} = \vec{0}$. In other words, the first input $s$ has no impact on outputs $T$. Since $\mathrm{rank}{M_{T, R}} < t-1$ and adding one extra column with all zeros does not change its rank, we have $\mathrm{rank}{M_{T}} < t-1$, where $M_T$ denotes the submatrix of $M$ consisting of all rows in $T$. Let us add one output to $T$, denoted by $T'$, such that $|T'| = t$. By linear algebra,
\[
\mathrm{rank}{M_{T'}} \le \mathrm{rank}{M_{T}} + 1 < t,
\]
which is not of full rank. (Note that $M_{T'}$ is a $t \times \ell$ matrix.) Thus, there exists a subset of $T'$, denoted by $T''$, such that $|T''| < t$ and $\mathrm{rank}{M_{T''}} = \mathrm{rank}{M_{T'}}$, which implies that participants in $T''$ would be able to recover the secret, assuming participants in $T'$ can recover the secret. This contradicts the definition of $(t, n)$-threshold secret sharing scheme.
\textbf{Case 2:} $M_{T, 1} \not= \vec{0}$. Note that
\[
\begin{pmatrix}
y_1 \\
y_2 \\
\vdots \\
y_n
\end{pmatrix}
=
M
\begin{pmatrix}
s \\
r_1 \\
\vdots \\
r_{\ell-1}
\end{pmatrix},
\]
where $M$ is an $n \times \ell$ matrix computed by the arithmetic circuit. Denote by $Y_T$ the vector indexed by rows in $T$. So we have
\begin{eqnarray*}
y_T
& = &
M_{T}
\begin{pmatrix}
s \\
r_1 \\
\vdots \\
r_{\ell-1}
\end{pmatrix}
= M_{T, R} \begin{pmatrix}
r_1 \\
\vdots \\
r_{\ell-1}
\end{pmatrix}
+
sM_{T, 1}
\end{eqnarray*}
We assume for contradiction that $\mathrm{rank} M_{T, R} < t-1$.
\textbf{Case 2.1:} there exists $X \in \mathbb{F}^{\ell-1}$ such that $M_{T, R}X = M_{T, 1}$. In other words, the first column of $M_{T}$ is a linear combination of the remaining $\ell-1$ columns. By linear algebra, we have
\[
\mathrm{rank} M_{T} = \mathrm{rank} M_{T, R}.
\]
Consider any superset of $T$ of size $t$, denoted by $T'$. By linear algebra, we have
\[
\mathrm{rank} M_{T'} \le \mathrm{rank} M_{T} + 1 < t.
\]
Using the same argument as Case 1, we know there exists a proper subset of $T'$ of size $t-1$ whose collation can recover the secret.
\textbf{Case 2.2:} there does not exist $X \in \mathbb{F}^{\ell-1}$ such that $M_{T, R}X = M_{T, 1}$. Let $d = \mathrm{rank} M_{T, R}$, which is less than $t-1$ by assumption. Observe that
\begin{itemize}
\item The image of $X \mapsto M_{T, \{2, 3, \ldots, t\}} X$, where $X \in \mathbb{F}^{\ell-1}$, is a linear subspace of $\mathbb{F}^{t-1}$ of dimension $d$, denoted by $L \subseteq \mathbb{F}^{t-1}$.
\item For distinct $s \in \mathbb{F}$, $sM_{T, 1} + L$ are disjoint. (Otherwise, $M_{T, 1}$ would be written as a linear combination of the columns in $M_{T, R}$.)
\end{itemize}
So we conclude the collation of $T$ can always recover $s$. Contradiction!
\end{proof}
\begin{lemma} In the above model, if the circuit computes $n$ shares of some $(t, n)$-threshold linear secret sharing scheme, then for any subset of outputs $T \subseteq [n]$ of size $t$, the following conditions are satisfied:
\begin{itemize}
\item There are $t-1$ vertex-disjoint paths connecting $R$ and $T$. Moreover, $\mathrm{rank} M_{T, R} = t-1$.
\item There are $t$ vertex-disjoint paths connecting inputs and $T$. Moreover, $\mathrm{rank} M_{T} = t$.
\end{itemize}
\end{lemma}
\begin{proof}
Similar to Lemma \ref{lem:tm1_paths}, it suffices to prove the ``moreover'' part. By Lemma \ref{lem:tm1_paths}, we know for any $T' \subseteq T$ of size $t-1$, $\mathrm{rank} M_{T', R} = t-1$. Thus, we have
\[
\mathrm{rank} M_{T, R} \ge \mathrm{rank} M_{T', R} = t-1.
\]
On the other hand, $\mathrm{rank} M_{T, R} \le |T| = t$. We will prove $\mathrm{rank} M_{T, R} < t$.
Denote $n$ outputs by $Y = \begin{pmatrix}
y_1 \\
y_2 \\
\vdots \\
y_n
\end{pmatrix}$, $\ell$ inputs by $X = \begin{pmatrix}
s \\
r_1 \\
\vdots \\
r_{\ell-1}
\end{pmatrix}$, and $Y = MX$, where $M$ is a $n \times \ell$ matrix. For outputs $T \subseteq [n]$, we have
$
Y_T = M_{T}X,
$
where $M_T$ denotes the submatrix of $M$ indexed by rows $T$. Write
\begin{eqnarray*}
Y_T & = &
\begin{pmatrix}
M_{T, 1} & M_{T, R}
\end{pmatrix}
\begin{pmatrix}
s \\
X_R
\end{pmatrix}\\
& = & M_{T, 1}s + M_{T, R}X_R.
\end{eqnarray*}
If $\mathrm{rank} M_{T, R} = |T| = t$, $M_{T, R} X_R$ will be uniformly random in $\mathbb{F}^{t}$ (for $X_R \in \mathbb{F}^{\ell-1}$ is uniformly random), regardless of $s$. So participants in $T$ could not recover the secret $s$. This contradicts the definition of $(t, n)$-threshold secret sharing scheme.
We have shown that $\mathrm{rank} M_{T, R} = t - 1$. Thus the image of $X_R \mapsto M_{T, R} X_R$ is a $t-1$ dimensional vector space of $\mathbb{F}^t$, denoted by $L \subseteq \mathbb{F}^{t}$. Assume for contradiction that $\mathrm{rank} M_T = \mathrm{rank} M_{T, R} = t-1$, which implies that $M_{T, 1}$ can be written as linear combinations of the columns in $M_{T, R}$. So $Y_T$ will be a uniformly random element in $L$, regardless of $s$. Thus the coalition of participants in $T$ cannot recover the secret. Contradiction.
\end{proof}
\begin{comment}
, that is, there exists $R' \subseteq R$ of size $t-1$ such that
$\mathrm{rank} M_{T, \{1\} \cup R'} = t$.
Denote $n$ outputs by $Y = \begin{pmatrix}
y_1 \\
y_2 \\
\vdots \\
y_n
\end{pmatrix}$, $t$ inputs by $X = \begin{pmatrix}
s \\
r_1 \\
\vdots \\
r_{t-1}
\end{pmatrix}$, and $Y = MX$, where $M$ is a $n \times t$ matrix. For outputs $T \subseteq [n]$, we have
$
Y_T = M_{T}X,
$
where $M_T$ denotes the submatrix of $M$ indexed by rows $T$.
Let $i \in T$ be the smallest element, and $T' = T \setminus \{i\}$, and thus $|T'| = t-1$. Rewrite $Y_T = M_T X$ as
\[
\begin{pmatrix}
y_i \\
Y_{T'}
\end{pmatrix}
=
\begin{pmatrix}
m_{i1} & M_{i, [t]} \\
M_{T', 1} & M_{T', \{2, 3, \ldots, t\}}
\end{pmatrix}
\begin{pmatrix}
s \\
R
\end{pmatrix},
\]
which is
\begin{eqnarray*}
y_i & = & m_{i1}s + M_{i, [t]}R, \\
Y_{T'} & = & M_{T', 1}s + M_{T', \{2,3, \ldots, t\}}R. \\
\end{eqnarray*}
By Lemma \ref{lem:tm1_paths}, we know $M_{T', \{2,3, \ldots, t\}}$ is of full rank. So
$$
R = M_{T', \{2,3, \ldots, t\}}^{-1} (Y_{T'} - M_{T', 1}s),
$$
and thus
\begin{eqnarray*}
y_i & = & m_{i1}s + M_{i, [t]} M_{T', \{2,3, \ldots, t\}}^{-1} (Y_{T'} - M_{T', 1}s) \\
& = & (m_{i1} - M_{i, [t]} M_{T', \{2,3, \ldots, t\}}^{-1} M_{T', 1})s + M_{i, [t]} M_{T', \{2,3, \ldots, t\}}^{-1} Y_{T'}.
\end{eqnarray*}
So $s$ is solvable if and only if $m_{i1} - M_{i, [t]} M_{T', \{2,3, \ldots, t\}}^{-1} M_{T', 1} \not= 0$.
By linear algebra, we know
\begin{eqnarray*}
& & \det \begin{pmatrix}
m_{i1} & M_{i, [t]} \\
M_{T', 1} & M_{T', \{2, 3, \ldots, t\}}
\end{pmatrix} \\
& = &
\det M_{T', \{2, 3, \ldots, t\}} \det(m_{i1} - M_{i, [t]} M_{T', \{2, 3, \ldots, t\}}^{-1} M_{T', 1}),
\end{eqnarray*}
which is nonzero, as desired.
\end{comment}
\begin{comment}
In the arithmetic circuit model, we assume
\begin{itemize}
\item A secret an element in a finite field $\mathbb{F}$.
\item The scheme uses at most $t-1$ random elements (from field $\mathbb{F}$), denoted by inputs $r_1, \ldots, r_{t-1}$.
\item The distribution is computed by a linear arithmetic circuit over $\mathbb{F}$
\end{itemize}
We will prove the circuit must satisfy the following connection property:
\begin{itemize}
\item For any subset of outputs $T \subseteq [n]$ of size $t-1$, there must be $t-1$ vertex-disjoint paths connecting $r_1, r_2, \ldots, r_{t-1}$.
\item For any subset of outputs $T \subseteq [n]$ of size $t$, there must be $t$ vertex-disjoint paths connecting $T$ with all $t$ inputs.
\end{itemize}
In this linear arithmetic circuit model, combined with the results in the previous section, we know that the graph-theoretic property is both necessary and sufficient (for large field $\mathbb{F}$).
\begin{lemma}
\label{lem:tm1_paths}
In the above model, if the circuit computes the distribution of $(t, n)$-threshold secret sharing scheme, then for any subset of outputs $T \subseteq [n]$ of size $t-1$, there are $t-1$ vertex-disjoint paths connecting $r_1, \ldots, r_{t-1}$ with $T$. Moreover, the $(t-1) \times (t-1)$ submatrix $M_{T, \{2, 3, \ldots, t\}}$ is of full rank.
\end{lemma}
\begin{proof} The circuit computes a linear transformation $x \mapsto Mx$, where $M$ is an $n \times t$ matrix. Let $T \subseteq [n]$ of size $t-1$. Suppose for contradiction that there do not exist $t-1$ vertex-disjoint paths connecting inputs $r_1, \ldots, r_{t-1}$ to $T$. Thus there exist less than $t-1$ vertices whose removal would disconnect $r_1, \ldots, r_{t-1}$ and $T$. So every output in $T$ can be written as a linear function in the ``cut'' vertices, which implies that $\mathrm{rank} M_{T, \{2, 3, \ldots, t-1\}} < t-1$.
\textbf{Case 1:} $M_{T, 1} = \vec{0}$. In other words, the first input $x_1$ has no impact on outputs $T$. Since $\mathrm{rank}{M_{T, \{2, 3, \ldots, t\}}} < t-1$ and adding one extra column with all zeros does not change its rank, we have $\mathrm{rank}{M_{T, [t]}} < t-1$. Let us add one output to $T$, denoted by $T'$, such that $|T'| = t$. By linear algebra, $\mathrm{rank}{M_{T', [t]}}$ is at most $\mathrm{rank}{M_{T, [t]}} + 1 < t$, which is not of full rank. Thus, there exists a subset of $T'$, denoted by $S$, such that $|S| < t$ and $\mathrm{rank}{M_{S, [t]}} = \mathrm{rank}{M_{T', [t]}}$, which implies that participants $S$, $|S| < t$, would be able to recover the secret, assuming $T'$, $|T'| = t$, can recover the secret. This contracts to the definition of $(t, n)$-threshold secret sharing scheme.
\textbf{Case 2:} $M_{T, 1} \not= \vec{0}$. Note that
\[
\begin{pmatrix}
y_1 \\
y_2 \\
\vdots \\
y_n
\end{pmatrix}
=
M
\begin{pmatrix}
s \\
r_1 \\
\vdots \\
r_{t-1}
\end{pmatrix},
\]
where $M$ is an $n \times t$ matrix computed by the arithmetic circuit. Denote by $Y_T$ the vector indexed by rows in $T$. So we have
\begin{eqnarray*}
y_T
& = &
M_{T, [t]}
\begin{pmatrix}
s \\
r_1 \\
\vdots \\
r_{t-1}
\end{pmatrix}
= M_{T, \{2,3,\ldots, t\}} \begin{pmatrix}
r_1 \\
\vdots \\
r_{t-1}
\end{pmatrix}
+
sM_{T, 1}
\end{eqnarray*}
We assume for contradiction that $\mathrm{rank} M_{T, \{2,3,\ldots, t\}}$ is less than $t-1$.
\textbf{Case 2.1:} there exists $R \in \mathbb{F}^{t-1}$ such that $M_{T, \{2,3,\ldots,t\}}R = M_{T, 1}$. In other words, the first column of $M_{T, [t]}$ is a linear combination of the remaining $t-1$ columns. By linear algebra, we have
\[
\mathrm{rank} M_{T, [t]} = \mathrm{rank} M_{T, \{2, 3, \ldots, t\}}.
\]
Consider any superset of $T$ with size $t$, denoted by $T'$. By linear algebra, we have
\[
\mathrm{rank} M_{T', [t]} \le \mathrm{rank} M_{T, [t]} + 1 < t.
\]
Using the same argument as case 1, we know there exists a proper subset of $T'$ of size $t-1$ whose collation can recover the secret.
\textbf{Case 2.2:} there does not exist $R \in \mathbb{F}^{t-1}$ such that $M_{T, \{2,3,\ldots,t\}}R = M_{T, 1}$. Let $d = \mathrm{rank} M_{T, \{2, 3, \ldots, t\}}$, which is less than $t-1$ by assumption. Observe that
\begin{itemize}
\item The image of $R \mapsto M_{T, \{2, 3, \ldots, t\}} R$, where $R \in \mathbb{F}^{t-1}$, is a linear subspace of $\mathbb{F}^{t-1}$ of dimension $d$, denoted by $L \subseteq \mathbb{F}^{t-1}$.
\item For different $s \in \mathbb{F}$, $sM_{T, 1} + L$ are disjoint. (Otherwise, $M_{T, 1}$ would be written as a linear combination of the columns in $M_{T, \{2,3,\ldots,t\}}$.)
\end{itemize}
So we conclude the collation of $T$ can always recover $s$. Contradiction!
\end{proof}
\begin{lemma} In the above model, if the circuit computes the distribution of a $(t, n)$-threshold secret sharing scheme, then for any subset of outputs $T \subseteq [n]$ of size $t$, there are $t$ vertex-disjoint paths connecting $t$ inputs with $T$. Moreoever, $t \times t$ matrix $M_{T, [t]}$ is of full rank.
\end{lemma}
\begin{proof}
Denote $n$ outputs by $Y = \begin{pmatrix}
y_1 \\
y_2 \\
\vdots \\
y_n
\end{pmatrix}$, $t$ inputs by $X = \begin{pmatrix}
s \\
r_1 \\
\vdots \\
r_{t-1}
\end{pmatrix}$, and $Y = MX$, where $M$ is a $n \times t$ matrix. For outputs $T \subseteq [n]$, we have
$
Y_T = M_{T}X,
$
where $M_T$ denotes the submatrix of $M$ indexed by rows $T$.
Let $i \in T$ be the smallest element, and $T' = T \setminus \{i\}$, and thus $|T'| = t-1$. Rewrite $Y_T = M_T X$ as
\[
\begin{pmatrix}
y_i \\
Y_{T'}
\end{pmatrix}
=
\begin{pmatrix}
m_{i1} & M_{i, [t]} \\
M_{T', 1} & M_{T', \{2, 3, \ldots, t\}}
\end{pmatrix}
\begin{pmatrix}
s \\
R
\end{pmatrix},
\]
which is
\begin{eqnarray*}
y_i & = & m_{i1}s + M_{i, [t]}R, \\
Y_{T'} & = & M_{T', 1}s + M_{T', \{2,3, \ldots, t\}}R. \\
\end{eqnarray*}
By Lemma \ref{lem:tm1_paths}, we know $M_{T', \{2,3, \ldots, t\}}$ is of full rank. So
$$
R = M_{T', \{2,3, \ldots, t\}}^{-1} (Y_{T'} - M_{T', 1}s),
$$
and thus
\begin{eqnarray*}
y_i & = & m_{i1}s + M_{i, [t]} M_{T', \{2,3, \ldots, t\}}^{-1} (Y_{T'} - M_{T', 1}s) \\
& = & (m_{i1} - M_{i, [t]} M_{T', \{2,3, \ldots, t\}}^{-1} M_{T', 1})s + M_{i, [t]} M_{T', \{2,3, \ldots, t\}}^{-1} Y_{T'}.
\end{eqnarray*}
So $s$ is solvable if and only if $m_{i1} - M_{i, [t]} M_{T', \{2,3, \ldots, t\}}^{-1} M_{T', 1} \not= 0$.
By linear algebra, we know
\begin{eqnarray*}
& & \det \begin{pmatrix}
m_{i1} & M_{i, [t]} \\
M_{T', 1} & M_{T', \{2, 3, \ldots, t\}}
\end{pmatrix} \\
& = &
\det M_{T', \{2, 3, \ldots, t\}} \det(m_{i1} - M_{i, [t]} M_{T', \{2, 3, \ldots, t\}}^{-1} M_{T', 1}),
\end{eqnarray*}
which is nonzero, as desired.
\end{comment}
\subsection{Nonlinear SS scheme}
For \emph{nonlinear} SS scheme, the linear algebra argument does not work. In this section, we apply Shannon's information measures to prove the connection properties must hold for any, possibly nonlinear, SS schemes.
The computation model is, again, an unrestricted arithmetic circuit as illustrated by Figure \ref{fig:model}, which computes the shares of some $(t, n)$-threshold SS scheme. The inputs are $s$ and $R = \{r_1, r_2, \ldots, r_{\ell-1}$, where $s \in \mathbb{F}$ is the share, and $r_1, \ldots, r_{\ell-1} \in \mathbb{F}$ are the independently uniformly distributed in $\mathbb{F}$; the outputs are $y_1, \ldots, y_n$, representing $n$ shares.
Our goal is to prove, any circuit computing the shares of some $(t, n)$-threshold SS scheme must satisfy
\begin{itemize}
\item For any subset of outputs $T \subseteq [n]$ of size $t-1$, there are $t-1$ vertex-disjoint paths connecting $R$ and $T$.
\item For any subset of outputs $T \subseteq [n]$ of size $t$, there are $t$ vertex-disjoint paths connecting inputs (i.e., $R \cup \{s\}$) and $T$.
\end{itemize}
Our strategy is to formulate the \emph{connectivity requirements} as \emph{information inequalities}. Two critical observations are: one gate carries at most $\log |\mathbb{F}|$ units of information; if random variables $Y$ can be written as a function in random variables $X$, then $H(Y) \le H(X)$.
So, it suffices to prove
\begin{itemize}
\item For any subset of outputs $T \subseteq [n]$ of size $t-1$,
\begin{equation}
\label{equ:goal_tm1}
H(Y_T | S) \ge (t-1) H(S).
\end{equation}
\item For any subset of outputs $T \subseteq [n]$ of size $t$,
\begin{equation}
\label{equ:goal_t}
H(Y_T) \ge t H(S).
\end{equation}
\end{itemize}
Given \eqref{equ:h_cor} and \eqref{equ:h_pri}, it turns out inequalities \eqref{equ:goal_tm1} and \eqref{equ:goal_t} can be proved using Shannon-type inequalities \footnote{The information inequalities that can be implied by $I(X;Y | Z) \ge 0$ are called \emph{Shannon-type inequalities} \cite{yeung2002first}.}.
Before proving the information inequalities \eqref{equ:goal_tm1} and \eqref{equ:goal_t}, we need the following lemma.
\begin{lemma}
\label{lem:sum_nm1_nonnegative}
Let $Y_1, Y_2, \ldots, Y_n$ be random variables. We have
\[
\sum_{j \in [n]} H(Y_{[n] \setminus \{j\}}) - (n-1) H(Y_1, \ldots, Y_n) \ge 0.
\]
\end{lemma}
\begin{proof} Write
\begin{eqnarray}
& & \sum_{j \in [n]} H(Y_{[n] \setminus \{j\}}) - (n-1) H(Y_1, \ldots, Y_n) \nonumber\\
& = & \sum_{j \in [n]} \left(H(Y_{[n] \setminus \{j\}}) - H(Y_1, \ldots, Y_n) \right) + H(Y_1, \ldots, Y_n). \label{equ:sum_j}
\end{eqnarray}
Note that
\begin{eqnarray*}
& & H(Y_1, Y_2, \ldots, Y_n) \\
& = & H(Y_1) + H(Y_2 | Y_1) + H(Y_3 | Y_1, Y_2) + \ldots + H(Y_n | Y_1, Y_2, \ldots, Y_{n-1}) \\
& \ge & H(Y_1 | Y_{[n] \setminus \{1\}}) + H(Y_2 | Y_{[n] \setminus \{2\}}) + \ldots + H(Y_n | Y_{[n] \setminus \{n\}}).
\end{eqnarray*}
Plugging it into \eqref{equ:sum_j}, we have
\begin{eqnarray*}
& & \sum_{j \in [n]} H(Y_{[n] \setminus \{j\}}) - (n-1) H(Y_1, \ldots, Y_n)\\
& \ge & \sum_{j \in [n]} \left(H(Y_{[n] \setminus \{j\}}) - H(Y_1, \ldots, Y_n) \right) + \sum_{j \in [n]} H(Y_j | Y_{[n] \setminus \{j\}}) \\
& = & \sum_{j \in [n]} \left(H(Y_{[n] \setminus \{j\}}) - H(Y_1, \ldots, Y_n) + H(Y_j | Y_{[n] \setminus \{j\}})\right) \\
& = & 0,
\end{eqnarray*}
which completes the proof.
\end{proof}
\begin{theorem}
\label{thm:m}
Let $S, Y_1, Y_2, \ldots, Y_n$ be random variables satisfying
\begin{itemize}
\item $H(S | Y_T) = H(S)$ for any $T \subseteq [n]$ of size $t-1$, and
\item $H(S | Y_T) = 0$ for any $T \subseteq [n]$ of size $t$.
\end{itemize}
Then, we have
\[
H(Y_T) \ge t H(S)
\]
for any $T \subseteq [n]$ of size $t$.
\end{theorem}
\begin{proof} By \emph{symmetry}, without loss of generality, it suffices to prove $H(Y_1, \ldots, Y_t) \ge t H(S)$.
Write $H(Y_1, \ldots, Y_t) - t H(S)$ as
\begin{eqnarray}
& & H(Y_1, \ldots, Y_t) - t H(S) \nonumber\\
& = & \sum_{j \in [t]} \left( H(S, Y_{[t] \setminus \{j\}}) - H(Y_{[t] \setminus \{j\}}) - H(S) \right) - t\left( H(S, Y_{[t]}) - H(Y_{[t]})\right) \nonumber \\
& & + \sum_{j \in [t]} \left( H(S, Y_{[t]}) - H(S, Y_{[t] \setminus \{j\}}) \right) \nonumber\\
& & + \sum_{j \in [t]} H(Y_{[t] \setminus \{j\}}) - (t-1)H(Y_{[t]}) \nonumber \\
& = & \sum_{j \in [t]} \left( H(S | Y_{[t] \setminus \{j\}}) - H(S) \right) - t H(S | Y_{[t]}) \label{term:m_t1} \\
& & + \sum_{j \in [t]} H(Y_j | S, Y_{[t] \setminus \{j\}}) \label{term:m_t2} \\
& & + \sum_{j \in [t]} H(Y_{[t] \setminus \{j\}}) - (t-1) H(Y_{[t]}). \label{term:m_t3}
\end{eqnarray}
The first term \eqref{term:m_t1} is zero by our conditions; the second term \eqref{term:m_t2} is clearly nonnegative; the third term \eqref{term:m_t3} is nonnegative by Lemma \ref{lem:sum_nm1_nonnegative}.
Thus, we have $H(Y_1, \ldots, Y_t) - t H(S) \ge 0$, as desired.
\end{proof}
\begin{theorem}
\label{thm:master_m1}
Let $S, Y_1, Y_2, \ldots, Y_n$ be random variables satisfying
\begin{itemize}
\item $H(S | Y_T) = H(S)$ for any $T \subseteq [n]$ of size $t-1$, and
\item $H(S | Y_T) = 0$ for any $T \subseteq [n]$ of size $t$.
\end{itemize}
Then, we have
\[
H(Y_T | S) \ge (t-1)H(S)
\]
for any $T \subseteq [n]$ of size $t-1$.
\end{theorem}
\begin{proof}
By symmetry, we assume $T = \{1,2,\ldots,t-1\}$ without loss of generality. Write $H(Y_T | S) - (t-1) H(S)$ as
\begin{eqnarray}
& & H(Y_{[t-1]} | S) - (t-1) H(S) \nonumber \\
& = & H(S, Y_{[t-1]}) - t H(S) \nonumber \\
& = & \sum_{j \in [t-1]} \left( H(S, Y_{[t]}) - H(S, Y_{[t] \setminus \{j\}}) \right) \nonumber \\
& & + \sum_{j \in [t]} \left( H(S, Y_{[t]\setminus\{j\}}) - H(Y_{[t]\setminus\{j\}}) - H(S) \right) \nonumber \\
& & - (t-1) \left( H(S, Y_{[t]}) - H(Y_{[t]}) \right) \nonumber \\
& & + \sum_{j \in [t]} H(Y_{[t] \setminus \{j\}}) - (t-1) H(Y_{[t]}) \nonumber \\
& = & \sum_{j \in [t-1]} H(Y_j | S, Y_{[t] \setminus \{j\}}) \label{term:m1_t1} \\
& & + \sum_{j \in [t]} \left( H(S | Y_{[t]\setminus\{j\}}) - H(S) \right) \label{term:m1_t2} \\
& & - (t-1) H(S | Y_{[t]}) \label{term:m1_t3} \\
& & + \sum_{j \in [t]} H(Y_{[t] \setminus \{j\}}) - (t-1) H(Y_{[t]}) \label{term:m1_t4},
\end{eqnarray}
where the term \eqref{term:m1_t1} is clearly nonnegative; terms \eqref{term:m1_t2} and \eqref{term:m1_t3} are zero due to our conditions; term \eqref{term:m1_t4} is nonnegative by Lemma \ref{lem:sum_nm1_nonnegative}. Thus, we have $H(Y_{[t-1]} | S) - (t-1) H(S) \ge 0$, as desired.
\end{proof}
Now we are ready to prove our main result, which says any unrestricted arithmetic circuits computing the shares of some threshold SS scheme must satisfy certain connectivity properties.
\begin{theorem}
\label{thm:graph_properities_main}
In the above model as illustrated by Figure \ref{fig:model}, if the circuit computes the shares of some $(t, n)$-threshold SS scheme, the following conditions are satisfied:
\begin{itemize}
\item for any $T \subseteq [n]$ of size $t-1$, there are $t-1$ vertex-disjoint paths connecting $R$ and $T$;
\item for any $T \subseteq [n]$ of size $t$, there are $t$ vertex-disjoint paths connecting inputs and $T$.
\end{itemize}
\end{theorem}
\begin{proof} Assume for contradiction that, for some $T \subseteq [n]$ of size $t-1$, there are at most $t-2$ vertex-disjoint paths connecting $R$ and $T$. By Menger's theorem, there exists a subset of vertices, denoted by $C$, of size at most $t-2$, whose removal will disconnect $R$ and $T$.
By the definition of the cut set $C$, we know that after setting $S$ to a constant, the outputs $Y_T$ can be written as functions in the gates in $C$. By the basic properties of entropy function, we have
\[
H(Y_T | S = s) \le |C| \log \mathbb{F} \le (t-2) \log \mathbb{F}.
\]
Thus,
\begin{eqnarray*}
H(Y_T | S) & = & \sum_s\Pr[S = s] H(Y_T | S = s) \\
& \le & \sum_s\Pr[S = s] (t-2) \log \mathbb{F} \\
& = & (t-2) \log \mathbb{F}.
\end{eqnarray*}
On the other hand, by Theorem \ref{thm:master_m1}, we have $H(Y_T | S) \ge (t-1) H(S) = (t-1) \log \mathbb{F}$, by letting $S$ be uniformly random in $\mathbb{F}$. Contradiction!
The remaining part is similar to prove using Theorem \ref{thm:m}.
\end{proof}
The circuit, viewed as a graph, is an $(|R|+1, n, t)$-concentrator;
after removing input $s$ (as well as the incident edges), the remaining graph is an $(|R|, n, t-1)$-concentrator. First, note that there exist $O(n)$-size concentrators (moreover, superconcentrators). On the other hand, it is unclear what is the smallest size concentrator for \emph{fixed} depth (except for depth 1 \cite{Naka1982}). By Theorem \ref{thm:graph_properities_main}, lower bounds for bounded-depth \emph{concentrators} would imply circuit lower bound for threshold SS.
\section{SS scheme based on superconcentrator}
Given any $(t, n)$-superconcentrator $G$, we shall construct a $(t, n)$-threshold secret sharing scheme. The scheme is a linear secret sharing scheme over a sufficiently large finite field. We require $|\mathbb{F}| \gg d {n \choose t}$, where $d$ is the \emph{depth} of the superconcentrator.
\begin{figure}[h]
\includegraphics[scale=0.4]{circuit2.png}
\caption{arithmetic circuit realizing SS distribution}
\end{figure}
The secret sharing scheme has the following 3 phases:
\vspace{0.2cm}
\textbf{Setup:} Convert $G$ into an arithmetic circuit $C$ over field $\mathbb{F}$ by
\begin{itemize}
\item replacing each vertex with an addition gate, and
\item for every edge $e$, choosing a coefficient $c_e \in \mathbb{F}$ \emph{uniformly at random}.
\end{itemize}
One can easily check this linear arithmetic circuit computes a linear transformation $x \mapsto Mx$, where
$M = (m_{ij})$ is a $n \times t$ matrix. Here
\[
m_{i, j} = \sum_{ {v_1 = x_i, v_2, \ldots, v_\ell = y_j}} \prod_{i=1}^{\ell-1} c_{(v_i, v_{i+1})},
\]
where the sum ranges over all paths from the $j$th input $x_j$ to the $i$th output $y_i$.
\textbf{Sharing:} Feed the secret $s$ to input $x_1$, and set $x_2, \ldots, x_{t}$ uniformly at random. For every $i \in [n]$, send the $i$th output of the circuit to participant $P_i$.
In other words,
\[
\begin{pmatrix}
y_1 \\
y_2 \\
\vdots \\
y_n
\end{pmatrix}
=M
\begin{pmatrix}
s \\
r_2 \\
\vdots \\
r_t
\end{pmatrix},
\]
where $s \in \mathbb{F}$ is the secret, and $r_2, \ldots, r_t$ are uniformly random elements over $\mathbb{F}$.
\textbf{Reconstruction} Consider the coalition of any $t$ participants $T \subseteq [n]$, who receive $t$ shares, denoted by
\[
Y_T = M_T X = M_T \begin{pmatrix}
s \\
r_2 \\
\vdots \\
r_t
\end{pmatrix},
\]
where $X = (s, r_2, \ldots, r_t)^T$, and $M_T$ is a $t \times t$ submatrix of $M$ indexed by rows $T$. Assuming $M_T$ is invertible (as we will see shortly), we have $X = M_T^{-1} Y_T$. So the secret is exactly the first coordinate of $M_T^{-1} Y_T$.
\vspace{0.2cm}
\begin{lemma}
\label{lem:recover}
With probability at least $1 - \frac{d{n \choose t}}{|\mathbb{F}|}$, any $t$ participants can recover the secret.
\end{lemma}
\begin{proof}
It suffices to prove, with probability at least $1 - \frac{{n \choose t}}{|\mathbb{F}|}$, for all $T \subseteq [n]$ of size $t$, $\det(M_T) \not= 0$, where $M_T$ denotes the $t \times t$ submatrix indexed by rows $T$. Because if $M_T$ is invertible, we can recover the secret by computing $X = M_T^{-1} Y_T$, where $Y_T$ denotes the shares received by the $t$ participants.
\begin{claim} For any $T \subseteq [n]$ of size $t$, we have
\[
\Pr[\det(M_T) = 0] \le \frac{d}{|\mathbb{F}|}.
\]
\end{claim}
\begin{proof} (of the Claim) Viewing the coefficients $c_e$ as the indeterminates, $\det(M_T)$ is a polynomial in $\mathbb{F}[\{c_e : e \in E(G)\}]$.
Note that there are $t$ vertex-disjoint paths from inputs to $T$. Setting the variables along these $t$ vertex-disjoint paths to $1$, and leaving all variables zero, $\det(M_T)$ would evaluate to $\pm 1$. Thus, we claim the polynomial $\det(M_T)$ is nonzero.
Observe that the polynomial $\det(M_T)$ has total degree $\le d$, where $d$ is the depth of the circuit. By Schwartz-Zippel Lemma, we have
$
\Pr[\det(M_T) = 0] \le \frac{d}{|\mathbb{F}|}.
$
\end{proof}
Taking a union bound over all $T \subseteq [n]$ of size $t$, we have the desired conclusion.
\end{proof}
\begin{lemma}
\label{lem:zero_info}
With probability at least $1 - \frac{d{n \choose t-1}}{|\mathbb{F}|}$, any $t-1$ participants get zero information about the secret.
\end{lemma}
\begin{proof}
Let $M_{T, \{2,3,\ldots,t\}}$ denote the $|T| \times (t-1)$ matrix indexed by rows $T$ and columns $2, 3, \ldots, t$, where $T \subseteq [n]$. For any $T \subseteq [n]$ of size $t-1$, we claim
\[
\Pr[\det M_{T, \{2,3,\ldots,t\}} = 0] \le \frac{d}{|\mathbb{F}|}.
\]
Viewing the coefficients $c_e$ as indeterminates over $\mathbb{F}$, $\det M_{T, \{2,3,\ldots,t\}}$ is a polynomial in $\{c_e : e \in E(G)\}$ of degree at most $d$. Since $G$ is a superconcentrator, there exist $t-1$ vertex-disjoint path connecting $x_2, \ldots, x_t$ and $y_i$, $i \in T$. Setting the variables $c_e$ on these $t-1$ paths to 1, and leaving all other variables 0, $\det M_{T, \{2,3,\ldots,t\}}$ would evaluate $\pm 1$. Thus, we claim polynomial $\det M_{T, \{2,3,\ldots,t\}}$ is nonzero. The claim follows from Schwartz-Zipple Lemma.
Taking a union bound over all $T \subseteq [n]$ of size $t-1$, we know with probability at least $1 - \frac{d{n \choose t-1}}{|\mathbb{F}|}$, $\det M_{T, \{2,3,\ldots,t\}} \not= 0$ for all $T$.
Consider any $t-1$ participants indexed by $T$, who receive the following vector in the reconstruction phrase
\begin{eqnarray*}
y_T & = & M_{T, [t]} \begin{pmatrix}
s \\
r_2 \\
\vdots \\
r_t
\end{pmatrix} \\
& = &
\begin{pmatrix}
M_{T,1}, & M_{T, \{2, \ldots, t\}}
\end{pmatrix}
\begin{pmatrix}
s \\
R
\end{pmatrix} \\
& = &
M_{T, 1}s + M_{T, \{2, \ldots, t\}}R,
\end{eqnarray*}
where $R = \begin{pmatrix}
r_2 \\
\vdots \\
r_t
\end{pmatrix}$. Since $M_{T, \{2, \ldots, t\}}$ is of full rank, we know $M_{T, \{2, \ldots, t\}}R$ is uniformly distributed in $\mathbb{F}^{t-1}$ when $R \in \mathbb{F}^{t-1}$ is uniformly distributed. Thus $M_{T, 1}s + M_{T, \{2, \ldots, t\}}R$ is uniformly distributed. Therefore, $t-1$ participants get zero information about the secret.
\end{proof}
Note that in the proof the Lemma \ref{lem:recover} and Lemma \ref{lem:zero_info}, only a weaker condition is required (compared to that of superconcentrators):
\begin{itemize}
\item For any subset of outputs $T \subseteq [n]$ of size $t$, there are $t$ vertex-disjoint paths connecting inputs and $T$.
\item For any subset of outputs $T \subseteq [n]$ of size $t-1$, there are $t-1$ vertex-disjoint paths connecting inputs $\{x_2, x_3, \ldots, x_t\}$ and $T$.
\end{itemize}
These conditions coincide with the conditions in Theorem \ref{thm:graph_properities_main}.
What we need is actually weaker than superconcentrator. In fact, a \emph{concentrator} (Definition \ref{def:concentrator}) would suffice. For example, take a reversed $(n, t-1)$-concentrator; add an extra input node $s$, and connect $s$ directly to all the $n$ outputs. As such, the aforementioned two conditions will be satisfied. Therefore, upper bounds on the size of concentrator would imply circuit upper bound for threshold SS (over large finite field).
\section{Unbalanced superconcentrators}
Let $\mathrm{SC}_d(m, n)$ denote the size of the smallest depth-$d$ superconcentrator with $m$ inputs and $n$ outputs.
For secret sharing, we need \emph{unbalanced} superconcentrators, where the number of inputs is the threshold value $t$, and the number of outputs is the number of participants $n$.
From Table \ref{table:sc_bounds}, we know there exists a linear-size $(n, n)$-superconcentrator of depth $O(\alpha(n))$. By removing some inputs (and the incident edges), we get $O(n)$-size $(m, n)$-superconcentroator of depth $O(\alpha(n))$, for any $m \le n$. Size $O(n)$ is clearly optimal (up to a multiplicative constant), for we need at least $n$ edges incident to $n$ outputs. The question is, given $m, n$, can we achieve better depth than $O(\alpha(n))$?
\begin{definition} [Partial superconcentrator \cite{DDPW83}] An $(m, n)$-network is a $(p, q)$-partial superconcentrator if for any inputs $S \subseteq [m]$ and outputs $T \subseteq [n]$ with $|S| = |T| \in [q, p]$, there exist $|S| - q$ vertex-disjoint paths connecting $S$ and $T$.
\end{definition}
Let $\mathrm{SC}_d(m, n, p, q)$ denote the minimal size of an $(m, n)$-network of depth at most $d$ which is a $(p, q)$-partial superconcentartor.
\subsection{Depth 2}
In this subsection, we construct unbalanced superconcentrators of depth 2, which are used as building blocks for higher depth.
\begin{lemma}
\label{lem:depth2_partial_sc}
For any $r$, we have
\[
\mathrm{SC}_2(n, m, \frac{n}{r}, \frac{2}{3} \cdot \frac{n}{r}) = O(m \log m).
\]
\end{lemma}
\begin{proof} As illustrated by Figure \ref{figure:sc_depth2}, we have $n$ inputs, $m$ outputs, and a middle layer with $\frac{4}{3} \cdot \frac{n}{r}$ vertices. The construction consists of two layers:
\begin{itemize}
\item (top layer) $(n, \frac{4}{3} \cdot \frac{n}{r}, \frac{n}{r})$-concentrator.
\item (bottom layer) reversed $(m, \frac{4}{3} \cdot \frac{n}{r}, \frac{n}{r})$-concentrator.
\end{itemize}
\begin{figure}[h]
\centering
\includegraphics[scale=0.4]{sc_depth2.png}
\caption{construction of depth-2 superconcentrator}
\label{figure:sc_depth2}
\end{figure}
Consider $S \subseteq [n]$ and $T \subseteq [m]$ of size $\frac{2}{3} \cdot \frac{n}{r} + \Delta$, where $0 \le \Delta \le \frac{1}{3} \cdot \frac{n}{r}$. By the definition of $(n, \frac{4}{3} \cdot \frac{n}{r}, \frac{n}{r})$-concentrator, we know $S$ is connected to $|S|$ vertices in the middle layer, denoted by $S'$, and $T$ is connected to $|T|$ vertices in the middle layer, denoted by $T'$. We have
\[
|S' \cap T'| \ge |S'| + |T'| - \frac{4}{3} \cdot \frac{n}{r} = 2 \Delta.
\]
Thus, $S$ and $T$ are connected by $2 \Delta$ vertex-disjoint paths. (In fact, $\Delta$ vertex-disjoint paths suffice.) So, we conclude the $(n, m)$-network is a $(\frac{n}{r}, \frac{2}{3} \cdot \frac{n}{r})$-partial superconcentrator.
\end{proof}
By taking the union of $O(\log n)$ parital superconcentrators, we can prove the following upper bound on depth-2 superconcentrator.
\begin{lemma}
\label{lem:sc_depth2_size}
For any $n \le m$, we have
\[
\mathrm{SC}_2(n, m) = O(m \log m \log n).
\]
\end{lemma}
\begin{proof} Letting $r = 1, \frac{3}{2}, \left(\frac{3}{2}\right)^2, \ldots, \left(\frac{3}{2}\right)^\ell$, where $\ell = \log_{\frac{3}{2}}n - 1$, we get $(n, \frac{n}{1.5})$, $(\frac{n}{1.5}, \frac{n}{1.5^2})$, $\ldots$, $(\frac{n}{1.5^{\ell-1}}, \frac{n}{1.5^\ell})$-partial superconcentrators, where each is of size $O(m \log m)$ by Lemma \ref{lem:depth2_partial_sc}.
Putting $\ell$ partial superconcentrators together (and merging their inputs and outputs), where $\ell = O(\log n)$, we get an $(n, m)$-superconcentrator of size $O(m \log m \log n)$.
\end{proof}
When $m \ge n^{2+\Omega(1)}$, we prove there exists depth-2 $(m, n)$-superconcentrator of linear size.
\begin{lemma}
\label{lem:sc_depth2_linear_size}
For any $\epsilon > 0$, if $m \ge n^{2+\epsilon}$,
\[
\mathrm{SC}_2(m, n) = O\left(\frac{m}{\epsilon}\right).
\]
\end{lemma}
\begin{proof}
Construct an $(n, m)$-network of depth 2 as illustrated by Figure \ref{figure:sc_depth2_linear}. In the middle, put $\frac{m}{r}$ vertices; the top layer is a depth-1 $(n, \frac{m}{r})$-superconcentrator, i.e., a complete graph; the bottom layer is a reversed $(m, \frac{m}{r}, \frac{m}{r^{1+\epsilon}})$-concentrator, where $\frac{m}{r^{1+\epsilon}} = n$, that is, $r = (\frac{m}{n})^{\frac{1}{1+\epsilon}}$.
\begin{figure}[h]
\centering
\includegraphics[scale=0.6]{d3_improved.png}
\caption{construction of linear-size depth-2 superconcentrator}
\label{figure:sc_depth2_linear}
\end{figure}
Let us verify the construction is indeed an $(m, n)$-superconcentrator. For any subset of outputs $Y$ of size $|Y| \le n$, $Y$ is connected to $|Y|$ vertices in the middle layer by the definition of $(m, \frac{m}{r}, n)$-concentrator. These $|Y|$ vertices in the middle layer are connected to any arbitrarily chosen $|Y|$ inputs, by the definition of complete graph. So the $(m, n)$-network is an $(m, n)$-superconcentrator.
Now we estimate the size of the network. The complete graph is of size
\begin{eqnarray*}
n \cdot \frac{m}{r} & = & nm \left(\frac{n}{m}\right)^{\frac{1}{1+\epsilon}} \\
& = & m \cdot \left(\frac{n^{2 + \epsilon}}{m}\right)^{\frac{1}{1+\epsilon}}\\
& \le & m,
\end{eqnarray*}
when $m \ge n^{2 + \epsilon}$. By Lemma \ref{lem:linear_concentrator}, the $(m, \frac{m}{r}, \frac{m}{r^{1+\epsilon}})$-concentrator is of size
\[
O\left(m \frac{\log(r^{1+\epsilon})}{\log(r^\epsilon)}\right) = O\left(\frac{m}{\epsilon}\right).
\]
In total, the size is at most $O\left(\frac{m}{\epsilon}\right) + m = O\left(\frac{m}{\epsilon}\right)$.
\end{proof}
\subsection{Depth 3}
When $m \ge n (\log n)^{2 + \Omega(1)}$, we prove there exists depth-3 $(m, n)$-superconcentrator of linear size.
\begin{lemma}
\label{lem:d3_linear_sc}
For any $\epsilon > 0$, if $m \ge n (\log n)^{2 + \epsilon}$,
\[
\mathrm{SC}_3(m, n) = O\left( \frac{m}{\epsilon} \right).
\]
\end{lemma}
\begin{proof}
When $m \ge n^3$, by Lemma \ref{lem:sc_depth2_linear_size}, we have
\[
\mathrm{SC}_3(m, n) \le \mathrm{SC}_2(m, n) \le O(m).
\]
Assume $m < n^3$ from now on.
\begin{figure}[h]
\centering
\includegraphics[scale=0.5]{d3_linear_sc.png}
\caption{construction of linear-size depth-3 superconcentrator}
\label{figure:sc_depth3_linear}
\end{figure}
We construct an $(n, m)$-network consisting of two parts as illustrated by Figure \ref{figure:sc_depth3_linear}. The top is a depth-2 $(n, \frac{m}{r})$-superconcentrator; the bottom is a reversed $\left(m, \frac{m}{r}, \frac{m}{r^{1+\epsilon/2}}\right)$-concentrator, where $\frac{m}{r^{1+\epsilon/2}} = n$, that is,
\[
r = \left( \frac{m}{n} \right)^{\frac{1}{1 + \epsilon/2}}.
\]
Let us verify the construction is an $(n, m)$-superconcentrator. Consider any subset of inputs $X \subseteq [n]$ and any subset of outputs $Y \subseteq [m]$, where $|X| = |Y|$. By the definition of $\left(m, \frac{m}{r}, n\right)$-concentrator, there is a matching between $Y$ and some $|Y|$ vertices in the second last layer, denoted by $Z$; by the definition of $(n, \frac{m}{r})$-superconcentrator, there are $|X|$ vertex-disjoint paths connecting $X$ and $Z$. Thus, there are $|X|$ vertex-disjoint paths connecting $X$ and $Y$.
We estimate the size of the $(n, m)$-network. By Lemma \ref{lem:sc_depth2_size}, the size of the depth-2 $(n, \frac{m}{r})$-superconcentrator is
\begin{eqnarray*}
O\left(\frac{m}{r} \cdot \log \frac{m}{r} \cdot \log n \right) & \le & O\left(\frac{m}{r} \cdot (\log n)^2\right) \\
& = & O\left(m \cdot \frac{(\log n)^2}{(\frac{m}{n})^{\frac{1}{1 + \epsilon/2}}}\right) \\
& \le & O(m),
\end{eqnarray*}
where the first step is because $\log \frac{m}{r} \le \log m \le 3 \log n$, and the last step holds because $\frac{m}{n} \ge (\log n)^{2 + \epsilon}$, which implies that $(\frac{m}{n})^{\frac{1}{1 + \epsilon/2}} \ge (\log n)^2$. By Lemma \ref{lem:linear_concentrator}, the $(m, \frac{m}{r}, \frac{m}{r^{1+\epsilon/2}})$-concentrator is of size
\[
O\left(m \frac{\log(r^{1+\epsilon/2})}{\log(r^{\epsilon/2})}\right) = O\left(\frac{m}{\epsilon}\right).
\]
In total, the size is at most $O\left(\frac{m}{\epsilon}\right) + m = O\left(\frac{m}{\epsilon}\right)$.
\end{proof}
\subsection{Higher depth}
As we have shown, when $m \ge n^{2 + \Omega(1)}$, depth 2 is enough to achieve linear size; when $m \ge n (\log n)^{2 + \Omega(1)}$, depth 3 is enough; when $m$ is ``slightly larger'' than $n$, we would need higher depth.
In this subsection, we will prove for any $m \ge n$, depth $\alpha(m, n)+O(1)$ is enough, where $\alpha(m, n)$ is the two-parameter version of the inverse Ackermann function.
\begin{lemma}
\label{lem:depth_d_sc_size}
For depth $d \ge 3$,
\[
\mathrm{SC}_d(m, n) = O(m \lambda_d(n)).
\]
\end{lemma}
\begin{proof}
If $m \ge n^{2.5}$, by Lemma \ref{lem:sc_depth2_linear_size}, we have
\[
\mathrm{SC}_d(m, n) \le \mathrm{SC}_2(m, n) = O(m).
\]
If $m \le n^{2.5}$, we have
$
\lambda_d(m) \le \lambda_d(n^{2.5}).
$
When $d = 3$, $\lambda_d(n^{2.5}) = O(\log\log n^{2.5}) = O (\log \log n) = O(\lambda_3(n))$. When $d \ge 4$, we have
\begin{eqnarray*}
\lambda_d(n^{2.5}) & = & \min \{i : \lambda_{d-2}^{(i)}(n^{2.5}) \le 1 \} \\
& = & \lambda_d(\lambda_{d-2}(n^{2.5})) + 1 \\
& \le & \lambda_d(\lceil 2.5 \log n \rceil) + 1 \\
& \le & \lambda_d(n) + 1 \\
& = & O(\lambda_d(n)).
\end{eqnarray*}
So, when $m \le n^{2.5}$, we always have $\lambda_d(m) \le O(\lambda_d(n))$.
From Table \ref{table:sc_bounds}, we know there exist depth-$d$ $(m, m)$-superconcentrator of size $O(m \lambda_d(m))$.
Note that, by removing $m-n$ outputs and their incident edges, we are left with an $(m, n)$-superconcentrator. So we have
$
\mathrm{SC}_d(m, n) \le \mathrm{SC}_d(m, m) \le O(m \lambda_d(m)) \le O(m \lambda_d(n)).
$
\end{proof}
\begin{theorem}
\label{thm:general_d_linear_sc}
For depth $d \ge 3$, if $m \ge n \lambda_d^{1 + \epsilon}(n)$ for some $\epsilon > 0$, then
\[
S_{d+1}(m, n) = O\left(\frac{m}{\epsilon}\right).
\]
\end{theorem}
\begin{proof} Construct a depth-$(d+1)$ $(n, m)$-network as follows: put $\frac{m}{r}$ vertices on the second last layer; the first $d$ layers is an $(n, \frac{m}{r})$-superconcentrator; the last layer is a reversed $\left(m, \frac{m}{r}, \frac{m}{r^{1+\epsilon}}\right)$-concentrator, where $\frac{m}{r^{1+\epsilon}} = n$, i.e.,
\[
r = \left( \frac{m}{n} \right)^{\frac{1}{1 + \epsilon}}.
\]
We verify the $(n, m)$-network is an $(n, m)$-superconcentrator. Consider any subset of inputs $X \subseteq [n]$ and subset of outputs $Y \subseteq [m]$ of equal size. By the definition of $(m, \frac{m}{r}, n)$-concentrator, $Y$ is connected to $|Y|$ vertices on the second last layer (by disjoint edges), denoted by $Z$; by the definition of $(n, \frac{m}{r})$-superconcentrator, $X$ and $Z$ are connected by $|X|$ vertex-disjoint paths. Therefore, there are $|X| = |Y|$ vertex-disjoint paths connecting $X$ and $Y$.
We estimate the size of the $(n, m)$-network. By Lemma \ref{lem:depth_d_sc_size}, the size of the depth-$d$ $(n, \frac{m}{r})$-superconcentrator is of size
\begin{eqnarray*}
O\left(\frac{m}{r} \cdot \lambda_d(n)\right) & = & O\left( m \cdot \frac{\lambda_d(n)}{\left(\frac{m}{n}\right)^{\frac{1}{1 + \epsilon}}} \right) \\
& \le & O(m),
\end{eqnarray*}
where the last step is because $\frac{m}{n} \ge \lambda_d(n)^{1+\epsilon}$. By Lemma \ref{lem:linear_concentrator}, the $(m, \frac{m}{r}, \frac{m}{r^{1+\epsilon}})$-concentrator is of size
\[
O\left(m \frac{\log(r^{1+\epsilon})}{\log(r^\epsilon)}\right) = O\left(\frac{m}{\epsilon}\right).
\]
In total, the size is at most $O\left(\frac{m}{\epsilon}\right) + m = O\left(\frac{m}{\epsilon}\right)$.
\end{proof}
\begin{corollary} For any $m \ge n$, if $d \ge \alpha(m, n)+3$, we have
\[
\mathrm{SC}_d(m, n) = O(m).
\]
\end{corollary}
\begin{proof}
\textbf{Case 1:} $m \ge 128n$. By the definition of $\alpha(m, n)$, we have $\frac{m}{n} \ge \lambda_{\alpha(m, n)}(n)$. By Proposition \ref{prop:alpha_well_defined}, we have
$
\frac{m}{n} \ge \lambda_{\alpha(m,n)+2}^2(n).
$
By Theorem \ref{thm:general_d_linear_sc}, we conclude
$
\mathrm{SC}_{\alpha(m,n)+3}(m, n) = O(m).
$
\textbf{Case 2:} $m < 128n$. If $\alpha(m, n) = 1$, we have $m \ge n \lfloor\sqrt{n} \rfloor$. By Lemma \ref{lem:d3_linear_sc}, we know $\mathrm{SC}_4(m, n) \le \mathrm{SC}_3(m, n) = O(m)$. If $\alpha(m, n) = 2$, we have $m \ge n \log n \ge n (2\log^* n)^2$. By Theorem \ref{thm:general_d_linear_sc}, $\mathrm{SC}_5(m, n) = O(m)$.
From now on, we assume $\alpha(m, n) \ge 3$. By the definition of $\alpha(m, n)$, we have $\lambda_{\alpha(m, n)}(n) \le 4$. By Lemma \ref{lem:depth_d_sc_size}, we have
\[
\mathrm{SC}_{\alpha(m,n)}(m, n) = O(m \lambda_{\alpha(m, n)}(n)) = O(m).
\]
\end{proof}
Combining the construction of linear-size superconcentrator and the random linear SS scheme, we conclude, if $n \ge t^{2 + \Omega(1)}$, depth 2 is enough for a linear-size arithmetic circuit to compute the shares of a $(n, t)$-threshold SS scheme; if $n \ge t (\log t)^{1 + \Omega(1)}$, depth 3 is enough; generally, depth $\alpha(m, n) + O(1)$ is enough.
\section{Conclusion}
In this paper, we study the circuit complexity of threshold SS. We prove any unrestricted arithmetic circuit computing the shares of a threshold SS scheme must satisfy some connection properties. On the other hand, any graph satisfying these connection properties (that are weaker than that of superconcentators) can be turned into an arithmetic circuit (which computes the shares of a threshold SS scheme), assuming the underlying field is large enough. Therefore, for large finite fields, we have characterized the circuit complexity of threshold SS in terms of graph-theoretic properties.
We (non-explicitly) construct unbalanced $(t, n)$-superconcentrators in linear size and depth $O(\alpha(t, n))$, where $\alpha(t, n)$ is the two-parameter version of the inverse Ackermann function. Combining with our previous results, it implies that threshold SS schemes can be realized by linear size arithmetic circuits in almost constant depth.
It would be interesting to make the construction work for small fields, e.g., $\mathbb{F}_2$, and/or to make the construction explicit. Another open problem is to prove lower bounds for bounded-depth \emph{concentrators}, which would imply circuit lower bounds for threshold SS.
| {'timestamp': '2023-02-10T02:07:58', 'yymm': '2302', 'arxiv_id': '2302.04482', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04482'} | arxiv |
\section{Introduction}
Multi-task representation learning~\cite{caruana1997multitask} is an important problem which aims to learn a common low-dimensional representation from multiple related tasks. Representation learning has received extensive attention in both empirical applications~\cite{ando2005framework,bengio2013representation,li2014joint} and theoretical study~\cite{maurer2016benefit,du2020few,tripuraneni2021provable}.
Recently, an emerging number of works~\cite{yang2020impact,yang2022nearly,hu2021near,cella2022multi} investigate representation learning for sequential decision making, and show that if all tasks share a joint low-rank representation, then by leveraging such a joint representation,
it is possible to learn faster than treating each task independently.
Despite the accomplishments of these works, they mainly focus on the regret minimization setting, where the performance is measured by the cumulative reward gap between the optimal option and the actually chosen options.
However, in real-world applications where obtaining a sample is expensive and time-consuming, e.g., clinical trails~\cite{zhang2012multi},
it is often desirable to identify the optimal option using as few samples as possible, i.e., we face the \emph{pure exploration} scenario rather than regret minimization.
Moreover, in many decision-making applications, we often need to tackle multiple related tasks, e.g., treatment planning for different diseases~\cite{bragman2018uncertainty} and content optimization for multiple websites~\cite{agarwal2009explore}, and there
usually exists a common representation among these tasks, e.g., the features of drugs and the representations of website items. Thus, we desire to exploit the shared representation among tasks to expedite learning.
For example, in clinical treatment planning, we want to identify the optimal treatment for multiple diseases, and there exists a joint representation of treatments. In this case, since conducting a clinical trial and collecting a sample is time-consuming, we desire to make use of the shared representation and reduce the number of samples required. \looseness=-1
Motivated by the above fact, in this paper, we study representation learning for multi-task pure exploration in sequential decision making. Following prior works~\cite{yang2020impact,yang2022nearly,hu2021near}, we consider the linear bandit setting, which is one of the most popular settings in sequential decision making and has various applications such as clinical trials and recommendation systems.
Specifically, we investigate two pure exploration problems, i.e., representation learning for best arm identification in linear bandits ($\textup{RepBAI-LB}$) and best policy identification in contextual linear bandits ($\textup{RepBPI-CLB}$).
In $\textup{RepBAI-LB}$, an agent is given a confidence parameter $\delta$, an arm set $\mathcal{X}:=\{\boldsymbol{x}_1,\dots,\boldsymbol{x}_n\} \subseteq \mathbb{R}^{d}$ and $M$ tasks. For each task $m \in [M]$, the expected reward of each arm $\boldsymbol{x} \in \mathcal{X}$ is generated by $\boldsymbol{x}^\top \boldsymbol{\theta}_m$, where $\boldsymbol{\theta}_m \in \mathbb{R}^{d}$ is an underlying reward parameter. There exists an unknown global feature extractor $\boldsymbol{B} \in \mathbb{R}^{d \times k}$ and an underlying prediction parameter $\boldsymbol{w}_m$ such that $\boldsymbol{\theta}_m=\boldsymbol{B} \boldsymbol{w}_m$
for any $m \in [M]$, where $M \gg d \gg k$. We can understand the problem as that all tasks share a joint representation $\boldsymbol{f}(\boldsymbol{x}):= \boldsymbol{B}^\top \boldsymbol{x}$ for arms, where the dimension of $\boldsymbol{f}(\boldsymbol{x})$ is much smaller than that of $\boldsymbol{x}$. The agent sequentially selects arms and tasks to sample, and observes noisy rewards. The goal of the agent is to identify the best arm with the maximum expected reward for each task with confidence $1-\delta$, using as few samples as possible.
The $\textup{RepBPI-CLB}$ problem is an extension of $\textup{RepBAI-LB}$ to environments with random and varying contexts.
In $\textup{RepBPI-CLB}$, there are a context space $\mathcal{S}$, an action space $\mathcal{A}$, a known feature mapping $\boldsymbol{\phi}:\mathcal{S} \times \mathcal{A} \mapsto \mathbb{R}^d$ and an \emph{unknown} context distribution $\mathcal{D}$.
For each task $m \in [M]$, the expected reward of each context-action pair $(s,a) \in \mathcal{S} \times \mathcal{A}$ is generated by $\boldsymbol{\phi}(s,a)^\top \boldsymbol{\theta}_m$, where $\boldsymbol{\theta}_m=\boldsymbol{B} \boldsymbol{w}_m$.
We can similarly interpret the problem as that all tasks share a low-dimensional context-action representation $\boldsymbol{B}^\top \boldsymbol{\phi}(s,a) \in \mathbb{R}^k$. At each timestep, the agent first observes a context drawn from $\mathcal{D}$, and chooses an action and a task to sample, and then observes a random reward.
Given a confidence parameter $\delta$ and an accuracy parameter $\varepsilon$, the agent aims to identify an $\varepsilon$-optimal policy (i.e., a mapping $\mathcal{S} \mapsto \mathcal{A}$ that gives suboptimality within $\varepsilon$)
for each task with confidence $1-\delta$, while minimizing the number of samples used.
In contrast to existing representation learning works~\cite{yang2020impact,yang2022nearly,hu2021near,cella2022multi}, we focus on the pure exploration scenario and face several unique challenges:
(i) The sample complexity minimization objective requires us to plan an optimal sample allocation for recovering the low-rank representation, in order to save samples to the highest degree.
(ii) Unlike prior works which either assume that the arm set is an ellipsoid/sphere~\cite{yang2020impact,yang2022nearly} or are computationally inefficient~\cite{hu2021near}, we allow an arbitrary arm set that spans $\mathbb{R}^d$, which poses challenges on how to efficiently schedule samples according to the shapes of arms.
(iii) Different from prior works~\cite{huang2015efficient,li2022instance}, we do not assume prior knowledge of the context distribution. This imposes additional difficulties in sample allocation planning and estimator construction.
%
To handle these challenges, we design computationally and sample efficient algorithms, which effectively estimate the context distribution and employ the experimental design approaches to plan samples.
We summarize our contributions in this paper as follows.
\begin{itemize}
\item We formulate the problems of multi-task representation learning for best arm identification in linear bandits ($\textup{RepBAI-LB}$) and best policy identification in contextual linear bandits ($\textup{RepBPI-CLB}$). To the best of our knowledge, this is the first work to study representation learning in the multi-task pure exploration scenario.
\item For $\textup{RepBAI-LB}$, we propose an efficient algorithm $\mathtt{DouExpDes}$ equipped with \emph{double experimental designs}. The first design optimally schedules samples to learn the joint representation according to arm shapes, and the second design minimizes the estimation error for rewards using low-dimensional representations.
Furthermore, we establish a sample complexity guarantee $\tilde{O}(\frac{Mk}{\Delta_{\min}^2})$, which shows superiority over the baseline result $\tilde{O}(\frac{Md}{\Delta_{\min}^2})$ (i.e., solving each task independently). Here $\Delta_{\min}$ denotes the minimum reward gap.
\item For $\textup{RepBPI-CLB}$, we develop $\mathtt{C \hyphen DouExpDes}$, an algorithm which efficiently estimates the context distribution and conducts double experimental designs under the estimated context distribution to learn the global representation. A sample complexity result $\tilde{O}(\frac{Mk^2}{\varepsilon^2})$ is also provided for $\mathtt{C \hyphen DouExpDes}$, which significantly outperforms the baseline result $\tilde{O}(\frac{Md^2}{\varepsilon^2})$, and demonstrates the power of representation learning.
\end{itemize}
\section{Related Work}
In this section, we introduce two lines of related works, and defer a more complete literature review to Appendix~\ref{apx:related_work}. \looseness=-1
\textbf{Representation Learning.}
The study of representation learning has been initiated and developed in the supervised learning setting, e.g., \cite{baxter2000model,ando2005framework,maurer2016benefit,du2020few,tripuraneni2021provable}. Recently, representation learning for sequential decision making has attracted extensive attention.
\citet{yang2020impact,yang2022nearly} study representation learning for linear bandits with the regret minimization objective, where they assume that the arm set is an ellipsoid or sphere. \citet{hu2021near} relax this assumption and allow arbitrary arm sets, but their algorithms based on a multi-task joint least-square estimator are computationally inefficient. \citet{cella2022meta,cella2022multi} design algorithms which do not need to know the dimension of the underlying representation.
Different from the above works which consider regret minimization, we study representation learning for (contextual) linear bandits with the pure exploration objective, which brings unique challenges on how to optimally allocate samples to learn the feature extractor, and motivates us to design algorithms building upon double experimental designs. \looseness=-1
\textbf{Pure Exploration in (Contextual) Linear Bandits.}
Most existing linear bandit works focus on regret minimization, e.g.,~\cite{dani2008stochastic,chu2011contextual,abbasi2011improved}. Recently, there has been a surge of interests in the pure exploration objective for (contextual) linear bandits.
For linear bandits, \citet{soare2014best} firstly apply the experimental design approach to distinguish the optimal arm, and establish sample complexity that heavily depends on the minimum reward gap.
\citet{tao2018best} design a novel randomized estimator for the underlying reward parameter, and achieve tighter sample complexity which depends on the reward gaps of the best $d$ arms.
\citet{fiez2019sequential} provide the first near-optimal sample complexity upper and lower bounds for best arm identification in linear bandits.
For contextual linear bandits, \citet{zanette2021design} develop a non-adaptive policy to collect data, from which a near-optimal policy can be computed. \citet{li2022instance} build instance-optimal sample complexity for best policy identification in contextual linear bandits, with prior knowledge of the context distribution. By contrast, our work studies a multi-task setting where tasks share a common representation,
and does not assume any prior knowledge of the context distribution.
\section{Problem Formulation}
In this section, we present the formal problem formulations of $\textup{RepBAI-LB}$ and $\textup{RepBPI-CLB}$. Before describing the formulations, we first introduce some useful notations.
\textbf{Notations.}
We use bold lower-case letters to denote vectors and bold upper-case letters to denote matrices.
For any matrix $\boldsymbol{A}$, $\|\boldsymbol{A}\|$ denotes the spectral norm of $\boldsymbol{A}$, and $\sigma_{\min}(\boldsymbol{A})$ denotes the minimum singular value of $\boldsymbol{A}$. For any positive semi-definite matrix $\boldsymbol{A} \in \mathbb{R}^{d' \times d'}$ and vector $\boldsymbol{x} \in \mathbb{R}^{d'}$, $\|\boldsymbol{x}\|_{\boldsymbol{A}}:=\sqrt{\boldsymbol{x}^\top \boldsymbol{A} \boldsymbol{x}}$. We use $\textup{polylog}(\cdot)$ to denote a polylogarithmic factor in given parameters, and $\tilde{O}(\cdot)$ to denote an expression that hides polylogarithmic factors in all problem parameters except $\delta$ and $\varepsilon$.
\textbf{Representation Learning for Best Arm Identification in Linear Bandits ($\textup{RepBAI-LB}$).}
An agent is given a set of arms $\mathcal{X}:=\{\boldsymbol{x}_1,\dots,\boldsymbol{x}_n\} \subseteq \mathbb{R}^d$ and $M$ best arm identification tasks. Without loss of generality, we assume that $\mathcal{X}$ spans $\mathbb{R}^d$, as done in many prior works~\cite{fiez2019sequential,katz2020empirical,degenne2020gamification}. For any $\boldsymbol{x} \in \mathcal{X}$, $\|\boldsymbol{x}\|\leq L_{x}$ for some constant $L_{x}$. For each task $m \in [M]$, the expected reward of each arm $\boldsymbol{x} \in \mathcal{X}$ is $\boldsymbol{x}^\top \boldsymbol{\theta}_m$, where $\boldsymbol{\theta}_m \in \mathbb{R}^d$ is an unknown reward parameter. Among all tasks, there exists a common underlying feature extractor $\boldsymbol{B} \in \mathbb{R}^{d \times k}$, which satisfies that for each task $m \in [M]$, $\boldsymbol{\theta}_m=\boldsymbol{B} \boldsymbol{w}_m$. Here $\boldsymbol{B}$ has orthonormal columns, $\boldsymbol{w}_m \in \mathbb{R}^k$ is an unknown prediction parameter, and $M \gg d \gg k$. For any $m \in [M]$, $\|\boldsymbol{w}_m\|\leq L_{w}$ for some constant $L_{w}$.
At each timestep $t$, the agent chooses an arm $\boldsymbol{x} \in \mathcal{X}$ and a task $m \in [M]$, to sample arm $\boldsymbol{x}$ in task $m$. Then, she observes a random reward $r_t=\boldsymbol{x}^\top \boldsymbol{\theta}_m+\eta_t=\boldsymbol{x}^\top \boldsymbol{B} \boldsymbol{w}_m+ \eta_t$, where $\eta_t$ is an independent, zero-mean and sub-Gaussian noise. For simplicity of analysis, we assume that $\mathbb{E}[\eta_t^2]=1$, which can be easily relaxed by using a more carefully-designed estimator in our algorithm.
Given a confidence parameter $\delta \in (0,1)$, the agent aims to identify the best arms $\boldsymbol{x}^{*}_m:=\operatornamewithlimits{argmax}_{\boldsymbol{x} \in \mathcal{X}} \boldsymbol{x}^\top \boldsymbol{\theta}_m$ for all tasks $m \in [M]$ with probability at least $1-\delta$, using as few samples as possible. We define sample complexity as the total number of samples used over all tasks, which is the performance metric considered in our paper.
To efficiently learn the underlying low-dimensional representation,
we make the following standard assumptions.
\begin{assumption}[Diverse Tasks] \label{assumption:diverse_task}
We assume that $\sigma_{\min}(\frac{1}{M} \sum_{m=1}^{M} \boldsymbol{w}_m \boldsymbol{w}_m^\top) = \Omega(\frac{1}{k})$.
\end{assumption}
This assumption indicates that the prediction parameters $\boldsymbol{w}_1,\dots,\boldsymbol{w}_{M}$ are uniformly spread out in all directions of $\mathbb{R}^k$, which was also assumed in~\cite{du2020few,tripuraneni2021provable,yang2020impact}, and is necessary for recovering the feature extractor $\boldsymbol{B}$.
For any distribution $\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}$ and $\boldsymbol{B} \in \mathbb{R}^{d \times k}$, let $\boldsymbol{A}(\boldsymbol{\lambda}, \boldsymbol{B}):=\sum_{i=1}^{n} \lambda(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}$.
For any task $m \in [M]$, let
\begin{align*}
\boldsymbol{\lambda}^*_m := & \operatornamewithlimits{argmin}_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{x} \in \mathcal{X} \setminus \{\boldsymbol{x}^{*}_{m}\}} \frac{\| \boldsymbol{B}^\top (\boldsymbol{x}^{*}_{m} - \boldsymbol{x}) \|^2_{\boldsymbol{A}(\boldsymbol{\lambda}, \boldsymbol{B})^{-1}} }{ ((\boldsymbol{x}^{*}_{m} - \boldsymbol{x})^\top \boldsymbol{\theta}_m)^2 } .
\end{align*}
Here $\boldsymbol{\lambda}^*_m$ denotes the optimal sample allocation that minimizes prediction error of arms (i.e., the solution of G-optimal design~\cite{pukelsheim2006optimal}) under the underlying low-dimensional representation.
\begin{assumption}[Eigenvalue of G-optimal Design Matrix] \label{assumption:lambda^*_B_x_x_B_invertible}
For any task $m \in [M]$, $\sigma_{\min}(\boldsymbol{A}(\boldsymbol{\lambda}^*_m, \boldsymbol{B})) \geq \omega$ for some constant $\omega>0$.
\end{assumption}
This assumption implies that the covariance matrix $\boldsymbol{A}(\boldsymbol{\lambda}^*_m, \boldsymbol{B})$ under the optimal sample allocation is invertible, which is necessary for estimating $\boldsymbol{w}_m$. \looseness=-1
\textbf{Representation Learning for Best Policy Identification in Contextual Linear Bandits ($\textup{RepBPI-CLB}$).}
In this problem, there are a context space $\mathcal{S}$, an action space $\mathcal{A}$, a feature mapping $\boldsymbol{\phi}(\cdot,\cdot):\mathcal{S}\times\mathcal{A} \mapsto \mathbb{R}^d$ and an \emph{unknown} context distribution $\mathcal{D} \in \triangle_{\mathcal{S}}$. For any $(s,a) \in \mathcal{S} \times \mathcal{A}$, $\|\boldsymbol{\phi}(s,a)\|\leq L_{\phi}$ for some constant $L_{\phi}$.
An agent needs to solve $M$ best policy identification tasks. For each task $m \in [M]$, the expected reward of each context-action pair $(s,a) \in \mathcal{S} \times \mathcal{A}$ is $\boldsymbol{\phi}(s,a)^\top \boldsymbol{\theta}_m$, where $\boldsymbol{\theta}_m \in \mathbb{R}^d$ is an unknown reward parameter. Similar to $\textup{RepBAI-LB}$, there exists a global feature extractor $\boldsymbol{B} \in \mathbb{R}^{d \times k}$ with orthonormal columns, such that for each task $m \in [M]$, $\boldsymbol{\theta}_m=\boldsymbol{B} \boldsymbol{w}_m$. Here $\boldsymbol{w}_m \in \mathbb{R}^k$ is an unknown prediction parameter, $\|\boldsymbol{w}_m\|\leq L_{w}$ for any $m \in [M]$, and $M \gg d \gg k$.
At each timestep $t$, the agent first observes a random context $s_t$, which is i.i.d. drawn from $\mathcal{D}$. Then, she selects an action $a_t \in \mathcal{A}$ and a task $m \in [M]$, to sample action $a_t$ in context $s_t$ under task $m$. After sampling, she observes a random reward $r_t=\boldsymbol{\phi}(s_t,a_t)^\top \boldsymbol{\theta}_m+\eta_t=\boldsymbol{\phi}(s_t,a_t)^\top \boldsymbol{B} \boldsymbol{w}_m+ \eta_t$, where $\eta_t$ is an independent, zero-mean and $1$-sub-Gaussian noise.
We define a policy $\pi$ as a mapping from $\mathcal{S}$ to $\mathcal{A}$. For each task $m \in [M]$, we say a policy $\hat{\pi}_m$ is $\varepsilon$-optimal if\looseness=-1
\begin{align*}
\mathbb{E}_{s \sim \mathcal{D}} \mbr{ \max_{a \in \mathcal{A}} \sbr{\boldsymbol{\phi}(s,a) - \boldsymbol{\phi}(s,\hat{\pi}_m(s) }^\top \boldsymbol{\theta}_m } \leq \varepsilon .
\end{align*}
Given a confidence parameter $\delta \in (0,1)$ and an accuracy parameter $\varepsilon>0$, the goal of the agent is to identify an $\varepsilon$-optimal policy $\hat{\pi}_m$ for each task $m \in [M]$ with probability at least $1-\delta$, and minimize the number of samples used, i.e., sample complexity.
We also make two standard assumptions for $\textup{RepBPI-CLB}$: Assumption~\ref{assumption:diverse_task} and the following assumption on the context distribution and context-action features.
\begin{assumption}\label{assumption:bpi_rho_E_D_is_finite}
There exists some $\boldsymbol{\lambda} \in \triangle_{\mathcal{A}}$ such that
$$
\sigma_{\min}\sbr{\sum_{a \in \mathcal{A}} \lambda(a) \mathbb{E}_{s \sim \mathcal{D}}\mbr{ \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top }} \geq \nu
\vspace*{-1em}
$$
\end{assumption}
for some constant $\nu>0$.
Assumption~\ref{assumption:bpi_rho_E_D_is_finite} manifests that there exists at least one sample allocation, under which the expected covariance matrix with respect to random contexts is invertible. This assumption enables one to reveal the feature extractor $\boldsymbol{B}$, despite stochastic and varying contexts.
Note that Assumption~\ref{assumption:bpi_rho_E_D_is_finite} only assumes the existence of a feasible sample allocation, rather than the knowledge of this sample allocation.
It is worth mentioning that in this work, we do not assume that we can sample arbitrary vectors in an ellipsoid/sphere as in \cite{yang2020impact,yang2022nearly}, or assume that each arm (action) has zero mean and identity covariance as in \cite{tripuraneni2021provable}. In contrast, we allow arbitrary shapes of arms (actions), and efficiently allocate samples according to their different shapes. Moreover, we do not assume prior knowledge of the context distribution as in \cite{huang2015efficient,li2022instance}.
Instead, we design an effective scheme to estimate the context distribution, and carefully bound the estimation error in our analysis.
Below we will introduce our algorithms and results. We defer all our proofs to Appendix due to space limit.
\section{Representation Learning for Best Arm Identification in Linear Bandits}
In this section, we design a computationally efficient algorithm $\mathtt{DouExpDes}$ for $\textup{RepBAI-LB}$, which performs double delicate experimental designs to recover the feature extractor and distinguish the best arms using low-rank representations. Furthermore, we provide sample complexity guarantees that mainly depend on the underlying low dimension.
To better describe our algorithm, we first introduce the notion of \emph{experimental design}.
Experimental design is an important problem in statistics~\cite{pukelsheim2006optimal}. Consider a set of feature vectors and an unknown linear regression parameter. Sampling each feature vector will produce a noisy feedback of the inner-product of this feature vector and the unknown parameter.
Experimental design investigates how to schedule samples to maximize the statistical power of estimating the unknown parameter.
In our algorithm, we mainly use two popular types of experimental design, i.e., \emph{E-optimal design}, which minimizes the spectral norm of the inverse of sample covariance matrix, and \emph{G-optimal design}, which minimizes the maximum prediction error for feature vectors. \looseness=-1
\subsection{Algorithm $\mathtt{DouExpDes}$}
Now we present our algorithm $\mathtt{DouExpDes}$, whose pseudo-code is provided in Algorithm~\ref{alg:repbailb}. $\mathtt{DouExpDes}$ is a phased elimination algorithm, which first conducts the E-optimal design to optimally schedule samples for learning the feature extractor $\boldsymbol{B}$, and then performs the G-optimal design with low-dimensional representations to eliminate suboptimal arms.
$\mathtt{DouExpDes}$ uses a \emph{rounding procedure} $\mathtt{ROUND}$~\cite{allen2017near,fiez2019sequential}, which transforms a given continuous sample allocation (design) into a discrete sample sequence and maintains important properties (e.g., E-optimality and G-optimality) of the design. $\mathtt{ROUND}(\{(\boldsymbol{q}_i,\boldsymbol{Q}_i)\}_{i=1}^{n'}, \boldsymbol{\lambda}, \zeta, N)$ takes $n'$ arm-matrix pairs $(\boldsymbol{q}_1,\boldsymbol{Q}_1),\dots,(\boldsymbol{q}_{n'},\boldsymbol{Q}_{n'}) \in \mathcal{X} \times \mathbb{R}^{{d'} \times {d'}}$, a distribution $\boldsymbol{\lambda} \in \triangle_{\{\boldsymbol{q}_1,\dots,\boldsymbol{q}_{n'}\}}$, a rounding approximation parameter $\zeta>0$, and the number of samples $N$ such that $N \geq \frac{180d'}{\zeta^2}$ as inputs. It will return a sample sequence $\boldsymbol{s}_1, \dots, \boldsymbol{s}_N \in \mathcal{X}$, which correspond to feature matrices $\boldsymbol{S}_1, \dots, \boldsymbol{S}_N \in \{\mathcal{Q}_1,\dots,\mathcal{Q}_{n'}\}$, and $\sum_{j=1}^N \boldsymbol{S}_j$ has similar properties as the covariance matrix of the inputted design $N \sum_{i=1}^{n'} \lambda(\boldsymbol{q}_i) \boldsymbol{Q}_i$ (see Appendix~\ref{apx:rounding_procedure} for more details).
The procedure of $\mathtt{DouExpDes}$ is as follows. At the beginning, $\mathtt{DouExpDes}$ performs the E-optimal design with raw representations, to plan an optimal sample allocation $\boldsymbol{\lambda}^E$ for the purpose of recovering the feature extractor $\boldsymbol{B}$ (Line~\ref{line:bai_E_optimal_design}).
Then, $\mathtt{DouExpDes}$ calls $\mathtt{ROUND}$ to convert the E-optimal sample allocation $\boldsymbol{\lambda}^E$ into a discrete sample batch $\bar{\boldsymbol{x}}_1,\dots,\bar{\boldsymbol{x}}_p$, which satisfies that
$$
\bigg\| \Big(\sum_{j=1}^p \bar{\boldsymbol{x}}_j \bar{\boldsymbol{x}}_j^\top \Big)^{-1} \bigg\| \leq (1+\zeta) \bigg\| \Big(p \sum_{i=1}^n \lambda^E(\boldsymbol{x}_i) \boldsymbol{x}_i \boldsymbol{x}_i^\top \Big)^{-1} \bigg\| .
$$
Next, $\mathtt{DouExpDes}$ enters multiple phases, and maintains a candidate arm set $\hat{\mathcal{X}}_{t,m}$ for each task.
The specific value of $T_t$ in Line~\ref{line:bai_T_t} is presented in Eq.~\eqref{eq:value_T_t} of Appendix~\ref{apx:bai_feature_recover}
\begin{algorithm}[t]
\caption{$\mathtt{DouExpDes}$ (Double Experimental Design)} \label{alg:repbailb}
\begin{algorithmic}[1]
\STATE {\bfseries Input:} $\mathcal{X}$, $\delta$, rounding procedure $\mathtt{ROUND}$, rounding approximation parameter $\zeta:=\frac{1}{10}$, and the size of sample batch $p:= \frac{180d}{\zeta^2}$.
\STATE Let $\boldsymbol{\lambda}^{E}$ and $\rho^{E}$ be the optimal solution and the optimal value of the E-optimal design optimization:
$$
\min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \Big\| \big( \sum_{i=1}^n \lambda(\boldsymbol{x}_i) \boldsymbol{x}_i \boldsymbol{x}_i^\top \big)^{-1} \Big\|
\vspace*{-0.5em}
$$\label{line:bai_E_optimal_design}\\
\STATE $\bar{\boldsymbol{x}}_1,\dots,\bar{\boldsymbol{x}}_p \leftarrow \mathtt{ROUND}(\{(\boldsymbol{x}_i, \boldsymbol{x}_i \boldsymbol{x}_i^\top)\}_{i=1}^{n}, \boldsymbol{\lambda}^{E}, \zeta, p)$ \label{line:bai_E_optimal_round}
\STATE $\hat{\mathcal{X}}_{1,m} \leftarrow \mathcal{X}$ for any $m \in [M]$. $\delta_t \leftarrow \frac{\delta}{2 t^2}$ for any $t \geq 1$\;
\FOR{phase $t=1,2,\dots$}
\STATE $T_t \leftarrow \lceil \frac{c_1 \sbr{1+\zeta}^3 (\rho^E)^2 k^4 L_{x}^4 L_{w}^4}{M} \max\{2^{2t},\ \frac{L_x^4}{\omega^2}\}\cdot$\\$ \textup{polylog}(\zeta,\rho^E,p,k,L_{x},L_{w},\frac{1}{\delta_t}, \frac{1}{\omega}) \rceil$, where $c_1$ is an absolute constant \label{line:bai_T_t}
\STATE $\hat{\boldsymbol{B}}_t \leftarrow \mathtt{FeatRecover}(T_t, \{\bar{\boldsymbol{x}}_i\}_{i \in [p]})$\;
\STATE $\{\hat{\mathcal{X}}_{t+1,m}\}_{m \in [M]} \leftarrow$\\$ \mathtt{EliLowRep} (t, \mathcal{X}, \{\hat{\mathcal{X}}_{t,m}\}_{m \in [M]}, \delta_t, \mathtt{ROUND}, \zeta, \hat{\boldsymbol{B}}_t)$
\IF{$|\hat{\mathcal{X}}_{t+1,m}|=1$, $\forall m \in [M]$}
\STATE {\bfseries return} $\hat{\mathcal{X}}_{t+1,m}$ for all tasks $m \in [M]$\;
\ENDIF
\ENDFOR
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[t]
\caption{$\mathtt{FeatRecover}(T, \{\bar{\boldsymbol{x}}_i\}_{i \in [p]})$} \label{alg:feat_recover}
\begin{algorithmic}[1]
\FOR{task $m \in [M]$} \label{line:bai_stage2_sample_start}
\FOR{round $j \in [T]$ }
\FOR{arm $i \in [p]$}
\STATE Sample $\bar{\boldsymbol{x}}_i$, and observe random reward $\alpha_{m,j,i}$\; \label{line:bai_stage2_sample}
\ENDFOR
\STATE $\tilde{\boldsymbol{\theta}}_{m,j} \leftarrow (\sum_{i=1}^{p} \bar{\boldsymbol{x}}_i \bar{\boldsymbol{x}}_i^\top)^{-1} \sum_{i=1}^{p} \bar{\boldsymbol{x}}_i \alpha_{m,j,i}$
\ENDFOR
\ENDFOR \label{line:bai_stage2_sample_end}
\STATE $\boldsymbol{Z} \leftarrow \frac{1}{M T} \sum_{m=1}^{M} \sum_{j=1}^{T} \tilde{\boldsymbol{\theta}}_{m,j} (\tilde{\boldsymbol{\theta}}_{m,j})^\top - (\sum_{i=1}^{p} \bar{\boldsymbol{x}}_i \bar{\boldsymbol{x}}_i^\top)^{-1} $ \label{line:bai_Z_t}\;
\STATE Perform SVD decomposition on $\boldsymbol{Z}$, and let $\hat{\boldsymbol{B}}$ be the top-$k$ left singular vectors of $\boldsymbol{Z}$. {\bfseries return} $\hat{\boldsymbol{B}}$ \label{line:svd}\;
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[t!]
\caption{$\mathtt{EliLowRep}(t, \mathcal{X}\!,\! \{\hat{\mathcal{X}}_{m}\}_{\! m \in [M]}, \delta'\!, \mathtt{ROUND},\! \zeta,\! \hat{\boldsymbol{B}})$} \label{alg:elim_low_rep}
\begin{algorithmic}[1]
\FOR{task $m \in [M]$}
\STATE Let $\boldsymbol{\lambda}^{G}_{m}$ and $\rho^{G}_{m}$ be the optimal solution and the optimal value of the G-optimal design optimization:
$$
\operatornamewithlimits{argmin}_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{x},\boldsymbol{x}' \in \hat{\mathcal{X}}_{m}} \nbr{ \hat{\boldsymbol{B}}^\top (\boldsymbol{x}-\boldsymbol{x}') }^2_{\boldsymbol{A}(\boldsymbol{\lambda},\hat{\boldsymbol{B}})^{-1}}
\vspace*{-0.5em}
$$ \label{line:bai_G_optimal_design}\\
\STATE $N_{m} \leftarrow \lceil \max \{ 32 (1+\zeta) 2^{2t} \rho^{G}_{m} \log (\frac{4n^2 M}{\delta'}),$ $\frac{180 k}{\zeta^2} \} \rceil$\;
\STATE $\boldsymbol{z}_{m,1},\dots,\boldsymbol{z}_{m,N_{m}} \leftarrow$\\$ \mathtt{ROUND}(\{(\boldsymbol{x}_i, \hat{\boldsymbol{B}}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}})\}_{i=1}^{n}, \boldsymbol{\lambda}^{G}_{m}, \zeta, N_{m})$ \label{line:bai_stage3_round}\;
\STATE Sample the arms $\boldsymbol{z}_{m,1},\dots,\boldsymbol{z}_{m,N_{m}} \in \mathcal{X}$, and observe random rewards $r_{m,1}, \dots, r_{m,N_{m}}$\; \label{line:bai_stage3_sample}
\STATE Let $\tilde{\boldsymbol{z}}_{m,j} := \hat{\boldsymbol{B}}^\top \boldsymbol{z}_{m,j}$ for any $j \in [N_{m}]$
\STATE $\hat{\boldsymbol{w}}_{m} \leftarrow ( \sum_{j=1}^{N_{m}} \tilde{\boldsymbol{z}}_{m,j} \tilde{\boldsymbol{z}}_{m,j}^\top )^{-1} \sum_{j=1}^{N_{m}} \tilde{\boldsymbol{z}}_{m,j} r_{m,j}$ \label{line:bai_est_theta}\;
\STATE $\hat{\boldsymbol{\theta}}_{m} \leftarrow \hat{\boldsymbol{B}} \hat{\boldsymbol{w}}_{m}$ \label{line:bai_est_w}\;
\STATE $\hat{\mathcal{X}}'_{m} \leftarrow \hat{\mathcal{X}}_{m} \setminus \{ \boldsymbol{x} \in \hat{\mathcal{X}}_{m} \ | \ \exists \boldsymbol{x}' \in \hat{\mathcal{X}}_{m}: (\boldsymbol{x}'-\boldsymbol{x})^\top \hat{\boldsymbol{\theta}}_{m} > 2^{-t} \}$ \label{line:bai_elimination}\;
\ENDFOR
\STATE {\bfseries return} $\{\hat{\mathcal{X}}'_{m}\}_{m \in [M]}$
\end{algorithmic}
\end{algorithm}
In each phase $t$,
$\mathtt{DouExpDes}$ first calls subroutine $\mathtt{FeatRecover}$ to recover the feature extractor $\boldsymbol{B}$. In $\mathtt{FeatRecover}$ (Algorithm~\ref{alg:feat_recover}), we repeatedly sample $\bar{\boldsymbol{x}}_1,\dots,\bar{\boldsymbol{x}}_p$ in all tasks, and construct an estimator $\boldsymbol{Z}$ for $\frac{1}{M} \sum_{i=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top$, which contains the information of underlying reward parameters (Line~\ref{line:bai_Z_t}). Then, we perform SVD on $\boldsymbol{Z}$ and obtain the estimated feature extractor $\hat{\boldsymbol{B}}$ (Line~\ref{line:svd}).
Then, $\mathtt{DouExpDes}$ calls subroutine $\mathtt{EliLowRep}$ to eliminate suboptimal arms using low-dimensional representations.
In $\mathtt{EliLowRep}$ (Algorithm~\ref{alg:elim_low_rep}), we conduct the G-optimal design with the reduced-dimensional representations $\hat{\boldsymbol{B}}^\top \boldsymbol{x}$, and obtain sample allocation $\boldsymbol{\lambda}^{G}_{m}$ for each task (Line~\ref{line:bai_G_optimal_design}). We further use $\mathtt{ROUND}$ to transform $\boldsymbol{\lambda}^{G}_{m}$ into a sample sequence $\boldsymbol{z}_{m,1},\dots,\boldsymbol{z}_{m,N_{m}}$, which satisfies that
\begin{align*}
& \max_{\boldsymbol{x}, \boldsymbol{x}' \in \hat{\mathcal{X}}_{m}} \nbr{\boldsymbol{x}-\boldsymbol{x}'}^2_{\sbr{\sum_{j=1}^{N_{m}} \hat{\boldsymbol{B}}^\top \boldsymbol{z}_{m,j} \boldsymbol{z}_{m,j}^\top \hat{\boldsymbol{B}}}^{-1}}
\\
\leq & (1+\zeta) \max_{\boldsymbol{x}, \boldsymbol{x}' \in \hat{\mathcal{X}}_{m}} \nbr{\boldsymbol{x}-\boldsymbol{x}'}^2_{\sbr{N_{m} \sum_{i=1}^{n} \lambda^{G}_{m}(\boldsymbol{x}_i) \hat{\boldsymbol{B}}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}}^{-1}} .
\end{align*}
After sampling this sequence, we build estimators $\hat{\boldsymbol{w}}_{t,m}$ and $\hat{\boldsymbol{\theta}}_{t,m}$ for the underlying prediction parameter $\boldsymbol{w}_m$ and reward parameter $\boldsymbol{\theta}_m$, respectively (Lines~\ref{line:bai_est_theta}-\ref{line:bai_est_w}). Then, we discard the arms that show large gaps to the estimated optimal arm for each task (Line~\ref{line:bai_elimination}).
\subsection{Theoretical Performance of $\mathtt{DouExpDes}$}
In this subsection, we provide sample complexity guarantees for $\mathtt{DouExpDes}$.
%
To formally present our sample complexity,
we first revisit existing results for conventional single-task best arm identification in linear bandits (BAI-LB).
For a single-task BAI-LB instance with arm set $\mathcal{X} \in \mathbb{R}^d$ and underlying reward parameter $\boldsymbol{\theta} \in \mathbb{R}^{d}$, the instance-dependent hardness is defined as~\cite{fiez2019sequential}
\begin{align*}
\rho^{S}(\mathcal{X}, \boldsymbol{\theta}) := & \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{x} \in \mathcal{X} \setminus \{\boldsymbol{x}^{*}\}} \frac{\| \boldsymbol{x}^{*} - \boldsymbol{x} \|^2_{\sbr{\sum_{i=1}^{n} \lambda(\boldsymbol{x}_i) \boldsymbol{x}_i \boldsymbol{x}_i^\top }^{-1}} }{ ((\boldsymbol{x}^{*} - \boldsymbol{x})^\top \boldsymbol{\theta})^2 } ,
\end{align*}
and the best known sample complexity result is $\tilde{O}(\rho^{S}(\mathcal{X}, \boldsymbol{\theta}) \log(\frac{1}{\delta}))=\tilde{O}(\frac{d}{(\Delta^{S}_{\min})^2} \log(\frac{1}{\delta}))$~\cite{fiez2019sequential}.
Here $\boldsymbol{x}^{*}:=\operatornamewithlimits{argmax}_{\boldsymbol{x} \in \mathcal{X}} \boldsymbol{x}^\top \boldsymbol{\theta}$ denotes the best arm, and $\Delta^{S}_{\min}:=\min_{\boldsymbol{x} \in \mathcal{X} \setminus \{\boldsymbol{x}^{*}\}}(\boldsymbol{x}^{*} - \boldsymbol{x})^\top \boldsymbol{\theta}$ refers to the minimum reward gap.
It can be seen that a naive algorithm for RepBAI-LB is to run an existing single-task BAI-LB algorithm~\cite{fiez2019sequential,katz2020empirical} to solve $M$ tasks independently. Then, the sample complexity of such naive algorithm is
\begin{align}
\!\!\!\! \tilde{O} \! \sbr{ \sum_{m=1}^{M} \rho^{S}(\mathcal{X}, \boldsymbol{\theta}_m) \log\sbr{ \frac{1}{\delta} } \!} \!\!=\! \tilde{O}\sbr{\! \frac{Md}{\Delta_{\min}^2} \log\sbr{ \frac{1}{\delta} } \!} \!, \label{eq:bai_naive_sample_complexity}
\end{align}
where $\Delta_{\min}:=\min_{m \in [M], \boldsymbol{x} \in \mathcal{X} \setminus \{\boldsymbol{x}^{*}_m\}}(\boldsymbol{x}^{*}_m - \boldsymbol{x})^\top \boldsymbol{\theta}_m$ denotes the minimum reward gap among all tasks. In the following, we take Eq.~\eqref{eq:bai_naive_sample_complexity} as the baseline to demonstrate the power of representation learning.
Now we state the sample complexity for $\mathtt{DouExpDes}$.
\begin{theorem} \label{thm:bai_ub}
With probability at least $1-\delta$, algorithm $\mathtt{DouExpDes}$ returns the best arms $\boldsymbol{x}^{*}_{m}$ for all tasks $m \in [M]$, and the number of samples used is bounded by
\begin{align*}
\tilde{O} \bigg( & \sum_{m=1}^{M} \! \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \! \max_{\boldsymbol{x} \in \mathcal{X} \setminus \{\boldsymbol{x}^{*}_{m}\}} \!\!\!\!\! \frac{\| \boldsymbol{B}^\top (\boldsymbol{x}^{*}_{m} - \boldsymbol{x}) \|^2_{\boldsymbol{A}(\boldsymbol{\lambda},\boldsymbol{B})^{-1}} }{ ((\boldsymbol{x}^{*}_{m} - \boldsymbol{x})^\top \boldsymbol{\theta}_m)^2 } \! \log\Big(\frac{1}{\delta}\Big)
\\&
+ (\rho^E)^2 d k^4 L_{x}^2 L_{w}^2 D \log^4 \Big(\frac{1}{\delta}\Big) \bigg)
\\
= & \ \tilde{O} \bigg( \frac{M k}{\Delta_{\min}^2} \log\Big(\frac{1}{\delta}\Big) + (\rho^E)^2 d k^4 L_{x}^2 L_{w}^2 D \log^4 \Big(\frac{1}{\delta}\Big) \bigg) ,
\end{align*}
where
$D:=\max\{ \frac{1}{\Delta_{\min}^2} ,\ \frac{L_{x}^4}{\omega^2} \}$.
\end{theorem}
\textbf{Remark 1.} In the above theorem, the first term, $\sum_{m=1}^{M} \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{x} \in \mathcal{X} \setminus \{\boldsymbol{x}^{*}_{m}\}} \frac{\| \boldsymbol{B}^\top (\boldsymbol{x}^{*}_{m} - \boldsymbol{x}) \|^2_{\boldsymbol{A}(\boldsymbol{\lambda},\boldsymbol{B})^{-1}} }{ ((\boldsymbol{x}^{*}_{m} - \boldsymbol{x})^\top \boldsymbol{\theta}_m)^2 }=O(\frac{M k}{\Delta_{\min}^2})$, is the instance-dependent hardness of $M$ $k$-dimensional linear bandit problems with arm set $\tilde{\mathcal{X}}:=\{\boldsymbol{B}^\top \boldsymbol{x}: \boldsymbol{x} \in \mathcal{X}\} \subseteq \mathbb{R}^k$ and underlying reward parameters $\boldsymbol{w}_1,\dots,\boldsymbol{w}_{M} \in \mathbb{R}^k$. This term only depends on the reduced dimension $k$, instead of $d$.
In other words, it is an essential price that is needed for solving $M$ low-dimensional tasks, even if one knows the feature extractor $\boldsymbol{B}$.
The second term $(\rho^E)^2 d k^4 L_{x}^2 L_{w}^2 D$, which depends on the raw dimension $d$, is a cost paid for learning the feature extractor. Note that since this term does not contain $M$, the cost for learning the underlying features is paid only once, rather than for all tasks. \looseness=-1
When $M \gg d \gg k$, the first term dominates the bound. This indicates that algorithm $\mathtt{DouExpDes}$ effectively learns the low-dimensional representation, and exploits the intrinsic problem structure to
reduce the sample complexity from $\tilde{O}(\frac{M d}{\Delta_{\min}^2} \log (\frac{1}{\delta}))$ (i.e., learning each task independently)
to only $\tilde{O}(\frac{M k}{\Delta_{\min}^2} \log (\frac{1}{\delta}))$. Our result corroborates the benefits of representation learning for multi-task pure exploration.
\textbf{Analytical Novelty.}
We highlight several novelties in the analysis of Theorem~\ref{thm:bai_ub} as follows. (i) We develop a delicate concentration inequality for $\|\boldsymbol{Z} - \frac{1}{M} \sum_{i=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top\|$, by bounding $\|(\sum_{i=1}^{p} \bar{\boldsymbol{x}}_i \bar{\boldsymbol{x}}_i^{\top})^{-1}\|$ via the E-optimality of the sample batch $\bar{\boldsymbol{x}}_1,\dots,\bar{\boldsymbol{x}}_p$ and applying the matrix Bernstern inequality with truncated noises. Then, we employ the Davis-Kahan sin $\theta$ Theorem~\cite{bhatia2013matrix} to bound the estimation error of $\hat{\boldsymbol{B}}$
incurred from the SVD decomposition on $\boldsymbol{Z}$.
(ii) Furthermore, we decompose the prediction error $\boldsymbol{x}^\top (\hat{\boldsymbol{\theta}}_{m}-\boldsymbol{\theta}_m)$ into three parts, i.e., the sampling variance and bias for learning $\hat{\boldsymbol{w}}_{m}$ with estimated representation $\hat{\boldsymbol{B}}^\top \boldsymbol{x}$, and the estimation error of $\hat{\boldsymbol{B}}$. (iii) To interpret our sample complexity by the essential instance-dependent hardness with true representation $\boldsymbol{B}^\top \boldsymbol{x}$, we establish a connection between the actual effective dimension $\| \boldsymbol{B}^\top \boldsymbol{x} \|^2_{\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} }$ and our estimated effective dimension $\| \hat{\boldsymbol{B}}^\top \boldsymbol{x} \|^2_{\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}} }^{-1} }$.
\vspace*{-0.5em}
\section{Representation Learning for Best Policy Identification in Contextual Linear Bandits}
In this section, we turn to contextual linear bandits.
Different from prior contextual linear bandit works, e.g.,~\cite{huang2015efficient,li2022instance}, here we do not assume any knowledge of context distribution.
As a result, our $\textup{RepBPI-CLB}$ problem faces several unique challenges: (i) how to plan an efficient sample allocation for recovering the feature extractor in advance under an \emph{unknown} context distribution, and (ii) how to construct an estimator for the feature extractor with a partially observed context space.
We propose algorithm $\mathtt{C \hyphen DouExpDes}$, which first (i) efficiently estimates the context distribution and conducts experimental designs under the estimated context distribution, and then (ii) builds a delicate estimator for the feature extractor using instantaneous contexts.
Moreover, we also establish a sample complexity guarantee for $\mathtt{C \hyphen DouExpDes}$, which mainly depends on the low dimension of the common representation among tasks.
\vspace*{-0.5em}
\subsection{Algorithm $\mathtt{C \hyphen DouExpDes}$}
\begin{algorithm}[t]
\caption{$\mathtt{C \hyphen DouExpDes}$ (Contextual Double Experimental Design)} \label{alg:repbpiclb}
\begin{algorithmic}[1]
\STATE {\bfseries Input:} $\delta$, $\varepsilon$, $\boldsymbol{\phi}(\cdot,\cdot)$, regularization parameter $\gamma \geq 1$, rounding procedure $\mathtt{ROUND}$, rounding approximation parameter $\zeta:=\frac{1}{10}$, and the size of sample batch $p:= \lceil \frac{c_2 (1+\zeta)^2 L_{\phi}^4}{\nu^2} \textup{polylog}(\zeta,M,d,k,L_{\phi},L_{w},\gamma,\frac{1}{\nu},\frac{1}{\delta},\frac{1}{\varepsilon}) \rceil$, where $c_2$ is an absolute constant. \label{line:bpi_value_p}
\STATE $T_0 \leftarrow \lceil \frac{32^2 (1+\zeta)^2 L_{\phi}^4}{\nu^2} \log^2 (\frac{20d |\mathcal{A}|}{\delta}) \rceil$. $\hat{\mathcal{D}} \leftarrow \emptyset$
\FOR{$\tau \in [T_0]$}
\STATE \hspace*{-0.4em} Observe context $s_{\tau}$, and randomly sample an action \label{line:bpi_estimate_context_dis}\;
\STATE $\hat{\mathcal{D}} \leftarrow \hat{\mathcal{D}} \cup \{s_{\tau}\}$\;
\ENDFOR
\STATE Let $\boldsymbol{\lambda}^{E}_{\hat{\mathcal{D}}}$ and $\rho^{E}_{\hat{\mathcal{D}}}$ be the optimal solution and the optimal value of the E-optimal design optimization:
$$
\min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{A}}} \Big\| \big( \sum_{a \in \mathcal{A}} \lambda(a) \mathbb{E}_{s \sim \hat{\mathcal{D}}}\mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} \big)^{-1} \Big\|
\vspace*{-1em}
$$ \label{line:bpi_E_optimal_design}\\
\STATE $\{\bar{a}_i\}_{i \in [p]} \!\! \leftarrow \!\! \mathtt{ROUND}(\{(a, \mathbb{E}_{\! s \sim \hat{\mathcal{D}} \!\!}\mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top})\}_{a \in \mathcal{A}},$\\$ \boldsymbol{\lambda}^{E}_{\hat{\mathcal{D}}}, \zeta, p)$ \label{line:bpi_E_design_round}\;
\STATE $T \leftarrow \lceil \frac{c_3 (1+\zeta)^2 k^4 L_{\phi}^4 L_{w}^4 }{ M \nu^2 \varepsilon^2 } \textup{polylog}(\zeta,d,k,L_{\phi},L_{w},\gamma,\frac{1}{\nu},$\\$\frac{1}{\delta},\frac{1}{\varepsilon}) \rceil$, where $c_3$ is an absolute constant \label{line:bpi_value_T}
\STATE $\hat{\boldsymbol{B}} \leftarrow \mathtt{C \hyphen FeatRecover}(T, \{\bar{a}_i\}_{i \in [p]})$
\STATE $N \leftarrow \lceil \frac{ (k^2 + \gamma k L_{w}^2) }{\varepsilon^2} \log^4 ({\frac{ \gamma k L_{w} }{\varepsilon \delta}} ) \rceil$\;
\STATE $\{\hat{\boldsymbol{\theta}}_{m,N}\}_{m \in [M]} \leftarrow \mathtt{EstLowRep}(N, \gamma, \hat{\boldsymbol{B}})$
\STATE {\bfseries return} $\hat{\pi}_m(\cdot):=\operatornamewithlimits{argmax}_{a \in \mathcal{A}} \boldsymbol{\phi}(\cdot,a)^\top \hat{\boldsymbol{\theta}}_{m,N}$ for all tasks $m \in [M]$ \label{line:bpi_return}
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[t]
\caption{$\mathtt{C \hyphen FeatRecover}(T, \{\bar{a}_i\}_{i \in [p]})$} \label{alg:con_feat_recover}
\begin{algorithmic}[1]
\FOR{task $m \in [M]$} \label{line:bpi_stage2_sample_start}
\FOR{round $j \in [T]$}
\FOR{arm $i \in [p]$}
\STATE Observe context $s_{m,j,i}^{(1)}$, sample action $\bar{a}_i$ in task $m$, and observe reward $\alpha^{(1)}_{m,j,i}$\; \label{line:bpi_stage2_sample1}
\STATE Observe context $s_{m,j,i}^{(2)}$, sample action $\bar{a}_i$ in task $m$, and observe reward $\alpha^{(2)}_{m,j,i}$\; \label{line:bpi_stage2_sample2}
\ENDFOR
\STATE Let $\boldsymbol{\phi}^{(\ell)}_{m,j,i}\!:=\!\boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)$, $\forall i \!\in\! [p]$, $\forall \ell \!\in\! \{1,2\}$\;
\STATE $\tilde{\boldsymbol{\theta}}^{(\ell)}_{m,j} \! \leftarrow \!\! ( \sum_{i=1}^{p} \! \boldsymbol{\phi}^{(\ell)}_{m,j,i} {\boldsymbol{\phi}^{(\ell)}_{m,j,i}}^{\!\!\!\!\top} \!)^{-1} \! \sum_{i=1}^{p} \! \boldsymbol{\phi}^{(\ell)}_{m,j,i} \alpha^{(\ell)}_{m,j,i}$, $\forall \ell \in \{1,2\}$\;
\ENDFOR
\ENDFOR \label{line:bpi_stage2_sample_end}
\STATE $\boldsymbol{Z} \leftarrow \frac{1}{M T} \sum_{m=1}^{M} \sum_{j=1}^{T} \tilde{\boldsymbol{\theta}}^{(1)}_{m,j} (\tilde{\boldsymbol{\theta}}^{(2)}_{m,j})^\top$ \label{line:bpi_Z}\;
\STATE Perform SVD decomposition on $\boldsymbol{Z}$, and let $\hat{\boldsymbol{B}}$ be the top-$k$ left singular vectors. {\bfseries return} $\hat{\boldsymbol{B}}$\; \label{line:bpi_svd}
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[t]
\caption{$\mathtt{EstLowRep}(N, \gamma, \hat{\boldsymbol{B}})$} \label{alg:est_low_rep}
\begin{algorithmic}[1]
\STATE $\boldsymbol{\Sigma}_{m,0} \leftarrow \gamma I$ for any $m \in [M]$\;
\FOR{task $m \in [M]$}
\FOR{timestep $t \in [N]$}
\STATE Observe context $s_{m,t}$\; \label{line:bpi_stage3_context}
\STATE $a_{m,t} \leftarrow \operatornamewithlimits{argmax}_{a \in \mathcal{A}} \| \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,t},a) \|_{\boldsymbol{\Sigma}_{m,t-1}^{-1}}$\;
\STATE Sample action $a_{m,t}$, and observe reward $r_{m,t}$\; \label{line:bpi_stage3_sample}
\STATE $\boldsymbol{\Sigma}_{m,t} \leftarrow \boldsymbol{\Sigma}_{m,t-1} +$\\$ \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,t},a_{m,t}) \boldsymbol{\phi}(s_{m,t},a_{m,t})^\top \hat{\boldsymbol{B}}$\;
\STATE $\hat{\boldsymbol{w}}_{m,t} \leftarrow \boldsymbol{\Sigma}_{m,t}^{-1} \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) r_{m,\tau}$ \label{line:bpi_est_w}\;
\STATE $\hat{\boldsymbol{\theta}}_{m,t} \leftarrow \hat{\boldsymbol{B}} \hat{\boldsymbol{w}}_{m,t}$ \label{line:bpi_est_theta}\;
\ENDFOR
\ENDFOR
\STATE {\bfseries return} $\{\hat{\boldsymbol{\theta}}_{m,N}\}_{m \in [M]}$\;
\end{algorithmic}
\end{algorithm}
Algorithm~\ref{alg:repbpiclb} presents the pseudo-code of $\mathtt{C \hyphen DouExpDes}$.
At the beginning, $\mathtt{C \hyphen DouExpDes}$ uses $T_0$ samples to estimate the context distribution $\mathcal{D}$ (Line~\ref{line:bpi_estimate_context_dis}). Then, it performs the E-optimal design under the estimated context distribution $\hat{\mathcal{D}}$, and obtains an efficient sample allocation $\boldsymbol{\lambda}^{E}_{\hat{\mathcal{D}}}$ for the purpose of recovering the feature extractor $\boldsymbol{B}$ (Line~\ref{line:bpi_E_optimal_design}). Further, $\mathtt{C \hyphen DouExpDes}$ calls the rounding procedure $\mathtt{ROUND}$ to transform $\boldsymbol{\lambda}^{E}_{\hat{\mathcal{D}}}$ into a sample batch $\bar{a}_1,\dots,\bar{a}_p$, such tha
\begin{align*}
& \Big\| \big(\sum_{j=1}^p \mathbb{E}_{s \sim \hat{\mathcal{D}}}\mbr{\boldsymbol{\phi}(s,\bar{a}_j) \boldsymbol{\phi}(s,\bar{a}_j)^\top} \big)^{-1} \Big\|
\\
\leq & (1+\zeta) \Big\| \big(p \sum_{a \in \mathcal{A}} \lambda^{E}_{\hat{\mathcal{D}}}(a) \mathbb{E}_{s \sim \hat{\mathcal{D}}}\mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} \big)^{-1} \Big\| .
\end{align*}
The specific values of $p$ and $T$ in Lines~\ref{line:bpi_value_p},~\ref{line:bpi_value_T} are provided in Eq.~\eqref{eq:value_p} of Appendix~\ref{apx:bpi_sample_batch_planning} and Eq.~\eqref{eq:value_T} of Appendix~\ref{apx:bpi_feat_recover}, respectively.\looseness=-1
Next, $\mathtt{C \hyphen DouExpDes}$ runs subroutine $\mathtt{C \hyphen FeatRecover}$ to estimate the feature extractor $\boldsymbol{B}$ using the sample batch $\bar{a}_1,\dots,\bar{a}_p$.
In $\mathtt{C \hyphen FeatRecover}$ (Algorithm~\ref{alg:con_feat_recover}), we repeatedly sample $\bar{a}_1,\dots,\bar{a}_p$ in all tasks with random contexts.
In Lines~\ref{line:bpi_stage2_sample1}-\ref{line:bpi_stage2_sample2}, we sample this batch twice, and the superscripts $(1)$ and $(2)$ denotes the first and second samples, respectively.
After sampling, we carefully establish an estimator $\boldsymbol{Z}$ for the reward parameter related matrix $\frac{1}{M} \sum_{m=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top$, using instantaneous context-action features $\boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_{i})^\top$.
We then perform SVD decomposition on $\boldsymbol{Z}$ to obtain the estimated feature extractor $\hat{\boldsymbol{B}}$ (Lines~\ref{line:bpi_Z}-\ref{line:bpi_svd}).
Then, $\mathtt{C \hyphen DouExpDes}$ calls subroutine $\mathtt{EstLowRep}$, which adapts existing reward-free-exploration algorithm in \cite{zanette2021design} with low-rank representations to estimate $\boldsymbol{\theta}_m$.
In $\mathtt{EstLowRep}$ (Algorithm~\ref{alg:est_low_rep}), we employ the estimated representation $\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)$ to sample the actions with the maximum uncertainty under the observed contexts.
After that, we construct estimators $\hat{\boldsymbol{w}}_{m,t}$ and $\hat{\boldsymbol{\theta}}_{m,t}$ for the prediction parameter $\hat{\boldsymbol{w}}_m$ and reward parameter $\hat{\boldsymbol{\theta}}_m$ (Lines~\ref{line:bpi_est_w}-\ref{line:bpi_est_theta}).
At last, $\mathtt{C \hyphen DouExpDes}$ returns the greedy policy with respect to the estimated reward parameter $\hat{\boldsymbol{\theta}}_{m,N}$ for each task.
\subsection{Theoretical Performance of $\mathtt{C \hyphen DouExpDes}$}
Next, we establish sample complexity guarantees for algorithm $\mathtt{C \hyphen DouExpDes}$. In order to illustrate the advantages of representation learning, we first review existing results for traditional single-task best policy identification in contextual linear bandits (BPI-CLB).
For a single BPI-CLB instance with context-action features $\boldsymbol{\phi}(s,a) \in \mathbb{R}^d$ and reward parameter $\boldsymbol{\theta} \in \mathbb{R}^{d}$, the best known sample complexity is $\tilde{O}(\frac{d^2}{\varepsilon^2}\log(\frac{1}{\delta}))$~\cite{zanette2021design,li2022instance}.
Apparently, if one naively solves the $\textup{RepBPI-CLB}$ problem by running single-task BPI-CLB algorithms to tackle $M$ tasks independently, one will have a sample complexity
\begin{align*}
\vspace*{-0.5em}
\tilde{O}\bigg( \frac{Md^2}{\varepsilon^2} \log \Big(\frac{1}{\delta}\Big) \bigg) ,
\vspace*{-0.5em}
\end{align*}
which heavily depends on the raw dimension $d$ of context-action features.
The goal of representation learning is to leverage the common representation among tasks to alleviate the dependency of dimension and save samples.
Now we present the sample complexity for $\mathtt{C \hyphen DouExpDes}$. \looseness=-1
\begin{theorem} \label{thm:bpi_ub}
With probability at least $1-\delta$, $\mathtt{C \hyphen DouExpDes}$ returns an $\varepsilon$-optimal policy $\hat{\pi}_m$ such that
$
\mathbb{E}_{s \sim \mathcal{D}} [ \max_{a \in \mathcal{A}} (\boldsymbol{\phi}(s,a) - \boldsymbol{\phi}(s,\hat{\pi}_m(s) )^\top \boldsymbol{\theta}_m ] \leq \varepsilon
$
for each task $m \in [M]$, and the number of samples used is
\begin{align*}
\tilde{O} \sbr{ \frac{ M \sbr{k^2 + \gamma k L_{w}^2 } }{\varepsilon^2} + \frac{ k^4 L_{\phi}^8 L_{w}^4 }{ \nu^4 \varepsilon^2 } } .
\end{align*}
\end{theorem}
\vspace*{-1em}
\textbf{Remark 2.} The first term $\frac{ M (k^2 + \gamma k L_{w}^2) }{\varepsilon^2}$ is a cost of identifying optimal policies for $M$ tasks with underlying $k$-dimensional representation $\boldsymbol{B}^\top \boldsymbol{\phi}(s,a)$. The second term $\frac{ k^4 L_{\phi}^8 L_{w}^4 }{ \nu^4 \varepsilon^2 }$ is a price paid for learning global feature extractor $\boldsymbol{B}$ and does not depend on $M$, which indicates that we only need to pay this price once and then enjoy the benefits of dimension reduction for all $M$ tasks.
Theorem~\ref{thm:bpi_ub} shows that when $M \gg \frac{1}{\nu} \gg k$, $\mathtt{C \hyphen DouExpDes}$
performs almost as well as an oracle that knows inherent low-dimensional features $\boldsymbol{B}^\top \boldsymbol{\phi}(s,a)$. This sample complexity significantly outperforms the baseline result $\tilde{O}(\frac{M d^2}{\varepsilon^2})$ (i.e., solving $M$ tasks independently), and demonstrates the power of representation learning.
\textbf{Innovations in Analysis.}
The proof of Theorem~\ref{thm:bpi_ub} has several innovations. (i) We carefully bound the deviation between the estimated context distribution $\hat{\mathcal{D}}$ and the true context distribution $\mathcal{D}$, and utilize the E-optimality of sample batch $\bar{a}_1,\dots,\bar{a}_p$
to bound $\|(\sum_{i=1}^{p} \boldsymbol{\phi}^{(\ell)}_{m,j,i} {\boldsymbol{\phi}^{(\ell)}_{m,j,i}}^\top)^{-1}\|$. (ii) A concentration inequality for $\|\boldsymbol{Z}-\frac{1}{M} \sum_{m=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top\|$ is established, using the bounded $\|(\sum_{i=1}^{p} \boldsymbol{\phi}^{(\ell)}_{m,j,i} {\boldsymbol{\phi}^{(\ell)}_{m,j,i}}^\top)^{-1}\|$ and matrix Bernstern inequality with truncated noises. Furthermore, an estimation error guarantee for $\hat{\boldsymbol{B}}$ is derived by applying the SVD perturbation analysis. (iii) We provide a decomposition of the prediction error $\boldsymbol{\phi}(s,a)^\top (\hat{\boldsymbol{\theta}}_{m,t} - \boldsymbol{\theta}_m)$ into three components, including the variance and bias incurred in the sampling for learning $\hat{\boldsymbol{w}}_{m,t}$, and the estimation error of $\hat{\boldsymbol{B}}$. Then, we bound them via self-normalized concentration inequalities with reduced dimension $k$.
\section{Experiments}
In this section, we present experiments to evaluate the empirical performance of our algorithms.
In our experiments, we set $\delta=0.005$, $d=5$, $k=2$ and $M \in [50,230]$, where $k$ divides $M$. In $\textup{RepBAI-LB}$, $\mathcal{X}$ is the canonical basis of $\mathbb{R}^{d}$.
In $\textup{RepBPI-CLB}$, we set $\varepsilon=0.1$, $|\mathcal{S}|=5$ and $|\mathcal{A}|=5$.
$\mathcal{D}$ is the uniform distribution on $\mathcal{S}$. For any $s \in \mathcal{S}$, $\{\boldsymbol{\phi}(s,a)\}_{a \in \mathcal{A}}$ is the canonical basis of $\mathbb{R}^d$.
In both problems, $\boldsymbol{B}=[I_k;\boldsymbol{0}]$, where $I_k$ denotes the $k \times k$ identity matrix.
$\boldsymbol{w}_1,\dots,\boldsymbol{w}_M$ are divided into $k$ groups, with $\frac{M}{k}$ same members in each group.
The members in the $i$-th group ($i \in [k]$), i.e., $\boldsymbol{w}_{(M/k)\times(i-1)+1},\dots,\boldsymbol{w}_{(M/k)\times i}$, have $1$ in the $i$-th coordinate and $0$ in all other coordinates.
For any $m \in [M]$, $\boldsymbol{\theta}_m=\boldsymbol{B} \boldsymbol{w}_m$. We vary $M$ and perform $50$ independent runs to report the average sample complexity across runs.
\begin{figure}[t]
\centering
\subfigure[$\textup{RepBAI-LB}$] {
\label{fig:bai}
\includegraphics[width=0.45\columnwidth]{fig/BAI.pdf}
}
\subfigure[$\textup{RepBPI-CLB}$] {
\label{fig:bpi}
\includegraphics[width=0.45\columnwidth]{fig/BPI.pdf}
}
\vspace*{-1em}
\caption{Experimental results for $\textup{RepBAI-LB}$ and $\textup{RepBPI-CLB}$. The two figures compare the sample complexities of our algorithms with the naive algorithms which treat each task independently.
}
\label{fig:experiments}
\end{figure}
For $\textup{RepBAI-LB}$, we compare algorithm $\mathtt{DouExpDes}$ with the baseline $\mathtt{IndRAGE}$ which runs the state-of-the-art single-task BAI-LB algorithm $\mathtt{RAGE}$~\cite{fiez2019sequential} to solve $M$ tasks independently.
Figure~\ref{fig:bai} shows the empirical results for $\textup{RepBAI-LB}$. From Figure~\ref{fig:bai}, we can see that $\mathtt{DouExpDes}$ has a better sample complexity than $\mathtt{IndRAGE}$, and as the number of tasks $M$ increases, the sample complexity of $\mathtt{DouExpDes}$ increases at a lower rate than that of $\mathtt{IndRAGE}$. This demonstrates that $\mathtt{DouExpDes}$ effectively utilize the shared representation among tasks to reduce the number of samples needed for multi-task learning.
For $\textup{RepBPI-CLB}$, our algorithm $\mathtt{C \hyphen DouExpDes}$ is compared with the baseline $\mathtt{IndRFLinUCB}$, which tackles $M$ tasks independently by calling the state-of-the-art single-task BPI-CLB algorithm $\mathtt{Reward \hyphen free\ LinUCB}$~\cite{zanette2021design}. As presented in Figure~\ref{fig:bpi}, $\mathtt{C \hyphen DouExpDes}$ achieves a significantly lower sample complexity than $\mathtt{IndRFLinUCB}$. In addition, the slope of the sample complexity curve of $\mathtt{C \hyphen DouExpDes}$ with respect to $M$ is much smaller than that of $\mathtt{IndRFLinUCB}$, which validates that $\mathtt{C \hyphen DouExpDes}$ enjoys a lighter dependency on dimension in multi-task learning. These empirical results match our theoretical bounds, and corroborate the power of representation learning.
\section{Conclusion and Future Work}
In this paper, we investigate representation learning for pure exploration in multi-task (contextual) linear bandits. We propose two efficient algorithms which conduct double experimental designs to optimally allocate samples for learning the low-rank representation. The sample complexities of our algorithms mainly depend on the low dimension of the underlying joint representation among tasks, instead of the raw high dimension. Our theoretical and experimental results demonstrate the benefit of representation learning for pure exploration in multi-task bandits.
There are many interesting directions for further exploration. One direction is to establish lower bounds to validate the optimality of our algorithms. Another direction is to extend this work to more complex (nonlinear) representation settings.
\section{Related Work} \label{apx:related_work}
In this section, we present a full literature review for two lines of related works, i.e., representation learning and pure exploration in (contextual) linear bandit.
\textbf{Representation Learning.}
The study of representation learning has been initiated and developed in the supervised learning setting, e.g., \cite{baxter2000model,ben2003exploiting,ando2005framework,maurer2006bounds,cavallanti2010linear,maurer2016benefit,du2020few,tripuraneni2021provable}. Recently, representation learning for sequential decision making has attracted extensive attention, e.g., ~\cite{yang2020impact,yang2022nearly,hu2021near,cella2022meta,cella2022multi,qin2022non}.
\citet{tripuraneni2021provable} propose a method-of-moments estimator for recovering the feature extractor, and establish error guarantees for transferring the learned representation from past tasks to a new task.
\citet{yang2020impact,yang2022nearly} study representation learning for linear bandit with the regret minimization objective, and assume that the action set at each timestep is an ellipsoid or sphere. \citet{hu2021near} further relax this assumption and allow arbitrary action sets, but their algorithms equipped with a multi-task joint least-square estimator are computationally inefficient. \citet{cella2022meta,cella2022multi} also investigate the problem in \cite{yang2020impact} and propose algorithms which do not need to know the dimension of the underlying representation.
\citet{qin2022non} study representation learning for linear bandit under non-stationary environments, and develop algorithms that learn and transfer non-stationary representations adaptively.
Different from the above works which consider regret minimization, we study representation learning for (contextual) linear bandit with the pure exploration objective, which imposes unique challenges in how to optimally allocate samples to learn the feature extractor, and motivates us to design algorithms building upon double experimental designs.
\textbf{Pure Exploration in (Contextual) Linear Bandit.}
Most linear bandit studies consider regret minimization, e.g.,~\cite{dani2008stochastic,rusmevichientong2010linearly,chu2011contextual,abbasi2011improved}. Recently, there is a surge of interests in pure exploration for (contextual) linear bandit, e.g., \cite{soare2014best,tao2018best,xu2018fully,fiez2019sequential,katz2020empirical,degenne2020gamification,jedra2020optimal,du2021combinatorial,zanette2021design,li2022instance}.
For linear bandit, \citet{soare2014best} firstly apply the G-optimal design to identify the best arm, and provide a sample complexity result that heavily depends on the minimum reward gap.
\citet{tao2018best} design a novel randomized estimator for the underlying reward parameter, and achieve tighter sample complexity which depends on the reward gaps of the best $d$ arms. \citet{du2021combinatorial} further extend the algorithm in \citep{tao2018best} to develop a polynomial-time algorithm for combinatorially large arm sets. \citet{xu2018fully} propose a fully-adaptive algorithm which changes the arm selection strategy at each timestep. \citet{fiez2019sequential} establish the first near-optimal sample complexity upper and lower bounds for best arm identification in linear bandit. \citet{katz2020empirical} further extend the algorithm in \cite{fiez2019sequential} and use empirical processes to avoid an explicit union bound over the number of arms. \citet{degenne2020gamification,jedra2020optimal} develop asymptotically optimal algorithms using the track-and-stop approaches. For contextual linear bandit, \citet{zanette2021design} design a single non-adaptive policy to collect a dataset, from which a near-optimal policy can be computed. \citet{li2022instance} build the first instance-dependent upper and lower bounds for best policy identification in contextual linear bandit, with the prior knowledge of the context distribution. By contrast, our work studies multi-task best arm/policy identification in (contextual) linear bandit with a shared representation among tasks, and does not assume any prior knowledge of the context distribution.
\section{Rounding Procedure} \label{apx:rounding_procedure}
In this section, we introduce the rounding procedure $\mathtt{ROUND}$ in detail.
Let $\mathcal{X}^{+}:=\mathcal{X} \cup \mathcal{A}$ denote the union space of arm set $\mathcal{X}$ and action space $\mathcal{A}$. There are $n$ arms or actions $p_1,\dots,p_n \in \mathcal{X}^{+}$ and $n$ positive semi-definite matrices $\boldsymbol{Q}_1,\dots,\boldsymbol{Q}_n \in \mathbb{S}^{d}_{+}$, where $\boldsymbol{Q}_i$ represents the feature of arm or action $p_i$ for any $i \in [n]$. Denote $\mathcal{P}:=\{p_1,\dots,p_n\}$ and $\mathcal{Q}:=\{\boldsymbol{Q}_1,\dots,\boldsymbol{Q}_n\}$.
The rounding procedure $\mathtt{ROUND}(\{(p_i,\boldsymbol{Q}_i)\}_{i=1}^{n}, \boldsymbol{\lambda}, \zeta, N)$~\cite{allen2017near,fiez2019sequential} takes $n$ arm-matrix or action-matrix pairs $(p_1,\boldsymbol{Q}_1),\dots,(p_n,\boldsymbol{Q}_n) \in \mathcal{X}^{+} \times \mathbb{S}^{d}_{+}$, a distribution $\boldsymbol{\lambda} \in \triangle_{\mathcal{P}}$ (or equivalently, $\boldsymbol{\lambda} \in \triangle_{\mathcal{Q}}$), an approximation parameter $\zeta>0$, and the number of samples $N$ which satisfies that $N \geq \frac{180d}{\zeta^2}$ as inputs.
Roughly speaking, it will find a $N$-length discrete arm or action sequence whose associated feature matrices maintain the similar property (e.g., G-optimality and E-optimality) as the continuous sample allocation $\boldsymbol{\lambda}$.
Formally, $\mathtt{ROUND}(\{(p_i,\boldsymbol{Q}_i)\}_{i=1}^{n}, \lambda, \zeta, N)$ returns a discrete sample sequence $s_1, \dots, s_N \in \mathcal{P}^{N}$ associated with feature matrices $\boldsymbol{S}_1, \dots, \boldsymbol{S}_N \in \mathcal{Q}^{N}$, which satisfy the following properties:
(i) If $\boldsymbol{\lambda}$ is an E-optimal design, i.e., $\boldsymbol{\lambda}$ is the optimal solution of the optimization
$$
\min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{Q}}} \nbr{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{Q}_i) \boldsymbol{Q}_i}^{-1}} ,
$$
then $\boldsymbol{S}_1, \dots, \boldsymbol{S}_N$ satisfy that
\begin{align*}
\nbr{\sbr{\sum_{j=1}^N \boldsymbol{S}_j }^{-1}} \leq (1+\zeta) \nbr{\sbr{N \sum_{i=1}^n \lambda(\boldsymbol{Q}_i) \boldsymbol{Q}_i }^{-1}} .
\end{align*}
(ii) If $\boldsymbol{\lambda}$ is a G-optimal design, i.e., for a given prediction set $\mathcal{Y} \subseteq \mathbb{R}^d$, $\lambda$ is the optimal solution of the optimization
$$
\min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{Q}}} \max_{\boldsymbol{y} \in \mathcal{Y}} \nbr{\boldsymbol{y}}^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{Q}_i) \boldsymbol{Q}_i}^{-1}} ,
$$
then $\boldsymbol{S}_1, \dots, \boldsymbol{S}_N$ satisfy that
\begin{align*}
\max_{\boldsymbol{y} \in \mathcal{Y}} \nbr{\boldsymbol{y}}^2_{\sbr{\sum_{j=1}^{N} \boldsymbol{S}_j}^{-1}} \leq (1+\zeta) \max_{\boldsymbol{y} \in \mathcal{Y}} \nbr{\boldsymbol{y}}^2_{\sbr{N \sum_{i=1}^{n} \lambda(\boldsymbol{Q}_i) \boldsymbol{Q}_i}^{-1}} .
\end{align*}
We implement $\mathtt{ROUND}$ by setting $\boldsymbol{\pi}^*=N\boldsymbol{\lambda}$, $k=r=N$ and $\boldsymbol{x}_i \boldsymbol{x}_i^\top = (\sum_{i=1}^{n} \pi^*(\boldsymbol{Q}_i) \boldsymbol{Q}_i)^{-\frac{1}{2}} \boldsymbol{Q}_i (\sum_{i=1}^{n} \pi^*(\boldsymbol{Q}_i) \boldsymbol{Q}_i)^{-\frac{1}{2}}$ for any $i \in [n]$ in Algorithm 1 of \cite{allen2017near}.
Note that Algorithm 1 in \cite{allen2017near} only needs to access the feature matrix $\boldsymbol{x}_i \boldsymbol{x}_i^\top$ rather than the separate feature vector $\boldsymbol{x}_i$, which allows us to apply it to our problem. We refer interested readers to \cite{allen2017near} and Appendix B in \cite{fiez2019sequential} for more implementation details of this rounding procedure.
\section{Proofs for Algorithm $\mathtt{DouExpDes}$}
In this section, we provide the proofs for Algorithm~$\mathtt{DouExpDes}$.
Throughout our proofs, we use $L_{\theta}$ to denote the upper bound of $\|\boldsymbol{\theta}_m\|$ for any $m \in [M]$.
Since $\boldsymbol{\theta}_m=\boldsymbol{B}\boldsymbol{w}_m$ for any $m \in [M]$, we have that $\|\boldsymbol{\theta}_m\| \leq \|\boldsymbol{B}\| \|\boldsymbol{w}_m\| \leq \|\boldsymbol{w}_m\| \leq L_{w}$, and thus $L_{\theta} \leq L_{w}$.
\subsection{Sample Batch Planning}
Recall that
\begin{align*}
\boldsymbol{\lambda}^{E} := & \operatornamewithlimits{argmin}_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \nbr{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1}}
\end{align*}
and
\begin{align*}
\rho^{E} := & \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \nbr{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1}}
\end{align*}
are the optimal solution and the optimal value of the E-optimal design optimization, respectively (Line~\ref{line:bai_E_optimal_design} in Algorithm~\ref{alg:repbailb}). $\bar{\boldsymbol{x}}_1,\dots,\bar{\boldsymbol{x}}_p$ is an arm sequence generated according to sample allocation $\boldsymbol{\lambda}^{E}$ via rounding procedure $\mathtt{ROUND}$ (Line~\ref{line:bai_E_optimal_round} in Algorithm~\ref{alg:repbailb}).
Let
$$
\boldsymbol{X}_{\textup{batch}}:=
\begin{bmatrix}
\bar{\boldsymbol{x}}_1^\top
\\
\dots
\\
\bar{\boldsymbol{x}}_p^\top
\end{bmatrix} ,
$$
and
$$
\boldsymbol{X}_{\textup{batch}}^{+} := (\boldsymbol{X}_{\textup{batch}}^\top \boldsymbol{X}_{\textup{batch}})^{-1} \boldsymbol{X}_{\textup{batch}}^{\top} .
$$
According to the fact that $\mathcal{X}$ spans $\mathbb{R}^d$, the definition of E-optimal design and the guarantee of $\mathtt{ROUND}$, we have that $\boldsymbol{X}_{\textup{batch}}^\top \boldsymbol{X}_{\textup{batch}}$ is invertible.
Now, we first give an upper bound of $\|\boldsymbol{X}_{\textup{batch}}^{+}\|$.
\begin{lemma} \label{lemma:X_batch_ub}
It holds that
\begin{align*}
\|\boldsymbol{X}_{\textup{batch}}^{+}\| \leq \sqrt{\frac{(1+\zeta) \rho^{E}}{p}} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:X_batch_ub}]
We have
\begin{align*}
\|\boldsymbol{X}_{\textup{batch}}^{+}\| = & \nbr{\sbr{\boldsymbol{X}_{\textup{batch}}^{\top} \boldsymbol{X}_{\textup{batch}}}^{-1} \boldsymbol{X}_{\textup{batch}}^{\top}}
\\
= & \sqrt{ \nbr{\sbr{\boldsymbol{X}_{\textup{batch}}^{\top} \boldsymbol{X}_{\textup{batch}}}^{-1} \boldsymbol{X}_{\textup{batch}}^{\top} \boldsymbol{X}_{\textup{batch}} \sbr{\boldsymbol{X}_{\textup{batch}}^{\top} \boldsymbol{X}_{\textup{batch}}}^{-1}} }
\\
= & \sqrt{ \nbr{\sbr{\boldsymbol{X}_{\textup{batch}}^{\top} \boldsymbol{X}_{\textup{batch}}}^{-1}} }
\\
= & \sqrt{ \nbr{\sbr{\sum_{i=1}^{p} \bar{\boldsymbol{x}}_i \bar{\boldsymbol{x}}_i^{\top}}^{-1}} }
\\
\leq & \sqrt{(1+\zeta) \nbr{\sbr{p \sum_{i=1}^{n} \lambda^{E}(\boldsymbol{x}_i) \boldsymbol{x}_i \boldsymbol{x}_i^{\top}}^{-1}} }
\\
= & \sqrt{\frac{(1+\zeta) \rho^{E}}{p}} .
\end{align*}
\end{proof}
\subsection{Global Feature Extractor Recovery} \label{apx:bai_feature_recover}
For clarity of notation, we add subscript $t$ to the notations in subroutine $\mathtt{FeatRecover}$ to denote the quantities generated in phase $t$. Specifically, we use $\alpha_{t,m,j,i}$, $\tilde{\boldsymbol{\theta}}_{t,m,j}$, $\boldsymbol{Z}_t$ and $\hat{\boldsymbol{B}}_t$ to denote the random reward, estimator of reward parameter, estimator of $\frac{1}{M} \sum_{i=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top$ and estimator of feature extractor in phase $t$, respectively.
For any phase $t>0$, task $m \in [M]$, round $j \in [T_t]$ and arm $i \in [p]$, let $\eta_{t,m,j,i}$ denote the noise of the sample on arm $\bar{\boldsymbol{x}}_i$ in the $j$-th round for task $m$, during the execution of $\mathtt{FeatRecover}$ in phase $t$ (Line~\ref{line:bai_stage2_sample} in Algorithm~\ref{alg:feat_recover}). The noise $\eta_{t,m,j,i}$ is zero-mean and sub-Gaussian, and has variance $1$. $\eta_{t,m,j,i}$ is independent for different $t,m,j,i$.
For any phase $t>0$, task $m \in [M]$, round $j \in [T_t]$, let $\boldsymbol{\alpha}_{t,m,j}:=[\alpha_{t,m,j,1},\dots,\alpha_{t,m,j,p}]^\top$.
Then, we have that
$$
\tilde{\boldsymbol{\theta}}_{t,m,j} = \boldsymbol{X}_{\textup{batch}}^{+} \boldsymbol{\alpha}_{t,m,j} ,
$$
and
$$
\boldsymbol{Z}_t = \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \tilde{\boldsymbol{\theta}}_{t,m,j} (\tilde{\boldsymbol{\theta}}_{t,m,j})^\top - \boldsymbol{X}_{\textup{batch}}^{+} (\boldsymbol{X}_{\textup{batch}}^{+})^\top .
$$
\begin{lemma}[Expectation of $\boldsymbol{Z}_t$] \label{lemma:bai_expectation_Z_t}
It holds that
\begin{align*}
\mathbb{E} \mbr{ \boldsymbol{Z}_t } = \frac{1}{M} \sum_{m=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:bai_expectation_Z_t}]
$\boldsymbol{Z}_t$ can be written as
\begin{align}
\boldsymbol{Z}_t = & \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \tilde{\boldsymbol{\theta}}_{t,m,j} (\tilde{\boldsymbol{\theta}}_{t,m,j})^\top - \boldsymbol{X}_{\textup{batch}}^{+} (\boldsymbol{X}_{\textup{batch}}^{+})^\top
\nonumber\\
= & \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{X}_{\textup{batch}}^{+} \begin{bmatrix}
\alpha_{t,m,j,1}
\\
\vdots
\\
\alpha_{t,m,j,p}
\end{bmatrix}
[\alpha_{t,m,j,1}, \dots, \alpha_{t,m,j,p}]^\top (\boldsymbol{X}_{\textup{batch}}^{+})^\top
- \boldsymbol{X}_{\textup{batch}}^{+} (\boldsymbol{X}_{\textup{batch}}^{+})^\top
\nonumber\\
= & \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{X}_{\textup{batch}}^{+} \begin{bmatrix}
\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m + \eta_{t,m,j,1}
\\
\vdots
\\
\bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m + \eta_{t,m,j,p}
\end{bmatrix}
[\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m + \eta_{t,m,j,1}, \dots,
\bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m + \eta_{t,m,j,p} ]^\top (\boldsymbol{X}_{\textup{batch}}^{+})^\top
- \boldsymbol{X}_{\textup{batch}}^{+} (\boldsymbol{X}_{\textup{batch}}^{+})^\top
\nonumber\\
= & \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{X}_{\textup{batch}}^{+}
\begin{bmatrix}
(\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m + \eta_{t,m,j,1})^2 & \!\!\!\!\!\cdots\!\!\!\!\! & (\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m + \eta_{t,m,j,1}) (\bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m + \eta_{t,m,j,p}) \\
\cdots & \!\!\!\!\!\cdots\!\!\!\!\! & \cdots \\
(\bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m + \eta_{t,m,j,p})(\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m + \eta_{t,m,j,1}) & \!\!\!\!\!\cdots\!\!\!\!\! & (\bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m + \eta_{t,m,j,p})^2
\end{bmatrix}
(\boldsymbol{X}_{\textup{batch}}^{+})^\top
\nonumber\\& - \boldsymbol{X}_{\textup{batch}}^{+} (\boldsymbol{X}_{\textup{batch}}^{+})^\top
\nonumber\\
= & \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{X}_{\textup{batch}}^{+}
\Bigg(
\begin{bmatrix}
(\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m)^2 & \cdots & \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \\
\cdots & \cdots & \cdots \\
\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m & \cdots & (\bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m)^2
\end{bmatrix}
\nonumber\\& +
\begin{bmatrix}
2 \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} & \cdots & \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,p} + \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} \\
\cdots & \cdots & \cdots \\
\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,p} + \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} & \cdots & 2 \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,p}
\end{bmatrix}
\nonumber\\& +
\begin{bmatrix}
(\eta_{t,m,j,1})^2 & \cdots & \eta_{t,m,j,1} \eta_{t,m,j,p} \\
\cdots & \cdots & \cdots \\
\eta_{t,m,j,1} \eta_{t,m,j,p} & \cdots & (\eta_{t,m,j,p})^2
\end{bmatrix}
\Bigg)
(\boldsymbol{X}_{\textup{batch}}^{+})^\top
- \boldsymbol{X}_{\textup{batch}}^{+} (\boldsymbol{X}_{\textup{batch}}^{+})^\top . \label{eq:Z_t_decompose}
\end{align}
Then, taking the expectation on $\boldsymbol{Z}_t$, we have
\begin{align*}
\mathbb{E} [\boldsymbol{Z}_t] = & \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{X}_{\textup{batch}}^{+}
\Bigg( \begin{bmatrix}
(\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m)^2 & \cdots & \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \\
\cdots & \cdots & \cdots \\
\bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m & \cdots & (\bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m)^2
\end{bmatrix} + \boldsymbol{I}_d \Bigg)
(\boldsymbol{X}_{\textup{batch}}^{+})^\top
- \boldsymbol{X}_{\textup{batch}}^{+} (\boldsymbol{X}_{\textup{batch}}^{+})^\top
\\
= & \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{X}_{\textup{batch}}^{+}
\begin{bmatrix}
(\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m)^2 & \cdots & \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \\
\cdots & \cdots & \cdots \\
\bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m & \cdots & (\bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m)^2
\end{bmatrix}
(\boldsymbol{X}_{\textup{batch}}^{+})^\top
\\
= & \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{X}_{\textup{batch}}^{+}
\begin{bmatrix}
\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m
\\
\vdots
\\
\bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m
\end{bmatrix} [\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m, \dots, \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m]^\top
(\boldsymbol{X}_{\textup{batch}}^{+})^\top
\\
= & \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{X}_{\textup{batch}}^{+}
\boldsymbol{X}_{\textup{batch}} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top \boldsymbol{X}_{\textup{batch}}^\top
(\boldsymbol{X}_{\textup{batch}}^{+})^\top
\\
= & \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top
\\
= & \frac{1}{M} \sum_{m=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top .
\end{align*}
\end{proof}
Recall that for any $t>0$, $\delta_t:=\frac{\delta}{2t^2}$.
For any phase $t>0$, define events
\begin{align*}
\mathcal{E}_t:= \lbr{ \nbr{\boldsymbol{Z}_t - \mathbb{E} [\boldsymbol{Z}_t]}
\leq \frac{ 96 \nbr{\boldsymbol{X}_{\textup{batch}}^{+}}^2 p L_{x} L_{\theta} \log\sbr{\frac{16p}{\delta_t}} }{\sqrt{MT_t}} \log \sbr{\frac{16pMT_t}{\delta_t}} } ,
\end{align*}
and
\begin{align*}
\mathcal{E}:=\cap_{t=1}^{\infty} \mathcal{E}_t .
\end{align*}
\begin{lemma}[Concentration of $\boldsymbol{Z}_t$] \label{lemma:Z_t_est_error}
It holds that
\begin{align*}
\Pr \mbr{\mathcal{E}} \geq \frac{\delta}{2} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:Z_t_est_error}]
According to Eq.~\eqref{eq:Z_t_decompose}, we have
\begin{align*}
\boldsymbol{Z}_t - \mathbb{E} [\boldsymbol{Z}_t] = & \frac{1}{M T_t} \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{X}_{\textup{batch}}^{+}
\Bigg(
\begin{bmatrix}
2 \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} & \cdots & \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,p} + \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} \\
\cdots & \cdots & \cdots \\
\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,p} + \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} & \cdots & 2 \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,p}
\end{bmatrix}
\\& -
\mathbb{E}
\begin{bmatrix}
2 \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} & \cdots & \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,p} + \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} \\
\cdots & \cdots & \cdots \\
\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,p} + \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} & \cdots & 2 \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,p}
\end{bmatrix}
\nonumber\\& +
\begin{bmatrix}
(\eta_{t,m,j,1})^2 & \cdots & \eta_{t,m,j,1} \eta_{t,m,j,p} \\
\cdots & \cdots & \cdots \\
\eta_{t,m,j,1} \eta_{t,m,j,p} & \cdots & (\eta_{t,m,j,p})^2
\end{bmatrix}
-
\mathbb{E}
\begin{bmatrix}
(\eta_{t,m,j,1})^2 & \cdots & \eta_{t,m,j,1} \eta_{t,m,j,p} \\
\cdots & \cdots & \cdots \\
\eta_{t,m,j,1} \eta_{t,m,j,p} & \cdots & (\eta_{t,m,j,p})^2
\end{bmatrix}
\Bigg)
(\boldsymbol{X}_{\textup{batch}}^{+})^\top .
\end{align*}
Define the following matrices:
\begin{align*}
\boldsymbol{A}_{t,m,j} &:= \frac{1}{M T_t} \begin{bmatrix}
2 \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} & \cdots & \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,p} + \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} \\
\cdots & \cdots & \cdots \\
\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \eta_{t,m,j,p} + \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,1} & \cdots & 2 \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \eta_{t,m,j,p}
\end{bmatrix} ,
\\
\boldsymbol{A}_t &:= \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{A}_{t,m,j} ,
\\
\boldsymbol{C}_{t,m,j} &:= \frac{1}{M T_t} \begin{bmatrix}
(\eta_{t,m,j,1})^2 & \cdots & \eta_{t,m,j,1} \eta_{t,m,j,p} \\
\cdots & \cdots & \cdots \\
\eta_{t,m,j,1} \eta_{t,m,j,p} & \cdots & (\eta_{t,m,j,p})^2
\end{bmatrix} ,
\\
\boldsymbol{C}_t &:= \sum_{m=1}^{M} \sum_{j=1}^{T_t} \boldsymbol{C}_{t,m,j} .
\end{align*}
Then, we can write $\boldsymbol{Z}_t - \mathbb{E} [\boldsymbol{Z}_t]$ as
\begin{align*}
\boldsymbol{Z}_t - \mathbb{E} [\boldsymbol{Z}_t] = \boldsymbol{X}_{\textup{batch}}^{+} \sbr{ \boldsymbol{A}_t - \mathbb{E}[\boldsymbol{A}_t] + \boldsymbol{C}_t - \mathbb{E}[\boldsymbol{C}_t] } (\boldsymbol{X}_{\textup{batch}}^{+})^\top ,
\end{align*}
and thus,
\begin{align}
\nbr{\boldsymbol{Z}_t - \mathbb{E} [\boldsymbol{Z}_t]} \leq \nbr{\boldsymbol{X}_{\textup{batch}}^{+}}^2 \sbr{ \nbr{\boldsymbol{A}_t - \mathbb{E}[\boldsymbol{A}_t]} + \nbr{\boldsymbol{C}_t - \mathbb{E}[\boldsymbol{C}_t]} } . \label{eq:Z_t_expressed_by_A}
\end{align}
Next, we analyze $\|\boldsymbol{A}_t - \mathbb{E}[\boldsymbol{A}_t]\|$ and $\|\boldsymbol{C}_t - \mathbb{E}[\boldsymbol{C}_t]\|$. In order to use the truncated matrix Bernstein inequality (Lemma~\ref{lemma:matrix_bernstein_tau}), we define the truncated noise and truncated matrices as follows.
Let $R>0$ be a truncation level of noises, which will be chosen later. For any $t>0$, $m \in [M]$, $j \in [T_t]$ and $i \in [p]$, let $\tilde{\eta}_{t,m,j,i}=\eta_{t,m,j,i} \mathbbm{1}\{|\eta_{t,m,j,i}| \leq R\}$ denote the truncated noise. Then, we define the following truncated matrices:
\begin{align}
\tilde{\boldsymbol{A}}_{t,m,j} &:= \frac{1}{M T_t} \begin{bmatrix}
2 \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \tilde{\eta}_{t,m,j,1} & \cdots & \bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \tilde{\eta}_{t,m,j,p} + \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \tilde{\eta}_{t,m,j,1} \\
\cdots & \cdots & \cdots \\
\bar{\boldsymbol{x}}_1^\top \boldsymbol{\theta}_m \tilde{\eta}_{t,m,j,p} + \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \tilde{\eta}_{t,m,j,1} & \cdots & 2 \bar{\boldsymbol{x}}_p^\top \boldsymbol{\theta}_m \tilde{\eta}_{t,m,j,p}
\end{bmatrix}
\nonumber\\
\tilde{\boldsymbol{A}}_t &:= \sum_{m=1}^{M} \sum_{j=1}^{T_t} \tilde{\boldsymbol{A}}_{t,m,j} ,
\nonumber\\
\tilde{\boldsymbol{C}}_{t,m,j} &:= \frac{1}{M T_t} \begin{bmatrix}
(\tilde{\eta}_{t,m,j,1})^2 & \cdots & \tilde{\eta}_{t,m,j,1} \tilde{\eta}_{t,m,j,p} \\
\cdots & \cdots & \cdots \\
\tilde{\eta}_{t,m,j,1} \tilde{\eta}_{t,m,j,p} & \cdots & (\tilde{\eta}_{t,m,j,p})^2
\end{bmatrix} \label{eq:tilde_C_t_m_j}
\\
\tilde{\boldsymbol{C}}_t &:= \sum_{m=1}^{M} \sum_{j=1}^{T_t} \tilde{\boldsymbol{C}}_{t,m,j} \nonumber
\end{align}
First, we bound $\|\boldsymbol{A}_t-\mathbb{E}[\boldsymbol{A}_t]\|$.
Since for any $t>0$, $m \in [M]$, $j \in [T_t]$ and $i \in [p]$, $|\tilde{\eta}_{t,m,j,i}| \leq R$ and $|\bar{\boldsymbol{x}}_i^\top \boldsymbol{\theta}_m| \leq L_{x} L_{\theta}$, we have $\|\tilde{\boldsymbol{A}}_{t,m,j}\| \leq \frac{1}{M T_t} \cdot 2p L_{x} L_{\theta} R$.
Recall that for any $t>0$, $m \in [M]$, $j \in [T_t]$ and $i \in [p]$, $\eta_{t,m,j,i}$ is 1-sub-Gaussian. Using a union bound over $i \in [p]$, we have that for any $t>0$, $m \in [M]$, $j \in [T_t]$, with probability at least $1-2p\exp(-\frac{R^2}{2})$, $|\eta_{t,m,j,i}| \leq R$ for all $i \in [p]$. Thus, with probability at least $1-2p\exp(-\frac{R^2}{2})$, $\|\boldsymbol{A}_{t,m,j}\| \leq \frac{1}{M T_t} \cdot 2p L_{x} L_{\theta} R$.
Then, we have
\begin{align*}
\nbr{ \mathbb{E}[\boldsymbol{A}_{t,m,j}]-\mathbb{E}[\tilde{\boldsymbol{A}}_{t,m,j}] } \leq & \nbr{ \mathbb{E} \mbr{\boldsymbol{A}_{t,m,j} \cdot \indicator{ \nbr{\boldsymbol{A}_{t,m,j}} \geq \frac{2p L_{x} L_{\theta} R}{M T_t} }} }
\\
\leq & \mathbb{E} \mbr{ \nbr{\boldsymbol{A}_{t,m,j}} \cdot \indicator{ \nbr{\boldsymbol{A}_{t,m,j}} \geq \frac{2p L_{x} L_{\theta} R}{M T_t} } }
\\
= & \mathbb{E}\mbr{ \frac{2p L_{x} L_{\theta} R}{M T_t} \cdot \indicator{ \nbr{\boldsymbol{A}_{t,m,j}} \geq \frac{2p L_{x} L_{\theta} R}{M T_t} }} \\& + \mbr{\sbr{ \nbr{\boldsymbol{A}_{t,m,j}} - \frac{2p L_{x} L_{\theta} R}{M T_t}} \cdot \indicator{ \nbr{\boldsymbol{A}_{t,m,j}} \geq \frac{2p L_{x} L_{\theta} R}{M T_t} } }
\\
= & \frac{2p L_{x} L_{\theta} R}{M T_t} \cdot \Pr\mbr{ \nbr{\boldsymbol{A}_{t,m,j}} \geq \frac{2p L_{x} L_{\theta} R}{M T_t} } + \int_0^{\infty} \Pr \mbr{ \nbr{\boldsymbol{A}_{t,m,j}} - \frac{2p L_{x} L_{\theta} R}{M T_t} > x} dx
\\
\leq & \frac{2p L_{x} L_{\theta} R}{M T_t} \cdot 2p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p L_{x} L_{\theta}}{M T_t} \int_R^{\infty} \Pr \mbr{ \nbr{\boldsymbol{A}_{t,m,j}} > \frac{2p L_{x} L_{\theta} y}{M T_t} } dy
\\
\leq & \frac{2p L_{x} L_{\theta} R}{M T_t} \cdot 2p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p L_{x} L_{\theta}}{M T_t} \int_R^{\infty} 2p \exp\sbr{-\frac{y^2}{2}} dy
\\
\leq & \frac{2p L_{x} L_{\theta} R}{M T_t} \cdot 2p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p L_{x} L_{\theta}}{M T_t} \cdot 2p \cdot \frac{1}{R} \cdot \exp\sbr{-\frac{R^2}{2}}
\\
= & \frac{2p L_{x} L_{\theta}}{M T_t} \cdot 2p \cdot \sbr{R+\frac{1}{R}} \exp\sbr{-\frac{R^2}{2}} .
\end{align*}
Let $\delta' \in (0,1)$ be a confidence parameter which will be chosen later.
Using the truncated matrix Bernstein inequality (Lemma~\ref{lemma:matrix_bernstein_tau}) with $n=MT_t$, $R=\sqrt{2\log \sbr{\frac{2pMT_t}{\delta'}}}$, $n \Pr[\|\boldsymbol{A}_{t,m,j}\| \geq \frac{1}{M T_t} \cdot 2p L_{x} L_{\theta} R] \leq \delta'$, $U=\frac{2p L_{x} L_{\theta} \sqrt{2\log \sbr{\frac{2pMT_t}{\delta'}}}}{MT_t}$, $\sigma^2=M T_t U^2$, $\tau=\frac{4\cdot 2p L_{x} L_{\theta} \sqrt{2\log \sbr{\frac{2pMT_t}{\delta'}}} \log\sbr{\frac{2p}{\delta'}}}{\sqrt{M T_t}} + \frac{4\cdot 2p L_{x} L_{\theta} \sqrt{2\log \sbr{\frac{2pMT_t}{\delta'}}} \log\sbr{\frac{2p}{\delta'}}}{M T_t}$ and $\Delta=\frac{2p L_{x} L_{\theta} \cdot 2 \sqrt{2\log \sbr{\frac{2pMT_t}{\delta'}}}}{M T_t} \cdot \frac{\delta'}{M T_t}$, we have that with probability at least $1-2\delta'$,
\begin{align}
\nbr{\boldsymbol{A}_t - \mathbb{E}[\boldsymbol{A}_t]} \leq & \frac{4\cdot 2p L_{x} L_{\theta} \sqrt{2\log \sbr{\frac{2pMT_t}{\delta'}}} \log\sbr{\frac{2p}{\delta'}}}{\sqrt{M T_t}} + \frac{4\cdot 2p L_{x} L_{\theta} \sqrt{2\log \sbr{\frac{2pMT_t}{\delta'}}} \log\sbr{\frac{2p}{\delta'}}}{M T_t}
\nonumber\\
\leq & \frac{8\cdot 2p L_{x} L_{\theta} \sqrt{2\log \sbr{\frac{2pMT_t}{\delta'}}} \log\sbr{\frac{2p}{\delta'}}}{\sqrt{M T_t}} .
\label{eq:A_t_concentration}
\end{align}
Now we investigate $\|\boldsymbol{C}_t-\mathbb{E}[\boldsymbol{C}_t]\|$. Recall that in Eq.~\eqref{eq:tilde_C_t_m_j}, for any $t>0$, $m \in [M]$, $j \in [T_t]$ and $i \in [p]$, $|\tilde{\eta}_{t,m,j,i}| \leq R$. Then, we have $\|\tilde{\boldsymbol{C}}_{t,m,j}\| \leq \frac{1}{M T_t} \cdot pR^2$.
Recall that for any $t>0$, $m \in [M]$ and $j \in [T_t]$, with probability at least $1-2p\exp(-\frac{R^2}{2})$, $|\eta_{t,m,j,i}| \leq R$ for all $i \in [p]$. Thus, with probability at least $1-2p\exp(-\frac{R^2}{2})$, $\|\boldsymbol{C}_{t,m,j}\| \leq \frac{1}{M T_t} \cdot pR^2$. Then, we have
\begin{align*}
\nbr{ \mathbb{E}[\boldsymbol{C}_{t,m,j}]-\mathbb{E}[\tilde{\boldsymbol{C}}_{t,m,j}] } \leq & \nbr{ \mathbb{E} \mbr{\boldsymbol{C}_{t,m,j} \cdot \indicator{ \nbr{\boldsymbol{C}_{t,m,j}} \geq \frac{pR^2}{M T_t} }} }
\\
\leq & \mathbb{E} \mbr{ \nbr{\boldsymbol{C}_{t,m,j}} \cdot \indicator{ \nbr{\boldsymbol{C}_{t,m,j}} \geq \frac{pR^2}{M T_t} } }
\\
= & \mathbb{E}\mbr{ \frac{pR^2}{M T_t} \cdot \indicator{ \nbr{\boldsymbol{C}_{t,m,j}} \geq \frac{pR^2}{M T_t} }} + \mbr{\sbr{ \nbr{\boldsymbol{C}_{t,m,j}} - \frac{pR^2}{M T_t}} \cdot \indicator{ \nbr{\boldsymbol{C}_{t,m,j}} \geq \frac{pR^2}{M T_t} } }
\\
= & \frac{pR^2}{M T_t} \cdot \Pr\mbr{ \nbr{\boldsymbol{C}_{t,m,j}} \geq \frac{pR^2}{M T_t} } + \int_0^{\infty} \Pr \mbr{ \nbr{\boldsymbol{C}_{t,m,j}} - \frac{pR^2}{M T_t} > x} dx
\\
\leq & \frac{pR^2}{M T_t} \cdot 2p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p}{M T_t} \int_R^{\infty} \boldsymbol{y} \cdot \Pr \mbr{ \nbr{\boldsymbol{C}_{t,m,j}} > \frac{dy^2}{M T_t} } dy
\\
\leq & \frac{pR^2}{M T_t} \cdot 2p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p}{M T_t} \int_R^{\infty} \boldsymbol{y} \cdot 2p \exp\sbr{-\frac{y^2}{2}} dy
\\
\leq & \frac{pR^2}{M T_t} \cdot 2p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p}{M T_t} \cdot 2p \cdot \exp\sbr{-\frac{R^2}{2}}
\\
= & \frac{p}{M T_t} \cdot 2p \cdot \sbr{R^2+2} \exp\sbr{-\frac{R^2}{2}} .
\end{align*}
Using the truncated matrix Bernstein inequality (Lemma~\ref{lemma:matrix_bernstein_tau}) with $n=MT_t$, $R=\sqrt{2\log \sbr{\frac{2pMT_t}{\delta'}}}$, $n \Pr[\|\boldsymbol{C}_{t,m,j}\| \geq \frac{1}{M T_t} \cdot pR^2] \leq \delta'$, $U=\frac{p \cdot 2\log \sbr{\frac{2pMT_t}{\delta'}} }{MT_t}$, $\sigma^2=\frac{32p}{M T_t}$, $\tau=\frac{4\cdot p \cdot 2\log \sbr{\frac{2pMT_t}{\delta'}} \log\sbr{\frac{2p}{\delta'}}}{\sqrt{M T_t}} + \frac{4\cdot p \cdot 2\log \sbr{\frac{2pMT_t}{\delta'}} \log\sbr{\frac{2p}{\delta'}}}{M T_t}$ and $\Delta=\frac{p \cdot 2 \cdot 2\log \sbr{\frac{2pMT_t}{\delta'}} }{M T_t} \cdot \frac{\delta'}{M T_t}$, we have that with probability at least $1-2\delta'$,
\begin{align}
\nbr{\boldsymbol{C}_t - \mathbb{E}\mbr{\boldsymbol{C}_t}} \leq & \frac{4\cdot 2p \log \sbr{\frac{2pMT_t}{\delta'}} \log\sbr{\frac{2p}{\delta'}}}{\sqrt{M T_t}} + \frac{4 \cdot 2p \log \sbr{\frac{2pMT_t}{\delta'}} \log \sbr{\frac{2p}{\delta'}}}{M T_t}
\nonumber\\
\leq & \frac{8\cdot 2p \log \sbr{\frac{2pMT_t}{\delta'}} \log\sbr{\frac{2p}{\delta'}}}{\sqrt{M T_t}}
\label{eq:C_t_concentration}
\end{align}
Plugging Eqs.~\eqref{eq:A_t_concentration} and \eqref{eq:C_t_concentration} into Eq.~\eqref{eq:Z_t_expressed_by_A}, we have that with probability at least $1-4\delta'$,
\begin{align*}
\nbr{\boldsymbol{Z}_t - \mathbb{E} [\boldsymbol{Z}_t]} \leq & \nbr{\boldsymbol{X}_{\textup{batch}}^{+}}^2 \sbr{\nbr{\boldsymbol{A}_t - \mathbb{E} \mbr{\boldsymbol{A}_t}} + \nbr{\boldsymbol{C}_t - \mathbb{E} \mbr{\boldsymbol{C}_t}} }
\\
\leq & \nbr{\boldsymbol{X}_{\textup{batch}}^{+}}^2 \sbr{ \frac{8\cdot 2p L_{x} L_{\theta} \sqrt{2\log \sbr{\frac{2pMT_t}{\delta'}}} \log\sbr{\frac{2p}{\delta'}}}{\sqrt{M T_t}} + \frac{8\cdot 2p \log \sbr{\frac{2pMT_t}{\delta'}} \log\sbr{\frac{2p}{\delta'}}}{\sqrt{M T_t}} }
\\
\leq & \frac{ 96 \nbr{\boldsymbol{X}_{\textup{batch}}^{+}}^2 p L_{x} L_{\theta} \log\sbr{\frac{2p}{\delta'}} }{\sqrt{MT_t}} \log \sbr{\frac{2pMT_t}{\delta'}} .
\end{align*}
Let $\delta'=\frac{\delta_t}{8}$. Then, we obtain that with probability at least $1-\frac{\delta_t}{2}$,
\begin{align*}
\nbr{\boldsymbol{Z}_t - \mathbb{E} [\boldsymbol{Z}_t]} \leq & \frac{ 96 \nbr{\boldsymbol{X}_{\textup{batch}}^{+}}^2 p L_{x} L_{\theta} \log\sbr{\frac{16p}{\delta_t}} }{\sqrt{MT_t}} \log \sbr{\frac{16pMT_t}{\delta_t}} ,
\end{align*}
which implies that
$\Pr \mbr{\mathcal{E}_t} \geq 1-\frac{\delta_t}{2}$.
Taking a union bound over all phases $t\geq 1$ and recalling $\delta_t:=\frac{\delta}{2t^2}$, we obtain
\begin{align*}
\Pr \mbr{\mathcal{E}}
\geq & 1- \sum_{t=1}^{\infty} \Pr \mbr{\bar{\mathcal{E}_t}}
\\
\geq & 1- \sum_{t=1}^{\infty} \frac{\delta_t}{2}
\\
= & 1- \sum_{t=1}^{\infty} \frac{\delta}{4t^2}
\\
\geq & 1-\frac{\delta}{2} .
\end{align*}
\end{proof}
For any matrix $\boldsymbol{A} \in \mathbb{R}^{m \times n}$ with $m \geq n$, let $\sigma_{\max}(\boldsymbol{A})$ and $\sigma_{\min}(\boldsymbol{A})$ denote the maximum and minimum singular values of $\boldsymbol{A}$, respectively. For any $i \in [m]$, let $\sigma_i(\boldsymbol{A})$ denote the $i$-th singular value of $\boldsymbol{A}$.
For any matrix $\boldsymbol{A} \in \mathbb{R}^{m \times n}$ with $m \geq n$, let $\boldsymbol{A}_{\bot}$ denote the orthogonal complement matrix of $\boldsymbol{A}$, where the columns of $\boldsymbol{A}_{\bot}$ are the orthogonal complement of those of $\boldsymbol{A}$. Then, it holds that $\boldsymbol{A} \boldsymbol{A}^\top + \boldsymbol{A}_{\bot} \boldsymbol{A}_{\bot}^\top = \boldsymbol{I}_m$, where $\boldsymbol{I}_m$ is the $m \times m$ identity matrix.
According to Assumption~\ref{assumption:diverse_task}, there exists an absolute constant $c_0$ which satisfies that $\sigma_{\min}(\frac{1}{M} \sum_{m=1}^{M} \boldsymbol{w}_m \boldsymbol{w}_m^\top) = \sigma_{\min}(\frac{1}{M} \sum_{m=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top) \geq \frac{c_0}{k}$.
\begin{lemma}[Concentration of $\hat{\boldsymbol{B}}_t$] \label{lemma:concentration_B_hat_t}
Suppose that event $\mathcal{E}$ holds. Then, for any phase $t>0$,
\begin{align*}
\nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \leq \frac{ 192 \nbr{\boldsymbol{X}_{\textup{batch}}^{+}}^2 k p L_{x} L_{\theta} \log\sbr{\frac{16p}{\delta_t}} }{\sqrt{MT_t}} \log \sbr{\frac{16pMT_t}{\delta_t}} .
\end{align*}
Furthermore, for any phase $t>0$, if
\begin{align}
%
T_t = \Bigg \lceil & \frac{68 \cdot 192^2 \cdot 8^2 \sbr{1+\zeta}^3 (\rho^E)^2 k^4 L_{x}^4 L_{\theta}^2 L_{w}^2}{c_0^2 M} \cdot \max\lbr{2^{2t},\ \frac{L_x^4}{\omega^2}} \cdot \log^2 \sbr{\frac{16p}{\delta_t}} \nonumber\\& \log^2 \sbr{ \frac{192 \cdot 16 \cdot 8 \sbr{1+\zeta}^{\frac{3}{2}} \rho^E k^2 p L_{x}^2 L_{\theta} L_{w}}{c_0} \cdot \max\lbr{2^t,\ \frac{L_x^2}{\omega}} \cdot \frac{1}{\delta_t} \cdot \log\sbr{\frac{16p}{\delta_t}} } \Bigg \rceil , \label{eq:value_T_t}
\end{align}
then
\begin{align*}
\nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \leq \min\lbr{\frac{1}{8 k L_{x} L_{w} \cdot 2^t \sqrt{1+\zeta}},\ \frac{\omega}{6 L_x^2}} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:concentration_B_hat_t}]
From Assumption~\ref{assumption:diverse_task}, $\sigma_{k}(\mathbb{E}[\boldsymbol{Z}_t]) - \sigma_{k+1}(\mathbb{E}[\boldsymbol{Z}_t])=\sigma_{\min}( \frac{1}{M} \sum_{m=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top ) \geq \frac{c_0}{k}$. Using the Davis-Kahan sin $\theta$ Theorem~\cite{bhatia2013matrix} and letting $T_t$ be large enough to satisfy $\nbr{\boldsymbol{Z}_t - \mathbb{E}[\boldsymbol{Z}_t]} \leq \frac{c_0}{2k}$, we have
\begin{align*}
\nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \leq & \frac{ \nbr{\boldsymbol{Z}_t - \mathbb{E}[\boldsymbol{Z}_t]} }{ \sigma_{k}(\mathbb{E}[\boldsymbol{Z}_t]) - \sigma_{k+1}(\mathbb{E}[\boldsymbol{Z}_t]) - \nbr{\boldsymbol{Z}_t - \mathbb{E}[\boldsymbol{Z}_t]} }
\\
\leq & \frac{2k}{c_0} \nbr{\boldsymbol{Z}_t - \mathbb{E}[\boldsymbol{Z}_t]}
\\
\overset{\textup{(a)}}{\leq} & \frac{ 192 \nbr{\boldsymbol{X}_{\textup{batch}}^{+}}^2 k p L_{x} L_{\theta} \log\sbr{\frac{16p}{\delta_t}} }{c_0 \sqrt{MT_t}} \log \sbr{\frac{16pMT_t}{\delta_t}} ,.
\end{align*}
where inequality (a) uses the definition of event $\mathcal{E}$.
Using Lemma~\ref{lemma:technical_tool_bai_stage2} with $A= \frac{192 \nbr{\boldsymbol{X}_{\textup{batch}}^{+}}^2 k p L_{x} L_{\theta}}{c_0} \log\sbr{\frac{16p}{\delta_t}} $, $B=\frac{16p}{\delta_t}$ and $\kappa=\min\{\frac{1}{8 k L_{x} L_{w} \cdot 2^t \sqrt{1+\zeta}}, \frac{\omega}{6 L_x^2}\}$, we have that if
\begin{align*}
M T_t \geq & 68 \sbr{ \frac{192 \nbr{\boldsymbol{X}_{\textup{batch}}^{+}}^2 k p L_{x} L_{\theta}}{c_0} \log\sbr{\frac{16p}{\delta_t}}}^2 \cdot \max\lbr{ \sbr{8 k L_{x} L_{w} \cdot 2^t \sqrt{1+\zeta} }^2 ,\ \frac{6^2 L_x^4}{\omega^2} } \cdot \\& \log^2 \sbr{ \frac{192 \nbr{\boldsymbol{X}_{\textup{batch}}^{+}}^2 k p L_{x} L_{\theta}}{c_0} \log\sbr{\frac{16p}{\delta_t}} \cdot \frac{16p}{\delta_t} \cdot \max\lbr{ 8 k L_{x} L_{w} \cdot 2^t \sqrt{1+\zeta} ,\ \frac{6 L_x^2}{\omega} } } ,
\end{align*}
then $\nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \leq \min\lbr{\frac{1}{8 k L_{x} L_{w} \cdot 2^t \sqrt{1+\zeta}},\ \frac{\omega}{6 L_x^2}}$.
According to Lemma~\ref{lemma:X_batch_ub}, we have $\|\boldsymbol{X}_{\textup{batch}}^{+}\| \leq \sqrt{\frac{(1+\zeta) \rho^{E}}{p}}$.
Then, further enlarging $M T_t$, we have that if
\begin{align*}
M T_t \geq & \frac{68 \cdot 192^2 \cdot 8^2 \sbr{1+\zeta}^3 (\rho^E)^2 k^4 L_{x}^4 L_{\theta}^2 L_{w}^2}{c_0^2} \cdot \max\lbr{2^{2t},\ \frac{L_x^4}{\omega^2}} \cdot \log^2 \sbr{\frac{16p}{\delta_t}} \\& \log^2 \sbr{ \frac{192 \cdot 16 \cdot 8 \sbr{1+\zeta}^{\frac{3}{2}} \rho^E k^2 p L_{x}^2 L_{\theta} L_{w}}{c_0} \cdot \max\lbr{2^t,\ \frac{L_x^2}{\omega}} \cdot \frac{1}{\delta_t} \cdot \log\sbr{\frac{16p}{\delta_t}} } ,
\end{align*}
then
\begin{align*}
\nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \leq \min\lbr{\frac{1}{8 k L_{x} L_{w} \cdot 2^t \sqrt{1+\zeta}},\ \frac{\omega}{6 L_x^2}} .
\end{align*}
\end{proof}
\subsection{Elimination with Low-dimensional Representations}
For clarity of notation, we also add subscript $t$ to the notations in subroutine $\mathtt{EliLowRep}$ to denote the quantities generated in phase $t$. Specifically, we use the notations $\hat{\boldsymbol{B}}_t$, $\hat{\mathcal{X}}_{t,m}$, $\boldsymbol{\lambda}^{G}_{t,m}$, $\rho^{G}_{t,m}$, $N_{t,m}$, $\{\boldsymbol{z}_{t,m,i}\}_{i \in [N_{t,m}]}$, $\{r_{t,m,i}\}_{i \in [N_{t,m}]}$, $\hat{\boldsymbol{w}}_{t,m}$ and $\hat{\boldsymbol{\theta}}_{t,m}$ to denote the corresponding quantities used in $\mathtt{EliLowRep}$ in phase $t$.
Before analyzing the sample complexity of $\mathtt{EliLowRep}$, we first prove that there exists a sample allocation $\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}$ such that $\sum_{i=1}^{n} \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t$ is invertible, i.e., the G-optimal design optimization with $\hat{\boldsymbol{B}}_t$ is non-vacuous (Line~\ref{line:bai_G_optimal_design} in Algorithm~\ref{alg:elim_low_rep}).
For any task $m \in [M]$, let
\begin{align*}
\boldsymbol{\lambda}^*_m := & \operatornamewithlimits{argmin}_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{x} \in \mathcal{X} \setminus \{\boldsymbol{x}^{*}_{m}\}} \frac{\| \boldsymbol{B}^\top \boldsymbol{x}^{*}_{m} - \boldsymbol{B}^\top \boldsymbol{x} \|^2_{\sbr{ \sum_{i=1}^{n} \lambda(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} } }{\sbr{ ({\boldsymbol{x}^{*}_{m}} - \boldsymbol{x})^\top \boldsymbol{\theta}_m }^2} .
\end{align*}
$\boldsymbol{\lambda}^*_m$ is the optimal solution of the G-optimal design optimization with true feature extractor $\boldsymbol{B}$.
\begin{lemma} \label{lemma:invertible_under_hat_B}
For any phase $t>0$ and task $m \in [M]$, if $\|\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot}\| \leq \frac{\omega}{6 L_x^2}$, we have
\begin{align*}
\sigma_{\min}\sbr{\sum_{i=1}^{n} \lambda^{*}_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t} > 0 .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:invertible_under_hat_B}]
For any task $m \in [M]$, let $\boldsymbol{A}_m:=\sum_{i=1}^{n} \lambda^{*}_m(\boldsymbol{x}_i) \boldsymbol{x}_i \boldsymbol{x}_i^\top$.
Then, for any phase $t>0$ and task $m \in [M]$, we have
\begin{align*}
\sum_{i=1}^{n} \lambda^{*}_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t = & \hat{\boldsymbol{B}}_t^\top \boldsymbol{A}_m \hat{\boldsymbol{B}}_t
\\
= & \hat{\boldsymbol{B}}_t^\top \sbr{ \boldsymbol{B} \boldsymbol{B}^\top + \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top } \boldsymbol{A}_m \sbr{ \boldsymbol{B} \boldsymbol{B}^\top + \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top } \hat{\boldsymbol{B}}_t
\\
= & \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{A}_m \boldsymbol{B} \boldsymbol{B}^\top \hat{\boldsymbol{B}}_t + \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{A}_m \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \hat{\boldsymbol{B}}_t
\\& + \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{A}_m \boldsymbol{B} \boldsymbol{B}^\top \hat{\boldsymbol{B}}_t + \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{A}_m \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \hat{\boldsymbol{B}}_t .
\end{align*}
Hence, we have
\begin{align*}
\sigma_{\min}\sbr{\sum_{i=1}^{n} \lambda^{*}_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t} \geq & \sigma_{\min}\sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{A}_m \boldsymbol{B} \boldsymbol{B}^\top \hat{\boldsymbol{B}}_t } - \sigma_{\max}\sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{A}_m \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \hat{\boldsymbol{B}}_t }
\\& - \sigma_{\max}\sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{A}_m \boldsymbol{B} \boldsymbol{B}^\top \hat{\boldsymbol{B}}_t } - \sigma_{\max}\sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{A}_m \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \hat{\boldsymbol{B}}_t }
\\
\geq & \sigma_{\min}\sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} } \sigma_{\min}\sbr{ \boldsymbol{B}^\top \boldsymbol{A}_m \boldsymbol{B} } \sigma_{\min}\sbr{ \boldsymbol{B}^\top \hat{\boldsymbol{B}}_t } - \nbr{ \boldsymbol{B}_{\bot}^\top \hat{\boldsymbol{B}}_t } \nbr{\boldsymbol{A}_m}
\\& - \nbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} } \nbr{\boldsymbol{A}_m} - \nbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} } \nbr{\boldsymbol{A}_m}
\\
\geq & \sigma^2_{\min}\sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} } \sigma_{\min}\sbr{ \boldsymbol{B}^\top \boldsymbol{A}_m \boldsymbol{B} } - 3\nbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} } L_x^2
\\
\overset{\textup{(a)}}{\geq} & \sbr{ 1 - \nbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} }^2 } \omega - 3\nbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} } L_x^2 ,
\end{align*}
where inequality (a) uses the fact that $\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \hat{\boldsymbol{B}}_t + \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \hat{\boldsymbol{B}}_t = \hat{\boldsymbol{B}}_t^\top (B \boldsymbol{B}^\top + \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top) \hat{\boldsymbol{B}}_t =\hat{\boldsymbol{B}}_t^\top \hat{\boldsymbol{B}}_t=\boldsymbol{I}_k$, and thus, $\sigma^2_{\min}( \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} )=1 - \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \|^2$.
Let $\|\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot}\| \leq \frac{\omega}{6 L_x^2}$. Then, we have
\begin{align*}
\sigma_{\min}\sbr{\sum_{i=1}^{n} \lambda^{*}_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t} \geq & \sbr{ 1 - \frac{\omega^2}{36 L_x^4} } \omega - \frac{\omega}{2}
\\
= & \frac{\omega}{2} - \frac{\omega^3}{36 L_x^4}
\\
> & 0 ,
\end{align*}
where the last inequality is due to $\omega \leq L_x^2 < \sqrt{18} L_x^2$.
\end{proof}
Next, we bound the optimal value $\rho^{G}_{t,m}$ of the G-optimal design optimization with the estimated feature extractor $\hat{\boldsymbol{B}}_t$.
For any $\mathcal{Z} \subseteq \mathcal{X}$, let $\mathcal{Y}(\mathcal{Z}):=\{ \boldsymbol{x}-\boldsymbol{x}':\ \forall \boldsymbol{x},\boldsymbol{x}' \in \mathcal{Z},\ \boldsymbol{x} \neq \boldsymbol{x}' \}$.
Recall that in Line~\ref{line:bai_G_optimal_design} of Algorithm~\ref{alg:elim_low_rep}, for any phase $t>0$ and task $m \in [M]$,
$$
\rho^{G}_{t,m}:=\min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{y} \in \mathcal{Y}(\hat{\mathcal{X}}_{t,m})} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}} .
$$
\begin{lemma} \label{lemma:rho_t_leq_4k}
For any phase $t>0$ and task $m \in [M]$,
\begin{align*}
\rho^{G}_{t,m} \leq 4k .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:rho_t_leq_4k}]
For any phase $t>0$ and task $m \in [M]$, we have that $\hat{\mathcal{X}}_{t,m} \subseteq \mathcal{X}$ and $ \mathcal{Y}(\hat{\mathcal{X}}_{t,m}) \subseteq \mathcal{Y}(\mathcal{X})$.
For any fixed $\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}$,
\begin{align*}
\max_{\boldsymbol{y} \in \mathcal{Y}(\hat{\mathcal{X}}_{t,m})} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}} \leq & \max_{\boldsymbol{y} \in \mathcal{Y}(\mathcal{X})} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}
\\
= & \| \hat{\boldsymbol{B}}_t^\top (\boldsymbol{x}'_1-\boldsymbol{x}'_2) \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}
\\
\leq & \sbr{\| \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}'_1 \|_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}+\| \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}'_2 \|_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}}^2
\\
\leq & 2\| \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}'_1 \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}} + 2\| \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}'_2 \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}
\\
\leq & 4 \max_{\boldsymbol{x} \in \mathcal{X}} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{x} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}} ,
\end{align*}
where $\boldsymbol{x}'_1$ and $\boldsymbol{x}'_2$ are the arms which satisfy that $\boldsymbol{y}=\boldsymbol{x}'_1-\boldsymbol{x}'_2$ achieves the maximum value $\max_{\boldsymbol{y} \in \mathcal{Y}(\mathcal{X})} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}$.
Since $\hat{\boldsymbol{B}}_t^\top \boldsymbol{x} \in \mathbb{R}^k$, according to the Equivalence Theorem in \cite{kiefer1960equivalence}, we have
\begin{align*}
\min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{x} \in \mathcal{X}} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{x} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}} = k .
\end{align*}
Therefore, we have
\begin{align*}
4k = & 4 \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{x} \in \mathcal{X}} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{x} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}} \\
= & 4 \max_{\boldsymbol{x} \in \mathcal{X}} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{x} \|^2_{\sbr{\sum_{i=1}^n \lambda'(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}
\\
\geq & \max_{\boldsymbol{y} \in \mathcal{Y}(\hat{\mathcal{X}}_{t,m})} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda'(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}
\\
\geq & \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{y} \in \mathcal{Y}(\hat{\mathcal{X}}_{t,m})} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}
\\
= & \rho^{G}_{t,m} ,
\end{align*}
where $\boldsymbol{\lambda}':=\operatornamewithlimits{argmin}_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{x} \in \mathcal{X}} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{x} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}$.
\end{proof}
Now we analyze the estimation error of the estimated reward parameter $\hat{\boldsymbol{\theta}}_{t,m}=\hat{\boldsymbol{B}}_t \hat{\boldsymbol{w}}_{t,m}$ in $\mathtt{EliLowRep}$.
For any phase $t>0$, task $m \in [M]$ and arm $j \in [N_{t,m}]$, let $\xi_{t,m,j}$ denote the noise of the sample on arm $\boldsymbol{z}_{t,m,j}$ for task $m$, during the execution of $\mathtt{EliLowRep}$ in phase $t$ (Line~\ref{line:bai_stage3_sample} in Algorithm~\ref{alg:elim_low_rep}).
For any phase $t>0$, define events
\begin{align}
\mathcal{F}_t := \Bigg \{ &
\boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1} \sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot \xi_{t,m,j}
\nonumber\\
& \leq \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1}} \sqrt{2\log \sbr{\frac{4n^2 M}{\delta_t}}}, \ \forall m \in [M] ,\ \forall \boldsymbol{y} \in \mathcal{Y}(\hat{\mathcal{X}}_{t,m}) \Bigg\}, \label{eq:definition_cF}
\end{align}
and
\begin{align*}
\mathcal{F} := \cap_{t=1}^{\infty} \mathcal{F}_t .
\end{align*}
\begin{lemma}[Concentration of the Variance Term]\label{lemma:concentration_variance_bai}
It holds that
\begin{align*}
\Pr \mbr{\mathcal{F}} \geq 1-\frac{\delta}{2} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:concentration_variance_bai}]
Let $\boldsymbol{\Sigma}_{t,m}:=\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t$.
Then, we can write
\begin{align*}
\boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1} \sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot \xi_{t,m,j} =\sum_{j=1}^{N_{t,m}} \boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \boldsymbol{\Sigma}_{t,m}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot \xi_{t,m,j} .
\end{align*}
For any phase $t>0$, task $m \in [M]$ and arm $j \in [N_{t,m}]$, $\hat{\boldsymbol{B}}_t$, $\boldsymbol{\Sigma}_{t,m}$ and $\{\boldsymbol{z}_{t,m,j}\}_{j=1}^{N_{t,m}}$ are fixed before the sampling in $\mathtt{EliLowRep}$, and the noise $\xi_{t,m,j}$ is 1-sub-Gaussian (Line~\ref{line:bai_stage3_sample} in Algorithm~\ref{alg:elim_low_rep}).
Thus, we have that for any $t>0$, $m \in [M]$ and $j \in [N_{t,m}]$, $\boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \boldsymbol{\Sigma}_{t,m}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot \xi_{t,m,j} $ is $(\boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \boldsymbol{\Sigma}_{t,m}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j})$-sub-Gaussian.
Using Hoeffding's inequality and taking a union bound over all $m \in [M]$ and $\boldsymbol{y} \in \mathcal{Y}(\hat{\mathcal{X}}_{t,m})$, we have that with probability at least $1-\frac{\delta_t}{2}$,
\begin{align*}
& \sum_{j=1}^{N_{t,m}} \boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \boldsymbol{\Sigma}_{t,m}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot \xi_{t,m,j}
\\
\leq & \sqrt{2 \sum_{j=1}^{N_{t,m}} \sbr{\boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \boldsymbol{\Sigma}_{t,m}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j}}^2 \cdot \log \sbr{\frac{4n^2 M}{\delta_t}}}
\\
= & \sqrt{2 \sum_{j=1}^{N_{t,m}} \boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \boldsymbol{\Sigma}_{t,m}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t \boldsymbol{\Sigma}_{t,m}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \cdot \log \sbr{\frac{4n^2 M}{\delta_t}}}
\\
= & \sqrt{2 \boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \boldsymbol{\Sigma}_{t,m}^{-1} \sbr{\hat{\boldsymbol{B}}_t^\top \sum_{j=1}^{N_{t,m}} \boldsymbol{z}_{t,m,j} \cdot {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t} \boldsymbol{\Sigma}_{t,m}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \cdot \log \sbr{\frac{4n^2 M}{\delta_t}}}
\\
= & \sqrt{2 \boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \boldsymbol{\Sigma}_{t,m}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \cdot \log \sbr{\frac{4n^2 M}{\delta_t}}}
\\
= & \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\boldsymbol{\Sigma}_{t,m}^{-1}} \sqrt{2 \log \sbr{\frac{4n^2 M}{\delta_t}}} ,
\end{align*}
which implies that
\begin{align*}
\Pr \mbr{ \mathcal{F}_t } \geq 1 - \frac{\delta_t}{2} .
\end{align*}
Taking a union bound over all phases $t \geq 1$ and recalling $\delta_t:=\frac{\delta}{2t^2}$, we obtain
\begin{align*}
\Pr \mbr{\mathcal{F}}
\geq & 1- \sum_{t=1}^{\infty} \Pr \mbr{\bar{\mathcal{F}_t}}
\\
\geq & 1- \sum_{t=1}^{\infty} \frac{\delta_t}{2}
\\
= & 1- \sum_{t=1}^{\infty} \frac{\delta}{4t^2}
\\
\geq & 1-\frac{\delta}{2} .
\end{align*}
\end{proof}
\begin{lemma}[Concentration of $\hat{\boldsymbol{\theta}}_{t,m}$] \label{lemma:bai_concentration_theta_t_m}
Suppose that event $\mathcal{E} \cap \mathcal{F}$ holds. Then, for any phase $t>0$, task $m \in [M]$ and $\boldsymbol{y} \in \mathcal{Y}(\hat{\mathcal{X}}_{t,m})$,
\begin{align*}
\abr{\boldsymbol{y}^\top \sbr{\hat{\boldsymbol{\theta}}_{t,m}-\boldsymbol{\theta}_m}} \leq \frac{1}{2^t} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:bai_concentration_theta_t_m}]
For any phase $t>0$, task $m \in [M]$ and $\boldsymbol{y} \in \mathcal{Y}(\hat{\mathcal{X}}_{t,m})$,
\begin{align}
\boldsymbol{y}^\top \sbr{\hat{\boldsymbol{\theta}}_{t,m}- \boldsymbol{\theta}_m} = & \boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \hat{\boldsymbol{w}}_{t,m}-\boldsymbol{y}^\top \sbr{ \hat{\boldsymbol{B}}_t \hat{\boldsymbol{B}}_t^\top + \hat{\boldsymbol{B}}_{t,\bot} \hat{\boldsymbol{B}}_{t,\bot}^\top } \boldsymbol{\theta}_m
\nonumber\\
= & \boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \sbr{\hat{\boldsymbol{w}}_{t,m} - \hat{\boldsymbol{B}}_t^\top \boldsymbol{\theta}_m } -\boldsymbol{y}^\top \hat{\boldsymbol{B}}_{t,\bot} \hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{\theta}_m . \label{eq:y_theta_est_err_decompose}
\end{align}
Here, $\hat{\boldsymbol{w}}_{t,m}$ can be written as
\begin{align}
\hat{\boldsymbol{w}}_{t,m} = & \sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1} \sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot r_{t,m,j}
\nonumber\\
= & \sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1} \sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot \sbr{{\boldsymbol{z}_{t,m,j}}^\top \boldsymbol{\theta}_m + \xi_{t,m,j}}
\nonumber\\
= & \sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1} \sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot \sbr{{\boldsymbol{z}_{t,m,j}}^\top \sbr{ \hat{\boldsymbol{B}}_t \hat{\boldsymbol{B}}_t^\top + \hat{\boldsymbol{B}}_{t,\bot} \hat{\boldsymbol{B}}_{t,\bot}^\top } \boldsymbol{\theta}_m + \xi_{t,m,j}}
\nonumber\\
= & \hat{\boldsymbol{B}}_t^\top \boldsymbol{\theta}_m + \sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1} \sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_{t,\bot} \hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{\theta}_m \nonumber\\& + \sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1} \sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot \xi_{t,m,j} . \label{eq:hat_w_decompose}
\end{align}
Plugging Eq.~\eqref{eq:hat_w_decompose} into Eq.~\eqref{eq:y_theta_est_err_decompose}, we can decompose the estimation error of $\hat{\boldsymbol{\theta}}_{t,m}$ in $\mathtt{EliLowRep}$ into three parts as
\begin{align*}
\boldsymbol{y}^\top \sbr{\hat{\boldsymbol{\theta}}_{t,m}- \boldsymbol{\theta}_m} = &
\underbrace{\boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1} \sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_{t,\bot} \hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B} \boldsymbol{w}_m}_{\textup{Bias}} \\& + \underbrace{\boldsymbol{y}^\top \hat{\boldsymbol{B}}_t \sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1} \sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot \xi_{t,m,j}}_{\textup{Variance}} - \underbrace{\boldsymbol{y}^\top \hat{\boldsymbol{B}}_{t,\bot} \hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B} \boldsymbol{w}_m}_{\textup{Estimation error of $\hat{\boldsymbol{B}}_t$}} .
\end{align*}
Taking the absolute value on both sides, and using the Cauchy–Schwarz inequality and definition of event $\mathcal{F}$ (Eq.~\eqref{eq:definition_cF}), we have
\begin{align*}
& \abr{\boldsymbol{y}^\top \hat{\boldsymbol{\theta}}_{t,m}-\boldsymbol{y}^\top \boldsymbol{\theta}_m}
\\
\leq & \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1}} \cdot \nbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} \cdot {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_{t,\bot} \hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B} \boldsymbol{w}_m}_{\sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1}} \\& + \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1}} \sqrt{2\log \sbr{\frac{4n^2 M}{\delta_t}}} + \abr{\boldsymbol{y}^\top \hat{\boldsymbol{B}}_{t,\bot} \hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B} \boldsymbol{w}_m}
\\
\overset{\textup{(a)}}{\leq} & \frac{ \sqrt{1+\zeta} \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\sbr{\sum_{i=1}^{n} \lambda^{G}_{t,m}(\boldsymbol{x}_i) \cdot \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}}{\sqrt{N_{t,m}}} \cdot L_{x} L_{w} \nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \cdot \sum_{j=1}^{N_{t,m}} \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j}}_{\sbr{\sum_{j=1}^{N_{t,m}} \hat{\boldsymbol{B}}_t^\top \boldsymbol{z}_{t,m,j} {\boldsymbol{z}_{t,m,j}}^\top \hat{\boldsymbol{B}}_t}^{-1}} \\& + \frac{ \sqrt{1+\zeta} \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\sbr{\sum_{i=1}^{n} \lambda^{G}_{t,m}(\boldsymbol{x}_i) \cdot \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}}{\sqrt{N_{t,m}}} \cdot \sqrt{2\log \sbr{\frac{4n^2 M}{\delta_t}}} + 2 L_{x} L_{w} \nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}}
\\
\overset{\textup{(b)}}{\leq} & \frac{ \sqrt{1+\zeta} \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\sbr{\sum_{i=1}^{n} \lambda^{G}_{t,m}(\boldsymbol{x}_i) \cdot \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}}{\sqrt{N_{t,m}}} \cdot L_{x} L_{w} \nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \cdot \sqrt{k N_{t,m}} \\& + \frac{ \sqrt{1+\zeta} \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\sbr{\sum_{i=1}^{n} \lambda^{G}_{t,m}(\boldsymbol{x}_i) \cdot \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}}{\sqrt{N_{t,m}}} \cdot \sqrt{2\log \sbr{\frac{4n^2 M}{\delta_t}}} + 2 L_{x} L_{w} \nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}}
\\
\leq & \sqrt{1+\zeta} \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\sbr{\sum_{i=1}^{n} \lambda^{G}_{t,m}(\boldsymbol{x}_i) \cdot \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}} \cdot L_{x} L_{w} \nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \cdot \sqrt{k} \\& + \frac{ \sqrt{1+\zeta} \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\sbr{\sum_{i=1}^{n} \lambda^{G}_{t,m}(\boldsymbol{x}_i) \cdot \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}}{\sqrt{N_{t,m}}} \cdot \sqrt{2\log \sbr{\frac{4n^2 M}{\delta_t}}} + 2 L_{x} L_{w} \nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}}
\\
\leq & \sqrt{(1+\zeta) \cdot k \cdot \rho^{G}_{t,m}} \cdot L_{x} L_{w} \nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} + \frac{ \sqrt{(1+\zeta) \cdot \rho^{G}_{t,m} \cdot 2\log \sbr{\frac{4n^2 M}{\delta_t}} } }{\sqrt{N_{t,m}}} + 2 L_{x} L_{w} \nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}}
\\
\overset{\textup{(c)}}{\leq} & \sqrt{(1+\zeta) \cdot 4 k^2} \cdot L_{x} L_{w} \nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} + \frac{ \sqrt{(1+\zeta) \cdot \rho^{G}_{t,m} \cdot 2\log \sbr{\frac{4n^2 M}{\delta_t}} } }{\sqrt{N_{t,m}}} + 2 L_{x} L_{w} \nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}}
\\
\overset{\textup{(d)}}{\leq} & \sqrt{(1+\zeta) \cdot 4 k^2} \cdot L_{x} L_{w} \cdot \frac{1}{8 k L_{x} L_{w} \cdot 2^t \sqrt{1+\zeta}} + \frac{1}{4 \cdot 2^t} + 2 L_{x} L_{w} \cdot \frac{1}{8 k L_{x} L_{w} \cdot 2^t \sqrt{1+\zeta}}
\\
\leq & \frac{1}{4 \cdot 2^t} + \frac{1}{4 \cdot 2^t} + \frac{1}{4 \cdot 2^t}
\\
\leq & \frac{1}{2^t} .
\end{align*}
Here inequality (a) is due to the guarantee of rounding procedure $\mathtt{ROUND}$ and the triangle inequality. Inequality (b) uses Lemma~\ref{lemma:sqrt_n_k}, and inequality (c) follows from Lemma~\ref{lemma:rho_t_leq_4k}. Inequality (d) comes from Lemma~\ref{lemma:concentration_B_hat_t} and $N_{t,m}:=\max \{ \lceil 32 \cdot 2^{2t} (1+\zeta) \rho^{G}_{t,m} \log (\frac{4n^2 M}{\delta_t}) \rceil,\ \frac{180k}{\zeta^2} \}$.
\end{proof}
For any task $m \in [M]$ and arm $\boldsymbol{x} \in \mathcal{X}$, let $\Delta_m(\boldsymbol{x}):=({\boldsymbol{x}^{*}_{m}} - \boldsymbol{x})^\top \boldsymbol{\theta}_m$ denote the reward gap between the optimal arm $\boldsymbol{x}^{*}_{m}$ and arm $\boldsymbol{x}$ in task $m$.
For any phase $t>0$ and task $m \in [M]$, let $\mathcal{Z}_{t,m}:=\{ \boldsymbol{x} \in \mathcal{X} : \Delta_{m}(\boldsymbol{x}) \leq 4 \cdot 2^{-t} \}$.
\begin{lemma} \label{lemma:cX_subseteq_cS}
Suppose that event $\mathcal{E} \cap \mathcal{F}$ holds. For any phase $t>0$ and task $m \in [M]$,
\begin{align*}
\boldsymbol{x}^{*}_{m} \in \hat{\mathcal{X}}_{t,m} ,
\end{align*}
and for any phase $t\geq2$ and task $m \in [M]$,
\begin{align*}
\hat{\mathcal{X}}_{t,m} \subseteq \mathcal{Z}_{t,m} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:cX_subseteq_cS}]
This proof follows a similar analytical procedure as that of Lemma~2 in \cite{fiez2019sequential}.
First, we prove $\boldsymbol{x}^{*}_{m} \in \hat{\mathcal{X}}_{t,m}$ for any phase $t>0$ and task $m \in [M]$ by contradiction.
Suppose that for some $t>0$ and some $m \in [M]$, $\boldsymbol{x}^{*}_{m}$ is eliminated from $\hat{\mathcal{X}}_{t,m}$ in phase $t$.
Then, we have that there exists some $\boldsymbol{x}' \in \hat{\mathcal{X}}_{t,m}$ such that
\begin{align*}
(\boldsymbol{x}'-\boldsymbol{x}^{*}_{m})^\top \hat{\boldsymbol{\theta}}_{t,m} > 2^{-t} .
\end{align*}
Then, we have
\begin{align*}
(\boldsymbol{x}'-\boldsymbol{x}^{*}_{m})^\top \boldsymbol{\theta}_m = & (\boldsymbol{x}'-\boldsymbol{x}^{*}_{m})^\top \hat{\boldsymbol{\theta}}_{t,m} - (\boldsymbol{x}'-\boldsymbol{x}^{*}_{m})^\top \sbr{\hat{\boldsymbol{\theta}}_{t,m} - \boldsymbol{\theta}_m}
\\
\geq & (\boldsymbol{x}'-\boldsymbol{x}^{*}_{m})^\top \hat{\boldsymbol{\theta}}_{t,m} - 2^{-t}
\\
> & 2^{-t} - 2^{-t}
\\
= & 0 ,
\end{align*}
which contradicts the definition of $\boldsymbol{x}^{*}_{m}$. Thus, we obtain that $\boldsymbol{x}^{*}_{m} \in \hat{\mathcal{X}}_{t,m}$ for any phase $t>0$ and task $m \in [M]$.
Next, we prove $\hat{\mathcal{X}}_{t,m} \subseteq \mathcal{Z}_{t,m}$ for any phase $t\geq2$ and task $m \in [M]$, i.e., each $\boldsymbol{x} \in \hat{\mathcal{X}}_{t,m}$ satisfies that $\Delta_m(\boldsymbol{x}) \leq 4 \cdot 2^{-t}$.
Suppose that there exists some phase $t$, some task $m$ and some $\boldsymbol{x} \in \hat{\mathcal{X}}_{t,m}$ such that $\Delta_m(\boldsymbol{x}) > 4 \cdot 2^{-t}$. Then, in phase $t-1 \geq 1$, we have
\begin{align*}
(\boldsymbol{x}^{*}_{m}-\boldsymbol{x})^\top \hat{\boldsymbol{\theta}}_{t-1,m} = & (\boldsymbol{x}^{*}_{m}-\boldsymbol{x})^\top \boldsymbol{\theta}_m - (\boldsymbol{x}^{*}_{m}-\boldsymbol{x})^\top \sbr{\boldsymbol{\theta}_m-\hat{\boldsymbol{\theta}}_{t-1,m}}
\\
\geq & (\boldsymbol{x}^{*}_{m}-\boldsymbol{x})^\top \boldsymbol{\theta}_m - 2^{-(t-1)}
\\
> & 4 \cdot 2^{-t} - 2^{-(t-1)}
\\
= & 2^{-(t-1)} ,
\end{align*}
which implies that $x$ should have been eliminated from $\hat{\mathcal{X}}_{t,m}$ in phase $t-1$, and contradicts our supposition. Thus, we complete the proof.
\end{proof}
\subsection{Proof of Theorem~\ref{thm:bai_ub}}
Before proving Theorem~\ref{thm:bai_ub}, we first introduce a useful lemma.
For any task $m \in [M]$, let
\begin{align*}
\boldsymbol{\lambda}^*_m := & \operatornamewithlimits{argmin}_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{x} \in \mathcal{X} \setminus \{\boldsymbol{x}^{*}_{m}\}} \frac{\| \boldsymbol{B}^\top \boldsymbol{x}^{*}_{m} - \boldsymbol{B}^\top \boldsymbol{x} \|^2_{\sbr{ \sum_{i=1}^{n} \lambda(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} } }{ \sbr{({\boldsymbol{x}^{*}_{m}} - \boldsymbol{x})^\top \boldsymbol{\theta}_m}^2 } ,
\end{align*}
and
\begin{align*}
\rho^*_m := & \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{x} \in \mathcal{X} \setminus \{\boldsymbol{x}^{*}_{m}\}} \frac{\| \boldsymbol{B}^\top \boldsymbol{x}^{*}_{m} - \boldsymbol{B}^\top \boldsymbol{x} \|^2_{\sbr{ \sum_{i=1}^{n} \lambda(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} } }{ \sbr{({\boldsymbol{x}^{*}_{m}} - \boldsymbol{x})^\top \boldsymbol{\theta}_m}^2 } .
\end{align*}
$\boldsymbol{\lambda}^*_m$ and $\rho^*_m$ are the optimal solution and the optimal value of the G-optimal design optimization with true feature extractor $\boldsymbol{B}$, respectively.
\begin{lemma}\label{lemma:connection_ub_lb}
Suppose that event $\mathcal{E} \cap \mathcal{F}$ holds. For any task $m \in [M]$ and $\boldsymbol{y} \in \mathbb{R}^d$,
\begin{align*}
\| \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \|^2_{\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t }^{-1} } \leq \| \boldsymbol{B}^\top \boldsymbol{y} \|^2_{\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} } + \frac{ 11 L_{x}^4 }{ k \omega^2 \cdot 2^t } .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:connection_ub_lb}]
We first handle the term $( \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t )^{-1}$.
For any task $m \in [M]$, we have
\begin{align*}
& \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t
\\
= & \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i + \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i + \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i}^\top
\\
= & \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \Bigg( \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i}^\top + \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i}^\top
\\
& + \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i}^\top + \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i}^\top \Bigg)
\\
= & \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i}^\top
+ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \Bigg( \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i}^\top
\\& + \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i}^\top + \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i}^\top \Bigg) .
\end{align*}
Let $\boldsymbol{P}_t:=\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i) \cdot (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i)^\top$.
Let $\boldsymbol{Q}_t:=\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) ( (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i) \cdot (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i)^\top
+ (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i) \cdot (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i)^\top + (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i) \cdot (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{x}_i)^\top )$.
Then, we have $\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t = \boldsymbol{P}_t+\boldsymbol{Q}_t$.
From Assumption~\ref{assumption:lambda^*_B_x_x_B_invertible}, we have that for any task $m \in [M]$, $\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}$ is invertible.
Since $\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}$ is also invertible, we have that $\boldsymbol{P}_t$ is invertible.
According to Lemmas~\ref{lemma:concentration_B_hat_t} and \ref{lemma:invertible_under_hat_B}, we have that $\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t$ is also invertible.
Thus, we can write $(\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t)^{-1}$ as follows.
\begin{align*}
\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t }^{-1} = & \boldsymbol{P}_t^{-1}-\sbr{\boldsymbol{P}_t + \boldsymbol{Q}_t}^{-1} \boldsymbol{Q}_t \boldsymbol{P}_t^{-1}
\end{align*}
Hence, for any task $m \in [M]$ and $\boldsymbol{y} \in \mathbb{R}^d$, we have
\begin{align}
\|\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}\|^2_{\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t }^{-1}} = &
\sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}^\top \sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t }^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{y}
\nonumber\\
= & \underbrace{\sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}^\top \boldsymbol{P}_t^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\textup{Term 1}} - \underbrace{\sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}^\top \sbr{\boldsymbol{P}_t + \boldsymbol{Q}_t}^{-1} \boldsymbol{Q}_t \boldsymbol{P}_t^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}_{\textup{Term 2}} . \label{eq:norm_B_hat_y_decompose}
\end{align}
From Lemma~\ref{lemma:concentration_B_hat_t}, we have
\begin{align*}
\nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \leq \min\lbr{\frac{1}{8 k \cdot 2^t \sqrt{1+\zeta}},\ \frac{\omega}{6 L_x^2}} \leq \min\lbr{\frac{1}{8 k \cdot 2^t},\ \frac{\omega}{6 L_x^2}} .
\end{align*}
Since $\boldsymbol{B}^\top \hat{\boldsymbol{B}}_{t} \hat{\boldsymbol{B}}_{t}^\top \boldsymbol{B} + \boldsymbol{B}^\top \hat{\boldsymbol{B}}_{t,\bot} \hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B} = \boldsymbol{B}^\top (\hat{\boldsymbol{B}}_{t} \hat{\boldsymbol{B}}_{t}^\top + \hat{\boldsymbol{B}}_{t,\bot} \hat{\boldsymbol{B}}_{t,\bot}^\top) \boldsymbol{B} = \boldsymbol{B}^\top \boldsymbol{B} =\boldsymbol{I}_k$, we have $\sigma^2_{\min} ( \hat{\boldsymbol{B}}_{t}^\top \boldsymbol{B} )=1 - \| \hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B} \|^2$.
Thus, we have
\begin{align*}
\sigma_{\min}(\hat{\boldsymbol{B}}_{t}^\top \boldsymbol{B}) = \sqrt{1 - \nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}}^2} \geq \sqrt{1 - \min\lbr{\frac{1}{64 k^2 \cdot 2^{2t}},\ \frac{\omega^2}{36 L_x^4}} } > 0 ,
\end{align*}
which implies that $\hat{\boldsymbol{B}}_{t}^\top \boldsymbol{B}$ is invertible.
Now, we first analyze Term 1 in Eq.~\eqref{eq:norm_B_hat_y_decompose}.
\begin{align*}
\textup{Term 1} = & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}^\top \boldsymbol{P}_t^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{y}
\\
= & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y} + \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y} }^\top \boldsymbol{P}_t^{-1} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y} + \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y} }
\\
\\
= & \underbrace{\sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}}^\top \boldsymbol{P}_t^{-1} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}}}_{\textup{Term 1-1}} + \underbrace{\sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}}^\top \boldsymbol{P}_t^{-1} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y} } }_{\textup{Term 1-2}}
\\
& + \underbrace{\sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y} }^\top \boldsymbol{P}_t^{-1} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}}}_{\textup{Term 1-3}} + \underbrace{\sbr{ \hat{\boldsymbol{B}}_t^\top B_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y} }^\top \boldsymbol{P}_t^{-1} \sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y} }}_{\textup{Term 1-4}} .
\end{align*}
In the following, we bound Terms 1-1, 1-2, 1-3 and 1-4, respectively.
First, we have
\begin{align*}
\textup{Term 1-1} = & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}}^\top \sbr{\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i}^\top}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}
\\
= & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}}^\top \sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \sbr{\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^\top }^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}
\\
= & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}}^\top \sbr{\sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} }^\top \sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}
\\
= & \sbr{\boldsymbol{B}^\top \boldsymbol{y}}^\top \sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} \boldsymbol{B}^\top \boldsymbol{y}
\\
= & \nbr{\boldsymbol{B}^\top \boldsymbol{y}}^2_{\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1}} .
\end{align*}
We note that since $\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \hat{\boldsymbol{B}}_t + \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \hat{\boldsymbol{B}}_t = \hat{\boldsymbol{B}}_t^\top (B \boldsymbol{B}^\top + \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top) \hat{\boldsymbol{B}}_t = \hat{\boldsymbol{B}}_t^\top \hat{\boldsymbol{B}}_t =\boldsymbol{I}_k$, $\sigma^2_{\min}\sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} }=1 - \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot}}^2$.
In addition, $\nbr{\sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1}}=\frac{1}{ \sigma_{\min}(\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}) }=\frac{1}{ \sqrt{1 - \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot}}^2} }$.
Then, second, we have
\begin{align*}
\textup{Term 1-2} = & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}}^\top \sbr{\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i}^\top}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}
\\
= & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}}^\top \sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \sbr{\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^\top }^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}
\\
= & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}}^\top \sbr{\sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} }^\top \sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}
\\
= & \sbr{\boldsymbol{B}^\top \boldsymbol{y}}^\top \sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}
\\
\leq & 2 L_{x} \cdot \frac{1}{\omega} \cdot \frac{1}{ \sqrt{1-\nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot}}^2 } } \cdot \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot}} \cdot 2 L_{x}
\\
\leq & 4 L_{x}^2 \cdot \frac{1}{\omega} \cdot \frac{1}{\sqrt{ 1-\sbr{\frac{1}{8k \cdot 2^t}}^2 }} \cdot \frac{1}{8k \cdot 2^t}
\\
\leq & 4 L_{x}^2 \cdot \frac{1}{\omega} \cdot \frac{1}{\sqrt{ 1-\frac{3}{4} }} \cdot \frac{1}{8k \cdot 2^t}
\\
= & \frac{ L_{x}^2 }{ k \omega \cdot 2^t} .
\end{align*}
Third, we have
\begin{align*}
\textup{Term 1-3} = & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}}^\top \sbr{\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i}^\top}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}
\\
= & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}}^\top \sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \sbr{\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^\top }^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}
\\
= & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}}^\top \sbr{\sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} }^\top \sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{y}
\\
= & \sbr{ \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}}^\top \sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} \boldsymbol{B}^\top \boldsymbol{y} ,
\\
\leq & \frac{1}{ \sqrt{1-\nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot}}^2 } } \cdot \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot}} \cdot 2 L_{x} \cdot \frac{1}{\omega} \cdot 2 L_{x}
\\
\leq & 4 L_{x}^2 \cdot \frac{1}{\omega} \cdot \frac{1}{\sqrt{ 1-\sbr{\frac{1}{8k \cdot 2^t}}^2 }} \cdot \frac{1}{8k \cdot 2^t}
\\
\leq & 4 L_{x}^2 \cdot \frac{1}{\omega} \cdot \frac{1}{\sqrt{ 1-\frac{3}{4} }} \cdot \frac{1}{8k \cdot 2^t}
\\
= & \frac{ L_{x}^2 }{k \omega \cdot 2^t} .
\end{align*}
Finally, we have
\begin{align*}
\textup{Term 1-4} = & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}}^\top \sbr{\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i} \cdot \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \boldsymbol{B}^\top \boldsymbol{x}_i}^\top}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}
\\
= & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}}^\top \sbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B} \sbr{\sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^\top }^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}
\\
= & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}}^\top \sbr{\sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} }^\top \sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}
\\
= & \sbr{ \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y}}^\top \sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1} \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}}^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} \boldsymbol{B}_{\bot}^\top \boldsymbol{y} ,
\\
\leq & \sbr{\frac{1}{ \sqrt{1-\nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot}}^2 } } \cdot \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot}} \cdot 2 L_{x} }^2 \cdot \frac{1}{\omega}
\\
\leq & \sbr{ 2 L_{x} \cdot \frac{1}{\sqrt{ 1-\sbr{\frac{1}{8k \cdot 2^t}}^2 }} \cdot \frac{1}{8k \cdot 2^t} }^2 \cdot \frac{1}{\omega}
\\
\leq & \sbr{ 2 L_{x} \cdot \frac{1}{\sqrt{ 1-\frac{3}{4} }} \cdot \frac{1}{8k \cdot 2^t} }^2 \cdot \frac{1}{\omega}
\\
= & \frac{L_{x}^2}{4k^2 \omega \cdot 2^{2t}} .
\end{align*}
Thus, we have
\begin{align}
\textup{Term 1} = & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}^\top \boldsymbol{P}_t^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{y}
\nonumber\\
\leq & \nbr{\boldsymbol{B}^\top \boldsymbol{y}}^2_{\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1}} + \frac{ 2L_{x}^2 }{k \omega \cdot 2^t} + \frac{L_{x}^2}{4k^2 \omega \cdot 2^{2t}}
\nonumber\\
\leq & \nbr{\boldsymbol{B}^\top \boldsymbol{y}}^2_{\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1}} + \frac{ 3L_{x}^2 }{k \omega \cdot 2^t} . \label{eq:term1_ub}
\end{align}
Next, we investigate Term 2. In order to bound Term 2, we first bound the minimum singular value of $\boldsymbol{P}_t$ and the maximum singular value of $\boldsymbol{Q}_t$.
Since $\boldsymbol{P}_t=\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} (\sum_{i=1}^{n} \lambda^*(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}) (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B})^\top$, we have
\begin{align*}
\sigma_{\min}(\boldsymbol{P}_t) \geq & \sigma^2_{\min}(\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}) \cdot \omega
\\
= & \sbr{1-\|\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot}\|^2 } \omega
\\
\geq & \sbr{ 1-\frac{1}{8^2 k^2 \cdot 2^{2t}} } \omega
\\
\geq & \frac{3}{4} \omega .
\end{align*}
Since $\boldsymbol{Q}_t=\hat{\boldsymbol{B}}_t^\top \boldsymbol{B} (\sum_{i=1}^{n} \lambda^*(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}_{\bot} ) (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot})^\top
+ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} (\sum_{i=1}^{n} \lambda^*(\boldsymbol{x}_i) \boldsymbol{B}^\top_{\bot} \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} ) (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B})^\top + \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} (\sum_{i=1}^{n} \lambda^*(\boldsymbol{x}_i) \boldsymbol{B}^\top_{\bot} \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}_{\bot} ) (\hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot})^\top $, we have
\begin{align*}
\sigma_{\max}(\boldsymbol{Q}_t) \leq & 3 L_{x}^2 \nbr{ \hat{\boldsymbol{B}}_t^\top \boldsymbol{B}_{\bot} }
\\
\leq & \min \lbr{ \frac{3 L_{x}^2}{8k \cdot 2^t} , \ \frac{ \omega }{2} } .
\end{align*}
Then, we can bound Term 2 as
\begin{align}
\textup{Term 2} = & \sbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}^\top \sbr{\boldsymbol{P}_t + \boldsymbol{Q}_t}^{-1} \boldsymbol{Q}_t \boldsymbol{P}_t^{-1} \hat{\boldsymbol{B}}_t^\top \boldsymbol{y}
\nonumber\\
\leq & \nbr{\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}}^2 \cdot \nbr{\sbr{\boldsymbol{P}_t + \boldsymbol{Q}_t}^{-1}} \cdot \nbr{\boldsymbol{Q}_t} \cdot \nbr{\boldsymbol{P}_t^{-1}}
\nonumber\\
\leq & \frac{ 4 L_{x}^2 \cdot \sigma_{\max}\sbr{\boldsymbol{Q}_t} }{ \sigma_{\min}\sbr{\boldsymbol{P}_t + \boldsymbol{Q}_t} \cdot \sigma_{\min}\sbr{\boldsymbol{P}_t} }
\nonumber\\
\leq & \frac{ 4 L_{x}^2 \cdot \sigma_{\max}\sbr{\boldsymbol{Q}_t} }{ \sbr{\sigma_{\min}\sbr{\boldsymbol{P}_t} - \sigma_{\max}\sbr{\boldsymbol{Q}_t}} \cdot \sigma_{\min}\sbr{\boldsymbol{P}_t} }
\nonumber\\
\leq & \frac{ 4 L_{x}^2 \cdot \frac{3 L_{x}^2}{8k \cdot 2^t} }{ \sbr{ \frac{3}{4} \omega - \frac{ 1 }{2} \omega } \cdot \frac{3}{4} \omega }
\nonumber\\
= & \frac{ 8 L_{x}^4 }{ k \omega^2 \cdot 2^t } . \label{eq:term2_ub}
\end{align}
Plugging Eqs.~\eqref{eq:term1_ub} and \eqref{eq:term2_ub} into Eq.~\eqref{eq:norm_B_hat_y_decompose}, we have
\begin{align*}
\|\hat{\boldsymbol{B}}_t^\top \boldsymbol{y}\|^2_{\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t }^{-1}} \leq & \nbr{\boldsymbol{B}^\top \boldsymbol{y}}^2_{\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1}} + \frac{ 3L_{x}^2 }{k \omega \cdot 2^t} + \frac{ 8 L_{x}^4 }{ k \omega^2 \cdot 2^t } .
\\
\leq & \nbr{\boldsymbol{B}^\top \boldsymbol{y}}^2_{\sbr{ \sum_{i=1}^{n} \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B} }^{-1}} + \frac{ 11 L_{x}^4 }{ k \omega^2 \cdot 2^t } .
\end{align*}
\end{proof}
Below we prove the sample complexity for algorithm $\mathtt{DouExpDes}$ (Theorem~\ref{thm:bai_ub}).
\begin{proof}[Proof of Theorem~\ref{thm:bai_ub}]
According to Lemmas~\ref{lemma:Z_t_est_error} and \ref{lemma:concentration_variance_bai}, we have $\Pr [\mathcal{E} \cap \mathcal{F}] \geq 1-\delta$. Below, supposing that event $\mathcal{E} \cap \mathcal{F}$ holds, we prove the correctness and sample complexity.
We first prove the correctness.
For any task $m \in [M]$, let $t^{*}_m$ denote the first phase which satisfies $|\hat{\mathcal{X}}_{t,m}|=1$. Let $t_*=\max_{m \in [M]} t^{*}_m$ denote the total number of phases used.
For any task $m \in [M]$, let $\Delta_{m,\min}:=\min_{\boldsymbol{x} \in \mathcal{X} \setminus \{\boldsymbol{x}^{*}_{m}\}} (\boldsymbol{x}^{*}_{m} - \boldsymbol{x})^\top \boldsymbol{\theta}_m$ denote the minimum reward gap for task $m$. Let $\Delta_{\min}:=\min_{m \in [M]} \Delta_{\min,m}$ denote the minimum reward gap among all tasks.
From Lemma~\ref{lemma:cX_subseteq_cS}, we can obtain the following facts: (i) For any task $m \in [M]$, the optimal arm $\boldsymbol{x}^{*}_{m}$ will never be eliminated. (ii) $t^{*}_m \leq \lceil \log(\frac{4}{\Delta_{m,\min}}) \rceil +1$, and thus, $t_*\leq \lceil \log(\frac{4}{\Delta_{\min}}) \rceil +1$. Therefore, after at most $\lceil \log(\frac{4}{\Delta_{\min}}) \rceil +1$ phases, algorithm $\mathtt{DouExpDes}$ will return the optimal arms $\boldsymbol{x}^{*}_{m}$ for all tasks $m \in [M]$.
Now we prove the sample complexity.
In the following, we first prove that the sample complexity of algorithm $\mathtt{DouExpDes}$ is bounded by $\tilde{O} ( \frac{M k}{\Delta_{\min}^2} \log(\delta^{-1}) + (\rho^E)^2 d k^4 L_{x}^2 L_{w}^2 D \log^4(\delta^{-1}) )$.
Recall that $p=\frac{180d}{\zeta^2}$ and $\zeta=\frac{1}{10}$. Then, summing the number of samples used in subroutines $\mathtt{FeatRecover}$ and $\mathtt{EliLowRep}$ in all phases (Line~\ref{line:bai_stage2_sample} in Algorithm~\ref{alg:feat_recover}, Line~\ref{line:bai_stage3_sample} in Algorithm~\ref{alg:elim_low_rep}), we have that the total number of samples is
\begin{align}
& \sum_{t=1}^{t^*} p M T_t + \sum_{m=1}^{M} \sum_{t=1}^{t^{*}_m} N_{t,m}
\nonumber\\
= & \sum_{t=1}^{t^*} p \cdot O \Bigg( \sbr{1+\zeta}^3 (\rho^E)^2 k^4 L_{x}^2 L_{\theta}^2 \max\lbr{2^{2t},\ \frac{L_{x}^4}{\omega^2}} \log^2 \sbr{\frac{p}{\delta_t}} \cdot \nonumber\\& \hspace*{5em} \log^2 \sbr{ \sbr{1+\zeta} \rho^E k p L_{x} L_{\theta} \max\lbr{2^t,\ \frac{L_{x}}{\omega}} \frac{1}{\delta_t} \log\sbr{\frac{p}{\delta_t}} } \Bigg)
\nonumber\\
& + \sum_{m=1}^{M} \sum_{t=1}^{t^{*}_m} O\sbr{ 2^{2t} (1+\zeta) \rho^{G}_{t,m} \log \sbr{\frac{n^2 M}{\delta_t}} + \frac{k}{\zeta^2} }
\nonumber\\
= & \sum_{t=1}^{O(\log(\Delta_{\min}^{-1}))} O \Bigg( (\rho^E)^2 k^4 d L_{x}^2 L_{\theta}^2 \max\lbr{2^{2t},\ \frac{L_{x}^4}{\omega^2}} \log^2 \sbr{\frac{d \log(\Delta_{\min}^{-1})}{\delta}} \cdot \nonumber\\& \hspace*{5em} \log^2 \sbr{ \rho^E k d L_{x} L_{\theta} \max\lbr{\Delta_{\min}^{-1},\ \frac{L_{x}}{\omega}} \frac{\log(\Delta_{\min}^{-1})}{\delta} \log\sbr{\frac{d \log(\Delta_{\min}^{-1})}{\delta}} } \Bigg)
\nonumber\\
& + \sum_{m=1}^{M} \sum_{t=1}^{O(\log(\Delta_{m,\min}^{-1}))} O\sbr{ 2^{2t} \rho^{G}_{t,m} \log \sbr{\frac{n^2 M \log(\Delta_{m,\min}^{-1}) }{\delta}} + k}
\label{eq:bai_sample_complexity} \\
= & O \Bigg( (\rho^E)^2 k^4 d L_{x}^2 L_{\theta}^2 \max\lbr{ \Delta_{\min}^{-2} ,\ \frac{ L_{x}^4 \log(\Delta_{\min}^{-1}) }{\omega^2} } \log^2 \sbr{\frac{d \log(\Delta_{\min}^{-1})}{\delta}} \cdot \nonumber\\& \hspace*{5em} \log^2 \sbr{ \rho^E k d L_{x} L_{\theta} \max\lbr{\Delta_{\min}^{-1},\ \frac{L_{x}}{\omega}} \frac{\log(\Delta_{\min}^{-1})}{\delta} \log\sbr{\frac{d \log(\Delta_{\min}^{-1})}{\delta}} } \Bigg)
\nonumber\\
& + O\sbr{ M k \Delta_{\min}^{-2} \log \sbr{\frac{n^2 M \log(\Delta_{\min}^{-1})}{\delta}} } . \nonumber
\end{align}
\end{proof}
Next, we prove that the sample complexity of algorithm $\mathtt{DouExpDes}$ is bounded by
$
\tilde{O} ( \sum_{m=1}^{M} \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{x} \in \mathcal{X} \setminus \{\boldsymbol{x}^{*}_{m}\}} \frac{\| \boldsymbol{B}^\top (\boldsymbol{x}^{*}_{m} - \boldsymbol{x}) \|^2_{\boldsymbol{A}(\boldsymbol{\lambda})^{-1}} }{ ((\boldsymbol{x}^{*}_{m} - \boldsymbol{x})^\top \boldsymbol{\theta}_m)^2 } \log (\delta^{-1}) + (\rho^E)^2 d k^4 L_{x}^2 L_{w}^2 D \log^4 (\delta^{-1}) ) .
$
From Eq.~\eqref{eq:bai_sample_complexity}, we have that with probability $1-\delta$, the number of samples used by algorithm $\mathtt{DouExpDes}$ is bounded by
\begin{align}
\tilde{O} \Bigg( \sum_{t=1}^{\log(\Delta_{\min}^{-1})} (\rho^E)^2 k^4 d L_{x}^2 L_{\theta}^2 \max\lbr{2^{2t},\ \frac{L_{x}^4}{\omega^2}} + \sum_{m=1}^{M} \sum_{t=1}^{\log(\Delta_{m,\min}^{-1})} 2^{2t} \rho^{G}_{t,m} + Mk \Bigg) . \label{eq:bai_sample_complexity_tilde}
\end{align}
For any $\mathcal{Z} \subseteq \mathcal{X}$, $\mathcal{Y}(\mathcal{Z}):=\{ \boldsymbol{x}-\boldsymbol{x}':\ \forall \boldsymbol{x},\boldsymbol{x}' \in \mathcal{Z},\ \boldsymbol{x} \neq \boldsymbol{x}' \}$ and $\mathcal{Y}^*_m(\mathcal{Z}):=\{ \boldsymbol{x}^{*}_{m}-\boldsymbol{x}:\ \forall \boldsymbol{x} \in \mathcal{Z},\ \boldsymbol{x} \neq \boldsymbol{x}^{*}_{m} \}$.
Then, we have that for any task $m \in [M]$ and phase $t\geq 2$,
\begin{align}
\sbr{2^t}^2 \rho^{G}_{t,m}
= & \sbr{2^t}^2 \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{y} \in \mathcal{Y}(\hat{\mathcal{X}}_{t,m})} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}
\nonumber\\
\leq & \sbr{2^t}^2 \max_{\boldsymbol{y} \in \mathcal{Y}(\hat{\mathcal{X}}_{t,m})} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}
\nonumber\\
\overset{\textup{(a)}}{\leq} & \sbr{2^t}^2 \max_{\boldsymbol{y} \in \mathcal{Y}(\mathcal{Z}_{t,m})} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}
\nonumber\\
\overset{\textup{(b)}}{\leq} & 4 \sbr{2^t}^2 \max_{\boldsymbol{y} \in \mathcal{Y}^*_m(\mathcal{Z}_{t,m})} \| \hat{\boldsymbol{B}}_t^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda^*_m(\boldsymbol{x}_i) \hat{\boldsymbol{B}}_t^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \hat{\boldsymbol{B}}_t}^{-1}}
\nonumber\\
\overset{\textup{(c)}}{\leq} & 4 \sbr{2^t}^2 \sbr{\max_{\boldsymbol{y} \in \mathcal{Y}^*_m(\mathcal{Z}_{t,m})} \| \boldsymbol{B}^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}}^{-1}} + \frac{ 11 L_{x}^4 }{ \omega^2 k \cdot 2^t } }
\nonumber\\
= & 4 \sbr{ \frac{16 \max_{\boldsymbol{y} \in \mathcal{Y}^*_m(\mathcal{Z}_{t,m})} \| \boldsymbol{B}^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}}^{-1}}}{\sbr{4 \cdot 2^{-t}}^2} + \frac{ 11 L_{x}^4 \cdot 2^t }{ \omega^2 k } }
\nonumber\\
\overset{\textup{(d)}}{\leq} & 4 \sbr{ 16 \max_{\boldsymbol{y} \in \mathcal{Y}^*_m(\mathcal{Z}_{t,m})} \frac{\| \boldsymbol{B}^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}}^{-1}}}{ \sbr{\boldsymbol{y}^\top \boldsymbol{\theta}_m}^2} + \frac{ 11 L_{x}^4 \cdot 2^t }{ \omega^2 k } }
\nonumber\\
\leq & 4 \sbr{ 16 \max_{\boldsymbol{y} \in \mathcal{Y}^*_m(\mathcal{X})} \frac{\| \boldsymbol{B}^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda^*_m(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}}^{-1}}}{ \sbr{\boldsymbol{y}^\top \boldsymbol{\theta}_m}^2} + \frac{ 11 L_{x}^4 \cdot 2^t }{ \omega^2 k } }
\nonumber\\
\overset{\textup{(e)}}{=} & 4 \sbr{ 16 \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{y} \in \mathcal{Y}^*_m(\mathcal{X})} \frac{\| \boldsymbol{B}^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}}^{-1}}}{ \sbr{\boldsymbol{y}^\top \boldsymbol{\theta}_m}^2} + \frac{ 11 L_{x}^4 \cdot 2^t }{ \omega^2 k } } . \label{eq:connection_ub_lb}
\end{align}
Here inequality (a) is due to $\hat{\mathcal{X}}_{t,m} \subseteq \mathcal{Z}_{t,m}$ (from Lemma~\ref{lemma:cX_subseteq_cS}). Inequality (b) uses the fact that for any $\boldsymbol{y}=\boldsymbol{x}_i-\boldsymbol{x}_j \in \mathcal{Y}(\mathcal{Z}_{t,m})$, we can write $\boldsymbol{y}=(\boldsymbol{x}^{*}_{m}-\boldsymbol{x}_j)-(\boldsymbol{x}^{*}_{m}-\boldsymbol{x}_i)$, and the triangle inequality. Inequality (c) follows from Lemma~\ref{lemma:connection_ub_lb}, and inequality (d) is due to that for any $\boldsymbol{y} \in \mathcal{Y}^*_m(\mathcal{Z}_{t,m})$, $\boldsymbol{y}^\top \boldsymbol{\theta}_m \leq 4 \cdot 2^{-t}$ (from the definition of $\mathcal{Z}_{t,m}$). Equality (e) comes from the definition of $\boldsymbol{\lambda}^*_m$.
Let $L:=\log^2 (\frac{d \log(\Delta_{\min}^{-1})}{\delta}) \cdot \log^2 (\rho^E k d L_{x} L_{\theta} \max \{\Delta_{\min}^{-1},\ \frac{L_{x}}{\omega}\} \frac{\log(\Delta_{\min}^{-1})}{\delta} \log (\frac{d \log(\Delta_{\min}^{-1})}{\delta}) ) $.
Plugging Eq.~\eqref{eq:connection_ub_lb} into Eq.~\eqref{eq:bai_sample_complexity_tilde}, we have that with probability $1-\delta$, the number of samples used by algorithm $\mathtt{DouExpDes}$ is bounded by
\begin{align*}
& O \sbr{ \sum_{m=1}^{M} \!\!\! \sum_{t=1}^{\log(\Delta_{m,\min}^{-1})} \!\!\!\!\!\! 2^{2t} \rho^{G}_{t,m} \log \sbr{\frac{n^2 M \log(\Delta_{m,\min}^{-1}) }{\delta}} + Mk \log(\Delta_{\min}^{-1}) + \sum_{t=1}^{\log(\Delta_{\min}^{-1})} (\rho^E)^2 k^4 d L_{x}^2 L_{\theta}^2 \max\lbr{2^{2t},\ \frac{L_{x}^4}{\omega^2}} L }
\\
= & O \Bigg( \sum_{m=1}^{M} \sum_{t=2}^{\log(\Delta_{m,\min}^{-1})} \Bigg( \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{y} \in \mathcal{Y}^*_m(\mathcal{X})} \frac{\| \boldsymbol{B}^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}}^{-1}}}{ \sbr{\boldsymbol{y}^\top \boldsymbol{\theta}_m}^2} + \frac{ L_{x}^4 \cdot 2^t }{ \omega^2 k } \Bigg) \cdot \log \sbr{\frac{n^2 M \log(\Delta_{m,\min}^{-1}) }{\delta}} \\& + \sum_{m=1}^{M} \rho^*_{1,m} \log \sbr{\frac{n^2 M \log(\Delta_{m,\min}^{-1}) }{\delta}} + Mk \log(\Delta_{\min}^{-1}) + \sum_{t=1}^{\log(\Delta_{\min}^{-1})} (\rho^E)^2 k^4 d L_{x}^2 L_{\theta}^2 \max\lbr{2^{2t},\ \frac{L_{x}^4}{\omega^2}} \cdot L \Bigg)
\\
\overset{\textup{(a)}}{=} & O \Bigg( \sum_{m=1}^{M} \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{y} \in \mathcal{Y}^*_m(\mathcal{X})} \frac{\| \boldsymbol{B}^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}}^{-1}}}{ \sbr{\boldsymbol{y}^\top \boldsymbol{\theta}_m}^2} \cdot \log \sbr{\frac{n^2 M \log(\Delta_{m,\min}^{-1}) }{\delta}} \cdot \log(\Delta_{m,\min}^{-1}) \\& + \frac{ M L_{x}^4 }{ \omega^2 k \cdot \Delta_{\min} } \cdot \log \sbr{\frac{n^2 M \log(\Delta_{\min}^{-1}) }{\delta}} + Mk \cdot \log \sbr{\frac{n^2 M \log(\Delta_{\min}^{-1}) }{\delta}} \cdot \log(\Delta_{\min}^{-1}) \\& \qquad + (\rho^E)^2 k^4 d L_{x}^2 L_{\theta}^2 \max\lbr{ \Delta_{\min}^{-2} ,\ \frac{L_{x}^4 \cdot \log(\Delta_{\min}^{-1})}{\omega^2}} \cdot L \Bigg) ,
\end{align*}
where equality (a) uses Lemma~\ref{lemma:rho_t_leq_4k}.
When $L_x=\omega=\Theta(1)$, we have that with probability $1-\delta$, the sample complexity of algorithm $\mathtt{DouExpDes}$ is bounded by
\begin{align*}
\tilde{O} \Bigg( \sum_{m=1}^{M} \min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{X}}} \max_{\boldsymbol{y} \in \mathcal{Y}^*_m(\mathcal{X})} \frac{\| \boldsymbol{B}^\top \boldsymbol{y} \|^2_{\sbr{\sum_{i=1}^n \lambda(\boldsymbol{x}_i) \boldsymbol{B}^\top \boldsymbol{x}_i \boldsymbol{x}_i^\top \boldsymbol{B}}^{-1}}}{ \sbr{\boldsymbol{y}^\top \boldsymbol{\theta}_m}^2} \log\sbr{\frac{1}{\delta}} + (\rho^E)^2 k^4 d L_{x}^2 L_{\theta}^2 \max\lbr{ \Delta_{\min}^{-2} ,\ \frac{L_{x}^4}{\omega^2}} \log^4\sbr{\frac{1}{\delta}} \Bigg) .
\end{align*}
\section{Proofs for Algorithm~$\mathtt{C \hyphen DouExpDes}$}
In this section, we present the proofs for Algorithm~$\mathtt{C \hyphen DouExpDes}$.
\subsection{Context Distribution Estimation and Sample Batch Planning} \label{apx:bpi_sample_batch_planning}
Define $\lambda_{\mathcal{D}}^{E}$ and $\rho_{\mathcal{D}}^{E}$ as the optimal solution and the optimal value of the following E-optimal design optimization:
\begin{align}
\min_{\boldsymbol{\lambda} \in \triangle_{\mathcal{A}}} \nbr{ \sbr{ \sum_{a \in \mathcal{A}} \lambda(a) \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} }^{-1} } . \label{eq:E_optimal_design}
\end{align}
\begin{lemma}\label{lemma:bound_rho_E_cD}
It holds that
\begin{align*}
\rho_{\mathcal{D}}^{E} \leq \frac{1}{\nu} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:bound_rho_E_cD}]
The optimization in Eq.~\eqref{eq:E_optimal_design} is equivalent to maximize the minimum singular value of the matrix $\sum_{a \in \mathcal{A}} \lambda(a) \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top}$.
Thus, $\lambda_{\mathcal{D}}^{E}$ is the optimal solution of the following optimization:
\begin{align*}
\max_{\boldsymbol{\lambda} \in \triangle_{\mathcal{A}}} \sigma_{\min} \sbr{ \sum_{a \in \mathcal{A}} \lambda(a) \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} } .
\end{align*}
Using Assumption~\ref{assumption:bpi_rho_E_D_is_finite}, we have
\begin{align*}
\sigma_{\min} \sbr{ \sum_{a \in \mathcal{A}} \lambda_{\mathcal{D}}^{E} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} } \geq \nu .
\end{align*}
Then, we have
\begin{align*}
\rho_{\mathcal{D}}^{E} = & \nbr{ \sbr{ \sum_{a \in \mathcal{A}} \lambda_{\mathcal{D}}^{E} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} }^{-1} }
\\
= & \frac{1}{\sigma_{\min} \sbr{ \sum_{a \in \mathcal{A}} \lambda_{\mathcal{D}}^{E} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} }}
\\
\leq & \frac{1}{\nu} .
\end{align*}
\end{proof}
Define event
\begin{align*}
\mathcal{K}:= \lbr{ \nbr{ \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{ \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top } - \mathbb{E}_{s \sim \mathcal{D}} \mbr{ \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top } } \leq \frac{ 8 L_{\phi}^2 \log \sbr{\frac{20d |\mathcal{A}|}{\delta}} }{ \sqrt{T_0} } , \ \forall a \in \mathcal{A} } .
\end{align*}
\begin{lemma} \label{lemma:number_of_samples_T0}
It holds that
\begin{align*}
\Pr \mbr{\mathcal{K}} \geq 1-\frac{\delta}{5} .
\end{align*}
Furthermore, if event $\mathcal{K}$ holds and
\begin{align*}
%
T_0 = \left \lceil \frac{32^2 (1+\zeta)^2 L_{\phi}^4}{\nu^2} \log^2 \sbr{\frac{20d |\mathcal{A}|}{\delta}} \right \rceil ,
\end{align*}
we have that for any $a \in \mathcal{A}$,
\begin{align*}
\nbr{ \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{ \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top } - \mathbb{E}_{s \sim \mathcal{D}} \mbr{ \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top } } \leq & \frac{\nu}{ 4(1+\zeta) } .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:number_of_samples_T0}]
For any $(s,a) \in \mathcal{S} \times \mathcal{A}$, $\| \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top \| \leq L_{\phi}^2$. Then, using the matrix Bernstern inequality (Lemma~\ref{lemma:matrix_bernstein_tau}) and a union bound over $a \in \mathcal{A}$, we have that with probability $1-\frac{\delta}{5}$, for any $a \in \mathcal{A}$,
\begin{align*}
\nbr{ \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{ \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top } - \mathbb{E}_{s \sim \mathcal{D}} \mbr{ \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top } } \leq & 4 L_{\phi}^2 \sqrt{ \frac{ \log \sbr{\frac{10 \cdot 2d |\mathcal{A}|}{\delta}} }{ T_0 } } + \frac{ 4 L_{\phi}^2 \log \sbr{\frac{10 \cdot 2d |\mathcal{A}|}{\delta}} }{ T_0 }
\\
\leq & \frac{ 8 L_{\phi}^2 \log \sbr{\frac{20d |\mathcal{A}|}{\delta}} }{ \sqrt{T_0} } .
\end{align*}
If $T_0 \geq 32^2 (1+\zeta)^2 \nu^{-2} L_{\phi}^4 \log^2 \sbr{\frac{20d |\mathcal{A}|}{\delta}}$, we have
\begin{align*}
\nbr{ \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{ \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top } - \mathbb{E}_{s \sim \mathcal{D}} \mbr{ \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top } } \leq \frac{\nu}{ 4(1+\zeta) } ,
\end{align*}
which completes the proof.
\end{proof}
Define event
\begin{align*}
\mathcal{L}:= \Bigg\{ & \nbr{ \sum_{i=1}^{p} \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i) \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)^\top - \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } \leq 8 L_{\phi}^2 \sqrt{ p } \log \sbr{\frac{40dMT}{\delta}} , \\& \forall m \in [M], \ \forall j \in [T], \ \forall \ell \in \{1,2\} \Bigg\} .
\end{align*}
\begin{lemma} \label{lemma:number_of_samples_p}
It holds that
\begin{align*}
\Pr \mbr{\mathcal{L}} \geq 1 - \frac{\delta}{5} .
\end{align*}
Furthermore, if event $\mathcal{L}$ holds and
\begin{align}
p = \left \lceil \frac{32^2 (1+\zeta)^2 L_{\phi}^4}{\nu^2} \log^2 \sbr{\frac{40dMT}{\delta}} \right \rceil , \label{eq:value_p}
\end{align}
we have that for any $m \in [M]$, $j \in [T]$ and $\ell \in \{1,2\}$,
\begin{align*}
\nbr{ \sum_{i=1}^{p} \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i) \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)^\top - \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } \leq & \frac{p \nu}{ 4(1+\zeta) } .
\end{align*}
Here, the value of $T$ is specified in Eq.~\eqref{eq:value_T}.
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:number_of_samples_p}]
For any $(s,a) \in \mathcal{S} \times \mathcal{A}$, $\| \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top \| \leq L_{\phi}^2$. Then, using the matrix Bernstern inequality (Lemma~\ref{lemma:matrix_bernstein_tau}) and a union bound over $m \in [M]$, $j \in [T]$ and $\ell \in \{1,2\}$, we have that with probability $1-\frac{\delta}{5}$, for any $m \in [M]$, $j \in [T]$ and $\ell \in \{1,2\}$,
\begin{align*}
\nbr{ \sum_{i=1}^{p} \! \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i) \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)^\top \!\!-\!\! \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } \leq & 4 L_{\phi}^2 \sqrt{ p \log \sbr{\frac{10 \cdot 4dMT}{\delta}} } \!+\! 4 L_{\phi}^2 \log \sbr{\frac{10 \cdot 4dMT}{\delta}}
\\
\leq & 8 L_{\phi}^2 \sqrt{ p } \log \sbr{\frac{40dMT}{\delta}} .
\end{align*}
In addition, if $p \geq 32^2 (1+\zeta)^2 \nu^{-2} L_{\phi}^4 \log^2 \sbr{\frac{40dMT}{\delta}}$, we have that
\begin{align*}
8 L_{\phi}^2 \sqrt{ p } \log \sbr{\frac{40dMT}{\delta}} \leq \frac{p \nu}{ 4(1+\zeta) }
\end{align*}
and thus,
\begin{align*}
\nbr{ \sum_{i=1}^{p} \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i) \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)^\top - \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } \leq \frac{p \nu}{ 4(1+\zeta) } ,
\end{align*}
which completes the proof.
\end{proof}
For any task $m \in [M]$, round $j \in [T]$ and $\ell \in \{1,2\}$, let
$$
\boldsymbol{\Phi}_{m,j}^{(\ell)} =
\begin{bmatrix}
\boldsymbol{\phi}(s_{m,j,1}^{(\ell)},\bar{a}_1)^\top
\\
\dots
\\
\boldsymbol{\phi}(s_{m,j,p}^{(\ell)},\bar{a}_p)^\top
\end{bmatrix} ,
$$
and
$$
(\boldsymbol{\Phi}_{m,j}^{(\ell)})^{+} = ((\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)})^{-1} (\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} .
$$
\begin{lemma} \label{lemma:norm_Phi_plus}
Suppose that event $\mathcal{K} \cap \mathcal{L}$ holds. Then, for any $m \in [M]$, $j \in [T]$ and $\ell \in \{1,2\}$,
\begin{align*}
\nbr{ (\boldsymbol{\Phi}_{m,j}^{(\ell)})^{+} }
\leq 2 \sqrt{\frac{(1+\zeta)}{p \nu}} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:norm_Phi_plus}]
We first assume that $(\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)}$ is invertible. In our later analysis, we will prove that as long as $T_0$ and $p$ are large enough, $(\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)}$ is invertible.
For any $m \in [M]$, $j \in [T]$ and $\ell \in \{1,2\}$, we have
\begin{align}
\nbr{ (\boldsymbol{\Phi}_{m,j}^{(\ell)})^{+} } = & \nbr{ ((\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)})^{-1} (\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} }
\nonumber\\
= & \sqrt{ \nbr{ ((\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)})^{-1} (\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)} ((\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)})^{-1} } }
\nonumber\\
= & \sqrt{ \nbr{ ((\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)})^{-1} } }
\nonumber\\
= & \frac{1}{ \sqrt{ \sigma_{\min} \sbr{ (\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)} } } } . \label{eq:norm_Phi_plus}
\end{align}
In addition, we have
\begin{align}
& \sigma_{\min} \sbr{ (\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)} }
\nonumber\\
= & \sigma_{\min} \sbr{ \sum_{i=1}^{p} \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i) \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)^\top }
\nonumber\\
= & \sigma_{\min} \sbr{ \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} + \sum_{i=1}^{p} \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i) \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)^\top - \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} }
\nonumber\\
\geq & \sigma_{\min} \sbr{ \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } - \nbr{ \sum_{i=1}^{p} \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i) \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)^\top - \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} }
\nonumber\\
= & \sigma_{\min} \sbr{ \sum_{i=1}^{p} \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} + \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} - \sum_{i=1}^{p} \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } \nonumber\\& - \nbr{ \sum_{i=1}^{p} \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i) \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)^\top - \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} }
\nonumber\\
\geq & \sigma_{\min} \sbr{ \sum_{i=1}^{p} \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } - \nbr{ \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} - \sum_{i=1}^{p} \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } \nonumber\\& - \nbr{ \sum_{i=1}^{p} \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i) \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)^\top - \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} }
\nonumber\\
\geq & \sigma_{\min} \sbr{ \sum_{i=1}^{p} \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } - \sum_{i=1}^{p} \nbr{ \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} - \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } \nonumber\\& - \nbr{ \sum_{i=1}^{p} \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i) \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)^\top - \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} }
\nonumber\\
\geq & \sigma_{\min} \sbr{ \sum_{i=1}^{p} \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } - \frac{p \nu}{ 4(1+\zeta) } - \frac{p \nu}{ 4(1+\zeta) }
, \label{eq:sigma_min_Phi_top_times_Phi}
\end{align}
where the last inequality uses Lemmas~\ref{lemma:number_of_samples_T0} and \ref{lemma:number_of_samples_p}.
In the following, we analyze $\sigma_{\min} (\sum_{i=1}^{p} \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top})$.
According to the guarantee of the rounding procedure $\mathtt{ROUND}$, we have
\begin{align*}
\nbr{ \sbr{ \sum_{i=1}^{p} \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} }^{-1} } \leq & (1+\zeta) \nbr{ \sbr{ p \sum_{a \in \mathcal{A}} \lambda^{E}_{\hat{\mathcal{D}}}(a) \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} }^{-1} }
\\
\leq & (1+\zeta) \nbr{ \sbr{ p \sum_{a \in \mathcal{A}} \lambda^{E}(a) \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} }^{-1} } ,
\end{align*}
which implies that
\begin{align}
& \sigma_{\min}\sbr{ \sum_{i=1}^{p} \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} }
\nonumber\\
\geq & \frac{p}{1+\zeta} \sigma_{\min} \sbr{ \sum_{a \in \mathcal{A}} \lambda^{E}(a) \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} }
\nonumber\\
\geq & \frac{p}{1+\zeta} \sigma_{\min} \Bigg( \sum_{a \in \mathcal{A}} \lambda^{E}(a) \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} \nonumber\\& + \sum_{a \in \mathcal{A}} \lambda^{E}(a) \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} - \sum_{a \in \mathcal{A}} \lambda^{E}(a) \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} \Bigg)
\nonumber\\
\geq & \frac{p}{1+\zeta} \Bigg( \sigma_{\min} \sbr{ \sum_{a \in \mathcal{A}} \lambda^{E}(a) \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} } \nonumber\\& - \nbr{ \sum_{a \in \mathcal{A}} \lambda^{E}(a) \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} - \sum_{a \in \mathcal{A}} \lambda^{E}(a) \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} } \Bigg)
\nonumber\\
\geq & \frac{p}{1+\zeta} \Bigg( \frac{1}{\rho_{\mathcal{D}}^{E}} - \sum_{a \in \mathcal{A}} \lambda^{E}(a) \nbr{ \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} - \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top} } \Bigg)
\nonumber\\
\overset{\textup{(a)}}{\geq} & \frac{p}{1+\zeta} \sbr{ \nu - \frac{\nu}{ 4(1+\zeta) } }
\nonumber\\
\geq & \frac{3p \nu}{ 4(1+\zeta) } , \label{eq:sigma_min_batch_under_hat_cD}
\end{align}
where inequality (a) uses Lemmas~\ref{lemma:bound_rho_E_cD} and \ref{lemma:number_of_samples_T0}.
Plugging Eq.~\eqref{eq:sigma_min_batch_under_hat_cD} into Eq.~\eqref{eq:sigma_min_Phi_top_times_Phi}, we have
\begin{align}
\sigma_{\min} \sbr{ (\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)} } \geq & \frac{3p \nu}{ 4(1+\zeta) } - \frac{p \nu}{ 4(1+\zeta) } - \frac{p \nu}{ 4(1+\zeta) }
\nonumber\\
= & \frac{p \nu}{ 4(1+\zeta) } . \label{eq:sigma_min_Phi_top_Phi_value}
\end{align}
Equations~\eqref{eq:sigma_min_Phi_top_times_Phi} and \eqref{eq:sigma_min_Phi_top_Phi_value} show that if $T_0$ and $p$ are large enough to satisfy that $\nbr{ \mathbb{E}_{s \sim \hat{\mathcal{D}}} \mbr{ \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top } - \mathbb{E}_{s \sim \mathcal{D}} \mbr{ \boldsymbol{\phi}(s,a) \boldsymbol{\phi}(s,a)^\top } } \leq \frac{\nu}{ 4(1+\zeta) }$ for any $a \in \mathcal{A}$ and $\nbr{ \sum_{i=1}^{p} \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i) \boldsymbol{\phi}(s_{m,j,i}^{(\ell)},\bar{a}_i)^\top - \sum_{i=1}^{p} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\boldsymbol{\phi}(s,\bar{a}_i) \boldsymbol{\phi}(s,\bar{a}_i)^\top} } \leq \frac{p \nu}{ 4(1+\zeta) }$ for any $m \in [M]$, $j \in [T]$ and $\ell \in \{1,2\}$, respectively, then we have that $ (\boldsymbol{\Phi}_{m,j}^{(\ell)})^{\top} \boldsymbol{\Phi}_{m,j}^{(\ell)} $ is invertible.
Continuing with Eq.~\eqref{eq:norm_Phi_plus}, we have
\begin{align*}
\nbr{ (\boldsymbol{\Phi}_{m,j}^{(\ell)})^{+} }
\leq 2 \sqrt{\frac{(1+\zeta)}{p \nu}} .
\end{align*}
\end{proof}
\subsection{Global Feature Extractor Recovery with Stochastic Contexts} \label{apx:bpi_feat_recover}
In subroutine $\mathtt{C \hyphen FeatRecover}$, for any $m \in [M]$, $j \in [T]$, $i \in [p]$ and $\ell \in \{1,2\}$, let $s^{(\ell)}_{m,j,i}$ and $\eta^{(\ell)}_{m,j,i}$ denote the random context and noise of the $\ell$-th sample on action $\bar{a}_i$ in the $j$-th round for task $m$, respectively. Here, the superscript $\ell \in \{1,2\}$ refers to the first sample (Line~\ref{line:bpi_stage2_sample1} in Algorithm~\ref{alg:con_feat_recover}) or the second sample (Line~\ref{line:bpi_stage2_sample2} in Algorithm~\ref{alg:con_feat_recover}) on an action $\bar{a}_i$.
In $\mathtt{C \hyphen FeatRecover}$, for any $m \in [M]$, $j \in [T]$, $i \in [p]$ and $\ell \in \{1,2\}$, let $\boldsymbol{\alpha}^{(\ell)}_{m,j} \leftarrow [\alpha^{(\ell)}_{m,j,1}, \dots, \alpha^{(\ell)}_{m,j,p}]^\top$, and then, $\tilde{\boldsymbol{\theta}}^{(\ell)}_{m,j} = (\boldsymbol{\Phi}_{m,j}^{(\ell)})^{+} \boldsymbol{\alpha}^{(\ell)}_{m,j}$. Recall that $\boldsymbol{Z} = \frac{1}{M T} \sum_{m=1}^{M} \sum_{j=1}^{T} \tilde{\boldsymbol{\theta}}^{(1)}_{m,j} (\tilde{\boldsymbol{\theta}}^{(2)}_{m,j})^\top$.
\begin{lemma}[Expectation of $\boldsymbol{Z}$] \label{lemma:bpi_expectation_Z}
It holds that
\begin{align*}
\mathbb{E} \mbr{ \boldsymbol{Z} } = \frac{1}{M} \sum_{m=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:bpi_expectation_Z}]
$\boldsymbol{Z}$ can be written as
\begin{align}
\boldsymbol{Z} = & \frac{1}{M T} \sum_{m=1}^{M} \sum_{j=1}^{T} \tilde{\boldsymbol{\theta}}^{(1)}_{m,j} (\tilde{\boldsymbol{\theta}}^{(2)}_{m,j})^\top
\nonumber\\
= & \frac{1}{M T} \sum_{m=1}^{M} \sum_{j=1}^{T} (\boldsymbol{\Phi}_{m,j}^{(1)})^{+} \begin{bmatrix}
\alpha^{(1)}_{m,j,1}
\\
\vdots
\\
\alpha^{(1)}_{m,j,p}
\end{bmatrix}
\mbr{\alpha^{(2)}_{m,j,1}, \dots, \alpha^{(2)}_{m,j,p}} ((\boldsymbol{\Phi}_{m,j}^{(2)})^{+})^{\top}
\nonumber\\
= & \frac{1}{M T} \sum_{m=1}^{M} \sum_{j=1}^{T} (\boldsymbol{\Phi}_{m,j}^{(1)})^{+} \Bigg( \!\!
\begin{bmatrix}
&\!\!\!\!\!\! \sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} &\!\!\!\!\!\!\dots\!\!\!\!\!\! &\sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m}
\\
&\!\!\!\!\!\! \dots &\!\!\!\!\!\!\dots\!\!\!\!\!\! &\dots
\\
&\!\!\!\!\!\! \sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} &\!\!\!\!\!\!\dots\!\!\!\!\!\! &\sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m}
\end{bmatrix}
\nonumber\\& \hspace*{-2em} +
\begin{bmatrix}
&\!\!\!\!\!\! \boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m \cdot \eta^{(2)}_{m,j,1} + \eta^{(1)}_{m,j,1} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m &\!\!\!\!\!\dots\!\!\!\!\! & \boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m \cdot \eta^{(2)}_{m,j,p} + \eta^{(1)}_{m,j,1} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m
\\
&\!\!\!\!\!\! \dots &\!\!\!\!\!\dots\!\!\!\!\! &\dots
\\
&\!\!\!\!\!\! \boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m \cdot \eta^{(2)}_{m,j,1} + \eta^{(1)}_{m,j,p} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m & \!\!\!\!\!\dots\!\!\!\!\! & \boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m \cdot \eta^{(2)}_{m,j,p} + \eta^{(1)}_{m,j,p} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m
\end{bmatrix}
\nonumber\\& \hspace*{-2em} +
\begin{bmatrix}
&\!\!\!\!\!\! \eta^{(1)}_{m,j,1} \cdot \eta^{(2)}_{m,j,1} &\dots & \eta^{(1)}_{m,j,1} \cdot \eta^{(2)}_{m,j,p}
\\
&\!\!\!\!\!\! \dots &\dots &\dots
\\
&\!\!\!\!\!\! \eta^{(1)}_{m,j,p} \cdot \eta^{(2)}_{m,j,1} &\dots &\eta^{(1)}_{m,j,p} \cdot \eta^{(2)}_{m,j,p}
\end{bmatrix}
\Bigg)
((\boldsymbol{\Phi}_{m,j}^{(2)})^{+})^{\top} \label{eq:decompose_Z} .
\end{align}
For any task $m \in [M]$, $j \in [T]$, $i \in [p]$, the sample on action $a_i$ in the first round (i.e., $s^{(1)}_{m,j,i}$ and $\eta^{(1)}_{m,j,i}$) is independent of that in the second round (i.e., $s^{(2)}_{m,j,i}$ and $\eta^{(2)}_{m,j,i}$).
Hence, taking the expectation on $\boldsymbol{Z}$, we obtain
\begin{align*}
\mathbb{E}[\boldsymbol{Z}] = & \frac{1}{M T} \sum_{m=1}^{M} \sum_{j=1}^{T} \mathbb{E} \Bigg[ (\boldsymbol{\Phi}_{m,j}^{(1)})^{+} \cdot
\\
&
\begin{bmatrix}
&\sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} &\!\!\!\!\!\dots\!\!\!\!\! &\sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m}
\\
&\dots &\!\!\!\!\!\dots\!\!\!\!\! &\dots
\\
&\sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} &\!\!\!\!\!\dots\!\!\!\!\! &\sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m}
\end{bmatrix}
((\boldsymbol{\Phi}_{m,j}^{(2)})^{+})^{\top} \Bigg]
\\
= & \frac{1}{M T} \sum_{m=1}^{M} \sum_{j=1}^{T} \mathbb{E} \Bigg[ ((\boldsymbol{\Phi}_{m,j}^{(1)})^{\top} \boldsymbol{\Phi}_{m,j}^{(1)})^{-1} (\boldsymbol{\Phi}_{m,j}^{(1)})^{\top}
\begin{bmatrix}
\boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m
\\
\vdots
\\
\boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m
\end{bmatrix}
\mbr{ \boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m, \dots, \boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m }
\cdot
\\
& \boldsymbol{\Phi}_{m,j}^{(2)} ((\boldsymbol{\Phi}_{m,j}^{(2)})^{\top} \boldsymbol{\Phi}_{m,j}^{(2)})^{-1} \Bigg]
\\
= & \frac{1}{M T} \sum_{m=1}^{M} \sum_{j=1}^{T} \mathbb{E} \mbr{ ((\boldsymbol{\Phi}_{m,j}^{(1)})^{\top} \boldsymbol{\Phi}_{m,j}^{(1)})^{-1} (\boldsymbol{\Phi}_{m,j}^{(1)})^{\top} \cdot \boldsymbol{\Phi}_{m,j}^{(1)} \boldsymbol{\theta}_m
(\boldsymbol{\theta}_m)^{\top} (\boldsymbol{\Phi}_{m,j}^{(2)})^{\top} \cdot
\boldsymbol{\Phi}_{m,j}^{(2)} ((\boldsymbol{\Phi}_{m,j}^{(2)})^{\top} \boldsymbol{\Phi}_{m,j}^{(2)})^{-1} }
\\
= & \frac{1}{M T} \sum_{m=1}^{M} \sum_{j=1}^{T} \boldsymbol{\theta}_m (\boldsymbol{\theta}_m)^\top
\\
= & \frac{1}{M} \sum_{m=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top .
\end{align*}
\end{proof}
Define event
\begin{align*}
\mathcal{G}:= \lbr{ \nbr{\boldsymbol{Z} - \mathbb{E} [\boldsymbol{Z}]} \leq \frac{ 256 (1+\zeta) L_{\phi} L_{\theta} \log\sbr{\frac{50d}{\delta}} }{\nu \sqrt{MT}} \log \sbr{\frac{100pMT}{\delta}} } .
\end{align*}
\begin{lemma}[Concentration of $Z$] \label{lemma:Z_est_error}
Suppose that $\mathcal{K} \cap \mathcal{L}$ holds. Then, it holds that
\begin{align*}
\Pr \mbr{\mathcal{G}} \geq 1-\frac{\delta}{5} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:Z_est_error}]
Define the following matrices:
\begin{align*}
\boldsymbol{D}_{m,j} &:= \frac{1}{M T} (\boldsymbol{\Phi}_{m,j}^{(1)})^{+} \cdot
\\
&
\begin{bmatrix}
&\sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} &\dots &\sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m}
\\
&\dots &\dots &\dots
\\
&\sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m} &\dots &\sbr{\boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m} \sbr{\boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m}
\end{bmatrix} ((\boldsymbol{\Phi}_{m,j}^{(2)})^{+})^\top
\\
\boldsymbol{D} &:= \sum_{m=1}^{M} \sum_{j=1}^{T} \boldsymbol{D}_{m,j}
\\
\boldsymbol{E}_{m,j} &:= \frac{1}{M T} (\boldsymbol{\Phi}_{m,j}^{(1)})^{+} \cdot
\\
&
\hspace*{-1.8em}
\begin{bmatrix}
&\!\!\!\!\! \boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m \cdot \eta^{(2)}_{m,j,1} + \eta^{(1)}_{m,j,1} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m &\!\!\!\!\!\dots\!\!\!\!\! & \boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m \cdot \eta^{(2)}_{m,j,p} + \eta^{(1)}_{m,j,1} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m
\\
&\!\!\!\!\!\dots &\!\!\!\!\!\dots\!\!\!\!\! &\dots
\\
&\!\!\!\!\! \boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m \cdot \eta^{(2)}_{m,j,1} + \eta^{(1)}_{m,j,p} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m & \!\!\!\!\!\dots\!\!\!\!\! & \boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m \cdot \eta^{(2)}_{m,j,p} + \eta^{(1)}_{m,j,p} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m
\end{bmatrix} \! \cdot
\\
& ((\boldsymbol{\Phi}_{m,j}^{(2)})^{+})^\top
\\
\boldsymbol{E} &:= \sum_{m=1}^{M} \sum_{j=1}^{T} \boldsymbol{E}_{m,j}
\\
\boldsymbol{F}_{m,j} &:= \frac{1}{M T} (\boldsymbol{\Phi}_{m,j}^{(1)})^{+}
\begin{bmatrix}
&\eta^{(1)}_{m,j,1} \cdot \eta^{(2)}_{m,j,1} &\dots & \eta^{(1)}_{m,j,1} \cdot \eta^{(2)}_{m,j,p}
\\
&\dots &\dots &\dots
\\
&\eta^{(1)}_{m,j,p} \cdot \eta^{(2)}_{m,j,1} &\dots &\eta^{(1)}_{m,j,p} \cdot \eta^{(2)}_{m,j,p}
\end{bmatrix} ((\boldsymbol{\Phi}_{m,j}^{(2)})^{+})^\top
\\
\boldsymbol{F} &:= \sum_{m=1}^{M} \sum_{j=1}^{T} \boldsymbol{F}_{m,j}
\end{align*}
From Eq.~\eqref{eq:decompose_Z}, we can bound $\|\boldsymbol{Z} - \mathbb{E} [\boldsymbol{Z}]\|$ as
\begin{align}
\nbr{\boldsymbol{Z} - \mathbb{E} [\boldsymbol{Z}]} \leq & \nbr{\boldsymbol{D} - \mathbb{E}[\boldsymbol{D}]} + \nbr{\boldsymbol{E} - \mathbb{E}[\boldsymbol{E}]} + \nbr{\boldsymbol{F} - \mathbb{E}[\boldsymbol{F}]} . \label{eq:decompose_Z_est_err}
\end{align}
Similar to the proof of Lemma~\ref{lemma:Z_t_est_error}, in order to use the truncated matrix Bernstein inequality (Lemma~\ref{lemma:matrix_bernstein_tau}), we define the truncated noise and some truncated matrices as follows.
Let $R>0$ be a truncation parameter of noises which will be chosen later. For any $m \in [M]$, $j \in [T]$, $i \in [p]$ and $\ell \in \{1,2\}$, let $\tilde{\eta}^{(\ell)}_{m,j,i}=\eta^{(\ell)}_{m,j,i} \mathbbm{1}\{|\eta^{(\ell)}_{m,j,i}| \leq R\}$ denote the truncated noise. Furthermore, we define the following matrices with truncated noises:
\begin{align*}
\tilde{\boldsymbol{E}}_{m,j} &:= \frac{1}{M T} (\boldsymbol{\Phi}_{m,j}^{(1)})^{+} \cdot
\\
&
\hspace*{-1.8em}
\begin{bmatrix}
&\!\!\!\!\! \boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m \cdot \tilde{\eta}^{(2)}_{m,j,1} + \tilde{\eta}^{(1)}_{m,j,1} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m &\!\!\!\!\!\dots\!\!\!\!\! & \boldsymbol{\phi}(s^{(1)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m \cdot \tilde{\eta}^{(2)}_{m,j,p} + \tilde{\eta}^{(1)}_{m,j,1} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m
\\
&\!\!\!\!\!\dots &\!\!\!\!\!\dots\!\!\!\!\! &\dots
\\
&\!\!\!\!\! \boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m \cdot \tilde{\eta}^{(2)}_{m,j,1} + \tilde{\eta}^{(1)}_{m,j,p} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,1},\bar{a}_1)^\top \boldsymbol{\theta}_m & \!\!\!\!\!\dots\!\!\!\!\! & \boldsymbol{\phi}(s^{(1)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m \cdot \tilde{\eta}^{(2)}_{m,j,p} + \tilde{\eta}^{(1)}_{m,j,p} \cdot \boldsymbol{\phi}(s^{(2)}_{m,j,p},\bar{a}_p)^\top \boldsymbol{\theta}_m
\end{bmatrix} \! \cdot
\\
& ((\boldsymbol{\Phi}_{m,j}^{(2)})^{+})^\top
\\
\tilde{\boldsymbol{E}} &:= \sum_{m=1}^{M} \sum_{j=1}^{T} \tilde{\boldsymbol{E}}_{m,j}
\\
\tilde{\boldsymbol{F}}_{m,j} &:= \frac{1}{M T} (\boldsymbol{\Phi}_{m,j}^{(1)})^{+}
\begin{bmatrix}
&\tilde{\eta}^{(1)}_{m,j,1} \cdot \tilde{\eta}^{(2)}_{m,j,1} &\dots & \tilde{\eta}^{(1)}_{m,j,1} \cdot \tilde{\eta}^{(2)}_{m,j,p}
\\
&\dots &\dots &\dots
\\
&\tilde{\eta}^{(1)}_{m,j,p} \cdot \tilde{\eta}^{(2)}_{m,j,1} &\dots &\tilde{\eta}^{(1)}_{m,j,p} \cdot \tilde{\eta}^{(2)}_{m,j,p}
\end{bmatrix} ((\boldsymbol{\Phi}_{m,j}^{(2)})^{+})^\top
\\
\tilde{\boldsymbol{F}} &:= \sum_{m=1}^{M} \sum_{j=1}^{T} \tilde{\boldsymbol{F}}_{m,j}
\end{align*}
Recall that from Lemma~\ref{lemma:norm_Phi_plus}, we have that for any $m \in [M]$, $j \in [T]$ and $\ell \in \{1,2\}$, $\|(\boldsymbol{\Phi}_{m,j}^{(\ell)})^{+}\| \leq 2 \sqrt{\frac{(1+\zeta)}{p \nu}}$. Let $B_{\Phi}:=2 \sqrt{\frac{(1+\zeta)}{p \nu}}$.
We first analyze $\|\boldsymbol{D}-\mathbb{E}[\boldsymbol{D}]\|$. Since $|\boldsymbol{\phi}(s^{(\ell)}_{m,j,i},\bar{a}_i)^\top \boldsymbol{\theta}_m| \leq L_{\phi}L_{\theta}$ for any $m \in [M]$, $j \in [T]$, $i \in [p]$ and $\ell \in \{1,2\}$, we have that $\|\boldsymbol{D}_{m,j}\| \leq \frac{1}{MT} \cdot p L_{\phi} L_{\theta} B_{\Phi}^2$ and $\| \sum_{m=1}^{M} \sum_{j=1}^{T} \mathbb{E}[\boldsymbol{D}^2_{m,j}]\| \leq MT \cdot \frac{1}{M^2 T^2} \cdot p^2 L_{\phi}^2 L_{\theta}^2 B_{\Phi}^4 = \frac{1}{M T} \cdot p^2 L_{\phi}^2 L_{\theta}^2 B_{\Phi}^4$ for any $m \in [M]$ and $j \in [T]$.
Let $\delta' \in (0,1)$ be a confidence parameter which will be chosen later.
Using the matrix Bernstein inequality (Lemma~\ref{lemma:matrix_bernstein_tau}), we have that with probability at least $1-\delta'$,
\begin{align}
\nbr{ \boldsymbol{D} - \mathbb{E}[\boldsymbol{D}] } \leq & 4 \sqrt{ \frac{p^2 L_{\phi}^2 L_{\theta}^2 B_{\Phi}^4 \log \sbr{\frac{2d}{\delta'}}}{M T} } + \frac{4 p L_{\phi} L_{\theta} B_{\Phi}^2 \log \sbr{\frac{2d}{\delta'}}}{MT}
\nonumber\\
\leq & \frac{8 \cdot 4 p L_{\phi} L_{\theta} B_{\Phi}^2 \log \sbr{\frac{2d}{\delta'}}}{\sqrt{MT}} \label{eq:D_est_err}.
\end{align}
Next, we bound $\|\boldsymbol{E}-\mathbb{E}[\boldsymbol{E}]\|$.
Since $|\boldsymbol{\phi}(s^{(\ell)}_{m,j,i},\bar{a}_i)^\top \boldsymbol{\theta}_m| \leq L_{\phi} L_{\theta}$ and $|\tilde{\eta}^{(\ell)}_{m,j,i}| \leq R$ for any $m \in [M]$, $j \in [T]$, $i \in [p]$ and $\ell \in \{1,2\}$, we have that $\|\tilde{\boldsymbol{E}}_{m,j}\| \leq \frac{1}{M T} \cdot 2pR L_{\phi} L_{\theta} B_{\Phi}^2$ and $\nbr{\sum_{m=1}^{M} \sum_{j=1}^{T} \mathbb{E} [\tilde{\boldsymbol{E}}_{m,j}^2]} \leq \frac{1}{M T} \cdot 4p^2R^2 L_{\phi}^2 L_{\theta}^2 B_{\Phi}^4$ for any $m \in [M]$ and $j \in [T]$.
%
Since $\eta^{(\ell)}_{m,j,i}$ is 1-sub-Gaussian for any $m \in [M]$, $j \in [T]$, $i \in [p]$ and $\ell \in \{1,2\}$, using a union bound over $i \in [p]$ and $\ell \in \{1,2\}$, we have that for any $m \in [M]$ and $j \in [T]$, with probability at least $1-4p\exp(-\frac{R^2}{2})$, $|\eta^{(\ell)}_{m,j,i}| \leq R$ for all $i \in [p]$ and $\ell \in \{1,2\}$, and thus, $\|\boldsymbol{E}_{m,j}\| \leq \frac{1}{M T} \cdot 2pR L_{\phi} L_{\theta} B_{\Phi}^2$. Then, we have
\begin{align*}
& \nbr{ \mathbb{E}[\boldsymbol{E}_{m,j}]-\mathbb{E}[\tilde{\boldsymbol{E}}_{m,j}] }
\nonumber\\
\leq & \nbr{ \mathbb{E} \mbr{\boldsymbol{E}_{m,j} \cdot \indicator{ \nbr{\boldsymbol{E}_{m,j}} \geq \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T} }} }
\\
\leq & \mathbb{E} \mbr{ \nbr{\boldsymbol{E}_{m,j}} \cdot \indicator{ \nbr{\boldsymbol{E}_{m,j}} \geq \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T} } }
\\
= & \mathbb{E}\mbr{ \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T} \!\cdot\! \indicator{ \nbr{\boldsymbol{E}_{m,j}} \!\geq\! \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T} }} \!+\! \mathbb{E} \mbr{\sbr{ \nbr{\boldsymbol{E}_{m,j}} \!-\! \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T}} \!\cdot\! \indicator{ \nbr{\boldsymbol{E}_{m,j}} \!\geq\! \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T} } }
\\
= & \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T} \cdot \Pr\mbr{ \nbr{\boldsymbol{E}_{m,j}} \geq \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T} } + \int_0^{\infty} \Pr \mbr{ \nbr{\boldsymbol{E}_{m,j}} - \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T} > x} dx
\\
\leq & \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T} \cdot 4p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p L_{\phi} L_{\theta} B_{\Phi}^2}{M T} \int_R^{\infty} \Pr \mbr{ \nbr{\boldsymbol{E}_{m,j}} > \frac{2p L_{\phi} L_{\theta} B_{\Phi}^2 y}{M T} } dy
\\
\leq & \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T} \cdot 4p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p L_{\phi} L_{\theta} B_{\Phi}^2}{M T} \int_R^{\infty} 4p \exp\sbr{-\frac{y^2}{2}} dy
\\
\leq & \frac{2pR L_{\phi} L_{\theta} B_{\Phi}^2}{M T} \cdot 4p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p L_{\phi} L_{\theta} B_{\Phi}^2}{M T} \cdot 4p \cdot \frac{1}{R} \cdot \exp\sbr{-\frac{R^2}{2}}
\\
= & \frac{2p L_{\phi} L_{\theta} B_{\Phi}^2}{M T} \cdot 4p \cdot \sbr{R+\frac{1}{R}} \exp\sbr{-\frac{R^2}{2}} .
\end{align*}
Using the truncated matrix Bernstein inequality (Lemma~\ref{lemma:matrix_bernstein_tau}) with $n=MT$, $R=\sqrt{2\log \sbr{\frac{4pMT}{\delta'}}}$, $U=\frac{2p L_{\phi} L_{\theta} B_{\Phi}^2 \sqrt{2\log \sbr{\frac{4pMT}{\delta'}}}}{MT}$, $\sigma^2=\frac{(2p L_{\phi} L_{\theta} B_{\Phi}^2 \sqrt{2\log \sbr{\frac{4pMT}{\delta'}}})^2}{MT}$, $\tau=4\sqrt{\frac{ (2p L_{\phi} L_{\theta} B_{\Phi}^2 \sqrt{2\log \sbr{\frac{4pMT}{\delta'}}})^2 \cdot \log\sbr{\frac{2d}{\delta'}}}{MT}}+\frac{4 \cdot 2p L_{\phi} L_{\theta} B_{\Phi}^2 \sqrt{2\log \sbr{\frac{4pMT}{\delta'}}} \cdot \log\sbr{\frac{2d}{\delta'}}}{M T}$ and $\Delta=\frac{2p L_{\phi} L_{\theta} B_{\Phi}^2 \cdot 2 \sqrt{2\log \sbr{\frac{4pMT}{\delta'}}}}{M T} \cdot \frac{\delta'}{M T}$, we have that with probability at least $1-2\delta'$,
\begin{align}
\nbr{\boldsymbol{E} - \mathbb{E}[\boldsymbol{E}]} \leq \frac{8 \cdot 2p L_{\phi} L_{\theta} B_{\Phi}^2 \sqrt{2\log \sbr{\frac{4pMT}{\delta'}}} \cdot \log\sbr{\frac{2d}{\delta'}}}{\sqrt{M T}} . \label{eq:E_est_err}
\end{align}
Now we investigate $\nbr{\boldsymbol{F} - \mathbb{E}[\boldsymbol{F}]}$. Since $|\tilde{\eta}^{(\ell)}_{m,j,i}| \leq R$ for any $m \in [M]$, $j \in [T]$, $i \in [p]$ and $\ell \in \{1,2\}$, we have that $\|\tilde{\boldsymbol{F}}_{m,j}\| \leq \frac{1}{M T} \cdot pR^2 B_{\Phi}^2$ and $\nbr{\sum_{m=1}^{M} \sum_{j=1}^{T} \mathbb{E} \mbr{\tilde{\boldsymbol{F}}_{m,j}^2} } \leq \frac{1}{M T} \cdot p^2 R^4 B_{\Phi}^4$.
%
Recall that for any $m \in [M]$ and $j \in [T]$, with probability at least $1-4p\exp(-\frac{R^2}{2})$, $|\eta^{(\ell)}_{m,j,i}| \leq R$ for all $i \in [p]$ and $\ell \in \{1,2\}$, and thus, $\|\boldsymbol{F}_{m,j}\| \leq \frac{1}{M T} \cdot p B_{\Phi}^2 R^2 $. Then, we have
\begin{align*}
\nbr{ \mathbb{E}[\boldsymbol{F}_{m,j}]-\mathbb{E}[\tilde{\boldsymbol{F}}_{m,j}] } \leq & \nbr{ \mathbb{E} \mbr{\boldsymbol{F}_{m,j} \cdot \indicator{ \nbr{\boldsymbol{F}_{m,j}} \geq \frac{p B_{\Phi}^2 R^2}{M T} }} }
\\
\leq & \mathbb{E} \mbr{ \nbr{\boldsymbol{F}_{m,j}} \cdot \indicator{ \nbr{\boldsymbol{F}_{m,j}} \geq \frac{p B_{\Phi}^2 R^2}{M T} } }
\\
= & \mathbb{E}\mbr{ \frac{p B_{\Phi}^2 R^2}{M T} \cdot \indicator{ \nbr{\boldsymbol{F}_{m,j}} \geq \frac{p B_{\Phi}^2 R^2}{M T} }} + \mbr{\sbr{ \nbr{\boldsymbol{F}_{m,j}} - \frac{p B_{\Phi}^2 R^2}{M T}} \cdot \indicator{ \nbr{\boldsymbol{F}_{m,j}} \geq \frac{p B_{\Phi}^2 R^2}{M T} } }
\\
= & \frac{p B_{\Phi}^2 R^2}{M T} \cdot \Pr\mbr{ \nbr{\boldsymbol{F}_{m,j}} \geq \frac{p B_{\Phi}^2 R^2}{M T} } + \int_0^{\infty} \Pr \mbr{ \nbr{\boldsymbol{F}_{m,j}} - \frac{p B_{\Phi}^2 R^2}{M T} > x} dx
\\
\leq & \frac{p B_{\Phi}^2 R^2}{M T} \cdot 4p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p B_{\Phi}^2}{M T} \int_R^{\infty} \boldsymbol{y} \cdot \Pr \mbr{ \nbr{\boldsymbol{F}_{m,j}} > \frac{p B_{\Phi}^2 y^2}{M T} } dy
\\
\leq & \frac{p B_{\Phi}^2 R^2}{M T} \cdot 4p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p B_{\Phi}^2}{M T} \int_R^{\infty} \boldsymbol{y} \cdot 4p \exp\sbr{-\frac{y^2}{2}} dy
\\
\leq & \frac{p B_{\Phi}^2 R^2}{M T} \cdot 4p \cdot \exp\sbr{-\frac{R^2}{2}} + \frac{2p B_{\Phi}^2}{M T} \cdot 4p \cdot \exp\sbr{-\frac{R^2}{2}}
\\
= & \frac{p B_{\Phi}^2}{M T} \cdot 4p \cdot \sbr{R^2+2} \exp\sbr{-\frac{R^2}{2}} .
\end{align*}
Using the truncated matrix Bernstein inequality (Lemma~\ref{lemma:matrix_bernstein_tau}) with $n=MT$, $R=\sqrt{2\log \sbr{\frac{4pMT}{\delta'}}}$, $U=\frac{p B_{\Phi}^2 \cdot 2\log \sbr{\frac{4pMT}{\delta'}}}{MT}$, $\sigma^2=\frac{(p B_{\Phi}^2 \cdot 2\log \sbr{\frac{4pMT}{\delta'}})^2}{MT}$, $\tau=4\sqrt{\frac{ (p B_{\Phi}^2 \cdot 2\log \sbr{\frac{4pMT}{\delta'}})^2 \cdot \log\sbr{\frac{2d}{\delta'}}}{MT}}+\frac{4\cdot p B_{\Phi}^2 \cdot 2\log \sbr{\frac{4pMT}{\delta'}} \cdot \log\sbr{\frac{2d}{\delta'}}}{M T}$ and $\Delta=\frac{p B_{\Phi}^2 \cdot 2 \cdot 2\log \sbr{\frac{4pMT}{\delta'}} }{M T} \cdot \frac{\delta'}{M T}$, we have that with probability at least $1-2\delta'$,
\begin{align}
\nbr{\boldsymbol{F} - \mathbb{E}\mbr{\boldsymbol{F}}} \leq \frac{8 \cdot p B_{\Phi}^2 \cdot 2\log \sbr{\frac{4pMT}{\delta'}} \cdot \log\sbr{\frac{2d}{\delta'}}}{\sqrt{MT}} \label{eq:F_est_err} .
\end{align}
Plugging Eqs.~\eqref{eq:D_est_err}-\eqref{eq:F_est_err} into Eq.~\eqref{eq:decompose_Z_est_err}, we have that with probability at least $1-5\delta'$,
\begin{align*}
\nbr{\boldsymbol{Z} - \mathbb{E} [\boldsymbol{Z}]} \leq & \nbr{\boldsymbol{D} - \mathbb{E} \mbr{\boldsymbol{D}}} + \nbr{\boldsymbol{E} - \mathbb{E} \mbr{\boldsymbol{E}}} + \nbr{\boldsymbol{F} - \mathbb{E} \mbr{\boldsymbol{F}}}
\\
\leq & \frac{64 p L_{\phi} L_{\theta} B_{\Phi}^2 \log \sbr{\frac{4pMT}{\delta'}} \log\sbr{\frac{2d}{\delta'}}}{\sqrt{MT}} .
\end{align*}
Let $\delta'=\frac{\delta}{25}$. Recall that $B_{\Phi}:=2 \sqrt{\frac{(1+\zeta)}{p \nu}}$. Then, we obtain that with probability at least $1-\frac{\delta}{5}$,
\begin{align*}
\nbr{\boldsymbol{Z} - \mathbb{E} [\boldsymbol{Z}]} \leq \frac{ 256 (1+\zeta) L_{\phi} L_{\theta} \log\sbr{\frac{50d}{\delta}} }{\nu \sqrt{MT}} \log \sbr{\frac{100pMT}{\delta}} ,
\end{align*}
which implies that
$\Pr[\mathcal{G}]\geq 1-\frac{\delta}{5}$.
\end{proof}
According to Assumption~\ref{assumption:diverse_task}, there exists an absolute constant $c_0$ which satisfies that $\sigma_{\min}(\frac{1}{M} \sum_{m=1}^{M} \boldsymbol{w}_m \boldsymbol{w}_m^\top) = \sigma_{\min}(\frac{1}{M} \sum_{m=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top) \geq \frac{c_0}{k}$.
\begin{lemma}[Concentration of $\hat{\boldsymbol{B}}$] \label{lemma:concentration_hat_B_clb}
Suppose that event $\mathcal{G}$ holds. Then,
\begin{align*}
\nbr{\hat{\boldsymbol{B}}_{\bot}^\top \boldsymbol{B}} \leq \frac{ 2048 (1+\zeta) k L_{\phi} L_{\theta} \log\sbr{\frac{50d}{\delta}} }{c_0 \nu \sqrt{MT}} \log \sbr{\frac{ 135 (1+\zeta) d L_{\phi} M T}{\nu \delta} } .
\end{align*}
Furthermore, if
\begin{align}
%
T = \left \lceil \frac{68 \cdot 2048^2 \cdot 96^2 (1+\zeta)^2 k^4 L_{\phi}^4 L_{\theta}^2 L_{w}^2 }{ c_0^2 \nu^2 \varepsilon^2 M } \log^6 \sbr{ \frac{ 2048 \cdot 135 \cdot 96 \cdot 50 \cdot 5 (1+\zeta)^2 k^2 d^2 L_{\phi}^3 L_{\theta} L_{w} N }{c_0 \nu^2 \delta^3 \varepsilon} } \right \rceil , \label{eq:value_T}
\end{align}
we have
\begin{align*}
\nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \leq \frac{\varepsilon}{ 96 k \log \sbr{\frac{5N}{\delta}} L_{\phi} L_{w} } .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:concentration_hat_B_clb}]
First, we have that $\sigma_{k}(\mathbb{E}[\boldsymbol{Z}]) - \sigma_{k+1}(\mathbb{E}[\boldsymbol{Z}])=\sigma_{\min}( \frac{1}{M} \sum_{m=1}^{M} \boldsymbol{\theta}_m \boldsymbol{\theta}_m^\top )\geq \frac{c_0}{k}$. Let $p := \lceil 32^2 (1+\zeta)^2 \nu^{-2} L_{\phi}^4 \log^2 \sbr{\frac{40dMT}{\delta}} \rceil$.
Then, using the Davis-Kahan sin $\theta$ Theorem~\cite{bhatia2013matrix} and letting $T_t$ be large enough to satisfy that $\nbr{\boldsymbol{Z} - \mathbb{E}[\boldsymbol{Z}]} \leq \frac{c_0}{2k}$, we have
\begin{align*}
\nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \leq & \frac{ \nbr{\boldsymbol{Z} - \mathbb{E}[\boldsymbol{Z}]} }{ \sigma_{k}(\mathbb{E}[\boldsymbol{Z}]) - \sigma_{k+1}(\mathbb{E}[\boldsymbol{Z}]) - \nbr{\boldsymbol{Z} - \mathbb{E}[\boldsymbol{Z}]} }
\\
\leq & \frac{2k}{c_0} \nbr{\boldsymbol{Z} - \mathbb{E}[\boldsymbol{Z}]}
\\
\leq & \frac{ 512 (1+\zeta) k L_{\phi} L_{\theta} \log\sbr{\frac{50d}{\delta}} }{c_0 \nu \sqrt{MT}} \log \sbr{\frac{100pMT}{\delta}}
\\
\leq & \frac{ 512 (1+\zeta) k L_{\phi} L_{\theta} \log\sbr{\frac{50d}{\delta}} }{c_0 \nu \sqrt{MT}} \log \sbr{\frac{100MT}{\delta} \cdot \frac{2 \cdot 32^2 (1+\zeta)^2 L_{\phi}^4}{\nu^2} \log^2 \sbr{\frac{40dMT}{\delta}}}
\\
\leq & \frac{ 512 (1+\zeta) k L_{\phi} L_{\theta} \log\sbr{\frac{50d}{\delta}} }{c_0 \nu \sqrt{MT}} \log \sbr{\frac{ 2 \cdot 100 \cdot 32^2 \cdot 40^2 (1+\zeta)^2 d^2 L_{\phi}^4 M^3 T^3}{\nu^2 \delta^3} }
\\
\leq & \frac{ 2048 (1+\zeta) k L_{\phi} L_{\theta} \log\sbr{\frac{50d}{\delta}} }{c_0 \nu \sqrt{MT}} \log \sbr{\frac{ 135 (1+\zeta) d L_{\phi} M T}{\nu \delta} } .
\end{align*}
Using Lemma~\ref{lemma:technical_tool_bai_stage2} with $A=2048 (1+\zeta) k c_0^{-1} \nu^{-1} L_{\phi} L_{\theta} \log\sbr{\frac{50d}{\delta}}$, $B=\frac{ 135 (1+\zeta) d L_{\phi} }{\nu \delta}$ and $\kappa=\frac{\varepsilon}{ 96 k \log \sbr{\frac{5N}{\delta}} L_{\phi} L_{w}}$, we have that if
\begin{align*}
M T \geq & \frac{68 \cdot 2048^2 \cdot 96^2 (1+\zeta)^2 k^4 L_{\phi}^4 L_{\theta}^2 L_{w}^2 }{ c_0^2 \nu^2 \varepsilon^2 } \cdot \\& \log^2 \sbr{\frac{50d}{\delta}} \log^2 \sbr{\frac{5N}{\delta}} \log^2 \sbr{ \frac{ 2048 \cdot 135 \cdot 96 (1+\zeta)^2 k^2 d L_{\phi}^3 L_{\theta} L_{w} }{c_0 \nu^2 \delta \varepsilon} \log\sbr{\frac{50d}{\delta}} \log \sbr{\frac{5N}{\delta}} } ,
\end{align*}
then $\nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \leq \frac{\varepsilon}{ 96 k \log \sbr{\frac{5N}{\delta}} L_{\phi} L_{w} }$.
Further enlarging $MT$, if
\begin{align*}
M T \geq \frac{68 \cdot 2048^2 \cdot 96^2 (1+\zeta)^2 k^4 L_{\phi}^4 L_{\theta}^2 L_{w}^2 }{ c_0^2 \nu^2 \varepsilon^2 } \log^6 \sbr{ \frac{ 2048 \cdot 135 \cdot 96 \cdot 50 \cdot 5 (1+\zeta)^2 k^2 d^2 L_{\phi}^3 L_{\theta} L_{w} N }{c_0 \nu^2 \delta^3 \varepsilon} } ,
\end{align*}
then
\begin{align*}
\nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \leq \frac{\varepsilon}{ 96 k \log \sbr{\frac{5N}{\delta}} L_{\phi} L_{w} } .
\end{align*}
\end{proof}
\subsection{Estimation with Low-dimensional Representations}
\begin{lemma} \label{lemma:computation_logdet}
In subroutine $\mathtt{EstLowRep}$ (Algorithm~\ref{alg:est_low_rep}), for any $m \in [M]$ and $t > 0$, we have
\begin{align*}
\log \sbr{ \frac{\det\sbr{ \gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} } }{ \det \sbr{ \gamma I} } } \leq k \log \sbr{ 1 + \frac{ t }{\gamma k} } .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:computation_logdet}]
This proof uses a similar idea as Lemma 11 in \cite{abbasi2011improved}.
It holds that
\begin{align*}
& \log \sbr{ \frac{\det\sbr{ \gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} } }{ \det \sbr{ \gamma I} } }
\\
\leq & \log \sbr{ \frac{\sbr{ \frac{ \textup{Trace} \sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}}} }{k}}^{k} }{ \gamma^{k} } }
\\
= & k \log \sbr{ \frac{ \textup{Trace} \sbr{\gamma I} + \sum_{\tau=1}^{t} \textup{Trace} \sbr{ \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}}} }{\gamma k} }
\\
= & k \log \sbr{ \frac{ \gamma k + \sum_{\tau=1}^{t} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})}^2 }{\gamma k} }
\\
\leq & k \log \sbr{ 1 + \frac{ t }{\gamma k} } .
\end{align*}
\end{proof}
\begin{lemma} \label{lemma:decreasing_uncertainty}
In subroutine $\mathtt{EstLowRep}$ (Algorithm~\ref{alg:est_low_rep}), for any $m \in [M]$ and $t \geq 0$, we have
\begin{align*}
\mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} } \geq \mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t+1}^{-1}} } .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:decreasing_uncertainty}]
This proof is similar to that of Lemma 6 in \cite{zanette2021design}.
For any $m \in [M]$ and $t \geq 0$, since $\boldsymbol{\Sigma}_{m,t+1} \succeq \boldsymbol{\Sigma}_{m,t}$, we have $\boldsymbol{\Sigma}_{m,t}^{-1} \succeq \boldsymbol{\Sigma}_{m,t+1}^{-1}$. Hence, for any $m \in [M]$, $t \geq 0$, $s \in \mathcal{S}$ and $a \in \mathcal{A}$, we have
\begin{align*}
\boldsymbol{\phi}(s,a)^\top \hat{\boldsymbol{B}} \boldsymbol{\Sigma}_{m,t}^{-1} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a) \geq \boldsymbol{\phi}(s,a)^\top \hat{\boldsymbol{B}} \boldsymbol{\Sigma}_{m,t+1}^{-1} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a) ,
\end{align*}
which implies that
\begin{align*}
\nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \geq \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t+1}^{-1}} .
\end{align*}
Therefore, for any $m \in [M]$ and $t \geq 0$, we have
\begin{align*}
\mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} } \geq \mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t+1}^{-1}} } .
\end{align*}
\end{proof}
In subroutine $\mathtt{EstLowRep}$, for any $m \in [M]$ and $t>0$, let $\xi_{m,t}$ denote the noise of the sample at timestep $t$ for task $m$ (Line~\ref{line:bpi_stage3_sample} in Algorithm~\ref{alg:est_low_rep}).
Define event
\begin{align*}
\mathcal{H} := \Bigg\{ &
\nbr{\sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \xi_{m,\tau}}_{\sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{-1}} \leq \\& k \log \sbr{ 1 + \frac{ t }{\gamma k} } + 2 \log\sbr{\frac{5}{\delta}}, \ \forall m \in [M],\ \forall t>0 \Bigg\} .
\end{align*}
\begin{lemma}[Martingale Concentration of the Variance Term] \label{lemma:martingale_concentration_variance}
It holds that
\begin{align*}
\Pr \mbr{\mathcal{H}} \geq 1-\frac{\delta}{5} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:martingale_concentration_variance}]
Let $\delta'$ be a confidence parameter which will be chosen later.
Since $\hat{\boldsymbol{B}}$ is fixed before sampling $(s_{m,\tau},a_{m,\tau})$ for all $m \in [M]$ and $\tau>0$, using Lemma~\ref{lemma:self-normalized_vector_concentration}, we have that with probability at least $1-\delta'$, for any task $m \in [M]$ and $t>0$,
\begin{align*}
& \nbr{\sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \xi_{m,j}}_{\sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{-1}}
\\
\leq & 2 \log \sbr{ \frac{\det\sbr{ \gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{\frac{1}{2}} }{ \det \sbr{ \gamma I}^{\frac{1}{2}} \cdot \delta'} }
\\
\leq & \log \sbr{ \frac{\det\sbr{ \gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} } }{ \det \sbr{ \gamma I} } } + 2 \log\sbr{\frac{1}{\delta'}}
\\
\overset{\textup{(a)}}{\leq} & k \log \sbr{ 1 + \frac{ t }{\gamma k} } + 2 \log\sbr{\frac{1}{\delta'}} ,
\end{align*}
where inequality (a) uses Lemma~\ref{lemma:computation_logdet}.
Letting $\delta'=\frac{\delta}{5}$, we obtain this lemma.
\end{proof}
Define event
\begin{align*}
\mathcal{J} := \Bigg\{ & \sum_{t=1}^{N} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{t-1}^{-1}} } \leq \\& \frac{1}{4} \sbr{ 2\sqrt{\log \sbr{\frac{5}{\delta}}} + \sqrt{ 4 \log \sbr{\frac{5}{\delta}} + 4 \sbr{ \sum_{t=1}^{N} \max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_t,a) }_{\boldsymbol{\Sigma}_{t-1}^{-1}} + 2 \log \sbr{\frac{5}{\delta}} } } }^2 \Bigg\} .
\end{align*}
\begin{lemma} \label{lemma:reverse_bernstein_uncertainty}
It holds that
\begin{align*}
\Pr \mbr{\mathcal{J}} \geq 1-\frac{\delta}{5} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:reverse_bernstein_uncertainty}]
Using Lemma~\ref{lemma:reverse_bernstein}, we can obtain this lemma.
\end{proof}
\begin{lemma} \label{lemma:number_of_samples_N}
Suppose that event $\mathcal{K} \cap \mathcal{L} \cap \mathcal{G} \cap \mathcal{H} \cap \mathcal{J}$ holds. For any task $m \in [M]$, we have
\begin{align*}
\mathbb{E}_{s \sim \mathcal{D}} & \mbr{\max_{a \in \mathcal{A}} \abr{\boldsymbol{\phi}(s,a)^\top \sbr{ \hat{\boldsymbol{\theta}}_{m,N} - \boldsymbol{\theta}_m}}} \leq \sbr{2\sqrt{ \frac{2 k \log \sbr{ 1 + \frac{ N }{\gamma k} }}{N} } + \frac{8 \log \sbr{\frac{5}{\delta}} }{N}} \cdot \\& \sbr{ \nbr{\hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B}} \sqrt{Nk} + \sqrt{k \log \sbr{ 1 + \frac{ N }{\gamma k} } + 2 \log\sbr{\frac{5}{\delta}}} + \sqrt{\gamma} } + \nbr{\hat{\boldsymbol{B}}_{\bot}^\top \boldsymbol{B}} .
\end{align*}
Furthermore, if
\begin{align*}
%
N = \left \lceil \frac{4^2 \cdot 26^4 \cdot 24^2 \cdot 2 \sbr{k^2 + k \gamma L_{\theta}^2 } \log^4 \big({\frac{240 ( k + \sqrt{k \gamma} L_{\theta}) }{\varepsilon \delta}} \big) }{\varepsilon^2} \right \rceil ,
\end{align*}
then
\begin{align*}
\mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \abr{\boldsymbol{\phi}(s,a)^\top \sbr{ \hat{\boldsymbol{\theta}}_{m,N} - \boldsymbol{\theta}_m}}} \leq \frac{\varepsilon}{2}
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:number_of_samples_N}]
For any task $m \in [M]$ and $t \in [N]$,
\begin{align*}
\hat{\boldsymbol{w}}_{m,t} = & \boldsymbol{\Sigma}_{m,t}^{-1} \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) r_{m,\tau}
\\
= & \sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{-1} \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \sbr{ \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \boldsymbol{\theta}_m + \xi_{m,j} }
\\
= & \sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{-1} \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \cdot \\& \sbr{ \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} \hat{\boldsymbol{B}}^\top \boldsymbol{\theta}_m + \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}}_{\perp} \hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{\theta}_m + \xi_{m,j} }
\\& + \gamma \sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{-1} \hat{\boldsymbol{B}}^\top \boldsymbol{\theta}_m
\\& - \gamma \sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{-1} \hat{\boldsymbol{B}}^\top \boldsymbol{\theta}_m
\\
= & \hat{\boldsymbol{B}}^\top \boldsymbol{\theta}_m + \sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{-1} \cdot
\\&
\sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}}_{\perp} \hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B} \boldsymbol{w}_m
\\&
+ \sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{-1} \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \xi_{m,j}
\\&
- \gamma \sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{-1} \hat{\boldsymbol{B}}^\top \boldsymbol{\theta}_m .
\end{align*}
Hence, for any task $m \in [M]$, $t \in [N]$ and $(s,a) \in \mathcal{S} \times \mathcal{A}$,
\begin{align*}
\boldsymbol{\phi}(s,a)^\top \sbr{ \hat{\boldsymbol{\theta}}_{m,t} - \boldsymbol{\theta}_m} = & \boldsymbol{\phi}(s,a)^\top \hat{\boldsymbol{B}} \hat{\boldsymbol{w}}_{m,t} - \boldsymbol{\phi}(s,a)^\top \sbr{\hat{\boldsymbol{B}}\hat{\boldsymbol{B}}^\top+\hat{\boldsymbol{B}}_{\bot}\hat{\boldsymbol{B}}_{\bot}^\top} \boldsymbol{\theta}_m
\\
= & \boldsymbol{\phi}(s,a)^\top \hat{\boldsymbol{B}} \sbr{ \hat{\boldsymbol{w}}_{m,t} - \hat{\boldsymbol{B}}^\top \boldsymbol{\theta}_m } - \boldsymbol{\phi}(s,a)^\top \hat{\boldsymbol{B}}_{\bot}\hat{\boldsymbol{B}}_{\bot}^\top \boldsymbol{\theta}_m
\\
= & \boldsymbol{\phi}(s,a)^\top \hat{\boldsymbol{B}}
\sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{-1} \cdot \\& \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}}_{\perp} \hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B} \boldsymbol{w}_m
\\&
+ \boldsymbol{\phi}(s,a)^\top \hat{\boldsymbol{B}} \sbr{\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}} }^{-1} \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \xi_{m,j}
\\&
-\! \gamma \boldsymbol{\phi}(s,a)^{\!\top} \! \hat{\boldsymbol{B}} \sbr{ \! \gamma I \!+\! \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^{\!\top} \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^{\!\top} \hat{\boldsymbol{B}} \! }^{\!\!-1} \!\!\!\!\!\! \hat{\boldsymbol{B}}^\top \! \boldsymbol{\theta}_m \!-\! \boldsymbol{\phi}(s,a)^{\!\top} \! \hat{\boldsymbol{B}}_{\bot}\hat{\boldsymbol{B}}_{\bot}^{\!\top} \boldsymbol{B} \boldsymbol{w}_m .
\end{align*}
For any $m \in [M]$, let $\boldsymbol{\Sigma}_{m,0}:=\gamma I$. For any $m \in [M]$ and $t \geq 1$, let $\boldsymbol{\Sigma}_{m,t}:=\gamma I + \sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}}$.
Taking the absolute value on both sides and using the Cauchy–Schwarz inequality, we obtain that for any $m \in [M]$, $t \in [N]$ and $(s,a) \in \mathcal{S} \times \mathcal{A}$,
\begin{align*}
& \abr{\boldsymbol{\phi}(s,a)^\top \sbr{ \hat{\boldsymbol{\theta}}_{m,t} - \boldsymbol{\theta}_m}}
\\
\leq & \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \nbr{\sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}}_{\perp} \hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B} \boldsymbol{w}_m}_{\boldsymbol{\Sigma}_{m,t}^{-1}}
\\&
+ \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \nbr{\sum_{\tau=1}^{t} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \xi_{m,j}}_{\boldsymbol{\Sigma}_{m,t}^{-1}}
\\&
+ \gamma \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\theta}_m}_{\boldsymbol{\Sigma}_{m,t}^{-1}}
\\&
+ \abr{\boldsymbol{\phi}(s,a)^\top \hat{\boldsymbol{B}}_{\bot}\hat{\boldsymbol{B}}_{\bot}^\top \boldsymbol{B} \boldsymbol{w}_m}
\\
\overset{\textup{(a)}}{\leq} & \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \sum_{\tau=1}^{t} \abr{ \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}}_{\perp} \hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B} \boldsymbol{w}_m } \cdot \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})}_{\boldsymbol{\Sigma}_{m,t}^{-1}}
\\&
+ \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \sqrt{k \log \sbr{ 1 + \frac{ t }{\gamma k} } + 2 \log\sbr{\frac{5}{\delta}}}
\\&
+ \gamma \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \cdot \frac{1}{\sqrt{\gamma}} \cdot \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\theta}_m} + \nbr{\hat{\boldsymbol{B}}_{\bot}^\top \boldsymbol{B}} L_{\phi} L_{w}
\\
\leq & \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \cdot \nbr{\hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B}} L_{\phi} L_{w} \cdot \sum_{\tau=1}^{t} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})}_{\boldsymbol{\Sigma}_{m,t}^{-1}}
\\&
+ \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \sqrt{k \log \sbr{ 1 + \frac{ t }{\gamma k} } + 2 \log\sbr{\frac{5}{\delta}}}
\\&
+ \sqrt{\gamma} L_{\theta} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} + \nbr{\hat{\boldsymbol{B}}_{\bot}^\top \boldsymbol{B}} L_{\phi} L_{w}
\\
\overset{\textup{(b)}}{\leq} & \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \cdot \nbr{\hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B}} L_{\phi} L_{w} \cdot \sqrt{tk}
\\&
+ \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \sqrt{k \log \sbr{ 1 + \frac{ t }{\gamma k} } + 2 \log\sbr{\frac{5}{\delta}}}
\\&
+ \sqrt{\gamma} L_{\theta} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} + \nbr{\hat{\boldsymbol{B}}_{\bot}^\top \boldsymbol{B}} L_{\phi} L_{w}
\\
= & \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{m,t}^{-1}} \sbr{ \nbr{\hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B}} L_{\phi} L_{w} \cdot \sqrt{tk} + \sqrt{k \log \sbr{ 1 + \frac{ t }{\gamma k} } + 2 \log\sbr{\frac{5}{\delta}}} + \sqrt{\gamma} L_{\theta} } \\& + \nbr{\hat{\boldsymbol{B}}_{\bot}^\top \boldsymbol{B}} L_{\phi} L_{w} ,
\end{align*}
where inequality (a) uses the triangle inequality and the definition of event $\mathcal{H}$, and inequality (b) is due to Lemma~\ref{lemma:sqrt_n_k_gamma}.
Taking the maximum over $a \in \mathcal{A}$ and taking the expectation on $s \sim \mathcal{D}$, we have that for any task $m \in [M]$,
\begin{align}
\mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \abr{\boldsymbol{\phi}(s,a)^\top \sbr{ \hat{\boldsymbol{\theta}}_{m,N} - \boldsymbol{\theta}_m}}} \leq & \mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_N^{-1}} } \cdot
\nonumber\\&
\sbr{ \nbr{\hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B}} L_{\phi} L_{w} \cdot \sqrt{Nk} + \sqrt{k \log \sbr{ 1 + \frac{ N }{\gamma k} } + 2 \log\sbr{\frac{5}{\delta}}} + \sqrt{\gamma} L_{\theta} }
\nonumber\\&
+ \nbr{\hat{\boldsymbol{B}}_{\bot}^\top \boldsymbol{B}} L_{\phi} L_{w} . \label{eq:ex_max_phi_theta}
\end{align}
According to Lemma~\ref{lemma:decreasing_uncertainty}, $\mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_t^{-1}} }$ is non-increasing with respect to $t$. Hence, we have
\begin{align}
\mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{N}^{-1}} } \leq & \frac{1}{N} \sum_{t=1}^{N} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{t}^{-1}} }
\nonumber\\
\leq & \frac{1}{N} \sum_{t=1}^{N} \mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{t-1}^{-1}} }
\nonumber\\
\overset{\textup{(a)}}{\leq} & \frac{1}{4N} \Bigg( 2\sqrt{\log \sbr{\frac{5}{\delta}}} \nonumber\\& + \sqrt{ 4 \log \sbr{\frac{5}{\delta}} + 4 \sbr{ \sum_{t=1}^{N} \max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_t,a) }_{\boldsymbol{\Sigma}_{t-1}^{-1}} + 2 \log \sbr{\frac{5}{\delta}} } } \Bigg)^2
\nonumber\\
= & \frac{1}{4N} \sbr{ 2\sqrt{\log \sbr{\frac{5}{\delta}}} + \sqrt{ 4 \log \sbr{\frac{5}{\delta}} + 4 \sbr{ \sum_{t=1}^{N} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_t,a_t)}_{\boldsymbol{\Sigma}_{t-1}^{-1}} + 2 \log \sbr{\frac{5}{\delta}} } } }^{\!\!\!2} \!\! , \label{eq:ex_max_B_phi}
\end{align}
where inequality (a) is due to the definition of event $\mathcal{J}$.
In addition, we have
\begin{align}
\sum_{t=1}^{N} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_t,a_t)}_{\boldsymbol{\Sigma}_{t-1}^{-1}} \leq & \sqrt{N \cdot \sum_{t=1}^{N} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_t,a_t)}^2_{\boldsymbol{\Sigma}_{t-1}^{-1}}}
\nonumber\\
\overset{\textup{(a)}}{\leq} & \sqrt{2N \log \sbr{\frac{\det \sbr{\gamma I + \sum_{\tau=1}^{N} \hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau}) \boldsymbol{\phi}(s_{m,\tau},a_{m,\tau})^\top \hat{\boldsymbol{B}}}}{\det \sbr{\gamma I}}}}
\nonumber\\
\overset{\textup{(b)}}{\leq} & \sqrt{2 N k \log \sbr{ 1 + \frac{ N }{\gamma k} }} , \label{eq:B_phi_leq_k_log}
\end{align}
where inequality (a) uses Lemma~\ref{lemma:elliptical_potential}, and inequality (b) is due to Lemma~\ref{lemma:computation_logdet}.
Combining Eqs.~\eqref{eq:ex_max_B_phi} and \eqref{eq:B_phi_leq_k_log}, we have
\begin{align}
\mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \nbr{\hat{\boldsymbol{B}}^\top \boldsymbol{\phi}(s,a)}_{\boldsymbol{\Sigma}_{N}^{-1}} } \leq &
\frac{1}{4N} \sbr{ 2\sqrt{\log \sbr{\frac{5}{\delta}}} + \sqrt{ 4 \log \sbr{\frac{5}{\delta}} + 4 \sbr{ \sqrt{2 N k \log \sbr{ 1 + \frac{ N }{\gamma k} }} + 2 \log \sbr{\frac{5}{\delta}} } } }^2
\nonumber\\
\overset{\textup{(a)}}{\leq} & \frac{1}{2N} \sbr{ 4 \log \sbr{\frac{5}{\delta}} + 4 \log \sbr{\frac{5}{\delta}} + 4 \sbr{ \sqrt{2 N k \log \sbr{ 1 + \frac{ N }{\gamma k} }} + 2 \log \sbr{\frac{5}{\delta}} } }
\nonumber\\
= & \frac{1}{N} \sbr{ 2\sqrt{2 N k \log \sbr{ 1 + \frac{ N }{\gamma k} }} + 8 \log \sbr{\frac{5}{\delta}} }
\nonumber\\
= & 2\sqrt{ \frac{2 k \log \sbr{ 1 + \frac{ N }{\gamma k} }}{N} } + \frac{8 \log \sbr{\frac{5}{\delta}} }{N} , \label{eq:sum_ex_max_B_phi_final_bound}
\end{align}
where inequality (a) uses the Cauchy–Schwarz inequality.
Furthermore, plugging Eq.~\eqref{eq:sum_ex_max_B_phi_final_bound} into Eq.~\eqref{eq:ex_max_phi_theta} and using $\gamma \geq 1$, we have that for $N \geq 1$ and $\sqrt{k}\log(2N) \geq 1$,
\begin{align}
& \mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \abr{\boldsymbol{\phi}(s,a)^\top \sbr{ \hat{\boldsymbol{\theta}}_{m,N} - \boldsymbol{\theta}_m}}}
\\
\leq & \sbr{2\sqrt{ \frac{2 k \log \sbr{ 1 + \frac{ N }{\gamma k} }}{N} } + \frac{8 \log \sbr{\frac{5}{\delta}} }{N}} \cdot \nonumber\\& \sbr{ \nbr{\hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B}} L_{\phi} L_{w} \sqrt{N k} + \sqrt{k \log \sbr{ 1 + \frac{ N }{\gamma k} } + 2 \log\sbr{\frac{5}{\delta}}} + \sqrt{\gamma} L_{\theta} } + \nbr{\hat{\boldsymbol{B}}_{\bot}^\top \boldsymbol{B}} L_{\phi} L_{w}
\nonumber\\
\leq & \frac{ 12 \sqrt{k} \log \sbr{\frac{5N}{\delta}} }{\sqrt{N}} \sbr{ \nbr{\hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B}} L_{\phi} L_{w} \sqrt{Nk} + 2\sqrt{k} \log\sbr{\frac{5N}{\delta}} + \sqrt{\gamma} L_{\theta} } + \nbr{\hat{\boldsymbol{B}}_{\bot}^\top \boldsymbol{B}} L_{\phi} L_{w}
\nonumber\\
\leq & \frac{ \sbr{24 k + 12 \sqrt{k \gamma} L_{\theta} } \log^2 \sbr{\frac{5N}{\delta}} }{\sqrt{N}} + 24 k \log \sbr{\frac{5N}{\delta}} \nbr{\hat{\boldsymbol{B}}_{\perp}^\top \boldsymbol{B}} L_{\phi} L_{w} . \label{eq:ex_max_phi_theta_B_hat_times_B}
\end{align}
Using Lemma~\ref{lemma:technical_tool_log_N_square} with $A=24 k + 12 \sqrt{k \gamma} L_{\theta}$, $B=\frac{5}{\delta}$ and $\kappa=\frac{\varepsilon}{4}$, we have that if
\begin{align*}
N \geq \frac{26^4 \sbr{24 k + 12 \sqrt{k \gamma} L_{\theta}}^2 \log^4 \big({\frac{2 \cdot 5 (24 k + 12 \sqrt{k \gamma} L_{\theta}) }{\varepsilon \delta}} \big) }{\sbr{\frac{\varepsilon}{4}}^2} ,
\end{align*}
then $\frac{ \sbr{24 k + 12 \sqrt{k \gamma} L_{\theta} } \log^2 \sbr{\frac{5N}{\delta}} }{\sqrt{N}} \leq \frac{\varepsilon}{4}$.
Further enlarging $N$, if
\begin{align}
N \geq \frac{4^2 \cdot 26^4 \cdot 24^2 \cdot 2 \sbr{k^2 + k \gamma L_{\theta}^2 } \log^4 \big({\frac{240 ( k + \sqrt{k \gamma} L_{\theta}) }{\varepsilon \delta}} \big) }{\varepsilon^2} , \label{eq:number_of_samples_N}
\end{align}
then
\begin{align*}
\frac{ \sbr{24 k + 12 \sqrt{k \gamma} L_{\theta} } \log^2 \sbr{\frac{5N}{\delta}} }{\sqrt{N}} \leq \frac{\varepsilon}{4} .
\end{align*}
According to Lemma~\ref{lemma:concentration_hat_B_clb}, we have $\nbr{\hat{\boldsymbol{B}}_{t,\bot}^\top \boldsymbol{B}} \leq \frac{\varepsilon}{ 96 k \log \sbr{\frac{5N}{\delta}} L_{\phi} L_{w} }$.
Thus, setting $N$ as the value in Eq.~\eqref{eq:number_of_samples_N}, and continuing with Eq.~\eqref{eq:ex_max_phi_theta_B_hat_times_B}, we have
\begin{align*}
\mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \abr{\boldsymbol{\phi}(s,a)^\top \sbr{ \hat{\boldsymbol{\theta}}_{m,N} - \boldsymbol{\theta}_m}}} \leq \frac{\varepsilon}{4} + \frac{\varepsilon}{4}
= \frac{\varepsilon}{2} .
\end{align*}
\end{proof}
\subsection{Proof of Theorem~\ref{thm:bpi_ub}}
\begin{proof}[Proof of Theorem~\ref{thm:bpi_ub}]
Combining Lemmas~\ref{lemma:number_of_samples_T0}, \ref{lemma:number_of_samples_p}, \ref{lemma:Z_est_error}, \ref{lemma:martingale_concentration_variance} and \ref{lemma:reverse_bernstein_uncertainty}, we have that $Pr[\mathcal{K} \cap \mathcal{L} \cap \mathcal{G} \cap \mathcal{H} \cap \mathcal{J}] \geq 1-\delta$.
Suppose that event $\mathcal{K} \cap \mathcal{L} \cap \mathcal{G} \cap \mathcal{H} \cap \mathcal{J}$ holds.
First, we uses a similar analytical procedure as that
in \cite{zanette2021design} to prove the correctness.
Using Lemma~\ref{lemma:number_of_samples_N}, we have that for any task $m \in [M]$,
\begin{align*}
\mathbb{E}_{s \sim \mathcal{D}} \mbr{\max_{a \in \mathcal{A}} \abr{\boldsymbol{\phi}(s,a)^\top \sbr{ \hat{\boldsymbol{\theta}}_{m,N} - \boldsymbol{\theta}_m}}} \leq \frac{\varepsilon}{2} .
\end{align*}
For any $m \in [M]$ and $s \in \mathcal{S}$, let $\beta_m(s):=\max_{a\in\mathcal{A}}|\boldsymbol{\phi}(s,a)^\top (\hat{\boldsymbol{\theta}}_{m,N}-\boldsymbol{\theta}_m)|$ and $\pi^*_m(s):=\operatornamewithlimits{argmax}_{a \in \mathcal{A}} \boldsymbol{\phi}(s,a)^\top \boldsymbol{\theta}_m$.
For any $m \in [M]$ and $s \in \mathcal{S}$, we have
\begin{align*}
\boldsymbol{\phi}(s,\hat{\pi}_m(s))^\top \boldsymbol{\theta}_m \geq & \boldsymbol{\phi}(s,\hat{\pi}_m(s))^\top \hat{\boldsymbol{\theta}}_{m,N} - \beta_m(s)
\\
\overset{\textup{(a)}}{\geq} & \boldsymbol{\phi}(s,\pi^*_m(s))^\top \hat{\boldsymbol{\theta}}_{m,N} - \beta_m(s)
\\
\geq & \boldsymbol{\phi}(s,\pi^*_m(s))^\top \boldsymbol{\theta}_m - 2\beta_m(s) ,
\end{align*}
where inequality (a) is due to that $\hat{\pi}_m(s)$ is greedy with respect to $\hat{\boldsymbol{\theta}}_{m,N}$.
Rearranging the above equation and taking the expectation of $s$ on both sides, we have
\begin{align*}
\mathbb{E}_{s\sim\mathcal{D}}\mbr{\max_{a \in \mathcal{A}} \sbr{\boldsymbol{\phi}(s,a) - \boldsymbol{\phi}(s,\hat{\pi}_m(s))}^\top \boldsymbol{\theta}_m }
\leq 2 \mathbb{E}_{s\sim\mathcal{D}}[\beta_m(s)] \leq \varepsilon .
\end{align*}
Now we prove the sample complexity.
Summing the number of samples used in the main algorithm of $\mathtt{C \hyphen DouExpDes}$ and subroutines $\mathtt{C \hyphen FeatRecover}$ and $\mathtt{EstLowRep}$ (Line~\ref{line:bpi_estimate_context_dis} in Algorithm~\ref{alg:repbpiclb}, Lines~\ref{line:bpi_stage2_sample1}-\ref{line:bpi_stage2_sample2} in Algorithm~\ref{alg:con_feat_recover} and Line~\ref{line:bpi_stage3_sample} in Algorithm~\ref{alg:est_low_rep}), we have that the total number of samples is bounded by
\begin{align*}
& T_0+2MTp+MN
\\
= & O \Bigg( \frac{L_{\phi}^4}{\nu^2} \log^2 \sbr{\frac{d |\mathcal{A}|}{\delta}} + \frac{ k^4 L_{\phi}^4 L_{\theta}^2 L_{w}^2 }{ \nu^2 \varepsilon^2 } \log^6 \sbr{ \frac{ k d L_{\phi} L_{\theta} L_{w} N }{\nu \delta \varepsilon} } \cdot \frac{L_{\phi}^4}{\nu^2} \log^2 \sbr{\frac{dMT}{\delta}} \\&+ M \cdot \frac{\sbr{k^2 + k \gamma L_{\theta}^2 } \log^4 \big({\frac{ k + \sqrt{k \gamma} L_{\theta} }{\varepsilon \delta}} \big) }{\varepsilon^2} \Bigg)
\\
= & O \Bigg( \frac{ k^4 L_{\phi}^4 L_{\theta}^2 L_{w}^2 }{ \nu^2 \varepsilon^2 } \log^6 \sbr{ \frac{ |\mathcal{A}| k d L_{\phi} L_{\theta} L_{w} N }{\nu \delta \varepsilon} } \cdot \frac{L_{\phi}^4}{\nu^2} \log^2 \sbr{\frac{dMT}{\delta}} \\&+ M \cdot \frac{\sbr{k^2 + k \gamma L_{\theta}^2 } \log^4 \big({\frac{ k + \sqrt{k \gamma} L_{\theta} }{\varepsilon \delta}} \big) }{\varepsilon^2} \Bigg)
\\
= & \tilde{O} \Bigg( \frac{ k^4 L_{\phi}^8 L_{\theta}^2 L_{w}^2 }{ \nu^4 \varepsilon^2 } + \frac{ M \sbr{k^2 + k \gamma L_{\theta}^2 } }{\varepsilon^2} \Bigg) .
\end{align*}
\end{proof}
\section{Technical Tools}
In this section, we provide some useful technical tools.
\begin{lemma}[Matrix Bernstern Inequality - Average, Lemma 31 in \cite{tripuraneni2021provable}] \label{lemma:matrix_bernstein_tripuraneni2021}
Consider a truncation level $U>0$. If $\{\boldsymbol{Z}_1,\dots,\boldsymbol{Z}_n\}$ is a sequence of $d_1 \times d_2$ independent random matrices and
$\boldsymbol{Z}'_i = \boldsymbol{Z}_i \cdot \indicator{\|\boldsymbol{Z}_i\| \leq U}$ for any $i \in [n]$, then
\begin{align*}
\Pr \mbr{ \nbr{ \frac{1}{n} \sum_{i=1}^{n} \sbr{ \boldsymbol{Z}_i - \mathbb{E}[\boldsymbol{Z}_i] } } \geq t } \leq
\Pr \mbr{ \nbr{ \frac{1}{n} \sum_{i=1}^{n} \sbr{ \boldsymbol{Z}'_i - \mathbb{E}[\boldsymbol{Z}'_i] } } \geq t - \Delta } + n \Pr \mbr{ \|\boldsymbol{Z}_i\| \geq U } ,
\end{align*}
where $\Delta \geq \|\mathbb{E}[\boldsymbol{Z}_i]-\mathbb{E}[\boldsymbol{Z}'_i]\|$ for any $i \in [n]$.
In addition, for $t \geq \Delta$, we have
\begin{align*}
\Pr \mbr{ \nbr{ \frac{1}{n} \sum_{i=1}^{n} \sbr{ \boldsymbol{Z}'_i - \mathbb{E}[\boldsymbol{Z}'_i] } } \geq t - \Delta } \leq (d_1 + d_2) \exp \sbr{- \frac{n^2 (t-\Delta)^2}{2\sigma^2 + \frac{2Un(t-\Delta)}{3}}} ,
\end{align*}
where
\begin{align*}
\sigma^2 = & \max \lbr{ \nbr{\sum_{i=1}^{n} \mathbb{E}[(\boldsymbol{Z}'_i-\mathbb{E}[\boldsymbol{Z}'_i])^\top (\boldsymbol{Z}'_i-\mathbb{E}[\boldsymbol{Z}'_i])]},\ \nbr{\sum_{i=1}^{n} \mathbb{E}[(\boldsymbol{Z}'_i-\mathbb{E}[\boldsymbol{Z}'_i]) (\boldsymbol{Z}'_i-\mathbb{E}[\boldsymbol{Z}'_i])^\top]} }
\\
\leq & \max \lbr{ \nbr{\sum_{i=1}^{n} \mathbb{E}[{\boldsymbol{Z}'_i}^\top \boldsymbol{Z}'_i]},\ \nbr{\sum_{i=1}^{n} \mathbb{E}[\boldsymbol{Z}'_i {\boldsymbol{Z}'_i}^\top]} } .
\end{align*}
\end{lemma}
Lemma 31 in \cite{tripuraneni2021provable} gives a truncated matrix Bernstern inequality for symmetric random matrices. Here we extend it to general random matrices.
Lemma~\ref{lemma:matrix_bernstein_tripuraneni2021} can be obtained by combining the truncation argument in the proof of Lemma 31 in \cite{tripuraneni2021provable} and Theorem 6.1.1 in \cite{tropp2015introduction} (classic matrix Bernstern inequality for general random matrices).
\begin{lemma}[Matrix Bernstern Inequality - Summation] \label{lemma:matrix_bernstein_tau}
Consider a truncation level $U>0$. If $\{\boldsymbol{Z}_1,\dots,\boldsymbol{Z}_n\}$ is a sequence of $d_1 \times d_2$ independent random matrices, and $\boldsymbol{Z}'_i = \boldsymbol{Z}_i \cdot \indicator{\|\boldsymbol{Z}_i\| \leq U}$ and $\Delta \geq \|\mathbb{E}[\boldsymbol{Z}_i]-\mathbb{E}[\boldsymbol{Z}'_i]\|$ for any $i \in [n]$, then for $\tau \geq 2 n\Delta$,
\begin{align*}
\Pr \mbr{ \nbr{ \sum_{i=1}^{n} \sbr{ \boldsymbol{Z}_i - \mathbb{E}[\boldsymbol{Z}_i] } } \geq \tau } \leq
(d_1 + d_2) \exp \sbr{- \frac{1}{4} \cdot \frac{ \tau^2}{2\sigma^2 + \frac{U \tau}{3}}} + n \Pr \mbr{ \|\boldsymbol{Z}_i\| \geq U } ,
\end{align*}
where
\begin{align*}
\sigma^2 = & \max \lbr{ \nbr{\sum_{i=1}^{n} \mathbb{E}[(\boldsymbol{Z}'_i-\mathbb{E}[\boldsymbol{Z}'_i])^\top (\boldsymbol{Z}'_i-\mathbb{E}[\boldsymbol{Z}'_i])]},\ \nbr{\sum_{i=1}^{n} \mathbb{E}[(\boldsymbol{Z}'_i-\mathbb{E}[\boldsymbol{Z}'_i]) (\boldsymbol{Z}'_i-\mathbb{E}[\boldsymbol{Z}'_i])^\top]} }
\\
\leq & \max \lbr{ \nbr{\sum_{i=1}^{n} \mathbb{E}[{\boldsymbol{Z}'_i}^\top \boldsymbol{Z}'_i]},\ \nbr{\sum_{i=1}^{n} \mathbb{E}[\boldsymbol{Z}'_i {\boldsymbol{Z}'_i}^\top]} } .
\end{align*}
Furthermore, we have
\begin{align*}
\Pr \mbr{ \nbr{ \sum_{i=1}^{n} \sbr{ \boldsymbol{Z}_i - \mathbb{E}[\boldsymbol{Z}_i] } } \geq 4 \sqrt{ \sigma^2 \log \sbr{\frac{d_1 + d_2}{\delta}} } + 4 U \log \sbr{\frac{d_1 + d_2}{\delta}} } \leq
\delta + n \Pr \mbr{ \|\boldsymbol{Z}_i\| \geq U } .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:matrix_bernstein_tau}]
Using Lemma~\ref{lemma:matrix_bernstein_tripuraneni2021} and defining $\tau:=nt$, we have that for $\tau>n\Delta$,
\begin{align*}
\Pr \mbr{ \nbr{ \sum_{i=1}^{n} \sbr{ \boldsymbol{Z}_i - \mathbb{E}[\boldsymbol{Z}_i] } } \geq \tau } \leq &
(d_1 + d_2) \exp \sbr{- \frac{ (\tau-n \Delta)^2}{2\sigma^2 + \frac{2U(\tau-n \Delta)}{3}}} + n \Pr \mbr{ \|\boldsymbol{Z}_i\| \geq U } .
\end{align*}
If $\tau>2n\Delta$, then $\tau-n\Delta>\frac{1}{2} \tau$ and we have
\begin{align}
\Pr \mbr{ \nbr{ \sum_{i=1}^{n} \sbr{ \boldsymbol{Z}_i - \mathbb{E}[\boldsymbol{Z}_i] } } \geq \tau }
\leq & (d_1 + d_2) \exp \sbr{- \frac{ \sbr{\frac{1}{2} \tau}^2}{2\sigma^2 + \frac{2U \sbr{\frac{1}{2} \tau}}{3} } } + n \Pr \mbr{ \|\boldsymbol{Z}_i\| \geq U }
\nonumber\\
\leq & (d_1 + d_2) \exp \sbr{- \frac{1}{4} \cdot \frac{ \tau^2 }{2\sigma^2 + \frac{U \tau}{3} }} + n \Pr \mbr{ \|\boldsymbol{Z}_i\| \geq U } . \label{eq:matrix_bernstein_error}
\end{align}
Plugging $\tau=4 \sqrt{ \sigma^2 \log \sbr{\frac{d_1 + d_2}{\delta}} } + 4 U \log \sbr{\frac{d_1 + d_2}{\delta}}$ into Eq.~\eqref{eq:matrix_bernstein_error}, we have
\begin{align*}
& \Pr \mbr{ \nbr{ \sum_{i=1}^{n} \sbr{ \boldsymbol{Z}_i - \mathbb{E}[\boldsymbol{Z}_i] } } \geq 4 \sqrt{ \sigma^2 \log \sbr{\frac{d_1 + d_2}{\delta}} } + 4 U \log \sbr{\frac{d_1 + d_2}{\delta}} }
\\
\leq & (d_1 + d_2) \exp \sbr{- \frac{1}{4} \cdot \frac{ 16 \sigma^2 \log \sbr{\frac{d_1 + d_2}{\delta}} + 16 U^2 \log^2 \sbr{\frac{d_1 + d_2}{\delta}} + 32 U \log \sbr{\frac{d_1 + d_2}{\delta}} \sqrt{ \sigma^2 \log \sbr{\frac{d_1 + d_2}{\delta}} } }{2\sigma^2 + \frac{1}{3} \sbr{4U \sqrt{ \sigma^2 \log \sbr{\frac{d_1 + d_2}{\delta}} } + 4 U^2 \log \sbr{\frac{d_1 + d_2}{\delta}} }} } \\& + n \Pr \mbr{ \|\boldsymbol{Z}_i\| \geq U}
\\
\leq & (d_1 + d_2) \exp \sbr{- \frac{1}{4} \cdot 4 \log \sbr{\frac{d_1 + d_2}{\delta}} } + n \Pr \mbr{ \|\boldsymbol{Z}_i\| \geq U }
\\
= & \delta + n \Pr \mbr{ \|\boldsymbol{Z}_i\| \geq U } .
\end{align*}
\end{proof}
\begin{lemma}\label{lemma:technical_tool_bai_stage2}
For any $A,B>1$, $\kappa \in (0,1)$ and $T>0$ such that $\log\sbr{\frac{AB}{\kappa}}>1$ and $\log(BT)>2$, if
$$
T \geq \frac{68 A^2 \log^2 \sbr{\frac{AB}{\kappa}} }{\kappa^2} ,
$$
then
$$
\frac{A}{\sqrt{T}} \log(B T) \leq \kappa .
$$
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:technical_tool_bai_stage2}]
If $T = \frac{68 A^2 \log^2 \sbr{\frac{AB}{\kappa}} }{\kappa^2}$, we have
\begin{align*}
\frac{A}{\sqrt{T}} \log(B T) = & \frac{A \kappa}{ \sqrt{68} A \log \sbr{\frac{AB}{\kappa}} } \log \sbr{ \frac{68 A^2 B \log^2 \sbr{\frac{AB}{\kappa}} }{\kappa^2}}
\\
= & \frac{\kappa}{ \sqrt{68} \log \sbr{\frac{AB}{\kappa}} } \sbr{ \log \sbr{68} + \log \sbr{ \frac{A^2 B}{\kappa^2}} + \log \sbr{ \log^2 \sbr{\frac{AB}{\kappa}} } }
\\
\leq & \frac{\kappa}{ \sqrt{68} \log \sbr{\frac{AB}{\kappa}} } \sbr{ \log \sbr{68} + 2 \log \sbr{ \frac{A B}{\kappa}} + 2 \log \sbr{ \frac{AB}{\kappa} } }
\\
\leq & \frac{\kappa}{ \sqrt{68} \log \sbr{\frac{AB}{\kappa}} } \sbr{ \log \sbr{68} \log \sbr{ \frac{A B}{\kappa}} + 4 \log \sbr{ \frac{A B}{\kappa}} }
\\
\leq & \kappa .
\end{align*}
Let $f(T)=\frac{A}{\sqrt{T}} \log(B T)$. Then, the derivative of $f(T)$ is
\begin{align*}
f'(T)= \frac{2A-A\log(BT)}{2T\sqrt{T}} .
\end{align*}
If $\log(BT)>2$, then $f'(T)<0$, and thus $f(T)$ is decreasing with respect to $T$.
Therefore, if $T \geq \frac{68 A^2 \log^2 \sbr{\frac{AB}{\kappa}} }{\kappa^2}$, we have
\begin{align*}
\frac{A}{\sqrt{T}} \log(B T) \leq \kappa.
\end{align*}
\end{proof}
\begin{lemma}\label{lemma:technical_tool_log_N_square}
For any $A,B>1$ and $\kappa \in (0,1)$ such that $\log (\frac{AB}{\kappa})>1$ and $\log(BN)>4$, if
$$
N \geq \frac{26^4 A^2 \log^4 (\frac{AB}{\kappa}) }{\kappa^2} ,
$$
then
$$
\frac{A \log^2 \sbr{BN}}{\sqrt{N}} \leq \kappa .
$$
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:technical_tool_log_N_square}]
If $N = \frac{26^4 A^2 \log^4 (\frac{AB}{\kappa}) }{\kappa^2}$, we have
$
\kappa \sqrt{N} = 26^2 A \log^2 (\frac{AB}{\kappa})
$,
and
\begin{align*}
A \log^2 \sbr{BN} = & A \log^2 \sbr{ \frac{26^4 A^2 B \log^4 (\frac{AB}{\kappa}) }{\kappa^2} }
\\
\leq & A \log^2 \sbr{ \frac{26^4 A^2 B }{\kappa^2} \cdot \frac{A^4 B^4}{\kappa^4} }
\\
\leq & 36 A \log^2 \sbr{ \frac{26 A B }{\kappa} }
\\
= & 36 A \sbr{\log \sbr{26} + \log \sbr{ \frac{A B }{\kappa} }}^2
\\
\leq & 36 A \sbr{\log \sbr{26} \log \sbr{ \frac{A B }{\kappa} } + \log \sbr{ \frac{A B }{\kappa} }}^2
\\
= & 36 \sbr{\log \sbr{26}+1}^2 A \log^2 \sbr{ \frac{A B }{\kappa} }
\\
\leq & 26^2 A \log^2 \sbr{ \frac{A B }{\kappa} }
\\
= & \kappa \sqrt{N} ,
\end{align*}
and thus $\frac{A \log^2 \sbr{BN}}{\sqrt{N}} \leq \kappa$.
Let $f(N)=\frac{A \log^2 \sbr{BN}}{\sqrt{N}}$. Then, the derivative function of $f(N)$ is
\begin{align*}
f'(N)= \frac{4A\log(BN)-A\log^2(BN)}{2N\sqrt{N}} = \frac{A\log(BN) \cdot (4-\log(BN))}{2N\sqrt{N}} .
\end{align*}
If $\log(BN)>4$, then $f'(N)<0$, and thus $f(N)$ is decreasing with respect to $N$.
Therefore, if $N \geq \frac{26^4 A^2 \log^4 (\frac{AB}{\kappa}) }{\kappa^2}$, we have
$\frac{A \log^2 \sbr{BN}}{\sqrt{N}} \leq \kappa$.
\end{proof}
\begin{lemma}\label{lemma:sqrt_n_k}
For any $\boldsymbol{x}_1,\dots,\boldsymbol{x}_n \in \mathbb{R}^k$, we have
\begin{align*}
\sum_{j=1}^{n} \|\boldsymbol{x}_j\|_{\sbr{\sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1}} \leq \sqrt{nk} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:sqrt_n_k}]
It holds that
\begin{align*}
\sum_{j=1}^{n} \|\boldsymbol{x}_j\|_{\sbr{\sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1}} = & \sum_{j=1}^{n} \sqrt{\boldsymbol{x}_j^\top \sbr{\sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} \boldsymbol{x}_j}
\\
\leq & \sqrt{ n \cdot \sum_{j=1}^{n} \boldsymbol{x}_j^\top \sbr{\sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} \boldsymbol{x}_j}
\\
\leq & \sqrt{ n \cdot \sum_{j=1}^{n} \textup{Trace} \sbr{ \boldsymbol{x}_j^\top \sbr{\sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} \boldsymbol{x}_j}}
\\
= & \sqrt{ n \cdot \sum_{j=1}^{n} \textup{Trace} \sbr{ \boldsymbol{x}_j \boldsymbol{x}_j^\top \sbr{\sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} }}
\\
= & \sqrt{ n \cdot \textup{Trace} \sbr{ \sum_{j=1}^{n} \boldsymbol{x}_j \boldsymbol{x}_j^\top \sbr{\sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} }}
\\
= & \sqrt{ n \cdot \textup{Trace} \sbr{ \boldsymbol{I}_k } }
\\
= & \sqrt{ n k }
\end{align*}
\end{proof}
\begin{lemma}\label{lemma:sqrt_n_k_gamma}
For any $\boldsymbol{x}_1,\dots,\boldsymbol{x}_n \in \mathbb{R}^k$ and $\gamma>0$, we have
\begin{align*}
\sum_{j=1}^{n} \|\boldsymbol{x}_j\|_{\sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1}} \leq \sqrt{nk} .
\end{align*}
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lemma:sqrt_n_k_gamma}]
It holds that
\begin{align*}
\sum_{j=1}^{n} \|\boldsymbol{x}_j\|_{\sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1}} = & \sum_{j=1}^{n} \sqrt{\boldsymbol{x}_j^\top \sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} \boldsymbol{x}_j}
\\
\leq & \sqrt{ n \cdot \sum_{j=1}^{n} \boldsymbol{x}_j^\top \sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} \boldsymbol{x}_j}
\\
= & \sqrt{ n \cdot \sum_{j=1}^{n} \textup{Trace} \sbr{ \boldsymbol{x}_j^\top \sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} \boldsymbol{x}_j}}
\\
= & \sqrt{ n \cdot \sum_{j=1}^{n} \textup{Trace} \sbr{ \boldsymbol{x}_j \boldsymbol{x}_j^\top \sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} }}
\\
= & \sqrt{ n \cdot \textup{Trace} \sbr{ \sum_{j=1}^{n} \boldsymbol{x}_j \boldsymbol{x}_j^\top \sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} }}
\\
\overset{\textup{(a)}}{\leq} & \sqrt{ n \!\cdot\! \sbr{\textup{Trace} \sbr{ \sum_{j=1}^{n} \boldsymbol{x}_j \boldsymbol{x}_j^\top \sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{\!\!\!-1} } \!+\! \textup{Trace} \sbr{ \gamma \sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{\!\!\!-1} } } }
\\
= & \sqrt{ n \cdot \textup{Trace} \sbr{ \sum_{j=1}^{n} \boldsymbol{x}_j \boldsymbol{x}_j^\top \sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} + \gamma \sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} }}
\\
= & \sqrt{ n \cdot \textup{Trace} \sbr{ \sbr{\gamma I + \sum_{j=1}^{n} \boldsymbol{x}_j \boldsymbol{x}_j^\top} \sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}^{-1} } }
\\
= & \sqrt{ n \cdot \textup{Trace} \sbr{ \boldsymbol{I}_k } }
\\
= & \sqrt{ n k } ,
\end{align*}
where inequality (a) is due to that $\sbr{\gamma I + \sum_{i=1}^{n} \boldsymbol{x}_i \boldsymbol{x}_i^\top}$ is a positive definite matrix.
\end{proof}
\begin{lemma}[Self-normalized Concentration for Martingales, Theorem 1 in \cite{abbasi2011improved}]\label{lemma:self-normalized_vector_concentration}
Let $\{\mathcal{F}_t\}_{t=0}^{\infty}$ be a filtration such that for any $t \geq 1$, the selected action $\boldsymbol{X}_t \in \mathbb{R}^k$ is $\mathcal{F}_{t-1}$-measurable, the noise $\eta_t \in \mathbb{R}$ is $\mathcal{F}_{t}$-measurable, and conditioning on $\mathcal{F}_{t-1}$, $\eta_t$ is zero-mean and $R$-sub-Gaussian. Let $\boldsymbol{V}_0 \in \mathbb{R}^{k \times k}$ be a positive definite matrix and let $\boldsymbol{V}_t=\sum_{i=1}^{t} \boldsymbol{X}_i \boldsymbol{X}_i^\top$ for any $t \geq 1$. Then, for any $\delta>0$, with probability at least $1-\delta$, for all $t \geq 1$,
\begin{align*}
\nbr{\sum_{i=1}^{t} \boldsymbol{X}_i \cdot \eta_i}^2_{\sbr{\boldsymbol{V}_0+\boldsymbol{V}_t}^{-1}} \leq 2R^2 \log \sbr{ \frac{\det(\boldsymbol{V}_t)^{\frac{1}{2}} }{ \det(\boldsymbol{V}_0)^{\frac{1}{2}} \cdot \delta} } .
\end{align*}
\end{lemma}
\begin{lemma}[Reverse Bernstein Inequality for Martingales, Theorem 3 in \cite{zanette2021design}] \label{lemma:reverse_bernstein}
Let $(\boldsymbol{\Sigma},\mathcal{F},\Pr[\cdot])$ be a probability space and consider the stochastic process $\{\boldsymbol{X}_t\}$ adapted to the filtration $\{\mathcal{F}_t\}$. Let $\mathbb{E}_t [\boldsymbol{X}_t]:=\mathbb{E}[\boldsymbol{X}_t|\mathcal{F}_{t-1}]$ be the conditional expectation of $\boldsymbol{X}_t$ given $\mathcal{F}_{t-1}$. If $0 \leq \boldsymbol{X}_t \leq 1$ then it holds that
\begin{align*}
\Pr \mbr{ \sum_{t=1}^{T} \mathbb{E}_t [\boldsymbol{X}_t] \geq \frac{1}{4} \sbr{ 2\sqrt{\log \sbr{\frac{1}{\delta}}} + \sqrt{ 4 \log \sbr{\frac{1}{\delta}} + 4 \sbr{ \sum_{t=1}^{T} \boldsymbol{X}_t + 2 \log \sbr{\frac{1}{\delta}} } } }^2 } \leq \delta .
\end{align*}
\end{lemma}
\begin{lemma}[Elliptical Potential Lemma, Lemma 11 in \cite{abbasi2011improved}] \label{lemma:elliptical_potential}
Let $\{\boldsymbol{X}_t\}_{t=1}^{\infty}$ be a sequence in $\mathbb{R}^k$. Let $\boldsymbol{V}_0$ be a $k \times k$ positive definite matrix and let $\boldsymbol{V}_t = \boldsymbol{V}_0 + \sum_{i=1}^{t} \boldsymbol{X}_i \boldsymbol{X}_i^\top$ such that for any $t \geq 1$, $\|\boldsymbol{X}_t\|^2_{\boldsymbol{V}_{t-1}^{-1}} \leq 1$. Then, we have that
\begin{align*}
\sum_{t=1}^{n} \nbr{ \boldsymbol{X}_t }^2_{\boldsymbol{V}_{t-1}^{-1}} \leq 2 \log \frac{\det(\boldsymbol{V}_n)}{\det(\boldsymbol{V}_0)} .
\end{align*}
\end{lemma}
\begin{lemma}[Moments of Sub-Gaussian Random Variables, Proposition 3.2 in \cite{subgaussian_note}] \label{lemma:subgaussian_moment}
For a $\sigma^2$-sub-Gaussian random variable $\boldsymbol{X}$ which satisfies
\begin{align*}
\mathbb{E} \mbr{ \exp \sbr{\mu \boldsymbol{X} } } \leq \exp \sbr{ \frac{\sigma^2 \mu^2}{2} }, \ \forall \mu \in \mathbb{R} ,
\end{align*}
we have that for any integer $n \geq 1$,
\begin{align*}
\mathbb{E} [|\boldsymbol{X}|^{n}] \leq \sbr{2\sigma^2}^{\frac{n}{2}} n \cdot \Gamma\sbr{\frac{n}{2}} ,
\end{align*}
where $\Gamma(n):=(n-1)!$ for any integer $n\geq1$.
\end{lemma}
| {'timestamp': '2023-02-10T02:06:44', 'yymm': '2302', 'arxiv_id': '2302.04441', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04441'} | arxiv |
\section{Introduction}
\vspace{-0.05cm}
\begin{figure}
\centering
\includegraphics[width=0.45\textwidth]{fig/model_intro_6.pdf}
\vspace{-0.3cm}
\caption{Overview for the bag of tricks explored in this work, with an evaluation of precision ($\mathcal{M}_P$). Bars in \textcolor{ured}{pink} denote the methods in the improved suffix generation, and bars in \textcolor{orange}{orange} denote the methods in the improved suffix ranking. The \emph{dashed bars} indicate the best method in each category.}
\vspace{-0.3cm}
\label{fig: overview}
\end{figure}
Recent advances in language models (LMs) have led to impressive performance in a variety of downstream language tasks~\citep{kenton2019bert,brown2020language}. It has been demonstrated, however, that training data can be extracted from LMs due to the memorization effects~\citep{kenton2019bert,carlini2019secret,feldman2020does,brown2020language}. These training data may contain sensitive information such as names, email addresses, phone numbers, and physical addresses, resulting in privacy leakage that hinders the widespread adoption of LMs~\citep{carlini2021extracting,carlini2022quantifying,lehman2021does}.
As privacy security has been an important issue of public concern, a crucial topic is to develop efficient methods for evaluating privacy leakage. Thus, the focus of our research is on the adversarial task of training data extraction from LMs, a relatively new area of study~\citep{carlini2021extracting,lehman2021does}. Existing extraction methods have yielded successful records, but there are instances in which these methods are even less effective than simply selecting the most popular entity based on prior score. In addition, successful data extraction requires a high generation ratio, i.e., the need to generate and rank a large number of candidates in order to identify a single successful instance. These suboptimal results suggest that, despite the viability of training data extraction and developed pioneering methods as demonstrated in previous research, this task is still relatively new with an abundance of problems to solve
In this study, we aim to develop techniques for efficient training data extraction. We adhere to the criteria of the recent Training Data Extraction Challenge,\footnote{\url{https://github.com/google-research/lm-extraction-benchmark}} which employs a 1.3B parameter GPT-Neo model~\citep{gpt-neo} for \emph{targeted extraction of $1$-eidetic memorized data}. Targeted extraction refers to the scenario where a prefix of the data is provided, such as `Yu's phone number is', and the adversary attempts to recover the suffix `12345'. Accroding to \citet{carlini2021extracting}, $\kappa$-eidetic memorization is defined as the capacity of a language model to memorize a string that appears $\kappa$ times in the training material. The targeted and $1$-eidetic extraction poses a greater risk and is more challenging than non-targeted and $\kappa$-eidetic (for $\kappa>1$) settings.
Through ablation studies, we assess a variety of simple techniques in natural language processing (NLP) and empirically evaluate their impact on successful extraction rates, as in Figure~\ref{fig: overview}. Our empirical analysis reveals that the extraction performance may be sensitive to the experimental setup.
With proper settings, the results show that several previously overlooked tricks can contribute to significant improvements of training data extraction.
Based on the GPT-Neo 1.3B evaluation results, our proposed tricks outperform the baseline by a large margin in most cases, providing a much stronger baseline for future research.
Nonetheless, utilizing more than one training data extraction trick does not necessarily boost the performance, and in some cases, even shows incompatibility and results in inferior precision. These findings suggest that judicious selection and combination of the tricks are essential for optimal performance.
\vspace{-0.2cm}
\section{Related Work}
\vspace{-0.05cm}
We briefly introduce training data extraction, membership inference attacks, and other memorization-based attacks.
\vspace{-0.1cm}
\subsection{Training Data Extraction}
\vspace{-0.05cm}
The extraction of training data from a pretrained language model, also referred to as language model data extraction, is a method for recovering the examples used to train the model. Despite being a relatively new task, many of the underlying technologies and analysis methods, including membership inference~\citep{shokri2017membership} and leveraging network memorization for attacks~\citep{thomas2020investigating,leino2020stolen}, were introduced much earlier.
\citet{carlini2021extracting} were among the first to define the concepts of model knowledge extraction and $\kappa$-eidetic memorization, as well as to propose promising training strategies for data extraction. Both the theoretical properties of memorization and the application of model extraction in sensitive fields, such as the analysis of clinical notes, have been the focus of subsequent research in this field.
Recently, \citet{kandpal2022deduplicating} demonstrated that in language models, the efficacy of data extraction is frequently attributable to duplication in commonly used web-scraped training sets. Using nondeterminism, \citet{jagielski2022measuring} provided an explanation for forgetting memorized examples. \citet{carlini2022quantifying} analyzed three factors that affect the memorization of training data. For natural data distributions, \citet{feldman2020does} showed that label memorization is required to achieve near-optimal performance. In the application of model extraction, \citet{lehman2021does} indicated that pretrained BERT, when trained on clinical notes, poses a risk of sensitive data leakage, especially when the data exhibits a high level of repetition or `note bloat'~\citep{liu2022note}. \citet{jayaraman2022active} proposed an active extraction attack that employs canonical patterns and differential privacy to defend against pattern extraction attacks.
\vspace{-0.1cm}
\subsection{Membership Inference Attacks}
\vspace{-0.05cm}
The membership inference attack (MIA)~\citep{shokri2017membership} is another adversarial task in data protection that is closely associated with training data extraction. It aims to determine whether a particular record is present in its training dataset, given black-box access to a model. MIA has been demonstrated to be effective on numerous machine learning tasks, including classification~\citep{sablayrolles2019white,choquette2021label,rezaei2021difficulty} and generation~\citep{hayes2019logan,hilprecht2019monte}.
The methods utilized by MIA fall into two categories: classifier-based methods and metric-based methods~\citep{hu2022membership}. Classifier-based methods involve training a binary classifier to recognize the complex relationship between members and non-members, with shadow training being a commonly used technique~\citep{shokri2017membership,he2020segmentations,wang2021against}. Metric-based methods, on the other hand, make membership inferences by first calculating metrics on the model prediction vectors~\citep{yeom2018privacy,salem2018ml,sablayrolles2019white,song2021systematic,choquette2021label}. Several defense methods based on differential privacy~\citep{leino2020stolen,naseri2020toward,choquette2021label}, data pruning~\citep{wang2021against}, data augmentation~\citep{kaya2021does} and causal inference~\citep{tople2020alleviating} have been proposed to mitigate this vulnerability.
\vspace{-0.1cm}
\subsection{Other Memorization-Based Attacks}
\vspace{-0.05cm}
It has been discovered that large pretrained models are susceptible to memorizing information from the training data, which can lead to a variety of attacks. In addition to training data extraction and membership inference attacks, there are other memorization-based attacks that target these models.
Model extraction attacks and the corresponding protection methods~\citep{tramer2016stealing,juuti2019prada,gong2020model,wu2022model} focus on the issue of duplicating the functionality of a given model. In this type of attacks, the adversary attempts to build a second model with a similar predictive performance to the original black-box model.
The objective of attribute inference attacks is to extract specific personal attributes such as locations, occupations, and interests from the model~\citep{fredrikson2015model,gong2016you,ganju2018property,parisot2021property}. The objective of property inference attacks is to extract properties of the training data that the model producer may not have intended to share, such as the environment in which the data was generated or the proportion of the data that belongs to a particular class. The primary distinction between training data extraction attacks and attribute/property inference attacks is that attribute/property inference attacks do not require prior knowledge of the attributes or properties to be extracted, whereas training data extraction attacks require the generated information to be identical to the training data at the sentence level, which is more difficult and dangerous.
\vspace{-0.3cm}
\section{Preliminary} \label{sect: definition}
\vspace{-0.05cm}
We recap the basic setups employed in our study. These setups mainly follow the guidelines of the Training Data Extraction Challenge. We then define the threat model and evaluation metrics.
\vspace{-0.15cm}
\subsection{Basic Setups}
\vspace{-0.05cm}
\textbf{Dataset.} The dataset used in this study is a subset of 20,000 examples from the Pile's training dataset~\citep{gao2020pile}. Each example consists of a 50-token prefix and a 50-token suffix. The attacker's task is to predict the suffix given the prefix. All the 100-token long sentences in this dataset appear only once in the training set. For the purposes of this study, we divide the dataset into a training set of 19,000 samples and a testing set of 1,000 samples.
\textbf{Language model.} We employ the GPT-Neo 1.3B model implemented on HuggingFace Transformers~\citep{wolf2020transformers}, which is a transformer model designed using EleutherAI's replication of the GPT-3 architecture~\citep{brown2020language}, and trained on the Pile dataset. GPT-Neo is an autoregressive language model $f_{\theta}$ parameterized by $\theta$, which generates a sequence of tokens $x_{0},x_{1},\cdots,x_{N}$ via the chain rule
\begin{equation}
f_{\theta}\left(x_{0},x_{1},\cdots,x_{N}\right)=\prod_{n=0}^{N}f_{\theta}\left(x_{n}|x_{[0,n-1]}\right)\textrm{,}
\end{equation}
where $x_{[0,n-1]}=x_{<n}=\{x_{0},\cdots,x_{n-1}\}$ for notation compactness. At the sentence level, given a prefix $p$, we denote the probability of generating a certain suffix $s$ conditional on the prefix $p$ as $f_{\theta}(s|p)$.
\vspace{-0.15cm}
\subsection{Threat Model}
\vspace{-0.05cm}
In this study, we focus on the threat model of targeted extraction of $\kappa$-eidetic memorized data, where we choose $\kappa=1$. According to the model knowledge extraction defined in \citep{carlini2021extracting}, we assume the language model generates a suffix $s$ by the most-likely criterion. Then we can write a formal definition of targeted extraction as
\begin{definition}
(Targeted extraction) Given a prefix $p$ contained in the training data and a pretrained language model $f_{\theta}$.
Targeted extraction is to generate the suffix by $s=\textrm{argmax}_{s'} f_{\theta}(s'|p)$.
\end{definition}
As to $\kappa$-eidetic memorized data, we follow the definition in \citet{carlini2021extracting} that the sentence $[p,s]$ appears in at most $\kappa$ examples in the training data. In practice, the length of the generated sentence is typically fixed using truncating and concatenation techniques applied to the training dataset. If a generated sentence is shorter than the specified length, padding tokens are used to bring it up to the required length. In this study, the generated sentence length is 100.
\vspace{-0.cm}
\subsection{Evaluation Metrics}
\vspace{-0.cm}
Non-targeted extraction has been evaluated using the number of memorized examples in previous studies~\citep{carlini2021extracting}. To evaluate more comprehensively, we use three metrics to evaluate performance in this targeted data extraction task, including precision $\mathcal{M}_{\textrm{P}}$, recall $\mathcal{M}_{\textrm{R}}$ and Hamming distance $\mathcal{M}_{\textrm{H}}$.
\textbf{Precision $\mathcal{M}_{\textrm{P}}$.}
The proportion of correctly generated suffixes over the total number of given prefixes is referred to as precision $\mathcal{M}_{\textrm{P}}$. Notice that for a correct generation, the suffix and ground truth must be identical in both sentence length and generated tokens.
\textbf{Recall $\mathcal{M}_{\textrm{R}}$.} The proportion of correctly generated suffixes over the total number of generated suffixes is indicated by recall $\mathcal{M}_{\textrm{R}}$. The metric used in the Training Data Extraction Challenge is denoted by $\boldsymbol{e}_{j}$, which is defined as the number of correctly recovered suffixes when the number of incorrectly generated suffixes reaches a threshold of $j$. $\boldsymbol{e}_{j}$ can assess the effectiveness of the attack. We define $\mathcal{M}_{\textrm{R}}=\frac{\boldsymbol{e}_{j}}{\boldsymbol{e}_{j}+j}$, we will use $\mathcal{M}_{\textrm{R}}$ instead of $e_j$ in the following paragraphs. In our experiments, the value of $j$ is chosen to be proportional to the size of the test set, and it is set to 100 with a test set of 1,000 prefixes.
\textbf{Hamming distance $\mathcal{M}_{\textrm{H}}$.} The Hamming distance denotes the difference between two equal-length strings, calculated as the number of positions where the corresponding symbols differ. We can quantitatively evaluate the similarity between the generated suffixes and the ground truth using the average Hamming distance, providing a token-level evaluation of the extraction methods' performance. $\mathcal{M}_{\textrm{H}} = \frac{1}{N}\sum_{n} x_n\oplus gt_n$, where $a\oplus b=1 \;\textrm{if}\; a=b, \textrm{else}\; 0$. $N$ is the number of tokens in a generated sentence, $x_n$ is the generated token, and $gt_n$ is the corresponding ground truth token.
We would like to point out that the commonly used metrics that measure the repetition or quality of generated sentences, e.g., the Zipfian coefficient and REP~\citep{welleck2019neural}, may not be aligned with the goal of training data extraction. Thus, we propose the metrics listed above, which are specifically designed to assess the efficacy of training data extraction methods. These metrics, $\mathcal{M}_{\textrm{P}}$, $\mathcal{M}_{\textrm{R}}$, and $\mathcal{M}_{\textrm{H}}$, are closely linked with the success rate of the extracted data rather than the quality of generated language.
\vspace{-0.cm}
\section{Pipeline Overview}
\vspace{-0.cm}
A basic training data extraction pipeline can be divided into two stages. The first stage is \emph{suffix generation}, which means coming up with a set of suffixes based on a prefix. The autoregressive language model $f_{\theta}$ computes the probability of each token in a vocabulary list and generates the next token by sampling from the probability distribution. A basic strategy employed to control the number of generations is limiting to the top-$k$ tokens with $k=10$, which means the LMs only sample from the tokens with top-$k$ probability. The second stage is \emph{suffix ranking}, which entails estimating the likelihood of these suffixes and retaining only those with a high probability. Typically this is accomplished through the use of membership inference attacks, determined based on the perplexity metric~\citep{carlini2019secret,carlini2021extracting} as
\begin{equation}
\mathcal{P} = \exp\left(-\frac{1}{N}\sum_{n=0}^{N} \log f_{\theta}(x_n|x_{[0:n-1]})\right)\textrm{.}
\end{equation}
where $N$ is the number of tokens in a generated sentence.
We explore and evaluate various tricks for both stages. The results for suffix generation are presented in Section~\ref{sect: tricks}, and the results for suffix ranking are presented in Section~\ref{sect: ranking}.
\section{Improved Suffix Generation} \label{sect: tricks}
To improve suffix generation, we analyze the logits distributions of both the ground-truth and generated tokens. As shown in Figure~\ref{fig:token_hist_spline}, there is a significant difference between the two distributions. To address this, we examine the effects of a variety of NLP techniques, such as changes to sampling strategies and probability distributions, as described below.
\subsection{Sampling Strategy} \label{sect:sampling}
{The most popular decoding objective, especially for conditional generation in NLP tasks, is maximization-based decoding. Based on the provided prefix, it searches for the suffix with the highest likelihood. It is also suited for our training data extraction task since the models are directly maximized for the likelihood of the training data. However, finding the theoretically argmax sequence from models is intractable~\citep{holtzman2019curious}. The common practice is using beam search~\citep{freitag-al-onaizan-2017-beam} instead.
As an approximate solution, beam search only keeps a predetermined number of best partial solutions.
Since it always takes the top ones at each step, it is often criticized for its lack of diversity~\citep{holtzman2019curious}.
As shown in Table~\ref{tab:beams}, although the required memory is increasing, the performance gain from a larger beam width diminishes quickly when the beam width exceeds two.
Due to the randomness in generation, sampling methods always introduce more diversity than beam search.
Therefore, we mainly study sampling strategies below, including top-$k$ sampling, nucleus sampling and typical sampling.
}
\begin{table}[t]
\centering
\small
\vspace{-0.3cm}
\caption{Results of $\mathcal{M}_{\textrm{P}}$, $\mathcal{M}_{\textrm{R}}$, and $\mathcal{M}_{\textrm{H}}$ under different numbers of beams in beam search. All results are reported on a single trial.}
\vspace{0.1in}
\begin{tabular}{crccc}
\toprule
\textbf{Beam} & \textbf{Memory} & \makecell[c]{$\mathcal{M}_{\textrm{P}}$(\%) $\uparrow$} & \makecell[c]{$\mathcal{M}_{\textrm{R}}$(\%) $\uparrow$} & \makecell[c]{$\mathcal{M}_{\textrm{H}}$ $\downarrow$} \\ \midrule
7 & 21531M & 51.1 & 76.3 & 15.501 \\
6 & 21379M & 51.0 & 76.4 & 15.575 \\
5 & 20731M & 51.3 & 76.3 & 15.499 \\
4 & 17051M & 50.7 & 76.3 & 15.763 \\
3 & 14333M & 50.7 & 76.2 & 15.764 \\
2 & 12023M & 50.6 & 76.2 & 15.931 \\
1 & 8783M & 37.0 & 76.5 & 20.245 \\
\bottomrule
\end{tabular}
\label{tab:beams}
\vspace{-2mm}
\end{table}
\begin{figure}[t]
\centering
\includegraphics[width=.98\linewidth]{./fig/token_hist_spline.pdf}
\vspace{-0.5cm}
\caption{Histogram of token logits. The histogram depicts the distribution of logit values obtained from 1,000 suffixes, each containing 50 tokens. A spline interpolation technique is employed to smooth the histogram, with the original histogram included in the appendix for reference.}
\label{fig:token_hist_spline}
\vspace{0.2cm}
\end{figure}
\textbf{Top-$k$} denotes the truncated sampling method with the truncation set defined as the top-$k$ highest-probability tokens~\citep{fan2018hierarchical,holtzman2018learning,radford2019language}. Figure~\ref{fig:topketc}(a) demonstrates that a larger $k$ may increase the diversity of the generated sentences but also decrease the precision and hamming distance. The result is consistent with that observed in other NLP tasks~\citet{meister2022locally}.
\textbf{Nucleus-$\eta$}~\citep{holtzman2019curious} truncates the vocabulary based on the summed probability. Namely, the smallest set of the most likely tokens with total probabilities equal to or greater than $\eta$ are selected.
\citet{meister2022locally} demonstrate that lower values of $\eta$ are more conducive to story generation. In contrast, the extraction task is optimal at $\eta\approx 0.6$, which yields a 31\% improvement in extraction precision over the baseline. Larger or smaller $\eta$ both shows decreased performance (Figure~\ref{fig:topketc}(b)).
\textbf{Typical-$\phi$}~\citep{meister2022locally} recommends selecting a token with information content similar to the expected information content. Namely, it guarantees the probability mass from the original distribution that will be taken into account in typical decoding. This sampling strategy can improve sentence consistency while reducing degenerate repetitions. The typical-$\phi$ strategy is equivalent to a subset optimization problem with an entropy rate constraint. Typical-$\phi$ exhibits a non-monotonic tendency, which is similar to its effect on abstract summary and story generation tasks.
\subsection{Probability Distribution Adjustment}
{Besides the sampling strategies that truncate the sampling distribution, we introduce in this section another strategy that directly adjusts the probability distribution $f_{\theta}\left(x_{n}|x_{<n}\right)$. Below we introduce two tricks, adjusting the temperature and repetition penalty, to refine the distribution. These tricks bring nearly no additional computation cost but can still lead to a performance improvement.}
\textbf{Temperature $T$}~\citep{DBLP:journals/corr/HintonVD15} is a technique of local renormalization with an annealing term. A higher temperature $T > 1$ results in decreased confidence in the language model's predictions but may also increase the diversity of the generated suffixes. The study conducted by \citet{carlini2021extracting} found that gradually decreasing the temperature throughout the generation process can be beneficial. The effect of the temperature is presented in Table~\ref{tab:temp}. It is important to note that as the temperature is increased, the number of generated suffixes required to include the ground truth also increases, causing the efficiency to degrade. It is important to find a balance between diversity and efficiency.
\textbf{Repetition penalty} is constructed on the conditional language model~\citep{keskar2019ctrl}.
A repetition penalty is introduced by locally modifying the generation probability of each token based on whether it is a repetition of the previous token. The logit of the repeated token is divided by a value $r$ before entering the softmax layer. Setting $r > 1$ penalizes repetition while $r < 1$ encourages it. Our results in Table~\ref{tab:rp} show that repetition penalty has mostly negative effects on the task of training data extraction.
\input{fig/fig_hpo.tex}
\input{fig/fig_gtl.tex}
\subsection{Exposure Bias Reduction}
For efficient vectorization, it is common practice to pack multiple sentences into a fixed-length sequence when training language models. As an example, consider the sentence `The phone number of Yu is 12345' may be truncated or prefixed with another sentence in the training set, such as `number of Yu is 12345' or `Yu's address is at XXX. The phone number of Yu is 12345'. The prefix in the training set, as in Table~\ref{tab:fail case}, is not always a complete sentence. To better mimic the training settings, we propose to adjust the context window size and adjust the position shifting.
\subsubsection{Dynamic Context Window}
The length of the training window may differ from the length of the extraction window. As a result, we propose adjusting the context window size, i.e. the number of previously generated tokens, as shown in Eq.~(\ref{eq:winlen}). Furthermore, we encourage the results of different context window sizes to collaborate in determining the next generated token as
\begin{equation}
\begin{split}
&f_{\theta}\left(x_{n};\mathcal{W}\right) \\
=&h_{\mathcal{W}}\left(f_{\theta}\left(x_{n}|x_{[n-w_1,n-1]}\right),...,f_{\theta}\left(x_{n}|x_{[n-w_m,n-1]}\right)\right)\textrm{,}
\end{split}
\label{eq:winlen}
\end{equation}
where $h_{\mathcal{W}}$ denotes the ensemble method, $\mathcal{W}$ denotes the ensemble hyperparameter, including the number of different context window sizes $m$ and each window size $w_i$. We use $m=4$ and $w_i \in \{n,n-1,n-2,n-3\}$ in our methods. Carefully chosen hyperparameters $m$ and $w_i$ may improve the performance even more.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{./fig/sen_hist_original.pdf}
\vspace{-0.6cm}
\caption{Histogram of the rank of the ground truth perplexity. The x-axis represents the rank of the ground truth perplexity within a list of 100 suffix perplexities.
}
\vspace{-0.1cm}
\label{fig:sen_hist_original}
\end{figure}
We present two implementation options. The first option, as specified in Eq.~(\ref{eq:ws}), entails computing the probabilities generated by utilizing various lengths of previously generated tokens $x_{[n-w_i,n-1]}$, and then producing the final probabilities via a weighted average sum of these probabilities, as
\begin{equation} \label{eq:ws}
f_{\theta}\left(x_{n};\mathcal{W}_w\right) = \frac{\sum_{i=1}^{m}{\epsilon_i f_{\theta}\left(x_{n}|x_{[n-w_i,n-1]}\right)}}{\sum_{i=1}^{m}{\epsilon_i}}\textrm{,}
\end{equation}
where $\mathcal{W}_w$ denotes the hyperparameters in the solution, comprising of $m$, $w_i$ and $\epsilon_i$. $\epsilon_i$ denotes the weighting coefficient of each probability. The second option as specified in Eq.~(\ref{eq:vote}), is based on a voting mechanism, in which each model trained with a distinct context window length casts its vote for the tokens it is most confident in, formulated as
\begin{equation} \label{eq:vote}
f_{\theta}(x_{n};\mathcal{W}_v) = \frac{1}{m}\sum_{i=1}^{m}\mathcal{V}(f_{\theta}(x_{n}|x_{[n-w_i,n-1]})\textrm{;}
\end{equation}
\begin{equation}
\!\!\! \mathcal{V}(f_{\theta}(x_{n})) =
\begin{cases}
\rho-\mathcal{R}(f_{\theta}(x_{n}))\textrm{,} &\textrm{if} \; \mathcal{R}(f_{\theta}(x_{n})) \leq \rho \textrm{;} \\
0\textrm{,} &\textrm{otherwise} \textrm{,}
\end{cases}
\end{equation}
where $\mathcal{V}(\cdot)$ denotes the voting function, $\mathcal{R}(\cdot)$ denotes the rank function, and it votes for the tokens that it has confidence in. $\mathcal{W}_v$ denotes the hyperparameters in the solution, comprising of $w_i$, $m$ and $\rho$.
It is stated in~\citet{carlini2022quantifying} that the proportion of extractable sequences increases log-linearly with the number of context tokens. We observed a similar phenomenon in our experiments, where the generation accuracy of a token decreases as the prefix becomes shorter. However, we discovered that combining multiple context window lengths significantly improves accuracy. The probabilities produced by different window lengths can be combined to significantly improve extraction accuracy. Our implementation of $\mathcal{W}_w$ employs the weighting coefficient $\epsilon_i=0.9^i$, and $\mathcal{W}_v$ assigns $[5,4,3,2,1]$ points to its top-$5$ confident tokens, $\rho=5$. The results presented in Table~\ref{tab: window_len} show that ensemble methods can significantly improve on the baseline approach, achieving improvements of 143\% and 139\%, respectively, and we discovered that the weighted average strategy performs slightly better than the voting strategy. One common failure mode observed is that when a wrong token is generated, it causes subsequent tokens to also be wrong (exemplars shown in Table \ref{tab:fail case}). The window size ensemble introduced here can help reduce this problem.
\begin{table}[t]
\centering
\caption{Results of $\mathcal{M}_{\textrm{P}}$, $\mathcal{M}_{\textrm{R}}$, and $\mathcal{M}_{\textrm{H}}$ under different temperature. Temperature = 1 is the baseline. All results are reported on 5 trials.}
\small
\vspace{0.1in}
\begin{tabular}{cccc}
\toprule
\textbf{Temperature} & $\mathcal{M}_{\textrm{P}}$ (\%)$\left(\uparrow\right)$ & $\mathcal{M}_{\textrm{R}}$ (\%)$\left(\uparrow\right)$ & $\mathcal{M}_{\textrm{H}}$ $\left(\downarrow\right)$ \\ \midrule
Varying & 48.0 & 76.3 & 19.614 \\ \midrule
0.3 & 48.9 & 76.4 & 16.341 \\
1 & 37.0 & 76.5 & 20.245 \\
\bottomrule
\end{tabular} \label{tab:temp}
\vspace{-0.3cm}
\end{table}
\begin{table}[t]
\centering
\caption{Results of $\mathcal{M}_{\textrm{P}}$, $\mathcal{M}_{\textrm{R}}$, and $\mathcal{M}_{\textrm{H}}$ under different repetition penalty. Repetition penalty $r=1$ is the baseline. All results are reported on 5 trials.}
\small
\vspace{0.1in}
\begin{tabular}{cccc}
\toprule
\textbf{Repetition penalty} & $\mathcal{M}_{\textrm{P}}$ (\%)$\left(\uparrow\right)$ & $\mathcal{M}_{\textrm{R}}$ (\%)$\left(\uparrow\right)$& $\mathcal{M}_{\textrm{H}}$ $\left(\downarrow\right)$\\ \midrule
0.9 & 19.8 & 66.4 & 27.927 \\
1 & 37.0 & 76.5 & 19.614 \\
1.1 & 37.3 & 76.5 & 20.181 \\
1.2 & 37.1 & 76.5 & 20.323 \\
1.3 & 36.7 & 76.4 & 20.332 \\
1.5 & 34.7 & 75.7 & 21.154 \\
\bottomrule
\end{tabular}
\label{tab:rp}
\vspace{0.3cm}
\end{table}
\subsubsection{Dynamic Position Shifting}
Positional embeddings are added to the token feature in models like GPT-Neo. During training, this is added per batch of sentences, causing the same sentence to have different offsets in positional embedding in different training batches and during generation.
To improve the extraction of memorized suffixes, we propose to recover the positions used during training by evaluating different shifted positions and selecting the 'best' one. Specifically, for a given prefix $p$, we evaluate different position $\mathcal{C} = {c^i}$, where $c^i$ is a list of consecutive natural numbers, $c^i=\{c^i_1,\cdots\}$, s.t. $|c^i|=|p|$ and calculate the corresponding perplexity values. The position with the lowest perplexity value is then chosen as the position from which to generate the suffix as
\begin{equation}
c = \mathop{\textrm{argmin}}\limits_{c^i \in \mathcal{C}} \mathcal{P}(p,c^i)\textrm{; }\hspace{0.2cm}\hat{\phi}{(x_i)} = \psi(c_n) + \phi(x_n)\textrm{,}
\end{equation}
where $\psi(\cdot)$ denotes positional encoding layers, $\phi(\cdot)$ denotes the feature mapping function, $\hat{\phi}$ denotes the feature mapping function consisting positional encoding, and $\mathcal{P}$ computes the perplexity of the prefix. The experimental results are presented in Table~\ref{tab: window_len}. $\mathcal{C}=\{[0,1,\cdots,|p|],[1,2,\cdots,|p|+1],\cdots\}$ is evaluated. The data show that, while using position shifting improves the $\mathcal{M}_{\textrm{H}}$ metric, it may have a negative impact on precision and recall.
\subsection{Look-Ahead}
Table~\ref{tab:fail case} highlights a common issue encountered during the training data extraction process, where only one or two tokens are incorrectly generated or placed in an inappropriate position. To address this problem, we propose a technique that involves looking $\nu$ steps ahead and using the probability of the subsequent tokens to inform the generation of the current token. The goal of look-ahead is to use the posterior distribution to help compute the current token generation probability. We begin by presenting the precise mathematical formulation of the optimal probability and then introduce the implementation, which employs an estimation due to efficiency considerations. The posterior is calculated as
\begin{equation}
\begin{split}
&f_{\theta}\left(x_{n}|x_{n+1}, x_{<n}\right)\\
=&\frac{f_{\theta}\left(x_{n+1}|x_{n},x_{<n}\right)f_{\theta}\left(x_{n}|x_{<n}\right)}{\sum_{x_{n}'}f_{\theta}\left(x_{n+1}|x_{n}',x_{<n}\right)f_{\theta}\left(x_{n}'|x_{<n}\right)}\textrm{.}
\end{split}
\label{eq:lookahead_step1}
\end{equation}
\begin{table}[t]
\centering
\small
\caption{Results of $\mathcal{M}_{\textrm{P}}$, $\mathcal{M}_{\textrm{R}}$, and $\mathcal{M}_{\textrm{H}}$ under context window length adjustments. All results are reported on a single trial.}
\vspace{0.1in}
\begin{tabular}{lccc}
\toprule
& $\mathcal{M}_{\textrm{P}}$ (\%)$\left(\uparrow\right)$& $\mathcal{M}_{\textrm{R}}$ (\%)$\left(\uparrow\right)$& $\mathcal{M}_{\textrm{H}}$ $\left(\downarrow\right)$ \\ \midrule
Baseline & 19.5 & 65.6 & 26.948 \\ \midrule
\rowcolor{Gray} Context Win $\mathcal{W}_w$ & 47.4 & 77.6 & 16.993 \\
Context Win $\mathcal{W}_v $ & 46.7 & 77.5 & 17.164 \\\midrule
Position Shifting & 16.4 & 39.0 & 21.154 \\
\bottomrule
\end{tabular}
\label{tab: window_len}
\vspace{-2mm}
\end{table}
\begin{table}[t]
\centering
\caption{Results of $\mathcal{M}_{\textrm{P}}$, $\mathcal{M}_{\textrm{R}}$, and $\mathcal{M}_{\textrm{H}}$ under auto-tuning. All results are reported on 5 trials.}
\vspace{0.1in}
\small
\begin{tabular}{lccc}
\toprule
\textbf{Strategy} & \makecell[c]{$\mathcal{M}_{\textrm{P}}$ (\%)$\left(\uparrow\right)$}&\makecell[c]{$\mathcal{M}_{\textrm{R}}$ (\%)$\left(\uparrow\right)$} & \makecell[c]{$\mathcal{M}_{\textrm{H}}$$\left(\downarrow\right)$ } \\ \midrule
{Baseline} & 37.0 & 76.5 & 19.614 \\
Manual selection & 48.8 & 76.4 & 16.379 \\
{Auto-tuning} & 49.4 & 76.6 & 16.127 \\
\bottomrule
\end{tabular}\label{tab:autotuning}
\end{table}
More generally, let $\textbf{Track}(x_{\textrm{start}}, x_{\textrm{end}}|x_{\textrm{cond}})$ be the probability product of the track starting from $x_{\textrm{start}}$ and ending at $x_{\textrm{end}}$, conditioned on $x_{\textrm{cond}}$. Then we can write $\nu$-step posterior as
\begin{equation}
\!\!\!\! f_{\theta}\left(x_{n}|x_{n+\nu}, x_{<n}\right)=\frac{\textbf{Track}(x_{n}, x_{n+\nu}|x_{<n})}{\sum_{x_{n}'}\textbf{Track}(x_{n}', x_{n+\nu}|x_{<n})}\textrm{.}
\end{equation}
Based on the 1-step look-ahead formulation in Eq.~(\ref{eq:lookahead_step1}), we utilize the posterior probability to calculate the confidence of the current token. However, due to the size of the vocabulary list (more than 50,000), we only select $\lambda$ tokens whose probability $f_\theta\left(x_{n}'|x_{<n}\right)$ ranks among the highest, as
\begin{equation}
\begin{split}
\mathcal{X} = \{x_n'|\mathcal{R}( f_\theta\left(x_{n}'|x_{<n}\right)) \geq \lambda\}\textrm{,}
\end{split}
\label{eq:lookahead_approx}
\end{equation}
where $\mathcal{R}(\cdot)$ is the rank function. The experimental results, as detailed in Table~\ref{tab: window_len}, show that using a look-ahead strategy leads to a significant improvement in precision. Furthermore, an increase in the value of $\lambda$ results in a corresponding improvement in performance. It is important to note, however, that increasing the value of $\lambda$ also increases the computational cost, with a complexity of $\mathcal{O}(\lambda\cdot N)$, where $N$ denotes the length of the generated tokens.
\begin{table}[t]
\centering
\small
\caption{Hyper-parameters selection for auto-tuning. Multiple configurations of final hyperparameters are found to yield equivalent performances, and a representative example is presented.}
\vspace{0.1in}
\begin{tabular}{ccccc}
\toprule
\textbf{Parameters} & \textbf{Range} & \textbf{Step} & \textbf{Initial} & \textbf{Final} \\ \midrule
Top-$k$ & {[}1, 50{]} & 1 & 10 & 24 \\
Nucleus-$\eta$ & {[}0.1, 1{]} & 0.01 & 0.6 & 0.8\\
Typical-$\phi$ & {[}0.1, 1{]} & 0.01 & 0.6 & 0.9 \\
Temperature $T$ & {[}0.1, 5{]} & 0.1 & 0.3 & 0.58 \\
Repetition Penalty & {[}0.8, 1.3{]} & 0.01 & 1 & 1.04 \\ \bottomrule
\end{tabular}\label{tab:autotune para}
\end{table}
\begin{table}[t]
\centering
\small
\vspace{-.6cm}
\caption{Experimental results of $\mathcal{M}_{\textrm{P}}$, $\mathcal{M}_{\textrm{R}}$, and $\mathcal{M}_{\textrm{H}}$ under look-ahead. All results are reported on a single trial.}
\vspace{0.1in}
\begin{tabular}{llccc}
\toprule
& & $\mathcal{M}_{\textrm{P}}$(\%)$\left(\uparrow\right)$& $\mathcal{M}_{\textrm{R}}$(\%)$\left(\uparrow\right)$ & $\mathcal{M}_{\textrm{H}}$ $\left(\downarrow\right)$ \\ \midrule
\multicolumn{2}{l}{Baseline} & 19.5 & 65.6 & 26.948 \\ \midrule
\multicolumn{1}{l}{\multirow{3}{*}{Look-ahead}} & $\lambda$=10 & 33.1 & 71.6 & 24.262 \\
\multicolumn{1}{l}{} & $\lambda$=20 & 35.5 & 72.6 & 22.157 \\
\multicolumn{1}{l}{} & $\lambda$=30 & 36.7 & 73.0 & 21.333 \\
\bottomrule
\end{tabular} \label{tab:lookahead}
\vspace{-0.cm}
\end{table}
\subsection{Hyperparameter Optimization}
The aforementioned tricks in Section~\ref{sect:sampling} involve various hyperparameters, and simply using the best parameters is usually suboptimal. Manually searching for the best hyperparameters, also known as 'babysitting,' can be time-consuming. We use a versatile architecture auto-tuning method~\citep{akiba2019optuna}, which incorporates efficient search and pruning strategies, to determine the optimized hyperparameters following advanced frameworks~\citep{snoek2012practical,koch2018autotune,akiba2019optuna}. As the search algorithm, we use covariance matrix adaptation evolutionary strategies (CMA-ES)~\citep{hansen2003reducing}. The search objective in our experiment is set to $\mathcal{M}_{\textrm{P}}$, and the parameters that are searched over include top-$k$, nucleus-$\eta$, typical-$\phi$, temperature $T$, and repetition penalty $r$.
Table~\ref{tab:autotune para} contains the detailed search parameter settings. We also provide the baseline parameters as initial values to the search algorithm to speed up convergence. The number of search rounds is limited to 1,000. The experimental results are shown in Table~\ref{tab:autotuning}. Simply using the best parameters outlined in Section.~\ref{sect:sampling} with $k$=5, $\eta$=0.6, $\phi$=0.6, $T$=0.4, $r$=1 yields a precision of 48.8\%. Implementing auto-tuning results in a 37\% improvement over baseline, and auto-tuning performs slightly better than the hypermeter manual section.
\vspace{-0.25cm}
\section{Improved Suffix Ranking} \label{sect: ranking}
\vspace{-0.05cm}
Following the generation of multiple suffixes, a ranking process is carried out in which less likely suffixes are eliminated using perplexity $\mathcal{P}$ as a metric. However, our statistical analysis in Figure~\ref{fig:sen_hist_original} reveals that the ground-truth sentences do not consistently have the lowest perplexity values. Thus, we propose additional ranking metrics to address this disparity.
\subsection{Sentence-Level Criteria}
\textbf{Zlib.} The entropy of a text, as determined by the Zlib compression algorithm~\citep{gailly2004zlib} using the number of bits, is a quantitative indicator of the sequence's information content. We use the ratio of the perplexity of a given sentence as computed by the GPT-Neo model, and the Zlib entropy of the same sentence as a metric for membership inference, as outlined in the work of \citet{carlini2021extracting}. Besides, we investigate the potential utility of producting perplexity and Zlib entropy, as both metrics tend to decrease when the model shows a high degree of confidence in its predictions. Both metrics produce only a marginal improvement in the overall performance of the membership inference task, as shown in Table~\ref{tab:membership}.
\textbf{Cumprod.} We consider alternative metrics such as the cumprod, which depicts the tandem probability of a generation sentence as $\mathcal{L}_c = (\prod_{n=0}^{N} \log p(x_n|x_0,..,x_{n-1}))^{-N}$. However, the effect of tandem probability on precision is marginal and has a negative effect on $\mathcal{M}_{\textrm{R}}$.
\subsection{Token-Level Criteria}
\textbf{Reward on high confidence.} The presence of a high degree of confidence in memorized data is one of the defining features of the phenomenon known as the'memorization effect'~\citep{goodfellow2016deep,zhang2021understanding,pmlr-v70-arpit17a}. We propose implementing a strategy that rewards suffixes with high-confidence tokens based on this insight. If the sentence contains confident tokens, the possibility of the generated token is higher than a threshold, and the difference between the generated token and other token is higher than a threshold, we rank it higher. This trick makes a noticeable improvement as seen in Table~\ref{tab:membership}.
\textbf{Encouraging surprised patterns.} According to recent studies~\citep{holtzman2019curious}, human text generation frequently exhibits a pattern in which tokens with high perplexity are intermittently included, as opposed to consistently selecting tokens with low perplexity. To address this problem, we propose a simple solution that encourages the presence of surprised tokens (high perplexity tokens) by calculating the perplexity of a generated prompt based on only the majority tokens:
\begin{equation} \label{eq:sp}
\setlength\abovedisplayskip{3pt}
\setlength\belowdisplayskip{3pt}
\scalemath{0.9}{
\begin{aligned}
\mathcal{L}_s = \frac{1}{|\hat{\mathcal{X}}|}&\sum_{x_n \in \hat{\mathcal{X}}} \log p(x_n|x_{[0:n-1]})\textrm{,} \\
\hat{\mathcal{X}} = \{x_j| \mu-3\sigma < &\log p(x_n|x_{[0:n-1])}) < \mu+3\sigma\}\textrm{,}
\end{aligned}}
\end{equation}
where $\mu$ and $\sigma$ denotes the mean and standard of the $p(x_n|x_{[0:n-1]})$ in a batch. The inclusion of surprised tokens in a generation does not have a negative impact on overall sentence perplexity when using this method, thereby increasing the likelihood of their selection during membership inference. As demonstrated in Table~\ref{tab:membership}, the improvement is relatively marginal.
\begin{table}[t]
\centering
\caption{Experimental results of precision, recall, and Hamming distance under different ranking methods. All results are reported on a single trial.}
\vspace{0.05in}
\small
\begin{tabular}{llll}
\toprule
\textbf{Method} &\makecell[c]{$\mathcal{M}_{\textrm{P}}$(\%)$\left(\uparrow\right)$} & \makecell[c]{$\mathcal{M}_{\textrm{R}}$(\%)$\left(\uparrow\right)$} & \makecell[c]{ $\mathcal{M}_{\textrm{H}}$$\left(\downarrow\right)$} \\ \midrule
Baseline & 37.0 & 76.5 & 19.614 \\ \midrule
Perplexity\,$\div$\,Zlib & 37.1 & 76.0 & 20.191 \\
Perplexity\,$\times$\,Zlib & 37.1 & 76.3 & 20.368 \\
Cumprod & 36.6 & 39.8 & 20.127 \\\midrule
High confidence & 40.6 & 77.3 & 19.518 \\
Surprised patterns & 37.1 & 75.5 & 20.072 \\
\bottomrule
\end{tabular} \label{tab:membership}
\end{table}
\subsection{Compatibility Analysis}
It has been discovered that accumulating the aforementioned tricks does not always result in a proportionate increase in performance. We investigate the interactive effects of combining various techniques in a targeted and efficient manner, in order to establish a viable baseline method. The results are shown in Table~\ref{tab:compatible}.
The application of multiple of the aforementioned techniques yields no significant improvement in performance. Even when using a beam width of 2 and maintaining the same settings as in the previous experiments, the results do not show a significant improvement. The empirical findings presented in this section suggest that to achieve optimal results, a more deliberate and strategic combination of various methods is required.
\begin{table}[t]
\centering
\vspace{-0.3cm}
\small
\caption{Experimental results of precision, recall, and Hamming distance for compatibility analysis. All results are reported on a single trial.}
\vspace{0.05in}\label{tab:compatible}
\resizebox{1.0\linewidth}{!}{
\begin{tabular}{llll}
\toprule
& $\mathcal{M}_{\textrm{P}}$(\%) $\uparrow$ & $\mathcal{M}_{\textrm{R}}$(\%) $\uparrow$ & $\mathcal{M}_{\textrm{H}}$ $\downarrow$ \\ \midrule
Context win\,+\,Beams=2 & 46.7 & 77.5 & 17.154 \\
Auto-tuning\,+\,Beams=2 & 46.4 & 76.2 & 17.331 \\
Context win\,+\,Auto-tuning & 46.5 & 77.5 & 17.370 \\
Context win\,+\,High confidence & 46.8 & 77.5 & 17.144 \\
\bottomrule
\end{tabular}
}
\end{table}
\section{Conclusion and Future Work}
We investigate a dozen techniques for extracting training data from LMs. These techniques make minor changes to the generation strategies and ranking strategies. Our empirical findings show that several of these tricks improve significantly, while interactions between different tricks are more subtle than expected. Besides, the empirical results show that commonly used versatile methods for general text generation are not always effective for extraction tasks.
In future works, explortion in developing compatible techniques in data extraction is preferred. Techniques in both suffix generation and ranking suffix may be combined and explored in an end-to-end fashion. In addition, further investigation to gain a deeper understanding of the underlying mechanisms that contribute to the superior performance of certain techniques in this paper are encouraged.
| {'timestamp': '2023-02-10T02:07:26', 'yymm': '2302', 'arxiv_id': '2302.04460', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04460'} | arxiv |
\section{Research Problems}
In text attributed networks, nodes are characterized by textual information. For example, in social networks, the nodes (users) are
linked with other nodes by friend relationships and each node is associated with text like their profile information. Recent works show that leveraging both textual information and topological structure into network representation learning (NRL) benefits downstream tasks performances~\citep{chen2021effective,zhang2019attributed}. However, most real-world graphs associated with people or human-related activities are often sensitive and might contain confidential information~\citep{sajadmanesh2021locally}. Releasing the representations of nodes in real world graphs gives adversaries a potential way to infer the sensitive information of nodes and edges. Thus, it is critical to develop privacy-preserving representations for applications using graphs that require users' sensitive data to fulfill users' privacy requirements.
\textbf{Challenges}
\textit{Current NRL works have a few remaining problems. First, training a Graph Neural Network (GNN) from private node data is a challenging task due to the absence of a trusted third party. Second, typical NRLs, e.g., diffusion mechanisms and random walks on graphs, only assess the pairwise relationships between two individual nodes, but ignore the higher-order interactions between nodes. Third, current GNNs ignore important interactions between global invariant features, i.e., data characteristics which are invariant under continuous transformations such as stretching, bending, and compressing.} Recently, simplicial neural networks (SNNs) offer a mathematically rigorous framework to evaluate not only higher-order interactions, but also global invariant features of the observed graph to systematically learn topological structures. These features occur in the form of homological features, intuitively perceived as holes, or voids, in any desired dimension. It is important to investigate -$\mathbf{Q1}$: how to build representation outputs from SNNs (RO\_SNNs) that integrate attribute textual information with multi-scale relationships between nodes and -$\mathbf{Q2}$: to study if the RO\_SNNs are exposed to new threats and if they are more vulnerable compared to regular representation outputs from typical GNNs. Besides, -$\mathbf{Q3}$: it is also challenging to propose \textit{secure RO\_SNNs} that even if an adversary has access to user representation outputs in the database, that adversary will still be unable to learn too much about the user's sensitive data.
\section{Research Plan}
Currently, there are a few SNNs~\citep{keros2022dist2cycle,chen2021topological} that utilize GNN models for learning functions parametrized by the homological features to learn topological relationships of the underlying simplicial complexes. All existing SNNs are not focusing on NRL on text-attributed networks. It is non-trivial to incorporate text representations in existing SNNs due to SNNs cannot easily handle additional information during its graph convolution. Fortunately, according to the theoretical finding that NRLs are equivalent to factorize an affinity matrix $M$ derived from the adjacency matrix of the original network~\citep{yang2015network}. In $\mathbf{Q1}$, we first develop the RT4SC. The learning process includes two stages. In the first stage, we integrate text representations with regular pairwise node interactions via factorizing $M$ into the product of three matrices as $M=W^THT$, where $W \in \mathbb{R}^{k\times \cdot }$, $H \in \mathbb{R}^{k \times t}$ and
text features $T \in \mathbb{R}^{t \times \cdot}$. Then we can concatenate $W$ and $HT$ as $2k$-dimensional representations of nodes. In the second stage, we will enrich the node representations by: 1) first extracting local topological side information from subgraphs using persistent homology of the small neighborhoods of nodes; and then 2) incorporating the extracted local topological side information into the local GNN algorithm for NRL. In $\mathbf{Q2}$, we will first investigate the membership inference attack and show that an adversary can distinguish which node participates in the training of the GNN via training an inference model to recognize differences between the prediction of the model trained with the record and that of the model trained without the record. Second, the server can aggregate nodes’ representations with their neighbors to learn better user representations for improving its services. This means if there is an edge between two nodes, then their RO\_SNNs should be closer. Therefore, a potential adversary could possibly recover the sensitive edge information (e.g., friend lists) via a machine learning classifier that simply measures distance differences of the RO\_SNNs. Thus, we will study whether representations can be inverted to recover the graph used to generate
them. Graph reconstruction attacks (GRAs) try to infer the edges of graphs. Regular GRAs predict edges via measuring distance differences between linked node pairs and unlinked node pairs via clustering~\citep{he2021stealing}. However, we will propose a GRA that utilizes a graph-decoder to minimize the reconstruction loss of the generated adjacency matrix via backpropagation. We will further perform both attacks on outputs from regular GNNs and measure if RO\_SNNs are more vulnerable compared to regular outputs from GNNs. In $\mathbf{Q3}$, I will study a privacy-preserving deterministic differentially private alternating direction method of multiplier, i.e., D$^2$-ADMM, to learn secure RO\_SNNs that not only capture multi-scale relationships, but also could defend the potential attacks on an untrusted server.
\paragraph{Completed Research and Timeline}
Me and my Ph.D. advisor have been researching privacy-preserving text representations. In our paper~\citep{zhan2021multi}, we show that some of the hidden private information correlates with the output labels and therefore can be learned by a neural network. In such a case, there is a tradeoff between the utility of the representation and its privacy. We explicitly cast this problem as multi-objective optimization and propose a multiple-gradient descent algorithm that enables the efficient application of the Frank-Wolfe algorithm to search for the optimal utility privacy configuration of the text classification network. Our prior work~\citep{zhan2022new} also show that it is challenging to protect privacy while preserving important semantic information about an input text. In particular, the threats are (1) these representations reveal sensitive attributes, no matter if they explicitly exist in the input text and (2) the representations can be partially recovered via generative models. In our recent paper~\citep{zhan2023graph}, we propose a GRA to recover a graph’s adjacency matrix from three types of representation outputs, i.e., representation outputs from graph convolutional networks, graph attention networks, and SNNs. We find that SNN outputs obtain the highest precision and AUC on five real-world networks. Therefore, the SNN outputs reveal the lowest privacy-preserving ability to defend the GRAs. Thus, it calls for future research towards building more private and higher-order representations that could defend the potential threats. My research timeline is as follows: By the date of submission, I addressed the first part of $\mathbf{Q2}$. By the workshop date, I plan to complete $\mathbf{Q1}$ and $\mathbf{Q2}$ and I will complete $\mathbf{Q3}$ after the workshop.
| {'timestamp': '2023-02-10T02:03:46', 'yymm': '2302', 'arxiv_id': '2302.04383', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04383'} | arxiv |
\section{Introduction}
\IEEEPARstart{A}{utonomous} aerial robots, thanks to its high maneuverability, can be employed for many highly complex and dynamic tasks such as aerial interception \cite{cite:interception}, aerial perching \cite{cite:perching}, task dispatching \cite{cite:dispatching}, juggling \cite{cite:juggling}, racing \cite{cite:racing}, etc.. Catching is the most complex and typical problem among all the highly dynamic tasks, which requires not only accurate target motion prediction and precise interception but also adaptability and flexibility in the catching moment. In addition, it is necessary to make decisions of catching time and sequence when facing multiple targets. For catching task, motion planning and decision making (planning-with-decision) is the most important component since it determines all the expected quadrotor states. This article aims to provide a lightweight solution for catching, which can also be referenced for other highly dynamic tasks.
Although there exists some work that finished catching task, the catching time and terminal state still need to be determined manually or through a large number of trials, which lacks autonomy and flexibility. At present, there is no catching method that is fully autonomous and can generate dynamically feasible trajectories in real time. Furthermore, existing work can only catch single target. We summarize the requirements of catching tasks for high-speed targets as follow (\textbf{FLAF}):
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\columnwidth]{./figures/experiment_double.pdf}
\end{center}
\caption{
\label{fig:introduction}
The process of the quadrotor catching 2 flying targets, in which the service interval is 0.8$s$. The targets trajectories are drawn in orange and red. The trajectory of the quadrotor is represented by 6 ghost images separated by 0.3$s$. The green box is the pitching machine. The yellow box is the starting position of quadrotor planning.
}
\vspace{-0.5cm}
\end{figure}
\begin{itemize}
\item \textbf{F}ormulistic: Planning-with-decision problems are hard or even impossible to explicitly formulate, which directly leads to the over simplification of planning-with-decision problems in previous work. Proper formulation is a powerful guarantee for optimal catching.
\item \textbf{L}ightweight: Due to the errors in ego motion and target trajectory prediction, the drone needs high-frequency decision-making and re-planning, which requires lightweight method.
\item \textbf{A}daptive: When facing different flying targets, quadrotors need adaptively determine highly coupled catching time and terminal position.
\item \textbf{F}lexible: Quadrotors should be allowed to catch targets in any reasonable attitude and deviations from the ideal catching position, rather than fixed.
\end{itemize}
Unfortunately, it is difficult, even internally contradictory, to achieve these four aspects at the same time. Planning is usually decoupled with decision making in previous method. The over simplified decision making problem does not fully account for more refined trajectory planning, which results in the gap between planning and decision making. On the other hand, an optimal planning-with-decision method will iterate over all possible solutions and select the nearly optimal one rather than stop at a feasible solution. However, higher optimality comes from sophisticated formulation and more iterations or trials in the solution space, which significantly increases computation cost. Then, adaptability requires the joint optimization of coupled catching time and terminal position, which makes the problem non convex and challenging to find a solution. The introduction of flexibility further increases the difficulty of problem solving. In fact, only satisfying some basic requirements such as safety and feasibility while minimizing time and maximizing smoothness is already a difficult problem \cite{cite:ego_planner}. That is why most works are unable to take into account the above FLAF requirements at the same time.
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\columnwidth]{./figures/frame_simple.pdf}
\end{center}
\caption{
\label{fig:frame}
The overview of Catch Planner. All parts run online.
}
\vspace{-0.5cm}
\end{figure}
In this paper, we propose a systematic scheme called Catch Planner to meet FLAF demands and use table tennis ball as targets in our catching experiments. The Catch Planner consists of Decision-making, Motion Primitive Trajectory Generation, Trajectory Optimization and Target Motion Perception modules, as shown in Fig. \ref{fig:frame}. We propose a deep reinforcement learning (DRL) based policy search method to solve the sequential decision making problem that is hard to formulate. In addition, we build simulation environment which decouples dynamics and physics to greatly reduce training computation consumption.(see Sec. \ref{section:decision-making} for more details). Furthermore, the policy search results are used to generate control effort optimal motion primitive trajectory (see Sec. \ref{section:primitive} for more details). Finally, we adopt MINCO trajectory class \cite{cite:MINCO} to conduct trajectory re-parameterization and optimization. To make the catching adaptive, we propose a differentiable target trajectory model with online iterative correction (see Sec. \ref{section:prediction} for more details). Based on the differentiable target trajectory representation, we jointly optimize highly coupled terminal states and catching time and propose a lightweight terminal constraint transcription method enabling the quadrotor to catch targets at any reasonable attitude and position bias. Benefiting from sparse parametric optimization in MINCO and our constraint elimination and transcription approach (see Sec. \ref{section:optimization} for more details), FLAF requirements are satisfied. Eventually, the robustness and scalability are verified by extensive experiments in real world and simulation.
We summarize the contributions of our proposed Catch Planner as follows.
\begin{itemize}
\item A learning based sequential decision-making method and a self-supervised neural network policies training method are proposed for catching targets.
\item We propose a terminal-flexible spatio-temporal trajectory optimization method which jointly optimize highly coupled terminal state and catching time, and trade off dynamic feasibility, control effort and safety.
\item Catch Planner provides a new paradigm for merging learning and planning. The effectiveness is verified in extensive simulations and real-world experiments for catching.
\end{itemize}
\section{Related Work}
There are few researches on the catching task, especially for planning-with-decision. Most existing methods treat target catching as a fixed state-to-state motion planning problem. \cite{cite:bvp} proposes a closed-form solution to generate motion primitives for catching. This method is efficient, but the catching height must be determined manually or through trials. Furthermore, the dynamic feasibility of the trajectory is not considered while planning. \cite{cite:juggling_Wei} designs a controller to track the trajectory using the method from \cite{cite:bvp} with high following accuracy. \cite{cite:interception_JFR} proposes a three-dimensional optimal terminal velocity control guidance for multicopter intercepting maneuvering drone with equal maneuverability level. This low-order planning leads to unsmooth trajectory. \cite{cite:juggling} shows two quadrocopters cooperatively juggling a ball back-and-forth. The trajectory is caculated under small-angle assumption, but it does not take actuator saturation into account. A target prediction method is also proposed in \cite{cite:juggling} by integrating forward the current position and velocity. All the above planning method artificially fix the catching time and position, leading to reduced catching flexibility. In fact, coupled catching terminal and time make it difficult to jointly optimize the trajectory. Our work well overcome this difficulty. We also provide a method to make the quadrotor attitude and position offset flexible under the premise of successful catching.
There are also some catching works that tend to obtain complex decision variables, such as time and sequence. Although the sequential decision making problem can be modeled by introducing integer variables, it will cause a second-level computational burden \cite{cite:MIP1}\cite{cite:MIP2}, which is intolerable for the catching task. The arrival of DRL method on robotics tasks \cite{cite:policy_search20} \cite{cite:minimum_time22} \cite{cite:policy_search22} brings hope to solve the problem online. DRL has the power of improving the policy when the agent is constantly interacting with the environment by trial and error. However, most successful cases appear in simulation and games \cite{cite:nature19} rather than in reality. For catching task, \cite{cite:learning_catch} proposes an end-to-end method of visual reaction in the context of playing catch with a drone in visually rich synthetic environments. However, they are not deployed to the real environment. This is because making decisions directly in the control space is difficult to migrate to the real world. \cite{cite:tennis} brings the learning method into reality and builds a library of “hitting motions” to determine the best hitting motion. But the success rate of interception is too low, which is because the decision does not consider the feasibility of quadrotor motion planning. To sum up, imperfect catch is caused by improper model. The decision making and motion planning are not considered coupled, resulting in the decision results can not be well implemented. Our method solve the above contradiction well, and provides a good paradigm for solving planning-with-decision problems.
Other works focus on the catching structure design \cite{cite:structure}, control \cite{cite:mpc_catch}, visual detection \cite{cite:detection1} \cite{cite:detection2}, and state estimation \cite{cite:Shen}. All these have not solved the planning-with-decision problems, so will not be introduced.
\section{Problem Statement}
In this section, we summarize the formulation of the planning-with-decision problem for catching. The dynamic model of quadrotor and target are also introduced.
\subsection{Quadrotor Dynamic Model}
The quadrotor is modeled as a rigid body with six degrees of freedom: linear translation $p \in \mathbb R^3$ and rotation $R \in \mathrm{SE}(3)$. Translational motion depends on the gravitational acceleration $\bar g$ as well as the control input thrust $\tilde f$. Rotational motion takes the body rate $\omega \in \mathbb R^3$ as input. The model is \cite{cite:model_quadrotor}
\begin{equation}
\begin{cases}
\tau = \tilde f R \mathbf e_3 / m, \\
\ddot{p} = \tau - \bar{g} \mathbf e_3, \\
\dot{R} = R \hat \omega,
\end{cases}
\end{equation}
where $\tau$ denotes the net thrust, $\mathbf e_i$ is the $i$-th column of $\mathbf I_3$ and $\hat \cdot$ is the skew-symmetric matrix form of the vector cross product.
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\columnwidth]{./figures/model.pdf}
\end{center}
\caption{
\label{fig:model}
Modeling overview and problem definition. The quadrotor can catch the targets in different attitudes (the target velocity $\dot{s_b}$ has an intersection angle with the catching net center $c(t)$), in which the movement is reflected by rotation $\mathbf{R}$. It can also catch the ball at different target positions (the catched position $s_b$ of the ball has a position offset with the catching net center $c(t)$) , in which the movement is reflected by translation $\mathbf{t}$.
}
\vspace{-0.5cm}
\end{figure}
Moreover, the catching loop with a net installed, shown in Fig. \ref{fig:model}, has a bias with the drone body. We use $\bar l$ to denote the length of the loop's centroid to the body. Thus the center of the loop is represented as $c(t) = p(t) - \bar l z_b(t)$, where $z_b(t)$ is the quadrotor attitude in time $t$.
\subsection{Target Dynamic Model}
The flying target is high-order nonlinear which affected by gravity $F_g$, aerodynamic drag $F_r$, Magnus force $F_m$, air buoyancy $F_b$, etc. Since the ball rotation is small in this paper, the Magnus force is ignored. And the air buoyancy is normally considered in conjunction with gravity. So we simplify the ball's motion as \cite{cite:model_ball}
\begin{equation}\\
\label{eq:ball_model}
\ddot{s_b} = g - K_D \left\| \dot{s_b} \right\| \dot{s_b},
\end{equation}
where $\mathbf s_b$ denotes the ball's position. $K_D$ is proportionality coefficient. $\left\| \cdot \right\| $ refers to the Euclidean norm.
\subsection{Problem Formulation}
\label{subsection:problem_formulation}
The basic requirements of a planning trajectory $p(t)$ include dynamical feasibility and safety. Meanwhile, it is preferable to minimize control effort and time cost. The terminal state constraints are relaxed to catch more flexibly. It should also have decision making ability. In conclusion, the requirements of optimal catching gives the following problem.
\begin{subequations}
\label{eq:problem_formulation}
\begin{align}
\min_{p(t), T} & \label{eq:cost_function}~\sum_{i} \mathcal J_i = \sum_{i}\int_{0}^{T} {\norm{p_{i}^{(s)}(t)}^2} \df{t} + \rho T_i, \\
s.t.~ & \label{eq:T_constrain} ~T_i > 0, \\
& \label{eq:continue_constrain}~p_{i}^{(s-1)}(0)=p_{i-1}^{(s-1)}(T_i), \\
& \label{eq:actuator_constrain}~\norm{D_{i}(t)}\leq D_{max}, ~\forall t\in[0,T], \\
& \label{eq:ground_constrain}~\mathbf e_3^T p_{i}(t) \geq z_{min}, ~\forall t\in[0,T], \\
& \label{eq:catching_position}~p_{i}(T_{i})=s_b - \bar l \mathbf z_d ~\text{(in the ideal case)}, \\
& \label{eq:catching_angle}~\left<-\dot{s_b}, \mathbf z_d\right>\leq \theta_{max},
\end{align}
\end{subequations}
where Eq. \ref{eq:cost_function} is a general form that trades off smoothness and aggression. $T_i$ is the allocated time for each segment of the trajectory. Eq. \ref{eq:continue_constrain} provides a guarantee for the continuity. Eq. \ref{eq:actuator_constrain} shows actuator constraints including speed $p_{i}^{[1]}(t)$, body rate $\omega$ and thrust $\tau$ limitations. Eq. \ref{eq:ground_constrain} is a safety constraint to avoid hitting the ground. Eq. \ref{eq:catching_position} means the proposed terminal constraint transformation method allows deviations from the ideal catching position and will be discussed later in Section \ref{section:decision-making}. $\mathbf z_d$ denotes the quadrotor’s desired catching attitude which is restricted by Eq. \ref{eq:catching_angle} and $\mathbf z_d = \tau / \norm{\tau}$.
It is worth noting that $\sum\limits _{i} \cdot$ includes the catching sequence and is guaranteed by the learning based decision making module. The goal is to maximize the cumulative reward and the optimal policy $\pi^*$ can be written explicitly for a discount factor $\gamma$:
\begin{align}
\pi^* = \mathop{\arg\max}\limits_{\pi} \mathbb{E}[\sum_{t=1}^T\gamma^{t-1}r_t].
\end{align}
The optimal policy determines the order of catching, which is implicitly expressed as $\sum\limits _{i} \cdot$ in Eq. \ref{eq:problem_formulation}.
\section{Learning-based Sequential Decision Making}
\label{section:decision-making}
In this section, we introduce the decision making framework and explain core terms design including rewards design, observation representation, action representation and invalid action masking in details. At the end we present the training strategy and platform.
\subsection{Learning Neural Network Policies}
\subsubsection{Decision Making Framework}
In our task, the decision making policy receives current quadrotor position, quadrotor attitude, quadrotor velocity, targets position and targets velocity as inputs, and outputs predicted time variables for catching each target. The decision making policy is trained using Proximal Policy Optimization (PPO) \cite{cite:ppo}, which demonstrates impressive performance for continuous tasks. Our main objective is to update policy search network parameters $\theta$ by maximizing the following:
\begin{align}
\begin{split}
\mathcal J_{DM}(\theta) = \mathbb{E}_t[ &\min(\frac{\pi_\theta(a_t|s_t)}{\pi_{\theta_{old}}(a_t|s_t)}\hat{A_t}, \\
&{\rm clip}(\frac{\pi_\theta(a_t|s_t)}{\pi_{\theta_{old}}(a_t|s_t)}, 1-\epsilon, 1+\epsilon)\hat{A_t})],
\end{split}
\end{align}
where $\theta_{old}$ and $\theta$ are the policy parameters before and after the update respectively, $\hat{A_t}$ is an estimator of adavantage function at time step $t$ and $\epsilon$ is a hyperparameter.
\subsubsection{State Representation}
The following components which are essential and minimalistic to represent states are used:
\begin{align}
\textbf s_t= \left [ p_d(t), q_d(t), p^{ (1) }_d(t), p_t(t), p^{(1)}_t(t) \right ],
\end{align}
where $p_d(t), q_d(t), p^{(1) }_d(t), p_t(t), p^{(1)}_t(t)$ stand for the quadrotor’s position, attitude represented by quaternion, velocity and targets’ position and velocity at time step $t$, respectively.
\subsubsection{Action Representation}
In our case, the decision-making time and sequence results are used in trajectory generation. To achieve this goal, we define the action $\textbf a_t$ to be predicted cathing time sequence, which can be written as:
\begin{subequations}
\begin{align}
\pi_\theta(\textbf s_t) &= \textbf a_t = \mathcal T_p, \\
\pi_\theta(\textbf s_t) &\sim \mathcal N (\mu_t, \sigma_t),
\end{align}
\end{subequations}
where $\theta$ means the network parameters for policy search, $\mathcal T_p$ represents predicted catching time sequence and each element of the sequence shows the predicted catching time for each target, $\mathcal N$ is a multivariate Gaussian density function, $\mu_t$ and $\sigma_t$ are the mean and variance of the Gaussian distribution respctively.
\subsubsection{Reward Design}
In order to make the quadrotor catch as more targets as possible while flying smoothly and agilely, we design the reward signal which takes both caught targets amount, trajectory cost, optimized time and sequence into consideration at the same time. The reward signal $\textbf r_t$ is calculated by:
\begin{align}
\textbf r_t = \lambda_n(e^{n(t)-N}-e^{-N})-\lambda_cln(\mathcal J)-\lambda_t||\mathcal T_p-\mathcal T_o||_2,
\end{align}
where $n(t)$ suggests caught targets amount at time step $t$, $N$ represents total targets amount, $\mathcal J$ indicates trajectory cost at time step $t$, $\lambda_n$ $\lambda_c$ and $\lambda_t$ are catching reward coefficient, trajectory cost punishment coefficient and time punishment coefficient respectively and $||\mathcal T_p-\mathcal T_o||_2$ means the L2 norm between predicted catching time sequence and optimized catching time sequence.
\subsubsection{Invalid Action Masking}
An action sampled directly from the whole action space can be typically invalid because time variable ranges from 0 to infinity. Invalid action masking is an applicable solution to deal with such problems. In our task, we firstly limit each time variable to the range from 0 to $t_{max}$, where $t_{max}$ demonstrates maximum flying time of targets. Furthermore, it is also hard for quadrotor to catch targets within a surprisingly short time such as 0.1s. Therefore, we limit the predicted catching time within the range from $t_{min}$ to $t_{max}$, where $t_{min}$ denotes the minimum expected time for the quadrotor to catch targets.
\subsection{Training Strategy and Platform}
One hundred independent parallel training environments and agents are created and utilized to improve data collection speed, increase data quality and accelerate training speed. Our policy network is MLP with 2 hidden layers of 64 units and ReLU activation function, which is lightweight to run on real drone.
To speed up the self-supervised neural network policies training, we decouple physics environment and simulation environment from planning module. We define the process including targets states random initialization, quadrotor states random initialization, targets throwing, decision making, motion planning and targets catching as one step. After decision making, trajectory generation and optimization, we can directly obtain the catching result and trajectory cost by calculating the trajectory terminal state and target motion instead of executing the whole trajectory, which offers great impovement on training speed.
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\columnwidth]{./figures/rl_decision.pdf}
\end{center}
\caption{
\label{fig:learning}
The overview of the learning based sequential decision making.
}
\vspace{-0.1cm}
\end{figure}
\section{Motion Primitive Trajectory Generation}
In this section, the purpose is to find a trajectory that is closer to the optimal trajectory, considering requirements for catching. First, we introduce the analytic expression method of target trajectory prediction, in which the expression are optimized by online iteration. Then we introduce the method of control effort cost minimum trajectory generation, which uses the results of decision making module as input.
\subsection{Target Trajectory Prediction}
\label{section:prediction}
Catching task needs accurate target state estimation and trajectory prediction. Eq. \ref{eq:ball_model} shows that $\dot{s_b}$ brings nonlinear effects for ball flying dynamics model, which is unacceptable for trajectory optimization. \cite{cite:ball_simple_model} proposed a simplified linear target model and trained a parameter identification neural network offline model to obtain $K_D$. We extend this model to online. Ball’s linear equation of motion $s_b(t) $ can be expressed as
\begin{subequations}
\label{eq:ball_simple_model}
\vspace{-0.5cm}
\begin{align}
s(t) = &s_0 - \dfrac{ \dot{s_0}+ \dfrac{g} { K_D}}{K_D} e^{-K_Dt-1}-\dfrac{g}{K_D}t,
\end{align}
\end{subequations}
where $g$ and $K_D$ are decoupled in $\mathbf e$, $s_0$ is the the initial ball's position each update. Note that Eq. \ref{eq:ball_simple_model} is continuously differentiable, so it is easy to obtain the gradient $\partial s_b/\partial c_i$ and $\partial s_b/\partial T_i$. Then the extended kalman filter \cite{cite:control_book} (EKF) is used to optimize the observation value. The state transformation function is presented as
\begin{align}
\begin{bmatrix}
\mathbf s_{b_i}^{t} \\
\mathbf v_{b_i}^{t}
\end{bmatrix}
=
\begin{bmatrix}
\mathbf I_{3\times 3} & \mathbf I_{3\times 3}\Delta t \\
\mathbf0 & \mathbf I_{3\times 3}e^{-K_i \Delta t} \\
\end{bmatrix}
\begin{bmatrix}
\mathbf s_{b_i}^{t-1} \\
\mathbf v_{b_i}^{t-1}
\end{bmatrix}
+
\begin{bmatrix}
\mathbf0 \\
1
\end{bmatrix
\frac{g(e^{-K_i \Delta t} - 1)}{K_i},
\end{align}
where $i \in \{ x, y, z\}$, $\begin{bmatrix} \mathbf s_{b_i}^{t}&\mathbf v_{b_i}^{t} \end{bmatrix}$ represent the target state at the moment $t$. Kalman state estimate at $t$ can be expressed by
\begin{align}
\mathbf s_{b}^{cor} = \mathbf s_{b}^t + K_a(Z-\mathbf Hs_{b}^t),
\end{align}
where the observation matrix $\mathbf H = \left [\mathbf I_{3\times 3}\ \mathbf 0_{3\times 3} \right ]^T$, $K_a$ denotes kalman gain. $ Z$ denotes the motion capture observation. To make $K_D$ more accurate, we use nonlinear least squares method \cite{cite:LSM} to optimize $K_D$ online. The cost function is constructed as
\begin{align}
\mathcal J_{K_D} = \sum_{i}^{i+n}(\mathbf s_{b}^{cor}-\mathbf s_{b})^2,
\end{align}
where $n$ represents the number of states used for optimization in continuous time. The goal is to minimize it, which is efficiently solved by Ceres Solver \footnote{https://github.com/ceres-solver/ceres-solver}.
\subsection{Motion Primitive trajectory generation}
\label{section:primitive}
The motion primitive generator \cite{cite:bvp} is considered as an efficient method to plan a state-to-state trajectory, which is closed-form. We use it as the front end of trajectory optimization. Consider an $m$-dimensional trajectory whose $i$-th piece is denoted by a $N = 2s - 1$ degree polynomial:
\begin{align}
\label{eq:trajectory}
p(t)= \textbf{c}_i^T \beta (t), t \in \left[ 0, T_i \right],
\end{align}
where $\textbf{c}_i \in \mathbb{R}^{2s \times m}$ is the coefficient matrix, $T_i$ is obtained from the policy searching, $\beta (t) = (1,t,\cdots, t^N)^T$ is the natural basis.
Following \cite{cite:bvp}, we consider the motion of the quadrotor in terms of the jerk $s = 3$, allowing the system to be considered as a triple integrator in each axis, and minimize the cost function
\begin{align}
\mathcal J_{MP} = \frac{1}{T} \int_{T}^{0}\left\| p^{(3)}(t) \right\|^2 dt,
\end{align}
where $T$ is from decision-making module. Just like \cite{cite:bvp}, we use Pontryagin’s minimum principle \cite{cite:control_book} to generate the optimal state trajectory by introducing the costate $\lambda_m = (\lambda_1, \lambda_2, \lambda_3)$ and defining the Hamiltonian function $H(s, j, \lambda_m)$ as
\begin{subequations}
\begin{align}
\label{eq:hamiltonian}~H(s, j, \lambda_m) &=\frac{1}{T}j^2+\lambda_m^Tf_s(s, j) = \frac{1}{T}j^2+\lambda_1v+\lambda_2a+\lambda_3j, \\
\label{eq:bvp}\dot{\lambda_m} &=\triangledown H(s^\star, j^\star, \lambda_m) = (0, -\lambda_1, -\lambda_2),
\end{align}
\end{subequations}
where $ j^\star$ and $ s^\star$ represent the optimal input and state. The cost value can be calculated as
\begin{align}
\mathcal J_{MP} = \gamma^2 + \beta \gamma T + \frac{1}{3} \beta^2 T^2 + \frac{1}{3}\alpha \gamma T^2 + \frac{1}{4} \alpha \beta T^3 + \frac{1}{20} \alpha^2 T^4,
\end{align}
where $\alpha, \beta$ and $\gamma$ are constants. They are explicitly calculated according to current state of the quadrotor $s(0)$ and final state $s(T)$, which is determined by Eq. \ref{eq:ball_simple_model} and $T$ from the policy search. For more details, please see \cite{cite:bvp}. Then we can get the initial trajectory $p_0(t)$.
\section{Terminal-flexible Temporal-Spatio Trajecory Optimization for Cathing}
\label{section:optimization}
In this section, we summarize the proposed trajectory optimization method for catching, which jointly optimizes all the requirements in the planning module. The problem form can be efficiently transformed from Eq. \ref{eq:problem_formulation} into a new form of unconstrained nonlinear programming. The generated trajectory $p_0(t)$ is used to generate the initial values. Moreover, a lightweight terminal constraint transcription method is proposed to make catching more flexible.
\subsection{MINCO Trajectory Class}
We adopt $\mathfrak{T}_{\mathrm{MINCO}}$ for trajectory representation, which is a \textbf{min}imum \textbf{co}ntrol (MINCO) \cite{cite:MINCO} polynomial trajectory class, defined as
\begin{equation}
\begin{aligned}
\mathfrak{T}_{\mathrm{MINCO}} = \Big\{ & p(t):[0, T]\mapsto\mathbb{R}^m~ \Big|~\mathbf{c}=\mathcal{M}(\mathbf{q},\mathbf{T}),~ \\
& ~~\mathbf{q}\in\mathbb{R}^{m(M-1)},~\mathbf{T}\in\mathbb{R}_{>0}^M\Big\},
\end{aligned}
\end{equation}
where an $m$-dimensional trajectory $p(t)$ is represented by a piece-wise polynomial of $M$ pieces and $N=2s-1$ degree. In this paper, we use $s=4$ for minimum snap for enough freedom of trajectory. All trajectories in $\mathfrak{T}_{\mathrm{MINCO}}$ have compact parameterization by only the intermediate waypoint vector $\mathbf{q}$ and time vector $\mathbf{T}$ via the linear-complexity formulation $\mathbf c = \mathcal M(\mathbf q, \mathbf T)$. Furthermore, any cost function $\mathcal J(\mathbf q, \mathbf T) = F(\mathcal{M}(\mathbf q, \mathbf T), \mathbf T)$. The mapping also gives a linear-complexity way to cpmpute $\partial \mathcal J / {\partial \mathbf q}$ and $\partial \mathcal J / {\partial \mathbf T}$ from $\partial F / {\partial \mathbf q}$ and $\partial F / {\partial \mathbf T}$. After that, a high-level optimizer is able to optimize the objective efficiently.
\subsection{Trajectory Joint Optimization}
\label{subsection:nonlinear_optimization}
Considering all described requirements in Eq. \ref{eq:problem_formulation}, we adopt the compact parameterization of $\mathfrak{T}_{\mathrm{MINCO}}$, temporal constraint elimination, and constraint penalty to transform trajectories generation problem into an unconstrained nonlinear optimization problem:
\begin{align}
\label{eq:nonlinear_const_function}
\underset{\mathbf c,\mathbf T}{min} \sum_{i+1} \mathcal J_e + \lambda \cdot \left [ \mathcal J_t, \mathcal J_p, \mathcal J_\theta , \mathcal J_v, \mathcal J_\omega, \mathcal J_f, \mathcal J_g \right],
\end{align}
where $i$ is the number of the targets, $\lambda$ is the weight vector.
\subsubsection{Control Effort $\mathcal J_e$} The control cost is the same as Eq. \ref{eq:cost_function}. Then the gradients $\partial{\mathcal J_e}/\partial c$ and $\partial{\mathcal J_e}/\partial T$ are evaluated as
\begin{subequations}
\begin{align}
\mathcal J_e = & \int_{0}^{T} {\norm{p_{i}^{(4)}(t)}^2} \df{t} , \\
\frac{\partial{\mathcal J_e}}{\partial c_i} = & 2\left( \int_0^{T_i} \beta^{(3)}(t)\beta^{(3)}(t)^{\mathrm{T}} \df{t} \right) c_i, \\
\frac{\partial{\mathcal J_e}}{\partial T_i} = & c_i^{\mathrm{T}}\beta^{(3)}(T_i)\beta^{(3)}(T_i)^{\mathrm{T}} c_i,
\end{align}
\end{subequations}
\subsubsection{Temporal Constraint Elimination $\mathcal J_t$} In order to catch more targets, shorter total time is eagerly expected. We minimize the total time just like Eq. \ref{eq:cost_function}.
\begin{align}
\mathcal J_t = & \rho T_i.
\end{align}
Meanwhile, Eq. \ref{eq:T_constrain}, which requires the strict positiveness of each entry in $\mathbf T$, does harm to the optimization process. We eliminate it by explicit diffeomorphism in Euclidean spaces as $T_i = e^{t_i}$. Therefore, $t_i \in \mathbb{R}$ instead of $T_i \in \mathbb{R_+}$ becomes the new optimal variable. The gradient is calculated by
\begin{align}
\frac{\partial \mathcal J_t}{\partial c_i} = 0, \frac{\partial \mathcal J_t}{\partial t_i} = \frac{\partial \mathcal J_t} {\partial T_i} e^{t_i}.
\end{align}
\subsubsection{Flexible Terminal Transformation $\mathcal J_p, \mathcal J_\theta$}
Since the flat-output \cite{cite:minsnap} characteristics of quadrotor, the terminal state can be determined by $p_i^{(s-1)}(T_i )$. Eq. \ref{eq:catching_position} shows the ideal situation for catching. Such a strict restriction is obviously not in line with reality. The quadrotor shall be able to catch the ball at any position in the net with any attitude, as shown in the Fig. \ref{fig:model}. We relax the constraints by designing a penalty function
\begin{align}
\label{eq:position_penalty}
\mathcal J_p = \mathcal L_\varepsilon \left[ \mathcal G_p(t) \right], \mathcal G_p(t) = \norm{p-s_b- \bar l\mathbf z_d}.
\end{align}
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\columnwidth]{./figures/logistic_function.pdf}
\end{center}
\caption{
\label{fig:logic}
The logistic function.
}
\vspace{-0.5cm}
\end{figure}
In order to make the catching position flexible while inside the net, we design a smooth and continuous logistic function
\begin{align}
\label{eq:logistic_function}
\mathcal L_\varepsilon [x] =
\begin{cases}
0, & x \leq 0, \\
x^3, & 0 < x \leq \varepsilon, \\
\varepsilon^3+(x-\varepsilon)^2x/\varepsilon^4, & x > \varepsilon,
\end{cases}
\end{align}
where the gradient changes smoothly when $0 < x \leq \varepsilon$, while drastic when $x > \varepsilon$, meaning stronger penalties for violating constraints. Then the gradient
\begin{equation}
\label{eq:feasible_p_gradient}
\begin{aligned}
\frac{\partial{\mathcal J_p}}{\partial c_i}= & \frac{\partial{\mathcal J_p}}{\partial{\mathcal G_p}} \frac{\partial{\mathcal G_p}}{\partial c_i} = 0, \frac{\partial{\mathcal J_p}}{\partial T_i}= &\frac{\partial{\mathcal J_p}}{\partial{\mathcal G_p}} \frac{\partial{\mathcal G_p}}{\partial s_b} \frac{\partial s_b}{\partial T_i}.
\end{aligned}
\end{equation}
It is worth noting that each item can be calculated by Eq. \ref{eq:ball_simple_model}, Eq. \ref{eq:position_penalty} and Eq. \ref{eq:logistic_function}.
The angle constraint Eq. \ref{eq:catching_angle} requires that the quadrotor's terminal attitude $\mathbf z_d$ and the moving direction of the flying target are kept within a safe range. This constraint is translated into the following penalty function.
\begin{align}
\label{eq:angle_penalty}
\mathcal G_\theta(t) = \cos \theta_{safe}- \frac{\dot{s_b}\cdot \mathbf z_d}{\norm{\dot{s_b}}\norm{\mathbf z_d}}, \mathcal J_\theta = \mathcal L_\varepsilon \left[ \mathcal G_\theta(t) \right].
\end{align}
And the gradient can be caculated just like Eq. \ref{eq:feasible_p_gradient}.
\subsubsection{Continuous-Time Constraints $\mathcal J_v, \mathcal J_\omega, \mathcal J_f, \mathcal J_g$}
$\mathfrak{T}_{\mathrm{MINCO}}$ can be freely deformed to meet the continuous-time constraints $\mathcal G$. However, enforcing $\mathcal G$ over the entire trajectory involves infinitely many inequalities that cannot be solved by constrained optimization. Inspired by \cite{cite:MINCO}, We transform $\mathcal G$ into finite inequality constraints using integral of constraint violations.
\begin{subequations}
\begin{align}
\label{eq:time_integral_penalty}
\mathcal I^\star_i= & \frac{T_i}{\kappa}\sum_{j=0}^{\kappa_i}\bar{\omega}_j\mathcal{G}_\star \rbrac{\frac{j}{\kappa} T_i },
\mathcal J_\star = \sum_{i=1}^{M} \mathcal I^\star_i, \\
\frac{\partial \mathcal J_\star}{\partial c_i} = & \frac{\partial \mathcal I^\star_i}{\partial \mathcal G_\star} \frac{\partial \mathcal G_\star}{\partial c_i},
~\frac{\partial \mathcal J_\star}{\partial T_i} = \frac{\mathcal I^\star_i}{T_i} + \frac{j}{\kappa} \frac{\partial \mathcal I^\star_i}{\partial \mathcal G_\star}\frac{\partial \mathcal G_\star}{\partial t},
\end{align}
\end{subequations}
where integer $\kappa$ controls the relative resolution of quadrature. $\rbrac{\bar{\omega}_0,\bar{\omega}_1,\dots,\bar{\omega}_{\kappa_i-1},\bar{\omega}_{\kappa_i}}=\rbrac{1/2,1,\cdots,1,1/2}$ are the quadrature coefficients following the trapezoidal rule \cite{cite:trapezoidal_rule}. $i = (1, 2, \cdots, N)$ denotes the $i$-th piece and $j = (1, 2, \cdots, \kappa)$.
\paragraph{Actuator Constraints}
Inspired by \cite{cite:feasible_constraint}, velocity $p_{i}^{(1)}(t)$, body rate $\omega$ and thrust $\tau$ of Eq. \ref{eq:actuator_constrain} can be constrained by constructing such a penalty function as follow, and the penalty gradients are caculated by
\begin{subequations}
\label{eq:actuator_penalty}
\begin{align}
~\mathcal G_D(t) = \mathcal L_\mu [\norm{D(t)}^2-D_{max}^2],
D= p_{i}^{(1)}(t), \omega, \tau, \\
\mathcal L_\mu[x] =
\begin{cases}
0, & x \leq 0, \\
(\mu - x/2)(x/\mu)^3, & 0 < x \leq \mu, \\
x - \mu/2, & x > \mu.
\end{cases}
\end{align}
\vspace{-0.2cm}
\begin{align}
~\frac{\partial \mathcal G_D}{\partial c_i} = 2\beta _i^{(n)} (t) p_i^{(n)}(t)^T \frac{\mathcal L_\mu}{\partial x}, \\
~\frac{\partial \mathcal G_D}{\partial T_i} = 2\beta _i^{(n)}(t) c_i p^{(n)}(t) \frac{\mathcal L_\mu}{\partial x}.
\end{align}
\end{subequations}
\paragraph{Safety Constraints}
The safety constraint Eq. \ref{eq:ground_constrain} avoiding the collision with ground can be transformed as such a penalty function \cite{cite:perching} as follow
\begin{equation}
\begin{aligned}
\label{eq:ground_penalty}
\mathcal G_g(t) = \mathcal L_\mu [z_{min}^2 - \norm{\mathbf e_3^T p(t)}^2].
\end{aligned}
\end{equation}
And the gradient is calculated just like Eq. \ref{eq:actuator_penalty}.
Summarizing the above strategies, the constraints of the Eq. \ref{eq:problem_formulation} are unified to the same unconstrained cost function Eq. \ref{eq:nonlinear_const_function}. The requiements can be trade off by adjusting the weight vector $\lambda$. We set initial value according to $p_0(t)$ in Section \ref{section:primitive} by calculating each intermediate waypoint position using the uniform time from decision making module. The problem is then efficiently solved by the L-BFGS \cite{cite:LBFGS} whose solver is open source\footnote{https://github.com/ZJU-FAST-Lab/LBFGS-Lite}.
\section{Experiments}
\begin{figure*}[htbp]
\subfloat[The process of the quadrotor catching triple targets continuously]{
\includegraphics[width=2.0\columnwidth]{./figures/experiment.pdf}
\label{fig:triple}
}
\vspace{-0.3cm}
\subfloat[Position map of ball catching process]{
\includegraphics[width=0.9\columnwidth]{./figures/experiment_p.pdf}
\label{fig:catching}
}
\subfloat[The quadrotor]{
\includegraphics[width=0.52\columnwidth]{./figures/experiment_quadrotor.pdf}
\label{fig:quadrotor}
}
\subfloat[The pitching machine]{
\includegraphics[width=0.53\columnwidth]{./figures/experiment_throwing.pdf}
\label{fig:throwing}
}
\vspace{0cm}
\subfloat[Velocity]{
\includegraphics[width=0.49\columnwidth]{./figures/experiment_v.pdf}
\label{fig:actuator_v}
}
\subfloat[Body Rate]{
\includegraphics[width=0.49\columnwidth]{./figures/experiment_w.pdf}
\label{fig:actuator_w}
}
\subfloat[Thrust]{
\includegraphics[width=0.49\columnwidth]{./figures/experiment_f.pdf}
\label{fig:actuator_f}
}
\subfloat[Jerk]{
\includegraphics[width=0.5\columnwidth]{./figures/experiment_j.pdf}
\label{fig:actuator_j}
}
\caption{
Experimental platform and results. (a) shows the process of catching triple targets. The time from each target thrown to hitting the ground (if not catched) is less than 1.9$s$. The time left for the quadrotor response is less than 1.6$s$. The catching time is less than 1.3$s$. The motion trajectories of three targets are represented by red, blue and orange respectively. Local images are magnified to see the moment of catching the targets clearly. The trajectories of the quadrotor are represented by ghost images. The green box is the pitching machine. The yellow box is the starting position of quadrotor planning. (b) shows the positions of the quadrotor and the targets moving measured by Vicon cameras. The translucent rectangle is the erea where the ball is measured for the first time and the landing position. (c) shows the quadrotor designed by ourselves. The diameter of catching net is 250mm, and the diagonal propeller distance of the quadrotor is 330mm. The distance between the hoop plane and the propeller plane is 200mm. (d)shows the pitching machine. The ball is pushed to the tee by the wave wheel, and the ball is squeezed and launched by two rubber wheels driven by brushless motors. (e) shows the quadrotor velocity from an EKF. (f) shows the quadrotor angular rate measured by the IMU. Due to the vibration of the rack, the curve has a small jitter, which is a normal phenomenon. (g) shows the thrust. The orange translucent lines are the measured value with noise, and blue is the expected command. (h) shows the desired jerk.
}
\label{fig:experiment}
\vspace{-0.5cm}
\end{figure*}
We design real scenes and simulated scenes to verify the robustness and extensibility of Catch Planner, and compare with the benchmark.
\subsection{Real-world Experiments}
\subsubsection{Experiments Platform}
We design a quadrotor with a net attached above the center of mass, shown as Fig. \ref{fig:quadrotor}. An NUC-11TNHI5 is used as the onboard computer and all programs run on Intel I5-1135G7 CPU at 2.4GHz. Motion Primitive Planner (MPP)\cite{cite:bvp} is as the benchmark, which runs on the same computer. A $18m * 9m * 5m$ motion capture gym with 22 Vicon cameras is used as the experimental site, shown in Fig. \ref{fig:triple}. A pitching machine with two driven rubber wheels is used for throwing balls, shown as Fig. \ref{fig:throwing}. The state estimation of the quadrotor is given by an EKF of the pose from Vicon cameras and the IMU data from a PX4 Autopilot. We adopt the $SE(3)$ casecade PID controller using Hopf fibration \cite{cite:Holf} to avoid singularities and align the attitude calculation of planning and control. Control command is calculated from the trajectory by using differential flatness output model \cite{cite:minsnap}.
The target throwing position is set at $(4, 0, 0.8) $ under world coordinate. Because the throwing is random, the ball's landing position is within $2m \times 0.8m$ at height 0$m$, shown in Fig. \ref{fig:catching}. Due to the height limitation, the balls only fly below 4.2$m$, which means that the flight time of the ball does not exceed 1.9$s$. In fact, in our experiment, the sensing data is considered stable and used only after the balls are thrown more than 2$m$. After the first target motion model updated, the state of the ball is output after the ball exceeds the height of 2.8$m$. In this case, the whole flight time of each target does not exceed 1.6$s$.
\subsubsection{Experimential Results}
\begin{figure*}[t]
\begin{center}
\subfloat[Velocity]{
\includegraphics[width=0.6\columnwidth]{./figures/benchmark_v.pdf}
}
\subfloat[Body Rate]{
\includegraphics[width=0.6\columnwidth]{./figures/benchmark_w.pdf}
}
\subfloat[Thrust]{
\includegraphics[width=0.6\columnwidth]{./figures/benchmark_f.pdf}
}
\end{center}
\caption{
\label{fig:benchmark}
The MPP's planning dynamic curve.
}
\vspace{-0.5cm}
\end{figure*}
We check the dynamic, safety and catching constraints of the desired trajectory to ensure that the calculated trajectory is executable. If the trajectory passes the check, the decision and planning are considered successful. If the ball falls into the net, it will be regarded as a successful catching. In addition, we propose the optimal time ratio (OTR) to measure the gap between decision results and optimal results. The MPP has no OTR because it has no decision-making ability. The OTR is defined as follows:
\begin{align}
OTR = \frac{1}{n}\sum \frac{|T_o-T_p|}{T_o},
\end{align}
which measures the proximity of $n$ output of the decision-making module $T_p \in \mathcal T_p$ and optimized time $T_o \in \mathcal T_o $. Obviously, the closer the decision result is to the optimal result, the smaller OTR is. It also provides a pattern for measuring the ability of decision making under similar planning-with-decision frameworks.
We carry out 50 experiments respectively for Catch Planner and MPP \cite{cite:bvp}. Like \cite{cite:bvp}, we set the terminal catching height below 2$m$. The terminal velocity and acceleration are sampled, and the trajectory with the lowest cost is finally adopted. Table \ref{tab:real-world_result} summarizes the experimental results. It can be seen that the success rate of Catch Planner is far greater than that of MPP. Due to the gap between ideal and reality, the success rate of catching will never be higher than the success rate of planning, which is caused by various errors.
\begin{table}[ht]
\renewcommand\arraystretch{1.2}
\centering
\caption{Success Rate and Optimal Time Ratio}
\label{tab:real-world_result}
\begin{tabular}{ccccc}
\toprule
\multicolumn{2}{c}{} & \makecell{Planning \\ Success Rate} & \makecell{Catching \\ Success Rate } & OTR \\
\midrule
\multicolumn{2}{c}{Catch Planner} & 96\% & 64\% & 0.092 \\
\multicolumn{2}{c}{MPP\cite{cite:bvp}} & 14\% & 8\% & - \\
\bottomrule
\end{tabular}
\end{table}
Three consecutive successful catch cases are selected to analyze the dynamics. We only visualize the real data of the quadrotor during moving, not including hovering. Fig. \ref{fig:experiment}e-g show that the planned trajectory can effectively constrain the velocity, angular velocity and thrust. Fig. \ref{fig:actuator_j} shows that the planned trajectory is smooth enough, even jerk.
We compare Catch Planner with the state-of-the-art catching method MPP. The logged bag of the first catching in Fig. \ref{fig:experiment} is used to simulate the same throwing. The catching time is set to be the same, which means the same state of caught target. The desired trajectory of MPP is shown in the Fig. \ref{fig:benchmark}. It can be seen that ignoring the dynamic feasibility and safety of the benchmark leads to some actuator's command exceeding the limit, which often appears in the 50 experiments.
Our method can also catch multiple flying balls, which benefits from the real-time decision making ability. Although it is within the 4.2$m$ height limit, the quadrotor still shows the ability to catch two targets flying together in the air, as shown in Fig. \ref{fig:introduction}.
\begin{table}[ht]
\renewcommand\arraystretch{1.2}
\centering
\caption{Characteristics comparison}
\label{tab:characteristics}
\begin{tabular}{ccccc}
\toprule
\multicolumn{2}{c}{} & Catch Planner & Benchmark's \\
\midrule
\multicolumn{2}{c}{Decision-making Ability} & \textbf{Autonomous} & Manual \\ \multicolumn{2}{c}{Time \& Terminal State} & \textbf{Optimize} & Fix \\
\multicolumn{2}{c}{Dynamic Feasibility} & \textbf{Optimize} & Check \\
\multicolumn{2}{c}{Crash Safety} & \textbf{Optimize} & Check \\
\multicolumn{2}{c}{Computing Consumption} & 9 $ms$ & \textbf{0.149 $ms$} \\
\bottomrule
\end{tabular}
\end{table}
The characteristics of Catch Planner and MPP are summarized as the Table \ref{tab:characteristics}. MPP does not have high-level decision making ability, but relies on manual assignment. The state of the target is highly coupled with the time. This is not considered by MPP \cite{cite:bvp}. The dynamic feasibility and safety are also ignored during planning and only checked the end state. In addition, For computing consumption, although the calculted time of a single trajectory in \cite{cite:bvp} is far less than our method, 9$ms$ is enough for the 100$hz$ frequency of state estimation and control, while only 2$ms$ is required for re-planning.
\subsection{Simulation Experiments }
\begin{figure}[t]
\begin{center}
\includegraphics[width=1\columnwidth]{./figures/simulation_all.pdf}
\end{center}
\caption{
\label{fig:simulation}
The simulation scenarios. Multiple flight paths of the target are visualized as curves with multiple colors. (a) Parabola. (b) Harmonic. (c) Triangle. (d) Hexagon.
}
\vspace{-1cm}
\end{figure}
\subsubsection{Scene Simulation}
We design 4 scenarios to evaluate our planning-with-decision method according to different target trajectory types. Compared with real experiments, simulation scenarios effectively eliminate the target prediction error, sensing error, control error and communication delay in the real environment, so that we can focus on verifying the effectiveness of planning-with-decision methods. Thanks to the economy of simulation, we test 1000 experiments for each scenario in short time. The different trajectories types of the targets are as follow:
\paragraph{Parabola} This simulation to throw 2 targets is highly consistent with the real experimental scene, except that the target is free from height limitation and wind resistance. The change of position from initial position $p_0$ can be expressed by acceleration $a$ and velocity $v_{pa}$ motion trajectory as $p_{pa}(t) = 1/2at^2+v_{pa} t+p_0,\ t<2$.
\paragraph{Harmonic} 2 targets move at the speed $v_{ha}$ in the shape of harmonic, expressed as $p_{ha}(t) = sin(v_{ha}t) +p_0,\ t<7$.
\paragraph{Triangle} 3 diagonally moving objects move and form an equilateral triangle. For the $i$-th and $j$-th targets, the position can be calculated as $p_{tr}(t) = v_{tr}t+p_0, \ \left< v^i, v^j \right>=2/3\pi \ and \ v^i \neq v^j for \ \forall v^i, v^j,\ t<6$.
\paragraph{Hexagon} The position of 6 targets flying in parallel at a constant velocity $v_{he}$ can be expressed as $p_{he}(t) = v_{he}t+p_0,\ t<10$.
It is worth noting that the above trajectories are all on $e_3$. The target keeps constant velocity on $e_1$ and $e_2$.
\subsubsection{Experimential Results}
In our simulation experiment, there is no target trajectory prediction and quadrotor control error. The success rate in Table \ref{tab:simulation_result} can reflect the ability of our method through thousands of experiments.
The results show that the catching difficulty increases as the targets amount increases and trajectory becomes more complex, which is due to the parameter random initialization in training and testing experiment.
Experience tells us that the success rate usually exceeds 80\% when the OTR is below 0.3. Although it has not been proved by theory, it can be used as a reference for researchers.
The experimental results demonstrate the scalability of our method. In fact, the only requirement for using our method is that the motion of targets can be differentially analytically expressed. This condition can be easily achieved by establishing curve fitting or simplifying dynamic models.
\begin{table}[ht]
\renewcommand\arraystretch{1.2}
\setlength{\tabcolsep}{0.15cm}
\centering
\caption{Success Rate}
\label{tab:simulation_result}
\begin{tabular}{ccccccc}
\toprule
\multicolumn{2}{c}{} & \makecell{Parabola \\ (1 target) } & \makecell{Parabola \\ (2 targets) } & \makecell{Harmonic \\ (2 targets)} & \makecell{Triangle \\ (3 targets)} & \makecell{Hexagon \\ (6 targets)} \\
\midrule
\multicolumn{2}{c}{\makecell{Success \\ Rate} } & 99.3\% & 98.2\% & 84.7\% & 99.7\% & 76.3\% \\
\multicolumn{2}{c}{OTR} &0.052 & 0.119 & 0.234 & 0.126 & 0.458 \\
\bottomrule
\end{tabular}
\end{table}
\section{Conclusion}
In this paper, we propose a novel planning-with-decision framework Catch Planner to catch high-speed moving targets when facing \textbf{F}ormulistic, \textbf{L}ightweight, \textbf{A}daptive and \textbf{F}lexible requirements (FLAF). It integrates decision making, trajectory generation and optimization, and target trajectory prediction modules.
Under Catch Planner framework, the advantages of learning based and optimization based methods complement each other by the coupling of planning and decision making, meeting the \textbf{F}ormulistic need. We propose a policy search method based on DRL to solve the decision making problem, and propose a self-supervised neural network training method. Then, we propose a spatio-temporal optimal trajectory optimization method for optimal catching. Facing different flying targets, the coupling time and terminal position are jointly optimized to\textbf{A}daptively catch, and a terminal constraint transformation method is proposed to make the catching \textbf{F}lexible. All the above are solved online with the calculation consumption does not exceed 10$ms$, which proves the \textbf{L}ightweight of the framework.
We conduct simulations and real experiments to verify the robustness of the proposed method. The real world planning success rate is 96\%. The universality and scalability of the algorithm are verified by setting different target trajectories. Furthermore, this method has the potential to solve other highly dynamic problems.
\section{Acknowledgment}
The authors would like to thank Prof. H. Li and L. Xu for their helps in the establishment of experimental site.
| {'timestamp': '2023-02-10T02:03:57', 'yymm': '2302', 'arxiv_id': '2302.04387', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04387'} | arxiv |
\section{Introduction}\label{introduction}}
\IEEEPARstart{T}{he} problems of clustering aim at the optimal grouping of the observed data and appear in very diverse fields
including pattern recognition and signal compression. Fuzzy c-means \cite{dunn1973fuzzy, bezdek1973fuzzy, bezdek2013pattern, bezdek1984fcm}
and deterministic annealing clustering \cite{rose1990deterministic,rose1990statistical,rose1993constrained,beni1994least}
are the most widely used ones among the objective function-based clustering methods.
Both of them start with an attempt to alleviate the local minimum trap problem
suffered by hard c-means \cite{duda1973pattern}
and achieved better performance in most cases.
However, we haven't yet found solid theoretical foundation for FCM,
and the parameter $m$ involved seems unnatural without any physical meaning.
Another crucial assumption underlying most current theory of clustering problem is that the distribution
of training samples is identical to the distribution of future test samples, but it is often violated in practice
where the distribution of future data deviates from the distribution of training data.
For example, a decision-making system is forecasting future actions in the presence of
current uncertainty and imperfect knowledge\cite{garibaldi2019need}.
In this paper, we propose a clustering model based on importance sampling
which minimizes the worst case of expected distortions under the constraint of distribution deviation.
The distribution deviation is measured by the Kullback–Leibler
divergence\cite{kullback1951information,williams1980bayesian, sadaaki1997fuzzy,ichihashi2000gaussian,
coppi2006fuzzy,ortega2013thermodynamics,genewein2015bounded,hihn2019information}
between the current distribution and a future distribution.
The proposed model is called \textit{Importance Sampling Deterministic Annealing}, denoted as ISDA for short,
and we show that fuzzy c-means is a special case of ISDA
which gives a physical meaning of the fuzzy exponent $m$ in fuzzy c-means.
The proposed ISDA clustering algorithm aims to minimize the loss in maximum degradation
and hence the resulting optimal problem is a minimax problem.
Inspired from the importance sampling method\cite{tokdar2010importance,shi2009neural,shi2009hierarchical},
we convert the constraint between the current and future distribution
to a constraint on the importance sampling weights.
The constrained minimax problem can be reformulated to an unconstrained problem using the Lagrange method.
The advantage of the reformulation of ISDA is that the
resulting unconstrained optimization problem is dependent on cluster centers only and
the solution to the corresponding optimization problem can be found by applying the
quasi-newton algorithms\cite{gill1972quasi,fletcher2013practical}.
We conduct experiments on both synthetic datasets and a real-world dataset
to validate the effectiveness of ISDA.
First, an evaluation metric called M-BoundaryDist is proposed
as a measure of how well a clustering algorithm performs
with respect to the boundary points.
M-BoundaryDist calculates the sum of distances of boundary points to the dataset centroid.
Experiment results on synthetic Gaussian datasets show that
when $T_2$ is small, the cluster centers of ISDA are closer to the boundary points
compared with Kmeans\cite{krishna1999genetic} and FCM
and performs better under large distribution shifts.
Next, results on load forecasting problem show that
ISDA performs better compared with Kmeans and FCM
on 9 out of 12 months on future load series.
Both synthetic and real-world examples validate the effectiveness of ISDA.
\textbf{Outline of the paper.}
\Cref{Related Work} gives a brief review of related work on fuzzy c-means and deterministic annealing clustering algorithm.
\Cref{ISDA} describes our proposed importance sampling deterministic annealing for clustering model
and the algorithm to solve it.
The relationship between fuzzy c-means and ISDA is also given in this section.
\Cref{Results} conducts experiments on synthetic Gaussian datasets.
Specifically, \Cref{metric} compares Kmeans, FCM and ISDA with respect to the boundary points and
\Cref{dist-shift} compares the three clustering methods on deviated datasets.
\Cref{T2} analyzes how the temperature $T_2$ affects the ISDA clustering result.
\Cref{load-forecasting} applies ISDA on a real-world load forecasting problem and show that ISDA performs better
under most scenarios of future distribution shifts.
Finally, we conclude this paper in \Cref{conclusion}.
\section{Related Work} \label{Related Work}
Let $D =\{x_1,x_2,\cdots,x_N\}$ be a given set of $N$ points in $S$ dimensional space.
These data points are to be partitioned into $C$ clusters.
We denote the prototype of cluster $j$ as $y_j$.
$Y=\{y_1, y_2, \cdots, y_C\}$ denotes all cluster centers and
$d(x_i, y_j)$ denotes the \textbf{squared} distance between $x_i$ and $y_j$,
which is usually used as the distortion measure.
\textbf{Hard C-Means Clustering}
In clustering analysis, hard c-means assigns each data point to a single cluster\cite{menard2004non}
and aims to minimize the following objective function $F_H(Y,U)$
\begin{align}
\begin{split}
\label{eqn:HCM-uij}
\min_{Y,U} \quad & F_{H}(Y,U)=\sum_{i=1}^{N}\sum_{j=1}^{C}u_{ij}d(x_i,y_j) \\
\text{s. t.} \quad & \sum_{j=1}^{C}u_{ij}=1, 1\leq i \leq N \\
& 0 < \sum_{i=1}^{N} u_{ij} < N, 1\leq j \leq C \\
& u_{ij}\in\{0,1\}, 1\leq i \leq N, 1\leq j \leq C
\end{split}
\end{align}
where $u_{ij}$ denotes the membership of the $i$-th data point to the $j$-th cluster center
and $U=[u_{ij}]_{N \times C}$ is the partition matrix.
The objective of hard c-means is to find the optimal center $Y$ and the membership $U$.
\textbf{Fuzzy C-Means Clustering}
Fuzzy clustering is a fruitful extension of hard c-means\cite{duda1973pattern}
with various applications and is supported by cognitive evidence.
The fuzzy clustering algorithms regard each cluster as a fuzzy set
and each data point may be assigned to multiple clusters
with some degree of sharing\cite{menard2004non}.
In fuzzy c-means\cite{bezdek1984fcm}, an exponent parameter $m$ is introduced and
$u_{ij} $ is interpreted as the fuzzy membership with values in $[0,1]$
which measures the degree to which the $i$-th data point belongs to the $j$-th cluster.
The corresponding objective function $F_{FCM}(Y,U)$ and the constraints are as follows
\begin{align}
\begin{split}
\label{eqn:FCM}
\min_{Y,U} \quad & F_{FCM}(Y,U)=\sum_{i=1}^{N}\sum_{j=1}^{C} u_{ij}^{m} d(x_i,y_j)\\
\text{s. t.} \quad & \sum_{j=1}^{C} u_{ij}=1, 1\leq i \leq N \\
& 0 < \sum_{i=1}^{N} u_{ij} < N, 1\leq j \leq C \\
& u_{ij}\in [0,1], 1\leq i \leq N, 1\leq j \leq C
\end{split}
\end{align}
where $m \in [1, \infty)$ is a fuzzy exponent called the fuzzifier.
The larger $m$ is, the fuzzier the partition\cite{ichihashi2000gaussian}.
The necessary optimality conditions for the fuzzy partition matrix
$U$ is as follows\cite{bezdek2013pattern}
\begin{align}
u_{ij}=\frac{d(x_i,y_j)^{\frac{1}{1-m}}}{\sum_{j=1}^{c}d(x_i,y_j)^{\frac{1}{1-m}}},
\quad 1\leq j \leq C, \quad 1\leq i \leq N. \label{eq:FCM-Uij}
\end{align}
Substituting \eqref{eq:FCM-Uij} into \eqref{eqn:FCM}, we get
\begin{align}
R_{FCM}(Y) = \sum_{i=1}^{N} (\sum_{j=1}^{C} d(x_i,y_j)^{1\over 1-m})^{1-m}. \label{eq:FCM-reform}
\end{align}
Minimizing $R_{FCM}(Y)$ with respect to $Y$, we can get the optimal cluster prototypes.
\eqref{eq:FCM-reform} is called the reformulated criteria of FCM\cite{hathaway1995optimization}
and can be solved by commercially available software.
The function $F_{FCM}(Y,U)$ depends on both $U$ and $Y$ and the function $R_{FCM}(Y)$ depends on $Y$ only.
The aim of reformulation is to decrease the number of variables by eliminating $U$
by the optimal necessary condition with respect to $U$.
\textbf{Deterministic Annealing Clustering}
The deterministic annealing clustering was derived from a statistical physical or information-theoretical view,
and finds many applications in unsupervised and supervised problems\cite{rose1998deterministic}.
Let $x$ denote a data point or source vector, $y(x)$ denote its representation cluster center,
and $d(x,y(x))$ denote the distortion measure.
For a random variable $X$ with distribution $p(x)$, the expected distortion for this representation can be written as
\begin{equation}
L = \int_x\int_y p(x,y)d(x,y)dxdy = \int_x p(x)\int_y p(y|x)d(x,y)dxdy \label{eq:Loss}
\end{equation}
where $p(x,y)$ is the joint probability distribution
and $p(y|x)$ is the association probability relating input vector $x$ and cluster center $y$.
The aim of deterministic annealing for clustering is to
minimize $L$ with respect to the conditional probability $p(y|x)$ and $y$
subject to a specified level of randomness.
The level of randomness is usually measured by the joint entropy $H(X,Y)$,
which can be decomposed into sums of entropy and conditional entropy,
which is $H(X,Y)=H(X) + H(Y|X)$.
Since $H(X)$ is independent of clustering,
we use the conditional entropy $H(Y|X)$ as a measure of randomness.
Therefore, the constraint becomes $H(Y|X) \leq C_0$ and
the constrained optimization problem becomes
\begin{align}
\min_{p(y|x),y} \quad L & = \int_x p(x)\int_y p(y|x)d(x,y)dxdy \label{eq:DA-L} \\
s.t. \quad & H(Y|X) \leq C_0. \label{eq:DA-constraints}
\end{align}
The above problem can be reformulated to the unconstrained optimization problem
using the Lagrange method, as shown in \eqref{eq:DA-lagrange}
\begin{align}
\min_{p(y|x), y} F & = L-T_1H(Y|X). \label{eq:DA-lagrange}
\end{align}
Here the Lagrange multiplier $T_1$ is the temperature
which governs the level of randomness of the conditional entropy.
In classical clustering problems,
the dataset $D$ is assumed to be independently drawn from $p(x)$
and the codebook $Y$ is finite. If we denote the association probability $p(y_j|x_i)$ as $u_{ij}$,
then the empirical estimates of \eqref{eq:DA-lagrange} is \eqref{eq:DA-distortion}
\begin{equation}
F_{DA}(Y,U) = \sum_{i=1}^{N}\sum_{j=1}^{C}u_{ij}d(x_i,y_j) +
T_1\sum_{i=1}^{N}\sum_{j=1}^{C}u_{ij}log u_{ij} \label{eq:DA-distortion}
\end{equation}
then the optimization problem becomes
\begin{align}
\begin{split}
\label{eqn:DA}
\min_{U,Y} \quad & F_{DA}(Y,U) \\
\text{s.t.} \quad & \sum_{j=1}^{C} u_{ij}=1, 1\leq i \leq N \\
& 0 < \sum_{i=1}^{N} u_{ij} < N, 1 \leq j \leq C \\
& u_{ij} \in [0,1], 1\leq i \leq N ,1 \leq j \leq C.
\end{split}
\end{align}
This is known as deterministic annealing for clustering\cite{rose1990deterministic,rose1998deterministic}.
An equivalent derivation of \eqref{eqn:DA} can be obtained by
the principle of maximum entropy in which the level of expected distortion $L$
is fixed\cite{rose1998deterministic,jaynes1957information}.
Minimizing $F_{DA}(Y,U)$ with respect to $u_{ij}$
is straightforward and gives the Gibbs distribution\cite{rose1998deterministic}
\begin{equation}
u_{ij} = \frac{exp(-\frac{1}{T_1} d(x_i, y_j))}{\sum_{j=1}^{C} exp(-\frac{1}{T_1} d(x_i, y_j))}. \label{eq:DA-U}
\end{equation}
The corresponding minimum of $F_{DA}(Y,U)$ is obtained by
putting \eqref{eq:DA-U} back to \eqref{eq:DA-distortion},
also known as the reformulation of determinisic annealing for clustering\cite{zhang2003robust}, which is
\begin{equation}
R_{DA}(Y) = - T_1 \sum_{i=1}^{N} log(\sum_{j=1}^{C} exp(-\frac{d(x_i, y_j)}{T_1})). \label{eq:DA-reformulation}
\end{equation}
The underlying assumption of HCM, FCM and determinisic annealing clustering
is that the distribution of training data is the same as future data,
however it may not hold in many real cases.
In the following section, we propose a new clustering algorithm
to handle this this problem derived from the importance sampling method.
\section{Importance Sampling Deterministic Annealing} \label{ISDA}
In the proposed Importance Sampling Deterministic Annealing (ISDA) clustering method,
we assume that the observed data set draws from a distribution $q(x)$
and our aim is to construct a clustering algorithm for a population with unknown distribution $p(x)$.
We further assume that if $p(x)$ are, instead of being completely unknown,
restricted to a class of distributions, i.e.
\begin{equation}
\Gamma = \{p(x): KL(p(x)||q(x)) \leq C_1 \}. \label{eq:gamma}
\end{equation}
A \textit{minimax} approach is applied through minimizing the
worst-case loss restricted to this constraint.
\Cref{ISDA-model} gives a principled derivation of the minimax approach and
\Cref{ISDA-algorithm} solves the corresponding optimization problem based on its reformulation.
The derivation of our proposed approach in this paper is heavily dependent on the work\cite{rose1998deterministic}.
\subsection{Principle of ISDA clustering} \label{ISDA-model}
In this section, we give out the principled deviation of the minimax approach.
In our proposed algorithm, we aim to minimize the \textit{worst-case situation}
of expected distortion under the given constraints,
which is
\begin{equation}
L = \int_x\int_y p(x,y)d(x,y)dydx
\end{equation}
where $d(x,y)$ represents a \textbf{squared} distance between $x$ and $y$
for convenience and the derivation also holds for other distortion measures.
First, we find the best partition $U$ to minimize the expected distortion $L$
under the conditional entropy constraint.
The corresponding optimization problem is
\begin{align}
\begin{split}
\min_{p(y|x)} \quad & L =\int_x\int_y p(x,y)d(x,y)dydx \\
\text{s.t.} \quad & H(Y|X) \leq C_0.
\end{split}
\end{align}
Second, for a given partition $p(y|x)$ , we find a $p(x)$
which maximizing the objective function and corresponds to the \textit{worst-case situation}.
However, $p(x)$ is unknown in the problem and we assume that
$p(x)$ is subject to the constraint $KL(p(x)||q(x)) \leq C_1$.
Therefore, the corresponding optimization problem becomes
\begin{align}
\begin{split}
\max_{p(x)} \min_{p(y|x)} \quad & L =\int_x\int_y p(x,y)d(x,y)dydx \\
\text{s.t.} \quad & H(Y|X) \leq C_0 \\
\quad & KL(p(x)||q(x)) \leq C_1.
\end{split}
\end{align}
Third, given the fuzzy partition $p(y|x)$ and the worst-case distribution $p(x)$,
we aim to find the best prototype $y$ which minimizes the objective function.
Then the corresponding optimization problem is
\begin{align}
\begin{split} \label{eq:L-with-constraints}
\min_{y} \max_{p(x)} \min_{p(y|x)} \quad & L=\int_x\int_y p(x,y)d(x,y)dydx \\
\text{s.t.} \quad & H(Y|X) \leq C_0 \\
\quad & KL(p(x)||q(x)) \leq C_1.
\end{split}
\end{align}
Suppose $Y=\{y_1,y_2,\cdots,y_C\}$ is a finite set and
the observed dataset $D =\{x_1,x_2,\cdots,x_N\}$ are $N$ i.i.d samples drawn from $q(x)$.
Derived from the importance sampling method,
the constraint on $p(x)$ becomes the constraint on the importance sampling weights, which is
\begin{equation}
\Gamma = \{w(x_i): KL(w(x_i)||\{ \frac{1}{N} \}) \leq C_1 \} \label{eq:gamma-W}
\end{equation}
where $\{ \frac{1}{N} \}$ denotes the discrete uniform distribution with $N$ points.
The self-normalized importance sampling weight for $x_i$ is
$w_i = {{p(x_i)\over q(x_i)}\over{{\sum_l {{p(x_l)\over q(x_l)}}}}}$.
The corresponding importance sampling weight is $W=[w_i]_{N \times 1}$ with $\sum_{i=1}^{N} w_i=1$,
which is called the importance sampling weight distribution.
The association probability $p(y_j|x_i)$ is denoted as $u_{ij}$
and the fuzzy membership matrix is $U=[u_{ij}]_{N \times C}$.
Then the empirical estimate of $L$ is
\begin{equation}
L \approx \sum_{i=1}^{N} w_i \sum_{j=1}^{C} u_{ij} d(x_i, y_j), \label{eq:L-empirical}
\end{equation}
the empirical estimate of $H(Y|X)$ is
\begin{equation}
H(Y|X) \approx \sum_{i=1}^{N} w_i \sum_{j=1}^{C} u_{ij} log u_{ij}, \label{eq:H(Y|X)-empirical}
\end{equation}
and the empirical estimate of $KL(p(x)\parallel q(x))$ is
\begin{align}
KL(p(x) \parallel q(x)) & \approx KL(w(x_i) \parallel \{\frac{1}{N}\}) \nonumber \\
& = \sum_{i=1}^{N} w_i log w_i + log N. \label{eq:KL-pq-empirical}
\end{align}
The proof of \eqref{eq:L-empirical}, \eqref{eq:H(Y|X)-empirical} and \eqref{eq:KL-pq-empirical}
are shown in Appendix A
Then, the constrained optimization problem in \eqref{eq:L-with-constraints} can be reformulated to
the unconstrained optimization problem using the Lagrange method,
\begin{equation}
F_{ISDA}^{0}(Y,W,U) = L-T_1H(Y|X) -T_2 KL(w(x_i)||\{ \frac{1}{N} \}) \label{eq:ISDA-objective} \\
\end{equation}
where $T_1 > 0$ and $T_2 > 0$ are the temperature parameters
which govern the randomness of $U$ and $W$ respectively.
Plugging \eqref{eq:L-empirical}, \eqref{eq:H(Y|X)-empirical} and \eqref{eq:KL-pq-empirical}
back into \eqref{eq:ISDA-objective}, we get the empirical estimates of the objective function for ISDA
clustering, which is
\begin{align}
& F_{ISDA}^{0}(Y,W,U) = \sum_{i=1}^{N} w_i\{\sum_{j=1}^{C} u_{ij} d(x_i,y_j) \nonumber \\
& +T_1\sum_{j=1}^{C}u_{ij}log u_{ij}\} -T_2\sum_{i=1}^{N} w_i log w_i-T_2log(N). \label{eq:ISDA-empirical-0}
\end{align}
Since $T_2$ is predefined and the last term $log(N)$ is a constant,
we finally get $F_{ISDA}(Y,W,U)$ by omitting the last term, which is
\begin{align}
& F_{ISDA}(Y,W,U) = \sum_{i=1}^{N} w_i\{\sum_{j=1}^{C} u_{ij} d(x_i,y_j) \nonumber \\
& + T_1\sum_{j=1}^{C}u_{ij}log u_{ij}\} - T_2\sum_{i=1}^{N} w_i log w_i. \label{eq:ISDA-empirical}
\end{align}
Adding the constraints on the partition matrix $U$ and the importance sampling weight $W$,
the optimization problem of ISDA is as follows
\begin{align}
\min_{Y} \max_{W} \min_{U} \quad & F_{ISDA}(Y,W,U) \label{eq:ISDA} \\
\text{s.t.} \quad & \sum_{j=1}^{C} u_{ij}=1, 1 \leq i \leq N \nonumber \\
& 0 < \sum_{i=1}^{N} u_{ij} < N, 1 \leq j \leq C \label{eq:constraints-uij} \\
& u_{ij} \in [0,1], 1\leq i \leq N ,1 \leq j \leq C \nonumber \\
& \sum_{i=1}^{N}w_{i}=1, w_i \in [0,1], 1 \leq i \leq N \label{eq:constraints-wi}
\end{align}
where \eqref{eq:constraints-uij} are the constraints for the fuzzy membership $U$\cite{bezdek1984fcm}
and \eqref{eq:constraints-wi} is the constraint for the importance sampling weight $W$.
In conclusion, ISDA is an objective-function-based clustering method and
the objective funciton can be seen as a trade-off between
the expected distortion, the level of randomness and the distribution deviation.
When $T_2 \rightarrow 0$, the distribution shift $KL(p(x)) \parallel q(x))$ can be very large
and for $T_2 \rightarrow \infty $, the distribution shift should be small,
the effect of $T_2$ is further illustrated in \Cref{T2}.
\subsection{Reformulation of ISDA clustering} \label{ISDA-algorithm}
In this section, we give a reformulation of ISDA and
a corresponding optimization routine following \cite{hathaway1995optimization} to solve the problem.
We derive the membership and weight update equations from the necessary optimality
conditions for minimization of the criterion function
by differentiating $F_{ISDA}(U,W,Y)$ with respect to $U$, $W$ and set the derivatives to zero.
Specifically, let the Lagrange multiplier be $\{\lambda_i \}_{i=1}^{N}$ and $\lambda$,
then the Lagrange function becomes $\mathcal{L}_{ISDA}$
\begin{align}
\mathcal{L}_{ISDA} & = \sum_{i=1}^{N} w_i\{\sum_{j=1}^{C} u_{ij} d(x_i,y_j)+
T_1\sum_{j=1}^{C}u_{ij}log u_{ij}\} \nonumber \\
& -T_2\sum_{i=1}^{N} w_i log w_i \nonumber \\
& - \sum_{i=1}^{N} \lambda_i (\sum_{j=1}^{C} u_{ij} -1) - \lambda (\sum_{i=1}^{N} w_i-1). \label{eq:ISDA-lagrange}
\end{align}
Setting the derivative of $\mathcal{L}_{ISDA}$ with respect to $U$ to zero,
we get the optimality necesary condition for $U$, which is
\begin{equation}
u_{ij} = \frac{exp(-\frac{d(x_i, y_j)}{T_1})}{\sum_{j=1}^{C} exp(-\frac{d(x_i, y_j)}{T_1})}. \label{eq:ISDA-uij}
\end{equation}
Plugging \eqref{eq:ISDA-uij} back into \eqref{eq:ISDA-lagrange}, we get the reformulation for $U$, which is
\begin{align}
R_{ISDA}(Y,W) = & -T_1 \sum_{i=1}^{N} w_i [log \sum_{j=1}^{C} exp(-\frac{d(x_i, y_j)}{T_1})] \nonumber \\
& \quad -T_2\sum_{i=1}^{N} w_i log w_i - \lambda (\sum_{i=1}^{N} w_i-1). \label{eq:ISDA-Y-W}
\end{align}
Setting the derivative of $R_{ISDA}(Y,W)$ with respect to $W$ to zero,
we get the optimality necesary condition for $W$, which is
\begin{equation}
w_i = \frac{[\sum_{j=1}^{C} exp(-\frac{d(x_i, y_j)}{T_1})]^{-\frac{T_1}{T_2}}}
{\sum_{l=1}^{N} [\sum_{j=1}^{C} exp(-\frac{d(x_l, y_j)}{T_1})]^{-\frac{T_1}{T_2}}}.\label{eq:ISDA-wi}
\end{equation}
Substituting \eqref{eq:ISDA-wi} into \eqref{eq:ISDA-Y-W}, we get the reformulation for $U$ and $W$, which is
\begin{equation}
R_{ISDA}(Y) = T_2 log(\sum_{l=1}^{N} [\sum_{j=1}^{C} exp(-\frac{d(x_i, y_j)}{T_1})]^{-\frac{T_1}{T_2}}). \label{eq:ISDA-Y}
\end{equation}
We call $R_{ISDA}(Y)$ the reformulation function of $F_{ISDA}(Y,W,U)$
and the minimization of $R_{ISDA}(Y)$ with respect to $Y$ is equivalent to
the min-max-min of $F_{ISDA}(Y,W,U)$ with respect to $Y,W,U$.
Therefore, finding the solution to ISDA clustering becomes minimization of
$R_{ISDA}(Y)$ with respect to $Y$.
The proofs of \Crefrange{eq:ISDA-uij}{eq:ISDA-Y} are shown in Appendix B.
\textit{Remark:}
ISDA can be seen as a two-level statistical physical model.
For the first system, for a given $x_i$,
if we regard $d(x_i,y_j)$ as the energy for the prototype $y_j$,
then
\begin{equation}
\sum_{j=1}^{C} u_{ij} d(x_i,y_j) + T_1\sum_{j=1}^{C}u_{ij}log u_{ij}
\end{equation}
becomes the Helmholtz free energy with the temperature $T_1$\cite{rose1998deterministic}.
In bounded rationality theory\cite{genewein2015bounded,ortega2015information},
$-T_1 log \sum_{j=1}^{C} exp(-\frac{d(x_i,y_j)}{T_1}) $ is called the certainty equivalence.
For the second system, if we regard $log [\sum_{j=1}^{C} exp(-\frac{d(x_i, y_j)}{T_1})]^{T_1}$
as the energy for $x_i$, then
\begin{equation}
- \sum_{i=1}^{N} w_i [log \sum_{j=1}^{C} exp(-\frac{d(x_i, y_j)}{T_1})]^{T_1} -T_2 \sum_{i=1}^{N} w_i log w_i
\end{equation}
becomes the negative Helmholtz free energy with the temperature $T_2$.
\subsection{Fuzzy-ISDA}
In this section, we use the \textbf{logarithmic} transformation\cite{sadaaki1997fuzzy} of distortion $d(x,y)$ as the distortion measure
and call the resulting ISDA model as Fuzzy-ISDA.
The expected logarithmic distortion is
\begin{equation}
L^{Fuzzy} = \int_x\int_y p(x,y)log d(x,y)dydx.
\end{equation}
Similarly in ISDA, the corresponding optimization problem of Fuzzy-ISDA is
\begin{align}
\begin{split} \label{eq:L-log-with-constraints}
\min_{y} \max_{p(x)} \min_{p(y|x)} \quad & L^{Fuzzy} = \int_x\int_y p(x,y)log d(x,y)dydx \\
\text{s.t.} \quad & H(Y|X) \leq C_0 \\
\quad & KL(p(x)||q(x)) \leq C_1.
\end{split}
\end{align}
The empirical estimation of the reformulation of Fuzzy-ISDA with respect to $U$ and $W$ is as follows
\begin{equation}
R_{ISDA}^{Fuzzy}(Y) =T_2 log (\sum_{i=1}^{N} (\sum_{j=1}^{C} d(x_i, y_j)^{-\frac{1}{T_1}})^{-\frac{T_1}{T_2}}). \label{eq:ISDA-Y-log}
\end{equation}
Let $T_1=m-1$, $T_2=1$, then \eqref{eq:ISDA-Y-log} becomes
\begin{align}
R_{ISDA}^{Fuzzy}(Y)= log (\sum_{i=1}^{N} (\sum_{j=1}^{C} d(x_i, y_j)^{\frac{1}{1-m}})^{1-m}).\label{eq:ISDA-FCM}
\end{align}
Comparing \eqref{eq:ISDA-FCM} with the reformulation function of FCM
\begin{equation}
R_F(Y)=\sum_{i=1}^{N}(\sum_{j=1}^{C}d(x_i,y_j)^{1\over 1-m})^{1-m} \label{eq:FCM-reformulation}
\end{equation}
we can see that the minimization of $R_{F}(Y)$ is equivalent to
the minimization of $R_{ISDA}^{Fuzzy}(Y)$ with respect to $Y$.
Finally, we obtain the following theorem which
\textbf{reveals the relationship between fuzzy clustering and ISDA clustering}.
\begin{theorem} \label{ISDA-FCM}
The fuzzy c-means is a special case of ISDA clustering in which distortion is measured by $log d(x_i,y_j)$
and the parameters $T_1$, $T_2$ are set as $T_1=m-1$, $T_2=1$.
\end{theorem}
Therefore, the fuzzy component $m=T_1+1$ in fuzzy c-means can be interpreted
as the recalibration of temperature in thermodynamic system.
The \autoref{ISDA-FCM} reveals there is a deep relationship between fuzzy c-means
with thermodynamics\cite{rose1998deterministic} and information theory\cite{genewein2015bounded}.
\subsection{Algorithm} \label{algorithm}
In this section, we give out the algorithm to solve \eqref{eq:ISDA-Y}.
Inspired from \cite{hathaway1995optimization}, we use \textit{fminunc's} BFGS\cite{fletcher2013practical} algorithm
in MATLAB Optimization Toolbox\cite{MatlabOTB} to find the minimum of the unconstrained optimization problem.
The corresponding $U$ and $W$ are obtained through \eqref{eq:ISDA-uij} and \eqref{eq:ISDA-wi}.
The initial cluster centers are uniformly sampled from the domain of the training dataset $\mathcal{X}$.
$U$ and $W$ are sampled from the standard uniform distribution
and standardized according to \eqref{eq:constraints-uij} and \eqref{eq:constraints-wi} respectively.
The details of the ISDA clustering algorithm are as follows.
\[
\left[ \begin{array}{l}
Inputs:X, C, T_1, T_2 \\[1ex]
Outputs: U, W, Y
\end{array} \right]
\]
\begin{enumerate}
\item Sample initial $U$ and $W$ from the standard uniform distribution
and normalize them columnwisely to satisfy
\eqref{eq:constraints-uij} and \eqref{eq:constraints-wi}.
Choose $C$ centers uniformly at random from $\mathcal{X}$.
\item Using \textit{fminunc} in MATLAB Optimization Toolbox to get $y_j$
until a given stopping criterion is satisfied.\\
Apply \eqref{eq:ISDA-uij} to compute $u_{ij}$. \\
Apply \eqref{eq:ISDA-wi} to compute $w_i$.
\end{enumerate}
\section{\textbf{Numerical Results}} \label{Results}
In this section, we conduct numerical experiments to show the effectiveness
of our proposed algorithm and analyze its performance.
Specifically, \Cref{metric} shows that ISDA centers are closer to the boundary points
which are used to measure the worst-case scenarios.
\Cref{T2} analyzes how the temperature $T_2$ affects the ISDA results.
\Cref{dist-shift} shows that ISDA performs better compared with Kmeans and FCM
under large future distribution shifts.
\textbf{Dataset}
In this section, we use the following synthetic dataset if not otherwise specified.
The dataset contains three clusters and the data points in each cluster are normally
distributed over a two-dimensional space.
The three means and covariance matrices
are (1, 0), (-0.578,-1), (-0.578, 1) and
$\begin{pmatrix}
1.0 & 0.0 \\
0.0 & 0.3
\end{pmatrix}$,
$\begin{pmatrix}
0.475 & 0.303 \\
0.303 & 0.825
\end{pmatrix}$,
$\begin{pmatrix}
0.475 & -0.303 \\
-0.303 & 0.825
\end{pmatrix}$.
The default number of points in each cluster is 200.
This dataset is called the \textit{default} dataset in this paper.
\textbf{Experiment settings}
We follow the python package scikit\cite{scikit-learn} for the implementation
of Kmeans using the initialization proposed in Kmeans++\cite{arthur2006k} and use
\cite{dias2019fuzzy} for the implementation of FCM.
We use the commonly chosen $m=2$ in fuzzy clustering as the default value in all compared FCM models.
The effect of $T_1$ is analyzed in detail in \cite{rose1998deterministic} and it behaves similarly in ISDA.
Therefore, we set $T_1=1.0$ as the default value in all ISDA models.
For the implementation of ISDA,
we use the squared Euclidean distance as the distance measure and apply the following
stopping criterion,
we use the default optimality tolerance $ \Delta F_{ISDA}(Y) \leq 10^{-6}$ in MATLAB
as the stopping criteria.
\subsection{Boundary Points} \label{metric}
\textbf{M-BoundaryDist}
In this paper, we propose a metric called M-BoundaryDist
as a measure of how well a clustering algorithm performs
with respect to the boundary points.
The boundary points are used to measure the worst-case scenarios.
First, we define the \textit{centroid} of one dataset as the mean of the dataset
averaged over each dimension.
The \textit{boundary points} of the dataset is the points far away from
the centroid of the dataset.
We denote the centroid of the dataset $D$ as $D_{centroid}$ and
the $M$ boundary points as \textit{M-BoundaryPoints}.
Suppose the boundary points assigned to the cluster-$j$ are denoted as $x^{j}_1, \ldots ,x^{j}_{c_j}$,
where $c_j$ is the number of boundary points assigned to the cluster-$j$
and $y_j$ represents the cluster center.
Next, M-BoundaryDist is defined as follows
\begin{align*}
\text{M-BoundaryDist} = \sum_{j=1}^{C} \sum_{m=1}^{c_j} d(x^{m}_j,y_j).
\end{align*}
Clearly, $\sum_{j=1}^{C}c_{j}=M$.
When $M=1$, the boundary point is called MaxBoundaryPoint and the corresponding
distance is called MaxBoundaryDist.
\begin{figure}
\begin{center}
\includegraphics[width=.9\linewidth]{ISDA-MBoundaryPoints.pdf}
\end{center}
\caption{Fuzzy-ISDA ($T_2=0.1$) clustering result of
four synthetic Gaussian datasets with 2,3,4,6 clusters.
The data points are colored under the Fuzzy-ISDA clustering result.}
\label{fig:ISDA-MBoundaryPoints}
\end{figure}
\autoref{fig:ISDA-MBoundaryPoints}(a),(b),(c),(d) shows Fuzzy-ISDA($T_2=0.1$) clustering result
of four synthetic Gaussian datasets with 2,3,4,6 clusters respectively.
The details of the datasets are in Appendix C.
The figure shows the dataset centroids, 10-BoundaryPoints,
true centers and Fuzzy-ISDA clustering centers.
\autoref{fig:ISDA-MBoundaryPoints} shows that Fuzzy-ISDA centers are closer
to the boundary points of the dataset compared with true centers.
\subsection{Effect of $T_2$} \label{T2}
\begin{figure*}
\begin{center}
\includegraphics[width=.9999\linewidth]{boundaryPoints_clusterCenter_diffT2.pdf}
\end{center}
\caption{Results of Fuzzy-ISDA, ISDA, FCM and Kmeans centers of $T_2$ changes from 0.1 to 1.0.
The training dataset are colored under Fuzzy-ISDA clustering results.
$-\sum_{i=1}^{N} w_i log w_i$ measures the entropy of the importance sampling weight of Fuzzy-ISDA.}
\label{fig:diffT2}
\end{figure*}
\begin{table}
\caption{\label{tab:ISDA-T2}
Comparison of MaxBoundaryDist of Fuzzy-ISDA, ISDA, FCM and Kmeans under different $T_2$.
MBD represents MaxBoundaryDist and Entropy represents $-\sum_{i=1}^{N} w_i log w_i$.
``\textit{Fuzzy-}'' means Fuzzy-ISDA. ``\textit{--}'' means not available.}
\centering
\begin{tabular}{ lccccc }
\hline
Model&$T_2$& Fuzzy-Entropy & Fuzzy-MBD & Entropy & MBD \\
\hline
Kmeans&--&--&--&--&8.89\\
FCM &--&--&--&--&8.31\\
ISDA&0.1&4.19&2.97&2.97&3.53\\
ISDA&0.2&4.44&4.03&3.50&3.69\\
ISDA&0.3&4.69&5.26&3.92&3.87\\
ISDA&0.4&5.02&6.29&4.30&4.06\\
ISDA&0.5&5.32&6.94&4.63&4.26\\
ISDA&0.6&5.55&7.38&4.91&4.46\\
ISDA&0.7&5.71&7.70&5.16&4.67\\
ISDA&0.8&5.83&7.95&5.36&4.87\\
ISDA&0.9&5.92&8.15&5.52&5.06\\
ISDA&1.0&5.99&8.31&5.65&5.25\\
ISDA&1.5&6.17&8.75&6.04&6.06\\
ISDA&2.0&6.25&8.80&6.19&6.65\\
\hline
\end{tabular}
\end{table}
\begin{figure}
\begin{center}
\includegraphics[width=.99\linewidth]{Dist-W-T2-eps-converted-to.pdf}
\end{center}
\caption{Comparison of weight distributions under different $T_2$.
The annotation shows the maximum weights $w_i$ under different $T_2$.
The dashed lines zoom in the weight distributions between [0,0.01].}
\label{fig:Dist-W-T2}
\end{figure}
In this section, we analyze the effect of the temperature $T_2$.
\autoref{fig:diffT2} displays the ISDA clustering result under different $T_2$ together with FCM and Kmeans.
\autoref{tab:ISDA-T2} compares MaxBoundaryDist under different $T_2$.
\autoref{fig:Dist-W-T2} shows the weight distributions among different $T_2$.
\autoref{fig:diffT2} compares clustering centers of Fuzzy-ISDA, ISDA, FCM and Kmeans under different $T_2$.
The figure shows that as $T_2$ gets smaller, the trend that Fuzzy-ISDA centers(red points)
moving towards boundary points is very clear.
When $T_2$ changes from 1.0 to 0.1,
the cluster center of green points moves upper left,
the cluster center of orange points moves lower left and
the cluster center of light blue points moves right.
The cluster centers of Fuzzy-ISDA and ISDA are closer to the boundary points
compared with FCM and Kmeans.
Meanwhile, \autoref{tab:ISDA-T2} compares numeric results of MaxBoundaryDist under different $T_2$.
As $T_2$ gets smaller, MaxBoundaryDist becomes smaller in both models.
When $T_2\in [0.1, 1.0]$, MaxBoundaryDist of Fuzzy-ISDA is smaller than that of Kmeans and FCM,
this observation shows that Fuzzy-ISDA performs better than Kmeans and FCM in terms of
distances to MaxBoundaryPoint when $T_2$ is small.
Moreover, \autoref{fig:diffT2}(a) shows that
the centers of Fuzzy-ISDA($T_1=1,T_2=1$) overlap with the centers of FCM($m=2$)
and \autoref{tab:ISDA-T2} shows MaxBoundaryDist of Fuzzy-ISDA($T_1=1,T_2=1$)
is equal to MaxBoundaryDist of FCM($m=2$).
This observation validates the result in \autoref{ISDA-FCM}.
Since the performance of Fuzzy-ISDA is more stable than that of ISDA,
we use Fuzzy-ISDA as the default model in the following experiments.
Then, we analyze how $T_2$ affects the weight distributions in Fuzzy-ISDA.
\autoref{fig:Dist-W-T2} compares the weight distributions under different $T_2$.
The figure shows that smaller $T_2$ leads to more sharply peaked weight distribution
while larger $T_2$ leads to broader weight distribution.
The maximum weight of three models under $T_2=0.3$, $T_2=0.5$, $T_2=0.7$ in Fuzzy-ISDA are
0.121, 0.053 and 0.027 respectively.
This is because as $T_2 \rightarrow 0$, the distribution $KL(w(x_i) \parallel \{\frac{1}{N}\})$
can be very large, in other words, smaller $T_2$ leads to more sharply peaked distribution.
Numeric results in \autoref{tab:ISDA-T2} also show that as $T_2$ gets smaller,
the entropy $-\sum_{i=1}^{N} w_i log w_i$ gets smaller.
\subsection{Distribution Shift} \label{dist-shift}
In previous sections, we validate that the centers of Fuzzy-ISDA are closer to the boundary points
compared with FCM and Kmeans when $T_2$ is small.
In this section, we mimic possible future distribution shifts by generating shifted Gaussians
and show that Fuzzy-ISDA performs better when the distribution shift is large.
The distance between the original and the shifted Gaussian distributions is calculated by the KL divergence.
Suppose there are two multivariate Gaussian distributions $\mathcal{N} (\mu_1, \Sigma_1)$
and $\mathcal{N} (\mu_2, \Sigma_2)$, the KL divergence between the above two distributions
is defined as follows\cite{duchi2007derivations}
\begin{align*}
\medmath{\text{KL-Dist} = \frac{1}{2} \bigl( log \frac{det \Sigma_2}{det \Sigma_1} - n + tr(\Sigma_2^{-1} \Sigma_1)
+ (\mu_2 - \mu_1)^{T} \Sigma_2^{-1} (\mu_2 - \mu_1)\bigr)}
\end{align*}
where $n$ is the number of dimensions of the data.
Two types of distribution shift are considered here, first is the translation of the Gaussian mean
and the second is the scale of the Gaussian covariance matrix.
For mean translation, a shifted distribution is generated from a new mean under the same covariance matrix.
The new means are selected evenly on the circumference of the circle centered at the original mean $(a,b)$
with a radius of $R$. Here, we call $R$ the shifted mean distance
and larger $R$ implies larger distribution shifts.
The polar coordinates of the circle are defined as
$x = R * cos(\phi) + a$ and $y = R * cos(\phi) + b$ where $\phi \in [0, 2\pi]$.
In this experiment, 13 equiangularly spaced points are selected,
therefore three Gaussians in the default dataset lead to 13*13*13=2197 shifted Gaussian distributions in total.
For the covariance scale, the shifted distribution is generated from a scaled covariance matrix
by simply multiplying a scaling factor under the same mean.
These 13 scaling factors ($S$) are chosen from \{0.5,0.6,0.7,0.8,0.9,1.0,1.5,2,2.5,3,3.5,4,4.5\}.
The total KL divergence between the original and the new dataset is calculated by summing
three KL divergence together, which is
$\text{KL-Dist} = \text{KL-Dist}_1 + \text{KL-Dist}_2 + \text{KL-Dist}_3$.
\begin{figure}
\begin{center}
\includegraphics[width=.9999\linewidth]{dist-shift-eps-converted-to.pdf}
\end{center}
\caption{Original and shifted datasets under maximum and minimum KL divergence.
(a) and (b) show maximum and minimum distribution shifts under mean translation
where $R$ represents the shifted distance.
(c) and (d) show maximum and minimum distribution shifts under scaled covariance where
$S1$, $S2$ and $S3$ represent the scaling factors.
(d) shows the same distribution under a different random seed since all three covariance scaling factors are 1.0.
``A-'' represents WithinClusterDist and
``A-diff'' represents the difference between WithinClusterDist between Kmeans and Fuzzy-ISDA($T_2=0.1$).}
\label{fig:dist-shift}
\end{figure}
\begin{figure}
\begin{center}
\includegraphics[width=.9999\linewidth]{dist-shift-scatter-eps-converted-to.pdf}
\end{center}
\caption{Comparison of WithinClusterDist difference against KL divergence
between the original and shifted distributions.
X-axis represents the KL divergence between the original distribution
and the shifted distributions.
Y-axis in (a) represents Kmeans's WithinClusterDist minus Fuzzy-ISDA($T_2=0.1$)'s WithinClusterDist.
Y-axis in (b) represents FCM's WithinClusterDist minus Fuzzy-ISDA($T_2=0.1$)'s WithinClusterDist.
The black dotted horizontal line represents WithinClusterDist difference equals zero.
In the legend, $R$ represents shifted mean distance,
\textit{pos} and \textit{neg}
represent the ratio of positive and negative distance difference respectively.}
\label{fig:dist-shift-scatter}
\end{figure}
In this experiment,
we first get three models (Fuzzy-ISDA($T_2=0.1$), FCM and Kmeans) under the default dataset,
then generating new datasets under the shifted distributions,
next predicting on the shifted dataset and calculating within cluster sum of distances,
denoted as \textbf{WithinClusterDist}.
The metric WithinClusterDist is used to measure
\textit{how well a clustering model performs under a future distribution shift},
which is calculated by summing all distances within each cluster.
Specifically, suppose the new data points in the shifted distribution
assigned to the cluster-$j$ are denoted as ${x^{*}}^{j}_1, \ldots ,{x^{*}}^{j}_{A^{*}_j}$,
where $A^{*}_j$ denotes the number of points in cluster-$j$ and $y_j$
represents the cluster center of the original dataset,
WithinClusterDist is defined as follows,
\begin{align*}
\text{WithinClusterDist} = \sum_{j=1}^{C} \sum_{m=1}^{A^{*}_j}d({x^{*}}^{j}_{m}, y_j).
\end{align*}
We calculated 2197 WithinClusterDist and show the maximum and the minimum ones
with respect to the KL divergence, which are shown in \autoref{fig:dist-shift}.
WithinClusterDist of three clustering models are shown in the title of each subplot.
\autoref{fig:dist-shift}(a) and \autoref{fig:dist-shift}(b) show maximum and minimum distribution shifts under mean translations.
The difference on WithinClusterDist between Fuzzy-ISDA and Kmeans is 531.98 and 264.09 when $R=3.0$ and $R=1.5$ respectively.
\autoref{fig:dist-shift}(c) and \autoref{fig:dist-shift}(d) show maximum and minimum distribution shifts under scaled covariances.
The difference on WithinClusterDist between Fuzzy-ISDA and Kmeans is 267.20 and -523.72 when $S=4.5$ and $S=1.0$ respectively.
\autoref{fig:dist-shift} shows that
Fuzzy-ISDA performs better than FCM and Kmeans when the distribution shift is large as in (a), (b), (c)
while performs worse than FCM and Kmeans when the distribution shift is small in (d).
Furthermore, \autoref{fig:dist-shift-scatter} compares WithinClusterDist difference
between Fuzzy-ISDA and Kmeans(FCM) against KL divergence under different shift translation factor $R$.
Within each subplot, we can see that larger $R$ leads to larger KL divergence,
which implies larger distribution shifts.
Points above zero (black dotted line) mean Fuzzy-ISDA performs better while
points below zero mean Fuzzy-ISDA performs worse.
The ratios of positive and negative WithinClusterDist difference are shown in the legend.
In (a), when $R$ equals \{1.5, 2.0, 2.5, 3.0\}, the ratio that Fuzzy-ISDA performs better than Kmeans
is \{0.40, 0.67, 0.89, 0.98\}.
In (b), when $R$ equals \{1.5, 2.0, 2.5, 3.0\}, the ratio that Fuzzy-ISDA performs better than FCM
is \{0.42, 0.69, 0.90, 0.99\}.
This observation shows that Fuzzy-ISDA performs better
when the distribution shift becomes larger, which validates our assumption that
Fuzzy-ISDA can \textit{do best in the worst case} where the level of ``worse''
is measured by the KL divergence.
\section{Load forecasting} \label{load-forecasting}
\begin{figure}
\begin{center}
\includegraphics[width=.9\linewidth]{month_load-eps-converted-to.pdf}
\end{center}
\caption{Normalized load in 2014 for each month on testing dataset.
X-axis represents the time index.}
\label{fig:month-load}
\end{figure}
In this section, we evaluate the properties of our proposed Fuzzy-ISDA clustering algorithm on a real-world load forecasting problem.
First, we give the outline of the method and then explain it in detail.
Following \cite{fan2006short,dong2017short,liu2018short}, we use a two-stage method.
First, three clustering models(Kmeans, FCM and Fuzzy-ISDA) are applied to separate the training days
into several clusters in an unsupervised manner.
Second, for each time stamp (96 time stamps in total),
a Support Vector Regression\cite{smola2004tutorial} model is used to fit training data in each cluster in a supervised manner.
For each testing day, it is first assigned to a cluster according to the trained clusters,
then for each time stamp, using the corresponding regression model for the cluster and predicting the result.
Specifically, the load forecasting dataset \footnote{\url{http://shumo.neepu.edu.cn/index.php/Home/Zxdt/news/id/3.html}}
we use in this section is from The Ninth Electrician Mathematical Contest in Modeling in China,
which is composed of two parts: historical loads and weather conditions.
Daily load is recorded every 15 minutes, 96 records in total.
Each record time is called a time stamp in this paper.
The weather dataset consists of daily maximum, minimum and mean temperature,
humid and rainfall. The time range is from 20120101 to 20141231.
We use the consecutive 24 months as the training dataset and the following one month as
testing dataset. For example, if the training dataset ranges from 20120201 to 20140131,
the corresponding testing dataset is from 20140201 to 20140228.
There are 12 testing datasets, from January to December.
Take February as an example, the length of the training dataset is 731 and
the length of testing dataset is 28, therefore
the shapes of training and testing load data are [731,96] and [28,96] respectively.
We normalize the training dataset for each time stamp by $\frac{x-x_{max}}{x_{max}-x_{min}}$.
The testing dataset is normalized using the statistics from the training dataset, $x_{max}$ and $x_{min}$.
The normalized monthly load series is shown in \autoref{fig:month-load}.
Next, we explain the features used for clustering and regression models.
Inspired from \cite{fan2006short}, we use the following available features for clustering:
previous day's maximum daily load, last week's average maximum daily load,
average of the previous two days' mean temperature.
Therefore, the shape of training feature for the clustering models is [731,3].
Meanwhile, the regression features are historical loads
from previous \{24,25,26,48,72,96,120,144,168\} hours,
which means previous \{96, 100, 104, 192, 288, 384, 480, 576, 672\}
time stamps. This is because there are 4 records per hour.
As a result, the regression feature is of length 9.
In this paper, we use Support Vector Regression(SVR) as the regression model
where the regularization parameter $SVR_{C}$ and the epsilon $SVR_{\epsilon}$ are set to 1 and 0.1,
which are the default values for the SVR model in sklearn\cite{scikit-learn} package.
Finally, we explain the training routine in detail.
The training days are first separated into $C$ clusters based on the clustering features.
Then, for each cluster, we train 96 SVRs, one for each time stamp.
For each test day in the test dataset, we first predict which cluster it belongs to based on its clustering features.
Next, for each time stamp, we find its corresponding regression model and make the prediction.
Mean squared error (MSE) is used to measure the performance of the model,
\textit{smaller MSE implies more reasonable separation of clusters}.
In this section, we use $T_2=0.1$ as the default value in Fuzzy-ISDA models and
for each model, we use different random seeds and report the mean of 6 runs.
\begin{figure}
\begin{center}
\includegraphics[width=.9\linewidth]{max_weight-eps-converted-to.pdf}
\end{center}
\caption{Fuzzy-ISDA($T_2=0.1$) weights and the corresponding average daily load of each training day.
The model is trained with 3 clusters on February.
The top 1\%(73) weights and their corresponding daily loads are highlighted by red stars.
max{\_}W{\_}num means the selected number of largest weights.}
\label{fig:max-weight}
\end{figure}
\begin{figure}
\begin{center}
\includegraphics[width=.9\linewidth]{month_mse.pdf}
\end{center}
\caption{Comparison of test mean squared error of three clustering models for each month.
X-axis shows the number of clusters $C$.
Y-axis shows the test mean squared error.
Dotted lines represent means and shaded areas represent standard deviations of 6 runs.}
\label{fig:month-mse}
\end{figure}
\begin{table}
\caption{\label{tab:power-test-mse}
Fuzzy-ISDA($T_2=0.1$), FCM and Kmeans' test MSE for 12 months.
The best mean of 6 runs are reported
and the best result in each row is marked in bold.}
\centering
\small
\begin{tabular}{lccc}
\hline
Month & Kmeans & FCM & Fuzzy-ISDA$(T_2=0.1)$ \\
\hline
1 & 0.006490 & 0.006254 & \textbf{0.005157} \\
2 & 0.017547 & 0.016247 & \textbf{0.007210} \\
3 & \textbf{0.003348} & 0.003368 & 0.003398 \\
4 & 0.005413 & 0.005045 & \textbf{0.004742} \\
5 & 0.008841 & 0.009042 & \textbf{0.007786} \\
6 & 0.019318 & 0.019131 & \textbf{0.018890} \\
7 & 0.019871 & \textbf{0.017205} & 0.017815 \\
8 & 0.007177 & 0.007041 & \textbf{0.006707} \\
9 & 0.010046 & 0.010002 & \textbf{0.009837} \\
10 & 0.008517 & 0.008667 & \textbf{0.008115} \\
11 & 0.004919 & 0.005071 & \textbf{0.004880} \\
12 & 0.003682 & \textbf{0.003654} & 0.004059 \\
\hline
\end{tabular}
\end{table}
First, \autoref{fig:max-weight} shows the importance sampling weight $W$ and
the average daily loads of the training dataset.
The training dataset contains 731 days and
the Fuzzy-ISDA($T_2=0.1$) model is trained with $C=3$ clusters on February.
\autoref{fig:max-weight}(a) shows Fuzzy-ISDA weights for each day
and \autoref{fig:max-weight}(b) shows each day's average daily load.
The largest 1\% weights and its corresponding daily loads
are highlighted by red stars.
\autoref{fig:max-weight}(b) shows that daily loads with higher
weights are around the valleys, which are the data points with extreme values.
This is because the clustering features are partly based on a day's previous daily loads.
As a result, the data points around valleys and preceding the valleys
are of higher weigths.
This observation shows that Fuzzy-ISDA clustering algorithm puts higher weights on
the data points with extreme values.
Second, we compare the performance of Kmeans, FCM($m=2$) and Fuzzy-ISDA($T_2=0.1$) on testing dataset.
For each clustering model, \autoref{tab:power-test-mse} reports the lowest test MSE
among the models with different number of clusters, which is $C=2,3,4,5,6,7,8,9,10$.
\autoref{tab:power-test-mse} shows that Fuzzy-ISDA($T_2=0.1$) performs better
on 9(1,2,4,5,6,8,9,10,11) out of 12 months compared with Kmeans and FCM.
\autoref{fig:month-mse} shows the test MSE of these models on 12 months and 9 clusters in detail.
Since the distribution of testing dataset is different from the training dataset,
results in \autoref{fig:month-mse} and \autoref{tab:power-test-mse}
validate the effectiveness of Fuzzy-ISDA under future distribution shifts in most scenarios.
\section{\textbf{Conclusion}} \label{conclusion}
In this paper, we propose an Importance Sampling Deterministic Annealing(ISDA) clustering method,
which combines importance sampling and determinisic annealing to solve the problem of
data distribution deviation clustering problems.
The objective function of ISDA is derived from an information-theoretical viewpoint and
\autoref{ISDA-FCM} reveals that FCM is a special case of ISDA and the fuzzy exponent $m$
can be interpreted as the recalibration of temperature in thermodynamic system.
This observation shows that Fuzzy c-means has a solid theoretical rationale.
Experiment results show that ISDA performs better in worst-case scenarios
compared with Kmeans and FCM on both synthetic and real-world datasets.
Besides, there are many possible applications for ISDA
such as designing a deliver system considering
not only economic benefits but also reachability to remote areas;
designing a recommendation system for users with few ratings and
designing a fair face recognition system taking care of the minority.
Applying ISDA to these problems will be studied in our future work.
\section*{\textbf{Disclosure statement}}
No potential conflict of interest was reported by the authors.
\section*{Acknowledgments}
This work is supported by
the National Natural Science Foundation of China under Grants 61976174.
Lizhen Ji is addtionally supported by the
Nature Science Basis Research Program of Shaanxi (2021JQ-055).
\bibliographystyle{IEEEtran}
| {'timestamp': '2023-02-10T02:05:36', 'yymm': '2302', 'arxiv_id': '2302.04421', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04421'} | arxiv |
\section{Proof of~\cref{thm:constraintsatisfaction}}\label{app:thmconstraintsatisfaction}
Remember that our Idea I in~\cref{sec:algorithm} is mainly designed for guaranteeing safety. As we discussed there, (i) condition 1 in~\eqref{eq:safetycondition1} implies that by choosing action $a$ for state $s$ at step $h$, the instantaneous hard constraint is guaranteed to be satisfied at step $h$; (ii) condition 2 in~\eqref{eq:safetycondition2} implies that all possible next states in $\mathcal{S}_h(s,a)$ (i.e., the next states that could be visited with non-zero probability) must be safe for next step $h+1$. Thus, with conditions 1 and 2 satisfied simultaneously in a backward manner, all step $h'\geq h$ (not even just next step $h+1$) following $(s,a)$ must be safe. Hence, the probability of our~\text{LSVI-NEW}~algorithm being safe depends on the accuracy of the estimated safety value $\tilde{c}_h^k$ in~\eqref{eq:estimatesafetyvalue}.
Moreover, remember that, on the RHS of~\eqref{eq:estimatesafetyvalue}, the first term is the projected safety value of $(s,a,s')$ on $\mathcal{U}_h$, the second term is the projected empirical safety value of $(s,a,s')$ on $\mathcal{U}^{\perp}_h$, and the last term is a UCB bonus for the safety uncertainty. In addition, the second term there relies on the accuracy of the regularized least-square estimator of the projected safety parameter $\boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*)$. Thus, the accuracy of $\tilde{c}_h^k$ further depends on how accurate $\boldsymbol{\gamma}_h^k$ in~\eqref{eq:estimatesafetyparameter} is and how small the safety uncertainty is.
Therefore, we first prove~\cref{lemma:safetyparameteraccuracy} below for quantifying the accuracy of the estimated safety parameter $\boldsymbol{\gamma}_h^k$ in~\eqref{eq:estimatesafetyparameter}.
\begin{lemma}\label{lemma:safetyparameteraccuracy}
\textbf{(Accuracy of the estimated safety parameter)} For any $p\in (0,1)$, with probability $1-p$, we have that, for all steps $h$ of all episode $k$,
\begin{align}\label{eq:safetyparameteraccuracy}
\left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \boldsymbol{\gamma}_h^k \right\rVert_{\boldsymbol{\Lambda}_{h,1}^k} \leq \beta_1,
\end{align}
where $\beta_1 = \sigma \sqrt{d \log\left( \frac{2+\frac{2T D^2}{\lambda}}{p} \right)} + \sqrt{\lambda} L$.
\end{lemma}
\begin{proof}
\textbf{(Proof of~\cref{lemma:safetyparameteraccuracy})} First, according to~\eqref{eq:estimatesafetyparameter}, we have that the estimated safety parameter is equal to
\begin{align}
& \boldsymbol{\gamma}_h^k = \left( \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) + \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \boldsymbol{\psi}^{\text{T}}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \right)^{-1} \nonumber \\
&\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad \cdot \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \left( \hat{c}_h^{\tau} - \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}_{h,h+1}^{\tau}), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 \right) \nonumber \\
& = \left( \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) + \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \boldsymbol{\psi}^{\text{T}}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \right)^{-1} \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \Bigg[ \left\langle \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*), \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \right\rangle + \zeta_h^{\tau} \Bigg]. \nonumber
\end{align}
By opening the bracket $[\cdot]$, and adding and subtracting the term $\lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I})$, we have
\begin{align}
& \boldsymbol{\gamma}_h^k = \left( \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) + \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \boldsymbol{\psi}^{\text{T}}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \right)^{-1} \left( \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) + \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \boldsymbol{\psi}^{\text{T}}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \right) \nonumber \\
&\qquad\qquad\qquad \cdot \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \left( \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) + \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \boldsymbol{\psi}^{\text{T}}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \right)^{-1} \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) \nonumber \\
&\qquad + \left( \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) + \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \boldsymbol{\psi}^{\text{T}}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \right)^{-1} \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \zeta_h^{\tau}. \nonumber
\end{align}
Thus, we have
\begin{align}
& \boldsymbol{\gamma}_h^k = \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \left( \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) + \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \boldsymbol{\psi}^{\text{T}}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \right)^{-1} \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) \nonumber \\
&\qquad + \left( \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) + \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \boldsymbol{\psi}^{\text{T}}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \right)^{-1} \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \zeta_h^{\tau}. \label{eq:safetyparameteraccuracy3}
\end{align}
According to~\eqref{eq:safetyparameteraccuracy3}, the square of the left-hand-side of~\eqref{eq:safetyparameteraccuracy} is equal to
\begin{align}
\Big\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \boldsymbol{\gamma}_h^k \Big\rVert_{\boldsymbol{\Lambda}_{h,1}^k}^2 = \Big[ \left( \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \boldsymbol{\gamma}_h^k \right) \boldsymbol{\Lambda}_{h,1}^k \Big]^{\text{T}} & \left( \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) + \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \boldsymbol{\psi}^{\text{T}}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \right)^{-1} \nonumber \\
& \cdot \left( \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \zeta_h^{\tau} \right). \nonumber
\end{align}
Then, according to the Cauchy-Schwarz inequality, we have
\begin{align}
\Big\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \boldsymbol{\gamma}_h^k \Big\rVert_{\boldsymbol{\Lambda}_{h,1}^k}^2 \leq & \Big\lVert \left( \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \boldsymbol{\gamma}_h^k \right) \boldsymbol{\Lambda}_{h,1}^k \Big\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
& \cdot \left[ \left\lVert \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} + \left\lVert \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \zeta_h^{\tau} \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}\right]. \nonumber
\end{align}
Notice that the smallest eigenvalue of $\boldsymbol{\Lambda}_{h,1}^k$ is $\lambda_{min}(\boldsymbol{\Lambda}_{h,1}^k) = \lambda$. Hence, according to Theorem 1 in~\cite{abbasi2011improved}, we have that, with probability $1-p$ for any $p\in (0,1)$,
\begin{align}
\Big\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \boldsymbol{\gamma}_h^k \Big\rVert_{\boldsymbol{\Lambda}_{h,1}^k}^2 \leq \Big\lVert \left( \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \boldsymbol{\gamma}_h^k \right) \boldsymbol{\Lambda}_{h,1}^k \Big\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \cdot \left[ \sigma \sqrt{d \log\left( \frac{2+\frac{2kD^2}{\lambda}}{p} \right)} + \sqrt{\lambda} L \right]. \label{eq:safetyparameteraccuracy6}
\end{align}
Finally, by rearranging the terms in~\eqref{eq:safetyparameteraccuracy6}, we have
\begin{align}
\Big\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \boldsymbol{\gamma}_h^k \Big\rVert_{\boldsymbol{\Lambda}_{h,1}^k} \leq \sigma \sqrt{d \log\left( \frac{2+\frac{2kD^2}{\lambda}}{p} \right)} + \sqrt{\lambda} L \leq \beta_1. \nonumber
\end{align}
This concludes the proof of~\cref{lemma:safetyparameteraccuracy}.
\end{proof}
\cref{lemma:safetyparameteraccuracy} shows that with high probability, the estimated safety parameter $\boldsymbol{\gamma}_h^k$ is close enough to the projected true safety parameter $\boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*)$. Now, we prove~\cref{thm:constraintsatisfaction} based on our Idea I in~\cref{sec:algorithm}~and~\cref{lemma:safetyparameteraccuracy} above.
\begin{proof}
\textbf{(Proof of~\cref{thm:constraintsatisfaction})} We let $\mathcal{G}_h^{k,\text{safe}}$ denote the set of safe subsubgraphs constructed at step $h$ in episode $k$ by~\text{LSVI-NEW}~using our Idea I. Then, using mathematical induction, we prove that $\mathcal{G}_h^{k,\text{safe}}$ is safe, i.e., any state-action-state triplet $(s_{h'}^k,a_{h'}^k,s_{h'+1}^k)$, where $h\leq h' \leq H$, in $\mathcal{G}_h^{k,\text{safe}}$ satisfies the instantaneous hard constraint~\eqref{eq:defhardconstraint}.
(i) Base case: when $h=H$, according to~\cref{lemma:safetyparameteraccuracy} and the Cauchy-Schwarz inequality, we have
\begin{align}
\Big\langle \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_{H}^k)) \Big\rangle \leq \beta_1 \Big\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_{H}^k)) \Big\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}. \label{eq:constraintsatisfaction1}
\end{align}
From~\eqref{eq:constraintsatisfaction1}, we have
\begin{align}
\Big\langle \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*), \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_{H}^k)) \Big\rangle \leq \Big\langle \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_{H}^k)) \Big\rangle + \beta_1 \Big\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_{H}^k)) \Big\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}. \label{eq:constraintsatisfaction2}
\end{align}
Next, since the left-hand-side of~\eqref{eq:constraintsatisfaction2} is equal to
\begin{align}
\Big\langle \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*), \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_{H}^k)) \Big\rangle & = \Big\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\phi}(s_{H}^k) \Big\rangle - \Big\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s_{H}^k)) \Big\rangle \nonumber \\
& = \Big\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\phi}(s_{H}^k) \Big\rangle - \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s_{H}^k)), \tilde{\bphi}(s_{H}^0) \rangle}{\lVert \boldsymbol{\phi}(s_{H}^0) \rVert_2} \cdot c_{H}^0, \nonumber
\end{align}
we have
\begin{align}
\Big\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\phi}(s_{H}^k) \Big\rangle \leq \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s_{H}^k)), \tilde{\bphi}(s_{H}^0) \rangle}{\lVert \boldsymbol{\phi}(s_{H}^0) \rVert_2} \cdot c_{H}^0 + \Big\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\phi}(s_{H}^k) \Big\rangle + \beta_1 \Big\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_{H}^k)) \Big\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \label{eq:constraintsatisfaction4}.
\end{align}
Notice that, since the parameter $\beta$ used for the estimated safety value $\tilde{c}_{H}^k(s_{H}^k)$ in~\eqref{eq:estimatesafetyvalue} is larger than or equal to $\beta_1$, the right-hand-side of~\eqref{eq:constraintsatisfaction4} is less than or equal to $\tilde{c}_{H}^k(s_{H}^k)$, which is less than or equal to $\bar{c}$ due to our condition 1 in~\eqref{eq:safetycondition1}. Hence, we have $c_{H}(s_{H}^k) \leq \bar{c}$.
(ii) Induction step: we hypothesize that $\mathcal{G}_h^{k,\text{safe}}$ is safe when $h=h_0$. Then, we prove that $\mathcal{G}_h^{k,\text{safe}}$ is safe for $h=h_0-1$ similar to the base case, while condition 2 that we construct in~\eqref{eq:safetycondition2} becomes important here. First, according to~\cref{lemma:safetyparameteraccuracy} and the Cauchy-Schwarz inequality, we have
\begin{align}
\Big\langle \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*) - \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k)) \Big\rangle \leq \beta_1 \Big\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k)) \Big\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}. \label{eq:constraintsatisfaction5}
\end{align}
From~\eqref{eq:constraintsatisfaction5}, we have
\begin{align}
\Big\langle \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*), \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k)) \Big\rangle \leq \Big\langle \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k)) \Big\rangle + \beta_1 \Big\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k)) \Big\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}. \label{eq:constraintsatisfaction6}
\end{align}
Next, since the left-hand-side of~\eqref{eq:constraintsatisfaction6} is equal to
\begin{align}
\Big\langle \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*), \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k)) \Big\rangle & = \Big\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k) \Big\rangle - \Big\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k)) \Big\rangle \nonumber \\
& = \Big\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k) \Big\rangle - \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k)), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0, \nonumber
\end{align}
we have
\begin{align}
& \Big\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k) \Big\rangle \nonumber \\
&\quad \leq \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k)), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 + \Big\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k) \Big\rangle + \beta_1 \Big\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k)) \Big\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \label{eq:constraintsatisfaction8}.
\end{align}
Notice that, the right-hand-side of~\eqref{eq:constraintsatisfaction8} is less than or equal to the estimated safety value $\tilde{c}_h^k(s_h^k,a_h^k,s_{h+1}^k)$ in~\eqref{eq:estimatesafetyvalue}, which is less than or equal to $\bar{c}$ due to our condition 1 in~\eqref{eq:safetycondition1}. Thus, we have $c_h(s_h^k) \leq \bar{c}$. In addition, according to condition 2 that we construct in~\eqref{eq:safetycondition2} and the induction hypothesis, $s_{h+1}$ must also be safe. Hence, $\mathcal{G}_h^{k,\text{safe}}$ is safe.
\end{proof}
\section{Proof of~\cref{lemma:impactfromfuture}}\label{app:lemmaimpactfromfuture}
As we discussed in~\cref{subsec:proofsketch},~\cref{lemma:impactfromfuture} implies that when $k$ increases, the UCB terms $l_1$ and $l_2$ decrease to be closer to $0$, and thus $\alpha_0$ on the right-hand-side of~\eqref{eq:impactfromfuture} gets closer to $0$. Then, $\tilde{f}_h(s,a_0 \vert s_h^*=s)$ on the left-hand-side of~\eqref{eq:impactfromfuture} gets closer to $0$. Notice that $\tilde{f}_h(s,a_0|s_h^*=s)$ represents the gap between the decision of the policy $\pi^k$ used by~\text{LSVI-NEW}~and the optimal decision. In addition, in $\alpha_0$, $l_1$ characterizes the transition uncertainty and $l_2$ characterizes the uncertainty from future steps. Thus, the above implication from~\cref{lemma:impactfromfuture} is consistent with the intuition that as more safety values revealed, we should be able to get closer to the optimal action.
Moreover, when there is no constraint on states, all terms related to the next state $s'$ in $\alpha_0$, e.g., $l_2$, $\bar{c}_{h'}^0$ and $\Delta_{\bphi}(c)$, would be $0$. Then, $\alpha_0$ would be reduced to be in a much simpler form $1 - \frac{\bar{c}-c_h^0-2\beta \lVert \boldsymbol{\phi}(s,a_h^*(s)) \rVert}{\bar{c}-c_h^0}$, which results in a parameter that is same to that used for the UCB bonus term in the case with only unsafe actions~\cite{amani2021safe}. However, due to unsafe states and transitions in our case, the impacts from the future steps $h'>h$ are characterized in $\alpha_0$ here, which results in a different parameter $\epsilon_{h,2}$ in our Idea II and a new parameter $\epsilon_{h,3}$ in our Idea III in~\cref{sec:algorithm}.
Further, as stated in~\cref{lemma:impactfromfuture}, we only need to show there exists such a safe action $a_0 \in \tilde{\mca}_h^k(s)$. Thus, we only need to prove the existence of an estimated safe subgraph, such that this state-action pair $(s,a_0)$ is contained. Hence,~\eqref{eq:impactfromfuture} does not depends on the estimation accuracy of the $Q$-value parameter $w_h^*$.
In this section, we provide the complete proof for~\cref{lemma:impactfromfuture}. Please see~\cref{app:lemmainvariants} for our discussions and proofs on how the new impacts from future steps captured in $\alpha_0$ affect the requirements for choosing the parameters $\epsilon_{h,2}$ and $\epsilon_{h,3}$.
To prove~\cref{lemma:impactfromfuture}, we first provide another new lemma below, which proves to be important. We let
\begin{align}\label{eq:deftruesafetydiff}
\Delta_h(s,a,s') \triangleq \max_{s'' \in \mathcal{S}_h(s,a)} \left\{ c_h(s,a,s'') - c_h(s,a,s') \right\}
\end{align}
denote the maximum difference between the \emph{true} safety value $c_h(s,a,s'')$ of the state-action-state triplet $(s,a,s'')$ for any next state $s''\in\mathcal{S}_h(s,a)$ of the state-action pair $(s,a)$ and the true safety value $c_h(s,a,s')$ of the given state-action-state triplet $(s,a,s')$. Let
\begin{align}\label{eq:defestimatesafetydiff}
\tilde{\Delta}_h^k(s,a,s') \triangleq \max_{s'' \in \mathcal{S}_h(s,a)} \left\{ \tilde{c}_h^k(s,a,s'') - \tilde{c}_h^k(s,a,s') \right\}
\end{align}
denote the maximum difference between the \emph{estimated} safety value $\tilde{c}_h^k(s,a,s'')$ of the state-action-state triplet $(s,a,s'')$ for any next state $s''\in\mathcal{S}_h(s,a)$ of the state-action pair $(s,a)$ and the estimated safety value $\tilde{c}_h^k(s,a,s')$ of the given state-action-state triplet $(s,a,s')$.
\begin{lemma}\label{lemma:relatetrueestimatesafetydiff}
\textbf{(Relating the true and estimated safety differences)} The estimated safety difference $\tilde{\Delta}_h^k(s,a,s')$ can be upper-bounded by the true safety difference $\Delta_h(s,a,s')$ as follows:
\begin{align}\label{eq:relatetrueestimatesafetydiff}
\tilde{\Delta}_h^k(s,a,s') \leq \Delta_h(s,a,s') + 2 \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}},
\end{align}
where $\tilde{s}_{\max}'$ is the maximizer of~\eqref{eq:defestimatesafetydiff}.
\end{lemma}
\begin{proof}
\textbf{(Proof of~\cref{lemma:relatetrueestimatesafetydiff})} We let $s_{\max}'$ denote the maximizer of~\eqref{eq:deftruesafetydiff}. Notice that $s_{\max}'$ could be different from $\tilde{s}_{\max}'$ (the maximizer of~\eqref{eq:defestimatesafetydiff}). First, the true safety difference is equal to
\begin{align}
\Delta_h(s,a,s') & = \max_{s'' \in \mathcal{S}_h(s,a)} \left\{ c_h(s,a,s'') - c_h(s,a,s') \right\} = c_h(s,a,s_{\max}') - c_h(s,a,s') \nonumber \\
& = \left\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\phi}(s,a,s_{\max}') \right\rangle - \left\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\phi}(s,a,s') \right\rangle. \label{eq:relatetrueestimatesafetydiff1}
\end{align}
Next, the estimated safety difference is equal to
\begin{align}
& \tilde{\Delta}_h^k(s,a,s') = \max_{s'' \in \mathcal{S}_h(s,a)} \left\{ \tilde{c}_h^k(s,a,s'') - \tilde{c}_h^k(s,a,s') \right\} \nonumber \\
& = \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 + \left\langle \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rangle + \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
&\qquad - \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s,a,s')), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 - \left\langle \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \right\rangle - \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}. \label{eq:relatetrueestimatesafetydiff2}
\end{align}
Considering the second term, third term, and the last two terms on the right-hand-side of~\eqref{eq:relatetrueestimatesafetydiff2} together, we have
\begin{align}
& \left\langle \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rangle + \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
&\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad - \left\langle \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \right\rangle - \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
& = \left\langle \boldsymbol{\gamma}_h^k - \boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rangle + \left\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rangle + \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
&\qquad\qquad\qquad\qquad + \left\langle \boldsymbol{\gamma}_h^* - \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \right\rangle - \left\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \right\rangle - \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
& \leq \left\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rangle - \left\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \right\rangle + 2 \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}, \label{eq:relatetrueestimatesafetydiff3}
\end{align}
where the inequality is by applying~\cref{lemma:safetyparameteraccuracy} and the Cauchy-Schwarz inequality to the first term in the third line and the first term in the fourth line in~\eqref{eq:relatetrueestimatesafetydiff3} above, and the fact that $\beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \geq 0$. Next, by combining~\eqref{eq:relatetrueestimatesafetydiff2} and~\eqref{eq:relatetrueestimatesafetydiff3}, we have
\begin{align}
& \tilde{\Delta}_h^k(s,a,s') \leq \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 + \left\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rangle \nonumber \\
&\qquad - \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s,a,s')), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 - \left\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \right\rangle + 2 \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
& \leq \Delta_h(s,a,s') + 2 \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}, \nonumber
\end{align}
where the last inequality is because of the definition of the true safety difference $\Delta_h(s,a,s')$ in~\eqref{eq:deftruesafetydiff}.
\end{proof}
\cref{lemma:relatetrueestimatesafetydiff} shows that the estimated safety difference is only larger than the true safety difference by a term, i.e., $2 \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}$, that decreases to $0$ as the number of learning episodes $k$ increases. This is consistent with the intuition that, as $k$ increases, the estimated safety difference $\tilde{\Delta}_h^k(s,a,s')$ should get closer to the true safety difference $\Delta_h(s,a,s')$. Below, based on~\cref{lemma:relatetrueestimatesafetydiff}, we prove~\cref{lemma:impactfromfuture}.
\begin{proof}
\textbf{(Proof of~\cref{lemma:impactfromfuture})} Recall that $\tilde{f}_h(s,a_0|s_h^*=s)$ represents the gap between the decision of the policy $\pi^k$ used by~\text{LSVI-NEW}~and the optimal decision. Thus, now we characterize the relation between the safety values based on the state-action pair $(s,a_0)$ and the optimal state-action pair $(s,a_h^*(s))$. First, according to the definition of estimated safety value in~\eqref{eq:estimatesafetyvalue} and~\cref{ass:starconvexity}, the estimated safety value of any state-action-state triplet $(s,a_0,s'(s,a_0))$ induced by the state-action pair $(s,a_0)$ is equal to
\begin{align}
& \tilde{c}_h^k(s,a_0,s'(s,a_0)) \nonumber \\
& = \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s,a_0,s')), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 + \left\langle \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_0,s')) \right\rangle + \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_0,s')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
& = \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\alpha_{s'}\boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0)+(1-\alpha_{s'})\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s)))), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 \nonumber \\
&\qquad\qquad\qquad\qquad\qquad + \left\langle \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\alpha_{s'}\boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0)+(1-\alpha_{s'})\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s)))) \right\rangle \nonumber \\
&\qquad\qquad\qquad\qquad\qquad + \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\alpha_{s'}\boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0)+(1-\alpha_{s'})\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s)))) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}. \label{eq:pfimpactfromfuture3}
\end{align}
where we drop $(s,a_0)$ from $s'(s,a_0)$ for simplicity. Since $\boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0)) = \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0)$ and $\boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0)) = 0$, from~\eqref{eq:pfimpactfromfuture3}, we have
\begin{align}
& \tilde{c}_h^k(s,a_0,s'(s,a_0)) = \alpha_{s'(s,a_0)} \cdot \frac{\langle \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 \nonumber \\
& + (1-\alpha_{s'(s,a_0)}) \cdot \Bigg[ \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s)))), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 \nonumber \\
&\qquad\qquad + \Big\langle \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}\Big( \mathcal{U}^{\perp}_h,\boldsymbol{\phi}\big(s,a_h^*(s),s'(s,a_h^*(s))\big) \Big) \Big\rangle + \beta \Bigg\lVert \boldsymbol{\psi}\Big( \mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s))) \Big) \Bigg\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \Bigg]. \label{eq:pfimpactfromfuture4}
\end{align}
Let us focus on the terms in the bracket $[\cdot]$ of~\eqref{eq:pfimpactfromfuture4}. Notice that, (i) we have
\begin{align}
& \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s)))), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 + \left\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s)))) \right\rangle \nonumber \\
& = \left\langle \boldsymbol{\gamma}_h^*, \left\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s)))), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \right\rangle \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \right\rangle + \left\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s)))) \right\rangle \nonumber \\
& = \left\langle \boldsymbol{\gamma}_h^*, \boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s))) \right\rangle \nonumber \\
& = c_h(s,a_h^*(s),s'(s,a_h^*(s))) \nonumber \\
& \leq \bar{c} - \Delta_h(s,a_h^*(s),s'(s,a_h^*(s))), \label{eq:pfimpactfromfuture5}
\end{align}
where the inequality is (a) because $(s,a_h^*(s))$ is safe, and hence $c_h(s,a_h^*(s),s') \leq \bar{c}$ for all $s' \in \mathcal{S}_h(s,a_h^*(s))$; (b) according to the definition of the true safety difference in~\eqref{eq:deftruesafetydiff}. (ii) According to~\cref{lemma:safetyparameteraccuracy}, we have
\begin{align}
\left\langle \boldsymbol{\gamma}_h^k-\boldsymbol{\gamma}_h^*, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s)))) \right\rangle \leq \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s)))) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}. \label{eq:pfimpactfromfuture6}
\end{align}
By combining~\eqref{eq:pfimpactfromfuture4},~\eqref{eq:pfimpactfromfuture5} and~\eqref{eq:pfimpactfromfuture6}, we have
\begin{align}
& \tilde{c}_h^k(s,a_0,s'(s,a_0)) \nonumber \\
& \leq \alpha_{s'(s,a_0)} c_h^0 + (1-\alpha_{s'(s,a_0)}) \left[\bar{c} - \Delta_h(s,a_h^*(s),s'(s,a_h^*(s))) + 2\beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s'(s,a_h^*(s)))) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \right]. \label{eq:pfimpactfromfuture7}
\end{align}
Next, since the optimal action $a_h^*(s)$ has not been found by the algorithm, there must exist at least one next-state $s' \in \mathcal{S}_h(s,a)$, such that the instantaneous hard constraint~\eqref{eq:defhardconstraint} is violated. Thus, we must have
\begin{align}\label{eq:pfimpactfromfuture1}
\tilde{c}_h^k(s,a_h^*(s),\tilde{s}_{\max}') > \bar{c}.
\end{align}
Combining~\eqref{eq:pfimpactfromfuture1} and~\cref{lemma:relatetrueestimatesafetydiff}, we have that, for all next state $s'(s,a_h^*(s)) \in \mathcal{S}_h(s,a_h^*(s))$,
\begin{align}
\tilde{c}_h^k(s,a_h^*(s),s'(s,a_h^*(s))) > \bar{c} - \Delta_h(s,a_h^*(s),s'(s,a_h^*(s))) - 2 \beta \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,\tilde{s}_{\max}')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}. \label{eq:pfimpactfromfuture2}
\end{align}
However, as we discussed in our Idea II and Idea III in~\cref{sec:algorithm}, due to possible unsafe transitions and unsafe states in our problem, such a safety value in~\eqref{eq:pfimpactfromfuture2} may not be achieved by the algorithm. This is a critical difference compared with the case without instantaneous constraints or with only unsafe actions. Therefore, in the following, we first quantify the gap between the state-action pair $(s,a_0')$ that achieves the safety value in~\eqref{eq:pfimpactfromfuture2} and the optimal state-action pair $(s,a_h^*(s))$. Then, we quantify the smallest gap between the \emph{safe} state-action pair $(s,a_0)$ and such a possibly unsafe state-action pair $(s,a_0')$. Specifically, for the state-action pair $(s,a_0')$ that takes the safety value in~\eqref{eq:pfimpactfromfuture2}, from~\eqref{eq:pfimpactfromfuture7}, we have
\begin{align}
\alpha_{s'(s,a_0')} \leq 1 - \frac{\bar{c}-c_{h}^0-\Delta_h(s,a_h^*(s),s'(s,a_h^*(s)))-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}}{\bar{c}-c_{h}^0-\Delta_h(s,a_h^*(s),s'(s,a_h^*(s)))+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}}. \label{eq:pfimpactfromfuture8}
\end{align}
Since the right-hand-side of~\eqref{eq:pfimpactfromfuture8} increases with $\Delta_h(s,a_h^*(s),s'(s,a_h^*(s)))$, we have
\begin{align}
\alpha_{s'(s,a_0')} \leq 1 - \frac{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}}. \label{eq:pfimpactfromfuture9}
\end{align}
Note that~\eqref{eq:pfimpactfromfuture9} quantifies the gap between the state-action pair $(s,a_0')$ that achieves the safety value in~\eqref{eq:pfimpactfromfuture2} and the optimal state-action pair $(s,a_h^*(s))$. Next, we quantify the smallest gap between the safe state-action pair $(s,a_0)$ and such a possibly unsafe state-action pair $(s,a_0')$. According to~\eqref{eq:pfimpactfromfuture9}, there must exists a safe action $a_{h',0}'$ for only step $h'$, s.t.,
\begin{align}
\alpha_{s'(s,a_{h',0}')} \leq 1 - \frac{\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{ \bar{c}-c_{h'}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} }. \label{eq:pfimpactfromfuture10}
\end{align}
Then, let $\hat{f}_h(s,a) \triangleq f_h(\boldsymbol{\phi}(s,a,\cdot)-\boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0))$ denote the normalized $\mathcal{L}_2$-distance between the features of the transitions associated with the state-action pair $(s,a)$ and the known safe feature $\boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0)$. According to~\eqref{eq:pfimpactfromfuture10} and~\eqref{eq:lipschitztransition}, there must exists an action $a_0$ that induces at least one safe subsubgraph $G_h^{k,\text{safe}}(s,a_0)$, s.t.,
\begin{align}
\frac{\hat{f}_h(s,a_0)}{\hat{f}_h(s,a_0')} \geq \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)+2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} }. \label{eq:pfimpactfromfuture11}
\end{align}
Finally, by combining~\eqref{eq:pfimpactfromfuture9} and~\eqref{eq:pfimpactfromfuture11}, we have that the left-hand-side of~\eqref{eq:impactfromfuture} can be upper-bounded as follows:
\begin{align}
& \tilde{f}_h(s,a_0 \vert s_h^*=s)
= 1 - \frac{\hat{f}_h(s,a_0 \vert s_h^*=s)}{\hat{f}_h(s,a_0' \vert s_h^*=s)} \cdot \hat{f}_h(s,a_0' \vert s_h^*=s) \nonumber \\
&\qquad\qquad \leq 1 - \frac{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}} \nonumber \\
&\qquad\qquad\qquad\qquad \cdot \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)+2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} }. \nonumber
\end{align}
\end{proof}
\section{Proof of~\cref{lemma:impactfrompast}}\label{app:lemmaimpactfrompast}
As we mentioned in~\cref{subsec:proofsketch}, compared with~\cref{lemma:impactfromfuture}, the main difference in~\cref{lemma:impactfrompast} is that~\cref{lemma:impactfrompast} quantifies the impacts from past steps, i.e., $h' \leq h$. This special new impact results in the bonus term with parameter $\epsilon_{4}$ in our Idea IV in~\cref{sec:algorithm}.
Notice that~\cref{lemma:impactfrompast} implies that when $k$ increases, the UCB terms $l_3$ decreases to be closer to $0$, and thus the right-hand-side~\eqref{eq:impactfrompast} get closer to $0$. Then, $\tilde{f}_h(\hat{s},a_0)$ on the left-hand-side of~\eqref{eq:impactfrompast} gets closer to $0$. Notice that $\tilde{f}_h(\hat{s},a_0)$ represents the gap between the decision of the policy $\pi^k$ used by~\text{LSVI-NEW}~and the optimal decision. In addition, on the right-hand-side of~\eqref{eq:impactfrompast}, $l_3$ characterizes the uncertainty from past steps. Thus, the above implication from~\cref{lemma:impactfrompast} is consistent with the intuition that as more safety values revealed, we should be able to get closer to the optimal action.
In this section, we provide the complete proof for~\cref{lemma:impactfrompast}. Please see~\cref{app:lemmainvariants} for our discussions and proofs on how this special new impact from past steps results in a new bonus term in our Idea IV in~\cref{sec:algorithm} and how it affects the requirements for choosing the parameters $\epsilon_{4}$.
\begin{proof}
According to~\cref{lemma:relatetrueestimatesafetydiff} and~\eqref{eq:pfimpactfromfuture10}, there must exists a safe action $a_{h',0}$ at step $h'\leq h$, s.t.,
\begin{align}
\alpha_{s'(s,a_{h',0})} \leq 1 - \frac{\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{ \bar{c}-c_{h'}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} }. \label{eq:pfimpactfrompast1}
\end{align}
Then, according to~\cref{ass:lipschitzreward}, there must exists a safe action $a_0$ at step $h$, s.t.,
\begin{align}
\alpha_{s'(\hat{s},a_0)} \leq 1 - \frac{\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\delta \left( \bar{c}-c_{h'}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \right) }. \label{eq:pfimpactfrompast2}
\end{align}
Finally, since $\tilde{f}_h(\hat{s},a_0) \leq \alpha_{s'(\hat{s},a_0)}$, we have
\begin{align}
\tilde{f}_h(\hat{s},a_0) \leq 1 - \frac{\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\delta \left( \bar{c}-c_{h'}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \right) }. \nonumber
\end{align}
\end{proof}
\section{Proof of~\cref{lemma:invariants}}\label{app:lemmainvariants}
In this section, we provide the proof of~\cref{lemma:invariants}. The proof replies on~\cref{lemma:impactfromfuture} and~\cref{lemma:impactfrompast}. Recall from~\cref{subsec:proofsketch} that invariant (i) shows that, if the optimal state has been found, the estimated $V$-value must be higher than the optimal $V$-value. From a high-level point of view, if the optimal safe action has also been found, invariant (i) trivially holds. If it has not been found, thanks to our new bonus terms that essentially capture the distance between the estimated safe actions and the optimal action, invariant (i) still holds. Moreover, invariant (ii) shows that, if the optimal state has not been found, the $V$-value of the sub-optimal state in $\tilde{\mcs}_h^k$ is still larger than the optimal $V$-value. This is intuitively because $\tilde{\mcs}_h^k$ only contains safe states with transitions close enough (within a small gap captured by the small constant $\bar{\alpha}_0$) to the optimal transitions, and the distance is captured by our new bonus terms.
\begin{proof}
We prove~\cref{lemma:invariants} by mathematical induction.
(i) Base case: when $h=H+1$, both invariants are trivially true, since $V_h^*(s) = V_h^k(s) = 0$.
(ii) Induction step: we hypothesize that the two invariants are true when $h=h_0$. Then, we prove that they are true for $h=h_0-1$.
(ii-a) Step-a: note that invariant (i) trivially holds for $h=H$ since $V_h^*(s) = V_h^k(s) = r_{H}(s)$. Next, we prove invariant (i) for $h<H$ by considering the following two cases, based on whether the optimal action $a_h^*(s)$ has been \emph{found} in $\tilde{\mca}_h^k(s)$ and \emph{chosen} or not.
(ii-a-1) Case-1: If the optimal action $a_h^*(s)$ has been found in $\tilde{\mca}_h^k(s)$ and chosen by $\pi^k$, i.e., $a_h^k(s) = a_h^*(s)$, based on Section D.4 in~\cite{jia2020model}, we have
\begin{align}
V_h^k(s) = Q_h^k(s,a_h^k(s)) = Q_h^k(s,a_h^*(s)) \geq Q_h^*(s,a_h^*(s)) = V_h^*(s), \label{eq:pfinvariants1}
\end{align}
where the inequality is because of the definition of $V_h^k(s)$ in~\eqref{eq:defanalysisvfunction} and the induction hypothesis of invariant (i) at step $h_0$. Notice that this step is different from the analysis in the case without constraints or with only unsafe actions. Here, the optimal action $a_h^*(s)$ must already be chosen, i.e., it is not enough to simply find that the action is safe. This is because, if the optimal action $a_h^*(s)$ is simply found to be safe while not chosen by the algorithm, a future subsubgraph that is completely different from that of the optimal policy could be visited by $\pi^k$.
(ii-a-2) Case-2: If the optimal action $a_h^*(s)$ has not been \emph{chosen} by $\pi^k$, i.e., $a_h^k(s) \neq a_h^*(s)$, we consider the following two subcases based on whether the optimal action $a_h^*(s)$ has been \emph{found} in $\tilde{\mca}_h^k(s)$ or not.
(ii-a-2-I) Subcase-2-I: If the optimal action $a_h^*(s)$ has been found in $\tilde{\mca}_h^k(s)$ by $\pi^k$, i.e., $a_h^*(s) \in \tilde{\mca}_h^k(s)$, we have
\begin{align}
V_h^k(s) = \max_{a\in \tilde{\mca}_h^k(s)} Q_h^k(s,a) = Q_h^k(s,a_h^*(s) \vert V_{h+1}^k) \geq Q_h^*(s,a_h^*(s) \vert V_{h+1}^k) \geq Q_h^*(s,a_h^*(s)) = V_h^*(s), \label{eq:pfinvariants2}
\end{align}
where the second inequality is because of the definition of $V_h^k(s)$ in~\eqref{eq:defanalysisvfunction} and the induction hypothesis of invariant (ii) at step $h_0$. Recal from~\eqref{eq:optqvalue} that $Q_h^*(s,a) = r_h(s,a) + \langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(s,a) \rangle$, which depends on the $V$-value $V_{h+1}^*$ at next step. Thus, we write such a dependency explicitly for $Q_h^k$ and $Q_h^*$ in~\eqref{eq:pfinvariants2}.
(ii-a-2-II) Subcase-2-II: If the optimal action $a_h^*(s)$ has not been found in $\tilde{\mca}_h^k(s)$ by $\pi^k$, i.e., $a_h^*(s) \notin \tilde{\mca}_h^k(s)$, we consider the following two subsubcases, based on the reason the optimal action $a_h^*(s)$ has not been found in $\tilde{\mca}_h^k(s)$ by $\pi^k$.
(ii-a-2-II-A) Subsubcase-2-II-A: If the optimal action $a_h^*(s)$ has not been found in $\tilde{\mca}_h^k(s)$ by $\pi^k$ because condition 1 in~\eqref{eq:safetycondition1} is violated, we have
\begin{align}
\max_{s'\in \mathcal{S}_h(s,a_h^*(s))} \tilde{c}_h^k(s,a_h^*(s),s') > \bar{c}, \nonumber
\end{align}
Note that $V_h^k(s) = \max_{a\in \tilde{\mca}_h^k(s)} Q_h^k(s,a) \geq Q_h^k(s,a_0)$ and the bonus term $\epsilon_{4} \cdot \max_{s'\in \mathcal{S}_1(s_1,a_1^k)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_1,\boldsymbol{\phi}(s_1,a_1^k,s')) \rVert_{(\boldsymbol{\Lambda}_{1,1}^k)^{-1}}$ in~\eqref{eq:estimateqvalue} is non-negative, we have
\begin{align}
V_h^k(s) & \geq \min\Big\{ r_h(s,a_0) + \left\langle \boldsymbol{w}_h^k, \boldsymbol{\phi}_{V_{h+1}^k}(s,a_0) \right\rangle + \epsilon_{1} \cdot \lVert \boldsymbol{\phi}_{V_{h+1}^k}(s,a_0) \rVert_{(\boldsymbol{\Lambda}_{h,2}^k)^{-1}} \nonumber \\
& + \epsilon_{h,2}\cdot \max_{s'\in \mathcal{S}_h(s,a_0)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_0,s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} + \epsilon_{h,3}\cdot \max_{(s_{h'},a_{h'},s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'},a_{h'},s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}, H \Big\}. \nonumber
\end{align}
Then, according to Section D.4 in~\cite{jia2020model}, we have
\begin{align}
V_h^k(s) & \geq \min\Big\{ r_h(s,a_0) + \left\langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^k}(s,a_0) \right\rangle + (\epsilon_{1}-1) \cdot \lVert \boldsymbol{\phi}_{V_{h+1}^k}(s,a_0) \rVert_{(\boldsymbol{\Lambda}_{h,2}^k)^{-1}} \nonumber \\
& + \epsilon_{h,2}\cdot \max_{s'\in \mathcal{S}_h(s,a_0)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_0,s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} + \epsilon_{h,3}\cdot \max_{(s_{h'},a_{h'},s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'},a_{h'},s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}, H \Big\}. \label{eq:pfinvariants5}
\end{align}
Moreover, according to~\cref{lemma:impactfromfuture}, there must exists an action $a_0 \in \tilde{\mca}_h^k(s)$, s.t.,
\begin{align}
& \tilde{f}_h(s,a_0 \vert s_h^*=s) \leq 1 - \frac{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}} \nonumber \\
&\qquad\qquad\qquad\qquad \cdot \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)+2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} }. \label{eq:pfinvariants6}
\end{align}
By combining~\eqref{eq:pfinvariants5} and~\eqref{eq:pfinvariants6}, and according to~\cref{ass:lipschitzreward} and invariant (ii) at the next step $h_0$, we have
\begin{align}
& V_h^k(s) \geq \min\Bigg\{ \frac{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}} \nonumber \\
&\qquad \cdot \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)+2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} } \cdot \delta \Big[ r_h(s,a_h^*(s)) \nonumber \\
&\quad + \left\langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \right\rangle + (\epsilon_{1}-1) \cdot \lVert \boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \rVert_{(\boldsymbol{\Lambda}_{h,2}^k)^{-1}} + \epsilon_{h,2} \nonumber \\
&\qquad \cdot \max_{s'\in \mathcal{S}_h(s,a_h^*(s))} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} + \epsilon_{h,3}\cdot \max_{(s_{h'}^*,a_{h'}^*,s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Big], H \Bigg\}. \nonumber
\end{align}
Since $\epsilon_{1}$ is set to be equal to $\beta+1$, we have $\epsilon_{1}-1\geq 0$. Thus, $(\epsilon_{1}-1) \cdot \lVert \boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \rVert_{(\boldsymbol{\Lambda}_{h,2}^k)^{-1}} \geq 0$.
Thus, we have
\begin{align}
& V_h^k(s) \geq \min\Bigg\{ \frac{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}} \nonumber \\
&\qquad \cdot \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)+2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} } \cdot \delta \Big[ r_h(s,a_h^*(s)) \nonumber \\
&\quad + \left\langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \right\rangle + \epsilon_{h,2} \cdot \max_{s'\in \mathcal{S}_h(s,a_h^*(s))} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
&\quad + \epsilon_{h,3}\cdot \max_{(s_{h'}^*,a_{h'}^*,s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Big], H \Bigg\}. \label{eq:pfinvariants7}
\end{align}
Thus, to prove that $V_h^k(s) \geq V_h^*(s)$, we need to prove that
\begin{align}
& \delta \Big[ \bar{c}-c_{h}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \Big] \nonumber \\
&\quad \cdot\Big[ \bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Big] \nonumber \\
&\quad \cdot \Big[ Q_h^*(s,a_h^*(s)) + \epsilon_{h,2} \cdot \max_{s'\in \mathcal{S}_h(s,a_h^*(s))} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
&\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad + \epsilon_{h,3}\cdot \max_{(s_{h'}^*,a_{h'}^*,s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Big] \nonumber \\
& \geq \Big[ \bar{c}-c_{h}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \Big] \nonumber \\
&\quad \cdot\Big[ \bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)+2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Big] \cdot Q_h^*(s,a_h^*(s)). \label{eq:pfinvariants8}
\end{align}
By rearranging the terms in~\eqref{eq:pfinvariants8}, we have
\begin{align}
& \delta \Big[ \bar{c}-c_{h}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \Big] \nonumber \\
&\quad \cdot\Big[ \bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Big] \nonumber \\
&\quad \cdot \Big[ \epsilon_{h,2} \cdot \max_{s'\in \mathcal{S}_h(s,a_h^*(s))} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} + \epsilon_{h,3}\cdot \max_{(s_{h'}^*,a_{h'}^*,s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Big] \nonumber \\
& \geq 4\beta \Big[ (\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)) \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
&\qquad\qquad + (\bar{c}-c_{h}^0-\Delta_{\bphi}(c)) \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Big] \cdot Q_h^*(s,a_h^*(s)). \nonumber
\end{align}
Since $Q_h^*(s,a_h^*(s)) \leq H$ for all states $s$ and steps $h$, we have
\begin{align}
& \epsilon_{h,2} \cdot \max_{s'\in \mathcal{S}_h(s,a_h^*(s))} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} + \epsilon_{h,3}\cdot \max_{(s_{h'}^*,a_{h'}^*,s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \nonumber \\
& \geq \frac{4\bettH}{\delta} \Bigg[ \frac{ \bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) }{ \bar{c}-c_{h}^0-\Delta_{\bphi}(c) } \max_{s'} \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
&\qquad\qquad\qquad\qquad\qquad\qquad\qquad + \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Bigg] \nonumber \\
& \cdot \Big[ \bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) - \frac{ \bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) }{ \bar{c}-c_{h}^0-\Delta_{\bphi}(c) } 2\beta \max_{s'} \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
&\qquad\qquad\qquad\qquad\qquad\qquad\qquad - 2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Big]^{-1}. \label{eq:pfinvariants10}
\end{align}
Note that~\eqref{eq:pfinvariants10} indicates that, to have $V_h^k(s) \geq V_h^*(s)$, we need
\begin{align}
\epsilon_{h,2} \geq \frac{4\beta H\frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)}}{\delta(\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) - \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)}\kappa)}
\text{ and }
\epsilon_{h,3} \geq \frac{4\beta H}{\delta(\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) - \kappa)}. \nonumber
\end{align}
This is reason we set the parameters $\epsilon_{h,2}$ and $\epsilon_{h,3}$ in our Idea II and Idea III to be in the form in~\eqref{eq:epss} and ~\eqref{eq:epsss}, respectively.
(ii-a-2-II-B) Subsubcase-2-II-B: If the optimal action $a_h^*(s)$ has not been found in $\tilde{\mca}_h^k(s)$ by $\pi^k$ because (although condition 1 in~\eqref{eq:safetycondition1} is satisfied) condition 2 in~\eqref{eq:safetycondition2} is violated, we have
\begin{align}
\mathcal{S}_{h+1}(s,a_h^*(s)) \not\subseteq \mathcal{S}_{h+1}^{k,\text{safe}}. \nonumber
\end{align}
In this subsubcase, we can leverage the knowledge from the satisfied condition 1 to prove $V_h^k(s) \geq V_h^*(s)$. The proof then could follow the similar inductions in the proof for subsubcase-2-II-A. For completeness, we provide the proof steps below. First, since the bonus term $\epsilon_{4} \cdot \max_{s'\in \mathcal{S}_1(s_1,a_1^k)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_1,\boldsymbol{\phi}(s_1,a_1^k,s')) \rVert_{(\boldsymbol{\Lambda}_{1,1}^k)^{-1}}$ in~\eqref{eq:estimateqvalue} is non-negative, according to Section D.4 in~\cite{jia2020model}, we have
\begin{align}
V_h^k(s) & \geq \min\Big\{ r_h(s,a_0) + \left\langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^k}(s,a_0) \right\rangle + (\epsilon_{1}-1) \cdot \lVert \boldsymbol{\phi}_{V_{h+1}^k}(s,a_0) \rVert_{(\boldsymbol{\Lambda}_{h,2}^k)^{-1}} \nonumber \\
& + \epsilon_{h,2}\cdot \max_{s'\in \mathcal{S}_h(s,a_0)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_0,s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} + \epsilon_{h,3}\cdot \max_{(s_{h'},a_{h'},s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'},a_{h'},s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}, H \Big\}. \nonumber
\end{align}
Next, according to~\cref{ass:lipschitzreward}, invariant (ii) at next step $h+1$ and $(\epsilon_{1}-1) \cdot \lVert \boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \rVert_{(\boldsymbol{\Lambda}_{h,2}^k)^{-1}} \geq 0$, we have
\begin{align}
& V_h^k(s) \geq \min\Bigg\{ \frac{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}} \nonumber \\
&\qquad \cdot \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)-2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)+2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} } \cdot \delta \Big[ r_h(s,a_h^*(s)) \nonumber \\
&\quad + \left\langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \right\rangle + \epsilon_{h,2} \cdot \max_{s'\in \mathcal{S}_h(s,a_h^*(s))} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
&\quad + \epsilon_{h,3}\cdot \max_{(s_{h'}^*,a_{h'}^*,s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Big], H \Bigg\}. \nonumber
\end{align}
Then, to prove $V_h^k(s) \geq V_h^*(s)$, based on~\eqref{eq:pfinvariants8} and since $Q_h^*(s) \leq H$, we have
\begin{align}
& \epsilon_{h,2} \cdot \max_{s'\in \mathcal{S}_h(s,a_h^*(s))} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} + \epsilon_{h,3}\cdot \max_{(s_{h'}^*,a_{h'}^*,s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \nonumber \\
& \geq \frac{4\bettH}{\delta} \Bigg[ \frac{ \bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) }{ \bar{c}-c_{h}^0-\Delta_{\bphi}(c) } \max_{s'} \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
&\qquad\qquad\qquad\qquad\qquad\qquad\qquad + \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Bigg] \nonumber \\
& \cdot \Big[ \bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) - \frac{ \bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) }{ \bar{c}-c_{h}^0-\Delta_{\bphi}(c) } 2\beta \max_{s'} \left\lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \right\rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
&\qquad\qquad\qquad\qquad\qquad\qquad\qquad - 2\beta \max_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*(s),s')\in \mathcal{G}_h(s)\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} \Big]^{-1}, \nonumber
\end{align}
which provides the same requirements on the parameters $\epsilon_{h,2}$ and $\epsilon_{h,3}$.
(ii-b) Step-b: differently from invariant (i) that trivially holds for $h=H$, we need to carefully handle the correctness of invariant (ii) at step $h=H$. Next, we prove invariant (ii) for all steps $h\leqH$ as follows.
First, since the bonus terms $\epsilon_{h,2} \cdot \max_{s'\in \mathcal{S}_h(s,a)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}$ and $\epsilon_{h,3} \cdot \max_{(s_{h'},a_{h'},s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'},a_{h'},s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}$ in~\eqref{eq:estimateqvalue} are non-negative, to prove $V_h^k(\hat{s}) \geq V_h^*(s)$, we need to prove that
\begin{align}
& r_h(\hat{s},\hat{a}) + \langle \boldsymbol{w}_h^k, \boldsymbol{\phi}_{V_{h+1}^k}(\hat{s},\hat{a}) \rangle + \epsilon_{1} \cdot \lVert \boldsymbol{\phi}_{V_{h+1}^k}(\hat{s},\hat{a}) \rVert_{(\boldsymbol{\Lambda}_{h,2}^k)^{-1}} + \epsilon_{4}\cdot \max_{s'\in \mathcal{S}_1(s_1,a_1^k)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_1,\boldsymbol{\phi}(s_1,a_1^k,s')) \rVert_{(\boldsymbol{\Lambda}_{1,1}^k)^{-1}} \nonumber \\
& \geq r_h(s,a_h^*(s)) + \left\langle w_h^*,\boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \right\rangle, \label{eq:pfinvariants16}
\end{align}
for some $\hat{a} \in \tilde{\mca}_h^k(\hat{s})$. To prove~\eqref{eq:pfinvariants16}, we prove
\begin{align}
& \left[ r_h(s,a_h^*(s)) + \left\langle w_h^*,\boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \right\rangle \right] - \left[ r_h(\hat{s},\hat{a}) + \langle \boldsymbol{w}_h^k, \boldsymbol{\phi}_{V_{h+1}^k}(\hat{s},\hat{a}) \rangle \right] \nonumber \\
& \leq \epsilon_{1} \cdot \lVert \boldsymbol{\phi}_{V_{h+1}^k}(\hat{s},\hat{a}) \rVert_{(\boldsymbol{\Lambda}_{h,2}^k)^{-1}} + \epsilon_{4}\cdot \max_{s'\in \mathcal{S}_1(s_1,a_1^k)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_1,\boldsymbol{\phi}(s_1,a_1^k,s')) \rVert_{(\boldsymbol{\Lambda}_{1,1}^k)^{-1}}. \label{eq:pfinvariants17}
\end{align}
By adding and subtracting $r_h(\hat{s},\hat{a}) + \langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(\hat{s},\hat{a}) \rangle$, we decompose the left-hand-side of~\eqref{eq:pfinvariants17} into two parts that are easier for analysis in the following special way,
\begin{align}
& \left[ r_h(s,a_h^*(s)) + \left\langle w_h^*,\boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \right\rangle \right] - \left[ r_h(\hat{s},\hat{a}) + \langle \boldsymbol{w}_h^k, \boldsymbol{\phi}_{V_{h+1}^k}(\hat{s},\hat{a}) \rangle \right] \nonumber \\
& = \left[ r_h(s,a_h^*(s)) + \left\langle w_h^*,\boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \right\rangle \right] - \left[ r_h(\hat{s},\hat{a}) + \langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(\hat{s},\hat{a}) \rangle \right] \nonumber \\
&\qquad\qquad\qquad\qquad\qquad + \left[ r_h(\hat{s},\hat{a}) + \langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(\hat{s},\hat{a}) \rangle \right] - \left[ r_h(\hat{s},\hat{a}) + \langle \boldsymbol{w}_h^k, \boldsymbol{\phi}_{V_{h+1}^k}(\hat{s},\hat{a}) \rangle \right]. \label{eq:pfinvariants18}
\end{align}
Notice that by decomposing in this way, the value in the first two brackets $[\cdot]$ on the right-hand-side of~\eqref{eq:pfinvariants18} characterizes how the policy executed by our~\text{LSVI-NEW}~algorithm learns about and searches towards the optimal safe subgraph. The value in the last two brackets $[\cdot]$ on the right-hand-side of~\eqref{eq:pfinvariants18} characterizes how the policy executed by our~\text{LSVI-NEW}~algorithm learns and estimates the optimal $Q$-value parameter $w_h^*$. Next, according to invariant (ii) at next step $h_0$, the value in the last two brackets $[\cdot]$ on the right-hand-side of~\eqref{eq:pfinvariants18} can be upper-bounded as follows,
\begin{align}
& \left[ r_h(\hat{s},\hat{a}) + \langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(\hat{s},\hat{a}) \rangle \right] - \left[ r_h(\hat{s},\hat{a}) + \langle \boldsymbol{w}_h^k, \boldsymbol{\phi}_{V_{h+1}^k}(\hat{s},\hat{a}) \rangle \right] \nonumber \\
&\qquad \leq \left[ r_h(\hat{s},\hat{a}) + \langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^k}(\hat{s},\hat{a}) \rangle \right] - \left[ r_h(\hat{s},\hat{a}) + \langle \boldsymbol{w}_h^k, \boldsymbol{\phi}_{V_{h+1}^k}(\hat{s},\hat{a}) \rangle \right] \leq \epsilon_{1} \cdot \lVert \boldsymbol{\phi}_{V_{h+1}^k}(\hat{s},\hat{a}) \rVert_{(\boldsymbol{\Lambda}_{h,2}^k)^{-1}}. \nonumber
\end{align}
Then, to prove~\eqref{eq:pfinvariants17}, we need to prove
\begin{align}
& \left[ r_h(s,a_h^*(s)) + \left\langle w_h^*,\boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \right\rangle \right] - \left[ r_h(\hat{s},\hat{a}) + \langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(\hat{s},\hat{a}) \rangle \right] \nonumber \\
&\qquad \leq \epsilon_{4}\cdot \max_{s'\in \mathcal{S}_1(s_1,a_1^k)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_1,\boldsymbol{\phi}(s_1,a_1^k,s')) \rVert_{(\boldsymbol{\Lambda}_{1,1}^k)^{-1}}. \label{eq:pfinvariants20}
\end{align}
Therefore, below we focus on bounding the value in the first two brackets on the right-hand-side of~\eqref{eq:pfinvariants18}. According to the definition of $V_h^k(s)$ and~\cref{lemma:impactfrompast}, there must exist an action $\hat{a} \in \tilde{\mca}_h^k(\hat{s})$ and $1 \leq h' \leq h$, s.t.,
\begin{align}
\tilde{f}_h(\hat{s},\hat{a}) \leq 1 - \frac{\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)-2\beta \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\delta(\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)+2\beta \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}})}. \nonumber
\end{align}
Thus, we have
\begin{align}
& r_h(\hat{s},\hat{a}) + \left\langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(\hat{s},\hat{a}) \right\rangle \nonumber \\
& \geq \frac{\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)-2\beta \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)+2\beta \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}} \left[ r_h(s,a_h^*(s)) + \left\langle w_h^*,\boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \right\rangle \right]. \label{eq:pfinvariants22}
\end{align}
Notice that~\eqref{eq:pfinvariants22} indicates that the left-hand-side of~\eqref{eq:pfinvariants20} can be upper-bounded as follows,
\begin{align}
& \left[ r_h(s,a_h^*(s)) + \left\langle w_h^*,\boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \right\rangle \right] - \left[ r_h(\hat{s},\hat{a}) + \langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(\hat{s},\hat{a}) \rangle \right] \nonumber \\
& \leq \frac{4\beta \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)+2\beta \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}} \left[ r_h(s,a_h^*(s)) + \left\langle w_h^*,\boldsymbol{\phi}_{V_{h+1}^*}(s,a_h^*(s)) \right\rangle \right] \nonumber \\
& \leq \frac{4\beta H \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)+2\beta \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}, \label{eq:pfinvariants23}
\end{align}
where the last inequality is because $V_h^*(s) \leq H$ for all states $s$ and steps $h$.~\eqref{eq:pfinvariants23} indicates that to prove~\eqref{eq:pfinvariants20}, we need
\begin{align}
& (\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)+2\beta \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}) \cdot \epsilon_{4}\cdot \max_{s'\in \mathcal{S}_1(s_1,a_1^k)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_1,\boldsymbol{\phi}(s_1,a_1^k,s')) \rVert_{(\boldsymbol{\Lambda}_{1,1}^k)^{-1}} \nonumber \\
& \geq 4\beta H \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}. \label{eq:pfinvariants24}
\end{align}
Note that~\eqref{eq:pfinvariants24} shows that, to prove $V_h^k(\hat{s}) \geq V_h^*(s)$, we need
\begin{align}\nonumber
\epsilon_{4} \geq \frac{4\beta H}{\bar{c}-c_{1}^0-\Delta_{\bphi}(c)}.
\end{align}
This is the reason we set the parameter $\epsilon_{4}$ in our Idea IV to be in the form in~\eqref{eq:epssss}.
\end{proof}
\section{Proof of~\cref{thm:regret}}\label{app:thmregret}
As we mentioned in~\cref{subsec:proofsketch}, because of the new challenges from the instantaneous hard constraint~\eqref{eq:defhardconstraint} and our novel ideas in the algorithm design, there are several new difficulties in the regret analysis, which is shown in this section. The key ones are: (I) Differently from the unconstrained setting or the setting with only unsafe actions, in our case, the states that could be visited with non-zero probability by different policies could be completely different at each step $h$. Hence, the commonly-used invariant on $V$-values, i.e., $V_h^k(s) \geq V_h^*(s)$ for all $h$ and $s$, that relies on the ergodicity property no longer holds in our case. This difficulty is resolved by~\cref{lemma:invariants}. (II) How to quantify the impacts when looking ahead and peeking backward. This difficulty is resolved by~\cref{lemma:impactfromfuture} and~\cref{lemma:impactfrompast}.
\begin{proof}
First, for the convenience of the reader, we restate our new construction for the $V$-values functions of different policies. We let $\mathcal{S}_h^*$ denote the state set at step $h$ in the optimal safe subgraph. Let $\mathcal{S}_h^k$ denote the state set at step $h$ in the subgraph followed by policy $\pi^k$ of~\text{LSVI-NEW}~in episode $k$. Moreover, we let $\tilde{f}_h(s,a) \triangleq f_h(\boldsymbol{\phi}(s,a,\cdot)-\boldsymbol{\phi}(s_h^*,a_h^*,\cdot))$ denote the gap between the transitions associated with the state-action pair $(s,a)$ and the optimal transitions. Let $\tilde{\mca}_h^k(s) \triangleq \{a\in\mathcal{A}_h^{k,\text{safe}}(s): \tilde{f}_h(s,a) \leq \bar{\alpha}_0\} \cup \{a_h^k(s)\}$ denote the union of the safe actions with transitions close to the optimal transitions and the action chosen by $\pi^k$ for a safe state $s$ at step $h$, where
\begin{align}
& \bar{\alpha}_0 = \max\Bigg\{ 1 - \frac{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)-2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)+2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}} \nonumber \\
&\qquad\qquad\qquad\qquad\qquad\qquad\qquad \cdot \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)-2\beta \max\limits_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*),s'\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)+2\beta \max\limits_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*),s'\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}, \nonumber \\
&\qquad\qquad\qquad\qquad 1 - \frac{\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)-2\beta \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}}{\delta(\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)+2\beta \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}})} \Bigg\} \nonumber
\end{align}
is a small value that decreases to be closer to $0$ when the number of learning episodes $k$ increases. Let $\tilde{\mcs}_h^k \triangleq \{s\in\mathcal{S}_h^{k,\text{safe}}: \exists a\in\mathcal{A}_h^{k,\text{safe}}(s), \text{ s.t., } \tilde{f}_h(s,a) \leq \bar{\alpha}_0\}
\cup \mathcal{S}_h^k$ denote the union of the safe states with transitions close to the optimal transitions and the state set at step $h$ in the subgraph followed by policy $\pi^k$ of~\text{LSVI-NEW}~in episode $k$. Next, we define the $V$-value functions of the optimal policy, estimated policy and policy $\pi^{k}$ to be
\begin{align}
& V_h^*(s) \triangleq Q_h^*(s,a_h^*(s)), \forall s \in \mathcal{S}_h^*, \label{eq:defoptvfunctionn} \\
& V_h^k(s) \triangleq \max_{a\in \tilde{\mca}_h^k(s)} Q_h^k(s,a), \forall s\in \tilde{\mcs}_h^k, \label{eq:defanalysisvfunctionn} \\
& V_h^{\pi^k}(s) \triangleq Q_h^{\pi^k}(s,a_h^k(s)), \forall s\in \mathcal{S}_h^k, \label{eq:defalgvfunctionn}
\end{align}
respectively. Then, the regret $R^{\text{LSVI-NEW}}$ can be decomposed into two parts as follows:
\begin{align}
R^{\text{LSVI-NEW}} = \sum\limits_{k=1}^{K} \left\{ V_1^*(s_1) - V_1^{\pi^k}(s_1) \right\} = \sum\limits_{k=1}^{K} \left\{ \Big[ V_1^*(s_1) - V_1^{k}(s_1) \Big] + \Big[ V_1^k(s_1) - V_1^{\pi^k}(s_1) \Big] \right\}. \label{eq:regretdecomposee}
\end{align}
To upper-bound the regret, we prove that, with high probability, (i) the value in the first bracket on the right-hand-side of~\eqref{eq:regretdecompose} is non-positive; (ii) the value in the second bracket on the right-hand-side of~\eqref{eq:regretdecomposee} can be upper-bounded. Note that, according to~\cref{lemma:invariants}, we have the value in the first bracket on the right-hand-side of~\eqref{eq:regretdecomposee} must be non-positive, i.e., $V_1^*(s_1) - V_1^{k}(s_1) \leq 0$ for all episodes $k$. The value in the second bracket on the right-hand-side of~\eqref{eq:regretdecomposee} can be upper-bounded by slightly modifying existing techniques for the linear mixture MDP. Specifically, according to the Azuma-Hoeffding inequality, we have
\begin{align}
& \sum\limits_{k=1}^{K} \left\{ V_1^k(s_1) - V_1^{\pi^k}(s_1) \right\} \leq \sum\limits_{k=1}^{K} \sum\limits_{h=1}^{H} \Big\{ \epsilon_{1} \cdot \lVert \boldsymbol{\phi}_{V_{h+1}^k}(s,a) \rVert_{(\boldsymbol{\Lambda}_{h,2}^k)^{-1}} + \epsilon_{h,2}\cdot \max_{s'\in \mathcal{S}_h(s,a)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
& + \epsilon_{h,3}\cdot \max_{(s_{h'},a_{h'},s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'},a_{h'},s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} + \epsilon_{4}\cdot \max_{s'\in \mathcal{S}_1(s_1,a_1^k)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_1,\boldsymbol{\phi}(s_1,a_1^k,s')) \rVert_{(\boldsymbol{\Lambda}_{1,1}^k)^{-1}} \Big\} \nonumber \\
& + 2H \sqrt{\chK \log\left(\frac{2d\chK}{p}\right)} + \chK' \nonumber \\
& \leq \sum\limits_{k=1}^{K} \sum\limits_{h=1}^{H} \Bigg\{ \beta+1 + \frac{\frac{4\beta H}{\tilde{\delta}} \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)}}{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) - \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)}\kappa} + \frac{4\beta H / \tilde{\delta}}{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) - \kappa} + \frac{4\beta H}{\bar{c}-c_{1}^0-\Delta_{\bphi}(c)} \Bigg\} \nonumber \\
&\qquad\qquad\qquad \cdot \sqrt{2d\chK \log\left(1+\chK\right)} + 2H \sqrt{\chK \log\left(\frac{2d\chK}{p}\right)} + \chK' + \frac{D}{\lambda_{0}}\left(\frac{K}{K'}-1\right), \nonumber
\end{align}
where the last inequality is because of Lemma D.2 in~\cite{jin2020provably} and Lemma 1 in~\cite{amani2019linear}.
\end{proof}
\section{Proof of~\cref{thm:lowerbound}}\label{app:thmlowerbound}
In this section, we provide the proof for~\cref{thm:lowerbound}. The proof is based on the lower bound in the unconstrained horizon-free linear mixture MDP setting~\cite{zhou2022computationally} and the lower bound in the constrained bandit setting~\cite{pacchiano2021stochastic}. Note that these existing lower bounds do not show the dependency on the episode length $H$ and the safety parameter $\Delta_{\bphi}(c)$ that are captured in our lower bound.
\begin{proof}
Notice that in~\cref{thm:lowerbound}, we assume $K \geq 32\underline{R}$. Under this assumption, Lemma 25 in~\cite{zhou2021nearly} indicates that in the linear bandit problems that are parameterized by the vector $\mu^*=\left\{-\frac{\sqrt{\delta/K}}{4\sqrt{2}},\frac{\sqrt{\delta/K}}{4\sqrt{2}}\right\}^{d}$ and with the action space $\mathcal{A}=\{-1,1\}^d$ and Bernoulli distributed reward $r \sim \mathcal{B}(\delta+\langle\mu^*,a\rangle)$, where $0<\delta \leq \frac{1}{3}$, the regret of any algorithm is lower-bounded by $\frac{dH\sqrt{K}}{8\sqrt{2}}$. Next, consider an instance with three states $\{s_1,s_2,s_3\}$, one action $a$, and the reward $r_h(s_1,a)=r_h(s_2,a)=0$ and $r_h(s_3,a)=1$ for each $h$. Then, by using the same transition probability in Section C.3 of~\cite{zhou2022computationally}, we have that the regret of any algorithm for linear mixture MDPs with $H$ steps in each episode is lower-bounded by $\frac{dH\sqrt{K}}{16\sqrt{2}}$. Since the linear mixture MDP with instantaneous hard constraints subsumes (when the cost $c_h(s,a,s')=0$ for all state-action-state triplets) the unconstrained case, $\frac{dH\sqrt{K}}{16\sqrt{2}}$ is also a lower bound of the regret in our case.
Further, to quantify the impact of the safety term $\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c)$ on the lower bound, in the following, we focus on showing that, when the instantaneous hard constraint with threshold $\bar{c}$ is considered, the regret is at least $\frac{H}{24(\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c))^2}$. We prove this by contradiction. Assume there exists a safe algorithm that can achieve a regret $R_0 < \frac{H}{24(\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c))^2}$ for any instance of the problem that we consider. Let us consider the following transition probability function: At step $h=1$, the transition probability is equal to $\mathbb{P}_1(s_2(i) \vert s_1,a(i)) = 1$ for all $i$, and $\mathbb{P}_1(s_2(i) \vert s_1,a(j)) = 0$ for all $i\neq j$; at step $h>1$, the transition probability is equal to $\mathbb{P}_h(s_{h+1}(i) \vert s_h(i),a(j))=1$ for all $i$ and $j$, and $\mathbb{P}_h(s_{h+1}(j) \vert s_h(i),a(l))=0$ for all $i \neq j$ and all $l$, where $i$, $j$ and $l$ are the indices of the states and actions.
Now, let us consider an instance where the safety value function is as follows: at step $h=1$, the safety value is equal to $c_1(s_1,a(1),s') = \bar{c}_1^0$, $c_1(s_1,a(2),s') = 2\bar{c}-\bar{c}_1^0$, $c_1(s_1,a(3),s') = \bar{c}_1^0$, $c_1(s_1,a(4),s') = 2\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c)$ and $c_1(s_1,a(i),s') = 2\bar{c}-\bar{c}_1^0$ for all $i>4$. Notice that $a(1)$ and $a(3)$ are safe actions, while $a(2)$, $a(4)$ and other actions are unsafe for state $s_1$ at step $h=1$. Moreover, at step $h>1$, for all $i$, the safety value is equal to $c_h(s_h(1),a(i),s') = \bar{c}_1^0$, $c_1(s_h(2),a(i),s') = 2\bar{c}-\bar{c}_1^0$, $c_1(s_h(3),a(i),s') = \bar{c}_1^0$, $c_1(s_h(4),a(i),s') = 2\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c)$ and $c_1(s_h(j),a(i),s') = 2\bar{c}-\bar{c}_1^0$ for all $j>4$. Notice that $s_h(1)$ and $s_h(3)$ are safe states, while $s_h(2)$, $s_h(4)$ and other states are unsafe at each step $h>1$. The reward value function is as follows: at step $h=1$, the reward is equal to $r_1(s_1,a(1)) = \frac{1}{8}$, $r_1(s_1,a(2)) = 1$, $r_1(s_1,a(3)) = 0$ and $r_1(s_1,a(i)) = \frac{1}{2}$ for all $i>3$; at step $h>1$, for all $i$, the reward is equal to $r_h(s_h(1),a(i)) = \frac{1}{8}$, $r_1(s_h(2),a(i)) = 1$, $r_1(s_h(3),a(i)) = 0$ and $r_1(s_h(j),a(i)) = \frac{1}{2}$ for all $j>3$. Since for any algorithm that chooses action $a(1)$ at step $h=1$ less than half of the total episodes with probability $p_1$, the regret is at least $\frac{p_1\chK}{2}$. Moreover, since the regret of assumed algorithm is $R_0 < \frac{H}{24(\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c))^2}$, we have that, for this algorithm,
\begin{align}
p_1 \leq \frac{1}{12K(\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c))^2}. \nonumber
\end{align}
Next, let us consider another instance where the safety value function is as follows: at step $h=1$, the safety value is equal to $c_1(s_1,a(1),s') = \bar{c}_1^0$, $c_1(s_1,a(2),s') = 2\bar{c}-\bar{c}_1^0$, $c_1(s_1,a(3),s') = \bar{c}_1^0$, $c_1(s_1,a(4),s') = \bar{c}_1^0+\Delta_{\bphi}(c)$ and $c_1(s_1,a(i),s') = 2\bar{c}-\bar{c}_1^0$ for all $i>4$. Notice that $a(1)$, $a(3)$ and $a(4)$ are safe actions, while $a(2)$ and other actions are unsafe for state $s_1$ at step $h=1$. Moreover, at step $h>1$, for all $i$, the safety value is equal to $c_h(s_h(1),a(i),s') = \bar{c}_1^0$, $c_1(s_h(2),a(i),s') = 2\bar{c}-\bar{c}_1^0$, $c_1(s_h(3),a(i),s') = \bar{c}_1^0$, $c_1(s_h(4),a(i),s') = \bar{c}_1^0+\Delta_{\bphi}(c)$ and $c_1(s_h(j),a(i),s') = 2\bar{c}-\bar{c}_1^0$ for all $j>4$. Notice that $s_h(1)$, $s_h(3)$ and $s_h(4)$ are safe states, while $s_h(2)$ and other states are unsafe at each step $h>1$. The reward value function is as follows: at step $h=1$, the reward is equal to $r_1(s_1,a(1)) = \frac{1}{8}$, $r_1(s_1,a(2)) = 1$, $r_1(s_1,a(3)) = 0$ and $r_1(s_1,a(i)) = \frac{1}{2}$ for all $i>3$; at step $h>1$, the reward is equal to $r_h(s_h(1),a(i)) = \frac{1}{8}$, $r_1(s_h(2),a(i)) = 1$, $r_1(s_h(3),a(i)) = 0$ and $r_1(s_h(j),a(i)) = \frac{1}{2}$ for all $j>3$. Since for any algorithm that chooses action $a(1)$ at step $h=1$ more than half of the total episodes with probability $p_2$, the regret is at least $\frac{3p_2\chK}{16}$. Moreover, since the regret of the assumed algorithm is $R_0 < \frac{H}{24(\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c))^2}$, we have, for this algorithm,
\begin{align}
p_2 \leq \frac{2}{9K(\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c))^2}. \nonumber
\end{align}
Notice that the main difference between this two instances is change of the safety of action $a(4)$ for state $s_1$ at step $h=1$. Specifically, in instance 1, action $a(4)$ is unsafe, while in instance 2 it becomes safe and incurs the largest reward. Thus, we can quantify the total variation distance between the statistical distributions between these two instances, which can further be upper-bounded by the Kullback–Leibler (KL) divergence. More specifically, according to Lemma 1 in~\cite{kaufmann2016complexity} and Lemma 15.1 in~\cite{lattimore2020bandit}, we have that this KL divergence is at least $q(4)\cdot D_{\text{KL}}\left( \mathcal{N}(2\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c), \boldsymbol{I}) \Vert \mathcal{N}(\bar{c}_1^0+\Delta_{\bphi}(c), \boldsymbol{I}) \right) = 2q(4)(\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c))^2 \geq \frac{1}{2}$, where $q(4)$ is the expected number of times of choosing action $a(4)$ at step $h=1$ in instance 1. Thus, we have
\begin{align}
q(4) \geq \frac{1}{4(\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c))^2} \nonumber
\end{align}
For the algorithm choosing action $a(4)$ for at least $q(4)$ times in average for instance 1, the regret is at least $q(4)\cdot \frac{1}{2} \cdot \frac{1}{3} = \frac{1}{6}q(4)$. This contradicts with our assumption that the regret of this algorithm is $R_0 < \frac{H}{24(\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c))^2}$.
\end{proof}
\section{Introduction}\label{sec:introduction}
Reinforcement learning (RL) has been extensively studied to improve the learning performance in sequential decision-making problems for machine learning applications. These decision making problems are usually modelled as a Markov Decision Process (MDP), where an online learner interacts with an unknown environment sequentially to achieve a large expected cumulative reward. Many RL algorithms that do not consider any constraint (and hence are allowed to freely explore any state-action pair) with sample-complexity guarantees have been proposed in the literature~\cite{azar2017minimax,jin2018q,agarwal2019reinforcement,jin2020provably,jia2020model,zhou2021provably,he2022near}. Moreover, existing ``safe'' RL algorithms are usually designed under the constraint that requires expected cumulative, i.e., not \emph{instantaneous}, costs over all steps to be bounded~\cite{yang2019projection,brantley2020constrained,ding2021provably,paternain2022safe} (please see more related work in~\cref{subsec:relatedwork}). Thus, practical scenarios where unsafe states and actions must be avoided at \emph{each} time/step are not captured.
Instantaneous hard constraints are important in many practical scenarios, and any unsafe states and actions (and transitions) should be avoided at each step. In safety-critical systems, violating such a constraint could result in catastrophic consequences. For example, in power systems, it is well-known that the states of blackouts (e.g., due to violating the power-grid operation constraints) must be avoided~\cite{amani2019linear,shi2022stability}. In autonomous driving, improper operations that could cause dangerous states, e.g., crashing, must be avoided~\cite{amani2021safe,vamvoudakis2021handbook}. In robotics, even a single bad action could damage the machines and any undesirable state of failure must be avoided~\cite{turchetta2016safe,wachi2018safe}.
Recently, instantaneous hard constraints have been studied in theoretical machine learning. Specifically,~\cite{amani2019linear} and~\cite{pacchiano2021stochastic} studied bandits with linear instantaneous constraints that require a linear safety value of the chosen action to be bounded at each step. However, it is well-known that bandits are only a very special case of MDP.~\cite{amani2021safe} studied safe linear MDP with linear instantaneous hard constraints. However, they still assume that only the actions could be unsafe, and hence unsafe states (and transitions) are still not considered. Intuitively, when there are only unsafe actions, any action will always lead to a state in any future step that is safe. Then, we could consider the safety at each step separately. Indeed, the existing idea in such a setting is to estimate the safe actions at each step separately, \emph{without the need to consider the impact from other steps}. In sharp contrast, when one allows for the more practical scenario when unsafe states can also exist (as done in this paper), even though an action is safe at a step, it may cause unsafe states in subsequent steps. As a result, at each step, the impact from other steps must be carefully handled. This results in significantly new challenges in both the algorithm design and regret analysis.
Therefore, this paper studies a fundamentally important and open question: \emph{in MDPs with unsafe states and actions (and transitions) under instantaneous hard constraints, is it possible to design an RL algorithm that not only still achieves a strong sample-complexity guarantee, but is also safe (i.e., satisfies the instantaneous hard constraint) at each step?}
\subsection{Our Contributions}\label{subsec:contribution}
\emph{In this paper, we make the first effort to address this question.} Specifically, we study episodic MDPs with unsafe states and actions under instantaneous hard constraints and the linear mixture model. We develop an RL algorithm, called Least-Square Value Iteration by lookiNg ahEad and peeking backWard (\text{LSVI-NEW}).~\text{LSVI-NEW}~not only achieves a regret $\tilde{O}(\frac{dH^3 \sqrt{dK}}{\Delta_c})$ that tightly matches the state-of-the-art regret in the \emph{unsafe-action} setting and nearly matches that in the \emph{unconstrained} setting, but is also safe at each step, where $d$ is the feature-mapping dimension, $K$ is the number of episodes, $H$ is the number of steps in each episode, and $\Delta_c$ (which is defined in~\cref{thm:regret}) is a safety-related parameter. We also provide a lower bound $\tilde{\Omega}(\max\{dH \sqrt{K}, \frac{H}{\Delta_c^2}\})$, which indicates that the dependency on $\Delta_c$ is necessary.
As discussed before, in our case, the coupling between steps need to be carefully handled. To resolve the new challenges due to this coupling, our algorithm in~\cref{sec:algorithm} involves four important novel ideas. \textbf{Idea I:} \emph{constructing safe subgraphs (defined in~\cref{subsec:performancemetric}).} Remember that an action that is safe at a step could cause unsafe future states. To resolve this problem, we restrict~\text{LSVI-NEW}~to be inside safe subgraphs of the state-transition diagram. These safe subgraphs are constructed by estimating safe state-sets at each step in a backward manner, such that the chosen action could only result in future states that are estimated to be safe. \textbf{Idea II:} \emph{encouraging to explore the transitions with higher uncertainty.} Due to our first idea for safety, the choices of actions become restricted. In order to still achieve a sublinear regret, the algorithm needs to be more optimistic in the learning process. To resolve this new pessimism-optimism dilemma, we construct a new bonus term in the estimated $Q$-value function to encourage~\text{LSVI-NEW}~to explore transitions with higher uncertainty. \textbf{Idea III:} \emph{encouraging to explore the future subsubgraphs with higher uncertainty.} Idea-II by itself is not sufficient, since each step could be affected by the safety-learning process at future steps. For example, even though the safety function at step $h$ may be precisely known, a bad learning quality at a future step $h'>h$ could make the algorithm still not be able to really execute the optimal safe action at step $h$. To resolve this difficulty, we construct another new bonus term to encourage~\text{LSVI-NEW}~to explore future subsubgraphs with higher uncertainty. \textbf{Idea IV:} \emph{encouraging to explore the past subsubgraphs with higher uncertainty.} Similar to that in Idea III, since each step $h$ is also affected by past steps $h'<h$, we construct a new bonus term to encourage~\text{LSVI-NEW}~to explore past subsubgraphs with higher uncertainty.
To show a sublinear regret of~\text{LSVI-NEW}, our regret analysis involves novel ideas for solving the following difficulties. (Please see~\cref{sec:finalresults} for details.) \textbf{Difficulty I:} \emph{the commonly-used invariant in RL relying on the ergodicity property does not hold any more.} Due to our special design of the safe subgraphs, the optimal policy and~\text{LSVI-NEW}~may visit different sets of states at each step. Thus, the classical invariant that shows the estimated $V$-value is larger than the optimal $V$-value at any state does not hold any more. To resolve this problem, we construct the value functions in a special way so that other useful interesting invariants still hold. \textbf{Difficulty II:} \emph{how to quantify the impact from other steps?} Our idea is to consider the future and past impacts separately. Then, we could quantify such impacts based on our construction of the safe subgraphs. This way of quantification precisely implies the requirements for the parameters of the new bonus terms that we construct for~\text{LSVI-NEW}.
\subsection{Related Work}\label{subsec:relatedwork}
We provide more related work in this section. \emph{To the best of our knowledge, none of existing work has addressed the fundamental open problem that we consider in this paper.}
\textbf{RL with constraints:} First, constraints that require some expected cumulative costs over all steps to be bounded have been widely studied in safe RL~\cite{wu2016conservative,achiam2017constrained,tessler2018reward,yang2019projection,efroni2020exploration,singh2020learning,ding2020natural,brantley2020constrained,kalagarla2021sample,liu2021learning,ding2021provably,wei2021provably,xu2021crpo,paternain2022safe,bai2022achieving,ghosh2022provably}. Second, many other work, e.g.,~\cite{caramanis2014efficient} and~\cite{wu2018budget}, studied budget constraints that will halt the learning process whenever the budget has run out of.
\textbf{Instantaneous hard constraints with only unsafe actions:} First,~\cite{amani2019linear,pacchiano2021stochastic} studied safe linear bandits which require a linear safety value of the chosen action to be bounded at each step. Second,~\cite{amani2021safe} studied linear MDPs with instantaneous hard constraints, while assuming only actions could be unsafe.
\textbf{Instantaneous hard constraints under deterministic transitions:}~\cite{turchetta2016safe} and~\cite{wachi2018safe} studied instantaneous hard constraints with unsafe states, while assuming the state transitions are deterministic, i.e., by choosing an action, a state will be transferred to a known single deterministic state.
\section{Problem Formulation}\label{sec:problemformulation}
In this section, we provide the problem formulation and introduce the performance metric.
\subsection{Episodic MDP Under Instantaneous Hard Constraints and the Linear Mixture Model}\label{subsec:emdplinearmixturemodel}
We study the constrained episodic MDP, denoted by $\mathcal{M} = (\mathcal{S},\mathcal{A},H,\mathbb{P},r,c)$, in an online setting with $K$ episodes, where $\mathcal{S}$ and $\mathcal{A}$ denote the state and action spaces, respectively; $H$ denotes the number of steps in each episode; $\mathbb{P}=\{\mathbb{P}_h\}_{h=1}^{H}$, $r=\{r_h\}_{h=1}^{H}$ and $c=\{c_h\}_{h=1}^{H}$ denote the transition probability function, reward function and safety function, respectively. Let $T=\chK$ denote the total number of steps. The learner interacts with the unknown environment as follows. At each step $h$ of episode $k$, the learner first chooses an action $a_h^k \in \mathcal{A}$ for current state $s_h^k$. Then, the learner receives a reward $r_h(s_h^k,a_h^k)$, where $r_h(\cdot): \mathcal{S} \times \mathcal{A} \to [0,1]$ is known. Finally, according to the \emph{unknown} transition probability function $\mathbb{P}_h(\cdot \vert s_h^k,a_h^k): \mathcal{S} \times \mathcal{A} \times \mathcal{S} \to [0,1]$, the environment draws a next state $s_{h+1}^k$ and reveals it to the learner. Meanwhile, the learner observes a noisy safety value $\hat{c}_h^k = c_h(s_h^k,a_h^k,s_{h+1}^k) + \zeta_h^k$, where $c_h(\cdot): \mathcal{S} \times \mathcal{A} \times \mathcal{S} \to [0,1]$ is \emph{unknown} and $\zeta_h^k$ is an additive $0$-mean $\sigma$-subGaussian random variable.
\textbf{Instantaneous hard constraint:} At each step $h<H$ of each episode $k$, the following constraint must be satisfied,
\begin{align}\label{eq:defhardconstraint}
c_h(s_h^k,a_h^k,s_{h+1}^k) \leq \bar{c},
\end{align}
where $\bar{c}$ is a known constant, and $c_h(s_{H}^k) \leq \bar{c}$ must be satisfied at step $H$. The transition from $s_h^k$ through $a_h^k$ to $s_{h+1}^k$ is said to be unsafe if constraint~\eqref{eq:defhardconstraint} is violated. Due to this constraint, some states and actions could also be unsafe.
\begin{itemize}
\item A state is said to be unsafe at step $h$, if there exists no action, such that constraint~\eqref{eq:defhardconstraint} can be satisfied, i.e., $\min_{a\in\mathcal{A}} \max_{\{s':\mathbb{P}_h(s' \vert s,a)>0\}} c_h(s,a,s') > \bar{c}$.
\item An action is said to be unsafe for state $s$ at step $h$, if there is a non-zero probability to transit to a state, such that constraint~\eqref{eq:defhardconstraint} will be violated, i.e., $\max_{\{s':\mathbb{P}_h(s' \vert s,a)>0\}} c_h(s,a,s') > \bar{c}$.
\end{itemize}
As discussed in~\cref{sec:introduction}, due to unsafe states and actions caused by the instantaneous hard constraint, e.g., bad movements and failures in robotics, crushing in autonomous driving and blackouts in power systems, new fundamental difficulties need to be resolved, which is the focus of this paper.
\textbf{Linear mixture MDP:} Due to the ergodicity under the linear function approximation $\mathbb{P}_h(\cdot \vert s,a) = \langle \boldsymbol{\mu}_h^*(\cdot),\boldsymbol{\phi}(s,a) \rangle$ from~\cite{jin2020provably}, any state could be finally visited from any other state. Thus, in such a linear MDP, no algorithm can avoid the unsafe states under constraint~\eqref{eq:defhardconstraint}. Thus, instead we borrow the linear mixture MDP model from~\cite{jia2020model,zhou2021nearly,zhou2021provably,zhou2022computationally,he2022near}. The importance and many applications of linear mixture MDPs have been provided in these references. Specifically, the transition probability $\mathbb{P}_h(s' \vert s,a) = \langle \boldsymbol{\mu}_h^*,\boldsymbol{\phi}(s,a,s') \rangle$ and safety value $c_h(s,a,s') = \langle \boldsymbol{\gamma}_h^*,\boldsymbol{\phi}(s,a,s') \rangle$ are linear functions of a given feature mapping $\boldsymbol{\phi}: \mathcal{S} \times \mathcal{A} \times \mathcal{S} \to \mathbb{R}^d$, where $\boldsymbol{\mu}_h^*\in \mathbb{R}^d$ and $\boldsymbol{\gamma}_h^* \in \mathbb{R}^d$ are \emph{unknown} parameters. As typically assumed, for any bounded function $V_h: \mathcal{S} \to [0,H]$ and state-action pair $(s,a)$, we have $\lVert \bphi_{V_h}(s,a) \rVert_2 \leq D$, where $\bphi_{V_h}(s,a) = \sum_{\{s':\mathbb{P}_h(s' \vert s,a)>0\}} \boldsymbol{\phi}(s,a,s')V_h(s') \in \mathbb{R}^d$. Moreover, $\lVert \boldsymbol{\mu}_h^* \rVert_2 \leq L$ and $\lVert \boldsymbol{\gamma}_h^* \rVert_2 \leq L$.
\subsection{State-Action Subgraphs and Performance Metric}\label{subsec:performancemetric}
Notice that the ergodicity property, (i.e., any state could finally be visited from any other state) in classical MDPs does not hold any more under instantaneous hard constraint~\eqref{eq:defhardconstraint}. This is because if unsafe states can be visited from any other state, it is impossible to satisfy~\eqref{eq:defhardconstraint} at all steps. Due to this non-ergodicity, we define two important notions below.
First, we let $\mathcal{S}_h(s,a)$ denote the set of next-states that could be transited to with non-zero probability from a state-action pair $(s,a)$ at step $h$, i.e., $\mathcal{S}_h(s,a) \triangleq \{s':\mathbb{P}_h(s' \vert s,a)>0\}$. Similar to that required in the case with deterministic transitions~\cite{turchetta2016safe} and~\cite{wachi2018safe}, we assume that the algorithm knows $\mathcal{S}_h(s,a)$ in advance. (Note that the transition kernel $\mathbb{P}$ is still \emph{unknown}.) If $\mathcal{S}_h(s,a)$ is not known in advance, no safe algorithm can achieve a sub-linear regret. This is because (i) if an unsafe state $s'$ that \emph{will not be} transited to is considered for a state-action pair $(s,a)$, the algorithm will lose the chance to explore $(s,a)$. This could result in a linear-to-$T$ regret when $(s,a)$ is actually optimal. (ii) If an unsafe state $s'$ that \emph{will be} transited to is missed for $(s,a)$, the algorithm will suffer from this unsafe state $s'$ when choosing $a$ at state $s$.
\begin{figure}[t]
\vskip 0.2in
\begin{center}
\centerline{\includegraphics[width=\columnwidth]{sketchsubgraph.pdf}}
\caption{A sketch of subgraph examples. Squares represent states. The red dashed square at step $h=5$ is the unsafe state. Circles represent actions. Arrows represent state transitions. There are two actions $a=1,2$, as shown by the numbers in the circles.}
\label{fig:sketchsubgraph}
\end{center}
\vskip -0.2in
\end{figure}
\textbf{State-action subgraph:} While ergodicity does not hold, an important property here is that, by executing a \emph{deterministic} policy $\pi(s,h): \mathcal{S} \times [1,H] \to \mathcal{A}$, the learner follows a closed directed state-action subgraph
\begin{align}\nonumber
G^{\pi} \triangleq \left\{ (s_1,\pi(s_1,1)), \left\{(s_2,\pi(s_2,2))\right\}_{s_2 \in \mathcal{S}_2^{\pi}}, ..., \mathcal{S}_{H}^{\pi} \right\},
\end{align}
where $\mathcal{S}_h^{\pi}$ denotes the set of all states that are visited with non-zero probability by policy $\pi$ at step $h$. $G$ may contain only a subset of all states in the global state space $\mathcal{S}$. For simplicity, we assume all episodes start from a fixed state $s_1$. (Our results can be easily generalized to the more general case with an arbitrary starting state.)
Please see~\cref{fig:sketchsubgraph} for a simple sketch of subgraph examples. For example, when choosing action $a=1$ at all steps, the learner follows subgraph $G_1$. Notice that $G_1$ is a safe subgraph, since the unsafe state at step $h=5$ will not be visited. As another example, the learner follows subgraph $G_2$ when choosing $a=2$ at step $h=1$, choosing $a=1$ at step $h=2$, choosing $a=2$ for the second state (i.e., the second square from the top when $h=3$) and $a=1$ for the third state (i.e., the third square from the top when $h=3$) at step $h=3$, and choosing $a=2$ at step $h=4$ and step $h=5$. Notice that $G_2$ is an unsafe subgraph, since the unsafe state at $h=5$ could be visited. For ease of understanding, in~\cref{fig:sketchsubgraph}, we only draw finite states, two actions and three subgraphs. However, this paper considers the general linear mixture MDP, where the number of states $s$, actions $a$ and subgraphs $G$ could be infinite.
\textbf{Performance metric:} We let $\mathcal{G}^{\text{safe}} \triangleq \{G^{\text{safe}}\}$ denote the set of all possible safe subgraphs, where all state-action-state triplets satisfy the instantaneous hard constraint~\eqref{eq:defhardconstraint}. Then, the set of all possible safe \emph{deterministic} policies is
\begin{align}
\Pi^{\text{safe}} \triangleq \left\{ \pi: G^{\pi} \in \mathcal{G}^{\text{safe}} \right\}.
\end{align}
Moreover, the $Q$-value (state-action-value) function and the $V$-value (state-value) function are defined as follows:
\begin{align}
& Q_h^{\pi}(s,a) \triangleq r_h(s,a) + \mathbb{E} \left[ \sum\limits_{h'=h+1}^{H} r_{h'}(s_{h'},\pi(s_{h'},h')) \Big\vert s_h=s,a_h=a \right], \label{eq:defqvaluestandard} \\
& V_h^{\pi}(s) \triangleq \mathbb{E} \left[ \sum\limits_{h'=h}^{H} r_{h'}(s_{h'},\pi(s_{h'},h')) \Big\vert s_h=s \right]. \label{eq:defvvaluestandard}
\end{align}
Therefore, our goal is to develop an RL algorithm $\pi \triangleq \{\pi^k\}_{k=1}^{K}$ that (i) is safe: $\pi^k \in \Pi^{\text{safe}}$ for all $k$, i.e., constraint~\eqref{eq:defhardconstraint} is satisfied in all episodes $k$; (ii) achieves a sublinear regret, which is defined as
\begin{align}\label{eq:defregret}
R^{\pi} \triangleq \sum\limits_{k=1}^{K} \left\{ V_1^{*}(s_1) - V_1^{\pi^k}(s_1) \right\},
\end{align}
where $V_1^{*}(s_1)$ is the $V$-value of the optimal \emph{safe} policy, i.e.,
\begin{align}\label{eq;defoptimalvvalue}
V_1^{*}(s_1) = \max\limits_{\pi \in \Pi^{\text{safe}}} V_1^{\pi}(s_1).
\end{align}
\section{A Near-Optimal Safe Algorithm}\label{sec:algorithm}
In this section, we present our algorithm, called Least-Square Value Iteration by lookiNg ahEad and peeking backWard (\text{LSVI-NEW}), as shown in~\cref{algorithm}. Before introducing our algorithm, we present a necessary assumption.
\begin{assumption}\label{ass:knownseedsubgraph}
\textbf{(Known seed safe subgraph)} There exists a known seed safe subgraph $G^{\text{safe},0} \in \mathcal{G}^{\text{safe}}$ with the known safety value $c^0_h$ for a state-action-state triplet $(s_h^0,a_h^0,s_{h+1}^0)$ at each step $h$ of $G^{\text{safe},0}$.
\end{assumption}
A known seed safe subgraph is necessary for the existence of \emph{safe} RL algorithms under instantaneous hard constraints. Without it, the unsafe states and actions cannot be avoided in the first episode. Same assumptions on such a known safe set are also made in related work~\cite{pacchiano2021stochastic,amani2021safe}. As pointed out there, such an assumption is realistic since the known safe set can be obtained from existing strategies or trials with possibly low rewards.
Next, we define some notations. First, we let $\mathcal{U}_h \triangleq \{\alpha \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0): \alpha\in \mathbb{R}\}$ denote the span of the feature $\boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0)$. Let $\boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}_1) \triangleq \langle \boldsymbol{\phi}_1, \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle \cdot \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0)$ denote the projection of a vector $\boldsymbol{\phi}_1$ to $\mathcal{U}_h$, where $\tilde{\bphi}(s,a,s') \triangleq \frac{\boldsymbol{\phi}(s,a,s')}{\lVert\boldsymbol{\phi}(s,a,s')\rVert_2}$ is the normalized vector of $\boldsymbol{\phi}(s,a,s')$. Second, we let $\mathcal{U}^{\perp}_h \triangleq \{\boldsymbol{\phi}_3 \in \mathbb{R}^d: \langle\boldsymbol{\phi}_3,\boldsymbol{\phi}_2\rangle=0, \forall \boldsymbol{\phi}_2\in\mathcal{U}_h\}$ denote the orthogonal complement of $\mathcal{U}_h$. Let $\boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}_1) \triangleq \boldsymbol{\phi}_1 - \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}_1)$ denote the projection of $\boldsymbol{\phi}_1$ to $\mathcal{U}^{\perp}_h$. Third, we let $\bphi_{h,h+1}^k = \boldsymbol{\phi}(s_h^k,a_h^k,s_{h+1}^k)$ denote the feature vector of the state-action-state triplet $(s_h^k,a_h^k,s_{h+1}^k)$. Let $\lVert \boldsymbol{x} \rVert_{\boldsymbol{\Lambda}} = \sqrt{\boldsymbol{x}^{\text{T}}\boldsymbol{\Lambda} \boldsymbol{x}}$ denote the weighted $2$-norm of $\boldsymbol{x}$ with respect to $\boldsymbol{\Lambda}$. Let $\boldsymbol{I}$ denote the identity matrix.
\begin{algorithm}[t]
\caption{Least-Square Value Iteration by lookiNg ahEad and peeking backWard (\text{LSVI-NEW})}
\label{algorithm}
\begin{algorithmic}
\FOR{$k=1$ {\bfseries to} $K'$}
\STATE At each step $h$, first choose the action $a_h^k=a_h(s_h^k)$ in the known seed safe subgraph $G^{\text{safe},0}$, then observe the next state $s_{h+1}^k$, finally observe the safety value $c_h(s_h^k,a_h^k,s_{h+1}^k)$.
\ENDFOR
\FOR{$k=K'+1$ {\bfseries to} $K$}
\FOR{$h=H$ {\bfseries to} $1$}
\STATE \textit{Step-1:} Update the estimated safety parameter $\boldsymbol{\gamma}_h^k$ according to~\eqref{eq:estimatesafetyparameter} and the estimated safety function $\tilde{c}_h^k$ according to~\eqref{eq:estimatesafetyvalue}.
\STATE \textit{Step-2:} Update the estimated safe state-set:
\begin{align}\nonumbe
\mathcal{S}_h^{k,\text{safe}} = \{s\in\mathcal{S} \vert \exists a\in\mathcal{A}, \text{ s.t.}~\eqref{eq:safetycondition1} \text{ and}~\eqref{eq:safetycondition2} \text{ hold}\},
\end{align}
and estimated safe action-set for states $s\in\mathcal{S}_h^{k,\text{safe}}$:
\begin{align}\nonumbe
& \mathcal{A}_h^{k,\text{safe}}(s) = \{a\in\mathcal{A} \vert \eqref{eq:safetycondition1} \text{ and}~\eqref{eq:safetycondition2} \text{ hold for state } s\} .
\end{align}
\STATE \textit{Step-3:} Update the parameter $\boldsymbol{w}_h^k$ according to~\eqref{eq:estimatemodel}.
\STATE \textit{Step-4:} Update the estimated $Q$-values for all state-action pairs $(s,a)$ that are estimated to be safe, i.e., $s\in\mathcal{S}_h^{k,\text{safe}}$ and $a\in \mathcal{A}_h^{k,\text{safe}}(s)$, according to~\eqref{eq:estimateqvalue}.
\ENDFOR
\FOR{$h=1$ {\bfseries to} $H-1$}
\STATE \textit{Step-5:} Observe the current state $s_h^k$, and then choose an action according to~\eqref{eq:chooseaction}.
\ENDFOR
\ENDFOR
\end{algorithmic}
\end{algorithm}
Our~\text{LSVI-NEW}~algorithm contains a simple initialization phase and \emph{a more important learning phase that involves four novel ideas}. In the initialization phase,~\text{LSVI-NEW}~purely explores inside the known seed safe subgraph $G^{\text{safe},0}$, i.e., the first for-loop in~\cref{algorithm}, where $K'$ is a tunable parameter. This initialization phase borrows the idea in bandits with instantaneous hard constraints for obtaining and preparing some parameter information for the later learning phase~\cite{amani2019linear}.
From now on, we focus on introducing the five steps in the \emph{learning phase} (i.e., the second for-loop in~\cref{algorithm}) that involves four important novel ideas. In Step-1,~\text{LSVI-NEW}~updates the regularized least-square estimator of the \emph{projected} safety parameter $\boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\gamma}_h^*)$ as follows:
\begin{align}\label{eq:estimatesafetyparameter}
\boldsymbol{\gamma}_h^k = (\boldsymbol{\Lambda}_{h,1}^k)^{-1} \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\hat{c}_h^{\tau}),
\end{align}
where the Gram matrix $\boldsymbol{\Lambda}_{h,1}^k = \lambda \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) + \sum_{\tau=1}^{k-1} \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau}) \boldsymbol{\psi}^{\text{T}}(\mathcal{U}^{\perp}_h,\bphi_{h,h+1}^{\tau})$, $\boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{I}) = \boldsymbol{I} - \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \tilde{\bphi}^{\text{T}}(s_h^0,a_h^0,s_{h+1}^0)$, $\boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\hat{c}_h^{\tau}) = \hat{c}_h^{\tau} - \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}_{h,h+1}^{\tau}), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0$ and $\lambda\geq d$ is a tunable parameter. Then, we estimate the safety function as follows:
\begin{align}
\tilde{c}_h^k(s,a,s') = \frac{\langle \boldsymbol{\psi}(\mathcal{U}_h,\boldsymbol{\phi}_1), \tilde{\bphi}(s_h^0,a_h^0,s_{h+1}^0) \rangle}{\lVert \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2} \cdot c_h^0 + \langle \boldsymbol{\gamma}_h^k, \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}_1) \rangle + \beta \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}_1) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}, \label{eq:estimatesafetyvalue}
\end{align}
where $\boldsymbol{\phi}_1 = \boldsymbol{\phi}(s,a,s')$ and $\beta$ is a tunable parameter given in~\cref{thm:regret}. Notice that, on the right-hand-side (RHS) of~\eqref{eq:estimatesafetyvalue}, the first term is the projected safety value of $(s,a,s')$ on $\mathcal{U}_h$, the second term is the projected empirical safety value of $(s,a,s')$ on $\mathcal{U}^{\perp}_h$, and the last term is an upper-confidence-bound (UCB) bonus for the safety uncertainty. Thus, the accuracy of the safety value $\tilde{c}_h^k$ depends on how accurate $\boldsymbol{\gamma}_h^k$ in~\eqref{eq:estimatesafetyparameter} is and how small the safety uncertainty is. Next, Step-2 in~\cref{algorithm} is based on $\tilde{c}_h^k$ and involves our first novel idea that is critical for guaranteeing safety.
\textbf{Idea I: Constructing safe subgraphs by looking ahead.} As we discussed in~\cref{sec:introduction}, in bandits and RL with only unsafe actions, the safety at each step can be estimated \emph{separately}. In sharp contrast, due to the unsafe states and transitions in our setting, we must handle possible unsafe \emph{future} steps. Consider~\cref{fig:sketchsubgraph} as an example. Even though taking action $a=1$ for the third state (the third square from the top) at step $h=3$ is safe for $h=3$, by doing so, the unsafe state (the red dashed square) at $h=5$ will be visited no matter what action would be taken at $h=4$. To resolve this new challenge, our idea is to construct special safe subgraphs where any action only results in safe future (not even just next) states. To achieve this, in Step-2, we estimate the safe state-set $\mathcal{S}_h^{k,\text{safe}}$ and action-set $\mathcal{A}_h^{k,\text{safe}}(s)$ in a \emph{backward} manner based on the two conditions below:
\begin{align}
& \text{Condition 1: } \max_{s'\in\mathcal{S}_h(s,a)} \tilde{c}_h^k(s,a,s') \leq \bar{c}. \label{eq:safetycondition1} \\
& \text{Condition 2: } \mathcal{S}_h(s,a) \subseteq \mathcal{S}_{h+1}^{k,\text{safe}}. \label{eq:safetycondition2}
\end{align}
Notice that, (i) condition 1 requires that by choosing action $a$ for state $s$, the instantaneous hard constraint is always satisfied at step $h$; (ii) condition 2 requires that all possible next states in $\mathcal{S}_h(s,a)$ must be safe for next step $h+1$. Thus, with conditions 1 and 2 satisfied simultaneously in a backward manner, all (not just next) steps $h'\geq h$ following $(s,a)$ must be safe. Please see~\cref{thm:constraintsatisfaction} for the safety performance of~\text{LSVI-NEW}~at all steps in any episode.
Moreover, since the linear mixture MDP induces a linear form of the $Q$-value function as follows:
\begin{align} \label{eq:optqvalue}
Q_h^*(s,a) = \min\{ r_h(s,a) + \langle w_h^*, \boldsymbol{\phi}_{V_{h+1}^*}(s,a) \rangle, H \},
\end{align}
in Step-3 of~\cref{algorithm}, we update the regularized least-square estimator of the parameter $w_h^*$ in~\eqref{eq:optqvalue} as follows:
\begin{align}\label{eq:estimatemodel}
\boldsymbol{w}_h^k = (\boldsymbol{\Lambda}_{h,2}^k)^{-1} \sum_{\tau=1}^{k-1} \boldsymbol{\phi}_{h,V_{h+1}^{\tau}}^{\tau} V_{h+1}^{\tau}(s_{h+1}^{\tau}),
\end{align}
where the Gram matrix $\boldsymbol{\Lambda}_{h,2}^k = \lambda \boldsymbol{I} + \sum_{\tau=1}^{k-1} \boldsymbol{\phi}_{h,V}^{\tau} \boldsymbol{\phi}_{h,V}^{\tau,\text{T}}$ and $\boldsymbol{\phi}_{h,V}^{\tau} = \boldsymbol{\phi}_{V}(s_h^{\tau},a_h^{\tau})$. Then, in Step-4 of~\cref{algorithm}, we update the $Q$-values of the safe state-action pairs as follows:
\begin{align}
& Q_h^k(s,a) = \min\Big\{ H, r_h(s,a) + \langle \boldsymbol{w}_h^k, \boldsymbol{\phi}_{V_{h+1}^k}(s,a) \rangle \nonumber \\
& + \epsilon_{1} \cdot \lVert \boldsymbol{\phi}_{V_{h+1}^k}(s,a) \rVert_{(\boldsymbol{\Lambda}_{h,2}^k)^{-1}} + \epsilon_{h,2} \cdot \max_{s'\in \mathcal{S}_h(s,a)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a,s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}} \nonumber \\
& + \epsilon_{h,3} \max_{(s_{h'},a_{h'},s') \in \mathcal{G}_h(s)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'},a_{h'},s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}} + \epsilon_{4} \max_{s'\in \mathcal{S}_1(s_1,a_1^k)} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_1,\boldsymbol{\phi}(s_1,a_1^k,s')) \rVert_{(\boldsymbol{\Lambda}_{1,1}^k)^{-1}} \Big\}, \label{eq:estimateqvalue}
\end{align}
where $\epsilon_{1}=\beta+1$, $\epsilon_{h,2}$, $\epsilon_{h,3}$ and $\epsilon_{4}$ are given soon later, and $\mathcal{G}_h(s)$ is the set of subsubgraphs starting from state $s$ at step $h$. Notice that (i) the term with $\epsilon_{1}$ on the RHS of~\eqref{eq:estimateqvalue} is the standard Hoeffding bonus term; (ii) the terms with $\epsilon_{h,2}$, $\epsilon_{h,3}$ and $\epsilon_{4}$ are three new bonus terms that we construct for capturing the impacts from future and past steps. We elaborate our novel ideas in these new bonus terms below.
\textbf{Idea II: Encouraging to explore the transitions with higher uncertainty (i.e., looking ahead).} As we mentioned in~\cref{sec:introduction}, there is a new pessimism-optimism dilemma in our setting. Specifically, according to the optimism-in-face-of-uncertainty principle~\cite{azar2017minimax}, algorithms need to learn optimistically to achieve a sublinear regret. However, to avoid the unsafe states and transitions in our setting, algorithms have to be relatively pessimistic. To resolve this new dilemma, we construct a bonus term to encourage~\text{LSVI-NEW}~to explore the transitions with \emph{higher} uncertainty. To achieve this, this new bonus term, i.e., the term with $\epsilon_{h,2}$ in~\eqref{eq:estimateqvalue}, is designed to be the maximum UCB bonus over all possible next-states $s'\in \mathcal{S}_h(s,a)$.
Then, another new difficulty here is how to quantify the parameter $\epsilon_{h,2}$ for such a bonus term, such that a sublinear regret can be achieved. To resolve this problem, we set
\begin{align}\label{eq:epss}
\epsilon_{h,2} = \frac{\frac{4\beta H}{\tilde{\delta}} \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)}}{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) - \frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)}\kappa},
\end{align}
where $\bar{c}_{h'}^0 = \max_{h\leq h'\leq H} c_{h'}^0$, $\Delta_{\bphi}(c) = L \cdot \max_{s,a,h}\max_{s',s''\in\mathcal{S}_h(s,a)} \lVert \boldsymbol{\phi}(s,a,s')-\boldsymbol{\phi}(s,a,s'') \rVert_2$, and $\tilde{\delta}$ and $\kappa$ are scalars given in~\cref{thm:regret}. Notice that when all states are assumed to be safe, all terms related to next state $s'$ would be $0$. Then, $\epsilon_{h,2}$ would be $\frac{4\beta H}{\bar{c}-c_h^0}$, which is the same as the parameter used in the setting with only unsafe actions~\cite{amani2021safe}. However, one difference here is that we need to handle the \emph{worst} transition. Thus, the denominator needs to capture the \emph{smallest} safety balance, i.e., $\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)$, that is left for exploration. Another difference is that even though the safety balance at current step is small, if the safety balance in future steps is large, the algorithm should still be encouraged to explore. To capture such a new special impact from future steps, we add the term $\frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)}$, such that $\epsilon_{h,2}$ increases with the ratio between future safety balance $\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)$ and current balance $\bar{c}-c_{h}^0-\Delta_{\bphi}(c)$. Please see~\cref{app:lemmaimpactfromfuture} for details.
\textbf{Idea III: Encouraging to explore the future subsubgraphs with higher uncertainty (i.e., looking ahead).} Idea II by itself is not sufficient to achieve a sublinear regret. This is because future uncertainty could prevent the algorithm from choosing the optimal action at current step. Consider~\cref{fig:sketchsubgraph} as an example and assume $G_1$ is the optimal subgraph. Even though the safety value at $h=1$ has been precisely known, the algorithm may still not choose the optimal action $a=1$ due to future uncertainty, e.g., it is uncertain whether the first two states at $h=2$ are safe or not. This is another critical difference compared with the case without instantaneous constraints or with only unsafe actions. Hence, at each step, the algorithm should be encouraged to explore the state that induces a future subsubgraph with \emph{higher} uncertainty. To achieve this, we construct a new bonus term (the term with $\epsilon_{h,3}$ in~\eqref{eq:estimateqvalue}) that is the maximum UCB bonus over all future subsubgraphs $G_h(s)$, where
\begin{align}\label{eq:epsss}
\epsilon_{h,3} = \frac{4\beta H / \tilde{\delta}}{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c) - \kappa}.
\end{align}
Differently from $\epsilon_{h,2}$ in~\eqref{eq:epss}, the term $\frac{\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)}{\bar{c}-c_{h}^0-\Delta_{\bphi}(c)}$ does not appear in $\epsilon_{h,3}$, because the maximization in this bonus term is taken over all states and actions in $\mathcal{G}_h(s)$, which already captures the impacts from future steps.
\textbf{Idea IV: Encouraging to explore the past subsubgraphs with higher uncertainty (i.e., peeking backward).} Surprisingly, with Ideas II and III alone, a sublinear regret may still not be achieved. This is because of the tricky impact from past steps. Intuitively, by choosing a different action at step $h=1$, what will happen in future steps could be completely different. To resolve this new challenge, we construct a new bonus term, i.e., the term with $\epsilon_{4}$ in~\eqref{eq:estimateqvalue}, to encourage~\text{LSVI-NEW}~to explore the past subsubgraphs with \emph{higher} uncertainty, where
\begin{align}\label{eq:epssss}
\epsilon_{4} = \frac{4\beta H}{ \bar{c}-c_{1}^0-\Delta_{\bphi}(c) }.
\end{align}
Differently from $\epsilon_{h,3}$ in~\eqref{eq:epsss}, the denominator here depends on $c_1^0$ (not $\bar{c}_{h'}^0$) at step $h=1$ that affects all future steps.
Finally, in Step-5,~\text{LSVI-NEW}~chooses an action
\begin{align}\label{eq:chooseaction}
a_h^k = {\arg\max}_{a \in \mathcal{A}_h^{k,\text{safe}}(s,a)} Q_h^k(s_h^k,a).
\end{align}
\section{Theoretical Results}\label{sec:finalresults}
In this section, we provide the safety and regret guarantees for our~\text{LSVI-NEW}~algorithm, and a regret lower-bound.
Before these, we make two necessary assumptions for obtaining good theoretical performance in our setting.~\cref{ass:starconvexity} below is from~\cite{amani2021safe}. The counter-example given there shows that such an assumption is required for the existence of safe algorithms with sublinear regrets. We let $\Phi_{\boldsymbol{\alpha}}(s,a) \triangleq [\alpha(s')\boldsymbol{\phi}(s,a,s')]_{s'\in\mathcal{S}(s,a)}$ denote a matrix with $\alpha(s')\boldsymbol{\phi}(s,a,s')$ in each column, where $\alpha(s')$ is a scalar.
\begin{assumption}\label{ass:starconvexity}
\textbf{(Star convexity)} For all states $s_h$ at step $h$, the set $\mathcal{D}(s_h) \triangleq \{\Phi_{\mathbf{1}}(s_h,a): a\in\mathcal{A}\} \cup \{\Phi_{\mathbf{1}}(s_h^0,a_h^0): \Phi_{\mathbf{1}}(s_h^0,a_h^0,\cdot)=\boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0)\}$ is a star convex set around the safe feature $\boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0)$, i.e., for all $\Phi_{\mathbf{1}}(s_h,a) \in \mathcal{D}(s_h)$ and $\boldsymbol{\alpha}: \mathcal{S}_h(s_h,a) \to [0,1]$ with $\lVert \boldsymbol{\alpha} \rVert_1 = 1$, we have $\Phi_{\boldsymbol{\alpha}}(s_h,a) + \Phi_{\boldsymbol{1-\alpha}}(s_h^0,a_h^0) \in \mathcal{D}(s_h)$, where $\mathbf{1}$ denotes a vector with all entries equal to $1$.
\end{assumption}
Next, we let $f_h(\boldsymbol{\phi}_1-\boldsymbol{\phi}_2) \triangleq \frac{\lVert \boldsymbol{\phi}_1 - \boldsymbol{\phi}_2 \rVert_2}{\lVert \boldsymbol{\phi}(s_h^*,a_h^*,s_{h+1}^*) - \boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0) \rVert_2}$ denote the $\mathcal{L}_2$-distance between features $\boldsymbol{\phi}_1$ and $\boldsymbol{\phi}_2$, normalized by the $\mathcal{L}_2$-distance between the unknown optimal feature $\boldsymbol{\phi}(s_h^*,a_h^*,s_{h+1}^*)$ and the known safe feature $\boldsymbol{\phi}(s_h^0,a_h^0,s_{h+1}^0)$ at step $h$. Let $g(r_{h,1}-r_{h,2}) \triangleq \frac{r_{h,1}-r_{h,2}}{r_h(s_h^*,a_h^*)}$ denote the reward difference $r_{h,1}-r_{h,2}$, normalized by the reward of the unknown optimal state-action pair at step $h$.
\begin{assumption}\label{ass:lipschitzreward}
\textbf{(Lipschitz rewards and transitions)} There exists $\delta \in [0,1]$, s.t., for any two safe state-action pairs $(s(i),a(i))$ and $(s(j),a(j))$ at step $h$,
\begin{align}
& g\left( r_h(s(i),a(i))-r_h(s(j),a(j)) \right) \leq \delta f_h\left( \boldsymbol{\phi}(s(i),a(i),\cdot)-\boldsymbol{\phi}(s(j),a(j),\cdot) \right), \label{eq:lipschitzreward} \\
& f_{h'} \left( \boldsymbol{\phi}(s_{h'}(i),a_{h'}(i),\cdot)-\boldsymbol{\phi}(s_{h'}(j),a_{h'}(j),\cdot) \right) \leq \delta f_h \left( \boldsymbol{\phi}(s(i),a(i),\cdot)-\boldsymbol{\phi}(s(j),a(j),\cdot) \right), \label{eq:lipschitztransition}
\end{align}
where $(s_{h'}(i),a_{h'}(i))$ ($h'>h$) is the descendant of the state-action pair $(s(i),a(i))$ in the safe subgraphs.
\end{assumption}
Note that~\eqref{eq:lipschitzreward} implies that rewards are $\delta$-Lipschitz: as feature differences (RHS of~\eqref{eq:lipschitzreward}) become smaller, reward differences (LHS of~\eqref{eq:lipschitzreward}) become smaller; and~\eqref{eq:lipschitztransition} implies that safe transitions are $\delta$-Lipschitz: as feature differences at current step (RHS of~\eqref{eq:lipschitztransition}) become smaller, feature differences at future steps $h'$ (LHS of~\eqref{eq:lipschitztransition}) become smaller.
When the unsafe states and transitions are taken into consideration, to still achieve a sublinear regret,~\cref{ass:lipschitzreward} is required. This is because (i) if rewards are not Lipschitz, even though a feature vector \emph{close to} the optimal one is learned to be safe, the learner could still suffer from a large reward gap compared with the optimal safe decision, which could result in a linear-to-$T$ regret; (ii) if safe transitions are not Lipschitz, even though the optimal safe decision at a step \emph{has been learned}, the learner could still be far away from optimum \emph{in future steps}, and hence suffer from a large reward gap, which could also result in a linear-to-$T$ regret.
\subsection{Performance Guarantees and A Lower Bound}\label{subsec:results}
In \cref{thm:constraintsatisfaction} below, we show that~\text{LSVI-NEW}~is safe.
\begin{theorem}\label{thm:constraintsatisfaction}
\textbf{(Safety)} For any $p\in (0,1)$, with probability $1-p$, our~\text{LSVI-NEW}~algorithm satisfies the instantaneous hard constraint~\eqref{eq:defhardconstraint} at all steps $h$ of all episodes $k$.
\end{theorem}
Thanks to our Idea I in~\cref{sec:algorithm} for guaranteeing safety, the proof of~\cref{thm:constraintsatisfaction} (in~\cref{app:thmconstraintsatisfaction}) focuses on quantifying the accuracy of the estimated safety value in~\eqref{eq:estimatesafetyvalue}. Below,~\cref{thm:regret} provides the regret upper-bound of~\text{LSVI-NEW}.
\begin{theorem}\label{thm:regret}
\textbf{(Regret)} By setting $\tilde{\delta}=\delta$, $\lambda = d$, $\beta = \max\left\{ \sigma \sqrt{d \log\left( \frac{2+2T D^2/ \lambda}{p} \right)} + \sqrt{\lambda} L, b_{\beta} dH \sqrt{\log\left( \frac{dT}{p} \right)} \right\}$, $K' = 4 \beta D \sqrt{T} \log\left(\frac{d}{p}\right)$, where $T=\chK$, $\kappa = \frac{4\beta D}{\lambda+\lambda_{0} K'}$ and $\Delta_c = \bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c)$, then there exist absolute constants $b_{\beta}>0$ and $\lambda_{0}>0$, with probability $1-p$, the regret of~\text{LSVI-NEW}~is upper-bounded as follows:
\begin{align}\label{eq:regret}
R^{\text{LSVI-NEW}} \leq \left[ \epsilon_{1} + \epsilon_{4} + \max_{h} \left( \epsilon_{h,2}+\epsilon_{h,3} \right) \right] \sqrt{2dHT \log\left( 1+T \right)} + 2H\sqrt{T\log\left( \frac{2dT}{p} \right)} + \chK' + \frac{D}{\lambda_{0}}\left(\frac{K}{K'}-1\right).
\end{align}
\end{theorem}
The regret in~\eqref{eq:regret} is dominated by the first term on the RHS of~\eqref{eq:regret} that results from the aforementioned new challenges due to the instantaneous hard constraint. Thus, incorporated with the values of the parameters,~\cref{thm:regret} indicates that the regret of~\text{LSVI-NEW}~is upper-bounded by $\tilde{O}\left( \frac{dH^3 \sqrt{dK}}{\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c)} \right)$. Notably, it tightly matches the state-of-the-art regret $\tilde{O}\left( \frac{dH^3 \sqrt{dK}}{\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c)} \right)$ in the setting with only unsafe actions~\cite{amani2021safe} and nearly matches that $\tilde{O}(dH^2\sqrt{K})$ in the unconstrained linear mixture MDP~\cite{jia2020model}. \emph{To the best of our knowledge, this is the first such result in the literature.} Further, we provide a lower bound in~\cref{thm:lowerbound} below that shows that the dependency on the safety term $\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c)$ is necessary.
\begin{theorem}\label{thm:lowerbound}
\textbf{(A lower bound)} Assuming $K \geq 32\underline{R}$. The regret of any safe algorithm $\pi$ is lower-bounded as follows:
\begin{align}\label{eq:lowerbound}
R^{\pi} \geq \underline{R} \triangleq \max\left\{ \frac{dH\sqrt{K}}{16\sqrt{2}}, \frac{H/24}{(\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c))^2} \right\}.
\end{align}
\end{theorem}
\cref{thm:lowerbound} implies that the dependency of the regret of~\text{LSVI-NEW}~on $\bar{c}-\bar{c}_1^0-\Delta_{\bphi}(c)$ is necessary. In addition, the regret of~\text{LSVI-NEW}~matches the lower bound within a factor of $\tilde{O}(H^2\sqrt{d})$. Same as in the setting with only unsafe actions, we conjecture that this gap can be further reduced by applying Bernstein inequality and leave this as future work. Please see~\cref{app:thmlowerbound} for the proof.
\subsection{Proof Sketch for~\cref{thm:regret}}\label{subsec:proofsketch}
In this subsection, we provide the high-level ideas for proving~\cref{thm:regret} (please see~\cref{app:thmregret} for the proof). Because of the new challenges from instantaneous hard constraints and our novel ideas in the algorithm design, there are several new difficulties in the regret analysis. The key ones are: (I) Differently from MDPs without constraints or with only unsafe actions, in our case, different policies could visit very different sets of states at each step. Hence, the commonly-used invariant on $V$-values that relies on the \emph{ergodicity} property no longer holds. (II) How to quantify the impacts when looking ahead and peeking backward. Below, we introduce our new analytical ideas, which may be of independent interest.
\textbf{Step-I: Solving difficulty I by constructing new invariants.} We construct new forms of $V$-value functions for different policies below. We let $\mathcal{S}_h^*$ denote the state set at step $h$ in the optimal safe subgraph. Let $\mathcal{S}_h^k$ denote the state set at step $h$ in the subgraph followed by policy $\pi^k$ of~\text{LSVI-NEW}~in episode $k$. Moreover, we let $\tilde{f}_h(s,a) \triangleq f_h(\boldsymbol{\phi}(s,a,\cdot)-\boldsymbol{\phi}(s_h^*,a_h^*,\cdot))$ denote the gap of transitions compared with optimal transitions. Let $\tilde{\mca}_h^k(s) \triangleq \{a\in\mathcal{A}_h^{k,\text{safe}}(s): \tilde{f}_h(s,a) \leq \bar{\alpha}_0\} \cup \{a_h^k(s)\}$ capture the safe actions with transitions close to the optimal transitions, where $\bar{\alpha}_0$ is the maximum of $\alpha_0$ in~\eqref{eq:impactfromfuture} and the RHS of~\eqref{eq:impactfrompast}. Let $\tilde{\mcs}_h^k \triangleq \{s\in\mathcal{S}_h^{k,\text{safe}}: \exists a\in\mathcal{A}_h^{k,\text{safe}}(s), \text{ s.t., } \tilde{f}_h(s,a) \leq \bar{\alpha}_0\}
\cup \mathcal{S}_h^k$ capture the safe states with transitions close to the optimal transitions. Next, we define the $V$-value functions of the optimal policy, estimated policy and policy $\pi^{k}$ to be
\begin{align}
& V_h^*(s) \triangleq Q_h^*(s,a_h^*(s)), \forall s \in \mathcal{S}_h^*, \label{eq:defoptvfunction} \\
& V_h^k(s) \triangleq \max_{a\in \tilde{\mca}_h^k(s)} Q_h^k(s,a), \forall s\in \tilde{\mcs}_h^k, \label{eq:defanalysisvfunction} \\
& V_h^{\pi^k}(s) \triangleq Q_h^{\pi^k}(s,a_h^k(s)), \forall s\in \mathcal{S}_h^k, \label{eq:defalgvfunction}
\end{align}
respectively. Then, the regret $R^{\text{LSVI-NEW}}$ can be decomposed into two parts, i.e., the values in the two brackets $[\cdot]$ below,
\begin{align}
R^{\text{LSVI-NEW}} = \sum\limits_{k=1}^{K} \left\{ [ V_1^*(s_1) - V_1^{k}(s_1) ] + [ V_1^k(s_1) - V_1^{\pi^k}(s_1) ] \right\}. \label{eq:regretdecompose}
\end{align}
To upper-bound the regret, we prove that, with high probability, (i) the value in the first bracket of~\eqref{eq:regretdecompose} is non-positive; (ii) the value in the second bracket can be upper-bounded. Result (ii) can be obtained by upper-bounding the bonus terms, which can further be proven by slightly modifying existing techniques in linear mixture MDP. The main difficulty is to prove result (i). To resolve this difficulty, we construct two new invariants that hold at each step.
\begin{lemma}\label{lemma:invariants}
\textbf{(New invariants)} At each step $h$ of each episode,
\newline (i) for any state $s$, s.t., $s\in\mathcal{S}_h^*$ and $s\in \tilde{\mcs}_h^k$, we have
\begin{align}\label{eq:invariant1}
V_h^k(s) \geq V_h^*(s);
\end{align}
(ii) for any state $s$, s.t., $s\in \mathcal{S}_h^*$ and $s\notin \tilde{\mcs}_h^k$, and any state $\hat{s}$, s.t., $\hat{s}\in \tilde{\mcs}_h^k$ and $\hat{s}\notin \mathcal{S}_h^*$, we have
\begin{align}\label{eq:invariant2}
V_h^k(\hat{s}) \geq V_h^*(s).
\end{align}
\end{lemma}
Invariant (i) shows that, if the optimal state has been found, the estimated $V$-value must be higher than the optimal $V$-value. Notice that if the optimal safe action has also been found,~\eqref{eq:invariant1} trivially holds. If it has not been found, thanks to our new bonus terms that essentially capture the distance from the optimal action,~\eqref{eq:invariant1} still holds. Moreover, invariant (ii) shows that, if the optimal state has not been found, the $V$-value of the sub-optimal state in $\tilde{\mcs}_h^k$ is still larger than the optimal $V$-value. This is intuitively because $\tilde{\mcs}_h^k$ only contains safe states with transitions \emph{close} to the optimal transitions, and the distance is captured by our new bonus terms. Please see~\cref{app:lemmainvariants} for details and the proof.
\textbf{Step-II: Solving difficulty II by quantifying future impacts.} The impact when looking ahead can be characterized by quantifying the impacts from future steps.
\begin{lemma}\label{lemma:impactfromfuture}
\textbf{(Impacts from future steps)} For any state $s$, s.t., $s\in\mathcal{S}_h^*$ and $s\in\tilde{\mcs}_h^k$, if $a_h^*(s) \notin \tilde{\mca}_h^k(s)$, there must exist an action $a_0 \in \tilde{\mca}_h^k(s)$, s.t.,
\begin{align}
\tilde{f}_h(s,a_0 \vert s_h^*=s) \leq \alpha_0, \label{eq:impactfromfuture}
\end{align}
where $\alpha_0 = 1 - \frac{(\bar{c}-c_{h}^0-\Delta_{\bphi}(c)-l_1)(\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)-l_2)}{(\bar{c}-c_{h}^0-\Delta_{\bphi}(c)+l_1)(\bar{c}-\bar{c}_{h'}^0-\Delta_{\bphi}(c)+l_2)}$, $l_1 = 2\beta \max_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_h,\boldsymbol{\phi}(s,a_h^*(s),s')) \rVert_{(\boldsymbol{\Lambda}_{h,1}^k)^{-1}}$ and $l_2 = 2\beta \max\limits_{\{h<h'\leq H,(s_{h'}^*,a_{h'}^*),s'\}} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}$.
\end{lemma}
\cref{lemma:impactfromfuture} implies that when $k$ increases, the UCB terms $l_1$ and $l_2$ decrease to be closer to $0$, and thus $\alpha_0$ gets closer to~$0$. Then, the gap between~\text{LSVI-NEW}'s decision and the optimal decision, i.e., $\tilde{f}_h(s,a_0|s_h^*=s)$ on the LHS of~\eqref{eq:impactfromfuture}, gets closer to $0$. This is consistent with the intuition that as more safety values revealed, we should be able to get closer to the optimal action. Moreover, when there is no constraint on states, all terms related to the next state $s'$ in $\alpha_0$ would be $0$. Then, $\alpha_0$ would be reduced to be $1 - \frac{\bar{c}-c_h^0-2\beta \lVert \boldsymbol{\phi}(s,a_h^*(s)) \rVert}{\bar{c}-c_h^0}$, which results in a parameter same to that used in the case with only unsafe actions~\cite{amani2021safe}. However, due to unsafe states and transitions, impacts from future steps $h'>h$ are captured in $\alpha_0$ here, which results in a different parameter $\epsilon_{h,2}$ in our Idea II and a new parameter $\epsilon_{h,3}$ in Idea III. Please see~\cref{app:lemmaimpactfromfuture} for details and the proof.
\textbf{Step-III: Solving difficulty II by quantifying past impacts.} The impact when peeking backward can be characterized by quantifying the impacts from past steps.
\begin{lemma}\label{lemma:impactfrompast}
\textbf{(Impacts from past steps)} For any state $\hat{s}$, s.t., $\hat{s}\in \tilde{\mcs}_h^k$ and $\hat{s}\notin \mathcal{S}_h^*$, there must exist an action $a_0 \in \tilde{\mca}_h^k(\hat{s})$ and $1 \leq h' \leq h$, s.t.,
\begin{align}\label{eq:impactfrompast}
\tilde{f}_h(\hat{s},a_0) \leq 1 - \frac{\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)-l_3}{\delta(\bar{c}-c_{h'}^0-\Delta_{\bphi}(c)+l_3)},
\end{align}
where $l_3 = 2\beta \max\limits_{s'} \lVert \boldsymbol{\psi}(\mathcal{U}^{\perp}_{h'},\boldsymbol{\phi}(s_{h'}^*,a_{h'}^*,s')) \rVert_{(\boldsymbol{\Lambda}_{h',1}^k)^{-1}}$.
\end{lemma}
Differently from~\cref{lemma:impactfromfuture},~\cref{lemma:impactfrompast} quantifies the impacts from past steps, i.e., $h' \leq h$. This special impact results in the new bonus term with parameter $\epsilon_{4}$ in our Idea IV in~\cref{sec:algorithm}. These are also the reasons all $\epsilon_{h,2}$, $\epsilon_{h,3}$ and $\epsilon_{4}$ are different from the parameter used in the setting with only unsafe actions~\cite{amani2021safe}. Please see~\cref{app:lemmaimpactfrompast} for the proof.
\section{Conclusion}\label{sec:conclusion}
In this paper, we make the first effort to resolve the challenges due to unsafe states and actions under instantaneous hard constraints in RL. We develop an RL algorithm that not only achieves a regret that tightly matches the state-of-the-art regret in the setting with only unsafe actions and nearly matches that in the unconstrained setting, but also is safe (i.e., satisfies the instantaneous hard constraint) at each step. We also provide a lower bound of the regret that indicates that the dependency of the regret of our algorithm on the safety parameters is necessary. Further, both our algorithm design and regret analysis involve several novel ideas, which may be of independent interest.
| {'timestamp': '2023-02-10T02:03:33', 'yymm': '2302', 'arxiv_id': '2302.04375', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04375'} | arxiv |
\section{Background: the meta re-weighting algorithm}\label{sec: background}
In this section, we present some necessary details on the meta re-weighting algorithm from \cite{shu2019meta}.
Suppose the meta re-weighting algorithm is conducted on a large imperfect training set, $D_{\text{train}}=\{(\textbf{x}_j,y_j)\}_{j=1}^N$ and a small perfect meta set $D_{\text{meta}}=\{(\mx{i}, \my{i})\}_{i=1}^M$. Imagine that we want to learn a model parameterized by $\Theta$, and the loss evaluated on a training sample $(\textbf{x}_j,y_j)$ and a meta sample $(\mx{i}, \my{i})$ is denoted as $\f{j}{\Theta}$ and $\mf{i}{\Theta}$ respectively. We further denote the weight of each training sample $j$ as $w_j$ (between 0 and 1). Following \cite{shu2019meta}, the meta re-weighting algorithm jointly learns the weights $\textbf{W} = \{w_j\}_{j=1}^N$ and the model parameter $\Theta$ by solving the following bi-level optimization problem:
\begin{small}
\begin{align}\label{eq: meta_reweight_goal}
\begin{split}
&\min_{\textbf{W}} \frac{1}{M} \sum\nolimits_{i=1}^M \mf{i}{\Theta^*(\textbf{W})},\\
& \text{s.t.}\ \Theta^*(\textbf{W}) = \text{argmin}_{\Theta} \frac{1}{N} \sum\nolimits_{j=1}^Nw_j \f{j}{\Theta}
\end{split}
\end{align}
\end{small}
in which $\Theta^*(\textbf{W})$ denotes the learned model parameters on the training set weighted by $\textbf{W}$. This problem can be efficiently solved by the meta re-weighting algorithm proposed by \cite{shu2019meta}, which can be abstracted with the following formulas \footnote{Note that these formulas are slightly different from the ones in \cite{shu2019meta} since the sample weights in \cite{shu2019meta} are produced by another neural net. But its learning algorithm is also applicable to the case where the sample weights are updated directly. We therefore start from this simple case. \revise{Further note that \cite{ren2018learning} and \cite{hu2019learning} solve Equation \eqref{eq: meta_reweight_goal} in a similar manner. Therefore, although we develop our methods mostly based on \cite{shu2019meta},
they are also potentially applicable to the solutions in \cite{ren2018learning} and \cite{hu2019learning}. We therefore discuss how it can be extended to \cite{ren2018learning}, in Appendix \nameref{appendix: generalization_method}}}:
\begin{small}
\begin{empheq}[box=\widefbox]{align}
& \textbf{Meta re-weighting:} \nonumber \\
&\hat{\Theta}(\textbf{W}_t) = \Theta_t - \frac{\alpha_t}{N}\sum\nolimits_{j=1}^Nw_{j,t} \nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t}
\label{eq: model_pre_update}\\
& w_{j,t+1} = w_{j,t} - \frac{\eta_t}{M}\sum\nolimits_{i =1}^M \nabla_{w_j} \mf{i}{\hat{\Theta}(\textbf{W}_t)} |_{\textbf{W} = \textbf{W}_t}
\label{eq: sample_weights_update}\\
& \Theta_{t+1} = \Theta_t - \frac{\alpha_t}{N} \cdot \sum\nolimits_{j=1}^N w_{j,t+1}\nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t}
\label{eq: model_post_update}
\end{empheq}
\end{small}
The above formulas show how to update the model parameter and sample weights at the $t^{th}$ iteration. Among these formulas, Equation \eqref{eq: model_pre_update} tries to update the model parameter $\Theta_t$ given the current sample weights $\textbf{W}_t=[w_{1,t},w_{2,t},\dots,w_{N,t}]$, which is then employed for updating the sample weights in Equation \eqref{eq: sample_weights_update}. Afterwards, in Equation \eqref{eq: model_post_update}, the updated sample weights, $\textbf{W}_{t+1}$, are inserted into Equation \eqref{eq: model_pre_update} to obtain the model parameters for the next iteration, i.e., $\Theta_{t+1}$. This process is then repeated until the convergence.
\section*{Checklist}
\begin{enumerate}
\item For all authors...
\begin{enumerate}
\item Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope?
\answerYes{}
\item Did you describe the limitations of your work?
\answerYes{} See Appendix \ref{appendix: limitation}
\item Did you discuss any potential negative societal impacts of your work?
\answerYes{} See Apppendix \ref{appendix: social_impact}
\item Have you read the ethics review guidelines and ensured that your paper conforms to them?
\answerYes{}
\end{enumerate}
\item If you are including theoretical results...
\begin{enumerate}
\item Did you state the full set of assumptions of all theoretical results?
\answerYes{}
\item Did you include complete proofs of all theoretical results?
\answerYes{See Appendix \ref{appedix:derivation_method_one_objective}, \ref{sec: theorem_main}.}
\end{enumerate}
\item If you ran experiments...
\begin{enumerate}
\item Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
\answerYes{Included in the supplemental material.}
\item Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
\answerYes{See Section \ref{sec: experiment_setup} and the Appendix for more details.}
\item Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
\answerYes{We report error bars for the class imbalance experiments and have more complete results for the label noise experiments in Appendix \ref{sec: supple_exp}.}
\item Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?
\answerYes{See Section \ref{sec: experiment}.}
\end{enumerate}
\item If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
\begin{enumerate}
\item If your work uses existing assets, did you cite the creators?
\answerYes{}
\item Did you mention the license of the assets?
\answerYes{}
\item Did you include any new assets either in the supplemental material or as a URL?
\answerNo{}
\item Did you discuss whether and how consent was obtained from people whose data you're using/curating?
\answerNA{}
\item Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?
\answerNo{We use only MNIST\ and CIFAR\ datasets.}
\end{enumerate}
\item If you used crowdsourcing or conducted research with human subjects...
\begin{enumerate}
\item Did you include the full text of instructions given to participants and screenshots, if applicable?
\answerNA{}
\item Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?
\answerNA{}
\item Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
\answerNA{}
\end{enumerate}
\end{enumerate}
\section{Conclusion}
In this work, we propose a clustering-based framework for selecting pivotal samples to improve performance of meta re-weighting in the presence of various defects on training data. Based on our theoretical analysis, we show that selecting pivotal samples can be reduced to a weighted K-means algorithm under reasonable assumptions. To efficiently evaluate this algorithm we propose two methods, RBC\ and GBC, which can balance the computational efficiency and prediction performance.
Through empirical studies on noisily labeled and class-imbalanced image classification benchmark datasets, we can demonstrate that
our technique could select a better set of pivotal samples for meta re-weighting algorithm than other sample selection techniques, thereby resulting in better model performance.
\section{Experiments}\label{sec: experiment}
We demonstrate the effectiveness of our methods for training deep neural nets on image classification datasets, MNIST\ \cite{deng2012mnist}, CIFAR-10\ \cite{krizhevsky2009learning} and CIFAR-100\ \cite{krizhevsky2009learning}, and \revise{Imagenet-10\ \cite{russakovsky2015imagenet}\footnote{Imagenet-10\ is a subset of ImageNet and produced by following \cite{li2021contrastive}}}.
By following \cite{shu2019meta} and \cite{ren2018learning}, we consider the occurrence of noisy labels and class imbalance respectively on the training set. All the code is publicly available\footnote{\url{https://github.com/thuwuyinjun/meta_sample_selections}}.
\begin{table*}[t]
\caption{Test accuracy on MNIST, CIFAR-10\ and CIFAR-100\ dataset with noise rate 60\%}\label{table: noise_label}
\small
\centering
\begin{tabular}[!h]{>{\arraybackslash}p{1.5cm}|>{\centering\arraybackslash}p{1.5cm}|>{\centering\arraybackslash}p{1.35cm}>{\centering\arraybackslash}p{1.5cm}|>{\centering\arraybackslash}p{1.35cm}>{\centering\arraybackslash}p{1.4cm}|>{\centering\arraybackslash}p{0.8cm}>{\centering\arraybackslash}p{1.3cm}} \hline\hline
Dataset &\multicolumn{1}{c|}{MNIST}&\multicolumn{2}{c|}{CIFAR-10}&\multicolumn{2}{c}{CIFAR-100}&\multicolumn{2}{|c}{\makecell{Imagenet-10}} \\ \hline
Noise type &adversarial&uniform&adversarial&uniform&adversarial&uniform&adversarial\\ \hline
Base model & 51.74$\pm$1.52 & 77.74$\pm$1.22 & 40.24$\pm$0.39 &43.63$\pm$2.30 & 27.15$\pm$0.40 & 72.22&38.00 \\
Random &85.67$\pm$0.90 & 73.56$\pm$0.40 & 76.02$\pm$2.01 & 42.30$\pm$4.68 & 45.33$\pm$1.70 &93.33 & 59.77\\
Certain &81.84$\pm$0.89 & 74.76$\pm$1.07 &70.78$\pm$5.00 & 45.95$\pm$4.20 & 47.06$\pm$2.10 &91.20 &58.22\\
Uncertain &76.38$\pm$0.54 & 73.83$\pm$0.24 & 74.45$\pm$6.10& 36.67$\pm$0.20 & 44.65$\pm$0.65 &85.22 & 51.00\\
Fine-tuning & 53.39$\pm$1.22& 78.46$\pm$2.10 &23.07$\pm$7.58 &25.28$\pm$1.13 & 24.88$\pm$1.10 & 70.44&35.67\\
TA-VAAL &79.31$\pm$0.23 &72.89$\pm$0.82 & 61.46$\pm$4.65&31.07$\pm$2.56&38.79$\pm$0.86&86.34 &43.26 \\
craige & 92.84$\pm$0.14&78.77$\pm$0.86 &78.55$\pm$1.03 &39.85$\pm$1.23&44.61$\pm$1.21&88.90 & 61.00\\
RBC-K &\underline{93.78$\pm$0.61}&77.91$\pm$1.43&75.71$\pm$1.22&49.32$\pm$0.35&49.51$\pm$0.43& 91.33&54.67 \\ \hline
RBC &93.00$\pm$1.01 & \underline{80.15$\pm$0.25} &\underline{79.20$\pm$0.64} & \underline{49.56$\pm$0.53} & \underline{50.60$\pm$1.51}&\textbf{94.22}&\textbf{63.67} \\
GBC &\textbf{94.26$\pm$0.24} &\textbf{80.36$\pm$0.96}&\textbf{80.88$\pm$1.46}& \textbf{50.88$\pm$1.90} & \textbf{53.14$\pm$1.33}&\underline{94.00}&\textbf{63.67} \\ \hline\hline
\end{tabular}
\end{table*}
\subsection{Experimental set-up}\label{sec: experiment_setup}
For the MNIST\ dataset, we train a LeNet model \cite{lecun1998gradient} and for CIFAR-10, CIFAR-100\ and Imagenet-10\ dataset, we train a ResNet-34 model \cite{he2016deep}.
All the hyper-paremters are reported in Appendix \nameref{sec: supple_exp}.
\begin{table}[t]
\centering
\begin{small}
\begin{tabular}[!h]{>{\arraybackslash}p{1.5cm}|>{\centering\arraybackslash}p{1.6cm}>{\centering\arraybackslash}p{1.6cm}} \hline\hline
Dataset &\multicolumn{1}{c}{CIFAR-10}&\multicolumn{1}{c}{CIFAR-100} \\ \hline
BaseModel & 61.45$\pm$0.60& 28.14$\pm$0.57 \\
Random & 65.96$\pm$1.74 & 29.29$\pm$0.46 \\
Uncertain & 64.46$\pm$1.20 & 28.39$\pm$0.21 \\
Certain & 66.05$\pm$1.19 & 28.52$\pm$0.15 \\
Fine-tuning\ & 60.04$\pm$1.69 & 29.73$\pm$0.06\\
TA-VAAL & 61.58$\pm$1.21 & 30.89$\pm$1.09 \\
craige &66.60$\pm$0.89 & 29.56$\pm$1.46\\
RBC-K& 65.96$\pm$1.02 &30.77$\pm$1.23 \\ \hline
RBC\ & \textbf{68.18$\pm$1.58} & \underline{31.78$\pm$1.10} \\
GBC\ & \underline{67.37$\pm$1.51} & \textbf{33.87$\pm$0.66} \\\hline\hline
\end{tabular}
\hfill
\caption{Test performance on imbalanced CIFAR-10\ and CIFAR-100\ dataset with imbalanced factor 200}\label{Table: cifar_imb}
\end{small}
\end{table}
\begin{figure}
\centering
\includegraphics[
width=0.35\textwidth
]{Figures/performance_with_noise.pdf}
\captionof{figure}{Test performance on MNIST\ dataset with varied noisy rate}\label{fig: mnist_vary_noise}
\end{figure}
\subsection{Noisy label experiments}
We first study how our methods perform in the presence of two types of label noise, i.e., {\em uniform noise} and {\em adversarial noise}:
\begin{itemize}[leftmargin=*, noitemsep,topsep=0pt]
\item {\em uniform noise}: all labels can be uniformly flipped at random to any other label with probability $p/100$, in which $p$ is a percent specified by users. This has been explored in \cite{shu2019meta} and \cite{ren2018learning};
\item {\em adversarial noise}:
the labels for a subset of samples, chosen at random, are determinisitcally mapped to another label (e.g., selected samples with label 0 are all given label 1).
This is meant to simulate an extreme case where the labels are {\em adversarially} flipped and has been explored in some prior works (e.g., \cite{li2022selective})
\end{itemize}
We present the results with one fixed noise rate, $p = 60$, for both types of noise on MNIST, CIFAR\ and Imagenet-10\ and \revise{the effect of varied $p$ is also explored on the MNIST\ dataset (see Figure \ref{fig: mnist_vary_noise})}. Surprisingly, we found that 60\% uniform noise only reduces the model accuracy on MNIST\ by a few percent. We therefore only report the results on MNIST\ with adversarial noise.
Throughout this experiment, we compare RBC\ and GBC\ against the following baseline methods:
\begin{itemize}[leftmargin=*, noitemsep,topsep=0pt]
\item \textbf{Random selection} (\textit{Random}): We uniformly at random select meta samples from the training set;
\item \textbf{Fine-tuning}: We fine-tune the model using only the selected meta samples, selected by Random;
\item \textbf{Active learning}: We select meta samples using 1) \textbf{Uncertainty based selection} (\textit{Uncertain}) \cite{lewis1994sequential}
by selecting the {\em most uncertain} training samples, 2) \textbf{Certainty based selection} (\textit{Certain})
by selecting the {\em most certain} training samples and 3) two state-of-the-art active learning solutions, \textbf{Task-Aware Variational Adversarial Active Learning} (\textit{TA-VAAL}) \cite{kim2021task} and \textbf{craige} (\textit{craige}) \cite{mirzasoleiman2020coresets}
\item \textbf{RBC-k}: We use the original K-means clustering algorithm rather than the weighted version proposed in Section \nameref{sec: solve_mco} to determine the meta samples in RBC.
\end{itemize}
Note that for both of our methods and the above baseline methods, the labels of the selected meta samples are cleaned by human annotators, which is simulated by replacing their noisy labels with ground-truth labels. This thus justifies the use of the perfectly labeled benchmark datasets (rather than real datasets with unreliable labels). As a result, for fair comparison, our methods and the above baseline methods share the same labeling budget, which is set as 20, 50, 200 and 50 for MNIST, CIFAR-10, CIFAR-100\ and Imagenet-10\ respectively (\revise{which includes the labeled samples in the pre-training phase}). We pre-train the models by running the meta re-weighting algorithm with small amount of randomly selected meta samples (10 for MNIST, 10 for CIFAR-10, 50 for CIFAR-100\ and 10 for Imagenet-10) since selecting those meta samples one time leads to sub-optimal performance\footnote{We empirically show this in Appendix \nameref{sec: supple_exp}}, \revise{which is applied to all the baseline methods for fair comparison}.
\begin{table}
\caption{The AUC score of the sample weights on MNIST\ with noise rate 80\%}\label{Table: mnist_sample_weights}
\small
\centering
\begin{tabular}[!h]{>{\arraybackslash}p{1cm}|>{\centering\arraybackslash}p{1cm}>{\centering\arraybackslash}p{1cm}} \hline\hline
Method &All& Boundary \\ \hline
Random & 0.922 & 0.589 \\
RBC\ & \textbf{0.958} &0.775 \\
GBC\ & 0.949 & \textbf{0.854}\\\hline\hline
\end{tabular}
\end{table}
\paragraph{Overall performance} We present the test accuracy in Table \ref{table: noise_label}\footnote{We report the validation accuracy for Imagenet-10\ since the ground-truth labels of test samples are invisible} after running the meta re-weighting algorithm with meta samples selected by different methods. As indicated by this table, the clustering-based methods, RBC-k, RBC\ and GBC\ can significantly outperform other methods in most cases and the performance gains are up to~6\% (see the performance difference between GBC\ and Certain\ in column ``adversarial'' of CIFAR-100\ dataset).
\revise{Furthermore, RBC\ consistently outperforms RBC-K, which suggests the weighted K-means algorithm is capable of identifying a better set of meta samples than the original K-means algorithm.}
\paragraph{Efficiency of RBC} \revise{We also observe a trade-off between performance and speed when comparing GBC\ and RBC. According to Table \ref{table: noise_label}, GBC\ performs better than RBC\ in most cases while the former is slower than the latter (2.5 hours VS 3 mins) to construct $\concatvec{j}$. \revise{Note that the running time of RBC\ is negligible in comparison to the running time of the meta re-weighting algorithm, which is around 4 mins per epoch and there are hundreds of epochs in total.}}
\paragraph{Robustness against varied noise rate} \revise{As indicated by Figure \ref{fig: mnist_vary_noise}, both RBC\ and GBC\ outperform all the baseline methods across all the noise rates and the performance gains become even larger with more samples being noisily labeled (up to 2\%). This indicates the robustness of our methods against a varied level of label noise.}
\paragraph{Sample weight distributions} \revise{Recall that our methods depend on the assumption that larger updates to the sample weights will more effectively result in the weights of the noisy and clean samples approaching 0 and 1 respectively. We therefore empirically verify this assumption by inspecting the sample weights learned by Random, RBC\ and GBC. Specifically, we calculate the AUC between the learned sample weights and the cleanness of the sample labels (1 for clean while 0 for corrupt). We report this quantity for MNIST\ with 80\% noisy labels in Table \ref{Table: mnist_sample_weights} for the entire training set and for the 1000 samples nearest to the decision boundary\footnote{We measure the distance between each sample and the decision boundary by utilizing the metric proposed by \cite{elsayed2018large}}. As Table \ref{Table: mnist_sample_weights} shows, the AUC of RBC\ and GBC\ are significantly higher than that of Random, especially for those samples near the boundary, thus suggesting the capability for RBC\ and GBC\ to better distinguish between clean and noisy samples. This could thus explain why RBC\ and GBC\ achieve superior performance according to Table \ref{fig: mnist_vary_noise}, thereby verifying our assumption.}
\subsection{Class imbalance experiments}
For evaluating our method on class imbalanced data, we follow \cite{cui2019class} to produce the long-tailed CIFAR\ dataset. Specifically, we down-sample some classes so that the ratio between the number of training samples in the largest class and that in the smallest one (which is denoted the {\em imbalance factor}) is large. \revise{In Table \ref{Table: cifar_imb}, we report the results with imbalance factor 200 on CIFAR-10\ and CIFAR-100\ dataset}.
As shown in Table \ref{Table: cifar_imb}, our method, RBC, outperforms all the baseline methods for CIFAR-10\ and CIFAR-100\, and the performance gain is up to 3.10\%.
\subsection{Other experimental results}
\revise{Due to the space limit, all other experimental results are presented in Appendix: \nameref{sec: supple_exp}, including the experiments with real labeling noise on CIFAR\ dataset, the effect of the pre-training phase, the effect of varied number of meta samples, the effect of the number of sampled gradients in RBC\ and GBC\ (recall that both approximate Equation \eqref{eq: weighted_k_means_obj_0} through sampling according to Section: \nameref{sec: solve_mco}), and some qualitative studies.}
\section{Introduction}
\label{sec: intro}
Recently, with the advent of the data-centric AI era \cite{miranda2021towards, polyzotis2021can, hajij2021data}, there is an increasing concern about the {\em quality} of data for training neural network models.
How to construct and maintain a high-quality data set is extremely challenging due to the existence of various defects in real-life data, e.g., imperfect labels or imbalanced distributions across classes.
To tackle these issues, various techniques have been explored.
One such example is \revise{the} sample re-weighting \revise{strategy} \cite{shu2019meta,ren2018learning,hu2019learning, jiang2018mentornet,chang2017active}, which target\revise{s} jointly learning to obtain {\em re-weighted} training samples and training neural nets upon them.
One promising strategy for learning to re-weight training samples is to leverage the framework of meta learning \cite{hospedales2021meta, andrychowicz2016learning, thrun2012learning} by formulating this problem as a bi-level optimization problem \cite{shu2019meta,ren2018learning,hu2019learning}.
In this approach, the weights of training samples are learned so that the performance of the models learned on the re-weighted training samples is maximized on a small set of perfect samples---referred to as {\em meta samples}.
Existing works mainly focus on designing computationally efficient algorithms for solving this bi-level optimization problem.
For example, \cite{shu2019meta} propose a {\em meta re-weighting} algorithm which alternates between updates to the model parameters and the sample weights.
These algorithms, however, rely on the assumption that the meta sample set is {\em given}, and they construct this set by random sampling in their empirical studies.
However, as the toy example in Figure \ref{fig:toy_boundaries} shows, randomly selected meta samples may perform worse than carefully selected ones by using our methods (62.9\% vs.\ 87.1\% on test accuracy), which we further verify in Section \nameref{sec: experiment}.
\begin{figure*}
\centering
\includegraphics[width=0.9\textwidth]{Figures/toy_decision_boundaries_fixed.pdf}
\caption{We produce a toy two-dimensional dataset by drawing 1000 samples from a mixture of four Gaussian distributions over two variables where the distributions are centered at the four vertices of the 2-dimensional hypercube. The upper two distributions are labeled green while the lower two are labeled red and 1\% of the labels are flipped to introduce a small amount of noise to the ground truth. We visualize all the samples with their ground-truth labels in this figure. This toy dataset is then divided into 600 training, 240 testing, and 160 validation samples using a random partition, and a randomly selected 60\% of the training labels are flipped. To learn a robust model (which is a neural network with two hidden layers in this example) on this noisy training set, we employ the meta-reweighting algorithm with 6 cleaned meta samples.
We then show the selected meta samples (outlined with stars) and the learned decision boundaries (shaded regions) from our methods and the random selection method. The expected classifier, i.e., the learned classifier (black dotted line) on the ``clean'' training set is also visualized.
By examining the learned classifier from these methods,
we see that the one learned by random selections deviates farther from the expected classifier, thus leading to worse prediction performance than our methods (56.3\% vs. 92.0\%).
}
\label{fig:toy_boundaries}
\end{figure*}
In this paper, we study how to learn to identify a set of meta samples from a large, imperfect training set such that the {\em meta re-weighting} performance is optimized. Specifically, we propose a framework which reduces the problem of selecting such meta samples to a weighted K-means clustering problem through rigorous theoretical analysis. This derivation basically transforms the formula for iteratively updating sample weights from the meta re-weighting algorithm into a weighted K-means clustering objective function. We can show that \textit{optimizing this objective function can aid in effectively distinguishing high-quality training samples from low-quality ones by giving them more confident sample weights (i.e. weights close to 0 or 1)}.
This objective function, however, requires the gradients of {\em each individual training sample} as input, which is computationally expensive. To facilitate efficient evaluation of this objective function, we propose two methods, i.e. Representation-based clustering method\ (RBC) and Gradient-based clustering method\ (GBC), which balance performance with computational efficiency. Specifically, by assuming that the gradients of the bottom layers of the neural nets are insignificant, RBC\ only utilizes the gradient of the last layer, which is efficiently calculated through feed-forward passes. In contrast, GBC\ samples model parameters such that the estimation of the objective function in the above K-means problem is unbiased. Due to the necessity of explicitly (but partially) computing sample-wise gradients, GBC\ is slower than RBC, but can lead to better model performance in most cases.
We further explore whether our methods select reasonable meta samples for re-weighting noisily labeled data and class-imbalanced data by
conducting experiments on re-weighting MNIST, CIFAR, and Imagenet-10\ datasets in the presence of noisy labels or imbalanced class distribution. The results show that with the same meta re-weighting algorithm, our methods outperform other sample selection strategies in most cases.
\section*{Method}\label{sec: method}
Unlike \cite{shu2019meta, hu2019learning, ren2018learning} where the meta set $D_{\text{meta}}$ is assumed to be given, our goal is to select this set from $D_{\text{train}}$. Once this meta set is selected and possibly cleaned by humans (when noisy labels exist), the meta re-weighting algorithm can be used. We hope that the resulting model performance is optimized with respect to the sample selection strategy. We observe that one critical property of such $D_{\text{meta}}$ is that it needs to produce \textit{``significant'' cumulative gradient updates (rather than near-zero gradient) in Equation \eqref{eq: sample_weights_update} for every training sample $j (=1,2,\dots,N)$ and every iteration $t$ in the meta re-weighting algorithm}. This can thus guarantee that good training samples are efficiently up-weighted while bad training samples are efficiently down-weighted.
Therefore, our goal is to maximize the magnitude of the sum of the gradient in Equation \eqref{eq: sample_weights_update} evaluated for each training sample $j$, across all iterations:
\begin{small}
\begin{align}\label{eq: meta_reweighting_goal}
\begin{split}
& \max_{D_{\text{meta}}}\left|\sum\nolimits_{\hat{\Theta}(\textbf{W}_t)} 1/M\cdot\sum\nolimits_{i=1}^M \nabla_{w_j} \mf{i}{\hat{\Theta}(\textbf{W}_t)}\right|,\\
&\text{for all $j=(1,2,\dots,N)$},
\end{split}
\end{align}
\end{small}
which we rewrite as follows according to \cite{shu2019meta} (the constant coefficients are ignored below):
\begin{small}
\begin{align}\label{eq: gradient_inner_prod}
\begin{split}
& \max_{D_{\text{meta}}}\left|\sum_{\hat{\Theta}(\textbf{W}_t), \Theta_t}\sum_{i=1}^M \langle\nabla_{\Theta} \mf{i}{\Theta}|_{\Theta = \hat{\Theta}(\textbf{W}_t)}, \nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t}\rangle\right|,
\end{split}
\end{align}
\end{small}
which thus
represents \textit{the Frobenius inner product of the gradient of the loss} between the meta sample $i$ and the training sample $j$.
If the above inner product is large enough, the weight of this sample will be significantly updated. Since we want to maximize the updates of the weight of each training sample, we sum up the above formula over all training samples, leading to:
\begin{small}
\begin{align*}
\begin{split}
& \max_{D_{\text{meta}}}\sum_{j=1}^N{\left|\sum_{\hat{\Theta}(\textbf{W}_t), \Theta_t}\sum_{i=1}^M \langle\nabla_{\Theta} \mf{i}{\Theta}|_{\Theta = \hat{\Theta}(\textbf{W}_t)}, \nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t}\rangle\right|},
\end{split}
\end{align*}
\end{small}
which can be further approximated as follows by leveraging the fact that $\hat{\Theta}(\textbf{W}_t)$,
is very close to $\Theta_t$:
\begin{small}
\begin{align}\label{eq: our_init_objective0}
\begin{split}
\max_{D_{\text{meta}}}\sum_{j=1}^N{\left|\sum_{i=1}^M \sum_{\Theta_t}\textcolor{blue}{\langle\nabla_{\Theta} \mf{i}{\Theta}|_{\Theta =\Theta_t}, \nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t}\rangle}\right|}
\end{split}
\end{align}
\end{small}
Equation \eqref{eq: our_init_objective0} can be further rewritten as the following Meta-Sample Search Objective (MSSO):
\begin{small}
\begin{align}\label{eq: our_init_objective}
\begin{split}
& \text{MSSO} := \text{Equation }\eqref{eq: our_init_objective0} = \max_{D_{\text{meta}}}\sum_{j=1}^N \left|\sum_{i=1}^M \langle\concatvec{j}, \concatvec{\text{meta}, i}\rangle\right|,
\end{split}
\end{align}
\end{small}
in which, we define
$\concatvec{j} = \left[\concatvec{j}^{(1)}, \dots,\concatvec{j}^{(t)},\dots\right]$ and
$\concatvec{\text{meta},i} = \left[\concatvec{\text{meta},i}^{(1)}, \dots,\concatvec{\text{meta},i}^{(t)},\dots\right]$
as block matrices formed by concatenating the gradients,
$\concatvec{\text{meta},i}^{(t)} := \nabla_{\Theta} \mf{i}{\Theta}|_{\Theta = \Theta_t}$ and
$\concatvec{j}^{(t)} := \nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t}$,
from each iteration into one matrix.
Note that the meta sample set, $D_{\text{meta}}$, needs to be selected from the training set, $D_{\text{train}}$. Thus, explicitly solving MSSO
is computationally intractable since there are ${N\choose M}$ possible selections of a meta set of size $M$.
In what follows, we present an approximation to MSSO with rigorous guarantees, \revise{which can be effectively solved with a weighted K-means clustering algorithm.}
\subsection*{Approximating MSSO}
We
show that with reasonable assumptions, solving MSSO is approximately equivalent to searching for a set of cluster centroids, $\mathcal{C} = \{C_i\}_{i=1}^M$, i.e.,:
\begin{small}
\begin{align*}
\begin{split}
&\text{MSSO}
\approx \max_{\mathcal{C}}\sum\nolimits_{j=1}^N\left| \sum\nolimits_{i=1}^M \langle\concatvec{j}, C_i\rangle\right|\\
\end{split}
\end{align*}
\end{small}
which can be approximated by solving the following $M$-clustering objective (MCO)
\begin{small}
\begin{align}\label{eq: transformed_k_means_objective}
\begin{split}
&\text{MSSO}
\approx \text{MCO}:= \max_{\mathcal{C}}\sum\nolimits_{j=1}^N \sum\nolimits_{i=1}^M \left|\langle\concatvec{j}, C_i\rangle\right|,
\end{split}
\end{align}
\end{small}
where MSSO is approximated by moving the absolute value to the inside of the sum.
The approximation above can be justified by the following Theorem.
\begin{theorem}\label{theorem: main}
Suppose that for each sample $i$, the positive terms in the innermost sum of Equation \eqref{eq: our_init_objective} are dominant over the negative terms or vice versa, i.e.:
\begin{small}
\begin{align*}
& \frac{|\sum_{\langle\concatvec{j}, C_i\rangle > 0}\langle\concatvec{j}, C_i\rangle|}{|\sum_{\langle\concatvec{j}, C_i\rangle < 0}\langle\concatvec{j}, C_i\rangle|} > D \gg 1, \\
&\text{or } \frac{|\sum_{\langle\concatvec{j}, C_i\rangle < 0}\langle\concatvec{j}, C_i\rangle|}{|\sum_{\langle\concatvec{j}, C_i\rangle > 0}\langle\concatvec{j}, C_i\rangle|} > D \gg 1, \text{for all $i$},
\end{align*}
\end{small}
then solving MCO is a $\frac{D-1}{D+1}$-approximation to solving MSSO, i.e., $\frac{D-1}{D+1} \leq \frac{MSSO}{MCO} \leq 1$
\end{theorem}
The proof is included in Appendix \nameref{sec: theorem_main}. Intuitively, we can see that our approximation is perfect when each inner product in \eqref{eq: our_init_objective} is positive, and we have less of a guarantee of the effectiveness when a cluster is less homogeneous in the sign of the inner products between its members and centroid. Indeed, we found that the assumptions in the above theorem hold in most cases (see Appendix \nameref{sec: supple_exp}).
Therefore, due to the closeness of MSSO and MCO, we focus on solving MCO rather than MSSO.
\begin{figure*}
\centering
\includegraphics[
width=0.9\textwidth
]{Figures/overview.jpg}
\captionof{figure}{Overview of our methods, RBC\ and GBC. We use \textcolor{methodonecolor}{$\rightarrow$} (green colored arrow) and \textcolor{methodtwocolor}{$\rightarrow$} (purple colored arrow) to denote the data flow of RBC\ and GBC\ respectively. Specifically, at each sampled time step $t_k$, for each input training sample $(\textbf{x}_j,y_j)$, RBC\ combines its feature vector from the input to the last layer of the model, $\Tilde{\textbf{x}_j}$, and the coefficient, $\textbf{A}_{j}(\Theta_{t_k})$ (defined in Equation \eqref{eq: method_one_coeff0}) while GBC\ concatenate the gradients from the sampled layers in the model. We then concatenate the above calculated results from all the time steps $t_1,t_2,\dots$ to compose the input to weighted K-means clustering algorithm, $G_j$ (see the red dotted box), which is then used for determining the meta samples.}\label{fig: method_overview}
\end{figure*}
\subsection*{Solving MCO}\label{sec: solve_mco}
MCO resembles the K-means clustering objective, so it is promising to solve it with the K-means clustering algorithm. As the first step toward this, MCO is transformed to the following form:
\begin{small}
\begin{align}\label{eq: weighted_k_means_obj_0}
\begin{split}
\text{MCO} &=\max_{\mathcal{C}}\sum_{j=1}^N \|\concatvec{j}\| \sum_{i=1}^M \|C_i\|\cdot |\text{cosine}(\concatvec{j}, C_i)|,
\end{split}
\end{align}
\end{small}
which can be regarded as a weighted K-means clustering objective function.
Specifically,
the norm of each $C_i$ is used for re-weighting the cosine similarity between each training sample $j$ and each cluster centroid $i$, which is followed by re-weighting the overall similarity of each training sample $j$ to \textit{all} cluster centroids with the norm of $\concatvec{j}$.
Further details on how to tailor the vanilla K-means clustering algorithm to solve MCO are presented in Appendix \nameref{appendix: k_means}.
After $\mathcal{C} = \{C_i\}_{i=1}^M$ is identified by this weighted K-means algorithm, the samples closest to each cluster centroid are returned as the selected meta samples, $D_{\text{meta}}$\footnote{We notice that other strategies, e.g., \cite{auvolat2015clustering}, can be employed to solve MCO, which, however\revise{,} do not \revise{perform} well and are thus ignored. }.
Note that in Equation \eqref{eq: transformed_k_means_objective}, collecting all $\concatvec{j}$ is very expensive.
This is because $j$ is over all training samples which can be very large,
and $\concatvec{j}$ depends on all $\Theta_t$, i.e., the model parameters at all iterations (see Equation \eqref{eq: our_init_objective}).
To address the above efficiency concerns, we firstly propose two methods, i.e., Representation-based clustering method\ (RBC) and Gradient-based clustering method\ (GBC) in Section \nameref{sec: method_one} and Section \nameref{sec: method_two} respectively, for addressing the first concern. We further discuss how to sample from all $\Theta_t (t=1,2,\dots)$ in Section \nameref{sec: chicken_egg_problem} to handle the second concern.
\subsubsection{Representation-based clustering method\ (RBC)}\label{sec: method_one}
RBC\ is built upon the assumption that
the gradient of the model parameters on the bottom layers (i.e. those layers closer to the input) is less significant than the ones in the last layer. Due to the vanishing gradient problem, this assumption usually holds in practice. As a consequence, we
only consider the gradients from the last layer in \text{Equation }\eqref{eq: transformed_k_means_objective}, leading to the following approximations on $\concatvec{j}$:
\begin{small}
\begin{align}\label{eq: method_one_objective_function}
\begin{split}
\concatvec{j} = \textbf{A}_{j}(\Theta_t)\Tilde{\textbf{x}_j}(\Theta_t)^\top,
\end{split}
\end{align}
\end{small}
in which
$\Tilde{\textbf{x}_j}(\Theta_t)$ represents the input to the last linear layer in the neural network model produced by the
training sample $j$, while $\textbf{A}_{j}(\Theta_t)$
is defined as follows:
\begin{small}
\begin{align}\label{eq: method_one_coeff0}
& \textbf{A}_{j}(\Theta_t) = \text{softmax}(\Theta_t^{(-1)}\Tilde{\textbf{x}_j}(\Theta_t)) - \text{onehot}(y_j)
\end{align}
\end{small}
in which $\Theta_t^{(-1)}$ represents the model parameters in the last layer. The detailed derivation of Equation \eqref{eq: method_one_objective_function} is included in Appendix \nameref{appedix:derivation_method_one_objective}. Equation \eqref{eq: method_one_objective_function}-\eqref{eq: method_one_coeff0} shows that to obtain $\concatvec{j}$,
only forward passes on the models are needed, which makes this method very efficient.
\subsubsection{Gradient-based clustering method\ (GBC)}\label{sec: method_two}
Unlike RBC, GBC\ is applicable to general cases where the gradients generated by the bottom neural layers may be significant. To facilitate efficient evaluations of MCO, we importance sample the network layers from the model, such that we can obtain an unbiased estimation of Equation \eqref{eq: transformed_k_means_objective}. Then $\concatvec{j}$ is constructed by concatenating the gradients calculated in those sampled layers.
Specifically, first of all, the blue part of Equation \eqref{eq: our_init_objective0} (which is the essential part of Equation \eqref{eq: transformed_k_means_objective}) can be rewritten in terms of a sum over the model parameters at each layer $l \in [1,2,\dots, L]$, i.e.:
\begin{small}
\begin{align}\label{eq: inner_prod_by_layer}
\begin{split}
&\langle\nabla_{\Theta} \mf{i}{\Theta}|_{\Theta = \Theta_t}, \nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t}\rangle\\
& = \left[\sum\nolimits_{l=1}^L \langle\nabla_{\Theta^{(l)}} \mf{i}{\Theta}), \nabla_{\Theta^{(l)}} \f{j}{\Theta})\rangle\right]_{\Theta = \Theta_t},
\end{split}
\end{align}
\end{small}
in which $\Theta^{(l)}$ represents the model parameters at the $l^{th}$ layer. Then the above formula could be rewritten as follows:
\begin{small}
\begin{align}\label{eq: inner_prod_by_layer_by_importance_score}
\begin{split}
&\text{Equation }\eqref{eq: inner_prod_by_layer} \\
& = A\cdot\left[\sum_{l=1}^L \frac{A^{(l)}}{A} \langle\frac{\nabla_{\Theta^{(l)}} \mf{i}{\Theta}}{\sqrt{A^{(l)}}}, \frac{\nabla_{\Theta^{(l)}} \f{j}{\Theta}}{\sqrt{A^{(l)}}}\rangle\right]_{\Theta = \Theta_t},
\end{split}
\end{align}
\end{small}
in which, $A^{(l)} = \|\frac{1}{N}\sum_{j=1}^N \nabla_{\Theta^{(l)}} \f{j}{\Theta}\|_F^2$ and $A=\sum_{l=1}^L A^{(l)}$
Then we can conduct importance sampling (with replacement) on the $L$ innermost sums in Equation \eqref{eq: inner_prod_by_layer_by_importance_score} for several times (say 5 times)\footnote{we conduct the importance sampling once for all the samples so that the dimension of $\concatvec{j}$ is the same among all the samples. Although it is not rigorously correct, the empirical studies show that this approximation could achieve good performance}, in which the probability of selecting the $l^{th} (l=1,2,\dots,L)$ term is $A^{(l)}/A$. This leads to an unbiased estimation of Equation \eqref{eq: inner_prod_by_layer_by_importance_score} and significant speed-ups.
\subsubsection{Sampling model parameters from history}\label{sec: chicken_egg_problem}
It is worth noting that $\Theta_t$ is unknown before we obtain all meta samples (see Equation \eqref{eq: model_pre_update}-\eqref{eq: model_post_update}), but it is essential for determining the meta samples (see Equation \eqref{eq: our_init_objective0}). Therefore, we propose to cache the model parameter $\Tilde{\Theta}_t (t=1,\dots, T)$ during the training process without any available meta samples, which is regarded as an approximation of $\Theta_t$.
In addition, as mentioned above, $\concatvec{j}$ depends on the model parameters from all the time steps, which is thus very expensive to evaluate. We uniformly sample several time steps, instead of using all $\Tilde{\Theta}_t$, to get an unbiased estimation of MCO.
In the end, we visually present both RBC\ and GBC\ equipped with this sampling technique in Figure \ref{fig: method_overview} and include their pseudo-code in Algorithm \ref{alg: rbc_gbc} in Appendix \nameref{appendix: adapted_k_means}.
\section{Related Work}\label{sec: related_work}
\paragraph{Sample re-weighting}
The problem of re-weighting training samples for a neural network model has been extensively studied in the literature. Sample re-weighting can be beneficial for constructing robust neural network models in the presence of many defects in training data, such as corrupted labels \cite{han2018co, ren2018learning, shu2019meta}, biased distributions \cite{khan2017cost, dong2017class}, low cardinalities \cite{hu2019learning} and adversarial attacks \cite{holtz2021learning}. Other than solving this problem within the meta-learning framework (e.g., \cite{shu2019meta, ren2018learning, hu2019learning}), various strategies have been proposed for deriving sample weights. For example, in \cite{wang2017robust}, the sample weights are modeled as a Bayesian latent variable and inferred through probabilistic models. In \cite{jiang2018mentornet}, a mentor network is designed to derive the sample weights such that the target model does not overfit on samples with noisy labels, which falls within the curriculum learning \cite{bengio2009curriculum} framework. In \cite{kumar2010self}, the weights of training samples are determined by their training loss during the training process. However, as \cite{shu2019meta} suggests, these re-weighting techniques all perform worse than the meta re-weighting algorithm in the presence of label noise and distribution imbalance in training data.
\paragraph{Data efficiency}
As mentioned in Section \nameref{sec: intro}, it is critical to obtain large amounts of high-quality training samples for deep neural nets. However, this can be expensive and time consuming since labeling typically requires non-trivial work from human annotators, especially in scientific domains (see e.g, \cite{karimi2020deep, irvin2019chexpert}). High labeling cost is thus a strong motivator for studies on various label efficiency techniques, e.g., active learning (see a survey in \cite{ren2021survey} and some recent works \cite{mirzasoleiman2020coresets}), semi-supervised learning (see \cite{van2020survey}), and weakly-supervised learning (see Snorkel \cite{ratner2017snorkel}) in the past few years. All of these studies aim at minimizing human labeling effort while maintaining relatively high model performance. Note that for the meta re-weighting problem, the construction of perfect meta samples also requires human labeling effort when label noise exists. Therefore, our framework shares the same spirit as the traditional label efficiency research.
\paragraph{Data valuation}
\revise{In the literature, other than active learning, there exists many techniques to quantify the importance of individual samples, e.g., influence function \cite{koh2017understanding} and its variants \cite{wu2021chef}, Glister \cite{killamsetty2021glister}, HOST-CP \cite{das2021finding}, TracIn \cite{pruthi2020estimating}, DVRL \cite{yoon2020data} and Data Shapley value \cite{ghorbani2019data}. However, among these methods, Data Shapley value \cite{ghorbani2019data} is very computationally expensive while others rely on the assumption that a set of ``clean'' validation samples (or meta samples) are given, which is thus not suitable for our framework (we have more detailed discussions on Data Shapley value and its extensions in Appendix \nameref{appendix: related_work}). We therefore do not include these solutions as baseline methods. }
\section{Appendix: more related work}\label{appendix: related_work}
\subsection{Extra related work on Shapley-value based data valuation}
Due to the space limit of the main paper, we provide here a more extensive discussion on the existing data valuation literature, in particular, the works based on Data Shapley value \citesupp{ghorbani2019data}. We notice that \citesupp{sim2022data} summarized the recent progress in this area.
However, as noted by \citesupp{sim2022data}, these solutions are not scalable to large datasets due to the high computational overhead of data Shapley. It is worth noting that although these solutions, e.g., \citesupp{xu2021validation, sim2020collaborative, xu2021gradient}, claim that they are applicable to realistic large datasets, they only study the data Shapley value of several ``partitions'' of the entire dataset and the number of partitions is typically smaller than 10. In contrast, to identify meta samples for the meta re-weighting algorithm, we need to compute the value of each individual training sample and thus the number of ``partitions'' is equivalent to the number of training samples, which is typically very large. This thus indicates that all the existing data Shapley dependent solutions are computationally intractable for our problem. Although there have been many recent attempts to approximately but efficiently compute data Shapley values, e.g., \citesupp{jia2019towards, yan2021if, jia12efficient}, they are still far from being practical solutions since they either explicitly assume that the models have certain properties, which may not hold for general neural nets (e.g., \citesupp{jia2019towards, jia12efficient}), or still require repetitive training (e.g., \citesupp{yan2021if}). As a consequence, it is still an open challenge to efficiently compute data Shapley values for \textit{each sample} in large datasets for \textit{general neural nets} \citesupp{sim2022data}.
In addition, note that \citesupp{xu2021validation} proposes a data valuation metric without relying on the performance on the validation set, which, however, is built upon the data Shapley value, thus suffering from the efficiency issue as mentioned above.
\section{Appendix: Extra algorithmic details}
\subsection{Supplemental materials on the weighted K-means algorithm}\label{appendix: k_means}
In section \nameref{sec: solve_mco}, we discussed adapting the vanilla K-means clustering algorithm for solving MCO, which is presented in details in this section.
\begin{algorithm}
\textbf{Input}: {A set of gradient vectors $\{\concatvec{j}\}_{j=1}^N$}\\
\textbf{output}: {A set of cluster centroids $\{C_i\}_{i=1}^M$}
\begin{algorithmic}[1]
\STATE Randomly initialize $\{C_i\}_{i=1}^M$
\WHILE{not converged}
\STATE \textbf{Assignment step:} Assign the sample $j$ to the cluster $\hat{i}$ such that $\hat{i} = \text{argmax}_{i}\{\|C_i\|\text{cosine}(\concatvec{j}, C_i)\}_{i=1}^M$.
\STATE \textbf{Update step:} Update the cluster centroid $j$ by Equation \eqref{eq: weighted_k_means_update_step}.
\ENDWHILE
\caption{A weighted K-means clustering algorithm for solving MCO}\label{alg: weighted_k_means}
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\textbf{Input:}{A training set $D_{\text{train}}=\{(\textbf{x}_i,y_i)\}_{i=1}^N$, the total number of training iterations, $T$, the number of the randomly sampled meta samples in the warm-up phase, $M_0$, and a model with model parameter $\Theta$}\\
\textbf{Output:}{A set of meta samples $D_{\text{meta}}$}
\begin{algorithmic}
\STATE Initialize $D_{\text{meta}}=\{\}$
\COMMENT{Warm-up phase}
\STATE Randomly sample $M_0$ meta samples and add them into $D_{\text{meta}}$
\STATE Run meta re-weighting algorithm with $D_{\text{meta}}$ as the meta sample set,
resulting in a list of model parameters $\{\Tilde{\Theta}_t\}_{t=1}^T$ at each iteration.
\WHILE{more validation samples are needed}
\STATE Remove those training samples that are close to $D_{\text{meta}}$ (the similarity measure is the weighted cosine similarity defined in Equation \eqref{eq: weighted_cosine_sim})
\STATE Repetitively run Algorithm \ref{alg: weighted_k_means} until there is no empty clusters, in which \revise{$\{\concatvec{j}\}_{j=1}^N$ is computed}
with RBC\ or GBC, and parameterized by $\{\Tilde{\Theta}_t\}_{t=1}^T$. Suppose this results in cluster centroids $\{C_i\}_{i=1}^M$
\STATE For each $C_i (i=1,2,\dots, M)$, add the closest training sample to this centroid into $D_{\text{meta}}$
\STATE Run meta re-weighting algorithm with $D_{\text{meta}}$ as the meta sample set,
resulting in a list of model parameters $\{\Theta_t\}_{t=1}^T$ at each iteration.
\STATE $\{\Tilde{\Theta}_t\}_{t=1}^T := \{{\Theta}_t\}_{t=1}^T$
\ENDWHILE
\caption{K-means clustering based meta sample selection}\label{alg: overall_algorithm}
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\textbf{Input:}{A set of model parameters $\{\Theta_t\}_{t=1}^T$, the epoch $t^*$ with best validation performance}\\
\textbf{Output:}{$\{\concatvec{j}\}_{j=1}^N$}
\begin{algorithmic}
\STATE Uniformly sample $K$ models from $\{\Theta_t\}_{t=t^*+1}^T$, resulting in $\{\Theta_{t_k}\}_{k=1}^K$ where $t^* < t_1 < t_2 < \dots < t_K$
\STATE Initialize $\{\concatvec{j}\}_{j=1}^N$ so that $\concatvec{j}=[]$ for all $j$.
\FOR{$k=1$ to $K$}
\IF{RBC}
\FOR{$j=1$ to $N$}
\STATE Append $\textbf{A}_{j}(\Theta_{t_k})\Tilde{\textbf{x}_j}(\Theta_{t_k})^\top$ to $\concatvec{j}$ according to Equation \eqref{eq: method_one_objective_function}
\ENDFOR
\ELSIF{GBC}
\STATE Compute $A^{(l)}(\Theta_{t_k})$ and $A(\Theta_{t_k})$ for all $l (l=1,2,\dots,L)$ as described in Section \nameref{sec: method_two}
\FOR{$j=1$ to $N$}
\STATE Conduct importance sampling from $[\nabla_{\Theta^{(1)}}f_j(\Theta_{t_k}) \dots \nabla_{\Theta^{(L)}}f_j(\Theta_{t_k})]$
with sampling probability $[\frac{A^{(1)}(\Theta_{t_k})}{A(\Theta_{t_k})}, \frac{A^{(2)}(\Theta_{t_k})}{A(\Theta_{t_k})}, \dots, \frac{A^{(L)}(\Theta_{t_k})}{A(\Theta_{t_k})}]$, resulting in a list of gradients from $R$ layers: $\text{Grad}_{j} = [\nabla_{\Theta^{(l_1)}}f_j(\Theta_{t_k}), \nabla_{\Theta^{(l_2)}}f_j(\Theta_{t_k}), \dots, \nabla_{\Theta^{(l_R)}}f_j(\Theta_{t_k})]$
\STATE Append $\text{Grad}_{j}$ to $\concatvec{j}$
\ENDFOR
\ENDIF
\ENDFOR
\FOR{$j=1$ to $N$}
\STATE Organize $\concatvec{j}$ as a block matrix
\ENDFOR
\caption{RBC and GBC}\label{alg: rbc_gbc}
\end{algorithmic}
\end{algorithm}
\subsubsection{Details of the adapted K-means algorithm}\label{appendix: adapted_k_means}
We tailor the vanilla K-means clustering algorithm to efficiently solve Equation \eqref{eq: weighted_k_means_obj_0}. Note that the K-means clustering algorithm is composed of two steps, i.e., the \textbf{assignment step} and the \textbf{update step}, which are conducted alternatively until convergence. In the \textbf{assignment step} of the modified K-means clustering algorithm, we follow the same principle of the vanilla K-means clustering algorithm. Specifically, we assign each training sample to its nearest cluster centroid, where the similarity between each training sample $j$ and each cluster centroid $i$ is the cosine similarity weighted by the norm of the centroid $C_i$:
\begin{small}
\begin{align}\label{eq: weighted_cosine_sim}
\begin{split}
\|C_i\|\cdot |\text{cosine}(\concatvec{j}, C_i)|
\end{split}
\end{align}
\end{small}
After each training sample $j$ is assigned to a certain cluster centroid $C_i$, we proceed to update the cluster centroids in the \textbf{update step} given their assigned training samples. Indeed, according to Equation \eqref{eq: weighted_k_means_obj_0}, we conduct clustering on the normalized gradients, $\frac{\concatvec{j}}{\|\concatvec{j}\|}$, rather than $\concatvec{j}$ itself. Plus, since the overall similarity between each training sample $j$ and all clustering centroids is weighted by the norm of $\concatvec{j}$, we therefore update the cluster centroids by leveraging the following formula:
\begin{small}
\begin{align}\label{eq: weighted_k_means_update_step}
\begin{split}
C_i \leftarrow \sum\nolimits_{j \in \text{cluster }i} \frac{\|\concatvec{j}\|\cdot\frac{\concatvec{j}}{\|\concatvec{j}\|}}{\sum\nolimits_{j \in \text{cluster }i} \|\concatvec{j}\|} = \sum\nolimits_{j \in \text{cluster }i} \frac{\concatvec{j}}{\sum\nolimits_{j \in \text{cluster }i} \|\concatvec{j}\|},
\end{split}
\end{align}
\end{small}
in which, the cluster centroid $C_i$ is updated as the weighted mean of all the {\em normalized} samples that are assigned to this cluster.
\revise{The value of each $G_j$ is computed based on if RBC or GBC is used. The details are summarized in Algorithm \ref{alg: rbc_gbc}.}
In the end, we summarize this adapted K-means clustering algorithm in
Algorithm \ref{alg: weighted_k_means}.
\subsubsection{Determining number of clusters and continuously adding meta samples}\label{appendix: cluster_count}
In this section, we further discuss how to determine the number of clusters and how to continuously add meta samples while the meta re-weighting algorithm is repetitively invoked.
First of all, we assume that the number of clusters, $M$, could be provided by the users. However, we observe that given an inappropriately large $M$, empty clusters are often generated, meaning that no samples are assigned to these clusters. Suppose that there are $M_{\text{empty}}$ empty clusters in total, we therefore restart the K-means clustering algorithm with the number of clusters as $M-M_{\text{cluster}}$. This process is repeated until there are no empty clusters. We then identify meta samples with the resulting clusters, which are used in the meta re-weighting algorithm.
Suppose we get model parameters ${\Theta}_t (t=1,2,\dots, T)$ from the meta re-weighting algorithm, we can also optionally run RBC\ or GBC\ again by leveraging ${\Theta}_t$ so that we can add more meta samples. This process is summarized in Algorithm \ref{alg: overall_algorithm}. Note that in the subsequent invocation of RBC\ or GBC, we remove a certain portion of training samples (e.g., half of them) that are closest to the existing meta samples and only cluster the remaining training samples to discover new meta samples.
\section{Appendix: Mathematical details}
\subsection{Derivation of Equation \eqref{eq: gradient_inner_prod}}
First of all, we compute the partial gradient of Equation \eqref{eq: model_pre_update} with respect to $w_j$, i.e.:
\begin{small}
\begin{align}\label{eq: model_preupdate_weight_grad}
\begin{split}
\frac{\partial \hat{\Theta}(\textbf{W}_t)}{\partial w_j}& = \frac{\partial}{\partial w_j}[\Theta_t - \alpha_t \cdot \frac{1}{N}\sum\nolimits_{r=1}^Nw_{r,t} \nabla_{\Theta} \f{r}{\Theta}|_{\Theta = \Theta_t}]\\
& = - \frac{\alpha_t}{N} \nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t},
\end{split}
\end{align}
\end{small}
which utilizes the fact that except for $w_{j,t} \nabla_{\theta} \f{j}{\Theta}$, all the other terms in Equation \eqref{eq: model_pre_update} do not depend on the weight $w_{j,t}$.
In addition, we utilize chain rule on the gradient of Equation \eqref{eq: sample_weights_update}, leading to:
\begin{small}
\begin{align}\label{eq: single_sample_weights_update_2}
\begin{split}
& \nabla_{w_j} \mf{i}{\hat{\Theta}(\textbf{W}_t)}= \langle\nabla_{\Theta}\mf{i}{\Theta}|_{\Theta = \hat{\Theta}(\textbf{W}_t)}, \frac{\partial \hat{\Theta}(\textbf{W}_t)}{w_j}\rangle\\
& = - \frac{\alpha_t}{N} \langle\nabla_{\Theta}\mf{i}{\Theta}|_{\Theta = \hat{\Theta}(\textbf{W}_t)}, \nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t}\rangle
\end{split}
\end{align}
\end{small}
\subsection{Derivation of Equation \eqref{eq: method_one_objective_function}}\label{appedix:derivation_method_one_objective}
In the main paper, we have used $\langle,\rangle$ to denote the \textit{Frobenius inner product} between matrices. But in the following analysis, the inner products between vectors will also appear, which are also conventionally denoted as $\langle,\rangle$. Therefore, to distinguish between these two types of inner products in what follows, we use $\langle,\rangle_F$ rather than $\langle,\rangle$ to represent the Frobenius inner product between matrices while $\langle,\rangle$ is used for representing the inner product between vectors.
First of all, suppose the loss function is cross-entropy loss, then we could have the following lemma for this loss:
\begin{lemma}\label{lemma_cl}
For cross-entropy loss, we can write it as the following form:
\begin{align}\label{eq: cross_entropy}
L(\textbf{x}, y) = \log (\frac{\exp^{-x_j}}{\sum_{k=1}^m \exp^{-x_k}}),
\end{align}
in which we assume that $y = j\ (j \in \{1,2,\dots, m\})$ and $\textbf{x} = [x_1,x_2,\dots, x_m]$ is a vector of length $m$.
Then the gradient of $L(\textbf{x},y)$ with respect to the input $\textbf{x}$ could be split into two parts, i.e. the label-dependent part and the label-free part.
\end{lemma}
\begin{proof}
The gradient of $L(\textbf{x}, y)$ with respect to $\textbf{x}$ could be derived as follows:
\begin{small}
\begin{align*}
\frac{\partial L(\textbf{x}, y)}{\partial \textbf{x}} = [\frac{\partial L(\textbf{x}, y)}{\partial x_1}, \frac{\partial L(\textbf{x}, y)}{\partial x_2}, \dots, \frac{\partial L(\textbf{x}, y)}{\partial x_r}, \dots, \frac{\partial L(\textbf{x}, y)}{\partial x_m}]^\top,
\end{align*}
\end{small}
in which,
\begin{small}
\begin{align*}
\frac{\partial L(\textbf{x}, y)}{\partial x_r} = \begin{cases} \frac{\exp^{-x_r}}{\sum_{k=1}^m \exp^{-x_k}}, r \neq y \\
\frac{\exp^{-x_r}}{\sum_{k=1}^m \exp^{-x_k}}-1, r = y
\end{cases}
\end{align*}
\end{small}
As a consequence, $\frac{\partial L(\textbf{x}, y)}{\partial \textbf{x}}$ could be written as:
\begin{small}
\begin{align}\label{eq: grad_decomposition}
\begin{split}
\frac{\partial L(\textbf{x}, y)}{\partial \textbf{x}} & = [\frac{\partial L(\textbf{x}, y)}{\partial x_1}, \frac{\partial L(\textbf{x}, y)}{\partial x_2}, \dots, \frac{\partial L(\textbf{x}, y)}{\partial x_r}, \dots, \frac{\partial L(\textbf{x}, y)}{\partial x_m}]^\top\\
& = [\frac{\exp^{-x_1}}{\sum_{k=1}^m \exp^{-x_k}}, \frac{\exp^{-x_2}}{\sum_{k=1}^m \exp^{-x_k}}, \dots, \frac{\exp^{-x_r}}{\sum_{k=1}^m \exp^{-x_k}}, \dots, \frac{\exp^{-x_m}}{\sum_{k=1}^m \exp^{-x_k}}]^\top - \text{onehot}(j)\\
& = \underbrace{\text{softmax}(\textbf{x})}_{\textit{label free part}} - \underbrace{\text{onehot}(y)}_{\textit{label dependent part}}
\end{split}
\end{align}
\end{small}
\end{proof}
Note that when we only consider the gradient of the last layer, whose parameters are denoted as $\Theta^{(-1)}$, $\f{j}{\Theta}$ and $\mf{i}{\Theta}$ could be represented as:
\begin{small}
\begin{align*}
\f{j}{\Theta} = L(\lastxout{j}(\Theta),y_j) = L(\Theta^{(-1)}\Tilde{\textbf{x}_j}(\Theta), y_j),
\mf{i}{\Theta} = L(\lastxout{\text{meta},i}(\Theta),\my{i}) = L(\Theta^{(-1)}\Tilde{\mx{i}}(\Theta), \my{i}).
\end{align*}
\end{small}
Recall that in Section \nameref{sec: method_one} and Section \nameref{sec: application_label_noise}, we use $\lastxout{j}(\Theta)$ and $\Tilde{\textbf{x}_j}(\Theta)$ to denote the input of the last linear layer and the input of the softmax layer (i.e. the output of the last linear layer) given the training sample $j$. Similarly, $\lastxout{\text{meta},i}(\Theta)$ and $\Tilde{\mx{i}}(\Theta)$ represent the input and the output of the last linear layer given the meta sample $i$.
Then we could derive the gradient of $\f{j}{\Theta}$ (same for $\mf{i}{\Theta}$) with respect to the vectorized $\Theta^{(-1)}$ by leveraging the chain rule, leading to:
\begin{small}
\begin{align}\label{eq: vectorized_inner_prod_last_layer}
\nabla_{\vect{\Theta^{(-1)}}} \f{j}{\Theta} = \frac{\partial \lastxout{j}(\Theta)}{\partial \vect{\Theta^{(-1)}}}\cdot \frac{\partial L(\lastxout{j}(\Theta), \Tilde{y_j})}{\partial \lastxout{j}(\Theta)}.
\end{align}
\end{small}
By leveraging Lemma \ref{lemma_cl}, the above formula could be rewritten as:
\begin{small}
\begin{align*}
\nabla_{\vect{\Theta^{(-1)}}} \f{j}{\Theta} = \frac{\partial \lastxout{j}(\Theta)}{\partial \vect{\Theta^{(-1)}}}\cdot [\text{softmax}(\Theta^{(-1)}\Tilde{\textbf{x}_j}(\Theta)) - \text{onehot}(y_j)]
\end{align*}
\end{small}
and for $\frac{\partial \lastxout{j}(\Theta)}{\partial \vect{\Theta^{(-1)}}}$, it could be further derived as follows by utilizing the calculus on block matrix:
\begin{small}
\begin{align*}
\frac{\partial \lastxout{j}(\Theta)}{\partial \vect{\Theta^{(-1)}}} =\frac{\partial \Theta^{(-1)}\Tilde{\textbf{x}_j}(\Theta)}{\partial \vect{\Theta^{(-1)}}} = [\Tilde{\textbf{x}_j}(\Theta) \otimes \textbf{I}]^\top = [\Tilde{\textbf{x}_{j,1}}(\Theta)\textbf{I}, \Tilde{\textbf{x}_{j,2}}(\Theta)\textbf{I}, \dots \Tilde{\textbf{x}_{j,m}}(\Theta)\textbf{I}]^\top
\end{align*}
\end{small}
in which $\textbf{x}_{j,r}(\Theta)$ denotes the $r_{th}$ entry of the vector $\textbf{x}_{j}(\Theta)$ and $\otimes$ denotes the Kronecker product \citesupp{henderson1983history} on two matrices.
We then plug the above formula into Equation \eqref{eq: vectorized_inner_prod_last_layer}, resulting in:
\begin{small}
\begin{align*}
\nabla_{\vect{\Theta^{(-1)}}} \f{j}{\Theta}& = [\Tilde{\textbf{x}_{j,1}}(\Theta)\textbf{I}, \Tilde{\textbf{x}_{j,2}}(\Theta)\textbf{I}, \dots \Tilde{\textbf{x}_{j,m}}(\Theta)\textbf{I}]^\top \cdot [\text{softmax}(\Theta^{(-1)}\Tilde{\textbf{x}_j}(\Theta)) - \text{onehot}(y_j)]\\
& = \vect{\left[\text{softmax}(\Theta^{(-1)}\Tilde{\textbf{x}_j}(\Theta)) - \text{onehot}(y_j)\right] \Tilde{\textbf{x}_{j}}(\Theta)^\top},
\end{align*}
\end{small}
Recall that in Section \nameref{sec: method_one}, we use $\textbf{A}_j(\Theta)$ to denote $\text{softmax}(\Theta^{(-1)}\Tilde{\textbf{x}_j}(\Theta)) - \text{onehot}(y_j)$. Therefore, the above formula could be rewritten as:
\begin{small}
\begin{align*}
\begin{split}
\nabla_{\vect{\Theta^{(-1)}}} \f{j}{\Theta} = \vect{\textbf{A}_j(\Theta)\Tilde{\textbf{x}_{j}}(\Theta)^\top}
\end{split}
\end{align*}
\end{small}
Similarly, the following equation holds for the meta sample $i$:
\begin{small}
\begin{align*}
\begin{split}
\nabla_{\vect{\Theta^{(-1)}}} \mf{i}{\Theta} = \vect{\textbf{A}_{\text{meta}, i}(\Theta)\Tilde{\mx{i}}(\Theta)^\top}
\end{split}
\end{align*}
\end{small}
As a result, we can compute the inner product between $\nabla_{\vect{\Theta^{(-1)}}} \mf{i}{\Theta}$ and $\nabla_{\vect{\Theta^{(-1)}}} \f{j}{\Theta}$ by leveraging the above two formulas, leading to:
\begin{small}
\begin{align*}
\begin{split}
\langle \nabla_{\vect{\Theta^{(-1)}}} \mf{i}{\Theta}, \nabla_{\vect{\Theta^{(-1)}}} \f{j}{\Theta} \rangle & = \langle \vect{\textbf{A}_j(\Theta)\Tilde{\textbf{x}_{j}}(\Theta)^\top}, \vect{\textbf{A}_{\text{meta}, i}(\Theta)\Tilde{\mx{i}}(\Theta)^\top} \rangle\\
& = \langle \textbf{A}_j(\Theta)\Tilde{\textbf{x}_{j}}(\Theta)^\top, \textbf{A}_{\text{meta}, i}(\Theta)\Tilde{\mx{i}}(\Theta)^\top \rangle_F
\end{split}
\end{align*}
\end{small}
We can then plug the above formula into Equation \eqref{eq: our_init_objective}, i.e. MSSO, leading to:
\begin{small}
\begin{align*}
\text{MSSO} & = \max_{D_{\text{meta}}}\sum\nolimits_{j=1}^N \left|\sum\nolimits_{i=1}^M \langle\concatvec{j}, \concatvec{\text{meta}, i}\rangle\right|\\
& = \max_{D_{\text{meta}}}\sum\nolimits_{j=1}^N \left|\sum\nolimits_{i=1}^M \sum\nolimits_{\Theta_t}\langle\nabla_{\Theta} \f{j}{\Theta}|_{\Theta=\Theta_t}, \nabla_{\Theta} \mf{i}{\Theta}|_{\Theta=\Theta_t}\rangle\right|\\
& = \max_{D_{\text{meta}}}\sum\nolimits_{j=1}^N \left|\sum\nolimits_{i=1}^M \sum\nolimits_{\Theta_t}\langle\nabla_{\vect{\Theta}} \f{j}{\Theta}|_{\Theta=\Theta_t}, \nabla_{\vect{\Theta}} \mf{i}{\Theta}|_{\Theta=\Theta_t}\rangle\right|\\
& \approx \max_{D_{\text{meta}}}\sum\nolimits_{j=1}^N \left|\sum\nolimits_{i=1}^M \sum\nolimits_{\Theta_t}\langle\nabla_{\vect{\Theta^{(-1)}}} \f{j}{\Theta}|_{\Theta=\Theta_t}, \nabla_{\vect{\Theta^{(-1)}}} \mf{i}{\Theta}|_{\Theta=\Theta_t}\rangle\right|\\
& = \max_{D_{\text{meta}}}\sum\nolimits_{j=1}^N \left|\sum\nolimits_{i=1}^M \sum\nolimits_{\Theta_t}\langle\textbf{A}_{j}(\Theta_t)\Tilde{\textbf{x}_j}(\Theta_t)^\top, \textbf{A}_{\text{meta}, i}(\Theta_t)\Tilde{\mx{i}}(\Theta_t)^\top\rangle_F\right|
\end{align*}
\end{small}
This thus concludes the derivation of Equation \eqref{eq: method_one_objective_function}.
\subsection{Proof of Theorem \ref{theorem: main}}\label{sec: theorem_main}
\begin{proof}
By utilizing the following property concerning the absolute values of the sum of two numbers \citesupp{stewart2011calculus}:
\begin{small}
\begin{align*}
|a+b| = ||a| - |b||, \text{if } a\cdot b \leq 0,
\end{align*}
\end{small}
the inner most sum in Equation \eqref{eq: our_init_objective} could be rewritten as follows:
\begin{small}
\begin{align*}
& |\sum\nolimits_{i=1}^M \langle\concatvec{j}, C_i\rangle|\\
& = |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle + \sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|\\
& = ||\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle| - |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle||
\end{align*}
\end{small}
Also, by utilizing the following property concerning the sum of the absolute value of two numbers \citesupp{stewart2011calculus}:
\begin{small}
\begin{align*}
|a|+|b| = |a+b|, \text{if } a\cdot b \geq 0
\end{align*}
\end{small}
for the innermost sum in Equation \eqref{eq: transformed_k_means_objective} could be rewritten as follows:
\begin{small}
\begin{align*}
& \sum\nolimits_{i=1}^M |\langle\concatvec{j}, C_i\rangle|\\
& = \sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0}| \langle\concatvec{j}, C_i\rangle| + \sum_{\langle\concatvec{j}, C_i\rangle < 0} |\langle\concatvec{j}, C_i\rangle|\\
& = |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle| + |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0}\langle\concatvec{j}, C_i\rangle|
\end{align*}
\end{small}
Then we compute the ratio between the above two formulas, leading to:
\begin{small}
\begin{align}\label{eq: theorem_bound_derivation_1}
\begin{split}
&\frac{|\sum\nolimits_{i=1}^M \langle\concatvec{j}, C_i\rangle|}{\sum\nolimits_{i=1}^M |\langle\concatvec{j}, C_i\rangle|} = \frac{||\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle| - |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle||}{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle| + |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|}\\
& = \begin{cases}
\frac{\frac{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|}{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|}-1}{\frac{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|}{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|}+1} = 1 - \frac{2}{\frac{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|}{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|}+1} & \text{if } |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle| > |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|\\
\frac{\frac{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|}{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|}-1}{\frac{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|}{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|}+1} = 1 - \frac{2}{\frac{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|}{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|}+1} & \text{if } |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle| > |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|
\end{cases}
\end{split}
\end{align}
\end{small}
Then by leveraging the assumption of this Theorem, we know that:
\begin{small}
\begin{align*}
\begin{cases}
\frac{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|}{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|} > D & \text{ if } |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle| > |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|\\
\frac{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|}{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|} > D & \text{ if } |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle| > |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|
\end{cases}
\end{align*}
\end{small}
Therefore, Equation \eqref{eq: theorem_bound_derivation_1} could be bounded as follows:
\begin{small}
\begin{align*}
\text{Equation }\eqref{eq: theorem_bound_derivation_1} & = \begin{cases}
1 - \frac{2}{\frac{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|}{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|}+1} & \text{if } |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle| > |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|\\
1 - \frac{2}{\frac{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|}{|\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|}+1} & \text{if } |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle| > |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|
\end{cases}\\
& > \begin{cases}
1 - \frac{2}{D+1} & \text{if } |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle| > |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle|\\
1 - \frac{2}{D+1} & \text{if } |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle > 0} \langle\concatvec{j}, C_i\rangle| > |\sum\nolimits_{\langle\concatvec{j}, C_i\rangle < 0} \langle\concatvec{j}, C_i\rangle|
\end{cases}\\
& = \frac{D-1}{D+1}
\end{align*}
\end{small}
In Section \nameref{sec: supple_exp}, we will calculate the value of $D$ empirically. Recall that the value of $D$ needs to be significantly larger than 1 so that solving MCO (i.e. Equation \eqref{eq: transformed_k_means_objective}) could end up with a reasonable approximation to the solution of MSSO (i.e. Equation \eqref{eq: our_init_objective}), which could be empirically justified on MNIST\ and CIFAR\ dataset.
\end{proof}
\subsection{Generalization of our methods for \citesupp{ren2018learning}}\label{appendix: generalization_method}
\revise{As discussed in Section \nameref{sec: background}, our methods mainly utilize the meta-reweighting algorithm proposed in \citesupp{shu2019meta}. However, we can show that our methods can also support other meta-reweighting algorithms, such as \citesupp{ren2018learning}, which we illustrate in this section.}
\revise{First of all, we notice that \citesupp{ren2018learning} and \citesupp{shu2019meta} mainly differ in how to update the sample weights at each time step. Specifically, we reformulate Equation \eqref{eq: model_pre_update}-Equation \eqref{eq: model_post_update} according to \citesupp{ren2018learning} as follows:}
\begin{small}
\begin{empheq}[box=\widefbox]{align}
& \textbf{Meta re-weighting \citesupp{ren2018learning}:} \nonumber \\
&\hat{\Theta}(\textbf{W}_t) = \Theta_t - \alpha_t \cdot \frac{1}{N}\sum\nolimits_{j=1}^Nw_{j,t} \nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t, w_{j,t}=0}
\label{eq: model_pre_update_general}\\
& \hat{w}_{j,t+1} = - \eta_t \cdot \frac{1}{M}\sum\nolimits_{i=1}^M \nabla_{w_{j,t}} \mf{i}{\hat{\Theta}(\textbf{W}_t)} |_{w_{j,t}=0}
\label{eq: sample_weights_update_general}\\
& \hat{w}_{j,t+1} = \max\{\hat{w}_{j,t+1}, 0\}, w_{j,t+1} = \text{normalize}([\hat{w}_{1,t+1}, \hat{w}_{2,t+1},\dots,\hat{w}_{N,t+1}]) \label{eq: sample_weights_update_general2}\\
& \Theta_{t+1} = \Theta_t - \alpha_t\cdot \frac{1}{N}\sum\nolimits_{j=1}^N w_{j,t+1}\nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t}
\label{eq: model_post_update_general},
\end{empheq}
\end{small}
\revise{Recall that the intuition of our methods is to find meta samples so that each sample weight $w_j$ is effectively updated during the training process instead of staying close to its random initialization. Therefore, we hope to maximize the following cumulative gradients across all the samples during the entire training process, i.e.:}
\begin{small}
\begin{align}\label{eq: meta_reweighting_goal_general}
\max_{D_{\text{meta}}}\sum\nolimits_{\hat{\Theta}(\textbf{W}_t)} \frac{1}{M}\sum\nolimits_{i=1}^M \nabla_{w_j} \mf{i}{\hat{\Theta}(\textbf{W}_t)}, \text{for all $j=(1,2,\dots,N)$},
\end{align}
\end{small}
\revise{Note that different from Equation \eqref{eq: meta_reweighting_goal}, no absolute value is calculated in Equation \eqref{eq: meta_reweighting_goal_general}. Then by following the same derivation as Equation \eqref{eq: gradient_inner_prod}, we can get the following formula which is similar to Equation \eqref{eq: our_init_objective0}:}
\begin{small}
\begin{align}\label{eq: our_init_objective0_general}
\begin{split}
& \max_{D_{\text{meta}}}\sum\nolimits_{j=1}^N{\sum\nolimits_{\hat{\Theta}(\textbf{W}_t), \Theta_t}\sum\nolimits_{i=1}^M \langle\nabla_{\Theta} \mf{i}{\Theta}|_{\Theta = \hat{\Theta}(\textbf{W}_t)}, \nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t}\rangle}\\
& \approx \max_{D_{\text{meta}}}\sum\nolimits_{j=1}^N{\sum\nolimits_{i=1}^M \sum\nolimits_{\Theta_t}\langle\nabla_{\Theta} \mf{i}{\Theta}|_{\Theta =\Theta_t}, \nabla_{\Theta} \f{j}{\Theta}|_{\Theta = \Theta_t}\rangle}.\\
\end{split}
\end{align}
\end{small}
\revise{Again, the only difference between Equation \eqref{eq: our_init_objective0} and Equation \eqref{eq: our_init_objective0_general} is the existence of the absolute value computation. As a result, when the meta-reweighting algorithm from \citesupp{ren2018learning} is used, our methods, including both RBC\ and GBC, can be employed for selecting meta samples, except that the absolute value is not evaluated. }
\subsection{Analysis of the gradient with and without label-free part}\label{appendix: label_free_gradient}
According to Section \nameref{sec: application_label_noise}, in the presence of label noises, the sample-wise gradient $\nabla_{\Theta} \f{j}{\Theta}$ could be split into {\em label-free part} and the {\em label-dependent part}, which are represented as follows:
\begin{small}
\begin{align}\label{eq: split_gradient}
\begin{split}
& \nabla_{\Theta} \f{j}{\Theta} = [\underbrace{\frac{\partial \lastxout{j}(\Theta)}{\partial \Theta}\cdot \text{softmax}(\lastxout{j}(\Theta))}_{\textit{label-free gradient}} - \underbrace{\frac{\partial \lastxout{j}(\Theta)}{\partial \Theta} \cdot \text{onehot}(y)}_{\textit{label-dependent gradient}}],
\end{split}
\end{align}
\end{small}
in which $\lastxout{j}(\Theta)$ represents the input of the softmax layer of the neural model. The derivation of Equation \eqref{eq: split_gradient} is discussed in Lemma \ref{lemma_cl} in Appendix \nameref{appedix:derivation_method_one_objective}.
Recall that in Section \nameref{sec: application_label_noise}, we only focus on the label-free part in the sample-wise gradient, i.e., $\nabla_{\Theta} \widetilde{\f{j}{\Theta}}$. Therefore, by replacing $\nabla_{\Theta}\f{j}{\Theta}$ with $\nabla_{\Theta} \widetilde{\f{j}{\Theta}}$ and $\nabla_{\Theta} \mf{i}{\Theta}$ with $\nabla_{\Theta} \widetilde{\mf{i}{\Theta}}$ in Equation \eqref{eq: transformed_k_means_objective}, the objective function becomes:
\begin{small}
\begin{align}\label{eq: transformed_k_means_objective_label_free}
&\max_{D_{\text{meta}}}(\sum_{j=1}^N \sum_{i=1}^M |\langle \widetilde{\concatvec{j}}, \widetilde{\concatvec{\text{meta}, i}}\rangle |),
\end{align}
\end{small}
in which,
\begin{small}
\begin{align*}
\widetilde{\concatvec{j}} = \left[ \nabla_{\Theta} \widetilde{\f{j}{\Theta}}|_{\Theta = \Theta_1} \cdots \nabla_{\Theta}\widetilde{\f{j}{\Theta}}|_{\Theta = \Theta_t} \cdots \right], \widetilde{\concatvec{\text{meta},i}} = \left[ \nabla_{\Theta} \widetilde{\mf{i}{\Theta}}|_{\Theta = \Theta_1} \cdots \nabla_{\Theta} \widetilde{\mf{i}{\Theta}}|_{\Theta = \Theta_t} \cdots \right]
\end{align*}
\end{small}
In what follows, i.e., Theorem \ref{theorem: approximate_label_free}, we are going to show that with some assumptions, solving Equation \eqref{eq: transformed_k_means_objective_label_free} can produce approximately the same clusters as the ones produced by solving Equation \eqref{eq: transformed_k_means_objective} where the sample labels are involved.
\begin{theorem}\label{theorem: approximate_label_free}
Suppose solving Equation \eqref{eq: method_one_objective_function} with the weighted K-means algorithm, i.e., Algorithm \ref{alg: weighted_k_means}, assigns the training sample $j$ to the cluster centroid $c^{(j)}$. Then if the following assumptions hold for the training sample $i$:
\begin{enumerate}
\item The similarity between the training sample $j$ and the assigned centroid $c^{(j)}$,
is greater than $\alpha_j$ and the similarity between each training sample $j$ and any other cluster centroid $i$ is smaller than $\beta_j$ ($\alpha_j > \beta_j$), i.e.:
\begin{small}
\begin{align*}
&|\langle \widetilde{\concatvec{j}}, \widetilde{\concatvec{\text{meta}, c^{(j)}}}\rangle| \geq \alpha_j\\
& |\langle \widetilde{\concatvec{j}}, \widetilde{\concatvec{\text{meta}, i}}\rangle| \leq \beta_j, i \neq c^{(j)}
\end{align*}
\end{small}
\label{assp: bound}
\item The ratio between $|\langle \widetilde{\concatvec{j}}, \widetilde{\concatvec{\text{meta}, i}}\rangle|$ and $|\langle \concatvec{j}, \concatvec{\text{meta},i}\rangle|$ is lower bounded by $L_j$ and upper bounded by $U_j$ (The values of $L_j$ and $U_j$ could depend on each training samples $j$).
\end{enumerate}
then the following inequalities on $|\langle \concatvec{j}, \concatvec{\text{meta}, i}\rangle|$ hold:
\begin{small}
\begin{align*}
&|\langle \concatvec{j}, \concatvec{\text{meta}, c^{(j)}}\rangle| \geq L_j \alpha_j\\
& |\langle \concatvec{j}, \concatvec{\text{meta}, i}\rangle| \leq U_j \beta_j, i \neq c^{(j)},
\end{align*}
in which $\concatvec{\text{meta}, i}$ involves the ground-truth labels of the meta sample $i$.
\end{small}
\end{theorem}
This theorem thus suggests that if $L_j\alpha_j$ is greater than $U_j\beta_j$, then the cluster centroid $c^{j}$ could be still the closest centroid of the training sample $j$. In Appendix \nameref{appendix: quantitative_res}, we will empirically
count how many training samples can still be assigned to the same cluster centroid after we change the similarity measure from $|\langle \widetilde{\concatvec{j}}, \widetilde{\concatvec{\text{meta}, i}}\rangle|$ to $|\langle \concatvec{j}, \concatvec{\text{meta}, i}\rangle|$.
\section{Supplemental experiments}\label{sec: supple_exp}
In this section, we provide some extra experiments which could not be included in the main paper.
\subsection{Details of all hyper-parameters in the experiments}
To run meta re-weighting algorithm, we use SGD with initial learning rate 0.1, momentum 0.8, and weight decay $5\times10^{-4}$ for the CIFAR\ experiments, and we use SGD with constant learning rate 0.1 for the MNIST\ experiments. We use a mini-batch size of 4096 and 128 for MNIST\ and CIFAR\ respectively.
Following \citesupp{shu2019meta}, we also use a learning rate decay for CIFAR\ experiments such that the learning rate is divided by 10 at epoch 80 and epoch 90 (100 epochs in total).
As indicated in Section \nameref{sec: chicken_egg_problem}, for both RBC\ and GBC, we need to sample certain model parameters from each epoch of the warm-up phase, i.e. the meta re-weighting process with some randomly selected samples as the meta samples. We therefore sample those model parameters every 20 epochs after the epoch $t^*$ where the best model parameters occur. Plus, for GBC, as mentioned in Section \nameref{sec: method_two}, we sample several the model parameters at the granularity of network layers to estimate Equation \eqref{eq: inner_prod_by_layer_by_importance_score} and the number of the sampled network layers is set as 5. After collecting gradients of each training sample for RBC\ and GBC, we then run the weighted K-means clustering algorithm (i.e. Algorithm \ref{alg: weighted_k_means}) long enough. To guarantee the convergence, the number of epochs is set as 200.
\subsection{More quantitative results}\label{appendix: quantitative_res}
\subsubsection{Empirical evaluations of Theorem \ref{theorem: main}} Note that Theorem \ref{theorem: main} depends on the assumption that the positive part or the negative part in the innermost sum of Equation \eqref{eq: our_init_objective} are dominant over the negative terms or vice versa. This assumption is not theoretically analyzed, which is thus verified empirically in this section. Specifically, we calculate the ratio between the (dominant) positive part and the negative part (or the dominant negative part with respect to the positive part), (denoted as $D_j$) for each training sample $j$ in the label noise experiments when RBC\ is used. Note that the value of $D$ in Theorem \ref{theorem: main} equals to the minimum of all $D_j$. We therefore report the statistics of $D_j$
in Table \ref{Table: D_value}.
\begin{table}[ht]
\caption{The statistics of the value of $D_j (j=1,2,\dots,)$ in label noise experiments (RBC)}\label{Table: D_value}
\small
\centering
\begin{tabular}[!h]{>{\arraybackslash}p{2cm}|>{\centering\arraybackslash}p{1.8cm}>{\centering\arraybackslash}p{1.8cm}|>{\centering\arraybackslash}p{1.8cm}>{\centering\arraybackslash}p{1.8cm}} \hline\hline
Dataset &\multicolumn{2}{c|}{CIFAR-10}&\multicolumn{2}{c}{CIFAR-100} \\ \hline
Noise type & uniform & adversarial & uniform & adversarial \\ \hline
minimum & 1.70 & inf & 1.01 & 1.01 \\ \hline
5\%-quantile & 4.38 & inf & 1.40 &1.68 \\ \hline \hline
\end{tabular}
\end{table}
As indicated in Table \ref{Table: D_value}, for both CIFAR-10\ with different types of noises, the values of $D$ are all significantly greater than 1 across all training samples, thus verifying the assumption of Theorem \ref{theorem: main} (inf means that all the terms in the innermost sum of Equation \eqref{eq: our_init_objective} have the same signs). Similar results are also observed in the class-imbalance experiments. For CIFAR-100, although the minimum value of $D_j$ is almost 1, there are less than 5\% training samples with near-one $D_j$ value. Therefore, after removing this small portion of outlier samples, the assumption of Theorem \eqref{theorem: main} still holds.
\subsubsection{Empirical evaluations of Theorem \ref{theorem: approximate_label_free}}
Recall that due to the unavailable ground-truth labels when RBC\ or GBC\ are used in the presence of label noises, we proposed to only employ the label-free part in the sample-wise gradients as the input to our methods, which results in a label-free similarity measure, $|\langle \widetilde{\concatvec{j}}, \widetilde{\concatvec{\text{meta}, i}}\rangle|$, and a label-free objective function in Equation \eqref{eq: transformed_k_means_objective_label_free}. Theorem \ref{theorem: approximate_label_free} explored under what conditions, by using the label-aware similarity, $|\langle {\concatvec{j}}, {\concatvec{\text{meta}, i}}\rangle|$, the sample $j$ could still be closest to the cluster centroid, $c^{(j)}$, which is determined by solving the label-free objective function, Equation \eqref{eq: transformed_k_means_objective_label_free}. This type of samples are named as {\em stable samples} and we count how many such samples exist in the label noise experiments, which is reported in Table \ref{Table: label_free_approx_eval}.
\begin{table}[ht]
\caption{The number of stable samples (out of 25k) in the label noise experiments (RBC)}\label{Table: label_free_approx_eval}
\small
\centering
\begin{tabular}[!h]{>{\arraybackslash}p{2cm}|>{\centering\arraybackslash}p{1.8cm}>{\centering\arraybackslash}p{1.8cm}|>{\centering\arraybackslash}p{1.8cm}>{\centering\arraybackslash}p{1.8cm}} \hline\hline
Dataset &\multicolumn{2}{c|}{CIFAR-10}&\multicolumn{2}{c}{CIFAR-100} \\ \hline
Noise type & uniform & adversarial & uniform & adversarial \\ \hline
count & 23593 & 20517 & 20543 & 20547 \\ \hline
\end{tabular}
\end{table}
Note that due to the existence of the meta samples from the warm-up phase, according to Algorithm \ref{alg: overall_algorithm}, we only conduct the weighted K-means clustering algorithm on the samples that are far away from the existing meta samples. As mentioned in Appendix \nameref{appendix: cluster_count}, the number of such samples is around half of the entire training set, i.e., around 25k for CIFAR-10\ and CIFAR-100\ dataset. As indicated in Table \ref{Table: label_free_approx_eval}, over 80\% of the training samples are {\em stable samples} for both CIFAR-10\ and CIFAR-100\ dataset. This thus suggests that clustering the label-free part of the sample-wise gradients in our methods could lead to a reasonable approximation of the results produced by clustering the ground-truth-label-aware gradients.
\begin{table}[ht]
\caption{Test accuracy on CIFAR-10\ with noise rate 60\% by repetitively adding meta samples}\label{table: repeat_run}
\small
\centering
\begin{tabular}[!h]{>{\arraybackslash}p{3cm}|>{\centering\arraybackslash}p{1.5cm}>{\centering\arraybackslash}p{1.5cm}>{\centering\arraybackslash}p{1.5cm}>{\centering\arraybackslash}p{1.5cm}} \hline\hline
Meta sample count & 20 & 30 & 40 & 50 \\ \hline
Certain & 66.15 & \underline{81.03}&81.65 & 81.57 \\
TA-VAAL &66.73 &68.63 & 60.63& 61.47\\ \hline
RBC & \textbf{78.95} & \textbf{82.10}& \textbf{83.36}& \underline{81.76}\\
GBC & \underline{76.46}& 80.58&\underline{81.96} & \textbf{81.93}\\ \hline\hline
\end{tabular}
\end{table}
\paragraph{Results with real label noise} Note that so far we only studied the performance of our methods by polluting the labels of the benchmark datasets in a synthetic manner, which may not occur in the real applications. We therefore follow \citesupp{wei2021learning} to add real human labeling errors to CIFAR-10\ and CIFAR-100\ datasets and evaluate our methods in this setting. We include the experimental results of CIFAR-100\ in Table \ref{table: real_noise}, which indicates that our methods can still outperform all the baseline methods in the presence of realistic labeling errors. For CIFAR-10, it turns out that the real human labeling errors have very little influence on the model performance and thus all of these methods only boost the performance marginally, which is thus not shown here.
\begin{table*}[t]
\caption{Test accuracy of CIFAR\ dataset with real human labeling errors}\label{table: real_noise}
\small
\centering
\begin{tabular}[!h]{>{\arraybackslash}p{1.5cm}|>{\centering\arraybackslash}p{1.5cm}} \hline\hline
& CIFAR-100 \\\hline
Base model & 49.33\\
Random & 57.54\\
Certain & 57.48\\
Uncertain & 56.23\\
Fine-tuning &51.24\\
TA-VAAL & 44.50\\
craige & 57.92\\
RBC-K& 59.24\\ \hline
RBC &\textbf{59.25} \\
GBC &\underline{59.25}\\ \hline\hline
\end{tabular}
\end{table*}
\subsubsection{Effect of the number of meta samples} We further study the effect of the number of meta samples on the performance of our methods by continuously adding more and more meta samples. Specifically, for CIFAR-10\ dataset with 60\% adversarial label errors, we repetitively add 10 meta samples and run the meta re-weighting algorithm for 4 times after the warm-up phase. The results are included in Table \ref{table: repeat_run} and we only include the baseline methods which perform relatively better than other methods, e.g., Certain\ and TA-VAAL. As this table shows, our methods can consistently outperform (with performance gains up to~13\% when 20 meta samples are selected) with respect to the baseline methods.
\subsubsection{Effect of the number of sampled gradients for RBC\ and GBC} Recall that in Section \nameref{sec: solve_mco}, it is not possible to collect all the calculated gradients from all the iterations during the meta-reweighting training phase to evaluate MCO due to limited GPU memory. This thus motivates the idea of randomly sampling calculated gradients in RBC\ and GBC. We therefore studied the effect of the number of sampled gradients, i.e., the value of $K$, on the performance of our methods. Specifically, we vary $k$ between 4 and 100 on RBC\ and conduct meta-reweighting on MNIST\ dataset with 80\% adversarial labeling errors (with the same experimental setup as Section \nameref{sec: experiment_setup}). The results are summarized in Table \ref{table: mnist_rbc_varied_k}. According to this table, we can know that
the test performance of extremely small $K$ is significantly worse than that of large $K$ (e.g, $K=4$ VS $K>10$), which thus indicates that more gradients would boost the model performance. However, when $K$ is larger than certain value, say $K > 10$ in Table \ref{table: mnist_rbc_varied_k}, no significant performance gains occur while more GPU memory is needed for containing more sampled gradients. This thus indicates that with proper value of $K$, randomly sampling gradients could perfectly balance the test performance and the GPU memory consumption.
\subsubsection{Effect of pre-training phase} We further studied the effect of the pre-training phase on the performance. When pre-training phase is not executed, we select all samples once by using our methods or the baseline methods. We include the results on CIFAR-100\ dataset in Table \ref{table: pretraining}, in which we compare our methods against Certain\ and Uncertain\ since they are two relatively better baseline methods in comparison to others.
According to this table, we can tell that both our methods and baseline methods can generally benefit from pre-training phase, thus demonstrating the benefit of the pre-training phase.
\begin{table}[ht]
\caption{Test accuracy of RBC\ on MNIST\ dataset with varied $K$}\label{table: mnist_rbc_varied_k}
\small
\centering
\begin{tabular}[!h]{c|c} \hline\hline
$K$ & Test Accuracy \\ \hline
100 &93.01 \\
50 & 93.32\\
10 & 93.10\\
6 & 91.48\\
4 &91.68 \\\hline
\end{tabular}
\end{table}
\subsubsection{Supplemental results on class-imbalanced + label noise experiments} In addition to evaluating our methods on noisily labeled and imbalanced data separately, we also look at the combination of the two in Table (\ref{Table: cifar_imb_noise}). In these experiments, we perform an initial warmup step with 10 and 100 randomly selected meta samples and then select an additional 100 and 200 samples using the different methods for CIFAR-10\ and CIFAR-100\ respectively. With 40\% uniform noise and class imbalance levels of 200 and 100, our methods outperform all baselines for CIFAR-100\ and CIFAR-10\ with imbalance of 100.
\begin{table}[ht]
\caption{Test accuracy of ResNet-34 on imbalanced CIFAR-10\ and CIFAR-100\ dataset with 40\% uniform noise}\label{Table: cifar_imb_noise}
\small
\centering
\begin{tabular}[!h]{>{\arraybackslash}p{2cm}|>{\centering\arraybackslash}p{1.8cm}>{\centering\arraybackslash}p{1.8cm}|>{\centering\arraybackslash}p{1.8cm}>{\centering\arraybackslash}p{1.8cm}} \hline\hline
Dataset &\multicolumn{2}{c|}{CIFAR-10}&\multicolumn{2}{c}{CIFAR-100} \\ \hline
Imbalance & 200 & 100 & 200 & 100 \\ \hline
Base Model & 27.3 & 31.92 & 6.97 & 9.13\\
Random & \underline{29.32} & 35.49 & 9.30 & 10.30\\
Uncertainty & 27.91 & 35.59 & 9.16 & 10.62\\
Certainty & 28.48 & 35.29 & \underline{9.40} & 10.27\\
Finetune & 28.97 & 36.76 & 8.07 & 7.93\\
TA-VAAL & \textbf{29.77} & \underline{36.89} & 9.00 & 10.33\\
\hline
RBC\ & 27.73 & \textbf{38.01} & \textbf{9.99}& \underline{11.02}\\
GBC\ & 28.44 & 35.75 & 8.17 & \textbf{11.24}\\\hline\hline
\end{tabular}
\end{table}
\begin{table*}[t]
\caption{Test performance with and without pre-training with 60\% label noise}\label{table: pretraining}
\small
\centering
\begin{tabular}[!h]{>{\centering\arraybackslash}p{2cm}|>{\centering\arraybackslash}p{1.6cm}>{\centering\arraybackslash}p{1.6cm}|>{\centering\arraybackslash}p{1.6cm}>{\centering\arraybackslash}p{1.6cm}} \hline\hline
\multirow{2}{*}{Label noise type} &\multicolumn{2}{c}{uniform}&\multicolumn{2}{|c}{adversarial} \\ \hhline{~----}
&\makecell{with\\pretraining}&\makecell{without\\pretraining}&\makecell{with\\pretraining}&\makecell{without\\pretraining}\\ \hline
Certain & 45.95&45.32&47.06&44.35\\
Uncertain & 36.67&35.99& 44.65&44.54\\
RBC-K &49.32&\underline{47.65}& 49.51&47.66\\ \hline
RBC & \underline{49.56} &45.27 &\underline{50.60}&\underline{48.91}\\
GBC & \textbf{50.88} &\textbf{50.24}&\textbf{53.14}&\textbf{52.55}\\ \hline\hline
\end{tabular}
\end{table*}
\subsection{Qualitative results}
Figure \ref{fig: visual_cluster} is a visualization using t-SNE \citesupp{van2008visualizing} of the partial sample-wise gradients collected by RBC\ as well as the cluster centroids generated by the weighted K-means clustering. As this figure shows, there exists obvious clustering structure on the sample-wise gradients, thus justifying the use of the K-means clustering algorithm. In addition, recall that in Section \nameref{sec: solve_mco}, we tailor the vanilla K-means clustering algorithm for solving MCO. Figure \ref{fig: visual_cluster} thus demonstrates the effectiveness of this tailored algorithm since the cluster centroids discovered in this manner cover all the clusters very well.
\begin{figure}
\centering
\includegraphics[width=0.4\textwidth]{Figures/RBC_tsne.pdf}
\caption{Visualization of the partial gradients used in RBC\ on CIFAR-10\ with imbalance factor 200 and the corresponding cluster centroids identified by the weighted K-means clustering algorithm.}
\label{fig: visual_cluster}
\end{figure}
\section{Limitations of our work}\label{appendix: limitation}
Most of the theoretical results we present hold in a general setting except some dataset-dependent assumptions (e.g., the assumption of Theorem \ref{theorem: main}). We therefore would love to explore whether those assumptions hold for general datasets or not.
Also, our empirical claims are shown on just three standard datasets for the noisy label case and two datasets for the class imbalance case. The datasets we use are MNIST, CIFAR-10, and CIFAR-100\ which are benchmark image datasets, which, however, do not include the datasets from other domains. Similarly, our empirical results use a ResNet model which is a standard neural network model for vision. We leave the evaluation of our methods on other models like Transformers for future work.
We also manually introduced label noise and a class imbalance into these datasets and have not yet evaluated on a dataset which is known to contain label noise or a class imbalance. Additionally, we use two standard types of label noise in our experiments, but our method may perform differently if the distribution of noise in another dataset is significantly different from our uniform or adversarial noise.
Furthermore, the selections of meta samples or validation samples could occur in many different scenarios, e.g., general meta learning framework \citesupp{andrychowicz2016learning} and the data valuation methods depending on a clean validation samples (see the discussion in Section \nameref{sec: related_work}). Therefore, it would be interesting to explore whether the techniques proposed in this paper could address the validation sample selection problem in more general set-up.
\section{Discussions on societal impacts}\label{appendix: social_impact}
Our framework can be useful for domains in which data is commonly noisy and imbalanced. In these settings, the sample labels are usually manually cleaned.
However, labelling in these domains is expensive and may suffer from the risk of getting incorrect labels.
As indicated by the experiments, our methods can perform very well when the labeling budget is very small. This thus suggests that our methods can reduce the number of required perfect labels. As a consequence, more labeling effort can be spent on the few pivotal samples to get high-quality labels, rather than a large amount of low-quality labels in these domains.
\section{Applications}
We demonstrate the effectiveness of our methods for two applications, i.e., re-weighting a training set with noisy labels and re-weighting an imbalanced training set. In what follows, we discussed how to tailor RBC\ and GBC\ to these two applications.
\subsection{Re-weighting a training set with noisy labels}\label{sec: application_label_noise}
To re-weight a noisily labeled training set, we can select a subset of meta samples from the training set and obtain their clean labels from human annotators.
Note that for RBC\ and GBC,
the evaluation of the gradients depend on the clean labels of the meta samples while these clean labels are obtained from human annotators {\em after} RBC\ or GBC\ is invoked. To address this chicken or the egg issue, we observe that if the loss function is the cross-entropy loss, then the sample-wise gradient, $\nabla_{\Theta} \f{j}{\Theta}$, can be broken into two parts, the {\em label-free part} and the {\em label-dependent part}.
Due to the unavailability of the clean labels, we therefore only leverage the \textit{label-free part} as the input to RBC\ and GBC.
Although we only use the label-free part, in Appendix \nameref{appendix: label_free_gradient} (see Theorem \ref{theorem: approximate_label_free}), we theoretically analyze under what conditions the label-dependent part is insignificant to determining which cluster each training sample belongs to after the weighted k-means clustering algorithm is invoked.
Those conditions are satisfied by a large portion of the training samples through our empirical studies (see Appendix \nameref{sec: supple_exp}), thus justifying the effectiveness of discarding the label-dependent part.
\subsection{Re-weighting a training set with a class-imbalance}
As indicated by \cite{shu2019meta}, the meta re-weighting algorithm can also be leveraged for re-weighting class-imbalanced training sets.
Unlike the case where the labels are noisy, we assume clean labels in the class-imbalanced training set. As a consequence, we evaluate the sample-wise gradient $\nabla_{\Theta} \f{j}{\Theta}$ as a whole rather than removing the label-dependent part from it.
\section{Acknowledgments}
We thank our anonymous reviewers for valuable feedback. This research was supported by grants from DARPA (\#FA8750-19-2-0201) and NSF award (IIS-2145644).
\section{Introduction}
\newpage
\input{Sections/Ack}
| {'timestamp': '2023-02-10T02:05:24', 'yymm': '2302', 'arxiv_id': '2302.04418', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04418'} | arxiv |
\section{Introduction}
Researchers invest significant effort to create benchmarks in machine learning, including ImageNet~\cite{deng2009imagenet}, SQUAD~\cite{rajpurkar2016squad}, and SNLI~\cite{bowman2015large}, as well as to develop models that solve them. \textit{Can we rely on these benchmarks?} A growing body of recent research~\cite{schwartz2017effect,poliak2018hypothesis,kaushik2018much} is revealing that models exploit spurious bias/artifacts-- unintended correlations between input and output~\cite{torralba2011unbiased} (e.g. the word `not' is associated with the label `contradiction' in Natural Language Inference (NLI)~\cite{gururangan2018annotation})-- instead of the actual underlying features, to solve many popular benchmarks. Models, therefore, fail to generalize, and experience drastic performance drops when testing with out-of-distribution (OOD) data or adversarial examples ~\cite{bras2020adversarial,Mishra2020OurEM,mccoy2019right,zhang2019paws,larson2019evaluation,sakaguchi2019winogrande,hendrycks2016baseline}. This begs the question: \textit{Shouldn't ML researchers consequently focus on creating `better' datasets rather than developing increasingly complex models on bias-laden benchmarks?}
Deletion of samples based on bias baseline reports-- hypothesis-only baseline in NLI~\cite{dua2019drop})-- and mitigation approaches such as AFLite~\cite{sakaguchi2019winogrande} (adversarial filtering which deletes targeted data subsets), ~\cite{clark2019don,kaushik2019learning}, have the following limitations: (i) data deletion/augmentation and residual learning do not justify the original investment in data creation, and (ii) crowdworkers are not provided adequate feedback to learn what constitutes high-quality data-- and so have additional overhead due to the manual effort involved in sample creation/validation. Furthermore, \cite{parmar2022don} show that biased samples are created even when crowdworkers are provided with an initial set of annotation instructions. One potential solution to these problems is continuous, \textit{in situ} feedback about artifacts while benchmark data is being created. \textit{To our knowledge, there are no approaches that provide real-time artifact identification, feedback, and reconciliation opportunities to data creators, nor guide them on data quality}.
\textbf{Contributions: } (i) We propose \textit{VAIDA} (Visual Analytics for Interactively Discouraging Artifacts), a novel system for benchmark creation that provides continuous visual feedback to data creators in real-time. VAIDA supports artifact identification and resolution, implicitly educating \textit{crowdworkers} and \textit{analysts} on data quality. (ii) We evaluate VAIDA empirically through expert review and a user study to understand the cognitive workload it imposes. The results indicate that VAIDA decreases mental demand, temporal demand, effort, and frustration of crowdworkers (\textcolor{decR}{31.1\%}) and analysts (\textcolor{decR}{14.3\%}); it increases their performance by \textcolor{incG}{34.6\%} and \textcolor{incG}{30.8\%} respectively, and educates crowdworkers on how to create \textit{high-quality} samples. Overall, we see a \textcolor{decR}{45.8\%} decrease in the presence of artifacts in created samples. (iii) Even though our main goal is to reduce artifacts in samples, we observe that samples created in our user study are adversarial across language models with performance decreases of \textcolor{decR}{31.3\%} (BERT), \textcolor{decR}{22.5\%} (RoBERTa), and \textcolor{decR}{14.98\%} (GPT-3 fewshot).
\section{Related Work}
This work sits at the intersection of two primary areas: (1) \textit{visual analysis of data quality} (higher presence of artifacts indicates lower quality), and (2) \textit{development of a novel data collection pipeline}.\footnote{Detailed related work is in the Supplemental Material.}
\subsection{Sample Quality and Artifacts}
Data Shapley \cite{ghorbani2019data} has been proposed as a metric to quantify the value of each training datum to the predictor performance. However, the metric might not signify bias content, as the value of training datum is quantified based on predictor performance, and biases might favor the predictor. Moreover, this approach is model and task-dependent. VAIDA uses DQI (Data Quality Index), proposed by ~\cite{Mishra2020DQIAG}, to: (i) compute the overall data quality for a benchmark with $n$ data samples, and (ii) compute the impact of a new $(n+1)^{th}$ data sample. Table~\ref{tab:dqi} broadly defines DQI components, along with their interpretation in VAIDA, and juxtaposes them against evaluation methods used in prior works on crowdsourcing pipelines, as discussed in \ref{sub:pipelinesrw}. \cite{wang2020vibe} propose a tool for measuring and mitigating artifacts in image datasets.
\subsection{Crowdsourcing Pipelines}
\label{sub:pipelinesrw}
Several pipelines have been proposed to handle various aspects of artifact presence in samples.
\textbf{Adversarial Sample Creation: } Pipelines such as Quizbowl \cite{wallace2019trick} and Dynabench \cite{kiela2021dynabench}, highlight portions of text from input samples during crowdsourcing, based on how important they are for model prediction; this prompts users to alter their samples, and produce samples that can fool the model being used for evaluation \cite{talmor2022commonsenseqa}. While these provide more focused feedback compared to adversarial pipelines like ANLI \cite{nie2019adversarial}, which do not provide explicit feedback on text features, adversarial sample creation is contingent on performance against a specific model (Quizbowl for instance is evaluated against IR and RNN models, and may therefore not see significant performance drops against more powerful models). Additionally, such sample creation might introduce new artifacts over time into the dataset and doesn't always correlate with high quality-- for instance, a new entity introduced to fool a model in an adversarial sample might be the result of insufficient inductive bias, though reducing the level of spurious bias.
A similar diagnostic approach is followed for unknown unknown identification-- i.e., instances for which a model makes a high-confidence prediction that is incorrect. \cite{attenberg2015beat} and \cite{vandenhof2019hybrid} propose techniques to identify UUs, in order to discover specific areas of failure in model generalization through crowdsourcing. The detection of these instances is however, model-dependent; VAIDA addresses the occurrence of such instances by comparing sample characteristics between different labels to identify (and resolve) potential artifacts and/or under-represented features in created data.
\textbf{Promoting Sample Diversity: } Approaches focusing on improving sample diversity have been proposed, in order to promote model generalization. \cite{yaghoub2020dynamic} use a probabilistic model to generate word recommendations for crowdworker paraphrasing. \cite{larson2019outlier} propose retaining only the top k\% of paraphrase samples that are the greatest distance away from the mean sentence embedding representation of all collected data. These `outlier' samples are then used to seed the next round of paraphrasing. \cite{larson2020iterative} iteratively constrain crowdworker writing by using a taboo list of words, that prevents the repetition of over-represented words, which are also a source of spurious bias. Additionally, \cite{stasaski2020more} assess the new sample's contribution to the diversity of the entire sub-corpus.
\textbf{Controlled Dataset Creation:}
Previous work \cite{roit2019crowdsourcing} in controlled dataset creation trains crowdworkers, and selects a subset of the best-performing crowdworkers for actual corpus creation. Each crowdworker's work is reviewed by another crowdworker, who acts as an analyst (as per our framework) of their samples. However, in real-world dataset creation, such training and selection phases might not be possible. Additionally, the absence of a metric-in-the-loop basis for feedback provided during training can potentially bias (through trainers) the created samples.
As shown in Table \ref{tab:dqi}, DQI encompasses the aspects of artifacts studied by the aforementioned works; it further quantifies the presence of many more inter and intra-sample artifacts,\footnote{See Supplemental Material for details on artifacts that DQI identifies.} and provides a one-stop solution to address artifact impact on multiple fronts. VAIDA leverages DQI to identify artifacts, and further focuses on educating crowdworkers on exactly `why' an artifact is undesirable, as well as the impact its presence will have on the overall corpus. It is also easily extensible to incorporate additional metrics such as quality control measures \cite{ustalov2021general}, enabling benchmarking evaluation in a reproducible manner. This is in contrast to the implicit feedback provided by word recommendation and/or highlighting in prior works, based on a static set of metrics-- VAIDA facilitates the systematic elimination of artifacts without the unintentional creation of new artifacts, something that has hitherto remained unaddressed.
\section{Modules}
In this section, we describe VAIDA's important backend processes.
\textbf{DQI:} DQI can be expressed as a quality metric that examines different sources of artifacts in text, by scoring samples along 7 different components. We use DQI in order to demonstrate VAIDA's ability to cover multiple facets of artifact creation, although VAIDA is metric agnostic. VAIDA uses an intuitive traffic signal color coding (\textcolor{decR}{high}$>>$\textcolor{modO}{moderate}$>>$\textcolor{incG}{low}) to indicate levels of artifacts (i.e., quality) in samples. Hyperparameters for color mapping with respect to DQI component values depend on (i) the application type, and (ii) characteristics of pre-existing samples present in the corpus at the time of new sample creation.\footnote{\label{footeval} \label{footref} See Supplemental Material: Evaluation, for details across all DQI components, hyperparameter tuning, and analyses.} For instance, when recreating SNLI \cite{bowman2015large} with VAIDA, we tune hyperparameters separating the boundary between red, yellow, and green flags on 0.01\% of the SNLI training dataset manually in a supervised manner \cite{Mishra2020DQIAG}.
\definecolor{myRed}{rgb}{0.97,0.36,0.3}
\definecolor{myYellow}{rgb}{0.96,0.74,0.37}
\definecolor{myGreen}{rgb}{0.56,0.93,0.56}
\label{sec:auto}
\textbf{AutoFix: } We propose AutoFix as a module to help crowdworkers avoid creating bad samples by recommending changes to a sample to improve its quality. The AutoFix algorithm is explained in Figure~\ref{fig:AutoFix}. Given a premise, hypothesis, and DQI values for the hypothesis, AutoFix sequentially masks each word in the hypothesis and ranks words based on their influence on model output, i.e., their importance. The hypothesis word of highest importance is replaced, to achieve at least \textcolor{modO}{moderate} quality. DQI hence controls the amount and aspect of changes made by AutoFix. By incrementally changing the sample, users can understand how and why their sample is being modified and how DQI values are affected.
\begin{figure}[h]
\centering
\includegraphics[width=\columnwidth]{Figures/AutoFix.png}
\caption{AutoFix Algorithm applied to an SNLI entailment sample, replacing one word per iteration. The DQI of the hypothesis changes from 3.822 to 5.047.}
\label{fig:AutoFix}
\end{figure}
\label{sec:tf}
\textbf{TextFooler: } From an analyst's perspective, the quality of a submitted sample might be ``too low'' because (i) the crowdworker might not employ AutoFix appropriately, or (ii) there is a narrow acceptability range due to the criticality of the application domain, such as in BioNLP~\cite{lee2020biobert, parmar2022boxbart}. We therefore implement TextFooler~\cite{jin2019bert} to adversarially transform low-quality samples (instead of discarding them), to improve benchmark robustness, and ensure that crowdsourcing effort is not wasted. We initially use AFLite~\cite{bras2020adversarial}, to bin samples into \textit{good} (retained samples) and \textit{bad} (filtered samples) splits. Using TextFooler, we adversarially transform bad split data to flip the label; we revert back to the original label and identify sample artifacts using DQI (see Figure \ref{fig:wf2}).
\section{Interface Design and Workflow}
\label{interface}
VAIDA provides customized interfaces for both crowdworkers and analysts, as shown in Figures~\ref{fig:crowdworker_interface}, ~\ref{fig:analyst_interfaces} respectively.\footnote{\label{footi}See Supplemental Material: Interface Design for interface intuitions and detailed descriptions, with full-resolution images.} We describe VAIDA's workflow via a case study for sample creation (crowdworker) and review (analyst) in Figures~\ref{fig:wf1},\ref{fig:wf2}.
\begin{figure}[h]
\centering
\includegraphics[width=.5\textwidth]{Figures/IF1.png}
\caption{VAIDA's crowdworker interface consists of six linked panels: (A) Instructions, (B) Data creation, (C) DQI results, (D) Sample distribution, (E) More details, and (F) Additional communication.\textsuperscript{\ref{footi}}}
\label{fig:crowdworker_interface}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[width=.5\textwidth]{Figures/IF2.png}
\caption{VAIDA provides a collection of interfaces for the analyst supporting detailed analysis and investigation of submitted samples and the overall benchmark.\textsuperscript{\ref{footi}}}
\label{fig:analyst_interfaces}
\end{figure}
\begin{figure*}[!h]
\centering
\includegraphics[width=1.67\columnwidth]{Figures/wf-1.png}
\caption{VAIDA workflow for the creation of a single sample by a crowdworker.}
\label{fig:wf1}
\end{figure*}
\begin{figure*}[!h]
\centering
\subfloat{\includegraphics[width=1.67\columnwidth]{Figures/wf-2.png}}\\
\subfloat{\includegraphics[width=1.67\columnwidth]{Figures/wf-3.png}}
\caption{VAIDA workflow for the evaluation of a single sample by an analyst, and subsequent analyst feedback provided to the crowdworker.}
\label{fig:wf2}
\end{figure*}
The crowdworker interface provides instructions \textbf{(A)} to navigate through the panels and how to interpret feedback for created samples. Communication links for FAQs, and error reporting are also provided (F). Crowdworkers can then review the instructions for data creation \textbf{(B)}-- here, we use the same instructions provided in the original SNLI crowdsourcing interface \textbf{(b1)}.
\textbf{1. Sample Creation:} The premise field auto-populates with a caption from the Flickr30 corpus \textbf{(b2)}. The crowdworker must create three hypotheses (for the entailment, neutral, contradiction labels) at a time, though they are reviewed individually.
\textbf{2. DQI Evaluation Feedback:} On clicking the review button, DQI feedback is shown in \textbf{(C)}, for each component. Each colored circle \textbf{(c1)} indicates the level of artifacts present corresponding to each DQI component for the created sample; hovering displays a tooltip that explains and highlights \textbf{(c2)} the artifacts in the created sample, pertaining to the category of bias covered by that component. The overall sample quality \textbf{(c3)} is calculated, by averaging over the artifact percentiles of all 7 DQI components for the sample. By comparing sample quality with that of pre-existing samples, the probability that the sample will be accepted/rejected is shown \textbf{(c4)}. The user can choose to either revise or submit the sample.
\textbf{3a. Sample Revision:} \textit{Manual Revision} or \textit{AutoFix} can be done. We illustrate the improvement of sample quality in this step in Figure~\ref{fig:wf1}.
\textbf{3b. Sample Submission:} After review (and potentially iterative DQI evaluations/sample revisions), the sample can be submitted for benchmark inclusion. On submission, a sample enters a \textit{pending} state \textbf{(d1)} until review by the analyst.
While crowdworkers work within a single tightly-coordinated interface to create, submit, and review samples, analysts can navigate between a set of nine screens (Figure~\ref{fig:analyst_interfaces}) to review samples in detail to make `accept', `reject', and `modification' decisions, and to assess overall benchmark quality. Analysts review samples in batches of size 50.\footnote{DQI components 1, 2, 3, 6, and 7, gauge artifact presence relative to pre-existing samples. We observe given at least 50 pre-existing samples, DQI component values change by less than 5\% for the overall dataset if another 50 samples are accepted.}
\textbf{4. Analyst Review:} Review can consist of several different operations by the analyst.
\textit{(i) Direct Acceptance--} The home page \textbf{(UI)} for the analyst provides a view similar to the crowdworker interface, and allows the analyst to review the work of a single crowdworker. If the data quality is deemed to be sufficiently high by just viewing the DQI color flags and quality percentile, the analyst can directly accept the sample into the corpus from this screen, as shown in Figure~\ref{fig:wf2}.
\textit{(ii) Visual Analysis and Modification--} VAIDA provides several visualizations \textbf{(C1-C7)} to support detailed analysis and review of submitted samples, and to assess artifact presence (i.e., quality) in the overall benchmark. Each visualization allows the analyst to simulate how adding one or more submitted samples affects the benchmark's quality.
For example, in Figure~\ref{fig:wf2}, we show the visualizations for analysis of DQI component 4 (C4), which deals with artifacts caused due to word similarity within a sample. For each sample in the corpus, the word similarities between all possible pairs of words are averaged; the samples are then hierarchically displayed as a treemap based on their DQI color mapping and average word similarity. We note that the color scale followed is bilinear, as while artifacts must be eliminated, there still needs to be a sufficient inductive bias for the sample to be solvable. The size of a rectangle indicates the distance of each sample from the average word similarity across all samples. The new sample is highlighted in the treemap with a black outline. In the example shown, we see that the dataset's C4 value decreases slightly (0.807) when the new sample is added, though the flag color remains red.
Further examination of the new sample can be done, to establish why the sample has low effect on the dataset's C4; the user clicks on the sample rectangle in the treemap, and is taken to a heat map view. The heatmap shows the similarity values between every word pair (from the premise/hypothesis/both) in a tooltip on hover, with the values mapped to the same color scale used for the treemap . For instance, in Figure~\ref{fig:wf2}, the words `man' and `champagne are repeated verbatim, and `overjoyed', `smiling', `celebrating', `pop', and `shoot' also have similarity of [0.6--1]. This indicates that several words in the sample are too closely related and constitute artifacts.
Each such visualization is therefore individually tailored to represent a specific DQI component of interest, based on the linguistic features examined for artifact creation in that component. We further elaborate on the design intuitions and analysis conducted with all the component visualizations available to the analyst in the supplementary.
Post analysis, if the analyst feels that the submitted sample requires only a minor change (for instance, reshuffling or the addition of a single word) to warrant acceptance, then they can invoke the TextFooler module to transform the sample adversarially, and then accept, thereby ensuring minimal data loss. In the case shown, TextFooler improves the sample's C4 with most of the heatmap varying from 0.3-0.7. Due to this, the analyst decides to accept the updated sample.
\textbf{5. Analyst Feedback:} Once the analyst has reached a decision, the crowdworker sees updates (Figure \ref{fig:wf2}) in (D) to the reviewed sample count (d2) -- increases to 16-- and the pie chart that indicates the distribution of actions taken by the analyst over all samples submitted by the crowdworker (d3). Additionally, in (E), the line chart (e1), which contains the history of previously submitted samples is updated. The x-axis denotes the sample number and the y-axis denotes the quality percentile (c3), of the corresponding sample. On click, the corresponding sample is loaded, along with its DQI component values and feedback to the crowdworker. The crowdworker can also use the box plot (e2), to view their current rank, and choose to view the sample history of another crowd worker.
\section{Evaluation}
We evaluate VAIDA's efficacy at providing real-time feedback to educate crowdworkers during benchmark creation using expert review and a user study. We also evaluate model performance (BERT~\cite{devlin2018bert}, RoBERTa~\cite{liu2019roberta}, GPT-3 (fewshot)~\cite{brown2020language}) on data created with VAIDA during the user study.
\subsection{Expert Review}
We present an initial prototype of our tool, to a set of three researchers with expertise in NLP and knowledge of data visualization. For each expert, the two interfaces were demoed in a Pair-Analytics session \cite{5718616}. Participants could ask questions and make interaction/navigation decisions to facilitate a natural user experience. All the experts appreciated the easily interpretable traffic-signal color scheme (and further suggested that alternates be provided to account for color blindness) and found the organization of the interfaces---providing separate detailed views within the analyst workflow-- a way to prevent cognitive overload (too much information on one screen). A caveat of this would be the inability for an analyst to simultaneously juxtapose different component visualizations. It was also hypothesized that a learning curve of ~$\sim$50--60 samples would be required for cohesive use of all system modules by both types of users; however, this would be offset by the eventual capability of users to deal with samples of middling quality based on their multi-granular feedback about artifact presence.
\subsection{User Study}\label{sec-4.3}
\textbf{Setup: } We approach several software developers, testing managers, and undergraduate/graduate students. Based on their domain familiarity (in NLP and visualization, rated from 1:novice-5:expert), we split them into 23 crowdworkers and 8 analysts for constructing NLI samples, given premises. There are 100 high-quality samples in the system at the time each participant participates in each ablation round (Table \ref{tab:conf}). For both types of users, a preliminary walkthrough of the system configuration, using 2 fixed samples, is conducted for each round of the study (Figure \ref{user1}). At the end of each round, they are also asked for their comments.\textsuperscript{\ref{foot1}}
\begin{table}[h]
\centering
\scriptsize
\resizebox{\columnwidth}{!}{%
\begin{tabular}{p{0.2\columnwidth}p{0.725\columnwidth}p{0.075\columnwidth}}
\toprule
\textbf{Configuration} & \textbf{Description} & \textbf{User}\\\midrule
Conventional Crowdsourcing & No feedback or auto modification tools& C \\\midrule
Conventional Analysis & Manual review without feedback or modification tools & A \\\midrule
Traffic Signal Feedback & Color mapping based on DQI values & C, A \\\midrule
AutoFix & Incremental sample auto-modification functionality& C \\\midrule
TextFooler & Adversarial sample transformation functionality & A \\\midrule
Visualization & Data visualizations for in-depth exploration (also includes traffic signal feedback) & A \\\midrule
Full System & All modules and system functionalities & C,A \\\bottomrule
\end{tabular}%
}
\caption{System configurations used for randomly ordered ablation rounds presented to users functioning as crowdworkers (C) and analysts (A) in the study.}
\label{tab:conf}
\end{table}
User experience (mental workload) is subjectively evaluated using NASA Task Load Index~\cite{hart2006nasa}\footnote{ \label{foot1} See Supplemental Material: User Study for more details. We do aggregated analysis of comments, full quotes of comments are present in the Supplemental Material. We also have IRB approval to conduct this user study.} (NASA TLX); each dimension is scored in a 100-points range, with 5-point steps. Users are also asked to report overall ratings for each system configuration at the end of the study.
\begin{figure}[h]
\centering
\includegraphics[width=0.9\columnwidth]{Figures/Setup1.png}
\caption{User Study Setup-- describes the timeframe and requirements of the user study over ablation rounds.}
\label{user1}
\end{figure}
\textbf{Analysis: } Figure \ref{user2} summarizes study results,\footnote{All results are found to have $p \leq 0.02$} averaged over all user responses, for different system configurations. The general trend across both crowdworkers and analysts is that there is: (i) significant improvement across all NASA TLX dimensions, (ii) increase in number of samples created/reviewed, and (iii) user ratings for the system, when comparing VAIDA to conventional interfaces. In the case of partial module availability, we find that the effectiveness of traffic signal feedback and visualizations is comparable. The use of AutoFix and TextFooler\ref{foot1} is more prevalent initially, on creation/evaluation of a low or middling quality sample for users as: (i) crowdworkers find constructive sample modification more difficult initially, and (ii) analysts are initially unsure of how to deal with middling quality samples.
\begin{figure}[t]
\centering
\includegraphics[width=0.85\columnwidth]{Figures/Setup2.png}
\includegraphics[width=0.85\columnwidth]{Figures/Setup3.png}
\caption{User Study Results-- NASA TLX dimension scores, and user scoring of the configurations, averaged across participant responses, for each ablation round. Percentages shown indicate comparison of full system scores with respect to the conventional system.}
\label{user2}
\end{figure}
\begin{figure*}[t]
\centering
\includegraphics[width=0.82\textwidth]{Figures/userlast.png}
\caption{User education curves. Cold start has no pre-existing samples, and direct-n has n pre-existing samples. Mental Demand, Temporal Demand, Frustration, and Effort are averaged, Physical Demand is ignored. Performance is plotted separately as it shows differing behavior from the others.}
\label{figuser}
\end{figure*}
\textbf{Learning Curve: } At the end of the study, all users are asked the following: \textit{``What do you think high quality means?"} We find that users are able to distinguish certain patterns that promote higher quality, such as keeping sentence length appropriate and uniform across labels (not too long/short), using complex phrasing (`not bad')/gender information/modifiers across labels, decreasing premise-hypothesis word overlap; they also do not display undesirable behavior like tweaking previously submitted samples just to create more. We also find an overall decrease of \textcolor{decR}{-45.8\%} in the level of artifacts of created samples, across all rounds of ablation.
\textbf{User Education: }We also conduct a secondary study where a subset of participants (7 crowdworkers and 2 analysts) agreed to create/ analyze samples, for varying numbers of pre-accepted samples (Figure \ref{figuser}), in only the full system condition. We find that when participants are directly started in situations with $>$ 500 samples in the system, their unfamiliarity with the system initially causes a steepening of the learning curve compared to the cold start condition; this also tapers and saturates more slowly than cold start as the users gain experience. This is attributed to: (a) an increased likelihood of samples of low/middling quality (more artifacts) being created (evinced by performance), and (b) lower impact of an individual sample on overall dataset quality. We also find that users who create $\sim$50 samples report lesser reliance on AutoFix as they get better at creating higher quality samples; those who analyze $\sim$75 samples use TextFooler more efficiently as they understand how to deal with samples of middling quality better in the cold start condition. These numbers increase by $\sim$25\% when users start with 500 pre-existing samples.
\begin{figure}[h]
\centering
\includegraphics[width=\columnwidth]{Figures/Model.png}
\caption{Model performance results for samples created during each ablation round of the user study.}
\label{fig:model}
\end{figure}
\subsection{Model Performance Results}
We evaluate BERT and RoBERTa (trained on the full SNLI dataset), and GPT-3 (in fewshot setting) against the data created during the ablation rounds of the user study.\footnote{\label{scd}We also create samples for the Story CLOZE dataset in the full system condition; see Supplementary Material} There are 100 high-quality samples(DQI>0.7) from the original SNLI dataset present in the system for the study\textsuperscript{\ref{mprd}}. This remains constant across all ablation rounds and for all users. 69 samples are created per ablation round during our study, across all users, for a total of 345(69*5) samples that we evaluate with the models. Figure \ref{fig:model} shows the results for samples over each round of ablation. (\footnote{\label{mprd}The dataset is included in the Supplemental Material.}) In the case of TextFooler, samples are created using the `full system' condition and then further modified using TextFooler by the analyst. The other sample sets are not modified by the analyst, and are directly accepted after evaluation.
We find that across all models, performance is lower when explicit quality feedback (via the traffic signal scheme) is provided, compared to the regular crowdsourcing condition. The highest drop is seen for BERT (\textcolor{decR}{-20.66\%}), while GPT-3 shows a lesser magnitude of performance decrease (\textcolor{decR}{-12.89\%}). Performance further decreases for all models when AutoFix is implemented, indicating the effectiveness of this module in seeding suggestions for sample improvement; the magnitude of performance loss follows BERT$>>$RoBERTa$>>$GPT-3. We can attribute this apparent variation in model robustness i.e., BERT$<<$RoBERTa$<<$GPT-3 as proportionate to increase in size of (i) the respective language models, and (ii) the pre-training corpora.
A significant decrease is seen in the full system and TextFooler conditions. Particularly, in the TextFooler round, performance sharply decreases for all models (\textcolor{decR}{-31.3\%} BERT, \textcolor{decR}{-22.5\%} RoBERTa, \textcolor{decR}{-14.98\%} GPT-3). Furthermore, in the TextFooler round, there is a \textcolor{decR}{-71.70\%} decrease in the level of sample artifacts. This indicates that crowdworkers and analysts are able to utilize VAIDA's affordances to create more robust text samples.
\section{Discussion and Conclusion}
We propose VAIDA, a paradigm to address benchmark artifacts, by integrating human-in-the-loop sensemaking with continuous visual feedback. VAIDA uses several visualization interfaces to analyze quality considerations (based on artifact levels) at multiple granularities. While we do not explicitly address computational quality control or fairness consideration (though some aspects can be targeted by currently integrated metrics), since VAIDA is extensible to the incorporation of customized backend-metrics, we believe our paradigm can support multi-faceted benchmark evaluation.
In our usability evaluation, we see that users report greater satisfaction, and lower difficulty with their work and system experience; this implies possible higher crowdworker retention and engagement. Additionally, in our study, we see that users effectively identify and avoid artifact patterns during sample creation. Based on our study results, we believe that a minimum of 30 annotators would be needed for large-scale data creation to ensure timely feedback (i.e., sample decision provided within 24 hours) to crowdworkers. Based on our secondary study, we believe analysts will exhibit increased performance and maintain satisfaction ratings in full-scale creation, as they will become well-versed in the nuances of bias for the data-creation task they are evaluating, as well as the visualizations being used. This, however, is contingent on restricting the visualization views to display only the ~200--300 samples with closest artifact levels to the sample being evaluated.
Overall, samples created with VAIDA are found to not only of higher quality than achieved with conventional crowdsourcing, but are also seen to be adversarial across transformer models. This is also maintained across multiple task types-- we additionally create StoryCLOZE \cite{schwartz2017effect} samples with VAIDA\textsuperscript{\ref{scd}}. This was done independent of the study described in the paper, with 4 crowdworkers creating samples. However, for this, several interface features had to be changed, so we focus on reporting only NLI results in the main paper. VAIDA hence demonstrates a novel, dynamic approach for building benchmarks and mitigating artifacts, and serves as a starting point for the next generation of benchmarks in machine learning.
\section*{Limitations}
In future work, we intend to integrate VAIDA with an actual crowdsourcing framework, and run a full-scale data creation study to create a high-quality benchmark. Expanding to such a setup will require additional back-end engineering, to ensure that (i) timely and accurate feedback continues to be provided in real-time to crowdworkers, (ii) analysts are available on hand to process samples in a timely manner. This is out of scope for the current paper (e.g., it would require a significant budget), but we see our current work as a stepping stone in this direction. Additionally, studying the problem and designing the visualizations and real-time feedback mechanisms are essential steps before moving to large-scale evaluation; the novel affordances and designs are a necessary first step, and we believe they will be impactful to the NLP community.
Crowdworker retention and engagement in this full-scale setting also need to be evaluated, in order to better contextualize the learning curve associated with system usage and handling artifact creation, given an increasingly higher number of pre-existing system samples. Comparing this setup directly with the effect of in-depth user training \cite{roit2019crowdsourcing} on artifact creation and review, prior to crowdsourcing, would also further help analyze and quantify if/how user strategy and performance changes during VAIDA usage.
Design modifications when creating different types of datasets will mainly require the redesigning of sample input fields, corresponding to the application and the type of metric used for artifact evaluation. However, in full-scale dataset creation, the visualization views for the analyst corresponding to different artifact types will have to be restricted to the $\sim$300 samples closest artifact levels, to the given sample being created, in order to facilitate scalable processing for analysts. Additionally, since visualization familiarity is required for the analyst to effectively review samples, the analysts may choose to streamline analysis by only using a subset of the provided visualization types in their version of the system, corresponding to the application domain.
\subsection{Infrastructure Used }\label{supp1}
In Section 3, we describe VAIDA's flow by high level workflow and back-end processes(DQI, AutoFix, and TextFooler). Further, as discussed in Subsection 3.2 DQI can be used for quantifying artifact presence for the: i) overall benchmark, and ii) impact of new samples. Depending on the task at hand we run our experiments in different hardware settings. The DQI calculations run mostly using CPU, for new samples as well as overall samples. The AutoFix procedure, as explained in Subsection 3.2, gives the user assistance in improving quality on a per submission basis. Therefore that does not require high GPU intensive systems; we have provisions to shift execution to a GPU as well if necessary to speed up the process. For TextFooler the fine tuning of the model is run on "TeslaV100-SXM2-16GB"; CPU cores per node 20; CPU memory per node: 95,142 MB; CPU memory per core: 4,757 MB-- this is not a necessity as code has been tested on lower configuration GPUs as well but we have run our experiments in this setting. The attack part of the TextFooler requires more memory and we run that code on "Tesla V100-SXM2-32GB" com-pute Capability: 7.0 core Clock: 1.53GHz, coreCount: 80, device Memory Size: 31.75GiB device Memory Bandwidth: 836.37GiB/s.
\subsection{Run-time Estimations}\label{supp2}
The DQI calculations run on CPU (for real life setting purposes); for the approximate estimate of the time taken, we run experiments for fixed data size of 10K samples. If the DQI calculations are done to calculate the impact of individual new samples it take a couple of seconds. On the other hand, If we take the whole 10k size dataset it takes around 48 hours to complete the process on CPU. This whole process can be run in parallel to reduce the time taken to 16 hours.
The TextFooler part consists of two steps-- the fine tuning part and attack part-- for generating adversaries. For fine tuning models we use "TeslaV100-SXM2-16GB", and it takes 20-30 minutes to complete the process. For the attack part we use "Tesla V100-SXM2-32GB", which takes 2-3 hrs for completing 20k data samples. This estimate requires the cosine similarity matrix for word embeddings to be calculated before hand which takes around 1-2 hrs, but this step has to be done only if the word embeddings are modified. This is a rare task so we have kept this separated.
\subsection{Hyper Parameters}\label{supp3}
To look at the estimations of DQI and its variations, we have kept basic hyper-parameters fixed in the experiments. We keep the learning rate to 1e-5, the number of epochs during the experiments are varied from 2-3, the per gpu train batch and eval batch sizes vary from 8-64 samples (the results shown are with respect to a batch size of 8), adam epsilon is set to 1e-8, weight decay is set to 0, maximum gradient normalisation is set to 1, and maximum sequence length is set to 128. For TextFooler the the semantic similarity is fixed to 0.5 uniformly for all the experiments shown in this paper.
Additionally, the variations and range in the DQI parameters are dataset specific, i.e., hyperparameters depend on the application task. \cite{Mishra2020DQIAG} design DQI as a generic metric to evaluate diverse benchmarks. However, the definitions of what constitutes high and low quality will vary depending on the application. For example, BiomedicaNLP might have lower tolerance levels for spurious bias than General NLP. Another case is in water quality-- cited as an inspiration for DQI by \cite{Mishra2020DQIAG}-- where the quality of water needed for irrigation is different than that of drinking or medicine. We can therefore say that the hyper-parameters in the form of boundaries separating high and low quality data (i.e., inductive and spurious bias) are dependent on applications.
\subsection{Related Work}\label{supp4}
\subsubsection{Sample Quality and Artifacts}
Data Shapley \cite{ghorbani2019data} has been proposed as a metric to quantify the value of each training datum to the predictor performance. However, the metric might not signify bias content, as the value of training datum is quantified based on predictor performance, and biases might favor the predictor. Moreover, this approach is model and task-dependent. VAIDA uses DQI (Data Quality Index), proposed by ~\cite{Mishra2020DQIAG}, to: (i) compute the overall data quality for a benchmark with $n$ data samples, and (ii) compute the impact of a new $(n+1)^{th}$ data sample. \cite{wang2020vibe} concurrently propose a tool for measuring and mitigating artifacts in image datasets.
Data Shapley \cite{ghorbani2019data} has been proposed as a metric to quantify the value of each training datum to the predictor performance. However, this approach is model and task dependent. More importantly, the metric might not signify bias content, as the value of training datum is quantified based on predictor performance, and biases might favor the predictor. VAIDA uses DQI (data quality index), proposed by ~\cite{Mishra2020DQIAG}, to: (i) compute the overall data quality for a benchmark with $n$ data samples, and (ii) compute the impact of a new $(n+1)^{th}$ data sample. The quality of individual features (aspects) of samples are evaluated based on decreasing presence of artifacts and increasing generalization capability. In a concurrent work \cite{wang2020vibe}, a tool for measuring and mitigating bias in image datasets has also been proposed. DQI estimates artifact presence by calculating seven component values corresponding to a set of language properties;, along with their interpretation in VAIDA.
\subsubsection{Crowdsourcing Pipelines}
\label{sub:pipelines}
\textbf{Adversarial Sample Creation: } Pipelines such as Quizbowl\cite{wallace2019trick} and Dynabench\cite{kiela2021dynabench}, highlight portions of text from input samples during crowdsourcing, based on how important they are for model prediction; this prompts users to alter their samples, and produce samples that can fool the model being used for evaluation. While these provide more focused feedback compared to adversarial pipelines like ANLI \cite{nie2019adversarial}, which do not provide explicit feedback on text features, adversarial sample creation is contingent on performance against a specific model (Quizbowl for instance is evaluated against IR and RNN models, and may therefore not see significant performance drops against more powerful models). Additionally, such sample creation might introduce new artifacts over time into the dataset and doesn't always correlate with high quality-- for instance, a new entity introduced to fool a model in an adversarial sample might be the result of insufficient inductive bias, though reducing the level of spurious bias.
A similar diagnostic approach is followed for unknown unknown identification-- i.e., instances for which a model makes a high confidence prediction that is incorrect. \cite{attenberg2015beat} and \cite{vandenhof2019hybrid} propose techniques to identify UUs, in order to discover specific areas of failure in model generalization through crowdsourcing. The detection of these instances is however, model-dependent; VAIDA addresses the occurrence of such instances by comparing sample characteristics between different labels to identify (and resolve) potential artifacts and/or under-represented features in created data.
\textbf{Promoting Sample Diversity: } Approaches focusing on improving sample diversity have been proposed, in order to promote model generalization. \cite{yaghoub2020dynamic} use a probablistic model to generate word recommendations for crowdworker paraphrasing. \cite{larson2019outlier} propose retaining only the top k\% of paraphrase samples that are the greatest distance away from the mean sentence embedding representation of all collected data. These `outlier' samples are then used to seed the next round of paraphrasing. \cite{larson2020iterative} iteratively constrain crowdworker writing by using a taboo list of words, that prevents the repetition of over-represented words, which are also a source of spurious bias. Additionally, \cite{stasaski2020more} assess the new sample's contribution to the diversity of the entire sub-corpus.
DQI encompasses the aspects of artifacts studied by the aforementioned works; it further quantifies the presence of many more inter and intra-sample artifacts, and provides a one stop solution to address artifact impact on multiple fronts. VAIDA leverages DQI to identify artifacts, and further focuses on educating crowdworkers on exactly `why' an artifact is undesirable, as well as the impact its presence will have on the overall corpus. This is in contrast to the implicit feedback provided by word recommendation and/or highlighting in prior works-- VAIDA facilitates the elimination of artifacts without the unintentional creation of new artifacts, something that has hitherto remained unaddressed.
\subsubsection{Task Selection and Controlled Dataset Creation}
In this work, we demonstrate VAIDA for a natural language inference task (though it is task-independent), and mimic the SNLI dataset creation and validation processes. Elicited annotation has been found to lead to social bias in SNLI using probablistic mutual information (PMI) \cite{rudinger2017social}. Visual feedback is provided based on DQI (which takes PMI into account) to explicitly correct this bias, and discourage the creation of such samples. Also, human annotation of machine-generated sentences/sentences pulled from existing texts instead of elicitation has been suggested to reduce such bias \cite{zhang2017ordinal}. However, machine-generated text might look artificial, and work has shown that text generation has its own set of quality issues \cite{mathur2020tangled}. While we use AutoFix and TextFooler as modules to automatically transform samples, they are designed to be used in parallel with human sample creation. Their results can also be further modified by humans prior to submission. We see less reliance on these tools over the course of our user study, as discussed in Subsection 6.2. Additionally, previous work \cite{roit2019crowdsourcing} in controlled dataset creation trains crowdworkers, and selects a subset of the best-performing crowdworkers for actual corpus creation. Each crowdworker's work is reviewed by another crowdworker, who acts as an analyst (as per our framework) of their samples. However, in real-world dataset creation, such training and selection phases might not be possible. Additionally, the absence of a metric-in-the-loop basis for feedback provided during training can potentially bias (through trainers) the created samples.
\subsection{DQI Components}\label{supp5}
DQI shows the (i) the overall data quality and (ii) the impact of new data created on the overall quality. In this paper, higher quality implies lower artifact presence and higher generalization capability. DQI clubs artifacts into seven broad aspects of text, which cover the space of various possible interactions between samples in an NLP dataset. Please refer to \cite{Mishra2020DQIAG} and \cite{mishra2022survey} for a full explanation of parameters.
\begin{figure*}[!t]
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p1.png}
\caption{$DQI_{c1}$ Visualization Prior to New Sample Addition}
\label{fig:Vis1before}
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p1ns.png}
\caption{$DQI_{c1}$ Visualization On New Sample Addition}
\label{fig:Vis1after}
\end{figure*}
\subsection{Interface Design Intuitions}\label{supp7}
\paragraph{Careful Selection of Visualizations}
Prior to the design of test cases and a user interface, data visualizations highlighting the effects of sample addition are built. Considering the complexity of the formulas for the components of empirical DQI, we carefully select visualizations to help illustrate and analyze the effect to which individual text properties are affected.
\subsubsection{Vocabulary}
\paragraph{Which Characteristics of Data are Visualized?}
The contribution of samples to the size of the vocabulary is tracked using a dual axis bar chart. This displays the vocabulary size, along with the vocabulary magnitude, across the train, dev, and test splits for the dataset. By randomizing data splits, the distribution of vocabulary across dataset samples can clearly be identified. We use a dual axis chart as juxtaposition of the vocabulary magnitude against raw counts of words better reflects the evenness of the vocabulary distribution; it is not useful to have only a few samples contributing new words as other samples automatically become easy for the model to solve.
To further clarify the contribution of individual samples to vocabulary, the distribution of sentence lengths is plotted as a histogram. Each sample contributes two sentences, i.e., the premise and hypothesis statements. Figure \ref{fig:Vis1before} illustrates this. The histogram provides analysts with a frame of reference to identify gaps or outliers in the distribution, essential for determining which sentences are undesirable for the corpus due to extremely high (low inductive bias) or extremely low (high artifact-- spurious bias) vocabulary contribution.
\subsubsection{Inter-sample N-gram Frequency and Relation}
\paragraph{Which Characteristics of Data are Visualized?}
There are different granularities of samples that are used to calculate the values of this component, namely: words, POS tags, sentences, bigrams, and trigrams. The granularities' respective frequency distributions and standard deviations are utilized for this calculation.
\paragraph{Bubble Chart for visualizing the frequency distribution:}
A bubble chart is used to visualize the frequency distribution of the respective granularity. This design choice is made in order to clearly view the contribution made by a new sample when added to the existing dataset in terms of different granularities. The bubbles are colored according to the bounds set for frequencies by the hyperparameters, and sized based on the frequency of the elements they represent. Additionally, some insight into variance can be obtained from this chart, by observing the variation in bubble size.
\paragraph{Bullet Chart for impact of new sample:}
The impact of sample addition on standard deviation can be viewed using the bullet chart. The bullet chart is useful to visually track performance against a target (in this case ideal standard deviation), displaying results in a single column; it looks like a thermometer and is therefore easy to follow. The red-yellow-green color bands for each granularity represent the standard deviation bounds of that granularity. The vertical black line represents the ideal value of the standard deviation of that granularity. The two horizontal bars represent the value of standard deviation before and after the new sample's addition. Figure \ref{fig:Vis2before} illustrates the visualization.
\begin{figure*}[!t]
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p2.png}
\caption{$DQI_{c2}$ Visualization Prior to New Sample Addition}
\label{fig:Vis2before}
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p2ns.png}
\caption{$DQI_{c2}$ Visualization On New Sample Addition}
\label{fig:Vis2after}
\end{figure*}
\begin{figure*}[!t]
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p3.png}
\caption{$DQI_{c3}$ Visualization Prior to New Sample Addition}
\label{fig:Vis3before}
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p3ns.png}
\caption{$DQI_{c3}$ Visualization On New Sample Addition}
\label{fig:Vis3after}
\end{figure*}
\subsubsection{Inter-sample STS}
\paragraph{Which Characteristics of Data are Visualized?}
The main units used in this DQI component are the similarity values between sentences across the dataset. This refers to either premise or hypothesis statements, relative to all other premise/hypothesis statements. In order to understand the similarity relations of sentences, a force layout and horizontal bar chart are used. This is illustrated in Figure \ref{fig:Vis3before}.
\paragraph{Force Layout for Similar Sentence Pairs}
In the force layout, those sentence pairs with a similarity value that meets the minimum threshold are connected. Each node represents a sentence. The thickness of the connecting line depends on how close the similarity value is to the threshold. Similarity values are used to create this network, as the aim of this component is to drill down into whether a sample has sufficient inductive bias (i.e., is closely linked to a sufficient extent to exiting samples), and also if a sample is too similar (spurious bias) to existing samples.
\paragraph{Horizontal Bar Chart for Most Similar Sentences}
In the horizontal bar chart, the sentences that are most similar to the given sentence are ordered in terms of their similarity value. The bar colors are centered around the threshold. This helps identify the most important subset to juxtapose the given sample against;the analyst can use this subset to for instance, decide if a moderate quality sample requires a small or big change in order to reacch acceptable quality..
\subsubsection{Intra-sample Word Similarity}
\paragraph{Which Characteristics of Data are Visualized?}
In this section, A sample's word similarity is viewed in terms
of premise-only, hypothesis-only, and both. The relationship between non-adjacent words in the sample's sentences is analyzed specifically.
\paragraph{Overview Chart for Average Word Similarities and Heatmap for Single Sample}
The overview chart that is used is a tree map, which uses the average value of all word similarities per sample- i.e., concatenated premise and hypothesis- to color and group its components. This is illustrated in Figure \ref{fig:Vis4before}. Treemaps capture relative sizes of data categories, allowing for quick perception of the items that are large contributors to each category. This makes them ideal to analyze the inter-relationships between different word pairs across sample, in a concise manner.
The treemap also makes it easy to drill down into the specifics of a particular sample even further. This detailed view is provided in the form of a heatmap. All the words in a single sample, are plotted against each other, as shown in Figure \ref{fig:Vis4component}. The heatmap provides a mechanism for word-level drill down of sample similarity. Like with the previous component, this helps provide the analyst with a frame of reference as to whether a moderate quality sample can be sent to TextFooler or not.
\begin{figure*}[!t]
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p4.png}
\caption{$DQI_{c4}$ Visualization Prior to New Sample Addition}
\label{fig:Vis4before}
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p4nsa.png}
\caption{$DQI_{c4}$ Visualization On New Sample Addition: Dataset View}
\label{fig:Vis4after}
\end{figure*}
\subsubsection{Intra-sample STS}
\paragraph{Which Characteristics of Data are Visualized?}
Premise-Hypothesis similarity is analyzed on the basis of length variation, meeting a minimum threshold, and similarity distribution across the dataset. The first is addressed already in the vocabulary property by viewing the sentence length distribution. The other two are visualized using a histogram and kernel density estimation curve, as shown in Figure \ref{fig:Vis5before}.
\paragraph{Histogram and Kernel Density Curve for Sample Distribution}
The histogram represents the distribution of the samples, and is colored by centering around the threshold as the ideal value. The number of bins can be changed, and therefore multi-level analysis can be conducted. This helps identify the proportion of samples that are of non-optimal range.
The kernel density curve is used to check for the overall skew of the distribution. KDE helps visualize the distribution sans user defied bins; this is colored to reflect the bi-linear color scale, and indicates the probability with which a sample will be correctly solved by a model given its similarity. This helps contextualize the level of artifacts relating to word overlap and sentence similarity in the sample.
\begin{figure*}[!t]
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p4nsb.png}
\caption{$DQI_{c4}$ Visualization On New Sample Addition: Sample View}
\label{fig:Vis4component}
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p5.png}
\caption{$DQI_{c5}$ Visualization Prior to New Sample Addition}
\label{fig:Vis5before}
\end{figure*}
\begin{figure*}[!t]
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p5ns.png}
\caption{$DQI_{c5}$ Visualization On New Sample Addition}
\label{fig:Vis5after}
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p6a.png}
\caption{$DQI_{c6}$ Visualization Prior to New Sample Addition}
\label{fig:Vis6before1}
\end{figure*}
\subsubsection{N-Gram Frequency per Label}
\paragraph{Which Characteristics of Data are Visualized?}
This component drills down on the second component, to view the patterns seen in granularities per label. There are two small multiples charts, divided based on label, used in this view- a violin plot and a box plot.
\paragraph{Violin plot and Kernel Density Curve for Skew of Distribution:}
The violin plots are structured to display both jittered points, according to their frequency distribution, as well as a kernel density curve to judge the skew of the distribution. The points each represent an element of the granularity.
\paragraph{Box Plots for More Information}
The box plots are used to garner more information about the distribution, in terms of its min, max, median, mean, and inter quartile range. These help further characterize the distribution, as well as provide a quantitative definition of the skew seen using density curves. Jittered points representing elements are present in this plot as well.
\begin{figure*}[!t]
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p6b.png}
\caption{$DQI_{c6}$ Visualization after removing outliers Prior to New Sample Addition}
\label{fig:Vis6before2}
\end{figure*}
\begin{figure*}[!t]
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p6nsb.png}
\caption{$DQI_{c6}$ Visualization with mouseover On New Sample Addition}
\label{fig:Vis6after2}
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p7.png}
\caption{$DQI_{c7}$ Visualization Prior to New Sample Addition}
\label{fig:Vis7before}
\end{figure*}
\begin{figure*}[!t]
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/p7ns.png}
\caption{$DQI_{c7}$ Visualization On New Sample Addition}
\label{fig:Vis7after}
\end{figure*}
\subsubsection{Inter-split STS}
\paragraph{Which Characteristics of Data are Visualized?}
Train-Test similarity must be kept minimal to prevent data leakage. This component's main feature is finding the train split sample that is most similar to a given test split sample.
\paragraph{Parallel Coordinate Graph for Train-Test Similarity:} A subset of test and train samples, all found to have close similarity within their respective splits, and significant similarity across the splits are plotted as a one step parallel coordinate graph, with test samples along one axis, and train samples along the other. This subset is seeded with those samples closest in similarity to the new sample to be introduced, based on the third component's visualization. The links connecting points on the two axes are drawn between the most similar matches across the split, as shown in Figure \ref{fig:Vis7before}.
\subsection{AutoFix and TextFooler Examples}
\label{supp8}
See Tables \ref{tab:Autofixeg}, \ref{tab:tfeg}.
\begin{figure*}[t]
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/csw.png}
\caption{Crowdworker-View}
\label{fig:cview}
\includegraphics[width=\linewidth,height=8.55cm]{OLD_figures/analyst.png}
\caption{Analyst View}
\label{fig:anaview}
\end{figure*}
\begin{table*}[t]
\textsf{
{
\footnotesize
\begin{tabularx}{\textwidth}{p{3cm}p{6.8cm}X}
\toprule
\textbf{Task} & \textbf{Description} & {Component}\\
\midrule \rowcolor{gray!15}
New Sample & Adds the sample under review to dataset and updates visualizations. & All\\
Undo & Removes sample under review from dataset and updates visualizations.& All\\ \rowcolor{gray!25}
Randomize Split & Randomized re-sampling of data across splits in a 70:10:20 ratio. & Vocabulary\\
Undo Split & Reverses last random split generated. & Vocabulary\\ \rowcolor{gray!15}
Save Split & Freezes split for the remainder of analysis. & Vocabulary\\
Changing Granularity & View granularity can be changed by selecting drop down option. & Inter-sample N-gram Frequency and Relation, N-Gram Frequency per Label \\ \rowcolor{gray!15}
Change Heat Map View & Using the drop down, the heatmap shows word similarities for the (a) premise, (b) hypothesis, or (c) both sentences. & Intra-sample Word Similarity\\
Rebinning Histogram & By filling a new value in the textbox, the number of bins in the histogram changes to that value. & Intra-sample STS\\ \rowcolor{gray!15}
Remove Outliers & Removes elements with frequency count less than median count of granularity being viewed.&N-Gram Frequency per Label\\
Include All Samples & Displays all elements for a granularity.&N-Gram Frequency per Label\\
\bottomrule
\end{tabularx}
}
}
\caption{Task Descriptions for Visual Interfaces}
\label{tab:dqi_tasks}
\end{table*}
\begin{table*}[t]
\large
\resizebox{1.9\columnwidth}{!}{%
\begin{tabular}{llllll}
\hline
\textbf{Premise} & \textbf{Orig. Hypothesis} & \textbf{DQI} & \textbf{\begin{tabular}[c]{@{}l@{}}Suggested \\ Words\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}New Hypothesis based \\ on suggestions\end{tabular}} & \textbf{New DQI} \\ \hline
\begin{tabular}[c]{@{}l@{}}A woman, in a green shirt, \\ preparing to run on a treadmill.\end{tabular} & \begin{tabular}[c]{@{}l@{}}A woman is preparing to\\ sleep on a treadmill\end{tabular} & \begin{tabular}[c]{@{}l@{}}2.4650170\end{tabular} & preparing,sleep & \begin{tabular}[c]{@{}l@{}}A woman is organizing\\ to rest on a treadmill\end{tabular} & \begin{tabular}[c]{@{}l@{}}2.5275722\end{tabular} \\ \hline
The dog is catching a treat & The cat is not catching a treat & \begin{tabular}[c]{@{}l@{}}2.752542\end{tabular} & catching & the cat is not getting a treat & \begin{tabular}[c]{@{}l@{}}3.6909140\end{tabular} \\ \hline
\begin{tabular}[c]{@{}l@{}}Three young men are watching\\ a tennis match on a large screen\\ outdoors\end{tabular} & \begin{tabular}[c]{@{}l@{}}Three young men watching \\ a tennis match on a screen \\ outdoors, because their \\ brother is playing\end{tabular} & \begin{tabular}[c]{@{}l@{}}2.6435402\\ 891414217\end{tabular} & \begin{tabular}[c]{@{}l@{}}young,watching,\\ playing\end{tabular} & \begin{tabular}[c]{@{}l@{}}Three youthful men observing\\ a tennis match on a screen outdoors, \\ because their brother is performing.\end{tabular} & \begin{tabular}[c]{@{}l@{}}2.6787982\end{tabular} \\ \hline
\end{tabular}%
}
\caption{A few samples for Autofix with Intra Sample STS in DQI }
\label{tab:Autofixeg}
\end{table*}
\begin{table*}[t]
\centering
\resizebox{1.9\columnwidth}{!}{%
\begin{tabular}{lllllll}
\hline
\textbf{Premise} & \textbf{Orig. Hypothesis} & \textbf{DQI} & \textbf{New Hypothesis} & \textbf{New DQI} & \textbf{Label}\\\hline
A woman and a man sweeping the sidewalk. & The couple is sitting down for dinner. & 2.416 & The couple is meeting for dinner. & 3.479 & Contradiction \\ \hline
A woman enjoying the breeze of a primitive fan. & The woman has a fan. & 2.127 & The woman owns a fan. & 2.733 & Entailment \\ \hline
There is a man in tan lounging outside in a chair. & A man is preparing for vacation. & 2.801 & A man is arranging to take a vacation. & 3.502 & Neutral \\ \hline
\end{tabular}%
}
\caption{Examples for TextFooler, with DQI's Intra-sample STS values for existing SNLI samples.}
\label{tab:tfeg}
\end{table*}
\subsection{User Study}
\label{supp9}
\paragraph{AutoFix Suggestions:} See Tables \ref{tab:Autofix}, \ref{tab:tfeg}.
\begin{table*}[t]
\large
\resizebox{\textwidth}{!}{%
\begin{tabular}{llllll}
\hline
\textbf{Premise} & \textbf{Orig. Hypothesis} & \textbf{DQI} & \textbf{\begin{tabular}[c]{@{}l@{}}Suggested \\ Words\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}New Hypothesis based \\ on suggestions\end{tabular}} & \textbf{New DQI} \\ \hline
\begin{tabular}[c]{@{}l@{}}A woman, in a green shirt, \\ preparing to run on a treadmill.\end{tabular} & \begin{tabular}[c]{@{}l@{}}A woman is preparing to\\ sleep on a treadmill\end{tabular} & \begin{tabular}[c]{@{}l@{}}2.4650170\end{tabular} & preparing,sleep & \begin{tabular}[c]{@{}l@{}}A woman is organizing\\ to rest on a treadmill\end{tabular} & \begin{tabular}[c]{@{}l@{}}2.5275722\end{tabular} \\ \hline
The dog is catching a treat & The cat is not catching a treat & \begin{tabular}[c]{@{}l@{}}2.752542\end{tabular} & catching & the cat is not getting a treat & \begin{tabular}[c]{@{}l@{}}3.6909140\end{tabular} \\ \hline
\begin{tabular}[c]{@{}l@{}}Three young men are watching\\ a tennis match on a large screen\\ outdoors\end{tabular} & \begin{tabular}[c]{@{}l@{}}Three young men watching \\ a tennis match on a screen \\ outdoors, because their \\ brother is playing\end{tabular} & \begin{tabular}[c]{@{}l@{}}2.6435402\\ 891414217\end{tabular} & \begin{tabular}[c]{@{}l@{}}young,watching,\\ playing\end{tabular} & \begin{tabular}[c]{@{}l@{}}Three youthful men observing\\ a tennis match on a screen outdoors, \\ because their brother is performing.\end{tabular} & \begin{tabular}[c]{@{}l@{}}2.6787982\end{tabular} \\ \hline
\begin{tabular}[c]{@{}l@{}}A man in a green apron smiles\\ behind a food stand\end{tabular} & A man smiles & \begin{tabular}[c]{@{}l@{}}3.2367785\end{tabular} & smiles & A person is grinning. & \begin{tabular}[c]{@{}l@{}}6.303777\end{tabular} \\\hline
\end{tabular}%
}
\caption{A few samples for Autofix with ISSTS in DQI }
\label{tab:Autofix}
\end{table*}
\paragraph{NASA TLX:}
The NASA Task Load Index (NASA-TLX) is a subjective, multidimensional assessment tool that rates perceived workload in order to assess a task, system, or team's effectiveness or other aspects of performance \cite{hart2006nasa}.
NASA-TLX divides the total workload into six subjective subscales that are represented on a single page. There is a description for each of these subscales that the subject should read before rating. They rate each subscale within a 100-point range, with 5-point steps, as shown in Figure \ref{fignasa}. Providing descriptions for each measurement can be found to help participants answer accurately \cite{schuff2011comparing}. The descriptions are as follows:
\begin{itemize}
\item \textbf{Mental Demand: } How much mental and perceptual activity was required? Was the task easy or demanding, simple or complex?
\item \textbf{Physical Demand: } How much physical activity was required? Was the task easy or demanding, slack or strenuous?
\item \textbf{Temporal Demand: } How much time pressure did you feel due to the pace at which the tasks or task elements occurred? Was the pace slow or rapid?
\item \textbf{Performance: } How successful were you in performing the task? How satisfied were you with your performance?
\item \textbf{Effort: } How hard did you have to work (mentally and physically) to accomplish your level of performance?
\item \textbf{Frustration: } How irritated, stressed, and annoyed versus content, relaxed, and complacent did you feel during the task?
\end{itemize}
\begin{figure*}[!t]
\centering
\includegraphics[width=0.7\textwidth]{NASA.png}
\caption{NASA TLX Form}
\label{fignasa}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[width=\textwidth]{Demographics.png}
\caption{Demographic information for the User Study}
\label{fig:demouser}
\end{figure*}
We record participant demographics-- age, gender, and occupation. We also ask participants to rate their familiarity with Visualization and NLP, on a scale of 1 (novice) to 5 (expert). Demographic information is shown in Figure \ref{fig:demouser}. Participants are asked to fill this form at the end of each round of the user study. We also record the number of questions participants successfully create, as well as a record of how often participants use each module in the full system round. At the end of the user study, participants are asked what their impression of data quality is, and their free response is recorded.
\paragraph{Subscale Wise Results:}
Individual results of the averaged subscales in Figure \ref{figuser} are shown in Figures \ref{figc},\ref{figa}. Physical demand does not change significantly across user study rounds.
\begin{figure*}[t]
\centering
\includegraphics[width=0.6\textwidth]{CW.png}
\caption{NASA TLX-- Crowdworker Subscale Results}
\label{figc}
\end{figure*}
\begin{figure*}[t]
\centering
\includegraphics[width=0.7\textwidth]{A.png}
\caption{NASA TLX-- Analyst Subscale Results}
\label{figa}
\end{figure*}
\subsection{Expert and User Comments}
\label{supp10}
\textbf{Experts \textit{(P)}:} We present an initial prototype of our tool, to a set of three researchers with expertise in NLP and knowledge of data visualization, in order to judge the interface design. For each expert, the crowdworker interface and then analyst interfaces were demoed. Participants ($P$) could ask questions and make interaction/navigation decisions to facilitate a natural user experience. All the experts appreciated the easily interpretable traffic-signal color scheme and found the organization of the interfaces---providing separate detailed views within the analyst workflow-- a way to prevent cognitive overload (too much information on one screen); \textbf{$P_2$} said the latter \textit{``…enhances readability for understanding the data at different granularities."}. \textbf{$P_1$} suggested the inclusion of \textit{``…a provenance module within the analyst views to show historical sample edits and overall data quality changes over time to understand how data quality evolves as the benchmark size increases… this would help with the bubble plot and tree map which will get more cluttered and complex as data size increases"}. Additionally \textbf{$P_3$} remarked that \textit{``The frequency of samples of middling quality should increase as benchmark size increases, but the initial exposure that analysts will have with higher or lower quality samples should lessen the learning curve as they are familiar enough with interface subtleties by the time they begin to encounter more challenging cases."}
\textbf{Crowdworkers \textit{(C)}: } When presented with traffic signal feedback, crowdworkers report that the time and effort required to create high quality samples increases--\textit{``You need to keep redoing the sample since when you see it's all red, you know it's probably not going to be accepted"}\textbf{$(C_3)$}; however, they are more confident about their performance and sample quality \textit{``...when there's green, I know I've done it right, and it cuts down on my having to create a lot of samples to get paid"} \textbf{$(C_{15})$}. We find that AutoFix usage \textsuperscript{\ref{foot1}} causes an unexpected increase in mental and temporal demand, as well as frustration; we attribute this to observed user behavior-- \textit{``I'm not sure how much I trust this recommendation without seeing the colors"}\textbf{$(C_{12})$}, and \textit{``I'd prefer to change a couple of things since I can't see the feedback anymore}\textbf{$(C_{21})$}. The drastic improvement over all aspects (highest for frustration) in the case of using the full system is in line with this observation--\textit{``This is so easy, I can create samples really fast, and I have a better chance of getting more accepted."}\textbf{$(C_{8})$} and \textit{``Now that I get the feedback along with the recommendation, I can see the quality improvement. So using the recommendation is now definitely faster."}\textbf{$(C_{12})$}. The number of questions created per round as well as system scores also follows this trend, across all types of crowdworkers.
\textbf{Summary:} Traffic signal feedback initially increases time (\textcolor{incG}{+25\%}) and effort (\textcolor{incG}{+60\%}) required to create high quality samples, as users have to correct them. However they are more confident (performance-- \textcolor{incG}{+27\%}) of sample quality. AutoFix usage causes an unexpected increase in effort (\textcolor{incG}{+5\%}) and frustration (\textcolor{incG}{+88.8\%}), as users do not fully trust recommendations without visual feedback. The drastic improvement over all aspects (frustration-- \textcolor{decR}{-44.4\%}, mental demand-- \textcolor{decR}{-38.1\%}, temporal demand-- \textcolor{decR}{-29.1\%}, effort-- \textcolor{decR}{-20\%}, average decrease in difficulty-- \textcolor{decR}{-31.1\%}, performance-- \textcolor{incG}{+34.6\%}) in the case of using the full system is in line with this observation. The number of questions created per round (traffic signal-- \textcolor{decR}{-8.3\%}, AutoFix-- \textcolor{incG}{+25\%}, full system-- \textcolor{incG}{+83.3\%}) as well as system scores (traffic signal-- \textcolor{incG}{+27.3\%}, AutoFix-- \textcolor{incG}{+13.6\%}, full system-- \textcolor{incG}{+54.5\%}) also follows this trend, across all types of crowdworkers.
\textbf{Analysts \textit{(A)}: } In the case of direct quality feedback, i.e., traffic signals, analysts report an increased performance and find the task easier--\textit{``... it's easier to directly choose based on quality... and it takes care of typos too, the typo samples are marked down so the work goes pretty fast"}($A_3$). When analysts are shown the visualization interfaces, they are explicitly taught to differentiate the traffic signal colors in the visualizations as being indicative of how the sample affects the overall dataset quality, i.e., the colors in different component views represent individual terms of the components calculated over the whole dataset (analysts can toggle between the states of original dataset and new sample addition). We find that users initially find this more difficult to do-- \textit{``It takes a little time to figure out how to go through the views. I learned that in the samples I looked at, components three and seven seemed to be linked. So I'd look at those first the next time I used the system"} ($A_6$) and \textit{``... it takes me some time to figure out how to read the interfaces effectively, but it does make me more secure in judging sample quality at multiple granularities and that would help if I was doing this for a particular application"}($A_1$). Analysts averaged behavior on TextFooler models the conventional approach quite closely, as analysts are seen to have a tendency to either-- \textit{``... deciding to reject or repair is difficult when you don't have the sample or dataset feedback... and what if the repaired sample still isn't good enough?"}($A_4$), or-- \textit{`` I like having this option to repair... I don't need to waste time on analyzing something that isn't outright an accept or reject, I can send it to be repaired and come back to it later"}($A_8$). When shown the full system, analysts also report improvement in all aspects, particularly mental demand and performance--\textit{``I can be sure of not having to redo things since it's likely that I will be able to get a low hypothesis baseline using this system"}($A_2$, $A_1$). The visualization usage also improves-- \textit{``... I went to component three right off the bat this time, I knew that I could look at the linked components..."} ($A_6$). Altogether, sample evaluation by analysts increases, following this trend, and analysts are more assured of their performance.
\textbf{Summary:} Analysts find the task easier (effort-- \textcolor{decR}{-19.3\%}, performance-- \textcolor{incG}{+26.9\%}) with traffic signal feedback, as quality is clearly marked. When analysts are shown the visualization interfaces, they are explicitly taught to differentiate how the traffic signal colors in the visualizations indicate a sample's effect on the overall dataset quality. Analysts can toggle between the states of original dataset and new sample addition. We find that analysts initially find toggling more difficult to do (mental demand-- \textcolor{incG}{+15.4\%}, temporal demand-- \textcolor{incG}{+36.4\%}, frustration-- \textcolor{incG}{3.5\%}), though they agree that it improves their judgement of quality (performance-- \textcolor{incG}{+15.9\%}). Analysts' average behavior on TextFooler models the conventional approach quite closely, as analysts are seen to have a tendency to send all samples that are unclear to TextFooler immediately. With the full system, analysts also report improvement in all aspects (average decrease in difficulty-- \textcolor{decR}{-14.3\%}), particularly mental demand (\textcolor{decR}{-19.2\%}) and performance (\textcolor{incG}{+30.8\%}), considering that the system increases the likelihood of a low hypothesis baseline. The visualization usage also improves, as analysts learn component relationships. Altogether, sample evaluation by analysts increases (full system-- \textcolor{incG}{+83.3\%}), following this trend, and analysts are more assured of their performance (full system score-- \textcolor{incG}{+94.1\%}).
| {'timestamp': '2023-02-10T02:06:29', 'yymm': '2302', 'arxiv_id': '2302.04434', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04434'} | arxiv |
\section{Introduction}
Cracks are common surface defects that occur everywhere. Minor cracks on the surface of an object can be easily mixed up with complex backgrounds. But even tiny cracks can pose immeasurable security risks to space equipment, sophisticated electronics and more. Returning defective goods to the factory also increases post-sale costs. Since the crack data satisfies the characteristics of extreme class imbalance, crack detection application is chosen as experimental validation.
Deep neural networks have yielded remarkable results in various computer vision tasks such as classification and object detection. While these methods can detect whether an image contains cracks or not, in general, image segmentation methods are more elaborate. Numerous works focus on designing better networks with encoder-decoder architectures, e.g., U-Net, SegNet \cite{SegNet}, V-Net \cite{V-net} and UNet++ \cite{Unet++}. Several works have improved the performance of these networks using the attention mechanism, e.g., Attention U-Net \cite{Att-Unet} and Attention U-Net++ \cite{Att-Unet++}. Some other works focus on making the encoder stronger, e.g., E-Net \cite{E-net} adopts early downsampling, which heavily reduces the input size in the first two blocks for real-time purposes. Eff-UNet \cite{Eff-UNet} uses EfficientNet \cite{Efficientnet} as an encoder in combination with a U-Net decoder. EfficientUNet++ \cite{Eff-Unet++} is based on EfficientNet and U-Net++. TransUNet \cite{Transunet} applied vision transformer (ViT) \cite{ViT} as encoder.
Recently, the proposal of decoder-part with residual blocks \cite{OptimizedCrack} has shown new state-of-the-art results on segmentation of road surface cracks and made it possible to accurately segment cracks in industrial field.
In image segmentation, the design of the loss function is as important as the network design. Various loss functions have been proposed to address the class imbalance issue. One approach is to improve the cross-entropy loss, e.g., weighted cross-entropy loss \cite{WCE}, focal loss \cite{Focalloss}, asymmetric focal loss \cite{Overfitting}. Since the use of dice loss in \cite{V-net} for image segmentation, many works have turned to improve it, e.g., Tversky Index \cite{TverskyLoss}, Focal Tversky \cite{Focaltversky}, Log-Cosh dice\cite{Log-Cosh-Dice}. More recent works combine cross-entropy-based loss and dice-based loss as a compound loss, such as combo loss \cite{ComboLoss}, dice focal loss \cite{AnatomyNet}, hybrid focal loss \cite{Focus-Unet} and unified focal loss \cite{Unified-Focal}. Li \cite{Overfitting} suggested that class imbalance in the data leads to overfitting, and the regularization method is another effective way to deal with overfitting and class imbalance, which is different from the focal method. However, none of these recent works apply regularizers to entropy-based component loss.
To overcome aforementioned issue, entropy-based loss is split into regularizer-based entropy loss and focal-based entropy loss. Inspired by Unified Focal \cite{Unified-Focal}, we propose Focal Margin to optimize the entropy-based component loss in these works. Our experiment data demonstrate the proposed loss function can significantly improve the performance on crack segmentation.
\section{Related Work}
\subsection{Networks for Crack Segmentation}
Zou $et\ al\ldotp$\cite{DeepCrack-Zou} proposed a SegNet-based DeepCrack in which the decoders employ unpooling to upsample the features. Another version of DeepCrack architecture proposed by Y.Liu \cite{DeepCrack-Liu} uses a VGG backbone and concatenates all the side output applied by deep supervision \cite{DeepSupervision}. In recent work, a re-designed decoder was proposed that can be added to various backbones such as VGG \cite{VGG}, ResNet \cite{ResNet} and EfficientNet \cite{OptimizedCrack}. Nearest neighbor up-sampling is used to increase the spatial size, which can then be concatenated with the output of the encoder at a particular level before being fed into the decoder block. Each decoder block except level one contains a standard Conv-BN-ReLU sequence followed by two residual blocks \cite{OptimizedCrack}. Two 3x3 Conv-BN-ReLU sequences are applied at level one to still extract features. Evidence in \cite{OptimizedCrack} shows that the application of residual blocks and nearest neighbor up-sampling in the decoder blocks can significantly improve the crack segmentation results.
\subsection{Losses for Class Imbalance}
A commonly used loss function is the BceDice ($L_{bcedice}$), a loss function with a combined binary cross-entropy (Bce) and dice coefficient (Dice) \cite{Sorenson-Dice}. In binary class segmentation, the $L_{bcedice}$ used in \cite{OptimizedCrack} is given as follows:
\begin{equation}
L_{bcedice}(P,T) = -\frac{1}{N} \sum_{c=1}^{}(T_c\cdot \log_{}{P_c} + \frac{2\cdot T_c\cdot P_c + 1}{T_c+P_c + 1} )
\end{equation}
For the class c=1, $P_c$ represents the model prediction while $T_c$ represents the ground truth for that class. The smoothing term 1 in the dice loss is added to ensure that negative samples also contribute to the training.
Li proposed that class imbalance in the data can lead to overfitting of the rare foreground class \cite{Overfitting}. Their work shows that the distribution of the activated logits of rare class shift towards and even across the decision boundary, resulting in a loss of sensitivity \cite{Overfitting}. To this end, asymmetric modifications on losses and training strategies were applied.
Asymmetric focal loss is one of the proposed modifications in \cite{Overfitting} to address the observed overfitting of neural networks under class imbalance. Since the foreground class is rare, the entropy loss contributed by the foreground is already sufficiently small compared to the large background entropy loss. It is helpful to remove the loss attenuation for the foreground class from the focal loss \cite{Focalloss}, which leads to the following asymmetric focal loss:
\begin{equation}
\mathop{L_{aF}}\limits_{c=1}(P,T) = - \frac{1}{N}T_{c}\cdot{\log_{}{P_{c}} } - \frac{1}{N}P_{c}^{\gamma }\cdot (1-T_{c})\cdot{\log_{}{(1-P_{c})} }\label{eq.2}
\end{equation}
Another asymmetric loss analyzed in \cite{Overfitting} was the modification of the large margin loss \cite{LargeMargin}. Considering that unseen foreground class may shift toward the background class, a margin is set for rare foreground class as a regularizer to mitigate the bias of class imbalance, which leads to the following asymmetric large margin loss:
\begin{equation}
\mathop{L_{aM}}\limits_{c=1}(P,T) = - \frac{1}{N}T_{c}\cdot\log_{}{\hat{P_c}} - \frac{1}{N} (1-T_{c})\cdot{\log_{}{(1-P_{c})} }\label{eq.3}
\end{equation}
Salehi further split the denominator of Dice coefficient \cite{TverskyLoss} into $T_c\cdot P_c + (1-P_c)\cdot T_c$ + $P_c\cdot (1-T_c)$, in which $(1-P_c)\cdot T_c$ represents false-negatives (FNs) and $P_c\cdot (1-T_c)$ represents false-positives (FPs). By adding coefficients $\alpha$ and $\beta$ to FNs and FPs, Tversky Index denotes as follows:
\begin{equation}
TI(P,T)=\sum_{c=1}^{}\frac{T_c\cdot P_c + \gamma}{T_c\cdot P_c + \alpha(1-P_c)\cdot T_c+\beta P_c\cdot (1-T_c)+\gamma}
\end{equation}
Especially, when $\alpha$ = $\beta$ = 0.5, the Tversky Index becomes the Dice coefficient. Tverysky Index can be adapted to handle imbalanced data by adjusting $\alpha$ and $\beta$ to selectively focus on FNs or FPs. Although the weights of FNs and FPs can be adjusted in Tversky Index, it is still a linear loss function.
Milletari proposed a novel dice loss \cite{V-net} that simply squared the $P_c$ and $T_c$ in the denominator and turned dice from a linear function to a nonlinear one. Assuming that $P_c$ is highly close to 0, the squared $P_c$ will be even closer to 0. When $P_c$ is close to 1, the squared $P_c$ does not decrease too much. The power operation makes the loss more focused on hard samples:
\begin{equation}
DL(P,T)=1-\frac{1}{N} \sum_{c=1}^{}\frac{2\cdot T_c\cdot P_c + \gamma}{T_c^2+ P_c^2 +\gamma}
\end{equation}
Another nonlinear variant of the Tversky loss is the Focal Tversky \cite{Focaltversky}, where the TI is first performed and then the exponential $\gamma$ is added directly on top of the 1-TI:
\begin{equation}
\mathop{L_{FT}}\limits_{c=1}=\sum_{c}(1-TI_c)^{\gamma}
\end{equation}
Yeung \cite{Unified-Focal} recently summarized the derivation of dice-based and cross-entropy-based losses and proposed a unified focal loss to handle class imbalanced medical segmentation. Prior to unified focal loss, they proposed hybrid focal loss \cite{Focus-Unet}, a combination of focal loss ($L_F$) and focal tversky loss ($L_{FT}$):
\begin{equation}
L_{HF}=\lambda L_F + (1-\lambda)L_{FT}
\end{equation}
They then mimicked the idea of asymmetric modification in \cite{Overfitting} and define the modified asymmetric focal tversky loss as follows:
\begin{equation}
L_{aFT} = \sum_{c\ne r }^{} (1-TI) + \sum_{c=r}(1-TI)^{1-r}
\end{equation}
Finally, the parameters $\alpha$ in the focal loss and $\alpha$ and $\beta$ in the focal tversky loss are unified that using a single $\delta$, since these parameters are all for class weighting. The attenuation parameter $\gamma$ in focal loss and the enhancement parameter $\gamma$ in the focal tversky loss are also unified. The unified focal loss ($L_{sUF}$) and its corresponding asymmetric modifications ($L_{aUF}$) are described as follows:
\begin{equation}
L_{sUF} = \lambda L_{F} + (1-\lambda)L_{FT}
\end{equation}
\begin{equation}
L_{aUF} = \lambda L_{aF} + (1-\lambda)L_{aFT}
\end{equation}
\section{Methodology}
The derivation of dice-based and cross-entropy-based loss deeply depends on the degree of class imbalance. We can infer that further improvements to the derivation can be applied when the ratio is 1:20 or lower. Although asymmetric modifications have been proposed in \cite{Overfitting}, detailed relations between asymmetric loss functions have not yet been presented.
Inspired by the unified focal loss \cite{Unified-Focal}, we propose the asymmetric focal margin loss ($L _{aFM}$) which establishes the connection between the asymmetric focal loss and the asymmetric large margin loss to unify the two loss functions.
\begin{figure}[!htb
\setlength{\belowcaptionskip}{0.1cm}
\centering
\includegraphics[width=0.45\textwidth]{images/focal_margin.jpg}
\caption{Our proposed focal margin loss unifies the regularizer-based entropy loss and the focal-based entropy loss. The arrows and associated parameters indicate the transitions between the formulas. The pink part in the middle represents the main contribution. The focal margin loss produces the focal loss when margin value ($m$) is zero, and produces the large margin loss when the $\gamma$ is zero. The focal margin loss yields the standard cross-entropy loss when both $m$ and $\gamma$ are set to zero.}
\label{Fig.1}
\end{figure}
\begin{table*}[htbp]
\renewcommand{\arraystretch}{1.3}
\caption{Experimental results for the DeepCrack Dataset with 237 test images, our proposal performs best in IoU compared to previous losses.}
\label{tab1}
\centering
\begin{tabular}{cccccc}
\hline
& & DeepCrack-DB && \\
\hline
Loss functions &Parameters &IoU &F1 & Recall & Precision \\
\hline
$ L_{bce}$& - & 60.67&75.43&66.98&\textbf{87.01}\\
$ L_{dice}$& - & 67.49&80.49&77.44&84.38\\
$ L_{FL}$& $\hat{\gamma}=2.0$ & 56.38&71.99&63.14&84.74\\
$ L_{aFL}$& $\hat{\gamma}=2.0$ & 61.94&76.41&73.41&80.38\\
$ L_{Tversky}$& $\delta=0.7$ & 68.27&81.05&82.46&80.16\\
$ L_{FT}$& $\delta=0.7, \gamma=0.75$ &68.47&81.19&83.71&79.26\\
$ {L_{bcedice}}^{\mathrm{a}}$& - &68.33 & 81.10 &80.17 &82.59 \\
$ {L_{HF}}^{\mathrm{b}}$& $\hat{\gamma}=2.0,\delta=0.7,\gamma=0.75$ & 69.32&81.80&82.82&81.30\\
$ {L_{aUF}}^{\mathrm{c}}$& $\delta=0.6,\gamma=0.5$ & 68.91&81.51&80.55&82.94\\
\hline
$ L_{ours}{\mathrm{d}}$& $\hat{\gamma}=2.0,\delta=0.7,\gamma=0.75,m=0.5$ & \textbf{69.75{\color{green}(+0.43)}}&\textbf{82.09{\color{green}(+0.29)}}&83.57{\color{green}(+0.75)}&81.09\\
$ L_{ours}$& $\hat{\gamma}=2.0,\delta=0.7,\gamma=0.75,m=1.0$ & 69.62{\color{green}(+0.30)} &82.00{\color{green}(+0.20)} &\textbf{83.71}{\color{green}(+0.89)} &80.77\\
$ L_{ours}$& $\hat{\gamma}=2.0,\delta=0.7,\gamma=0.75,m=1.5$ & 69.38{\color{green}(+0.06)} & 81.83{\color{green}(+0.03)} & 82.98{\color{green}(+0.16)} &81.19\\
\hline
\end{tabular}
\vspace{0.3cm}
\end{table*}
\begin{table*}[htbp]
\renewcommand{\arraystretch}{1.3}
\caption{Experimental results for the CRACK500 Dataset with 494 test images, our proposal performs the same as previous $L_{bcedice}$.}
\label{tab2}
\centering
\begin{tabular}{cccccc}
\hline
& & CRACK500 && & \\
\hline
Loss functions &Parameters &IoU &F1 & Recall & Precision \\
\hline
$ L_{bce}$& - & 54.10&70.17&64.99&\textbf{76.42}\\
$ L_{dice}$& - & 59.34&74.44&75.24&73.78\\
$ L_{FL}$& $\hat{\gamma}=2.0$ & 46.95&63.84&55.33&75.74\\
$ L_{aFL}$& $\hat{\gamma}=2.0$ & 52.89&69.15&68.36&70.16\\
$ L_{Tversky}$& $\delta=0.7$ & 57.47&72.95&82.45&65.55\\
$ L_{FT}$& $\delta=0.7, \gamma=0.75$ &57.33&72.84&\textbf{82.67}&65.21\\
$ {L_{bcedice}}^{\mathrm{a}}$& - & 60.65&75.47&76.37&74.73\\
$ {L_{HF}}^{\mathrm{b}}$& $\hat{\gamma}=2.0,\delta=0.7,\gamma=0.75$ & 59.10&74.25&81.90&68.01\\
$ {L_{aUF}}^{\mathrm{c}}$& $\delta=0.6,\gamma=0.5$ & 59.35&74.45&79.42&70.18\\
\hline
$ L_{ours}{\mathrm{d}}$& $\hat{\gamma}=0.0,\delta=0.5,\gamma=1.0,m=0.5$ & \textbf{60.66}{\color{green}(+0.01)} &\textbf{75.48}{\color{green}(+0.01)} &77.40{\color{green}(+1.03)} &73.79\\
$ L_{ours}$& $\hat{\gamma}=0.0,\delta=0.5,\gamma=1.0,m=1.0$ & 60.54&75.38&77.66 &73.38\\
$ L_{ours}$& $\hat{\gamma}=0.0,\delta=0.5,\gamma=1.0,m=1.5$ & 60.60& 75.43 & 77.86 &73.28\\
\hline
\end{tabular}
\vspace{0.3cm}
\end{table*}
\begin{table*}[htbp]
\renewcommand{\arraystretch}{1.3}
\caption{Experimental results for the PanelCrack Dataset with 513 test images, our proposal performs best in IoU compared to previous losses.}
\label{tab3}
\centering
\begin{tabular}{cccccc}
\hline
& & PanelCrack && & \\
\hline
Loss functions &Parameters &IoU &F1 & Recall & Precision \\
\hline
$ L_{bce}$& - & -&-&-&-\\
$ L_{dice}$& - & 23.22&37.55&57.26&28.43\\
$ L_{FL}$& $\hat{\gamma}=2.0$ & 4.88&9.17&5.06&32.12\\
$ L_{aFL}$& $\hat{\gamma}=2.0$ & 11.83&20.93&13.46&41.54\\
$ L_{Tversky}$& $\delta=0.7$ & 33.51&50.00&59.10&43.63\\
$ L_{FT}$& $\delta=0.7, \gamma=0.75$ &33.10&49.56&59.24&42.87\\
$ {L_{bcedice}}^{\mathrm{a}}$& - & 32.09&48.45&49.58&\textbf{47.60}\\
$ {L_{HF}}^{\mathrm{b}}$& $\hat{\gamma}=2.0,\delta=0.7,\gamma=0.75$ & 34.64&51.24&56.60&47.14\\
$ {L_{aUF}}^{\mathrm{c}}$& $\delta=0.6,\gamma=0.5$ & 32.72&49.08&51.19&47.53\\
\hline
$ L_{ours}{\mathrm{d}}$& $\hat{\gamma}=2.0,\delta=0.7,\gamma=0.75,m=0.5$ & 34.94{\color{green}(+0.3)} &51.55{\color{green}(+0.31)} &56.87\color{green}(+0.27) &47.49\\
$ L_{ours}$& $\hat{\gamma}=2.0,\delta=0.7,\gamma=0.75,m=1.0$ & 34.85{\color{green}(+0.21)}&51.49{\color{green}(+0.25)} &57.57\color{green}(+0.97) &46.95\\
$ L_{ours}$& $\hat{\gamma}=2.0,\delta=0.7,\gamma=0.75,m=1.5$ & \textbf{35.08}{\color{green}(+0.44)} & \textbf{51.74}{\color{green}(+0.50)} & \textbf{57.61}{\color{green}(+1.01)} &47.32\\
\hline
\multicolumn{4}{l}{$^{\mathrm{a}}$The performance of vanilla loss used in \cite{OptimizedCrack} for crack segmentation.}\\
\multicolumn{4}{l}{$^{\mathrm{b}}$A combination of asymmetric focal loss and focal tversky loss.}\\
\multicolumn{4}{l}{$^{\mathrm{c}}$Asymmetric Unified Focal Loss with default parameters.}\\
\multicolumn{4}{l}{$^{\mathrm{d}}$Focal Margin component in our loss produces asymmetric focal loss when $m=0$.}
\end{tabular}
\vspace{0.3cm}
\end{table*}
Observing the foreground and background terms of \eqref{eq.2} and \eqref{eq.3} respectively, the regularized foreground term of $L_{aM}$ can be combined with the weight attenuation background term of $L _{aF}$, leading to the following asymmetric focal margin loss:
\begin{equation}
\mathop{L _{aFM}}\limits_{c=1}(P,T) = - \frac{1}{N}T_{c}\cdot\log_{}{\hat{P_c}} - \frac{1}{N}P_{c}^{\hat{\gamma}}\cdot (1-T_{c})\cdot{\log_{}{(1-P_{c})} }\label{eq.11}
\end{equation}
Here, N represents a number of samples, Pc and Tc represent prediction and ground truth of class c, respectively. $\hat{P_c}$ is the regularized prediction. The removed loss attenuation for foreground class pushes it away from the decision boundary, and the added margin regularizer further moves the decision boundary closer to the background, which makes it suitable to handle extremely imbalanced data such as crack data and preventing overfitting.
$ L _{aFM}$ degenerates to $L_{aM}$ for $\hat{\gamma}=0$. With $m=0$, \eqref{eq.11} yields $L_{aF}$. Moreover, setting both $\hat{\gamma}$ and $m$ to 0, $L _{aFM}$ becomes the standard binary cross-entropy loss. The symmetric focal margin loss is given as follows:
\begin{equation}
\mathop{L _{FM}}(P,T) = - \frac{1}{N}(1-P_{c})^{\hat{\gamma}}\cdot T_{c}\cdot \log_{}{\hat{P_c}}
\end{equation}
Therefore, the hybrid focal loss in \cite{Focus-Unet} is optimized by replacing the focal loss with our proposed focal margin loss. The final optimized hybrid focal margin loss is given as follows:
\begin{equation}
L_{sHFM} = \lambda L_{FM} + (1-\lambda)L_{FT}
\end{equation}In the binary class segmentation, the non-rare term in $L_{aFT}$ can be discarded which simplifies to $L_{FT}$. In addition, the $\delta$ of focal loss component in \cite{Unified-Focal} is removed in our case since the contribution of rare foreground loss is small enough, thus the weight of rare foreground does not need to be attenuated while the background weight can still be reduced by the suppression parameter $\hat{\gamma}$. Moreover, Yeung indicates that $\lambda$ is partially redundant \cite{Unified-Focal} should be simplified as well. To this end, we simplify our optimized loss ($L_{ours}$) for experimental purposes as follows, and assume that the results showing an increase or decrease in performance also carry over to other derivations of dice and entropy-based losses:
\begin{equation}
L_{ours} = L_{aFM} + L_{FT}
\end{equation}
A version of hybrid focal loss used in our experiments for comparison purpose is defined as follows:
\begin{equation}
{L}_{HF} = L_{aF} + L_{FT}
\end{equation}
\section{Experiments}
\paragraph{Datasets} We use the open-sourced DeepCrack Dataset (DeepCrack-DB) \cite{DeepCrack-Liu}. It contains 537 images (300 for training, and 237 for testing) with sizes of 554*384 pixels. In order to reduce the deformation effect caused by scaling and speed up the experiments, we simply cropped each image to 384*384, and adjusted the training and test images to 96*96 pixels. Cracks account for 5.05\% of the resampled DeepCrack dataset.
Another dataset for road cracks, CRACK500 \cite{RoadCrack, Featurepyramid}, was used in our experiments. Due to the average image size being 1509*2512 pixels, we first picked 250 images from CRACK500, then cropped images to 512*512, and finally resized the crack images to 128*128 pixels. All images containing no cracks were removed. The experimental CRACK500 dataset (7.3\% is crack) contains 1481 training images (75\%) and 494 testing images (25\%).
Our PanelCrack dataset consists of industrial panel cracks is also added, which contains 3.15\% crack images. We created panel cracks partly by hand tapping and partly by collecting real panel crack data from the factory and scanning it with a camera. A total number of 2051 images were resampled into 128*128 pixels, with 1538 images (75\%) for training and 513 images (25\%) for testing.
\paragraph{Augmentations} A standard augmentation policy shows in Fig.~\ref{Fig.2} was applied to all experiments, alleviating the over-fitting in the beginning.
\begin{figure}[htbp
\setlength{\belowcaptionskip}{0.1cm}
\centering
\includegraphics[width=0.45\textwidth]{images/algorithm.png}
\caption{Detailed augmentation policy for our training experiments. p repressents the probability with which each augmentation step is applied.}
\label{Fig.2}
\end{figure}
\paragraph{Loss Function}
To investigate the effect of different margins, we use the default $\delta=0.7$ suggested by \cite{Focaltversky} and the default $\hat{\gamma}=2.0$ suggested by \cite{Overfitting} for the asymmetric focal loss component. In our opinion, a $\hat{\gamma}$ value larger than 1.0 can suppress the background efficiently due to the activation of logits are between (0,1). The exponent $\gamma$ for $L_{FT}$ is 0.75 as suggested by \cite{Focaltversky}, which enhances the rare class. Table~\ref{tab1},~\ref{tab2} and ~\ref{tab3} show the performance of $ L_{ours}$ with different margin values on DeepCrack-DB, CRACK500 and our datasets, respectively. Moreover, the baseline loss ($L_{bcedice}$) and other previous loss functions, e.g., $L_{FL}$, $L_{aFL}$, $L_{Tversky}$, $L_{FT}$, $L_{HF}$ and $L_{aUF}$ are also presented for a comparison purpose.
\paragraph{Analysis}
We have tried different margin values from 0 to 2 for each dataset and found that 0.5, 1.0 and 1.5 obtained outstanding IoU on the three experimental datasets, respectively. Hence, 0.5, 1.0 and 1.5 are used as a set of hyperparameters in formal experiments. All losses are evaluated by using the recent Crack Segmentation Architecture \cite{OptimizedCrack} with Unet basis. Each model is trained 10 times (each time for 100 epochs) and all these results are averaged to a mean value. As shown in Table~\ref{tab1} for margin values larger than 0, further improvements of segmentation results are achieved. Specifically, when $m=0.5$, the recall of DeepCrack-DB increases 0.75, which also leads to the increase of IoU and F1. However, $L_{aUF}$ with the default parameters suggested by \cite{Unified-Focal} performs worse than the experimental $L_{HF}$.
For CRACK500 dataset, $L_{bcedice}$ performs best due to crack accounted for a relatively high proportion in CRACK500 compared to other datasets in our experiments. Other parameters are therefore simplified except $m$ to $L_{bcedice}$. Note that with $m=0$, hybrid focal margin loss produces hybrid focal loss. In the experiments, $m$ does not significantly improve the segmentation and the results are almost equivalent with or without $m$.
\begin{figure}[!htb
\setlength{\belowcaptionskip}{0.1cm}
\centering
\includegraphics[width=0.5\textwidth]{images/margin_propotion.png}
\caption{The choice of margin value depends on the degree of class imbalance. A higher margin value than 1.5 is recommended when the proportion of foreground is less than 3\%. A lower margin value than 0.5 is also recommended when the proportion of foreground is larger than 7\%.}
\label{Fig.3}
\end{figure}
Table~\ref{tab3} shows the model performance on our dataset. $L_{bce}$ does not work due to extreme class imbalance. With $m=1.5$, our proposal improves Recall by 1.01, F1 by 0.5 and IoU by 0.44, respectively. According to our experiments, margin value in the range of 0.5 to 1.5 is recommended for class imbalance segmentation. Moreover, a large margin value is recommended when the class imbalance is more severe and the training data is less. In general, the dice-based loss performs better than the entropy-based loss, especially when the data is extremely imbalanced. That leads to the less contribution of entropy component to the whole compound loss. The previous focal-based entropy loss alleviates this problem to some extent, while our proposal further improves the entropy component of the compound loss and thus boosts the overall segmentation performance. Fig.~\ref{Fig.4} illustrates the outperformance of our proposal compared to previous losses.
In addition, the original pretrained EfficientUnet-B7 and TransUnet-R50-ViT-B\_16 have also been tested on DeepCrack-DB using our loss function and previous compound losses for comparison. Table~\ref{tab4} shows that our proposal is also suitable for other networks such as EfficientUNet and TransUNet.
\begin{table}[!htb]
\renewcommand{\arraystretch}{1.3}
\caption{Our proposal still improves the IoU on the DeepCrack-DB that uses the recent EfficientUnet and TransUnet architectures. Each result on this table is the mean value of 10 times attempts.}
\label{tab4}
\centering
\resizebox{8.5cm}{1.0cm}{
\begin{tabular}{|l|l|l|l|l|}
\hline
Models & $L_{bcedice}$ & $L_{HF}$ & $L_{aUF}$ & $L_{ours}$ \\ \hline
CrackSeg \cite{OptimizedCrack} & 68.33 & 69.32 & 68.91 & \textbf{69.75} \\ \hline
EfficientUNet-B7 \cite{Eff-UNet} & 67.28 & 67.43 & 67.39 &\textbf{67.73} \\ \hline
TransUNet-R50-ViT-B\_16 \cite{Transunet} &64.21& 68.02&64.24& \textbf{68.84} \\ \hline
\end{tabular}}
\end{table}
\begin{figure*}[htbp
\centering
\includegraphics[width=0.8\textwidth]{images/Qualitative_comparision_between_losses.png}
\caption{Comparison of AsyFocal, FocalTversky, BceDice, HybridFocal, UnifiedFocal and Our proposal, The results of Hybrid Focal Margin loss are closest to ground truth in most cases.}
\label{Fig.4}
\end{figure*}
\section{Conclusion}
In this work, we investigate previous loss functions for class-imbalanced data. We reveal that entropy-based loss can be further split into regularizer-based entropy loss and focal-based entropy loss and propose an optimized hybrid focal margin loss to optimize the previous losses. In a complex background, the Focal Margin component can not only address class imbalance, but also prevent overfitting. Our experiments demonstrate that margin values in the range of 0.5 to 1.5 are recommended for image segmentation with different degrees of class imbalance. Our proposed method outperforms the baseline BceDice and the HybridFocal in IoU scores and presents balanced precision-recall scores. We believe that the Focal Margin component and its modifications and combination with other losses can handle various segmentation tasks flexibly.
| {'timestamp': '2023-02-10T02:04:07', 'yymm': '2302', 'arxiv_id': '2302.04395', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04395'} | arxiv |
\section{Introduction}
ACM's consolidated article template, introduced in 2017, provides a
consistent \LaTeX\ style for use across ACM publications, and
incorporates accessibility and metadata-extraction functionality
necessary for future Digital Library endeavors. Numerous ACM and
SIG-specific \LaTeX\ templates have been examined, and their unique
features incorporated into this single new template.
If you are new to publishing with ACM, this document is a valuable
guide to the process of preparing your work for publication. If you
have published with ACM before, this document provides insight and
instruction into more recent changes to the article template.
The ``\verb|acmart|'' document class can be used to prepare articles
for any ACM publication --- conference or journal, and for any stage
of publication, from review to final ``camera-ready'' copy, to the
author's own version, with {\itshape very} few changes to the source.
\section{Template Overview}
As noted in the introduction, the ``\verb|acmart|'' document class can
be used to prepare many different kinds of documentation --- a
double-blind initial submission of a full-length technical paper, a
two-page SIGGRAPH Emerging Technologies abstract, a ``camera-ready''
journal article, a SIGCHI Extended Abstract, and more --- all by
selecting the appropriate {\itshape template style} and {\itshape
template parameters}.
This document will explain the major features of the document
class. For further information, the {\itshape \LaTeX\ User's Guide} is
available from
\url{https://www.acm.org/publications/proceedings-template}.
\subsection{Template Styles}
The primary parameter given to the ``\verb|acmart|'' document class is
the {\itshape template style} which corresponds to the kind of publication
or SIG publishing the work. This parameter is enclosed in square
brackets and is a part of the {\verb|documentclass|} command:
\begin{verbatim}
\documentclass[STYLE]{acmart}
\end{verbatim}
Journals use one of three template styles. All but three ACM journals
use the {\verb|acmsmall|} template style:
\begin{itemize}
\item {\texttt{acmsmall}}: The default journal template style.
\item {\texttt{acmlarge}}: Used by JOCCH and TAP.
\item {\texttt{acmtog}}: Used by TOG.
\end{itemize}
The majority of conference proceedings documentation will use the {\verb|acmconf|} template style.
\begin{itemize}
\item {\texttt{acmconf}}: The default proceedings template style.
\item{\texttt{sigchi}}: Used for SIGCHI conference articles.
\item{\texttt{sigchi-a}}: Used for SIGCHI ``Extended Abstract'' articles.
\item{\texttt{sigplan}}: Used for SIGPLAN conference articles.
\end{itemize}
\subsection{Template Parameters}
In addition to specifying the {\itshape template style} to be used in
formatting your work, there are a number of {\itshape template parameters}
which modify some part of the applied template style. A complete list
of these parameters can be found in the {\itshape \LaTeX\ User's Guide.}
Frequently-used parameters, or combinations of parameters, include:
\begin{itemize}
\item {\texttt{anonymous,review}}: Suitable for a ``double-blind''
conference submission. Anonymizes the work and includes line
numbers. Use with the \texttt{\acmSubmissionID} command to print the
submission's unique ID on each page of the work.
\item{\texttt{authorversion}}: Produces a version of the work suitable
for posting by the author.
\item{\texttt{screen}}: Produces colored hyperlinks.
\end{itemize}
This document uses the following string as the first command in the
source file:
\begin{verbatim}
\end{verbatim}
\section{Modifications}
Modifying the template --- including but not limited to: adjusting
margins, typeface sizes, line spacing, paragraph and list definitions,
and the use of the \verb|\vspace| command to manually adjust the
vertical spacing between elements of your work --- is not allowed.
{\bfseries Your document will be returned to you for revision if
modifications are discovered.}
\section{Typefaces}
The ``\verb|acmart|'' document class requires the use of the
``Libertine'' typeface family. Your \TeX\ installation should include
this set of packages. Please do not substitute other typefaces. The
``\verb|lmodern|'' and ``\verb|ltimes|'' packages should not be used,
as they will override the built-in typeface families.
\section{Title Information}
The title of your work should use capital letters appropriately -
\url{https://capitalizemytitle.com/} has useful rules for
capitalization. Use the {\verb|title|} command to define the title of
your work. If your work has a subtitle, define it with the
{\verb|subtitle|} command. Do not insert line breaks in your title.
If your title is lengthy, you must define a short version to be used
in the page headers, to prevent overlapping text. The \verb|title|
command has a ``short title'' parameter:
\begin{verbatim}
\title[short title]{full title}
\end{verbatim}
\section{Authors and Affiliations}
Each author must be defined separately for accurate metadata
identification. As an exception, multiple authors may share one
affiliation. Authors' names should not be abbreviated; use full first
names wherever possible. Include authors' e-mail addresses whenever
possible.
Grouping authors' names or e-mail addresses, or providing an ``e-mail
alias,'' as shown below, is not acceptable:
\begin{verbatim}
\author{Brooke Aster, David Mehldau}
\email{dave,judy,[email protected]}
\email{[email protected]}
\end{verbatim}
The \verb|authornote| and \verb|authornotemark| commands allow a note
to apply to multiple authors --- for example, if the first two authors
of an article contributed equally to the work.
If your author list is lengthy, you must define a shortened version of
the list of authors to be used in the page headers, to prevent
overlapping text. The following command should be placed just after
the last \verb|\author{}| definition:
\begin{verbatim}
\renewcommand{\shortauthors}{McCartney, et al.}
\end{verbatim}
Omitting this command will force the use of a concatenated list of all
of the authors' names, which may result in overlapping text in the
page headers.
The article template's documentation, available at
\url{https://www.acm.org/publications/proceedings-template}, has a
complete explanation of these commands and tips for their effective
use.
Note that authors' addresses are mandatory for journal articles.
\section{Rights Information}
Authors of any work published by ACM will need to complete a rights
form. Depending on the kind of work, and the rights management choice
made by the author, this may be copyright transfer, permission,
license, or an OA (open access) agreement.
Regardless of the rights management choice, the author will receive a
copy of the completed rights form once it has been submitted. This
form contains \LaTeX\ commands that must be copied into the source
document. When the document source is compiled, these commands and
their parameters add formatted text to several areas of the final
document:
\begin{itemize}
\item the ``ACM Reference Format'' text on the first page.
\item the ``rights management'' text on the first page.
\item the conference information in the page header(s).
\end{itemize}
Rights information is unique to the work; if you are preparing several
works for an event, make sure to use the correct set of commands with
each of the works.
The ACM Reference Format text is required for all articles over one
page in length, and is optional for one-page articles (abstracts).
\section{CCS Concepts and User-Defined Keywords}
Two elements of the ``acmart'' document class provide powerful
taxonomic tools for you to help readers find your work in an online
search.
The ACM Computing Classification System ---
\url{https://www.acm.org/publications/class-2012} --- is a set of
classifiers and concepts that describe the computing
discipline. Authors can select entries from this classification
system, via \url{https://dl.acm.org/ccs/ccs.cfm}, and generate the
commands to be included in the \LaTeX\ source.
User-defined keywords are a comma-separated list of words and phrases
of the authors' choosing, providing a more flexible way of describing
the research being presented.
CCS concepts and user-defined keywords are required for for all
articles over two pages in length, and are optional for one- and
two-page articles (or abstracts).
\section{Sectioning Commands}
Your work should use standard \LaTeX\ sectioning commands:
\verb|section|, \verb|subsection|, \verb|subsubsection|, and
\verb|paragraph|. They should be numbered; do not remove the numbering
from the commands.
Simulating a sectioning command by setting the first word or words of
a paragraph in boldface or italicized text is {\bfseries not allowed.}
\section{Tables}
The ``\verb|acmart|'' document class includes the ``\verb|booktabs|''
package --- \url{https://ctan.org/pkg/booktabs} --- for preparing
high-quality tables.
Table captions are placed {\itshape above} the table.
Because tables cannot be split across pages, the best placement for
them is typically the top of the page nearest their initial cite. To
ensure this proper ``floating'' placement of tables, use the
environment \textbf{table} to enclose the table's contents and the
table caption. The contents of the table itself must go in the
\textbf{tabular} environment, to be aligned properly in rows and
columns, with the desired horizontal and vertical rules. Again,
detailed instructions on \textbf{tabular} material are found in the
\textit{\LaTeX\ User's Guide}.
Immediately following this sentence is the point at which
Table~\ref{tab:freq} is included in the input file; compare the
placement of the table here with the table in the printed output of
this document.
\begin{table}
\caption{Frequency of Special Characters}
\label{tab:freq}
\begin{tabular}{ccl}
\toprule
Non-English or Math&Frequency&Comments\\
\midrule
\O & 1 in 1,000& For Swedish names\\
$\pi$ & 1 in 5& Common in math\\
\$ & 4 in 5 & Used in business\\
$\Psi^2_1$ & 1 in 40,000& Unexplained usage\\
\bottomrule
\end{tabular}
\end{table}
To set a wider table, which takes up the whole width of the page's
live area, use the environment \textbf{table*} to enclose the table's
contents and the table caption. As with a single-column table, this
wide table will ``float'' to a location deemed more
desirable. Immediately following this sentence is the point at which
Table~\ref{tab:commands} is included in the input file; again, it is
instructive to compare the placement of the table here with the table
in the printed output of this document.
\begin{table*}
\caption{Some Typical Commands}
\label{tab:commands}
\begin{tabular}{ccl}
\toprule
Command &A Number & Comments\\
\midrule
\texttt{{\char'134}author} & 100& Author \\
\texttt{{\char'134}table}& 300 & For tables\\
\texttt{{\char'134}table*}& 400& For wider tables\\
\bottomrule
\end{tabular}
\end{table*}
Always use midrule to separate table header rows from data rows, and
use it only for this purpose. This enables assistive technologies to
recognise table headers and support their users in navigating tables
more easily.
\section{Math Equations}
You may want to display math equations in three distinct styles:
inline, numbered or non-numbered display. Each of the three are
discussed in the next sections.
\subsection{Inline (In-text) Equations}
A formula that appears in the running text is called an inline or
in-text formula. It is produced by the \textbf{math} environment,
which can be invoked with the usual
\texttt{{\char'134}begin\,\ldots{\char'134}end} construction or with
the short form \texttt{\$\,\ldots\$}. You can use any of the symbols
and structures, from $\alpha$ to $\omega$, available in
\LaTeX~\cite{Lamport:LaTeX}; this section will simply show a few
examples of in-text equations in context. Notice how this equation:
\begin{math}
\lim_{n\rightarrow \infty}x=0
\end{math},
set here in in-line math style, looks slightly different when
set in display style. (See next section).
\subsection{Display Equations}
A numbered display equation---one set off by vertical space from the
text and centered horizontally---is produced by the \textbf{equation}
environment. An unnumbered display equation is produced by the
\textbf{displaymath} environment.
Again, in either environment, you can use any of the symbols and
structures available in \LaTeX\@; this section will just give a couple
of examples of display equations in context. First, consider the
equation, shown as an inline equation above:
\begin{equation}
\lim_{n\rightarrow \infty}x=0
\end{equation}
Notice how it is formatted somewhat differently in
the \textbf{displaymath}
environment. Now, we'll enter an unnumbered equation:
\begin{displaymath}
\sum_{i=0}^{\infty} x + 1
\end{displaymath}
and follow it with another numbered equation:
\begin{equation}
\sum_{i=0}^{\infty}x_i=\int_{0}^{\pi+2} f
\end{equation}
just to demonstrate \LaTeX's able handling of numbering.
\section{Figures}
The ``\verb|figure|'' environment should be used for figures. One or
more images can be placed within a figure. If your figure contains
third-party material, you must clearly identify it as such, as shown
in the example below.
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{sample-franklin}
\caption{1907 Franklin Model D roadster. Photograph by Harris \&
Ewing, Inc. [Public domain], via Wikimedia
Commons. (\url{https://goo.gl/VLCRBB}).}
\Description{A woman and a girl in white dresses sit in an open car.}
\end{figure}
Your figures should contain a caption which describes the figure to
the reader.
Figure captions are placed {\itshape below} the figure.
Every figure should also have a figure description unless it is purely
decorative. These descriptions convey what’s in the image to someone
who cannot see it. They are also used by search engine crawlers for
indexing images, and when images cannot be loaded.
A figure description must be unformatted plain text less than 2000
characters long (including spaces). {\bfseries Figure descriptions
should not repeat the figure caption – their purpose is to capture
important information that is not already provided in the caption or
the main text of the paper.} For figures that convey important and
complex new information, a short text description may not be
adequate. More complex alternative descriptions can be placed in an
appendix and referenced in a short figure description. For example,
provide a data table capturing the information in a bar chart, or a
structured list representing a graph. For additional information
regarding how best to write figure descriptions and why doing this is
so important, please see
\url{https://www.acm.org/publications/taps/describing-figures/}.
\subsection{The ``Teaser Figure''}
A ``teaser figure'' is an image, or set of images in one figure, that
are placed after all author and affiliation information, and before
the body of the article, spanning the page. If you wish to have such a
figure in your article, place the command immediately before the
\verb|\maketitle| command:
\begin{verbatim}
\begin{teaserfigure}
\includegraphics[width=\textwidth]{sampleteaser}
\caption{figure caption}
\Description{figure description}
\end{teaserfigure}
\end{verbatim}
\section{Citations and Bibliographies}
The use of \BibTeX\ for the preparation and formatting of one's
references is strongly recommended. Authors' names should be complete
--- use full first names (``Donald E. Knuth'') not initials
(``D. E. Knuth'') --- and the salient identifying features of a
reference should be included: title, year, volume, number, pages,
article DOI, etc.
Using the BibLaTeX system, the bibliography is included in your source
document with the following command, placed just before the \verb|\end{document}| command:
\begin{verbatim}
\printbibliography
\end{verbatim}
The command \verb|\addbibresource{bibfile}| declares the \BibTeX\ file to use
in the {\bfseries preamble} (before the command
``\verb|\begin{document}|'') of your \LaTeX\ source
where ``\verb|bibfile|'' is the name, \emph{with} the ``\verb|.bib|'' suffix.
Notice that \verb|\addbibresource| takes only one argument: to declare multiple files,
use multiple instances of the command.
Citations and references are numbered by default. A small number of
ACM publications have citations and references formatted in the
``author year'' style; for these exceptions, please pass the option \verb|style=acmauthoryear|
to the \verb|biblatex| package loaded in the {\bfseries preamble} (before the command
``\verb|\begin{document}|'') of your \LaTeX\ source.
Some examples. A paginated journal article \cite{Abril07}, an
enumerated journal article \cite{Cohen07}, a reference to an entire
issue \cite{JCohen96}, a monograph (whole book) \cite{Kosiur01}, a
monograph/whole book in a series (see 2a in spec. document)
\cite{Harel79}, a divisible-book such as an anthology or compilation
\cite{Editor00} followed by the same example, however we only output
the series if the volume number is given \cite{Editor00a} (so
Editor00a's series should NOT be present since it has no vol. no.),
a chapter in a divisible book \cite{Spector90}, a chapter in a
divisible book in a series \cite{Douglass98}, a multi-volume work as
book \cite{Knuth97}, a couple of articles in a proceedings (of a
conference, symposium, workshop for example) (paginated proceedings
article) \cite{Andler79, Hagerup1993}, a proceedings article with
all possible elements \cite{Smith10}, an example of an enumerated
proceedings article \cite{VanGundy07}, an informally published work
\cite{Harel78}, a couple of preprints \cite{Bornmann2019,
AnzarootPBM14}, a doctoral dissertation \cite{Clarkson85}, a
master's thesis: \cite{anisi03}, an online document / world wide web
resource \cite{Thornburg01, Ablamowicz07, Poker06}, a video game
(Case 1) \cite{Obama08} and (Case 2) \cite{Novak03} and \cite{Lee05}
and (Case 3) a patent \cite{JoeScientist001}, work accepted for
publication \cite{rous08}, 'YYYYb'-test for prolific author
\cite{SaeediMEJ10} and \cite{SaeediJETC10}. Other cites might
contain 'duplicate' DOI and URLs (some SIAM articles)
\cite{Kirschmer:2010:AEI:1958016.1958018}. Boris / Barbara Beeton:
multi-volume works as books \cite{MR781536} and \cite{MR781537}. A
couple of citations with DOIs:
\cite{2004:ITE:1009386.1010128,Kirschmer:2010:AEI:1958016.1958018}. Online
citations: \cite{TUGInstmem, Thornburg01, CTANacmart}.
Data Artifacts: \cite{UMassCitations}.
Software project: ~\cite{cgal,delebecque:hal-02090402}. Software Version: ~\cite{gf-tag-sound-repo,}. Software Module: ~\cite{cgal:lp-gi-20a}. Code fragment: ~\cite{simplemapper}.
\section{Acknowledgments}
Identification of funding sources and other support, and thanks to
individuals and groups that assisted in the research and the
preparation of the work should be included in an acknowledgment
section, which is placed just before the reference section in your
document.
This section has a special environment:
\begin{verbatim}
\begin{acks}
...
\end{acks}
\end{verbatim}
so that the information contained therein can be more easily collected
during the article metadata extraction phase, and to ensure
consistency in the spelling of the section heading.
Authors should not prepare this section as a numbered or unnumbered {\verb|\section|}; please use the ``{\verb|acks|}'' environment.
\section{Appendices}
If your work needs an appendix, add it before the
``\verb|\end{document}|'' command at the conclusion of your source
document.
Start the appendix with the ``\verb|appendix|'' command:
\begin{verbatim}
\section{Introduction}
ACM's consolidated article template, introduced in 2017, provides a
consistent \LaTeX\ style for use across ACM publications, and
incorporates accessibility and metadata-extraction functionality
necessary for future Digital Library endeavors. Numerous ACM and
SIG-specific \LaTeX\ templates have been examined, and their unique
features incorporated into this single new template.
If you are new to publishing with ACM, this document is a valuable
guide to the process of preparing your work for publication. If you
have published with ACM before, this document provides insight and
instruction into more recent changes to the article template.
The ``\verb|acmart|'' document class can be used to prepare articles
for any ACM publication --- conference or journal, and for any stage
of publication, from review to final ``camera-ready'' copy, to the
author's own version, with {\itshape very} few changes to the source.
\section{Template Overview}
As noted in the introduction, the ``\verb|acmart|'' document class can
be used to prepare many different kinds of documentation --- a
double-blind initial submission of a full-length technical paper, a
two-page SIGGRAPH Emerging Technologies abstract, a ``camera-ready''
journal article, a SIGCHI Extended Abstract, and more --- all by
selecting the appropriate {\itshape template style} and {\itshape
template parameters}.
This document will explain the major features of the document
class. For further information, the {\itshape \LaTeX\ User's Guide} is
available from
\url{https://www.acm.org/publications/proceedings-template}.
\subsection{Template Styles}
The primary parameter given to the ``\verb|acmart|'' document class is
the {\itshape template style} which corresponds to the kind of publication
or SIG publishing the work. This parameter is enclosed in square
brackets and is a part of the {\verb|documentclass|} command:
\begin{verbatim}
\documentclass[STYLE]{acmart}
\end{verbatim}
Journals use one of three template styles. All but three ACM journals
use the {\verb|acmsmall|} template style:
\begin{itemize}
\item {\verb|acmsmall|}: The default journal template style.
\item {\verb|acmlarge|}: Used by JOCCH and TAP.
\item {\verb|acmtog|}: Used by TOG.
\end{itemize}
The majority of conference proceedings documentation will use the {\verb|acmconf|} template style.
\begin{itemize}
\item {\verb|acmconf|}: The default proceedings template style.
\item{\verb|sigchi|}: Used for SIGCHI conference articles.
\item{\verb|sigchi-a|}: Used for SIGCHI ``Extended Abstract'' articles.
\item{\verb|sigplan|}: Used for SIGPLAN conference articles.
\end{itemize}
\subsection{Template Parameters}
In addition to specifying the {\itshape template style} to be used in
formatting your work, there are a number of {\itshape template parameters}
which modify some part of the applied template style. A complete list
of these parameters can be found in the {\itshape \LaTeX\ User's Guide.}
Frequently-used parameters, or combinations of parameters, include:
\begin{itemize}
\item {\verb|anonymous,review|}: Suitable for a ``double-blind''
conference submission. Anonymizes the work and includes line
numbers. Use with the \verb|\acmSubmissionID| command to print the
submission's unique ID on each page of the work.
\item{\verb|authorversion|}: Produces a version of the work suitable
for posting by the author.
\item{\verb|screen|}: Produces colored hyperlinks.
\end{itemize}
This document uses the following string as the first command in the
source file:
\begin{verbatim}
\documentclass[sigconf]{acmart}
\end{verbatim}
\section{Modifications}
Modifying the template --- including but not limited to: adjusting
margins, typeface sizes, line spacing, paragraph and list definitions,
and the use of the \verb|\vspace| command to manually adjust the
vertical spacing between elements of your work --- is not allowed.
{\bfseries Your document will be returned to you for revision if
modifications are discovered.}
\section{Typefaces}
The ``\verb|acmart|'' document class requires the use of the
``Libertine'' typeface family. Your \TeX\ installation should include
this set of packages. Please do not substitute other typefaces. The
``\verb|lmodern|'' and ``\verb|ltimes|'' packages should not be used,
as they will override the built-in typeface families.
\section{Title Information}
The title of your work should use capital letters appropriately -
\url{https://capitalizemytitle.com/} has useful rules for
capitalization. Use the {\verb|title|} command to define the title of
your work. If your work has a subtitle, define it with the
{\verb|subtitle|} command. Do not insert line breaks in your title.
If your title is lengthy, you must define a short version to be used
in the page headers, to prevent overlapping text. The \verb|title|
command has a ``short title'' parameter:
\begin{verbatim}
\title[short title]{full title}
\end{verbatim}
\section{Authors and Affiliations}
Each author must be defined separately for accurate metadata
identification. Multiple authors may share one affiliation. Authors'
names should not be abbreviated; use full first names wherever
possible. Include authors' e-mail addresses whenever possible.
Grouping authors' names or e-mail addresses, or providing an ``e-mail
alias,'' as shown below, is not acceptable:
\begin{verbatim}
\author{Brooke Aster, David Mehldau}
\email{dave,judy,[email protected]}
\email{[email protected]}
\end{verbatim}
The \verb|authornote| and \verb|authornotemark| commands allow a note
to apply to multiple authors --- for example, if the first two authors
of an article contributed equally to the work.
If your author list is lengthy, you must define a shortened version of
the list of authors to be used in the page headers, to prevent
overlapping text. The following command should be placed just after
the last \verb|\author{}| definition:
\begin{verbatim}
\renewcommand{\shortauthors}{McCartney, et al.}
\end{verbatim}
Omitting this command will force the use of a concatenated list of all
of the authors' names, which may result in overlapping text in the
page headers.
The article template's documentation, available at
\url{https://www.acm.org/publications/proceedings-template}, has a
complete explanation of these commands and tips for their effective
use.
Note that authors' addresses are mandatory for journal articles.
\section{Rights Information}
Authors of any work published by ACM will need to complete a rights
form. Depending on the kind of work, and the rights management choice
made by the author, this may be copyright transfer, permission,
license, or an OA (open access) agreement.
Regardless of the rights management choice, the author will receive a
copy of the completed rights form once it has been submitted. This
form contains \LaTeX\ commands that must be copied into the source
document. When the document source is compiled, these commands and
their parameters add formatted text to several areas of the final
document:
\begin{itemize}
\item the ``ACM Reference Format'' text on the first page.
\item the ``rights management'' text on the first page.
\item the conference information in the page header(s).
\end{itemize}
Rights information is unique to the work; if you are preparing several
works for an event, make sure to use the correct set of commands with
each of the works.
The ACM Reference Format text is required for all articles over one
page in length, and is optional for one-page articles (abstracts).
\section{CCS Concepts and User-Defined Keywords}
Two elements of the ``acmart'' document class provide powerful
taxonomic tools for you to help readers find your work in an online
search.
The ACM Computing Classification System ---
\url{https://www.acm.org/publications/class-2012} --- is a set of
classifiers and concepts that describe the computing
discipline. Authors can select entries from this classification
system, via \url{https://dl.acm.org/ccs/ccs.cfm}, and generate the
commands to be included in the \LaTeX\ source.
User-defined keywords are a comma-separated list of words and phrases
of the authors' choosing, providing a more flexible way of describing
the research being presented.
CCS concepts and user-defined keywords are required for for all
articles over two pages in length, and are optional for one- and
two-page articles (or abstracts).
\section{Sectioning Commands}
Your work should use standard \LaTeX\ sectioning commands:
\verb|section|, \verb|subsection|, \verb|subsubsection|, and
\verb|paragraph|. They should be numbered; do not remove the numbering
from the commands.
Simulating a sectioning command by setting the first word or words of
a paragraph in boldface or italicized text is {\bfseries not allowed.}
\section{Tables}
The ``\verb|acmart|'' document class includes the ``\verb|booktabs|''
package --- \url{https://ctan.org/pkg/booktabs} --- for preparing
high-quality tables.
Table captions are placed {\itshape above} the table.
Because tables cannot be split across pages, the best placement for
them is typically the top of the page nearest their initial cite. To
ensure this proper ``floating'' placement of tables, use the
environment \textbf{table} to enclose the table's contents and the
table caption. The contents of the table itself must go in the
\textbf{tabular} environment, to be aligned properly in rows and
columns, with the desired horizontal and vertical rules. Again,
detailed instructions on \textbf{tabular} material are found in the
\textit{\LaTeX\ User's Guide}.
Immediately following this sentence is the point at which
Table~\ref{tab:freq} is included in the input file; compare the
placement of the table here with the table in the printed output of
this document.
\begin{table}
\caption{Frequency of Special Characters}
\label{tab:freq}
\begin{tabular}{ccl}
\toprule
Non-English or Math&Frequency&Comments\\
\midrule
\O & 1 in 1,000& For Swedish names\\
$\pi$ & 1 in 5& Common in math\\
\$ & 4 in 5 & Used in business\\
$\Psi^2_1$ & 1 in 40,000& Unexplained usage\\
\bottomrule
\end{tabular}
\end{table}
To set a wider table, which takes up the whole width of the page's
live area, use the environment \textbf{table*} to enclose the table's
contents and the table caption. As with a single-column table, this
wide table will ``float'' to a location deemed more
desirable. Immediately following this sentence is the point at which
Table~\ref{tab:commands} is included in the input file; again, it is
instructive to compare the placement of the table here with the table
in the printed output of this document.
\begin{table*}
\caption{Some Typical Commands}
\label{tab:commands}
\begin{tabular}{ccl}
\toprule
Command &A Number & Comments\\
\midrule
\texttt{{\char'134}author} & 100& Author \\
\texttt{{\char'134}table}& 300 & For tables\\
\texttt{{\char'134}table*}& 400& For wider tables\\
\bottomrule
\end{tabular}
\end{table*}
Always use midrule to separate table header rows from data rows, and
use it only for this purpose. This enables assistive technologies to
recognise table headers and support their users in navigating tables
more easily.
\section{Math Equations}
You may want to display math equations in three distinct styles:
inline, numbered or non-numbered display. Each of the three are
discussed in the next sections.
\subsection{Inline (In-text) Equations}
A formula that appears in the running text is called an inline or
in-text formula. It is produced by the \textbf{math} environment,
which can be invoked with the usual
\texttt{{\char'134}begin\,\ldots{\char'134}end} construction or with
the short form \texttt{\$\,\ldots\$}. You can use any of the symbols
and structures, from $\alpha$ to $\omega$, available in
\LaTeX~\cite{Lamport:LaTeX}; this section will simply show a few
examples of in-text equations in context. Notice how this equation:
\begin{math}
\lim_{n\rightarrow \infty}x=0
\end{math},
set here in in-line math style, looks slightly different when
set in display style. (See next section).
\subsection{Display Equations}
A numbered display equation---one set off by vertical space from the
text and centered horizontally---is produced by the \textbf{equation}
environment. An unnumbered display equation is produced by the
\textbf{displaymath} environment.
Again, in either environment, you can use any of the symbols and
structures available in \LaTeX\@; this section will just give a couple
of examples of display equations in context. First, consider the
equation, shown as an inline equation above:
\begin{equation}
\lim_{n\rightarrow \infty}x=0
\end{equation}
Notice how it is formatted somewhat differently in
the \textbf{displaymath}
environment. Now, we'll enter an unnumbered equation:
\begin{displaymath}
\sum_{i=0}^{\infty} x + 1
\end{displaymath}
and follow it with another numbered equation:
\begin{equation}
\sum_{i=0}^{\infty}x_i=\int_{0}^{\pi+2} f
\end{equation}
just to demonstrate \LaTeX's able handling of numbering.
\section{Figures}
The ``\verb|figure|'' environment should be used for figures. One or
more images can be placed within a figure. If your figure contains
third-party material, you must clearly identify it as such, as shown
in the example below.
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{sample-franklin}
\caption{1907 Franklin Model D roadster. Photograph by Harris \&
Ewing, Inc. [Public domain], via Wikimedia
Commons. (\url{https://goo.gl/VLCRBB}).}
\Description{A woman and a girl in white dresses sit in an open car.}
\end{figure}
Your figures should contain a caption which describes the figure to
the reader.
Figure captions are placed {\itshape below} the figure.
Every figure should also have a figure description unless it is purely
decorative. These descriptions convey what’s in the image to someone
who cannot see it. They are also used by search engine crawlers for
indexing images, and when images cannot be loaded.
A figure description must be unformatted plain text less than 2000
characters long (including spaces). {\bfseries Figure descriptions
should not repeat the figure caption – their purpose is to capture
important information that is not already provided in the caption or
the main text of the paper.} For figures that convey important and
complex new information, a short text description may not be
adequate. More complex alternative descriptions can be placed in an
appendix and referenced in a short figure description. For example,
provide a data table capturing the information in a bar chart, or a
structured list representing a graph. For additional information
regarding how best to write figure descriptions and why doing this is
so important, please see
\url{https://www.acm.org/publications/taps/describing-figures/}.
\subsection{The ``Teaser Figure''}
A ``teaser figure'' is an image, or set of images in one figure, that
are placed after all author and affiliation information, and before
the body of the article, spanning the page. If you wish to have such a
figure in your article, place the command immediately before the
\verb|\maketitle| command:
\begin{verbatim}
\begin{teaserfigure}
\includegraphics[width=\textwidth]{sampleteaser}
\caption{figure caption}
\Description{figure description}
\end{teaserfigure}
\end{verbatim}
\section{Citations and Bibliographies}
The use of \BibTeX\ for the preparation and formatting of one's
references is strongly recommended. Authors' names should be complete
--- use full first names (``Donald E. Knuth'') not initials
(``D. E. Knuth'') --- and the salient identifying features of a
reference should be included: title, year, volume, number, pages,
article DOI, etc.
The bibliography is included in your source document with these two
commands, placed just before the \verb|\end{document}| command:
\begin{verbatim}
\bibliographystyle{ACM-Reference-Format}
\section{Introduction}
ACM's consolidated article template, introduced in 2017, provides a
consistent \LaTeX\ style for use across ACM publications, and
incorporates accessibility and metadata-extraction functionality
necessary for future Digital Library endeavors. Numerous ACM and
SIG-specific \LaTeX\ templates have been examined, and their unique
features incorporated into this single new template.
If you are new to publishing with ACM, this document is a valuable
guide to the process of preparing your work for publication. If you
have published with ACM before, this document provides insight and
instruction into more recent changes to the article template.
The ``\verb|acmart|'' document class can be used to prepare articles
for any ACM publication --- conference or journal, and for any stage
of publication, from review to final ``camera-ready'' copy, to the
author's own version, with {\itshape very} few changes to the source.
\section{Template Overview}
As noted in the introduction, the ``\verb|acmart|'' document class can
be used to prepare many different kinds of documentation --- a
double-blind initial submission of a full-length technical paper, a
two-page SIGGRAPH Emerging Technologies abstract, a ``camera-ready''
journal article, a SIGCHI Extended Abstract, and more --- all by
selecting the appropriate {\itshape template style} and {\itshape
template parameters}.
This document will explain the major features of the document
class. For further information, the {\itshape \LaTeX\ User's Guide} is
available from
\url{https://www.acm.org/publications/proceedings-template}.
\subsection{Template Styles}
The primary parameter given to the ``\verb|acmart|'' document class is
the {\itshape template style} which corresponds to the kind of publication
or SIG publishing the work. This parameter is enclosed in square
brackets and is a part of the {\verb|documentclass|} command:
\begin{verbatim}
\documentclass[STYLE]{acmart}
\end{verbatim}
Journals use one of three template styles. All but three ACM journals
use the {\verb|acmsmall|} template style:
\begin{itemize}
\item {\texttt{acmsmall}}: The default journal template style.
\item {\texttt{acmlarge}}: Used by JOCCH and TAP.
\item {\texttt{acmtog}}: Used by TOG.
\end{itemize}
The majority of conference proceedings documentation will use the {\verb|acmconf|} template style.
\begin{itemize}
\item {\texttt{acmconf}}: The default proceedings template style.
\item{\texttt{sigchi}}: Used for SIGCHI conference articles.
\item{\texttt{sigchi-a}}: Used for SIGCHI ``Extended Abstract'' articles.
\item{\texttt{sigplan}}: Used for SIGPLAN conference articles.
\end{itemize}
\subsection{Template Parameters}
In addition to specifying the {\itshape template style} to be used in
formatting your work, there are a number of {\itshape template parameters}
which modify some part of the applied template style. A complete list
of these parameters can be found in the {\itshape \LaTeX\ User's Guide.}
Frequently-used parameters, or combinations of parameters, include:
\begin{itemize}
\item {\texttt{anonymous,review}}: Suitable for a ``double-blind''
conference submission. Anonymizes the work and includes line
numbers. Use with the \texttt{\acmSubmissionID} command to print the
submission's unique ID on each page of the work.
\item{\texttt{authorversion}}: Produces a version of the work suitable
for posting by the author.
\item{\texttt{screen}}: Produces colored hyperlinks.
\end{itemize}
This document uses the following string as the first command in the
source file:
\begin{verbatim}
\documentclass[sigconf, language=french,
language=german, language=spanish, language=english]{acmart}
\end{verbatim}
\section{Modifications}
Modifying the template --- including but not limited to: adjusting
margins, typeface sizes, line spacing, paragraph and list definitions,
and the use of the \verb|\vspace| command to manually adjust the
vertical spacing between elements of your work --- is not allowed.
{\bfseries Your document will be returned to you for revision if
modifications are discovered.}
\section{Typefaces}
The ``\verb|acmart|'' document class requires the use of the
``Libertine'' typeface family. Your \TeX\ installation should include
this set of packages. Please do not substitute other typefaces. The
``\verb|lmodern|'' and ``\verb|ltimes|'' packages should not be used,
as they will override the built-in typeface families.
\section{Title Information}
The title of your work should use capital letters appropriately -
\url{https://capitalizemytitle.com/} has useful rules for
capitalization. Use the {\verb|title|} command to define the title of
your work. If your work has a subtitle, define it with the
{\verb|subtitle|} command. Do not insert line breaks in your title.
If your title is lengthy, you must define a short version to be used
in the page headers, to prevent overlapping text. The \verb|title|
command has a ``short title'' parameter:
\begin{verbatim}
\title[short title]{full title}
\end{verbatim}
\section{Authors and Affiliations}
Each author must be defined separately for accurate metadata
identification. As an exception, multiple authors may share one
affiliation. Authors' names should not be abbreviated; use full first
names wherever possible. Include authors' e-mail addresses whenever
possible.
Grouping authors' names or e-mail addresses, or providing an ``e-mail
alias,'' as shown below, is not acceptable:
\begin{verbatim}
\author{Brooke Aster, David Mehldau}
\email{dave,judy,[email protected]}
\email{[email protected]}
\end{verbatim}
The \verb|authornote| and \verb|authornotemark| commands allow a note
to apply to multiple authors --- for example, if the first two authors
of an article contributed equally to the work.
If your author list is lengthy, you must define a shortened version of
the list of authors to be used in the page headers, to prevent
overlapping text. The following command should be placed just after
the last \verb|\author{}| definition:
\begin{verbatim}
\renewcommand{\shortauthors}{McCartney, et al.}
\end{verbatim}
Omitting this command will force the use of a concatenated list of all
of the authors' names, which may result in overlapping text in the
page headers.
The article template's documentation, available at
\url{https://www.acm.org/publications/proceedings-template}, has a
complete explanation of these commands and tips for their effective
use.
Note that authors' addresses are mandatory for journal articles.
\section{Rights Information}
Authors of any work published by ACM will need to complete a rights
form. Depending on the kind of work, and the rights management choice
made by the author, this may be copyright transfer, permission,
license, or an OA (open access) agreement.
Regardless of the rights management choice, the author will receive a
copy of the completed rights form once it has been submitted. This
form contains \LaTeX\ commands that must be copied into the source
document. When the document source is compiled, these commands and
their parameters add formatted text to several areas of the final
document:
\begin{itemize}
\item the ``ACM Reference Format'' text on the first page.
\item the ``rights management'' text on the first page.
\item the conference information in the page header(s).
\end{itemize}
Rights information is unique to the work; if you are preparing several
works for an event, make sure to use the correct set of commands with
each of the works.
The ACM Reference Format text is required for all articles over one
page in length, and is optional for one-page articles (abstracts).
\section{CCS Concepts and User-Defined Keywords}
Two elements of the ``acmart'' document class provide powerful
taxonomic tools for you to help readers find your work in an online
search.
The ACM Computing Classification System ---
\url{https://www.acm.org/publications/class-2012} --- is a set of
classifiers and concepts that describe the computing
discipline. Authors can select entries from this classification
system, via \url{https://dl.acm.org/ccs/ccs.cfm}, and generate the
commands to be included in the \LaTeX\ source.
User-defined keywords are a comma-separated list of words and phrases
of the authors' choosing, providing a more flexible way of describing
the research being presented.
CCS concepts and user-defined keywords are required for for all
articles over two pages in length, and are optional for one- and
two-page articles (or abstracts).
\section{Sectioning Commands}
Your work should use standard \LaTeX\ sectioning commands:
\verb|section|, \verb|subsection|, \verb|subsubsection|, and
\verb|paragraph|. They should be numbered; do not remove the numbering
from the commands.
Simulating a sectioning command by setting the first word or words of
a paragraph in boldface or italicized text is {\bfseries not allowed.}
\section{Tables}
The ``\verb|acmart|'' document class includes the ``\verb|booktabs|''
package --- \url{https://ctan.org/pkg/booktabs} --- for preparing
high-quality tables.
Table captions are placed {\itshape above} the table.
Because tables cannot be split across pages, the best placement for
them is typically the top of the page nearest their initial cite. To
ensure this proper ``floating'' placement of tables, use the
environment \textbf{table} to enclose the table's contents and the
table caption. The contents of the table itself must go in the
\textbf{tabular} environment, to be aligned properly in rows and
columns, with the desired horizontal and vertical rules. Again,
detailed instructions on \textbf{tabular} material are found in the
\textit{\LaTeX\ User's Guide}.
Immediately following this sentence is the point at which
Table~\ref{tab:freq} is included in the input file; compare the
placement of the table here with the table in the printed output of
this document.
\begin{table}
\caption{Frequency of Special Characters}
\label{tab:freq}
\begin{tabular}{ccl}
\toprule
Non-English or Math&Frequency&Comments\\
\midrule
\O & 1 in 1,000& For Swedish names\\
$\pi$ & 1 in 5& Common in math\\
\$ & 4 in 5 & Used in business\\
$\Psi^2_1$ & 1 in 40,000& Unexplained usage\\
\bottomrule
\end{tabular}
\end{table}
To set a wider table, which takes up the whole width of the page's
live area, use the environment \textbf{table*} to enclose the table's
contents and the table caption. As with a single-column table, this
wide table will ``float'' to a location deemed more
desirable. Immediately following this sentence is the point at which
Table~\ref{tab:commands} is included in the input file; again, it is
instructive to compare the placement of the table here with the table
in the printed output of this document.
\begin{table*}
\caption{Some Typical Commands}
\label{tab:commands}
\begin{tabular}{ccl}
\toprule
Command &A Number & Comments\\
\midrule
\texttt{{\char'134}author} & 100& Author \\
\texttt{{\char'134}table}& 300 & For tables\\
\texttt{{\char'134}table*}& 400& For wider tables\\
\bottomrule
\end{tabular}
\end{table*}
Always use midrule to separate table header rows from data rows, and
use it only for this purpose. This enables assistive technologies to
recognise table headers and support their users in navigating tables
more easily.
\section{Math Equations}
You may want to display math equations in three distinct styles:
inline, numbered or non-numbered display. Each of the three are
discussed in the next sections.
\subsection{Inline (In-text) Equations}
A formula that appears in the running text is called an inline or
in-text formula. It is produced by the \textbf{math} environment,
which can be invoked with the usual
\texttt{{\char'134}begin\,\ldots{\char'134}end} construction or with
the short form \texttt{\$\,\ldots\$}. You can use any of the symbols
and structures, from $\alpha$ to $\omega$, available in
\LaTeX~\cite{Lamport:LaTeX}; this section will simply show a few
examples of in-text equations in context. Notice how this equation:
\begin{math}
\lim_{n\rightarrow \infty}x=0
\end{math},
set here in in-line math style, looks slightly different when
set in display style. (See next section).
\subsection{Display Equations}
A numbered display equation---one set off by vertical space from the
text and centered horizontally---is produced by the \textbf{equation}
environment. An unnumbered display equation is produced by the
\textbf{displaymath} environment.
Again, in either environment, you can use any of the symbols and
structures available in \LaTeX\@; this section will just give a couple
of examples of display equations in context. First, consider the
equation, shown as an inline equation above:
\begin{equation}
\lim_{n\rightarrow \infty}x=0
\end{equation}
Notice how it is formatted somewhat differently in
the \textbf{displaymath}
environment. Now, we'll enter an unnumbered equation:
\begin{displaymath}
\sum_{i=0}^{\infty} x + 1
\end{displaymath}
and follow it with another numbered equation:
\begin{equation}
\sum_{i=0}^{\infty}x_i=\int_{0}^{\pi+2} f
\end{equation}
just to demonstrate \LaTeX's able handling of numbering.
\section{Figures}
The ``\verb|figure|'' environment should be used for figures. One or
more images can be placed within a figure. If your figure contains
third-party material, you must clearly identify it as such, as shown
in the example below.
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{sample-franklin}
\caption{1907 Franklin Model D roadster. Photograph by Harris \&
Ewing, Inc. [Public domain], via Wikimedia
Commons. (\url{https://goo.gl/VLCRBB}).}
\Description{A woman and a girl in white dresses sit in an open car.}
\end{figure}
Your figures should contain a caption which describes the figure to
the reader.
Figure captions are placed {\itshape below} the figure.
Every figure should also have a figure description unless it is purely
decorative. These descriptions convey what’s in the image to someone
who cannot see it. They are also used by search engine crawlers for
indexing images, and when images cannot be loaded.
A figure description must be unformatted plain text less than 2000
characters long (including spaces). {\bfseries Figure descriptions
should not repeat the figure caption – their purpose is to capture
important information that is not already provided in the caption or
the main text of the paper.} For figures that convey important and
complex new information, a short text description may not be
adequate. More complex alternative descriptions can be placed in an
appendix and referenced in a short figure description. For example,
provide a data table capturing the information in a bar chart, or a
structured list representing a graph. For additional information
regarding how best to write figure descriptions and why doing this is
so important, please see
\url{https://www.acm.org/publications/taps/describing-figures/}.
\subsection{The ``Teaser Figure''}
A ``teaser figure'' is an image, or set of images in one figure, that
are placed after all author and affiliation information, and before
the body of the article, spanning the page. If you wish to have such a
figure in your article, place the command immediately before the
\verb|\maketitle| command:
\begin{verbatim}
\begin{teaserfigure}
\includegraphics[width=\textwidth]{sampleteaser}
\caption{figure caption}
\Description{figure description}
\end{teaserfigure}
\end{verbatim}
\section{Citations and Bibliographies}
The use of \BibTeX\ for the preparation and formatting of one's
references is strongly recommended. Authors' names should be complete
--- use full first names (``Donald E. Knuth'') not initials
(``D. E. Knuth'') --- and the salient identifying features of a
reference should be included: title, year, volume, number, pages,
article DOI, etc.
The bibliography is included in your source document with these two
commands, placed just before the \verb|\end{document}| command:
\begin{verbatim}
\bibliographystyle{ACM-Reference-Format}
\section{Introduction}
ACM's consolidated article template, introduced in 2017, provides a
consistent \LaTeX\ style for use across ACM publications, and
incorporates accessibility and metadata-extraction functionality
necessary for future Digital Library endeavors. Numerous ACM and
SIG-specific \LaTeX\ templates have been examined, and their unique
features incorporated into this single new template.
If you are new to publishing with ACM, this document is a valuable
guide to the process of preparing your work for publication. If you
have published with ACM before, this document provides insight and
instruction into more recent changes to the article template.
The ``\verb|acmart|'' document class can be used to prepare articles
for any ACM publication --- conference or journal, and for any stage
of publication, from review to final ``camera-ready'' copy, to the
author's own version, with {\itshape very} few changes to the source.
\section{Template Overview}
As noted in the introduction, the ``\verb|acmart|'' document class can
be used to prepare many different kinds of documentation --- a
double-blind initial submission of a full-length technical paper, a
two-page SIGGRAPH Emerging Technologies abstract, a ``camera-ready''
journal article, a SIGCHI Extended Abstract, and more --- all by
selecting the appropriate {\itshape template style} and {\itshape
template parameters}.
This document will explain the major features of the document
class. For further information, the {\itshape \LaTeX\ User's Guide} is
available from
\url{https://www.acm.org/publications/proceedings-template}.
\subsection{Template Styles}
The primary parameter given to the ``\verb|acmart|'' document class is
the {\itshape template style} which corresponds to the kind of publication
or SIG publishing the work. This parameter is enclosed in square
brackets and is a part of the {\verb|documentclass|} command:
\begin{verbatim}
\documentclass[STYLE]{acmart}
\end{verbatim}
Journals use one of three template styles. All but three ACM journals
use the {\verb|acmsmall|} template style:
\begin{itemize}
\item {\verb|acmsmall|}: The default journal template style.
\item {\verb|acmlarge|}: Used by JOCCH and TAP.
\item {\verb|acmtog|}: Used by TOG.
\end{itemize}
The majority of conference proceedings documentation will use the {\verb|acmconf|} template style.
\begin{itemize}
\item {\verb|acmconf|}: The default proceedings template style.
\item{\verb|sigchi|}: Used for SIGCHI conference articles.
\item{\verb|sigchi-a|}: Used for SIGCHI ``Extended Abstract'' articles.
\item{\verb|sigplan|}: Used for SIGPLAN conference articles.
\end{itemize}
\subsection{Template Parameters}
In addition to specifying the {\itshape template style} to be used in
formatting your work, there are a number of {\itshape template parameters}
which modify some part of the applied template style. A complete list
of these parameters can be found in the {\itshape \LaTeX\ User's Guide.}
Frequently-used parameters, or combinations of parameters, include:
\begin{itemize}
\item {\verb|anonymous,review|}: Suitable for a ``double-blind''
conference submission. Anonymizes the work and includes line
numbers. Use with the \verb|\acmSubmissionID| command to print the
submission's unique ID on each page of the work.
\item{\verb|authorversion|}: Produces a version of the work suitable
for posting by the author.
\item{\verb|screen|}: Produces colored hyperlinks.
\end{itemize}
This document uses the following string as the first command in the
source file:
\begin{verbatim}
\documentclass[sigconf]{acmart}
\end{verbatim}
\section{Modifications}
Modifying the template --- including but not limited to: adjusting
margins, typeface sizes, line spacing, paragraph and list definitions,
and the use of the \verb|\vspace| command to manually adjust the
vertical spacing between elements of your work --- is not allowed.
{\bfseries Your document will be returned to you for revision if
modifications are discovered.}
\section{Typefaces}
The ``\verb|acmart|'' document class requires the use of the
``Libertine'' typeface family. Your \TeX\ installation should include
this set of packages. Please do not substitute other typefaces. The
``\verb|lmodern|'' and ``\verb|ltimes|'' packages should not be used,
as they will override the built-in typeface families.
\section{Title Information}
The title of your work should use capital letters appropriately -
\url{https://capitalizemytitle.com/} has useful rules for
capitalization. Use the {\verb|title|} command to define the title of
your work. If your work has a subtitle, define it with the
{\verb|subtitle|} command. Do not insert line breaks in your title.
If your title is lengthy, you must define a short version to be used
in the page headers, to prevent overlapping text. The \verb|title|
command has a ``short title'' parameter:
\begin{verbatim}
\title[short title]{full title}
\end{verbatim}
\section{Authors and Affiliations}
Each author must be defined separately for accurate metadata
identification. Multiple authors may share one affiliation. Authors'
names should not be abbreviated; use full first names wherever
possible. Include authors' e-mail addresses whenever possible.
Grouping authors' names or e-mail addresses, or providing an ``e-mail
alias,'' as shown below, is not acceptable:
\begin{verbatim}
\author{Brooke Aster, David Mehldau}
\email{dave,judy,[email protected]}
\email{[email protected]}
\end{verbatim}
The \verb|authornote| and \verb|authornotemark| commands allow a note
to apply to multiple authors --- for example, if the first two authors
of an article contributed equally to the work.
If your author list is lengthy, you must define a shortened version of
the list of authors to be used in the page headers, to prevent
overlapping text. The following command should be placed just after
the last \verb|\author{}| definition:
\begin{verbatim}
\renewcommand{\shortauthors}{McCartney, et al.}
\end{verbatim}
Omitting this command will force the use of a concatenated list of all
of the authors' names, which may result in overlapping text in the
page headers.
The article template's documentation, available at
\url{https://www.acm.org/publications/proceedings-template}, has a
complete explanation of these commands and tips for their effective
use.
Note that authors' addresses are mandatory for journal articles.
\section{Rights Information}
Authors of any work published by ACM will need to complete a rights
form. Depending on the kind of work, and the rights management choice
made by the author, this may be copyright transfer, permission,
license, or an OA (open access) agreement.
Regardless of the rights management choice, the author will receive a
copy of the completed rights form once it has been submitted. This
form contains \LaTeX\ commands that must be copied into the source
document. When the document source is compiled, these commands and
their parameters add formatted text to several areas of the final
document:
\begin{itemize}
\item the ``ACM Reference Format'' text on the first page.
\item the ``rights management'' text on the first page.
\item the conference information in the page header(s).
\end{itemize}
Rights information is unique to the work; if you are preparing several
works for an event, make sure to use the correct set of commands with
each of the works.
The ACM Reference Format text is required for all articles over one
page in length, and is optional for one-page articles (abstracts).
\section{CCS Concepts and User-Defined Keywords}
Two elements of the ``acmart'' document class provide powerful
taxonomic tools for you to help readers find your work in an online
search.
The ACM Computing Classification System ---
\url{https://www.acm.org/publications/class-2012} --- is a set of
classifiers and concepts that describe the computing
discipline. Authors can select entries from this classification
system, via \url{https://dl.acm.org/ccs/ccs.cfm}, and generate the
commands to be included in the \LaTeX\ source.
User-defined keywords are a comma-separated list of words and phrases
of the authors' choosing, providing a more flexible way of describing
the research being presented.
CCS concepts and user-defined keywords are required for for all
articles over two pages in length, and are optional for one- and
two-page articles (or abstracts).
\section{Sectioning Commands}
Your work should use standard \LaTeX\ sectioning commands:
\verb|section|, \verb|subsection|, \verb|subsubsection|, and
\verb|paragraph|. They should be numbered; do not remove the numbering
from the commands.
Simulating a sectioning command by setting the first word or words of
a paragraph in boldface or italicized text is {\bfseries not allowed.}
\section{Tables}
The ``\verb|acmart|'' document class includes the ``\verb|booktabs|''
package --- \url{https://ctan.org/pkg/booktabs} --- for preparing
high-quality tables.
Table captions are placed {\itshape above} the table.
Because tables cannot be split across pages, the best placement for
them is typically the top of the page nearest their initial cite. To
ensure this proper ``floating'' placement of tables, use the
environment \textbf{table} to enclose the table's contents and the
table caption. The contents of the table itself must go in the
\textbf{tabular} environment, to be aligned properly in rows and
columns, with the desired horizontal and vertical rules. Again,
detailed instructions on \textbf{tabular} material are found in the
\textit{\LaTeX\ User's Guide}.
Immediately following this sentence is the point at which
Table~\ref{tab:freq} is included in the input file; compare the
placement of the table here with the table in the printed output of
this document.
\begin{table}
\caption{Frequency of Special Characters}
\label{tab:freq}
\begin{tabular}{ccl}
\toprule
Non-English or Math&Frequency&Comments\\
\midrule
\O & 1 in 1,000& For Swedish names\\
$\pi$ & 1 in 5& Common in math\\
\$ & 4 in 5 & Used in business\\
$\Psi^2_1$ & 1 in 40,000& Unexplained usage\\
\bottomrule
\end{tabular}
\end{table}
To set a wider table, which takes up the whole width of the page's
live area, use the environment \textbf{table*} to enclose the table's
contents and the table caption. As with a single-column table, this
wide table will ``float'' to a location deemed more
desirable. Immediately following this sentence is the point at which
Table~\ref{tab:commands} is included in the input file; again, it is
instructive to compare the placement of the table here with the table
in the printed output of this document.
\begin{table*}
\caption{Some Typical Commands}
\label{tab:commands}
\begin{tabular}{ccl}
\toprule
Command &A Number & Comments\\
\midrule
\texttt{{\char'134}author} & 100& Author \\
\texttt{{\char'134}table}& 300 & For tables\\
\texttt{{\char'134}table*}& 400& For wider tables\\
\bottomrule
\end{tabular}
\end{table*}
Always use midrule to separate table header rows from data rows, and
use it only for this purpose. This enables assistive technologies to
recognise table headers and support their users in navigating tables
more easily.
\section{Math Equations}
You may want to display math equations in three distinct styles:
inline, numbered or non-numbered display. Each of the three are
discussed in the next sections.
\subsection{Inline (In-text) Equations}
A formula that appears in the running text is called an inline or
in-text formula. It is produced by the \textbf{math} environment,
which can be invoked with the usual
\texttt{{\char'134}begin\,\ldots{\char'134}end} construction or with
the short form \texttt{\$\,\ldots\$}. You can use any of the symbols
and structures, from $\alpha$ to $\omega$, available in
\LaTeX~\cite{Lamport:LaTeX}; this section will simply show a few
examples of in-text equations in context. Notice how this equation:
\begin{math}
\lim_{n\rightarrow \infty}x=0
\end{math},
set here in in-line math style, looks slightly different when
set in display style. (See next section).
\subsection{Display Equations}
A numbered display equation---one set off by vertical space from the
text and centered horizontally---is produced by the \textbf{equation}
environment. An unnumbered display equation is produced by the
\textbf{displaymath} environment.
Again, in either environment, you can use any of the symbols and
structures available in \LaTeX\@; this section will just give a couple
of examples of display equations in context. First, consider the
equation, shown as an inline equation above:
\begin{equation}
\lim_{n\rightarrow \infty}x=0
\end{equation}
Notice how it is formatted somewhat differently in
the \textbf{displaymath}
environment. Now, we'll enter an unnumbered equation:
\begin{displaymath}
\sum_{i=0}^{\infty} x + 1
\end{displaymath}
and follow it with another numbered equation:
\begin{equation}
\sum_{i=0}^{\infty}x_i=\int_{0}^{\pi+2} f
\end{equation}
just to demonstrate \LaTeX's able handling of numbering.
\section{Figures}
The ``\verb|figure|'' environment should be used for figures. One or
more images can be placed within a figure. If your figure contains
third-party material, you must clearly identify it as such, as shown
in the example below.
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{sample-franklin}
\caption{1907 Franklin Model D roadster. Photograph by Harris \&
Ewing, Inc. [Public domain], via Wikimedia
Commons. (\url{https://goo.gl/VLCRBB}).}
\Description{A woman and a girl in white dresses sit in an open car.}
\end{figure}
Your figures should contain a caption which describes the figure to
the reader.
Figure captions are placed {\itshape below} the figure.
Every figure should also have a figure description unless it is purely
decorative. These descriptions convey what’s in the image to someone
who cannot see it. They are also used by search engine crawlers for
indexing images, and when images cannot be loaded.
A figure description must be unformatted plain text less than 2000
characters long (including spaces). {\bfseries Figure descriptions
should not repeat the figure caption – their purpose is to capture
important information that is not already provided in the caption or
the main text of the paper.} For figures that convey important and
complex new information, a short text description may not be
adequate. More complex alternative descriptions can be placed in an
appendix and referenced in a short figure description. For example,
provide a data table capturing the information in a bar chart, or a
structured list representing a graph. For additional information
regarding how best to write figure descriptions and why doing this is
so important, please see
\url{https://www.acm.org/publications/taps/describing-figures/}.
\subsection{The ``Teaser Figure''}
A ``teaser figure'' is an image, or set of images in one figure, that
are placed after all author and affiliation information, and before
the body of the article, spanning the page. If you wish to have such a
figure in your article, place the command immediately before the
\verb|\maketitle| command:
\begin{verbatim}
\begin{teaserfigure}
\includegraphics[width=\textwidth]{sampleteaser}
\caption{figure caption}
\Description{figure description}
\end{teaserfigure}
\end{verbatim}
\section{Citations and Bibliographies}
The use of \BibTeX\ for the preparation and formatting of one's
references is strongly recommended. Authors' names should be complete
--- use full first names (``Donald E. Knuth'') not initials
(``D. E. Knuth'') --- and the salient identifying features of a
reference should be included: title, year, volume, number, pages,
article DOI, etc.
The bibliography is included in your source document with these two
commands, placed just before the \verb|\end{document}| command:
\begin{verbatim}
\bibliographystyle{ACM-Reference-Format}
\section{Introduction}
ACM's consolidated article template, introduced in 2017, provides a
consistent \LaTeX\ style for use across ACM publications, and
incorporates accessibility and metadata-extraction functionality
necessary for future Digital Library endeavors. Numerous ACM and
SIG-specific \LaTeX\ templates have been examined, and their unique
features incorporated into this single new template.
If you are new to publishing with ACM, this document is a valuable
guide to the process of preparing your work for publication. If you
have published with ACM before, this document provides insight and
instruction into more recent changes to the article template.
The ``\verb|acmart|'' document class can be used to prepare articles
for any ACM publication --- conference or journal, and for any stage
of publication, from review to final ``camera-ready'' copy, to the
author's own version, with {\itshape very} few changes to the source.
\section{Template Overview}
As noted in the introduction, the ``\verb|acmart|'' document class can
be used to prepare many different kinds of documentation --- a
double-blind initial submission of a full-length technical paper, a
two-page SIGGRAPH Emerging Technologies abstract, a ``camera-ready''
journal article, a SIGCHI Extended Abstract, and more --- all by
selecting the appropriate {\itshape template style} and {\itshape
template parameters}.
This document will explain the major features of the document
class. For further information, the {\itshape \LaTeX\ User's Guide} is
available from
\url{https://www.acm.org/publications/proceedings-template}.
\subsection{Template Styles}
The primary parameter given to the ``\verb|acmart|'' document class is
the {\itshape template style} which corresponds to the kind of publication
or SIG publishing the work. This parameter is enclosed in square
brackets and is a part of the {\verb|documentclass|} command:
\begin{verbatim}
\documentclass[STYLE]{acmart}
\end{verbatim}
Journals use one of three template styles. All but three ACM journals
use the {\verb|acmsmall|} template style:
\begin{itemize}
\item {\verb|acmsmall|}: The default journal template style.
\item {\verb|acmlarge|}: Used by JOCCH and TAP.
\item {\verb|acmtog|}: Used by TOG.
\end{itemize}
The majority of conference proceedings documentation will use the {\verb|acmconf|} template style.
\begin{itemize}
\item {\verb|acmconf|}: The default proceedings template style.
\item{\verb|sigchi|}: Used for SIGCHI conference articles.
\item{\verb|sigchi-a|}: Used for SIGCHI ``Extended Abstract'' articles.
\item{\verb|sigplan|}: Used for SIGPLAN conference articles.
\end{itemize}
\subsection{Template Parameters}
In addition to specifying the {\itshape template style} to be used in
formatting your work, there are a number of {\itshape template parameters}
which modify some part of the applied template style. A complete list
of these parameters can be found in the {\itshape \LaTeX\ User's Guide.}
Frequently-used parameters, or combinations of parameters, include:
\begin{itemize}
\item {\verb|anonymous,review|}: Suitable for a ``double-blind''
conference submission. Anonymizes the work and includes line
numbers. Use with the \verb|\acmSubmissionID| command to print the
submission's unique ID on each page of the work.
\item{\verb|authorversion|}: Produces a version of the work suitable
for posting by the author.
\item{\verb|screen|}: Produces colored hyperlinks.
\end{itemize}
This document uses the following string as the first command in the
source file:
\begin{verbatim}
\documentclass[sigconf]{acmart}
\end{verbatim}
\section{Modifications}
Modifying the template --- including but not limited to: adjusting
margins, typeface sizes, line spacing, paragraph and list definitions,
and the use of the \verb|\vspace| command to manually adjust the
vertical spacing between elements of your work --- is not allowed.
{\bfseries Your document will be returned to you for revision if
modifications are discovered.}
\section{Typefaces}
The ``\verb|acmart|'' document class requires the use of the
``Libertine'' typeface family. Your \TeX\ installation should include
this set of packages. Please do not substitute other typefaces. The
``\verb|lmodern|'' and ``\verb|ltimes|'' packages should not be used,
as they will override the built-in typeface families.
\section{Title Information}
The title of your work should use capital letters appropriately -
\url{https://capitalizemytitle.com/} has useful rules for
capitalization. Use the {\verb|title|} command to define the title of
your work. If your work has a subtitle, define it with the
{\verb|subtitle|} command. Do not insert line breaks in your title.
If your title is lengthy, you must define a short version to be used
in the page headers, to prevent overlapping text. The \verb|title|
command has a ``short title'' parameter:
\begin{verbatim}
\title[short title]{full title}
\end{verbatim}
\section{Authors and Affiliations}
Each author must be defined separately for accurate metadata
identification. Multiple authors may share one affiliation. Authors'
names should not be abbreviated; use full first names wherever
possible. Include authors' e-mail addresses whenever possible.
Grouping authors' names or e-mail addresses, or providing an ``e-mail
alias,'' as shown below, is not acceptable:
\begin{verbatim}
\author{Brooke Aster, David Mehldau}
\email{dave,judy,[email protected]}
\email{[email protected]}
\end{verbatim}
The \verb|authornote| and \verb|authornotemark| commands allow a note
to apply to multiple authors --- for example, if the first two authors
of an article contributed equally to the work.
If your author list is lengthy, you must define a shortened version of
the list of authors to be used in the page headers, to prevent
overlapping text. The following command should be placed just after
the last \verb|\author{}| definition:
\begin{verbatim}
\renewcommand{\shortauthors}{McCartney, et al.}
\end{verbatim}
Omitting this command will force the use of a concatenated list of all
of the authors' names, which may result in overlapping text in the
page headers.
The article template's documentation, available at
\url{https://www.acm.org/publications/proceedings-template}, has a
complete explanation of these commands and tips for their effective
use.
Note that authors' addresses are mandatory for journal articles.
\section{Rights Information}
Authors of any work published by ACM will need to complete a rights
form. Depending on the kind of work, and the rights management choice
made by the author, this may be copyright transfer, permission,
license, or an OA (open access) agreement.
Regardless of the rights management choice, the author will receive a
copy of the completed rights form once it has been submitted. This
form contains \LaTeX\ commands that must be copied into the source
document. When the document source is compiled, these commands and
their parameters add formatted text to several areas of the final
document:
\begin{itemize}
\item the ``ACM Reference Format'' text on the first page.
\item the ``rights management'' text on the first page.
\item the conference information in the page header(s).
\end{itemize}
Rights information is unique to the work; if you are preparing several
works for an event, make sure to use the correct set of commands with
each of the works.
The ACM Reference Format text is required for all articles over one
page in length, and is optional for one-page articles (abstracts).
\section{CCS Concepts and User-Defined Keywords}
Two elements of the ``acmart'' document class provide powerful
taxonomic tools for you to help readers find your work in an online
search.
The ACM Computing Classification System ---
\url{https://www.acm.org/publications/class-2012} --- is a set of
classifiers and concepts that describe the computing
discipline. Authors can select entries from this classification
system, via \url{https://dl.acm.org/ccs/ccs.cfm}, and generate the
commands to be included in the \LaTeX\ source.
User-defined keywords are a comma-separated list of words and phrases
of the authors' choosing, providing a more flexible way of describing
the research being presented.
CCS concepts and user-defined keywords are required for for all
articles over two pages in length, and are optional for one- and
two-page articles (or abstracts).
\section{Sectioning Commands}
Your work should use standard \LaTeX\ sectioning commands:
\verb|section|, \verb|subsection|, \verb|subsubsection|, and
\verb|paragraph|. They should be numbered; do not remove the numbering
from the commands.
Simulating a sectioning command by setting the first word or words of
a paragraph in boldface or italicized text is {\bfseries not allowed.}
\section{Tables}
The ``\verb|acmart|'' document class includes the ``\verb|booktabs|''
package --- \url{https://ctan.org/pkg/booktabs} --- for preparing
high-quality tables.
Table captions are placed {\itshape above} the table.
Because tables cannot be split across pages, the best placement for
them is typically the top of the page nearest their initial cite. To
ensure this proper ``floating'' placement of tables, use the
environment \textbf{table} to enclose the table's contents and the
table caption. The contents of the table itself must go in the
\textbf{tabular} environment, to be aligned properly in rows and
columns, with the desired horizontal and vertical rules. Again,
detailed instructions on \textbf{tabular} material are found in the
\textit{\LaTeX\ User's Guide}.
Immediately following this sentence is the point at which
Table~\ref{tab:freq} is included in the input file; compare the
placement of the table here with the table in the printed output of
this document.
\begin{table}
\caption{Frequency of Special Characters}
\label{tab:freq}
\begin{tabular}{ccl}
\toprule
Non-English or Math&Frequency&Comments\\
\midrule
\O & 1 in 1,000& For Swedish names\\
$\pi$ & 1 in 5& Common in math\\
\$ & 4 in 5 & Used in business\\
$\Psi^2_1$ & 1 in 40,000& Unexplained usage\\
\bottomrule
\end{tabular}
\end{table}
To set a wider table, which takes up the whole width of the page's
live area, use the environment \textbf{table*} to enclose the table's
contents and the table caption. As with a single-column table, this
wide table will ``float'' to a location deemed more
desirable. Immediately following this sentence is the point at which
Table~\ref{tab:commands} is included in the input file; again, it is
instructive to compare the placement of the table here with the table
in the printed output of this document.
\begin{table*}
\caption{Some Typical Commands}
\label{tab:commands}
\begin{tabular}{ccl}
\toprule
Command &A Number & Comments\\
\midrule
\texttt{{\char'134}author} & 100& Author \\
\texttt{{\char'134}table}& 300 & For tables\\
\texttt{{\char'134}table*}& 400& For wider tables\\
\bottomrule
\end{tabular}
\end{table*}
Always use midrule to separate table header rows from data rows, and
use it only for this purpose. This enables assistive technologies to
recognise table headers and support their users in navigating tables
more easily.
\section{Math Equations}
You may want to display math equations in three distinct styles:
inline, numbered or non-numbered display. Each of the three are
discussed in the next sections.
\subsection{Inline (In-text) Equations}
A formula that appears in the running text is called an inline or
in-text formula. It is produced by the \textbf{math} environment,
which can be invoked with the usual
\texttt{{\char'134}begin\,\ldots{\char'134}end} construction or with
the short form \texttt{\$\,\ldots\$}. You can use any of the symbols
and structures, from $\alpha$ to $\omega$, available in
\LaTeX~\cite{Lamport:LaTeX}; this section will simply show a few
examples of in-text equations in context. Notice how this equation:
\begin{math}
\lim_{n\rightarrow \infty}x=0
\end{math},
set here in in-line math style, looks slightly different when
set in display style. (See next section).
\subsection{Display Equations}
A numbered display equation---one set off by vertical space from the
text and centered horizontally---is produced by the \textbf{equation}
environment. An unnumbered display equation is produced by the
\textbf{displaymath} environment.
Again, in either environment, you can use any of the symbols and
structures available in \LaTeX\@; this section will just give a couple
of examples of display equations in context. First, consider the
equation, shown as an inline equation above:
\begin{equation}
\lim_{n\rightarrow \infty}x=0
\end{equation}
Notice how it is formatted somewhat differently in
the \textbf{displaymath}
environment. Now, we'll enter an unnumbered equation:
\begin{displaymath}
\sum_{i=0}^{\infty} x + 1
\end{displaymath}
and follow it with another numbered equation:
\begin{equation}
\sum_{i=0}^{\infty}x_i=\int_{0}^{\pi+2} f
\end{equation}
just to demonstrate \LaTeX's able handling of numbering.
\section{Figures}
The ``\verb|figure|'' environment should be used for figures. One or
more images can be placed within a figure. If your figure contains
third-party material, you must clearly identify it as such, as shown
in the example below.
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{sample-franklin}
\caption{1907 Franklin Model D roadster. Photograph by Harris \&
Ewing, Inc. [Public domain], via Wikimedia
Commons. (\url{https://goo.gl/VLCRBB}).}
\Description{A woman and a girl in white dresses sit in an open car.}
\end{figure}
Your figures should contain a caption which describes the figure to
the reader.
Figure captions are placed {\itshape below} the figure.
Every figure should also have a figure description unless it is purely
decorative. These descriptions convey what’s in the image to someone
who cannot see it. They are also used by search engine crawlers for
indexing images, and when images cannot be loaded.
A figure description must be unformatted plain text less than 2000
characters long (including spaces). {\bfseries Figure descriptions
should not repeat the figure caption – their purpose is to capture
important information that is not already provided in the caption or
the main text of the paper.} For figures that convey important and
complex new information, a short text description may not be
adequate. More complex alternative descriptions can be placed in an
appendix and referenced in a short figure description. For example,
provide a data table capturing the information in a bar chart, or a
structured list representing a graph. For additional information
regarding how best to write figure descriptions and why doing this is
so important, please see
\url{https://www.acm.org/publications/taps/describing-figures/}.
\subsection{The ``Teaser Figure''}
A ``teaser figure'' is an image, or set of images in one figure, that
are placed after all author and affiliation information, and before
the body of the article, spanning the page. If you wish to have such a
figure in your article, place the command immediately before the
\verb|\maketitle| command:
\begin{verbatim}
\begin{teaserfigure}
\includegraphics[width=\textwidth]{sampleteaser}
\caption{figure caption}
\Description{figure description}
\end{teaserfigure}
\end{verbatim}
\section{Citations and Bibliographies}
The use of \BibTeX\ for the preparation and formatting of one's
references is strongly recommended. Authors' names should be complete
--- use full first names (``Donald E. Knuth'') not initials
(``D. E. Knuth'') --- and the salient identifying features of a
reference should be included: title, year, volume, number, pages,
article DOI, etc.
The bibliography is included in your source document with these two
commands, placed just before the \verb|\end{document}| command:
\begin{verbatim}
\bibliographystyle{ACM-Reference-Format}
\subsection{Library Terminology}
This section briefly explains the main terminology used in our library.
\begin{itemize}
\item A \textbf{sensitive attribute} is an attribute that partitions the population into groups with unequal benefits received.
\item A \textbf{protected group} (or simply group) is created by partitioning the population by one or many sensitive attributes.
\item A \textbf{privileged value} of a sensitive attribute is a value that gives more benefit to a protected group, which includes it, than to protected groups, which do not include it.
\item A \textbf{subgroup} is created by splitting a protected group by privileges and disprivileged values.
\item A \textbf{group metric} is a metric that shows the relation between privileged and disprivileged subgroups created based on one or many sensitive attributes.
\end{itemize}
\subsection{Code Quality Management}
Establishing high code quality practices is essential for an open-source library to be adopted by the community and extended by contributors. We do not propose any novelty in code quality management, but the good foundation of these practices is another feature that distinguishes us from other fairness projects.
Automation of development workflows in the \textsf{Virny}\xspace GitHub repository is provided by \textbf{GitHub Actions}. Each pull request to the ‘main’ branch triggers a CI pipeline that automatically runs unit tests with pytest and adds a description of new features and modifications in the documentation. The status of the test execution is displayed to the reviewer of the pull request to check the impact of added modifications on other existing library functionality.
Creating test cases, which cover the main library functionality, is a crucial component of reliable development of new features. Our library has two types of tests: \textbf{unit tests} and \textbf{integration tests}. Unit tests are created based on the pytest Python library, ensuring the correct functionality of the main library functions. Integration tests are developed in Jupyter notebooks to check component interaction for all library use cases.
TODO: [Table of test coverage]
We also understand that user adoption requires comprehensive \textbf{library documentation} and detailed \textbf{use case examples}. Therefore, we created a website with all API descriptions and examples hosted on GitHub Pages using \href{https://squidfunk.github.io/mkdocs-material/}{mkdocs-material Python library}. Additionally, we adapted an open-source mkdocs parser (\href{https://github.com/MaxHalford/yamp}{YAMP}) for our library to generate automatic function descriptions based on code documentation.
\section{conclusions and Future Work}
\label{sec:discussion}
In this work we attempted to clarify the desiderata of fairness and stability, by asking the question: ``Is estimator variance a friend or a foe?''. In answering this question we uncovered the fairness-variance-accuracy trade-off, an enrichment of the classically understood fairness-accuracy and accuracy-robustness trade-offs. We empirically demonstrated contexts in which large estimator variance, as well as large disparity in estimator variance, can have a corrective effect on both model accuracy and fairness, but we also identified scenarios in which variance fails to help. We hope that our work will usher in a new paradigm of fairness-enhancing interventions that go beyond the classic fairness-accuracy dichotomy~\cite{chouldechova_frontiers}. For instance, there is interesting future work to be done to exploit large noise variance on protected groups with improved fairness and accuracy through this fairness-variance-accuracy trichotomy. Furthermore, our insights on the effect of estimator variance could help guide model selection in cases when several models are equally ``fair'' or equally accurate.
Our work also comes with important limitations: \citet{debiasing_bias} highlight statistical errors in the measurement of different performance metrics, and the statistical procedures used to compute estimator variance in this study also suffer from the same shortcomings. There are also interesting statistical questions around the variance of these variance estimates --- specially in social contexts where it is widely believed that noise variance tracks protected attributes~\cite{kappelhof2017,schelter2019fairprep} --- which we leave for future work.
Fairness is not a purely technical or statistical concept, but rather a normative and philosophical one. The major contributions of this work (methods, results and analysis) are purely technical, and are based on a popular technical definition of ``fairness'' as the parity in statistical bias. This is of course a limiting view, and one that should be regarded within a broader socio-legal-political view of fairness.
One of the contributions of our work is the \textsf{Virny}\xspace software library.
We envision several enhancements to our software library. Firstly, we would like to support other sampling-during-inference techniques for variance estimation beyond the simple Bootstrap, such as the Jackknife~\cite{Jackknife_review}, as well as combinations of Bootstrap and Jackknife~\cite{barber2021jackknife+,kim2020predictive_jackknife_bootstrap,Efron1992JackknifeAfterBootstrapSE}. We would also like to evaluate Conformal Prediction methods~\cite{vovk2017conformal,shafer2008conformal,angelopoulos2021conformal} for quantifying and correcting model instability. Specifically, it would be interesting to compare the insights from the variance metrics analyzed in this study with insights from the coverage and interval widths on different protected groups of conformal methods.
\section{Experiments}
\label{sec:experiments}
We used the \textsf{Virny}\xspace library, presented in Section~\ref{sec:library}, to conduct an extensive empirical comparison of the behavior of the metrics described in Section~\ref{sec:fairness}, and evaluate the trade-offs between fairness, variance and accuracy.
\subsection{Benchmarks} We used two fair-ml benchmarks for our evaluation, namely \href{https://github.com/zykls/folktables#1}{folktables} and \href{https://github.com/propublica/compas-analysis}{COMPAS}.
Folktables~\citep{DBLP:conf/nips/DingHMS21} is constructed from census data from 50 US states for the years 2014-2018. We report results on the ACSEmployment task: a binary classification task of predicting whether an individual is employed. We report our results on data from Georgia from 2018. The dataset has 16 covariates, including age, schooling, and disability status, and contains about 200k samples, which we sub-sample down to 20k samples for computational feasibility.
COMPAS~\citep{compas_propublica} is perhaps the most influential dataset in fair-ML, released for public use by ProPublica as part of their seminal report titled ``Machine Bias.'' We use the binary classification task to predict violent recidivism. Covariates include sex, age, and information on prior criminal justice involvement. We use the version of COMPAS supported by \href{https://fairlearn.org/v0.4.6/auto_examples/plot_binary_classification_COMPAS.html}{FairLearn}. \textsf{FairLearn} loads the dataset pre-split into training and test. We merge these into a single dataset and then perform different random splits. We use the full dataset with 5,278 samples.
\begin{table*}[t!]
\caption{Demographic composition of folktables and COMPAS.}
\centering
\small
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\hline
& sex$\_$race$\_$priv
& sex$\_$race$\_$dis
& sex$\_$priv
& sex$\_$dis
& race$\_$priv
& race$\_$dis \\
\hline
folktables & 0.322 & 0.177 & 0.484 & 0.516 & 0.661 & 0.339 \\
\hline
COMPAS & 0.083 & 0.491 & 0.188 & 0.812 & 0.404 & 0.596 \\
\hline
\end{tabular}
\label{tab:protected-info}
\end{table*}
We define binary groups with respect to two features, sex and race. Males are the privileged group in folktables, while females are the privileged group in COMPAS. Whites are the privileged group in both folktables and COMPAS. We also look at intersectional groups constructed from sex and race: (male, white) and (female, black) are the intersectionally privileged and disadvantaged groups in folktables respectively, while (female,white) and (male,black) are the intersectionally privileged and disadvantaged groups in COMPAS respectively. The proportion of demographic groups in folktables and COMPAS is reported in Table~\ref{tab:protected-info}.
\subsection{Model Training} In our experiments, we evaluate the performance of 6 different models, namely, Decision Tree (DT), Logistic Regression (LR), Random Forest (RF), XG-Boosted Trees (XGB), K-Neighbors classifier (kNN), and a Neural Network (historically called the Multi-layer Perceptron, or MLP). In each run, we randomly split the dataset into train-test-validation sets (80:10:10). We use the validation set to tune hyper-parameters once for each model type, for each dataset. We fit a single model on the complete train set and compute standard performance metrics (such as accuracy, TPR, FPR, TNR and FNR) both on the overall test set, and broken down by demographic groups listed in table~\ref{tab:protected-info}. Next, we use the bootstrap to construct 200 different versions of the training set (each with a size of $80\%$ of the full training set) and use this to train an ensemble of 200 predictors. We compute the variance metrics described in Section~\ref{sec:variance-metrics} on the outputs of this ensemble. We repeat this procedure for 10 different seeds on COMPAS and for 6 different seeds on folktables.
\subsection{Experimental Results}
For our analysis we will focus on four dimensions of model performance:
\begin{enumerate}
\item Overall statistical bias: an \emph{accurate} model has low statistical bias on the full test set.
\item Overall variance: a \emph{stable} model has low variance on the full test set.
\item Disparity in statistical bias: a \emph{fair} model shows parity in statistical bias on \textsf{dis}\xspace and \textsf{priv}\xspace groups.
\item Disparity in variance: a \emph{uniformly stable} model shows parity in variance on \textsf{dis}\xspace and \textsf{priv}\xspace groups.
\end{enumerate}
The overall statistical bias and variance of different models is presented in Figure \ref{fig:folk_metrics} for folktables and Figure \ref{fig:compas_metrics} for COMPAS. Standard deviation (Std), inter-quantile range (IQR), jitter, and label stability are measures of estimator variance, while accuracy, TPR, FPR, TNR, and FNR are measures of statistical bias. We report all parity-based measures in Table~\ref{tab:folk-metrics} for folktables and Table~\ref{tab:COMPAS-metrics} for COMPAS.
Cells are colored according to the following scheme: cells with values close to parity (0 for difference measures, 1 for ratio measures) are in green. Cells that report discrimination (i.e.,\xspace disparity in favor of the \textsf{priv}\xspace group) are in pink, while those that report reverse discrimination (i.e.,\xspace disparity in favor of the \textsf{dis}\xspace group) are in yellow. The positive class in folktables (positive employment status) is desirable, whereas in COMPAS (positive risk of recidivism) is undesirable, and so we flip the coloring scheme across datasets. For variance metrics, cells that show larger instability on the \textsf{priv}\xspace group than on the \textsf{dis}\xspace group are in yellow, and those with a larger instability on the \textsf{dis}\xspace group than on the \textsf{priv}\xspace group are in pink. A summary of desirable behavior on our metrics, and the corresponding color scheme, is presented in Table~\ref{tab:color-table}.
\begin{table}
\centering
\caption{Summary of desirable behavior and coloring scheme on different metrics. Pink represents discrimination, yellow represents reverse-discrimination.}
\begin{tabular}{|c|c|c|c|}
\hline
Metric name & Value & folktables & COMPAS \\
\hline
Accuracy Parity & >0 & \colorbox{yellow}{ } & \colorbox{yellow}{ } \\
Equalized Odds FPR & >0 & \colorbox{pink}{ } & \colorbox{pink}{ } \\
Statistical Parity Difference & >0 & \colorbox{yellow}{ } & \colorbox{pink}{ } \\
Disparate Impact & >1 & \colorbox{yellow}{ } & \colorbox{pink}{ } \\
IQR Parity & >0 & \colorbox{pink}{ } & \colorbox{pink}{ } \\
Jitter Parity & >0 & \colorbox{pink}{ } & \colorbox{pink}{ } \\
Std Parity & >0 & \colorbox{pink}{ } & \colorbox{pink}{ } \\
Label Stability Ratio & >1 & \colorbox{yellow}{ } & \colorbox{yellow}{ } \\
\hline
\end{tabular}
\label{tab:color-table}
\end{table}
\begin{figure*}[h!]
\centering
\includegraphics[width=\linewidth]{folk-all-metrics.png}
\caption{Statistical bias and variance metrics on folktables.}
\label{fig:folk_metrics}
\end{figure*}
\input{folk-table.tex}
\subsection{The Fairness-Variance-Accuracy Trade-off}
Overall, as expected, ensemble models (Random Forest and XGBoost) are the most stable on all metrics and all datasets. Generally, the kNN and Decision Tree classifiers score highly on variance metrics (i.e.,\xspace are the least stable). The neural network (MLP) is stable on COMPAS, but is the least stable model on folktables! This is interesting, and counter-intuitive to the general understanding of how estimator variance relates to dataset size: folktables has 20k samples, while COMPAS has only 5k samples. From a statistical bias perspective, all models perform poorly on COMPAS (no model has accuracy higher than $68\%$).
\subsubsection{Folktables}
The MLP classifier and Random Forest are the best performing models on folktables, with an accuracy of $82.16\%$ and $82.3\%$ respectively. Random Forest is also one of the most stable models (low Std, low IQR, low Jitter, and high Label Stability), while MLP is one of the least stable models (both MLP and kNN have high Std, IQR and Jitter, and low Label Stability).
From a fairness perspective, the MLP classifier and Logistic Regression perform the best. The Logistic Regression is not the best model on overall metrics, but has good parity on both statistical bias-based and variance-based metrics on folktables, as reported in Table \ref{tab:folk-metrics}. This is the first indication of a fairness-variance-accuracy trade-off: parity in variance and parity in statistical bias (``fairness'') comes at the cost of overall model accuracy.
Strikingly, the MLP is also a reasonably fair model --- it shows low Statistical Parity Difference and Disparate Impact (close to 0 and 1, respectively), despite having low overall stability and large disparity in variance-based metrics across groups. We argue that this is a feature and not a bug, and is, once again, the fairness-variance-accuracy trade-off at play: the classifier shows a larger variation in outputs on \textsf{dis}\xspace than on \textsf{priv}\xspace, and this has a corrective effect on both the overall fairness and accuracy. Here, we are trading off stability/variance to gain fairness and accuracy.
The behavior of the Random Forest classifier also illustrates this trade-off: as mentioned previously, the Random Forest has the highest accuracy of all the models. From Table~\ref{tab:folk-metrics} we see that this classifier also shows good parity on almost all variance metrics. This, however, comes with model unfairness (large disparity in statistical bias)! On metrics that relate to model error (such as accuracy parity and equalized odds) the model is ``unfair'', in the sense that it discriminates against the \textsf{dis}\xspace group. However, on metrics that track selection rates (such as statistical parity and disparate impact) the Random Forest classifier shows reverse discrimination, in the sense that it over-selects the \textsf{dis}\xspace group. Here, the model trades off fairness on the one hand for high accuracy and parity in variance on the other hand.
There is no observable consistent trend in terms of fairness or stability for the kNN and XGBoost classifiers, and perhaps their lower overall accuracy compared to other models can also be explained by a sub-optimal trade-off on the fairness-variance-accuracy spectrum.
\begin{figure*}[h!]
\centering
\includegraphics[width=\linewidth]{compas-all-metrics.png}
\caption{Statistical bias and variance metrics on COMPAS}
\label{fig:compas_metrics}
\end{figure*}
\input{compas-table.tex}
\subsubsection{COMPAS}
As described previously, none of the models in our experiments are particularly accurate on COMPAS. As expected, we also do not find these models to be particularly fair along any of the sensitive attributes, and for any fairness metrics. XGBoost is the most accurate model, and it does show parity for a handful of the bias-based metrics (Statistical Parity Difference and Disparate Impact, both along the lines of sex) and variance-based metrics (for IQR parity, Jitter parity, and Label stability ratio). For a classifier that has low overall accuracy, stability (low variance) and uniform stability (parity in variance) negates any potentially corrective effect estimator variance could have had, and results in model unfairness.
Interestingly, the Decision Tree is the most ``fair'' model on COMPAS --- it is close to having parity in accuracy across all groups and has the best parity in bias-based metrics for intersectional groups. Further, unlike the XGBoost classifier on COMPAS, the Decision Tree is far from having parity in variance, and it, in fact has higher variance on the \textsf{priv}\xspace group. Here, we see the corrective effect of estimator variance on the ``fairness'' of an inaccurate model: the Decision Tree has low accuracy --- even as compared to the other poorly performing models --- but its disparity in variance seems to improve the parity in statistical bias-based measures.
\subsection{Comparing variance metrics}
\label{sec:metrics-comparison}
\begin{figure*}[h!]
\centering
\includegraphics[width=\linewidth]{folk-scatter-models-20k.png}
\caption{folktables (20k samples): Relationship between different variance metrics. Y=X line is plotted in blue}
\label{fig:metrics-scatter-folk-20k}
\end{figure*}
\begin{figure*}[h!]
\centering
\includegraphics[width=\linewidth]{folk-scatter-models-5k.png}
\vspace{-0.75cm}
\caption{folktables (5k samples): Relationship between different variance metrics. Y=X line is plotted in blue}
\label{fig:metrics-scatter-folk-5k}
\end{figure*}
\begin{figure*}[h!]
\centering
\includegraphics[width=\linewidth]{compas-scatter-models.png}
\vspace{-0.75cm}
\caption{COMPAS (5k samples): Relationship between different variance metrics. Y=X line is plotted in blue}
\label{fig:metric-scatter-compas}
\end{figure*}
In our last set of experiments, we examined two families of complimentary variance metrics: (1) Standard deviation (Std) and Inter-Quantile Range (IQR) track the spread of the predicted probabilities, while (2) Jitter and Label Stability track how often the predicted label flips. We compare how ``good'' (i.e.,\xspace informative) these different measures of estimator variance are in Figures~\ref{fig:metrics-scatter-folk-20k} and~\ref{fig:metrics-scatter-folk-5k} for folktables, and in Figure~\ref{fig:metric-scatter-compas} for COMPAS.
The behavior of variance metrics seems to be both model-specific and-dataset specific. The MLP classifier (shown in red dots in Figure \ref{fig:metrics-scatter-folk-20k} and in green dots in Figure \ref{fig:metrics-scatter-folk-5k}) falls approximately on the $Y=X$ line (plotted in blue in both figures). This means that IQR, Jitter and Std are highly correlated, and so can be used interchangeably for this model. Extending our earlier discussion of the instability of the MLP classifier on folktables: we see high instability in both the model that was trained on 5k samples (Figure~\ref{fig:metrics-scatter-folk-20k}) and in the model that was trained on 20k samples (Figure ~\ref{fig:metrics-scatter-folk-5k}). As expected, estimator variance decreases as the sample size increases: the MLP classifier trained with 20k and 5k samples has a maximum (worst-case) IQR of approximately 0.15 and 0.20 respectively.
We see interesting trends in estimator variance on the COMPAS dataset: in Figure~\ref{fig:metric-scatter-compas}, variance metrics reported for different model types forms clusters that are almost constant along one dimension. For the same value of IQR, models have a range of values of Jitter (left-most subplot), and for the same value of Std, models have a range of values for Jitter (second plot from the left). We do not observe this behavior when considering Label Stability: the metrics of different models do form clusters, but they do not stay constant along one dimension. This suggests that, while we may be tempted to treat them interchangeably, we do need to look at them as a set, since reporting them on different benchmark datasets (such as COMPAS here) could lead to some metrics appearing to be redundant, despite being informative in a different context (such as on folktables in Figure \ref{fig:metrics-scatter-folk-20k} and \ref{fig:metrics-scatter-folk-5k}).
\section{Metrics for Model Performance}
\label{sec:fairness}
Literature on fair-ML abounds with measures of models ``fairness''. Here, we first summarize some influential fairness measures that are stated as the ratio or the difference of measures of statistical bias computed on different demographic groups in Section~\ref{sec:bias-metrics}, and go on to define a new family of variance-based measures in Section~\ref{sec:variance-metrics}.
\paragraph{Notation.} Let $Y$ be the target or true outcome, $X$ be the covariates or features, and $A$ be the set of protected/sensitive attributes. To start, we limit our treatment to binary group membership, letting $A=1$ denote the privileged group and $A=0$ denote the disadvantaged group. We are interested to construct an estimator $\hat{Y} = f(X,A)$ that predicts $Y$, with the help of a suitable loss function. In fair-ML, we apply additional constraints on the interaction between $\hat{Y}$, $Y$ and $A$ in order to ensure that the estimator $\hat{Y}$ does not discriminate on the basis of sensitive attributes $A$. Different notions of fairness are formalized as different constraints, and a violation of the fairness constraint is usually defined as the corresponding measure of model unfairness, as we will discuss next.
\subsection{Measures of Model (Un)Fairness}
\label{sec:bias-metrics}
\subsubsection{Equalized Odds}
The fairness criterion of Equalized Odds from \citet{hardt_EOP2016} is defined as:
$$ P(\hat{Y}=1|A=0,Y=y)=P(\hat{Y}=1|A=1,Y=y), y \in \{0,1\} $$
For $Y = 1$ (the positive outcome), this fairness constraint requires parity in true positive rates (TPR) across the groups $A = 0$ and $A = 1$, and for $Y = 0$ (the negative outcome), the constraint requires parity in false positive rates (FPR). A violation of this constraint (i.e.,\xspace the disparity in TPR and FPR across groups) is reported as a measure of model unfairness. In our paper, we refer to TPR and FPR as the \emph{base measures}, and we say that the fairness criterion of Equalized Odds is \emph{composed} as the difference between these base measures computed for the disadvantaged group ($A=0$, which we call \textsf{dis}\xspace) and for the privileged group ($A=1$, which we call \textsf{priv}\xspace), respectively.
$$\text{Equalized Odds Violation (True Positive)} = \Delta\text{TPR} = P(\hat{Y}=1|A=0,Y=1) -P(\hat{Y}=1|A=1,Y=1) $$
$$\text{Equalized Odds Violation (False Positive)} = \Delta\text{FPR} = P(\hat{Y}=1|A=0,Y=0)- P(\hat{Y}=1|A=1,Y=0) $$
We will now rewrite other influential fairness measures~\cite{chouldechova_impossibility, Kleinberg_impossibility} as the difference or ratio between different the base measures on the \textsf{dis}\xspace and \textsf{priv}\xspace groups. \footnote{$\Delta f = f_{dis} - f_{priv} $, $\mathcal{Q} f = f_{dis} / f_{priv} $}
\subsubsection{Disparate Impact}
Inspired by the 4/5th's rule in legal doctrines, Disparate Impact has been formulated as a fairness measure:
$$ \text{Disparate Impact} = \mathcal{Q}(\text{Positive Rate}) = \frac{P(\hat{Y}=1|A=0)}{P(\hat{Y}=1|A=1)} $$
$P(\hat{Y}=1)$ is simply the Positive Rate of the estimator, and so the measure of Disparate Impact is composed as the ratio of the Positive Rate on the \textsf{dis}\xspace and \textsf{priv}\xspace groups, respectively.
\subsubsection{Statistical Parity Difference}
Similarly, Statistical Parity is the fairness criterion that asks that comparable proportions of samples from each protected group receive the positive outcome:
$$ P(\hat{Y}=1|A=0) = P(\hat{Y}=1|A=1) $$
Statistical parity difference (SPD) is a popular fairness metric composed simply as the difference between the estimator's Positive Rate on \textsf{dis}\xspace and \textsf{priv}\xspace groups, respectively.
$$ \text{Statistical Parity Difference} = \Delta(\text{Positive Rate}) = P(\hat{Y}=1|A=0) - P(\hat{Y}=1|A=1) $$
\subsubsection{Accuracy Parity}
Accuracy parity is also commonly reported, and is computed as the difference in accuracy on \textsf{dis}\xspace and \textsf{priv}\xspace samples.
$$ \text{Accuracy Parity} = \Delta(\text{Accuracy}) = \frac{P(\hat{Y}=1|A=0,Y=1)+P(\hat{Y}=0|A=0,Y=0)}{P(\hat{Y}=1|A=0,Y=1)+P(\hat{Y}=1|A=0,Y=0)+P(\hat{Y}=0|A=0,Y=1)+P(\hat{Y}=0|A=0,Y=0)} $$
$$ - \frac{P(\hat{Y}=1|A=1,Y=1)+P(\hat{Y}=0|A=1,Y=0)}{P(\hat{Y}=1|A=1,Y=1)+P(\hat{Y}=1|A=1,Y=0)+P(\hat{Y}=0|A=1,Y=1)+P(\hat{Y}=0|A=1,Y=0)} $$
\subsection{Measures of Model (In)Stability}
\label{sec:variance-metrics}
We now introduce several variance-based metrics. We will introduce several base measures of model variance first, as this requires some reconciliation with uncertainty quantification and robustness literature, and then define the corresponding variance-based measures of model instability on different groups.
To measure the variation in model output, we will use the popular bootstrap technique~\cite{efron1994bootstrap}. This involves constructing multiple training sets by sampling with replacement from the given training set, and then
fitting estimators (with the same architecture and hyper-parameters) on these bootstrapped training sets. This allows us to construct a predictive distribution from the outputs of each trained model, instead of a single point estimate of the predicted probability. We can thereby compute different measures of variation between the predictions of the ensemble of estimators for the same data point, and use it to approximate the variance of a single model trained on the full dataset. We provide more details of our implementation of these techniques in Sections~\ref{sec:library} and~\ref{sec:experiments}.
\subsubsection{Label Stability}
Label Stability \cite{Darling2018TowardUQ} is defined as the normalized absolute difference between the number of times a sample is classified as positive or negative:
$$ \text{Label Stability} = \frac{|\sum_{i=1}^{b} \mathbbm{1}[p_{\theta_{i}}(x)==1] - \sum_{i=1}^{b} \mathbbm{1}[p_{\theta_{i}}(x)==0]|}{b} $$
where $x$ is an unseen test sample, and $p_{\theta_{i}}(x)$ is the prediction of the $i^{\text{th}}$ model in the ensemble that has $b$ estimators.
Recall that we are using the bootstrap to construct an ensemble of predictors to approximate the variance of a single estimator fit on the entire dataset. Label stability is a measure of disagreement between estimators in the ensemble: If the absolute difference is large, the label is more stable. If the difference is exactly zero, then the estimator is said to be ``highly unstable'' because a test sample is equally likely to be classified as positive or negative by the ensemble.
We define the \textbf{Label Stability Ratio} as a new parity measure. It is computed as the ratio of the average Label Stability on samples from the disadvantaged (dis) group and the privileged (priv) group respectively.
\subsubsection{Jitter}
Jitter \cite{liu2022model} is a measure of the disparities of the model's predictions for each individual test example. It reuses a notion of \emph{Churn} \cite{milani2016launch} to define a ''pairwise jitter'':
$$
J_{i, j}\left(p_\theta\right)=\operatorname{Churn}_{i, j}\left(p_\theta\right)=\frac{\left|p_{\theta i}(x) \neq p_{\theta j}(x)\right|_{x \in X}}{|X|}
$$
where $x$ is an unseen test sample, and $p_{\theta i}(x)$, $p_{\theta j}(x)$ are the predictions of the $i^{\text{th}}$ and $j^{\text{th}}$ estimator in the ensemble for $x$, respectively.
To compute the variability over all models in the ensemble, we need to average \textit{pairwise jitters} over all pairs of models. This more general definition is called \emph{Jitter}:
$$J\left(p_\theta\right)=\frac{\sum_{\forall i, j \in N} J_{i, j}\left(p_\theta\right)}{N \cdot(N-1) \cdot \frac{1}{2}} \text{, where } i<j$$
We define \textbf{Jitter Parity} as the difference of the average Jitter on samples from the \textsf{dis}\xspace and \textsf{priv}\xspace groups, respectively.
\subsubsection{Standard Deviation and Inter-Quantile Range}
The bootstrap can also be used to compute the standard deviation (Std) and the inter-quantile range (IQR) of the predicted probabilities of the ensemble, as an approximation of the spread in predictions of a single model trained on the full dataset.
We compute the standard deviation (Std) and IQR on different groups (\textsf{dis}\xspace and \textsf{priv}\xspace), and compose the group-wise difference as \textbf{Std Parity} and \textbf{IQR Parity}, respectively.
We will empirically demonstrate the usefulness of these variance-based metrics, especially where statistical-bias based measures fail to provide a complete picture of model performance, in Section \ref{sec:experiments}. We will use a software library we developed to support this empirical analysis, and describe it next.
\section{Introduction}
\label{sec:intro}
The error of an estimator can be decomposed into a (statistical) bias term, a variance term, and an irreducible noise term. When we do bias analysis, formally we are asking the question: ``how \emph{good} are the predictions?'' The role of bias in the error decomposition is clear: if we trust the labels/targets, then we would want the estimator to have as low bias as possible, in order to minimize error. Fair machine learning (fair-ML) is concerned with the question: ``Are the predictions \emph{equally good} for different demographic or socioeconomic groups?'' One way to define \emph{equally good} is to require that the statistical bias of the estimator on samples from different demographic groups should be comparable. In other words, unbiasedness is a fairness desideratum if we trust the data labels. This has naturally led to a variety of proposed fairness metrics, usually defined as the difference or the ratio of a measure of statistical bias (such as the True Positive Rate or the True Negative Rate) computed on different test subsets --- corresponding to socially privileged and socially disadvantaged groups, respectively.
A complementary statistical question concerns the variance of the estimator. When we do variance analysis, formally we are asking the question: ``How \emph{stable} are the predictions?'' The role of variance in the error decomposition is subtle: it is unclear whether low variance is always a desirable property. For example, in a biased estimator --- whose predictions deviate from the true value --- high variance can have a corrective effect on some samples.
From a philosophical perspective, randomness is morally neutral, and so the effects of large variance can be morally more acceptable (and fairness-enhancing) than the effects of a systematic skew. Randomization is, of course, already used in algorithmic fairness research~\cite{dwork_awareness}, and it is an essential building block of the differential privacy framework~\cite{DBLP:journals/cacm/Dwork11}.
In this paper, our goal is to understand the role of estimator variance from a fairness
perspective --- what behavior of estimator variance is morally desirable? The dominant belief in fair-ML is that both stability and fairness are simultaneously desirable, that is, that we want to construct estimators that have parity in statistical bias across groups (are ``fair'') and have low variance (are ``stable'')~\cite{huang2019stable, friedler2019comparative}. Our insights provide a more nuanced picture of the stability desideratum in fair-ML and uncover a novel fairness-variance-accuracy trade-off.
\paragraph{\textbf{Contributions:}}
\begin{enumerate}
\item
We propose a new family of performance measures based on group-wise parity in variance in Section~\ref{sec:fairness}, and demonstrate their usefulness on folktables~\cite{DBLP:conf/nips/DingHMS21} and COMPAS~\cite{compas_propublica} benchmarks in Section \ref{sec:experiments}.
\item We clarify the relationship between fairness and stability: If a model is fair (in the sense of exhibiting low disparity in statistical bias), then we also desire it to be stable (in the sense of exhibiting overall low variance). However, instability (high variance) does not imply unfairness (high disparity in statistical bias)! Indeed, as we show empirically in Section~\ref{sec:experiments}, there is a fairness-variance-accuracy trade-off, where:
\begin{itemize}
\item[(i)] Parity in variance and parity in statistical bias (``fairness'') can come at the cost of overall model accuracy, as we demonstrate empirically using the logistic regression model for the ACSEmployment task on the folktables benchmark~\cite{DBLP:conf/nips/DingHMS21}.
\item[(ii)] Variance can have a corrective effect on both fairness and the overall accuracy for models that have reasonably high overall accuracy. For example, we observe the MLP classifier on the ACSEmployment task on folktables and Decision Tree on COMPAS~\cite{compas_propublica} trading-off model stability to gain parity in statistical bias.
\item[(iii)] Conversely, for a classifier that has low overall accuracy, attempting to improve overall stability (low variance) and parity in stability across groups (parity in variance) negates any potentially corrective effect of estimator variance, and thereby leads to model unfairness. We observe this empirically for the XGBoost classifier on COMPAS.
\end{itemize}
\item We developed and publicly release a software library called
\textsf{Virny}\xspace\footnote{https://github.com/DataResponsibly/Virny}
that reconciles uncertainty quantification techniques with fairness analysis/auditing frameworks. Using this library, it is easy to measure stability (estimator variance) and fairness for several protected groups, and their intersections. We use this library in our own empirical analysis.
\end{enumerate}
\paragraph{\textbf{Roadmap.}} In Section~\ref{sec:fairness}, we present metrics for model performance. We first review influential fairness metrics, expressing them as ratios or differences of measures of statistical bias (Section~\ref{sec:bias-metrics}). Next, we introduce several measures of estimator variance from robustness and uncertainty quantification literature, and propose a new family of performance metrics, expressed as the difference or ratio of these variance metrics (Section \ref{sec:variance-metrics}). This reconciles statistical bias-based and variance-based analysis of parity in estimator performance on different subgroups, and provides a richer picture of algorithmic discrimination, as we empirically demonstrate in Section \ref{sec:experiments}. In Section \ref{sec:library} we introduce a new software library --- \textsf{Virny}\xspace ---to compute statistical bias and variance metrics on subgroups of interest, and to compose parity-based performance metrics from them. In Section \ref{sec:experiments}, we report our empirical findings on folktables and COMPAS benchmarks, introduce the fairness-variance-accuracy trichotomy, and give a critical comparison of our proposed variance metrics with existing metrics. We conclude and discuss avenues for exciting future work in Section~\ref{sec:discussion}.
\section{Motivation}
\label{sec:intro}
Heteroskedastic noise --- noise variance tracks protected group membership. Bias variance tradeoffs in groups. \todo{TODO: Forward reference C-IID work.}
Fairness and the need to measure fairness --- model does not perform equally good on all parts of the input space: so we define fairness metrics as ratios or differences between performance metrics computed on different test subsets --- corresponding to demographic groups. Intuitively makes sense to define as disparity. Led to some good insights \todo{(cite important work here)}, turns out different performance metrics trade off against each other.
But, reader, perhaps your statistical senses are tingling...Plotting how well the estimator performs for different groups is only one part of the story --- the bias part. In this paper we tell the variance story: we introduce a new family of 'fairness' metrics, computed as ratios and differences of several measures of variation in model outputs.
Unfortunately there are several sources of uncertainty and it is not immediately obvious how to quantify individual effects. So, we instead identify stages in the model life-cycle that can introduce uncertainty, intervene on them one stage at a time, keeping all others constant, and measure the uncertainty propagated to the model outputs.
We also compute standard fairness metrics under each intervention, and this reconciles bias-based and variance-based measures of fairness, and provides a more rich picture of algorithmic discrimination.
\textbf{Contributions:}
\begin{enumerate}
\item Introduce a new family of variance-based fairness measures. Demonstrated how this complements bias-based fairness measures in the literature through experiments on benchmark datasets.
\item We also make a significant contribution to literature that aims to study the fairness of ML models through a lifecycle-view. To the best our knowledge, ours is the first systematic empirical study to quantify uncertainty at different stages of the model lifecycle.
\end{enumerate}
\section{The \textsf{Virny}\xspace software library}
\label{sec:library}
In order to reconcile the reporting of statistical bias-based and variance-based performance measures discussed in Section \ref{sec:fairness}, we developed \textsf{Virny}\xspace\footnote{\emph{\textsf{Virny}\xspace} is a Ukranian word meaning faithful, true or reliable. $\#$ScienceForUkraine} --- a Python library for auditing model stability and fairness. The \textsf{Virny}\xspace library was developed based on three fundamental principles: 1) easy extensibility of model analysis capabilities; 2) compatibility to user-defined/custom datasets and model types; 3) simple composition of parity metrics based on context of use.
\textsf{Virny}\xspace decouples model auditing into several stages, including: subgroup metrics computation, group metrics composition, and metrics visualization and reporting. This gives data scientists and practitioners more control and flexibility to use the library for both model development and monitoring post-deployment.
\subsection{Comparison with existing fairness libraries}
Many toolkits dedicated to measuring bias and fairness have been released in the past couple of years. The majority of these toolkits are easily extensible, can measure a list of fairness metrics, and create detailed reports and visualizations. For example, \textsf{AI Fairness 360}~\cite{bellamy2018ai} is an extensible Python toolkit for fairness researchers and industry practitioners that can detect, explain, and mitigate unwanted algorithmic bias. \textsf{Aequitas}~\cite{saleiro2018aequitas} is another fairness auditing toolbox for both data scientists and policymakers. It concentrates on detailed explanations of how it should be used in a public policy context, including a ``Fairness Tree'' that guides the user to select suitable fairness metrics for their decision-making context.
\textsf{FairLearn}~\cite{bird2020fairlearn} provides an interactive visualization dashboard and implements unfairness mitigation algorithms. These components help with navigating trade-offs between fairness and model performance.
Similarly, \textsf{LiFT}~\cite{vasudevan2020lift} can measure a set of fairness metrics, but additionally, it focuses on scalable metric computation for large ML systems. Authors have shown how bias measurement and mitigation tools can be integrated with production ML systems and, at the same time, how to enable monitoring and mitigation at each stage of the ML lifecycle. Finally, \textsf{fairlib}~\cite{han2022fairlib} implements a broad range of bias mitigation approaches and supports the analysis of neural networks for complex computer vision and natural language processing tasks. In addition, the analysis module of \textsf{fairlib} provides an interactive model comparison to explore the effects of different mitigation approaches.
\textsf{Virny}\xspace distinguishes itself from the existing libraries in three key aspects. First, our software library instantiates our conceptual contribution, allowing the data scientist to understand the role of estimator variance in assessing model fairness.
\textsf{Virny}\xspace supports the measurement of both statistical bias and variance metrics for a set of initialized models, both overall on the full test set and broken down by user-defined subgroups of interest.
Second, \textsf{Virny}\xspace provides several APIs for metrics computation, including an interface for the analysis of a set of initialized models based on multiple executions and random seeds. This interface enables a detailed model audit, and supports reliable and reproducible analysis of model performance.
Third, our library allows data scientists to specify multiple sensitive attributes, as well as their intersections, for analysis. For example, \textsf{Virny}\xspace can audit statistical bias and variance with respect to all of the following simultaneously: \textsf{sex}, \textsf{race}, \textsf{age}, \textsf{sex\&race}, and \textsf{race\&age}.
We also support the definition of non-binary sensitive attributes (although we limit our experimental evaluation in Section~\ref{sec:experiments} to binary groups). We hope that this flexibility in selecting datasets, models, metrics and subgroups of interest will help usher in an era of research where measuring and reporting a variety of metrics of model performance on different subgroups is the norm, and not a specialized research interest of the few.
\subsection{Architecture}
\begin{figure*}[h!]
\centering
\includegraphics[width=\linewidth]{library-architecture.png}
\vspace{-0.75cm}
\caption{\textsf{Virny}\xspace Architecture}
\label{fig:library_diagram}
\end{figure*}
Figure \ref{fig:library_diagram} shows how \textsf{Virny}\xspace constructs a pipeline for model analysis. Pipeline stages are shown in blue, and the output of each stage is shown in purple.
Each analysis pipeline has three processing stages: subgroup metrics computation, group metrics composition, and metrics visualization and reporting. We will now describe each of them.
\subsubsection{Inputs}
To use \textsf{Virny}\xspace, the user needs to provide three inputs, namely:
\begin{itemize}
\item A \textsf{dataset class} is a for the user's dataset that includes its descriptive attributes such a target column, numerical columns, categorical columns, etc\xspace. This class must be inherited from the $BaseDataset$ class, which was created for user convenience. The idea behind having a common base class is to standardize raw dataset pre-processing and feature creation and to simplify the logic for downstream metric computation.
\item A \textsf{config Yaml} is a file that specifies the configuration parameters for \textsf{Virny}\xspace's user interfaces for metrics computation. We adopt this user-specified configuration approach to allow more flexibility to users. For instance, users can easily shift from one experiment to another, having just one config yaml per experiment, without having to make any further modifications before using \textsf{Virny}\xspace's user interfaces.
The config file contains information such as the number of bootstrap samples to create (this is the number of estimators in our ensemble for variance analysis), the fraction of samples in each bootstrap sample, a list of random seeds, etc\xspace. Importantly, we ask the user to specify subgroups of interest in the dataset by simply passing a dictionary where key-value pairs specify the relevant column names and the values of the sensitive attribute of the groups of interest. Users can also specify intersectional groups here.
\item Finally, a \textsf{models config} is a Python dictionary, where keys are model names and values are initialized models for analysis. This dictionary helps conduct audits of multiple models for one or multiple runs and analyze different types of models.
\end{itemize}
\subsubsection{Subgroup metric computation} After the variables are input to a user interface, \textsf{Virny}\xspace creates a \textsf{generic pipeline} based on the input dataset class to hide pre-processing complexity (such as one-hot encoding categorical columns, scaling numerical columns, etc\xspace) and provide methods for subsequent model analysis. Later, this generic pipeline is used in subgroup analyzers to compute different sets of metrics. Our library implements a \textsf{Subgroup Variance Analyzer} and a \textsf{Subgroup Statistical Bias Analyzer}, and it is easily extensible to include other analyzers. We provide abstract analyzer classes for users to inherit from and to create custom analyzers. Once these analyzers finish computing metrics, their outputs are combined and returned as a \textsf{pandas} dataframe.
The \textsf{Subgroup Variance Analyzer} is responsible for computing our variance metrics (from Section \ref{sec:variance-metrics}) on the overall test set, as well as on subgroups of interest specified by the user. We use a simple bootstrapping approach~\cite{efron1994bootstrap} to quantify estimator variance, as is common in uncertainty quantification literature~\cite{Darling2018TowardUQ,liu2022jitter,debiasing_bias}. However, instead of simply computing the standard deviation of the predictive distribution, we also compute additional metrics such as label stability, jitter and IQR (defined in Section \ref{sec:variance-metrics}).
Similarly, the \textsf{Subgroup Statistical Bias Analyzer} computes statistical bias metrics (such as accuracy, TPR, FPR, TNR, and FNR) on the overall test set as well as for subgroups of interest.
\subsubsection{Group metric composition} The \textsf{Metrics Composer} is responsible for the second stage of the model audit. Currently, it computes the statistical bias-based and variance-based parity metrics described in Section \ref{sec:fairness}, but a user can compose additional metrics if desired. For example, the fairness measure of Disparate Impact is composed as the ratio of the Positive Rate computed on the \textsf{priv}\xspace and \textsf{dis}\xspace subgroups.
\subsubsection{Metric visualization and reporting} The \textsf{Metrics Visualizer}
unifies different processing steps on the composed metrics and creates various data formats to ease visualization. Users can use methods of this class to create custom plots for analysis. Additionally, these plots can be collected in an HTML report with comments for reporting.
\subsection{User Interfaces}
For the first library release, we have developed the following three user interfaces:
\subsubsection{Single run, single model} This interface gives the ability to audit one model for one execution. Users can set a model seed or generate and record a random seed, and control the number of estimators for bootstrap, the fraction of samples used in each bootstrap sample, and the test set fraction. This interface returns a \textsf{pandas} dataframe of statistical bias and variance metrics for an input base model and stores results separately in a file.
\subsubsection{Single run, multiple models} This interface extends the functionality of the previous interface to audit multiple models. It can be more convenient and speed up the computation of multiple metrics for all models.
\subsubsection{Multiple runs, multiple models} This interface can be used for a more extensive model audit. Users specify a set of models to use and the seeds for each run. This interface then computes metrics for all specified models and seeds, and saves the results after each run. In addition to metrics, this interface stores the seeds used for each run, which can help maintain consistent and reproducible results, such as those reported in Section~\ref{sec:experiments}.
\section{Quantifying Uncertainty in the Model Lifecycle}
\label{sec:lifecycle}
\todo{New experiments: model selection and data generating process, on one folktables task on one state}
We quantify the uncertainty/variance in model outputs with respect to the following dimensions. Our list of interventions are mapped onto different stages of the data science life-cycle, shown in Figure \ref{fig:lifecycle}
\subsection{Hypothesis Space}
\label{sec:hypothesis}
Different model architectures encode different inductive biases, and so one source of uncertainty, which could result in instability in model outputs downstream, is the hypothesis class over which we are running our optimization.
\subsection{Parameter Space}
\label{sec:parameter}
The settings of several hyper parameters in predictive model determine how stable the model outputs will be --- based on choice we make in the parameter space we might end up at a minimum in a flat valley in the loss surface, and parameterize a stable model, whose performance generalizes reasonably well to unseen samples, or the local minimum we pick might be extremely sharp, and the corresponding model could produce large deviations in outputs for small perturbations in the input space.
\subsection{Data Processing}
\label{sec:preprocessing}
Raw data is necessarily pre-processed and cleaned before being fed into data-driven models. The choice of data engineering technique is another source of uncertainty, because it involves a strategic manipulation of the dataset, which modifies it statistical properties. For example, standardization or max-min scaling is a common technique to reduce the variance in a dataset.
\subsection{Data Collection}
\label{sec:collection}
The quality of an estimator depends acutely on the quality and size of the dataset that it was estimated from. We supplement our analysis of the impact of data errors (see point above), with an analysis of dataset size --- a model simply could not have seen enough data to make stable predictions, ie to find good, stable minima, and so dataset size is an important facet along which to study model instability.
\subsection{Data Generating Process}
\label{sec:generation}
In practice, we will not be able to confidently assert that the data we built our model from, and the data that we will apply our model to get predictions for, comes from the same distribution. If any part of the data generating process changes (more weakly, if we suddenly start accessing/sampling from a different, previously unseen part of the data space) then the guarantees that we have for model performance no longer hold. We will study bais-variance trade-offs in the simple setting of test-data coming from a distribution that is different from the one sampled our training set from
\subsection{Learning Paradigm}
\label{sec:paradigm}
We take a second, more detailed look at the effect of data uncertainty on model stability by intervening on the learning paradigm -- whether the model sees all the data at once (batch), or is trained iteratively (incremental/online).
\begin{figure}
\includegraphics[width=\textwidth]{stability_lifecycle.png}
\caption{Stages in the model lifecycle at which we study stability. The numbers in circles map to different interventions, described in Section \ref{sec:lifecycle}.}
\centering
\Description{Stages in the model lifecycle at which we will measure stability}
\label{fig:lifecycle}
\end{figure}
\section{Uncertainty Quantification Techniques}
\label{sec:methods}
\subsection{Sampling During Inference \todo{TODO: Diagrams? + How to construct confidence intervals}}
\label{sec:sampling-during-inference}
The basic idea of these UQ techniques is to generate samples at inference time (hence the name), and use the sample variance of simulated values to approximate the true variance of the estimator (by the law of large numbers) \cite{wasserman2004all}.
We will now discuss dominant approaches to constructing these samples during inference, contrasting their statistical properties/guarantees and computational complexities.
\subsubsection{\textbf{The Bootstrap}}
\label{sec:bootstrap}
The bootstrap ~\citep{efron1994bootstrap} is a widely used and understood statistical procedure so we will not spend time explaining it here. Instead, we will describe how the Bootstrap can be used at inference time to get uncertainty estimates, along with the standard predicted probabilities: By construction, any ensemble model implicitly fits several copies of the same model (with the same base architecture). Ensembles constructed from bootstraps of the same training set come with implicit uncertainty estimates --- we make a prediction based on the ensemble mean, but we could also look at the ensemble variance. In this way, the predictive variance of the bootstrap outputs approximates the variance in predictions as if a single model was being used to make a prediction. Indeed the reduction in variance that we gain from ensembling can be interpreted as an estimate of the worst-case variance of a single model.
\subsubsection{\textbf{The Jackknife}}
\label{sec:jackknife}
The jackknife~\citep{Jackknife_review} is the intellectual predecessor to the sampling technique of leave-one-out cross-validation. Similarly to how we used the Bootstrap to construct estimates of predictive variance (and related measures) we can construct samples during inference from the base training set by leaving one (k in general) sample out each time. So, the Jackkife constructs subsampled dataset by iteraticely leaving one sample of the training set (hence the name leave-one-out). If there are n samples, the Jackknife constructs n permuted training sets, each of which differ exactly in one sample (added in one sample, omitted in the other). Hence, a common realistic scenario under which the Jackknife is preferable to the Bootstrap is when the number of samples is critically low: recall that the Bootstrap constructs variations of the base train set by sampling with replacement. If we do not have enough samples to be able to construct unique subsets through the Bootstrap, we might instead prefer to construct samples using the Jackknife: this is very computationally optimal when the train set size is sufficiently small. In other words, the Bootstrap is a more computationally feasible alternative to the Jackknife when the sample size is prohibitively high.
\subsubsection{\textbf{Jackknife+}}
\label{sec:jaccknife-plus}
~\cite{barber2021jackknife+} showed that the Jackknife fails to provide an assumption-free guarantee. The key observation they make is that the test residual computed on a held-out test set is not comparable with the leave-one-out residuals computed on the Jackknife. This is because the former sees one more observation in training than the latter sees (the single observation that is left out while constructing the subsets using the Jackknife. Instead the Jackknife+ makes a slight modification: it uses the ensemble constructed from models trained on the leave-one-out training for inference directly. The residuals on the held-out test set can therefore be used to construct confidence intervals for the ensemble with a guarantee of distribution-free predictive coverage at level 1-{$2\alpha$}. We point the reader to the original Jackknife+ paper~\cite{barber2021jackknife+} for the technical proofs.
\subsubsection{\textbf{Jackknife+-after-Bootstrap}}
\label{sec:jackknife-bootstrap}
There are several variants that combine ideas from the Jackknife and the Bootstrap. Here we highlight perhaps the most influential variant: the Jackknife+-after-bootstrap~\citep{kim2020predictive_jackknife_bootstrap}. The authors make a very neat observation that allows them to use "out-of-bag" estimates to improve on the computational complexity of sampling-during-inference techniques, namely that it is possible to obtain the i-th leave-one-out residual without having to recompute residuals from the base model by reusing the residuals computed from each training set. We can simply aggregate the residuals from models that did not see the i-th data point and directly compute the residual!
\subsection{Conformal Prediction}
\label{sec: conformal}
To motivate conformal prediction let us think about a scenario in which we are working with large-scale dataset or one where model evaluation is expensive: As the sample size increases, both the bootstrap and the jackknife become increasingly computationally expensive --- prohibitively so. In such a situation it would be more feasible to instead create a second hold-out set --- called the 'calibration set' --- on which to construct our confidence intervals from. This a very different procedure than sampling-during-inference techniques. Here, we train a single model --- we do not create multiple copies of the base model, train them on slightly different training sets and then construct predictive distributions. Instead, we train one model, apply it on the calibration set, compute residuals (or any suitable non-conformity score) and use it to construct confidence intervals for unseen samples. Alternatively, we could construct prediction sets for each unseen sample (with uncertainty built into the selection), instead of constructing confidence intervals around point estimates. In this manner conformal prediction can be thought of as a transformation from an uncertainty heuristic (computed on the labelled samples) into an uncertainty guarantee (for held-out samples).
The basic algorithm for conformal prediction (with coverage 1-$\alpha$) is as follows:
\begin{enumerate}
\item Fit your estimator. This is the model whose uncertainty you want to quantify and calibrate to satisfy the desired coverage.
\item Define a score function. Intuitively this is a measure of non-conformity, and larger scores indicate larger disagreement between inputs.
\item Compute the non-conformity between the true label and the predicted values from the estimator for all the samples in the calibration set. From this compute the (1-$\alpha$) quantile of these calibration score (let us call it $qˆ$).
\item Use this quantile to form the prediction sets for new examples as:
$$ C(X_{test}) = \{y : s(X_{test},y) \leq qˆ\}. $$
\end{enumerate}
Conformal prediction is an increasingly popular area of research in machine learning. For a more complete treatment of this technique we point the reader to the excellent primer on Conformal Prediction from \cite{angelopoulos2021conformal} and to seminal works from ~\cite{shafer2008conformal, vovk2017conformal, shafer2008conformal, vovk_cross-conformal}.
\todo{TODO: Comparison of methods table}
\section{Model Stability/Robustness Metrics}
\label{sec:metrics}
The Jackknife and Bootstrap (and their many variants) are all ways to construct a predictive distribution on a held-out set, instead of single point estimates. There are several things we can do with this distribution, we group them broadly into supervised and unsupervised methods. Supervised methods use the true labels to compute residuals and construct confidence intervals for unseen test samples, as discussed in Section \ref{sec:methods}.
Now, we discuss unsupervised approaches which instead focus on the statistical properties of the predictive distribution. In this way, sampling during inference UQ techniques have a natural connection to metrics of model stability from stability/ adversarial robustness literature. Popular statistical measures of variation include, but are not limited to: \todo{TODO: set up single notation for all equations + diagram showing connection between methods?}
\begin{enumerate}
\item \textbf{Label Stability:} Normalized absolute difference between the number of times a sample is classified as positive or negative. Value of 1 means perfect stability. Value of 0 means extremely bad model stability, because it indicates that ensemble members disagree greatly on the predicted labels.
\item \textbf{Jitter:} TODO
\item \textbf{Sample Variance:} The spread of the predictive distribution is a natural measure of model (in)stability.
\item \textbf{Sample Inter Quantile Range:} This is another natural statistical measure of the spread of predictions by the ensemble.
\item \textbf{Predictive Entropy:} (?)
\end{enumerate}
\section{Notation}
\label{sec:notation}
Before proceeding let us fix some notation. \todo{TODO}
\section{Quantifying Uncertainty in the Model Lifecycle}
\label{sec:setup}
\begin{figure}
\includegraphics[width=\textwidth]{stability_lifecycle.png}
\caption{Stages in the model lifecycle at which we study stability. The numbers in circles map to different interventions, described in Section \ref{sec:setup}.}
\centering
\Description{Stages in the model lifecycle at which we will measure stability}
\label{fig:lifecycle}
\end{figure}
\subsection{Interventions}
We quantify the uncertainty/variance in model outputs with respect to the following dimensions. Our list of interventions are mapped onto different stages of the data science life-cycle, shown in Figure \ref{fig:lifecycle}
\begin{enumerate}
\item \textbf{Hypothesis Space:} Different model architectures encode different inductive biases, and so one source of uncertainty, which could result in instability in model outputs downstream, is the hypothesis class over which we are running our optimization.
\todo{Bias-variance plots (broken down by groups) for different models: linear models, tree-based models, ensembles, knn, linear NNs, SVM(?). Also plot training dynamics for each model: train loss, test loss, label stability on the test set, as a function of train epochs}
\item \textbf{Parameter Space:} The settings of several hyper parameters in predictive model determine how stable the model outputs will be --- based on choice we make in the parameter space we might end up at a minimum in a flat valley in the loss surface, and parameterize a stable model, whose performance generalizes reasonably well to unseen samples, or the local minimum we pick might be extremely sharp, and the corresponding model could produce large deviations in outputs for small perturbations in the input space.
\todo{Pick one (best) model from each hypothesis class, train it in three regimes: underfitting, overfitting and tuned. Plot bias vs fairness for different subgroups.}
\item \textbf{Data Processing:} Raw data is necessarily pre-processed and cleaned before being fed into data-driven models. The choice of data engineering technique is another source of uncertainty, because it involves a strategic manipulation of the dataset, which modifies it statistical properties. For example, standardization or max-min scaling is a common technique to reduce the variance in a dataset.
\todo{We will limit our analysis to the impact of synthetically generated data errors, so that we have access to the ground truth. For this we will: simulate nulls (percentage), add noise to produce outliers (frac of noise/weight of noise) and randomly flip labels in the train set (frac of labels flipped -- can be strategic wrt groups). Create bias-variance plots comparing different procedures for each error type. Also plot bias and variance metrics for different values of the noise hyperparameters (written in brackets above) }
\item \textbf{Data Collection:} The quality of an estimator depends acutely on the quality and size of the dataset that it was estimated from. We supplement our analysis of the impact of data errors (see point above), with an analysis of dataset size --- a model simply could not have seen enough data to make stable predictions, ie to find good, stable minima, and so dataset size is an important facet along which to study model instability.
\todo{Subsample the dataset and report trends for bias and variance metrics}
\item \textbf{Data Generating Process:} In practice, we will not be able to confidently assert that the data we built our model from, and the data that we will apply our model to get predictions for, comes from the same distribution. If any part of the data generating process changes (more weakly, if we suddenly start accessing/sampling from a different, previously unseen part of the data space) then the guarantees that we have for model performance no longer hold. We will study bais-variance trade-offs in the simple setting of test-data coming from a distribution that is different from the one sampled our training set from
\todo{Only do for folktables: train on (S1, Y1), sample test data points from (S2, Y1), (S1, Y2) and (S2,Y2) and report bias-variance plots for each. Can we capture a notion of shift? KL between datasets?}
\item{ \textbf{Learning Paradigm:} We take a second, more detailed look at the effect of data uncertainty on model stability by intervening on the learning paradigm -- whether the model sees all the data at once (batch), or is trained iteratively (incremental/online).}
\todo{Compare incremental vs batch versions of the same algorithm, ie. hold the hypothesis space fixed, and report bias-variance plots. }
\end{enumerate}
| {'timestamp': '2023-02-10T02:09:16', 'yymm': '2302', 'arxiv_id': '2302.04525', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04525'} | arxiv |
\section{Introduction}
Parameters in mathematical models in science and engineering are often not fully known and have to be {estimated from observed data}. Accurate reconstruction of the parameters, as well as an estimate of the uncertainty in the reconstruction, are crucial for reliable predictions and risk assessments. The recent explosion of available data, driven by the increase in large-scale scientific experiments and the development of sensor technology, means that there is a pressing need to develop new algorithms for the seamless integration of observed data with sophisticated mathematical models.
The complexity of models involved in modern applications, such as those based on partial differential equations, result in a {huge computational cost} and render many methods for solving inverse problems practically infeasible. A widespread solution to this problem is to approximate the model by a computationally cheaper surrogate model to obtain an approximate likelihood that is much faster to {compute, feasible to use for simulations in practice and ideally is accurate where it needs to be accurate for solution of the parameter learning problem of interest} \cite{kennedy2001bayesian,mnr07,bwg08,mx09,cfo11,st18}.
This paper discusses the use of surrogate models in the Bayesian approach to inverse problems, in which we find the {\em posterior} distribution of the unknown parameters conditioned on the observed data. A particular focus is on random surrogate models and Gaussian process regression. We provide new results that show that the context of the surrogate model, i.e. the Bayesian posterior distribution, should be taken into account when designing the surrogate model, by choosing training points in the area of parameter space where the posterior places significant mass. This poses a somewhat circular problem, since the reason we are using Gaussian process regression is to be able to compute the posterior. However, various computational approaches have been suggested to circumvent this problem in practice, including a sequential design strategy that only requires access to the approximate posterior \cite{sn17}, and the updating of training points while exploring the posterior with sampling methods such as Markov chain Monte Carlo \cite{dunbar2021calibration,cleary2021calibrate}.
The structure of the remainder of the paper is the following. In section \ref{sec:inv}, we introduce Bayesian posterior distributions in inverse problems, discuss computational approximations using surrogate models, and prove new error bounds between the true and approximate posterior distributions in a norm weighted by the posterior. The main novel results are Theorems \ref{thm:mean_posterior} and \ref{thm:marginal_posterior}. In section \ref{sec:gp}, we introduce Gaussian process regression as surrogate models, and prove new results on the accuracy of Gaussian process regression and suitable choices of training points in the context of inverse problems. The main new results are Corollary \ref{cor:post_conv_gp_phi}, Corollary \ref{cor:post_conv_gp_G} and Theorem \ref{thm:gp_conv_weighted}. Section \ref{sec:num} gives some simple numerical examples illustrating the theoretical findings.
\section{Bayesian Inverse Problems and Their Approximation}\label{sec:inv}
{In this section, we set up the Bayesian inverse problem and describe its approximation using random surrogate models. In subsection \ref{ssec:BIP} we introduce
the framework for Bayesian inversion, and discuss MCMC methods for them.
Subsection \ref{ssec:exbip} contains two large-scale examples that motivate
the need for surrogate modeling. In subsection \ref{ssec:inv_surrogate} we
explain surrogate modeling in detail leading, in subsection \ref{ssec:justify},
to error estimates summarizing the effect of errors in the surrogate model on
the solution of the Bayesian inverse problem.}
\subsection{Bayesian Inverse Problems}
\label{ssec:BIP}
We are interested in solving the inverse problem of determining an unknown parameter $u \in U$ from noisy, indirect data $y \in \mathbb{R}^{d_y}$ given by
\begin{equation}
\label{eq:naa}
y = \mathcal G(u) + \eta,
\end{equation}
for some observation operator $\mathcal G : U \rightarrow \mathbb{R}^{d_y}$. For ease of presentation we assume the noise $\eta$ is a realization of the $\mathbb R^{d_y}$-valued Gaussian random variable $\mathcal N(0,\Gamma)$, for a known positive definite covariance matrix $\Gamma$, but other distributions on $\eta$ can be dealt with similarly \cite{lst18}.
{We adopt a Bayesian statistical perspective, in which the pair $(u,y)$ is treated as a random variable ($u$ in finite dimensions) or a random process ($u$ in infinite dimensions).} The aim is to find the distribution of the conditional random variable $u|y$. This approach leads to a well-posed problem in the sense of Hadamard: there exists a unique conditional distribution $u|y$ that depends continuously on $y$ \cite{stuart10, latz20}.
In the absence of data, we assume $u$ is distributed according to a prior measure $\mu_0$. {Equation \eqref{eq:naa} then defines the conditional distribution of $y|u$, assuming that $\eta$ is independent of $u.$ Suitable choices of prior measure will depend on the application. We are then interested in the posterior distribution $\mu^y$ on the conditioned random variable $u | y$, which can be characterized as follows through Bayes' Theorem. This delivers the
the Radon-Nikodym derivative of the posterior
with respect to the prior distribution (see e.g. \cite{stuart10}).}
\begin{proposition} \label{prop:bayes} Suppose $U$ is a separable Banach space, $\mathcal G : U \rightarrow \mathbb{R}^{d_y}$ is continuous and $\mu_0(U) = 1$. Then the posterior distribution $\mu^y$ on the conditioned random variable $u | y$ is absolutely continuous with respect to $\mu_0$ and given by Bayes' Theorem:
\begin{equation*
\frac{d\mu^y}{d\mu_0}(u) = \frac{1}{Z} \exp\big(-\Phi(u)\big),
\end{equation*}
where
\begin{align*
\Phi(u) = \frac{1}{2} \left\| y - \mathcal G (u) \right\|_{{\Gamma}}^2, \qquad
\text{and } \qquad
Z = \mathbb{E}_{\mu_0}\Big(\exp\big(-\Phi(u)\big)\Big).
\end{align*}
\end{proposition}
In the preceding we adopt the notational convention
{$\|\cdot \|_{A}=\|A^{-\frac12}\cdot\|_2$}
as in \cite{stuart10}, where $\|\cdot\|_2$ is the Euclidean norm and $A$ is any symmetric positive matrix.
In a finite-dimensional setting, where $u \in U \subseteq \mathbb{R}^{d_u}$ and we are inferring a finite number of unknown parameters, Bayes' Theorem can be written in terms of the probability density function (pdf) of the prior and posterior, denoted by $\pi_0$ and $\pi^y$, respectively \cite{kaipio2005statistical}. This takes the form
\[
\pi^y (u) = \frac{1}{Z} \exp\big(-\Phi(u)\big) \pi_0(u),
\]
with $\Phi$ and $Z$ as defined in Proposition \ref{prop:bayes}.
The term $\exp\big(-\Phi(u)\big)$ is referred to as the {\em data likelihood}, and comes from the distribution of $y|u$. In other words, it characterizes how likely it is to observe the data $y$ given a particular choice of the parameter $u$. Since $y = \mathcal G(u) + \eta$ and $\eta \sim \mathrm{N}(0,\Gamma)$, we have $y|u \sim \mathrm N(\mathcal G(u),\Gamma)$, and the pdf of $y|u$ is hence proportional to $\exp\big(-\Phi(u)\big)$. The normalization constant $Z$ ensures that the posterior $\mu^y$ is a probability distribution, with $\mu^y(U)=1$. By Bayes' Theorem, $Z = Z(y)$ is the marginal pdf of the data $y$, and hence characterizes how likely it is to observe the data $y$ given the observational model $\mathcal G$. $Z$ is therefore often referred to as the {\em model evidence}. The analytical value of $Z$ is usually not known, and computing $Z$ numerically is notoriously difficult (see e.g. \cite{zja16}).
In applications, the goal is usually to compute a quantity of interest related to the posterior distribution $\mu^y$. This could for example be an expected value $\mathbb{E}_{\mu^y}[g(u)]$, where $g : U \rightarrow U$ is chosen as the identity for the conditional mean $\mathbb{E}[u|y] = \mathbb{E}_{\mu^y}[u]$ or $g: U \rightarrow \{0,1\}$ is chosen as the indicator function $\mathrm{I}_{ u \in A}$ for computing event probabilities $\mathbb{P}[u|y \in A] = \mathbb{E}_{\mu^y}[\mathrm{I}_{ u \in A}]$.
The method of choice for sampling from the posterior distribution, enabling the computation of expected values and other quantities of interest, is often Markov chain Monte Carlo (MCMC) \cite{hastings70,mrrtt53,robert_casella,conrad2016accelerating,gc11,crsw13}. A prototypical example is the Metropolis-Hastings algorithm, which consists of the following steps for sampling from a target density $\pi$ on a finite-dimensional parameter space $U \subseteq \mathbb{R}^{d_u}$:
\begin{itemize}
\item[1.] Choose $u^{(1)}$ with $\pi(u^{(1)}) > 0$.
\item[2.] At state $u^{(i)}$, sample a proposal $u'$ from
density $q(u' \, | \, u^{(i)})$.
\item[3.] Accept sample $u'$ with probability \vspace{-1ex}
\[
\alpha(u' \, | \, u^{(i)}) = \displaystyle \min \bigg( 1,
\frac{\pi(u') \, q(u^{(i)} \, | \, u')}{\pi(u^{(i)}) \, q(u' \, | \, u^{(i)})}\bigg),
\] \\ \vspace{-1.5ex}
i.e. $u^{(i+1)}=u'$ with probability
$\alpha(u' \, | \, u^{(i)})$; otherwise stay at $u^{(i+1)}=u^{(i)}$.
\end{itemize}
Steps 2 and 3 are repeated until the required number of samples have been generated. In the context of inverse problems and Bayesian posterior distributions, we note in particular that knowledge of the normalization constant of the target density $\pi$ is not required, since this cancels in the ratio in $\alpha$. The crucial ingredient in the algorithm is the {\em proposal density} $q$ in step 2, and a wide range of options exists, from simple random walks to methods using (higher-order) derivatives of the target and the geometry of the parameter space (see e.g. \cite{robert_casella,crsw13,gc11}). There is a rich theory underpinning the Metropolis-Hastings algorithm, and in particular, it is guaranteed under mild assumptions that the distribution of $u^{(i)}$ converges to the target density $\pi$ as $i \rightarrow \infty$ (see e.g. \cite{robert_casella}).
MCMC methods typically require repeated evaluation of the data likelihood. In the Metropolis-Hastings algorithm above; this can be seen in step 3, where $\exp\big( - \Phi(u') \big)$ needs to be computed for every proposal $u'$. This quickly becomes infeasible in modern applications where the computation of the likelihood is very costly. This includes for example inverse problems in geophysics (subsurface flow model) and climate (general circulation model), where $\mathcal G$ involves the solution of one or more coupled partial differential equations (PDEs). Two such examples are given
in the next subsection.
\subsection{Examples of Large-Scale Complex Bayesian Inverse Problems}
\label{ssec:exbip}
\begin{example} {\em Subsurface Flow Model} {A simple model for stationary subsurface fluid flow is given by
\begin{equation} \label{eq:pde}
- \nabla \cdot \left( k(x) \nabla p(x) \right) = g(x), \qquad x \in D,
\end{equation}
where $k$ represents the permeability (or hydraulic conductivity) of the subsurface, $p$ denotes the pressure head of the fluid, $g$ incorporates any sources or sinks, and suitable boundary conditions are imposed on the computational domain $D$ \cite{zhang,rubin}. This model comes from a combination of Darcy's law for single-phase fluid flow in a porous medium, $q(x) = - k(x) \nabla p(x)$, and conservation of mass, $ \nabla \cdot q = g$.
A typical inverse problem in this context is to reconstruct the permeability $k$ given noisy measurements of the pressure head $y = \{ p(x_i) + \eta_i\}_{i=1}^{d_y}$ or the Darcy flux $y = \{ k(x_i) \nabla p(x_i) + \eta_i\}_{i=1}^{d_y}$ at fixed locations $x_i \in D$. Although we in general wish to reconstruct the function $k \in L^2(D)$, we often choose a parametrization of $k$ in computations. The inverse problem then becomes that
of learning the coefficients $u \in \mathbb{R}^{d_u}$ in the parametrization. For example, we can choose a piecewise constant model
\[
k(x; u) = \sum_{j=1}^{d_u} {u_j} \mathrm{I}_{x \in D_j}(x),
\]
where $D_j$ is a partitioning of the domain $D$ representing layers of different types of rock, and $u_j$ is the value of the permeability $k$ in the layer $D_j$. Since the permeability is always positive, and can vary over orders of magnitude between different types of rock, the prior distribution $\mu_0$ on $u =\{u_j\}_{j=1}^{d_u}$ should reflect these properties, and log-normal distributions are often used.
Evaluation of the parameter-to-observation map $\mathcal G : \mathbb{R}^{d_u}_{> 0} \rightarrow \mathbb{R}^{d_y}$, defined by $\mathcal G(u) = \{ p(x_i; u) \}_{i=1}^{d_y}$ or $\mathcal G(u) = \{ k(x_i; u) \nabla p(x_i; u) \}_{i=1}^{d_y}$, requires the solution of the PDE \eqref{eq:pde} with a different coefficient $k$ for every $u$ and is thus typically very costly.
}
\end{example}
\begin{example} {\em General Circulation Model}
General Circulation Models (GCMs) typically comprise discretization of a system of three space-dimensional time-dependent PDEs, with
spatial dimensions representing Earth's longitude, latitude and vertical dimensions. Unknown
parameters appear in sub-grid scale models which attempt to capture unresolvable physics
on the scale of clouds. These parameters can in principle be learned from data in the form
of time-averaged satellite measurements of the Earth's atmosphere.
Uncertainty quantification, and hence the Bayesian approach, is crucial as estimation (and reduction) of uncertainty in climate models is a central goal of modern climate modeling research \cite{schneider2020earth}. In this paper we will consider a specific GCM from \cite{o2008hydrological}.
The conservation laws, which are discretized to form the computational model, include two
equations which take the form
\begin{align*}
\text{Moisture Conservation:}\quad \frac{\partial q}{\partial t} + {v}\cdot\nabla q &= - \frac{q - q_{\textrm{ref}}(T; {\theta})}{\tau_q(q, T; {\theta})} \\
\text{Energy Conservation:}\quad \frac{\partial T}{\partial t} + {v}\cdot\nabla T &= \frac{T - T_{\textrm{ref}}(q, T; {\theta})}{\tau_T(q, T; {\theta})} + \cdots\,,
\end{align*}
coupled to further conservation laws for mass and momentum. The model includes two unknown
parameters: ${\theta_{RH}}$, the reference relative humidity; and ${\theta_{\tau}}$ a relaxation timescale; the functional forms of $q_{\textrm{ref}}$, $T_{\textrm{ref}},$ $\tau_q$ and $\tau_T$
are known. The unknown parameter is $\theta=({\theta_{RH}},{\theta_{\tau}}).$
The inverse problem is to learn about $\theta$, and
uncertainty in $\theta$, from climate statistics; the paper \cite{dunbar2021calibration}
employs 30-day averages of the free-tropospheric relative humidity, of the precipitation rate, and of a measure of the frequency of extreme precipitation. The parameter-to-data map thus requires
simulation of the discretized conservation laws. This leads to ${\mathcal O}(10^2)$ noisy and indirect observations from which to learn about the $2$ unknowns. Similar, related inverse
problems may be found in \cite{huang2022iterated}[subsection 5.10],
in which the number of unknown parameters is $4.$
\end{example}
\subsection{Surrogate Models}\label{ssec:inv_surrogate}
To make computations feasible in practice, it is common to approximate the log-likelihood $\Phi$, or the forward model $\mathcal{G}$, by a surrogate model, also known as an emulator, meta-model or reduced order model.
A wide range of suitable surrogate models exist, see e.g. \cite{st18,lst18} and the references therein. Recently, a particular focus has been on the use of {\em random} surrogate models. These have been shown to lead to better approximations of the posterior distribution when the error in the surrogate model is large compared to the noise in the observations \cite{cgssz17,btz23}, and to improve the statistical efficiency of MCMC methods \cite{cfo11}. Examples of random surrogate models are methods from the field of probabilistic numerics \cite{cgssz17,lss19}, randomized projection methods \cite{lmbn17,njls09}, and Gaussian process emulators \cite{kennedy2001bayesian,st18}.
Given a random surrogate model for the log-likelihood $\Phi$ or the forward model $\mathcal{G}$, there are then different ways of using this to approximate the posterior distribution $\mu^y$. We will henceforth fix our notation to using a surrogate model for $\Phi$, since using a surrogate model for $\mathcal G$ can be translated into a surrogate model for $\Phi$ using the specific form of the likelihood.
Let us denote the random surrogate model by $\Phi_N$, where $N$ denotes a discretization parameter such as the number of training points in a Gaussian process emulator or the number of grid points used in a probabilistic PDE solver.
Using the mean $\mathbb{E}[\Phi_N]$ of the surrogate model to approximate $\Phi$, we obtain the {\em mean-based approximation} \vspace{-2ex}
\begin{align}
\frac{d\mu^{y,N}_\mathrm{mean}}{d\mu_0}(u) &= \frac{1}{Z_{N}^\mathrm{mean}} \exp\big(- \mathbb{E}[\Phi_N(u)] \big), \label{eq:rad_nik_mean} \\
Z_{N}^\mathrm{mean} &= \mathbb{E}_{\mu_0}\Big(\exp\big(-\mathbb{E}[\Phi_N(u)] \big)\Big) \nonumber.
\end{align}
Alternatively, we can use the random surrogate $\Phi_N$ directly to approximate $\Phi$, and take the expected value of the resulting random approximation of the likelihood. This gives the {\em marginal approximation} \vspace{-2ex}
\begin{align}
\frac{d\mu^{y,N}_\mathrm{marginal}}{d\mu_0}(u) &= \frac{1}{Z_{N}^\mathrm{marginal}} \mathbb{E} \Big(\exp\big(-\Phi_N (u) \big)\Big), \label{eq:rad_nik_marginal} \\
Z_{N}^\mathrm{marginal} &= \mathbb{E}_{\mu_0} \left(\mathbb{E}\Big(\exp\big(- \Phi_N(u)\big)\Big) \right). \nonumber
\end{align}
Intuitively, the marginal approximation introduces additional uncertainty in the approximate posterior distribution, coming from the randomness of the surrogate model. One interpretation of the randomness of our surrogate model is that since we have used a finite amount of information/resources in the construction, there is still some uncertainty (or {\em error}) associated to it. Including this uncertainty in the approximate posterior distribution then allows us to take into account the error in the surrogate model when inferring the parameter $u$. In practical applications, where the accuracy of the surrogate model might be limited due to computational resources, the uncertainty (or error) in the surrogate model can be large (or comparable) to the uncertainty present in the observations $y$, and it is crucial to take this into account to avoid over-confident and biased predictions \cite{cgssz17,btz23}.
In special cases, it can be shown analytically that the marginal approximation results in a form of variance inflation in the likelihood. One such instance is when the forward model $\mathcal G$ is approximated by a Gaussian process $\mathcal G_N \sim \mathrm{GP}(m_N^\mathcal G, K_N)$ with mean $m_N^\mathcal G$ and covariance kernel $K_N$ (see section \ref{sec:gp} for more details). The mean-based approximation assumes the observational model $y = m_N^\mathcal G(u) + \eta$, whereas the marginal approximation uses
\[
y = \mathcal G_N(u) + \eta = m_N^\mathcal G(u) + \xi(u) + \eta,
\]
with $\xi(u) \sim \mathrm{N}(0, K_N(u,u))$. The resulting approximate likelihoods are proportional to
\[
\frac{1}{\sqrt{\det{(\Gamma)}}} \exp\left(-\frac{||y - m_N^\mathcal{G}(u)||^2_{\Gamma}}{2}\right)
\]
for the mean-based approximation, and
\[
\frac{1}{\sqrt{\det{(\Gamma + K_N(u,u) )}}} \exp\left(-\frac{||y - m_N^\mathcal{G}(u)||^2_{(\Gamma +K_N(u,u))}}{2}\right)
\]
for the marginal approximation, see e.g. \cite{cdss18,cosg17,btz23}. The difference between the two likelihoods hence depends on the relationship between $\Gamma$, the uncertainty in the observations $y$, and $K_N$, the uncertainty in the surrogate model $\Phi_N$. If $K_N$ is small compared to $\Gamma$, the two approximate posteriors will be similar.
The approximate posterior distributions can also be motivated from a decision theoretic point of view \cite{sn17,jgvm21}. Suppose $U$ is a compact subset of $\mathbb{R}^{d_u}$, and we approximate the negative log-likelihood $\Phi$ by a Gaussian process $\Phi_N \sim \mathrm{GP}(m_N^\Phi, k_N)$. Then the (un-normalized) marginal approximation minimizes the expected $L^2$-loss:
\[
\mathbb{E} \Big(\exp\big(-\Phi_N (u) \big)\Big) \pi_0(u) = \argmin_{f \in L^2(U)} \; \mathbb{E} \int_U \left( \exp\big(-\Phi_N (u) \big) \pi_0(u) -f(u) \right)^2 \mathrm{d} u.
\]
The (un-normalized) mean-based approximation instead minimizes the expected $L^1$-loss:
\[
\exp\big(-m^\Phi_N (u) \big)\pi_0(u) = \argmin_{f \in L^1(U)} \; \mathbb{E} \int_U \left| \exp\big(-\Phi_N (u) \big) \pi_0(u) -f(u) \right| \mathrm{d} u.
\]
\begin{remark}[Alternative approximate posteriors] In addition to the approximations described above, we can also consider the {\em sample-based} approximation
\begin{align*}
\frac{d\mu^{y,N}_\mathrm{sample}}{d\mu_0}(u) &= \frac{1}{Z_{N}^\mathrm{sample}} \exp\big(-\Phi_N (u) \big) , \\
Z_{N}^\mathrm{sample} &= \mathbb{E}_{\mu_0} \left( \exp\big(- \Phi_N(u)\big) \right),
\end{align*}
which results in a random approximation of the posterior \cite{st18,lst18}. If there is considerable uncertainty in the random surrogate model $\Phi_N$, the posterior approximations corresponding to different samples of $\Phi_N$ may look very dissimilar.
An alternative marginal approximation can be defined by taking the expected value of the normalized random likelihood defined above,
\begin{align*}
\frac{d\mu^{y,N}_\mathrm{marginal'}}{d\mu_0}(u) &= \mathbb{E} \left( \frac{1}{Z_{N}^\mathrm{sample}} \exp\big(-\Phi_N (u) \big) \right).
\end{align*}
However, this approximation is not easily amenable to sampling methods such as (pseudo-marginal) MCMC, since the computation of $Z_{N}^\mathrm{sample}$ is intractable. $\blacksquare$
\end{remark}
\subsection{Error in the Surrogate-accelerated Posterior Distribution}
\label{ssec:justify}
To justify the use of the approximate posterior distributions $\mu^{y,N}_\mathrm{mean}$ and $\mu^{y,N}_\mathrm{marginal}$ in practice, we want to show that they converge to the true posterior $\mu^y$ as $N \rightarrow \infty$. We will measure the error in the Hellinger distance \vspace{-1ex}
\begin{equation*}
d_{\mbox {\tiny{\rm Hell}}}(\mu^y, \mu^{y,N}) = \left( \frac{1}{2} \int_{U} \left(\sqrt{\frac{d \mu^y}{d \nu}} - \sqrt{\frac{d \mu^{y,N}}{d \nu}} \right)^2 d \nu \right)^{1/2},
\end{equation*}
where $\nu$ is any measure such that $\mu^y$ and $\mu^{y,N}$ are both absolutely continuous with respect to $\nu$ {(and the value of the distance is independent of the choice of $\nu.$)
In \cite{lst18,st18, t20} bounds were obtained on $d_{\mbox {\tiny{\rm Hell}}}(\mu^y, \mu^{y,N}_\mathrm{mean})$ and $d_{\mbox {\tiny{\rm Hell}}}(\mu^y, \mu^{y,N}_\mathrm{marginal})$ in terms of $\left\|\Phi - \mathbb{E}[\Phi_N] \right\|_{L^{p}_{\mu_0}(U)}$ and $\left\| \mathbb{E}\bigl[ \left| \Phi - \Phi_{N} \right|^{q_1} \bigr]^{1/q_1} \right\|_{L^{q_2}_{\mu_{0}}(U)}$, respectively, for $p$, $q_1$ and $q_2$ depending on the regularity of the problem. These results suggest that choosing $\Phi_N$ to be a good approximation to $\Phi$ in all regions where the prior $\mu_0$ places significant mass is sufficient for accurate surrogate modeling in the
context of Bayesian inference. However we would expect that, in fact, $\Phi_N$ only needs to be a good approximation to $\Phi$ in regions where the posterior $\mu^y$ places significant mass. This is captured in the following results, which follow
by analyzing the Hellinger distance with the choice $\nu = \mu^y$.}
\begin{theorem}[Convergence of mean-based approximation]\label{thm:mean_posterior} Suppose that there exist scalars $C_1, C_2 \geq 0$, independent of $N$, such that for the H\"{o}lder-conjugate exponent pair $(p_1,p_1')$, we have\footnote{For $p_1=\infty$, assumption (i) requires bounding the standard $L^\infty(U)$-norm, due to the corresponding H\"older inequality $\int_U f g \mu^y(\mathrm{d}u) \leq \sup_{u \in U } |f(u)| \int_U |g| \mu^y(\mathrm{d}u) = \|f\|_{L^\infty(U)} \|g\|_{L^1_{\mu^y}(U)}$.}
\begin{enumerate}
\item[(i)] $\left\| \exp\left((\Phi - \mathbb{E} [\Phi_N])\right) \right\|_{L^{p_1}_{\mu^y}(U)} \leq C_1(p_1)$;
\item[(ii)] $C_2^{-1} \leq Z_{N}^\mathrm{mean} \leq C_2$.
\end{enumerate}
Then there exists a constant $C_{\mathrm{Thm} \ref{thm:mean_posterior}} =C_{\mathrm{Thm} \ref{thm:mean_posterior}} (C_1,C_2, Z)$, independent of $N$, such that
\begin{subequations}
\begin{align*}
d_{\mbox {\tiny{\rm Hell}}}(\mu^y, \mu^{y,N}_\mathrm{mean}) &\leq C_{\mathrm{Thm} \ref{thm:mean_posterior}} \left\|\Phi - \mathbb{E} [\Phi_N] \right\|_{L^{2p_1'}_{\mu^y}(U)}.
\end{align*}
\end{subequations}
\end{theorem}
\begin{theorem}[Convergence of marginal approximation] \label{thm:marginal_posterior}
Suppose that there exist scalars $C_1, C_2 \geq 0$, independent of $N$, such that, for the H\"{o}lder-conjugate exponent pairs $(p_1,p_1')$ and $(p_2,p_2')$, we have\footnotemark[1]
\begin{enumerate}
\item[(i)] \label{item:hell_conv_marg_b} $\left\| \mathbb{E} \big[ \left(\exp\left(\Phi - \Phi_N\right)\right)^{p_2} \big]^{1/{p_2}} \right\|_{L^{2p_1}_{\mu^y}(U)} \leq C_1(p_1,p_2)$
\item[(ii)] \; $C_2^{-1} \leq Z_{N}^\mathrm{marginal} \leq C_2$.
\end{enumerate}
Then there exists a constant $C_{\mathrm{Thm} \ref{thm:marginal_posterior}}=C_{\mathrm{Thm} \ref{thm:marginal_posterior}} (C_1,C_2,Z)$, independent of $N$, such that \vspace{-0.5ex}
\begin{subequations}
\label{eq:hell_conv_marg_result}
\begin{align*}
d_{\mbox {\tiny{\rm Hell}}} \bigl( \mu, \mu^{y,N}_\mathrm{marginal} \bigr) &\leq C_{\mathrm{Thm} \ref{thm:marginal_posterior}} \left\| \mathbb{E} \big[ \left(\Phi - \Phi_N \right)^{p_2'} \big]^{1/p_2'} \right\|_{L^{2p_1'}_{\mu^y}(U)}.
\end{align*}
\end{subequations}
\end{theorem}
Note that these results hold in the general setting where the parameter space $U$ is a Banach space, and do not require $U$ to be finite-dimensional. The proofs of these results are similar to those in \cite{st18,lst18}, and can be found in the appendix. The assumptions in the above theorems are generally applicable to any random surrogate model $\Phi_N$, and in fact also to general distributions on the noise $\eta$. They need to be checked on a case-by-case basis. This is done for Gaussian noise and surrogate models based on Gaussian process regression in section \ref{sec:gp}.
Assumption $(i)$ in Theorems \ref{thm:mean_posterior} and \ref{thm:marginal_posterior} is related to integrability properties of our surrogate model $\Phi_N$. The exponent $p_1$, present in both theorems, is related to the decay rate of the tails in $u$. The exponent $p_2$, related to the decay rate of the tails of the distribution of $\Phi_N$, is only needed in Theorem \ref{thm:marginal_posterior}, since the mean-based approximation $\mu^{y,N}_\mathrm{mean}$ does not make use of the randomness in $\Phi_N$.
Assumption $(ii)$ in Theorems \ref{thm:mean_posterior} and \ref{thm:marginal_posterior} ensures that the normalization constants $Z_{N}^\mathrm{mean}$ and $Z_{N}^\mathrm{marginal}$, and hence the approximate posteriors, are well-defined.
\section{Gaussian {Process Regression}} \label{sec:gp}
We now want to use Gaussian process regression to build a surrogate model for the data likelihood. Gaussian process regression (a.k.a Gaussian process emulation, or kriging) is a way of building an approximation to a function $f$, based on a finite number of evaluations of $f$ at a chosen set of training points (a.k.a. {design points}).
We will here consider emulation of either the parameter-to-observation map $\mathcal G: U \rightarrow \mathbb{R}^{d_y}$ or the negative log-likelihood $\Phi:U \rightarrow \mathbb{R}$. We will for simplicity focus on the emulation of scalar valued functions, and assume that an emulator of $\mathcal G$ in the case $d_y > 1$ is constructed by emulating each entry independently. However, we remark here that in practice including correlation between different entries in $\mathcal G$ can significantly improve the quality of the approximate posterior \cite{btz23}.
{In subsection \ref{ssec:su} we set-up the framework of Gaussian process
regression, followed in subsection \ref{ssec:sm} by discussion of the use
of this regression technique in the context of surrogate modeling. Subsection
\ref{ssec:exsm} returns to the two examples from subsection \ref{ssec:exbip},
in order to illustrate the potential for reduction in computational cost achieved by the surrogate model $f_N$ compared to the original model $f$. Subsection \ref{ssec:error0}
is devoted to estimates of the error in the approximate posterior
in terms of the error in a GP surrogate
model used to approximate the likelihood contribution to the posterior.
In subsection \ref{ssec:gp_sk} error estimates for Gaussian process regression,
which may be used in the analysis of the previous subsection, are provided.}
\subsection{Set-up}
\label{ssec:su}
Let $U \subseteq \mathbb{R}^{d_u}$ be finite-dimensional, and let $f : U \rightarrow \mathbb{R}$ be an arbitrary function. Gaussian process regression is a Bayesian procedure, and the starting point is to put a Gaussian process prior on the function $f$. In other words, we model $f$ as a sample of the Gaussian process
\begin{equation}\label{eq:gp}
{f_0} \sim \text{GP}(m(u), k(u,u')),
\end{equation}
with $m : U \rightarrow \mathbb{R}$ a chosen mean function, giving $ \mathbb{E}[f_0(u)] = m(u)$, and $k : U \times U \rightarrow \mathbb{R}$ a chosen symmetric, positive-definite covariance kernel, giving $\mathbb{C}\mathrm{ov}(f_0(u), f_0(u')) = k(u,u')$. This means that for any set of points $\{ \tilde u^m\}_{m=1}^M \subseteq U$, the vector $[f_0(\tilde u^1); \dots; f_0(\tilde u^M)] \in \mathbb{R}^M$ follows a multivariate Gaussian distribution, with mean $[m(\tilde u^1); \dots; m(\tilde u^M)] \in \mathbb{R}^M$ and covariance matrix $K \in \mathbb{R}^{M \times M}$ with entries $K_{i,j} = k(\tilde u^i, \tilde u^j)$.
Typical choices of the mean function $m$ include the zero function and polynomials \cite{rasmussen_williams}.
A family of covariance functions $k$ frequently used in applications are the Mat\`ern covariance functions \cite{matern}, given by
\begin{equation}\label{eq:mat_cov}
k_{\nu,\lambda,\sigma_k^2}(u,u') = \sigma_k^2 \, \frac{1}{\Gamma(\nu) 2^{\nu-1}} \left(\frac{\|u-u'\|_2}{\lambda}\right)^\nu B_\nu\left( \frac{\|u-u'\|_2}{\lambda}\right) ,
\end{equation}
where $\Gamma$ denotes the Gamma function, $B_\nu$ denotes the modified Bessel function of the second kind and $\nu, \lambda$ and $\sigma_k^2$ are positive parameters. The parameter $\lambda$ is referred to as the {\em correlation length}, and governs the length scale at which ${f_0}(u)$ and ${f_0}(u')$ are correlated. The parameter $\sigma_k^2$ is the {\em marginal variance} $\sigma_k^2 = k_{\nu,\lambda,\sigma_k^2}(u,u) = \mathbb{V}[f_0(u)]$, and governs the typical magnitude of ${f_0}(u)$. Finally, the parameter $\nu$ is referred to as the {\em smoothness parameter}, and governs the regularity of sample paths of ${f_0}$ as a function of $u$. Sample paths of $f_0$ are in the Sobolev space $H^{\nu-\epsilon}(U)$ almost surely, for any $\epsilon > 0$, see e.g. \cite{khss18}.
In the limit $\nu \rightarrow \infty$, we obtain the Gaussian covariance function
\begin{equation*}\label{eq:gauss_cov}
k_{\infty,\lambda,\sigma_k^2}(u,u') = \sigma_k^2 \exp \left(-\frac{\|u-u'\|_2^2}{2 \lambda^2}\right),
\end{equation*}
also known as the squared exponential or {radial basis function (RBF)} covariance function.
The formula for the Mat\`ern covariance function furthermore simplifies when $\nu$ is a half integer, and popular choices include
\begin{align*}
k_{\frac{1}{2},\lambda,\sigma_k^2}(u,u') &= \sigma_k^2 \exp \left(-\frac{\|u-u'\|_2}{\lambda}\right), \\
k_{\frac{3}{2},\lambda,\sigma_k^2}(u,u') &= \sigma_k^2 \left( 1 + \sqrt{3} \frac{\|u-u'\|_2}{\lambda}\right)\exp \left(-\sqrt{3} \frac{\|u-u'\|_2}{\lambda}\right).
\end{align*}
The choice $\nu=\frac{1}{2}$ gives the exponential covariance function, also known as the Laplace covariance function; {in the setting of one-dimensional input
variable $u$ it is the covariance function of the Ornstein-Uhlenbeck process.}
Figure \ref{fig:samples} shows 5 independent sample paths of the Gaussian process $f_0$ with $m=0$ and 4 different choices of the parameters in the Mat\'ern covariance function. We also show the mean $\mathbb{E}[f(u)] = m(u) = 0$ as the solid black line, and the marginal standard deviation $\sqrt{k(u,u)} = \sigma =1$ as the light grey interval around the mean. The two plots in the top row show $\nu=\frac{1}{2}$, leading to sample paths that are continuous but not differentiable, and the two plots in the bottom row show $\nu=\infty$, in which case the sample paths are infinitely smooth. The left column shows a long correlation length $\lambda$, leading to mostly large scale variations, whereas the right column shows a shorter correlation length, resulting in more small scale fluctuations.
\begin{figure}[!ht]
\centering
\subfloat{\includegraphics[width=.4\textwidth]{sample1.png}}\quad
\subfloat{\includegraphics[width=.4\textwidth]{sample2.png}}\\
\subfloat{\includegraphics[width=.4\textwidth]{sample3.png}}\quad
\subfloat{\includegraphics[width=.4\textwidth]{sample4.png}}
\caption{Sample paths of the Gaussian process $f_0$ with Mat\'ern covariance function $k_{\nu,\lambda,\sigma_k^2}$. Top left: $\{\nu,\lambda,\sigma_k^2\} = \{\frac{1}{2},1,1\}$. Top right: $\{\nu,\lambda,\sigma_k^2\} = \{\frac{1}{2},0.1,1\}$. Bottom left: $\{\nu,\lambda,\sigma_k^2\} = \{\infty,1,1\}$. Bottom right: $\{\nu,\lambda,\sigma_k^2\} = \{\infty,0.1,1\}$.}
\label{fig:samples}
\end{figure}
\begin{figure}[!ht]
\centering
\subfloat{\includegraphics[width=.4\textwidth]{post_sample1.png}}\quad
\subfloat{\includegraphics[width=.4\textwidth]{post_sample3.png}}\\
\caption{Sample paths of the Gaussian process $f_3$ with Mat\'ern covariance function $k_{\nu,\lambda,\sigma_k^2}$, for $f(x)=\sin{(x-2.5)^2}$. Left: $\{\nu,\lambda,\sigma_k^2\} = \{\frac{1}{2},0.1,0.63^2\}$ Right: $\{\nu,\lambda,\sigma_k^2\} = \{\infty,0.1,0.63^2\}$.}
\label{fig:samples_posterior}
\end{figure}
Now suppose we are given data in the form of a set of distinct training points $D_N := \{u^n\}_{n=1}^N \subseteq U$, together with corresponding function values
\begin{equation}\label{eq:data_exact}
f(D_N) := [f(u^1); \dots; f(u^N)] \in \mathbb{R}^N.
\end{equation}
{Since $f_0$ is a Gaussian process, the vector $[f_0(u^1); \dots; f_0(u^N); f_0(\tilde u^1); \dots, f_0(\tilde u^M)] \in \mathbb{R}^{N+M}$, for any set of test points $\{ \tilde u^m\}_{m=1}^M \subseteq U$, follows a multivariate Gaussian distribution. The conditional distribution of $f_0(\tilde u^1), \dots, f_0(\tilde u^M)$, given the values $f_0(u^1) = f(u^1), \dots, f_0(u^N) = f(u^N)$, is then again Gaussian, with mean and covariance given by the standard formulas for the conditioning of Gaussian random variables \cite{rasmussen_williams}.}
Conditioning the Gaussian process \eqref{eq:gp} on the known values $f(D_N)$, we hence obtain another Gaussian process $f_N$, known as the {\em predictive process}. We have
\begin{equation}\label{eq:gp_pred}
f_N \sim \text{GP}(m^f_N(u), k_N(u,u')),
\end{equation}
where the predictive mean $m^f_N : U \rightarrow \mathbb{R}$ and predictive covariance $k_N : U \times U \rightarrow \mathbb{R}$ are known explicitly, and depend on the modeling choices made in \eqref{eq:gp}. We will from now on focus on the popular choice $m \equiv 0$; the case of a non-zero mean is discussed in Remark \ref{rem:mean}.
When $m \equiv 0$, we have
\begin{align}
m_N^f(u) &= k(u,D_N)^T K(D_N,D_N)^{-1} f(D_N), \label{eq:pred_eq_mean}\\
k_N(u,u') &= k(u,u') - k(u,D_N)^T K(D_N,D_N)^{-1} k(u',D_N), \label{eq:pred_eq_var}
\end{align}
where $k(u,D_N) = [k(u,u^1); \dots; k(u,u^N)] \in \mathbb{R}^{N}$ and $K(D_N,D_N) \in \mathbb{R}^{N \times N}$ is the matrix with $ij^\mathrm{th}$ entry equal to $k(u^i,u^j)$ \cite{rasmussen_williams}.
Figure \ref{fig:samples_posterior} is similar to Figure \ref{fig:samples}, and shows samples from the predictive process $f_N$ (with $N=3$) for different choices of hyper-parameters in the Mat\`ern covariance kernel. We also show the updated mean $\mathbb{E}[f_N(u)] = m_N^f(u)$ and the updated marginal standard deviation $\sqrt{k_N(u,u)}$. We see that the choice of hyper-parameters can have a significant influence on the behaviour of the predictive process. Good values of hyper-parameters are often not known a priori, and have to be estimated from the observed values $f(D_N)$ in \eqref{eq:data_exact} (see e.g. \cite{rasmussen_williams} and the references therein). This is done for $\lambda$ and $\sigma^2$ in Figure \ref{fig:samples_posterior} using \texttt{scikit-learn} \cite{scikit-learn}.
From \eqref{eq:pred_eq_mean}, we note that $m_N^f$ interpolates the function $f$ at the training points $D_N$, since the vector $k(u^n,D_N)$ is the $n^\mathrm{th}$ row of the matrix $K(D_N,D_N)$. In other words, we have $m_N^f(u^n) = f(u^n)$, for all $n=1,\dots,N$.
For the predictive covariance $k_N$, we note that $k_N(u,u) < k(u,u)$ for all $u \in U$, since $K(D_N,D_N)$ is positive-definite by assumption. Furthermore, we also note that $k_N(u^n,u^n) = 0$, for $n=1, \dots, N$, since $k(u^n,D_N)^T \; K(D_N,D_N)^{-1} \; k(u^n,D_N) = k(u^n,u^n)$.
\begin{remark}\label{rem:mean}{\em (Prior with non-zero mean)} If in \eqref{eq:gp} we use a non-zero mean $m(\cdot)$, the formula for the predictive mean $m_N^f$ changes to
\begin{equation*
m_N^{f,m}(u) = m(u) + k(u,D_N)^T K(D_N,D_N)^{-1} (f(D_N) - m(D_N)),
\end{equation*}
where $m(D_N) := [m(u^1); \dots; m(u^N)] \in \mathbb{R}^N$. The predictive covariance $k_N(u,u')$ is as in \eqref{eq:pred_eq_mean}. As in the case $m \equiv 0$, we have $m_N^f(u^n) = f(u^n)$, for $n=1, \dots, N$, and $m_N^f$ is an interpolant of $f$. Under suitable assumptions on $m$, any error bounds derived in the case $m \equiv 0$ can be transferred to the general case, see e.g \cite{t20}. $\blacksquare$
\end{remark}
\begin{remark}\label{rem:noisy}{\em (Noisy function values)} If instead of exact function values as in \eqref{eq:data_exact}, we observe noisy function values
\[
d := [f(u^1) + \varepsilon_1; \dots; f(u^N)+\varepsilon_N] \in \mathbb{R}^N,
\]
with $\varepsilon_i \sim \mathrm{N}(0,\sigma^2)$ i.i.d., then the formulas for the predictive process $f_N$ presented above hold with $K(D_N,D_N)$ replaced by $K(D_N,D_N) + \sigma^2 \mathrm{I}$. $\blacksquare$
\end{remark}
\subsection{Gaussian Process Regression as Surrogate Model}
\label{ssec:sm}
There are two main use cases for Gaussian process regression: (i) the true function $f$ generating the input-output pairs $\{u^n, f(u^n)\}_{n=1}^N$ is unknown, or (ii) the function $f$ generating $\{u^n, f(u^n)\}_{n=1}^N$ is known, but computationally very expensive to evaluate. In scenario (i), we wish to learn what the function $f$ is from the observed input-output pairs. This is often based on real data, and so the assumption that the observed function values contain noise is common. In the case of (ii), we wish to construct a surrogate model (a.k.a. reduced model, meta-model or emulator) that is cheaper to evaluate than the original $f$. This is often based on data $\{u^n, f(u^n)\}_{n=1}^N$ obtained from simulating a mathematical model on a computer, and so assuming no noise in the function values may be more {appropriate.}
To construct a surrogate model for $f$, we simulate $N$ model runs at inputs $\{u^n\}_{n=1}^N$ to obtain outputs $\{f(u^n)\}_{n=1}^N$, and then follow the Bayesian procedure outlined in the previous section to obtain the predictive process $f_N \sim \text{GP}(m^f_N(u), k_N(u,u'))$. As such, it is similar to many other surrogate models based on model runs or {\em snapshots}.
The Gaussian process $f_N$ is a random surrogate model for $f$. The uncertainty in $f_N$, encoded in the predictive variance $k_N$, is a model for the remaining uncertainty about $f$ after observing the finite amount of information $\{u^n, f(u^n)\}_{n=1}^N$, or in other words a model for the error between $f$ and $m^f_N$, based on the assumption that $f$ is a sample of the Gaussian process prior \eqref{eq:gp}. At the training points $D_N$, where we have observed $f$, there is no uncertainty about what value $f$ takes and there is no error in $m_N^f$ (i.e. $k_N(u^n, u^n) = 0$ and $m_N^f(u^n) = f(u^n)$, cf Figure \ref{fig:samples_posterior}). Away from the training points, where we do not know the value of $f$, there is still some uncertainty/error (i.e. $k_N(u, u) > 0$ and $m_N^f(u) \neq f(u)$ in general).
It remains to see that $f_N$ is indeed a surrogate model in the sense that it is much cheaper to evaluate than the original model $f$. To this end, note that in the approximate posteriors in section \ref{ssec:inv_surrogate}, we typically need to evaluate the predictive mean $m_N^f$ and the predictive variance $k_N$. As can be seen from \eqref{eq:pred_eq_mean}, the predictive mean $m_N^f$ is a linear combination of kernel evaluations:
\begin{equation*
m_N^f(u) = \sum_{n=1}^N \alpha_n k(u,u^n), \qquad \alpha = K(D_N,D_N)^{-1} f(D_N) \in \mathbb{R}^N.
\end{equation*}
To evaluate $m_N^f(u)$ at an unobserved input $u \in U \setminus D_N$, we hence only need to evaluate the sum on the RHS of the expression above. Firstly, we note that the number of summands $N$ is typically small. This corresponds to the number of times we need to run our original model $f$, and in many practical applications, this will be limited by computational resources. Secondly, we note that the computation of the coefficients $\alpha$ can, {in general, be somewhat costly, since it involves finding the Cholesky factorization (or similar) of $K(D_N,D_N)$ which incurs computational cost $\mathcal O(N^3)$; however, as noted previously, $N$ is typically small in the applications of surrogate modeling that we consider in this paper.} Furthermore, the coefficients $\alpha$ only need to be computed {\em once}, rather than for every $u$. Thirdly, we note that the evaluation of the kernel $k(u,u^n)$ is cheap, since this typically involves the evaluation of standard functions such as polynomials and exponentials. Similar arguments apply to evaluations of the predictive variance $k_N(u,u)$.
\subsection{Examples of Gaussian Process Regression as Surrogate Model}
\label{ssec:exsm}
{We return to the two examples introduced in subsection \ref{ssec:exbip}
in order to illustrate the potential speedups afforded by use of
Gaussian process surrogate modeling.}
\begin{example} {Computational Timings in Subsurface Flow Example} Consider the subsurface flow example from subsection \ref{ssec:exbip}. The table below gives representative computational timings comparing cost of the evaluation of the
solution of the PDE, $f(u)$, with the two primary costs incurred in the Gaussian
process surrogate modeling, namely the determination of the coefficients of the kernel representation of the mean, $\alpha$, and evaluation of the mean $m_N^f$. Further details, and more extensive numerical experiments, may be found in \cite{btz23}. The numerical solution of the PDE for a given parameter $u$, representing the true model $f$, is implemented in Firedrake \cite{firedrake2016}.
\begin{table}[h!]
\centering
\begin{tabular}{|c | c c c|}
\hline
Set-up & Computing $f(u)$ & Computing $m_N^f(u)$ & Computing $\alpha$ \\ [0.5ex]
\hline\hline
$d_u = 2, d_y=10, D = (0,1), N=10$ & $2.6 \times 10^{-1}$s & $ 3.6 \times 10^{-5}$s & $3.2 \times 10^{-3}$s \\
$d_u = 2, d_y=10, D = (0,1), N=20$ & $2.6 \times 10^{-1}$s & $ 4.0 \times 10^{-5}$s & $1.2 \times 10^{-2}$s \\
$d_u = 10, d_y=10, D = (0,1), N=10$ & $2.6 \times 10^{-1}$s & $ 5.6 \times 10^{-5}$s & $3.2 \times 10^{-3}$s \\
[1ex]
\hline
\end{tabular}
\label{table:1}
\end{table}
\end{example}
\begin{example} {Computational Motivation for GCM Example}
In the paper \cite{dunbar2021calibration} Gaussian process regression is
used to accelerate Bayesian inference for parameters appearing in an idealized general
circulation model (GCM) used in climate modeling and described in subsection
\ref{ssec:exbip}. Evaluation of the
parameter-to-data map is computationally
expensive and use of Gaussian process surrogates, as
overviewed in this paper, can be used to accelerate the computations. In
particular the number of unknown parameters in the example considered in
\cite{dunbar2021calibration} is $2$, the number of observations is on the order of
${\mathcal O}(10^2)$, whilst the number of variables in the computational model
is on the order of ${\mathcal O}(10^5)$; by using Gaussian process surrogates, which
sidestep the need to work in space of dimension ${\mathcal O}(10^5)$, computational
costs can be significantly reduced. The natural measure
of computational cost is the number of evaluations of the GCM required to perform MCMC to obtain
solution of the Bayesian inverse problem. Without emulation this is $\mathcal{O}(10^5)$; with
Gaussian process emulation it is possible to achieve the same accuracy in solution of the
Bayesian inverse problem with $\mathcal{O}(10^2)$ evaluations of the forward model \cite{dunbar2021calibration}. These evaluations arise from providing training data for the Gaussian process and in particular from the use of the ensemble Kalman based calibrate-emulate-sample approach to the design of this training data \cite{cleary2021calibrate}. The wish to put the
calibrate-emulate-sample methodology on firm theoretical foundations motivates our work
in this paper on the optimal choice of design points for Gaussian process surrogate modeling
in the context of Bayesian inverse problems.
\end{example}
\subsection{Error in GP-accelerated Posterior Distribution}
\label{ssec:error0}
Suppose now that we use Gaussian process regression as our surrogate model in the approximate posterior distributions \eqref{eq:rad_nik_mean} and \eqref{eq:rad_nik_marginal}. An application of Theorems \ref{thm:mean_posterior} and \ref{thm:marginal_posterior} gives the following error bounds. We denote by $H_k(U)$ the reproducing kernel Hilbert space (RKHS) (see e.g. \cite{wendland}) of the prior covariance kernel $k$ in \eqref{eq:gp}.
\begin{corollary} \label{cor:post_conv_gp_phi} Suppose $U \subseteq \mathbb{R}^{d_u}$, $\Phi \in H_k(U)$, and the random surrogate model is constructed by applying Gaussian process regression to $\Phi$, resulting in $\Phi_N \sim \text{GP}(m^\Phi_N(u), k_N(u,u'))$. Then there exist constants $C_{\mathrm{Cor} \ref{cor:post_conv_gp_phi}} , C_{\mathrm{Cor} \ref{cor:post_conv_gp_phi}} ' > 0$, independent of $N$, such that \vspace*{-1ex}
\begin{align*}
d_{\mbox {\tiny{\rm Hell}}}(\mu^y, \mu^{y,N}_\mathrm{mean}) &\leq C_{\mathrm{Cor} \ref{cor:post_conv_gp_phi}} \left\|\Phi - m^\Phi_N \right\|_{L^{2}_{\mu^y}(U)}, \end{align*}
and, under the additional assumptions that $U$ is bounded with Lipschitz boundary and $\sup_{u \in U} k_N(u,u) \rightarrow 0$ as $N \rightarrow \infty$, \vspace*{-1ex}
\begin{align*}
d_{\mbox {\tiny{\rm Hell}}}(\mu^y, \mu^{y,N}_\mathrm{marginal}) &\leq C_{\mathrm{Cor} \ref{cor:post_conv_gp_phi}} ' \left( \left\|\Phi - m^\Phi_N\right\|_{L^{2}_{\mu^y}(U)} + \left\| k_N^{1/2}(\cdot, \cdot) \right\|_{L^{2}_{\mu^y}(U)} \right).
\end{align*}
\end{corollary}
\begin{corollary} \label{cor:post_conv_gp_G} Suppose $U \subseteq \mathbb{R}^{d_u}$, $\mathcal G^j \in H_k(U)$ for $j=1,\dots,d_y$, and the random surrogate model is constructed by applying Gaussian process regression component-wise to $\mathcal G$, resulting in $\mathcal G_N^j \sim \text{GP}(m^{\mathcal G^j}_N(u), k_N(u,u'))$ and $\Phi_N(u) = \frac{1}{2} \left\| y - \mathcal G_N(u) \right\|_{\Gamma}^2$. Then there exist constants $C_{\mathrm{Cor}\ref{cor:post_conv_gp_G}} , C_{\mathrm{Cor}\ref{cor:post_conv_gp_G}}' > 0$, independent of $N$, such that \vspace*{-1ex}
\begin{align*}
d_{\mbox {\tiny{\rm Hell}}}(\mu^y, \mu^{y,N}_\mathrm{mean}) &\leq C_{\mathrm{Cor}\ref{cor:post_conv_gp_G}} \sum_{j=1}^{d_y} \left\|\mathcal G^j - m^{\mathcal G^j}_N \right\|_{L^{2}_{\mu^y}(U)},
\end{align*}
and, under the additional assumptions that $U$ is bounded with Lipschitz boundary and $\sup_{u \in U} k_N(u,u) \rightarrow 0$ as $N \vspace{-0.5ex}\rightarrow \infty$, \vspace*{-1ex}
\begin{align*}
d_{\mbox {\tiny{\rm Hell}}}(\mu^y, \mu^{y,N}_\mathrm{marginal}) &\leq C_{\mathrm{Cor}\ref{cor:post_conv_gp_G}}' \left( \sum_{j=1}^{d_y} \left\|\mathcal G^j - m^{\mathcal G^j}_N \right\|_{L^{2}_{\mu^y}(U)} + \left\| k_N^{1/2}(\cdot, \cdot) \right\|_{L^{2}_{\mu^y}(U)} \right).
\end{align*}
\end{corollary}
Proofs of the above results are similar to those in \cite{st18} developed
using the $L^2$-norm weighted by the prior measure $\mu_0$, $L^{2}_{\mu_0}(U).$
The proofs are outlined in the appendix.
However, in contrast to \cite{st18}, for the new results derived here, all error measures are
computed in the $L^2$-norm weighted by the true posterior measure $\mu^y$,
$L^{2}_{\mu^y}(U).$ This enables us to deduce that the behaviour of the random surrogate model $\Phi_N$ in parts of the parameter space to which $\mu^y$ does not attach significant mass does not have a big influence on the accuracy of the approximate posterior distributions.
For the mean-based approximation \eqref{eq:rad_nik_mean} the results
show that we only need to control the error in the predictive means $m^\Phi_N$ and $m^{{\mathcal G}^j}_N$, respectively. For the marginal approximations \eqref{eq:rad_nik_marginal}, we also need to control the predictive variance $k_N$.
\subsection{Error Bounds for GP Regression in Weighted Spaces}
\label{ssec:gp_sk}
We now study the behaviour of the predictive mean $m_N^f$ and predictive variance $k_N$ as $N \rightarrow \infty$, for a general function $f : U \rightarrow \mathbb{R}$ that we wish to emulate. Using a representer theorem (\cite{rasmussen_williams,schoelkopf2002learning}),
{the predictive mean $m_N^f$ defined in \eqref{eq:pred_eq_mean}} can be shown to be the minimum norm interpolant in the RKHS $H_k(U)$ of the prior covariance kernel $k$:
\begin{equation}\label{eq:mean_min}
m_N^f = \argmin_{\substack{{g \in H_k(U) \; \text{s.t. }} \\ {g(u^{(n)}) = f(u^{(n)}), \, 1 \leq n \leq N}}} \|g\|_{H_k(U)}.
\end{equation}
For the Mat\`ern kernels defined in \eqref{eq:mat_cov}, it is known that the RKHS is equal to the Sobolev space $H^{\nu + d_u/2}(U)$ as a vector space, with equivalent norms \cite{wendland}. So there exist constants $C_\mathrm{low}(U), C_\mathrm{up}(U) > 0$ such that for all $g \in H_k(U)$, we have
\begin{equation}\label{eq:norm_equi}
C_\mathrm{low}(U) \|g\|_{H^{\nu + d_u/2}(U)} \leq \|g\|_{H_{k}(U)} \leq C_\mathrm{up}(U) \|g\|_{H^{\nu + d_u/2}(U)}.
\end{equation}
{Given the training points $D_N$ we introduce the mapping $m_N^{(\cdot)} : H_k(U) \rightarrow H_k(U)$, which is built on the definition of the predictive mean $m_N^f$ given in \eqref{eq:pred_eq_mean}. With $g(D_N) := [g(u^1); \dots; g(u^N)] \in \mathbb{R}^N$ as in \eqref{eq:data_exact}, we let
\begin{align} \label{eq:pred_mean_g}
g(u) \mapsto m_N^g(u) = k(u,D_N)^T K(D_N,D_N)^{-1} g(D_N).
\end{align}
The predictive variance $k_N$ satisfies the equality in Proposition \ref{prop:predvar_sup}, which follows, allowing us to transfer convergence results on $m_N^f$ to convergence results on $k_N$ \cite{sss13,st18}.
\begin{proposition}\label{prop:predvar_sup} Suppose $k_N$ and $m_N^{(\cdot)}$ are given by \eqref{eq:pred_eq_var} and \eqref{eq:pred_mean_g}, respectively. Then for any $u \in U$ we have
\[
k_N(u,u)^{\frac{1}{2}} = \sup_{\substack{{g \in H_k(U) \; \text{s.t. }} \\ \|g\|_{H_k(U)}=1}} | g(u) - m^g_N(u)|.
\]
\end{proposition}}
For any bounded set $\tilde U \subseteq U$, we define the {fill distance} $h_{D_N, \tilde U}$ as
\begin{equation*}
h_{D_N, \tilde U} := \sup_{u \in \tilde U} \inf_{u^n \in D_N \cap \tilde U} \|u- u^n\|_2.
\end{equation*}
The fill distance is the maximum distance any point in $\tilde U$ can be from a training point $u^n \in D_N \cap \tilde U$, and we require a space-filling set of training points $D_N$ (in $\tilde U$) to ensure that the fill distance goes to zero as $N \rightarrow \infty$. The following result follows from standard results in scattered data approximation \cite{wendland,nww05,alt12}.
\begin{proposition}\label{prop:scat_zeros} Suppose $\tilde U \subseteq U$ is a Lipschitz domain that satisfies an interior cone condition with angle $\theta$, and $\tilde U$ is contained in the cube $B(u_c, R_c) = \{ u \in \mathbb{R}^{d_u} : \|u - u_c\|_\infty \leq R_c \}$, for some $u_c \in \mathbb{R}^{d_u}$ and $0 < R_c < \infty$. Suppose further that the RKHS $H_k(\tilde U)$ is isomorphic to the Sobolev space $H^\tau(\tilde U)$ and $f \in H^\tau(\tilde U)$. Then there exist constants $C_{\mathrm{Prop} \ref{prop:scat_zeros}}, C_{\mathrm{Prop} \ref{prop:scat_zeros}}' > 0$, independent of $f$, $D_N$ and $N$, such that
\[
\| f - m_N^f\|_{H^\beta(\tilde U)} \leq C_{\mathrm{Prop }\ref{prop:scat_zeros}}(\theta) h_{D_N, \tilde U} ^{\tau - \beta} \|f\|_{H^\tau(U)}, \qquad \text{for any } \beta \leq \tau,
\]
for all sets $D_N$ with $h_{D_N, \tilde U} \leq h_0(\tilde U) = C_{\mathrm{Prop} \ref{prop:scat_zeros}}' R_c$.
\end{proposition}
{Proposition \ref{prop:scat_zeros} allows us to bound the error $f - m_N^f$ locally in a subdomain $\tilde U$, in the sense that $\| f - m_N^f\|_{H^\beta(\tilde U)}$ can be bounded in terms of the local fill distance $h_{D_N, \tilde U}$. The proof is given in the appendix. }
The behaviour of the fill distance $h_{D_N, \tilde U}$ in terms of $N$ can be characterized explicitly for many point sets $D_N$, see e.g. \cite{t20,wbg21} and the references therein. The fastest possible decay as $N \rightarrow \infty$ is $h_{D_N, \tilde U} = \mathcal O(N^{-\frac{1}{d_u}})$, which is obtained for example by uniform tensor grids. As seen in Proposition \ref{prop:rand_fill} below, the fill distance of randomly sampled point sets also decays at (almost) the optimal rate.
\begin{proposition} \label{prop:rand_fill} Suppose
\begin{enumerate}
\item[(i)] $\tilde U \subseteq \mathbb R^{d_u}$ is a bounded Lipschitz domain that satisfies an interior cone condition, and $\tilde U$ is contained in the cube $B(u_c, R_c) = \{ u \in \mathbb{R}^{d_u} : \|u - u_c\|_\infty \leq R_c \}$, for some $u_c \in \mathbb{R}^{d_u}$ and $0 < R_c < \infty$,
\item[(ii)] $g : [0, \infty) \rightarrow [0, \infty)$ is continuous, monotonically increasing, and satisfies $g(0) = 0$ and $\lim_{x \downarrow 0} g(x) \exp(x^{-3d_u})= \infty$,
\item[(iii)] training points $\tilde D_N \subseteq \tilde U$ are sampled i.i.d. from a measure $\nu$ with density $\rho$ satisfying $\rho(u) \geq \rho_\mathrm{min} > 0$ for all $u \in \overline{\tilde U}$.
\end{enumerate}
Then there exists constants $C_{\mathrm{Prop } \ref{prop:rand_fill} }, C_{\mathrm{Prop } \ref{prop:rand_fill} }' > 0$ and $0 < C_{\mathrm{Prop } \ref{prop:rand_fill} }'' \leq 1$, independent of $N$, $u_c$ and $R_c$, such that for any $\varepsilon > 0$, we have
\begin{align*}
\mathbb{E}_\nu[g( h_{\tilde D_N, \tilde U})] &\leq C_{\mathrm{Prop } \ref{prop:rand_fill}}\, R_c \, g (N^{-\frac{1}{d_u} + \varepsilon}), \\
\mathbb{P}_\nu[h_{\tilde D_N, \tilde U} > h] &\leq C_{\mathrm{Prop } \ref{prop:rand_fill}}' \, \left( \frac{h}{R_c}\right)^{-d_u} \left( 1 - C_{\mathrm{Prop } \ref{prop:rand_fill}}'' \left( \frac{h}{R_c}\right)^{d_u} \right)^{N}, \quad \textrm{for any } 0 \leq h \leq R_c.
\end{align*}
\end{proposition}
The proof of Proposition \ref{prop:rand_fill} in the special case $\tilde U \subseteq [0,1]^{d_u}$ can be found in \cite{ocbg19}. The general case follows from a simple transformation $u \mapsto R_c u + u_c$. The constants $C_{\mathrm{Prop } \ref{prop:rand_fill}}$ and $C_{\mathrm{Prop } \ref{prop:rand_fill}}''$ deteriorate, to $\infty$ and $0$ respectively, as $\rho_\mathrm{min} \rightarrow 0$.
The results of Proposition \ref{prop:rand_fill} further extend to the setting where the training points are not sampled i.i.d. from $\nu$, but are instead generated from a uniformly ergodic Markov chain with $\nu$ as its stationary distribution \cite{ocbg19}.
Motivated by the results in Corollaries \ref{cor:post_conv_gp_phi} and \ref{cor:post_conv_gp_G}, we now study the quantitites $\mathbb{E}_\nu \left[ \|f - m_N^f\|_{L^2_{\mu^y}(U)} \right]$ and $\mathbb{E}_\nu \left[ \|k_N^{1/2}(\cdot, \cdot)\|_{L^2_{\mu^y}(U)}\right]$, where the design points $D_N$ are assumed to be sampled from $\nu$. We are particularly interested in the interplay between the sampling measure $\nu$ (with density $\rho$) and the posterior $\mu^y$ (with density $\pi^y$). Intuitively, we would expect $\nu \approx \mu^y$, since Gaussian process regression will be more accurate in regions with a higher density of training points.
\begin{theorem} \label{thm:gp_conv_weighted} Suppose $U$ is a bounded Lipschitz domain, $H_k(U)$ is isomorphic to the Sobolev space $H^\tau(U)$, and $ f \in H^\tau(U)$. Further suppose that for all $N \in \mathbb{N}$,
\begin{enumerate}
\item[(i)] $U_N \subseteq \mathbb{R}^{d_u}$ is compact and $U_N \subseteq \left\{u \in \mathbb{R}^{d_u} : \pi^y(u) \leq C_1^2 N^{-\frac{2 \tau}{d_u}} \right\}$,
\item[(ii)] the training points $D_N$ are sampled i.i.d. from a measure $\nu_N$ with density $\rho_N$ satisfying $\rho_N(u) \geq \rho_{\mathrm{min}} > 0$ for all $u \in \overline{U \setminus U_N}$, and $\rho_N(u) = 0$ otherwise,
\item[(iii)] $U \setminus U_N $ is a Lipschitz domain that satisfies an interior cone condition with angle $\theta$, and $U \setminus U_N $ is contained in the cube $B(u_c, R_c^N) = \{ u \in \mathbb{R}^{d_u} : \|u - u_c\|_\infty \leq R_c^N \}$, for some $u_c \in \mathbb{R}^{d_u}$ and $0 < R_c^N < C_2 \log N$.
\end{enumerate}
Then there exists a constant $C_{\mathrm{Thm } \ref{thm:gp_conv_weighted}} >0$, independent of $f$ and $N$, such that for all $0 \leq \beta \leq \tau$ and $\varepsilon > 0$ we have
\[
\mathbb{E}_{\nu_N} \left[ \|f - m_N^f\|_{H^\beta_{\mu^y}(U)} \right] \leq C_{\mathrm{Thm } \ref{thm:gp_conv_weighted}} \; N^{-\frac{\tau-\beta}{d_u} + \varepsilon} \, \|f\|_{H^\tau(U)}.
\]
Furthermore, for any partitioning $U \setminus U_N \subseteq \cup_{i=1}^r B_i$, where each $B_i$ is a bounded Lipschitz domain that satisfies an interior cone condition with angle $\theta'$, there exists a constant $C_{\mathrm{Thm } \ref{thm:gp_conv_weighted}}' $ such that for all $0 \leq \beta \leq \tau$ we have
\begin{align*}
&\mathbb{E}_{\nu_N} \left[ \|f - m_N^f\|_{H^\beta_{\mu^y}(U)} \mathrm{I}_{\{ h_{D_N, B_i} \, \leq \, h_0(B_i), 1 \leq i \leq n \}} \right] \\
&\leq C_{\mathrm{Thm } \ref{thm:gp_conv_weighted}}' \left( \left(\sup_{u \in U_N} \pi^y(u)\right)^{\frac{1}{2}} + \sum_{i=1}^{r} \left( \sup_{u \in B_i} \pi^y(u) \right)^{\frac{1}{2}} \, \mathbb{E}_{\nu_N} \left[ h_{D_N, B_i}^{\tau - \beta} \right] \right).
\end{align*}
\end{theorem}
The choice $\beta = 0$ in Theorem \ref{thm:gp_conv_weighted} gives a bound on $\|f - m_N^f\|_{L^2_{\mu^y}(U)}$, whereas $\beta = d_u/2 + \delta$, for any $\delta > 0$, gives a bound on $\|k_N^{1/2}(\cdot, \cdot)\|_{L^2_{\mu^y}(U)}$ via Proposition \ref{prop:predvar_sup} and the Sobolev embedding theorem as in \cite{st18}. The assumption that $U$ is bounded is required only since we need $\rho_\mathrm{min} > 0$ in assumption $(ii)$. The assumption that $R_c^N \leq C_2 \log N$ in $(iii)$ can be dropped since $U$ is bounded and hence $R_c^N$ is uniformly bounded in $N$. However, $R_c^N$ does appear as a factor in $C_{\mathrm{Thm } \ref{thm:gp_conv_weighted}}$ and so different choices of $R_c^N$ could lead to pre-asymptotic effects slowing down convergence. In assumption $(iii)$ we assume that the angle $\theta$ is independent of $N$, which ensures that the constant $C_{\mathrm{Prop }\ref{prop:scat_zeros}}(\theta)$ in Proposition \ref{prop:scat_zeros} is also independent of $N$.
The results in Theorem \ref{thm:gp_conv_weighted} give us insight into the interplay between the choice of training points $D_N$ and the posterior $\mu^y$. We introduce the set $U_N$ as the part of the parameter space $U$ which does not carry significant posterior mass. We then place training points only in $U \setminus U_N$, according to a sampling measure $\nu_N$. The first claim shows that even by ignoring the set $U_N$, and placing training points only where the posterior density is sufficiently large, we still obtain (almost) the optimal rate of convergence in $N$. Optimality here refers to the fastest obtainable rate $N^{-1/d_u}$ of the fill distance in $d_u$ dimensions, as well as the fastest obtainable rate $N^{-\tau/d_u}$ for the approximation of $f \in H^\tau(U)$ in $L^2(U)$ by $N$ function values (see e.g. \cite{t20} and the references therein). The first claim holds for any choice of sampling measure $\nu_N$ on $U \setminus U_N$, but in general we expect $C_{\mathrm{Thm } \ref{thm:gp_conv_weighted}}$ to deteriorate as $\rho_{ \mathrm{min}}$ gets close to zero.
The second claim shows that the sampling measure $\nu_N$ should be chosen such that the local fill distance $h_{D_N, B_i}$ is small where the posterior mass $\sup_{u \in B_i}\pi^y(u)$ is large. In other words, we want to put training points in the regions with highest posterior density.
We also note that the bound in the second claim suggests oversampling in the tails of the posterior density $\pi^y$, since the fill distance should be balanced with the {\em square-root of $\pi^y$}. This might be related to the fact that extrapolation is generally much harder than interpolation.
Finally, we remark that the above observations agree with previous studies on the subject. In \cite{sn17}, the authors develop a sequential strategy for optimally choosing the training points $D_N$, in the context of the marginal approximation \eqref{eq:rad_nik_marginal}. In practice this results in the training points being placed in regions of high posterior density. Similarly, the choice of design points attained by the calibrate-emulate-sample approach in \cite{cleary2021calibrate,dunbar2021calibration}, gives training points in regions of high posterior density for the solution of the Bayesian inverse problem in the GCM example from subsection \ref{ssec:exbip}. The results in this paper are the first to provide a theoretical justification for this choice of training points in terms of accuracy of the approximate posterior distributions.
The related problem of optimal choice of training points $D_N$ in Bayesian quadrature, i.e. when we are interested in bounding the error
\[
\left| \int_U f(u) \pi(u) \mathrm{d} u - \int_U m_N^f(u) \pi(u) \mathrm{d} u \right|,
\]
for some target measure $\pi$, is studied numerically in \cite{boccg17}. They observe that choosing the design points $D_N$ according to a slightly inflated version of $\pi$, i.e. oversampling in the tails of $\pi$, seems to give the smallest error.
\section{Numerical Examples}\label{sec:num}
We finish this work with two simple illustrative examples. In the first example, our function is $f(u)=u$, and our posterior measure is $\mu \sim \mathcal{N}(1,1)$. We then take our design measure to be $\nu \sim \mathcal{N}(1,\sigma^{2})$. We are interested in analyzing the following error quantity
\begin{equation} \label{eq:error}
e(N,\nu)=\int_{-\infty}^{\infty} \mathbb{E}_{\nu}| m^f_{N}(u)-f(u)|^{2}\mu(du)
\end{equation}
both as a function of the value of the variance $\sigma^{2}$ of the design measure $\nu$ as well as the number of points $N$ used in the Gaussian process regression. In all our calculations we have used $10^{3}$ realizations for the design points in order to approximate the expectation in \eqref{eq:error}. Note that this example does not fulfill all assumptions of Theorem \ref{thm:gp_conv_weighted}, since $U$ is unbounded and there is no a-priori truncation of the parameter space by discarding $U_N$, but the behaviour is still as {predicted by that theorem}.
As we can in Figure \ref{fig:comparison_gaussian}, the results agree with the Theorem \ref{thm:gp_conv_weighted}. In particular, as expected we observe that as the number of design points $N$ increases $e(N,\nu)$ decreases, and at the same rate for different choices of $\sigma$. Furthermore, perhaps more interestingly we observe that as we increase the variance of the design measure the error overall decreases until it reaches a minimum value nearby the value of the variance of the true posterior and then slowly increases.
\begin{figure}
\begin{center}
\subfloat{\includegraphics[width=.45\textwidth]{Gaussian_mu_nu.png}}\quad
\subfloat{\includegraphics[width=.45\textwidth]{Gaussian_mu_nu1.png}}\\
\end{center}
\caption{$e(N,\nu)$ as a function of $\sigma$ and $N$ for the case of Gaussian posterior $\mu$ and design measure $\nu$, with Gaussian covariance kernel $k$.}
\label{fig:comparison_gaussian}
\end{figure}
{In the second numerical experiment} we now repeat the first experiment, again with $f(u)=u$, but now with the true posterior measure $\mu \sim U[-1,1]$ and the design measure $\nu \sim U[-\epsilon,\epsilon]$. As we can see in Figure \ref{fig:comparison_uniform} the results are similar to the Gaussian case studied before with the error reducing as a function of $N$ for a fixed value of $\epsilon$.
\begin{figure}
\begin{center}
\subfloat{\includegraphics[width=.45\textwidth]{uniform_mu_nu.png}}\quad
\subfloat{\includegraphics[width=.45\textwidth]{uniform_mu_nu1.png}}\\
\end{center}
\caption{$e(N,\nu)$ as a function of $\epsilon$ and $N$ for the case of uniform posterior $\mu$ and design measure $\nu$, with Gaussian covariance kernel $k$.}
\label{fig:comparison_uniform}
\end{figure}
\section*{Acknowledgements}
ALT would like to thank the Isaac Newton Institute for Mathematical Sciences, Cambridge, for support and hospitality during the programme {\em Mathematical and statistical foundations of future data-driven engineering} where work on this paper was undertaken. This work was supported by EPSRC grant no EP/R014604/1.
AMS is also grateful to the National Science Foundation (grant
AGS-1835860).
\bibliographystyle{siam}
| {'timestamp': '2023-02-10T02:09:08', 'yymm': '2302', 'arxiv_id': '2302.04518', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04518'} | arxiv |
\section{Introduction}
\label{sec:1}
\IEEEPARstart{3}{D} reconstruction is an increasingly critical module in recent photogrammetric systems. It has been extensively utilized for constructing digital cities\cite{xiong2015flexible}, documenting cultural heritages\cite{murtiyoso2017documentation}, and inspecting tunnel cracks\cite{liao2022automatic}, etc. 3D reconstruction can be implemented by using varying instruments, e.g., LiDAR (Light Detection and Ranging) scanners, TOF (Time of Flight) sensors, and optical cameras. The popularity of image sensors and the development of processing techniques have led to the vast usage of image-based 3D reconstruction techniques among all available sensors in the field of photogrammetry and remote sensing (RS), such as satellite and aerial-based images for urban buildings\cite{zhang2022building}. Due to the relatively high acquisition altitudes and nearly vertical viewpoints, satellite and aerial-based RS images mainly observe building roofs over large-scale regions.
\begin{figure}[t!]
\centering
\includegraphics[width=0.48\textwidth]{Figure1}
\caption{3D reconstruction based on spherical images. (a) a spherical image and one enlarged region for detail comparison; (b) the sparse reconstruction model; and (c) the dense reconstruction model after texture mapping.}
\label{fig:figure1}
\end{figure}
With the increasing demands for fine-scale modeling, such as building facades and indoor environments, recent years have witnessed explosive development of 3D reconstruction based on low-altitude unmanned aerial vehicles (UAV)\cite{jiang2021unmanned,li2022optimized} or terrestrial mobile mapping systems (MMS)\cite{puente2013review}. Compared with satellite and airborne-based RS platforms, these near-ground platforms have the advantages of flexible instrument integration and multi-view imaging, which can record images with extremely high spatial and temporal resolutions. Therefore, UAV and MMS have been used as essential RS platforms for data acquisitions in urban and indoor scenes\cite{anguelov2010google}.
Perspective cameras are the most widely used sensors for image-based 3D reconstruction, especially in aerial and close-range photogrammetry. However, due to their limited FOV (Field of View), perspective cameras cannot cope with the characteristics of data acquisition in street-view and indoor environments\cite{da2019dense}, which can be observed from two main aspects. On the one hand, surrounding environments are different from aerial photogrammetry. In street-view and indoor environments, the trajectory of data acquisitions is limited by street structures and indoor layouts, which causes sudden viewpoint changes at turning points and track failure between camera frames\cite{ji2020panoramic}. On the other hand, the observation regions are extended from the single-direction records in aerial photogrammetry to the omnidirectional acquisitions in street-view and indoor environments. It requires more images at each camera exposure position and incredibly increases acquisition time consumption\cite{zhang2016benefit}. Thus, effective imaging techniques are needed for 3D reconstruction in street-view and indoor situations given these considerations.
Spherical cameras, also termed 360 cameras or omnidirectional cameras, can record all surrounding environments using one camera exposure. In contrast to traditional perspective cameras, recorded images of spherical cameras can cover the whole scene, whose FOV ranges are 360 and 180 degrees in horizontal and vertical directions, respectively. Due to the advantage of spherical cameras, spherical images have been adopted for 3D modeling in street-view and indoor environments\cite{bruno2019accuracy,fangi2018improving}. In addition, low-cost consumer-grade spherical cameras like the Insta360 and Ricoh theta\cite{gao2022review} are growing in popularity, which greatly simplifies data acquisition and encourages their use in a variety of fields, such as damaged building inspection\cite{jhan2021integrating}, urban environment analysis\cite{biljecki2021street}, urban geo-localization\cite{cheng2018crowd,wen2020urbanloco}, and heritage modeling\cite{fangi2013photogrammetric}. Thus, spherical images have become one of the most popular RS data sources for 3D reconstruction, especially for street-view and indoor environments \cite{kang2020review}, as illustrated in Fig. \ref{fig:figure1}.
Spherical images, however, have different characteristics when compared with traditional perspective images in the context of image-based 3D reconstruction\cite{pagani2011structure}. One of the most important differences is the camera imaging model. For perspective cameras, 3D scenes are mapped onto 2D image planes through perspective projection; on the contrary, spherical projection occurs in spherical cameras, which describes the locations of 3D points using 3D spherical coordinate systems. Consequently, 3D reconstruction of spherical images has technique differences from perspective images. In addition, fewer commercial and open-source solutions are designed for the 3D reconstruction of spherical images when compared with perspective images. Therefore, this study aims to give a review of reported techniques related to 3D reconstruction of spherical images. The main contributions of this study include: (1) we give a systematic and extensive review of recent techniques for 3D reconstruction of spherical images; (2) we present the most promising applications related to 3D reconstruction of spherical images; and (3) we also conclude the prospects for 3D reconstruction of spherical images from the aspects of technique development and application promotion. The purpose of this study is to provide useful clues to guide further research for 3D reconstruction of spherical images.
This paper is organized as follows. The state-of-the-art of data acquisition, image matching, image orientation, and dense matching for 3D modeling of spherical images is reviewed in Section \ref{sec:2}. Section \ref{sec:3} examines prospective applications for 3D reconstruction spherical images, which is followed by the primary prospects presented in Section \ref{sec:4}. Finally, Section \ref{sec:5} concludes this work and future studies.
\section{Techniques}
\label{sec:2}
This section presents the recent techniques for 3D reconstruction of spherical images. The main workflow for the photogrammetric 3D reconstruction is first introduced, followed by data acquisition with varying spherical cameras, image matching for establishing correspondences, image orientation for estimating camera poses, and dense matching for producing point clouds. The details are listed as follows.
\subsection{Main workflow}
\label{sec:2.1}
According to the literature, there are five significant steps in the workflow of image-based 3D reconstruction, i.e., data acquisition using photogrammetric systems, image matching to establish correspondences, image orientation to determine camera poses, dense matching to produce point clouds, and point cloud meshing and texturing. Spherical images differ in the camera imaging model and image representation format compared with classical perspective images, which causes extra considerations in the first four steps. Thus, this study reviews data acquisition, image matching, image orientation, and dense matching, and the main workflow of 3D reconstruction for spherical images is presented in Fig. \ref{fig:figure2}.
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure2}
\caption{ The main workflow of 3D reconstruction for spherical images.}
\label{fig:figure2}
\end{figure}
\subsection{Data acquisition}
\label{sec:2.2}
Data acquisition is the first step in the main workflow of 3D reconstruction for spherical images. In this section, three topics related to data acquisition would be presented, i.e., spherical cameras, image representations, and acquisition platforms. The details are shown in the following subsections. In the literature, there exist some useful and public datasets captured by sphere cameras, which is presented in Table \ref{tab:table8}.
\begin{table*}[t!]
\caption{A list of benchmark datasets for spherical images.}
\label{tab:table8}
\centering
\makebox[\textwidth]{
\begin{tabular}{p{0.15\textwidth} p{0.05\textwidth} p{0.2\textwidth} p{0.4\textwidth}}
\toprule
\textbf{Name} &
\textbf{Year} &
\textbf{Purpose} &
\textbf{Website} \\
\midrule
\multirow{2}{0.15\textwidth}{3D60}
& 2021
& Dense matching
& \url{https://vcl3d.github.io/3D60}\\
& \multicolumn{3}{L{0.6\textwidth}}{It provides composited and realistically scanned 3D datasets of interior spaces that are used to generate high-quality, densely annotated spherical panoramas\cite{zioulis2018omnidepth}.} \\
\midrule
\multirow{2}{0.15\textwidth}{Re-rendering subsets of Stanford 2D-3D and Matter-port3D}
& 2020
& Dense matching
& \url{https://albert100121.github.io/360SD-Net-Project-Page/}\\
& \multicolumn{3}{L{0.6\textwidth}}{It contains re-rendered subsets of the Stanford 2D-3D and Matter-port3D data sets, which consists of 3,577 1024 x 512 stereoscopic ERP images\cite{wang2020360sd}.} \\
\midrule
\multirow{2}{0.15\textwidth}{Structured3D}
& 2020
& Structured 3D modeling
& \url{https://structured3d-dataset.org/}\\
& \multicolumn{3}{L{0.6\textwidth}}{It provides 196,515 frames from 3,500 synthetic, photo-realistic house designs, and each scene has 1024 × 512 ERP images at three different light conditions and camera poses\cite{chang2017matterport3d}.} \\
\midrule
\multirow{2}{0.15\textwidth}{Re-rendering subset of Stanford 2D-3D}
& 2019
& Dense matching
& \url{https://github.com/pokonglai/ods-net}\\
& \multicolumn{3}{L{0.6\textwidth}}{It provides a re-rendered subset of the Stanford 2D-3D dataset. It provides about 50,000 256 × 128 stereo ERP images separated by a 6.5cm horizontal baseline\cite{lai2019real}.} \\
\midrule
\multirow{2}{0.15\textwidth}{PanoSUNCG}
& 2018
& Camera motion and depth
& \url{https://fuenwang.ml/project/360-depth/} \\
& \multicolumn{3}{L{0.6\textwidth}}{It provides about 25,000 images captured by SUNCG from 103 different scenes in five camera paths, including color, depth, and rendering tracks\cite{wang2018self}.}\\
\midrule
\multirow{2}{0.15\textwidth}{Stanford 2D-3D}
& 2017
& Dense matching
& \url{http://3dsemantics.stanford.edu} \\
& \multicolumn{3}{L{0.6\textwidth}}{It contains 1,413 full fields of view indoor realistic capture of six wide range of areas, which provides depth, normal, and semantic mapping\cite{armeni2017joint}.}\\
\midrule
\multirow{2}{0.15\textwidth}{Matterport3D}
& 2017
& Dense matching
& \url{https://niessner.github.io/Matterport/} \\
& \multicolumn{3}{L{0.6\textwidth}}{It provides 10,800 CMP panoramas from 90 real building scale scenes, including depth, camera position, and semantic segmentation\cite{chang2017matterport3d}.}\\
\bottomrule
\end{tabular}
}
\end{table*}
\subsubsection{ Spherical camera}
\label{sec:2.2.1}
The development of spherical cameras can be traced back to two centuries ago\cite{luhmann2004historical}, which were invented for the documentation of ancient buildings and cultural heritages. For the purpose of surveying and mapping, spherical cameras were first used in close-range photogrammetry, in which spherical images were usually captured by rotating camera around the projection center or stitching overlapped images through image matching. For aerial photogrammetry, spherical cameras are designed as an integration instrument that consists of several well-calibrated perspective cameras.
(1) camera category
In recent years, the performance of spherical cameras has been greatly improved by the progress in the fields of camera sensors and image processing techniques, e.g., high-resolution digital cameras and high-precision stitching algorithms. Based on the design principle, spherical cameras can be divided into three major categories, i.e., dioptric cameras, catadioptric cameras, and polydioptric cameras\cite{gao2022review,scaramuzza2014omnidirectional}:
\begin{itemize}
\item \textbf{Dioptric cameras} use a particular lens group to refract rays that compress the direction of the light entering the subsequent lens group. The obtained FOV reaches 360 degrees in the horizontal direction and is larger than 90 degrees in the vertical direction. Thus, two lenses combined back to back can capture the full surroundings. Fig. \ref{fig:figure3}(a) is an example of the fisheye camera.
\item \textbf{Catadioptric cameras} utilize the combination of a lens group for ray refraction and a special mirror for ray reflection, e.g., a parabolic, hyperbolic, or elliptical mirror, with a standard camera to achieve the FOV of 360 degrees and greater than 100 degrees in the horizontal and vertical direction, respectively. Compared with fisheye cameras, this design can reflect the surrounding light into the subsequent lens. Fig. \ref{fig:figure3}(b) is an illustration of the catadioptric camera.
\item \textbf{Polydioptric cameras} adopt multiple dioptric cameras to obtain a real spherical FOV, i.e., 360 degrees and 180 degrees in the horizontal and vertical directions, respectively, in which dioptric cameras have overlapping FOV to facilitate image stitching. Fig. \ref{fig:figure3}(c) shows an example of a polydioptric camera comprising 16 cameras.
\end{itemize}
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth]{Figure3}
\caption{The design principle of three commonly used spherical cameras. (a) dioptric camera; (b) catadioptric camera; and (c) polydioptric camera.}
\label{fig:figure3}
\end{figure}
(2) spherical camera
Among the three categories, polydioptric cameras have become the most extensively used spherical cameras for both professional and consumer-grade applications because of two main reasons. On the one hand, it can provide the full omnidirectional imaging technique; on the other hand, recorded images have extremely high resolutions due to the use of multiple cameras. Table \ref{tab:table1} presents the detailed configurations of well-known spherical cameras, including the consumer-grade cameras, e.g., the Ricoh Theta series and Insta360 Sphere, and the professional cameras, e.g., Insta360 Pro2 and Teledyne FLIR Ladybug5+. Except for Weiss AG Civetta, all the other spherical cameras are designed by using the polydioptric mechanism. For consumer-grade cameras, the lens number is usually configured as 2 or 3. The illustration of the cameras is presented in Fig. \ref{fig:figure4}. In general, there are two ways to increase the resolution of recorded images, i.e., increasing the number of integrated cameras or exchanging the style of image recording. The former has been used in Panono and Ladybug5+, which enables instant image recording, e.g., equipped with an MMS system. The latter has been used in Weiss AG Civetta to obtain extremely high resolution. This strategy, however, sacrifices the capability of instant acquisition, and it is more suitable for site-based image recording.
\begin{table*}[!t]
\caption{The detailed configurations of well-known spherical cameras. Noticeably, the resolution for Ladybug5+ is the image dimension of an individual camera.}
\label{tab:table1}
\centering
\makebox[\linewidth]{
\begin{tabular}{l l l l l l l}
\toprule
\textbf{Camera} &
\textbf{Manufacture} &
\textbf{Principle} &
\textbf{Lens} &
\textbf{Resolution(pixel)} &
\textbf{Weight (kg)} &
\textbf{Professional}\\
\midrule
Gear360 & Samsung & polydioptric & 2 & 4096×2048 & 0.13 & $\times$ \\
Theta Z1 & Ricoh & polydioptric & 2 & 6720×3360 & 0.18 & $\times$ \\
Theta X & Ricoh & polydioptric & 2 & 11008×5504 & 0.17 & $\times$ \\
Max 360 & GoPro & polydioptric & 3 & 5760×2880 & 0.16 & $\times$ \\
Sphere & Insta360 & polydioptric & 2 & 6080×3040 & 0.19 & $\times$ \\
Pro 2 & Insta360 & polydioptric & 6 & 7680×7680 & 1.55 & $\checkmark$ \\
Panono & Professional360 & polydioptric & 36 & 16000×8000 & 0.48 & $\checkmark$ \\
Ladybug5+ & Teledyne FLIR & polydioptric & 6 & 2048×2464* & 3.00 & $\checkmark$ \\
Civetta & Weiss AG & dioptric & / & 230 M & 5.70 & $\checkmark$ \\
\bottomrule
\end{tabular}}
\end{table*}
\begin{figure}[!t]
\centering
\subfloat[]{\includegraphics[height=0.15\textwidth]{Figure4-a
\label{fig:figure4-a}}
\subfloat[]{\includegraphics[height=0.15\textwidth]{Figure4-b
\label{fig:figure4-b}}
\subfloat[]{\includegraphics[height=0.15\textwidth]{Figure4-c
\label{fig:figure4-c}} \\
\subfloat[]{\includegraphics[height=0.15\textwidth]{Figure4-d
\label{fig:figure4-d}}
\subfloat[]{\includegraphics[height=0.15\textwidth]{Figure4-e
\label{fig:figure4-e}}
\subfloat[]{\includegraphics[height=0.15\textwidth]{Figure4-f
\label{fig:figure4-f}} \\
\subfloat[]{\includegraphics[height=0.15\textwidth]{Figure4-g
\label{fig:figure4-g}}
\subfloat[]{\includegraphics[height=0.15\textwidth]{Figure4-h
\label{fig:figure4-h}}
\subfloat[]{\includegraphics[height=0.15\textwidth]{Figure4-i
\label{fig:figure4-i}}
\caption{The illustration of the well-known spherical cameras. (a) Gear360; (b) Theta Z1; (c) Theta X; (d) Max 360; (e) Sphere; (f) Pro 2; (g) Panono; (h) Ladybug5+; (i) Civetta.}
\label{fig:figure4}
\end{figure}
\subsubsection{Image representation}
\label{sec:2.2.2}
Spherical images record the surrounding environments at each camera exposure position. In contrast to the 2D plane representation of perspective images, there are three types of image representation methods for spherical images\cite{da20223d}, as shown in Fig. \ref{fig:figure5} .
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure5}
\caption{Three typical formats for spherical image representation: (a) spherical representation; (b) equirectangular representation; (c) cubic-map representation.}
\label{fig:figure5}
\end{figure}
\begin{itemize}
\item The first one is the spherical representation. Objects in surrounding environments are mapped onto a sphere, as presented in Fig. \ref{fig:figure5} (a). Spherical representation is useful for panoramic navigation, which has been widely used for street-view navigation, e.g., Google and Baidu Street View. Spherical representation, however, is unsuitable for image processing and hardware storage.
\item Equirectangular images, which are produced by the equirectangular projection, are a common representation, as presented in Fig. \ref{fig:figure5} (b). Similar to perspective images, equirectangular images can be considered typical images and processed by existed algorithms, e.g., feature extraction and matching\cite{pagani2011structure}. Because of the projection from 3D sphere to 2D plane, geometric distortions are introduced to equirectangular images, especially for the regions near sphere poles.
\item The third image representation, i.e., cubic-map representation, is created to alleviate the distortion in equirectangular projection, which converts one spherical image into six concentric perspective images, as presented in Fig. \ref{fig:figure5} (c). Each cubic-map image can be considered as one typical perspective image whose projection distortions have been removed. However, this representation would decrease the overlap region between frames and increase the image number for image orientation.
\end{itemize}
Since the simple and typical format, equirectangular representation has been extensively adopted for spherical images, including well-known open-source and commercial software packages, e.g., OpenMVG\cite{moulon2016openmvg}, Agisoft Metashape \cite{2022Agisoft}, and Pix4dMapper \cite{2022Pix4dMapper}. Thus, this review would pay more attention to the equirectangular representation of spherical images.
\subsubsection{Acquisition platform}
\label{sec:2.2.3}
Depending on their individual properties, spherical cameras can be operated manually or with various remote sensing platforms. Since spherical cameras are complementary to aerial RS images, the most extensively adopted platforms can be moving vehicles\cite{anguelov2010google}, ground-fixed tripods\cite{herban2022use}, and handheld poles. These platforms record images along urban streets or around center landmarks, as presented in Fig. \ref{fig:figure6}(a) and Fig. \ref{fig:figure6}(b).
In recent years, UAV platforms are also designed to accommodate spherical cameras\cite{zhang2020uav}, which can record spherical images from relatively high altitudes, as shown in Fig. \ref{fig:figure6}(c). Compared with spherical cameras for the other two platforms, e.g., Ladybug5+ for moving vehicles and Civetta for ground-fixed tripods, spherical cameras for UAVs are seriously strict to the weight and dimension of sensors due to the limited payload weight and flight endurance. In addition, spherical cameras are required instant recording ability when mounted on moving vehicles and UAV platforms, which would restrict the resolution of recorded images. On the contrary, spherical cameras designed for ground-fixed tripods can record images with extremely high spatial resolution. Fig. \ref{fig:figure7} shows the images recorded by the Weiss AG Civetta spherical camera, from which details can be observed from both outdoor and indoor recorded spherical images.
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth]{Figure6}
\caption{Different acquisition platforms and corresponding sample images. (a) moving vehicles; (b) ground-fixed tripods; and (c) unmanned aerial vehicles.}
\label{fig:figure6}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth]{Figure7}
\caption{Spherical images recorded by the Weiss AG Civetta camera \cite{2022WeissAg}. (a) the example for the outdoor scene; and (b) the example for the indoor scene.}
\label{fig:figure7}
\end{figure}
\subsection{Image matching}
\label{sec:2.3}
Image matching is the second step in the main workflow of 3D reconstruction for spherical images, which aims to establish correspondence matches between image pairs with high inlier ratio and even spatial distribution. In the literature, image matching have been a well-studied topic in the fields of photogrammetry and computer vision, which can be verified from earlier hand-crafted algorithms to recent learning-based networks\cite{hartmann2016recent,jiang2021learned,ma2021image}. In this section, we focus on reported methods that can be utilized for spherical images. Table \ref{tab:table2} lists the algorithms for image matching.
\begin{table*}[t!]
\caption{The algorithms for feature matching of spherical images.}
\label{tab:table2}
\centering
\makebox[\textwidth]{
\begin{tabular}{p{0.15\textwidth} p{0.1\textwidth} p{0.1\textwidth} p{0.4\textwidth}}
\toprule
\textbf{Name} &
\textbf{Language} &
\textbf{Year} &
\textbf{Website} \\
\midrule
\multirow{2}{0.1\textwidth}{OmniCV}
& C++
& 2020
& \url{https://github.com/kaustubh-sadekar/OmniCV-Lib}\\
& \multicolumn{3}{L{0.6\textwidth}}{A computer vision library for omnidirectional cameras, e.g., dioptric, catadioptric and polydioptric cameras. It provides tools for format conversion and image viewing.} \\
\midrule
\multirow{2}{0.1\textwidth}{SPHORB}
& C++
& 2015
& \url{https://github.com/tdsuper/SPHORB}\\
& \multicolumn{3}{L{0.6\textwidth}}{A package based on a nearly regular hexagonal grid parametrization of the sphere geodesic grid, which adapts planar ORB to the spherical domain\cite{zhao2015sphorb}.} \\
\midrule
\multirow{2}{0.1\textwidth}{SSIFT}
& Matlab
& 2009
& \url{https://github.com/Artcs1/Keypoints}\\
& \multicolumn{3}{L{0.6\textwidth}}{It transforms the plane SIFT to spherical coordinates and proposes two descriptors for feature matching\cite{cruz2012scale}.} \\
\midrule
\multirow{2}{0.1\textwidth}{Tangent Images}
& Python
& 2020
& \url{https://github.com/meder411/Tangent-Images}\\
& \multicolumn{3}{L{0.6\textwidth}}{Distortion is alleviated by rendering the spherical image as a set of local planar image grids tangent to the subdivided icosahedron\cite{eder2020tangent}.} \\
\midrule
\multirow{2}{0.1\textwidth}{UGSCNN}
& Python
& 2019
& \url{https://github.com/maxjiang93/ugscnn}\\
& \multicolumn{3}{L{0.6\textwidth}}{A CNN network for spherical signals based on parameterized differential operators on unstructured grids\cite{jiang2019spherical}.}\\
\midrule
\multirow{2}{0.1\textwidth}{DEEPSPHERE}
& Python
& 2020
& \url{https://github.com/deepsphere}\\
& \multicolumn{3}{L{0.6\textwidth}}{A graphical representation of a sampling sphere that achieves a controlled balance between efficiency and rotationally equivalent variance\cite{defferrard2020deepsphere}.} \\
\midrule
\multirow{2}{0.1\textwidth}{S2CNN}
& Python
& 2018
& \url{https://github.com/jonkhler/s2cnn}\\
& \multicolumn{3}{L{0.6\textwidth}}{A library for the rotation equivariant CNNs for spherical signals (e.g. omnidirectional images, signals on the globe)\cite{cohen2018spherical}.} \\
\midrule
\multirow{2}{0.1\textwidth}{SphereNet}
& Python
& 2018
& \url{https://github.com/ChiWeiHsiao/SphereNet-pytorch}\\
& \multicolumn{3}{L{0.6\textwidth}}{A network that adjusts sampling positions of CNN kernels, which can transfer existed perspective networks to the omnidirectional case\cite{coors2018spherenet}.} \\
\bottomrule
\end{tabular}
}
\end{table*}
\subsubsection{Feature detection and description}
\label{sec:2.3.1}
The purpose of feature detection and description is to detect distinguishable keypoints that can be found in overlapped images and calculate their robust descriptors that are invariant to the changes in scale, viewpoint, and illumination. Due to the equirectangular projection of spherical images, more serious geometric distortions disturb feature detection and description. According to the strategy used, existed methods can be divided into four groups, including classical methods, 2D plane-based methods, 3D sphere-based methods, and learning-based methods. The details of these four groups are listed in Table \ref{tab:table3}.
\begin{table*}[t!]
\centering
\caption{Method comparison for feature detection and description.}
\label{tab:table3}
\makebox[\linewidth]{
\begin{tabular}{p{0.1\textwidth} p{0.15\textwidth} p{0.5\textwidth}}
\toprule
\textbf{Category} & \textbf{Methods} & \textbf{Advantages and disadvantages} \\
\midrule
Classical methods & SIFT\cite{lowe2004distinctive},\cite{yu2011asift}, SURF\cite{bay2008speeded}, ORB\cite{rublee2011orb}
& \textbf{\emph{Advantages}}: (1) existed algorithms can be used directly; (2) high efficiency without other computational costs.
\textbf{\emph{Disadvantages}}: (1) do not consider geometric distortions. \\
\midrule
2D plane-based methods & Local\cite{chuang2018rectified},\cite{eder2020tangent}, semi-global\cite{taira2015robust}, global\cite{wang2018cubemapslam}
& \textbf{\emph{Advantages}}: (1) decrease local or global geometric distortions.
\textbf{\emph{Disadvantages}}: (1) require extra time costs for image rectification. \\
\midrule
3D sphere-based methods & SSIFT\cite{cruz2012scale}, SPHORB\cite{zhao2015sphorb}, BRISKS\cite{guan2017brisks}
& \textbf{\emph{Advantages}}: (1) avoid geometric distortions by using spherical coordinates.
\textbf{\emph{Disadvantages}}: (1) requires extra time costs for image reprojection; (2) cannot use existed algorithms. \\
\midrule
Learning-based methods & ContextDesc\cite{luo2019contextdesc}, LoFRT\cite{sun2021loftr}, SuperGlue\cite{cui20213d}, sphere CNN\cite{su2017learning}
& \textbf{\emph{Advantages}}: (1) leverage the power of CNN to cope with low textures and repetitive patterns for indoor scenes.
\textbf{\emph{Disadvantages}}: (1) depend on large training datasets; (2) retraining of existed networks or design of new networks.
\\
\bottomrule
\end{tabular}
}
\end{table*}
(1) Classical methods
Classical feature detection and description methods can also be applied to equirectangular images because of two main reasons. On the one hand, image regions near the sphere equator have relatively small distortions after equirectangular projection; on the other hand, most data acquisition campaigns are conducted by fixing the roll and pitch angles of sphere cameras, such as cameras mounted on moving vehicles for street-view images\cite{torii2009google} or on fixed tripods for corridor photos\cite{herban2022use}. These two conditions ensure the repeatability of extracted features on equirectangular images.
In the literature, classical feature detectors have been applied to equirectangular images, including floating and binary feature descriptors\cite{bay2008speeded,lowe2004distinctive,morel2009asift,rublee2011orb}. \cite{torii2009google} used SURF (Speeded-up Robust Features) to extract features from street-view images and conduct SfM-based image orientation. Inspired by ASIFT (Affine Scale Invariant Feature Transform), \cite{pagani2011structure} proposed a spherical variant of ASIFT for feature detection. Thus, existed algorithms can be directly utilized for equirectangular images, which can achieve high efficiency without extra computational costs. Fig. \ref{fig:figure8} gives an example of feature extraction using the classical SIFT algorithm. For the image pair shown in Fig. \ref{fig:figure8}(a) and Fig. \ref{fig:figure8}(b), a total number of 746 and 392 correspondences are matched respectively.
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth]{Figure8}
\caption{The influence of geometric distortion on feature matching. The value in each image indicates the rotation angle around the X axis, and the yellow circles represent the matched feature points between the two images.}
\label{fig:figure8}
\end{figure}
(2) 2D plane-based methods
When spherical images are rotated around the X (pitch angle) or Z (roll angle) axis, the image appearances near the sphere equator would change obviously, which causes serious geometric distortions. For visual analysis, Fig. \ref{fig:figure8} illustrates three images that are captured by rotating the X axis with the angle of 0, 45, and 75 degrees, respectively. It is clearly shown that geometric distortions increase dramatically with the increase of rotation angles. Because of the introduced distortions, the number of correspondences decreases in these two corresponding regions. Feature detection and description must therefore receive more attention.
In the field of photogrammetry, image rectification has been widely used to decrease the influence of geometric distortions on feature detection and description \cite{jiang2017board}. Similar to the rectification strategy, some research has been documented for spherical images, which can be divided into three main groups, i.e., global methods, semi-global methods, and local methods.
\begin{itemize}
\item \textbf{Global methods} aim to rectify the whole image, and cubic-map representation has been the classical strategy, as presented in Fig. \ref{fig:figure5}(c). For example, \cite{wang2018cubemapslam} proposed reprojecting spherical images into cubic-map images for feature detection and implementing a SLAM (Simultaneous Localization and Mapping) system, termed CubemapSLAM.
\item \textbf{Semi-global methods} are designed to reproject a proportion of spherical images and conduct feature detection on the rectified image region, which is inspired by the truth that small distortions exist near the sphere equator, as presented in Fig. \ref{fig:figure9}(b). \cite{taira2015robust} proposed generating three reprojected equirectangular images by a rotation of 0, 60, and 120 degrees around X axis, respectively, and detecting features from the equator regions in each rectified equirectangular image.
\item \textbf{Local methods} aim to rectify local image regions around detected feature points and calculate their descriptors on the rectified image patches\cite{eder2020tangent,chuang2018rectified}, as presented in Fig. \ref{fig:figure9}(a). In the work of \cite{chuang2018rectified}, image patches around feature points are projected to the tangent planes across these feature points, and SURF descriptors are computed from these patches with similar perspective views. Although 2D plane-based methods are based on a simple principle, extra time costs are required in image rectification.
\end{itemize}
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth]{Figure9}
\caption{The illustration of 2D plane-based methods. (a) local methods based on the tangent plane projection of feature point patches; (b) semi-global methods based on the projection around the sphere equator region. Red shapes indicate detected features.}
\label{fig:figure9}
\end{figure}
(3) 3D sphere-based methods
In contrast to image geometric rectification, some research starts from scratch to design and implement algorithms for feature detection and description of spherical images\cite{cruz2012scale,guan2017brisks,zhao2015sphorb}. The primary motivation is to avoid the high computational costs consumed in image geometric rectification and decrease the influence of geometric distortions introduced by equirectangular projection. Naturally, the spherical representation is the optimal solution instead of the equirectangular representation used in the above-mentioned methods. Thus, existed research exploits the spherical coordinate to design new feature detection and description algorithms. The core of these methods is how to construct the scale space pyramid on spherical images\cite{arican2012scale}. Like SIFT, \cite{cruz2012scale} implemented a spherical SIFT, termed SSIFT, which directly simulates image representation, scale space construction, extreme point detection, and descriptor calculation in the spherical coordinates, and shows better performance compared with classical SIFT. Inspired by this work, others attempt to improve the efficiency of SSIFT by replacing the time-consuming SIFT with binary detectors and descriptors, such as SPHORB\cite{zhao2015sphorb} and BRISKS\cite{guan2017brisks}. Fig. \ref{fig:figure10} shows feature matching of ORB and SPHORB. In a word, 3D sphere-based methods can avoid the geometric distortions in equirectangular images with the sacrifice of redesigning the basic algorithmic modules from scratch.
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth]{Figure10}
\caption{The comparison of feature detection and matching between ORB and SPHORB. (a) the matching result of ORB; (b) the matching result of SPHORB.}
\label{fig:figure10}
\end{figure}
(4) Learning-based methods
Due to the powerful representation learning ability, CNN (Convolutional Neural Network) based deep learning networks have been extensively used for feature detection and description. According to the work of \cite{jiang2021learned}, existed networks can be divided into three groups, i.e., joint feature and metric learning networks\cite{han2015matchnet,kumar2016learning,simo2015discriminative}, separate detector and descriptor learning networks\cite{luo2019contextdesc,luo2018geodesc,mishchuk2017working},\cite{tian2017l2}, and joint detector and descriptor learning networks\cite{detone2018superpoint,Dusmanu2019CVPR}. For the first group, CNN models learn a similarity function to predict image patch similarities and integrate feature representation and matching within the same network. For the second group, CNN networks only learn feature representation, and feature matching is conducted based on classical strategies, such as the L2-norm Euclidean distance-based metric between feature descriptors. For the third group, trained models learn detectors and descriptors simultaneously, which can cope with images recorded in varying conditions. Similar to hand-crafted methods, existed networks have been used for spherical images by using pre-trained or finetuned models, as shown in Fig. \ref{fig:figure11}(a). For further details, readers can refer to\cite{da2017evaluation},\cite{murrugarra2022pose}.
Due to inevitable distortions in sphere-to-plane projection, CNN networks for perspective images may obtain inaccurate results. To address this issue, reported approaches in literature can be divided into three groups, i.e., tangent projection methods, CNN kernel shape resizing methods, and CNN sampling point adjustment methods.
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth]{Figure11}
\caption{The principle of CNN for spherical images\cite{su2017learning},\cite{zhao2018distortion}. (a) direct applying CNN on the ERP spherical images; (b) applying CNN on the tangent images; (c) adjusting the kernel shape of CNN at varying latitudes; (d) adjusting the sampling points of CNN kernels by using tangent plane projection.}
\label{fig:figure11}
\end{figure}
\begin{itemize}
\item For the first one, similar to 2D plane-based methods, equirectangular images are first projected to undistorted tangent images\cite{eder2020tangent} or divided into quasi-uniform discrete images\cite{shan2018descriptor}, and then existed CNN networks are applied to resulting images, as shown in Fig. \ref{fig:figure11}(b). Although these methods can achieve high accurate predictions, they suffer from high computational costs due to resampling of 3D spherical images to 2D plane images.
\item For the second one, CNN networks are designed to work on equirectangular images by adjusting the CNN kernel shape\cite{coors2018spherenet},\cite{su2017learning},\cite{zhao2018distortion}. In the work of \cite{su2017learning}, a network termed SPHCONV has been proposed, which aims to produce results as the output of applying perspective CNN networks to the corresponding tangent images. SPHCONV was achieved by defining convolution kernels with varying shapes for pixels in different image rows, as illustrated in Fig. \ref{fig:figure11}(c). Similarly, \cite{su2019kernel} proposed a kernel transformer network (KTN) network to learn spherical kernels by taking as input the latitude angle and source kernels for perspective images.
\item For the third one, sampling points of CNN kernels are adjusted based on ERP sphere image distortions instead of adjusting convolution kernel shape. For example, \cite{zhao2018distortion} and \cite{coors2018spherenet} designed distortion-aware networks that sample non-regular grid locations according to the distortions of different pixels, as shown in Fig. \ref{fig:figure11}(d). The core idea is to determine sampling locations based on the sphere projection of a regular grid on the corresponding tangent plane. Due to regular convolution kernels, these frameworks enable the transfer between CNN models for perspective and equirectangular images.
\end{itemize}
\subsubsection{Feature matching}
\label{sec:2.3.2}
The purpose of feature matching is to search correspondences from two sets of feature descriptors. Generally, feature matching is achieved by using nearest-neighbor searching based on the L2-norm Euclidean distance metric\cite{muja2009fast}. In the literature, extensive research has been reported for feature matching from the aspects of efficiency acceleration and precision improvement\cite{hartmann2016recent},\cite{jiang2021unmanned}. Due to the high dimension of local feature descriptors and the large number of spherical images, exhaustive feature matching consumes extremely high time costs. Thus, it becomes very critical to increasing the efficiency of feature matching.
In the literature, there are valuable methods for accelerating feature matching, including restricting the number of features in feature matching, decreasing the number of images, and reducing the number of match pairs. For a detailed review, the readers can refer to this work\cite{hartmann2016recent},\cite{jiang2020effcient}. Among these reported methods, match pair selection can be the most straightforward and effective way to accelerate feature matching. Three strategies can be exploited for spherical images based on their acquisition environments. First, data acquisition constraints can be used, e.g., the time-sequential constraint for street-view images. In other words, feature matching can be restricted to neighbors according to their acquisition time. Second, for professional MMS systems and consumer-grade sensors, precise or rough GNSS (Global Navigation Satellite System) data is usually recorded simultaneously with spherical images, which provides the best clue to select spatially overlapped match pairs. Third, the CBIR (Content-based Image Retrieval) technique has become a standard module\cite{jiang2020efficient},\cite{zheng2017sift}. It merely uses images for visual retrieval without other assumptions and auxiliary data. Fig. \ref{fig:figure12*} shows an example of CBIR for spherical images. It is shown that all top 12 images are true match pairs, and the last three images are false match pairs because no other match pairs exist.
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth]{Figure12}
\caption{An example of CBIR for spherical images. The image with blue borders is the query image, and the other images are the retrieval results. Images with green and red borders represent true and false retrieval results, respectively.}
\label{fig:figure12*}
\end{figure}
\subsection{Image orientation}
\label{sec:2.4}
Image orientation aims to estimate camera poses, scene structures, and intrinsic parameters based on established two-view correspondences. Image orientation is also termed aerial triangulation (AT) in photogrammetric 3D reconstruction, which requires good initial values of unknown parameters and well-designed configurations in data acquisition. However, these prerequisites cannot be completely satisfied due to the usage of consumer-grade sensors and the participation of non-professional users for spherical images. Consequently, image orientation of spherical images is usually achieved through the well-known Structure from Motion (SfM) technique for multi-view geometry in computer vision\cite{snavely2006photo} or the Simultaneous Localization and Mapping (SLAM) technique for instant localization in robot vision\cite{mouragnon2006real}. Thus, this subsection presents SfM-based offline and SLAM-based online methods for spherical image orientation. Besides, methods for camera calibration would also be presented in this section.
\subsubsection{Camera calibration}
\label{sec:2.4.1}
\hfill
(1) camera imaging model
The camera imaging model is the basis for camera calibration, which establishes the geometric transformation between 3D points in the object space and 2D points in the image plane. Based on the design of spherical cameras, there are three major camera imaging models, i.e., the unified projection model, general camera model, and multi-camera model.
\begin{itemize}
\item \textbf{Unified projection model}\cite{mei2007single} has been mainly designed for central catadioptric cameras, in which environment light rays intersect in a single point, i.e., the projection center of the mirror, as shown in Fig. \ref{fig:figure13}(a). This camera imaging model follows a strict theoretical projection function that models real-world imaging errors. The unified projection model has recently been verified as effective for wide-angle and fisheye cameras\cite{heng2013camodocal}.
\item \textbf{General camera model} (Taylor model)\cite{scaramuzza2006flexible} has been used for modeling the imaging procedure of central catadioptric and dioptric cameras. Instead of using the strict theoretical model in the unified projection model, the general camera model utilizes a Taylor polynomial function to fit the projection, which expands the application to the lens without prior knowledge, e.g., fisheye cameras.
\item \textbf{Multi-camera model} has been designed to establish the projection of the widely used polydioptric cameras that record spherical images by using a camera rig, e.g., the Ladybug 5+ camera. The multi-camera model can be implemented using several individual camera models or a unit sphere camera model\cite{ji2014comparison}. The former is more rigorous in formulating the imaging system, as shown in Fig. \ref{fig:figure13}(b); on the contrary, the latter has a more straightforward formula widely used in close-range photogrammetry, as shown in Fig. \ref{fig:figure13}(c).
\end{itemize}
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure13}
\caption{Camera imaging models\cite{ji2014comparison},\cite{scaramuzza2006flexible}. (a) central catadioptric cameras; (b) individual camera model; and (c) unit sphere camera model.}
\label{fig:figure13}
\end{figure}
(2) camera calibration
The purpose of camera calibration is to calculate the intrinsic parameters of cameras, e.g., the focal length, principle point, and lens distortion coefficients. After selecting a proper camera imaging model, camera calibration can be achieved by using a combined bundle adjustment of both interior and exterior orientation parameters. In practice, there are three ways to estimate the parameters: self-calibration based on the epipolar geometry constraint, space resection using non-planar 3D control points, and laboratory calibration using checkerboards\cite{urban2015improved}. In the work of \cite{aghayari2017geometric}, a Ricoh Theta dual-camera system has been calibrated based on the expanded unit sphere camera model, in which two extra parameters that model the displacement of latitude and longitude coordinates are incorporated into the camera imaging model. For calibrating a professional Ladybug multi-camera system, \cite{lichti2020geometric} adopted the colinear equation-based rigorous model, which combines five radial distortion parameters and two decentering distortion parameters to model the imaging errors. For comparing different calibration methods for spherical cameras, readers can refer to the work of \cite{puig2012calibration}. Besides, Table \ref{tab:table4} presents a list of open-source software packages for spherical camera calibration.
\begin{table*}[t!]
\caption{A list of open-source software packages for spherical camera calibration.}
\label{tab:table4}
\centering
\makebox[\textwidth]{
\begin{tabular}{p{0.15\textwidth} p{0.1\textwidth} p{0.1\textwidth} p{0.4\textwidth}}
\toprule
\textbf{Name} &
\textbf{Language} &
\textbf{Year} &
\textbf{Website} \\
\midrule
\multirow{2}{0.1\textwidth}{OCamCalib}
& Matlab
& 2006
&\url{https://sites.google.com/site/scarabotix/ocamcalib-omnidirectional-camera-calibration-toolbox-for-matlab}\\
& \multicolumn{3}{L{0.6\textwidth}}{A toolbox to calibrate any central omnidirectional camera, i.e., panoramic cameras having a single effective viewpoint\cite{scaramuzza2006flexible}.} \\
\midrule
\multirow{2}{0.1\textwidth}{Improved OcamCalib}
& Matlab
& 2015
& \url{https://github.com/urbste/ImprovedOcamCalib}\\
& \multicolumn{3}{L{0.6\textwidth}}{An add-on toolkit to the OCamCalib toolbox that implements calibration algorithms for wide-angle, fisheye, and omnidirectional cameras\cite{urban2015improved}.} \\
\midrule
\multirow{2}{0.1\textwidth}{LIBOMNICAL}
& Matlab
& 2014
& \url{https://www.cvlibs.net/projects/omnicam}\\
& \multicolumn{3}{L{0.6\textwidth}}{a MATLAB Toolbox to calibrate central and slightly non-central catadioptric cameras and catadioptric stereo setups\cite{schonbein2014calibrating}.} \\
\midrule
\multirow{2}{0.1\textwidth}{Omnidirectional Calibration Toolbox Mei}
& Matlab
& 2007
& \url{https://www.robots.ox.ac.uk/~cmei/Toolbox.html}\\
& \multicolumn{3}{L{0.6\textwidth}}{A toolbox implements the unified projection model to calibrate hyperbolic, parabolic, and folding mirrors and spherical and wide-angle sensors\cite{mei2007single}.} \\
\midrule
\multirow{2}{0.1\textwidth}{camodocal}
& C++
& 2013
& \url{https://github.com/hengli/camodocal}\\
& \multicolumn{3}{L{0.6\textwidth}}{A toolbox for automatic intrinsic and extrinsic calibration of a camera rig with multiple generic cameras and odometry\cite{heng2013camodocal}.}\\
\midrule
\multirow{2}{0.1\textwidth}{kalibr}
& C++
& 2016
& \url{https://github.com/ethz-asl/kalibr}\\
& \multicolumn{3}{L{0.6\textwidth}}{A toolbox for the calibration of multi-camera calibration and multi-sensor integration, such as camera and IMU\cite{rehder2016extending}.} \\
\bottomrule
\end{tabular}
}
\end{table*}
\subsubsection{SfM-based offline methods}
\label{sec:2.4.2}
\hfill
(1) Principle of incremental SfM
Existed SfM can be divided into three major groups, i.e., incremental SfM, global SfM, and hybrid SfM, according to the used strategy for estimating and optimizing unknown parameters\cite{cui2017hsfm}. Compared with other techniques, incremental SfM has the advantages of resisting high outlier ratios and achieving accurate orientation models. Incremental SfM has been widely used in photogrammetric 3D reconstruction\cite{jiang2017board}.
The workflow of incremental SfM is shown in Fig. \ref{fig:figure14}, which consists of two components, i.e., feature matching and incremental image registration. Feature matching can be solved by using the methods presented in Section \ref{sec:3.1}. For image registration, consistent correspondences are first tied to create tie-points\cite{cao2019fast}. In incremental image registration, two seed images are first selected among all matched image pairs, which have a large enough intersection angle and a sufficient number of well-distributed matched features. A base model is then constructed by recovering their relative poses and triangulating 3D scene points, which would be used to register the next-best image and triangulate more 3D scene points. Meanwhile, local or global bundle adjustment (BA) optimization is executed to decrease accumulated errors and remove false matches. After iterative image registration and point triangulation, all images are registered into the same 3D model\cite{snavely2008modeling}.
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure14}
\caption{The workflow of the incremental SfM\cite{jiang2020effcient}.}
\label{fig:figure14}
\end{figure}
In the above-mentioned iterative local and global BA, the optimization problem is usually formulated as a joint minimization of the reprojection function \cite{triggs1999bundle}, where the sum of errors between tie-point projections and their corresponding image points is minimized. The object function of BA is presented by the Equation \eqref{eq:1}.
\begin{equation}
\min\limits_{C_j,X_i}\sum_{i=1}^n\sum_{j=1}^m\rho_{ij}\parallel P(C_j,X_i)-x_{ij} \parallel ^2
\label{eq:1}
\end{equation}
where $X_i$ and $C_j$ indicate a 3D point and a camera, respectively; $P(C_j, X_i)$ is the projection of point $X_i$ on camera $C_j$; $x_{ij}$ is an observed image point; $\left\|\bullet\right\|$ denotes L2-norm; $\rho_{ij}$ is an indicator function with $\rho_{ij}=1$ if point $X_i$ is visible in camera $C_j$; otherwise $\rho_{ij}=0$.
(2) Perspective SfM to spherical SfM
For spherical image orientation, there have been some attempts to adapt perspective SfM to spherical SfM in the last two decades. \cite{chang2000omni} proposed a two-step SfM for omnidirectional images depending on linear initialization and nonlinear optimization, which only recovers camera relative geometry. Uncertainty analysis and result comparison were also conducted and compared with perspective SfM. In the work of \cite{torii2005two}, both two-view and three-view geometry of spherical images have been analyzed and discussed. The epipolar geometry forms the basis for 3D reconstruction of spherical images, e.g., the pose recovery in a virtual navigation system\cite{kangni2007orientation}.
With the usage of advanced MMS systems for urban city modeling and navigation, some researchers moved their attention to 3D reconstruction of large-scale scenes instead of two or three-view geometry estimation in the earlier work\cite{micusik2006structure}. As one of the early pioneering attempts, \cite{torii2009google} proposed an incremental SfM system that combines state-of-the-art techniques, e.g., local feature-based feature detection, approximate nearest neighbor-based feature matching, and robust essential matrix estimation and optimization. The performance of the proposed SfM system has been verified by using Google Street View images that cover a large street block\cite{anguelov2010google}, as presented in Fig. \ref{fig:figure15}(a). For full spherical images, \cite{pagani2011structure} investigated different error metrics on relative and absolute pose estimation and also designed the error approximations to reduce computational costs. These error metrics consist of the basic blocks for spherical SfM.
In contrast to professional sensors, recent years also witnessed the explosive development of consumer-grade spherical cameras\cite{gao2022review} and their usage in 3D modeling. In \cite{guan2016structure}, the von Mises-Fisher distribution was utilized to model the noise distribution of feature point positions on spherical images and to reformulate the error function in the bundle adjustment optimization. Meanwhile, spherical-n-point and triangulation algorithms that are suitable for spherical images have been proposed to achieve spherical video orientation and viewing direction stabilization. \cite{zhang2020uav} embedded spherical cameras into a UAV platform and proposed a solution for panoramic photogrammetry, as presented in Fig. \ref{fig:figure15}(b). In data processing, original spherical images are first reprojected to cubic images, which are then reconstructed by using existed commercial software. The study verifies the validation of spherical cameras for oblique photogrammetric 3D modeling of urban buildings.
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth]{Figure15}
\caption{SfM for spherical images. (a) direct processing of spherical images based on the unit spherical camera model\cite{torii2009google}; (b) indirect processing of spherical images based on sphere-to-plane projection\cite{zhang2020uav}.}
\label{fig:figure15}
\end{figure}
Although extensive research has been reported in the literature, the majority of both open-source and commercial software packages are now designed for perspective images. Table \ref{tab:table5} lists the well-known and widely used software packages for 3D reconstruction in the fields of photogrammetry and computer vision. It is shown that only a few packages provide the full 3D reconstruction module for spherical images, e.g., the open-source software OpenMVG and MicMac and the commercial software Pix4Dmapper and Metashape. With the increasing popularity of spherical cameras, there is an urgent requirement for well-designed toolkits that can support scientific research and engineering application. Thus, further research is required for photogrammetric 3D reconstruction of spherical images.
\begin{table*}[t!]
\caption{A list of open-source and commercial SfM software packages.}
\label{tab:table5}
\centering
\makebox[\textwidth]{
\begin{tabular}{p{0.15\textwidth} p{0.1\textwidth} p{0.1\textwidth} p{0.4\textwidth} p{0.1\textwidth}}
\toprule
\textbf{Name} &
\textbf{Language} &
\textbf{Year} &
\textbf{Website} &
\textbf{Spherical camera} \\
\midrule
\multirow{2}{0.1\textwidth}{AliceVision}
& C++
& 2018
& \url{https://github.com/alicevision}
& $\times$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A photogrammetric computer vision framework for 3D reconstruction. It provides three types of camera models, i.e., Radial, Brown, and Fisheye\cite{griwodz2021alicevision}.} \\
\midrule
\multirow{2}{0.1\textwidth}{COLMAP}
& C++
& 2016
& \url{https://github.com/colmap/colmap}
& $\times$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A 3D reconstruction software that includes both sparse and dense matching modules, which includes Radial, and Fisheye camera models\cite{schonberger2016structure}.} \\
\midrule
\multirow{2}{0.1\textwidth}{OpenMVG}
& C++
& 2015
& \url{https://github.com/openMVG/openMVG}
& $\checkmark$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A well-known sparse reconstruction software that provides Radial, Brown, Fisheye, and Sphere camera models. It can directly process spherical images\cite{moulon2016openmvg}.} \\
\midrule
\multirow{2}{0.1\textwidth}{MicMac}
& C++
& 2007
& \url{https://github.com/micmacIGN/micmac}
& $\checkmark$ \\
& \multicolumn{3}{L{0.6\textwidth}}{An open-source photogrammetric toolkit that provides modules of AT, dense matching, and ortho-rectification for satellite, aerial and close-range images\cite{rupnik2017micmac}.} \\
\midrule
\multirow{2}{0.1\textwidth}{ContextCapture}
& /
& 2022
& \url{https://www.bentley.com}
& $\times$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A well-known and widely used 3D modeling software in the field of photogrammetry, which can provide the best 3D textured mesh models. It only supports perspective cameras.} \\
\midrule
\multirow{2}{0.1\textwidth}{Pix4Dmapper}
& /
& 2022
& \url{https://www.pix4d.com}
& $\checkmark$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A well-known and widely used photogrammetric software for aerial and close-range images in the field of photogrammetry. It supports perspective, fisheye, and spherical cameras.} \\
\midrule
\multirow{2}{0.1\textwidth}{Metashape}
& /
& 2022
& \url{https://www.agisoft.com}
& $\checkmark$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A well-known and widely used photogrammetric software for aerial and close-range images in the field of photogrammetry. It supports perspective, fisheye, and spherical cameras.} \\
\midrule
\multirow{2}{0.1\textwidth}{RealityCapture}
& /
& 2022
& \url{https://www.capturingreality.com }
& $\times$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A photogrammetric computer vision software for 3D reconstruction. It features a fast speed for image processing. It now supports a perspective camera.} \\
\bottomrule
\end{tabular}
}
\end{table*}
\begin{table*}[t!]
\caption{A list of open-source SLAM software packages.}
\label{tab:table6}
\centering
\makebox[\textwidth]{
\begin{tabular}{p{0.15\textwidth} p{0.1\textwidth} p{0.1\textwidth} p{0.4\textwidth} p{0.1\textwidth}}
\toprule
\textbf{Name} &
\textbf{Language} &
\textbf{Year} &
\textbf{Website} &
\textbf{Spherical camera} \\
\midrule
\multirow{2}{0.1\textwidth}{ORB-SLAM3}
& C++
& 2021
& \url{https://github.com/UZ-SLAMLab/ORB_SLAM3}
& $\times$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A SLAM system that supports perspective and fisheye cameras and can be embedded with monocular, stereo, and RGBD cameras\cite{campos2021orb}.} \\
\midrule
\multirow{2}{0.1\textwidth}{OpenVSLAM}
& C++
& 2019
& \url{https://github.com/xdspacelab/openvslam}
& $\checkmark$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A visual SLAM system that supports various camera models, including perspective, fisheye, and spherical cameras\cite{sumikura2019openvslam}.} \\
\midrule
\multirow{2}{0.1\textwidth}{Cubemap-SLAM}
& C++
& 2018
& \url{https://github.com/nkwangyh/CubemapSLAM }
& $\times$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A visual SLAM system that converts fisheye images into perspective images and achieves image orientation based on the ORB-SLAM\cite{wang2018cubemapslam}.} \\
\midrule
\multirow{2}{0.1\textwidth}{DSO}
& C++
& 2017
& \url{https://github.com/JakobEngel/dso}
& $\times$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A direct sparse visual odometry that supports only perspective cameras\cite{engel2017direct}.} \\
\midrule
\multirow{2}{0.1\textwidth}{MultiCol-SLAM}
& C++
& 2016
& \url{https://github.com/urbste/MultiCol-SLAM}
& $\times$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A multi-fisheye SLAM that supports rigidly coupled multi-camera systems. It extends the ORB-SLAM and ORB-SLAM2 systems\cite{urban2016multicol}.} \\
\midrule
\multirow{2}{0.1\textwidth}{LSD-SLAM}
& c++
& 2014
& \url{https://github.com/tum-vision/lsd_slam }
& $\times$ \\
& \multicolumn{3}{L{0.6\textwidth}}{A direct monocular SLAM system that enables real-time image orientation and semi-dense depth map generation\cite{engel2014lsd}.} \\
\bottomrule
\end{tabular}
}
\end{table*}
\subsubsection{SLAM-based online methods}
\label{sec:2.4.3}
\hfill
(1) Principle of visual SLAM
In contrast to the offline SfM technique, SLAM can implement simultaneous and real-time image orientation and scene reconstruction, which origins from the robotic field for localization and navigation without GNSS signals, as well as environment mapping\cite{huang2019survey}. In the field of photogrammetry and computer vision, SLAM has also been used for online image orientation, e.g., UAV and MMS images\cite{huang2020fast},\cite{lu2018survey}. Various sensors can be integrated into a SLAM system, such as RGB and depth cameras, laser scanners, GNSS and IMU (Inertial Measurement Unit) instruments, and wheel odometry\cite{huang2019survey}. In the context of spherical image orientation, the used SLAM system is termed visual SLAM, which is merely coupled with the RGB cameras.
Fig. \ref{fig:figure16} shows the workflow of the visual SLAM, which consists of two major components. The front-end is utilized to process sequentially observed images through feature extraction, feature matching, motion estimation, and keyframe selection; the back-end is responsible for loop detection, BA optimization, and 3D mapping. The processing pipeline of the visual SLAM system includes: 1) sequentially estimating the motion of newly added images with local BA optimization; 2) checking whether or not the newly added images are keyframes and creating more map points from keyframes; 3) detecting loops between newly added images and existed 3D models and conducting global BA optimization to reduce error accumulation. Through the iterative execution of these three steps, images are sequentially oriented.
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure16}
\caption{The workflow of the visual SLAM system.}
\label{fig:figure16}
\end{figure}
(2) SLAM with large FOV cameras
Cameras with large field-of-view angles can enhance the robustness of the SLAM systems\cite{zhang2016benefit} since they enable long-period feature tracking, especially in urban streets and indoor environments. Large FOV cameras have been increasingly integrated into visual SLAM systems. Recently adopted large FOV cameras can be grouped into two categories, including fisheye cameras with wide FOV and spherical cameras with full FOV.
Fisheye cameras are the most reported large FOV sensors coupled with visual SLAM systems\cite{caruso2015large,matsuki2018omnidirectional,won2020omnislam,zhang2016benefit}. \cite{caruso2015large} proposed a direct monocular SLAM based on a unified omnidirectional camera model. It was an extension of their previous LSD-SLAM\cite{engel2014lsd}, and it has superior performance on the accuracy of localization and robustness to strong rotational movement. In the work of \cite{matsuki2018omnidirectional}, the authors also designed a direct monocular SLAM system, which is an extension of the DSO system\cite{engel2017direct} and integrates the unified camera model proposed in \cite{caruso2015large}. \cite{wang2018cubemapslam} proposed a feature-based SLAM system, termed Cubemap-SLAM, based on the cubic projection of fisheye images. In this work, the cubemap model has been embedded into the ORB-SLAM. To evaluate the impact of large FOV cameras, \cite{zhang2016benefit} conducted a series of tests by using both indoor and outdoor datasets, and their evaluation reveals that the reconstruction accuracy also depends on the environment, and large FOV cameras tend to improve performance in indoor scenes.
Spherical cameras can further extend the FOV of fisheye cameras, and they have been widely used for data acquisition in MMS systems\cite{anguelov2010google,torii2009google}. \cite{tardif2008monocular} proposed a feature-based SLAM workflow that only estimates the pose of the latest image without the execution of BA optimization. The core idea is to decouple the problem of pose recovery into rotation estimation from epipolar geometry and translation estimation using 3D-2D correspondences. \cite{urban2016multicol} extended the ORB-SLAM\cite{mur2015orb,mur2017orb} system into a multi-fisheye omnidirectional SLAM system, termed MultiCol-SLAM, which supports the arbitrary rigidly coupled multi-camera systems. In \cite{ji2020panoramic}, a fisheye calibration model has been designed and used for multiple fisheye camera rigs, as shown in Fig. \ref{fig:figure17}(a), and a feature-based SLAM, termed PAN-SLAM, has been proposed based on well-designed strategies for initialization, feature matching and tracking, and loop detection. The tests demonstrate the validation of the proposed SLAM system.
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure17}
\caption{The visual SLAM systems based on (a) the multi-fisheye camera rig\cite{ji2020panoramic} and (b) the full special camera\cite{sumikura2019openvslam}.}
\label{fig:figure17}
\end{figure}
In recent years, spherical images captured by dual-fisheye cameras are becoming more and more popular, which promotes the development of panoramic SLAM systems\cite{huang2022360vo,im2016all,sumikura2019openvslam,zhang2021panoramic}. \cite{sumikura2019openvslam} designed a versatile visual SLAM, termed OpenVSLAM, which implements perspective, fisheye, and spherical camera models and supports monocular, stereo, and RGB-D cameras, as shown in Fig. \ref{fig:figure17}(b). In addition, the authors provided an indoor benchmark for performance evaluation\cite{chappellet2021benchmarking}. \cite{zhang2021panoramic} investigated varying feature detection and description techniques, including SPHORB and SSIFT, and compared their performance in spherical image orientation based on SLAM. Recently, \cite{huang2022360vo} implemented a direct SLAM system that extends DSO with the spherical camera model to process equirectangular images. Table \ref{tab:table6} presents a list of open-source SLAM software packages. The same finding can be made as for SfM-based methods that few open-source SLAM systems can support full spherical cameras.
\subsection{Dense matching}
\label{sec:2.5}
Dense matching aims to establish pixel-wise correspondences and generate point clouds from SfM or SLAM-based oriented images. According to the 3D reconstruction pipeline shown in Fig. \ref{fig:figure2}, generated dense point clouds would be used to construct detailed 3D models after point meshing and texture mapping. Thus, the performance of dense matching methods would determine the precision and completeness of the final 3D models. In the literature, dense matching has been an extensively studied topic with the arising of 3D reconstruction in photogrammetry and computer vision. Except for traditional methods for perspective images, recent years have witnessed increasingly reported dense matching methods for spherical images. Table \ref{tab:table7} lists the methods for dense matching. Generally, this work can be grouped into single-view depth prediction and multi-view stereo matching. The details for dense matching of spherical images are listed as follows.
\begin{table*}[t!]
\centering
\caption{Method comparison for dense matching.}
\label{tab:table7}
\makebox[\linewidth]{
\begin{tabular}{p{0.14\textwidth} p{0.15\textwidth} p{0.45\textwidth}}
\toprule
\textbf{Category} & \textbf{Methods} & \textbf{Advantages and disadvantages} \\
\midrule
Single-view prediction & Single view \cite{feng2022360,jang2022egocentric,jin2020geometric,pintore2021slicenet,zioulis2018omnidepth}
& \textbf{\emph{Advantages}}: (1) avoid SfM and SLAM-based image orientation.
\textbf{\emph{Disadvantages}}: (1) do not use multi-view constraints. \\
\midrule
Existed methods & Hand-crafted methods\cite{furukawa2010accurate,hirschmuller2007stereo,rothermel2012sure} and learning-based methods\cite{chang2018pyramid,seki2017sgm,yao2020blendedmvs}
& \textbf{\emph{Advantages}}: (1) use existed algorithms and software packages; (2) be suitable for engineer usage.
\textbf{\emph{Disadvantages}}: (1) cannot avoid the distortions or require extra time costs for image projection. \\
\midrule
Redesigned methods & Stereo-view methods\cite{meuleman2021real,wang2020360sd} and multi-view methods\cite{jang2022egocentric}
& \textbf{\emph{Advantages}}: (1) adapt to spherical images; (2) make use of the learning-based CNN network.
\textbf{\emph{Disadvantages}}: (1) design special acquisition sensors and (2) label data for network training. \\
\bottomrule
\end{tabular}
}
\end{table*}
\subsubsection{Single-view depth prediction}
\label{sec:2.5.1}
Single-view depth prediction methods can process an individual spherical image instead of pixel-wise correspondence searching between images. In the literature, single-view depth prediction methods are usually implemented through learning-based CNN networks\cite{feng2022360,jang2022egocentric,jin2020geometric,pintore2021slicenet,zioulis2018omnidepth}, which belong to a new research topic in the last five years. As one of the earliest works, \cite{zioulis2018omnidepth} prepared and released a spherical training dataset with ground-truth depth maps, as presented in Fig. \ref{fig:figure18}(a). It can be used as the training dataset for depth estimation networks for spherical images instead of training on perspective datasets with sub-optimal performance. Considering the correlation between depth and geometric structure in indoor environments, \cite{jin2020geometric} attempted to leverage existed geometric structures, e.g., corners, boundaries, and planes, as priors for network training or inferring these structures from generated depth estimation. The reconstruction models are presented in Fig. \ref{fig:figure18}(b). For indoor scenes, \cite{pintore2021slicenet} suggested representing equirectangular images by using vertical slices of the sphere, which partitions input images into vertical slices. Based on the LSTM (long short-term memory), the authors designed a network called SliceNet for depth estimation.
In contrast to indoor scenes, \cite{feng2022360} prepared the Depth360 dataset and designed an end-to-end two-branch network, termed SegFuse, for depth prediction of spherical images. The core idea is to integrate the segmentation of cubic-map images from one branch into the depth estimation of rectangular images from the other branch. In conclusion, depth estimation from one single spherical image has begun attracting attention.
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth]{Figure18}
\caption{Single view depth prediction for spherical images. (a) a prepared 360 datasets\cite{zioulis2018omnidepth}; (b) indoor depth prediction from spherical images\cite{jin2020geometric}.}
\label{fig:figure18}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth]{Figure19}
\caption{multi-view dense matching for spherical images. (a) revised PMVS algorithm\cite{pagani2011dense}; (b) sphere sweeping algorithm\cite{im2016all}; and (c) the finetuned CNN network\cite{jang2022egocentric}.}
\label{fig:figure19}
\end{figure}
\subsubsection{Multi-view stereo matching}
\label{sec:2.5.2}
\hfill
(1) existed method
Multi-view stereo matching methods attempt to recover dense point clouds from two or multiple oriented images based on SfM and SLAM image orientation techniques\cite{furukawa2015multi}. Existed methods can be divided into two groups based on the strategies used. For the first one, traditional hand-crafted methods are on the one hand revised to adapt to spherical images. In the work of\cite{pagani2011structure,pagani2011dense}, the PMVS (Patch-based Multi-view Stereo) library was revised to directly process spherical images for dense matching, as shown in Fig. \ref{fig:figure19}(a). For the second one, spherical images are projected into cubic-map images, and traditional hand-crafted algorithms and deep learning-based networks are adopted straightforward since they are designed or trained for perspective images, e.g., hand-crafted methods\cite{bleyer2011patchmatch,furukawa2010accurate,hirschmuller2007stereo,rothermel2012sure} and learning-based methods\cite{chang2018pyramid,khamis2018stereonet,seki2017sgm,yao2018mvsnet,yao2020blendedmvs}. These two strategies can make use of existed well-designed methods.
(2) redesigned method
For this category, algorithms are designed and implemented from scratch considering the characteristic of spherical images\cite{da2019dense,im2016all,kim20133d,meuleman2021real,wang2020360sd}. In \cite{kim20133d}, a full workflow was designed for 3D reconstruction of spherical image pairs, in which a stereo matching algorithm was proposed based on a partial differential equation (PDE), and the complete 3D scene was obtained by registering partial models. Considering the power of the plan sweeping algorithm, \cite{im2016all} proposed a sphere sweeping algorithm based on the unified omnidirectional camera model, in which virtual spheres were used instead of virtual planes, as shown in Fig. \ref{fig:figure19}(b). The algorithm was tested by using both synthetic and real datasets. These methods can be seen as mimics of the traditional dense matching algorithm for perspective images.
Recently, CNN networks have also been adopted to design multi-view stereo solutions. In the work of \cite{wang2020360sd}, a dual-camera imaging system that consists of top and bottom cameras was designed, which ensures that the epipolar lines of captured images are vertically aligned. A polar angle layer was added to a two-branch network for depth estimation, which plays as additional input geometric information to supervise model training. \cite{jang2022egocentric} proposed a complete solution for 3D reconstruction of spherical images, including image orientation, epipolar rectification, dense matching, and texture mapping. For dense matching, the authors adopted an existed network that was retrained using a synthetic dataset to learn spherical disparity and designed a spherical binoctree structure for depth map fusion. The proposed solution achieves superior performance when compared with traditional methods, as presented in Fig. \ref{fig:figure19}(c). In conclusion, dense matching methods based on CNN networks develop rapidly. This review would not cover all aspects in this field.
\section{Applications}
\label{sec:3}
This section presents promising applications related to spherical images. Due to the characteristics of full FOV and low cost, spherical images have been used widely in a variety of applications. According to the purpose of this study, the reviewed applications would be restricted to 3D reconstruction, including cultural heritage documentation, urban modeling and navigation, tunnel mapping and inspection, and other applications, e.g., urban tree localization, emergency response and rescue, and underwater occlusion avoidance.
\subsection{Cultural heritage documentation}
\label{sec:3.1}
Cultural heritage documentation (CHD) is the earliest usage of spherical images, which can be data back to two centuries ago\cite{luhmann2004historical}. In contrast to the large-scale acquisition required in aerial photogrammetry, the scale of cultural heritage documentation is much smaller but with serious occlusions, e.g., building pillars and inner structures. It requires close-range data acquisition with a large FOV to decrease human labor and ensure completeness. When compared to conventional aerial plane-based and recent UAV-based photogrammetry, spherical images can be recorded in a more flexible way, e.g., ground-fixed tripods and hand-held poles, and have been widely used for cultural heritage documentation.
In the field of photogrammetry and remote sensing,\cite{fangi2007multi,fangi2010multiscale,fangi2013photogrammetric} have made an earlier contribution to CHD by using spherical images. This work presents the basic principle of the proposed spherical photogrammetry (SP), i.e., the collinear equation of spherical imaging and the coplanarity condition for image orientation. By using two church architectures, this study verifies the advantages of spherical images with the remarkable efficiency of data acquisition, the completeness of documentation, and the low economic cost compared with other photogrammetric instruments.
With the explosive development of consumer-grade spherical cameras, recent researchers have also turned to adopting low-cost cameras for data acquisition and 3D reconstruction of CHD. For example, \cite{fangi2018improving} used a Panono 360 camera for the image collection of two churches, which is a ball-shaped camera that consists of 36 camera submodules to record surrounding environments. This study verified the centimeter-level precision of dense point clouds from SfM and MVS-based photogrammetric processing. \cite{barazzetti2018can} exploited a Xiaomi Mi Sphere 360 camera for the precision assessment of 3D modeling. In this study, a Leica TS30 total station has been used for an in-site survey of ground control points (GCPs), and two software packages, including Agisoft Metashape and Pix4dMapper, have been evaluated. Experiments demonstrate that millimeter-level accuracy has been obtained in both image orientation and 3D reconstruction by using GCPs and laser scanning point clouds.
Because of the complex structure of cultural heritages, aerial and ground images have also been combined to reconstruct complex cultural heritages. \cite{herban2022use} combined low-altitude UAV images and hand-held spherical images for 3D documentation of a bell tower. In this work, a DJI Phantom 4 Pro UAV has been adopted for scanning external structures under a properly designed flight trajectory, and two spherical cameras, i.e., the GoPro Fusion and the Kandao Qoocam 8K, have been used for scanning internal structures. Based on an SfM and MVS-based processing solution, the reconstructed 3D model has high-quality details in the external and internal of the complex bell tower. In contrast to using consumer-grade spherical cameras, \cite{2022Agisoft} conducted high-quality digital twin documentation of a well-known town, Long Hu Gu Zhai at Guangdong Province, China. This study uses professional Weiss AG Civetta spherical cameras for terrestrial images with 230 megapixels resolution and a UAV for along-street aerial images. By using the Agisoft Metashape, 3D models were reconstructed from aerial and terrestrial images, as presented in Fig. \ref{fig:figure20}. The results demonstrate the potential of aerial and ground images for the precision documentation of complex buildings.
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure20}
\caption{Cultural heritage documentation by using aerial UAV images and terrestrial spherical\cite{2022Agisoft}. (a) data acquisition based on the Weiss AG Civetta camera; (b) image orientation of aerial-ground images; (c) dense matching of building inner structures; (d) 3D reconstruction of buildings.}
\label{fig:figure20}
\end{figure}
\subsection{Urban modeling and navigation}
\label{sec:3.2}
Spherical cameras have been integrated with mobile mapping systems (MMS) for urban street modeling and navigation. The most famous application of spherical images comes from Google Street View, which provides immersive navigation and observation along urban streets. At the beginning of Google Street View, collected street images have also been used for 3D modeling of building facades, except for image navigation\cite{anguelov2010google},\cite{bruno2019accuracy}, as shown in Fig. \ref{fig:figure21}(a). Similarly, \cite{micusik2009piecewise} designed a unified framework to reconstruct 3D models from spherical images captured from a Ladybug camera, in which bundle adjustment free image orientation, piecewise planarity constrained dense matching, and novel depth map fusion were reported considering the characteristics of low-texture, repetitive pattern, and large light changes in urban streets.
In contrast to mesh-based 3D models, recent studies show well-formed wire-frame models reconstructed from spherical images. Under the Manhattan world assumption, \cite{kim20133d} converted spherical images into cubic-map representation and segmented urban scenes into planar structures under the constraints of image color, and edge and normal information from MVS-based depth maps, as presented in Fig. \ref{fig:figure21}(b). By using street images and deep learning techniques, \cite{xu2022building} designed a workflow for building detection and height calculation and created LOD2 (Level-of-Detail) 3D models for large-scale urban scenes. In a word, these studies verify the potential of spherical images for 3D modeling.
Due to the high image overlap of large FOV cameras, spherical images have also been widely used to achieve localization and navigation in complex urban environments. \cite{cheng2018crowd} proposed a solution for the large-scale localization of photos without geotagged labels. In this study, 3D sparse models reconstructed from street view images were used as the reference data source, and a three-step algorithm was designed for geo-localization, which includes image retrieval-based coarse geo-localization, reliable feature matching between the query image and retrieved candidate images, and the PnP (Perspective n Points) based precise geo-localization. Instead of using low-level features, \cite{jayasuriya2020active} turned to detect high-level semantic information from spherical images, such as lamp posts and street signs, which are detected based on a retrained YOLO CNN network. To geo-localizing interesting targets within urban scenes to assist vehicle navigation, \cite{li2022optimized} proposed a line of bearing (LOB) based positioning method for urban street objects, e.g., road lamps, shown in Fig. \ref{fig:figure21}(c).
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure21}
\caption{Urban modeling and navigation. (a) mesh models from Google Street View\cite{anguelov2010google}; (b) wire-frame models from spherical images\cite{kim20133d}; (c) street object localization\cite{li2022optimized}.}
\label{fig:figure21}
\end{figure}
\subsection{Tunnel mapping and inspection}
\label{sec:3.3}
Artificial tunnels are extensively used in daily life, e.g., traffic tunnels and drainage pipes. Regular inspection is essential to ensure normal functions and extend the lifespans. In practice, the inspection work has been widely achieved through labor-sensitive operators. In recent years, with the advent of small-size spherical cameras and the development of image processing techniques, image-based inspection solutions have also been presented and verified to achieve automatic tunnel mapping and inspection\cite{leingartner2016evaluation}.
In the work of \cite{zhu2016panoramic}, a low-cost and flexible system has been designed to create a panorama image of the traffic tunnels, in which SfM-based image orientation and stitching-based image registration techniques have been used under the constraint of tunnel design data. This work verified the feasibility of image-based mapping for tunnel in-field inspection. Based on the rapid data acquisition ability of spherical cameras, \cite{janiszewski2022rapid} designed an overall framework for photogrammetric tunnel mapping. In this work, an Insta360 Pro sphere camera integrating six fisheye camera modules has been used to record images with 4000 by 3000 pixels. During data acquisition, the spherical camera was installed on a tripod to image recording with long exposure times. For quality verification, point clouds were also collected by using a Riegl VZ-400i TLS scanner. Experimental results demonstrate that the reconstructed tunnel models can achieve millimeter level precision when compared with TLS point clouds, as presented in Fig. \ref{fig:figure22}(a).
In contrast to large-size tunnel mapping, small-size gas and drainage pipes are the other typical inspection scenes that require the full FOV acquisition ability of a spherical camera due to the limited space in these pipes. In the work of\cite{zhang20193d}, drainage pipe inspection has been implemented by using low-cost GoPro Fusion video cameras. Key frames were extracted from recorded videos and converted to cubic-map images, then used to reconstruct 3D models based on typical SfM and MVS-based solutions. For the inspection of drainage pipes with minimal space, \cite{fang2022sewer} designed a pipeline capsule machine (PCM), as presented in Fig. \ref{fig:figure22}(b), which mainly consists of a large FOV camera, a LED (light-emitting diode) lighting instrument, and a power supply module. The PCM sensor can record images with the flow of pipe water, which are further used for crack and erosion detection based on deep learning-based methods\cite{guo2022detection}.
Similarly, for the inspection of gas pipes,\cite{karkoub2020gas} designed an inspection robot that is equipped with a catadioptric camera for spherical image collection. Unlike the PCM, depending on flowing water, the inspection robot can operate on other pipes since it uses wheels for forward moving. In a word, spherical cameras have good advantages for tunnel mapping and inspection due to the low cost of sensors and the limited space of tunnels.
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure22}
\caption{Tunnel mapping and inspection. (a) mine tunnel mapping\cite{janiszewski2022rapid}; (b) drainage pipe inspection\cite{guo2022detection}.}
\label{fig:figure22}
\end{figure}
\subsection{Other applications}
\label{sec:3.4}
In recent years, spherical images have also been used in other applications, e.g., emergency response and rescue, urban tree detection and mapping, collision avoidance of underwater vehicles, etc. \cite{jhan2021integrating} designed an integrated photogrammetric system for rapid data acquisition and a workflow for point cloud generation from aerial-ground images. This work took advantage of low-altitude UAVs and ground backpack MMSs to collect aerial-ground images and validate the integration of aerial-ground images for the full 3D reconstruction of urban buildings to boost the observation completeness.
Tree number, location, and structure are critical for the precision management of forest resources. Although conventional aerial photogrammetry and LiDAR (Light Detection and Ranging) can provide large-scale RS data, they suffer serious occlusions of urban scenes and cannot achieve accurate measurements of street trees. Considering these issues, \cite{itakura2020automatic} proposed using spherical cameras for the 3D modeling and parameter calculation of urban trees. In this study, 3D models were reconstructed based on SfM, which were further processed to extract individual trees, as shown in Fig. \ref{fig:figure23}(a). Based on the 3D models, some useful parameters, such as trunk diameter and tree height, can be then calculated. Similarly, \cite{lumnitz2021mapping} adopted a deep learning network for individual tree detection from urban street images and depended on the single-view depth estimation and triangulation techniques to calculate the precise tree geo-localization.
The underwater image collection is a frequent task for marine exploration, which has been completed by using autonomous underwater vehicles. Acoustic sensors are widely utilized instruments for obstacle avoidance. However, they cannot work well at a close range. In the work of \cite{ochoa2022collision}, an obstacle detection instrument has been designed by using a spherical camera, which can generate real-time point clouds from a visual SLAM system and assist the autonomous obstacle detection, as presented in Fig. \ref{fig:figure23}(b).
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure23}
\caption{Spherical cameras for (a) urban tree detection\cite{itakura2020automatic} and (b) obstacle avoidance of underwater vehicles\cite{ochoa2022collision}.}
\label{fig:figure23}
\end{figure}
\section{Prospects}
\label{sec:4}
3D reconstruction of spherical images has been greatly promoted by the development of professional and consumer-grade cameras and automatic image processing techniques, as well as their increasing usage in varying fields. Compared with classical perspective images, there still exist some challenges for 3D reconstruction based on spherical images, which can be categorized as exploitation of crowdsource image, spatial resolution of spherical image, camera distortion and calibration, and integration of aerial-ground image. The details are presented in the following subsections.
\subsection{Exploitation of crowdsource image}
\label{sec:4.1}
In recent years, spherical images can be easily recorded based on low-cost and easy-to-use spherical cameras, as presented in Fig. \ref{fig:figure4}. Besides, spherical images can also be downloaded from well-known map providers, e.g., Google Maps and Tencent Maps. These crowdsource images are usually freely provided for non-commercial usage, which plays a critical role in spherical image-based applications\cite{biljecki2021street}. However, 3D reconstruction based on these crowdsource images is non-trivial for two main reasons. On the one hand, the diversity of crowdsource images is very large, which can be recorded by using professional or consumer-grade cameras, and obtained from indoor or outdoor scenes, as shown in Fig. \ref{fig:figure24}; on the other hand, the overlap degree of crowdsource images can not be ensured since they are captured by non-professional users or just for the visual navigation purpose. These factors can frequently cause the failure of 3D reconstruction.
Crowdsource images still have great potential in 3D reconstruction, especially for urban buildings, although they have the above-mentioned drawbacks. There are some possible solutions to exploit the potential of freely available crowdsource images. First, image classification methods can be used to separate indoor and outdoor images, e.g., recent deep learning-based networks. The classified images can be used for subsequent indoor or outdoor 3D modeling. Second, existed crowdsource images can be useful compensation from the street viewpoints, such as for UAV images from aerial viewpoints. In this situation, crowdsource images could be registered to the reconstructed 3D models from UAV images, avoiding the requirement of high overlap degrees in image-based 3D reconstruction.
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure24}
\caption{Crowdsource images from Google Street Views.}
\label{fig:figure24}
\end{figure}
\subsection{Spatial resolution of spherical image}
\label{sec:4.2}
Spherical cameras record the 360 by 180 degrees of surrounding environments using only one shot, which dramatically accelerates data acquisition. However, because of the limited CCD (Charge Coupled Device) dimensions of cameras, the spatial resolution of collected images is also obviously decreased when compared with classical perspective cameras withmages the same CCD dimensions. The spatial resolution causes a contradiction between the efficiency of data acquisition and the quality of the reconstructed model.
\begin{itemize}
\item \textbf{The efficiency of data acquisitions.} Much more time would be consumed to record images with higher resolutions to ensure the endurance of camera exposure. For example, a Weiss AG Civetta spherical camera can record images with a dimension of 230 M pixels as it uses a rotation lens to scan surrounding scenes. This camera, however, can only install on a ground-fixed tripod since it consumes about 40 seconds for each camera exposure.
\item \textbf{The quality of reconstructed models.} The consumer-grade cameras usually consist of two or more dioptric camera modules, such as the Theta X camera with two lenses. This design model decreases the time costs consumed in outdoor data acquisition. However, they sacrifice the spatial resolution of recorded images, which can further reduce the quality of reconstructed models.
\end{itemize}
In order to increase the spatial resolution of spherical images, two possible solutions can be implemented without sacrificing the efficiency of data acquisition. On the one hand, more cameras can be integrated into one spherical camera as the spherical image is the fusion of images from these camera modules. This strategy has been widely used in recent spherical cameras, such as the Ladybug 5+ with six cameras and the Panono with 36 cameras; on the other hand, high-speed imaging could be a promising technology. It does not increase the size and weight of spherical cameras, and at the same time, it decreases the time costs for recording high-resolution images\cite{feng2016measurement}.
\subsection{Camera distortion and calibration}
\label{sec:4.3}
Serious geometric distortions exist in spherical images. On the one hand, the individual camera module has imaging geometric distortions; on the other hand, generating the spherical image would also introduce distortions. Especially for consumer-grade cameras, such as Ricoh Theta X and Insta360 Sphere, these cameras project multiple images from each camera onto a sphere and generate the ERP format spherical images.
Generally, an ideal unit sphere camera model is used in the generation of the ERP format, as illustrated in Fig. \ref{fig:figure13}(c), including the well-known commercial and open-source software packages Agisoft Metashape, Pix4Dmapper, and OpenMVG. This projection would introduce distortions and cause errors in 3D reconstruction. Fig. \ref{fig:figure25} presents a comparison of 3D models reconstructed from consumer-grade and professional spherical images. It is clearly shown that the point clouds in Fig. \ref{fig:figure25}(a) are very coarse, even on the plain wall. On the contrary, the point clouds generated using the professional camera are more accurate, from which the text is very clear. Therefore, camera calibration should be seriously considered and executed for spherical images to improve the quality of reconstructed models.
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth]{Figure25}
\caption{The illustration of dense matching point clouds from (a) a consumer-grade camera; and (b) a professional camera.}
\label{fig:figure25}
\end{figure}
\subsection{Integration of aerial-ground image}
\label{sec:4.4}
Although spherical cameras can record 360 by 180 degrees of surrounding environments, their effective observation range is still limited to the near-ground region. In order to obtain complete reconstruction, aerial images must be integrated with ground spherical images. In the literature, there are valuable attempts for the integration of aerial-ground images in the context of 3D reconstruction, which can be roughly divided into 2D image-based methods and 3D point cloud-based methods\cite{gao2018accurate}.
\begin{itemize}
\item \textbf{2D image-based methods.} These methods aim to establish reliable correspondence between aerial and ground images and implement combined bundle adjustment by using both aerial and ground images. The commonly used strategies are image rectification and virtual rendering. The former aims to rectify aerial and ground images onto the same plane in the object space\cite{wu2018integration}; the latter utilizes the rough POS data of ground images and render virtual images from the 3D models reconstructed from aerial images\cite{zhu2020leveraging}. The core idea of these methods is to decrease the geometric distortion caused by large viewpoints. However, for spherical images, their camera imaging model differs from the conventional perspective model. Thus, further consideration should be paid to achieving the 2D image-based method.
\item \textbf{3D point cloud-based methods.} The core idea is to create 3D models separately from aerial and ground images and find reliable enough common 3D correspondences from these 3D models. The integration problem is then converted into the registration of 3D point clouds\cite{gao2018accurate}. However, for spherical images, two issues should be considered. On the one hand, the trajectory of spherical images is limited by the structure of urban streets, which causes large accumulate drift in SfM or SLAM-based image orientation. Thus, it may be hard to model the registration between 3D point clouds by using the commonly used similarity transformation; on the other hand, as shown in Fig. \ref{fig:figure25}, the reconstructed models of spherical images may contain many false 3D points due to camera distortions. Finding reliable correspondences becomes a non-trivial between 3D point clouds created from varying images.
\end{itemize}
For the first issue, the recent deep learning-based technique can be used to achieve reliable feature detection and matching. Especially for decreasing the projection distortions, the DCN (deformable convolutional network)\cite{zhu2019deformable} based network can be a promising technique to achieve viewpoint invariant feature detection, and the GCN (graph convolutional network) based network, e.g., SuperGlue\cite{sarlin2020superglue}, can exploit the context information to execute reliable feature matching. For the second issue, the large image orientation problem can be divided into some clusters based on the street structures, and the accumulated drift can be obviously decreased. This divide-and-conquer strategy has been used for efficient and accurate 3D reconstruction of UAV images\cite{jiang2022parallel}.
\section{Conclusions}
\label{sec:5}
Spherical images can record all surrounding environments by using one camera exposure. In contrast to perspective images with limited FOV, spherical images can cover the whole scene and have been increasingly used for 3D modeling in street-view and indoor environments. This paper reviews the 3D reconstruction of spherical images in terms of data acquisition, image matching, image orientation, and dense matching to wrap up recent techniques of 3D modeling based on spherical images. It also presents promising 3D reconstruction applications, including cultural heritage documentation, urban modeling and navigation, tunnel mapping and inspection, and other applications, e.g., urban tree localization, emergency response and rescue, and underwater collision avoidance. Finally, the main prospects are discussed in terms of the exploitation of crowdsource images, the spatial resolution of spherical images, camera distortion and calibration, and integration of aerial-ground images. According to this review, we can conclude that spherical images have great potential in the 3D reconstruction of street view and indoor scenes, and contemporary techniques can support their applications. Future studies can increase the spatial resolution of spherical cameras for data acquisition and exploit current deep learning-based methods to optimize the 3D reconstruction workflow.
\section{Acknowledgment}
\label{sec:6}
The authors would like to thank the anonymous reviewers and editors, whose comments and advice improved the quality of the work. This research was funded by the National Natural Science Foundation of China (Grant No. 42001413) and the Hong Kong Scholars Program (Grant No. 2021-114).
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
\nocite{*}
| {'timestamp': '2023-02-10T02:08:31', 'yymm': '2302', 'arxiv_id': '2302.04495', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04495'} | arxiv |
\section{You \emph{can} have an appendix here.}
\end{document}
\section{Additional Details}
\subsection{Explanation of Game Objectives}
\label{game_objectives}
\textbf{Skiing.} The player controls the direction and speed of a skier and must avoid obstacles, such as trees and moguls. The goal is to reach the end of the course as rapidly as possible, but the skier must pass through a series of gates (indicated by a pair of closely spaced flags). Missed gates count as a penalty against the player's time.
\textbf{Tennis.} The player plays the game of tennis. When serving and returning shots, the tennis players automatically swing forehand or backhand as the situation demands, and all shots automatically clear the net and land in bounds.
\textbf{Ms. Pac-Man.}
The player earns points by eating pellets and avoiding ghosts, which contacting them results in losing a life. Eating a ``power pellet'' causes the ghosts to turn blue, allowing them to be eaten for extra points. Bonus fruits can be eaten for increasing point values, twice per round.
\textbf{Breakout} Using a single ball, the player must use the paddle to knock down as many bricks as possible. If the player's paddle misses the ball's rebound, the player will lose a life.
\subsection{Outputs of QA Extraction Module}
\begin{table}[h]
{\centering
\begin{tabular}{l|m{20em} @{\hskip 0.3in} m{20em}}
Game & \multicolumn{1}{c}{Wikipedia} & \multicolumn{1}{c}{Official Manual}\\
\hline
& \multicolumn{2}{c}{What is the objective of the game?}\\
\cline{2-3}
\multirow{8}{3em}{Skiing} & To reach the bottom of the ski course as rapidly as possible. & To reach the bottom of the hill in the fastes time Have fun and god bless!".\\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{How to succeed in the game?}\\
\cline{2-3}
& N/A & Learning to control the tips of your skis and anticipating and avoiding trouble. \\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{How to score at the game?}\\
\cline{2-3}
& N/A & Elapsed time at the end of the run.\\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{Who are your enemies?}\\
\cline{2-3}
& N/A & N/A\\
\hline
& \multicolumn{2}{c}{What is the objective of the game?}\\
\cline{2-3}
\multirow{8}{3em}{Pacman} & The player earns points by eating pellets and avoiding ghosts. & To score as many points as you can practice clearing the maze of dots before trying to gobble up the ghosts.\\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{How to succeed in the game?}\\
\cline{2-3}
& The player earns points by eating pellets and avoiding ghosts. & Score as many points as you can. \\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{How to score at the game?}\\
\cline{2-3}
& The player earns points by eating pellets and avoiding ghosts. & N/A\\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{Who are your enemies?}\\
\cline{2-3}
& N/A & Ghosts. stay close to an energy pill before eating it, and tease the ghosts.\\
\hline
& \multicolumn{2}{c}{What is the objective of the game?}\\
\cline{2-3}
\multirow{8}{3em}{Tennis} & The first player to win one six-game set is declared the winner of the match. & N/A\\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{How to succeed in the game?}\\
\cline{2-3}
& The first player to win one six-game set is declared the winner of the match. & precisely aim your shots and hit them out of reach of your opponent. \\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{How to score at the game?}\\
\cline{2-3}
& N/A & The first player to win at least 6 games and be ahead by two games wins the set.\\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{Who are your enemies?}\\
\cline{2-3}
& N/A & N/A\\
\hline
& \multicolumn{2}{c}{What is the objective of the game?}\\
\cline{2-3}
\multirow{8}{3em}{Breakout} & The player must knock down as many bricks as possible. & Destroy the two walls using five balls To destroy the wall in as little time as possible The first player or team to completely destroy both walls or score the most points To smash their way through the wall and score points\\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{How to succeed in the game?}\\
\cline{2-3}
& the player must knock down as many bricks as possible by using the walls and/or the paddle below to hit the ball against the bricks and eliminate them & The first team to destroy a wall or score the most points after playing five balls wins the game To destroy the walls in as little time as possible \\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{How to score at the game?}\\
\cline{2-3}
& N/A & Scores are determined by the bricks hit during a game A player scores points by hitting one of the wall's bricks Smash their way through the wall and score points.\\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{Who are your enemies?}\\
\cline{2-3}
& N/A & N/A\\
\hline
\end{tabular}
}
\caption{\label{table:wiki_vs_official_FULL} Table showing the outputs of the QA Extraction module on Wikipedia instructions vs the official Atari manual. The Wikipedia manual is significantly shorter, and contains less information, causing the extractive QA model to repeat answers. However, the overall information, across the 4 questions, captured by the Extraction module is in good agreement across Wiki and Official manuals.}
\end{table}
\section{Background}\label{sec2}
\subsection{Reducing sample complexity in RL}
Prior works have attempted to improve sample efficiency with new exploration techniques \cite{schulman2017proximal,haarnoja2018soft,badia2020agent57}, self-supervised objectives \cite{pathak2017curiosity,muzero}, and static demonstration data \cite{kumar2019stabilizing,kumar2020conservative}. \citet{fan2022generalized} cast the RL training problems into a training data distribution optimization problem, and propose a policy mathematically controlled to traverse high-value and non-trivial states. However, such a solution requires manual reward shaping. Currently, the SOTA RL agent \cite{badia2020agent57} still requires billions of frames to complete the Skiing game that can be mastered by humans within minutes.
\subsection{Grounding objects for control problems}
\label{background:instruction}
Most prior works study grounding -- associating perceived objects with appropriate text -- in the setting of step-by-step instruction following for object manipulation tasks \cite{wang2016learning,bahdanau2018learning} or indoor navigation tasks \cite{chaplot2018gated,janner2018representation,chen2019touchdown,shridhar2020alfred}.
The common approach has been to condition the agent's policy on the embedding of both the instruction and observation \cite{mei2016listen,hermann2017grounded,janner2018representation,misra2017mapping,chen2019touchdown,pashevich2021episodic}. Recently, modular solutions have been shown to be promising \cite{min2021film}. However, the majority of these works use synthetic language. These often take the form of templates, e.g., ``what colour is $<$object$>$ in $<$room$>$'' \cite{chevalier2018babyai}.
On the other hand, recent attempts on large-scale image-text backbones, e.g., CLIP \cite{radford2021learning} have shown robustness at different styles of visual inputs, even on sketches. Therefore, CLIP may be the current best option for zero-shot grounding.
\subsection{Reinforcement learning informed by natural language}
\label{background:RL_text}
In the language-assisted setting, step-by-step instructions have been used to generate auxiliary rewards, when environment rewards are sparse. \citet{goyal2019using,wang2019reinforced} use auxiliary reward-learning modules trained offline to predict whether trajectory segments correspond to natural language annotations of expert trajectories.
In a more general setting, text may contain both information about optimal policy and environment dynamics.
\citet{branavan2012learning} improve Monte-Carlo tree search planning by accessing a natural language manual. They apply their approach to the first few moves of the game Civilization II, a turn-based strategy game. However, many of the features they use are handcrafted to fit the game of Civilization II, which limits the generalization of their approach.
\citet{narasimhan2018grounding,wang2021grounding} investigate planning in a 2D game environment with a fixed number of entities that are annotated by natural language (e.g. the `spider' and `scorpion' entities might be annotated with the descriptions ``randomly moving enemy'' and ``an enemy who chases you'', respectively). The agent learns to generalize to new environment settings by learning the correlation between the annotations and the environmental goals and mechanics. The proposed agent achieves better performance than the baselines, which do not use natural language. However the design of the 2D environment uses 6-line descriptions created from templates. Such design over-simplifies the observations into a 2D integer matrix, and removes the need for visual understanding and generalization to new objects and new formats of instruction manual, e.g., human written manuals.
\subsection{RL Models that Read Natural Language Instructions}
\citet{zhong2019rtfm,zhong2021silg} make use of special architectures with Bidirectional Feature-wise Linear Modulation Layers that support multi-hop reasoning on 6 $\times$ 6 grid worlds with template-generated instruction manuals. However, the model requires 200 million training samples from templates identical to the test environments. Such a training requirement results in performance loss even on 10 $\times$ 10 grid worlds with identical mechanics, thus limiting the generalization of the model.
\citet{wang2021grounding} mixes embedding of entities with multi-modal attention to get entity representations, which are then fed to a CNN actor. The attention model and CNN actor are trained jointly using RL. However, the whole framework is designed primarily for a grid world with a template generated instruction manual consisting of one line per entity.
In our experiments, we find that extracting entity embeddings from human-written Atari instruction manuals following \citet{wang2021grounding} does not improve the performance of our vision-based agent due to the complexity and diversity of the language.
\section{Conclusions}
In this work, we propose Read and Reward, a method that assists and speeds up RL algorithms on the Atari challenges by reading downloaded game manuals released by the Atari game developers. Our method consists of a QA extraction module that extracts and summarizes relevant information from the manual and a reasoning module that assigns auxiliary rewards to detected in-game events by reasoning with information from the manual. The auxiliary reward is then provided to a standard A2C RL agent.
To our knowledge, this work is the first successful attempt for using instruction manuals in a fully automated and generalizable framework for solving the widely used Atari RL benchmark \cite{badia2020agent57}. When assisted by our design, A2C improves on 4 games in Atari without immediate reward and requires 1000x fewer training frames compared to the previous SOTA Agent 57 on the hardest Skiing game.
\section{Limitations and Future Works}
\label{sec:limitations}
One of the main implementation challenges and limitations is the requirement of object localization and detection as mentioned in Section~\ref{sec:grounding}.
However, these limitations are not present in environments providing object ground-truth, such as modern game environments \cite{fan2022minedojo}, and virtual reality worlds \cite{ai2thor}. Other environments, such as indoor navigation and autonomous driving, include relatively reliable backbone object detection models \cite{he2017mask}.
In addition, with recent progress on video-language models, we believe that there will soon be more reliable solutions as drop-in replacements for our current algorithm for localization and detection.
Another simplification we made in Section~\ref{limitation_distance} is to consider only interactions where objects get sufficiently \textbf{close} to each other. While such simplification appears to be sufficient in Atari, where observations are 2D, one can imagine this to fail in a 3D environment like Minecraft \cite{fan2022minedojo} or an environment where multiple types of interaction could happen between same objects \cite{ai2thor}. Future works would benefit by grounding and tracking more types of events and interactions following \citet{wang2022language}.
\section{Introduction}\label{sec1}
Reinforcement Learning (RL) has achieved impressive performance in a variety of tasks, such as Atari \cite{mnih2015human,badia2020agent57}, Go \cite{silver2017mastering}, or autonomous driving \cite{GranTurismo,survey_driving}, and is hypothesized to be an important step toward artificial intelligence \cite{SILVER2021103535}. However, RL still faces a great challenge when applied to complicated, real-world-like scenarios \cite{shridhar2020alfworld,szot2021habitat} due to its low sample efficiency.
The Skiing game in Atari, for example, requires the skier (agent) to ski down a snowy hill and hit the objective gates in the shortest time, while avoiding obstacles. Such an intuitive game with simple controls (left, right) still required 80 billion frames to solve with existing RL algorithms \cite{badia2020agent57}, roughly equivalent to 100 years of non-stop playing.
Observing the gap between RL and human performance, we identify an important cause: the lack of knowledge and understanding about the game. One of the most available sources of information, that is often used by humans to solve real-world problems, is unstructured text, e.g., books, instruction manuals, and wiki pages. In addition, unstructured language has been experimentally verified as a powerful and flexible source of knowledge for complex tasks \cite{tessler2021learning}. Therefore, we hypothesize that RL agents could benefit from reading and understanding publicly available instruction manuals and wiki pages.
In this work, we demonstrate the possibility for RL agents to benefit from human-written instruction manuals.
We download per-game instruction manuals released by the original game developers\footnote{\href{https://atariage.com/system_items.php?SystemID=2600&itemTypeID=MANUAL}{atariage.com}} or Wikipedia and experiment with 4 Atari games where the object location ground-truths are available.
Two challenges arise with the use of human-written instruction manuals:
1) \emph{Length}: Manuals contain a lot of redundant information and are too long for current language models. However, only a few paragraphs out of the 2-3 page manuals contain relevant information for any specific aspect of concern, i.e., the game's objective or a specific interaction.
2) \emph{Reasoning}: References may be implicit and attribution may require reasoning across paragraphs. For example, in Skiing, the agent needs to understand that hitting an obstacle is bad using both ``you lose time if the skier hits an obstacle" and ``the objective is to finish in shortest time", which are from different parts of the manual. In addition, the grounding of in-game features to references in the text remains an open problem.
In addition to these challenges, manuals are unstructured and contain significant syntactic \emph{variation}. For example, the phrase ``don't hit an obstacle" is also referred to as ``don't get wrapped around a tree" or ``avoid obstacles". Finally, the grounding of in-game features to references in the text remains an open problem \cite{luketina2019survey}.
Our proposed Read and Reward framework (Figure~\ref{fig:archi}) addresses the challenges with a two-step process. First, a zero-shot extractive QA module is used to extract and summarize relevant information from the manual, and thus tackles the challenge of \emph{Length}. Second, a zero-shot reasoning module, powered by a large language model, \emph{reasons} about contexts provided by the extractive QA module and assigns auxiliary rewards to in-game interactions. After object detection and localization, our system registers an interaction based on the distance between objects. The auxiliary reward from the interaction can be consumed by any RL algorithm.
Even though we only consider ``hit" interactions (detected by tracking distance between objects) in our experiments, Read and Reward still achieves 60\% performance improvement on a baseline using 1000x fewer frames than the SOTA for the game of Skiing. In addition, since Read and Reward does not require explicit training on synthetic text \cite{hermann2017grounded,chaplot2018gated,janner2018representation,narasimhan2018grounding,zhong2019rtfm,zhong2021silg,wang2021grounding}, we observe consistent performance on manuals from two \emph{different} sources: Wikipedia and Official manuals.
To our knowledge, our work is the first to demonstrate the capability to improve RL performance in an end-to-end setting using real-world manuals designed for human readers.
\section{Read and Reward}\label{sec:read_and_reward}
We identify two key challenges to understanding and using the instruction manual with an RL agent.
The first challenge is \textbf{Length}.
Due to the sheer length of the raw text ($2\sim 3$ pages), current pre-trained language models cannot handle the raw manual due to input length constraints. Additionally, most works in the area of long-document reading and comprehension \cite{beltagy2020longformer,ainslie2020etc,zemlyanskiy2021readtwice} require a fine-tuning signal from the task, which is impractical for RL problems since the RL loss already suffers from high variance. Furthermore, an instruction manual may contain a lot of task-irrelevant information. For example, the official manual for MsPacman begins with: ``MS. PAC-MAN and characters are trademark of Bally Midway Mfg. Co. sublicensed to Atari, Inc. by Namco-America, Inc.''
\begin{figure*}[t]
\vspace{-3mm}
\centering
\centerline{\includegraphics[width=0.9\textwidth]{imgs/extract.png}}
\vspace{-6mm}
\caption{Illustration of the QA Extraction Module on the game PacMan. We obtain generic information about the game by running extractive QA on 4 generic questions (3 shown since one question did not have an answer). We then obtain object-specific information using a question template. We concatenate generic and object-specific information to obtain the $<$context$>$ string (used in Figure~\ref{fig:reasoning}).}
\label{fig:QA_extraction}
\vspace{-3mm}
\end{figure*}
It is therefore intuitive in our first step to have a QA Extraction Module that produces a summary directed toward game features and objectives, to remove distractions and simplify the problem of reasoning.
The second challenge is \textbf{Reasoning}. Information in the manual may be implicit. For example, the Skiing manual states that the goal is to arrive at the end in the fastest time, and that the player will lose time when they hit a tree, but it never states directly that hitting a tree reduces the final reward. Most prior works \cite{eisenstein2009reading,narasimhan2018grounding,wang2021grounding,zhong2019rtfm,zhong2021silg} either lack the capability of multi-hop reasoning or require extensive training to form reasoning for specific manual formats, limiting the generalization to real-world manuals with a lot of variations like the Atari manuals.
On the other hand, large language models have achieved success without training in a lot of fields including reading comprehension, reasoning, and planning \cite{brown2020language,kojima2022large,ahn2022can}. Therefore, in the Reasoning Module, we compose natural language queries about specific object interactions in the games, to borrow the in-context reasoning power of large language models.
The rest of the section describes how the two modules within our Read and Reward framework (a QA extraction module and a reasoning module) are implemented.
\paragraph{QA Extraction Module (Read)}\label{method:qa_extraction}
In order to produce a summary of the manual directed towards game features and objectives, we follow the extractive QA framework first proposed by \citet{bert}, which extracts a text sub-sequence as the answer to a question about a passage of text.
The extractive QA framework takes raw text sequence $S_{\text{manual}}=\{w^0, ...,w^L\}$ and a question string $S_{\text{question}}$ as input. Then for each token (word) $w^i$ in $S_{\text{manual}}$, the model predicts the probability that the current token is the start token $p^i_{\text{start}}$ and end token $p^i_{\text{end}}$ with a linear layer on top of word piece embeddings. Finally, the output $S_{\text{answer}}=\{w^{\text{start}},...,w^{\text{end}}\}$ is selected as a sub-sequence of $S_{\text{manual}}$ that maximizes the overall probability of the start and end: $w^{\text{start}},w^{\text{end}} = \arg\max_{w^{\text{start}},w^{\text{end}}} p^{\text{start}}p^{\text{end}}$.
Implementation-wise, we use a RoBERTa-large model \cite{liu2019roberta} for Extractive QA fine-tuned on the SQUAD dataset \cite{rajpurkar2016squad}. Model weights are available from the AllenNLP API\footnote{\href{https://demo.allennlp.org/reading-comprehension/transformer-qa}{AllenNLP Transformer-QA}}.
To handle instruction manual inputs longer than the maximum length accepted by RoBERTa, we split the manual into chunks according to the max-token size of the model, and concatenate extractive QA outputs on each chunk.
As shown in Figure~\ref{fig:QA_extraction}, we compose a set of generic prompts about the objective of the game, for example, ``What is the objective of the game?''. In addition, to capture information on agent-object interactions, we first identify the top 10 important objects using TFIDF. Then for each object, we obtain an answer to the generated query:``What happens when the player hit a $<$object$>$?''.
Finally, we concatenate all non-empty question-answer pairs per interaction into a $<$context$>$ string.
Note that the format of context strings closely resembles that of a QA dialogue.
\begin{figure}[h]
\centering
\centerline{\includegraphics[width=0.45\textwidth]{imgs/reasoning.png}}
\vspace{-3mm}
\caption{Illustration of the QA Extraction Module. The $<$context$>$ (from Figure~\ref{fig:QA_extraction}) related to the object \textbf{ghost} from the QA Extraction module is concatenated with a template-generated question to form the zero-shot in-context reasoning prompt for a Large Language Model. The Yes/No answer from the LLM is then turned into an auxiliary reward for the agent.}
\label{fig:reasoning}
\vspace{-3mm}
\end{figure}
\paragraph{Zero-shot reasoning with pre-trained QA model (Reward)}\label{method:read_and_reward:reasoning}
The summary $<$context$>$ string from the QA Extraction module could directly be used as prompts for reasoning through large language models \cite{brown2020language,kojima2022large,ahn2022can}.
Motivated by the dialogue structure of the summary, and the limit in computational resources, we choose Macaw \cite{macaw}, a general-purpose zero-shot QA model with performance comparable to GPT-3 \cite{brown2020language}. Compared to the RoBERTa extractive QA model for the QA Extraction module, Macaw is significantly larger and is better suited for reasoning. Although we find that GPT-3 generally provides more flexibility and a better explanation for its answers for our task, Macaw is faster and open-source.
As shown in Figure~\ref{fig:reasoning}, for each interaction we compose the query prompt as ``$<$context$>$ Question: Should you hit a $<$object of interaction$>$ if you want to win? Answer: '', and calculate the LLM score on choices \{Yes, No\}. The Macaw model directly supports scoring the options in a multiple-choice setting. We note that for other generative LLMs, we could use the probability of ``Yes" v.s. ``No" as scores similar to \citep{ahn2022can}.
Finally, during game-play, a rule-based algorithm detects `hit' events by checking the distance between bounding boxes. For detected interactions, an auxiliary reward is provided to the RL algorithm according to \{Yes, No\} rating from the reasoning module (see Section~\ref{limitation_distance} for details).
\section{Experiments}
\subsection{Atari Environment}
The Openai gym Atari environment contains diverse Atari games designed to pose a challenge for human players. The observation consists of a single game screen (frame): a 2D array of 7-bit pixels, 160 pixels wide by 210 pixels high. The action space consists of the 18 discrete actions defined by the joystick controller. Instruction manuals released by the original game developers have been scanned and parsed into publicly available HTML format\footnote{\href{https://atariage.com/system_items.php?SystemID=2600&itemTypeID=MANUAL}{atariage.com}}. For completeness, we also attach an explanation of the objectives for each game in Appendix~\ref{game_objectives}.
\subsection{Atari Baselines}
\paragraph{A2C} A2C \cite{mnih2016asynchronous} and PPO \cite{schulman2017proximal} are among some of the earliest Actor-Critic algorithms that brought success for deep RL on Atari games. A2C learns a policy $\pi$ and a value function $V$ to reduce the variance of the REINFORCE \cite{sutton1999policy} algorithm. The algorithm optimizes the advantage function $A(s,a)=Q(s,a)-V(s)$ instead of the action value function $Q(s,a)$ to further stabilize training.
\paragraph{MuZero}
MuZero algorithm \cite{muzero} combines a tree-based search with a learned model of the environment. The model of MuZero iteratively predicts the reward, the action-selection policy, and the value function. When applied to the Atari benchmarks, MuZero achieves super-human performance in a lot of games.
\paragraph{R2D2}
R2D2 \cite{kapturowski2018recurrent} proposes an improved training strategy for RNN-based RL agents with distributed prioritized experience replay. The algorithm is the first to exceed human-level performance in 52 of the 57 Atari games.
\paragraph{Agent 57}
\citet{badia2020agent57} train a neural network that parameterizes a family of policies with different exploration, and proposes a meta-controller to choose which policy to prioritize during training. Agent 57 exceeds human-level performance on all 57 Atari games.
\subsection{Delayed Reward Schedule}\label{method:delayed_reward}
Most current Atari environments include a dense reward structure, i.e., the reward is obtained quite often from the environment. Indeed, most RL algorithms for the Atari environments perform well due to their dense reward structure.
However, in many real-world scenarios \cite{ai2thor,wang2022learning} or open-world environments \cite{fan2022minedojo}, it is expensive to provide a dense reward. The reward is usually limited and ``delayed" to a single positive or negative reward obtained at the very end of an episode (e.g., once the robot succeeds or fails to pour the coffee).
Notably, Atari games with the above ``delayed" reward structure, such as Skiing, pose great challenges for current RL algorithms, and are among some of the hardest games to solve in Atari \cite{badia2020agent57}.
Therefore, to better align with real-world environments, we use a \emph{delayed reward} version of the tennis, breakout, and Pac-Man games by providing the reward (the ``final game score") only at the end of the game. This delayed reward structure does not change the optimization problem, but is more realistic and imposes additional challenges to RL algorithms.
\subsection{Grounding Objects in Atari}
\label{sec:grounding}
We find grounding (detecting and relating visual objects to keywords from TFIDF) a significant challenge to applying our framework. In some extensively studied planning/control problems, such as indoor navigation, pre-trained models such as masked RCNN reasonably solve the task of grounding \cite{shridhar2020alfred}. However, the objects in the Atari environments are too different from the training distribution for visual backbones like mask RCNN. Therefore, the problem becomes very challenging for the domain of Atari. Since it is not the main focus of our proposed work, we attempt to provide an unsupervised end-to-end solution only for the game of Skiing.
\paragraph{Full end-to-end pipeline on Skiing}
\label{skiing_pipeline}
To demonstrate the full potential of our work, we offer a proof-of-concept agent directly operating on raw visual game observations and the instruction manual for the game of Skiing. For unsupervised object localization, we use SPACE, a method that uses spatial attention and decomposition to detect visual objects \cite{lin2020space}. SPACE is trained on 50000 random observations from the environment, and generates object bounding boxes. These bounded boxes are fed to CLIP, a zero-shot model that can pair images with natural language descriptions \cite{radford2021learning}, to classify the bounding box into categories defined by key-words from TF-IDF. The SPACE/CLIP models produce mostly reasonable results; however, in practice we find that CLIP lacks reliability over time, and SPACE cannot distinguish objects that cover each other. Therefore, to improve classification reliability, we use a Multiple Object Tracker \cite{sort} and set the class of the bounding box to be the most dominant class over time.
\begin{figure}[ht]
\vspace{-3mm}
\centering
\centerline{\includegraphics[width=0.5\textwidth]{imgs/detection_failure.png}}
\vspace{-2mm}
\caption{\label{fig:detection_failure}Examples of SPACE \cite{lin2020space} and CLIP \cite{radford2021learning} in the full end-to-end pipeline (Section~\ref{skiing_pipeline}). The top row shows bounding boxes for objects and the bottom row shows corresponding object masks as detected by SPACE. Most of the bounding boxes generated are correct. \textbf{Left}: SPACE confuses bounding boxes of agent and tree into one and the box gets classified as ``tree" (blue), and the auxiliary penalty is not properly triggered. \textbf{Right}: The flag next to the agent (in red circle) is not detected, and therefore the auxiliary reward is not provided.}
\vspace{-4mm}
\end{figure}
\paragraph{Ground-truth object localization/grounding experiments}
\label{ram_pipeline}
For other games (Tennis, Ms. Pac-Man, and Breakout), we follow \citet{anand2019unsupervised} and directly calculate the coordinates of all game objects from the simulator RAM state. Specifically, we first manually label around 15 frames with object name and X,Y coordinates and then train a linear regression model mapping from simulator RAM state to labeled object coordinates. Note that this labeling strategy does not work for games in which multiple objects of the same kind appears in a frame, i.e., multiple trees appear in one frame of Skiing.
\subsection{Simplifying Interaction Detection to Distance Tracking}
\label{limitation_distance}
We make the assumption that all object interactions in Atari can be characterized by the distance between objects, and we ignore all interactions that do not contain the agent. We note that since the Atari environment is in 2D, it suffices to consider only interactions where objects get close to the agent so that we can query the manual for ``hit" interaction.
We, therefore, monitor the environment frames and register interaction whenever an object's bounding boxes intersect with the agent. For each detected interaction, we assign rewards from $\{-r_n, r_p\}$ accordingly as detailed in Section~\ref{sec:read_and_reward}. Experimentally, we find that it suffices to set $r_n=r_p=5$.
\subsection{RL Agent}
Since Read and Reward only provides an auxiliary reward, it is compatible with any RL algorithms like PPO, SAC, TD3, and even Agent 57 \cite{schulman2017proximal,haarnoja2018soft,fujimoto2018addressing,badia2020agent57}. For simplicity, we use a popular open-source implementation \cite{stooke2019rlpyt} of A2C \cite{mnih2016asynchronous}.
\begin{figure}[t]
\vspace{-3mm}
\centering
\centerline{\includegraphics[width=0.5\textwidth]{figures/scatter.pdf}}
\vspace{-4mm}
\caption{\label{fig:skiing}Performance (in Game Score) vs Efficiency (in Frames Seen) of fully end-to-end Read and Reward (green) compared to an A2C baseline, and MuZero \cite{muzero} on Skiing. Benefiting from the auxiliary rewards from the instruction manual, Read and Reward out-performs the A2C Baseline and achieves 60\% improvement on random performance while using much fewer training frames compared to the SOTA mixed-policy Agent 57~\cite{badia2020agent57} and GDI-H3~\cite{fan2022generalized}.}
\vspace{-3mm}
\end{figure}
\begin{figure}[t]
\centering
\centerline{\includegraphics[width=0.55\textwidth]{figures/Breakout.pdf}}
\centerline{\includegraphics[width=0.55\textwidth]{figures/Tennis.pdf}}
\centerline{\includegraphics[width=0.55\textwidth]{figures/MsPacman.pdf}}
\caption{Comparison of the training curves of Read and Reward v.s. A2C Baseline in terms of game score alongside Auxiliary Reward v.s. Frames Seen under our delayed reward setting for 3 different Atari games. Read and Reward (red) consistently outperforms the A2C baseline (brown) in all games. In addition, the auxiliary reward from Read and Reward demonstrates a strong positive correlation with the game score, suggesting that the model benefits from optimizing the auxiliary rewards at training time.}
\label{fig:learning_curves}
\end{figure}
\begin{table*}[t]
{\centering
\begin{tabular}{l|m{20em} @{\hskip 0.3in} m{20em}}
Game & \multicolumn{1}{c}{Wikipedia} & \multicolumn{1}{c}{Official Manual}\\
\hline
& \multicolumn{2}{c}{What is the objective of the game?}\\
\cline{2-3}
\multirow{8}{3em}{Pacman} & The player earns points by eating pellets and avoiding ghosts. & To score as many points as you can practice clearing the maze of dots before trying to gobble up the ghosts.\\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{How to succeed in the game?}\\
\cline{2-3}
& The player earns points by eating pellets and avoiding ghosts. & Score as many points as you can. \\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{How to score at the game?}\\
\cline{2-3}
& The player earns points by eating pellets and avoiding ghosts. & N/A\\
\cline{2-3}\cline{2-3}
& \multicolumn{2}{c}{Who are your enemies?}\\
\cline{2-3}
& N/A & Ghosts. stay close to an energy pill before eating it, and tease the ghosts.\\
\hline
\end{tabular}
}
\caption{\label{table:wiki_vs_official} Table showing the outputs of the QA Extraction module on Wikipedia instructions vs the official Atari manual. The Wikipedia manual is significantly shorter, and contains less information, causing the extractive QA model to use the same answer for all questions. Full table for all 4 games is shown in Table~\ref{table:wiki_vs_official_FULL} in the Appendix.}
\vspace{-3mm}
\end{table*}
\subsection{Full Pipeline Results on Skiing}
We compare the performance of our Read and Reward agent using the full pipeline to baselines in Figure~\ref{fig:skiing}, our agent is best on the efficiency axis and close to best on the performance axis. A2C equipped with Read and Reward outperforms A2C baseline and more complex methods like MuZero \cite{muzero}. We note a 50\% performance gap between our agent and the SOTA Agent 57, but our solution does not require policy mixing and requires better than 1000 times fewer frames to converge to performance 60\% better than prior works.
When experimenting with a full end-to-end pipeline as described in Section~\ref{skiing_pipeline}, we notice instability with the detection and grounding models. As shown in Figure~\ref{fig:detection_failure}, missing bounding boxes cause lots of mislabeling when objects are close to each other. Such errors may lead to the auxiliary reward being incorrectly assigned. We observe that performance could further be improved
Although Skiing is arguably one of the easiest games in Atari for object detection and grounding, with easily distinguishable objects and white backgrounds, we still observe that current unsupervised object detection and grounding techniques lack reliability.
\begin{table}[h]
{\centering
\begin{tabular}{lccc}
& R\& R Wiki & R\& R Official & A2C\\
\hline
Tennis & \textbf{-5} & \textbf{-5} & -23 \\
Pacman & \textbf{580} & \textbf{580} & 452 \\
Breakout & \textbf{14} & \textbf{14} & 2
\end{tabular}
}
\vspace{-2mm}
\caption{\label{table:wiki_results} Table of the game score of algorithms trained under \emph{delayed reward} schedule, Read and Reward consistently outperforms the baseline A2C agent, which does not use the manual, using either Wikipedia (\textbf{Wiki}) instructions or official Atari manual (\textbf{Official}).}
\vspace{-3mm}
\end{table}
\subsection{Results on Games with Delayed Reward Structure}
Since the problem of object detection and grounding is not the main focus of this paper, we obtain ground-truth labeling for object locations and classes as mentioned in Section~\ref{ram_pipeline}. In addition, for a setting more generalizable to other environments~\cite{ai2thor,fan2022minedojo}, we implement \emph{delayed reward} schedule (Section~\ref{method:delayed_reward}) for Tennis, MsPacman, and Breakout.
We plot the Game Score and the auxiliary rewards of the Read and Reward agent v.s. the A2C baseline in Figure~\ref{fig:learning_curves}. The A2C baseline fails to learn under the sparse rewards, while the performance of the Read and Reward agent continues to increase with more frames seen. In addition, we observe that the auxiliary reward from the Read and Reward framework has a strong positive correlation with the game score (game reward) of the agent, suggesting that the A2C agent benefits from optimizing the auxiliary rewards at training time.
\subsection{R\&R Behavior on Manuals from Different Source}
To illustrate the generalization of our proposed framework to a different source of information, we download the ``Gameplay" section from Wikipedia\footnote{\href{https://en.wikipedia.org/}{wikipedia.org}} for each game and feed the section as manual to our model. In Table~\ref{table:wiki_vs_official}, we show a comparison of the answers on the set of 4 generic questions on the Pacman by our QA Extraction Module. Note that the QA Extraction module successfully extracts all important information about avoiding ghosts and eating pellets to get points. In addition, since the official manual contains more information than the Gameplay section of Wikipedia (2 pages v.s. less than 4 lines), we were able to extract much more information from the official manual.
Due to the high similarity in the output from the QA Extraction Module, the Reasoning module demonstrates good agreement for both the Wiki manual and the official manual. Therefore, we observe consistent agent performance between the official manual and the Wikipedia manual in terms of game score (Table~\ref{table:wiki_results}). | {'timestamp': '2023-02-14T02:15:01', 'yymm': '2302', 'arxiv_id': '2302.04449', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04449'} | arxiv |
\section{Related Works}
\label{sec:relatedWorks}
\noindent
\textbf{Decision Forest Benchmark.} There are several benchmark frameworks for boosting-based tree algorithms. Microsoft Fast Retraining~\cite{fast-training, fast-training-blog} focused on the training time and accuracy of the two boosting-based algorithms, LightGBM and XGBoost, on CPU and GPU. GBM-perf~\cite{gbm-perf} compared the classification of the Airline dataset using H2O, XGBoost, LightGBM, and Catboost. Microsoft further developed the LightGBM benchmark suite~\cite{lightgbm-bench} to provide tooling for comparing implementations of boosting-based algorithms for both training and inferencing. Nvidia gbm-bench~\cite{gbm-bench} made Fast Retraining more scriptable and added support for the CatBoosting and RandomForest algorithm to the benchmark framework. They also ensure that hyperparameters are consistent for each training framework~\cite{dorogush2018every}.
While we leveraged these benchmarks a lot, we found that they did not consider data management and end-to-end latency. None of the existing studies explored the key design decisions of the end-to-end inference pipeline.
\noindent
\textbf{Other Related Works.}
Raven~\cite{karanasos2019extending} proposed two techniques to co-optimize decision tree inference and SQL queries. The first technique is to prune the decision tree based on the selection queries. The second technique is to inline single and simple decision trees into UDFs leveraging the Froid framework~\cite{ramachandra2017froid}. However, Raven executes ensemble tree inferences (e.g., random forest) in ONNX runtime.
Clipper~\cite{crankshaw2017clipper} proposed various techniques to improve the performance of model serving (including decision forest models), such as inference result caching, dynamic batching, and model selection.
Browne et al.~\cite{browne2019forest} proposed memory packing techniques and a novel tree traversal method to overcome the random memory access overheads.
A recent work, TreeBeard~\cite{prasad2022treebeard}, proposed an optimizing compiler based on the Multi-level Intermediate Representation.
It achieved significant speedup compared to baselines such as TreeLite, HummingBird, and XGBoost.
Tahoe~\cite{xie2021tahoe} and Sharp~\cite{sharp2008implementing} optimized decision forest inferences for GPU, and Owaida et al.~\cite{owaida2017scalable} proposed a decision forest inference framework for FPGA.
\section{Experimental Configuration}
\label{sec:config}
\noindent
\textbf{Software Configuration.} We used version Scikit-learn v1.1.2, ONNX v1.12.0, Hummingbird v0.4.5, Nvidia Rapids-FIL v22.08, TreeLite v2.3.0, TFDF v0.2.7, PostgreSQL v14. For lleaves, netsDB, and ConnectorX, we used the code download from their Github master repositories. For all platforms, we carefully tune the number of threads to fully use the computational resources.
We ran the HummingBird models in several different backends, including Pytorch v1.13.1, TorchScript (within Pytorch v1.13.1), and TVM v0.10.0, with and without GPU acceleration.
Nvidia FIL provides multiple options for inferences: (1) Auto, which automatically estimates and selects the best-performing strategy; (2) Batch Tree Reorganization for the dense forest storage format; (3) Using the sparse forest storage format. We used the Auto option by default.
The TFDF platform only supported the loading from Scikit-learn RandomForest models~\cite{tf-df}. With the help of Google TFDF engineers, we developed a converter to import XGBoost models to TFDF models. To this point, there is no API available for parallelizing the TFDF inference process, and it is slower than other platforms in most cases, and we omit the TFDF results in the overall evaluation (Sec.~\ref{sec:overall-evaluation}) and only discuss them in the detailed analysis (Sec.~\ref{sec:analysis}).
\noindent
\textbf{Hardware Configuration.}
For CPU experiments, we used the AWS EC2 r4.2xlarge instance with $8$ CPU cores and $62$ gigabytes of memory. All instances are installed with Linux Ubuntu $20$ and $200$ gigabytes SSD storage. The cost of the instance is \$$0.532$ per hour.
For the GPU experiments, we used an AWS g4dn.2xlarge instance, which has an NVIDIA T4 Tensor Core GPU with $16$ gigabytes memory and an eight-core CPU with $32$ gigabytes host memory. Its cost is \$$0.752$ per hour.
To resolve the performance variations in cloud environments, we repeated each experiment multiple times. In total, we used more than $\textit{\textbf{10,000}}$ hours of the AWS EC2 platform for the evaluation.
\noindent
\textbf{Profiling}
We monitored the various system resource utilization for CPU, memory, and disk I/O. In addition, we used Linux Perf to profile the elapsed time as well as cache misses. We used gpustat, a wrapper built on nvidia-smi, for profiling the GPU performance and memory utilization.
\section{Overall Evaluation Results}
\label{sec:overall-evaluation}
We first describe the overall evaluation results in three categories: small-scale dense datasets, medium to large-scale dense datasets, and sparse and/or wide datasets. For each case/measurement, the batch size is carefully tuned for each platform to achieve the lowest latency. We will discuss how batch size affects the overall performance in the detailed analysis (Sec.~\ref{sec:analysis}). Finally, we will discuss the model conversion and loading overheads which are not counted in the overall evaluation results.
\subsection{Small-Scale Dense Datasets}
In this section, we will summarize the results on two relatively smaller datasets: Fraud and Year, as described in Tab.~\ref{tab:datasets}.
The overall benchmark results for Fraud and Year are illustrated in Tab.~\ref{tab:fraud} and Tab.~\ref{tab:year}.
It showed that among all CPU/GPU platforms, netsDB with the UDF-centric representation (netsDB-UDF) achieved the lowest latency for small models that have $10$ trees. NetsDB with the model reuse optimization (netsDB-OPT) significantly reduced the latency for the relation-centric representation (netsDB-Rel) and achieved the lowest latency for medium to large models with $500$ and $1600$ trees across all platforms. That is because inference on such small datasets is significantly faster than data transfer, and data transfer thus becomes the major bottleneck. This bottleneck gets avoided using in-database inference.
\begin{table*}[]
\begin{center}
\small
\resizebox{\textwidth}{!}{
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c||c|c|c|c|}
\hline
&\multicolumn{10}{|c||}{CPU} & \multicolumn{4}{c|}{GPU}\\
&Sklearn&ONNX&HB-Pytorch&HB-TS&HB-TVM&TreeLite&lleaves&netsDB-UDF&netsDB-Rel&netsDB-OPT&HB-Pytorch&HB-TS&HB-TVM&FIL\\
\hline
\multicolumn{15}{|c|}{\texttt{RandomForest}} \\
\hline
10 Trees &1.0&1.0&1.0&1.3&1.0&1.0&-&\textbf{0.5}&2.1&0.6&\textbf{0.9}&1.4&\textbf{0.9}&1.0\\
500 Trees &1.3&1.1&4.4&4.0&1.5&1.2&-&1.3&2.3&\textbf{0.7}&1.0&1.4&\textbf{0.9}&1.0\\
1600 Trees &2.2&1.4&13.0&11.0&2.8&1.8&-&3.5&2.6&\textbf{1.0}&1.2&1.6&\textbf{1.0}&\textbf{1.0}\\
\hline
\multicolumn{15}{|c|}{\texttt{XGBoost}} \\
\hline
10 Trees &1.0&1.0&1.0&1.3&1.0&1.0&-&\textbf{0.5}&2.1&0.7&\textbf{0.9}&1.7&\textbf{0.9}&1.0\\
500 Trees &1.1&1.1&4.5&4.1&1.7&1.2&-&1.0&2.3&\textbf{0.8}&1.0&1.7&\textbf{0.9}&1.0\\
1600 Trees &1.3&1.4&13.0&11.0&2.5&1.4&-&2.1&2.6&\textbf{1.0}&1.2&1.7&\textbf{1.0}&\textbf{1.0}\\
\hline
\multicolumn{15}{|c|}{\texttt{LightGBM}} \\
\hline
10 Trees &1.0&1.0&1.0&1.4&1.0&1.0&1.0&\textbf{0.5}&2.1&0.6&\textbf{0.9}&1.7&\textbf{0.9}&1.0\\
500 Trees &1.5&1.2&4.4&4.0&1.7&1.5&1.0&1.1&2.3&\textbf{0.8}&1.0&1.7&\textbf{0.9}&1.0\\
1600 Trees &2.5&1.6&12.8&10.7&2.5&2.6&1.2&1.7&2.8&\textbf{1.1}&1.2&1.7&\textbf{0.9}&1.0\\
\hline
\end{tabular}
}
\caption{End-to-End Latency Comparison for Fraud. (Unit: seconds)}
\label{tab:fraud}
\end{center}
\end{table*}
\begin{table*}[]
\begin{center}
\small
\resizebox{\textwidth}{!}{
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c||c|c|c|c|}
\hline
&\multicolumn{10}{|c||}{CPU} & \multicolumn{4}{c|}{GPU}\\
&Sklearn&ONNX&HB-Pytorch&HB-TS&HB-TVM&TreeLite&lleaves&netsDB-UDF&netsDB-Rel&netsDB-OPT&HB-Pytorch&HB-TS&HB-TVM&FIL\\
\hline
\multicolumn{15}{|c|}{\texttt{RandomForest}} \\
\hline
10 Trees &4.7&4.7&4.8&5.1&4.7&4.7&-&\textbf{0.5}&2.3&0.8&\textbf{3.8}&4.3&\textbf{3.8}&3.9\\
500 Trees &5.5&5.2&11.5&10.4&5.9&6.4&-&1.4&2.9&\textbf{1.3}&\textbf{3.9}&4.4&\textbf{3.9}&4.0\\
1600 Trees &7.3&6.5&27.4&23.1&7.7&10.8&-&4.8&4.2&\textbf{2.6}&4.3&4.6&\textbf{4.0}&\textbf{4.0}\\
\hline
\multicolumn{15}{|c|}{\texttt{XGBoost}} \\
\hline
10 Trees &4.6&4.7&4.7&5.2&4.7&4.7&-&\textbf{0.5}&2.3&0.8&\textbf{3.8}&4.6&\textbf{3.8}&3.9\\
500 Trees &5.1&5.1&11.2&10.3&6.2&6.1&-&1.6&2.8&\textbf{1.2}&4.0&5.0&\textbf{3.8}&3.9\\
1600 Trees &6.1&5.9&26.7&23.2&7.1&9.7&-&4.8&3.8&\textbf{2.3}&4.3&5.3&\textbf{4.0}&\textbf{4.0}\\
\hline
\multicolumn{15}{|c|}{\texttt{LightGBM}} \\
\hline
10 Trees &4.7&4.7&4.8&5.1&4.7&4.7&4.7&\textbf{0.5}&2.3&0.8&\textbf{3.8}&4.3&\textbf{3.8}&3.9\\
500 Trees &6.3&5.2&11.3&10.3&6.1&6.1&5.0&1.5&2.7&\textbf{1.2}&4.0&4.4&\textbf{3.8}&4.0\\
1600 Trees &10.2&6.1&26.5&22.7&7.4&9.9&5.9&5.0&3.7&\textbf{2.2}&4.3&4.6&\textbf{4.0}&4.1\\
\hline
\end{tabular}
}
\caption{End-to-End Latency Comparison for Year. (Unit: seconds)}
\label{tab:year}
\end{center}
\end{table*}
\eat{
\begin{table}[]
\begin{center}
\small
\begin{tabular}{|c||c|c||c|c|}\hline
&\multicolumn{2}{|c||}{Fraud} & \multicolumn{2}{c|}{Year}\\
&CPU&GPU&CPU&GPU\\
\hline
\multicolumn{5}{|c|}{\texttt{RandomForest}} \\
\hline
10 Trees &\textbf{0.01} &0.02 &\textbf{0.01}&0.08 \\
500 Trees &\textbf{0.01} &0.02 &\textbf{0.02}&0.08 \\
1600 Trees &\textbf{0.01}&0.02&\textbf{0.04}&0.08\\
\hline
\multicolumn{5}{|c|}{\texttt{XGBoost}} \\
\hline
10 Trees &\textbf{0.01} &0.02 &\textbf{0.01}&0.08 \\
500 Trees &\textbf{0.01} &0.02 &\textbf{0.02}&0.08 \\
1600 Trees &\textbf{0.01}&0.02&\textbf{0.03}&0.08\\
\hline
\multicolumn{5}{|c|}{\texttt{LightGBM}} \\
\hline
10 Trees &\textbf{0.01} &0.02 &\textbf{0.01}&0.08 \\
500 Trees &\textbf{0.01} &0.02 &\textbf{0.02}&0.08 \\
1600 Trees &\textbf{0.02} &\textbf{0.02} &\textbf{0.03}&0.08\\
\hline
\end{tabular}
\caption{Comparison of CPU cost for the best-performed CPU platform on r4.2xlarge (\$$0.532$ per hour), and GPU cost for the best-performed GPU platform on g4dn.2xlarge (GPU, \$$0.752$ per hour) for inferring on small datasets (Unit:cents)}
\label{tab:small-cpu-gpu}
\end{center}
\end{table}
}
\begin{figure}[h]
\centering
\vspace{-10pt}
\subfigure[10 trees]{
\label{fig:10trees}
\includegraphics[width=0.48\textwidth]{figures/small_10trees_breakdown.pdf}}
\subfigure[500 trees]{
\label{fig:500trees}
\includegraphics[width=0.48\textwidth]{figures/small_500trees_breakdown.pdf}}
\subfigure[1600 trees]{
\label{fig:1600trees}
\includegraphics[width=0.48\textwidth]{figures/small_1600trees_breakdown.pdf}}
\caption{\label{fig:small-breakdown} \small
{\color{black}Latency breakdown for netsDB, the fastest of the rest CPU platforms, and the fastest GPU platform on small datasets.}
}
\end{figure}
\subsubsection{Fraud}
We have the following key observations on this workload.
First, netsDB outperformed other CPU/GPU platforms. That is because data transfer is the major bottleneck of the Fraud workload, as illustrated in Fig.~\ref{fig:small-breakdown}. When applying $10$-tree models to the Fraud dataset, data transfer accounts for $90\%$ of overall latency on ONNXCPU, $95\%$ on lleaves, and $97\%$ on HB-TVM. However, the ratio of data transfer latency to the overall latency decreases with the increase in model sizes. For example, for $1600$-tree models, the aforementioned ratios dropped to $65\%$, $76\%$, and $88\%$ respectively.
Second, netsDB-Rel performed significantly worse than other CPU/GPU platforms for models with $500$ and $1,600$ trees. That is mainly because it runs multiple pipeline stages, including partitioning the model to prepare for the \texttt{cross-product} operation. The scheduling and materialization overheads are significant compared to the inference latency. The model reuse technique, as in netsDB-OPT, resolved the issue and improved the performance.
Third, netsDB, ONNX, and lleaves achieved better monetary costs than GPU platforms (see Sec.~\ref{sec:config} for AWS cost information).
It indicates that GPU may not be very helpful for the inferences on small datasets, which is ubiquitous in real-time applications where testing samples are batched in small-size buffers to guarantee low buffering latency.
\subsubsection{Year}
The observations for the Year workload are similar to Fraud, except that netsDB achieved significantly higher speedups on the Year dataset.
For example, as illustrated in Tab.~\ref{tab:year}, for small models with $10$ trees, netsDB-UDF achieved $7.6\times$ speedup compared to the best GPU platform, and $9.4\times$ speedup compared to the best of the rest CPU platform. But the corresponding speedups achieved on the Fraud dataset were merely $1.8\times$ and $2\times$, respectively.
Then, for $500$-tree models, netsDB-OPT achieved $3\times$ speedup compared to the best GPU platform and $4\times$ speedup compared to the second-best CPU platforms, while the corresponding speedups achieved on the Fraud dataset was merely $1.1$ to $1.3\times$ for CPU and $1.1$ to $1.5\times$ for GPU.
In addition, for the case of $1,600$-tree models, for the Year dataset, netsDB-OPT achieved $1.7$ to $2.5\times$ speedup compared to the best GPU platform and $1.5$ to $2.7\times$ speedup compared to the second-best CPU platforms. However, for the same case, there was no significant speedup achieved on the Fraud dataset by netsDB-OPT compared to GPU platforms, and the speedup compared to the second-best CPU platforms was merely $1.1$ to $1.4\times$.
As illustrated in Fig.~\ref{fig:small-breakdown}, the data loading and writing times accounted for $96\%$, $96\%$, and $98\%$ on ONNXCPU, lleaves, and HB-TVM, respectively, which were even higher than the corresponding ratios for the Fraud workload. This explained the better speedup achieved on Year. Similar to Fraud, the ratio of data loading latency to the overall end-to-end latency decreased with the increase in model sizes. For $1600$-tree models, the aforementioned ratios dropped to $69\%$, $77\%$, and $94\%$ for the Year case.
\subsubsection{Summary of Findings}
The key findings are as follows:
\noindent
(1) The in-database inferences outperformed all CPU/GPU platforms for small datasets because the data loading process is always a major performance bottleneck.
\noindent
(2) NetsDB achieved lower costs than GPU platforms in all cases, and GPU is not very helpful for the inferences over small datasets, which are insufficient to fully utilize GPU resources. The inference computation time is insufficient to compensate for the overheads of transferring data between CPU and GPU.
\subsection{Medium to Large-Scale Dense Datasets}
This section mainly investigates the performance of three workloads, Higgs, Airline, and TPCx-AI. The overall benchmark results for these datasets are illustrated in Tab.~\ref{table:higgs}, Tab.~\ref{table:airline}, and Tab.~\ref{table:tpcx-ai}. When processing those larger-scale datasets, the latency difference between netsDB-Rel and netsDB-OPT is insignificant compared to the overall latency, so we omitted netsDB-OPT in the results.
\begin{table*}[]
\begin{center}
\small
\resizebox{\textwidth}{!}{
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c||c|c|c|c|}
\hline
&\multicolumn{9}{|c||}{CPU} & \multicolumn{4}{c|}{GPU}\\
&Sklearn&ONNX&HB-Pytorch&HB-TS&HB-TVM&TreeLite&lleaves&netsDB-UDF&netsDB-Rel&HB-Pytorch&HB-TS&HB-TVM&FIL\\
\hline
\multicolumn{14}{|c|}{\texttt{RandomForest}} \\
\hline
10 Trees &8.3&9.3&8.5&8.9&8.5&7.8&-&\textbf{0.9}&2.7&\textbf{7.7}&8.6&7.8&8.4\\
500 Trees &28.2&20.3&60.6&48.4&29.3&42.4&-&24.4&\textbf{14.2}&11.7&10.6&9.4&\textbf{8.7}\\
1600 Trees &70.8&45.2&205.5&167.1&80.8&130.4&-&98.6&\textbf{42.0}&20.6&16.1&\textbf{11.0}&11.1\\
\hline
\multicolumn{14}{|c|}{\texttt{XGBoost}} \\
\hline
10 Trees &8.1&9.3&8.7&8.8&8.8&8.3&-&\textbf{0.6}&2.3&8.0&8.6&\textbf{7.8}&8.0\\
500 Trees &19.1&20.8&57.5&47.5&33.0&35.3&-&25.9&\textbf{13.1}&11.6&11.0&8.4&\textbf{8.3}\\
1600 Trees &35.9&37.6&Failed&Failed&61.5&99.1&-&98.51&\textbf{34.7}&20.3&16.1&10.1&\textbf{8.8}\\
\hline
\multicolumn{14}{|c|}{\texttt{LightGBM}} \\
\hline
10 Trees &8.5&9.3&8.8&9.1&8.8&8.5&8.1&\textbf{0.9}&2.7&\textbf{7.8}&8.6&\textbf{7.8}&8.2\\
500 Trees &39.6&18.9&56.8&47.6&32.8&34.6&14.5&26.4&\textbf{14.2}&11.6&11.1&\textbf{8.5}&\textbf{8.5}\\
1600 Trees &113.2&39.2&202.8&183.3&61.1&102.8&\textbf{29.5}&119&38&20.3&16.1&9.1&\textbf{9.0}\\
\hline
\end{tabular}
}
\caption{End-to-End Latency Comparison for Higgs. (Unit: seconds)}
\label{table:higgs}
\end{center}
\end{table*}
\begin{table*}[]
\begin{center}
\small
\resizebox{\textwidth}{!}{
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c||c|c|c|c|}
\hline
&\multicolumn{9}{|c||}{CPU} & \multicolumn{4}{c|}{GPU}\\
&Sklearn&ONNX&HB-Pytorch&HB-TS&HB-TVM&TreeLite&lleaves&netsDB-UDF&netsDB-Rel&HB-Pytorch&HB-TS&HB-TVM&FIL\\
\hline
\multicolumn{14}{|c|}{\texttt{RandomForest}} \\
\hline
10 Trees &60.7&74.2&77.5&71.8&63.5&55.1&-&\textbf{3.3}&17.6&45.7&45.7&\textbf{45.3}&46.9\\
500 Trees &210.6&146.2&1502.2&1229.5&273.1&336.3&-&302.3&\textbf{82.4}&86.0&70.8&52.0&\textbf{50.3}\\
1600 Trees &543.5&305.5&5206.3&4144.7&760.8&1052.0&-&1120.6&\textbf{239.4}&177.7&126.4&70.6&\textbf{62.5}\\
\hline
\multicolumn{14}{|c|}{\texttt{XGBoost}} \\
\hline
10 Trees &59.2&73.3&77.9&69.8&63.8&59.8&-&\textbf{2.9}&18.6&45.7&45.8&\textbf{45.3}&46.1\\
500 Trees &143.4&137.8&1468.9&1212.8&305.2&264.7&-&272.3&\textbf{80.1}&85.3&70.7&51.3&\textbf{47.5}\\
1600 Trees &340.2&287.1&5130.3&4232.3&613.1&862.0&-&1071.1&\textbf{220.0}&175.8&125.0&68.4&\textbf{51.9}\\
\hline
\multicolumn{14}{|c|}{\texttt{LightGBM}} \\
\hline
10 Trees &60.5&74.7&77.5&71.8&64.3&59.4&58.8&\textbf{2.8}&18.6&45.7&45.8&\textbf{45.3}&46.7\\
500 Trees &339.7&144.1&1421.2&1142.6&306.4&224.5&98.8&96.9&\textbf{76.5}&85.2&70.9&51.4&\textbf{49.8}\\
1600 Trees &1039.2&296.5&4909.6&4198.1&614.0&654.8&\textbf{185.0}&914.8&220.7&176.1&125.1&68.5&\textbf{59.5}\\
\hline
\end{tabular}
}
\caption{End-to-End Latency Comparison for Airline. (Unit: seconds)}
\label{table:airline}
\end{center}
\end{table*}
\begin{table*}[]
\begin{center}
\small
\resizebox{\textwidth}{!}{
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c||c|c|c|c|}
\hline
&\multicolumn{9}{|c||}{CPU} & \multicolumn{4}{c|}{GPU}\\
&Sklearn&ONNX&HB-Pytorch&HB-TS&HB-TVM&TreeLite&lleaves&netsDB-UDF&netsDB-Rel&HB-Pytorch&HB-TS&HB-TVM&FIL\\
\hline
\multicolumn{14}{|c|}{\texttt{RandomForest}} \\
\hline
10 Trees &449.4&513.3&462.6&469.9&448.3&450.1&-&\textbf{3.2}&56.2&444.5&442.6&\textbf{442.3}&448.2\\
500 Trees &1233.9&865.1&4521.1&3087.0&1635.4&1061.0&-&1391.7&\textbf{363.7}&678.3&584.6&480.7&\textbf{465.6}\\
1600 Trees &3386.0&1649.3&15302.0&10482.5&4311.0&3153.7&-&5000.7&\textbf{1551.4}&1201.4&906.5&605.7&\textbf{526.7}\\
\hline
\multicolumn{14}{|c|}{\texttt{XGBoost}} \\
\hline
10 Trees &438.4&485.5&438.4&441.9&461.3&441.5&-&\textbf{2.3}&22.2&444.6&\textbf{443.1}&447.6&444.6\\
500 Trees &925.7&883.4&3821.6&2967.8&1835.4&1560.1&-&1328.1&\textbf{369.9}&678.3&583.5&476.6&\textbf{451.9}\\
1600 Trees &2014.7&1614.1&14093.3&11509.2&3590.2&4928.4&-&4735.7&\textbf{1612.9}&1193.0&895.1&578.6&\textbf{479.6}\\
\hline
\multicolumn{14}{|c|}{\texttt{LightGBM}} \\
\hline
10 Trees &445.1&509.9&434.1&436.7&447.0&434.2&434.7&\textbf{2.8}&22.2&443.3&\textbf{442.8}&445.7&447.7\\
500 Trees &2069.0&916.7&3711.0&3023.6&1876.2&1070.9&586.9&1122.0&\textbf{366.2}&672.9&580.5&478.4&\textbf{463.3}\\
1600 Trees &6146.0&1739.3&12196.5&11143.7&3646.8&3388.8&\textbf{997.2}&4623.6&1599.5&1186.2&890.1&573.6&\textbf{529.5}\\
\hline
\end{tabular}
}
\caption{End-to-End Latency Comparison for TPCx-AI. (Unit: seconds).}
\label{table:tpcx-ai}
\end{center}
\end{table*}
\eat{
\begin{table}[]
\begin{center}
\small
\begin{tabular}{|c||c|c||c|c||c|c|}\hline
&\multicolumn{2}{|c||}{Higgs} & \multicolumn{2}{c||}{Airline}& \multicolumn{2}{c|}{TPCx-AI}\\
&CPU&GPU&CPU&GPU&CPU&GPU\\
\hline
\multicolumn{7}{|c|}{\texttt{RandomForest}} \\
\hline
10 Trees &\textbf{0.01} &0.16 &\textbf{0.05}&0.94&\textbf{0.05} &9.24 \\
500 Trees &0.21 &\textbf{0.18} &1.22&\textbf{1.05}&\textbf{5.38} &9.73 \\
1600 Trees &0.62 &\textbf{0.23}&3.53&\textbf{1.31}&22.93 &\textbf{11.0}\\
\hline
\multicolumn{7}{|c|}{\texttt{XGBoost}} \\
\hline
10 Trees &\textbf{0.01} &0.16 &\textbf{0.04}&0.95&\textbf{0.03}&9.26\\
500 Trees &0.19 &\textbf{0.17} &1.18&\textbf{0.99}&\textbf{5.46}&9.44\\
1600 Trees &0.51 &\textbf{0.18} &3.25&\textbf{1.08}&23.84&\textbf{10.02}\\
\hline
\multicolumn{7}{|c|}{\texttt{LightGBM}} \\
\hline
10 Trees &\textbf{0.01} &0.16 &\textbf{0.04}&0.95&\textbf{0.04}&9.25\\
500 Trees &0.21 &\textbf{0.18} &1.13&\textbf{1.04}&\textbf{5.41}&9.68\\
1600 Trees &0.44 &\textbf{0.19} &2.73&\textbf{1.24}&14.73&\textbf{11.06}\\
\hline
\end{tabular}
\caption{Comparison of CPU cost of the best-performed CPU platform on r4.2xlarge (\$$0.532$ per hour), and GPU cost of the best-performed GPU platform on g4dn.2xlarge (\$$0.752$ per hour) for medium to large-scale datasets (Unit:cents)}
\label{table:large-cpu-gpu}
\end{center}
\end{table}
}
\begin{figure*}[]
\centering
\vspace{-10pt}
\subfigure[Higgs]{
\label{fig:higgs-breakdown}
\includegraphics[width=1\textwidth]{figures/higgs-breakdown.pdf}}
\subfigure[Airline]{
\label{fig:airline-breakdown}
\includegraphics[width=1\textwidth]{figures/airline-breakdown.pdf}}
\subfigure[TPCx-AI]{
\label{fig:tpcx-ai-breakdown}
\includegraphics[width=1\textwidth]{figures/tpcxai-breakdown.pdf}}
\caption{\label{fig:large-breakdown} \small
{\color{black}Latency breakdown for the netsDB, the fastest of the rest CPU platforms, and the fastest GPU platform for medium to large datasets.}
}
\end{figure*}
\subsubsection{Higgs}
As illustrated in Tab.~\ref{table:higgs}, when only using CPU processors, for a $10$-trees model, netsDB-UDF achieved $8$ to $10$ times speedup compared to the fastest of the rest CPU platforms. When using $500$ trees, netsDB-Rel achieved $1.3\times$ to $1.6\times$ speedup compared to the fastest of the rest CPU platforms. For large-scale decision forest models with $1,600$ trees, netsDB is slightly worse than the lleaves for LightGBM, but it is still slightly better than the Scikit-learn (XGBoost) and ONNX platforms and significantly better than all other CPU platforms.
When serving $500$ to $1,600$ trees, utilizing GPU significantly accelerated the decision forest prediction at even lower costs. Nvidia FIL and HummingBird with TVM as the backend achieved the best end-to-end performance on GPU.
As illustrated in Fig.~\ref{fig:higgs-breakdown}, most of the performance gain when using netsDB was contributed by the avoidance of the data transfer time, which is the major bottleneck for serving small-scale models. However, when the number of trees increases to $1600$ trees, inference, instead of data transfer, becomes the primary bottleneck, as illustrated in Fig.~\ref{fig:higgs-breakdown}. This explained the drop in the performance gain brought by netsDB with the increase in model sizes.
\subsubsection{Airline}
As illustrated in Tab.~\ref{table:airline}, the speedup achieved by netsDB on this workload is even higher than the Higgs workload. In terms of end-to-end time, for $10$-tree models, the netsDB-UDF achieved $18\times$-$21\times$ speedup compared to the fastest of the rest of the CPU platforms. For $500$-tree models, netsDB-Rel achieved $1.3\times$ to $1.9\times$ speedup compared to the fastest of the rest CPU platforms. Similar to Higgs, the performance gain shrinks with the increase in model size. For RandomForest and XGBoost $1,600$-tree models, netsDB-Rel achieved $1.3\times$ speedup. For LightGBM with $1,600$ trees, lleaves still performed slightly better than netsDB. In addition, similar to Higgs, the GPU platforms achieved significantly lower monetary costs than the CPU platforms in most cases.
As illustrated in Tab.~\ref{tab:datasets}, the size of the Airline testing dataset is five times larger than Higgs. As a result, the time spent in data transfer accounts for a significantly higher proportion in the end-to-end latency than Higgs, as observed in Fig.~\ref{fig:airline-breakdown}. This explained the increased performance gain of netsDB for the Airline case.
\vspace{-5pt}
\subsubsection{TPCx-AI} This workload used all $131$ million of samples for inferences.
With the increase in input dataset size, the data transfer time accounts for an even higher proportion in the overall latency than Higgs and Airline, as illustrated in Fig.~\ref{fig:large-breakdown}.
Correspondingly, the speedup achieved by netsDB also increased compared to Higgs and Airline, as illustrated in Tab.~\ref{table:tpcx-ai}.
NetsDB-UDF achieved more than $100 \times$ speedup compared to all other CPU/GPU platforms for the $10$-tree models. Moreover, for models with $500$ trees, netsDB-Rel achieved more than $1.6\times$ to $2.4\times$ speedup compared to the fastest of other CPU platforms, and it achieved $1.2\times$ to $1.3\times$ speedup compared to the fastest of the GPU platforms. Even for $1,600$-tree models, netsDB-Rel outperformed all other CPU platforms for RandomForest and XGBoost, though it is slower than lleaves for LightGBM. However, netsDB is slower than most of the GPU platforms in that case due to the increased GPU utilization. Compared to GPU platforms, the CPU platforms can reduce the monetary costs for models with $10$ trees and $500$ trees by $99\%$ and $44\%$, respectively. However, for serving models with $1,600$ trees, GPU can achieve better overall costs.
\subsubsection{Summary of Findings}
The key findings are:
\noindent
(1) On the CPU platforms, the in-database analytics outperformed other platforms in most cases, except that it is slightly worse than lleaves for large-scale model sizes (e.g., $1,600$ trees). That is because, when model size decreases, the data loading process becomes a more severe performance bottleneck.
\noindent
(2) GPU platforms outperformed netsDB on TPCx-AI using large models and Higgs and Airline using medium to large models.
However, netsDB outperformed most GPU platforms in all other cases.
\noindent
(3) NetsDB-Rel significantly improved the performance of medium to large-scale decision forest models compared to the netsDB-UDF. That is because model parallelism reduced the memory footprint and cache misses compared to data parallelism.
\noindent
(4) Lleaves, which compiles decision trees to partitioned and vectorized functions that consist of nested \texttt{if-else} blocks, achieved the best performance among CPU platforms for the LightGBM models.
\subsection{Wide and/or Sparse Datasets}
We also found that many popular datasets are wide and/or sparse. For example, in Bosch, Epsilon, and Criteo, each tuple has $968$, $2,000$, and $1$M features, respectively. Among these datasets, Bosch and Criteo are sparse datasets that contain missing values.
The overall results are illustrated in Tab.~\ref{tab:bosch}, Tab.~\ref{tab:epsilon}, and Tab.~\ref{tab:crieto}, which are explained in detail as follows.
\begin{table*}[]
\begin{center}
\small
\resizebox{\textwidth}{!}{
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c||c|c|c|c|}
\hline
&\multicolumn{10}{|c||}{CPU} & \multicolumn{4}{c|}{GPU}\\
&Sklearn&ONNX&HB-Pytorch&HB-TS&HB-TVM&TreeLite&lleaves&netsDB-UDF&netsDB-Rel&netsDB-OPT&HB-Pytorch&HB-TS&HB-TVM&FIL\\
\hline
\multicolumn{15}{|c|}{\texttt{XGBoost}} \\
\hline
10 Trees &22.8&23.0&22.6&23.7&23.8&23.6&-&\textbf{0.6}&4.2&2.4&\textbf{19.0}&20.0&19.5&19.6\\
500 Trees &23.4&24.9&28.4&27.1&26.1&26.2&-&\textbf{3.4}&8.0&6.2&\textbf{19.4}&19.9&19.6&19.7\\
1600 Trees &28.2&28.4&48.1&46.5&31.8&32.1&-&11.6&11.7&\textbf{10.1}&20.6&20.9&19.8&\textbf{19.7}\\
\hline
\multicolumn{15}{|c|}{\texttt{LightGBM}} \\
\hline
10 Trees &22.9&22.6&22.9&23.2&23.2&23.3&23.3&\textbf{0.6}&4.2&2.4&\textbf{19.0}&19.9&19.5&19.9\\
500 Trees &26.1&24.5&28.2&27.3&26.9&24.4&24.5&\textbf{3.2}&8.8&7.1&\textbf{19.4}&20.3&19.5&20.0\\
1600 Trees &35.3&29.1&43.8&44.2&32.7&29.7&27.1&9.8&11.9&\textbf{9.5}&20.6&20.9&\textbf{19.8}&20.1\\
\hline
\end{tabular}
}
\caption{End-to-End Latency Comparison for the Bosch. (Unit: seconds)}
\label{tab:bosch}
\end{center}
\end{table*}
\begin{table*}[]
\begin{center}
\small
\resizebox{\textwidth}{!}{
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c||c|c|c|c|}
\hline
&\multicolumn{9}{|c||}{CPU} & \multicolumn{4}{c|}{GPU}\\
&Sklearn&ONNX&HB-Pytorch&HB-TS&HB-TVM&TreeLite&lleaves&netsDB-UDF&netsDB-Rel&HB-Pytorch&HB-TS&HB-TVM&FIL\\
\hline
\multicolumn{14}{|c|}{\texttt{RandomForest}} \\
\hline
10 Trees &133.6&132.2&132.5&135.2&132.8&141.7&-&\textbf{0.4}&4.0&131.0&131.5&131.3&131.8\\
500 Trees &135.5&135.4&137.7&136.5&135.0&142.4&-&\textbf{3.1}&5.7&131.2&131.7&131.5&131.8\\
1600 Trees &138.1&135.1&141.8&141.6&135.9&-&-&9.7&\textbf{9.2}&131.6&132.1&131.5&131.9\\
\hline
\multicolumn{14}{|c|}{\texttt{XGBoost}} \\
\hline
10 Trees &132.3&132.3&132.8&132.4&134.4&132.6&-&\textbf{0.5}&3.9&131.0&131.9&131.3&131.5\\
500 Trees &132.6&135.2&135.4&141.1&135.7&134.6&-&\textbf{3.1}&5.7&131.2&132.4&131.5&131.6\\
1600 Trees &133.1&135.0&140.5&139.4&137.2&136.6&-&9.6&\textbf{9.0}&131.6&132.6&131.6&131.6\\
\hline
\multicolumn{14}{|c|}{\texttt{LightGBM}} \\
\hline
10 Trees &132.7&132.4&132.2&133.9&133.6&133.0&132.9&\textbf{0.5}&3.9&131.0&131.9&131.3&131.8\\
500 Trees &134.0&134.0&135.0&135.7&134.3&134.2&135.0&\textbf{3.1}&5.4&131.2&132.1&131.5&131.8\\
1600 Trees &136.2&135.2&139.2&137.4&135.8&143.1&-&9.1&\textbf{8.6}&131.6&132.3&133.4&132.0\\
\hline
\end{tabular}
}
\caption{End-to-End Latency Comparison for Epsilon. (Unit: seconds)}
\label{tab:epsilon}
\end{center}
\end{table*}
\begin{table}[]
\begin{center}
\small
\begin{tabular}{|c|c|c|c|}
\hline
&Sklearn&TreeLite&netsDB-UDF\\
\hline
\multicolumn{4}{|c|}{\texttt{RandomForest}} \\
\hline
10 Trees &130.8&124.7&\textbf{2.2}\\
500 Trees &409.0&152.1&\textbf{79.4}\\
1600 Trees &1061.7&\textbf{216.3}&277.9\\
\hline
\multicolumn{4}{|c|}{\texttt{XGBoost}} \\
\hline
10 Trees &125.2&126.2&\textbf{3.99}\\
500 Trees &209.8&\textbf{191.9}&193.1\\
1600 Trees &412.3&\textbf{326.7}&642.2\\
\hline
\multicolumn{4}{|c|}{\texttt{LightGBM}} \\
\hline
10 Trees &132.0&126.6&\textbf{4.0}\\
500 Trees &290.6&\textbf{141.7}&172.3\\
1600 Trees &645.7&\textbf{216.2}&564.6\\
\hline
\end{tabular}
\caption{End-to-End Latency for Criteo. (Unit: seconds)}
\label{tab:crieto}
\end{center}
\end{table}
\subsubsection{Bosch}
Bosch data in PostgreSQL contains NULL values. At the inference time, it is loaded from PostgreSQL as a Pandas DataFrame that contains nan values. Such sparse data is not directly supported in Scikit-learn for training a RandomForest model, which is needed by other dedicated inference platforms. Therefore, the RandomForest results are unavailable for this workload in Tab.~\ref{tab:bosch}.
For models trained on top of sparse data, each tree node specifies a default branch to follow if the feature of the tree node is missing in the input sample.
As illustrated in Tab.~\ref{tab:bosch}, for ten trees, netsDB-UDF achieved $37\times$ and $31\times$ speedup compared to the second-best CPU platform and the best GPU platform, respectively. For $500$ trees, netsDB-UDF achieved $8\times$ speedup on CPU and $6\times$ speedup on GPU. For $1,600$ trees, netsDB-OPT has better performance than netsDB-UDF, achieving $2.8\times$ speedup on CPU and $2.1\times$ speedup on GPU.
We found that wide and short datasets were inferred much faster than narrow and tall datasets of similar sizes. For example, the total size of Bosch is similar to Airline; however, the inference time of Bosch is significantly lower than Airline. That is because the number of tuples in Bosch is only $1\%$ of the number of tuples in the Airline dataset. (The computational complexity of the decision forest inference workload is mainly impacted by the number of tuples in the inference dataset, the number of trees, and the number of nodes in each tree.)
Moreover, because Bosch and Airline datasets have similar sizes, their data transfer overheads are similar. As a result, for Bosch, the ratio of the data transfer latency to the end-to-end latency is significantly higher than the Airline workload. It explains the increased speedup of netsDB on the Bosch dataset compared to the Airline dataset. It also indicates that netsDB can achieve better speedup compared to other platforms for wide and short datasets.
\begin{figure}[h]
\centering
\vspace{-10pt}
\includegraphics[width=0.45\textwidth]{figures/bosch-breakdown.pdf}
\caption{\label{fig:bosch-breakdown} \small
{\color{black} Comparison of Latency breakdown on netsDB, the second-best CPU platform, and the best GPU platform for Bosch}
}
\end{figure}
\subsubsection{Epsilon}
\label{sec:epsilon}
As aforementioned, Epsilon is a wide and dense dataset with $2,000$ features. Because PostgreSQL does not support more than $1,600$ columns, we store each sample as one column on PostgreSQL in array type for all platforms except netsDB. In netsDB, the dataset is stored as a collection of tensor blocks in pages, and the page size can be flexibly configured.
As illustrated in Tab.~\ref{tab:epsilon}, netsDB achieved more than $300\times$, $40\times$, $10\times$ speedup for models with $10$, $500$, and $1600$ trees, respectively, compared to the fastest of the rest of CPU platforms and all GPU platforms. There are two reasons contributing to such huge performance gains. First, it turns out that it is expensive to convert a PostgreSQL array type back to a NumPy array, which becomes the bottleneck at the inference time in all platforms except netsDB. Second, this dataset contains fewer tuples than other datasets investigated in the paper. Therefore, the inference complexity is significantly lower than other narrower workloads of similar sizes (e.g., Higgs), given the same number of trees and the same depth of each tree.
As illustrated in Fig.~\ref{fig:epsilon-breakdown}, $99\%$ of time is spent in data loading (including converting the data received from the PostgreSQL array column into a NumPy array). This explained (1) the performance benefits brought by the in-database inference in netsDB compared to other platforms; (2)why all other platforms have similar latency (i.e., the data loading overhead, which becomes the bottleneck, is similar for all platforms except netsDB).
\begin{figure*}[]
\centering
\vspace{-10pt}
\includegraphics[width=1\textwidth]{figures/epsilon-breakdown.pdf}
\caption{\label{fig:epsilon-breakdown} \small
{\color{black} Comparison of Latency breakdown on netsDB, the second best CPU platform, and the best GPU platform for Epsilon}
}
\end{figure*}
\subsubsection{Criteo}
\label{sec:criteo}
Criteo is stored in LIBSVM file format~\cite{libsvmdata, CC01a}, where each row contains a row index and a list of <column-index, non-zero-value> pairs, which reduced $80\%$ of storage space. Among the platforms studied in this work, sparse storage formats such as LIBSVM are only supported by Scikit-learn, TreeLite, and netsDB. Therefore, results for other platforms are unavailable. (Using dense format with other platforms failed due to out-of-memory errors.)
According to our observation, using such a sparse format significantly reduced the end-to-end latency by reducing the data transfer overheads and the memory footprint. However, as a side effect, the ratio of the data transfer latency to the overall latency is also significantly reduced. As a result, less performance gain can be achieved via in-database inference compared to other workloads that used the dense storage format. As illustrated in Tab.~\ref{tab:crieto}, although netsDB-UDF achieved $30\times$ to $60\times$ speedup for $10$ trees compared to Sklearn and TreeLite, the performance of netsDB-UDF is significantly worse than TreeLite for $500$ and $1,600$ trees.
\subsubsection{Summary of Findings}
The key takeaways are:
\noindent
(1) The in-database inferences represented by netsDB outperformed all CPU/GPU platforms if the wide dataset is stored in dense format with missing values represented as nan. That is because the data loading process is more of a performance bottleneck for dense datasets that are \textit{short-and-wide} than \textit{tall-and-narrow} datasets of similar sizes.
\noindent
(2) GPU is less helpful for the inferences over short and wide datasets than tall and narrow datasets of similar sizes. That is because the short and wide datasets contain fewer testing samples, reducing the workload's computational complexity.
\noindent
(3) In-database inferences significantly outperformed dedicated ML platforms if the data loading process involves a complicated transformation between the source format in data stores and the target format in ML platforms.
\noindent
(4) If a large dataset is extremely sparse (e.g., Criteo), a sparse storage format will significantly reduce the storage costs. However, the performance benefits of in-database inferences will diminish correspondingly. That is because the dataset becomes significantly smaller, which incurs less overhead for data transfer.
\subsection{Model Conversion}
\label{sec:model-conversion}
It is necessary to convert Scikit-learn models to other dedicated inference platforms such as ONNX, HummingBird, netsDB, TreeLite, and lleaves. Then the converted models must be loaded into corresponding platforms before running any inference tasks.
In the results presented in previous sections, we did not consider the model conversion time and the model loading time because these are one-time costs and can be amortized to all inference tasks that use the same model. Here, we discuss the model conversion and loading overheads.
As illustrated in Fig.~\ref{fig:conversion}, the platforms using the compiled tree traversal algorithm, such as TreeLite and lleaves, need more than one day to convert a $1,600$-tree model, which may hinder the adoption of such platforms. The conversion overheads for other platforms are around tens of seconds
As illustrated in Fig.~\ref{fig:loading}, most of the converted models can be loaded in a short time that can be neglected. However, because the converted HummingBird model cannot be persisted, we convert the model during the loading process. That is why HummingBird's loading process took significantly more time than other platforms.
\begin{figure}[h]
\centering
\vspace{-10pt}
\subfigure[Model conversion (Unit: seconds)]{
\label{fig:conversion}
\includegraphics[width=0.48\textwidth]{figures/Conversion_time_1600_LightGBM.pdf}}
\subfigure[Model loading (Unit: milli-seconds)]{
\label{fig:loading}
\includegraphics[width=0.48\textwidth]{figures/Model_loading_time_1600_LightGBM.pdf}}
\caption{\label{fig:one-time-overheads} \small
{\color{black} Comparison of model conversion and loading overheads for 1600-tree LightGBM models. }
}
\end{figure}
\section{Detailed Analysis}
\label{sec:analysis}
In this section, we summarize and discuss the impacts of the various performance factors.
\noindent
\textbf{Single-Thread Comparison}
TFDF is the only framework that implements the Quick-Scorer algorithm. However, it does not support multiple threads for inferences; and it incurs significant overheads when invoking the underlying C++-based decision forest library, called Yggdrasil~\cite{guillame2022yggdrasil}, by copying data multiple times. Therefore, we did not consider it in Sec.~\ref{sec:overall-evaluation} for fairness. Instead, we compared its performance of XGBoost to various CPU platforms here, all using a single thread. As illustrated in Tab.~\ref{tab:single-thread}, the results showed that QuickScorer achieved the best inference latency in the single-thread setting. Note that only inference time is measured, and the maximum tree depth is $6$ due to the leaf number limit in the QuickScorer implementation, as aforementioned in Sec.~\ref{sec:db-decisions}.
\begin{table}[]
\begin{center}
\small
\begin{tabular}{|c||c|c|c|c|c|c|}
\hline
\#trees&Yggdrasil&TFDF&Sklearn&ONNX&TreeLite&HB-TVM\\
\hline
\multicolumn{7}{|c|}{\texttt{Higgs}} \\
\hline
10 &\textbf{0.7}&2.1&1.3&1.3&\textbf{0.7}&1.9\\
500 &\textbf{29.0}&45.4&31.9&34.8&87.6&98.4\\
1600 &\textbf{96.5}&140.5&98.9&105.0&340.5&298.1\\
\hline
\multicolumn{7}{|c|}{\texttt{Fraud}} \\
\hline
10 &\textbf{0.01}&0.31&0.03&0.02&\textbf{0.01}&0.03\\
500 &\textbf{0.26}&0.63&0.87&0.73&1.34&0.51\\
1600 &\textbf{0.48}&1.01&1.67&1.81&3.12&1.44\\
\hline
\multicolumn{7}{|c|}{\texttt{Year}} \\
\hline
10 &\textbf{0.002}&0.23&0.12&0.06&0.05&0.11\\
500 &1.27&2.86&1.58&1.60&4.08&\textbf{0.90}\\
1600 &\textbf{4.14}&7.08&4.93&4.87&17.80&2.61\\
\hline
\end{tabular}
\caption{\small XGBoost inference time using single thread.(Unit:seconds)}
\label{tab:single-thread}
\end{center}
\end{table}
\noindent
\textbf{Further Discussions about CPU Platforms.} When using multi-threading, as illustrated in Sec.~\ref{sec:overall-evaluation},
Lleaves, which adopts the compilation-based algorithm and only supports LightGBM, achieved the best performance among most CPU platforms for LightGBM for large-scale models and large-scale inference data. Although both TreeLite and lleaves use similar code-generation ideas, lleaves significantly outperformed TreeLite because it employed LLVM and used more optimization techniques such as vectorization~\cite{lleaves}.
\noindent
\textbf{Further Discussions about GPU Platforms.} On GPU, the latest version of FIL achieved similar performance with HB-TVM (i.e., HummingBird using TVM as the backend). FIL is slightly better than HB-TVM for large decision forest models. We observed that the memory consumption of FIL is significantly lower than HB-TVM because the tensors used for replacing tree traversal required larger storage space.
In addition, the performance results of HummingBird using different backends vary significantly, which indicates that the performance of the same algorithm is significantly impacted by the implementation.
\eat{
\begin{figure}[h]
\centering
\vspace{-10pt}
\includegraphics[width=0.45\textwidth]{figures/higgs-gpu-memory-utilization.pdf}
\caption{\label{fig:higgs-gpu-memory} \small
{\color{black}GPU platform memory utilization comparison for decision forest with 1600 trees on Higgs. Both platforms use a batch size of 100000, which is the optimal batch size.}
}
\end{figure}
}
\eat{
\begin{table}[]
\begin{center}
\small
\begin{tabular}{|c||c|c|c|}
\hline
&Auto&Dense forest w/ batch tree reorg&Sparse forest\\
\hline
\multicolumn{4}{|c|}{\texttt{RandomForest}} \\
\hline
10 Trees &0.7&0.7&0.7\\
500 Trees &1.0&1.0&1.3\\
1600 Trees &3.5&3.5&3.5\\
\hline
\multicolumn{4}{|c|}{\texttt{XGBoost}} \\
\hline
10 Trees &0.5&0.5&0.5\\
500 Trees &0.7&0.7&0.9\\
1600 Trees &1.3&1.3&1.9\\
\hline
\multicolumn{4}{|c|}{\texttt{LightGBM}} \\
\hline
10 Trees &0.7&0.7&0.7\\
500 Trees &1.0&1.0&1.3\\
1600 Trees &2.5&2.5&3.0\\
\hline
\end{tabular}
\caption{Comparison of the inference time with different storage configurations for Nvidia FIL with batch size tuned to 100,000. (Unit:seconds)}
\label{table:higgs-fil}
\end{center}
\end{table}
}
\noindent
\textbf{Parallelism Model} When the model size increases to $500$ to $1,600$ trees, we found that model parallelism significantly outperformed data parallelism. For example, for $500$ and $1,600$ trees, netsDB-UDF, which uses data parallelism, is significantly slower than netsDB-Rel, which uses model parallelism, as explained in Sec.~\ref{sec:overall-evaluation}.
Model parallelism is preferred for large-scale models because after partitioning the model, each thread only requires access to a subset of trees, which greatly improves the cache locality. This is also proved by our profiling of cache misses.
Platforms that use data parallelism could also benefit from model partitioning. For example, In Yggdrasil, the underlying library of TF-DF, its optimized tree traversal algorithm, each thread will process $k$ trees at each iteration until all trees finish inference on the data partition. It achieved better performance than the naive tree traversal algorithm. Lleaves used similar ideas.
\noindent
\textbf{Batching}
On most of the platforms, the performance improved with the increase in batch size until the processing of the batch exceeded available (memory) resources. For example, for TPCx-AI, netsDB-Rel achieved the best performance if we partitioned the TPCx-AI dataset into five batches. For HummingBird platforms using Pytorch and TorchScript as backends on the CPU, the optimal batch size is around $1,000$, while the TVM backend usually achieved the best performance with a batch size of around $100,000$
\eat{
\begin{figure}[h]
\centering
\vspace{-10pt}
\includegraphics[width=0.45\textwidth]{figures/higgs-batching-cpu.pdf}
\caption{\label{fig:higgs-batching-cpu} \small
{\color{black}Inference time vs. batch size for CPU platforms for LightGBM with 1600 trees {on Higgs} (Unit: seconds).}
}
\end{figure}
\begin{figure}[h]
\centering
\vspace{-10pt}
\includegraphics[width=0.45\textwidth]{figures/higgs-batching-gpu.pdf}
\caption{\label{fig:higgs-batching-gpu} \small
{\color{black}Inference time vs. batch size for GPU platforms for LightGBM with 1600 trees {on Higgs} (Unit: seconds).}
}
\end{figure}
\begin{figure}[h]
\centering
\vspace{-10pt}
\includegraphics[width=0.45\textwidth]{figures/fraud-batching-cpu.pdf}
\caption{\label{fig:fraud-batching-cpu} \small
{\color{black}Inference time vs. batch size for CPU platforms for LightGBM with 1600 trees {on Fraud} (Unit: seconds).}
}
\end{figure}
\begin{figure}[h]
\centering
\vspace{-10pt}
\includegraphics[width=0.45\textwidth]{figures/fraud-batching-gpu.pdf}
\caption{\label{fig:fraud-batching-gpu} \small
{\color{black}Inference time vs. batch size for GPU platforms for LightGBM with 1600 trees {on Fraud} (Unit: seconds).}
}
\end{figure}
\begin{figure}[h]
\centering
\vspace{-10pt}
\includegraphics[width=0.45\textwidth]{figures/year-batching-cpu.pdf}
\caption{\label{fig:year-batching-cpu} \small
{\color{black}Inference time vs. batch size for CPU platforms for LightGBM with 1600 trees {on Year} (Unit: seconds).}
}
\end{figure}
\begin{figure}[h]
\centering
\vspace{-10pt}
\includegraphics[width=0.45\textwidth]{figures/year-batching-gpu.pdf}
\caption{\label{fig:year-batching-gpu} \small
{\color{black}Inference time vs. batch size for GPU platforms for LightGBM with 1600 trees {on Year} (Unit: seconds).}
}
\end{figure}
}
\noindent
\textbf{Vectorization} In netsDB-UDF and netsDB-Rel, we tuned vectorization granularity, which is the number of sample blocks that can be processed by each operator and the number of samples in each block. The results showed that the number of samples in a block will more significantly impact the performance than the number of sample blocks. It showed that in addition to vectorizing the relational processing operators (i.e., atomic operators), vectorizing underlying UDFs is even more important
\section{Introduction}
\label{sec:intro}
Decision forest models, such as RandomForest~\cite{breiman2001random}, XGBoost~\cite{chen2016xgboost}, and LightGBM~\cite{ke2017lightgbm} are widely used machine learning algorithms for classification and regression tasks in production scenarios, such as search ranking in Microsoft Bing~\cite{ling2017model, zhu2017deep}, Alta Vista, Yahoo!~\cite{yin2016ranking}, and Yandex~\cite{styskin2011recency,lefortier2014online}, advertising in Facebook~\cite{he2014practical}, credit-card fraud prediction, healthcare, business intelligence. Compared to deep neural network models that are considered opaque, decision forest models are easier to identify and explain the significant variables in the data~\cite{arik2021tabnet}, which is important when applied to business decision processes that have compliance and audit requirements. They are popular for their robustness, scalability, and their abilities to handle a large number of features, handle missing data, and work well with both linear and non-linear relationships~\cite{kaggle-trend, dong2016characterizing, johnson2013learning, chapelle2011yahoo, qin2021neural}.
Given the importance of decision forest models, there are many systems engineered recently to support and optimize the inference process of such models. Several highly cited examples of open-source systems include Scikit-Learn~\cite{pedregosa2011scikit}, ONNX~\cite{bai2019onnx}, TensorFlow Decision Forest (TFDF)~\cite{guillame2022yggdrasil}, TreeLite~\cite{cho2018treelite}, HummingBird~\cite{nakandala2020tensor}, lleaves~\cite{lleaves}, and Nvidia FIL~\cite{nvidia-fil, nvidia-fil-github}.
However, we observed two significant gaps in these systems and related performance studies:
\noindent
\textbf{The data management gap.} All of these systems decouple the inference computation and data management and thus introduce additional latency for loading data from/to external data stores.
Existing databases, such as IBM Infosphere Data Warehouse, ATLAS~\cite{wang2003atlas}, Oracle Data Mining, GLADE~\cite{Cheng2012GLADEBD}, MauveDB~\cite{mauvedb}, have support for “traditional ML” workloads based on Predictive Model Markup Language (PMML), stored procedures, user-defined functions (UDFs) and user-defined aggregates (UDAs), and views. However, there is little documentation discussing how these systems implement and optimize for decision forest workloads. \textit{It is unclear whether in-database inference will achieve lower end-to-end latency than the standalone inference platforms.}
\vspace{6pt}
\noindent
\textbf{The performance understanding gap.} We identified key performance factors that cover the main architectural differences among the aforementioned decision forest inference frameworks. \textit{It is unclear how these design decisions will affect the end-to-end performance and how to make such design decisions for an in-database inference framework.} These key performance factors include:
\vspace{3pt}
\noindent
\textbf{F1. Algorithm.} There exist multiple algorithms for serving decision forest models, including: (1) \textbf{Naive tree traversal}, which traverses each decision tree from the root to the leaf, as illustrated in Fig.~\ref{fig:naive-tree-traversal} and Fig.~\ref{fig:naive-impl}. (2) \textbf{Compiled tree traveral}, which unrolls the naive tree traversal process into nested \texttt{if-else} blocks, as illustrated in Fig.~\ref{fig:compiled-impl}, to generate code that has conditional branches optimized~\cite{prasad2022treebeard, cho2018treelite, lleaves}. (3) \textbf{Predicated tree traveral}~\cite{asadi2013runtime}, which replaces conditional branches by predicates to avoid branch mis-predictions, as illustrated in Fig.~\ref{fig:predicated-impl}.
(4) \textbf{Hummingbird}~\cite{nakandala2020tensor}, which converts the decision tree inference into matrix computations, as illustrated in Fig.~\ref{fig:hummingbird} to leverage tensor computing libraries such as TVM~\cite{chen2018tvm}, TorchScript~\cite{Paszke_PyTorch_An_Imperative_2019}, and PyTorch~\cite{Paszke_PyTorch_An_Imperative_2019}. (5) \textbf{QuickScorer}~\cite{lucchese2017quickscorer, lucchese2015quickscorer}, which encodes each tree node into a bit vector and converts tree traversal into bit-wise AND operations of the bit vectors of all FALSE nodes (i.e., tree nodes that are evaluated as False for the current testing sample), as illustrated in Fig.~\ref{fig:quickscorer}.
\vspace{3pt}
\noindent
\textbf{F2. Parallelism.} If using \textbf{data parallelism}, each thread runs the entire decision forest inference computation on a different data partition. When using \textbf{model parallelism}, each thread is responsible for running the inference of a partition of trees over the input data. Then the partial prediction results from all threads need to be aggregated to generate the final prediction.
\vspace{3pt}
\noindent
\textbf{F3. Batching.} Batching of testing samples for inferences is critical in balancing resource utilization and the overall latency. Different platforms and workloads desire different batch sizes to fully utilize the system resources.
\vspace{3pt}
\noindent
\textbf{F4. Vectorization.} Platforms such as lleaves, netsDB, Scikit-learn (only the RandomForest and XGBoost), and TFDF, applied vectorization, as illustrated in Fig.~\ref{fig:vectorized-impl}, to their inference functions, so that
SIMD instructions can be leveraged to accelerate the inference.
\begin{figure*}[]
\centering
\hspace{-10pt}
\subfigure[Naive Tree Traversal]{
\label{fig:naive-tree-traversal}
\includegraphics[width=0.33\textwidth]{figures/naive-tree-traversal.pdf}}
\subfigure[HummingBird]{
\label{fig:hummingbird}
\includegraphics[width=0.33\textwidth]{figures/hummingbird.pdf}}
\subfigure[QuickScorer]{
\label{fig:quickscorer}
\includegraphics[width=0.33\textwidth]{figures/quick_scorer.pdf}}
\caption{\label{fig:algorithms} \small
{Illustration of Decision Forest Algorithms.}
}
\end{figure*}
\begin{figure}[]
\centering
\hspace{-10pt}
\subfigure[Naive Prediction]{
\label{fig:naive-impl}
\includegraphics[width=0.26\textwidth]{figures/naive-impl.pdf}}
\subfigure[Compiled Prediction]{
\label{fig:compiled-impl}
\includegraphics[width=0.19\textwidth]{figures/compiled-impl.pdf}}
\subfigure[Predicated Prediction]{
\label{fig:predicated-impl}
\includegraphics[width=0.22\textwidth]{figures/predicated-impl.pdf}}
\subfigure[Vectorized Prediction]{
\label{fig:vectorized-impl}
\includegraphics[width=0.23\textwidth]{figures/vectorized-impl.pdf}}
\caption{\label{fig:traversal-impl} \small
{Illustration of Different Tree-Traversal Implementations.}
}
\end{figure}
\eat{
}
\subsection{Our Contributions}
\noindent
\textbf{1. An in-database decision forest inference framework.}
To address the data management gap, we implemented a prototype of in-database decision forest inference in netsDB\footnote{https://github.com/asu-cactus/netsdb}, which is an object-oriented relational database management system (RDBMS) based on the PlinyCompute object model and query compilation framework implemented in C/C++ ~\cite{zou2018plinycompute, zou2019pangea, zou2020watson, zou2020architecture, DBLP:journals/pvldb/ZouDBIYJJ21, DBLP:journals/pvldb/ZhouCDMYZZ22, yuan2020tensor, jankov12declarative, shi2014mrtuner, jankov2020declarative}.
We explored different representations of the decision forest inference in RDBMS. The \textbf{UDF-centric} representation encapsulates the entire inference computation into a single UDF. We found that when the size of the model
increases, the cache locality worsens quickly using this approach. The \textbf{relation-centric} representation breaks down the inference computation into a flow of relational operators, including a \texttt{cross-product} operator that pairs up each decision tree and a block of testing samples. Then, for each pair, the prediction function from the decision tree is invoked to predict for each sample in the block. This operator is followed by an \texttt{aggregate} operator that aggregates all partial prediction results.
Both representations support batching and vectorization. In addition, the UDF-centric representation adopts data parallelism so that each thread invokes the UDF on a data partition. The relation-centric representation adopts model parallelism, e.g., the cross-product operator is launched in multiple threads, with each thread responsible for a model partition (i.e., a subset of decision trees).
The \textbf{relation-centric} representation requires a model partitioning job stage.
Once this job stage gets executed, its output can be reused for inferring different datasets. We thus proposed the model-reuse technique so that this job stage's output is materialized to accelerate executing different inference queries.
\vspace{6pt}
\noindent
\textbf{2. A comprehensive performance comparison.}
To address the performance understanding gap, we compared the dedicated decision forest inference frameworks and our proposed in-database inference framework on a broad class of workloads at all scales using RandomForest, XGBoost, and LightGBM. The types of datasets range from sparse to dense and narrow to wide. We compared the end-to-end latency of the decision forest inference process, including data loading, inference, and result writing.
The benchmarking framework is fully automated and open-sourced\footnote{https://github.com/asu-cactus/DFInferBench}.
\vspace{5pt}
\noindent
\textbf{3. A series of interesting observations that may benefit future database and AI/ML systems design}, such as:
\noindent
$\bullet$ Data loading is a major performance bottleneck, particularly for (1) Workloads that infer large-scale datasets using small to medium forest models that have tens to hundreds of trees; and (2) Workloads that infer small-scale or wide-and-short datasets using all-scale models. For these workloads, our in-database inference framework achieved up to hundreds of times speedup.
\eat{
\noindent
$\bullet$ For the two types of workloads mentioned above, CPU platforms usually achieved lower costs than GPU platforms.
GPU platforms achieved significantly lower costs than CPU platforms when using large-scale forest models and large batches of data where inference rather than data loading becomes the major bottleneck.}
\noindent
$\bullet$ Cache locality is crucial to the performance of large-scale forest models. Therefore, model parallelism, which reduces the memory footprint of each thread/partition, outperformed data parallelism, where each thread needs to access the whole model in memory.
\noindent
$\bullet$ The relation-centric representation significantly improved netsDB's performance in handling large-scale models, while the UDF-centric representation achieved the best performance for small-scale models. In addition, the model reuse optimization significantly improved the performance of the relation-centric representation for handling small-scale datasets.
\noindent
$\bullet$ GPU platforms achieved lower costs than CPU platforms for medium and large-scale forest models and large batches of data. But CPU platforms outperformed GPU platforms in other cases where data loading becomes the performance bottleneck.
\noindent
$\bullet$ If only inference computation time is considered, the QuickScorer algorithm achieved the best single-thread latency. The compilation-based approach combined with other optimizations, as implemented in lleaves, achieved the best inference latency among CPU platforms for large-scale (LightGBM) models. Nevertheless, such an approach required tremendous compilation latency, as detailed in Sec.~\ref{sec:model-conversion}.
\section{Conclusion}
Decision forest, including RandomForest and boosting-based algorithms (e.g., XGBoost and LightGBM), is widely used in a variety of applications such as finance, healthcare, marketing, and search ranking, because of its robustness, scalability to large-scale datasets, model interpretability, etc. However, most existing benchmarks and evaluations did not consider the management of the inference data and the data transfer to/from external data stores, which significantly impacts the overall performance, as shown in this study.
In this work, we have conducted a comprehensive comparison study for the end-to-end inference performance of decision forest models at different scales on eight platforms ($15$ platforms if consider variance in hardware, backends, etc.). We implemented our own in-database decision forest inference solution on netsDB, using two representations: UDF-Centric and Relation-Centric.
Our study showed that in-database inferences will save significant data loading/conversion time for runtime inferences. This is particularly important for two broad classes of workloads, where data transfer becomes a significant bottleneck. The first type of workloads serves large-scale datasets using small to medium-scale forest models with tens to hundreds of trees. The second type of workloads infers small-scale or wide-and-short datasets using all-scale models. These workloads argue for an in-database inference solution such as netsDB.
However, for workloads that exploit large-scale models, where inference rather than data transfer becomes the major performance bottleneck, in-database inference may not be an ideal solution due to its sub-optimal inference performance. Therefore, improving in-database inference performance for large-scale models by integrating with high-performance libraries and hardware acceleration could be a helpful direction.
We believe these observations shed some light on the integration of database and AI/ML and may benefit the design of future systems.
\begin{acks}
ASU students Jiaqing Chen and Yuze Liao have contributed to the work at the early stages of the benchmark development.
\end{acks}
\bibliographystyle{ACM-Reference-Format}
\section{Optimization of Decision Tree in RDBMS}
\section{Survey of Existing Platforms}
\noindent
\textbf{A brief introduction about decision forest.}
RandomForest~\cite{breiman2001random}, XGBoost~\cite{chen2016xgboost}, and LightGBM~\cite{ke2017lightgbm} are three different decision forest training algorithms. Even training on the same dataset, with the same number of trees and the same maximum depth of each tree, the trained models could have different shapes using these training algorithm
~\cite{nakandala2020tensor}.
The inference processes of the three decision forest models share the same first phase, which is to obtain the exit leaf for each tree in the forest. The second phase is slightly different. Taking Scikit-learn implementations of binary classification as an example, in the second phase, the RandomForest algorithm averages all trees' exit labels and then applies a sigmoid function to convert the averaged value to a probability score. For XGBoost and LightGBM, the second phase sums up the weights of all exit labels and then obtains the final prediction using a sigmoid function.
\vspace{6pt}
\noindent
\textbf{Platforms.} Due to the popularity and importance of the decision forest inference workloads, a number of platforms have been developed and dedicated for decision forest inferences. Next, we provide a survey about the most popular platforms:
\noindent
\textbf{Scikit-learn~\cite{pedregosa2011scikit}} It implements its own RandomForest algorithm but invokes the XGBoost~\cite{chen2016xgboost} and LightGBM~\cite{ke2017lightgbm} libraries to train and make inferences using XGBoost and LightGBM models. They all implement the naive tree traversal algorithm for inference, as illustrated in Fig.~\ref{fig:naive-tree-traversal}.
Scikit-learn used model parallelism for random forest prediction, each thread runs the inferences of a partition of trees over the input data, and the results will be used to update a shared result vector protected by a lock. The predict function is vectorized by taking a batch of samples as input.
Both XGBoost and LightGBM libraries adopt data parallelism. The XGBoost library also uses vectorization, while the LightGBM does not.
\vspace{3pt}
\noindent
\textbf{ONNX~\cite{bai2019onnx} } It also uses the naive tree traversal algorithm. It chooses data parallelism or model parallelism based on the number of input samples and the number of trees in the forest.
It does not exploit vectorization, and the underlying tree traversal function takes a single sample as input at a time.
\vspace{3pt}
\noindent
\textbf{HummingBird~\cite{nakandala2020tensor}} It transforms the tree traversal process into tensor computations, as illustrated in Fig.~\ref{fig:hummingbird}. It first converts the decision tree structure to two main tensors: (1) A tensor \texttt{A} that represents the relationships between each internal node and each feature; (2) A tensor \texttt{C} that captures the parent-child relationships among each pair of internal nodes. Then, the tensor of input samples is multiplied with tensor \texttt{A} to obtain the input path tensor. After that, the input path tensor is multiplied with tensor \texttt{C} to obtain the output path tensor. This way, existing tensor libraries on the CPU and GPU can be leveraged to accelerate the prediction process.
\vspace{3pt}
\noindent
\textbf{TensorFlow Decision Forest (TFDF)~\cite{tf-df}} It wraps a C++-based Yggdrasil library~\cite{guillame2022yggdrasil}, which implements the QuickScorer algorithm~\cite{lucchese2017quickscorer, lucchese2015quickscorer, ye2018rapidscorer} as well as the naive tree traversal algorithm. It will benchmark and select the best algorithm at the model compilation stage. The QuickScorer algorithm is illustrated in Fig.~\ref{fig:quickscorer}. It first encodes every tree node into a bit vector, with each bit corresponding to a leaf node. If the bit is set to 0, it means the leaf node is impossible to be the exit leaf if the current node is a FALSE node (i.e., evaluated to False). For a given input sample, the prediction of one decision tree can be obtained by applying the bit-wise AND operation to the bit vectors of all FALSE nodes. To identify FALSE nodes, the algorithm first groups the nodes from all trees in the model by features so that nodes regarding the same feature from different trees are stored together and sorted by their predicate thresholds. Given an input sample, it quickly determines all FALSE nodes using binary searches.
\vspace{3pt}
\noindent
\textbf{TreeLite~\cite{cho2018treelite}} It imports external models and partitions the trees into several compilation units. These compilation units will be transformed to C source functions in parallel. Each C source function corresponds to a compilation unit. As illustrated in Fig.~\ref{fig:compiled-impl}, it takes a single sample as input, runs a series of nested \texttt{if-else} blocks, and outputs the final predictions for trees belonging to the compilation unit. Then, these C source code functions will be further compiled into a shared library (i.e., a .so file
. At prediction time, the shared library will be loaded to perform the prediction.
\vspace{3pt}
\noindent
\textbf{Nvidia FIL~\cite{nvidia-fil, nvidia-fil-github}} FIL implements a GPU version of the predicated tree traversal algorithm. Each GPU thread is responsible for inferring a batch of samples on one tree. To optimize the GPU cache locality, it exploits a reorganized dense tree representation in GPU memory, where the nodes at the same level but from different trees will be stored together to improve the cache locality. It also implements a sparse tree storage format, where the nodes from all trees are stored in one flat array. While nodes from one tree are stored together, sibling nodes that share the same parent node are always stored adjacently.
For both cases, because the left child and right child are stored adjacently, it can use a predicate to replace the conditional branch. As illustrated in Fig.~\ref{fig:predicated-impl}, the conditional branch: \texttt{\textbf{if} (cond) \textbf{return}left(node\_idx) \textbf{else} \textbf{return} right(node\_idx)}, is replaced by \texttt{\textbf{return} left(node\_idx) + cond}, which avoided branches in GPU computation.
\vspace{3pt}
\noindent
\textbf{lleaves~\cite{lleaves}} It also compiles trees to nested \texttt{if-else} blocks. However, instead of translating the model into C source codes for compilation, lleaves designs an intermediate representation to describe the models and leverages the LLVM framework for code generation. Notably, lleaves is more optimized than TreeLite. For example, the functions generated by lleaves support vectorization. Lleaves currently only supports the LightGBM model on CPU.
\section{Our In-Database Inference Design}
\label{sec:netsdb}
\begin{figure}[]
\centering
\hspace{-10pt}
\subfigure[UDF-Centric]{
\label{fig:udf-centric}
\includegraphics[width=0.09\textwidth]{figures/udf-based.pdf}}
\subfigure[Relation-Centric]{
\label{fig:rel-centric}
\includegraphics[width=0.18\textwidth]{figures/rel-based.pdf}}
\subfigure[Model Reuse]{
\label{fig:model-reuse}
\includegraphics[width=0.18\textwidth]{figures/reuse.pdf}}
\caption{\label{fig:database-representations} \small
{Computation graph for various database representations.}
}
\end{figure}
\subsection{Key Design Decisions}
\label{sec:db-decisions}
\noindent
\textbf{Algorithm.} We found that the naive tree traversal algorithm and the predicated tree traversal algorithm are best suited for RDBMS. The compiled tree traversal algorithm requires code generation for UDFs such as the predict function, which is not supported in many RDBMS. The HummingBird algorithm relies on optimization for expensive matrix computations, and it is not suitable for most RDBMS designed for CPU platforms. The QuickScorer algorithm is hard to be represented in a relation-centric style. One reason is that the QuickScorer model groups all nodes by features; thus, the model is essentially a collection of feature groups. Because the sizes of feature groups are not well-balanced, it is challenging to partition the model evenly. In addition, C++ lacks a good library for large bit vectors that have more than $64$ bits, which limits the number of leaf nodes to $64$ in a decision tree. For example, the TFDF's implementation of QuickScorer is single-threaded and only supports a maximum tree depth of $6$ (i.e., $log_2^{64}$).
We thus implemented both naive tree traversal and predicated tree traversal algorithms in netsDB, but we did not observe any significant difference in the inference time for most of the workloads.
\vspace{3pt}
\noindent
\textbf{Storage of Input Samples.} Physically, the input samples are stored as a collection of tensor blocks, called sample blocks. Each block is a 2D tensor that represents a vector of feature vectors.
\vspace{3pt}
\noindent
\textbf{Batching.} The application can specify a batch size to control the number of sample blocks in one batch. Then, the application can iteratively issue an inference query to process one batch until all batches are processed.
\vspace{3pt}
\noindent
\textbf{Scheduling and Parallelism.} In netsDB, similar to other dataflow frameworks such as Apache Spark~\cite{zaharia2010spark, armbrust2015spark}, the users develop their applications as dataflow graphs, where every node represents a relational operator (which should be customized using UDFs) and every edge represents a dataset. At runtime, a dataflow graph is split into multiple pipeline (job) stages. A pipeline stage is a series of atomic operators (e.g., \texttt{scan}, \texttt{transform}, \texttt{hash}, \texttt{partition}, \texttt{probe}, \texttt{join}, \texttt{cross-product}, \texttt{aggregate}, \texttt{write}) with the last operator being a pipeline breaker that materializes the output data (e.g., \texttt{hash}, \texttt{partition}, \texttt{aggregate}, \texttt{write}). For example, a \texttt{cross-product} relational operator will be split into multiple atomic operators belonging to different pipeline stages as described in Sec.~\ref{sec:rel-centric}. Each pipeline stage is executed with multiple threads. These threads run the same logic but with different input data. Usually, we configure the number of threads for each pipeline stage to be the number of CPU cores. As we will detail in Sec.~\ref{sec:udf-centric} and Sec.~\ref{sec:rel-centric}, the UDF-centric representation of decision forest inference implements data parallelism, and the relation-centric representation implements model-parallel inferences.
\vspace{3pt}
\noindent
\textbf{Vectorization.} When executing a pipeline stage, each thread iteratively fetches a vector of sample blocks and runs a series of atomic operators to process the vector. Each atomic operator in the pipeline stage is vectorized. It takes in a vector of sample blocks and outputs a vector of result blocks to the next atomic operator.
\subsection{The UDF-Centric Representation}
\label{sec:udf-centric}
With the UDF-centric representation, the decision forest inference logic is encapsulated in a single UDF that customizes a \texttt{transform} operator (i.e., like a \texttt{map} function). The UDF contains a forest object, which is a vector of trees, and each tree is stored as a vector of tree nodes. The UDF has a prediction function that takes a sample block as input and outputs a block of predictions. The prediction function iteratively processes each sample in the block by traversing each tree and aggregating the prediction of all trees.
As illustrated in Fig.~\ref{fig:udf-centric}, the corresponding dataflow graph for a simple example of UDF-centric inference consists of a \texttt{transform} operator that is customized by a UDF, which takes a sample block as input and outputs a result block. After compilation, the dataflow graph is scheduled as one pipeline stage. Each thread iteratively fetches a vector of sample blocks, runs the prediction UDF over it, and writes the final predictions to an output dataset. The UDF is initialized by parsing a pre-trained scikit-learn model.
The benefit of this approach is in its simplicity, e.g., the inference process is compiled to a single pipeline stage. The encapsulation also facilitates extending the UDF to invoke functions from popular libraries, including GPU libraries.
The shortcoming is that each CPU core needs to access the whole forest model, which leads to significant cache misses for large-scale models.
\subsection{The Relation-Centric Representation}
\label{sec:rel-centric}
To reduce the cache misses for inferences with large-scale models, we propose a relation-centric representation that facilitates model parallelism.
As illustrated in Fig.~\ref{fig:rel-centric}, we represent the decision forest inference process as a dataflow graph that uses two key operators:
(1) A \texttt{cross-product} operator, which performs a Cartesian product between the collection of trees and the collection of input sample blocks, and enumerates all possible pairs of tree and sample block.
Each pair is further converted into a block of prediction results (e.g., the return class or weight associated with the exit leaf) using a \texttt{transform} UDF that performs tree traversal over each sample in the block iteratively.
(2) An \texttt{aggregate} operator is used to aggregate all prediction results for the same sample using different aggregation logic for different types of models.
\noindent
To reduce the cache misses, we implement the \texttt{cross-product} operator in a model-parallel fashion. It partitions the model into many subsets of decision trees and allocates each partition to a thread. Then, a pointer to each page from the inference dataset is sent to all threads for generating the cross-product and partial prediction results. Using this approach, each thread only needs to access a partition of trees. It significantly reduces the cache misses and shortens the inference latency for large-scale models, as observed in our experiments.
\noindent
\textbf{Model Reuse.} While the relation-centric representation works well for inferring large datasets, it brings significant overheads for processing small datasets. That is because compared to the UDF-centric representation that only requires one pipeline stage, the relation-centric representation is compiled to multiple pipeline stages because there exist multiple pipeline breakers in the dataflow graph. For example, one stage partitions the model, one stage runs the \texttt{cross-product} and groups partial prediction results by tree IDs, one stage aggregates the prediction results from all trees, and one stage post-processes the aggregated result (e.g., applying the sigmoid function) and writes the final output to a dataset. To reduce the overheads, we identified that the model-partitioning stage can be reused by different inference applications as long as they use the same model. Therefore, we can materialize the results of this pipeline stage and directly reuse the materialized results to simplify the dataflow graph, as illustrated in Fig.~\ref{fig:model-reuse}.
\section{Introduction}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse a arcu quis arcu malesuada ultricies vitae in felis. Curabitur porta lacus at felis viverra hendrerit in non eros. Nam tempus tincidunt metus vitae fermentum. Donec sed risus felis. Cras luctus massa elementum, semper urna vel, efficitur ipsum. Morbi at tellus libero.
Praesent imperdiet, lacus nec varius placerat, est ex eleifend justo, a vulputate leo massa consectetur nunc. Donec posuere in mi ut tempus. Pellentesque sem odio, faucibus non mi in, laoreet maximus arcu. In hac habitasse platea dictumst. Nunc euismod neque eu urna accumsan, vitae vehicula metus tincidunt. Maecenas congue tortor nec varius pellentesque. Pellentesque bibendum libero ac dignissim euismod. Aliquam justo ante, pretium vel mollis sed, consectetur accumsan nibh. Nulla sit amet sollicitudin est.
\section{Core Structural Elements}
Nulla placerat feugiat augue, id blandit urna pretium nec. Nulla velit sem, tempor vel mauris ut, porta commodo quam. Donec lectus erat, sodales eu mauris eu, fringilla vestibulum nisl. Morbi viverra tellus id lorem faucibus cursus. Quisque et orci in est faucibus semper vel a turpis. Vivamus posuere sed ligula et.
\subsection{Figures}
Aliquam justo ante, pretium vel mollis sed, consectetur accumsan nibh. Nulla sit amet sollicitudin est. Etiam ullamcorper diam a sapien lacinia faucibus. Duis vulputate, nisl nec tincidunt volutpat, erat orci eleifend diam, eget semper risus est eget nisl. Donec non odio id neque pharetra ultrices sit amet id purus. Nulla non dictum tellus, id ullamcorper libero. Curabitur vitae nulla dapibus, ornare dolor in, efficitur enim. Cras fermentum facilisis elit vitae egestas. Nam vulputate est non tellus efficitur pharetra. Vestibulum ligula est, varius in suscipit vel, porttitor id massa. Nulla placerat feugiat augue, id blandit urna pretium nec. Nulla velit sem, tempor vel mauris ut, porta commodo quam \autoref{fig:duck}.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{figures/duck}
\caption{An illustration of a Mallard Duck. Picture from Mabel Osgood Wright, \textit{Birdcraft}, published 1897.}
\label{fig:duck}
\end{figure}
\begin{table*}[t]
\caption{A double column table.}
\label{tab:commands}
\begin{tabular}{ccl}
\toprule
A Wide Command Column & A Random Number & Comments\\
\midrule
\verb|\tabular| & 100& The content of a table \\
\verb|\table| & 300 & For floating tables within a single column\\
\verb|\table*| & 400 & For wider floating tables that span two columns\\
\bottomrule
\end{tabular}
\end{table*}
\subsection{Tables}
Curabitur vitae nulla dapibus, ornare dolor in, efficitur enim. Cras fermentum facilisis elit vitae egestas. Mauris porta, neque non rutrum efficitur, odio odio faucibus tortor, vitae imperdiet metus quam vitae eros. Proin porta dictum accumsan \autoref{tab:commands}.
Duis cursus maximus facilisis. Integer euismod, purus et condimentum suscipit, augue turpis euismod libero, ac porttitor tellus neque eu enim. Nam vulputate est non tellus efficitur pharetra. Aenean molestie tristique venenatis. Nam congue pulvinar vehicula. Duis lacinia mollis purus, ac aliquet arcu dignissim ac \autoref{tab:freq}.
\begin{table}[hb
\caption{Frequency of Special Characters}
\label{tab:freq}
\begin{tabular}{ccl}
\toprule
Non-English or Math & Frequency & Comments\\
\midrule
\O & 1 in 1000& For Swedish names\\
$\pi$ & 1 in 5 & Common in math\\
\$ & 4 in 5 & Used in business\\
$\Psi^2_1$ & 1 in 40\,000 & Unexplained usage\\
\bottomrule
\end{tabular}
\end{table}
Nulla sit amet enim tortor. Ut non felis lectus. Aenean quis felis faucibus, efficitur magna vitae. Curabitur ut mauris vel augue tempor suscipit eget eget lacus. Sed pulvinar lobortis dictum. Aliquam dapibus a velit.
\subsection{Listings and Styles}
Aenean malesuada fringilla felis, vel hendrerit enim feugiat et. Proin dictum ante nec tortor bibendum viverra. Curabitur non nibh ut mauris egestas ultrices consequat non odio.
\begin{itemize}
\item Duis lacinia mollis purus, ac aliquet arcu dignissim ac. Vivamus accumsan sollicitudin dui, sed porta sem consequat.
\item Curabitur ut mauris vel augue tempor suscipit eget eget lacus. Sed pulvinar lobortis dictum. Aliquam dapibus a velit.
\item Curabitur vitae nulla dapibus, ornare dolor in, efficitur enim.
\end{itemize}
Ut sagittis, massa nec rhoncus dignissim, urna ipsum vestibulum odio, ac dapibus massa lorem a dui. Nulla sit amet enim tortor. Ut non felis lectus. Aenean quis felis faucibus, efficitur magna vitae.
\begin{enumerate}
\item Duis lacinia mollis purus, ac aliquet arcu dignissim ac. Vivamus accumsan sollicitudin dui, sed porta sem consequat.
\item Curabitur ut mauris vel augue tempor suscipit eget eget lacus. Sed pulvinar lobortis dictum. Aliquam dapibus a velit.
\item Curabitur vitae nulla dapibus, ornare dolor in, efficitur enim.
\end{enumerate}
Cras fermentum facilisis elit vitae egestas. Mauris porta, neque non rutrum efficitur, odio odio faucibus tortor, vitae imperdiet metus quam vitae eros. Proin porta dictum accumsan. Aliquam dapibus a velit. Curabitur vitae nulla dapibus, ornare dolor in, efficitur enim. Ut maximus mi id arcu ultricies feugiat. Phasellus facilisis purus ac ipsum varius bibendum.
\subsection{Math and Equations}
Curabitur vitae nulla dapibus, ornare dolor in, efficitur enim. Cras fermentum facilisis elit vitae egestas. Nam vulputate est non tellus efficitur pharetra. Vestibulum ligula est, varius in suscipit vel, porttitor id massa. Cras facilisis suscipit orci, ac tincidunt erat.
\begin{equation}
\lim_{n\rightarrow \infty}x=0
\end{equation}
Sed pulvinar lobortis dictum. Aliquam dapibus a velit porttitor ultrices. Ut maximus mi id arcu ultricies feugiat. Phasellus facilisis purus ac ipsum varius bibendum. Aenean a quam at massa efficitur tincidunt facilisis sit amet felis.
\begin{displaymath}
\sum_{i=0}^{\infty} x + 1
\end{displaymath}
Suspendisse molestie ultricies tincidunt. Praesent metus ex, tempus quis gravida nec, consequat id arcu. Donec maximus fermentum nulla quis maximus.
\begin{equation}
\sum_{i=0}^{\infty}x_i=\int_{0}^{\pi+2} f
\end{equation}
Curabitur vitae nulla dapibus, ornare dolor in, efficitur enim. Cras fermentum facilisis elit vitae egestas. Nam vulputate est non tellus efficitur pharetra. Vestibulum ligula est, varius in suscipit vel, porttitor id massa. Cras facilisis suscipit orci, ac tincidunt erat.
\section{Citations}
Some examples of references. A paginated journal article~\cite{Abril07}, an enumerated journal article~\cite{Cohen07}, a reference to an entire issue~\cite{JCohen96}, a monograph (whole book) ~\cite{Kosiur01}, a monograph/whole book in a series (see 2a in spec. document)~\cite{Harel79}, a divisible-book such as an anthology or compilation~\cite{Editor00} followed by the same example, however we only output the series if the volume number is given~\cite{Editor00a} (so Editor00a's series should NOT be present since it has no vol. no.), a chapter in a divisible book~\cite{Spector90}, a chapter in a divisible book in a series~\cite{Douglass98}, a multi-volume work as book~\cite{Knuth97}, an article in a proceedings (of a conference, symposium, workshop for example) (paginated proceedings article)~\cite{Andler79}, a proceedings article with all possible elements~\cite{Smith10}, an example of an enumerated proceedings article~\cite{VanGundy07}, an informally published work~\cite{Harel78}, a doctoral dissertation~\cite{Clarkson85}, a master's thesis~\cite{anisi03}, an finally two online documents or world wide web resources~\cite{Thornburg01, Ablamowicz07}.
\begin{acks}
This work was supported by the [...] Research Fund of [...] (Number [...]). Additional funding was provided by [...] and [...]. We also thank [...] for contributing [...].
\end{acks}
\bibliographystyle{ACM-Reference-Format}
\section{Benchmark Workload Description}
We evaluated the performance of various decision forest models at all scales on well-known classification datasets, as shown in Tab.~\ref{tab:datasets}.
\begin{table}[h]
\centering
\scriptsize
\caption{\label{tab:datasets} {\small Statistics of the Datasets}}
\begin{tabular}{|l|r|r|l|r|} \hline
Dataset&NumRows&NumFeatures&Prediction Type&Testing Ratio\\\hline \hline
Epsilon&$100$K&$2000$&Classification&$20\%$\\ \hline
Fraud&$285$K &$28$&Classification&$20\%$\\ \hline
Year&$515$K&$90$&Regression&$20\%$ \\ \hline
Bosch&$1.184$M&968&Classification&$20\%$\\ \hline
Higgs&$11$M&$28$&Classification&$20\%$ \\ \hline
Criteo&51M&1M&Classification&$11\%$\\ \hline
Airline&$115$M&$13$&Classification/Regression&$20\%$\\ \hline
TPCx-AI (SF=30)&131M&7&Classification&$100\%$\\ \hline
\end{tabular}
\end{table}
Most of the platforms investigated in this work, such as ONNX, HummingBird, TreeLite, lleaves, and netsDB, can not directly train a model. Therefore, we use Scikit-learn to train models using RandomForest, XGBoost, and LightGBM algorithms on each evaluation dataset in Tab.~\ref{tab:datasets}. For each type of model, we used a different number of trees, ranging from $10$ to $1,600$, with each tree having a maximum depth of $8$. These are all widely used hyper-parameters~\cite{nakandala2020tensor}. We then convert these models to be loaded to each platform for inferences. The performance of the model conversion and loading process is discussed in Sec.~\ref{sec:model-conversion}.
For most datasets except TPCx-AI~\cite{tpcx-ai} and Criteo~\cite{criteo}, we used $80\%$ of samples to train models. Then we convert the trained model to run inferences against the $20\%$ remaining samples on each target platform. For TPCx-AI, we used the fraud detection scenario~\cite{tpcx-ai}. We trained the model on a smaller dataset with scale factor (SF) 1, then tested the model on the dataset with SF 30, which is described in Tab.~\ref{tab:datasets}. For Criteo, the training and testing data was pre-split by the data provider~\cite{libsvmdata,criteo}, as illustrated in Tab.~\ref{tab:datasets}.
\noindent
\textbf{Target Scenarios.} In this work, we focused on the end-to-end latency of inference pipelines that ran all types of models to make inferences for datasets that are managed by native or external data stores. In practice, features are extracted from databases in many industrial scenarios, such as fraud detection and recommendation based on transaction records~\cite{lam2021automated}.
Therefore, for netsDB, the testing datasets were stored natively. For other platforms, the testing datasets, except for Epsilon and Criteo, were stored in tabular format in a PostgreSQL database installed on the same machine, with the database connection accelerated using the state-of-art ConnectorX library~\cite{wang2022connectorx}. Besides, Epsilon has $2000$ features, and Criteo has $1$ million features, but PostgreSQL only supports up to $1600$ columns~\cite{postgresql-limits}. Therefore, for Epsilon, we stored each tuple in Array type in PostgreSQL, which turned out to be slower than the tabular format in data loading as detailed in Sec.~\ref{sec:epsilon}. For Criteo, we simply loaded it from a LIBSVM file in sparse storage format~\cite{CC01a}.
We measured data loading time, inferences time, and data writing time in an end-to-end inference process. We did not consider the model conversion and model loading time as part of the end-to-end latency because these times can be amortized to multiple inference queries. We will discuss such one-time costs in Sec.~\ref{sec:model-conversion}.
\eat{
}
\eat{
\vspace{5pt}
\noindent
\textbf{Model Conversion.} Target systems, such as ONNX, HummingBird, TreeLite, lleaves, and Nvidia FIL, all support importation from Sciki-learn models. TFDF only supports the conversion for RandomForest models. With the help of Google engineers, we developed our own XGBoost converter for TFDF.
}
| {'timestamp': '2023-02-10T02:06:07', 'yymm': '2302', 'arxiv_id': '2302.04430', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04430'} | arxiv |
\section{Introduction}
\label{intro-sec}
Open-domain spoken dialogue systems aim to carry out a natural conversation with a human user on any topic. While this remains an extremely challenging problem, a number of advances have been made in recent years, partly through competitions such as the Alexa Prize SocialBot Grand Challenge~\cite{khatri2018advancing,gabriel2020further}.
However, given the diversity of user interests and utterances in conversation, even the best of these systems can struggle to come up with good responses in many contexts \cite{pichl2020alquist,paranjape2020neural,chen2018gunrock,fang2017sounding,curry2018alana,bowden2019entertaining}. As a result, most such systems utilize
multiple response generators that contribute to a pool of potential responses in every dialogue context. Thus, the ability to rank several potential responses and then select the most appropriate one plays an important role in ensuring that a dialogue system remains coherent and engaging \cite{shalyminov2018neural,hedayatnia2022systematic,ghazarian2022wrong,kim2020speech,mehri2020unsupervised,ghazarian2020predictive}. The aim of this work is to develop improved response selection methods for open-domain spoken conversation.
The recent growth and popularity of open-domain systems has been accompanied by many new reference-free dialogue response ranking methods. Frameworks such as DialogRPT, DynaEval, USR, RUBER, and FED, {\it inter alia}, provide off-the-shelf tools for estimating the quality of a turn in an ongoing conversation
\cite{gao2020dialogue, zhang2021dynaeval, yeh2021comprehensive, mehri-USR20,tao2018ruber,mehri2020unsupervised}. We test several of these off-the-shelf rankers on the task of response ranking in Athena, a socialbot that competed in the Alexa Prize Socialbot Grand Challenge over the past few years \cite{harrison2020athena,patilathena2021}.
Athena's dialogue system architecture, shown in Figure~\ref{fig:athena-arch}, follows typical socialbot design principles, where the response sub-component consists of multiple response generators (RGs) for each topic. Unlike
open-domain chatbots based on LLMs such as GPT3 or DialoGPT \cite{zhang2019dialogpt,radford2019language}, Athena includes topic-specific response generators that use live content from WikiData and other databases, as well as topic-specific trivia.
For each system turn, a Dialogue Manager (DM) queries a subset of RGs for responses given the topic and the dialog context, resulting in a pool of candidate responses, from which a response is constructed and spoken to the user.
During the third Alexa Prize competition, we fielded Athena-Heuristic, a heuristic response ranker.
In this paper, we report experiments on training a new transformer-based response ranker we call \textit{Athena-RR}. We first
create a dataset of annotated (conversation-context, response-pool) examples, from live customer traffic, by logging all the responses that could be produced by the RGs at any point in an Athena dialogue.\footnote{We cannot release this dataset due to user privacy issues, however a checkpoint for the trained model is available at \url{github.com/Vrindiesel/athena-rr} .} We annotate the goodness of all the responses,
and then use the annotated corpus to train a new response ranker.
\begin{figure*}[htb]
\centering
\fbox{\includegraphics[width=0.95\textwidth]{athena-sys-architecture-updated.jpg}}
\caption{Athena's architecture showing Multiple Types of Response Generators}
\label{fig:athena-arch}
\end{figure*}
We compare the performance of the DynaEval, DialogRPT, and FED
off-the-shelf response-rankers, to Athena-Heuristic and Athena-RR on the
annotated test corpus. We also test Athena-Heuristic and Athena-RR
in the production Athena system in an A/B study where we can measure user ratings and conversation lengths.
We show that Athena-RR ranker achieves an Recall@1 of 70.79\% at selecting highly rated responses, and that deploying Athena-RR to live customer traffic resulted in an increase in mean conversation ratings from 3.64 to 3.77 and an increase in mean conversation length from 15.02 to 24.77 turns. The best off-the-shelf ranker is the DialogRPT Depth metric with a Recall@1 of 50.56\%. We find that the DynaEval metric does not perform as well on our data as on other corpora, with a Recall@1 of only 21.34. We also find that the 8 FED metrics are very highly correlated with one another, and that their Recall@1 values range between 28.09\% and 41.57\%.
\section{Related Work}
\label{sec:background}
There has recently been an upsurge of interest in response ranking for open-domain dialogues \cite{georgila2020predicting,deriu2021survey,yeh2021comprehensive}. In many cases, these are trained on an existing corpus, that doesn't have negative examples, so that that the ranker is trained to select the true response as opposed to a randomly selected one \cite{lowe2017training,liu2016not}. More recent work uses quality annotations on dialogues, either from crowd-sourced workers who created the dialogue turns, or from independent judges \cite{zhang2018personalizing,yeh2021comprehensive}, with the types of dialogues ranging
from short chit-chat conversations such as DailyDialogue \cite{li2017dailydialog}, to longer information dense conversations such as Topical Chat \cite{gopalakrishnan2019topical}.
Our experiments test the off-the-shelf rankers DialogRPT, DynaEval, and FED. DialogRPT is trained on Reddit threads, and uses up/down votes, number of direct responses, and length of response threads to produce different methods of ranking responses \cite{gao2020dialogue}. DynaEval has multiple versions trained on Empathetic Dialogues, ConvAI2 and Daily Dialogue. We use the Empathetic Dialogues variant that was used by the original authors for their out-of-domain evaluation on FED\cite{zhang2022fined}.
The FED ranker uses the pretrained transformer DialoGPT to score responses on various dimensions of conversational quality,
using the language model probabilities of the response eliciting a follow-on user reply such as ``That's interesting'' \cite{mehri2020unsupervised}.
There are also other response rankers specifically used in the context of the Alexa Prize. Kim et al. uses a large corpus labelled with the output of an acoustically-based user sentiment detector to train a model that predicts the users' sentiment towards a potential response \cite{kim2020speech}. Other work has used specific user responses such as ``Ask me if I care'' to label the previous turn as good or bad and then trained a ranker \cite{see2021understanding,shalyminov2018neural}. Another approach relied on conversational data annotated at the response level for its coherence and relevance in the context \cite{yi2019towards}.
In a similar approach to what we take here, Hedayatnia et al. trained a response ranker on an annotated set of Alexa Prize conversations with multiple responses generated by different neural response generation models (NRGs), and then compared its performance to off-the-shelf models, using different methods for negative and positive sampling \cite{hedayatnia2022systematic}. In this work, there were true negative responses,
as in the Athena annotated corpus described in Section~\ref{sec:corpus}. However, unlike Athena, Hedayatnia's system had only two topic-specific RGs, one for movies and another for music, and thus the response pools are quite different than Athena's. We make Athena-RR publicly available\footnote{github.com/Vrindiesel/athena-rr} in the hope that other Alexa Prize teams will test it on their systems.
\section{The Athena System}
\label{athena-sec}
Athena is an Alexa Prize socialbot that has competed in the Alexa Prize for the last two years \cite{harrison2020athena,walker2021athena}.
During the competition,
Athena carries out thousands of conversations a week with real users who access Alexa Prize systems by simply saying ``Let's Chat'' to an Alexa-enabled device.
At the end of each conversation, the user has the option to rate the conversation on a scale of 1 to 5, indicating their interest in speaking with Athena again in the future. We posited that an improved response ranker would increase Athena's average rating and lead to longer conversations.
Figure~\ref{fig:athena-arch} in Section~\ref{intro-sec} illustrates Athena's architecture. Response ranking in Athena is especially challenging due to the large pool of RGs that can be queried in any given turn. The types of response generators (RGs) are shown in Figure~\ref{fig:athena-arch}, but there are Flow-RGs, KG-RGs and Entity-based Indexing (trivia) RGs for each topic that Athena supports. The Dialogue Manager
tracks the discourse history and the context, as well as the topic under discussion, and uses this state information to
decide which RGs to run.
\begin{figure*}[htb]
\centering
\fbox{\includegraphics[width=0.95\textwidth]{RG-Distribution-Athena.png}}
\caption{Distribution of Utilization of Athena's Response Generators over a 6 month period}
\label{fig:rg-distribution}
\end{figure*}
Figure~\ref{fig:rg-distribution}
shows the utilization of Athena's RGs over a six month period. Note the large number of topics, including rare or niche topics
such as the Marvel Comic Universe (MCU), nutrition, astronomy, pirates and dinosaurs. Our response ranker needs to work well for all of these topics.
Figure~\ref{fig:rg-distribution} also shows how
topics, such as music and movies, have both a KG and a Flow-based RG that compete with one another
to take the next turn. For example, Music-KG, accesses knowledge triples about musicians and albums from the WikiData Knowledge Graph \cite{reed2022jurassic}, while the Music RG is a flow-based RG that structures the conversation by asking the user about their music preferences and opinions. The RG labelled as CENTER in Figure~\ref{fig:rg-distribution}
represents the Entity Indexing RGs that provide trivia,
with almost all topics having a corresponding trivia RG, which could also compete for the turn. The EVI QA engine was also called in every context to provide alternative possible responses. Neural Response Generators (NRGs) provided by Amazon were primarily run in the background in Athena due to latency issues and the difficulty with controlling their frequent topic changes \cite{rajasekaran2020,patilathena2021,chi2021neural,saha2021proto}.
While this multiple-RG setup allows for flexibility in handling unplanned user behavior and results in more engaging and diverse conversations, it makes response selection given the context of the conversation a very crucial task. Figure~\ref{fig:music-interleaving} illustrates how Athena-RR, discussed in more detail below, allows the Athena system to flexibly interleave responses from the three different response generators for Music.
\begin{figure*}[htb]
\centering
\fbox{\includegraphics[width=0.98\textwidth]{Music-RG-Interweaving}}
\caption{Dialogue illustrating the use of Multiple Response Generators for a single topic. The RG column indicates the type of RG, also indicated through different colors for each RG type. }
\label{fig:music-interleaving}
\end{figure*}
\section{Corpus Creation}
\label{sec:corpus}
\begin{table}[ht]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{l|p{3.0in}|c}
\toprule
{\cellcolor[gray]{0.9} \textbf{Speaker}} & {\cellcolor[gray]{0.9} \textbf{Dialogue Context}} & {\cellcolor[gray]{0.9} \bf Response Generator} \\ \toprule
ATHENA & Yeah. A lot of people have cool hobbies, but what about me? What kind of hobby do you think I would like? & Intro RG\\ \hline
USER & what's the name for music &\\ \hline
ATHENA & I love talking about music! Is there a musician or band that you like? & Music-KG\\ \hline
USER & no \\ \bottomrule
{ \cellcolor[gray]{0.9} \textbf{Rank}} & { \cellcolor[gray]{0.9} \textbf{Response Candidates}} & { \cellcolor[gray]{0.9} \textbf{Response Generator}}\\ \toprule
D & I recently read this fact about Britney Spears. Spears had gotten her start in fame through being on The Mickey Mouse Club with other artists like Christina Aguilera. & Center-Music \\ \hline
A & no problem! it can be hard to think of one. i like talking about the band Fleetwood Mac. Do you like Fleetwood Mac? & Music-KG \\ \hline
C & I recently read an interesting fact about the world's largest piano. The record for the largest piano ever made is held by Adrian Mann, a piano tuner from New Zealand. It took him four years to build the piano, and this grandiose instrument weighs 1.4 tonnes and is 5.7 meters long. & Center-Music \\ \hline
A & So tell me, why do you like music? & Music-Flow\\ \hline
C & I just read this fascinating fact about the history of Drums. Did you know that drums are one of the oldest musical instruments in the world? & Center-Music \\ \hline
C & Do you know the size of the world's smallest violin is? Well, I heard in Guangzhou, China, a 66-year-old senior violinist Chen Lianzhi made a 1-centimeter-long violin which sets the new world record for the world's smallest violin. & Center-Music \\ \hline
~ & None of the above. \\ \hline
\end{tabular}
}
\caption{Response pool annotation task example for Music. An ``A" indicates an excellent response, while an``B" indicates a response that could be used, and a ``C" indicates a response that might be okay in another context, while a ``D" indicates a bad response. }
\label{fig:rr-response-pool-music-anno-example}
\end{table}
We use Athena's live traffic with real human users to create our annotated corpus.
We take a random sample of 1,600 response pool instances with their associated conversation histories. The 1,600 instances are comprised of 100 random samples from each of 16 internal topics used by Athena, as illustrated in Figure~\ref{fig:rg-distribution}. The responses are selected such that we get 20 instances from conversations belonging to each 1-5 rating value, whenever possible.
\begin{table}[ht]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{l|p{3.0in}|c}
{\cellcolor[gray]{0.9} \textbf{Speaker}} & {\cellcolor[gray]{0.9} \textbf{Dialogue Context}} & {\cellcolor[gray]{0.9} \bf Response Generator} \\
ATHENA & Nice choice. And for me? It's hard for me to pick a specific scene, but I certainly liked Eli Wallach in this movie. What did you think of her portrayal of Tuco? & Movies-Flow \\ \hline
USER & i'm not familiar with that actress & \\ \hline
ATHENA & In order to capture legal conversations, the Director of Marriage story would meet with actual divorce attorneys. & Center-Movies\\ \hline
USER & i don't know anything about that & \\ \bottomrule
{\cellcolor[gray]{0.9} \textbf{Rank}} & {\cellcolor[gray]{0.9} \textbf{Response Candidate Text}} & {\cellcolor[gray]{0.9} \bf Response Generator} \\ \toprule
A & Seen any good movies recently? & Movies-KG \\ \hline
A & I was wondering what you think about this. Would you rather star in a commercial blockbuster or an independent film that wins prestigious awards? & Movies-Flow \\ \hline
C & Show business seems like it would be a really confusing business to navigate. Keanu Reeves was actually tricked into appearing in the film when a friend forged his signature on the contract.& Center-Movies \\ \hline
C & I already though Charlize Theron was really interesting, and then I heard this. When she was a baby, Charlize Theron had jaundice, and the doctors put her on antibiotics. Her baby teeth rotted because of the medicine, so she did not have a normal set of teeth until she was 11 years old and her adult teeth grew in.& Center-Movies \\ \hline
B & The director would explain the concept of the divorce at the center of the story then ask what kind of things these lawyers would target in the characters. & Center-Movies \\ \hline
A & Who is your favorite actor or actress? & Movies-KG \\ \hline
C & Is there a director that you like? Is there a movie that you want to talk about? & Movies-KG \\ \hline
C & I was a little disappointed that The Two Popes had some historical inaccuracies. One thing The Two Popes got right though is that Pope Benedict liked Orange Fanta, he drank at least 4 cans of the soda every day!& Center-Movies \\ \hline
& None of the above. & None-candidate \\ \hline
\end{tabular}
}
\caption{Response pool annotation task example for Movies. An ``A" indicates an excellent response, while an``B" indicates a response that could be used, and a ``C" indicates a response that might be okay in another context, while a ``D" indicates a bad response. }
\label{fig:rr-response-pool-movies-anno-example}
\end{table}
Athena particularly struggles with selecting good responses to questions, so we also bias the sampling to include 40/100 instances where the user's most recent utterance is a question. This is not always possible because question dialogue acts occur less frequently within some topics compared to others. So we collect an additional random sample of 494 instances of users asking questions, without regards to topic. This amounts to a total of 2,094 response pool instances. When collecting response pools, we limit the sampling to instances where the response pool contains more than one candidate response. An example response pool for a Music conversation is shown in Table~\ref{fig:rr-response-pool-music-anno-example} and one for Movies is shown in Table~\ref{fig:rr-response-pool-movies-anno-example}.
We collect annotations for the corpus via a response selection task where human judges rate response candidates. In each annotation instance, the judges are presented with 4 turns of conversation history ending with the user's most recent utterance, with a pool of response candidates listed below. The data is in spreadsheet format. Annotators are asked to select a response that they would say next by filling in the cell next to the selected response candidate. The annotations for the two response pool examples are shown in the LHS of Table~\ref{fig:rr-response-pool-music-anno-example} and of Table~\ref{fig:rr-response-pool-movies-anno-example}. Annotators are allowed to select multiple response candidates if multiple responses would be appropriate to say next. Notice that in both Table~\ref{fig:rr-response-pool-music-anno-example} and Table~\ref{fig:rr-response-pool-movies-anno-example} multiple responses are indicated with an ``A'' indicating they are equally good. Notice also that the response pools show how different RGs for the same topic compete with one another to take the turn. The Center RGs provide trivia, and they are part of the response pool in general to guarantee that Athena always has something to say, but even though they are ``on topic'' they are often not as good as responses produced by the KG response generators or the scripted Flow response generators.
Annotators are always given a "None of the above" option for situations where the response pool does not contain any good candidates. The annotations are performed by the authors and recruited lab-mates. Each response pool received one annotation therefore we did not measure annotator agreement.
\begin{table}[hbt]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{lr|lr|lr}
\toprule
\multicolumn{2}{c|}{\cellcolor[gray]{0.9} Corpus Descriptive Statistics}
& \multicolumn{2}{c}{\cellcolor[gray]{0.9} Un-normalized Corpus}
& \multicolumn{2}{c}{\cellcolor[gray]{0.9} Normalized Corpus}
\\
\toprule
\# topics & 16 & \# annotated responses & 7,915 & \# annotated responses & 6,113 \\
\# instances per topic & 100
& mean response pool size & 4.43
& mean response pool size & 3.42 \\
\# topical instances & 1,600
& median response pool size & 4.0 & median response pool size & 3.0
\\
\# extra question instances & 494 & & & &
\\
Total \# of instances & 2,094 & & & & \\
\bottomrule
\end{tabular}
}
\caption{Corpus statistics for annotated Athena response pool dataset.}
\label{table:rr-athena-corpus-stats}
\end{table}
Overall statistics on the annotated corpus of Athena response pools can be seen in Table~\ref{table:rr-athena-corpus-stats}
and Table~\ref{table:rr-athena-corpus-stats2}. Table~\ref{table:rr-athena-corpus-stats} summarizes how the response pool covers all of Athena's topics, as well as a general pool of questions. The mean and median response pool sizes are artificially reduced to make it easier for the annotators. In general, in any dialogue context, there are many more than 3 or 4 possible responses as illustrated by the response pool annotation examples in Figure~\ref{fig:rr-response-pool-music-anno-example} and Figure \ref{fig:rr-response-pool-movies-anno-example}. This is because there are many Center-RG potential responses as well as multiple responses from the knowledge graph RGs.
\begin{table}[t]
\centering
\begin{tabular}{l|r|r}
\toprule
{\cellcolor[gray]{0.9} Data} & {\cellcolor[gray]{0.9} Topical instances} & {\cellcolor[gray]{0.9} Question instances}\\ \hline
\# initial response pools & 1,600 (\%100.0) & \\
\# pools with only negative responses & 306 (\%19.1) & - \\
\# pools with positive responses & 1,294 (\%80.8) & 494 \\
\bottomrule
\# included in training set & 1,294 & 494 \\
\bottomrule
\end{tabular}
\caption{Response Pools positive and negative instances}
\label{table:rr-athena-corpus-stats2}
\end{table}
Table~\ref{table:rr-athena-corpus-stats2} breaks the corpus statistics down further, to show how many positive and negative examples there are in each category of topical instances and question instances. Despite the many different RGs, 19.1\% of the response pools are judged to have no good response, perhaps illustrating how it can be difficult to fully predict how users will behave. This observation is also supported by other work on Alexa Prize, where approximately 33\% of the response pools had no good responses \cite{hedayatnia2022systematic}.
\section{Ranking Responses: Experiment Overview}
\label{sec:ranking-models-intro}
Our primary goal is to evaluate how well different response ranking methods, when given the conversation context, are able to select the best response out of a pool of responses. We train our own Athena specific response ranker Athena-RR, and test three recently proposed models for
domain independent, reference free response ranking, namely DialogRPT, DynaEval and FED \cite{zhang2022fined,mehri2020unsupervised,gao2020dialogue}.
We compare these to Athena-Heuristic, a response ranker that was fielded in the third Alexa Prize competition. We evaluate response ranking methods in two ways: (1) accuracy against our test corpus; and (2) by deployment into the production Athena system as part of an A/B study on user ratings and conversation lengths.
\subsection{Response Ranking Models}
\label{response-models-sec}
\vspace{.1in}
\noindent{\bf Athena's Heuristic Response Ranker.}
Athena's heuristic response ranker is based on a topic-agnostic approach to dialogue management based on theories of discourse coherence~\cite{GroszCentering,prasad2010exploiting} to dynamically structure a dialogue.
The heuristic ranker applies rules on the current dialogue state to try to remain on topic until the user requests a topic change or the topic has been exhausted.
Topic-specific RGs can provide additional signals to the DM along with their response such as an indication that they \textit{must continue}, \textit{can continue}, or \textit{have ended} their conversation.
Preference is first given to the RG that had control on the last turn, in order to increase local coherence and promote conversation flow.
Then preference would be given to another RG on the same topic, for example when a FlowRG for music was exhausted, the KG-RG for music
and the Center RG for music would be equally preferred.
\vspace{.1in}
\noindent{\bf DialogRPT Response Ranker.}
\label{sec:dialogRPT-model}
DialogRPT\footnote{\url{https://github.com/golsun/DialogRPT}}\cite{gao2020dialogue}
is a transformer-based dialogue response ranking model trained by predicting human feedback (i.e., upvotes or replies) of responses on a large-scale social media platform. The model was trained on 100's of millions of Reddit
conversation threads. DialogRPT is trained with a contrastive ranking loss where the model learns to perform pairwise classification, maximizing the likelihood of the positive class instance over that of the negative class instance.
Multiple versions of DialogRPT were trained using different types of human feedback. We use three variants of DialogRPT whose checkpoints were made publicly available by the original authors. The DialogRPT-updown was trained using post upvote information, DialogRPT-width and DialogRPT-depth were trained using conversation thread width and depth information, respectively. We use the implementation and model available through Huggingface Tranformers.\footnote{\url{https://github.com/huggingface/transformers}}
\vspace{.1in}
\noindent{\bf DynaEval Ranker.}
DynaEval \cite{zhang2022fined} leverages a Graph Neural Network to model
the dialog-level interactions between a user and a
system. This allows it to distinguish well-formed dialogues from carefully constructed negative samples that allow it to better capture dialogue level coherence. Previous work that tested DynaEval on
DailyDialog, the USR subset of Topical Chat, ConvAI2 and Empathetic Dialogues showed
that it performs considerably better than other metrics across these different datasets \cite{yeh2021comprehensive}. We evaluate DynaEval for turn-level response ranking and selection by selecting the candidate response with the highest dialog-level coherence score.
\vspace{.1in}
\noindent{\bf The FED Ranker.}
\label{sec:fed-ranker}
FED is a method proposed to perform reference-free evaluation of 18 fine-grained dialogue qualities using a large pretrained model \cite{mehri2020unsupervised}. These dialogue qualities are further divided into 8 \textit{turn-level} and 10 \textit{conversation-level} qualities. The turn-level qualities measure whether a specific turn of a conversation was \textit{Interesting, Engaging, Specific, Relevant, Correct, Semantically Appropriate, Understandable,} and \textit{Fluent}. We select FED as one of our baselines for turn-level evaluation in Athena because the Meena and Mitsuku datasets that it showed good results for are similar to Athena conversations \cite{adiwardana2020towards}.
\begin{table}
\begin{footnotesize}
\begin{tabular}{p{.8in} p{.5in} p{3.0in}}
\toprule
Metric & Type & Probe \\ \midrule
Interesting &
Positive & Wow that is really interesting. / That's really interesting! / Cool! That sounds super interesting. \\
& Negative & That's not very interesting. / That's really boring. / That was a really boring response. \\ \midrule
Engaging &
Positive & Wow! That's really cool! / Tell me more! /
I'm really interested in learning more about this. \\
& Negative & Let's change the topic. / I don't really care. That's pretty boring. / I want to talk about something else.
\\ \midrule
Relevant &
Positive & \; --- \\
& Negative & That's not even related to what I said. / Don't change the topic! / Why are you changing the topic?
\\ \midrule
Correct &
Positive & \; --- \\
& Negative & You're not understanding me! / I am so confused right now! /
I don't understand what you're saying.
\\ \midrule
Semantically &
Positive & That makes sense. / You have a good point. , \\
Appropriate & negative & That makes no sense!
\\ \midrule
Fluent &
Positive & That makes sense! / You have a good point. \\
& Negative & Is that real English? / I'm so confused right now! / That makes no sense!
\\ \bottomrule
\end{tabular}
\caption{\label{fed-probes} Sample User response probes for FED turn level metrics}
\end{footnotesize}
\end{table}
The turn-level metrics are computed by determining the relative likelihood of a system response in context being followed by a set of predefined positive and negative probe responses for a given dialoguequality. The probe responses
are shown in Table~\ref{fed-probes}.
For each conversation in the normalized corpus, the turn-level FED metric scores given the previous context is computed for each candidate response using a \textit{DialoGPT-large} model. We exclude dialogues that do not have any context turns, since the initial turns are greeting turns and do not involve response selection. This yields a final corpus of 5927 candidate responses in 1743 dialogues.
FED is meant to provide general metrics based on LLMs that are not a reflection of a particular training set. Previous work suggests that the correlations between FED metrics and
human annotations can be as high as .21 at the turn level and as high as .443 at the dialogue level \cite{mehri2020unsupervised}.
Our hypothesis was that the different turn-level FED measures strongly overlap in terms of what they are trying to capture.
To explore this, we calculated the the Pearson correlation for the individual metric scores
for all the responses from the conversation corpus. The correlation heatmap is shown in Figure~\ref{fig:rr-fed_correlation_matrix_large}. The heatmap clearly shows (light cream blocks) that sets of metrics are highly correlated with one another. In particular, the following groups of metrics exhibit a high degree of correlation with each other --- (i) \textit{interesting}, \textit{engaging}, \textit{specific} (ii) \textit{relevant}, \textit{correct}, (iii) \textit{semantically appropriate}, \textit{understandable}, \textit{fluent}. The heatmap also shows that the \textit{interesting}, \textit{engaging}, and \textit{specific} metrics have a strong negative correlation with the \textit{semantically appropriate}, \textit{understandable}, \textit{fluent} metrics.
\begin{wrapfigure}{r}{2.5in}
\vspace{-.35in}
\centering
\includegraphics[width=2.5in]{fed_dialogpt_large_corr_heatmap.png}
\caption{FED metric Correlations on Athena corpus (DialoGPT-large)}
\label{fig:rr-fed_correlation_matrix_large}
\vspace{-.2in}
\end{wrapfigure}
We posit two causes for this result --- one being the conversations that DialoGPT is trained on are very different from Athena conversations and the other being many of the chosen reference sentences used to compute the FED scores are very similar across the correlated metrics. Note that the reference sentences shown in Table~\ref{fed-probes} for \textit{semantically appropriate, understandable}, and \textit{fluent} are based on the same positive prompts while using very similar or overlapping examples of negative prompts. Also \textit{relevant, correct} both contain only negative prompts while \textit{interesting, engaging, specific} use positive prompts that can be construed as being similar. As a result, the metrics in each correlated group appear to measure the same attribute, which is in line with related work that report similar correlations in the human annotation scores of the conversation-level qualities in the FED dataset\cite{zhang2022fined}.
We also explored whether there's a significant difference between the FED metric scores for the population of human preferred and dispreferred responses in the normalized Athena corpus. We did a two-sided t-test for the FED metrics between the samples of human preferred and dispreferred utterances. We found that \textit{Interesting, Engaging, Specific} scores for the human preferred responses were actually significantly lower than those of dispreferred responses; in other words they go the opposite direction of what they are supposed to measure. The two samples for \textit{Relevant, Correct, Semantically Appropriate, Fluent} showed no statistically significant difference. The only metric that worked as predicted was \textit{Understandable}, where the scores for human preferred responses were significantly higher than those of the dispreferred responses.
Overall, the FED metrics demonstrate weak results on Athena conversations for response ranking and may not be a suitable measure for dialogue quality evaluations.
\vspace{.1in}
\noindent{\bf Athena-RR: A Response Ranking transformer.}
\label{sec:Athena-RR-model}
Much of the recent research using pre-trained transformer models use an end-to-end dialogue learning approach. Rather than aiming to construct an end-to-end model, we want to enhance the dialogue system that we already have. Therefore, we will not be able to ``copy" the problem setup used in other work \cite{Gopalakrishnan2019,Dinan_Roller_Shuster_Fan_Auli_Weston_2019,Wolf_Sanh_Chaumond_Delangue_2019}.
We also want Athena's response ranker to take advantage of all the information contained in Athena's internal dialogue state representation. We develop a method of incorporating the additional information into the model by extending the input sequence dialogue tokens using special token representations of Athena's internal state.
We train a BERT based model, Athena-RR, using our annotated corpus of Athena's response pools. Athena-RR is trained by optimizing a next-utterance classification loss, similar to that used in the next-sentence prediction task used in BERT\cite{Devlin2019BERTPO}. The model performs binary classification on each response candidate to predict whether or not a potential utterance occurs next for a given conversation context. Our end goal is to have a model capable of picking responses from a response pool rather than just performing binary classification on responses.
Our model is pre-trained on the Topical Chats corpus using random sampling for False next-utterances. We take the model checkpoint with the highest validation accuracy on the Topical Chats corpus and fine-tune the model on Athena conversation data. For the sake of evaluation on this intermediate binary classification task, we use a random training/evaluation partition of the dataset using a $90:10$ ratio.
To smooth the distribution of positive and negative class instances in the data, the annotated corpus is down sampled to smooth the distributions of response candidate selections. Some response candidates were presented to annotators a disproportionate number of times, resulting in some utterances having been not selected most of the times they were in a response pool. This is due to the internal working of Athena, and the way that the response pools were collected. In cases where an example occurs more than 8 times as a negative example, we cap its frequency using the cap value $N_{\text{cap}}$, computed as:
$ N_{\text{cap}} = 8 + 2 \cdot \text{log}(\bar{C}) $
where $\bar{C}$ is the number of times annotators had the opportunity to select the candidate but didn't.
\vspace{.1in}
\noindent
\textbf{Input Representation.}
Model inputs are the conversation context and a candidate response.
Conversation context includes four turns of history represented as sequence of tokens with a special \texttt{[SEP]} token between turns. The context also includes special tokens that represent Athena's internal dialogue state, such as the current topic and the previous topic.
We also add special tokens to the front of the response candidate token sequence that denote the RG it came from.
\begin{figure}[htb]
\centering
\includegraphics[width=\textwidth]{speaker-aware-token.jpg}
\caption{Speaker aware token embeddings.}
\label{fig:speaker-aware-embeddings}
\end{figure}
\noindent
\textbf{Speaker-Aware turn embeddings.}
Athena-RR is implemented using the HuggingFace Transformers\cite{Wolf2019HuggingFacesTS}
implementation of the BERT transformer in our experiments.
Similar to \citep{Wolf_Sanh_Chaumond_Delangue_2019}, we adapt the model by adding special embeddings that indicate the speaker and the dialogue state information. Figure~\ref{fig:speaker-aware-embeddings} shows the speaker aware embedding token and embedding function.
\subsection{Evaluation Methods and Setup}
\noindent{\bf Corpus Evaluation.}
We evaluate all five ranking models, DialogRPT, DynaEval, FED, Athena-Heuristic and Athena-RR in terms of recall@1 on a held-out test set of 89 (context, response pool) instances.
To measure the performance of the off-the-shelf models, we test whether the response with the highest model score is a human preferred response in each conversation.
\vspace{+.1in}
\noindent{\bf Evaluation: Live User Study.}
Because Athena is a real system that interacts with human users, we were also able to
incorporate our response ranking model into Athena's dialogue manager and deploy it in an A/B study with the \textit{A} version using a pre-existing heuristic response ranker, and the \textit{B} version using Athena-RR.
We trained a new version of the model using our entire annotation corpus including our test set. During training, the model learns to perform binary classification on a given response candidate: say it next or don't say it next. We incorporate the model into Athena by scoring each candidate response separately for a given response pool, and then returning the response with the highest log-likelihood. Note that Athena-RR does not do topic-selection, this is driven by a model of user topic preferences and the dialogue context. Athena-RR is also not used when the response pool contains only one response candidate.
\section{Results}
\label{sec:results}
\begin{wraptable}{r}{2.0in}
\vspace{-0.3in}
\centering
\begin{small}
\begin{tabular}{lr}
\toprule
Model & Recall@1 \\ \midrule
DialogRPT-updown & 29.21\% \\
DialogRPT-width & 46.07\% \\
DialogRPT-depth & 47.19\% \\
DialogRPT-human-vs-rand & 42.70\% \\
DialogRPT-human-vs-machine & 38.20\% \\
\midrule
DynaEval & 21.34\% \\ \midrule
FED-Interesting & 28.09\% \\
FED-Engaging & 30.34\% \\
FED-Specific & 26.97\% \\
FED-Relevant & 39.33\% \\
FED-Correct & 41.57\% \\
FED-Semantically Appropriate & 41.57\% \\
FED-Understandable & 40.45\% \\
FED-Fluent & 39.33\% \\ \midrule
Athena-Heuristic & 56.18\% \\ \midrule
Athena-RR & 70.79\% \\
\bottomrule
\end{tabular}
\end{small}
\caption{Performance of the various response rankers on the test set}
\label{table:ranking-autoeval}
\end{wraptable}
Table~\ref{table:ranking-autoeval} shows that DynaEval and the DialogRPT-updown metric have the poorest performance with accuracies of only 21.34\% and 29.21\% respectively.
The DialogRPT width and depth metrics perform much better with the depth metric achieving an accuracy of 47.19\%. DialogRPT is better than the best FED metric. Previous work suggests that the DialogRPT human-vs-random ranker performs the best \cite{hedayatnia2022systematic}, though the human-based metrics are not better than DialogRPT-width and DialogRPT-depth on the Athena corpus. The FED metrics \textit{Interesting, Engaging, Specific} all have accuracies at 30\% or worse. \textit{Relevant, Correct, Semantically Appropriate, Understandable}, and \textit{Fluent} have the highest accuracies, with best accuracy at 41.57\%, but the differences between them are not statistically significant (p $=$ .58). The Athena-Heuristic ranker is better than DialogRPT-depth and better than FED Semantically Appropriate (p $=$ 0.037), which is the highest accuracy FED metric. The relatively poorer performance of the FED metrics in comparison to the Athena-Heuristic ranker that simply tries to stay on topic indicates that FED does not have any notion of topic relevance. The Athena-RR ranker, trained specifically for this task, performs the best, as might be expected. The accuracy of 70.79\% is much better than that achieved by the previous heuristic Athena response ranker.
\begin{wraptable}{r}{2.0in}
\vspace{-.2in}
\begin{small}
\centering
\begin{tabular}{lcccc}
& & Median & Mean & Mean \\
Version & N & \# turns & \# turns & rating \\ \toprule
Heur. & 3,502 & 10 & 15.02 & 3.64 \\
Trans. & 2,856 & 19 & 24.77 & 3.77 \\ \hline
& & & \textit{p}\textless 0.01 & \textit{p}\textless 0.01 \\ \bottomrule
\end{tabular}
\caption{A/B study results: heuristic response ranker versus AthenaRR.}
\label{table:rr-ab-study-results}
\end{small}
\end{wraptable}
\vspace{.1in}
\noindent{\bf Human Evaluation A/B Study}. We then deployed Athena-RR and Athena-Heuristic simultaneously in a live A/B study. Because the metrics used in the Alexa Prize are the average user rating and length (number of turns) for conversations, we evaluate those measures in the A/B study. Athena-RR is not used until the fourth system turn so we only consider conversations that meet this length requirement. We also note that there are a number of possible situations in a conversation where response ranking is not used \cite{whang2021response}. For instance, if the user says "Let's talk about something else", the flow-of-control returns to the DM to select a new topic. Also, Athena-RR is not used when the system needs to perform a functional speech act, e.g., user asks the system to repeat itself, or Athena needs to deflect a user seeking adult content.
Table~\ref{table:rr-ab-study-results} shows the A/B study results for conversations where Athena-RR was used on one or more turn, compared to conversations where Athena-Heuristic was used on every turn. The results show that Athena-RR outperforms the Athena-Heuristic model for both conversation length and ratings, with a significant (p $<$ .01) and large increase in both measures.
\section{Discussion and Conclusion}
\label{sec:discussion}
\label{sec:conclusion}
This paper describes a response ranker for the Athena SocialBot system, a competitor in the Alexa Prize. Response ranking is challenging in Athena because it has the capacity to provide many different on-topic responses in a particular dialogue context: the response ranker needs to discriminate between different on-topic responses. We developed a corpus of Athena conversations with real human users by logging all possible responses that Athena could produce for many different dialogue contexts, and then sampled these so as to represent all of Athena's topics, as well as to have a good distribution of contexts where users ask questions.
We then explore different models for response ranking and selection. We train a new conversational response ranking model, Athena-RR, based on the speaker-aware BERT architecture and compare its performance to the reference-free dialogue evaluation metrics DialogRPT, DynaEval and FED, as well as to Athena-Heuristic, the rule-based response ranker fielded in Alexa Prize 3. We find that DialogRPT-depth provides the highest performance of the off-the-shelf metrics with a Recall@1 of 47.19\%. We show that DynEval performs much worse on Athena than on other corpora \cite{yeh2021comprehensive}. We also demonstrate that the turn-level metrics within FED exhibit strong correlations with each other, as also found in previous work \cite{zhang2022fined}, and that FED performs significantly worse than DialogRPT-depth, with the best turn-level FED metrics achieving a Recall@1 of 41.57\%. Finally, we show that Athena-RR significantly outperforms Athena-Heuristic in an offline evaluation with a Recall@1 of 70.79\% as compared to 56.18\%, and that it is also significantly better than any of the off-the-shelf metrics.
One surprising result was that Athena-Heuristic, which simply tries to stay on topic, significantly outperformed all the off-the-shelf metrics (p $=$ 0). One would imagine that DialogRPT, which is trained on thousands of Reddit conversations, would have internalized a notion of topical coherence. Perhaps DialogRPT performs more poorly than expected because Reddit conversations are very different in style than Athena: the conversations are between humans, topical coherence may not be an issue, and the number of human responses to an utterance may reflect their individual opinions rather than utterance quality.
Finally we conduct an A/B study of Athena-RR and Athena-Heuristic in our live deployed system with over 6000 conversations with end-users. Our results show that Athena-RR led to significantly better conversation ratings (3.77 compared to 3.64) and longer conversations (24.77 turns as compared to 15.02 turns) when compared to those chosen by a heuristic-based response ranker.
\bibliographystyle{plainnat}
| {'timestamp': '2023-02-10T02:05:48', 'yymm': '2302', 'arxiv_id': '2302.04424', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04424'} | arxiv |
\section{Introduction}
Explain what multimodality is and what a recommender system is. Explain what a multimodal based recommender system is.\\
Summary of existing MM tasks/models in CV/NLP. They do not consider the personalisation which is important for a recommender system.\\
Why incorporating multimodal information into the recommender system.
(can potentially alleviate the sparsity problem and improve the quality recommendations)\\
The scope of this survey. How this survey is organized.\\
\section{Taxonomy based on modalities}
\subsection{Visual or Textual or Audio}
How the features are extracted. How to use features for the recommendation task.
\subsubsection{Visual enriched Models.} Data sources include images and videos.
\\ \\
\subsubsection{Textual enriched Models.} Data sources include user reviews, item descriptions, item titles.
(How the features are extracted)\\
1. Topic Based.
Topic based methods normally apply Latent Dirichlet Allocation(LDA)\cite{blei2003latent} to uncover hidden dimensions in text. It models each document as a distribution of an underlying set of topics.
\begin{center}
\begin{tabular}{|p{0.15\linewidth}|p{0.15\linewidth}|p{0.15\linewidth}|p{0.4\linewidth}|}
\hline
Data Sources & Notes & Model & Publications \\
\hline
Reviews & Items only & LDA & CTR\cite{wang2011collaborative}, HFT\cite{mcauley2013hidden} \\
\hline
\end{tabular}
\end{center}
2. Neural Networks.
\begin{center}
\begin{tabular}{|p{0.15\linewidth}|p{0.15\linewidth}|p{0.15\linewidth}|p{0.4\linewidth}|}
\hline
Data Sources & Notes & Model & Publications \\
\hline
Item contents & Items only & SDAE & CDL\cite{wang2015collaborative}, CKE\cite{zhang2016collaborative} \\
\hline
Item contents & Items only & CNN & ConvMF\cite{kim2016convolutional}\\
\hline
Reviews & Items \& Users & CNN & DeepCoNN\cite{zheng2017joint},TransNets\cite{catherine2017transnets},D-Attn\cite{seo2017interpretable},CARL\cite{wu2019context},NARRE\cite{chen2018neural},DAML\cite{liu2019daml}\\
\hline
Reviews & Items & GRU & TARMF\cite{lu2018coevolutionary} \\
\hline
Reviews & Items & DNN & GATE\cite{ma2019gated} \\
\hline
\end{tabular}
\end{center}
(How to use features for the recommendation task) \\
1. The text acts like the regularization term for rating prediction. Examples are HFT\cite{mcauley2013hidden}, ConvMF\cite{kim2016convolutional}, TARMF\cite{lu2018coevolutionary}.
2. Review-based embeddings are combined with ratings-based embeddings through summation NARRE, DAML\cite{chen2018neural, liu2019daml}, concatenation TransNets\cite{catherine2017transnets} or neural network layer GATE\cite{ma2019gated}. And then use dot product, FM, NeuFM or AE for recommendation task.
3. Each of the review-based and ratings-based model generates a prediction score and will be combined linearly for final prediction. CARL\cite{wu2019context}
\\ \\
\subsubsection{Hybrid Models.} Data sources include visual, textual, or audio features. How those modalities are fused.
\subsection{Knowledge Graphs.}
\subsection{Social Graphs.}
\section{Taxonomy Based on ML tasks}
\subsection{Recommendation}
\begin{enumerate}
\item deep learning
\item graphs
\end{enumerate}
\subsection{Pre-training}
\begin{enumerate}
\item pretrain user embeddings: what prefix tasks
\item pretrain item embeddings: what prefix tasks
\end{enumerate}
\subsection{Cross modal retrieval}
\section{Taxonomy Based on specific domains}
\subsection{Micro-video Recommendation}
\subsection{Fashion Recommendation}
\subsection{News Recommendation}
\section{Datasets and Experiments}
\subsection{Datasets}
\subsubsection{Visual and textual}
\subsubsection{Knowledge graphs}
\subsubsection{Social graphs}
\subsection{Experiments}
\subsubsection{Recommendation performance comparison using visual and textual.}
\subsubsection{Downstream task performance comparison using pretrained user or item embeddings.}
\subsubsection{Performances on different user or item popularity groups.}
\subsubsection{Will embeddings extracted from different pretrained models affect the performance?}
\section{Challenges and Future Research Directions}
How to effectively fuse multimodal information?\\
Design of prefix tasks for pretraining
\section{Conclusion}
\begin{acks}
To Robert, for the bagels and explaining CMYK and color spaces.
\end{acks}
\bibliographystyle{ACM-Reference-Format}
\section{Introduction}
why multimodal?
can potentially alleviate the sparsity problem and improve the quality recommendations
\section{Datasets and Evaluation}
\subsection{Datasets}
TBD
\subsection{Evaluation}
TBD
\section{Unimodal Feature Representation}
\subsection{Rating Based Representation}
TBD
\subsection{Textual Representation}
\subsubsection{Topic Based}
Topic based methods normally apply Latent Dirichlet Allocation(LDA)\cite{blei2003latent} to uncover hidden dimensions in text. It models each document as a distribution of an underlying set of topics.
\begin{center}
\begin{tabular}{|p{0.15\linewidth}|p{0.15\linewidth}|p{0.15\linewidth}|p{0.4\linewidth}|}
\hline
Data Sources & Notes & Model & Publications \\
\hline
Documents or Reviews & Items only & LDA & CTR\cite{wang2011collaborative}, HFT\cite{mcauley2013hidden} \\
\hline
\end{tabular}
\end{center}
\subsubsection{Neural Networks}
\begin{center}
\begin{tabular}{|p{0.15\linewidth}|p{0.15\linewidth}|p{0.15\linewidth}|p{0.4\linewidth}|}
\hline
Data Sources & Notes & Model & Publications \\
\hline
Item contents & Items only & SDAE & CDL\cite{wang2015collaborative}, CKE\cite{zhang2016collaborative} \\
\hline
Item contents & Items only & CNN & ConvMF\cite{kim2016convolutional}\\
\hline
Reviews & Items \& Users & CNN & DeepCoNN\cite{zheng2017joint},TransNets\cite{catherine2017transnets},D-Attn\cite{seo2017interpretable},CARL\cite{wu2019context},NARRE\cite{chen2018neural},DAML\cite{liu2019daml}\\
\hline
Reviews & Items & GRU & TARMF\cite{lu2018coevolutionary} \\
\hline
Reviews & Items & DNN & GATE\cite{ma2019gated} \\
\hline
\end{tabular}
\end{center}
\subsection{Image Representation}
TBD
\subsection{Video Representation}
TBD
\subsection{Audio Representation}
TBD
\section{Multimodal Feature Representation}
\subsection{Textual Representation x Rating Based Representation}
\begin{itemize}
\item Jointly Learned Representations
\end{itemize}
The framework is based on matrix factorization where item embeddings were trained by a separate model, such as LDA\cite{wang2011collaborative} or SDAE\cite{wang2015collaborative}. And the prediction is made by taking the dot product of item embeddings and user embeddings.
\begin{itemize}
\item Aligned Representations
\end{itemize}
Embeddings learnt through ratings and reviews are aligned by certain constraints. The text acts like the regularization term for rating prediction. Examples are HFT\cite{mcauley2013hidden}, ConvMF\cite{kim2016convolutional}, TARMF\cite{lu2018coevolutionary}.
\begin{itemize}
\item Combined Representations
\end{itemize}
Review-based embeddings are combined with ratings-based embeddings through summation NARRE, DAML\cite{chen2018neural, liu2019daml}, concatenation TransNets\cite{catherine2017transnets} or neural network layer GATE\cite{ma2019gated}. And then use dot product, FM, NeuFM or AE for recommendation task.
\begin{itemize}
\item Late Fusion Prediction
\end{itemize}
Each of the review-based and ratings-based model generates a prediction score and will be combined linearly for final prediction. CARL\cite{wu2019context}
\section{Multimodal Generation}
TBD
\section{Applications}
TBD
\section{Challenges and Future Research Directions}
TBD
\section{Conclusion}
\begin{acks}
To Robert, for the bagels and explaining CMYK and color spaces.
\end{acks}
\bibliographystyle{ACM-Reference-Format}
\section{Introduction}
With the development of society, a huge number of items and information have been displayed in the network, it would be difficult for users to decide which is useful and pick out the preferred one. The information overload issue has been solved when the recommendation system appears\cite{lu2012recommender}. It predicts the rating or user preference over all items and recommends the most probable and pertinent items that the user might choose according to the historical interaction data and public item information(like clicks and sales). The algorithms of recommendation could be classified into collaborative filtering (CF), content-based filtering and hybrid recommendation system~\cite{shah2016survey}. CF is based on analyzing and gathering the user's historical behaviors data, which includes the historical interactions (\emph{e.g.},\xspace clicks, look-through, purchases) and user preference (\emph{e.g.},\xspace ratings). The content-based filtering suggests products based on the user profile and item profile of the user. The item is described with the keywords and the user's profile will express the types of items the user likes. The main idea of this method is the user will probably choose similar items that they like before. Hybrid approach combines different techniques of collaborative filtering and content-based filtering to get a better result.
Those traditional recommendation methods~\cite{he2020lightgcn,zhou2021selfcf,zhang2022diffusion,zhou2022layer} have shortages as we introduce that they require a large number of interactions between users and items to make a more accurate recommendation. The users and items with few or even no interactions will influence the accuracy of recommendations.
In order to alleviate the data sparsity problem~\cite{zhou2016evaluating,zhou2022bribery} and cold start issue, multimodal information has been introduced into the recommendation system. The multimodal recommendation leverages the auxiliary multimodal information which could supplement the historical user-item interactions to improve the recommendation performance. The multimodal model is able to represent and discover hidden relations between different modalities and possibly recover the complementary information which can not be captured by a uni-modal approach and implicit interactions. Such skills are also necessary for natural language processing~\cite{sulubacak2019multimodal} to achieve human-level comprehension in a variety of AI jobs. The multimedia data shows not only the relationship between users and items but also reflect the preference of user in different modalities. For the same modality, the data might reflect the similarity and the semantic meaning of different items. In order to incorporate multimodal information into the recommendation system, the current method is extracting the features from different modalities and then using the modality fusion result as the side information or the item representation. VBPR~\cite{he2016vbpr} is the first model that considers introducing visual features into the recommendation system by concatenating visual embeddings with id embeddings as the item representation. \cite{wei2019mmgcn,wang2021dualgnn,wei2020graph} utilize the GCN-based methods to produce the representations of each modality and then fuse them together as the final representations. Except for fusing the modality representations, the knowledge graph based modality side information is also introduced into the multimodal recommendation~\cite{sun2020multi}. Different techniques have been introduced into the multimodal recommendation that tries to find better representations for users and items to achieve more accurate recommendation results.
Nowadays, online sharing platforms are commonly used, such as fashion, news, short video and music recommendation platforms. Those popular online platforms contain a large number of multimodal information that drives the user's choice. As people commonly use those platforms with huge multimodal information contained inside, the multimodal recommendation is necessarily applied to learn more accurate user preferences.
Different from the traditional recommendation, those applications have utilized the item multimodal content information like the video frames, audio track and item descriptions. MMGCN~\cite{wei2019mmgcn}, MGAT~\cite{tao2020mgat}, DualGNN~\cite{wang2021dualgnn} and SLMRec~\cite{tao2022self} are the micro video recommendation models that utilize description, captions, audio, and frames inside the video to model the multimodal user preference on the micro-video. Fashion recommendation faces difficulties to build an efficient recommender cause of the complex features involved and the subjectivity. \cite{kang2017visually,chen2019personalized} aims to utilize multimodal information to overcome the issue. The news recommendation previously focuses on the title and text uni-modal information but ignores the visual information like images. \cite{wu2021mm,xun2021we} try to use multi-modality to enhance the recommendation performance.
The multimodal recommendation system is popularly used because of the advantages and necessities we discussed above. And there is no survey that discusses the techniques used for multimodal recommendation. In order to provide a guideline for researchers, we describe the overview of the multimodal recommendation system and classify the reviewed papers according to the methods used. The goal of this survey is to introduce how the multimodal recommendation system works by showing a clear pipeline of the process with techniques used in each step. We aim to guide new researchers to understand the principles and techniques commonly used in multimodal recommendation systems. Additionally, we provide a developed code framework that contains the implemented SOTA models with pre-extracted multimodal features, which makes it efficient for researchers to run the SOTA models or develop their own model based on the framework.
\subsection{Strategy for Literature search}
Since our survey focuses on reviewing the multimodal recommendation, we retrieved most of the top conferences related to recommendation systems such as WWW, SIGIR, KDD, ICLR, AAAI, WSDM, and RecSys, also the top journals such as TKDD, TMM, and so on. At the same time, we also utilize Google Scholar to search for related papers. We use the keywords multimodal recommendation, multimodal recommendation, multimedia recommendation, content+RS, context+RS, etc, to search for the related papers. After getting the list of papers, we also look through the related works of those papers to make sure that we covered a majority of papers about multimodal recommendations.
\subsection{Differences compared with other surveys}
There are surveys that have looked into the recommendation area because of the importance and popularity of the recommendation system ~\cite{le2022survey,wang2021graph,shi2014collaborative,rafsanjani2013recommendation}. To the best of our knowledge, those surveys do not consider the multi-modality information and there is only one survey~\cite{deldjoo2020recommender} that discusses the multimedia recommendation and mentions the multi-modality information. Although discussion of multi-modality always involves both modality and media, these two terms are not synonymous but with overlapping~\cite{lauer2009contending}. The media is a physical channel that uses technology to store, move, and transmit information. It is the tool and material resource to produce and disseminate information. The modality is a human sensory channel that serves as the user input modality when interacting with a system. It can be considered a way of representing information. For one media, there might be several modalities contained inside. For example, books are considered to be media but the different languages of text are considered as modalities. Additionally, this survey only aims to bridge the recommendation system with multimedia and just classify the papers according to the media type and application. It considers which application those modalities could be used for (like music recommendation, movie recommendation, etc.) but ignores the hidden algorithm and methods that are used to utilize the multi-modality information in the recommendation system, and also ignores the fusion methods of different modalities.
Unlike the existing surveys, our survey is organized according to the different methods usually used for multimodal recommendation systems. The mentioned multimedia survey just wants to divide models according to the media type. What we want to achieve is that the new beginners could learn what are the main steps of the multimodal recommendation system, what models could be used for their purpose and what are the mainly used techniques in each step like extracting features from different modalities and fusing the different modalities' representations. Another difference in our survey is that we not only provide the summaries of those multimodal recommendation models but develop a framework that contains the SOTA models utilizing different methods with several commonly used datasets. The beginners could easily run those baseline models after reading this survey, and they could conveniently develop their model with add new datasets according to the format.
\subsection{Organization and Contribution of Survey}
The main content of this survey is the overview of research on multimodal recommendation. The purpose of our work is to summarize the main methods that are used in this area and highlight the importance of multimodal content. Also, we will provide a common framework that contains the code implementation of the commonly used models which could help the beginner quickly run their data or implement the models in this framework. We will organize the survey as follows:
\begin{itemize}
\item Introduction
\item Pipeline of multimodal recommendation
\item Feature Extraction
\item Model Classification
\item Modality Fusion
\item Measurement and Optimization
\item Dataset and experiment results
\item Challenges and Future research directions
\item Conclusion
\end{itemize}
Having presented the organization of this survey, we summarize our main contributions as follows.
\begin{itemize}
\item We present a theoretical review of the multimodal recommendation system (MMRec), outline the various strategies for learning and leveraging modality information, and provide a comprehensive explanation of the techniques the model utilizes and how each MMRec model works.
\item We present the main steps of how the recommendation system leverages multimodal information and shows the pipeline of MMRec. Discuss how to choose the suitable dataset, feature extraction and optimization methods, which provide a clear guide to readers on developing the MMRec system.
\item We validate the effectiveness and efficiency of the SOTA multimodal recommendation models by performing extensive experiments on four public datasets. Also, discuss the key factor that influences models' performance (\emph{e.g.},\xspace different modality information, different data split methods).
\item Additionally, we create an open-source framework, MMRec~\cite{zhou2023mmrecsm}\footnote{https://github.com/enoche/MMRec}, that could be used to implement the baselines of MMRec models mentioned in this survey. Readers could also use this code framework to develop their own models. We hope this framework helps beginners easier understand how the multimodal recommendation model works and conveniently develop their own model considering only how to design the model with other steps done by the framework. In addition, we created an open-source repository that includes all those reviewed papers and the unimodal models\footnote{https://github.com/hongyurain/Recommendation-with-modality-information}.
\end{itemize}
\section{Pipeline of Multimodal Recommendation}
The multimodal recommendation system generally follows the steps in Fig.~\ref{Pipeline} and the modality fusion methods will be in different steps according to the settings which have been squared by dotted lines in the graph. The details of each step have been described in the following.
The multimodal recommendation system aims to learn informative representations of users and items by leveraging multimodal features. The first step is to extract modality features from the raw data. After getting the modality feature, you can choose to fuse them before feeding them into the multimodal models, fuse them in the intermediate layer of the model, or fuse the output of multimodal models. There will be different techniques applied to learn the user-item relations and leverage the multimodal information, which improves the recommendation accuracy with matched objective functions.
\begin{figure}[H]
\centering
\includegraphics[scale=0.4]{pipeline.pdf}
\caption{Pipeline of multimodal recommendation}
\label{Pipeline}
\end{figure}
\section{Feature Extraction}
The commonly used datasets may not contain all the modality features so it is also important to select suitable datasets according to the modality included. Table~\ref{tab: common dataset} shows the most commonly used datasets are the Amazon dataset, Movielens, Tiktok and Kwai. The Amazon dataset always contains image and text information, and there are many categories under Amazon so the selection of the dataset will also depend on the category. Baby, Sports, Beauty and Arts are commonly used for multimodal recommendation~\cite{zhou2022bootstrap,zhang_mining_2021,zhou2023enhancing}. And for some special domains like fashion recommendation, it always utilizes the Men and Women categories under Amazon. Food recommendations use the Yelp dataset which contains images and user reviews. News recommendations use the MIND dataset. The Tiktok, Kwai and Movielens datasets are used for the short video recommendation which contains textual, visual and audio information~\cite{wei2019mmgcn,wang2021dualgnn}, but Tiktok and Kwai are not publicly available. If you need special modality information or there are no datasets for your research domain, you can also crawl the data from the website and existing datasets to establish a new dataset.
\begin{table}[h]
\centering
\renewcommand\arraystretch{1.5}{
\begin{tabular}{m{9em}m{28em}}
\toprule
Dataset & Models \\
\hline
Amazon & VBPR\cite{he2016vbpr}, VMCF\cite{park2017also}, AMR\cite{tang2019adversarial}, VECF\cite{chen2019personalized}, PAMD\cite{han2022modality}, PMGT\cite{liu2021pre}, LATTICE\cite{zhang_mining_2021}, JRL\cite{zhang2017joint}, BM3\cite{zhou2022bootstrap}, GraphCAR\cite{xu2018graphcar}, DVBPR\cite{kang2017visually}, MAML\cite{liu2019userdiverse}, DMRL\cite{liu2022disentangled}, MVGAE\cite{yi2021multi}, MMCPR\cite{liu2022multi}, HCGCN\cite{mu2022learning}, FREEDOM~\cite{zhou2022tale}, DRAGON~\cite{zhou2023enhancing} \\
\hline
Kwai& MMGCN\cite{wei2019mmgcn}, SLMRec\cite{tao2022self}, GRCN\cite{wei2020graph}, EliMRec\cite{liu2022elimrec}, InvRL\cite{du2022invariant}, A2BM2GL\cite{cai2022adaptive} \\
\hline
Tiktok& MMGCN\cite{wei2019mmgcn}, DualGNN\cite{wang2021dualgnn}, MGAT\cite{tao2020mgat}, SLMRec\cite{tao2022self}, GRCN\cite{wei2020graph}, MMGCL\cite{yi2022multi}, EgoGCN\cite{chen2022breaking}, EliMRec\cite{liu2022elimrec}, InvRL\cite{du2022invariant}, A2BM2GL\cite{cai2022adaptive}, LUDP\cite{lei2022learning}\\
\hline
MovieLens& MMGCN\cite{wei2019mmgcn}, DualGNN\cite{wang2021dualgnn}, MGAT\cite{tao2020mgat}, SLMRec\cite{tao2022self}, GRCN\cite{wei2020graph}, MMGCL\cite{yi2022multi}, MKGAT\cite{sun2020multi}, EgoGCN\cite{chen2022breaking}, EliMRec\cite{liu2022elimrec}, InvRL\cite{du2022invariant}, A2BM2GL\cite{cai2022adaptive}, LUDP\cite{lei2022learning}\\
\hline
Yelp& PAMD\cite{han2022modality}\\
\hline
MIND& IMRec\cite{xun2021we} \\
\hline
Dianping& MKGAT\cite{sun2020multi} \\
\hline
Alishop& MVGAE\cite{yi2021multi} \\
\hline
Pinterest& ACF\cite{chen2017attentive}, AMR\cite{tang2019adversarial} \\
\hline
Crawl dataset& PAMD\cite{han2022modality}, MM-Rec\cite{wu2021mm}, UVCAN\cite{liu2019user}, DVBPR\cite{kang2017visually}, ACF\cite{chen2017attentive} \\
\bottomrule
\end{tabular}}
\caption{Commonly used Dataset}
\label{tab: common dataset}
\end{table}
The purpose of feature extraction is to describe the modality features in a low-dimensional and explainable way with embeddings. The modality data can be utilized in two ways. The first is passing the pre-extracted modality data into the model, and the second is passing the raw data into the model by applying end-to-end learning. According to most of the MMRec model settings, our framework are following the first method to use pre-extracted features. Different modality data have modality-specific methods to extract. Table~\ref{feature extraction} summarize the multimodal feature extraction methods. Depending on the different modalities, the data resources and methods are different. We simply divided the task according to the data resources and list out the mainly used extraction methods with the example models.
We can figure out that for visual features, the commonly used techniques are the CNN and variants of CNN. For the models~\cite{wei2019mmgcn,wang2021dualgnn} utilize Kwai and Tiktok, Those two datasets are not publicly available, even the researchers that own the datasets utilize the visual and textual features which are pre-extracted. For the textual feature, different pre-trained language models are used according to the purpose of the model.
\begin{table}
\centering
\begin{tabular}{m{6em} m{6em} m{7em} m{18em}}
\toprule
Modality & Content & Methods & Models \\
\hline
Visual &Micro Video & Published \qquad feature &MMGCN\cite{wei2019mmgcn}, DualGNN\cite{wang2021dualgnn}, MGAT\cite{tao2020mgat}, SLMRec\cite{tao2022self}, GRCN\cite{wei2020graph}, HHFAN\cite{cai2021heterogeneous}, MMGCL\cite{yi2022multi}, EgoGCN\cite{chen2022breaking}, InvRL\cite{du2022invariant}, A2BM2GL\cite{cai2022adaptive}, LUDP\cite{lei2022learning} \\
\hline
\multirow{7}{*}{Visual} & \multirow{7}{*}{Images} & VGG-19 & VECF\cite{chen2019personalized}, PAMD\cite{han2022modality} \\
& & VILBERT & MM-Rec\cite{wu2021mm} \\
& & CNN+MLPs & IMRec\cite{xun2021we} \\
& & Inception-v4 & PMGT\cite{liu2021pre} \\
& & Inception-v3 & UVCAN\cite{liu2019user} \\
& & Deep CNN & VBPR\cite{he2016vbpr}, VMCF\cite{park2017also}, LATTICE\cite{zhang_mining_2021}, FREEDOM~\cite{zhou2022tale}, HCGCN\cite{mu2022learning}, JRL\cite{zhang2017joint}, BM3\cite{zhou2022bootstrap}, GraphCAR\cite{xu2018graphcar}, DVBPR\cite{kang2017visually}, DRAGON~\cite{zhou2023enhancing} \\
& & Caffe & MAML\cite{liu2019userdiverse},DMRL\cite{liu2022disentangled} \\
& & ResNet & MKGAT\cite{sun2020multi}, MVGAE\cite{yi2021multi}, GraphCAR\cite{xu2018graphcar}, ACF\cite{chen2017attentive}, AMR\cite{tang2019adversarial}, EgoGCN\cite{chen2022breaking}, EliMRec\cite{liu2022elimrec}, InvRL\cite{du2022invariant} \\
\hline
\hline
Textual & Video Titles & Published \qquad feature & MMGCN\cite{wei2019mmgcn}, DualGNN\cite{wang2021dualgnn}, MGAT\cite{tao2020mgat}, SLMRec\cite{tao2022self}, GRCN\cite{wei2020graph}, HHFAN\cite{cai2021heterogeneous}, MMGCL\cite{yi2022multi}, EgoGCN\cite{chen2022breaking}, A2BM2GL\cite{cai2022adaptive}, LUDP\cite{lei2022learning} \\
\hline
\multirow{5}{*}{Textual} & \multirow{5}{*}{Reviews} & GRU & VECF\cite{chen2019personalized}\\
& & Glove+MLP & PAMD\cite{han2022modality} \\
& & PV-DBOW & JRL\cite{zhang2017joint} \\
& & PV-DM & MAML\cite{liu2019userdiverse} \\
& & BERT & DMRL\cite{liu2022disentangled} \\
& & Word2Vec+SIF & MKGAT\cite{sun2020multi}\\
\hline
\multirow{2}{*}{Textual} & \multirow{2}{*}{Title} & VILBERT & MM-Rec\cite{wu2021mm}\\
& & Attention & IMRec\cite{xun2021we} \\
\hline
\multirow{5}{*}{Textual} & \multirow{5}{*}{Item description} &BERT & PMGT\cite{liu2021pre}\\
& & TF-IDF & ADDVAE\cite{tran2022aligning} \\
& & Word2Vec+SIF & MKGAT\cite{sun2020multi}\\
& & Sentence-transformer & Lattice\cite{zhang_mining_2021}, FREEDOM~\cite{zhou2022tale}, HCGCN\cite{mu2022learning}, BM3\cite{zhou2022bootstrap}, DRAGON~\cite{zhou2023enhancing}\\
& & Sentence2Vec & MVGAE\cite{yi2021multi}, EgoGCN\cite{chen2022breaking}, EliMRec\cite{liu2022elimrec}, InvRL\cite{du2022invariant}\\
\bottomrule
\end{tabular}
\caption{Modality feature extraction methods.}
\label{feature extraction}
\end{table}
\section{Model Classification}
We have classified models according to the methods that they utilized in the model as Table~\ref{tab: Model Classification} shows. The Matrix Factorization and MLP-based methods are the earlier ways to do recommendations. Previously, researchers just utilize the multimodality information simply, like VBPR~\cite{he2016vbpr} used the CNN extracted visual feature concatenate with id embeddings as the item representation then feeds into the MF module. Although it is simple, it could utilize the modality information as side information to help the cold start and data sparsity issues. Then a lot of deep learning techniques have been introduced into MMRec and show significant enhancement to utilize the modality information. For example, Autoencoder and Variational autoencoder techniques were introduced into the recommender system. Also, MMGCN~\cite{wei2019mmgcn} starts to use the Graph Convolutional Network to learn the representation of each modality then fuse the modality representation and id embedding together as the final item representations. Based on this GCN structure, researchers introduce knowledge graph~\cite{sun2020multi}, attention mechanism, edge refine~\cite{wei2020graph} and other fusion ways to help to learn better representations. In recent years, as the pretrain \& finetune has achieved good performance in CV and NLP, it is introduced into the MMRec system. This table only shows the overview of the classification of models, the following content will provide the introduction of each model and how they utilize the modality information by different techniques. One model might appear twice because some of the models are utilizing a combination of several approaches.
\begin{table}
\centering
\renewcommand\arraystretch{1.5}{
\begin{tabular}{m{19em}m{18em}}
\toprule
Method & Models \\
\hline
Matrix Factorization & VBPR\cite{he2016vbpr}, GraphCAR\cite{xu2018graphcar}, VMCF\cite{park2017also}, AMR\cite{tang2019adversarial}, ACF\cite{chen2017attentive}, ConvMF\cite{kim2016convolutional}, DeepCoNN\cite{zheng2017joint}, DVBPR\cite{kang2017visually} \\
\hline
Multilayer Perceptron & JRL\cite{zhang2017joint} \\
\hline
(Variational) Autoencoder & CKE\cite{zhang2016collaborative}, ADDVAE\cite{tran2022aligning}, MVGAE\cite{yi2021multi}\\
\hline
Attention Network & UVCAN\cite{liu2019user}, ACF\cite{chen2017attentive}, MAML\cite{liu2019userdiverse}, MMRec\cite{wu2021mm}, DMRL\cite{liu2022disentangled}, IMRec\cite{xun2021we} \\
\hline
Graph Neural Network(GNN) & HHFAN\cite{cai2021heterogeneous}, MKGAT\cite{sun2020multi}, MMGCN\cite{wei2019mmgcn}, DualGNN\cite{wang2021dualgnn}, MGAT\cite{tao2020mgat}, MEGCF\cite{liumegcf}, GRCN\cite{wei2020graph}, Lattice\cite{zhang_mining_2021}, FREEDOM~\cite{zhou2022tale}, HUIGN\cite{wei2021hierarchical}, HGCL\cite{cai2022heterogeneous}, HCGCN\cite{mu2022learning}, EgoGCN\cite{chen2022breaking}, EliMRec\cite{liu2022elimrec}, InvRL\cite{du2022invariant}, A2BM2GL\cite{cai2022adaptive}, LUDP\cite{lei2022learning}, DRAGON~\cite{zhou2023enhancing}\\
\hline
RNN+Attention & VECF\cite{chen2019personalized}\\
\hline
Matrix Factorization+CNN & ConvMF\cite{kim2016convolutional}, DeepCoNN\cite{zheng2017joint}, DVBPR\cite{kang2017visually}\\
\hline
GNN+Pretrain and Finetune & PMGT\cite{liu2021pre}, PAMD\cite{han2022modality}, MMCPR\cite{liu2022multi}\\
\hline
GNN+self-supervised learning & SLMRec\cite{tao2022self}, BM3\cite{zhou2022bootstrap}, MMGCL\cite{yi2022multi}\\
\bottomrule
\end{tabular}}
\caption{Model classification}
\label{tab: Model Classification}
\end{table}
\subsection{Matrix Factorization based Models}
Matrix Factorization is a kind of Collaborative filtering method. The user-item interaction matrix is broken down into the product of two rectangular matrices with lower dimensions via the matrix factorization method.
Side information such as reviews and ratings has been used to help with recommendations. But the visual appearance of the items has been ignored before this work. VBPR~\cite{he2016vbpr} utilizes a pretrained deep CNN to get the visual feature then linearly transforms to visual space. Then the visual feature and id embedding are combined as the item representation and the representation is sent into Matrix Factorization to perform the preference prediction. AMR~\cite{tang2019adversarial} indicates the vulnerability of the current multimedia recommender system like VBPR and utilizes adversarial learning to build a more robust recommender system. VMCF~\cite{park2017also} constructs a product-affinity network with the nodes denoting products and the edges denoting the 'also-viewed' relations, which utilizes not only the appearance as side information but leverages the information hidden in the relations.
ConvMF~\cite{kim2016convolutional} would like to utilize the CNN architecture to capture the document information but the existing CNN method is used to solve the classification problem which is not suitable to do regression such as recommendation. This model then integrated probabilistic matrix factorization with CNN to do recommendations.
DVBPR~\cite{kang2017visually} incorporated the visual signals into the recommendation model, and it integrated the CNN module into the MF module that trains the image representation and recommendation model jointly to improve the performance. Additionally, by using this model, images that are similar to those in the training corpus could be produced. Given a user and category, this model with the Generative Adversarial Networks could generate a new item that is consistent with the user preference.
GraphCAR~\cite{xu2018graphcar} combines multimedia content with the traditional CF method. It first multiplies the user-item interaction matrix with the user attribute matrix or item feature matrix before using a two-layer graph convolutional network to generate the user and item latent representation. The preference score is then calculated using the inner product of the user and item latent vectors following a non-linear feature transformation.
\subsection{Deep Learning based Models}
\subsubsection{Multilayer Perceptron.}\hfill
A rich source of multimodal features could represent different aspects of user preference. In the JRL~\cite{zhang2017joint} framework, different sources of information have been projected into the unified space using MLP. Learning the weight to transfer multimodal features into user and item embedding. Meanwhile, the associated user and item representations have been learned using the feature reconstruction loss.
\subsubsection{Convolutional Neural Network.}\hfill
CNN is a kind of feedforward neural network with convolution layers and pooling operations to process the multimodal features. Most of the CNN-based recommender system utilizes CNN to extract features or learn the representation by capturing global and local features.
Due to the bag of words model's inherent limitations, it's hard to fully capture the document information. ConvMF~\cite{kim2016convolutional} utilizes CNN to capture the local features of an image or document and bridge PMF and CNN to utilize both the interaction and description information.
DeepCoNN~\cite{zheng2017joint} utilizes the pre-trained word embedding technique to extract the semantic representation of both user and items from the review text. Then feed the user and item semantic embeddings into two parallel CNN modules to learn the item properties and user representations. The top layer is used to let the hidden factors of the user and items interacted with each other and jointly learn the item properties and user behaviors.
DVBPR~\cite{kang2017visually} Utilize the Siamese CNN framework and the last layer of CNN is used as the item representation. Those fashion-aware image representations are trained with the recommendation system together in an end-to-end manner.
\subsubsection{Attention networks.}\hfill
The attention mechanism is motivated by human attention. The attention mechanism simulates that the user will pay different attention to different modalities or the different aspects of one modality, which could capture the user's preference and enrich the user representation.
The traditional collaborative filtering systems are not well designed for the multimodal recommendation that ignores leveraging the multimodal information. ACF~\cite{chen2017attentive} designs the item-level and component-level attention modules incorporating into traditional collaborative filtering models to do recommendations. The user's desire is typically represented by a fixed feature vector. However, different vectors for various items ought to better represent the user's preference. With a particular focus on diverse item characteristics, MAML~\cite{liu2019userdiverse} models user preferences for a variety of items. The retrieved text and visual features are first concatenated before being fed into the multilayer neural network. It introduces an attention neural network that utilizes the fusion of visual and text features, which can recognize users' varied preferences for various product attributes. DMRL~\cite{liu2022disentangled} also models the users' varied preferences but on the aspects of each modality. DMRL first utilizes a disentangled representation approach to learn the independent factors representation of several modalities. Based on this disentangled representation, it designs a weight-shared multimodal attention mechanism that could draw the user's attention to aspects of various modalities for factors. It may be possible to anticipate user preference for target items by combining such user and item representation with learned attention. DMR~\cite{wang2021multimodal} also learns the disentangled representations that could be capable to capture both complementary and common information from multi-modalities. Then it applies the disentangled representations to recommendation tasks.
The above micro-video recommendation works only consider the multimodal information of users but ignores the multimodal information of micro-video. UVCAN~\cite{liu2019user} learns the multimodal representation for both users and micro-video to do the personalized micro-video recommendation. unlike only concentrating on video attention, UVCAN utilizes the co-attention mechanism between items and micro-video to better jointly perform attention. A stacked attention network has been used to deal with the user profile and micro-video multimodal features, which considers the multimodal features as input queries and gets the video attention by multi-step reasoning. After learning the video representation, it will be leveraged as the input query to capture the user's attention through multi-step reasoning.
News representation is critical for news recommendation, most of the existing news recommendation models ignore the visual information of news but only consider the text information like titles. MM-Rec~\cite{wu2021mm} incorporates both modalities to learn news representation. First, it does object detection to get the region of interest (ROIs) from the image. Then the visiolinguistic model has been used to encode both text and image ROIs and the co-attention transformers have been used to learn the inherent cross-modal relations. It also introduces a cross-modal candidate-aware attention network that learns the relations between clicked news and candidate news to better capture user preference on candidate news.
The decision-making process is always ignored by researchers when they design the multimodal modeling module. IMRec~\cite{xun2021we} based on the fact that users pay more attention to the visual impression when they search for the news. It developed the local impression modeling module to extract significant clues from the impression image and bridged the gaps between semantics and impressions which enhance the news titles' semantic meaning. The global impression modeling module is used to fuse different cues without losing structural information. The experiment dataset makes use of the MIND dataset by adding screenshots of impression images.
\subsubsection{RNNs.}\hfill
The existing fashion recommendation works mainly utilize multimodal information to model the news representation, but they did not consider that users will focus on different regions of the image to do decisions. VECF~\cite{chen2019personalized} uses the VGG model to get the pre-segmented image regions first. Then it models the human sense and utilizes an attention mechanism over the image regions to capture user preference. Also, the user reviews information has been used as a weak supervision signal to capture better preference of users by using Vanilla LSTM to infuse the attentive image embedding into the word generation.
\subsubsection{Autoencoder.}\hfill
The collaborative filtering method is always hampered by the lack of user-item interactions. The rich side information has been used in the existing method to improve the recommendation system. CKE~\cite{zhang2016collaborative} investigates the way to utilize the collected heterogeneous information that has been gathered on the knowledge base. The network embedding procedure Bayesian TransR has been used to extract the structure knowledge embedding, Bayesian stacked denoising auto-encoder to extract the latent representation for text, and Bayesian stacked convolutional auto-encoder to extract the latent representation for the visual aspect. Then the collaborative joint learning procedure has been proposed.
\subsubsection{Variational Autoencoder.}\hfill
Classical methods express the user preference as a single vector in the latent space which would not express the meaning facets. ADDVAE~\cite{tran2022aligning} utilizes the disentangled representations to capture better user preference that is influenced by several hidden factors. it leverages the text content to learn the second disentangled representation, coupling disentangled factors from two MacridVAE networks through mutual information maximization and then using the attention mechanism to align the representations with each other, which could resolve the sparsity of user-item interactions and map the uninterpretable dimensions from representations to words.
The sparsity of user-item interactions and feature noises will affect the graph embedding-based method employed for the recommendation. MVGAE~\cite{yi2021multi} is a multimodal variational graph auto-encoder model which utilizes the modality-specific variational encoder to learn the node representation. The Gaussian variable has been used for each node, the mean vector conveys semantic meaning and the variance vector represents the noise level of each modality. The unique modality attributes weight have been combined using the experts' product (PoE), which is dependent on the noise level.
\subsubsection{Graph Neural Networks} \hfill
Graph Neural Networks have been demonstrated powerful to learn the representations for graph data in different areas~\cite{guo2021syntax,zhou2020graph,ding2021graph,liu2022m2gcn,zhou2022inductive}. It could be easily extended to the recommendation system by considering the user-item relations as a graph relation. Most data in recommendation could be represented by the graph structure in Fig.~\ref{graph structure}. The main idea of GNN is to aggregate the information from neighbor nodes and update the node representation during the propagation process. We roughly divided those GNN-based models according to the fusion step.
\begin{figure}[H]
\centering
\subfigure[user-item bipartite graph]{
\includegraphics[width=6cm]{u-i.pdf}
\label{u-i}
}
\quad
\subfigure[user co-occurrence graph]{
\includegraphics[width=6cm]{u-u.pdf}
\label{u-u}
}
\quad
\subfigure[item-item relation graph]{
\includegraphics[width=6cm]{i-i.pdf}
\label{i-i}
}
\quad
\subfigure[knowledge graph]{
\includegraphics[width=6cm]{kg.pdf}
\label{kg}
}
\caption{Graph structure in multimodal recommendation system}
\label{graph structure}
\end{figure}
\tb{Direct fusion.} Directly fuse multimodal embeddings extracted for each node. Use the multimodal feature as node representation then apply the Graph neural network techniques. Other models build the modality-specific graph to learn the representation for each modality, then fuse the output of GNN as the final representation.
PMGT~\cite{liu2021pre} is the pre-trained model that leverages the fused multimodal feature and interactions. For the extracted multimodal embeddings, an attention mechanism has been used here to obtain the multi-model representation. Then the multimodal representation adds position embedding and role-based embedding together as the initialized node embeddings. Then the pre-train and downstream task starts based on the node embeddings.
The recommendation built on a knowledge graph as Fig.~\ref{kg} shows, makes use of important outside knowledge to improve performance. However, they frequently disregard the different data types of multimodal features. MKGAT~\cite{sun2020multi} creates the multimodal knowledge graph using the entity-based approach. Different encoders are employed by the multimodal knowledge graph entity encoder to encode various data types, and the multimodal knowledge graph attention layer is used to aggregate neighbors' information. After each entity representation has been learned, the knowledge graph embedding will take them as input to learn the knowledge reasoning relation.
\tb{Heterogeneous graph fusion.} A heterogeneous graph is a kind of information network that contains different types of nodes. We consider the user and item as different types of nodes and the interactions between them as the edges as shown in Fig.~\ref{u-i}. Directly perform feature aggregation using GCN(MMGCN~\cite{wei2019mmgcn}, DualGNN~\cite{wang2021dualgnn}) or GAT(MGAT~\cite{tao2020mgat}) on the user-item bipartite graph as shown in Fig.~\ref{fig: step} for each modality.
\begin{figure}[H]
\centering
\includegraphics[width=14cm]{step.pdf}
\caption{The overall framework of GNN in user-item bipartite graph}
\label{fig: step}
\end{figure}
The previous multimodal recommendation works more focus on utilizing the multimodal information to represent items better but ignores the information interchanges between users and items. MMGCN~\cite{wei2019mmgcn} framework based on graph neural network to achieve message passing, and it builds the user-item bipartite graph for specific modalities. The information from the multi-hop neighbors could be used to better understand user preferences and create an improved user representation after the aggregate and combination processes have been completed.
MMGCN simply applies GNNs for the interaction graph and equally treats the neighbors to do information change. It would be influenced by redundant even noisy information. MGAT~\cite{tao2020mgat} based on the MMGCN framework utilizes the original GCN to do aggregation and the same way to combine the aggregated result. To manage the information transmission for each modality, it added a new gated attention mechanism. As a result, it could record intricate user interaction patterns and produce better user recommendations. DualGNN~\cite{wang2021dualgnn} also introduces a model preference learning module and draws the user's attention to various modalities. Also, the influence made by the modality missing could be improved by the learned multimodal fusion pattern.
The above GNN based-model like MMGCN merges isolated modal-specific graphs into a single one through operations such as concatenation, which is prone to underrate the interrelations among different modalities. EgoGCN~\cite{chen2022breaking} develops an effective graph fusion method Ego fusion to break the isolation. It constructed the modality-specific graphs the same as MMGCN but was not limited to propagating information in the unimodal graph by aggregating informative inter-modal messages of the neighbor nodes. The results of multimodal propagation and the ID embedding propagation are concatenated to be the final representations.
Utilizing the non-uniform datasets with roughly fuse single modality feature to multimodal feature will lead to the single modal bias. EliMRec~\cite{liu2022elimrec} indicates that the single modal bias could be eliminated by leveraging causal inference and counterfactual analysis. The causal effect (Total Effect, TE) of single modality information on the final result is caused by (Total Indirect Effect, TIE) via single modal $\rightarrow$ item representation $\rightarrow$ final result and (Natural Direct Effect, NDE) via single modal $\rightarrow$ final result. The single modal bias can be eliminated by subtracting NDE from TE. It follows the same structure of MMGCN but eliminates the single-modal bias.
Multimodal feature extraction (MFE) and user interest modeling (UIM) are the two main modules of multimodal recommendation. But existing works ignore the mismatching between them. MEGCF~\cite{liumegcf} Utilizes the user sentiment information and semantic entities which are much related to user behavior and preference can help to change from the content-oriented MFE to user-oriented. To solve the mismatch problem, after transforming to user-oriented MFE, it makes the association between MFE and UIM using the Separated framework. Graph Convolutional Network as the commonly used technique that can capture the high order correlation between nodes is used here, but the sentiment information has been added to weight neighbor aggregation that could enhance the graph convolution operations.
\tb{Homogeneous graph fusion.} A heterogeneous graph is a kind of information network that contains only one type of node and edge. The above GNN-based approach of micro-video recommendation only considers the relations between users and items but ignores the rich relations between the homogeneous data. Build homogeneous graphs by considering item-item relations(Lattice~\cite{zhang_mining_2021}) for each modality as Fig.~\ref{i-i} shows or considering the user co-occurrence frequency to build the graph as Fig.~\ref{u-u} shows, which helps to capture the relations between the same type of nodes.
The heterogeneous user-item interaction graph with multimodal information utilizes the historical interactions, but they ignore the semantic item-item relations which could better capture the item representation. LATTICE~\cite{zhang_mining_2021} utilizes the modality features in the modality-aware structure learning layer to learn item structures and then performs graph convolutions to learn better representation by the item affinities. Multimodal fusion introduces an attention mechanism that obtains the different importance of each modality and fuses the item embedding to get a powerful representation. Also, the self-supervised contrastive auxiliary task has been used to maximize the agreement between the item embedding of each modality and the fused multimodal representation. After learning the item representations, the existing collaborative filtering method will utilize them to get better performance. Not only the semantic item-item relations are used to build a homogeneous graph, but also the user co-occurrence time has been considered in DualGNN~\cite{wang2021dualgnn}. It builds on the user micro-video bipartite graph and user co-occurrence graph to draw the user's attention to various modalities. Also, the influence made by the modality missing could be improved by the learned multimodal fusion pattern. DRAGON~\cite{zhou2023enhancing} uses the user-item bipartite graph to learn the user-item relations. In addition, it utilizes item semantic graph and user co-occurrence graph to capture the internal relations among the two groups themselves. The dual representations for both users and items help to capture complementary information.
There is no recommendation system that considers the user's intent before. In order to direct the learning of user and item representations, HUIGN~\cite{wei2021hierarchical} tries to learn the multi-level user intents. It constructs two different types of information aggregation methods and a co-interacted item graph. The intra-level aggregation leverages the correlation between items and gets the representations that could convey the user intent to items. The inter-level aggregation models the relations between high-level and low-level user intents. The supernodes were established as coarser-grained user intents.
HGCL~\cite{cai2022heterogeneous} propose that most of the GNN techniques (\emph{e.g.},\xspace GCN~\cite{kipf2016semi}, GraphSage~\cite{hamilton2017inductive}, GAT~\cite{velivckovic2017graph}) are designed for the homogeneous graph but users and items in the recommendation system are the heterogeneous data. The performance of the present GNN-based recommendation systems will be impacted by their inability to accurately capture the heterogeneity of nodes in the user-item graph and their over-smoothing issue. In HGCL~\cite{cai2022heterogeneous}, the heterogeneous graph encoder network is used to acquire the heterogeneity in the user-item bipartite networks by utilizing the random surfing model to generate the specific node-type homogeneous graphs, then apply a GNN on the homogeneous graphs to learn the representations. Also, a graph contrastive learning framework also applies to the graph with specific node types by averaging the mutual information between global representation and local patch representation to learn an expressive representation of nodes.
The commonly used modality fusion method is to fuse the multimodal information into the id embedding to learn meaningful item representations. LATTICE begins to figure out that modality features could be used to construct the latent structure between items but not fuse the modality information into the user-item bipartite graphs. FREEDOM~\cite{zhou2022tale} finds that learning latent structure is inefficient and freezes the item-item graph before training could help to learn better item semantic relations. It also denoises the graph based on the calculated scores of the degree-sensitive edge pruning technique. HCGCN~\cite{mu2022learning} also follows the general process of LATTICE by constructing the item semantic graph and user-item interaction graph. It additionally introduces the co-clustering technique that learns the user and item representations in the same subgraph, which helps to capture the various user behavior patterns. The corresponding co-clustering and item-clustering losses have been used to enhance the user-item preference feedback and adjust the modality importance. A similar structure that utilizes features to construct a homogeneous graph is also mentioned in A2BM2GL~\cite{cai2022adaptive}. It leverages the similarity of multimodal contents to construct the feature graph to learn the semantic representation. Except for the semantic representation learning module, it constructs a collaborative representation learning module to learn the collaborative representation and an anti-bottleneck module that utilizes an attention mechanism to learn the importance weights of the short-range and long-range nodes. It updated the weighted regression loss to adaptive recommendation loss that could help to capture the varying intensity of users. LUDP~\cite{lei2022learning} indicates that the user preference is poorly learning using the current models that only enrich the item representation by multimodal features. So, it designed both the same item-item modal similarity graph to capture the potential item relations and the user preference graph to capture the user preference on different modalities.
\tb{Sampled subgraph fusion.} Sample a subgraph for each node. Group nodes based on modalities. HHFAN~\cite{cai2021heterogeneous} develops a heterogeneous graph that contains user, item and multimodal information. A random walk through the graph to sample neighbors according to the node type. It employs the FC layer to transform various types of node vectors into a single space and LSTM to aggregate embeddings of nodes of the same type for each set of nodes in the intra-type feature aggregation network. Then uses attribute-aware self-attention and neighbor-aware attention for different types of nodes in the inter-type feature aggregation network to create final representations that are better able to convey the structure and semantic information. HCGCN~\cite{mu2022learning} sample subgraph for the user-item interaction graph to divide users and items into groups, which helps to capture the various user behavior patterns for each group. HCGCN samples subgraph to capture the user behavior patterns, a similar method has been utilized by InvRL~\cite{du2022invariant}. It indicates the spurious correlation issue that the generic representation focus on the semantic meaning but not the factors that influence user preference. To alleviate the impact of spurious correlation, it sampled subgraphs to learn the invariant masks which divided the multimodal representation into invariant and variant representations. Based on the UltraGCN~\cite{mao2021ultragcn}, utilizing the invariant representations could eliminate the spurious correlation.
\tb{Use multimodal info to refine the graph structure.} The recommendation system extensively uses the user-item interaction graph to perform representation learning and information propagation. However, there are some false-positive edges exist which will influence the performance of the recommendation. GRCN~\cite{wei2020graph} works on identifying and cutting the noise edges to refine the structures of the user-item interaction graph. In the graph refine layer, a neighbor routing mechanism has been used to refine the prototypical network. The matching between user preference and the prototypical shows the probability to be the true-positive edge. According to the matching score, those edges will be corrupted. Then the graph convolutional layer and prediction layer will be used to do recommendations based on the refined user-item graph. LATTICE~\cite{zhang_mining_2021} builds a graph structure learning layer with modality-aware to learn item graph structures from multimodal information and combine multimodal graphs. By using graph convolutions, one item can acquire useful high-order affinities from its neighbors along the learned graph structures.
\subsubsection{Self-supervised learning}\hfill
The multimodal recommendation aims to learn suitable representations for each modality. They are mainly based on historical interactions and the multimodal side information to do supervised learning. The self-supervised learning techniques could also help to explore the underlying relations. SLMRec~\cite{tao2022self} learns the relationships by incorporating self-supervised learning into GNN-based recommendation models. This paper treats ID as a special modality with visual, textual and acoustic modalities. And it constructs the modality-specific graph the same as ~\cite{wei2019mmgcn,wang2021dualgnn,zhang_mining_2021}. Then the GNN techniques are used in the modality-specific graphs and get the modality representations. It considers each modality as a separate feature and utilizes the self-supervised learning tasks feature drop(FD), feature masking (FM) and feature fine and coarse spaces (FAC) to produce different views of items then uses contrastive learning to learn the underlying training signals.
BM3~\cite{zhou2022bootstrap} overcomes the computational cost and noise supervision signal issues by introducing self-supervised learning methods into the multimodal recommendation. First, it utilizes simple dropout techniques to generate different views from the item and user representations. Then three multimodal objectives were optimized to find better representations. Graph Reconstruction Loss is used to maximize the prediction of the item when giving the user by reconstructing the user-item interaction graph. The Inter-modality Feature Alignment Loss and the Intra-modality Feature Masked Loss were both used to align modality features. This model achieves better performance and also consumes fewer computational resources.
MMGCL~\cite{yi2022multi} introduces the self-supervised learning approaches based on graphs into the micro-video recommendation and it introduces a cutting-edge negative sampling method that demonstrates the relationship between modalities. Two data-augmented techniques have been used in this model: modality edge dropout and modality masking. Another technique used is to perturb one of the negative sample's modalities making just one modality difference between positive and negative samples. These methods combine to reveal the relationships between several modalities and ensure that each modality makes a meaningful contribution.
\subsubsection{Pretrain}\hfill
The pre-trained models have been proven useful in natural language and images. Side information like images and text has been used to enhance the effectiveness of the recommendation system. PMGT~\cite{liu2021pre} develops a pre-trained model which considers both the multimodal features and item relations to learn the item representation. An attention mechanism has been used to aggregate the multimodal features by weight and a graph structure has been constructed by the common user behaviors to represent the item relations. The two pre-train tasks are graph structure reconstruct and masked node feature reconstruction. It developed a mini-batch contextual neighbors sampling algorithm to sample negative and positive data which is used to handle large-scale graphs. After the Pre-train has been done, we could get the node representations and use them to initiate the item embeddings for the downstream tasks. In this paper, the recommendation task uses Neural Collaborative Filtering as the fundamental model. Training NCF and fine-tuning the item embeddings depending on the user-item interactions achieved the best accuracy compared with the other multimodal recommendation models.
The homogeneous graphs like the item graph and the user graph are proven helpful to learn the representation and improve the performance of recommendations. MMCPR~\cite{liu2022multi} pretrains on the homogeneous and heterogeneous graphs, aiming to learn better user and item representations that could capture user preference and item characteristics. To learn user and item representation, the user graph and item graph are built based on their co-interact relationships. For user representation, it considers two modalities: review text and user graph.
It uses LightGCN as the graph encoder to get the node representations in the user graph. Intra-modal aggregation is used for the texts of the reviews to get the aggregated review representations and inter-modal aggregation aggregates the two representations of modalities by attention mechanism. For item representation, it considers three modalities: text, image and item graph. The CLIP is used to extract the features. Because the image and text are describing the same item but from different aspects, the self-supervised contrastive inter-modal alignment (CIMA) task is used to align these two embeddings by maximizing the cos similarities between them. The intra-modal aggregation is the same as the user side to aggregate those three representations by attention mechanism to get the final item embeddings. Pre-train based on the Contrastive Inter-modal Alignment loss and user-item similarity loss to get the pre-trained embeddings. Then the LightGCN based on MixGCF is selected as the fine-tuning base model.
The multimodal features reflect both common knowledge and specific knowledge of the items. Recent simple fusion techniques combine both common and unique characteristics into a single vector representation. PAMD~\cite{han2022modality} seeks to understand both common and unique characteristics of objects. The modality characteristics are divided into common and particular representations using a disentangled encoder. Then contrastive learning performs cross-modality alignment to map the modality-common representations with primitive representations. Then it utilizes the transferred representations of primitive and specific-modality representations into optimization by measuring the gaps between them. After the pre-training stage, every item could get four representations. It uses the attention mechanism to fuse all the embeddings to get the final representations and adopts BPR as the downstream base model.
\begin{table}
\centering
\renewcommand\arraystretch{1.5}{
\begin{tabular}{m{9em}m{9em}m{19em}}
\toprule
Fusion Step & Fusion Method & Models \\
\hline
\multirow{2}{*}{Early Fusion} & Concatenate & VBPR\cite{he2016vbpr}, UVCAN\cite{liu2019user}, MAML\cite{liu2019userdiverse}\\
& Attention-based & VECF\cite{chen2019personalized}, PMGT\cite{liu2021pre}, LATTICE\cite{zhang_mining_2021}, FREEDOM~\cite{zhou2022tale}, HCGCN\cite{mu2022learning}, InvRL\cite{du2022invariant}, LUDP\cite{lei2022learning} \\
\hline
\hline
\multirow{4}{*}{Intermediate Fusion} & Concatenate & MMGCL\cite{yi2022multi} \\
& Attention-based & MMRec\cite{wu2021mm}, MKGAT\cite{sun2020multi}, DMRL\cite{liu2022disentangled} \\
& Product of Expert & MVGAE\cite{yi2021multi}\\
& Ego Fusion & EgoGCN\cite{chen2022breaking}\\
\hline
\hline
\multirow{3}{*}{Late Fusion} & Concatenation & MMGCN\cite{wei2019mmgcn}, GRCN\cite{wei2020graph}, SLMRec\cite{tao2022self}, JRL\cite{zhang2017joint}, EliMRec\cite{liu2022elimrec} \\
& Element-wise sum & MMGCN\cite{wei2019mmgcn}, SLMRec\cite{tao2022self}, A2BM2GL\cite{cai2022adaptive} \\
& Attention-based & DualGNN\cite{wang2021dualgnn}, MGAT\cite{tao2020mgat}, PAMD\cite{han2022modality}, MMCPR\cite{liu2022multi}, DRAGON~\cite{zhou2023enhancing}\\
\bottomrule
\end{tabular}}
\caption{Modality fusion}
\label{tab: fusion}
\end{table}
\section{Modality fusion}
For the multimodal recommendation system, modality fusion is an important research point. Finding an explainable and complementary fused multimodal representation can achieve significant enhancement. In technical terms, multimodal fusion is integrating the information from different modalities to get a single representation that could be used in different tasks like prediction and classification. The advantages of multimodal fusion are three points. Firstly, utilizing multimodal information could capture the universal pattern in each modality which could get a more robust representation based on the same pattern. Secondly, the multi-modality can capture complementary information which is not visible in the single modality. Lastly, the multi-modality fusion could handle the modality missing problem that could still operate with one modality missing. According to the timing of action in the pipeline, it could be roughly divided into early fusion, late fusion and intermediate fusion~\cite{baltruvsaitis2018multimodal}.
\begin{itemize}
\item Early fusion also names data-level fusion which means it fuses modality embeddings into a single feature representation and then inputs to the model. But this approach could not capture the complementary information of multi-modality and might include data redundancy. The early fusion approach is usually applied with some feature extraction methods (like PCA and autoencoder) to overcome the problem.
\item Late fusion also named decision-level fusion based on the prediction result or scores of each modality. The commonly used approaches are max-fusion, averaged-fusion, Bayes’rule based and ensemble learning. This kind of approach could learn complementary information and each modality is independent from others which will not lead to the addition of mistakes.
\item The intermediate fusion fuse the modality information after getting the high dimensional embeddings of each modality and then utilize the middle layer to do fusion. This kind of fusion depends on the model design.
\end{itemize}
According to the different fusion methods, we can divide it into element-wise sum, attention-based and concatenation. The element-wise sum and concatenation simply add or concatenate the modality representation, formally:
\begin{align}
\bm{u}&=\bm{u_v}+\bm{u_t}+\bm{u_a} & \bm{u}&=\bm{u_v}\parallel \bm{u_t}\parallel \bm{u_a}
\label{eq1}
\end{align}
The attention-based method is used to capture the different importance of each modality, and it could be applied to the basic fusion method like the element-wise sum:
\begin{equation}
\bm{u}=\sum_{m \in \left \{ v,t,a \right \} }^{} \alpha_m\bm{u_m}
\label{eq2}
\end{equation}
There exists some model designed their own way to fuse modalities like MVGAE~\cite{yi2021multi} adapt the Product of Expert module to distinguish modalities with multiple uncertainty levels that solve the issue of concatenation. And IMRec~\cite{xun2021we} does not fuse the modality information but encoded the impression image as a whole. We classify the models according to their modality fusion method as Table~\ref{tab: fusion} shows.
\section{Measurement and Optimization}
\subsection{Evaluation metrics}
Commonly used evaluation metrics for the recommendation system include accuracy, precision, recall, F1-score, hit rate, Normalized Discounted Cumulative Gain (NDCG) and Mean Average Precision (MAP). We consider the ground truth labels as positive and negative, within the predicted labels, there will be True Positive (TP), True Negative (TN), False positive (FP) and False Negative (FN). Accuracy represents the ratio of corrected predicted items over the total number of items:
\begin{equation}
Accuracy = \frac{TP+TN}{TP+TN+FP+FN}
\label{eq3}
\end{equation}
In a real situation, the positive and negative samples in datasets are unbalanced. Usually, the positive samples are less than 10\%, which means you can get an accuracy higher than 0.9 even if you predict all items as negative. We aim to measure the ability to predict positive items. Recall and Precision are used to represent the ratio of the truly predicted positive samples over the predicted positive and the ground truth positive. F1-score combines the result of recall and precision:
\begin{align}
Recall &= \frac{TP}{TP+FN} &
Precision &= \frac{TP}{TP+FP} &
F1-score &= \frac{2*precision*recall}{precision+recall}
\label{eq4}
\end{align}
The hit rate likes the name implies, represents the ratio of hit items in the predicted top-k list over the total items in the test set. If a user actually interacts with one of the top-k items we recommend, it is considered a hit.
\begin{equation}
HR = \frac{NumberOfHits@K}{Test}
\label{eq5}
\end{equation}
Precision and Recall do not consider ordering. The average precision (AP) is used to evaluate order-sensitive recommendation results for one user, and MAP is the average of $AP@K$ over all users:
\begin{align}
AP@K &= \frac{1}{\left | K \right | }\sum_{k=1}^{K} \frac{p_{k}\cdot rel(k)}{k} & MAP&=\frac{1}{\left | U \right | } \sum_{u \in U}^{} AP_u
\label{eq6}
\end{align}
Normalized Discounted Cumulative Gain (NDCG) is also a measure of rank quality. Cumulative Gain (CG) is the relevance score in a recommendation list, DCG fills the gaps that CG only utilizes the relevance score but did not consider the rank position. iDCG is the DCG of the ideal ordered recommendation list. NDCG is calculated by DCG over iDCG, formally:
\begin{align}
DCG&=\sum_{i=1}^{K} \frac{2^{relevance_i}-1 }{log_2(i+1)} & NDCG=\frac{DCG}{iDCG}
\label{eq7}
\end{align}
\begin{table}
\centering
\renewcommand\arraystretch{1.5}{
\begin{tabular}{m{9em}m{25em}}
\toprule
Method & Models \\
\hline
BPR & VBPR\cite{he2016vbpr}, ACF\cite{chen2017attentive}, MMGCN\cite{wei2019mmgcn}, DualGNN\cite{wang2021dualgnn}, GRCN\cite{wei2020graph}, MGAT\cite{tao2020mgat}, GraphCAR\cite{xu2018graphcar}, PAMD\cite{han2022modality}, MMGCL\cite{yi2022multi}, MKGAT\cite{sun2020multi}, MVGAE\cite{yi2021multi}, DVBPR\cite{kang2017visually}, LATTICE\cite{zhang_mining_2021}, FREEDOM~\cite{zhou2022tale}, DMRL\cite{liu2022disentangled}, HCGCN\cite{mu2022learning}, EgoGCN\cite{chen2022breaking}, EliMRec\cite{liu2022elimrec}, InvRL\cite{du2022invariant}, LUDP\cite{lei2022learning}, DRAGON~\cite{zhou2023enhancing} \\
\hline
Pairwise Loss & MAML\cite{liu2019userdiverse}\\
\hline
MSE Loss & VMCF\cite{park2017also}\\
\hline
Cross Entropy Loss & UVCAN\cite{liu2019user}, MMRec\cite{wu2021mm}, MMCPR\cite{liu2022multi}, IMRec\cite{xun2021we}\\
\hline
Contrastive Loss & PAMD\cite{han2022modality}, MMCPR\cite{liu2022multi}. MMGCL\cite{yi2022multi}, BM3\cite{zhou2022bootstrap}, SLMRec\cite{tao2022self}\\
\hline
Reconstruction Loss & PMGT\cite{liu2021pre}, BM3\cite{zhou2022bootstrap} \\
\hline
Self-designed Loss&A2BM2GL\cite{cai2022adaptive}\\
\bottomrule
\end{tabular}}
\caption{Loss Function}
\label{tab: loss}
\end{table}
\subsection{Objective Functions}
Typical losses include mean square loss (MSE), pairwise loss, cross-entropy loss, and Bayesian Personalized Ranking (BPR) loss. When it comes to the top-k suggestion, the final two loss functions are typically utilized but MSE and pairwise loss are used less. MSE is always used for rating prediction.
\begin{equation}
MSE=\sqrt{\frac{1}{m}\sum_{i=1}^{m}(h(\bm{x^i})-\bm{y^i})^2} \\
\label{eq8}
\end{equation}
Basic pairwise loss is not usually used but some updated version exists. The Weighted ApproximateRank Pairwise (WARP)~\cite{weston2010large} updated the basic pairwise loss by considering the ranking that penalizes a positive item at a lower rank much more heavily than the one at the top.
While BPR~\cite{rendle2012bpr} approaches the top-k task as a ranking problem, encouraging the ranking of positive things above negative ones for the given user, Cross entropy loss approaches the top-k task as a classification challenge and make the target user u and the target item i as similar as possible. BPR loss is more suitable for the top-k recommendation and most of the models are applying this loss to do optimization like ~\cite{wei2019mmgcn,wang2021dualgnn,zhang_mining_2021,chen2019personalized}.
\begin{align}
\mathcal{L}_{bpr}&=\sum_{(u,i,i')\in \mathcal{R}}^{} -ln\mu (\bm{u}^T\bm{i}-\bm{u}^T\bm{i'}) \\ \mathcal{L}_{CE}&=-\sum_{(u,i)\in \mathcal{R}}^{}y_{ui}\cdot log(\bm{u}^T\bm{i})+(1-y_{ui})\cdot log(1-\bm{u}^T\bm{i})
\end{align}
As the pretrain and finetune were introduced into Multimodal recommendation, the pretrain task loss has been used to get a better representation result. \cite{liu2021pre} utilizes the edge reconstruction loss and the node feature reconstruction loss to do optimization. Recently, contrastive loss has also been introduced into recommendation as the self-supervised learning method has been applied in this area. Contrastive loss aims to increase the similarity between similar items but make the item representation different from the other items. And the InfoNCE loss is the variant that considers the problem as a multi-class classification~\cite{tao2022self, yi2022multi}. BM3~\cite{zhou2022bootstrap} doesn't need to do negative sampling and designs different views to get the contrastive loss by calculating the similarities between views.
\begin{equation}
\mathcal{L}_{CL}=\frac{\bm{u}^T\bm{i}}{\left \| \bm{u} \right \|_2\left \| \bm{i} \right \|_2 }
\end{equation}
SLMRec~\cite{tao2022self} has designed the contrastive loss for both self-supervised tasks and the recommendation task.
\begin{equation}
\mathcal{L}_{InfoNCE}=-log\frac{exp(\bm{u}^T\bm{i}/\tau )}{ {\textstyle \sum_{i' \in N_u}^{}exp(\bm{u}^T\bm{i'}/\tau)} }
\end{equation}
We have classified the models according to the objective function they used as Table~\ref{tab: loss} shows.
\section{Datasets and Experiments}
\subsection{Experimental Datasets}
Some commonly used datasets are huge with a large number of users, items and interactions like, Kwai and Tiktok, and some of the datasets are not available to the public. Here we use the publicly available and most commonly used Amazon dataset and one of the Food datasets collected from a website as our experimental dataset. We conduct the experiment on the four main categories baby, sports, electronics and food. The statistics of these four datasets are summarized in Table~\ref{tab: dataset}.
Same as the previous works~\cite{wei2020graph,wei2019mmgcn,zhang_mining_2021,zhou2022bootstrap}, we do the 5-core setting for all the amazon datasets, the 10-core setting for the food dataset and split them into training, validation, and testing sets with a ratio of 8:1:1. It should be mentioned that the split is based on randomly selecting train and test samples for each user according to the ratio. In the following experiments, we will discuss different ways to split train, test and validation sets such as based on the user time or global time.
The metadata of the amazon datasets contains the text description and the URL of images that could be used as textual and visual modalities. For the collected Food dataset, the recipe and ingredients are used as the text modality, the food images are the visual modality. We used the pre-trained sentence-transformers~\cite{reimers2019sentence} to extract the text features with 384 dimensions and follows~\cite{zhang_mining_2021} to use the published 4096-dimensional visual features. After getting the textual and visual embeddings, we consider the user ratings as a positive interaction and then construct the user-item graph based on the review ratings.
\begin{table}
\caption{Statistics of the datasets.}
\small
\centering
\begin{tabular}{ l |c c c |r }
\hline
Dataset & \# Users & \# Items & \# Interactions & Sparsity \\
\hline
Baby & 19,445 & 7,050 & 160,792 & 99.8827\% \\
sports & 35,598 & 18,357 & 296,337 & 99.9547\% \\
FoodRec & 61,668 & 21,874 & 1,654,456 & 99.8774\%\\
Elec & 192,403& 63,001 & 1,689,188 & 99.9861\% \\
\hline
\end{tabular}
\label{tab: dataset}
\end{table}
\subsection{Baseline models}
We provide a framework for the readers to run their datasets using baseline models or implement their own models based on the framework. The framework is implemented by Pytorch and the input format is simple with textural embedding, visual embedding and the interaction graph. The following models except ADDVAE~\cite{tran2022aligning} are already implemented in our framework and the experiments are conducted to compare their recommendation performance. note that BPR and LightGCN are not using multimodal information but only use historical user-item interactions. The ADDVAE model is not implemented in our framework because it utilizes the text feature in a different input format produced by the TF-IDF extraction method. We have implemented ADDVAE separately and run it with the same train-test splitting sets and text raw feature with different extraction methods. Here we just include them as the baselines of multimodal recommendation performance.
\begin{itemize}
\item BPR~\cite{rendle2012bpr}
utilizes the historical user-item interactions to model user and item representations as the latent factor. Predicting user's preference based on the similarity between the representations. This model introduces the mainly used loss function BPR loss.
\item LightGCN~\cite{he2020lightgcn}
is a graph-based model designed by simplifying the Graph Convolution Network (GCN)~\cite{kipf2016semi} which improves the performance and also the efficiency of recommendation.
\item VBPR~\cite{he2016vbpr}
is the first model that considers the visual features in the recommendation. It integrated the visual embedding into item representations. To be fair, we concatenate both vision and text features as the multimodal feature when we learn the representations. The BPR loss is used here to learn the user preference.
\item MMGCN~\cite{wei2019mmgcn}
learns the modality-specific preference by constructing the modal-specific graphs for each modality. And utilize those user-item graphs to learn the representations in each modality. Then aggregates all the modality-specific representations to get the final user and item embeddings.
\item DuaGNN~\cite{wang2021dualgnn}
introduces a new user-user co-occurrence graph that utilizes the representations learned from modality-specific graphs and fuses the neighbor's representations.
\item GRCN~\cite{wei2020graph}
utilizes the same user-item graphs as previous GCN-based models generated. It identifies the false-positive edges in the graph and cut off the edges then the new representations would be generated by performing aggregation and information propagation in the refined graph.
\item LATTICE~\cite{zhang_mining_2021}
introduces a new item-item graph for each modality and gets the latent item graphs by aggregating all the modalities. Both the item-item graph and user-item graph utilize the graph convolution operations to get out the final user and item representations.
\item BM3~\cite{zhou2022bootstrap}
introduces a new self-supervised learning method to help reduce the cost of computational resources and the issue of wrong supervision signals. It utilizes the simple dropout technique to generate contrastive views and use three contrastive loss functions to optimize the result representations.
\item SLMRec~\cite{tao2022self}
utilizes the self-supervised learning techniques in the Graph Neural network based model to learn the underlying relations. The SSL tasks supplement the supervised tasks to uncover the hidden signals from the data itself. The FD, FM and FAC self-supervised data augmentation operations have been performed here and then the contrastive loss is used to optimize.
\item ADDVAE~\cite{tran2022aligning}
utilizes the MacridVAE network with mutual information maximization to get two disentangled representations from user-item interactions and the text content of users. Then utilizing the attention mechanism to align the disentangled representations.
\item FREEDOM~\cite{zhou2022tale}
utilizes the item-item graph for each modality established the same as LATTICE but freezes the graphs before training, and introduces the degree-sensitive edge pruning techniques to denoise the user-item interaction graph.
\end{itemize}
\subsection{Experimental Results}
In this section, we first analyze the performances of all implemented algorithms on the four datasets (Section 7.3.1). We then discuss the performance of different types of data split strategies (Section 7.3.2). Finally, we evaluate the effectiveness of multimodal representation learning by utilizing different modality information(Section 7.3.3). We adopt the widely-used metrics to evaluate the performance of preference ranking: Recall@k and NDCG@k. By default, we set k = 10,20,50 and report the averaged metrics for all users in the testing set.
\subsubsection{Recommendation performance comparison using different models.}\hfill
Table~\ref{tab: performance} reports the performance comparison results, from which we could observe the following and know how to choose the suitable models:
\begin{itemize}
\item The content-aware methods overall achieve better performance than the CF-based methods(\emph{e.g.},\xspace BPR, LightGCN), which indicates the multimodal features always provide richer information about the items and help the recommendation model to reach higher accuracy. Although the recommendation accuracy of VBPR which build based on the BPR has improved a lot. The MMGCN~\cite{wei2019mmgcn} always shows worse performance than LightGCN which does not utilize the multimodal information. It is because of the unreasonable design as LightGCN~\cite{he2020lightgcn} indicated that much noise will influence the performance. MMGCN is the earlier model designed for the multimodal recommendation, At that time the LightGCN technique is not published, but for DualGNN~\cite{wang2021dualgnn}, it adopted the advantage of LightGCN to learn the modality user-item bipartite graph and achieves better performance.
Additionally, the existing content-aware methods largely depend on the representatives of the multimodal features which will cause fluctuating performances among different datasets.\\
\item Specifically, FREEDOM~\cite{zhou2022tale} achieves the best performance on the baby and sports datasets but gets lower ranks for the food and electronic datasets, which are huge graphs with around 1.7 million interactions. FREEDOM works well on a small graph but it is not suitable for a large graph. ADDVAE always ranks highly except for the FoodRec dataset, which might be because the FoodRec dataset is extracted from the website and the text features for this dataset are messing and the information could hard to be utilized. For the food dataset, there's only a small difference between those models. The performance of SLMRec always depends on the dataset and this model has a long time parameter searching process. LATTICE and BM3 perform stably for the experimental datasets and the performance ranks higher than the CF-based methods and the earlier developed multimodal models like MMGCN and VBPR.\\
\item The size of the graph and the resource consumed will also influence the choice of algorithms. LATTICE builds an item graph and the model needs many resources to run, which could not be applied to a large graph although it performs well for most datasets. FREEDOM~\cite{zhou2022tale} could achieve high accuracy for the small dataset but the performance applied to large graphs is not the best. It needs fewer computing resources than LATTICE but achieves higher performance. SLMRec could apply to different sizes of graphs but has a long time parameter searching process. We could simplify the search process by reducing the parameters that have been found insensitive by analyzing the results of many datasets. BM3 works well for all sizes of datasets and could achieve the upper rank of performance with fewer resources consumed.
\end{itemize}
\begin{table}[htp]
\caption{Performance by different models in terms of Recall and NDCG, Best results are in \textbf{boldface} and the second best is \underline{underlined}.}
\small
\centering
\renewcommand\arraystretch{1.1}{
\begin{tabular}{cccccccc}
\hline
Dataset & Model & Recall@10 & Recall@20 & Recall@50 & NDCG@10 & NDCG@20 & NDCG@50\\
\hline
\multirow{11}*{Baby} & BPR & 0.0357 & 0.0575 & 0.1054 & 0.0192 & 0.0249 & 0.0345\\
\cline{2-8}
& LightGCN & 0.0479 & 0.0754 & 0.1333 & 0.0257 & 0.0328 & 0.0445 \\
\cline{2-8}
& VBPR & 0.0423 & 0.0663 & 0.1212 & 0.0223 & 0.0284 & 0.0396 \\
\cline{2-8}
& MMGCN & 0.0378 & 0.0615 & 0.1100 & 0.0200 & 0.0261 & 0.0359 \\
\cline{2-8}
& DualGNN & 0.0448 & 0.0716 & 0.1288 & 0.0240 & 0.0309 & 0.0424 \\
\cline{2-8}
& GRCN & 0.0539 & 0.0833 & 0.1464 & 0.0288 & 0.0363 & 0.0490 \\
\cline{2-8}
& LATTICE & 0.0547 & 0.0850 & 0.1477 & 0.0292 & 0.0370 & 0.0497\\
\cline{2-8}
& BM3 & 0.0564 & 0.0883 & 0.1477 & 0.0301 & 0.0383 & 0.0502 \\
\cline{2-8}
& SLMRec & 0.0529 & 0.0775 & 0.1252 & 0.0290 & 0.0353 & 0.0450\\
\cline{2-8}
& ADDVAE & \underline{0.0598} & \underline{0.091} & \underline{0.1508} & \underline{0.0323} & \underline{0.0404} & \underline{0.0525} \\
\cline{2-8}
& FREEDOM & \textbf{0.0627} & \textbf{0.0992} & \textbf{0.1655} & \textbf{0.0330} & \textbf{0.0424} & \textbf{0.0558} \\
\hline
\multirow{11}*{Sports} & BPR & 0.0432 & 0.0653 & 0.1083 & 0.0241 & 0.0298 & 0.0385 \\
\cline{2-8}
& LightGCN & 0.0569 & 0.0864 & 0.1414 & 0.0311 & 0.0387 & 0.0498 \\
\cline{2-8}
& VBPR & 0.0558 & 0.0856 & 0.1391 & 0.0307 & 0.0384 & 0.0492 \\
\cline{2-8}
& MMGCN & 0.0370 & 0.0605 & 0.1078 & 0.0193 & 0.0254 & 0.0350 \\
\cline{2-8}
& DualGNN & 0.0568 & 0.0859 & 0.1392 & 0.0310 & 0.0385 & 0.0493 \\
\cline{2-8}
& GRCN & 0.0598 & 0.0915 & 0.1509 & 0.0332 & 0.0414 & 0.0535 \\
\cline{2-8}
& LATTICE & 0.0620 & 0.0953 & 0.1561 & 0.0335 & 0.0421 & 0.0544\\
\cline{2-8}
& BM3 & 0.0656 & 0.0980 & 0.1581 & 0.0355 & 0.0438 & 0.0561\\
\cline{2-8}
& SLMRec & 0.0663 & 0.0990 & 0.1543 & 0.0365 & 0.0450 & 0.0562\\
\cline{2-8}
& ADDVAE & \underline{0.0709} & \underline{0.1035} & \underline{0.1663} & \textbf{0.0389} & \underline{0.0473} & \underline{0.0600} \\
\cline{2-8}
& FREEDOM & \textbf{0.0717} & \textbf{0.1089} & \textbf{0.1768} & \underline{0.0385} & \textbf{0.0481} & \textbf{0.0618} \\
\hline
\multirow{11}*{FoodRec} & BPR & 0.0303 & 0.0511 & 0.0948 & 0.0188 & 0.0250 & 0.0356 \\
\cline{2-8}
& LightGCN & 0.0331 & 0.0546 & 0.1003 & 0.0210 & 0.0274 & 0.0386 \\
\cline{2-8}
& VBPR & 0.0306 & 0.0516 & 0.0972 & 0.0191 & 0.0254 & 0.0365 \\
\cline{2-8}
& MMGCN & 0.0307 & 0.0510 & 0.0943 & 0.0192 & 0.0253 & 0.0359 \\
\cline{2-8}
& DualGNN & \underline{0.0338} & 0.0559 & \underline{0.1027} & \underline{0.0214} & \underline{0.0280} & \underline{0.0394} \\
\cline{2-8}
& GRCN & \textbf{0.0356} & \textbf{0.0578} & \textbf{0.1063} & \textbf{0.0226} & \textbf{0.0295} & \textbf{0.0411} \\
\cline{2-8}
& LATTICE & 0.0336 & \underline{0.0560} & 0.1012 & 0.0211 & 0.0277 & 0.0388\\
\cline{2-8}
& BM3 & 0.0334 & 0.0553 & 0.0994 & 0.0208 & 0.0274 & 0.0381\\
\cline{2-8}
& SLMRec & 0.0323 & 0.0515 & 0.0907 & 0.0208 & 0.0266 & 0.0362\\
\cline{2-8}
& ADDVAE & 0.0309 & 0.0508 & 0.093 & 0.0186 & 0.0247 & 0.035 \\
\cline{2-8}
& FREEDOM & 0.0333 & 0.0556 & 0.1009 & 0.0212 & 0.0279 & 0.0389 \\
\hline
\multirow{11}*{Elec} & BPR & 0.0235 & 0.0367 & 0.0621 & 0.0127 & 0.0161 & 0.0212 \\
\cline{2-8}
& LightGCN & 0.0363 & 0.0540 & 0.0879 & 0.0204 & 0.0250 & 0.0318 \\
\cline{2-8}
& VBPR & 0.0293 & 0.0458 & 0.0778 & 0.0159 & 0.0202 & 0.0267 \\
\cline{2-8}
& MMGCN & 0.0213 & 0.0343 & 0.0610 & 0.0112 & 0.0146 & 0.0200 \\
\cline{2-8}
& DualGNN & 0.0365 & 0.0542 & 0.0875 & 0.0206 & 0.0252 & 0.0319 \\
\cline{2-8}
& GRCN & 0.0389 & 0.0590 & 0.0970 & 0.0216 & 0.0268 & 0.0345 \\
\cline{2-8}
& LATTICE & - & - & - & - & - & -\\
\cline{2-8}
& BM3 & 0.0437 & 0.0648 & 0.1021 & 0.0247 & 0.0302 & 0.0378\\
\cline{2-8}
& SLMRec & \underline{0.0443} & \underline{0.0651} & \underline{0.1038} & \underline{0.0249} & \underline{0.0303} & \underline{0.0382}\\
\cline{2-8}
& ADDVAE & \textbf{0.0451} & \textbf{0.0665} & \textbf{0.1066} & \textbf{0.0253} & \textbf{0.0308} & \textbf{0.0390} \\
\cline{2-8}
& FREEDOM & 0.0396 & 0.0601 & 0.0998 & 0.0220 & 0.0273 & 0.0353 \\
\hline
\end{tabular}}
\label{tab: performance}
\end{table}
\subsubsection{Recommendation performance comparison using different data split methods.}\hfill
The offline evaluation is based on the historical item ratings or the implicit item feedback. As this method relies on the user-item interactions and the models are all learning based on the supervised signals, we need to split the interactions into train, validation and test sets. There are three main split strategies that we applied to compare the performance:
\begin{itemize}
\item Random split:\\
As the name suggested, this split strategy randomly selects the train and test boundary for each user. Previously the Leave One Last Item strategy only select the last interaction as the test, but random splitting selects to split the interactions according to the ratio. The disadvantage of the random splitting strategy is that they are not capable to reproduce unless the authors publish how the data split and this is not a realistic scenario without considering the time.
\item User time split:\\
The temporal split strategy splits the historical interactions based on the interaction timestamp by the ratio (e.g. train:validation:test=8:1:1). It split the last percentage of interactions the user made as the test set. VAECF~\cite{liang2018variational}, SVAE~\cite{sachdeva2019sequential} and NGCF~\cite{wang2019neural} are evaluated under this strategy. Although it considers the timestamp, it is still not a realistic scenario because it is still split the train/test sets among all the interactions one user made but did not consider the global time.
\item Global time split:\\
The global time splitting strategy fixed the time point shared by all users according to the splitting ratio. The interactions after the last time point are split as the test set. Additionally, the users of the interactions after the global temporal boundary must be in the training set, which follows the most realistic and strict settings. The limitation of this strategy is that the number of users will be reduced due to deleting the users not existing in the training set.
\end{itemize}
\begin{table}
\caption{Performance by different data split in terms of Recall and NDCG}
\small
\centering
\begin{tabular}{ cccccccc}
\hline
\multirow{2}*{Dataset} & \multirow{2}*{Model} & random&user time&global time & random&user time&global time\\
\cline{3-8}
~&~&\multicolumn{3}{c}{Recall@10}&\multicolumn{3}{c}{Recall@20}\\
\hline
\multirow{10}*{sports} & MMGCN & 0.0384 & 0.0266 & 0.0140 & 0.0611 & 0.0446 & 0.0245 \\
\cline{2-8}
& BPR & 0.0444 & 0.0322 & 0.0152 & 0.0663 & 0.0509 & 0.0258 \\
\cline{2-8}
& VBPR & 0.0563 & 0.0385 & 0.0176 & 0.0851 & 0.0620 & 0.0298 \\
\cline{2-8}
& DualGNN & 0.0576 & 0.0403 & 0.0181 & 0.0859 & 0.0611 & 0.0297 \\
\cline{2-8}
& GRCN & 0.0604 & 0.0418 & 0.0167 & 0.0915 & 0.0666 & 0.0286 \\
\cline{2-8}
& LightGCN & 0.0568 & 0.0405 & 0.0205 & 0.0863 & 0.0663 & 0.0336 \\
\cline{2-8}
& LATTICE & 0.0641 & 0.0450& 0.0207 & 0.0964 & 0.0699 & 0.0337\\
\cline{2-8}
& BM3 & 0.0646 & 0.0447 & 0.0213 & 0.0955 & 0.0724 & 0.0336 \\
\cline{2-8}
& SLMRec & 0.0651 & 0.0470 & 0.0220 & 0.0985 & 0.0733 & 0.0350\\
\cline{2-8}
& FREEDOM & 0.0708 & 0.0490 & 0.0226 & 0.1080 & 0.0782 & 0.0372 \\
\hline
\multirow{2}*{Dataset} & \multirow{2}*{Model} & \multicolumn{3}{c}{\multirow{2}*{NDCG@10}}& \multicolumn{3}{c}{\multirow{2}*{NDCG@20}}\\
~&~&\multicolumn{3}{c}{~}&\multicolumn{3}{c}{~}\\
\hline
\multirow{10}*{sports}& MMGCN & 0.0202 & 0.0134 & 0.0091 & 0.0261 & 0.0180 & 0.0125 \\
\cline{2-8}
& BPR & 0.0245 & 0.0169 & 0.0102 & 0.0302 & 0.0218 & 0.0135 \\
\cline{2-8}
& VBPR & 0.0304 & 0.0204 & 0.0115 & 0.0378 & 0.0265 & 0.0153 \\
\cline{2-8}
& DualGNN & 0.0321 & 0.0214 & 0.0118 & 0.0394 & 0.0268 & 0.0155 \\
\cline{2-8}
& GRCN & 0.0332 & 0.0219 & 0.0101 & 0.0412 & 0.0282 & 0.0138 \\
\cline{2-8}
& LightGCN & 0.0315 & 0.0220 & 0.0139 & 0.0391 & 0.0286 & 0.0180 \\
\cline{2-8}
& LATTICE & 0.0351 & 0.0238 & 0.0138 & 0.0434 & 0.0302 & 0.0177\\
\cline{2-8}
& BM3 & 0.0356 & 0.0237 & 0.0144 & 0.0436 & 0.0308 & 0.0182 \\
\cline{2-8}
& SLMRec & 0.0364 & 0.0253 & 0.0148 & 0.0450 & 0.0321 & 0.0189\\
\cline{2-8}
& FREEDOM & 0.0388 & 0.0255 & 0.0151 & 0.0485 & 0.0330 & 0.0197 \\
\hline
\end{tabular}
\label{tab: data split}
\end{table}
In order to do a recommendation performance comparison using different data split methods, we did some simple experiments of different data split strategies on the Sports dataset. Table~\ref{tab: data split} shows the performance comparison results in the terms of Recall@k and NDCG@k where k=10,20. And Table~\ref{tab: data split rank} shows the performance ranking of models based on Recall@20 and NDCG@20.
We would like to figure out what impact the data split strategy will make on the state-of-the-art models. Hence we compare the performances of 10 SOTA models on the Sports dataset by applying three data split strategies: Random split, user time split and global time split. As Table~\ref{tab: data split} demonstrates that the models will get different performance numbers by using different data splitting strategies even with the same dataset and evaluation metrics. It is problematic to compare the performance of different models design with different data split strategies and the models are not comparable.
Table~\ref{tab: data split rank} reports the ranks of the 10 SOTA models under different splitting strategies. The rows are sorted by the performance of models under the random splitting strategy, with the up and down arrows indicating the relative rank position swaps compared with random splitting. As we can see, the ranking swaps are observed between the models under different splitting strategies. For example, the GRCN~\cite{wei2020graph} will rank four positions lower under the global time splitting than the random splitting with the performance of BPR, VBPR and LightGCN exceeding. For our experiments, it shows the performance rank of the most effective models and the weakest models will not be influenced, only the rank of middle-performance models has changed under different splitting strategies. Additionally, the time-based splitting will lead to cold start issues of the recommendation systems considered to be solved by leveraging multimodal information. As the performance ranks show, the overall performance of content-based models outperforms the CF-based models over all splitting strategies. However, we get one opposite discovery that there is a rough pattern for the swaps occurred: the CF-based models will be more probably to enhance the ranks under temporal evaluation but some of the content-based models (\emph{e.g.},\xspace DualGNN and GRCN) will get lower rank. We guess the reason might be that some of the content-based models did not correctly utilize the multimodal features, which does not help to solve the cold start issue but becomes noise information when facing the cold start issue.
Most of the multimodal recommender systems use the random splitting strategy, less models use user time splitting and global time splitting. However, the temporal settings are closer to the realistic scenario because the recommender system could not get future data as training data. The robust recommender system should perform stable over all splitting strategies. The behaviors of models depend on how the representations are learned and how the instance has been selected. Hence, we could conclude that the data splitting strategy is the key factor that influences the performance of models and the models for different situations need to choose suitable splitting strategies. However, we only get some superficial inspiration from the simple experiments and we only run 10 models on the sports dataset. If you are interested in the impact of different splitting, you can apply more models with more datasets to find the underlying issues.
\begin{table}[h]
\caption{Performance Rank of Sports Dataset}
\renewcommand\arraystretch{1.2}{
\begin{minipage}{0.45\linewidth}
\centering
\scalebox{0.65}{
\begin{tabular}{cccc}
\hline
\multirow{2}*{Model} & \multicolumn{3}{c}{Sports,NDCG@20} \\
\cline{2-4} & random split & User time split & Global time split\\
\hline
MMGCN & 10 &10&10\\
\hline
BPR & 9 & 9 & 8$\uparrow$1\\
\hline
VBPR&8 &8&7 $\uparrow$1\\
\hline
LightGCN&7 &5$\uparrow$2&4 $\uparrow$3\\
\hline
DualGNN& 6&7$\downarrow$1&6\\
\hline
GRCN &5 &6$\downarrow$1&9 $\downarrow$4\\
\hline
LATTICE& 4 &4 &5$\downarrow$1\\
\hline
BM3&3&3&3\\
\hline
SLMRec&2&2&2\\
\hline
FREEDOM&1&1&1\\
\hline
\end{tabular}}
\end{minipage}
\begin{minipage}{0.45\linewidth}
\centering
\scalebox{0.65}{
\begin{tabular}{cccc}
\hline
\multirow{2}*{Model} & \multicolumn{3}{c}{Sports,Recall@20} \\
\cline{2-4} & random split & User time split & Global time split\\
\hline
MMGCN & 10&10&10\\
\hline
BPR & 9 & 9 & 9\\
\hline
VBPR&8&7 $\uparrow$1&6 $\uparrow$2 \\
\hline
DualGNN&7&8 $\downarrow$1& 7\\
\hline
LightGCN&6&6&5$\uparrow$1\\
\hline
GRCN&5&5 &8$\downarrow$3\\
\hline
BM3&4&3 $\uparrow$1&4\\
\hline
LATTICE&3&4 $\downarrow$1& 3\\
\hline
SLMRec&2&2&2\\
\hline
FREEDOM&1&1&1\\
\hline
\end{tabular}}
\end{minipage}
\label{tab: data split rank}
}
\end{table}
\subsubsection{Recommendation performance comparison using Different Modalities}\hfill
Multimodal information has been introduced to the recommendation system which helps to alleviate the cold-start problem. Some models utilize the modality information as the side information to enrich the item representations, and some leverage it with the interaction information to enhance the user representation or capture the user preference.
We are interested in how the modality information benefits the recommendation, and which modality contributes more. We would like to figure out the influence of each modality and provide guidelines for researchers on selecting the modality information utilized.
We evaluate how the multimodal information influences the recommendation performance of the SOTA models by feeding the single modality information, and compare the performance between using both modalities and the single modality. Table~\ref{tab: text and vision feature recall} shows our experimental results of different modalities. The bold is the best performance of the specific model by feeding other modalities. We draw Fig.~\ref{Modality performance} based on Recall@20 to show the summary and tendency of other modalities which could intuitively show the different influences of modalities on different models. The orange circle represents the performance of multi-modality, the green one represents the performance of textual modality and the blue circle is for visual modality.
\begin{figure}
\centering
\subfigure[Baby]{
\includegraphics[width=2.6in]{modality-baby.pdf}
}
\subfigure[Sports]{
\includegraphics[width=2.6in]{modality-sports.pdf}
}
\caption{Performance comparison of modalities}
\label{Modality performance}
\end{figure}
We first experiment on the baby and sports datasets. As the result shows, only GRCN~\cite{wei2020graph} with multimodal features outperforms those with a single textual or visual feature over all datasets. For other models, utilizing the single modality information might achieve better performance than fusing the modalities, which indicates that simply fusing the modalities representation by sum, weighted sum and concatenate is not useful to learn the item representation. The simple fusion will destroy the modality-specific information and modality preference learned from each modality. Especially for DualGNN~\cite{wang2021dualgnn}, the textual and visual single modality achieves much better performance than the fusion of modalities, which indicates that the fusion method used influences the quality of representation learned.
Also, we find that the representations are more closely related to the textual modality. The textual modality performance is better or close to the multimodal performance as Fig.~\ref{Modality performance} shows. We are thinking if the dataset influences the result and if those datasets we test are more concentrated on the textual modality. Then we try the Clothing dataset where the visual features are more important, but the result still indicates the importance of textual modality.
For the fusion problem, we need to find out suitable methods which could fuse the multimodal representations with keeping the modality-specific information and capturing the complementary information that a single modality does not contain. The desired result is that the multimodal representations outperform the single modal representations. For the issue that textual modality has better or closely equal performance with the multi-modality, the first reason is the fusion method influences the quality of representations, the second reason might be that the high dimensional visual embedding through an MLP layer to the latent space will compress the data and miss some modality-specific property. Additionally, we found some ablation studies of the baseline models also contain the performance comparison of multi-modality and single-modality~\cite{wei2019mmgcn,wang2021dualgnn} and the multi-modality outperforms single-modality, but the dataset is not published. So the last reason might be because different datasets concentrate on different modalities. The micro video dataset more concentrates on visual modality and it contains more visual modality information to help learn meaningful representations.
\begin{table}
\caption{Performance by different features in terms of Recall}
\small
\centering
\setlength{\tabcolsep}{2.7mm}{
\begin{tabular}{cccccccc}
\hline
\multirow{2}*{Dataset} & \multirow{2}*{Model} & Both&Textual& Visual&Both&Textual&Visual\\
\cline{3-8}
~&~&\multicolumn{3}{c}{Recall@10}&\multicolumn{3}{c}{Recall@20}\\
\hline
\multirow{8}*{Baby} & VBPR & 0.0423 & 0.0400 & \textbf{0.0428} & 0.0663 & 0.0638 & \textbf{0.0665}\\
\cline{2-8}
& MMGCN & 0.0378 & 0.0365 & \textbf{0.0384} & 0.0615 & 0.0623 & \textbf{0.0634} \\
\cline{2-8}
& DualGNN & 0.0448 & \textbf{0.0612} & 0.0511 & 0.0716 & \textbf{0.0943} & 0.0830 \\
\cline{2-8}
& GRCN & \textbf{0.0539} & 0.0517 & 0.0488 & \textbf{0.0833} & 0.0800 & 0.0767 \\
\cline{2-8}
& LATTICE & \textbf{0.0547} & 0.0546 & 0.0492 & 0.0850 & \textbf{0.0874} & 0.0781\\
\cline{2-8}
& BM3 & 0.0564 & \textbf{0.0571} & 0.0544 & \textbf{0.0883} & 0.0858 & 0.0841 \\
\cline{2-8}
& ADDVAE & - & 0.0598 & - & - & 0.091 & - \\
\cline{2-8}
& FREEDOM & \textbf{0.0627} & 0.0622 & 0.0501 & \textbf{0.0992} & 0.0980 & 0.0816 \\
\hline
\multirow{8}*{Sports} & VBPR & \textbf{0.0558} & 0.0472 & \textbf{0.0558} & \textbf{0.0856} & 0.0709 & 0.0847\\
\cline{2-8}
& MMGCN & 0.0370 & \textbf{0.0401} & 0.0358 & 0.0605 & \textbf{0.0633} & 0.0561 \\
\cline{2-8}
& DualGNN & 0.0568 & \textbf{0.0697} & 0.0615 & 0.0859 & \textbf{0.1060} & 0.0926 \\
\cline{2-8}
& GRCN & \textbf{0.0598} & 0.0545 & 0.0495 & \textbf{0.0915} & 0.0850 & 0.0782 \\
\cline{2-8}
& LATTICE & 0.0620 & \textbf{0.0625} & 0.0572 & 0.0953 & \textbf{0.0971} & 0.0887\\
\cline{2-8}
& BM3 & \textbf{0.0656} & 0.0652 & 0.0649 & 0.0980 & \textbf{0.0983} & 0.0982 \\
\cline{2-8}
& ADDVAE & - & 0.0709 & - & - & 0.1035 & - \\
\cline{2-8}
& FREEDOM & 0.0717 & \textbf{0.0725} & 0.0589 & 0.1089 & \textbf{0.1092} & 0.0899\\
\hline
\multirow{7}*{Clothing} & VBPR & 0.0281 & \textbf{0.0328} & 0.0283 & 0.0415 & \textbf{0.0506} & 0.0416\\
\cline{2-8}
& MMGCN & \textbf{0.0218} & 0.0211 & 0.0203 & \textbf{0.0345} & 0.0342 & 0.0328 \\
\cline{2-8}
& DualGNN & 0.0454 & \textbf{0.0524} & 0.0420 & 0.0683 & \textbf{0.0798} & 0.0636 \\
\cline{2-8}
& GRCN & \textbf{0.0424} & 0.0392 & 0.0351 & \textbf{0.0662} & 0.0612 & 0.0542 \\
\cline{2-8}
& LATTICE & 0.0492 & \textbf{0.0521} & 0.0408 & 0.0733 & \textbf{0.0749} & 0.0614\\
\cline{2-8}
& BM3 & 0.0422 & 0.0413 & \textbf{0.0423} & 0.0621 & 0.0613 & \textbf{0.0626} \\
\cline{2-8}
& FREEDOM & \textbf{0.0629} & 0.0625 & 0.0420 & \textbf{0.0941} & 0.0921 & 0.0640 \\
\hline
\multirow{2}*{Dataset} & \multirow{2}*{Model} & \multicolumn{3}{c}{\multirow{2}*{NDCG@10}}& \multicolumn{3}{c}{\multirow{2}*{NDCG@20}}\\
~&~&\multicolumn{3}{c}{~}&\multicolumn{3}{c}{~}\\
\hline
\multirow{8}*{Baby} & VBPR & 0.0223 & 0.0213 & \textbf{0.0230} & 0.0284 & 0.0275 & \textbf{0.0290}\\
\cline{2-8}
& MMGCN & \textbf{0.0200} & 0.0189 & 0.0197 & \textbf{0.0261} & 0.0256 & 0.0261 \\
\cline{2-8}
& DualGNN & 0.0240 & \textbf{0.0331} & 0.0278 & 0.0309 & \textbf{0.0417} & 0.0360 \\
\cline{2-8}
& GRCN & \textbf{0.0288} & 0.0269 & 0.0258 & \textbf{0.0363} & 0.0342 & 0.0330 \\
\cline{2-8}
& LATTICE & \textbf{0.0292} & 0.0287 & 0.0265 & 0.0370 & \textbf{0.0371} & 0.0339\\
\cline{2-8}
& BM3 & 0.0301 & \textbf{0.0303} & 0.0290 & \textbf{0.0383} & 0.0377 & 0.0367 \\
\cline{2-8}
& ADDVAE & - & 0.0323 & - & - & 0.0404 & - \\
\cline{2-8}
& FREEDOM & \textbf{0.0330} & 0.0325 & 0.0274 & \textbf{0.0424} & 0.0417 & 0.0355 \\
\hline
\multirow{8}*{Sports} & VBPR & \textbf{0.0307} & 0.0256 & 0.0306 & \textbf{0.0384} & 0.0317 & 0.0380\\
\cline{2-8}
& MMGCN & 0.0193 & \textbf{0.0212} & 0.0193 & 0.0254 & \textbf{0.0272} & 0.0245 \\
\cline{2-8}
& DualGNN & 0.0310 & \textbf{0.0379} & 0.0335 & 0.0385 & \textbf{0.0473} & 0.0415 \\
\cline{2-8}
& GRCN & \textbf{0.0332} & 0.0289 & 0.0258 & \textbf{0.0414} & 0.0368 & 0.0332 \\
\cline{2-8}
& LATTICE & 0.0335 & \textbf{0.0336} & 0.0312 & 0.0421 & \textbf{0.0425} & 0.0393\\
\cline{2-8}
& BM3 & \textbf{0.0355} & 0.0352 & 0.0352 & \textbf{0.0438} & 0.0437 & \textbf{0.0438} \\
\cline{2-8}
& ADDVAE & - & 0.0389 & - & - & 0.0473 & - \\
\cline{2-8}
& FREEDOM & 0.0385 & \textbf{0.0387} & 0.0318 & 0.0481 & \textbf{0.0482} & 0.0397 \\
\hline
\multirow{7}*{Clothing} & VBPR & 0.0158 & \textbf{0.0173} & 0.0159 & 0.0192 & \textbf{0.0218} & 0.0193\\
\cline{2-8}
& MMGCN & \textbf{0.0110} & 0.0109 & 0.0107 & \textbf{0.0142} & 0.0142 & 0.0139 \\
\cline{2-8}
& DualGNN & 0.0241 & \textbf{0.0281} & 0.0229 & 0.0299 & \textbf{0.0351} & 0.0283 \\
\cline{2-8}
& GRCN & \textbf{0.0223} & 0.0204 & 0.0178 & \textbf{0.0283} & 0.0260 & 0.0226 \\
\cline{2-8}
& LATTICE & 0.0268 & \textbf{0.0290} & 0.0221 & 0.0330 & \textbf{0.0348} & 0.0273\\
\cline{2-8}
& BM3 & 0.0231 & 0.0225 & \textbf{0.0235} & 0.0281 & 0.0276 &\textbf{ 0.0286} \\
\cline{2-8}
& FREEDOM & \textbf{0.0341} & 0.0336 & 0.0227 & \textbf{0.0420} & 0.0411 & 0.0283 \\
\hline
\end{tabular}
}
\label{tab: text and vision feature recall}
\end{table}
\section{Challenges and Future Research Directions}
Leveraging the multimodal information in the recommender system is highly related to realistic application. The utilization of multimodal content is widespread in recent years to recommend products or related items on e-commerce and social platforms.
In this survey, we have reviewed and classified the most recent and popular used models in the multimodal recommendation area. Particularly, we have introduced a taxonomy of the multimodal recommendation systems by classifying the models according to the techniques they utilized to leverage the multi-modality information that benefits the Recommendation. Additionally, we have introduced the process of multimodal recommendation and listed the common techniques used to do feature extraction, modality fusion and evaluation. Furthermore, we have built a common framework that could help the new researchers easily run the baseline models and know how the recommendation model is designed. The readers could also utilize this framework to easier develop their own models and compare them with baselines.
During the review and our research process, we find some challenges and possible future research directions.
\subsection{How to effectively fuse multimodal information?}
As the modality information proved to be helpful for the recommendation, how to design the models to better utilized the multi-modality becomes the research challenge. Correctly utilizing multimodal features could improve the performance but use wrongly will make it noisy information. As our experiments show above, the performance of the recommendation system could be improved by utilizing the modality information, but for some models, the single modality will also achieve good performance even higher than utilizing the multimodal information together. We guess for those models, the fusion of multi-modalities causes this issue. Each modality may capture different aspects of the items, we should find a way to fuse them together with keeping the modality-specific information, to learn a multimodal representation containing complementary information that a single modal representation could not include. If the models could fuse the multi-modality features efficiently, the recommendation accuracy should be higher than utilizing the single modality.
Additionally, the modality missing issue is common in the real world. However, some models assume that all modality information is available during training and inference, which will not work when facing the incomplete and missing modality. LRMM~\cite{wang2018lrmm} mitigates the modality missing and cold-start issues by utilizing the generative model to reconstruct the modality-specific embedding and impute the missing modality.
Future research directions should be studied on how to efficiently utilize the multimodal features: (1) Find out the efficient modality fusion method that can capture complementary information that a single modality can not contain. (2) How to solve the modality missing issue and reconstruct the meaningful representation.
\subsection{How to standardize the data splitting strategy and the general dataset used?}
Several data splitting strategies are applied during the train/test sets splitting process. As the previous experiments show, the models will get different performance numbers by using different data splitting strategies even with the same dataset and evaluation metrics, the ranks of model performances will also be influenced by different splitting strategies. Although the most commonly used is random splitting, temporal-based splitting is closer to the realistic scenario. The robust multimodal recommender models should perform well either with random splitting or time splitting.
The datasets used for multimodal recommendations are not standardized and most of the datasets used in the reviewed papers are not publically available like Kwai, Tiktok and DianPing. Although works on the same public datasets, the setting of datasets is not standardized. Someone would like to do the 5-core setting but others might do the 10-core, which makes the preprocessing of the datasets different. The feature extract techniques will also influence the final representation learned but every paper use different techniques as we showed before.
In future work, we should find out the best preprocessing method with suitable extract techniques and suitable splitting strategies to standardize the experiments' train/test sets.
\subsection{Evaluation metrics}
The evaluation of the recommendation model is an important research topic. The recommender system should not only consider the accuracy but also the other recommendation qualities such as the recommendation list's diversity and the presence of unique items, which may have a significant influence on a recommender system's overall quality~\cite{kaminskas2016diversity}. Additionally, \cite{ge2018evaluation} indicates that the evaluation from the general recommendation might not be totally adopted for the multimodal recommendation. The effectiveness should not just consider accuracy but also the user experience and fairness.
\subsection{Research and application gap}
The multimodal recommendation is not only researched by academic researchers but also by the industrial community. The data used, the information available and even the application scenario are different between them.
Additionally, the increasing data volume is a big challenge in true-world situations. The scalability and time complexity are critical considerations for choosing models in the industrial community. Industrial research is in a more realistic setting as we said before. Some settings for academic research should be standardized and more practical to develop models suitable for industrial scenarios. The desired recommendation systems should be robust and easily applied to realistic scenarios. More future works should be studied on how to efficiently recommend: (1) Balance the model complexity and scalability when facing large datasets (2) the computation efficiency for high-dimensional tensor and multimodal information.
\subsection{Multimodal sequential recommendation}
A sequential recommendation system is different from the recommendation systems that use collaborative filtering and content-based filtering, as it attempts to understand and model the sequential behaviors of the users over time. The multimodal information could greatly influence the user's preference, however, most of the existing sequential recommendation models ignore such useful information. MML~\cite{pan2022multimodal} incorporates the multimodal side information of items to improve and stabilize the meta-learning process and help to solve the cold-start issue. Therefore, leveraging multimodal information in sequential recommendation systems would be an important direction for future work.
\subsection{Cross domain recommendation}
The cross-domain recommendation system leverage behavior information from other domains or platforms to improve the performance of the target domain. The commonly used technique relies on explicit overlapping data (\emph{e.g.},\xspace common users and items) to transfer data across domains. Recently, some works learn the universal representations for users and items that could be applied to the cross-domain recommendation. UniSRec~\cite{hou2022towards} leverages the text information to learn the universal item representations without requiring the common users and items, which could apply to different domains. In the future, leveraging the multimodal information might be able to help models learn the universal representations.
\section{Conclusion}
In this survey, we provide an extensive review on multimodal recommendation systems. We proposed a clear pipeline for MMRec and list out the commonly used techniques in each step. We classify the models by the learning approaches used for organizing and clustering existing publications. We also make experiments on four commonly used datasets to evaluate the performance of models and provide a common framework for users to easier run the models and develop their models. Additionally, we detail some pressing challenges and promising future research directions. There are a large number of new developed techniques each year, we hope our survey provided a helpful and detailed overview for the researchers, the framework provided an easy and efficient way to run models, and encourage future progress.
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2023-02-10T02:07:49', 'yymm': '2302', 'arxiv_id': '2302.04473', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04473'} | arxiv |
\section{Introduction}
\label{sec:intro}
The explosive growth of edge devices can constantly generate massive useful and learnable data and bring about tangible benefits for various end users, i.e., user verification~\cite{face, lip}, self-driving~\cite{drive}, human activity recognition~\cite{human}, medical health monitoring~\cite{health}, and so on.
However, the data resources are usually geographically distributed across different edge devices, this is then challenging to training a deep model collaboratively on both privacy preservation and transmission overhead reduction.
Worse still, the `isolated data islands' could be seriously heterogeneous in terms of data distribution, quality, and quantity.
Therefore,
how to efficiently excavate the rich knowledge hidden behind these distributed data and train an accurate cooperative model in a privacy-protection way has become a crucial research topic.\par
To address the above challenges,
the federated learning (FL) has emerged as a promising paradigm of privacy-preserving distributed machine learning framework~\cite{FedAvg,tang2022personalized}. FL enables edge device to train a model locally based on its own dataset and communicates with other models in the server for aggregating a more generalized global model, without collecting and sharing any privacy-sensitive information from users.
However, existing FL methods mostly use a unified global model for all participants and ignore the potential hardware and data heterogeneities between them, i.e., diverse hardware specifications, different network conditions, highly biased data, and inconsistent data qualities. \par
In recent years, there have been some works focusing on eliminating the FL heterogeneity and obtained some promising results~\cite{1,2,3,4}.
However, most of them suffer from sub-optimization in both model performance and training efficiency, for only addressing the above problems in a single dimensional perspective, i.e., data heterogeneity.
Such a scheme may have three limitations: 1) the computation and transmission stragglers among different clients usually lead to extremely low training efficiency;
2) the communication overhead of exchanging the updates of full models may cause excessive transmission delays, especially for large deep neural networks;
and 3) the heterogeneities can lead to biased training across clients and introduce significant performance unfairness.
\iffalse
\begin{figure*}[ht]
\centering
\includegraphics[width=0.8\textwidth]{fig1.jpg}
\caption{Illustrations of three main heterogeneous challenges in federated learning scenarios}
\label{fig1}
\end{figure*}
\fi
In this paper, we propose a novel Multidimensional Customized Federated Learning (CFL) system to achieve a fairer and more efficient FL.
The main idea of CFL is to strengthen the identity between the FL participants by minimizing the impact of multi-dimensional heterogeneities on FL.
Specifically, a specially designed data-quality aware model with a tiny reinforcement learning (RL) module is regarded as the common model in CFL.
Then, CFL tailors a personalized model from the common one for each client according to the corresponding device's hardware specification and data condition.
The model tailoring is achieved by an online trained model-search helper which can output the sub-model, i.e., network sub-structure, with the best accuracy and less latency for the current client.
Moreover, to better aggregate information from asymmetric personalized models,
we propose a novel parameter aggregation algorithm
via module scaling and alignment in each FL round.
Therefore, the personalized models can be sampled dynamically from the common model with the data-aware RL module, and be trained further in a FL paradigm with the new scaling aggregation method.
Extensive experiments on CIFAR-10 and MNIST datasets (processed as mixed quality) demonstrate that the proposed CFL can achieve better task accuracy, fairer model performance, and higher training acceleration against representative FL methods.
\begin{itemize}
\item We propose a new FL paradigm that tailors customized sub-models for heterogeneous edge workers, which obviously reduces the time differences of local training on different devices and greatly speeds up the federated training stage.
\item We design a novel search helper to select customized models for different workers and a new model aggregation algorithm to aggregate updates with different architectures. Both proposals enable the using of FL in essentially heterogeneous edge computing.
\item We improve the parent model to be data quality-aware by adding an RL module and training it on special process datasets with different data qualities. It turns out that data quality-aware FL models perform better on real-world applications in edge computing scenarios than traditional FL paradigms.
\end{itemize}
\begin{figure*}[!ht]
\centering
\includegraphics[width = 0.9\textwidth]{OverallExecutionGraph.png}
\caption{The overview of the CFL. The server part consists of three main components, i.e., the online accuracy predictor, the latency lookup table, and the expansion module, which work jointly to sample the optimal sub-model for each client and update the global model. The blue lines on the parent model represent additional RL gating modules.}
\label{fig1}
\end{figure*}
\section{Related Works}\label{Section:RelatedWork}
Recently, a mainstream direction in edge computing is model compression, so in this section, we will introduce some related work on model compression and show the difference between using model compression and CFL in edge computing. As a prerequisite, we also introduce traditional federated learning. Finally, as the main problem to be solved when using FL in edge computing, the heterogeneity in edge computing is briefly explained at the end.
\subsection{Model Compression}
Model compression has been extensively studied to reduce the computation overhead and memory usage, so that neural models can be better deployed on resource-limited edge devices \cite{DC, wang2021survey}. It is essential to do a trade-off between the compressed rate and the accuracy reduction. Current popular methods include pruning \cite{Han2015Learning}~\cite{Anwar2015Structured}~\cite{Rueda2017Neuron}, quantization~\cite{Li2017Performance}, parameter sharing~\cite{Chen2015Compressing}, knowledge distillation, low-rank approximation and direct design of compact models, etc. Besides, another similar method named Neural Architecture Search (NAS) is also widely considered to explore a suitable lightweight model for resource-limited devices. NAS usually deploys a well-trained model on the server as the parent, and trains a neural network \cite{ofa20} or RL agent \cite{Mnasnet} to help to choose proper sub-models from the parent model to adapt dynamic runtime resources on distributed platforms. We compare our work with several mainstream related works including standard FL \cite{FedAvg}, MT-FL \cite{MTL} and Model compression. The details are shown in Table~\ref{table1}.
\begin{table*}[htbp]
\renewcommand{\arraystretch}{1.5}
\caption{Comparison of some works related to edge computing}
\label{table1}
\centering
\begin{tabular}{|p{1.6cm}<{\centering}|p{1.2cm}<{\centering}|p{0.6cm}<{\centering}|p{5cm}<{\centering}|p{1.2cm}<{\centering}|p{0.6cm}<{\centering}|p{3.5cm}<{\centering}|}
\hline
\textbf{Methods} & \multicolumn{3}{c|}{\textbf{Heterogeneous in training}} & \multicolumn{3}{c|}{\textbf{Heterogeneous in inference}} \\ \cline{2-7}
\multicolumn{1}{|l|}{} & \textbf{Device} & \textbf{Data} & \textbf{Idea} & \textbf{Device} & \textbf{Data} & \textbf{Idea} \\ \hline
Standard FL & N & N & All clients train the same model & N & N & All clients use the same trained model \\ \hline
\multirow{2}{*}{MT-FL } & \multirow{2}{*}{N} & \multirow{2}{*}{Y} & Same structure for collaboration & \multirow{2}{*}{N} & \multirow{2}{*}{Y} & \multicolumn{1}{l|}{\multirow{2}{*}{Each client uses its specific model}} \\ \cline{4-4}
& & & Different parameters for data heterogeneity & & & \multicolumn{1}{l|}{} \\ \hline
Model compression & N & N & Training a large model in cloud & Y & N & \multicolumn{1}{p{3.5cm}|}{Compress the large model into a small model} \\ \hline
\multirow{2}{*}{CFL (ours)} & \multirow{2}{*}{Y} & \multirow{2}{*}{Y} & Different structures for both types of heterogeneity & \multirow{2}{*}{Y} & \multirow{2}{*}{Y} & \multirow{2}{*}{Each client uses its specific model} \\ \cline{4-4}
& & & The same parameters for collaboration & & & \\ \hline
\end{tabular}
\end{table*}
\subsection{Federated Learning}
Applying big data analysis and artificial intelligence (AI) in practical scenarios is not easy since high-quality datasets are rare or difficult to access. To deal with the data island problem and utilize the distributed data from different mobile devices, Google has proposed federated learning (FL) ~\cite{FL1,FedAvg} in 2016 to train machine learning models over decentralized devices. Such a paradigm aims to mine distributed datasets without sharing privacy-sensitive data, and thus is deemed to greatly help launch AI in more areas. FL requires a set of workers to cooperate with the coordinator server, who assigns the model parameters to each worker to train the local model, and collects the updated parameters to accumulate to the shared model repeatedly. Current focuses of FL research include user privacy preservation \cite{privacy}, incentive scheme to promote collaboration between multiple users \cite{incentive}, communication overhead \cite{commu} and fairness optimization ~\cite{fair}.
\subsection{Heterogeneity in Data and Devices}
Data heterogeneity here is defined as "the datasets from different devices are often statistically deficient (non-IID), e.g., of different label distribution, dataset size and sample noise level, etc". Device heterogeneity refers to the fact that different devices participating in FL tasks are highly likely to possess quite different levels of hardware specification and environmental conditions, e.g., different CPU spec, memory size, and network bandwidth. Heterogeneity in distributed scenarios leads to inevitable waiting latency for parameter aggregation as well as the variance of model accuracy among different devices. Lots of works have been proposed to deal with such problems. For example, the vertical FL is proposed to deal with feature heterogeneity \cite{survey}.
Several approaches to personalized federated learning \cite{pfl1,pfl2,pfl3} have been proposed to address the heterogeneity problem in FL. Most mainstream work can be divided into two categories \cite{pfltan} including global model personalization and learning personalization models. Gloabal model personalization aims to train a shared more powerful global FL model, and then conduct additional training on local data to achieve the purpose of personalization. Such methods mainly focus on the training ability of the first-stage global FL model on non-IID data. For example, Zhao et al. \cite{pflzhao} used the method of data enhancement to reduce the statistical heterogeneity between customer data sets and strengthen the training of the whole play model by sharing some balanced global data among drifting clients. Another personalization FL strategy focuses on setting up a personalized model structure for each client. For example, Li et al. \cite{pflli} proposed the FedMD method to train a global model with the assistance of a public dataset and allow each client to fine-tune with its own private dataset through knowledge distillation to obtain a personalized model. However, most of the above methods only consider the heterogeneity of data distribution between clients during training for personalized design, ignoring the common heterogeneous problems such as hardware and data quality. \cite{MTL} takes into account both device heterogeneity and data distribution heterogeneity, but also ignores the heterogeneity of data quality between clients during training, as well as the data heterogeneity during training and reasoning. Although very difficult, CFL incorporates the diverse heterogeneity in all the above-mentioned edge environments into the consideration of federated learning.
\section{Methodology}
\label{sec:Methodology}
\subsection{An Overview of CFL}\label{Subsection:Overview}
The pipeline of CFL is illustrated in Figure.~\ref{fig1}. Specifically, CFL can be divided into the interwoven local training and global updating process that follows a three-part paradigm: \textbf{sub-models sampling} (on server), \textbf{local training} (on client), and \textbf{model updating} (on server).
First, in the sub-models sampling stage, the server samples a personalized network sub-structure for each FL worker according to its hardware specification and data quality, wherein the hardware specification is defined by the device model, and the data quality is quantized to five different quality levels according to the Gaussian Blur.
To be specific, the sub-models are first sampled from the global (parent) model using ``Genetic Algorithm'' on both model depth and width dimensions.
After that, the selected sub-model will be further filtered through a search helper composed of an online-trained accuracy predictor and an offline latency lookup table~\cite{ofa20}.
Next, the sampled sub-models are assigned to different clients and be trained with heterogeneous local datasets separately. At the last epoch of local training, the test accuracy of each sub-model is collected as the training profile, which is then be uploaded along with the model gradients.\par
Last, there are two model updating process parallelly conducted in the server.
The first update is about the \textbf{global model}, which aggregates all the uploaded local updates from clients by the specially designed aggregation algorithm.
The second update is about the \textbf{accuracy predictor}, which judges the accuracy that the current sub-model can achieve based on the hardware and data conditions reported by each client. \par
\subsection{Personalized Models For Device Heterogeneity}\label{Subsection:Customized sub-models}
In this subsection, we mainly focus on problems introduced by device heterogeneity in traditional federated learning during the training stage. Specifically, there are two main problems. The first comes from the selection of customized sub-models, one of the filters of which needs an accurate and less training overhead accuracy predictor. And another challenge would be the above-mentioned sub-models aggregation. These two issues are respectively discussed in the following two subsections below.
\subsubsection{Sub-models Sampling}\label{Subsubsection:Customization}
The sub-model sampling process is based on two sequential steps, including sub-model searching and filtering. To be specific, sub-models are firstly randomly generated using genetic algorithms in a two-dimensional-limited search space. The details can be found in Algorithm \ref{alg1}.
\begin{algorithm}[htbp]
\caption{Sub-models Selection}
\label{alg1}
\begin{algorithmic}
\STATE {\bfseries Input:} Accuracy predictor $f_{t}$, computational latency table $g$, parent model $\omega_t$, search times $S$, computational latency bound $l_{k}$, hardware profile $p_{k}$, data quality $q_{k}$, number of workers $K$
\STATE {\bfseries Output:} Customized models $\omega_{k}^t$ for each worker $k$
\STATE Initialize $acc_k=0, \forall\ k=1,\ldots,K$;
\FOR{$i=0, ..., S$}
\FOR{$k=0, \ldots ,K$}
\STATE Select a sub-model $\omega$ from $\omega_t$ with the bounded latency on worker $k$ as $g(\omega, p_{k})<l_{k}$;
\IF{$f_{t}(\omega,q_{k})>acc_k$}
\STATE $acc_k = f_{t}(\omega, q_{k})$;
\STATE $\omega_{k}^t=\omega$;
\ENDIF
\ENDFOR
\ENDFOR
\end{algorithmic}
\end{algorithm}
After that, these generating results will be further filtered through a search helper composed of an online-trained accuracy predictor and an offline latency lookup table~\cite{ofa20}.
Wherein, the accuracy predictor is essentially a four-layers linear classifier and is dynamically trained in the first several FL rounds. %
Its training datasets are the above-mentioned training profiles, which are formed by using the sub-model structure information and data quality as the data sample, and the test accuracy as the data label.
Since the accuracy predictor is a simple linear classifier and the number of clients in FL is large, the data samples and labels collected from one or two CFL rounds would be sufficient enough to let the accuracy predictor converge or reach a satisfying prediction accuracy. Once the training of the accuracy predictor starts to converge, or its test accuracy reaches a predefined threshold, its training can be stopped to stabilize sub-models as well as reduce overhead.
In subsequent rounds, the predicted accuracy, together with the latency table, are used for the selection process. A complete training process in one CFL round of the accuracy predictor is shown in Algorithm~\ref{alg3}.
\begin{algorithm}[!t]
\caption{Training Accuracy Predictor}
\label{alg3}
\begin{algorithmic}
\STATE {\bfseries Input:} The accuracy predictor $f$
\STATE {\bfseries Output:} $f$ in each FL round
\FOR{$t=1$ to $T$}
\FOR{$k=1$ to $K$}
\STATE Collect $q_{k}$, $\omega_{k}^t$, $acc_{k}^t$ from the worker $k$;
\STATE Construct sample $x_k=(q_{k}, \omega_{k}^t)$, $y_k=acc_{k}^t$;
\ENDFOR
\STATE Use all $K$ samples $(x,y)$ to update the accuracy predictor $f_t$ for one epoch;
\ENDFOR
\end{algorithmic}
\end{algorithm}
\subsubsection{Sub-models Aggregation}\label{Subsubsection:Aggregation}
To solve the challenges of the aggregation of structurally misaligned personalized sub-models, we proposed a novel aggregation algorithm that expands and aligns all sub-models before the actual aggregation. Same with model sampling, the expanding of sub-models is also limited in depth and width dimension. The details are as follows.
\iffalse
\begin{figure}[tp]
\centering
\subfigure[Layer group in the parent model with residual architecture.]{
\includegraphics[width=0.44\textwidth]{fig3.jpg}
}\\
\subfigure[Layer group in a customized sub-model during aggregation.]{
\includegraphics[width=0.4\textwidth]{group.jpg}
}
\caption{(a) illustrates the vanilla group setting on parent model with residual architecture, where a group represents a set of convolutional layers with some of the same properties, i.e, a residual block in ResNet. And b shows the layer grouping in a customized models before and after aggregation of CFL respectively.}
\label{group}
\end{figure}
\fi
\begin{figure}[htbp]
\centering
\includegraphics[width = 0.4\textwidth]{depth.jpg}
\caption{Depth expansion of sub-model.}
\label{depth}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[width = 0.45\textwidth]{width.jpg}
\caption{Width expansion of customized models. The left rectangle represents the width of layers in the global model. The right rectangle represents the width of the layers in the sub-models.}
\label{width}
\end{figure}
\begin{itemize}
\item Layer group: Since a residual model architecture is used in the parent model, different parameter settings and activation functions are used in different residual blocks. Before the actual model depth and layer width alignment, a layer grouping process is necessary to maintain the same parameter distribution as the parent model before and after expanding operation. Specifically, all the convolution layers except the first one of sub-models are divided into different groups according to the residual settings of the server model to achieve a group-level alignment.
\item Width expansion: Since the channels of each layer of the sub-models are randomly selected from the parent model according to the limitations of the accuracy predictor and latency lookup table. In the vanilla FL aggregation stage, it is the parameters of the channels at the same location in different sub-models participate in one operation. To face the challenge of the disordered channels of various sub-models that are scrambled during the sampling process, as shown in Fig.~\ref{width}, all channels in the sub-models are first sorted in the original order to keep the consistency of the parent model structure. And then, after the sorting process, an expansion operation is performed for each layer of the sub-models, if its current layer width is smaller than the width of the large model, all $0$ channels will be added to fill the current layer to its original width in the parent model. Thus far, all sub-models have achieved width alignment.
\item Depth expansion: Depth alignment is performed group-wise and can be done only after the group alignment. As shown in Fig.~\ref{depth}, for those groups with fewer layers in sub-models than the parent model, they are padded with all $0$ layers to reach the layer number of the parent standard. Furthermore, the width and kernel size in these all-zero layers are the same as the width of the corresponding layer of the parent model.
\end{itemize}
After the model alignment, the federated average algorithm could be performed to aggregate all of the uploaded local grads and update the global model. The detailed working flow of the whole alignment and aggregation operation is given in Algorithm \ref{alg3}.
\begin{algorithm}[htbp]
\caption{Sub-model Alignment and Aggregation}
\label{alg3}
\begin{algorithmic}
\STATE {\bfseries Input:} The number of workers $K$, sub-model update $\Delta_k^t$ and data size $n_k$ for each worker $k$, and total data size $n$;
\STATE {\bfseries Output:} Global model $\omega_t$;
\FOR{$k=1$ to $K$ in parallel}
\STATE Group the layers of the update $\Delta_{k}^{t}$ by block;
\STATE Expand the width of the layers of $\Delta_{k}^{t}$;
\STATE Extend the depth of $\Delta_{k}^{t}$;
\ENDFOR
\STATE Aggregate all updates $\Delta_{t} = \sum_{k=1}^K \frac{n_{k}}{n} \Delta_{k}^{t} $;
\end{algorithmic}
\end{algorithm}
\subsection{RL-Based parent model For Data Heterogeneity}
After the training stage of FL, the optimized models (or sub-models) would be deployed on edge devices in the real world.
And a machine learning model in the wild (e.g., a self-driving car) must be prepared to make sense of its surroundings in rare conditions that may not have been well-represented in its training set. However, the previous personalized FL only focus on the heterogeneity of data distribution and ignores the changes in data quality in practice.
Previous work \cite{skip} has proved that to achieve the same prediction accuracy, heterogeneous data quality requires different network complexity. For example, a clear image may only require a smaller neural network to achieve the same accuracy as a blurred image.
Thus, to achieve fairer task performance across heterogeneous datasets, we enable the global model to be data-aware by an RL gating module to assign personalized sub-models according to different data conditions. The RL function could dynamically select which layers of a convolutional neural network should be skipped during sub-model sampling.
Specifically, we first introduce layer-wise RL agents which are coded as a function from the feature activations to the probability distribution over the skipping action.
Note that to cope with non-differentiable data-aware model sampling decisions, we first warm up the global model and train it using a hybrid learning algorithm~\cite{skip}.
It turns out that the RL modules in CFL not only speed up the FL edge training but also could accelerate the following inference stage by assigning more lightweight models to edge devices. In a word, CFL is a great full-stack FL system that could greatly reduce the computing overhead in both the training and inference stages.
Last, the overall process of our method is summary in Algorithm~\ref{alg:framework}.
\begin{algorithm}[htbp]
\caption{CFL: Customized Architecture Search based Federated Learning}
\label{alg:framework}
\begin{algorithmic}
\STATE {\bfseries Input:} Number of workers $K$, learning rate $\eta$
\STATE {\bfseries Output:} local updates $\Delta_k^t$ and test accuracy of worker $k$ in communication round $t$
\STATE {\bfseries Initialize:} parent model $\mathbf{\omega}_1$;
\FOR{$t=1$ {\bfseries to} $T$}
\STATE \underline{{\bfseries On server}:}
\STATE \textit{Select} the sub-model $\omega_k^t$ from $\omega_{t}$ for each worker $k$ by using the search helper;
\STATE Send sub-models $\omega_k^t$ to all workers ;
\STATE Receive and \textit{aggregate} $\Delta_k^t$ of all workers to get $\Delta_t$;
\STATE Update the global model $\omega_{t+1} = \omega_{t} - \Delta_t$;
\STATE Receive data and hardware profile and use them to update the search helper;
\STATE \underline{{\bfseries On worker} k=1,\ldots,K:}
\STATE Receive sub-model $\omega_k^t$ from server;
\FOR{epoch $e$ ranges from $1$ to $E$}
\STATE Compute the stochastic gradient $\nabla l(\omega_{k,e-1}^t)$ from a random mini-batch;
\STATE Update sub-model $\omega_{k,e}^t = \omega_{k, e-1}^t -\eta \nabla l(\omega_{k,e-1}^t)$;
\ENDFOR
\STATE Compute local update $\Delta_k^t = \omega_{k,E}^t - \omega_{k,0}^t$
\STATE Send $\Delta_k^t$ to server;
\STATE Send test accuracy and hardware specification profile to server;
\ENDFOR
\end{algorithmic}
\end{algorithm}
\section{Experiment}
\label{sec:Result}
\subsection{Benchmark}
\textbf{Dataset}:
We use CIFAR-10 and MNIST datasets specially processed to emulate two different data heterogeneities.
\textit{Data quality heterogeneity:} Both datasets are independently and identically (IID) divided into several batches and processed by gaussian blurring and image sharpening with different levels. These batches are re-mixed to form new mixed-quality datasets.
\textit{Data distribution heterogeneity:} Each dataset is randomly divided into 32 Non-IID subsets. The data class imbalance degree is set to 0.8 in this work, i.e., 80\% of each worker's local data belongs to the same class, and the remaining 20\% are evenly selected from the remaining categories. \\
\textbf{Model}:
We use MobileNetV3 with elastic depth, width, input size, and additional layer-wise RL gating modules as the global model in FL.
\textbf{Dataset}:
We use CIFAR-10 and MNIST dataset as the baseline and a set of extended datasets derived from both of them to emulate two different data heterogeneities including \textbf{data quality heterogeneity} and \textbf{data distribution heterogeneity}.
\textbf{CIFAR-10} dataset is processed to simulate the data quality heterogeneity. It consists of 60000 32x32 color images in 10 classes, with 6000 images per class and 10000 images per batch. There are five batches of images for training and one batch of images for the test. To simulate data quality heterogeneity during practical inference, we use three different degrees of gaussian blur and image sharpening on the CIFAR-10 dataset, one per batch, to produce datasets of different quality but the same distribution. To be specific, we divided the training set of CIFAR-10 into five groups: unprocessed, three degrees of gaussian blur and sharpening images respectively. Instead of using complex data quality metrics, we apply different variances of the added noise to represent the heterogeneity in data quality.
\textbf{MNIST} dataset is used to generate data heterogeneity in both distribution and quality. As for the data quality heterogeneity, we divide the MNIST training set uniformly into five IID subsets and conduct the above-mentioned gaussian blur or image sharpening per group, to produce datasets of different quality but the same distribution. As for the data distribution heterogeneity, we divide the whole MNIST dataset randomly into 32 Non-IID subsets to simulate the different data distribution between federated workers. The data class imbalance degree is set to 0.8 in this work, i.e., 80\% of each worker's local data belongs to the same class, and the remaining 20\% are evenly selected from the remaining categories.
\noindent \textbf{Model}:
We use a once-for-all network \cite{ofa20} with RL gate as the parent model, which is built on MobileNetV3 with elastic depth, width and input size. All of the customized submodels in our experiments are selected from the parent model.
\subsection{The Comparison of CFL with FL SOTA}\label{subsec:cus and same}
In this section, we compare the performance of CFL using personalized models and FL SOTAs using one global model (abbreviated as FL in the following) on two different data heterogeneity settings with respect to data quality and distribution. The results are shown in Figure. \ref{subvsofa} (a) and Figure.\ref{subvsofa} (b), respectively.
It is obvious that CFL performs significantly better than FL under both heterogeneous settings, especially when the data quality is heterogeneous.
Figure. \ref{time} shows the time required for the first 200 iterations over 32 clients of CFL and FL, respectively.
\par
The results demonstrate that CFL not only significantly improves training efficiency but also improves FL fairness because the training time difference between clients is significantly reduced.
\begin{figure}[ht]
\centering
\subfigure[Quality heterogeneity]{
\includegraphics[width =0.91\columnwidth]{Fig6a.pdf}
}
\subfigure[Distribution heterogeneity]{
\includegraphics[width = 0.91\columnwidth]{Fig6b.pdf}
}
\caption{(a) Quality heterogeneity. (b) Distribution heterogeneity.}
\label{subvsofa}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width = 0.91\columnwidth]{Fig8.pdf}
\caption{Time required for 200 iterations on 32 workers.}
\label{time}
\end{figure}
\subsection{Federated Learning vs. Independent Learning}\label{subsec:fl and ind}
The performance gain from CFL to local independent learning (IL) using customized models is demonstrated. The training experiments are conducted over two categories of datasets, i.e., MNIST with both heterogeneous quality and heterogeneous distribution, which are split into 32 subsets for each worker respectively. The result of the accuracy comparison between CFL and independent local training is shown in Table \ref{table3}, it is obvious that using CFL in model training for edge computing consistently outperforms independent training in both heterogeneous and non-heterogeneous data distributions. And, in the case of data heterogeneity, the advantages of CFL are further amplified.\par
\begin{table}[htbp]
\renewcommand\arraystretch{1.5}
\centering
\caption{Comparison of test accuracy under two edge computing settings: CFL and Independent local training.}
\label{table3}
\begin{tabular}{l|cc|cc}
\bottomrule
& \multicolumn{2}{c|}{Non-heterogeneous Data} & \multicolumn{2}{c}{Heterogeneous Data} \\ \hline
scenario & \begin{tabular}[c]{@{}l@{}}CFL (\%)\end{tabular} & \begin{tabular}[c]{@{}l@{}}IL (\%)\end{tabular} & \begin{tabular}[c]{@{}l@{}}CFL (\%)\end{tabular} & \begin{tabular}[c]{@{}l@{}}IL (\%)\end{tabular} \\ \hline
worker 0 & 82 & 74.8 & 80.5 & 68.7 \\ \hline
worker 1 & 73.6 & 73.4 & 72.6 & 50.8 \\ \hline
worker 2 & 86.1 & 82.3 & 85.6 & 69 \\ \bottomrule
\end{tabular}
\end{table}
\begin{figure}[tp]
\centering
\subfigure[Quality heterogeneity]{
\includegraphics[width =0.85\columnwidth]{Fig9a.pdf}
}\\
\subfigure[Distribution heterogeneity]{
\includegraphics[width = 0.85\columnwidth]{Fig9b.pdf}
}
\vspace{-7pt}
\caption{Comparison between CFL and independent learning with customized submodels. (a) Quality Heterogeneity: MNIST and 32 workers. (b) Distribution Heterogeneity: MNIST and 32 workers.}
\label{noniidjoinindep}
\end{figure}
\begin{figure}[htp]
\centering
\subfigure[Worker 0 with gaussian fuzzy data]{
\includegraphics[width=\columnwidth]{20210907exp3_gau1.png}
}\\
\subfigure[Worker 1 with unprocessed standard data]{
\includegraphics[width=\columnwidth]{20210907exp3_data.png}
}\\
\subfigure[Worker 2 with sharpening data]{
\includegraphics[width=\columnwidth]{20210907exp3-rh.png}
}\\
\subfigure[Computation Percentage]{
\includegraphics[width=\columnwidth]{20210907exp4_comp.png}
}
\caption{Comparison of accuracy and computational cost between the FL model using data quality-aware (with RL gate) and the common FL model without awareness under different data quality.}
\label{gate}
\end{figure}
\textbf{} (\romannumeral1)
\textit{Heterogeneous Data Quality:} We generate Gaussian fuzzy data with three fuzzy degrees, unprocessed data and sharpening data for all workers (randomly assigned), and then conduct the CFL and independent learning respectively. The results are shown in Fig~\ref{noniidjoinindep}(a). It is verified that the final test accuracy of the customized models in CFL is obviously higher than that of the independent learning method. This is because in CFL workers can learn from the experiences of others, which is absent in independent training. In reality different edge devices often have heterogeneous data.
\textbf{} (\romannumeral2)
\textit{Heterogeneous Data Distribution:} Fig~\ref{noniidjoinindep} (b) shows that the final test accuracy of CFL is higher than that of independent learning. Because in CFL, workers can learn and improve the local model from the parameter aggregation operation, while it is not possible for independent training.
\subsection{Data quality-aware Parent Model}\label{subsec:par}
\vspace{20pt}
In this section, we show how the RL gates can benefit the parent model. We set different data qualities for different workers. After deploying RL gates on each layer of the original parent model, we first train it in advance on the server using a small public dataset with uniformly distributed categories and the worst data quality. This pre-trained model can then be used for sub-model selection initially. The test accuracy of customized models is shown in Fig.~\ref{gate}(a-c). The results show that the RL gate-enabled sub-model selection not only consumes less time to converge but also reduces both the training and inference time since the computation of some layers of customized models are waived. To better demonstrate the computation overhead reduction, the computational percentage curves in the training phase of the customized models for three workers are given in Fig.~\ref{gate}(d). This percentage is defined as the ratio of the number of layers that are actually calculated to the number of all layers of the model.
\section{Conclusion}
In this paper, we introduce a novel customized federated learning framework, which first takes the multi-dimensional heterogeneity in federated learning. Specifically, we design a novel aggregation algorithm to reduce the calculation delay and accuracy difference between the cooperative FL devices.
What's more, CFL uses a specially designed data quality-aware central model via RL gate to accelerate reasoning and improve robustness in the face of data quality changes. Extensive experiments have proved the effectiveness of CFL.
\bibliographystyle{ieeetr}
| {'timestamp': '2023-02-10T02:07:29', 'yymm': '2302', 'arxiv_id': '2302.04464', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04464'} | arxiv |
\section{Introduction}
Nadir altimeter satellites provide invaluable direct measurements of the sea surface height (SSH) to monitor sea surface dynamics.
They have played a key role in better understanding ocean circulation and improving climate monitoring. Altimeter-derived SSH data are also of key interest for offshore activities, marine pollution monitoring or maritime traffic routing among others.
However due to the sparse and irregular sampling associated with nadir altimeter constellations, a wide range of ocean processes from the mesoscale to the submesoscale range remains unresolved, typically for horizontal scales below 150 kilometers and time scales below 10 days.
The recently launched SWOT mission, with its Ka-band radar interferometer (KaRIN) sensor, provides for the first time higher-resolution and two-dimensional snapshots of the SSH. Once this data is adequately processed, it will likely strongly impact our ability to observe and study upper ocean dynamics \cite{Peral_Esteban-Fernandez_2018}.
\begin{figure}[!t]
\begin{center}
\includegraphics[width=\linewidth]{gridded_sensors.png}
\end{center}
\caption{\textbf{Observing System Simulation Experiment Cross-Calibration data:} \textit{Top left:} Sea surface height (SSH) on October 26th 2012 from NATL60 simulation dataset. \textit{Top right:} Calibrated NADIR pseudo-observations sampled using realistic orbits from the SSH are used to compute gridded product for the cross-calibration.\textit{Bottom-left:} NADIR + noise-free-KaRIN pseudo-observations, the 2{\sc d} sampled the SSH is the target of the cross-calibration.\textit{Bottom-right:} NADIR + noisy-KaRIN pseudo-observations, simulated errors added to the swath SSH constitute the uncalibrated input of the cross-calibration problem}
\label{fig:gridded}
\end{figure}
As reported in Figure \ref{fig:gridded}, KaRIN data will be affected by instrument and geophysical errors \cite{ubelmann_swot_nodate} and their exploitation requires to develop robust calibration schemes. We illustrate in Fig.\ref{fig:filtered_swath_uncal_comp} the two main error sources: instrument errors, especially roll errors, are expected to cause the dominant large-scale signal in both across-swath and along-swath directions; and geophysical errors, in particular due to wet-troposphere-induced delays\footnote{We refer the reader to Section \ref{subsec:altimetry} for the description of these error signals in raw KaRIN observations.}.
The amplitude of these errors typically range from a few centimeters to a few meters in simulation, when the variability of the SSH for scales below 150km typically amounts to centimeters (See Fig. \ref{fig:gridded_impact}). This makes SWOT calibration a particularly challenging task in terms of signal-to-noise ratio. State-of-the calibration schemes \cite{Dibarboure_Ubelmann_Flamant_Briol_Peral_Bracher_Vergara_Faugere_Soulat_Picot_2022} rely on explicit spectral priors to address the calibration problem.
The underlying hypotheses that one can linearly separate the SSH and the different error components may however impede the performance of such calibration methods. Here, we propose a novel learning-based approach.
We leverage the computational efficiency of deep learning schemes with a scale-space decomposition \cite{Witkin_1984} adapted to the geometry of KaRIN observations.
Our main contributions are as follows:
\begin{itemize}
\item{We state the cross-calibration of KaRIN altimetry observations as a learning problem using both raw KaRIN altimetry data and a gridded altimetry product as inputs to the neural network.}
\item{Our neural network architecture applies a scale-space decomposition scheme in the geometry of the KaRIN swath to improve the separability of the SSH and of the errors.}
\item{Numerical experiments using an Observing System Simulation Experiment (OSSE) demonstrate the relevance of the proposed approach and highlight the impact of the quality of the gridded altimetry product to retrieve finer-scale patterns in the calibrated KaRIN observations.}
\end{itemize}
This paper is organized as follows. Section \ref{sec:background} provides some background on related work. We introduce the considered data and case-study in Section \ref{sec:case_study}.
Section \ref{sec:method} presents our method and we report numerical experiments in Section \ref{sec:results}.
Section \ref{sec:conclusion} discusses further our main contributions.
\section{Background}
\label{sec:background}
\noindent
\begin{figure*}[!t]%
\centering
\subfloat[$f$]{{\includegraphics[width=.49\textwidth]{swath_err_details} }}%
\subfloat[$\mathcal{G}_{200km}((f)) - \mathcal{G}_{10km}(f)$]{{\includegraphics[width=.49\textwidth]{swath_err_f10_200_details} }}%
\caption{\textbf{1000km segment of KaRIN observation components in swath geometry:}\textit{(a)} Looking at the three signals we see that the large scale instrument errors (middle) are predominant compared to the SSH (top) and geophysical error (bottom). \textit{(b)} Looking at the along-track scales between 10km and 200km, we see that the SSH is dominant w.r.t the error signals.}%
\label{fig:filtered_swath_uncal_comp}%
\end{figure*}
\subsection{Satellite altimeters}
In this paper, we address the cross-calibration of KaRIN observations, meaning that the proposed calibration scheme relies on external calibrated data. More specifically, we consider a constellation of nadir satellite altimeters of typically 4 to 7 satellites over the last decade. We recall that nadir altimeters provide can provide calibrated measurements of the SSH for medium to large scales along 1{\sc d} profiles corresponding to satellites' orbiting paths.
By contrast, according to the mission's error budget specification \cite{Peral_Esteban-Fernandez_2018} the KaRIN instrument samples a two-dimensional swath of approximately 120km-wide with a 2km$\times$2km pixel resolution everywhere over the ocean.
In Figure \ref{fig:gridded}, we report simulated altimetry observations for both nadir altimeters and KaRIN along with the reference SSH issued from a numerical simulation dataset (see Section \ref{sec:case_study} for details). As an illustration of the complexity of calibration problem, the error signals completely occlude the SSH signal in the uncalibrated KaRIN observation.
Figure \ref{fig:filtered_swath_uncal_comp} illustrates further this point in the swath geometry. When focusing to along-track scales between 10km and 200km, the SSH signal becomes the main signal (Fig. \ref{fig:filtered_swath_uncal_comp}). This supports
both to consider a scale-space decomposition and to
investigate a cross-calibration approach with
the exploitation of nadir-altimeter-derived altimetry products, which typically resolve horizontal scales longer than 80km.
\subsection{Interpolation of satellite-derived altimetry data}
\label{subsec:interpolation}
As mentioned previously, flying nadir altimeter constellations naturally advocate for considering the resulting interpolated SSH products as auxiliary data of interest to address the calibration of KaRIN observations.
Regarding operational SSH products, we may distinguish the optimally-interpolated altimetry-derived product (DUACS) \cite{taburet_duacs_2019} and reanalysis products using ocean general circulation models to assimilate various observation datasets, including satellite altimetry and satellite-derived sea surface temperature data \cite{glorys_rea_2021}. Both types of products typically retrieve SSH dynamics on a global scale for horizontal scales above 150km and 10 days.
Recently, a renewed interest has emerged in interpolation methods for ocean remote sensing data \cite{beauchamp_intercomparison_2020}\cite{fablet_end2end_2021}. Especially, deep learning schemes have emerged as appealing approaches to make the most of available observation datasets. Recent benchmarking experiments \cite{osse_data_challenge} point out significant potential gain compared with the above-mentioned operational products.
Here, we aim at investigating the extent to which the quality of L4 nadir-altimetry-derived SSH products may impact the calibration of KaRIN observations.
\subsection{Scale-space theory}
\label{subsec:scalespace}
Introduced in 1984 by A.P Witkin \cite{Witkin_1984},
The scale-space theory provides a mathematically-sound framework to decompose 2{\sc d} signals at different spatial scales \cite{Witkin_1984}. Gaussian scale-space methods are among the most widely used. They rely on applying Gaussian blur transformations with different standard deviations. This approach has been widely used in low-level image processing tasks \cite{lindeberg1996edge,Lindeberg_2015}.
Recent studies have used the scale-space theory in deep learning architectures \cite{Pintea_Tomen_Goes_Loog_van_Gemert_2021,Worrall_Welling_2019}. These neural networks better deal with multi-scale patterns in the data.
Here, we draw inspiration from the scale-space framework to address the KaRIN calibration problem.
We design a scale-aware decomposition scheme as part of our learning approach with a view to
better account for the different characteristic scales of the signals in play.
\subsection{Deep Learning for earth observation}
\label{subsec:dl}
\noindent
Convolutional neural networks are among the state-of-the-art neural architectures for image processing applications, including
image classification\cite{lecun98,resnet2016}, image in-painting\cite{liu_image_2018}, object detection\cite{yolo2016} and more.
They have also led to breakthroughs in remote sensing problems such as SAR image segmentation\cite{colin2021,colin_2022}, altimetry data interpolation \cite{fablet_joint_2021} and even sensor calibration \cite{li_convolutional_2022}.
The problem of multi-scale processing in neural networks has traditionally been tackled through the use of pooling layers in architectures such as the UNet \cite{Ronneberger_Fischer_Brox_2015}. As shown in the reported numerical experiments, these architectures do not reach a state-of-the-art performance for our KaRIN calibration problem. This advocates for the design of neural architectures better accounting for the key features of KaRIN observations.
\section{Data and Case-study}
\label{sec:case_study}
In this paper, we run an Observing System Simulation Experiment (OSSE), meaning that we rely on simulated data to apply and evaluate the proposed neural approach.
In this section, we present the different datasets considered in this OSSE.
\subsection{NATL60}
The simulation of the sea surface height field is taken from the NATL60 \cite{ajayi_spatial_2020} run of the NEMO ocean model. This simulation spans one year and covers the North Atlantic basin with a 1/60° spatial resolution. We more specifically use the data from a 12°$\times$12° domain over the Gulfstream ranging from the longitudes -66° to -52° and latitudes 32° to 44°.
\subsection{Nadir observations}
\label{subsec:altimetry}
In order to generate realistic nadir-altimeter pseudo-observations, we consider the real orbits of the years 2012 and 2013 of the four missions Topex-Poseidon, Jason 1, Geosat Follow-On, Envisat, as well as the 21-day cycle phase SWOT orbit from the SWOT simulator \cite{ubelmann_swot_nodate} project. The sampling of the nadir-altimeter pseudo-observations relies on the interpolation of the hourly SSH fields of the NATL60 run at the orbit coordinates. We consider nearest-neighbor interpolation in time and a bilinear interpolation in space.
\subsection{KaRIN observations}
The SWOT simulator also generates the swath coordinates on each side of the SWOT nadir. The swath spans from 10km to 60km off nadir with a 2km by 2km resolution. The SSH is then sampled on those coordinates the same way as the nadir observations.
Additionally, we also use the SWOT simulator in its "baseline" configuration to generate observation errors.
Our simulation includes the systematic instrument errors with the roll, phase, timing and baseline dilation signals. Those signals have time-varying constant, linear or quadratic shape in the across track dimension.
We also consider the geophysical error with the wet troposphere residual error as implemented in the simulator.
We refer the reader to \cite{ubelmann_swot_nodate}
for a detailed presentation of the SWOT simulator.
\subsection{Gridded Altimetry Products}
\label{subsec:mapping}
\noindent
As explained in section \ref{subsec:interpolation}, we make use of interpolated SSH products based on
nadir altimetry data as inputs for our cross-calibration method.
We consider two interpolation schemes in our study:
\begin{itemize}
\item the operational state-of-the-art based on optimal interpolation as implemented in the DUACS product \cite{taburet_duacs_2019}.
\item a state-of-the-art neural interpolation scheme, referred to as 4DVarNet \cite{fablet_joint_2021}. This method is based on a trainable adaptation of the 4DVAR \cite{carrassi_data_2018} variational data assimilation method, and out-performs concurrent approaches in the considered OSSE setup \cite{osse_data_challenge}. We consider two 4DVarNet interpolation configurations, one using only nadir altimetry data \cite{Beauchamp_Febvre_Georgenthum_Fablet_2022}, one using jointly nadir altimetry and sea surface temperature data \cite{Fablet_Febvre_Chapron_2022}. We also include the latter as it significantly improves the reconstruction of the SSH at finer scales.
\end{itemize}
\section{Proposed Methodology}
\label{sec:method}
\noindent
This section presents the proposed methodology for the cross-calibration of raw KaRIN observations.
We design trainable neural architectures that take as inputs the uncalibrated KaRIN observations and the nadir-altimeter-derived gridded SSH products interpolated on the KaRIN swath. We train these architectures in a supervised manner on the reconstruction of the SSH on the KaRIN swath.
We first present an overview of the proposed neural architectures (Section \ref{subsec:neural_arch}). We then detail two specific components, namely the scale-space decomposition block (Section \ref{subsec:scale_decomp}) and the swath-mixing layers (Section \ref{subsec:mixing}).
\subsection{Proposed neural architecture}
\label{subsec:neural_arch}
\noindent
\begin{figure*}
\begin{center}
\includegraphics[width=\textwidth]{CalDiag2.png}
\end{center}
\caption{\textbf{Overview of the proposed architecture:} From left to right: First, the nadir-based gridded product is interpolated on the swath segment. Then, it and the KaRIN observation go through the scale decomposition scheme described in \ref{subsec:scale_decomp}. The scale components are stacked as channels and processed through the neural network. The green color of the "Split Conv" indicates that each side of the swath is processed independently by the convolution layer whereas the orange coloring of the "Swath Mix" layer tells that the whole data is processed jointly by the step (more details in \ref{subsec:mixing}). The final convolution computes a correction to be added to the gridded product for computing the calibrated KaRIN data}
\label{fig:arch}
\end{figure*}
The overall architecture considered is shown in figure \ref{fig:arch}. The scale-space decomposition block first decomposed independently the input L4 SSH products and KaRIN observations
into $N_s$-scale tensors, which we concatenate as the channel dimension.
This results into a tensor of shape $(2N_s, N_{al}, N_{ac})$ where $N_{al}$ and $N_{ac}$ are respectively the along track and across track sizes of the input swath section. The scale-space decomposition step is described in section \ref{subsec:scale_decomp}
A linear 2{\sc d} convolution layer follows.
The data is then processed by a series of residual convolutional blocks composed of a convolution layer, a ReLU non-linearity \cite{Nair_Hinton_2019}, a skip connection and a swath-mixing layer as described in \ref{subsec:mixing}. A last linear convolution layer outputs a residual field, which we sum with the input gridded L4 SSH product to produce the calibrated KaRIN observation.
\subsection{Scale decomposition}
\label{subsec:scale_decomp}
We exploit a Gaussian scale-space to compute a scale-space decomposition of the fields provided as inputs to our neural architecture. For given scales $\sigma_1$ and $\sigma_2$, we extract the associated signal as the difference between filtered versions of the input signal using two Gaussian filters with standard deviation $\sigma_1$ and $\sigma_2$. We consider one-dimensional filters for the along-track direction. Formally, denoting
$\cal{G_{\sigma}}$ the 1-dimensional Gaussian blur operator with standard deviation $\sigma$ in the along track dimension, the considered scale-space decomposition of a signal $f$ given a sequence of increasing scales $[\sigma_1, \sigma_1, ..., \sigma_S]$ computes the following $S+1$ components: $[\mathcal{G}_{\sigma_1}(f), \mathcal{G}_{\sigma_2}(f) - \mathcal{G}_{\sigma_1}(f),...,\mathcal{G}_{\sigma_S}(f) - \mathcal{G}_{\sigma_{S-1}}(f), f - \mathcal{G}_{\sigma_S}]$
These different components are then considered as channels for the convolutionnal networks. In our experiments, we consider 20 scales in the along-track dimension evenly spaced from 8km to 160km. We discuss in section \ref{subsec:decomp_sens} how sensitive the proposed method is to the parameterization of the decomposition.
To account for scale-dependent energy levels in the computed scale-space representation (see fig. \ref{fig:var_in_out}), we introduce a batch normalization layer \cite{Ioffe_Szegedy_2015}. It re-scales each component to centered and unit-variance variables.
We illustrate in Fig.\ref{fig:var_in_out} the impact of the batch normalization step on the relative variance of the signal of each scale of the decomposition.
One may regard the proposed scale-scale decomposition as a convolutional block. Learning such a decomposition from data would however require very large convolutional filters, which does not seem
realistic, or a deeper architecture with pooling layers that would require very efficient optimization given the quantity of data available.
\begin{figure}[!t
\centering
{\includegraphics[width=\linewidth]{var_rescale_obs} }%
\caption{\textbf{Explained variance of scale components before and after re-scaling:} Each bar indicates how much each scale component of the uncalibrated KaRIN contributes to the total variance of the signal, we can see that before re-scaling (blue) there is four orders of magnitude between largest scale and the others. The learnt re-scaling allows for scale component to be spread within a single order of magnitude (orange), which is more suited to the downstream neural architecture.}%
\label{fig:var_in_out}%
\end{figure}
\subsection{Swath mixer block}
\label{subsec:mixing}
As observed in Figure \ref{fig:filtered_swath_uncal_comp}, the swath observed from the KaRIN sensor is not contiguous in the across-track dimension. The observation errors are however clearly correlated between the two sides of the swath. To exploit these correlations in our architecture, we design a swath-mixer block with two specific layers.
To avoid convolution kernels to mix information from the two sides of the swath which could add some unwanted side effect, each side is processed separately by each convolution layer noted "Split Conv" in Fig. \ref{fig:arch}. Additionally, each convolution layer input is padded so that the height and width of the input remain unchanged throughout the network.
Besides, to combine relevant features from the two sides of the swath, we introduce a layer denoted as "Swath-mix" in Fig. \ref{fig:arch}. It implements a convolution layer after transposing the across-track dimension as a channel dimension. This idea of a mixer layer has been used in architectures such as the MLP-Mixer \cite{mlpmixer}, in which it has been shown to help with the expressiveness of neural networks.
We analyse in section \ref{subsec:ablation} the contribution of the mixing layer.
\section{Experimental results}
\label{sec:results}
\subsection{Setup}
\noindent
The results of this section have been computed using the one year ocean simulation NATL60, over the 12°x12° domain over the Gulfstream. The model evaluation is done on forty days in the inner 10°x10° region. The training of the mapping and calibration models are done on the remaining days.
The experimental setup used is the same as in \cite{osse_data_challenge}
The base configuration for our architecture uses three convolutional blocks with 128 channels as presented in Figure \ref{fig:arch}.
The supervised training loss is a weighted mean of the mean square errors for the reconstruction of the SSH, its gradient and its Laplacian.
The default scale-space decomposition used is made of twenty 8 kilometers band.
The calibration model is trained for 250 epochs with a annealing triangular cyclical learning rate \cite{Smith_2017}.
\subsection{Benchmarking experiments}
\label{subsec:main_res}
\noindent
\begin{table}[t]
\begin{center}
\input{res_main}
\end{center}
\caption{Residual error of the proposed calibration framework CalCNN}
\label{table:main}
\end{table}
We summarize our benchmarking experiments in Table \ref{table:main}.
We compare our approach, referred to as CalCNN, with a standard UNet \cite{Ronneberger_Fischer_Brox_2015} architecture. The latter uses as inputs the gridded altimetry product and the uncalibrated KaRIN observation stacked together as a 2{\sc d} field with 2 channels. We consider the same training configuration for this UNet model as for the CalCNN.
As baseline, we also consider the reconstruction performance for the KaRIN SSH issued from the 4DVarNet method using nadir-altimeter-only data.
We evaluate all methods according to the following two metrics, the root mean squared error (RMSE) of the SSH field, and the RMSE of the amplitude of the gradients of the SSH field.
Whereas the UNet fails to produce a better estimate than the nadir-only interpolation baseline, our CalCNN improves the estimation of the SSH and its gradient by over 35\% and brings the residual error below 1.4cm (Table \ref{table:main}).
In Figure \ref{fig:err_scales}, we further decompose the calibration error of the CalCNN w.r.t. the spatial scale using 1-dimensional Gaussian blurs as introduced in \ref{subsec:scale_decomp}. We draw a comparison with the 4DVarNet interpolation baseline and observation errors. The CalCNN reaches a lower error than both KaRIN observations and the interpolation baseline across all scales. At larger scales the error gets closer to the latter as instrument errors dominate the large-scale components of KaRIN observations.
Interestingly, at scales lower than 10km, we still retrieve some improvement even though the observation error is quite high.
This can be explained by the fact that the high frequency errors on the KaRIN observations is easily separable from the underlying SSH signal.
Between 10-100km, our method successfully exploits the lower observation errors to improve the interpolation baseline.
\begin{figure}[!t]
\centering
\includegraphics[width=\linewidth]
{norm_cumsum_highpass_errors_1.png}%
\caption{{\bf Observation and reconstruction error for the SSH as a function of the spatial scales:} The figure shows the error relative to the SSH at different scales for the inputs (Uncalibrated KaRIN in orange and nadir based interpolation in blue) and output (Calibrated KaRIN in green) of our method. The x axis correspond to the standard deviation of the Gaussian blur that was used to extract the low scale components. We can see the expected trend of the interpolation error of the nadir that is bigger at finer scale and becomes low w.r.t the SSH at large scale. Regarding the Uncalibrated KaRIN, we see that the error is lower than the interpolation only in the 10km-100km range. We see the Calibrated output of our method achieves lower error across all scales, successfully extracting relevant scale information from each signal.}
\label{fig:err_scales}%
\end{figure}
\subsection{Ablation Study}
\label{subsec:ablation}
\noindent
\begin{table}[t]
\begin{center}
\input{res_ablation.tex}
\end{center}
\label{table:ablation}
\caption{Ablation results}
\end{table}
In this section we analyse further the contribution of the different components of our neural architecture.
In Table \ref{table:ablation}, we report
the performance metrics of the considered ablation study with the following models:
a model without skip connections, one without gridded product as input, one without the scale-space decomposition scheme (Sec. \ref{subsec:scale_decomp}) and one without the swath-mixer layers (Sec.\ref{subsec:mixing}. Overall, these four models lead to a significantly lower performance.
The largest impact comes from the nadir-altimetry-only gridded product which provides large scale information about the SSH. And without which we lose an order of magnitude in the calibration errors.
Moreover, we can see that without the skip connections or scale decomposition, we fail to improve on the L4 gridded product.
Finally, we can note that we still get ~10\% reduction of the RMSE w.r.t the L4 product without the mixing layer, however sharing the information between each side of the swath improves this gain three fold.
In Table \ref{table:size}, we show the sensitivity to the size of the network for the same training configuration. we compare the base architecture 3x128 (3 convolution blocks with 128 channels) with a linear operator, as well as a smaller network 1x32 and a bigger one 5x512. The linear version fails to extract geophysical information from the uncalibrated information. This further points out how challenging the considered calibration task is. Interestingly, our architecture leads to a similar performance for different complexity levels. The smaller and larger architectures leads to a slight increase in the residual error but the smaller model shows a slight improvement in the gradient reconstruction and spatial resolution.
Overall, these results support the robustness of the proposed learning-based approaches and the conclusions we raise in section \ref{subsec:main_res} are not very sensitive to the hyper-parameters of our network architecture.
\begin{table}[t]
\begin{center}
\input{res_size}
\end{center}
\caption{Impact of network size}
\label{table:size}
\end{table}
\subsection{Gridded product sensitivity}
\label{subsec:gridded_sens}
\noindent
We analyze further how the quality of nadir-altimetry-only gridded product affects the calibration performance.
In Figure \ref{fig:gridded_impact}, we display the improvement in RMSE of the SSH on the swath and of the gradients of the SSH obtained by our CalCNN for the three gridded products introduced in Sec. \ref{subsec:interpolation}.
For all three interpolated products, the proposed calibration method improves the reconstruction of the SSH for the KaRIN swath from the joint analysis of the interpolation product and raw KaRIN observations. We report the larger improvement for DUACS product. This relates to the spectral overlap between the SSH information of the uncalibrated KaRIN and SWOT's NADIR. The associated calibration performance remains however significantly worse than that of the two 4DVarNet products, which may relate to the worse interpolation performance of DUACS product \cite{fablet_end2end_2021,osse_data_challenge}.
When comparing the impact of the two 4DVarNet products, the results are more nuanced. The 4DVarNet-SST product leads to better metrics. The difference of RMSE is greatly reduced after calibration whereas the gap in RMSE of the gradients is conserved.
This could be interpreted as the gain of RMSE we get from using the SST can be obtained from the uncalibrated KaRIN, however some of the gradients we reconstruct through the SST are not easily extracted from the observations.
Overall this shows interesting relations between the redundant information in the uncalibrated KaRIN and the interpolated products.
\begin{figure}
\begin{center}
\includegraphics{gridded_impact.png}
\end{center}
\caption{{\bf Impact of the nadir-based gridded product on the CalCNN output:} The figure shows the RMSE and the RMSE of the $|| \nabla_{ssh} ||$ of the calibrated observation (stars) and their associated nadir-based gridded products (squares). We see an improvement brought by the CalCNN of both the RMSE and the RMSE of the $|| \nabla_{ssh} ||$ in the same direction for all three gridded products. This improvement can be interpreted as the relevant information extracted from the uncalibrated KaRIN by the CalCNN. The biggest relative improvement for DUACS (blue) which doesn't uses the SWOT's nadir altimeter, and the smallest one for the 4DVarNet that uses the SST.}
\label{fig:gridded_impact}
\end{figure}
\subsection{Sensitivity to the scale-space decomposition}
\label{subsec:decomp_sens}
\noindent
In Table \ref{table:scale_dec}, we display the calibration metrics for different scale-space decompositions. We vary the number of scales considered and the spacing between two consecutive scales. When considering the same scale range from 8km to 160km, we retrieve the best performance with 20 scales. But, even with only 5 scales evenly separated by 32 km, the performance decreases only by 3\%.
By contrast, when considering a scale separation of 8km but varying the number of scales, we note a more significant drop of performance (about 10\% in the residual RMSE). This suggests a greater sensitivity to the span of the scale-space decomposition than to the number and spacing of the components.
However we still achieve less than 1.6cm residual error for any of the considered variations which is still a competitive calibration outcome.
\begin{table}[!t]
\begin{center}
\input{res_scale_decomp}
\end{center}
\caption{Calibration metrics in function of the scale decomposition}
\label{table:scale_dec}
\end{table}
\section{Conclusion}
\label{sec:conclusion}
\noindent
We have proposed in this work a neural calibration approach which combines a scale-space decomposition of KaRIN observations and a convolutional architecture. This approach proves to be robust with a
residual error below 1.5cm which can be compared with the 2cm residual error of the expected operational approaches performance although demonstrated globally using a different ocean simulation \cite{Dibarboure_Ubelmann_Flamant_Briol_Peral_Bracher_Vergara_Faugere_Soulat_Picot_2022}. While we can reach a satisfactory calibration performance using the operational nadir altimetry mapping product, our experiments highlight the potential benefit of ongoing effort on neural SSH interpolation schemes to further improve the retrieval of finer-scale features from KaRIN observations.
This naturally advocates for future work exploring jointly calibration and mapping problems for nadir and wide-swath altimeters, possibly combining our deep learning approach and variational mapping formulations introduced in \cite{Febvre_Fablet_Sommer_Ubelmann_2022}.
Finally, even though the calibration results shown here are promising, the generalization to real signals of our calibration operator trained on simulated data are yet to be demonstrated.
\bibliographystyle{IEEEbib}
| {'timestamp': '2023-02-15T02:12:29', 'yymm': '2302', 'arxiv_id': '2302.04497', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04497'} | arxiv |
\section{Introduction}\label{sect:introduction}
Recent years have witnessed a surge of interest in machine learning on graphs \cite{hamilton2017representation}, with the goal of encoding high-dimensional data associated with nodes, edges, or (sub)graphs into low-dimensional vector representations that well preserve the original graph structural (manifold) information. Graph learning techniques have shown promising results for various important applications such as vertex (data) classification \cite{kipf2017iclr,grover2016node2vec}, link prediction (recommendation systems) \cite{ying-gcn-kdd2018, zhang2018link}, community detection \cite{ zhou2018graph, cai2018comprehensive, goyal2018graph}, drug discovery \cite{rathi2019practical,lim2019predicting }, solving partial differential equations (PDEs) \cite{belbute2020combining, li2020multipole,iakovlev2020learning}, and electronic design automation (EDA) \cite{ma-gnn-test-dac19, zhang2019circuit, wang2020gcn,mirhoseini2021graph}.
Modern graph learning tasks (without a known input graph topology) typically involve the following two key tasks: (1) graph topology learning for converting high-dimensional node feature (attribute) data into a graph representation, and (2) graph embedding for converting graph-structured data (e.g. graph topology and node features) into low-dimensional vector representations to facilitate downstream machine learning or data mining tasks.
Although there exist abundant research studies on graph embedding techniques \cite{hamilton2017representation,hamilton2017inductive,deng2019graphzoom}, it still remains challenging to learn a meaningful graph topology from a given data set. To this end, the well-known graphical Lasso method has been proposed as a sparse penalized maximum likelihood estimator for the concentration or precision matrix (inverse of covariance matrix) of a multivariate elliptical distribution \cite{friedman2008sparse}. The latest graph signal processing (GSP) based learning techniques also have been proposed to estimate sparse graph Laplacians, which has shown very promising results \cite{egilmez2017graph,dong2019learning}. For example, the graph topology learning problem is addressed by restricting the precision matrix (inverse of the sample covariance matrix) to be a graph Laplacian-like matrix and maximizing a posterior estimation of {{attractive Gaussian Markov Random Field (GMRF)}},
while an $\ell_1$-regularization term is leveraged to promote graph sparsity \cite{egilmez2017graph};
a graph Laplacian learning method is proposed by imposing additional spectral
constraints \cite{kumar2019structured};
a graph topology learning approach (GLAD) is introduced based on an Alternating Minimization (AM) algorithm \cite{shrivastava2019glad}, while \cite{pu2021learning} tries to learn a mapping from node data to the graph structure based on the idea of learning to optimise (L2O) \cite{li2016learning,chen2021learning}.
However, {the state-of-the-art graph topology learning methods \cite{ egilmez2017graph, dong2019learning, shrivastava2019glad} do not scale to large data sets} due to their high algorithm complexity. For example, recent graph topology learning methods based on Laplacian matrix estimation require solving convex optimization problems, which have a time complexity of at least {$O(N^2)$} per iteration for $N$ data points and thus can only be applied to rather small data sets with a few hundreds of data points \cite{ egilmez2017graph, dong2019learning,shrivastava2019glad}; the state-of-the-art deep learning based approach (GLAD) can only handle a few thousands of nodes on a high-performance GPU \cite{shrivastava2019glad}. Consequently, existing graph topology learning methods can not be efficiently applied in electronic design automation (EDA) tasks considering the sheer size of modern integrated circuit systems that typically involve millions or billions of elements.
\begin{figure}
\includegraphics[width=0.9995\linewidth]{overview_narrow.pdf}
\caption{Spectral graph learning for data-driven vectorless verification.}
\label{fig:overview_sfsgl}
\end{figure}
To the best of our knowledge, this paper introduces the first scalable spectral method (SF-SGL) for learning resistor networks from linear voltage and current measurements based on our recent SGL framework \cite{feng2021sgl}. An indispensable step in the original SGL framework requires to compute Laplacian eigenvalues/eigenvectors for estimating spectral embedding distortions \cite{feng2021sgl}, which can be potentially accelerated by leveraging the latest theoretical results in spectral graph theory. However, the state-of-the-art spectral algorithms strongly rely on fast Laplacian solvers that are usually difficult to implement in practice and inherently-challenging to accelerate on parallel processors. For example, the effective-resistance based spectral sparsification method \cite{spielman2011graph} requires multiple Laplacian matrix solutions for computing each edge's leverage (sampling) score, while the latest spectral-perturbation based algorithm \cite{feng2020grass} leverages a Laplacian solver for estimating each edge's spectral importance. The proposed algorithm (SF-SGL) is based on {a scalable multilevel spectral graph densification framework} for estimating attractive Gaussian Markov Random Fields (GMRFs).
SF-SGL can efficiently solve the graphical Lasso problem \cite{friedman2008sparse} with a Laplacian-like precision matrix by iteratively including the most influential edges to dramatically reduce spectral embedding distortions. A unique property of the learned graphs is that {the spectral embedding or effective-resistance distances on the constructed graph will encode the similarities} between the original input data points (node voltage measurements). Our method allows each iteration to be completed in $O(N \log N)$ time, whereas existing state-of-the-art methods \cite{ egilmez2017graph,dong2019learning} require at least $O(N^2)$ time for each iteration. Our analysis for sample complexity shows that by leveraging the proposed spectral algorithms it is possible to accurately estimate a sparse resistor network with only $O(\log N)$ voltage (and current) measurements (vectors).
The proposed solver-free approach (SF-SGL) will also bring new opportunities for developing brand new physics-informed, data-driven EDA algorithms and applications, as shown in Figure \ref{fig:overview_sfsgl}.
In this work, by exploiting SF-SGL we introduce a data-driven EDA algorithm for vectorless power/thermal integrity verifications to allow estimating worst-case voltage/temperature (gradient) distributions across the entire chip by leveraging only a few voltage/temperature measurements that can be potentially obtained from on-chip voltage/temperature sensors \cite{chung2011autocalibrated,anik2020chip,ku2019voltage}.
{{
The main contribution of this work has been summarized as follows:
\begin{enumerate}
\item This work introduces a spectral graph densification framework (SGL) for learning resistor networks with linear measurements. We prove that given $O(\log N)$ pairs of voltage and current measurements, it is possible to recover sparse $N$-node resistor networks that can well preserve the effective resistance distances on the original graph.
\item To achieve more scalable performance, a solver-free spectral graph learning framework (SF-SGL) is proposed that utilizes the multilevel spectral graph densification framework for constructing the learned graph. Compared to the previous SGL method which requires the Laplacian solver for estimating spectral embedding distortions, the proposed SF-SGL allows us to more efficiently identify the critical edges for constructing the learned graphs.
\item Our extensive experimental results show that the proposed method can produce a hierarchy of high-quality learned graphs in nearly-linear time for a variety of real-world, large-scale graphs and circuit networks. When compared with prior state-of-the-art spectral methods, such as SGL \cite{feng2021sgl}, the proposed SF-SGL can construct the learned graph in a much faster way with better graph quality.
\item The proposed method has been validated with the application of the data-driven EDA algorithm for vectorless power grid and thermal integrity verification for estimating worst-case voltage/temperature distributions of the entire chip, showing reliable verification accuracy and efficiency.
\end{enumerate}
}}
The rest of this paper is organized as follows: Section \ref{background_sec} introduces the background of graph learning techniques. Section \ref{main_sec} introduces the theoretical foundation of the original single-level spectral graph learning framework (SGL), which also includes the sample and algorithm complexity analysis. Section \ref{sec:solver_free} extends the SGL framework by introducing a more scalable solver-free multilevel graph learning approach (SF-SGL). Section
\ref{result_sec} demonstrates extensive experimental results for learning a variety of real-world, large-scale graph problems, as well as data-driven vectorless integrity verification tasks, which is followed by the conclusion of this work in Section \ref{conclusion}.
\section{Background}
\label{background_sec}
\subsection{Introduction to Graph Topology Learning}
Given $M$ observations on $N$ data entities in a data matrix $X=[x_1, ..., x_M]\in {\mathbb{R} ^{N\times M}}$, each column vector of $X$ can be considered as a signal on a graph. {For example, the MNIST data set \cite{lecun1998gradient}, which includes $70,000$ images of handwritten digits with each image having $784$ pixels, will result in a feature matrix $X\in {\mathbb{R} ^{N\times M}}$ with $N=70,000$ and $M=784$.} The recent GSP-based graph learning methods \cite{dong2016learning,kalofolias2016learn, egilmez2017graph,kalofolias2017large, dong2019learning} estimate graph Laplacians from $X$ for achieving the following two desired characteristics:
\begin{enumerate}
\item \textbf{Smoothness of graph signals.} The graph signals corresponding to the real-world data should be sufficiently smooth on the learned graph structure: the signal values will only change gradually across connected neighboring nodes.
\item \textbf{Sparsity of estimated Laplacians.} Graph sparsity is another critical consideration in graph learning. One of the most important motivations of learning a graph is to use it for downstream computing tasks. Therefore, more desired graph topology learning algorithms should allow better capturing and understanding the global structure (manifold) of the data set, while producing sufficiently sparse graphs that can be easily stored and efficiently manipulated in the downstream algorithms, such as circuit simulations/optimizations, network partitioning, dimensionality reduction, data visualization, etc.
\end{enumerate}
\subsection{Existing Methods for Graph Topology Learning}\label{sec:method}
\textbf{Problem formulation.} Consider a random vector $x\sim N(0,\Sigma)$ with probability density function:
\begin{equation}
f(x)=\frac{\exp{\left(-\frac{1}{2}x^\top \Sigma^{-1}x\right)}}{(2\pi)^{N/2}\det(\Sigma)^{(1/2)}}\propto \det(\Theta)^{1/2}\exp{\left (-\frac{1}{2}x^\top \Theta x\right )},
\end{equation}
where $\Sigma=\mathbb{E}[xx^\top]\succ 0$ denotes the covariance matrix, and $\Theta=\Sigma^{-1}$ denotes the precision matrix (inverse covariance matrix). Prior graph topology learning methods aim at estimating sparse precision matrix $\Theta$ from potentially high-dimensional input data, which fall into the following two categories:
\underline{\textbf{(A) The graphical Lasso}} method aims at estimating a sparse precision matrix $\Theta$ using convex optimization to maximize the log-likelihood of $f(x)$ \cite{friedman2008sparse}:
\begin{equation}\label{formula_lasso}
\max_{\Theta}: \log\det(\Theta)- Tr(\Theta S)-{\beta}{{\|\Theta\|}}^{}_{1},
\end{equation}
where $\Theta$ denotes a non-negative definite precision matrix, $S$ denotes a sample covariance matrix, and $\beta$ denotes a regularization parameter.
The first two terms together can be interpreted as the log-likelihood under a GMRF. $\|\bullet\|_1$ denotes the entry-wise $\ell_1$ norm, so ${\beta}{{\|\Theta\|}}^{}_{1} $ becomes the sparsity promoting regularization term. This model learns the graph structure by maximizing the penalized log-likelihood.
{When the sample covariance matrix $S$ is obtained from $M$ i.i.d (independent and identically distributed) samples $X=[x_1,...,x_M]$, where $X\sim N(0, S)$ has an $N$-dimensional Gaussian distribution with zero mean}, each element in the precision matrix $\Theta_{i,j}$ encodes the conditional dependence between variables $X_i$ and $X_j$. For example, $\Theta_{i,j}=0$ implies that variables $X_i$ and $X_j$
are conditionally independent, given the rest.
{\underline{\textbf{(B) The GSP-based Laplacian estimation}} methods have been recently introduced for more efficiently solving the following convex problem \cite{dong2019learning,lake2010discovering}:}
\begin{equation}\label{opt2}
{\max_{\Theta}}: F(\Theta)= \log\det(\Theta)- \frac{1}{M}Tr({X^\top \Theta X})-\beta {{\|\Theta\|}}^{}_{1},
\end{equation}
where {$\Theta={L}+\frac{1}{\sigma^2}I$}, ${L}$ represents the set of valid Laplacian matrices, where $Tr(\bullet)$ denotes the matrix trace, $I$ denotes the identity matrix, and $\sigma^2>0$ represents the prior feature variance. The three terms in (\ref{opt2}) correspond to the terms $\log\det(\Theta)$, $Tr(\Theta S)$ and ${\beta}{{\|\Theta\|}}^{}_{1}$ in (\ref{formula_lasso}), respectively. When every column vector in the data matrix $X$
is regarded as a graph signal vector, there is a close connection between the formulation in (\ref{opt2}) and the original graphical Lasso problem \cite{friedman2008sparse}.
Since {$\Theta={L}+\frac{1}{\sigma^2}I$} are symmetric and positive definite (PSD) matrices (or M matrices) with non-positive off-diagonal entries, this formulation will lead to the estimation of attractive GMRFs \cite{ dong2019learning, slawski2015estimation}.
{When $X$ is non-Gaussian}, the formulation in (\ref{opt2}) can be regarded as a
Laplacian estimation method by minimizing the Bregman divergence between positive definite matrices induced by the function $\Theta \mapsto -\log \det(\Theta)$ \cite{slawski2015estimation}.
\section{SGL: A Spectral Learning Approach}\label{main_sec}
\begin{figure}
\centering
\epsfig{file=overview2, width=0.4965\textwidth}
\caption{Overview of the proposed framework for graph topology learning. \protect\label{fig:sgloverview}}
\end{figure}
Consider $M$ linear measurements of $N$-dimensional voltage and current vectors stored in data matrices $X\in {\mathbb{R} ^{N\times M}}$ and $Y\in {\mathbb{R} ^{N\times M}}$, where the $i$-th column vector $X(:,i)$ is a voltage response (graph signal) vector corresponding to the $i$-th input current vector $Y(:,i)$. This work introduces a spectral graph learning method (SGL) for Laplacian matrix estimation by exploiting the linear voltage ($X$) and current ($Y$) measurements \cite{feng2021sgl}, as shown in Figure \ref{fig:sgloverview}.
\begin{figure*}
\centering
\epsfig{file=SGL_flow-cropped.pdf, width=0.9799598\textwidth}
\caption{SGL for spectral graph topology learning from voltage/current measurements. {($v_p$ and $v_s$ are node embedding vectors for node $p$ and $s$, $x_p$ and $x_s$ are voltage vectors for node $p$ and $s$.)} \protect\label{fig:sgl}}
\end{figure*}
To quantify the smoothness of a graph signal vector $x$ over a undirected graph $G=(V,E, w)$, the following Laplacian quadratic form can been adopted:
\begin{equation}\label{quad_form}
{x^\top}L x= \sum\limits_{\left( {s,t} \right) \in E}
{{w_{s,t}}{{\left( {x\left( s \right) - x\left( t \right)}
\right)}^2}},
\end{equation}
where $L=D-W$ denotes the graph Laplacian matrix, $w_{s,t}=W(s,t)$ denotes the weight for edge ($s,t$), while $D$ and $W$ denote the degree and the weighted adjacency matrices, respectively. {The smoothness of a set of signals }$X$ over graph $G$ can be computed using the following matrix trace \cite{kalofolias2016learn}:
\begin{equation}\label{trace}
Q(X,L)=Tr({X^\top L X}).
\end{equation}
\subsection{Gradient Estimation via Perturbation Analysis}\label{sec:theory}
Express the graph Laplacian matrix as follows
\begin{equation}\label{LaplacianEdge}
L=\sum\limits_{\left( {s,t} \right) \in E}
{w_{s,t}}e_{s,t}e^\top_{s,t},
\end{equation}
where ${e_{s}} \in \mathbb{R}^N$ denotes the standard basis vector with all zero entries except for the $s$-th entry being $1$, and ${e_{s,t}}=e_s-e_t$. By substituting (\ref{LaplacianEdge}) into (\ref{opt2}),
we have:
\begin{equation}\label{opt1}
\begin{split}
F &= \sum\limits_{i=1}^N \log (\lambda_i+\frac{1}{\sigma^2})
- \\&\frac{1}{M}\left(\frac{Tr(X^\top X)}{\sigma^2}+\sum\limits_{\left( {s,t} \right) \in E}
{w_{s,t}}\|X^\top e_{s,t}\|_2^2\right)-4 \beta \sum\limits_{\left( {s,t} \right) \in E}
{w_{s,t}},
\end{split}
\end{equation}
{{where ${\lambda _i}$ are non-decreasing eigenvalues of $L$ for $i=1, \cdots, N$. Given the eigenvalue ${\lambda _i}$ and the corresponding eigenvector $u_i$, it satisfies:}
\begin{equation}\label{eigen}
L u_i = \lambda_i u_i.
\end{equation}}
Taking the partial derivative of (\ref{opt1}) with respect to $w_{s,t}$ leads to:
\begin{equation}\label{optF}
\frac{\partial F}{\partial w_{s,t} } = \sum\limits_{i=1}^N \frac{1}{\lambda_i+1/\sigma^2} \frac{\partial \lambda_i}{\partial w_{s,t} }
- \frac{1}{M}\|X^\top e_{s,t}\|_2^2-4 \beta.
\end{equation}
The last two terms in (\ref{optF}) both imply constraints on graph sparsity: adding more edges will lead to a greater trace $Tr({X^\top \Theta X})$. Consequently, we can safely choose $\beta=0$ in the rest of this work, without impacting the ranking of candidate edges and thus the final solution quality of SGL.
\begin{theorem}\label{thm:pertub}
The spectral perturbation $\delta {\lambda _i} $ due to adding a candidate edge $({s,t})$ into the latest graph will be:
\begin{equation}\label{sc}
\delta {\lambda _i}= \delta w_{s,t}\left( {{{u_i^\top}e_{s,t}} } \right)^2.
\end{equation}
\end{theorem}
\begin{proof}
Consider the following spectral perturbation analysis:
\begin{equation}\label{formula_eig_perturb1}
\left( {L + \delta L} \right)\left( {{u_i} + \delta {u_i}} \right) = \left( {{\lambda _i} + \delta {\lambda _i}} \right)\left( {{u_i} + \delta {u_i}} \right),
\end{equation}
where a small perturbation $\delta L$ due to including a new edge $(s,t)$ is applied to $L$, which results in perturbed eigenvalues and eigenvectors ${\lambda _i} + \delta {\lambda _i}$ and ${u_i} + \delta {u_i}$ for $i=1,...,N$, respectively. By only keeping the first-order terms, we have:
\begin{equation}\label{formula_eig_perturb1_first_order}
{L}\delta {u_i} + {\delta L}{u_i} = {{\lambda _i}{\delta {u_i}} + \delta {\lambda _i}} {{u_i} }.
\end{equation}
Express $\delta u_i$ in terms of the original eigenvectors $u_i$ {{for}} $i=1,...,N$ as:
{{\begin{equation}\label{delta u_i}
{\delta {u_i}} = \sum\limits_{i = j}^{N} {{\alpha _j}{u_j}}.
\end{equation}}}
By substituting (\ref{delta u_i}) into (\ref{formula_eig_perturb1_first_order}), we have:
{{\begin{equation}\label{formula_eig_perturb1_first_order_expand}
{L}\sum\limits_{j = 1}^{N} {{\alpha _j}{u_j}} + {\delta L}{u_i} = {{\lambda _i}\sum\limits_{j = 1}^{N} {{\alpha _j}{u_j}} + \delta {\lambda _i}} {{u_i} }.
\end{equation}}}
After multiplying ${u_i^\top}$ to both sides of (\ref{formula_eig_perturb1_first_order_expand}) we have:
\begin{equation}\label{formula_eig_perturb1_conclusion}
\delta {\lambda _i} = \delta w_{s,t}\left( {{{u_i^\top}e_{s,t}} } \right)^2.
\end{equation}
\end{proof}
Subsequently, we construct the following eigensubspace matrix for spectral graph embedding using the first $r-1$ nontrivial Laplacian eigenvectors
\begin{equation}\label{subspace}
U_r=\left[\frac{u_2}{\sqrt {\lambda_2 +1/\sigma^2}},..., \frac{u_r}{\sqrt {\lambda_r +1/\sigma^2}}\right].
\end{equation}
Theorem \ref{thm:pertub} allows each edge's \textbf{spectral sensitivity} $s_{s,t}=\frac{\partial F}{\partial w_{s,t} }$ in (\ref{optF}) to be written as:
\begin{equation}\label{optF2}
\begin{split}
s_{s,t}&=\sum\limits_{i=1}^N \frac{1}{\lambda_i+1/\sigma^2} \frac{\partial \lambda_i}{\partial w_{s,t} }-\frac{1}{M}\|X^\top e_{s,t}\|_2^2\\
&= \|U_N^\top e_{s,t}\|_2^2
- \frac{1}{M}\|X^\top e_{s,t}\|_2^2\\
&\approx \|U_r^\top e_{s,t}\|_2^2
- \frac{1}{M}\|X^\top e_{s,t}\|_2^2\\
&=z_{s,t}^{emb}-\frac{1}{M}z_{s,t}^{data}, where ~~~r \ll N.
\end{split}
\end{equation}
In the above expressions, $z_{s,t}^{emb}=\|U_r^\top e_{s,t}\|^2_2$ and $z_{s,t}^{data}={\|X^\top e_{s,t}\|^2_2}{}$ denote the $\ell_2$ distances in the spectral embedding space as well as the data (voltage measurement) vector space, respectively. The partial derivative term $s_{s,t}$ in (\ref{optF2}) can be leveraged for solving the optimization task in (\ref{opt2}) using gradient-based methods, such as the general stagewise algorithm for group-structured learning \cite{tibshirani2015general}.
\subsection{Spectral Densification for Graph Topology Learning}
\textbf{Spectrally-critical edges.} We define the {spectral embedding distortion} $\eta_{s,t}$ of an edge $(s, t)$ to be:
\begin{equation}\label{embedDist}
\eta_{s,t}=M\frac{ z_{s,t}^{emb}}{z_{s,t}^{data}}.
\end{equation}
We also call the candidate edge $(p, q)$ that has a relatively large spectral sensitivity ($s_{p,q}$) or embedding distortion {{$ {\eta_{p,q}}=M{z_{p,q}^{emb}}/{z_{p,q}^{data}}$}} a {spectrally-critical edge}.
\textbf{The proposed SGL iterations.} Let's consider the $(k+1)$-th SGL iteration for finding a few most spectrally-critical candidate edges with the largest spectral sensitivities (or embedding distortions) to be added into the latest graph $G_k=(V_k,E_k, w_k)$.
(\ref{optF2}) implies that including such edges into the latest graph $G_k$ will more effectively improve the objective function and significantly mitigate the spectral embedding distortions.
\textbf{Spectral graph sparsification (prior work).} Prior research shows that for every undirected graph there exists a sparsified graph with $O (\frac{N\log N}{\epsilon^2})$ edges that can be obtained by sampling each edge $(p, q)$ with a probability (leverage score) $p_{e}$ proportional to its effective resistance \cite{spielman2011graph}:
\begin{equation}\label{equ:resist}
p_e\propto \frac{R^{\textit{eff}}_{p,q}}{R^{}_{p,q}}=w_{p,q}R^{\textit{eff}}_{p,q},
\end{equation}
where $R^{}_{p,q}=1/w_{p,q}$ represents the original resistance and $R^{\textit{eff}}_{p,q}$ is the edge effective resistance. In addition, the following inequality will be valid \cite{spielman2011graph}:
\begin{equation}\label{equ:spectralspar}
\forall x \in \mathbb{R}^N~~~ (1-\epsilon){x^\top}L x \le {x^\top}\Tilde{L} x \le (1+\epsilon){x^\top}L x,
\end{equation}
where $L$ and $\Tilde{L}$ are the original and sparsified graph Laplacian matrices, respectively.
\textbf{Spectral graph densification.} For any candidate edge selected based on its spectral sensitivity during an SGL iteration, by setting its weight as:
\begin{equation}\label{equ:edgeweight}
{w_{p,q}}\propto\frac{1}{z_{p,q}^{data}},
\end{equation}
the spectral embedding distortion can be estimated as follows
\begin{equation}\label{equ:embdist}
{{\eta_{p,q}}=M\frac{z_{p,q}^{emb}}{z_{p,q}^{data}} \propto w_{p,q} R^{\textit{eff}}_{p,q},}
\end{equation}
which becomes the leverage score for spectral graph sparsification \cite{spielman2011graph}. Consequently, as opposed to spectral sparsification, SGL can be regarded as a {spectral graph densification} procedure that aims to identify and include $O (N\log N)$ spectrally-critical edges with large spectral sensitivities (embedding distortions).
\textbf{Algorithm convergence.} The optimal solution of (\ref{opt2}) can be achieved when the maximum edge sensitivity ($s_{max}$) in (\ref{optF2}) becomes zero or equivalently when the maximum spectral embedding distortion ($\eta_{max}$) in (\ref{embedDist}) becomes one. Moreover, upon the convergence of SGL iterations, the spectral embedding (effective-resistance) distances on the learned graphs will encode the $\ell_2$ distances between the original data points (voltage measurements), which can be exploited in many important tasks, such as VLSI CAD, manifold learning, dimensionality reduction, and data visualization \cite{zhao:dac19,belkin2003laplacian,carey2017graph,imre2020spectrum}.
\subsection{Sample Complexity of the SGL Algorithm}
The sample complexity of SGL can be obtained by analyzing the required number of voltage vectors (measurements) for accurate graph learning. We assume $\sigma^2\rightarrow +\infty$. For the ground-truth graph $G_*$, we define its edge weight matrix $W_*$ to be a diagonal matrix with $W_*(i,i)=w_i$, and its injection matrix as:
\begin{equation}
B_*(i,p)=\begin{cases}
1 & \text{ if } p \text{ is i-th edge's head}\\
-1 & \text{ if } p \text{ is i-th edge's tail} \\
0 & \text{ otherwise }.
\end{cases}
\end{equation}
Consequently, the Laplacian matrix of $G_*$ can be written as
\begin{equation}\label{effRes2}
L_*=B_*^\top W_* B_*.
\end{equation}
Therefore, the effective resistance $R_*^\textit{eff}({s,t})$ between nodes $s$ and $t$ can be expressed as:
\begin{equation}\label{effRes2}
R_*^\textit{eff}({s,t})=e^\top_{s,t}L_*^+e_{s,t}=\|W_*^{\frac{1}{2}} B_*L_*^{+}e_{s,t}\|_2^2,
\end{equation}
where $L^+_*$ represents the Moore–Penrose pseudoinverse of $L_*$. According to the Johnson-Lindenstrauss Lemma, the effective-resistance distance for every pair of nodes satisfies \cite{spielman2011graph}:
\begin{equation}\label{effResJL}
(1-\epsilon)R_*^\textit{eff}({s,t})\le\|X^\top e_{s,t}\|_2^2 \le (1+\epsilon)R_*^\textit{eff}({s,t}),
\end{equation}
where the data (voltage measurement) matrix $X\in \mathbb{R}^{N\times M}$ is created by going through the following steps:
\begin{enumerate}
\item Let $C$ be a random $\pm \frac{1}{\sqrt{M}}$ matrix of dimension $M\times |E|$, where $|E|$ denotes the number of edges and $M=24 \log \frac{N}{\epsilon^2}$ denotes the number of voltage measurements;
\item Construct $Y=CW_*^{\frac{1}{2}}B_*$, with the $i$-th row vector denoted by $y^\top_i$;
\item Solve $L_* x_i= y_i$ for all rows in $C$ ($1 \le i\le M$), and construct $X$ matrix using $x_i$ as its $i$-th column vector.
\end{enumerate}
Obviously, (\ref{effResJL}) implies that given $M\ge O(\log {N}/{\epsilon^2})$ voltage vectors (measurements) obtained through the above procedure, $(1\pm \epsilon)$-approximate effective resistances can be computed by
\begin{equation}
\tilde R_*^\textit{eff}(s,t)=\|X^\top e_{s,t}\|_2^2
\end{equation}
for any pair of nodes $(s,t)$ in the original graph $G_*$. Consider the following close connection between effective resistances and spectral graph properties (such as the first few Laplacian eigenvalues/eigenvectors):
\begin{equation}\label{formula_Reff}
R^\textit{eff}_{s,t}=\|U_N^\top e_{s,t}\|^2_2,~\text{where~} U_N=\left[\frac{u_2}{\sqrt {\lambda_2}},..., \frac{u_N}{\sqrt {\lambda_N}}\right].
\end{equation}
Therefore, using $O(\log {N})$ voltage measurements would be sufficient for SGL to learn an $N$-node graph for well preserving the original graph effective-resistance distances.
\subsection{Key Steps in the SGL Algorithm}\label{sec:overview}
To achieve good runtime and memory efficiency in graph learning tasks that may involve a large number of nodes, the proposed SGL algorithm strives to iteratively identify and include the most influential (spectrally-critical) edges into the latest graph until no such edges can be found, through the following key steps, as shown in Figure \ref{fig:sgl}:
\textbf{Step 1: Initial graph construction.}
(\ref{optF2}) implies that by iteratively identifying and adding the most influential edges (with the largest sensitivities) into the latest graph, the graph spectral embedding (or effective-resistance) distance will encode the $\ell_2$ distances between the original data (voltage measurement) vectors.
{ The ideal pool of candidate edges should include all possible edge connections, e.g. forming a complete graph with $O(N^2)$ edges for $N$ data samples. The proposed graph learning algorithm can be better understood through the following steps: a) each initial edge weight of the complete graph is set to be a very small value (close to zero); b) the edge weight with the highest spectral sensitivity will be updated with a greater value; c) repeat step b) until no edge can be updated (no positive edge sensitivity exists). The above iterative scheme is equivalent to starting with no edge connectivity. However, considering all edge connections will require the quadratic complexity, which may lead to rather poor runtime scalability.}
To achieve a better runtime scalability, $k$-nearest-neighbor (kNN) graph \cite{malkov2018efficient} can be leveraged as a sparsified complete graph. {Note that when the effective-resistance distances encode the Euclidean distances between data samples, the proposed graph learning iterations will converge. This implies that when the learned graph has a tree-like structure, the effective-resistance distances will approximately match the shortest path distances and thus encode the Euclidean distances between data samples. Therefore, Euclidean distance becomes a natural choice for kNN graph construction.}
However, choosing an optimal $k$ value (the number of nearest neighbors) for constructing kNN graphs can still be challenging for general graph learning tasks: choosing a too large $k$ allows well approximating the global structure of the manifold for the original data points (voltage measurements), but will result in a rather dense graph; choosing a too small $k$ may lead to many small isolated graphs, which may slow down the iterations.
Since circuit networks are typically very sparse (e.g. 2D or 3D meshes) in nature, the voltage or current measurements (vectors) usually lie near low-dimensional manifolds, which allows choosing a proper $k$ for our graph learning tasks. To achieve a good trade-off between complexity and quality, the initial graph will be set up through the following steps: \textbf{(1)} Construct a connected kNN graph with a relatively small $k$ value (e.g. $5\le k \le 10$), which will suffice for approximating the global manifold corresponding to the original measurement data; \textbf{(2)} Sparsify the kNN graph by extracting a maximum spanning tree (MST) that can serve as a reasonably good initial graph in practice. Later, SGL will incrementally improve the graph by iteratively adding the most influential off-tree edges from the initial kNN graph until convergence. {As shown in Figure \ref{fig:objknn}, using different k values will not significantly impact the final objective function value after going through the proposed graph learning iterations.}
\textbf{Step 2: Spectral graph embedding.}
Spectral graph embedding leverages the first few Laplacian eigenvectors for mapping nodes onto low-dimensional space \cite{belkin2003laplacian}. The eigenvalue decomposition of Laplacian matrix is usually the computationally demanding in spectral graph embedding, especially for large graphs. To achieve good scalability, it is possible to exploit recent fast Laplacian eigensolvers with nearly-linear time complexity \cite{zhao2021wsdm}.
\textbf{Step 3: Influential edge identification.}
Given the first few Laplacian eigenvalues and eigenvectors, SGL will efficiently identify the most influential off-tree edges by looking at each candidate edge's sensitivity score defined in (\ref{optF2}). Specifically, each off-tree edge that belongs to the kNN graph will be sorted according to its edge sensitivity. Only a few most influential edges with the largest sensitivities will be included into the latest graph. Note that when $r\ll N$, the following inequality holds for any edge $(s, t)$:
\begin{equation}\label{distBound}
\|U_r^\top e_{s,t}\|^2_2=z_{s,t}^{emb} < \|U_N^\top e_{s,t}\|^2_2 \le R^\textit{eff}({s,t}),
\end{equation}
which implies that the edge sensitivities ($s_{s,t}$) approximately computed using the first $r$ eigenvectors will always be lower than the actual values. It is obvious that using more eigenvectors for spectral embedding will lead to more accurate estimation of edge sensitivities. For typical circuit networks, edge sensitivities computed using only a small number (e.g. $r<10$) of eigenvectors will be sufficiently accurate for ranking the off-tree edges.
\textbf{Step 4: Convergence checking.}
In this work, we examine the maximum edge sensitivities computed by (\ref{optF2}) for checking the convergence of SGL iterations. If there exists no off-tree edge that has a sensitivity greater than a given threshold ($s_{max}\ge tol$), the SGL iterations will be terminated. We note that choosing different tolerance ($tol$) levels will result in graphs with different densities. For example, choosing a smaller threshold will result in more edges to be included so that the final spectral embedding distances on the learned graph can more accurately encode the distances between the original data points (voltage measurements).
\textbf{Step 5: Spectral edge scaling.}
To further improve the spectral approximation quality, we choose to globally scale up edge weights of the learned graph obtained via SGL. Given the ground truth Laplacian matrix ${L_*}$, the effective resistance between nodes $s$ and $t$ can be represented as $R_{s,t}^{\textit{eff}}= e_{s,t}^T {L^+_*}{e}_{s,t}$. If we consider the graph as a resistor network with each conductance value corresponding to each edge weight, $R_{s,t}^{\textit{eff}}$ can be regarded as the power dissipation of the resistor network when a unit current is flowing into node $s$ and out from node $t$. By relaxing the vector $\mathbf{e}_{s,t}$ with a random vector $y_i$ that is orthogonal to the all-one vector, it can be shown that matching the power dissipations between the original graph and the learned graph will immediately lead to improved spectral approximation of the learned graph. Given the normalized current vectors $Y = (y_1, \cdots, y_M)$, corresponding measurement (voltage) vectors $X = (x_1, \cdots, x_M)$ and $\tilde{X} = (\tilde{x}_1, \cdots, \tilde{x}_M)$ can be computed for the original graph and the learned graph, respectively, where $x_i = {L^+_*} y_i$ and $\tilde{x}_i = L^+y_i$. To better match the structural properties of the original graph, we propose to globally scale up the edge weights in learned graph:
\begin{equation}\label{scaling2}
w_{s,t}= w_{s,t}*\alpha'
\end{equation}
with the following scaling factor $\alpha'$:
\begin{equation}\label{eqn:scaling}
\alpha' = \frac{1}{M}\sum_{i=1}^{M}{\frac{y_i^\top L^+y_i}{y_i^\top {L^+_*} y_i}} = \frac{1}{M}\sum_{i=1}^{M}{\frac{y_i^\top \tilde{x}}{y_i^\top x_i}}.
\end{equation}
\subsection{Algorithm Flow and Complexity of SGL }\label{main:complexity}
The detailed SGL algorithm flow has been shown in Algorithm \ref{alg:sgl}. All the aforementioned steps in SGL can be accomplished in nearly-linear time by leveraging recent high-performance algorithms for kNN graph construction \cite{malkov2018efficient}, spectral graph embedding for influential edge identification \cite{zhao:dac19,zhao2021wsdm}, and fast Laplacian solver for edge scaling \cite{miller:2010focs,zhiqiang:iccad17}. Consequently, each SGL iteration can be accomplished in nearly-linear time, whereas the state-of-the-art methods require at least $O(N^2)$ time \cite{dong2019learning}.
\begin{algorithm}
{ \caption{The SGL Algorithm Flow.} \label{alg:sgl}
\textbf{Input:} The voltage measurement matrix $X \in {\mathbb{R} ^{N\times M}}$, input current measurement matrix $Y \in {\mathbb{R} ^{N\times M}}$, $k$ for initial kNN graph construction, $r$ for constructing the projection matrix in (\ref{subspace}), the maximum edge sensitivity tolerance ($tol$), and the edge sampling ratio ($0 < \beta \le 1$). ~~~\textbf{Output:} The learned graph $G=(V, E, w)$.\\
\begin{algorithmic}[1]
\STATE {Construct a kNN graph $G_{o}=(V, E_o, w_o)$ based on $X$.}
\STATE {Extract an MST subgraph $T$ from $G_{o}$. }
\STATE {Assign $G=T=(V, E, w)$ as the initial graph. }
\WHILE{$s_{max} \ge tol$}
\STATE{Compute the projection matrix $U_r$ with (\ref{subspace}) for the latest graph $G$.}
\STATE{Sort off-tree edges $(s,t)\in E_o\setminus E$ according to their sensitivities computed by $s_{s,t}=\frac{\partial F}{\partial w_{s,t} }$ using (\ref{optF2}).}
\STATE{Include an off-tree edge $(s, t)$ into $G$ if its $s_{s, t}>tol$ and it has been ranked among the top $\ceil{ N{\beta}}$ edges. }
\STATE{Record the maximum edge sensitivity $s_{max}$. }
\ENDWHILE
\STATE{Do spectral edge scaling using $X$ and $Y$ following (\ref{scaling2});}
\STATE {Return the learned graph $G$.}
\end{algorithmic}
}
\end{algorithm}
\vspace{-0pt}
\section{SF-SGL: Solver-Free Spectral Graph Learning} {\label{sec:solver_free}}
\begin{figure*}[!htb]
\minipage{0.32451\textwidth}
\includegraphics[width=\linewidth]{feature_graph.pdf}
\caption{Graph coarsening by local embedding.}\label{fig:coarsening}
\endminipage\hfill
\minipage{0.265\textwidth}
\includegraphics[width=\linewidth]{mapping.pdf}
\caption{Graph learning from bottom up. }\label{fig:backward}
\endminipage\hfill
\minipage{0.39074053\textwidth}%
\includegraphics[width=\linewidth]{embedding.pdf}
\caption{ Influential off-tree edge identification. }\label{fig:emebedding}
\endminipage
\end{figure*}
\textbf{Overview of SF-SGL.} In this work, we extend SGL by introducing {a solver-free}, multilevel spectral graph learning scheme (SF-SGL).
The key procedures in SF-SGL are described as follows:
(1) given the measurement vectors, such as voltage and current matrices $X$ and $Y$, a hierarchy of coarse level kNN graphs will be constructed by exploiting a scalable spectral graph coarsening framework \cite{zhao2021wsdm}, as shown in Figure \ref{fig:coarsening}; (2) the SGL algorithm will be leveraged for graph learning starting from the coarsest level: an MST is first extracted, which is followed by a procedure for identifying spectrally-critical off-tree edges (that belong to the coarsest kNN graph) with large embedding distortions that can be efficiently computed by exploiting a solver-free local spectral graph embedding scheme; (3) after SGL converges at the coarsest level, the learned graph will be progressively mapped to the finer levels, as show in Figure \ref{fig:backward}, where additional candidate edges (that belong to the coarsened kNN graphs) will be identified and included into the latest graphs with updated local embedding vectors, as shown in Figure \ref{fig:emebedding}. Once the learned graph is obtained, the proposed framework and learned graph can be efficiently applied in different tasks. One immediate application is to facilitate the vectorless power grid and thermal integrity verification, as shown in Figure \ref{fig:overview_sfsgl}.
In the rest of this paper, given an initial kNN graph ${G}_{0}= {G}$, a series of coarsened kNN graphs ${G}_1, {G}_2,...,{G}_{l_f}$ will be generated via the spectral graph coarsening \cite{zhao:dac19}, where ${G}_{l_f}$ denotes the coarsest kNN graph. The multilevel learned graphs are denoted by ${P}_0, {P}_1,...,{P}_{l_f}$. For the sake of simplicity, all the symbols used in this paper are summarized in Table \ref{tab:symbols}.
\begin{center}
\begin {table}
\caption {Summary of symbols in the SF-SGL framework ($l=0,1,...,{l_f} , i=1,...,n_l$).} \label{tab:symbols}
\resizebox{\columnwidth}{!}{
\begin{tabular}{|c c|c c|}
\hline
symbols & description & symbols & description \\ \hline
$\Theta$ & precision matrix & $\mathcal{C}$ & sample covariance matrix \\
${H}_l$ & coarsening operator & ${X}_l$ & feature matrix at level $l$ \\
${z}_{p,q}^{data}$ & data distance & ${z}_{p,q}^{emb}$ & embedding distance \\
${s}_{p,q}$ & spectral sensitivity & ${\eta}_{p,q}$ & distortion \\
${G}_l=({V}_l,{E}_l)$ & an undirected graph at level $l$ & ${P}_l=(V_l,E_l)$ & the learned graph\\
${\omega_{l}(p,q)}$ & weight of edge $(p, q)$ for ${G}_l$ & $\tilde{\omega}_l(p,q)$ & weight of edge $(p, q)$ for ${P}_l$\\
${E}_l$ & edge set of ${G}_l$ & $\tilde{E}_l$ & edge set of ${P}_l$\\
$m_l=|{E}_l|$ & number of edges in ${G}_l$ & $\tilde{m}_l=|\tilde{E}_l|$ & number of edges in ${P}_l$ \\
${V}_l$ & node set at level $l$ & ${n}_l=|{V}_l|$ & number of nodes \\
${L}_{{G}_l}$ & Laplacian of graph ${G}_l$ &${L}_{P_l}$ & Laplacian of graph ${P}_l$\\
$u_{l}^{(i)}$ and $\tilde{u}_{l}^{(i)}$ & eigenvectors of $L_{G_l}$ and $ L_{P_l}$&
$\lambda_{l}^{(i)}$ and $\tilde{\lambda}_{l}^{(i)}$ & eigenvalues of of $L_{G_l}$ and $L_{P_l}$ \\
\hline
\end{tabular}}
\end{table}
\end{center}
\subsection{Spectral Graph Coarsening
}\label{sec:sfgrass}
\textbf{Node aggregation sets for graph coarsening.} {{As shown in Figure \ref{fig:coarsening}, coarsening the graph from $G_{l-1}$ to $G_l$ requires to cluster the node set $V_{l-1}$ of $G_{l-1}$ into $n_l$ different node aggregation sets $S^{(i)}_{l-1}$ with $i=1,..., n_l$. The subgraph $G_{l-1}[S^{(i)}_{l-1}]$ induced by each node aggregation set $S^{(i)}_{l-1}$ will be a strongly-connected component in graph $G_{l-1}$, which will be aggregated into a single node in the coarser graph $G_l$. Consequently, once the node aggregation sets are determined, a node-mapping matrix $H_{l}$ can be uniquely constructed accordingly, which allows creating $G_{l}$ as follows:
\begin{equation}
L_{G_{l}}:=H_{l}^{\mp}L_{G_{l-1}}H_{l}^{+}, \quad x_{l}:=H_{l}x_{l-1},
\end{equation}
where ${H}_{l} \in \mathbb{R}^{n_{l}\times n_{l-1}}$, $x_{l}\in \mathbb{R}^{n_l\times 1}$, $l=1,...,l_f$, and $H_{l}^\top,H_{l}^+,H_{l}^\mp$ denote the transpose, pseudoinverse, and transposed pseudoinverse of $H_{l}$, respectively. $H_{l} $ and $H_{l}^+$ can be constructed as follows \cite{loukas2019graph}:
{\small\begin{equation}
H_{l}(i,p)=\begin{cases}
\frac{1}{{|S^{(i)}_{l-1}|}} & \text{if p} \in S_{l-1}^{(i)} \\
0 & \text{otherwise } .
\end{cases}
\text{, }
H^+_{l}(p,i)=\begin{cases}
1 & \text{if p} \in S_{l-1}^{(i)} \\
0 & \text{otherwise. }
\end{cases}
\end{equation}}
}}
\textbf{Spectral coarsening via local embedding.} The key to spectral coarsening in SF-SGL is to determine the node aggregation sets. To this end, a low-pass graph filtering scheme has been adopted for local spectral embedding, which can be achieved in linear time \cite{zhao:dac19}. Let $b_{l}^{(k)}\in \mathbb{R}^{n_l\times 1}$ with $k=1,\cdots,K$ be the initial random vectors which are orthogonal to the all-one vector. After applying a few steps of Gaussian-Seidel relaxations for solving the linear system of equations $L_{G_{l}} b_{l}^{(k)}=0$ with $k = 1, \cdots, K$
\cite{livne2012lean}, we can associate each node in the graph $G_l$ with a $K$-dimensional vector using the embedding matrix $B_l=[b_{l}^{(1)},...,b_{l}^{(K)}]$. Since each $b_{l}^{(k)}$ can be considered as the linear combinations of the first few Laplacian eigenvectors after smoothing (low-pass filtering), the embedding matrix $B_l$ can well approximate the eigensubspace matrix $U_r$ in (\ref{subspace}). Consequently, the nodes that are close to each other in the spectral embedding space can be clustered into the same aggregation set. After finding all node aggregation sets, the node mapping matrix $H_{l}$ that uniquely determines a coarse-level graph can be formed.
Subsequently, the node feature matrix at level $l$ can also be obtained by $X_l=H_lX_{l-1}$, as shown in Figure \ref{fig:coarsening}. To better encode the feature information on the coarsened graph, we propose the following scheme for updating edge weight between neighbouring nodes $s$ and $t$ based on their feature distance:
\begin{equation}
\omega_l(s,t)=1/\|X_l^\top e_{s,t}\|^2_2.
\end{equation}
\textbf{Bounding approximation errors.} To ensure the solution quality of the proposed graph learning framework, it is important to estimate and bound the errors due to spectral graph coarsening. Graph ${{G}_{l}}$ is considered as a good approximation of its finer version ${G}_{l-1}$ if the following holds \cite{loukas2019graph}:
\begin{equation}
\begin{split}
\gamma_1 \lambda_{l-1}^{(i)}\leq
\lambda_{l}^{(i)}\leq\gamma_2 {\small{\frac{(1+\epsilon)^2}{1-\tau\epsilon^2}}} \lambda_{l-1}^{(i)}
\\
\frac{1}{\sigma_{l-1}}\|u^{(i)}_{l-1}\|_{L_{G_{l-1}}}\leq \|u^{(i)}_{l}\|_{L_{G_{l}}}\leq \sigma_{l-1}\|u^{(i)}_{l-1}\|_{L_{G_{l-1}}},
\end{split}
\end{equation}
where $l=1,...,l_f$, $\lambda_{l}^{(1)},..,\lambda_{l}^{(K)}$ denote the $K$ non-decreasing eigenvalues of $L_{G_{l}}$, $ \tau=\lambda^{(K)}_{l-1}/\lambda^{(2)}_{l-1}$, $\epsilon=(\sigma_{l-1}^2-1)/(\sigma_{l-1}^2+1)$ with $\sigma_{l-1}\leq (\frac{1+\sqrt{\tau}}{1-\sqrt{\tau}})^{\frac{1}{2}}$, and $\gamma_1 (\gamma_2$) denotes the smallest (largest) eigenvalue of $(H_lH_l^\top)^{-1}$.
\subsection{ Graph Topology Learning via A Bottom-up Approach}
\textbf{A spectrum decomposition perspective.} As shown in \cite{zhang2020sf}, the spectrally-coarsened graphs will carry different (spectrum) bandwidths of the original graph $G$. For example, the coarsest graph Laplacian $L_{G_{l_f}}$ will only preserve the key spectral properties of ${G_{0}}$, such as the first few Laplacian eigenvalues and eigenvectors, whereas the Laplacians of the increasingly finer graphs will match the lower to moderate eigenvalues of $L_{G_{0}}$. Consequently, {the coarsened graphs can be considered as a cascade of low-pass graph filters} with gradually decreasing bandwidths: the finest graph retains the highest bandwidth, whereas the coarsest graph retains the lowest bandwidth.
\textbf{Mapping the learned graphs to finer levels.} SF-SGL strives to {progressively form a series of increasingly finer graphs such that the spectral embedding distortions can be significantly mitigated}. As shown in Figure \ref{fig:backward}, to map the learned graph $P_l$ to a finer level, two different types of edges will be formed for constructing the graph $P_{l-1}$ at the $(l-1)$-th level: (1) any node in $P_{l}$ corresponds to a node aggregation set in $P_{l-1}$, in which an MST will be extracted to form the \textbf{inner-cluster edges}; (2) any edge in $P_{l}$ corresponds to at least one edge connecting between the two node aggregation sets in $P_{l-1}$, while only the edge with the largest weight will be kept as the \textbf{inter-cluster edge} for constructing $P_{l-1}$.
\textbf{Spectrally-critical edges at coarse levels.} As shown in Figure \ref{fig:emebedding}, in order to identify and include spectrally-critical off-subgraph edges with large spectral embedding distortions, the aforementioned local spectral embedding will be applied for graph $P_{l-1}$ to generate its embedding matrix $B'_{l-1}=[b_{l-1}^{(1)},\cdots,b_{l-1}^{(K)}]$.
The spectral embedding distortion of the coarse level graph $P_{l-1}$ can be computed as
\begin{equation}
\eta_{s,t}={z_{s,t}^{emb}}/{z_{s,t}^{data}},
\end{equation}
where $z_{s,t}^{emb}=\|B_{l-1}^{'\top} e_{s,t}\|^2_2$ and $z^{data}_{s,t} =\| X_{l-1}^\top e_{s,t}\|^2_2$.
A larger embedding distortion of an off-subgraph edge indicates that including this edge into the learned graph will more precisely encode the distances between the data points.
Note that the edges identified by SF-SGL on the coarsest graph will tend to connect the most distant nodes for drastically mitigating long-range spectral embedding distortions, thereby impacting only the first few Laplacian eigenvalues (low-frequency band); on the other hand, the edges identified on the finest graph will tend to only connect local nodes for mitigating short-range embedding distortions, thereby impacting relatively large eigenvalues (high-frequency band).
\subsection{Algorithm Flow and Complexity of SF-SGL }\label{main:complexity}
The proposed multilevel graph learning framework (SF-SGL) allows a flexible decomposition of the entire graph spectrum (to be learned) into multiple different eigenvalue clusters, such that the most spectrally-critical edges that are the key to mitigating various ranges of spectral embedding distortions can be more efficiently identified.
Algorithm \ref{alg:directed_graph_spar} shows the algorithm flow for the proposed SF-SGL framework. All the aforementioned steps in SF-SGL can be accomplished in nearly-linear time by leveraging recent high performance algorithms for kNN graph construction \cite{malkov2018efficient}, solver-free spectral graph coarsening and embedding, as well as fast Laplacian solver. Consequently, SF-SGL can be accomplished in nearly-linear time
\begin{algorithm}[!htbp]
\small { \caption{The SF-SGL algorithm flow.} \label{alg:directed_graph_spar}
\begin{flushleft}
\hspace*{\algorithmicindent} \textbf{Input:} Voltage and current measurement matrices: $X \textit{, } Y\in \mathbb{R}^{N\times M}$, $k$ for initial kNN graph construction;\\
\hspace*{\algorithmicindent} \textbf{Output:} Learned graph $P$;
\end{flushleft}
\begin{algorithmic}[1]
\STATE{$P_{l} = \emptyset$ for $l = 0, ..., l_f$};\\
\STATE{Construct an initial kNN graph $G$ as $G_0$ based on X};\\
\STATE{ Perform spectral graph coarsening to get a series of coarsened kNN graphs ${G_1},...,{G_{l_f}}$ as well as the coarsening operators $H_1,...,H_{l_f}$ };\\
\STATE{Let $X_0=X$ and calculate the feature matrices ${X_1},...,{X_{l_f}}$ by $X_{l}=H X_{l-1} $ for $l = 1, ..., l_f$; }\\
\STATE{ Set $l = l_f$ and learn a sparse graph $P_{l}$ through SGL iterations; }\\
\WHILE{ $ l\ge1$}
\FOR{each node $i \in V_l$}
\STATE{Find the induced subgraph $G_{l-1}[S_{l-1}^{(i)}]$ w.r.t. the aggregation set $S_{l-1}^{(i)}$; } \\
\STATE{Extract the MST of the induced subgraph $G_{l-1}[S_{l-1}^{(i)}]$ and add its edges into $P_{l-1}$ };
\ENDFOR
\FOR{each edge $(s,t) \in \tilde{E}_l$}
\STATE{Add the edge with maximum weight between sets $S_{l-1}^{(s)}$ and $S_{l-1}^{(t)}$ into graph $P_{l-1}$} ;
\ENDFOR
\STATE{Compute $\eta_{s,t}$ for each candidate edge $(s,t) \in E_{l-1}\setminus \tilde{E}_{l-1}$};
\STATE{Add the candidate edges with large $\eta_{s,t}$ values into $P_{l-1}$};
\STATE{$l=l-1$}
\ENDWHILE\\
\STATE{Scale up the edge weights in $P_0$ and return the learned graph ${P}$}.
\end{algorithmic} }
\end{algorithm}
\section{Experimental Results}\label{result_sec}
The proposed SGL and SF-SGL algorithms have been implemented in Matlab and $C$++. The test cases in this paper have been selected from a great variety of matrices that have been used in circuit simulation and finite element analysis problems. Note that the prior state-of-the-art graph learning algorithms \cite{egilmez2017graph} can take excessively long time even for very small graphs. For example, learning the test case ``airfoil" graph with $4,253$ nodes using the CGL algorithm \cite{egilmez2017graph} can not be completed after $12$ hours, whereas the proposed SGL algorithm only takes about $4$ seconds to achieve a high-quality solution; learning the ``yaleShieldBig" graph with $1,059$ nodes using CGL takes $1,235$ seconds, whereas SGL only takes about $2$ seconds (over $600\times$ speedups) for achieving similar solution (spectrum preservation) quality. Therefore, in this work we will only compare with the graph construction method based on the standard kNN algorithm. All of our experiments have been conducted using a single CPU core of a computing platform running 64-bit RHEW 7.2 with a $2.67$GHz 12-core CPU and $50$ GB memory.
\vspace{-0pt}
\subsection{Experimental Setup}
To create the linear voltage and current measurements, the following procedure has been applied: (1) we first randomly generate $M$ current source vectors with each element sampled from a standard normal distribution; (2) each current vector will be normalized and orthogonalized to the all-one vector; (3) $M$ voltage vector measurements will be collected by solving the original graph Laplacian matrix with the $M$ current vectors as the (right-hand-side) input vectors; (4) the voltage and current vectors will be stored in data matrices $X=[x_1,...,x_M]$ and $Y=[y_1,...,y_M] \in {\mathbb{R} ^{N\times M}}$, respectively, which will be used as the input data of the proposed SGL and SF-SGL algorithms. By default, $M=50$ is used for generating the voltage and current measurements. By default, we choose $k=5$ for constructing the kNN graph for all test cases in SGL, and set $r=5$ for constructing the spectral embedding matrix in (\ref{subspace}). The edge sampling ratio $\beta=10^{-3}$ has been used. The SGL iterations will be terminated if $s_{max}<tol=10^{-12}$. When approximately computing the objective function value (\ref{opt2}), the first $50$ nonzero Laplacian eigenvalues are used.
To visualize the structure of each graph, the spectral graph drawing technique has been adopted \cite{koren2003spectral}: to generate the 2D graph layouts, each entry of the first two nontrivial Laplacian eigenvectors ($u_2, u_3$) will be used as the $x$ or $y$ coordinate for embedding each node (data point), respectively. We also assign the nodes with the same color if they belong to the same node cluster determined by spectral graph clustering \cite{zhao2021wsdm}.
\vspace{-0pt}
\subsection{Comprehensive Results for Graph Learning with SGL}
\textbf{Algorithm convergence.} As shown in Figure \ref{fig:distRes}, for the ``2D mesh" graph ($|V|=10,000$, $|E|=20,000$) learning task, SGL requires about $40$ iterations to converge to $s_{max}\le 10^{-12}$ when starting from an initial MST of a 5NN graph.
\begin{figure}
\centering\includegraphics[width=0.795\linewidth]{convergence.pdf}
\caption{The decreasing maximum sensitivities (``2D mesh" graph). }\label{fig:distRes}
\end{figure}
\begin{figure}
\centering\includegraphics[width=0.7985\linewidth]{convergence4elt.pdf}
\caption{The objective function values (``fe\_4elt2" graph). }\label{fig:compKNN}
\end{figure}
\textbf{Comparison with kNN graph.} As shown in Figure \ref{fig:compKNN}, for the ``fe\_4elt2" graph ($|V|=11,143$, $|E|=32,818$) learning task, SGL converges in about $90$ iterations when starting from an initial MST of a 5NN graph. For the 5NN graph, we do the same spectral edge scaling. As shown in Figures \ref{fig:compKNN} and \ref{fig:compKNN2}, the SGL-learned graph achieves a more optimal objective function value and a much better spectral approximation than the 5NN graph. As observed, the SGL-learned graph has a density similar to a spanning tree, which is much sparser than the 5NN graph.
\begin{figure}[!htb]
\centering\includegraphics[width=0.995\linewidth]{eigen4elt__.pdf}
\caption{The comparison with a 5NN graph (``fe\_4elt2" graph)}\label{fig:compKNN2}
\end{figure}
\textbf{Learning circuit networks.} As shown in Figures \ref{fig:sgl_airfoil}, \ref{fig:sgl_crack} and \ref{fig:G2} for the ``airfoil" ($|V|=4,253$, $|E|=12,289$), the ``crack" ($|V|=10,240$, $|E|=30,380$),
and the ``G2\_circuit" ($|V|=150,102$, $|E|=288,286$) graphs, SGL can consistently learn sparse graphs which are slightly denser than spanning trees while preserving the key graph spectral properties. In Figure \ref{fig:resistance}, we observe highly correlated results when comparing the effective resistances computed on the original graphs with the graphs learned by SGL.
\textbf{Learning reduced networks.} As shown in Figure \ref{fig:G2Redu}, by randomly choosing a small portion of node voltage measurements (without using any currents measurements in $Y$ matrix) for graph learning, SGL can learn spectrally-similar graphs of much smaller sizes: when $20\%$ and $10\%$ node voltage measurements are used for graph learning, $5\times$ and $10\times$ smaller resistor networks can be constructed, respectively, while preserving the key spectral (structural) properties of the original graph.
\begin{figure}
\includegraphics[width=0.9995\linewidth]{airfoil.pdf}
\caption{The results for learning the ``airfoil" graph.}\label{fig:sgl_airfoil}
\end{figure}
\begin{figure}
\includegraphics[width=0.995\linewidth]{resultCrack.pdf}
\caption{The results for learning the ``crack" graph.}\label{fig:sgl_crack}
\end{figure}
\begin{figure}
\includegraphics[width=0.9995\linewidth]{G2circuit.pdf}
\caption{The results for learning the ``G2\_circuit" graph.}\label{fig:G2}
\end{figure}
\begin{figure}
\includegraphics[width=0.9995\linewidth]{ResultResistance.pdf}
\caption{The effective resistances correlations (scatter plots). }\label{fig:resistance}
\end{figure}
\begin{figure}
\includegraphics[width=0.999\linewidth]{NodeReductionG2.pdf}
\caption{The reduced graphs learned by SGL (``G2\_circuit" ).}\label{fig:G2Redu}
\end{figure}
\textbf{Learning with noisy measurements.} We show the results of the ``2D mesh" graph learning with noisy voltage measurements. For each SGL graph learning task, each input voltage measurement (vector) $\tilde x$ will be computed by: $\tilde x= x+ \zeta\| x\|_2\epsilon$, where $\epsilon$ denotes a normalized Gaussian noise vector, and $\zeta$ denotes the noise level. As shown in Figure \ref{fig:MeshNoise}, the increasing noise levels will result in worse approximations of the original spectral properties. It is also observed that even with a very significant noise level of $\zeta=0.5$, the graph learned by the proposed SGL algorithm can still preserve the first few Laplacian eigenvalues that are key to the graph structural (global) properties.
\begin{figure}
\includegraphics[width=0.995\linewidth]{noise2Dmesh.pdf}
\caption{The graphs learned with noises (``2D mesh" graph).}\label{fig:MeshNoise}
\end{figure}
\begin{figure}
\includegraphics[width=0.9995\linewidth]{sampleComplexity4elt.pdf}
\caption{The effect of the number of measurements (``fe\_4elt2" graph). }\label{fig:sampleComplexity}
\end{figure}
\begin{figure}
\centering\includegraphics[width=0.78259835\linewidth]{runtime.pdf}
\vspace{-0pt}
\caption{The runtime scalability of the SGL algorithm.}\label{fig:sgl_runtime}
\vspace{-5pt}
\end{figure}
\textbf{Sample complexity and runtime scalability} Figure \ref{fig:sampleComplexity} shows how the sample complexity (number of measurements)
may impact the graph learning quality. As observed, with increasing number of samples (measurements), substantially improved approximation of the graph spectral properties can be achieved. In the last, we show the runtime scalability of the proposed SGL algorithm in Figure \ref{fig:sgl_runtime}. The runtime includes the total time of Step 2 to Step 5 but does not include the time for Step 1. Note that modern kNN algorithms can achieve highly scalable runtime performance \cite{malkov2018efficient}.
\begin{figure}
\centering\includegraphics[width=0.7595\linewidth]{objfunknn.pdf}
\caption{The final object function values achieved with various kNN graphs.}\label{fig:objknn}
\end{figure}
\begin{figure}
\centering\includegraphics[width=0.8\linewidth]{eig_err_sgl-cropped.pdf}
{\caption{The average relative errors of the first 50 eigenvalues between learned graph and original graph with different $k$ (the ``fe$\_$4elt" graph).}\label{fig:errknn}}
\end{figure}
\textbf{Ablation analysis of SGL.} We provide comprehensive ablation analysis for the proposed SGL algorithm. In Figure \ref{fig:objknn}, we show that different choices of the number of nearest neighbors for constructing kNN graphs will only slightly impact the final solution quality (objective function values) of SGL. {{Figure \ref{fig:errknn} shows the average relative errors of the first $50$ eigenvalues between the learned graph and the original graph with various number of the nearest neighbors $k$. For example, given the first $50$ pairs of learned graph eigenvalues $\tilde{\lambda}_i$ and the original graph eigenvalues $\lambda_i$, the average relative error can be computed as $\frac{1}{50}\sum_{i=1}^{50}{\frac{|\tilde{\lambda}_i-\lambda_i|}{\lambda_i}}$. It can be observed that the learned graphs can well preserve the spectral properties of the original graph with different $k$ for initial kNN graphs. }} In Figure \ref{fig:embdim}, it is observed that with a higher dimension $r$ for spectral graph embedding, more accurate preservation of Laplacian eigenvalues in the learned networks can be achieved. In Figure \ref{fig:edgeiter}, we show that adding more edges in each SGL iteration will substantially improve the overall graph learning runtime without compromising the solution quality.
\begin{figure}
\centering\includegraphics[width=0.995\linewidth]{eigenvaldim.pdf}
\caption{SGL results with different spectral embedding dimensions $r$.}\label{fig:embdim}
\end{figure}
\begin{figure}
\centering\includegraphics[width=0.995\linewidth]{edgeiter.pdf}
\caption{SGL iterations with different number of edges added per iteration.}\label{fig:edgeiter}
\end{figure}
\subsection{Comprehensive Results for Graph Learning with SF-SGL}\label{subsection:SF-SGL}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{Gmat_4elt.pdf}
\caption{SF-SGL vs SGL on learned graphs (``fe$\_$4elt").}
\label{fig:4elt}
\end{figure}
\textbf{Spectrum/resistance preservation.} Figure \ref{fig:4elt} shows the learned graph comparison using the proposed SF-SGL and SGL algorithms on graph ``fe$\_$4elt", where the first $50$ eigenvalues are compared between the learned graphs and the original graph. Meanwhile, we randomly sample $100$ pairs of the nodes to compute their effective resistances on the learned graphs and the original graph. $\textbf{Rel. Err}$ represents the average relative errors given $k$ pairs of the approximated solution $\tilde{a}$ and the true solution $a$, such that $\textbf{Rel. Err} = \frac{1}{k}\sum_{i=1}^k{\frac{|\tilde{a}-a|}{a}}$. Under this condition, $k$ will be $50$ for eigenvalue comparison and $100$ for effective resistance comparison. It can be observed that the graph learned with SF-SGL can better preserve the spectral properties of the original graph.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{airfoil_noise.pdf}
\caption{Learned graphs with noise (the ``airfoil" graph).}
\label{fig:airfoil}
\end{figure}
\textbf{Learning with noises.} Figure \ref{fig:airfoil} shows the results of the ``airfoil" graph learning with noisy voltage measurements, where graph density of the learned graph is $1.04$. We observe that the measurement noises will result in worse approximations of the original spectral graph properties. However, the learned graph can still well preserve the key spectral properties of the original graph even with $30\%$ of noise level in the measurement data.
\begin{table*}
\centering \caption{Comparison of spectral graph learning results between SF-SGL and SGL. }
\resizebox{\textwidth}{!}{
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{Test cases} & {\multirow{2}{*}{$|V|$}} & {\multirow{2}{*}{$|E|$}} &
{\multirow{2}{*}{$\tau_G$}} &
{\multirow{2}{*}{$\tau_P$}} &\multicolumn{4}{|c|}{SGL } & \multicolumn{4}{|c|}{SF-SGL }\\
\cline{6-13}
{ } & { } & { } & { } & { }& {$Err(\lambda)$} & {$Err(R)$} & {$T_P$} & {$T$} & {$Err(\lambda)$} & {$Err(R)$} & $T_P$ & {$T$}\\
\hline
{airfoil} & {$4.3E3$} & {$1.2E4$} & {$2.89$} & {$1.04$} & {$0.228$} & {$0.296$} & {$5.5s$} & {$7.5s$} & {$\mathbf{0.125} $} & {$\mathbf{0.223}$} & {$0.2s$ $(27X)$} & {$0.3s$ $(25X)$} \\
\hline
{fe$\_$4elt} & {$1.1E4$} & {$3.3E4$} & {$2.97$} & {$1.03$} & {$0.162$} & {$0.325$} & {$10.6s$} & {$16.8s$} & {$\mathbf{0.074}$} & {$\mathbf{0.217}$} & {$0.5s$ $(21X)$}& {$0.7s$ $(24X)$} \\
\hline
{crack} & {$1.0E4$} & {$3.0E4$} & {$2.97$} & {$1.04$} & {$\mathbf{0.049}$} & {$0.271$} & {$10.1s$} & {$15.8s$} & {$0.176$} & {$\mathbf{0.141}$} & {$0.7s$ $(14X)$} & {$0.9s$ ($17X$)} \\
\hline
{fe$\_$sphere} & {$1.6E4$} & {$4.9E4$} & {$3.00$} & {$1.05$} & {$0.084$} & {$0.243$} & {$19.5s$} & {$29.9s$} & {$\mathbf{0.078}$} & {$\mathbf{0.163}$} & {$1.3s$ $(15X)$}& {$1.8s$ $(16X)$} \\
\hline
{2Dmesh} & {$2.5E5$} & {$5.0E5$} & {$2.00$} & {$1.02$} & {$0.136$} & {$0.263$} & {$356.7s$ } & {$2,464.7s$} & {$\mathbf{0.062}$} & {$\mathbf{0.119}$} & {$21.3s$ ($17X$)} & {$31.6s$ ($78X$)} \\
\hline
{3Dmesh} & {$2.5E5$} & {$7.4E5$} & {$2.95$} & {$1.12$} & {$0.207$} & {$0.577$} & {$1,054.7s$ } & {$3,155.7s$} & {$\mathbf{0.125}$} & {$\mathbf{0.260}$} & {$36.8s$ ($28X$)} & {$47.8s$ ($66X$)} \\
\hline
{mat3} & {$4.0E5$} & {$1.2E6$} & {$2.89$} & {$1.13$} & {-} & {-} & {-} & {-} & {$0.236$} & {$0.350$} & {$67.7s$} & {$86.7s$} \\
\hline\end{tabular}\label{table:sf_sgl}
}
\end{table*}
\textbf{More detailed results.} Table \ref{table:sf_sgl} shows more comprehensive results on learned graphs using the proposed SF-SGL and SGL algorithms, where $\tau_G$ and $\tau_P$ represent the graph densities ($|E|/|V|$) for the original graph and the learned graph, respectively; $Err(\lambda)$ denotes the average relative error of the first $50$ eigenvalues between the original graph and the learned graph, and $Err(R)$ is the average relative error of the effective resistances measured on $100$ pairs of randomly picked nodes, with better results highlighted in the table; $T_P$ and $T$ represent the graph learning time (without considering the initial kNN graph construction time) and total runtime of the corresponding graph learning algorithms, respectively. The SF-SGL runtime speedups over SGL are also included in the table. We observe that the graphs learned by SF-SGL can more accurately preserve the spectral properties of the original graph, while the runtime is much smaller than SGL. For example, SF-SGL successfully generate the learned graph for the ``mat3" graph, while SGL failed due to the limited memory resources.
{{
\begin{figure}
\centering
\includegraphics[width=0.790596\linewidth]{eig_err_sfsgl-cropped.pdf}
{\caption{The average relative errors of the first 50 eigenvalues between the learned graph and the original graph with different $k$ (the ``fe$\_$4elt" graph).}
\label{fig:eigerr_sfsgl}}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.790596\linewidth]{effe_err_sfsgl-cropped.pdf}
{\caption{The average relative errors of the effective resistances (100 pairs) between the learned graph and the original graph with different $k$ (the ``fe$\_$4elt" graph).}
\label{fig:effeerr_sfsgl}}
\end{figure}
\textbf{Learning with different kNN graphs.} Given the original ``fe$\_$4elt" graph and the learned graph generated by SF-SGL with a graph density as 1.05, Figure \ref{fig:eigerr_sfsgl} shows the average relative errors of the first $50$ eigenvalues between learned graph and original graph with various number of the nearest neighbors $k$. While Figure \ref{fig:effeerr_sfsgl} shows the average relative errors of the effective resistance values for $100$ randomly picked node pairs on the learned graph and the original graph with various number of the nearest neighbors $k$. It can be observed that the learned graphs can well preserve the spectral properties of the original graph with various number of the nearest neighbors for initial kNN graphs.
}}
\begin{figure}
\centering
\includegraphics[width=0.799596\linewidth]{tradeoff2.pdf}
\caption{Learned graphs with various graph densities (the ``mat1" graph).}
\label{fig:mat1}
\end{figure}
\textbf{Trade-off analysis.} Figure \ref{fig:mat1} shows the tradeoffs between the eigenvalue average relative errors/runtime and graph densities learned by SF-SGL for the ``mat1" graph. It can be shown that although higher graph density will result in higher runtime, it will achieve better spectrum preservation of the original graph.
\begin{figure}
\centering
\includegraphics[width=0.7995995\linewidth]{runtime2.pdf}
\caption{The runtime scalability of the SF-SGL algorithm.}
\label{fig:runtime}
\end{figure}
\textbf{Runtime scalability.} Figure \ref{fig:runtime} shows the nearly-linear runtime scalability of the proposed SF-SGL algorithm even for very large graphs.
\subsection{Data-Driven Vectorless Integrity Verification}\label{subsection:application}
\begin{table*}
\centering \caption{Application of SF-SGL in Vectorless Integrity Verification Tasks. }
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{Test cases} & {\multirow{2}{*}{$|V|$}} & {\multirow{2}{*}{$|E|$}} &\multicolumn{4}{|c|}{Original graph} & \multicolumn{6}{|c|}{Learned graph}\\
\cline{4-13}
{ } & { } & { } & {$\tau_G$} & {$T(chol)$}& {$T(sol)$} & {$T(lp)$} & {$\tau_P$} & {$T$} & {$T(chol)$}& {$T(sol)$} & {$T(lp)$} & {$Err$}\\
\hline
{ibm4} & {$9.5E5$} & {$1.6E6$} & {$1.63$} & {$11.86s$} & {$52.82s$} & {$171.60s$} & {$1.02$} & {$237.94s$} & {$1.19s$} & {$3.00s$} & {$162.57s$} & {$0.01\%$} \\
\hline
{thu1} & {$5.0E6$} & {$8.2E6$} & {$1.66$} & {$134.91s$} & {$618.52s$} & {$1,469.92s$} & {$1.03$} & {$1,338.41s$} & {$7.70s$} & {$16.03s$} & {$1,025.85s$} & {$0.01\%$} \\
\hline
{mat1} & {$1.0E5$} & {$2.8E5$} & {$2.88$} & {$3.75s$} & {$15.66s$} & {$14.07s$} & {$1.09$} & {$19.09s$} & {$0.25s$} & {$0.56s$} & {$12.62s$} & {$0.84\%$} \\
\hline
{mat2} & {$2.0E5$} & {$5.8E5$} & {$2.93$} & {$16.60s$} & {$56.77s$} & {$23.82s$} & {$1.07$} & {$43.63s$} & {$0.59s$} & {$1.15s$} & {$23.07s$} & {$0.99\%$} \\
\hline
{mat3} & {$4.0E5$} & {$1.2E6$} & {$2.89$} & {$27.29s$} & {$89.04s$} & {$69.21s$} & {$1.07$} & {$90.19s$} & {$1.21s$} & {$2.15s$} & {$79.90s$} & {$0.45\%$} \\
\hline
{mat4} & {$9.0E5$} & {$2.6E6$} & {$2.89$} & {$169.40s$} & {$333.96s$} & {$531.38s$} & {$1.04$} & {$235.79s$} & {$3.28s$} & {$6.91s$} & {$196.98s$} & {$0.10\%$} \\
\hline
{mat5} & {$1.6E6$} & {$4.6E6$} & {$2.90$} & {$1,031.42 s$} & {$38,062.90s$} & {$1623.62s$} & {$1.04$} & {$511.16s$} & {$9.01s$} & {$9.99s$} & {$379.10s$} & {$0.46\%$} \\
\hline\end{tabular}\label{table:sf_ver}
\end{table*}
The integrity of power distribution networks must be verified throughout the design process to ensure that the supply voltage fluctuations are within certain thresholds. To achieve the desired levels of chip reliability and functionality, compute-intensive full-chip thermal analysis and integrity verifications are indispensable, which typically involves estimating thermal profiles under a variety of workloads and power budgets. In this work, we introduce {a data-driven vectorless power/thermal integrity verification framework}: \textbf{(1)} given a collection of voltage/temperature measurements that can be potentially obtained from on-chip voltage/temperature sensors \cite{anik2020chip,ku2019voltage}, the proposed data-driven method will first construct a sparse power/thermal grid network leveraging the proposed graph topology learning approach; \textbf{(2)} next, vectorless power/thermal integrity verification framework will be exploited for estimating the worst-case voltage/temperature (gradient) distributions \cite{zhao2020spectral,zhao2017spectral}.
Table \ref{table:sf_ver} shows the single-level vectorless integrity verification results between learned graphs and original graphs, where ``ibm4" and ``thu1" are power grid test cases, ``mat1" to ``mat5" are 3D thermal grids; $T$, {$T(chol)$}, {$T(sol)$} and {$T(lp)$} represent the runtime for SF-SGL, Cholesky factorization, adjoint sensitivity calculation using matrix factors and the linear programming (LP) computation, respectively. {$T(sol)$} and {$T(lp)$} are runtime results computed by summing up the runtime for verifying $100$ randomly chosen nodes. $Err$ denotes the average relative solution error compared to the ones obtained with the original graph. Compared with the verification results on original graphs, the SF-SGL learned graphs have achieved the very similar results with much lower overall runtime.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{thermal_dis.pdf}
\caption{Worst-case temperature distributions obtained by vectorless verification with the original thermal grid (left) and the learned grid (right).}
\label{fig:thermal}
\end{figure}
Figure \ref{fig:thermal} shows the worst-case temperature distributions obtained by vectorless verification using the original thermal grid (left) and the learned grid (right) for the ``mat1" graph. It can be observed that very similar worst-case thermal profiles can be obtained using the SF-SGL learned graph.
\section{Conclusions}\label{conclusion}
This work proposes highly-scalable spectral algorithms for learning large resistor networks from linear voltage and current measurements.
We show that the proposed graph learning approach is equivalent to solving the classical graphical Lasso problems with Laplacian-like precision matrices. A unique feature of the proposed methods is that the learned graphs will have the {spectral embedding or effective-resistance distances to encode the similarities} between the original input data points (voltage measurements).
As an important extension, we also introduce a more scalable solver-free spectral graph learning (SF-SGL) algorithm. Such a scalable framework allows learning a hierarchy of spectrally-reduced and sparsified graphs in nearly-linear time, which can become key to accelerating many graph-based numerical computing tasks. The proposed spectral approach is simple to implement and inherently parallel friendly. The proposed spectral algorithms allow each iteration to be completed in $O(N \log N)$ time, whereas existing state-of-the-art methods require at least $O(N^2)$ time for each iteration. We also provide a sample complexity analysis to show that it is possible to accurately recover a resistor network with only $O(\log N)$ voltage measurements (vectors).
Our extensive experimental results show that the proposed method can produce a hierarchy of high-quality learned graphs in nearly-linear time for a variety of real-world, large-scale graphs and circuit networks when compared with prior state-of-the-art spectral methods.
\vspace{-0pt}
\section{Acknowledgments}
This work is supported in part by the National Science Foundation under Grants CCF-2021309, CCF-2011412, CCF-2212370, and CCF-2205572.
\bibliographystyle{unsrt}
{
| {'timestamp': '2023-02-10T02:03:48', 'yymm': '2302', 'arxiv_id': '2302.04384', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04384'} | arxiv |
\section{Introduction}\label{sec:1}
\subsection{Background and Motivation}
High-mobility, agility, and accessibility are the representative advantages of unmanned aerial vehicles (UAVs) that can help serve a wide range of services beyond 5G or 6G~\cite{9044378,9428629,9459481,9023459,saad2019vision}. UAV deployments continue to grow, and the number of UAV fleets will reach 1.6 million by 2024, according to a Federal Aviation Administration (FAA) prediction~\cite{mozaffari2021toward}. Examples of varied UAV applications include real-time surveillance~\cite{yun2022cooperative}, package delivery~\cite{9098900}, smart factory~\cite{10012051,lee2018online}, and disaster monitoring/management~\cite{9583845}. Notably, UAVs can provide wireless communication service without a fixed terrestrial infrastructure to create mobile access networks, providing broader wireless coverage and real-time service~\cite{tvt202106jung,8660516}.
UAVs can rapidly establish wireless connections with ground UEs in emergencies (\textit{i.e.}, military issues or disasters) and in extreme areas where installing terrestrial base stations is not easy for technical or economic reasons~\cite{zhang2021joint, bor2016new,zeng2016wireless}.
However, constructing a UAV-enabled mobile access system is demanding since there are manifold unexpected dynamics and uncertainties in a real environment (\textit{i.e.,} obstacles, gales, collisions, energy limitations, or malfunctioning). For this reason, designing a machine learning algorithm that autonomously and adaptively provides the optimal UAV trajectories can be an alternative solution to the abovementioned issues.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{Figure/Sys_architecture.pdf}
\caption{Proposed architecture of mobile access for quantum multi-UAV systems.}
\label{fig:sys_architecture}
\end{figure}
Although eclectic machine learning (ML) and deep learning (DL) algorithms can become dominant solutions, reinforcement learning (RL) has shown the most notable performance in sequential decision-making problems~\cite{pieee202105park}. RL can enable effective resource management service in a dynamic networking system, including UAV-aided mobile access~\cite{lahmeri2021artificial}. In addition, RL also has scalability to use multi-agent reinforcement learning (MARL) to control multiple UAVs. However, there are various interactions between UAVs in MARL where they train their policies contemporaneously and affect each other's policy training performance. In addition, UAVs can observe partial information about the dynamic environment due to physical limitations. These factors considerably make the MARL environment non-stationary.
Quantum MARL (QMARL) using quantum entanglement can handle the above non-stationary problem~\cite{oh2020tutorial}. Building quantum neural networks (QNNs) using quantum computing (QC) enables efficient consumption of computing resources with fewer model parameters than conventional neural networks, resulting in more reliable and faster learning~\cite{chen2020variational, yun2022quantum,9555241}.
Existing studies have performed CTDE-based computation for the cooperation of multiple agents using a structure called \textit{CommNet}~\cite{sukhbaatar2016learning}. \textit{CommNet} is a structure that receives state information of all agents as input and learns the actions of all agents in one single neural network. If $m$ agents represent the state as an $n$-dimensional vector, the input of the CommNet increases to $m\times n$. Accordingly, the input size scales up linearly as the number of agents increases. However, this linear scale-up is very burdensome in the QC environment due to the near intermediate-scale quantum (NISQ) limitation in using qubits, which is a chronic scalability issue~\cite{shor1995scheme}.
\subsection{Algorithm Design Rationale}
We take care of this scalability issue, which is mentioned previously, in the quantum domain by using a structure in which a \textit{centralized critic} network trains multiple \textit{actor} networks iteratively~\cite{yun2022quantum}. This paper proposes a CTDE-based training algorithm, referred to as a {QMACN} algorithm utilizing the benefit of QC (\textit{i.e.}, quantum entanglement, efficient utilization of computing resource with fewer parameters). Using our proposed algorithm, we can realize cooperative mobile access, fully utilizing quantum supremacy. As observed in Fig.~\ref{fig:sys_architecture}, the CTDE-based approach can overcome physical limitations due to weight or storage conditions (\textit{e.g.}, cryogenic environment) when mounting a real quantum computer on a UAV. In addition, inter-UAV communications are not needed thanks to the information-sharing provided by CTDE.
Finally, this paper designs concrete environments by taking into account the UAVs' information noise, which usually hinders them from behaving as intended. Considering this factor, this paper authenticates UAVs can react more adaptively to environmental noises through performance evaluations.
\subsection{Contributions}
The contributions of this work are as follows.
\begin{itemize}
\item This paper presents a {QMACN} algorithm enabling multiple UAVs to provide autonomous mmWave communication services cooperatively by training UAVs to find optimal trajectories in uncertain and dynamic environments.
\item In addition, this paper proposes a CTDE framework to realize QMARL by rising above the limitations of quantum computing, \textit{i.e.}, quantum error in increasing the number of qubits in the NISQ era and the impossibility of putting a quantum computer on a UAV.
\item Moreover, we design a realistic environment by noise injection to construct robust mobile access in multi-UAV systems, where the environmental noises are considered based on reality. One of the representative characteristics of RL is to train agents to respond adaptively to dynamic elements.
\item Lastly, This paper corroborates the advantages of QMARL and realistic noise reflection on training policies by carrying out various data-intensive evaluations in policy training and its inference process.
\end{itemize}
\subsection{Organization}
The rest of this paper is organized as follows. Sec.~\ref{sec:2} reviews preliminary knowledge. The details of the baseline models are described in Sec.~\ref{sec:3}. Sec.~\ref{sec:4} presents a novel quantum reinforcement learning algorithm for multi-UAV mobile access. Sec.~\ref{sec:5} evaluates the performance via data-intensive simulations. Lastly, Sec.~\ref{sec:6} concludes this paper.
\section{Quantum Machine Learning}\label{sec:2}
\begin{figure}
\centering
\subfigure[Classical MARL.]
{
\includegraphics[width=0.95\linewidth]{Figure/MARL_Layer.pdf}
\label{fig:MARL_Layer}
}
\subfigure[Quantum MARL.]
{
\includegraphics[width=0.95\linewidth]{Figure/Quantum_Layer.pdf}
\label{fig:Quantum_Layer}
}
\caption{Architectures of classical computing and quantum computing.}
\end{figure}
\subsection{Qubits}
Qubits are used in QC as the basic unit of information. They can take any value between 0 and 1 because they are expressed as a combination of two bases: $|0\rangle$ and $|1\rangle$. A qubit that is composed of both bases is said to be in a state of \textit{superposition} and can also be used to express quantum states~\cite{bouwmeester2000physics}. In addition, \textit{entanglement} between qubits is also possible, which can significantly increase the correlation between two individual qubits. This nature of qubits allows QC to contain and control more information compared to classical computing. Assuming a $q$ qubits system, a quantum state existing in the Hilbert state of the system can be expressed as $|\psi\rangle=\alpha_{1}|0\cdots 0\rangle + \cdots + \alpha_{2^q}|1\cdots 1\rangle$,
where $\alpha$ stands for the probability amplitude, \textit{i.e.}, $\sum^{2^q}_{i=1}\alpha_{i}^2=1$.
As $\alpha$ is a complex number, a quantum state can be expressed as a point on the Bloch sphere geometry.
\subsection{Quantum Neural Network}
In order to design and compute QNN using qubits, the qubits should be controllable for training the neural network. The control can be achieved via the utilization of basic quantum gates in order to control the positions of qubits over Bloch sphere. Representative examples of the basic quantum gates are rotation gates, which are expressed as $R_x$, $R_y$, and $R_z$, which are for the rotation over $x$-, $y$-, and $z$-axes. For more details, the gate functions can be performed as unitary operations on a single qubit, causing it to rotate by a specific value in the given directions of $x$-, $y$-, and $z$-axes. Furthermore, these gates can not only control qubits but also can encode classical bit-scale data. While basic quantum rotation gates are single qubit gates that can only be applied to a single qubit simultaneously, there are also multiple qubit gates acting on two or more qubits simultaneously. For example, \textit{CNOT} gate can cause entanglement among several qubits by performing \textit{XOR} operation on two qubits~\cite{williams1998explorations}. Based on these theories and concepts, QNN models can be built by assembling these gates. conventional QNN models consist of following three components, \textit{i)} state encoding circuit (refer to \textsf{A} in Fig.~\ref{fig:Quantum_Layer}), \textit{ii)} parameterized quantum circuit (PQC) (refer to \textsf{B} in Fig.~\ref{fig:Quantum_Layer}), and \textit{iii)} quantum measurement (refer to \textsf{C} in Fig.~\ref{fig:Quantum_Layer}) layers.
More details for these layers are as follows.
\subsubsection{State Encoding Circuit}
First of all, the encoding layer's function is to encode classical data into quantum states because quantum circuits cannot take classical bits as input. Therefore, the state encoder converts bits into qubits by passing $q$ number of $|0\rangle$ into an array of rotation gates using classical data used as parameters denoted as $\theta_{enc}$. Additionally, the input data $X$ is split into $[x_{1} \cdots x_{N}]$ such that they can be individually used as parameters, where $N$ is the number of split data for the input $X$. Then, the output quantum state of this layer will contain the information of classical data.
\subsubsection{Parameterized Quantum Circuit}
Secondly, there is the PQC which carries out the desired computation, and it is equivalent to a classical deep neural network (DNN), especially accumulated hidden layer multiplication. In this layer, the input quantum state is rotated by a specific angle using quantum gates such that the output will give the required value (\textit{i.e.}, action and state values). For this paper, the qubits are computed using the \textit{Controlled-Universal (CU)} gate which has flexible control over the direction of rotation, entanglement, and disentanglement.
The structure of the QNN model in this paper is as illustrated in Fig.~\ref{fig:Quantum_Layer}, and it can be seen that the encoding layer followed by the CU3 layer is repeated several times. This particular structure is due to the data re-uploading technique~\cite{P_rez_Salinas_2020}, simultaneously encoding and rotating the qubits. As a result, the computation efficiency of each qubit is maximized, \textit{i.e.}, the number of qubits is decreased which is required to produce the values needed for MARL.
\subsubsection{Quantum Measurement}
Lastly, the quantum state produced from the PQC becomes the input of the measurement layer. In this stage, the input is measured such that the quantum data can be decoded back into classical data for optimization. This measurement operation is equivalent to the multiplication of a projection matrix with respect to $z$-axis. While $z$-axis is most commonly used for measurement, it can be any other properly defined directions. After conducting the measurement of the quantum state, the quantum state collapses, and it becomes an \textit{observable}.
After the decoding procedure, the \textit{observable} is used to minimize the loss function. Then, it should be differentiated for backpropagation, however, quantum data cannot be differentiated because applying chain rule will completely collapse the qubits. Thus, the technique for obtaining the loss gradient via the symmetric difference quotient of the loss function is used for QNN training.
\subsection{Quantum Reinforcement Learning}
The quantum circuit's final \textit{observable} value represents the agent's action probability in MARL computation. It coincides with the \textit{softmax} function, as illustrated in Fig.~\ref{fig:MARL_Layer}. Using the information in the replay buffer will compute the action distribution of the agents in the environment. Then, as the agents move based on this action, a new state, observation, and reward data will be produced for another repeated iteration of learning~\cite{yun2022quantum}. Previous studies with many spurs have verified better performance than DNN-based RL methods composed of the same parameters~\cite{lockwood2020reinforcement, yun2022quantum, chen2020variational}. The proposed algorithm in this paper takes advantage of QC for robust mobile access; and it investigates the performance evaluation of QMARL compared to traditional MARL to show quantum supremacy in our considering problems in this paper.
\begin{figure*}[t]
\centering
\includegraphics[width=\linewidth]{Figure/overall_training_architecture.pdf}
\caption{Proposed CTDE-based training pipeline for constructing the quantum multi-UAV systems.}
\label{fig:sys_pipeline}
\end{figure*}
\section{Model}\label{sec:3}
\subsection{Mobile Access Model using Multi-UAV Networks}
We propose {QMACN} algorithm aiming to construct reliable and robust autonomous multi-UAV networks to use QMARL in a dynamic environment, as illustrated in Fig.~\ref{fig:sys_pipeline}. To implement QC, our proposed {QMACN} algorithm can overcome scalability and physical issues of QC as described in Sec.~\ref{sec:1}. Regarding the delay, we assume the state of the server's queue is ideal. It also takes into account the situation where if communication for sending a UAV's experience fails, it will retransmit until it succeeds like the standard TCP protocol. Considering the natural CTDE environment, UAVs may encounter multifaceted uncertainties represented as noise when sending their experiences for training to the central server. Not only the interactions between UAVs can affect the training policy of other agents, but also various noise factors can. It is the reason for using RL, and two types of noises are fed into our MARL system to consider a realistic environment in this paper; \textit{i)} state noise and \textit{ii)} action noise. We will discuss the detailed descriptions of these noises in Sec.~\ref{sec:3-c}.
\subsection{Noise Distribution Model in UAV Positioning}\label{sec:3-c}
\BfPara{State Noise}
UAVs trained by our {QMACN} algorithm determine their own locations and positioning using a global positioning system (GPS) which is trivial in many mobility systems and platforms~\cite{mobisys2010paek}.
However, the GPS receivers have noise, \textit{i.e.}, interference, jamming, and delay lock loop (DLL), which can be modeled to Gaussian or non-Gaussian distributions. The considering model of the state noise in GPS sensors is a canonical model, \textit{i.e.}, generalized Cauchy noise~\cite{liu2008performance}, as follows,
\begin{equation}
p_{cy}(z,\sigma_z)=\frac{Y}{\left(1+v^{-1}[|z|/X]^k\right)^{v+1/k}},
\label{eq:state_noise}
\end{equation}
where $X=\Big[\sigma_z^2\frac{\Gamma(1/k)}{\Gamma(3/k)}\Big]^{1/2}, Y=\frac{kv^{-1/k}\Gamma(v+1/k)}{2X\Gamma(v)\Gamma(1/k)}$, and $\Gamma(t)=\int_{0}^{\infty} x^{t-1}e^{-x}\, dx$ (Gamma function). In the variance of the generalized Cauchy density, $k$ and $v$ mean the impulsiveness and variance of the GPS noise~\cite{kassam2012signal}. We depict the probability distribution function (PDF) of the state noise as generalized Cauchy density in Fig.~\ref{fig:state_noise} with the scale parameter $\sigma_z$ where we set $k=0.20$, $v=40$, and $\sigma_z^2=0.22$~\cite{liu2008performance}.
\BfPara{Action Noise}
The wind noise can be dealt with Weibull distribution, a widely used probability distribution for wind speed modeling, and is formulated as~\cite{feng2015modelling},
\begin{equation}
p_{wb}(v,\sigma_v)=\left(c/A\right)\left(v/A\right)^{c-1}\texttt{exp}(-vc/A),
\label{eq:action_noise}
\end{equation}
where $v$ is a wind velocity, $A=\left(\frac{\sigma_v}{\Bar{v}}\right)^{-1.086}$ and $c=\frac{\Bar{v}}{\Gamma(1+1/A)}$ stand for scale and shape parameters with the mean $\bar{v}$ and the standard deviation $\sigma_v$ of wind speed calculated from the data~\cite{feng2015modelling}. The meteorological measurements for a total of $145,048$ data were conducted during three years (from June 1st, 1999 to May 31, 2002). Fig.~\ref{fig:action_noise} is the PDF of Weibull distribution with $A=10.97\,m/s$ and $c=2.29$ to represent the probability of the wind speed. In addition, Fig.~\ref{fig:wind_direction} means the probability of $12$ directions where the wind can blow from.
\begin{figure}[ht]
\centering
\subfigure[State Noise.]{
\includegraphics[width=0.465\linewidth]{Figure/Caucy_Noise_Model-eps-converted-to.pdf}
\label{fig:state_noise}
}
\subfigure[Action Noise.]{
\includegraphics[width=0.465\linewidth]{Figure/Weibull_Distribution-eps-converted-to.pdf}
\label{fig:action_noise}
}\\
\subfigure[Wind Direction.]{
\includegraphics[width=\linewidth]{Figure/Direction_Prob-eps-converted-to.pdf}
\label{fig:wind_direction}
}
\caption{Probability distribution functions of state and action noises.}
\label{fig:Noise_model}
\end{figure}
\BfPara{Modeling the Gap between Real-World and Ideal}
Considering the aforementioned noise states, we can reconfigure the \textit{actor-critic} model. This paper considers both \textit{ideal} and \textit{real} state/action cases. The ideal case doesn't consider the noise in the environment, and the other considers the noise. The relationship between these cases can be modeled as follows,
\begin{align}
s_{\textrm{real}} & = s_{\textrm{ideal}} + n_s,
\\
a_{\textrm{real}} & = a_{\textrm{ideal}} + n_a,
\end{align}
where $n_s$ and $n_a$ stand for the noises of states and actions. Note that $n_s\sim p_{cy}(z, \sigma_z)\;\{x,y\}\in z$ and $n_a \sim p_{wb}(v, \sigma_v)$, where $x$ and $y$ are the cardinal points in the two-dimensional coordinate of UAVs' positions.
\section{MARL Algorithm for Multi-UAV Cooperation}\label{sec:4}
\subsection{MARL Formulation}
Our considered multi-UAV system is mathematically defined as the decentralized partially observable MDP (Dec-POMDP), which is widely used for CTDE MARL framework~\cite{rashid2020monotonic}, because each UAV conducts distributed sequential decision-making with partial environment information due to its physical limitations.
The Dec-POMDP of $M$ UAVs can be denoted as $\langle\mathcal{S}, \mathcal{A}, P, r, \mathcal{O}, \mathcal{Z}, \gamma\rangle$ where
$\mathcal{S}$ is a set of states where $s\in\mathcal{S}$;
$\mathcal{A}$ is a set of actions where ${a_m}\in A_m \subset \mathcal{A}$, and here, $a_m$ denotes the $m$-th UAV's action, which composes the joint UAV actions, \textit{i.e.}, $\textbf{a}\in \mathcal{A}$, and note that $A_m$ means a set of $m$-th UAV's actions;
$P$ is a state transition probability $P:\Pr(s'\,|\,s,\textbf{a})=\mathcal{S}\times\mathcal{A}\times\mathcal{S}\rightarrow\mathcal{S}$ with joint UAV actions $\textbf{a}$;
$r$ is a shared reward which is given to all UAVs equally with $r(s,\textbf{a},s')=\mathcal{S}\times\mathcal{A}\times\mathcal{S}\rightarrow\mathbb{R}$.
In addition,
$\mathcal{O}$ is a set of observations where $m$-th UAV's observation is denoted as $o_m\in O_m \subset \mathcal{O}$ and note that $O_m$ means a set of observations of $m$-th UAV. Here, the joint UAV observation for training is denoted as $\textbf{o}\in\mathcal{O}$.
$\mathcal{Z}$ is conditional observation probabilities function space, \textit{i.e.}, $\mathcal{Z}(s',\textbf{a},\textbf{o})$ and $\gamma$ is a discount factor.
When each $m$-th UAV takes action $a_m$ while observing $\mathcal{O}_m$ based on $\mathcal{Z}(s',\textbf{a}, \textbf{o})=\mathcal{S}\times\mathcal{A}\rightarrow\mathcal{O}$, the state is updated based on $P$. After this computation, the reward is engendered using $r(s,\textbf{a},s')$. More details about observations, states, actions, rewards, and objective are as follows.
\BfPara{Observations}
The $m$-th UAV can partially observe its own environment information based on its position, which is composed of position $p_m\in\{x_m,y_m\}$ and energy state $e_m$ where $x_m$ and $y_m$ stands for Cartesian coordinates. In addition, the UAV can observe the distance between its own position and other UAV within the observable scope of the $m$-th UAV, \textit{i.e.},
\begin{equation}
d_{mm'} = \begin{cases}
\|p_m - p_{m'}\|_2,& \textit{if.}~~~\|p_m - p_{m'}\|_2 \leq D_{\textit{th}}, \\
-1,& \textit{(otherwise)},
\end{cases}
\end{equation}
where $D_{\textit{th}}$ and $\|\cdot\|_2$ mean the observation scope and L2-norm. The observation of the $m$-th UAV is defined as $\mathcal{O}_m \triangleq\{p_m, e_m, \bigcup_{m'=1}^{M}\{d_{mm'}\}\}$, $\forall \{m,m'\} \in M$.
\BfPara{States}
The state consists of two service details in mobile access; \textit{i)} availability of service $c_{mn}\triangleq\{0,1\}$ and \textit{ii)} quality of service (QoS) $q_{mn}$. The QoS of $n$-th user supported by $m$-th UAV can be formulated as follows,
\begin{equation}
q_{mn}=
\begin{cases}
\left(1+\exp^{-w_{a}\left(\kappa_{mn}-w_{b}\right)}\right)^{-1},\;\textit{(video traffic)},\\
\log\left(w_{c}\cdot\kappa_{mn}+w_{d}\right),\;\textit{(otherwise)},
\end{cases}
\label{eq:quality}
\end{equation}
where $\kappa_{mn}$ is the $n$-th user's data rates serviced by the $m$-th UAV. In addition, the values of weight parameters are $w_a$\,=\,0.01, $w_b$\,=\,1024, $w_c$\,=\,1, and $w_d$\,=\,1~\cite{jung2021infrastructure}.
Here, all UAVs have the same state information simultaneously because the total service is affected by all UAVs.
Accordingly, the state information can be denoted as $s\triangleq \bigcup^{M}_{m=1}\bigcup^{N}_{n=1}\{c_{mn}, q_{mn}\}$.
\BfPara{Actions}
All UAVs take actions sequentially based on their policies at $t$. UAVs can move in four cardinal points because they are in the two-dimensional Cartesian coordinates $(x,y)\in\mathbb{R}^2$. Therefore, the action set that UAVs can take is $\mathrm{a}\triangleq\{x_m \pm (v_m \times t), y_m \pm (v_m \times t)\}_{m=1}^M$ where $v_m$ is UAV's velocity.
\BfPara{Rewards}
The reward $r(s,\textbf{a})$ is generated with the current state $s$ and all UAVs' selected actions $\textbf{a}$. Then, the reward function can be is as follows,
\begin{equation}
r(s,\textbf{a},s')=w_c\times\sum_{m=1}^{M}\sum_{n=1}^{N}\left(c_{mn} \times q_{mn}\right)\times\tau\times\mathbbm{1}(e_m),
\label{eq:reward}
\end{equation}
where $w_c$ is a reward weight to make the learning process more stable; $\tau^t$ is all UAVs' overlapped rate at $t$ which has to be decreased to reduce interference among them; $\mathbbm{1}(\cdot)$ is an indicator function to differentiate whether it is zero or not. Therefore, it can be seen that UAVs try to maximize the ground users' supported rate and QoS within the energy limit according to this reward function definition.
\BfPara{Objective}
Our main objective in MARL is formulated as,
\begin{equation}
\begin{split}
& \pi^*_{\boldsymbol{\theta}} = \\
& \argmaxD_{\boldsymbol{\theta}}\mathbb{E}_{s_{\textrm{real}}\sim E,\,\mathrm{a}_{\textrm{real}}\sim\pi_{\boldsymbol{\theta}}}\left[\sum_{t=1}^T\gamma^{t-1}\!\cdot\!r\left(s_{\textrm{real}},\mathbf{a}_{\textrm{real}},s'_{\textrm{real}}\right)\right],
\label{eq:goal}
\end{split}
\end{equation}
where $E$, $T$, and $\gamma \in [0,1)$ stand for the environment where UAVs exist, an episode length, and a discounted factor.
By redefining the objective function in RL, UAVs can consider realistic environmental noise (\textit{i.e.,} $s_{\textrm{real}}$, $\mathbf{a}_{\textrm{real}}$, and $s'_{\textrm{real}}$) to make their policy more robust to versatile noises. More details about how UAVs achieve optimal decision-making with the reconfigured objective function are discussed in Sec.~\ref{sec:4B}.
\subsection{QMACN for Cooperative Multi-UAV Mobile Access}\label{sec:4B}
\BfPara{QMARL Algorithm Design}
Sec.~\ref{sec:1} clearly states the scalability issue due to the limited number of qubits. However, in the existing \textit{actor-critic} training method~\cite{konda1999actor}, the number of qubits must also increase as the number of agents grows in MARL. This need brings out quantum errors that inhibit system stability~\cite{shor1995scheme,yun2022quantum}.
Accordingly, we propose a novel {QMACN} algorithm utilizing the CTDE, the methodology based on the multi-agent \textit{actor-critic} RL framework~\cite{yun2022quantum, lowe2017multi}.
In CTDE, there is one \textit{centralized critic} and multiple \textit{actor} networks where the number of actor networks is commensurate with the number of agents in Dec-POMDP~\cite{oliehoek2016concise} as observed in the server of Fig.~\ref{fig:sys_pipeline}. CTDE-based agents make the sequential decision dispersively and train their \textit{actor} networks corresponding to the policy by evaluating the value of \textit{centralized critic} network, which can be expressed as follows,
\begin{align}
\!\!\!Q(o,a;\boldsymbol{\theta}) &=\beta_a \langle O_a \rangle_{o,\boldsymbol{\theta}}\!\!\!\!&=\beta_a\text{Tr}(U^{a\dagger}(o;\boldsymbol{\theta})M_a U^{a}(o;\boldsymbol{\theta}))
\label{obs:actor}\\
\!\!\!V(s;\boldsymbol{\phi}) &=\beta_c \langle O \rangle_{s,\boldsymbol{\phi}}\!\!\!\!&=\beta_c\text{Tr}(U^{c\dagger}(s;\boldsymbol{\phi})M_c U^{c}(s;\boldsymbol{\phi}))
\label{obs:critic}
\end{align}
where operators $\text{Tr}(\cdot)$, $U(\cdot)$, and $(\cdot)^\dagger$ represent trace operator, the unitary operation for qubit rotation, and the entanglement of multiple qubits and complex conjugate, respectively. When the quantum state is measured, the output (known as observable) exists between -1 and 1, \textit{i.e.}, $\forall \langle O\rangle\in [-1,1]$, we utilize hyper-parameters $(\beta_a,\beta_c)$ for \textit{actors} and \textit{critic} networks to be well-trained.
Note that $M_a$ and $M_c$ are Hermitian matrices. With \eqref{obs:actor}, \eqref{obs:critic}, and the hyper-parameters, the \textit{actor-critic} networks can approximate the value function.
\BfPara{Quantum Actor}
At every time step $t$, the $m$-th quantum \textit{actor} chooses the action with the most significant probability among the currently possible actions based on its state and observation information, which is represented as follows,
\begin{equation}
\mathrm{a_{m,real}} = \argmaxD_{\mathrm{a}}\pi_{\boldsymbol{\theta}_m}(\mathrm{a}_{\textrm{ideal}}|s_{\textrm{ideal}}+n_s,{o}_m)+n_a,
\end{equation}
subject to
\begin{align}
& \pi_{\boldsymbol{\theta}_m}(\mathrm{a}_{\textrm{ideal}}|s+n_s,{o}_m) \triangleq \textit{softmax}(Q(o,a;\boldsymbol{\theta}_m)),\\
& \textit{softmax}(\mathbf{x}) \triangleq \left[\frac{e^{x_1}}{\sum_{i=1}^N e^{x_i}},\cdots,\frac{e^{x_N}}{\sum_{i=1}^N e^{x_i}}\right],
\end{align}
where the \textit{softmax}$(\cdot)$ is an activation function to normalize the inputs. By using it, we can extract all actions' probabilities of the \textit{actor} with the observable $\langle O_a\rangle_{o,\boldsymbol{\theta}}$ in~\eqref{obs:actor}.
\BfPara{Quantum Centralized Critic}
The CTDE has a \textit{centralized critic} responsible for valuing the current state with a state-value function as follows,
\begin{multline}
V_{\boldsymbol{\phi}}(s) \!=\! \langle O_c \rangle_{s, \boldsymbol{\phi}} \!\simeq \! \\
\mathbb{E}_{s_{\textrm{real}}\sim E,\,\mathrm{a}_{\textrm{real}}\sim\pi_{\boldsymbol{\theta}}}\left[\sum_{t'=t}^{T} \gamma^{t'-t}\!\!\cdot r(s_{\textrm{real}},\!\mathbf{a}_{\textrm{real}},s'_{\textrm{real}})\right],
\end{multline}
where $s_t$ is the measured state at the current state at $t$. We can also use the \textit{critic} network's observable to evaluate the current state's value.
\subsubsection{Training and Inference}
As mentioned in~\eqref{eq:goal}, agents in MARL try to maximize the expected return. We utilize the congruent state-value function $V_\phi$ of the \textit{centralized critic} network to derive the gradients from maximizing the common goal. With the parameters of \textit{actor} and \textit{critic} networks, which correspond to $\boldsymbol{\theta}$ and $\boldsymbol{\phi}$, we can configure a multi-agent policy gradient (MAPG) based on the temporal difference \textit{actor-critic} model by \textit{Bellman optimality equation}, as follows,
\begin{multline}
\nabla_{\boldsymbol{\theta}}J(\boldsymbol{\theta}) = \\ \mathbb{E}_{s_{\textrm{real}} \sim E} \left[\sum\limits^{T}_{t=1}\sum\limits^{M}_{m=1}
\delta_{\boldsymbol{\phi}}\cdot\nabla_{\boldsymbol{\theta}_m}\log\pi_{\boldsymbol{\theta}_m}(\mathrm{a}_m|s_{\textrm{real}}, o_m)\right],
\label{eq:l_actor}
\end{multline}
and
\begin{equation}
\nabla_{\boldsymbol{\phi}}\mathcal{L}(\boldsymbol{\phi}) = \sum^{T}_{t=1}\nabla_{\boldsymbol{\phi}}\left\|\delta_{\boldsymbol{\phi}}\right\|^2,
\label{eq:l_critic}
\end{equation}
subject to
\begin{equation}
\delta_{\boldsymbol{\phi}} = r\left(s_{\textrm{real}},\mathbf{a}_{\textrm{real}},s'_{\textrm{real}}\right)+\gamma V_{\boldsymbol{\phi}}(s'_{\textrm{real}})-V_{\boldsymbol{\phi}}(s_{\textrm{real}}),
\label{eq:delta}
\end{equation}
where \eqref{eq:l_actor} is the objective function for \textit{actor} networks, and the other is the loss function for \textit{critic} network.
We describe how to obtain loss gradients with quantum and classical computing. Hereafter, we denote an \textit{actor}-network and \textit{critic} network as $\boldsymbol{\theta}$ and $\boldsymbol{\phi}$ for mathematical amenability.
We can calculate their loss values with the temporal difference error of \textit{centralized critic} $\delta_{\boldsymbol{\phi}}$ in~\eqref{eq:delta}, where the derivative of \textit{actor}/\textit{critic}'s $i$-th parameters is expressed as follows,
\begin{eqnarray}
\frac{\partial J(\boldsymbol{\theta})}{\partial \theta_i} = \frac{\partial J(\boldsymbol{\theta})}{\partial \pi_{\boldsymbol{\theta}}} \cdot \frac{\partial \pi_{\boldsymbol{\theta}}}{\partial \langle O \rangle_{o,\boldsymbol{\theta}}}\cdot \frac{{\partial \langle O \rangle_{o,\boldsymbol{\theta}}}}{\partial \theta_i},\label{eq:loss_actor_derivative} \\
\frac{\partial\mathcal{L}(\boldsymbol{\phi})}{\partial \phi_i} = \frac{\partial\mathcal{L}(\boldsymbol{\phi})}{\partial V_{\boldsymbol{\phi}}} \cdot \frac{\partial V_{\boldsymbol{\phi}}}{\partial \langle O \rangle_{s,\boldsymbol{\phi}}} \cdot \frac{{\partial \langle O \rangle_{s,\boldsymbol{\phi}}}}{\partial \phi_i}, \label{eq:loss_critic_derivative}
\end{eqnarray}
where the first and second derivatives of RHS in \eqref{eq:loss_actor_derivative} and \eqref{eq:loss_critic_derivative} can be calculated by classical computing. However, the latter derivative cannot be calculated because the quantum state is unknown before its measurement.
Thus, we use the parameter-shift rule~\cite{crook19}. This allows us to bridge classical and quantum computing by multiplying the partial derivatives of classical and quantum computing. The parameter-shift rule applied to~\eqref{eq:l_actor}--\eqref{eq:l_critic}, where the derivative of $i$-th \textit{actor} parameter can be obtained with zeroth derivative as follows,
\begin{equation}
\frac{{\partial \langle O \rangle_{o,\boldsymbol{\theta}}}}{\partial \theta_i} =\langle O \rangle_{o,\boldsymbol{\theta} + \frac{\pi}{2} \mathbf{e}_i } - \langle O \rangle_{o,\boldsymbol{\theta} - \frac{\pi}{2} \mathbf{e}_i },\label{eq:param-shift}
\end{equation}
where $\mathbf{e}_i$ correspond to the $i$-th basis of $\boldsymbol{\theta}$, respectively. Similarly, the LHS of \eqref{eq:loss_critic_derivative} is obtained via \eqref{eq:param-shift}.
Finally, we can calculate the gradient of the objective function as elaborated in \eqref{eq:l_actor}--\eqref{eq:l_critic}.
\subsubsection{Algorithm Pseudo-Code}
Details of the proposed CTDE-based training and inference procedure is explained in Algorithm~\ref{alg:CTDE} and the corresponding descriptions are as follows.
\begin{enumerate}
\item
Initialize the parameters of \textit{actor} and \textit{centralized critic} networks, which are $\boldsymbol{\theta}$ and $\boldsymbol{\phi}$, respectively \textsc{(line 1)}.
\item
All agents learn their policy by repeating the below procedure until all training epochs reach maximum epochs:
(i) At the start of every epoch, initialize environments to set starting state $s_0$ \textsc{(line 3)}.
(ii) Each UAV selects an action based on its policy for every time step. By taking action, the environment is transited to the next time step ${s}^{t+1}$ \textsc{(lines 5–7)}. Calculate the total reward $R^t$ and transition pairs (\textit{i.e.,} experiences) by UAVs $\xi = \{s^t, \textbf{o}^t, R^t, s^{t+1}, \textbf{o}^{t+1}\}$ are stored in the replay buffer $\mathcal{D}$ \textsc{(lines 8-10)}.
(iii) UAVs randomly sample the mini-batch from $\mathcal{D}$ for getting $V_{\boldsymbol{\phi}}$. By doing so, the learning performance improves by reducing the continuity of the data used for training~\cite{mnih2013playing}. Note that we start training networks of UAVs to prevent the direction of training from being biased to initial data \textsc{(lines 12-13)}.
(iv) Update parameters of the \textit{centralized critic} network $\boldsymbol{\phi}$ by gradient descent to the loss function to reduce its value \textsc{(lines 14-15)}.
(v) Update parameters of all \textit{actor} network by gradient ascent to the objective function in the direction of increasing its value evaluated by \textit{centralized critic} network \textsc{(line 16)}.
After completing all UAVs' policies training, they perform multiple inference processes on the environment \textsc{(lines 19-27)}.
\end{enumerate}
\begin{algorithm}[t]
\small
Initialize weights of the \textit{actor} and \textit{centralized critic} networks which are denoted as $\boldsymbol{\theta}$ and $\boldsymbol{\phi}$, $\forall m \in [1,M]$ \\
\For{Epoch = 1, MaxEpoch}{
$\triangleright$ \textbf{Initialize Multi-UAV Environments}, set $s_0$ \\
\For{time step = 1, $T$}{
\For{each UAV $m$}{
$\triangleright$ Select the action $\mathrm{a}_m$ based on its policy $\pi_{\boldsymbol{\theta}_m}(a_m\,|\,o_m)$ at time step $t$ \\
}
$\triangleright$ $s^t \rightarrow s^{t+1}$, $\textbf{o}^t \rightarrow \textbf{o}^{t+1}$ with the reward $R^t$
$\triangleright$ Set $\xi= \{s^t, \textbf{o}^t, \textbf{a}^t, R^t, s^{t+1}, \textbf{o}^{t+1}\}$ \\
$\triangleright$ Update replay buffer $\mathcal{D}$: $Enqueue(\mathcal{D},\xi)$ \\
}
\If {$\mathcal{D}$ \textbf{is full enough to train:}}{
\For{each UAV $m$}{
$\triangleright$ Get $V_{\boldsymbol{\phi}}$ by sampling mini-batch from $\mathcal{D}$\\
$\triangleright$ Update $\boldsymbol{\phi}$ by \textbf{gradient descent} to loss function of the \textit{centralized critic} network: $\nabla_{\boldsymbol{\phi}}\mathcal{L}(\boldsymbol{\phi})$ \\
$\triangleright$ Update $\boldsymbol{\theta}_m$ by \textbf{gradient ascent} to objective function of the \textit{actor} network: $\nabla_{\boldsymbol{\theta}_m}J(\boldsymbol{\theta}_m)$
}
}
}
\For{Episode = 1, MaxEpisode}{
$\triangleright$ \textbf{Initialize Multi-UAV Environments}, set $s_0$ \\
\For{time step = 1, $T$}{
\For{each UAV $m$}{
$\triangleright$ Select the action $\mathrm{a}_m$ based on its policy $\pi_{\boldsymbol{\theta}_m}(a_m\,|\,o_m)$ at time step $t$ \\
}
$\triangleright$ $s^t \rightarrow s^{t+1}$, $\textbf{o}^t \rightarrow \textbf{o}^{t+1}$ with the reward $R^t$ \\
}
}
\caption{QMACN training and inference process for multi-UAV cooperation}
\label{alg:CTDE}
\end{algorithm}
\begin{table}[t!]
\small
\caption{Experimental setup parameters}
\centering
\begin{tabular}{c|l|r}\toprule[1pt]
\multicolumn{2}{c}{\textbf{{Parameters}}} & \textbf{{Values}} \\
\midrule
$M$ & The number of UAVs & $4$ \\
$N$ & The number of UEs & $25$ \\
$T$ & Episode length & $30\,\mathrm{min}$ \\
- & State dimension & $179$ \\
- & Action dimension & $4$ \\
$\mathcal{D}$ & Replay buffer size & $50$k \\
- & Mini-batch size & $32$ \\
$\gamma$ & Discount factor & $0.98$ \\
$w_c$ & Reward coefficient & $0.01$ \\
$\epsilon$ & Initial value of epsilon & $0.275$ \\
- & Annealing epsilon & $0.00005$ \\
- & Minimum epsilon & $0.01$ \\
- & Training epochs & $10$k \\
- & Learning rate of \textit{actor} & $0.001$ \\
- & Learning rate of \textit{centralized critic} & $0.00025$ \\
- & Activation function & ReLU \\
- & Optimizer & Adam \\
\bottomrule[1pt]
\end{tabular}
\label{tab:parameter}
\end{table}
\section{Performance Evaluation}\label{sec:5}
\subsection{System Setup}
\subsubsection{Environment}
Our environment setting includes two primary objects, ground users (\textit{i.e.}, UEs) and UAVs. UEs are randomly distributed over $6,000\times6,000\,\mathrm{m}^2$ area/map; and UAVs fly at the altitude of $2500\,\mathrm{m}$. For UAV mechanical modeling, DJI Phantom4 Pro v2.0 is used~\cite{tvt202106jung}. We assume that all UAVs are located at the center of the map, it the start of every episode.
Table \ref{tab:parameter} summarizes other environmental parameters.
\subsubsection{Communication Methodology}
In addition, a 60\,GHz mmWave wireless technology is considered for communications.
The reason why the 60\,GHz wireless network is considered is that it has \textit{i)} a large channel bandwidth, \textit{ii)} low-latency transmission, \textit{iii)} high beam directivity, \textit{iv)} high diffraction, and \textit{v)} high scattering~\cite{singh2011interference}.
These characteristics are advantageous due to less sensitivity to interference from nearby mobile access (spatial reuse) while being sensitive to blocking~\cite{singh2011interference}.
In an urban environment, for example, blocking by high-rise buildings may affect mmWave wireless systems. However, our proposed algorithm can minimize this problem through the optimal cooperative UAVs positioning. Thus, it is possible to provide better QoS to users using high directivity as well as low latency~\cite{singh2011interference}. More details are in~\cite{park2022cooperative} and also summarized in Appendix~\ref{sec:mmwave}.
\subsubsection{Benchmark}
We will compare the performance of our proposed method against various benchmarks to substantiate the proposed QMARL algorithm, as outlined below.
\begin{itemize}
\item `{{w/ Dual noise (Proposed)}}' trains each UAV's policy with our QMARL algorithm in a realistic environment with state and action noise. Accordingly, the position of the UAV is affected by not only its action decision. We conduct an \textit{ablation study} to investigate how each noise component affects the performance and robustness of our model against noise.
\item `{{w/ State noise}}' and `{{w/ Action noise}}' train the policy with QMARL algorithm with only state noise from GPS sensors and action noise from winds, respectively.
\item `{{Ideal}}' trains the policy using QMARL algorithm in an environment without noise. It means that the position of the UAV is only dependent on its action decision.
\item `{{CMARL}}' is the latest MARL using classical neural networks to compare the training performance with our proposed QMARL algorithm. The multi-UAVs in this training scheme train their policies by the classical CTDE using backpropagation~\cite{hecht1992theory}. Note that we set the same number of model parameters with our proposed QMARL training benchmarks.
\item `{{Random walk}}' algorithm means all UAVs decide their actions randomly regardless of given state and observation information. By comparing it, we can verify the superiority of MARL.
\end{itemize}
\subsection{Feasibility of Reward Function Design}
In this subsection, we will scrutinize the feasibility of reward function design with Fig.~\ref{fig:overall_result}.
From the results, we observe that noise-reflected benchmarks (\textit{i.e.}, `w/ Dual noise', `w/ State noise', and `w/ Action noise') show huge fluctuations (\textit{i.e.,} high variance) than the ideal due to the noise effect.
However, the total rewards of QMARL-based training algorithms converge to a more considerable value than the above two benchmarks at the end of the training process. Despite fewer parameters, we emphasize that our proposed QMARL algorithm has a more predominant policy training performance than the CMARL. UAVs trained by the QMARL get analogous final reward values in the order of `Ideal', `w/ Action noise', `w/ State noise', and `w/ Dual noise'.
Next, the average support rate and QoS of ground UEs' tend to be similar to the reward convergence as observed in Fig.~\ref{fig:support_rate}--\ref{fig:qos}. These results show that our formulation about the reward function is well set for multi-UAVs to achieve the intended goals of reliable wireless communication service provisioning.
In summary, we confirm that our reward design is justified for not only ideal condition but noise contained environment.
\begin{figure*}[!ht]
\centering
\includegraphics[width=0.75\linewidth]{Figure/Comp_description.pdf}\\
\subfigure[Average total reward.]{
\includegraphics[width=0.31\linewidth]{Figure/reward-eps-converted-to.pdf}
\label{fig:reward}
}
\subfigure[Average support rate.]{
\includegraphics[width=0.31\linewidth]{Figure/support_rate-eps-converted-to.pdf}
\label{fig:support_rate}
}
\subfigure[Average total QoS.]{
\includegraphics[width=0.31\linewidth]{Figure/quality_of_service-eps-converted-to.pdf}
\label{fig:qos}
}
\caption{Average values of training results in all training benchmarks in every time step. Fig.~\ref{fig:reward} shows UAVs' total obtained rewards over the entire epochs, Fig.~\ref{fig:support_rate} shows UAVs' total obtained average support rate over the entire epochs, and Fig.~\ref{fig:qos} shows the ground UEs' support rate and QoS served by UAVs.}
\label{fig:overall_result}
\end{figure*}
\begin{figure}
\centering
\includegraphics[width=0.75\linewidth]{Figure/NN_description.pdf}\\
\includegraphics[width=0.75\linewidth]{Figure/reward_dim-eps-converted-to.pdf}
\caption{Comparison reward convergence of each training method in classical neural networks and quantum computing. \textit{dim} means the dimension of the hidden layer in each classical neural network.}
\label{fig:with_classical_NN}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[width=0.9999\linewidth]{Figure/Comp_description2.pdf}\\
\subfigure[Support Rate.]{
\includegraphics[width=0.43\linewidth]{Figure/num_user-eps-converted-to.pdf}
\label{fig:inference_support_rate}
}
\subfigure[QoS.]{
\includegraphics[width=0.43\linewidth]{Figure/qos-eps-converted-to.pdf}
\label{fig:inference_qos}
}
\\
\subfigure[Average Support Rate.]{
\includegraphics[width=0.415\linewidth]{Figure/Bar_support_rate-eps-converted-to.pdf}
\label{fig:inference_support_rate_avg}
}
\subfigure[Average QoS.]{
\includegraphics[width=0.415\linewidth]{Figure/Bar_qos-eps-converted-to.pdf}
\label{fig:inference_qos_avg}
}
\caption{Overall support rate and quality of service in the {inference process} where there are state and action noise.}
\label{fig:inference}
\end{figure}
\subsection{Comparison with Classical Neural Networks}
This subsection will determine the hidden layer's dimension of the `{{CMARL}}', and investigate quantum performance compared to existing neural networks. Fig~\ref{fig:with_classical_NN} illustrates the tendency of the reward convergence with the classical neural networks varying from 1 to 128, the ideal, and the random walk in an ideal environment. Placing an adequate number of neurons in the hidden layers can reduce training time with high accuracy, but overfitting problems arise when there are unnecessary increases in neurons or layers. It means that more neural networks with more neurons do not necessarily have better training performance. Among all training benchmark algorithms, our QMARL outperforms in terms of the reward convergence value and speed. Except for QMARL, only classical neural networks with 64 and 128 hidden dimensions obtained higher rewards than the random walk at the end of the training epochs. However, the classical neural network with 128 hidden dimensions has a more unstable training performance than random walk, and fewer rewards than Ideal. Therefore, it is reasonable to set the CMARL's hidden layer level to 64.
In Fig.~\ref{fig:reward}, the reward convergence trends of all training benchmarks are illustrated over the whole training epochs. {{CMARL}} and {{the random walk}}, which are not based on QMARL algorithms, have the inferior performance of training policy in terms of the total reward value than QMARL-based training benchmarks.
In summary, our proposed QMARL training algorithm (\textit{i.e.}, `Ideal') enables UAVs to learn the more near-optimal policy than CMARL in the ideal environment.
\subsection{Impact of Noise on Robustness in Realistic Environment}
After the learning process, all UAVs sequentially make decisions based on the learned policy in the inference process for attesting to the policy's feasibility. We will compare our QMARL algorithms training in various environments (\textit{i.e.,} ablation study) by inference of 100 iterations. As illustrated in Fig.~\ref{fig:inference}, `w/ Dual noise' has the most robust and highest value regarding support rate (avg.\,60.9\,\%) and QoS (avg.\,37.2) in the entire inference process. `w/ State noise' and `w/ Action noise' constitute the second reliable mobile access with 18\,\% lower support rate and 25\,\% lower QoS than `w/ Dual noise'. `Ideal' provides the poorest wireless communication service due to environmental noise among all QMARL training algorithms. It served an average 77\,\% lower support rate and QoS to ground UEs than `w/ Dual noise'. In a nutshell, the more noise we consider similar to the real environment, the more robust and reliable the agent can learn policies to build mobile access in the real world.
\subsection{Discussion}
This section will discuss the performance of our proposed noise-reflected QMARL training algorithm with the experimental results in Sec.~\ref{sec:5}.
\subsubsection{Quantum Advantage in MARL Environments}
Fig.~\ref{fig:with_classical_NN}--\ref{fig:overall_result} show that our QMARL algorithms based on PQC have comparable policy training performance with fewer parameters when compared to CMARL~\cite{yun2022quantum2}. This empirical advantage lies in memorization, a representative hallmark of PQC~\cite{jerbi2021parametrized}. Preserving knowledge about existing labels when learning new labels helps train policies near-optimally~\cite{yun2022quantum2}. Quantum has sufficient flexibility in this feature, but conventional neural networks (\textit{i.e.,} DNN policy) do not~\cite{jerbi2021parametrized}. This difference affects the speed or performance of training, as observed in our numerical performance evaluations. In addition, quantum gates employing quantum features (\textit{i.e.,} superposition, entanglement) have the advantage of exponential computational gain over conventional neural networks~\cite{shor1999polynomial}.
\subsubsection{Effects of Noise Injection for Realistic Environment Design}
This paper conducted an ablation study with noise reflection. In general, environmental noise affects the behavior of agents in RL. However, some Gaussian noises improve policy robustness~\cite{he2019parametric} and alleviate the malfurious effects on the gradient quality by selective noise injection (SNI)~\cite{igl2019generalization}. This scheme helps the agent achieve desired goals more efficiently as well as work robustly to natural noise. Our noise models in~\eqref{eq:state_noise}--\eqref{eq:action_noise} following Gaussian distributions make UAVs come across abundant experience in environments and prevent overfitting to restricted training environments for a reason in Fig.~\ref{fig:reward}. Even taking some fluctuations into account, benchmarks with noise (`w/ Dual noise', `w/ State noise', and `w/ Action noise') have a faster convergence speed and higher value regarding rewards compared to `Ideal'. Furthermore, we investigated the model robustness in realistic environments with noise in Fig.~\ref{fig:inference}.
\section{Concluding Remarks}\label{sec:6}
This paper proposes a CTDE-based quantum multi-agent actor-critic networks ({QMACN}) training algorithm for constructing a robust mobile access using multiple UAVs. For the practical use of QC, we adopt a CTDE in overcoming scalability and physical issues in order to realize quantum supremacy. Our proposed {QMACN} algorithm verifies the advantage of QMARL with the remarkable performance improvements in terms of training speed and wireless service quality in various data-intensive evaluations. Moreover, we successfully validate that the noise injection scheme can help multiple UAVs react to environmental uncertainties, making mobile access more robust. In a nutshell, our proposed {QMACN} algorithm shows considerable performance improvements in constructing the cooperative multi-UAV mobile access compared to the conventional training methods with fewer model parameters, which leads to efficient computing resource management.
\bibliographystyle{IEEEtran}
| {'timestamp': '2023-02-10T02:06:49', 'yymm': '2302', 'arxiv_id': '2302.04445', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04445'} | arxiv |
\section{Introduction}
\IEEEPARstart{Q}{uadrotors} , also known as quadrotor unmanned aerial vehicles (UAVs), are increasingly being utilized for a variety of applications, including search-and-rescue, homeland security, package delivery, and military surveillance \cite{shraim2018survey}. However, the propellers of these UAVs may be subject to damage during task execution (see Fig. \ref{propeller}) due to unexpected circumstances, such as collision with obstacles. Such damage can compromise the ability of the UAV to complete its assigned tasks, and may even result in catastrophic damage to the UAV itself and potentially those in the immediate vicinity. To mitigate these risks, real-time monitoring of the condition of quadrotor propellers is crucial. By detecting and addressing issues with the propellers in a timely manner, we can ensure the safe and effective operation of these UAVs, and ultimately prevent potential damages and injuries.
\begin{figure}[htp]
\centering
\includegraphics[width=0.8\linewidth]{Figures/Fig1.png}
\caption{Examples of broken propellers}
\label{propeller}
\end{figure}
Model-based methods are a common approach for detecting faults in quadrotors \cite{guzman2019actuator}, \cite{amoozgar2013experimental}. These methods involve first developing system models and then identifying faults based on the difference between the model output and the actual output. However, accurately modeling quadrotor systems can be challenging, as it requires extensive expert knowledge and may require multiple experiments to identify structural parameters.
In contrast, data-driven approaches, which operate in a model-free manner, have received increasing attention in recent years \cite{iannace2019fault}, \cite{park2022multiclass}. These approaches utilize deep neural networks (DNNs) \cite{hinton2006reducing} to directly map sensor input to the results of the diagnosis. The parameters of the DNNs are learned from real-world flying data. As they are data-driven and work in an end-to-end fashion, such approaches do not require the development of system models or the design of fault classifiers based on these models. Much of the previous work in this area \cite{yang2021intelligent}, \cite{yang2021intelligentb} has focused on designing powerful DNN models that can learn the complex nonlinear relationship between the input features and use this knowledge to identify propeller faults.
While data-driven approaches have demonstrated promising results for fault diagnosis in quadrotors, collecting flying data with broken propellers can be dangerous and costly. In contrast, generating fault data in simulation is a safer and more cost-effective option. However, there is often a discrepancy between simulation data and real flight data, known as the simulation-to-reality gap, which can result in poor performance of classifiers trained on simulation data when applied to real-flight data.
In this research, we focus on improving the performance of the classifier in the real-world by reducing the simulation-to-reality gap. To achieve this goal, we propose newly identified features (NIF) that exhibit a linear relationship between input features, allowing for efficient learning by the DNN model. These features are also capable of generalizing to data from different domains. In addition, we utilize a domain adaptation (DA) method to further enhance the cross-domain performance of the classifier. Finally, we propose an adjusted simulation model to generate training data that more accurately reflects the unbalanced behavior of real quadrotors. Overall, the contributions of our work include:
\begin{itemize}
\item Newly identified features are proposed to enhance the robustness of the classifier to domain changes.
\item Domain adaptation is utilized to reduce the domain gap and improve the performance of the classifier in the target domain.
\item With the help of NIF, DA and the adjusted simulation model, the fault classifier trained with simulation data can achieve high accuracy when applied to real flight.
\end{itemize}
The remainder of this paper is organized as follows. A brief overview of related works is provided in Section \ref{RW}, followed by the problem description in Section \ref{Preliminaries}. The intelligent diagnosis method is introduced in Section \ref{approach}, and extensive experiments are conducted to evaluate our method in Section \ref{Implementation}. Last, we draw the conclusions and the future works in Section \ref{Conclusion}.
\section{Related works}\label{RW}
To identify faults in propellers using deep learning, there are two main approaches based on the input source. The first involves using a specific sensor to monitor propeller conditions, with microphone arrays being a popular choice. For example, Katta et al. \cite{katta2022real} used microphone arrays to detect propeller faults and released a dataset for further research. They first converted audio data into Mel-frequency cepstral coefficient (MFCC) features and used deep neural networks such as convolutional neural networks (CNNs) \cite{lecun1995convolutional}
and transformer \cite{vaswani2017attention} encoders as fault classifiers. Similarly, Liu et al. \cite{liu2020audio} used CNNs to diagnose faults from the time-frequency spectrum of audio signals, and also employed transfer learning to reduce the training time of fault classifiers for quadrotors with different dynamics. Instead of installing microphones on the quadrotor, Iannace et al. \cite{iannace2019fault} placed microphones around the quadrotor to detect unbalanced propellers. With this setup, a one-hidden-layer neural network achieved an accuracy of 97.63\%. While this approach has high accuracy in indoor scenarios, its performance in outdoor environments, particularly under windy conditions, may be impaired. Additionally, it requires installing a microphone array on top of the quadrotor, which increases cost and battery consumption.
The second approach involves using flying data to monitor propeller conditions. Yang et al. \cite{yang2021intelligent} proposed a deep residual shrinkage network as a classifier using quadrotor state information (roll value, pitch value, roll rate, pitch rate, and yaw rate) and the four angular velocities of the propeller as input. Additionally, Park et al. \cite{park2022multiclass} used a stacked pruning sparse denoising autoencoder to process image inputs consisting of 20 signals with a length of 20 containing drone attitude, position, velocity, and acceleration information, and employed a CNN as a classifier. This approach exhibits good performance in noisy environments due to the denoising operation. However, although the trained classifiers demonstrated high accuracy during testing, their performance in different scenarios is unknown.
\section{Preliminaries}\label{Preliminaries}
First of all, abbreviations which are frequently used in this work are summarized in Table \ref{Abbreviations}.
\begin{table}[htp]
\caption{\label{Abbreviations} Abbreviations and descriptions}
\centering
\begin{tabular}{ll}
\hline
\hline
Abbreviation & Description \\ \hline
CF & Conventional features \\
DA & Domain adaptation \\
DCNN & Deep convolutional neural network \\
MMD & Maximum Mean Discrepancy \\
NIF & Newly identified features \\
t-SNE & t-distributed stochastic neighbor embedding \\ \hline
\hline
\end{tabular}
\end{table}
\subsection{Problem description}
The UAV fault diagnosis problem can be approached as a classification task, with the goal of accurately identifying the fault type of a given UAV based on its flying data. As shown in Table \ref{labels}, there are five potential fault categories, including an all-healthy category and four faulty categories. To train a classifier, we collect and label flying data for each of these categories. Utilizing this labeled dataset, we can then train a deep neural network as a classifier, with the aim of accurately predicting the fault type of a given UAV based on its flying data. The classifier has five outputs, each corresponding to one of the five fault categories.
In this study, as shown in Fig. \ref{prod}, we aim to develop a fault classifier for UAV propeller using simulated data, and subsequently apply it to real-world fault detection. This simulation-to-reality UAV fault diagnosis problem can be modeled as a cross-domain classification problem, with the simulation data serving as the source domain and the real-world data serving as the target domain.
One challenge in this scenario is that the simulation model may not perfectly match the real-world counterpart, due to factors such as noise and installation error. As a result, a classifier trained solely on source domain data may perform poorly when applied to the target domain. To reduce the domain gap, during training, the classifier also has access to all-healthy samples from the target domain. The objective of this paper is to learn a fault classifier with high fault-classification accuracy in target domain.
\begin{figure}[htp]
\centering
\includegraphics[width=1.0\linewidth]{Figures/FIG2.pdf}
\caption{Illustration of the simulation-to-reality UAV fault diagnosis problem.}
\label{prod}
\end{figure}
\begin{table}[htp]
\caption{\label{labels} Labels of five fault categories.}
\centering
\begin{tabular}{lllll}
\hline
\hline
label` & Propeller 1 & Propeller 2 & Propeller 3 & Propeller 4 \\ \hline
1 & healthy & healthy & healthy & healthy \\
2 & faulty & healthy & healthy & healthy \\
3 & healthy & faulty & healthy & healthy \\
4 & healthy & healthy & faulty & healthy \\
5 & healthy & healthy & healthy & faulty \\
\hline
\hline
\end{tabular}
\end{table}
\section{APPROACH}\label{approach}
In this research, we propose a novel approach for monitoring the health status of quadrotor propellers using flying data. The comprehensive framework of the proposed approach is depicted in Fig. \ref{Framework}. Both training and testing data use the proposed newly identified input representation. The end-to-end model employed in the training process is a DCNN (Deep Convolutional Neural Network) \cite{krizhevsky2017imagenet}, which utilizes multi-source features as input and contains multiple convolutional layers. The data used for training is generated by the adjusted simulation model. During the testing phase, the trained DCNN model can be utilized for the diagnosis of propeller faults in real-world scenarios.
\begin{figure}[htp]
\centering
\includegraphics[width=1.0\linewidth]{Figures/Framework.pdf}
\caption{Framework of the proposed approach.}
\label{Framework}
\end{figure}
\subsection{Newly identified input representation}\label{A1}
In this paper, onboard flying data are utilized to monitor the health status of the quadrotor propeller. In selecting the input for the DCNN, we consider two main criteria. First, the input should contain both the input and output information for the propeller. This is because, when a propeller is damaged, the output of the propeller will change in response to the same input information. By analyzing these changes, the DCNN can effectively detect faults or failures. Second, we aim to minimize the complexity of the relationship between the input and output information. A linear relationship is generally the most straightforward and easiest for the DCNN to process, as nonlinear relationships may be more difficult for the network to effectively extract useful features from the input representation.
Based on these considerations, we select DCNN input from the quadrotor dynamic equation. By doing so, we are able to effectively capture both the input and output information for the propeller, as well as maintain a relatively simple relationship between these two variables. This allows for accurate and efficient fault detection, ultimately contributing to the overall health and safety of the quadrotor system. As shown in Fig. \ref{UAV}, based on Euler’s Equations of Motion, the relationship between the quadrotor angular accelerations $\left(\dot{p},\dot{q},\dot{r}\right)$, the forces $F_{i=1,2,3,4}$ and the torques $\tau_{i=1,2,3,4}$ of the four propellers is given in Equation \ref{dy_eq}.
\begin{figure}[htp]
\centering
\includegraphics[width=0.8\linewidth]{Figures/UAV.pdf}
\caption{The configuration of the quadrotor in the body frame.}
\label{UAV}
\end{figure}
\begin{equation}\label{dy_eq}
\begin{aligned}
I\left[\begin{matrix}\dot{p}\\\dot{q}\\\dot{r}\\\end{matrix}\right]=\left[\begin{matrix}L\left(F_3-F_4\right)\\L\left(F_2-F_1\right)\\\tau_1-\tau_3+\tau_2-\tau_4\\\end{matrix}\right]-\left[\begin{matrix}p\\q\\r\\\end{matrix}\right]\times I\left[\begin{matrix}p\\q\\r\\\end{matrix}\right].
\end{aligned}
\end{equation}
where $I$ denotes the inertia matrix as follows,
\begin{equation}\label{inertia}
\begin{aligned}
I=\left[\begin{matrix}I_{xx}&0&0\\0&I_{yy}&0\\0&0&I_{zz}\\\end{matrix}\right]
\end{aligned}
\end{equation}
where $I_{xx}$, $I_{yy}$ and $I_{zz}$ are the moments of inertia along the $x$, $y$, and $z$ axes of the quadrotor. Since $F_i=k_F\omega_i^2$ and $\tau_i=k_\tau\omega_i^2$, where $k_F$ and $k_\tau$ are two constants, Equation \ref{dy_eq} becomes
\begin{equation}\label{dy_eq2}
\begin{aligned}
I\left[\begin{matrix}\dot{p}\\\dot{q}\\\dot{r}\\\end{matrix}\right]=\left[\begin{matrix}Lk_F\left(\omega_3^2-\omega_4^2\right)\\Lk_F\left(\omega_2^2-\omega_1^2\right)\\k_\tau\left(\omega_1^2-\omega_3^2+\omega_2^2-\omega_4^2\right)\\\end{matrix}\right]-\left[\begin{matrix}p\\q\\r\\\end{matrix}\right]\times I\left[\begin{matrix}p\\q\\r\\\end{matrix}\right]
\end{aligned}
\end{equation}
When one of the propellers breaks, under the same rotational speed of the motor, the generated force and torque are different from the healthy counterpart. Once the force and torque of the propeller change, the quadrotor’s angular accelerations will change accordingly. Based on this observation and our two criteria, at time step $t$, the input $x_t$ to the DCNN is designed as as follows,
\begin{equation}\label{input_eq}
\begin{aligned}
x_t=\left[\begin{matrix}{\dot{p}}_{t-T}&{\dot{p}}_{t-T+1}&\cdots&{\dot{p}}_t\\{\dot{q}}_{t-T}&{\dot{q}}_{t-T+1}&\cdots&{\dot{q}}_t\\{\dot{r}}_{t-T}&{\dot{r}}_{t-T+1}&\cdots&{\dot{r}}_t\\\omega_{1, t-T}^2&\omega_{1, t-T+1}^2&\cdots&\omega_{1, t}^2\\\omega_{2, t-T}^2&\omega_{2, t-T+1}^2&\cdots&\omega_{2, t}^2\\\omega_{3, t-T}^2&\omega_{3, t-T+1}^2&\cdots&\omega_{3, t}^2\\\omega_{4, t-T}^2&\omega_{4, t-T+1}^2&\cdots&\omega_{4, t}^2\\\end{matrix}\right].
\end{aligned}
\end{equation}
where $T$ ($T=80$ in this paper) is the length of the time window, which controls the range of historical information of the input. As shown, $x_t$ can be treated as a temporal signal which contains seven feature channels. As these input features are newly identified by this work, we refer to $x_t$ as newly identified features (NIF).
\subsection{DCNN model with domain adaptation}\label{AdaIP}
Recently, deep convolutional neural networks (DCNNs) have gained significant traction as a powerful end-to-end classification tool for fault diagnosis tasks \cite{Zhang2017}, \cite{Zhang2018}. These networks are able to learn to extract useful features from multi-channel time-sequence input data through the use of convolutional layers, and subsequently classify these features using dense layers.
The structure of the DCNN model used in this study is depicted in Fig. \ref{DCNN}. The input of DCNN (see Eq. \ref{input_eq}) is treated as a one-dimensional signal with seven input channels. As shown, the first layer is a 1D convolutional layer with a kernel size of three and 64 filters. Following the convolutional layer, a max-pooling operation is performed to reduce the dimensions of the extracted features. This convolutional and max-pooling module is repeated three times in subsequent layers, with the goal of effectively extracting useful feature representations from the input data.
After the four convolutional and max-pooling modules, two dense layers with 128 neurons and a softmax layer are employed to classify the extracted features into five distinct categories. In order to enhance the generalization performance of the model, layer dropout \cite{Srivastava2014} with a dropout rate of 0.1 is applied to the two dense layers. The output layer utilizes the Softmax function to transform the logits of the five neurons into discrete probability distributions representing the five possible quadrotor health conditions. The formula for the Softmax function is as follows:
\begin{equation}\label{dynamic}
\begin{aligned}
q\left(z_j\right)=\text{softmax}\left(z_j\right)=\frac{e^{z_j}}{\sum_{i=1}^{5}e^{z_i}}.
\end{aligned}
\end{equation}
where $z_j$ denotes the logits of the $j$-th output neuron.
The classification loss of our DCNN model is the cross-entropy loss between the estimated softmax output probability distribution and the target class probability distribution. Let $p(x)$ denote the target distribution (the one-hot format labels) and $q(x)$ denote the estimated distribution outputted by DCNN, the cross-entropy between $p(x)$ and $q(x)$ is:
\begin{equation}\label{dynamic}
\begin{aligned}
\mathcal{L}_{cross_entropy}= H(p(x),q(x))=-\Sigma_{x}p(x)\log q(x).
\end{aligned}
\end{equation}
\begin{figure}[htp]
\centering
\includegraphics[width=0.9\linewidth]{Figures/net_MMD.pdf}
\caption{The structure of DCNN.}
\label{DCNN}
\end{figure}
When a fault classifier is utilized for fault diagnosis, its performance may be compromised due to the different distributions of the target and source domain data. To address this issue, domain adaptation (DA) methods are frequently employed to align the distribution of the target domain data with that of the source domain data. However, typical DA approaches require access to the full range of unlabeled data from the target domain, which is not feasible in our case due to the risks associated with flying a quadrotor with a broken propeller. Therefore, our DA method aims to utilize only the all-healthy samples from the target domain to extract transferable features, which allows for a safer approach. Similar to \cite{Wen2018}, only the all-healthy samples from the target domain are utilized for DA. Our DA method is under the following assumption,
\begin{assumption}\label{assumption1}
The cross-domain variation way for samples of different faults is similar
\end{assumption}
Under the assumption that the distributions of healthy source and target domain data are brought closer together, it is possible to decrease the distance between the source and target domain distributions of other categories. In this paper, we use Maximum Mean Discrepancy (MMD) to measure the distance between the distributions of all-healthy data in the source and target domains in the feature space. As shown Fig. \ref{DCNN}, the features used for calculating the MMD loss are extracted from the first dense layer. With the features, the MMD loss is defined as follows,
\begin{equation}\label{MMD loss}
\begin{aligned}
\mathcal{L}_{MMD}=\lVert\frac{1}{n_{c}^s}\sum_{p=1}^{n_{c}^s}\phi\left(x_{c,p}^s\right)-\frac{1}{n_{\omega_c}^t}\sum_{q=1}^{n_{c}^t}\phi\left(x_{c,q}^t\right)\rVert_\mathcal{H}^2.
\end{aligned}
\end{equation}
where $\phi(x)$, representing the features outputted by the first fully-connected layer, and $x_{c}^s$ and $x_{c}^t$ are samples of the $c$ ($c=1$ in this report) category from $\mathcal{D}^s$ and $\mathcal{D}^t$, respectively. The minimization of the MMD loss serves to align the distribution of real flight all-healthy samples with that of simulated all-healthy samples.
By integrating the classification loss and MMD loss together, the model loss function is as follows,
\begin{equation}\label{dynamic}
\begin{aligned}
\mathcal{L} = \mathcal{L}_{cross\_entropy}+\lambda\mathcal{L}_{MMD}
\end{aligned}
\end{equation}
where $\lambda$ is a constant which weighs the contribution of the MMD loss.
\subsection{Adjusted simulation model}
In our previous simulation model \cite{tong2023machine}, we follow an ideal dynamic model of the quadrotor, i.e., if given four propellers with the same rotation speed, it should be in an upright hovering position with angular velocity and acceleration equal to zero. However, in the real world, this behavior is often not realistic because of the following factors: 1) the center of gravity that is off-centered; 2) the imperfect condition of the mounted propeller or motor; 3) the inaccuracy of flight sensors as well as the imperfect build of the quadrotor’s structure. Therefore, to make our simulation more accurate in fault detection on real flight data, we need to adjust our simulation model based on the real-flight data to account for this phenomenon.
To achieve this, the rotational speeds of the motors are adjusted by multiplying the unbalanced ratio $\rho$. The unbalanced ratio is designed by the following observation: if the average speed of motor \textit{i} is higher than motor 1 at steady state, which means that, on average, motor \textit{i} must rotate faster to keep the quadrotor in a stable position. Hence, in simulation, motor \textit{i} is assumed to be weaker than motor 1 such that it is required to rotate at a faster rate to produce similar torque and thrust. The unbalanced ratio can be computed using the average RPM ($\bar\omega_i$) of each respective motor over the baseline motor 1 ($\bar\omega_1$) during steady state, i.e.,
\begin{equation}
\rho_i=\frac{\bar\omega_i}{\bar\omega_1}
\end{equation}
where \textit{i} is index of the \textit{i-}th motor. As $\rho_i$ varies with $\omega_i$, a linear interpolation approach is used to compute the specific ratio at each respective $\omega_i$ value of the motor. The computation of $\rho_i(\omega_i)$, is as follows,
\begin{equation}
\rho_i(\omega_i)=\frac{\omega_i}{\max(\omega_i)}\rho_i
\end{equation}
with the specific unbalanced ratio $\rho_i(\omega_i)$, the adjusted rotational speed of motor \textit{i} is as follows
\begin{equation}
\omega_{i, a}=\rho_i(\omega_i)\omega_i
\end{equation}
\section{Implementation and test}\label{Implementation}
In this section, we evaluate the simulation-to-reality performance of the proposed method. The training data for the DCNN model is generated using the adjusted simulation model. After training, the DCNN model is applied to classify faults on real flight data."
\subsection{Dataset Description}
The quadrotor angular accelerations $\left(\dot{p_t},\dot{q_t},{\dot{r}}_t\right)$ can be calculated using the angular velocities of the quadrotor. However, the motor velocities cannot be directly measured or calculated using the available flying data. According to \cite{Powers2015}, the relationship between the real motor velocity $\omega_i$ and the commanded motor velocity $\omega_i^{com}$ is as follows,
\begin{equation}\label{dynamic}
\begin{aligned}
{\dot{\omega}}_i=k_m\left(\omega_i^{com}-\omega_i\right).
\end{aligned}
\end{equation}
where the time constant $k_m$ is the motor gain. As a first approximation, it can be assumed that the motor controller is perfect and that the time constant related to the motor response is arbitrarily small \cite{Powers2015}. In other words, it can be assumed that the real motor velocity and the commanded motor velocity are equal. Hence, in this paper, we use $\omega_i^{com}$ as the $\omega_i$ for fault diagnosis.
The adjusted simulation model was utilized to generate dataset S, which will be employed for the training of the DNN model. As illustrated in Fig. \ref{sim_exp}, for each fault category, the UAV autonomously flew to the specified waypoints during data collection in the simulation process. As depicted in Table \ref{real_dataset}, a total of 800 samples were generated for each fault category using the adjusted simulation model, resulting in a comprehensive dataset for each fault category.
\begin{table*}[htp]
\centering
\caption{\label{real_dataset} Description of quadrotor datasets generated from simulation (for training) and real flight (for testing).}
\begin{tabular}{|c|c|c|ccccc|}
\hline
\multirow{3}{*}{\begin{tabular}[c]{@{}c@{}}Dataset\\ name\end{tabular}} & \multirow{3}{*}{\begin{tabular}[c]{@{}c@{}}Dataset type\end{tabular}} & \multirow{3}{*}{\begin{tabular}[c]{@{}c@{}}Dataset domain\end{tabular}} & \multicolumn{5}{c|}{Category label (fault location)} \\ \cline{4-8}
& & & \multicolumn{1}{c|}{1 (None)} & \multicolumn{1}{c|}{2 (Propeller 1)} & \multicolumn{1}{c|}{3 (Propeller 2)} & \multicolumn{1}{c|}{4 (Propeller 3)} & 5 (Propeller 4) \\ \cline{4-8}
& & & \multicolumn{5}{c|}{Number of samples} \\ \hline
S & Training & \begin{tabular}[c]{@{}c@{}}Source domain (Simulation)\end{tabular} & \multicolumn{1}{c|}{800} & \multicolumn{1}{c|}{800} & \multicolumn{1}{c|}{800} & \multicolumn{1}{c|}{800} & 800 \\ \hline
T & Testing & \begin{tabular}[c]{@{}c@{}}Target domain (Real flight)\end{tabular} & \multicolumn{1}{c|}{800} & \multicolumn{1}{c|}{800} & \multicolumn{1}{c|}{800} & \multicolumn{1}{c|}{800} & 800 \\ \hline
\end{tabular}
\end{table*}
In order to gather real flight data for testing purposes, indoor experiments were conducted as depicted in Fig. \ref{real_exp}. Prior to the real flight, the real UAV was equipped with a broken propeller (see Fig \ref{bp}) in the designated position (see Fig. \ref{real_UAV}). It is important to note that only one broken propeller was installed for each fault category, while the remaining propellers were healthy. During data collection, the UAV was manually controlled by a pilot for approximately two minutes, and this procedure was repeated five times to encompass the five fault categories. The resulting real flight data was used to generate Dataset T for testing purposes.
\begin{figure}[htpb]
\centering
\subfloat[Data collection in simulation]{
\includegraphics[width=0.45\linewidth]{Figures/wp3.png}\label{sim_exp}}
\subfloat[Data collection in real flight]{
\includegraphics[width=0.45\linewidth]{Figures/real_exp.png}\label{real_exp}}
\caption{Data collection in simulation and real flight.}
\label{data_collection}
\end{figure}
\begin{figure}[htpb]
\centering
\subfloat[Broken propellers]{
\includegraphics[width=0.7\linewidth]{Figures/bp.png}\label{bp}}
\\
\subfloat[Real UAV model]{
\includegraphics[width=0.7\linewidth]{Figures/real_UAV.png}\label{real_UAV}}
\caption{The real UAV model and broken propellers used in real-world data collection.}
\label{real_propeller}
\end{figure}
\subsection{Training details}
To assess the performance enhancement of the proposed NIF on the DCNN model in the target domain, a comparison was conducted with conventional features (CF, as used in \cite{yang2021intelligent}). Similar to NIF, CF also comprises a multi-channel temporal signal with nine feature channels: roll value, pitch value, roll rate, pitch rate, yaw rate, and the four rotational speeds of the propellers. As CF has nine feature channels, the channel number of its DCNN model is nine. Apart from that, the network structures of the DCNN models utilized for NIF and CF are equivalent. These models are referred to as DCNN+NIF and DCNN+CF, respectively. Furthermore, domain adaptation was applied to the DCNN+NIF model, resulting in the model named DCNN+NIF+DA.
The training hyperparameters are presented in Table \ref{training}. The training process was terminated when the maximum number of training epochs was reached or when the training loss did not decrease after ten consecutive epochs. The utilization of a GPU (RTX 2080Ti) facilitated the acceleration of each training process, which took approximately ten minutes. The network saved for testing was the one with the smallest training loss. To evaluate the stability and repeatability of each model, the training process was repeated ten times.
\begin{table}[htp]
\caption{\label{training} Hyperparameter settings.}
\centering
{\begin{tabular}{ll}
\hline
\hline
Hyperparameters & Value \\ \hline
Mini-batch size & 128 \\
Learning rate & $5\times10^{-4}$ \\
Maximum training epochs & 50 \\
Optimizer & Adam \\
Dropout rate & 10\% \\
Factor of MMD loss: $\lambda$ & $10^4$ \\
\hline
\hline
\end{tabular}}
\end{table}
\subsection{Results and comparison study}
After training, the DCNN model can be effectively utilized for fault classification tasks. The classification accuracy of the DCNN+CF, DCNN+NIF, and DCNN+NIF+DA models on Datasets S and T are presented in Fig. \ref{real_acc}. As depicted, the value of each bar represents the average accuracy over ten runs, with the standard deviation of the ten-time accuracy also displayed above each bar. It can be seen that the DCNN+CF model only attains an average accuracy of 73\%, while the proposed DCNN+NIF model achieves an accuracy of approximately 80\%, indicating NIF can enhance the generalization performance of the DCNN model. Moreover, the use of DA resulted in a significant enhancement in the accuracy of the DCNN model, with the accuracy increasing to 96\%. This demonstrates the reliability of the proposed DCNN+NIF+DA model as a fault classifier in real flight scenarios.
Additionally, the features learned by the DCNN+NIF+DA model on Datasets S and T are compressed into two dimensions using t-SNE \cite{van2008visualizing}. The features are extracted by the first dense layer, which is also utilized in the calculation of the MMD loss. As shown in Fig. \ref{real_tsne}The distribution of target domain data is observed to be closely aligned with that of the source domain data, which may explain why the classifier trained on source domain data is able to make accurate predictions on the target domain data.
\begin{figure}[htp]
\centering
\includegraphics[width=0.9\linewidth]{Figures/real_acc.png}
\caption{Accuracy of the three DCNN models on the Dataset S (simulation) and Dataset T (real flight).}
\label{real_acc}
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[width=0.9\linewidth]{Figures/real_tsne.pdf}
\caption{t-SNE visualization of features learned by DCNN+NIF+DA on Dataset S and Dataset T.}
\label{real_tsne}
\end{figure}
\section{Conclusion}\label{Conclusion}
In this paper, the proposed UAV fault diagnosis method effectively addresses the issue of poor performance of fault classifiers trained with simulated data due to the simulation-to-reality gap. By utilizing newly identified features and the MMD-based domain adaptation technique, as well as introducing the adjusted simulation model, our approach achieved an accuracy of 96\% in detecting propeller faults in real flight. This makes it the first reliable and efficient method for simulation-to-reality fault diagnosis of quadrotor propellers, ensuring the safe and efficient operation of these devices. In the future, we plan to extend the evaluation of our method to more challenging scenarios, such as windy outdoor environments. This will provide a better understanding of the robustness and limitations of our approach, and may inform further improvements.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2023-02-10T02:05:13', 'yymm': '2302', 'arxiv_id': '2302.04410', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04410'} | arxiv |
\section{Introduction}
\begin{figure}[t]
\begin{center}
\includegraphics[width=0.98\linewidth]{figs/overall_archi_230126_2333.png}
\end{center}
\vspace{-3mm}
\caption{The model architectures for representation types.}
\label{fig:overall_archi}
\vspace{-4mm}
\end{figure}
One of the main challenges in deep reinforcement learning (RL) from pixels is determining how to effectively represent the state of the environment. Many previous approaches have represented the state using single-vector representations \citep{dqn, vae_ood,dqn,visuomotor}, encoding the entire input image into a single vector which is then used as input for the policy network (Figure \ref{fig:overall_archi}a). However, such representations may fail to capture important relationships and interactions between entities in the scene \citep{rn}. One way to address this limitation is to use a region-based representation, where an image is encoded into a grid of representations \citep{rdrl} which are then combined using a transformer encoder that allows for explicit modeling of interactions between the different regions (Figure \ref{fig:overall_archi}b).
Recent work in learning unsupervised Object-Centric Representations (OCR) provides another potentially promising way of representing the state of the scene \citep{air,spair,space,cswm, op3, monet,iodine,genesis,genesisv2,sa,slate}.
These approaches learn a structured visual representation from images without the need for labels, modeling each image as a composition of objects.
They provide a more semantically explicit way of modeling the entities in the scene than region-based representation models and can be similarly combined using a transformer encoder to model the relationships between the objects (Figure \ref{fig:overall_archi}c).
Thus, they have the promise of being an effective pre-training technique to learn representations for downstream RL.
Most previous research in OCRs, however, have evaluated OCRs only indirectly in the context of reconstruction loss, segmentation quality, or object property prediction \citep{generalization_ocr}.
While some studies have applied OCRs to a few specific RL problems \citep{rim, smorl, cobra, load}, OCR pre-training has not been systematically and thoroughly evaluated for RL tasks. Therefore, many aspects of the relationship between OCR pre-training and RL remain unclear and further research is needed to fully understand its potential impact. This is of particular importance because many properties often show quite different behavior when it is applied to reinforcement learning due to the difficulties related to non-stationarity and reward sparsity.
In this study, we investigate the effectiveness of OCR pre-training as a representation learning framework for RL through empirical experimentation.
To achieve this, we propose a new benchmark that covers a range of object-centric tasks such as object interaction and relational reasoning \citep{stephens2008one}. The benchmark is set in a visually simple 2D scene (shown in Figure \ref{fig:task_illustration}) that current unsupervised OCR methods can successfully decompose, allowing us to isolate the effects of different experiment parameters and draw specific conclusions about when OCR pre-training is effective.
We further evaluate the performance in a more visually complex 3D scene \citep{causalworld} to explore a more realistic scenario where OCR pre-training may be beneficial.
\begin{figure}[t]
\begin{center}
\includegraphics[width=0.93\linewidth]{figs/icml_bar_overall_23-01-26-23-31-24.png}
\vspace{-3mm}
\end{center}
\caption{The performance comparison of unsupervised object-centric representation (OCR) pre-training against other representation types in object-centric tasks. The results indicate that OCR pre-training demonstrates a significant performance gap compared to other representations and slightly worse performance than ground truth states in the comparison tasks where relational reasoning is a crucial aspect. However OCR pre-training performance is similar to or worse than baselines for other tasks.}
\label{fig:overall_regime}
\vspace{-2mm}
\end{figure}
Our investigation includes evaluating a series of hypotheses that have been presumed in prior work but not systematically investigated for OCR pre-training \citep{van2019perspective,building,binding, oomdp, schemanet, rdrl,lrn,rim,load,smorl}. The results of our investigation provide insights beyond these hypotheses. For instance, one of the hypotheses posits that OCR leads to improved performance in object-centric tasks \citep{smorl}.
However, our findings, as illustrated in Figure \ref{fig:overall_regime}, indicate that while OCR pre-training can indeed lead to improved performance in relational-reasoning tasks, it may not be as beneficial in other tasks even if they are object-centric.
Another common hypothesis suggests that decompositional representations are beneficial for reasoning tasks \citep{binding,van2019perspective,building}.
From our investigation, we find that the \textit{type} of the decompositional representation is crucial -- OCR pre-training performs well on relational-reasoning tasks, but fixed region representations, another type of decompositional representation, failed to solve these tasks.
Additionally, we also investigate important characteristics of applying OCR pre-training to RL, such as performance in a visually complex environment and what kind of pooling layer is appropriate to aggregate the object representations.
The main contribution of this paper is to provide insights into the effectiveness of OCR pre-training in RL tasks and the potential and limitations of its use through empirical evidence. To accomplish this, we make the following specific contributions: (1) propose a new simple benchmark to systematically validate OCR pre-training for RL tasks, (2) evaluate OCR pre-training performance compared with various baselines on this benchmark, and (3) systematically analyze different aspects of OCR pre-training to develop a better understanding of when and why OCR pre-training is beneficial for RL. Additionally, we will release the benchmark and our experiment framework code to the community.
\begin{figure*}[t]
\centering
\includegraphics[width=0.85\textwidth]{figs/benchmark_samples.png}
\caption{Samples from the dataset and five tasks in our benchmark; Object Goal / Object Interaction / Object Comparison / Property Comparison / Object Reaching tasks. In the 2D tasks ((b) - (e)), the red ball is always the agent. See main text for details about each task. In the robotics task (f), the goal is to use the green robotic finger to touch the blue object before touching any of the distractor objects.}
\label{fig:task_illustration}
\end{figure*}
\section{Related Work} \label{sec:related_work}
\textbf{Object-Centric Representation Learning}.
Recent research in machine learning has focused on developing unsupervised object-centric representation (OCR) learning methods \citep{air,spair,sqair,space,scalor,cswm, op3, monet,iodine,genesis,genesisv2,sa,gswm,slate,savi,savi++,steve}. These methods aim to learn structured visual representations from images without the need for labels, modeling each image as a composition of objects. The motivation behind this research is the potential benefits for downstream tasks such as improved generalization and relational reasoning \citep{binding, van2019perspective}.
In this paper, we investigate state-of-the-art OCR learning methods such as IODINE \citep{iodine}, Slot-Attention \citep{sa}, and SLATE \citep{slate}. IODINE represents objects with multiple latent variables through iterative refinement. Slot-Attention uses a similar approach but incorporates an attention mechanism to refine the variables. SLATE improves upon Slot-Attention by using a Transformer-based decoder instead of a pixel-mixture decoder, resulting in better generalization and comparable reconstruction performance. Additionally, we also implement a larger version of Slot-Attention (Slot-Attention-Large) to fairly compare the two methods with similar model sizes.
\textbf{Object-Centric Representations and Reinforcement Learning}.
Reinforcement learning (RL) is a frequently mentioned downstream task where OCR are thought to be beneficial due to their potential for improved generalization, reasoning, and sample efficiency \citep{rdrl,garnelo2016towards,oomdp,schemanet,crafter_cnnfm,lrn,visuomotor}. However, to our knowledge, there have been no studies that systematically and thoroughly demonstrate these benefits.
\citet{rim} evaluated OCR for RL through end-to-end learning, which may lead to task-specific representations that lack the strengths of unsupervised OCR learning such as sample efficiency, generalization, and reasoning.
\citet{smorl} investigated OCR pre-training but applied a bounding box-based method \citep{scalor} and proposed/evaluated a new policy for the limited regime of goal-conditioned RL.
\citet{cobra} evaluate OCR pre-training for a synthetic benchmark but a simple search is used rather than policy learning.
Previous studies have also investigated the use of decomposed representations in RL \citep{rdrl,garnelo2016towards,oomdp,schemanet,crafter_cnnfm,lrn,visuomotor}. Many of these works use CNN feature maps \citep{rdrl, crafter_cnnfm, visuomotor} as the representation or their own encoders \citep{garnelo2016towards}. Other studies have used ground truth states \citep{oomdp, schemanet, lrn}, and these representations have been implemented through separate object detectors and encoders \citep{oomdp, load}. The effectiveness of pre-trained representations for out-of-distribution generalization of RL agents is studied in \citep{vae_ood}, but only the single-vector representation (i.e. VAE) is evaluated. In our work, we use a similar model as a baseline to compare with our pre-trained OCR model.
\section{Experimental Setup}
In this section, we provide an overview of our experimental setup.
We first discuss the OCR pre-training models and baselines we chose to evaluate and explain how the representations are used in a policy for RL.
We then introduce the tasks used in our experiments detailing the motivation behind each task.
\subsection{Models} \label{sec:model}
Each model consists of (1) an \textbf{encoder} that takes as input an image observation and outputs a latent representation and (2) a \textbf{pooling layer} that combines the latent representation into a single vector suitable to be used for the value function and policy network of an RL algorithm. We use PPO \citep{ppo} for all our experiments. Detailed information about the architecture and hyperparameters is in Appendix \ref{appx:model}.
\begin{comment}
\begin{table*}[t]
\centering
\begin{tabular}{@{}lccc@{}}
\toprule
& \multicolumn{2}{c}{Training Regimes} \\ \cmidrule(l){2-3}
Representation Types & End-to-end Learning & Pre-training \\ \midrule
\multirow{3}{14em}{Single-vector Representation} & \multirow{2}{15em}{CNN \citep{dqn}} & VAE \citep{vae_ood} \\
& & MAE-CLS \citep{mvp} \\
& & SLATE-CNN \citep{visuomotor}\\\midrule
\multirow{1}{14em}{Fixed-region Representation} & \multirow{1}{15em}{CNNFeat \citep{rdrl}} & MAE-Patch \\\midrule
\multirow{4}{14em}{Object-Centric Representation} & \multirow{4}{15em}{MultiCNNs \citep{cswm}} & SLATE \citep{slate} \\
& & Slot-Attention \citep{sa} \\
& & Slot-Attention-Large \\
& & IODINE \citep{iodine} \\ \bottomrule
\end{tabular}
\caption{Summary of Evaluated Encoders}
\label{tab:rep_regime_summ}
\end{table*}
\end{comment}
\textbf{Encoders.}
To investigate OCR pre-training, we evaluated three types of representations (single-vector representation, fixed-region representation, and Object-Centric Representation (OCR)) and two training regimes for each type (end-to-end learning and pre-training). Single-vector representations encode the observation to a single vector which is used in the downstream policy.
Fixed-region representations use multiple vectors to represent the image, each corresponding to a region of the observation such as a mini-patch.
For our experiments, we use the CNN feature map \citep{rn,rdrl} for end-to-end learned fixed-region representations and the mini-patch representations from pre-trained Masked AutoEncoder (MAE) \citep{mae} for pre-trained fixed-region representations.
Since the fixed-region representation can support an explicit interaction architecture, such as a Transformer encoder, it can be a stronger baseline than single-vector representations.
For end-to-end trained OCR, we use an encoder consisting of multiple CNN encoders \citep{cswm, vin}.
The pre-trained OCR methods we use in our study are described in Section \ref{sec:related_work}.
The evaluated encoders are summarized in Table \ref{tab:rep_regime_summ}.
\textbf{Pooling Layers.}
In order to use the three types of representations for RL, we implement different pooling layers for each type. For single-vector representations, an MLP (or a CNN-MLP \citep{visuomotor} in the case of SLATE-CNN) is used to obtain a single-vector representation.
For region and object-centric representations, a Transformer encoder \citep{transformer} is used.
For fixed-region representations, we add a positional embedding to identify the location of each region.
This is not needed for object-centric representations because the representations are order-invariant.
The overall architectures are shown in Figure \ref{fig:overall_archi}.
\subsection{Benchmark and Tasks}
To verify our hypotheses, we created a suite of tasks and a dataset for pre-training using objects from Spriteworld \citep{spriteworld} (Figures \ref{fig:task_illustration}b-e).
While this environment is visually simple, we wanted to ensure that the OCR pre-training models could cleanly segment the objects in the scene into separate slots, reducing the possibility that the downstream RL performance is affected by poor OCR quality.
In order to evaluate the performance of OCR pre-training in a more visually complex environment, we also implemented a robotic reaching task using the CausalWorld framework \citep{causalworld} (Figure \ref{fig:task_illustration}f).
Details about the implementation of these benchmarks can be found in Appendix \ref{appx:benchmark}.
\textbf{Dataset: } For pre-training on the 2D tasks, we generate a dataset with a varying number of objects of different shapes randomly placed in the scene.(Figures \ref{fig:task_illustration}a).
Note that this data is diverse enough to cover all four 2D tasks, so we use the same dataset for pre-training on all 2D tasks.
For 3D task from CausalWorld framework, we generate a dataset through a random policy on the task.
\textbf{Object Goal Task: } The agent (red circle), target object (blue square), and other distractor objects are randomly placed in this task.
The goal of the task is for the agent to move to the target object without touching any distractor objects.
Once the agent reaches the target object, a positive reward is given, and the episode ends.
If a distractor object is reached, the episode ends without any reward.
The discrete action space consists of the four cardinal directions to move the agent.
To solve this task, the agent must be able to extract information about the location of the target object and the objects between the agent and the target.
Therefore, through this task, we can verify that the agent can extract per-object information from the representation.
\textbf{Object Interaction Task: } This task is similar to the object goal task but requires the agent to push the target to a specific location.
In Figure \ref{fig:task_illustration}c, the bottom left blue square area is the goal area.
Since the agent cannot push two objects at once, the agent must plan how to move the target to the goal area while avoiding the other objects.
Therefore, through this task, we can verify how well the agent can extract per-object information and how well the agent can reason about how the objects interact.
The action space is the same as above, and the reward is only given when the agent pushes the target to the goal area.
\textbf{Object Comparison Task: } This task is designed to test relational reasoning ability. It is motivated by the odd-one-out task in cognitive science \cite{crutch2009different, stephens2008one, beatty2015prospects}, which has been previously investigated with language-augmented agents \cite{lampinen2022tell}.
To solve this task, the agent must determine which object is different from the other objects and move to it.
That is, it must find an object with no duplicates in the scene.
Unlike the object goal or object interaction tasks, the characteristics of the target object can change from episode to episode.
For example, in Figure \ref{fig:task_illustration}d, the green box is the target object in the top sample, while the blue triangle is the target object in the bottom sample.
Therefore, to know which object is the target, the agent must compare every object with every other object, which requires object-wise reasoning.
The action space and reward structure are the same as the Object Goal Task.
\begin{table*}[t]
\centering
\begin{tabular}{@{}lccc@{}}
\toprule
& \multicolumn{2}{c}{Training Regimes} \\ \cmidrule(l){2-3}
Representation Types & End-to-end Learning & Pre-training \\ \midrule
\multirow{3}{14em}{Single-Vector Representation} & \multirow{2}{15em}{CNN \citep{dqn}} & VAE \citep{vae_ood} \\
& & MAE-CLS \citep{mvp} \\
& & SLATE-CNN \citep{visuomotor}\\\midrule
\multirow{1}{14em}{Fixed-Region Representation} & \multirow{1}{15em}{CNNFeat \citep{rdrl}} & MAE-Patch \\\midrule
\multirow{4}{14em}{Object-Centric Representation} & \multirow{4}{15em}{MultiCNNs \citep{cswm}} & SLATE \citep{slate} \\
& & Slot-Attention \citep{sa} \\
& & Slot-Attention-Large \\
& & IODINE \citep{iodine} \\ \bottomrule
\end{tabular}
\caption{Summary of Evaluated Encoders}
\label{tab:rep_regime_summ}
\end{table*}
\begin{figure*}[t]
\hspace{-8mm}
\begin{center}
\includegraphics[width=0.95\textwidth]{figs/icml_bar_each_model_23-01-26-23-45-12.png}
\caption{Success Rates for Object Goal, Object Interaction, Object Comparison, and Property Comparison Tasks. The specific representation types and training regimes used for each model are outlined in Table \ref{tab:rep_regime_summ}.
}
\label{fig:overall}
\end{center}
\vspace{-2mm}
\end{figure*}
\textbf{Property Comparison Task: }
This task is similar to the Object Comparison Task, but the agent must now find the object with a \textit{property} (i.e., color or shape) that is different from the other objects.
For example, in the top sample of Figure \ref{fig:task_illustration}e, the green triangle is the target because it is the only green in the scene.
The blue triangle is the target in the bottom sample because it is the only triangle object.
Therefore, this task requires property-level comparison, not just object-level comparison.
While OCRs are designed to be disentangled at the object level, it is not apparent how easily specific properties can be extracted and used for reasoning.
Through this task, we can verify how well OCRs can facilitate property-level reasoning.
The action space and reward structure are the same as the Object Comparison Task.
\textbf{Object Reaching Task:} Lastly, in order to evaluate the models in a more visually realistic environment, we also created a version of the Object Goal Task using the CausalWorld framework \citep{causalworld} (Figure \ref{fig:task_illustration}f).
In this environment, a fixed target object and a set of distractor objects are randomly placed in the scene.
The agent controls a tri-finger robot and must reach the target object with one of its fingers (the other two are always fixed) to obtain a positive reward and solve the task.
The episode ends without reward if the finger first touches one of the distractor objects.
The action space in this environment consists of the three continuous joint positions of the moveable finger.
We do not provide proprioceptive information to the agent, so it must learn how to control the finger from images.
\section{Experiments}
We present our experimental results and analysis as a series of questions and answers, each probing a different aspect of OCR pre-training for RL.
For each result below, we average the performance from three random seeds and every agent is trained to 2 million steps.
\begin{figure*}[t]
\hspace{-8mm}
\centering
\includegraphics[width=0.95\linewidth]{figs/icml_plot_overall_globalstep_23-01-26-23-56-36.png}
\vspace{-2mm}
\caption{The comparison of success rate against the number of interaction steps with the environments. Note that SLATE is compared with baselines for the Object Interaction task, where averaged performance of OCR pre-training is hard to be compared because other OCR methods failed to solve.}
\label{fig:overall_globalstep}
\vspace{-3mm}
\end{figure*}
\textbf{Question 1:} \textit{Does OCR pre-training improve performance in object-centric tasks? Which types of tasks benefit the most from OCR pre-training?}
OCR pre-training represents objects through separate slots and is assumed to be beneficial for object-centric reinforcement learning (RL) tasks \citep{iodine}. Previous work has evaluated this for specific object-centric RL tasks such as goal-conditioned skill learning~\citep{smorl}. However, it remains elusive whether this representation improves performance for general object-centric tasks, which types of tasks benefit the most from OCR pre-training, and how it compares to other representations.
In Figure \ref{fig:overall_regime} and \ref{fig:overall}, we show the final Success Rates of the different models described in Table \ref{tab:rep_regime_summ} for the four synthetic tasks in our benchmark.
For the Object Goal task, where the agent must find a pre-defined goal object while avoiding distractor objects, all models achieved success rates of over 80\%, with the exception of the pre-trained single-vector representation models.
This task requires agents to extract information about the target object and the distractor objects, but it does not necessarily require modeling of interactions between objects.
This result suggests that explicit modeling of objects through OCR is not the only option for this type of task---the models with end-to-end trained single-vector representations and fixed-region representations can also be reasonable choices.
The pre-trained single-vector representation, on the other hand, seems to not be able to extract the per-object information necessary to solve the task.
We investigate this more in the response in Appendix \ref{appx:sec:more_fewer_objs}.
In the Object Interaction task, which requires the agent to learn object-level interactions, it is observed that only pre-trained SLATE and end-to-end learned CNN models exhibit performance comparable to that of a model utilizing ground truth state, achieving a Success Rate of approximately 80\%. It is noteworthy that other OCR pre-training models, namely Slot-Attention, Slot-Attention-Large, and IODINE, fail on this task.
This discrepancy in performance may be attributed to the fact that the Object Interaction task is harder than others due to its sparser rewards and that SLATE representations are trained with a transformer decoder, whereas other OCR models utilize mixture-based decoders. One possibility is that the utilization of a transformer decoder in SLATE enhances the compatibility of these representations with transformer-based agent training, as compared to other OCR models.
For the Object Comparison and Property Comparison tasks, OCR pre-training demonstrated its strengths by performing similarly to GT, with all models except IODINE. Although IODINE showed worse performance than the other OCR pre-training and GT models, it still performs better than the other baselines. End-to-end learned OCR also performed better than other baselines but was not able to fully solve the tasks (success rates were around 50\%).
Interestingly, fixed-region representations, namely CNNFeat and MAE-Patch, failed for the comparison tasks while also utilizing a transformer pooling layer. This is because the task requires object-level reasoning while the agents with the fixed-region representations are required to do something more to infer object-level representations.
These results align with the hypothesis discussed in previous works \citep{binding,van2019perspective,building} that decompositional representations are beneficial for reasoning tasks while suggesting that the level of decompositionality of representations is also important.
Another interesting point is that OCRs were not necessarily disentangled at the property level but are effectively utilized to solve property-level comparisons. We hypothesize that the transformer pooling layer plays a critical role in correctly extracting property-level information.
In conclusion, OCR pre-training does not always provide better performance for every object-centric task, but for relational reasoning tasks, it demonstrates better performance when compared to other diversely trained representations.
\textbf{Question 2:} \textit{Does OCR pre-training improve sample efficiency in object-centric tasks?}
Analyzing the sample efficiency of OCR pre-training compared with other methods will give us insights into whether or not the learned representations are appropriate for the downstream tasks.
As shown in Figure \ref{fig:overall_globalstep}, OCR pre-training generally demonstrates improved sample efficiency compared to other pre-training methods.
The exception is for the non-SLATE OCR pre-training methods for the Object Interaction task that failed to solve the task.
This shows that when compared to pre-training with single-vector or fixed-region representations, the pre-trained object-centric representations are more suitable for these tasks.
When compared with the end-to-end trained methods, we see that OCR pre-training also has better sample efficiency for the comparison tasks but worse sample efficiency for the object interaction task.
These results suggest that, as with performance improvement, OCR pre-training may not always improve sample efficiency for every object-centric task, but it does enhance sample efficiency for tasks where the relationship between objects is important.
\begin{figure*}[t]
\hspace{-10mm}
\begin{center}
\includegraphics[width=0.95\linewidth]{figs/icml_plot_ood_23-01-28-22-55-15.png}
\end{center}
\vspace{-2mm}
\caption{Generalization performance for the out-of-distribution settings. The in-distribution setting is denoted by ``(in)''. The \textbf{top row} shows the success rate for unseen numbers of objects, and the \textbf{bottom row} shows the success rate for unseen object colors. SLATE is compared for the Object Interaction task. OCR pre-training and SLATE are highlighted through markers. Note that GT is not evaluated for the unseen number of objects test on the Object Interaction task as the MLP pooling is used for the task and cannot be applied to unseen objects.}
\label{fig:ood}
\vspace{-3mm}
\end{figure*}
\textbf{Question 3:} \textit{Does OCR pre-training help in generalization of agents?} \label{sec:ood_exp}
OCR has been shown to have strong generalization capabilities due to its object-wise modular representations, particularly when dealing with out-of-distribution data such as unseen numbers or combinations of objects \citep{generalization_ocr,sa,iodine,slate}.
Agents that utilize explicit interaction networks, such as Transformers \citep{rdrl} or Linear Relational Networks \citep{lrn}, have also demonstrated good generalization performance in policy learning.
It can be hypothesized that OCR pre-training in conjunction with explicit interaction networks could further improve generalization robustness, but this has not yet been thoroughly investigated. In the following, we will investigate the generalization capabilities of OCR pre-training in the context of two different types of distribution shifts: unseen number of objects and unseen types of objects.
First, we investigated the effect on agent performance when the number of objects differs from that on which the agent was trained.
The results are shown in the top row of Figure \ref{fig:ood}.
For all tasks, OCR pre-training generally maintained good performance, although success rates on Object Interaction tasks were low.
For the Object Interaction task, SLATE shows comparable generalization performance.
However, it is worth noting that other methods, such as GT or CNN, also demonstrated comparable generalization capabilities.
This is not surprising for the Object Goal and Interaction tasks, since the model must extract the target object from the observations.
For comparison tasks, however, increasing the number of objects can create unseen patterns such as the ones in Figure \ref{fig:task_illustration}e, and the agent must compare each object to all other objects to find the odd one.
The transformer pooling layer can handle this pairwise comparison, which is why OCR pre-training and GT perform well when scaling to more objects.
Next, we evaluate the agent's performance when presented with object colors not seen during training. The experimental details, such as which colors were changed, are described in Appendix \ref{appx:ood_unseen_color_detail}. The results are shown in the bottom row of Figure \ref{fig:ood}.
For the Object Goal and Interaction tasks, we change the color of the distractors. The target object remains the same, so we can infer that this distribution shift does not affect performance if the agent can correctly extract the target object. As expected, model performance remains relatively stable regardless of the number of unseen distractors.
For the comparison tasks, however, the agent must compare each object, and unseen colors can negatively impact performance.
As expected, the performance of every model that performs better than random chance significantly decreased. Especially, the GT success rate drops from almost 100\% to 2-30\%. This is likely due to the unseen index (object type is represented as an integer index in the GT state) being critical to infer the correct action. On the other hand, except for the Property Comparison task with one unseen color, OCR pre-training demonstrates more robust performance than GT.
\textbf{Question 4:} \textit{Does OCR pre-training work well in visually complex environments where segmentation is difficult?}
In order to evaluate the effectiveness of OCR pre-training in visually complex environments where segmentation is challenging, we conducted experiments on the Object Reaching task using the SLATE model and several baselines (GT, CNN, and VAE). The results of the segmentation performed by SLATE, as shown in Figure \ref{fig:cw_seg}, demonstrate that it is not perfect and sometimes splits multiple objects between slots and does not accurately capture the robotic finger.
However, as illustrated in Figure \ref{fig:cw}, the agent utilizing SLATE demonstrated superior sample efficiency and converged success rate compared to the other methods. Although this task does not explicitly require reasoning among the objects, it is still crucial for the agent to learn to avoid touching the distractor objects before the target object. This result suggests that the conclusions from the experiments in visually simple environments can potentially be generalized to more complex environments.
\begin{figure}[h]
\begin{center}
\includegraphics[width=0.7\linewidth]{figs/icml_3d_23-01-27-00-06-21.png}
\end{center}
\vspace{-5mm}
\caption{Success rates for the Object Reaching Task.}
\label{fig:cw}
\vspace{-1mm}
\end{figure}
\textbf{Question 5:} \textit{Which OCR model is better for RL?}
From the results presented in Figures \ref{fig:overall} and \ref{appx:fig:each_model_walltime2}, it is clear that the SLATE model performs the best in terms of overall performance on the tasks evaluated in this study. In contrast, the IODINE model demonstrated slower computational times and inferior performance across all tasks. Slot-Attention performed similarly to the SLATE model on Object Goal, Object Comparison, and Property Comparison tasks, but failed to effectively solve the Object Interaction task, even when utilizing a more extensive architecture (Slot-Attention-Large).
\begin{table}[h]
\begin{center}
\begin{tabular}{@{}lcccc@{}}
\toprule
& \multicolumn{4}{c}{Tasks} \\ \cmidrule(l){2-5}
Models & Goal & Int. & Obj. Com. & Pro. Com. \\ \midrule
SLATE &\textbf{0.985}&\textbf{0.787}&\textbf{0.979}&\textbf{0.98} \\
SLATE-MLP&0.9 &0.03 &0.238 &0.229 \\ \bottomrule
\end{tabular}
\caption{Success Rate comparison between Transformer and MLP pooling layers}\label{tab:slate_mlp}
\end{center}
\end{table}
\textbf{Question 6:} \textit{How does the choice of pooling layer affect task performance?}
In this study, the transformer pooling layer is used for the OCR pre-training models due to its permutation invariance and ability to explicitly model interactions between the slots, which are important properties for relational reasoning tasks. To evaluate the effect of the pooling layer on task performance, an ablation study is conducted, where the MLP pooling layer is applied to the SLATE (referred to as SLATE-MLP). The results, as shown in Table \ref{tab:slate_mlp}, indicate that the use of the MLP pooling layer resulted in inferior performance on all tasks, with complete failure to solve the interaction and comparison tasks. Interestingly, the SLATE-MLP is still able to achieve good performance on the Object Goal task. This may be because the task is easier than others, the target object can still be extracted from the MLP, and the interaction between objects is not very important to solve that task.
\section{Conclusion and Discussion}
In this paper, we investigated Object-Centric Representation for RL tasks. To do this, we empirically evaluated the hypotheses shown or suggested from previous works \citep{smorl,binding,van2019perspective,building,rdrl, load,lrn} on our new benchmark with diverse types of representations. We found more specific conditions to satisfy the hypotheses through this empirical investigation. OCR pre-training does not always provide sample efficiency but is efficient for relational reasoning tasks. OCR pre-training is not always better than other methods for out-of-distribution tasks also, but it shows better generalization performance for unseen objects when compared with GT.
In addition, SLATE shows comparable performance to GT for visually complex tasks where OCR cannot segment objects correctly. We also studied ablations for the pooling layer. Other interesting questions were also considered, but due to space limitation, they are discussed in the Appendix \ref{appx:additional_res}.
Although our benchmark covers several important object-centric tasks, such as object interaction and relational reasoning, it can seem very synthetic. We chose those visually simple scenes to ensure the downstream RL performance is not affected by poor segmentation quality. It allows us to probe more specific aspects of the reinforcement learning task to assess where OCR pre-training is most beneficial. In order to investigate the case where segmentation quality is not perfect, we also ran experiments on the robotics Object Reaching Task, which we discuss in \textbf{Question 4}. Investigating OCR in more complex and realistic environments is a promising direction for future work, especially as unsupervised OCR models continue to improve. Furthermore, in addition to scene complexity, there are other aspects of agent learning that can benefit from OCR, such as partially observable environments or tasks that require exploration.
These are good candidates to extend the benchmark in the future.
Lastly, we hope our benchmark can help evaluate OCR models in the context of agent learning, in addition to the previously standard metrics such as segmentation quality and property prediction accuracy. Further discussion is in Appendix \ref{appx:discussion}.
\section*{Acknowledgement}
This work is supported by Brain Pool Plus (BP+) Program (No. 2021H1D3A2A03103645) and Young Researcher Program (No. 2022R1C1C1009443) through the National Research Foundation of Korea (NRF) funded by the Ministry of Science and ICT.
The work is also supported by Electronics and Telecommunications Research Institute (ETRI) grant funded by the Korean government. [23ZR1100, A Study of Hyper-Connected Thinking Internet Technology by autonomous connecting, controlling, and evolving ways] JS thanks to SAP for their support, and Jindong for constructive discussion.
| {'timestamp': '2023-02-10T02:05:31', 'yymm': '2302', 'arxiv_id': '2302.04419', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04419'} | arxiv |
\section{Introduction}
Most real-world graphs associated with people or human-related activities are often sensitive and might contain confidential information. In this paper, we focus on the threat of edge privacy, e.g., in an online social network, a user's friend list could potentially be private to the user. The server could aggregate node representations with their neighbors to learn better user representations to improve its services. Thus, if there is an edge between two nodes, their output representations obtained from the graph neural network (GNN) should be closer. Therefore, a potential adversary could possibly recover the sensitive edge information (e.g., friend lists) via a machine learning classifier that computes distance differences in graph representations.
In this paper, we study three representation methods (two low-order and one higher-order) that perform different aggregations to capture important graph structure properties, i.e., representations output from GCN, GAT, and our proposed SNN. Unlike the first two types of representations that only encode pairwise relationships, the proposed SNN utilize a higher-order combinatorial Laplacian to learn a graph convolution that encodes the homological features of simplicial complexes, which are higher-dimensional analogs of graphs~\citep{horak2013spectra}. We will then measure if SNN outputs are more vulnerable to potential attacks compared to regular GCN or GAT outputs.
We use GRAs as the potential attacks to measure privacy leakage. GRAs study whether representations can be inverted to recover the graph used to generate them. We propose a novel GRA for accurate representation inversion, i.e., from the representation outputs of a graph $\mathcal{G}$, we can find a graph $\hat{\mathcal{G}}$ with a very similar adjacency matrix. When a user’s device computes a representation via GNN and sends it to a server for node classification, we assume the adversary could access the representation outputs with non-confidential edges during the data uploading process. We propose a graph decoder that reconstructs the graph by minimizing the reconstruction loss between the partial graph (with non-confidential edges) and the reconstructed graph. In our experiments, we will show that the SNN outputs reveal the lowest privacy-preserving ability to defend the GRAs. This calls for future research towards building more private representations with higher-order node information that could defend the potential attacks, such as GRAs.
\section{Our Proposed Methods}
\begin{table*}[!ht]
\centering
\begin{tabular}{l| c c c c c }
\hline
\backslashbox[40mm]{Attacks}{Dataset}& Citeseer& Cora& Pubmed & Computers & Photos \\ [0.5ex]
\hline
Attack-6~\citep{he2021stealing} & $0.9795$ & $0.9638$ & $0.9702$ & $0.9800$ & $0.9691$\\
GRA\_GCN outputs (Ours)& $0.8832^\downarrow$ & $0.8900^\downarrow$ & $0.8937^\downarrow$& $0.9041^\downarrow$ & $0.9157^\downarrow$\\
GRA\_GAT outputs (Ours)& $0.9224^\downarrow$ & $0.9640$ & $0.9704$ & $0.9800^{=}$ & $0.9703$\\
\textbf{GRA\_SNN outputs (Ours)} & $\mathbf{0.9833}$ & $\mathbf{0.9713}$ & $\mathbf{0.9826}$ & $\mathbf{0.9802}$ & $\mathbf{0.9832}$\\
\hline
\end{tabular}
\caption{AUC Score on Three Types of Representations.}
\label{table:recall}
\end{table*}
\paragraph{SNN Outputs}
In this paper, we will refer abstract simplicial complex to simplicial complexes. An abstract simplicial complex is a collection $K$ of subsets of a finite set $S$ that satisfies two axioms: (1) The singleton set $\{v\}$ lies in $K$ for each $v$ in $S$. (2) Whenever some $\sigma \subset S$ lies in $K$, every subset of $\sigma$ must also lie in $K$. The constituent subsets $\sigma \subset S$ which lie in $K$ are called simplices. Next, we will introduce the computation of $d$-dimensional incidence matrices. Fixing a collection $K$ and letting $K_d$ indicate the set of all $d$-simplices in $K$, the $d$-dimensional incidence matrices operators can be represented as $ \partial_d: \mathbb{R}^{K_d} \rightarrow \mathbb{R}^{K_{d-1}}$. To build these incidence matrices operators, one first orders the nodes in $K_0$ so that each $d$-simplex $\sigma \in K$ can be uniquely expressed as a list $\sigma = [v_0,..., v_d]$ of nodes in increasing order. The desired matrix $\partial_d$ is completely prescribed by the following action on each $\sigma$:
$\partial_d (\sigma) = \sum_{i=0}^d (-1)^i \cdot \sigma_{-i},$
where $\sigma_{-i} := [v_0,...,\hat{v}_i,..., v_d]$ and $\hat{v}_i$ indicates that $v_i$ is omitted. These operators form a sequence of vector spaces and linear maps:
\begin{equation}
\cdots \overset{\partial_{d+1}}{\rightarrow} \mathbb{R}^{K_d} \overset{\partial_{d}}{\rightarrow} \mathbb{R}^{K_{d-1}} \overset{\partial_{d-1}}{\rightarrow}\cdots.
\end{equation}
In order to model the higher-order interactions between nodes, the graph Laplacian was generalized to simplicial complexes by~\citet{horak2013spectra}. The higher-order combinatorial Laplacian can be formulated as:
$
\mathcal{L}_d := \partial_{d+1} \partial_{d+1}^T + \partial_{d}^T \partial_{d}.$ Therefore, leveraging this $\mathcal{L}_d,$ we could obtain the final SNN outputs via the graph convolution as follows:
$
H^{(2)} = \sigma(\tilde{Q}^{-\frac{1}{2}}\tilde{\mathcal{L}}_d\tilde{Q}^{-\frac{1}{2}} \sigma(\tilde{Q}^{-\frac{1}{2}}\tilde{\mathcal{L}}_d\tilde{Q}^{-\frac{1}{2}}H^{(0)}W^{(0)})W^{(1)}),\notag
$
where $\tilde{\mathcal{L}}_d = \mathcal{L}_d+\mathbb{I}$, $\mathbb{I}$ is the identity matrix, $\tilde{Q}_{ii} = \sum_j\tilde{\mathcal{I}}_{d_{ij}}$ and $W^{(k)}$ is a layer-specific trainable weight matrix. $\sigma(\cdot)$ denotes an activation function. $H^{(k)}$ is the matrix of activations in the $k$-th layer and the initial node representations are $H^{(0)}$.
\paragraph{Graph Reconstruction Attack}
A graph $\mathcal{G} = (V, E)$ is represented by the set of nodes $V = \{v_i\}_{i = 1}^{|V|}$ and edges $E = \{e_{ij}\}_{i,j = 1}^{|E|}$. To measure the privacy leakage via GRA, we will then propose a decoder only approach. Specifically, we utilize the outputs $H^{(k)}$ and a partial adjacency matrix $\mathcal{A}^{*}$ as the prior knowledge, the decoder $f_{dec}$ reconstructs the adjacency matrix $A_{rec} = f_{dec}(H^{(k)})$ via
$
A_{rec} = \sigma((\tilde{\mathcal{A}}^{*} H^{(k)} W_a) (\tilde{\mathcal{A}}^{*} H^{(k)} W_a)^\mathbf{T}),
$
where $W_a$ is trained using back-propagation to minimize reconstruction loss between the adjacency matrix of thee partial graph $\mathcal{A}^{*}$ and the reconstructed partial graph $\mathcal{A}_{rec}^{*}$ using
$
\mathcal{L}^{(att)} = ||\mathcal{A}^{*}-\mathcal{A}_{rec}^{*}||^2_2.$
\section{Experiments}
\paragraph{Datasets}
In our experiments, we used five well-known real-world datasets: CiteSeer and CORA from~\citet{sen2008collective}, PubMed~\citep{namata2012query}, as well as Amazon Computers and Amazon Photo from~\citet{shchur2018pitfalls}.
\paragraph{Experimental Set-Up}
In order to generate GCN and GAT outputs, we follow the original graph convolution in GCNs~\citep{welling2016semi} and concatenation in GATs~\citep{velivckovic2017graph}. We only consider $1$-simplices, i.e., $d=1.$
\paragraph{Performance for Three Types of Representations}
Table~\ref{table:recall} shows the GRA performance in terms of AUC of three types of representations for recovering the adjacency matrix $\mathcal{A}$ of $\mathcal{G}$. We compare our results with Attack-6~\citep{he2021stealing} because it also requires node representations and the partial adjacency matrix $\mathcal{A}^{*}$ as prior knowledge. Our proposed GRA with GCN outputs (GRA\_GCN outputs) obtains inferior performances compared to Attack-6 (with $\downarrow$). However, GRA\_GAT outputs achieve higher performances compared to Attack-6 in most of the cases and GRA\_SNN outputs achieve the highest performances for all datasets (in bold), e.g., it achieves $98.33\%$ AUC on the Citeseer dataset. This indicates the SNN outputs reveal the lowest privacy-preserving ability to
defend the GRAs, followed by GAT and GCN outputs.
\section{Conclusion}
In this paper, we measure the privacy leakage via studying whether representations can be inverted to recover the graph used to generate
them using GRA. Our proposed GRA recovers a graph’s adjacency matrix from the representations via a graph decoder that minimizes the reconstruction loss. We studied three types of representations that are trained on the graph, i.e., GCN outputs, GAT outputs, and SNN outputs using a higher-order combinatorial Laplacian. We found SNN outputs reveal the lowest privacy preserving ability. This indicates
the importance of building more private representations with higher-order node information that could defend the potential threats.
| {'timestamp': '2023-02-10T02:03:33', 'yymm': '2302', 'arxiv_id': '2302.04373', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04373'} | arxiv |
\section{Introduction}
In this paper, we are interested in deciding properties of graphs defined in monadic second-order logic.
A series of results by Courcelle deals with this question; in particular \cite{courcelle} proves that every MSO property is decidable in linear time, given a graph with bounded treewidth (encoded by its transition matrix).
Now what if the graph is not typical, but presents some structure that allows a shorter encoding?
Assume that the graph is described succintly, i.e, by a Boolean circuit which computes the adjacency relation between nodes, which are represented by binary numbers.
One natural question is whether it is possible to exploit the circuits in better ways than just querying for possible edges, in order to more directly deduce structural information about the transition graph.
Our main result essentially tells that it is impossible as soon as the property is non-trivial for bounded treewidth graphs.
\begin{theorem}\label{t:succinct}
If $\phi$ is an arborescent MSO sentence,
then testing $\phi$ on graphs represented succinctly is either {\ensuremath{\mathsf{NP}}}- or {\ensuremath{\mathsf{coNP}}}-hard.
\end{theorem}
\emph{Arborescent} means that $\phi$ has infinitely many models with some fixed treewidth,
and infinitely many countermodels with some fixed treewidth.
Formal definitions appear in Section~\ref{sec:pre}, including a definition of \emph{treewidth}.
Many of the properties considered in the literature so far.
Our motivation comes from the world of automata networks.
An \emph{automata network} (AN) can be seen as a computer network where all machines hold a local state and update synchronously by reading neighboring states and applying a local transition.
One of the initial intents behind this definition was to model the dynamics of gene regulation~\cite{k69,t73,tt95,ma98,epa04,ks08}.
Nowadays, automata networks are also used as a setup for distributed algorithms and as a modelling tool in engineering.
Those applications have motivated the study of automata network \emph{per se}
and many theoretical properties were found~\cite{e59,g67,c71,r86,gm90,a08,r11,dns12}.
Let us give a slightly more formal description of automata networks.
An AN is given by a finite digraph, called \emph{communication graph}, where each node is endowed with a local update function.
The graph is directed, so one-way transfer of information is possible.
Different automata may have different transition tables and state sets.
To update a node $v$ of the network, first collect the states of its inbound neighbors into a tuple,
and then feed that tuple as an input symbol to the update function of $v$.
Globally speaking, all nodes are updated synchronously (though an extensive literature has explored other \emph{update modes}~\cite{ds20}),
so that the state of $v$ at time $t+1$ only depends on the states of its neighbors at time $t$.
This description suggests an alternative way to think about automata networks:
they can be seen as a generalization of finite cellular automata.
The generalization resides in that the ``grid'' of an AN can be an arbitrary (finite) digraph,
rather than just a regular grid.
Besides, each cell gets its own update function, so no uniformity is enforced.
That analogy between automata networks and cellular automata is relevant,
as we often meet the same sort of research problems in both cases:
information needs to flow in the network to enable nodes to perform useful tasks,
so we need to understand what can or cannot be transmitted efficiently, and where.
In general, the automata in a network may be nondeterministic, so that the network as a whole may be nondeterministic.
Hence we need to consider network updates as a relation,
rather than a function.
We now formalize this idea.
Let $F$ denote an automata network.
A \emph{configuration} of $F$ is a possible state of the whole system, i.e., an assignment of a state to each node.
If configuration $x_1$ evolves in one round into configuration $x_2$, then we say that $x_1$ \emph{transitions} to $x_2$.
We sometimes say that $x_1$ is a \emph{predecessor} of $x_2$, or that $x_2$ is a \emph{successor} of $x_1$.
In general, automata networks are nondeterministic, so that a given configuration might have several successors.
The concepts of \emph{predecessor} and \emph{sucessor} allow to state virtually all interesting questions about $F$.
For instance:
\begin{itemize}
\item Is $F$ deterministic, i.e., do all configurations have exactly one successor?
If not, how many configurations have more than one successor?
How many have none?
What is the maximal number of successors for a configuration?
\item Is $F$ injective, i.e., do all configurations have exactly one predecessor?
How many have more than one? Or none?
What is the maximal number of predecessors?
\item Does $F$ have a fixed point, i.e., a configuration that is its own successor?
How many are there?
\item Does $F$ have a cycle of configurations?
(A sequence of configurations $x_0,\dots,x_{k-1}$ such that $x_i$ transitions to $x_{i+1}$, with indices taken modulo $k$.)
How many of them does it have? What are their lengths?
\end{itemize}
The \emph{transition graph} of $F$, denoted by $\TG{F}$, is the digraph of the \emph{transition} relation.
In other terms, its vertices are the configurations of $F$ and there is an edge from configuration $x_1$ to configuration $x_2$ if $x_1$ transitions to $x_2$.
The transition graph is exponentially bigger than the communication graph.
That graph describes the dynamical behavior of $F$: all the questions above (and many more) are actually questions about $\TG{F}$ rather than $F$.
We are interested in testing properties of $\TG{F}$, given $F$ as input.
When given as input to an algorithm, $F$ is encoded through a Boolean circuit that, given two integer sequences $z_1,\dots,z_n$ and $z'_1,\dots,z'_n$ in binary, returns whether or not the first configuration can transition into the second one.
This corresponds to a succinct representation for $\TG F$.
While seemingly artificial, this encoding is relevant for applications.
When automata networks are used to model actual computer networks, it is reasonable to assume access only to the source code of the programs run by the nodes.
Boolean circuits represent this source code.
Similarly in biology, experimental observations show how each pair of nodes (in this case, genes) influence each other;
for a given node, the influences should be summed or otherwise accumulated.
This data does not give a complete transition table for each node, but can easily be encoded as Boolean circuits.
If a transition table happens to be available, it can be re-encoded as a circuit quickly and efficiently without sacrificing much space.
In a sense, designing algorithms (respectively, hardness results) for automata network is like designing algorithms (respectively, hardness results) for succinct graphs.
In particular, every graph is the transition graph of an automata network, i.e.,
for every graph $G=(V,E)$ there is an automata network $F$ such that $\TG{F}=G$
(we can choose $F$ with just one nondeterministic automaton having $|V|$ states).
The results from~\cite{ggpt21} already hint that the encoding cannot be smartly used to efficiently solved some questions.
For instance,
\begin{theorem}[see~\cite{ggpt21}]
\label{thm:fo}
Let $\phi$ denote a question about graphs expressible in first-order logic.
It is either $O(1)$, or {\ensuremath{\mathsf{NP}}}-hard, or {\ensuremath{\mathsf{coNP}}}-hard, given a deterministic automata network $F$ as input, whether $\TG{F}$ satisfies $\phi$.
\end{theorem}
In particular, first-order logic cannot express any non-trivial polynomial-time solvable question about the dynamics of automata networks, unless ${\ensuremath{\mathsf{P}}}={\ensuremath{\mathsf{NP}}}$.
This is a strong indication that it is indeed not tractable to analyze the Boolean circuits given to us in order to extract structural information about the dynamics: the best we can do is to evaluate the circuits to explore the transition graph.
The intuition behind this hardness result is that automata networks are morally a model of computation,
so they are subjected to some analogue of Rice's theorem:
\begin{theorem}[see~\cite{r53}]
\label{thm:rice}
Any nontrivial property of the function computed by a Turing machine is undecidable.
\end{theorem}
The ``function computed by a Turing machine'' in Theorem~\ref{thm:rice} compares to ``property of $\TG{F}$'' in Theorem~\ref{thm:fo},
while ``undecidable'' compares to ``${\ensuremath{\mathsf{NP}}}$-hard or ${\ensuremath{\mathsf{coNP}}}$-hard'' and ``trivial'' compares to ``$O(1)$''.
There is no hope to obtain undecidability results on automata networks because $\TG{F}$ is a finite object:
we can always enumerate all configurations of $F$ and reconstruct $\TG{F}$, then test whatever we want on it.
That would take exponential space, though, so it makes sense to try and find more direct algorithms or hardness results for questions about $\TG{F}$.
What we show is that such algorithms, under standard complexity assumptions (${\ensuremath{\mathsf{P}}}\neq{\ensuremath{\mathsf{NP}}}$), cannot run in polynomial time.
There are other ``Rice theorems'' for models of computation, e.g., cellular automata: see~\cite{k94}.
\paragraph{Contributions.}
The present work started as an attempt to generalize Theorem~\ref{thm:fo} in two directions:
from first-order logic (FO) to monadic second-order logic (MSO),
and from deterministic automata networks to nondeterministic networks.
Neither generalization is trivial.
\emph{Questions about general ANs are harder than questions about deterministic ANs.}
For instance, the question ``is $F$ deterministic?'' is expressible in FO.
If we restrict ourselves to deterministic ANs, that question is $O(1)$; in general, it is not.
Thence the generalization requires to prove, in particular, that determinism is either {\ensuremath{\mathsf{NP}}}- or {\ensuremath{\mathsf{coNP}}}-hard.
\emph{Questions in MSO are stronger than questions in FO.}
For instance, MSO can express ``$\TG{F}$ is connected'', while FO cannot.
Thence we need to prove, in particular, that connectedness of the transition graph is either {\ensuremath{\mathsf{NP}}}- or {\ensuremath{\mathsf{coNP}}}-hard.
Hardness of connectedness and determinism will both be consequences of our main result, Theorem~\ref{thm:mso}.
In addition to being technically harder, both generalizations are useful.
Indeed, when restricting ourselves to deterministic networks, we restrict ourselves to transition graphs of out-degree one.
This is not very exciting from the perspective of graph theory.
The generalization to nondeterministic networks lifts that restriction,
which enables future work to explore deeper connections between automata networks, Boolean circuits, and graph combinatorics.
Moreover MSO logic allows to express the relation ``there is a chain of transitions from configuration $x$ to configuration $y$'',
which FO cannot.
That relation naturally arises in many practical questions.
Things turned out more complicated than expected, and we do not get a general result.
\begin{theorem}
\label{thm:mso}
If $\phi$ is an \emph{arborescent} MSO sentence,
then testing $\phi$ on the transition graph of automata networks is either {\ensuremath{\mathsf{NP}}}- or {\ensuremath{\mathsf{coNP}}}-hard.
\end{theorem}
This theorem rephrases Theorem~\ref{t:succinct}.
Many of the properties considered in the literature so far, and in particular questions mentioned earlier in this introduction, are arborescent (up to turning counting questions into decision questions in the usual way,
so ``how many fixpoints are there?'' becomes ``are there more than $k$ fixpoints?'' for a fixed $k$).
The \emph{arborescent} condition is crucial in our proofs, since it gives the existence of regular families of models and countermodels on which to build a polynomial reduction.
It is natural to ask whether it is necessary.
In Section~\ref{sec:bad}, we give the following partial answer:
\begin{theorem}
\label{thm:noarb}
There is a (nonarborescent) first-order sentence $\psi$ such that,
under plausible complexity assumptions,
testing $\psi$ in the transition graph of a given AN is neither
constant time, nor {\ensuremath{\mathsf{NP}}}-hard, nor {\ensuremath{\mathsf{coNP}}}-hard.
\end{theorem}
\paragraph{Contents.}
\begin{itemize}
\item In Section~\ref{sec:pre}, we give the definitions and notations.
\item In Section~\ref{sec:stmt}, we restate the main result and give a proof outline.
\item In Sections~\ref{sec:saturating}--\ref{sec:sat}, we prove the main result;
their respective roles are explained in the proof outline in Section~\ref{sec:stmt}.
Readers willing to skip the technical details can safely skip these sections.
\item In Section~\ref{sec:bad}, we discuss nonarborescent sentences.
\item We conclude with a discussion and a few suggestions for further research.
\end{itemize}
\section{Definitions}
\label{sec:pre}
\paragraph{Automata networks.}
An \emph{automata network} is a finite digraph $F=(V,E)$ where each node $v$ is equipped with a finite \emph{state set} $Q_v$ and
a \emph{local function} (also called \emph{transition function}):
\begin{equation*}
f_v: \left(\prod_{(u,v)\in E} Q_u\right) \to Q_v.
\end{equation*}
A \emph{configuration} is an assignment of a state to each node; formally, it is an element of $\prod_{u\in V} Q_u$.
If $x$ is a configuration and $v$ a node of $F$, we write $x_v$ for the state of $v$ in $x$; formally, it is the projection~$\pi_v(x)$.
The \emph{updated configuration} $F(x)$ is the configuration given by:
\begin{equation*}
F(x)_v=f_v\left(\prod_{(u,v)\in E} x_u\right),
\end{equation*}
for every $v$ in $V$.
As the notation $F(x)$ suggests,
we often view an automata network as a \emph{global function}:
\begin{equation*}
F:\prod_{u\in V} Q_u \to \prod_{u\in V} Q_u
\end{equation*}
from the set of configurations to itself.
We will consider \emph{nondeterministic} automata networks throughout this paper, unless specified otherwise.
The global function $F$ becomes a \emph{global relation}
$F\subseteq\prod_{u\in V} Q_u \times \prod_{u\in V} Q_u$ (or equivalently a ``multi-valued functions''), which tells whether a configuration can transition to another one.
The terminology and notation of the deterministic case carry over to nondeterministic networks.
This global nondeterminism can come from the Cartesian product of local nondeterministic $f_v\subseteq\prod_{u\in V}Q_u\times Q_v$ (a natural definition for nondeterministic automata networks), but it is generally not enough.
For instance, a particle moving nondeterministically on a graph cannot be modeled be a Cartesian product of local nondeterministic choices made at each node, correlation between choices of neighboring nodes is required.
To emphasize the locality of transitions in the general case, a nondeterministic automata network can be defined by $F=\{(x,y) : \forall U\in\mathcal U,(x_U,y_U)\in f_U\}$, where $\mathcal U$ is a set of subsets of $V$, and for each of its elements $U\in\mathcal U$, $f_U\subseteq\prod_{u\in U}Q_u\times\prod_{u\in U}Q_u$ is a relation ``located'' over $U$.
\begin{remark}
The automata networks constructed in our proof cannot generally be obtained through the Cartesian product of local determinism, but they are non-deterministic in a very weak sense: each configuration has only a bounded number of images (the transition graph has bounded degree).
The bound depends only on
the formula.
This makes the result stronger that it is actually stated.
\end{remark}
Another point of view is that of \emph{succinct graph representations},
where the communication graph and the locality of map $F$ is discarded while describing the graph $\TG{F}$.
A graph $G$ is said to be \emph{succinctly represented} as a pair $(N,C)$,
where $C$ is a Boolean circuit on $2n$ inputs and one output and $N$ is an integer (encoded in binary) with ${N\leq 2^n}$,
whenever there is a one-to-one labeling of the vertices of $G$ onto ${\{0,\cdots,N-1\}}$ such that ${C(x,y)=1}$ if and only if there is an edge from the vertex labeled $x$ to the vertex labeled $y$.
It is easy to transform an automata network $F$ encoded as above into a succinct graph representation of ${\TG{F}}$.
Conversely, one can see a succinct representation ${(N,C)}$ of a graph $G$ as a (degenerate) automata network with just one node and $N$ states whose transition graph is $G$.
We always assume that a Boolean circuit is not bigger than its transition table:
if it were, we could
encode the table into a circuit of the same size (up to a polynomial factor).
\paragraph{MSO Logic.}
Given an automata network $F$, we want to test Monadic Second-Order logic formulae inside its transition graph $\TG{F}$.
MSO formulae have two kinds of variables: vertices ($x_1, x_2, \dots$) and sets of vertices ($X_1, X_2, \dots$)---in our case, vertices are configurations.
Accordingly, there are two kinds of existential quantifiers: existence of a configuration, and existence of a set of configurations.
The Boolean connectives $\neg$ and $\wedge$ are as usual.
The universal quantifiers, bounded quantifiers and other Boolean connectives are derived from them.
The atoms are: equality ($x_1=x_2$),
membership ($x_1\in X_1$),
and transition ($F(x_1, x_2)$, meaning $F(x_1)=x_2$ or more correctly $x_2\in F(x_1)$).
Note that the transition symbol $F$ is a relational symbol in our signature, \textbf{not} a functional symbol.
A \emph{sentence} is a closed monadic second-order formula, i.e., one where all variables are bound to a quantifier.
Here are some examples:
\begin{itemize}
\item \emph{(Existence of a fixed point)} $\exists x: F(x,x)$.
\item \emph{(Unicity of fixed point)} $\forall x, \forall x': F(x,x) \wedge F(x',x') \implies x=x'$.
\item \emph{(Injectivity)} $\forall y, \forall x, \forall x': F(x,y) \wedge F(x',y)\implies x=x'$.
\item \emph{(Determinism)} $\forall x, \forall y, \forall y': F(x,y) \wedge F(x,y')\implies y=y$.
\item \emph{(Nontrivial cycle)} $\exists X,[\exists x\in X]\wedge[\forall x\in X,\exists y\in X:x\neq y\wedge F(x,y)]$.
\end{itemize}
With this MSO signature, it is possible to express as a macro the relation $F^*(x,y)$: ``there exists a chain $x=z_1,z_2,\dots,z_{n-1},z_n=y$ such that $F(z_{k},z_{k+1})$ holds for every $1\leq k\leq n-1$.''
On the other hand, it is not possible to express something like: ``all configurations have the same out-degree.''
See~\cite{l04} or~\cite{df13} for more information about MSO logic in graphs.
\paragraph{Tree decompositions.}
A \emph{tree decomposition} of a graph $G=(V,E)$ is a tree $T$ whose nodes are labeled with subsets of $V$%
---called \emph{bags}---
satisfying the three conditions below.
If $p$ is a node of $T$, we write $B(p)$ for its label, i.e., the corresponding bag.
\begin{enumerate}[label=(\roman*)]
\item Every node of $G$ belongs to at least one bag.
\item For every edge $(v_1,v_2)$ of $G$, there is at least one bag in $T$ containing both $v_1$ and $v_2$.
\item For all nodes $p,q,r$ of $T$, if $q$ is on the (unique) path from $p$ to $r$,
then $B(p)\cap B(r) \subseteq B(q)$.
\end{enumerate}
That definition is usually stated for undirected graphs, but it works without change for directed graphs.
In other terms, we look at tree decompositions of the symmetric closures of the considered graphs.
A graph has, in general, many different tree decompositions.
The \emph{width} of a decomposition is the size of its largest bag minus one.
The \emph{treewidth} of a graph is the minimal width among all of its tree decompositions.
For every integer $k$, a \emph{$k$-tree decomposition} means a tree decomposition of width $k$.
In this paper, any tree (including tree decompositions) is regarded as rooted and oriented downwards: edges point away from root.
\paragraph{Additional conventions.}
If $G$ is a graph, let $|G|$ denote the number of its nodes, dubbed its \emph{size}.
If $S$ is an instance of SAT, let $|S|$ denote the number of its variables, also dubbed its \emph{size}.
If $\phi$ is an MSO sentence, its \textbf{quantifier rank} is its number of quantifiers
(not the number of alternances).
Unless stated otherwise: \textbf{increasing} means strictly increasing;
\textbf{integer} means positive or null integer;
\textbf{polynomial} means nonconstant polynomial with integer coefficients.
\section{Statement of the main result and proof outline}
\label{sec:stmt}
\paragraph{The problem.}
Given an MSO sentence $\phi$, define the problem $\phi$\textsc{-Dynamics} as follows:
\begin{enumerate}[label=]
\item $\phi$\textsc{-Dynamics}
\item \emph{Input:} an automata network $F$ (given as Boolean circuits for the local relation of each node).
\item \emph{Output:} does $\TG{F}\models\phi$?
\end{enumerate}
Observe that $\phi$ is \emph{not} part of the input: it is considered constant.
In other words, we have a family of problems parameterized by MSO sentences.
Analogously, we can define the model checking problem of $\phi$ on graphs given by a succinct representation.
\begin{enumerate}[label=]
\item \textsc{Succinct-}$\phi$
\item \emph{Input:} a succinct representation ${(C,N)}$ of some graph $G$.
\item \emph{Output:} does $G\models\phi$?
\end{enumerate}
Following the remarks on automata networks encoding and succinct representations, it is straightforward to show that for any MSO formula $\phi$ the problems $\phi$\textsc{-Dynamics} and \textsc{Succinct-}$\phi$ are \textsf{LOGSPACE}-equivalent.
Our main result is the following.
\begin{theorem}
\label{thm:main}
If $\phi$ has infinitely many models with the same treewidth $k_1$ and infinitely many countermodels with the same treewidth $k_2$,
then $\phi$\textsc{-Dynamics} is either {\ensuremath{\mathsf{NP}}}-hard or {\ensuremath{\mathsf{coNP}}}-hard.
The result still holds if we restrict inputs of $\phi$\textsc{-Dynamics} to automata networks with bounded non-determinism (transition graph with outdegree at most $k$, for large enough $k$ depending on $\phi$).
\end{theorem}
It can also be phrased as a counterpoint to Courcelle's theorem, as follows:
\begin{corollary}
If $\phi$ is an MSO property with infinitely many models and countermodels among graphs of bounded treewidth, then the problem \textsc{Succinct-}$\phi$ is either {\ensuremath{\mathsf{NP}}}-hard or {\ensuremath{\mathsf{coNP}}}-hard.
The result still holds if we restrict to graphs of bounded degree.
\end{corollary}
An MSO sentence is \emph{arborescent} if it satisfies the condition of Theorem~\ref{thm:main}.
All examples of sentences given in the previous section are arborescent.
We will deal with non-arborescent sentences in Section~\ref{sec:bad}.
\paragraph{Proof outline.}
First, we show that there exists a ``good'' graph, call it $\Omega$,
such that $\Omega\sqcup G$ is always a model of $\phi$ (where $\sqcup$ denotes disjoint union),
no matter what $G$ is.
Then, we show that there exists a ``bad'' graph, say $Y$,
such that $Y\sqcup\dots\sqcup Y$ is always a countermodel of $\phi$, no matter how many disjoint copies of $Y$ we put.
We can arrange things so that $\Omega$ and $Y$ have the same number of vertices.
Now we perform a reduction: we are given an instance $S$ of SAT with $s$ Boolean variables,
and we produce an automata network $F$ such that $\TG{F}\models\phi$ if and only if $S$ has at least one positive assignment.
The network $F$ has $s$ automata with two states ($0$ and $1$) and one ``big'' automaton with $|\Omega|=|Y|$ states.
What $F$ does is interpret the states of the $s$ Boolean automata as an assignment for the variables of $S$, and evaluate $S$ on that assignemnt.
If it finds ``true'', then the big automaton transitions so as to realize a copy of $\Omega$ in $\TG{F}$.
If it finds ``false'', then the big automaton realizes a copy of $Y$ instead.
(The Boolean automata never change their states.)
Consequently, $\TG{F}$ contains as many copies of $\Omega$ as positive assignments for $S$,
and as many copies of $Y$ as negative assignments for $S$.
This completes the reduction: if there is at least one positive assignment, the defining property of $\Omega$ guarantees that the dynamics satisfies $\phi$.
Otherwise, the dynamics is only a pack of disjoint copies of $Y$, which does not satisfy $\phi$.
This whole construction can be performed in polynomial time because $\Omega$ and $Y$ do not depend on $S$:
they only depend on $\phi$, hence they are constants.
(Recall that $\phi$ is \emph{not} part of the input of the problem.)
The only part of $F$ that depends on $\phi$ is the evaluation of $S$, but automata network are encoded as Boolean circuits.
It is easy, given an instance of SAT, to produce in polynomial time circuits that evaluate a given assignment.
\smallskip
Of course, things are not that simple.
First problem: we will not be able to control whether $\Omega$ (called a \emph{saturating graph}) turns any graph into a model or into a countermodel.
If it so happens that $\Omega$ turns any graph into a countermodel,
then we will have to symmetrize all the remainder of the proof (in particular, $Y\sqcup\dots\sqcup Y$ will have to be a model),
and in that case we will get {\ensuremath{\mathsf{coNP}}}-hardness instead of {\ensuremath{\mathsf{NP}}}-hardness.
On the other hand, it turns out that $\Omega$ does not depend on $\phi$, but only on the quantifier rank of $\phi$,
which is pretty amusing.
The details are explained in Section~\ref{sec:saturating}.
Second problem: we have to relax the requirements on $Y$.
What we will actually get is a triple of graphs $(X,Y,Z)$ such that $X\oplus Y\oplus \dots\oplus Y\oplus Z$ is a countermodel of $\phi$ (or, if needed, a model of $\phi$), no matter how many copies of $Y$ are in there.
The gluing operator $\oplus$ is more general than disjoint union; $G\oplus G'$ basically means:
``take the disjoint union of $G$ and $G'$, but also merge some designated vertices of $G$ with designated vertices of $G'$''.
The details are explained in Section~\ref{sec:pump}
(for notational convenience, $X,Y,Z$ are called $G_1,G_2,G_3$ in that section---the subscripts come in handy).
Third problem: because of the concessions just made on $Y$,
the reduction from SAT described above does not work anymore.
Indeed we have to make some space for $X$ and $Z$ in the dynamics of $F$,
and we have to account for the merged vertices (per definition of $\oplus$).
This requires care, because we cannot allow any extraneous configuration in the dynamics:
every single configuration has to belong to the (unique) copy of $X$, the (unique) copy of $Z$,
some copy of $Y$, or some copy of $\Omega$.
The details are explained in Section~\ref{sec:sat}, which also includes the final proof of Theorem~\ref{thm:main}.
Sections~\ref{sec:saturating}, \ref{sec:pump} and~\ref{sec:sat} each start with a proposition, and the remainder of the section is the proof of the proposition.
These three propositions together quickly yield a proof for Theorem~\ref{thm:main}.
\section{A graph saturating all sentences of fixed quantifier rank}
\label{sec:saturating}
\begin{proposition}
\label{pro:saturating}
Fix $m\in\mathbb{N}$.
There exists a graph $\Omega_m$ such that,
for every MSO sentence $\phi$ of rank $m$, either:
\begin{enumerate}[label=(\roman*)]
\item for every graph $G$, we have $G\sqcup\Omega_m\models\phi$; or
\item for every graph $G$, we have $G\sqcup\Omega_m\not\models\phi$.
\end{enumerate}
\end{proposition}
In the first case, we say that $\Omega_m$ is a \emph{sufficient subgraph} for $\phi$;
in the second case, $\Omega_m$ is a \emph{forbidden subgraph} for $\phi$.
A graph that is either sufficient or forbidden for a given sentence is called \emph{saturating} for that sentence.
The rest of this section is a proof of Proposition~\ref{pro:saturating}.
If $G$ and $G'$ are graphs, write $G\equiv_m G'$ if and only if $G$ and $G'$ satisfy exactly the same MSO sentences of quantifier rank $m$.
Write $G\sqcup G'$ for the disjoint union of a copy of $G$ and a copy of $G'$.
If $k$ is an integer, write $\bigsqcup^k G$ the disjoint union of $k$ copies of $G$.
\begin{lemma}
\label{lem:qexists}
For every nonempty graph $G$,
there exists an integer $q(G,m)$ such that $\bigsqcup^{q(G,m)} G\equiv_m \bigsqcup^{q(G,m)+1} G$.
\end{lemma}
\begin{proof}
We show that there exists an integer $q(G,m_1,m_2)$ such that,
in the MSO-Ehrenfeucht-Fraïssé game over the graphs
\begin{equation*}
\gamma=\bigsqcup\nolimits^{q(G,m_1,m_2)} G \hspace{1cm}\text{and}\hspace{1cm} \gamma'=\bigsqcup\nolimits^{q(G,m_1,m_2)+1} G,
\end{equation*}
if Spoiler plays at most $m_1$ point moves and $m_2$ set moves,
then Duplicator wins.
(For more details about MSO-Ehrenfeucht-Fraïssé games, see Section~7.2 of~\cite{l04}.)
To conclude the proof, it will suffice to set $q(G,m)=\max \{q(G,m_1,m_2) : m_1+m_2=m\}$.
Reason by induction over $m_2$.
If $m_2=0$, then Spoiler only plays point moves.
Set $q(G,m_1,0)=m_1$.
Since the game lasts $m_1$ turns, Spoiler touches at most $m_1$ copies of $G$ in $\gamma'$,
thus they cannot point any difference with $\gamma$.
If $m_2>0$, then set:
\begin{equation*}
\log_2\left( q(G,m_1,m_2) \right) = |G|\cdot \left(q(G,m_1,m_2-1)+m_1+m_2\right).
\end{equation*}
Call $\gamma_i$ (respectively $\gamma'_i$) the $i^{\mbox{\scriptsize th}}$ copy of $G$ in $\gamma$ (respectively $\gamma'$),
for $1\leq i\leq q(G,m_1,m_2)$ (respectively $1\leq i\leq q(G,m_1,m_2)+1$).
If Spoiler starts by playing a point move in $\gamma_i$,
then Duplicator chooses the same vertex in $\gamma'_i$.
The case of Spoiler playing in $\gamma'_i$ is symmetric:
up to reordering the $\gamma'_i$, we can assume that Spoiler never plays in $\gamma'_{q(G,m_1,m_2)+1}$.
Duplicator continues this strategy as long as Spoiler plays point moves.
Now consider the first set move of Spoiler and suppose that it was in $\gamma$.
Recall that we can assume no point move took place in $\gamma'_{q(G,m_1,m_2)+1}$.
Spoiler just pointed a subset of vertices of $\gamma$,
or equivalently pointed a subset of vertices of each $\gamma_i$ separately.
Call $V_1,\dots,V_{2^{|G|}}$ all possible subsets of vertices of $G$ and $f:\{1,\dots,q(G,m_1,m_2)\}\to\{1,\dots,2^{|G|}\}$ the function such that for each $\gamma_i$,
Spoiler pointed $V_{f(i)}$.
For $1\leq i\leq q(G,m_1,m_2)$, Duplicator plays in $\gamma'_i$ the set $V_{f(i)}$,
i.e., the same set of vertices as Spoiler played in $\gamma_i$.
It remains to play a set of vertices for $\gamma'_{q(G,m_1,m_2)+1}$:
choose $n$ such that $|f^{-1}(n)|> q(G,m_1,m_2-1)$ and play $V_n$.
Call $f'$ the function such that, for every $i$, Duplicator played $V_{f'(i)}$ in $\gamma'_i$.
To finish the game, Duplicator actually plays $2^{|G|}$ games in parallel,
one in each couple of graphs $(f^{-1}(n), f'^{-1}(n))$ for $1\leq n\leq 2^{|G|}$.
All those couples of graphs either have the same number of copies of $G$ inside,
or both have more than $q(G,m_1,m_2-1)$ copies of $G$, and Duplicator wins by induction.
Symmetrically, suppose that the first set move of Spoiler was in $\gamma'$.
Up to reordering the $\gamma'_i$,
we can suppose both that no point move took place in $\gamma'_{q(G,m_1,m_2)+1}$
and that $|f'(q(G,m_1,m_2)+1)|>q(G,m_1,m_2-1)$.
In $\gamma_i$, Duplicator plays the set $V_{f(i)}$.
To finish the game, Duplicator actually plays $2^{|G|}$ games in parallel,
one in each couple of graphs $(f^{-1}(n), f'^{-1}(n))$ for $1\leq n\leq 2^{|G|}$.
Once again all those couples of graphs either have the same number of copies of $G$ inside,
or both have more than $q(G,m_1,m_2-1)$ copies of $G$, so Duplicator wins by induction.
\end{proof}
\begin{lemma}[Proposition~7.5 from~\cite{l04}]
For every $m$, the relation $\equiv_m$ has finitely many equivalence classes.
\end{lemma}
Call $a(m)$ the number of classes of $\equiv_m$ and let $A_1,\dots,A_{a(m)}$ denote representatives of each class.
\begin{proof}[Proof of Proposition~\ref{pro:saturating}.]
Define $\Omega_m$ as follows: take $q(A_i,m)$ disjoint copies of $A_i$, for $i$ ranging in $\{1,\dots,a(m)\}$.
We show that $\Omega_m$ is either a forbidden or a sufficient subgraph for $\phi$.
for every graph $G$, we have $G \equiv_m A_i$ for one $i$ in $\{1,\dots,a(m)\}$.
Hence $\Omega_m \sqcup G \equiv_m \Omega_m \sqcup A_i$:
in the MSO-Ehrenfeucht-Fraïsé game between those graphs,
Duplicator can apply its winning strategies separately in $\Omega_m$ and in $G/A_i$.
Consequently, adding $G$ to $\Omega_m$ is equivalent to adding a $[q(A_i,m)+1]^\text{\scriptsize th}$ copy of $A_i$ to $\Omega_m$.
By definition of $q$ in Lemma~\ref{lem:qexists}, the resulting graph is equivalent to $\Omega_m$.
As a conclusion, $\Omega_m\equiv_m \Omega_m\sqcup G$, and whether it is a model of $\phi$ or not does not depend on $G$.
\end{proof}
\section{Pumping models of arborescent sentences}
\label{sec:pump}
A \emph{boundaried graph} is a digraph $G$ endowed with an additional specific sequence $P=(p_0,\dots,p_{k-1})$ of distinct nodes of $G$, called \emph{ports}.
The set of vertices, of edges and of ports of a boundaried graph $G$ are denoted by $V(G)$, $E(G)$ and $P(G)$ respectively.
If $G$ and $G'$ denote boundaried graphs with the same number of ports,
then $G\oplus G'$ (``$G$ glued to $G'$'') is defined as the graph $G\sqcup G'$ where the $i^\text{\scriptsize th}$ port of $G$ is merged with the $i^\text{\scriptsize th}$ port of $G'$.
A \emph{$k$-biboundaried graph}, or $k$-graph for short, is a digraph $G$ endowed with two sequences of $k$ ports:
the \emph{primary ports}, denoted by $P_1(G)$, and the \emph{secondary ports}, denoted by $P_2(G)$.
(So we have $|P_1(G)|=|P_2(G)|=k$.)
For two such graphs $G$ and $G'$, write $G\oplus G'$ for $G\sqcup G'$ where $P_2(G)$ is identified with $P_1(G')$.
Moreover, set $P_1(G\oplus G')=P_1(G)$ and $P_2(G\oplus G')=P_2(G')$.
Note that $P_1(G)$ and $P_2(G)$ may intersect.
Now let $\Gamma=\{G_i\}_{i\in I}$ be a finite family of $k$-graphs;
if $w$ is a nonempty word over alphabet $I$, then define $\Delta^\Gamma(w)$ by induction over the length of $w$ as follows:
\begin{equation*}
\Delta^\Gamma(w_1)=G_{w_1},
\hspace{1cm}
\Delta^\Gamma(w_1\dots w_{n}) = \Delta^\Gamma(w_1\dots w_{n-1})\oplus G_{w_{n}}.
\end{equation*}
See Figure~\ref{fig:gpack}---although the possibility that $P_1$ and $P_2$ intersect is not shown on that figure.
\begin{proposition}
\label{pro:pump}
Let $\phi$ denote an MSO sentence and $k$ an integer.
If $\phi$ has infinitely many models of treewidth $k$,
then there exists a triple of $k$-graphs $\Gamma=\{G_1,G_2,G_3\}$ such that $\Delta^\Gamma(2\cdot 1^n\cdot 3)$ is a model of $\phi$ for every integer $n$.
\end{proposition}
For the remainder of this section, we prove Proposition~\ref{pro:pump}.
Fix a sentence $\phi$ and an integer $k$.
\begin{definition}
Let $G$, $G'$ be $k$-graphs.
We write $G \sim G'$ if and only if for every $k$-graph $H$, we have:
\begin{equation*}
G\oplus H\models\phi \iff G'\oplus H\models\phi.
\end{equation*}
Of course this depends on $\phi$ and $k$, but they have been fixed for this section.
Call $\Sigma$ the set of equivalence classes of $\sim$.
\end{definition}
\begin{lemma}[Theorem~13.1.1 from~\cite{df13}]
\label{lem:pum}
The set $\Sigma$ of equivalence classes of $\sim$ is finite.
\end{lemma}
\begin{definition}
Let $G$ denote a $k$-graph with a $k$-tree decomposition $T$.
For a node $v$ of $T$, let $\mathcal{S}(v)$ denote the largest subtree of $T$ rooted in $v$.
Call $\mathcal{N}(v)$ the boundaried graph consisting of the subgraph of $G$ spanned by $\bigcup_{u\in\mathcal{S}(v)} B(u)$ and whose set of ports is $B(v)$.
Finally, call $\mathcal{C}(v)$ the equivalence class of $\mathcal{N}(v)$ for the relation $\sim$.
When the tree to which $v$ belongs is unclear, we write $\mathcal{S}_T(v)$, $\mathcal{N}_T(v)$ and $\mathcal{C}_T(v)$ to specify it.
\end{definition}
Observe that any tree decomposition of any graph can be viewed as a $\Sigma$-labeled tree:
label each node $v$ with $\mathcal{C}(v)$ instead of a bag.
We say that the $\Sigma$-labeled tree \emph{corresponds to} the tree decomposition.
The following remark is an immediate consequence of the definition of $\sim$.
\begin{remark}
\label{rk:coh}
Let $G$ denote a graph with a $k$-tree decomposition $T$, and $v$ the root of $T$.
Whether $G\models\phi$ or not depends only on $\mathcal{C}_T(v)$.
\end{remark}
A $\Sigma$-labeled tree is \emph{positive} if it corresponds to the decomposition of a model of $\phi$.
A given $\Sigma$-labeled tree might correspond to decompositions of several different graphs,
but Remark~\ref{rk:coh} ensures that they are either all models, or all countermodels.
The next definition applies both to tree decompositions and to $\Sigma$-labeled trees.
\begin{definition}
\label{dfn:tpack}
Let $T$ denote a tree, $v$ a node of $T$, and $T'$ another tree.
Write $T[\mathcal{S}(v)\gets T']$ for the tree obtained by replacing the largest subtree of $T$ rooted in $v$ with $T'$.
If $v$ is a leaf of $T$, then write $T\oplus_v T'$ for the tree $T[\mathcal{S}(v)\gets T']$.
When no confusion arises, we may drop the subscript and write $T\oplus T'$.
Now let $\mathcal{T}=\{T_i\}_{i\in I}$ denote a finite family of trees, each with a pointed leaf, and $w$ a finite, nonempty word over alphabet $I$.
Define $\Lambda^\mathcal{T}$ by induction over the length of $w$:
\begin{equation*}
\Lambda^\mathcal{T}(w_1)=T_{w_1},
\hspace{1cm}
\Lambda^\mathcal{T}(w_1\dots w_{n})= \Lambda^\mathcal{T}(w_1\dots w_{n-1}) \oplus T_{w_{n}},
\end{equation*}
where the pointed leaf of the result is inherited from $T_{w_1}$ or $T_{w_{n}}$, respectively.
See Figure~\ref{fig:tpack}.
\end{definition}
\begin{figure}
\newcommand{0.5}{0.5}
\begin{minipage}{0.48\linewidth}
\centering
\begin{tikzpicture}[scale=1.125*0.5]
\draw (0,0) rectangle node{$G_{w_{n}}$} ++(5,3);
\draw[pattern=north east lines] (0.3,2.5) rectangle ++(4.7,0.5);
\draw (5.5,2.75) node[right]{$P_2(G_{w_{n-1}})=P_1(G_{w_{n}})$};
\draw (0.3,2.5) rectangle node{$G_{w_{n-1}}$} ++(5,3);
\draw[pattern=north east lines] (0.3,5) rectangle ++(4.7,0.5);
\draw (5.5,5.25) node[right]{$P_2(G_{w_{n-2}})=P_1(G_{w_{n-1}})$};
\draw (0,5) rectangle node{$G_{w_{n-2}}$} ++(5,3);
\draw (2.5,9.25) node{$\vdots$};
\draw (0,10.5) rectangle node{$G_{w_2}$} ++(5,3);
\draw[pattern=north east lines] (0.3,13) rectangle ++(4.7,0.5);
\draw (5.5,13.25) node[right]{$P_2(G_{w_1})=P_1(G_{w_2})$};
\draw (0.3,13) rectangle node{$G_{w_1}$} ++(5,3);
\end{tikzpicture}
\caption{Illustration of $\Delta$}
\label{fig:gpack}
\end{minipage}
\begin{minipage}{0.48\linewidth}
\centering
\begin{tikzpicture}[scale=0.5]
\draw (0,0) -- +(3,3) node{$\bullet$} -- +(6,0) -- cycle;
\draw (3,1.5) node{$T_{w_{n}}$};
\draw (0,3) -- +(3,3) node{$\bullet$} -- +(6,0) -- cycle;
\draw (3,4.5) node{$T_{w_{n-1}}$};
\draw (0,6) -- +(3,3) -- +(6,0) -- cycle;
\draw (3,7.5) node{$T_{w_{n-2}}$};
\draw (3,10.5) node{$\vdots$};
\draw (0,12) -- +(3,3) node{$\bullet$} -- +(6,0) -- cycle;
\draw (3,13.5) node{$T_{w_2}$};
\draw (0,15) -- +(3,3) -- +(6,0) -- cycle;
\draw (3,16.5) node{$T_{w_1}$};
\end{tikzpicture}
\caption{Illustration of $\Lambda$}
\label{fig:tpack}
\end{minipage}
\end{figure}
\begin{lemma}
\label{lem:subst}
Let $G$ denote a model of $\phi$ with a $k$-tree decomposition $T$,
and $H$ a graph with a $k$-tree decomposition $U$ whose root is called $u$.
If $v$ is a node of $T$ such that $\mathcal{C}_T(v)=\mathcal{C}_U(u)$
then $T[\mathcal{S}(v)\gets U]$, viewed as a $\Sigma$-labeled tree, is positive.
\end{lemma}
\begin{proof}
Let $T_1$ denote $T\setminus(\mathcal{S}_T(v) - \{v\})$ and $T_2$ denote $\mathcal{S}_T(v)$.
Call $G_1$ and $G_2$ the subgraphs of $G$ spanned by the nodes in all the bags of $T_1$ and $T_2$, respectively,
and set $P(G_1)=P(G_2)=B(v)$.
Observe that $G=G_1\oplus G_2$.
Make $H$ a boundaried graph by setting $P(H)=B(u)$.
The relation $\mathcal{C}_U(u)=\mathcal{C}_T(v)$ implies that $\mathcal{N}_U(u)\sim\mathcal{N}_T(v)$, in other terms $H\sim G_2$,
so by definition of $\sim$ we have $G=G_1\oplus G_2\models\phi\iff G_1\oplus H\models\phi$ (recall that $\oplus$ is symmetric on boundaried graphs).
Hence $G_1\oplus H$ is a model of $\phi$.
Observe that $T[\mathcal{S}(v)\gets U]$ corresponds to a tree decomposition of $G_1\oplus H$ and the lemma is proved.
\end{proof}
\begin{remark}
\label{rmk:pump}
Let $\Gamma=\{G_i\}_{i\in I}$ a collection of $k$-graphs and $\mathcal{T}=\{T_i\}_{i\in I}$ a collection of $\Sigma$-labeled trees, both indexed by the same finite set $I$.
Suppose that for every $i$, the tree $T_i$ corresponds to a decomposition of $G_i$ such that the root's bag is $P_1(G_i)$ and there is a leaf whose bag is $P_2(G_i)$.
Make that leaf the pointed leaf of $T_i$.
Then, for every nonempty word $w$ over alphabet $I$,
the tree $\Lambda^\mathcal{T}(w)$ corresponds to a decomposition of $\Delta^\Gamma(w)$.
As an illustration of this remark,
we could say that the bags of the bold nodes in Figure~\ref{fig:tpack} are the nodes in hatched areas in Figure~\ref{fig:gpack}.
\end{remark}
Recall that in a digraph (and in particular in a tree),
the degree of a node is the sum of its in-degree and its out-degree.
\begin{lemma}
\label{lem:tdeg}
If a graph $G$ has a $k$-tree decomposition with $n$ nodes,
then it has a $k$-tree decomposition of degree~$3$ with at least $n$ nodes.
\end{lemma}
\begin{proof}
Split any node with more than $3$ neighbors in the tree into a chain of nodes.
\end{proof}
\begin{proof}[Proof of Proposition~\ref{pro:pump}]
The sentence $\phi$ has models with $k$-tree decompositions having arbitrarily high numbers of nodes.
By Lemma~\ref{lem:tdeg}, there is a sequence $(M_i)_{i\in\mathbb{N}}$ of models and
a sequence $(D_i)_{i\in\mathbb{N}}$ of respective $k$-tree decompositions,
such that $D_i$ has depth at least $i$.
View the $D_i$'s as $\Sigma$-labeled trees.
By Lemma~\ref{lem:pum} the set $\Sigma$ of values for $\mathcal{C}(\cdot)$ is finite;
let $n=|\Sigma|+1$, so that any $\Sigma$-labeled path of length $n$ contains two nodes with the same label.
In particular, the model $M_n$ has a tree decomposition $D_n$ containing a path of length $n$,
thus two nodes $v$ and $v'$ such that $\mathcal{C}(v)=\mathcal{C}(v')$.
Suppose without loss of generality that $v$ has lesser depth than $v'$ and let (see Figure~\ref{fig:pump}):
\begin{equation*}
T_1=\mathcal{S}(v)\setminus(\mathcal{S}(v') - \{v'\}),
\hspace{1cm}
T_2=D_n\setminus(\mathcal{S}(v) - \{v\}),
\hspace{1cm}
T_3=\mathcal{S}(v').
\end{equation*}
Define the graphs $G_1$, $G_2$ and $G_3$ as the induced subgraphs of $M_n$ spanned by all the bags of $T_1$, $T_2$ and $T_3$, respectively.
Set $P_2(G_2)=P_1(G_1)=B(v)$ and $P_2(G_1)=P_1(G_3)=B(v')$;
choose arbitrarily $P_1(G_2)$ and $P_2(G_3)$.
Let $\Gamma=(G_1,G_2,G_3)$ and $\mathcal{T}=(T_1,T_2,T_3)$, so that by Remark~\ref{rmk:pump},
the tree $\Lambda^\mathcal{T}(2\cdot 1^m\cdot 3)$ corresponds to a decomposition of $\Delta^\Gamma(2\cdot 1^m\cdot 3)$ for every $m$.
Since $\mathcal{C}(v)=\mathcal{C}(v')$, Lemma~\ref{lem:subst} implies that for every integer $m$,
the tree $\Lambda^\mathcal{T}(2\cdot 1^m\cdot 3)$ is positive.
Therefore $\Delta^\Gamma(2\cdot 1^m\cdot 3)$ is a model of $\phi$.
\end{proof}
\begin{figure}
\centering
\begin{tikzpicture}[scale=.7,baseline]
\foreach \s [count=\i] in {0,1.5,3} {
\coordinate (a\i) at ($(0,0) +(0,-\s)$);
\coordinate (b\i) at ($(2,3) +(0,-\s)$);
\coordinate (c\i) at ($(4,0) +(0,-\s)$);
\coordinate (d\i) at ($(3,0) +(0,-\s)$);
\coordinate (e\i) at ($(2,1.5)+(0,-\s)$);
\coordinate (f\i) at ($(1,0) +(0,-\s)$);
}
\foreach \i in {1,2} {
\draw (a\i)--(b\i)--(c\i)--(d\i)--(e\i)--(f\i)--cycle;
}
\draw (a3)--(b3)--(c3)--cycle;
\draw (b1)++(0,-.75) node{$T_2$};
\draw (b2) node{$\bullet$} node[right]{$v$} ++(0,-.75) node{$T_1$};
\draw (b3) node{$\bullet$} node[right]{$v'$} ++(0,-1.5) node{$T_3$};
\draw[decorate,decoration={brace,mirror}] (-.5,3) -- node[left]{$D_n$} (-.5,-3);
\end{tikzpicture}
\hspace{.5cm}
$\to$
\hspace{.5cm}
\begin{tikzpicture}[scale=.7,baseline]
\foreach \s [count=\i] in {0,1.5,...,6} {
\coordinate (a\i) at ($(0,0) +(0,-\s)$);
\coordinate (b\i) at ($(2,3) +(0,-\s)$);
\coordinate (c\i) at ($(4,0) +(0,-\s)$);
\coordinate (d\i) at ($(3,0) +(0,-\s)$);
\coordinate (e\i) at ($(2,1.5)+(0,-\s)$);
\coordinate (f\i) at ($(1,0) +(0,-\s)$);
}
\foreach \i in {1,...,4} {
\draw (a\i)--(b\i)--(c\i)--(d\i)--(e\i)--(f\i)--cycle;
}
\draw (a5)--(b5)--(c5)--cycle;
\draw (b1)++(0,-.75) node{$T_2$};
\foreach \i in {2,...,4} {
\draw (b\i)++(0,-.75) node{$T_1$};
}
\draw (b5)++(0,-.75) node{$T_3$};
\end{tikzpicture}
\caption{Proof of Proposition~\ref{pro:pump}.}
\label{fig:pump}
\end{figure}
\begin{remark}
Note that in Proposition~\ref{pro:pump}, graphs $G_1$, $G_2$ and $G_3$ are constant so the family of graphs of the form ${\Delta^\Gamma(2\cdot 1^n\cdot 3)}$ for ${n\geq 1}$ is of bounded pathwidth.
Therefore it holds that an MSO formula has infinitely many models models among bounded treewidth graphs if and only if it does among bounded pathwidth ones.
\end{remark}
\section{A reduction from \textsc{$\phi$-Dynamics} to SAT}
\label{sec:sat}
In all this section, for any biboundaried graph $G$, assume that $V(G)=\{0,\dots,|G|-1\}$
and for a node $u$ of $G$, write $G(u)$ the set $\{v:(u,v)\in E(G)\}$.
Thus, $P_1(G)$, $P_2(G)$ and $G(u)$ are all subsets of $\{0,\dots,|G|-1\}$.
\begin{proposition}
\label{pro:sat}
Fix an MSO sentence $\phi$.
Let $k$ be an integer and $\Gamma=\{G_0, G_1, G_2, G_3\}$ four $k$-graphs such that:
\begin{enumerate}[label={(\roman*)}]
\item\label{itm:eqsz} $|G_0|=|G_1|$;
\item\label{itm:cap} $P_1(G_0)\cap P_2(G_0)=P_1(G_1)\cap P_2(G_1)$; and
\item\label{itm:img} for every $p$ in $P_1(G_0)\cap P_2(G_0)$, we have $G_0(p)=G_1(p)$.
\end{enumerate}
Suppose that, for every word $w$ over alphabet $\{0,1\}$, we have $\Delta^\Gamma(2\cdot w \cdot 3)\models\phi$ if and only if $w$ contains letter $0$.
Then $\phi$-dynamics is {\ensuremath{\mathsf{NP}}}-hard, even if we restrict to inputs with bounded non-determinism.
\end{proposition}
\begin{definition}
If $S$ is an instance of SAT with $s$ variables,
then $\overline{S}$ is the word of length $2^s$ such that $\overline{S}_i$ is $1$ if $S(i)$ is false, and $0$ if $S(i)$ is true
(viewing the binary expansion of $i$ as a Boolean assignment for $S$).
\end{definition}
\begin{lemma}
\label{lem:sat}
Let $S$ be an instance of SAT with $s$ variables,
$k$ an integer and $\Gamma=\{G_0, G_1, G_2, G_3\}$ four $k$-graphs satisfying Conditions~\ref{itm:eqsz}--\ref{itm:img} of Proposition~\ref{pro:sat}.
Then, there is an integer $c$ and an automata network $F$ such that
\begin{equation*}
\TG{F}=\Delta^\Gamma(2\cdot\overline{S}\cdot 1^c \cdot3),
\end{equation*}
that can be computed in polynomial time given $S$ (the $G_i$ are considered constant).
\end{lemma}
\begin{proof}
The proof is in two steps.
The first step only gives the configuration space and the global transition relation of $F$.
It does not explain how these transitions are realized by an automata network,
nor how Boolean circuits for that network may be produced in polynomial time: that is deferred to the second step.
\paragraph*{First step.}
For now, let $c$ be an arbitrary positive or null integer.
(We will need to perform some form of padding in the second step and $c$ will be that amount of padding;
it remains unspecified in the first step.)
If $G$ is a biboundaried graph, define:
\begin{equation*}
P'_1(G)=P_1(G)\setminus P_2(G),\hspace{1cm}
P'_2(G)=P_2(G)\setminus P_1(G),\hspace{1cm}
P'_3(G)=P_1(G)\cap P_2(G).
\end{equation*}
The rationale is that we will need to handle ports that are in $P_1(G) \cap P_2(G)$ as a special case later.
By Conditions~\ref{itm:eqsz} and~\ref{itm:cap}, we have $|P'_1(G_1)|=|P'_1(G_0)|=|P'_2(G_1)|=|P'_2(G_0)|$;
call $k'$ that quantity.
We also have $|P'_3(G_1)|=|P'_3(G_0)|$; call $k''$ that quantity.
Observe that $k=k'+k''$.
Recall that for any $k$-graph $G$, we assume that $V(G)=\{0,\dots,|G|-1\}$.
Intuitively, we want to arrange things so that $P_1(G)$ is at the beginning of the interval (i.e., $\{0,\dots,k-1\}$)
and $P_2(G)$ at the end of the interval (i.e., $\{|G|-k,\dots,|G|-1\}$), so that it becomes easy to merge vertices when computing a gluing ($\oplus$) operation---see Figure~\ref{fig:sat}.
Things are unfortunately not that simple: we need to account for the possibility that $P_1(G)\cap P_2(G)\neq\emptyset$.
Thus we will put $P'_1$ at the beginning, $P'_3$ at the end, and $P'_2$ just before $P'_3$.
The only exception is in $G_3$: we put $P'_3$ just after $P'_1$, for reasons that we will explain later on.
Formally speaking, for $i=0,1,2$, assume without loss of generality that:
\begin{align*}
P'_1(G_i)&=(0,\dots,k'-1),&
P'_2(G_i)&=(|G_i|-k,\dots,|G_i|-k''-1),&
P'_3(G_i)&=(|G_i|-k'',\dots,|G_i|-1),\\
P'_1(G_3)&=(0,\dots,k'-1),&
P'_2(G_3)&=(|G_3|-k',\dots,|G_3|-1),&
P'_3(G_3)&=(k',\dots,k-1).
\end{align*}
Define the quantities:
\begin{equation*}
n_1=|G_1|-k=|G_0|-k,
\hspace{1cm}
n_2=|G_2|-k,
\hspace{1cm}
n_3=|G_3|.
\end{equation*}
The configuration space of $F$ is $\{0,\dots,n_2+(2^s+c)\cdot n_1+n_3-1\}$: see Figure~\ref{fig:sat} for a picture of its organization.
The initial segment is the (unique) copy of $G_2$, followed by $2^s+c$ copies of $G_0$ or $G_1$, followed by the (unique) copy of $G_3$.
Those copies overlap to account for the merged vertices between all those graphs.
Let $\ell=2^s+c-1$ be the index of the last copy of $G_0$ or $G_1$.
For $q$ in $\{-1,0,\dots,2^s+c\}$, define (see the following paragraph for intuition):
\begin{align}
\label{eq:dcase01}
\delta^q_0(r)=\delta^q_1(r)&=
\begin{cases}
n_2+q\cdot n_1+r &\text{ if } r\in\{0,\dots,|G_1|-k''-1\},\\
n_2+\ell\cdot n_1+r &\text{ if } r\in\{|G_1|-k'',\dots,|G_1|-1\};
\end{cases}\\
\label{eq:dcase2}
\delta^q_2(r)&=
\begin{cases}
r &\text{ if } r\in\{0,\dots,|G_2|-k''-1\},\\
\delta^\ell_1(r)+|G_1|-|G_2|&\text{ if } r\in\{|G_2|-k'',\dots,|G_2|-1\};\\
\end{cases}\\
\label{eq:dcase3}
\delta^q_3(r)&=n_2+(2^s+c)\cdot n_1+r.
\end{align}
The functions $\delta$ map integers to integers, but we implicitly extend them to sets of integers, elementwise.
Intuitively, $\delta^q_j(r)$ refers to the $r^\text{\scriptsize th}$ node of a copy of $G_j$ in Figure~\ref{fig:sat}, i.e., in the configuration space of $F$.
There is only one copy of $G_2$ and one of $G_3$, so if $j=2,3$, this is unambiguous.
But there are many (precisely $2^s+c$) copies of $G_0$ and $G_1$, and whether a given graph is $G_0$ or $G_1$ will change according to $S$;
therefore, the superscript $q$ is used to specify which copy of $G_0$ (or $G_1$) we are targeting.
It will be convenient to write $\delta^q_2$ and $\delta^q_3$ even though they do not depend on $q$.
Now the only difficulty resides in the $k''$ ports common to all occurrences of $G_0$ and $G_1$---%
which are also common to the copy of $G_2$ and the copy of $G_3$, by construction.
They are ``physically'' located after the last copy of $G_0$ or $G_1$, which has index $\ell$.
There is a special case in Equations~\eqref{eq:dcase01} and~\eqref{eq:dcase2} to redirect any edges going into these nodes to the proper location.
The graph $G_3$ is organized so that elements of $P'_3(G_3)$ are already at the right place.
The edges going out of those nodes are handled later on.
We are now ready to give the global transition function $F$, from the configuration space to itself.
Recall that $F$ is nondeterministic, so the value of $F(x)$ is a set.
\begin{itemize}
\item If $x<n_2$, then set:
\begin{equation}
\label{eq:fcase2}
F(x)=(\delta^0_2\circ G_2)(x).
\end{equation}
\item If $x-n_2<(2^s+c)\cdot n_1$, then by Euclidean division let $q$, $r$ be such that $x-n_2=q\cdot n_1+r$, with $r \in \{0,\dots,n_1-1\}$.
Let $i$ and $j$ denote $\overline{S}(q-1)$ and $\overline{S}(q)$ respectively.
However if $q=0$, then set $i=2$ instead;
if $q-1$ (respectively $q$) is $2^s$ or higher, then set $i$ (respectively $j$) to $1$ instead.
Set:
\begin{equation}
\label{eq:fcase01}
F(x)=
\begin{cases}
(\delta^q_j\circ G_j)(r) \sqcup (\delta^{q-1}_i\circ G_i)(r+n_i) &\text{ if } r\in\{0,\dots,k'-1\},\\
(\delta^q_j\circ G_j)(r) &\text{ otherwise.}
\end{cases}
\end{equation}
\item Otherwise, $n_2+(2^s+c)\cdot n_1\leq x$, so let $q=2^s+c$ and $r=x-(n_2+(2^s+c)\cdot n_1)$.
Let $i=\overline{S}(2^s-1)$ if $c=0$ and $i=1$ otherwise, and set:
\begin{equation}
\label{eq:fcase3}
F(x)=
\begin{cases}
(\delta^0_3\circ G_3)(r)\sqcup(\delta^{q-1}_i\circ G_i)(r+n_1)&\text{ if }0\leq r<k',\\
(\delta^0_3\circ G_3)(r)\sqcup(\delta^0_2\circ G_2)(r+n_2) \bigsqcup_{t=0}^\ell(\delta^t_1\circ G_1)(r+n_1)&\text{ if }k'\leq r<k,\\
(\delta^0_3\circ G_3)(r) &\text{ otherwise.}
\end{cases}
\end{equation}
\end{itemize}
Observe that $\TG{F}$ is, by construction, $\Delta^\Gamma(2\cdot\overline{S}\cdot 1^c\cdot 3)$.
Assume, for the sake of the discussion, that $S(0)$ evaluates to true and $S(1)$ to false, so the first two graphs after $G_2$ are $G_0$, then $G_1$.
Those two graphs share $k'$ vertices that they do not share with any other $G_j$ in the construction.
Those vertices are ``physically'' located at nodes $\{0,\dots,k'-1\}$ of the copy of $G_1$.
The edges from $G_0$ going into those shared nodes naturally point correctly,
because the last $k'$ nodes of $G_0$ are identified with the first $k'$ nodes of $G_1$
(both are, by definition, encoded by $n_2+n_1+\{0,\dots,k'-1\}$ in the global dynamics---see the overlaps in Figure~\ref{fig:sat}).
The edges going out of those shared nodes into $G_0$ are realized by the first case in Equation~\eqref{eq:fcase01}.
The same reasoning goes for $S(1)$ and $S(2)$, and so on.
As explained previously, there are $k''$ nodes that are shared by all the copies of $G_0,G_1,G_2,G_3$ in the dynamics.
The edges going into those nodes were handled in the definition of $\delta^q_j$;
the edges going out of those nodes are handled by the second case of Equation~\eqref{eq:fcase3}.
That case assumes that all copies of $G_0$ and $G_1$ in the dynamics are in fact copies of $G_1$;
this yields the desired results by Condition~\ref{itm:img}.
\begin{figure}
\centering
\begin{tikzpicture}[xscale=.9,yscale=.7]
\fill[gray!40!white] (14.2,0) rectangle node[black]{$k''$} ++(0.8,1.25);
\newcommand{0.1}{0.1}
\draw[->,>=latex] (0,0) -- (17,0);
\draw (0,-0.1) -- (0,+0.1);
\foreach \x in {0.2,0.4,...,16.8} {
\draw (\x,0) -- (\x,0.1);
}
\newcommand{\gr}[4]{
\draw[decorate,decoration={brace}] (#1,#2) -- node[above]{#3} ++(#4,0);
\draw[dashed] (#1,#2) -- (#1,0);
\draw[dashed] (#1+#4,#2) -- (#1+#4,0);
}
\gr{0}{0.8}{$G_2$}{3.2};
\gr{2.4}{1.2}{$G_0$}{3};
\gr{4.8}{0.8}{$G_1$}{3};
\gr{7.2}{1.2}{$G_0$}{3};
\draw (10.7,0.5) node{$\dots$};
\gr{11.2}{0.8}{$G_1$}{3};
\gr{13.6}{1.2}{$G_3$}{3.2};
\draw[<-] (0.1,-0.1) -- ++(0,-0.5) node[below]{$0$};
\draw[<-] (2.5,-0.1) -- ++(0,-0.5) node[below]{$n_2$};
\draw[<-] (3.3,-0.1) -- ++(0,-1.5) node[below]{$n_2+k'=|G_2|-k''$};
\draw[<-] (4.9,-0.1) -- ++(0,-0.5) node[below]{$n_2+n_1$};
\draw[<-] (5.5,-0.1) -- ++(0,-2.5) node[below]{$n_2+n_1+k'=n_2+|G_0|-k''$};
\draw[<-] (7.3,-0.1) -- ++(0,-0.5) node[below]{$n_2+2n_1\,~$};
\draw[<-] (7.925,-0.1) -- ++(0,-1.5) node[below]{$n_2+n_1+|G_1|-k''$};
\draw[<-] (11.3,-0.1) -- ++(0,-0.5) node[below]{$n_2+(2^s+c-1)\cdot n_1$};
\draw[<-] (13.7,-0.1) -- ++(0,-1.5) node[below]{$n_2+(2^s+c)\cdot n_1$};
\end{tikzpicture}
\caption{Proof of Lemma~\ref{lem:sat}, a representation of $\{0,\dots,n_2+(2^s+c)\cdot n_1+n_3-1\}$ as the configuration space of $F$.
The gray area ($k''$) is actually common to all the graphs.}
\label{fig:sat}
\end{figure}
\paragraph*{Second step.}
We have a configuration space and a transition relation; we want an automata network that realizes them.
First, we determine (in polynomial time) the number of automata of $F$ and the alphabet of each automaton.
This process fixes the value of $c$, which does no harm, because the previous step worked for arbitrary values of $c$.
Let $p=n_2+n_3$ and $d=\gcd(p,n_1)$; write $p=p'\cdot d$ and $n_1=n'\cdot d$ for coprime integers $p'$, $n'$.
Find an integer $t$ such that $p\leq 2^t$ and $\gcd(s+t,\varphi(n'))=1$, where $\varphi$ denotes Euler's totient and $s$ is the number of Boolean variables of $S$.
To do so, let $t'=s/\gcd(s,\varphi(n'))$, so that $t'$ and $\varphi(n')$ have no common prime factors.
Then let $t''$ denote a power of $t'$ that exceeds $s+\lceil\log_2 p\rceil$ (compute it by successive squarings).
Finally, take $t=t''-s$.
Since $\gcd(p',n')=1$, we can use Algorithm~17.1 from~\cite{s12}
to find an integer $e\geq 1$ such that $e^{s+t}\equiv p'\mod n'$.
For the rest of the proof, assume that $e\geq 2$: indeed, if $e=1$, then $p'\equiv 1\mod n'$,
so by Euler's formula we can choose $e=p'^{\varphi(n')}$ instead.
Since Algorithm~17.1 from~\cite{s12} runs in polynomial time and $p'$, $n'$ are constants, we can find $e$ and $t$ in polynomial time.
(Recall that $s$ is the number of variables of $S$, our input, so we can consider that $s$ is given in unary.)
The automata network $F$ has one node over alphabet $\{0,\dots,d-1\}$ and $s+t$ nodes over alphabet $\{0,\dots,e-1\}$.
Its configuration space has $d\cdot e^{s+t}$ elements.
Since $2\leq e$, we have $2^s\leq e^s$ and $p\leq 2^t\leq e^t$;
moreover we have $e^{s+t}\equiv p'\mod n'$, so there is an integer $c\geq 0$ such that $d\cdot e^{s+t}=p+(2^s+c)\cdot n$.
Now that we have the right number of configurations, it is easy to produce in polynomial time the Boolean circuits for $F$:
they read the current configuration as an integer and apply the rules from the first step of this proof.
The $G_i$ are considered constant, and the only part that depends on $S$ merely evaluates $S$.
Moreover, each configuration requires at most two evaluations of $S$ to compute the set of successors (in Equation~\ref{eq:fcase01},
for the values of $i$ and $j$).
This concludes the proof.
\end{proof}
\begin{proof}[Proof of Proposition~\ref{pro:sat}]
Immediate consequence of Lemma~\ref{lem:sat}:
given an instance $S$ of SAT, compute in polynomial time the corresponding automata network $F$, and ask $\phi$-dynamics on that $F$.
Moreover, the transition graphs of such automata networks are all of the form ${\Delta^\Gamma(w)}$ for a fixed set of finite graphs $\Gamma$ so they have a bounded degree, meaning that the constructed automata networks have bounded non-determinism.
\end{proof}
\begin{proof}[Proof of Theorem~\ref{thm:main}]
Let $\phi$ denote an arborescent MSO sentence with $m$ quantifiers.
By Proposition~\ref{pro:saturating}, the graph $\Omega_m$ is either forbidden or sufficient for $\phi$.
Assume that $\Omega_m$ is forbidden for $\phi$ and prove that $\phi$-dynamics is {\ensuremath{\mathsf{NP}}}-hard.
(If it was sufficient, then consider $\neg\phi$ instead---this would yield that $\phi$-dynamics is {\ensuremath{\mathsf{coNP}}}-hard.)
By Proposition~\ref{pro:pump},
there exist a triple of graphs $\Gamma=(G_1,G_2,G_3)$ such that $\Delta^\Gamma(2\cdot 1^n\cdot 3)$ is a model of $\phi$ for every integer $n$.
Let $H$ denote the subgraph of $G_1$ spanned by:
\begin{equation*}
\left[P_1(G_1)\cap P_2(G_1)\right]
\;\bigcup\;
\{j : \exists i \in P_1(G_1)\cap P_2(G_1), (i,j)\in E(G_1)\}
\end{equation*}
and $G_0=H\sqcup \Omega_m$ (see Figure~\ref{fig:G0}).
Let $G'_1=\bigoplus_{i=1}^n G_1$, where $n$ is the smallest integer such that $|G'_1|\geq |G_0|$.
Finally, let $G'_0$ denote $G_0$ with enough isolated nodes added so that $|G'_0|=|G'_1|$.
It is possible to reorder the nodes of $G'_0, G'_1$ and add ports so that the quadruple $\Gamma'=(G'_0, G'_1, G_2, G_3)$ satisfies all the conditions of Proposition~\ref{pro:sat}.
This concludes the proof of the theorem.
\end{proof}
\begin{figure}
\centering
\begin{tikzpicture}
\draw[dashed] (0,0) rectangle ++(8,3);
\draw (0,2.75) node[right]{($H$, copied from $G_1$)};
\foreach \i in {1,...,7} {
\node (a\i) at (\i,1) {$\bullet$};
\node (b\i) at (\i+.25,2) {$\bullet$};
\node (c\i) at (\i,2) {$\bullet$};
\node (d\i) at (\i-.25,2) {$\bullet$};
\draw[->,>=latex] (a\i) -- (b\i);
\draw[->,>=latex] (a\i) -- (c\i);
\draw[->,>=latex] (a\i) -- (d\i);
}
\draw[decorate,decoration={brace,mirror}] (a1.south) -- node[below]{$P_1(G_1)\cap P_2(G_1)$} (a7.south);
\draw (9,0) rectangle node{$\Omega_m$} ++(3,3);
\end{tikzpicture}
\caption{Representation of $G_0$ in the proof of Theorem~\ref{thm:main}.}
\label{fig:G0}
\end{figure}
\begin{remark}
Note that the constructed automata networks are such that all nodes except one have the same alphabet.
The proof of Lemma~\ref{lem:sat} is as close as we could get to a proof working for automata networks with constant uniform alphabet, which is the most usual setting in the literature.
We have no idea how to close the gap to fit this setting.
\end{remark}
\section{Nonarborescent formulae}
\label{sec:bad}
In this section, we explore what happens when the \emph{arborescence} condition in Theorem~\ref{thm:main} is negated.
First, if $\phi$ is an MSO sentence with finitely many models or with finitely many countermodels, then it is not arborescent.
But in this case, we can test $\phi$ in constant time.
Indeed, if $\phi$ has finitely many models, then there are finitely many automata networks whose dynamics satisfy $\phi$
(because we assume that Boolean circuits are never bigger than their transition tables).
So testing $\phi$ amounts to testing whether the input belongs to a fixed list, which can be done in constant time:
any input larger than the largest element of the list can immediately be rejected without further computation.
We call such sentences \textbf{trivial}.
More interestingly, the question ``is $\TG{F}$ a clique?'' is expressible in first order, hence in MSO,
but is both nonarborescent and nontrivial.
It is easy to show that this question is {\ensuremath{\mathsf{coNP}}}-hard: given an instance $S$ of SAT with $s$ variables,
make a network with $s$ Boolean automata that views its own configuration as an assignement for $S$ and evaluates it.
If it finds ``false'', then each automaton can choose nondeterministically either to change state or to remain in the same state.
If it finds ``true'', then all automata are required to stay in the same state.
The transition graph of that network is a clique if and only if all assignments for $S$ evaluate to false.
Producing Boolean circuits which evaluate a given instance of SAT is easily done in polynomial time,
which concludes the reduction.
It is tempting to conjecture that for every nontrivial MSO formula $\phi$, the problem \textsc{$\phi$-Dynamics} is either {\ensuremath{\mathsf{NP}}}- or {\ensuremath{\mathsf{coNP}}}-hard.
The next theorem shows that this conjecture is unlikely to hold.
\begin{definition}[Definition~1 from~\cite{fs17}]
A set $M$ of integers is \textbf{robust} if and only if:
\begin{equation*}
\forall k, \exists \ell \geq 2: \{\ell,\ell+1,\dots,\ell^k\} \subset M.
\end{equation*}
This implies that $M$ is infinite.
\end{definition}
We denote by UNSAT the complement of SAT (\textit{i.e.} CNF formulae that are not satisfiable).
\begin{theorem}
\label{thm:bad}
There is a nontrivial first-order sentence $\psi$ such that, if either SAT or UNSAT reduces to \textsc{$\psi$-Dynamics},
then there is a polynomial-time algorithm solving SAT for a robust set of sizes of instances.
\end{theorem}
According to Proposition~8 and Theorem~12 of~\cite{fs17}, our Theorem~\ref{thm:bad} implies:
\begin{corollary}
Let $\psi$ be given by Theorem~\ref{thm:bad}.
If either SAT or UNSAT reduces to \textsc{$\psi$-Dynamics},
then any problem in the polynomial hierarchy can be solved in polynomial time on a robust set of sizes of instances.
\end{corollary}
The rest of this section is a proof of Theorem~\ref{thm:bad}.
For now, let $\psi$ be an arbitrary first-order sentence,
and $f$ a polynomial reduction from either SAT or UNSAT to \textsc{$\psi$-Dynamics}.
\begin{definition}
Let $P$ be a polynomial and $n$ a positive integer.
The reduction $f$ is \textbf{$P$-meager in $n$} if and only if
for every instance $S$ of SAT with size $n$, we have:
\begin{equation*}
|f(S)| \leq \log P(n).
\end{equation*}
The set of values in which $f$ is $P$-meager is called the \textbf{$P$-meagerness set} of $f$.
\end{definition}
Let $P$ denote a polynomial.
If $f$ is $P$-meager in some integer $n$,
then all instances of SAT with size $n$ are mapped to networks whose transition graphs have $O(P(n))$ vertices.
Indeed, the transition graph is exponentially large in the network description.
Besides, we can test $\psi$ on a graph $G$ in time polynomial in $|G|$,
the degree of the polynomial being the quantifier rank of $\psi$
(recall that $\psi$ is a first-order sentence).
Therefore:
\begin{lemma}
\label{lem:meagersat}
Assume that $f$ is a reduction as before and let $P$ be a polynomial.
There is a polynomial-time algorithm that solves SAT on all instance sizes that are in the $P$-meagerness set of $f$.
\end{lemma}
\begin{proof}
Given an instance $S$ of SAT with size $n$, compute the network $f(S)$ in polynomial time;
call $G$ its transition graph.
We can compute the size of $G$ from $f(S)$ in polynomial time,
because we have the list of nodes and the state set of each node.
If $|G| > P(n)$, then return whatever answer: $f$ is not $P$-meager in $n$ anyway.
Otherwise compute $G$ itself, which can be done in polynomial time since $|G| \leq P(n)$,
and evaluate $\psi$ on $G$, which can also be done in polynomial time (the final answer is negated if reduction $f$ is from UNSAT instead of SAT).
\end{proof}
\begin{lemma}
\label{lem:meagerenum}
Let $f$ be a reduction as before and $P$ be a polynomial.
If $f$ has a nonrobust $P$-meagerness set then, for every integer $d\geq 1$, either:
\begin{enumerate}[label=(\roman*)]
\item $f$ produces a model of $\psi$ whose size is not in $\mathbb{N}^{(d)}=\{n^d : n\in\mathbb{N}\}$; or
\item there exists an increasing primitive-recursive sequence $\mu$ such that $\mu(n)^d$ is the size of a model of $\psi$ for each $n$.
\end{enumerate}
\end{lemma}
\begin{proof}
By hypothesis there is an integer $k$ such that, for every $\ell \geq 2$,
there is at least one value among $\ell,\ell+1,\dots,\ell^k$ in which $f$ is not $P$-meager.
Observe that if $P'$ is the polynomial giving the execution time of $f$,
then $f$ produces networks whose transition graphs have size at most $2^{P'(n)}$
with $n$ the size of the SAT or UNSAT instance.
Let $t:\mathbb{N}\to\mathbb{N}$ be a primitive recursive function such that, for every $n$:
\begin{equation}
\label{eq:t}
t(n+1) > \max\{2^{P'(t(n))}, t(n)^k\}.
\end{equation}
Moreover since the meagerness set of $f$ is nonrobust,
we can additionally choose $t$ such that $f$ is not $P$-meager in $t(n)$, for every $n$.
(Starting from a function $t$ that satisfies Equation~\eqref{eq:t}, given $n$,
it is possible to enumerate all values $t(n),t(n)+1,\dots,t(n)^k$ and to find the one for which $f$ is not $P$-meager.
That computation can be done in a primitive recursive fashion.)
For every $n$, let us pass to $f$ a positive instance of SAT with size $t(n)$
(or a negative instance if reduction $f$ is from UNSAT instead of SAT);
the result is a sequence of automata networks, $(\alpha(n))_{n\in\mathbb{N}}$.
This sequence can be made primitive recursive because $t$ and $f$ are.
Call $\beta(n)$ the transition graph of $\alpha(n)$;
since $f$ is a reduction and we passed positive instances of SAT to it,
the graph $\beta(n)$ is a model of $\psi$.
By non-$P$-meagerness of $f$ in $t(n)$, we can furthermore compute
the instances of SAT such that:
\begin{equation*}
P(t(n))\leq |\beta(n)|,
\end{equation*}
in a primitive recursive fashion
(simply by enumerating propositional formulae of size $t(n)$).
Also, considering that $P'$ is the running time of $f$,
that a transition graph is at most exponential in the size of the network,
and Equation~\eqref{eq:t}, we have:
\begin{equation*}
|\beta(n)| \leq 2^{P'(t(n))} < t(n+1).
\end{equation*}
Since $P(t(n)) \leq |\beta(n)| < P(t(n+1))$, the sequence $|\beta(n)|$ is increasing in $n$.
Moreover for every $d\geq 1$, there is an $n_0$ such that for every ${n\geq n_0}$,
we have $|\beta(n+2)|^{1/d} > |\beta(n)|^{1/d}$ (as $|\beta(n+2)|> 2^{P'(|\beta(n)|)}$).
If ${|\beta(n)|^{1/d}}$ is not an integer for some $n$ then the reduction $f$ produces a model of $\psi$ whose size is not in ${\mathbb{N}^{(d)}}$ and the lemma follows.
Otherwise, we define the map $\mu:\mathbb{N}\to\mathbb{N}$ by $\mu(n) = |\beta(2(n+n_0))|^{1/d}$;
by the previous inequality $\mu$ is an increasing map.
Finally, since $\alpha(n)$ is primitive recursive in $n$, so is $\beta(n)$ and so is $\mu(n)$.
The lemma follows because by construction ${\mu(n)^d}$ is always the size of a model of $\phi$.
\end{proof}
\begin{definition}
The \textbf{spectrum} of $\psi$ is the set of sizes of models of $\psi$.
In symbols:
\begin{equation*}
\mathrm{Spec}(\psi) = \{|G|:G\models\psi\}.
\end{equation*}
See~\cite{djmm12} for a survey about this notion.
A function $h:\mathbb{N}\to\mathbb{N}$ is \textbf{time-constructible} if and only if
there is a Turing machine that, for every $n$, halts in exatly $h(n)$ steps on input $n$ written in binary.
\end{definition}
\begin{lemma}
\label{lem:specim}
For every time-constructible function $h$,
there exist a first-order sentence $\psi_h$ and an integer $d$ such that $\mathrm{Spec}(\psi_h)=\mathrm{Im}(h)^{(d)}$, where
$\mathrm{Im}(h)^{(d)} = \{n^d : n \in \mathrm{Im}(h)\}$.
\end{lemma}
\begin{proof}
By~\cite[Theorem 4.5]{js75} and~\cite[Theorem 3]{f75},
we just have to prove that $\mathrm{Im}(h)$ is a {\ensuremath{\mathsf{NEXPTIME}}}{} language.
Given $n$, the algorithm guesses a word $u$ of length at most $n$,
runs $h$ on input $u$ and checks that it halts in $n$ steps exactly.
If $n\in\mathrm{Im}(h)$ then there is $u$ such that $h(u)=n$ and $|u|\leq n$
because the machine cannot read more than $n$ input symbols within $n$ steps.
\end{proof}
\begin{lemma}
\label{lem:diag}
There is a first-order sentence $\psi$ and an integer $d$ such that, for every increasing primitive-recursive function $R$, we have:
\begin{equation}
\label{eq:specpsi}
\mathrm{Im}(R)^{(d)} \not\subseteq \mathrm{Spec}(\psi)\subseteq\mathbb{N}^{(d)}.
\end{equation}
\end{lemma}
\begin{proof}
Let $(R_n)_{n\in\mathbb{N}}$ be a computable enumeration of increasing primitive-recursive functions.
(To construct one, start from a computable enumeration of primitive-recursive functions $(R'_n)_{n\in\mathbb{N}}$
and change $R'_n$ into $R_n$ as follows: $R_n:i\mapsto \max\{R_n(i-1)+1, R'_n(i)\}$.
This transformation is computable and leaves increasing functions unchanged, so it hits all of them.)
For every integer $n$, define the set:
\begin{equation}
\label{eq:en}
E(n) = \{R_i(j) : 0\leq i,j\leq n\},
\end{equation}
and let $h$ denote an increasing time-constructible function such that:
\begin{equation}
\label{eq:hn}
h(n) > \max E(n),
\end{equation}
for instance, $h$ may explicitly compute $\max E(n)$ and spend that many steps idling by decreasing a counter.
Let us show that for every $n$, there exists an element in $\mathrm{Im}(R_n)\setminus\mathrm{Im}(h)$.
The set $\{h(0), \dots, h(n-1)\}$ cannot contain $\{R_n(0), \dots, R_n(n)\}$ because $R_n$ is injective
(since it is increasing).
So there is an element $i$ of $\{0, \dots, n\}$ such that $R_n(i)$ does not belong to $\{h(0), \dots, h(n-1)\}$.
We have $R_n(i) < h(n)$ by Equations~\eqref{eq:en}--\eqref{eq:hn};
since $h$ is increasing, $R_n(i)$ is not in $\mathrm{Im}(h)$.
The existence of desired formula $\psi$ follows from Lemma~\ref{lem:specim}.
\end{proof}
\begin{proof}[Proof of Theorem~\ref{thm:bad}.]
Let $\psi$ and $d$ be given by Lemma~\ref{lem:diag} and assume that $f$ is a polynomial reduction from either SAT or UNSAT to \textsc{$\psi$-Dynamics}.
Both the spectrum of $\psi$ and its complement are infinite, so $\psi$ is nontrivial.
If there exists some polynomial $P$ such that $f$ has a robust meagerness set,
then by Lemma~\ref{lem:meagersat} there exists a polynomial-time algorithm solving SAT on a robust set of instance sizes.
Otherwise, since $\mathrm{Spec}(\psi)\subseteq\mathbb{N}^{(d)}$, Lemma~\ref{lem:meagerenum} implies that there is an increasing primitive-recursive map $\mu$ such that,
for every $n$, the quantity $\mu(n)^d$ is the size of a model of $\psi$.
But then, by Lemma~\ref{lem:diag}, one of those sizes will not be contained in the spectrum of $\psi$: a contradiction.
\end{proof}
\section*{Discussion and Future work}
One could consider different parametrizations of \textsc{$\phi$-Dynamics}.
Let us first point out that parametrization by the size or quantification rank of the formula fails.
The formula $\exists x: F(x,x)$ expresses the property: ``$F$ has at least one fixed point.''
That question is {\ensuremath{\mathsf{NP}}}-hard: given an instance $S$ of SAT, produce an AN with $|S|$ Boolean automata that evaluates its own configuration on $S$;
if it finds ``true'', nothing changes; if it finds ``false'', it transitions to the next configuration (in lexicographic order).
The formula above is virtually the smallest possible by any reasonable parameterization of logic formulae,
so there is no hope to get fixed-parameter tractability if the parameter concerns the formula.
Moreover, in this reduction every transition graph produced is either a huge cycle or a sequence of paths ending in loops.
This implies that they all have treewidth~$1$, so parameterization by the treewidths of transition graphs also fails:
we have {\ensuremath{\mathsf{NP}}}-difficulty even when the treewidth is guaranteed to be at most~$1$.
Another relevant parameter, when taking the automata networks point of view, is the size of the alphabets $Q_v$ used at each nodes.
For instance, as it is usually the case in the automata networks literature, one could consider \textsc{$\phi$-dynamics} restricted to automata networks where all nodes share the same alphabet of size $q$.
Our reduction in Lemma~\ref{lem:sat} fails in this settings as it produces automata networks with possibly two different alphabet sizes among their nodes.
We do not know whether our main theorem holds for a fixed alphabet, but it is interesting to note that some formulae become trivial when fixing the alphabet: for instance, a formula asking that each configuration belong to a cycle of length two has no model with a ternary alphabet.
On the other hand, it remains to fully characterize which nonarborescent MSO sentences yield an {\ensuremath{\mathsf{NP}}}- or {\ensuremath{\mathsf{coNP}}}-hard problem,
and what happens with those that do not.
In particular, Theorem~\ref{thm:bad} does not say whether the formula $\phi$ has a polynomial-time solvable \textsc{$\phi$-Dynamics} problem.
We do not know whether it could be the case for some $\phi$ under reasonable complexity assumptions.
It would be interesting to have average-case difficulty rather than worst-case difficulty,
e.g., to show that ``draw a configuration at random and check whether it is a fixed point'' is not a good algorithm to find fixed points in general.
In the same vein, general hardness results on \emph{probabilistic} automata network would also be welcome.
Finally, let us recall that the main result of this paper do not hold when restricting to some natural families of automata networks and using other input representation than circuits: for instance
threshold automata networks or automata networks of bounded degree can be naturally described as labeled graphs. In such cases, arborescent formulae can have a polynomial-time \textsc{$\phi$-Dynamics} problem, like ``being a constant function''. It would be interesting to understand what properties become tractable in these natural restrictions (which are often considered in the literature) and which fragment of MSO remains intractable.
\section*{Acknowledgments}
The authors are very grateful to Édouard Bonnet (LIP, France) for the proof of Proposition~\ref{pro:saturating}.
\printbibliography
\end{document}
| {'timestamp': '2023-02-10T02:09:14', 'yymm': '2302', 'arxiv_id': '2302.04522', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04522'} | arxiv |
\subsection{Norm bounds on simple graph matrices}
In this section, we will prove \cref{lem: graphmatrixnormbound_nomiddlevertices}. First, we recall the following scalar concentration result from \cite{schudy2011bernstein}.
\subsubsection{Schudy-Sviridenko moment bound}
The definitions and main bound in this section are from \cite{schudy2011bernstein}.
\begin{definition}
A random variable $Z$ is central moment bounded with real parameter $L > 0$ if for any integer $i \ge 1$,
\[\mathbb{E}[|Z - \mathbb{E}[Z]|^i] \le i\cdot L\cdot \mathbb{E}[|Z - \mathbb{E}[Z]|^{i - 1}]\]
\end{definition}
\begin{propn}
The $p$-biased Bernoulli random variable $Z$ is central moment bounded with real parameter $L =\sqrt{\frac{1 - p}{p}}$.
\end{propn}
\begin{proof}
We have $\mathbb{E}[Z] = 0$ and for $p \le \frac{1}{2}$, $|Z| \le \sqrt{\frac{1 - p}{p}}$, therefore,
\begin{align*}
\mathbb{E}[|Z - \mathbb{E}[Z]|^i] &= p\sqrt{\frac{p}{1 - p}}^i + (1 - p)\sqrt{\frac{1 - p}{p}}^i\\
&\le \sqrt{\frac{1 - p}{p}}\bigg(p\sqrt{\frac{p}{1 - p}}^{i - 1} + (1 - p)\sqrt{\frac{1 - p}{p}}^{i- 1}\bigg)\\
&= \sqrt{\frac{1 - p}{p}}\mathbb{E}[|Z - \mathbb{E}[Z]|^{i - 1}]
\end{align*}
therefore, we can take $L = \sqrt{\frac{1 - p}{p}}$.
\end{proof}
For a given multilinear polynomial $f(x)$ on variables $x_1, \ldots, x_n$, we can naturally associate with it a hypergraph $H$ on vertices $[n]$ and weighted hyperedges $E(H)$ where each $h \in E(H)$ corresponds to a distinct term of $f(x)$. Each hyperedge $h$ is a subset $V(h)$ of vertices and has a real valued weight $w_h$ which is the coefficient of that monomial in $f$. Therefore,
\[f(x) = \sum_{h \in E(H)} w_h \prod_{v \in V(h)} x_v\]
Assume $f$ has degree $d_p$, then each hyperedge of $H$ has at most $d_p$ vertices.
Now, for a given collection of independent random variables $Y_1, \ldots, Y_n$, a multilinear poynomial $f$ with associated hypergraph $H$ and weights $w$, and an integer $r \ge 0$, define
\[\mu_r(f, Y) = \max_{S \subseteq [n], |S| = r} \bigg(\sum_{h \in E(H), S \subseteq V(h)} |w_h|\prod_{v \in V(h) \setminus S} \mathbb{E}[|Y_v|]\bigg)\]
\begin{lemma}[\cite{schudy2011bernstein}, Lemma 5.1]\label{lem: schudy_sviridenko}
Given $n$ independent central moment bounded random variables $Y_1, \ldots, Y_n$ with the same parameter $L > 0$ and a degree $d_p$ multilinear polynomial $f(x)$. Let $t \ge 2$ be an even integer, then
\[\mathbb{E}[|f(Y) - \mathbb{E} [f(Y)]|^t] \le \max\bigg\{\bigg(\sqrt{tR_4^{d_p}\var{f(Y)}}\bigg)^t, \max_{r \in [d_p]}(t^rR_4^{d_p}L^r\mu_r(f, Y))^t\bigg\}\]
where $R_4 \ge 1$ is some absolute constant.
\end{lemma}
In our setting, we can also bound the variance in terms of the $\mu_r$ as was shown in \cite{schudy2011bernstein}, which will simplify our calculations.
\begin{lemma}[\cite{schudy2011bernstein}, Lemma 1.5]\label{lem: var_bound}
For the same setting as in \cref{lem: schudy_sviridenko},
\[\var{f(Y)} \le 2d_p 4^{d_p}\max_{r \in [d_p]} (\mu_0(f, Y) \mu_r(f, Y)4^rL^r)\]
\end{lemma}
\subsubsection{Proof of \cref{lem: graphmatrixnormbound_nomiddlevertices}}
We are ready to prove \cref{lem: graphmatrixnormbound_nomiddlevertices} which we restate for convenience.
\simplegraphmatrixnormbounds*
We will prove it the same way as \cref{lem: empty_shape}, by bounding the schatten norm of each diagonal block by an appropriate power of its Frobenius norm. In this case, to bound the expected power of the Frobenius norm, we use the scalar concentration inequality from the previous section.
\begin{proof}[Proof of \cref{lem: graphmatrixnormbound_nomiddlevertices}]
First, we note that ${\mat{M}}_{\tau}$ has a block diagonal structure indexed by the realizations of the set of common vertices $S_0 = U_{\tau_P} \cap V_{\tau_P}$. For $T \in [n]^{S_0}$, let ${\mat{M}}_{\tau, T}$ be the block of ${\mat{M}}_{\tau}$ with $\varphi(S_0) = T$. Then, ${\mat{M}}_{\tau, T}{\mat{M}}_{\tau, T'}^\intercal = {\mat{M}}_{\tau, T}^\intercal{\mat{M}}_{\tau, T'} = 0$ for $T \neq T'$ and so,
\begin{align*}
\Esch{{\mat{M}}_{\tau}}{2t} = \sum_{T \in [n]^{S_0}} \Esch{{\mat{M}}_{\tau, T}}{2t} \le \sum_{T \in [n]^{S_0}}\mathbb{E}(\sch{{\mat{M}}_{\tau, T}}{2})^t
\end{align*}
where we bounded the Schatten norm by a power of the Frobenius norm.
Fix $T \in [n]^{S_0}$ and consider $\Esch{{\mat{M}}_{\tau, T}}{2}$. Let ${\mathcal{R}}$ be the set of realizations $\varphi$ of $\tau$ such that $\varphi(S_0) = T$. Then, for $\varphi \in {\mathcal{R}}$ and $e \in E(S_0)$, the value of $\varphi(e)$ is fixed. Using this,
\begin{align*}
\norm{{\mat{M}}_{\tau, T}}_2^2 &= \sum_{\varphi \in {\mathcal{R}}} \prod_{e \in E(\tau)} G_{\varphi(e)}^2\\
&= \prod_{e \in E(S_0)} G_{\varphi(e)}^2 \sum_{\varphi \in {\mathcal{R}}} \prod_{e \in E(\tau) \setminus E(S_0)} G_{\varphi(e)}^2\\
&\le L^{|E(S_0)|} \sum_{\varphi \in {\mathcal{R}}} \prod_{e \in E(\tau) \setminus E(S_0)} G_{\varphi(e)}^2
\end{align*}
where $L = \frac{1 - p}{p}$ is an upper bound on $G_{ij}^2$ for $p \le \frac{1}{2}$. Define the quantity
\[A = \max_{S_0 \subseteq S \subseteq V(\tau)}L^{|E(S)|}n^{|V(\tau)| - |S|}\]
\begin{claim}\label{claim: lil_claim}
$\mathbb{E}(\norm{{\mat{M}}_{\tau, T}}_2)^t \le (Ct)^{t|E(\tau)|} |V(\tau)|^{t|V(\tau)|}A^t$ for an absolute constant $C > 0$.
\end{claim}
Using this claim, we have
\begin{align*}
\Esch{{\mat{M}}_{\tau}}{2t} &\le \sum_{T \in [n]^{S_0}} \mathbb{E}(\norm{{\mat{M}}_{\tau, T}}_2)^t\\
&\le n^{|S_0|}(Ct)^{t|E(\tau)|} |V(\tau)|^{t|V(\tau)|}A^t\\
&= n^{|V(\tau)|} (Ct)^{t|E(\tau)|} |V(\tau)|^{t|V(\tau)|}\max_{U_{\tau} \cap V_{\tau} \subseteq S \subseteq V(\tau)}\left(\frac{1 - p}{p}\right)^{t|E(S)|}n^{t(|V(\tau)| - |S|)}
\end{align*}
as required.
\end{proof}
It remains to prove the claim.
\begin{proof}[Proof of \cref{claim: lil_claim}]
For $1\le i, j \le n$, define the variables $Y_{ij} = G_{ij}^2$ with $\mathbb{E}[|Y_{ij}|] = 1$. Let $f(Y)$ be the polynomial $L^{|E(S_0)|} \sum_{\varphi \in {\mathcal{R}}} \prod_{e \in E(\tau) \setminus E(S_0)} Y_{\varphi(e)}$. It suffices to prove that $\mathbb{E}[f(Y)^t] \le (Ct)^{t|E_1|}A^t$.
We will first prove that $\mathbb{E}[(f(Y) - \mathbb{E}[f(Y)])^t] \le (C't)^{t|E(\tau)|}|V(\tau)|^{t|V(\tau)|}A^t$ for a sufficiently large constant $C' > 0$.
$f$ is a homogeneous multilinear polynomial of degree $|E(\tau) \setminus E(S_0)|$. If we had $E(\tau) \setminus E(S_0) = \emptyset$, then $f$ is a constant and so, the inequality is obvious because $f(Y) = \mathbb{E}[f(Y)]$. Now, assume $E(\tau) \setminus E(S_0) \neq \emptyset$. We invoke \cref{lem: schudy_sviridenko}. Let $f$ have associated hypergraph $H$ and weights $w$. Then,
{\footnotesize
\[\mathbb{E}[|f(Y) - \mathbb{E} [f(Y)]|^t] \le \max\bigg\{\bigg(\sqrt{tR_4^{|E(\tau) \setminus E(S_0)|}\var{f(Y)}}\bigg)^t, \max_{r \in [|E(\tau) \setminus E(S_0)|]}(t^rR_4^{|E(\tau) \setminus E(S_0)|}L^r\mu_r(f, Y))^t\bigg\}\]
}
For all $r \ge 0$, we will prove that $L^r\mu_r(f, Y) \le |V(\tau)|^{|V(\tau)|}A$. By definition,
\begin{align*}
\mu_r(f, Y) &= \max_{F \subseteq \binom{[n]}{2}, |F| = r} \sum_{h \in E(H), F \subseteq V(h)} |w_h|
\end{align*}
Consider any set of edge labels $F \subseteq \binom{[n]}{2}, |F| = r$.
Then, $\sum_{h \in E(H), F \subseteq V(h)} |w_h|$ is at most $L^{|E(S_0)|}c$ where $c$ is the number of realizations $\varphi \in {\mathcal{R}}$ such that $\varphi(E(\tau))$ contains $F$.
Suppose $F$ contains $v$ new labels apart from $\varphi(S_0) = T$.
Then $c \le |V(\tau)|^v n^{|V(\tau)| - |S_0| - v}$ because we can first choose and label the set of vertices that get these $v$ labels and then label the remaining vertices freely, each of which has at most $n$ choices.
Observe that $L^{|E(S_0)|} L^r n^{|V(\tau)| - |S_0| - v} \le A$ because in the definition of $S$, we can set $S$ to be the union of $S$ and any valid choice of these $v$ vertices. Putting this together, we get
\begin{align*}
L^r\mu_r(f, Y) &\le L^r\max_{F \subseteq \binom{[n]}{2}, |F| = r} \sum_{h \in E(H), F \subseteq V(h)} |w_h|\\
&\le |V(\tau)|^{|V(\tau)|} A
\end{align*}
which implies
\[\max_{r \in [|E(\tau) \setminus E(S_0)|]}(t^rR_4^{|E(\tau) \setminus E(S_0)|}L^r\mu_r(f, Y))^t \le |V(\tau)|^{t|V(\tau)|}(R_4t)^{t|E(\tau)|}A^t\]
and using \cref{lem: var_bound},
\begin{align*}
\var{f(Y)} &\le 2|E(\tau)|4^{|E(\tau)|}\max_{r \in [|E(\tau) \setminus E(S_0)|]} (\mu_0(f, Y) \mu_r(f, Y)4^rL^r)\\
&\le 2|E(\tau)|16^{|E(\tau)|} |V(\tau)|^{2|V(\tau)|}A^2
\end{align*}
Putting them together, we get
{\footnotesize
\begin{align*}
\mathbb{E}[(f(Y) - \mathbb{E}[f(Y)])^t] &\le \max\bigg\{\bigg(\sqrt{2tR_4^{|E(\tau)|}|E(\tau)|16^{|E(\tau)|} |V(\tau)|^{2|V(\tau)|}A^2}\bigg)^t, |V(\tau)|^{t|V(\tau)|}(R_4t)^{t|E(\tau)|}A^t\bigg\}\\
&\le (C't)^{t|E(\tau)|}|V(\tau)|^{t|V(\tau)|}A^t
\end{align*}
}
for an absolute constant $C' > 0$.
Finally, $\mathbb{E}[f(Y)] \le L^{|E(S_0)|} |{\mathcal{R}}| \le L^{|E(S_0)|}n^{|V(\tau) \setminus S_0|} \le A$ which gives
\begin{align*}
\mathbb{E}[f(Y)^t] &\le 2^t(\mathbb{E}[(f(Y) - \mathbb{E}[f(Y)])^t] + \mathbb{E}[f(Y)]^t)\\
&\le 2^t((C't)^{t|E(\tau)|}|V(\tau)|^{t|V(\tau)|}A^t + A^t)\\
&\le (Ct)^{t|E(\tau)|}|V(\tau)|^{t|V(\tau)|}A^t
\end{align*}
for an absolute constant $C > 0$.
\end{proof}
\subsubsection{Definitions}
Define by ${\mathcal{G}}_{n, p}$ the Erd\H{o}s\xspace-R\'enyi\xspace random graph on the vertex set $[n]$ with $n$ vertices, where each edge is present independently with probability $p$. Let the graph be encoded by variables $G_{i, j} \in \Omega = \{-\sqrt{\frac{1 - p}{p}}, \sqrt{\frac{p}{1 - p}}\}$ where $-\sqrt{\frac{1 - p}{p}}$ indicates the presence of the edge $\{i, j\}$ and $\sqrt{\frac{p}{1 - p}}$ indicates absence, for all $1 \le i, j \le n$.
So, each $G_{i, j}$ for $i < j$ is sampled from $\Omega$ where $G_{i, j}$ takes the value $-\sqrt{\frac{1 - p}{p}}$ with probability $p$ and takes the value $\sqrt{\frac{p}{1 - p}}$ otherwise. Here, $\Omega$ has been normalized so that $\mathbb{E}_{x \sim \Omega}[x] = 0, \mathbb{E}_{x \sim \Omega}[x^2] = 1$. as is standard in $p$-biased Fourier analysis.
When $p = \nicefrac{1}{2}$, we are in the setting of \textit{dense graph matrices}. Then, ${\mathcal{G}}_{n, 1/2}$ can be thought of as a sampling of the $G_{i, j}, i < j$ independently and uniformly from $\Omega = \{-1, 1\}$.
For a set of edges $E \subseteq \binom{[n]}{2}$, define $G_E := \prod_{e \in E} G_e$. When $p = \nicefrac{1}{2}$, the $G_E$ correspond to the Fourier basis for functions of the graph.
Define ${\mathcal{I}}$ to be the set of sub-tuples of $[n]$, including the empty tuple. Graph matrices will have rows and columns indexed by ${\mathcal{I}}$. Each graph matrix has a succinct representation as a graph with some extra information, that is called a \textit{shape}.
\begin{definition}[Shape]
A shape is a tuple $\tau = (V(\tau), E(\tau), U_{\tau}, V_{\tau})$ where $(V(\tau), E(\tau))$ is a graph and $U_{\tau}, V_{\tau}$ are ordered subsets of the vertices.
\end{definition}
\begin{definition}[Realization]
Given a shape $\tau$, a realization of $\tau$ is an injective map $\varphi: V(\tau) \rightarrow [n].$
\end{definition}
\begin{definition}[Graph matrices]
Let $\tau$ be a shape.
Corresponding to $\tau$, the graph matrix $\graphmat{\tau} : \{ \pm 1\}^{n \choose 2} \rightarrow {\mathbb R}^{{\mathcal{I}}\times {\mathcal{I}}}$ is defined to be the matrix-valued function with $I, J$-th entry defined as follows.
\[
{\mat{M}}_{\tau}[I, J] := \sum_{\substack{\text{Realization }\varphi\\ \varphi(U_{\tau}) = I, \varphi(V_{\tau}) = J}}{G_{\varphi(E(\tau))}} = \sum_{\substack{\text{Realization }\varphi\\ \varphi(U_{\tau}) = I, \varphi(V_{\tau}) = J}}\prod_{(u, v) \in E(\tau)} G_{\varphi(u), \varphi(v)}
\]
In other words, we sum over all realizations of $\tau$ that map $U_{\tau}, V_{\tau}$ to $I, J$ respectively and for each such realization, we have a term corresponding to the Fourier character that the realization gives.
\end{definition}
\begin{figure}[!h]
\centering
\includegraphics[trim={3cm 21cm 3cm 1cm}, clip, scale=1]{efron-stein-sos/images/2shapes.pdf}
\caption{Left: Shape corresponding to adjacency matrix, Right: Example of a more complicated shape}
\label{fig: shape}
\end{figure}
The following examples illustrate some simple graph matrices.
\begin{example}[Adjacency matrix]
Let $\tau$ be the shape on the left in \cref{fig: shape}, with two vertices $V(\tau) = \{u,v\}$ and a single edge $E(\tau) = \{\{ u,v\}\}$. $U_\tau, V_\tau$ are $(u), (v)$ respectively where we use tuples to indicate ordering.
Then ${\mat{M}}_\tau$ has nonzero entries ${\mat{M}}_\tau[(i), (j)](G) = G_{i, j}$ for all $i \neq j$.
If $G \in \{ \pm 1\}^{n \choose 2}$ is thought of as a graph, then ${\mat{M}}_\tau$ has as principal submatrix the $\pm 1$ adjacency matrix of $G$ with zeros on the diagonal, and the other entries are $0$.
\end{example}
\begin{example}
In \cref{fig: shape}, consider the shape $\tau$ on the right. We have $U_{\tau} = (u_1, u_2), V_{\tau} = (v_1), V(\tau) = \{u_1, u_2, v_1, w_1\}$ and $E(\tau) = \{\{u_1, w_1\}, \{u_2, w_1\}, \{w_1, v_1\}\}$. ${\mat{M}}_{\tau}$ is a matrix with rows and columns indexed by sub-tuples of $[n]$. Its nonzero entries are in rows $I$ and columns $J$ with $|I| = |U_{\tau}| = 2$ and $|J| = |V_{\tau}| = 1$ respectively. More specifically, for all distinct $a_1, a_2, b_1$, the entry corresponding to row $(a_1, a_2)$ and column $(b_1)$ is $\sum_{c_1 \in [n] \setminus \{a_1, a_2, b_1\}} G_{a_1, c_1}G_{a_2, c_1}G_{c_1, b_1}$.
Here, each term is obtained via the realization $\varphi$ that maps $u_1, u_2, w_1, v_1$ to $a_1, a_2, c_1, b_1$ respectively. Succinctly, \[{\mat{M}}_{\tau} =
\begin{blockarray}{rl@{}c@{}r}
& & \makebox[0pt]{column $(b_1)$} \\[-0.5ex]
& & \,\downarrow \\[-0.5ex]
\begin{block}{r(l@{}c@{}r)}
& & \vdots & \\[-0.2ex]
\text{row }(a_1, a_2) \rightarrow \mkern-9mu & \raisebox{0.5ex}{\makebox[3.2em][l]{\dotfill}} & \sum_{c_1 \in [n] \setminus \{a_1, a_2, b_1\}} G_{a_1, c_1}G_{a_2, c_1}G_{c_1, b_1} & \raisebox{0.5ex}{\makebox[4.2em][r]{\dotfill}} \\[+.5ex]
& & \vdots & \\
\end{block}
\end{blockarray}\]
\end{example}
Intuitively, graph matrices are symmetrizations of the Fourier basis, where the symmetry is incorporated by summing over all realizations of ``free'' vertices $V(\tau) \setminus U_{\tau} \setminus V_{\tau}$ of the shape $\tau$.
For more examples of graph matrices and why they can be a useful tool to work with, see \cite{ahn2016graph}.
\subsubsection{Norm bounds for dense graph matrices}\label{sec: norm_bounds_for_dense_graph_matrices}
In this section, we study the concentration of the so-called ``dense graph matrices'' which is a term that refers to graph matrices $M_{\tau}$ in the setting $p = \nicefrac{1}{2}$.
Since the edges of a random graph sampled from ${\mathcal{G}}_{n,1/2}$ can be viewed as independent Rademacher random variables, we can apply our framework in this setting.
In particular, we will obtain bounds on $\Esch{{\mat{M}}_{\tau} - \mathbb{E}{\mat{M}}_{\tau}}{2t}$.
The $G_{i, j} \in \{-1, 1\}$ correspond to the $Z_i$s in \cref{sec: basic_recursion} and for a fixed shape $\tau$, ${\mat{M}}_{\tau}$ will be the matrix ${\mat{F}}$ we are interested in analyzing. For $I, J \in {\mathcal{I}}$, ${\mat{M}}_{\tau}[I, J]$ is a nonzero polynomial only when there exists at least one realization of $\tau$ that maps $U_{\tau}, V_{\tau}$ to $I, J$ respectively. In particular, we must have $|I| = |U_{\tau}|$ and $|J| = |V_{\tau}|$. In this case, ${\mat{M}}_{\tau}[I, J]$ is a homogenous polynomial of degree $|E(\tau)|$.
By \cref{thm: main_rademacher}, we have
\[\Esch{{\mat{M}}_{\tau} - \mathbb{E}{\mat{M}}_{\tau}}{2t} ~\le~ \sum_{a + b \ge 1\atop a, b \ge 0}(16t|E(\tau)|)^{(a + b)t}\sch{\mathbb{E}{\mat{M}}_{\tau, a, b}}{2t}\]
where for integers $a, b \ge 0$, ${\mat{M}}_{\tau, a, b}$ is defined to be the matrix with rows and columns each indexed by ${\mathcal{I}} \times \{0, 1\}^{\binom{n}{2}}$ such that for all $I, J \in {\mathcal{I}}$, we have
\[{\mat{M}}_{\tau, a, b}[(I, \alpha), (J, \beta)] ~=~ \begin{dcases}
\nabla_{\alpha + \beta} {\mat{M}}_{\tau}[I, J] & \text{ if $|\alpha|_0 = a, |\beta|_0 = b, \alpha \cdot \beta = 0$}\\
0 & \text{o.w.}
\end{dcases}
\]
For any multilinear homogenous polynomial $f$ of degree $d$, since $\mathbb{E}[G_{i, j}] = 0$ for all $i, j$, we have $\nabla_{\alpha}f = 0$ whenever $|\alpha|_0 < d$. Therefore, $\mathbb{E}{\mat{M}}_{\tau, a, b} = 0$ for all $a + b < |E(G)|$. Moreover, $\mathbb{E}{\mat{M}}_{\tau, a, b} = 0$ whenever $a + b \neq |E(G)|$ otherwise $\mathbb{E}{\mat{M}}_{\tau, a, b} = {\mat{M}}_{\tau, a, b}$. So, we can further simplify the above expression to
\[\Esch{{\mat{M}}_{\tau} - \mathbb{E}{\mat{M}}_{\tau}}{2t} ~\le~ \sum_{a + b = |E(\tau)|\atop a, b \ge 0}(16t|E(\tau)|)^{|E(\tau)|t}\sch{{\mat{M}}_{\tau, a, b}}{2t}\]
It remains to analyze $\sch{{\mat{M}}_{\tau, a, b}}{2t}$ for $a + b = |E(G)|$. We will see that analyzing these matrices is much simpler since they are deterministic matrices and simple computations using the Frobenius norm bound will work well. To state our final bounds, we need to define the notion of vertex separators of shapes.
\begin{remark}
As we will see, when analyzing the Frobenius norms for these deterministic matrices, the notion of the minimum vertex separator arises naturally. In prior trace method calculations (e.g. \cite{medarametla2016bounds}, \cite{ahn2016graph}), this required ingenious combinatorial observations.
\end{remark}
\begin{restatable}[Vertex separator]{definition}{vertexseparator}
For a shape $\tau$, define a vertex separator to be a subset of vertices $S \subseteq V(\tau)$ such that there is no path from $U_{\tau}$ to $V_{\tau}$ in $\tau \setminus S$, which is the shape obtained by deleting all the vertices of $S$ (including all edges they're incident on).
\end{restatable}
For a shape $\tau$, denote by $S_{\tau}$ a vertex separator of the smallest size. Also, let $I_{\tau}$ be the set of isolated vertices (vertices with degree $0$) in $V(\tau) \setminus U_{\tau} \setminus V_{\tau}$, so the presence of these vertices essentially scale the matrix by a scalar factor.
\begin{theorem}\label{thm: dense_graph_matrix_norm_bounds}
For a shape $\tau$ and any integer $t \ge 1$,
\[\mathbb{E}\sch{{\mat{M}}_{\tau} - \mathbb{E} {\mat{M}}_{\tau}}{2t} \le \bigg(C^{t|E(\tau)|}n^{|V(\tau)|} t^{t|E(\tau)|}|E(\tau)|^{2t|E(\tau)|}\bigg)n^{t(|V(\tau)| - |S_{\tau}| + |I_{\tau}|)}\]
for an absolute constant $C > 0$.
\end{theorem}
Up to lower order terms, the same result has been shown before in \cite{medarametla2016bounds, ahn2016graph}. To interpret this bound, assume that $\tau$ has a constant number of vertices. By setting $t \approx {\mathrm{polylog}}(n)$, we get \[\norm{{\mat{M}}_{\tau}} = \widetilde{\operatorname{O}}\left(\sqrt{n}^{|V(\tau)| - |S_{\tau}| + |I_{\tau}|}\right)\] with high probability, where $\widetilde{\operatorname{O}}$ hides logarithmic factors.
This is obtained by applying Markov's inequality on the bound on $\Esch{{\mat{M}}_{\tau}}{2t}$. If $\tau$ has at least one edge, then $\mathbb{E} {\mat{M}}_{\tau} = 0$ and \cref{thm: dense_graph_matrix_norm_bounds} yields such bounds. If $\tau$ has no edges, then it's quite simple to obtain such a bound and we include it in \cref{lem: empty_shape} for the sake of completeness. \cref{cor: dense_graph_matrix_norm_bounds} makes precise the high probability bound above. Therefore, this power of $n$ is essentially what controls the norm bound and this is utilized heavily in applications (e.g. \cite{BHKKMP16, ghosh2020sum, potechin2020machinery}).
\begin{proof}[Proof of \cref{thm: dense_graph_matrix_norm_bounds}]
We first argue that we can assume $I_{\tau} = \emptyset$. This is because of the following reason. Each distinct vertex in $\tau$ of degree $0$ essentially scales the matrix by a factor of at most $n$. And in the right hand side of the inequality, each vertex in $I_{\tau}$ contributes a factor of $n^{2t}$ accordingly, from $n^{t|V(\tau)|}$ and from $n^{t|I_{\tau}|}$, and the other changes only weaken the inequality.
Now, fix $a, b \ge 0$ such that $a + b = |E(\tau)|$ and consider ${\mat{M}}_{\tau, a, b}$. For $I, J \in {\mathcal{I}}, \alpha, \beta \in \{0, 1\}^{\binom{n}{2}}$ such that $|\alpha|_0 = a, |\beta|_0 = b, \alpha \cdot \beta = 0$, by definition,
\begin{align*}
{\mat{M}}_{\tau, a, b}[(I, \alpha), (J, \beta)] &~=~ \nabla_{\alpha + \beta} \left(\sum_{\varphi: \varphi(U_{\tau}) = I, \varphi(V_{\tau})= J} \prod_{u, v \in E(\tau)} G_{\varphi(u), \varphi(v)}\right)\\
&~=~ |\{\varphi ~|~ \varphi(U_{\tau}) = I, \varphi(V_{\tau})= J, \varphi(E(\tau)) = \supp(\alpha + \beta)\}|
\end{align*}
where $\supp(.)$ denotes the support. We will now obtain norm bounds on these deterministic matrices by reinterpreting them as graph matrices for different shapes.
Let $P = (E_1, E_2)$ denote the partition of $E(\tau) = E_1 \sqcup E_2$ into two ordered sets $E_1, E_2$, where $\sqcup$ denotes disjoint union. Then, we can write ${\mat{M}}_{\tau, a, b} = \sum_{P \in {\mathcal{P}}} {\mat{M}}_{\tau, a, b, P}$ where
\[{\mat{M}}_{\tau, a, b, P}[(I, \alpha), (J, \beta)] ~=~ |\{\varphi ~|~ \varphi(U_{\tau}) = I, \varphi(V_{\tau})= J, \varphi(E_1) = \supp(\alpha), \varphi(E_2) = \supp(\beta)\}|\]
Let the set of ordered partitions $P$ be ${\mathcal{P}}$. Then, $|{\mathcal{P}}| \le (4|E(\tau)|)^{|E(\tau)|}$ and so, by \cref{fact: holder},
\[\sch{{\mat{M}}_{\tau, a, b}}{2t} \le (4|E(\tau)|)^{t|E(\tau)|} \sum_{P \in {\mathcal{P}}}\sch{{\mat{M}}_{\tau, a, b, P}}{2t}\]
Each ${\mat{M}}_{\tau, a, b, P}$ can be interpreted as a graph matrix for a different shape $\tau_P$, with the same vertex set and no edges. Let $V(\tau_P) = V(\tau), E(\tau_P) = \emptyset$ and set $U_{\tau_P} = U_{\tau} \cup V(E_1), V(\tau_P) = V_{\tau} \cup V(E_2)$ using a canonical ordering. Then, ${\mat{M}}_{\tau, a, b}$ is equal to ${\mat{M}}_{\tau_P}$ up to renaming of the rows and columns. For an illustration, see \cref{fig: evolution_new}.
\begin{figure}[!h]
\centering
\includegraphics[trim={2cm 20cm 2cm 2cm}, clip, scale=0.9]{efron-stein-sos/images/evolution_new.pdf}
\caption{An example illustrating how $\tau_P$ is defined. In this example, $P$ constraints the blue and red edges to go to $\alpha$ and $\beta$ respectively. $U_{\tau_P}, V_{\tau_P}$ have an ordering on the vertices (not shown here).}
\label{fig: evolution_new}
\end{figure}
This graph matrix has a block diagonal structure indexed by the realizations of the set of common vertices $S = U_{\tau_P} \cap V_{\tau_P}$. Indeed, for $K \in [n]^S$, let ${\mat{M}}_{\tau_P, K}$ be the block of ${\mat{M}}_{\tau_P}$ with $\varphi(S) = K$. Then, ${\mat{M}}_{\tau_P, K}{\mat{M}}_{\tau_P, K'}^\intercal = {\mat{M}}_{\tau_P, K}^\intercal{\mat{M}}_{\tau_P, K'} = 0$ for $K \neq K'$ and so,
\begin{align*}
\Esch{{\mat{M}}_{\tau, a, b}}{2t} &\le (4|E(\tau)|)^{t|E(\tau)|} \sum_{P \in {\mathcal{P}}}\sch{{\mat{M}}_{\tau_P}}{2t}\\
&= (4|E(\tau)|)^{t|E(\tau)|} \sum_{P \in {\mathcal{P}}} \sum_{T \in [n]^S}\sch{{\mat{M}}_{\tau_P, T}}{2t}\\
&\le (4|E(\tau)|)^{t|E(\tau)|} \sum_{P \in {\mathcal{P}}} \sum_{T \in [n]^S}\left(\sch{{\mat{M}}_{\tau_P, T}}{2}\right)^t
\end{align*}
where we bounded the Schatten norm by the appropriate power of the Frobenius norm.
For any fixed $K \in [n]^S$, the entries of ${\mat{M}}_{\tau_P, K}$ take values in $\{0, 1\}$ and the number of nonzero entries is at most $n^{|V(\tau)| - |S|}$ because the realizations of vertices in $S$ are fixed and the other vertices have at most $n$ choices each. Therefore, $\sch{{\mat{M}}_{\tau_P, K}}{2} \le n^{|V(\tau)| - |S|}$.
Finally, we bound $|S|$ to estimate how large this term can be over all possibilities of $P$.
We argue that $S$ blocks all paths from $U_{\tau}$ to $V_{\tau}$. To see this, consider any path from $U_{\tau}$ to $V_{\tau}$, it must contain an edge $(u, v) \in E(\tau)$ such that $u \in U_{\tau_P}, v \in V_{\tau_P}$. We must either have $(u, v) \in E_1$, in which case $u, v \in U_{\tau_P}$ and $v \in S$, or $(u, v) \in E_2$, in which case $u, v \in V_{\tau_P}$ and $u \in S$. In either case, $S$ must contain either $u$ or $v$. This argument implies $S$ must be a vertex separator of $\tau$, giving $|S| \ge |S_{\tau}|$.
For a proof by picture, see \cref{fig: proof_by_picture}.
\begin{figure}[!h]
\centering
\includegraphics[trim={2cm 20cm 2cm 2cm}, clip, scale=0.9]{efron-stein-sos/images/proof_by_picture.pdf}
\caption{Proof by picture that $|S| \ge |S_{\tau}|$. Green edges can occur in $\tau$, orange edges cannot, so $S$ blocks all paths from $U_{\tau}$ to $V_{\tau}$.}
\label{fig: proof_by_picture}
\end{figure}
We also have the trivial upper bound $|S| \le |V(\tau)|$. Ultimately, this gives
\begin{align*}
\sch{{\mat{M}}_{\tau, a, b}}{2t} &\le (4|E(\tau)|)^{t|E(\tau)|} \sum_{P \in {\mathcal{P}}} \sum_{T \in [n]^S}n^{t(|V(\tau)| - |S_{\tau}|)}\\
&\le (4|E(\tau)|)^{t|E(\tau)|}(4|E(\tau)|)^{|E(\tau)|}n^{|V(\tau)|}n^{t(|V(\tau)| - |S_{\tau}|)}
\end{align*}
Along with our prior discussion, we get
{\footnotesize
\begin{align*}
\Esch{{\mat{M}}_{\tau} - \mathbb{E}{\mat{M}}_{\tau}}{2t} &\le \sum_{a + b = |E(\tau)|}(16t|E(\tau)|)^{|E(\tau)|t}\sch{{\mat{M}}_{\tau, a, b}}{2t}\\
&\le \sum_{a + b = |E(\tau)|}(16t|E(\tau)|)^{|E(\tau)|t}(4|E(\tau)|)^{t|E(\tau)|}(4|E(\tau)|)^{|E(\tau)|}n^{|V(\tau)|}n^{t(|V(\tau)| - |S_{\tau}|)}\\
&\le \bigg(C^{t|E(\tau)|}n^{|V(\tau)|} t^{t|E(\tau)|}|E(\tau)|^{2t|E(\tau)|}\bigg)n^{t(|V(\tau)| - |S_{\tau}|)}
\end{align*}}
for an absolute constant $C > 0$.
\end{proof}
In the proof above, our analysis of the shape $\tau_P$ which has no edges, applies in general to any shape $\tau$ with no edges. For the sake of completeness, we state it explicity in the following lemma.
\begin{lemma}\label{lem: empty_shape}
For a shape $\tau$ with no edges and any integer $t \ge 1$,
\[\Esch{{\mat{M}}_{\tau}}{2t} \le n^{|U_{\tau} \cap V_{\tau}|}n^{t(V(\tau) - |U_{\tau} \cap V_{\tau}| + |I_{\tau}|)}\]
\end{lemma}
Note that this has the same form as \cref{thm: dense_graph_matrix_norm_bounds} because for a shape $\tau$ with no edges, the minimum vertex separator $S_{\tau}$ is just $U_{\tau} \cap V_{\tau}$.
The following corollary obtains high probability norm bounds for norms of graph matrices via Markov's inequality.
\begin{corollary}\label{cor: dense_graph_matrix_norm_bounds}
For a shape $\tau$, for any constant $\varepsilon > 0$, with probability $1 - \varepsilon$,
\[\norm{{\mat{M}}_{\tau}} \le (C|E(\tau)| \log(n^{|V(\tau)|}/\varepsilon))^{|E(\tau)|}\cdot\sqrt{n}^{|V(\tau)| - |S_{\tau}| + |I_{\tau}|}\]
for an absolute constant $C > 0$.
\end{corollary}
\begin{proof}
If $E(\tau) = \emptyset$, we invoke \cref{lem: empty_shape}. Otherwise, $\mathbb{E}{\mat{M}}_{\tau} = 0$ and we invoke \cref{thm: dense_graph_matrix_norm_bounds}. By an application of Markov's inequality,
\begin{align*}
Pr[\norm{{\mat{M}}_{\tau}} \ge \theta] &\le Pr[\sch{{\mat{M}}_{\tau}}{2t} \ge \theta^{2t}]\\
&\le \theta^{-2t} \mathbb{E}\sch{{\mat{M}}_{\tau}}{2t}\\
&\le \theta^{-2t}\bigg((C')^{t|E(\tau)|}n^{|V(\tau)|} t^{t|E(\tau)|}|E(\tau)|^{2t|E(\tau)|}\bigg)n^{t(|V(\tau)| - |S_{\tau}| + |I_{\tau}|)}
\end{align*}
for an absolute constant $C' > 0$. We now set
\[\theta = \bigg(\varepsilon^{-1/(2t)} (C'')^{|E(\tau)|} n^{|V(\tau)|/(2t)} t^{|E(\tau)|/2}|E(\tau)|^{|E(\tau)|}\bigg)\sqrt{n}^{|V(\tau)| - |S_{\tau}| + |I_{\tau}|}\] for an absolute constant $C'' > 0$, to make this expression at most $\varepsilon$. Set $t = \frac{1}{2} \log(n^{|V(\tau)|}/\varepsilon)$ to complete the proof.
\end{proof}
\section{Introduction}\label{sec: intro}
\input{intro}
\section{Preliminaries}\label{sec: prelims}
\input{prelims}
\section{The basic framework for Rademacher random variables} \label{sec: basic_recursion}
\input{rademacher_recursion}
\section{Applications}\label{sec:rademacher-applications}
To illustrate our framework, we apply it to obtain concentration bounds for nonlinear random matrices that have been considered in the literature before. The first one is a simple tensor network that arose in the analysis of spectral algorithms for a variant of principal components analysis (PCA) \cite{hopkins2015tensor, hopkins2018statistical}.
The second application is to obtain norm bounds on dense graph matrices \cite{medarametla2016bounds, ahn2016graph}. In the second application, the norm bounds are governed by a combinatorial structure called \textit{the minimum vertex separator of a shape}. We will see how this notion arises naturally under our framework, while prior works that derived such bounds used the trace power method and required nontrivial combinatorial insights.
\subsection{A simple tensor network}
\input{tensor_network_norm_bound}
\subsection{Graph matrices}\label{sec: dense_graph_matrices}
\input{dense_graph_matrices}
\section{Why a na\"ive application of \cite{paulin2016} may fail for general product distributions} \label{sec: failure_of_basic}
\input{failure_of_basic}
\section{The general recursion framework}\label{sec: general_recursion}
\input{general_recursion}
\section{A generalization of \cite{paulin2016} and proof of \cref{lem: main_general}}\label{sec: proof_of_general}
\input{proof_of_general}
\section{Application: Sparse graph matrices} \label{sec: sparse_graph_matrices}
\input{sparse_graph_matrices}
\bibliographystyle{alpha}
\subsection{Generalizing \cite{paulin2016} via explicit inner kernels}\label{sec: explicit_inner_kernels}
In our setting, observe that $(Z, Z')$ has the same distribution as $(Z', Z)$. This is what is known as an \textit{exchangeable pair} of variables, that will be extremely useful for our analysis. In particular, $Z, Z'$ have the same distribution and $\mathbb{E} f(Z, Z') = \mathbb{E} f(Z', Z)$ for every integrable function $f$.
\begin{definition}[Laplacian operator ${\mathcal{L}}$]
Define the operator ${\mathcal{L}}$ on the space ${\mathcal{S}}$ as
\[{\mathcal{L}}(f)(Z) = \mathbb{E}[f(Z) - f(Z') | Z]\]
for all polynomials $f \in {\mathcal{S}}$.
\end{definition}
Note that this operator is well-defined since for any $f \in {\mathcal{S}}$, $\mathbb{E}[L(f)] = \mathbb{E}[\mathbb{E}[f(Z) - f(Z') | Z]] = \mathbb{E}[f(Z) - f(Z')] = 0$ and hence, $L(f) \in {\mathcal{S}}$.
\begin{lemma}\label{lem: eigenvector}
For all $\alpha \in \mathbb{N}^n$, $\chi_{\alpha}$ is an eigenvector of ${\mathcal{L}}$ with eigenvalue $\frac{|\alpha|_0}{n}$.
\end{lemma}
\begin{proof}
Recall that $Z'$ is obtained by choosing $i \in [n]$ uniformly at random and then setting $Z' = Z^{(i)}$. Therefore,
\begin{align*}
{\mathcal{L}}(\chi_{\alpha})(Z) &= \mathbb{E}[\chi_{\alpha}(Z) - \chi_{\alpha}(Z') | Z]\\
&= \frac{1}{n}\sum_{i \le n} \mathbb{E}[\chi_{\alpha}(Z) - \chi_{\alpha}(Z^{(i)}) | Z]
\end{align*}
When $\alpha_i = 0$, $\chi_{\alpha}(Z) - \chi_{\alpha}(Z^{(i)}) = 0$. Otherwise, $\mathbb{E}[\chi_{\alpha}(Z) - \chi_{\alpha}(Z^{(i)})|Z] = \chi_{\alpha}(Z)$. Therefore, the above expression simplifies to $\frac{|\alpha|_0}{n} \chi_{\alpha}(Z)$.
\end{proof}
\begin{theorem}[Explicit Kernel]\label{thm: explicit_kernel_for_poly}
For any mean-centered polynomial $f \in {\mathcal{S}}$, there exists a polynomial $K_f$ on $2n$ variables $z_1, \ldots, z_n, z_1', \ldots, z_n'$, denoted collectively as $(z, z')$, with the following properties
\begin{enumerate}
\item $K_f(z', z) = -K_f(z, z')$
\item $\mathbb{E}[K_f(Z, Z') | Z] = f(Z)$ where $(Z, Z')$ is the exchangeable pair we consider above.
\end{enumerate}
\end{theorem}
\begin{proof}
Using \cref{propn: basis} and \cref{lem: eigenvector}, under the basis of polynomials $\chi_{\alpha}$, the operator ${\mathcal{L}}$ is a diagonal matrix with nonzero diagonal entries and therefore, ${\mathcal{L}}^{-1}$ exists and is explicitly given by
\[{\mathcal{L}}^{-1}(f)(Z) = \sum_{\alpha} \frac{n}{|\alpha|_0}\coef{f}{\alpha} \chi_{\alpha}(Z)\]
We then take $K_f(z, z') = {\mathcal{L}}^{-1}(f)(z) - {\mathcal{L}}^{-1}(f)(z')$. The first condition is obvious and for the second condition, we have
\[\mathbb{E}[K_f(Z, Z')|Z] = \mathbb{E}[{\mathcal{L}}^{-1}(f)(Z) - {\mathcal{L}}^{-1}(f)(Z') | Z] = {\mathcal{L}}({\mathcal{L}}^{-1}(f)) = f\]
\end{proof}
As seen in the proof of \cref{thm: explicit_kernel_for_poly}, ${\mathcal{L}}$ has a well-defined inverse ${\mathcal{L}}^{-1}$. We now define the matrix ${\mat{K}}_{k, a, b}$ that we call the \textit{inner kernel}.
\begin{definition}[The inner kernel matrix ${\mat{K}}_{k, a, b}$]
For integers $k \ge 1, a, b \ge 0$ such that $a + b < k$, define the matrix ${\mat{K}}_{k, a, b} \in {\mathbb R}[Z]^{{\mathcal{I}} \times {\mathcal{K}}} \times {\mathbb R}[Z]^{{\mathcal{J}} \times {\mathcal{K}}}$ taking $2n$ variables $(z, z') = (z_1, \ldots, z_n, z_1', \ldots, z_n')$ as input as follows
\[{\mat{K}}_{k, a, b}(z, z') = {\mathcal{L}}^{-1}({\mat{G}}_{k, a, b})(z) - {\mathcal{L}}^{-1}({\mat{G}}_{k, a, b})(z')\]
\end{definition}
In the rest of this section except where explicitly stated, fix integers $k \ge 1, a, b \ge 0$ such that $a + b < k$. Then, the inner kernel ${\mat{K}}_{k, a, b}$ is well-defined.
\begin{lemma}\label{lem: explicit_kernel_for_matrices}
${\mat{K}}_{k, a, b}(Z, Z') = \frac{n}{k - a - b}({\mat{G}}_{k, a, b}(Z) - {\mat{G}}_{k, a, b}(Z'))$
\end{lemma}
\begin{proof}
\begin{align*}
{\mat{K}}_{k, a, b}(Z, Z') &= {\mathcal{L}}^{-1}({\mat{G}}_{k, a, b})(Z) - {\mathcal{L}}^{-1}({\mat{G}}_{k, a, b})(Z')\\
&= \sum_{|\alpha|_0 = k - a - b} \coef{{\mat{G}}_{k, a, b}}{\alpha} ({\mathcal{L}}^{-1}(\chi_{\alpha})(Z) - {\mathcal{L}}^{-1}(\chi_{\alpha})(Z'))\\
&= \frac{n}{k - a - b}\sum_{|\alpha|_0 = k - a - b} \coef{{\mat{G}}_{k, a, b}}{\alpha} (\chi_{\alpha}(Z) - \chi_{\alpha}(Z'))\\
&= \frac{n}{k - a - b}({\mat{G}}_{k, a, b}(Z) - {\mat{G}}_{k, a, b}(Z'))
\end{align*}
\end{proof}
The following lemma postulates important properties of the the inner kernel, including how it interacts with ${\mat{D}}_1$ and ${\mat{D}}_2$.
\begin{lemma}\label{lem: props_of_exp_kernel_mat}
${\mat{K}}_{k, a, b}$ satisfies the following properties
\begin{enumerate}
\item ${\mat{K}}_{k, a, b}(z', z) = -{\mat{K}}_{k, a, b}(z, z')$
\item $\mathbb{E}[{\mat{K}}_{k, a, b}(Z, Z') | Z] = {\mat{G}}_{k, a, b}(Z)$
\item $({\mat{D}}_1(Z) - {\mat{D}}_1(Z')){\mat{K}}_{k, a, b}(Z, Z') = {\mat{K}}_{k, a, b}(Z, Z')({\mat{D}}_2(Z) - {\mat{D}}_2(Z')) = 0$.
\end{enumerate}
\end{lemma}
\begin{proof}
The first equality is obvious from the definition. For the second equality, note that $\mathbb{E}[{\mat{G}}_{k, a, b}] = 0$ and ${\mat{K}}_{k, a, b}$ is defined by replacing each entry $f$ of ${\mat{G}}_{k, a, b}$ by the kernel polynomial $K_f$ as exhibited in \cref{thm: explicit_kernel_for_poly}. Now, we prove the third equality.
Consider the matrix $({\mat{D}}_1(Z) - {\mat{D}}_1(Z')){\mat{K}}_{k, a, b}(Z, Z')$ whose $[(I, \alpha_1, \gamma_1), (J, \alpha_2, \gamma_2)]$ entry is given by
\[\frac{n}{k - a - b}\sqrt{\mathbb{E}[Z^{2\alpha_1\cdot (1 - \gamma_1)}]}(Z^{\alpha_1 \cdot \gamma_1} - (Z')^{\alpha_1\cdot \gamma_1})(\nabla_{\alpha_1 + \alpha_2}{\mat{X}}_k[I, J](Z) - \nabla_{\alpha_1 + \alpha_2}{\mat{X}}_k[I, J](Z'))\]
where we have used \cref{lem: explicit_kernel_for_matrices}.
We will argue that this term is identically $0$.
We must have $Z' = Z^{(i)}$ for some $i \le n$. If $(\alpha_1 \cdot \gamma_1)_i = 0$, then $Z^{\alpha_1 \cdot \gamma_1} = (Z')^{\alpha_1\cdot \gamma_1}$ and the above term is $0$.
Otherwise, $(\alpha_1 + \alpha_2)_i \neq 0$ and so $\nabla_{\alpha_1 +\alpha_2}$ on any polynomial $f$ will only contain the terms independent of $Z_i$, in which case $\nabla_{\alpha_1 + \alpha_2}{\mat{X}}_k[I, J](Z) = \nabla_{\alpha_1 + \alpha_2}{\mat{X}}_k[I, J](Z')$. In this case was well, the above term is $0$. The proof of the other equality is analogous.
\end{proof}
The reason we call ${\mat{K}}_{k, a, b}$ the inner kernel is because, as seen above, it serves as a kernel for the inner matrix ${\mat{G}}$ in the decomposition ${\mat{F}} = {\mat{D}}{\mat{G}}{\mat{D}}$.
Since we will need to work with Hermitian dilations, we define \[{\mat{D}} = \begin{bmatrix}
{\mat{D}}_1 & 0\\
0 & {\mat{D}}_2
\end{bmatrix}\]
We will use the following basic fact extensively in our manipulations.
\begin{fact}
For any matrix ${\mat{A}} \in {\mathbb R}[Z]^{{\mathcal{I}}\times {\mathcal{K}}} \times {\mathbb R}[Z]^{{\mathcal{J}}\times {\mathcal{K}}}$, ${\mat{D}} \herm{{\mat{A}}}{\mat{D}} = \herm{{\mat{D}}_1{\mat{A}}{\mat{D}}_2}$.
\end{fact}
\begin{proof}
We have
\begin{align*}
{\mat{D}} \herm{{\mat{A}}}{\mat{D}} =
\begin{bmatrix}
{\mat{D}}_1 & 0\\
0 & {\mat{D}}_2
\end{bmatrix}
\begin{bmatrix}
0 & {\mat{A}} \\
{\mat{A}}^\intercal & 0
\end{bmatrix}
\begin{bmatrix}
{\mat{D}}_1 & 0\\
0 & {\mat{D}}_2
\end{bmatrix}
&=
\begin{bmatrix}
0 & {\mat{D}}_1{\mat{A}}\\
{\mat{D}}_2{\mat{A}}^\intercal & 0
\end{bmatrix}
\begin{bmatrix}
{\mat{D}}_1 & 0\\
0 & {\mat{D}}_2
\end{bmatrix}\\
&=
\begin{bmatrix}
0 & {\mat{D}}_1{\mat{A}}{\mat{D}}_2\\
{\mat{D}}_2{\mat{A}}^\intercal{\mat{D}}_1 & 0
\end{bmatrix}\\
&= \herm{{\mat{D}}_1{\mat{A}}{\mat{D}}_2}
\end{align*}
\end{proof}
We start with a generalized version of a result from \cite{paulin2016}.
\begin{lemma}\label{lem: deviation_bound}
Let ${\mat{K}} = \herm{{\mat{K}}}_{k, a, b}$. For any symmetric matrix valued function ${\mat{R}}$ on the variables $Z$ of the same dimensions as ${\mat{K}}$, such that $\mathbb{E}\norm{{\mat{K}}(Z, Z'){\mat{R}}(Z)} < \infty$, we have
\[\mathbb{E}[\herm{{\mat{F}}}_{k, a, b}(Z){\mat{R}}(Z)] = \frac{1}{2}\mathbb{E}[{\mat{D}}(Z){\mat{K}}(Z, Z'){\mat{D}}(Z) ({\mat{R}}(Z) - {\mat{R}}(Z'))]\]
\end{lemma}
\begin{proof}
By \cref{lem: props_of_exp_kernel_mat}, we have
\begin{align*}
\mathbb{E}[\herm{{\mat{F}}}_{k, a, b}(Z){\mat{R}}(Z)] &= \mathbb{E}[{\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}(Z){\mat{D}}(Z) {\mat{R}}(Z)]\\
&= \mathbb{E}[{\mat{D}}(Z)\mathbb{E}[{\mat{K}}(Z, Z') | Z]{\mat{D}}(Z) {\mat{R}}(Z)]\\
&= \mathbb{E}[{\mat{D}}(Z){\mat{K}}(Z, Z'){\mat{D}}(Z) {\mat{R}}(Z)]
\end{align*}
where the first equality follow from condition $2$ of \cref{lem: props_of_exp_kernel_mat} and the second follows from the pull-through property of expectations. Continuing,
\begin{align*}
\mathbb{E}[\herm{{\mat{F}}}_{k, a, b}(Z){\mat{R}}(Z)] &= \mathbb{E}[{\mat{D}}(Z){\mat{K}}(Z, Z'){\mat{D}}(Z){\mat{R}}(Z)]\\
&= \mathbb{E}[{\mat{D}}(Z'){\mat{K}}(Z', Z){\mat{D}}(Z') {\mat{R}}(Z')]\\
&= -\mathbb{E}[{\mat{D}}(Z'){\mat{K}}(Z, Z'){\mat{D}}(Z') {\mat{R}}(Z')]\\
&= -\mathbb{E}[{\mat{D}}(Z){\mat{K}}(Z, Z'){\mat{D}}(Z') {\mat{R}}(Z')]\\
&= -\mathbb{E}[{\mat{D}}(Z){\mat{K}}(Z, Z'){\mat{D}}(Z) {\mat{R}}(Z')]
\end{align*}
Here, the second equality follows from the fact that $(Z, Z')$ has the same distribution as $(Z', Z)$, so we can exchange them. The third, fourth and fifth equalities follow from conditions $1, 3, 3$ of \cref{lem: props_of_exp_kernel_mat} respectively. Adding the two displays, we get the result.
\end{proof}
\begin{definition}[Matrices ${\mat{U}}_{k, a, b}, {\mat{V}}_{k, a, b}$]
We define the following matrices
\[{\mat{U}}_{k, a, b} = \mathbb{E}[(\herm{{\mat{F}}}_{k, a, b}(Z) - \herm{{\mat{F}}}_{k, a, b}(Z'))^2|Z]\]
\[{\mat{V}}_{k, a, b} = \mathbb{E}[({\mat{D}}(Z)\herm{{\mat{K}}}_{k, a, b}(Z, Z'){\mat{D}}(Z))^2|Z]\]
\end{definition}
The definition of ${\mat{U}}_{k, a, b}$ is essentially unchanged from \cite{paulin2016}, where it is called the \textit{conditional variance}. The definition of ${\mat{V}}_{k, a, b}$ is slightly different in our setting. This lets us exploit the specific product structure exhibited by $\herm{{\mat{F}}}_{k, a, b}$ and the special properties of the inner kernel from \cref{lem: props_of_exp_kernel_mat}.
We will now prove a lemma which is similar to a lemma shown in \cite{paulin2016}.
\begin{lemma}\label{lem: main_pmt_bound}
For any $s > 0$ and for any integer $t \ge 1$,
\begin{align*}
\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}
&\le \left(\frac{2t - 1}{4}\right)^t\Esch{s{\mat{U}}_{k, a, b} + s^{-1}{\mat{V}}_{k, a, b}}{t}
\end{align*}
\end{lemma}
To prove this, we will need the following inequality.
\begin{lemma}[Polynomial mean value trace inequality, \cite{paulin2016}]\label{lem: mean_value_trace_inequality}
For all matrices ${\mat{A}}, {\mat{B}}, {\mat{C}} \in \mathbb{H}^d$, all integers $q \ge 1$ and all $s > 0$,
\begin{align*}
\tr [{\mat{C}}({\mat{A}}^q - {\mat{B}}^q)]| \le \frac{q}{4} \tr[(s({\mat{A}} - {\mat{B}})^2 + s^{-1}{\mat{C}}^2)({\mat{A}}^{q - 1} + {\mat{B}}^{q - 1})]
\end{align*}
\end{lemma}
\begin{proof}[Proof of \cref{lem: main_pmt_bound}]
We start by invoking \cref{lem: deviation_bound} by setting ${\mat{R}}(Z) = \herm{{\mat{F}}}_{k, a, b}^{2t - 1}(Z)$.
\begin{align*}
\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t} &= \mathbb{E}\tr [\herm{{\mat{F}}}_{k, a, b}\cdot\herm{{\mat{F}}}_{k, a, b}^{2t - 1}]\\
&= \frac{1}{2}\mathbb{E}[{\mat{D}}(Z)\herm{{\mat{K}}}_{k, a, b}(Z, Z'){\mat{D}}(Z) (\herm{{\mat{F}}}_{k, a, b}^{2t - 1}(Z) - \herm{{\mat{F}}}_{k, a, b}^{2t - 1}(Z'))]
\end{align*}
Applying \cref{lem: mean_value_trace_inequality},
{\footnotesize
\begin{align*}
&\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}\\
&\le (\frac{2t - 1}{8})\mathbb{E}\tr[(s(\herm{{\mat{F}}}_{k, a, b}(Z) - \herm{{\mat{F}}}_{k, a, b}(Z'))^2 + s^{-1}({\mat{D}}(Z)\herm{{\mat{K}}}_{k, a, b}(Z, Z'){\mat{D}}(Z))^2)(\herm{{\mat{F}}}_{k, a, b}^{2t - 2}(Z) + \herm{{\mat{F}}}_{k, a, b}^{2t - 2}(Z'))]\\
&= (\frac{2t - 1}{4})\mathbb{E}\tr[(s(\herm{{\mat{F}}}_{k, a, b}(Z) - \herm{{\mat{F}}}_{k, a, b}(Z'))^2 + s^{-1}({\mat{D}}(Z)\herm{{\mat{K}}}_{k, a, b}(Z, Z'){\mat{D}}(Z))^2)\herm{{\mat{F}}}_{k, a, b}^{2t - 2}(Z)]
\end{align*}
}
where the last line used the fact that $(Z, Z')$ has the same distribution as $(Z', Z)$ and applied condition $3$ of \cref{lem: props_of_exp_kernel_mat}. Using the definitions of ${\mat{U}}_{k, a, b}$ and ${\mat{V}}_{k, a, b}$, we get
\begin{align*}
\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t} &\le \frac{2t - 1}{4}\mathbb{E}\tr[(s{\mat{U}}_{k, a, b} + s^{-1}{\mat{V}}_{k, a, b})\herm{{\mat{F}}}_{k, a, b}^{2t - 2}]\\
&\le \frac{2t - 1}{4}\left(\Esch{s{\mat{U}}_{k, a, b} + s^{-1}{\mat{V}}_{k, a, b}}{t}\right)^{1/t}(\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t})^{(t - 1)/t}
\end{align*}
where we used H\"{o}lder's inequality for the trace and H\"{o}lder's inequality for the expectation. Rearranging gives the result.
\end{proof}
\subsection{Proof of \cref{lem: main_general}}
\cref{lem: main_pmt_bound} suggests that in order to bound $\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}$, it suffices to bound $\Esch{{\mat{U}}_{k, a, b}}{t}$ and $\Esch{{\mat{V}}_{k, a, b}}{t}$. Indeed, this will be our strategy. To bound $\Esch{{\mat{U}}_{k, a, b}}{t}$, we will bound it via the matrices that we define below.
\begin{definition}[Matrices ${\mat{\Del}}_1^{k, a, b}, {\mat{\Del}}_2^{k, a, b}, {\mat{\Del}}_3^{k, a, b}$]
Define the matrices
\[{\mat{\Del}}_1^{k, a, b} = \mathbb{E}[(({\mat{D}}(Z) - {\mat{D}}(Z'))\herm{{\mat{G}}}_{k, a, b}(Z){\mat{D}}(Z))^2|Z]\]
\[{\mat{\Del}}_2^{k, a, b} = \mathbb{E}[({\mat{D}}(Z)(\herm{{\mat{G}}}_{k, a, b}(Z) - \herm{{\mat{G}}}_{k, a, b}(Z')){\mat{D}}(Z))^2|Z]\]
\[{\mat{\Del}}_3^{k, a, b} = \mathbb{E}[({\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}(Z)({\mat{D}}(Z) - {\mat{D}}(Z')))^2|Z]\]
\end{definition}
\begin{lemma}\label{lem: bound_U_by_Deltas}
${\mat{U}}_{k, a, b} \preceq 3({\mat{\Del}}_1^{k, a, b} + {\mat{\Del}}_2^{k, a, b} + {\mat{\Del}}_3^{k, a, b})$.
\end{lemma}
To prove this lemma, we will use the following lemma.
\begin{lemma}\label{lem: orthogonality}
We have the relations
\[({\mat{D}}(Z) - {\mat{D}}(Z'))(\herm{{\mat{G}}}_{k, a, b}(Z){\mat{D}}(Z) - \herm{{\mat{G}}}_{k, a, b}(Z'){\mat{D}}(Z')) = 0\]
\[(\herm{{\mat{G}}}_{k, a, b}(Z) - \herm{{\mat{G}}}_{k, a, b}(Z'))({\mat{D}}(Z) - {\mat{D}}(Z')) = 0\]
\end{lemma}
\begin{proof}[Proof sketch]
The proof is similar to the proof of third equality in \cref{lem: props_of_exp_kernel_mat}. When $Z'$ is set to $Z^{(i)}$ for some $i \le n$, when a diagonal entry of ${\mat{D}}(Z) - {\mat{D}}(Z')$ is nonzero, then the corresponding row of $\herm{{\mat{G}}}_{k, a, b}(Z){\mat{D}}(Z) - \herm{{\mat{G}}}_{k, a, b}(Z'){\mat{D}}(Z')$ will be $0$. The second equality is analogous.
\end{proof}
\begin{proof}[Proof of \cref{lem: bound_U_by_Deltas}]
We have
\begin{align*}
&(\herm{{\mat{F}}}_{k, a, b}(Z) - \herm{{\mat{F}}}_{k, a, b}(Z'))^2\\
&= ({\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}(Z){\mat{D}}(Z) - {\mat{D}}(Z')\herm{{\mat{G}}}_{k, a, b}(Z'){\mat{D}}(Z'))^2\\
&= \bigg({\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}(Z)({\mat{D}}(Z) - {\mat{D}}(Z')) + {\mat{D}}(Z)(\herm{{\mat{G}}}_{k, a, b}(Z) - \herm{{\mat{G}}}_{k, a, b}(Z')){\mat{D}}(Z')\\
&\qquad + ({\mat{D}}(Z) - {\mat{D}}(Z'))\herm{{\mat{G}}}_{k, a, b}(Z'){\mat{D}}(Z')\bigg)^2\\
&= \bigg({\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}(Z)({\mat{D}}(Z) - {\mat{D}}(Z')) + {\mat{D}}(Z)(\herm{{\mat{G}}}_{k, a, b}(Z) - \herm{{\mat{G}}}_{k, a, b}(Z')){\mat{D}}(Z)\\
& \qquad + ({\mat{D}}(Z) - {\mat{D}}(Z'))\herm{{\mat{G}}}_{k, a, b}(Z){\mat{D}}(Z)\bigg)^2
\end{align*}
where the last equality follows from \cref{lem: orthogonality}. Taking expectations conditioned on $Z$ and applying \cref{fact: cs}, we immediately get ${\mat{U}}_{k, a, b} \preceq 3({\mat{\Del}}_1^{k, a, b} + {\mat{\Del}}_2^{k, a, b} + {\mat{\Del}}_3^{k, a, b})$.
\end{proof}
In subsequent sections, we will prove the following technical bounds on the matrices we have considered so far.
\begin{restatable}{lemma}{boundDelTwo}\label{lem: bound_on_Del2}
For all integers $t \ge 1$, \[\Esch{{\mat{\Del}}_2^{k, a, b}}{t} \le \frac{(2d_p)^t}{n^t} (\Esch{\herm{{\mat{F}}}_{k, a, b + 1}}{2t} + \Esch{\herm{{\mat{F}}}_{k, a + 1, b}}{2t})\]
\end{restatable}
\begin{restatable}{lemma}{boundV}\label{lem: bound_on_V}
For all integers $t \ge 1$, \[\Esch{{\mat{V}}_{k, a, b}}{t} \le (2d_p)^tn^t (\Esch{\herm{{\mat{F}}}_{k, a, b + 1}}{2t} + \Esch{\herm{{\mat{F}}}_{k, a + 1, b}}{2t})\]
\end{restatable}
\begin{restatable}{lemma}{boundDelOne}\label{lem: bound_on_Del1}
For all integers $t \ge 1$, \[\Esch{{\mat{\Del}}_1^{k, a, b}}{t} \le \frac{(8dd_p)^t}{n^t}\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}\]
\end{restatable}
\begin{restatable}{lemma}{boundDelThree}\label{lem: bound_on_Del3}
For all integers $t \ge 1$, \[\Esch{{\mat{\Del}}_3^{k, a, b}}{t} \le \frac{(4d_p)^t}{n^t}\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}\]
\end{restatable}
Assuming the above lemmas, we can complete the proof of \cref{lem: main_general}, which we restate for convenience.
\maingeneral*
\begin{proof}[Proof of \cref{lem: main_general}]
Using \cref{lem: main_pmt_bound}, \cref{lem: bound_U_by_Deltas}, we get that for any $s > 0$,
\begin{align*}
\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}
&\le (\frac{2t - 1}{4})^t\Esch{s{\mat{U}}_{k, a, b} + s^{-1}{\mat{V}}_{k, a, b}}{t}\\
&\le t^t(s^t\Esch{{\mat{U}}_{k, a, b}}{t} + s^{-t}\Esch{{\mat{V}}_{k, a, b}}{t})\\
&\le (9st)^t(\Esch{{\mat{\Del}}_1^{k, a, b}}{t} + \Esch{{\mat{\Del}}_2^{k, a, b}}{t} + \Esch{{\mat{\Del}}_3^{k, a, b}}{t}) + t^ts^{-t}\Esch{{\mat{V}}_{k, a, b}}{t}
\end{align*}
Let $\rho = s / n$. Since the inequality is true for any choice of $s > 0$, it is true for any choice of $\rho > 0$.
Now, using \cref{lem: bound_on_Del1}, \cref{lem: bound_on_Del3},
\begin{align*}
(9st)^t(\Esch{{\mat{\Del}}_1^{k, a, b}}{t} + \Esch{{\mat{\Del}}_3^{k, a, b}}{t}) &\le (9st)^t\bigg(\frac{(8dd_p)^t}{n^t} + \frac{(4d_p)^t}{n^t}\bigg)\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}\\
&= \rho^t (C_1tdd_p)^t\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}
\end{align*}
for an absolute constant $C_1 > 0$. Using \cref{lem: bound_on_Del2}, \cref{lem: bound_on_V},
{\footnotesize
\begin{align*}
(9st)^t\Esch{{\mat{\Del}}_2^{k, a, b}}{t} + t^ts^{-t}\Esch{{\mat{V}}_{k, a, b}}{t} & \le\bigg((9st)^t\frac{(2d_p)^t}{n^t} + t^ts^{-t}(2d_p)^tn^t\bigg)(\Esch{\herm{{\mat{F}}}_{k, a, b + 1}}{2t} + \Esch{\herm{{\mat{F}}}_{k, a + 1, b}}{2t})\\
&\le (\rho^tC_2^t + \rho^{-t}C_3^t) (td_p)^t (\Esch{\herm{{\mat{F}}}_{k, a, b + 1}}{2t} + \Esch{\herm{{\mat{F}}}_{k, a + 1, b}}{2t})
\end{align*}
}
for absolute constants $C_2, C_3 > 0$.
Therefore,
\begin{align*}
\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t} &\le \rho^t (C_1tdd_p)^t\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t} \\&\qquad+ (\rho^tC_2^t + \rho^{-t}C_3^t) (td_p)^t(\Esch{\herm{{\mat{F}}}_{k, a, b + 1}}{2t} + \Esch{\herm{{\mat{F}}}_{k, a + 1, b}}{2t})
\end{align*}
We choose $\rho > 0$ so that $\rho^t (C_1tdd_p)^t = \frac{1}{2}$ to get
\begin{align*}
\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t} &\le \frac{1}{2}\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t} + \frac{1}{2}(Ct^2dd_p^2)^t (\Esch{\herm{{\mat{F}}}_{k, a, b + 1}}{2t} + \Esch{\herm{{\mat{F}}}_{k, a + 1, b}}{2t})
\end{align*}
for an absolute constant $C > 0$.
Rearranging yields the result.
\end{proof}
\subsection{Bounding ${\mat{\Del}}_2^{k, a, b}$ and ${\mat{V}}_{k, a, b}$}
The next lemma relates ${\mat{V}}_{k, a, b}$ to ${\mat{\Del}}_2^{k, a, b}$ upto a factor of $n^2$ which will be enough for us. We can then focus on bounding ${\mat{\Del}}_2^{k, a, b}$.
\begin{lemma}\label{lem: bounding_V_loewner}
${\mat{V}}_{k, a, b} \preceq n^2 {\mat{\Del}}_2^{k, a, b}$
\end{lemma}
\begin{proof}
Using \cref{lem: explicit_kernel_for_matrices},
\begin{align*}
{\mat{V}}_{k, a, b} &= \mathbb{E}[({\mat{D}}(Z)\herm{{\mat{K}}}_{k, a, b}(Z, Z'){\mat{D}}(Z))^2|Z]\\
&= \mathbb{E}[({\mat{D}}(Z)\bigg(\frac{n}{k - a - b}(\herm{{\mat{G}}}_{k, a, b}(Z) - \herm{{\mat{G}}}_{k, a, b}(Z'))\bigg){\mat{D}}(Z))^2|Z]\\
&\preceq n^2\mathbb{E}[({\mat{D}}(Z)(\herm{{\mat{G}}}_{k, a, b}(Z) - \herm{{\mat{G}}}_{k, a, b}(Z')){\mat{D}}(Z))^2|Z]\\
&= n^2 {\mat{\Del}}_2^{k, a, b}
\end{align*}
\end{proof}
For $1 \le i \le n$ and $1 \le l \le d$, let $\mat{e}_{i, l} \in \mathbb{N}^n$ denote the vector $\alpha$ with $\alpha_i = l$ and $\alpha_j = 0$ for $j \neq i$.
We note the following simple proposition.
\begin{propn}\label{propn: difference_equality}
For any polynomial $f$ such that the degree of $Z_i$ is at most $d$, \[f(Z) - f(Z^{(i)}) = \sum_{1 \le l \le d} (Z_i^l - \resamp{Z_i}^l)\nabla_{\mat{e}_{i, l}}(f)\]
\end{propn}
We now restate and prove \cref{lem: bound_on_Del2}.
\boundDelTwo*
\begin{proof}
Consider
\begin{align*}
{\mat{\Del}}_2^{k, a, b} &= \mathbb{E}[({\mat{D}}(Z)(\herm{{\mat{G}}}_{k, a, b}(Z) - \herm{{\mat{G}}}_{k, a, b}(Z')){\mat{D}}(Z))^2|Z]\\
&= \mathbb{E}\bigg[ \begin{bmatrix}
{\mat{M}}\mM^\intercal & 0\\
0 & {\mat{M}}^\intercal{\mat{M}}
\end{bmatrix} | Z\bigg]\\
&= \begin{bmatrix}
\mathbb{E}[{\mat{M}}\mM^\intercal|Z] & 0\\
0 & \mathbb{E}[{\mat{M}}^\intercal{\mat{M}}|Z]
\end{bmatrix}
\end{align*}
where ${\mat{M}} = {\mat{D}}_1(Z)({\mat{G}}_{k, a, b}(Z) - {\mat{G}}_{k, a, b}(Z')){\mat{D}}_2(Z)$. Using \cref{propn: difference_equality},
{\footnotesize
\begin{align*}
\mathbb{E}[{\mat{M}}\mM^T | Z] &= \mathbb{E}[{\mat{D}}_1(Z)({\mat{G}}_{k, a, b}(Z) - {\mat{G}}_{k, a, b}(Z')){\mat{D}}_2(Z)\cdot {\mat{D}}_2(Z) ({\mat{G}}_{k, a, b}(Z) - {\mat{G}}_{k, a, b}(Z'))^\intercal{\mat{D}}_1(Z)|Z]\\
&= \frac{1}{n} \sum_{i = 1}^n\mathbb{E}[{\mat{D}}_1(Z)({\mat{G}}_{k, a, b}(Z) - {\mat{G}}_{k, a, b}(Z^{(i)})){\mat{D}}_2(Z)\cdot {\mat{D}}_2(Z) ({\mat{G}}_{k, a, b}(Z) - {\mat{G}}_{k, a, b}(Z^{(i)}))^\intercal{\mat{D}}_1(Z)|Z]\\
&= \frac{1}{n}\sum_{i = 1}^n \sum_{l = 1}^d\mathbb{E}[(Z_i^l - \resamp{Z_i}^l)^2|Z]\cdot {\mat{D}}_1(Z)(\nabla_{\mat{e}_{i, l}} {\mat{G}}_{k, a, b})(Z){\mat{D}}_2(Z)\cdot {\mat{D}}_2(Z) (\nabla_{\mat{e}_{i, l}} {\mat{G}}_{k, a, b})(Z)^\intercal{\mat{D}}_1(Z)
\end{align*}
}
Define ${\mat{N}}_{i, l}(Z) := {\mat{D}}_1(Z)(\nabla_{\mat{e}_{i, l}} {\mat{G}}_{k, a, b})(Z){\mat{D}}_2(Z)$. Then,
\begin{align*}
\mathbb{E}[{\mat{M}}\mM^T | Z] &= \frac{1}{n}\sum_{i = 1}^n \sum_{l = 1}^d\mathbb{E}[(Z_i^l - \resamp{Z_i}^l)^2|Z]\cdot {\mat{N}}_{i, l}(Z){\mat{N}}_{i, l}(Z)^\intercal\\
&\preceq \frac{2}{n}\sum_{i = 1}^n \sum_{l = 1}^d(Z_i^{2l} + \mathbb{E}[Z_i^{2l}])\cdot {\mat{N}}_{i, l}(Z){\mat{N}}_{i, l}(Z)^\intercal
\end{align*}
Similarly,
\begin{align*}
\mathbb{E}[{\mat{M}}^\intercal{\mat{M}} | Z] &\preceq \frac{2}{n}\sum_{i = 1}^n \sum_{l = 1}^d(Z_i^{2l} + \mathbb{E}[Z_i^{2l}])\cdot {\mat{N}}_{i, l}(Z)^\intercal{\mat{N}}_{i, l}(Z)
\end{align*}
\begin{claim}\label{claim: reduction_general}
We have the relations
\[\sum_{i = 1}^n\sum_{l = 1}^d (Z_i^{2l} + \mathbb{E}[Z_i^{2l}]) \cdot {\mat{N}}_{i, l}(Z){\mat{N}}_{i, l}(Z)^\intercal = (b + 1){\mat{F}}_{k, a, b + 1}{\mat{F}}_{k, a, b + 1}^\intercal\]
\[\sum_{i = 1}^n \sum_{l = 1}^d(Z_i^{2l} + \mathbb{E}[Z_i^{2l}])\cdot {\mat{N}}_{i, l}(Z)^\intercal{\mat{N}}_{i, l}(Z) = (a + 1){\mat{F}}_{k, a + 1, b}^\intercal{\mat{F}}_{k, a + 1, b}\]
\end{claim}
Using this claim, we have
\[\mathbb{E}[{\mat{M}}\mM^T | Z] \preceq \frac{2(b + 1)}{n}{\mat{F}}_{k, a, b + 1}{\mat{F}}_{k, a, b + 1}^\intercal \preceq \frac{2d_p}{n}{\mat{F}}_{k, a, b + 1}{\mat{F}}_{k, a, b + 1}^\intercal\]
\[\mathbb{E}[{\mat{M}}^\intercal{\mat{M}} | Z] \preceq \frac{2(a + 1)}{n}{\mat{F}}_{k, a + 1, b}^\intercal{\mat{F}}_{k, a + 1, b} \preceq \frac{2d_p}{n}{\mat{F}}_{k, a + 1, b}^\intercal{\mat{F}}_{k, a + 1, b}\]
Therefore,
\begin{align*}
\Esch{{\mat{\Del}}_2^{k, a, b}}{t} &= \Esch{\mathbb{E}[{\mat{M}}\mM^\intercal|Z]}{t} + \Esch{\mathbb{E}[{\mat{M}}^\intercal{\mat{M}}|Z]}{t}\\
&\le \frac{(2d_p)^t}{n^t} (\Esch{{\mat{F}}_{k, a, b + 1}}{2t} + \Esch{{\mat{F}}_{k, a + 1, b}}{2t})\\
&\le \frac{(2d_p)^t}{n^t} (\Esch{\herm{{\mat{F}}}_{k, a, b + 1}}{2t} + \Esch{\herm{{\mat{F}}}_{k, a + 1, b}}{2t})
\end{align*}
\end{proof}
It remains to prove the claim.
\begin{proof}[Proof of~\cref{claim: reduction_general}]
We will prove the first relation, the second is analogous.
For a fixed $i \le n, l \le d$, consider any nonzero entry $[(I_1, \alpha_1, \gamma_1), (I_2, \alpha_2, \gamma_2)]$ of $\sum_{i = 1}^n \sum_{l = 1}^d (Z_i^{2l} + \mathbb{E}[Z_i^{2l}]) {\mat{N}}_{i, l}(Z) {\mat{N}}_{i, l}(Z)^\intercal$, where $I_1, I_2 \in {\mathcal{I}}, (\alpha_1, \gamma_1), (\alpha_2, \gamma_2) \in {\mathcal{K}}$. We must have $|\alpha_1|_0 = |\alpha_2|_0 = a$, in which case the entry is equal to
{\footnotesize
\begin{align*}
\sum_{\substack{(J, \alpha_3, \gamma_3) \in {\mathcal{J}}\times {\mathcal{K}}\\ |\alpha_3| = b \\ \alpha_1\alpha_3 = \alpha_2\alpha_3 = 0}} &(Z_i^{2l} + \mathbb{E}[Z_i^{2l}]) \cdot (\sqrt{\mathbb{E}[Z^{2\alpha_1\cdot (1 - \gamma_1) + 2\alpha_3\cdot (1 - \gamma_3)}]}Z^{\alpha_1\cdot \gamma_1 + \alpha_3\cdot\gamma_3}\nabla_{\mat{e}_{i, l}} \nabla_{\alpha_1 + \alpha_3} {\mat{X}}_k[I_1, J])\\
&\cdot (\sqrt{\mathbb{E}[Z^{2\alpha_2\cdot (1 - \gamma_2) + 2\alpha_3\cdot (1 - \gamma_3)}]}Z^{\alpha_2\cdot \gamma_2 + \alpha_3\cdot\gamma_3}\nabla_{\mat{e}_{i, l}} \nabla_{\alpha_2 + \alpha_3} {\mat{X}}_k[I_2, J])
\end{align*}}
Note that the term inside the summation is nonzero only when $\mat{e}_{i, l}\cdot (\alpha_1 + \alpha_3) = \mat{e}_{i, l} \cdot (\alpha_2 + \alpha_3) = 0$. Hence, this sum can be written as
\begin{align*}
\sum_{\substack{(J, \alpha_3, \gamma_3) \in {\mathcal{J}}\times {\mathcal{K}}\\ |\alpha_3| = b + 1 \\ \mat{e}_{i, l} \unlhd \alpha_3, \alpha_1\alpha_3 = \alpha_2\alpha_3 = 0}} &(\sqrt{\mathbb{E}[Z^{2\alpha_1\cdot (1 - \gamma_1) + 2\alpha_3\cdot (1 - \gamma_3)}]}Z^{\alpha_1\cdot \gamma_1 + \alpha_3\cdot\gamma_3}\nabla_{\alpha_1 + \alpha_3} {\mat{X}}_k[I_1, J])\\
&\cdot (\sqrt{\mathbb{E}[Z^{2\alpha_2\cdot (1 - \gamma_2) + 2\alpha_3\cdot (1 - \gamma_3)}]}Z^{\alpha_2\cdot \gamma_2 + \alpha_3\cdot\gamma_3}\nabla_{\alpha_2 + \alpha_3} {\mat{X}}_k[I_2, J])
\end{align*}
When we add this entry over all $i \le n, l \le d$, this simplifies to
\begin{align*}
(b + 1) \cdot \sum_{\substack{(J, \alpha_3, \gamma_3) \in {\mathcal{J}}\times {\mathcal{K}}\\ |\alpha_3| = b + 1 \\ \alpha_1\alpha_3 = \alpha_2\alpha_3 = 0}} &(\sqrt{\mathbb{E}[Z^{2\alpha_1\cdot (1 - \gamma_1) + 2\alpha_3\cdot (1 - \gamma_3)}]}Z^{\alpha_1\cdot \gamma_1 + \alpha_3\cdot\gamma_3}\nabla_{\alpha_1 + \alpha_3} {\mat{X}}_k[I_1, J])\\
&\cdot (\sqrt{\mathbb{E}[Z^{2\alpha_2\cdot (1 - \gamma_2) + 2\alpha_3\cdot (1 - \gamma_3)}]}Z^{\alpha_2\cdot \gamma_2 + \alpha_3\cdot\gamma_3}\nabla_{\alpha_2 + \alpha_3} {\mat{X}}_k[I_2, J])
\end{align*}
The factor of $(b + 1)$ came because the index $i$ could have been chosen from among all the active indices in $\alpha_3$. But this is precisely the $[(I_1, \alpha_1, \gamma_1), (I_2, \alpha_2, \gamma_2)]$ entry of $(b + 1){\mat{F}}_{k, a, b + 1}{\mat{F}}_{k, a, b + 1}^\intercal$, proving the claim.
\end{proof}
We restate and prove \cref{lem: bound_on_V}.
\boundV*
\begin{proof}
Using \cref{lem: bounding_V_loewner} and \cref{lem: bound_on_Del2}, we get
\begin{align*}
\Esch{{\mat{V}}_{k, a, b}}{t} &\le n^{2t}\Esch{{\mat{\Del}}_2^{k, a, b}}{t}\\
&\le (2d_p)^tn^t (\Esch{\herm{{\mat{F}}}_{k, a, b + 1}}{2t} + \Esch{\herm{{\mat{F}}}_{k, a + 1, b}}{2t})
\end{align*}
\end{proof}
\subsection{Bounding ${\mat{\Del}}_1^{k, a, b}$ and ${\mat{\Del}}_3^{k, a, b}$}
Define $\sqcup$ to be the disjoint union of sets. For $1 \le i \le n$ and $1 \le l \le d$, define the diagonal matrices ${\mat{\Pi}}_{i, l}, {\mat{\Pi}}_{i, l}', {\mat{\Pi}}_i, {\mat{\Pi}}_i' \in {\mathbb R}^{({\mathcal{I}} \times {\mathcal{K}}) \sqcup ({\mathcal{J}} \times {\mathcal{K}})} \times {\mathbb R}^{({\mathcal{I}} \times {\mathcal{K}}) \sqcup ({\mathcal{J}} \times {\mathcal{K}})}$ (the same dimensions as ${\mat{D}}$) as
{\footnotesize
\[{\mat{\Pi}}_{i, l}[(I, \alpha, \beta), (I, \alpha, \beta)] = \begin{dcases}
1 & \text{ if $(\alpha \cdot \gamma)_i \neq 0$ and $\alpha_i = l$}\\
0 & \text{ o.w.}
\end{dcases}\qquad {\mat{\Pi}}_i[(I, \alpha, \beta), (I, \alpha, \beta)] = \begin{dcases}
1 & \text{ if $(\alpha \cdot \gamma)_i \neq 0$}\\
0 & \text{ o.w.}
\end{dcases}\]
\[{\mat{\Pi}}'_{i, l}[(I, \alpha, \beta), (I, \alpha, \beta)] = \begin{dcases}
1 & \text{ if $\alpha_i \neq 0$ and $\alpha_i = l$}\\
0 & \text{ o.w.}
\end{dcases}\qquad {\mat{\Pi}}_i'[(I, \alpha, \beta), (I, \alpha, \beta)] = \begin{dcases}
1 & \text{ if $\alpha_i \neq 0$}\\
0 & \text{ o.w.}
\end{dcases}\]
}
for all $I \in {\mathcal{I}} \sqcup {\mathcal{J}}$.
Note that for all $i \le n$, ${\mat{\Pi}}_i = \sum_{l = 1}^d {\mat{\Pi}}_{i, l}$.
Also, for all $1 \le i \le n$, we define the permutation matrices ${\mat{\Sig}}_i \in{\mathbb R}^{({\mathcal{I}} \times {\mathcal{K}}) \sqcup ({\mathcal{J}} \times {\mathcal{K}})} \times {\mathbb R}^{({\mathcal{I}} \times {\mathcal{K}}) \sqcup ({\mathcal{J}} \times {\mathcal{K}})}$ as follows. Consider the permutation $\sigma_1$ on ${\mathcal{I}}\times {\mathcal{K}}$ that transposes $(I, \alpha, \gamma)$ and $(I, \alpha, \gamma + \mat{e}_i)$ for all $(I, \alpha, \gamma) \in {\mathcal{I}}\times {\mathcal{K}}$ such that $\alpha_i \neq 0$. Here, $\mat{e}_i \in \{0, 1\}^n$ has exactly one nonzero entry, which is in the $i$th position, and $\gamma + \mat{e}_i$ is the usual addition over $\mathbb{F}_2$. $\sigma_1$ leaves other positions fixed. Let ${\mat{\Sig}}^{(1)}_i$ be the permutation matrix for $\sigma$. Similarly, let ${\mat{\Sig}}^{(2)}_i$ be the permutation matrix of the permutation $\sigma_2$ on ${\mathcal{J}} \times {\mathcal{K}}$ that transposes $(J, \alpha, \gamma)$ and $(J, \alpha, \gamma + \mat{e}_i)$ for all $(J, \alpha, \gamma) \in {\mathcal{J}}\times {\mathcal{K}}$ such that $\alpha_i \neq 0$, and leaves all other positions fixed. Then, we define ${\mat{\Sig}}_i = \begin{bmatrix}
{\mat{\Sig}}^{(1)}_i & 0\\
0 & {\mat{\Sig}}^{(2)}_i
\end{bmatrix}$. The following fact is easy to verify.
\begin{fact}\label{fact: commutativity}
${\mat{\Pi}}'_{i, l}{\mat{\Sig}}_i = {\mat{\Sig}}_i{\mat{\Pi}}'_{i, l}$ and ${\mat{\Pi}}_i' {\mat{\Sig}}_i = {\mat{\Sig}}_i {\mat{\Pi}}_i'$.
\end{fact}
We are now ready to prove \cref{lem: bound_on_Del1} which we restate for convenience.
\boundDelOne*
\begin{proof}
Firstly,
\begin{align*}
{\mat{\Del}}_1^{k, a, b} &= \mathbb{E}[(({\mat{D}}(Z) - {\mat{D}}(Z'))\herm{{\mat{G}}}_{k, a, b}(Z){\mat{D}}(Z))^2|Z]\\
&= \mathbb{E}[({\mat{D}}(Z) - {\mat{D}}(Z'))\herm{{\mat{G}}}_{k, a, b}(Z){\mat{D}}(Z)\cdot {\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}(Z)({\mat{D}}(Z) - {\mat{D}}(Z'))|Z]\\
&= \mathbb{E}[({\mat{D}}(Z) - {\mat{D}}(Z')) {\mat{M}}(Z) ({\mat{D}}(Z) - {\mat{D}}(Z'))|Z]
\end{align*}
where we define ${\mat{M}}(Z) = \herm{{\mat{G}}}_{k, a, b}(Z){\mat{D}}(Z)\cdot {\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}(Z)$.
Recall that $Z' = Z^{(i)}$ for some $i$ randomly chosen from $[n]$ uniformly. Observing that ${\mat{D}}(Z) - {\mat{D}}(Z^{(i)}) = {\mat{\Pi}}_i({\mat{D}}(Z) - {\mat{D}}(Z^{(i)}))$ for all $i$, we get
\begin{align*}
{\mat{\Del}}_1^{k, a, b}
&= \mathbb{E}[ \mathbb{E}_{i \in [n]} [({\mat{D}}(Z) - {\mat{D}}(Z^{(i)})) {\mat{M}}(Z) ({\mat{D}}(Z) - {\mat{D}}(Z^{(i)}))]|Z]\\
&= \mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{\Pi}}_i({\mat{D}}(Z) - {\mat{D}}(Z^{(i)})) {\mat{M}}(Z) ({\mat{D}}(Z) - {\mat{D}}(Z^{(i)})){\mat{\Pi}}_i]|Z]\\
&\preceq 2\bigg(\mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{\Pi}}_i{\mat{D}}(Z){\mat{M}}(Z){\mat{D}}(Z){\mat{\Pi}}_i]|Z] + \mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{\Pi}}_i{\mat{D}}(Z^{(i)}){\mat{M}}(Z){\mat{D}}(Z^{(i)}){\mat{\Pi}}_i]|Z]\bigg)\\
&\preceq 2\bigg(\mathbb{E}_{i \in [n]} [{\mat{\Pi}}_i\herm{{\mat{F}}}_{k, a, b}^2{\mat{\Pi}}_i] + \mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{\Pi}}_i{\mat{D}}(Z^{(i)}){\mat{M}}(Z){\mat{D}}(Z^{(i)}){\mat{\Pi}}_i]|Z]\bigg)\\
& \preceq 2({\mat{\Del}}_{10} + {\mat{\Del}}_{11})
\end{align*}
where we define
\[{\mat{\Del}}_{10} = \mathbb{E}_{i \in [n]} [{\mat{\Pi}}_i\herm{{\mat{F}}}_{k, a, b}^2{\mat{\Pi}}_i], \qquad {\mat{\Del}}_{11} = \mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{\Pi}}_i{\mat{D}}(Z^{(i)}){\mat{M}}(Z){\mat{D}}(Z^{(i)}){\mat{\Pi}}_i]|Z]\]
Invoking \cref{lem: jensen_trace} over the interval $[0, \infty)$ with the convex continuous function $f(x) = x^t$, ${\mat{B}}_i = \herm{{\mat{F}}}_{k, a, b}^2, {\mat{A}}_i = \frac{1}{\sqrt{d_p}}{\mat{\Pi}}_i$ where we observe that $\sum_{i = 1}^n {\mat{A}}_i {\mat{A}}_i^T = \frac{1}{d_p}\sum_{i = 1}^n {\mat{\Pi}}_i^2\preceq {\mat{I}}$, we get
\begin{align*}
\Esch{{\mat{\Del}}_{10}}{t} = \mathbb{E}\tr[{\mat{\Del}}_{10}^t] = \mathbb{E}\tr[\bigg(\mathbb{E}_{i \in [n]} [{\mat{\Pi}}_i\herm{{\mat{F}}}_{k, a, b}^2{\mat{\Pi}}_i]\bigg)^t] &= \frac{1}{n^t}\mathbb{E}\tr[\bigg(\sum_{i = 1}^n{\mat{\Pi}}_i\herm{{\mat{F}}}_{k, a, b}^2{\mat{\Pi}}_i\bigg)^t]\\
&\le \frac{d_p^{t - 1}}{n^t}\mathbb{E}\tr[\bigg(\sum_{i = 1}^n{\mat{\Pi}}_i\herm{{\mat{F}}}_{k, a, b}^{2t}{\mat{\Pi}}_i\bigg)]\\
&\le \frac{d_p^{t - 1}}{n^t}\mathbb{E}\tr[\bigg(\sum_{i = 1}^n{\mat{\Pi}}_i^2\bigg)\herm{{\mat{F}}}_{k, a, b}^{2t}]\\
&\le \frac{d_p^t}{n^t}\mathbb{E}\tr[\herm{{\mat{F}}}_{k, a, b}^{2t}]\\
&= \frac{d_p^t}{n^t}\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}
\end{align*}
Now, consider
\begin{align*}
{\mat{\Del}}_{11} &= \mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{\Pi}}_i{\mat{D}}(Z^{(i)}){\mat{M}}(Z){\mat{D}}(Z^{(i)}){\mat{\Pi}}_i]|Z]\\
&= \mathbb{E}[\mathbb{E}_{i \in [n]} [(\sum_{l = 1}^d{\mat{\Pi}}_{i, l}){\mat{D}}(Z^{(i)}){\mat{M}}(Z){\mat{D}}(Z^{(i)})(\sum_{l = 1}^d{\mat{\Pi}}_{i, l})]|Z]\\
&\preceq d\cdot \mathbb{E}[\mathbb{E}_{i \in [n]} [\sum_{l = 1}^d{\mat{\Pi}}_{i, l}{\mat{D}}(Z^{(i)}){\mat{M}}(Z){\mat{D}}(Z^{(i)}){\mat{\Pi}}_{i, l}]|Z]\\
&= d\cdot \mathbb{E}_{i \in [n]} [\sum_{l = 1}^d \frac{\mathbb{E}[Z_i^{2l}]}{Z_i^{2l}}{\mat{\Pi}}_{i, l}{\mat{D}}(Z){\mat{M}}(Z){\mat{D}}(Z){\mat{\Pi}}_{i, l}]\\
&= \frac{d}{n} \sum_{i = 1}^n\sum_{l = 1}^d \frac{\mathbb{E}[Z_i^{2l}]}{Z_i^{2l}}{\mat{\Pi}}_{i, l}{\mat{D}}(Z){\mat{M}}(Z){\mat{D}}(Z){\mat{\Pi}}_{i, l}\\
&= \frac{d}{n} \sum_{i = 1}^n\sum_{l = 1}^d {\mat{\Pi}}_{i, l}{\mat{\Sig}}_i{\mat{D}}(Z){\mat{M}}(Z){\mat{D}}(Z){\mat{\Sig}}_i^\intercal{\mat{\Pi}}_{i, l}\\
&= \frac{d}{n} \sum_{i = 1}^n\sum_{l = 1}^d {\mat{\Pi}}_{i, l}{\mat{\Sig}}_i\herm{{\mat{F}}}_{k, a, b}^2{\mat{\Sig}}_i^\intercal{\mat{\Pi}}_{i, l}
\end{align*}
We now invoke \cref{lem: jensen_trace} on $dd_p$ terms with ${\mat{B}}_{i, l} = \herm{{\mat{F}}}_{k, a, b}^2$ and ${\mat{A}}_{i, l} = \frac{1}{\sqrt{d_p}} {\mat{\Pi}}_{i, l}{\mat{\Sig}}_i$ where we observe that
\[\sum_{i = 1}^n\sum_{l = 1}^d {\mat{A}}_{i, l} {\mat{A}}_{i, l}^T = \frac{1}{d_p}\sum_{i = 1}^n\sum_{l = 1}^d {\mat{\Pi}}_{i, l}{\mat{\Sig}}_i{\mat{\Sig}}_i^\intercal{\mat{\Pi}}_{i, l}^\intercal = \frac{1}{d_p}\sum_{i = 1}^n\sum_{l = 1}^d {\mat{\Pi}}_{i, l}^2 \preceq {\mat{I}}\]
to get
\begin{align*}
\Esch{{\mat{\Del}}_{11}}{t} = \mathbb{E} \tr[{\mat{\Del}}_{11}^t] &\le \frac{d^t}{n^t} \mathbb{E}\tr[(\sum_{i = 1}^n\sum_{l = 1}^d {\mat{\Pi}}_{i, l}{\mat{\Sig}}_i\herm{{\mat{F}}}_{k, a, b}^2{\mat{\Sig}}_i^\intercal{\mat{\Pi}}_{i, l})^t]\\
&\le \frac{(dd_p)^t}{n^t}\mathbb{E}\tr[\bigg(\frac{1}{d_p}\sum_{i = 1}^n\sum_{l = 1}^d {\mat{\Pi}}_{i, l}{\mat{\Sig}}_i\herm{{\mat{F}}}_{k, a, b}^{2t}{\mat{\Sig}}_i^\intercal{\mat{\Pi}}_{i, l}\bigg)]\\
&= \frac{(dd_p)^t}{n^t}\mathbb{E}\tr[\bigg(\frac{1}{d_p}\sum_{i = 1}^n\sum_{l = 1}^d {\mat{\Sig}}_i^\intercal{\mat{\Pi}}_{i, l}{\mat{\Pi}}_{i, l}{\mat{\Sig}}_i\herm{{\mat{F}}}_{k, a, b}^{2t}\bigg)]
\end{align*}
To simplify this, we use \cref{fact: commutativity} to get
\begin{align*}
\sum_{i = 1}^n\sum_{l = 1}^d {\mat{\Sig}}_i^\intercal({\mat{\Pi}}_{i, l})^2{\mat{\Sig}}_i \preceq \sum_{i = 1}^n\sum_{l = 1}^d {\mat{\Sig}}_i^\intercal({\mat{\Pi}}'_{i, l})^2{\mat{\Sig}}_i = \sum_{i = 1}^n\sum_{l = 1}^d {\mat{\Pi}}'_{i, l}{\mat{\Sig}}_i^\intercal{\mat{\Sig}}_i{\mat{\Pi}}'_{i, l} &= \sum_{i = 1}^n\sum_{l = 1}^d {\mat{\Pi}}'_{i, l}{\mat{\Pi}}'_{i, l}\\ &\preceq d_p {\mat{I}}
\end{align*}
Therefore,
\[\Esch{{\mat{\Del}}_{11}}{t} \le \frac{(dd_p)^t}{n^t}\mathbb{E}\tr[\herm{{\mat{F}}}_{k, a, b}^{2t}] = \frac{(dd_p)^t}{n^t}\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}\]
Putting them together, using \cref{fact: holder},
\begin{align*}
\Esch{{\mat{\Del}}_1^{k, a, b}}{t} &\le 4^t(\Esch{{\mat{\Del}}_{10}}{t} + \Esch{{\mat{\Del}}_{11}}{t})\\
&\le \frac{(8dd_p)^t}{n^t}\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}
\end{align*}
\end{proof}
We now restate and prove \cref{lem: bound_on_Del3}.
\boundDelThree*
\begin{proof}
Recall that $Z' = Z^{(i)}$ for $i$ sampled uniformly from $[n]$. Then,
\begin{align*}
{\mat{\Del}}_3^{k, a, b} &= \mathbb{E}[({\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}(Z)({\mat{D}}(Z) - {\mat{D}}(Z')))^2|Z]\\
&= \mathbb{E}[\mathbb{E}_{i \in [n]} [({\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}(Z)({\mat{D}}(Z) - {\mat{D}}(Z^{(i)})))^2] | Z]\\
&= \mathbb{E}[\mathbb{E}_{i \in [n]} [({\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}(Z){\mat{\Pi}}_i({\mat{D}}(Z) - {\mat{D}}(Z^{(i)})))^2] | Z]
\end{align*}
where we use the fact that ${\mat{D}}(Z) - {\mat{D}}(Z^{(i)}) = {\mat{\Pi}}_i({\mat{D}}(Z) - {\mat{D}}(Z^{(i)}))$ for all $i$. Define ${\mat{M}}(Z) = {\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}$ to get
\begin{align*}
{\mat{\Del}}_3^{k, a, b} &= \mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Pi}}_i({\mat{D}}(Z) - {\mat{D}}(Z^{(i)}))^2{\mat{\Pi}}_i{\mat{M}}(Z)^\intercal] | Z]\\
&\preceq 2(\mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Pi}}_i{\mat{D}}(Z)^2{\mat{\Pi}}_i{\mat{M}}(Z)^\intercal] | Z] + \mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Pi}}_i{\mat{D}}(Z^{(i)})^2{\mat{\Pi}}_i{\mat{M}}(Z)^\intercal] | Z])\\
&= 2(\mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Pi}}_i{\mat{D}}(Z)^2{\mat{\Pi}}_i{\mat{M}}(Z)^\intercal] + \mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Pi}}_i{\mat{D}}(Z^{(i)})^2{\mat{\Pi}}_i{\mat{M}}(Z)^\intercal] | Z])\\
&= 2({\mat{\Del}}_{30} + {\mat{\Del}}_{31})
\end{align*}
where we define
\[{\mat{\Del}}_{30} = \mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Pi}}_i{\mat{D}}(Z)^2{\mat{\Pi}}_i{\mat{M}}(Z)^\intercal], \qquad {\mat{\Del}}_{31} = \mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Pi}}_i{\mat{D}}(Z^{(i)})^2{\mat{\Pi}}_i{\mat{M}}(Z)^\intercal] | Z]\]
We have
\begin{align*}
{\mat{\Del}}_{30} = \mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Pi}}_i{\mat{D}}(Z)^2{\mat{\Pi}}_i{\mat{M}}(Z)^\intercal] &= \mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{D}}(Z){\mat{\Pi}}_i{\mat{\Pi}}_i{\mat{D}}(Z){\mat{M}}(Z)^\intercal]\\
&= {\mat{M}}(Z) {\mat{D}}(Z)(\frac{1}{n}\sum_{i = 1}^n{\mat{\Pi}}_i^2){\mat{D}}(Z){\mat{M}}(Z)^\intercal\\
&\preceq \frac{d_p}{n} {\mat{M}}(Z) {\mat{D}}(Z){\mat{D}}(Z){\mat{M}}(Z)^\intercal\\
&= \frac{d_p}{n} \herm{{\mat{F}}}_{k, a, b}^2
\end{align*}
For the other term, using \cref{fact: commutativity},
\begin{align*}
{\mat{\Del}}_{31} &= \mathbb{E}[\mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Pi}}_i{\mat{D}}(Z^{(i)})^2{\mat{\Pi}}_i{\mat{M}}(Z)^\intercal] | Z]\\
&= \mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Pi}}_i{\mat{\Sig}}_i{\mat{D}}(Z)^2{\mat{\Sig}}_i{\mat{\Pi}}_i{\mat{M}}(Z)^\intercal]\\
&\preceq \mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Pi}}'_i{\mat{\Sig}}_i{\mat{D}}(Z)^2{\mat{\Sig}}_i{\mat{\Pi}}'_i{\mat{M}}(Z)^\intercal]\\
&= \mathbb{E}_{i \in [n]} [{\mat{M}}(Z) {\mat{\Sig}}_i{\mat{\Pi}}'_i{\mat{D}}(Z)^2{\mat{\Pi}}'_i{\mat{\Sig}}_i{\mat{M}}(Z)^\intercal]\\&= \mathbb{E}_{i \in [n]} [{\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b} {\mat{\Sig}}_i{\mat{\Pi}}'_i{\mat{D}}(Z)^2{\mat{\Pi}}'_i{\mat{\Sig}}_i\herm{{\mat{G}}}_{k, a, b}{\mat{D}}(Z)]
\end{align*}
Observe that $\herm{{\mat{G}}}_{k, a, b} {\mat{\Sig}}_i = \herm{{\mat{G}}}_{k, a, b}$ because the entries of $\herm{{\mat{G}}}$ only depend on $\alpha$ and not on $\gamma$, so permuting the $\gamma$s will not have any effect on the matrix. Therefore,
\begin{align*}
{\mat{\Del}}_{31} &\preceq \mathbb{E}_{i \in [n]} [{\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}{\mat{\Pi}}'_i{\mat{D}}(Z)^2{\mat{\Pi}}'_i\herm{{\mat{G}}}_{k, a, b}{\mat{D}}(Z)]\\
&\preceq \mathbb{E}_{i \in [n]} [{\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}{\mat{D}}(Z){\mat{\Pi}}'_i{\mat{\Pi}}'_i{\mat{D}}(Z)\herm{{\mat{G}}}_{k, a, b}{\mat{D}}(Z)]\\
&= \mathbb{E}_{i \in [n]} \herm{{\mat{F}}}_{k, a, b}{\mat{\Pi}}'_i{\mat{\Pi}}'_i\herm{{\mat{F}}}_{k, a, b}\\
&= \frac{1}{n} \sum_{i = 1}^n \herm{{\mat{F}}}_{k, a, b}{\mat{\Pi}}'_i{\mat{\Pi}}'_i\herm{{\mat{F}}}_{k, a, b}\\
&\preceq \frac{d_p}{n}\herm{{\mat{F}}}_{k, a, b}^2
\end{align*}
where we used the fact that $\sum_{i = 1}^n{\mat{\Pi}}'_i{\mat{\Pi}}'_i \preceq d_p {\mat{I}}$. Putting them together,
\begin{align*}
\Esch{{\mat{\Del}}_3^{k, a, b}}{t} \le 2^t(\Esch{{\mat{\Del}}_{30}}{t} + \Esch{{\mat{\Del}}_{31}}{t}) \le 2^t \cdot 2 \frac{d_p^t}{n^t}\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t} \le \frac{(4d_p)^t}{n^t}\Esch{\herm{{\mat{F}}}_{k, a, b}}{2t}
\end{align*}
\end{proof}
\subsubsection*{Random Variables}
\subsubsection*{Multi-index notation}
For any pair of vectors $\alpha, \beta \in \mathbb{N}^n$ and scalar $c \in \mathbb{N}$, we define $\alpha + \beta, \alpha \cdot \beta, c\alpha$ entrywise. We also define the orderings $\alpha \le \beta$ and $\alpha \unlhd \beta$ where we say $\alpha \le \beta$ if for each $i$, $\alpha_i \le \beta_i$, and $\alpha \unlhd \beta$ if for each $i$, $\alpha_i$ is either $0$ or $\beta_i$. We denote by $|\alpha|_0$ the number of nonzero entries of $\alpha$ and by $|\alpha|_1$, the sum of entries of $\alpha$. For a boolean vector $\gamma \in \{0, 1\}^n$, we define $1 - \gamma$ the vector with all its bits flipped.
\subsubsection*{Derivatives}
For variables $Z_1, \ldots, Z_n$ and $\alpha \in \mathbb{N}^n$, define the monomial $Z^{\alpha} := \prod_{i = 1}^n Z_i^{\alpha_i}$. This forms a standard basis for polynomials.
For $\alpha \in \mathbb{N}^n$, we define the linear operator $\nabla_{\alpha}$ that acts on polynomials by defining its action on the elements $Z^{\beta}$ as follows and then extend linearly to all polynomials.
\[\nabla_{\alpha}(Z^{\beta}) = \begin{dcases}
Z^{\beta - \alpha} & \text{ if $\alpha \unlhd \beta$}\\
0 & \text{ o.w.}
\end{dcases}\]
Informally, for a polynomial $f$ written as a linear combination of the standard basis polynomials $Z^{\beta}$, $\nabla_{\alpha}(f)$ isolates the terms that precisely contain the powers $Z_i^{\alpha_i}$ for all $i$ such that $\alpha_i \neq 0$ and then truncates these powers. In other words, it's the coefficient of $Z^{\alpha}$ in $f$. In particular, observe that $\nabla_{\alpha}(f)$ does not depend on $Z_i$ for any $i$ such that $\alpha_i \neq 0$.
Supose $f$ is multilinear, as we can assume in the Rademacher case when we are working with $Z_i \in \{-1,1\}\xspace$. For $\alpha \in \{0, 1\}^n$ with nonzero indices $i_1, \ldots, i_k \in [n]$, we have $\nabla_{\alpha}(f) = \frac{\partial}{\partial Z_{i_1}}\ldots \frac{\partial}{\partial Z_{i_k}}f$. So this linear operator generalizes the partial derivative operator. But note that in general, $\nabla$ is not simply the standard partial derivative operator.
\subsubsection*{Matrix Analysis}
Linear operators that act on polynomials can also be naturally defined to act on matrices by acting on each entry.
We define ${\mat{I}}_m$ to be the $m \times m$ identity matrix. We drop the subscript when it's clear.
For matrices ${\mat{F}}, {\mat{G}}$, define ${\mat{F}} \oplus {\mat{G}}$ to be the matrix $\begin{bmatrix}
0 & {\mat{F}}\\
{\mat{G}} & 0
\end{bmatrix}$. For a matrix ${\mat{F}}$, define its Hermitian dilation $\herm{{\mat{F}}}$ as ${\mat{F}} \oplus {\mat{F}}^T$. Denote by $\preceq$ the Loewner order, that is, ${\mat{A}} \preceq {\mat{B}}$ for ${\mat{A}}, {\mat{B}} \in \mathbb{H}^n$ if and only if ${\mat{B}} - {\mat{A}}$ is positive semi-definite.
\begin{definition}
For a matrix ${\mat{F}}$ and an integer $t \ge 0$, define the Schatten $2t$-norm as
\[\norm{{\mat{F}}}_{2t}^{2t} = \tr[{({\mat{F}}\mF^T)^t}]\]
\end{definition}
\begin{fact}\label{fact: cs}
For real symmetric matrices ${\mat{X}}_1, \ldots, {\mat{X}}_n$, we have
\begin{align*}
({\mat{X}}_1 + \ldots + {\mat{X}}_n)^2 \preceq n({\mat{X}}_1^2 + \ldots + {\mat{X}}_n^2)
\end{align*}
\end{fact}
\begin{fact}\label{fact: holder}
For positive semidefinite matrices ${\mat{X}}, {\mat{X}}_1, \ldots, {\mat{X}}_n$ such that ${\mat{X}} \preceq {\mat{X}}_1 + \ldots + {\mat{X}}_n$ and for any integer $t \ge 1$,
\begin{align*}
\tr [{\mat{X}}^t] \le n^{t - 1}(\tr[{\mat{X}}_1^t] + \ldots + \tr[{\mat{X}}_n^t])
\end{align*}
\end{fact}
\begin{proof}
By H\"{o}lder's inequality, $n^{t - 1}(\tr[{\mat{X}}_1^t] + \ldots + \tr[{\mat{X}}_n^t]) \ge (\norm{{\mat{X}}_1}_t + \ldots + \norm{{\mat{X}}_n}_t)^t$. By triangle inequality of Schatten norms, this is at least $\norm{{\mat{X}}_1 + \ldots + {\mat{X}}_n}_t^t$. Finally, because ${\mat{X}}_1 + \ldots + {\mat{X}}_n \succeq {\mat{X}}\succeq 0$, we can use the monotonicity of trace functions (see \cite[Proposition 1]{petz1994survey}) where we use the increasing function $f(x) = x^t$ on $x \in [0, \infty)$. This proves the result.
\end{proof}
\begin{lemma}[Jensen's operator trace inequality]\cite[Corollary 2.5]{hansen2003jensen}\label{lem: jensen_trace}
Let $f$ be a convex, continuous function defined on an interval $I$ and suppose that $0 \in I$ and $f(0) \le 0$. Then, for all integers $m, n \ge 1$, for every tuple ${\mat{B}}_1, \ldots, {\mat{B}}_n$ of real symmetric $m \times m$ matrices with spectra contained in $I$ and every tuple ${\mat{A}}_1, \ldots, {\mat{A}}_n$ of $m \times m$ matrices with $\sum_{i = 1}^n {\mat{A}}_i^T{\mat{A}}_i \preceq {\mat{I}}$, we have
\[\tr[f(\sum_{i = 1}^n {\mat{A}}_i^T {\mat{B}}_i {\mat{A}}_i)] \le \tr[\sum_{i = 1}^n {\mat{A}}_i^T f({\mat{B}}_i) {\mat{A}}_i]\]
\end{lemma}
\section{Introduction}\label{sec: intro}
\input{efron-stein-sos/intro}
\section{Preliminaries}\label{sec: prelims}
\input{efron-stein-sos/prelims}
\section{The basic framework for Rademacher random variables} \label{sec: basic_recursion}
\input{efron-stein-sos/rademacher_recursion}
\section{Applications}\label{sec:rademacher-applications}
To illustrate our framework, we apply it to obtain concentration bounds for nonlinear random matrices that have been considered in the literature before. The first one is a simple tensor network that arose in the analysis of spectral algorithms for a variant of principal components analysis (PCA) \cite{hopkins2015tensor, hopkins2018statistical}.
The second application is to obtain norm bounds on dense graph matrices \cite{medarametla2016bounds, ahn2016graph}. In the second application, the norm bounds are governed by a combinatorial structure called \textit{the minimum vertex separator of a shape}. We will see how this notion arises naturally under our framework, while prior works that derived such bounds used the trace power method and required nontrivial combinatorial insights.
\subsection{A simple tensor network}
\input{efron-stein-sos/tensor_network_norm_bound}
\subsection{Graph matrices}\label{sec: dense_graph_matrices}
\input{efron-stein-sos/dense_graph_matrices}
\section{Why a na\"ive application of \cite{paulin2016} may fail for general product distributions} \label{sec: failure_of_basic}
\input{efron-stein-sos/failure_of_basic}
\section{The general recursion framework}\label{sec: general_recursion}
\input{efron-stein-sos/general_recursion}
\section{A generalization of \cite{paulin2016} and proof of \cref{lem: main_general}}\label{sec: proof_of_general}
\input{efron-stein-sos/proof_of_general}
\section{Application: Sparse graph matrices} \label{sec: sparse_graph_matrices}
\input{efron-stein-sos/sparse_graph_matrices}
\section{Nonlinear concentration for non-product distributions}
Our techniques in \cref{chap: efron_stein} apply to a collection of random variables that are sampled independently of each other. A natural question is to ask if we can generalize to the case when they are not independent. For example, this is useful when instead of analyzing Erd\H{o}s\xspace-R\'enyi\xspace random graphs, we wish to analyze uniform $d$-regular graphs. Such a generalization seems extremely likely because our proof techniques essentially requires a Markov Chain that mixes rapidly to the given distribution, and then we can recursively apply the Poincar\'e\xspace inequality. We leave this for future work.
\section{Sum of Squares lower bounds}
In this dissertation, we saw several SoS lower bounds and while they build on fundamental conceptual building blocks such as the nonlinear concentration results we show and simple heuristics like pseudocalibration, an important technical barrier in the current proofs is that the proofs are highly technical and have many moving parts. It's an important research question to understand if the proofs can be simplified. Apart from enabling a better understanding of the SoS hierarchy, this will also help us understand the computational barriers of several fundamental problems in computer science. Examples of such problems follow.
\subsection{Sparse Independent Set}
In a follow-up work \cite{jones2022sum}, we prove SoS lower bounds for the important problem of maximum independent set on sparse Erd\H{o}s\xspace-R\'enyi\xspace random graphs.
In this dissertation, the SoS lower bounds studied were in the setting when the input was sampled from product distributions where each distribution was either Rademacher or Gaussian. This is also the case in many prior works on SoS lower bounds. Recall that this was termed the \textit{dense setting} in \cref{chap: efron_stein}. It's equally important to study problems in the fascinating average-case \textit{sparse setting} where the input distribution could have high Orlicz norm, for example when the input is an Erd\H{o}s\xspace-R\'enyi\xspace random graph sampled from $G_{n, p}$ instead of $G_{n, \frac{1}{2}}$ for some $p = o(1)$. The techniques developed in this work and prior works for high degree SoS lower bounds do not easily generalize to this setting. The work \cite{jones2022sum} initiates this research direction for the fundamental problem of maximum independent set on random sparse graphs.
Consider the independent set problem on a graph $G \sim G_{n, \frac{d}{n}}$ where $d$ is the average degree. If $d = \frac{n}{2}$, then this is the same as the maximum clique problem and SoS lower bounds were obtained in \cite{BHKKMP16}. We now focus on the setting $d \ll n$. We first state the size of the true optimum.
\begin{fact}[\cite{COE15, DM11, DSS16}]
W.h.p. the max independent set in $G$ has size $(1+o_d(1)) \cdot \frac{2\ln d}{d} \cdot n$.
\end{fact}
The famous Lov\'asz\xspace $\vartheta$ function efficiently computes an upper bound on this value and its value is well-known on such random graphs.
\begin{fact}[\cite{CO05}]
W.h.p. $\vartheta(G) =\Theta(\frac{n}{\sqrt{d}} )$.
\end{fact}
The value of the $\vartheta$ function is also the output of the degree $2$ SoS relaxation for this problem. So, there is an integrality gap of approximately $\sqrt{d}$. We therefore naturally ask whether higher degree SoS can perform better or this gap persists. In our work, we show that this $\sqrt{d}$ integrality gap persists for higher degrees of SoS as well
We prove two main results, one in the setting $(\log n)^2 \le d \le \sqrt{n}$ and the other in the setting $n^{\Omega(1)} \le d \le \frac{n}{2}$.
Note that we have not covered the case when the average degree $d$ is constant. This is an interesting direction for future work.
In the first setting $(\log n)^2 \le d \le \sqrt{n}$, we show a tradeoff between the degree $D_{sos}$ of the SoS relaxation and the integrality gap.
\begin{theorem}
There is an absolute constant $c_0 \in {\mathbb{N}}$ such that for sufficiently large $n \in {\mathbb{N}}$ and ${d \in [(\log n)^2, n^{0.5}]}$, and parameters $k, D_{\text{SoS}}$ satisfying
%
$
k ~\leq~ \frac{n}{D_{\text{SoS}}^{c_0}\cdot \log n \cdot d^{1/2}},$
%
w.h.p. over $G~\sim~ G_{n,~d/n}$, there exists a degree-$D_{\text{SoS}}$ pseudoexpectation for the maximum independent set problem with objective value $(1-o(1)) k$.
\end{theorem}
In particular, when $d \in [n^{\Omega(1)}, \sqrt{n}]$, this exhibits an SoS lower bound against polynomial degree $n^{\Omega(1)}$ SoS.
In the second setting $n^{\Omega(1)} \le d \le \frac{n}{2}$, we show an SoS lower bound for logarithmic degree SoS.
\begin{theorem}
\label{thm:informal-logd}
For any $\varepsilon_1, \varepsilon_2 >0$ there is $\delta > 0$, such that for $d \in [n^{\varepsilon_1}, n/2]$ and $k \leq \frac{n}{d^{1/2+\varepsilon_2}}$, w.h.p. over $G~\sim~ G_{n,~d/n}$, there exists a degree-$(\delta \log d)$ pseudoexpectation with objective value $(1-o(1))k$.
\end{theorem}
We remark that these theorems rule out polynomial-time certification (i.e. constant
degree SoS) for any $d \geq {\mathrm{polylog}}(n)$.
Broadly speaking, we utilize similar techniques to show these results, namely pseudo-calibration, graph matrices and approximate PSD decomposition. However, the approach does not readily work and we overcome the difficulties with several new ideas and techniques. We summarize some of them below.
\begin{itemize}
\item The first conceptual difficulty we overcome is that we are unable to apply pseudo-calibration due to the lack of a good candidate planted distribution. For most natural choices of the planted distribution, simple statistics distinguish the random distribution from the planted distribution. While a suitable planted distribution that enables the use of pseudo-calibration may very well exist, we are yet to find one. Instead, in this work, we simply use the na\"ive planted distribution but instead modify the heuristic of pseudo-calibration (that we term \textit{pseudo-calibration with connected trunction}) to construct our candidate moment matrix.
\item The second conceptual difficulty was the lack of good norm bounds for graph matrices built from sparse graphs. In that work, we utilized the trace method with a careful analysis to obtain better norm bounds. Moreover, as we saw in \cref{chap: efron_stein}, we are able to obtain similar norm bounds without the trace method, using our general recursion theorem.
\end{itemize}
Apart from the above developments, we develop several technical tools such as conditioning, a generalization of the intersection tradeoff lemma, etc.
For more details, see \cite{jones2022sum}.
\subsection{Planted Affine Planes and Maximum Cut}\label{sec:open-problems}
For the Planted Affine Planes problem from \cref{chap: sk} where we sampled $m$ vectors $d_1, \ldots, d_m$ independently from $\mathcal{N}(0, I_n)$, we showed an SoS lower bound for $m \le n^{3/2 - \varepsilon}$. However, from the analysis of $\tilde{\EE}[1]$ in \cref{rmk:pe-one}, we expect a lower bound to hold for $m \ll n^{2 - \varepsilon}$. This is because, as we saw in \cref{chap: sos} and which we will revisit in the next section, analyzing $\tilde{\EE}[1]$ is an established way to hypothesize about the power of SoS. Therefore, we conjecture
\begin{conjecture}
\cref{theo:sos-bounds} holds with the bound on the number of sampled vectors $m$ loosened to $m \leq n^{2-\varepsilon}$.
\end{conjecture}
Dual to this (in fact, we exploit the duality in our proof in \cref{chap: sk}), we conjecture an SoS lower bound for the Planted Boolean Vector problem holds whenever $p \geq n^{1/2+\varepsilon}$.
\begin{conjecture}
\cref{theo:boolean-subspace} holds with the bound on the dimension $p$ of a random subspace
loosened to $p \geq n^{1/2+\varepsilon}$.
\end{conjecture}
We remark that recent work \cite{zadik2021latticebased} has exhibited a polynomial time for the search variant of Planted Affine Planes for $m \ge n + 1$, as opposed to prior known algorithms that required $m \gg n^2$ \cite{mao2021optimal}. The algorithm in \cite{mao2021optimal} is spectral and robust to noise, moreover it is likely captured by SoS. On the other hand, the algorithm in \cite{zadik2021latticebased} is lattice-based and is not robust to noise, (i.e. it assumes that all vectors must exactly lie in the two planes), and is not captured by SoS.
In our SoS lower bounds for the Planted Boolean Vector problem and the Planted Affine Planes problem, we assumed that the input entries were chosen i.i.d Gaussian or Boolean. In fact, it's plausible that our proof techniques go through when the distribution is ``random enough'', such as the uniform distribution from the sphere. One potential extension of this intuition is as follows: In the Planted Boolean Vector problem, if the subspace is the eigenspace of the bottom
eigenvectors of a random adjacency matrix, the instance should still be
difficult. This last setting arises in Maximum Cut, for which we conjecture the following.
\begin{conjecture}\label{conj: sos_for_max_cut}
Let $d \geq 3$, and let $G$ be a random $d$-regular graph on $n$ vertices. For some $\delta > 0$, w.h.p. there is a degree-$n^\delta$ pseudoexpectation operator $\tilde{\EE}$ on boolean variables $x_i$ with maximum cut value at least
\[ \frac{1}{2} + \frac{\sqrt{d-1}}{d}(1 - \operatorname{o}_{d,n}(1)) \]
\end{conjecture}
The above expression is w.h.p. the value of the spectral relaxation for Maximum Cut, therefore qualitatively this conjecture expresses that degree $n^\delta$ SoS cannot significantly tighten the basic spectral relaxation.
We should remark that, with respect to the goal of showing SoS cannot significantly outperform the Goemans-Williamson relaxation, random instances are not integrality gap instances. The main difficulty in comparing (even degree 4) SoS to the Goemans-Williamson algorithm seems to be the lack of a candidate hard input distribution.
Evidence for this conjecture comes from the fact that the only property
required of the random inputs $d_1, \dots, d_m$ was that norm bounds hold for
the graph matrix with Hermite polynomial entries. When the variables
$\{d_{u,i}\}$ are i.i.d from some other distribution, if we use graph matrices
for the orthonormal polynomials under the distribution and assuming suitable
bounds on the moments of the distribution, the same norm bounds
hold~\cite{ahn2016graph}.
When $d_u$ is sampled uniformly from the sphere or another distribution for which the coordinates are not
i.i.d, it seems likely that
similar norm bounds hold. Moreover, as explained in the previous section, the techniques from \cref{chap: efron_stein} will likely be useful to obtain such norm bounds.
\subsection{Unique Games}
The famous Unique Games conjecture (UGC) \cite{Khot02:unique} postulates that a graph theory problem known as the Unique Games problem is NP-hard. This conjecture gained tremendous traction in the community because of it's numerous consequences (e.g. \cite{Khot02:unique, KhotKMO04, Raghavendra08})) and connections to various other fields such as metric geometry \cite{KhotV05} and discrete Fourier analysis \cite{KR03}. An exciting array of recent works \cite{dinur2018towards, barak2018small, subhash2018pseudorandom} has shown that a problem closely related to unique games, known as $2$-to-$2$ games, is NP-hard. This is an important step towards proving the UGC and offers evidence that the UGC is true.
On the algorithmic side, there have been various attempts (see for e.g. \cite{T05:unique, CharikarMM06, arora2015subexponential}) to disprove the UGC. In particular, Barak et al. \cite{barak2012hypercontractivity} showed that degree $8$ SoS can efficiently solve integrality gap instances of the Unique Games problem that were proposed for linear programs and SDPs considered earlier. This work caused significant interest in the community, since it suggests that SoS might be a way to refute the UGC.
Therefore, it's tremendously important to understand the performance of SoS on the unique games problem. A good first step would be to understand the performance of SoS for the problem of maximum cut, which is a special case of the Unique Games problem. In fact, we can be even more concrete and ask for the performance of SoS for the problem of maximum cut on random graphs, more precisely \cref{conj: sos_for_max_cut}. Lower bounds were shown for degree $2$ and degree $4$ in \cite{MS16, mohanty2020lifting} and generalizing their analyses for higher degree SoS is a nontrivial but important open problem.
\section{Low degree likelihood ratio hypothesis}
As explained in \cref{chap: sos}, the low-degree likelihood ratio hypothesis analytically predicts the computational barriers for hypothesis testing in bounded time, for \textit{sufficiently nice} distributions. See \cite{hop18, kunisky19notes, holmgren2020counterexamples} and references therein for more details. A full proof of this hypothesis is beyond current techniques, since it's likely harder than proving say $P \neq NP$. Despite this, confirming the hypothesis in restricted proof systems is a fascinating and important field for future research. In particular, building on the notation from \cref{chap: sos}, we would like to prove that for sufficiently nice distributions $\nu, \mu$, after pseudo-calibrating, if $\tilde{\EE}[1] = 1 + o(1)$, then there exists an SoS lower bound. Indeed, in this work, we confirm this for several fundamental problems. Proving this in general will go a long way towards understanding the power of bounded-time algorithms.
\section{Technical improvements}
Having covered some general directions for future research, we now specify a few directions for improving some technical aspects of our results.
\subsubsection{Improving parameter dependences}
In many of our lower bounds, we require polynomial decay in the Fourier coefficients. For example, we require a decay of $n^{\varepsilon}$ for each new Fourier character, where $n$ is the input size. This is done to handle various other factors that appear in norm bounds when doing the charging arguments. In the proofs, we term these as vertex or edge decay, corresponding to how they are encoded in the graph matrix arguments we use.
By doing this, we obtain a slightly weaker lower bound. For example, instead of getting a $n^{1/4}$ lower bound (up to polylogarithmic factors) for Tensor PCA, we obtain a $n^{1/4 - \varepsilon}$ lower bound for any $\varepsilon > 0$. In general, while they facilitate the proof, it's not clear that this sort of decay is necessary and it's open to find a tighter analysis so as to close the gap from known upper bounds up to a polylogarithmic factor.
Related to the above discussion, another open problem is to push the degree of SoS higher in our lower bounds. For example, in the Sherrington-Kirkpatrick lower bound, it's open to push the SoS degree from $n^{\varepsilon}$ to $\widetilde{\Omega}(n)$. Our current techniques do not handle this but we expect the lower bound to nevertheless hold.
\subsubsection{Satisfying constraints exactly}
In some of our lower bounds, our planted distributions only approximately satisfy constraints such as having a subgraph of size $k$, having a unit vector $u$, and having $u$ be $k$-sparse. While we would like to use planted distributions which satisfy such constraints exactly, the moment matrix becomes much harder to analyze.
We do resolve it for the Sherrington-Kirkpatrick lower bound by using a rounding technique \cite{ghosh2020sum}.
This same issue also appeared in the SoS lower bounds for planted clique \cite{BHKKMP16}, which was fixed in a recent paper by Pang \cite{Pang21}.
We leave it to future work to resolve this in general.
\section{Implications for Computer Science}
As we saw in the introduction, the current state of affairs in Theoretical Computer Science research seems to be to understand the limits of computation for various problems. Even though there maybe potential ultimate goals such as settling the P vs NP problem or even relatively modest goals such as settling the Unique Games Conjecture, there's much to be learnt and uncovered from this process. For example, for various problems, there seems to be a discernible gap between what's information theoretically possible and what's computationally feasible. Our work adds insight into this intriguing phenomenon, known as the information-computation tradeoff.
However, there are also other questions that need answering. For example, what makes certification seemingly harder than estimation or recovery? Can we characterize the precise property of problems that potentially make them hard or easy for various classes of algorithms such as Sum of Squares?
While much rich structure is slowly being uncovered in this general pursuit, a proper understanding still eludes us.
However, applications of what we've discovered so far, both technically and philosophically, are already numerous in various branches of mathematics and science, therefore research in this field is more than for the sake of mere curiosity.
We hope our work serves as a meaningful progress towards this grand goal.
\section{Certification problems}
As opposed to search or decision problems, certification problems, given an input, ask for a bound on the objective value that holds with probability $1$, along with a certificate of the output bound. The quality of the algorithm is usually measured in terms of how close the bound gets to the true optimum.
In the running example of maximum cut, given a graph, the task could be to output a value that's always an upper bound on the size of the maximum cut. A simple algorithm could be to simply return the total number of edges in the graph. Indeed, this is a valid certification algorithm but we could ask if one could do better.
This is fundamentally a different approach to algorithm design. Consider the scenario when we are maximizing some objective function and so we desire an upper bound on the optimal value. Then, designing a certification algorithm can be construed as attacking a problem from \textit{above} as opposed to from \textit{below}, the latter of which is the more standard notion of algorithm design.
The notion of linear programming relaxations already provide such certification algorithms. Given a problem that can be formulated as an integer program (as many can be), a natural way to obtain a certification solution is to widen the search space from integral variables to real variables, adding other appropriate constraints as necessary. This is known as relaxing the program. This enables a faster algorithm to attempt to compute the solution, but comes at a loss of only obtaining an approximate solution. More importantly, the objective value obtained by the return solution is a definite bound bound on the optimal solution, no matter the input. This is what a certification algorithm desires. Measuring the quality of the returned output often depends on the type of relaxation considered and problem specific structure.
In many cases, it's possible to obtain an approximation algorithm to a problem by looking at a relaxation of the program, obtaining a non-integral solution and rounding it to a valid solution. For the maximum cut problem, this was done by Goemans and Williamson in their seminal work \cite{GW94} where they used a semidefinite programming relaxation, which is more powerful than linear programming relaxations.
In this dissertation, we will focus on a specific class of such certification algorithms, namely the Sum of Squares (SoS) hierarchy, sometimes referred to as the Lasserre hierarchy. The SoS hierarchy is a series of convex relaxations to a given program. By virtue of being a relaxation, they can be used for certification.
Due to it's tremendous success for various fundamental optimization problems such as maximum cut, constraint satisfaction, etc., the SoS hierarchy has become a powerful optimization technique. This is further amplified by results that say that the SoS hierarchy is the optimal relaxation among a broad class of semidefinite programming relaxations \cite{lrs15}, and assuming the famous unique games conjecture, it's the best approximation algorithm for every constraint satisfaction problem \cite{Raghavendra08}.
A chief goal of this dissertation is to understand the limits of this powerful technique. We especially focus on the so-called average-case setting, that we will define now.
\section{Average-case analysis}
An important theme in this work is the study of random instances of problems, which is termed average-case analysis. As opposed to traditional worst-case algorithm design, where we wish to design an algorithm that performs well on the worst possible input, there has been an exciting development of research on problems where the input is randomly sampled from a distribution. For instance, in the maximum cut problem, we could assume that the input comes from the Erd\H{o}s\xspace-R\'enyi\xspace family of random graphs, where the number of vertices in the graph is chosen beforehand and each edge is present independently with probability $0.5$.
In average-case algorithm design, we wish to design algorithms that perform well on average-case inputs with high probability, as opposed to all inputs.
This is important because studying the worst case complexity of a problem may not shed light on the intrinsic hardness of the problem. This happens because the worst-case instance input for an algorithm could be highly artificial and contrived. Put another way, in real world scenarios, the inputs for various optimization or search problems we encounter are unlikely to be such instances. This is seen in practice as well. For example, the simplex method for linear programming \cite{dantzig2016linear} is exponentially slow in the worst-case, as was shown by Klee and Minty \cite{klee1972good}, but performs extremely well practically. Various works have tried to explain this behavior, e.g. \cite{borgwardt1982average, smale1983average, borgwardt1988probabilistic, spielman2004smoothed}, a highlight is the work of Spielman and Teng for which they were awarded the G\"{o}del\xspace prize in 2008.
Tremendous effort has been invested to understand the average-case complexity for a wide variety of problems. Research towards designing average-case algorithms brings about a deeper understanding of the core of the problem, enabling the design of worst-case algorithms as well. This can be seen for example for the famous Densest $k$-subgraph problem \cite{bhaskara2010detecting}. In this work, we will focus on average-case analysis.
In our pursuit, fundamental mathematical objects that occur repeatedly are large random matrices. We often desire to understand their behavior.
\section{Underlying theme of this work: Random matrices}
Random matrices are abundant in computer science, especially in the fields of optimization and statistics. Often, the analysis of an algorithm requires analyzing the behavior of certain random matrices that can be constructed from the input. Even outside computer science, random matrix theory is a fundamental field of it's own right, having been studied since the early $1900$s, with applications also extending to many branches of mathematics and physics. For a short survey, see \cite{forrester2003developments}.
There has been tremendous effort over the last few decades to develop the theory of random matrices, see the book by Tropp \cite{tropp2015:book}. For example, the matrix-Bernstein inequality studies the behavior of a random weighted sum of matrices; the Wigner semicircle law studies the distribution of the eigenvalues of a random matrix sampled from the Gaussian Orthogonal ensemble. On the other hand, fewer tools are available to understand the behavior of nonlinear random matrices, where each matrix entry is a nonlinear function of the input, say for instance low-degree polynomials.
In our setting, this occurs frequently when trying to analyze the SoS hierarchy for various problems. This is true both when trying to design algorithms via SoS as well as when trying to study the limitations of SoS algorithms, for example, \cite{barak2012hypercontractivity, hopkins2015tensor, schramm2017fast, moitra2019spectral, jones2022sum}. Therefore, we begin with this important endeavor of understanding the behavior of nonlinear random matrices. In the first part of this thesis, we are interested specifically in concentration behavior. We emphasize that this is an important research direction in it's own right.
To bound the fluctuations of a random matrix from its mean, measured in terms of spectral or Schatten $t$-norm of the difference, a simple but powerful technique that has been widely used (including in many of the works cited above) is the so-called trace method. In this method, the (centered) random matrix is raised to a large power and the expected trace of the resulting matrix is bounded. While this method gives satisfactory results, it often requires ingenious observations and highly nontrivial combinatorics.
Another approach is as follows. Consider a random matrix that is a function of several independent input variables. We can study it's behavior by studying how much it deviates when a single uniformly chosen input entry is resampled. By bounding these local fluctuations, we can bound the global fluctuation of the random matrix.
This technique gives rise to the Efron-Stein inequalities. Originally, they were developed for scalar random variables (which can be thought of as $1 \times 1$ matrices). In this special case, they turned out to be extremely powerful since they have been shown to recover many standard concentration inequalities. Recently, the work \cite{paulin2016} showed a matrix version of the Efron-Stein inequalities.
In this work, we build on this to obtain a general framework for proving concentration of large random matrices.
In the second part of this thesis, in the analysis of SoS algorithms, the fundamental difficulty that appears is to analyze the behavior of a large nonlinear random matrix. In particular, we want to argue that this random matrix is positive semidefinite with high probability over the choice of the input. For this, we exhibit an approximate Cholesky decomposition of the matrix and the proof extensively builds on the concentration results we develop above.
In conclusion, the motif in this work is the study of nonlinear random matrices, where we both build a general framework for analyzing concentration and apply them to study algorithms on fundamental problems.
\section{The Sum of Squares Hierarchy}
Given an optimization problem in the form of a program with polynomial inequality constraints, there have been many works proposing generic approaches to relax the program, in order to obtain good solutions efficiently. Some of the more dominant approaches have been the Lov\'asz\xspace-Schrijver hierarchy \cite{LoS91} and the Sherali-Adams hierarchy \cite{SA90}. Informally speaking, these hierarchies of algorithms lift the program to a larger set of variables, tied together via various constraints, relax and solve the larger program, and finally project the solution down to the original variable space. They are parameterized by an integer known as the degree, where larger degrees offer tighter relaxations at the cost of larger running times.
The Sum of Squares (SoS) hierarchy is a similar optimization technique that harnesses the power of semidefinite programming. For polynomial optimization problems, the SoS hierarchy, first independently investigated by Shor \cite{shor1987approach}, Nesterov \cite{nesterov2000squared}, Parillo \cite{parrilo2000structured}, Lasserre \cite{lasserre2001global} and Grigoriev \cite{grigoriev2001complexity, Grigoriev01}, offers a sequence of convex relaxations parameterized by an integer called the degree of the SoS hierarchy.
As we increase the degree $d$ of the hierarchy, we get progressively stronger convex relaxations which are solvable in $n^{O(d)}$ time.
This has paved the way for the SoS hierarchy to be almost a blackbox tool for algorithm design. As has been shown in multiple works, it serves as a strong algorithm for various problems, both in the worst case and the average case settings.
Consider our running example of the Maximum Cut problem. The seminal Goemans-Williamson algorithm \cite{GW94:stoc} achieves an approximation factor of $\approx 0.878$ for this problem via a semidefinite programming relaxation. As it turns out, this algorithm is just the degree $2$ SoS hierarchy. This approximation factor is conjectured to be optimal and there has been increasing evidence that this is indeed the case. This highlights an example of why the SoS hierarchy is powerful.
Indeed, there has been tremendous success in using the SoS hierarchy to obtain efficient algorithms for combinatorial optimization problems (e.g., \cite{GW94, AroraRV04, GuruswamiS11, raghavendra2017strongly}) as well as problems stemming from Statistics and Machine Learning (e.g., \cite{barak2012hypercontractivity, bks15, HopSS15, pot17, kothari2017outlier}). In fact, SoS achieves the state-of-the-art approximation guarantees for many fundamental problems such as Sparsest Cut \cite{AroraRV04}, Maximum Cut \cite{GW94}, Tensor PCA \cite{HopSS15} and all Max-$k$-CSPs \cite{Raghavendra08}. As mentioned earlier, for a large class of problems, it's been shown that SoS relaxations are the most efficient among all semidefinite programming relaxations \cite{lrs15}.
The term ``Sum of Squares'' comes from a dual view in proof complexity.
Besides being an algorithmic technique, SoS can be equivalently viewed as giving a proof or certificate of a bound on the optimal value of a polynomial optimization problem.
This work can be traced back to Hilbert's seventeeth problem which has led to work on a proof complexity result known as the Positivstellensatz, which gives conditions under which polynomial systems can be shown to have no solutions, see e.g. \cite{stengle1974nullstellensatz, putinar1993positive, reznick2000some}. The algorithmic implications were originally observed by Lasserre \cite{lasserre2001global} and Parillo \cite{parrilo2000structured, parrilo2003semidefinite} leading to the interpretation of SoS as an optimization technique as we study in this work.
This duality can be completely formalized and has led to the so-called framework of ``proofs to algorithms'' that has achieved tremendous success, especially recently in robust statistics, see e.g., \cite{kothari2017outlier, karmalkar2019list, hopkins2020mean, bakshi2021robust}. The adage is that if we can find an ``easy'' proof of an identifiability result for a search problem, then it can be automatized to give an algorithm.
We will not explore this in detail here, and we refer the reader to the monograph \cite{FKP19}.
Next, we move onto SoS lower bounds but before that, we highlight some related techniques that has gained traction in the community recently.
\subsection{Related Algorithmic Techniques}\label{subsec: related_techniques}
Apart from search, decision and certification, researchers have also considered other related types of problems. Consider a problem where the input is sampled from one of two known distributions and we would like to identify which distribution it was sampled from. This is known generally as hypothesis testing. For example, one distribution could be the distribution of Erd\H{o}s\xspace-R\'enyi\xspace random graphs while the other could be the distribution of Erd\H{o}s\xspace-R\'enyi\xspace random graphs but with a large cut planted in them. It's clear that this problem is a different flavor of the maximum cut problem on random graphs. Beyond being interesting in their own right, studying these related formulations offer alternate perspectives and interesting insights into the search or certification variants as well.
Another type of problem, known as recovery problems, is to recover the planted structure when the input is sampled from the latter distribution.
For all the type of problems considered so far, apart from SoS, there have also been several other framework of algorithms that have been considered and in some cases, extensively studied. Examples include
\begin{itemize}
\item Lov\'asz\xspace-Schrijver and Sherali-Adams hierarchies --- As discussed earlier, these hierarchies lift a program to a larger set of variables and then relax any integrality constraints. The resulting solution is then projected back to the original variables which may then be rounded to an integral solution. These hierarchies are captured by the SoS hierarchy, or in other words, the SoS hierarchy is at least as powerful as these hierarchies \cite{FKP19}.
\item Low degree polynomials --- For hypothesis testing, low degree polynomials can be used to try and distinguish the two distributions. More precisely, if there is a low degree polynomial such that its expected value on the two distributions behave differently and the variance isn't too large, this can be used to distinguish the two distributions. This is related to the SoS hierarchy and we will revisit this point in more detail later.
\item Statistical query algorithms --- For hypothesis testing, the statistical query model (SQ) is another popular restricted class of algorithms introduced by \cite{kearns1998efficient}. In this model, for an underlying distribution, we can access it indirectly by querying expected values of functions, up to some error.
Given access to this oracle, we would like to hypothesis test. SQ algorithms capture a broad class of algorithmic techniques in statistics and machine learning including spectral methods, moment and tensor methods (see e.g. \cite{feldman2017statistical, feldman2021statistical}). SQ algorithms has also been used to study information-computation tradeoffs and more broadly has been studied in other contexts \cite{Feldman2016}. There has also been significant work trying to understand the limits of SQ algorithms (e.g. \cite{feldman2017statistical, feldman2018complexity, diakonikolas2017statistical}). Recent work \cite{brennan2020statistical} has shown that low degree polynomials and statistical query algorithms have equivalent power under mild conditions.
\item Approximate message passing and other statistical physics techniques such as belief propagation, see e.g. the review \cite{zdeborova2016statistical}.
\item Local algorithms, see e.g. \cite{elek2010borel, fan2017well, hoppen2018local}.
\item Circuit models of computation of bounded size, see e.g. \cite{rossman2010average, rossman2014monotone}.
\end{itemize}
\section{Lower bounds against the Sum of Squares Hierarchy}
Because of the incredible success of the SoS hierarchy for a variety of problems, it's an important research direction to study the limits of the SoS hierarchy, which we endeavour in this dissertation. In particular, we will focus on average-case problems and as we will see, most of the technical difficulty boils down to the analysis of nonlinear random matrices, to handle which we develop various techniques.
There are many reasons for why studying lower bounds against the SoS hierarchy is important. The SoS hierarchy is general enough to capture a broad class of algorithmic reasoning \cite{FKP19}. In particular, SoS captures the Lov\'asz\xspace-Schrijver and Sherali-Adams hierarchies and under mild restrictions, also statistical query algorithms and algorithms based on low degree polynomials. Therefore, SoS lower bounds indicate to the algorithm designer the intrinsic hardness of the problem and suggest that if they want to break the algorithmic barrier, they need to search for algorithms that are not captured by SoS. Secondly, in average case problem settings, standard complexity theoretic assumptions such as P $\neq$ NP have not been shown to give insight into the limits of efficient algorithms. Instead, lower bounds against powerful techniques such as SoS have served as strong evidence of computational hardness \cite{hop17, hop18}. Thus, understanding the power of the SoS hierarchy on these problems is an important step towards understanding the approximability of these problems. See also the surveys \cite{BS14:ICM, moitra2020sum} for more on this.
There have been relatively fewer works on SoS lower bounds, as opposed to some other classes of algorithms we have discussed, which can be attributed to the sheer technical difficulty of proving such lower bounds. For example, the works \cite{Grigoriev01, Schoenebeck08, KothariMOW17} studied SoS lower bounds for random constraint satisfaction problems. A series of works \cite{feige2000finding, meka2015sum, deshpande2015improved, BHKKMP16, Pang21} studied SoS lower bounds for maximum clique on random graphs. Some other SoS lower bounds, not including the ones in this thesis, are the works \cite{ma_wigderson_15, kothari2018sum, mohanty2020lifting, kunisky2020, kothari2021stress}.
\section{A summary of our main results}
In the first part of this work, we study concentration behavior of nonlinear random matrices. In the second part, we study lower bounds against the SoS hierarchy for several fundamental problems.
\subsection{Nonlinear matrix concentration via Matrix Efron-Stein}
We start by giving a general theorem on concentration of random matrices whose entries are polynomials of independent random variables. The famous matrix-Bernstein inequality answers this question when we only have linear polynomials. However, understanding the setting of non-linear polynomials is just as important yet it poses significant challenges. When they arise in various applications in the literature, the usual way to handle such random matrices has been the so-called trace method. While this method gives the desired results, sometimes to great effect, applying it usually turns out to be highly nontrivial. In this work, we propose an alternate way to prove matrix concentration via the Matrix Efron-Stein inequalities. We propose a general matrix concentration inequality, the proof of which relies on the powerful method of exchangeable pairs. We show some applications of this inequality and expect it to have significant applications outside what we have explored here.
\subsection{Sum of Squares lower bounds}
We obtain strong sub-exponential time lower bounds against the SoS hierarchy for a variety of fundamental problems in computer science. All our applications start with the so-called pseudocalibration heuristic, reducing the problem to analyzing the behavior of a large random matrix, known as the \textit{moment matrix}. Our conceptual and technical innovations happen at this step. The results we present are as follows.
\subsubsection{Sherrington-Kirkpatrick Hamiltonian}
An important problem in statistical physics, the Sherrington-Kirkpatrick problem is to optimize the quadratic form of a random matrix sampled from the Gaussian Orthogonal Ensemble, over boolean vectors. It's been known for a long time that the true optimal value concentrates at a particular constant, up to scaling. Recently, an efficient algorithm was proposed for this optimization problem. Certification on the other hand was widely believed to be hard beyond the simple spectral algorithm. We provide strong evidence for this by exhibiting lower bounds against SoS for this problem. This work requires us to understand the nullspace of the moment matrix and \textit{nullify it} before applying our matrix concentration tools. Conceptually, this work provides a lot of insight into the behavior of SoS on other fundamental problems such as maximum cut and learning mixtures of Gaussians.
\subsubsection{Sparse PCA}
Sparse PCA is a variant of principal components analysis (PCA), a fundamental routine in statistics and machine learning. We work with the spiked Wishart model, which is the most natural version of this problem, but which has proved quite hard to analyze in SoS.
Prior works have predicted the computational barrier of the recovery of the sparse component, as a tradeoff between the dimension, sparsity and number of samples. We confirm this barrier by proving lower bounds, matching known algorithms, against sub-exponential time SoS. This work involves splitting the random moment matrix into different matrices and using innovative combinatorial charging arguments to study how these matrices interact with each other. Conceptually, this work confirms the computational barrier diagram for this problem, that has been predicted and believed to be true for a long time.
\subsubsection{Planted Slightly Denser subgraph}
Finding a dense subgraph in a given graph is an important problem that has received much scrutiny over the years, both algorithmically as well as from the algorithmic hardness angle. For random instances of the problem under certain parameter regimes, the difficulty of this problem has been conjectured, usually referred to as the PDS conjecture, and this problem has been used as a canonical hard problem to reduce to various other problems and study their computational barriers. Moreover, these hard instances have also been used as a basis for cryptographic schemes.
Therefore, SoS lower bounds against this problem go a long way towards confirming this conjecture. In this work, we exhibit such sub-exponential time lower bounds for certain parameter regimes, where it has been widely believed to require sub-exponential time.
\subsubsection{Tensor PCA}
Tensor PCA is the average-case version of the problem of optimizing homogeneous polynomials over the sphere, which is a fundamental and important problem in optimization due to it's connections to a variety of fields. In this work, we prove SoS lower bounds matching known algorithms for this problem, settling the computational barrier for SoS for this problem. It also offers insight on the approximability-inapproximability threshold for general homogeneous polynomial optimization and suggests that random instances may not be the hardest for this problem.
\section{Excluded work}
This dissertation contains the main body of my research conducted during my PhD but there have also been other research directions that have been left out, regrettably. This includes the following works.
\subsection{SoS Lower bounds for Sparse Independent Set}
In our work \cite{jones2022sum}, we show SoS lower bounds for the maximum independent set problem on sparse Erd\H{o}s\xspace-R\'enyi\xspace random graphs, matching the Lov\'asz\xspace theta function up to low order terms. To do this, we build on the tools developed in this dissertation as well as develop a variety of new techniques. In particular, this work is the first venture in the important research direction of understanding the limitations of SoS on sparse random graphs. We highlight that for this work, our nonlinear matrix concentration tools from \cref{chap: efron_stein} are very useful. We will elaborate on this result in \cref{chap: future_work} since it builds on much of the work we will develop in this dissertation.
\subsection{Causal Inference }
Causal inference is the study of discovering and understanding causal relationships in observed data, which has diverse applications in medicine, genetics, economics, epidemics, artificial intelligence, etc. In our work \cite{rajendran2021structure}, we focus on the problem of learning a class of causal models known as Bayesian Networks (BN), from data. This is a classical and fundamental problem since BNs are compact, modular and offer intuitive causal interpretation, which has made them very useful in various fields. We propose and study a new practical algorithm for this problem. It is efficient, provably differs from the widely used Greedy-Equivalence-Search algorithm, and since the algorithm is a general-purpose score-based learning algorithm, it is widely applicable. Also, under some statistical assumptions that are inspired from and which generalize recent works, our algorithm provably recovers the true Bayesian Network, even for non-parametric models, while making no assumptions on linearity, additivity, independent noise or faithfulness. It also suggests interesting potential connections to other machine learning fields such as clustering, forward-backward greedy methods, and kernel methods.
\subsection{Latent Variable modeling}
In our work \cite{kivva2021learning}, we study a relatively understudied but important problem of latent variable modeling of observed data. Building from the previous section, we now have unobserved (sometimes even unmeasurable!) latent causes or confounders for the observed variables. We focus on the setting of probabilistic mixture models, which naturally comes up in machine learning, economics, finance, biology, etc. Under some natural assumptions on the model, we develop an algorithm that takes the observed data and uncovers the hidden variables and the underlying causal relationships. Prior works related to this problem have usually focused on special settings such as linear models. We instead propose an algorithm to this problem in the highly nonlinear mixture models setting which works atop existing algorithms for mixture model order estimation (which is easier than density estimation).
\subsection{Causal representation learning}
An exciting new branch of machine learning, known as causal representation learning, takes as input raw, unstructured data, and aims to learn the underlying generative model that generated it. On top of this, it also aims to learn the causal relationships among the learnt latent variables, hence the name causal representation learning. In particular, this field brings together ideas from two fields which have largely developed separately, namely causal inference and latent variable modeling, the two topics described above. In our work \cite{kivva2022identifiability}, we prove an interesting and surprising result in this direction. We show that a broad class of generative models with a mixture of Gaussians prior is identifiable (which means it can be recovered from raw data). In particular, our models have universal approximation capabilities and have been used extensively (without theoretical validation) in many practical works on deep representation learning \cite{dilokthanakul2016deep, jiang2016variational, willetts2021don}.
In deep learning, there has been tremendous effort to identify the latent features and the mechanisms that generate observed data. Instead of handcrafting low level features of data, this process is largely automated via algorithms that learn low level representations. The models thus learnt are quite useful for a variety of downstream tasks such as sampling, prediction, classification, clustering, interventions, etc. A prominent player here is variational autoencoders \cite{kingma2013auto, rezende2014stochastic}. Various improvements to variational autoencoders have been made over the last decade, with a wide variety of applications. A much-desired property of the training process is stability, i.e. whether repeated trainings will lead to the same latent variable generative model. This can be captured by the mathematical notion of identifiability, which is a crucial primitive which guarantees that there is a unique parameter and generation mechanism that could have generated the data. Putting computational feasibility aside, identifiability is a necessary condition for stable and repeatable training. Apart from stability of training, this also paves the way for other important considerations in machine learning, such as the increasing need to learn representations of data that are robust, interpretable, explainable and fair.
In our work \cite{kivvaidentifiability}, we show that for commonly used variational autoencoders with a mixture of Gaussians prior, identifiability holds under the assumption that the warping mechanism is affine (in particular, deep neural networks with ReLU activations satisfy this property) and importantly, without assuming that auxiliary information is available. This significantly improves upon a flurry of recent works (initiated by \cite{khemakhem2020variational}) that have shown identifiability in the presence of auxiliary variables or side information. Also, several prior works have made empirical observations that a mixture of Gaussians prior often leads to stable and repeatable training for variational autoencoders, thereby suggesting identifiability. Our work theoretically grounds these observations.
\section{Organization of the thesis}
In \cref{chap: efron_stein}, we develop our nonlinear matrix concentration results and show it's applications towards various nonlinear random matrices that have arisen in the literature. We then introduce the Sum of Squares hierarchy in \cref{chap: sos}, introduce the technique of pseudocalibration used for showing SoS lower bounds and show it's connections to low-degree algorithms. In \cref{chap: main_results}, we formally state the main SoS lower bounds we show in this thesis and put them in context with known prior works. In \cref{chap: sk}, we prove the SoS lower bound for the Sherrington-Kirkpatrick problem. In the next two chapters, \cref{chap: qual} and \cref{chap: quant}, we prove the SoS lower bounds for Planted Slightly Denser Subgraph, Tensor PCA and Sparse PCA. We conclude with follow-up and potential future works in \cref{chap: future_work}.
\subsection{Our contributions}
In this paper, we consider the following general category of problems: Given a random input, can we certify that it does not contain a given structure?
Some important examples of this kind of problem are as follows.
\begin{enumerate}
\item Planted clique: Can we certify that a random graph does not have a large clique?
\item Tensor PCA: Given an order $k$ tensor $T$ with random independent Gaussian entries, can we certify that there is no unit vector $x$ such that $\ip{T}{x \otimes\ldots\otimes x}$ is large?
\item Wishart model of sparse PCA: Given an $m \times d$ matrix $S$ with random independent Gaussian entries (which corresponds to taking $m$ samples from $\mathcal{N}(0, I_d)$), can we certify that there is no $k$-sparse unit vector $x$ such that $\norm{Sx}$ is large?
\end{enumerate}
These kinds of problems, known as certification problems, are closely related to their optimization or estimation variants. A certification algorithm is required to produce a proof/certificate of a bound that holds for \textit{all} inputs, as opposed to most inputs. The Sum-of-Squares hierarchy provides such certificates in a canonical way for a wide variety of such problems, so analyzing SoS paves the way towards understanding the certification complexity of these problems. We investigate the following question.
\begin{quote}
\em{For certification problems, what are the best bounds that SoS can certify?}
\end{quote}
In this work, we build general machinery for proving probabilistic Sum of Squares lower bounds on certification problems. To build our machinery, we generalize the techniques pioneered by \cite{BHKKMP16} for proving Sum of Squares lower bounds for planted clique. We start with the standard framework for proving probabilistic Sum of Squares lower bounds:
\begin{enumerate}
\item Construct candidate pseudo-expectation values $\tilde{\EE}$ and the corresponding moment matrix $\Lambda$ (see \cref{subsec: sos}).
\item Show that with high probability, $\Lambda \succeq 0$.
\end{enumerate}
For planted clique, \cite{BHKKMP16} constructed $\tilde{\EE}$ and the corresponding moment matrix $\Lambda$ by introducing the pseudo-calibration technique (see \cref{subsec: pseudocalibration}). They then showed through a careful and highly technical analysis that with high probability $\Lambda \succeq 0$.
In this paper, we investigate how generally the techniques used for planted clique can be applied. We show that by constructing coefficient matrices based on the coefficients obtained by pseudo-calibration, we can give relatively simple conditions on these coefficient matrices which are sufficient to ensure that the moment matrix $\Lambda$ is PSD with high probability.
By abstracting out a lot of the technical analysis that goes into sum of squares lower bound proofs with a general framework, we pave the way for future works on SoS lower bounds to use our machinery as a blackbox and instead focus on the analysis of the problem specific structure. We exhibit the usefulness of our machinery by achieving strong SoS lower bounds for the problems of Tensor PCA, Sparse PCA and a problem closely related to the Planted Clique problem that we call Planted Slightly Denser Subgraph. We do this with relative ease once the machinery is in place. The Sparse PCA lower bounds complement a long line of work on algorithmic guarantees that stretches for over two decades (the most recent one being \cite{sparse_pca_focs20}), giving a complete picture (up to polylogarithmic factors) for the approximability-inapproximability thresholds for Sparse PCA.
\subsubsection{A brief summary of pseudo-calibration}
A natural way to prove lower bounds on a certification problem is as follows.
\begin{enumerate}
\item Construct a "maximum entropy" planted distribution of inputs which has the given structure.
\item Show that we cannot distinguish between the random and planted distributions and thus cannot certify that a random input does not have the given structure.
\end{enumerate}
Based on this idea, the pseudo-calibration technique introduced by \cite{BHKKMP16} constructs candidate pseudo-expectation values $\tilde{\EE}$ so that as far as low degree tests are concerned, $\tilde{\EE}$ for the random distribution mimics the behavior of the given structure for the planted distribution (for details, see \cref{subsec: pseudocalibration}). This gives a candidate moment matrix $\Lambda$ which we can then analyze with our machinery. A majority of known high-degree average-case SoS lower bounds in the literature have pseudo-expectation values that were either obtained by, or could be obtained by pseudocalibration, e.g., Planted Clique \cite{BHKKMP16}, Max-$k$-CSPs \cite{KothariMOW17}, Max-Cut on regular graphs \cite{MRX20}, Sherrington-Kirkpatrick problem \cite{sklowerbounds, MRX20}. It has also been successful for Densest-$k$-subgraph but for the weaker Sherali-Adams Hierarchy \cite{chlamtavc2018sherali}.
Naturally, pseudocalibration is the starting point for our SoS lower bounds. That said, our machinery is quite general and can be applied even if the candidate moment matrix $\Lambda$ is not obtained via pseudo-calibration.
\subsubsection{Our results on Tensor PCA, Sparse PCA, and Planted Slightly Denser Subgraph}
In this section, we formally state the main hardness theorems we show by applying our machinery. We defer discussing prior work, how we improve on them, and other related work to \cref{sec: prior_work}.
We describe the planted distributions we use to show our SoS lower bounds for planted slightly denser subgraph, tensor PCA, and the the Wishart model of sparse PCA. We also state the random distributions for completeness and for contrast. We then state our results.
\paragraph{Planted slightly denser subgraph}
We use the following distributions.
\begin{restatable}{itemize}{PLDSdistributions}
\item Random distribution: Sample $G$ from $G(n, \frac{1}{2})$
\item Planted distribution: Let $k$ be an integer and let $p > \frac{1}{2}$. Sample a graph $G'$ from $G(n, \frac{1}{2})$. Choose a random subset $S$ of the vertices, where each vertex is picked independently with probability $\frac{k}{n}$. For all pairs $i, j$ of vertices in $S$, rerandomize the edge $(i, j)$ where the probability of $(i, j)$ being in the graph is now $p$. Set $G$ to be the resulting graph.
\end{restatable}
In \cref{sec: plds_qual}, we compute the candidate moment matrix $\Lambda$ obtained by using pseudo-calibration on this planted distribution.
\begin{restatable}{theorem}{PLDSmain}\label{thm: plds_main}
Let $C_p > 0$. There exists a constant $C > 0$ such that for all sufficiently small constants $\varepsilon > 0$, if $k \le n^{\frac{1}{2} - \varepsilon}$ and $p = \frac{1}{2} + \frac{n^{-C_p\varepsilon}}{2}$, then with high probability, the candidate moment matrix $\Lambda$ given by pseudo-calibraton for degree $n^{C\varepsilon}$ Sum-of-Squares is PSD.
\end{restatable}
\begin{corollary}\label{cor: plds_main}
Let $C_p > 0$. There exists a constant $C > 0$ such that for all sufficiently small constants $\varepsilon > 0$, if $k \le n^{\frac{1}{2} - \varepsilon}$ and $p = \frac{1}{2} + \frac{n^{-C_p\varepsilon}}{2}$, then with high probability, degree $n^{C\varepsilon}$ Sum-of-Squares cannot certify that a random graph $G$ from $G(n, \frac{1}{2})$ does not have a subgraph of size $\approx k$ with edge density $\approx p$.
\end{corollary}
\paragraph{Tensor PCA}
Let $k \ge 2$ be an integer. We use the following distributions.
\begin{restatable}{itemize}{TPCAdistributions}
\item Random distribution: Sample $A$ from $\mathcal{N}(0, I_{[n]^k})$.
\item Planted distribution: Let $\lambda,\Delta > 0$. Sample $u$ from $\{-\frac{1}{\sqrt{\Delta n}}, 0, \frac{1}{\sqrt{\Delta n}}\}^n$ where the values are taken with probabilites $\frac{\Delta}{2}, 1 - \Delta, \frac{\Delta}{2}$ respectively. Then sample $B$ from $\mathcal{N}(0, I_{[n]^k})$. Set $A = B + \lambda \tens{u}{k}$.
\end{restatable}
In \cref{sec: tpca_qual}, we compute the candidate moment matrix $\Lambda$ obtained by using pseudo-calibration on this planted distribution.
\begin{restatable}{theorem}{TPCAmain}\label{thm: tpca_main}
Let $k \ge 2$ be an integer. There exist constants $C,C_{\Delta} > 0$ such that for all sufficiently small constants $\varepsilon > 0$, if $\lambda \le n^{\frac{k}{4} - \varepsilon}$ and $\Delta = n^{-C_{\Delta}\varepsilon}$ then with high probability, the candidate moment matrix $\Lambda$ given by pseudo-calibration for degree $n^{C\varepsilon}$ Sum-of-Squares is PSD.
\end{restatable}
\begin{corollary}\label{cor: tpca_main}
Let $k \ge 2$ be an integer. There exists a constant $C > 0$ such that for all sufficiently small constants $\varepsilon > 0$, if $\lambda \le n^{\frac{k}{4} - \varepsilon}$, then with high probability, degree $n^{C\varepsilon}$ Sum-of-Squares cannot certify that for a random tensor $A$ from $\mathcal{N}(0, I_{[n]^k})$, there is no vector $u$ such that $\norm{u} \approx 1$ and $\ip{A}{\underbrace{x \otimes\ldots\otimes x}_{\text{k times}}} \approx \lambda$.
\end{corollary}
\paragraph{Wishart model of Sparse PCA}
We use the following distributions.
\begin{restatable}{itemize}{SPCAdistributions}
\item Random distribution: $v_1, \ldots, v_m$ are sampled from $\mathcal{N}(0, I_d)$ and we take $S$ to be the $m \times d$ matrix with rows $v_1, \ldots, v_m$.
\item Planted distribution: Sample $u$ from $\{-\frac{1}{\sqrt{k}}, 0, \frac{1}{\sqrt{k}}\}^d$ where the values are taken with probabilites $\frac{k}{2d}, 1 - \frac{k}{d}, \frac{k}{2d}$ respectively. Then sample $v_1, \ldots, v_m$ as follows. For each $i \in [m]$, with probability $\Delta$, sample $v_i$ from $\mathcal{N}(0, I_d + \lambda uu^T)$ and with probability $1 - \Delta$, sample $v_i$ from $\mathcal{N}(0, I_d)$. Finally, take $S$ to be the $m \times d$ matrix with rows $v_1, \ldots, v_m$.
\end{restatable}
In \cref{sec: spca_qual}, we compute the candidate moment matrix $\Lambda$ obtained by using pseudo-calibration on this planted distribution.
\begin{restatable}{theorem}{SPCAmain}\label{thm: spca_main}
There exists a constant $C > 0$ such that for all sufficiently small constants $\varepsilon > 0$, if $m \le \frac{d^{1 - \varepsilon}}{\lambda^2}, m \le \frac{k^{2 - \varepsilon}}{\lambda^2}$, and there exists a constant $A$ such that $0 < A < \frac{1}{4}$, $d^{4A} \le k \le d^{1 - A\varepsilon}$, and $\frac{\sqrt{\lambda}}{\sqrt{k}} \le d^{-A\varepsilon}$, then with high probability, the candidate moment matrix $\Lambda$ given by pseudo-calibration for degree $d^{C\varepsilon}$ Sum-of-Squares is PSD.
\end{restatable}
\begin{corollary}\label{cor: spca_main}
There exists a constant $C > 0$ such that for all sufficiently small constants $\varepsilon > 0$, if $m \le \frac{d^{1 - \varepsilon}}{\lambda^2}, m \le \frac{k^{2 - \varepsilon}}{\lambda^2}$, and there exists a constant $A$ such that $0 < A < \frac{1}{4}$, $d^{4A} \le k \le d^{1 - A\varepsilon}$, and $\frac{\sqrt{\lambda}}{\sqrt{k}} \le d^{-A\varepsilon}$, then with high probability, the degree $d^{C\varepsilon}$ degree Sum-of-Squares cannot certify that for a random $m \times d$ matrix $S$ with Gaussian entries, there is no vector $u$ such that $u$ has $\approx k$ nonzero entries, $\norm{u} \approx 1$, and $\norm{Su}^2 \approx m + m{\Delta}\lambda$.
\end{corollary}
\begin{remark}
Note that our planted distributions only approximately satisfy constraints such as having a subgraph of size $k$, having a unit vector $u$, and having $u$ be $k$-sparse. While we would like to use planted distributions which satisfy such constraints exactly, these distributions don't quite satisfy the conditions of our machinery. This same issue appeared in the SoS lower bounds for planted clique \cite{BHKKMP16}. Resolving this issue is a subtle but important open problem.
\end{remark}
\subsection{Relation to prior work on Planted Clique/Dense Subgraph, Tensor PCA, and Sparse PCA}\label{sec: prior_work}
\subsubsection{Planted Dense Subgraph}\label{sec: plds}
In the planted dense subgraph problem, we are given a random graph $G$ where a dense subgraph of size $k$ has been planted and we are asked to find this planted dense subgraph.
This is a natural generalization of the $k$-clique problem \cite{karp1972reducibility} and has been subject to a long line of work over the years (e.g. \cite{feige1997densest, feige2001dense, khot2006ruling, bhaskara2010detecting, bhaskara2012polynomial, braverman2017eth, manurangsi2017almost}).
In this work, we consider the following certification variant of planted dense subgraph.
\begin{quote}
\em{Given a random graph $G$ sampled from the Erd\H{o}s\xspace-R\'enyi\xspace model $G(n, \frac{1}{2})$, certify an upper bound on the edge density of the densest subgraph on $k$ vertices.}
\end{quote}
For many different parameter regimes of the random and planted distributions (an example being planting $G_{k, q}$ in $G_{n, p}$ for constants $p < q$), and when $k = o(\sqrt{n})$, the hardness of the easier distinguishing version of planted dense subgraph problem has been posed as formal conjecture (often referred to as the PDS conjecture) before in the literature (see e.g., \cite{hajek2015computational, chen2014statistical, brennan2018reducibility, brennan2019universality}). This has also led to many reductions to other problems \cite{brennan2019optimal}, although it's not clear if these reductions can be made in the SoS framework without loss in the parameter dependence.
In our case, we consider the slightly planted denser subgraph version where for $k \le n^{\frac{1}{2} - \varepsilon}$, we plant a subgraph of density $\frac{1}{2} + \frac{1}{n^{O(\varepsilon)}}$, i.e. $p = \frac{1}{2}, q = \frac{1}{2} + \frac{1}{n^{O(\varepsilon)}}$. This has been widely believed to require sub-exponential time. Our work provides strong evidence towards this by exhibiting unconditional lower bounds against the powerful SoS hierarchy, even if we consider $n^{O(\varepsilon)}$ levels, which corresponds to $n^{n^{O(\varepsilon)}}$ running time! We expect this to lead to this problem being used as a natural starting point for reductions to show sub-exponential time hardness for various problems.
Within the SoS literature, \cite{BHKKMP16} show that for $k \le n^{\frac{1}{2} - \varepsilon}$ for a constant $\varepsilon > 0$, the degree $o(\log n)$ Sum-of-Squares cannot distinguish between a fully random graph sampled from $G(n, \frac{1}{2})$ from a random graph which has a planted $k$-clique. This implies that degree $o(\log n)$ SoS cannot certify an edge density better than $1$ for the densest $k$-subgraph if $k \le n^{\frac{1}{2} - \varepsilon}$.
In \cref{cor: plds_main}, we show that for $k \le n^{\frac{1}{2} - \varepsilon}$ for a constant $\varepsilon > 0$, degree $n^{\Omega(\varepsilon)}$ SoS cannot certify an edge density better than $\frac{1}{2} + \frac{1}{n^{O(\varepsilon)}}$. The degree of SoS in our setting, $n^{\Omega(\varepsilon)}$ is vastly higher than the earlier known result which uses degree $o(\log n)$. To the best of our knowledge, this is the first result that proves such a high degree lower bound.
We remark that when we take $k = n^{\frac{1}{2} - \varepsilon}$, the true edge density of the densest $k$-subgraph is $\frac{1}{2} + \frac{\sqrt{\log(n/k)}}{\sqrt{k}} + \operatorname{o}(\frac{1}{\sqrt{k}}) \approx \frac{1}{2} + \frac{1}{n^{1/4 - \varepsilon/2}}$ as was shown in \cite[Corollary 2]{gamarnik2019landscape} whereas, by \cref{cor: plds_main}, the SoS optimum is as large as $\frac{1}{2} + \frac{1}{n^{\varepsilon}}$. This highlights a significant difference in the optimum value.
\subsubsection{Tensor PCA}
The Tensor Principal Component Analysis problem, originally introduced by \cite{richard2014statistical}, is a generalization of the PCA problem from machine learning to higher order tensors. Given an order $k$ tensor of the form $\lambda u^{\otimes k} + B$ where $u \in {\mathbb R}^n$ is a unit vector and $B \in {\mathbb R}^{[n]^k}$ has independent Gaussian entries, we would like to recover $u$. Here, $\lambda$ is known as the signal-to-noise ratio.
This can be equivalently considered to be the problem of optimizing a homogenous degree $k$ polynomial $f(x)$, with random Gaussian coefficients over the unit sphere $\norm{x} = 1$. In general, polynomial optimization over the unit sphere is a fundamental primitive with a lot of connections to other areas of optimization (e.g. \cite{frieze2008new, brubaker2009random,brandao2017quantum, barak2014rounding, bks15, bhattiprolu2017weak}). Tensor PCA is an average case version of the above problem and has been studied before in the literature \cite{richard2014statistical, HopSS15, tensorpca16, hop17}. In this work, we consider the certification version of this average case problem.
\begin{quote}
\em{For an integer $k \ge 2$, given a random tensor $A \in {\mathbb R}^{[n]^k}$ with entries sampled independently from $\mathcal{N}(0, 1)$, certify an upper bound on $\ip{A}{x^{\otimes k}}$ over unit vectors $x$.}
\end{quote}
In \cite{tensorpca16}, it was shown that $q \le n$ levels of SoS certifies an upper bound of $\frac{2^{O(k)} (n \cdot \text{polylog}(n))^{k/4}}{q^{k/4 - 1/2}}$ for the Tensor PCA problem. When $q = n^{\varepsilon}$ for sufficiently small $\varepsilon$, this gives an upper bound of $n^{\frac{k}{4} - O(\varepsilon)}$. \cref{cor: tpca_main} shows that this is tight.
In \cite{hop17}, they state a theorem similar to \cref{cor: tpca_main} and observe that it can be proved by applying the techniques used to prove the SoS lower bounds for planted clique. However, they do not give an explicit proof. Also, while they consider the setting where the random distribution has entries from $\{-1, 1\}$, we work with the more natural setting where the distribution is $\mathcal{N}(0, 1)$. We remark that our machinery can also easily recover their result with the entries being restricted to $\{-1, 1\}$.
When $k = 2$, the maximum value of $\ip{\tens{x}{k}}{A}$ over the unit sphere $\norm{x}^2 = 1$ is precisely the largest eigenvalue of $(A + A^T)/2$ which is $\Theta(\sqrt{n})$ with high probability. For any integer $k \ge 2$, the true maximum of $\ip{\tens{x}{k}}{A}$ over $\norm{x}^2 = 1$ is $O(\sqrt{n})$ with high probability \cite{tomioka2014}. In contrast, by \cref{cor: tpca_main}, the optimum value of the degree $n^{\varepsilon}$ SoS is as large as $n^{\frac{k}{4} - O(\varepsilon)}$. This exhibits an integrality gap of $n^{\frac{k}{4} - \frac{1}{2} - O(\varepsilon)}$.
\subsubsection{Wishart model of Sparse PCA}
The Wishart model of Sparse PCA, also known as the Spiked Covariance model, was originally proposed by \cite{johnstone_lu2009}. In this problem, we observe $m$ vectors $v_1, \ldots, v_m \in {\mathbb R}^d$ from the distribution $\mathcal{N}(0, I_d + \lambda uu^T)$ where $u$ is a $k$-sparse unit vector, and we would like to recover $u$. Here, the sparsity of a vector is the number of nonzero entries and $\lambda$ is known as the signal-to-noise ratio.
Sparse PCA is a fundamental problem that has applications in a diverse range of fields (e.g. \cite{wang2012online, naikal2011informative, majumdar2009image, tan2014classification, chun2009expression, allen2011sparse}). It's known that vanilla PCA does not yield good estimators in high dimensional settings \cite{baik2005phase, paul2007asymptotics, johnstone_lu2009}. A large volume of work has gone into studying Sparse PCA and it's variants, both from an algorithmic perspective (e.g. \cite{amini_wainwright2008, ma2013sparse, krauthgamer2015, deshpande2016, wang2016statistical}) as well as from an inapproximability perspective (e.g. \cite{berthet2013complexity, ma_wigderson_15, diakonikolas2017statistical, hop17, brennan2019optimal}).
Given the decades of research on this problem and how fundamental it is for a multitude of applications and disciplines, understanding the computational threshold behavior of the Wishart model of Sparse PCA is an extremely important research topic in statistics. In particular, prior works have explored statistical query lower bounds, SDP lower bounds, lower bounds by reductions from widely believed conjectures, etc. On the other hand, there have only been two prior works on lower bounds against SoS, specifically only for degree $2$ and degree $4$ SoS, which can be attributed to the difficulty in proving such lower bounds. In this paper, we vastly strengthen these lower bounds and show almost-tight lower bounds for the SoS hierarchy of degree $d^{\varepsilon}$ which corresponds to a running time of $d^{d^{O(\varepsilon)}}$.
Between this work and prior works, we completely understand the parameter regimes where sparse PCA is easy or conjectured to be hard up to polylogarithmic factors. In \cref{fig: spca_thresholds}, we classify the different parameter regimes into the following categories.
\begin{itemize}
\item DT: In this regime, Diagonal thresholding \cite{johnstone_lu2009, amini_wainwright2008} recovers the sparse vector. Covariance thresholding \cite{krauthgamer2015, deshpande2016} and SoS \cite{sparse_pca_focs20} can also be used in this regime. Covariance thresholding has better dependence on logarithmic factors and SoS works in the presence of adversarial errors.
\item PCA: Vanilla PCA can recover the vector, i.e. we do not need to use the fact that the vector is sparse (see e.g. \cite{berthet2013, sparse_pca_focs20}).
\item Spectral: An efficient spectral algorithm recovers the sparse vector (see e.g. \cite{sparse_pca_focs20}).
\item Spectral*: A simple spectral algorithm distinguishes the planted distribution from the random distribution but it is information theoretically impossible to recover the sparse vector \cite[Appendix E]{sparse_pca_focs20}.
\item Hard: A regime where it is conjectured to be hard to distinguish between the random and the planted distributions. We discuss this in more detail below.
\end{itemize}
\begin{figure}[!ht]
\centering
\includegraphics[scale=.6]{machinery/images/spca_graph_2}
\caption{The threshold behavior of the Wishart model of Sparse PCA where the $x$-axis is $d$, the ambient dimension and the $y$-axis is $k$, the sparsity of the hidden vector. [*] indicates the regime studied in this paper.}
\label{fig: spca_thresholds}
\end{figure}
In the \textit{Hard} parameter regime where $m \ll \frac{k^2}{\lambda^2}$ and $m \ll \frac{d}{\lambda^2}$, degree $2$ and degree $4$ SoS lower bounds have been shown in prior works, while we handle degree $d^{O(\varepsilon)}$. In particular, the works \cite{krauthgamer2015, berthet2013} obtain degree $2$ SoS lower bounds. \cite{ma_wigderson_15} obtain degree $4$ SoS lower bounds using an ad-hoc construction. It's not clear if their construction can be generalized for higher degrees. Moreover, the bounds they obtain are tight up to polylogarithmic factors when $\lambda$ is a constant but are not tight when $\lambda$ is not a constant, so we improve their bounds even in the degree $4$ case. We subsume all these earlier known results in this work with \cref{cor: spca_main}. This is a vast improvement over prior known sum of squares lower bounds and provides compelling evidence for the hardness of Sparse PCA in this parameter range.
The work \cite{hop17} considers the related but qualitatively different Wigner model of Sparse PCA and they state degree $d^{\varepsilon}$ SoS lower bounds, without explicitly proving these bounds. The techniques in that work do not recover our results because the matrix formed by the random samples in the Wishart model is asymmetric, and handling it correctly is far from being a mere technicality. On the other hand, our machinery can recover the results on the Wigner model as well, though we only analyze the Wishart model in this paper.
In \cite{sparse_pca_focs20}, they prove that if $m \le \frac{d}{\lambda^2}$ and $m \le \left(\frac{k^2}{\lambda^2}\right)^{1 - \Omega(\varepsilon)}$, then degree $n^{\varepsilon}$ polynomials cannot distinguish the random and planted distributions.
\cref{cor: spca_main} says that under mildly stronger assumptions, degree $n^{\varepsilon}$ Sum-of-Squares cannot distinguish the random and planted distributions, so we confirm that SoS is no more powerful than low degree polynomials in this setting.
There have also been direct reductions from planted clique to Sparse PCA \cite{brennan2019optimal}, and it's natural to ask if these reductions can obtain SoS lower bounds on Sparse PCA from the known SoS lower bounds on planted clique \cite{BHKKMP16}. To the best of our knowledge, no such reduction is known and constructing such a reduction would be challenging as it would have to be captured by SoS and avoid losing too much in the parameters. Still, it may well be possible to construct such a reduction.
\subsection{An overview of the machinery: All three results from a single main theorem}
Now that we have described our results,
we want to highlight that all three results are obtained via applications of one main theorem, which we call the machinery. \cref{thm: plds_main}, \cref{thm: tpca_main} and \cref{thm: spca_main} all essentially boil down to showing that a large moment matrix $\Lambda$ is PSD. To show this, the machinery constructs certain \emph{coefficient matrices} from $\Lambda$ and gives conditions on these coefficient matrices which are sufficient to guarantee that $\Lambda$ is PSD with high probability. In this section, we give an informal sketch of the machinery and how it generalizes the techniques used to prove the SoS lower bound for planted clique \cite{BHKKMP16}. We also motivate some of the conditions that arise in the machinery.
\subsubsection{Shapes and graph matrices}
Before we can describe how our machinery works, we need to describe shapes and graph matrices, which were originally introduced by \cite{BHKKMP16, medarametla2016bounds} and later generalized in \cite{AMP20}. Both the planted clique analysis and our analysis use shapes and graph matrices.
Shapes $\alpha$ are graphs that contain extra information about the vertices. Corresponding to each shape $\alpha$, there is a matrix-valued function (i.e. a matrix whose entries depend on the input) $M_{\alpha}$ that we call a graph matrix. Graph matrices are analogous to a Fourier basis, but for matrix-valued functions that exhibit a certain kind of symmetry. In our setting, $\Lambda$ will be such a matrix-valued function, so we can decompose $\Lambda$ as a linear combination of graph matrices.
Shapes and graph matrices have several properties which make them very useful to work with. First, $\norm{M_{\alpha}}$ can be bounded with high probability in terms of simple combinatorial properties of the shape $\alpha$. Second, if two shapes $\alpha$ and $\beta$ match up in a certain way, we can combine them to form a larger shape $\alpha \circ \beta$. We call this operation shape composition. Third, each shape $\alpha$ has a canonical decomposition into three shapes, the left, middle and right parts of $\alpha$, which we call $\sigma$, $\tau$, and ${\sigma'}^T$. For this canonical decomposition, we have that $\alpha = \sigma \circ \tau \circ {\sigma'}^T$ and $M_{\alpha} \approx M_{\sigma}M_{\tau}M_{{\sigma'}^T}$ \footnote{Actually, due to a technical issue related to automorphism groups, this equation is off by a multiplicative constant. For details, see Lemma \ref{lm:morthsimplereexpression}.}. This decomposition turns out to be crucial for both the planted clique analysis and our analysis.
\subsubsection{Summary of the SoS lower bound for planted clique and the machinery}
We now give a brief summary of the techniques for the SoS lower bound for planted clique and for our machinery. We elaborate on these steps in \cref{ideadescriptionsubsection}, we formally describe these steps in \cref{sec: informal_statement}, and we carry out these steps in full generality in \cref{sec: technical_def_and_main_theorem} and \cref{sec: proof_of_main}.
For planted clique, the SoS lower bound analysis works as follow
\begin{enumerate}
\item Using the technique of pseudo-calibration, construct a candidate moment matrix $\Lambda$.
\item Decompose the moment matrix $\Lambda$ as a linear combination $\Lambda = \sum_{\text{shapes } \alpha}{\lambda_{\alpha}M_{\alpha}}$ of graph matrices $M_{\alpha}$.
\item For each shape $\alpha$, decompose $\alpha$ into a left part $\sigma$, a middle part $\tau$, and a right part ${\sigma'}^T$.
We then have that $M_{\alpha} \approx M_{\sigma}M_{\tau}M_{{\sigma'}^T}$.
\item Using the approximate decompositions $M_{\alpha} \approx M_{\sigma}M_{\tau}M_{{\sigma'}^T}$, give an approximate decomposition $\Lambda \approx LQL^T$ of $M$ where $Q \succeq 0$ with high probability.
\item Show that with high probability, $\Lambda = LQL^T - (LQL^T - M) \succeq 0$ by carefully analyzing the difference $LQL^T - M$ using similar techniques.
\end{enumerate}
For our machinery, we use a similar framework. The key innovation of our machinery is that we introduce coefficient matrices (step 4) and carry out the analysis in terms of these coefficient matrices.
\begin{enumerate}
\item Construct a candidate moment matrix $\Lambda$. This can be done either using pseudo-calibration or in a more ad-hoc manner.
\item Decompose the moment matrix $\Lambda$ as a linear combination $\Lambda = \sum_{\text{shapes } \alpha}{\lambda_{\alpha}M_{\alpha}}$ of graph matrices $M_{\alpha}$
\item For each shape $\alpha$, decompose $\alpha$ into a left part $\sigma$, a middle part $\tau$, and a right part ${\sigma'}^T$.
\item Based on the coefficients $\lambda_{\alpha}$ and the decompositions of the shapes $\alpha$ into left, middle, and right parts, construct coefficient matrices $H_{Id_U}$ and $H_{\tau}$.
\item Based on the coefficient matrices $H_{Id_U}$ and $H_{\tau}$, obtain an approximate PSD decomposition of $\Lambda$.
\item Show that the error terms (which we call intersection terms) can be bounded by the approximate PSD decomposition of $\Lambda$.
\end{enumerate}
We show that this analysis will succeed as long as three conditions on the coefficient matrices are satisfied (see \cref{sec: informal_statement} for a qualitative statement of these conditions and \cref{sec: technical_def_and_main_theorem} for the precise statement of these conditions). Thus, in order to use our machinery to prove sum of squares lower bounds, it is sufficient to do the following.
\begin{enumerate}
\item Construct a candidate moment matrix $\Lambda$.
\item Decompose the moment matrix $\Lambda$ as a linear combination $\Lambda = \sum_{\text{shapes } \alpha}{\lambda_{\alpha}M_{\alpha}}$ of graph matrices $M_{\alpha}$ (akin to Fourier decomposition) and find the corresponding coefficient matrices.
\item Verify the required conditions on the coefficient matrices.
\end{enumerate}
\subsubsection{A sketch of the intuition behind the machinery conditions}\label{ideadescriptionsubsection}
\begin{comment}
\paragraph{Graph matrices}
Graph matrices were originally introduced by \cite{BHKKMP16, medarametla2016bounds} and later generalized in \cite{AMP20}. We use the generalized graph matrices in our analysis.
Each graph matrix is a matrix valued function of the input, that can be identified by a graph with labeled edges that we call a shape. Informally, graph matrices will form a basis for all matrix valued functions of the input that have a certain symmetry. In particular, $\Lambda$ is one such matrix valued function and can thus be decomposed into graph matrices. For a shape $\alpha$, the graph matrix associated to $\alpha$ is denoted by $M_{\alpha}$.
Graph matrices have several useful properties. Firstly, $\norm{M_{\alpha}}$ can be bounded with high probability in terms of simple combinatorial properties of the shape $\alpha$. Secondly, when we multiply two graph matrices $M_{\alpha}, M_{\beta}$ corresponding to shapes $\alpha, \beta$, it approximately equals the graph matrix $M_{\alpha \circ \beta}$ where the shape $\alpha \circ \beta$, called the composition of the two shapes $\alpha$ and $\beta$, is easy to describe combinatorially.
These makes graph matrices a convenient tool to analyze the moment matrix. In our setting, the moment matrix decomposes as $\Lambda = \sum \lambda_{\alpha} M_{\alpha}$ where the sum is over all shapes $\alpha$ and $\lambda_{\alpha} \in {\mathbb R}$ are the coefficients that arise from pseudo-calibration.
\paragraph{Decomposing Shapes}
For graph matrices $\alpha, \beta$, $M_{\alpha}M_{\beta} \approx M_{\alpha \circ \beta}$ where we define the composition of two shapes $\alpha \circ \beta$ to be a larger shape that is obtained by concatenating the shapes $\alpha, \beta$. This equality is only approximate and handling it precisely is a significant source of difficulty in our analysis. Shape composition is also associative, hence we can define composition of three or more shapes.
A crucial idea for our machinery is that for any shape $\alpha$, there exists a canonical and unique decomposition of $\alpha$ as $\sigma \circ \tau \circ \sigma'^T$ satisfying some nice structural properties, for shapes $\sigma, \tau$ and $\sigma'^T$. Here, $\sigma, \tau, \sigma'^T$ are called the left part, the middle part and the right part of $\alpha$ respectively.
Using this, our moment matrix can be written as
\[\Lambda = \sum_{\alpha}\lambda_{\alpha}M_{\alpha} = \sum_{\sigma, \tau, \sigma'} \lambda_{\sigma\circ\tau\circ\sigma'^T}M_{\sigma\circ\tau\circ\sigma'^T}\]
\end{comment}
\paragraph{Giving an approximate PSD factorization}
As discussed above, we decompose the moment matrix $\Lambda$ as a linear combination $\Lambda = \sum_{\text{shapes } \alpha}{\lambda_{\alpha}M_{\alpha}}$ of graph matrices $M_{\alpha}$. We then decompose each $\alpha$ into left, middle, and right parts $\sigma$, $\tau$, and ${\sigma'}^T$. We now have that
\[
\Lambda = \sum_{\alpha = \sigma \circ \tau \circ {\sigma'}^T}{\lambda_{\sigma \circ \tau \circ {\sigma'}^T}M_{\sigma \circ \tau \circ {\sigma'}^T}}
\]
We first consider the terms $\sum_{\sigma, \sigma'} \lambda_{\sigma \circ \sigma'^T}M_{\sigma \circ \sigma'^T} \approx \sum_{\sigma, \sigma'} \lambda_{\sigma \circ \sigma'^T}M_{\sigma} M_{\sigma'^T}$ where $\tau$ corresponds to an identity matrix and can be ignored.
If there existed real numbers $v_{\sigma}$ for all left shapes $\sigma$ such that $\lambda_{\sigma \circ \sigma'^T} = v_{\sigma}v_{\sigma'}$, then we would have
\[
\sum_{\sigma, \sigma'} \lambda_{\sigma \circ \sigma'^T}M_{\sigma} M_{\sigma'^T} = \sum_{\sigma, \sigma'} v_{\sigma}v_{\sigma'}M_{\sigma} M_{\sigma'^T} = (\sum_{\sigma} v_{\sigma}M_{\sigma})(\sum_{\sigma} v_{\sigma}M_{\sigma})^T \succeq 0
\]
which shows that the contribution from these terms is positive semidefinite. In fact, this turns out to be the case for the planted clique analysis. However, this may not hold in general. To handle this, we note that the existence of $v_{\sigma}$ can be relaxed as follows: Let $H$ be the matrix with rows and columns indexed by left shapes $\sigma$ such that $H(\sigma, \sigma') = \lambda_{\sigma \circ \sigma'^T}$. Up to scaling, $H$ will be one of our coefficient matrices. If $H$ is positive semidefinite then the contribution from these terms will also be positive semidefinite. In fact, this will be the first condition of our main theorem, the qualitative version of which can be found in \cref{informalmaintheoremstatement}.
\paragraph{Handling terms with a non-trivial middle part}
Unfortunately, we also have terms $\lambda_{\sigma \circ \tau \circ \sigma'^T}M_{\sigma \circ \tau \circ \sigma'^T}$ where $\tau$ is non-trivial. Our strategy will be to charge these terms to other terms.
For the sake of simplicity, we will describe how to handle one term. A starting point is the following inequality. For a left shape $\sigma$, a middle shape $\tau$, a right shape $\sigma'^T$, and real numbers $a, b$,
\[(a M_{\sigma} - bM_{\sigma'}M_{\tau^T})(a M_{\sigma} - bM_{\sigma'}M_{\tau^T})^T \succeq 0\]
which rearranges to
\begin{align*}
ab(M_{\sigma}M_{\tau}M_{\sigma'^T} + (M_{\sigma}M_{\tau}M_{\sigma'^T})^T) &\preceq a^2M_{\sigma}M_{\sigma^T} + b^2M_{\sigma'}M_{\tau^T}M_{\tau}M_{\sigma'^T}\\
&\preceq a^2M_{\sigma}M_{\sigma^T} + b^2\norm{M_{\tau}}^2M_{\sigma'}M_{\sigma'^T}
\end{align*}
If $\lambda_{\sigma \circ \tau \circ \sigma'^T}^2\norm{M_{\tau}}^2 \le \lambda_{\sigma \circ \sigma^T}\lambda_{\sigma' \circ \sigma'^T}$, then we can choose $a, b$ such that $a^2 \le \lambda_{\sigma \circ \sigma^T}, b^2 \norm{M_{\tau}}^2 \le \lambda_{\sigma' \circ \sigma'^T}$ and $ab = \lambda_{\sigma \circ \tau \circ \sigma'^T}$. This will approximately imply
\[\lambda_{\sigma \circ \tau \circ \sigma'^T}(M_{\sigma \circ \tau \circ \sigma'^T} + M_{\sigma \circ \tau \circ \sigma'^T}^T) \preceq \lambda_{\sigma \circ \sigma^T}M_{\sigma \circ \sigma^T} + \lambda_{\sigma' \circ \sigma'^T}M_{\sigma' \circ \sigma'^T}\]
which will give us a way to charge terms with a nontrivial middle part against terms with a trivial middle part.
While we could try to apply this inequality term by term, it is not strong enough to give us our results. Instead, we generalize this inequality to work with the entire set of shapes $\sigma, \sigma'$ for a fixed $\tau$. This will lead us to the second condition of our main theorem, the qualitative version of which can be found in \cref{informalmaintheoremstatement}.
\paragraph{Handing intersection terms}
There's one important technicality in the above heuristic calculations. Whenever we decompose $\alpha$ into left, middle, and right parts $\sigma$, $\tau$, and ${\sigma'}^T$, $M_{\sigma}M_{\tau}M_{{\sigma'}^T}$ is only approximately equal to $M_{\alpha} = M_{\sigma \circ \tau \circ {\sigma'}^T}$. All the other error terms have to be carefully handled in our analysis. We call these terms intersection terms.
These intersection terms themselves turn out to be graph matrices and our strategy is to now recursively decompose them into $\sigma_2 \circ \tau_2 \circ \sigma_2'^T$ and apply the previous ideas. To do this methodically, we employ several ideas such as the notion of intersection patterns and the generalized intersection tradeoff lemma (see \cref{sec: proof_of_main}). Properly handling the intersection terms is one of the most technically intensive parts of our work.
This analysis leads us to the third condition of the main theorem, the qualitative version of which can be found in \cref{informalmaintheoremstatement}.
\paragraph{Applying the machinery}
To apply the machinery to our problems of interest, we verify the spectral conditions that our coefficients should satisfy and then we can use our main theorem. The Planted slightly denser subgraph application is straightforward and will serve as a good warmup to understand our machinery. In the applications to Tensor PCA and Sparse PCA, the shapes corresponding to the graph matrices with nonzero coefficients have nice structural properties that will be crucial for our analysis. We exploit this structure and use novel charging arguments to verify the conditions of our machinery.
\subsubsection{A summary of our contributions}
\begin{comment}
\subsubsection{Power and limitations of the machinery}
We note that our machinery has the same level of generality as the generalized graph matrices in \cite{AMP20}, which is quite general. In particular, our machinery can handle inputs This generality allows our machinery to handle problems such as the Wishart model of Sparse PCA which were outside the range of previous lower bound analyses for sum of squares.
That said, in our experience, in order for the machinery to work well, we need the coefficients $\lambda_{\alpha}$ to decay exponentially in the number of vertices and edges of $\alpha$ and we need this decay to be precise. This is an important reason why our machinery has trouble handling hard global constraints
It is an interesting question whether or not our machinery can be applied to problems on sparse inputs. On the one hand, qualitatively, there is
\end{comment}
\paragraph{The machinery} In this work, we have attempted to drastically simplify the notoriously hard task of proving PSDness for SoS lower bounds to verifying relatively simple conditions that are assembled from the candidate moment matrix. Coefficient matrices are simple matrices whose entries are filled in a specific but well defined manner with the Fourier coefficients of $\Lambda$, i.e. coefficients $\lambda_{\alpha}$ for which we can write $\Lambda = \sum_{\alpha} \lambda_{\alpha} M_{\alpha}$. Here, $M_{\alpha}$ are called graph matrices, that will play the part of a Fourier basis. Indeed, they can be thought of as an analogue for the Fourier basis for large matrices that satisfy a certain type of symmetry.
The conditions, which are relatively easy to verify for specific applications, moreover give the right tradeoffs for SoS lower bounds that can be shown via coefficient decay techniques. That is, the bounds $\lambda \ll n^{k/4}$ for Tensor PCA or the bound $m \ll \min(d / \lambda^2, k^2/\lambda^2)$ for the Wishart model of Sparse PCA, almost naturally appear when applying the machinery on these problems. Moreover, as we saw in \cref{sec: prior_work}, these thresholds in fact match the best known algorithmic guarantees, thereby giving conclusive evidence of the correct computational threshold behavior of these problems.
\paragraph{Applicability to certification problems}
The machinery works well for problems where the Fourier coefficients of the candidate moment matrix exhibit a sort of decay behavior. This is akin to saying larger Fourier coefficients should be smaller in the Fourier decomposition. Such coefficient decay is present in many standard certification problems once we find a good planted distribution. Sometimes, noise can be easily introduced to the problem instance to force such kinds of decay, at a cost of slightly lowering the integrality gap we set out to prove, say from $n^{k/4}$ to $n^{k/4 - \varepsilon}$ for a small $\varepsilon > 0$.
The machinery in this work applies for both dense and sparse problems alike. Dense problems include certification problems on $G_{n, 1/2}$ or statistics problems with inputs being standard Gaussian inputs. Sparse problems include problems on $G_{n, p}$ for $p = n^{\varepsilon}$ or statistics problems with inputs having bounded sub-Gaussian norm. While we have optimized our functions for dense problems, the general main theorem is readily applicable, with almost no modifications, for sparse problems as well. For sparse problems, to get the tightest possible tradeoffs, the functions might have to be optimized even further to reflect the behavior of random matrices on these sparse inputs but we haven't attempted this in this work.
\paragraph{Other contributions}
While the machinery builds on ideas from the work on Planted Clique, the kind of matrices they use, known as graph matrices are not powerful enough to handle problems on tensors or Gaussian inputs. This is addressed in the work of \cite{AMP20} who introduce the notion of generalized graph matrices. When trying to apply generally the same techniques, there are numerous difficulties that have to be overcome and we systematically handle them using both new ideas and by significantly generalizing known techniques.
We introduce and use the notion of coefficient matrices which attempt to abstract out the precise conditions that are needed in such SoS lower bound proofs. By making the dominant and non-dominant terms in the PSD decomposition explicit, the coefficient matrices shed light on the intrinsic structure of the problem at hand, to prevent getting lost in the technical details.
\subsection{Comparison to Other Sum-of-Squares Lower Bounds on Certification Problems}
\cite{BHKKMP16} proved sum of squares lower bounds for the planted clique problem. Our machinery vastly generalizes the techniques of their paper. For a specific technical reason, our machinery actually doesn't recover the same lower bounds as planted clique in particular (See \cref{rmk: planted_clique_failure}). That said, this is because we have attempted to keep our framework as general as possible so that it is applicable to other problems, at the cost of losing a specific technicality that's needed for planted clique in particular.
\cite{hop17} remarked that the techniques used in \cite{BHKKMP16} can be used to give Sum-of-Squares lower bounds for $\pm{1}$ variants of tensor PCA and sparse PCA, though this is not made explicit. In this paper, we use our machinery to make these lower bounds explicit. We also handle the Wishart model of sparse PCA, which is more natural and significantly harder to prove lower bounds for. In particular, the bounds we prove do not follow solely from the techniques used in prior works.
\cite{KothariMOW17} proved that for random constraint satisfaction problems (CSPs) where the predicate has a balanced pairwise independent distribution of solutions, with high probability, degree $\Omega(n)$ SoS is required to certify that these CSPs do not have a solution. While they don't state it in this manner, the pseudo-expectation values used by \cite{KothariMOW17} can also be derived using pseudo-calibration \cite{rajendran2018combinatorial, brown2020extended}. The analysis for showing that the moment matrix is PSD is very different. It is an interesting question whether or not it is possible to unify these analyses.
\cite{MRX20} showed that it's possible to lift degree $2$ SoS solutions to degree $4$ SoS solutions under suitable conditions, and used it to obtain degree $4$ SoS lower bounds for average case $d$-regular Max-Cut and the Sherrington Kirkpatrick problem. Their construction is inspired by pseudo-calibration and their analysis also goes via graph matrices.
Recently, \cite{sklowerbounds} proved degree $n^{\varepsilon}$ SoS lower bounds for the Sherrington-Kirkpatrick problem via an intermediate problem known as Planted Affine Planes. Their construction and analysis also goes via pseudo-calibration and graph matrices, but since the constructed moment matrix had a nontrivial nullspace, they had to use different techniques to handle them. However, once this nullspace is taken into account, the moment matrix is dominated by its expected value. After this preprocessing, our machinery would imply their result but using it would be overkill.
\cite{kunisky2020} recently proposed a technique to lift degree $2$ SoS lower bounds to higher levels and applied it to construct degree $6$ lower bounds for the Sherrington-Kirkpatrick problem. Interestingly, their construction does not go via pseudo-calibration.
\subsection{Related Algorithmic Techniques}\label{subsec: related_techniques}
\paragraph{Low degree polynomials} Consider a problem where the input is sampled from one of two distributions and we would like to identify which distribution it was sampled from. Usually, one distribution is the completely random distribution while the other is a planted distribution that contains a given structure not present in the random distribution. In this setting, a closely related method is to use low degree polynomials to try and distinguish the two distributions. More precisely, if there is a low degree polynomial such that its expected value on the random distribution is very different than its expected value on the planted distribution, this distinguishes the two distributions.
Recently, this method has been shown to be an excellent heuristic, as it recovers the conjectured hardness thresholds for several problems and is considerably easier to analyze \cite{hop17, hop18, kunisky19notes}.
Under some conditions, the SoS hierarchy is at least as powerful as low degree polynomials \cite{hop17}. It is an important open question whether low degree polynomials generally have the same power as the SoS hierarchy or if there are situations where the SoS hierarchy is more powerful. On the one hand, we know of very few examples where low degree polynomials fail yet some polynomial time algorithm succeeds and the examples we do know of are somewhat contrived \cite{holmgren2020counterexamples}. On the other hand, to the best of our knowledge there is no known way to obtain sum of squares lower bounds from low degree polynomial lower bounds. In this paper, we confirm that for tensor PCA and the Wishart model of sparse PCA with slightly adjusted planted distributions, the SoS hierarchy is no more powerful than low-degree polynomials.
\paragraph{The Statistical Query Model}
The statistical query model is another popular restricted class of algorithms introduced by \cite{kearns1998efficient}. In this model, for an underlying distribution, we can access it by querying expected value of functions of the distribution. Concretely, for a distribution $D$ on ${\mathbb R}^n$, we have access to it via an oracle that given as query a function $f: {\mathbb R}^n \rightarrow [-1, 1]$ returns $\mathbb{E}_{x \sim D} f(x)$ upto some additive adversarial error. SQ algorithms capture a broad class of algorithms in statistics and machine learning and has also been used to study information-computation tradeoffs. There has also been significant work trying to understand the limits of SQ algorithms (e.g. \cite{feldman2017statistical, feldman2018complexity, diakonikolas2017statistical}). The recent work \cite{brennan2020statistical} showed that low degree polynomials and statistical query algorithms have equivalent power under mild conditions. It's an interesting open question whether or not SQ algorithms have the same power as Sum-of-Squares algorithms. An important distinction to note is that SQ algorithms do not take into account the complexity of the oracle whereas SoS studies the whole computational aspect of the problem. Therefore, with our current knowledge, SoS lower bounds are strictly stronger evidence of intrinsic hardness of problems.
\subsection{Organization of the paper}
In this work, we occasionally distinguish between the qualitative and quantitative versions of theorem statements. Qualitative theorem statements capture the essence of the inequalities we prove, and serve to illustrate the main forms of the bounds we desire, without getting lost in the details. Quantitative theorems on the other hand build on their qualitative counterparts by stating the precise bounds that are needed.
The remainder of this paper is organized as follows. In \cref{sec: prelim}, we give some preliminaries. In particular, we describe the Sum-of-Squares hierarchy and present a brief overview of the machinery and some proof techniques that we use. In \cref{sec: informal_statement}, we present the informal statement of the main theorem. In \cref{sec: plds_qual}, \cref{sec: tpca_qual} and \cref{sec: spca_qual}, we qualitatively verify the conditions of the machinery for planted slightly denser subgraph, tensor PCA, and sparse PCA respectively. While these sections only verify the qualitative conditions, the results in these sections are precise and will be reused in \cref{sec: plds_quant}, \cref{sec: tpca_quant} and \cref{sec: spca_quant} to fully verify the conditions of the machinery. In \cref{sec: technical_def_and_main_theorem}, we introduce all the formal definitions and state the main theorem in full generality. In \cref{sec: proof_of_main}, we prove the main theorem while abstracting out the choice of several functions. In \cref{sec: choosing_funcs}, we choose these functions so that that they satisfy the conditions needed for our main theorem. In Section \ref{sec: showing_positivity}, we give tools for verifying a technical condition of our machinery which is related to truncation error. Finally, in \cref{sec: plds_quant}, \cref{sec: tpca_quant} and \cref{sec: spca_quant}, we verify all the conditions necessary to prove \cref{thm: plds_main}, \cref{thm: tpca_main} and \cref{thm: spca_main} respectively.
For a first pass, the reader is encouraged to read the informal description of the machinery as outlined in \cref{sec: informal_statement}. Then, they can read any of the qualitative bounds \cref{sec: plds_qual}, \cref{sec: tpca_qual}, \cref{sec: spca_qual} to get a sense of how the machinery can be applied to these problems qualitatively. For readers interested in seeing complete proofs of the main applications, they can read parts of the quantitative bounds sections of their favorite problem(s) from among \cref{sec: plds_quant}, \cref{sec: tpca_quant}, \cref{sec: spca_quant}. To understand the details of the machinery, the reader may then read the formal definitions and theorem statement in \cref{sec: technical_def_and_main_theorem} whose proof follows in section \cref{sec: proof_of_main}. In \cref{sec: technical_def_and_main_theorem}, for the sake of clarity, the reader is given a choice of generality in the definitions and theorem statement.
\subsection{Middle shape bounds}
\begin{lemma}\label{lem: tpca_charging}
Suppose $\lambda \le n^{\frac{k}{4} - \varepsilon}$. For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, suppose $deg^{\tau}(i)$ is even for all $i \in V(\tau) \setminus U_{\tau} \setminus V_{\tau}$, then
\[\sqrt{n}^{|V(\tau)| - |U_{\tau}|}S(\tau) \le \frac{1}{n^{0.5\varepsilon\sum_{e \in E(\tau)} l_e}}\]
\end{lemma}
\begin{proof}
Firstly, we claim that $\sum_{e \in E(\tau)} kl_e \ge 2(|V(\tau)| - |U_{\tau}|)$. For any vertex $i \in V(\tau) \setminus U_{\tau} \setminus V_{\tau}$, $deg^{\tau}(i)$ is even and is not $0$, hence, $deg^{\tau}(i) \ge 2$. Any vertex $i \in U_{\tau} \setminus V_{\tau}$ cannot have $deg^{\tau}(i) = 0$ otherwise $U_{\tau} \setminus\{i\}$ is a vertex separator of strictly smaller weight than $U_{\tau}$, which is not possible, hence, $deg^{\tau}(i) \ge 1$. Therefore,
\begin{align*}
\sum_{e \in E(\tau)}kl_e = \sum_{i \in V(\tau)} deg^{\tau}(i)
&\ge \sum_{i \in V(\tau) \setminus U_{\tau} \setminus V_{\tau}} deg^{\tau}(i) + \sum_{i \in U_{\tau} \setminus V_{\tau}} deg^{\tau}(i) + \sum_{i \in V_{\tau} \setminus U_{\tau}} deg^{\tau}(i)\\
&\ge 2|V(\tau) \setminus U_{\tau} \setminus V_{\tau}| + |U_{\tau} \setminus V_{\tau}| + |V_{\tau} \setminus U_{\tau}|\\
&= 2(|V(\tau)| - |U_{\tau}|)
\end{align*}
By choosing $C_{\Delta}$ sufficiently small, we have
\begin{align*}
\sqrt{n}^{|V(\tau)| - |U_{\tau}|}S(\tau) &= \sqrt{n}^{|V(\tau)| - |U_{\tau}|} \Delta^{|V(\tau)| - |U_{\tau}|}\prod_{e \in E(\tau)}\left(\frac{\lambda}{(\Delta n)^{\frac{k}{2}}}\right)^{l_e}\\
&\le \sqrt{n}^{|V(\tau)| - |U_{\tau}|}\Delta^{|V(\tau)| - |U_{\tau}|}\prod_{e \in E(\tau)}n^{(-\frac{k}{4} - 0.5\varepsilon)l_e}\\
&= \sqrt{n}^{|V(\tau)| - |U_{\tau}| - \frac{\sum_{e \in E(\tau)}kl_e}{2}}\Delta^{|V(\tau)| - |U_{\tau}|}\prod_{e \in E(\tau)}n^{-0.5\varepsilon l_e}\\
&= \Delta^{|V(\tau)| - |U_{\tau}|}\prod_{e \in E(\tau)}n^{-0.5 \varepsilon l_e}\\
&\le\frac{1}{n^{0.5\varepsilon\sum_{e \in E(\tau)} l_e}}
\end{align*}
\end{proof}
\begin{corollary}\label{cor: tpca_norm_decay}
For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, we have \[c(\tau)B_{norm}(\tau)S(\tau) \le 1\]
\end{corollary}
\begin{proof}
Since $\tau$ is a proper middle shape, we have $w(I_{\tau}) = 0$ and $w(S_{\tau, min}) = w(U_{\tau})$. This implies
$n^{\frac{w(V(\tau)) + w(I_{\tau}) - w(S_{\tau, min})}{2}} = \sqrt{n}^{|V(\tau)| - |U_{\tau}|}$.
If $deg^{\tau}(i)$ is odd for any vertex $i \in V(\tau) \setminus U_{\tau} \setminus V_{\tau}$, then $S(\tau) = 0$ and the inequality is true. So, assume $deg^{\tau}(i)$ is even for all $i \in V(\tau) \setminus U_{\tau} \setminus V_{\tau}$. As was observed in the proof of \cref{lem: tpca_charging}, every vertex $i \in V(\tau) \setminus U_{\tau}$ or $i \in V(\tau) \setminus V_{\tau}$ has $deg^{\tau}(i) \ge 1$ and hence, $|V(\tau)\setminus U_{\tau}| + |V(\tau)\setminus V_{\tau}| \le 4 \sum_{e \in E(\tau)} l_e$. Also, $|E(\tau)| \le \sum_{e \in E(\tau)} l_e$ and $q = n^{O(1) \cdot \varepsilon (C_V + C_E)}$. We can set $C_V, C_E$ sufficiently small so that, using \cref{lem: tpca_charging},
\begin{align*}
c(\tau)B_{norm}(\tau)S(\tau)
&= 100(3D_V)^{|U_{\tau}\setminus V_{\tau}| + |V_{\tau}\setminus U_{\tau}| + k|E(\tau)|}2^{|V(\tau)\setminus (U_{\tau}\cup V_{\tau})|}\\
&\quad\cdot 2e(6qD_V)^{|V(\tau)\setminus U_{\tau}| + |V(\tau)\setminus V_{\tau}|}\prod_{e \in E(\tau)} (400D_V^2D_E^2q)^{l_e}\sqrt{n}^{|V(\tau)| - |U_{\tau}|}S(\tau)\\
&\le n^{O(1) \cdot \varepsilon(C_V + C_E) \cdot \sum_{e \in E(\tau)} l_e} \cdot \sqrt{n}^{|V(\tau)| - |U_{\tau}|}S(\tau)\\
&\le n^{O(1) \cdot \varepsilon(C_V + C_E) \cdot \sum_{e \in E(\tau)} l_e} \cdot \frac{1}{n^{0.5\varepsilon\sum_{e \in E(\tau)} l_e}}\\
&\le 1
\end{align*}
\end{proof}
We can now show middle shape bounds.
\begin{lemma}\label{lem: tpca_cond2}
For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$,
\[
\begin{bmatrix}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_U} & B_{norm}(\tau) H_{\tau}\\
B_{norm}(\tau) H_{\tau}^T & \frac{1}{|Aut(U)|c(\tau)}H_{Id_U}
\end{bmatrix}
\succeq 0
\]
\end{lemma}
\begin{proof}
We have
\begin{align*}
&\begin{bmatrix}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_U} & B_{norm}(\tau)H_{\tau}\\
B_{norm}(\tau)H_{\tau}^T & \frac{1}{|Aut(U)|c(\tau)}H_{Id_U}
\end{bmatrix}\\
&\qquad= \begin{bmatrix}
\left(\frac{1}{|Aut(U)|c(\tau)} - \frac{S(\tau)B_{norm}(\tau)}{|Aut(U)|}\right)H_{Id_U} & 0\\
0 & \left(\frac{1}{|Aut(U)|c(\tau)} - \frac{S(\tau)B_{norm}(\tau)}{|Aut(U)|}\right)H_{Id_U}
\end{bmatrix}\\
&\qquad \qquad+ B_{norm}(\tau)\begin{bmatrix}
\frac{S(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix}
\end{align*}
By \cref{lem: tpca_cond2_simplified}, $\begin{bmatrix}
\frac{S(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix}
\succeq 0$, so the second term above is positive semidefinite. For the first term, by \cref{lem: tpca_cond1}, $H_{Id_U} \succeq 0$ and by \cref{cor: tpca_norm_decay}, $\frac{1}{|Aut(U)|c(\tau)} - \frac{S(\tau)B_{norm}(\tau)}{|Aut(U)|} \ge 0$, which proves that the first term is also positive semidefinite.
\end{proof}
\subsection{Intersection term bounds}
\begin{lemma}\label{lem: tpca_charging2}
Suppose $\lambda \le n^{\frac{k}{4} - \varepsilon}$. For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and for all $\gamma \in \Gamma_{U, V}$,
\[n^{w(V(\gamma)\setminus U_{\gamma})} S(\gamma)^2 \le \frac{1}{n^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)}}\]
for some constant $B$ that depends only on $C_{\Delta}$. In particular, it is independent of $C_V$ and $C_E$.
\end{lemma}
\begin{proof}
Suppose there is a vertex $i \in V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}$ such that $deg^{\gamma}(i)$ is odd, then $S(\gamma) = 0$ and the inequality is true. So, assume $deg^{\gamma}(i)$ is even for all vertices $i \in V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}$.
We first claim that $k\sum_{e \in E(\gamma)} l_e \ge 2|V(\gamma) \setminus U_{\gamma}|$. Since $\gamma$ is a left shape, all vertices $i$ in $V(\gamma) \setminus U_{\gamma}$ have $deg^{\gamma}(i) \ge 1$. In particular, all vertices $i \in V_{\gamma} \setminus U_{\gamma}$ have $deg^{\gamma}(i) \ge 1$.
Moreover, if $i \in V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}$, since $deg^{\gamma}(i)$ is even, we must have $deg^{\gamma}(i) \ge 2$.
Let $S'$ be the set of vertices $i \in U_{\gamma} \setminus V_{\gamma}$ that have $deg^{\gamma}(i) \ge 1$. Then, note that $|S'| + |U_{\gamma} \cap V_{\gamma}| \ge |V_{\gamma}| \Longrightarrow |S'| \ge |V_{\gamma} \setminus U_{\gamma}|$ since otherwise $S' \cup (U_{\gamma} \cap V_{\gamma})$ will be a vertex separator of $\gamma$ of weight strictly less than $V_{\gamma}$, which is not possible. Then,
\begin{align*}
\sum_{e \in E(\gamma)}kl_e &= \sum_{i \in V(\gamma)} deg^{\gamma}(i)\\
&\ge \sum_{i \in V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}} deg^{\gamma}(i) + \sum_{i \in U_{\gamma} \setminus V_{\gamma}} deg^{\gamma}(i) + \sum_{i \in V_{\gamma} \setminus U_{\gamma}} deg^{\gamma}(i)\\
&\ge 2|V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}| + |S'| + |V_{\gamma} \setminus U_{\gamma}|\\
&\ge 2|V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}| + 2|V_{\gamma} \setminus U_{\gamma}|\\
&= 2|V(\gamma) \setminus U_{\gamma}|
\end{align*}
Finally, note that $2|V(\gamma)| - |U_{\gamma}| - |V_{\gamma}| = |U_{\gamma} \setminus V_{\gamma}| + |V_{\gamma} \setminus U_{\gamma}| + 2|V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}| \ge |V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})|$. By choosing $C_{\Delta}$ sufficiently small, we have
\begin{align*}
n^{w(V(\gamma)\setminus U_{\gamma})} S(\gamma)^2 &= n^{|V(\gamma)\setminus U_{\gamma})|} \Delta^{2|V(\gamma)| - |U_{\gamma}| - |V_{\gamma}|} \prod_{e \in E(\gamma)} \left(\frac{\lambda^2}{(\Delta n)^k}\right)^{l_e}\\
&\le n^{|V(\gamma)\setminus U_{\gamma})|} \Delta^{2|V(\gamma)| - |U_{\gamma}| - |V_{\gamma}|} \prod_{e \in E(\gamma)} n^{-(\frac{k}{2} + \varepsilon)l_e}\\
&\le \Delta^{2|V(\gamma)| - |U_{\gamma}| - |V_{\gamma}|} \prod_{e \in E(\gamma)} n^{-\varepsilon l_e}\\
&\le \frac{1}{n^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)}}
\end{align*}
for a constant $B$ that depends only on $C_{\Delta}$.
\end{proof}
\begin{remk}
In the above bounds, note that there is a decay of $n^{B\varepsilon}$ for each vertex in $V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})$. One of the main technical reasons for introducing the slack parameter $C_{\Delta}$ in the planted distribution was to introduce this decay, which is needed in the current machinery.
\end{remk}
We can now obtain the intersection term bounds.
\begin{lemma}\label{lem: tpca_cond3}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and all $\gamma \in \Gamma_{U, V}$, \[c(\gamma)^2N(\gamma)^2B(\gamma)^2H_{Id_V}^{-\gamma, \gamma} \preceq H_{\gamma}'\]
\end{lemma}
\begin{proof}
By \cref{lem: tpca_cond3_simplified}, we have
\begin{align*}
c(\gamma)^2N(\gamma)^2B(\gamma)^2H_{Id_V}^{-\gamma, \gamma} &\preceq c(\gamma)^2N(\gamma)^2B(\gamma)^2 S(\gamma)^2 \frac{|Aut(U)|}{|Aut(V)|} H'_{\gamma}
\end{align*}
Using the same proof as in \cref{lem: tpca_cond1}, we can see that $H'_{\gamma} \succeq 0$. Therefore, it suffices to prove that $c(\gamma)^2N(\gamma)^2B(\gamma)^2 S(\gamma)^2 \frac{|Aut(U)|}{|Aut(V)|} \le 1$.
Since $U, V \in {\mathcal I}_{mid}$, $|Aut(U)| = |U|!,|Aut(V)| = |V|!$. Therefore, $\frac{|Aut(U)|}{|Aut(V)|} = \frac{|U|!}{|V|!} \le D_V^{|U_{\gamma} \setminus V_{\gamma}|}$. Also, $|E(\gamma)| \le \sum_{e \in E(\gamma)} l_e$ and $q = n^{O(1) \cdot \varepsilon (C_V + C_E)}$. Let $B$ be the constant from \cref{lem: tpca_charging2}. We can set $C_V, C_E$ sufficiently small so that, using \cref{lem: tpca_charging2},
\begin{align*}
c(\gamma)^2&N(\gamma)^2B(\gamma)^2S(\gamma)^2 \frac{|Aut(U)|}{|Aut(V)|} \\
&\le 100^2 (3D_V)^{2|U_{\gamma}\setminus V_{\gamma}| + 2|V_{\gamma}\setminus U_{\gamma}| + 2k|E(\alpha)|}4^{|V(\gamma) \setminus (U_{\gamma} \cup V_{\gamma})|}\\
&\quad\cdot (3D_V)^{4|V(\gamma)\setminus V_{\gamma}| + 2|V(\gamma)\setminus U_{\gamma}|} (6qD_V)^{2|V(\gamma)\setminus U_{\gamma}| + 2|V(\gamma)\setminus V_{\gamma}|} \prod_{e \in E(\gamma)} (400D_V^2D_E^2q)^{2l_e}\\
&\quad\cdot n^{w(V(\gamma)\setminus U_{\gamma})} S(\gamma)^2 \cdot D_V^{|U_\gamma \setminus V_{\gamma}|} \\
&\le n^{O(1) \cdot \varepsilon(C_V + C_E) \cdot (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)} \cdot n^{w(V(\gamma)\setminus U_{\gamma})} S(\gamma)^2\\
&\le n^{O(1) \cdot \varepsilon(C_V + C_E) \cdot (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)} \cdot \frac{1}{n^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)}}\\
&\le 1
\end{align*}
\end{proof}
\subsection{Truncation error bounds}
In this section, we will obtain the truncation error bounds using the strategy sketched in section 10 of \cite{potechin2020machinery}. We also reuse the notation. First, we need the following bound on $B_{norm}(\sigma) B_{norm}(\sigma') H_{Id_U}(\sigma, \sigma')$.
\begin{lemma}\label{lem: tpca_charging3}
Suppose $\lambda = n^{\frac{k}{4} - \varepsilon}$. For all $U \in {\mathcal I}_{mid}$ and $\sigma, \sigma' \in {\mathcal L}_U$,
\[B_{norm}(\sigma) B_{norm}(\sigma') H_{Id_U}(\sigma, \sigma') \le \frac{1}{n^{0.5\varepsilon C_{\Delta}|V(\sigma \circ \sigma')|}\Delta^{D_{sos}}n^{|U|}}\]
\end{lemma}
\begin{proof}
Suppose there is a vertex $i \in V(\sigma) \setminus V_{\sigma}$ such that $deg^{\sigma}(i) + deg^{U_{\sigma}}(i)$ is odd, then $H_{Id_U}(\sigma, \sigma') = 0$ and the inequality is true. So, assume that $deg^{\sigma}(i) + deg^{U_{\sigma}}(i)$ is even for all $i \in V(\sigma) \setminus V_{\sigma}$. Similarly, assume that $deg^{\sigma'}(i) + deg^{U_{\sigma'}}(i)$ is even for all $i \in V(\sigma') \setminus V_{\sigma'}$. Also, if $\rho_{\sigma} \neq \rho_{\sigma'}$, we will have $H_{Id_U}(\sigma, \sigma') = 0$ and we'd be done. So, assume $\rho_{\sigma} = \rho_{\sigma'}$.
Let $\alpha = \sigma \circ \sigma'$. We will first prove that $\sum_{e \in E(\alpha)} kl_e + 2deg(\alpha) \ge 2|V(\alpha)| + 2|U|$. Firstly, note that all vertices $i \in V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})$ have $deg^{\alpha}(i)$ to be even and nonzero, and hence at least $2$. Moreover, in both the sets $U_{\alpha} \setminus (U_{\alpha} \cap V_{\alpha})$ and $V_{\alpha} \setminus (U_{\alpha} \cap V_{\alpha})$, there are at least $|U| - |U_{\alpha} \cap V_{\alpha}|$ vertices of degree at least $1$, because $U$ is a minimum vertex separator. Also, note that $deg(\alpha) \ge |U_{\alpha}| + |V_{\alpha}|$. This implies that
\begin{align*}
\sum_{e \in E(\alpha)} kl_e &+ 2deg(\alpha)\\
&\ge 2 |V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})| + 2(|U| - |U_{\alpha} \cap V_{\alpha}|) + 2(|U_{\alpha}| + |V_{\alpha}|)\\
&= 2 (|V(\alpha)| - |U_{\alpha} \cup V_{\alpha}|) + 2(|U| - |U_{\alpha} \cap V_{\alpha}|) + 2(|U_{\alpha} \cup V_{\alpha}| + |U_{\alpha} \cap V_{\alpha}|)\\
&= 2|V(\alpha)| + 2|U|
\end{align*}
where we used the fact that $U_{\alpha} \cap V_{\alpha} \subseteq U$. Finally, by choosing $C_V, C_E$ sufficiently small,
\begin{align*}
&B_{norm}(\sigma) B_{norm}(\sigma') H_{Id_U}(\sigma, \sigma') \\
&= 2e(6qD_V)^{|V(\sigma)\setminus U_{\sigma}| + |V(\sigma)\setminus V_{\sigma}|}\prod_{e \in E(\sigma)} (400D_V^2D_E^2q)^{l_e} n^{\frac{w(V(\sigma)) - w(U)}{2}}\\
&\quad\cdot 2e(6qD_V)^{|V(\sigma')\setminus U_{\sigma'}| + |V(\sigma')\setminus V_{\sigma'}|}\prod_{e \in E(\sigma')} (400D_V^2D_E^2q)^{l_e} n^{\frac{w(V(\sigma')) - w(U)}{2}}\\
&\quad\cdot \frac{1}{|Aut(U)|} \Delta^{|V(\alpha)|} \left(\frac{1}{\sqrt{\Delta n}}\right)^{deg(\alpha)} \prod_{e \in E(\alpha)} \left(\frac{\lambda}{(\Delta n)^{\frac{k}{2}}}\right)^{l_e}\\
&\le n^{O(1) \cdot \varepsilon (C_V + C_E) \cdot (|V(\alpha)| + \sum_{e \in E(\alpha)} l_e)} \Delta^{|V(\alpha)|}\left(\frac{1}{\sqrt{\Delta}}\right)^{deg(\alpha)}\\
&\quad\cdot \sqrt{n}^{|V(\alpha)| - |U|} \left(\frac{1}{\sqrt{n}}\right)^{deg(\alpha)}\prod_{e \in E(\alpha)}n^{(-\frac{k}{4} - 0.5\varepsilon)l_e}\\
&\le \frac{n^{O(1) \cdot \varepsilon (C_V + C_E) \cdot (|V(\alpha)| + \sum_{e \in E(\alpha)} l_e)}}{n^{\varepsilon C_{\Delta}|V(\alpha)|}n^{0.5\varepsilon\sum_{e \in E(\alpha)} l_e}} \cdot \frac{1}{\Delta^{D_{sos}}n^{|U|}}\sqrt{n}^{|V(\alpha)| + |U| - deg(\alpha) - \frac{1}{2}\sum_{e \in E(\alpha)} kl_e}\\
&\le \frac{1}{n^{0.5\varepsilon C_{\Delta}|V(\alpha)|}\Delta^{D_{sos}}n^{|U|}}
\end{align*}
where we used the facts $\Delta \le 1, deg(\alpha) \le 2D_{sos}$.
\end{proof}
We now apply the strategy by showing the following bounds.
\begin{restatable}{lemma}{TPCAfive}\label{lem: tpca_cond5}
Whenever $\norm{M_{\alpha}} \le B_{norm}(\alpha)$ for all $\alpha \in {\mathcal M}'$,
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq \frac{\Delta^{2D_{sos}^2}}{n^{D_{sos}}} Id_{sym}
\]
\end{restatable}
\begin{proof}
For $V \in {\mathcal I}_{mid}$, $\lambda_V = \frac{1}{n^{|V|}}$. We then choose $w_V = \left(\frac{1}{n}\right)^{D_{sos} - |V|}$. For all left shapes $\sigma \in {\mathcal L}_V$, it's easy to verify $w_{V} \leq \frac{w_{U_{\sigma}}\lambda_{U_{\sigma}}}{|\mathcal{I}_{mid}|B_{norm}(\sigma)^2{c(\sigma)^2}{H_{Id_V}(\sigma,\sigma)}}$ using \cref{lem: tpca_charging3}. This completes the proof.
\end{proof}
\begin{restatable}{lemma}{TPCAsix}\label{lem: tpca_cond6}
\[\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} \frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)} \le \frac{1}{\Delta^{2D_{sos}}2^{D_V}}\]
\end{restatable}
\begin{proof}
We use the same argument and notation as in \cref{lem: plds_cond6}. When we plug in the bounds, we get
\begin{align*}
\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} &\frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)} \\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}} {B_{norm}(\sigma)B_{norm}(\sigma')H_{Id_{U}}(\sigma,\sigma')\frac{1}{2^{\min(m_{\sigma}, m_{\sigma'}) - 1}}}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{1}{n^{0.5\varepsilon C_{\Delta}|V(\sigma \circ \sigma')|}\Delta^{D_{sos}}n^{|U|}2^{\min(m_{\sigma}, m_{\sigma'}) - 1}}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{1}{n^{0.5\varepsilon C_{\Delta}|V(\sigma \circ \sigma')|}\Delta^{D_{sos}}2^{\min(m_{\sigma}, m_{\sigma'}) - 1}}
\end{align*}
where we used \cref{lem: tpca_charging3}. Using $n^{0.5 C_{\Delta} |V(\sigma \circ \sigma')|} \ge n^{0.1\varepsilon C_{\Delta} |V(\sigma \circ \sigma')|}2^{|V(\sigma \circ \sigma')|}$,
\begin{align*}
\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} &\frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{1}{n^{0.1 \varepsilon C_{\Delta}|V(\sigma \circ \sigma')|} \Delta^{D_{sos}} 2^{|V(\sigma \circ \sigma')|}2^{\min(m_{\sigma}, m_{\sigma'}) - 1}}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{1}{n^{0.1 \varepsilon C_{\Delta}|V(\sigma \circ \sigma')|}\Delta^{D_{sos}} 2^{D_V}}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{1}{D_{sos}^{D_{sos}}n^{0.1 \varepsilon C_{\Delta}|V(\sigma \circ \sigma')|}\Delta^{2D_{sos}} 2^{D_V}}
\end{align*}
where we set $C_{sos}$ small enough so that $D_{sos} = n^{\varepsilon C_{sos}} \le n^{c\varepsilon C_{\Delta}} = \frac{1}{\Delta}$. The final step will be to argue that $\sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{1}{D_{sos}^{D_{sos}}n^{0.1 C_{\Delta}\varepsilon|V(\sigma \circ \sigma')|}} \le 1$ which will complete the proof. But this will follow if we set $C_V, C_E$ small enough.
\end{proof}
We can finally complete the analysis of the truncation error.
\begin{lemma}\label{lem: tpca_cond4}
Whenever $\norm{M_{\alpha}} \le B_{norm}(\alpha)$ for all $\alpha \in \mathcal{M}'$,
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq 6\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\]
\end{lemma}
\begin{proof}
Choose $C_{sos}$ sufficiently small so that $\frac{\Delta^{2D_{sos}^2}}{n^{D_{sos}}} \ge \frac{6}{\Delta^{2D_{sos}}2^{D_V}}$ which is satisfied by setting $C_{sos} < 0.5 C_V$. Then, since $Id_{Sym} \succeq 0$, using \cref{lem: tpca_cond5} and \cref{lem: tpca_cond6},
\begin{align*}
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} &\succeq \frac{\Delta^{2D_{sos}^2}}{n^{D_{sos}}} Id_{sym}\\
&\succeq \frac{6}{\Delta^{2D_{sos}}2^{D_V}} Id_{sym}\\
&\succeq 6\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\end{align*}
\end{proof}
\subsection{Pseudo-calibration}
\begin{definition}[Slack parameter]
Define the slack parameter to be $\Delta = n^{-C_{\Delta}\varepsilon}$ for a constant $C_{\Delta} > 0$.
\end{definition}
We will pseudo-calibrate with respect the following pair of random and planted distributions which we denote $\nu$ and $\mu$ respectively.
\TPCAdistributions*
Let the Hermite polynomials be $h_0(x) = 1, h_1(x) = x, h_2(x) = x^2 - 1, \ldots$. For $a \in \mathbb{N}^{[n]^k}$ and variables $A_e$ for $e \in [n]^k$, define $h_a(A) := \prod_{e \in [n]^k} h_e(A_e)$. We will work with this Hermite basis.
\begin{lemma}
Let $I \in \mathbb{N}^n, a \in \mathbb{N}^{[n]^k}$. For $i \in [n]$, let $d_i = \sum_{i \in e \in [n]^k} a_e$. Let $c$ be the number of $i$ such that $I_i + d_i$ is nonzero. Then, if $I_i + d_i$ are all even, we have
\[\mathbb{E}_{\mu}[u^I h_a(A)] = \Delta^c\left(\frac{1}{\sqrt{\Delta n}}\right)^{|I|} \prod_{e \in [n]^k} \left(\frac{\lambda}{(\Delta n)^{\frac{k}{2}}}\right)^{a_e}\]
Else, $\mathbb{E}_{\mu}[u^I h_a(v)] = 0$.
\end{lemma}
\begin{proof}
When $A \sim \mu$, for all $e \in [n]^k$, we have $A_e = B_e + \lambda \prod_{i \le k} u_{e_i}$. where $B_e \sim \mathcal{N}(0, 1)$.
Let's analyze when the required expectation is nonzero. We can first condition on $u$ and use the fact that for a fixed $t$, $\mathbb{E}_{g \sim \mathcal{N}(0, 1)}[h_k(g + t)] = t^k$ to obtain
\[\mathbb{E}_{(u_i, w_e) \sim \mu}[u^I h_a(A)] = \mathbb{E}_{(u_i) \sim \mu}[u^I\prod_{e \in [n]^k}(\lambda \prod _{i \le k}u_{e_i})^{a_e}] = \mathbb{E}_{(u_i) \sim \mu}[\prod_{i \in [n]} u_i^{I_i + d_i}] \prod_{e \in [n]^k} \lambda^{a_e}\]
Observe that this is nonzero precisely when all $I_i + d_i$ are even, in which case \[\mathbb{E}_{(u_i) \sim \mu}[\prod_{i \in [n]} u_i^{I_i + d_i}] = \Delta^c\left(\frac{1}{\sqrt{\Delta n}}\right)^{\sum_{i \le n} I_i + d_i} = \Delta^c\left(\frac{1}{\sqrt{\Delta n}}\right)^{|I|} \prod_{e \in [n]^k} \left(\frac{1}{(\Delta n)^{\frac{k}{2}}}\right)^{a_e}\]
where we used the fact that $\sum_{e \in [n]^k} a_e = k \sum_{i \in [n]} d_i$.
This completes the proof.
\end{proof}
Define the degree of SoS to be $D_{sos} = n^{C_{sos}\varepsilon}$ for some constant $C_{sos} > 0$ that we choose later. And define the truncation parameters to be $D_V = n^{C_V\varepsilon}, D_E = n^{C_E\varepsilon}$ for some constants $C_V, C_E > 0$.
\begin{remk}[Choice of parameters]\label{rmk: choice_of_params2}
We first set $\varepsilon$ to be a sufficiently small constant. Based on the choice of $\varepsilon$, we will set the constant $C_{\Delta} > 0$ sufficiently small so that the planted distribution is well defined. Based on these choices, just as in \cref{rmk: choice_of_params1} we choose $C_V, C_E, C_{sos}$ in that order.
\end{remk}
The underlying graphs for the graph matrices have the following structure; There will be $n$ vertices of a single type and the edges will be ordered hyperedges of arity $k$.
For the analysis of Tensor PCA, we will use the following notation.
\begin{itemize}
\item For an index shape $U$ and a vertex $i$, define $deg^{U}(i)$ as follows: If $i \in V(U)$, then it is the power of the unique index shape piece $A \in U$ such that $i \in V(A)$. Otherwise, it is $0$.
\item For an index shape $U$, define $deg(U) = \sum_{i \in V(U)} deg^U(i)$. This is also the degree of the monomial that $U$ corresponds to.
\item For a shape $\alpha$ and vertex $i$ in $\alpha$, let $deg^{\alpha}(i) = \sum_{i \in e \in E(\alpha)} l_e$.
\item For any shape $\alpha$, let $deg(\alpha) = deg(U_{\alpha}) + deg(V_{\alpha})$.
\end{itemize}
We will now describe the decomposition of the moment matrix $\Lambda$.
\begin{definition}\label{def: tpca_coeffs}
If a shape $\alpha$ satisfies the following properties:
\begin{itemize}
\item $deg^{\alpha}(i) + deg^{U_{\alpha}}(i) + deg^{V_{\alpha}}(i)$ is even for all $i \in V(\alpha)$,
\item $\alpha$ is proper,
\item $\alpha$ satisfies the truncation parameters $D_{sos}, D_V, D_E$.
\end{itemize}
then define \[\lambda_{\alpha} = \Delta^{|V(\alpha)|} \left(\frac{1}{\sqrt{\Delta n}}\right)^{deg(\alpha)} \prod_{e \in E(\alpha)} \left(\frac{\lambda}{(\Delta n)^{\frac{k}{2}}}\right)^{l_e}\]
Otherwise, define $\lambda_{\alpha} = 0$.
\end{definition}
\begin{corollary}
$\Lambda = \sum \lambda_{\alpha}M_{\alpha}$.
\end{corollary}
\subsection{Qualitative machinery bounds}
Just as in planted slightly denser subgraph, we prove the PSD mass condition and the qualitative middle shape and intersection term bounds, by first stating them and then introducing appropriate notation to prove them all in a unified manner.
\begin{restatable}[PSD mass]{lemma}{TPCAone}\label{lem: tpca_cond1}
For all $U \in {\mathcal I}_{mid}$, $H_{Id_U} \succeq 0$
\end{restatable}
We define the following quantities to capture the contribution of the vertices within $\tau, \gamma$ to the Fourier coefficients.
\begin{restatable}{definition}{TPCAstau}\label{def: tpca_stau}
For $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, if $deg^{\tau}(i)$ is even for all vertices $i \in V(\tau) \setminus U_{\tau} \setminus V_{\tau}$, define
\[S(\tau) = \Delta^{|V(\tau)| - |U_{\tau}|}\prod_{e \in E(\tau)}\left(\frac{\lambda}{(\Delta n)^{\frac{k}{2}}}\right)^{l_e}\]
Otherwise, define $S(\tau) = 0$.
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and $\gamma \in \Gamma_{U, V}$, if $deg^{\gamma}(i)$ is even for all vertices $i$ in $V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}$, define
\[S(\gamma) = \Delta^{|V(\gamma)| - \frac{|U_{\gamma}| + |V_{\gamma}|}{2}}\prod_{e \in E(\gamma)}\left(\frac{\lambda}{(\Delta n)^{\frac{k}{2}}}\right)^{l_e}\]
Otherwise, define $S(\gamma) = 0$.
\end{restatable}
We now state the qualitative bounds in terms of these quantities.
\begin{restatable}[Qualitative middle shape bounds]{lemma}{TPCAtwosimplified}\label{lem: tpca_cond2_simplified}
For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$,
\[
\begin{bmatrix}
\frac{S(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix}
\succeq 0
\]
\end{restatable}
We again use the canonical definition of $H_{\gamma}'$ from \cref{sec: hgamma_qual}.
\begin{restatable}[Qualitative intersection term bounds]{lemma}{TPCAthreesimplified}\label{lem: tpca_cond3_simplified}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and all $\gamma \in \Gamma_{U, V}$,
\[\frac{|Aut(V)|}{|Aut(U)|}\cdot\frac{1}{S(\gamma)^2}H_{Id_V}^{-\gamma, \gamma} \preceq H_{\gamma}'\]
\end{restatable}
\subsubsection{Proof of PSD mass condition}
We introduce some notation which makes it easy to show the qualitative bounds and which also sheds light on the structure of the coefficient matrices. When we compose shapes $\sigma, \sigma'$, from \cref{def: tpca_coeffs}, in order for $\lambda_{\sigma\circ \sigma'}$ to be nonzero, observe that all vertices $i$ in $\lambda_{\sigma \circ \sigma'}$ should have $deg^{\sigma \circ \sigma'}(i) + deg^{U_{\sigma \circ \sigma'}}(i) + deg^{V_{\sigma \circ \sigma'}}(i)$ to be even. To partially capture this notion conveniently, we will introduce the notion of parity vectors.
\begin{definition}
Define a parity vector $\rho$ to be a vector whose entries are in $\{0, 1\}$.
For $U\in {\mathcal I}_{mid}$, define ${\mathcal P}_U$ to be the set of parity vectors $\rho$ whose coordinates are indexed by $U$.
\end{definition}
\begin{definition}
For a left shape $\sigma$, define $\rho_{\sigma} \in {\mathcal P}_{V_{\sigma}}$, called the parity vector of $\sigma$, to be the parity vector such that for each vertex $i \in V_{\sigma}$, the $i$-th entry of $\rho_{\sigma}$ is the parity of $deg^{U_{\sigma}}(i) + deg^{\sigma}(i)$, that is $(\rho_{\sigma})_i \equiv deg^{U_{\sigma}}(i) + deg^{\sigma}(i) \pmod 2$.
For $U \in {\mathcal I}_{mid}$ and $\rho \in {\mathcal P}_U$, let ${\mathcal L}_{U, \rho}$ be the set of all left shapes $\sigma \in {\mathcal L}_U$ such that $\rho_{\sigma} = \rho$, that is, the set of all left shapes with parity vector $\rho$.
\end{definition}
For a shape $\tau$, for a $\tau$ coefficient matrix $H_{\tau}$ and parity vectors $\rho \in {\mathcal P}_{U_{\tau}}, \rho' \in {\mathcal P}_{V_{\tau}}$, define the $\tau$-coefficient matrix $H_{\tau, \rho, \rho'}$ as $H_{\tau ,\rho, \rho'}(\sigma, \sigma') = H_{\tau}(\sigma, \sigma')$ if $\sigma \in {\mathcal L}_{U_{\tau}, \rho}, \sigma' \in {\mathcal L}_{V_{\tau}, \rho'}$ and $0$ otherwise.
The following proposition is immediate.
\begin{propn}
For any shape $\tau$ and $\tau$-coefficient matrix $H_{\tau}$, we have the equality $H_{\tau} = \sum_{\rho \in {\mathcal P}_{U_{\tau}}, \rho' \in {\mathcal P}_{V_{\tau}}} H_{\tau, \rho, \rho'}$
\end{propn}
\begin{propn}
For any $U \in {\mathcal I}_{mid}$, $H_{Id_U} = \sum_{\rho \in {\mathcal P}_U} H_{Id_U, \rho, \rho}$
\end{propn}
\begin{proof}
For any $\sigma, \sigma' \in {\mathcal L}_U$, using \cref{def: tpca_coeffs}, note that in order for $H_{Id_U}(\sigma, \sigma')$ to be nonzero, we must have $\rho_{\sigma} = \rho_{\sigma'}$.
\end{proof}
We define the following quantity to capture the contribution of the vertices within $\sigma$ to the Fourier coefficients.
\begin{definition}
For a shape $\sigma\in {\mathcal L}$, if $deg^{\sigma}(i) + deg^{U_{\sigma}}(i)$ is even for all vertices $i \in V(\sigma) \setminus V_{\sigma}$, define
\[T(\sigma) = \Delta^{|V(\sigma)| - \frac{|V_{\sigma}|}{2}}\left(\frac{1}{\sqrt{\Delta n}}\right)^{deg(U_{\sigma})}\prod_{e \in E(\sigma)}\left(\frac{\lambda}{(\Delta n)^{\frac{k}{2}}}\right)^{l_e}\]
Otherwise, define $T(\sigma) = 0$.
For $U \in {\mathcal I}_{mid}$ and $\rho \in {\mathcal P}_U$, define $v_{\rho}$ to be the vector indexed by $\sigma \in {\mathcal L}$ such that $v_{\rho}(\sigma)$ is $T(\sigma)$ if $\sigma \in {\mathcal L}_{U, \rho}$ and $0$ otherwise.
\end{definition}
With this notation, the PSD mass condition is easily shown.
\begin{proof}[Proof of the PSD mass condition \cref{lem: tpca_cond1}]
For all $U\in {\mathcal I}_{mid}, \rho \in {\mathcal P}_U$, \cref{def: tpca_coeffs} implies $H_{Id_U, \rho, \rho} = \frac{1}{|Aut(U)|}v_{\rho}v_{\rho}^T$.
Therefore, \[H_{Id_U} = \sum_{\rho \in {\mathcal P}_U} H_{Id_U, \rho, \rho} = \frac{1}{|Aut(U)|} \sum_{\rho \in {\mathcal P}_U} v_{\rho}v_{\rho}^T \succeq 0\]
\end{proof}
\subsubsection{Qualitative middle shape bounds}
The next proposition captures the fact that when we compose shapes $\sigma, \tau, \sigma'^T$, in order for $\lambda_{\sigma \circ \tau \circ \sigma'^T}$ to be nonzero, the parities of the degrees of the merged vertices should add up correspondingly.
\begin{propn}\label{propn: tpca_coeff_2}
For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, there exist two sets of parity vectors $P_{\tau}, Q_{\tau} \subseteq {\mathcal P}_{U}$ and a bijection $\pi : P_{\tau} \rightarrow Q_{\tau}$ such that $H_{\tau} = \sum_{\rho \in P_{\tau}} H_{\tau, \rho, \pi(\rho)}$.
\end{propn}
\begin{proof}
Using \cref{def: tpca_coeffs}, in order for $H_{\tau}(\sigma, \sigma')$ to be nonzero, in $\sigma \circ \tau \circ \sigma'$, we must have that for all $i \in U_{\tau} \cup V_{\tau}$, $deg^{U_{\sigma}}(i) + deg^{U_{\sigma'}}(i) + deg^{\sigma \circ \tau \circ \sigma'^T}(i)$ must be even. In other words, for any $\rho \in {\mathcal P}_U$, there is at most one $\rho' \in {\mathcal P}_U$ such that if we take $\sigma \in {\mathcal L}_{U, \rho}, \sigma' \in {\mathcal L}_U$ with $H_{\tau}(\sigma, \sigma')$ nonzero, then the parity of $\sigma'$ is $\rho'$. Also, observe that $\rho'$ determines $\rho$. We then take $P_{\tau}$ to be the set of $\rho$ such that $\rho'$ exists, $Q_{\tau}$ to be the set of $\rho'$ and in this case, we define $\pi(\rho) = \rho'$.
\end{proof}
A straightforward verification of the conditions of \cref{def: tpca_coeffs} implies the following proposition.
\begin{propn}
For any $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, suppose we take $\rho \in P_{\tau}$. Let $\pi$ be the bijection from \cref{propn: tpca_coeff_2} so that $\pi(\rho) \in Q_{\tau}$. Then, $H_{\tau, \rho, \pi(\rho)} = \frac{1}{|Aut(U)|^2} S(\tau) v_{\rho}v_{\pi(\rho)}^T$.
\end{propn}
We can now prove the qualitative middle shape bounds.
\begin{proof}[Proof of the qualitative middle shape bounds \cref{lem: tpca_cond2_simplified}]
Let $P_{\tau}, Q_{\tau}, \pi$ be from \cref{propn: tpca_coeff_2}. For $\rho, \rho' \in {\mathcal P}_U$, let $W_{\rho, \rho'} = v_{\rho}(v_{\rho'})^T$. Then, $H_{Id_U} = \sum_{\rho \in {\mathcal P}_U} H_{Id_U, \rho, \rho} = \frac{1}{|Aut(U)|} \sum_{\rho \in {\mathcal P}_U}W_{\rho, \rho}$ and $H_{\tau} = \sum_{\rho \in P_{\tau}} H_{\tau, \rho, \pi(\rho)} = \frac{1}{|Aut(U)|^2}S(\tau)\sum_{\rho \in P_{\tau}} W_{\rho, \pi(\rho)}$. We have
\begin{align*}
\begin{bmatrix}
\frac{S(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix}
&= \frac{S(\tau)}{|Aut(U)|^2}
\begin{bmatrix}
\sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho} & \sum_{\rho \in P_{\tau}} W_{\rho, \pi(\rho)}\\
\sum_{\rho \in P_{\tau}} W_{\rho, \pi(\rho)}^T & \sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho}
\end{bmatrix}
\end{align*}
Since $\frac{S(\tau)}{|Aut(U)|^2} \ge 0$, it suffices to prove that $\begin{bmatrix}
\sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho} & \sum_{\rho \in P_{\tau}} W_{\rho, \pi(\rho)}\\
\sum_{\rho \in P_{\tau}} W_{\rho, \pi(\rho)}^T & \sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho}
\end{bmatrix}\succeq 0$. Consider
\begin{align*}
\begin{bmatrix}
\sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho} & \sum_{\rho \in P_{\tau}} W_{\rho, \pi(\rho)}\\
\sum_{\rho \in P_{\tau}} W_{\rho, \pi(\rho)}^T & \sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho}
\end{bmatrix} =& \begin{bmatrix}
\sum_{\rho \in {\mathcal P}_U \setminus P_{\tau}} W_{\rho, \rho} & 0\\
0 & \sum_{\rho \in {\mathcal P}_U \setminus Q_{\tau}} W_{\rho, \rho}
\end{bmatrix}\\
& + \begin{bmatrix}
\sum_{\rho \in P_{\tau}} W_{\rho, \rho} & \sum_{\rho \in P_{\tau}} W_{\rho, \pi(\rho)}\\
\sum_{\rho \in P_{\tau}} W_{\rho, \pi(\rho)}^T & \sum_{\rho \in P_{\tau}} W_{\pi(\rho), \pi(\rho)}
\end{bmatrix}\\
\end{align*}
We have $\sum_{\rho \in {\mathcal P}_U \setminus P_{\tau}} W_{\rho, \rho} = \sum_{\rho \in {\mathcal P}_U \setminus P_{\tau}} v_{\rho}v_{\rho}^T \succeq 0$. Similarly, $\sum_{\rho \in {\mathcal P}_U \setminus Q_{\tau}} W_{\rho, \rho} \succeq 0$ and so, the first term in the above expression,
$\begin{bmatrix}
\sum_{\rho \in {\mathcal P}_U \setminus P_{\tau}} W_{\rho, \rho} & 0\\
0 & \sum_{\rho \in {\mathcal P}_U \setminus Q_{\tau}} W_{\rho, \rho}
\end{bmatrix}$ is positive semidefinite. For the second term,
\begin{align*}
\begin{bmatrix}
\sum_{\rho \in P_{\tau}} W_{\rho, \rho} & \sum_{\rho \in P_{\tau}} W_{\rho, \pi(\rho)}\\
\sum_{\rho \in P_{\tau}} W_{\rho, \pi(\rho)}^T & \sum_{\rho \in P_{\tau}} W_{\pi(\rho), \pi(\rho)}
\end{bmatrix} &= \sum_{\rho \in P_{\tau}}
\begin{bmatrix}
W_{\rho, \rho} & W_{\rho, \pi(\rho)}\\
W_{\rho, \pi(\rho)}^T & W_{\pi(\rho), \pi(\rho)}
\end{bmatrix}\\
&= \sum_{\rho \in P_{\tau}}
\begin{bmatrix}
v_{\rho}v_{\rho}^T & v_{\rho}(v_{\pi(\rho)})^T\\
v_{\pi(\rho)}(v_{\rho})^T & v_{\pi(\rho)}(v_{\pi(\rho)})^T
\end{bmatrix}\\
&= \sum_{\rho \in P_{\tau}}
\begin{bmatrix}
v_{\rho}\\
v_{\pi(\rho)}
\end{bmatrix}
\begin{bmatrix}
v_{\rho} &
v_{\pi(\rho)}
\end{bmatrix}\\
& \succeq 0
\end{align*}
\end{proof}
\subsubsection{Qualitative intersection term bounds}
Similar to \cref{propn: tpca_coeff_2}, the next proposition captures the fact that when we compose shapes $\sigma, \gamma, \gamma^T, \sigma'^T$, in order for $\lambda_{\sigma \circ \gamma \circ \gamma'^T \circ \sigma'^T}$ to be nonzero, the parities of the degrees of the merged vertices should add up correspondingly.
We use the following notation.
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$, for $\gamma \in \Gamma_{U, V}$ and parity vectors $\rho, \rho' \in {\mathcal P}_U$, define the $\gamma \circ \gamma^T$-coefficient matrix $H_{Id_V, \rho, \rho'}^{-\gamma, \gamma}$ as $H_{Id_V, \rho, \rho'}^{-\gamma, \gamma}(\sigma, \sigma') = H_{Id_V}^{-\gamma, \gamma}(\sigma, \sigma')$ if $\sigma \in {\mathcal L}_{U, \rho}, \sigma' \in {\mathcal L}_{U, \rho'}$ and $0$ otherwise.
\begin{propn}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$, for all $\gamma \in \Gamma_{U, V}$, there exists a set of parity vectors $P_{\gamma} \subseteq {\mathcal P}_U$ such that
$H_{Id_V}^{-\gamma, \gamma} = \sum_{\rho \in P_{\gamma}} H_{Id_V, \rho, \rho}^{-\gamma, \gamma}$.
\end{propn}
\begin{proof}
Take any $\rho \in {\mathcal P}_U$. For $\sigma \in {\mathcal L}_{U, \rho}, \sigma' \in {\mathcal L}_U$, since $H_{Id_V}^{-\gamma, \gamma}(\sigma, \sigma') = \frac{\lambda_{\sigma \circ \gamma \circ \gamma^T \circ \sigma'^T}}{|Aut(V)|}$, $H_{Id_V}^{-\gamma, \gamma}(\sigma, \sigma')$ is nonzero precisely when $\lambda_{\sigma \circ \gamma \circ \gamma^T \circ \sigma'^T}$ is nonzero. For this quantity to be nonzero, using \cref{def: tpca_coeffs}, we get that it is necessary, but not sufficient, that the parity vector of $\sigma'$ must also be $\rho$. And also observe that there exists a set $P_{\gamma}$ of parity vectors $\rho$ for which $H_{Id_V, \rho, \rho}^{-\gamma, \gamma}$ is nonzero and their sum is precisely $H_{Id_V}^{-\gamma, \gamma}$.
\end{proof}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$, for all $\gamma \in \Gamma_{U, V}$ and parity vector $\rho \in {\mathcal P}_U$, define the matrix $H'_{\gamma, \rho, \rho}$ as $H'_{\gamma, \rho, \rho}(\sigma, \sigma') = H'_{\gamma}(\sigma, \sigma')$ if $\sigma, \sigma' \in {\mathcal L}_{U, \rho}$ and $0$ otherwise. The following proposition is immediate from the definition.
\begin{propn}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$, for $\gamma \in \Gamma_{U, V}$, $H_{\gamma}' = \sum_{\rho \in P_{\gamma}} H_{\gamma, \rho, \rho}'$.
\end{propn}
\begin{propn}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$, for all $\gamma \in \Gamma_{U, V}$ and $\rho \in P_{\gamma}$,
\[H_{Id_V, \rho, \rho}^{-\gamma, \gamma} = \frac{|Aut(U)|}{|Aut(V)|} S(\gamma)^2 H'_{\gamma, \rho, \rho}\]
\end{propn}
\begin{proof}
Fix $\sigma, \sigma' \in {\mathcal L}_{U, \rho}$ such that $|V(\sigma \circ \gamma)|, |V(\sigma' \circ \gamma)| \le D_V$. Note that $|V(\sigma)| - \frac{|V_{\sigma}|}{2} + |V(\sigma')| - \frac{|V_{\sigma'}|}{2} + 2(|V(\gamma)| - \frac{|U_{\gamma}| + |V_{\gamma}|}{2}) = |V(\sigma \circ \gamma \circ \gamma^T \circ \sigma'^T)|$. Using \cref{def: tpca_coeffs}, we can easily verify that $\lambda_{\sigma \circ \gamma \circ \gamma^T \circ \sigma'^T} = T(\sigma)T(\sigma') S(\gamma)^2$. Therefore, $H_{Id_V, \rho, \rho}^{-\gamma, \gamma}(\sigma, \sigma') = \frac{|Aut(U)|}{|Aut(V)|} S(\gamma)^2 H_{Id_U, \rho, \rho}(\sigma, \sigma')$. Since $H'_{\gamma, \rho, \rho}(\sigma, \sigma') = H_{Id_U, \rho, \rho}(\sigma, \sigma')$ whenever we have $|V(\sigma \circ \gamma)|, |V(\sigma' \circ \gamma)| \le D_V$, this completes the proof.
\end{proof}
With this, we can prove the qualitative intersection term bounds.
\begin{proof}[Proof of qualitative intersection term bounds \cref{lem: tpca_cond3_simplified}]
We have
\begin{align*}
\frac{|Aut(V)|}{|Aut(U)|}\cdot\frac{1}{S(\gamma)^2}H_{Id_V}^{-\gamma, \gamma} = \sum_{\rho \in P_{\gamma}} \frac{|Aut(V)|}{|Aut(U)|}\cdot\frac{1}{S(\gamma)^2} H_{Id_V, \rho, \rho}^{-\gamma, \gamma}
= \sum_{\rho \in P_{\gamma}} H'_{\gamma, \rho, \rho}
&\preceq \sum_{\rho \in {\mathcal P}_U} H'_{\gamma, \rho, \rho}\\
&= H'_{\gamma}
\end{align*}
where we used the fact that for all $\rho \in {\mathcal P}_U$, we have $H'_{\gamma,\rho, \rho} \succeq 0$.
\end{proof}
\subsection{Warm-up: Analysis with no intersection terms}
In this subsection, we show how the analysis works if we ignore the difference between $M^{fact}$ and $M^{orth}$
\begin{theorem}\label{thm:nointersectionanalysis}
For all $\varepsilon' \in (0,\frac{1}{2}]$, if the norm bounds hold and the following conditions hold
\begin{enumerate}
\item For all $U \in \mathcal{I}_{mid}$, $H_{Id_{U}} \succeq 0$
\item For all $U \in \mathcal{I}_{mid}$ and all $\tau \in \mathcal{M}_U$
\[
\left[ {\begin{array}{cc}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_{U}} & B_{norm}(\tau)H_{\tau} \\
B_{norm}(\tau)H^T_{\tau} & \frac{1}{|Aut(U)|c(\tau)}H_{Id_{U}}
\end{array}} \right] \succeq 0
\]
\item $\forall U \in \mathcal{I}_{mid}, \sum_{\tau \in \mathcal{M}_U}{\frac{1}{|Aut(U)|c(\tau)}} \leq \varepsilon'$.
\end{enumerate}
then
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}(H_{Id_U})} + \sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_U}{M^{fact}_{\tau}(H_{\tau})} \succeq (1-2\varepsilon')\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}(H_{Id_U})}} \succeq 0
\]
\end{theorem}
\begin{proof}
We first show how a single term $M_{\sigma}M_{\tau}M_{{\sigma'}^T}$ plus its transpose $M_{\sigma'}M_{{\tau}^T}M_{{\sigma}^T}$ can be bounded.
\begin{lemma}
If the norm bounds hold then for all $\tau \in \mathcal{M}'$ and shapes $\sigma,\sigma'$ such that $\sigma,\tau,{\sigma'}^T$ are composable, for all $a,b$ such that $a > 0$, $b > 0$, and $ab = B_{norm}(\tau)^2$,
\[
M_{\sigma}M_{\tau}M_{{\sigma'}^T} + M_{\sigma'}M_{{\tau}^T}M_{{\sigma}^T} \preceq aM_{\sigma}M_{\sigma^T} + bM_{\sigma'}M_{{\sigma'}^T}
\]
\end{lemma}
\begin{proof}
Observe that
\begin{align*}
0 \preceq &\left(\sqrt{a}M_{\sigma} - \frac{\sqrt{b}}{B_{norm}(\tau)}M_{{\sigma'}}M_{\tau^T}\right)\left(\sqrt{a}M_{\sigma} - \frac{\sqrt{b}}{B_{norm}(\tau)}M_{{\sigma'}}M_{\tau^T}\right)^T = \\
&\left(\sqrt{a}M_{\sigma} - \frac{\sqrt{b}}{B_{norm}(\tau)}M_{{\sigma'}}M_{\tau}\right)\left(\sqrt{a}M_{{\sigma}^T} - \frac{\sqrt{b}}{B_{norm}(\tau)}M_{{\tau}}M_{{\sigma'}^T}\right) = \\
&aM_{\sigma}M_{\sigma^T} - M_{\sigma}M_{\tau}M_{{\sigma'}^T} - M_{\sigma'}M_{{\tau}^T}M_{{\sigma}^T} + \frac{b}{B_{norm}(\tau)^2}M_{\sigma'}M_{\tau^{T}}M_{\tau}M_{{\sigma'}^T} \preceq \\
&aM_{\sigma}M_{\sigma^T} - M_{\sigma}M_{\tau}M_{{\sigma'}^T} - M_{\sigma'}M_{{\tau}^T}M_{{\sigma}^T} + \frac{b}{B_{norm}(\tau)^2}M_{\sigma'}(B_{norm}(\tau)^2{Id})M_{{\sigma'}^T}
\end{align*}
Thus, $M_{\sigma}M_{\tau}M_{{\sigma'}^T} + M_{\sigma'}M_{{\tau}^T}M_{{\sigma}^T} \preceq aM_{\sigma}M_{\sigma^T} + bM_{\sigma'}M_{{\sigma'}^T}$, as needed.
\end{proof}
Unfortunately, if we try to bound everything term by term, there may be too many terms to bound. Instead, we generalize this argument for vectors and coefficient matrices.
\begin{definition}
Let $\tau$ be a shape. We say that a vector $v$ is a left $\tau$-vector if the coordinates of $v$ are indexed by left shapes $\sigma \in \mathcal{L}_{U_{\tau}}$. We say that a vector $w$ is a right $\tau$-vector if the coordinates of $w$ are indexed by left shapes $\sigma' \in \mathcal{L}_{V_{\tau}}$.
\end{definition}
\begin{lemma}\label{lm:rankonetosquares}
For all $\tau \in \mathcal{M}'$, if the norm bounds hold, $v$ is a left $\tau$-vector, and $w$ is a right $\tau$-vector then
\[
M^{fact}_{\tau}(vw^T) + M^{fact}_{{\tau}^T}(wv^T) \preceq B_{norm}(\tau)\left(M^{fact}_{Id_{U_{\tau}}}(vv^T) + M^{fact}_{Id_{V_{\tau}}}(ww^T)\right)
\]
and
\[
-M^{fact}_{\tau}(vw^T) - M^{fact}_{{\tau}^T}(wv^T) \preceq B_{norm}(\tau)\left(M^{fact}_{Id_{U_{\tau}}}(vv^T) + M^{fact}_{Id_{V_{\tau}}}(ww^T)\right)
\]
\end{lemma}
\begin{proof}
Observe that
\begin{align*}
0 \preceq &\left(\sum_{\sigma}{v_{\sigma}M_{\sigma} \mp \frac{w_{\sigma}M_{\sigma}M_{{\tau}^T}}{B_{norm}(\tau)}}\right)
\left(\sum_{\sigma'}{v_{\sigma'}M_{\sigma'} \mp \frac{w_{\sigma'}M_{\sigma'}M_{{\tau}^T}}{B_{norm}(\tau)}}\right)^T = \\
&\left(\sum_{\sigma}{v_{\sigma}M_{\sigma} \mp \frac{w_{\sigma}M_{\sigma}M_{{\tau}^T}}{B_{norm}(\tau)}}\right)\left(\sum_{\sigma'}{v_{\sigma'}M_{{\sigma'}^T} \mp \frac{w_{{\sigma'}}M_{\tau}M_{{\sigma'}^T}}{B_{norm}(\tau)}}\right) = \\
&\sum_{\sigma,\sigma'}{\left(v_{\sigma}v_{\sigma'}\right)M_{\sigma}M_{{\sigma'}^T}} \mp \sum_{\sigma,\sigma'}{\frac{\left(v_{\sigma}w_{\sigma'}\right)}{B_{norm}(\tau)}M_{\sigma}M_{\tau}M_{\sigma'}} \\
&\mp \sum_{\sigma,\sigma'}{\frac{\left(w_{\sigma}v_{\sigma'}\right)}{B_{norm}(\tau)}M_{\sigma}M_{{\tau}^T}M_{\sigma'}} +
\frac{1}{B_{norm}(\tau)^2}\sum_{\sigma,\sigma'}{\left(v_{\sigma}v_{\sigma'}\right)M_{\sigma}M_{\tau}M_{{\tau}^T}M_{{\sigma'}^T}}
\end{align*}
Further observe that
\begin{enumerate}
\item $\sum_{\sigma,\sigma'}{\left(v_{\sigma}v_{\sigma'}\right)M_{\sigma}M_{{\sigma'}^T}} = M^{fact}_{Id_{U_{\tau}}}(vv^T)$
\item $\sum_{\sigma,\sigma'}{\left(v_{\sigma}w_{\sigma'}\right)M_{\sigma}M_{\tau}M_{{\sigma'}^T}} = M^{fact}_{\tau}(vw^T)$
\item $\sum_{\sigma,\sigma'}{\left(w_{\sigma}v_{\sigma'}\right)M_{\sigma}M_{{\tau}^T}M_{{\sigma'}^T}} = M^{fact}_{{\tau}^T}(wv^T)$
\item
\begin{align*}
\sum_{\sigma,\sigma'}{\left(w_{\sigma}w_{\sigma'}\right)M_{\sigma}M_{\tau}M_{{\tau}^T}M_{{\sigma'}^T}}
&= \left(\sum_{\sigma}{w_{\sigma}M_{\sigma}}\right)M_{\tau}M_{{\tau}^T}\left(\sum_{\sigma}{w_{\sigma}M_{\sigma}}\right)^T \\
&\preceq \left(\sum_{\sigma}{w_{\sigma}M_{\sigma}}\right)B_{norm}(\tau)^2{Id}\left(\sum_{\sigma}{w_{\sigma}M_{\sigma}}\right)^T \\
&= B_{norm}(\tau)^2\sum_{\sigma,\sigma'}{\left(w_{\sigma}w_{\sigma'}\right)M_{\sigma}M_{{\sigma'}^T}} \\
&= {B_{norm}(\tau)^2}M^{fact}_{Id_{V_{\tau}}}(ww^T)
\end{align*}
\end{enumerate}
Putting everything together,
\[
\frac{M^{fact}_{\tau}(vw^T) + M^{fact}_{{\tau}^T}(wv^T)}{B_{norm}(\tau)} \preceq M^{fact}_{Id_{U_{\tau}}}(vv^T) + M^{fact}_{Id_{V_{\tau}}}(ww^T)
\]
and
\[
-\frac{M^{fact}_{\tau}(vw^T) + M^{fact}_{{\tau}^T}(wv^T)}{B_{norm}(\tau)} \preceq M^{fact}_{Id_{U_{\tau}}}(vv^T) + M^{fact}_{Id_{V_{\tau}}}(ww^T)
\]
as needed.
\end{proof}
\begin{corollary}\label{cor:factorizedmatrixbound}
For all $\tau \in \mathcal{M}'$, if the norm bounds hold and $H_U$ and $H_V$ are matrices such that
\[
\left[ {\begin{array}{cc}
H_{U} & B_{norm}(\tau)H_{\tau} \\
B_{norm}(\tau)H^T_{\tau} & H_{V}
\end{array}} \right] \succeq 0
\]
then $M^{fact}_{\tau}(H_{\tau}) + M^{fact}_{{\tau}^T}(H_{\tau^T}) \preceq M^{fact}_{Id_{U_{\tau}}}(H_{U}) + M^{fact}_{Id_{V_{\tau}}}(H_{V})$
\end{corollary}
\begin{proof}
If $ \left[ {\begin{array}{cc}
H_{U} & B_{norm}(\tau)H_{\tau} \\
B_{norm}(\tau)H^T_{\tau} & H_{V}
\end{array}} \right] \succeq 0$ then we can write
\[ \left[ {\begin{array}{cc}
H_{U} & B_{norm}(\tau)H_{\tau} \\
B_{norm}(\tau)H^T_{\tau} & H_{V}
\end{array}} \right] = \sum_{i}{(v_i,w_i)(v_i,w_i)^T}
\]
Since the $M^{fact}$ operations are linear, the result now follows by summing the equation
\[
M^{fact}_{\tau}({v_i}w_i^T) + M^{fact}_{{\tau}^T}({w_i}v_i^T) \preceq B_{norm}(\tau)\left(M^{fact}_{Id_{U_{\tau}}}({v_i}v_i^T) + M^{fact}_{Id_{V_{\tau}}}({w_i}w_i^T)\right)
\]
over all $i$.
\end{proof}
Theorem \ref{thm:nointersectionanalysis} now follows directly. For all $U \in \mathcal{I}_{mid}$ and all $\tau \in \mathcal{M}_U$, using Corollary \ref{cor:factorizedmatrixbound} with $H_U = H_V = \frac{1}{|Aut(U)|c(\tau)}H_{Id_{U}}$,
\[
M^{fact}_{\tau}(H_{\tau}) + M^{fact}_{{\tau}^T}(H_{\tau^T}) \preceq \frac{1}{|Aut(U)|c(\tau)}M^{fact}_{Id_{U}}(H_{Id_{U}}) + \frac{1}{|Aut(U)|c(\tau)}M^{fact}_{Id_{U}}(H_{Id_{U}})
\]
Summing this equation over all $U \in \mathcal{I}_{mid}$ and all $\tau \in \mathcal{M}_U$, we obtain that
\[
\sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_U}{M^{fact}_{\tau}(H_{\tau})}} \preceq 2\varepsilon'\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}(H_{Id_U})}
\] as needed.
\end{proof}
\subsection{Intersection Term Analysis Strategy}\label{qualitativeintersectionpatternssection}
As we saw in the previous subsection, the analysis works out nicely if we work with $M^{fact}$. Unfortunately, our matrices are expressed in terms of $M^{orth}$. In this subsection, we describe our strategy for analyzing the difference between $M^{fact}$ and $M^{orth}$.
Recall the following expressions for $\left(M^{fact}_{\tau}(H)\right)(A,B)$ and $\left(M^{orth}_{\tau}(H)\right)(A,B)$ where $A$ has shape $U_{\tau}$ and $B$ has shape $V_{\tau}$:
\[
\left(M^{fact}_{\tau}(H)\right)(A,B) = \sum_{\sigma \in \mathcal{L}_{U_{\tau}}, \sigma' \in \mathcal{L}_{V_{\tau}}}{H(\sigma,\sigma')\sum_{A',B'}{
\sum_{R_1 \in \mathcal{R}(\sigma,A,A'), R_2 \in \mathcal{R}(\tau,A',B'), \atop R_3 \in \mathcal{R}({\sigma'}^T,B',B)}M_{R_1}(A,A')M_{R_2}(A',B')M_{R_3}(B',B)}}
\]
\begin{align*}
&\left(M^{orth}_{\tau}(H)\right)(A,B) \\
&= \sum_{\sigma \in \mathcal{L}_{U_{\tau}}, \sigma' \in \mathcal{L}_{V_{\tau}}}{H(\sigma,\sigma')\sum_{A',B'}{
\sum_{R_1 \in \mathcal{R}(\sigma,A,A'), R_2 \in \mathcal{R}(\tau,A',B'), \atop {R_3 \in \mathcal{R}({\sigma'}^T,B',B), R_1,R_2,R_3 \text{ are properly composable}}}M_{R_1}(A,A')M_{R_2}(A',B')M_{R_3}(B',B)}}
\end{align*}
This implies that $\left(M^{fact}_{\tau}(H)\right)(A,B) - \left(M^{orth}_{\tau}(H)\right)(A,B)$ is equal to
\[
\sum_{\sigma \in \mathcal{L}_{U_{\tau}}, \sigma' \in \mathcal{L}_{V_{\tau}}}{H(\sigma,\sigma')\sum_{A',B'}{
\sum_{R_1 \in \mathcal{R}(\sigma,A,A'), R_2 \in \mathcal{R}(\tau,A',B'), \text{ and } R_3 \in \mathcal{R}({\sigma'}^T,B',B) \atop R_1,R_2,R_3 \text{ are not properly composable}}M_{R_1}(A,A')M_{R_2}(A',B')M_{R_3}(B',B)}}
\]
Thus, to understand the difference between $M^{fact}$ and $M^{orth}$, we need to analyze the terms $\chi_{R_1}\chi_{R_2}\chi_{R_3} = \chi_{R_1 \circ R_2 \circ R_3}$ for ribbons $R_1,R_2,R_3$ which are composable but not properly composable. These terms, which we call intersection terms, are not negligible and must be analyzed carefully. In particular, we decompose each resulting ribbon $R = R_1 \circ R_2 \circ R_3$ into new left, middle, and right parts. We do this as follows:
\begin{enumerate}
\item Let $V_{*}$ be the set of vertices which appear more than once in $V(R_1 \circ R_2 \circ R_3)$. In other words, $V_{*}$ is the set of vertices involved in the intersections between $R_1$, $R_2$, and $R_3$ (not counting the facts that $B_{R_1} = A_{R_2}$ and $B_{R_2} = A_{R_3}$ because we expect these intersections).
\item Let $A'$ be the leftmost minimum vertex separator of $A_{R_1}$ and $B_{R_1} \cup V_{*}$ in $R_1$. We turn $A'$ into a matrix index by specifying an ordering $O_{A'}$ for the vertices in $A'$.
\item Let $B'$ be the leftmost minimum vertex separator of $A_{R_3} \cup V_{*}$ and $B_{R_3}$ in $R_2$. We turn $B'$ into a matrix index by specifying an ordering $O_{B'}$ for the vertices in $B'$.
\item Decompose $R_1$ as $R_1 = {R'}_1 \cup R_4$ where ${R'}_1$ is the part of $R_1$ between $A_{R_1}$ and $A'$ and $R_4$ is the part of $R_1$ between $B'$ and $B_{R_1} = A_{R_2}$. Similarly, decompose
$R_3$ as $R_3 = R_5 \cup {R'}_3 $ where $R_5$ is the part of $R_3$ between $B_{R_1} = A_{R_2}$ and $B'$ and ${R'}_3$ is the part of $R_3$ between $B'$ and $B_{R_3}$.
\item Take $R'_2 = R_4 \circ R_2 \circ R_5$ and note that $R'_1 \circ R'_2 \circ R'_3 = R_1 \circ R_2 \circ R_3$. We view $R'_1,R'_2,R'_3$ as the left, middle, and right parts of $R = R_1 \circ R_2 \circ R_3$
\end{enumerate}
While we will verify our analysis by checking the coefficients of the ribbons, we want to express everything in terms of shapes. We use the following conventions for the names of the shapes:
\begin{enumerate}
\item As usual, we let $\sigma$, $\tau$, and ${\sigma'}^T$ be the shapes of $R_1$, $R_2$, and $R_3$.
\item We let $\gamma$ and ${\gamma'}^T$ be the shapes of $R_4$ and $R_5$.
\item We let $\sigma_2$, $\tau_{P}$, and ${\sigma'_2}^T$ be the shapes of $R'_1$, $R'_2$, and $R'_3$. Here $P$ is the intersection pattern induced by $R_4$, $R_2$, and $R_5$ which we define in the next subsection.
\end{enumerate}
\begin{remark}
A key feature of our analysis is that it will work the same way regardless of the shapes $\sigma_2,{\sigma'_2}^T$ of $R'_1$ and $R'_3$. In other words, if we replace $\sigma_2$ by $\sigma_{2a}$ and $\sigma'_2$ by $\sigma'_{2a}$ for a given intersection term, this just replaces $\sigma = \sigma_2 \cup \gamma$ with $\sigma_{a} = \sigma_{2a} \cup \gamma$ and $\sigma' = \sigma'_2 \cup \gamma'$ with $\sigma'_{a} = \sigma'_{2a} \cup \gamma'$. This allows us to focus on the shapes $\gamma$, $\tau$, and ${\gamma'}^T$ and is the reason why the $-\gamma,\gamma$ operation appears in our results.
\end{remark}
\subsection{Intersection Term Analysis}\label{intersectiontermanalysissection}
In this section, we implement our strategy for analyzing intersection terms. For simplicity, we only give rough definitions and proof sketches here. For a more rigorous treatment, see Apendix \ref{canonicalmapsection}.
We begin by defining intersection patterns which describe how the ribbons $R_1$, $R_2$, and $R_3$ intersect.
\begin{definition}[Rough Definition of Intersection Patterns]\label{intersectionpatternroughdef}
Given $\tau \in \mathcal{M}'$, $\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\}$, $\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}$, and ribbons $R_1$, $R_2$, and $R_3$ of shapes $\gamma$, $\tau$, and ${\gamma'}^T$ which are composable but not properly composable, we define the intersection pattern $P$ induced by $R_1$, $R_2$, and $R_3$ and the resulting shape $\tau_P$ as follows:
\begin{enumerate}
\item We take $V(P) = V(\gamma \circ \tau \circ {\gamma'}^T)$.
\item We take $E(P)$ to be the set of edges $(u,v)$ such that $u,v$ are distinct vertices in $V(\sigma \circ \tau \circ {\sigma'}^T)$ but $u$ and $v$ correspond to the same vertex in $R_1 \circ R_2 \circ R_3$
\item We define $\tau_{P}$ to be the shape of the ribbon $R = R_1 \circ R_2 \circ R_3$
\end{enumerate}
\end{definition}
\begin{definition}\label{setPdefinition}
Given $\tau \in \mathcal{M}'$, $\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\}$, and $\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}$, we define $\mathcal{P}_{\gamma,\tau,{\gamma'}^T}$ to be the set of all possible intersection patterns $P$ which can be induced by ribbons $R_1$, $R_2$, and $R_3$ of shapes $\gamma$, $\tau$, and ${\gamma'}^T$.
\end{definition}
\begin{remark}
Note that if $\gamma = Id_{U_{\tau}}$ and $\gamma' = Id_{V_{\tau}}$ then $\mathcal{P}_{\gamma,\tau,{\gamma'}^T} = \emptyset$ as every intersection pattern must have an unexpected intersection so either $\gamma$ or $\gamma'$ must be non-trivial.
\end{remark}
It would be nice if the intersection pattern $P$ together with the ribbon $R$ allowed us to recover the original ribbons $R_1$, $R_2$, and $R_3$. Unfortunately, it is possible for different triples of ribbons to result in the same intersection pattern $P$ and ribbon $R$. That said, the number of such triples cannot be too large, and this is sufficient for our purposes.
\begin{definition}
Given an intersection pattern $P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}$, let $R$ be a ribbon of shape $\tau_{P}$. We define $N(P)$ to be the number of different triples of ribbons $R_1,R_2,R_3$ such that $R_1 \circ R_2 \circ R_3 = R$ and $R_1,R_2,R_3$ induce the intersection pattern $P$.
\end{definition}
\begin{lemma}
For all intersection patterns $P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}$, $N(P) \leq |V(\tau_{P})|^{|V(\gamma) \setminus U_{\gamma}| + |V(\gamma') \setminus U_{\gamma'}|}$
\end{lemma}
\begin{proof}[Proof sketch]
This can be proved by making the following observations:
\begin{enumerate}
\item $A_{R_1} = A_{R}$ and $B_{R_3} = B_{R}$.
\item All of the remining vertices in $V(R_1)$ and $V(R_3)$ must be equal to some vertex in $V(R)$.
\item Once $R_1$ and $R_3$ are determined, there is at most one ribbon $R_2$ such that $R_1,R_2,R_3$ are composable, $R = R_1 \circ R_2 \circ R_3$, and $R_1,R_2,R_3$ induce the intersection pattern $P$.
\end{enumerate}
\end{proof}
With these definitions, we can now analyze the intersection terms.
\begin{definition}
Given a left shape $\sigma$, define $e_{\sigma}$ to be the vector which has a $1$ in coordinate $\sigma$ and has a $0$ in all other coordinates.
\end{definition}
\begin{lemma}\label{lm:singleshapeintersections}
For all $\tau \in \mathcal{M}'$, $\sigma \in \mathcal{L}_{U_{\tau}}$, and $\sigma' \in \mathcal{L}_{V_{\tau}}$,
\begin{align*}
&M^{fact}_{\tau}(e_{\sigma}e^T_{\sigma'}) - M^{orth}_{\tau}(e_{\sigma}e^T_{\sigma'}) = \sum_{\sigma_2 \in \mathcal{L}, \gamma \in \Gamma: \sigma_2 \circ \gamma = \sigma}{\frac{1}{|Aut(U_{\gamma})|}\sum_{P \in \mathcal{P}_{\gamma,\tau,Id_{V_{\tau}}}}N(P)M^{orth}_{\tau_P}(e_{\sigma_2}e^T_{\sigma'})} \\
&+ \sum_{\sigma'_2 \in \mathcal{L}, \gamma' \in \Gamma: \sigma'_2 \circ \gamma' = \sigma'}{\frac{1}{|Aut(U_{\gamma'})|}\sum_{P \in \mathcal{P}_{Id_{U_{\tau}},\tau,{\gamma'}^T}}N(P)M^{orth}_{\tau_P}(e_{\sigma}e^T_{\sigma'_2})} \\
&+ \sum_{\sigma_2 \in \mathcal{L}, \gamma \in \Gamma: \sigma_2 \circ \gamma = \sigma}{\sum_{\sigma'_2 \in \mathcal{L}, \gamma' \in \Gamma: \sigma'_2 \circ \gamma' = \sigma'}{
\frac{1}{|Aut(U_{\gamma})|\cdot|Aut(U_{\gamma'})|}\sum_{P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}}N(P)M^{orth}_{\tau_P}(e_{\sigma_2}e^T_{\sigma'_2})}}
\end{align*}
\end{lemma}
\begin{proof}[Proof sketch]
This lemma follows from the following bijection. Consider the third term
\[
\sum_{\sigma_2 \in \mathcal{L}, \gamma \in \Gamma: \sigma_2 \circ \gamma = \sigma}{\sum_{\sigma'_2 \in \mathcal{L}, \gamma' \in \Gamma: \sigma'_2 \circ \gamma' = \sigma'}{
\frac{1}{|Aut(U_{\gamma})|\cdot|Aut(U_{\gamma'})|}\sum_{P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}}N(P)M^{orth}_{\tau_P}(e_{\sigma_2}e^T_{\sigma'_2})}}
\]
On one side, we have the following data:
\begin{enumerate}
\item Ribbons $R_1$, $R_2$, and $R_3$ of shapes $\gamma,\tau,{\gamma'}^T$ such that $R_1,R_2,R_3$ are composable but $R_1$ and $R_2 \circ R_3$ are not properly composable (i.e. $R_1$ has an unexpected intersection with $R_2$ and/or $R_3$) and $R_1 \circ R_2$ and $R_3$ are not properly composable (i.e. $R_3$ has an unexpected intersection with $R_1$ and/or $R_2$).
\item An ordering $O_{A'}$ on the leftmost minimum vertex separator $A'$ of $A_{R_1}$ and $V_{*} \cup B_{R_1}$ (recall that $V_{*}$ is the set of vertices which appear more than once in $V(R_1 \circ R_2 \circ R_3)$).
\item An ordering $O_{B'}$ on the rightmost minimum vertex separator $B'$ of $V_{*} \cup A_{R_3}$ and $B_{R_3}$.
\end{enumerate}
On the other side, we have the following data
\begin{enumerate}
\item An intersection pattern $P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}$ where $\gamma$ and ${\gamma'}^T$ are non-trivial.
\item Ribbons $R'_1$, $R'_2$, $R'_3$ of shapes $\sigma_2$, $\tau_P$, ${\sigma'_2}^T$ which are properly composable
\item A number in $[N(P)]$ describing which possible triple of ribbons resulted in the intersection pattern $P$ and the ribbon $R'_2$.
\end{enumerate}
To see this bijection, note that given the data on the first side, we can recover the ribbons $R'_1$, $R'_2$, and $R'_3$ as follows:
\begin{enumerate}
\item We decompose $R_1$ as $R_1 = R'_1 \circ R_4$ where $B_{R'_1} = A_{R_4} = A'$ with the ordering $O_{A'}$.
\item We decompose $R_3$ as $R_3 = R_5 \circ R'_3$ where where $B_{R_5} = A_{R'_3} = B'$ with the ordering $O_{B'}$.
\item We take $R'_2 = R_4 \circ R_2 \circ R_5$.
\end{enumerate}
The intersection pattern $P$ and the number in $[N(P)]$ can be obtained from $R_1$, $R_2$, and $R_3$.
Conversely, with the data on the other side, we can recover the data on the first side as follows:
\begin{enumerate}
\item $R'_2$ gives an ordering $O_{A'}$ for $A' = A_{R'_2}$ and an ordering $O_{B'}$ for $B' = B_{R'_2}$.
\item The ribbon $R'_2$, intersection pattern $P$, and number in $[N(P)]$ allow us to recover $R_4$, $R_2$, and $R_5$.
\item We take $R_1 = R'_1 \circ R_4$ and $R_3 = R_5 \circ R'_3$.
\end{enumerate}
Thus, both sides have the same coefficient for each ribbon.
The analysis for the the first term is the same except that when $\gamma'$ is trivial, we always take $\gamma' = Id_{V_{\tau}}$. Thus, we always have that $B' = B_{R'_2} = B_{R_2}$ (with the same ordering) and $R'_3 = R_3 = Id_{B'}$. Because of this, there is no need to specify $R_3$, $R'_3$, $R_5$, or an ordering on $B'$.
Similarly, the analysis for the the second term is the same except that when $\gamma$ is trivial, we always take $\gamma = Id_{U_{\tau}}$. Thus, we always have that $A' = A_{R'_2} = A_{R_2}$ (with the same ordering) and $R'_1 = R_1 = Id_{A'}$. Because of this, there is no need to specify $R_1$, $R'_1$, $R_4$, or an ordering on $A'$.
\end{proof}
Applying Lemma \ref{lm:singleshapeintersections} for all $\sigma$ and $\sigma'$ simultaneously, we obtain the following corollary.
\begin{definition}
For all $U,V \in \mathcal{I}_{mid}$, given a $\gamma \in \Gamma_{U,V}$ and a vector $v$ indexed by left shapes $\sigma \in \mathcal{L}_V$, define $v^{-\gamma}$ to be the vector indexed by left shapes $\sigma_2 \in \mathcal{L}_{U}$ such that $v^{-\gamma}(\sigma_2) = v(\sigma_2 \circ \gamma)$ if $\sigma_2 \circ \gamma \in \mathcal{L}_V$ and $v^{-\gamma}(\sigma_2) = 0$ otherwise.
\end{definition}
\begin{proposition}
For all composable $\gamma_2,\gamma_1 \in \Gamma$ and all vectors $v$ indexed by left shapes in $\mathcal{L}_{V_{\gamma_1}}$, $(v^{-\gamma_1})^{-\gamma_2} = v^{-\gamma_2 \circ \gamma_1}$
\end{proposition}
\begin{corollary}\label{cor:singlestepintersections}
For all $\tau \in \mathcal{M}'$, for all left $\tau$-vectors $v$ and all right $\tau$-vectors $w$,
\begin{align*}
&M^{orth}_{\tau}(vw^T) = M^{fact}_{\tau}(vw^T) - \sum_{\gamma \in \Gamma_{*,U_{\tau}}}{\frac{1}{|Aut(U_{\gamma})|}\sum_{P \in \mathcal{P}_{\gamma,\tau,Id_{V_{\tau}}}}N(P)M^{orth}_{\tau_P}(v^{-\gamma}w^T)} \\
&- \sum_{\gamma' \in \Gamma_{*,V_{\tau}}}{\frac{1}{|Aut(U_{\gamma'})|}\sum_{P \in \mathcal{P}_{Id_{U_{\tau}},\tau,{\gamma'}^T}}N(P)M^{orth}_{\tau_P}(v(w^{-\gamma})^T)} \\
&- \sum_{\gamma \in \Gamma_{*,U_{\tau}}}{\sum_{\gamma' \in \Gamma_{*,V_{\tau}}}{
\frac{1}{|Aut(U_{\gamma})|\cdot|Aut(U_{\gamma'})|}\sum_{P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}}N(P)M^{orth}_{\tau_P}(v^{-\gamma}(w^{-\gamma'})^T)}}
\end{align*}
\end{corollary}
Applying Corollary \ref{cor:singlestepintersections} iteratively, we obtain the following theorem:
\begin{definition}\label{multigammadefinition}
Given $\gamma,\gamma' \in \Gamma \cup \{Id_U:U \in \mathcal{I}_{mid}\}$ and $j > 0$, let $\Gamma_{\gamma,\gamma',j}$ be the set of all $\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma \cup \{Id_U:U \in \mathcal{I}_{mid}\}$ such that:
\begin{enumerate}
\item $\gamma_j,\ldots,\gamma_1$ are composable and $\gamma_j \circ \ldots \circ \gamma_1 = \gamma$
\item $\gamma'_j,\ldots,\gamma'_1$ are composable and $\gamma'_j \circ \ldots \circ \gamma'_1 = \gamma'$
\item For all $i \in [1,j]$, $\gamma_i$ or $\gamma'_i$ is non-trivial (i.e. $\gamma_i \neq Id_{U_{\gamma_i}}$ or $\gamma'_i \neq Id_{U_{\gamma'_i}}$).
\end{enumerate}
\end{definition}
\begin{remark}
Note that if $\gamma = Id_{U}$ and $\gamma' = Id_{V}$ then for all $j > 0$, $\Gamma_{\gamma,\gamma',j} = \emptyset$.
\end{remark}
\begin{theorem}\label{thm:mfactmorthdifference}
For all $\tau \in \mathcal{M}'$, left $\tau$-vectors $v$, and right $\tau$-vectors $w$,
\begin{align*}
&M^{orth}_{\tau}(v{w^T}) = M^{fact}_{\tau}(v{w^T}) + \\
&\sum_{\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\},\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}: \atop \gamma \text{ or } \gamma' \text{ is non-trivial }}\sum_{j>0}{(-1)^{j}\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}
\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}}} \\
&\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{\left(\prod_{i=1}^{j}{N(P_i)}\right)M^{fact}_{\tau_{P_j}}(v^{-\gamma}{(w^{-\gamma'})^T})}
\end{align*}
where we take $\tau_{P_0} = \tau$.
\end{theorem}
\subsection{Bounding the difference between $M^{fact}$ and $M^{orth}$}\label{boundingdifferencesection}
In this subsection, we bound the difference between $M^{fact}_{\tau}(H_{\tau})$ and $M^{orth}_{\tau}(H_{\tau})$. We recall the following conditions on $B(\gamma)$, $N(\gamma)$, and $c(\gamma)$:
\begin{enumerate}
\item For all $\tau \in \mathcal{M}'$, $\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\}$, and $\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}$,
\begin{align*}
&\sum_{j>0}{\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\left(\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}\right)
\left(\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}\right)}}\\
&\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{\left(\prod_{i=1}^{j}{N(P_i)}\right)} \leq \frac{N(\gamma)N(\gamma')}{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}}
\end{align*}
\item For all $\tau \in \mathcal{M}'$, $\gamma \in \Gamma_{*,U_{\tau}}$, and $\gamma' \in \Gamma_{*,V_{\tau}}$, for all $P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}$,
$B_{norm}(\tau_{P}) \leq B(\gamma)B(\gamma')B_{norm}(\tau)$
\item $\forall V \in \mathcal{I}_{mid}, \sum_{\gamma \in \Gamma_{*,V}}{\frac{1}{|Aut(U_{\gamma})|c(\gamma)}} \leq \varepsilon' \leq \frac{1}{20}$
\end{enumerate}
With these conditions, we can now bound the difference between $M^{fact}$ and $M^{orth}$.
\begin{lemma}\label{keyboundinglemma}
If the norm bounds and the conditions on $B(\gamma)$, $N(\gamma)$, and $c(\gamma)$ hold then for all $\tau \in \mathcal{M}'$, left $\tau$-vectors $v$, and right $\tau$-vectors $w$,
\begin{align*}
&\left(M^{fact}_{\tau}(v{w^T}) + M^{fact}_{{\tau}^T}(w{v^T})\right) - \left(M^{orth}_{\tau}(v{w^T}) + M^{orth}_{{\tau}^T}(w{v^T})\right) \preceq \\
&\\
&{\varepsilon'}B_{norm}(\tau)M^{fact}_{Id_{U_{\tau}}}(vv^{T}) +
2\sum_{\gamma \in \Gamma_{*,U_{\tau}}}{\frac{B(\gamma)^{2}N(\gamma)^{2}B_{norm}(\tau){c(\gamma)}}{|Aut(U_{\gamma})|}M^{fact}_{Id_{U_{\gamma}}}(v^{-\gamma}(v^{-\gamma})^T)} + \\
&{\varepsilon'}B_{norm}(\tau)M^{fact}_{Id_{V_{\tau}}}(ww^{T}) +
2\sum_{\gamma' \in \Gamma_{*,V_{\tau}}}{\frac{B(\gamma')^{2}N(\gamma')^{2}B_{norm}(\tau){c(\gamma')}}{|Aut(U_{\gamma'})|}M^{fact}_{Id_{U_{\gamma'}}}(w^{-\gamma'}(w^{-\gamma'})^T)}
\end{align*}
\end{lemma}
\begin{proof}
By Theorem \ref{thm:mfactmorthdifference}, taking $\tau_{P_0} = \tau$,
\begin{align*}
&M^{orth}_{\tau}(v{w^T}) = M^{fact}_{\tau}(v{w^T}) + \\
&\sum_{\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\},\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}: \atop \gamma \text{ or } \gamma' \text{ is non-trivial }}\sum_{j>0}{(-1)^{j}\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}
\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}}} \\
&\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{\left(\prod_{i=1}^{j}{N(P_i)}\right)M^{fact}_{\tau_{P_j}}(v^{-\gamma}{(w^{-\gamma'})^T})}
\end{align*}
Taking the transpose of this equation gives
\begin{align*}
&M^{orth}_{{\tau}^T}(w{v^T}) = M^{fact}_{{\tau}^T}(w{v^T}) + \\
&\sum_{\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\},\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}: \atop \gamma \text{ or } \gamma' \text{ is non-trivial }}\sum_{j>0}{(-1)^{j}\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}
\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}}} \\
&\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{\left(\prod_{i=1}^{j}{N(P_i)}\right)M^{fact}_{\tau^{T}_{P_j}}({w^{-\gamma'}(v^{-\gamma})^T})}
\end{align*}
Now observe that by Lemma \ref{lm:rankonetosquares}, if the norm bounds hold,
\begin{align*}
&{\pm}\left(M^{fact}_{\tau_{P_j}}(v^{-\gamma}{(w^{-\gamma'})^T}) + M^{fact}_{\tau^{T}_{P_j}}({w^{-\gamma'}(v^{-\gamma})^T})\right) = \\
&{\pm}M^{fact}_{\tau_{P_j}}\left(\left(\sqrt{\frac{N(\gamma)B(\gamma){c(\gamma)}}{N(\gamma')B(\gamma'){c(\gamma')}}}v^{-\gamma}\right)
\left(\sqrt{\frac{N(\gamma')B(\gamma'){c(\gamma')}}{N(\gamma)B(\gamma){c(\gamma)}}}{(w^{-\gamma'})^T}\right)\right) \pm \\
&M^{fact}_{\tau^{T}_{P_j}}\left(\left(\sqrt{\frac{N(\gamma')B(\gamma'){c(\gamma')}}{N(\gamma)B(\gamma){c(\gamma)}}}w^{-\gamma'}\right)
\left(\sqrt{\frac{N(\gamma)B(\gamma){c(\gamma)}}{N(\gamma')B(\gamma'){c(\gamma')}}}{(v^{-\gamma})^T}\right)\right) \preceq \\
&B_{norm}(\tau_{P_j})\left(\frac{N(\gamma)B(\gamma){c(\gamma)}}{N(\gamma')B(\gamma'){c(\gamma')}}M^{fact}_{Id_{U_{\gamma}}}(v^{-\gamma}(v^{-\gamma})^T) +
\frac{N(\gamma')B(\gamma'){c(\gamma')}}{N(\gamma)B(\gamma){c(\gamma)}}M^{fact}_{Id_{U_{\gamma'}}}(w^{-\gamma'}(w^{-\gamma'})^T)\right)
\end{align*}
Combining these equations,
\begin{align*}
&\left(M^{fact}_{\tau}(v{w^T}) + M^{fact}_{{\tau}^T}(w{v^T})\right) - \left(M^{orth}_{\tau}(v{w^T}) + M^{orth}_{{\tau}^T}(w{v^T})\right) \preceq \\
&\sum_{\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\},\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}: \atop \gamma \text{ or } \gamma' \text{ is non-trivial }}\sum_{j>0}{\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}
\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}}} \\
&\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{\left(\prod_{i=1}^{j}{N(P_i)}\right)
B_{norm}(\tau_{P_j})} \\
&\left(\frac{N(\gamma)B(\gamma){c(\gamma)}}{N(\gamma')B(\gamma'){c(\gamma')}}M^{fact}_{Id_{U_{\gamma}}}(v^{-\gamma}(v^{-\gamma})^T) +
\frac{N(\gamma')B(\gamma'){c(\gamma')}}{N(\gamma)B(\gamma){c(\gamma)}}M^{fact}_{Id_{U_{\gamma'}}}(w^{-\gamma'}(w^{-\gamma'})^T)\right)
\end{align*}
From the conditions on $B(\gamma)$ and $N(\gamma)$,
\begin{enumerate}
\item $B_{norm}(\tau_{P_j}) \leq B(\gamma)B(\gamma')B_{norm}(\tau)$
\item
\begin{align*}
&\sum_{j>0}{\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\left(\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}\right)
\left(\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}\right)}}\\
&\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{\left(\prod_{i=1}^{j}{N(P_i)}\right)} \leq \frac{N(\gamma)N(\gamma')}{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}}
\end{align*}
\end{enumerate}
Putting these equations together,
\begin{align*}
&\left(M^{fact}_{\tau}(v{w^T}) + M^{fact}_{{\tau}^T}(w{v^T})\right) - \left(M^{orth}_{\tau}(v{w^T}) + M^{orth}_{{\tau}^T}(w{v^T})\right) \preceq \\
&\sum_{\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\},\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}: \atop \gamma \text{ or } \gamma' \text{ is non-trivial }}{\frac{B(\gamma)^{2}N(\gamma)^{2}B_{norm}(\tau){c(\gamma)}}{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}{c(\gamma')}}M^{fact}_{Id_{U_{\gamma}}}(v^{-\gamma}(v^{-\gamma})^T)} + \\
&\sum_{\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\},\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}: \atop \gamma \text{ or } \gamma' \text{ is non-trivial }}{\frac{B(\gamma')^{2}N(\gamma')^{2}B_{norm}(\tau){c(\gamma')}}{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}{c(\gamma)}}M^{fact}_{Id_{U_{\gamma'}}}(w^{-\gamma'}(w^{-\gamma'})^T)}
\end{align*}
Now observe that
\begin{align*}
&\sum_{\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\},\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}: \atop \gamma \text{ or } \gamma' \text{ is non-trivial }}{\frac{B(\gamma)^{2}N(\gamma)^{2}B_{norm}(\tau){c(\gamma)}}{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}{c(\gamma')}}M^{fact}_{Id_{U_{\gamma}}}(v^{-\gamma}(v^{-\gamma})^T)} \preceq \\
&\left(\sum_{\gamma' \in \Gamma_{*,V_{\tau}}}{\frac{1}{|Aut(U_{\gamma'})|{c(\gamma')}}}\right)B_{norm}(\tau)M^{fact}_{Id_{U_{\tau}}}(vv^{T}) + \\
&\sum_{\gamma \in \Gamma_{*,U_{\tau}}}{\left(\sum_{\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}}{\frac{1}{(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}{c(\gamma')}}}\right)\frac{B(\gamma)^{2}N(\gamma)^{2}B_{norm}(\tau){c(\gamma)}}{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}}M^{fact}_{Id_{U_{\gamma}}}(v^{-\gamma}(v^{-\gamma})^T)} \preceq \\
&{\varepsilon'}B_{norm}(\tau)M^{fact}_{Id_{U_{\tau}}}(vv^{T}) +
2\sum_{\gamma \in \Gamma_{*,U_{\tau}}}{\frac{B(\gamma)^{2}N(\gamma)^{2}B_{norm}(\tau){c(\gamma)}}{|Aut(U_{\gamma})|}M^{fact}_{Id_{U_{\gamma}}}(v^{-\gamma}(v^{-\gamma})^T)}
\end{align*}
Following similar logic,
\begin{align*}
&\sum_{\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\},\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}: \atop \gamma \text{ or } \gamma' \text{ is non-trivial }}{\frac{B(\gamma')^{2}N(\gamma')^{2}B_{norm}(\tau){c(\gamma')}}{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}{c(\gamma)}}M^{fact}_{Id_{U_{\gamma'}}}(w^{-\gamma'}(w^{-\gamma'})^T)} \preceq \\
&{\varepsilon'}B_{norm}(\tau)M^{fact}_{Id_{V_{\tau}}}(ww^{T}) +
2\sum_{\gamma' \in \Gamma_{*,V_{\tau}}}{\frac{B(\gamma')^{2}N(\gamma')^{2}B_{norm}(\tau){c(\gamma')}}{|Aut(U_{\gamma'})|}M^{fact}_{Id_{U_{\gamma'}}}(w^{-\gamma'}(w^{-\gamma'})^T)}
\end{align*}
Putting everything together,
\begin{align*}
&\left(M^{fact}_{\tau}(v{w^T}) + M^{fact}_{{\tau}^T}(w{v^T})\right) - \left(M^{orth}_{\tau}(v{w^T}) + M^{orth}_{{\tau}^T}(w{v^T})\right) \preceq \\
&\\
&{\varepsilon'}B_{norm}(\tau)M^{fact}_{Id_{U_{\tau}}}(vv^{T}) +
2\sum_{\gamma \in \Gamma_{*,U_{\tau}}}{\frac{B(\gamma)^{2}N(\gamma)^{2}B_{norm}(\tau){c(\gamma)}}{|Aut(U_{\gamma})|}M^{fact}_{Id_{U_{\gamma}}}(v^{-\gamma}(v^{-\gamma})^T)} + \\
&{\varepsilon'}B_{norm}(\tau)M^{fact}_{Id_{V_{\tau}}}(ww^{T}) +
2\sum_{\gamma' \in \Gamma_{*,V_{\tau}}}{\frac{B(\gamma')^{2}N(\gamma')^{2}B_{norm}(\tau){c(\gamma')}}{|Aut(U_{\gamma'})|}M^{fact}_{Id_{U_{\gamma'}}}(w^{-\gamma'}(w^{-\gamma'})^T)}
\end{align*}
as needed.
\end{proof}
Using Lemma \ref{keyboundinglemma} we have the following corollaries:
\begin{corollary}\label{notauintersectiontermcorollary}
For all $U \in \mathcal{I}_{mid}$, if the norm bounds and the conditions on $B(\gamma)$, $N(\gamma)$, and $c(\gamma)$ hold and $H_{Id_U} \succeq 0$ then
\[
M^{fact}_{Id_{U}}(H_{Id_U}) - M^{orth}_{Id_{U}}(H_{Id_U}) \preceq {\varepsilon'}M^{fact}_{Id_{U}}(H_{Id_U}) +
2\sum_{\gamma \in \Gamma_{*,U}}{\frac{B(\gamma)^{2}N(\gamma)^{2}{c(\gamma)}}{|Aut(U_{\gamma})|}M^{fact}_{Id_{U_{\gamma}}}(H^{-\gamma,\gamma}_{Id_{U}})}
\]
\end{corollary}
\begin{corollary}\label{yestauintersectiontermcorollary}
For all $U \in \mathcal{I}_{mid}$ and all $\tau \in \mathcal{M}_{U}$, if the norm bounds and the conditions on $B(\gamma)$, $N(\gamma)$, and $c(\gamma)$ hold and
\[
\left[ {\begin{array}{cc}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_U} & B_{norm}(\tau)H_{\tau} \\
B_{norm}(\tau)H^T_{\tau} & \frac{1}{|Aut(U)|c(\tau)}H_{Id_U}
\end{array}} \right] \succeq 0
\]
then
\begin{align*}
&\left(M^{fact}_{\tau}(H_{\tau}) + M^{fact}_{{\tau}^T}(H^{T}_{\tau})\right) - \left(M^{orth}_{\tau}(H_{\tau}) + M^{orth}_{{\tau}^T}(H^{T}_{\tau})\right) \preceq \\
&\\
&2{\varepsilon'}\frac{1}{|Aut(U)|c(\tau)}M^{fact}_{Id_{U}}(H_{Id_U}) +
4\sum_{\gamma \in \Gamma_{*,U}}{\frac{B(\gamma)^{2}N(\gamma)^{2}{c(\gamma)}}{|Aut(U_{\gamma})|\cdot|Aut(U)|c(\tau)}M^{fact}_{Id_{U_{\gamma}}}(H_{Id_{U}}^{-\gamma,\gamma}})
\end{align*}
\end{corollary}
\subsection{Proof of the Main Theorem}
We now prove the following theorem which is a slight modification of Theorem \ref{maintheoremviaproperties} and which implies Theorem \ref{maintheoremviaproperties}.
\begin{theorem}\label{maintheoremviapropertiescopy}
For all $\varepsilon > 0$ and all $\varepsilon' \in (0,\frac{1}{20}]$, for any moment matrix
\[
\Lambda = \sum_{U \in \mathcal{I}_{mid}}{M^{orth}_{Id_U}(H_{Id_U})} + \sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_U}{M^{orth}_{\tau}(H_{\tau})}},
\]
if we have that for all $\alpha \in \mathcal{M}', ||M_{\alpha}|| \leq B_{norm}(\alpha)$ and $B(\gamma)$, $N(\gamma)$, and $c(\alpha)$ are functions such that
\begin{enumerate}
\item For all $\tau \in \mathcal{M}'$, $\gamma \in \Gamma_{*,U_{\tau}}$, $\gamma' \in \Gamma_{*,V_{\tau}}$, and all intersection patterns $P \in \mathcal{P}_{\gamma,\tau,\gamma'}$,
\[
B_{norm}(\tau_{P}) \leq B(\gamma)B(\gamma')B_{norm}(\tau)
\]
\item For all composable $\gamma_1,\gamma_2$, $B(\gamma_1)B(\gamma_2) = B(\gamma_1 \circ \gamma_2)$.
\item $\forall U \in \mathcal{I}_{mid}, \sum_{\gamma \in \Gamma_{U,*}}{\frac{1}{|Aut(U)|c(\gamma)}} < \varepsilon'$
\item $\forall V \in \mathcal{I}_{mid}, \sum_{\gamma \in \Gamma_{*,V}}{\frac{1}{|Aut(U_{\gamma})|c(\gamma)}} < \varepsilon'$
\item $\forall U \in \mathcal{I}_{mid}, \sum_{\tau \in \mathcal{M}_{U}}{\frac{1}{|Aut(U)|c(\tau)}} < \varepsilon'$
\item For all $\tau \in \mathcal{M}'$, $\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\}$, and $\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}$,
\begin{align*}
&\sum_{j>0}{\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}
\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}}}\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{\left(\prod_{i=1}^{j}{N(P_i)}\right)} \\
&\leq \frac{N(\gamma)N(\gamma')}
{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}}
\end{align*}
\end{enumerate}
and we have SOS-symmetric coefficient matrices $\{H'_{\gamma}: \gamma \in \Gamma\}$ such that the following conditions hold:
\begin{enumerate}
\item For all $U \in \mathcal{I}_{mid}$, $H_{Id_{U}} \succeq 0$
\item For all $U \in \mathcal{I}_{mid}$ and $\tau \in \mathcal{M}_U$,
\[
\left[ {\begin{array}{cc}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_{U}} & B_{norm}(\tau)H_{\tau} \\
B_{norm}(\tau)H^T_{\tau} & \frac{1}{|Aut(U)|c(\tau)}H_{Id_{U}}
\end{array}} \right] \succeq 0
\]
\item For all $U,V \in \mathcal{I}_{mid}$ where $w(U) > w(V)$ and all $\gamma \in \Gamma_{U,V}$,
\[
c(\gamma)^2{N(\gamma)}^2{B(\gamma)^2}H^{-\gamma,\gamma}_{Id_{V}} \preceq H'_{\gamma}
\]
\end{enumerate}
then
\[
\Lambda \succeq \frac{1}{2}\left(\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}}\right) - 3\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\]
If it is also true that
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq 6\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\]
then $\Lambda \succeq 0$.
\end{theorem}
\begin{proof}
We make the following observations:
\begin{enumerate}
\item By Theorem \ref{thm:nointersectionanalysis},
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}(H_{Id_U})} + \sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_U}{M^{fact}_{\tau}(H_{\tau})} \succeq (1-2\varepsilon')\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}(H_{Id_U})}}
\]
\item By Corollary \ref{notauintersectiontermcorollary},
\[
\sum_{U \in \mathcal{I}_{mid}}{\left(M^{fact}_{Id_{U}}(H_{Id_U}) - M^{orth}_{Id_{U}}(H_{Id_U})\right)} \preceq {\varepsilon'}\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_{U}}(H_{Id_U})} +
2\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{*,U}}{\frac{M^{fact}_{Id_{U_{\gamma}}}(H'_{\gamma})}{c(\gamma)|Aut(U_{\gamma})|}}}
\]
\item By Corollary \ref{yestauintersectiontermcorollary},
\begin{align*}
&\sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_U}{\left(M^{fact}_{\tau}(H_{\tau}) - M^{orth}_{\tau}(H_{\tau})\right)}} \preceq \\
&\\
&\sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_U}{\left(\frac{2{\varepsilon'}}{|Aut(U)|c(\tau)}M^{fact}_{Id_{U}}(H_{Id_U}) +
4\sum_{\gamma \in \Gamma_{*,U}}{\frac{B(\gamma)^{2}N(\gamma)^{2}{c(\gamma)}}{|Aut(U_{\gamma})|\cdot|Aut(U)|c(\tau)}M^{fact}_{Id_{U_{\gamma}}}(H_{Id_{U}}^{-\gamma,\gamma})}\right)}} \preceq \\
&2{\varepsilon'}^2\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_{U}}(H_{Id_U})} +
4{\varepsilon'}\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{*,U}}{\frac{M^{fact}_{Id_{U_{\gamma}}}(H'_{\gamma})}{c(\gamma)|Aut(U_{\gamma})|}}}
\end{align*}
\item
\begin{align*}
&\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{*,U}}{\frac{M^{fact}_{Id_{U_{\gamma}}}(H'_{\gamma})}{c(\gamma)|Aut(U_{\gamma})|}}} =
\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{*,U}}{\frac{M^{fact}_{Id_{U_{\gamma}}}(H_{Id_{U_\gamma}}) + \left(M^{fact}_{Id_{U_{\gamma}}}(H'_{\gamma}) - M^{fact}_{Id_{U_{\gamma}}}(H_{Id_{U_\gamma}})\right)}{c(\gamma)|Aut(U_{\gamma})|}}} \preceq \\
&\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{*,U}}{\frac{M^{fact}_{Id_{U_{\gamma}}}(H_{Id_{U_{\gamma}}})}{c(\gamma)|Aut(U_{\gamma})|}}} +
\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U_{\gamma}}}(H'_{\gamma},H_{Id_{U_{\gamma}}})}{|Aut(U_{\gamma})|c(\gamma)}}}\right)Id_{sym} \preceq \\
&{\varepsilon'}\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{U}(H_{Id_{U}})} +
\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U_{\gamma}}}(H'_{\gamma},H_{Id_{U_{\gamma}}})}{|Aut(U_{\gamma})|c(\gamma)}}}\right)Id_{sym}
\end{align*}
\end{enumerate}
Putting everything together,
\begin{align*}
&\Lambda = \sum_{U \in \mathcal{I}_{mid}}{M^{orth}_{Id_U}(H_{Id_U})} + \sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_U}{M^{orth}_{\tau}(H_{\tau})}} = \\
&\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}(H_{Id_U})} + \sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_U}{M^{fact}_{\tau}(H_{\tau})}} +
\sum_{U \in \mathcal{I}_{mid}}{\left(M^{fact}_{Id_{U}}(H_{Id_U}) - M^{orth}_{Id_{U}}(H_{Id_U})\right)} + \\
&\sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_U}{\left(M^{fact}_{\tau}(H_{\tau}) - M^{orth}_{\tau}(H_{\tau}) \right)}} \succeq \\
&(1 - 3{\varepsilon'} - 2{\varepsilon'}^2)\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}(H_{Id_U})} -
(2 + 4\varepsilon')\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{*,U}}{\frac{M^{fact}_{Id_{U_{\gamma}}}(H'_{\gamma})}{c(\gamma)|Aut(U_{\gamma})|}}} \succeq \\
&(1 - 5{\varepsilon'} - 6{\varepsilon'}^2)\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}(H_{Id_U})} -
(2 + 4\varepsilon')\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U_{\gamma}}}(H'_{\gamma},H_{Id_{U_{\gamma}}})}{|Aut(U_{\gamma})|c(\gamma)}}}\right)Id_{sym} \succeq \\
&\frac{1}{2}\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}(H_{Id_U})} -
3\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U_{\gamma}}}(H'_{\gamma},H_{Id_{U_{\gamma}}})}{|Aut(U_{\gamma})|c(\gamma)}}}\right)Id_{sym}
\end{align*}
\end{proof}
\subsection{Theorem Statements}
Recall the following definitions from Section \ref{quantitativetheoremstatementsection}.
\begin{definition}
We define $S_{\alpha}$ to be the leftmost minimum vertex separator of $\alpha$
\end{definition}
\begin{definition}[Simplified Isolated Vertices]
Under our simplifying assumptions, we define
\[
I_{\alpha} = \{v \in W_{\alpha}: v \text{ is not incident to any edges in } E(\alpha)\}
\]
\end{definition}
\begin{theorem}[Simplified $B_{norm}(\alpha)$, $B(\gamma)$, $N(\gamma)$, and $c(\alpha)$]\label{simplifiedfunctionstheorem}
Under our simplifying assumptions, for all $\varepsilon, \varepsilon' > 0$ and all $D_V \in \mathbb{N}$, if we take
\begin{enumerate}
\item $q = 3\left\lceil{{D_V}ln(n) + \frac{ln(\frac{1}{\varepsilon})}{3} + {D_V}ln(5) + 3{D^2_V}ln(2)}\right\rceil$
\item $B_{vertex} = 6{D_V}\sqrt[4]{2eq}$
\item $B_{norm}(\alpha) = {B_{vertex}^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}}n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha})}{2}}$
\item $B(\gamma) = B_{vertex}^{|V(\gamma) \setminus U_{\gamma}| + |V(\gamma) \setminus V_{\gamma}|}n^{\frac{w(V(\gamma) \setminus U_{\gamma})}{2}}$
\item $N(\gamma) = (3D_V)^{2|V(\gamma) \setminus V_{\gamma}| + |V(\gamma) \setminus U_{\gamma}|}$
\item $c(\alpha) = \frac{5(3D_V)^{|U_{\alpha} \setminus V_{\alpha}| + |V_{\alpha} \setminus U_{\alpha}| + 2|E(\alpha)|}2^{|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})|}}{\varepsilon'}$
\end{enumerate}
then the following conditions hold:
\begin{enumerate}
\item With probability at least $(1-\varepsilon)$, $\forall \alpha \in \mathcal{M}'$, $||M_{\alpha}|| \leq B_{norm}(\alpha)$
\item For all $\tau \in \mathcal{M}'$, $\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\}$, $\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}$, and intersection patterns $P \in \mathcal{P}_{\gamma,\tau,\gamma'}$,
\[
B_{norm}(\tau_{P}) \leq B(\gamma)B(\gamma')B_{norm}(\tau)
\]
\item For all composable $\gamma_1,\gamma_2$, $B(\gamma_1)B(\gamma_2) = B(\gamma_1 \circ \gamma_2)$.
\item $\forall U \in \mathcal{I}_{mid}, \sum_{\gamma \in \Gamma_{U,*}}{\frac{1}{|Aut(U)|c(\gamma)}} < \varepsilon'$
\item $\forall V \in \mathcal{I}_{mid}, \sum_{\gamma \in \Gamma_{*,V}}{\frac{1}{|Aut(U_{\gamma})|c(\gamma)}} < \varepsilon'$
\item $\forall U \in \mathcal{I}_{mid}, \sum_{\tau \in \mathcal{M}_{U}}{\frac{1}{|Aut(U)|c(\tau)}} < \varepsilon'$
\item For all $\tau \in \mathcal{M}'$, $\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\}$, and $\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}$,
\begin{align*}
&\sum_{j>0}{\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}
\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}}}\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{\left(\prod_{i=1}^{j}{N(P_i)}\right)} \\
&\leq \frac{N(\gamma)N(\gamma')}
{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}}
\end{align*}
\end{enumerate}
\end{theorem}
\subsubsection{General functions $B_{norm}(\alpha)$, $B(\gamma)$, $N(\gamma)$, and $c(\alpha)$*}
Recall the following definitions from Section \ref{generalmaintheoremstatementsection}.
\begin{definition}[$S_{\alpha,min}$ and $S_{\alpha,max}$]
Given a shape $\alpha \in \mathcal{M}'$, define $S_{\alpha,min}$ to be the leftmost minimum vertex separator of $\alpha$ if all edges with multiplicity at least $2$ are deleted and define $S_{\alpha,max}$ to be the leftmost minimum vertex separator of $\alpha$ if all edges with multiplicity at least $2$ are present.
\end{definition}
\begin{definition}[General $I_{\alpha}$]
Given a shape $\alpha$, define $I_{\alpha}$ to be the set of vertices in $V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})$ such that all edges incident with that vertex have multplicity at least $2$.
\end{definition}
\begin{definition}[$B_{\Omega}$]
We take $B_{\Omega}(j)$ to be a non-decreasing function such that for all $j \in \mathbb{N}$, $E_{\Omega}[x^{j}] \leq B_{\Omega}(j)^{j}$
\end{definition}
\begin{definition}
For all $i$, we define $h^{+}_i$ to be the polynomial $h_i$ where we make all of the coefficients have positive sign.
\end{definition}
\begin{lemma}
If $\Omega = N(0,1)$ then we can take $B_{\Omega}(j) = \sqrt{j}$ and we have that
\end{lemma}
\begin{theorem}[General $B_{norm}(\alpha)$, $B(\gamma)$, $N(\gamma)$, and $c(\alpha)$]\label{generalfunctionstheorem}
For all $\varepsilon, \varepsilon' > 0$ and all $D_V,D_E \in \mathbb{N}$, if we take
\begin{enumerate}
\item $q = \left\lceil{3{D_V}ln(n) + ln(\frac{1}{\varepsilon}) + {(3D_V)^k}ln(D_E + 1) + 3{D_V}ln(5)}\right\rceil$
\item $B_{vertex} = 6q{D_V}$
\item $B_{edge}(e) = 2h^{+}_{l_e}(B_{\Omega}(6{D_V}D_E))
\max_{j \in [0,3{D_V}D_E]}{\left\{\left(h^{+}_{j}(B_{\Omega}(2qj))\right)^{\frac{l_e}{\max{\{j,l_e\}}}}\right\}}$
\item $B_{norm}(\alpha) =
2e{B_{vertex}^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}}\left(\prod_{e \in E(\alpha)}{B_{edge}(e)}\right)n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha})}{2}}$
\item $B(\gamma) = B_{vertex}^{|V(\gamma) \setminus U_{\gamma}| + |V(\gamma) \setminus V_{\gamma}|}\left(\prod_{e \in E(\gamma)}{B_{edge}(e)}\right)n^{\frac{w(V(\gamma) \setminus U_{\gamma})}{2}}$
\item $N(\gamma) = (3D_V)^{2|V(\gamma) \setminus V_{\gamma}| + |V(\gamma) \setminus U_{\gamma}|}$
\item $c(\alpha) = \frac{5(3{t_{max}}D_V)^{|U_{\alpha} \setminus V_{\alpha}| + |V_{\alpha} \setminus U_{\alpha}| + k|E(\alpha)|}(2t_{max})^{|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})|}}{\varepsilon'}$
\end{enumerate}
then the following conditions hold:
\begin{enumerate}
\item With probability at least $(1-\varepsilon)$, $\forall \alpha \in \mathcal{M}'$, $||M_{\alpha}|| \leq B_{norm}(\alpha)$
\item For all $\tau \in \mathcal{M}'$, $\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\}$, $\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}$, and intersection patterns $P \in \mathcal{P}_{\gamma,\tau,\gamma'}$,
\[
B_{norm}(\tau_{P}) \leq B(\gamma)B(\gamma')B_{norm}(\tau)
\]
\item For all composable $\gamma_1,\gamma_2$, $B(\gamma_1)B(\gamma_2) = B(\gamma_1 \circ \gamma_2)$.
\item $\forall U \in \mathcal{I}_{mid}, \sum_{\gamma \in \Gamma_{U,*}}{\frac{1}{|Aut(U)|c(\gamma)}} < \varepsilon'$
\item $\forall V \in \mathcal{I}_{mid}, \sum_{\gamma \in \Gamma_{*,V}}{\frac{1}{|Aut(U_{\gamma})|c(\gamma)}} < \varepsilon'$
\item $\forall U \in \mathcal{I}_{mid}, \sum_{\tau \in \mathcal{M}_{U}}{\frac{1}{|Aut(U)|c(\tau)}} < \varepsilon'$
\item For all $\tau \in \mathcal{M}'$, $\gamma \in \Gamma_{*,U_{\tau}} \cup \{Id_{U_{\tau}}\}$, and $\gamma' \in \Gamma_{*,V_{\tau}} \cup \{Id_{V_{\tau}}\}$,
\begin{align*}
&\sum_{j>0}{\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}
\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}}}\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{\left(\prod_{i=1}^{j}{N(P_i)}\right)} \\
&\leq \frac{N(\gamma)N(\gamma')}
{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}}
\end{align*}
\end{enumerate}
\end{theorem}
\begin{remark}
Recall that if $\Omega = N(0,1)$ then we may take $B_{\Omega}(j) = \sqrt{j}$ and we have that
\[
h^{+}_j(x) \leq \frac{1}{\sqrt{j!}}(x^2 + j)^{\frac{j}{2}} \leq \left(\frac{e}{j}(x^2 + j)\right)^{\frac{j}{2}}
\]
Thus, when $\Omega = N(0,1)$ we can take
\[
B_{edge}(e) = 2\left(\frac{e}{l_e}(6{D_V}D_E + l_e)\right)^{l_e}\left(e(6{D_V}{D_E}q + 1)\right)^{l_e} \leq \left(400{D^2_V}{D^2_E}q\right)^{l_e}
\]
\end{remark}
\subsection{Choosing $B_{norm}(\alpha)$}
We need matrix norm bounds which hold for all $\alpha \in \mathcal{M}'$. For convenience, we recall the definition of $\mathcal{M}'$ below.
\begin{definition}[$\mathcal{M}'$]
We define $\mathcal{M}'$ to be the set of all shapes $\alpha$ such that
\begin{enumerate}
\item[1.] $|V(\alpha)| \leq 3D_V$
\item[2.*] $\forall e \in E(\alpha), l_e \leq D_E$
\item[3.*] All edges $e \in E(\alpha)$ have multiplicity at most $3D_V$.
\end{enumerate}
\end{definition}
To obtain such norm bounds, we start with the norm bounds in the graph matrix norm bound paper. We then modify these bounds as follows:
\begin{enumerate}
\item We make the bounds more compatible with the conditions of our machinery. To do this, we upper bound many of the terms in the norm bound by $B_{vertex}^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}$ where $B_{vertex}$ is a function of our parameters. In general, we will also need to upper bound some of the terms by $\prod_{e \in E(\alpha)}(B_{edge}(e))$ where $B_{edge}(e)$ is a function of $l_e$, $\Omega$, and our parameters.
\item We generalize the bounds so that they apply to improper shapes as well as proper shapes. Under our simplifying assumptions, all we need to do here is to take isolated vertices into account. In general, we also need to handle multi-edges.
\end{enumerate}
\subsubsection{Simplified $B_{norm}(\alpha)$}
Under our simplifying assumptions, we start with the following norm bound from the updated graph matrix norm bound paper \cite{AMP20}:
\begin{theorem}[Simplified Graph Matrix Norm Bounds]\label{originalsimplifiednormbounds}
Under our simplifying assumptions, for all $\varepsilon > 0$ and all proper shapes $\alpha$, taking $c_{\alpha} = |V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})| + |S_{\alpha} \setminus (U_{\alpha} \cap V_{\alpha})|$,
\[
Pr\left(||M_{\alpha}|| > (2|V_{\alpha} \setminus (U_{\alpha} \cap V_{\alpha})|)^{|V(\alpha) \setminus (U_{\alpha} \cap V_{\alpha})|}(2eq)^{\frac{c_{\alpha}}{2}}n^{\frac{w(V(\alpha)) - w(S_{\alpha})}{2}}\right) < \varepsilon
\]
where $q = 3\left\lceil\frac{ln(\frac{n^{w(S_{\alpha})}}{\varepsilon})}{3c_{\alpha}}\right\rceil$
\end{theorem}
\begin{corollary}\label{firsttweakedsimplifiednormbound}
For all shapes $\alpha$ and all $\varepsilon > 0$,
\[
Pr\left(||M_{\alpha}|| > \left(2|V_{\alpha}|\sqrt[4]{2eq}\right)^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha})}{2}}\right) < \varepsilon
\]
where $q = 3\left\lceil\frac{ln(\frac{n^{w(S_{\alpha})}}{\varepsilon})}{3c_{\alpha}}\right\rceil$.
\end{corollary}
\begin{proof}
Observe that adding an isolated vertex to $\alpha$ is equivalent to multiplying $M_{\alpha}$ by $n - |V(\alpha)|$. Thus, if the bound holds for all proper $\alpha$ then it will hold for improper $\alpha$ as well.
We now make the following observations:
\begin{enumerate}
\item $|S_{\alpha} \setminus (U_{\alpha} \cap V_{\alpha})| \leq |U_{\alpha} \setminus V_{\alpha}|$, so $c_{\alpha} = |W_{\alpha}| + |S_{\alpha} \setminus (U_{\alpha} \cap V_{\alpha})| \leq |V(\alpha) \setminus V_{\alpha}|$. Similarly, $|S_{\alpha} \setminus (U_{\alpha} \cap V_{\alpha})| \leq |V_{\alpha} \setminus U_{\alpha}|$, so $c_{\alpha} \leq |V(\alpha) \setminus U_{\alpha}|$. Thus, $c_{\alpha} \leq \frac{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}{2}$.
\item $|V(\alpha) \setminus (U_{\alpha} \cap V_{\alpha})| \leq |V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|$
\end{enumerate}
Thus, by Theorem \ref{originalsimplifiednormbounds}, for all proper shapes $\alpha$ and all $\varepsilon > 0$,
\[
Pr\left(||M_{\alpha}|| > \left(2|V_{\alpha}|\sqrt[4]{2eq}\right)^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha})}{2}}\right) < \varepsilon''
\]
where $q = 3\left\lceil\frac{ln(\frac{n^{w(S_{\alpha})}}{\varepsilon})}{3c_{\alpha}}\right\rceil$.
\end{proof}
\begin{corollary}\label{tweakedsimplifiednormbound}
For all $z \in \mathbb{N}$ and all $\varepsilon > 0$, taking $\varepsilon'' = \frac{\varepsilon}{5^{z}2^{z^2}}$, with probability at least $1-\varepsilon$ we have that for all shapes $\alpha$ such that $|V(\alpha)| \leq z$,
\[
||M_{\alpha}|| \leq \left(2|V_{\alpha}|\sqrt[4]{2eq}\right)^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha})}{2}}
\]
where $q = 3\left\lceil\frac{ln(\frac{n^{w(S_{\alpha})}}{\varepsilon''})}{3c_{\alpha}}\right\rceil$.
\end{corollary}
\begin{proof}
This result can be proved from Corollary \ref{firsttweakedsimplifiednormbound} using a union bound and the following proposition:
\begin{proposition}\label{simplifiedcountingalpha}
Under our simplifying assumptions, for all $z \in \mathbb{N}$, there are at most $5^{z}2^{z^2}$ proper shapes $\alpha$ such that $V(\alpha) \leq z$.
\end{proposition}
\begin{proof}
Observe that we can construct any proper shape $\alpha$ with at most $m$ vertices as follows:
\begin{enumerate}
\item Start with $z$ vertices $v_1,\ldots,v_z$.
\item For each vertex $v_i$, choose whether $v_i \in V(\alpha) \setminus U_{\alpha} \setminus V_{\alpha}$, $v_i \in U_{\alpha} \setminus V_{\alpha}$, $v_i \in V_{\alpha} \setminus U_{\alpha}$, $v_i \in U_{\alpha} \cap V_{\alpha}$, or $v_i \notin V(\alpha)$.
\item For each pair of vertices $v_i,v_j \in V(\alpha)$, choose whether or not $(v_i,v_j) \in E(\alpha)$
\end{enumerate}
\end{proof}
\end{proof}
\begin{corollary}\label{finalsimplifiednormbound}
For all $D_V \in \mathbb{N}$ and all $\varepsilon > 0$, taking
\[
q = 3\left\lceil\frac{ln(\frac{5^{3D_V}2^{9D^2_V}n^{3D_V}}{\varepsilon})}{3}\right\rceil =
3\left\lceil{{D_V}ln(n) + \frac{ln(\frac{1}{\varepsilon})}{3} + {D_V}ln(5) + 3{D^2_V}ln(2)}\right\rceil,
\]
$B_{vertex} = 6{D_V}\sqrt[4]{2eq}$, and
\[
B_{norm}(\alpha) = {B_{vertex}^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}}n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha})}{2}},
\]
with probability at least $(1-\varepsilon)$ we have that for all shapes $\alpha \in \mathcal{M}'$, $||M_{\alpha}|| \leq B_{norm}(\alpha)$
\end{corollary}
\begin{proof}
This follows from Corollary \ref{tweakedsimplifiednormbound} and the fact that for all $\alpha \in \mathcal{M}'$, $w(S_{\alpha}) \leq |V(\alpha)| \leq3D_V$
\end{proof}
\subsubsection{General $B_{norm}(\alpha)$}
In general, we start with the following norm bound from the updated graph matrix norm bound paper \cite{AMP20}:
\begin{theorem}[General Graph Matrix Norm Bounds]\label{originalgeneralnormbounds}
For all $\varepsilon > 0$ and all proper shapes $\alpha$, taking $q = \lceil{ln(\frac{n^{w(S_{\alpha})}}{\varepsilon})}\rceil$
\[
P\left(||M_{\alpha}|| > 2e(2q|V(\alpha)|)^{|V(\alpha) \setminus (U_{\alpha} \cap V_{\alpha})|}\left(\prod_{e \in E(\alpha)}{h^{+}_{l_{e}}(B_{\Omega}(2q{l_e}))}\right)
n^{\frac{(w(V(\alpha)) - w(S_{\alpha}))}{2}}\right) < \varepsilon
\]
\end{theorem}
\begin{corollary}
For all $\varepsilon > 0$, for all $z,l_{max},m \in \mathbb{N}$, taking $\varepsilon'' = \frac{\varepsilon}{5^{z}(l_{max} + 1)^{z^k}}$, with probability at least $1-\varepsilon$, for all shapes $\alpha$ such that
\begin{enumerate}
\item $|V(\alpha)| \leq z$.
\item All edges in $E(\alpha)$ have label at most $l_{max}$.
\item All edges in $E(\alpha)$ have multiplicity at most $m$.
\end{enumerate},
\begin{align*}
||M_{\alpha}|| \leq &2e(2q|V(\alpha)|)^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}\left(\prod_{e \in E(\alpha)}{2h^{+}_{l_e}(B_{\Omega}(2ml_{max}))
\max_{j \in [0,ml_{max}]}{\left\{\left(h^{+}_{j}(B_{\Omega}(2qj))\right)^{\frac{l_e}{\max{\{j,l_e\}}}}\right\}}}\right)\\
&n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha,min})}{2}}
\end{align*}
where $q = \left\lceil{ln\left(\frac{n^{w(S_{\alpha,max})}}{\varepsilon''}\right)}\right\rceil$
\end{corollary}
\begin{proof}
Observe that for each $\alpha$ which has multi-edges, we can write $M_{\alpha} = \sum_{i}{{c_i}M_{\alpha_i}}$ where each $\alpha_i$ has no multiple edges. We first upper bound $\sum_{i}{|c_i|}$.
\begin{lemma}
For any $a_1,\ldots,a_m \in \mathbb{N} \cup \{0\}$, taking $p_{max} = \sum_{i=1}^{m}{a_i}$ and writing $\prod_{i=1}^{m}{h_{a_i}} = \sum_{k=0}^{p_{max}}{{c_k}h_k}$,
\[
\sum_{k=0}^{p_{max}}{|c_k|} \leq (p_{max}+1)\prod_{i=1}^{m}{h^{+}_{a_i}(B_{\Omega}(2p_{max}))} \leq \prod_{i=1}^{m}{2h^{+}_{a_i}(B_{\Omega}(2p_{max}))}
\]
\end{lemma}
\begin{proof}
Suppose $\prod_{i = 1}^m (h_{a_i}(x))^2 = \sum_{k = 0}^{2p_{max}} u_kx^k$ and $\prod_{i = 1}^m (h^+_{a_i}(x))^2 = \sum_{k = 0}^{p_{max}} v_kx^k$. Then, note that $|u_k| \le v_k$ and so, \[E_{\Omega}[\prod_{i = 1}^{m}(h_{a_i}(x))^2] = \sum_{k = 0}^{2p_{max}} u_k E_{\Omega}[x^k] \le \sum_{k = 0}^{2p_{max}} v_k|E_{\Omega}[x^k]| \le \sum_{k = 0}^{2p_{max}} v_k(B_{\Omega}(2p_{max}))^k = \prod_{i = 1}^m (h_{a_i}^+(B_{\Omega}(2p_{max}))^2\]
Therefore, using the fact that $h_k$ form an orthonormal basis,
\[\sum_{k = 0}^{p_{max}} c_k^2 = E_{\Omega}[(\sum_{k = 0}^{p_{max}} c_kh_k(x))^2] = E_{\Omega}[\prod_{i = 1}^m (h_{a_i}(x))^2] \le \prod_{i = 1}^m (h_{a_i}^+(B_{\Omega}(2p_{max}))^2\]
This implies
\[(\sum_{k = 0}^{p_{max}}|c_k|)^2 \le (p_{max} + 1)(\sum_{k = 0}^{p_{max}} c_k^2) \le (p_{max} + 1) \prod_{i = 1}^m (h_{a_i}^+(B_{\Omega}(2p_{max}))^2\]
Taking square roots gives the inequality.
\end{proof}
\begin{corollary}
For any shape $\alpha$ such that every edge of $\alpha$ has multiplicity at most $m$ and label at most $l_{max}$, if we write
$M_{\alpha} = \sum_{i}{{c_i}M_{\alpha_i}}$ where each $\alpha_i$ has no multi-edges then $\sum_{i}{|c_i|} \leq \prod_{e \in E(\alpha)}{2h^{+}_{l_e}(B_{\Omega}(2ml_{max}))}$
\end{corollary}
The result now follows from Theorem \ref{originalgeneralnormbounds} and the following observations:
\begin{enumerate}
\item $|V(\alpha) \setminus (U_{\alpha} \cap V_{\alpha})| \leq |V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|$.
\item For any $\alpha$, writing $M_{\alpha} = \sum_{i}{{c_i}M_{\alpha_i}}$ where each $\alpha_i$ has no multi-edges, for all $\alpha_i$,
\[
w(V(\alpha_i)) + w(I_{\alpha_i}) - w(S_{\alpha_i}) \leq w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha,min})
\]
\item For any $a_1,\ldots,a_m \in \mathbb{N} \cup \{0\}$ such that $\forall i' \in [m], a_{i'} \leq l_{max}$, for all $j \in [0,ml_{max}]$
\[
h^{+}_{j}(B_{\Omega}(2qj)) \leq \prod_{i'=1}^{m}{\left(h^{+}_{j}(B_{\Omega}(2qj))\right)^{\frac{a_{i'}}{\max{\{j,a_{i'}\}}}}} \leq
\prod_{i'=1}^{m}{\max_{j' \in [0,ml_{max}]}{\left\{\left(h^{+}_{j'}(B_{\Omega}(2qj'))\right)^{\frac{a_{i'}}{\max{\{j',a_{i'}\}}}}\right\}}}
\]
\end{enumerate}
\begin{proposition}
For all $z,l_{max} \in \mathbb{N}$, there are at most $5^{z}(l_{max} + 1)^{z^k}$ proper shapes $\alpha$ such that $|V(\alpha)| \leq z$ and every edge in $E(\alpha)$.
\end{proposition}
\begin{proof}
This can be proved in the same way as before. Observe that we can construct any proper shape $\alpha$ with at most $z$ vertices as follows:
\begin{enumerate}
\item Start with $z$ vertices $v_1,\ldots,v_z$.
\item For each vertex $v_i$, choose whether $v_i \in V(\alpha) \setminus U_{\alpha} \setminus V_{\alpha}$, $v_i \in U_{\alpha} \setminus V_{\alpha}$, $v_i \in V_{\alpha} \setminus U_{\alpha}$, $v_i \in U_{\alpha} \cap V_{\alpha}$, or $v_i \notin V(\alpha)$.
\item For each $k$ tuple of vertices in $V(\alpha)$, choose the label of the hyperedge between these vertices (or $0$ if the hyperedge is not in $E(\alpha)$).
\end{enumerate}
\end{proof}
\end{proof}
\begin{corollary}\label{finalgeneralnormbounds}
For all $D_V,D_E \in \mathbb{N}$ and all $\varepsilon > 0$, taking
\[
B_{norm}(\alpha) = 2e{B_{vertex}^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}}\left(\prod_{e \in E(\alpha)}{B_{edge}(e)}\right)n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha})}{2}}
\] where
\begin{enumerate}
\item $q = \left\lceil{ln\left(\frac{n^{3D_V}}{\varepsilon''}\right)}\right\rceil = \left\lceil{3{D_V}ln(n) + ln(\frac{1}{\varepsilon}) + {(3D_V)^k}ln(D_E + 1) + 3{D_V}ln(5)}\right\rceil$
\item $B_{vertex} = 6q{D_V}$
\item $B_{edge}(e) = 2h^{+}_{l_e}(B_{\Omega}(6{D_V}D_E))
\max_{j \in [0,3{D_V}D_E]}{\left\{\left(h^{+}_{j}(B_{\Omega}(2qj))\right)^{\frac{l_e}{\max{\{j,l_e\}}}}\right\}}$
\end{enumerate}
with probability at least $(1-\varepsilon)$, for all shapes $\alpha \in \mathcal{M}'$, $||M_{\alpha}|| \leq B_{norm}(\alpha)$.
\end{corollary}
\subsection{Choosing $B(\gamma)$}
We now describe how to choose the function $B(\gamma)$. Recall that we want the following conditions to hold:
\begin{enumerate}
\item For all $\gamma, \tau, \gamma'$ and all intersection patterns $P \in \mathcal{P}_{\gamma,\tau,\gamma'}$,
\[
B_{norm}(\tau_{P}) \leq B(\gamma)B(\gamma')B_{norm}(\tau)
\]
\item For all composable $\gamma_1,\gamma_2$, $B(\gamma_1)B(\gamma_2) = B(\gamma_1 \circ \gamma_2)$.
\end{enumerate}
The most important part of choosing $B(\gamma)$ is to make sure that the factors of $n$ are controlled. For this, we use the following intersection tradeoff lemma. Under our simplifying assumptions, this lemma follows from \cite[Lemma 7.12]{BHKKMP16}. We defer the general proof of this lemma to the end of this section.
\begin{lemma}[Intersection Tradeoff Lemma]
For all $\gamma, \tau, \gamma'$ and all intersection patterns $P \in \mathcal{P}_{\gamma,\tau,\gamma'}$,
\[
w(V(\tau_P)) + w(I_{\tau_P}) - w(S_{\tau_P,min}) \leq w(V(\tau)) + w(I_{\tau}) - w(S_{\tau,min})+ w(V(\gamma) \setminus U_{\gamma}) + w(V(\gamma') \setminus U_{\gamma'})
\]
\end{lemma}
Based on this intersection tradeoff lemma, we can choose the function $B(\gamma)$ as follows.
\begin{corollary}
If we take
\[
B_{norm}(\alpha) = C \cdot B_{vertex}^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}\left(\prod_{e \in E(\alpha)}{B_{edge}(e)}\right)n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha})}{2}}
\]
for some constant $C > 0$ and take
\[
B(\gamma) = B_{vertex}^{|V(\gamma) \setminus U_{\gamma}| + |V(\gamma) \setminus V_{\gamma}|}\left(\prod_{e \in E(\gamma)}{B_{edge}(e)}\right)n^{\frac{w(V(\gamma) \setminus U_{\gamma})}{2}}
\]
then the following conditions hold:
\begin{enumerate}
\item For all $\gamma, \tau, \gamma'$ and all intersection patterns $P \in \mathcal{P}_{\gamma,\tau,\gamma'}$,
\[
B_{norm}(\tau_{P}) \leq B(\gamma)B(\gamma')B_{norm}(\tau)
\]
\item For all composable $\gamma_1,\gamma_2$, $B(\gamma_1)B(\gamma_2) = B(\gamma_1 \circ \gamma_2)$.
\end{enumerate}
\end{corollary}
\begin{proof}
We have that
\[
B_{norm}(\tau_{P}) = B_{vertex}^{|V(\tau_P) \setminus U_{\tau_P}| + |V(\tau_P) \setminus V_{\tau_P}|}\left(\prod_{e \in E(\tau_P)}{B_{edge}(e)}\right)n^{\frac{w(V(\tau_P)) + w(I_{\tau_P}) - w(S_{\tau_P})}{2}}
\]
and
\begin{align*}
B(\gamma)B(\gamma')B_{norm}(\tau) &= B_{vertex}^{|V(\gamma) \setminus U_{\gamma}| + |V(\gamma) \setminus V_{\gamma}| + |V(\gamma') \setminus U_{\gamma'}| + |V(\gamma') \setminus V_{\gamma'}| + |V(\tau) \setminus U_{\tau}| + |V(\tau) \setminus V_{\tau}|} \\
&\left(\prod_{e \in E(\gamma) \cup E(\gamma') \cup E(\tau)}{B_{edge}(e)}\right)n^{\frac{w(V(\gamma) \setminus U_{\gamma}) + w(V(\gamma') \setminus U_{\gamma'}) +
w(V(\tau)) + w(I_{\tau}) - w(S_{\tau})}{2}}
\end{align*}
The first condition now follows immediately from the following observations:
\begin{enumerate}
\item \begin{align*}
&|V(\gamma) \setminus U_{\gamma}| + |V(\gamma) \setminus V_{\gamma}| + |V(\gamma') \setminus U_{\gamma'}| + |V(\gamma') \setminus V_{\gamma'}| + |V(\tau) \setminus U_{\tau}| + |V(\tau) \setminus V_{\tau}| \\
&= |V(\gamma \circ \tau \circ {\gamma'}^T) \setminus U_{\gamma \circ \tau \circ {\gamma'}^T}| + |V(\gamma \circ \tau \circ {\gamma'}^T) \setminus V_{\gamma \circ \tau \circ {\gamma'}^T}|
\geq |V(\tau_P) \setminus U_{\tau_P}| + |V(\tau_P) \setminus V_{\tau_P}|
\end{align*}
\item $E(\tau_P) = E(\gamma) \cup E(\tau) \cup E({\gamma'}^T)$ so
$\prod_{e \in E(\tau_P)}{B_{edge}(e)} = \prod_{e \in E(\gamma) \cup E(\gamma') \cup E(\tau)}{B_{edge}(e)}$.
\item By the intersection tradeoff lemma,
\[
w(V(\tau_P)) + w(I_{\tau_P}) - w(S_{\tau_P}) \leq w(V(\tau)) + w(I_{\tau}) - w(S_{\tau}) + w(V(\gamma) \setminus U_{\gamma}) + w(V(\gamma') \setminus U_{\gamma'})
\]
\end{enumerate}
The second condition follows from the form of $B(\gamma)$.
\end{proof}
\subsection{Choosing $N(\gamma)$}
To choose $N(\gamma)$, we use the following lemma:
\begin{lemma}
For all $D_V \in \mathbb{N}$, for all composable $\gamma,\tau,{\gamma'}^T$ such that $|V(\gamma)| \leq D_V$, $|V(\tau)| \leq D_V$, and $|V(\gamma')| \leq D_V$,
\begin{align*}
&\sum_{j>0}{\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}
\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}}}\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{\left(\prod_{i=1}^{j}{N(P_i)}\right)} \\
&\leq \frac{{(3D_V)}^{2(|V(\gamma) \setminus V_{\gamma}| + |V(\gamma') \setminus V_{\gamma'}|) + (|V(\gamma) \setminus U_{\gamma}| + |V(\gamma') \setminus U_{\gamma'}|)}}
{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}}
\end{align*}
\end{lemma}
\begin{proof}[Proof sketch]
Observe that aside from the orderings (which are canceled out by the $|Aut(U_{\gamma_i})|$ and $|Aut(U_{\gamma'_i})|$ factors), the intersection patterns $\{P_i: i \in [j]\}$ are determined by the following data on each vertex $v \in (V(\gamma) \setminus V_{\gamma}) \cup (V({\gamma'}^T) \setminus V_{{\gamma'}^T})$:
\begin{enumerate}
\item The first $i \in [j]$ such that $v \in (V(\gamma_i) \setminus V_{\gamma_i}) \cup (V({\gamma'_i}^T) \setminus V_{{\gamma'_i}^T})$. There are at most $j$ possibilities for this.
\item A vertex $u$ (if one exists) in $V(\gamma_{i-1} \circ \ldots \circ \gamma_1 \circ \tau \circ {\gamma'_1}^T \ldots \circ {\gamma'_{i-1}}^T)$ such that $u$ and $v$ are equal. There are at most $3D_V$ possibilities for this.
\end{enumerate}
Using these observations and taking $j_{max} = |V(\gamma) \setminus V_{\gamma}| + |V(\gamma') \setminus V_{\gamma'}|$,
\begin{align*}
&\sum_{j > 0}{\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}
\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}}}\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{1} \\
&\leq \sum_{j =1}^{j_{max}}{\frac{{(3jD_V)}^{|V(\gamma) \setminus V_{\gamma}| + |V(\gamma') \setminus V_{\gamma'}|}}
{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}}} \\
&\leq j_{max}\left(\frac{2}{3}\right)^{j_{max}}\frac{{(3D_V)}^{2(|V(\gamma) \setminus V_{\gamma}| + |V(\gamma') \setminus V_{\gamma'}|)}}
{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}} \\
&< \frac{{(3D_V)}^{2(|V(\gamma) \setminus V_{\gamma}| + |V(\gamma') \setminus V_{\gamma'}|)}}
{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}}
\end{align*}
Now recall that by Lemma ,
for any $\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^{T}$ and any intersection pattern $P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}$,
\[
N(P_i) \leq |V(\tau_{P_i})|^{|V(\gamma_i) \setminus U_{\gamma_i}| + |V(\gamma'_i) \setminus U_{\gamma'_i}|}
\]
Thus, for any $P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}$, $\prod_{i=1}^{j}{N(P_i)} \leq (3D_V)^{|V(\gamma) \setminus U_{\gamma}| + |V(\gamma') \setminus U_{\gamma'}|}$.
Putting everything together, the result follows.
\end{proof}
\begin{corollary}
For all $D_V \in \mathbb{N}$, if we take $N(\gamma) = (3D_V)^{2|V(\gamma) \setminus V_{\gamma}| + |V(\gamma) \setminus U_{\gamma}|}$ then for all composable $\gamma, \tau, {\gamma'}^T$ such that $|V(\gamma)| \leq D_V$, $|V(\tau)| \leq D_V$, and $|V(\gamma')| \leq D_V$,
\begin{align*}
&\sum_{j>0}{\sum_{\gamma_1,\gamma'_1,\cdots,\gamma_j,\gamma'_j \in \Gamma_{\gamma,\gamma',j}}{\prod_{i:\gamma_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma_i})|}}
\prod_{i:\gamma'_i \text{ is non-trivial}}{\frac{1}{|Aut(U_{\gamma'_i})|}}}}\sum_{P_1,\cdots,P_j:P_i \in \mathcal{P}_{\gamma_i,\tau_{P_{i-1}},{\gamma'_i}^T}}{\left(\prod_{i=1}^{j}{N(P_i)}\right)} \\
&\leq \frac{N(\gamma)N(\gamma')}
{(|Aut(U_{\gamma})|)^{1_{\gamma \text{ is non-trivial}}}(|Aut(U_{\gamma'})|)^{1_{\gamma' \text{ is non-trivial}}}}
\end{align*}
\end{corollary}
\subsection{Choosing $c(\alpha)$}
In this section, we describe how to choose $c(\alpha)$. For simplicity, we first describe how to choose $c(\alpha)$ under our simplifying assumptions. We then describe the minor adjustments that are needed when we have hyperedges and multiple types of vertices.
\begin{lemma}\label{calphalemma}
Under our simplifying assumptons, for all $U \in \mathcal{I}_{mid}$,
\[
\sum_{\alpha: U_{\alpha} \equiv U, \alpha \text{ is proper and non-trivial}}{\frac{1}{|Aut(U_{\alpha} \cap V_{\alpha})|(3D_V)^{|U_{\alpha} \setminus V_{\alpha}| + |V_{\alpha} \setminus U_{\alpha}| + 2|E(\alpha)|}2^{|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})|}}} < 5
\]
\end{lemma}
\begin{proof}
In order to choose $\alpha$, it is sufficient to choose the following:
\begin{enumerate}
\item The number $j_1$ of vertices in $U_{\alpha} \setminus V_{\alpha}$, the number $j_2$ of vertices in $V_{\alpha} \setminus U_{\alpha}$, and the number $j_3$ of vertices in $V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})$.
\item A mapping in $Aut(U_{\alpha} \cap V_{\alpha})$ determining how the vertices in $U_{\alpha} \cap V_{\alpha}$ match up with each other.
\item The position of each vertex $u \in U_{\alpha} \setminus V_{\alpha}$ within $U_{\alpha}$ (there are at most $|U_{\alpha}| \leq D_V$ choices for this).
\item The position of each vertex $v \in V_{\alpha} \setminus U_{\alpha}$ within $V_{\alpha}$ (there are at most $|U_{\alpha}| \leq D_V$ choices for this).
\item The number $j_4$ of edges in $E(\alpha)$.
\item The endpoints of each edge in $E(\alpha)$.
\end{enumerate}
This implies that for all $j_1,j_2,j_3,j_4 \geq 0$
\[
\sum_{\alpha: U_{\alpha} \equiv U, |U_{\alpha} \setminus V_{\alpha}| = j_1, |V_{\alpha} \setminus U_{\alpha}| = j_2 \atop
|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})| = j_3, |E(\alpha)| = j_4}{\frac{1}{|Aut(U_{\alpha} \cap V_{\alpha})|(D_V)^{j_1 + j_2}
(D_V)^{2j_4}}} \leq 1
\]
Using this, we have that
\begin{align*}
&\sum_{\alpha: U_{\alpha} \equiv U, \alpha \text{ is proper and non-trivial}}{\frac{1}{|Aut(U_{\alpha} \cap V_{\alpha})|(3D_V)^{|U_{\alpha} \setminus V_{\alpha}| + |V_{\alpha} \setminus U_{\alpha}| + 2|E(\alpha)|}2^{|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})|}}} \\
&\leq \sum_{j_1,j_2,j_3,j_4 \in \mathbb{N} \cup \{0\}: j_1 + j_2 + j_3 + j_4 \geq 1}{\frac{1}{3^{j_1 + j_2}9^{j_4}2^{j_3}}} \leq 2\left(\frac{3}{2}\right)^2\frac{9}{8} - 1 < 5
\end{align*}
\end{proof}
\begin{corollary}
For all $\varepsilon' > 0$, if we take
\[
c(\alpha) = \frac{5(3D_V)^{|U_{\alpha} \setminus V_{\alpha}| + |V_{\alpha} \setminus U_{\alpha}| + 2|E(\alpha)|}2^{|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})|}}{\varepsilon'}
\]
then
\begin{enumerate}
\item $\forall U \in \mathcal{I}_{mid}, \sum_{\gamma \in \Gamma_{U,*}}{\frac{1}{|Aut(U)|c(\gamma)}} < \varepsilon'$
\item $\forall V \in \mathcal{I}_{mid}, \sum_{\gamma \in \Gamma_{*,V}}{\frac{1}{|Aut(U_{\gamma})|c(\gamma)}} < \varepsilon'$
\item $\forall U \in \mathcal{I}_{mid}, \sum_{\tau \in \mathcal{M}_{U}}{\frac{1}{|Aut(U)|c(\tau)}} < \varepsilon'$
\end{enumerate}
\end{corollary}
\subsubsection{Choosing $c(\alpha)$ in general*}
When we have multiple types of vertices and hyperedges of arity $k$, Lemma \ref{calphalemma} can be generalized as follows:
\begin{lemma}
Under our simplifying assumptons, for all $U \in \mathcal{I}_{mid}$,
\[
\sum_{\alpha: U_{\alpha} \equiv U, \alpha \text{ is proper and non-trivial}}{\frac{1}{|Aut(U_{\alpha} \cap V_{\alpha})|(3D_V{t_{max}})^{|U_{\alpha} \setminus V_{\alpha}| + |V_{\alpha} \setminus U_{\alpha}| + k|E(\alpha)|}(2t_{max})^{|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})|}}} < 5
\]
\end{lemma}
\begin{proof}[Proof sketch]
This can be proved in the same way as Lemma \ref{calphalemma} with the following modifications:
\begin{enumerate}
\item In addition to choosing the number of vertices in $U_{\alpha} \setminus V_{\alpha}$, $V_{\alpha} \setminus U_{\alpha}$, and $V(\alpha) \setminus (U_{\alpha} \cap V_{\alpha})$, we also have to choose the types of these vertices.
\item For each hyperedge, we have to choose $k$ endpoints rather than $2$ endpoints.
\end{enumerate}
\end{proof}
\begin{corollary}\label{cor: calphachoice}
For all $\varepsilon' > 0$, if we take
\[c(\alpha) = \frac{5(3{t_{max}}D_V)^{|U_{\alpha} \setminus V_{\alpha}| + |V_{\alpha} \setminus U_{\alpha}| + k|E(\alpha)|}(2t_{max})^{|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})|}}{\varepsilon'}\]
then
\begin{enumerate}
\item $\forall U \in \mathcal{I}_{mid}, \sum_{\gamma \in \Gamma_{U,*}}{\frac{1}{|Aut(U)|c(\gamma)}} < \varepsilon'$
\item $\forall V \in \mathcal{I}_{mid}, \sum_{\gamma \in \Gamma_{*,V}}{\frac{1}{|Aut(U_{\gamma})|c(\gamma)}} < \varepsilon'$
\item $\forall U \in \mathcal{I}_{mid}, \sum_{\tau \in \mathcal{M}_{U}}{\frac{1}{|Aut(U)|c(\tau)}} < \varepsilon'$
\end{enumerate}
\end{corollary}
For technical reasons, we will need a more refined bound when the sum is over all shapes $\gamma$ of at least a prescribed size.
\begin{lemma}\label{lem: tpca_refined_bound}
For all $\varepsilon' > 0$, for the same choice of $c(\alpha)$ as in $\cref{cor: calphachoice}$, for any $U \in {\mathcal I}_{mid}$ and integer $m \ge 1$, we have \[\sum_{\gamma \in \Gamma_{U, *}: |V(\gamma)| \ge |U| + m} \frac{1}{|Aut(U)|c(\gamma)} \le \frac{\varepsilon'}{5\cdot 2^{m - 1}}\]
\end{lemma}
\begin{proof}[Proof sketch]
The proof is similar to the proof of \cref{cor: calphachoice}, but we now have the extra condition $j_2 + j_3 \ge m$ in the proof of \cref{calphalemma}. Then,
\[\sum_{j_1, j_2, j_3, j_4 \in \mathbb{N}\cup \{0\}: j_2 + j_3 \ge m} \frac{1}{3^{j_1 + j_2}9^{j_4}2^{j_3}} \le \sum_{j_1, j_4 \in \mathbb{N}\cup \{0\}} \frac{1}{2^m3^{j_1}9^{j_4}} = \frac{27}{16\cdot 2^m}\le \frac{1}{2^{m - 1}}\]
\end{proof}
\subsection{Proof of the Generalized Intersection Tradeoff Lemma}
We now prove the generalized intersection tradeoff lemma.
\begin{lemma}
For all $\gamma, \tau, \gamma'$ and all intersection patterns $P \in \mathcal{P}_{\gamma,\tau,\gamma'}$,
\[
w(V(\tau_P)) + w(I_{\tau_P}) - w(S_{\tau_P,min}) \leq w(V(\tau)) + w(I_{\tau}) - w(S_{\tau,min})+ w(V(\gamma) \setminus U_{\gamma}) + w(V(\gamma') \setminus U_{\gamma'})
\]
\end{lemma}
\begin{proof}
\begin{definition} \
\begin{enumerate}
\item We define $I_{LM}$ to be the set of vertices which, after intersections, touch $\gamma$ and $\tau$ but not ${\gamma'}^T$. In particular, $I_{LM}$ consists of the vertices which result from intersecting a pair of vertices in $V(\gamma) \setminus V_{\gamma}$ and $V(\tau) \setminus U_{\tau} \setminus V_{\tau}$ and the vertices which are in $U_{\tau} \setminus V_{\tau}$ and are not intersected with any other vertex.
\item We define $I_{MR}$ to be the set of vertices which, after intersections, touch $\tau$ and ${\gamma'}^T$ but not $\gamma$. In particular, $I_{MR}$ consists of the vertices which result from intersecting a pair of vertices in $V(\tau) \setminus U_{\tau} \setminus V_{\tau}$ and $V({\gamma'}^T) \setminus U_{{\gamma'}^T}$ and the vertices which are in $V_{\tau} \setminus U_{\tau}$ and are not intersected with any other vertex.
\item We define $I_{LR}$ to be the set of vertices which, after intersections, touch $\gamma$ and ${\gamma'}^T$ but not $\tau$. In particular, $I_{LR}$ consists of the vertices which result from intersecting a pair of vertices in $V(\gamma) \setminus V_{\gamma}$ and $V({\gamma'}^T) \setminus U_{{\gamma'}^T}$.
\item We define $I_{LMR}$ to be the set of vertices which, after intersections, touch $\gamma$, $\tau$, and ${\gamma'}^T$. In particular, $I_{LMR}$ consists of the vertices which result from intersecting a triple of vertices in $V(\gamma) \setminus V_{\gamma}$, $V(\tau) \setminus U_{\tau} \setminus V_{\tau}$, and $V({\gamma'}^T) \setminus U_{{\gamma'}^T}$, intersecting a pair of vertices in $V(\gamma) \setminus V_{\gamma}$ and $V_{\tau} \setminus U_{\tau}$, intersecting a pair of vertices in $U_{\tau} \setminus V_{\tau}$ and $V({\gamma'}^T) \setminus U_{{\gamma'}^T}$, and single vertices in $U_{\tau} \cap V_{\tau}$.
\end{enumerate}
\end{definition}
The main idea is as follows. A priori, any of the vertices in $I_{LM} \cup I_{MR} \cup I_{LR} \cup I_{LMR}$ could become isolated. We handle this by keeping track of the following types of flows:
\begin{enumerate}
\item Flows from $U_{\gamma}$ to $I_{LM} \cup I_{LR} \cup I_{LMR}$
\item Flows from $I_{LR} \cup I_{MR} \cup I_{LMR}$ to $V_{{\gamma'}^T}$
\item Flows from $I_{LM}$ to $I_{MR}$. For technical reasons, we also view vertices in $I_{LMR}$ as having flow to themselves.
\end{enumerate}
We then observe that flows to and from these vertices prevent these vertices from being isolated and can provide flow from $U_{\gamma}$ to $V_{{\gamma'}^T}$, which gives a lower bound on $w(S_{\tau_P})$.
We now implement this idea.
\begin{definition}[Flow Graph]
Given a shape $\alpha$, we define the directed graph $H_{\alpha}$ as follows:
\begin{enumerate}
\item For each vertex $v \in V(\alpha)$, we create two vertices $v_{in}$ and $v_{out}$. We then create a directed edge from $v_{in}$ to $v_{out}$ with capacity $w(v)$
\item For each pair of vertices $(v,w)$ which is an edge of multiplicity $1$ in $E(\alpha)$ (or part of a hyperedge of multiplicity $1$ in $E(\alpha)$), we create a directed edge with infinite capacity from $v_{out}$ to $w_{in}$ and we create a directed edge with infinite capacity from $w_{out}$ to $v_{in}$.
\item We define $U_{H_{\alpha}}$ to be $U_{H_{\alpha}} = \{u_{in}: u \in U_{\alpha}\}$ and we define $V_{H_{\alpha}}$ to be $V_{H_{\alpha}} = \{v_{out}: v \in V_{\alpha}\}$
\end{enumerate}
\end{definition}
\begin{lemma}
The maximum flow from $U_{H_{\alpha}}$ to $V_{H_{\alpha}}$ is equal to the minimum weight of a separator between $U_{\alpha}$ and $V_{\alpha}$.
\end{lemma}
\begin{proof}
This can be proved using the max flow min cut theorem.
\end{proof}
\begin{definition}[Modified Flow Graph]
Given a shape $\alpha$ together with a set $I_L \subseteq V(\alpha)$ of vertices in $\alpha$ (which will be the vertices in $\alpha$ which are intersected with a vertex to the left of $\alpha$) and a set $I_R \subseteq V(\alpha)$ of vertices in $\alpha$ (which will be the vertices in $\alpha$ which are intersected with a vertex to the right of $\alpha$), we define the modified flow graph $H^{I_L,I_R}_{\alpha}$ as follows:
\begin{enumerate}
\item We start with the flow graph $H_{\alpha}$
\item For each vertex $u \in I_L$, we delete all of the edges into $u_{in}$ and add $u_{in}$ to $U_{H_{\alpha}}$
\item For each vertex $v \in I_R$, we delete all of the edges out of $v_{out}$ and add $v_{out}$ to $V_{H_{\alpha}}$
\item We call the resulting graph $H^{I_L,I_R}_{\alpha}$ and the resulting sets $U_{H^{I_L,I_R}_{\alpha}}$ and $V_{H^{I_L,I_R}_{\alpha}}$
\end{enumerate}
\end{definition}
\begin{lemma}\label{increasedflowlemma}
The maximum flow from $U_{H^{I_L,I_R}_{\alpha}}$ to $V_{H^{I_L,I_R}_{\alpha}}$ in $H^{I_L,I_R}_{\alpha}$ is at least as large as the maximum flow from $U_{H_{\alpha}}$ to $V_{H_{\alpha}}$ in $H_{\alpha}$
\end{lemma}
\begin{proof}[Proof sketch]
Observe that if we have a cut $C$ in $H^{I_L,I_R}_{\alpha}$ which separates $U_{H^{I_L,I_R}_{\alpha}}$ and $V_{H^{I_L,I_R}_{\alpha}}$ then $C$ separates $U_{H_{\alpha}}$ and $V_{H_{\alpha}}$ in $H_{\alpha}$
\end{proof}
Before the intersections, we have the following flows.
\begin{enumerate}
\item We take $F_1$ to be the maximum flow from $U_{\gamma}$ to $V_{\gamma}$ in $\gamma$. Note that $F_1$ has value $w(V_{\gamma})$
\item We take $F_2$ to be the maximum flow from $U_{\tau}$ to $V_{\tau}$ in $\tau$. Note that $F_2$ has value $w(S_{\tau,min})$
\item We take $F_3$ to be the maximum flow from $U_{{\gamma'}^T}$ to $V_{{\gamma'}^T}$ in ${\gamma'}^T$. Note that $F_1$ has value $w(U_{{\gamma'}^T})$
\end{enumerate}
After the intersections, we take the following flows:
\begin{enumerate}
\item We take $F'_1$ to be the maximum flow from $U_{H^{\emptyset,I_{LM} \cup I_{LR} \cup I_{LMR}}_{\gamma}}$ to $V_{H^{\emptyset,I_{LM} \cup I_{LR} \cup I_{LMR}}_{\gamma}}$ in \\
$H^{\emptyset,I_{LM} \cup I_{LR} \cup I_{LMR}}_{\gamma}$.
\item We take $F'_2$ to be the maximum flow from $U_{H^{I_{LM} \cup I_{LMR},I_{MR} \cup I_{LMR}}_{\tau}}$ to $V_{H^{I_{LM} \cup I_{LMR},I_{MR} \cup I_{LMR}}_{\tau}}$ in \\
$H^{I_{LM} \cup I_{LMR},I_{MR} \cup I_{LMR}}_{\tau}$
\item We take $F'_3$ to be the maximum flow from $U_{H^{I_{MR} \cup I_{LR} \cup I_{LMR},\emptyset}_{{\gamma'}^T}}$ to $V_{H^{I_{MR} \cup I_{LR} \cup I_{LMR},\emptyset}_{{\gamma'}^T}}$ in \\
$H^{I_{MR} \cup I_{LR} \cup I_{LMR},\emptyset}_{{\gamma'}^T}$.
\end{enumerate}
Observe that because of how intersection patterns are defined, $val(F'_1) = w(U_{\gamma})$ and $val(F'_3) = w(V_{{\gamma'}^T})$. By Lemma \ref{increasedflowlemma}, the value of $F'_2$ is at least as large as the value of $F_2$, so $val(F'_2) \geq w(S_{\tau,min})$.
We now consider $F'_1 + F'_2 + F'_3$. As is, this is not a flow, but we can fix this.
\begin{definition}
For each vertex $v \in V(\tau_P)$,
\begin{enumerate}
\item We define $f_{in}(v)$ to be the flow into $v_{in}$ in $F'_1 + F'_2 + F'_3$.
\item We define $f_{out}(v)$ to be the flow out of $v_{out}$ in $F'_1 + F'_2 + F'_3$.
\item We define $f_{through}(v)$ to be the flow from $v_{in}$ to $v_{out}$ in $F'_1 + F'_2 + F'_3$
\item We define $f_{imbalance}(v)$ to be $f_{imbalance}(v) = |f_{in}(v) - f_{out}(v)|$
\item We define $f_{excess}(v)$ to be $f_{excess}(v) = f_{through}(v) - max{\{f_{in}(v),f_{out}(v)\}}$
\end{enumerate}
With this information, we fix the flow $F'_1 + F'_2 + F'_3$ as follows. For each vertex $v \in V(\tau_P)$,
\begin{enumerate}
\item If $f_{in}(v) > f_{out}(v)$ then we create a vertex $v_{supplemental,out}$ and an edge from $v_{out}$ to $v_{supplemental,out}$ with capacity $f_{imbalance}(v)$ and we route $f_{imbalance}(v)$ of flow along this edge. We then add $v_{supplemental,out}$ to a set of vertices $V_{supplemental}$.
\item If $f_{in}(v) < f_{out}(v)$ then we create a vertex $v_{supplemental,in}$ and an edge from $v_{supplemental,in}$ to $v_{in}$ with capacity $f_{imbalance}(v)$ and we route $f_{imbalance}(v)$ of flow along this edge. We then add $v_{supplemental,out}$ to a set of vertices $V_{supplemental}$.
\item We reduce the flow on the edge from $v_{in}$ to $v_{out}$ by $f_{excess}(v)$
\end{enumerate}
We call the resulting flow $F'$
\end{definition}
\begin{proposition}
$F'$ is a flow from $U_{H^{\emptyset,I_{LM} \cup I_{LR} \cup I_{LMR}}_{\gamma}} \cup U_{supplemental}$ to $V_{H^{I_{MR} \cup I_{LR} \cup I_{LMR},\emptyset}_{{\gamma'}^T}} \cup V_{supplemental}$ with value $val(F') = val(F'_1) + val(F'_2) + val(F'_3) - \sum_{v \in V(\tau)}{f_{excess}(v)}$
\end{proposition}
\begin{corollary}\label{fixedflowcorollary}
There exists a flow $F''$ from $U_{H^{\emptyset,I_{LM} \cup I_{LR} \cup I_{LMR}}_{\gamma}}$ to $V_{H^{I_{MR} \cup I_{LR} \cup I_{LMR},\emptyset}_{{\gamma'}^T}}$ with value $val(F'') \geq val(F'_1) + val(F'_2) + val(F'_3) - \sum_{v \in V(\tau)}{(f_{excess}(v) + f_{imbalance}(v))}$
\end{corollary}
\begin{proof}
Consider the minimum cut $C$ between $U_{H^{\emptyset,I_{LM} \cup I_{LR} \cup I_{LMR}}_{\gamma}}$ and $V_{H^{I_{MR} \cup I_{LR} \cup I_{LMR},\emptyset}_{{\gamma'}^T}}$. If we add all of the supplemental edges to $C$ then this gives a cut $C'$ between $U_{H^{\emptyset,I_{LM} \cup I_{LR} \cup I_{LMR}}_{\gamma}}$ and $V_{H^{I_{MR} \cup I_{LR} \cup I_{LMR},\emptyset}_{{\gamma'}^T}}$ with capacity
\[
capacity(C') = capacity(C) + \sum_{v \in V(\tau)}{f_{imbalance}(v)} \geq val(F')
\]
Thus, $capacity(C) \geq val(F') - \sum_{v \in V(\tau)}{f_{imbalance}(v)}$ so there exists a flow $F''$ from $U_{H^{\emptyset,I_{LM} \cup I_{LR} \cup I_{LMR}}_{\gamma}}$ to $V_{H^{I_{MR} \cup I_{LR} \cup I_{LMR},\emptyset}_{{\gamma'}^T}}$ with value
\[
val(F'') = capacity(C) \geq val(F'_1) + val(F'_2) + val(F'_3) - \sum_{v \in V(\tau)}{(f_{excess}(v) + f_{imbalance}(v))}
\]
\end{proof}
We now make the following observations:
\begin{lemma} \
\begin{enumerate}
\item For all vertices $v \notin I_{LM} \cup I_{MR} \cup I_{LR} \cup I_{LMR}$, $f_{excess}(v) = f_{imbalance}(v) = 0$ (and these vertices can never be isolated).
\item For all vertices $v \in I_{LM}$, $f_{excess}(v) + f_{imbalance}(v) \leq w(v)$. Moreover, for all vertices $v \in I_{LM}$ which are isolated, $f_{excess}(v) = f_{imbalance}(v) = 0$.
\item For all vertices $v \in I_{MR}$, $f_{excess}(v) + f_{imbalance}(v) \leq w(v)$. Moreover, for all vertices $v \in I_{LM}$ which are isolated, $f_{excess}(v) = f_{imbalance}(v) = 0$.
\item For all vertices $v \in I_{LR}$, $f_{excess}(v) + f_{imbalance}(v) \leq w(v)$. Moreover, for all vertices $v \in I_{LM}$ which are isolated, $f_{excess}(v) = f_{imbalance}(v) = 0$.
\item For all vertices $v \in I_{LMR}$, $f_{excess}(v) + f_{imbalance}(v) \leq 2w(v)$. Moreover, for all vertices $v \in I_{LMR}$ which are isolated, $f_{excess}(v) = w(v)$ and $f_{imbalance}(v) = 0$.
\end{enumerate}
\end{lemma}
\begin{proof}
For the first statement, observe that for vertices $v \notin I_{LM} \cup I_{MR} \cup I_{LR} \cup I_{LMR}$, neither $v_{in}$ nor $v_{out}$ is ever a sink or source so the flow into these vertices must equal the flow out of these vertices and thus $f_{in}(v) = f_{out}(v) = f_{through}(v)$.
For the second statement, observe that for a vertex $v \in I_{LM}$,
\begin{enumerate}
\item $F'_1$ will have a flow of $f_{in}(v)$ into $v_{in}$ and along the edge from $v_{in}$ to $v_{out}$
\item $F'_2$ will have a flow of $f_{out}(v)$ along the edge from $v_{in}$ to $v_{out}$ and out of $v_{out}$.
\end{enumerate}
Thus, $f_{excess}(v) = f_{in}(v) + f_{out}(v) - \max\{f_{in}(v),f_{out}(v)\}$. Since $f_{imbalance}(v) = |f_{in}(v) - f_{out}(v)|$,
$f_{excess}(v) + f_{imbalance}(v) = f_{in}(v) + f_{out}(v) - \min\{f_{in}(v),f_{out}(v)\} \leq w(v)$.
If $v$ is isolated then neither $F'_1$ nor $F'_2$ can have any flow to $v_{in}$ or out of $v_{out}$ so $f_{in}(v) = f_{through}(v) = f_{out}(v) = 0$
The third and fourth statements can be proved in the same way as the second statement.
For the fifth statement, observe that for a vertex $v \in I_{LMR}$,
\begin{enumerate}
\item $F'_1$ will have a flow of $f_{in}(v)$ into $v_{in}$ and along the edge from $v_{in}$ to $v_{out}$.
\item $F'_2$ will have a flow of $w(v)$ along the edge from $v_{in}$ to $v_{out}$
\item $F'_3$ will have a flow of $f_{out}(v)$ along the edge from $v_{in}$ to $v_{out}$ and out of $v_{out}$.
\end{enumerate}
Thus, $f_{excess}(v) = w(v) + f_{in}(v) + f_{out}(v) - \max\{f_{in}(v),f_{out}(v)\}$. Since $f_{imbalance}(v) = |f_{in}(v) - f_{out}(v)|$,
$f_{excess}(v) + f_{imbalance}(v) = w(v) + f_{in}(v) + f_{out}(v) - \min\{f_{in}(v),f_{out}(v)\} \leq 2w(v)$.
If $v$ is isolated then neither $F'_1$ nor $F'_3$ can have any flow to $v_{in}$ or out of $v_{out}$ so $f_{in}(v) = f_{out}(v) = 0$ and $f_{through}(v) = w(v)$.
\end{proof}
Putting everything together, we have the following corollary:
\begin{corollary} \
\[
\sum_{v \in V(\tau_P)}{(f_{excess}(v) + f_{imbalance}(v))} \leq w(I_{LM}) + w(I_{LR}) + w(I_{MR}) + 2w(I_{LMR}) - (w(I_{\tau_P}) - w(I_{\tau}))
\]
\end{corollary}
Combining this with Corollary \ref{fixedflowcorollary},
\begin{align*}
w(S_{\tau_P,min}) &\geq val(F'_1) + val(F'_2) + val(F'_3) - \sum_{v \in V(\tau_P)}{(f_{excess}(v) + f_{imbalance}(v))}\\
&\geq w(U_{\gamma}) + w(S_{\tau,min}) + w(V_{{\gamma'}^T}) - w(I_{LM}) - w(I_{LR}) - w(I_{MR}) - 2w(I_{LMR}) + (w(I_{\tau_P}) - w(I_{\tau}))
\end{align*}
Since $w(V(\tau_P)) = w(V(\tau)) + w(V(\gamma)) + w(V(\gamma')) - w(I_{LM}) - w(I_{LR}) - w(I_{MR}) - 2w(I_{LMR})$,
\[
w(S_{\tau_P,min}) \geq w(U_{\gamma}) + w(S_{\tau,min}) + w(V_{{\gamma'}^T}) + w(V(\tau_P)) - w(V(\tau)) - w(V(\gamma)) - w(V(\gamma')) + (w(I_{\tau_P}) - w(I_{\tau}))
\]
Rearranging this gives
\[
w(V(\tau_P)) - w(S_{\tau_P,min}) + w(I_{\tau_P}) \leq w(V(\tau)) - w(S_{\tau,min}) + w(I_{\tau}) + w(V(\gamma) \setminus U_{\gamma}) + w(V(\gamma') \setminus U_{\gamma'})
\]
which is the generalized intersection tradeoff lemma.
\end{proof}
\subsubsection{Additional Parameters for the General Case*}
In the general case we will need a few additional parameters which we define here.
\begin{definition} \
\begin{enumerate}
\item We define $k$ to be the arity of the hyperedges corresponding to the input.
\item We define $t_{max}$ to be the number of different types of indices. We define $n_i$ to be the number of possibilities for indices of type $i$ and we define $n = \max{\{n_i: i \in [t_{max]}\}}$.
\end{enumerate}
\end{definition}
\subsection{Indices, Input Entries, Vertices, and Edges}
Note: For this section, we use $X$ to denote the input, we use $x$ to denote entries of the input and we use $y$ to denote solution variables.
\begin{definition}[Vertices: Simplified Case]
When the input and solution variables are indexed by one type of index which takes values in $[n]$ then we represent the index $i$ by a vertex labeled $i$.
If we want to leave an index unspecified, we instead represent it by a vertex labeled with a variable (we will generally use $u$, $v$, or $w$ for these variables).
\end{definition}
\begin{definition}[Vertices: General Case*]
When the input and solution variables are indexed by several types of indices where indices of type $t$ take values in $[n_t]$, we represent an index of type $t$ with value $i$ as a vertex labeled by the tuple $(t,i)$. We say that such a vertex has type $t$.
If we want to leave an index of type $t$ unspecified, we instead represent it by a vertex labeled with a tuple $(t,?)$ where $?$ is a variable (which will generally be $u$, $v$, or $w$).
\end{definition}
\begin{definition}[Edges: Simplified Case]
When the input is $X \in \{-1,+1\}^{\binom{n}{2}}$, we represent the entries of the input by the undirected edges $\{(i,j): i < j \in [n]\}$. Given an edge $e = (i,j)$, we take $x_e = x_{ij}$ to be the input entry corresponding to $e$.
\end{definition}
\begin{definition}[Edges: General Case*]
In general, we represent the entries of the input by hyperedges whose form depends on nature of the input. We still take $x_e$ to be the input entry corresponding to $e$.
\end{definition}
\begin{example}
If the input is an $n_1 \times n_2$ matrix $X$ then we will have two types of indices, one for the row and one for the column. Thus, we will have the vertices $\{(1,i): i \in [n_1]\} \cup \{(2,j): j \in [n_2]\}$. In this case, we have an edge $((1,i),(2,j))$ for each entry $x_{ij}$ of the input.
\end{example}
\begin{example}
If the input is an $n \times n$ matrix $X$ which is not symmetric then we only need the indices $[n]$. In this case, we have a directed edge $(i,j)$ for each entry $x_{ij}$ where $i \neq j$. If the entries $x_{ii}$ are also part of the input than we also have loops $(i,i)$ for these entries.
\end{example}
\begin{example}
If our input is a symmetric $n \times n \times n$ tensor $X$ (i.e. $x_{ijk} = x_{ikj} = x_{jik} = x_{jki} = x_{kij} = x_{kji}$) and $x_{ijk} = 0$ whenever $i,j,k$ are not distinct then we only need the indices $[n]$. In this case, we have an undirected hyperedge $e = (i,j,k)$ for each entry $x_{e} = x_{ijk}$ of the input where $i,j,k$ are distinct.
\end{example}
\begin{example}
If the input is an $n_1 \times n_2 \times n_3$ tensor $X$ then we will have three types of indices. Thus, we will have the vertices $\{(1,i): i \in [n_1]\} \cup \{(2,j): j \in [n_2]\} \cup \{(3,k): k \in [n_3]\}$. In this case, we have a hyperedge $e = ((1,i),(2,j),(3,k))$ for each entry $x_e = x_{ijk}$ of the input.
\end{example}
\subsection{Matrix Indices and Monomials}
In this subsection, we discuss how our matrices are indexed and how we associate matrix indices with monomials. We also describe the automorphism groups of matrix indices.
\begin{definition}[Matrix Indices: Simplified Case]
If there is only one type of index and we have the constraints $y^2_i = 1$ or $y^2_i = y_i$ on the solution variables then we define a matrix index $A$ to be a tuple of indices $(a_1,\ldots,a_{|A|})$. We make the following definitions about matrix indices:
\begin{enumerate}
\item We associate the monomial $\prod_{j=1}^{|A|}{y_{a_j}}$ to $A$.
\item We define $V(A)$ to be the set of vertices $\{a_i: i \in [|A|]\}$. For brevity, we will often write $A$ instead of $V(A)$ when it is clear from context that we are referring to $A$ as a set of vertices rather than a matrix index.
\item We take the automorphism group of $A$ to be $Aut(A) = S_{|A|}$ (the permutations of the elements of $A$)
\end{enumerate}
\end{definition}
\begin{example}
The matrix index $A = (4,6,1)$ represents the monomial ${y_4}{y_6}{y_1} = {y_1}{y_4}{y_6}$ and $Aut(A) = S_3$
\end{example}
\begin{remark}
We take $A$ to be an ordered tuple rather than a set for technical reasons.
\end{remark}
In general, we need a more intricate definition for matrix indices. We start by defining matrix index pieces
\begin{definition}[Matrix Index Piece Definition*]
We define a matrix index piece $A_i = ((a_{i1},\ldots,a_{i|A_i|}), t_i, p_i)$ to be a tuple of indices $(a_{i1},\ldots,a_{i|A_i|})$ together with a type $t_i$ and a power $p_i$. We make the following definitions about matrix index pieces:
\begin{enumerate}
\item We associate the monomial $p_{A_i} = \prod_{j = 1}^{|A_i|}{y^{p_i}_{{t_i}j}}$ with $A_i$.
\item We define $V(A_i)$ to be the set of vertices $\{(t_i,a_{ij}): j \in [|A_i|]\}$.
\item We take the automorphism group of $A_i$ to be $Aut(A_i) = S_{|A_i|}$
\item We say that $A_i$ and $A_j$ are disjoint if $V(A_i) \cap V(A_j) = \emptyset$ (i.e. $t_i \neq t_j$ or $\{a_{i1},\ldots,a_{i|A_i|}\} \cap \{a_{j1},\ldots,a_{j|A_j|}\} = \emptyset$)
\end{enumerate}
\end{definition}
\begin{definition}[General Matrix Index Definition*]
We define a matrix index $A = \{A_i\}$ to be a set of disjoint matrix index pieces. We make the following definitions about matrix indices:
\begin{enumerate}
\item We associate the monomial $p_{A} = \prod_{A_i \in A}{p(A_i)}$ with $A$.
\item We define $V(A)$ to be the set of vertices $\cup_{A_i \in A}{V(A_i)}$. For brevity, we will often write $A$ instead of $V(A)$ when it is clear from context that we are referring to $A$ as a set of vertices rather than a matrix index.
\item We take the automorphism group of $A$ to be $Aut(A) = \prod_{A_i \in A}{Aut(A_i)}$
\end{enumerate}
\end{definition}
\begin{example}[*]
If $A_1 = ((2),1,1)$, $A_2 = ((3,1),1,2)$, and $A_3 = ((1,2,3),2,1)$ then $A = \{A_1,A_2,A_3\}$ represesents the monomial $p = {y_{12}}{y^2_{13}}{y^2_{11}}{y_{21}}{y_{22}}{y_{23}}$ and we have $Aut(A) = S_1 \times S_2 \times S_3$
\end{example}
\subsection{Fourier Characters and Ribbons}
A key idea is to analyze Fourier characters of the input.
\begin{definition}[Simplified Fourier Characters]
If the input distribution is $\Omega = \{-1,1\}$ then given a multi-set of edges $E$, we define $\chi_{E}(X) = \prod_{e \in E}{x_e}$.
\end{definition}
\begin{example}
If the input is a graph $G \in \{-1,1\}^{\binom{n}{2}}$ and $E$ is a set of potential edges of $G$ (with no multiple edges) then $\chi_E(G) = (-1)^{|E \setminus E(G)|}$.
\end{example}
In general, the Fourier characters are somewhat more complicated.
\begin{definition}[Orthonormal Basis for ${\Omega}$*]
We define the polynomials $\{h_i: i \in \mathbb{Z} \cap [0,|supp(\Omega)|-1]\}$ to be the unique polynomials (which can be found through the Gram-Schmidt process) such that
\begin{enumerate}
\item $\forall i, E_{\Omega}[h^2_i(x)] = 1$
\item $\forall i \neq j, E_{\Omega}[h_i(x)h_j(x)] = 0$
\item For all $i$, the leading coefficient of $h_i(x)$ is positive.
\end{enumerate}
\end{definition}
\begin{example}\label{example: hermite_basis}
If $\Omega$ is the normal distribution then the polynomials $\{h_i\}$ are the Hermite polynomials with the appropriate normalization so that for all $i$, $E_{\Omega}[h^2_i(x)] = 1$. In particular, $h_0(x) = 1$, $h_1(x) = x$, $h_2(x) = \frac{x^2 - 1}{\sqrt{2!}}$, $h_3(x) = \frac{x^3 - 3x}{\sqrt{3!}}$, etc.
\end{example}
\begin{definition}[General Fourier Characters*]
Given a multi-set of hyperedges $E$, each of which has a label $l(e) \in [|support(\Omega)|-1]$ (or $\mathbb{N}$ if $\Omega$ has infinite support), we define $\chi_E = \prod_{e \in E}{h_{l(e)}{(X_e)}}$.
We say that such a multi-set of hyperedges $E$ is proper if it contains no duplicate hyperedges, i.e. it is a set (though the labels on the hyperedges can be arbitrary non-negative integers). Otherwise, we say that $E$ is improper.
\end{definition}
\begin{remark}
The Fourier characters are $\{\chi_{E}: E \text{ is proper}\}$. For improper $E$, $\chi_{E}$ can be decomposed as a linear combination of $\chi_{E_j}$ where each $E_j$ is proper. We allow improper $E$ because it is sometimes more convenient to have improper $E$ in the middle of the analysis and then do this decomposition at the end.
\end{remark}
\begin{definition}[Ribbons]\label{def: ribbons}
A ribbon $R$ is a tuple $(H_R,A_R,B_R)$ where $H_R$ is a multi-graph (*or multi-hypergraph with labeled edges in the general case) whose vertices are indices of the input and $A_R$ and $B_R$ are matrix indices such that $V(A_R) \subseteq V(H_R)$ and $V(B_R) \subseteq V(H_R)$. We make the following definitions about ribbons:
\begin{enumerate}
\item We define $V(R) = V(H_R)$ and $E(R) = E(H_R)$
\item We define $\chi_R = \chi_{E(R)}$.
\item We define $M_R$ to be the matrix such that $(M_R)_{{A_R}{B_R}} = \chi_R$ and $M_{AB} = 0$ whenever $A \neq A_R$ or $B \neq B_R$.
\end{enumerate}
We say that $R$ is a proper ribbon if $H_R$ contains no isolated vertices outside of $A_R \cup B_R$ and $E(R)$ is proper. If there is an isolated vertex in $(V(R) \setminus A_R) \setminus B_R$ or $E(R)$ is improper then we say that $R$ is an improper ribbon.
\end{definition}
Proper ribbons are useful because they give an orthonormal basis for the space of matrix valued functions.
\begin{definition}[Inner products of matrix functions]
For a pair of real matrices $M_1,M_2$ of the same dimension, we write $\langle{M_1,M_2}\rangle = tr({M_1}{M_2}^T)$ (i.e. $\langle{M_1,M_2}\rangle$ is the entrywise dot product of $M_1$ and $M_2$). For a pair of matrix-valued functions $M_1, M_2$ (of the same dimensions), we define
\[
\langle{M_1,M_2}\rangle = E_{X}\left[\langle{M_1(X),M_2(X)}\rangle\right]
\]
\end{definition}
\begin{proposition}
If $R$ and $R'$ are two proper ribbons then $\langle{M_R,M_{R'}}\rangle = 1$ if $R = R'$ and is $0$ otherwise.
\end{proposition}
We have already seen examples of ribbons in earlier chapters, but we provide an example here for convenience.
For more examples, see \cite{AMP20}.
\begin{example}[Simplified Ribbon]
In \cref{fig: ribbon_shape}, consider the ribbon $R$ as shown. We have $A_R = (1, 3), B_R = (4), V(R) = \{1, 2, 3, 4\}, E_R = \{\{1, 2\}, \{3, 2\}, \{2, 4\}\}$. The Fourier character is $\chi_{E_R} = \chi_{1, 2}\chi_{3, 2}\chi_{2, 4}$. And finally, $M_R$ is a matrix with rows and columns indexed by tuples of length $|A_R| = 2$ and $|B_R| = 1$ respectively, with exactly one nonzero entry $M_R((1, 3), (4)) = \chi_{E_R}$. Succinctly, \[M_R =
\begin{blockarray}{rl@{}c@{}r}
& & \makebox[0pt]{column $(4)$} \\[-0.5ex]
& & \,\downarrow \\[-0.5ex]
\begin{block}{r(l@{}c@{}r)}
& \makebox[3.1em]{\Large $0$\bigstrut[t]} & \vdots &\makebox[4.2em]{\Large $0$} \\[-0.2ex]
\text{row }(1, 3) \rightarrow \mkern-9mu & \raisebox{0.5ex}{\makebox[3.2em][l]{\dotfill}} & \chi_{1, 2}\chi_{3, 2}\chi_{2, 4} & \raisebox{0.5ex}{\makebox[4.2em][r]{\dotfill}} \\[+0ex]
& \makebox[3.1em]{\Large $0$} & \vdots &\makebox[4.2em]{\bigstrut\Large $0$} \\
\end{block}
\end{blockarray}\]
\end{example}
\begin{figure}[!h]
\centering
\includegraphics[scale=.6, trim={0 5cm 2 5cm},clip]{machinery/images/ribbon_shape}
\caption{Example of a ribbon and a shape}
\label{fig: ribbon_shape}
\end{figure}
\subsection{Shapes}
In this subsection, we describe a basis for $S$-invariant matrix valued functions where each matrix in this basis can be described by a relatively small \emph{shape} $\alpha$. The fundamental idea behind shapes is that we keep the structure of the objects we are working with but leave the elements of the object unspecified.
\subsubsection{Simplified Index Shapes}
\begin{definition}[Simplified Index shapes]
With our simplifying assumptions, an index shape $U$ is a tuple of unspecified indices $(u_1,\cdots,u_{|U|})$. We make the following definitions about index shapes:
\begin{enumerate}
\item We define $V(U)$ to be the set of vertices $\{u_i: i \in [|U|]\}$. For brevity, we will often write $U$ instead of $V(U)$ when it is clear from context that we are referring to $U$ as a set of vertices rather than an index shape.
\item We define the weight of $U$ to be $w(U) = |U|$.
\item We take the automorphism group of $U$ to be $Aut(U) = S_{|U|}$ (the permutations of the elements of $U$)
\end{enumerate}
\end{definition}
\begin{definition}
We say that a matrix index $A = (a_1,\ldots,a_{|A|})$ has index shape $U = (u_1,\ldots,u_{|U|})$ if $|U| = |A|$. Note that in this case, if we take the map $\varphi: \{u_j: j \in [|U|]\} \rightarrow [n]$ where $\varphi(u_j) = a_j$ then $\varphi(U) = (\varphi(u_1),\ldots,\varphi(u_{|U|})) = (a_1,\ldots,a_{|A|}) = A$
\end{definition}
\begin{definition}
We say that index shapes $U = (u_1,\ldots,u_{|U|})$ and $V = (v_1,\ldots,v_{|V|})$ are equivalent (which we write as $U \equiv V$) if $|U| = |V|$. If $U \equiv V$ then we can set $U = V$ by setting $v_j = u_j$ for all $j \in [|U|]$.
\end{definition}
\begin{example}
The matrix index $A = \{4,6,1\}$ has shape $U = \{u_1,u_2,u_3\}$ which has weight $3$.
\end{example}
\subsubsection{General Index Shapes*}
In general, we define general index shapes in the same way that we defined general matrix indices (just with unspecified indices)
\begin{definition}[Index Shape Piece Definition]
We define a index shape piece $U_i = ((u_{i1},\ldots,u_{i|U_i|}), t_i, p_i)$ to be a tuple of indices $(u_{i1},\ldots,u_{i|A_i|})$ together with a type $t_i$ and a power $p_i$. We make the following definitions about index shape pieces:
\begin{enumerate}
\item We define $V(U_i)$ to be the set of vertices $\{(t_i,u_{ij}): j \in [|U_i|]\}$.
\item We define $w(U_i) = |U_i|log_{n}(n_{t_i})$
\item We take the automorphism group of $U_i$ to be $Aut(U_i) = S_{|U_i|}$
\end{enumerate}
\end{definition}
\begin{definition}[General Index Shape Definition]
We define an index shape $U = \{U_i\}$ to be a set of index shape pieces such that for all $i' \neq i$, either $t_{i'} \neq t_i$ or $p_{i'} \neq p_i$. We make the following definitions about index shapes:
\begin{enumerate}
\item We define $V(U)$ to be the set of vertices $\cup_{U_i \in U}{V(U_i)}$. For brevity, we will often write $U$ instead of $V(U)$ when it is clear from context that we are referring to $U$ as a set of vertices rather than an index shape.
\item We define $w(U)$ to be $w(U) = \sum_{U_i \in U}{w(U_i)}$
\item We take the automorphism group of $U$ to be $Aut(U) = \prod_{U_i \in U}{Aut(U_i)}$
\end{enumerate}
\end{definition}
\begin{remark}
For technical reasons, we want to ensure that if two index shapes $U$ and $U'$ have the same weight then $U$ and $U'$ have the same number of each type of vertex. To ensure this, we add an infinitesimal perturbation to each $n_i$ if necessary.
\end{remark}
\begin{definition}
We say that a matrix index $A$ has index shape $U$ if there is an assignment of values to the unspecified indices of $U$ which results in $A$. More precisely, we say that $A$ has index shape $U$ if there is a map $\varphi: \{u_{ij}\} \rightarrow \mathbb{N}$ such that if we define $\varphi(U_i)$ to be $\varphi(U_i) = ((\varphi(u_{i1}),\ldots,\varphi(u_{i|U_i|})),t_i,p_i)$ then $\varphi(U) = \{\varphi(U_i)\} = \{A_i\} = A$.
\end{definition}
\begin{definition}
If $U$ and $V$ are two index shapes, we say that $U$ is equivalent to $V$ (which we write as $U \equiv V$) if $U$ and $V$ have the same number of index shape pieces and we can order the index shape pieces of $U$ and $V$ so that writing $U = \{U_i\}$ and $V = \{V_i\}$ where $U_i = ((u_{i1},\ldots,u_{i|U_i|}), t_i, p_i)$ and $V_{i} = ((v_{i1},\ldots,v_{i|V_i|}), t'_i, p'_i)$, we have that for all $i$, $|V_i| = |U_i|$, $t'_i = t_i$, and $p'_i = p_i$. If $U \equiv V$ then we can set $U = V$ by setting $u_{ij} = v_{ij}$ for all $i$ and all $j \in [|U_i|]$.
\end{definition}
\subsubsection{Ribbon Shapes}
With these definitions, we are now ready to define shapes and the matrices associated to them.
\begin{definition}[Shapes]\label{def: shapes}
A ribbon shape $\alpha$ (which we call a shape for brevity) is a tuple $\alpha = (H_{\alpha},U_{\alpha},V_{\alpha})$ where $H_{\alpha}$ is a multi-graph (*or multi-hypergraph with labeled edges in the general case) whose vertices are unspecified distinct indices of the input (*whose type is specified in the general case) and $U_{\alpha}$ and $V_{\alpha}$ are index shapes such that $V(U_{\alpha}) \subseteq V(H_\alpha)$ and $V(V_{\alpha}) \subseteq V(H_\alpha)$. We make the following definitions about shapes:
\begin{enumerate}
\item We define $V(\alpha) = V(H_{\alpha})$ (note that $V(\alpha)$ and $V_{\alpha}$ are not the same thing) and we define $E(\alpha) = E(H_{\alpha})$.
\item We say that a shape $\alpha$ is proper if it contains no isolated vertices outside of $V(U_{\alpha}) \cup V(V_{\alpha})$, $E(\alpha)$ has no multiple edges/hyperedges and edges in $E(\alpha)$ do not have label $0$. If there is an isolated vertex in $V(\alpha) \setminus V(U_{\alpha}) \setminus V(V_{\alpha})$ or $E(\alpha)$ has a multiple edge/hyperedge then we say that $\alpha$ is an improper shape.
\end{enumerate}
Note: For brevity, we will often write $U_{\alpha}$ and $V_{\alpha}$ instead of $V(U_{\alpha})$ and $V(V_{\alpha})$ when it is clear from context that we are referring to $U_{\alpha}$ and $V_{\alpha}$ as sets of vertices rather than index shapes.
\end{definition}
\begin{definition}[Trivial shapes]
We say that a shape $\alpha$ is trivial if $V(\alpha) = V(U_{\alpha}) = V(V_{\alpha})$ and $E(\alpha) = \emptyset$. Otherwise, we say that $\alpha$ is non-trivial.
\end{definition}
\begin{remark}
Note that all trivial shapes can do is permute the order of the vertices in $V(U_{\alpha}) = V(V_{\alpha})$.
\end{remark}
\begin{definition}
Informally, we say that a ribbon $R$ has shape $\alpha$ if replacing the indices in $R$ with unspecified labels results in $\alpha$. Formally, we say that $R$ has shape $\alpha$ if there is an injective mapping $\varphi:V(\alpha) \rightarrow [n]$ (*or $[t_{max}] \times [n]$ in the general case) such that $\varphi(\alpha) = R$, i.e. $\varphi(H_{\alpha}) = H_R$, $\varphi(U_{\alpha}) = A_R$, and $\varphi(V_{\alpha}) = B_R$
\end{definition}
\begin{definition}
We say that two shapes $\alpha$ and $\beta$ are equivalent (which we write as $\alpha \equiv \beta$) if they are the same up to renaming their indices. More precisely, we say that $\alpha \equiv \beta$ if there is a bijective map $\pi: V(H_\alpha) \rightarrow V(H_\beta)$ such that $\pi(H_\alpha) = H_{\beta}$, $\pi(U_{\alpha}) = U_{\beta}$, and $\pi(V_{\alpha}) = V_{\beta}$.
\end{definition}
\begin{definition}
Given a shape $\alpha$ and matrix indices $A,B$ of shapes $U_\alpha$ and $V_\alpha$ respectively, we define $\mathcal{R}(\alpha,A,B)$ to be the set of ribbons $R$ such that $R$ \emph{has shape $\alpha$}, $A_R = A$, and $B_R = B$.
\end{definition}
\begin{definition}
For a shape $\alpha$, we define the matrix-valued function $M_\alpha$ to have entries $M_{\alpha}(A,B)$ given by
\[
(M_\alpha)_{A,B}(X) = \sum_{R \in \mathcal{R}(\alpha, A,B )} \chi_R(X)
\]
\end{definition}
We have seen examples of shapes in earlier chapters, but we provide one here for convenience.
For more examples, see \cite{AMP20}.
\begin{example}[Simplified Shape]
In \cref{fig: ribbon_shape}, consider the shape $\alpha$ as shown. We have $U_{\alpha} = (u_1, u_2), V_{\alpha} = (v_1), V(\alpha) = \{u_1, u_2, v_1, w_1\}$ and $E(\alpha) = \{\{u_1, w_1\}, \{u_2, w_1\}, \{w_1, v_1\}\}$. $M_{\alpha}$ is a matrix with rows and columns indexed by tuples of length $|U_{\alpha}| = 2$ and $|V_{\alpha}| = 1$ respectively. The nonzero entries will have rows and columns indexed by $(a_1, a_2)$ and $b_1$ respectively for all distinct $a_1, a_2, b_1$, with the corresponding entry being $M_{\alpha}((a_1, a_2), (b_1)) = \sum_{c_1 \in [n] \setminus \{a_1, a_2, b_1\}} \chi_{a_1, c_1}\chi_{a_2, c_1} \chi_{c_1, b_1}$. Here, the injective map $\varphi$ maps $u_1, u_2, w_1, v_1$ to $a_1, a_2, c_1, b_1$ respectively and we sum over all such maps. Succinctly, \[M_{\alpha} =
\begin{blockarray}{rl@{}c@{}r}
& & \makebox[0pt]{column $(c_1)$} \\[-0.5ex]
& & \,\downarrow \\[-0.5ex]
\begin{block}{r(l@{}c@{}r)}
& & \vdots & \\[-0.2ex]
\text{row }(a_1, a_2) \rightarrow \mkern-9mu & \raisebox{0.5ex}{\makebox[3.2em][l]{\dotfill}} & \sum_{c_1 \in [n] \setminus \{a_1, a_2, b_1\}} \chi_{a_1, c_1}\chi_{a_2, c_1} \chi_{c_1, b_1} & \raisebox{0.5ex}{\makebox[4.2em][r]{\dotfill}} \\[+.5ex]
& & \vdots & \\
\end{block}
\end{blockarray}\]
\end{example}
\begin{proposition}
The $M_\alpha$'s for proper shapes $\alpha$ are an orthogonal basis for the $S$-invariant functions.\footnote{
Because of orthogonality of the underlying Fourier characters, it is not hard to check that when $\alpha \neq \alpha'$ and $M_\alpha, M_{\alpha'}$ have the same dimensions, $\langle{M_\alpha, M_{\alpha'}}\rangle = 0$.}
\end{proposition}
\begin{remark}
Conceptually, one may think of forming an orthonormal basis for this space with the functions $M_\alpha / \sqrt{\langle{M_\alpha, M_\alpha}\rangle}$, but for technical reasons it is easiest to work with these functions without normalizing them to $1$.
By orthogonality and the fact that every Boolean function is a polynomial, any $S$-invariant matrix-valued function $\Lambda$ is expressible as
\[
\Lambda = \sum_{\alpha} \frac{\langle{\Lambda, M_\alpha}\rangle}{\langle{M_\alpha, M_\alpha}\rangle} \cdot M_\alpha
\]
\end{remark}
\subsection{Composing Ribbons and Shapes}
\begin{definition}[Composing Ribbons]
We say that ribbons $R_1$ and $R_2$ are composable if $B_{R_1} = A_{R_2}$. Note that this definition is not symmetric so we may have that $R_1$ and $R_2$ are composable but $R_2$ and $R_1$ are not composable.
We say that $R_1$ and $R_2$ are properly composable if we also have that $V(R_1) \cap V(R_2) = V(B_{R_1}) = V(A_{R_2})$ (there are no unexpected intersections between $R_1$ and $R_2$).
If $R_1$ and $R_2$ are composable ribbons then we define the composition of $R_1$ and $R_2$ to be the ribbon $R_1 \circ R_2$ such that
\begin{enumerate}
\item $A_{R_1 \circ R_2} = A_{R_1}$ and $B_{R_1 \circ R_2} = B_{R_2}$
\item $V(R_1 \circ R_2) = V(R_1) \cup V(R_2)$
\item $E(R_1 \circ R_2) = E(R_1) \cup E(R_2)$ (and thus $\chi_{R_1 \circ R_2} = \chi_{R_1}\chi_{R_2}$)
\end{enumerate}
We say that ribbons $R_1,\ldots,R_k$ are composable/properly composable if for all $j \in [k-1]$, $R_1 \circ \ldots \circ R_j$ and $R_{j+1}$ are composable/properly composable. If $R_1,\ldots,R_k$ are composable then we define $R_1 \circ \ldots \circ R_k$ to be
$R_1 \circ \ldots \circ R_k = (R_1 \circ \ldots \circ R_{k-1}) \circ R_k$
\end{definition}
\begin{proposition}
Ribbon composition is associative, i.e. if $R_1,R_2,R_3$ are composable/properly composable ribbons then $R_2, R_3$ are composable/properly composable, $R_1, (R_2 \circ R_3)$ are composable/properly composable, and $R_1 \circ (R_2 \circ R_3) = (R_1 \circ R_2) \circ R_3$
\end{proposition}
\begin{proposition}
If $R_1$ and $R_2$ are composable ribbons then $M_{R_1 \cup R_2} = M_{R_1}M_{R_2}$.
\end{proposition}
We have similar definitions for composing shapes.
\begin{definition}[Composing Shapes]
We say that shapes $\alpha$ and $\beta$ are composable if $U_{\beta} \equiv V_{\alpha}$. Note that this definition is not symmetric so we may have that $\alpha$ and $\beta$ are composable but $\beta$ and $\alpha$ are not composable.
If $\alpha$ and $\beta$ are composable shapes then we define the composition of $\alpha$ and $\beta$ to be the shape $\alpha \circ \beta$ such that
\begin{enumerate}
\item $U_{\alpha \circ \beta} = U_{\alpha}$ and $V_{\alpha \circ \beta} = V_{\beta}$
\item After setting $U_{\beta} = V_{\alpha}$, we take $V(\alpha \circ \beta) = V(\alpha) \cup V(\beta)$
\item $E(\alpha \circ \beta) = E(\alpha) \cup E(\beta)$
\end{enumerate}
We say that shapes $\alpha_1,\ldots,\alpha_k$ are composable if for all $j \in [k-1]$, $\alpha_1 \circ \ldots \circ \alpha_j$ and $\alpha_{j+1}$ are composable. If $\alpha_1,\ldots,\alpha_k$ are composable then we define the shape $\alpha_1 \circ \ldots \circ \alpha_k$ to be
$\alpha_1 \circ \ldots \circ \alpha_k = (\alpha_1 \circ \ldots \circ \alpha_{k-1}) \circ \alpha_k$
\end{definition}
\begin{proposition}
Shape composition is associative, i.e. if $\alpha_1,\alpha_2,\alpha_3$ are composable shapes then $\alpha_2, \alpha_3$ are composable, $\alpha_1, (\alpha_2 \circ \alpha_3)$ are composable, and $\alpha_1 \circ (\alpha_2 \circ \alpha_3) = (\alpha_1 \circ \alpha_2) \circ \alpha_3$
\end{proposition}
\begin{example}
\cref{fig: basic_shape_comp} illustrates an example of shape composition in the simplified case. Observe how the shapes $\sigma \circ \sigma'^T$ and $\sigma \circ \tau \circ \sigma'^T$ are obtained from the shapes $\sigma, \tau$ and $\sigma'^T$.
\end{example}
\begin{example}
\cref{fig: shape_comp} illustrates an example of shape composition in the general case. We have two types of vertices that we diagrammaticaly represent by squares and circles. Observe how the shapes $\sigma \circ \sigma'^T$ and $\sigma \circ \tau \circ \sigma'^T$ are obtained from the shapes $\sigma, \tau$ and $\sigma'^T$.
\end{example}
\begin{figure}[!h]
\centering
\includegraphics[scale=0.45, trim={4.5cm 2cm 0 2cm},clip]{machinery/images/basic_shape_comp}
\caption{Illustration of shape composition and decomposition in the simplified case.}
\label{fig: basic_shape_comp}
\end{figure}
\begin{figure}[!h]
\centering
\includegraphics[scale=0.38, trim={8cm 2cm 0 2cm},clip]{machinery/images/shape_comp}
\caption{Illustration of shape composition and decomposition in the general case.}
\label{fig: shape_comp}
\end{figure}
\subsection{Decomposition of Shapes into Left, Middle, and Right parts}
In this subsection, we describe how shapes can be decomposed into left, middle, and right parts based on the leftmost and rightmost \emph{minimum vertex separators}, which is a crucial idea for the analysis.
\begin{definition}[Paths]
A \emph{path} in a shape $\alpha$ is a sequence of vertices $v_1,\ldots,v_t$ such that $v_i, v_{i+1}$ are in some edge/hyperedge together.
A pair of paths is vertex-disjoint if the corresponding sequences of vertices are disjoint.
\end{definition}
\begin{definition}[Vertex separators]
Let $\alpha$ be a shape and let $U$ and $V$ be sets of vertices in $\alpha$. We say that a set of vertices $S \subseteq V(\alpha)$ is a \emph{vertex separator} of $U$ and $V$ if every path in $\alpha$ from $U$ to $V$ contains at least one vertex in $S$. Note that any vertex separator $S$ of $U$ and $V$ must contain all of the vertices in $U \cap V$.
As a special case, we say that $S$ is a vertex separator of $\alpha$ if $S$ is a vertex separator of $U_{\alpha}$ and $V_{\alpha}$
\end{definition}
We define the weight of a set of vertices $S \subseteq V(\alpha)$ in the same way that weight is defined for index shapes.
\begin{definition}[Simplified Weight]
When there is only one type of index, the weight of a set of vertices $S \subseteq V(\alpha)$ is simply $|S|$.
\end{definition}
\begin{definition}[General Weight*]
In general, given a set of vertices $S \subseteq V(\alpha)$, writing $S = \cup_{t}{S_t}$ where $S_t$ is the set of vertices of type $t$ in $S$, we define the weight of $S$ to be $w(S) = \sum_{t}{|S_t|log_{n}(n_t)}$
\end{definition}
\begin{remark}[*]
Again, if necessary, we add an infinitesimal perturbation to $n_1,n_2,\ldots,n_{t_{max}}$ so that if two separators $S$ and $S'$ have the same weight then $S$ and $S'$ have the same number of each type of vertex.
\end{remark}
\begin{definition}[Leftmost and rightmost minimum vertex separators]
The \emph{leftmost} minimum vertex separator is the vertex separator $S$ of minimum weight such that for every other minimum-weight vertex separator $S'$, $S$ is a separator of $U_\alpha$ and $S'$.
The \emph{rightmost} minimum vertex separator is the vertex separator $T$ of minimum weight such that for every other minimum-weight vertex separator $T'$, $T$ is a separator of $T'$ and $V_{\alpha}$
\end{definition}
The work \cite{BHKKMP16} showed that under the simplifying assumptions, leftmost and rightmost minimum vertex separators are well defined. For a general proof that leftmost and rightmost minimum vertex separators are well defined, see \cite{potechin2020machinery}.
We now have the following crucial idea. Every shape $\alpha$ can be decomposed into the composition of three composable shapes $\sigma,\tau,{\sigma'}^T$ based on the leftmost and rightmost minimum vertex separators $S,T$ of $\alpha$ together with orderings of $S$ and $T$.
\begin{definition}[Simplified Separators With Orderings]
Under our simplifying assumptions, given a set of vertices $S \subseteq V(\alpha)$ and an ordering $O_S = s_1,\ldots,s_{|S|}$ of the vertices of $S$, we define the index shape $(S, O_S)$ to be $(S, O_S) = (s_1,\ldots,s_{|S|})$.
\end{definition}
\begin{definition}[General Separators With Orderings*]
In the general case, we need to give an ordering for each type of vertex. Let $S \subseteq V(\alpha)$ be a subset of the vertices of $\alpha$ and write $S = \cup_{t}{S_t}$ where $S_t$ is the set of vertices in $S$ of type $t$. Given $O_S = \{O_t\}$ where $O_t = s_{t1},\ldots,s_{t|S_t|}$ is an ordering of the vertices of $S_t$, we define the index shape piece $(S_t, O_t)$ to be $(S_t, O_t) = ((s_{t1},\ldots,s_{t|S_t|}), t, 1)$ and we define the index shape $(S,O_S)$ to be $(S,O_S) = \{(S_t,O_t)\}$.
\end{definition}
\begin{proposition}
The number of possible orderings $O$ for $S$ is equal to $|Aut((S,O_S))|$
\end{proposition}
\begin{definition}[Shape transposes]
Given a shape $\alpha$, we define $\alpha^{T}$ to be the shape $\alpha$ with $U_{\alpha}$ and $V_{\alpha}$ swapped i.e. $U_{\sigma^{T}} = V_{\sigma}$ and $V_{\sigma^{T}} = U_{\sigma}$.
\end{definition}
\begin{definition}[Left, middle, and right parts]
Let $\alpha$ be a shape. Let $S$ and $T$ be the leftmost and rightmost minimal vertex separators of $\alpha$ together with orderings $O_S,O_T$ of $S$ and $T$.
\begin{itemize}
\item We define the \emph{left part} $\sigma_{\alpha}$ of $\alpha$ to be the shape such that
\begin{enumerate}
\item $H_{\sigma_{\alpha}}$ is the induced subgraph of $H_{\alpha}$ on all of the vertices of $\alpha$ reachable from $U_{\alpha}$ without passing through $S$ (note that $H_{\sigma_{\alpha}}$ includes the vertices of $S$) except that we remove any edges/hyperedges which are contained entirely within $S$.
\item $U_{\sigma_{\alpha}} = U_{\alpha}$ and $V_{\sigma_{\alpha}} = (S,O_S)$
\end{enumerate}
\item We define the \emph{right part} ${\sigma'}^T_{\alpha}$ of $\alpha$ to be the shape such that
\begin{enumerate}
\item $H_{{\sigma'}^T_{\alpha}}$ is the induced subgraph of $H_{\alpha}$ on all of the vertices of $\alpha$ reachable from $V_{\alpha}$ without passing through $T$ (note that $H_{{\sigma'}^T_{\alpha}}$ includes the vertices of $T$) except that we remove any edges/hyperedges which are contained entirely within $T$.
\item $V_{{\sigma'}^T_{\alpha}} = V_{\alpha}$ and $U_{{\sigma'}^T_{\alpha}} = (T,O_T)$
\end{enumerate}
\item We define the \emph{middle part} $\tau_{\alpha}$ of $\alpha$ to be the shape such that
\begin{enumerate}
\item $H_{\tau_{\alpha}}$ is the induced subgraph of $H_{\alpha}$ on all of the vertices of $\alpha$ which are not reachable from $U_{\alpha}$ and $V_{\alpha}$ without touching $S$ and $T$ (note that $H_{\tau_{\alpha}}$ includes the vertices of $S$ and $T$). $H_{\tau_{\alpha}}$ also includes the hyperedges entirely within $S$ and the hyperedges entirely within $T$.
\item $U_{\tau_{\alpha}} = (S,O_S)$ and $V_{\tau_{\alpha}} = (T,O_T)$
\end{enumerate}
\end{itemize}.
\end{definition}
\begin{example}
\cref{fig: basic_shape_comp} illustrates an example decomposition in the simplified case.
\begin{enumerate}
\item If we start with the shape $\alpha$ denoted as $\sigma \circ \sigma'^T$, observe that there is a unique minimum vertex separator, which consists of the middle vertex of degree $5$, i.e. the one that's not in either $U_{\sigma \circ \sigma'^T}$ or $V_{\sigma \circ \sigma'^T}$.
Then, $\alpha$ is decomposed in to the left part $\sigma$, a trivial middle part $\tau$ (not shown in this figure) which has $V(\tau) = \{u\}, U_{\tau} = V_{\tau} = (u), E(\tau) = \emptyset$, and the right part $\sigma'^T$.
\item If we start with the shape $\alpha$ denoted as $\sigma \circ \tau \circ \sigma'^T$, then the leftmost minimum vertex separator is the vertex of degree $4$ and the rightmost minimum vertex separator is the vertex of degree $5$. Then, $\alpha$ is decomposed into the left part $\sigma$, the middle part $\tau$ and the right part $\sigma'^T$, which are all shown in this figure.
\end{enumerate}
\end{example}
\begin{example}
\cref{fig: shape_comp} illustrates an example decomposition in the general case. We have two types of vertices that we diagrammatically represent by squares and circles. In this example, we assume that the set containing a single circle vertex has a lower weight compared to a set of two square vertices.
\begin{enumerate}
\item If we start with the shape $\sigma \circ \sigma'^T$, then it can be decomposed uniquely in to the composition of the left shape $\sigma$, the right shape $\sigma'^T$. In this case, the middle shape (not shown in this figure) is trivial.
\item If we start with the shape $\sigma \circ \tau \circ \sigma'^T$, then it can be decomposed uniquely into the composition of the left shape $\sigma$, the middle shape $\tau$ and the right shape $\sigma'^T$, which are all shown in this figure.
\end{enumerate}
\end{example}
\begin{proposition}
If $\sigma,\tau,{\sigma'}^{T}$ are the left, middle, and rights parts for $\alpha$ for given orderings $O_S,O_T$ of $S$ and $T$ then $\alpha = \sigma \circ \tau \circ {\sigma'}^T$.
\end{proposition}
\begin{remark}
One may ask which ordering(s) we should take of $S$ and $T$. The answer is that we will take all of the possible orderings of $S$ and $T$ simultaneously, giving equal weight to each.
\end{remark}
Based on this decomposition and the following claim, we make the following definitions for what it means for a shape to be a left, middle, or right part.
\begin{claim}[Proved in Section 6.1 in \cite{BHKKMP16}]
\footnote{The proof in \cite{BHKKMP16} only explicitly treats the case when the shapes $\alpha$ are graphs, but the proof easily generalizes to the case when the $\alpha$ are hypergraphs.}
\begin{itemize}
\item Every shape $\sigma$ which is the left part of some other shape $\alpha$ has that $V_\sigma$ is its left-most and right-most minimum-weight separator.
\item Every shape ${\sigma}^T$ which is the right part of some other shape $\alpha$ has that $U_{{\sigma}^T}$ is its left-most and right-most minimum-weight separator.
\item Every shape $\tau$ which is the middle part of some other shape $\alpha$ has $U_\tau$ as its left-most minimum size separator and $V_{\tau}$ as its right-most minimum-weight separator.
\end{itemize}
\end{claim}
\begin{definition}\label{leftmiddlerightshapedefinitions} \
\begin{enumerate}
\item We say that a shape $\sigma$ is a left shape if $\sigma$ is a proper shape, $V_{\sigma}$ is the left-most and right-most minimum-weight separator of $\sigma$, every vertex in $V(\sigma) \setminus V_{\sigma}$ is reachable from $U_{\sigma}$ without touching $V_{\sigma}$, and $\sigma$ has no hyperedges entirely within $V_{\sigma}$.
\item We say that a shape $\tau$ is a proper middle shape if $\tau$ is a proper shape, $U_{\tau}$ is the left-most minimum-weight separator of $\tau$, and $V_{\tau}$ is the right most minimum-weight separator of $\tau$. In the analysis, we will also need to consider improper middle shapes $\tau$ which may not be proper shapes and which may have smaller separators between $U_{\tau}$ and $V_{\tau}$.
\item We say that a shape ${\sigma}^{T}$ is a right shape if ${\sigma}^{T}$ is a proper shape, $U_{{\sigma}^{T}}$ is the left-most and right-most minimum-weight separator of ${\sigma}^{T}$, every vertex in $V({\sigma}^{T}) \setminus U_{{\sigma}^{T}}$ is reachable from $V_{{\sigma}^{T}}$ without touching $U_{{\sigma}^{T}}$, and ${\sigma}^{T}$ has no hyperedges entirely within $U_{{\sigma}^{T}}$.
\end{enumerate}
\end{definition}
\begin{proposition}
For all shapes $\sigma$, $\sigma$ is a left shape if and only if $\sigma^{T}$ is a right shape.
\end{proposition}
\begin{remark}
As the reader has likely guessed, throughout this section we use $\sigma$ to denote left parts and $\tau$ to denote middle parts. Instead of having a separate letter for right parts, we express right parts as the transpose of a left part.
\end{remark}
\subsection{Coefficient matrices}\label{fullcoefficientmatrixsubsection}
We will have that $\Lambda = \sum_{\alpha}{\lambda_{\alpha}M_{\alpha}}$. To analyze $\Lambda$, it is extremely useful to express these coefficients in terms of matrices. To do this, we will need a few more definitions. We start by defining the sets of index shapes that can appear when analyzing $\Lambda$.
\begin{definition}
Given a moment matrix $\Lambda$, we define the following sets of index shapes.
\begin{enumerate}
\item We define $\mathcal{I}(\Lambda) = \{U: \exists \text{ matrix index } A: A \text{ is a row index of } \Lambda, A \text{ has shape } U\}$ to be the set of index shapes which describe row and column indices of $\Lambda$.
\item We define $w_{max}$ to be $w_{max} = \max{\{w(U):U \in \mathcal{I}(\Lambda)\}}$.
\item With our simplifying assumptions, we define $\mathcal{I}_{mid}$ to be $\mathcal{I}_{mid} = \{U: |U| \leq w_{max}\}$
\item[3*.] In general, we define $\mathcal{I}_{mid}$ to be $\mathcal{I}_{mid} = \{U: w(U) \leq w_{max}, \forall U_i \in U, p_i = 1\}$
\end{enumerate}
\end{definition}
We also need to define the sets of shapes which can appear when analyzing $\Lambda$.
\begin{definition}[Truncation Parameters]
Given a moment matrix $\Lambda = \sum_{\alpha}{\lambda_{\alpha}M_{\alpha}}$, we define $D_V,D_E$ to be the smallest natural numbers such that for all shapes $\alpha$ such that $\lambda_{\alpha} \neq 0$, decomposing $\alpha$ as $\alpha = \sigma \circ \tau \circ {\sigma'}^T$,
\begin{enumerate}
\item $|V(\sigma)| \leq D_V$, $|V(\tau)| \leq D_V$, and $|V(\sigma')| \leq D_V$.
\item[2.*] For all edges $e \in E(\sigma) \cup E(\tau) \cup E(\sigma')$, $l_e \leq D_E$.
\end{enumerate}
\end{definition}
\begin{remark}
Under our simplifying assumptions, all edges have label $1$ so we will take $D_E = 1$ and ignore conditions involving $D_E$.
\end{remark}
\begin{definition}
Given a moment matrix $\Lambda$, we define the following sets of shapes:
\begin{enumerate}
\item $\mathcal{L} = \{\sigma: \sigma \text{ is a left shape}, U_{\sigma} \in \mathcal{I}(\Lambda), V_{\sigma} \in \mathcal{I}_{mid}, |V(\sigma)| \leq D_V, \forall e \in E(\sigma), l_e \leq D_E\}$
\item Given $V \in \mathcal{I}_{mid}$, we define $\mathcal{L}_V = \{\sigma \in \mathcal{L}: V_{\sigma} \equiv V\}$
\item Given $U \in \mathcal{I}_{mid}$, we define $\mathcal{M}_U = \{\tau: \tau \text{ is a non-trivial proper middle shape}, U_{\tau} \equiv V_{\tau} \equiv U,
|V(\tau)| \leq D_V, \forall e \in E(\tau), l_e \leq D_E\}$
\end{enumerate}
\end{definition}
\begin{definition}
Given a moment matrix $\Lambda$, we define a $\Lambda$-coefficient matrix (which we call a coefficient matrix for brevity) to be a matrix whose rows and columns are indexed by left shapes $\sigma,\sigma' \in \mathcal{L}$.
We say that a coefficient matrix $H$ is SOS-symmetric if $H(\sigma,\sigma')$ is invariant under permuting the vertices of $U_{\sigma}$ and permuting the vertices of $U_{\sigma'}$ (*more precisely, for the general case we permute the vertices within each index shape piece of $U_{\sigma}$ and permute the vertices within each index shape piece of $U_{\sigma'}$).
\end{definition}
\begin{definition}
Given a shape $\tau$, we say that a coefficient matrix $H$ is a $\tau$-coefficient matrix if $H(\sigma,\sigma') = 0$ whenever $V_{\sigma} \not\equiv U_{\tau}$ or $V_{\tau} \not\equiv U_{{\sigma'}^T}$.
\end{definition}
\begin{definition}
Given an index shape $U$, we define $Id_{U}$ to be the shape with $U_{Id_{U}} = V_{Id_{U}} = U$, no other vertices, and no edges.
\end{definition}
Given a shape $\tau$ and a $\tau$-coefficient matrix $H$, for convenience, we create a different matrix-valued functions $M^{fact}_{\tau}(H)$ as follows.
\begin{definition}
Given a shape $\tau$ and a $\tau$-coefficient matrix $H$, define
\[
M^{fact}_{\tau}(H) = \sum_{\sigma \in \mathcal{L}_{U_{\tau}},\sigma' \in \mathcal{L}_{V_{\tau}}}{H(\sigma,\sigma')M_{\sigma}M_{\tau}M_{\sigma'}^T}
\]
\end{definition}
Given a matrix-valued function $\Lambda$, we can associate coefficient matrices to $\Lambda$ as follows:
\begin{definition}
Given a matrix-valued function $\Lambda = \sum_{\alpha: \alpha \text{ is proper}}{\lambda_{\alpha}M_{\alpha}}$,
\begin{enumerate}
\item For each index shape $U \in \mathcal{I}_{mid}$ and every $\sigma,\sigma' \in \mathcal{L}_{U}$, we take $H_{Id_U}(\sigma,\sigma') = \frac{1}{|Aut(U)|}\lambda_{\sigma \circ {\sigma'}^T}$
\item For each $U \in \mathcal{I}_{mid}$, $\tau \in \mathcal{M}_U$ and $\sigma, \sigma' \in \mathcal{L}_{U}$, we take
$H_{\tau}(\sigma,\sigma') = \frac{1}{|Aut(U_{\tau})|\cdot|Aut(V_{\tau})|}\lambda_{\sigma \circ \tau \circ {\sigma'}^T}$
\end{enumerate}
\end{definition}
\subsection{The $-\gamma,-\gamma$ operation and qualitative theorem statement}
In the intersection term analysis, we will need to further decompose left shapes $\sigma$ as $\sigma = \sigma_2 \circ \gamma$ where $\sigma_2$ and $\gamma$ are themselves left shapes. Accordingly, we make the following definitions
\begin{definition} Given a moment matrix $\Lambda$, we define the following sets of left shapes:
\begin{enumerate}
\item $\Gamma = \{\gamma: \gamma \text{ is a non-trivial left shape}, U_{\gamma}, V_{\gamma} \in \mathcal{I}_{mid}, |V(\gamma)| \leq D_V, \forall e \in E(\gamma), l_e \leq D_E\}$
\item Given $U,V \in \mathcal{I}_{mid}$ such that $w(U) > w(V)$, define $\Gamma_{U,V} = \{\gamma \in \Gamma: U_{\gamma} \equiv U, V_{\gamma} \equiv V\}$.
\item Given $U \in \mathcal{I}_{mid}$, define $\Gamma_{U,*} = \{\gamma \in \Gamma: U_{\gamma} \equiv U\}$
\item Given $V \in \mathcal{I}_{mid}$, define $\Gamma_{*,V} = \{\gamma \in \Gamma: V_{\gamma} \equiv V\}$
\end{enumerate}
\begin{remark}
Under our simplifying assumptions, $\Gamma$ is the same as $\mathcal{L}$ except that $\Gamma$ excludes the trivial shapes. In general, while $\mathcal{L}$ requires that $U_{\sigma} \in \mathcal{I}(\Lambda)$, $\Gamma$ requires that $U_{\gamma} \in \mathcal{I}_{mid}$. Note that $\mathcal{I}(\Lambda)$ and $\mathcal{I}_{mid}$ may be incomparable because
\begin{enumerate}
\item There may be index shapes $U \in \mathcal{I}_{mid}$ such that no matrix index of $\Lambda$ has shape $U$.
\item All index shape pieces $U_i$ for index shapes $U \in \mathcal{I}_{mid}$ must have $p_i = 1$ while this is not the case for $\mathcal{I}(\Lambda)$.
\end{enumerate}
\end{remark}
\end{definition}
We now state the theorem qualitatively after giving one more definition.
\begin{definition}
Given a shape $\tau$, left shapes $\gamma \in {\Gamma}_{*,U_{\tau}}$ and $\gamma' \in {\Gamma}_{*,V_{\tau}}$, and a $\tau$-coefficient matrix $H$, define $H^{-\gamma,\gamma'}$ to be the $(\gamma \circ \tau \circ {\gamma'}^T)$-coefficient matrix with entries
\begin{enumerate}
\item $H^{-\gamma,\gamma'}(\sigma,\sigma') = H(\sigma \circ \gamma,\sigma' \circ \gamma')$ if $|V(\sigma \circ \gamma)| \leq D_V$ and $|V(\sigma' \circ \gamma')| \leq D_V$.
\item $H^{-\gamma,\gamma'}(\sigma,\sigma') = 0$ if $|V(\sigma \circ \gamma)| > D_V$ or $|V(\sigma' \circ \gamma')| > D_V$.
\end{enumerate}
\end{definition}
\begin{remark}
For the theorem, we will only need the case when $\gamma' = \gamma$
\end{remark}
The qualitative theorem statement is as follows:
\begin{theorem}\label{thm:mainqualitative}
Let $\Lambda = \sum_{U \in \mathcal{I}_{mid}}{M^{orth}_{Id_U}(H_{Id_U})} + \sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_U}{M^{orth}_{\tau}(H_{\tau})}}$ be an SOS-symmetric matrix valued function.
There exist functions $f(\tau)$ and $f(\gamma)$ depending on $n$ and other parameters such that if the following conditions hold:
\begin{enumerate}
\item For all $U \in \mathcal{I}_{mid}$, $H_{Id_{U}} \succeq 0$
\item For all $U \in \mathcal{I}_{mid}$ and all $\tau \in \mathcal{M}_{U}$,
\[
\left[ {\begin{array}{cc}
H_{Id_{U}} & f(\tau)H_{\tau} \\
f(\tau)H^T_{\tau} & H_{Id_{U}}
\end{array}} \right] \succeq 0
\]
\item For all $U,V \in \mathcal{I}_{mid}$ where $w(U) > w(V)$ and all $\gamma \in \Gamma_{U,V}$, $H^{-\gamma,\gamma}_{Id_{V}} \preceq f(\gamma)H_{Id_{U}}$
\end{enumerate}
then with high probability $\Lambda \succeq 0$
\end{theorem}
\begin{remark}
Roughly speaking, conditions 1 and 2 give us an approximate PSD decomposition for the moment matrix $M$. Condition 3 comes from the intersection term analysis, which is the most technically intensive part of the proof.
\end{remark}
\begin{remark}
As we will demonstrate in this work, the machinery works well when the coefficients $\lambda_{\alpha}$ has a polynomial decay for each vertex or edge in the shape. In many settings, this can be done quite easily by adding noise to the distribution, such as resampling part of the input, or by lowering the parameters slightly, such as $m \le n^{k/4 - \varepsilon}$ instead of $m \le n^{k/4}$.
\end{remark}
\subsubsection{Choice of functions $f(\tau)$ and $f(\gamma)$ in the simplified case}
We will describe some intuition for the functions $f(\tau), f(\gamma)$. For simplicity, consider the simplified case.
In a rough sense, $f(\tau)$ measures the blow-up in the norm by using $M_{\tau}$ instead of $M_{Id_U}$ in the corresponding term of the Fourier decomposition. So we choose $f(\tau)$ to be $\norm{M_{\tau}}$, upto lower order terms. Our second condition verifies that the coefficients that arise because of this $\tau$ (which are encoded in $H_{\tau}$) are sufficiently small to overpower this norm blowup.
The fact that $\norm{M_{\tau}}$ is equal to $\tilde{O}(n^{\frac{|V(\tau)|-|U_{\tau}|}{2}})$ has been shown in previous works \cite{BHKKMP16, AMP20}. So, we choose $f(\tau)$ to be $\tilde{O}(n^{\frac{|V(\tau)|-|U_{\tau}|}{2}})$ where the problem instance is on $G_{n, 1/2}$. For problems with Gaussian or other inputs, similar forms of $f(\tau)$ can be used, which have been shown formally in the work of \cite{AMP20}. When we state the main theorem in general, we use a single $f(\tau)$ that incorporates all of these settings.
$f(\gamma)$ is a bit trickier to describe. In the machinery analysis, we roughly collect intersection terms from the approximate PSD decomposition and charge them to shapes of the form $\sigma \circ \gamma \circ \gamma^T \circ \sigma'^T$. Using the same idea as the previous step, we charge these to shapes with trivial middle shapes. Roughly, $f(\gamma)$ for a fixed $\gamma$ upper bounds the blowup from the norms of the original shape as compared to the new intersection shape. And the third condition argues that the the original coefficients are sufficiently small to compensate for these blowups.
For problems on $G_{n, 1/2}$, we set $f(\gamma) = \tilde{O}(n^{|V(\gamma) \setminus U_{\gamma}|})$. For problems with Gaussian inputs, we choose essentially the same function, but they fall under the umbrella of generalized graph matrices, where $V(\gamma)$ and $U_{\gamma}$ are defined accordingly. Indeed, in the main theorem, we encompass both these settings with a single choice of $f(\gamma)$.
\subsection{Quantitative theorem statement}\label{quantitativetheoremstatementsection}
To state the theorem quantitatively, we will need a few more things. First, the conditions of the theorem will involve functions $B_{norm}(\alpha)$, $B(\gamma)$, $N(\gamma)$, and $c(\alpha)$. Roughly speaking, these functions will be used as follows in the analysis:
\begin{enumerate}
\item $B_{norm}(\alpha)$ will bound the norms of the matrices $M_{\alpha}$
\item $B(\gamma)$ and $N(\gamma)$ will help us bound the intersection terms.
\item $c(\alpha)$ will help us sum over the possible $\gamma$ and $\tau$.
\end{enumerate}
Second, for technical reasons it turns out that comparing $H^{-\gamma,\gamma}_{Id_{V_{\gamma}}}$ to $H_{Id_{U_{\gamma}}}$ doesn't quite work. Instead, we compare $H^{-\gamma,\gamma}_{Id_{V_{\gamma}}}$ to a matrix $H'_{\gamma}$ of our choice where $H'_{\gamma}$ is very close to $H_{Id_{U_{\gamma}}}$ ($H'_{\gamma}$ will be the same as $H_{Id_{U_{\gamma}}}$ up to truncation error).
\begin{definition}
Given a function $B_{norm}(\alpha)$, we define the distance $d_{\tau}(H_{\tau},H'_{\tau})$ between two $\tau$-coefficient matrices $H_{\tau}$ and $H'_{\tau}$ to be
\[
d_{\tau}(H_{\tau},H'_{\tau}) = \sum_{\sigma \in \mathcal{L}_{U_{\tau}},\sigma' \in \mathcal{L}_{V_{\tau}}}{|H'_{\tau}(\sigma,\sigma') - H_{\tau}(\sigma,\sigma')|B_{norm}(\sigma)B_{norm}(\tau)B_{norm}(\sigma')}
\]
\end{definition}
Third, we need an SOS-symmetric analogue of the identity matrix.
\begin{definition}
We define $Id_{Sym}$ to be the matrix such that
\begin{enumerate}
\item The rows and columns of $Id_{Sym}$ are indexed by the matrix indices $A,B$ whose index shape is in $\mathcal{I}(\Lambda)$.
\item $Id_{Sym}(A,B) = 1$ if $p_A = p_B$ and $Id_{Sym}(A, B) = 0$ if $p_A \neq p_B$.
\end{enumerate}
\end{definition}
\begin{proposition}
If $M$ has SOS-symmetry and the rows and columns of $Id_{Sym}$ are indexed by matrix indices $A,B$ whose index shape is in $\mathcal{I}(\Lambda)$ then $M \preceq \norm{M}Id_{Sym}$
\end{proposition}
\begin{corollary}\label{distanceboundingcorollary}
For all $\tau$ and all SOS-symmetric $\tau$-coefficient matrices $H_{\tau}$ and $H'_{\tau}$,
\[
M^{fact}_{\tau}(H'_{\tau}) + M^{fact}_{{\tau}^T}(H'_{{\tau}^T}) - M^{fact}_{\tau}(H_{\tau}) - M^{fact}_{{\tau}^T}(H_{{\tau}^T}) \preceq 2d_{\tau}(H_{\tau},H'_{\tau})Id_{Sym}
\]
Note that if $\tau$, $H_{\tau}$ and $H'_{\tau}$ are all symmetric then
\[
M^{fact}_{\tau}(H'_{\tau}) - M^{fact}_{\tau}(H_{\tau}) \preceq d_{\tau}(H_{\tau},H'_{\tau})Id_{Sym}
\]
\end{corollary}
Finally, we need a few more definitions about shapes $\alpha$.
\begin{definition}[$\mathcal{M}'$]
We define $\mathcal{M}'$ to be the set of all shapes $\alpha$ such that
\begin{enumerate}
\item[1.] $|V(\alpha)| \leq 3D_V$
\item[2.*] $\forall e \in E(\alpha), l_e \leq D_E$
\item[3.*] All edges $e \in E(\alpha)$ have multiplicity at most $3D_V$.
\end{enumerate}
\end{definition}
\begin{definition}[$S_{\alpha}$]
Given a shape $\alpha$, define $S_{\alpha}$ to be the leftmost minimum vertex separator of $\alpha$
\end{definition}
\begin{definition}[$I_{\alpha}$]
Given a shape $\alpha$, define $I_{\alpha}$ to be the set of vertices in $V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})$ which are isolated.
\end{definition}
We can now state the main theorem.
\begin{theorem}\label{simplifiedmaintheorem}
Given the moment matrix $\Lambda = \sum_{\alpha}{\lambda_{\alpha}M_{\alpha}}$,
for all $\varepsilon > 0$, if we take
\begin{enumerate}
\item $q = 3\left\lceil{{D_V}ln(n) + \frac{ln(\frac{1}{\varepsilon})}{3} + {D_V}ln(5) + 3{D^2_V}ln(2)}\right\rceil$
\item $B_{vertex} = 6{D_V}\sqrt[4]{2eq}$
\item $B_{norm}(\alpha) = {B_{vertex}^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}}n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha})}{2}}$
\item $B(\gamma) = B_{vertex}^{|V(\gamma) \setminus U_{\gamma}| + |V(\gamma) \setminus V_{\gamma}|}n^{\frac{w(V(\gamma) \setminus U_{\gamma})}{2}}$
\item $N(\gamma) = (3D_V)^{2|V(\gamma) \setminus V_{\gamma}| + |V(\gamma) \setminus U_{\gamma}|}$
\item $c(\alpha) = 100(3D_V)^{|U_{\alpha} \setminus V_{\alpha}| + |V_{\alpha} \setminus U_{\alpha}| + 2|E(\alpha)|}2^{|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})|}$
\end{enumerate}
and we have SOS-symmetric coefficient matrices $\{H'_{\gamma}: \gamma \in \Gamma\}$ such that the following conditions hold:
\begin{enumerate}
\item For all $U \in \mathcal{I}_{mid}$, $H_{Id_{U}} \succeq 0$
\item For all $U \in \mathcal{I}_{mid}$ and $\tau \in \mathcal{M}_U$,
\[
\left[ {\begin{array}{cc}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_{U}} & B_{norm}(\tau)H_{\tau} \\
B_{norm}(\tau)H^T_{\tau} & \frac{1}{|Aut(U)|c(\tau)}H_{Id_{U}}
\end{array}} \right] \succeq 0
\]
\item For all $U,V \in \mathcal{I}_{mid}$ where $w(U) > w(V)$ and all $\gamma \in \Gamma_{U,V}$,
\[
c(\gamma)^2{N(\gamma)}^2{B(\gamma)^2}H^{-\gamma,\gamma}_{Id_{V}} \preceq H'_{\gamma}
\]
\end{enumerate}
then with probability at least $1 - \varepsilon$,
\[
\Lambda \succeq \frac{1}{2}\left(\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}}\right) - 3\left(\sum_{U \in \mathcal{I}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\]
If it is also true that whenever $\norm{M_{\alpha}} \leq B_{norm}(\alpha)$ for all $\alpha \in \mathcal{M}'$,
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq 6\left(\sum_{U \in \mathcal{I}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\]
then with probability at least $1 - \varepsilon$, $\Lambda \succeq 0$.
\end{theorem}
\subsubsection{General Main Theorem}\label{generalmaintheoremstatementsection}
Before stating the general main theorem, we need to modify a few definitions for $\alpha$ and give a few definitions for $\Omega$
\begin{definition}[$S_{\alpha,min}$ and $S_{\alpha,max}$]
Given a shape $\alpha \in \mathcal{M}'$, define $S_{\alpha,min}$ to be the leftmost minimum vertex separator of $\alpha$ if all edges with multiplicity at least $2$ are deleted and define $S_{\alpha,max}$ to be the leftmost minimum vertex separator of $\alpha$ if all edges with multiplicity at least $2$ are present.
\end{definition}
\begin{definition}[General $I_{\alpha}$]
Given a shape $\alpha$, define $I_{\alpha}$ to be the set of vertices in $V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})$ such that all edges incident with that vertex have multplicity at least $2$.
\end{definition}
\begin{definition}[$B_{\Omega}$]
We take $B_{\Omega}(j)$ to be a non-decreasing function such that for all $j \in \mathbb{N}$, $E_{\Omega}[x^{j}] \leq B_{\Omega}(j)^{j}$
\end{definition}
\begin{definition}[$h^{+}_j$]
For all $j$, we define $h^{+}_j$ to be the polynomial $h_j$ where we make all of the coefficients have positive sign.
\end{definition}
\begin{lemma}
If $\Omega = N(0,1)$ then we can take $B_{\Omega}(j) = \sqrt{j}$ and we have that
\[
h^{+}_j(x) \leq \frac{1}{\sqrt{j!}}(x^2 + j)^{\frac{j}{2}} \leq \left(\frac{e}{j}(x^2 + j)\right)^{\frac{j}{2}}
\]
\end{lemma}
For a proof, see \cite[Lemma 8.15]{AMP20}.
\begin{theorem}\label{generalmaintheorem}
Given the moment matrix $\Lambda = \sum_{\alpha}{\lambda_{\alpha}M_{\alpha}}$,
for all $\varepsilon > 0$, if we take
\begin{enumerate}
\item $q = \left\lceil{3{D_V}ln(n) + ln(\frac{1}{\varepsilon}) + {(3D_V)^k}ln(D_E + 1) + 3{D_V}ln(5)}\right\rceil$
\item $B_{vertex} = 6q{D_V}$
\item $B_{edge}(e) = 2h^{+}_{l_e}(B_{\Omega}(6{D_V}D_E))
\max_{j \in [0,3{D_V}D_E]}{\left\{\left(h^{+}_{j}(B_{\Omega}(2qj))\right)^{\frac{l_e}{\max{\{j,l_e\}}}}\right\}}$
As a special case, if $\Omega = N(0,1)$ then we can take $B_{edge}(e) = \left(400{D^2_V}{D^2_E}q\right)^{l_e}$
\item $B_{norm}(\alpha) =
2e{B_{vertex}^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}}\left(\prod_{e \in E(\alpha)}{B_{edge}(e)}\right)n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha,min})}{2}}$
\item $B(\gamma) = B_{vertex}^{|V(\gamma) \setminus U_{\gamma}| + |V(\gamma) \setminus V_{\gamma}|}\left(\prod_{e \in E(\gamma)}{B_{edge}(e)}\right)n^{\frac{w(V(\gamma) \setminus U_{\gamma})}{2}}$
\item $N(\gamma) = (3D_V)^{2|V(\gamma) \setminus V_{\gamma}| + |V(\gamma) \setminus U_{\gamma}|}$
\item $c(\alpha) = 100(3{t_{max}}D_V)^{|U_{\alpha} \setminus V_{\alpha}| + |V_{\alpha} \setminus U_{\alpha}| + k|E(\alpha)|}(2t_{max})^{|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})|}$
\end{enumerate}
and we have SOS-symmetric coefficient matrices $\{H'_{\gamma}: \gamma \in \Gamma\}$ such that the following conditions hold:
\begin{enumerate}
\item For all $U \in \mathcal{I}_{mid}$, $H_{Id_{U}} \succeq 0$
\item For all $U \in \mathcal{I}_{mid}$ and $\tau \in \mathcal{M}_U$,
\[
\left[ {\begin{array}{cc}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_{U}} & B_{norm}(\tau)H_{\tau} \\
B_{norm}(\tau)H^T_{\tau} & \frac{1}{|Aut(U)|c(\tau)}H_{Id_{U}}
\end{array}} \right] \succeq 0
\]
\item For all $U,V \in \mathcal{I}_{mid}$ where $w(U) > w(V)$ and all $\gamma \in \Gamma_{U,V}$,
\[
c(\gamma)^2{N(\gamma)}^2{B(\gamma)^2}H^{-\gamma,\gamma}_{Id_{V}} \preceq H'_{\gamma}
\]
\end{enumerate}
then with probability at least $1 - \varepsilon$,
\[
\Lambda \succeq \frac{1}{2}\left(\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}}\right) - 3\left(\sum_{U \in \mathcal{I}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\]
If it is also true that whenever $\norm{M_{\alpha}} \leq B_{norm}(\alpha)$ for all $\alpha \in \mathcal{M}'$,
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq 6\left(\sum_{U \in {\mathcal I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\]
then with probability at least $1 - \varepsilon$, $\Lambda \succeq 0$.
\end{theorem}
The full proof of the main theorems can be found in \cite{potechin2020machinery}. In this work, we will apply the machinery to prove our main SoS lower bounds.
\subsection{Choosing $H'_{\gamma}$ and Truncation Error}\label{sec: choosing_hgamma}
A canonical choice for $H'_{\gamma}$ is to take
\begin{enumerate}
\item $H'_{\gamma}(\sigma,\sigma') = H_{Id_U}(\sigma, \sigma')$ whenever $|V(\sigma \circ \gamma)| \leq D_V$ and $|V(\sigma' \circ \gamma)| \leq D_V$.
\item $H'_{\gamma}(\sigma,\sigma') = 0$ whenever $|V(\sigma \circ \gamma)| > D_V$ or $|V(\sigma' \circ \gamma)| > D_V$.
\end{enumerate}
With this choice, the truncation error is
\[
d_{Id_{U_{\gamma}}}(H_{Id_{U_{\gamma}}},H'_{\gamma}) = \sum_{\sigma,\sigma' \in \mathcal{L}_{U_{\gamma}}: V(\sigma) \leq D_V, V(\sigma') \leq D_V,
\atop |V(\sigma \circ \gamma)| > D_V \text{ or } |V(\sigma' \circ \gamma)| > D_V}{B_{norm}(\sigma)B_{norm}(\sigma')H_{Id_{U_{\gamma}}}(\sigma,\sigma')}
\]
\end{comment}
\subsection{Middle shape bounds}
\begin{lemma}\label{lem: spca_charging}
Suppose $0 < A < \frac{1}{4}$ is a constant such that $\frac{\sqrt{\lambda}}{\sqrt{k}} \le d^{-A\varepsilon}$ and $\frac{1}{\sqrt{k}} \le d^{-2A}$. For all $m$ such that $m \le \frac{d^{1 - \varepsilon}}{\lambda^2}, m \le \frac{k^{2 - \varepsilon}}{\lambda^2}$, for all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, suppose $deg^{\tau}(i)$ is even for all $i \in V(\tau) \setminus U_{\tau} \setminus V_{\tau}$, then
\[\sqrt{d}^{|\tau|_1 - |U_{\tau}|_1}\sqrt{m}^{|\tau|_2 - |U_{\tau}|_2}S(\tau) \le \prod_{j \in V_2(\tau) \setminus U_{\tau} \setminus V_{\tau}} (deg^{\tau}(j) - 1)!!\cdot \frac{1}{d^{A\varepsilon\sum_{e \in E(\tau)} l_e}}\]
\end{lemma}
\begin{proof}
Let $r_1 = |\tau|_1 - |U_{\tau}|_1, r_2 = |\tau|_2 - |U_{\tau}|_2$. Since $\Delta \le 1$, it suffices to prove
\[E := \sqrt{d}^{r_1}\sqrt{m}^{r_2}\left(\frac{k}{d}\right)^{r_1} \left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{\sum_{e \in E(\tau)} l_e} \le \frac{1}{d^{A\varepsilon\sum_{e \in E(\tau)} l_e}}\]
We will need the following claim.
\begin{claim}
$\sum_{e \in E(\tau)} l_e \ge 2 \max(r_1, r_2)$.
\end{claim}
\begin{proof}
We will first prove $\sum_{e \in E(\tau)} l_e \ge 2 r_1$. For any vertex $i \in V_1(\tau) \setminus U_{\tau} \setminus V_{\tau}$, $deg^{\tau}(i)$ is even and is not $0$, hence, $deg^{\tau}(i) \ge 2$. Any vertex $i \in U_{\tau} \setminus V_{\tau}$ cannot have $deg^{\tau}(i) = 0$ otherwise $U_{\tau} \setminus\{i\}$ is a vertex separator of strictly smaller weight than $U_{\tau}$, which is not possible, hence, $deg^{\tau}(i) \ge 1$. Similarly, for $i \in V_{\tau} \setminus U_{\tau}$, $deg^{\tau}(i) \ge 1$. Also, since $H_{\tau}$ is bipartite, we have $\sum_{i \in V_1(\tau)} deg^{\tau}(i) = \sum_{j \in V_2(\tau)} deg^{\tau}(j)= \sum_{e \in E(\tau)} l_e$. Consider
\begin{align*}
\sum_{e \in E(\tau)} l_e &= \sum_{i \in V_1(\tau)} deg^{\tau}(i)\\
&\ge \sum_{i \in V_1(\tau) \setminus U_{\tau} \setminus V_{\tau}} deg^{\tau}(i) + \sum_{i \in (U_{\tau})_1 \setminus V_{\tau}} deg^{\tau}(i) + \sum_{i \in (V_{\tau})_1 \setminus U_{\tau}} deg^{\tau}(i)\\
&\ge 2|V_1(\tau) \setminus U_{\tau} \setminus V_{\tau}| + |(U_{\tau})_1 \setminus V_{\tau}| + |(V_{\tau})_1 \setminus U_{\tau}|\\
&= 2r_1
\end{align*}
We can similarly prove $\sum_{e \in E(\tau)} l_e \ge 2 r_2$
\end{proof}
To illustrate the main idea, we will start by proving the weaker bound $E \le 1$. Observe that our assumptions imply $m \le \frac{d}{\lambda^2}, m \le \frac{k^2}{\lambda^2}$ and also, using the fact $\frac{\sqrt{\lambda}}{\sqrt{k}} \le d^{-A\varepsilon} \le 1$, we have $E \le \sqrt{d}^{r_1}\sqrt{m}^{r_2}\left(\frac{k}{d}\right)^{r_1} \left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{2\max(r_1, r_2)}$.
\begin{claim}\label{claim: spca_decay}
For integers $r_1, r_2 \ge 0$, if $m \le \frac{d}{\lambda^2}$ and $m \le \frac{k^2}{\lambda^2}$, then,
\[\sqrt{d}^{r_1}\sqrt{m}^{r_2}\left(\frac{k}{d}\right)^{r_1} \left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{2\max(r_1, r_2)} \le 1\]
\end{claim}
\begin{proof}
We will consider the cases $r_1 \ge r_2$ and $r_1 < r_2$ separately. If $r_1 \ge r_2$, we have
\begin{align*}
\sqrt{d}^{r_1}\sqrt{m}^{r_2}\left(\frac{k}{d}\right)^{r_1} \left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{2r_1} &\le \sqrt{d}^{r_1}\left(\frac{\sqrt{d}}{\lambda}\right)^{r_2}\left(\frac{k}{d}\right)^{r_1} \left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{2r_1}\\
&= \left(\frac{\lambda}{\sqrt{d}}\right)^{r_1 - r_2}\\
&\le \left(\frac{1}{\sqrt{m}}\right)^{r_1 - r_2}\\
&\le 1
\end{align*}
And if $r_1 < r_2$, we have
\begin{align*}
\sqrt{d}^{r_1}\sqrt{m}^{r_2}\left(\frac{k}{d}\right)^{r_1} \left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{2r_2} &= \sqrt{d}^{r_1}\sqrt{m}^{r_2 - r_1}\sqrt{m}^{r_1}\left(\frac{k}{d}\right)^{r_1} \left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{2r_2}\\
&\le \sqrt{d}^{r_1}\left(\frac{k}{\lambda}\right)^{r_2 - r_1}\left(\frac{\sqrt{d}}{\lambda}\right)^{r_1}\left(\frac{k}{d}\right)^{r_1} \left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{2r_2}\\
&= 1
\end{align*}
\end{proof}
For the desired bounds, we mimic this argument while carefully keeping track of factors of $d^{\varepsilon}$.
\begin{claim}\label{claim: spca_decay2}
For integers $r_1, r_2 \ge 0$ and an integer $r \ge 2\max(r_1, r_2)$, if $m \le \frac{d^{1 - \varepsilon}}{\lambda^2}$ and $m \le \frac{k^{2 - \varepsilon}}{\lambda^2}$, then,
\[\sqrt{d}^{r_1}\sqrt{m}^{r_2}\left(\frac{k}{d}\right)^{r_1} \left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^r \le \left(\frac{1}{d^{A\varepsilon}}\right)^r\]
\end{claim}
\begin{proof}
If $r_1 \ge r_2$,
\begin{align*}
E &= \sqrt{d}^{r_1}\sqrt{m}^{r_2} \left(\frac{k}{d}\right)^{r_1}\left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{2r_1}\left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{r - 2r_1}\\
&\le \sqrt{d}^{r_1}\left(\frac{\sqrt{d}^{1 - \varepsilon}}{\lambda}\right)^{r_2} \left(\frac{k}{d}\right)^{r_1}\left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{2r_1}\left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{r - 2r_1}\\
& = \left(\frac{\lambda}{\sqrt{d}^{1 - \varepsilon}}\right)^{r_1 - r_2} \left(\frac{1}{\sqrt{d}}\right)^{\varepsilon r_1}\left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{r - 2r_1}\\
& \le \left(\frac{1}{\sqrt{m}}\right)^{r_1 - r_2} \left(\frac{1}{\sqrt{d}}\right)^{\varepsilon r_1}\left(\frac{1}{d^{A\varepsilon}}\right)^{r - 2r_1}\\
&\le \left(\frac{1}{d^{2A}}\right)^{\varepsilon r_1}\left(\frac{1}{d^{A\varepsilon}}\right)^{r - 2r_1}\\
&= \left(\frac{1}{d^{A\varepsilon}}\right)^r
\end{align*}
And if $r_1 < r_2$,
\begin{align*}
E &= \sqrt{d}^{r_1}\sqrt{m}^{r_2 - r_1} \sqrt{m}^{r_1} \left(\frac{k}{d}\right)^{r_1}\left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{2r_2}\left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{r - 2r_2}\\
&\le \sqrt{d}^{r_1}\left(\frac{\sqrt{k}^{2 - \varepsilon}}{\lambda}\right)^{r_2 - r_1}\left(\frac{\sqrt{d}^{1 - \varepsilon}}{\lambda}\right)^{r_1} \left(\frac{k}{d}\right)^{r_1}\left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{2r_2}\left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{r - 2r_2}\\
&= \left(\frac{\sqrt{k}}{\sqrt{d}}\right)^{\varepsilon r_1}\left(\frac{1}{\sqrt{k}}\right)^{\varepsilon r_2}\left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{r - 2r_2}\\
&\le \left(\frac{1}{\sqrt{k}}\right)^{\varepsilon r_2}\left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^{r - 2r_2}\\
&\le \left(\frac{1}{d^{2A}}\right)^{\varepsilon r_2}\left(\frac{1}{d^{A\varepsilon}}\right)^{r - 2r_2}\\
&\le \left(\frac{1}{d^{A\varepsilon}}\right)^{\sum_{e \in E(\tau)} l_e}
\end{align*}
\end{proof}
The result follows by setting $r = \sum_{e \in E(\tau)} l_e$ in the above claim.
\end{proof}
\begin{corollary}\label{cor: spca_norm_decay}
For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, we have
\[c(\tau) B_{norm}(\tau)S(\tau)R(\tau) \le 1\]
\end{corollary}
\begin{proof}
First, note that if $deg^{\tau}(i)$ is odd for any vertex $i \in V(\tau) \setminus U_{\tau} \setminus V_{\tau}$, then $S(\tau) = 0$ and the inequality is true. So, assume that $deg^{\tau}(i)$ is even for all $i \in V(\tau) \setminus U_{\tau} \setminus V_{\tau}$.
Since $\tau$ is a proper middle shape, we have $w(I_{\tau}) = 0$ and $w(S_{\tau, min}) = w(U_{\tau})$. This implies
$n^{\frac{w(V(\tau)) + w(I_{\tau}) - w(S_{\tau, min})}{2}} = \sqrt{d}^{|\tau|_1 - |U_{\tau}|_1}\sqrt{m}^{|\tau|_2 - |U_{\tau}|_2}$.
As was observed in the proof of \cref{lem: spca_charging}, every vertex $i \in V(\tau) \setminus U_{\tau}$ or $i \in V(\tau) \setminus V_{\tau}$ has $deg^{\tau}(i) \ge 1$ and hence, $|V(\tau)\setminus U_{\tau}| + |V(\tau)\setminus V_{\tau}| \le 4 \sum_{e \in E(\tau)} l_e$. Also, $q = d^{O(1)\cdot \varepsilon(C_V + C_E)}$. We can set $C_V, C_E$ sufficiently small so that
{\footnotesize
\begin{align*}
c(\tau)B_{norm}(\tau)S(\tau)R(\tau) &=100(6D_V)^{|U_{\tau}\setminus V_{\tau}| + |V_{\tau}\setminus U_{\tau}| + 2|E(\tau)|}4^{|V(\tau)\setminus (U_{\tau}\cup V_{\tau})|}\\
&\cdot 2e(6qD_V)^{|V(\tau)\setminus U_{\tau}| + |V(\tau)\setminus V_{\tau}|}\prod_{e \in E(\tau)} (400D_V^2D_E^2q)^{l_e}\\
&\cdot \sqrt{d}^{|\tau|_1 - |U_{\tau}|_1}\sqrt{m}^{|\tau|_2 - |U_{\tau}|_2} S(\tau) (C_{disc}\sqrt{D_E})^{\sum_{j \in (U_{\tau})_2 \cup (V_{\tau})_2} deg^{\tau}(j)}\\
&\le d^{O(1) \cdot (C_V + C_E) \cdot \varepsilon\sum_{e \in E(\tau)} l_e}\cdot \prod_{j \in V_2(\tau) \setminus V_2(U_{\tau}) \setminus V_2(V_{\tau})} (deg^{\tau}(j) - 1)!!\cdot \frac{1}{d^{A\varepsilon\sum_{e \in E(\tau)} l_e}}\\
&\le d^{O(1) \cdot (C_V + C_E) \cdot \varepsilon\sum_{e \in E(\tau)} l_e}\cdot (D_VD_E)^{\sum_{e \in E(\tau)} l_e}\cdot \frac{1}{d^{A\varepsilon\sum_{e \in E(\tau)} l_e}}\\
&\le 1
\end{align*}}
\end{proof}
We can now obtain our desired middle shape bounds.
\begin{lemma}\label{lem: spca_cond2}
For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$,
\[
\begin{bmatrix}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_U} & B_{norm}(\tau) H_{\tau}\\
B_{norm}(\tau) H_{\tau}^T & \frac{1}{|Aut(U)|c(\tau)}H_{Id_U}
\end{bmatrix}
\succeq 0
\]
\end{lemma}
\begin{proof}
We have
\begin{align*}
&\begin{bmatrix}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_U} & B_{norm}(\tau)H_{\tau}\\
B_{norm}(\tau)H_{\tau}^T & \frac{1}{|Aut(U)|c(\tau)}H_{Id_U}
\end{bmatrix}\\
&\qquad= \begin{bmatrix}
\left(\frac{1}{|Aut(U)|c(\tau)} - \frac{S(\tau)R(\tau)B_{norm}(\tau)}{|Aut(U)|}\right)H_{Id_U} & 0\\
0 & \left(\frac{1}{|Aut(U)|c(\tau)} - \frac{S(\tau)R(\tau)B_{norm}(\tau)}{|Aut(U)|}\right)H_{Id_U}
\end{bmatrix}\\
&\qquad\quad+ B_{norm}(\tau)\begin{bmatrix}
\frac{S(\tau)R(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)R(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix}
\end{align*}
By \cref{lem: spca_cond2_simplified}, $\begin{bmatrix}
\frac{S(\tau)R(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)R(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix}
\succeq 0$, so the second term above is positive semidefinite. For the first term, by \cref{lem: spca_cond1}, $H_{Id_U} \succeq 0$ and by \cref{cor: spca_norm_decay}, $\frac{1}{|Aut(U)|c(\tau)} - \frac{S(\tau)R(\tau)B_{norm}(\tau)}{|Aut(U)|} \ge 0$, which proves that the first term is also positive semidefinite.
\end{proof}
\subsection{Intersection term bounds}
\begin{lemma}\label{lem: spca_charging2}
Suppose $0 < A < \frac{1}{4}$ is a constant such that $\frac{\sqrt{\lambda}}{\sqrt{k}} \le d^{-A\varepsilon}, \frac{1}{\sqrt{k}} \le d^{-2A}$ and $\frac{k}{d} \le d^{-A\varepsilon}$. For all $m$ such that $m \le \frac{d^{1 - \varepsilon}}{\lambda^2}, m \le \frac{k^{2 - \varepsilon}}{\lambda^2}$, for all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and for all $\gamma \in \Gamma_{U, V}$,
\[n^{w(V(\gamma)\setminus U_{\gamma})} S(\gamma)^2 \le \left(\prod_{j \in V_2(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}}(deg^{\gamma}(j)- 1)!!\right)^2\frac{1}{d^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)}}\]
for some constant $B > 0$ that depends only on $C_{\Delta}$. In particular, it is independent of $C_V$ and $C_E$.
\end{lemma}
\begin{proof}
Suppose there is a vertex $i \in V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}$ such that $deg^{\gamma}(i)$ is odd, then $S(\gamma) = 0$ and the inequality is true. So, assume $deg^{\gamma}(i)$ is even for all vertices $i \in V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}$.
We have $n^{w(V(\gamma) \setminus U_{\gamma})} = d^{|\gamma|_1 - |U_{\gamma}|_1}m^{|\gamma|_2 - |U_{\gamma}|_2}$. Plugging in $S(\gamma)$, we get that we have to prove
{\footnotesize
\begin{align*}
E := d^{|\gamma|_1 - |U_{\gamma}|_1}m^{|\gamma|_2 - |U_{\gamma}|_2} \left(\frac{k}{d}\right)^{2|\gamma|_1 - |U_{\gamma}|_1 - |V_{\gamma}|_1}\Delta^{2|\gamma|_2 - |U_{\gamma}|_2 - |V_{\gamma}|_2} \prod_{e \in E(\gamma)} \frac{\lambda^{l_e}}{k^{l_e}} \le \frac{1}{d^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)}}
\end{align*}}
Let $S'$ be the set of vertices $i \in U_{\gamma} \setminus V_{\gamma}$ that have $deg^{\gamma}(i) \ge 1$. Let $e, f$ be the number of type $1$ vertices and the number of type $2$ vertices in $S'$ respectively. Observe that $S' \cup (U_{\gamma} \cap V_{\gamma})$ is a vertex separator of $\gamma$.
Let $g = |V_{\gamma} \setminus U_{\gamma}|_1$ (resp. $h = |V_{\gamma} \setminus U_{\gamma}|_2$) be the number of type $1$ vertices (resp. type $2$ vertices) in $V_{\gamma} \setminus U_{\gamma}$.
We first claim that $d^em^f \ge d^gm^h$. To see this, note that the vertex separator $S' \cup (U_{\gamma} \cap V_{\gamma})$ has weight $\sqrt{d}^{e + |U_{\gamma} \cap V_{\gamma}|_1}\sqrt{m}^{f + |U_{\gamma} \cap V_{\gamma}|_2}$. On the other hand, $V_{\gamma}$ has weight $\sqrt{d}^{g + |U_{\gamma} \cap V_{\gamma}|_1}\sqrt{m}^{h + |U_{\gamma} \cap V_{\gamma}|_2}$. Since $\gamma$ is a left shape, $V_{\gamma}$ is the unique minimum vertex separator and hence, we have the inequality $\sqrt{d}^{e + |U_{\gamma} \cap V_{\gamma}|_1}\sqrt{m}^{f + |U_{\gamma} \cap V_{\gamma}|_2} \ge \sqrt{d}^{g + |U_{\gamma} \cap V_{\gamma}|_1}\sqrt{m}^{h + |U_{\gamma} \cap V_{\gamma}|_2}$ which implies $d^em^f \ge d^gm^h$.
Let $p = |V(\gamma) \setminus (U_{\gamma} \cup V_{\gamma})|_1$ (resp. $q = |V(\gamma) \setminus (U_{\gamma} \cup V_{\gamma})|_2$) be the number of type $1$ vertices (resp. type $2$ vertices) in $V(\gamma) \setminus (U_{\gamma} \cup V_{\gamma})$.
To illustrate the main idea, we will first prove the weaker inequality $E \le 1$. Since $\Delta \le 1$, it suffices to prove
\begin{align*}
d^{|\gamma|_1 - |U_{\gamma}|_1}m^{|\gamma|_2 - |U_{\gamma}|_2} \left(\frac{k}{d}\right)^{2|\gamma|_1 - |U_{\gamma}|_1 - |V_{\gamma}|_1} \prod_{e \in E(\gamma)} \frac{\lambda^{l_e}}{k^{l_e}} \le 1
\end{align*}
We have
$d^{|\gamma|_1 - |U_{\gamma}|_1}m^{|\gamma|_2 - |U_{\gamma}|_2} = d^{p + g}m^{q + h} \le n^{p + \frac{e + g}{2}}m^{q + \frac{f + h}{2}}$
since $d^em^f \ge d^gm^h$. Also, $2|\gamma|_1 - |U_{\gamma}|_1 - |V_{\gamma}|_1 = 2p + e + g$. So, it suffices to prove
\begin{align*}
n^{p + \frac{e + g}{2}}m^{q + \frac{f + h}{2}}\left(\frac{k}{d}\right)^{2p + e + g} \prod_{e \in E(\gamma)} \left(\frac{\lambda}{k}\right)^{l_e} \le 1
\end{align*}
We will need the following claim.
\begin{claim}
$\sum_{e \in E(\gamma)} l_e \ge \max(2p + e + g, 2q + f + h)$
\end{claim}
\begin{proof}
Since $H_{\gamma}$ is bipartite, we have $\sum_{e \in E(\gamma)}l_e = \sum_{i \in V_1(\gamma)} deg^{\gamma}(i) = \sum_{i \in V_2(\gamma)} deg^{\gamma}(i)$. Observe that all vertices $i \in V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}$ have $deg^{\gamma}(i)$ nonzero and even, and hence, $deg^{\gamma}(i) \ge 2$. Then,
\begin{align*}
\sum_{e \in E(\gamma)}l_e &= \sum_{i \in V_1(\gamma)} deg^{\gamma}(i)\\
&\ge \sum_{i \in V_1(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}} deg^{\gamma}(i) + \sum_{i \in (U_{\gamma})_1 \setminus V_{\gamma}} deg^{\gamma}(i) + \sum_{i \in (V_{\gamma})_1 \setminus U_{\gamma}} deg^{\gamma}(i)\\
&\ge 2p + e + g
\end{align*}
Similarly,
\begin{align*}
\sum_{e \in E(\gamma)}l_e &= \sum_{i \in V_2(\gamma)} deg^{\gamma}(i)\\
&\ge \sum_{i \in V_2(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}} deg^{\gamma}(i) + \sum_{i \in (U_{\gamma})_2 \setminus V_{\gamma}} deg^{\gamma}(i) + \sum_{i \in (V_{\gamma})_2 \setminus U_{\gamma}} deg^{\gamma}(i)\\
&\ge 2q + f + h
\end{align*}
Therefore, $\sum_{e \in E(\gamma)} l_e \ge \max(2p + e + g, 2q + f + h)$.
\end{proof}
Now, let $r_1 = p + \frac{e + g}{2}, r_2 = q + \frac{f + h}{2}$. Then, $\sum_{e \in E(\gamma)} l_e \ge 2\max(r_1, r_2)$ and we wish to prove
$d^{r_1}m^{r_2} \left(\frac{k}{d}\right)^{2r_1} \left(\frac{\lambda}{k}\right)^{2\max(r_1, r_2)} \le 1$
This expression simply follows by squaring \cref{claim: spca_decay}.
Now, to prove that $E \le \frac{1}{d^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)}}$, we mimic this argument while carefully keeping track of factors of $d^{\varepsilon}$. Again, using $d^em^f \ge d^gm^h$, it suffices to prove that
\begin{align*}
d^{p + \frac{e + g}{2}}m^{q + \frac{f + h}{2}} \left(\frac{k}{d}\right)^{2|\gamma|_1 - |U_{\gamma}|_1 - |V_{\gamma}|_1}&\Delta^{2|\gamma|_2 - |U_{\gamma}|_2 - |V_{\gamma}|_2} \prod_{e \in E(\gamma)} \frac{\lambda^{l_e}}{k^{l_e}}\\
&\le \frac{1}{d^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)}}
\end{align*}
The idea is that the $d^{B\varepsilon}$ decay for the edges are obtained from the stronger assumption on $m$, namely $m \le \frac{d^{1 - \varepsilon}}{\lambda^2}, m \le \frac{k^{2 - \varepsilon}}{\lambda^2}$. And the $d^{B\varepsilon}$ decay for the type $1$ vertices of $V(\gamma) \setminus(U_{\gamma} \cap V_{\gamma})$ are obtained both from the stronger assumption on $m$ as well as the factors of $\frac{k}{d}$, the latter especially useful for the degree $0$ vertices. Finally, the $d^{B\varepsilon}$ decay for the type $2$ vertices of $V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})$ are obtained from the factors of $\Delta$.
Indeed, note that for a constant $B$ that depends on $C_{\Delta}$, $\Delta^{2|\gamma|_2 - |U_{\gamma}|_2 - |V_{\gamma}|_2} \le d^{-B\varepsilon|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})|_2}$. So, we would be done if we prove
\begin{align*}
d^{p + \frac{e + g}{2}}m^{q + \frac{f + h}{2}} \left(\frac{k}{d}\right)^{2|\gamma|_1 - |U_{\gamma}|_1 - |V_{\gamma}|_1}\left(\frac{\lambda}{k}\right)^{\sum_{e \in E(\gamma)} l_e} \le \frac{1}{d^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})|_1 + \sum_{e \in E(\gamma)} l_e)}}
\end{align*}
Let $c_0$ be the number of type $1$ vertices $i$ in $V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})$ such that $deg^{\gamma}(i) = 0$. Since they have degree $0$, they must be in $(U_{\gamma})_1 \setminus V_{\gamma}$. Also, we have $2|\gamma|_1 - |U_{\gamma}|_1 - |V_{\gamma}|_1 = 2p + e + g + c_0$ and hence, $\left(\frac{k}{d}\right)^{2|\gamma|_1 - |U_{\gamma}|_1 - |V_{\gamma}|_1} = \left(\frac{k}{d}\right)^{2p + e + g + c_0}$. For these degree $0$ vertices, we have that the factors of $\frac{k}{d} \le d^{-A\varepsilon}$ offer a decay of $\frac{1}{d^{B\varepsilon}}$. Therefore, it suffices to prove
\begin{align*}
d^{p + \frac{e + g}{2}}m^{q + \frac{f + h}{2}} \left(\frac{k}{d}\right)^{2p + e + g}\left(\frac{\lambda}{k}\right)^{\sum_{e \in E(\gamma)} l_e} \le \frac{1}{d^{B\varepsilon (p + q + e + f + g + h) + \sum_{e \in E(\gamma)} l_e)}}
\end{align*}
for a constant $B > 0$. Observe that $p + q + e + f + g + h \le 2(\sum_{e \in E(\gamma)} l_e)$. Therefore, using the notation $r_1 = p + \frac{e + g}{2}, r_2 = q + \frac{f + h}{2}$, it suffices to prove
\begin{align*}
d^{r_1}m^{r_2} \left(\frac{k}{d}\right)^{2r_1}\left(\frac{\lambda}{k}\right)^{\sum_{e \in E(\gamma)} l_e} \le \frac{1}{d^{B\varepsilon \sum_{e \in E(\gamma)} l_e}}
\end{align*}
for a constant $B > 0$. But this follows by squaring \cref{claim: spca_decay2} where we set $r = \sum_{e \in E(\gamma)} l_e$.
\end{proof}
\begin{remk}
In the above bounds, note that there is a decay of $d^{B\varepsilon}$ for each vertex in $V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})$. One of the main technical reasons for introducing the slack parameter $C_{\Delta}$ in the planted distribution was to introduce this decay, which is needed in the current machinery.
\end{remk}
With this, we obtain intersection term bounds.
\begin{lemma}\label{lem: spca_cond3}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and all $\gamma \in \Gamma_{U, V}$, \[c(\gamma)^2N(\gamma)^2B(\gamma)^2H_{Id_V}^{-\gamma, \gamma} \preceq H_{\gamma}'\]
\end{lemma}
\begin{proof}
By \cref{lem: spca_cond3_simplified}, we have
\begin{align*}
c(\gamma)^2N(\gamma)^2B(\gamma)^2H_{Id_V}^{-\gamma, \gamma} &\preceq c(\gamma)^2N(\gamma)^2B(\gamma)^2 S(\gamma)^2R(\gamma)^2 \frac{|Aut(U)|}{|Aut(V)|} H'_{\gamma}
\end{align*}
Using the same proof as in \cref{lem: spca_cond1}, we can see that $H'_{\gamma} \succeq 0$. Therefore, it suffices to prove that $c(\gamma)^2N(\gamma)^2B(\gamma)^2 S(\gamma)^2R(\gamma)^2 \frac{|Aut(U)|}{|Aut(V)|} \le 1$.
Since $U, V \in {\mathcal I}_{mid}$, $Aut(U) = |U|_1!|U|_2!, Aut(V) = |V|_1!|V|_2!$. Therefore, $\frac{|Aut(U)|}{|Aut(V)|} = \frac{|U|_1!|U|_2!}{|V|_1!|V|_2!} \le D_V^{|U_{\gamma} \setminus V_{\gamma}|}$. Also, $|E(\gamma)| \le \sum_{e \in E(\gamma)} l_e$ and $q = d^{O(1) \cdot \varepsilon (C_V + C_E)}$. Note $R(\gamma)^2 = (C_{disc}\sqrt{D_E})^{2\sum_{j \in (U_{\gamma})_2 \cup (V_{\gamma})_2} deg^{\gamma}(j)} \le d^{O(1)\cdot \varepsilon C_E \cdot \sum_{e \in E(\gamma)} l_e}$ and \[\left(\prod_{j \in V_2(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}}(deg^{\gamma}(j)- 1)!!\right)^2 \le (D_VD_E)^{2\sum_{e \in E(\tau)} l_e} \le d^{O(1)\cdot \varepsilon (C_V + C_E) \cdot \sum_{e \in E(\gamma)} l_e}\]
Let $B$ be the constant from \cref{lem: spca_charging2}. We can set $C_V, C_E$ sufficiently small so that, using \cref{lem: spca_charging2},
\begin{align*}
c(\gamma)^2&N(\gamma)^2B(\gamma)^2S(\gamma)^2R(\gamma)^2 \frac{|Aut(U)|}{|Aut(V)|} \\
&\le 100^2 (6D_V)^{2|U_{\gamma}\setminus V_{\gamma}| + 2|V_{\gamma}\setminus U_{\gamma}| + |E(\alpha)|}16^{|V(\gamma) \setminus (U_{\gamma} \cup V_{\gamma})|}\\
&\quad\cdot (3D_V)^{4|V(\gamma)\setminus V_{\gamma}| + 2|V(\gamma)\setminus U_{\gamma}|} (6qD_V)^{2|V(\gamma)\setminus U_{\gamma}| + 2|V(\gamma)\setminus V_{\gamma}|} \prod_{e \in E(\gamma)} (400D_V^2D_E^2q)^{2l_e}\\
&\quad\cdot n^{w(V(\gamma)\setminus U_{\gamma})} S(\gamma)^2 d^{O(1)\cdot \varepsilon C_E \cdot \sum_{e \in E(\gamma)} l_e}\cdot D_V^{|U_\gamma \setminus V_{\gamma}|} \\
&\le d^{O(1) \cdot \varepsilon(C_V + C_E) \cdot (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)} \cdot n^{w(V(\gamma)\setminus U_{\gamma})} S(\gamma)^2\\
&\le d^{O(1) \cdot \varepsilon(C_V + C_E) \cdot (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)}\cdot \frac{1}{d^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)}}\\
&\le 1
\end{align*}
\end{proof}
\subsection{Truncation error bounds}
In this section, we will obtain truncation error bounds using the strategy sketched in \cite[Section 10]{potechin2020machinery}. We also reuse the notation. To do this, we need to first obtain a bound on the quantity $B_{norm}(\sigma) B_{norm}(\sigma') H_{Id_U}(\sigma, \sigma')$.
\begin{lemma}\label{lem: spca_charging3}
Suppose $0 < A < \frac{1}{4}$ is a constant such that $\frac{\sqrt{\lambda}}{\sqrt{k}} \le d^{-A\varepsilon}$ and $\frac{1}{\sqrt{k}} \le d^{-2A}$. Suppose $m$ is such that $m \le \frac{d^{1 - \varepsilon}}{\lambda^2}, m \le \frac{k^{2 - \varepsilon}}{\lambda^2}$. For all $U \in {\mathcal I}_{mid}$ and $\sigma, \sigma' \in {\mathcal L}_U$,
\[B_{norm}(\sigma) B_{norm}(\sigma') H_{Id_U}(\sigma, \sigma') \le \frac{1}{d^{0.5A\varepsilon(|V(\sigma \circ \sigma')| + \sum_{e \in E(\alpha) l_e}}} \cdot \frac{1}{d^{|U_{\sigma}|_1 + |U_{\sigma'}|_1}m^{|U_{\sigma'}|_2 + |U_{\sigma'}|_2}}\]
\end{lemma}
\begin{proof}
Suppose there is a vertex $i \in V(\sigma) \setminus V_{\sigma}$ such that $deg^{\sigma}(i) + deg^{U_{\sigma}}(i)$ is odd, then $H_{Id_U}(\sigma, \sigma') = 0$ and the inequality is true. So, assume that $deg^{\sigma}(i) + deg^{U_{\sigma}}(i)$ is even for all $i \in V(\sigma) \setminus V_{\sigma}$. Similarly, assume that $deg^{\sigma'}(i) + deg^{U_{\sigma'}}(i)$ is even for all $i \in V(\sigma') \setminus V_{\sigma'}$. Also, if $\rho_{\sigma} \neq \rho_{\sigma'}$, we will have $H_{Id_U}(\sigma, \sigma') = 0$ and we would be done. So, assume $\rho_{\sigma} = \rho_{\sigma'}$.
Let there be $e$ (resp. $f$) vertices of type $1$ (resp. type $2$) in $V(\sigma) \setminus U_{\sigma} \setminus V_{\sigma}$. Then, $n^{\frac{w(V(\sigma)) - w(U)}{2}} = \sqrt{d}^{|V(\sigma)|_1 - |U|_1}\sqrt{m}^{|V(\sigma)|_2 - |U|_2} = \sqrt{d}^{|U_{\sigma}|_1}\sqrt{m}^{|U_{\sigma}|_2} \sqrt{d}^e\sqrt{m}^f$. Let there be $g$ (resp. $h$) vertices of type $1$ (resp. type $2$) in $V(\sigma') \setminus U_{\sigma'} \setminus V_{\sigma'}$. Then, similarly, $n^{\frac{w(V(\sigma')) - w(U)}{2}} \le \sqrt{d}^{|U_{\sigma'}|_1}\sqrt{m}^{|U_{\sigma'}|_2}\sqrt{d}^g\sqrt{m}^h$.
Let $\alpha = \sigma \circ \sigma'$. Since all vertices in $V(\alpha) \setminus U_{\alpha} \setminus V_{\alpha}$ have degree at least $2$, we have $\sum_{e \in E(\alpha)} l_e \ge \sum_{i \in V_1(\alpha) \setminus U_{\alpha} \setminus V_{\alpha}} deg^{\alpha}(i) \ge 2(e + g) + |U_{\sigma}|_1 + |U_{\sigma}|_2$. Similarly, $\sum_{e \in E(\alpha)} l_e \ge 2(f + h) + |U_{\sigma'}|_1 + |U_{\sigma'}|_2$. Therefore, by setting $r_1 = e + g, r_2 = f + h$ in \cref{claim: spca_decay2}, we have
\[\sqrt{d}^{e + g}\sqrt{m}^{f + h} \left(\frac{k}{d}\right)^{e + g}\prod_{e \in E(\alpha)} \frac{\sqrt{\lambda}^{l_e}}{\sqrt{k}^{l_e}} \le \frac{1}{d^{A\varepsilon \sum_{e \in E(\alpha)} l_e}}\]
Also, \[\left(\frac{k}{d}\right)^{|\alpha|_1} \le \left(\frac{k}{d}\right)^{e + g + |U_{\sigma}|_1 + |U_{\sigma'}|_1}\]
and \[\prod_{j \in V_2(\alpha)} (deg^{\alpha}(j) - 1)!! \le d^{\varepsilon C_V \sum_{e \in E(\alpha)} l_e}\]
Therefore,
\begin{align*}
&n^{\frac{w(V(\sigma)) - w(U)}{2}}n^{\frac{w(V(\sigma')) - w(U)}{2}}H_{Id_U}(\sigma, \sigma')\\
&\le d^{O(1)D_{sos}}\sqrt{d}^e\sqrt{m}^f d^{O(1)D_{sos}}\sqrt{d}^g\sqrt{m}^h\\
&\qquad \cdot\frac{1}{|Aut(U)|}\left(\frac{1}{\sqrt{k}}\right)^{deg(\alpha)}\left(\frac{k}{d}\right)^{|\alpha|_1}\Delta^{|\alpha|_2} \prod_{j \in V_2(\alpha)} (deg^{\alpha}(j) - 1)!!\prod_{e \in E(\alpha)} \frac{\sqrt{\lambda}^{l_e}}{\sqrt{k}^{l_e}}\\
&\le d^{O(1)D_{sos}} d^{\varepsilon C_V \sum_{e \in E(\alpha)} l_e} \sqrt{d}^{e + g}\sqrt{m}^{f + h} \left(\frac{k}{d}\right)^{e + g}\prod_{e \in E(\alpha)} \frac{\sqrt{\lambda}^{l_e}}{\sqrt{k}^{l_e}} \cdot \frac{1}{d^{|U_{\sigma}|_1 + |U_{\sigma'}|_1}m^{|U_{\sigma'}|_2 + |U_{\sigma'}|_2}}\\
&\le \frac{d^{\varepsilon C_V \sum_{e \in E(\alpha)} l_e}}{d^{A\varepsilon \sum_{e \in E(\alpha)} l_e}} \cdot \frac{1}{d^{|U_{\sigma}|_1 + |U_{\sigma'}|_1}m^{|U_{\sigma'}|_2 + |U_{\sigma'}|_2}}
\end{align*}
By setting $C_V, C_E$ sufficiently small and plugging in the expressions for $B_{norm}(\sigma), B_{norm}(\sigma')$, we obtain the result.
\end{proof}
We can apply the the strategy now.
\begin{restatable}{lemma}{SPCAfive}\label{lem: spca_cond5}
Whenever $\norm{M_{\alpha}} \le B_{norm}(\alpha)$ for all $\alpha \in {\mathcal M}'$,
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq \frac{1}{d^{K_1D_{sos}^2}} Id_{sym}
\]
for a constant $K_1 > 0$ that can depend on $C_{\Delta}$.
\end{restatable}
\begin{proof}
For $V \in {\mathcal I}_{mid}$, $\lambda_V = \frac{\Delta^{|V|_2}}{d^{|V|_1}k^{|V|_2}}$. Let the minimum value of this quantity over all $V$ be $N$. We then choose $w_V = N / \lambda_V$ so that for all left shapes $\sigma \in {\mathcal L}_V$, \cref{lem: spca_charging3} implies $w_{V} \leq \frac{w_{U_{\sigma}}\lambda_{U_{\sigma}}}{|\mathcal{I}_{mid}|B_{norm}(\sigma)^2{c(\sigma)^2}{H_{Id_V}(\sigma,\sigma)}}$, completing the proof.
\end{proof}
\begin{restatable}{lemma}{SPCAsix}\label{lem: spca_cond6}
\[\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} \frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)} \le \frac{d^{K_2 D_{sos}}}{2^{D_V}}\]
for a constant $K_2 > 0$ that can depend on $C_{\Delta}$.
\end{restatable}
\begin{proof}
We do the same calculations as in the proof of \cref{lem: plds_cond6}, until
\begin{align*}
\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} &\frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}} {B_{norm}(\sigma)B_{norm}(\sigma')H_{Id_{U}}(\sigma,\sigma')\frac{1}{2^{\min(m_{\sigma}, m_{\sigma'}) - 1}}}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{d^{O(1) D_{sos}}}{d^{0.5A\varepsilon|V(\sigma \circ \sigma')|}2^{\min(m_{\sigma}, m_{\sigma'}) - 1}}
\end{align*}
where we used \cref{lem: spca_charging3}. Using $d^{0.5A\varepsilon |V(\sigma \circ \sigma')|} \ge d^{0.1A\varepsilon |V(\sigma \circ \sigma')|}2^{|V(\sigma \circ \sigma')|}$,
\begin{align*}
\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} \frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)} &\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{d^{O(1) D_{sos}}}{d^{0.1A\varepsilon|V(\sigma \circ \sigma')|} 2^{|V(\sigma \circ \sigma')|}2^{\min(m_{\sigma}, m_{\sigma'}) - 1}}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{d^{O(1) D_{sos}}}{d^{0.1A\varepsilon|V(\sigma \circ \sigma')|} 2^{D_V}}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{d^{O(1) D_{sos}}}{D_{sos}^{D_{sos}}d^{0.1A\varepsilon|V(\sigma \circ \sigma')|} 2^{D_V}}
\end{align*}
The final step will be to argue that $\sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{1}{D_{sos}^{D_{sos}}d^{0.1 A\varepsilon|V(\sigma \circ \sigma')|}} \le 1$ which will complete the proof. But this will follow if we set $C_V, C_E$ small enough.
\end{proof}
We can finally show that truncation errors can be handled.
\begin{restatable}{lemma}{SPCAfour}\label{lem: spca_cond4}
Whenever $\norm{M_{\alpha}} \le B_{norm}(\alpha)$ for all $\alpha \in \mathcal{M}'$,
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq 6\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\]
\end{restatable}
\begin{proof}
Choose $C_{sos}$ sufficiently small so that $\frac{1}{d^{K_1D_{sos}^2}} \ge 6\frac{d^{K_2D_{sos}}}{2^{D_V}}$ which can be satisfied by setting $C_{sos} < K_3 C_V$ for a sufficiently small constant $K_3 > 0$. Then, since $Id_{Sym} \succeq 0$, using \cref{lem: spca_cond5} and \cref{lem: spca_cond6},
\begin{align*}
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} &\succeq \frac{1}{d^{K_1D_{sos}^2}} Id_{sym}\\
&\succeq 6\frac{d^{K_2D_{sos}}}{2^{D_V}} Id_{sym}\\
&\succeq 6\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\end{align*}
\end{proof}
\subsection{Fourier analysis for matrix-valued functions: ribbons, shapes, and graph matrices}
For our machinery, we need the definitions of ribbons, shapes, and graph matrices from \cite{AMP20}.
\subsubsection{Ribbons}
\emph{Ribbons} lift the usual Fourier basis for functions $\{ f \, : \, \{ \pm 1\}^{n \choose 2} \rightarrow {\mathbb R} \}$ to matrix-valued functions.
\begin{definition}[Simplified ribbons -- see \cref{def: ribbons}]
Let $n \in {\mathbb{N}}$.
A ribbon $R$ is a tuple $(E_R,A_R,B_R)$ where $E_R \subseteq {[n] \choose 2}$ and $A_R,B_R$ are tuples of elements in $[n]$.
$R$ thus specifies:
\begin{enumerate}
\item A Fourier character $\chi_{E_R}$.
\item Row and column indices $A_R$ and $B_R$.
\end{enumerate}
We think of $R$ as a graph with vertices
\[
V(R) = \{ \text{ endpoints of $(i,j) \in E_R$ } \} \cup A_R \cup B_R
\]
and edges $E(R) = E_R$, where $A_R, B_R$ are distinguished tuples of vertices.
\end{definition}
\begin{definition}[Matrix-valued function for a ribbon $R$]
Given a ribbon $R$, we define the matrix valued function $M_R \, : \, \{ \pm 1\}^{n \choose 2} \rightarrow {\mathbb R}^{\frac{n!}{(n - |A_R|)!} \times \frac{n!}{(n - |B_R|)!}}$ to have entries $M_R(A_R,B_R) = \chi_{E_R}$ and $M_R(A',B') = 0$ whenever $A' \neq A_R$ or $B' \neq B_R$.
\end{definition}
The following proposition captures the main property of the matrix-valued functions $M_R$ -- they are an orthonormal basis. We leave the proof to the reader.
\begin{proposition}
The matrix-valued functions $M_R$ form an orthonormal basis for the vector space of matrix valued functions with respect to the inner product
\[
\iprod{M,M'} = {\mathbb E}_{G \sim \{ \pm 1\}^{n \choose 2} }\left[\Tr \left(M(G) (M'(G))^\top\right)\right].
\]
\end{proposition}
We don't directly utilize this proposition in our work but this gives insight on to the structure of the matrix valued functions we define and motivates the definition of graph matrices, that we use extensively.
\begin{example}
In \cref{fig: ribbon_shape}, consider the ribbon $R$ as shown. We have $A_R = (1, 3), B_R = (4), V(R) = \{1, 2, 3, 4\}, E_R = \{\{1, 2\}, \{3, 2\}, \{2, 4\}\}$. The Fourier character is $\chi_{E_R} = \chi_{1, 2}\chi_{3, 2}\chi_{2, 4}$. And finally, $M_R$ is a matrix with rows and columns indexed by tuples of length $|A_R| = 2$ and $|B_R| = 1$ respectively, with exactly one nonzero entry $M_R((1, 3), (4)) = \chi_{E_R}$. Succinctly, \[M_R =
\begin{blockarray}{rl@{}c@{}r}
& & \makebox[0pt]{column $(4)$} \\[-0.5ex]
& & \,\downarrow \\[-0.5ex]
\begin{block}{r(l@{}c@{}r)}
& \makebox[3.1em]{\Large $0$\bigstrut[t]} & \vdots &\makebox[4.2em]{\Large $0$} \\[-0.2ex]
\text{row }(1, 3) \rightarrow \mkern-9mu & \raisebox{0.5ex}{\makebox[3.2em][l]{\dotfill}} & \chi_{1, 2}\chi_{3, 2}\chi_{2, 4} & \raisebox{0.5ex}{\makebox[4.2em][r]{\dotfill}} \\[+0ex]
& \makebox[3.1em]{\Large $0$} & \vdots &\makebox[4.2em]{\bigstrut\Large $0$} \\
\end{block}
\end{blockarray}\]
\end{example}
\begin{figure}[!h]
\centering
\includegraphics[scale=.6, trim={0 5cm 2 5cm},clip]{machinery/images/ribbon_shape}
\caption{Example of a ribbon and a shape}
\label{fig: ribbon_shape}
\end{figure}
\subsubsection{Shapes and Graph Matrices}
As described above, \emph{ribbons} are an orthonormal basis for matrix-valued functions. However, we will need an orthogonal basis for the subset of those functions which are symmetric with respect to the action of $S_n$. For this, we use \emph{graph matrices}, which are described by \emph{shapes}. The idea is that each ribbon $R$ has a shape $\alpha$ which is obtained by replacing the vertices of $R$ with unspecified indices. Up to scaling, the graph matrix $M_{\alpha}$ is the average of $M_{\pi(R)}$ over all permutations $\pi \in S_n$.
\begin{definition}[Simplified shapes -- see \cref{def: shapes}]
Informally, a shape $\alpha$ is just a ribbon $R$ where the vertices are specified by variables rather than having specific values in $[n]$. More precisely, a shape $\alpha = (V(\alpha),E(\alpha),U_{\alpha},V_{\alpha})$ is a graph on vertices $V(\alpha)$, with
\begin{enumerate}
\item Edges $E(\alpha) \subseteq {{V(\alpha)} \choose 2}$
\item Distinguished tuples of vertices $U_\alpha = (u_1,u_2,\dots)$ and $V_\alpha = (v_1,v_2,\dots)$, where $u_i,v_i \in V(\alpha)$.
\end{enumerate}
(Note that $V(\alpha)$ and $V_\alpha$ are not the same object!)
\end{definition}
\begin{definition}[Shape transposes]
Given a shape $\alpha$, we define $\alpha^{\top}$ to be the shape $\alpha$ with $U_{\alpha}$ and $V_{\alpha}$ swapped i.e. $U_{\sigma^{\top}} = V_{\sigma}$ and $V_{\sigma^{\top}} = U_{\sigma}$.
Note that $M_{\alpha^{\top}} = M_\alpha^{\top}$, where $M_\alpha^{\top}$ is the usual transpose of the matrix-valued function $M_\alpha$.
\end{definition}
\begin{definition}[Graph matrices]
Let $\alpha$ be a shape.
The graph matrix $M_{\alpha} \, : \, \{ \pm 1\}^{n \choose 2} \rightarrow {\mathbb R}^{\frac{n!}{(n - |U_{\alpha}|)!} \times \frac{n!}{(n - |V_{\alpha}|)!}}$ is defined to be the matrix-valued function with $A,B$-th entry
\[
M_{\alpha}(A,B) = \sum_{\substack{R \text{ s.t. } A_R = A, B_R = B \\ \exists \varphi:V(\alpha) \rightarrow [n]: \\ \varphi \text{ is injective}, \varphi(\alpha) = R}}{\chi_{E_R}}
\]
In other words, $M_\alpha = \sum_{R} M_R$ where the sum is over ribbons $R$ which can be obtained by assigning each vertex in $V(\alpha)$ a label from $[n]$.
\end{definition}
\begin{example}
In \cref{fig: ribbon_shape}, consider the shape $\alpha$ as shown. We have $U_{\alpha} = (u_1, u_2), V_{\alpha} = (v_1), V(\alpha) = \{u_1, u_2, v_1, w_1\}$ and $E(\alpha) = \{\{u_1, w_1\}, \{u_2, w_1\}, \{w_1, v_1\}\}$. $M_{\alpha}$ is a matrix with rows and columns indexed by tuples of length $|U_{\alpha}| = 2$ and $|V_{\alpha}| = 1$ respectively. The nonzero entries will have rows and columns indexed by $(a_1, a_2)$ and $b_1$ respectively for all distinct $a_1, a_2, b_1$, with the corresponding entry being $M_{\alpha}((a_1, a_2), (b_1)) = \sum_{c_1 \in [n] \setminus \{a_1, a_2, b_1\}} \chi_{a_1, c_1}\chi_{a_2, c_1}, \chi_{c_1, b_1}$. Here, the injective map $\varphi$ maps $u_1, u_2, w_1, v_1$ to $a_1, a_2, c_1, b_1$ respectively and we sum over all such maps. Succinctly, \[M_{\alpha} =
\begin{blockarray}{rl@{}c@{}r}
& & \makebox[0pt]{column $(c_1)$} \\[-0.5ex]
& & \,\downarrow \\[-0.5ex]
\begin{block}{r(l@{}c@{}r)}
& & \vdots & \\[-0.2ex]
\text{row }(a_1, a_2) \rightarrow \mkern-9mu & \raisebox{0.5ex}{\makebox[3.2em][l]{\dotfill}} & \sum_{c_1 \in [n] \setminus \{a_1, a_2, b_1\}} \chi_{a_1, c_1}\chi_{a_2, c_1}, \chi_{c_1, b_1} & \raisebox{0.5ex}{\makebox[4.2em][r]{\dotfill}} \\[+.5ex]
& & \vdots & \\
\end{block}
\end{blockarray}\]
\end{example}
\begin{remk}
The fact that we are summing over all "free" vertices in $V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})$ is how we are incorporating symmetry into the definition of these graph matrices.
\end{remk}
The following examples illustrate that simple matrices such as the adjacency matrix of a graph and the identity matrix are also graph matrices.
\begin{example}[Adjacency matrix]\label{ex:adj-matrix}
Let $\alpha$ be the shape with two vertices $V(\alpha) = \{u_1,v_1\}$ and a single edge $E(\alpha) = \{\{ u_1,v_1\}\}$. The tuples $U_\alpha, V_\alpha$ are $(u_1), (v_1)$, respectively.
Then $M_\alpha$ has entries $(M_\alpha)_{i,j}(G) = G_{ij}$ if $i \neq j$ and $(M_\alpha)_{i,i} = 0$.
If $G \in \{ \pm 1\}^{n \choose 2}$ is thought of as a graph, then $M_\alpha$ is precisely its $\pm 1$ adjacency matrix with zeros on the diagonal.
\end{example}
\begin{example}[Identity matrix]
If $V(\alpha) = \{u\}$ is a singleton, $E(\alpha) = \emptyset$, and $U_{\alpha} = V_{\alpha} = (u)$, then $M_\alpha(G)$ is identically equal to the $n \times n$ identity matrix, independent of $G$.
\end{example}
For more examples of graph matrices and why they can be a useful tool to work with, see \cite{AMP20}.
\begin{remark}
As noted in \cite{AMP20}, we index graph matrices by tuples rather than sets so that they are symmetric (as a function of the input) under permutations of $[n]$.
\end{remark}
\subsection{Factoring Graph Matrices and Decomposing Shapes into Left, Middle, and Right Parts}
A crucial idea in our analysis is the idea from \cite{BHKKMP16} of decomposing each shape $\alpha$ into left, middle, and right parts. This will allow us to give an approximate factorization of each graph matrix $M_{\alpha}$.
\subsubsection{Leftmost and Rightmost Minimum Vertex Separators and Decomposition of Shapes into Left, Middle, and Right Parts}
For each shape $\alpha$ we will identify three other shapes, which we denote by $\sigma,\tau,{\sigma'}^T$ and call (for reasons we will see soon) the \emph{left, middle, and right parts of $\alpha$}, respectively.
The idea is that $M_{\alpha} \approx M_{\sigma} M_{\tau} M_{{\sigma'}^T}$.
We obtain $\sigma, \tau$, and ${\sigma'}^T$ by splitting the shape $\alpha$ along the \emph{leftmost and rightmost minimum vertex separators}.
\begin{definition}[Vertex Separators]
We say that a set of vertices $S$ is a vertex separator of $\alpha$ if every path from $U_{\alpha}$ to $V_{\alpha}$ in $\alpha$ (including paths of length $0$) intersects $S$. Note that for any vertex separator $S$, $U_{\alpha} \cap V_{\alpha} \subseteq S$.
\end{definition}
\begin{definition}[Minimum Vertex Separators]
We say that $S$ is a minimum vertex separator of $\alpha$ if $S$ is a vertex separator of $\alpha$ and for any other vertex separator $S'$ of $\alpha$, $|S| \leq |S'|$.
\end{definition}
\begin{definition}[Leftmost and Rightmost Minimum Vertex Separators] \
\begin{enumerate}
\item We say that $S$ is the leftmost minimum vertex separator of $\alpha$ if $S$ is a minimum vertex separator of $\alpha$ and for every other minimum vertex separator $S'$ of $\alpha$, every path from $U_{\alpha}$ to $S'$ intersects $S$.
\item We say that $T$ is the rightmost minimum vertex separator of $\alpha$ if $T$ is a minimum vertex separator of $\alpha$ and for every other minimum vertex separator $S'$ of $\alpha$, every path from $S'$ to $V_{\alpha}$ intersects $T$.
\end{enumerate}
\end{definition}
It is not immediately obvious that leftmost and rightmost minimum vertex separators are well-defined. For the simplified setting we are considering here, this was shown by \cite{BHKKMP16}. We give a more general proof in \cref{separatorswelldefinedsection}.
We now describe how to split $\alpha$ into left, middle, and right parts $\sigma, \tau$, and ${\sigma'}^T$.
\begin{definition}[Decomposition Into Left, Middle, and Right Parts]
Let $\alpha$ be a shape and let $S$ and $T$ be the leftmost and rightmost minimum vertex separators of $\alpha$. Given orderings $O_S$ and $O_T$ for $S$ and $T$, we decompose $\alpha$ into left, middle, and right parts $\sigma$, $\tau$, and ${\sigma'}^T$ as follows.
\begin{enumerate}
\item The left part $\sigma$ of $\alpha$ is the part of $\alpha$ reachable from $U_\alpha$ without passing through $S$. It includes $S$ but excludes all edges which are entirely within $S$.
More formally,
\begin{enumerate}
\item $V(\sigma) = \{u \in V(\alpha): \text{ there is a path } P \text{ from } U_{\alpha} \text{ to } u \text{ in } \alpha \text{ such that } (V(P) \setminus \{u\}) \cap S = \emptyset\}$
\item $U_\sigma = U_\alpha$ and $V_\sigma = S$ with the ordering $O_S$
\item $E(\sigma) = \{\{u,v\} \in E(\alpha): u,v \in V(\sigma), u \notin S \text{ or } v \notin S\}$
\end{enumerate}
\item
The right part ${\sigma'}^T$ of $\alpha$ is the part of $\alpha$ reachable from $V_\alpha$ without intersecting $T$ more than once. It includes $T$ but excludes all edges which are entirely within $T$.
More formally,
\begin{enumerate}
\item $V({\sigma'}^T) = \{u \in V(\alpha): \text{ there is a path } P \text{ from } V_{\alpha} \text{ to } u \text{ in } \alpha \text{ such that } (V(P) \setminus \{u\}) \cap T = \emptyset\}$
\item $U_{{\sigma'}^T} = T$ with the ordering $O_T$ and $V_{{\sigma'}^T} = V_\alpha$.
\item $E({\sigma'}^T) = \{\{u,v\} \in E(\alpha): u,v \in V({\sigma'}^T), u \notin T \text{ or } v \notin T\}$
\end{enumerate}
\item The middle part $\tau$ of $\alpha$ is, informally, the part of $\alpha$ between $S$ and $T$ (including $S$ and $T$ and all edges which are entirely within $S$ or within $T$).
More formally, let $U_\tau = S$ with the ordering $O_S$, let $V_\tau = T$ with the ordering $O_T$, and let $E(\tau) = E(\alpha) \setminus (E(\sigma) \cup E(\sigma'))$ be all of the edges of $E(\alpha)$ which do not appear in $E(\sigma)$ or $E(\sigma')$.
Then $V(\tau)$ is all of the vertices incident to edges in $E(\tau)$ together with $S, T$.
\end{enumerate}
\end{definition}
\begin{example}
\cref{fig: basic_shape_comp} illustrates an example decomposition.
\begin{enumerate}
\item If we start with the shape $\alpha$ denoted as $\sigma \circ \sigma'^T$, observe that there is a unique minimum vertex separator, which consists of the middle vertex of degree $5$, i.e. the one that's not in either $U_{\sigma \circ \sigma'^T}$ or $V_{\sigma \circ \sigma'^T}$.
Then, $\alpha$ is decomposed in to the left part $\sigma$, a trivial middle part $\tau$ (not shown in this figure) which has $V(\tau) = \{u\}, U_{\tau} = V_{\tau} = (u), E(\tau) = \emptyset$, and the right part $\sigma'^T$.
\item If we start with the shape $\alpha$ denoted as $\sigma \circ \tau \circ \sigma'^T$, then the leftmost minimum vertex separator is the vertex of degree $4$ and the rightmost minimum vertex separator is the vertex of degree $5$. Then, $\alpha$ is decomposed into the left part $\sigma$, the middle part $\tau$ and the right part $\sigma'^T$, which are all shown in this figure.
\end{enumerate}
\end{example}
\begin{remark}
Note that the decomposition into left, middle, and right parts depends on the ordering for the vertices in $S$ and $T$. As we will discuss later (see Section \ref{fullcoefficientmatrixsubsection}), we will use all possible orderings simultaneously and then scale things by an appropriate constant.
\end{remark}
\begin{figure}[!h]
\centering
\includegraphics[scale=0.45, trim={4.5cm 2cm 0 2cm},clip]{machinery/images/basic_shape_comp}
\caption{Illustration of shape composition and decomposition.}
\label{fig: basic_shape_comp}
\end{figure}
\noindent Because of the minimality and leftmost/rightmost-ness of the vertex separators $S,T$ used to define $\sigma, \tau, \sigma'$, the shapes $\sigma, \tau, \sigma'$ have some special combinatorial structure, which we capture in the following proposition. We defer the proof until \cref{sec: technical_def_and_main_theorem} where we state a generalized version.
\begin{proposition}
$\sigma$, $\tau$, and ${\sigma'}^{T}$ have the following properties:
\begin{enumerate}
\item $V_{\sigma} = S$ is the unique minimum vertex separator of $\sigma$.
\item $S$ and $T$ are the leftmost and rightmost minimum vertex separators of $\tau$.
\item $T = U_{{\sigma'}^T}$ is the unique minimum vertex separator of ${\sigma'}^T$.
\end{enumerate}
\end{proposition}
\noindent Based on this, we define sets of shapes which can appear as left, middle, or right parts.
\begin{definition}[Left, Middle, and Right Parts] Let $\alpha$ be a shape.
\begin{enumerate}
\item We say that $\alpha$ is a left part if $V_{\alpha}$ is the unique minimum vertex separator of $\alpha$, all vertices of $\alpha$ are reachable from $U_{\alpha}$ without passing through $V_{\alpha}$, and $E(\alpha)$ has no edges which are entirely contained in $V_{\alpha}$.
\item We say that $\alpha$ is a proper middle part if $U_{\alpha}$ is the leftmost minimum vertex separator of $\alpha$ and $V_{\alpha}$ is the rightmost minimum vertex separator of $\alpha$
\item We say that $\alpha$ is a right part if $U_{\alpha}$ is the unique minimum vertex separator of $\alpha$, all vertices of $\alpha$ are reachable from $V_{\alpha}$ without passing through $U_{\alpha}$, and $E(\alpha)$ has no edges which are entirely contained in $U_{\alpha}$.
\end{enumerate}
\end{definition}
\begin{remark}
For technical reasons, later on we will need to consider improper middle parts $\tau$ where $U_{\tau}$ and $V_{\tau}$ are not the leftmost and rightmost minimum vertex separators of $\tau$, which is why we make this distinction here.
\end{remark}
\noindent The following proposition is also straightforward from the definitions.
\begin{proposition}
A shape $\sigma$ is a left part if and only if $\sigma^{T}$ is a right part
\end{proposition}
\subsubsection{Products of Graph Matrices}
We now analyze what happens when we take the products of graph matrices. Roughly speaking, we will have that if $\alpha$ can be decomposed into left, middle, and right parts $\sigma$, $\tau$, and ${\sigma'}^{T}$ then $M_{\alpha} \approx M_{\sigma}M_{\tau}M_{{\sigma'}^T}$. However, this is only an approximation rather than an equality, and this will be the source of considerable technical difficulties.
We begin with a concatenation operation on ribbons.
\begin{definition}[Ribbon Concatenation]
If $R_1$ and $R_2$ are two ribbons such that $V(R_1) \cap V(R_2) = B_{R_1} = A_{R_2}$ and either $R_1$ or $R_2$ contains no edges entirely within $B_{R_1} = A_{R_2}$ then we define $R_1 \circ R_2$ to be the ribbon formed by glueing together $R_1$ and $R_2$ along $B_{R_1} = A_{R_2}$.
In other words,
\begin{enumerate}
\item $V(R_1 \circ R_2) = V(R_1) \cup V(R_2)$
\item $E(R_1 \circ R_2) = E(R_1) \cup E(R_2)$
\item $A_{R_1 \circ R_2} = A_{R_1}$ and $B_{R_1 \circ R_2} = B_{R_2}$.
\end{enumerate}
\end{definition}
\noindent The following proposition is easy to check.
\begin{proposition}
Whenever $R_1, R_2$ are ribbons such that $R_1 \circ R_2$ is defined, $M_{R_1}M_{R_2} = M_{R_1 \circ R_2}$
\end{proposition}
\noindent We have an analogous definition for concatenating shapes:
\begin{definition}[Shape Concatenation]
If $\alpha_1$ and $\alpha_2$ are two shapes such that $V(\alpha_1) \cap V(\alpha_2) = V_{\alpha_1} = U_{\alpha_2}$ and either $\alpha_1$ or $\alpha_2$ contains no edges entirely within $V_{\alpha_1} = U_{\alpha_2}$ then we define $\alpha_1 \circ \alpha_2$ to be the shape formed by glueing together $\alpha_1$ and $\alpha_2$ along $V_{\alpha_1} = U_{\alpha_2}$. In other words,
\begin{enumerate}
\item $V(\alpha_1 \circ \alpha_2) = V(\alpha_1) \cup V(\alpha_2)$
\item $E(\alpha_1 \circ \alpha_2) = E(\alpha_1) \cup E(\alpha_2)$
\item $U_{\alpha_1 \circ \alpha_2} = U_{\alpha_1}$ and $V_{\alpha_1 \circ \alpha_2} = V_{\alpha_2}$.
\end{enumerate}
\end{definition}
\begin{example}
\cref{fig: basic_shape_comp} illustrates an example of shape composition. Observe how the shapes $\sigma \circ \sigma'^T$ and $\sigma \circ \tau \circ \sigma'^T$ are obtained from the shapes $\sigma, \tau$ and $\sigma'^T$.
\end{example}
\noindent The next proposition, again easy to check, shows that the shape concatenation operation respects the left/middle/right part decomposition.
\begin{proposition}
If $\alpha$ can be decomposed into left, middle, and right parts $\sigma,\tau,{\sigma'}^{T}$ then $\alpha = \sigma \circ \tau \circ {\sigma'}^T$.
\end{proposition}
We now discuss why $M_\alpha = M_{\sigma \circ \tau \circ {\sigma'}^T} \approx M_\sigma M_\tau M_{{\sigma'}^T}$ is only an approximation rather than an equality. Consider the difference $M_{\sigma}M_\tau M_{{\sigma'}^T} - M_{\sigma \circ \tau \circ {\sigma'}^T}$. The graph matrix $M_{\sigma \circ \tau \circ {\sigma'}^T}$ decomposes (by definition) into a sum over injective maps $\varphi \, : \, V(\sigma \circ \tau \circ {\sigma'}^T) \rightarrow [n]$. Also by expanding definitions, the product $M_{\sigma}M_\tau M_{{\sigma'}^T}$ expands into a sum over triples of injective maps $(\varphi_1, \varphi_2, \varphi_3)$, where $\varphi_1 \, : \, V(\sigma) \rightarrow [n], \varphi_2 \, : \, V(\tau) \rightarrow [n], \varphi_3 \, : \, V(\sigma') \rightarrow [n]$ where $\varphi_1$ and $\varphi_2$ agree on $V_{\sigma} = U_{\tau}$ and $\varphi_2$ and $\varphi_3$ agree on $V_{\tau} = U_{{\sigma'}^T}$.
If they are combined into one map $\varphi: V(\sigma \cup \tau \cup {\sigma'} ) \rightarrow [n]$, the resulting $\varphi$ may not be injective because $\varphi_1(V(\sigma)), \varphi_2(V(\tau)), \varphi_3(V({\sigma'}^T))$ may have nontrivial intersection (beyond $\varphi_1(V_\sigma)$ and $\varphi_2(V_\tau)$).
We call the resulting terms \emph{intersection terms} and handling them properly is a major part of the technical analysis.
\begin{remark}
Actually, the approximation $M_\alpha = M_{\sigma \circ \tau \circ {\sigma'}^T} \approx M_\sigma M_\tau M_{{\sigma'}^T}$ is also off by a multiplicative constant because there is also a subtle issue involving the automorphism groups of these shapes. For now, we ignore this issue. For details about this issue, see Lemma \ref{lm:morthsimplereexpression}.
\end{remark}
\subsection{Shape Coefficient Matrices}
The idea for our analysis is as follows. Given a matrix-valued function $\Lambda$ which is symmetric under permutations of $[n]$, we write $\Lambda = \sum_{\alpha}{\lambda_{\alpha}M_{\alpha}}$. We then break each shape $\alpha$ up into left, middle, and right parts $\sigma$, $\tau$, and ${\sigma'}^{T}$.
For this analysis, we use \emph{shape coefficient matrices} $H_{\tau}$ whose rows and columns are indexed by left shapes and whose entries depend on the coefficients $\lambda_{\alpha}$. We choose these matrices so that
\[
\Lambda = \sum_{\tau}{H_{\tau}(\sigma,\sigma')M_{\sigma \circ \tau \circ {\sigma'}^T}} \approx \sum_{\tau}{H_{\tau}(\sigma,\sigma')M_{\sigma}M_{\tau}M_{{\sigma'}^T}}
\]
To set this up, we separate the possible middle parts $\tau$ into groups based on the size of $U_{\tau}$ and whether or not they are trivial.
\begin{definition}
We define $\mathcal{I}_{mid}$ to be the set of all possible $U_{\tau}$. Here $\mathcal{I}_{mid}$ is the set of tuples of unspecified vertices of the form $U = (u_1,\ldots,u_k)$ where $0 \leq k \leq d$.
\end{definition}
\begin{definition}
We say that a proper middle shape $\tau$ is trivial if $E(\tau) = \emptyset$ and $|U_{\tau} \cap V_{\tau}| = |U_{\tau}| = |V_{\tau}|$ (i.e. $V_{\tau}$ is a permutation of $U_{\tau}$).
\end{definition}
For simplicity, the only proper trivial middle parts $\tau$ we consider are shapes $Id_U$ corresponding to identity matrices.
\begin{definition}
Given a tuple of unspecified vertices $U = (u_1,\ldots,u_{|U|})$ We define $Id_U$ to be the shape where $V(Id_U) = U$, $U_{Id_U} = V_{Id_U} = U$, and $E(Id_U) = \emptyset$.
\end{definition}
We group all of the proper non-trivial middle parts $\tau$ into sets $\mathcal{M}_U$ based on the size of $U_{\tau}$.
\begin{definition}
Given a tuple of unspecified vertices $U = (u_1,\ldots,u_{|U|})$, we define $\mathcal{M}_U$ to be the set of proper non-trivial middle parts $\tau$ such that $U_{\tau}$ and $V_{\tau}$ have the same size as $U$. Note that $U_{\tau}$ and $V_{\tau}$ may intersect each other arbitrarily.
\end{definition}
With these definitions, we can now define our shape coefficient matrices.
\begin{definition}
Given $U \in \mathcal{I}_{mid}$, we define $\mathcal{L}_U$ to be the set of left shapes $\sigma$ such that $|V_{\sigma}| = |U|$.
\end{definition}
\begin{definition}
For each $U \in \mathcal{I}_{mid}$, we define the shape coefficient matrix $H_{Id_U}$ to be the matrix indexed by left shapes $\sigma,\sigma' \in \mathcal{L}_{U}$ with entries $H_{Id_U}(\sigma,\sigma') = \frac{1}{|U|!}\lambda_{\sigma \circ {\sigma'}^T}$
\end{definition}
\begin{definition}
For each $U \in \mathcal{I}_{mid}$, for each $\tau \in \mathcal{M}_{U}$, we define the shape coefficient matrix $H_{\tau}$ to be the matrix indexed by left shapes $\sigma,\sigma' \in \mathcal{L}_{U}$ with entries $H_{\tau}(\sigma,\sigma') = \frac{1}{(|U|!)^2}\lambda_{\sigma \circ \tau \circ {\sigma'}^T}$
\end{definition}
With these shape coefficient matrices, we have the following decomposition of $\Lambda = \sum_{\alpha}{\lambda_{\alpha}M_{\alpha}}$.
\begin{lemma}
$\Lambda = \sum_{U \in \mathcal{I}_{mid}}{\sum_{\sigma,\sigma' \in \mathcal{L}_U}{H_{Id_U}(\sigma,\sigma')M_{\sigma \circ {\sigma'}^T}}} + \sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_{U}}{\sum_{\sigma,\sigma' \in \mathcal{L}_U}{H_{\tau}(\sigma,\sigma')M_{\sigma \circ \tau \circ {\sigma'}^T}}}}$
\end{lemma}
We defer the proof of this lemma to \cref{lm:determiningcoefficientmatrices}.
For technical reasons, we need to define one more operation to handle intersection terms. We call this operation \emph{the $-\gamma,\gamma$ operation.}
\begin{definition}
Given $U,V \in \mathcal{I}_{mid}$ where $|U| > |V|$, we define $\Gamma_{U,V}$ to be the set of left parts $\gamma$ such that $|U_{\gamma}| = |U|$ and $|V_{\gamma}| = |V|$.
\end{definition}
\begin{definition}
Given $U,V \in \mathcal{I}_{mid}$ where $|U| > |V|$, a shape coefficient matrix $H_{Id_V}$, and a $\gamma \in \Gamma_{U,V}$, we define the shape coefficient matrix $H^{-\gamma,\gamma}_{Id_V}$ to be the matrix indexed by left shapes $\sigma,\sigma' \in \mathcal{L}_{U}$ with entries $H^{-\gamma,\gamma}_{Id_V}(\sigma,\sigma') = H(\sigma \circ \gamma, \sigma' \circ \gamma)$
\end{definition}
\subsection{Informal Theorem Statement}
We are now ready to state a simplified, qualitative version of our main theorem. For the full, quantitative version of our main theorem, see \cref{simplifiedmaintheorem}.
\begin{theorem}\label{informalmaintheoremstatement}
There exist functions $f(\tau): \mathcal{M}_U \rightarrow {\mathbb R}$ and $f(\gamma): \Gamma_{U,V} \rightarrow {\mathbb R}$ depending on $n$ and other parameters such that if $\Lambda = \sum_{\alpha}{\lambda_{\alpha}M_{\alpha}}$ and the following conditions hold:
\begin{enumerate}
\item For all $U \in \mathcal{I}_{mid}$, $H_{Id_U} \succeq 0$
\item For all $U \in \mathcal{I}_{mid}$ and all $\tau \in \mathcal{M}_{U}$,
\[
\left[ {\begin{array}{cc}
H_{Id_U} & f(\tau)H_{\tau} \\
f(\tau)H^T_{\tau} & H_{Id_U}
\end{array}} \right] \succeq 0
\]
\item For all $U,V \in \mathcal{I}_{mid}$ such that $|U| > |V|$ and all $\gamma \in \Gamma_{U,V}$, $H^{-\gamma,\gamma}_{Id_{V_{\gamma}}} \preceq f(\gamma)H_{Id_{U_{\gamma}}}$
\end{enumerate}
then with probability at least $1-o(1)$ over $G \sim \{ \pm 1\}^{n \choose 2}$ it holds that $\Lambda(G) \succeq 0$.
\end{theorem}
\begin{remark}
Condition $1$ of \cref{informalmaintheoremstatement} will follow from condition $2$ but we state it explicitly since it will correspond to the dominating terms of the approximate PSD decomposition. And in applications, it will be both easy to verify and will shed light on the structure of the coefficients which in turn will be useful for verifying conditions $2$ and $3$.
\end{remark}
\begin{remark}
As we will demonstrate in the remainder of this paper, our machinery works well when the coefficients $\lambda_{\alpha}$ has a polynomial decay for each vertex or edge in the shape. In many settings, this can be done quite easily by adding noise to the distribution, such as resampling part of the input, or by lowering the parameters slightly, such as $m \le n^{k/4 - \varepsilon}$ instead of $m \le n^{k/4}$. That said, it's possible to optimize many of our functions so that a significantly better bound can be obtained (say for example $m \le n^{k/4} / polylog(n)$ is potentially feasible), we do not attempt this in this work.
\end{remark}
\subsubsection{Choice of functions $f(\tau)$ and $f(\gamma)$, upto lower order terms}
In a rough sense, $f(\tau)$ measures the blow-up in the norm by using $M_{\tau}$ instead of $M_{Id_U}$ in the corresponding term of the Fourier decomposition. So we choose $f(\tau)$ to be $\norm{M_{\tau}}$, upto lower order terms. Our second condition verifies that the coefficients that arise because of this $\tau$ (which are encoded in $H_{\tau}$) are sufficiently small to overpower this norm blowup.
The fact that $\norm{M_{\tau}}$ is equal to $\tilde{O}(n^{\frac{|V(\tau)|-|U_{\tau}|}{2}})$ has been shown in previous works \cite{BHKKMP16, AMP20}. So, we choose $f(\tau)$ to be $\tilde{O}(n^{\frac{|V(\tau)|-|U_{\tau}|}{2}})$ where the problem instance is on $G_{n, 1/2}$. For problems with Gaussian or other inputs, similar forms of $f(\tau)$ can be used, which have been shown formally in the work of \cite{AMP20}. When we state the main theorem in general, we use a single $f(\tau)$ that incorporates all of these settings.
$f(\gamma)$ is a bit trickier to describe. In our analysis, we roughly collect intersection terms from the approximate PSD decomposition and charge them to shapes of the form $\sigma \circ \gamma \circ \gamma^T \circ \sigma'^T$. Using the same idea as the previous step, we charge these to shapes with trivial middle shapes. Roughly, $f(\gamma)$ for a fixed $\gamma$ upper bounds the blowup from the norms of the original shape as compared to the new intersection shape. And the third condition argues that the the original coefficients are sufficiently small to compensate for these blowups.
For problems on $G_{n, 1/2}$, we set $f(\gamma) = \tilde{O}(n^{|V(\gamma) \setminus U_{\gamma}|})$. For problems with Gaussian inputs, we choose essentially the same function, but they fall under the umbrella of generalized graph matrices, where $V(\gamma)$ and $U_{\gamma}$ are defined accordingly. Indeed, in our main theorem, we encompass both these settings with a single choice of $f(\gamma)$.
\subsection{An informal application to planted clique}
Before we move on to further definitions needed for a more complete statement of the main theorem, we present an informal example.
\begin{example}
When the pseudo-calibration method is applied to prove an SoS lower bound for the planted clique problem in $n$ node graphs with clique size $k$, as in \cite{BHKKMP16}, the matrix-valued function which results is $\Lambda = \sum_{\alpha \, : \, |V(\alpha)| \leq t}{\left(\frac{k}{n}\right)^{|V(\alpha)|}M_{\alpha}}$ where $t \approx \log(n)$.
One may then compute that the matrices $H_{Id_U}$ and $H_{\tau}$ are as follows (at least so long as $|V(\sigma)|,|V(\tau)|,|V(\sigma')| \ll t$; we ignore this detail for now).
For all $r \in [0,\frac{d}{2}]$,
\begin{enumerate}
\item For $U$ with $|U| = r$, $H_{Id_U}(\sigma,\sigma') = \left(\frac{k}{n}\right)^{|V(\sigma)| + |V(\sigma')| - r}$
\item For all proper, non-trivial middle shapes $\tau$ such that $|U_{\tau}| = |V_{\tau}| = r$,
\[
H_{\tau}(\sigma,\sigma') = \left(\frac{k}{n}\right)^{|V(\sigma)| + |V(\sigma')| + |V(\tau)|- 2r}
\]
\end{enumerate}
Defining $v_r$ to be the vector such that $v_r(\sigma) = \left(\frac{k}{n}\right)^{|V(\sigma)| - \frac{r}{2}}$, we have that
\begin{enumerate}
\item For $U$ with $|U| = r$, $H_{Id_U} = {v_{|U|}}{v^T_{|U|}}$
\item For all proper, non-trivial middle shapes $\tau$ such that $|U_{\tau}| = |V_{\tau}| = r$, $H_{\tau} = \left(\frac{k}{n}\right)^{|V(\tau)|- r}{v_r}{v^T_r}$
\item For all left parts $\gamma$, $H^{-\gamma,\gamma}_{Id_{V_{\gamma}}} = \left(\frac{k}{n}\right)^{2|V(\gamma)| - |U_{\gamma}| - |V_{\gamma}|}v_{|U_{\gamma}|}v^{T}_{|U_{\gamma}|}$
\end{enumerate}
It turns out in this setting that we can take $f(\tau)$ to be $\tilde{O}(n^{\frac{|V(\tau)|-|U_{\tau}|}{2}})$ and $f(\gamma)$ to be $\tilde{O}(n^{|V(\gamma) \setminus U_{\gamma}|})$. Thus, as long as $k \ll \sqrt{n}$,
\begin{enumerate}
\item For any $U$ and all $\tau$ such that $V_{\tau} \neq U_{\tau}$ with $|U_{\tau}| = |V_{\tau}| = |U|$, $f(\tau)H_{\tau} \preceq H_{Id_U}$.
\item For all non-trivial left parts $\gamma$, $H^{-\gamma,\gamma}_{Id_{V_{\gamma}}} \preceq f(\gamma)H_{Id_{U_{\gamma}}}$
\end{enumerate}
\end{example}
\begin{remark}\label{rmk: planted_clique_failure}
This does not quite satisfy the conditions of Theorem \ref{informalmaintheoremstatement} because there are $\tau$ such that $V_{\tau} = U_{\tau}$ but which are non-trivial because $E(\tau) \neq \emptyset$. For these $\tau$, condition 2 of Theorem \ref{informalmaintheoremstatement} fails. In order to prove their SoS lower bounds for planted clique, \cite{BHKKMP16} handle this issue by grouping together all of the $\tau$ where $V_{\tau} = U_{\tau}$ into the indicator function for whether $V_{\tau} = U_{\tau}$ is a clique.
Since this issue is specific to planted clique, we don't try to incorporate it into the machinery to avoid losing generality.
\end{remark}
For the sake of exposition, a detailed analysis with figures of all the shapes and all the coefficient matrices that appear for the degree-$4$ SoS lower bound for planted clique is given in \cref{sec: deg_4_planted_clique}.
\subsection{Generalizing the machinery}
In this section, we restricted ourselves to the case when the input is from $\{-1,1\}^{\binom{n}{2}}$ for simplicity. However, for our results we will need to handle more general types of inputs. We now briefly describe which kinds of inputs we will need to handle and how we handle them.
\begin{enumerate}
\item In general, the entries of the input may be labeled by more than $2$ indices. For example, for tensor PCA on order $3$ tensors, the entries of the input are indexed by $3$ indices. To handle this, we will have shapes which have hyperedges rather than edges.
\item In general, the entries of the input will come from a distribution $\Omega$ rather than being $\pm{1}$. To handle this, we will take an orthonormal basis $\{h_k\}$ for $\Omega$. We will then give each edge/hyperedge a label $l$ to specify which polynomial $h_l$ should be applied to that entry of the input.
\item In general, there may be $t$ different types of indices rather than just one type of index. In this case, the symmetry group will be $S_{n_1} \times \ldots \times S_{n_t}$ rather than $S_n$. To handle this, we will have shapes with different types of vertices.
\end{enumerate}
We formally make these generalizations in \cref{sec: technical_def_and_main_theorem}.
\subsection{Further definitions needed for our applications}
We will describe some more notations and definitions that will be useful to us to describe the qualitative bounds for our applications. For each of our applications, we will describe the corresponding modifications needed to the definitions already in place and present new definitions where necessary.
\subsubsection{Planted slightly denser subgraph}
Since the input is a graph $G \in \{-1, 1\}^{\binom{[n]}{2}}$, most of what we introduced already apply to this setting. To describe the moment matrix, we need to define the truncation parameter.
\begin{definition}[Truncation parameters]
For integers $D_{sos}, D_V \ge 0$, say that a shape $\alpha$ satisfies the truncation parameters $D_{sos}, D_V$ if
\begin{itemize}
\item The degrees of the monomials that $U_{\alpha}$ and $V_{\alpha}$ correspond to, are at most $\frac{D_{sos}}{2}$
\item The left part $\sigma$, the middle part $\tau$ and the right part $\sigma'$ of $\alpha$ satisfy $|V(\sigma)|, |V(\tau)|, |V(\sigma')| \le D_V$
\end{itemize}
\end{definition}
\subsubsection{Tensor PCA}
We consider the input to be a tensor $A \in {\mathbb R}^{[n]^k}$. The input entries are now sampled from the distribution $\mathcal{N}(0, 1)$ instead of $\{-1, 1\}$. So, we will work with the Hermite basis of polynomials.
Let the standard unnormalized Hermite polynomials be denoted as $h_0(x) = 1, h_1(x) = x, h_2(x) = x^2 - 1, \ldots$. Then, we work with the basis $h_a(A) := \prod_{e \in [n]^k} h_e(A_e)$ over $a \in \mathbb{N}^{[n]^k}$. Accordingly, we will modify the graphs that represent ribbons (and by extension, shapes), to have labeled hyperedges of arity $k$. So, an hyperedge $e$ with a label $t$ will correspond to the hermite polynomial $h_t(A_e)$.
\begin{definition}[Hyperedges]
Instead of standard edges, we will have labeled hyperedges of arity $k$ in the underlying graphs for our ribbons as well as shapes. The label for an hyperedge $e$, denoted $l_e$, is an element of $\mathbb{N}$ which will correspond to the Hermite polynomial being evaluated on that entry.
\end{definition}
Note that our hyperedges are ordered since the tensor $A$ is not necessarily symmetric.
For variables $x_1, \ldots, x_n$, the rows and columns of our moment matrix will now correspond to monomials of the form $\prod_{i \le n} x_i^{p_i}$ for $p_i \ge 0$. To capture this, we use the notion of index shape pieces and index shapes. Informally, we split the above monomial product into groups based on their powers and each such group will form an index shape piece.
\begin{definition}[Index shape piece]
An index shape piece $U_i= ((U_{i, 1}, \ldots, U_{i, t}), p_i)$ is a tuple of indices $(U_{i, 1}, \ldots, U_{i, t})$ along with a power $p_i \in \mathbb{N}$. Let $V(U_i)$ be the set $\{U_{i, 1}, \ldots, U_{i, t}\}$ of vertices of this index shape piece. When clear from context, we use $U_i$ instead of $V(U_i)$.
\end{definition}
If we realize $U_{i, 1}, \ldots, U_{i, t}$ to be indices $a_1, \ldots, a_t \in [n]$, then, this realization of this index shape piece corresponds to the monomial $\prod_{j \le t} x_{a_j}^{p_i}$.
\begin{definition}[Index shape]
An index shape $U$ is a set of index shape pieces $U_i$ that have different powers. Let $V(U)$ be the set of vertices $\cup_i V(U_i)$. When clear from context, we use $U$ instead of $V(U)$.
\end{definition}
Observe that each realization of an index shape corresponds to a row or column of the moment matrix.
\begin{definition}
For two index shapes $U, V$, we write $U \equiv V$ if for all powers $p$, the index shape pieces of power $p$ in $U$ and $V$ have the same length.
\end{definition}
\begin{definition}
Define ${\mathcal I}_{mid}$ to be the set of all index shapes $U$ that contain only index shape pieces of power $1$.
\end{definition}
In the definition of shapes, the distinguished set of vertices should now be replaced by index shapes.
\begin{definition}[Shapes]
Shapes are tuples $\alpha = (H_{\alpha}, U_{\alpha}, V_{\alpha})$ where $H_{\alpha}$ is a graph with hyperedges of arity $k$ and $U_{\alpha}, V_{\alpha}$ are index shapes such that $U_{\alpha}, V_{\alpha} \subseteq V(H_{\alpha})$.
\end{definition}
\begin{definition}[Proper shape]
A shape $\alpha$ is proper if it has no isolated vertices outside $U_{\alpha} \cup V_{\alpha}$, no multi-edges and all the edges have a nonzero label.
\end{definition}
To define the notion of vertex separators, we modify the notion of paths for hyperedges.
\begin{definition}[Path]
A path is a sequence of vertices $u_1, \ldots, u_t$ such that $u_i, u_{i + 1}$ are in the same hyperedge, for all $i \le t - 1$.
\end{definition}
The notions of vertex separator and decomposition into left, middle and right parts are identically defined with the above notion of hyperedges and paths. In \cref{sec: technical_def_and_main_theorem}, we will show that they are well defined.
In the definition of trivial shape $\tau$, we now require $U_{\tau} \equiv V_{\tau}$. For $U \in {\mathcal I}_{mid}$, ${\mathcal M}_U$ will be the set of proper non-trivial middle parts $\tau$ with $U_{\tau} \equiv V_{\tau} \equiv U$ and ${\mathcal L}_U$ will be the set of left parts $\sigma$ such that $V_{\sigma} \equiv U$. Similarly, for $U, V \in {\mathcal I}_{mid}$, ${\mathcal L}_{U, V}$ will be the set of left parts $\gamma$ such that $U_{\gamma} \equiv U$ and $V_{\gamma} \equiv V$.
In order to define the moment matrix, we need to truncate our shapes based on the number of vertices and the labels on our hyperedges. So, we make the following definition.
\begin{definition}[Truncation parameters]
For integers $D_{sos}, D_V, D_E \ge 0$, say that a shape $\alpha$ satisfies the truncation parameters $D_{sos}, D_V, D_E$ if
\begin{itemize}
\item The degrees of the monomials that $U_{\alpha}$ and $V_{\alpha}$ correspond to, are at most $\frac{D_{sos}}{2}$
\item The left part $\sigma$, the middle part $\tau$ and the right part $\sigma'^T$ of $\alpha$ satisfy $|V(\sigma)|, |V(\tau)|, |V(\sigma'^T)| \le D_V$
\item For each $e \in E(\alpha)$, $l_e \le D_E$.
\end{itemize}
\end{definition}
\subsubsection{Sparse PCA}
We consider the $m$ vectors $v_1, \ldots, v_m \in {\mathbb R}^d$ to be the input. Similar to Tensor PCA, we will work with the Hermite basis of polynomials since the entries are sampled from the distribution $\mathcal{N}(0, 1)$.
In particular, if we denote the unnormalized Hermite polynomials by $h_0(x) = 1, h_1(x) = x, h_2(x) = x^2 - 1, \ldots$, then, we work with the basis $h_a(v) := \prod_{i \in [m], j \in [n]} h_{a_{i, j}}(v_{i, j})$ over $a \in \mathbb{N}^{m \times n}$. To capture these bases, we will modify the graphs that represent ribbons (and by extension, shapes), to be bipartite graphs with two types of vertices, and have labeled edges that go across vertices of different types. So, an edge $(i, j)$ with label $t$ between a vertex $i$ of type $1$ and a vertex $j$ of type $2$ will correspond to $h_t(v_{i, j})$.
\begin{definition}[Vertices]
We will have two types of vertices, the vertices corresponding to the $m$ input vectors that we call type $1$ vertices and the vertices corresponding to ambient dimension of the space that we call type $2$ vertices.
\end{definition}
\begin{definition}[Edges]
Edges will go across vertices of different types, thereby forming a bipartite graph. An edge between a type $1$ vertex $i$ and a type 2 vertex $j$ corresonds to the input entry $v_{i, j}$. Each edge will have a label in $\mathbb{N}$ corresponding to the Hermite polynomial evaluated on that entry.
\end{definition}
We will have variables $x_1, \ldots, x_n$ in our SoS program, so we will work with index shape pieces and index shapes as in Tensor PCA, since the rows and columns of our moment matrix will now correspond to monomials of the form $\prod_{i \le n} x_i^{p_i}$ for $p_i \ge 0$. But since in our decompositions into left, right and middle parts, we will have type $2$ vertices as well in the vertex separators, we will define a generalized notion of index shape pieces and index shapes.
\begin{definition}[Index shape piece]
An index shape piece $U_i= ((U_{i, 1}, \ldots, U_{i, t}), t_i, p_i)$ is a tuple of indices $(U_{i, 1}, \ldots, U_{i, t})$ along a type $t_i \in \{1, 2\}$ with a power $p_i \in \mathbb{N}$. Let $V(U_i)$ be the set $\{U_{i, 1}, \ldots, U_{i, t}\}$ of vertices of this index shape piece. When clear from context, we use $U_i$ instead of $V(U_i)$.
\end{definition}
For an index shape piece $((U_{i, 1}, \ldots, U_{i, t}), t_i, p_i)$ with type $t_i = 2$, if we realize $U_{i_1}, \ldots, U_{i_t}$ to be indices $a_1, \ldots, a_t \in [n]$, then, this index shape pieces correspond this to the monomial $\prod_{j \le n} x_{a_j}^{p_i}$.
\begin{definition}[Index shape]
An index shape $U$ is a set of index shape pieces $U_i$ that have either have different types or different powers. Let $V(U)$ be the set of vertices $\cup_i V(U_i)$. When clear from context, we use $U$ instead of $V(U)$.
\end{definition}
Observe that each realization of an index shape corresponds to a row or column of the moment matrix. For our moment matrix, the only nonzero rows correspond to index shapes that have only index shape pieces of type $2$, since the only SoS variables are $x_1 \ldots, x_n$, but in order to do our analysis, we need to work with the generalized notion of index shapes that allow index shape pieces of both types.
\begin{definition}
For two index shapes $U, V$, we write $U \equiv V$ if for all types $t$ and all powers $p$, the index shape pieces of type $t$ and power $p$ in $U$ and $V$ have the same length.
\end{definition}
\begin{definition}
Define ${\mathcal I}_{mid}$ to be the set of all index shapes $U$ that contain only index shape pieces of power $1$.
\end{definition}
Since we are working with standard graphs, the notion of path and vertex separator need no modifications, but we will now use the minimum weight vertex separator instead of the minimum vertex separator where we define the weight as follows.
\begin{definition}[Weight of an index shape]
Suppose we have an index shape $U = \{U_1, U_2\} \in {\mathcal I}_{mid}$ where $U_1 = ((U_{1, 1}, \ldots, U_{1, |U_1|}), 1, 1)$ is an index shape piece of type $1$ and $U_2 = ((U_{2, 1}, \ldots, U_{2, |U_2|}), 2, 1)$ is an index shape piece of type $2$. Then, define the weight of this index shape to be $w(U) = \sqrt{m}^{|U_1|}\sqrt{n}^{|U_2|}$.
\end{definition}
We now give the modified definition of shapes.
\begin{definition}[Shapes]
Shapes are tuples $\alpha = (H_{\alpha}, U_{\alpha}, V_{\alpha})$ where $H_{\alpha}$ is a graph with two types of vertices, has labeled edges only across vertices of different types and $U_{\alpha}, V_{\alpha}$ are index shapes such that $U_{\alpha}, V_{\alpha} \subseteq V(H_{\alpha})$.
\end{definition}
\begin{definition}[Proper shape]
A shape $\alpha$ is proper if it has no isolated vertices outside $U_{\alpha} \cup V_{\alpha}$, no multi-edges and all the edges have a nonzero label.
\end{definition}
In \cref{sec: technical_def_and_main_theorem}, we will show that with this new definition of weight and shapes, any shape $\alpha$ has a unique decomposition into $\sigma \circ \tau \circ \sigma'^T$ where $\sigma, \tau, \sigma'^T$ are left, middle and right parts respectively. Here, $\tau$ may possibly be improper.
In the definition of trivial shape $\tau$, we now require $U_{\tau} \equiv V_{\tau}$. For $U \in {\mathcal I}_{mid}$, ${\mathcal M}_U$ will be the set of proper non-trivial middle parts $\tau$ with $U_{\tau} \equiv V_{\tau} \equiv U$ and ${\mathcal L}_U$ will be the set of left parts $\sigma$ such that $V_{\sigma} \equiv U$. Similarly, for $U, V \in {\mathcal I}_{mid}$, ${\mathcal L}_{U, V}$ will be the set of left parts $\gamma$ such that $U_{\gamma} \equiv U$ and $V_{\gamma} \equiv V$.
Finally, in order to define the moment matrix, we need to truncate our shapes based on the number of vertices and the labels on our edges. So, we make the following definition.
\begin{definition}[Truncation parameters]
For integers $D_{sos}, D_V, D_E \ge 0$, say that a shape $\alpha$ satisfies the truncation parameters $D_{sos}, D_V, D_E$ if
\begin{itemize}
\item The degrees of the monomials that $U_{\alpha}$ and $V_{\alpha}$ correspond to, are at most $\frac{D_{sos}}{2}$
\item The left part $\sigma$, the middle part $\tau$ and the right part $\sigma'^T$ of $\alpha$ satisfy $|V(\sigma)|, |V(\tau)|, |V(\sigma'^T)| \le D_V$
\item For each $e \in E(\alpha)$, $l_e \le D_E$.
\end{itemize}
\end{definition}
\subsubsection{Relaxing the third condition}\label{sec: hgamma_qual}
In \cref{informalmaintheoremstatement}, the third qualitative condition we'd like to show is as follows:
For all $U,V \in \mathcal{I}_{mid}$ such that $|U| > |V|$ and all $\gamma \in \Gamma_{U,V}$, $H^{-\gamma,\gamma}_{Id_{V_{\gamma}}} \preceq f(\gamma)H_{Id_{U_{\gamma}}}$.
For technical reasons, we won't be able to show this directly. To handle this, we instead work with a slight modification of $H_{Id_{U_{\gamma}}}$, a matrix $H_{\gamma}'$ that's very close to $H_{Id_{U_{\gamma}}}$. So, what we will end up showing is:
For all $U,V \in \mathcal{I}_{mid}$ such that $|U| > |V|$ and all $\gamma \in \Gamma_{U,V}$, $H^{-\gamma,\gamma}_{Id_{V_{\gamma}}} \preceq f(\gamma)H'_{\gamma}$
Let $D_V$ be the truncation parameter. A canonical choice for $H'_{\gamma}$ is to take
\begin{enumerate}
\item $H'_{\gamma}(\sigma,\sigma') = H_{Id_U}(\sigma, \sigma')$ whenever $|V(\sigma \circ \gamma)| \leq D_V$ and $|V(\sigma' \circ \gamma)| \leq D_V$.
\item $H'_{\gamma}(\sigma,\sigma') = 0$ whenever $|V(\sigma \circ \gamma)| > D_V$ or $|V(\sigma' \circ \gamma)| > D_V$.
\end{enumerate}
With this choice, $H_{\gamma}'$ is the same as $H_{Id_{U_{\gamma}}}$ upto truncation error. We will formally bound the errors in the quantitative sections after we introduce the full machinery.
\subsection{Pseudo-calibration}
We will pseudo-calibrate with respect the following pair of random and planted distributions which we denote $\nu$ and $\mu$ respectively.
\PLDSdistributions*
We assume that the input is given as $G_{i, j}$ for $i, j \in \binom{[n]}{2}$ where $G_{i, j}$ is $1$ if the edge $(i, j)$ is present in the graph and $-1$ otherwise. We work with the Fourier basis $\chi_E$ defined as $\chi_E(G) := \prod_{(i, j) \in E} G_{i, j}$. For a subset $I \subseteq [n]$, define $x_I := \prod_{i \in I} x_I$.
\begin{lemma}
Let $I \subseteq [n], E \subseteq \binom{[n]}{2}$. Then,
\[\mathbb{E}_{\mu}[x_I \chi_E(G)] = \left(\frac{k}{n}\right)^{|I \cup V(E)|} (2p - 1)^{|E|}\]
\end{lemma}
\begin{proof}
When we sample $(G, S)$ from $\mu$, we condition on whether $I \cup V(E) \subseteq S$.
\begin{align*}
\mathbb{E}_{(G, S)\sim \mu}[x_I \chi_E(G)] &= Pr_{(G, S) \sim \mu}[I \cup V(E) \subseteq S]\mathbb{E}_{(G, S) \sim \mu}[x_I\chi_E(G)|I \cup V(E) \subseteq S]\\
&\qquad + Pr_{(G, S) \sim \mu}[I \cup V(E) \not\subseteq S]\mathbb{E}_{(G, S) \sim \mu}[x_I\chi_E(G)|I \cup V(E) \not\subseteq S]
\end{align*}
We claim that the second term is $0$. In particular, $\mathbb{E}_{(G, S) \sim \mu}[x_I\chi_E(G)|I \cup V(E) \not\subseteq S] = 0$ because when $I \cup V(E) \not\subseteq S$, either $S$ doesn't contain a vertex in $I$ or an edge $(i, j) \in E$ is outside $S$. If $S$ doesn't contain a vertex in $I$, then $x_I = 0$ and hence, the quantity is $0$. And if an edge $(i, j) \in E$ is outside $S$, since this edge is sampled with probability $\frac{1}{2}$, by taking expectations, the quantity $\mathbb{E}_{(G, S) \sim \mu}[x_I\chi_E(G)|I \cup V(E) \not\subseteq S]$ is $0$.
Finally, note that $Pr_{(G, S) \sim \mu}[I \cup V(E) \subseteq S] = \left(\frac{k}{n}\right)^{|I \cup V(E)|}$ and
\[\mathbb{E}_{(G, S) \sim \mu}[x_I\chi_E(G)|I \cup V(E) \subseteq S] = \mathbb{E}_{(G, S) \sim \mu}[\chi_E(G)|V(E) \subseteq S] = (2p - 1)^{|E|}\]
The last equality follows because for each edge $e \in E$, since $e$ is present independently with probability $p$, the expected value of $\chi_e$ is $1\cdot p + (-1) \cdot (1 - p) = 2p - 1$.
\end{proof}
Define the degree of SoS to be $D_{sos} = n^{C_{sos}\varepsilon}$ for some constant $C_{sos} > 0$ that we choose later. And define the truncation parameter to be $D_V = n^{C_V\varepsilon}$ for some constant $C_V > 0$.
\begin{remk}[Choice of parameters]\label{rmk: choice_of_params1}
We first set $\varepsilon$ to be a sufficiently small constant. Based on this choice, we will set $C_V$ to be a sufficiently small constant to satisfy all the inequalities we use in our proof. Based on these choices, we can choose $C_{sos}$ to be sufficiently small to satisfy the inequalities we use.
\end{remk}
We will now describe the decomposition of the moment matrix $\Lambda$.
\begin{definition}\label{def: plds_coeffs}
If a shape $\alpha$ satisfies the following properties:
\begin{itemize}
\item $\alpha$ is proper,
\item $\alpha$ satisfies the truncation parameter $D_{sos}, D_V$.
\end{itemize}
then define \[\lambda_{\alpha} = \left(\frac{k}{n}\right)^{|V(\alpha)|} (2p - 1)^{|E(\alpha)|}\]
\end{definition}
\begin{corollary}
$\Lambda = \sum \lambda_{\alpha}M_{\alpha}$.
\end{corollary}
\subsection{Qualitative machinery bounds}
In this section, we will prove the PSD mass condition and the qualitative versions of the middle shape and intersection term bounds.
\begin{restatable}[PSD mass]{lemma}{PLDSone}\label{lem: plds_cond1}
For all $U \in {\mathcal I}_{mid}$, $H_{Id_U} \succeq 0$
\end{restatable}
While this is easy to prove directly, we would like to introduce appropriate notation so that this lemma as well as the qualitative bounds to follow are immediate.
Therefore, we state the qualitative conditions next and then prove them all together.
Now, we define the following quantities which capture the contribution of the vertices within $\tau, \gamma$ to the Fourier coefficients.
\begin{restatable}{definition}{PLDSstau}\label{def: plds_stau}
For $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, define
$S(\tau) = \left(\frac{k}{n}\right)^{|V(\tau)| - |U_{\tau}|}(2p - 1)^{|E(\tau)|}$.
And for all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and $\gamma \in \Gamma_{U, V}$, define
$S(\gamma) = \left(\frac{k}{n}\right)^{|V(\gamma)| - \frac{|U_{\gamma}| + |V_{\gamma}|}{2}}(2p - 1)^{|E(\gamma)|}$.
\end{restatable}
We can now state our qualitative bounds, which we prove shortly.
\begin{restatable}[Qualitative middle shape bounds]{lemma}{PLDStwosimplified}\label{lem: plds_cond2_simplified}
For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$,
\[
\begin{bmatrix}
\frac{S(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix}
\succeq 0
\]
\end{restatable}
In the following qualitative intersection term bounds, we use the canonical definition of $H_{\gamma}'$ from \cref{sec: hgamma_qual}.
\begin{restatable}[Qualitative intersection term bounds]{lemma}{PLDSthreesimplified}\label{lem: plds_cond3_simplified}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and all $\gamma \in \Gamma_{U, V}$,
\[\frac{|Aut(V)|}{|Aut(U)|}\cdot\frac{1}{S(\gamma)^2}H_{Id_V}^{-\gamma, \gamma} = H_{\gamma}'\]
\end{restatable}
In order to prove these bounds, we define the following quantity to capture the contribution of the vertices within $\sigma$ to the Fourier coefficients.
\begin{definition}
For a shape $\sigma\in {\mathcal L}$, define
$T(\sigma) = \left(\frac{k}{n}\right)^{|V(\sigma)| - \frac{|V_{\sigma}|}{2}}(2p - 1)^{|E(\sigma)|}$.
For $U \in {\mathcal I}_{mid}$, define $v_U$ to be the vector indexed by $\sigma \in {\mathcal L}$ such that $v_U(\sigma) = T(\sigma)$ if $\sigma \in {\mathcal L}_U$ and $0$ otherwise.
\end{definition}
The following propositions are immediate from \cref{def: plds_coeffs}.
\begin{propn}
For all $U\in {\mathcal I}_{mid}, \rho \in {\mathcal P}_U$, $H_{Id_U} = \frac{1}{|Aut(U)|}v_Uv_U^T$.
\end{propn}
\begin{propn}
For any $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, $H_{\tau} = \frac{1}{|Aut(U)|^2} S(\tau) v_Uv_U^T$.
\end{propn}
The first proposition implies that for all $U \in {\mathcal I}_{mid}$, $H_{Id_U} \succeq 0$, which is the PSD mass condition \cref{lem: plds_cond1}.
\cref{lem: plds_cond2_simplified} and \cref{lem: plds_cond3_simplified} also follow easily.
\begin{proof}[Proof of \cref{lem: plds_cond2_simplified}]
\begin{align*}
\begin{bmatrix}
\frac{S(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix} &= \begin{bmatrix}
\frac{S(\tau)}{|Aut(U)|}v_Uv_U^T & \frac{S(\tau)}{|Aut(U)|^2}v_Uv_U^T\\
\frac{S(\tau)}{|Aut(U)|^2}v_Uv_U^T & \frac{S(\tau)}{|Aut(U)|}v_Uv_U^T
\end{bmatrix} \succeq 0
\end{align*}
\end{proof}
\begin{proof}[Proof of \cref{lem: plds_cond3_simplified}]
Fix $\sigma, \sigma' \in {\mathcal L}_{U}$ such that $|V(\sigma \circ \gamma)|, |V(\sigma' \circ \gamma)| \le D_V$. Note that $|V(\sigma)| - \frac{|V_{\sigma}|}{2} + |V(\sigma')| - \frac{|V_{\sigma'}|}{2} + 2(|V(\gamma)| - \frac{|U_{\gamma}| + |V_{\gamma}|}{2}) = |V(\sigma \circ \gamma \circ \gamma^T \circ \sigma'^T)|$. Using \cref{def: plds_coeffs}, we can easily verify that $\lambda_{\sigma \circ \gamma \circ \gamma^T \circ \sigma'^T} = T(\sigma)T(\sigma') S(\gamma)^2$. Therefore, we have $H_{Id_V}^{-\gamma, \gamma}(\sigma, \sigma') = \frac{|Aut(U)|}{|Aut(V)|} S(\gamma)^2 H_{Id_U}(\sigma, \sigma')$. Since $H'_{\gamma}(\sigma, \sigma') = H_{Id_U}(\sigma, \sigma')$ whenever $|V(\sigma \circ \gamma)|, |V(\sigma' \circ \gamma)| \le D_V$, this completes the proof.
\end{proof}
\subsection{The Sum of Squares Hierarchy}\label{subsec: sos}
The SoS hierarchy is a powerful class of algorithms parameterized by it's degree. As we increase the degree, we get progressively stronger algorithms (with longer running times). It's been shown formally to obtain the state-of-the art guarantees for many problems both in the worst case and the average case setting.
For constant degree SoS, the hierarchy can be optimized in polynomial time\footnote{There is a caveat, see \cite{o2017sos}}. In general, for degree-$d$ SoS, we can solve it in $n^{O(d)}$ time. Most of our applications in this paper focus on showing hardness for the SoS hierarchy when the degree is $n^{\varepsilon}$, which corresponds to a subexponential running time.
We now formally describe the sum of squares hierarchy.
\begin{definition}[Pseudo-expectation values]\label{def: pseudoexpectation}
Given polynomial constraints $g_1 = 0$,\ldots,$g_m = 0$, degree $d$ pseudo-expectation values are a linear map $\tilde{\EE}$ from polynomials of degree at most $d$ to $\mathbb{R}$ satisfying the following conditions:
\begin{enumerate}
\item $\tilde{\EE}[1] = 1$, \label{pe:normalized}
\item $\tilde{\EE}[f \cdot g_i] = 0$ for every $i \in [m]$ and polynomial $f$ such that $\deg(f \cdot g_i) \leq d$. \label{pe:feasible}
\item $\tilde{\EE}[f^2] \geq 0$ for every polynomial $f$ such that $\deg(f^2) \le d$. \label{pe:psdness}
\end{enumerate}
\end{definition}
The intuition behind pseudo-expectation values is that the conditions on the pseudo-expectation values are conditions that would be satisfied by any actual expected values over a distribution of solutions, so optimizing over pseudo-expectation values gives a relaxation of the problem. Moreover, the conditions on pseudo-expectation values can be captured by a semidefinite program.
In particular, \cref{pe:psdness} in \cref{def: pseudoexpectation} can be reexpressed in terms of a matrix called the moment matrix.
\begin{definition}[Moment Matrix of $\tilde{\EE}$]
Given degree $d$ pseudo-expectation values $\tilde{\EE}$, define the associated moment matrix $\Lambda$ to be a matrix with rows and columns indexed by monomials $p$ and $q$ such that the entry corresponding to row $p$ and column $q$ is
\[
\Lambda[p, q] := \tilde{\EE}\left[pq\right].
\]
\end{definition}
It is easy to verify that \cref{pe:psdness} in~\cref{def: pseudoexpectation} equivalent to $\Lambda \succeq 0$.
For our setting, we are investigating the following kind of question. Given polynomial constraints $g_1 = 0$,\ldots,$g_m = 0$, can degree $d$ SoS certify that some other polynomial $h$ has value at most $c$?
If there do not exist pseudo-expectation values $\tilde{\EE}$ satisfying the conditions in~\cref{def: pseudoexpectation} such that $\tilde{\EE}[h] > c$ then degree $d$ SoS certifies that $\tilde{\EE}[h] \leq c$. More precisely, by duality, there exists a degree $d$ SoS/Positivstellensatz proof that $h \leq c$.
On the other hand, if there exist degree $d$ pseudo-expectation values $\tilde{\EE}$ satisfying the conditions in~\cref{def: pseudoexpectation} such that $\tilde{\EE}[h] > c$ then degree $d$ SoS fails to certify that $h \leq c$. This is what we need to show in order to prove SoS lower bounds on certification problems.
\begin{comment}
We will first introduce the notion of a pseudoexpectation operator for a set of polynomial constraints and then describe the Sum-of-Squares relaxation for a polynomial optimization problem.
For an integer $d$, Let ${\mathbb R}^{\le d}[x_1, \ldots, x_n]$ be the set of polynomials on $x_1 \ldots, x_n$ of degree at most $d$. We denote the degree of a polynomial
$f \in {\mathbb R}[x_1,\dots,x_n]$ by $\deg(f)$.
\begin{definition}[Pseudoexpectation operator]\label{def: pseudoexpectation}
Given polynomial constraints $g_1(x) = 0, \ldots, g_m(x) = 0$ on variables $x_1,\dots,x_n$ such that $deg(g_i) \le D$ for an integer $D \ge 0$. For an even integer $d \ge D$, a degree-$d$ pseudoexpectation operator $\tilde{\EE}$ satisfying these constraints is an operator
$\tilde{\EE} \colon {\mathbb R}^{\le d}[x_1,\dots,x_n] \rightarrow \mathbb{R}$ satisfying:
\begin{enumerate}
\item $\tilde{\EE}[1] = 1$, \label{pe:normalized}
\item $\tilde{\EE}$ is an ${\mathbb R}$-linear operator, i.e., $\tilde{\EE}[f+cg] = \tilde{\EE}[f] + c\tilde{\EE}[g]$ for every $f,g \in {\mathbb R}^{\le d}[x_1,\dots,x_n], c \in {\mathbb R}$, \label{pe:linear}
\item $\tilde{\EE}[g_i \cdot f] = 0$ for every $i = 1, \ldots, m$ and $f \in {\mathbb R}^{\le d}[x_1,\dots,x_n]$ with $\deg(f \cdot g_i) \le d$. \label{pe:feasible}
\item $\tilde{\EE}[f^2] \ge 0$ for every $f \in {\mathbb R}^{\le d}[x_1,\dots,x_n]$ with $\deg(f^2) \le d$. \label{pe:psdness}
\end{enumerate}
\end{definition}
The notion of $\tilde{\EE}$ generalizes the standard expectation operator. The idea is that optimizing over this larger space of pseudoexpectation operators can be formulated as a semidefinite programming problem and hence, will serve as a relaxation of our program that can be solved efficiently.
Formally, consider an optimization task on $n$ variables $x_1, \ldots, x_n \in {\mathbb R}$ formulated as maximizing a polynomial $f(x)$ subject to polynomial constraints $g_1(x) = 0, \ldots, g_m(x) = 0$. Suppose all the polynomials $f, g_1, \ldots, g_m$ have degree at most $D$. Then, for an even integer $d \ge D$, the degree $d$ Sum-of-Squares relaxation of this program is as follows: Over all pseudoexpectation operators $\tilde{\EE}$ satisfying $\tilde{\EE}[g_1(x)] = 0, \ldots, \tilde{\EE}[g_m(x)] = 0$, output the maximum value of $\tilde{\EE}[f(x)]$.
To prove an SoS lower bound, we need to exhibit an operator $\tilde{\EE}$ that satisfies these constraints with optimum value of $\tilde{\EE}[f(x)]$ being far away from the true optimum.
In most cases, when constructing $\tilde{\EE}$, the condition \cref{pe:psdness} in \cref{def: pseudoexpectation} is the most technically challenging condition to satisfy. It can be equivalently stated as a positive semidefiniteness condition of an associated matrix called the moment matrix.
To define the moment matrix, we need to set up some more notation.
For an integer $d \ge 0$, let ${\mathcal I}_d$ denote the set of all tuples $(t_1, \ldots, t_n)$ such that $t_i \ge 0$ for all $i$ and $\sum t_i \le d$. For $I = (t_1, \ldots, t_n) \in {\mathcal I}_d$, denote by $x^I := x_1^{t_1}x_2^{t_2} \ldots x_n^{t_n}$.
\begin{definition}[Moment Matrix of $\tilde{\EE}$]
For a degree $2d$ pseudoexpectation operator $\tilde{\EE}$ on variables $x_1, \ldots, x_n$, define the associated moment matrix $\Lambda$ to be a matrix with rows and columns indexed by ${\mathcal I}_d$ such that the entry corresponding to row $I$ and column $J$ is
\[
\Lambda[I, J] := \tilde{\EE}\left[ x^I \cdot x^J \right].
\]
\end{definition}
It is easy to verify that \cref{pe:psdness} in~\cref{def: pseudoexpectation} equivalent to $\Lambda \succeq 0$.
The machinery in this paper provides general conditions under which we can show that with high probability, $\Lambda \succeq 0$.
\end{comment}
\subsection{Pseudo-calibration}\label{subsec: pseudocalibration}
To obtain SoS integrality gaps on random instances, we need to construct valid pseudo-expectation values for a random input instance of an optimization problem. Naturally, these pseudo-expectation values will depend on the input. Psuedo-calibration is a heuristic introduced by \cite{BHKKMP16} to construct such candidate pseudo-expectation values almost mechanically by considering a planted distribution supported on instances of the problem with large objective value and using this planted distribution as a guide to construct the pseudo-expectation values.
Unfortunately, psuedo-calibration doesn't guarantee feasibility of these candidate pseudo-expectation values and the corresponding moment matrix and this has to be verified separately for different problems. This verification of feasibility is relatively easy except for the PSDness condition, which often leads to highly technical and involved analyses. The machinery attempts to mitigate this problem by providing easily verifiable conditions to prove PSDness, regardless of whether the moment matrix was obtained via pseudo-calibration.
For our applications, psuedocalibration is used to obtain a candidate pseudoexpectation operator $\tilde{\EE}$ and a corresponding moment matrix $\Lambda$
from the random vs planted problem. This will be the starting point for all our applications. Here, we do not attempt to motivate and describe it in great detail. Instead, we will briefly describe the heuristic, the intuition behind it and show an example of how to use it. A detailed treatment can be found in \cite{BHKKMP16}.
Let $\nu$ denote the random distribution and $\mu$ denote the planted distribution. Let $v$ denote the input and $x$ denote the variables for our SoS relaxation. The main idea is that, for an input $v$ sampled from $\nu$ and any polynomial $f(x)$ of degree at most the SoS degree, pseudo-calibration proposes that for any low-degree test $g(v)$, the correlation of $\tilde{\EE}[f]$ should match in the planted and random distributions. That is,
\[\mathbb{E}_{v \sim \nu}[\tilde{\EE}[f(x)]g(v)] = \mathbb{E}_{(x, v) \sim \mu}[f(x)g(v)]\]
Here, the notation $(x, v) \sim \mu$ means that in the planted distribution $\mu$, the input is $v$ and $x$ denotes the planted structure in that instance. For example, in planted clique, $x$ would be the indicator vector of the clique. If there are multiple, pick an arbitrary one.
Let ${\mathcal F}$ denote the Fourier basis of polynomials for the input $v$. By choosing different basis functions from ${\mathcal F}$ as choices for $g$ such that the degree is at most $n^{\varepsilon}$ (hence the term low-degree test), we get all lower order Fourier coefficients for $\tilde{\EE}[f(x)]$ when considered as a function of $v$. Furthermore, the higher order coefficients are set to be $0$ so that the candidate pseudoexpectation operator can be written as
\[\tilde{\EE} f(x) = \sum_{\substack{g \in {\mathcal F}\\deg(g) \le n^{\varepsilon}}} \mathbb{E}_{v \sim \nu}[\tilde{\EE}[f(x)]g(v)] g(v) = \sum_{\substack{g \in {\mathcal F}\\deg(g) \le n^{\varepsilon}}} \mathbb{E}_{(x, v) \sim \mu}[[f(x)]g(v)] g(v)\]
The coefficients $\mathbb{E}_{(x, v) \sim \mu}[[f(x)]g(v)]$ can be explicitly computed in many settings, which therefore gives an explicit pseudoexpectation operator $\tilde{\EE}$.
One intuition for pseudo-calibration is as follows. The planted distribution is usually chosen to be a maximum entropy distribution which still has the planted structure. This conforms to the philosophy that random instances are hard for SoS, such as the uniform Bernoulli distribution for planted clique or the Gaussian distribution for Tensor PCA. By conditioning on the lower order moments matching such a planted distribution, pseudo-calibration can be interpreted as sort of interpolating between the random and planted distributions by only looking at lower order Fourier characters. This intuition has proven to be successful, since pseudo-calibration been successfully exploited to construct SoS lower bounds for a wide variety of dense as well as sparse problems.
An advantage of pseudo-calibration is that this construction automatically satisfies some nice properties that the pseudoexpectation $\tilde{\EE}$ should satisfy. It's linear in $v$ by construction. For all polynomial equalities of the form $f(x) = 0$ that is satisfied in the planted distribution, it's true that $\tilde{\EE}[f(x)] = 0$. For other polynomial equalities of the form $f(x, v) = 0$ that are satisfied in the planted distribution, the equality $\tilde{\EE}[f(x, v)] = 0$ is approximately satisfied. In most cases, $\tilde{\EE}$ can be mildly adjusted to satisfy these exactly.
The condition $\tilde{\EE}[1] = 1$ is not automatically satisfied but in most applications, we usually require that $\tilde{\EE}[1] = 1 \pm \operatorname{o}(1)$. Indeed, this has been the case for all known successful applications of pseudo-calibration. Once we have this, we simply set our final pseudoexpectation operator to be $\tilde{\EE}'$ defined as $\tilde{\EE}'[f(x)] = \tilde{\EE}[f(x)] / \tilde{\EE}[1]$.
We remark that the condition $\tilde{\EE}[1] = 1 \pm \operatorname{o}(1)$ has been quite successful in predicting the right thresholds between approximability and inapproximability\cite{hop17, hop18, kunisky19notes}.
\paragraph{Example: Planted Clique}
As an warmup, we review the pseudo-calibration calculation for planted clique. Here, the random distribution $\nu$ is $G(n, \frac{1}{2})$.
The planted distribution $\mu$ is as follows. For a given integer $k$, first sample $G'$ from $G(n, \frac{1}{2})$, then choose a random subset $S$ of the vertices where each vertex is picked independently with probability $\frac{k}{n}$. For all pairs $i, j$ of distinct vertices in $S$, add the edge $(i, j)$ to the graph if not already present. Set $G$ to be the resulting graph.
The input is given by $G \in \{-1, 1\}^{\binom{[n]}{2}}$ where $G_{i, j}$ is $1$ if the edge $(i, j)$ is present and $-1$ otherwise. Let $x_1, \ldots, x_n$ be the boolean variables for our SoS program such that $x_i$ indicates if $i$ is in the clique.
\begin{definition}
Given a set of vertices $V \subseteq [n]$, define $x_V = \prod_{v \in V}{x_v}$.
\end{definition}
\begin{definition}
Given a set of possible edges $E \subseteq \binom{[n]}{2}$, define $\chi_E = (-1)^{|E \setminus E(G)|} = \prod_{(i, j) \in E}G_{i, j}$.
\end{definition}
Pseudo-calibration says that for all small $V$ and $E$,
\[
\mathbb{E}_{G \sim \nu}\left[\tilde{E}[x_V]\chi_E\right] = \mathbb{E}_{\mu}\left[x_V{\chi_E}\right]
\]
Using standard Fourier analysis, this implies that if we take
\[
c_E = \mathbb{E}_{\mu}\left[x_V{\chi_E}\right] = \left(\frac{k}{n}\right)^{|V \cup V(E)|}
\]
where $V(E)$ is the set of the endpoints of the edges in $E$, then for all small $V$,
\[
\tilde{\EE}[x_V] = \sum_{E:E \text{ is small}}{{c_E}\chi_E} = \sum_{E:E \text{ is small}}{\left(\frac{k}{n}\right)^{|V \cup V(E)|}\chi_E}
\]
Since the values of $\tilde{\EE}[x_V]$ are known, by multi-linearity, this can be naturally extended to obtain values $\tilde{\EE}[f(x)]$ for any polynomial $f$ of degree at most the SoS degree.
\subsection{Pseudo-calibration}
\begin{definition}[Slack parameter]
Define the slack parameter to be $\Delta = d^{-C_{\Delta}\varepsilon}$ for a constant $C_{\Delta} > 0$.
\end{definition}
We will pseudo-calibrate with respect the following pair of random and planted distributions which we denote $\nu$ and $\mu$ respectively.
\SPCAdistributions*
We will again work with the Hermite basis of polynomials. For $a \in \mathbb{N}^{m \times d}$ and variables $v_{i, j}$ for $i \in [m], j \in [n]$, define $h_a(v) := \prod_{i \in [m], j \in [n]} h_{a_{i, j}}(v_{i, j})$.
For a nonnegative integer $t$, define $t!!= \frac{(2t)!}{t!2^t} = 1 \times 3 \times \ldots \times t$ if $t$ is odd and $0$ otherwise.
\begin{lemma}
Let $I \in \mathbb{N}^d, a \in \mathbb{N}^{m \times d}$. For $i \in [m]$, let $e_i = \sum_{j \in [d]} a_{ij}$ and for $j \in [d]$, let $f_j = I_j + \sum_{i \in [m]} a_{ij}$. Let $c_1$ (resp. $c_2$) be the number of $i$ (resp. $j$) such that $e_i > 0$ (resp. $f_j > 0$). Then, if $e_i, f_j$ are all even, we have
\[\mathbb{E}_{\mu}[u^I h_a(v)] = \left(\frac{1}{\sqrt{k}}\right)^{|I|} \left(\frac{k}{d}\right)^{c_2} \Delta^{c_1}\prod_{i \in [m]} (e_i - 1)!! \prod_{i, j} \frac{\sqrt{\lambda}^{a_{ij}}}{\sqrt{k}^{a_{ij}}}\]
Else, $\mathbb{E}_{\mu}[u^I h_a(v)] = 0$.
\end{lemma}
\begin{proof}
$v_1, \ldots, v_m \sim \mu$ can be written as $v_i = g_i + \sqrt{\lambda} b_i l_i u$ where $g_i \sim \mathcal{N}(0, I_d), l_i \sim \mathcal{N}(0, 1), b_i \in \{0, 1\}$ where $b_i = 1$ with probability $\Delta$.
Let's analyze when the required expectation is nonzero. We can first condition on $b_i, l_i, u$ and use the fact that for a fixed $t$, $\mathbb{E}_{g \sim \mathcal{N}(0, 1)}[h_k(g + t)] = t^k$ to obtain
\begin{align*}
\mathbb{E}_{(u, l_i, b_i, g_i) \sim \mu}[u^I h_a(v)] &= \mathbb{E}_{(u, l_i, b_i) \sim \mu}[u^I\prod_{i, j}(\sqrt{\lambda}b_il_iu_j)^{a_{ij}}]\\
&= \mathbb{E}_{(u, l_i, b_i) \sim \mu}[\prod_{i \in [m]} (b_il_i)^{e_i}\prod_{j \in [d]} u_j^{f_j}] \prod_{i, j} \sqrt{\lambda}^{a_{ij}}
\end{align*}
For this to be nonzero, the set of $c_1$ indices $i$ such that $e_i > 0$, should not have been resampled otherwise $b_i = 0$, each of which happens independently with probability $\Delta$. And the set of $c_2$ indices $j$ such that $f_j > 0$ should have been such that $u_j$ is nonzero, each of which happens independently with probability $\frac{k}{d}$. Since $l_i, u_j$ are have zero expectation in $\nu$, we need $e_i, f_j$ to be even. The expectation then becomes
{\footnotesize
\begin{align*}
\Delta^{c_1} \left(\frac{k}{d}\right)^{c_2}\mathbb{E}_{(u, l_i) \sim \mu}[\prod_{i \in [m]} l_i^{e_i}\prod_{j \in [d]} u_j^{f_j}] \prod_{i, j} \sqrt{\lambda}^{a_{ij}} = \left(\frac{1}{\sqrt{k}}\right)^{|I|} \left(\frac{k}{d}\right)^{c_2} \Delta^{c_1}\prod_{i \in [m]} (e_i - 1)!! \prod_{i, j} \frac{\sqrt{\lambda}^{a_{ij}}}{\sqrt{k}^{a_{ij}}}
\end{align*}}
The last equality follows because, for each $j$ such that $u_j$ is nonzero, we have $u_j^t = (\frac{1}{\sqrt{k}})^t$ and $\mathbb{E}_{g \sim \mathcal{N}(0, 1)}[g^t] = (t - 1)!!$ if $t$ is even.
\end{proof}
Define the degree of SoS to be $D_{sos} = d^{C_{sos}\varepsilon}$ for some constant $C_{sos} > 0$ that we choose later.
Define the truncation parameters to be $D_V = d^{C_V\varepsilon}, D_E = d^{C_E\varepsilon}$ for some constants $C_V, C_E > 0$. Regarding the choice of parameters, although we are working with a different problem, \cref{rmk: choice_of_params2} directly applies.
The underlying graphs for the graph matrices have the following structure:
There will be two types of vertices - $d$ type $1$ vertices corresponding to the dimensions of the space and $m$ type $2$ vertices corresponding to the different input vectors. The shapes will correspond to bipartite graphs with edges going between across of different types.
For the analysis of Sparse PCA, we will use the following notation.
\begin{itemize}
\item For a shape $\alpha$ and type $t \in \{1, 2\}$, let $V_t(\alpha)$ denote the vertices of $V(\alpha)$ that are of type $t$. Let $|\alpha|_t = |V_t(\alpha)|$.
\item For an index shape $U$ and a vertex $i$, define $deg^{U}(i)$ as follows: If $i \in V(U)$, then it is the power of the unique index shape piece $A \in U$ such that $i \in V(A)$. Otherwise, it is $0$.
\item For an index shape $U$, define $deg(U) = \sum_{i \in V(U)} deg^U(i)$. This is also the degree of the monomial $p_U$.
\item For a shape $\alpha$ and vertex $i$ in $\alpha$, let $deg^{\alpha}(i) = \sum_{i \in e \in E(\alpha)} l_e$.
\item For any shape $\alpha$, let $deg(\alpha) = deg(U_{\alpha}) + deg(V_{\alpha})$.
\item For an index shape $U \in {\mathcal I}_{mid}$ and type $t \in \{1, 2\}$, let $U_t \in U$ denote the index shape piece of type $t$ in $U$ if it exists, otherwise define $U_t$ to be $\emptyset$. Note that this is well defined since for each type $t$, there is at most one index shape piece of type $t$ in $U$ since $U \in {\mathcal I}_{mid}$. Also, denote by $|U|_t$ the length of the tuple $U_t$.
\end{itemize}
We will now describe the decomposition of the moment matrix $\Lambda$.
\begin{definition}\label{def: spca_coeffs}
If a shape $\alpha$ satisfies the following properties:
\begin{itemize}
\item Both $U_{\alpha}$ and $V_{\alpha}$ only contain index shape pieces of type $1$,
\item $deg^{\alpha}(i) + deg^{U_{\alpha}}(i) + deg^{V_{\alpha}}(i)$ is even for all $i \in V(\alpha)$,
\item $\alpha$ is proper,
\item $\alpha$ satisfies the truncation parameters $D_{sos}, D_V, D_E$.
\end{itemize}
then define \[\lambda_{\alpha} = \left(\frac{1}{\sqrt{k}}\right)^{deg(\alpha)}\left(\frac{k}{d}\right)^{|\alpha|_1}\Delta^{|\alpha|_2} \prod_{j \in V_2(\alpha)} (deg^{\alpha}(j) - 1)!!\prod_{e \in E(\alpha)} \frac{\sqrt{\lambda}^{l_e}}{\sqrt{k}^{l_e}}\]
Otherwise, define $\lambda_{\alpha} = 0$.
\end{definition}
\begin{corollary}
$\Lambda = \sum \lambda_{\alpha}M_{\alpha}$.
\end{corollary}
\subsection{Qualitative machinery bounds}
In this section, we will prove the main PSD mass condition and obtain qualitative bounds of the other two conditions, which we will reuse in the full verification.
As in prior sections, we will state the bounds first, introduce notation and then prove them all in a unified manner.
\begin{restatable}[PSD mass]{lemma}{SPCAone}\label{lem: spca_cond1}
For all $U \in {\mathcal I}_{mid}$, $H_{Id_U} \succeq 0$
\end{restatable}
We define the following quantities to capture the contribution of the vertices within $\tau, \gamma$ to the Fourier coefficients.
\begin{restatable}{definition}{SPCAstau}\label{def: spca_stau}
For $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, if $deg^{\tau}(i)$ is even for all vertices $i \in V(\tau) \setminus U_{\tau} \setminus V_{\tau}$, define
\[S(\tau) =
\left(\frac{k}{d}\right)^{|\tau|_1 - |U_{\tau}|_1}\Delta^{|\tau|_2 - |U_{\tau}|_2} \prod_{j \in V_2(\tau) \setminus U_{\tau} \setminus V_{\tau}} (deg^{\tau}(j) - 1)!!\prod_{e \in E(\tau)} \frac{\sqrt{\lambda}^{l_e}}{\sqrt{k}^{l_e}}\]
Otherwise, define $S(\tau) = 0$. For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and $\gamma \in \Gamma_{U, V}$, if $deg^{\gamma}(i)$ is even for all vertices $i$ in $V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}$, define
\[S(\gamma) =
\left(\frac{k}{d}\right)^{|\gamma|_1 - \frac{|U_{\gamma}|_1 + |V_{\gamma}|_1}{2}}\Delta^{|\gamma|_2 - \frac{|U_{\gamma}|_2 + |V_{\gamma}|_2}{2}} \prod_{j \in V_2(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}} (deg^{\gamma}(j) - 1)!!\prod_{e \in E(\gamma)} \frac{\sqrt{\lambda}^{l_e}}{\sqrt{k}^{l_e}}\]
Otherwise, define $S(\gamma) = 0$.
\end{restatable}
For getting the best bounds, it will be convenient to discretize the Normal distribution. The following fact follows from standard results on Gaussian quadrature, see for e.g. \cite[Lemma 4.3]{diakonikolas2017statistical}.
\begin{fact}[Discretizing the Normal distribution]\label{fact: quadrature}
There is an absolute constant $C_{disc}$ such that, for any positive integer $D$, there exists a distribution ${\mathcal E}$ over the real numbers supported on $D$ points $p_1, \ldots, p_D$, such that $|p_i| \le C_{disc} \sqrt{D}$ for all $i \le D$ and
$\mathbb{E}_{g \sim {\mathcal E}}[g^t] = \mathbb{E}_{g \sim \mathcal{N}(0, 1)}[g^t]$ for all $t = 0, 1, \ldots, 2D - 1$.
\end{fact}
\begin{definition} For any shape $\tau$, suppose $U' = (U_{\tau})_2, V' = (V_{\tau})_2$ are the type $2$ vertices in $U_{\tau}, V_{\tau}$ respectively. Define
$R(\tau) = (C_{disc}\sqrt{D_E})^{\sum_{j \in U' \cup V'} deg^{\tau}(j)}$.
\end{definition}
We can now state our qualitative bounds.
\begin{restatable}[Qualitative middle shape bounds]{lemma}{SPCAtwosimplified}\label{lem: spca_cond2_simplified}
For all $U \in{\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$,
\[
\begin{bmatrix}
\frac{S(\tau)R(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)R(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix}
\succeq 0\]
\end{restatable}
We again use the canonical definition of $H_{\gamma}'$ from \cref{sec: hgamma_qual}.
\begin{restatable}[Qualitative intersection term bounds]{lemma}{SPCAthreesimplified}\label{lem: spca_cond3_simplified}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and all $\gamma \in \Gamma_{U, V}$,
\[\frac{|Aut(V)|}{|Aut(U)|}\cdot\frac{1}{S(\gamma)^2R(\gamma)^2}H_{Id_V}^{-\gamma, \gamma} \preceq H_{\gamma}'\]
\end{restatable}
\subsubsection{Proof of the PSD mass condition}
Most of the notation and analysis here are similar to the case of Tensor PCA, we just need to appropriately modify them since there are two types of vertices in the Sparse PCA application.
When we compose shapes $\sigma, \sigma'$, from \cref{def: spca_coeffs}, in order for $\lambda_{\sigma\circ \sigma'}$ to be nonzero, observe that all vertices $i$ in $\lambda_{\sigma \circ \sigma'}$ should have $deg^{\sigma \circ \sigma'}(i) + deg^{U_{\sigma \circ \sigma'}}(i) + deg^{V_{\sigma \circ \sigma'}}(i)$ to be even. To capture this notion conveniently, we again use the notion of parity vectors.
\begin{definition}
Define a parity vector $\rho$ to be a vector whose entries are in $\{0, 1\}$.
For $U\in {\mathcal I}_{mid}$, define ${\mathcal P}_U$ to be the set of parity vectors $\rho$ whose coordinates are indexed by $U_1$ followed by $U_2$.
\end{definition}
\begin{definition}
For a left shape $\sigma$, define $\rho_{\sigma} \in {\mathcal P}_{V_{\sigma}}$, called the parity vector of $\sigma$, to be the parity vector such that for each vertex $i \in V_{\sigma}$, the $i$-th entry of $\rho_{\sigma}$ is the parity of $deg^{U_{\sigma}}(i) + deg^{\sigma}(i)$, that is, $(\rho_{\sigma})_i \equiv deg^{U_{\sigma}}(i) + deg^{\sigma}(i) \pmod 2$.
For $U \in {\mathcal I}_{mid}$ and $\rho \in {\mathcal P}_U$, let ${\mathcal L}_{U, \rho}$ be the set of all left shapes $\sigma \in {\mathcal L}_U$ such that $\rho_{\sigma} = \rho$, that is, the set of all left shapes with parity vector $\rho$.
\end{definition}
For a shape $\tau$, for a $\tau$ coefficient matrix $H_{\tau}$ and parity vectors $\rho \in {\mathcal P}_{U_{\tau}}, \rho' \in {\mathcal P}_{V_{\tau}}$, define the $\tau$-coefficient matrix $H_{\tau, \rho, \rho'}$ as $H_{\tau ,\rho, \rho'}(\sigma, \sigma') = H_{\tau}(\sigma, \sigma')$ if $\sigma \in {\mathcal L}_{U_{\tau}, \rho}, \sigma' \in {\mathcal L}_{V_{\tau}, \rho'}$ and $0$ otherwise. This immediately implies the following proposition.
\begin{propn}
For any shape $\tau$ and $\tau$-coefficient matrix $H_{\tau}$, we have the equality $H_{\tau} = \sum_{\rho \in {\mathcal P}_{U_{\tau}}, \rho' \in {\mathcal P}_{V_{\tau}}} H_{\tau, \rho, \rho'}$
\end{propn}
\begin{propn}
For any $U \in {\mathcal I}_{mid}$, $H_{Id_U} = \sum_{\rho \in {\mathcal P}_U} H_{Id_U, \rho, \rho}$
\end{propn}
\begin{proof}
For any $\sigma, \sigma' \in {\mathcal L}_U$, using \cref{def: spca_coeffs}, note that in order for $H_{Id_U}(\sigma, \sigma')$ to be nonzero, we must have $\rho_{\sigma} = \rho_{\sigma'}$.
\end{proof}
We now discretize the normal distribution while matching the first $2D_E - 1$ moments.
\begin{definition}\label{def: discretized_gaussian}
Let ${\mathcal D}$ be a distribution over the real numbers obtained by setting $D = D_E$ in \cref{fact: quadrature}. So, in particular, for any $x$ sampled from ${\mathcal D}$, we have $|x| \le C_{disc}\sqrt{D_E}$ and for $t \le 2D_E - 1$, $\mathbb{E}_{x \sim {\mathcal D}}[x^t] = (t - 1)!!$.
\end{definition}
We define the following quantities to capture the contribution of the vertices within $\sigma$ to the Fourier coefficients.
\begin{definition}
For a shape $\sigma\in {\mathcal L}$, if $deg^{\sigma}(i) + deg^{U_{\sigma}}(i)$ is even for all vertices $i \in V(\sigma) \setminus V_{\sigma}$, define
\[T(\sigma) = \left(\frac{1}{\sqrt{k}}\right)^{deg(U_{\sigma})}\left(\frac{k}{d}\right)^{|\sigma|_1 - \frac{|V_{\sigma}|_1}{2}}\Delta^{|\sigma|_2 - \frac{|V_{\sigma}|_2}{2}} \prod_{j \in V_2(\sigma) \setminus V_{\sigma}} (deg^{\sigma}(j) - 1)!!\prod_{e \in E(\sigma)} \frac{\sqrt{\lambda}^{l_e}}{\sqrt{k}^{l_e}}\]
Otherwise, define $T(\sigma) = 0$.
\end{definition}
\begin{definition}
Let $U \in {\mathcal I}_{mid}$. Let $x_i$ for $i \in U_2$ be variables. Denote them collectively as $x_{U_2}$. For $\rho \in {\mathcal P}_U$, define $v_{\rho, x_{U_2}}$ to be the vector indexed by left shapes $\sigma \in {\mathcal L}$ such that the $\sigma$th entry is $T(\sigma) \prod_{i \in {U_2}} x_i^{deg^{\sigma}(i)}$ if $\sigma \in {\mathcal L}_{U, \rho}$ and $0$ otherwise.
\end{definition}
The following proposition is obvious and immediately implies the PSD mass condition.
\begin{propn}
For any $U\in {\mathcal I}_{mid}, \rho \in {\mathcal P}_U$, suppose $x_i$ for $i \in U_2$ are random variables sampled from ${\mathcal D}$. Then,
$H_{Id_U, \rho, \rho} = \frac{1}{|Aut(U)|}\mathbb{E}_{x}[v_{\rho, x_{U_2}}v_{\rho, x_{U_2}}^T]$.
\end{propn}
\begin{proof}
Observe that for $\sigma, \sigma' \in {\mathcal L}_{U, \rho}$ and $t \in \{1, 2\}$, $(|\sigma|_t - \frac{|V_{\sigma}|_t}{2}) + (|\sigma'|_t - \frac{|V_{\sigma'}|_t}{2}) = |\sigma \circ \sigma'|_t$. The result follows by verifying the conditions of \cref{def: spca_coeffs} and using \cref{def: discretized_gaussian}.
\end{proof}
\begin{proof}[Proof of the PSD mass condition \cref{lem: spca_cond1}]
We have $H_{Id_U} = \sum_{\rho \in {\mathcal P}_U} H_{Id_U, \rho, \rho} \succeq 0$ because of the above proposition.
\end{proof}
\subsubsection{Qualitative middle shape bounds}
The next proposition captures the fact that when we compose shapes $\sigma, \tau, \sigma'^T$, in order for $\lambda_{\sigma \circ \tau \circ \sigma'^T}$ to be nonzero, the parities of the degrees of the merged vertices should add up correspondingly.
\begin{propn}\label{propn: spca_coeff_2}
For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, there exist two sets of parity vectors $P_{\tau}, Q_{\tau} \subseteq {\mathcal P}_{U}$ and a bijection $\pi : P_{\tau} \rightarrow Q_{\tau}$ such that $H_{\tau} = \sum_{\rho \in P_{\tau}} H_{\tau, \rho, \pi(\rho)}$.
\end{propn}
\begin{proof}
Using \cref{def: spca_coeffs}, in order for $H_{\tau}(\sigma, \sigma')$ to be nonzero, we must have that, in $\sigma \circ \tau \circ \sigma'$, for all $i \in U_{\tau} \cup V_{\tau}$, $deg^{U_{\sigma}}(i) + deg^{U_{\sigma'}}(i) + deg^{\sigma \circ \tau \circ \sigma'^T}(i)$ must be even. In other words, for any $\rho \in {\mathcal P}_U$, there is at most one $\rho' \in {\mathcal P}_U$ such that if we take $\sigma \in {\mathcal L}_{U, \rho}, \sigma' \in {\mathcal L}_U$ with $H_{\tau}(\sigma, \sigma')$ nonzero, then the parity of $\sigma'$ is $\rho'$. Also, observe that $\rho'$ determines $\rho$. We then take $P_{\tau}$ to be the set of $\rho$ such that $\rho'$ exists, $Q_{\tau}$ to be the set of $\rho'$ and in this case, we define $\pi(\rho) = \rho'$.
\end{proof}
\begin{propn}
For any $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, suppose we take $\rho \in P_{\tau}$. Let $\pi$ be the bijection from \cref{propn: spca_coeff_2} so that $\pi(\rho) \in Q_{\tau}$. Let $U' = (U_{\tau})_2, V' = (V_{\tau})_2$ be the type $2$ vertices in $U_{\tau}, V_{\tau}$ respectively. Let $x_i$ for $i \in U' \cup V'$ be random variables independently sampled from ${\mathcal D}$. Define $x_{U'}$ (resp. $x_{V'}$) to be the subset of variables $x_i$ for $i \in U'$ (resp. $i \in V'$). Then,
\[H_{\tau, \rho, \pi(\rho)} = \frac{1}{|Aut(U)|^2} S(\tau) \mathbb{E}_x\left[v_{\rho, x_{U'}}\left(\prod_{i \in U' \cup V'} x_i^{deg^{\tau}(i)}\right)v_{\pi(\rho), x_{V'}}^T\right]\]
\end{propn}
\begin{proof}
For $\sigma \in L_{U, \rho}, \sigma' \in {\mathcal L}_{U, \pi(\rho)}$ and $t \in \{1, 2\}$, we have $(|\tau|_t - |U_{\tau}|_t) + (|\sigma|_t - \frac{|V_{\sigma}|_t}{2}) + (|\sigma'|_t - \frac{|V_{\sigma'}|_t}{2}) = |\sigma \circ \tau\circ \sigma'|_t$.
The result then follows by a straightforward verification of the conditions of \cref{def: spca_coeffs} using \cref{def: discretized_gaussian}.
\end{proof}
We are ready to show the qualitative middle shape bounds.
\begin{proof}[Proof of the qualitative middle shape bounds \cref{lem: spca_cond2_simplified}]
Let $P_{\tau}, Q_{\tau}, \pi$ be from \cref{propn: spca_coeff_2}. Let $U' = (U_{\tau})_2, V' = (V_{\tau})_2$ be the type $2$ vertices in $U_{\tau}, V_{\tau}$ respectively. Let $x_i$ for $i \in U' \cup V'$ be random variables independently sampled from ${\mathcal D}$. Define $x_{U'}$ (resp. $x_{V'}$) to be the subset of variables $x_i$ for $i \in U'$ (resp. $i \in V'$).
For $\rho \in {\mathcal P}_U$, define $W_{\rho, \rho} = \mathbb{E}_{y_{U_2} \sim {\mathcal D}^{U_2}}[v_{\rho, y_{U_2}}v_{\rho, y_{U_2}}^T]$ so that $H_{Id_U, \rho, \rho} = \frac{1}{|Aut(U)|} W_{\rho, \rho}$. Observe that $W_{\rho, \rho} = \mathbb{E}[v_{\rho, x_{U'}}v_{\rho, x_{U'}}^T] = \mathbb{E}[v_{\rho, x_{V'}}v_{\rho, x_{V'}}^T]$ because $x_{U'}$ and $x_{V'}$ are also sets of variables sampled from ${\mathcal D}$ and, $U'$, $V'$ have the same size as $U_2$ because $U_{\tau} = V_{\tau} = U$.
For $\rho, \rho' \in {\mathcal P}_U$, define $Y_{\rho, \rho'} = \mathbb{E}\left[v_{\rho, x_{U'}}\left(\prod_{i \in U' \cup V'} x_i^{deg^{\tau}(i)}\right)v_{\pi(\rho), x_{V'}}^T\right]$. Then, $H_{\tau} = \sum_{\rho \in P_{\tau}} H_{\tau, \rho, \pi(\rho)} = \frac{1}{|Aut(U)|^2}S(\tau)\sum_{\rho \in P_{\tau}} Y_{\rho, \pi(\rho)}$. We have
\begin{align*}
\begin{bmatrix}
\frac{S(\tau)R(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)R(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix}
&= \frac{S(\tau)}{|Aut(U)|^2}
\begin{bmatrix}
R(\tau)\sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho} & \sum_{\rho \in P_{\tau}} Y_{\rho, \pi(\rho)}\\
\sum_{\rho \in P_{\tau}} Y_{\rho, \pi(\rho)}^T & R(\tau)\sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho}
\end{bmatrix}
\end{align*}
Since $\frac{S(\tau)}{|Aut(U)|^2} \ge 0$, it suffices to prove that $\begin{bmatrix}
R(\tau)\sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho} & \sum_{\rho \in P_{\tau}} Y_{\rho, \pi(\rho)}\\
\sum_{\rho \in P_{\tau}} Y_{\rho, \pi(\rho)}^T & R(\tau)\sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho}
\end{bmatrix}\succeq 0$. Consider
\begin{align*}
\begin{bmatrix}
R(\tau)\sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho} & \sum_{\rho \in P_{\tau}} Y_{\rho, \pi(\rho)}\\
\sum_{\rho \in P_{\tau}} Y_{\rho, \pi(\rho)}^T & R(\tau)\sum_{\rho \in {\mathcal P}_U} W_{\rho, \rho}
\end{bmatrix} =& R(\tau)\begin{bmatrix}
\sum_{\rho \in {\mathcal P}_U \setminus P_{\tau}} W_{\rho, \rho} & 0\\
0 & \sum_{\rho \in {\mathcal P}_U \setminus Q_{\tau}} W_{\rho, \rho}
\end{bmatrix}\\
& + \begin{bmatrix}
R(\tau)\sum_{\rho \in P_{\tau}} W_{\rho, \rho} & \sum_{\rho \in P_{\tau}} Y_{\rho, \pi(\rho)}\\
\sum_{\rho \in P_{\tau}} Y_{\rho, \pi(\rho)}^T & R(\tau)\sum_{\rho \in P_{\tau}} W_{\pi(\rho), \pi(\rho)}
\end{bmatrix}\\
\end{align*}
We have $\sum_{\rho \in {\mathcal P}_U \setminus P_{\tau}} W_{\rho, \rho} = \sum_{\rho \in {\mathcal P}_U \setminus P_{\tau}} \mathbb{E}[v_{\rho, x_{U'}}v_{\rho, x_{U'}}^T] \succeq 0$. Similarly, $\sum_{\rho \in {\mathcal P}_U \setminus Q_{\tau}} W_{\rho, \rho} \succeq 0$. Also, $R(\tau) \ge 0$ and therefore, we have that the first term in the above expression,
$R(\tau)\begin{bmatrix}
\sum_{\rho \in {\mathcal P}_U \setminus P_{\tau}} W_{\rho, \rho} & 0\\
0 & \sum_{\rho \in {\mathcal P}_U \setminus Q_{\tau}} W_{\rho, \rho}
\end{bmatrix}$, is positive semidefinite. For the second term,
{\footnotesize
\begin{align*}
&\begin{bmatrix}
R(\tau)\sum_{\rho \in P_{\tau}} W_{\rho, \rho} & \sum_{\rho \in P_{\tau}} Y_{\rho, \pi(\rho)}\\
\sum_{\rho \in P_{\tau}} Y_{\rho, \pi(\rho)}^T & R(\tau)\sum_{\rho \in P_{\tau}} W_{\pi(\rho), \pi(\rho)}
\end{bmatrix}\\
&\qquad= \sum_{\rho \in P_{\tau}}
\begin{bmatrix}
R(\tau)\mathbb{E}[v_{\rho, x_{U'}}v_{\rho, x_{U'}}^T] & \mathbb{E}\left[v_{\rho, x_{U'}}\left(\prod_{i \in U' \cup V'} x_i^{deg^{\tau}(i)}\right)v_{\pi(\rho), x_{V'}}^T\right]\\
\mathbb{E}\left[v_{\rho, x_{U'}}^T\left(\prod_{i \in U' \cup V'} x_i^{deg^{\tau}(i)}\right)v_{\pi(\rho), x_{V'}}\right] & R(\tau)\mathbb{E}[v_{\pi(\rho), x_{V'}}v_{\pi(\rho), x_{V'}}^T]
\end{bmatrix}\\
&\qquad= \sum_{\rho \in P_{\tau}}\mathbb{E}
\begin{bmatrix}
R(\tau)v_{\rho, x_{U'}}v_{\rho, x_{U'}}^T & v_{\rho, x_{U'}}\left(\prod_{i \in U' \cup V'} x_i^{deg^{\tau}(i)}\right)v_{\pi(\rho), x_{V'}}^T\\
v_{\rho, x_{U'}}^T\left(\prod_{i \in U' \cup V'} x_i^{deg^{\tau}(i)}\right)v_{\pi(\rho), x_{V'}} & R(\tau)v_{\pi(\rho), x_{V'}}v_{\pi(\rho), x_{V'}}^T
\end{bmatrix}
\end{align*}}
We will prove that the term inside the expectation is positive semidefinite for each $\rho \in P_{\tau}$ and each sampling of the $x_i$ from ${\mathcal D}$, which will complete the proof. Fix $\rho \in P_{\tau}$ and any sampling of the $x_i$ from ${\mathcal D}$. Let $w_1 = v_{\rho, X_{U'}}, w_2 = v_{\pi(\rho), x_{V'}}$. Let $E = \prod_{i \in U' \cup V'} x_i^{deg^{\tau}(i)}$. We would like to prove that $\begin{bmatrix}
R(\tau)w_1w_1^T & Ew_1w_2^T\\
Ew_1^Tw_2 & R(\tau)w_2w_2^T
\end{bmatrix} \succeq 0$. For all $y$ sampled from ${\mathcal D}$, $|y| \le C_{disc}\sqrt{D_E}$ and so, $|E| \le (C_{disc}\sqrt{D_E})^{\sum_{j \in U' \cup V'} deg^{\tau}(j)} = R(\tau)$.
If $E \ge 0$, then
{\footnotesize
\begin{align*}
\begin{bmatrix}
R(\tau)w_1w_1^T & Ew_1w_2^T\\
Ew_1^Tw_2 & R(\tau)w_2w_2^T
\end{bmatrix} &= (R(\tau) - E)
\begin{bmatrix}
w_1w_1^T & 0\\
0 & w_2w_2^T
\end{bmatrix}
+ E\begin{bmatrix}
w_1w_1^T & w_1w_2^T\\
w_1^Tw_2 & w_2w_2^T
\end{bmatrix}\\
&= (R(\tau) - E)\left(
\begin{bmatrix}
w_1\\
0
\end{bmatrix}
\begin{bmatrix}
w_1 & 0
\end{bmatrix} +
\begin{bmatrix}
0\\
w_2
\end{bmatrix}
\begin{bmatrix}
0 & w_2
\end{bmatrix}\right) +
E\begin{bmatrix}
w_1\\
w_2
\end{bmatrix}
\begin{bmatrix}
w_1 & w_2
\end{bmatrix}\\
& \succeq 0
\end{align*}}
since $R(\tau) - E \ge 0$ And if $E < 0$,
{\footnotesize
\begin{align*}
\begin{bmatrix}
R(\tau)w_1w_1^T & Ew_1w_2^T\\
Ew_1^Tw_2 & R(\tau)w_2w_2^T
\end{bmatrix} &= (R(\tau) + E)
\begin{bmatrix}
w_1w_1^T & 0\\
0 & w_2w_2^T
\end{bmatrix}
- E\begin{bmatrix}
w_1w_1^T & -w_1w_2^T\\
-w_1^Tw_2 & w_2w_2^T
\end{bmatrix}\\
&= (R(\tau) + E)\left(
\begin{bmatrix}
w_1\\
0
\end{bmatrix}
\begin{bmatrix}
w_1 & 0
\end{bmatrix} +
\begin{bmatrix}
0\\
w_2
\end{bmatrix}
\begin{bmatrix}
0 & w_2
\end{bmatrix}\right)
- E\begin{bmatrix}
w_1\\
-w_2
\end{bmatrix}
\begin{bmatrix}
w_1 & -w_2
\end{bmatrix}\\
& \succeq 0
\end{align*}}
since $R(\tau) + E \ge 0$.
\end{proof}
\subsubsection{Qualitative intersection term bounds}
Just as in \cref{propn: spca_coeff_2}, the next proposition captures the fact that when we compose shapes $\sigma, \gamma, \gamma^T, \sigma'^T$, in order for $\lambda_{\sigma \circ \gamma \circ \gamma^T \circ \sigma'^T}$ to be nonzero, the parities of the degrees of the merged vertices should add up correspondingly.
Just as in the tensor PCA application, we similarly define $H_{Id_V, \rho, \rho'}^{-\gamma, \gamma}$ and $H'_{\gamma, \rho, \rho}$. The following propositions are simple and proved the same way.
\begin{propn}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$, for all $\gamma \in \Gamma_{U, V}$, there exists a set of parity vectors $P_{\gamma} \subseteq {\mathcal P}_U$ such that
$H_{Id_V}^{-\gamma, \gamma} = \sum_{\rho \in P_{\gamma}} H_{Id_V, \rho, \rho}^{-\gamma, \gamma}$.
\end{propn}
\begin{propn}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$, for $\gamma \in \Gamma_{U, V}$, $H_{\gamma}' = \sum_{\rho \in P_{\gamma}} H_{\gamma, \rho, \rho}'$.
\end{propn}
We will now define vectors which are truncations of $v_{\rho, x_{U_2}}$. This definition and the following proposition are mostly a matter of technicality and they are essentially similar to the PSD mass condition analysis.
\begin{definition}
Let $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$, and let $\gamma \in \Gamma_{U, V}$. Let $x_i$ for $i \in U_2$ be variables. Denote them collectively as $x_{U_2}$. For $\rho \in {\mathcal P}_U$, define $v_{\rho, x_{U_2}}^{-\gamma}$ to be the vector indexed by left shapes $\sigma \in {\mathcal L}$ such that the $\sigma$th entry is $v_{\rho, x_{U_2}}(\sigma)$ if $|V(\sigma \circ \gamma)| \le D_V$ and $0$ otherwise.
\end{definition}
With this, we can decompose each slice $H_{Id_V, \rho, \rho}^{-\gamma, \gamma}$.
\begin{propn}\label{lem: spca_decomp}
For any $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$, and for any $\gamma \in \Gamma_{U, V}$, suppose we take $\rho \in P_{\gamma}$. When we compose $\gamma$ with $\gamma^T$ to get $\gamma \circ \gamma^T$, let $U' = (U_{\gamma \circ \gamma^T})_2, V' = (V_{\gamma \circ \gamma^T})_2$ be the type $2$ vertices in $U_{\gamma \circ \gamma^T}, V_{\gamma \circ \gamma^T}$ respectively. And let $W'$ be the set of type $2$ vertices in $\gamma \circ \gamma^T$ that were identified in the composition when we set $V_{\gamma} = U_{\gamma}^T$. Let $x_i$ for $i \in U' \cup W' \cup V'$ be random variables independently sampled from ${\mathcal D}$. Define $x_{U'}$ (resp. $x_{V'}, x_{W'}$) to be the subset of variables $x_i$ for $i \in U'$ (resp. $i \in V', i \in W'$). Then,
\[H_{Id_V, \rho, \rho}^{-\gamma, \gamma} = \frac{1}{|Aut(V)|}S(\gamma)^2 \mathbb{E}_x\left[(v_{\rho, x_{U'}}^{-\gamma})\left(\prod_{i \in U' \cup W' \cup V'} x_i^{deg^{\gamma \circ \gamma^T}(i)}\right)(v_{\rho, x_{V'}}^{-\gamma})^T\right]\]
\end{propn}
\begin{proof}
Fix $\sigma, \sigma' \in {\mathcal L}_{U, \rho}$ such that $|V(\sigma \circ \gamma)|, |V(\sigma' \circ \gamma)| \le D_V$. Note that for $t \in \{1, 2\}$, $|\sigma|_t - \frac{|V_{\sigma}|_t}{2} + |\sigma'|_t - \frac{|V_{\sigma'}|_t}{2} + 2(|\gamma|_t - \frac{|U_{\gamma}|_t + |V_{\gamma}|_t}{2}) = |\sigma \circ \gamma \circ \gamma^T \circ \sigma'^T|_t$. We can easily verify the equality using \cref{def: spca_coeffs} and \cref{def: discretized_gaussian}.
\end{proof}
\begin{propn}
For any $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$, and for any $\gamma \in \Gamma_{U, V}$, suppose we take $\rho \in {\mathcal P}_U$. Then,
\[H'_{\gamma, \rho, \rho} = \frac{1}{|Aut(U)|}\mathbb{E}_{y_{U_2}\sim {\mathcal D}^{U_2}}\left[(v_{\rho, y_{U_2}}^{-\gamma})(v_{\rho, y_{U_2}}^{-\gamma})^T\right]\]
\end{propn}
We can finally show the qualitative intersection term bounds.
\begin{proof}[Proof of the qualitative intersection term bounds \cref{lem: spca_cond3_simplified}]
Let $U', V', W'$ be defined as in \cref{lem: spca_decomp}. We have
{\footnotesize
\begin{align*}
\frac{|Aut(V)|}{|Aut(U)|}\cdot\frac{1}{S(\gamma)^2R(\gamma)^2}H_{Id_V}^{-\gamma, \gamma} &= \sum_{\rho \in P_{\gamma}} \frac{|Aut(V)|}{|Aut(U)|}\cdot\frac{1}{S(\gamma)^2R(\gamma)^2} H_{Id_V, \rho, \rho}^{-\gamma, \gamma}\\
&= \sum_{\rho \in P_{\gamma}} \frac{1}{|Aut(U)|}\cdot\frac{1}{R(\gamma)^2} \mathbb{E}_x\left[(v_{\rho, x_{U'}}^{-\gamma})\left(\prod_{i \in U' \cup W' \cup V'} x_i^{deg^{\gamma \circ \gamma^T}(i)}\right)(v_{\rho, x_{V'}}^{-\gamma})^T\right]
\end{align*}}
We will now prove that, for all $\rho \in P_{\gamma}$,
\begin{align*}
\frac{1}{|Aut(U)|}\cdot \frac{1}{R(\gamma)^2} \mathbb{E}_x\left[(v_{\rho, x_{U'}}^{-\gamma})\left(\prod_{i \in U' \cup W' \cup V'} x_i^{deg^{\gamma \circ \gamma^T}(i)}\right)(v_{\rho, x_{V'}}^{-\gamma})^T\right] \preceq H'_{\gamma, \rho, \rho}
\end{align*}
which reduces to proving that
{\footnotesize
\begin{align*}
\frac{2}{R(\gamma)^2} \mathbb{E}_x\left[(v_{\rho, x_{U'}}^{-\gamma})\left(\prod_{i \in U' \cup W' \cup V'} x_i^{deg^{\gamma \circ \gamma^T}(i)}\right)(v_{\rho, x_{V'}}^{-\gamma})^T\right] &\preceq 2\mathbb{E}_{y_{U_2}\sim {\mathcal D}^{U_2}}\left[(v_{\rho, y_{U_2}}^{-\gamma})(v_{\rho, y_{U_2}}^{-\gamma})^T\right]\\
&= \mathbb{E}_{x}\left[(v_{\rho, x_{U'}}^{-\gamma})(v_{\rho, x_{U'}}^{-\gamma})^T + (v_{\rho, x_{V'}}^{-\gamma})(v_{\rho, x_{V'}}^{-\gamma})^T\right]
\end{align*}}
where the last equality followed from linearity of expectation and the fact that $U' \equiv V' \equiv U_2$.
Since $H_{Id_V, \rho, \rho}^{-\gamma, \gamma}$ is symmetric, we have
{\footnotesize
\[\mathbb{E}_x\left[(v_{\rho, x_{U'}}^{-\gamma})\left(\prod_{i \in U' \cup W' \cup V'} x_i^{deg^{\gamma \circ \gamma^T}(i)}\right)(v_{\rho, x_{V'}}^{-\gamma})^T\right] = \mathbb{E}_x\left[(v_{\rho, x_{V'}}^{-\gamma})\left(\prod_{i \in U' \cup W' \cup V'} x_i^{deg^{\gamma \circ \gamma^T}(i)}\right)(v_{\rho, x_{U'}}^{-\gamma})^T\right]\]}
So, it suffices to prove
{\footnotesize
\begin{align*}
\frac{1}{R(\gamma)^2}&\mathbb{E}_x\left[(v_{\rho, x_{U'}}^{-\gamma})\left(\prod_{i \in U' \cup W' \cup V'} x_i^{deg^{\gamma \circ \gamma^T}(i)}\right)(v_{\rho, x_{V'}}^{-\gamma})^T + (v_{\rho, x_{V'}}^{-\gamma})\left(\prod_{i \in U' \cup W' \cup V'} x_i^{deg^{\gamma \circ \gamma^T}(i)}\right)(v_{\rho, x_{U'}}^{-\gamma})^T\right]\\
&\preceq \mathbb{E}_{x}\left[(v_{\rho, x_{U'}}^{-\gamma})(v_{\rho, x_{U'}}^{-\gamma})^T + (v_{\rho, x_{V'}}^{-\gamma})(v_{\rho, x_{V'}}^{-\gamma})^T\right]
\end{align*}}
We will prove that for every sampling of the $x_i$ from ${\mathcal D}$, we have
{\footnotesize
\begin{align*}
\frac{1}{R(\gamma)^2}&\left((v_{\rho, x_{U'}}^{-\gamma})\left(\prod_{i \in U' \cup W' \cup V'} x_i^{deg^{\gamma \circ \gamma^T}(i)}\right)(v_{\rho, x_{V'}}^{-\gamma})^T + (v_{\rho, x_{V'}}^{-\gamma})\left(\prod_{i \in U' \cup W' \cup V'} x_i^{deg^{\gamma \circ \gamma^T}(i)}\right)(v_{\rho, x_{U'}}^{-\gamma})^T\right) \\
&\preceq (v_{\rho, x_{U'}}^{-\gamma})(v_{\rho, x_{U'}}^{-\gamma})^T + (v_{\rho, x_{V'}}^{-\gamma})(v_{\rho, x_{V'}}^{-\gamma})^T
\end{align*}}
Then, taking expectations will give the result. Indeed, fix a sampling of the $x_i$ from ${\mathcal D}$. Let $E = \prod_{i \in U' \cup W' \cup V'} x_i^{deg^{\gamma \circ \gamma^T}(i)}$ and let $w_1 = v_{\rho, x_{U'}}^{-\gamma}, w_2 = v_{\rho, x_{V'}}^{-\gamma}$. Then, the inequality we need to show is
\[\frac{E}{R(\gamma)^2}(w_1w_2^T + w_2w_1^T) \preceq w_1w_1^T + w_2w_2^T\]
Now, since $|x_i| \le C_{disc}\sqrt{D_E}$ for all $i$, we have $|E| \le \prod_{i \in U' \cup W' \cup V'} (C_{disc}\sqrt{D_E})^{deg^{\gamma \circ \gamma^T}(i)} = R(\gamma)^2$.
If $E \ge 0$, using $\frac{E}{R(\gamma)^2}(w_1 - w_2)(w_1 - w_2)^T \succeq 0$ gives
\begin{align*}
\frac{E}{R(\gamma)^2} (w_1w_2^T + w_2w_1^T) &\preceq \frac{E}{R(\gamma)^2} (w_1w_1^T + w_2w_2^T)
\preceq w_1w_1^T + w_2w_2^T
\end{align*}
since $0 \le E \le R(\gamma)^2$.
And if $E < 0$, using $\frac{-E}{R(\gamma)^2}(w_1 + w_2)(w_1 + w_2)^T \succeq 0$ gives
\begin{align*}
\frac{E}{R(\gamma)^2} (w_1w_2^T + w_2w_1^T) &\preceq \frac{-E}{R(\gamma)^2} (w_1w_1^T + w_2w_2^T)
\preceq w_1w_1^T + w_2w_2^T
\end{align*}
since $0 \le -E \le R(\gamma)^2$.
Finally, we use the fact that for all $\rho \in {\mathcal P}_U$, we have $H'_{\gamma,\rho, \rho} \succeq 0$ which can be proved the same way as the proof of \cref{lem: spca_cond1}. Therefore,
\begin{align*}
\frac{|Aut(V)|}{|Aut(U)|}\cdot\frac{1}{S(\gamma)^2R(\gamma)^2}H_{Id_V}^{-\gamma, \gamma} &\preceq \sum_{\rho \in P_{\gamma}} H'_{\gamma, \rho, \rho}
\preceq \sum_{\rho \in {\mathcal P}_U} H'_{\gamma, \rho, \rho}
= H'_{\gamma}
\end{align*}
\end{proof}
\subsection{Intuition for quantitative bounds}
In this section, we will give some intuition on the bounds needed for our main theorem \cref{thm: spca_main}, which is formally proved in \cref{sec: spca_quant}. Informally, the theorem states that when $m \le \frac{d}{\lambda^2}$ and $m \le \frac{k^2}{\lambda^2}$, then $\Lambda \succeq 0$ with high probability.
We will try and understand why the inequality $\lambda_{\sigma \circ \tau \circ \sigma'^T}^2\norm{M_{\tau}}^2 \le \lambda_{\sigma \circ \sigma^T}\lambda_{\sigma' \circ \sigma'^T}$ holds. Assume for simplicity that $d < n$ and consider the shapes in \cref{fig: sparse_pca}. The assumption $d < n$ is used in this example since otherwise, if $d > n$, the decomposition differs from what's shown in the figure.
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.9, trim={2cm 5cm 0 4cm},clip]{machinery/images/spca}
\caption{Shapes $\sigma \circ \tau_1\circ \sigma^T, \sigma \circ \tau_2 \circ \sigma^T$ and $\sigma \circ \sigma^T$. All edges have label $1$.}
\label{fig: sparse_pca}
\end{figure}
Firstly, the shape $\sigma \circ \sigma^T$ has a coefficient of $\lambda_{\sigma \circ \sigma^T} \approx \left(\frac{1}{\sqrt{k}}\right)^4\left(\frac{k}{d}\right)^2$.
The first shape $\sigma \circ \tau_1 \circ \sigma^T$ has a coefficient of $\lambda_{\sigma \circ \tau_1 \circ \sigma^T} \approx \left(\frac{1}{\sqrt{k}}\right)^4\left(\frac{k}{d}\right)^4 \left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^4$ and with high probability, upto lower order terms, $\norm{M_{\tau_1}} \le md$. So, the inequality $\lambda_{\sigma \circ \tau_1 \circ \sigma^T}^2\norm{M_{\tau_1}}^2 \le \lambda_{\sigma \circ \sigma^T}\lambda_{\sigma \circ \sigma^T}$ rearranges to $m \le \frac{d}{\lambda^2}$. But this is precisely one of the assumptions on $m$. Moreover, this also confirms that we need this assumption on $m$ in order for our strategy to go through.
The second shape $\sigma \circ \tau_2 \circ \sigma^T$ has a coefficient of $\lambda_{\sigma \circ \tau_2 \circ \sigma^T} \approx \left(\frac{1}{\sqrt{k}}\right)^4\left(\frac{k}{d}\right)^4 \left(\frac{\sqrt{\lambda}}{\sqrt{k}}\right)^8$ and with high probability, upto lower order terms, $\norm{M_{\tau_2}} \le m^2d$. So, the inequality $\lambda_{\sigma \circ \tau_2 \circ \sigma^T}^2\norm{M_{\tau_2}}^2 \le \lambda_{\sigma \circ \sigma^T}\lambda_{\sigma \circ \sigma^T}$ rearranges to $m^2 \le \frac{k^2d}{\lambda^4}$. But this is obtained simply by multiplying our assumptions on $m$, namely $m \le \frac{k^2}{\lambda^2}$ and $m \le \frac{d}{\lambda^2}$.
Moreover, consider a shape of the form $\sigma \circ \tau_3 \circ \sigma^T$ where $\tau_3$ is similar to $\tau_2$ except it has $t$ (instead of $3$) different circle vertices that are common neighbors to the top 2 square vertices. Analyzing our required inequality, we get for our strategy to go through, $m$ has to satisfy $m \le \frac{k^2}{\lambda^2} \cdot \left(\frac{d}{k^2}\right)^{\frac{2}{t + 1}}$. By taking $t$ arbitrarily large, we can see that the condition $m \le \frac{k^2}{\lambda^2}$ is needed.
So, we get that for our analysis to go through, the assumptions $m \le \frac{d}{\lambda^2}$ and $m \le \frac{k^2}{\lambda^2}$ are necessary. We will prove that in fact, these are sufficient. To do this, we use a charging argument that exploits the special structure of the shapes $\alpha$ that appear in our decomposition of $\Lambda$ and their coefficients $\lambda_{\alpha}$, as we obtained in \cref{def: spca_coeffs}. For details, see \cref{sec: spca_quant}.
\subsection{Middle shape bounds}
\begin{lemma}\label{lem: plds_charging}
Suppose $k \le n^{1/2 - \varepsilon}$. For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$,
\[\sqrt{n}^{|V(\tau)| - |U_{\tau}|}S(\tau) \le \frac{1}{n^{C_p\varepsilon|E(\tau)|}}\]
\end{lemma}
\begin{proof}
This result follows by plugging in the value of $S(\tau)$. Using $k \le n^{1/2 - \varepsilon}$,
\begin{align*}
\sqrt{n}^{|V(\tau)| - |U_{\tau}|}S(\tau) &= \sqrt{n}^{|V(\tau)| - |U_{\tau}|} \left(\frac{k}{n}\right)^{|V(\tau)| - |U_{\tau}|}(2(\frac{1}{2} + \frac{1}{2n^{C_p\varepsilon}}) -1 )^{|E(\tau)|}
\le \frac{1}{n^{C_p\varepsilon|E(\tau)|}}
\end{align*}
\end{proof}
\begin{corollary}\label{cor: plds_norm_decay}
For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$, we have \[c(\tau)B_{norm}(\tau)S(\tau) \le 1\]
\end{corollary}
\begin{proof}
Since $\tau$ is a proper middle shape, we have $w(I_{\tau}) = 0$ and $w(S_{\tau}) = w(U_{\tau})$. This implies
$n^{\frac{w(V(\tau)) + w(I_{\tau}) - w(S_{\tau})}{2}} = \sqrt{n}^{|V(\tau)| - |U_{\tau}|}$.
Since $\tau$ is proper, every vertex $i \in V(\tau) \setminus U_{\tau}$ or $i \in V(\tau) \setminus V_{\tau}$ has $deg^{\tau}(i) \ge 1$ and hence, $|V(\tau)\setminus U_{\tau}| + |V(\tau)\setminus V_{\tau}| \le 4|E(\tau)|$. Also, $q = n^{O(1) \cdot \varepsilon C_V}$. We can set $C_V$ sufficiently small so that, using \cref{lem: plds_charging},
{\footnotesize
\begin{align*}
c(\tau)&B_{norm}(\tau)S(\tau)\\
&= 100(3D_V)^{|U_{\tau}\setminus V_{\tau}| + |V_{\tau}\setminus U_{\tau}| + 2|E(\tau)|}2^{|V(\tau)\setminus (U_{\tau}\cup V_{\tau})|}
\cdot (6D_V\sqrt[4]{2eq})^{|V(\tau)\setminus U_{\tau}| + |V(\tau)\setminus V_{\tau}|}\sqrt{n}^{|V(\tau)| - |U_{\tau}|}S(\tau)\\
&\le n^{O(1) \cdot \varepsilon C_V \cdot |E(\tau)|} \cdot \sqrt{n}^{|V(\tau)| - |U_{\tau}|}S(\tau)\\
&\le n^{O(1) \cdot \varepsilon C_V \cdot |E(\tau)|} \cdot \frac{1}{n^{C_p\varepsilon|E(\tau)|}}\\
&\le 1
\end{align*}
}
\end{proof}
We can now obtain middle shape bounds.
\begin{lemma}
For all $U \in {\mathcal I}_{mid}$ and $\tau \in {\mathcal M}_U$,
\[
\begin{bmatrix}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_U} & B_{norm}(\tau) H_{\tau}\\
B_{norm}(\tau) H_{\tau}^T & \frac{1}{|Aut(U)|c(\tau)}H_{Id_U}
\end{bmatrix}
\succeq 0
\]
\end{lemma}
\begin{proof}
We have
{\footnotesize
\begin{align*}
&\begin{bmatrix}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_U} & B_{norm}(\tau)H_{\tau}\\
B_{norm}(\tau)H_{\tau}^T & \frac{1}{|Aut(U)|c(\tau)}H_{Id_U}
\end{bmatrix}\\
&\qquad = \begin{bmatrix}
\left(\frac{1}{|Aut(U)|c(\tau)} - \frac{S(\tau)B_{norm}(\tau)}{|Aut(U)|}\right)H_{Id_U} & 0\\
0 & \left(\frac{1}{|Aut(U)|c(\tau)} - \frac{S(\tau)B_{norm}(\tau)}{|Aut(U)|}\right)H_{Id_U}
\end{bmatrix}\\
&\qquad \qquad + B_{norm}(\tau)\begin{bmatrix}
\frac{S(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix}
\end{align*}}
By \cref{lem: plds_cond2_simplified}, $\begin{bmatrix}
\frac{S(\tau)}{|Aut(U)|}H_{Id_U} & H_{\tau}\\
H_{\tau}^T & \frac{S(\tau)}{|Aut(U)|}H_{Id_U}
\end{bmatrix}
\succeq 0$, so the second term above is positive semidefinite. For the first term, by \cref{lem: plds_cond1}, $H_{Id_U} \succeq 0$ and by \cref{cor: plds_norm_decay}, $\frac{1}{|Aut(U)|c(\tau)} - \frac{S(\tau)B_{norm}(\tau)}{|Aut(U)|} \ge 0$, which proves that the first term is also positive semidefinite.
\end{proof}
\subsection{Intersection term bounds}
\begin{lemma}\label{lem: plds_charging2}
Suppose $k \le n^{1/2 - \varepsilon}$. For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and for all $\gamma \in \Gamma_{U, V}$,
\[n^{w(V(\gamma)\setminus U_{\gamma})} S(\gamma)^2 \le \frac{1}{n^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + |E(\gamma)|)}}\]
for some constant $B$ that depends only on $C_p$. In particular, it is independent of $C_V$.
\end{lemma}
\begin{proof}
Since $\gamma$ is a left shape, we have $|U_{\gamma}| \ge |V_{\gamma}|$ as $V_{\gamma}$ is the unique minimum vertex separator of $\gamma$ and so, $n^{w(V(\gamma) \setminus U_{\gamma})} = n^{|V(\gamma)| - |U_{\gamma}|} \le n^{|V(\gamma)| - \frac{|U_{\gamma}| + |V_{\gamma}|}{2}}$. Also, note that $2|V(\gamma)| - |U_{\gamma}| - |V_{\gamma}| = |U_{\gamma} \setminus V_{\gamma}| + |V_{\gamma} \setminus U_{\gamma}| + 2|V(\gamma) \setminus U_{\gamma} \setminus V_{\gamma}| \ge |V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})|$. Therefore,
\begin{align*}
n^{w(V(\gamma)\setminus U_{\gamma})} S(\gamma)^2 &= n^{|V(\gamma)\setminus U_{\gamma})|} \left(\frac{k}{n}\right)^{2|V(\gamma)| - |U_{\gamma}| - |V_{\gamma}|} (2(\frac{1}{2} + \frac{1}{2n^{C_p\varepsilon}}) - 1)^{2|E(\gamma)|}\\
&\le n^{|V(\gamma)| - \frac{|U_{\gamma}| + |V_{\gamma}|}{2}}\left(\frac{1}{n^{1/2 + \varepsilon}}\right)^{2|V(\gamma)| - |U_{\gamma}| - |V_{\gamma}|}\left(\frac{1}{n^{2C_p\varepsilon}}\right)^{|E(\gamma)|}\\
&\le \left(\frac{1}{n^{\varepsilon}}\right)^{2|V(\gamma)| - |U_{\gamma}| - |V_{\gamma}|}\left(\frac{1}{n^{2C_p\varepsilon}}\right)^{|E(\gamma)|}\\
&\le \frac{1}{n^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)}}
\end{align*}
for a constant $B$ that depends only on $C_p$.
\end{proof}
We obtain intersection term bounds.
\begin{lemma}
For all $U, V \in {\mathcal I}_{mid}$ where $w(U) > w(V)$ and all $\gamma \in \Gamma_{U, V}$, \[c(\gamma)^2N(\gamma)^2B(\gamma)^2H_{Id_V}^{-\gamma, \gamma} \preceq H_{\gamma}'\]
\end{lemma}
\begin{proof}
By \cref{lem: plds_cond3_simplified}, we have
\begin{align*}
c(\gamma)^2N(\gamma)^2B(\gamma)^2H_{Id_V}^{-\gamma, \gamma} &= c(\gamma)^2N(\gamma)^2B(\gamma)^2 S(\gamma)^2 \frac{|Aut(U)|}{|Aut(V)|} H'_{\gamma}
\end{align*}
Using the same proof as in \cref{lem: plds_cond1}, we can see that $H'_{\gamma} \succeq 0$. Therefore, it suffices to prove that $c(\gamma)^2N(\gamma)^2B(\gamma)^2 S(\gamma)^2 \frac{|Aut(U)|}{|Aut(V)|} \le 1$.
Since $U, V \in {\mathcal I}_{mid}$, $|Aut(U)| = |U|!,|Aut(V)| = |V|!$. Therefore, $\frac{|Aut(U)|}{|Aut(V)|} = \frac{|U|!}{|V|!} \le D_V^{|U_{\gamma} \setminus V_{\gamma}|}$. Also, $q = n^{O(1) \cdot \varepsilon C_V}$. Let $B$ be the constant from \cref{lem: plds_charging2}. We can set $C_V$ sufficiently small so that, using \cref{lem: plds_charging2},
{\footnotesize
\begin{align*}
c(\gamma)^2N(\gamma)^2B(\gamma)^2S(\gamma)^2 \frac{|Aut(U)|}{|Aut(V)|} &\le 100^2 (3D_V)^{2|U_{\gamma}\setminus V_{\gamma}| + 2|V_{\gamma}\setminus U_{\gamma}| + 4|E(\alpha)|}4^{|V(\gamma) \setminus (U_{\gamma} \cup V_{\gamma})|}\\
&\quad\cdot (3D_V)^{4|V(\gamma)\setminus V_{\gamma}| + 2|V(\gamma)\setminus U_{\gamma}|} (6D_V\sqrt[4]{2eq})^{2|V(\gamma)\setminus U_{\gamma}| + 2|V(\gamma)\setminus V_{\gamma}|}\\
&\quad\cdot n^{w(V(\gamma)\setminus U_{\gamma})} S(\gamma)^2 \cdot D_V^{|U_\gamma \setminus V_{\gamma}|} \\
&\le n^{O(1) \cdot \varepsilon C_V \cdot (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)} \cdot n^{w(V(\gamma)\setminus U_{\gamma})} S(\gamma)^2\\
&\le n^{O(1) \cdot \varepsilon C_V \cdot (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)} \cdot \frac{1}{n^{B\varepsilon (|V(\gamma) \setminus (U_{\gamma} \cap V_{\gamma})| + \sum_{e \in E(\gamma)} l_e)}}\\
&\le 1
\end{align*}}
\end{proof}
\subsection{Truncation error bounds}
In this section, we will prove truncation error bounds.
We use the strategy and notation from \cite[Section 10]{potechin2020machinery}.
First, we will need a bound on $B_{norm}(\sigma) B_{norm}(\sigma') H_{Id_U}(\sigma, \sigma')$ that is obtained below.
\begin{lemma}\label{lem: plds_charging3}
Suppose $k \le n^{1/2 - \varepsilon}$. For all $U \in {\mathcal I}_{mid}$ and $\sigma, \sigma' \in {\mathcal L}_U$,
\[B_{norm}(\sigma) B_{norm}(\sigma') H_{Id_U}(\sigma, \sigma') \le \frac{1}{n^{0.5\varepsilon|V(\alpha)| + C_p\varepsilon|E(\alpha)|}} \left(\frac{k}{n}\right)^{|U|}
\]
\end{lemma}
\begin{proof}
Let $\alpha = \sigma \circ \sigma'$. Observe that $|V(\sigma)| + |V(\sigma')| = |V(\alpha)| + |U|$. By choosing $C_V$ sufficiently small,
{\footnotesize
\begin{align*}
B_{norm}(\sigma) B_{norm}(\sigma') H_{Id_U}(\sigma, \sigma') &= (6D_V\sqrt[4]{2eq})^{|V(\sigma)\setminus U_{\sigma}| + |V(\sigma)\setminus V_{\sigma}|} n^{\frac{w(V(\sigma)) - w(U)}{2}}\\
&\quad\cdot (6D_V\sqrt[4]{2eq})^{|V(\sigma')\setminus U_{\sigma'}| + |V(\sigma')\setminus V_{\sigma'}|} n^{\frac{w(V(\sigma')) - w(U)}{2}}\\
&\quad\cdot \frac{1}{|Aut(U)|} \left(\frac{k}{n}\right)^{|V(\alpha)|} (2(\frac{1}{2} + \frac{1}{2n^{C_p\varepsilon}}) - 1)^{|E(\alpha)|}\\
&\le n^{O(1) \cdot \varepsilon C_V \cdot |V(\alpha)|} \sqrt{n}^{|V(\sigma)| - |U|}\sqrt{n}^{|V(\sigma')| - |U|} \left(\frac{k}{n}\right)^{|V(\alpha)|}\frac{1}{n^{C_p\varepsilon|E(\alpha)|}}\\
&\le \frac{1}{n^{0.5\varepsilon|V(\alpha)| + C_p\varepsilon|E(\alpha)|}} \left(\frac{k}{n}\right)^{|U|}
\end{align*}}
\end{proof}
Now, we are ready to apply the strategy.
\begin{restatable}{lemma}{PLDSfive}\label{lem: plds_cond5}
Whenever $\norm{M_{\alpha}} \le B_{norm}(\alpha)$ for all $\alpha \in {\mathcal M}'$,
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq \frac{1}{n^{K_1D_{sos}^2}} Id_{sym}
\]
for a constant $K_1 > 0$.
\end{restatable}
\begin{proof}
For $V \in {\mathcal I}_{mid}$, we have $\lambda_V = \left(\frac{k}{n}\right)^{|V|}$. Now, we choose $w_V = \left(\frac{k}{n}\right)^{D_{sos} - |V|}$. Then, for all $\sigma \in {\mathcal L}_{V}$, we have $w_{V} \leq \frac{w_{U_{\sigma}}\lambda_{U_{\sigma}}}{|\mathcal{I}_{mid}|B_{norm}(\sigma)^2{c(\sigma)^2}{H_{Id_V}(\sigma,\sigma)}}$ which is easily verified using \cref{lem: plds_charging3}. The result now follows.
\end{proof}
\begin{restatable}{lemma}{PLDSsix}\label{lem: plds_cond6}
\[\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} \frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)} \le \frac{n^{K_2 D_{sos}}}{2^{D_V}}\]
for a constant $K_2 > 0$.
\end{restatable}
\begin{proof}
We have
\begin{align*}
&\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} \frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)} \\
&= \sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} \frac{1}{|Aut(U)|c(\gamma)}\sum_{\sigma,\sigma' \in \mathcal{L}_{U_{\gamma}}: |V(\sigma)| \leq D_V, |V(\sigma')| \leq D_V,
\atop |V(\sigma \circ \gamma)| > D_V \text{ or } |V(\sigma' \circ \gamma)| > D_V}{B_{norm}(\sigma)B_{norm}(\sigma')H_{Id_{U_{\gamma}}}(\sigma,\sigma')}
\end{align*}
The set of $\sigma, \sigma'$ that could appear in the above sum must necessarily be non-trivial and hence, $\sigma, \sigma' \in {\mathcal L}_U'$. Then,
{\footnotesize
\begin{align*}
&\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} \frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)}\\
&= \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}} {B_{norm}(\sigma)B_{norm}(\sigma')H_{Id_{U}}(\sigma,\sigma')}\sum_{\gamma \in \Gamma_{U, *}: |V(\sigma \circ \gamma)| > D_V \text{ or } |V(\sigma' \circ \gamma)| > D_V} \frac{1}{|Aut(U)|c(\gamma)}
\end{align*}}
For $\sigma \in {\mathcal L}'_{U}$, define $m_{\sigma} = D_V + 1 - |V(\sigma)| \ge 1$. This is precisely set so that for all $\gamma \in \Gamma_{U, *}$, we have $|V(\sigma \circ \gamma)| > D_V$ if and only if $|V(\gamma)| \ge |U| + m_{\sigma}$. So, for $\sigma, \sigma' \in {\mathcal L}'_U$,
\begin{align*}
\sum_{\gamma \in \Gamma_{U, *}: |V(\sigma \circ \gamma)| > D_V \text{ or } |V(\sigma' \circ \gamma)| > D_V} &\frac{1}{|Aut(U)|c(\gamma)} \\
&=
\sum_{\gamma \in \Gamma_{U, *}: |V(\gamma)| \ge |U| + \min(m_{\sigma}, m_{\sigma'})} \frac{1}{|Aut(U)|c(\gamma)}\\
&\le \frac{1}{2^{\min(m_{\sigma}, m_{\sigma'}) - 1}}
\end{align*}
Also, for $\sigma, \sigma' \in {\mathcal L}_U'$, we have $|V(\sigma \circ \sigma')| + min(m_{\sigma}, m_{\sigma'}) - 1 \ge D_V$.
Therefore,
\begin{align*}
\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} &\frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)} \\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}} {B_{norm}(\sigma)B_{norm}(\sigma')H_{Id_{U}}(\sigma,\sigma')\frac{1}{2^{\min(m_{\sigma}, m_{\sigma'}) - 1}}}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{n^{O(1) D_{sos}}}{n^{0.5\varepsilon|V(\sigma \circ \sigma')|}2^{\min(m_{\sigma}, m_{\sigma'}) - 1}}
\end{align*}
where we used \cref{lem: plds_charging3}. Using $n^{0.5\varepsilon |V(\sigma \circ \sigma')|} \ge n^{0.1\varepsilon |V(\sigma \circ \sigma')|}2^{|V(\sigma \circ \sigma')|}$,
\begin{align*}
\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} \frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)} &\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{n^{O(1) D_{sos}}}{n^{0.1\varepsilon|V(\sigma \circ \sigma')|} 2^{|V(\sigma \circ \sigma')|}2^{\min(m_{\sigma}, m_{\sigma'}) - 1}}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{n^{O(1) D_{sos}}}{n^{0.1\varepsilon|V(\sigma \circ \sigma')|} 2^{D_V}}\\
&\le \sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{n^{O(1) D_{sos}}}{D_{sos}^{D_{sos}}n^{0.1\varepsilon|V(\sigma \circ \sigma')|} 2^{D_V}}
\end{align*}
The final step will be to argue that $\sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma,\sigma' \in \mathcal{L}'_{U}}\frac{1}{D_{sos}^{D_{sos}}n^{0.1 \varepsilon|V(\sigma \circ \sigma')|}} \le 1$ which will complete the proof. But this will follow if we set $C_V$ small enough.
\end{proof}
We conclude the following.
\begin{lemma}
Whenever $\norm{M_{\alpha}} \le B_{norm}(\alpha)$ for all $\alpha \in \mathcal{M}'$,
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq 6\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\]
\end{lemma}
\begin{proof}
Choose $C_{sos}$ sufficiently small so that $\frac{1}{n^{K_1D_{sos}^2}} \ge 6\frac{n^{K_2D_{sos}}}{2^{D_V}}$ which can be satisfied by setting $C_{sos} < K_3 C_V$ for a sufficiently small constant $K_3 > 0$. Then, since $Id_{Sym} \succeq 0$, using \cref{lem: plds_cond5} and \cref{lem: plds_cond6},
\begin{align*}
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} &\succeq \frac{1}{n^{K_1D_{sos}^2}} Id_{sym}\\
&\succeq 6\frac{n^{K_2D_{sos}}}{2^{D_V}} Id_{sym}\\
&\succeq 6\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\end{align*}
\end{proof}
\subsection{General strategy to lower bound $\sum_{V \in \mathcal{I}_{mid}}{M^{fact}(H_{Id_V})}$}\label{subsec: positivity_lower_bound_strategy}
In this section, we describe how to show that $\sum_{V \in \mathcal{I}_{mid}}{M^{fact}(H_{Id_V})} \succeq {\delta}Id_{Sym}$ for some $\delta > 0$ where $\delta$ will depend on $n$ and other parameters. For now, we assume that the indices of $\Lambda$ are multilinear monomials. We will then describe the adjustments that are needed to handle non-multilinear matrix indices.
We start with a few more definitions.
\begin{definition}
For all $V \in \mathcal{I}_{mid}$ we define $Id_{Sym,V}$ to be the matrix such that
\begin{enumerate}
\item $Id_{Sym,V}(A,B) = 1$ if $A$ and $B$ both have index shape $V$.
\item Otherwise, $Id_{Sym,V}(A,B) = 0$.
\end{enumerate}
\end{definition}
\begin{proposition}
$Id_{Sym} = \sum_{V \in \mathcal{I}_{mid}}{Id_{Sym,V}}$
\end{proposition}
\begin{definition}
For all $V \in \mathcal{I}_{mid}$ we define $\lambda_V = |Aut(V)|H_{Id_V}(Id_V,Id_V)$
\end{definition}
We now describe our strategy for showing $\sum_{V \in \mathcal{I}_{mid}}{M^{fact}(H_{Id_V})} \succeq {\delta}Id_{Sym}$. The idea is as follows. We will consider the index shapes $V \in \mathcal{I}_{mid}$ from largest weight to smallest weight and we will show that for each $V \in \mathcal{I}_{mid}$, there exists a $\delta_V > 0$ such that $\sum_{V \in \mathcal{I}_{mid}}{M^{fact}(H_{Id_V})} \succeq \delta_{V}\sum_{U \in \mathcal{I}_{mid}: w(U) \geq w(V)}{Id_{Sym,U}}$.
For the first step, letting $V_{max}$ be the maximum weight index shape in $\mathcal{I}_{mid}$, $M^{fact}(H_{Id_{V_{max}}}) = \lambda_{V_{max}}Id_{Sym,V_{max}}$ because there are no non-trivial left shapes $\sigma$ such that $V_{\sigma} = V_{max}$. For other $V \in \mathcal{I}_{mid}$, $\lambda_{V}Id_{Sym,V}$ is a part of $M^{fact}(H_{Id_V})$ but $M^{fact}(H_{Id_V})$ will also contain terms of the form $H_{Id_V}(\sigma,\sigma')M_{\sigma}M_{{\sigma'}^T}$ where $U_{\sigma} \neq V$ or $U_{\sigma'} \neq V$.
We can handle the terms $H_{Id_V}(\sigma,\sigma')M_{\sigma}M_{{\sigma'}^T}$ where $U_{\sigma} \neq V$ and $U_{\sigma'} \neq V$ by bounding these terms in terms of $Id_{Sym,U_{\sigma}}$ and $Id_{Sym,U_{\sigma'}}$. Since $w(U_{\sigma}) > w(V)$ and $w(U_{\sigma'}) > w(V)$, $Id_{Sym,U_{\sigma}}$ and $Id_{Sym,U_{\sigma'}}$ are already available to us. To handle the terms $H_{Id_V}(\sigma,\sigma')M_{\sigma}M_{{\sigma'}^T}$ where exactly one of $U_{\sigma}$ and $U_{\sigma'}$ are equal to $V$, we use the following trick.
\begin{definition}
Given $V \in \mathcal{I}_{mid}$, define $H''_{Id_V}$ to be the coefficient matrix such that
\begin{enumerate}
\item If $U_{\sigma} = U_{\sigma'} = V$ then $H''_{Id_V}(\sigma,\sigma') = \frac{1}{2}H_{Id_V}(\sigma,\sigma')$
\item If exactly one of $U_{\sigma}$ and $U_{\sigma'}$ are equal to $V$ then $H''_{Id_V}(\sigma,\sigma') = H_{Id_V}(\sigma,\sigma')$
\item If $U_{\sigma} \neq V$ and $U_{\sigma'} \neq V$ then $H''_{Id_V}(\sigma,\sigma') = 2H_{Id_V}(\sigma,\sigma')$
\end{enumerate}
\end{definition}
\begin{proposition}
$M^{fact}(H''_{Id_V}) \succeq 0$
\end{proposition}
\begin{proof}
Since $H_{Id_V} \succeq 0$, $H''_{Id_V} \succeq 0$ and thus $M^{fact}(H''_{Id_V}) \succeq 0$.
\end{proof}
\begin{corollary}\label{cor: showing_positivity_corollary}
For all $V \in \mathcal{I}_{mid}$,
\[
M^{fact}(H_{Id_V}) + \sum_{\sigma,\sigma' \in \mathcal{L}_V: U_{\sigma} \neq V, U_{\sigma'} \neq V}{H_{Id_V}(\sigma,\sigma')M_{\sigma}M_{{\sigma'}^T}} \succeq \frac{\lambda_V}{2}Id_{Sym,V}
\]
\end{corollary}
\begin{proof}
Observe that
\[
M^{fact}(H_{Id_V}) - \frac{\lambda_V}{2}Id_{Sym,V} + \sum_{\sigma,\sigma' \in \mathcal{L}_V: U_{\sigma} \neq V, U_{\sigma'} \neq V}{H_{Id_V}(\sigma,\sigma')M_{\sigma}M_{{\sigma'}^T}} =
M^{fact}(H''_{Id_V}) \succeq 0
\]
\end{proof}
We now analyze the terms $ \sum_{\sigma,\sigma' \in \mathcal{L}_V: U_{\sigma} \neq V, U_{\sigma'} \neq V}{H_{Id_V}(\sigma,\sigma')M_{\sigma}M_{{\sigma'}^T}}$.
\begin{definition}
Given $U,V \in \mathcal{I}$ with $w(U) > w(V)$, we define $W(U,V)$ to be
\[
W(U,V) = \frac{1}{|Aut(U)|}\sum_{\sigma \in \mathcal{L}_{V}: U_{\sigma} = U}{\sum_{\sigma' \in \mathcal{L}_{V}: U_{\sigma'} \neq V}{B_{norm}(\sigma)B_{norm}(\sigma')H_{Id_V}(\sigma,\sigma')}}
\]
\end{definition}
\begin{lemma}\label{showingpositivitylemma}
For all $V \in \mathcal{I}_{mid}$,
\[
\sum_{\sigma,\sigma' \in \mathcal{L}_V: U_{\sigma} \neq V, U_{\sigma'} \neq V}{H_{Id_V}(\sigma,\sigma')M_{\sigma}M_{{\sigma'}^T}} \preceq \sum_{U \in \mathcal{I}_{mid}: w(U) > w(V)}{W(U,V)Id_{Sym,U}}
\]
\end{lemma}
\begin{proof}
Observe that for all $\sigma,\sigma' \in \mathcal{L}_{V}$ such that $U_{\sigma} \neq V$ and $U_{\sigma'} \neq V$, $||M_{\sigma}M_{{\sigma'}^T}|| \leq B_{norm}(\sigma)B_{norm}(\sigma')$ and thus
\[
\frac{1}{2}\left(M_{\sigma}M_{{\sigma'}^T} + M_{\sigma'}M_{{\sigma}^T}\right) \preceq \frac{1}{2}B_{norm}(\sigma)B_{norm}(\sigma')\left(M_{Id_{U_{\sigma}}} + M_{Id_{U_{\sigma'}}}\right)
\]
Summing this equation over all $\sigma,\sigma' \in \mathcal{L}_{V}$ such that $U_{\sigma} \neq V$ and $U_{\sigma'} \neq V$,
\begin{align*}
&\sum_{\sigma,\sigma' \in \mathcal{L}_V: U_{\sigma} \neq V, U_{\sigma'} \neq V}{H_{Id_U}(\sigma,\sigma')M_{\sigma}M_{{\sigma'}^T}} \preceq
\sum_{\sigma,\sigma' \in \mathcal{L}_V: U_{\sigma} \neq V, U_{\sigma'} \neq V}{B_{norm}(\sigma)B_{norm}(\sigma')M_{Id_{U_{\sigma}}}} \\
&\preceq \sum_{U \in \mathcal{I}_{mid}: w(U) > w(V)}{\sum_{\sigma \in \mathcal{L}_{V}: U_{\sigma} = U}{\sum_{\sigma' \in \mathcal{L}_{V}: V_{\sigma} \neq V}{B_{norm}(\sigma)B_{norm}(\sigma')H_{Id_U}(\sigma,\sigma')M_{Id_U}}}} \\
&\preceq \sum_{U \in \mathcal{I}_{mid}: w(U) > w(V)}|Aut(U)|W(U,V)M_{Id_U}
\end{align*}
Since all of the coefficient matrices have SOS-symmetry, we can replace $M_{Id_U}$ by $\frac{1}{|Aut(U)|}Id_{Sym,U}$ and this completes the proof.
\end{proof}
Using this lemma, we can show the following theorem:
\begin{theorem}
Let $G$ be the following directed graph:
\begin{enumerate}
\item The vertices of $G$ are the index shapes $V \in \mathcal{I}_{mid}$
\item For each $U,V \in \mathcal{I}_{mid}$ such that $w(U) > w(V)$, we have an edge $e = (V,U)$ with weight $w(e) = \frac{2W(U,V)}{\lambda_V}$
\end{enumerate}
For all $V \in \mathcal{I}_{mid}$,
\[
Id_{Sym,V} \preceq 2\sum_{U \in \mathcal{I}_{mid}: w(U) \geq w(V)}{\left(\sum_{P: P \text{ is a path from V to U in } G}{\prod_{e \in E(P)}{w(e)}}\right)\frac{1}{{\lambda_{U}}}M^{fact}(H_{Id_{U}})}
\]
\end{theorem}
\begin{proof}[Proof sketch]
This can be proved by starting with \cref{cor: showing_positivity_corollary} and iteratively applying Lemma \ref{showingpositivitylemma} and \cref{cor: showing_positivity_corollary}.
\end{proof}
\subsubsection{Handling Non-multilinear Matrix Indices*}
In order to handle non-multilinear matrix indices, we need to make a few adjustments. First, we need to modify the definition of $Id_{Sym,V}$.
\begin{definition}
For all $V \in \mathcal{I}_{mid}$ we define $Id_{Sym,V}$ to be the matrix such that
\begin{enumerate}
\item $Id_{Sym,V}(A,B) = 1$ if $A$ and $B$ have the same index shape $U$ and $U$ has the same number of each type of vertex as $V$. Note that $B$ may be a permutation of $A$ and $U$ may have different powers than $V$.
\item Otherwise, $Id_{Sym,V}(A,B) = 0$.
\end{enumerate}
\end{definition}
Observe that with this modified definition, we will still have $Id_{Sym} = \sum_{V \in \mathcal{I}_{mid}}{Id_{Sym,V}}$.
We also need to adjust how we define $\lambda_V$ as there are left shapes $\sigma$ such that $U_{\sigma}$ and $V_{\sigma}$ have the same numbers and types of vertices but $U_{\sigma}$ has different powers.
\begin{definition}
Given $V \in \mathcal{I}_{mid}$, we define $\mathcal{T}_V \subseteq \mathcal{L}_V$ to be the set of left shapes $\sigma \in \mathcal{L}_V$ such that $U_{\sigma}$ has the same numbers and types of vertices as $V$ (which automatically implies that $E(\sigma) = \emptyset$).
\end{definition}
\begin{definition}
Define $Id^{*}_{Sym,V}$ to be the matrix indexed by left shapes $\sigma,\sigma' \in \mathcal{T}_V$ such that $Id^{*}_{Sym,V}(\sigma,\sigma') = \frac{1}{|Aut(V)|}$ if $U_{\sigma} \equiv U_{\sigma'}$ and $Id^{*}_{Sym,V}(\sigma,\sigma') = 0$ otherwise.
\end{definition}
\begin{proposition}
$M^{fact}(Id^{*}_{Sym,V}) = Id_{Sym,V}$
\end{proposition}
\begin{definition}
Let $H'_{Id_V}$ be the matrix $H_{Id_V}$ restricted to rows and columns $\sigma,\sigma'$ where $\sigma,\sigma' \in \mathcal{T}_V$. We define $\lambda_V$ to be the largest constant $\lambda$ such that $H'_{Id_V} \succeq {\lambda}Id^{*}_{Sym,V}$
\end{definition}
Finally, whenever we have the condition that $U_{\sigma} \neq V$, it should instead be the condition that $U_{\sigma}$ does not have the same number of each type of vertex as $V$. With these adjustments, the same arguments go through.
\subsection{Strategy to prove positivity in our applications}
Now, we will illustrate the final ingredients needed to show positivity for our applications.
To use \cref{generalmaintheorem}, we would need to prove a statement of the form: Whenever $\norm{M_{\alpha}} \le B_{norm}(\alpha)$ for all $\alpha \in \mathcal{M}'$,
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq 6\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\]
We will sketch the strategy we use to prove this. Let $D_{sos}$ be the degree of the SoS program.
For the left hand side, we will prove a lower bound of the form: Whenever $\norm{M_{\alpha}} \le B_{norm}(\alpha)$ for all $\alpha \in {\mathcal M}'$,
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq \frac{1}{n^{K_1D_{sos}^2}} Id_{sym}
\]
for a constant $K_1 > 0$. For this, we use the strategy from \cref{subsec: positivity_lower_bound_strategy}. Then, we prove an upper bound on the right hand side of the form
\[\sum_{U\in {\mathcal I}_{mid}} \sum_{\gamma \in \Gamma_{U, *}} \frac{d_{Id_{U}}(H_{Id_{U}}, H'_{\gamma})}{|Aut(U)|c(\gamma)} \le \frac{n^{K_2D_{sos}}}{2^{D_V}}\]
for a constant $K_2 > 0$.
Now, we put these two together. Using the fact that $Id_{Sym} \succeq 0$, by simply setting $\frac{1}{n^{K_1D_{sos}^2}} > \frac{n^{K_2D_{sos}}}{2^{D_V}}$ which can be obtained by choosing $D_{sos}$ small enough, we obtain the desired result.
We will also need the following bound that says that that lets us sum over all shapes if we have sufficient decay for each vertex, then, the sum of this decay, over all shapes $\sigma \circ \sigma'$ for $\sigma, \sigma' \in {\mathcal L}_U'$, is bounded.
\begin{definition}
For $U \in {\mathcal I}_{mid}$, let ${\mathcal L}_{U}' \subset {\mathcal L}_U$ be the set of non-trivial shapes in ${\mathcal L}_U$.
\end{definition}
\begin{lemma}\label{lem: gp_sum}
Suppose $D_V = n^{C_V\varepsilon}, D_E = n^{C_E\varepsilon}$ for constants $C_V, C_E > 0$, are the truncation parameters for our shapes. For any $U \in {\mathcal I}_{mid}$,
\begin{align*}
\sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma, \sigma' \in {\mathcal L}'_U} \frac{1}{D_{sos}^{D_{sos}}n^{F \varepsilon|V(\sigma \circ \sigma')|}} \le 1
\end{align*}
for a constant $F > 0$ that depends only on $C_V, C_E$. In particular, by setting $C_V, C_E$ small enough, we can make this constant arbitrarily small.
\end{lemma}
\begin{proof}
For a given $j = |U|$, the number of ways to choose $U$ is at most $t_{max}^j$. For a given $U \in {\mathcal I}_{mid}$, we will bound the number of ways to choose $\sigma, \sigma' \in {\mathcal L}_U'$. To choose $\sigma, \sigma'\in {\mathcal L}'_U$, it is sufficient to choose
\begin{itemize}
\item The number of vertices $j_1 \ge 1$ (resp. $j_1' \ge 1$) in $U_{\sigma} \setminus V_{\sigma}$ (resp. $U_{\sigma'} \setminus V_{\sigma'}$), their types of which there are at most $t_{max}$, and their powers which have at most $D_{sos}$ choices.
\item The number of vertices $j_2$ (resp. $j_2'$) in $V(\sigma) \setminus (U_{\sigma} \cup V_{\sigma})$ (resp. $V(\sigma') \setminus (U_{\sigma'} \cup V_{\sigma'})$) and also their types, of which there are at most $t_{max}$.
\item The position of each vertex $i$ in $U_{\sigma} \setminus V_{\sigma}$ (resp. $U_{\sigma'} \setminus V_{\sigma'}$) within $U_{\sigma}$ (resp. $U_{\sigma'}$). There are at most $D_V$ choices for each vertex.
\item The subset of $U_{\sigma}$ (resp. $U_{\sigma'}$) that is in $V_{\sigma}$ (resp. $V_{\sigma'}$) and a mapping in $Aut(U_{\sigma} \cap V_{\sigma})$ (resp. $Aut(U_{\sigma'} \cap V_{\sigma'})$) that determines the matching between the vertices in $U_{\sigma} \cap V_{\sigma}$ (resp. $U_{\sigma'} \cap V_{\sigma'}$).
\item The number $j_3$ (resp. $j_3'$) of edges in $E(\sigma)$ (resp. $E(\sigma')$). and the $k$ endpoints of each edge. Each endpoint has at most $D_V$ choices.
\end{itemize}
Therefore, for all $j \ge 0, j_1, j_1' \ge 1, j_2, j_2', j_3, j_3' \ge 0$, we have
\begin{align*}
\sum_{U \in {\mathcal I}_{mid}}\sum_{\substack{\sigma, \sigma' \in {\mathcal L}'_U \\ |U_{\sigma} \setminus V_{\sigma}| = j_1, |U_{\sigma'} \setminus V_{\sigma'}| = j_1' \\ |V(\sigma) \setminus (U_{\sigma} \cup V_{\sigma})| = j_2, |V(\sigma') \setminus (U_{\sigma'} \cup V_{\sigma'})| = j_2'\\ |E(\sigma)| = j_3, |E(\sigma')| = j_3'}} \frac{1}{|Aut(U_{\sigma'} \cap V_{\sigma'})||Aut(U_{\sigma} \cap V_{\sigma})|(2t_{max})^{j + j_2 + j_2'}(D_Vt_{max}D_{sos})^{j_1 + j_1'}(D_V)^{kj_3}} \le 1
\end{align*}
This implies that
\begin{align*}
\sum_{U\in {\mathcal I}_{mid}} \sum_{\sigma, \sigma' \in {\mathcal L}'_U} \frac{1}{D_{sos}^{D_{sos}}n^{F \varepsilon|V(\sigma \circ \sigma')|}} \le 1
\end{align*}
for a constant $F > 0$ that only depends on $C_V, C_E$.
\end{proof}
\section{Omitted technical details}
\subsection{Proof that the Leftmost and Rightmost Minimum Vertex Separators are Well-defined}\label{separatorswelldefinedsection}
In this section, we give a general proof that the leftmost and rightmost minimum vertex separators are well-defined.
\begin{lemma}\label{leftrightseparatorlemma}
For any two distinct vertex separators $S_1$ and $S_2$ of $\alpha$, there exist vertex separators $S_L$ and $S_R$ of $\alpha$ such that:
\begin{enumerate}
\item $S_L$ is a vertex separator of $U_{\alpha}$ and $S_1$ and a vertex separator of $U_{\alpha}$ and $S_2$.
\item $S_R$ is a vertex separator of $S_1$ and $V_{\alpha}$ and a vertex separator of $S_2$ and $V_{\alpha}$.
\item $w(S_L) + w(S_R) \leq w(S_1) + w(S_2)$
\end{enumerate}
\end{lemma}
\begin{proof}
Take $S_L$ to be the set of vertices $v \in V(\alpha) \cap (S_1 \cup S_2)$ such that there is a path from $U_{\alpha}$ to $v$ which doesn't intersect $S_1 \cup S_2$ before reaching $v$. Similarly, take $S_R$ to be the set of vertices $v \in V(\alpha) \cap (S_1 \cup S_2)$ such that there is a path from $V_{\alpha}$ to $v$ which doesn't intersect $S_1 \cup S_2$ before reaching $v$.
Now observe that $S_L$ is a vertex separator between $U_{\alpha}$ and $S_1$. To see this, note that for any path $P$ from $U_{\alpha}$ to a vertex $v \in S_1$, either $P$ intersects $S_L$ before reaching $v$ or $P$ does not intersect $S_L$ before reaching $v$. In the latter case, $v \in S_L$. Thus, in either case, $P$ intersects $S_L$. Following similar logic, $S_L$ is also a vertex separator between $U_{\alpha}$ and $S_2$, $S_R$ is a vertex separator between $S_1$ and $V_{\alpha}$, and $S_R$ is also a vertex separator between $S_2$ and $V_{\alpha}$.
To show that $w(S_L) + w(S_R) \leq w(S_1) + w(S_2)$, observe that $w(S_L) + w(S_R) = w(S_R \cup S_R) + w(S_L \cap S_R)$ and $w(S_1) + w(S_2) = w(S_1 \cup S_2) + w(S_1 \cap S_2)$. Thus, to show that $w(S_L) + w(S_R) \leq w(S_1) + w(S_2)$, it is sufficient to show that
\begin{enumerate}
\item $S_L \cup S_R \subseteq S_1 \cup S_2$
\item $S_L \cap S_R \subseteq S_1 \cap S_2$
\end{enumerate}
For the first statement, note that by definition any vertex in $S_L \cup S_R$ must be in $S_1 \cup S_2$. For the second statement, note that if $v \in S_L \cap S_R$ then there is a path from $U_{\alpha}$ to $v$ which does not intersect any other vertices in $S_1 \cup S_2$ and there is a path from $v$ to $V_{\alpha}$ which does not intersect any other vertices in $S_1 \cup S_2$. Combining these paths, we obtain a path $P$ from $U_{\alpha}$ to $V_{\alpha}$ such that $v$ is the only vertex in $P$ which is in $S_1 \cup S_2$. This implies that $v \in S_1 \cap S_2$ as otherwise either $S_1$ or $S_2$ would not be a vertex separator between $U_{\alpha}$ and $V_{\alpha}$.
\end{proof}
\begin{corollary}
The leftmost and rightmost minimum vertex separators between $U_{\alpha}$ and $V_{\alpha}$ are well-defined.
\end{corollary}
\begin{proof}
Assume that there is no minimum leftmost vertex separator. If so, then there exists a minimum vertex separator $S_1$ between $U_{\alpha}$ and $V_{\alpha}$ such that
\begin{enumerate}
\item There does not exist a minimum vertex separator $S'$ of $\alpha$ such that $S'$ is also a minimum vertex separator of $U_{\alpha}$ and $S_1$ (otherwise we would take $S'$ rather than $S$)
\item There exists a minimum vertex separator $S_2$ of $\alpha$ such that $S'$ is not a minimum vertex separator of $U_{\alpha}$ and $S_2$ (as otherwise $S_1$ would be the leftmost minimum vertex separator)
\end{enumerate}
Now let $S_L$ and $S_R$ be the vertex separators of $\alpha$ obtained by applying Lemma \ref{leftrightseparatorlemma} to $S_1$ and $S_2$. Since $S_1$ and $S_2$ are minimum vertex separators of $\alpha$, we must have that $w(S_L) = w(S_R) = w(S_1) = w(S_2)$. Since $S_L$ is a vertex separator of $U_{\alpha}$ and $S_2$, $S_L \neq S_1$. However, $S_L$ is a vertex separator of $U_{\alpha}$ and $S_1$, which contradicts our choice of $S_1$.
Thus, there must be a leftmost minimum vertex separator of $\alpha$. Following similar logic, there must be a rightmost minimum vertex separator of $\alpha$ as well.
\end{proof}
\subsection{Proofs with Canonical Maps}\label{canonicalmapsection}
In this section, we give alternative proofs of Lemmas \ref{lm:morthsimplereexpression} and \ref{lm:singleshapeintersections} using canonical maps.
\begin{definition}[Canonical Maps]
For each shape $\alpha$ and each ribbon $R$ of shape $\alpha$, we arbitrarily choose a canonical map $\varphi_R: V(\alpha) \rightarrow V(R)$ such that $\varphi_R(H_{\alpha}) = H_R$, $\varphi_{R}(U_{\alpha}) = A_R$, and $\varphi_{R}(V_{\alpha}) = B_R$. Note that there are $|Aut(\alpha)|$ possible choices for this map.
\end{definition}
\subsection{Proof of Lemma \ref{lm:morthsimplereexpression}}
\begin{lemma}
\[
M^{orth}_{\tau}(H) = \sum_{\sigma \in Row(H),\sigma' \in Col(H)}{H(\sigma,\sigma')|Decomp(\sigma,\tau,{\sigma'}^T)|M_{\sigma \circ \tau \circ {\sigma'}^T}}
\]
\end{lemma}
\begin{proof}
Observe that there is a bijection between ribbons $R$ with shape $\sigma \circ \tau \circ {\sigma'}^T$ together with an element $\pi \in Decomp(\sigma,\tau,\sigma')$ and triples of ribbons $(R_1,R_2,R_3)$ such that
\begin{enumerate}
\item $R_1,R_2,R_3$ have shapes $\sigma$, $\tau$, and ${\sigma'}^T$, respectively.
\item $V(R_1) \cap V(R_2) = A_{R_2} = B_{R_1}$, $V(R_2) \cap V(R_3) = A_{R_3} = B_{R_2}$, and $V(R_1) \cap V(R_3) = A_{R_2} \cap B_{R_2}$
\end{enumerate}
To see this, note that given such ribbons $R_1,R_2,R_3$, the ribbon $R = R_1 \circ R_2 \circ R_3$ has shape $\sigma \circ \tau \circ {\sigma'}^T$. Further note that we have two bijective maps from $V(\sigma \circ \tau \circ {\sigma'}^T)$ to $V(R)$. The first map is $\varphi_R$. The second map is $\varphi_{R_1} \circ \varphi_{R_2} \circ \varphi_{R_3}$. Using this, we can take $\pi = \varphi^{-1}_R(\varphi_{R_1} \circ \varphi_{R_2} \circ \varphi_{R_3})$
Conversely, given a ribbon $R$ of shape $\sigma \circ \tau \circ {\sigma'}^T$ and an element $\pi \in Decomp(\sigma,\tau,\sigma')$, let $R_1 = \varphi_R(\pi(\sigma))$, let $R_2 = \varphi_R(\pi(\tau))$, and let $R_3 = \varphi_R(\pi({\sigma'}^T))$. Note that this is well defined because for any element $\pi' \in Aut(\sigma) \times Aut(\tau) \times Aut({\sigma'}^T)$, $\varphi_R(\pi\pi'(\sigma)) = \varphi_R(\pi(\pi'(\sigma))) = \varphi_R(\pi(\sigma))$. Similarly, $\varphi_R(\pi\pi'(\tau)) = \varphi_R(\pi(\tau))$ and $\varphi_R(\pi\pi'({\sigma'}^T)) = \varphi_R(\pi({\sigma'}^T))$.
To confirm that this is bijection, we have to show that these two maps are inverses of each other. Given $R_1$, $R_2$, and $R_3$, applying these two maps gives us ribbons $R'_1 = \varphi_R\varphi^{-1}_R(\varphi_{R_1} \circ \varphi_{R_2} \circ \varphi_{R_3})(H_{\sigma}) = R_1$, $R'_2 = \varphi_R\varphi^{-1}_R(\varphi_{R_1} \circ \varphi_{R_2} \circ \varphi_{R_3})(H_{\tau}) = R_2$, and $R'_3 = \varphi_R\varphi^{-1}_R(\varphi_{R_1} \circ \varphi_{R_2} \circ \varphi_{R_3})(H_{{\sigma'}^T}) = R_3$. Conversely, given $R$ and an element $\pi \in Decomp(\sigma,\tau,\sigma')$ (which we represent by an element $\pi \in Aut(\sigma \circ \tau \circ {\sigma'}^T)$), applying these two maps gives us the ribbon
\[
R' = \varphi_R(\pi(\sigma)) \circ \varphi_R(\pi(\tau)) \circ \varphi_R(\pi({\sigma'}^T)) = {\varphi_R}\pi(\sigma \circ \tau \circ {\sigma'}^T) = R
\]
and gives us the map
\[
\varphi^{-1}_R(\varphi_{\varphi_R(\pi(\sigma))} \circ \varphi_{\varphi_R(\pi(\tau))} \circ \varphi_{\varphi_R(\pi({\sigma'}^T))})
\]
Now observe that both ${\varphi_R}\pi$ and $\varphi_{\varphi_R(\pi(\sigma))}$ give bijective maps from $\sigma$ to the ribbon ${\varphi_R}\pi(\sigma)$ so $\varphi^{-1}_{\varphi_R(\pi(\sigma))}{\varphi_R}\pi \in Aut(\sigma)$. Following similar logic for $\tau$ and ${\sigma'}^T$, in $Decomp(\sigma,\tau,\sigma')$ this map is equivalent to $
\varphi^{-1}_R({\varphi_R}\pi) = \pi$
\end{proof}
\subsection{Proof of Lemma \ref{lm:singleshapeintersections}}
\begin{definition}[Rigorous definition of intersection patterns]
We define an intersection pattern $P$ on composable shapes $\gamma,\tau,{\gamma'}^T$ to consist of the shape $\gamma \circ \tau \circ {\gamma'}^T$ together with a non-empty set of constraint edges $E(P)$ on $V(\gamma \circ \tau \circ {\gamma'}^T)$ such that:
\begin{enumerate}
\item For all vertices $u,v,w \in V(\gamma \circ \tau \circ {\gamma'}^T)$, if $(u,v),(v,w) \in E(P)$ then $(u,w) \in E(P)$
\item $E(P)$ does not contain a path between two vertices of $\gamma$, two vertices of $\tau$, or two vertices of ${\gamma'}^T$. This ensures that when we consider $\gamma,\tau,\gamma'$ individually, their vertices are distinct.
\item Defining $V_{*}(\gamma) \subseteq V(\gamma)$ to be the vertices of $\gamma$ which are incident to an edge in $E(P)$, $U_{\gamma}$ is the unique minimum-weight vertex separator between $U_{\gamma}$ and $V_{*}(\gamma) \cup V_{\gamma}$
\item Similarly, defining $V_{*}({\gamma'}^T) \subseteq V({\gamma'}^T)$ to be the vertices of ${\gamma'}^T$ which are incident to an edge in $E(P)$, $V_{{\gamma'}^T}$ is the unique minimum-weight vertex separator between $V_{*}({\gamma'}^T) \cup U_{{\gamma'}^T}$ and $V_{U_{{\gamma'}^T}}$
\item[5.*] All edges in $E(P)$ are between vertices of the same type.
\end{enumerate}
\end{definition}
\begin{definition}
We say that two intersection patterns $P,P'$ on shapes $\gamma,\tau,{\gamma'}^T$ are equivalent (which we write as $P \equiv P'$) if there is an automorphism $\pi \in Aut(\gamma) \times Aut(\tau) \times Aut({\gamma'}^T)$ such that $\pi(P) = P'$ (i.e. if $E(P)$ and $E(P')$ are the constraint edges for $P$ and $P'$ respectively then $\pi(E(P)) = E(P')$).
\end{definition}
\begin{definition}
Given composable shapes $\gamma,\tau,{\gamma'}^T$, we define $\mathcal{P}_{\gamma,\tau,{\gamma'}^T}$ to be the set of all possible intersection patterns $P$ on $\gamma,\tau,{\gamma'}^T$ (up to equivalence)
\end{definition}
\begin{definition}
Given composable (but not properly composable) ribbons $R_1$, $R_2$, $R_3$ of shapes $\gamma, \tau, {\gamma'}$, we define the intersection pattern $P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}$ induced by $R_1,R_2,R_3$ as follows:
\begin{enumerate}
\item Take the canonical maps $\varphi_{R_1}: V(\gamma) \rightarrow V(R_1)$, $\varphi_{R_2}: V(\tau) \rightarrow V(R_2)$, and $\varphi_{R_3}: V({\gamma'}^T) \rightarrow V(R_3)$
\item Given vertices $u \in V(\gamma)$ and $v \in V(\tau)$, add a constraint edge between $u$ and $v$ if and only if $\varphi_{R_1}(u) = \varphi_{R_2}(v)$. Similarly, given vertices $u \in V(\gamma)$ and $w \in V({\gamma'}^T)$, add a constraint edge between $u$ and $w$ if and only if $\varphi_{R_1}(u) = \varphi_{R_3}(w)$ and given vertices $v \in V(\tau)$ and $w \in V({\gamma'}^T)$, add a constraint edge between $v$ and $w$ if and only if $\varphi_{R_2}(v) = \varphi_{R_3}(w)$.
\end{enumerate}
\end{definition}
\begin{definition}
Given an intersection pattern $P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}$, we define $V(\gamma \circ \tau \circ {\gamma'}^T)/E(P)$ to be $V(\gamma \circ \tau \circ {\gamma'}^T)$ where all of the edges in $E(P)$ are contracted (i.e. if $(u,v) \in E(P)$ then $u = v$ and $u = v$ only appears once).
\end{definition}
\begin{definition}
Given an intersection pattern $P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}$, we define $\tau_{P}$ to be the shape such that:
\begin{enumerate}
\item $V(H_{\tau_P}) = V(\gamma \circ \tau \circ {\gamma'}^T)/E(P)$
\item $E(H_{\tau_P}) = E(\gamma) \cup E(\tau) \cup E({\gamma'}^{T})$
\item $U_{\tau_P} = U_{\gamma}$
\item $V_{\tau_P} = V_{{\gamma'}^T}$
\end{enumerate}
\end{definition}
\begin{definition}
Given an intersection pattern $P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}$, we make the following definitions:
\begin{enumerate}
\item We define $Aut(P) = \{\pi \in Aut(\gamma \circ \tau \circ {\gamma'}^T): \pi(E(P)) = E(P)\}$
\item We define $Aut_{pieces}(P) = \{\pi \in Aut(U_{\gamma}) \times Aut(\tau) \times Aut({\gamma'}^T): \pi(E(P)) = E(P)\}$
\item We define $N(P) = |Aut(P)/Aut_{pieces}(P)|$
\end{enumerate}
\end{definition}
\begin{lemma}
For all composable $\sigma$, $\tau$, and ${\sigma'}^T$ (inclulding improper $\tau$),
\begin{align*}
&M^{fact}_{\tau}(e_{\sigma}e^T_{\sigma'}) - M^{orth}_{\tau}(e_{\sigma}e^T_{\sigma'}) = \sum_{\sigma_2, \gamma: \gamma \text{ is non-trivial }, \atop \sigma_2 \cup \gamma = \sigma}{\frac{1}{|Aut(U_{\gamma})|}\sum_{P \in \mathcal{P}_{\gamma,\tau,Id_{V_{\tau}}}}N(P)M^{orth}_{\tau_P}(e_{\sigma_2}e^T_{\sigma'})} \\
&+ \sum_{\sigma'_2, \gamma': \gamma' \text{ is non-trivial }, \atop \sigma'_2 \cup \gamma' = \sigma'}{\frac{1}{|Aut(U_{\gamma'})|}\sum_{P \in \mathcal{P}_{Id_{U_{\tau}},\tau,{\gamma'}^T}}N(P)M^{orth}_{\tau_P}(e_{\sigma}e^T_{\sigma'_2})} \\
&+ \sum_{\sigma_2, \gamma: \gamma \text{ is non-trivial }, \atop \sigma_2 \cup \gamma = \sigma}{\sum_{\sigma'_2, \gamma': \gamma' \text{ is non-trivial }, \atop \sigma'_2 \cup \gamma' = \sigma'}{
\frac{1}{|Aut(U_{\gamma})|\cdot|Aut(U_{\gamma'})|}\sum_{P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}}N(P)M^{orth}_{\tau_P}(e_{\sigma_2}e^T_{\sigma'_2})}}
\end{align*}
\end{lemma}
\begin{proof}
This lemma follows from the following bijection. Consider the third term
\[
\sum_{\sigma_2, \gamma: \gamma \text{ is non-trivial }, \atop \sigma_2 \cup \gamma = \sigma}{\sum_{\sigma'_2, \gamma': \gamma' \text{ is non-trivial }, \atop \sigma'_2 \cup \gamma' = \sigma'}{
\frac{1}{|Aut(U_{\gamma})|\cdot|Aut(U_{\gamma'})|}\sum_{P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}}N(P)M^{orth}_{\tau_P}(e_{\sigma_2}e^T_{\sigma'_2})}}
\]
On one side, we have the following data:
\begin{enumerate}
\item Ribbons $R_1$, $R_2$, and $R_3$ such that
\begin{enumerate}
\item $R_1,R_2,R_3$ have shapes $\sigma$, $\tau$, and ${\sigma'}^T$, respectively.
\item $A_{R_2} = B_{R_1}$ and $A_{R_3} = B_{R_2}$
\item $\left(V(R_1) \cup V(R_2)\right) \cap V(R_3) \neq A_{R_3}$ and $\left(V(R_2) \cup V(R_3)\right) \cap V(R_1) \neq B_{R_1}$
\end{enumerate}
\item An ordering $O_{S'}$ on the leftmost minimum vertex separator $S'$ between $A_{R_1}$ and $V_{*} \cup B_{R_1}$.
\item An ordering $O_{T'}$ on the rightmost minimum vertex separator $S'$ between $V_{*} \cup A_{R_3}$ and $B_{R_3}$.
\end{enumerate}
On the other side, we have the following data
\begin{enumerate}
\item An intersection pattern $P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}$ where $\gamma$ and ${\gamma'}^T$ are non-trivial.
\item Ribbons $R'_1$, $R'_2$, $R'_3$ of shapes $\sigma_2$, $\tau_P$, ${\sigma'_2}^T$ such that $V(R'_1) \cap V(R'_2) = A_{R'_2} = B_{R'_1}$, $V(R'_2) \cap V(R'_3) = B_{R'_2} = A_{R'_3}$, and $V(R'_1) \cap V(R'_3) = A_{R'_2} \cap B_{R'_2}$
\item An element $\pi \in Aut(P)/Aut_{pieces}(P)$
\end{enumerate}
To see this bijection, given $R_1,R_2,R_3$, we again implement our strategy for analyzing intersection terms. Recall that $V_{*}$ is the set of vertices in $V(R_1) \cup V(R_2) \cup V(R_3)$ which have an unexpected equality with another vertex, $S'$ is the leftmost minimum vertex separator between $A_{R_1}$ and $B_{R_1} \cup V_{*}$, and $T'$ is the rightmost minimum vertex separator between $A_{R_3} \cup V_{*}$ and $B_{R_3}$.
\begin{enumerate}
\item Decompose $R_1$ as $R_1 = {R'}_1 \circ R_4$ where ${R'}_1$ is the part of $R_1$ between $A_{R_1}$ and $(S',O_{S'})$ and $R_4$ is the part of $R_1$ between $(S',O_{S'})$ and $B_{R_1} = A_{R_2}$. Decompose $R_3$ as $R_5 \cup R'_3$ where $R_5$ is the part of $R_3$ between $A_{R_3}$ and $(T',O_{T'})$ and $R'_3$ is the part of $R_3$ between $(T',O_{T'})$ and $B_{R_3}$
\item Take the intersection pattern $P$ and the ribbon $R'_2$ induced by $R_4$, $R_2$, and $R_5$.
\item Observe that we have two bijective maps from $V(\gamma \circ \tau \circ {\gamma'}^T)/E(P)$ to $V(R_4) \cup V(R_2) \cup V(R_5)$. The first map is $\varphi_{R_4} \circ \varphi_{R_2} \circ \varphi_{R_5}$ and the second map is $\varphi_{R'_2}$. We take $\pi = \varphi^{-1}_{R'_2}(\varphi_{R_4} \circ \varphi_{R_2} \circ \varphi_{R_5})$.
\end{enumerate}
Conversely, given an intersection pattern $P \in \mathcal{P}_{\gamma,\tau,{\gamma'}^T}$, $R'_1$, $R'_2$, $R'_3$, and an element $\pi \in Aut(P)/Aut_{pieces}(P)$:
\begin{enumerate}
\item Take $R_4 = \varphi_{R'_2}\pi(V(\gamma))$, $R_2 = \varphi_{R'_2}\pi(V(\tau))$, and $R_5 = \varphi_{R'_2}\pi(V({\gamma'}^T))$.
\item Take $R_1 = R'_1 \cup R_4$ and take $R_3 = R_5 \cup R'_3$.
\item Take $O_S$ and $O_T$ based on $B_{R'_1} = A_{R_4}$ and $B_{R_5} = A_{R'_3}$.
\end{enumerate}
To confirm that this is a bijection, we need to show that these maps are inverses of each other.
If we apply the first map and then the second, we obtain the following:
\begin{enumerate}
\item We obtain the ribbons
\begin{enumerate}
\item $R''_1 = R'_1 \circ \varphi_{R'_2}\varphi^{-1}_{R'_2}(\varphi_{R_4} \circ \varphi_{R_2} \circ \varphi_{R_5})(V(\gamma))$
\item $R''_2 = \varphi_{R'_2}\varphi^{-1}_{R'_2}(\varphi_{R_4} \circ \varphi_{R_2} \circ \varphi_{R_5})(V(\tau))$
\item $R''_3 = \varphi_{R'_2}\varphi^{-1}_{R'_2}(\varphi_{R_4} \circ \varphi_{R_2} \circ \varphi_{R_5})(V({\gamma'}^T)) \circ R'_3$
\end{enumerate}
where
\begin{enumerate}
\item $R'_1$ is the part of $R_1$ between $A_{R_1}$ and $(S',O_{S'})$ where $S'$ is the minimum vertex separator between $A_{R_1}$ and $V_{*} \cup B_{R_1}$.
\item $R_4$ is the part of $R_1$ between $(S',O_{S'})$ and $B_{R_1}$
\item $R'_2$ is the ribbon of shape $\tau_{P}$ induced (along with the intersection pattern $P$) by $R_1$, $R_2$, and $R_3$.
\item $R_5$ is the part of $R_3$ between $A_{R_3}$ and $(T',O_{T'})$.
\item $R'_3$ is the part of $R_3$ between $(T',O_{T'})$ and $B_{R_3}$
\end{enumerate}
This implies that $R''_1 = R'_1 \circ R_4 = R_1$, $R''_2 = R_2$, and $R''_3 = R_5 \circ R'_3 = R_3$. Since the second map leaves $R'_1$ and $R'_3$ unchanged, we recover the orderings $O_S$ and $O_T$ as well.
\end{enumerate}
Conversely, if we apply the second map, we have that $R_1 = R'_1 \circ \varphi_{R'_2}\pi(V(\gamma))$, $R_2 = \varphi_{R'_2}\pi(V(\tau))$, and $R_3 = \varphi_{R'_2}\pi(V({\gamma'}^T)) \circ R'_3$ and we have the orderings $O_S$ and $O_T$ corresponding to $B_{R'_1}$ and $A_{R'_3}$ respectively. If we apply the first map,
\begin{enumerate}
\item $R'_1$ and $R'_3$ are preserved.
\item $R''_2$ and $P''$ are the ribbon and intersection pattern induced by the ribbons $\varphi_{R'_2}\pi(\gamma)$, $\varphi_{R'_2}\pi(\tau)$, and $\varphi_{R'_2}\pi({\gamma'}^T)$. To see that $R''_2 = R'_2$, observe that
\[
R''_2 = \varphi_{R'_2}\pi(V(\gamma)) \circ \varphi_{R'_2}\pi(V(\tau)) \circ \varphi_{R'_2}\pi(V({\gamma'}^T)) = \varphi_{R'_2}{\pi(\gamma \circ \tau \circ {\gamma'}^T)} = \varphi_{R_2}(\gamma \circ \tau \circ {\gamma'}^T) = R'_2
\]
To see that $P'' \equiv P$, observe that:
\begin{enumerate}
\item We have two bijective maps from $V(\gamma)$ to $V(\varphi_{R'_2}\pi(\gamma))$. These two maps are $\varphi_{R'_2}\pi$ and $\varphi_{\varphi_{R'_2}\pi(\gamma)}$.
\item We have two bijective maps from $V(\tau)$ to $V(\varphi_{R'_2}\pi(\tau))$. These two maps are $\varphi_{R'_2}\pi$ and $\varphi_{\varphi_{R'_2}\pi(\tau)}$.
\item We have two bijective maps from $V({\gamma'}^T)$ to $V(\varphi_{R'_2}\pi({\gamma'}^T))$. These two maps are $\varphi_{R'_2}\pi$ and $\varphi_{\varphi_{R'_2}\pi({\gamma'}^T)}$.
\item For $P''$, the constraint edges are
\[
\left(\varphi^{-1}_{\varphi_{R'_2}\pi(\gamma)}\varphi_{R'_2}\pi \circ \varphi^{-1}_{\varphi_{R'_2}\pi(\tau)}\varphi_{R'_2}\pi \circ \varphi^{-1}_{\varphi_{R'_2}\pi({\gamma'}^T))}\varphi_{R'_2}\pi\right)(E(P))
\]
\end{enumerate}
\item We have that
\[
\pi'' = \varphi^{-1}_{R'_2}(\varphi_{\varphi_{R'_2}\pi(V(\gamma))} \circ \varphi_{\varphi_{R'_2}\pi(V(\tau))} \circ \varphi_{\varphi_{R'_2}\pi(V({\gamma'}^T))})
\]
To see that $\pi'' \equiv \pi$, note that
\[
\pi = \pi''\left(\varphi^{-1}_{\varphi_{R'_2}\pi(V(\gamma))}\varphi_{R'_2}\pi \circ \varphi^{-1}_{\varphi_{R'_2}\pi(V(\tau))}\varphi_{R'_2}\pi \circ \varphi^{-1}_{\varphi_{R'_2}\pi(V({\gamma'}^T))}\varphi_{R'_2}\pi)\right)
\]
\end{enumerate}
The analysis for the the first term is the same except that when $\gamma'$ is trivial, we always take $\gamma'$ to be the identity so $T = V(V_{\tau}) = V(U_{{\sigma'}^T})$ and the ordering $O_{T}$ is given by $V_{\tau} = U_{{\sigma'}^T}$.
Similarly, the analysis for the the second term is the same except that when $\gamma$ is trivial, we always take $\gamma$ to be the identity so $S = V(V_{\sigma}) = V(U_{\tau})$ and the ordering $O_{S}$ is given by $V_{\sigma} = U_{\tau}$.
\end{proof}
\section{Degree 4 Planted Clique Analysis}\label{sec: deg_4_planted_clique}
For this example, we name the shapes based on what they look like to make them easier to keep track of. With the exception of $Id_{U}$, these names only appear in this section.
\subsection{The shapes $\alpha$ and coefficients $\lambda_{\alpha}$}
After several preprocessing steps, the moment matrix which needs to be analyzed is $M \approx \sum_{\alpha}{\lambda_{\alpha}M_{\alpha}}$ for the following shapes $\alpha$ and coefficients $\lambda_{\alpha}$
\begin{definition} \
\begin{enumerate}
\item Given $E \subseteq \{(u_1,v_1), (u_1,v_2), (u_2,v_1), (u_2,v_2)\}$, we define $\alpha_{E}$ to be the shape where $U_{\alpha_E} = (u_1,u_2)$, $V_{\alpha_E} = (v_1,v_2)$, and $E(\alpha) = E$.
\item Given $E \subseteq \{(u_1,v_1), (u_1,v_2), (u_2,v_1), (u_2,v_2)\}$, we define $\alpha_{X,E}$ to be the shape where $U_{\alpha_E} = (u_1,u_2)$, $V_{\alpha_E} = (v_1,v_2)$, there is one additional vertex $w_1$, and $E(\alpha) = E \cup \{(u_1,w_1), (u_2,w_1), (w_1,v_1), (w_1,v_2)\}$.
\item Given $i,j \in \{1,2\}$, we define $\alpha_{u_i = v_j,e}$ to be the shape where $U_{\alpha_{u_i = v_j,e}} = (u_1,u_2)$, $V_{\alpha_{u_i = v_j,e}} = (v_1,v_2)$, $u_i = v_j$, and $E(\alpha_{u_i = v_j,e}) = \{(u_{2-i},v_{2-j})\}$.
\item Given $i,j \in \{1,2\}$, we define $\alpha_{u_i = v_j,\emptyset}$ to be the shape where $U_{\alpha_E} = (u_1,u_2)$, $V_{\alpha_E} = (v_1,v_2)$, $u_i = v_j$, and $E(\alpha) = \emptyset$.
\item We define $\alpha_{Id:} = Id_{(u_1,u_2)}$ to be the shape where $U_{Id_{(u_1,u_2)}} = V_{Id_{(u_1,u_2)}} = (u_1,u_2)$ and $E(Id_{(u_1,u_2)}) = \emptyset$.
\item We define $\alpha_{swap}$ to be the shape where $U_{\alpha_{swap}} = (u_1,u_2)$, $V_{\alpha_{swap}} = (u_2,u_1)$ and $E(\alpha_{swap}) = \emptyset$.
\end{enumerate}
\end{definition}
For illustrations of these shapes $\alpha$, see Figures \ref{zerointersectionalphasfigure}.\\
\begin{figure}[ht]\label{zerointersectionalphasfigure}
\centerline{\includegraphics[height=4cm]{machinery/images/ZeroIntersectionAlphas}}
\caption{This figure shows the shapes $\alpha$ where $|U_{\alpha} \cap V_{\alpha}| = 0$. On the left we have $\alpha_{E}$ and on the right we have $\alpha_{X,E}$.}
\end{figure}
\begin{figure}[ht]\label{oneintersectionalphasfigure}
\centerline{\includegraphics[height=4cm]{machinery/images/OneIntersectionAlphas}}
\caption{This figure shows the shapes $\alpha$ where $|U_{\alpha} \cap V_{\alpha}| = 1$. From left to right, we have $\alpha_{u_2 = v_2,\emptyset}$ and $\alpha_{u_2 = v_2,e}$, $\alpha_{u_2 = v_1,\emptyset}$ and $\alpha_{u_2 = v_1,e}$, $\alpha_{u_1 = v_1,\emptyset}$ and $\alpha_{u_1 = v_1,e}$, and $\alpha_{u_1 = v_2,\emptyset}$ and $\alpha_{u_1 = v_2,e}$.}
\end{figure}
\begin{figure}[ht]\label{twointersectionalphasfigure}
\centerline{\includegraphics[height=4cm]{machinery/images/TwoIntersectionAlphas}}
\caption{This figure shows the shapes $\alpha$ where $|U_{\alpha} \cap V_{\alpha}| = 2$. On the left we have $\alpha_{Id:}$ and on the right we have $\alpha_{swap}$.}
\end{figure}
We have the following coefficients on these shapes.
\begin{enumerate}
\item For each $E \subseteq \{(u_1,v_1), (u_1,v_2), (u_2,v_1), (u_2,v_2)\}$, $\lambda_{\alpha_E} = \frac{k^4}{n^4}$.
\item For each $E \subseteq \{(u_1,v_1), (u_1,v_2), (u_2,v_1), (u_2,v_2)\}$, $\lambda_{\alpha_{X,E}} = C\frac{k^5}{n^5}$ for some constant $C > 1$. These coefficients are the ad-hoc fix to the candidate pseudo-expectation values for planted clique in \cite{meka2015sum}.
\item For each $i,j \in \{1,2\}$, $\lambda_{\alpha_{u_i = v_j,e}} = \lambda_{\alpha_{u_i = v_j,\emptyset}} = \frac{k^3}{n^3}$.
\item $\lambda_{\alpha_{Id:}} = \lambda_{\alpha_{swap}} = \frac{k^2}{n^2}$
\end{enumerate}
\subsection{Decomposing $\alpha$ and coefficient matrices}
To find the coefficient matrices $H_{Id_{\emptyset}}$, $H_{Id_{(u_1)}}$, $H_{Id_{(u_1,u_2)}}$, and $H_{\tau}$, we need to decompose each $\alpha$ into a left part $\sigma$, a proper middle part $\tau$, and a right part ${\sigma'}^T$.
The following left shapes will appear in these decompositions
\begin{definition} \
\begin{enumerate}
\item Define $\sigma_{Id:} = Id_{(u_1,u_2)}$. Note that $\sigma_{Id:} = \alpha_{Id:}$ but it is playing a different role.
\item Define $\sigma_{swap} = \alpha_{swap}$.
\item Define $\sigma_7$ to be the shape where $U_{\sigma_{7}} = (u_1,u_2)$, $V_{\sigma_{7}} = (v_1)$, and $E(\sigma_{7}) = \{(u_1,v_1),(u_2,v_1)\}$.
\item Define $\sigma_{u_1,u_2 \rightarrow u_1}$ to be the shape where $U_{\sigma_{u_1,u_2 \rightarrow u_1}} = (u_1,u_2)$, $V_{\sigma_{u_1,u_2 \rightarrow u_1}} = (u_1)$, and $E(\sigma_{u_1,u_2 \rightarrow u_1}) = \emptyset$.
\item Similarly, define $\sigma_{u_1,u_2 \rightarrow u_2}$ to be the shape where $U_{\sigma_{u_1,u_2 \rightarrow u_2}} = (u_1,u_2)$, $V_{\sigma_{u_1,u_2 \rightarrow u_2}} = (u_2)$, and $E(\sigma_{u_1,u_2 \rightarrow u_2}) = \emptyset$.
\item Define $\sigma_{u_1,u_2 \rightarrow \emptyset}$ to be the shape where $U_{\sigma_{u_1,u_2 \rightarrow \emptyset}} = (u_1,u_2)$, $V_{\sigma_{u_1,u_2 \rightarrow \emptyset}} = \emptyset$, and $E(\sigma_{u_1,u_2 \rightarrow \emptyset}) = \emptyset$.
\end{enumerate}
\end{definition}
These left shapes are illustrated in Figure \ref{onerightsidevertexsigmasfigure}. \\
\begin{figure}[ht]\label{onerightsidevertexsigmasfigure}
\centerline{\includegraphics[height=4cm]{machinery/images/OneRightSideVertexSigmas}}
\caption{This figure shows the left shapes $\sigma$ where $|V_{sigma}| = 1$. From left to right we have $\sigma_{u_1,u_2 \rightarrow u_1}$, $\sigma_{u_1,u_2 \rightarrow u_2}$, and $\sigma_7$.}
\end{figure}
\begin{figure}[ht]\label{zeroortworightvertexsigmasfigure}
\centerline{\includegraphics[height=4cm]{machinery/images/ZeroorTwoRightVertexSigmas}}
\caption{This figure shows the left shapes $\sigma$ where $|V_{\sigma}| = 2$ or $|V_{\sigma}| = 0$. On the left we have $\sigma_{Id:}$ and $\sigma_{swap}$. On the right we have $\sigma_{u_1,u_2 \rightarrow \emptyset}$.}
\end{figure}
The following proper middle shapes will appear in these decompositions.
\begin{definition} \
\begin{enumerate}
\item Define $\tau_{Id:} = Id_{(u_1,u_2)}$
\item Given $E \subseteq \{(u_1,v_1), (u_1,v_2), (u_2,v_1), (u_2,v_2)\}$ such that all four vertices $u_1,u_2,v_1,v_2$ are incident to at least one edge in $E$, we define $\tau_{E} = \alpha_{E}$.
\item Given $E \subseteq \{(u_1,v_1), (u_1,v_2), (u_2,v_1), (u_2,v_2)\}$ such that $E \neq \emptyset$, we define $\tau_{X,E} = \alpha_{X,E}$.
\item Given $i,j \in \{1,2\}$, we define $\tau_{u_i = v_j,e} = \alpha_{u_i = v_j,e}$.
\item Define $\tau_{Id\cdot} = Id_{(u_1)}$ to be the shape where $U_{Id_{(u_1)}} = V_{Id_{(u_1)}} = (u_1)$ and $E(Id_{(u_1)}) = \emptyset$.
\item Define $\tau_{e}$ to be the shape where $U_{\tau_{e}} = (u_1)$, $V_{\tau_{e}} = (v_1)$, and $E(\tau_{e}) = \{(u_1,v_1)\}$.
\item Define $\tau_{\emptyset}$ to be the empty shape with no vertices.
\end{enumerate}
\end{definition}
These proper middle shapes (except for $\tau_{\emptyset}$) are illustrated in Figure \ref{twovertexseparatortausfigure}. \\
\begin{figure}[ht]\label{twovertexseparatortausfigure}
\centerline{\includegraphics[height=8cm]{machinery/images/TwoVertexSeparatorTaus}}
\caption{This figure shows the proper middle shapes $\tau$ where $|U_{tau}| = |V_{tau}| = 2$. In the upper row, we have $\tau_{Id:}$, $\tau_{E}$, and $\tau_{X,E}$. In the bottom row, we have $\tau_{u_2 = v_2,e}$, $\tau_{u_2 = v_1,e}$, $\tau_{u_1 = v_1,e}$, and $\tau_{u_1 = v_2,e}$.}
\end{figure}
\begin{figure}[ht]\label{onevertexseparatortausfigure}
\centerline{\includegraphics[height=3cm]{machinery/images/OneVertexSeparatorTaus}}
\caption{This figure shows the proper middle shapes $\tau$ where $|U_{tau}| = |V_{tau}| = 1$. On the left we have $\tau_{Id\cdot}$ and on the right we have $\tau_{e}$.}
\end{figure}
Some decompositions are as follows:
\begin{example} \
\begin{enumerate}
\item $\alpha_{X,\emptyset} = \sigma_7 \circ \tau_{Id\cdot} \circ \sigma_7^T$ (see Figure \ref{decompositiononefigure}).
\item $\alpha_{\{(u_1,v_1),(u_2,v_1)\}} = \sigma_7 \circ \tau_{Id\cdot} \circ \sigma_{u_1,u_2 \rightarrow u_1}^T$ (see Figure \ref{decompositiontwofigure}).
\item $\alpha_{\{(u_2,v_1)\}} = \sigma_{u_1,u_2 \rightarrow u_2} \circ \tau_{e} \circ \sigma_{u_1,u_2 \rightarrow u_1}^T$ (see Figure \ref{decompositionthreefigure}).
\item \begin{align*}
\alpha_{\{(u_1,v_1),(u_2,v_2)\}} &= \sigma_{Id:} \circ \alpha_{\{(u_1,v_1),(u_2,v_2)\}} \circ \sigma_{Id:}^T = \sigma_{Id:} \circ \alpha_{\{(u_1,v_2),(u_2,v_1)\}} \circ \sigma_{swap}^T \\
&= \sigma_{swap}^T \circ \alpha_{\{(u_1,v_2),(u_2,v_1)\}} \circ \sigma_{Id:} = \sigma_{swap} \circ \alpha_{\{(u_1,v_1),(u_2,v_2)\}} \circ \sigma_{swap}^T
\end{align*}
\end{enumerate}
\end{example}
\begin{remark}
Since there are $4$ different ways to decompose $\alpha_{\{(u_1,v_1),(u_2,v_2)\}}$, we split the coefficient $\lambda_{\alpha_{\{(u_1,v_1),(u_2,v_2)\}}}$ among these four decompositions. This is the reason for the factor of $4$ in the denominator in the entries of the matrix $H_{\tau}$.
\end{remark}
\begin{figure}[ht]\label{decompositiononefigure}
\centerline{\includegraphics[height=4cm]{machinery/images/DecompositionOne}}
\caption{This figure shows the decomposition $\alpha_{X,\emptyset} = \sigma_7 \circ \tau_{Id\cdot} \circ \sigma_7^T$.}
\end{figure}
\begin{figure}[ht]\label{decompositiontwofigure}
\centerline{\includegraphics[height=4cm]{machinery/images/DecompositionTwo}}
\caption{This figure shows the decomposition $\alpha_{\{(u_1,v_1),(u_2,v_1)\}} = \sigma_7 \circ \tau_{Id\cdot} \circ \sigma_{u_1,u_2 \rightarrow u_1}^T$.}
\end{figure}
\begin{figure}[ht]\label{decompositionthreefigure}
\centerline{\includegraphics[height=4cm]{machinery/images/DecompositionThree}}
\caption{This figure shows the decomposition $\alpha_{\{(u_2,v_1)\}} = \sigma_{u_1,u_2 \rightarrow u_2} \circ \tau_{e} \circ \sigma_{u_1,u_2 \rightarrow u_1}^T$.}
\end{figure}
Our coefficient matrices are as follows (ignoring zero rows and columns):
\begin{enumerate}
\item $H_{Id_{(u_1,u_2)}}$ has two rows and columns indexed by $\sigma_{Id:}$ and $\sigma_{swap}$ and has entries $\left(\begin{matrix}
\frac{k^2}{2n^2} & \frac{k^2}{2n^2}\\
\frac{k^2}{2n^2} & \frac{k^2}{2n^2}\\
\end{matrix}\right)$.
\item $H_{Id_{(u_1)}}$ has rows and columns indexed by $\sigma_{u_1,u_2 \rightarrow u_1}$, $\sigma_{u_1,u_2 \rightarrow u_2}$, and $\sigma_7$ and has entries
\[
\left(\begin{matrix}
\frac{k^3}{n^3} & \frac{k^3}{n^3} & \frac{k^4}{n^4}\\
\frac{k^3}{n^3} & \frac{k^3}{n^3} & \frac{k^4}{n^4}\\
\frac{k^4}{n^4} & \frac{k^4}{n^4} & C\frac{k^5}{n^5}\\
\end{matrix}\right) \]
\item $H_{Id_{\emptyset}}$ has a single row and column indexed by $\sigma_{u_1,u_2 \rightarrow \emptyset}$ and has a single entry which is $\frac{k^4}{n^4}$.
\item For all $E \subseteq \{(u_1,v_1), (u_1,v_2), (u_2,v_1), (u_2,v_2)\}$ such that all four vertices $u_1,u_2,v_1,v_2$ are incident to at least one edge in $E$, $H_{\tau_{E}}$ has two rows and columns indexed by $\sigma_{Id:}$ and $\sigma_{swap}$ and has entries $\left(\begin{matrix}
\frac{k^4}{4n^4} & \frac{k^4}{4n^4}\\
\frac{k^4}{4n^4} & \frac{k^4}{4n^4}\\
\end{matrix}\right)$.
\item For all $E \subseteq \{(u_1,v_1), (u_1,v_2), (u_2,v_1), (u_2,v_2)\}$ such that $E \neq \emptyset$, $H_{\tau_{X,E}}$ has two rows and columns indexed by $\sigma_{Id:}$ and $\sigma_{swap}$ and has entries $\left(\begin{matrix}
\frac{k^5}{4n^5} & \frac{k^5}{4n^5}\\
\frac{k^5}{4n^5} & \frac{k^5}{4n^5}\\
\end{matrix}\right)$.
\item For all $i,j \in \{1,2\}$, $H_{\tau_{u_i = v_j,e}}$ has two rows and columns indexed by $\sigma_{Id:}$ and $\sigma_{swap}$ and has entries $\left(\begin{matrix}
\frac{k^3}{4n^3} & \frac{k^3}{4n^3}\\
\frac{k^3}{4n^3} & \frac{k^3}{4n^3}\\
\end{matrix}\right)$.
\item $H_{\tau_{e}}$ has rows and columns indexed by $\sigma_{u_1,u_2 \rightarrow u_1}$ and $\sigma_{u_1,u_2 \rightarrow u_2}$ and has entries
\[
\left(\begin{matrix}
\frac{k^4}{n^4} & \frac{k^4}{n^4}\\
\frac{k^4}{n^4} & \frac{k^4}{n^4}\\
\end{matrix}\right)\]
\end{enumerate}
\subsection{Verifying the first and second conditions of the machinery}
We can verify the fist and second conditions of the machinery as follows.
\begin{enumerate}
\item $H_{Id_{(u_1,u_2)}} \succeq 0$ and $H_{Id_{\emptyset}} \succeq 0$
\item As long as $C \geq 1$, $H_{Id_{(u_1)}} \succeq 0$. This condition is the reason why we need to add this term in.
\item For all $E \subseteq \{(u_1,v_1), (u_1,v_2), (u_2,v_1), (u_2,v_2)\}$ such that all four vertices $u_1,u_2,v_1,v_2$ are incident to at least one edge in $E$, $||M_{\tau_{E}}||$ is $\tilde{O}(n)$ so $||M_{\tau_{E}}||H_{\tau_{E}} \preceq H_{Id_{(u_1,u_2)}}$ as long as $k << \sqrt{n}$.
\item For all $E \subseteq \{(u_1,v_1), (u_1,v_2), (u_2,v_1), (u_2,v_2)\}$ such that $E \neq \emptyset$,
$||M_{\tau_{X,E}}||$ is $\tilde{O}(n^{3/2})$ so $||M_{\tau_{X,E}}||H_{\tau_{X,E}} \preceq H_{Id_{(u_1,u_2)}}$ as long as $k << \sqrt{n}$.
\item For all $i,j \in \{1,2\}$, $||M_{\tau_{u_i = v_j,e}}||$ is $\tilde{O}(\sqrt{n})$ so $||M_{\tau_{u_i = v_j,e}}||H_{\tau_{u_i = v_j,e}} \preceq H_{Id_{(u_1,u_2)}}$ as long as $k << \sqrt{n}$.
\item Since $\left(\begin{matrix}
\frac{k^3}{n^3} & \frac{k^3}{n^3} & \frac{k^4}{n^4}\\
\frac{k^3}{n^3} & \frac{k^3}{n^3} & \frac{k^4}{n^4}\\
\frac{k^4}{n^4} & \frac{k^4}{n^4} & C\frac{k^5}{n^5}\\
\end{matrix}\right) \succeq (1 - \frac{1}{C})\left(\begin{matrix}
\frac{k^3}{n^3} & \frac{k^3}{n^3} & 0\\
\frac{k^3}{n^3} & \frac{k^3}{n^3} & 0\\
0 & 0 & 0\\
\end{matrix}\right)$ and $||M_{\tau_{e}}||$ is $\tilde{O}(\sqrt{n})$, $||M_{\tau_{e}}||H_{\tau_{e}} \preceq H_{Id_{(u_1)}}$ as long as $C > 1$ and $k << \sqrt{n}$. Note that for pseudo-calibration we take $C = 1$. We can do this because we have more terms which allows us to have a more delicate factorization.
\end{enumerate}
\subsection{Verifying the third condition of the machinery}
The following left shapes $\gamma$ appear.
\begin{definition} \
\begin{enumerate}
\item Define $\gamma_7 = \sigma_7$.
\item Define $\gamma_{u_1,u_2 \rightarrow u_1} = \sigma_{u_1,u_2 \rightarrow u_1}$.
\item Define $\gamma_{u_1,u_2 \rightarrow u_2} = \sigma_{u_1,u_2 \rightarrow u_2}$.
\item Define $\gamma_{u_1,u_2 \rightarrow \emptyset} = \sigma_{u_1,u_2 \rightarrow \emptyset}$.
\item Define $\gamma_{u_1 \rightarrow \emptyset}$ to be the shape with $U_{\gamma_{u_1 \rightarrow \emptyset}} = (u_1)$ and $V_{\gamma_{u_1 \rightarrow \emptyset}} = \emptyset$
\end{enumerate}
\end{definition}
For illustrations of these gammas, see Figure \ref{possiblegammasfigure}. \\
\begin{figure}[ht]\label{possiblegammasfigure}
\centerline{\includegraphics[height=4cm]{machinery/images/PossibleGammas}}
\caption{This figure shows the left shapes $\gamma$ which appear in the analysis. From left to right we have $\gamma_{u_1,u_2 \rightarrow u_1}$, $\gamma_{u_1,u_2 \rightarrow u_2}$, $\gamma_7$, $\gamma_{u_1,u_2 \rightarrow \emptyset}$, and $\gamma_{u_1 \rightarrow \emptyset}$}
\end{figure}
We have the following compositions.
\begin{enumerate}
\item $\sigma_{Id:} \circ \gamma_7 = \sigma_{swap} \circ \gamma_7 = \sigma_7$ (see Figure \ref{compositiononefigure}).
\item $\sigma_{Id:} \circ \gamma_{u_1,u_2 \rightarrow u_1} = \sigma_{u_1,u_2 \rightarrow u_1}$ and $\sigma_{swap} \circ \gamma_{u_1,u_2 \rightarrow u_1} = \sigma_{u_1,u_2 \rightarrow u_2}$ (see Figure \ref{compositiontwofigure}).
\item Similarly, $\sigma_{Id:} \circ \gamma_{u_1,u_2 \rightarrow u_2} = \sigma_{u_1,u_2 \rightarrow u_2}$ and $\sigma_{swap} \circ \gamma_{u_1,u_2 \rightarrow u_2} = \sigma_{u_1,u_2 \rightarrow u_1}$.
\item $\sigma_{Id:} \circ \gamma_{u_1,u_2 \rightarrow \emptyset} = \sigma_{swap} \circ \gamma_{u_1,u_2 \rightarrow \emptyset} = \sigma_{u_1,u_2 \rightarrow \emptyset}$.
\item $\sigma_{u_1,u_2 \rightarrow u_1} \circ \gamma_{u_1 \rightarrow \emptyset} = \sigma_{u_1,u_2 \rightarrow u_2} \circ \gamma_{u_1 \rightarrow \emptyset} = \sigma_{u_1,u_2 \rightarrow \emptyset}$ (see Figure \ref{compositionthreefigure}).
\end{enumerate}
\begin{figure}[ht]\label{compositiononefigure}
\centerline{\includegraphics[height=4cm]{machinery/images/CompositionOne}}
\caption{This figure shows the compositions $\sigma_{Id:} \circ \gamma_{7} = \sigma_{7}$ and $\sigma_{swap} \circ \gamma_{7} = \sigma_{7}$.}
\end{figure}
\begin{figure}[ht]\label{compositiontwofigure}
\centerline{\includegraphics[height=8cm]{machinery/images/CompositionTwo}}
\caption{This figure shows the compositions $\sigma_{Id:} \circ \gamma_{u_1,u_2 \rightarrow u_1} = \sigma_{u_1,u_2 \rightarrow u_1}$ and $\sigma_{swap} \circ \gamma_{u_1,u_2 \rightarrow u_1} = \sigma_{u_1,u_2 \rightarrow u_2}$ .}
\end{figure}
\begin{figure}[ht]\label{compositionthreefigure}
\centerline{\includegraphics[height=4cm]{machinery/images/CompositionThree}}
\caption{This figure shows the compositions $\sigma_{u_1,u_2 \rightarrow u_1} \circ \gamma_{u_1 \rightarrow \emptyset} = \sigma_{u_1,u_2 \rightarrow \emptyset}$ and $\sigma_{u_1,u_2 \rightarrow u_2} \circ \gamma_{u_1 \rightarrow \emptyset} = \sigma_{u_1,u_2 \rightarrow \emptyset}$.}
\end{figure}
Based on these compositions, we have the following matrices:
\begin{enumerate}
\item $H_{Id_{(u_1)}}^{-\gamma_7,\gamma_7}$ has two rows and columns indexed by $\sigma_{Id:}$ and $\sigma_{swap}$ and has entries $\left(\begin{matrix}
\frac{k^5}{n^5} & \frac{k^5}{n^5}\\
\frac{k^5}{n^5} & \frac{k^5}{n^5}\\
\end{matrix}\right)$.
\item $H_{Id_{(u_1)}}^{-\gamma_{u_1,u_2 \rightarrow u_1},\gamma_{u_1,u_2 \rightarrow u_1}}$ has two rows and columns indexed by $\sigma_{Id:}$ and $\sigma_{swap}$ and has entries $\left(\begin{matrix}
\frac{k^3}{n^3} & \frac{k^3}{n^3}\\
\frac{k^3}{n^3} & \frac{k^3}{n^3}\\
\end{matrix}\right)$.
\item $H_{Id_{(u_1)}}^{-\gamma_{u_1,u_2 \rightarrow u_2},\gamma_{u_1,u_2 \rightarrow u_2}} = H_{Id_{(u_1)}}^{-\gamma_{u_1,u_2 \rightarrow u_1},\gamma_{u_1,u_2 \rightarrow u_1}}$.
\item $H_{Id_{\emptyset}}^{-\gamma_{u_1,u_2 \rightarrow \emptyset},\gamma_{u_1,u_2 \rightarrow \emptyset}}$ has two rows and columns indexed by $\sigma_{Id:}$ and $\sigma_{swap}$ and has entries $\left(\begin{matrix}
\frac{k^4}{n^4} & \frac{k^4}{n^4}\\
\frac{k^4}{n^4} & \frac{k^4}{n^4}\\
\end{matrix}\right)$.
\item $H_{Id_{\emptyset}}^{-\gamma_{u_1 \rightarrow \emptyset},\gamma_{u_1 \rightarrow \emptyset}}$ has two rows and columns indexed by $\sigma_{u_1,u_2 \rightarrow u_1}$ and $\sigma_{u_1,u_2 \rightarrow u_2}$ and has entries $\left(\begin{matrix}
\frac{k^4}{n^4} & \frac{k^4}{n^4}\\
\frac{k^4}{n^4} & \frac{k^4}{n^4}\\
\end{matrix}\right)$.
\end{enumerate}
We can qualitatively verify the third condition of the machinery as follows
\begin{enumerate}
\item $B(\gamma_7)$ is $\tilde{O}(n^{\frac{|V(\gamma_7) \setminus U_{\gamma_7}|}{2}}) = \tilde{O}(\sqrt{n})$ so ${B(\gamma_7)^2}H_{Id_{(u_1)}}^{-\gamma_7,\gamma_7} \preceq H_{Id_{(u_1,u_2)}}$ as long as $k << n^{\frac{2}{3}}$.
\item $B(\gamma_{u_1,u_2 \rightarrow u_1})$ is $\tilde{O}(n^{\frac{|V(\gamma_{u_1,u_2 \rightarrow u_1}) \setminus U_{\gamma_{u_1,u_2 \rightarrow u_1}}|}{2}}) = \tilde{O}(1)$ so ${B(\gamma_{u_1,u_2 \rightarrow u_1})^2}H_{Id_{(u_1)}}^{-\gamma_{u_1,u_2 \rightarrow u_1},\gamma_{u_1,u_2 \rightarrow u_1}} \preceq H_{Id_{(u_1,u_2)}}$. Following the same logic, ${B(\gamma_{u_1,u_2 \rightarrow u_2})^2}H_{Id_{(u_1)}}^{-\gamma_{u_1,u_2 \rightarrow u_2},\gamma_{u_1,u_2 \rightarrow u_2}} \preceq H_{Id_{(u_1,u_2)}}$.
\item $B(\gamma_{u_1,u_2 \rightarrow \emptyset})$ is $\tilde{O}(n^{\frac{|V(\gamma_{u_1,u_2 \rightarrow \emptyset}) \setminus U_{\gamma_{u_1,u_2 \rightarrow \emptyset}}|}{2}}) = \tilde{O}(1)$ so ${B(\gamma_{u_1,u_2 \rightarrow \emptyset})^2}H_{Id_{\emptyset}}^{-\gamma_{u_1,u_2 \rightarrow \emptyset},\gamma_{u_1,u_2 \rightarrow \emptyset}} \preceq H_{Id_{(u_1,u_2)}}$.
\item $B(\gamma_{u_1 \rightarrow \emptyset})$ is $\tilde{O}(n^{\frac{|V(\gamma_{u_1 \rightarrow \emptyset}) \setminus U_{\gamma_{u_1 \rightarrow \emptyset}}|}{2}}) = \tilde{O}(1)$ so ${B(\gamma_{u_1 \rightarrow \emptyset})^2}H_{Id_{\emptyset}}^{-\gamma_{u_1 \rightarrow \emptyset},\gamma_{u_1 \rightarrow \emptyset}} \preceq H_{Id_{(u_1)}}$ as
\[
\left(\begin{matrix}
\frac{k^3}{n^3} & \frac{k^3}{n^3} & \frac{k^4}{n^4}\\
\frac{k^3}{n^3} & \frac{k^3}{n^3} & \frac{k^4}{n^4}\\
\frac{k^4}{n^4} & \frac{k^4}{n^4} & C\frac{k^5}{n^5}\\
\end{matrix}\right) \succeq (1 - \frac{1}{C})\left(\begin{matrix}
\frac{k^3}{n^3} & \frac{k^3}{n^3} & 0\\
\frac{k^3}{n^3} & \frac{k^3}{n^3} & 0\\
0 & 0 & 0\\
\end{matrix}\right) \succeq \tilde{O}(1)\left(\begin{matrix}
\frac{k^4}{n^4} & \frac{k^4}{n^4} & 0\\
\frac{k^4}{n^4} & \frac{k^4}{n^4} & 0\\
0 & 0 & 0\\
\end{matrix}\right)
\].
\end{enumerate}
\subsection{Shapes and graph matrices}
Consider the setting when the input distribution is a Rademacher $G_{n, 1/2}$ graph with the input entries being $\chi_e \in \{-1, 1\}$. For $T \subseteq \binom{[n]}{2}$, let $\chi_T = \prod_{e \in T} \chi_e$ be the standard Fourier basis. In this setting, shapes were already defined in \cref{chap: efron_stein}. Here, for technical reasons, we slightly modify the definitions so that the rows and columns are indexed by sub-tuples of $[n]$ rather than subsets of $[n]$. The techniques developed in \cref{chap: efron_stein} still carry over to bound the norms of such graph matrices.
\begin{definition}[Shapes in the setting of Rademacher $G_{n, 1/2}$ inputs]
A shape $\alpha = (V(\alpha),E(\alpha),U_{\alpha},V_{\alpha})$ is a graph on vertices $V(\alpha)$ and edges $E(\alpha)$ with two distinguished tuples of vertices $U_{\alpha}, V_{\alpha} \subseteq V(\alpha)$. Note that $U_{\alpha}, V_{\alpha}$ are ordered subsets (tuples).
\end{definition}
As we saw earlier, we can define corresponding matrices for each shape, that are termed graph matrices. Recall that a realization is an injective map from $V(\alpha)$ to $[n]$. The main difference here, as compared to \cref{chap: efron_stein}, is that in the definition of graph matrices, we sum over realizations $\varphi$ that correspond to distinct characters, rather than all realizations $\varphi$.
To capture this notion precisely, we use the following definition. Define two realizations (injective maps from $V(\alpha)$ to $[n]$) $\varphi, \varphi'$ to be equivalent if $\varphi(U_{\alpha}) = \varphi'(U_{\alpha}), \varphi(V_{\alpha}) = \varphi'(V_{\alpha})$ as tuples and $\varphi(E(\alpha)) = \varphi'(E(\alpha))$ as sets. Let the set of non-equivalent realizations of $\alpha$ be denoted $\mathrm{Real}(\alpha)$.
\begin{definition}[Graph matrices in the setting of Rademacher $G_{n, 1/2}$ inputs]
For a shape $\alpha$, the graph matrix $M_{\alpha}$ is a matrix-valued function with rows and columns indexed by sub-tuples of $[n]$ of sizes $|U_{\alpha}|, |V_{\alpha}|$ respectively, which is defined as follows: It maps input graph $G \in \{\pm 1\}^{\binom{n}{2}}$ (wich associated fourier characters $\chi_E$) to a matrix with the $A, B$-th entry being \[M_{\alpha}(A,B) = \sum_{\substack{\varphi(U_{\alpha}) = A, \varphi(V_{\alpha}) = B\\\varphi \in \mathrm{Real}(\alpha)}}{\chi_{E(\alpha)}}\]
\end{definition}
\begin{definition}[Shape transposes]
For a shape $\alpha = (V(\alpha),E(\alpha),U_{\alpha},V_{\alpha})$, define its transpose $\alpha^T$ to be $\alpha^T = (V(\alpha),E(\alpha),V_{\alpha},U_{\alpha})$.
Note that $M_{\alpha^T} = M_{\alpha}^T$ as matrix transpose.
\end{definition}
\begin{example}
In \cref{fig: sample_shape}, consider the shape $\alpha$ as shown. We have $U_{\alpha} = (u_1, u_2), V_{\alpha} = (v_1), V(\alpha) = \{u_1, u_2, v_1, w_1\}$ and $E(\alpha) = \{\{u_1, w_1\}, \{u_2, w_1\}, \{w_1, v_1\}\}$. $M_{\alpha}$ is a matrix with rows and columns indexed by tuples of length $|U_{\alpha}| = 2$ and $|V_{\alpha}| = 1$ respectively. The nonzero entries will have rows and columns indexed by $(a_1, a_2)$ and $b_1$ respectively for all distinct $a_1, a_2, b_1$, with the corresponding entry being $M_{\alpha}((a_1, a_2), (b_1)) = \sum_{c_1 \in [n] \setminus \{a_1, a_2, b_1\}} \chi_{a_1, c_1}\chi_{a_2, c_1}\chi_{c_1, b_1}$. Here, the injective map $\varphi$ maps the vertices $u_1, u_2, w_1, v_1$ to $a_1, a_2, c_1, b_1$ respectively and we sum over all such maps (as they are all pairwise non-equivalent). Succinctly, \[M_{\alpha} =
\begin{blockarray}{rl@{}c@{}r}
& & \makebox[0pt]{column $(b_1)$} \\[-0.5ex]
& & \,\downarrow \\[-0.5ex]
\begin{block}{r(l@{}c@{}r)}
& & \vdots & \\[-0.2ex]
\text{row }(a_1, a_2) \rightarrow \mkern-9mu & \raisebox{0.5ex}{\makebox[3.2em][l]{\dotfill}} & \sum_{c_1 \in [n] \setminus \{a_1, a_2, b_1\}} \chi_{a_1, c_1}\chi_{a_2, c_1}\chi_{c_1, b_1} & \raisebox{0.5ex}{\makebox[4.2em][r]{\dotfill}} \\[+.5ex]
& & \vdots & \\
\end{block}
\end{blockarray}\]
\end{example}
\begin{figure}[!h]
\centering
\includegraphics[scale=.3, trim={0 0 0 0},clip]{machinery/images/sample_shape}
\caption{Example of a shape}
\label{fig: sample_shape}
\end{figure}
Some simple matrices such as the adjacency matrix of a graph and the identity matrix are also graph matrices, as we see below
\begin{itemize}
\item Take $\alpha$ to be a shape with two vertices $u, v$ with $U_{\alpha} = (u), V_{\alpha} = (v)$ and exactly one edge $\{u, v\}$. Then, $M_{\alpha}$ has rows and columns indexed by $[n]$ (more specifically tuples of length $1$) with the $i, j$-th entry being $G_{ij}$ if $i \neq j$ and $0$ otherwise. Therefore, $M_{\alpha}$ is just the $\pm 1$ adjacency matrix of the graph $G$.
\item Take $\alpha$ to be the shape with exactly $1$ vertex $u$, no edges and $U_{\alpha} = V_{\alpha} = (u)$. Then, $M_{\alpha}$ is the identity matrix of size $n \times n$.
\end{itemize}
For more examples of graph matrices and why they can be a useful tool to work with, see \cite{ahn2016graph}.
We now define some terms to capture the rows and columns of graph matrices.
\paragraph{Matrix indices and index shapes}
In the above setting of Rademacher $G_{n, 1/2}$ inputs, a matrix index $A$ is a tuple of indices $(a_1, \ldots, a_{|A|})$ where $a_i \in [n]$. When the SoS variables are $y_1, \ldots, y_n$, we associate to this matrix index $A$ the monomial $\prod_{i \le |A|} y_{a_i}$. With this definition, graph matrices have as rows and columns matrix indices.
Define an index shape $U = (u_1, \ldots, u_{|U|})$ to be a tuple of formal variables $u_i$, or in other words, unspecified indices. If $|U| = t$, we say that any matrix index $A$ of length $t$ has shape $U$. We say two index shapes $U, V$ are equivalent, denoted $U \equiv V$ if $|U| = |V|$. Finally, define the weight of $U$ to be $w(U) = |U|$ and the automorphism group $Aut(U) = S_{|U|}$ (the permutations of the elements of $U$). The latter definition is needed for describing coefficients.
\paragraph{Shape definitions}
We say a shape $\alpha$ is proper if it has no isolated vertices (i.e. no degree $0$ vertices) outside $U_{\alpha} \cup V_{\alpha}$. We say a shape $\alpha$ is trivial if $U_{\alpha}$ and $V_{\alpha}$ are equal as sets, and they constitute all the vertices in $\alpha$. and moreover, there are no edges in $\alpha$.
A path is a sequence of vertices of $V(\alpha)$ such that every consecutive pair of vertices form an edge in $V(\alpha)$. A vertex separator of $\alpha$ is a set of vertices $S$ such that every path from $U_{\alpha}$ to $V_{\alpha}$ passes through $S$. As we saw in \cref{chap: efron_stein}, the norm bounds of the graph matrix $M_{\alpha}$ rely on the size of the minimum vertex separator of $\alpha$. Define the weight of a vertex separator $S$ as $|S|$.
The above definitions are sufficient for the application to the Planted Slightly Denser subgraph problem. But when we work with Tensor PCA and Sparse PCA, we need to generalize the notion of shapes and graph matrices. These generalized shapes and graph matrices were studied in \cite{ahn2016graph}. Now, we describe the required generalizations.
\subsubsection{Definitions for Tensor PCA}
In the Tensor PCA application, the input is a tensor $A \in {\mathbb R}^{[n]^k}$. To incorporate this, we modify our definitions of shapes and index shapes accordingly. The input entries are now sampled from the distribution $\mathcal{N}(0, 1)$ instead of $\{-1, 1\}$. So, we will work with the Hermite basis of polynomials.
Let the standard unnormalized Hermite polynomials be denoted as $h_0(x) = 1, h_1(x) = x, h_2(x) = x^2 - 1, \ldots$. Then, we work with the basis $h_a(A) := \prod_{e \in [n]^k} h_e(A_e)$ over $a \in \mathbb{N}^{[n]^k}$. Accordingly, we will modify the graphs that represent shapes, to have labeled hyperedges of arity $k$. So, an hyperedge $e$ with a label $t$ will correspond to the hermite polynomial $h_t(A_e)$.
\begin{definition}[Hyperedges]
Instead of standard edges, we will have labeled hyperedges of arity $k$ in the underlying graphs for our ribbons as well as shapes. The label for an hyperedge $e$, denoted $l_e$, is an element of $\mathbb{N}$ which will correspond to the Hermite polynomial being evaluated on that entry.
\end{definition}
Note that our hyperedges are ordered since the tensor $A$ is not necessarily symmetric.
For variables $x_1, \ldots, x_n$, the rows and columns of our moment matrix will now correspond to monomials of the form $\prod_{i \le n} x_i^{p_i}$ for $p_i \ge 0$. To capture this, we use the notion of index shape pieces and index shapes. Informally, we split the above monomial product into groups based on their powers and each such group will form an index shape piece.
\begin{definition}[Index shape piece]
An index shape piece $U_i= ((U_{i, 1}, \ldots, U_{i, t}), p_i)$ is a tuple of indices $(U_{i, 1}, \ldots, U_{i, t})$ along with a power $p_i \in \mathbb{N}$. Let $V(U_i)$ be the set $\{U_{i, 1}, \ldots, U_{i, t}\}$ of vertices of this index shape piece. When clear from context, we use $U_i$ instead of $V(U_i)$.
\end{definition}
If we realize $U_{i, 1}, \ldots, U_{i, t}$ to be indices $a_1, \ldots, a_t \in [n]$, then this realization of this index shape piece corresponds to the monomial $\prod_{j \le t} x_{a_j}^{p_i}$.
\begin{definition}[Index shape]
An index shape $U$ is a set of index shape pieces $U_i$ that have different powers. Let $V(U)$ be the set of vertices $\cup_i V(U_i)$. When clear from context, we use $U$ instead of $V(U)$.
\end{definition}
Observe that each realization of an index shape corresponds to a row or column of the moment matrix.
Equivalence of index shapes is analogous, namely, for two index shapes $U, V$, we write $U \equiv V$ if for all powers $p$, the index shape pieces of power $p$ in $U$ and $V$ have the same length.
We also define the automorphism group of $U$ as $Aut(U) = \prod_{U_i \in U}{Aut(U_i)}$ where the automorphism group of an index shape piece $U_i$ is $Aut(U_i) = S_{|U_i|}$.
In the definition of shapes, the distinguished set of vertices should now be replaced by index shapes.
\begin{definition}[Shapes]
Shapes are tuples $\alpha = (V(\alpha), E(\alpha), U_{\alpha}, V_{\alpha})$ where $(V(\alpha), E(\alpha))$ is a graph with hyperedges of arity $k$ and $U_{\alpha}, V_{\alpha}$ are index shapes such that $U_{\alpha}, V_{\alpha} \subseteq V(\alpha)$.
\end{definition}
A shape $\alpha$ is proper if it has no isolated vertices outside $U_{\alpha} \cup V_{\alpha}$, no multi-edges and all the edges have a nonzero label.
To define the notion of vertex separators, we accordingly modify the notion of paths for hyperedges instead of edges. Formally, a path is a sequence of vertices $u_1, \ldots, u_t$ such that $u_i, u_{i + 1}$ are in the same hyperedge, for all $i \le t - 1$.
The notion of vertex separator is identically defined with the above notion of hyperedges and paths.
Finally, the definition of trivial shape $\tau$ is similar, the only change being that we now require $U_{\tau} \equiv V_{\tau}$ instead of saying they're equal as sets.
\subsubsection{Definitions for Sparse PCA}
We are given the $m$ vectors $v_1, \ldots, v_m \in {\mathbb R}^d$ as input. Similar to Tensor PCA, we will work with the Hermite basis of polynomials since the entries are sampled from the distribution $\mathcal{N}(0, 1)$.
In particular, if we denote the unnormalized Hermite polynomials by $h_0(x) = 1, h_1(x) = x, h_2(x) = x^2 - 1, \ldots$, then, we work with the basis $h_a(v) := \prod_{i \in [m], j \in [n]} h_{a_{i, j}}(v_{i, j})$ over $a \in \mathbb{N}^{m \times n}$. To capture this basis, we will modify the graphs that represent shapes to be bipartite graphs with two types of vertices, and have labeled edges that go across vertices of different types. So, an edge $(i, j)$ with label $t$ between a vertex $i$ of type $1$ and a vertex $j$ of type $2$ will correspond to $h_t(v_{i, j})$.
Formally, we will have two types of vertices, the vertices corresponding to the $m$ input vectors that we call type $1$ vertices and the vertices corresponding to ambient dimension of the space that we call type $2$ vertices. For a shape with such vertices, edges will go across vertices of different types, thereby forming a bipartite graph. An edge between a type $1$ vertex $i$ and a type 2 vertex $j$ corresonds to the input entry $v_{i, j}$. Each edge will have a label in $\mathbb{N}$ corresponding to the Hermite polynomial evaluated on that entry.
We will have variables $x_1, \ldots, x_n$ in our SoS program, so we will work with index shape pieces and index shapes as in Tensor PCA, since the rows and columns of our moment matrix will now correspond to monomials of the form $\prod_{i \le n} x_i^{p_i}$ for $p_i \ge 0$. But since we have $2$ types of vertices, we need to slightly modify the notion of index shape pieces and index shapes.
\begin{definition}[Index shape piece]
An index shape piece $U_i= ((U_{i, 1}, \ldots, U_{i, t}), t_i, p_i)$ is a tuple of indices $(U_{i, 1}, \ldots, U_{i, t})$ along a type $t_i \in \{1, 2\}$ with a power $p_i \in \mathbb{N}$. Let $V(U_i)$ be the set $\{U_{i, 1}, \ldots, U_{i, t}\}$ of vertices of this index shape piece. When clear from context, we use $U_i$ instead of $V(U_i)$.
\end{definition}
For an index shape piece $((U_{i, 1}, \ldots, U_{i, t}), t_i, p_i)$ with type $t_i = 2$, if we realize $U_{i_1}, \ldots, U_{i_t}$ to be indices $a_1, \ldots, a_t \in [n]$, then, this index shape pieces correspond this to the monomial $\prod_{j \le n} x_{a_j}^{p_i}$.
\begin{definition}[Index shape]
An index shape $U$ is a set of index shape pieces $U_i$ that have either have different types or different powers. Let $V(U)$ be the set of vertices $\cup_i V(U_i)$. When clear from context, we use $U$ instead of $V(U)$.
\end{definition}
Each realization of an index shape will correspond to a row or column of the moment matrix. For our moment matrix, the only nonzero rows correspond to index shapes that have only index shape pieces of type $2$, since the only SoS variables are $x_1 \ldots, x_n$, but in order to do our analysis, we need to work with the generalized notion of index shapes that allow index shape pieces of both types.
Analogous to our previous definitions, for two index shapes $U, V$, we write $U \equiv V$ if for all types $t$ and all powers $p$, the index shape pieces of type $t$ and power $p$ in $U$ and $V$ have the same length.
Since we are working with standard graphs, the original notion of path and vertex separator will work , but we will now use the minimum weight vertex separator instead of the minimum vertex separator where we define the weight as follows.
\begin{definition}[Weight of an index shape]
Suppose we have an index shape $U = \{U_1, U_2\} \in {\mathcal I}_{mid}$ where $U_1 = ((U_{1, 1}, \ldots, U_{1, |U_1|}), 1, 1)$ is an index shape piece of type $1$ and $U_2 = ((U_{2, 1}, \ldots, U_{2, |U_2|}), 2, 1)$ is an index shape piece of type $2$. Then, define the weight of this index shape to be $w(U) = \sqrt{m}^{|U_1|}\sqrt{n}^{|U_2|}$.
\end{definition}
The definition carries over for a vertex separator as well. We also define the automorphism group of $U$ as $Aut(U) = \prod_{U_i \in U}{Aut(U_i)}$ where the automorphism group of an index shape piece $U_i$ is $Aut(U_i) = S_{|U_i|}$. We now give the modified definition of shapes.
\begin{definition}[Shapes]
Shapes are tuples $\alpha = (V(\alpha), E(\alpha), U_{\alpha}, V_{\alpha})$ where $(V(\alpha), E(\alpha))$ is a graph with two types of vertices, has labeled edges only across vertices of different types and $U_{\alpha}, V_{\alpha}$ are index shapes such that $U_{\alpha}, V_{\alpha} \subseteq V(\alpha)$.
\end{definition}
The other definitions that follow are analogous. A shape $\alpha$ is proper if it has no isolated vertices outside $U_{\alpha} \cup V_{\alpha}$, no multi-edges and all the edges have a nonzero label. In the definition of trivial shape $\tau$, just as in Tensor PCA, we require $U_{\tau} \equiv V_{\tau}$ instead of saying they're equal as sets.
\subsection{Decomposing shapes}
Compared to the lower bound strategy in the Sherrington-Kirkpatrick lower bound in \cref{chap: sk}, the main strategy in the machinery is to provide an approximate PSD decomposition by decomposing shapes $\alpha$ into three other shapes $\sigma, \tau, \sigma'^T$ such that $M_{\alpha} \approx M_{\sigma}M_{\tau} M_{\sigma'^T}$. Then, the idea is to argue that the graph matrix coefficients of the moment matrix also decompose similarly, ending with a PSD decomposition showing that the moment matrix is PSD.
We first need to define composition of shapes. We say that shapes $\alpha$ and $\beta$ are composable if $U_{\beta} \equiv V_{\alpha}$. In this case, define their composition to be the shape $\alpha \circ \beta$ which is obtained by concatenating $\alpha, \beta$ while gluing together $U_{\beta}, V_{\alpha}$. Formally, $\alpha\circ \beta$ is such that $U_{\alpha \circ \beta} = U_{\alpha}$, $V_{\alpha \circ \beta} = V_{\beta}$, and after setting $U_{\beta} = V_{\alpha}$, we take $V(\alpha \circ \beta) = V(\alpha) \cup V(\beta)$, and finally, $E(\alpha \circ \beta) = E(\alpha) \cup E(\beta)$.
Note that by doing this, the concatenated shape could become improper if edges repeat.
We remark that shape composition is not necessarily commutative, but it is associative.
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.45, trim={4.5cm 2cm 0 2cm},clip]{machinery/images/basic_shape_comp}
\caption{Illustration of shape composition and decomposition.}
\label{fig: basic_shape_comp}
\end{figure}
\begin{example}
\cref{fig: basic_shape_comp} illustrates an example of shape composition in the setting where there is only one type of vertex. Observe how the shapes $\sigma \circ \sigma'^T$ and $\sigma \circ \tau \circ \sigma'^T$ are obtained from the shapes $\sigma, \tau$ and $\sigma'^T$.
\end{example}
\begin{example}
\cref{fig: shape_comp} illustrates an example of shape composition in the setting where there are two types of vertices. We have two types of vertices that we diagrammaticaly represent by squares and circles. Observe how the shapes $\sigma \circ \sigma'^T$ and $\sigma \circ \tau \circ \sigma'^T$ are obtained from the shapes $\sigma, \tau$ and $\sigma'^T$.
\end{example}
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.38, trim={8cm 2cm 0 2cm},clip]{machinery/images/shape_comp}
\caption{Illustration of shape composition and decomposition.}
\label{fig: shape_comp}
\end{figure}
Previously, we defined the notion of minimum vertex separators (and analogously, minimum weight vertex separators). In what follows, we collectively term either of them as minimum weight vertex separators. by Define the \textit{leftmost} (resp. \textit{rightmost}) minimum-weight vertex separator $S$ (resp. $T$) to be a minimum-weight vertex separator such that for every other minimum-weight vertex separator $S'$ (resp. $T'$), $S$ separates $U_{\alpha}$ from $S'$ (resp. $T'$ from $V_{\alpha}$).
In \cite{BHKKMP16, potechin2020machinery}, it's shown that these are well-defined.
With these definitions in hand, we can now define how to decompose a shape $\alpha$ into its left, middle and right parts $\sigma, \tau, \sigma'^T$ respectively.
\begin{definition}[Shape decomposition]
Let $\alpha$ be a shape. Let $S$ and $T$ be the leftmost and rightmost minimum-weight vertex separators of $\alpha$ together with some orderings $O_S,O_T$ of $S$ and $T$.
\begin{itemize}
\item We define the left part $\sigma$ of $\alpha$ to be the shape formed by taking the induced subgraph on all of the vertices of $\alpha$ reachable from $U_{\alpha}$ without passing through $S$ (but including the vertices of $S$) where all edges and hyperedges within $S$ are removed, and we take $U_{\sigma} = U_{\alpha}$ and $V_{\sigma} = (S,O_S)$.
\item We define the right part ${\sigma'}^T$ of $\alpha$ to be the shape formed by taking the induced subgraph on all of the vertices of $\alpha$ reachable from $V_{\alpha}$ without passing through $T$ (but we include the vertices of $T$) where all edges and hyperedges within $T$ are removed, and we take $V_{{\sigma'}^T} = V_{\alpha}$ and $U_{{\sigma'}^T} = (T,O_T)$.
\item Finally, we define the middle part $\tau$ of $\alpha$ to be the shape formed by the induced subgraph on all of the vertices of $\alpha$ which are not reachable from $U_{\alpha}$ and $V_{\alpha}$ without touching $S$ and $T$ respectively (but we include the vertices of $S$ and $T$), where we also include the edges or hyperedges entirely within $S$ and the edges or hyperedges entirely within $T$, and we take $U_{\tau} = (S,O_S)$ and $V_{\tau} = (T,O_T)$.
\end{itemize}
\end{definition}
It's evident from the definition that $\alpha = \sigma \circ \tau \circ \sigma'^T$.
\begin{example}
\cref{fig: basic_shape_comp} illustrates an example decomposition in the setting where there is only one type of vertex.
\begin{enumerate}
\item If we start with the shape $\alpha$ denoted as $\sigma \circ \sigma'^T$, observe that there is a unique minimum vertex separator, which consists of the middle vertex of degree $5$, i.e. the one that's not in either $U_{\sigma \circ \sigma'^T}$ or $V_{\sigma \circ \sigma'^T}$.
Then, $\alpha$ is decomposed in to the left part $\sigma$, a trivial middle part $\tau$ (not shown in this figure) which has $V(\tau) = \{u\}, U_{\tau} = V_{\tau} = (u), E(\tau) = \emptyset$, and the right part $\sigma'^T$.
\item If we start with the shape $\alpha$ denoted as $\sigma \circ \tau \circ \sigma'^T$, then the leftmost minimum vertex separator is the vertex of degree $4$ and the rightmost minimum vertex separator is the vertex of degree $5$. Then, $\alpha$ is decomposed into the left part $\sigma$, the middle part $\tau$ and the right part $\sigma'^T$, which are all shown in this figure.
\end{enumerate}
\end{example}
\begin{example}
\cref{fig: shape_comp} illustrates an example decomposition in the setting where there are two types of vertices. We have two types of vertices that we diagrammatically represent by squares and circles. In this example, we assume that the set containing a single circle vertex has a lower weight compared to a set of two square vertices.
\begin{enumerate}
\item If we start with the shape $\sigma \circ \sigma'^T$, then it can be decomposed uniquely in to the composition of the left shape $\sigma$, the right shape $\sigma'^T$. In this case, the middle shape (not shown in this figure) is trivial.
\item If we start with the shape $\sigma \circ \tau \circ \sigma'^T$, then it can be decomposed uniquely into the composition of the left shape $\sigma$, the middle shape $\tau$ and the right shape $\sigma'^T$, which are all shown in this figure.
\end{enumerate}
\end{example}
At this point, the definitions of left shapes, middle shapes and right shapes are natural.
We say that a shape $\sigma$ is a left shape if $\sigma$ is a proper shape, $V_{\sigma}$ is the left-most and right-most minimum-weight separator of $\sigma$, every vertex in $V(\sigma) \setminus V_{\sigma}$ is reachable from $U_{\sigma}$ without touching $V_{\sigma}$, and $\sigma$ has no hyperedges entirely within $V_{\sigma}$.
Similarly, we say that a shape $\tau$ is a proper middle shape if $\tau$ is a proper shape, $U_{\tau}$ is the left-most minimum-weight separator of $\tau$, and $V_{\tau}$ is the right most minimum-weight separator of $\tau$. We do not define improper middle shapes, which are needed in the machinery proof, but not here.
Finally, we say that a shape ${\sigma}^{T}$ is a right shape if it is the transpose of a left shape.
\subsection{Coefficient matrices}
We have all the necessary definitions in place for shapes and graph matrices. To apply the machinery, we will decompose the given moment matrix $\Lambda$ as $\Lambda = \sum \lambda_{\alpha}M_{\alpha}$ where the sum is over all shapes $\alpha$. The coefficients $\lambda_{\alpha}$ are then assembled into matrices, termed coefficient matrices, that we will define next. The conditions of the machinery will be in terms of these coefficient matrices.
We will begin with some notations for different sets of index shapes. Given a moment matrix $\Lambda$, define $\mathcal{I}(\Lambda)$ to the set of matrix shapes $U$ such that some row or column index of $\Lambda$ has shape $U$. Define $w_{max} = \max{\{w(U):U \in \mathcal{I}(\Lambda)\}}$ to be the maximum possible weight of an index shape in ${\mathcal I}(\Lambda)$. Finally, define $\mathcal{I}_{mid}$ to be $\mathcal{I}_{mid} = \{U: w(U) \leq w_{max}, \forall U_i \in U, p_i = 1\}$.
Observe that in the setting of Rademacher $G_{n, 1/2}$ inputs, we have $\mathcal{I}_{mid} = \{U: |U| \leq w_{max}\}$.
In pseudo-calibration, we only keep the shapes that satisfy certain truncation parameters that we choose. Formally, satisfication of truncation parameters is defined as follows.
\begin{definition}[Truncation parameters for the setting of Rademacher $G_{n, 1/2}$ inputs]
For integers $D_{sos}, D_V \ge 0$, say that a shape $\alpha$ satisfies the truncation parameters $D_{sos}, D_V$ if
\begin{itemize}
\item The degrees of the monomials that $U_{\alpha}$ and $V_{\alpha}$ correspond to, are at most $\frac{D_{sos}}{2}$
\item The left part $\sigma$, the middle part $\tau$ and the right part $\sigma'$ of $\alpha$ satisfy the bounds $|V(\sigma)|, |V(\tau)|, |V(\sigma')| \le D_V$.
\end{itemize}
\end{definition}
\begin{definition}[Truncation parameters for Tensor PCA and Sparse PCA]
For integers $D_{sos}, D_V, D_E \ge 0$, say that a shape $\alpha$ satisfies the truncation parameters $D_{sos}, D_V, D_E$ if
\begin{itemize}
\item The degrees of the monomials that $U_{\alpha}$ and $V_{\alpha}$ correspond to, are at most $\frac{D_{sos}}{2}$
\item The left part $\sigma$, the middle part $\tau$ and the right part $\sigma'^T$ of $\alpha$ satisfy the bounds $|V(\sigma)|, |V(\tau)|, |V(\sigma'^T)| \le D_V$
\item For each $e \in E(\alpha)$, $l_e \le D_E$.
\end{itemize}
\end{definition}
We also need to define the sets of shapes which can appear when analyzing $\Lambda$.
Given a moment matrix $\Lambda$, define $\mathcal{L} = \{\sigma: \sigma \text{ is a left shape}, U_{\sigma} \in \mathcal{I}(\Lambda), V_{\sigma} \in \mathcal{I}_{mid}, |V(\sigma)| \leq D_V, \forall e \in E(\sigma), l_e \leq D_E\}$. Moreover, given $V \in \mathcal{I}_{mid}$, define $\mathcal{L}_V = \{\sigma \in \mathcal{L}: V_{\sigma} \equiv V\}$. Finally, given $U \in \mathcal{I}_{mid}$, define $\mathcal{M}_U = \{\tau: \tau \text{ is a non-trivial proper middle shape}, U_{\tau} \equiv V_{\tau} \equiv U, |V(\tau)| \leq D_V, \forall e \in E(\tau), l_e \leq D_E\}$.
We are now ready to define coefficient matrices. Given a moment matrix $\Lambda$, a coefficient matrix is a matrix $H$ whose rows and columns are indexed by left shapes $\sigma,\sigma' \in \mathcal{L}$. $H$ is called SoS-symmetric if $H(\sigma,\sigma')$ is invariant under the action of the symmetric group, i.e. if we permute the vertices of $U_{\sigma}$ and the vertices of $U_{\sigma'}$ (where we only permute within the same type) under the same permutation, then the entry doesn't change.
For a shape $\tau$, we say that a coefficient matrix $H$ is a $\tau$-coefficient matrix if $H(\sigma,\sigma') = 0$ whenever $V_{\sigma} \not\equiv U_{\tau}$ or $V_{\tau} \not\equiv U_{{\sigma'}^T}$. Given an index shape $U$, we define $Id_{U}$ to be the shape with $U_{Id_{U}} = V_{Id_{U}} = U$, no other vertices, and no edges.
As stated earlier, the coefficients $\lambda_{\alpha}$ of the moment matrix $\Lambda$ are assembled to form coefficient matrices, which are used to state the machinery conditions.
Given a shape $\tau$ and a $\tau$-coefficient matrix $H$, we consider the matrix-valued function $M^{fact}_{\tau}(H)$ defined as
\[
M^{fact}_{\tau}(H) = \sum_{\sigma \in \mathcal{L}_{U_{\tau}},\sigma' \in \mathcal{L}_{V_{\tau}}}{H(\sigma,\sigma')M_{\sigma}M_{\tau}M_{\sigma'}^T}
\]
The motivation for this definition is as follows. First observe that $\Lambda$ is essentially an expression of the form $\sum_{\tau}\sum_{\sigma, \sigma'}{H(\sigma,\sigma')M_{\sigma \circ \tau \circ {\sigma'}^T}}$. For each $\tau$, the inner expression sort of looks like $M_{\tau}^{fact}(H)$. However, there is a technical difference.
Recall that if we expand out the definition of the graph matrices $M_{\sigma}, M_{\tau}$ and $M_{\sigma'}^T$, then $M_{\tau}^{fact}(H)$ sums over non-equivalent realizations coming from the sets $\textrm{Real}(\sigma), \textrm{Real}(\tau), \textrm{Real}(\sigma'^T)$ respectively. Apriori, it's not guaranteed that for each choice of realizations $\varphi_1, \varphi_2, \varphi_3$ from these sets, the corresponding subset of labels $\varphi_1(V(\sigma)), \varphi_2(V(\tau)), \varphi_3(V(\sigma'^T)) \subseteq [n]$ are disjoint. However, if we enforce that they are disjoint, then we will obtain a matrix closely related to what we desire. The work \cite{potechin2020machinery} terms this matrix obtained by enforcing disjointness of the realizations as $M^{orth}_{\tau}(H)$.
As they remark, it is not true that $M^{orth}_{\tau}(H) = \sum_{\sigma,\sigma'}{H(\sigma,\sigma')M_{\sigma \circ \tau \circ {\sigma'}^T}}$ because of additional terms involving automorphism groups.
Nevertheless, because of this enforced condition that the realizations don't overlap, $\Lambda$ can be easily expressed in terms of $M^{orth}$. Indeed, as they show via careful counting, $\Lambda = \sum_{U \in \mathcal{I}_{mid}}{M^{orth}_{Id_U}(H_{Id_U})} + \sum_{U \in \mathcal{I}_{mid}}{\sum_{\tau \in \mathcal{M}_U}{M^{orth}_{\tau}(H_{\tau})}}$, where $H_{Id_U}$ and $H_{\tau}$, formally defined below, are simple coefficient matrices assembled from $\lambda_{\alpha}$
Despite wanting to work with $M^{orth}$, the machinery instead works with $M^{fact}$ instead because showing PSDness is easier with $M^{fact}$ due to the product structure. The proof strategy in the machinery is to then show that the error terms when going from $M^{fact}$ to $M^{orth}$ (and therefore, $\Lambda$) are negligible with high probability, concluding the PSDness proof.
Given a matrix-valued function $\Lambda$, we assemble the following coefficient matrices.
\begin{definition}
Given a matrix-valued function $\Lambda = \sum_{\alpha: \alpha \text{ is proper}}{\lambda_{\alpha}M_{\alpha}}$,
\begin{enumerate}
\item For each index shape $U \in \mathcal{I}_{mid}$ and every $\sigma,\sigma' \in \mathcal{L}_{U}$, set $H_{Id_U}(\sigma,\sigma') = \frac{1}{|Aut(U)|}\lambda_{\sigma \circ {\sigma'}^T}$
\item For each $U \in \mathcal{I}_{mid}$, $\tau \in \mathcal{M}_U$ and $\sigma, \sigma' \in \mathcal{L}_{U}$, set
$H_{\tau}(\sigma,\sigma') = \frac{1}{|Aut(U_{\tau})|\cdot|Aut(V_{\tau})|}\lambda_{\sigma \circ \tau \circ {\sigma'}^T}$
\end{enumerate}
\end{definition}
We need a final definition, that of the coefficient matrix $H^{-\gamma, \gamma}$.
In order to handle error terms in the approximate PSD decomposition, the machinery has to further decompose left shapes $\sigma$ as $\sigma = \sigma_2 \circ \gamma$ where $\sigma_2$ and $\gamma$ are themselves left shapes. In order to capture this operation, the following definitions are needed.
Given a moment matrix $\Lambda$, define $\Gamma = \{\gamma: \gamma \text{ is a non-trivial left shape with } U_{\gamma}, V_{\gamma} \in \mathcal{I}_{mid}, |V(\gamma)| \leq D_V, \forall e \in E(\gamma), l_e \leq D_E\}$. Moreover, given $U,V \in \mathcal{I}_{mid}$ such that $w(U) > w(V)$, define $\Gamma_{U,V} = \{\gamma \in \Gamma: U_{\gamma} \equiv U, V_{\gamma} \equiv V\}$. Finally, given $U \in \mathcal{I}_{mid}$, define $\Gamma_{U,*} = \{\gamma \in \Gamma: U_{\gamma} \equiv U\}$.
We finally define the coefficient matrix $H^{-\gamma, \gamma}$ given the truncation parameter $D_V$. Given a shape $\tau$ with $U_{\tau} \equiv V_{\tau}$, left shape $\gamma \in {\Gamma}_{*,U_{\tau}}$ (and therefore, $\gamma \in {\Gamma}_{*,V_{\tau}}$), and a $\tau$-coefficient matrix $H$, define $H^{-\gamma,\gamma}$ to be the $(\gamma \circ \tau \circ {\gamma}^T)$-coefficient matrix with entries
\begin{itemize}
\item $H^{-\gamma,\gamma}(\sigma,\sigma') = H(\sigma \circ \gamma,\sigma' \circ \gamma)$ if $|V(\sigma \circ \gamma)| \leq D_V$ and $|V(\sigma' \circ \gamma)| \leq D_V$.
\item $H^{-\gamma,\gamma}(\sigma,\sigma') = 0$ if $|V(\sigma \circ \gamma)| > D_V$ or $|V(\sigma' \circ \gamma)| > D_V$.
\end{itemize}
\subsection{Main theorems}
For a problem ${\mathcal P}$, let $\Lambda_{{\mathcal P}}$ be the moment matrix obtained via pseudo-calibration. We then state the conditions that the machinery requires in order to show positivity with high probability.
We will use the following notion of distance between coefficient matrices, which will be useful to bound truncation error.
\begin{definition}
Given a function $B_{norm}(\alpha)$, define the distance $d_{\tau}(H_{\tau},H'_{\tau})$ between two $\tau$-coefficient matrices $H_{\tau}$ and $H'_{\tau}$ as
\[
d_{\tau}(H_{\tau},H'_{\tau}) = \sum_{\sigma \in \mathcal{L}_{U_{\tau}},\sigma' \in \mathcal{L}_{V_{\tau}}}{|H'_{\tau}(\sigma,\sigma') - H_{\tau}(\sigma,\sigma')|B_{norm}(\sigma)B_{norm}(\tau)B_{norm}(\sigma')}
\]
\end{definition}
We also define $Id_{Sym}$, which is the SoS-symmetric analogue of the identity matrix. For a matrix index $A$, denote by $p_A$ the formal monomial (in terms of the SoS program variables) it corresponds to. Define $Id_{Sym}$ to be the matrix such that the rows and columns of $Id_{Sym}$ are indexed by the matrix indices $A,B$ whose index shape is in $\mathcal{I}(\Lambda)$ and $Id_{Sym}(A,B) = 1$ if $p_A = p_B$ and $Id_{Sym}(A, B) = 0$ if $p_A \neq p_B$.
We introduce a few more notations about shapes in order to state our parameters.
Define $\mathcal{M}'$ to be the set of all shapes $\alpha$ such that $|V(\alpha)| \leq 3D_V$, $\forall e \in E(\alpha), l_e \leq D_E$ and all edges $e \in E(\alpha)$ have multiplicity at most $3D_V$. Note that the latter two conditions are not needed for the setting of Rademacher $G_{n, 1/2}$ inputs but they're needed in the setting of Gaussian inputs.
In the setting of Rademacher $G_{n, 1/2}$ inputs, for a shape $\alpha$, define $S_{\alpha}$ to be the leftmost minimum vertex separator of $\alpha$ and define $I_{\alpha}$ to be the set of vertices in $V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})$ which are isolated. In the setting of Gaussian $\mathcal{N}(0, 1)$ inputs, for a shape $\alpha \in \mathcal{M}'$, define $S_{\alpha,min}$ to be the leftmost minimum vertex separator of $\alpha$ if all edges with multiplicity at least $2$ are deleted. Moreover, define $I_{\alpha}$ to be the set of vertices in $V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})$ such that all edges incident with that vertex have multiplicity at least $2$.
\subsubsection{Choice of parameters in the setting of Rademacher $G_{n, 1/2}$ inputs}
We first state some parameters we will use in this work and then state the main conditions that are needed for the main theorem statement, which is stated after this.
Let $\varepsilon > 0$ and $D_V, D_E$ be truncation parameters. Define
\begin{itemize}
\item $q = 3\left\lceil{{D_V}\ln n + \frac{\ln(\frac{1}{\varepsilon})}{3} + {D_V}\ln 5 + 3{D^2_V}\ln 2}\right\rceil$
\item $B_{vertex} = 6{D_V}\sqrt[4]{2eq}$
\item $B_{norm}(\alpha) = {B_{vertex}^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}}n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha})}{2}}$
\item $B(\gamma) = B_{vertex}^{|V(\gamma) \setminus U_{\gamma}| + |V(\gamma) \setminus V_{\gamma}|}n^{\frac{w(V(\gamma) \setminus U_{\gamma})}{2}}$
\item $N(\gamma) = (3D_V)^{2|V(\gamma) \setminus V_{\gamma}| + |V(\gamma) \setminus U_{\gamma}|}$
\item $c(\alpha) = 100(3D_V)^{|U_{\alpha} \setminus V_{\alpha}| + |V_{\alpha} \setminus U_{\alpha}| + 2|E(\alpha)|}2^{|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})|}$
\end{itemize}
In our application, as stated earlier, we show SoS lower bounds for degree-$n^{\varepsilon}$ SoS, where the input size is $n^{O(1)}$. In this setting, we take $D_V, D_E$ to be of the order of $n^{O(\varepsilon)}$. Therefore, for simplicity, we can interpret the parameters as
\[q = n^{O(\varepsilon)}, B_{vertex} = n^{O(\varepsilon)}, B_{norm}(\alpha) =n^{O(\varepsilon)|V(\alpha)|}n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha})}{2}}\]
\[B(\gamma) = n^{O(\varepsilon)|V(\gamma)|}n^{\frac{w(V(\gamma) \setminus U_{\gamma})}{2}}, N(\gamma) = n^{O(\varepsilon)|V(\gamma)|}, c(\alpha) = n^{O(\varepsilon)|V(\alpha)|}\]
\subsubsection{Choice of parameters in the setting of Gaussian inputs on hypergraphs}
We now state the parameters needed for the more general statement of the machinery where we have Gaussian inputs on hypergraphs.
In this setting, let there be at most $t_{max}$ types of vertices and let $k$ be the maximum arity of an hyperedge. In the setting of Tensor PCA, we take $t_{max} = 1$ and in the setting of Sparse PCA, we take $k = t_{max} = 2$.
For all $\varepsilon > 0$ and truncation parameters $D_V, D_E$, define
\begin{enumerate}
\item $q = \left\lceil{3{D_V}\ln n + \ln(\frac{1}{\varepsilon}) + {(3D_V)^k}\ln(D_E + 1) + 3{D_V}\ln 5}\right\rceil$
\item $B_{vertex} = 6q{D_V}$
\item $B_{edge}(e) = \left(400{D^2_V}{D^2_E}q\right)^{l_e}$
\item $B_{norm}(\alpha) =
2e{B_{vertex}^{|V(\alpha) \setminus U_{\alpha}| + |V(\alpha) \setminus V_{\alpha}|}}\left(\prod_{e \in E(\alpha)}{B_{edge}(e)}\right)n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha,min})}{2}}$
\item $B(\gamma) = B_{vertex}^{|V(\gamma) \setminus U_{\gamma}| + |V(\gamma) \setminus V_{\gamma}|}\left(\prod_{e \in E(\gamma)}{B_{edge}(e)}\right)n^{\frac{w(V(\gamma) \setminus U_{\gamma})}{2}}$
\item $N(\gamma) = (3D_V)^{2|V(\gamma) \setminus V_{\gamma}| + |V(\gamma) \setminus U_{\gamma}|}$
\item $c(\alpha) = 100(3{t_{max}}D_V)^{|U_{\alpha} \setminus V_{\alpha}| + |V_{\alpha} \setminus U_{\alpha}| + k|E(\alpha)|}(2t_{max})^{|V(\alpha) \setminus (U_{\alpha} \cup V_{\alpha})|}$
\end{enumerate}
In our applications, we can interpret the above parameters in a much simpler manner again. More specifically, $k$ is a constant and we work with SoS degree $n^{\varepsilon}$. Then, we can think of each vertex or edge of the shape $\alpha$ or $\gamma$ essentially contributing a factor of $n^{\varepsilon}$. Therefore, we can interpret
\[q = n^{O(\varepsilon)}, B_{vertex} = n^{O(\varepsilon)}, B_{edge} = n^{O(\varepsilon)|E(\alpha)|}\]
\[B_{norm}(\alpha) = n^{O(\varepsilon)(|V(\alpha)| + |E(\alpha)|)}n^{\frac{w(V(\alpha)) + w(I_{\alpha}) - w(S_{\alpha,min})}{2}}\]
\[B(\gamma) = n^{O(\varepsilon)(|V(\gamma)| + |E(\gamma)|)}n^{\frac{w(V(\gamma) \setminus U_{\gamma})}{2}}\]
\[N(\gamma) = n^{O(\varepsilon)|V(\gamma)|}, c(\alpha) = n^{O(\varepsilon)(|V(\alpha)| + |E(\alpha)|)}\]
\subsubsection{Statement of the machinery}
As discussed above, consider the appropriate choice of parameters suited for the problem. Now, we can state our conditions on the problem ${\mathcal P}$ in terms of its correspondingly constructed pseudo-calibrated moment matrix $\Lambda_{{\mathcal P}}$ and coefficient matrices $H_{Id_U}, H_{\tau}$.
\begin{definition}[PSD mass]
We say that ${\mathcal P}$ satisfies \normalfont{(PSD mass) } if for all $U \in \mathcal{I}_{mid}$, $H_{Id_{U}} \succeq 0$.
\end{definition}
\begin{definition}[Middle shape bounds]
We say that ${\mathcal P}$ satisfies \normalfont{(Middle shape bounds) } if for all $U \in \mathcal{I}_{mid}$ and $\tau \in \mathcal{M}_U$,
\[
\left[ {\begin{array}{cc}
\frac{1}{|Aut(U)|c(\tau)}H_{Id_{U}} & B_{norm}(\tau)H_{\tau} \\
B_{norm}(\tau)H^T_{\tau} & \frac{1}{|Aut(U)|c(\tau)}H_{Id_{U}}
\end{array}} \right] \succeq 0
\]
\end{definition}
\begin{definition}[Intersection term bounds]
For some SoS-symmetric coefficient matrices $\{H'_{\gamma}: \gamma \in \Gamma\}$, ${\mathcal P}$ satisfies \normalfont{(Intersection term bounds) } with respect to them if for all $U,V \in \mathcal{I}_{mid}$ where $w(U) > w(V)$ and all $\gamma \in \Gamma_{U,V}$,
\[
c(\gamma)^2{N(\gamma)}^2{B(\gamma)^2}H^{-\gamma,\gamma}_{Id_{V}} \preceq H'_{\gamma}
\]
\end{definition}
\begin{definition}[Truncation error bounds]
For some SoS-symmetric coefficient matrices $\{H'_{\gamma}: \gamma \in \Gamma\}$,
${\mathcal P}$ satisfies \normalfont{(Truncation error bounds) } with respect to them if the following condition holds: Whenever $\norm{M_{\alpha}} \leq B_{norm}(\alpha)$ for all $\alpha \in \mathcal{M}'$,
\[
\sum_{U \in \mathcal{I}_{mid}}{M^{fact}_{Id_U}{(H_{Id_U})}} \succeq 6\left(\sum_{U \in \mathcal{I}_{mid}}{\sum_{\gamma \in \Gamma_{U,*}}{\frac{d_{Id_{U}}(H'_{\gamma},H_{Id_{U}})}{|Aut(U)|c(\gamma)}}}\right)Id_{sym}
\]
\end{definition}
Finally, we can state our main theorem.
\begin{theorem}\label{generalmaintheorem}
For all $\varepsilon > 0$, if we take the parameters defined above, and we have SoS-symmetric coefficient matrices $\{H'_{\gamma}: \gamma \in \Gamma\}$ such that ${\mathcal P}$ satisfies \normalfont{(PSD mass) }, \normalfont{(Middle shape bounds) }, \normalfont{(Intersection term bounds) } and \normalfont{(Truncation error bounds) }\hspace{-.8em},
then with probability at least $1 - \varepsilon$, $\Lambda_{{\mathcal P}} \succeq 0$.
\end{theorem}
In our applications, for problems ${\mathcal P}$ of interest, we pseudo-calibrate, decompose into graph matrices, exhibit the desired conditions on ${\mathcal P}$ and invoke the machinery to prove our lower bounds.
\subsubsection{Choice of $H'_{\gamma}$ for our applications}\label{sec: hgamma_qual}
In our applications, we choose $H'_{\gamma}$ as follows.
\begin{enumerate}
\item $H'_{\gamma}(\sigma,\sigma') = H_{Id_U}(\sigma, \sigma')$ whenever $|V(\sigma \circ \gamma)| \leq D_V$ and $|V(\sigma' \circ \gamma)| \leq D_V$.
\item $H'_{\gamma}(\sigma,\sigma') = 0$ whenever $|V(\sigma \circ \gamma)| > D_V$ or $|V(\sigma' \circ \gamma)| > D_V$.
\end{enumerate}
Then, the truncation error that we need to bound is
\[
d_{Id_{U_{\gamma}}}(H_{Id_{U_{\gamma}}},H'_{\gamma}) = \sum_{\sigma,\sigma' \in \mathcal{L}_{U_{\gamma}}: V(\sigma) \leq D_V, V(\sigma') \leq D_V,
\atop |V(\sigma \circ \gamma)| > D_V \text{ or } |V(\sigma' \circ \gamma)| > D_V}{B_{norm}(\sigma)B_{norm}(\sigma')H_{Id_{U_{\gamma}}}(\sigma,\sigma')}
\]
\chapter{Introduction}\label{chap: intro}
\input{intro}
\chapter{Nonlinear matrix concentration}\label{chap: efron_stein}
\input{efron_stein}
\chapter{The Sum of Squares Hierarchy}\label{chap: sos}
\input{sos}
\chapter{Our main results on Sum of Squares lower bounds}\label{chap: main_results}
\input{main_results}
\chapter{The Sherrington-Kirkpatrick Hamiltonian}\label{chap: sk}
\input{sk}
\chapter{The machinery and Qualitative bounds}\label{chap: qual}
\input{qual}
\chapter{Quantitative bounds}\label{chap: quant}
\input{quant}
\chapter{Followup and Future work}\label{chap: future_work}
\input{future_work}
\makebibliography
\end{document}
\section{The Sherrington-Kirkpatrick Hamiltonian}
We first define the Gaussian Orthogonal Ensemble, $\GOE(n)$, a random matrix model for $n \times n$ matrices.
\begin{definition}
The Gaussian Orthogonal Ensemble, denoted $\GOE(n)$, is the distribution of $\frac{1}{\sqrt{2}}(A + A^\intercal)$
where $A$ is a random $n\times n$ matrix with i.i.d. standard Gaussian entries.
\end{definition}
Equivalently, we could define $\GOE(n)$ to be a probability distribution over symmetric matrices $W$ such that $W_{ii} \sim \mathcal{N}(0, 2)$ for $i \le n$ and for $i\neq j$, $W_{ij} = W_{ji} \sim \mathcal{N}(0, 1)$ independently.
We consider the main optimization task
\begin{equation}\label{eq:general_opt}
\OPT(W) := \max_{x \in \{\pm 1\}^n} x^\intercal W x,
\end{equation}
where $W$ is a random symmetric matrix in ${\mathbb R}^{n\times n}$. This is an important task that arises in computer science and statistical physics.
In computer science, a natural choice of $W$ is to take it to be the Laplacian of a graph~\cite[Section 4]{HooryLW06}. Then, the problem is equivalent to the
Maximum Cut problem, a well-known NP-hard problem in the worst
case~\cite{K72}. The equivalence is immediate by observing that
$x \in \{\pm 1\}^n$ can be thought of as encoding a bipartition of $[n] = \{1,
2, \ldots, n\}$.
In particular, an interesting special case is when we consider sparse random graphs, sampled either from the Erd\H{o}s\xspace-R\'enyi\xspace graphs $G(n, \frac{d}{n})$ with average degree $d$ or a uniformly chosen $d$-regular graph, where $d \ge 3$ is a fixed integer.
In this case, it is known that the true size of the maximum cut is asymptotically $n(\frac{d}{4} + f(d) \sqrt{d})$.
Moreover, it was shown in \cite{dembo2017extremal} (originally conjectured in \cite{zdeborova2010conjecture}) that $\lim_{d \rightarrow \infty} f(d) = \frac{1}{2}P^* \approx 0.382$, where
\[P^* := \frac{1}{2}\lim_{n\rightarrow\infty}{\mathbb E}_{W \sim \GOE(n)}[\frac{1}{n^{3/2}}\OPT(W)] \approx 0.7632\]
is referred to as the Parisi constant. This already strongly motivates the problem of studying \cref{eq:general_opt} when $W \sim \GOE(n)$. Interestingly, this problem is motivated for another fantastic reason.
In statistical physics, when $W \sim \GOE(n)$, our objective, up to scaling, is the Hamiltonian of the famous Sherrington-Kirkpatrick model. Here, $x$ can be thought of as encoding
spin values in a spin-glass model.
$-W_{i,j}$ models the interaction between spin $x_i$ and $x_j$
(with $-W_{i,j} \ge 0$ being ferromagnetic and $-W_{i,j} < 0$ being
anti-ferromagnetic). Then, the optimal value corresponds to the
minimum-energy, or ground state of the system, up to sign.
The works \cite{P79, parisi1980sequence, crisanti2002analysis} predicted, using non-rigorous means, that $P^* \approx 0.7632$. This was eventually formalized
in the works \cite{Tal06, Panchenko2014, guerra2003broken}.
In this work, we will focus on this average case optimization problem when $W \sim \GOE(n)$. The first natural question is whether there exists
a polynomial-time algorithm that
given $W \sim \GOE(n)$ computes an $x$ achieving close to $\OPT(W)$.
In a recent breakthrough work, Montanari~\cite{Montanari19} showed that, for any $\varepsilon > 0$, there exists a polynomial time algorithm that outputs $x$ given $W$ such that with high probability it achieves a value of $(2P^* - \varepsilon)n^{3/2}$ (assuming a widely believed conjecture).
Now we move onto certification: Is there an
efficient algorithm to certify an upper bound on $\OPT(W)$ for any
input $W$?
A simple algorithm will be the spectral algorithm where we just output the largest eigenvalue of $W$, up to scaling, for an upper bound.
Note that $\GOE(n)$ is a particular kind
of Wigner matrix ensemble, thereby satisfying the semicircle law, which
in this case establishes that the largest eigenvalue of $W$ is
$(2+\operatorname{o}_n(1)) \cdot \sqrt{n}$ with probability
$1-\operatorname{o}_n(1)$. Thus, a trivial spectral bound establishes
$\OPT(W) \le (2+\operatorname{o}_n(1)) \cdot n^{3/2}$ with probability
$1-\operatorname{o}_n(1)$.
Now, we can ask if it's possible to beat this spectral algorithm for certification. In
particular, we can ask how well SoS does as a certification
algorithm. The natural upper bound of $(2+\operatorname{o}_n(1)) \cdot
n^{3/2}$ obtained via the spectral norm of $W$ is also the value of
the degree-$2$ SoS relaxation~\cite{MS16}. Two independent recent
works of Mohanty--Raghavendra--Xu~\cite{mohanty2020lifting} and
Kunisky--Bandeira~\cite{KuniskyBandeira19} show that degree-4 SoS does
not perform much better, and a heuristic argument from~\cite{bkw19} suggests that even degree-$(n/\log n)$ SoS cannot certify anything stronger than the trivial spectral bound. Thus we ask,
\begin{center}
\emph{Can higher-degree SoS certify better upper bounds for the Sherrington--Kirkpatrick problem, \\
hopefully closer to the true bound $2 \cdot P^* \cdot n^{3/2}$?}
\end{center}
In this work, we answer the question above negatively by showing that even at degree as large as
$n^\delta$, SoS cannot improve upon the basic spectral
algorithm.
\begin{restatable}{theorem}{SKbounds}\label{theo:sk-bounds}
There exists a constant $\delta > 0$ such that, w.h.p. for $W \sim \GOE(n)$, there is a degree-$n^\delta$ SoS solution
for the Sherrington--Kirkpatrick problem with value at least $(2-\operatorname{o}_n(1)) \cdot n^{3/2}$.
\end{restatable}
An independent and concurrent work by Kunisky~\cite{kunisky2020} also showed a special case of the above theorem for degree-$6$ SoS, using different techniques.
We will present the proof of this theorem in \cref{chap: sk}.
The above theorem and it's proof originally appeared in \cite{sklowerbounds}, from which the material here is adapted from.
We now present the high level ideas behind the proof of this theorem.
\subsection{Our approach}
In order to prove~\cref{theo:sk-bounds}, we first introduce a new
average-case problem we call Planted Affine Planes (PAP) for which we directly prove a SoS lower bound. We then use
the PAP lower bound to prove a lower bound on the
Sherrington--Kirkpatrick problem. The PAP problem can be informally
described as follows (see~\cref{def:prob:pap} for the formal definition).
\begin{definition}[Informal statement of PAP]
Given $m$ random vectors $d_1,\ldots,d_m$ in $\mathbb{R}^n$, can we
prove that there is no vector $v \in {\mathbb R}^n$ such that for all
$u \in [m]$, $\langle v, d_u\rangle^2 = 1$? In other words, can we
prove that $m$ random vectors are not all contained in two parallel
hyperplanes at equal distance from the origin?
\end{definition}
This problem, when we restrict $v$ to a Boolean vector in $\set{\pm \frac{1}{\sqrt{n}}}^n$,
can be encoded as the feasibility of the polynomial system
\begin{align*}
\exists v \in {\mathbb R}^n~\text{s.t.} \qquad & \forall i \in [n], \; v_i^2 = \frac{1}{n},\\
& \forall u \in [m], \; \ip{v}{d_u}^2 = 1.
\end{align*}
Hence it is a ripe candidate for SoS. However, we show that SoS fails
to refute a random instance with high probability over the input. The Boolean restriction on $v$ actually
makes the lower bound result stronger since SoS cannot refute even a
smaller subset of vectors in ${\mathbb R}^n$. In this work, we will consider two
different random distributions, namely when $d_1, \ldots, d_m$ are
independent samples from the multivariate normal distribution and when
they are independent samples from the uniform distribution on the
boolean hypercube.
\begin{theorem}\label{theo:sos-bounds}
For both the Gaussian and Boolean settings, there exists a constant $c > 0$ such that for all $\varepsilon > 0$ and $\delta \le c\varepsilon$, for $m \leq n^{3/2 - \varepsilon}$, w.h.p. there is a feasible degree-$n^\delta$ SoS solution for Planted Affine Planes.
\end{theorem}
It turns out that the Planted Affine Plane problem introduced above is
closely related to the following ``Boolean vector in a random
subspace'' problem, which we call the Planted Boolean Vector problem,
introduced by~\cite{mohanty2020lifting} in the context of studying the performance
of SoS on computing the Sherrington--Kirkpatrick Hamiltonian.
The Planted Boolean Vector problem is to certify that a random subspace of ${\mathbb R}^n$ is far from containing a boolean vector.
Specifically, we want to certify an upper bound for
\[
\OPT(V) := \frac{1}{n}\max_{b \in \{\pm 1\}^n} b^\intercal \Pi_V b,
\]
where $V$ is a uniformly random $p$-dimensional subspace\footnote{$V$
can be specified by a basis, which consists of $p$ i.i.d. samples
from ${\mathcal N}(0, I)$.} of ${\mathbb R}^n$, and $\Pi_V$ is the projector onto
$V$. In brief, the relationship to the Planted Affine Plane problem is
that the PAP vector $v$ represents the coefficients on a linear
combination for the vector $b$ in the span of a basis of
$V$.
An argument of~\cite{mohanty2020lifting} shows that, when $p \ll n$, w.h.p.,
$\OPT(V) \approx \frac{2}{\pi}$, whereas they also show that
w.h.p. assuming $p \geq n^{0.99}$, there is a degree-4 SoS solution
with value $1-\operatorname{o}_n(1)$. They ask whether or not there is a
polynomial time algorithm that can certify a tighter bound; we rule
out SoS-based algorithms for a larger regime both in terms of SoS
degree and the dimension $p$ of the random subspace.
\begin{restatable}{theorem}{booleanSubspace}\label{theo:boolean-subspace}
There exists a constant $c > 0$ such that, for all $\varepsilon > 0$ and $\delta \le c\varepsilon$, for $p \geq n^{2/3 + \varepsilon}$, w.h.p. over $V$ there is a
degree-$n^\delta$ SoS solution for Planted Boolean Vector of value $1$.
\end{restatable}
The bulk of our technical contribution lies
in the SoS lower bound for the Planted Affine Planes
problem,~\cref{theo:sos-bounds}. We then show that Planted Affine
Planes in the Gaussian setting is equivalent to the Planted Boolean
Vector problem. The reduction from Sherrington-Kirkpatrick to the
Planted Boolean Vector problem is due to
Mohanty--Raghavendra--Xu~\cite{mohanty2020lifting}.
As a starting point to the PAP lower bound, we employ pseudocalibration to produce a good
candidate SoS solution $\tilde{\EE}$. The operator $\tilde{\EE}$ unfortunately does
not exactly satisfy the PAP constraints ``$\ip{v}{d_u}^2 = 1$'', it
only satisfies them up to a tiny error. In the original work, we use an interesting and
rather generic approach to round $\tilde{\EE}$ to a nearby pseudoexpectation
operator $\tilde{\EE}'$ which does exactly satisfy the constraints, We have omitted this in this thesis for the sake of brevity, but it can be found in the original work \cite{sklowerbounds}.
For degree $D$, the candidate SoS solution can be viewed as a
(pseudo) moment matrix ${\mathcal M}$ with rows and columns indexed by
subsets $I,J\subset [n]$ with size bounded by $D/2$ and with entries
\[{\mathcal M}[I,J] := \tilde{\EE}[v^{I} v^{J}].\]
The matrix ${\mathcal M}$ is a random function of the inputs $d_1, \dots, d_m$, and the most challenging part of the
analysis consists of showing that ${\mathcal M}$ is positive
semi-definite (PSD) with high probability.
Similarly to~\cite{BHKKMP16}, we decompose
${\mathcal M}$ as a linear combination of graph matrices, i.e., ${\mathcal M} = \sum_{\alpha} \lambda_{\alpha} \cdot M_{\alpha}$, where $M_{\alpha}$
is the graph matrix associated with shape $\alpha$. In brief, each
graph matrix aggregates all terms with shape $\alpha$ in the Fourier expansions of the entries of ${\mathcal M}$ -- the shape $\alpha$ is informally a graph with labeled edges
with size bounded by ${\mathrm{poly}}(D)$. A graph
matrix decomposition of ${\mathcal M}$ is particularly handy in the PSD
analysis since the operator norm of individual graph matrices $M_{\alpha}$ is (with high probability)
determined by simple combinatorial properties of the graph
$\alpha$. One technical difference from~\cite{BHKKMP16} is that our
graph matrices have two types of vertices $\square{}$ and $\circle{}$; these graph matrices fall into the general framework developed by Ahn et al. in~\cite{ahn2016graph}.
To show that the matrix ${\mathcal M}$ is PSD, we need to study the graph matrices that appear with nonzero coefficients in the decomposition. The matrix ${\mathcal M}$ can be split into blocks and each diagonal block contains in the decomposition a (scaled) identity matrix. From the graph matrix perspective, this means that certain ``trivial'' shapes appear in the decomposition, with appropriate coefficients. If we could bound the norms of all other graph matrices that appear against these trivial shapes and show that, together, they have negligible norm compared to the sum of these scaled identity blocks, then we would be in good shape.
Unfortunately, this approach will not work. The kernel of the matrix ${\mathcal M}$ is nontrivial, as a consequence of satisfying the PAP constraints ``$\ip{v}{d_u}^2 = 1$", and hence there is no hope of showing that the contribution of all nontrivial shapes in the decomposition of ${\mathcal M}$ has small norm. Indeed, certain shapes $\alpha$ appearing in the
decomposition of ${\mathcal M}$ are such that $\norm{\lambda_{\alpha} \cdot M_{\alpha}}$ is large. As it turns out, all such shapes have a simple graphical substructure, and so we call these shapes \textit{spiders}.
To get around the null space issue, we restrict ourselves to $\nullspace({\mathcal M})^\perp$, which is the complement of the nullspace of ${\mathcal M}$.
We show that the substructure present in a spider implies that the spider is close to the zero matrix in $\nullspace({\mathcal M})^\perp$. Because of this, we can almost freely
add and subtract $M_\alpha$ for spiders $\alpha$ while preserving the action of ${\mathcal M}$ on $\nullspace({\mathcal M})^\perp$. Our strategy is to ``kill'' the spiders
by subtracting off $\lambda_\alpha \cdot M_\alpha$ for each spider $\alpha$. However, because $M_{\alpha}$ is only approximately in $\nullspace({\mathcal M})^\perp$, this
strategy could potentially introduce new graph matrix terms, and in particular it could introduce new spiders. To handle this,
we recursively kill them while carefully analyzing how the coefficients of all the graph matrices change. After all spiders
are killed, the resulting moment matrix becomes
$$
\sum_{0 \le k \le D/2} \frac{1}{n^{k}} \cdot I_k + \sum_{\gamma \colon \textup{non-spiders}} \lambda_{\gamma}' \cdot M_{\gamma},
$$
for some new coefficients $\lambda_{\gamma}'$. Here, $I_k$ is the
matrix which has an identity in the $k$th block and the remaining
entries $0$. Using a novel charging argument, we finally show that the
latter term is negligible compared to the former term, thus
establishing ${\mathcal M} \succeq 0$.
\subsection{Related work}
Degree-$4$ SoS lower bounds on the
Sherrington-Kirkpatrick Hamiltonian problem were proved independently
by Mohanty--Raghavendra--Xu~\cite{mohanty2020lifting} and
Kunisky--Bandeira~\cite{KuniskyBandeira19}. The concurrent and independent work by Kunisky~\cite{kunisky2020} obtained degree $6$ SoS lower bounds. In this work, we prove an
improved degree-$n^{\delta}$ SoS lower bound for some constant $\delta
> 0$. Our result is obtained by reducing the Sherrington-Kirkpatrick
problem to the ``Boolean Vector in a Random Subspace'' problem which
is equivalent to our new Planted Affine Planes problem on the normal
distribution. The reduction from Sherrington-Kirkpatrick problem to
the ``Boolean Vector in a Random Subspace'' is due to
Mohanty--Raghavendra--Xu~\cite{mohanty2020lifting}. The results of
Mohanty--Raghavendra--Xu~\cite{mohanty2020lifting} and
Kunisky--Bandeira~\cite{KuniskyBandeira19} build on a degree-$2$ SoS
lower bounds of Montanari and Sen~\cite{MS16}.
Degree-$4$ SoS lower bounds on the ``Boolean Vector in a Random
Subspace'' problem for $p~\ge~n^{0.99}$ were proved by
Mohanty--Raghavendra--Xu in~\cite{mohanty2020lifting} where this problem was
introduced. We improve the dependence on $p$ to $p \ge n^{2/3
+ \varepsilon}$ for any $\varepsilon > 0$ and obtain a stronger
degree-$n^{c\varepsilon}$ SoS lower bound for some absolute constant $c > 0$.
Interestingly, the recent work \cite{zadik2021latticebased} exhibited a polynomial-time algorithm for the search variant of Planted Affine Planes for $m \ge n + 1$, achieving statistical optimality. In particular, they beat prior known polynomial time algorithms, including SoS based ones, all of which required $m \gg n^2$ \cite{mao2021optimal}. This new algorithm is a lattice-based method that uses the specific algebraic structure present in this problem. Because of this, their algorithm is not robust to small perturbations, that is, they require the points to lie exactly on the planes. On the other hand, the spectral algorithms such as the work of \cite{mao2021optimal} are robust to noise. Because of this necessity of lack of noise, the lattice based algorithm is of a similar flavor to how Gaussian elimination can beat SoS lower bounds in the absense of noise. Specifically, this means that this lattice based algorithm does not refute our certification lower bound, or the low degree likelihood ratio hypothesis described in \cref{subsec: ldlr}.
\section{Sparse PCA}
Principal components analysis (PCA) \cite{joliffe1992principal} is a popular data processing and dimension reduction routine that is widely used. It has numerous applications in Machine Learning, Statistics, Engineering, Biology, etc. Given a dataset, PCA projects the data to a lower dimensional space spanned by the principal components. The intuition is that PCA sheds lower order information such as noise but importantly preserves much of the intrinsic information present in the data that are needed for downstream tasks.
However, despite great optimality properties, PCA has its drawbacks. Firstly, because the principal components are linear combinations of all the original variables, it's notoriously hard to interpret them \cite{mahoney2009cur}. Secondly, it's well known that PCA does not yield good estimators in high dimensional settings \cite{baik2005phase, paul2007asymptotics, johnstone_lu2009}.
To address these issues, a variant of PCA known as Sparse PCA is often used. Sparse PCA searches for principal components of the data with the added constraint of sparsity.
Concretely, consider given data $v_1, v_2, \ldots, v_m \in {\mathbb R}^d$. In Sparse PCA, we want to find the top principal component of the data under the extra constraint that it has sparsity at most $k$. That is, we want to find a vector $v \in {\mathbb R}^d$ that maximizes $\sum_{i = 1}^m \ip{v}{v_i}^2$ such that $\norm{v}_0 \le k$.
Sparse PCA has enjoyed applications in a diverse range of fields ranging from medicine, computational biology, economics, image and signal processing, finance and of course, machine learning and statistics (e.g. \cite{wang2012online, naikal2011informative, majumdar2009image, tan2014classification, chun2009expression, allen2011sparse}).
Moreover, sparse PCA comes with the important benefit that the components are easier to interpret. A notable example of this is to recover topics from documents \cite{d2004direct, papailiopoulos2013sparse}. Moreover, interpretability has important benefits for algorithmic fairness in machine learning.
A large volume of research has been devoted to study Sparse PCA and its variants.
Algorithms have been proposed and studied by several works, e.g. \cite{amini_wainwright2008, ma2013sparse, krauthgamer2015, deshpande2016, wang2016statistical, berthet2013complexity, ma_wigderson_15, diakonikolas2017statistical, hop17, brennan2019optimal, ding2019subexponential, chowdhury2020approximation, d2020sparse}.
For example, simple variants of PCA such as thresholding on top of standard PCA \cite{johnstone_lu2009, chowdhury2020approximation} work well in certain parameter settings. This leads to the natural question whether more sophisticated algorithms can do better either for these settings or other parameter settings.
On the other hand, there have been works from the inapproximability perspective as well (e.g. \cite{berthet2013complexity, hop17, brennan2019optimal, krauthgamer2015, ding2019subexponential, wang2016statistical}, we will give a more detailed overview after stating our main result).
In particular, a lot of these inapproximability results have relied on various other conjectures, due to the difficulty of proving unconditional lower bounds.
Despite these prior works, exactly understanding the limits of efficient algorithms to this problem is still an active research area. This is natural considering the importance of sparse PCA and how fundamental it is to a multitude of applications.
Therefore, we naturally ask (also raised by and posed as an open problem in the works \cite{ma_wigderson_15, hop17, hop18})
\begin{it}
Can Sum of Squares algorithms beat known algorithms for Sparse PCA?
\end{it}
In this work, we show that SoS algorithms cannot beat known spectral algorithms, even if we allow sub-exponential time! Therefore, this suggests that currently used algorithms such as thresholding or other spectral algorithms are in a sense optimal for this problem.
To prove our results, we will consider random instances of Sparse PCA and show that they are naturally hard for SoS. In particular, we focus on the Wishart random model of Sparse PCA. This model is a more natural modeling assumption compared to other random models that have been studied before, such as the Wigner random model.
Note importantly that our model assumptions only strengthen our results because we are proving impossibility results. In other words, if SoS algorithms do not work for this restricted version of sparse PCA, then it will not work for more general models, e.g. with general covariance or multiple spikes.
We now describe the model.
The Wishart model of Sparse PCA, also known as the Spiked Covariance model, was originally proposed by \cite{johnstone_lu2009}. In this model, we observe $m$ vectors $v_1, \ldots, v_m \in {\mathbb R}^d$ from the distribution $\mathcal{N}(0, I_d + \lambda uu^T)$ where $u$ is a $k$-sparse unit vector, that is, $\norm{u}_0 \le k$ and we would like to recover the principal component $u$. Here, the sparsity of a vector is the number of nonzero entries and $\lambda$ is known as the signal-to-noise ratio.
As the signal to noise ratio $\lambda$ gets lower, it becomes harder and maybe even impossible to recover $u$ since the signature left by $u$ in the data becomes fainter. However, it's possible that this may be mitigated if the number of samples $m$ grows. Therefore, there is a tradeoff between $m, n$ and $k$ at play here. Algorithms proposed earlier have been able to recover $u$ at various regimes.
For example, if the number of samples is really large, namely $m \gg \max(\frac{d}{\lambda}, \frac{d}{\lambda^2})$, then standard PCA will work. If this is not the case, we may still be able to recover $u$ by assuming that the sparsity is not too large compared to the number of samples, namely $m \gg \frac{k^2}{\lambda^2}$. To do this, we use a variant of standard PCA known as diagonal thresholding. Similar results have been obtained for various regimes, while some regimes have resisted attack to algorithms.
Our results here complete the picture by showing that in the regimes that have so far resisted attack by efficient algorithms, the powerful Sum of Squares algorithms also cannot recover the principal component. We now state our theorem informally, postponing the formal statement to \cref{cor: spca_main}.
\begin{theorem}\label{thm: spca_main_informal}
For the Wishart model of Sparse PCA, sub-exponential time SoS algorithms fail to recover the principal component when the number of samples $m \ll \min(\frac{d}{\lambda^2}, \frac{k^2}{\lambda^2})$ .
\end{theorem}
In particular, this theorem resolves an open problem posed by \cite{ma_wigderson_15} and \cite{hop17, hop18}.
In almost all other regimes, algorithms to recover the principal component $u$ exist. We give a summary of such algorithms shortly, captured succinctly in \cref{fig: spca_thresholds}.
We say almost all other regimes because there is one interesting regime, namely $\frac{d}{\lambda^2} \le m \le \frac{\min(d, k)}{\lambda}$ marked by light green in \cref{fig: spca_thresholds}, where we can show that information theoretically, we cannot recover $u$ but it's possible to do hypothesis testing of Sparse PCA. That is, in this regime, we can distinguish purely random unspiked samples from the spiked samples. However, we will not be able to recover the principal component even if we use an exponential time brute force algorithm.
\begin{figure}[!h]
\centering
\begin{subfigure}{\textwidth}
\centering
\includegraphics[scale=.4, trim={0 0 0 0},clip]{SNRaboveOne_og}
\caption{SNR $\lambda \ge 1$}
\label{fig: spca_thresholds1}
\end{subfigure}%
\begin{subfigure}{\textwidth}
\centering
\includegraphics[scale=.4, trim={0 0 0 0},clip]{SNRbelowOne_og}
\caption{SNR $\lambda < 1$}
\label{fig: spca_thresholds2}
\end{subfigure}
\caption{Computational barrier diagram for Sparse PCA}
\label{fig: spca_thresholds}
\end{figure}
Now, we state our results a bit more formally.
First, we will assume that the entries of $u$ are in $\{-\frac{1}{\sqrt{k}}, 0, \frac{1}{\sqrt{k}}\}$ chosen such that the sparsity is $k$ (and hence, the norm is $1$). Note importantly that this assumption is only strengthening our result: If SoS cannot solve this problem even for this specific $u$, it cannot do any better for the general problem with arbitrary $u$.
Let the vectors from the given dataset be $v_1, \ldots, v_m$. Let them form the rows of a matrix $S \in {\mathbb R}^{m \times d}$.
Let $\Sigma = \frac{1}{m} \sum_{i = 1}^m v_iv_i^T$ be the sample covariance matrix. Then the standard PCA objective is to maximize $x^T\Sigma x$ and recover $x = \sqrt{k}u$. Therefore, the sparse PCA problem can be rephrased as
\[\text{maximize } m\cdot x^T\Sigma x = \sum_{i = 1}^m \ip{x}{v_i}^2\text{ such that }x_i^3 = x_i\text{ for all $i \le d$ and } \sum_{i = 1}^d x_i^2 = k\]
where the program variables are $x_1, \ldots, x_d$.
The constraint $x_i^3 = x_i$ enforces that the entries of $x$ are in $\{-1, 0, 1\}$ and along with these constraints, the last condition $\sum_{i = 1}^d x_i^2 = k$ enforces $k$-sparsity (but we remark that, due to technical reasons, we will only satisfy this condition up to $o(1)$ error in our lower bounds). Then, the vector $u$ can be recovered by setting $u = \frac{1}{\sqrt{k}} x$.
Now, we will consider the series of convex relaxations for Sparse PCA obtained by SoS algorithms. In particular, we will consider SoS degree of $d^{\varepsilon}$ for a small constant $\varepsilon > 0$. Note that this corresponds to SoS algorithms of subexponential running time in the input size $d^{O(1)}$.
Our main result states that for choices of $m$ below a certain threshold, when the vectors $v_1, \ldots, v_m$ are sampled from the unspiked standard Gaussian $\mathcal{N}(0, I_d)$, then sub-exponential time SoS algorithms will have optimal value close to $m + m\lambda$. This is also the optimal value in the case when the vectors $v_1, \ldots, v_m$ are indeed sampled from the spiked Gaussian $\mathcal{N}(0, I_d + \lambda uu^T)$ and $x = \sqrt{k}u$.
Therefore, SoS is unable to distinguish $\mathcal{N}(0, I_d)$ from $\mathcal{N}(0, I_d + \lambda uu^T)$ and hence cannot solve sparse PCA. Formally,
\begin{theorem}\label{cor: spca_main}
For all sufficiently small constants $\varepsilon > 0$, suppose $m \le \frac{d^{1 - \varepsilon}}{\lambda^2}, m \le \frac{k^{2 - \varepsilon}}{\lambda^2}$, and for some $A > 0$, $d^{A} \le k \le d^{1 - A\varepsilon}, \frac{\sqrt{\lambda}}{\sqrt{k}} \le d^{-A\varepsilon}$, then for an absolute constant $C > 0$, with high probability over a random $m \times d$ input matrix $S$ with Gaussian entries, the sub-exponential time SoS algorithm of degree $d^{C\varepsilon}$ for sparse PCA has optimal value at least $m + m\lambda - o(1)$.
\end{theorem}
In other words, sub-exponential time SoS cannot certify that for a random dataset with Gaussian entries, there is no unit vector $u$ with $k$ nonzero entries and $m \cdot u^T\Sigma u \approx m + m\lambda$.
A few remarks are in order.
\begin{enumerate}
\item Note here that $m + m\lambda$ is approximately the value of the SoS program when the input vectors $v_1, \ldots, v_m$ are indeed sampled from the spiked model $\mathcal{N}(0, I_d + \lambda uu^T)$ and $x = \sqrt{k}u$. Therefore, sub-exponential time SoS is unable to distinguish a completely random distribution from the spiked distribution and hence is unable to solve sparse PCA.
\item The constant $A$ can be thought of as $\approx 0$ and it appears for technical reasons, to ensure that we have sufficient decay in our bounds. In particular, most values of $k, \lambda$ fall under the conditions of the theorem.
\item For technical reasons, the constraint $\sum_{i = 1}^k x_i^2 = k$ is satisfied up to $o(1)$ error in our lower bounds. We leave to future work the problem of satisfying this constraint exactly.
\end{enumerate}
Informally, our main result says that when $m \ll \min\left(\frac{d}{\lambda^2}, \frac{k^2}{\lambda^2}\right)$, then subexponential time SoS cannot recover the principal component $u$. This is the content of \cref{thm: spca_main_informal}.
To show our results, we use the strategy from \cref{sec: strategy_for_sos_lower_bounds}.
For the Wishart model of Sparse PCA, we use the following distributions.
\begin{restatable}{itemize}{SPCAdistributions}
\item Random distribution $\nu$: $v_1, \ldots, v_m$ are sampled from $\mathcal{N}(0, I_d)$ and we take $S$ to be the $m \times d$ matrix with rows $v_1, \ldots, v_m$.
\item Planted distribution $\mu$: Sample $u$ from $\{-\frac{1}{\sqrt{k}}, 0, \frac{1}{\sqrt{k}}\}^d$ where the values are taken with probabilites $\frac{k}{2d}, 1 - \frac{k}{d}, \frac{k}{2d}$ respectively. Then sample $v_1, \ldots, v_m$ as follows. For each $i \in [m]$, with probability $\Delta$, sample $v_i$ from $\mathcal{N}(0, I_d + \lambda uu^T)$ and with probability $1 - \Delta$, sample $v_i$ from $\mathcal{N}(0, I_d)$. Finally, take $S$ to be the $m \times d$ matrix with rows $v_1, \ldots, v_m$.
\end{restatable}
In \cref{sec: spca_qual}, we compute the SoS solution obtained by pseudo-calibration. We prove the following theorem.
\begin{restatable}{theorem}{SPCAmain}\label{thm: spca_main}
There exists a constant $C > 0$ such that for all sufficiently small constants $\varepsilon > 0$, if $m \le \frac{d^{1 - \varepsilon}}{\lambda^2}, m \le \frac{k^{2 - \varepsilon}}{\lambda^2}$, and there exists a constant $A$ such that $0 < A < \frac{1}{4}$, $d^{4A} \le k \le d^{1 - A\varepsilon}$, and $\frac{\sqrt{\lambda}}{\sqrt{k}} \le d^{-A\varepsilon}$, then with high probability, the SoS solution given by pseudo-calibration for degree $d^{C\varepsilon}$ Sum of Squares is feasible.
\end{restatable}
Since we use an average case distribution, this SoS lower bound is a lower bound for certification. An overview of our proof is in \cref{sec: global_approach}. From this theorem, \cref{cor: spca_main} follows as a corollary.
\paragraph{Prior work on algorithms}
Due to its widespread importance, a tremendous amount of work has been devoted to obtaining algorithms for sparse PCA, both theoretically and practically, \cite{amini_wainwright2008, ma2013sparse, krauthgamer2015, deshpande2016, wang2016statistical, berthet2013complexity, ma_wigderson_15, diakonikolas2017statistical, hop17, brennan2019optimal, ding2019subexponential, chowdhury2020approximation, d2020sparse} to cite a few.
We now place our result in the context of known algorithms for Sparse PCA and explain why it offers tight tradeoffs between approximability and inapproximability.
Between this work and prior works, we completely understand the parameter regimes where sparse PCA is easy or conjectured to be hard up to polylogarithmic factors. In \cref{fig: spca_thresholds1} and \cref{fig: spca_thresholds2}, we assign the different parameter regimes into the following categories.
\begin{itemize}
\item Diagonal thresholding: In this regime, Diagonal thresholding \cite{johnstone_lu2009, amini_wainwright2008} recovers the sparse vector. Covariance thresholding \cite{krauthgamer2015, deshpande2016} and SoS algorithms \cite{sparse_pca_focs20} can also be used in this regime. The benefits of these alternate algorithms are that covariance thresholding has better dependence on logarithmic factors and SoS algorithms works in the presence of adversarial errors.
\item Vanilla PCA: Vanilla PCA (i.e. standard PCA) can recover the vector, i.e. we do not need to use the fact that the vector is sparse (see e.g. \cite{berthet2013, sparse_pca_focs20}).
\item Spectral: An efficient spectral algorithm recovers the sparse vector (see e.g. \cite{sparse_pca_focs20}).
\item Can test but not recover: A simple spectral algorithm can solve the hypothesis testing version of Sparse PCA but it is information theoretically impossible to recover the sparse vector \cite[Appendix E]{sparse_pca_focs20}.
\item Hard: A regime where it is conjectured to be hard for algorithms to recover the sparse principal component. We discuss this in more detail below.
\end{itemize}
In \cref{fig: spca_thresholds1} and \cref{fig: spca_thresholds2}, the regimes corresponding to Diagonal thresholding, Vanilla PCA and Spectral are dark green, while the regimes corresponding to Spectral* and Hard are light green and red respectively.
\paragraph{Prior work on hardness}
Prior works have explored statistical query lower bounds \cite{brennan2020statistical}, basic SDP lower bounds \cite{krauthgamer2015}, reductions from conjectured hard problems \cite{berthet2013, berthet2013complexity, brennan2019optimal, gao2017sparse, wang2016statistical}, lower bounds via the low-degree conjecture \cite{ding2019subexponential, sparse_pca_focs20}, lower bounds via statistical physics \cite{ding2019subexponential, arous2020free}, etc.
We note that similar threshold behaviors as us have been predicted by \cite{sparse_pca_focs20}, but importantly, they assume a conjecture known as the low-degree likelihood conjecture. Similarly, many of these other lower bounds rely on various conjectures. To put this in context, the low-degree likelihood conjecture is a stronger assumption than P $\neq$ NP. In contrast, our results are unconditional and do not assume any conjectures.
Compared to these other lower bounds, there have only been two prior works on lower bounds against SoS algorithms \cite{krauthgamer2015, berthet2013, ma_wigderson_15} which are only for degree $2$ and degree $4$ SoS. In particular, degree $2$ SoS lower bounds have been studied in \cite{krauthgamer2015, berthet2013} although they don't state it this way. Moreover, \cite{ma_wigderson_15} obtained degree $4$ SoS lower bounds but they were very lossy, i.e. they hold for a strict subset of the \textit{Hard} regime $m \ll \frac{k^2}{\lambda^2}$ and $m \ll \frac{d}{\lambda^2}$. Moreover, the ideas used in these prior works do not generalize for higher degrees.
The lack of other SoS lower bounds can be attributed to the difficulty in proving such lower bounds. In this paper, we vastly strengthen these known results and show almost-tight lower bounds for SoS algorithms of degree $d^{\varepsilon}$ which correspond to sub-exponential running time $d^{d^{O(\varepsilon)}}$.
We note that SoS algorithms get stronger as the degree increases, therefore our results immediately imply these prior results and even in the special case of degree $4$ SoS, we improve the known lossy bounds. In summary, \cref{cor: spca_main} subsumes all these earlier known results and is a vast improvement over prior known SoS lower bounds which provides compelling evidence for the hardness of Sparse PCA in this parameter range.
The work \cite{hop17} also states SoS lower bounds for Sparse PCA but it differs from our work in three important aspects. First, they handle the related but qualitatively different Wigner model of Sparse PCA. Their techniques fail for the Wishart model of Sparse PCA, which is more natural in practice. We overcome this shortcoming and work with the Wishart model. We emphasize that their techniques are insufficient to handle this generality and overcoming this is far from being a mere technicality. On the other hand, our techniques can easily recover their results.
Second, while they sketch a high level proof overview for their lower bound, they don't give a proof. On the other hand, our proofs are fully explicit.
Finally, they assume the input distribution has entries in $\{\pm 1\}$, that is, they work with the $\pm 1$ variant of PCA.
On the other hand, we work with the more realistic setting where the distribution is $\mathcal{N}(0, 1)$.
Again, our techniques can easily recover their results as well.
\section{Tensor PCA}
We use our techniques to also obtain strong results for the related Tensor Principal components analysis (Tensor PCA) problem.
Tensor PCA, originally introduced by \cite{richard2014statistical}, is a generalization of PCA to higher order tensors. Formally, given an order $k$ tensor of the form $\lambda u^{\otimes k} + B$ where $u \in {\mathbb R}^n$ is a unit vector and $B \in {\mathbb R}^{[n]^k}$ has independent Gaussian entries, we would like to recover the principal component $u$. Here, $\lambda$ is known as the signal-to-noise ratio.
Tensor PCA is a remarkably useful statistical and computational technique to exploit higher order moments of the data.
It was originally envisaged to be applied in latent variable modeling and indeed, it has found multiple applications in this context (e.g. \cite{anandkumar2014tensor, kivva2021learning, anandkumar2014analyzing}). Here, a tensor containing statistics of the input data is computed and then it's decomposed in order to recover the latent variables.
Because of the technique's versatility, it has gathered a lot of attention in machine learning with applications in topic modeling, video processing, collaborative filtering, community detection, etc. (see e.g. \cite{hsu2012spectral, anandkumar2014guaranteed, richard2014statistical, anandkumar2014tensor, anandkumar2014analyzing, duchenne2011tensor, li2010tensor} and references therein.)
For Tensor PCA, similar to sparse PCA, there has been wide interest in the community to study algorithms (e.g. \cite{arous2020algorithmic, tensorpca16, HopSS15, hopkins2016fast, richard2014statistical, zheng2015interpolating, wein2019kikuchi, kim2017community, anandkumar2017homotopy}) as well as approximability and hardness (e.g. \cite{montanari2015limitation, kunisky19notes, brennan2020reducibility, hop17}, a more detailed overview is presented after stating our main results).
It's worth noting that many of these hardness results are conditional, that is, they rely on various conjectures, sometimes stronger than P $\neq$ NP.
Moreover, there has been widespread interest from the statistics community as well, e.g. \cite{jagannath2020statistical, perry2016statistical, lesieur2017statistical, chen2019phase, chen2018phase}, due to fascinating connections to random matrix theory and statistical physics.
In this work, we study the performance of sub-exponential time Sum of Squares algorithms for Tensor PCA.
Our main result is stated informally below and formally in \cref{cor: tpca_main}.
\begin{theorem}\label{thm: tpca_main_informal}
For Tensor PCA, sub-exponential time SoS algorithms fail to recover the principal component when the signal to noise ratio $\lambda \ll n^{\frac{k}{4}}$.
\end{theorem}
In particular, this resolves an open question posed by the works \cite{HopSS15, tensorpca16, hop17, hop18}.
Let's make this theorem formal. Recall that we are given an order $k$ tensor $A$ of the form $A = \lambda u^{\otimes k} + B$ where $u \in {\mathbb R}^n$ is a unit vector and $B \in {\mathbb R}^{[n]^k}$ has independent Gaussian entries and we would like to recover the principal component $u$.
Tensor PCA can be rephrased by the program
\[\text{maximize }\ip{A}{x^{\otimes k}} = \ip{A}{\underbrace{x\otimes\ldots\otimes x}_{\text{$k$ times}}}\text{ such that } \sum_{i = 1}^n x_i^2 = 1\]
where the program variables are $x_1, \ldots, x_n$.
The principal component $u$ will then just be the returned solution $x$.
Just like in Sparse PCA, we remark that for technical reasons, we will satisfy the unit vector condition only up to $o(1)$ error in our lower bounds and satisfying the condition exactly is left for future work.
We will again consider sub-exponential time SoS algorithms, in particular degree $n^{\varepsilon}$ SoS, for this problem. This is sub-exponential time because the input size is $n^{O(1)}$.
We then show that if the signal to noise ratio $\lambda$ is below a certain threshold, then sub-exponential time SoS for the unspiked input $A \sim \mathcal{N}(0, I_{[n]^k})$ will have optimal value close to $\lambda$, which is also the optimal value in the spiked case when $A = \lambda u^{\otimes k} + B, B\sim \mathcal{N}(0, I_{[n]^k})$ and $x = u$. In other words, SoS cannot distinguish the unspiked and spiked distributions and hence cannot recover the principal component $u$.
\begin{theorem}\label{cor: tpca_main}
Let $k \ge 2$ be an integer. For all sufficiently small $\varepsilon > 0$, if $\lambda \le n^{\frac{k}{4} - \varepsilon}$, for an absolute constant $C > 0$, with high probability over a random tensor $A \sim\mathcal{N}(0, I_{[n]^k})$, the sub-exponential time SoS algorithm of degree $n^{C\varepsilon}$ for Tensor PCA has optimal value at least $\lambda - o(1)$.
\end{theorem}
Therefore, sub-exponential time SoS cannot certify that for a random tensor $A$ sampled from $\mathcal{N}(0, I_{[n]^k})$, there is no unit vector $u$ such that $\ip{A}{\underbrace{u \otimes\ldots\otimes u}_{\text{$k$ times}}} \approx \lambda$.
We again remark that when the tensor $A$ is actually sampled from the spiked model $A = \lambda u^{\otimes k} + B$, the optimal value of the SoS program is approximately $\lambda$ when $x = u$. Therefore, this shows that sub-exponential time SoS algorithms cannot solve Tensor PCA.
Informally, the theorem says that when the signal to noise ratio $\lambda \ll n^{\frac{k}{4}}$, SoS algorithms cannot solve Tensor PCA, as stated in \cref{thm: tpca_main_informal}.
To show our results for Tensor PCA, we apply the strategy from \cref{sec: strategy_for_sos_lower_bounds} where we use the following distributions. Let $k \ge 2$ be an integer.
\begin{restatable}{itemize}{TPCAdistributions}
\item Random distribution $\nu$: Sample $A$ from $\mathcal{N}(0, I_{[n]^k})$.
\item Planted distribution $\mu$: Let $\lambda,\Delta > 0$. Sample $u$ from $\{-\frac{1}{\sqrt{\Delta n}}, 0, \frac{1}{\sqrt{\Delta n}}\}^n$ where the values are taken with probabilites $\frac{\Delta}{2}, 1 - \Delta, \frac{\Delta}{2}$ respectively. Then sample $B$ from $\mathcal{N}(0, I_{[n]^k})$. Set $A = B + \lambda \tens{u}{k}$.
\end{restatable}
In \cref{sec: tpca_qual}, we apply pseudo-calibration and we prove the following theorem.
\begin{restatable}{theorem}{TPCAmain}\label{thm: tpca_main}
Let $k \ge 2$ be an integer. There exist constants $C,C_{\Delta} > 0$ such that for all sufficiently small constants $\varepsilon > 0$, if $\lambda \le n^{\frac{k}{4} - \varepsilon}$ and $\Delta = n^{-C_{\Delta}\varepsilon}$ then with high probability, the SoS solution given by pseudo-calibration for degree $n^{C\varepsilon}$ Sum of Squares is feasible.
\end{restatable}
This theorem can also be naturally interpreted as an SoS lower bound for the certification problem of Tensor PCA. A sketch of our proof follows in \cref{sec: global_approach}. From this theorem, \cref{cor: tpca_main} follows as a corollary.
\paragraph{Prior work}
Algorithms for Tensor PCA have been studied in the works \cite{arous2020algorithmic, tensorpca16, HopSS15, hopkins2016fast, richard2014statistical, zheng2015interpolating, wein2019kikuchi, kim2017community, anandkumar2017homotopy}. It was shown in \cite{tensorpca16} that the degree $q$ SoS algorithm certifies an upper bound of $\frac{2^{O(k)} (n \cdot \text{polylog}(n))^{k/4}}{q^{k/4 - 1/2}}$ for the Tensor PCA problem. When $q = n^{\varepsilon}$ this gives an upper bound of $n^{\frac{k}{4} - O(\varepsilon)}$. Therefore, our result is tight, giving insight into the computational threshold for Tensor PCA.
Lower bounds for Tensor PCA have been studied in various forms including statistical query lower bounds \cite{brennan2020statistical, dudeja2021statistical}, reductions from conjectured hard problems \cite{zhang2018tensor, brennan2020reducibility}, lower bounds from the low-degree conjecture \cite{hop17, hop18, kunisky19notes}, evidence based on the landscape behavior \cite{arous2019landscape, montanari2015limitation}, etc. Compared to a lot of these works which rely on various conjectures, we remark that our lower bounds are unconditional and do not rely on any conjectures.
In \cite{hop17}, similar to Sparse PCA, they state a similar theorem for a different variant of Tensor PCA. However, they do not give a proof whereas we give explicit proofs.
In particular, they state their result without proof for the $\pm{1}$ variant of Tensor PCA whereas we work with the more realistic setting where the distribution is $\mathcal{N}(0, 1)$. We remark that their techniques do not recover our results but on the other hand, our techniques can recover theirs.
\section{Planted Slightly Denser Subgraph}
In the planted dense subgraph problem, we are given a random graph $G$ where a dense subgraph of size $k$ has been planted and we are asked to find this planted dense subgraph.
This is a natural generalization of the $k$-clique problem \cite{karp1972reducibility} and has been subject to a long line of work over the years (e.g. \cite{feige1997densest, feige2001dense, khot2006ruling, bhaskara2010detecting, bhaskara2012polynomial, braverman2017eth, manurangsi2017almost}).
In this work, we consider the following certification variant of planted dense subgraph.
\begin{quote}
\em{Given a random graph $G$ sampled from the Erd\H{o}s\xspace-R\'enyi\xspace model $G(n, \frac{1}{2})$, certify an upper bound on the edge density of the densest subgraph on $k$ vertices.}
\end{quote}
We show a high degree SoS lower bound for this problem using the strategy from \cref{sec: strategy_for_sos_lower_bounds}. In particular, we use the following distributions.
\begin{restatable}{itemize}{PLDSdistributions}
\item Random distribution $\nu$: Sample $G$ from $G(n, \frac{1}{2})$
\item Planted distribution $\mu$: Let $k$ be an integer and let $p > \frac{1}{2}$. Sample a graph $G'$ from $G(n, \frac{1}{2})$. Choose a random subset $S$ of the vertices, where each vertex is picked independently with probability $\frac{k}{n}$. For all pairs $i, j$ of vertices in $S$, rerandomize the edge $(i, j)$ where the probability of $(i, j)$ being in the graph is now $p$. Set $G$ to be the resulting graph.
\end{restatable}
In \cref{sec: plds_qual}, we compute the candidate SoS solution obtained via pseudo-calibration. Our main theorem is as follows, with a proof sketch following in \cref{sec: global_approach}.
\begin{restatable}{theorem}{PLDSmain}\label{thm: plds_main}
Let $C_p > 0$. There exists a constant $C > 0$ such that for all sufficiently small constants $\varepsilon > 0$, if $k \le n^{\frac{1}{2} - \varepsilon}$ and $p = \frac{1}{2} + \frac{n^{-C_p\varepsilon}}{2}$, then with high probability, the candidate solution given by pseudo-calibraton for degree $n^{C\varepsilon}$ Sum of Squares is feasible.
\end{restatable}
\paragraph{Related work}
For many different parameter regimes of the random and planted distributions (an example being planting $G_{k, q}$ in $G_{n, p}$ for constants $p < q$), and when $k = o(\sqrt{n})$, the hardness of the easier distinguishing version of planted dense subgraph problem has been posed as formal conjecture (often referred to as the PDS conjecture) before in the literature (see e.g., \cite{hajek2015computational, chen2014statistical, brennan2018reducibility, brennan2019universality}). This has also led to many reductions to other problems \cite{brennan2019optimal}, although it's not clear if these reductions can be made in the SoS framework without loss in the parameter dependence.
In our case, we consider the slightly planted denser subgraph version where for $k \le n^{\frac{1}{2} - \varepsilon}$, we plant a subgraph of density $\frac{1}{2} + \frac{1}{n^{O(\varepsilon)}}$, i.e. $p = \frac{1}{2}, q = \frac{1}{2} + \frac{1}{n^{O(\varepsilon)}}$. This has been widely believed to require sub-exponential time. Our work provides strong evidence towards this by exhibiting unconditional lower bounds against the powerful SoS hierarchy, even if we consider $n^{O(\varepsilon)}$ levels, which corresponds to $n^{n^{O(\varepsilon)}}$ running time! We expect this to lead to this problem being used as a natural starting point for reductions to show sub-exponential time hardness for various problems.
Within the SoS literature, \cite{BHKKMP16} show that for $k \le n^{\frac{1}{2} - \varepsilon}$ for a constant $\varepsilon > 0$, the degree $o(\log n)$ Sum of Squares cannot distinguish between a fully random graph sampled from $G(n, \frac{1}{2})$ from a random graph which has a planted $k$-clique. This implies that degree $o(\log n)$ SoS cannot certify an edge density better than $1$ for the densest $k$-subgraph if $k \le n^{\frac{1}{2} - \varepsilon}$.
In \cref{thm: plds_main}, we show that for $k \le n^{\frac{1}{2} - \varepsilon}$ for a constant $\varepsilon > 0$, degree $n^{\Omega(\varepsilon)}$ SoS cannot certify an edge density better than $\frac{1}{2} + \frac{1}{n^{O(\varepsilon)}}$. The degree of SoS in our setting, $n^{\Omega(\varepsilon)}$ is vastly higher than the earlier known result which uses degree $o(\log n)$. To the best of our knowledge, this is the first result that proves such a high degree lower bound for this problem.
We remark that when we take $k = n^{\frac{1}{2} - \varepsilon}$, the true edge density of the densest $k$-subgraph is $\frac{1}{2} + \frac{\sqrt{\log(n/k)}}{\sqrt{k}} + \operatorname{o}(\frac{1}{\sqrt{k}}) \approx \frac{1}{2} + \frac{1}{n^{1/4 - \varepsilon/2}}$ as was shown in \cite[Corollary 2]{gamarnik2019landscape} whereas, by \cref{thm: plds_main}, the SoS optimum is as large as $\frac{1}{2} + \frac{1}{n^{\varepsilon}}$. This highlights a significant difference in the optimum value.
\section{Our approach}\label{sec: global_approach}
In this section, we briefly describe how to prove \cref{thm: spca_main}, \cref{thm: tpca_main} and \cref{thm: plds_main}. We naturally start with pseudocalibration and all constraints except positivity are easily shown to hold by construction. To show positivity and hence the lower bound, we will essentially apply a general meta-theorem called the machinery. The machinery enables us to show SoS lower bounds for certain kinds of ``noisy'' problems.
In this work, we state and use the machinery, whose proof can be found in the original work where it appeared \cite{potechin2020machinery}. To show PSDness, the machinery constructs certain \emph{coefficient matrices} from the moment matrix $\Lambda$ and gives conditions on these coefficient matrices which are sufficient to guarantee that $\Lambda$ is PSD with high probability. Some of the ideas involved in the machinery are a generalization of the techniques used to prove the SoS lower bound for planted clique \cite{BHKKMP16}. In this section, we give an informal sketch of the machinery. We also motivate some of the conditions that arise.
\paragraph{Shapes and graph matrices}
We start by describing shapes and graph matrices, which were originally introduced by \cite{BHKKMP16, medarametla2016bounds} and later generalized in \cite{ahn2016graph}. They will be covenient for our analysis.
Shapes $\alpha$ are graphs that contain extra information about the vertices. Corresponding to each shape $\alpha$, there is a matrix-valued function $M_{\alpha}$ (i.e. a matrix whose entries depend on the input) that we call a graph matrix. Graph matrices are analogous to a Fourier basis, but for matrix-valued functions that exhibit a certain kind of symmetry. In our setting, $\Lambda$ will be such a matrix-valued function, so we can decompose $\Lambda$ as a linear combination of graph matrices $\Lambda = \sum_{\text{shapes } \alpha}{\lambda_{\alpha}M_{\alpha}}$.
Shapes and graph matrices have several properties which make them very useful to work with. First, $\norm{M_{\alpha}}$ can be bounded with high probability in terms of simple combinatorial properties of the shape $\alpha$. Second, if two shapes $\alpha$ and $\beta$ match up in a certain way, we can combine them to form a larger shape $\alpha \circ \beta$. We call this operation shape composition. Third, each shape $\alpha$ has a canonical decomposition into three shapes, the left, middle and right parts of $\alpha$, which we call $\sigma$, $\tau$, and ${\sigma'}^T$. For this canonical decomposition, we have that $\alpha = \sigma \circ \tau \circ {\sigma'}^T$ and $M_{\alpha} \approx M_{\sigma}M_{\tau}M_{{\sigma'}^T}$. This decomposition is crucial for our analysis.
\paragraph{A general framework for SoS lower bounds}
We now sketch the strategy of the machinery.
\begin{enumerate}
\item Decompose the moment matrix $\Lambda$ as a linear combination $\Lambda = \sum_{\text{shapes } \alpha}{\lambda_{\alpha}M_{\alpha}}$ of graph matrices $M_{\alpha}$
\item For each shape $\alpha$, decompose $\alpha$ into a left part $\sigma$, a middle part $\tau$, and a right part ${\sigma'}^T$.
\item Based on the coefficients $\lambda_{\alpha}$ and the decompositions of the shapes $\alpha$ into left, middle, and right parts, construct coefficient matrices $H_{Id_U}$ and $H_{\tau}$.
\item Based on the coefficient matrices $H_{Id_U}$ and $H_{\tau}$, obtain an approximate PSD decomposition of $\Lambda$.
\item Show that the error terms (which we call intersection terms) can be bounded by the approximate PSD decomposition of $\Lambda$.
\end{enumerate}
This is broadly similar to the work of \cite{BHKKMP16} who showed SoS lower bounds for the planted clique problem.
The machinery shows that this analysis will succeed by distilling it as three conditions on the coefficient matrices.
The rough blueprint to use the machinery to prove SoS lower bounds is as follows.
\begin{enumerate}
\item Construct a candidate moment matrix $\Lambda$.
\item Decompose the moment matrix $\Lambda$ as a linear combination $\Lambda = \sum_{\text{shapes } \alpha}{\lambda_{\alpha}M_{\alpha}}$ of graph matrices $M_{\alpha}$ (akin to Fourier decomposition) and find the corresponding coefficient matrices.
\item Verify the required conditions on the coefficient matrices.
\end{enumerate}
\subsubsection{A sketch of the intuition behind the conditions}\label{ideadescriptionsubsection}
We now motivate and sketch the conditions we present in the machinery.
\paragraph{Giving an approximate PSD factorization}
As discussed above, we decompose the moment matrix $\Lambda$ as a linear combination $\Lambda = \sum_{\text{shapes } \alpha}{\lambda_{\alpha}M_{\alpha}}$ of graph matrices $M_{\alpha}$. We then decompose each $\alpha$ into left, middle, and right parts $\sigma$, $\tau$, and ${\sigma'}^T$. We now have that
\[
\Lambda = \sum_{\alpha = \sigma \circ \tau \circ {\sigma'}^T}{\lambda_{\sigma \circ \tau \circ {\sigma'}^T}M_{\sigma \circ \tau \circ {\sigma'}^T}}
\]
We first consider the terms $\sum_{\sigma, \sigma'} \lambda_{\sigma \circ \sigma'^T}M_{\sigma \circ \sigma'^T} \approx \sum_{\sigma, \sigma'} \lambda_{\sigma \circ \sigma'^T}M_{\sigma} M_{\sigma'^T}$ where $\tau$ corresponds to an identity matrix and can be ignored.
If there existed real numbers $v_{\sigma}$ for all left shapes $\sigma$ such that $\lambda_{\sigma \circ \sigma'^T} = v_{\sigma}v_{\sigma'}$, then we would have
\[
\sum_{\sigma, \sigma'} \lambda_{\sigma \circ \sigma'^T}M_{\sigma} M_{\sigma'^T} = \sum_{\sigma, \sigma'} v_{\sigma}v_{\sigma'}M_{\sigma} M_{\sigma'^T} = (\sum_{\sigma} v_{\sigma}M_{\sigma})(\sum_{\sigma} v_{\sigma}M_{\sigma})^T \succeq 0
\]
which shows that the contribution from these terms is positive semidefinite. In fact, this turns out to be the case for the planted clique analysis. However, this may not hold in general. To handle this, we note that the existence of $v_{\sigma}$ can be relaxed as follows: Let $H$ be the matrix with rows and columns indexed by left shapes $\sigma$ such that $H(\sigma, \sigma') = \lambda_{\sigma \circ \sigma'^T}$. Up to scaling, $H$ will be one of our coefficient matrices. If $H$ is positive semidefinite then the contribution from these terms will also be positive semidefinite. In fact, this will be
the PSD mass condition of the main theorem.
\paragraph{Handling terms with a non-trivial middle part}
Unfortunately, we also have terms $\lambda_{\sigma \circ \tau \circ \sigma'^T}M_{\sigma \circ \tau \circ \sigma'^T}$ where $\tau$ is non-trivial. Their strategy is to charge these terms to other terms.
For the sake of simplicity, we will describe how to handle one term. A starting point is the following inequality. For a left shape $\sigma$, a middle shape $\tau$, a right shape $\sigma'^T$, and real numbers $a, b$,
\[(a M_{\sigma} - bM_{\sigma'}M_{\tau^T})(a M_{\sigma} - bM_{\sigma'}M_{\tau^T})^T \succeq 0\]
which rearranges to
\begin{align*}
ab(M_{\sigma}M_{\tau}M_{\sigma'^T} + (M_{\sigma}M_{\tau}M_{\sigma'^T})^T) &\preceq a^2M_{\sigma}M_{\sigma^T} + b^2M_{\sigma'}M_{\tau^T}M_{\tau}M_{\sigma'^T}\\
&\preceq a^2M_{\sigma}M_{\sigma^T} + b^2\norm{M_{\tau}}^2M_{\sigma'}M_{\sigma'^T}
\end{align*}
If $\lambda_{\sigma \circ \tau \circ \sigma'^T}^2\norm{M_{\tau}}^2 \le \lambda_{\sigma \circ \sigma^T}\lambda_{\sigma' \circ \sigma'^T}$, then we can choose $a, b$ such that $a^2 \le \lambda_{\sigma \circ \sigma^T}$, $ b^2 \norm{M_{\tau}}^2 \le \lambda_{\sigma' \circ \sigma'^T}$ and $ab = \lambda_{\sigma \circ \tau \circ \sigma'^T}$. This will approximately imply
\[\lambda_{\sigma \circ \tau \circ \sigma'^T}(M_{\sigma \circ \tau \circ \sigma'^T} + M_{\sigma \circ \tau \circ \sigma'^T}^T) \preceq \lambda_{\sigma \circ \sigma^T}M_{\sigma \circ \sigma^T} + \lambda_{\sigma' \circ \sigma'^T}M_{\sigma' \circ \sigma'^T}\]
which will give us a way to charge terms with a nontrivial middle part against terms with a trivial middle part.
While we could try to apply this inequality term by term, it is not strong enough to give us the main machinery result. Instead, they generalize this inequality to work with the entire set of shapes $\sigma, \sigma'$ for a fixed $\tau$. This will lead us to
the middle shape bounds condition.
\paragraph{Handing intersection terms}
There's one important technicality in the above calculations. Whenever we decompose $\alpha$ into left, middle, and right parts $\sigma$, $\tau$, and ${\sigma'}^T$, $M_{\sigma}M_{\tau}M_{{\sigma'}^T}$ is only approximately equal to $M_{\alpha} = M_{\sigma \circ \tau \circ {\sigma'}^T}$. All the other error terms have to be carefully handled in the analysis. We call these terms intersection terms.
We exploit the fact that these intersection terms themselves are graph matrices. Therefore, we recursively decompose them into $\sigma_2 \circ \tau_2 \circ \sigma_2'^T$ and apply the previous ideas. To do this methodically, the machinery employs several ideas such as the notion of intersection patterns and the generalized intersection tradeoff lemma. Properly handling the intersection terms is one of the most technically intensive parts of their work.
This analysis leads us to the intersection term bounds condition.
\paragraph{Applying the machinery}
To apply the machinery to our problems of interest, we verify the spectral conditions that our coefficients should satisfy and then we can use the main theorem. The Planted slightly denser subgraph application is straightforward and will serve as a good warmup to understand the machinery. In the applications to Tensor PCA and Sparse PCA, the shapes corresponding to the graph matrices with nonzero coefficients have nice structural properties that will be crucial for our analysis. We exploit this structure and use novel charging arguments to verify the conditions of the machinery. We do this in this work.
\section{Related work on Sum of Squares Lower Bounds for Certification Problems}
\cite{KothariMOW17} proved that for random constraint satisfaction problems (CSPs) where the predicate has a balanced pairwise independent distribution of solutions, with high probability, degree $\Omega(n)$ SoS is required to certify that these CSPs do not have a solution. While they don't state it in this manner, the pseudo-expectation values used by \cite{KothariMOW17} can also be derived using pseudo-calibration \cite{rajendran2018combinatorial, brown2020extended}. The analysis for showing that the moment matrix is PSD is very different. It is an interesting question whether or not it is possible to unify these analyses.
\cite{mohanty2020lifting} showed that it's possible to lift degree $2$ SoS solutions to degree $4$ SoS solutions under suitable conditions, and used it to obtain degree $4$ SoS lower bounds for average case $d$-regular Max-Cut and the Sherrington Kirkpatrick problem. Their construction is inspired by pseudo-calibration and their analysis also goes via graph matrices.
\cite{kunisky2020} recently proposed a technique to lift degree $2$ SoS lower bounds to higher levels and applied it to construct degree $6$ lower bounds for the Sherrington-Kirkpatrick problem. Interestingly, their construction does not go via pseudo-calibration.
\section{Organization of the proofs}
We prove the Sherrington-Kirkpatrick lower bound, \cref{theo:sk-bounds}, in \cref{chap: sk}. The proofs for planted slightly denser subgraph, tensor PCA and sparse PCA, namely \cref{thm: plds_main}, \cref{thm: tpca_main} and \cref{thm: spca_main}, are split between \cref{chap: qual} and \cref{chap: quant}. The latter proofs are split into qualitative and quantitative versions. Qualitative theorem statements capture the essence of the inequalities we prove, and serve to illustrate the main forms of the bounds we desire, without getting lost in the details. Quantitative theorems on the other hand build on their qualitative counterparts by stating the precise bounds that are needed. In \cref{chap: qual}, we introduce the machinery and and in \cref{sec: plds_qual}, \cref{sec: tpca_qual} and \cref{sec: spca_qual}, we qualitatively verify the conditions of the machinery for planted slightly denser subgraph, tensor PCA, and sparse PCA respectively. While these sections only verify the qualitative conditions, the results in these sections are precise and will be reused in \cref{chap: quant}, where we fully verify the conditions of the machinery in \cref{sec: plds_quant}, \cref{sec: tpca_quant} and \cref{sec: spca_quant}.
\section{The machinery}\label{quantitativetheoremstatementsection}
In this section, we describe the machinery we apply to show SoS lower bounds.
\input{machinery_statement}
\section{Qualitative bounds for Planted slightly denser subgraph}\label{sec: plds_qual}
\input{machinery/planted_ds_qual}
\section{Qualitative bounds for Tensor PCA}\label{sec: tpca_qual}
\input{machinery/tensor_pca_qual}
\section{Qualitative bounds for Sparse PCA}\label{sec: spca_qual}
\input{machinery/sparse_pca_qual}
\section{Planted slightly denser subgraph: Full verification}\label{sec: plds_quant}
\input{machinery/planted_ds_quant}
\section{Tensor PCA: Full verification}\label{sec: tpca_quant}
\input{machinery/tensor_pca_quant}
\section{Sparse PCA: Full verification}\label{sec: spca_quant}
\input{machinery/sparse_pca_quant}
\subsection{PAP planted distribution}\label{subsec:pap:dist}
We formally define the random and the planted distributions for the
Planted Affine Planes problem in the Gaussian and boolean
settings. These two (families of) distributions are required by the
pseudocalibration machinery in order to define a candidate
pseudoexpectation operator $\tilde{\EE}$. For the Gaussian setting, we have
the following distributions.
\begin{definition}[Gaussian PAP distributions]\label{def:prob:pap:gauss:dist}
The Gaussian PAP distributions are as follows.
\begin{enumerate}
\item (Random distribution) $m$ i.i.d. vectors $d_u \sim \gauss{0}{I}$.
\item (Planted distribution) A vector $v$ is sampled uniformly from $\left\{\pm \frac{1}{\sqrt{n}}\right\}^n$, as well as signs $b_u \in_{\text{R}} \{\pm 1\}$,
and $m$ vectors $d_u$ are drawn from $\mathcal{N}(0, I)$ conditioned on $\ip{d_u}{v} = b_u$.
\end{enumerate}
\end{definition}
For the boolean setting, we have the following distributions.
\begin{definition}[Boolean PAP distributions]\label{def:prob:pap:bool:dist}
The boolean PAP distributions are as follows
\begin{enumerate}
\item (Random distribution) $m$ i.i.d. vectors $d_u \in_{\text{R}} \{-1,+1\}^n$.
\item (Planted distribution) A vector $v$ is sampled uniformly from $\left\{\pm \frac{1}{\sqrt{n}}\right\}^n$, as well as signs $b_u \in_{\text{R}} \{\pm 1\}$, and $m$ vectors $d_u$ are drawn from $\left\{\pm 1\right\}^n$ conditioned on $\ip{d_u}{v} = b_u$.
\end{enumerate}
\end{definition}
\subsection{Pseudocalibration technique}\label{subsec:pseudo_calib_technique}
We will use the shorthand ${\mathbb E}_{\text{ra}}$ and ${\mathbb E}_{\text{pl}}$ for
the expectation under the random and planted distributions.
Pseudocalibration gives a method for constructing a candidate
pseudoexpectation operator $\tilde{\EE}$.
The idea behind pseudocalibration is that
${\mathbb E}_{\text{ra}} \tilde{\EE} f(v)$ should match with ${\mathbb E}_{\text{pl}} f(v)$ for
every low-degree test of the data $t = t(d) = t(d_1, \dots, d_m)$,
\[{\mathbb E}_{\text{ra}} t(d) \tilde{\EE} f(v) = {\mathbb E}_{\text{pl}} t(d) f(v) .\]
When pseudocalibrating, one can freely choose the ``outer'' basis in
which to express the polynomial $f(v)$, as well as the ``inner'' basis
of low-degree tests which should agree with the planted
distribution. Though we attempted to use alternate bases to simplify
the analysis, ultimately we opted for the standard choice of bases: a
Fourier basis for the inner basis in each setting (Hermite functions
for the Gaussian setting, parity functions for the boolean setting),
and the coordinate basis $v^I$ for the outer basis.
When the inner basis is orthonormal under the random distribution (as a Fourier basis is), the pseudocalibration condition
gives a formula for the coefficients of $\tilde{\EE} f(v)$ in the orthonormal basis (though it only gives the coefficients of the low-degree functions $t(d)$). Concretely, letting the inner basis be indexed by $\alpha \in {\mathcal F}$, as a function of $d$ the pseudocalibration condition enforces
\[ \tilde{\EE} f(v) = \displaystyle\sum_{\substack{\alpha \in {\mathcal F}: \\ \abs{\alpha} \leq n^\tau}} \left( {\mathbb E}_{\text{pl}} t_\alpha(d) f(v) \right)t_\alpha (d).\]
Here we use ``$\abs{\alpha} \leq n^\tau$'' to describe the set of low-degree tests. The pseudocalibration condition does not prescribe any coefficients for functions $t_\alpha(d)$ with $\abs{\alpha} > n^\tau$ and an economical choice is to set these coefficients to zero.
When pseudocalibrating, our pseudoexpectation operator is guaranteed to be linear, as the expression above is linear in $f$. It is guaranteed to satisfy all constraints of the form ``$f(v) =0$''. It will approximately satisfy constraints of the form ``$f(v, d) = 0$'', though only up to truncation error.
\begin{fact}[Proof in \cite{sklowerbounds}]\label{lem:pE-constraints}
If $p(v)$ is a polynomial which is uniformly zero on the planted
distribution, then $\tilde{\EE}[p]$ is the zero function. If $p(v,d)$ is a polynomial which is uniformly zero on the planted distribution, then the only nonzero Fourier coefficients of $\tilde{\EE}[p]$ are those with size between $n^\tau \pm \deg_d(p)$.
\end{fact}
Truncation
introduces a tiny error in the constraints, which we are able to handle in \cite{sklowerbounds}, omitted in this work for brevity.
For the pseudocalibration we truncate to only Fourier coefficients of
size at most $n^\tau$. The relationship between the parameters is $\delta \le c\tau \le c'\varepsilon$ where $c' < c < 1$ are absolute constants. We will assume that they are sufficiently small for all our proofs to go through.
Pseudocalibration also by default does not enforce the condition $\tilde{\EE}[1] = 1$. However, this is easily fixed by dividing the operator by $\tilde{\EE}[1]$. As will be pointed out in~\cref{rmk:pe-one}, w.h.p. in the unnormalized pseudocalibration, $\tilde{\EE}[1] = 1 + \operatorname{o}_n(1)$ and so the error introduced does not impact the statement of any lemmas.
\subsection{Gaussian setting pseudocalibration}\label{subsec:calib:gauss}
We start by computing the pseudocalibration for the Gaussian setting. Here the natural choice of Fourier basis is the Hermite polynomials. Let $\alpha \in ({\mathbb{N}}^n)^m$ denote a Hermite polynomial index. Define $\alpha! := \prod_{u,i} \alpha_{u,i}!$ and $\abs{\alpha} := \sum_{u, i} \alpha_{u,i}$ and $\abs{\alpha_u} := \sum_i \alpha_{u,i}$. We let $h_\alpha(d_1, \dots, d_m)$ denote an unnormalized Hermite polynomial, so that $h_{\alpha}/\sqrt{\alpha!}$ forms an orthonormal basis for polynomials in the entries of the vectors $d_1, \dots, d_m$, under the inner product $\ip{p}{q} = {\mathbb E}_{d_1, \dots, d_m \sim {\mathcal N}(0, I)} [p \cdot q]$.
We can view $\alpha$ as an $m\times n$ matrix of natural numbers, and with this view we also define $\alpha^\intercal \in ({\mathbb{N}}^m)^n$.
\begin{lemma}\label{lem:gaussian-pseudocal}
For any $I \subseteq [n]$, the pseudocalibration value is
\[\tilde{\EE} v^I = \displaystyle\sum_{\substack{\alpha: \abs{\alpha} \leq n^\tau,\\ \abs{\alpha_u} \text{ even}, \\ \abs{(\alpha^\intercal)_i} \equiv I_i \; (\mod 2)}} \left(\prod_{u = 1}^m h_{\abs{\alpha_u}}(1) \right)\cdot\frac{1}{n^{\abs{I}/2 + \abs{\alpha}/2}} \cdot\frac{h_{\alpha}(d_1, \dots, d_m)}{\alpha!}. \]
\end{lemma}
In words, the nonzero Fourier coefficients are those which have even row sums, and whose column sums match the parity of $I$.
\begin{proof}
The truncated pseudocalibrated value is defined to be
\[\tilde{\EE} v^I = \displaystyle\sum_{\alpha : \abs{\alpha} \leq n^\tau} \frac{h_{\alpha}(d_1, \dots, d_m)}{\alpha!} \cdot {\mathbb E}_{\text{pl}}[h_{\alpha}(d_1, \dots, d_m) \cdot v^I] \]
So we set about to compute the planted moments. For this computation, the following lemma is crucial. Here, we give a short proof of this lemma using generating functions. For a different combinatorial proof, see \cite{sklowerbounds}.
\begin{lemma}\label{lem:fixed-moments}
Let $\alpha \in {\mathbb{N}}^n$. When $v$ is fixed and $b$ is fixed (not necessarily $\pm1$) and $d \sim N(0, I)$ conditioned on $\ip{v}{d} = b\norm{v}$,
\[{\mathbb E}_{d}[h_{\alpha}(d)] = \frac{v^\alpha}{\norm{v}^{\abs{\alpha}}} \cdot h_{\abs{\alpha}}(b).\]
\end{lemma}
\begin{proof}
It suffices to prove the claim when $\norm{v} = 1$ since the left-hand side is independent of $\norm{v}$. Express $d = bv + (I - vv^\intercal)x$ where $x \sim N(0,I)$ is a standard normal variable. Now we want
\[{\mathbb E}_{x \sim N(0,I)} h_{\alpha}\left(bv + (I - vv^\intercal)x\right). \]
The Hermite polynomial generating function is
\[\displaystyle\sum_{\alpha \in {\mathbb{N}}^n} {\mathbb E}_{x \sim N(0,I)} h_{\alpha}\left(bv + (I - vv^\intercal)x\right)\frac{t^{\alpha}}{\alpha!} = {\mathbb E}_x\exp\left(\ip{bv + (I - vv^\intercal)x}{t} - \frac{\norm{t}_2^2}{2}\right)\]
\[= \int_{\mathbb{R}^n} \frac{1}{(2\pi)^{\frac{n}{2}}} \cdot \exp\left(\ip{bv + (I - vv^\intercal)x}{t} - \frac{\norm{t}_2^2}{2} - \frac{\norm{x}_2^2}{2}\right) \; dx. \]
Completing the square,
\begin{align*}= & \int_{\mathbb{R}^n} \frac{1}{(2\pi)^{\frac{n}{2}}} \cdot \exp\left(\ip{bv}{t} - \frac{\ip{v}{t}^2}{2} - \frac{1}{2} \cdot\norm{x- (t - \ip{v}{t}v)}_2^2\right) \; dx \\
=& \exp\left(\ip{bv}{t} - \frac{\ip{v}{t}^2}{2}\right) \\
=& \exp\left(b\ip{v}{t} - \frac{1}{2} \cdot \ip{v}{t}^2\right).
\end{align*}
How can we Taylor expand this in terms of $t$? The Taylor expansion of $\exp(by - \frac{y^2}{2})$ is $\sum_{i=0}^\infty h_i(b) \frac{y^i}{i!}$. That is, the $i$-th derivative in $y$ of $\exp(by - \frac{y^2}{2})$, evaluated at 0, is $h_i(b)$. Using the chain rule with $y=\ip{v}{t}$, the $\alpha$-derivative in $t$ of our expression, evaluated at 0, is $v^\alpha \cdot h_{\abs{\alpha}}(b)$. This is the expression we wanted when $\norm{v} = 1$, and along with the aforementioned remark about homogeneity in $\norm{v}$ this completes the proof.
\end{proof}
Now we can finish the calculation.
To compute ${\mathbb E}_{\text{pl}}[h_{\alpha}(d_1, \dots, d_m) \cdot v^I]$, marginalize $v$ and the $b_u$ and factor the conditionally independent $b_u$ and $d_u$.
\begin{align*}
{\mathbb E}_{\text{pl}}[h_{\alpha}(d_1, \dots, d_m) v^I] &= {\mathbb E}_{v, b_u} v^I \prod_{u=1}^m {\mathbb E}_{d}\left[h_{\alpha_u}(d_u) \mid v, b_u\right]\\
&= {\mathbb E}_{v, b_u} v^I \cdot \prod_{u=1}^m \frac{v^{\alpha_u}}{\norm{v}^{\abs{\alpha_u}}} \cdot h_{\abs{\alpha_u}}(b_u) && (\text{\cref{lem:fixed-moments})}\\
&= \left({\mathbb E}_{v} \frac{v^{I + \sum_{u=1}^m \alpha_u}}{\norm{v}^{\sum_{u=1}^m\abs{\alpha_u}}} \right) \cdot \left( \prod_{u=1}^m {\mathbb E}_{b_u}h_{\abs{\alpha_u}}(b_u)\right)
\end{align*}
The Hermite polynomial expectations will be zero in expectation over $b_u$ if the degree is odd, and otherwise $b_u$ is raised to an even power and can be replaced by 1. This requires that $\abs{\alpha_u}$ is even for all $u$. The norm $\norm{v}$ is constantly $1$ and can be dropped. The numerator will be $\frac{1}{n^{\abs{I}/2 + \abs{\alpha}/2}}$ if the parity of every $\abs{(\alpha^\intercal)_i}$ matches $I_i$, and 0 otherwise. This completes the pseudocalibration calculation.
\end{proof}
We can now write ${\mathcal M}$ in terms of graph matrices.
\begin{definition}\label{def:calL_valid_shapes}
Let $\mathcal{L}$ be the set of all proper shapes $\alpha$ with the following properties
\begin{itemize}
\item $U_{\alpha}$ and $V_{\alpha}$ only contain square vertices and $|U_{\alpha}|, |V_{\alpha}| \le n^{\delta}$
\item $W_\alpha$ has no degree $0$ vertices
\item $\deg(\square{i}) + U_\alpha(\square{i}) + V_\alpha(\square{i})$ is even for all $\square{i} \in V(\alpha)$
\item $\deg(\circle{u})$ is even and $\deg(\circle{u}) \ge 4$ for all $\circle{u} \in V(\alpha)$
\item $|E(\alpha)| \le n^\tau$
\end{itemize}
\end{definition}
\begin{remark}
Note that the shapes in $\mathcal{L}$ can have isolated vertices in $U_{\alpha} \cap V_{\alpha}$.
\end{remark}
\begin{remark}\label{rmk:circle_deg_bound}
${\mathcal L}$ captures all the shapes that have nonzero coefficient when we write ${\mathcal M}$ in terms of graph matrices. The constraint $\deg(\circle{u}) \ge 4$ arises because pseudocalibration gives us that $\deg(\circle{u})$ is even, $\circle{u}$ cannot be isolated, and $h_2(1) = 0$.
\end{remark}
For a shape $\alpha$, we define
\[\alpha! := \prod_{e \in E(\alpha)} l(e)!\] Note that this equals the factorial of the corresponding index of the Hermite polynomial for this shape.
\begin{definition}
For any shape $\alpha$, if $\alpha \in \mathcal{L}$, define \[\lambda_{\alpha} :=
\left( \prod_{\circle{u}\in V(\alpha)} h_{\deg(\circle{u})}(1)\right)
\cdot \frac{1}{ n^{(\abs{U_\alpha} + \abs{V_\alpha} + \abs{E(\alpha)})/2}}
\cdot \frac{1}{\alpha!} \]
Otherwise, define $\lambda_{\alpha} := 0$.
\end{definition}
\begin{corollary} Modulo the footnote\footnote{Technically, the graph matrices $M_\alpha$ have rows and columns indexed by all subsets of ${\mathcal C}_m \cup {\mathcal S}_n$. The submatrix with rows and columns from $\binom{{\mathcal S}_n}{\leq D/2}$ equals the moment matrix for $\tilde{\EE}$.}, ${\mathcal M} = \displaystyle\sum_{\text{shapes }\alpha} \lambda_{\alpha} M_{\alpha}$.
\end{corollary}
\subsection{Boolean setting pseudocalibration}\label{subsec:calib:bool}
We now present the pseudocalibration for the boolean setting. For the
sequel, we need notation for vectors on a slice of the boolean
cube.
\begin{definition}[Slice]
Let $v \in \set{\pm 1}^n$ and $\theta \in \mathbb{Z}$. The slice $\slice_{v}(\theta)$ is defined as
$$
\slice_{v}(\theta) \coloneqq \set{d \in \set{\pm 1}^n ~\vert~ \ip{v}{d} = \theta}.
$$
We use $\slice_{v}(\pm \theta)$ to denote $\slice_{v}(\theta) \cup \slice_{v}(-\theta)$ and
$\slice(\theta)$ to denote $\slice_{v}(\theta)$ when $v$ is the all-ones vector.
\end{definition}
\begin{remark}
With our notation for the slice, the planted distribution in the boolean setting can be equivalently described as
\begin{enumerate}
\item Sample $v \in \set{\frac{\pm 1}{\sqrt{n}}}^n$ uniformly, and then
\item Sample $d_1,\dots,d_m$ independently and uniformly from $\slice_{\sqrt{n} \cdot v}(\pm\sqrt{n})$.
\end{enumerate}
\end{remark}
The planted distribution doesn't actually exist for every $n$, but this is immaterial, as we can still define the pseudoexpectation via the same formula.
We will also need the expectation of monomials over the slice
$\slice(\sqrt{n})$ since they will appear in the description of the
pseudocalibrated Fourier coefficients.
\begin{definition}
$
e(k) \coloneqq {\mathbb E}_{x \in_{\text{R}} \mathcal{S}(\sqrt{n})}\left[x_1\cdots x_k\right].
$
\end{definition}
We now compute the Fourier coefficients of $\tilde{\EE} v^{\beta}$, where
$\beta \in \mathbb{F}_2^n$. The Fourier basis when $d_1, \dots, d_m \in_{\text{R}} \{\pm 1\}^n$ is the set of parity functions. Thus a character can be specified by $\alpha \in ({\mathbb F}_2^n)^m$, where $\alpha$
is composed of $m$ vectors
$\alpha_1,\dots,\alpha_m \in \mathbb{F}_2^n$. More precisely, the
character $\chi_{\alpha}$ associated to $\alpha$ is defined as
\[ \chi_\alpha(d_1,\dots,d_m) := \prod_{u=1}^m d_u^{\alpha_u}\]
We denote by $\abs{\alpha}$ the number of non-zero entries of $\alpha$
and define $\abs{\alpha_u}$ similarly. Thinking of $\alpha$ as an $m\times n$ matrix with entries in ${\mathbb F}_2$, we also define $\alpha^\intercal \in ({\mathbb F}_2^n)^m$.
\begin{lemma}\label{lem:boolean-pseudocalibration}
We have
$$
\tilde{\EE} v^{\beta} = \frac{1}{n^{\abs{\beta}/2}}\sum_{\substack{\alpha \colon \abs{\alpha} \le n^\tau, \\ \abs{\alpha_u} \text{ even},\\ \abs{\alpha^\intercal_i} \equiv \beta_i \;(\mod 2) }} \prod_{u=1}^m e(\abs{\alpha_u}) \cdot \chi_{\alpha_u}(d_u).
$$
\end{lemma}
The set of nonzero coefficients has a similar structure as in the Gaussian case: the rows of $\alpha$ must have an even number of entries, and the $i$-th column must have parity matching $\beta_i$.
\begin{proof}
Given $\alpha \in ({\mathbb F}_2^n)^m$ with $\abs{\alpha} \le n^\tau$, the pseudocalibration equation enforces by construction that
$$
{\mathbb E}_{d_1,\dots,d_m \in \set{\pm 1}^n} (\tilde{\EE} v^{\beta})(d_1,\dots,d_m) \cdot \chi_{\alpha}(d_1,\dots,d_m) = {\mathbb E}_{\text{pl}} v^{\beta} \cdot \chi_{\alpha}(d_1,\dots,d_m).
$$
Computing the RHS above
yields
{\footnotesize
\begin{align*}
{\mathbb E}_{v \in \set{\pm 1}^n} {\mathbb E}_{d_1,\dots,d_m \in_{\text{R}} \slice_v(\pm \sqrt{n})}\left[ v^{\beta} \prod_{u=1}^m \chi_{\alpha_u}(d_u) \right] &= {\mathbb E}_{v \in \set{\pm 1}^n} {\mathbb E}_{d_1,\dots,d_m \in_{\text{R}} \slice(\pm \sqrt{n})} \left[ v^{\beta} \prod_{u=1}^m \chi_{\alpha_u}(v) \chi_{\alpha_u}(d_u) \right] \\
& = {\mathbb E}_{v \in \set{\pm 1}^n} \chi_{\alpha_1+\cdots +\alpha_m + \beta}(v) {\mathbb E}_{d_1,\dots,d_m \in \slice(\pm \sqrt{n})}\left[ \prod_{i=1}^m \chi_{\alpha_i}(d_i) \right] \\
& = \mathbf 1_{\left[\alpha_1+\cdots +\alpha_m=\beta\right]} \cdot \prod_{i=1}^m {\mathbb E}_{d_i \in \slice(\pm \sqrt{n})} \left[ \chi_{\alpha_i}(d_i) \right]\\
& = \mathbf 1_{\left[\alpha_1+\cdots +\alpha_m=\beta\right]} \cdot \prod_{i=1}^m \mathbf 1_{\left[\abs{\alpha_i} \equiv 0 \pmod{2} \right]} \cdot \prod_{i=1}^m e(\abs{\alpha_i}).
\end{align*}
}%
Since we have a general expression for the Fourier coefficient of each character,
applying Fourier inversion concludes the proof.
\end{proof}
We can now express the moment matrix in terms of graph matrices.
\begin{definition}
Let ${\mathcal L}_{bool}$ be the set of shapes in ${\mathcal L}$ from~\cref{def:calL_valid_shapes} in which the edge labels are all 1.
\end{definition}
\begin{remark}
${\mathcal L}_{bool}$ captures all the shapes that have nonzero coefficient when we write ${\mathcal M}$ in terms of graph matrices. Similar to~\cref{rmk:circle_deg_bound}, since $e(2) = 0$ (see~\cref{claim:e2}), we have the same condition $deg(\circle{u}) \ge 4$ for shapes in ${\mathcal L}_{bool}$.
\end{remark}
\begin{definition}
For all shapes $\alpha$, if $\alpha \in {\mathcal L}_{bool}$ define
\[\lambda_\alpha := \frac{1}{n^{(\abs{U_\alpha} + \abs{V_\alpha})/2}}\prod_{\circle{u} \in V(\alpha)} e(\deg(\circle{u}))\]
Otherwise, let $\lambda_\alpha := 0$.
\end{definition}
\begin{corollary}${\mathcal M} = \displaystyle\sum_{\text{shapes }\alpha} \lambda_\alpha M_\alpha$
\end{corollary}
\subsubsection{Unifying the analysis}
It turns out that the analysis of the boolean setting mostly
follows from the analysis in the Gaussian setting.
Initially, the boolean pseudocalibration is essentially equal to
the Gaussian pseudocalibration in which we have removed all shapes
containing at least one edge with a label $k \ge 2$. The coefficients
on the graph matrices will actually be slightly different, but they
both admit an upper bound that is sufficient for our purposes
(see~\cref{prop:coefficient-bound} for the precise statement).
To unify the notation in our analysis, we conveniently set the edge
functions of the graphs in the boolean case to be
\[h_k(x) = \left\{\begin{array}{lr}
1 & \text{if }k = 0\\
x & \text{if }k = 1\\
0 & \text{if }k \geq 2
\end{array}
\right. \]
This choice of $h_k(x)$ preserves the fact that
$\{h_0(x)=1,h_1(x)=x\}$ is an orthogonal polynomial basis in
the boolean setting, while zeroing out graphs with larger labels.
During the course of the analysis, we may multiply two graph matrices
and produce graph matrices with improper parallel edges (so-called
``intersections terms"). For a fixed pair ${u,i}$ of vertices, parallel
edges between $u$ and $i$ with labels $l_1,\dots,l_s$ correspond to
the product of orthogonal polynomials $\prod_{j=1}^s
h_{l_j}(d_{u,i}) \eqqcolon q(d_{u,i})$. We will re-express this product
as a linear combination of polynomials in the orthogonal family, i.e.,\xspace
$q(d_{u,i}) = \sum_{i=0}^{\textup{deg}(q)} \lambda_i \cdot
h_i(d_{u,i})$ for some coefficients $\lambda_i \in \mathbb{R}$. For
the boolean case, the polynomial $q(d_{u,i})$ will be either
$h_0(d_{u,i})=1$ or $h_1(d_{u,i})=d_{u,i}$. However, for the Gaussian
setting there may be up to $\textup{deg}(q)$ non-zero, potentially larger coefficients
$\lambda_i$ for the corresponding Hermite polynomials $h_i$.
For the graphs that arise in this way, we will always bound their
contributions to ${\mathcal M}$ by applying the triangle inequality and norm
bounds. Since we show bounds using the larger coefficients $\lambda_i$ from the Gaussian case,
the same bounds apply when using the 0/1 coefficients in the boolean case.
We will consider separate cases at any point where the analysis differs between the two settings.
\subsection{Finishing the proof}\label{sec:finishing-psdness}
The final step of the proof is to argue that, after the spider killing
process is completed, the newly created non-spider terms in ${\mathcal M}^+$ also
have small norm. Towards this, we would like to prove a statement similar
to~\cref{cor:non_spider_killing}. In that proof, we used special
structural properties of the non-spiders in ${\mathcal L}$ to
prove that non-spiders in the pseudocalibration were negligible.
But now, the non-spiders in ${\mathcal M}^+$ need not have the properties of
${\mathcal L}$ -- for instance, there could be circle vertices of degree $2$ or
isolated vertices. To handle the potentially larger norms, we will use
that the coefficients of these new non-spider terms $\beta$ come with the
coefficients $\lambda_\alpha$ of the spider terms $\alpha$ in whose web
they lie. Since $\alpha$ has more vertices/edges than $\beta$, the power of $\frac{1}{n}$ in $\lambda_\alpha$ is larger than the ``expected pseudocalibration'' coefficient of $\eta^{\abs{U_\beta} + \abs{V_\beta}} \cdot \frac{1}{n^{\abs{E(\beta)}/2}}$.
We prove that these extra factors of $\frac{1}{n}$ are enough to overpower isolated
vertices or a smaller vertex separator using a careful
charging argument.
\begin{lemma}\label{lem:advanced-charging}
If $\beta$ is a nontrivial non-spider and $\beta \in W(\alpha)$ for some spider $\alpha \in {\mathcal L}$, then
\[\eta^{\abs{U_\alpha} + \abs{V_\alpha}} \cdot \frac{1}{n^{\abs{E(\alpha)}/2}}\cdot n^{\frac{w(V(\beta)) - w(S_{\min}) + w(W_{iso})}{2}} \leq \eta^{\abs{U_\beta} + \abs{V_\beta}}\cdot \frac{1}{n^{\Omega(\varepsilon\abs{E(\alpha)})}}\]
where $S_{min}$ and $W_{iso}$ are the minimum vertex separator of $\beta$ and the set of isolated vertices of $V(\beta) \setminus (U_\beta \cup V_\beta)$ respectively.
\end{lemma}
\begin{proof}
We start by giving the idea of the proof. Suppose we try to use the same
distribution scheme as in the proof of \cref{lem:charging}. It doesn't work
for two reasons. Firstly, the circle vertices in $\beta$ still have even
degree, which follows from \cref{rmk:parity}, but now, they could have
degrees $0$ or $2$. For the previous distribution scheme to go through, we
needed them to have degree at least $4$ which gave the necessary edge decay
to handle the norm bounds. Secondly, the square vertices can now have degree
$0$ hence getting no decay from the edges.
The first issue is relatively easy to handle. Since $\beta$ was obtained by
collapsing $\alpha$, the circle vertices of degrees $0$ or $2$ in $\beta$
must have had degree at least $4$ in $\alpha$ to begin with. Hence, we can
fix a particular sequence of collapses from $\alpha$ to $\beta$ and then
assume for the sake of analysis that the removed edges are still present. In
this case, the same charging argument as in \cref{lem:charging} would go
through. This is made formal by looking at the sequence of improper
collapses of this chain of collapses.
To handle the second issue, let's analyze more carefully how degree $0$
square vertices appear. Fix a sequence of collapses from $\alpha$ to $\beta$
and consider a specific step where $\gamma$ collapsed to $\gamma'$ and a
square vertex of degree $0$ was formed. Let the two square vertices that
collapsed in $\gamma$ be $\square{i}, \square{j}$ and let the square vertex
of degree $0$ that formed in $\gamma'$ be $\square{k}$. In light of
\cref{rmk:parity}, since $\square{k}$ has degree $0$, it must not be in
$(U_{\gamma'} \cup V_{\gamma'})\setminus (U_{\gamma'} \cap V_{\gamma'})$ and
hence, $U_{\gamma'}(\square{k}) = V_{\gamma'}(\square{k}) = 0$ or
$U_{\gamma'}(\square{k}) = V_{\gamma'}(\square{k}) = 1$. But in the latter
case, this vertex does not contribute to norm bounds since it's in
$U_{\gamma'} \cap V_{\gamma'}$ so it can be safely disregarded. Note that
it doesn't have to stay in this set since future collapses might collapse
this vertex, but this is not a problem as we can charge for this collapse
if it happens.
So, assume we have $U_{\gamma'}(\square{k}) = V_{\gamma'}(\square{k}) = 0$.
But by the definition of collapse, at least one of $\square{i}$ or
$\square{j}$ must have been in $U_\gamma \setminus (U_\gamma \cap V_\gamma)$
or $V_\gamma \setminus (U_\gamma \cap V_\gamma)$. Also from the definition
of collapse, we have $U_{\gamma'}(\square{k}) = U_{\gamma}(\square{i}) +
U_{\gamma}(\square{j}) (\mod 2)$ and $V_{\gamma'}(\square{k}) =
V_{\gamma}(\square{i}) + V_{\gamma}(\square{j}) (\mod 2)$. Putting these
together, we immediately get that the only way this could have happened is
if either $\square{i}, \square{j} \in U_\gamma \setminus (U_\gamma \cap
V_\gamma)$ or if $\square{i}, \square{j} \in V_\gamma \setminus (U_\gamma
\cap V_{\gamma})$.
When such a collapse happens, observe that $|U_{\gamma}| + |V_{\gamma}| \ge
|U_{\gamma'}| + |V_{\gamma'}| + 2$. This is precisely where the decay from
our normalization factor $\eta = \frac{1}{\sqrt{n}}$ kicks in. This
inequality means that an extra decay factor of $\eta^2 = \frac{1}{n}$ is
available to us when we compare to the "expected pseudocalibration"
coefficient of $\beta$. We will use this factor to charge the new square
vertex of degree $0$.
We now make these ideas formal.
Let $Q = U_\beta \cap V_\beta, P = (U_\beta \cup V_\beta) \setminus Q$ and
let $P'$ be the set of degree $1$ square vertices in $\beta$ that are not in
$S_{min}$. Let $s_0$ be the number of degree $0$ square vertices in
$V(\beta)\setminus Q$. All the square vertices outside $P' \cup Q \cup
S_{min}$ have degree at least $2$, let there be $s_{\ge 2}$ of them.
Because of parity constraints, \cref{rmk:parity}, and because there are no
circle vertices in $U_{\beta} \cup V_{\beta}$, all circle vertices have even
degree in $\beta$. Let $c_0$ be the number of degree $0$ circle vertices in
$\beta$. Let $c_2, c_{\ge 4}$ be the number of degree $2$ circle vertices and
the number of circle vertices of degree at least $4$ in $V(\beta) \setminus
S_{min}$ respectively. Then, we have \[n^{\frac{w(V(\beta)) - w(S_{\min}) +
w(W_{iso})}{2}} \le n^{\frac{|P'| + s_{\ge 2} + (1.5 - \varepsilon)(c_2 + c_{\ge
4})}{2}} \cdot n^{s_0 + (1.5 - \varepsilon)c_0}\]
Using $\eta = \frac{1}{\sqrt{n}}$, it suffices to show
\begin{align*}
\abs{E(\alpha)} + &(|U_\alpha| + |V_\alpha| - |U_\beta| - |V_\beta|)\\
&\ge |P'| + s_{\ge 2} + (1.5 - \varepsilon)(c_2 + c_{\ge 4}) + 2s_0 + 2(1.5 - \varepsilon)c_0 + \Omega(\varepsilon\abs{E(\alpha)})
\end{align*}
There can be many ways to collapse $\alpha$ to $\beta$, fix any one. We first use a charging argument for the degree $0$ square vertices.
\begin{lemma}\label{lem:phantom_vertex}
$|U_\alpha| + |V_\alpha| - |U_\beta| - |V_\beta| \ge 2s_0$
\end{lemma}
\begin{proof}
In the collapse process, in each step, a vertex $\square{i} \in U_\gamma \setminus (U_\gamma \cap V_\gamma)$ or $\square{i} \in V_\gamma \setminus (U_\gamma \cap V_\gamma)$ of degree $1$ in an intermediate shape $\gamma$ collapses with another square vertex $\square{k}$. We have that $|U_\gamma| + |V_\gamma|$ decreases precisely when $\square{i}$ collapses with $\square{k} \in U_\gamma$ (resp. $\square{k} \in V_\gamma$). In either case, the quantity decreases by exactly $2$ which we allocate to this new merged vertex. Each degree $0$ square vertex in $V(\beta) \setminus Q$ must have arisen from a collapse, and hence must have had at least an additive quantity of $2$ allocated to it. This proves that $|U_\alpha| + |V_\alpha| - |U_\beta| - |V_\beta| \ge 2s_0$.
\end{proof}
We will now prove a structural lemma.
\begin{lemma}\label{lem:structure}
Any vertex $\circle{u}$ that has degree at least $2$ in $V(\beta) \setminus S_{min}$ is adjacent to at most $1$ vertex of $P'$.
\end{lemma}
\begin{proof}
Observe that $\circle{u}$ cannot be adjacent to $3$ vertices in $P'$ because otherwise, at least $2$ of them would be in $U_\beta \setminus Q$ or in $V_\beta \setminus Q$ which means $\beta$ would be a spider which is a contradiction. If $\circle{u}$ is adjacent to $2$ vertices in $P'$, then one of them is in $U_\beta \setminus Q$ and the other is in $V_\beta \setminus Q$ respectively. Since both of these vertices are not in $S_{min}$, it follows that $\circle{u}$ is in $S_{min}$ since there is no path from $U_\beta$ to $V_\beta$ that doesn't pass through $S_{min}$. This is a contradiction. Therefore, $\circle{u}$ is adjacent to at most $1$ vertex in $P'$.
\end{proof}
This lemma immediately implies $|P'| \le c_2 + c_{\ge 4}$.
To account for edges of $\alpha$ that are not in $\beta$, we let
$\widetilde{\beta}$ be the result of improperly collapsing $\alpha$ to
$\beta$; note that $\abs{E(\alpha)} = \abs{E(\widetilde{\beta})}$.
%
We call the edges that disappeared when properly collapsing ``phantom'' edges.
Let $\deg_{\widetilde{\beta}}(\square{i})$ (resp. $\deg_{\widetilde{\beta}}(\circle{u})$) denote the degree of vertex $\square{i}$ (resp. $\circle{u}$) in $\widetilde{\beta}$. Observe that any circle vertex $\circle{u}$ in $V(\beta)$ has $deg_{\widetilde{\beta}}(\circle{u}) \ge 4$.
\begin{lemma}\label{lem:phantom_edge}
$\abs{E(\alpha)} \ge |P'| + s_{\ge 2} + (1.5 - \varepsilon)(c_2 + c_{\ge 4}) + 2(1.5 - \varepsilon)c_0 + \Omega(\varepsilon\abs{E(\alpha)})$
\end{lemma}
\begin{proof}
We will use the following charging scheme. Each edge of $\beta$ incident on $P'$ allocates $1$ to the incident square vertex, which is in $P'$. Every other edge of $\beta$ allocates $\frac{1}{2}$ to the incident square vertex and $\frac{1}{2} - \frac{\varepsilon}{10}$ to the incident circle vertex. Each phantom edge allocates $1 - \frac{\varepsilon}{10}$ to the incident circle vertex $\circle{u}$. So, a total of $\frac{\varepsilon}{10}(\abs{E(\alpha)} - |P'|)$ has not been allocated.
All square vertices in $P'$ have been allocated a value of $1$. And observe that all square vertices of degree at least $2$ in $\beta$ have been allocated at least $1$ from the incident edges of $\beta$, for a total value of $s_{\ge 2}$. So, the square vertices get a total allocation of at least $|P'| + s_{\ge 2}$.
Consider any degree-$0$ circle vertex $\circle{u}$ in $V(\beta)$. It must be incident to at least $4$ phantom edges and hence, must be allocated at least a value of $4(1 - \frac{\varepsilon}{10}) > 2(1.5 - \varepsilon)$. Hence, the degree-$0$ circle vertices in $V(\beta$) have a total allocation of at least $2(1.5 - \varepsilon)c_0$.
Suppose the degree of $\circle{u}$ in $V(\beta)$ is $2$. Then, it is incident on at least $2$ phantom edges.
By \cref{lem:structure}, it is also adjacent to at most one vertex of $P'$ and so, must have been allocated a value of at least $2(1 - \frac{\varepsilon}{10}) + (deg_{\widetilde{\beta}}(\circle{u}) - 3)(\frac{1}{2} - \frac{\varepsilon}{10})$. This is at least $1.5 - \varepsilon + \frac{\varepsilon}{10}$.
Suppose the degree of $\circle{u}$ in $V(\beta)$ is at least $4$. By \cref{lem:structure}, it is adjacent to at most one vertex of $P'$. Then it must have been allocated a value of at least $(deg_{\widetilde{\beta}}(\circle{u}) - 1)(\frac{1}{2} - \frac{\varepsilon}{10})$. Using $deg_{\widetilde{\beta}}(\circle{u}) \ge 4$, this is at least $1.5 - \varepsilon + \frac{\varepsilon}{10}$.
This implies
\[\abs{E(\alpha)} \ge |P'| + s_{\ge 2} + 2(1.5 - \varepsilon)c_0 + (1.5 - \varepsilon + \frac{\varepsilon}{10})(c_2 + c_{\ge 4}) + \frac{\varepsilon}{10}(\abs{E(\alpha)} - |P'|)\]
Using $|P'| \le c_2 + c_{\ge 4}$ completes the proof.
\end{proof}
Adding \cref{lem:phantom_vertex} and \cref{lem:phantom_edge}, we get the result.
\end{proof}
\begin{corollary}\label{cor:non-spider-norm-bound}
If $\beta$ is a nontrivial non-spider and $\beta \in W(\alpha)$ for some spider $\alpha \in {\mathcal L}$, then
\[\eta^{\abs{U_\alpha} + \abs{V_\alpha}} \cdot \frac{1}{n^{\abs{E(\alpha)}/2}}\norm{M_\beta} \leq \eta^{\abs{U_\beta} + \abs{V_\beta}}\cdot \frac{1}{n^{\Omega(\varepsilon\abs{E(\alpha)})}}\]
\end{corollary}
\begin{proof}
From \cref{lem:gaussian-norm-bounds}, we have
\[ \norm{M_\beta} \leq 2\cdot\left(\abs{V(\beta)} \cdot (1+\abs{E(\beta)}) \cdot \log(n)\right)^{C\cdot (\abs{V_{rel}(\beta)} + \abs{E(\beta)})} \cdot n^{\frac{w(V(\beta)) - w(S_{\min}) + w(W_{iso})}{2}}\]
We have $\abs{V(\beta)}\cdot (1+\abs{E(\beta)}) \cdot \log(n) \le n^{O(\tau)}$. Also, $|V_{rel}(\beta)| \le 2(|E(\alpha)| + |E(\beta)|)$ since all the degree $0$ vertices in $V_{rel}(\beta)$ would have had vertices of $V_{rel}(\alpha)$ collapse into it in the chain of collapses and there are no degree $0$ vertices in $V_{rel}(\alpha)$. Finally, since $|E(\alpha)| \ge |E(\beta)|$, the factor
$2\cdot(\abs{V(\beta)} \cdot (1+\abs{E(\beta)}) \cdot \log(n))^{C\cdot (\abs{V_{rel}(\beta)} + \abs{E(\beta)})}$ can be absorbed into $\frac{1}{n^{\Omega(\varepsilon\abs{E(\alpha)})}}$. The result follows from \cref{lem:advanced-charging}.
\end{proof}
\begin{proposition}\label{prop:m+-diag}
If $\beta$ is a trivial shape, $\lambda_\beta^+ = \lambda_\beta$.
\begin{proof}
A trivial shape cannot appear in $W(\alpha)$ for any $\alpha$, since every collapse of a spider always keeps its circle vertices around.
\end{proof}
\end{proposition}
\begin{lemma}\label{lem:non-spider-psd}
For $k,l \in \{0, 1, \dots, D/2\}$, let ${\mathcal B}_{k,l}$ denote the set of nontrivial non-spiders on block $(k, l)$. Then
\[\displaystyle\sum_{\beta \in {\mathcal B}_{k,l}} \abs{\lambda_\beta^+}\norm{M_\beta} \leq \eta^{k+l} \cdot \frac{1}{n^{\Omega(\varepsilon)}} \]
\end{lemma}
\begin{proof}
\begin{align*}
\displaystyle\sum_{\beta \in {\mathcal B}_{k,l}}\norm{\lambda_\beta^+ M_\beta}
\leq & \sum_{\beta \in {\mathcal B}_{k,l}} \abs{\lambda_\beta} \norm{M_\beta} + \sum_{\beta \in {\mathcal B}_{k,l}} \sum_{\substack{\text{spiders }\alpha:\\ \beta \in W(\alpha)}} \abs{v_\beta} \abs{\lambda_\alpha} \norm{M_\beta}
\end{align*}
To bound the first term, we checked previously in~\cref{cor:non-spider-sum} that the total norm of nontrivial non-spiders appearing in the pseudocalibration (i.e. this term) is $\eta^{k+l}o_n(1)$. For the second term, via~\cref{lem:web-leaves} we have a bound on the accumulations $v_\gamma$ of one spider on one non-spider, so it is at most
\[\leq \sum_{\beta \in {\mathcal B}_{k,l}}\displaystyle\sum_{\substack{\text{spiders }\alpha:\\ \beta \in W(\alpha)}}(C_1\abs{V(\alpha)} \cdot \abs{E(\alpha)})^{C_2 \abs{E(\alpha)}} \cdot \abs{\lambda_\alpha} \norm{M_\beta}.\]
Use the bound on the coefficients $\abs{\lambda_\alpha}$,~\cref{prop:coefficient-bound},
\begin{align*}
\leq \sum_{\beta \in {\mathcal B}_{k,l}}\displaystyle\sum_{\substack{\text{spiders }\alpha:\\ \beta \in W(\alpha)}}(C_1\abs{V(\alpha)} \cdot \abs{E(\alpha)})^{C_2 \abs{E(\alpha)}} \cdot\eta^{\abs{U_\alpha} + \abs{V_\alpha}}\cdot \frac{\abs{E(\alpha)}^{3\abs{E(\alpha)}}}{n^{\abs{E(\alpha)}/2}} \cdot \norm{M_\beta}
\end{align*}
Invoking the norm bound for non-spiders which are collapses, \cref{cor:non-spider-norm-bound},
\begin{align*}
& \leq \eta^{k+l} \cdot \sum_{\beta \in {\mathcal B}_{k,l}}\displaystyle\sum_{\substack{\text{spiders }\alpha:\\ \beta \in W(\alpha)}} \left(\frac{C_1\abs{V(\alpha)} \cdot \abs{E(\alpha)}}{n^{\Omega(\varepsilon)}}\right)^{C_2' \abs{E(\alpha)}}\\
& \leq \eta^{k+l} \cdot \sum_{\beta \in {\mathcal B}_{k,l}}\displaystyle\sum_{\substack{\text{spiders }\alpha:\\ \beta \in W(\alpha)}} \left(\frac{C_1n^\tau \cdot n^\tau}{n^{\Omega(\varepsilon)}}\right)^{C_2' \abs{E(\alpha)}}.
\end{align*}
Bound the sum over all spiders by the sum over all shapes. By~\cref{prop:edge-shape-count}, the number of shapes with $i$ edges is $n^{O(\tau (i+1))}$. Summing by the number of edges, observe that $\abs{E(\alpha)} \geq \max(\abs{E(\beta)}, 2)$ since spiders always have at least $2$ edges.
\begin{align*}
& \leq \eta^{k+l}\sum_{\beta \in {\mathcal B}_{k,l}}\displaystyle\sum_{i=\max(\abs{E(\beta)}, 2)}^\infty
n^{O(\tau (i+1))} \cdot \left(\frac{C_1n^\tau \cdot n^{\tau}}{n^{\Omega(\varepsilon)}}\right)^{C_2' i} \\
&\leq \eta^{k+l}\sum_{\beta \in {\mathcal B}_{k,l}} \frac{1}{n^{\Omega(\varepsilon \max(\abs{E(\beta)}, 2))}}\\
& \leq \eta^{k+l}\sum_{i=0}^\infty \frac{n^{O(\delta (i+1))}}{n^{\Omega(\varepsilon \max(i, 2))}}\\
& = \eta^{k+l} \cdot \frac{1}{n^{\Omega(\varepsilon)}} \qedhere
\end{align*}
\end{proof}
\begin{corollary}\label{cor:m+-diag}
For $k \in \{0, \dots, D/2\}$, the $(k,k)$ block of ${\mathcal M}^+$ has minimum singular value at least $\eta^{2k}(1 - \frac{1}{n^{\Omega(\varepsilon)}})$, and for $k, l \in \{0, \dots, D/2\}, l \neq k$, the $(k,l)$ off-diagonal block has norm at most $\eta^{k+l} \cdot \frac{1}{n^{\Omega(\varepsilon)}}$.
\end{corollary}
\begin{proof}
By~\cref{prop:m+-diag} the identity matrix appears on the $(k,k)$ blocks with coefficient $\eta^{2k}$. By construction, ${\mathcal M}^+$ has no spider shapes. By~\cref{lem:non-spider-psd}, the total norm of the non-spider shapes on the $(k,l)$ block is at most $\eta^{k+l}\cdot \frac{1}{n^{\Omega(\varepsilon)}}$.
\end{proof}
\begin{theorem}
W.h.p. ${\mathcal M}_{fix} \succeq 0$.
\end{theorem}
\begin{proof}
For any $x \in \nullspace({\mathcal M}_{fix})$, we of course have $x^\intercal {\mathcal M}_{fix} x = 0$.
For any $x \perp \nullspace({\mathcal M}_{fix})$ with $\norm{x}_2 = 1$,
\begin{align*}
x^\intercal {\mathcal M}_{fix} x & = x^\intercal ({\mathcal M} + {\mathcal E}) x\\
&= x^\intercal {\mathcal M}^+ x + x^\intercal \left(\displaystyle\sum_{\text{spiders }\alpha} \lambda_\alpha\left( {\mathcal M}_\alpha - \sum_{\text{leaves }\gamma\text{ of }W(\alpha)}v_\gamma M_\gamma \right)\right)x + x^\intercal {\mathcal E} x\\
&= x^\intercal ({\mathcal M}^+ + {\mathcal E}) x
\end{align*}
where the last equality follows from \cref{prop:web-sum}.
Because the norm bound on ${\mathcal E}$ is significantly less than $\eta^{D} = n^{-n^{\delta}}$ (see \cite{sklowerbounds}), the bound on the norm of each block of ${\mathcal M}^+$
in~\cref{cor:m+-diag} also applies to the blocks of ${\mathcal M}^+ + {\mathcal E}$. Therefore,
we use~\cref{lem:block-psd} to conclude ${\mathcal M}^+ + {\mathcal E} \succeq 0$ and the above expression is nonnegative.
\end{proof}
\subsection{Combinatorial Proof of Lemma \ref{lem:fixed-moments}}\label{app:combinatorialpseudocalibration}
In this appendix, we give a combinatorial proof of Lemma \ref{lem:fixed-moments}. We recall the statement of Lemma \ref{lem:fixed-moments} here.
\begin{lemma}
Let $\alpha \in {\mathbb{N}}^n$. When $v$ is fixed and $b$ is fixed (not necessarily +1 or -1) and $d \sim N(0, I)$ conditioned on $\ip{v}{d} = b\norm{v}$,
\[{\mathbb E}_{d}[h_{\alpha}(d)] = \frac{v^\alpha}{\norm{v}^{\abs{\alpha}}} \cdot h_{\abs{\alpha}}(b).\]
\end{lemma}
\begin{proof}
Again, it is sufficient to prove this lemma when $\norm{v} = 1$. For this proof, we need the following description of Hermite polynomials in terms of matchings and Isserlis' Theorem/Wick's Theorem.
\begin{fact}
\[
h_k(x) = \sum_{M: M \text{ is a matching on } [k]}{(-1)^{|M|}x^{k - 2|M|}}
\]
\end{fact}
\begin{theorem}[Isserlis' Theorem/Wick's Theorem]
For any vectors $u_1,\ldots,u_k$,
\[
E_{x \sim N(0,I)}\left[\prod_{j=1}^{k}{\ip{x}{u_j}}\right] = \sum_{M: M \text{ is a perfect matching on } [k]}\prod_{(i,j) \in M}{\ip{u_i}{u_j}}
\]
\end{theorem}
The idea behind this proof is to break up each coordinate vector $e_i$ into a component which is parallel to $v$ and a component which is perpendicular to $v$.
\begin{definition}
For each coordinate $i$, define $e_{i}^{\perp} = e_i - {v_i}v$
\end{definition}
\begin{proposition}
For any coordinate $i$, $\ip{e_{i}^{\perp}}{e_{i}^{\perp}} = 1-{v_i}^2$. For any pair of distinct coordintes $i$ and $i'$, $\ip{e_{i}^{\perp}}{e_{i'}^{\perp}} = -{v_i}{v_{i'}}$
\end{proposition}
\begin{proof}
Observe that for all i,
\[
\ip{e_{i}^{\perp}}{e_{i}^{\perp}} = \ip{e_{i} - {v_i}v}{e_{i} - v_{i}v} = \ip{e_{i}}{e_{i}} - 2{v_i}\ip{v}{e_{i}} + {v_i}^2\ip{v}{v} = 1-{v_i}^2
\]
and if $i$ and $i'$ are distinct then
\[
\langle{e_{i}^{\perp},e_{i'}^{\perp}}\rangle = \langle{e_{i} - {v_i}v,e_{i'} - v_{i'}v}\rangle = \langle{e_{i},e_{i'}}\rangle - {v_i}\langle{v,e_{i'}}\rangle - {v_{i'}}\langle{e_i,v}\rangle + {v_i}{v_{i'}}\langle{v,v}\rangle = -{v_i}{v_{i'}}
\]
\end{proof}
To evaluate ${\mathbb E}_{d}[h_{\alpha}(d)]$, we proceed as follows:
\begin{enumerate}
\item Break up each $d_i = \ip{d}{e_i}$ as $d_i = \ip{bv}{e_{i}} + \ip{d^{\perp}}{e_{i}} = bv_{i} + \ip{d^{\perp}}{e_{i}^{\perp}}$
where $d^{\perp}$ is the component of $d$ which is orthogonal to $v$.
\item Observe that since each $e^{\perp}_{i}$ is orthogonal to $v$, we can replace $d^{\perp}$ by a random vector $d' \sim N(0,I)$.
\item Apply Isserlis' Theorem/Wick's Theorem to evaluate these terms.
\end{enumerate}
For this calculation, it is convenient to think of $\alpha$ as a tuple of $|\alpha|$ elements where each $i \in [n]$ appears $\alpha_i$ times.
\begin{definition}
For each $j \in [\abs{\alpha}]$, we define $\alpha(j)$ to be the index $i$ such that $\sum_{i' = 1}^{i-1}{\alpha_{i'}} < j$ and $\sum_{i'=1}^{i}{\alpha_{i'}} \geq j$. For example, if $\alpha = (2,1,0,3)$ then $\alpha(1) = \alpha(2) = 1$, $\alpha(3) = 2$, and $\alpha(4) = \alpha(5) = \alpha(6) = 4$.
\end{definition}
In the special case when $\alpha(1),\ldots,\alpha(\abs{\alpha})$ are all distinct,
\[
{\mathbb E}_{d}[h_{\alpha}(d)] = {\mathbb E}_d\Big[\prod_{j=1}^{\abs{\alpha}}{\ip{d}{e_{\alpha(j)}}}\Big] = {\mathbb E}_{d' \sim N(0,I)}\Big[\prod_{j=1}^{\abs{\alpha}}{\left(bv_{\alpha(j)} + \ip{d'}{e_{\alpha(j)}^{\perp}}\right)}\Big]
\]
In this case, we can associate a matching $M$ to each term we get after applying Isserlis' Theorem/Wick's Theorem as follows:
\begin{enumerate}
\item For each $j \in \abs{\alpha}$ where we have the $bv_{\alpha(j)}$ term, we take $j$ to be isolated.
\item For each pair of distinct $j,j' \in \abs{\alpha}$ such that we have the term $\ip{e_{\alpha
(j)}^{\perp}}{e_{\alpha(j')}^{\perp}}$ (which only happens if we start with the $\ip{d'}{e_{\alpha(j)}^{\perp}}$ and $\ip{d'}{e_{\alpha(j')}^{\perp}}$ terms and $e_{\alpha(j)}^{\perp}$ and $e_{\alpha(j')}^{\perp}$ are paired together after applying Isserlis' Theorem/Wick's Theorem), we add an edge between $j$ and $j'$ in $M$.
\end{enumerate}
We now have that
\begin{align*}
{\mathbb E}_{d}[h_{\alpha}(d)] &= \sum_{M:M \text{ is a matching on [\abs{\alpha}]}}{\left(\prod_{(j,j') \in M}{-v_{\alpha(j)}v_{\alpha(j')}}\right)\left(\prod_{j: j \text{ is unmatched by } M}{bv_{\alpha(j)}}\right)}\\
&= \left(\sum_{M:M \text{ is a matching on [\abs{\alpha}]}}{(-1)^{|M|}b^{\abs{\alpha} - 2|M|}}\right)\prod_{j=1}^{\abs{\alpha}}{v_{\alpha(j)}} \\
&= h_{\abs{\alpha}}(b)v^{\alpha}
\end{align*}
For the general case, we use a similar idea although it is somewhat more complicated. In particular, we associate a multi-colored matching $M = M_{blue} \cup M_{red} \cup M_{purple}$ to each term. The idea is that whenever we have a blue edge, we could have had a red edge instead and vice versa, so we can combine terms with red and blue edges to make purple edges which gives us an ordinary matching as before. More precisely, the idea is as follows.
\begin{enumerate}
\item When we expand out $h_{\alpha}(d)$ in terms of matchings, we take $M_{blue}$ to be the union of these matchings.
\item For each $j \in \abs{\alpha}$ where we have the $bv_{\alpha(j)}$ term, we take $j$ to be isolated.
\item For each pair of distinct $j,j' \in \abs{\alpha}$ such that we have the term $\ip{e_{\alpha
(j)}^{\perp}}{e_{\alpha(j')}^{\perp}}$ (which only happens if we start with the $\ip{d'}{e_{\alpha(j)}^{\perp}}$ and $\ip{d'}{e_{\alpha(j')}^{\perp}}$ terms and $e_{\alpha(j)}^{\perp}$ and $e_{\alpha(j')}^{\perp}$ are paired together after applying Isserlis' Theorem/Wick's Theorem), we add an edge between $j$ and $j'$. If $\alpha(j') = \alpha(j)$ then we take this edge to be red and add it to $M_{red}$. If $\alpha(j') \neq \alpha(j)$ then we take this edge to be purple and add it to $M_{purple}$.
\end{enumerate}
We now implement this idea. We have that
\begin{align*}
&{\mathbb E}_{d}[h_{\alpha}(d)] = \sum_{M_{blue}: M_{blue} \text{ is a matching on } [\abs{\alpha}], \atop \forall (j,j') \in M_{blue}, \alpha(j) = \alpha(j')}{
(-1)^{|M_{blue}|}{\mathbb E}_{d}\Big[\prod_{j \in \abs{\alpha}: j \text{ is unmatched by } M_{blue}}{\ip{d}{e_{\alpha(j)}}}\Big]} \\
&= \sum_{M_{blue}: M_{blue} \text{ is a matching on } [\abs{\alpha}], \atop \forall (j,j') \in M_{blue}, \alpha(j) = \alpha(j')}{
(-1)^{|M_{blue}|}{\mathbb E}_{d' \sim N(0,I)}\Big[\prod_{j \in \abs{\alpha}: j \text{ is unmatched by } M_{blue}}{\left(bv_{\alpha(j)} + \ip{d'}{e_{\alpha(j)}^{\perp}}\right)}\Big]}
\end{align*}
Expanding out ${\mathbb E}_{d' \sim N(0,I)}\Big[\prod_{j \in \abs{\alpha}: j \text{ is unmatched by } M_{blue}}{\left(bv_{\alpha(j)} + \ip{d'}{e_{\alpha(j)}^{\perp}}\right)}\Big]$ and applying Isserlis' Theorem/Wick's Theorem, we have that
\begin{align*}
{\mathbb E}_{d}[h_{\alpha}(d)] &= \sum_{M_{blue},M_{red},M_{purple}}{(-1)^{|M_{blue}|}\prod_{(j,j') \in M_{red}}{(1-v^{2}_{\alpha(j)})}\prod_{(j,j') \in M_{purple}}{(-v_{\alpha(j)}v_{\alpha(j')})}} \\
&\prod_{j: j \text{ is unmatched by } M = M_{blue} \cup M_{red} \cup M_{purple}}{bv_{\alpha(j)}}
\end{align*}
where the sum is taken over all $M_{blue},M_{red},M_{purple}$ such that
\begin{enumerate}
\item $M = M_{blue} \cup M_{red} \cup M_{purple}$ is a matching on $[\abs{\alpha}]$ and $M_{blue},M_{red},M_{purple}$ are disjoint.
\item $\forall (j,j') \in M_{blue}, \alpha(j) = \alpha(j')$.
\item $\forall (j,j') \in M_{red}, \alpha(j) = \alpha(j')$.
\item $\forall (j,j') \in M_{purple}, \alpha(j) \neq \alpha(j')$.
\end{enumerate}
Since whenever we have a blue edge, we could have instead had a red edge and vice versa, for each distinct $j,j'$ such that $\alpha(j') = \alpha(j)$, we can combine terms which have a blue edge between $j$ and $j'$ with terms which have a red edge between $j$ and $j'$. A blue edge between $j$ and $j'$ has a coefficient of $-1$ and a red edge between $j$ and $j'$ has a coefficient of $1 - v^2_{\alpha(j)}$, so this effectively gives a purple edge with coefficient $-v^2_{\alpha(j)} = v_{\alpha(j)}v_{\alpha(j')}$. Thus,
\begin{align*}
{\mathbb E}_{d}[h_{\alpha}(d)] &= \sum_{M:M \text{ is a matching on [\abs{\alpha}]}}{\left(\prod_{(j,j') \in M}{-v_{\alpha(j)}v_{\alpha(j')}}\right)\left(\prod_{j: j \text{ is unmatched by } M}{bv_{\alpha(j)}}\right)}\\
&= h_{\abs{\alpha}}(b)v^{\alpha}
\end{align*}
\end{proof}
\subsection{Killing a single spider}
\label{sec:single-spider}
We saw in the Proof Strategy section that the shape $2\beta_1 + \frac{1}{n}\beta_2$ lies in the nullspace of a moment matrix which
satisfies the constraints ``$\ip{v}{d_u}^2 = 1$". The shape $\beta_1$ is
exactly the kind of substructure that appears in a spider! Therefore it
is natural to hope that if $\alpha$ is a left spider, then
${\mathcal M}_{fix}M_{\alpha} = 0$. This
doesn't quite hold because $\ip{v}{d_u}^2$ is ``missing"
some terms: in realizations of $\alpha,$ the end vertices are required to be
distinct from the other squares in $\alpha$, which prevents terms
for all pairs $i,j$ from appearing in the product
${\mathcal M}_{fix}M_\alpha$. There are smaller ``intersection terms"
(which we call
collapses of $\alpha$) that we can add so that the end vertices are permitted to take
on all pairs $i, j$. After adding in these terms, we will produce a matrix $L$ with ${\mathcal M}_{fix}L =
0$.
We first define what it means to collapse a shape into another shape
by merging two vertices. Here, we only define it for merging two
square vertices, since these are the only kind of merges that will
happen in our analysis of intersection terms.
\begin{definition}[Improper collapse]
Let $\alpha$ be a shape and let $\square{i}, \square{j}$ be two distinct square vertices in $V(\alpha)$. We define the improper collapse of $\square{i}, \square{j}$ by:
\begin{itemize}
\item Remove \square{i}, \square{j} from $V(\alpha)$ and replace them by a single new vertex \square{k}.
\item Replace each edge $\{\square{i}, \circle{u}\}$ and $\{\square{j}, \circle{u}\}$, if present, by $\{\square{k}, \circle{u}\}$, keeping the same labels (note that there may be multiedges and so the new shape may not be proper).
\item Set $U(\square{k}) = U(\square{i}) + U(\square{j}) (\mod 2)$ and $V(\square{k}) = V(\square{i}) + V(\square{j}) (\mod 2)$.
\end{itemize}
\end{definition}
Improper collapses have parallel edges, but we can convert them back to a sum
of proper shapes.
This is done by, for each set of parallel edges, expanding the product of Fourier characters in the Fourier basis. For example, two parallel edges with label 1 should be expanded as
\[h_1(z)^2 = (z^2-1) + 1 = h_2(z) + h_0(z)\]
\begin{definition}[Collapsing a shape]
Let $\alpha$ be a shape with two distinct square vertices $\square{i}, \square{j}$. We say that $\beta$ is a (proper) collapse of $\square{i}, \square{j}$ if $\beta$ appears in the expansion of the improper collapse of $\square{i},\square{j}$.
\end{definition}
\begin{remark}
If $l_1, \dots, l_k$ are the labels of a set of parallel edges, then the product $h_{l_1}(z) \cdots h_{l_k}(z)$ is even/odd depending on the parity of $l_1 + \cdots + l_k$. Thus the nonzero Fourier coefficients will be the terms of matching parity. Therefore, in both the boolean and Gaussian cases, the shapes that are proper collapses of a given improper collapse are formed by replacing each set of parallel edges by a single edge $e$ such that $l(e) \le l_1 + \ldots + l_k$ and $l(e)~\equiv~l_1 + \cdots + l_k\pmod 2$.
\end{remark}
\begin{remark}\label{rmk:parity}
Looking at the definition and in light of the previous remark, we have the following.
\begin{enumerate}
\item The number of circle vertices does not change by collapsing a shape but the number of square vertices decreases by $1$.
\item $\alpha \in {\mathcal L}$ has the property that the vertices have odd degree if and only if they are in $(U_{\alpha} \cup V_{\alpha}) \setminus (U_{\alpha} \cap V_{\alpha})$. When $\alpha$ collapses, this property is preserved.
\end{enumerate}
\end{remark}
We now define the desired shapes $L_k$ which lie in the null space of ${\mathcal M}_{fix}$.
\begin{definition}
For $k \geq 2$ define the shape $\ell_k$ on $\{\square{1}, \dots, \square{k}, \circle{1} \}$ with two edges $\{\{\square{1}, \circle{1}\}$, $\{\square{2}, \circle{1}\}\}$. The left side of $\ell_k$ consists of $U_{\ell_k} = \{\square{1},\dots,\square{k}\}$. The right side consists of $V_{\ell_k} =\{\square{3}, \dots, \square{k}, \circle{1}\}$.
\end{definition}
\begin{definition}\label{def:lk}
Define the ``completed'' version $L_k$ of $\ell_k$ to be the matrix which is the sum of $c_\beta M_{\beta}$ for $\beta$ being the following shapes with coefficients:
\begin{itemize}
\item ($L_{k,1}$): $\ell_k$, with coefficient 2.
\item ($L_{k,2}$): If $k \geq 3$, collapse $\square{1}$ and $\square{3}$ in $\ell_k$ with coefficient $\frac{2}{n}$
\item ($L_{k,3}$): If $k \geq 4$, collapse $\square{1}$ and $\square{3}$, and collapse $\square{2}$ and $\square{4}$ in $\ell_k$ with coefficient $\frac{2}{n^2}$
\item ($L_{k,4}$): Collapse $\square{1}$ and $\square{2}$, replacing the edges by an edge with label 2, with coefficient $\frac{1}{n}$
\item ($L_{k,5}$): If $k \geq 3$, collapse $\square{1}, \square{2}$, and $\square{3}$, replacing the edges by an edge with label 2, with coefficient $\frac{1}{n}$.
\end{itemize}
\end{definition}
For a pictorial representation of the ribbons/shapes, see ~\cref{fig:Lk} below.
\begin{lemma}\label{lem:completed-left-side}
${\mathcal M}_{fix} L_k = 0$
\end{lemma}
\begin{proof}
These shapes are constructed so that if we fix a partial realization
of the vertices $\circle{1}$ and $\square{3}, \dots, \square{k}$ as $\circle{u} \in {\mathcal C}_m$ and $S \in \binom{{\mathcal S}_n}{k-2}$, the squares $\square{1}$ and $\square{2}$ can still be realized as any $j_1,j_2 \in [n]$. That is, exactly the following equality holds,
\begin{align*}
({\mathcal M}_{fix} L_k)_I &= \displaystyle\sum_{\substack{\circle{u} \in {\mathcal C}_m,\\ S \in \binom{{\mathcal S}_n}{k-2}} }\left(\sum_{\substack{j_1, j_2 \in [n]:\\ j_1 \neq j_2}} \tilde{\EE}[v^I v^S v_{j_1}v_{j_2}] d_{uj_1}d_{uj_2} + \sum_{j_1 \in [n]} \tilde{\EE}[v^Iv^Sv_{j_1}^2](d_{uj_1}^2 - 1)\right)\\
&= \displaystyle\sum_{\substack{\circle{u} \in {\mathcal C}_m,\\ S \in \binom{{\mathcal S}_n}{k-2}}} \tilde{\EE}[v^Iv^S(\ip{v}{d_u}^2 - 1)]\\
&= 0
\end{align*}
To demonstrate how the coefficients arise, we analyze the ribbons $R$ which $L_k$ is composed of and see how they contribute to the output.
For pictures of the ribbons/shapes, see~\cref{fig:Lk} below.
Let the ribbon be partially realized as $\circle{u}$ and $S = \{\square{j_3},\dots, \square{j_k}\}$. Let $(M_{fix}L_k)_{I(u, S)}$ denote the terms in $(M_{fix}L_k)_I$ with this partial realization. In this notation we want to show
\[({\mathcal M}_{fix}L_k)_{I(u, S)} = \sum_{\substack{j_1, j_2 \in [n]:\\ j_1 \neq j_2}} \tilde{\EE}[v^I v^S v_{j_1}v_{j_2}] d_{uj_1}d_{uj_2} + \sum_{j_1 \in [n]} \tilde{\EE}[v^Iv^Sv_{j_1}^2](d_{uj_1}^2 - 1).\]
\begin{figure}[!ht]
\centering
\includegraphics[height=10cm]{sherrington_kirkpatrick/LkFullWithNameU}
\caption{The five shapes that make up $L_4$.}
\label{fig:Lk}
\end{figure}
\begin{enumerate}
\item If we take a ribbon $R$ with $A_R = \{\square{j_1}, \dots, \square{j_k}\}$, $B_R = \{\square{j_3}, \dots, \square{j_k}\} \cup \{\circle{u}\}$ and $E(R) = \{\{\square{j_1}, \circle{u}\}, \{\square{j_2}, \circle{u}\}\}$ where $j_1 \neq j_2$ and $j_1, j_2 \notin S$ then
\[ ({\mathcal M}_{fix}M_R)_{I(u, S)} = \tilde{\EE}[v^Iv^Sv_{j_1}v_{j_2}]d_{uj_1}d_{uj_2}.\]
This ribbon must ``cover'' both ordered pairs $(j_1, j_2)$ and $(j_2, j_1)$, so we want each such ribbon $R$ to appear with a coefficient of 2 in $L_k$.
\item If we take a ribbon $R$ with $A_R = \{\square{j_1}, \dots, \square{j_k}\} \setminus \{\square{j_1}, \square{j_3}\}$, $B_R = \{\square{j_3}, \dots, \square{j_k}\} \cup \{\circle{u}\}$ and $E(R) = \{\{\square{j_3}, \circle{u}\}, \{\square{j_2}, \circle{u}\}\}$ where $j_1 = j_3 \in S$ then
\[ ({\mathcal M}_{fix}M_R)_{I(u, S)} = \tilde{\EE}[v^Iv^{S\setminus \{j_3\}}v_{j_2}]d_{uj_3}d_{uj_2} = n\tilde{\EE}[v^Iv^Sv_{j_1}v_{j_2}]d_{uj_1}d_{uj_2}.\]
Taking a coefficient of $\frac{2}{n}$ in $L_k$ covers the two pairs $(j_1, j_2)$ and $(j_2, j_1)$ for this case of overlap with $S$.
\item If we take a ribbon $R$ with $A_R = \{\square{j_1}, \dots, \square{j_k}\} \setminus \{\square{j_1}, \square{j_2}, \square{j_3}, \square{j_4}\}$, $B_R = \{\square{j_3}, \dots, \square{j_k}\} \cup \{\circle{u}\}$ and $E(R) = \{\{\square{j_3}, \circle{u}\}, \{\square{j_4}, \circle{u}\}\}$ where $j_1 = j_3 \in S$ and $j_2 = j_4 \in S$ then
\[ ({\mathcal M}_{fix}M_R)_{I(u, S)} = \tilde{\EE}[v^Iv^{S\setminus \{j_3, j_4\}}]d_{uj_3}d_{uj_4} = n^2\tilde{\EE}[v^Iv^Sv_{j_1}v_{j_2}]d_{uj_1}d_{uj_2}.\]
Taking a coefficient of $\frac{2}{n^2}$ in $L_k$ covers the two pairs $(j_1, j_2)$ and $(j_2, j_1)$ for this case of overlap with $S$.
\item If we take a ribbon $R$ with $A_R = \{\square{j_1}, \dots, \square{j_k}\}\setminus \{\square{j_1},\square{j_2}\}$, $B_R = \{\square{j_3}, \dots, \square{j_k}\} \cup \{\circle{u}\}$ and $E(R) = \{\{\square{j_1}, \circle{u}\}_2\}$ where $j_1 = j_2 \notin S$ then
\[ ({\mathcal M}_{fix}M_R)_{I(u, S)} = \tilde{\EE}[v^Iv^{S}](d_{uj_1}^2-1) = n\tilde{\EE}[v^Iv^Sv_{j_1}^2](d_{uj_1}^2-1).\]
Taking a coefficient of $\frac{1}{n}$ in $L_k$ covers these terms.
\item If we take a ribbon $R$ with $A_R = \{\square{j_1}, \dots, \square{j_k}\} \setminus \{\square{j_1}, \square{j_2}\}$, $B_R = \{\square{j_3}, \dots, \square{j_k}\} \cup \{\circle{u}\}$ and $E(R) = \{\{\square{j_3}, \circle{u}\}_2\}$ where $j_1 = j_2 =j_3\in S$ then
\[ ({\mathcal M}_{fix}M_R)_{I(u, S)} = \tilde{\EE}[v^Iv^{S}](d_{uj_3}^2-1) = n\tilde{\EE}[v^Iv^Sv_{j_1}^2](d_{uj_1}^2-1).\]
Taking a coefficient of $\frac{1}{n}$ in $L_k$ covers these terms.
\end{enumerate}
\end{proof}
One of the key facts about graph matrices is that multiplication of graph matrices approximately equals a new graph matrix, $M_\alpha \cdot M_\beta \approx M_{\gamma}$, where $\gamma$ is the result of gluing $V_\alpha$ with $U_\beta$ (and if $V_\alpha, U_\beta$ do not have the same number of vertices of each type, the product is zero). The error terms in the approximation are intersection terms (collapses) between the variables in $\alpha$ and $\beta$.
\begin{definition}
Say that shapes $\alpha$ and $\beta$ are composable if $V_\alpha$ and $U_\beta$ have the same number of square and circle vertices. We say a shape $\gamma$ is a gluing of $\alpha$ and $\beta$, if the graph of $\gamma$ is the disjoint union of the graphs of $\alpha$ and $\beta$, followed by identifying $V_\alpha$ and $U_\beta$ under some type-preserving bijection, and if $U_\gamma = U_\alpha$ and $V_\gamma = V_\beta$.
\end{definition}
\begin{proposition}\label{prop:graph-matrix-multiplication}
Let $\alpha, \beta$ be composable shapes. Assume that $V(\alpha) \setminus V_\alpha$ has only square vertices. Let $\{\gamma_i\}$ be the distinct gluings of $\alpha$ and $\beta$, and let $\widetilde{{\mathcal I}}$ be the set of improper collapses of any number of squares (possibly zero) in $V(\alpha) \setminus V_\alpha$ with distinct squares in $V(\beta) \setminus U_\beta$ in any gluing $\gamma_i$. Then there are coefficients $c_\gamma$ for $\gamma \in \widetilde{{\mathcal I}}$ such that
\[ M_\alpha\cdot M_\beta = \displaystyle\sum_{\gamma \in \widetilde{{\mathcal I}}} c_\gamma M_\gamma.\]
Furthermore, the coefficients satisfy $\abs{c_\gamma} \leq
2^{\abs{V(\alpha) \setminus V_\alpha}}\abs{V(\gamma)}^{\abs{V(\alpha) \setminus U_\alpha}}$.
\end{proposition}
\begin{proof}
The product $M_\alpha \cdot M_\beta$ is a matrix which is a symmetric function of the inputs $(d_1, \dots, d_m)$, the space of which is spanned by the $M_\gamma$ over all possible shapes $\gamma$ (not restricted to $\widetilde{{\mathcal I}}$), so there exist coefficients $c_\gamma$ if we allow all shapes $\gamma$. We need to check that $M_\alpha \cdot M_\beta$ actually lies in the span of shapes in $\widetilde{{\mathcal I}}$ by showing that all ribbons in $M_\alpha \cdot M_\beta$ have shapes in $\widetilde{{\mathcal I}}$. Expanding the definition,
{\footnotesize
\[ M_\alpha \cdot M_\beta = \left(\displaystyle\sum_{R \text{ is a ribbon of shape }\alpha} M_R\right)\left(\sum_{S\text{ is a ribbon of shape }\beta} M_S\right) = \displaystyle\sum_{\substack{R \text{ is a ribbon of shape }\alpha,\\ S \text{ is a ribbon of shape }\beta}} M_R M_S.\]
}%
In order for $M_RM_S$ to be nonzero, we require $B_R = A_S$ as sets; $R$ may assign the labels arbitrarily inside $B_R$, resulting in different gluings of $\alpha$ and $\beta$. Fix $R$ and $S$, and let $\gamma$ be the corresponding gluing of $\alpha$ and $\beta$ for this $R$ and $S$.
The matrix $M_RM_S$ has one nonzero entry; we claim that it is a Fourier character for a ribbon $T$ which is a collapse of $\gamma$. The labels of $R$ outside of $B_R$ can possibly overlap with the labels of $S$ outside of $A_S$, and naturally the shape of $T$ is the result of collapsing vertices in $\gamma$ with the same label.
To bound the coefficients $c_\gamma$ that appear, it suffices to bound the coefficient on a ribbon $M_T$, which is bounded by the number of contributing ribbons $R, S$, where we say ribbons $R$ of shape $\alpha$ and $S$ of shape $\beta$ contribute to $T$ if $M_RM_S = M_T$. From $T$, we can completely recover the sets $A_R$ and $B_S$. The labels of $V(R) \setminus A_R$ must be among the labels of $T$; choose them in at most $\abs{V(\gamma)}^{\abs{V(\alpha) \setminus U_\alpha}}$ ways. This also determines $B_R =A_S$. All that remains is to determine the graph structure of $S$. Since improper collapsing doesn't lose any edges, knowing the labels of $R$ we know exactly which edges of $T$ must come from $R$ and $S$. The vertices $V(T) \setminus V(R)$ must come from $S$, as must $B_R$; pick a subset of $V(R) \setminus B_R$ to include in $2^{\abs{V(\alpha) \setminus V_\alpha}}$ ways.
\end{proof}
Let $\alpha$ be a left spider with end vertices $\square{i}, \square{j}$ which are adjacent to a circle $\circle{u}$. Recall that our goal is to argue that ${\mathcal M} M_\alpha \approx 0$. To get there, we can try and factor $M_\alpha$ across the vertex separator $S = U_\alpha \cup \{\circle{u}\} \setminus \{\square{i},\square{j}\}$ which separates $\alpha$ into
\[ M_\alpha \approx L_{\abs{U_\alpha}} \cdot M_{\body(\alpha)}\]
where we have defined,
\begin{definition}
Let $\alpha$ be a left spider with end vertices $\square{i}, \square{j}$.
Define $\body(\alpha)$ as the shape whose graph is $\alpha$ with $\square{i}$ and $\square{j}$ deleted and with $U_{\body(\alpha)} = U_\alpha \cup \{\circle{u}\} \setminus \{\square{i},\square{j}\}$, $V_{\body(\alpha)} = V_\alpha$. The definition is analogous for right spiders.
\end{definition}
Due to~\cref{lem:completed-left-side}, the right-hand side of the approximation is in the null space of ${\mathcal M}$. We now formalize this approximate factorization.
\begin{definition}
Let $\alpha$ be a spider with end vertices $\square{i}, \square{j}$. Define $\widetilde{{\mathcal I}}_{\alpha}$ to be the set of shapes that can be obtained from $\alpha$ by performing at least one of the following steps:
\begin{itemize}
\item Improperly collapse $\square{i}$ with a square vertex in $\alpha$
\item Improperly collapse $\square{j}$ with a square vertex in $\alpha$
\end{itemize}
Let ${\mathcal I}_\alpha$ be the set of proper shapes that can be obtained via the same process but using proper collapses.
\end{definition}
In the above definition, we allow $\square{i}, \square{j}$ to collapse with two distinct squares, or to collapse together, or to both collapse with a common third vertex. For technical reasons we need to work with a refinement of ${\mathcal I}_\alpha$ into two sets of shapes and use tighter bounds on coefficients of one set.
\begin{definition}
Let ${\mathcal I}_{\alpha}^{(1)}$ be the set of shapes that can be obtained from $\alpha$ by performing at least one of the following steps:
\begin{itemize}
\item Collapse $\square{i}$ with a square vertex in $\body(\alpha) \setminus U_\alpha$
\item Collapse $\square{j}$ with a square vertex in $\body(\alpha) \setminus U_\alpha$ (distinct from $\square{i}$'s collapse if it happened)
\end{itemize}
Let ${\mathcal I}_\alpha^{(2)}:= {\mathcal I}_\alpha \setminus {\mathcal I}_\alpha^{(1)}$
and define the improper versions $\widetilde{{\mathcal I}}_\alpha^{(1)}, \widetilde{{\mathcal I}}_\alpha^{(2)}$ analogously.
\end{definition}
\begin{lemma}\label{lem:improper-collapse}
Let $\alpha$ be a left spider with end vertices \square{i}, \square{j}. There are coefficients $c_\beta$ for $\beta \in \widetilde{{\mathcal I}}_\alpha$ such that
\[L_{\abs{U_\alpha}} \cdot M_{\body(\alpha)} = 2M_{\alpha} + \sum_{\beta \in \widetilde{{\mathcal I}}_\alpha}c_\beta M_\beta,\]
\[\abs{c_\beta} \leq
\begin{cases}
40\abs{V(\alpha)}^3 & \beta \in \widetilde{{\mathcal I}}_\alpha^{(1)}\\
\frac{40\abs{V(\alpha)}^3}{n} & \beta \in \widetilde{{\mathcal I}}_\alpha^{(2)}
\end{cases}.\]
\end{lemma}
\begin{proof}
First, we can check that the coefficient of $M_\alpha$ is 2. Only the $\ell_k$ term of $L_k$ has the full number of squares, and it has a factor of 2 in $L_k$.
The shapes in $\widetilde{{\mathcal I}}_\alpha$ are definitionally the intersection
terms that appear in this graph matrix product, and furthermore the shapes in
$\widetilde{{\mathcal I}}_\alpha$ are definitionally the intersection terms for the $\ell_k$ term.
Using~\cref{prop:graph-matrix-multiplication}, for each of the five shapes
in $L_{\abs{U_\alpha}}$ the coefficient it contributes is bounded by
$4\abs{V(\alpha)}^3$. The coefficient on $\ell_k$ is 2, so the coefficients
for $\widetilde{{\mathcal I}}_\alpha^{(1)}$ are at most $8 \abs{V(\alpha)}^3$. The
maximum coefficient of the other four shapes in $L_{\abs{U_\alpha}}$ is
$\frac{2}{n}$, so their total contribution to coefficients on
$\widetilde{{\mathcal I}}_\alpha^{(2)}$ is at most $\frac{32\abs{V(\alpha)}^3}{n}$.
\end{proof}
We now want to turn our improper shapes into proper ones from ${\mathcal I}_\alpha$. Unfortunately it is not quite true that to expand an improper shape, one can just expand each edge individually
(though this is true for improper ribbons).
There is an additional difficulty that arises due to ribbon symmetries. To see the difficulty, consider the example given in \cref{fig:ribbon-symmetry} below.
\begin{figure}[!ht]
\centering
\begin{tikzpicture}[scale=0.5,every node/.style={scale=0.5}]
\draw (-6.5,1.5) rectangle node {\huge $u_1$} (-5,0);
\draw (5,1.5) rectangle node {\huge $v_2$} (6.5,0);
\draw (0,2.5) ellipse (1 and 1) node {\huge $w_1$};
\draw (0,-1) ellipse (1 and 1) node {\huge $w_2$};
\node (v1) at (-5,0.75) {};
\node (v3) at (1,2.5) {};
\node (v2) at (-1,2.5) {};
\node (v4) at (1,-1) {};
\draw (-7,2) rectangle (-4.5,-0.5);
\node at (-5.5,-1.5) {\huge $U_{\alpha}$};
\draw (4.5,2) rectangle (7,-0.5);
\node at (6,-1.5) {\huge $V_{\alpha}$};
\node (v6) at (-1,-1) {};
\node (v5) at (4.95,0.75) {};
\draw (v3);
\draw plot[smooth, tension=.7] coordinates {(v3) (v5)};
\draw plot[smooth, tension=.7] coordinates {(v5) (v4)};
\draw plot[smooth, tension=.7] coordinates {(v1) (v6)};
\draw plot[smooth, tension=.7] coordinates {(v1) (-3,2.5) (v2)};
\draw plot[smooth, tension=.7] coordinates {(v1) (-2.5,1) (v2)};
\node at (-3.5,3) {\Large $1$};
\node at (-2,0.5) {\Large $1$};
\node at (-3,-0.5) {\Large $2$};
\node at (3,2) {\Large $2$};
\node at (3,-0.5) {\Large $2$};
\draw (12.5,-3.5) rectangle node {\huge $u_1$} (14,-5);
\draw (24,-3.5) rectangle node {\huge $v_2$} (25.5,-5);
\draw (19,-2.5) ellipse (1 and 1) node {\huge $w_1$};
\draw (19,-6) ellipse (1 and 1) node {\huge $w_2$};
\node (v11) at (14,-4.25) {};
\node (v13) at (20,-2.5) {};
\node (v12) at (18,-2.5) {};
\node (v14) at (20,-6) {};
\draw (12,-3) rectangle (14.5,-5.5);
\node at (13.5,-6.5) {\huge $U_{\gamma_2}$};
\draw (23.5,-3) rectangle (26,-5.5);
\node at (25,-6.5) {\huge $V_{\gamma_2}$};
\node (v16) at (18,-6) {};
\node (v15) at (23.95,-4.25) {};
\draw (v13);
\draw plot[smooth, tension=.7] coordinates {(v13) (v15)};
\draw plot[smooth, tension=.7] coordinates {(v15) (v14)};
\draw plot[smooth, tension=.7] coordinates {(v11) (v16)};
\node at (16,5.5) {\Large $2$};
\node at (16,-5.5) {\Large $2$};
\node at (22,-3) {\Large $2$};
\node at (22,-5.5) {\Large $2$};
\draw (12.5,5) rectangle node {\huge $u_1$} (14,3.5);
\draw (24,5) rectangle node {\huge $v_2$} (25.5,3.5);
\draw (19,6) ellipse (1 and 1) node {\huge $w_1$};
\draw (19,2.5) ellipse (1 and 1) node {\huge $w_2$};
\node (v11) at (14,4.25) {};
\node (v13) at (20,6) {};
\node (v12) at (18,6) {};
\node (v14) at (20,2.5) {};
\draw (12,5.5) rectangle (14.5,3);
\node at (13.5,2) {\huge $U_{\gamma_1}$};
\draw (23.5,5.5) rectangle (26,3);
\node at (25,2) {\huge $V_{\gamma_1}$};
\node (v16) at (18,2.5) {};
\node (v15) at (23.95,4.25) {};
\draw (v13);
\draw plot[smooth, tension=.7] coordinates {(v13) (v15)};
\draw plot[smooth, tension=.7] coordinates {(v15) (v14)};
\draw plot[smooth, tension=.7] coordinates {(v11) (v16)};
\node at (16,3) {\Large $2$};
\node at (22,5.5) {\Large $2$};
\node at (22,3) {\Large $2$};
\draw plot[smooth, tension=.7] coordinates {(v11)};
\draw plot[smooth, tension=.7] coordinates {(v11) (v12)};
\node at (8.5,0.5) {\Huge $=$};
\node at (19,0) {\Huge $+$};
\node at (10.5,4) {\Huge \bf $2 \times$};
\end{tikzpicture}
\caption{A surprising equality of graph matrices.}
\label{fig:ribbon-symmetry}
\end{figure}
One would expect both coefficients on the right shapes to be 1 since $h_1(z)^2 = h_2(z) + h_0(z)$. However, in the left shape, the two circles are distinguishable, hence summing over all ribbons includes one with $w_1 = i, w_2 = j$ and a second with $w_1 = j, w_2 = i$. On the top right shape, the circles are indistinguishable, hence the graph/ribbon where the circles are assigned $\{i, j\}$ is counted twice. On the bottom right shape, the circles are distinguishable, so all ribbons are summed once. To bound the new coefficients, we use the concept of shape automorphisms.
\begin{definition}
An automorphism of a shape $\alpha$ is a function $\varphi:V(\alpha) \rightarrow V(\alpha)$ that preserves the sets $U_\alpha, V_\alpha$ and is an automorphism of the underlying edge-labeled graph. Let $\aut(\alpha)$ denote the automorphism group of $\alpha$.
\end{definition}
\begin{proposition}\label{prop:expand-improper}
Let $\alpha$ be an improper shape, and let ${\mathcal P}$ be the set of proper shapes that can be obtained by expanding $\alpha$. Then there are coefficients $\abs{c_\gamma} \leq C_{Fourier}\cdot C_{Aut}$ such that
\[M_\alpha = \displaystyle\sum_{\gamma \in {\mathcal P}} c_\gamma M_\gamma\]
where $C_{Fourier}$ is a bound on the magnitude of Fourier coefficients in the expansion and $C_{Aut} = \max_{\gamma \in {\mathcal P}} \frac{\abs{\aut(\gamma)}}{\abs{\aut(\alpha)}}$.
\end{proposition}
\begin{proof}
The number of realizations of a graph matrix giving a particular ribbon is exactly the number of automorphisms, therefore
\begin{align*}
M_\alpha &= \frac{1}{\abs{\aut(\alpha)}}\displaystyle\sum_{\text{realizations }\sigma} M_{\sigma(\alpha)}
\end{align*}
Expand each improper ribbon $M_{\sigma(\alpha)}$ into proper ribbons with coefficients at most $C_{Fourier}$.
Because the realizations of $\alpha$ and any $\gamma$ are the same, this exactly sums over all $\gamma$ and all realizations of $\gamma$. The
Fourier coefficient on each realization of $\gamma$ is the same; let it be
$c_\gamma'$ with $\abs{c_\gamma'} \leq C_{Fourier}$. Continuing,
\begin{align*}
&= \displaystyle\frac{1}{\abs{\aut(\alpha)}} \sum_{\gamma \in {\mathcal P}} c_\gamma'\sum_{\text{realizations }\sigma} M_{\sigma(\gamma)}\\
&= \sum_{\gamma \in {\mathcal P}} c_\gamma' \frac{\abs{\aut(\gamma)}}{\abs{\aut(\alpha)}} M_{\gamma}
\end{align*}
\end{proof}
\begin{proposition}\label{prop:hermite-product-coefficients}
Let $l_1 \leq \cdots \leq l_k \in {\mathbb{N}}$ and let $L = l_1 + \cdots + l_k$. Assume $L \ge 1$. In the Fourier expansion of $h_{l_1}(z)\cdots h_{l_k}(z)$, the maximum coefficient is bounded in magnitude by $(2L)^{L-l_k}$.
\begin{proof}
In the boolean case, the coefficient is 1. In the Gaussian case, the ``linearization coefficient'' of $h_p(z)$ in this product is given by orthogonality to be
\[\frac{{\mathbb E}_{z \sim {\mathcal N}(0,1)}[h_{l_1}(z) \cdots h_{l_k}(z) \cdot h_p(z)]}{{\mathbb E}_{z \sim {\mathcal N}(0,1)}[h_p^2(z)]} = \frac{{\mathbb E}_{z \sim {\mathcal N}(0,1)}[h_{l_1}(z) \cdots h_{l_k}(z) \cdot h_p(z)]}{p!}\]
A formula from, e.g.,~\cite[Example G (Continued)]{RotaWallstrom97} shows that ${\mathbb E}[h_{l_1} \cdots h_{l_k} \cdot h_p]$ equals the number of ``block perfect matchings'': perfect matchings on $l_1 + \cdots + l_k + p$ elements
divided into blocks of size $l_i$ or $p$ such that no two elements from the same block are matched. Bound the number of block perfect matchings by:
\begin{itemize}
\item Pick a partial function from blocks $l_1, \dots, l_{k-1}$ to $[L]$ in at most $(L+1)^{L-l_k}$ ways.
\item If this forms a valid partial matching and there are $p$ unmatched elements remaining, match them with the elements from the block of size $p$ in $p!$ ways.
\end{itemize}
Therefore the coefficient is bounded by $(L+1)^{L - l_k} \leq (2L)^{L-l_k}$.
\end{proof}
\end{proposition}
\begin{proposition}\label{prop:automorphism-ratio}
For a shape $\alpha$, let $\alpha\pm e$ denote the shape with edge $e$ added or deleted.
Then
\[ \frac{\abs{\aut(\alpha \pm e)}}{\abs{\aut(\alpha)}}~\leq~\abs{V(\alpha)}^2.\]
\end{proposition}
\begin{proof}
We show that the two groups have a large subgroup which are equal. Consider $\aut(\alpha\pm e)$ and $\aut(\alpha)$ as group actions on the set $\binom{V(\alpha)}{2}$. Letting $G^e$ denote the stabilizer of edge $e$, observe that $\aut(\alpha\pm e)^e = \aut(\alpha)^e$. By the orbit-stabilizer lemma, the index $\abs{G : G^e}$ is equal to the size of the orbit of $e$, which is at least 1 and at most $\abs{V(\alpha)}^2$. So,
\[\frac{\abs{\aut(\alpha \pm e)}}{\abs{\aut(\alpha)}} = \frac{\abs{\aut(\alpha \pm e) : \aut(\alpha \pm e)^e}}{\abs{\aut(\alpha) : \aut(\alpha)^e}} \leq \abs{V(\alpha)}^2.\qedhere \]
\end{proof}
\begin{lemma}\label{lem:collapse-lemma}
If $\alpha$ is a left spider, there are coefficients ${c_\beta}$ for each $\beta \in {\mathcal I}_\alpha$ such that
\[L_{\abs{U_\alpha}} \cdot M_{\body(\alpha)} = 2M_{\alpha} + \sum_{\beta \in {{\mathcal I}}_\alpha}c_\beta M_\beta,\]
\[\abs{c_\beta} \leq
\begin{cases}
160\abs{V(\alpha)}^7\abs{E(\alpha)}^2 & \beta \in {{\mathcal I}}_\alpha^{(1)}\\
\frac{160\abs{V(\alpha)}^7\abs{E(\alpha)}^2}{n} & \beta \in {{\mathcal I}}_\alpha^{(2)}
\end{cases}.\]
\end{lemma}
\begin{proof}
We express each $M_\beta, \beta \in \widetilde{{\mathcal I}}_\alpha$ in~\cref{lem:improper-collapse} in terms of proper shapes. We apply~\cref{prop:expand-improper} using the following bounds on $C_{Fourier}$ and $C_{Aut}$. The only improperness in $\beta$ comes from
collapsing (at most) the two end vertices, which have a single incident
edge each. Therefore the set of labels of any parallel edges is either
$\{1,k\}$ or $\set{1,1,k},$ for some $k \leq \abs{E(\alpha)}$. By~\cref{prop:hermite-product-coefficients}, we have $C_{Fourier} \leq 4\abs{E(\alpha)}^2$. There are at most two extra parallel edges in $\beta$, so we have $C_{Aut} \leq \abs{V(\alpha)}^4$ using~\cref{prop:automorphism-ratio}. Therefore the coefficients increase by at most $C_{Fourier}\cdot C_{Aut} \leq 4\abs{E(\alpha)}^2\abs{V(\alpha)}^4$.
\end{proof}
\begin{corollary}\label{cor:right-spider-coefs}
If $\alpha$ is a right spider, there are coefficients $c_\beta$ with the same bounds given in~\cref{lem:collapse-lemma} such that
\[M_{\body(\alpha)} \cdot L_{\abs{U_\alpha}}^\intercal = 2M_{\alpha} + \sum_{\beta \in {{\mathcal I}}_\alpha}c_\beta M_\beta.\]
\end{corollary}
\begin{corollary}\label{cor:spider-killing}
If $x \perp \nullspace({\mathcal M}_{fix})$ and $\alpha$ is a spider, then for some $c_\beta$ with the same bounds given in~\cref{lem:collapse-lemma},
\[x^\top(M_\alpha - \displaystyle\sum_{\beta \in {\mathcal I}_\alpha} c_\beta M_\beta) x = 0 \]
\end{corollary}
\begin{proof}
For a left spider, since
\[{\mathcal M}_{fix} (2M_\alpha + \displaystyle\sum_{\beta \in {\mathcal I}_\alpha} c_\beta M_\beta) = {\mathcal M}_{fix} \cdot L_{\abs{U_\alpha}} \cdot M_{\alpha'} = 0\]
we are in position to use~\cref{fact:null-space}. For a right spider, the proof is analogous.
\end{proof}
\subsection{Killing all the spiders}
The strategy is to start with the moment matrix ${\mathcal M}$ and apply~\cref{cor:spider-killing} repeatedly until we end up with no spiders in our decomposition. For each spider, killing it via~\cref{cor:spider-killing} leaves only intersection terms. Some of those intersection terms may themselves be smaller spiders, in which case we will apply the corollary again and again until only non-spiders remain. The difficulty during this procedure is to bound the total coefficient accumulated on each non-spider. To capture this process, we define the web of a spider $\alpha$, which will be a directed acyclic graph that will capture the spider killing process. For the sake of distinction, we will call the vertices of this graph ``nodes".
\begin{definition}[Web of $\alpha$]
The web $W(\alpha)$ of a spider $\alpha$ is a rooted directed acyclic graph
(DAG) whose nodes are shapes and whose root is $\alpha$. Each spider node
$\gamma$ has edges to nodes $\beta$ for each shape $\beta \in
{\mathcal I}_{\gamma}$.
The non-spider nodes are leaves/sinks of the DAG.
\end{definition}
\begin{remark}
The DAG structure arises because each shape in ${\mathcal I}_\gamma$ has strictly fewer square vertices than $\gamma$ for any spider $\gamma$. As a consequence, the height of a web $W(\alpha)$ is at most $\abs{V(\alpha)}$.
\end{remark}
Each node $\gamma$ of $W(\alpha)$ also has an associated value $v_\gamma$, which is defined by the following process:
\begin{itemize}
\item Initially, set $v_\alpha = 1$ and for all other $\gamma$, set $v_\gamma = 0$.
\item Starting from the root and in topological order, each spider node $\gamma$ adds $v_{\gamma} c_\beta$ to $v_\beta$ for each child $\beta \in {\mathcal I}_{\gamma}$, where the $c_\beta$ are the coefficients from~\cref{cor:spider-killing}.
\end{itemize}
\begin{proposition}\label{prop:web-sum}
If $x \perp \nullspace({\mathcal M}_{fix})$, then
\[\displaystyle x^\intercal(M_\alpha - \sum_{\text{leaves } \gamma\text{ of }W(\alpha)} v_\gamma M_\gamma)x = 0.\]
\end{proposition}
\begin{proof}
Start with the equation $x^\intercal M_{\alpha} x = x^\intercal
v_{\alpha}M_{\alpha} x$. In each step, we take the topologically first spider $\gamma$, which in this case means the spider closest to the root of $W(\alpha)$, that is present in the right hand side of our equation and using \cref{cor:spider-killing}, we
replace $v_{\gamma}M_{\gamma}$ by $\sum_{\beta \in
\text{children}(\gamma)} v_\gamma c_\beta M_\beta$.
Precisely by the definition of the $v_{\gamma}$, this
process ends with the equation
\[\displaystyle x^\intercal M_\alpha x = x^\intercal(\sum_{\text{leaves } \gamma\text{ of }W(\alpha)} v_\gamma M_\gamma)x\]
\end{proof}
\begin{proposition}\label{prop:web-parents}
For any node $\beta$ in $W(\alpha)$, $\abs{\parents(\beta)} \leq 4\abs{V(\alpha)}^3 \cdot \abs{E(\alpha)}^2$ where $parents(\beta)$ is the set of nodes $\gamma$ in $W(\alpha)$ such that $\beta \in {\mathcal I}_{\gamma}$.
\end{proposition}
\begin{proof}
The following process covers all parent left spiders $\gamma$ which could possibly collapse their end vertices to form $\beta$. Starting from $\gamma = \beta,$
\begin{itemize}
\item Pick a circle vertex $\circle{u} \in V(\gamma)$ to be the neighbor of the end vertices.
\item Pick a square vertex $\square{i} \in V(\gamma)$ to be the collapse of the first end vertex. ``Uncollapse'' it by adding a new square to $U_{\gamma}$ with a single edge to $\circle{u}$ with label $1$. Flip the value of $U_{\gamma}(\square{i})$. Modify the label of $\{\square{i}, \circle{u}\}$ to any number up to $\abs{E(\alpha)}$.
\item Pick a square vertex $\square{j} \in V(\gamma)$ to be the second end vertex. Optionally uncollapse it by adding a new square to $\gamma$ in the same way as above.
\end{itemize}
The process can be carried out in at most $\abs{V(\alpha)}^3\abs{E(\alpha)}(\abs{E(\alpha)}+1) \leq 2\abs{V(\alpha)}^3\abs{E(\alpha)}^2$ ways. We multiply by 2 to accommodate right spiders.
\end{proof}
Let us label each parent-child edge $(\gamma, \beta$) as either a ``type 1'' edge if $\beta \in {\mathcal I}_{\gamma}^{(1)}$ or a ``type 2'' edge if $\beta \in {\mathcal I}_{\gamma}^{(2)}$.
\begin{proposition}\label{prop:web-derivation-number}
Let $p$ be a path in $W(\alpha)$ with $\#_1(p)$ type 1 edges and $\#_2(p)$ type 2 edges. Then $\#_1(p)~\leq~\abs{E(\alpha)}~+~2\#_2(p)$.
\end{proposition}
\begin{proof}
For a shape $\gamma$, let $S_{\gamma}$ be the set of square vertices in $\gamma$. Then, $S_{\gamma} \cap W_{\gamma}$ will be the set of middle vertices of $\gamma$ which are squares.
We claim that the quantity $\abs{{\mathcal S}_\gamma \cap W_\gamma} + \abs{U_\gamma
\setminus (U_\gamma \cap V_\gamma)} + \abs{V_\gamma \setminus
(U_\gamma \cap V_\gamma)}$ decreases during a collapse.
Fix a pair of consecutive shapes $(\gamma, \beta)$ which form a type
1 edge. Looking at the definition of ${\mathcal I}_\gamma^{(1)}$, each end vertex either
collapses with (1) nothing, or (2) a vertex of $W_\gamma$, or (3) a vertex from
$V_\gamma \setminus U_\gamma$ (if $\gamma$ is a left spider;
for a right spider, $U_\gamma \setminus V_\gamma$).
Furthermore, case (2) or (3) must occur for at least one of the end vertices and also, they do not collapse together.
If case (2) occurs, then $\abs{{\mathcal S}_\beta \cap W_\beta} < \abs{{\mathcal S}_\gamma \cap W_\gamma}$ while $\abs{U_\beta
\setminus (U_\beta \cap V_\beta)} = \abs{U_\gamma \setminus (U_\gamma \cap
V_\gamma)}$ and $\abs{V_\beta \setminus
(U_\beta \cap V_\beta)} = \abs{V_\gamma \setminus
(U_\gamma \cap V_\gamma)}$.
On the other hand, if case (3) occurs, then $W_\beta = W_\gamma$ while
$\abs{U_\beta \setminus(U_\beta \cap V_\beta)}<\abs{U_\gamma
\setminus(U_\gamma \cap V_\gamma)}$ and $\abs{V_\beta \setminus(U_\beta \cap V_\beta)}<\abs{V_\gamma
\setminus(U_\gamma \cap V_\gamma)}$.
In all cases, $\abs{{\mathcal S}_\beta \cap W_\beta} + \abs{U_\beta
\setminus (U_\beta \cap V_\beta)} + \abs{V_\beta \setminus
(U_\beta \cap V_\beta)} < \abs{{\mathcal S}_\gamma \cap W_\gamma} + \abs{U_\gamma
\setminus (U_\gamma \cap V_\gamma)} + \abs{V_\gamma \setminus
(U_\gamma \cap V_\gamma)}$ as desired.
Now we bound this expression for $\alpha$. From the definition of ${\mathcal L}$, \cref{def:calL_valid_shapes},
for spiders appearing in the pseudocalibration,
the square vertices in $W_{\alpha}$, $U_\alpha \setminus (U_\alpha \cap
V_\alpha)$ and $V_\alpha \setminus (U_\alpha \cap
V_\alpha)$ have degree at least $1$ and can only be connected to circle vertices.
Therefore their number is bounded by $\abs{E(\alpha)}$. Hence, initially
$\abs{{\mathcal S}_\alpha \cap W_\alpha} + \abs{U_\alpha \setminus (U_\alpha \cap V_\alpha)} + \abs{V_\alpha \setminus (U_\alpha \cap V_\alpha)} \leq \abs{E(\alpha)}$.
Finally, each type 2 edge in $p$ can only increase the quantity $\abs{{\mathcal S}_\gamma \cap W_\gamma} + \abs{U_\gamma \setminus (U_\gamma \cap V_\gamma)} + \abs{V_\gamma \setminus (U_\gamma \cap V_\gamma)}$
by at most 2. Therefore, we have the desired inequality $\#_1(p) \leq \abs{E(\alpha)} + 2\#_2(p)$.
\end{proof}
\begin{corollary}\label{cor:web-derivation-number}
$\#_2(p) \geq \frac{\abs{p}}{3} - \frac{\abs{E(\alpha)}}{3}$.
\end{corollary}
\begin{proof}
Plug in $\abs{p} = \#_1(p) + \#_2(p)$ and rearrange.
\end{proof}
Finally, we can bound the accumulation on each non-spider by a term which only depends on the parameters of the spider $\alpha$.
\begin{lemma}\label{lem:web-leaves}
There are absolute constants $C_1, C_2$ so that for all leaves $\gamma$ of $W(\alpha)$,
\[ \abs{v_\gamma} \leq (C_1 \cdot \abs{V(\alpha)} \cdot \abs{E(\alpha)})^{C_2 \abs{E(\alpha)}}.\]
\end{lemma}
\begin{proof}
To bound $\abs{v_\gamma}$ we will sum the contributions of all paths $p = (\beta_0=\alpha,\dots,\beta_r=\gamma)$ in $W(\alpha)$
starting from $\alpha$ and ending at $\gamma$. This path contributes a product of coefficients $c_\beta$ towards $v_\gamma$.
\begin{remark}
Here it is important that type 2 edges have stronger bounds on their coefficients $\abs{c_\beta} \leq C\cdot (\abs{V(\alpha)}\abs{E(\alpha)})^{O(1)}/n \ll 1$.
\end{remark}
Before we proceed with the proof we establish some convenient notation and recall some facts.
%
For consecutive shapes $\beta_{i-1},\beta_{i}$ (i.e.,\xspace $\beta_{i}$ is a child of $\beta_{i-1}$),
we denote by $c_{\beta_i}$ the coefficient from~\cref{cor:spider-killing} applied on $\beta_{i - 1}$.
%
By~\cref{prop:web-parents}, the in-degree of $W(\alpha)$ can be bounded as $B_1~\cdot~(\abs{V(\alpha)}\abs{E(\alpha)})^{B_2}$ for some constants $B_1, B_2$. Thus,
the number of paths of length $r$ ending at $\gamma$ is at most $(B_1\abs{V(\alpha)}\abs{E(\alpha)})^{B_2 r}$. Using \cref{cor:spider-killing}, set $B_1, B_2$ large enough so that $c_{\beta_i}$ is at most $B_1 \cdot (\abs{V(\alpha)}\abs{E(\alpha)})^{B_2}$ for a type $1$ edge (resp. $B_1 \cdot (\abs{V(\alpha)}\abs{E(\alpha)})^{B_2} / n$ for a type $2$ edge).
{\footnotesize
\begin{align*}
\abs{v_\gamma} &\le \sum_{r=0}^\infty \sum_{\substack{p = (\beta_0=\alpha,\dots,\beta_r=\gamma) \\ \textup{path from $\alpha$ to $\gamma$ in } W(\alpha)}} \prod_{i=1}^r \abs{c_{\beta_i}}\\
&\le \sum_{r=0}^\infty\sum_{\substack{p = (\beta_0=\alpha,\dots,\beta_r=\gamma) \\ \textup{path from $\alpha$ to $\gamma$ in } W(\alpha)}} \left(B_1 \cdot (\abs{V(\alpha)}\abs{E(\alpha)})^{B_2} \right)^{\#_1(p)} \left(B_1 \cdot (\abs{V(\alpha)}\abs{E(\alpha)})^{B_2}/n \right)^{\#_2(p)} \\
&\le \sum_{r=0}^\infty\sum_{\substack{p = (\beta_0=\alpha,\dots,\beta_r=\gamma) \\ \textup{path from $\alpha$ to $\gamma$ in } W(\alpha)}} \left(B_1 \cdot (\abs{V(\alpha)}\abs{E(\alpha)})^{B_2} \right)^{\abs{E(\alpha)} + 2\#_2(p)} \left(B_1 \cdot (\abs{V(\alpha)}\abs{E(\alpha)})^{B_2}/n \right)^{\#_2(p)} \\
& = \sum_{r=0}^\infty\sum_{\substack{p = (\beta_0=\alpha,\dots,\beta_r=\gamma) \\ \textup{path from $\alpha$ to $\gamma$ in } W(\alpha)}} \left(B_1 \cdot (\abs{V(\alpha)}\abs{E(\alpha)})^{B_2} \right)^{\abs{E(\alpha)}} \left(B_1' \cdot (\abs{V(\alpha)}\abs{E(\alpha)})^{B_2'}/n \right)^{\#_2(p)}
\end{align*}
}
for some constants $B_1', B_2'$
where the first inequality followed by \cref{cor:spider-killing} and the second inequality followed by \cref{prop:web-derivation-number}.
We split the above sum into two sums, $r \le 3|E(\alpha)|$ and $r > 3|E(\alpha)|$. For $r \leq 3\abs{E(\alpha)}$, upper bounding the $\#_2(p)$ term by 1 and upper bounding
the number of paths by $(B_1\abs{V(\alpha)}\abs{E(\alpha)})^{B_2 r}$ gives a
bound of $(B_1''\abs{V(\alpha)}\abs{E(\alpha)})^{B_2'' \abs{E(\alpha)}}$ for some constants $B_1'', B_2''$.
For larger $r$, we lower bound
$\#_2(p) \geq r/9 = \abs{E(\alpha)}/3$ using~\cref{cor:web-derivation-number}. Applying the same bound on the number of paths,
the total contribution of the terms corresponding to larger $r$ is bounded by
1 using the power of $n$ in the denominator (assuming $\delta, \tau$ are
small enough).
\end{proof}
We define the result of all this spider killing to be a new matrix ${\mathcal M}^+$.
\begin{definition}
Define the matrix ${\mathcal M}^+$ as the result of killing all the spiders,
\[{\mathcal M}^+ := {\mathcal M} - \displaystyle\sum_{\text{spiders }\alpha} \lambda_\alpha \left( M_\alpha - \sum_{\text{leaves }\gamma \text{ of }W(\alpha)} v_\gamma M_\gamma \right)\]
\end{definition}
\section{Chapter Notes}
The technical results in this chapter are adapted from \cite{sklowerbounds}, joint work with Mrinalkanti Ghosh, Fernando Granha Jeronimo, Chris Jones and Aaron Potechin.
\input{sherrington_kirkpatrick/open_problems}
\subsection{Norm Bounds}\label{app:norm_bounds}
The precise norm bounds we use come from applying the trace power method
in~\cite{ahn2016graph}, but qualitatively, the bounds from \cref{chap: efron_stein} also work. The paper~\cite{ahn2016graph} uses a slightly different
definition of matrix index. They define a \textit{matrix index piece}
as a tuple of distinct elements from either ${\mathcal C}_m$ or ${\mathcal S}_n$
along with a fixed integer denoting multiplicity. A matrix index is
then a set of matrix index pieces. Our graph matrix $M_\alpha$ appears
as a submatrix of those matrices: for a given set of square vertices,
order the squares in increasing order in a tuple, and assign it
multiplicity 1. Hence the same norm bounds apply.
Boolean norm bounds:
\begin{lemma}\label{lem:norm-bounds}
Let $V_{rel}(\alpha) := V(\alpha) \setminus (U_\alpha \cap V_\alpha)$. There is a universal constant $C$ such that the following norm bound holds for all proper shapes $\alpha$ w.h.p.:
\[\norm{M_\alpha} \leq 2\cdot\left(\abs{V(\alpha)} \cdot \log(n)\right)^{C\cdot \abs{V_{rel}(\alpha)}} \cdot n^{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}} \]
\end{lemma}
\begin{proof}
From Corollary 8.13 of~\cite{ahn2016graph}, with probability at least $1-\varepsilon$ for a fixed shape $\alpha$,
\[\norm{M_\alpha} \leq 2 \abs{V(\alpha)}^{\abs{V_{rel}(\alpha)}}\cdot \left( 6e \ceil{\frac{\log\left(\frac{n^{w(S_{\min})}}{\varepsilon}\right)}{6\abs{V_{rel}(\alpha)}}}\right)^{\abs{V_{rel}(\alpha)}} \cdot n^{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}}\]
Letting $N_k$ be the number of distinct shapes on $k$ vertices (either
circles or squares), we apply the corollary with $\varepsilon = 1/(mn
N_{\abs{V(\alpha)}})$. Union bounding, the failure probability across
all shapes of size $k$ is at most $1/mn$, and since the number of
vertices in a shape is at most $m + n \leq 2m$, we have a bound that
holds with high probability for all shapes. It remains to simplify the
exact bound.
\begin{proposition}\label{prop:boolean-shape-counting}
$N_k \leq 8^k 2^{k^2}$
\begin{proof}
The following process forms all shapes on $k$ vertices: starting from $k$ formal variables, assign each variable to be either a circle or a square, decide whether each variable is in $U_\alpha$ and/or $V_\alpha$, then among the $k^2$ variable pairs put any number of edges.
\end{proof}
\end{proposition}
We also bound $n^{w(S_{\min})} \leq (mn)^{\abs{V(\alpha)}}$.
{\footnotesize
\begin{align*}
\norm{M_\alpha} & \leq 2 \abs{V(\alpha)}^{\abs{V_{rel}(\alpha)}}\cdot \left( 6e \ceil{\frac{\log\left(n^{w(S_{\min})} \cdot mn N_{\abs{V(\alpha)}}\right)}{6\abs{V_{rel}(\alpha)}}}\right)^{\abs{V_{rel}(\alpha)}} \cdot n^{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}} \\
& \leq 2 \abs{V(\alpha)}^{\abs{V_{rel}(\alpha)}}\cdot \left( 12e \log\left(n^{w(S_{\min})} \cdot mn N_{\abs{V(\alpha)}}\right)\right)^{\abs{V_{rel}(\alpha)}} \cdot n^{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}} \\
& \leq 2 \abs{V(\alpha)}^{\abs{V_{rel}(\alpha)}}\cdot \left( 12e \log\left((mn)^{\abs{V(\alpha)}} \cdot mn\cdot 8^{\abs{V(\alpha)}} 2^{\abs{V(\alpha)}^2}\right)\right)^{\abs{V_{rel}(\alpha)}} \cdot n^{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}}\\
& \leq 2 \abs{V(\alpha)}^{\abs{V_{rel}(\alpha)}}\cdot \left( 100e \abs{V(\alpha)}^2 \log\left(mn\right)\right)^{\abs{V_{rel}(\alpha)}} \cdot n^{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}}\\
& \leq 2\cdot\left(\abs{V(\alpha)} \cdot \log(mn)\right)^{3\cdot \abs{V_{rel}(\alpha)}} \cdot n^{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}}
\end{align*}
}%
Note that we now assume $m \leq n^2$.
\end{proof}
We have the following norm bound for Hermite shapes. For a Hermite shape $\alpha$, define the \textit{total size} to be $\abs{U_\alpha} + \abs{V_\alpha} + \abs{W_\alpha} + \abs{E(\alpha)}$.
\begin{lemma}\label{lem:gaussian-norm-bounds}
Let $V_{rel}(\alpha) := V(\alpha) \setminus (U_\alpha \cap V_\alpha)$ as sets. There is a universal constant $C$ such that the following norm bound holds for all proper shapes $\alpha$ with total size at most $n$ w.h.p.:
\[ \norm{M_\alpha} \leq 2\cdot\left(\abs{V(\alpha)} \cdot (1+\abs{E(\alpha)}) \cdot \log(n)\right)^{C\cdot (\abs{V_{rel}(\alpha)} + \abs{E(\alpha)})} \cdot n^{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}}\]
\end{lemma}
The proof performs the same calculation starting from~\cite[Corollary 8.15]{ahn2016graph}. Note that in our notation, $l(\alpha) = \abs{E(\alpha)}$. There is a further difference which is that~\cite{ahn2016graph} uses normalized Hermite polynomials whereas we use unnormalized Hermite polynomials; this contributes the additional term $\prod_{e \in E(\alpha)} l(e)! \leq (1+\abs{E(\alpha)})^{\abs{E(\alpha)}}$. We must replace Proposition~\ref{prop:boolean-shape-counting} with the following:
\begin{proposition}\label{prop:gaussian-shape-counting}
The number of Hermite shapes with total size $k$ is at most $k2^k(k+1)^{2k+k^2}$.
\begin{proof}
Such a shape has at most $k$ distinct variable vertices. Each of these is either a circle or a square. Each variable can be in $U_\alpha$ with multiplicity between 0 and (at most) $k$, and also in $V_\alpha$ with multiplicity between 0 and $k$. The $k^2$ possible pairs of vertices can have edge multiplicity in $E(\alpha)$ between 0 and $k$.
\end{proof}
\end{proposition}
\section{Satisfying the Constraints Exactly}
\label{sec:exact-constraints}
After pseudocalibration, the PAP constraints ``$\ip{v}{d_u}^2 = 1$'' are not exactly
satisfied by the pseudocalibration,
but they are satisfied up to truncation error $\tilde{\EE}[\ip{v}{d_u}^2 -1] = n^{-\Omega(n^\tau)}$. This is enough to produce a Sherrington-Kirkpatrick solution that is \textit{almost} boolean, meaning $\tilde{\EE}[x_i^2] = 1 \pm n^{-\Omega(n^\tau)}$ where the pseudocalibration is truncated to degree $n^\tau$. To satisfy the constraints exactly, and produce an SK solution which is \textit{exactly} boolean, we can project the pseudocalibration operator. The goal of this section is to prove the following lemma for the PAP problem,
\begin{lemma}\label{lem:pseudoexpectation-rounding}
W.h.p. for the PAP problem there is $\tilde{\EE}' \in {\mathbb R}^{\binom{[n]}{\leq D}}$ such that $\norm{\tilde{\EE} - \tilde{\EE}'}_2 \leq \frac{1}{n^{\Omega(n^\tau)}}$ and $\tilde{\EE}'$ exactly satisfies the constraints ``$\ip{v}{d_u}^2 = 1"$.
\end{lemma}
\begin{remark}
Note that $\tilde{\EE}'$ is syntactically guaranteed to still satisfy the constraints ``$v_i^2 = \frac{1}{n}$".
\end{remark}
\begin{corollary}\label{lem:constraint-fixing}
There is an $\binom{[n]}{\leq D/2} \times \binom{[n]}{\leq D/2}$ matrix ${\mathcal E}$ with $\norm{{\mathcal E}} \leq \frac{1}{n^{\Omega(n^\tau)}}$ such that the matrix $M_{fix}~:=~M~+~{\mathcal E}$ is SoS-symmetric and exactly satisfies the constraints ``$\ip{v}{d_u}^2 = 1$".
\end{corollary}
We view the operators $\tilde{\EE}$ as vectors in ${\mathbb R}^{\binom{[n]}{\leq D}}$. The approach we take is to define a ``check matrix" $Q$ such that $\tilde{\EE}$ satisfies the necessary constraints iff $\tilde{\EE} \in \nullspace(Q)$. When the constraints are functions of $v$ only, the matrix $Q$ would be filled with constants. Since the constraints depend on the inputs $d_u$, the matrix $Q$ is also a function of the $d_u$. This allows us to deconstruct it as a sum of graph matrices -- and in fact it is made out of graph matrices which we have seen already.
\begin{definition}
We let $Q$ be the matrix
\[Q := \displaystyle\sum_{k=2}^{D}L_k^\intercal \]
where the matrices $L_k$ are defined in~\cref{sec:psd}.
\end{definition}
\begin{lemma}
$Q\tilde{\EE} = 0$ iff $\tilde{\EE}$ exactly satisfies the constraints ``$\ip{v}{d_u}^2 = 1$".
\end{lemma}
\begin{proof}
One can see in the proof of~\cref{lem:completed-left-side} that the entries of $Q\tilde{\EE}$ measure exactly the error in the constraints.
\end{proof}
The natural choice of $\tilde{\EE}'$ is therefore the projection of $\tilde{\EE}$ to the nullspace. This is defined by
\[\tilde{\EE}' := \tilde{\EE} - Q^\intercal(QQ^\intercal)^+Q\tilde{\EE} \]
where we take the pseudo-inverse of $QQ^\intercal$ as it will turn out not to be invertible.
To prove~\cref{lem:pseudoexpectation-rounding}, we must decompose the second
term in terms of graph matrices and show it has small norm.
As a warm-up, we end this outline by
showing a simpler projection argument in the Planted Boolean Vector domain is
sufficient if one just wants to satisfy the boolean constraints in the Planted Boolean Vector problem rather than the constraints of the PAP problem.\footnote{Using the translation between the two problems in~\cref{sec:sk}, this would allow us to exactly satisfy ``$\ip{v}{d_u}^2 =1"$ for the PAP problem. Unfortunately, the constraints ``$v_i^2 =\frac{1}{n}$" might be broken.}
Let $\tilde{\EE}_{\text{PBV}}$ be a candidate, not-yet-boolean, degree-$D$ pseudoexpectation operator for the Planted Boolean Vector problem, $D = 2\cdot n^\delta$. $\tilde{\EE}_{\text{PBV}}$ has an entry for each monomial $b^\alpha$, therefore it
is $\multiset{n}{\leq D}$-dimensional. Let $Q_{bool}$ be the ``check
matrix'' for the boolean constraints. $Q_{bool}$ has $n~\cdot~\multiset{n}{\leq D-2}$ rows. The $(i, \alpha)$ row checks $\tilde{\EE}[b^\alpha \cdot b_i^2] = \tilde{\EE}[b^\alpha]$. It has entry 1 in column $\alpha$ and entry $-1$ in column $\alpha \cup \{i, i\}$.
\begin{lemma}
Assume that $\tilde{\EE}_{\text{PBV}}$ approximately satisfies the boolean constraints:
\[\tilde{\EE}_{\text{PBV}} [b^\alpha \cdot (b_i^2 - 1)] \leq n^{-\Omega(n^\tau)}\]
for any $b^\alpha$ with degree at most $D-2$. Then letting $\tilde{\EE}_{\text{PBV}}'$ be the projection to $\nullspace(Q_{bool})$, we have
\[\norm{\tilde{\EE}_{\text{PBV}} - \tilde{\EE}_{\text{PBV}}'}_2 \leq n^{-\Omega(n^\tau)}.\]
\end{lemma}
\begin{proof}
The effect of projecting $\tilde{\EE}$ to $\nullspace(Q_{bool})$ is to symmetrize $\tilde{\EE}[b^{\alpha + 2\beta}]$ across all $\beta$; average all entries $\tilde{\EE}[1], \tilde{\EE}[b_1^2], \tilde{\EE}[b_2^2], \tilde{\EE}[b_1^6b_7^4b_{10}^2]$ etc, average $\tilde{\EE}[b_1], \tilde{\EE}[b_1b_3^2], \tilde{\EE}[b_1b_3^4b_4^4]$ etc, and so on. One can see this because this is a linear map which fixes $\nullspace(Q_{bool})$ and takes all vectors into $\nullspace(Q_{bool})$.
By assumption, there is additive error $n^{-\Omega(n^\tau)}$ between $\tilde{\EE}_{\text{PBV}}[b^\alpha]$ and
$\tilde{\EE}_{\text{PBV}}[b^\alpha \cdot b_i^2]$. As the size of $\beta$ is at most $D \ll n^\tau$, we still easily have $\tilde{\EE}_{\text{PBV}}[b^{\alpha + 2\beta}] = \tilde{\EE}_{\text{PBV}}[b^\alpha] \pm n^{-\Omega(n^\tau)}$ for all $\beta$.
Therefore
averaging these entries changes each of them by at most
$n^{-\Omega(n^\tau)}$. Thus,
\[\norm{\tilde{\EE}_{\text{PBV}} - \tilde{\EE}_{\text{PBV}}'}_2 \leq \multichoose{n}{\leq D} \cdot \norm{\tilde{\EE}_{\text{PBV}} - \tilde{\EE}_{\text{PBV}}'}_\infty\]
\[\leq n^{O(n^{\delta})} \cdot n^{-\Omega(n^\tau)} = n^{-\Omega(n^\tau)}\]
\end{proof}
\subsection{Truncation error in the pseudocalibration}
The constraint ``$\ip{v}{d_u}^2 = 1$'' isn't exactly satisfied, but a general property of pseudocalibration is that it's satisfied up to truncation error, which is small w.h.p. We show a quantitative version of this bound.
We introduce the notation
\[\mu_{I, \alpha} := {\mathbb E}_{\text{pl}} [v^I \chi_{\alpha}(d)] \]
where $\chi_\alpha(d) = h_\alpha(d)$ in the Gaussian case and $\chi_\alpha(d) = d^\alpha$ in the boolean case.
\begin{lemma}\label{lem:boolean-approximate-constraints}
Let $p(d,v)$ such that $p$ is uniformly zero on the planted distribution. Let $\deg_d(p) = D$. For any $I \subseteq [n]$, the only nonzero Fourier coefficients of $\tilde{\EE}[v^I p]$ are those with size between $n^\tau \pm D$.
Furthermore, the nonzero coefficients are bounded in absolute value by
\[ M \cdot L \cdot 2^D e^{mn}\cdot \max_I\max_{\abs{\alpha} \in n^\tau \pm 2D} \abs{\mu_{I, \alpha}} \]
where $M$ is the number of nonzero monomials of $p$ and $L$ is the largest coefficient of $p$ (in absolute value).
\end{lemma}
\begin{proof} We divide the calculations into boolean and Gaussian cases. For each case we compute that Fourier coefficients below the truncation threshold neatly cancel and bound the coefficients at the threshold.
\noindent\textbf{(Boolean case)}
Expand $p(d,v) = \displaystyle\sum_{\abs{J} \leq D} d^J p_J(v)$. By linearity,
\[\tilde{\EE}[v^Ip] = \displaystyle\sum_{\abs{J} \leq D} d^J \tilde{\EE}[v^Ip_J(v)].\]
The $\alpha$-th Fourier coefficient gets a contribution from the $J$-th term equal to the $(\alpha \oplus J)$-th Fourier coefficient of $\tilde{\EE}[v^Ip_J(v)]$. Expand the polynomial $p_J$ in the $J$-th term,
\[ \tilde{\EE}[v^Ip_J(v)] = \sum_{K} c_{J,K} \tilde{\EE}[v^Iv^K]\]
The $(\alpha \oplus J)$-th coefficient of $\tilde{\EE}[v^Iv^K]$ is defined by pseudocalibration to be
\begin{equation}\label{eq:boolean-fourier-cases}
\left\{
\begin{array}{lr}
\mu_{I+K,\alpha\oplus J} & \abs{\alpha \oplus J} \leq n^\tau\\
0 & \abs{\alpha \oplus J} > n^\tau
\end{array}\right.
\end{equation}
For $\abs{\alpha} \leq n^\tau - D$ we are guaranteed to be in the first case. For this case the total $\alpha$-th Fourier coefficient is
\begin{align*}
\displaystyle\sum_{\abs{J} \leq D} \sum_K c_{J,K}\mu_{I+K, \alpha \oplus J} &= \sum_{\abs{J} \leq D} \sum_K c_{J,K}{\mathbb E}_{\text{pl}}[v^{I}v^K d^{J \oplus \alpha}]\\
&= \sum_{\abs{J} \leq D} \sum_K c_{J,K}{\mathbb E}_{\text{pl}}[v^{I}v^K d^\alpha d^{J}]\\
&= {\mathbb E}_{\text{pl}}[v^{I}d^{\alpha}p(d,v)]\\
& = 0.
\end{align*}
For $\abs{\alpha} > n^\tau + D$, we are guaranteed to be in the second case of~\cref{eq:boolean-fourier-cases}, in which case the total Fourier coefficient will also be zero. For $\abs{\alpha}$ within $D$ of the truncation parameter, some terms $J$ will not contribute their coefficients towards cancellation. We bound the Fourier coefficient for these $\alpha$,
\begin{align*}
\abs{\displaystyle\sum_{\substack{J:\abs{J} \leq D,\\ \abs{\alpha \oplus J} \leq n^\tau}} \sum_K c_{J,K}\cdot\mu_{I+K, \alpha \oplus J}} &\leq \displaystyle\sum_{\abs{J} \leq D} \sum_K \abs{c_{J,K}\cdot\mu_{I+K, \alpha \oplus J}}\\
&\leq M \cdot L \cdot \max_{I} \max_{\abs{\alpha} \in n^\tau \pm 2D} \abs{\mu_{I,\alpha}}.
\end{align*}
\noindent\textbf{(Gaussian case)} Expand $p(d, v) = \displaystyle\sum_{\abs{\beta} \leq D}h_\beta(d) p_\beta(v) = \sum_{\abs{\beta} \leq D}h_\beta(d) \sum_K c_{\beta, K} v^K$. The pseudoexpectation is
\begin{align*}
\tilde{\EE}[v^I p(d, v)] &= \displaystyle\sum_{\abs{\beta} \leq D}h_\beta(d) \tilde{\EE}[v^Ip_\beta(v)]\\
&= \sum_{\abs{\beta} \leq D}h_\beta(d) \sum_{K}c_{\beta,K}\tilde{\EE}[v^Iv^K]\\
&= \sum_{\abs{\beta} \leq D}h_\beta(d) \sum_K c_{\beta, K}\sum_{\abs{\alpha} \leq n^\tau} \mu_{I+K, \alpha}\frac{h_\alpha(d)}{\alpha!}.
\end{align*}
Let $l_{\alpha,\beta,\gamma}$ be the coefficient of $h_\gamma$ in the Hermite product $h_\alpha \cdot h_\beta$.
\begin{align*}
\tilde{\EE}[v^I p(d, v)] &= \displaystyle\sum_{\abs{\beta} \leq D} \sum_K c_{\beta, K}\sum_{\abs{\alpha} \leq n^\tau} \mu_{I+K, \alpha}\sum_{\gamma} l_{\alpha,\beta,\gamma}\frac{h_\gamma(d)}{\alpha!}
\end{align*}
In the case $\abs{\gamma} > n^\tau + D$, the coefficient of $h_\gamma(d)$ is zero because the max degree of a Hermite polynomial appearing in $h_{\alpha}\cdot h_{\beta}$ is at most $\abs{\alpha}+\abs{\beta} \leq n^\tau + D$. We show cancellations occur when $\abs{\gamma} \leq n^\tau - D$.
Moving the summations around, the coefficient of $h_\gamma$ is,
\begin{align*}
&\displaystyle\sum_{\abs{\beta} \leq D} \sum_K c_{\beta, K}\sum_{\abs{\alpha} \leq n^\tau} \mu_{I+K, \alpha} \cdot l_{\alpha,\beta,\gamma}\frac{1}{\alpha!}\\
= & \sum_{\abs{\beta} \leq D} \sum_K c_{\beta, K}\sum_{\abs{\alpha} \leq n^\tau} {\mathbb E}_{\text{pl}}[v^Iv^K h_{\alpha}(d)] \cdot l_{\alpha,\beta,\gamma}\frac{1}{\alpha!}\\
= & {\mathbb E}_{\text{pl}}v^I\sum_{\abs{\beta} \leq D} \sum_K c_{\beta, K}v^K\sum_{\abs{\alpha} \leq n^\tau} l_{\alpha,\beta,\gamma}\frac{h_{\alpha}(d) }{\alpha!}.
\end{align*}
We need an explicit formula for $l_{\alpha, \beta, \gamma}$ from~\cite[p.~92]{roman2005umbral},
\begin{proposition}\label{prop:multiply-coefficients}
\[l_{\alpha,\beta,\alpha+\beta - 2\delta} = \displaystyle\prod_{u,i}\binom{\alpha_{ui}}{\delta_{ui}}\binom{\beta_{ui}}{\delta_{ui}} \delta_{ui}! \]
\end{proposition}
\begin{proposition}\label{prop:hermite-product}
\[\sum_{\alpha} l_{\alpha,\beta,\gamma}\frac{h_{\alpha}(d) }{\alpha!} = h_{\beta}(d)\cdot \frac{h_\gamma(d)}{\gamma!}\]
\end{proposition}
\begin{proof}
Compute using~\cref{prop:multiply-coefficients}.
\end{proof}
In~\cref{prop:hermite-product}, the summation is actually finite. The largest $\alpha$ with $l_{\alpha,\beta,\gamma}$ nonzero has $\abs{\alpha}~\leq~\abs{\beta}~+~\abs{\gamma}$. Since we have $\abs{\beta}\leq D$ (the constraint only has degree $D$), as long as $\abs{\gamma} \leq n^\tau - D$, the above equality applies, in which case continuing the calculation for this case,
\begin{align*}
\tilde{\EE}[v^Ip] &= {\mathbb E}_{\text{pl}}v^I\sum_{\abs{\beta} \leq D} \sum_K c_{\beta, K}v^K \cdot h_{\beta}(d)\cdot \frac{h_\gamma(d)}{\gamma!}\\
&= {\mathbb E}_{\text{pl}}v^I \cdot \frac{h_\gamma(d)}{\gamma!} \cdot \sum_{\abs{\beta} \leq D} \sum_K c_{\beta, K}v^K \cdot h_{\beta}(d)\\
&= {\mathbb E}_{\text{pl}}v^I \cdot \frac{h_\gamma(d)}{\gamma!} \cdot p(d,v)\\
&= 0.
\end{align*}
We now bound the coefficients that appear in the remaining case when $n^\tau - D < \abs{\gamma} \leq n^\tau + D$.
\begin{align*}
\abs{\displaystyle\sum_{\abs{\beta} \leq D} \sum_K c_{\beta, K}\sum_{\abs{\alpha} \leq n^\tau} \mu_{I+K, \alpha} \cdot l_{\alpha,\beta,\gamma}\frac{1}{\alpha!}} & \leq \displaystyle\sum_{\abs{\beta} \leq D} \sum_K \abs{c_{\beta, K}}\sum_{\abs{\alpha} \leq n^\tau} \abs{\mu_{I+K, \alpha}} \cdot l_{\alpha,\beta,\gamma}\frac{1}{\alpha!}
\end{align*}
If $l_{\alpha,\beta,\gamma}> 0$ then we must have $\abs{\alpha} \geq \abs{\gamma} - \abs{\beta} \geq n^\tau - 2D$.
\begin{align*}
&\leq \sum_{\abs{\beta} \leq D} \sum_K \abs{c_{\beta, K}} \cdot \left(\max_I \max_{\abs{\alpha} \in n^\tau \pm 2D}\abs{\mu_{I, \alpha}} \right) \sum_{\alpha} l_{\alpha,\beta,\gamma}\frac{1}{\alpha!}
\end{align*}
\begin{proposition}
\[\sum_{\alpha} l_{\alpha,\beta,\gamma}\frac{1}{\alpha!} = e^{mn} \prod_{u,i}\binom{\beta_{ui}}{\frac{\alpha_{ui} + \beta_{ui} -\gamma_{ui}}{2}}\]
\end{proposition}
\begin{proof}
Compute using~\cref{prop:multiply-coefficients}.
\end{proof}
Using the proposition,
\[\leq \sum_{\abs{\beta} \leq D} \sum_K \abs{c_{\beta, K}} \cdot \left(\max_I \max_{\abs{\alpha} \in n^\tau \pm 2D}\abs{\mu_{I, \alpha}} \right) e^{mn}\prod_{u,i}\binom{\beta_{ui}}{\frac{\alpha_{ui} + \beta_{ui} -\gamma_{ui}}{2}} \]
We can bound
\[\prod_{u,i}\binom{\beta_{ui}}{k_{ui}} \leq \prod_{u,i} 2^{\beta_{ui}} = 2^{\abs{\beta}} \leq 2^D.\]
In total, letting $M$ be the number of nonzero coefficients in the constraint $p$ and $L$ be the largest coefficient, this Fourier coefficient is at most,
\[ M \cdot L \cdot 2^D e^{mn}\cdot \max_I\max_{\abs{\alpha}\in n^\tau \pm 2D} \abs{\mu_{I+K,\alpha}} .\]
\end{proof}
\begin{lemma}\label{lem:approximate-constraints}
W.h.p. $\norm{Q\tilde{\EE}} \leq \frac{1}{n^{\Omega(n^\tau)}}$
\end{lemma}
\begin{proof}
Via~\cref{lem:boolean-approximate-constraints} the only nonzero Fourier characters that appear in $Q\tilde{\EE}$ are those of size $n^\tau \pm 2$. Their coefficient in the lemma is at most
\begin{align*}
& C \cdot e^{mn}\cdot \max_I\max_{\abs{\alpha}\in n^\tau \pm 4} \abs{\mu_{I+K,\alpha}}\\
\leq & C \cdot e^{mn} \cdot \frac{(n^{\tau} - 4)^{3(n^\tau - 4)}}{n^{(n^\tau - 4)/2}} && (\text{\cref{prop:coefficient-bound}})\\
\leq & \frac{n^{3\tau n^\tau}}{n^{(\frac{1}{2} + o(1)) n^\tau }}
\end{align*}
Therefore we can express $Q\tilde{\EE}$ as a sum of graph matrices\footnote{Graph vectors, since $Q\tilde{\EE}$ is a vector.} of this size, with coefficients bounded by the above quantity. Now we bound the total norm by summing over all graphs.
The number of graph matrices of this size is at most $n^{O(\tau) \cdot n^\tau}$.
The norm of each term can be bounded using norm bounds by $n^{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}}$ w.h.p. Note that there is no minimum vertex separator since $V = \emptyset$, and there are $O(1)$ isolated vertices when multiplying graphs in $Q$ with graphs in the pseudocalibration (which have no isolated vertices). The number of circle vertices can be bounded by $\frac{1}{4}\abs{E(\alpha)} \leq \frac{1}{4}n^\tau$. The number of square vertices can be bounded by $O(n^\delta) + \frac{1}{2}\abs{E(\alpha)} \leq 0.52n^\tau$. Therefore the norms are at most $m^{\frac{1}{8}n^\tau}~n^{0.26n^\tau + O(1)}~\leq~n^{0.49n^\tau}$. Notably this is significantly less than the denominator of the graph matrix coefficient, which is $n^{(0.5+o(1))n^\tau}$. Assuming $\delta$ and $\tau$ are small enough, the denominator is enough to overpower all terms multiplied together.
\end{proof}
\subsection{Analyzing $Q{Q^T}$}
The main theorem of this subsection is that the minimum nonzero eigenvalue of $QQ^T$ is large.
\begin{theorem}\label{lem:pseudoinverse-lower-bound}
The minimum nonzero eigenvalue of $QQ^T$ is $\frac{n^2}{2} - \tilde{O}(n\sqrt{m})$.
\end{theorem}
\begin{proof}[Proof of~\cref{lem:pseudoexpectation-rounding} assuming~\cref{lem:pseudoinverse-lower-bound}]
\begin{align*}
\norm{\tilde{\EE} - \tilde{\EE}'} & = \norm{Q^\intercal (QQ^\intercal)^+ Q\tilde{\EE}} \leq \norm{Q} \cdot \norm{(QQ^\intercal)^+} \cdot\norm{Q\tilde{\EE}}\\
& \leq n^{O(1)} \cdot \frac{1}{n^2} \cdot \frac{1}{n^{\Omega(n^\tau)}}\\
& = \frac{1}{n^{\Omega(n^\tau)}}
\end{align*}
\end{proof}
Recall that $Q = \sum_{k}{L^T_k}$. Let us refer to the five shapes in~\cref{def:lk} as $\alpha_1$ through $\alpha_5$, and their coefficients as $c_{\alpha_i}$. Observe that the dominant part of $L_k$ is $2M_{\alpha_1}$ which has norm $\tilde{O}(n)$. The norm bounds for the other components of $L_k$ are as follows:
\begin{enumerate}
\item $\norm{c_{\alpha_2}M_{\alpha_2}}$ is $\tilde{O}\left(\frac{1}{n} \cdot \sqrt{mn}\right) = \tilde{O}\left(\frac{\sqrt{m}}{\sqrt{n}}\right)$
\item $\norm{c_{\alpha_3}M_{\alpha_3}}$ is $\tilde{O}\left(\frac{1}{n^2} \cdot n\sqrt{m}\right) = \tilde{O}\left(\frac{\sqrt{m}}{n}\right)$
\item $\norm{c_{\alpha_4}M_{\alpha_4}}$ is $\tilde{O}\left(\frac{1}{n} \cdot \sqrt{mn}\right) = \tilde{O}\left(\frac{\sqrt{m}}{\sqrt{n}}\right)$
\item $\norm{c_{\alpha_5}M_{\alpha_5}}$ is $\tilde{O}\left(\frac{1}{n} \cdot \sqrt{m}\right) = \tilde{O}\left(\frac{\sqrt{m}}{n}\right)$
\end{enumerate}
We start by analyzing $QQ^T = \sum_{k}{L^T_k{L_k}}$.
From the above, taking $\alpha = \alpha_1$, the dominant term of $L_k$ is $2M_{\alpha}$ where $U_{\alpha} = \{j_1,\ldots,j_{k}\}$, $V_{\alpha} = \{j_3,\ldots,j_{k}\} \cup \{u\}$, and $E(\alpha) = \{(j_1,u),(j_2,u)\}$. Since $\norm{M_{\alpha}}$ is $\tilde{O}(n)$ and $\norm{L_k - 2M_{\alpha}}$ is $\tilde{O}(\frac{\sqrt{m}}{\sqrt{n}})$, this implies that for each $k$, $\norm{L_{k}^T{L_k} - 4M^T_{\alpha}M_{\alpha}}$ is $\tilde{O}(\sqrt{mn})$. Thus, it is sufficient to analyze $M^T_{\alpha}M_{\alpha}$.
\begin{lemma}\label{QQTdecompositionlemma}
Taking $\alpha$ to be the shape such that $U_{\alpha} \setminus V_{\alpha} = \{j_1,j_2\}$, $U_{\alpha} \cap V_{\alpha} = \{j_3,j_4,\ldots,j_{k}\}$, $V_{\alpha} \setminus U_{\alpha} = \{i_{circ}\}$, and $E(\alpha) = \{(j_1,i),(j_2,i)\}$,
\[
M^{T}_{\alpha}M_{\alpha} = M_{\alpha_1} + M_{\alpha_2} + M_{\alpha_3} + M_{\alpha_4} + M_{\alpha_5} + M_{\alpha_6}
\] where $\alpha_1,\alpha_2,\alpha_3,\alpha_4,\alpha_5,\alpha_6$ are the following shapes. Note that $\alpha_1$ and $\alpha_2$ are improper shapes.
\begin{enumerate}
\item $U_{\alpha_1} \setminus V_{\alpha_1} = \emptyset$, $U_{\alpha_1} \cap V_{\alpha_1} = \{j_3,j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $V_{\alpha_1} \setminus U_{\alpha_1} = \emptyset$, $V(\alpha_1) \setminus (U_{\alpha_1} \cup V_{\alpha_1}) = \{j_1,j_2\}$, and $E(\alpha_1) = \{(i,j_1),(i,j_1),(i,j_2),(i,j_2)\}$.
\item $U_{\alpha_2} \setminus V_{\alpha_2} = \{j_1\}$, $U_{\alpha_2} \cap V_{\alpha_2} = \{j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $V_{\alpha_2} \setminus U_{\alpha_2} = \{j'_1\}$, $V(\alpha_2) \setminus (U_{\alpha_2} \cup V_{\alpha_2}) = \{j_2\}$, and $E(\alpha_2) = \{(i,j_1),(i,j'_1),(i,j_2),(i,j_2)\}$.
\item $U_{\alpha_3} \setminus V_{\alpha_3} = \{j_1,j_2\}$, $U_{\alpha_3} \cap V_{\alpha_3} = \{j_5,\ldots,j_{k}\} \cup \{i_{circ}\}$, $V_{\alpha_3} \setminus U_{\alpha_3} = \{j'_1,j'_2\}$, and $E(\alpha_3) = \{(i,j_1),(i,j_2),(i,j'_1),(i,j'_2)\}$.
\item $U_{\alpha_4} \setminus V_{\alpha_4} = \{i_{circ}\}$, $U_{\alpha_4} \cap V_{\alpha_4} = \{j_3,j_4,\ldots,j_{k}\}$, $V_{\alpha_4} \setminus U_{\alpha_4} = \{i'_{circ}\}$, $V(\alpha_4) \setminus (U_{\alpha_4} \cup V_{\alpha_4}) = \{j_1,j_2\}$, and $E(\alpha_4) = \{(i,j'_1),(i,j'_2),(i',j_1),(i',j_2)\}$.
\item $U_{\alpha_5} \setminus V_{\alpha_5} = \{j_1\} \cup \{i_{circ}\}$, $U_{\alpha_5} \cap V_{\alpha_5} = \{j_4,\ldots,j_{k}\}$, $V_{\alpha_5} \setminus U_{\alpha_5} = \{j'_1\} \cup \{i'_{circ}\}$, $V(\alpha_5) \setminus (U_{\alpha_5} \cup V_{\alpha_5}) = \{j_2\}$, and $E(\alpha_5) = \{(i,j'_1),(i,j_2),(i',j_1),(i',j_2)\}$.
\item $U_{\alpha_6} \setminus V_{\alpha_6} = \{j_1,j_2\} \cup \{i_{circ}\}$, $U_{\alpha_6} \cap V_{\alpha_6} = \{j_5,\ldots,j_{k}\}$, $V_{\alpha_6} \setminus U_{\alpha_6} = \{j'_1,j'_2\} \cup \{i'_{circ}\}$, and $E(\alpha_6) = \{(i',j_1),(i',j_2),(i,j'_1),(i,j'_2)\}$.
\end{enumerate}
\end{lemma}
For pictures of these shapes, see~\cref{fig:QQTdominantfigure} below.
\begin{figure}[ht]
\centerline{\includegraphics[height=10cm]{sherrington_kirkpatrick/QQTFull}}
\caption{This figure shows the decomposition of $M^T_{\alpha}M_{\alpha}$.}
\label{fig:QQTdominantfigure}
\end{figure}
\begin{remark}
For $k = 2$, only shapes $\alpha_1$ and $\alpha_4$ are present and for $k = 3$, only shapes $\alpha_1,\alpha_2,\alpha_4,\alpha_5$ are present.
\end{remark}
\begin{proof}[Proof of Lemma \ref{QQTdecompositionlemma}]
We compute $M_{\alpha^T}M_{\alpha}$ by considering the ribbons which appear in $M_{\alpha^T}M_{\alpha}$.
\begin{enumerate}
\item Each ribbon $R$ with $A_R \setminus B_R = \emptyset$, $A_R \cap B_R = \{j_3,j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_R \setminus A_R = \emptyset$, $V(R) \setminus (A_R \cup B_R) = \{j_1,j_2\}$, and $E(R) = \{(i,j_1),(i,j_1),(i,j_2),(i,j_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{i_{circ}\}$, $A_{R_1} \cap B_{R_1} = \{j_3,j_4,\ldots,j_{k}\}$, $B_{R_1} \setminus A_{R_1} = \{j_1,j_2\}$, and $E(R_1) = \{(i,j_1),(i,j_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{j_1,j_2\}$, $A_{R_2} \cap B_{R_2} = \{j_3,j_4,\ldots,j_{k}\}$, $B_{R_2} \setminus A_{R_2} = \{i_{circ}\}$, and $E(R_2) = \{(i,j_1),(i,j_2)\}$.
\end{enumerate}
\item Each ribbon $R$ with $A_R \setminus B_R = \{j_1\}$, $A_R \cap B_R = \{j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_R \setminus A_R = \{j'_1\}$, $V(R) \setminus (A_R \cup B_R) = \{j_2\}$, and $E(R) = \{(i,j_1),(i,j'_1),(i,j_2),(i,j_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{i_{circ}\}$, $A_{R_1} \cap B_{R_1} = \{j_1,j_4,\ldots,j_{k}\}$, $B_{R_1} \setminus A_{R_1} = \{j'_1,j_2\}$, and $E(R_1) = \{(i,j'_1),(i,j_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{j_1,j_2\}$, $A_{R_2} \cap B_{R_2} = \{j'_1,j_4,\ldots,j_{k}\}$, $B_{R_2} \setminus A_{R_2} = \{i_{circ}\}$, and $E(R_2) = \{(i,j_1),(i,j_2)\}$.
\end{enumerate}
\item Each ribbon $R$ with $A_R \setminus B_R = \{j_1,j_2\}$, $A_R \cap B_R = \{j_5,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_R \setminus A_R = \{j'_1,j'_2\}$, $V(R) \setminus (A_R \cup B_R) = \emptyset$, and $E(R) = \{(i,j_1),(i,j'_1),(i,j_2),(i,j'_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{i_{circ}\}$, $A_{R_1} \cap B_{R_1} = \{j_1,j_2,j_5,\ldots,j_{k}\}$, $B_{R_1} \setminus A_{R_1} = \{j'_1,j'_2\}$, and $E(R_1) = \{(i,j'_1),(i,j'_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{j_1,j_2\}$, $A_{R_2} \cap B_{R_2} = \{j'_1,j'_2,j_5,\ldots,j_{k}\}$, $B_{R_2} \setminus A_{R_2} = \{i_{circ}\}$, and $E(R_2) = \{(i,j_1),(i,j_2)\}$.
\end{enumerate}
\item Each ribbon $R$ with $A_R \setminus B_R = \{j_1,j_2\} \cup \{i_{circ}\}$, $A_R \cap B_R = \{j_5,\ldots,j_{k}\}$, $B_R \setminus A_R = \{j'_1,j'_2\} \cup \{i'_{circ}\}$, $V(R) \setminus (A_R \cup B_R) = \emptyset$, and $E(R) = \{(i,j'_1),(i,j'_2),(i',j_1),(i',j_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{i_{circ}\}$, $A_{R_1} \cap B_{R_1} = \{j_1,j_2,j_5,\ldots,j_{k}\}$, $B_{R_1} \setminus A_{R_1} = \{j'_1,j'_2\}$, and $E(R_1) = \{(i,j'_1),(i,j'_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{j_1,j_2\}$, $A_{R_2} \cap B_{R_2} = \{j'_1,j'_2,j_5,\ldots,j_{k}\}$, $B_{R_2} \setminus A_{R_2} = \{i'_{circ}\}$, and $E(R_2) = \{(i,j_1),(i,j_2)\}$.
\end{enumerate}
\item Each ribbon $R$ with $A_R \setminus B_R = \{i_{circ}\}$, $A_R \cap B_R = \{j_3,j_4,\ldots,j_{k}\}$, $B_R \setminus A_R = \{i'_{circ}\}$, $V(R) \setminus (A_R \cup B_R) = \{j_1,j_2\}$, and $E(R) = \{(i,j_1),(i,j_2),(i',j_1),(i',j_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{i_{circ}\}$, $A_{R_1} \cap B_{R_1} = \{j_3,j_4,\ldots,j_{k}\}$, $B_{R_1} \setminus A_{R_1} = \{j_1,j_2\}$, and $E(R_1) = \{(i,j_1),(i,j_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{j_1,j_2\}$, $A_{R_2} \cap B_{R_2} = \{j_3,j_4,\ldots,j_{k}\}$, $B_{R_2} \setminus A_{R_2} = \{i'_{circ}\}$, and $E(R_2) = \{(i',j_1),(i',j_2)\}$.
\end{enumerate}
\item Each ribbon $R$ with $A_R \setminus B_R = \{j_1\}$, $A_R \cap B_R = \{j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_R \setminus A_R = \{j'_1\}$, $V(R) \setminus (A_R \cup B_R) = \{j_2\}$, and $E(R) = \{(i,j_1),(i,j'_1),(i,j_2),(i,j_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{i_{circ}\}$, $A_{R_1} \cap B_{R_1} = \{j_1,j_4,\ldots,j_{k}\}$, $B_{R_1} \setminus A_{R_1} = \{j'_1,j_2\}$, and $E(R_1) = \{(i,j'_1),(i,j_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{j_1,j_2\}$, $A_{R_2} \cap B_{R_2} = \{j'_1,j_4,\ldots,j_{k}\}$, $B_{R_2} \setminus A_{R_2} = \{i_{circ}\}$, and $E(R_2) = \{(i,j_1),(i,j_2)\}$.
\end{enumerate}
\end{enumerate}
Based on these cases, we have that $M_{\alpha^T}M_{\alpha} = M_{\alpha_1} + M_{\alpha_2} + M_{\alpha_3} + M_{\alpha_4} + M_{\alpha_5} + M_{\alpha_6}$.
\end{proof}
We now analyze each of the matrices $M_{\alpha_1}, M_{\alpha_2}, M_{\alpha_3}, M_{\alpha_4}, M_{\alpha_5}, M_{\alpha_6}$.
\begin{lemma}
Taking $Id_{k-2,1}$ to be the shape where $U_{Id_{k-2,1}} \setminus V_{Id_{k-2,1}} = \emptyset$, $U_{Id_{k-2,1}} \cap V_{Id_{k-2,1}} = \{j_3,j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $V_{Id_{k-2,1}} \setminus U_{Id_{k-2,1}} = \emptyset$, and $E(Id_{k-2,1}) = \emptyset$, $\norm{M_{\alpha_1} - \binom{n-k+2}{2}M_{Id_{k-2,1}}}$ is $\tilde{O}\left(n^{\frac{3}{2}}\right)$.
\end{lemma}
\begin{proof}
To convert an improper shape $\alpha_1$ to a sum of proper shapes, we take each ribbon of shape $\alpha_1$ and decompose it into a sum of proper ribbons. Decomposing $M_{\alpha_1}$ in this way, each ribbon $R$ with $A_R \setminus B_R = \emptyset$, $A_R \cap B_R = \{j_3,j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_R \setminus A_R = \emptyset$, and $E(R) = \emptyset$ appears $\binom{n-k+2}{2}$ times, once for each pair $j_1,j_2$ such that $j_1 < j_2$ and $j_1,j_2 \notin \{j_3,\ldots,j_{k}\}$. The other ribbons which arise all have an edge with label $2$ incident with $j_1$ or $j_2$ and thus the resulting terms have norm $\tilde{O}\left(n^{\frac{3}{2}}\right)$.
\end{proof}
\begin{definition}
Define $\beta_2$ to be the shape such that $U_{\beta_2} \setminus V_{\beta_2} = \{j_1\}$, $U_{\beta_2} \cap V_{\beta_2} = \{j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $V_{\beta_2} \setminus U_{\beta_2} = \emptyset$, and $E(\beta_1) = \{(i,j_1)\}$.
\end{definition}
\begin{lemma}
$\norm{M_{\alpha_2} - (n-k+1)M_{\beta_2}M^T_{\beta_2}}$ is $\tilde{O}\left(n^{\frac{3}{2}}\right)$.
\end{lemma}
\begin{proof}
Again, to convert an improper shape $\alpha_2$ to a sum of proper shapes, we take each ribbon of shape $\alpha_2$ and decompose it into a sum of proper ribbons. Decomposing $M_{\alpha_2}$ in this way, each ribbon $R$ with $A_R \setminus B_R = \{j_1\}$, $A_R \cap B_R = \{j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_R \setminus A_R = \emptyset$, and $E(R) = \{(i,j_1),(i,j'_1)\}$ appears $(n-k+1)$ times, once for each $j_2 \in [n] \setminus \{j_1,j'_1,j_4,\ldots,j_k\}$. The other ribbons which arise have an edge with label $2$ incident with $j_2$ and thus the resulting terms have norm $\tilde{O}\left(n^{\frac{3}{2}}\right)$. This implies that if we take $\alpha'_2$ to be the shape where $U_{\alpha_2} \setminus V_{\alpha_2} = \{j_1\}$, $U_{\alpha_2} \cap V_{\alpha_2} = \{j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $V_{\alpha_2} \setminus U_{\alpha_2} = \{j'_1\}$, and $E(\alpha_2) = \{(i,j_1),(i,j'_1)\}$ then $\norm{M_{\alpha_2} - (n-k+1)M_{\alpha'_2}}$ is $\tilde{O}\left(n^{\frac{3}{2}}\right)$.
$\norm{M_{\alpha'_2}}$ is $\tilde{O}(n)$, so this term cannot be ignored. To handle this, we observe that $M_{\alpha'_2}$ is approximately equal to a PSD matrix. More precisely, $\norm{M_{\alpha'_2} - M_{\beta_2}M^T_{\beta_2}}$ is $\tilde{O}(1)$. To see this, note that when we expand out $M_{\beta_2}M^T_{\beta_2}$, the ribbons which result when there are no collisions give $M_{\alpha'_2}$ and for each ribbon $R$ which results from a collision, $A_R \setminus B_R = B_R \setminus A_R = \emptyset$ so the resulting terms have norm $\tilde{O}(1)$.
\end{proof}
\begin{figure}[ht]\label{BetaTwoFigure}
\centerline{\includegraphics[height=3cm]{sherrington_kirkpatrick/BetaTwo}}
\caption{This figure shows $\alpha'_2$ and $\beta_2$ for $k = 4$.}
\end{figure}
$\norm{M_{\alpha_3}}$ is $\tilde{O}(n^2)$, so this term cannot be ignored. To handle this, we observe that $M_{\alpha_3}$ is approximately equal to a PSD matrix. More precisely, we have the following lemma.
\begin{definition}
Define $\beta_3$ to be the shape such that $U_{\beta_3} \setminus V_{\beta_3} = \{j_1,j_2\}$, $U_{\beta_3} \cap V_{\beta_3} = \{j_5,\ldots,j_{k}\} \cup \{i_{circ}\}$, $V_{\beta_3} \setminus U_{\beta_3} = \emptyset$, and $E(\beta_3) = \{(i,j_1),(i,j_2)\}$.
\end{definition}
\begin{lemma}
$\norm{M_{\alpha_3} - M_{\beta_3}M^T_{\beta_3}}$ is $\tilde{O}(n)$.
\end{lemma}
\begin{proof}
To see this, note that when we expand out $M_{\beta_3}M^T_{\beta_3}$, the ribbons which result when there are no collisions give $M_{\alpha_3}$ and for each ribbon $R$ which results from a collision, $|A_R \setminus B_R| = |B_R \setminus A_R| \leq 1$ so the resulting terms have norm $\tilde{O}(n)$.
\end{proof}
\begin{figure}[ht]\label{BetaThreeFigure}
\centerline{\includegraphics[height=3cm]{sherrington_kirkpatrick/BetaThree}}
\caption{This figure shows $\alpha_3$ and $\beta_3$ for $k = 4$.}
\end{figure}
We now consider the norms of $M_{\alpha_4}$, $M_{\alpha_5}$, and $M_{\alpha_6}$.
\begin{enumerate}
\item $\norm{M_{\alpha_4}}$ is $\tilde{O}(n\sqrt{m})$.
\item $\norm{M_{\alpha_5}}$ is $\tilde{O}(n\sqrt{m})$.
\item $\norm{M_{\alpha_6}}$ is $\tilde{O}(n^2)$.
\end{enumerate}
This means that $M_{\alpha_4}$ and $M_{\alpha_5}$ can be ignored but $M_{\alpha_6}$ cannot be ignored. In fact, there is a very good reason for this. In particular, for $k \geq 4$, $L_k$ has a non-trivial nullspace $N_k$, so we cannot show that the minimum nonzero eigenvalue of ${L_k^T}{L_k}$ is large without taking this nullspace into account. We handle this nullspace $N_k$ in the next two subsubsections.
Putting everything together, we have the following corollary:
\begin{corollary}\label{QQTapproximationcorollary} \
\begin{enumerate}
\item For $k = 2$, $\norm{{L_k^T}L_k - 2{n^2}M_{Id_{k-2,1}}}$ is $\tilde{O}(n\sqrt{m})$
\item For $k = 3$, $\norm{{L_k^T}L_k - 2{n^2}M_{Id_{k-2,1}} - 4nM_{\beta_2}M^T_{\beta_2}}$ is $\tilde{O}(n\sqrt{m})$
\item For $k \geq 4$, $\norm{{L_k^T}L_k - 2{n^2}M_{Id_{k-2,1}} - 4nM_{\beta_2}M^T_{\beta_2} - 4M_{\beta_3}M^T_{\beta_3} - 4M_{\alpha_6}}$ is $\tilde{O}(n\sqrt{m})$
\end{enumerate}
\end{corollary}
\begin{remark}
We replaced $\binom{n-k+2}{2}$ with $\frac{n^2}{2}$ as $\norm{M_{Id_{k-2,1}}} = 1$ and $|\frac{n^2}{2} - \binom{n-k+2}{2}|$ is $\tilde{O}(n)$. Similarly, we replaced $(n-k+1)$ with $n$ as $\norm{M_{\alpha'_2}}$ is $\tilde{O}(n)$ and $|n - (n-k+1)|$ is $\tilde{O}(1)$
\end{remark}
\subsubsection{The Null Space $N_k$}
We now construct a matrix $N_k$ for each $k \geq 4$ such that ${L_k}{N_k} = 0$ and the columns of ${N_k}$ span the nullspace of $L_k$. To do this, we construct $N_k$ so that the entries of each column of $N_k$ is indexed by a subset $S = \{j_3,\ldots,j_{k}\} \subseteq [n]$ and an ordered tuple of circle indices $(i,i')$ where $i < i'$. We then want that if we view $\tilde{E}$ as a vector,
\[
({\tilde{E}^T}{L_k}N_k)_{S,(i,i')} = \tilde{E}\left[v^{S}\left({\ip{v}{d_i}}^2 - 1\right)\left({\ip{v}{d_{i'}}}^2 - 1\right)\right] - \tilde{E}\left[v^{S}\left({\ip{v}{d_{i'}}}^2 - 1\right)\left({\ip{v}{d_i}}^2 - 1\right)\right] = 0
\]
\begin{lemma}
$N_k = c_{\alpha_1}(M_{\alpha_1^+} - M_{\alpha_1^-}) + c_{\alpha_2}(M_{\alpha_2^+} - M_{\alpha_2^-}) + c_{\alpha_3}(M_{\alpha_3^+} - M_{\alpha_3^-}) + c_{\alpha_4}(M_{\alpha_4^+} - M_{\alpha_4^-}) + c_{\alpha_5}(M_{\alpha_5^+} - M_{\alpha_5^-})$ for the following shapes $\alpha_1^{+},\ldots,\alpha_5^{+}, \alpha_1^{-},\ldots,\alpha_5^{-}$ and coefficients $c_{\alpha_1},\ldots,c_{\alpha_5}$. Unless stated otherwise, all of these shapes have no middle vertices.
\begin{enumerate}
\item $U_{\alpha_1^+} \setminus V_{\alpha_1^+} = \{j_1,j_2\}$, $U_{\alpha_1^+} \cap V_{\alpha_1^+} = \{j_3,j_4,\ldots,j_{k}\} \cup \{i'_{circ}\}$, $V_{\alpha_1^+} \setminus U_{\alpha_1^+} = \{i_{circ}\}$, $E(\alpha_1^+) = \{(j_1,i),(j_2,i)\}$, and $c_{\alpha_1} = 2$.
\item $U_{\alpha_2^+} \setminus V_{\alpha_2^+} = \{j_2\}$, $U_{\alpha_2^+} \cap V_{\alpha_2^+} = \{j_4,\ldots,j_{k}\} \cup \{i'_{circ}\}$, $V_{\alpha_2^+} \setminus U_{\alpha_2^+} = \{j_3\} \cup \{i_{circ}\}$, $E(\alpha_2^+) = \{(j_3,i),(j_2,i)\}$, and $c_{\alpha_2} = \frac{2}{n}$.
\item $U_{\alpha_3^+} \setminus V_{\alpha_3^+} = \emptyset$, $U_{\alpha_3^+} \cap V_{\alpha_3^+} = \{j_5,\ldots,j_{k}\} \cup \{i'_{circ}\}$, $V_{\alpha_3^+} \setminus U_{\alpha_3^+} = \{j_3,j_4\} \cup \{i_{circ}\}$, $E(\alpha_3^+) = \{(j_3,i),(j_4,i)\}$, and $c_{\alpha_3} = \frac{2}{n^2}$.
\item $U_{\alpha_4^+} \setminus V_{\alpha_4^+} = \emptyset$, $U_{\alpha_4^+} \cap V_{\alpha_4^+} = \{j_3,j_4,\ldots,j_{k}\} \cup \{i'_{circ}\}$, $V_{\alpha_4^+} \setminus U_{\alpha_4^+} = \{i_{circ}\}$, $V(\alpha_4^+) \setminus (U_{\alpha_4^+} \cup V_{\alpha_4^+}) = \{j_1\}$ $E(\alpha_4^+) = \{(j_1,i)_2\}$, and $c_{\alpha_4} = \frac{1}{n}$.
\item $U_{\alpha_5^+} \setminus V_{\alpha_5^+} = \emptyset$, $U_{\alpha_5^+} \cap V_{\alpha_5^+} = \{j_3,j_4,\ldots,j_{k}\} \cup \{i'_{circ}\}$, $V_{\alpha_5^+} \setminus U_{\alpha_5^+} = \{i_{circ}\}$, $E(\alpha_5^+) = \{(j_3,i)_2\}$, and $c_{\alpha_5} = \frac{1}{n}$.
\end{enumerate}
where for all of these shapes, $(i_{circ},i'_{circ})$ is a tuple in the right side and $i < i'$. $\alpha_1^{-},\ldots,\alpha_5^{-}$ are the same as $\alpha_1^{+},\ldots,\alpha_5^{+}$ except that $i$ and $i'$ are swapped.
\end{lemma}
\begin{remark}
Note that $\alpha_1^{+},\ldots,\alpha_5^{+}$ are the same shapes which appear in the decomposition of $L_k$ except that the intersection of $U$ and $V$ now contains $i'_{circ}$ and we require that $i < i'$.
\end{remark}
For pictures of these shapes, see Figure \ref{NDecompositionFigure} below.
\begin{figure}[ht]
\centerline{\includegraphics[height=10cm]{sherrington_kirkpatrick/NFull081620}}
\caption{This figure shows the decomposition of $N_k$ for $k = 4$. Here we always have that $i < i'$. If $i$ and $i'$ are swapped then this flips the signs but these parts are not shown to save space.}
\label{NDecompositionFigure}
\end{figure}
\begin{proof}
To determine $N_k$, we analyze the ribbons which $N_k$ is composed of. Let $S = \{j_3,j_4,\ldots,j_k\}$.
\begin{enumerate}
\item If we take a ribbon $R$ with $A_R = \{j_1,\ldots,j_{k}\} \cup \{i'_{circ}\}$, $B_R = \{j_3,\ldots,j_{k}\} \cup (i_{circ},i'_{circ})$, and $E(R) = \{(j_1,i),(j_2,i)\}$ where $j_1 \neq j_2$ and $j_1,j_2 \notin S$ then
\[
({\tilde{E}^T}{L_k}M_R)_{S,i,i'} = \tilde{E}\left[v^{S}v_{j_1}v_{j_2}(d_{i})_{j_1}(d_i)_{j_2}\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]
\]
Each such term appears with a coefficient of $2$ in $\tilde{E}\left[v^{S}\left({\ip{v}{d_i}}^2 - 1\right)\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]$, so we want each such ribbon $R$ to appear with a coefficient of $2$ in $N_k$.
Similarly, we want each ribbon $R$ with $A_R = \{j_1,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_R = \{j_3,\ldots,j_{k}\} \cup (i_{circ},i'_{circ})$, and $E(R) = \{(j_1,i'),(j_2,i')\}$ where $j_1 \neq j_2$ and $j_1,j_2 \notin S$ to appear with a coefficient of $-2$ in $N_k$.
\item If we take a ribbon $R$ with $A_R = (\{j_1,\ldots,j_{k}\} \setminus \{j_1,j_3\}) \cup \{i'_{circ}\}$, $B_R = \{j_3,\ldots,j_{k}\} \cup (i_{circ},i'_{circ})$, and $E(R) = \{(j_3,i),(j_2,i)\}$ where $j_1 = j_3 \in S$ and $j_2 \notin S$ then
\begin{align*}
({\tilde{E}^T}{L_k}M_R)_{S,i,i'} &= \tilde{E}\left[v^{S \setminus \{j_1,j_3\}}v_{j_2}(d_{i})_{j_3}(d_i)_{j_2}\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]\\
&=n\tilde{E}\left[v^{S}v_{j_1}v_{j_2}(d_{i})_{j_1}(d_i)_{j_2}\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]
\end{align*}
Each such term appears with a coefficient of $\frac{2}{n}$ in $\tilde{E}\left[v^{S}\left({\ip{v}{d_i}}^2 - 1\right)\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]$, so we want each such ribbon $R$ to appear with a coefficient of $\frac{2}{n}$ in $N_k$.
Similarly, we want each ribbon $R$ with $A_R = (\{j_1,\ldots,j_{k}\} \setminus \{j_1,j_3\}) \cup \{i_{circ}\}$, $B_R = \{j_3,\ldots,j_{k}\} \cup (i_{circ},i'_{circ})$, and $E(R) = \{(j_3,i'),(j_2,i')\}$ where $j_1 = j_3 \in S$ and $j_2 \notin S$ to appear with a coefficient of $-\frac{2}{n}$ in $N_k$.
\item If we take a ribbon $R$ with $A_R = (\{j_1,\ldots,j_{k}\} \setminus \{j_1,j_2,j_3,j_4\}) \cup \{i'_{circ}\}$, $B_R = \{j_3,\ldots,j_{k}\} \cup (i_{circ},i'_{circ})$, and $E(R) = \{(j_3,i),(j_4,i)\}$ where $j_1 = j_3 \in S$ and $j_2 = j_4 \in S$ then
\begin{align*}
({\tilde{E}^T}{L_k}M_R)_{S,i,i'} &= \tilde{E}\left[v^{S \setminus \{j_1,j_2,j_3,j_4\}}(d_{i})_{j_3}(d_i)_{j_4}\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]\\
&=n^2\tilde{E}\left[v^{S}v_{j_1}v_{j_2}(d_{i})_{j_1}(d_i)_{j_2}\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]
\end{align*}
Each such term appears with a coefficient of $\frac{2}{n^2}$ in $\tilde{E}\left[v^{S}\left({\ip{v}{d_i}}^2 - 1\right)\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]$, so we want each such ribbon $R$ to appear with a coefficient of $\frac{2}{n^2}$ in $N_k$.
Similarly, we want each ribbon $R$ with $A_R = (\{j_1,\ldots,j_{k}\} \setminus \{j_1,j_2,j_3,j_4\}) \cup \{i_{circ}\}$, $B_R = \{j_3,\ldots,j_{k}\} \cup (i_{circ},i'_{circ})$, and $E(R) = \{(j_3,i'),(j_4,i')\}$ where $j_1 = j_3 \in S$ and $j_2 = j_4 \in S$ to appear with a coefficient of $-\frac{2}{n^2}$ in $N_k$.
\item If we take a ribbon $R$ with $A_R = (\{j_1,\ldots,j_{k}\} \setminus \{j_1,j_2\}) \cup \{i'_{circ}\}$, $B_R = \{j_3,\ldots,j_{k}\} \cup (i_{circ},i'_{circ})$, and $E(R) = \{(j_1,i)_2\}$ where $j_1 = j_2 \notin S$ then
\begin{align*}
({\tilde{E}^T}{L_k}M_R)_{S,i,i'} &= \tilde{E}\left[v^{S \setminus \{j_1,j_2\}}((d_{i})^2_{j_1} - 1)\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]\\
&=n\tilde{E}\left[v^{S}v_{j_1}^2((d_{i})^2_{j_1} - 1)\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]
\end{align*}
Each such term appears with a coefficient of $\frac{1}{n}$ in $\tilde{E}\left[v^{S}\left({\ip{v}{d_i}}^2 - 1\right)\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]$ so we want each such ribbon $R$ to appear with a coefficient of $\frac{1}{n}$ in $N_k$.
Similarly, we want each ribbon $R$ with $A_R = (\{j_1,\ldots,j_{k}\} \setminus \{j_1,j_2\}) \cup \{i'_{circ}\}$, $B_R = \{j_3,\ldots,j_{k}\} \cup (i_{circ},i'_{circ})$, and $E(R) = \{(j_1,i)_2\}$ where $j_1 = j_2 \notin S$ to appear with a coefficient of $-\frac{1}{n}$ in $N_k$.
\item If we take a ribbon $R$ with $A_R = (\{j_1,\ldots,j_{k}\} \setminus \{j_1,j_2\}) \cup \{i'_{circ}\}$, $B_R = \{j_3,\ldots,j_{k}\} \cup (i_{circ},i'_{circ})$, and $E(R) = \{(j_3,i)_2\}$ where $j_1 = j_2 = j_3 \in S$ then
\begin{align*}
({\tilde{E}^T}{L_k}M_R)_{S,i,i'} &= \tilde{E}\left[v^{S \setminus \{j_1,j_2\}}((d_{i})^2_{j_3} - 1)\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]\\
&=n\tilde{E}\left[v^{S}v_{j_1}^2((d_{i})^2_{j_1} - 1)\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]
\end{align*}
Each such term appears with a coefficient of $\frac{1}{n}$ in $\tilde{E}\left[v^{S}\left({\ip{v}{d_i}}^2 - 1\right)\left({\ip{v}{d_{i'}}}^2 - 1\right)\right]$ so we want each such ribbon $R$ to appear with a coefficient of $\frac{1}{n}$ in $N_k$.
Similarly, we want each ribbon $R$ with $A_R = (\{j_1,\ldots,j_{k}\} \setminus \{j_1,j_2\}) \cup \{i'_{circ}\}$, $B_R = \{j_3,\ldots,j_{k}\} \cup (i_{circ},i'_{circ})$, and $E(R) = \{(j_3,i)_2\}$ where $j_1 = j_2 = j_3 \in S$ to appear with a coefficient of $-\frac{1}{n}$ in $N_k$.
\end{enumerate}
\end{proof}
Observe that the dominant part of $N_k$ is $2(M_{\alpha_1^+} - M_{\alpha_1^-})$ which has norm $\tilde{O}(n)$. The norm bounds for the other components of $N_k$ are as follows:
\begin{enumerate}
\item $\norm{c_{\alpha_2}(M_{\alpha_2^+} - M_{\alpha_2^-})}$ is $\tilde{O}\left(\frac{1}{n} \cdot \sqrt{mn}\right) = \tilde{O}\left(\frac{\sqrt{m}}{\sqrt{n}}\right)$
\item $\norm{c_{\alpha_3}(M_{\alpha_3^+} - M_{\alpha_3^-})}$ is $\tilde{O}\left(\frac{1}{n^2} \cdot n\sqrt{m}\right) = \tilde{O}\left(\frac{\sqrt{m}}{n}\right)$
\item $\norm{c_{\alpha_4}(M_{\alpha_4^+} - M_{\alpha_4^-})}$ is $\tilde{O}\left(\frac{1}{n} \cdot \sqrt{mn}\right) = \tilde{O}\left(\frac{\sqrt{m}}{\sqrt{n}}\right)$
\item $\norm{c_{\alpha_5}(M_{\alpha_5^+} - M_{\alpha_5^-})}$ is $\tilde{O}\left(\frac{1}{n} \cdot \sqrt{m}\right) = \tilde{O}\left(\frac{\sqrt{m}}{n}\right)$
\end{enumerate}
\subsubsection{Analyzing $N_k{N^T_k}$}
The dominant terms of $N_k$ are $2M_{\alpha^{+}} - 2M_{\alpha^{-}}$ where
\begin{enumerate}
\item $U_{\alpha^{+}} \setminus V_{\alpha^{+}} = \{j_1,j_2\}$, $U_{\alpha^{+}} \cap V_{\alpha^{+}} = \{j_3,\ldots,j_{k}\} \cup \{i'_{circ}\}$, $V_{\alpha^{+}} \setminus U_{\alpha^{+}} = \{i_{circ}\}$, and $E(\alpha^{+}) = \{(j_1,i),(j_2,i)\}$. Note that here $i < i'$ and $(i_{circ},i'_{circ})$ appears as a tuple in $V_{\alpha^{+}}$.
\item $U_{\alpha^{-}} \setminus V_{\alpha^{-}} = \{j_1,j_2\}$, $U_{\alpha^{-}} \cap V_{\alpha^{-}} = \{j_3,\ldots,j_{k}\} \cup \{i_{circ}\}$, $V_{\alpha^{-}} \setminus U_{\alpha^{-}} = \{i'_{circ}\}$, and $E(\alpha^{-}) = \{(j_1,i'),(j_2,i')\}$. Note that here $i < i'$ and $(i'_{circ},i_{circ})$ appears as a tuple in $V_{\alpha^{-}}$.
\end{enumerate}
\begin{lemma}\label{NNTPluslemma}
$M_{\alpha^{+}}M_{\alpha^{+}}^T + M_{\alpha^{-}}M_{\alpha^{-}}^T = M_{\alpha_1} + M_{\alpha_2} + M_{\alpha_3}$ where $\alpha_1,\alpha_2,\alpha_3$ are the following shapes.
\begin{enumerate}
\item $U_{\alpha_1} \setminus V_{\alpha_1} = \emptyset$, $U_{\alpha_1} \cap V_{\alpha_1} = \{j_1,j_2,j_3,j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $V_{\alpha_1} \setminus U_{\alpha_1} = \emptyset$, $V(\alpha_1) \setminus (U_{\alpha_1} \cup V_{\alpha_1}) = \{i'_{circ}\}$, and $E(\alpha_1) = \{(i',j_1),(i',j_1),(i',j_2),(i',j_2)\}$.
\item $U_{\alpha_2} \setminus V_{\alpha_2} = \{j_1\}$, $U_{\alpha_2} \cap V_{\alpha_2} = \{j_2,j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $V_{\alpha_2} \setminus U_{\alpha_2} = \{j'_1\}$, $V(\alpha_2) \setminus (U_{\alpha_2} \cup V_{\alpha_2}) = \{i'_{circ}\}$, and $E(\alpha_2) = \{(i',j_1),(i',j'_1),(i',j_2),(i',j_2)\}$.
\item $U_{\alpha_3} \setminus V_{\alpha_3} = \{j_1,j_2\}$, $U_{\alpha_3} \cap V_{\alpha_3} = \{j_5,\ldots,j_{k}\} \cup \{i_{circ}\}$, $V_{\alpha_3} \setminus U_{\alpha_3} = \{j'_1,j'_2\}$, $V(\alpha_3) \setminus (U_{\alpha_3} \cup V_{\alpha_3}) = \{i'_{circ}\}$, and $E(\alpha_3) = \{(i',j_1),(i',j_2),(i',j'_1),(i',j'_2)\}$.
\end{enumerate}
Note that for these shapes, we do not assume that $i < i'$. Also note that $\alpha_1$ and $\alpha_2$ are improper shapes, though this does not matter for us.
\end{lemma}
\begin{remark}
Actually, we do not need to do this computation as we will just use that $M_{\alpha^{+}}M_{\alpha^{+}}^T + M_{\alpha^{-}}M_{\alpha^{-}}^T \succeq 0$, but we include it anyways to show the similarity with the decomposition of ${L_k^T}L_k$.
\end{remark}
For pictures of these shapes, see Figure \ref{NNTPlusfigure} below.
\begin{figure}[ht]\label{NNTPlusfigure}
\centerline{\includegraphics[height=6cm]{sherrington_kirkpatrick/NNTPlus}}
\caption{This figure shows the decomposition of $M_{\alpha^{+}}M_{\alpha^{+}}^T + M_{\alpha^{-}}M_{\alpha^{-}}^T$.}
\end{figure}
\begin{proof}[Proof of Lemma \ref{NNTPluslemma}]
We compute $M_{\alpha^{+}}M_{\alpha^{+}}^T + M_{\alpha^{-}}M_{\alpha^{-}}^T$ by considering the ribbons which appear in $M_{\alpha^{+}}M_{\alpha^{+}}^T + M_{\alpha^{-}}M_{\alpha^{-}}^T$. For these ribbons, we do not assume that $i < i'$.
\begin{enumerate}
\item Each ribbon $R$ with $A_R \setminus B_R = \emptyset$, $A_R \cap B_R = \{j_1,j_2,j_3,j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_R \setminus A_R = \emptyset$, $V(R) \setminus (A_R \cup B_R) = \{i'_{circ}\}$, and $E(R) = \{(i',j_1),(i',j_1),(i',j_2),(i',j_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{i_{circ}\}$, $A_{R_1} \cap B_{R_1} = \{j_3,j_4,\ldots,j_{k}\}$, $B_{R_1} \setminus A_{R_1} = \{j_1,j_2\}$, and $E(R_1) = \{(i,j_1),(i,j_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{j_1,j_2\}$, $A_{R_2} \cap B_{R_2} = \{j_3,j_4,\ldots,j_{k}\}$, $B_{R_2} \setminus A_{R_2} = \{i_{circ}\}$, and $E(R_2) = \{(i,j_1),(i,j_2)\}$.
\end{enumerate}
Whether $i < i'$ or $i' < i$ only affects whether this ribbon appears in $M_{\alpha^{+}}M_{\alpha^{+}}^T$ or $M_{\alpha^{-}}M_{\alpha^{-}}^T$.
\item Each ribbon $R$ with $A_R \setminus B_R = \{j_1\}$, $A_R \cap B_R = \{j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_R \setminus A_R = \{j'_1\}$, $V(R) \setminus (A_R \cup B_R) = \{i'_{circ}\}$, and $E(R) = \{(i,j_1),(i,j'_1),(i,j_2),(i,j_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{i_{circ}\}$, $A_{R_1} \cap B_{R_1} = \{j_1,j_4,\ldots,j_{k}\}$, $B_{R_1} \setminus A_{R_1} = \{j'_1,j_2\}$, and $E(R_1) = \{(i,j'_1),(i,j_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{j_1,j_2\}$, $A_{R_2} \cap B_{R_2} = \{j'_1,j_4,\ldots,j_{k}\}$, $B_{R_2} \setminus A_{R_2} = \{i_{circ}\}$, and $E(R_2) = \{(i,j_1),(i,j_2)\}$.
\end{enumerate}
Whether $i < i'$ or $i' < i$ only affects whether this ribbon appears in $M_{\alpha^{+}}M_{\alpha^{+}}^T$ or $M_{\alpha^{-}}M_{\alpha^{-}}^T$.
\item Each ribbon $R$ with $A_R \setminus B_R = \{j_1,j_2\}$, $A_R \cap B_R = \{j_5,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_R \setminus A_R = \{j'_1,j'_2\}$, $V(R) \setminus (A_R \cup B_R) = \{i'_{circ}\}$, and $E(R) = \{(i,j_1),(i,j'_1),(i,j_2),(i,j'_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{i_{circ}\}$, $A_{R_1} \cap B_{R_1} = \{j_1,j_2,j_5,\ldots,j_{k}\}$, $B_{R_1} \setminus A_{R_1} = \{j'_1,j'_2\}$, and $E(R_1) = \{(i,j'_1),(i,j'_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{j_1,j_2\}$, $A_{R_2} \cap B_{R_2} = \{j'_1,j'_2,j_5,\ldots,j_{k}\}$, $B_{R_2} \setminus A_{R_2} = \{i_{circ}\}$, and $E(R_2) = \{(i,j_1),(i,j_2)\}$.
\end{enumerate}
Whether $i < i'$ or $i' < i$ only affects whether this ribbon appears in $M_{\alpha^{+}}M_{\alpha^{+}}^T$ or $M_{\alpha^{-}}M_{\alpha^{-}}^T$.
\end{enumerate}
\end{proof}
\begin{lemma}\label{NNTMinuslemma}
$M_{\alpha^{+}}M_{\alpha^{-}}^T + M_{\alpha^{-}}M_{\alpha^{+}}^T = M_{\alpha_4} + M_{\alpha_5} + M_{\alpha_6}$ where $\alpha_4,\alpha_5,\alpha_6$ are the following shapes.
\begin{enumerate}
\item $U_{\alpha_4} \setminus V_{\alpha_4} = \{i_{circ}\}$, $U_{\alpha_4} \cap V_{\alpha_4} = \{j_1,j_2,j_3,j_4,\ldots,j_{k}\}$, $V_{\alpha_4} \setminus U_{\alpha_4} = \{i'_{circ}\}$, and $E(\alpha_4) = \{(i,j_1),(i,j_2),$ $(i',j_1),(i',j_2)\}$.
\item $U_{\alpha_5} \setminus V_{\alpha_5} = \{j_1\} \cup \{i_{circ}\}$, $U_{\alpha_5} \cap V_{\alpha_5} = \{j_2,j_4,\ldots,j_{k}\}$, $V_{\alpha_5} \setminus U_{\alpha_5} = \{j'_1\} \cup \{i'_{circ}\}$, and $E(\alpha_5) = \{(i,j'_1),(i,j_2),(i',j_1),(i',j_2)\}$.
\item $U_{\alpha_6} \setminus V_{\alpha_6} = \{j_1,j_2\} \cup \{i_{circ}\}$, $U_{\alpha_6} \cap V_{\alpha_6} = \{j_5,\ldots,j_{k}\}$, $V_{\alpha_6} \setminus U_{\alpha_6} = \{j'_1,j'_2\} \cup \{i'_{circ}\}$, and $E(\alpha_6) = \{(i',j_1),(i',j_2),(i,j'_1),(i,j'_2)\}$.
\end{enumerate}
\end{lemma}
For pictures of these shapes, see Figure \ref{NNTMinusfigure} below.
\begin{figure}[ht]\label{NNTMinusfigure}
\centerline{\includegraphics[height=6cm]{sherrington_kirkpatrick/NNTMinus}}
\caption{This figure shows the decomposition of $M_{\alpha^{+}}M_{\alpha^{+}}^T + M_{\alpha^{-}}M_{\alpha^{-}}^T$.}
\end{figure}
\begin{proof}[Proof of Lemma \ref{NNTMinuslemma}]
We compute $M_{\alpha^{+}}M_{\alpha^{-}}^T + M_{\alpha^{-}}M_{\alpha^{+}}^T$ by considering the ribbons which appear in $M_{\alpha^{+}}M_{\alpha^{-}}^T + M_{\alpha^{-}}M_{\alpha^{+}}^T$. For these ribbons, we do not assume that $i < i'$.
\begin{enumerate}
\item Each ribbon $R$ with $A_R \setminus B_R = \{i_{circ}\}$, $A_R \cap B_R = \{j_1,j_2,j_3,j_4,\ldots,j_{k}\}$, $B_R \setminus A_R = \{i'_{circ}\}$, $V(R) \setminus (A_R \cup B_R) = \emptyset$, and $E(R) = \{(i,j_1),(i,j_2),(i',j_1),(i',j_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{j_1,j_2\}$, $A_{R_1} \cap B_{R_1} = \{j_3,j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_{R_1} \setminus A_{R_1} = \{i'_{circ}\}$, and $E(R_1) = \{(i',j_1),(i',j_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{i_{circ}\}$, $A_{R_2} \cap B_{R_2} = \{j_3,j_4,\ldots,j_{k}\} \cup \{i'_{circ}\}$, $B_{R_2} \setminus A_{R_2} = \{j_1,j_2\}$, and $E(R_2) = \{(i,j_1),(i,j_2)\}$.
\end{enumerate}
Whether $i < i'$ or $i' < i$ only affects whether this ribbon appears in $M_{\alpha^{+}}M_{\alpha^{-}}^T$ or $M_{\alpha^{-}}M_{\alpha^{+}}^T$.
\item Each ribbon $R$ with $A_R \setminus B_R = \{j_1\} \cup \{i_{circ}\}$, $A_R \cap B_R = \{j_2,j_4,\ldots,j_{k}\}$, $B_R \setminus A_R = \{j'_1\} \cup \{i'_{circ}\}$, $V(R) \setminus (A_R \cup B_R) = \emptyset$, and $E(R) = \{(i,j_1),(i,j_2),(i',j'_1),(i',j_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{j_1,j_2\}$, $A_{R_1} \cap B_{R_1} = \{j'_1,j_4,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_{R_1} \setminus A_{R_1} = \{i'_{circ}\}$, and $E(R_1) = \{(i',j_1),(i',j_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{i_{circ}\}$, $A_{R_2} \cap B_{R_2} = \{j_1,j_4,\ldots,j_{k}\} \cup \{i'_{circ}\}$, $B_{R_2} \setminus A_{R_2} = \{j'_1,j_2\}$, and $E(R_2) = \{(i,j'_1),(i,j_2)\}$.
\end{enumerate}
Whether $i < i'$ or $i' < i$ only affects whether this ribbon appears in $M_{\alpha^{+}}M_{\alpha^{-}}^T$ or $M_{\alpha^{-}}M_{\alpha^{+}}^T$.
\item Each ribbon $R$ with $A_R \setminus B_R = \{j_1,j_2\} \cup \{i_{circ}\}$, $A_R \cap B_R = \{j_5,\ldots,j_{k}\}$, $B_R \setminus A_R = \{j'_1,j'_2\} \cup \{i'_{circ}\}$, $V(R) \setminus (A_R \cup B_R) = \emptyset$, and $E(R) = \{(i,j'_1),(i,j'_2),(i',j_1),(i',j_2)\}$ appears in exactly one way as the composition of the ribbons $R_1$ and $R_2$ where
\begin{enumerate}
\item $A_{R_1} \setminus B_{R_1} = \{j_1,j_2\}$, $A_{R_1} \cap B_{R_1} = \{j_1,j_2,j_5,\ldots,j_{k}\} \cup \{i_{circ}\}$, $B_{R_1} \setminus A_{R_1} = \{i'_{circ}\}$, and $E(R_1) = \{(i,j'_1),(i,j'_2)\}$.
\item $A_{R_2} \setminus B_{R_2} = \{i_{circ}\}$, $A_{R_2} \cap B_{R_2} = \{j'_1,j'_2,j_5,\ldots,j_{k}\} \cup \{i'_{circ}\}$, $B_{R_2} \setminus A_{R_2} = \{j'_1,j'_2\}$, and $E(R_2) = \{(i,j_1),(i,j_2)\}$.
\end{enumerate}
Whether $i < i'$ or $i' < i$ only affects whether this ribbon appears in $M_{\alpha^{+}}M_{\alpha^{-}}^T$ or $M_{\alpha^{-}}M_{\alpha^{+}}^T$.
\end{enumerate}
\end{proof}
We now consider the norm bounds for these terms
\begin{enumerate}
\item $\norm{M_{\alpha_4}}$ is $\tilde{O}(m)$.
\item $\norm{M_{\alpha_5}}$ is $\tilde{O}(m)$.
\item $\norm{M_{\alpha_6}}$ is $\tilde{O}(n^2)$.
\end{enumerate}
This means that $M_{\alpha_6}$ cannot be ignored, but this is fine. In fact, the $M_{\alpha_6}$ here will cancel with the $M_{\alpha_6}$ that appears in the decomposition of ${L_k^T}L_k$
\begin{corollary}\label{NNTapproximationcorollary}
For all $k \geq 4$, $\norm{{N_k}{N_k}^T - 4M_{\alpha^{+}}M_{\alpha^{+}}^T - 4M_{\alpha^{-}}M_{\alpha^{-}}^T + 4M_{\alpha_6}}$ is $\tilde{O}(m)$.
\end{corollary}
\subsubsection{Putting Everything Together}
We now put everything together to prove that for all $k$, the minimum nonzero eigenvalue of ${L_k^T}{L_k}$ is $2n^2 - \tilde{O}(n\sqrt{m})$.
\begin{enumerate}
\item For $k = 2$, by Corollary \ref{QQTapproximationcorollary}, $\norm{{L_k^T}L_k - 2{n^2}M_{Id_{k-2,1}}}$ is $\tilde{O}(n\sqrt{m})$ so the minimum eigenvalue of ${L_k^T}{L_k}$ is $2n^2 - \tilde{O}(n\sqrt{m})$.
\item For $k = 3$, by Corollary \ref{QQTapproximationcorollary}, $\norm{{L_k^T}L_k - 2{n^2}M_{Id_{k-2,1}} - 4nM_{\beta_2}M^T_{\beta_2}}$ is $\tilde{O}(n\sqrt{m})$ so the minimum eigenvalue of ${L_k^T}{L_k}$ is $2n^2 - \tilde{O}(n\sqrt{m})$.
\item For $k \geq 4$, by Corollary \ref{QQTapproximationcorollary}, $\norm{{L_k^T}L_k - 2{n^2}M_{Id_{k-2,1}} - 4nM_{\beta_2}M^T_{\beta_2} - 4M_{\beta_3}M^T_{\beta_3} - 4M_{\alpha_6}}$ is $\tilde{O}(n\sqrt{m})$. By Corollary \ref{NNTapproximationcorollary}, $\norm{{N_k}{N_k}^T - 4M_{\alpha^{+}}M_{\alpha^{+}}^T - 4M_{\alpha^{-}}M_{\alpha^{-}}^T + 4M_{\alpha_6}}$ is $\tilde{O}(m)$. Combining these equations,
\[
\norm{{L_k^T}L_k + {N_k}{N_k}^T - 2{n^2}M_{Id_{k-2,1}} - 4nM_{\beta_2}M^T_{\beta_2} - 4M_{\beta_3}M^T_{\beta_3} - 4M_{\alpha^{+}}M_{\alpha^{+}}^T - 4M_{\alpha^{-}}M_{\alpha^{-}}^T}
\] is $\tilde{O}(n\sqrt{m})$ so the minimum eigenvalue of ${L_k^T}L_k + {N_k}{N_k}^T$ is $2n^2 - \tilde{O}(n\sqrt{m})$. Since the minimum nonzero eigenvalue of ${L_k^T}L_k$ is at least as large as the minimum eigenvalue of ${L_k^T}L_k + {N_k}{N_k}^T$, the nonzero eigenvalue of ${L_k^T}{L_k}$ is $2n^2 - \tilde{O}(n\sqrt{m})$.
\end{enumerate}
This implies that the minimum nonzero eigenvaue of $QQ^T$ is $2n^2 - \tilde{O}(n\sqrt{m})$, as needed.
\subsection{Importance of Scaling}\label{app:scaling}
We remark that somewhat surprisingly, the scaling of the problem is important for our arguments. The reason this is somewhat surprising is that for the purpose of determining whether or not a matrix $M$ is PSD, the scaling of the rows and columns of $M$ doesn't matter. More precisely, we have the following proposition.
\begin{proposition}
For any symmetric $N \times N$ matrix $M$ and any $N \times N$ diagonal matrix $D$ such that $\forall i \in [N], D_{ii} \neq 0$, $M \succeq 0$ if and only if $DMD \succeq 0$.
\end{proposition}
However, for our techniques, we also use the fact that if $x$ is in the nullspace of $M$ then for the purposes of determining whether $M$ is PSD, we can freely add a non-negative multiple of $xx^T$ to $M$.
\begin{proposition}\label{addingnullspaceprop}
For any symmetric $N \times N$ symmetric matrix $M$, any vector $x$ such that $Mx = 0$, and any constant $c $, $M \succeq 0$ if and only if $M+cxx^T \succeq 0$.
\end{proposition}
As shown by the following example, the set of matrices that can be obtained using Proposition \ref{addingnullspaceprop} depends on the scaling of $M$.
If $M = \begin{pmatrix}
1 & 1 & 2 \\
1 & 2 & 3 \\
2 & 3 & 5
\end{pmatrix}$, $x = \begin{pmatrix}
1\\
1\\
-1
\end{pmatrix}$, and $D = \begin{pmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & \lambda
\end{pmatrix}$
then $DMD = \begin{pmatrix}
1 & 1 & 2\lambda \\
1 & 2 & 3\lambda \\
2\lambda & 3\lambda & 5{\lambda}^2
\end{pmatrix}$ and
\[
DMD + cD^{-1}x{x^T}D^{-1} = \begin{pmatrix}
1 + c & 1 + c & 2\lambda - \frac{c}{\lambda} \\
1 + c & 2 + c & 3\lambda - \frac{c}{\lambda} \\
2\lambda - \frac{c}{\lambda} & 3\lambda - \frac{c}{\lambda} & 5{\lambda}^2 + \frac{c}{{\lambda}^2}
\end{pmatrix}
\]
Scaling this so that the diagonal entries are $1$ gives the matrix
\[
\begin{pmatrix}
1 & \frac{\sqrt{1+c}}{\sqrt{2+c}} & \frac{2\lambda - \frac{c}{\lambda}}{\sqrt{(1+c)(5{\lambda}^2 + \frac{c}{{\lambda}^2})}} \\
\frac{\sqrt{1+c}}{\sqrt{2+c}} & 1 & \frac{3\lambda - \frac{c}{\lambda}}{\sqrt{(2+c)(5{\lambda}^2 + \frac{c}{{\lambda}^2})}} \\
\frac{2\lambda - \frac{c}{\lambda}}{\sqrt{(1+c)(5{\lambda}^2 + \frac{c}{{\lambda}^2})}} & \frac{3\lambda - \frac{c}{\lambda}}{\sqrt{(2+c)(5{\lambda}^2 + \frac{c}{{\lambda}^2})}} & 1
\end{pmatrix}
\]
Note that the entries in the upper left $2 \times 2$ block only depend on $c$ and are different for each $c$ while the other off-diagonal entries also depend on $\lambda$. Thus, different $\lambda$ give different sets of matrices.
\section{Open Problems}\label{sec:open-problems}
We conjecture that for the Planted Affine Planes problem, the problem remains difficult even with the number of vectors increased to $m = n^{2 - \varepsilon}$.
\begin{conjecture}
\cref{theo:sos-bounds} holds with the bound on the number of sampled vectors $m$ loosened to $m \leq n^{2-\varepsilon}$.
\end{conjecture}
The reason for the upper bound comes from \cref{rmk:pe-one}. Analyzing $\tilde{\EE}[1]$ is an established way to hypothesize about the power of SoS in hypothesis testing problems (see \cite{hop17}, \cite{hop18}).
Dual to the Planted Affine Planes problem, we conjecture a similar
bound for Planted Boolean Vector problem whenever $d \geq
n^{1/2+\varepsilon}$.
\begin{conjecture}
\cref{theo:boolean-subspace} holds with the bound on the dimension $p$ of a random subspace
loosened to $p \geq n^{1/2+\varepsilon}$.
\end{conjecture}
We conjecture that the Planted Boolean Vector problem/Planted Affine
Planes problem is still hard for SoS if the input is no longer i.i.d.
Gaussian or boolean entries, but is drawn from a ``random enough''
distribution. For example, if in the random instance of PAP the vectors
$d_u$ are i.i.d. samples from $S^n$, or a random orthonormal system,
degree $n^\delta$ SoS should still believe the instance is satisfiable
(after appropriate normalization of $v$). Or, taking the view of Planted
Boolean Vector, if the subspace is the eigenspace of the bottom
eigenvectors of a random adjacency matrix, the instance should still be
difficult. This last setting arises in Maximum Cut, for which we conjecture the following.
\begin{conjecture}
Let $d \geq 3$, and let $G$ be a random $d$-regular graph on $n$ vertices. For some $\delta > 0$, w.h.p. there is a degree-$n^\delta$ pseudoexpectation operator $\tilde{\EE}$ on boolean variables $x_i$ with maximum cut value at least
\[ \frac{1}{2} + \frac{\sqrt{d-1}}{d}(1 - \operatorname{o}_{d,n}(1)) \]
\end{conjecture}
The above expression is w.h.p. the value of the spectral relaxation for Maximum Cut, therefore qualitatively this conjecture expresses that degree $n^\delta$ SoS cannot significantly tighten the basic spectral relaxation.
We should remark that, with respect to the goal of showing SoS cannot significantly outperform the Goemans-Williamson relaxation, random instances are not integrality gap instances. The main difficulty in comparing (even degree 4) SoS to the Goemans-Williamson algorithm seems to be the lack of a candidate hard input distribution.
Evidence for this conjecture comes from the fact that the only property
required of the random inputs $d_1, \dots, d_m$ was that norm bounds hold for
the graph matrix with Hermite polynomial entries. When the variables
$\{d_{u,i}\}$ are i.i.d from some other distribution, if we use graph matrices
for the orthonormal polynomials under the distribution and assuming suitable
bounds on the moments of the distribution, the same norm bounds
hold~\cite{AMP20}.
When $d_u \in_{\text{R}} S^n$ or another distribution for which the coordinates are not
i.i.d, it seems likely that if we use e.g. the spherical harmonics then
similar norm bounds hold, but this is not proven.
\subsection{Problem statements}
We introduce the Planted Affine Planes problem over a distribution ${\mathcal D}$.
\begin{definition}[Planted Affine Planes (PAP) problem]\label{def:prob:pap}
Given $d_1, \dots, d_m \sim {\mathcal D}$ where each $d_u$ is a vector in ${\mathbb R}^n$,
determine whether there exists $v \in \set{\pm \frac{1}{\sqrt{n}}}^n$ such that
\[
\ip{v}{d_u}^2 = 1,
\]
for every $u \in [m]$.
\end{definition}
Our results hold for the Gaussian setting $\mathcal{D} = {\mathcal N}(0, I)$ and the boolean setting where ${\mathcal D}$ is uniformly sampled from $\{\pm 1\}^n$, though we conjecture (\cref{sec:open-problems}) that similar SoS bounds hold under more general conditions on ${\mathcal D}$.
Observe that in both settings the solution vector $v$ is restricted to be Boolean (in the sense that the entries are either $\frac{1}{\sqrt{n}}$ or $\frac{-1}{\sqrt{n}}$) and an SoS lower bound for this restricted version of the problem is
stronger than when $v$ can be an arbitrary vector from ${\mathbb R}^n$.
The Sherrington--Kirkpatrick (SK) problem comes from the spin-glass model
in statistical physics~\cite{SK76}.
\begin{definition}[Sherrington-Kirkpatrick problem]\label{def:prob:sk}
Given $W \sim \GOE(n)$, compute
\[
\OPT(W) := \max_{x \in \{\pm 1\}^n} x^\intercal W x.
\]
\end{definition}
The Planted Boolean Vector problem was introduced by
Mohanty--Raghavendra--Xu~\cite{MRX20}, where it was called the
``Boolean Vector in a Random Subspace''.
\begin{definition}[Planted Boolean Vector problem]\label{def:prob:pbv}
Given a uniformly random $p$-dimensional subspace $V$ of $\mathbb{R}^n$ in the form of
a projector $\Pi_V$ onto $V$, compute
\[
\OPT(V) := \frac{1}{n}\max_{b \in \{\pm 1\}^n} b^\intercal \Pi_V b.
\]
\end{definition}
\subsection{Sum-of-Squares solutions}
We will work with two equivalent definitions of a degree-$D$ SoS
solution: a pseudoexpectation operator and a moment matrix. We tailor these
definitions to our setting of feasibility of systems of polynomial
equality constraints given by the common zero set of a collection of
polynomials ${\mathcal P}$ on $\pm \frac{1}{\sqrt{n}}$ Boolean variables
$v_1,\dots,v_n$. For a degree-$D$ solution to be well defined, we
need $D$ to be at least the maximum degree of a polynomial in
${\mathcal P}$. Let ${\mathbb R}^{\le D}(v_1,\dots,v_n)$ be the subset of
polynomials of degree at most $D$ from the polynomial ring
${\mathbb R}(v_1,\dots,v_n)$. We denote the degree of a polynomial
$f \in {\mathbb R}(v_1,\dots,v_n)$ by $\deg(f)$.
\subsubsection{Pseudoexpectation operator}
We formally define the pseudoexpectation operators used in our setting.
\begin{definition}[Pseudoexpectation]\label{def:pseudoexpectation}
Given a finite collection of ``constraint'' polynomials ${\mathcal P}$ of degree at most $D$ on $\pm \frac{1}{\sqrt{n}}$ Boolean variables $v_1,\dots,v_n$,
a degree-$D$ pseudoexpectation operator $\tilde{\EE}$ is an operator
$\tilde{\EE} \colon {\mathbb R}^{\le D}(v_1,\dots,v_n) \rightarrow \mathbb{R}$ satisfying:
\begin{enumerate}
\item $\tilde{\EE}[1] = 1$, \label{pe:normalized}
\item $\tilde{\EE}$ is an ${\mathbb R}$-linear operator, i.e., $\tilde{\EE}[f+g] = \tilde{\EE}[f] + \tilde{\EE}[g]$ for every $f,g \in {\mathbb R}^{\le D}(v_1,\dots,v_n)$, \label{pe:linear}
\item $\tilde{\EE}[f^2] \ge 0$ for every $f \in {\mathbb R}^{\le D}(v_1,\dots,v_n)$ with $\deg(f^2) \le D$. \label{pe:psdness}
\item $\tilde{\EE}[(v_i^2-\frac{1}{n}) \cdot f] = 0$ for all $i \in [n]$ and for every $f \in {\mathbb R}^{\le D}(v_1,\dots,v_n)$ with $\deg(f) \le D-2$, and \label{pe:boolean}
\item $\tilde{\EE}[g \cdot f] = 0$ for every $g \in {\mathcal P}, f \in {\mathbb R}^{\le D}(v_1,\dots,v_n)$ with $\deg(f \cdot g) \le D$. \label{pe:feasible}
\end{enumerate}
\end{definition}
Note that $\tilde{\EE}$ behaves similarly to an expectation operator
restricted to ${\mathbb R}^{\le D}(v_1,\dots,v_n)$ with the caveat that $\tilde{\EE}$
is only guaranteed to be non-negative on sum-of-squares polynomials.
The degree-$D$ SoS algorithm checks feasibility of a polynomial system by
checking whether or not a degree-$D$ pseudoexpectation operator exists. To
show an SoS lower bound, one must construct a pseudoexpectation
operator.
\subsubsection{Moment matrix}\label{sec:moment-mtx}
We define
the moment matrix associated with a degree-$D$
pseudoexpectation $\tilde{\EE}$.
\begin{definition}[Moment Matrix of $\tilde{\EE}$]
The moment matrix ${\mathcal M}={\mathcal M}(\tilde{\EE})$ associated to a pseudoexpectation $\tilde{\EE}$ is a
$\binom{[n]}{\leq D/2} \times \binom{[n]}{\leq D/2}$ matrix with rows and columns indexed
by subsets of $I, J \subseteq [n]$ of size at most $D/2$ and defined as
\[
{\mathcal M}[I, J] := \tilde{\EE}\left[ v^I \cdot v^J \right].
\]
\end{definition}
To show that a candidate pseudoexpectation satisfies~\cref{pe:psdness} in~\cref{def:pseudoexpectation}, we will rely on the following standard fact.
\begin{fact}
In the definition of pseudoexpectation, \cref{def:pseudoexpectation}, the condition in \cref{pe:psdness} is equivalent to ${\mathcal M} \succeq 0$.
\end{fact}
\subsection{Graph matrices}
To study ${\mathcal M}$, we decompose it using the framework of \textit{graph matrices}. Originally developed in the context of the planted clique problem, graph matrices are random matrices whose entries are symmetric functions of an underlying random object -- in our case, the set of vectors $d_1, \dots, d_m$. We take the general presentation and results from~\cite{AMP20}. For our purposes, the following definitions are sufficient.
The graphs that we study have two types of vertices, circles $\circle{}$ and squares $\square{}$. We let ${\mathcal C}_m$ be a set of $m$ circles labeled 1 through $m$, which we denote by $\circle{1}, \circle{2}, \dots, \circle{m}$, and let ${\mathcal S}_n$ be a set of $n$ squares labeled 1 through $n$, which we denote by $\square{1}, \square{2}, \dots, \square{n}$. We will work with bipartite graphs with edges between circles and squares, which have positive integer labels on the edges. When there are no multiedges (the graph is simple), such graphs are in one-to-one correspondence with Fourier characters on the vectors $d_u$. An edge between $\circle{u}$ and $\square{i}$ with label $l$ represents $h_{l}(d_{u,i})$ where $\{h_k\}$ is the Fourier basis (e.g. Hermite polynomials).
\[ \text{simple graph with labeled edges} \qquad \Longleftrightarrow \qquad \displaystyle\prod_{\substack{\circle{u} \in {\mathcal C}_m,\\ \square{i} \in {\mathcal S}_n}} h_{l(\circle{u}, \square{i})}(d_{u,i}) \]
An example of a Fourier polynomial as a graph with labeled edges is given in~\cref{fig:fourier_graph}. Unlabeled edges are implicitly labeled 1.
\begin{figure}[h!]
\centering
\begin{tikzpicture}[scale=0.5,every node/.style={scale=0.5}]
\draw (-2,3) rectangle node {\huge $i_1$}(-0.5,1.5) node (v5) {};
\draw (3,1) ellipse (1 and 1) node {\huge $u$};
\draw (6.5,3) rectangle node (v10) {\huge $j_1$} (8,1.5);
\draw (-2,0) rectangle node {\huge $i_2$} (-0.5,-1.5);
\draw (6.5,0) rectangle node {\huge $j_2$} (8,-1.5);
\node (v1) at (-0.5,3) {};
\node (v4) at (-0.5,2.25) {};
\node (v6) at (6.5,2.25) {};
\node (v8) at (-0.5,-0.75) {};
\node (v9) at (6.5,-0.75) {};
\node at (-0.5,0) {};
\node (v2) at (2,1) {};
\node at (2,1.5) {};
\node (v7) at (6.5,1.5) {};
\node (v3) at (4,1) {};
\draw plot[smooth, tension=.7] coordinates {(v3)};
\draw plot[smooth, tension=.7] coordinates {(v3)};
\draw plot[smooth, tension=.7] coordinates {(v2) (0.5,2) (v4)};
\node at (1,2.2) {\huge $3$};
\draw plot[smooth, tension=.7] coordinates {(v3) (5,2) (v6)};
\draw plot[smooth, tension=.7] coordinates {(v3)};
\draw plot[smooth, tension=.7] coordinates {(v2) (1,-0.5) (v8)};
\draw plot[smooth, tension=.7] coordinates {(v3) (5,-0.5) (v9)};
\node at (6.5,3) {};
\draw plot[smooth, tension=.7] coordinates {(v3)};
\draw plot[smooth, tension=.7] coordinates {(v3)};
\draw plot[smooth, tension=.7] coordinates {(v10)};
\node at (6.5,3) {};
\draw (2,5.5) rectangle node {\huge $w_1$} (3.5,4);
\node (v11) at (2.5,4) {};
\node (v13) at (3,4) {};
\node (v12) at (3,2) {};
\draw plot[smooth, tension=.7] coordinates {(v12) (3,3) (3,4)};
\node at (2.5,3) {\huge $2$};
\end{tikzpicture}
\caption{The Fourier polynomial $h_3(d_{u,i_1})h_1(d_{u,i_2})h_2(d_{u,w_1})h_1(d_{u,j_1})h_1(d_{u,j_2})$ represented as a graph.}
\label{fig:fourier_graph}
\end{figure}
Define the degree of a vertex $v$, denoted $\deg(v)$, to be the sum of the labels incident to $v$, and $\abs{E}$ to be the sum of all labels. For
intuition it is mostly enough to work with simple graphs, in which case these quantities make sense as the edge multiplicities in an implicit multigraph.
\begin{definition}[Proper]
We say an edge-labeled graph is \textit{proper} if it has no multiedges.
\end{definition}
The definitions allow for ``improper'' edge-labeled multigraphs which simplify multiplying graph matrices (\cref{sec:single-spider} and \cref{sec:exact-constraints}).
\begin{definition}[Matrix indices]
A \textit{matrix index} is a set $A$ of elements from ${\mathcal C}_m \cup {\mathcal S}_n$.
\end{definition}
We let $A(\square{i})$ or $A(\circle{u})$ be 0 or 1 to indicate if the vertex is in $A$.
\begin{definition}[Ribbons]\label{def:ribbon}
A \textit{ribbon} is an undirected, edge-labeled graph $R = (V(R), E(R), A_R, B_R)$, where $V(R) \subseteq {\mathcal C}_m\cup {\mathcal S}_n$ and $A_R, B_R$ are two matrix indices (possibly not disjoint) with $A_R, B_R \subseteq V(R)$, representing two distinguished sets of vertices. Furthermore, all edges in $E(R)$ go between squares and circles.
\end{definition}
We think of $A_R$ and $B_R$ as being the ``left'' and ``right'' sides of $R$, respectively. We also define the set of ``middle vertices'' $C_R := V(R) \setminus (A_R \cup B_R)$. If $e \not\in E(R)$, then we define its label $l(e) = 0$. We also abuse notation and write $l(\square{i}, \circle{u})$ instead of $l(\{\square{i}, \circle{u}\})$.
Akin to the picture above, each ribbon corresponds to a Fourier polynomial.
This Fourier polynomial lives inside a single entry of the matrix $M_R$.
In the definition below, the $h_k(x)$ are the Fourier basis corresponding to the respective setting. In the Gaussian case, they are the (unnormalized) Hermite polynomials, and in the boolean case, they are just the parity function, represented by
\[h_0(x) = 1, \qquad h_1(x) = x, \qquad h_k(x) = 0 \;\; (k \geq 2) \]
\begin{definition}[Matrix for a ribbon]\label{def:ribbon-matrix}
The matrix $M_R$ has rows and columns indexed by subsets of ${\mathcal C}_m~\cup~{\mathcal S}_n$, with a single nonzero entry defined by
\[M_R[I, J] = \left\{\begin{array}{lr}
\displaystyle\prod_{\substack{e \in E(R), \\ e = \{\square{i}, \circle{u}\}}} h_{l(e)}(d_{u,i}) & I = A_R, J = B_R\\
0 & \text{Otherwise}
\end{array}\right. \]
\end{definition}
Next we describe the shape of a ribbon, which is essentially the ribbon when we have forgotten all the vertex labels and retained only the graph structure and the distinguished sets of vertices.
\begin{definition}[Index shapes]
An \textit{index shape} is a set $U$ of formal variables. Furthermore, each variable is labeled as either a ``circle'' or a ``square''.
\end{definition}
We let $U(\square{i})$ and $U(\circle{u})$ be either 0 or 1 for whether $\square{i}$ or $\circle{u}$, respectively, is in $U$.
\begin{definition}[Shapes]\label{def:shape}
A \textit{shape} is an undirected, edge-labeled graph $\alpha = (V(\alpha), E(\alpha), U_\alpha, V_\alpha)$ where $V(\alpha)$ is a set of formal variables, each of which is labeled as either a ``circle'' or a ``square''. $U_\alpha$ and $V_\alpha$ are index shapes (possibly with variables in common) such that $U_\alpha, V_\alpha \subseteq V(\alpha)$. The edge set $E(\alpha)$ must only contain edges between the circle variables and the square variables.
\end{definition}
We'll also use $W_\alpha := V(\alpha) \setminus (U_\alpha \cup V_\alpha)$ to denote the ``middle vertices'' of the shape.
\begin{remk}
We will abuse notation and use $\square{i}, \square{j}, \circle{u}, \circle{v}, \ldots$ for both the vertices of ribbons and the vertices of shapes. If they are ribbon vertices, then the vertices are elements of ${\mathcal C}_m\cup{\mathcal S}_n$ and if they are shape vertices, then they correspond to formal variables with the appropriate type.
\end{remk}
\begin{definition}[Trivial shape]
Define a shape $\alpha$ to be trivial if $U_\alpha = V_\alpha$, $W_\alpha = \emptyset$ and $E(\alpha) = \emptyset$.
\end{definition}
\begin{definition}[Transpose of a shape]
The transpose of a shape $\alpha = (V(\alpha), E(\alpha), U_\alpha, V_\alpha)$ is defined
to be the shape $\alpha^{\intercal} = (V(\alpha), E(\alpha), V_\alpha, U_\alpha)$.
\end{definition}
For a shape $\alpha$ and an injective map $\sigma :
V(\alpha) \rightarrow {\mathcal C}_m \cup {\mathcal S}_n$, we define the
realization $\sigma(\alpha)$ as a ribbon in the natural
way, by labeling all the variables using the map
$\sigma$. We also require $\sigma$ to be
type-preserving i.e. it takes square variables to ${\mathcal S}_n$ and circle variables to ${\mathcal C}_m$.
The ribbons that result are referred to as \textit{ribbons of shape $\alpha$}; notice that this partitions the set of all ribbons according to their shape\footnote{Partitions up to equality of shapes, where two shapes are equal if there is a type-preserving bijection between their variables that converts one shape to the other. When we operate on sets of shapes below, we implicitly use each distinct shape only once.}\footnote{Note that in our definition two realizations of a shape may give the same ribbon.}.
Finally, given a shape $\alpha$, the graph matrix $M_\alpha$ consists of all Fourier characters for ribbons of shape $\alpha$.
\begin{definition}[Graph matrices]\label{def:graph-matrix}
Given a shape $\alpha = (V(\alpha), E(\alpha), U_\alpha, V_\alpha)$, the \textit{graph matrix} $M_\alpha$ is
\[M_\alpha = \displaystyle\sum_{R \text{ is a ribbon of shape }\alpha} M_R\]
\end{definition}
The moment matrix for PAP will turn out to be defined using graph matrices $M_\alpha$ whose left and right sides only have square vertices, and no circles. However, in the course of the analysis we will factor and multiply graph matrices with circle vertices in the left or right.
\subsection{Norm bounds}
The spectral norm of a graph matrix is determined, up to logarithmic factors, by relatively simple combinatorial properties of the graph. For a subset $S \subseteq {\mathcal C}_m \cup {\mathcal S}_n$, we define the weight $w(S)~:=~(\#\text{ circles in }S)\cdot \log_n(m)+ (\#\text{ squares in }S)$. Observe that $n^{w(S)} = m^{\# \text{ circles in }S}\cdot n^{\#\text{ squares in }S}$.
\begin{definition}[Minimum vertex separator]
For a shape $\alpha$, a set $S_{\min}$ is a minimum vertex separator if all paths from $U_\alpha$ to $V_\alpha$ pass through $S_{\min}$ and $w(S_{\min})$ is minimized over all such separating sets.
\end{definition}
Let $W_{iso}$ denote the set of isolated vertices in $W_\alpha$. Then essentially the following norm bound holds for all shapes $\alpha$ with high probability (a formal statement can be found in~\cref{app:norm_bounds}):
\[\norm{M_\alpha} \leq \widetilde\operatorname{O}\left(n^{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}}\right)\]
In fact, the only probabilistic property required of the inputs $d_1, \dots, d_m$ by our proof is that the above norm bounds hold for all shapes that arise in the analysis.
We henceforth assume that the norm bounds in~\cref{lem:gaussian-norm-bounds} (for the Gaussian case) and~\cref{lem:norm-bounds} (for the boolean case) hold.
\subsection{Non-spiders are negligible}
For non-spiders, we will now show that their norm is small. We point out that this norm bound on non-spiders critically relies on the assumption $m \leq n^{3/2 - \varepsilon}$.
\begin{lemma}\label{lem:charging}
If $\alpha \in {\mathcal L}$ is not a trivial shape and not a spider, then
\[\frac{1}{n^{|E(\alpha)|/2}} n^{\frac{w(V(\alpha)) - w(S_{\min})}{2}} \le \frac{1}{n^{\Omega(\varepsilon |E(\alpha)|)}}\]
where $S_{min}$ is the minimum vertex separator of $\alpha$.
\end{lemma}
\begin{proof}
The idea behind the proof is as follows. Each square vertex which is not in the minimum vertex separator contributes $\sqrt{n}$ to the norm bound while each circle vertex which is not in the minimum vertex separator contributes $\sqrt{m}$. To compensate for this, we will try and take the factor of $\frac{1}{\sqrt{n}}$ from each edge and distribute it among its two endpoints so that each square vertex which is not in the minimum vertex separator is assigned a factor of $\frac{1}{\sqrt{n}}$ or smaller and each circle vertex which is not in the minimum vertex separator is assigned a factor of $\frac{1}{\sqrt{m}}$ or smaller.
\begin{remark}
Instead of using the minimum vertex separator, we will actually use a set $S$ of square vertices such that $w(S) \leq w(S_{\min})$. For details, see the actual distribution scheme below.
\end{remark}
To motivate the distribution scheme which we use, we first give two attempts which don't quite work. For simplicity, for these first two attempts we assume that $U_{\alpha} \cap V_{\alpha} = \emptyset$ as vertices in $U_{\alpha} \cap V_{\alpha}$ can essentially be ignored.
\begin{enumerate}
\item[] Attempt 1: Take each edge and assign a factor of $\frac{1}{\sqrt[4]{n}}$ to its square endpoint and a factor of $\frac{1}{\sqrt[8]{m}}$ to its circle endpoint.
With this distribution scheme, since each circle vertex has degree at least $4$, each circle vertex is assigned a factor of $\frac{1}{\sqrt{m}}$ or smaller. Since each square vertex in $W_{\alpha}$ has degree at least $2$, each square vertex in $W_{\alpha}$ is assigned a factor of $\frac{1}{\sqrt{n}}$ or smaller. However, square vertices in $U_{\alpha} \cup V_{\alpha}$ may only have degree $1$ in which case they are assigned a factor of $\frac{1}{\sqrt[4]{n}}$ which is not small enough.
To fix this issue, we can have all of the edges which are incident to a square vertex in $U_{\alpha} \cup V_{\alpha}$ give their entire factor of $\frac{1}{\sqrt{n}}$ to the square vertex.
\begin{remark}\label{rmk:pe-one}
For analyzing $\tilde{\EE}[1]$, this first attempt works as $U_{\alpha} = V_{\alpha} = \emptyset$. Thus, as long as $m \leq n^{2 - \varepsilon}$, with high probability $\tilde{\EE}[1] = 1 \pm \operatorname{o}_n(1)$ .
\end{remark}
\item[] Attempt 2: For each edge which is between a square vertex in $U_{\alpha} \cup V_{\alpha}$ and a circle vertex, we assign a factor of $\frac{1}{\sqrt{n}}$ to the square vertex and nothing to the circle vertex. For all other edges, we assign a factor of $\frac{1}{\sqrt[4]{n}}$ to its square endpoint and a factor of $\frac{1}{\sqrt[6]{m}}$ to its circle endpoint (which we can do because $m \leq n^{\frac{3}{2} - \varepsilon}$).
With this distribution scheme, each square vertex is assigned a factor of $\frac{1}{\sqrt{n}}$. Since $\alpha$ is not a spider, no circle vertex is adjacent to two vertices in $U_{\alpha}$ or $V_{\alpha}$. Thus, any circle vertex which is not adjacent to both a square vertex in $U_{\alpha}$ and a square vertex in $V_{\alpha}$ must be adjacent to at least $3$ square vertices in $W_{\alpha}$ and is thus assigned a factor of $\frac{1}{\sqrt{m}}$ or smaller. However, we can have circle vertices which are adjacent to both a square vertex in $U_{\alpha}$ and a square vertex in $V_{\alpha}$. These circle vertices may be assigned a factor of $\frac{1}{\sqrt[3]{m}}$, which is not small enough.
To fix this, observe that whenever we have a circle vertex which is adjacent to both a square vertex in $U_{\alpha}$ and a square vertex in $V_{\alpha}$, this gives a path of length $2$ from $U_{\alpha}$ to $V_{\alpha}$. Any vertex separator must contain one of the vertices in this path, so we can put one of these two square vertices in $S$ and not assign it a factor of $\frac{1}{\sqrt{n}}$.
\item[] Actual distribution scheme: Based on these observations, we use the following distribution scheme. Here we are no longer assuming that $U_{\alpha} \cap V_{\alpha}$ is empty.
\begin{enumerate}
\item[1.] Choose a set of square vertices $S \subseteq U_{\alpha} \cup V_{\alpha}$ as follows. Start with $S = U_{\alpha} \cap V_{\alpha}$. Whenever we have a circle vertex which is adjacent to both a square vertex in $U_{\alpha} \setminus V_{\alpha}$ and a square vertex in $V_{\alpha} \setminus U_{\alpha}$, put one of these two square vertices in $S$ (this choice is arbitrary). Observe that $w(S) \leq w(S_{\min})$
\item[2.] For each edge which is incident to a square vertex in $S$, assign a factor of $\frac{1}{\sqrt[3]{m}}$ to its circle endpoint and nothing to this square.
\item[3.] For each edge which is incident to a square vertex in $(U_{\alpha} \cup V_{\alpha}) \setminus S$, assign a factor of $\frac{1}{\sqrt{n}}$ to the square vertex and nothing to the circle vertex.
\item[4.] For all other edges, assign a factor of $\frac{1}{\sqrt[4]{n}}$ to its square endpoint and a factor of $\frac{1}{\sqrt[6]{m}}$ to its circle endpoint.
\end{enumerate}
Now each square vertex which is not in $S$ is assigned a factor of $\frac{1}{\sqrt{n}}$ and since $\alpha$ is not a spider, all circle vertices are assigned a factor of $\frac{1}{\sqrt{m}}$ or smaller.
\end{enumerate}
We now make this argument formal.
Let ${\mathcal C}_{\alpha}$ and ${\mathcal S}_{\alpha}$ be the set of circle vertices and the set of square vertices in $\alpha$ respectively. We have $ n^{\frac{w(V(\alpha)) - w(S_{\min})}{2}} \leq n^{0.5|{\mathcal S}_{\alpha} \setminus S_{min}| + (0.75 - \frac{\varepsilon}{2})|{\mathcal C}_{\alpha} \setminus S_{min}|}$. So, it suffices to prove that
\[|E(\alpha)| - |{\mathcal S}_{\alpha} \setminus S_{min}| - (1.5 - \varepsilon)|{\mathcal C}_{\alpha} \setminus S_{min}| \ge \Omega(\varepsilon |E(\alpha)|)\]
Let $Q = U_{\alpha} \cap V_{\alpha}, P = (U_{\alpha} \cup V_{\alpha}) \setminus Q$ and let $P'$ be the set of vertices of $P$ that have degree $1$ and are not in $S_{min}$. Let $E_1$ be the set of edges incident to $P'$ and let $E_2 = E(\alpha) \setminus E_1$.
For each vertex $\square{i}$ (resp. $\circle{u}$), let the number of edges of $E_2$ incident to it be $\deg'(\square{i})$ (resp. $\deg'(\circle{u})$). Since $\alpha$ is bipartite, we have that $|E_2| = \sum_{\square{i} \in {\mathcal S}_{\alpha}} \deg'(\square{i}) = \sum_{\circle{u} \in {\mathcal C}_{\alpha}} \deg'(\circle{u})$. We get that
\[|E(\alpha)| = |E_1| + |E_2| = |P'| + \frac{1}{2}(\sum_{\square{i} \in {\mathcal S}_{\alpha}} \deg'(\square{i}) + \sum_{\circle{u} \in {\mathcal C}_{\alpha}} \deg'(\circle{u}))\]
We also have $|S_{\alpha} \setminus S_{min}| \le |P'| + |{\mathcal S}_{\alpha} \cap W_{\alpha}| + |{\mathcal S}_{\alpha} \cap (P \setminus P')| \le |P'| + \frac{1}{2} \sum_{\square{i} \in {\mathcal S}_{\alpha}} \deg'(\square{i})$ because each square vertex outside $P' \cup Q$ has degree at least $2$ and is not incident to any edge in $E_1$. So, it suffices to prove
\[\frac{1}{2}\sum_{\circle{u} \in {\mathcal C}_{\alpha}} \deg'(\circle{u}) - (1.5 - \varepsilon)|{\mathcal C}_{\alpha} \setminus S_{min}| \ge \Omega(\varepsilon |E(\alpha)|)\]
Now, observe that each $\circle{u} \in {\mathcal C}_{\alpha}$ is incident to at most two edges in $E_1$. This is because if it were adjacent to at least $3$ edges in $E_1$, then either $\circle{u}$ is adjacent to at least two vertices of degree $1$ in $U_{\alpha}$ or $\circle{u}$ is adjacent to at least two vertices of degree $1$ in $V_{\alpha}$. However, this cannot happen since $\alpha$ is not a spider. This implies that $\deg'(\circle{u}) \ge \deg(\circle{u}) - 2$.
Note moreover that if $\circle{u} \in {\mathcal C}_{\alpha} \setminus S_{min}$, we have that $\deg'(\circle{u}) \ge \deg(\circle{u}) - 1$. This is because, building on the preceding argument, $\deg'(\circle{u}) = \deg(\circle{u}) - 2$ can only happen if there exist $\square{i} \in U_{\alpha}, \square{j} \in V_{\alpha}$ such that $(\square{i}, \circle{u}), (\square{j}, \circle{u}) \in E_1$. But then, note that we have $\square{i}, \square{j} \not\in S_{min}$ by definition of $P'$ and also, $\circle{u} \not\in S_{min}$ by assumption. This means that there is a path from $U_{\alpha}$ to $V_{\alpha}$ which does not pass through $S_{min}$, which is a contradiction.
Finally, we set $\varepsilon$ small enough such that the following inequalities are true, both of which follow from the fact that $\deg(\circle{u}) \ge 4$ for all $\circle{u} \in {\mathcal C}_{\alpha}$.
\begin{enumerate}
\item For any $\circle{u} \in {\mathcal C}_{\alpha} \cap S_{min}$, we have $\frac{\deg(\circle{u}) - 2}{2} \ge \frac{\varepsilon}{10}\deg(\circle{u})$.
\item For any $\circle{u} \in {\mathcal C}_{\alpha} \setminus S_{min}$, we have $\frac{\deg(\circle{u}) - 1}{2} - 1.5 + \varepsilon \ge \frac{\varepsilon}{10}\deg(\circle{u})$.
\end{enumerate}
Using this, we get
\begin{align*}
\frac{1}{2}\sum_{\circle{u} \in {\mathcal C}_{\alpha}} \deg'(\circle{u})& - (1.5 - \varepsilon)|{\mathcal C}_{\alpha} \setminus S_{min}| \\
&\ge \sum_{\circle{u} \in {\mathcal C}_{\alpha} \cap S_{min}}
\frac{\deg(\circle{u}) - 2}{2} + \sum_{\circle{u} \in {\mathcal C}_{\alpha} \setminus S_{min}}
\frac{\deg(\circle{u}) - 1}{2} - (1.5 - \varepsilon)|{\mathcal C}_{\alpha} \setminus S_{min}|\\
&\ge \sum_{\circle{u} \in {\mathcal C}_{\alpha} \cap S_{min}}
\frac{\varepsilon}{10}\deg(\circle{u}) + \sum_{\circle{u} \in {\mathcal C}_{\alpha} \setminus S_{min}} \left(\frac{\deg(\circle{u}) - 1}{2} - 1.5 + \varepsilon\right)\\
&\ge \sum_{\circle{u} \in {\mathcal C}_{\alpha} \cap S_{min}}
\frac{\varepsilon}{10}\deg(\circle{u}) + \sum_{\circle{u} \in {\mathcal C}_{\alpha} \setminus S_{min}}
\frac{\varepsilon}{10}\deg(\circle{u})\\
&= \sum_{\circle{u} \in {\mathcal C}_{\alpha}} \frac{\varepsilon}{10}\deg(\circle{u}) = \Omega(\varepsilon|E(\alpha)|)
\end{align*}
\end{proof}
Since ${\mathcal L}_{bool} \subseteq {\mathcal L}$, the above result extends to non-trivial non spider shapes in ${\mathcal L}_{bool}$ too.
\begin{corollary}
If $\alpha \in {\mathcal L}_{bool}$ is not a trivial shape and not a spider, then
\[\frac{1}{n^{|E(\alpha)|/2}} n^{\frac{w(V(\alpha)) - w(S_{\min})}{2}} \le \frac{1}{n^{\Omega(\varepsilon |E(\alpha)|)}}\]
\end{corollary}
\begin{corollary}\label{cor:non_spider_killing}
If $\alpha \in {\mathcal L}$ is not a trivial shape and not a spider, then w.h.p. \[\frac{1}{n^{|E(\alpha)|/2}}\norm{M_{\alpha}} \le \frac{1}{n^{\Omega(\varepsilon |E(\alpha)|)}}\]
\end{corollary}
\begin{proof}
Using the norm bounds in~\cref{lem:gaussian-norm-bounds}, we have
{\footnotesize\begin{align*}
\norm{M_\alpha} \leq 2\cdot\left(\abs{V(\alpha)} \cdot (1+\abs{E(\alpha)}) \cdot \log(n)\right)^{C\cdot (\abs{V_{rel}(\alpha)} + \abs{E(\alpha)})} \cdot n^q{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}}
\end{align*}}
We have $W_{iso} = \emptyset$. Observe that since there are no degree $0$ vertices in $V_{rel}(\alpha)$, we have that $|V_{rel}(\alpha)| \le 2|E(\alpha)|$ and since we also have $|V(\alpha)|\cdot (1+\abs{E(\alpha)})\cdot \log n \le n^{O(\tau)}$, the factor $2\cdot(\abs{V(\alpha)} \cdot (1+\abs{E(\alpha)}) \cdot \log(n))^{C\cdot (\abs{V_{rel}(\alpha)} + \abs{E(\alpha)})}$ can be absorbed into $\frac{1}{n^{\Omega(\varepsilon |E(\alpha)|)}}$. The result follows from~\cref{lem:charging}.
\end{proof}
This says that nontrivial non-spider shapes have $\operatorname{o}_n(1)$ norm (ignoring the extra factor $\eta$ for the moment). We now demonstrate how to use this norm bound to control the total norm of all non-spiders in a block of ${\mathcal M}$,~\cref{cor:non-spider-sum}. We will first need a couple propositions which will also be of use to us later after we kill the spiders.
\begin{proposition}\label{prop:edge-shape-count}
The number of proper shapes with at most $L$ vertices and exactly $k$ edges is at most $L^{8(k+1)}$.
\end{proposition}
\begin{proof}
The following process captures all shapes (though many will be constructed multiple times):
\begin{itemize}
\item Choose the number of square and circle variables in each of the four sets $U \cap V, U \setminus (U \cap V), V \setminus (U \cap V), W$. This contributes a factor of $L^{8}$.
\item Place each edge between two of the vertices. This contributes a factor of $L^{2 k}$.
\end{itemize}
\end{proof}
\begin{proposition}\label{prop:coefficient-bound}
$\abs{\lambda_\alpha} \leq \eta^{\abs{U_\alpha} + \abs{V_\alpha}} \cdot \frac{\abs{E(\alpha)}^{3\cdot \abs{E(\alpha)}}}{n^{\abs{E(\alpha)}/2}}$ where we assume by convention that $0^0 = 1$.
\end{proposition}
\begin{proof}
\noindent\textbf{(Gaussian setting)} Recall that the coefficients $\lambda_\alpha$ are either zero or are defined by the formula
\[\lambda_\alpha = \eta^{\abs{U_\alpha} + \abs{V_\alpha}}\cdot \left( \prod_{\circle{u}\in V(\alpha)} h_{\deg(\circle{u})}(1)\right)
\cdot \frac{1}{ n^{\abs{E(\alpha)}/2}}
\cdot \frac{1}{\alpha!}\]
The sequence $h_k(1)$ satisfies the recurrence $h_0(1) = h_1(1) = 1, h_{k + 1}(1) = h_k(1) - kh_{k - 1}(1)$. We can prove by induction that $\abs{h_k(1)} \le k^k$ and hence,
\[\prod_{\circle{u}\in V(\alpha)} \abs{h_{\deg(\circle{u})}(1)} \le \prod_{\circle{u}\in V(\alpha)} (\deg(\circle{u}))^{\deg(\circle{u})} \le \abs{E(\alpha)}^{\abs{E(\alpha)}}.\]
\noindent\textbf{(Boolean setting)} In the boolean setting the coefficients $\lambda_\alpha$ are defined by
\[\lambda_\alpha = \eta^{\abs{U_\alpha} + \abs{V_\alpha}} \cdot \left(\prod_{\circle{u} \in V(\alpha)} e(\deg(\circle{u})) \right)\]
Using~\cref{cor:bound_on_coeff_e_k}, we have that $\abs{e(k)} \le k^{3k} \cdot n^{-k/2}$. Thus,
\[
\abs{\lambda_\alpha} = \eta^{\abs{U_\alpha} + \abs{V_\alpha}} \cdot \prod_{\circle{u} \in V(\alpha)} \abs{e(\deg(\circle{u}))} \le \eta^{\abs{U_\alpha} + \abs{V_\alpha}} \cdot \frac{\abs{E(\alpha)}^{3\abs{E(\alpha)}}}{n^{\abs{E(\alpha)}/2}}.
\]
\end{proof}
\begin{corollary}\label{cor:non-spider-sum}
For $k, l \in \{0, 1, \dots , D/2\}$, let ${\mathcal B}_{k,l} \subseteq {\mathcal L}$ denote the set of nontrivial, non-spiders $\alpha \in {\mathcal L}$ on the $(k,l)$ block i.e. $\abs{U_\alpha} = k, \abs{V_\alpha} = l$. The total norm of the non-spiders in ${\mathcal B}_{k, l}$ satisfies
\[\sum_{\alpha \in {\mathcal B}_{k, l}} \abs{\lambda_\alpha} \norm{M_\alpha} = \eta^{k + l} \cdot \frac{1}{n^{\Omega(\varepsilon)}} \]
\end{corollary}
\begin{proof}
\begin{align*}
\sum_{\alpha \in {\mathcal B}_{k, l}} \abs{\lambda_\alpha} \norm{M_\alpha} & \leq \sum_{\alpha \in {\mathcal B}_{k, l}}\eta^{k+l} \cdot \frac{\abs{E(\alpha)}^{3\abs{E(\alpha)}}}{n^{\abs{E(\alpha)}/2}} \norm{M_\alpha} && \text{(\cref{prop:coefficient-bound})}\\
& \leq \eta^{k+l} \cdot\sum_{\alpha \in {\mathcal B}_{k, l}}\left(\frac{\abs{E(\alpha)}^3}{n^{\Omega(\varepsilon)}}\right)^{\abs{E(\alpha)}} && \text{(\cref{cor:non_spider_killing})}\\
& \leq\eta^{k+l} \cdot \sum_{\alpha \in {\mathcal B}_{k, l}}\left(\frac{n^{3\tau}}{n^{\Omega(\varepsilon)}}\right)^{\abs{E(\alpha)}} && (\alpha \in {\mathcal L})\\
& \leq \eta^{k+l} \cdot \sum_{\alpha \in {\mathcal B}_{k, l}}\frac{1}{n^{\Omega(\varepsilon\abs{E(\alpha)})}}\\
& \leq \eta^{k+l} \cdot\sum_{i=1}^\infty \frac{n^{O(\tau i)}}{n^{\Omega(\varepsilon i)}}\\
& = \eta^{k+l} \cdot \frac{1}{n^{\Omega(\varepsilon)}}
\end{align*}
where the last inequality used \cref{prop:edge-shape-count} and the fact $|E(\alpha)| \ge 1\text{ for }\alpha \in {\mathcal B}_{k, l}$.
\end{proof}
\subsection{Properties of $e(k)$}
In this section, we establish some properties of the $e(k)$ used in the
analysis. Recall that $e(k) = {\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1\dots x_k\right]$ where
$\mathcal{S}(\sqrt{n}) \coloneqq \set{x \in \set{\pm
1}^n \mid \sum_{i=1}^n x_i = \sqrt{n}}$.
\begin{claim}\label{claim:e2}
$e(2)=0$.
\end{claim}
\begin{proof}
Fix $y \in \mathcal{S}(\sqrt{n})$. Note that $(\sum_{i=1}^n y_i)^2 = n$ implying
$\sum_{i < j} y_i y_j = 0$. Using this fact, we get
$$
{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1 x_2\right] = {\mathbb E}_{\sigma \in S_n} y_{\sigma(1)} y_{\sigma(2)} = 0,
$$
concluding the proof.
\end{proof}
\begin{definition}
We say that a tuple $\lambda = (\lambda_1,\dots,\lambda_k)$ of non-negative integers is a partition of $k$
provided $\sum_{i=1}^k \lambda_i = k$ and $\lambda_1 \ge \cdots \ge \lambda_k$. We use the notation $\lambda \vdash k$
to denote a partition of $k$. We refer to $\lambda_i$ as a row/part of $\lambda$.
\end{definition}
In the following, we will dealing with polynomials that can be indexed by integer partitions.
For this reason, we now fix a notation for partitions and some associated objects.
\begin{definition}
The transpose of partition $\lambda = (\lambda_1,\dots,\lambda_k)$ is denoted $\lambda^t$ and defined as
$\lambda^t_i = \abs{\set{j \in [k] \mid \lambda_j \ge i}}$.
\end{definition}
\begin{remark}
For a partition $\lambda \vdash k$, $\lambda^t_1$ is the number of rows/parts of $\lambda$.
\end{remark}
\begin{definition}
The automorphism group of a partition $\aut(\lambda) \leq S_{\lambda^t_1}$ is the group generated by transpositions $(i,j)$
of rows $\lambda_i = \lambda_j$.
\end{definition}
\begin{remark}
Let $\lambda \vdash k$ and $p_1(\lambda),\dots,p_k(\lambda)$ be such that $p_i(\lambda) = \abs{\set{j \in [\lambda_1^t] \mid \lambda_j = i}}$.
Then $\aut(\lambda) \simeq S_{p_1} \times \cdots \times S_{p_k}$.
\end{remark}
\begin{lemma}\label{lem:slice_inv_exact}
We have
\[
\sum_{\lambda \vdash k} \frac{\lambda!}{\lambda_1!\cdots \lambda_k!} \cdot \frac{(n)_{\lambda^t_1}}{\abs{\aut(\lambda)}} \cdot {\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k} \right] = n^{k/2}.
\]
\end{lemma}
\begin{proof}
For $x \in \mathcal{S}(\sqrt{n})$, we have $(\sum_{i=1}^n x_i)^k =
n^{k/2}$. Then expanding $(\sum_{i=1}^n x_i)^k$ in the previous equations and
taking the expectation over $\mathcal{S}(\sqrt{n})$ on both sides
yields the result of the lemma (after appropriately collecting
terms).
\end{proof}
\begin{claim}\label{claim:bound_prod_exp_ff}
Let $\lambda \vdash k$. We have
$$
(n)_{\lambda^t_1} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k} \right]} \le 3^{k^3} \cdot n^{k/2}.
$$
\end{claim}
\begin{proof}
We induct on $k$. For $k=1$, we have $n \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1\right]} = \sqrt{n} \le 3 \cdot n^{1/2}$.
Now, suppose $k \ge 2$. We consider three cases:
\begin{enumerate}
\item Case $\lambda_1 \ge 3$: Let $\lambda'$ be the partition obtained from $\lambda$ by removing two boxes from $\lambda_1$.
Note that $\lambda_1^t = (\lambda')^t_1 \le k-2$ and
${\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1'} \dots x_{k-2}^{\lambda_{k-2}'} \right] = {\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_{k-2}^{\lambda_{k-2}} \right]$.
By the induction hypothesis, we have $(n)_{(\lambda')^t_1} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1'} \dots x_{k-2}^{\lambda_{k-2}'} \right]} \le 3^{(k-2)^2} \cdot n^{(k-2)/2}$.
\item Case $\lambda_1 = 2$: Let $\lambda'$ be the partition obtained from $\lambda$ by removing $\lambda_1$.
Note that $\lambda_1^t = (\lambda')^t_1 + 1 \le k-2$. By the induction hypothesis, we have
\begin{align*}
(n)_{\lambda^t_1} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_{k-2}^{\lambda_{k-2}} \right]} &\le n \cdot (n)_{(\lambda')^t_1} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1'} \dots x_{k-2}^{\lambda_{k-2}'} \right]}\\
&\le 3^{(k-2)^3} \cdot n^{k/2}.
\end{align*}
\item Case $\lambda_1 = 1$: To bound $(n)_k \cdot {\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k} \right]$, we use~\cref{lem:slice_inv_exact}
and the two preceding cases. Let $p(k)$ be the partition function, i.e., $p(k) = \abs{\set{\lambda \vdash k}}$. We deduce that
{\footnotesize
\begin{align*}
(n)_k \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k}\right]} & \le n^{k/2} + \sum_{\lambda \vdash k \colon \lambda_1 \ge 2} \frac{\lambda!}{\lambda_1!\cdots \lambda_k!} \cdot \frac{(n)_{\lambda^t_1}}{\abs{\aut(\lambda)}} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k} \right]} \\
& \le n^{k/2} + k! \sum_{\lambda \vdash k \colon \lambda_1 \ge 2} (n)_{\lambda^t_1} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k} \right]} \\
& \le n^{k/2} + k! \sum_{\lambda \vdash k \colon \lambda_1 \ge 3} (n)_{\lambda^t_1} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k} \right]} + \\
& \qquad \qquad k !\sum_{\lambda \vdash k \colon \lambda_1 = 2} (n)_{\lambda^t_1} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k} \right]}\\
& \le 3^{(k-2)^3} \cdot k! \cdot (1 + p(k) + k) \cdot n^{k/2} \le 3^{k^3} \cdot n^{k/2},
\end{align*}
}%
as desired.
\end{enumerate}
\end{proof}
\begin{claim}\label{claim:crude_bound_e}
Suppose $k < \sqrt{n}/2$. We have
$$
\abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1\dots x_k\right]} \le 2 \cdot 3^{k^3} \cdot n^{-k/2}.
$$
\end{claim}
\begin{proof}
Follows from~\cref{claim:bound_prod_exp_ff} and the bound on $k$.
\end{proof}
\begin{remark}
In~\cref{claim:crude_bound_e}, the factor $3^{k^3}$ is too lossy to
allow a meaningful bound with $k = n^{\varepsilon}$, where $\varepsilon >
0$ is a constant.
\end{remark}
Refining the ideas of~\cref{claim:bound_prod_exp_ff}, we prove a
stronger lemma below which will imply a tighter bound on $e(k)$
sufficient for our application.
\begin{lemma}\label{lem:slice_inv_exp}
There exists a universal constant $C \ge 1$ such that
\begin{equation}\label{eq:abs_e_k_sum}
\sum_{\lambda \vdash k} \frac{\lambda!}{\lambda_1!\cdots \lambda_k!} \cdot \frac{(n)_{\lambda^t_1}}{\abs{\aut(\lambda)}} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k} \right]} \le k^{C \cdot k} \cdot n^{k/2}.
\end{equation}
In particular, for $n \ge 6$,~\cref{eq:abs_e_k_sum} holds with $C=2$.
\end{lemma}
\begin{proof}
We induct on $k$. For $k = 1$, we have $n \cdot \abs{{\mathbb E}_{x \in \slice(\sqrt{n})} x_1} \le \sqrt{n}$ as desired.
Using $e(2) = 0$ from~\cref{claim:e2} and the case $k=1$ of~\cref{eq:abs_e_k_sum}, we get that~\cref{lem:slice_inv_exp}
also holds for $k=2$. Now, consider $k \ge 3$. Let $\Lambda_1 = \set{\lambda \vdash k \mid \lambda_1 = 1}$,
$\Lambda_2 = \set{\lambda \vdash k \mid \lambda_1 = 2}$ and $\Lambda_{\ge 3} = \set{\lambda \vdash k \mid \lambda_1 = 3}$.
Note that $\Lambda_1 \sqcup \Lambda_2 \sqcup \Lambda_{\ge 3} = \set{\lambda \vdash k}$ and $\abs{\Lambda_1} = 1$.
For convenience define $a_{\lambda}$ to be the term associated to $\lambda \vdash k$ on the LHS of~\cref{eq:abs_e_k_sum}, i.e.,
$$
a_{\lambda}
= \frac{\lambda!}{\lambda_1!\cdots \lambda_k!} \cdot \frac{(n)_{\lambda^t_1}}{\abs{\aut(\lambda)}} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots
x_k^{\lambda_k} \right]}.
$$
First we bound the contribution of the terms associated to
partitions from $\Lambda_{\ge 3}$ in the LHS
of~\cref{eq:abs_e_k_sum}. Let $\lambda'$ be the partition obtained
from $\lambda$ by removing two boxes from $\lambda_1$. Note that
$\lambda_1^t = (\lambda')^t_1 \le k-2$ and
${\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1'} \dots
x_{k-2}^{\lambda_{k-2}'} \right]
= {\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots
x_{k-2}^{\lambda_{k-2}} \right]$. Thus,
\begin{align*}
&a_{\lambda} = \frac{\lambda!}{\lambda_1!\cdots \lambda_k!} \cdot \frac{(n)_{\lambda^t_1}}{\abs{\aut(\lambda)}} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k} \right]} \\
& \qquad = \frac{k(k-1)}{\lambda_1 (\lambda_1-1)} \cdot \frac{\abs{\aut(\lambda')}}{\abs{\aut(\lambda)}} \frac{\lambda'!}{\lambda_1'!\cdots \lambda_k'!} \cdot \frac{(n)_{(\lambda')^t_1}}{\abs{\aut(\lambda')}} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1'} \dots x_{k-2}^{\lambda_{k-2}'} \right]} \\
& \qquad = k^2 \cdot \frac{\abs{\aut(\lambda')}}{\abs{\aut(\lambda)}} \cdot a_{\lambda'} \le k^3 \cdot a_{\lambda'},
\end{align*}
since $\abs{\aut(\lambda')}/\abs{\aut(\lambda)} \le k-2 \le k$.
For each $\lambda' \vdash k-2$, we can form a partition $\lambda \vdash k$ in $k-2 \le k$
ways by adding two blocks to a single row of $\lambda'$. Hence, we have
\begin{equation}\label{eq:lamb_ge_3_contrib}
\sum_{\lambda \in \Lambda_{\ge 3}} a_{\lambda} \le k \cdot \sum_{\lambda' \vdash k-2} k^3 \cdot a_{\lambda'} \le k^4 \cdot k^{C \cdot (k-2)} \cdot n^{(k-2)/2},
\end{equation}
where the last equality follows from the induction hypothesis.
Now we bound the contribution of the terms $a_{\lambda}$ associated to partitions $\lambda$
from $\Lambda_{2}$ in the LHS of~\cref{eq:abs_e_k_sum}. Let $i \ge 1$
be the number of parts of size two of $\lambda$
and let $\lambda'$ be the partition obtained
from $\lambda$ by removing these $i$ parts of size two. Note that $\lambda_1^t =
(\lambda')^t_1 + i \le k-1$. We have
\begin{align*}
&a_{\lambda} = \frac{\lambda!}{\lambda_1!\cdots \lambda_k!} \cdot \frac{(n)_{\lambda^t_1}}{\abs{\aut(\lambda)}} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k} \right]} \\
& \qquad \le n^i \cdot \frac{(k)_i}{2^i} \cdot \frac{\abs{\aut(\lambda')}}{\abs{\aut(\lambda)}} \cdot \frac{\lambda'!}{\lambda_1'!\cdots \lambda_k'!} \cdot \frac{(n)_{(\lambda')^t_1}}{\abs{\aut(\lambda')}} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1 \dots x_{k-2i} \right]} \\
& \qquad = n^i \cdot \frac{(k)_i}{2^i} \cdot \frac{1}{i!} \cdot \frac{\lambda'!}{\lambda_1'!\cdots \lambda_k'!} \cdot \frac{(n)_{(\lambda')^t_1}}{\abs{\aut(\lambda')}} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1 \dots x_{k-2i} \right]},\\
\end{align*}
where in the last equality we used $\abs{\aut(\lambda')}/\abs{\aut(\lambda)} = 1/(i!)$.
Since $\lambda \in \Lambda_2$ is uniquely specified by its number of parts of size two, applying the induction hypothesis we have
\begin{align*}
\sum_{\lambda \in \Lambda_2} a_{\lambda} & \le \sum_{i=1}^{\lfloor k/2 \rfloor} n^i \cdot \frac{(k)_i}{2^i} \cdot \frac{1}{i!} \cdot \left(\frac{\lambda'!}{\lambda_1'!\cdots \lambda_k'!} \cdot \frac{(n)_{(\lambda')^t_1}}{\abs{\aut(\lambda')}} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1 \dots x_{k-2i} \right]} \right)\\
&\le \sum_{i=1}^{\lfloor k/2 \rfloor} n^i \cdot \frac{(k)_i}{2^i} \cdot \frac{1}{i!} \cdot k^{C\cdot(k-2i)} \cdot n^{(k-2i)/2}\\
&\le k^{C \cdot (k-1) } \cdot n^{k/2} \cdot \sum_{i=0}^{\infty} k^{- C \cdot i} \le \frac{3}{2} \cdot k^{C \cdot (k-1) } \cdot n^{k/2},
\end{align*}
where in the last inequality we used $k \ge 3$ and $C \ge 1$.
Finally, we consider the case $\lambda_1 = 1$. To bound $a_{\lambda}$, we use~\cref{lem:slice_inv_exact}
and the two preceding cases. We deduce that
\begin{align*}
a_{\lambda} & \le n^{k/2} + \sum_{\mu \in \Lambda_2} a_{\mu} + \sum_{\mu \in \Lambda_{\ge 3}} a_{\mu} \le n^{k/2} + k^4 \cdot k^{C \cdot (k-2)} \cdot n^{(k-2)/2} + \frac{3}{2} \cdot k^{C \cdot (k-1) } \cdot n^{k/2}\\
& = k^{C \cdot k} \cdot n^{k/2} \left( \frac{1}{k^{C \cdot k}} + \frac{k^4}{n \cdot k^{2 \cdot C}} + \frac{3}{2 \cdot k^{C}} \right).
\end{align*}
We can bound the LHS of~\cref{eq:abs_e_k_sum} as
\begin{align*}
\sum_{\mu \in \Lambda_1} a_{\mu} + \sum_{\mu \in \Lambda_2} a_{\mu} + \sum_{\mu \in \Lambda_{\ge 3}} a_{\mu} &\le
k^{C \cdot k} \cdot n^{k/2} \left( \frac{1}{k^{C \cdot k}} + \frac{2 \cdot k^4}{n \cdot k^{2 \cdot C}} + \frac{3}{k^{C}} \right)\\
&\le k^{C \cdot k} \cdot n^{k/2},
\end{align*}
provided $C > 0$ is a sufficiently large constant. In particular, the constant $C$ can be taken to be $2$ for $n \ge 6$.
\end{proof}
\begin{corollary}\label{cor:bound_on_coeff_e_k}
We have
$$
\abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1\dots x_k\right]} \le k^{3\cdot k} \cdot n^{-k/2}.
$$
\end{corollary}
\begin{proof}
Suppose $k \le \sqrt{n}$.
Note that~\cref{lem:slice_inv_exp} implies that for $\lambda \vdash k$ with $\lambda_1$
there exists a constant $C > 0$ such that
\begin{align*}
\frac{\lambda!}{\lambda_1!\cdots \lambda_k!} \cdot \frac{(n)_{\lambda^t_1}}{\abs{\aut(\lambda)}} \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1^{\lambda_1} \dots x_k^{\lambda_k} \right]} &= (n)_k \cdot \abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1\dots x_k\right]}\\
&\le k^{C \cdot k} \cdot n^{k/2}.
\end{align*}
Simplifying and using the assumption $k \le \sqrt{n}$, we obtain
$$
\abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1\dots x_k\right]} \le \frac{k^{C \cdot k} \cdot n^{-k/2}}{\prod_{i=1}^{k-1} \left(1 - \frac{i}{n}\right)} \le 2 \cdot k^{C \cdot k} \cdot n^{-k/2}.
$$
Furthermore, for $n \ge 6$,~\cref{lem:slice_inv_exp} allows us to choose $C=2$.
Since $\abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1 \right]} = 1/\sqrt{n}$, the simpler
bound applies for all values of $k$
$$
\abs{{\mathbb E}_{x \in \mathcal{S}(\sqrt{n})}\left[x_1\dots x_k\right]} \le k^{3 \cdot k} \cdot n^{-k/2},
$$
Now the assumption $n \ge 6$ can be removed since, for $k \ge 2$, we have$(k^{3}/\sqrt{n})^{k} \ge 1$,
where $1$ is the trivial bound. Similarly, our initial assumption of $k \le \sqrt{n}$ can also be removed
as the bound also becomes trivial in the regime $k > \sqrt{n}$.
\end{proof}
\section{Technical preliminaries}
In this section we record formal problem statements, then define and discuss one of the main objects in our SoS
lower bound: graph matrices.
For a vector or variable
$v \in {\mathbb R}^n$, and $I \subseteq [n]$, we use the notation
$v^I := \prod_{i \in I}v_i$. When a statement holds with high
probability (w.h.p.), it means it holds with probability $1 - o_n(1)$. In
particular, there is no requirement for small $n$.
\subsection{Problem statements}
We introduce the Planted Affine Planes problem over a distribution ${\mathcal D}$.
\begin{definition}[Planted Affine Planes (PAP) problem]\label{def:prob:pap}
Given $d_1, \dots, d_m \sim {\mathcal D}$ where each $d_u$ is a vector in ${\mathbb R}^n$,
determine whether there exists $v \in \set{\pm \frac{1}{\sqrt{n}}}^n$ such that
\[
\ip{v}{d_u}^2 = 1,
\]
for every $u \in [m]$.
\end{definition}
Our results hold for the Gaussian setting $\mathcal{D} = {\mathcal N}(0, I)$ and the boolean setting where ${\mathcal D}$ is uniformly sampled from $\{\pm 1\}^n$, though we conjecture in \cref{sec:open-problems} that similar SoS bounds hold under more general conditions on ${\mathcal D}$.
Observe that in both settings the solution vector $v$ is restricted to be Boolean (in the sense that the entries are either $\frac{1}{\sqrt{n}}$ or $\frac{-1}{\sqrt{n}}$) and an SoS lower bound for this restricted version of the problem is
stronger than when $v$ can be an arbitrary vector from ${\mathbb R}^n$.
As we saw in \cref{chap: main_results}, the Sherrington--Kirkpatrick (SK) problem comes from the spin-glass model
in statistical physics~\cite{SK76}.
\begin{definition}[Sherrington-Kirkpatrick problem]\label{def:prob:sk}
Given $W \sim \GOE(n)$, compute
\[
\OPT(W) := \max_{x \in \{\pm 1\}^n} x^\intercal W x.
\]
\end{definition}
The Planted Boolean Vector problem was introduced by
Mohanty--Raghavendra--Xu \cite{mohanty2020lifting}, where it was called the
``Boolean Vector in a Random Subspace''.
\begin{definition}[Planted Boolean Vector problem]\label{def:prob:pbv}
Given as input a uniformly random $p$-dimensional subspace $V$ of $\mathbb{R}^n$ in the form of
a projector $\Pi_V$ onto $V$, compute
\[
\OPT(V) := \frac{1}{n}\max_{b \in \{\pm 1\}^n} b^\intercal \Pi_V b.
\]
\end{definition}
\subsection{Graph matrices}
To study ${\mathcal M}$, we decompose it using the framework of \textit{graph matrices}. Originally developed in the context of the planted clique problem, graph matrices are random matrices whose entries are symmetric functions of an underlying random object -- in our case, the set of vectors $d_1, \dots, d_m$. We take the general presentation and results from~\cite{ahn2016graph}. For our purposes, the following definitions are sufficient.
The graphs that we study have two types of vertices, circles $\circle{}$ and squares $\square{}$. We let ${\mathcal C}_m$ be a set of $m$ circles labeled 1 through $m$, which we denote by $\circle{1}, \circle{2}, \dots, \circle{m}$, and let ${\mathcal S}_n$ be a set of $n$ squares labeled 1 through $n$, which we denote by $\square{1}, \square{2}, \dots, \square{n}$. We will work with bipartite graphs with edges between circles and squares, which have positive integer labels on the edges. When there are no multiedges (the graph is simple), such graphs are in one-to-one correspondence with Fourier characters on the vectors $d_u$. An edge between $\circle{u}$ and $\square{i}$ with label $l$ represents $h_{l}(d_{u,i})$ where $\{h_k\}$ is the Fourier basis (e.g. Hermite polynomials).
\[ \text{simple graph with labeled edges} \qquad \Longleftrightarrow \qquad \displaystyle\prod_{\substack{\circle{u} \in {\mathcal C}_m,\\ \square{i} \in {\mathcal S}_n}} h_{l(\circle{u}, \square{i})}(d_{u,i}) \]
An example of a Fourier polynomial as a graph with labeled edges is given in~\cref{fig:fourier_graph}. Unlabeled edges are implicitly labeled 1.
\begin{figure}[h!]
\centering
\begin{tikzpicture}[scale=0.5,every node/.style={scale=0.5}]
\draw (-2,3) rectangle node {\huge $i_1$}(-0.5,1.5) node (v5) {};
\draw (3,1) ellipse (1 and 1) node {\huge $u$};
\draw (6.5,3) rectangle node (v10) {\huge $j_1$} (8,1.5);
\draw (-2,0) rectangle node {\huge $i_2$} (-0.5,-1.5);
\draw (6.5,0) rectangle node {\huge $j_2$} (8,-1.5);
\node (v1) at (-0.5,3) {};
\node (v4) at (-0.5,2.25) {};
\node (v6) at (6.5,2.25) {};
\node (v8) at (-0.5,-0.75) {};
\node (v9) at (6.5,-0.75) {};
\node at (-0.5,0) {};
\node (v2) at (2,1) {};
\node at (2,1.5) {};
\node (v7) at (6.5,1.5) {};
\node (v3) at (4,1) {};
\draw plot[smooth, tension=.7] coordinates {(v3)};
\draw plot[smooth, tension=.7] coordinates {(v3)};
\draw plot[smooth, tension=.7] coordinates {(v2) (0.5,2) (v4)};
\node at (1,2.2) {\huge $3$};
\draw plot[smooth, tension=.7] coordinates {(v3) (5,2) (v6)};
\draw plot[smooth, tension=.7] coordinates {(v3)};
\draw plot[smooth, tension=.7] coordinates {(v2) (1,-0.5) (v8)};
\draw plot[smooth, tension=.7] coordinates {(v3) (5,-0.5) (v9)};
\node at (6.5,3) {};
\draw plot[smooth, tension=.7] coordinates {(v3)};
\draw plot[smooth, tension=.7] coordinates {(v3)};
\draw plot[smooth, tension=.7] coordinates {(v10)};
\node at (6.5,3) {};
\draw (2,5.5) rectangle node {\huge $w_1$} (3.5,4);
\node (v11) at (2.5,4) {};
\node (v13) at (3,4) {};
\node (v12) at (3,2) {};
\draw plot[smooth, tension=.7] coordinates {(v12) (3,3) (3,4)};
\node at (2.5,3) {\huge $2$};
\end{tikzpicture}
\caption{The Fourier polynomial $h_3(d_{u,i_1})h_1(d_{u,i_2})h_2(d_{u,w_1})h_1(d_{u,j_1})h_1(d_{u,j_2})$ represented as a graph.}
\label{fig:fourier_graph}
\end{figure}
Define the degree of a vertex $v$, denoted $\deg(v)$, to be the sum of the labels incident to $v$, and $\abs{E}$ to be the sum of all labels. For
intuition it is mostly enough to work with simple graphs, in which case these quantities make sense as the edge multiplicities in an implicit multigraph.
\begin{definition}[Proper]
We say an edge-labeled graph is \textit{proper} if it has no multiedges.
\end{definition}
The definitions allow for ``improper'' edge-labeled multigraphs which simplify multiplying graph matrices (\cref{sec:single-spider}).
\begin{definition}[Matrix indices]
A \textit{matrix index} is a set $A$ of elements from ${\mathcal C}_m \cup {\mathcal S}_n$.
\end{definition}
We let $A(\square{i})$ or $A(\circle{u})$ be 0 or 1 to indicate if the vertex is in $A$.
\begin{definition}[Ribbons]\label{def:ribbon}
A \textit{ribbon} is an undirected, edge-labeled graph $R$ given by $R = (V(R), E(R), A_R, B_R)$, where $V(R) \subseteq {\mathcal C}_m\cup {\mathcal S}_n$ and $A_R, B_R$ are two matrix indices (possibly not disjoint) with $A_R, B_R \subseteq V(R)$, representing two distinguished sets of vertices. Furthermore, all edges in $E(R)$ go between squares and circles.
\end{definition}
We think of $A_R$ and $B_R$ as being the ``left'' and ``right'' sides of $R$, respectively. We also define the set of ``middle vertices'' $C_R := V(R) \setminus (A_R \cup B_R)$. If $e \not\in E(R)$, then we define its label $l(e) = 0$. We also abuse notation and write $l(\square{i}, \circle{u})$ instead of $l(\{\square{i}, \circle{u}\})$.
Akin to the picture above, each ribbon corresponds to a Fourier polynomial.
This Fourier polynomial lives inside a single entry of the matrix $M_R$.
In the definition below, the $h_k(x)$ are the Fourier basis corresponding to the respective setting. In the Gaussian case, they are the (unnormalized) Hermite polynomials, and in the boolean case, they are just the parity function, represented by
\[h_0(x) = 1, \qquad h_1(x) = x, \qquad h_k(x) = 0 \;\; (k \geq 2) \]
\begin{definition}[Matrix for a ribbon]\label{def:ribbon-matrix}
The matrix $M_R$ has rows and columns indexed by subsets of ${\mathcal C}_m~\cup~{\mathcal S}_n$, with a single nonzero entry defined by
\[M_R[I, J] = \left\{\begin{array}{lr}
\displaystyle\prod_{\substack{e \in E(R), \\ e = \{\square{i}, \circle{u}\}}} h_{l(e)}(d_{u,i}) & I = A_R, J = B_R\\
0 & \text{Otherwise}
\end{array}\right. \]
\end{definition}
Next we describe the shape of a ribbon, which is essentially the ribbon when we have forgotten all the vertex labels and retained only the graph structure and the distinguished sets of vertices.
\begin{definition}[Index shapes]
An \textit{index shape} is a set $U$ of formal variables. Furthermore, each variable is labeled as either a ``circle'' or a ``square''.
\end{definition}
We let $U(\square{i})$ and $U(\circle{u})$ be either 0 or 1 for whether $\square{i}$ or $\circle{u}$, respectively, is in $U$.
\begin{definition}[Shapes]\label{def:shape}
A \textit{shape} is an undirected, edge-labeled graph $\alpha$ given by $\alpha = (V(\alpha), E(\alpha), U_\alpha, V_\alpha)$ where $V(\alpha)$ is a set of formal variables, each of which is labeled as either a ``circle'' or a ``square''. $U_\alpha$ and $V_\alpha$ are index shapes (possibly with variables in common) such that $U_\alpha, V_\alpha \subseteq V(\alpha)$. The edge set $E(\alpha)$ must only contain edges between the circle variables and the square variables.
\end{definition}
We'll also use $W_\alpha := V(\alpha) \setminus (U_\alpha \cup V_\alpha)$ to denote the ``middle vertices'' of the shape.
\begin{remk}
We will abuse notation and use $\square{i}, \square{j}, \circle{u}, \circle{v}, \ldots$ for both the vertices of ribbons and the vertices of shapes. If they are ribbon vertices, then the vertices are elements of ${\mathcal C}_m\cup{\mathcal S}_n$ and if they are shape vertices, then they correspond to formal variables with the appropriate type.
\end{remk}
\begin{definition}[Trivial shape]
Define a shape $\alpha$ to be trivial if $U_\alpha = V_\alpha$, $W_\alpha = \emptyset$ and $E(\alpha) = \emptyset$.
\end{definition}
\begin{definition}[Transpose of a shape]
For a shape $\alpha = (V(\alpha), E(\alpha), U_\alpha, V_\alpha)$, its transpose is defined
to be the shape $\alpha^{\intercal} = (V(\alpha), E(\alpha), V_\alpha, U_\alpha)$.
\end{definition}
For a shape $\alpha$ and an injective map $\sigma :
V(\alpha) \rightarrow {\mathcal C}_m \cup {\mathcal S}_n$, we define the
realization $\sigma(\alpha)$ as a ribbon in the natural
way, by labeling all the variables using the map
$\sigma$. We also require $\sigma$ to be
type-preserving i.e. it takes square variables to ${\mathcal S}_n$ and circle variables to ${\mathcal C}_m$.
The ribbons that result are referred to as \textit{ribbons of shape $\alpha$}; notice that this partitions the set of all ribbons according to their shape\footnote{Partitions up to equality of shapes, where two shapes are equal if there is a type-preserving bijection between their variables that converts one shape to the other. When we operate on sets of shapes below, we implicitly use each distinct shape only once.}\footnote{Note that in our definition two realizations of a shape may give the same ribbon.}.
Finally, given a shape $\alpha$, the graph matrix $M_\alpha$ consists of all Fourier characters for ribbons of shape $\alpha$.
\begin{definition}[Graph matrices]\label{def:graph-matrix}
Given a shape $\alpha = (V(\alpha), E(\alpha), U_\alpha, V_\alpha)$, the \textit{graph matrix} $M_\alpha$ is
\[M_\alpha = \displaystyle\sum_{R \text{ is a ribbon of shape }\alpha} M_R\]
\end{definition}
The moment matrix for PAP will turn out to be defined using graph matrices $M_\alpha$ whose left and right sides only have square vertices, and no circles. However, in the course of the analysis we will factor and multiply graph matrices with circle vertices in the left or right.
\subsection{Norm bounds}
Similar to the norm bounds for graph matrices with only a single type of vertex (see \cref{chap: efron_stein}), the spectral norm of a graph matrix in our setting is determined, up to logarithmic factors, by relatively simple combinatorial properties of the graph. For a subset $S \subseteq {\mathcal C}_m \cup {\mathcal S}_n$, we define the weight $w(S)~:=~(\#\text{ circles in }S)\cdot \log_n(m)+ (\#\text{ squares in }S)$. Observe that $n^{w(S)} = m^{\# \text{ circles in }S}\cdot n^{\#\text{ squares in }S}$.
\begin{definition}[Minimum vertex separator]
For a shape $\alpha$, a set $S_{\min}$ is a minimum vertex separator if all paths from $U_\alpha$ to $V_\alpha$ pass through $S_{\min}$ and $w(S_{\min})$ is minimized over all such separating sets.
\end{definition}
Let $W_{iso}$ denote the set of isolated vertices in $W_\alpha$. Then essentially the following norm bound holds for all shapes $\alpha$ with high probability (a formal statement can be found in~\cref{app:norm_bounds}):
\[\norm{M_\alpha} \leq \widetilde\operatorname{O}\left(n^{\frac{w(V(\alpha)) - w(S_{\min}) + w(W_{iso})}{2}}\right)\]
In fact, the only probabilistic property required of the inputs $d_1, \dots, d_m$ by our proof is that the above norm bounds hold for all shapes that arise in the analysis.
We henceforth assume that the norm bounds in~\cref{lem:gaussian-norm-bounds} (for the Gaussian case) and~\cref{lem:norm-bounds} (for the boolean case) hold.
\section{Proof Strategy}\label{sec:strategy}
\input{sherrington_kirkpatrick/strategy}
\section{Pseudocalibration}\label{sec:pseudo_calib}
\input{sherrington_kirkpatrick/pseudo_calib}
\section{Proving PSD-ness}\label{sec:psd}
\input{sherrington_kirkpatrick/no_spider}
\input{sherrington_kirkpatrick/spider_killing}
\input{sherrington_kirkpatrick/finishing_the_proof}
\section{Sherrington-Kirkpatrick Lower Bounds}\label{sec:sk}
\input{sherrington_kirkpatrick/sk}
\section{Omitted technical details}
\input{sherrington_kirkpatrick/norm_bounds}
\input{sherrington_kirkpatrick/mon_on_slice}
\section{The Sum of Squares hierarchy}
We start by defining convex relaxations for polynomial optimization problems. The SoS hierarchy will then be a special family of convex relaxations. For a more detailed treatment, see e.g. \cite{sos_course, BS14:ICM, FKP19}.
\subsection{Polynomial optimization and convex relaxations}
In polynomial optimization, we are given multivariate polynomials $p, g_1, \ldots, g_m$ on $n$ variables $x_1, \ldots, x_n$ taking real values, denoted collectively by $x$, and the task is to:
\[\text{maximize } p(x)\text{ such that }g_1(x) = 0, \ldots, g_m(x) = 0\]
In general, we could also allow inequality constraints, e.g., $g_i(x) \ge 0$. For technical convenience in our setup, we work only with equality constraints but much of the theory generalizes, with some modifications, when we have inequality constraints instead. An alternate approach is to replace each inequality $g_i(x) \ge 0$ by $g_i(x) = y^2$ where $y$ is a new variable that we can introduce.
In this formulation, many optimization problems can be formulated as polynomial optimization problems.
\begin{example}[Maximum Cut]
Given a graph $G = (V, E)$, we would like to partition the set of vertices into two subsets such that the number of edges with endpoints in different subsets is maximized. To formulate this as a polynomial optimization problem, let the graph have $n$ vertices and let $x_1, \ldots, x_n$ be variables, one for each vertex. We wish to enforce $x_i \in \{-1, 1\}$ where all vertices $i$ with $x_i = -1$ form one subset and the rest form the other subset. We can enforce this set containment constraint via the polynomial constraint $x_i^2 = 1$. For any edge $(i, j) \in E$, it is cut if and only if $x_ix_j = -1$. Therefore, the total number of edges cut is $\sum_{(i, j) \in E} \frac{1}{2}(1 - x_ix_j)$. The polynomial formulation therefore becomes
\begin{align*}
\max_{x \in {\mathbb R}^n} \sum_{(i, j) \in E} \frac{1}{2}&(1 - x_ix_j) \text{ such that }\\
x_i^2 &= 1 \text{ for all }i \le n
\end{align*}
\end{example}
\begin{example}[Maximum Clique]\label{ex: max_clique}
Given a graph $G = (V, E)$, we would like to find the maximize size subset of vertices that form a clique. Again, let $x_1, \ldots, x_n$ be variables, one for each vertex. This time, we wish to enforce $x_i \in \{0, 1\}$, which we can easily do so using the polynomial constraint $x_i^2 = x_i$, with the intent being that all vertices $i$ with $x_i = 1$ form a clique. To enforce this clique constraint, we can add the polynomial constraint $x_ix_j = 0$ for all non-edges $(i, j) \not\in E$. Finally, to maximize the size of the subset, we simply maximize $\sum_{i \le n} x_i$. Therefore, the polynomial optimization is
\begin{align*}
\max_{x \in {\mathbb R}^n} \sum_{i \le n} &x_i \text{ such that}\\
x_ix_j &= 0 \text{ for all }(i, j) \not\in E\\
x_i^2 &= x_i \text{ for all } i \le n
\end{align*}
\end{example}
There can be other equivalent formulations for these problems. In general, many optimization problems can be stated in this manner, therefore generic polynomial optimization contains a large class of fundamental problems that appear in computer science.
Since exactly solving maximum cut or maximum clique is NP-hard \cite{karp1972reducibility}, exactly solving these polynomial optimization problems is also NP-hard. Therefore, we turn to convex relaxations.
A convex relaxation of a polynomial optimization problem widens the search space of solution vectors $x$ into a larger space that one can efficiently optimize over. We will describe one way to do this. We identify a convex space ${\mathcal C}$ that contains the space ${\mathcal S}= \{g_1(x) = 0, \ldots, g_m(x) = 0\}$ up to a map, that is, for each $x \in {\mathcal S}$, there exists a corresponding $y \in {\mathcal C}$ such that $y$ is a representative of $x$. We also identify a convex function $\tilde{p}(y)$ such that if $y$ is a representative of $x$, then $\tilde{p}(y) = p(x)$. Then, we simply optimize $\tilde{p}(y)$ over ${\mathcal C}$. There has been significant work on efficiently optimizing a convex function over a convex body, which is possible under reasonable assumptions (see e.g. \cite{PS82}). It's clear that from the above properties, the solution we get is at least as large as the optimal solution (in the case of maximization), but it comes with the advantage that it is efficiently computable. It is desirable to design convex relaxations for problems that yield good approximations. The SoS hierarchy is a family of such convex relaxations.
\subsection{Sum of Squares relaxations}
The SoS hierarchy, sometimes referred to as the Lasserre hierarchy, was first independently studied by \cite{parrilo2000structured, lasserre2001global, shor1987approach} and has been studied in other contexts by \cite{nesterov2000squared, grigoriev2001complexity, Grigoriev01}.
It is a family of convex relaxations for polynomial optimization, parameterized by an integer known as it's degree. As we increase the degree, we get progressively tighter relaxations, but requiring longer times to optimize over.
We now formally describe the Sum of Squares hierarchy, via the so-called pseudoexpectation operator view.
\begin{definition}[Pseudo-expectation values]\label{def: pseudoexpectation}
Given multivariate polynomial constraints $g_1 = 0$,\ldots,$g_m = 0$ on $n$ variables $x_1, \ldots, x_n$, degree $d$ pseudo-expectation values are a linear map $\tilde{\EE}$ from polynomials of $x_1, \ldots, x_n$ of degree at most $d$ to $\mathbb{R}$ satisfying the following conditions:
\begin{enumerate}
\item $\tilde{\EE}[1] = 1$, \label{pe:normalized}
\item $\tilde{\EE}[f \cdot g_i] = 0$ for every $i \in [m]$ and polynomial $f$ such that $\deg(f \cdot g_i) \leq d$. \label{pe:feasible}
\item $\tilde{\EE}[f^2] \geq 0$ for every polynomial $f$ such that $\deg(f^2) \le d$. \label{pe:psdness}
\end{enumerate}
\end{definition}
Any linear map $\tilde{\EE}$ satisfying the above properties is known as a degree $d$ pseudoexpectation operator satisfying the constraints $g_1 = 0, \ldots, g_m = 0$.
\begin{definition}[Degree $d$ SoS]
The degree $d$ SoS relaxation for the polynomial optimization problem
\[\text{maximize } p(x)\text{ such that }g_1(x) = 0, \ldots, g_m(x) = 0\]
is the program that maximizes $\tilde{\EE}[p(x)]$ over all degree $d$ pseudoexpectation operators $\tilde{\EE}$ satisfying the constraints $g_1 = 0, \ldots, g_m = 0$.
\end{definition}
The intuition behind pseudo-expectation values is that the conditions on the pseudo-expectation values are conditions that would be satisfied by any actual expected values over a distribution of solutions, so optimizing over pseudo-expectation values gives a relaxation of the problem.
The main observation is that the SoS relaxation can be efficiently solved! This is because the conditions on pseudo-expectation values can be captured by a semidefinite program. In particular, \cref{pe:psdness} in \cref{def: pseudoexpectation} can be reexpressed in terms of a matrix called the moment matrix.
\begin{definition}[Moment Matrix of $\tilde{\EE}$]
Given a degree $d$ pseudo-expectation operator $\tilde{\EE}$, define the associated moment matrix $\Lambda$ to be a matrix with rows and columns indexed by monomials $p$ and $q$ such that the entry corresponding to row $p$ and column $q$ is
\[
\Lambda[p, q] := \tilde{\EE}\left[pq\right].
\]
\end{definition}
It is easy to verify that \cref{pe:psdness} in~\cref{def: pseudoexpectation} equivalent to $\Lambda \succeq 0$. Therefore, solving the degree $d$ SoS relaxation can be done via semidefinite programming, see for e.g. \cite{vandenberghe1996semidefinite}.
In general, for degree-$d$ SoS, we can solve it in $n^{O(d)}$ time\footnote{This is not completely accurate due to issues of bit complexity \cite{o2017sos} but this doesn't occur for most problems of interest \cite{RW17:sos}}. Therefore, constant degree SoS can be solved in polynomial time.
\subsubsection{Analyzing degree $2$ SoS for maximum clique}
To illustrate the use of this technique, let's analyze the degree $2$ SoS relaxation for the maximum clique problem on Erd\H{o}s\xspace-R\'enyi\xspace random graphs $G_{n, 1/2}$. We use the program from \cref{ex: max_clique}.
Let $A$ be the adjacency matrix of a graph $G$ sampled from $G_{n, 1/2}$ and let $J$ be the matrix with all $1$s. Then, with high probability over the choice of $G$, from random matrix theory, we have $\lambda_{max}(A- J/2) = O(\sqrt{n})$ where $\lambda_{max}(.)$ denotes the maximum singular value. Now, suppose a set $S$ of vertices form a clique and let $\mathbf 1_S$ denote the indicator vector of the set $S$, then
\begin{align*}
\frac{k(k - 1)}{2} &= \ip{\mathbf 1_S}{(A - J/2)\mathbf 1_S}\\
&\le \norm{\mathbf 1_S}^2\cdot \lambda_{max}(A - J / 2)\\
&\le k \cdot O(\sqrt{n})
\end{align*}
which shows $k \le O(\sqrt{n})$.
The crux of this simple argument is that this is a \textit{low-degree proof}, more specifically degree $2$ proof, that SoS can capture. That is, if we solve the degree $2$ SoS relaxation, we will be able to show that $\tilde{\EE}[\sum x_i] = O(\sqrt{n})$ whp.
To see this formally, we start with the following inequality: $O(\sqrt{n})I - (A - J / 2) \succeq 0$ whp. This implies
\[x^\intercal(O(\sqrt{n})I - (A - J / 2))x = \sum p_i(x)^2\]
is a sum of squares of polynomials of degree at most $1$.
A simple computation yields
\[x^\intercal(A - J/2)x = \frac{1}{2}(\sum_{i = 1}^n x_i)^2 - \sum_{i, j} x_ix_j \mathbf 1_{(i, j) \not\in E(G)}\]
For our program variables $x$, we have $x_i^2 = x_i$ and $x_ix_j \mathbf 1_{(i, j) \not\in E(G)} = 0$. Therefore,
\[\sum p_i(x)^2 = O(\sqrt{n}) (\sum_{i = 1}^n x_i) - \frac{1}{2}(\sum_{i = 1}^n x_i)^2\]
Apply $\tilde{\EE}$ both sides. We finally use the fact that for a polynomial $p(x)$, we have $\tilde{\EE}[p(x)^2] \ge \tilde{\EE}[p(x)]^2$, which is true because this rearranges to $\tilde{\EE}[(p(x)- \tilde{\EE}[p(x)])^2] \ge 0$, which is true because the left hand side is the the pseudo-expectation of a square polynomial, which is nonnegative by definition. This simple fact is essentially saying that the pseudo-variance is nonnegative. Using the linearity of $\tilde{\EE}$, we finally get
\begin{align*}
O(\sqrt{n}) \tilde{\EE}[\sum_{i = 1}^n x_i] - \frac{1}{2}(\tilde{\EE}[\sum_{i = 1}^n x_i])^2 &\ge O(\sqrt{n}) \tilde{\EE}[\sum_{i = 1}^n x_i] - \frac{1}{2}\tilde{\EE}[(\sum_{i = 1}^n x_i)^2]\\
&= \tilde{\EE}[O(\sqrt{n}) (\sum_{i = 1}^n x_i) - \frac{1}{2}(\sum_{i = 1}^n x_i)^2]\\
&= \tilde{\EE}[\sum p_i(x)^2]\\
&= \sum \tilde{\EE}[p_i(x)^2]\\
& \ge 0
\end{align*}
Therefore, $\tilde{\EE}[\sum_{i = 1}^n x_i] = O(\sqrt{n})$ like we wanted to show.
This shows that the degree $2$ SoS relaxation certifies an upper bound of $O(\sqrt{n})$ whp on the size of the maximum clique of an Erd\H{o}s\xspace-R\'enyi\xspace random graph. In contrast, the size of the true maximum clique is $(2 + o(1)) \log n$ \cite{matula1976largest}. Despite intense effort, polynomial time algorithms can only detect a planted $k$-clique when $k = \Omega(\sqrt{n})$. Therefore, SoS already achieves the best known guarantees for this problem up to constant factors. It was shown in \cite{BHKKMP16} that higher degree SoS (up to degree $O(\log n)$) doesn't necessarily do much better, which is a SoS lower bound of the type we will study in this work.
\subsubsection{Alternate viewpoints of SoS}
In the polynomial optimization problem of maximizing $p(x)$ subject to the constraints $g_1(x) = 0, \ldots, g_m(x) = 0$, if there does not exist any degree $d$ pseudo-expectation operator $\tilde{\EE}$ satisfying $g_1 = 0, \ldots, g_m = 0$ such that $\tilde{\EE}[p] > c$, then we say that degree $d$ SoS certifies that $\tilde{\EE}[p(x)] \le c$.
A degree $d$ SoS proof that $p(x) \le c$ given $g_1(x) = 0, \ldots, g_m(x) = 0$ is an expression of the form
\[-1 = \sum_{i \le m} g_i(x) q_i(x) + \sum_{i \le a} s_i(x)^2 + (p(x) - c) \sum_{i \le b} t_i(x)^2\]
where $q_1, \ldots, q_m, s_1, \ldots, s_a, t_1, \ldots, t_b$ are polynomials in $x$ such that each term on the right hand side of the above expression has degree at most $d$. Indeed, the existence of such an expression automatically implies that $p(x) \le c$ whenever $g_1(x) = 0, \ldots, g_m(x) = 0$.
When degree $d$ SoS certifies that $\tilde{\EE}[p(x)] \le c$, by duality, this will imply that there exists a degree $d$ SoS proof that $p(x) \leq c$ given $g_1(x), \ldots, g_m(x) = 0$. The Positivstellensatz of Krivine and Stengle \cite{krivine1964anneaux, stengle1974nullstellensatz} says that for any $c$, either there exists $x$ such that $p(x) > c, g_1(x) = 0, \ldots, g_m(x) = 0$, or there is an SoS proof that $p(x) \le c$ given $g_1(x) = 0, \ldots, g_m(x) = 0$.
For a fixed $d$, degree $d$ SoS can indeed be construed as finding the best $c$ so that there is a degree $d$ SoS proof of $\tilde{\EE}[p(x)] \le c$. This also intuitively explains why higher degree SoS gives tighter relaxations. For most programs stemming from combinatorial optimization problems, degree $n$ SoS usually finds the optimal bound, where $n$ is the number of variables. So, for instance, degree $n$ SoS exactly outputs the size of the maximum clique of a graph. For efficient algorithms, we usually want constant degree SoS.
Therefore, for sum of squares lower bounds, the higher the degree, the stronger the lower bound.
In this work, all our lower bounds are for degree $n^{\varepsilon}$ SoS, which corresponds to subexponential time!
The viewpoint we have studied here is the dual view aka the search for simple proofs, which will suit our purposes. There is also the primal viewpoint where SoS can be viewed directly as a semi-definite programming relaxation of the program. This is sometimes useful for algorithm design.
Similar to the maximum clique application shown above, the SoS hierarchy has been shown formally to obtain the state-of-the art approximation guarantees for many fundamental problems both in the worst case and the average case setting. This includes constraint satisfaction problems \cite{Raghavendra08}, maximum cut \cite{GW94}, sparsest cut \cite{AroraRV04}, tensor PCA \cite{hopkins2015tensor}, etc.
Therefore, it's natural to study the limits of SoS by studying SoS lower bounds.
Before we discuss SoS lower bounds, we introduce the framework of hypothesis testing problem in more detail, suited to our purposes.
\section{Hypothesis testing}
Let $\Omega$ be a sample space. Let $\nu, \mu$ be probability distributions on $\Omega^n$. The hypothesis testing problem is the problem of distinguishing $\nu, \mu$ given access to a sample. Formally, input $x \sim \Omega^n$ is sampled from either
\begin{itemize}
\item $H_0$: $x \sim \mu$
\item $H_1$: $x \sim \nu$.
\end{itemize}
Our objective is to determine which distribution it came from, with high probability. This is the hypothesis testing problem in general, where traditionally, $H_0$ is known as the null hypothesis and $H_1$ the alternate hypothesis. We abuse notation and use $H_0, H_1$ to also denote the probability distributions $\mu, \nu$ respectively as well.
For example, $H_0$ could be the distribution of Erd\H{o}s\xspace-R\'enyi\xspace random graphs and $H_1$ could be the distribution of Erd\H{o}s\xspace-R\'enyi\xspace random graphs with a large planted clique. Given the graph, we would like to determine which of the two distributions it came from, or in other words, whether it contains a large clique.
A hypothesis test $f$ is a function $f: \Omega^n \rightarrow \{0, 1\}$. Given the input $x$, if $f(x) = 0$, then we report that $x$ came from the null distribution $H_0$ otherwise we report that $x$ came from the alternate distribution $H_1$.
A successful hypothesis test is a test $f$ such that when $b$ is chosen uniformly at random from $\{0, 1\}$ and $x$ is sampled from $H_b$, we have $\mathbb{E}_b \mathrm{Pr}_{x \sim H_b}[f(x) \neq b] \le o(1)$. That is, test $f$ has success probability $1 - o(1)$. Here, for simplicity, we don't distinguish type $1$ and type $2$ errors.
Indeed, for a test to be useful, it should be computable efficiently. When computational efficiency is disregarded, the famous Neyman-Pearson lemma precisely characterizes the best hypothesis test. To define this test, we need the following standard definition.
\begin{definition}[Likelihood ratio]
For a given hypothesis testing problem, define the likelihood ratio of an input $x$ to be $LR(x) = \frac{\mathrm{Pr}_{H_1}(x)}{\mathrm{Pr}_{H_0}(x)}$.
\end{definition}
\begin{lemma}[Neyman-Pearson Lemma]
For a given hypothesis testing problem, the test $f$ that minimizes $\mathbb{E}_b\mathrm{Pr}_{x \sim H_b} [f(x) \neq b]$ is the likelihood ratio test
\[f(x) = \begin{dcases}
1 & \text{ if $LR(x) > 1$}\\
0 & \text{ o.w.}
\end{dcases}\]
\end{lemma}
In this work, our focus will be on efficiently computable tests $f$.
\subsection{Low degree likelihood ratio}\label{subsec: ldlr}
Consider a given hypothesis testing problem. We focus on a special class of efficiently computable hypothesis tests involving low degree multivariate polynomials. These are termed low-degree distinguishers. We give a brief treatment in this section and refer the readers to \cite{hop18, kunisky2021spectral} for a more detailed treatment.
In this section, for polynomials to be well-defined, assume $\Omega \subseteq {\mathbb R}$. Moreover, assume $H_0$ has finite moments. We will consider distinguishers that arise from multivariate polynomials $f: {\mathbb R}^n \rightarrow {\mathbb R}$. We say that the distinguisher has degree $D$ if the degree of $f$ is at most $D$. Since the output of a polynomial need not be boolean, we need an alternate definition of the success of this distinguisher. We use the following definition from \cite{hop18}.
\begin{definition}[Degree $D$ distinguisher]
For a hypothesis testing problem, the multivariate polynomial $f$ is a successful degree $D$ distinguisher if
\begin{itemize}
\item (Low degree) $f$ is a multivariate polynomial of degree at most $D$.
\item (Normalization) $\mathbb{E}_{x \sim H_0}[f(x)] = 0, \mathbb{E}_{x \sim H_0} [f(x)^2] = 1$
\item (Distinguishability) $\lim_{n \rightarrow \infty} \mathbb{E}_{x \sim H_1} [f(x)] \rightarrow \infty$.
\end{itemize}
\end{definition}
The normalization ensures appropriate scaling for the polynomial. Note that the normalization is over the null distribution. Informally, normalized $f$ is a successful distinguisher if it attains unbounded values on the alternate distribution in the limit. Indeed, in applications, a hypothesis test may be obtained by appropriately thresholding on the value of the polynomial.
The limit on the degree imposes the kind of computational restrictions we wish to impose on our distinguishing algorithm.
Trying to understand the power of such low-degree distinguishers for hypothesis testing problems is an active area of research.
For instance, we could ask: If degree $O(\log n)$ distinguishers fail for a hypothesis testing problem with input size $n^{O(1)}$, is the problem hard for all polynomial time algorithms?
The first natural question is to ask what's the best degree $D$ distinguisher for a given hypothesis testing problem. This has been answered in prior works and is simply the projection of the likelihood ratio $LR(x) = \frac{\mathrm{Pr}_{H_1}(x)}{\mathrm{Pr}_{H_0}(x)}$ to degree $D$ polynomials.
To make this precise, for $f, g: {\mathbb R}^n \rightarrow {\mathbb R}$, define the inner product $\ip{f}{g} = \mathbb{E}_{x \sim H_0} f(x)g(x)$. Then, we can canonically define the projection $f^{\le D}$ of a function $f$ to degree $D$ polynomials via this inner product. Take an orthonormal basis $\chi_0 = 1, \chi_1, \ldots, \chi_t$ of multivariate polynomials of degree at most $D$ where $\chi_0 = 1$ is the constant function. Then, $f^{\le D}(x) = \sum_{i \le t} \ip{f}{\chi_t}\chi_t(x)$.
The following lemma is implicit in prior works (e.g. \cite{hop17efficient, hopkins2018integrality}). We include a proof for completeness.
\begin{lemma}\label{lem: best_distinguisher}
For a hypothesis testing problem, the optimal degree $D$ test $f$ that maximizes $\mathbb{E}_{x \sim H_1} f(x)$ is the normalized low-degree likelihood ratio $\frac{LR^{\le D} - 1}{\norm{LR^{\le D} - 1}}$. Moreover, its value is $\mathbb{E}_{x \sim H_1}[f(x)] = \norm{LR^{\le D} - 1}$.
\end{lemma}
\begin{proof}
Let $f$ be a normalized degree $D$ polynomial with $f = \sum_{i = 0}^t c_t\chi_t$. Then, $c_0 = \mathbb{E}[f] = 0$ and $\sum c_i^2 = \mathbb{E}[f^2] = 1$. Then, \[\mathbb{E}_{x \sim H_1} f(x) = \sum_{1 \le i \le t} c_i \mathbb{E}_{x \sim H_1} \chi_i \le \sqrt{(\sum_{1 \le i \le t} c_i^2)(\sum_{1 \le i \le t} (\mathbb{E}_{x \sim H_1}\chi_i)^2)} = \sqrt{\sum_{1 \le i \le t} (\mathbb{E}_{x \sim H_1}\chi_i)^2}\]
On the other hand, equality is attained by the polynomial $g = \frac{LR^{\le D} - 1}{\norm{LR^{\le D} - 1}}$. Indeed, we have $\mathbb{E}_{x \sim H_0}[g] = 0$ because $\mathbb{E}_{x \sim H_0}[LR^{\le D}(x)] = \mathbb{E}_{x \sim H_0}[LR(x)] = 1$ and trivially, we have $\mathbb{E}_{x \sim H_0}[g(x)^2] = 1$ since we scaled by the norm. Finally,
\[\mathbb{E}_{x \sim H_1} g(x) = \frac{1}{\norm{LR^{\le D} - 1}} \sum_{1 \le i \le t} \ip{LR(x)}{\chi_i}^2\]
We complete the proof by observing that $\ip{LR(x)}{\chi_i} = \mathbb{E}_{x \sim H_0} [LR(x)\chi_i(x)] = \mathbb{E}_{x \sim H_1}[\chi_i(x)]$. Computing the value is straightforward.
\end{proof}
The low-degree likelihood ratio hypothesis \cite{hop17, hop18, kunisky19notes} hypothesizes that if $H_0, H_1$ are \textit{sufficiently nice} distributions, then there is a successful hypothesis test with running itme $n^{O(D)}$ if and only if there exists a successful degree $D$ distinguisher. In particular, based on the above discussion, if $\norm{LR^{\le D} - 1} = O(1)$, then we expect that there is no $n^{O(D)}$ time successful hypothesis test.
A main contribution of this work is to provide strong evidence that this conjecture is true for many fundamental problems, by exhibiting strong SoS lower bounds. To see this connection a bit more formally, we will introduce pseudo-calibration and connect it with low-degree distinguishers.
\section{Pseudo-calibration}\label{subsec: pseudocalibration}
Consider an optimization problem we are trying to show SoS lower bounds for.
To obtain SoS integrality gaps on random instances, we need to construct valid pseudo-expectation values for a random input instance of the problem. Naturally, these pseudo-expectation values will depend on the input.
Psuedo-calibration is a heuristic introduced by \cite{BHKKMP16} to construct such candidate pseudo-expectation values almost mechanically by considering a planted distribution supported on instances of the problem with large objective value and using this planted distribution as a guide to construct the pseudo-expectation values. Note here that, for historic reasons, we use the term random distribution instead of null distribution and the term planted distribution instead of alternative distribution.
Unfortunately, psuedo-calibration doesn't guarantee feasibility of these candidate pseudo-expectation values and the corresponding moment matrix and this has to be verified separately for different problems. This verification of feasibility is relatively easy except for the PSDness condition. This is where the main contribution of this work lies, where we analyze the behavior of the constructed random moment matrix.
Indeed for our applications, psuedocalibration is used to obtain a candidate pseudoexpectation operator $\tilde{\EE}$ and a corresponding moment matrix $\Lambda$
from the random vs planted problem. This will be the starting point for all our applications. Pseudo-calibration gives lower bounds for many problems, such as the ones considered in the works \cite{Grigoriev01, Schoenebeck08, KothariMOW17, chlamtavc2018sherali, mohanty2020lifting}, making it an intriguing but poorly understood technique.
Here, we do not attempt to motivate and describe pseudo-calibration in great detail. Instead, we will briefly describe the heuristic, the intuition behind it and show an example of how to use it. A detailed treatment can be found in \cite{BHKKMP16}.
Let $\nu$ denote the random distribution and $\mu$ denote the planted distribution. Let $v$ denote the input and $x$ denote the variables for our SoS relaxation. The main idea is that, for an input $v$ sampled from $\nu$ and any polynomial $f(x)$ of degree at most the SoS degree, pseudo-calibration proposes that for any low-degree test $g(v)$, the correlation of $\tilde{\EE}[f]$ should match in the planted and random distributions. That is,
\[\mathbb{E}_{v \sim \nu}[\tilde{\EE}[f(x)]g(v)] = \mathbb{E}_{(x, v) \sim \mu}[f(x)g(v)]\]
Here, the notation $(x, v) \sim \mu$ means that in the planted distribution $\mu$, the input is $v$ and $x$ denotes the planted structure in that instance. For example, in planted clique, $x$ would be the indicator vector of the clique. If there are multiple, pick an arbitrary one.
Let ${\mathcal F}$ denote the Fourier basis of polynomials for the input $v$. By choosing different basis functions from ${\mathcal F}$ as choices for $g$ such that the degree is at most some truncation parameter $D$, we get all lower order Fourier coefficients for $\tilde{\EE}[f(x)]$ when considered as a function of $v$. Furthermore, the higher order coefficients are set to be $0$ so that the candidate pseudoexpectation operator can be written as
\[\tilde{\EE} f(x) = \sum_{\substack{g \in {\mathcal F}\\deg(g) \le n^{\varepsilon}}} \mathbb{E}_{v \sim \nu}[\tilde{\EE}[f(x)]g(v)] g(v) = \sum_{\substack{g \in {\mathcal F}\\deg(g) \le n^{\varepsilon}}} \mathbb{E}_{(x, v) \sim \mu}[[f(x)]g(v)] g(v)\]
The coefficients $\mathbb{E}_{(x, v) \sim \mu}[[f(x)]g(v)]$ can be explicitly computed in many settings, which therefore gives an explicit pseudoexpectation operator $\tilde{\EE}$.
One intuition for pseudo-calibration is as follows. The planted distribution is usually chosen to be a maximum entropy distribution which still has the planted structure. This conforms to the philosophy that random instances are hard for SoS, such as the uniform Bernoulli distribution for planted clique or the Gaussian distribution for Tensor PCA. By conditioning on the lower order moments matching such a planted distribution, pseudo-calibration can be interpreted as sort of interpolating between the random and planted distributions by only looking at lower order Fourier characters. This intuition has proven to be successful, since pseudo-calibration been successfully exploited to construct SoS lower bounds for a wide variety of dense as well as sparse problems.
An advantage of pseudo-calibration is that this construction automatically satisfies some nice properties that the pseudoexpectation $\tilde{\EE}$ should satisfy. It's linear in $v$ by construction. For all polynomial equalities of the form $f(x) = 0$ that is satisfied in the planted distribution, it's true that $\tilde{\EE}[f(x)] = 0$. For other polynomial equalities of the form $f(x, v) = 0$ that are satisfied in the planted distribution, the equality $\tilde{\EE}[f(x, v)] = 0$ is approximately satisfied. In most cases, $\tilde{\EE}$ can be mildly adjusted to satisfy these exactly.
The condition $\tilde{\EE}[1] = 1$ is not automatically satisfied but in most applications, we usually require that $\tilde{\EE}[1] = 1 \pm \operatorname{o}(1)$. Indeed, this has been the case for all known successful applications of pseudo-calibration. Once we have this, we simply set our final pseudoexpectation operator to be $\tilde{\EE}'$ defined as $\tilde{\EE}'[f(x)] = \tilde{\EE}[f(x)] / \tilde{\EE}[1]$.
We remark that the condition $\tilde{\EE}[1] = 1 \pm \operatorname{o}(1)$ has been quite successful in predicting the right thresholds between approximability and inapproximability\cite{hop17, hop18, kunisky19notes}. This will be crucial when we connect pseudo-calibration to low degree distinguishers.
\paragraph{Example: Planted Clique}
As a warmup, we review the pseudo-calibration calculation for planted clique. Here, the random distribution $\nu$ is $G(n, \frac{1}{2})$.
The planted distribution $\mu$ is as follows. For a given integer $k$, first sample $G'$ from $G(n, \frac{1}{2})$, then choose a random subset $S$ of the vertices where each vertex is picked independently with probability $\frac{k}{n}$. For all pairs $i, j$ of distinct vertices in $S$, add the edge $(i, j)$ to the graph if not already present. Set $G$ to be the resulting graph.
The input is given by $G \in \{-1, 1\}^{\binom{[n]}{2}}$ where $G_{i, j}$ is $1$ if the edge $(i, j)$ is present and $-1$ otherwise. Let $x_1, \ldots, x_n$ be the boolean variables for our SoS program such that $x_i$ indicates if $i$ is in the clique.
Given a set of vertices $V \subseteq [n]$, define $x_V = \prod_{v \in V}{x_v}$. Given a set of possible edges $E \subseteq \binom{[n]}{2}$, define $\chi_E = (-1)^{|E \setminus E(G)|} = \prod_{(i, j) \in E}G_{i, j}$.
Pseudo-calibration says that for all small $V$ and $E$,
\[
\mathbb{E}_{G \sim \nu}\left[\tilde{E}[x_V]\chi_E\right] = \mathbb{E}_{\mu}\left[x_V{\chi_E}\right]
\]
Using standard Fourier analysis, this implies that if we take
\[
c_E = \mathbb{E}_{\mu}\left[x_V{\chi_E}\right] = \left(\frac{k}{n}\right)^{|V \cup V(E)|}
\]
where $V(E)$ is the set of the endpoints of the edges in $E$, then for all small $V$,
\[
\tilde{\EE}[x_V] = \sum_{E:E \text{ is small}}{{c_E}\chi_E} = \sum_{E:E \text{ is small}}{\left(\frac{k}{n}\right)^{|V \cup V(E)|}\chi_E}
\]
Since the values of $\tilde{\EE}[x_V]$ are known, by multi-linearity, this can be naturally extended to obtain values $\tilde{\EE}[f(x)]$ for any polynomial $f$ of degree at most the SoS degree.
Here, we only set the Fourier coefficients for small $E$ and set the other larger Fourier coefficients to $0$. Usually, the choice of the truncation parameter is problem specific but there are some basic requirements \cite{hop17}. We now outline our general strategy to show SoS lower bounds. We employ this in all our results.
\subsection{Strategy to show SoS lower bounds}\label{sec: strategy_for_sos_lower_bounds}
In this work, the general strategy to show SoS lower bounds can be summarized as follows.
\begin{itemize}
\item Given a random distribution, identify a suitable planted distribution
\item Pseudocalibrate with respect the two distributions and obtain a candidate pseudoexpectation operator
\item Show that the moment matrix satisfies the constraints
\end{itemize}
The most technically challenging part of this approach usually is to show that the moment matrix is positive semidefinite. Much of our contributions lies in this step, where we analyze the behavior of the random moment matrix thus obtained. Now, we connect pseudo-calibration to low-degree distinguishers.
\subsection{Connection to Low-degree distinguishers}
We are ready to connect psuedo-calibration to low-degree tests. Recall that in pseudo-calibration, we set the higher order Fourier coefficients to $0$. This is known as truncation. In particular, we truncate so that the resulting pseudoexpectation has degree at most $D$ in the input. By construction, $\mathbb{E}[\tilde{\EE}[1]] = 1$ and we would like to understand how much $\tilde{\EE}[1]$ deviates from $1$. The following lemma says that the variance of $\tilde{\EE}[1]$ behaves like the squared value of the optimal degree-$D$ distinguisher.
\begin{lemma}\label{lem: pcal_to_ldlr}
The pseudo-calibrated pseudo-expectation $\tilde{\EE}$, truncated to degree $D$, satisfies
\[\mathrm{var}(\tilde{\EE}[1]) = \norm{LR^{\le D} - 1}^2\]
\end{lemma}
\begin{proof}
Pseudocalibration sets $\mathbb{E}_{x \sim H_0}[\tilde{\EE}[1] \chi_i] = \mathbb{E}_{x \sim H_1} [\chi_i]$ for all $i \le t$. Therefore, $\tilde{\EE}[1] = 1 + \sum_{1 \le i \le t} \mathbb{E}_{x \sim H_1} [\chi_i] \chi_i$ giving $\mathrm{var}(\tilde{\EE}[1]) = \sum_{1 \le i \le t} (\mathbb{E}_{x \sim H_1}\chi_i)^2 = \norm{LR^{\le D} - 1}^2$.
\end{proof}
One of the essential steps in our SoS lower bound proofs is to verify, after pseudo-calibration, that $\tilde{\EE}[1]$ is well-behaved. In particular, for strong SoS lower bounds, we expect $\tilde{\EE}[1] = 1 + o(1)$. Although this is not formally necessary, it has often been the case in our applications and we expect it to be necessary for obtaining strong SoS lower bounds via this approach.
But when this is indeed the case and we exhibit SoS lower bounds, note that this is already strong evidence towards the low-degree likelihood ratio hypothesis. In more detail, because of \cref{lem: best_distinguisher} and \cref{lem: pcal_to_ldlr}, the best degree $D$ distinguisher does not distinguish the two distributions $\mu, \nu$. Our lower bounds affirm that the powerful SoS hierarchy cannot distinguish the two distributions as well, which is an important step towards the general hypothesis.
It's an important open problem in this field to prove that for sufficiently nice distributions $\mu, \nu$, after pseudo-calibrating, $\tilde{\EE}[1] = 1 + o(1)$ implies the existence of strong SoS lower bounds.
\section{Why Sum of Squares?}
We briefly remark on the successes of SoS in the last decade, especially in robust machine learning, a branch of machine learning where the underlying dataset is noisy, with the noise being either random or adversarial.
Robust machine learning has gotten a lot of attention in recent years because of its wide variety of use cases in machine learning and other downstream applications, including safety-critical ones like autonomous driving. For example, there has been a high volume of practical works in computer vision \cite{szegedy2013intriguing, goodfellow2014explaining, xie2019feature, hendrycks2021natural, sebe2013robust, xie2020adversarial, fischer2017adversarial, kurakin2016adversarial} and speech recognition \cite{hsu2021robust, wang2022wav2vec, rajendran2022analyzing, ravanelli2020multi, li2015robust, alzantot2018did, neekhara2019universal, olivier2022recent}.
In this important field, SoS has recently lead to breakthrough algorithms for
long-standing open problems \cite{bakshi2020robustly, liu2021settling, hopkins2020mean, klivans2018efficient, FKP19, kothari2017outlier, bakshi2020outlier, bakshi2020list, schramm2017fast}. Highlights include
\begin{itemize}
\item Robustly learning mixtures of high dimensional Gaussians. This is an extremely important problem that has been subjected to intense scrutiny, with a long line of work culminating in \cite{bakshi2020robustly, liu2021settling}.
\item Efficient algorithms for the fundamental problems of regression \cite{klivans2018efficient}, moment estimation \cite{kothari2017outlier}, clustering \cite{bakshi2020outlier} and subspace recovery \cite{bakshi2020list} in the presence of outliers.
\end{itemize}
Moreover, SoS algorithms are believed to be the optimal robust algorithm for many statistical problems. In a different direction, SoS algorithms have led to the design of fast algorithms for problems such as tensor decomposition \cite{hopkins2016fast, schramm2017fast}.
Broadly speaking, due to its ability to capture a wide variety of algorithmic techniques, SoS has become a fundamental tool in algorithms and optimization. It was and still remains an extremely versatile tool for combinatorial optimization \cite{GW94, AroraRV04, GuruswamiS11, raghavendra2017strongly}) but as we saw above, it is also being extensively used in Statistics and Machine Learning (apart from the references above, see also \cite{BarakBHKSZ12, bks15, HopSS15, pot17}). This sets the stage for the rest of this work where we analyze it for various problems of interest stemming from statistics and statistical physics. | {'timestamp': '2023-02-10T02:07:28', 'yymm': '2302', 'arxiv_id': '2302.04462', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04462'} | arxiv |
\section{Introduction}\label{sec:introduction}
A well understood property of learned models is that semantically indistinguishable samples can yield different model outputs~ \cite{biggio2013evasion}. When constructed deliberately, such samples are known as \textit{adversarial examples}. These examples, and their associated adversarial attacks pose a significant risk for models which are deployed within contexts where incentives to manipulate the output exist. This risk grows all the more when the difference between the example and the original sample point is minimised, as this heightens the difficulty of detecting such examples.
In contrast to detecting examples, \emph{adversarial defences} attempt to mitigate attack effects. While partially successful, these approaches are typically tied to particular attacks, and as such can be evaded by considering different attack pathways. Rather than attempting to defend against specific attacks, \emph{certified guarantees} of adversarial robustness eschew the attacker-defender paradigm by providing a (possibly high-probability) guarantee that no adversarial examples exist within a bounded region.
It is well known that models endowed with certified guarantees can still admit practical attacks~\cite{cohen2019certified}. In fact, as we report on, \emph{certified guarantees themselves can be exploited} to more efficiently construct adversarial perturbations. While these perturbations exist outside the certification region, exploiting this previously unavailable attack surface allows for the construction of adversarial perturbations that are smaller than state-of-the-art. Such perturbations have a higher chance to evade detection, even in the case of human-in-the-loop verification systems~\cite{gilmer2018motivating}.
Motivated by the potential for misuse of certifications, we seek to answer the following questions:
\begin{enumerate}
\item How should adversarial examples be defined against models defended by Randomised Smoothing?
\item Can current approaches for attacking neural networks be extended to attack certifiably robust models?
\item Is it possible to exploit the nature of certifications to improve the efficacy of constructing adversarial attacks?
\end{enumerate}
The last of these questions is both the most intriguing and concerning, as it suggests that the very tools that we deploy to hinder adversarial attacks may also benefit the attackers.%
While uncovering new attacks has the potential to compromise deployed systems, there is a prima facie argument that any security provided by ignoring new attack vectors is illusory. Taking such a perspective has allowed security researchers to uncover attack vectors ranging from adversarial examples through to data poisoning, backdoor attacks, model stealing, transfer attacks and more. Within this work we demonstrate how the nature of certified guarantees admits a heretofore undiscovered attack surface, which allows norm-minimising adversarial examples to be detected through what we dub a \emph{Certification Aware Attack}.
\section{Adversarial Examples}\label{sec:related_work}
It has been consistently demonstrated that learned models can be exploited to produce highly confident but incorrect predictions~\cite{szegedy2013intriguing}, which can oftentimes be driven by the existence of piecewise-linear intra-model interactions \cite{goodfellow2014explaining}.
While many vectors exist to exploit this vulnerability, within this work we focus exclusively upon mechanisms that construct adversarial perturbations to evaluation-time (rather than training-time) data in a fashion that changes the model's output class.
The distance between an adversarial example and its corresponding sample point can be a reliable proxy for the \emph{detectability} of the adversarial example~\cite{gilmer2018motivating} and attacker cost~\cite{huang2011adversarial}. While their motivations vary, both attackers and defenders seek to find the distance to the nearest possible adversarial attack
\begin{align}\label{eqn:r_definition}
r &= \argmin_{\mathbf{x}' \in \Omega} \|\mathbf{x}' - \mathbf{x} \|_p \\
&\text{ where } \Omega = \{\mathbf{x}' \in [0,1]^d | F(\mathbf{x}') \neq F(\mathbf{x}) \}\nonumber %
\end{align}
to a sample point $\mathbf{x} \in [0,1]^d$ to be attacked. Here $r$ is the $p$-norm distance to the nearest possible adversarial example; and $F(\mathbf{x})$ is a mechanism that outputs a predicted class. %
While many approaches exist for constructing $\mathbf{x}'$, within this work we focus upon a set of key, representative techniques, that will serve as the basis of comparison to our new adversarial attack. The first of these is known as the Iterative Fast Gradient Method \cite{dong2018boosting} variant of Projected Gradient Descent (PGD) \cite{carlini2017towards}, which iteratively constructs adversarial examples by way of
\begin{equation}\label{eqn:PGD_its}\boldsymbol{x}_{k+1} = P \left( \boldsymbol{x}_{k} - \epsilon \left(\frac{\nabla_{\boldsymbol{x}} J(\theta, \boldsymbol{x}, y)}{\norm{\nabla_{\boldsymbol{x}} J(\theta, \boldsymbol{x}, y)}_{2}}\right) \right)\enspace.\end{equation}
This process exploits gradients of the loss $J(\theta, \boldsymbol{x}, y)$ to construct steps, subject to a step-size weighting parameter $\epsilon$, and a projection operator $P$ that ensures that $\boldsymbol{x}_{k+1}$ is restricted to the feasible input space, which is typically $[0,1]^d$ for a $d$-dimensional input space. Many PGD extensions exist, including momentum-based variants \cite{dong2018boosting} and AutoAttack \cite{croce2020reliable}.
Of these extensions, AutoAttack has received significant attention due to its prowess in identifying adversarial examples. In contrast to PGD, which sets a fixed step-size $\epsilon$, AutoAttack algorithmically specifies the step-size at each stage of its iterative process in the aide of converging upon adversarial examples with a pre-specified $L_2$ norm perturbation magnitude (which obtusely is also labelled as $\epsilon$). This pre-specified perturbation is problematic within contexts for which a norm-minimising perturbation is desirable. Our preliminary investigations have suggested that the only way to minimise the perturbation magnitude is to perform a greedy search over a range of possible pre-specified magnitudes, which is inherently problematic due to the computational cost of employing AutoAttack.
\citet{carlini2017towards} (C-W) construct adversarial perturbations by way of the minimisation problem
\begin{align}\label{eqn:CW}
\min_{\boldsymbol{x}'} & \left\{ \norm{\boldsymbol{x}' - \boldsymbol{x}}_{2}^{2} + \right. \\
& \left. \max \left\{ \max \{ f_{\theta}(\boldsymbol{x}')_{j} : j \neq i\} - f_{\theta}(\boldsymbol{x}')_{i}, -\kappa \right\}
\vphantom{ \norm{\boldsymbol{x}' - \boldsymbol{x}}_{2}^{2} }
\right\} \enspace, \nonumber %
\end{align}
which constructs an attack $\mathbf{x}'$ in terms of the trained model $f_{\theta}(\boldsymbol{x})$ (with weights $\theta$). Equation~\ref{eqn:CW} then compares the logit value of the target class $i$ with that of the next most likely class, subject to the parameter $\kappa$. The gradients of the solution to this are then solved in the fashion of Equation~\ref{eqn:PGD_its}. %
The final baseline attack that we will consider is DeepFool, which constructs untargetted $L_2$-norm attacks by attacking a linearised variant of the model. This proxy model is then updated using information from the attacks~\cite{moosavi2016deepfool} in a manner that allows for automatic step-size control.%
\subsection{Certification Mechanisms}
Rather than focusing upon any one adversarial example, certification mechanisms conceptually invert Equation~\ref{eqn:r_definition}, using it instead as a framework for attempting to provably guarantee the lack of adversarial examples up to some radius $r$. However, attempting such a process directly by rigorously exploring the input space of $\mathbf{x}'$ to comprehensively define $\Omega$ would be prohibitively expensive. Instead certification mechanisms typically examine the neighbourhood of $\mathbf{x}$ to find some proxy to $r$, that guarantee (or to high probability ensures) that the predicted class changes.
One common mechanism for constructing such certifications is \emph{randomised smoothing}~\cite{lecuyer2019certified}, which employs repeated sampling to certify against \emph{additive} perturbations up to some $L_p$-norm $r$ against a \emph{smoothed} version of the classifier, yielding an isotropic region of guaranteed class invariance covering
\begin{equation}
B_P(\mathbf{x}, r) := \left\{\mathbf{y} \in [0,1]^d | r \geq \|\mathbf{y} - \mathbf{x}\|_{P} \right\}\enspace.
\end{equation}
The smoothed classifier involves estimating the expected output of the model under repeated samples of Gaussian noise, such that
\begin{align}\label{eqn:expectations}
E_{\mathbf{X}}[&\argmax f_{\theta}(\mathbf{X}) = i] \approx \frac{1}{N} \sum_{j=1}^{N} \mathds{1}[\argmax f_{\theta}(\mathbf{X}) = i] \nonumber \\
&\mathbf{X} \stackrel{i.i.d.}{\sim} \mathbf{x} + \mathcal{N}(0, \sigma^2)\enspace.
\end{align}
Making this approximation makes constructing certifications computationally tractable, but comes at the cost of relaxing the associated guarantees from an absolute absence of adversarial examples to a high probability guarantee.
Numerous mechanisms exist for constructing certifications within such a framework, including differential privacy~\cite{lecuyer2019certified,dwork2006calibrating}, R\'{e}nyi divergence \cite{li2018certified}, and parametrising worst-case behaviours \cite{cohen2019certified, salman2019provably, cullen2022double}. The latter of these approaches has proved the most performant, and yields certifications that resemble
\begin{equation}\label{eqn:Cohen_Bound}
r = \frac{\sigma}{2} \left( \Phi^{-1}\left(\widecheck{E}_{0}[\mathbf{x}]\right) - \Phi^{-1}\left(\widehat{E}_{1}[\mathbf{x}]\right) \right)\enspace.
\end{equation}
In the interests of simplifying notation, we define $(E_0, E_1) = \topk\left(E_{\mathbf{X}}[\argmax f_{\theta}(\mathbf{X}) = i], 2\right)$ for the two largest class expectations. These quantities are mapped into what are respectively the lower and upper bounds $(\widecheck{E}_0, \widehat{E}_1)$ to some confidence level $\alpha$ (as calculated by way of the Goodman \etal \cite{goodman1965simultaneous} confidence interval). Beyond this $\sigma$ represents the level of additive noise, and $\Phi^{-1}$ is the inverse normal CDF, or Gaussian quantile function.
This is not to say that randomised smoothing is the only mechanism for achieving certifications. Other approaches typically attempt to construct bounding polytopes using either propagating interval bounds through the model (Interval Bound Propagation or IBP); or employing linear relaxation to construct bounding output polytopes over input bounded perturbations~\cite{salman2019convex, mirman2018differentiable, weng2018towards, CROWN2018, zhang2018efficient, singh2019abstract, mohapatra2020towards}, which generally provides tighter bounds than IBP~\cite{lyu2021towards}.
In contrast to randomised smoothing, IBP and convex relaxation employ augmented training processes to incentivise tight bounds \cite{xu2020automatic}, which requires significant model re-engineering. Moreover both of these approaches exhibit a time and memory complexity that makes them infeasible for complex model architectures or high-dimensional data~\cite{wang2021beta, chiang2020certified, levine2020randomized}. While the mechanisms that we will describe in the following sections can be applied to these methods, for the remainder of this work we will focus upon the more popular and scalable randomised smoothing.
\section{Attacking Randomised Smoothing}\label{sec:attacking_randomised}
That randomised smoothing constructs high-concentrated outputs that are nonetheless still random suggests that particular care is required to define what a successful adversarial attack looks like. One approach would be to attack the individual model draws under noise, in a fashion similar to Expectation Over Transformation~\cite{athalye2018synthesizing}. However, doing so would be inherently inefficient, as the attacker would eschew the advantages gained by the deterministic model structure in certification mechanisms.
Instead we suggest that a successful attack in this context should be one in which an adversarial perturbation $\boldsymbol{\delta}$ induces an expected class output change, of the form
\begin{align} \label{eqn:general_robust}
&\argmax_{i \in \mathcal{K}} E\left[f_j\left(\boldsymbol{X} + \boldsymbol{\delta} \right) = i \right] \\
\neq & \argmax_{i \in \mathcal{K}} E\left[ f\left(\boldsymbol{X}\right) = i \right] \nonumber
\end{align}
for some model $f(\mathbf{x}) \in \mathcal{K}$. To ensure that this attack is \emph{confident}, and not a product of the uncertainties inherent in the Monte-Carlo expectation process of Equation~\ref{eqn:expectations}, we add the additional condition that
\begin{equation}\label{eqn:attack_criteria}
\widecheck{\mathbb{E}_{k}}[f_{\theta}(\mathbf{X} + \boldsymbol{\delta})] > \widehat{\mathbb{E}_{i}}[f_{\theta}(\mathbf{X} + \boldsymbol{\delta})] \; \text{, for some } k \in \mathcal{K} \setminus i \enspace.
\end{equation}
That the underlying attack framework is still deterministic (with high probability) allows any of the attack frameworks within Section~\ref{sec:related_work} to be applied to this problem space.
The very nature of randomised smoothing would at first principles suggest that it may be easier to attack models employing it as a certification mechanism, as the smoothing process is analogous to a Gaussian blur of the decision space. Such a blurring would likely decrease the local variance of gradients in this space, and make it easier to identify nearby adversarial examples. However, one complicating factor is the presence of nondifferentiable $\argmax$ layers at the final layer of models $f(\mathbf{x})$. This limitation can be circumvented by any attacker with sufficient access, by replacing $\argmax$ layers with the Gumbel Softmax~\cite{jang2016categorical}%
\begin{equation}\label{eqn:gumbel}
y_i = \frac{\exp\left((\log(\pi_i) + g_i) / \tau \right)}{\sum_{j \in \mathcal{K}} \exp\left((\log(\pi_i) + g_i) / \tau \right)} \text{ for all } i \in \mathcal{K}\enspace.
\end{equation}
The ability of an attacker to modify the final layer to admit differentiation implies that the attacker must have some level of access to the model. However, such a level of access should be considered as a subset---rather than an extension---of the white-box assumption that is implicitly required to access gradient-based information. The only extension to a traditional white-box access model is the need to understand the level of added noise $\sigma$.
While such a white-box attack framework is limiting, prior works have demonstrated that it may be possible to successfully attack black-box models by way of surrogate models~\cite{papernot2017practical}, effectively converting black-box models into white-box models, that are suitable for attack. Moreover, as will be discussed in Appendix~\ref{app:sigma_accuracy}, the attacker does not require exact knowledge of $\sigma$, with even approximate values still yielding an attack which exhibits improved performance relative to comparable attacks.
We also emphasise that a number of other approaches can also be employed to circumvent concerns relating to differentiability, including stochastic gradient estimation~\cite{fu2006gradient, chen2019fast} and surrogate modelling. However, as the focus of this work is upon the applicability of attacks themselves, we choose to facilitate gradient-based adversarial attacks by way of the Gumbel-Softmax.
\section{Certification Aware Attacks}\label{sec:CAA}
The aforementioned approach allows any attack to be applied to models defended by randomised smoothing. However, %
we may further improve attack efficiency by exploiting the guarantees of certified robustness to construct smaller adversarial perturbations.
This is made possible by considering certifications not as guarantees regarding where adversarial attacks can not exist, but but as lower bounds on the space where attacks may exist.
Certifications exist not just at a point of interest, but across the instance space~\cite{cullen2022double}. Accordingly, we can exploit not just the sample point's certification, but at all points along an attack's iterative sequence. Moreover, once we identify an adversarial example, the certifications associated with successful attacks can be \emph{exploited to minimise the perturbation norm of the attacks themselves}.
To achieve this, we begin by solving the surrogate problem
\begin{align}\label{eqn:surrogate_problem}
\hat{\mathbf{x}} = & \argmin_{\hat{\mathbf{x}}} |E_0(\hat{\mathbf{x}}) - E_1(\hat{\mathbf{x}})| \\
& \text{s.t.}\; \argmax f(\hat{\mathbf{x}}) = f(\mathbf{x})\enspace. \nonumber
\end{align}
This formalism may seem counter-intuitive: the constraint ensures that $\hat{\mathbf{x}}$ cannot be an adversarial example. However, consider the gradient-based solution of the previous problem
\begin{equation}\label{eqn:CAA_iter}
\mathbf{x}_{i+1} = P\left(\mathbf{x}_{i} - \epsilon_i \left(\frac{\nabla_{\boldsymbol{x}_i} | E_0[\mathbf{x}_i] - E_1[\mathbf{x}_i] |}{\norm{ \nabla_{\boldsymbol{x}_i} | E_0[\mathbf{x}_i] - E_1[\mathbf{x}_i] |}} \right)\right)
\end{equation}
for which each $\mathbf{x}_i$ has associated certifications $r_i$. If we were to set that $\epsilon_i \leq r_i$, then by Equation~\ref{eqn:surrogate_problem} we can confidently state that $\mathbf{x}_{i+1}$ will always predict the same class as $\mathbf{x}_{i} \forall \text{ } i \in \mathbb{N}$, as each new sample does not move beyond the certified radius of the prior point, and thus $\mathbf{x}_{i+1}$ cannot elicit a change in the output class. However if we instead impose that $\epsilon_i \geq r_i$, we ensure that the new candidate solution $\mathbf{x}_{i+1}$ outside the region of certification of the previous point. Doing so is a \emph{necessary but not sufficient} condition for identifying an adversarial example.
\subsection{Specifying $\epsilon_i$}\label{sec:specifying}
One mechanism for ensuring that $\epsilon_i \geq r_i$ would simply be to set the $\epsilon_i$ of Equation~\ref{eqn:CAA_iter} to be
\begin{equation}\label{eqn:epsilon_basic}
\epsilon_i = r(\mathbf{x}_i) \left(1 + \delta\right)\enspace,
\end{equation}
for some $\delta > 0$. However, in doing so we are only taking into account the region of certification at $\mathbf{x}_{i}$, rather than for all $\mathbf{x}_{j}$ for $j = 0, \ldots, i$. The additional information about the potential region within which adversarial examples exist can be factored in by instead defining
\begin{align}\label{eqn:epsilon_complex}
\epsilon_i = & \left(1 + \delta \right) \argmax_{\hat{\epsilon}} \|\hat{\mathbf{x}}(\hat{\epsilon}) - \mathbf{x}_{i}\| \nonumber \\
&\text{ s.t. } \hat{\mathbf{x}} (\tilde{\epsilon}) \in \bigcup_{j=0}^{i} B_P(\mathbf{x}_{j}, \mathds{1}_{c_{0} = c_{j}} r_j) \text{ } \forall \text{ } \tilde{\epsilon} \in [0, \hat{\epsilon}], \nonumber \\
&\text{ where } c_i = \argmax_{i \in \mathcal{K}} E[f(\mathbf{x}) = i] \\
&\text{ and } \mathds{1}_{c_{0} = c_{i}} = \begin{cases}
1\hspace{0.5cm} \text{if } c_{0} = c_{i}\\
0\hspace{0.5cm} \text{if } c_{0} \neq c_{i}
\end{cases}\nonumber %
\end{align}
for an $\mathbf{x}_{i+1}(\epsilon_i)$ as defined by Equation~\ref{eqn:CAA_iter}.
This condition attempts to find the step size $\epsilon_i$ that maximises the distance between $\mathbf{x}_i$ and a new candidate solution $\hat{\mathbf{x}}$, while ensuring that the vector spanning $\mathbf{x}_i$ and $\hat{\mathbf{x}}$ remains strictly inside the region of previously certified examples predicting the same class as the original sample point $\mathbf{x}_0$.
The multiplicative factor of $(1 + \delta)$ ensures that the new candidate solution remains outside the region of prior certification if $\delta > 0$. However, in practice taking such large steps may be disadvantageous in certain contexts, and as such in practice we define $\epsilon_i$ such that
\begin{equation}\label{eqn:step_size_limits}
\tilde{\epsilon}_i = \clip\left(\epsilon_i, \epsilon_{\text{min}}, \epsilon_{\text{max}} \right)\enspace,
\end{equation}
where $\check{\epsilon}_i$ and $\hat{\epsilon}_i$ are pre-defined lower- and upper-bounds upon $\epsilon_i$. The details of how these parameters can be set experimentally can be found in Appendix~\ref{app:parameter_exploration}. %
\subsection{Refining Adversarial Examples}\label{sec:refining}
The logic behind exploiting certifications to help guide identifying adversarial examples can also be applied to \emph{refine} any identified examples. In doing so, we are able to minimise the perturbation norm, and ideally decrease the detectability of the attack. To achieve this, consider
the point $\mathbf{x}_i$, which results in a class prediction $c_i \neq c_0$ and certification radii $r_i$. The very nature of this certification guarantees that a step of size $\epsilon_i \leq r_i$ will produce a class prediction $c_{i+1} = c_{i} \neq c_0$, leading to the iterative scheme%
\begin{align}\label{eqn:correction}
\mathbf{x}_{i+1}(\epsilon) &= \mathbf{x}_{i} + \epsilon \frac{\mathbf{x}_0 - \mathbf{x}_i}{\|\mathbf{x}_0 - \mathbf{x}_i\|}\\
\text{where } \epsilon_i &= (1 - \delta) \argmin_{\hat{\epsilon}} \|\hat{\mathbf{x}}(\hat{\epsilon}) - \mathbf{x}_0\| \nonumber \\
\text{ s.t. } \mathbf{x}_{i} + \tilde{\epsilon} \frac{\mathbf{x}_0 - \mathbf{x}_i}{\|\mathbf{x}_0 - \mathbf{x}_i\|} &\in \bigcup_{j=0}^{i} B_P(\mathbf{x}_{j}, \mathds{1}_{c_{0} \neq c_{j}} r_j) \text{ } \forall \text{ } \tilde{\epsilon} \in [0, \hat{\epsilon}] \nonumber %
\end{align}
At first glance, this may appear to be a restatement of Equation~\ref{eqn:epsilon_complex} subject to a modified condition on the set of $B_P$, however there are key differences in both the equations themselves and their implications. While Equation~\ref{eqn:epsilon_complex} attempts to identify the largest adversarial step size that ensures that $\mathbf{x}_{i+1}$ moves outside the region certified by all previous elements in the sequence, Equation~\ref{eqn:correction} instead identifies the largest step size perturbation that minimises the norm distance to $\mathbf{x}_0$ while retaining an adversarial perturbation relative to this points predicted class. %
It must be emphasised though that this framing ensures that $c_{i} = c_{j} \text{ } \forall \text{ } j > i$---that is, once an adversarial example predicting a particular class has been identified, any subsequent adversarial examples will share the same prediction class. As such, even if the model is able to find the smallest adversarial example for the predicted class reached by this sequence, if the model is not a binary classifier it may be that there exists some adversarial example $\mathbf{x}''$ such that
$$\|\mathbf{x}'' - \mathbf{x}_0\| < \|\mathbf{x}_{i} - \mathbf{x}_0\| \qquad \forall \text{ } i \in \mathbb{N} \enspace.$$
While the above may be true, we emphasise that this process still has the potential to yield significantly smaller adversarial perturbations than can be identified through other techniques, a result that is made possible by exploiting the additional attack surface introduced by certified robustness.
\subsection{Algorithm}\label{sec:main_algorithms_section}
The aforementioned processes can be distilled into Algorithms~\ref{alg:CAA}, \ref{alg:model_predict} and \ref{alg:step_size}, the latter of which can be found within Appendix~\ref{app:algorithms}. Algorithm~\ref{alg:CAA} summarises the process of identifying a norm-minimisng adversarial example $\mathbf{x}'$, that induces a change in class prediction from $\mathbf{x}$. To ensure that a confident adversarial attack---in which $\widecheck{E}_0 > \widehat{E}_1$---is achieved the iterative process begins with Line $17$ minimising the gap between $\widecheck{E}_0$ and $\widehat{E}_1$, with each iterative step constructed such that the candidate attack is taken outside the certified radii of each prior sample.
Once a sample is found that changes the predicted class, but does not yet yield a confident solution, Line $13$ then attempts to maximise $\widecheck{E}_0 - \widecheck{E}_1$. Once a confident solution has been found Line $7$ minimises the norm difference between $\mathbf{x}'$ and $\mathbf{x}$. This step, while ostensibly trivial, is given utility by the constraint of Line $11$, which ensures that the candidate solution remains within region of samples which predict the adversarial class. A high level summary of this process can be seen within Figure~\ref{fig:circle_progressions}. Starting from an initial sample point of interest, we construct a $B_P(\mathbf{x}, r)$ describing the region of guaranteed class invariance for our learned function $f(\mathbf{x})$.
\begin{figure}
\centering
\includegraphics[width=.6\linewidth]{Figures/circles}
\caption{Diagrammatic Representation of the process outlined within Algorithm~\ref{alg:CAA}. Here blue and red circles respectively represent certifications of the label class and certifications of an adversarial class, with arrows representing steps of the iterative process. }\label{fig:circle_progressions}
\end{figure}
\begin{algorithm}[tb]
\caption{Certification Aware Attack Algorithm.}%
\label{alg:CAA}
\begin{algorithmic}[1]
\STATE {\bfseries Input:} data $\mathbf{x}$, level of additive noise $\sigma$, samples $N$, iterations $M$, true-label $i$, minimum and maximum step size $\left(\epsilon_{\text{min}}, \epsilon_{\text{max}} \right)$, scaling factors $(\delta_1, \delta_2)$ [where $\delta_1 \in (0, 1)$ and $\delta_2 \in (1, \infty)$
\STATE $\mathbf{x}', \mathbf{x}'_s, m = \mathbf{x}, \mathbf{0}, \infty$
\STATE $\mathcal{S}_i = [] \text{ } \forall i \in \mathcal{K}$
\FOR{$1$ {\bfseries to} $M$}
\STATE $\mathbf{y}, \widecheck{E}_0, \widehat{E}_1, r = \text{Model}(\mathbf{x}'; \sigma, N)$ \algorithmiccomment{Detailed in Algorithm~\ref{alg:model_predict}}
\STATE Append $(\mathbf{x}', r)$ to $\mathcal{S}_{\argmax \mathbf{y} = i}$
\IF{$\argmax_{j \in \mathcal{K}} y_j \neq i$}
\IF{$\widecheck{E}_0 > \widehat{E}_1$}
\STATE $d = \nabla_{\mathbf{x}'} \left( \norm{\mathbf{x}' - \mathbf{x}}\right)$
\IF{$\|\mathbf{x}' - \mathbf{x}\| < m$}
\STATE $m, \mathbf{x}'_s = \|\mathbf{x}' - \mathbf{x}\|, \mathbf{x}'$ \algorithmiccomment{New smallest perturbation has been identified}
\ENDIF
\STATE $\epsilon = $ Algorithm~\ref{alg:step_size}$(\mathcal{S}_{\argmax \mathbf{y} \neq i}, \mathbf{x}', d, r)$ %
\STATE $\epsilon = \clip(\delta_1 \epsilon, \epsilon_{\text{min}}, \epsilon_{\text{max}})$ %
\ELSE
\STATE $d = -\nabla_{\mathbf{x}'} \left( \widecheck{E}_0 - \widehat{E}_1 \right)$ %
\STATE $\epsilon = \epsilon_{\text{min}}$ \algorithmiccomment{When $\widecheck{E}_0 < \widehat{E}_1$ it must be that $r=0$. Setting $\epsilon = \epsilon_{min}$ avoids this}
\ENDIF
\STATE $\mathbf{x'} = P(\mathbf{x'} - \epsilon \frac{d}{\|d\|_2})$ \algorithmiccomment{Project upon $[0,1]^d$}
\ELSIF{$\argmax y = i$}
\STATE $\epsilon = $ Algorithm~\ref{alg:step_size}$(\mathcal{S}_{\argmax \mathbf{y} = i}, \mathbf{x}', d)$ %
\STATE $\epsilon = \clip(\delta_2 \epsilon, \epsilon_{\text{min}}, \epsilon_{\text{max}})$
\STATE $\mathbf{x}' = P\left(\mathbf{x}' + \epsilon \frac{\mathbf{x}_0 - \mathbf{x}'}{\|\mathbf{x}_0 - \mathbf{x}'\|}\right)$
\ENDIF
\ENDFOR
\STATE \textbf{return} $m, \mathbf{x}'_s$
\end{algorithmic}
\end{algorithm}
\section{Results}
\begin{table}
\caption{Metrics for MNIST (M), CIFAR-$10$ (C), and Imagenet (I) across $\sigma$, covering the proportion of successful attacks, and the proportion of attacks which outperform all other approaches (\emph{Succ.} and \emph{Best}); the median attack size and time ($r_{50}$ and \emph{Time} (s)); and the percentage difference to the certified guarantee of Cohen \etal}
\label{tab:main_times}
\centering
\begin{tabular}{lllllll}
\toprule
\multicolumn{2}{c}{ } & \multicolumn{5}{c}{Smallest Attack} \\
Data & Type & Succ. & Best & $r_{50}$ & $\%$-C & Time \\%(s) \\
\cmidrule(r){1-2} \cmidrule(r){3-7}
M-$.5$ & Ours & $65\%$ & $51\%$ & $1.86$ & $56$ & $0.46$ \\
& PGD & $51\%$ & $15\%$ & $1.81$ & $54$ & $2.50$ \\
& C-W & $93\%$ & $17\%$ & $8.67$ & $605$ & $1.37$ \\
& Auto & $81\%$ & $17\%$ & $5.50$ & $357$ & $47.2$ \\
& Fool & $4\%$ & $0\%$ & $8.42$ & $2126$ & $0.16$ \\
\cmidrule(r){1-2} \cmidrule(r){3-7}
M-$1$ & Ours & $100\%$ & $97\%$ & $2.46$ & $58$ & $0.45$ \\
& PGD & $68\%$ & $2\%$ & $2.19$ & $68$ & $2.41$ \\
& C-W & $94\%$ & $0\%$ & $9.50$ & $494$ & $1.06$ \\
& Auto & $100\%$ & $0\%$ & $6.80$ & $338$ & $45.5$ \\
& Fool & $43\%$ & $0\%$ & $16.53$ & $1503$ & $0.15$ \\
\cmidrule(r){1-2} \cmidrule(r){3-7}
C-$.5$ & Ours & $91\%$ & $83\%$ & $0.91$ & $56$ & $0.22$ \\
& PGD & $88\%$ & $7\%$ & $0.96$ & $65$ & $2.65$ \\
& C-W & $91\%$ & $1\%$ & $6.74$ & $865$ & $1.35$ \\
& Auto & $99\%$ & $9\%$ & $4.00$ & $495$ & $49.6$ \\
& Fool & $85\%$ & $0\%$ & $2.94$ & $486$ & $0.16$ \\
\cmidrule(r){1-2} \cmidrule(r){3-7}
C-$1$ & Ours & $100\%$ & $94\%$ & $1.32$ & $67$ & $0.30$ \\
& PGD & $94\%$ & $4\%$ & $1.45$ & $90$ & $2.60$ \\
& C-W & $96\%$ & $0\%$ & $7.19$ & $751$ & $1.16$ \\
& Auto & $96\%$ & $1\%$ & $4.99$ & $493$ & $48.9$ \\
& Fool & $98\%$ & $0\%$ & $3.32$ & $457$ & $0.17$ \\
\cmidrule(r){1-2} \cmidrule(r){3-7}
I-$.5$ & Ours & $54\%$ & $71\%$ & $1.03$ & $123$ & $3.12$ \\
& PGD & $59\%$ & $13\%$ & $1.25$ & $141$ & $31.0$ \\
& C-W & $56\%$ & $16\%$ & $33.56$ & $4248$ & $28.2$ \\
& Fool & $54\%$ & $0\%$ & $3.08$ & $663$ & $4.59$ \\
\cmidrule(r){1-2} \cmidrule(r){3-7}
I-$1$ & Ours & $40\%$ & $48\%$ & $1.10$ & $227$ & $4.08$ \\
& PGD & $46\%$ & $12\%$ & $1.68$ & $254$ & $31.0$ \\
& C-W & $70\%$ & $20\%$ & $36.10$ & $2998$ & $24.4$ \\
& Fool & $67\%$ & $20\%$ & $5.88$ & $748$ & $4.61$ \\
\bottomrule
\end{tabular}
\end{table}
To assess our newly identified attack vector, we focus our experiments in two primary directions: against the representative approaches outlined within Section~\ref{sec:related_work}; and against the certified guarantees provided by Equation~\ref{eqn:Cohen_Bound}. The first of these comparisons is intended to demonstrate progression over state of the art, while the second is intended to elucidate the difference between the size of certified guarantees---which are a \emph{conservative bound} upon the size of adversarial perturbations---against realisable adversarial attacks. The gap between the best performant attacks and the certified guarantees in turn can be considered as evidence for the potential to improve either certifications, attacks, or both.
To aide in these comparisons, we introduce the concept of the \textit{attack proportion}: the proportion of correctly predicted samples that have an identified attack below a given $L_2$-norm radius. As the certified radius provides a lower bound on the size of any individual attack, the largest attack proportion at any radius must be that associated with the certification. %
To achieve this, we performed comprehensive experimental validation against MNIST \citep{lecun1998gradient} (GNU v3.0 license), CIFAR-$10$ \citep{krizhevsky2009learning} (MIT license), and the Large Scale Visual Recognition Challenge variant of Imagenet \citep{deng2009imagenet, russakovsky2015imagenet} (which uses a custom, non-commercial license). Each model was trained in PyTorch~\citep{NEURIPS2019_9015} using a ResNet-$18$ architecture, with experiments considering two distinct levels of $\sigma$. Additional experiments involving the MACER~\cite{zhai2020macer} certification framework and a ResNet-$110$ architecture can be found in Appendix~\ref{app:macer}. The confidence intervals of expectations in all experiments was set according to the $\alpha = 0.005$ significance level.
Our experiments involving our \textbf{Certification Aware Attack} set the offsets $\delta_1$ and $\delta_2$ to $1.05$ and $0.95$. That $\delta_1 > 1$ ensures that the step is large enough to potentially induce a change in class, while setting $\delta_2 \leq 1$ ensures that the predicted class does not change after an adversarial example has been identified. The resultant step sizes are then clipped to sit between $0.1$ and $0.25$ through Equation~\ref{eqn:step_size_limits}, to ensure that over-stepping doesn't occur. Details of the experiments that yielded these specific hyperparameter choices can be found in Appendix~\ref{app:parameter_exploration}.
Following previous experimental works, we employed the following hyperparameters for each attack framework. For \textbf{Carlini-Wagner}, we set the $\kappa$ of Equation~\ref{eqn:CW} to $0$, and weighted the loss from the one-hot encoding by $10^{-4}$. The Carlini-Wagner training process was conducted using a learning rate of $0.01$ over $100$ iterations. Similarly \textbf{DeepFool} also employed $100$ iterations, and employed an overshoot factor of $0.02$. The parameter space of \textbf{PGD} was informed by the parameter study of Appendix~\ref{app:parameter_exploration}, leading to $\epsilon$ being set at $\frac{20}{255}$ over $100$ iterative steps. %
\textbf{AutoAttack} was performed using the randomised model variant, with the \emph{maximum attack radii} set at $\max\{5 \times R, 0.1\}$, where $R$ was calculated by Equation~\ref{eqn:Cohen_Bound}. AutoAttack was eschewed for Imagenet for runtime considerations.
Experiments on both MNIST and CIFAR-$10$ were performed upon a single NVIDIA A$100$ GPU core with $48$ GB of GPU RAM (with maximum GPU RAM utilisation being on the order of $12$ GB across all experiments), with expectations estimated over $1500$ samples. Over the course of $50$ epochs of training, each sample was perturbed with a single perturbation drawn from $\mathcal{N}(0, \sigma^2)$ and added prior to normalisation. Training then utilised a batch size of $128$, with losses assessed against the Cross Entropy loss. Parameter optimisation was performed with Adam \citep{kingma2014adam}, with the learning rate set as $0.001$. Imagenet was trained using a single A$100$ GPU, with $2$ additional GPU's being employed for evaluation. Training occurred using SGD over $80$ epochs, with a starting learning rate of $0.1$, decreasing by a factor of $10$ after $30$ and $60$ epochs, and momentum set to $0.9$. As our current attack implementation does not incorporate any batching, to preserve system resources we decreased the number of samples associated with the expectation calculations in Imagenet to $600$.
\paragraph{Performance against other attacks} Across our full set of tested experiments, Figure~\ref{fig:consolidated} and Table~\ref{tab:main_times} demonstrate that our new Certificate Aware Attack framework consistently constructs smaller adversarial perturbations than any other technique, with an average percentage reduction in the median radius of $8.5 \%$ relative to the next most performant approach in PGD. However, it must be emphasised that this is not strictly a like-for-like comparison, as each technique is capturing a different proportion of adversarial examples.
The magnitude of the performance increase relative to PGD appears to increase with the complexity of the input space, culminating with a $17.6 \%$ (at $\sigma = 0.5$) and $34.5 \%$ (at $\sigma = 1.0$) reduction in the median certified radius for Imagenet. This performance for Imagenet is revealing, in the context of the observation in Section~\ref{sec:refining} that all adversarial examples identified by our Certification Aware Attack framework must share the same class prediction as the first identified adversarial example for a given sample point. Intuitively such a drawback would appear to be substantially more limiting for the $1000$ class Imagenet, as compared to MNIST or CIFAR-$10$, however it appears that this disadvantage is outweighed by the Certification Aware Attacks' increased efficiency in exploring the potential search space.%
The primary drivers of outperformance by our technique, relative to other comparable attacks, is our ability to iteratively refine the step size as we approach potential adversarial examples. For fixed step size attacks even if its iteration count was set to infinity, the fixed step size will ensure that the candidate solution oscillates about a local optima, rather than converging upon it. These efficiencies translate to an on average $87 \%$ reduction in the computational time across our experiments, relative to PGD.
Across the remainder of techniques, AutoAttack, Carlini-Wagner, and DeepFool all exhibit median perturbation radii that are multiples of what is observed from our technique, although it is notable that for Imagenet at $\sigma = 1.0$ both Carlini-Wagner and DeepFool are able to identify significantly more adversarial examples than our approach, even if the associated perturbation radii was significantly higher. This is likely a product of suboptimal positioning in our $(\delta_1, \delta_2, \epsilon_{\text{min}}, \epsilon_{\text{max}})$ parameter space in the high-dimensional, $1000$-class Imagenet.
We also emphasise that the process espoused by our Certification Aware Attacks yields significant increases in the numerical efficiency of attacking these models, relative to the other attacks. In practice, Table~\ref{tab:main_times} demonstrates that our approach can produce a more than $10$-fold decrease in the computational time required to identify these attacks, relative to all approaches except DeepFool. However, that DeepFool's perturbations are $3$-times larger than our attacks underscores that the performance improvements yielded by our conceptual approach balance numerical efficiency against identifying norm-minimising perturbations.
\paragraph{Performance relative to certified guarantees}
While considering the differential performance of these adversarial attacks is valuable in and of itself, these experiments can also be used to explore how tight the certified guarantees provided by Equation~\ref{eqn:Cohen_Bound} are. Such an analysis must also consider the influence of increasing $\sigma$, as it is well understood that increasing the level of noise to a certifiably robust model decreases the accuracy, while increasing the certification of the samples that it can certify. However, in the context of \emph{attacking} these models, additional levels of noise inherently smooth the gradients, which should decrease the difficulty of attacking these models with gradient based methods. In practice Figure~\ref{fig:consolidated} demonstrates that the percentage difference between our new attack and the Cohen \etal certification radius of Equation~\ref{eqn:Cohen_Bound} is relatively constant across the tested $\sigma$ for all techniques. If it is true that increasing $\sigma$ makes it easier to attack a model, this would suggest that this ease is being offset by the certification bounds tightening with $\sigma$.
To further illuminate the nature of the performance of our attack, Figure~\ref{fig:comp_scatter} considers the sample-wise performance of both PGD and our Certification Aware Attack. Within this data there is a clear self-similar trend, in which the percentage difference to Equation~\ref{eqn:Cohen_Bound} increases as the largest class expectation decreases. This difference could indicate the potential for improving the certification of samples within this region. There also appears to be a correlation between the outperformance of our approach and the semantic complexity of the prediction task, which suggests that tightening these guarantees could be increasingly relevant for complex datasets of academic and industrial interest.
\begin{figure}
\centering
\includegraphics[width=.725\linewidth]{Figures/Attacks/Cifar10/Percent_scatter-cifar10-1.0-samples-1500-validating.pdf}
\caption{Percentage difference between constructed adversarial perturbations and the certified radii of Equation~\ref{eqn:Cohen_Bound} for CIFAR-$10$ at $\sigma=0.5$, with Our technique in red and PGD in blue.}%
\label{fig:comp_scatter}
\end{figure}
\begin{figure*}
\begin{center}
\includegraphics[width=0.90\textwidth]{Figures/NewData/consolidatedlarge.pdf}
\end{center}
\caption{Best achieved Attack Proportion for our new Certification Aware Attack (blue), PGD (red), DeepFool (cyan), Carlini-Wagner (green), and AutoAttack (magenta). The black dotted line represents the theoretical best case performance following Equation~\ref{eqn:Cohen_Bound}.}%
\label{fig:consolidated}
\end{figure*}
\section{Limitations} %
To this point, our work has considered $L_2$-norm measures of perturbation size, as such distances are aligned with the most common guarantees of certified robustness, which also exist within an $L_2$-space. While this inherently biases our approach towards datasets with image-structured data, the core concepts of attacking randomised smoothing, and of augmenting attack methodologies with the knowledge of regions of class invariance should be readily extensible to a broad array of data types and structures.
It must also be noted that an $L_2$-norm centred definition may not be appropriate in all contexts, and does not reflect the potential of rotational or translational modifications \citep{tian2018detecting}, nor functional attacks \citep{laidlaw2019functional}.
Finally, this attack requires access to significant amounts of GPU memory. Attacking a ResNet-$18$ model trained for CIFAR-$10$ required approximately $10$ GB of GPU memory when smoothing was performed over $1500$ samples, with significantly more memory required for attacking Imagenet-size datasets. This memory consumption is driven by our current implementation requiring all samples to be loaded into memory at once, prior to performing the gradient-based iterative step. While this process can be improved through batching, we chose not to follow this to focus upon the performance of the attack vector itself.%
\section{Conclusion}
The addition of calibrated noise through randomised smoothing has a well documented history of improving adversarial robustness. Recently, randomised smoothing has been introduced as a simple yet effective means to certifying the robustness of arbitrary models with high probability. However, within this work we demonstrate that this very process of certification through randomised smoothing can also introduce a new attack surface, that allows models incorporating randomised smoothing to be \emph{more easily attacked}.
Implementing this framework into Certification Aware Attacks allows us to leverage certifications of samples which both predict the benign and malicious classes to significantly decrease the size of the identified adversarial perturbations relative to state-of-the-art test-time attacks. Taking this approach would likely allow an attacker to influence more samples before being detected than any other attack, as it is produces perturbations up to $34 \%$ smaller than the next best technique, while also requiring significantly less computational time to attack. Based upon these observations, it is clear that the benefits and risks of deploying certifiably robust models should be considered in the context of our newly discovered attack vector.
\newpage %
| {'timestamp': '2023-02-10T02:03:43', 'yymm': '2302', 'arxiv_id': '2302.04379', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04379'} | arxiv |
\section{Specialized results for contextual bandits}\label{sec:contextual}
This section specializes our general result to contextual bandit problems, like Example \ref{ex:contextual-bandit}.
In such problems, the decision space $\mathcal{A}$ is a set of rules that map contexts to `arms.'
Naive bounds depend on the entropy rate of the optimal decision rule, $\bar{H}(A^*)$, and, like Corollary \ref{cor:k-armed}, the cardinality of the set of possible decision rules $|\mathcal{A}|$.
Leveraging the structure of the problem, we strengthen this result in two ways: (1) it depends on the conditional entropy rate of the optimal arm process and (2) it depends at most on the number of arms, rather than the number of decision rules.
To facilitate comparisons with past work, we state a finite time regret bound in unchanging environments (where $\theta_1=\theta_2 \ldots$) in Appendix {\bf (ADD THIS)}.
The analysis seems to resolve an open question raised by \citet{neu22}, around the proper application of information-ratio analysis to contextual problems.
\subsection{General result.}
Contextual bandit problems are a special case of our formulation that satisfy the following abstract assumption.
Re-read Example \ref{ex:contextual-bandit} to get intuition.
\begin{assumption}\label{assumption:contextual}
There is a set $\mathcal{X}$ and integer $k$ such that $\mathcal{A}$ is the set of functions mapping $\mathcal{X}$ to $[k]$. The observation at time $t$ is the tuple $O_t =(X_t, R_t) \in \mathcal{X}\times \mathbb{R}$.
Define $i_t \equiv A_t(X_t)\in [k]$ and $i^*_t \equiv A^*(X_t)\in [k]$.
Assume that for each $t$, $X_{t+1} \perp (A_t, R_t) \mid X_t, \mathcal{F}_{t-1}$.
and $R_t \perp A_t \mid (X_t, i_t).$
\end{assumption}
Theorem \ref{thm:main-result} bounds the regret rate of a policy $\pi$ in terms of its limiting information ratio $\Gamma(\pi)$ and the mutual information rate $\bar{I}(A; \mathcal{F})$.
Under assumption \ref{assumption:contextual}, we attain a bound on the information ratio that depends on the number of arms $k$, but is independent of the number of contexts or the size of the decision space, $|\mathcal{A}|$.
We bound the information rate by the conditional entropy rate of the optimal arm process.
\begin{theorem}\label{thm:contextual}
Under Assumption \ref{assumption:contextual},
\[
\Gamma(\pi^{\rm TS})\leq k \quad \& \quad \bar{I}(A^*; \mathcal{F}) \leq \bar{H}\left( i^* \mid X \right).
\]
\end{theorem}
The next result combines the information ratio bound above with the earlier bound of Theorem \ref{thm:effective-horizon-bound}.
The bound depends on the number of arms, the dimension of the parameter space, and the effective time horizon.
No further structural assumptions (e.g. linearity) are needed.
An unfortunate feature of the result is that it applies only to parameter vectors that are quantized at scale $\epsilon$, with a logarithmic dependence on $\epsilon$.
We believe this could be removed with more careful analysis.
\begin{corollary} Under Assumption \ref{assumption:contextual},
if $\theta_t \in \{ -1, -1+\epsilon, \ldots, 1-\epsilon, 1 \}^{p}$ is a discretized $p$-dimensional vector, and the optimal policy process $(A^*_t)_{t\in \mathbb{N}}$ is stationary, then
\[
\Delta(\pi^{\rm TS}) \leq \tilde{O}\left( \sigma \sqrt{ \frac{p \cdot k}{\tau_\textup{eff}} } \right)
\]
where $\tilde{O}(\cdot)$ omits logarithmic factors.
\end{corollary}
\subsection{Conditional entropy rate and VC dimension}\label{subsec:policy_complexity}
The next result provides a bound on the conditional entropy rate that depends on (1) a coarse measure of the effective time horizon, and (2) the Vapnik–Chervonenkis (VC) dimension of the class of decision-rules.
The concept of VC dimension plays a key role in the theory of classification. \citet{beygelzimer2011contextual} were the first to provide regret bounds for contextual bandit problems that depend on the VC dimension of the policy class.
Here, we show that bounds in terms of VC dimension follow through information-ratio analysis.
It is worth emphasizing that such bounds do not apply to the entropy rate of the decision rule, $\bar{H}(A^*)$, and only to the conditional entropy rate of the optimal arm process, $H(i^* \mid X)$.
For this reason, a naive extension of \citet{russo16} to contextual problems would not yield results that depend on VC dimension.
\begin{lemma}
Assume $k=2$ and there exists $\tau$ such that, with probability 1, $\theta_{1} =\ldots =\theta_{\tau}$, $\theta_{\tau +1} =\ldots =\theta_{2\tau}$ and so on. Let $\mathcal{C}\subset \{1,2\}^{\mathcal{X}}$ to be a policy class with VC dimension $d$ such that $A^* \in \mathcal{C}$ almost surely. Then,
\[
\bar{H}(i^* \mid X) \leq \frac{d \ln\left( \frac{\tau}{d}\right)}{\tau}.
\]
\end{lemma}
The next example applies this general result to a contextual bandit problem where rewards follow a sparse high-dimensional linear model.
\cite{bastani2020online} provide substantial technical analysis of similar problems.
Here, the results follows without any new analysis.
\begin{example}\label{ex:sparse_linear_models}
Let the context space $\mathcal{X} \subset \mathbb{R}^p$ consist of high-dimensional vectors and take $\mathcal{C}$ to be the set of all sparse linear classifiers on $\mathcal{X}$; that is, let $\mathcal{C}$ consist of functions of the form $f_{\beta}(x) = 1+ \mathbf{1}\left( x^\top \beta \geq 0 \right)$ for $\beta \in \mathbb{R}^p$ satisfying $\|\beta\|\leq d_0$. Then, \citet{abramovich2018high} show
${\rm VC}(\mathcal{C})\leq 2 d_0 \log_{2}\left( \frac{p e}{d_0}\right)$.
Now, we construct a problem where the optimal policy is an element of $\mathcal{C}$.
Assume there are just two arms ($k=2$) and $\theta = [\theta_t^{(1)}, \theta_t^{(2)}]$ is the concatenation of two different $p$ dimensional vectors. Rewards follow the linear model
\[
R_t = \langle X_t, \theta_t^{(i_t)} \rangle + W_t
\]
where $W_t$ is i.i.d noise. It is not hard to show that $i^*_t = 1 + \mathbf{1}\left( \langle X_t \, ,\, \theta_t^{(1)} - \theta_t^{(2)} \rangle \geq 0\right)$. If parameters are drawn from a sparse distribution, with $\| \theta_t^{(1)} - \theta_t^{(2)} \|_0 \leq d_0$ almost surely, then $A^* \in \mathcal{C}$.
\end{example}
\section{To move later}
\begin{example}[]
If $\theta_t \in \{ -1, -1+\epsilon, \ldots, 1-\epsilon, 1 \}^{p}$ is a discretized $p$ dimensional vector, and the optimal policy process $(A^*_t)_{t\in \mathbb{N}}$ is stationary, then
\begin{align*}
\bar{H}(A^*) &\leq \frac{1 + \log(\tau_\textup{eff}) + H(A_t^* | A_t^* \ne A_{t-1}^* ) }{\tau_\textup{eff}} \\
&\leq \frac{1 + \log(\tau_\textup{eff}) + H(\theta_t ) }{\tau_\textup{eff}}\\
&\leq \frac{1 + \log(\tau_\textup{eff}) + p \ln(2\epsilon) }{\tau_\textup{eff}}.
\end{align*}
Combining this gives
\[
\Delta(\pi^{\rm TS}) \leq \tilde{O}\left( \sigma \sqrt{ \frac{p \cdot d}{\tau_\textup{eff}} } \right),
\]
which depends on the raw dimension of the parameter space, the embedded dimension of the action space, and the effective horizon.
\end{example}
\section{Introduction}
\label{sec:intro}
We study the problem of learning in interactive decision-making.
Across a sequence of time periods, a decision-maker selects actions, observes outcomes, and associates these with rewards. They hope to earn high rewards, but this may require investing in gathering information.
Most of the literature studies stationary environments --- where the likelihood of outcomes under an action is fixed across time.\footnote{An alternative style of result lets the environment change, but tries only to compete with the best fixed action in hindsight.} Efficient algorithms limit costs required to converge on optimal behavior. We study the design and analysis of algorithms in nonstationary environments, where converging on optimal behavior is impossible.
In our model, the latent state of the environment in each time period is encoded in a parameter vector.
These parameters are unobservable, but evolve according to a known stochastic process.
The decision-maker hopes to earn high rewards by adapting their action selection as the environment evolves.
This requires continual learning from interaction and striking a judicious balance between exploration and exploitation.
Uncertainty about the environment's state cannot be fully resolved before the state changes and this necessarily manifests in suboptimal decisions.
Strong performance is impossible under adversarial forms of nonstationarity but is possible in more benign environments.
Why are A/B testing, or recommender systems, widespread and effective even though nonstationarity is a ubiquitous concern? Quantifying the impact different forms of nonstationarity have on decision-quality is, unfortunately, quite subtle.
\paragraph{Our contributions.}
We provide a novel information-theoretic analysis that bounds the inherent degradation of decision-quality in changing environments.
Note that the latent state evolution of the environment induces a latent optimal action process --- where the optimal action at any time step is that one that maximizes expected reward conditioned on the current environment parameter.
We bound limiting per-period regret in terms of the \emph{entropy-rate of the optimal action process}.
The entropy rate of a stochastic process is a fundamental concept in the theory of communications.
We use the entropy rate to measure the extent to which the evolving state of the environment manifests in surprising and erratic evolution of the optimal action process.
Subsection \ref{subsec:example} gives an example of nonstationarity, inspired by A/B testing, in which the entropy rate of the parameter process is large but the entropy rate of the action process is small.
We believe this distinction is essential.
We enrich this result in two ways.
First we provide a matching lower bound. This exhibits a sequence of problems with varying entropy rate under which no algorithm could meaningfully outperform our upper bounds.
Second, we upper bound on the entropy rate by the inverse of the problem's effective time horizon, which roughly captures the average length of time before the identity of the optimal action changes.
In this form, our bounds mirror classic ones that pertain to stationary problems, except that the effective time horizon replaces the problem's raw time horizon.
In addition to the problem's entropy rate, our general bounds depend on the algorithm's information ratio.
First introduced by \citet{russo16}, the information ratio measures the per-period price an algorithm pays to acquire new information.
It has been shown to properly capture the complexity of learning in a range of widely studied problems, and recent works link it to generic limits on when efficient learning is possible \cite{lattimore2022minimax, foster2022on}.
Because the information-ratio framework covers many of the most important sequential learning problems, our framework applies to \emph{nonstationary variants} of many of the most important sequential learning problems.
A secondary contribution of our work is extending information-ratio analysis to cover contextual bandits, resolving an open question highlighted by \citet{neu22}. See Section \ref{subsec:contextual}.
This work emphasizes understanding of the limits of attainable performance.
Thankfully, most results apply to Thompson sampling (TS), one of the most widely used learning algorithms in practice.
In some problems, TS is far from optimal, and better bounds are attained with Information-Directed Sampling \cite{russo18}.
\subsection{An illustrative Bayesian model of nonstationarity}
\label{subsec:example}
Consider a multi-armed bandit environment where two types of nonstationarity coexist -- a common variation that affects the performance of all arms, and idiosyncratic variations that affect the performance of individual arms separately.
More explicitly, let us assume that the mean reward of arm $a$ at time $t$ is given by
$$ \mu_{t,a} = \theta_t^{\rm cm} + \theta_{t,a}^{\rm id}, $$
where $( \theta_t^{\rm cm} )_{t \in \mathbb{N}}$ and $( \theta_{t,a}^{\rm id} )_{t \in \mathbb{N}}$'s are latent stochastic processes describing common and idiosyncratic disturbances.
While deferring the detailed description to \cref{app:numerical}, we introduce two hyperparameters $\tau^{\rm cm}$ and $\tau^{\rm id}$ in our generative model to control the time scale of these two types of variations.\footnote{
We assume that $( \theta_t^{\rm cm} )_{t \in \mathbb{N}}$ is a zero-mean Gaussian process satisfying $\text{Cov}[ \theta_s^{\rm cm}, \theta_t^{\rm cm} ] = \exp\left( -\frac{1}{2} \left( \frac{t-s}{\tau^{\rm cm}} \right)^2 \right)$ so that $\tau^{\rm cm}$ determines the volatility of the process.
Similarly, the volatility of $( \theta_{t,a}^{\rm id} )_{t \in \mathbb{N}}$ is determined by $\tau^{\rm id}$.}
\begin{figure}[ht]
\begin{center}
\centerline{\includegraphics[width=\columnwidth]{figures/cartoon}}
\caption{A two-arm bandit environment with two types of nonstationarity -- a common variation $( \theta_t^{\rm cm} )_{t \in \mathbb{N}}$ generated with a time-scaling factor $\tau^{\rm cm}=10$, and idiosyncratic variations $( \theta_{t,a}^{\rm id} )_{t \in \mathbb{N}, a \in \mathcal{A}}$ generated with a time-scaling factor $\tau^{\rm id}=50$.
While absolute performance of two arms are extremely volatile (left), their idiosyncratic performances are relatively stable (right).}
\label{fig:example-illustration}
\end{center}
\vskip -0.2in
\end{figure}
Inspired by real-world A/B tests \cite{wu2022non}, we imagine a two-armed bandit instance involving a common variation that is much more erratic than idiosyncratic variations.
Common variations reflect exogenous shocks to user behavior which impacts the reward under all treatment arms.
\cref{fig:example-illustration} visualizes such an example, a sample path generated with the choice of $\tau^{\rm cm}=10$ and $\tau^{\rm id}=50$.
Observe that the optimal action $A_t^*$ has changed only five times throughout 1,000 periods.
Although that the environment itself is highly nonstationary and unpredictable due to the common variation term, the optimal action sequence $(A_t^*)_{t \in \mathbb{N}}$ is relatively stable and predictable since it depends only on the idiosyncratic variations.
Now we ask --- \emph{How difficult is this learning task? Which type of nonstationarity determines the difficulty?}
A quick numerical investigation shows that the problem's difficulty is mainly determined by the frequency of optimal action switches, rather than volatility of common variation.
\begin{figure}[ht]
\begin{center}
\centerline{\includegraphics[width=\columnwidth]{figures/gauss_gp_compare}}
\caption{Performance of algorithms in two-armed bandit environments, with difference choices of time-scaling factors $\tau^{\rm cm}$ (common variation) and $\tau^{\rm id}$ (idiosyncratic variations).
Each data point reports per-period regret averaged over 1,000 time periods and 1,000 runs of simulation.}
\label{fig:example-performance}
\end{center}
\vskip -0.2in
\end{figure}
See \cref{fig:example-performance}, where we report the effect of $\tau^{\rm cm}$ and $\tau^{\rm id}$ on the performance of several bandit algorithms (namely, Thompson sampling with exact posterior sampling,\footnote{
In order to perform exact posterior sampling, it exploits the specified nonstationary structure as well as the values of $\tau^{\rm cm}$ and $\tau^{\rm id}$.
} and Sliding-Window TS that only uses recent $L \in \{10,50,100\}$ observations; see \cref{app:numerical} for the details).
Remarkably, their performances appear to be sensitive only to $\tau^{\rm id}$ but not to $\tau^{\rm cm}$, highlighting that nonstationarity driven by common variation is benign to the learner.
We remark that our information-theoretic analyses predict this result.
\cref{thm:main-result} shows that the complexity of a nonstationary environment can be sufficiently characterized by the entropy rate of the optimal action sequence, which should depend only on $\tau^{\rm id}$ but not on $\tau^{\rm cm}$ in this example.
\cref{thm:effective-horizon-bound} further expresses the entropy rate in terms of effective horizon, which corresponds to $\tau^{\rm id}$ in this example.
\subsection{Comments on the use of prior knowledge}
A substantive discussion of Bayesian, frequentist, and adversarial perspectives on decision-making uncertainty is beyond the scope of this short paper.
We make two quick observations.
First, where does a prior like the one in \cref{fig:example-illustration} come from?
One answer is that company may run many thousands of A/B tests, and an informed prior may let them transfer experience across tests \cite{azevedo2019empirical}.
In particular, experience with past tests may let them calibrate $\tau^{\rm id}$, or form hierarchical prior where $\tau^{\rm id}$ is also random.
Second, Thompson sampling with a stationary prior is perhaps the most widely used bandit algorithm.
One might view the model in Section \ref{subsec:example} as a more conservative way of applying TS that guards against a certain magnitude of nonstationarity.
\subsection{Literature review}
Most existing theoretical studies on nonstationary bandit experiments adopt adversarial or frequentist viewpoints in the modeling of nonstationarity, typically falling into two categories -- ``abruptly changing environments'' and ``slowly changing environments''.
\emph{Abruptly changing environments} (often referred to as switching bandits or piecewise stationary bandits) consider a situation where underlying reward distributions change at unknown times (often referred to as changepoints or breakpoints).
Denoting the total number of changes over $T$ periods by $S$, it was shown that the cumulative regret $\tilde{O}(\sqrt{ST})$ is achievable: e.g., Exp3.S \citep{auer02a, auer02b}, Discounted-UCB \citep{kocsis06}, Sliding-Window UCB \citep{garivier08}, and more complicated algorithms that actively detect the changepoints \citep{auer19, chen19}.
These results are consistent with our result: applied to this setup (assuming that the changes are occurring stochastically in a Bayesian sense), our analysis predicts $\tilde{O}(\sqrt{\mathbb{E}[S]T})$ when we represent the effective horizon as $T/\mathbb{E}[S]$.
Another stream of work considers \emph{slowly changing environments} (often referred to as drifting bandits).
Denoting the total variation in the underlying reward distribution by $V$ (often referred to as variation budget, e.g., $V = \sum_{t=2}^T \| \theta_t - \theta_{t-1} \|_{\infty}$), it was shown that the cumulative regret $\tilde{O}(V^{1/3} T^{2/3})$ is achievable \citep{besbes14, besbes15, cheung19}.
Building a tight connection between these results and ours is an important direction for future work.
We comment on this in the conclusion.
We adopt \emph{Bayesian viewpoints} to describe nonstationary environments: changes in the underlying reward distributions (more generally, changes in outcome distributions) are driven by a stochastic process.
Such a viewpoint dates back to the earliest work of \citet{whittle88} which introduces the term `restless bandits' and has motivated subsequent work \cite{slivkins08, chakrabarti08, jung19}.
On the other hand, since Thompson sampling (TS) has gained its popularity as a Bayesian bandit algorithm, its variants have been proposed for nonstationary settings accordingly: e.g., Dynamic TS \citep{gupta11}, Discounted TS \citep{raj17}, Sliding-Window TS \citep{trovo20}, TS with Bayesian changepoint detection \citep{mellor13, ghatak20}, and Predictive Sampling \citep{liu22}.
Although the Bayesian framework appears very flexible to model various types of nonstationarities (see examples discussed in \citet{liu22}), the performance analysis is hardly found and is often too specific to the assumed model.
Our analysis adopts an \emph{information-theoretic approach} introduced by \citet{russo16}, which has been motivating design and analysis of TS-like algorithms for complex environments \citep{russo18, liu18, dong19, lattimore21, russo22, neu22, liu22}.
Our work can be seen as its application to nonstationary bandit problems.
Notably, \citet{liu22} also adopts the same technique for nonstationary bandit problems, but for the purpose of analyzing their own algorithm with a customized definition of information ratio, resulting in tractable regret bounds only in some stylized setups.
\section{Problem Setup}
\label{sec:problem}
A decision-maker interacts with a changing environment across rounds $t \in \mathbb{N}:= \{1,2,3,\ldots\}$.
In period $t$, the decision-maker selects some action $A_t$ from a finite set $\mathcal{A}$, observes an outcome $O_t$, and associates this with reward $R_t = R(O_t, A_t)$ that depends on the outcome and action through a known utility function.
There is a function $g$, an i.i.d sequence of disturbances $W=(W_t)_{t\in \mathbb{N}}$, and a sequence of latent environment states $\theta=(\theta_t)_{t\in \mathbb{N}}$ taking values in $\Theta$, such that outcomes are determined as
\begin{equation}\label{eq:outcome-generation}
O_t=g(A_t, \theta_t, W_t ).
\end{equation}
Write potential outcomes as $O_{t,a}=g(a, \theta_t, W_t)$ and potential rewards as $R_{t,a}= R(O_{t,a}, a)$. Equation \eqref{eq:outcome-generation} is equivalent to specifying a known probability distribution over outcomes for each choice of action and environment state.
The decision-maker wants to earn high rewards even as the environment evolves, but cannot directly observe the environment state or influence its evolution.
Specifically, the decision-maker's actions are determined by some choice of policy $\pi=(\pi_1, \pi_2,\ldots)$.
At time $t$, an action $A_t= \pi_t(\mathcal{F}_{t-1}, \tilde{W}_t)$ is a function of the observation history $\mathcal{F}_{t-1}=(A_1, O_1, \ldots, A_{t-1}, O_{t-1})$ and an internal random seed $\tilde{W}_t$ that allows for randomness in action selection.
Reflecting that the seed is exogenously determined, assume $\tilde{W}=(\tilde{W}_t)_{t\in \mathbb{N}}$ is jointly independent of the outcome disturbance process $W$ and state process
$\theta=(\theta_t)_{t\in \mathbb{N}}$.
That actions do not influence the environment's evolution can be written formally through the conditional independence relation $(\theta_{s})_{s\geq t+1} \perp \mathcal{F}_t \mid (\theta_{\ell})_{\ell \leq t}$.
The decision-maker wants to select a policy $\pi$ that accumulates high rewards as this interaction continues.
They know all probability distributions and functions listed above, but are uncertain about how environment states will evolve across time.
To perform `well', they need to continually gather information about the latent environment states and carefully balance exploration and exploitation.
Rather than measure the reward a policy generates, it is helpful to measure its regret.
We define the \emph{regret rate} of a policy $\pi$ to be
\[
\Delta(\pi) := \limsup_{T \rightarrow \infty} \,\, \mathbb{E}_{\pi}\left[ \frac{1}{T} \sum_{t=1}^T \left(R_{t,A_t^*} - R_{t,A_t} \right)\right],
\]
where the latent optimal action $A_t^*$ is a function of the latent state $\theta_t$ satisfying $A_t^* \in \argmax_{a \in \mathcal{A}} \mathbb{E}[R_{t,a} \mid \theta_t]$.
A policy's regret rate is the limit of the Ces\`{a}ro average of its regret.
It measures the per-period degradation in performance due to uncertainty about the environment state.
\begin{remark} \label{rem:conjecture}
The use of a limit supremum and Ces\`{a}ro averages is likely unnecessary under some technical restrictions.
For instance, under Thompson sampling applied to Examples~\ref{ex:k-armed-bandit}--\ref{ex:contextual-bandit}, if the latent state process $(\theta_t)_{t \in \mathbb{N}}$ is ergodic, we conjecture that $\Delta(\pi)= \lim_{t\to \infty} \mathbb{E}_{\pi}\left[ \left(R_{t,A_t^*} - R_{t,A_t} \right)\right]$.
\end{remark}
Our analysis proceeds under the following assumption, which is standard in the literature.
\begin{assumption} \label{ass:subgaussian}
There exists $\sigma$ such that, conditioned on $\mathcal{F}_{t-1}$, $R_{t,a}$ is sub-Gaussian with variance proxy $\sigma^2$.
\end{assumption}
\subsection{`Stationary processes' in `nonstationary bandits'}
The way the term `nonstationarity' is used in the bandit learning literature could cause confusion as it conflicts with the meaning of `stationarity' in the theory of stochastic process, which we use elsewhere in this paper.
\begin{definition}\label{def:stationary}
A stochastic process $X=(X_t)_{t\in \mathbb{N}}$ is (strictly) stationary if for each integer $t$, the random vector $(X_{1+m}, \ldots, X_{t+m})$ has the same distribution for each choice of $m$.
\end{definition}
`Nonstationarity', as used in the bandit learning literature, means that \emph{realizations} of the latent state $\theta_t$ may differ at different time steps.
The decision-maker can gather information about the current state of the environment, but it may later change.
Nonstationarity of the stochastic process $(\theta_{t})_{t\in \mathbb{N}}$, in the language of probability theory, arises when apriori there are predictable differences between environment states at different timesteps -- e.g., if time period $t$ is nighttime then rewards tend to be lower than daytime.
It is often clearer to model predictable differences like that through contexts, as in \cref{ex:contextual-bandit}.
\subsection{Examples}
Many interactive decision-making problems can be naturally written as special cases of our general protocol, where actions generate outcomes that are associated with rewards.
Our first example describes a bandit problem with independent arms, where outcomes generate information only about the selected action.
\begin{example}[K-armed bandit]\label{ex:k-armed-bandit}
Consider a website who can display one among $k$ ads at a time and gains one dollar per click.
For each ad $a \in [k] := \{1,\ldots,k\}$, the potential outcome/reward $O_{t,a} = R_{t,a} \sim \text{Bernoulli}(\theta_{t,a})$ is a random variable representing whether the ad $a$ is clicked by the $t^\text{th}$ visitor if displayed, where $\theta_{t,a} \in [0,1]$ represents its click-through-rate.
The platform only observes the reward of the displayed ad, so $O_t = R_{t,A_t}$.
\end{example}
Full information online optimization problems fall at the other extreme.
There the potential observation $O_{t,a}$ does not depend on the chosen action $a$, so purposeful information gathering is unnecessary.
The next example was introduced by \citet{cover91} and motivates such scenarios.
\begin{example}[Log-optimal online portfolios]\label{ex:full-information}
Consider a small trader who has no market impact.
In period $t$ they have wealth $W_t$ which they divide among $k$ possible investments.
The action $A_{t}$ is chosen from a feasible set of probability vectors, with $A_{t,i}$ denoting the proportion of wealth invested in stock $i$.
The observation is $O_t\in \mathbb{R}^k_+$ where $O_{t,i}$ is the end-of-day value of $\$1$ invested in stock $i$ at the start of the day and the distribution of $O_t$ is parameterized by $\theta_t$.
Because the observation consists of publicly available data, and the trader has no market impact, $O_{t}$ does not depend on the investor's decision. Define the reward function $R_t=\log\left( O_t^\top A_t \right)$. Since wealth evolves according to the equation $W_{t+1} = \left(O_t^\top A_t\right) W_t$,
$$\sum_{t=1}^{T-1} R_t = \log(W_T/ W_0) .$$
\end{example}
Many problems lie in between these extremes.
We give two examples.
The first is a matching problem. Many pairs of individuals are matched together and, in addition to the cumulative reward, the decision-maker observes feedback on the quality of outcome from each individual match.
This kind of observation structure is sometimes called ``semi-bandit'' feedback \cite{audibert14}.
\begin{example}[Matching] \label{ex:matching}
Consider an online dating platform with two disjoint sets of individuals $\mathcal{M}$ and $\mathcal{W}$.
On each day $t$, the platform suggests a matching of size $k$, $A_t \subset \{ (m,w): m \in \mathcal{M}, w \in \mathcal{W} \}$ with $|A_t| \leq k$.
For each pair $(m,w)$, their match quality is given by $\theta_{t,(m,w)}$.
The platform observes the quality of individual matches, $O_t = \big( \theta_{t,(m,w)} : (m,w) \in A_t \big)$, and earns their average, $R_t = \frac{1}{k}\sum_{(m,w) \in A_t} \theta_{t,(m,w)}$.
\end{example}
Our final example is a contextual bandit problem.
Here an action is itself more likely a policy --- it is a rule for assigning treatments on the basis of an observed context.
Observations are richer than in the K-armed bandit.
The decision-maker sees not only the reward a policy generated but also the context in which it was applied.
\begin{example}[Contextual bandit] \label{ex:contextual-bandit}
Suppose that the website described in \cref{ex:k-armed-bandit} can now access additional information about each visitor, denoted by $X_t \in \mathcal{X}$.
The website observes the contextual information $X_t$, chooses an ad to display,
and then observes whether the user clicks.
To represent this task using our general protocol, we let the decision space $\mathcal{A}$ be the set of mappings from the context space $\mathcal{X}$ to the set of ads $\{1,\ldots, k\}$, the decision $A_t \in \mathcal{A}$ be a personalized advertising rule, and the observation $O_t=(X_t, R_t)$ contains the observed visitor information and the reward from applying the ad $A_t(X_t)$.
Rewards are drawn according to $R_t \mid X_t, A_t, \theta_t \sim \text{Bernoulli}( \phi_{\theta_t}(X_t, A_t(X_t) ) )$, where $\phi_\theta:\mathcal{X}\times [k] \to [0,1]$ is a parametric click-through-rate model.
Assume $X_{t+1} \perp (A_t, \theta) \mid X_t, \mathcal{F}_{t-1}$.
This assumption means that advertising decisions cannot influence the future contexts and that parameters of the click-through rate model $\theta=(\theta_t)_{t\in \mathbb{N}}$ cannot be inferred passively by observing contexts.
\end{example}
\section{Information Theoretic Preliminaries}
The entropy of a discrete random variable $X$, defined by $H(X)= -\sum_{x} \mathbb{P}(X=x)\log(\mathbb{P}(X=x))$, measures the uncertainty in its realization.
The entropy rate of a stochastic process $(X_1, X_2, \ldots)$ is the rate at which entropy of the partial realization $(X_1, \ldots, X_t)$ accumulates as $t$ grows.
\begin{definition}
The entropy rate of a stochastic process $X=(X_t)_{t\in \mathbb{N}}$, taking values in a discrete set $\mathbb{X}$, is
\begin{align*}
\bar{H}(X)&=\limsup_{T \rightarrow \infty} \,\, \frac{H\left([X_1, \ldots X_T] \right)}{T} \\
&= \limsup_{T \rightarrow \infty} \,\, \frac{1}{T} \sum_{t=1}^{T} H(X_t | X_{t-1}, \ldots, X_1 ).
\end{align*}
If $X$ is a stationary stochastic process, then
\begin{equation}\label{eq:entropy-rate-stationary}
\bar{H}(X) = \lim_{t\to \infty} H(X_t | X_{t-1}, \ldots, X_1 ).
\end{equation}
\end{definition}
The form \eqref{eq:entropy-rate-stationary} is especially elegant.
The entropy rate of a stationary stochastic process is the residual uncertainty in the draw of $X_t$ which cannot be removed by knowing the draw of $X_{t-1}, \ldots, X_1$.
Processes that evolve quickly and erratically have high entropy rate.
Those that tend to change infrequently (i.e., $X_t=X_{t-1}$ for most $t$) or change predictably will have low entropy rate.
\iffalse
The mutual information rate and conditional entropy rate are defined similarly. Now consider the stochastic process $(X,Z)=(X_t, Z_t)_{t\in \mathbb{N}}$, where $X_t$ takes values in a finite set. Define the conditional entropy rate as
\[
\bar{H}(X|Z) = \limsup_{T \rightarrow \infty} \frac{H( X_{1:T}\mid Z_{1:T})}{T}
\]
and information rate as
\[
\bar{I}(X;Z) = \limsup_{T \rightarrow \infty} \frac{I( X_{1:T} ; Z_{1:T})}{T}.
\]
It is immediate that $\bar{I}(X;Z) \leq \bar{H}(X)$.
When all limit suprema can be replaced by proper limits, $\bar{I}(X;Z) = \bar{H}(X) - \bar{H}(X|Z)$.
\fi
\section{Information-Theoretic Analysis of Dynamic Regret}
\label{sec:dregret}
We apply the information theoretic analysis of \citet{russo16} and establish upper bounds on the per-period regret, expressed in terms of (1) the algorithm's information ratio, and (2) the entropy rate of the optimal action process.
\subsection{Preview: special cases of our result}
We begin by giving a special case of our result.
It bounds the regret rate of Thompson sampling in terms of the reward variance proxy $\sigma^2$, the number of actions $|\mathcal{A}|$, and the entropy rate of the optimal action process $\bar{H}(A^*)$. Thompson sampling is denoted by $\pi^{\rm TS}$ and is defined by the probability matching property:
\begin{equation}\label{eq:ts}
\mathbb{P}(A_t=a \mid \mathcal{F}_{t-1})=\mathbb{P}(A_t^*=a \mid \mathcal{F}_{t-1}),
\end{equation}
which holds for all $t\in \mathbb{N}$, $a\in \mathcal{A}$. Actions are chosen by sampling from the posterior distribution of the optimal action.
\begin{corollary}\label{cor:k-armed}
Under any problem in the scope of our problem formulation,
\[
\Delta(\pi^{\rm TS}) \leq \sigma \sqrt{2 \cdot |\mathcal{A}| \cdot \bar{H}(A^*) }.
\]
\end{corollary}
According to $\eqref{eq:entropy-rate-stationary}$, the entropy rate is small when the conditional entropy $H(A_t^* \mid A^*_1, \ldots, A^*_{t-1})$ is small.
That is, the entropy rate is small if most uncertainty in the optimal action $A_t^*$ is removed through knowledge of the past optimal actions.
Of course, Thompson sampling does not observe the environment states or the corresponding optimal actions, so its dependence on this quantity is somewhat remarkable.
The dependence of regret on the number of actions, $|\mathcal{A}|$, is unavoidable in a problem like the $K$-armed bandit of \cref{ex:k-armed-bandit}.
But in other cases, it is undesirable. Our general results depend on the problem's information structure in a more refined manner.
To preview this, we give another corollary of our main result, which holds for problems with full-information feedback (see \cref{ex:full-information} for motivation).
In this case, the dependence on the number of actions completely disappears and the bound depends on the variance proxy and the entropy rate.
The bound applies to TS and the policy $\pi^{\rm Greedy}$, which chooses $A_t \in \argmax_{a \in \mathcal{A}} \mathbb{E}[R_{t,a} \mid \mathcal{F}_{t-1}]$ in each period $t$.
\begin{corollary}
For full information problems, where $O_{t,a}=O_{t,a'}$ for each $a,a'\in\mathcal{A}$,
\[
\Delta(\pi^{\rm Greedy}) \leq \Delta(\pi^{\rm TS}) \leq \sigma \sqrt{2 \cdot \bar{H}(A^*) }.
\]
\end{corollary}
\subsection{The entropy rate as an effective time horizon}
The entropy rate is an intrinsic measure of the rate of unpredictable variation in the optimal action process.
To aid in interpretation of this quantity, the next theorem upper bounds the entropy rate by the inverse of a notion of the problem's effective time horizon, denoted by $\tau_\textup{eff}$.
The effective time horizon is long when the optimal action changes infrequently, so that, intuitively, a decision-maker could continue to exploit the optimal action for a long time if it were identified.
\begin{theorem}\label{thm:effective-horizon-bound} When the process $(A_t^*)_{t\in \mathbb{N}}$ is stationary
$$ \bar{H}( A^* ) \leq \frac{1 + \log(\tau_\textup{eff}) + H(A_t^* | A_t^* \ne A_{t-1}^* ) }{\tau_\textup{eff}}, $$
where
\begin{equation}\label{eq:effective-horizon}
\tau_\textup{eff} := \frac{1}{\mathbb{P}( A_t^* \ne A_{t-1}^* ) }.
\end{equation}
\end{theorem}
Combining this result with \cref{cor:k-armed} gives the bound
\[
\Delta(\pi^{\rm TS}) \leq \tilde{O}\left( \sigma\sqrt{\frac{|\mathcal{A}|}{\tau_{\rm eff}}}\right),
\]
which closely mirrors familiar $O(\sqrt{k/T})$ regret bounds on the average per-period regret in bandit problems with $k$ arms, $T$ periods, and i.i.d rewards \cite{bubeck12}.
Through the entropy rate, our results yield a similar guarantee in terms of an intrinsic ``effective horizon.''
Note that it is not clear how one would directly establish such a guarantee for
TS; Even though the optimal action switches only once every $\tau_{\rm eff}$ periods, other features of the environment may change more erratically.
Below we give an example where the upper bound in \cref{thm:effective-horizon-bound} is nearly exact.
\begin{example}[Piecewise stationary environment]
Suppose $(A_t^*)_{t\in \mathbb{N}}$ follows a switching process.
With probability $1-\delta$ there is no change in the optimal action, whereas with probability $\delta$ there is a change-event and $A_t$ is drawn uniformly from among the other $k-1 \equiv|\mathcal{A}|-1$ arms.
Precisely, $(A_t^*)_{t\in \mathbb{N}}$ follows a Markov process with transition dynamics:
\[
\mathbb{P}(A^*_{t+1}=a \mid A^*_t=a')= \begin{cases}
1-\delta & \text{if } a=a' \\
\delta/(k-1) & \text{if } a\neq a'
\end{cases}
\]
for $a, a' \in \mathcal{A}$. Then
\begin{align*}
\bar{H}(A^*) &= (1-\delta)\log\left(\frac{1}{1-\delta}\right) + \delta\log\left(\frac{k-1}{\delta}\right)\\
&= (1-\delta)\log\left(1 + \frac{\delta}{1-\delta}\right) + \delta\log\left(\frac{k-1}{\delta}\right)\\
&\approx \delta+\delta\log((k-1)/\delta),
\end{align*}
where we used the approximation $\log(1+x) \approx x$.
Plugging in $\tau_{\rm eff}=1/\delta$ and $H(A_t^* \mid A_t^*\neq A^*_{t-1})=\log(k-1)$ yields,
\[
\bar{H}(A^*) \approx \frac{1+\log(\tau_{\rm eff}) + H(A_t^* \mid A_t^*\neq A^*_{t-1})}{\tau_{\rm eff}}.
\]
\end{example}
Although it can be illuminating to consider a problem's effective horizon, the entropy rate is a deeper quantity that better captures a problem's intrinsic difficulty.
Below we give an extreme example where the entropy rate is zero even though the optimal action changes frequently.
Although the example is quite artificial, it captures that some forms of benign nonstationarity involve quickly changing, but largely predictable evolution in the optimal action process.
\begin{example}[Cyclic optimal action sequence]
Consider a nonstationary Bernoulli bandit environment where the success probability of arm $a \in \{1,\ldots,k\}$ at time $t$ is given by
$$ \theta_{t,a} = \mathbb{I}\{ t \equiv a \text{ mod } k \}. $$
The optimal action process $(A_t^*)_{t \in \mathbb{N}}$ is a deterministic sequence\footnote{Strictly speaking, the process $A^*$ is not stationary according to \cref{def:stationary}.
To resolve this issue, one can introduce a random seed: $\theta_{t,a} = \mathbb{I}\{ t +N \equiv a \text{ mod } k \}$ where $N \sim \text{Uniform}(\{1,\ldots,k\})$.} taking values in $[k]$ cyclically.
Although the optimal action changes every single time (i.e., $\tau_{\rm eff} = 1$), the sequence is completely predictable and hence $\bar{H}(A^*) = 0$.
\end{example}
\subsection{Main result}
The corollaries presented earlier are special cases of a general result that we present now.
Define the limiting information ratio of an algorithm $\pi$ by,
\[
\Gamma(\pi) = \limsup_{T \rightarrow \infty} \frac{1}{T} \sum_{t=1}^{T} \underbrace{\frac{ \left( \mathbb{E}\left[ R_{t,A^*} - R_{t,A_t} \right] \right)^2 }{ I\left( A_t^*; (A_t, O_{t,A_t}) \mid \mathcal{F}_{t-1} \right) }}_{:=\Gamma_t(\pi)}.
\]
The per-period information ratio $\Gamma_t(\pi)$ was defined by \citet{russo16} and presented in this form by \citet{russo22}.
It is the ratio between the square of expected regret and the conditional mutual information between the optimal action and the algorithm's observation.
It measures the cost, in terms of the square of expected regret, that the algorithm pays to acquire each bit of information about the optimum.
Under sufficient ergodicity assumptions, we expect $\Gamma(\pi)=\lim_{t\to \infty} \Gamma_t(\pi)$.
We avoid imposing conditions under which such a limit exists by taking the limit supremum of Ces\`{a}ro averages.
The next theorem shows that any algorithm's regret is bounded by the square root of the product of its information ratio and the entropy of rate of its optimal action sequence.
The result has profound consequences, but follows easily by applying elegant properties of information measures.
\begin{theorem} \label{thm:main-result}
Under any algorithm $\pi$,
\[
\Delta(\pi) \leq \sqrt{ \Gamma(\pi) \cdot \bar{H}(A^*) }.
\]
\end{theorem}
\begin{proof} Use the shorthand notation $\Delta_t := \mathbb{E}[ R_{t,A^*} - R_{t,A_t} ]$ for regret, $G_t := I( A_t^*; (A_t, O_{t,A_t}) | \mathcal{F}_{t-1} )$ for information gain, and $\Gamma_t = \Delta_t^2/G_t$ for the information ratio at period $t$.
Then,
\begin{align*}
\Delta(\pi) &= \limsup_{T\to \infty} \, T^{-1}\sum_{t=1}^T \Delta_t \\
&= \limsup_{T\to \infty} T^{-1}\sum_{t=1}^T \sqrt{ \Gamma_t } \sqrt{ G_t }
\\& \, \leq \limsup_{T\to \infty} \sqrt{ T^{-1}\sum_{t=1}^T \Gamma_t } \cdot \sqrt{ T^{-1} \sum_{t=1}^T G_t }\\
\, &\leq \sqrt{\Gamma(\pi) \cdot \limsup_{T \rightarrow \infty}\, T^{-1}\sum_{t=1}^{T} G_t}.
\end{align*}
The first inequality uses Cauchy-Schwarz.
The second inequality uses that $\limsup x_t y_t \leq (\limsup x_t) \cdot (\limsup y_t)$ for any sequences $(x_t), (y_t)$.
We conclude by bounding the information gain. This uses the chain rule, the data processing inequality, and the fact that entropy bounds mutual information:
\begin{align*}
\sum_{t=1}^T G_t &= \sum_{t=1}^T I( A_t^*; (A_t, O_{t,A_t}) | \mathcal{F}_{t-1} )
\\&\leq \sum_{t=1}^T I( [A_1^*, \ldots, A_T^*] ; (A_t, O_{t,A_t}) | \mathcal{F}_{t-1} )
\\&= I( [A_1^*, \ldots, A_T^*]; \mathcal{F}_T ) \\
& \leq H( [A_1^*, \ldots, A_T^*] ).
\end{align*}
We conclude that $\limsup_{T \to \infty}\, T^{-1}\sum_{t=1}^{T} G_t \leq \bar{H}( A^* )$, completing the proof.
\end{proof}
\begin{remark}%
A careful reading of the proof reveals that it is possible to replace the entropy rate with the mutual information rate $\limsup_{T \rightarrow \infty} T^{-1} I( A_{1:T}^*; \mathcal{F}_T )$.
\end{remark}
\begin{remark}\label{rem:lambda-info-ratio}
Following \citet{lattimore21}, one can adopt a slightly different definition of information ratio,
$$ \Gamma_\lambda(\pi) := \sup_{t \in \mathbb{N}} \frac{ \left( \mathbb{E}\left[ R_{t,A^*} - R_{t,A_t} \right] \right)^\lambda }{ I\left( A_t^*; (A_t, O_{t,A_t}) \mid \mathcal{F}_{t-1} \right) }, $$
which immediately yields an inequality, $\Delta(\pi) \leq \left( \Gamma_\lambda(\pi) \bar{H}(A^*) \right)^{1/\lambda}$ for any $\lambda \geq 1$.
\end{remark}
\subsection{Some known bounds on the information ratio}
We list some known results about the information ratio. These were originally established for stationary bandit problems but immediately extend to nonstationary settings considered in this paper. Most results apply to Thompson sampling, and essentially all bounds apply to Information-directed sampling, which is designed to minimize the information ratio \cite{russo18}. The first four results were shown by \citet{russo16} under \cref{ass:subgaussian}.
\begin{description}
\item[Classical bandits.] $\Gamma(\pi^{\rm TS}) \leq 2\sigma^2|\mathcal{A}| $, for bandit tasks with finite action set (e.g., \cref{ex:k-armed-bandit}).
\item[Full information.] $\Gamma(\pi^{\rm TS}) \leq 2\sigma^2$, for problems with full-information feedback (e.g., \cref{ex:full-information}).
\item[Linear bandits.] $\Gamma(\pi^{\rm TS}) \leq 2\sigma^2 d$, for linear bandits of dimension $d$ (i.e., $\mathcal{A} \subseteq \mathbb{R}^d$, $\Theta \subseteq \mathbb{R}^d$, and $\mathbb{R}[R_{t,a} | \theta_t] = a^\top \theta_t$).
\item[Combinatorial bandits.] $\Gamma(\pi^{\rm TS}) \leq 2\sigma^2 \frac{d}{k^2}$, for combinatorial optimization tasks of selecting $k$ items out of $d$ items with semi-bandit feedback (e.g., \cref{ex:matching}).
\item[Contextual bandits.] See the below for a new result.
\item[Logistic bandits.] \citet{dong19} consider problems where mean-rewards follow a generalized linear model with logistic link function, and bound the information ratio by the dimension of the parameter vector and a new notion they call the `fragility dimension.'
\item[Graph based feedback.] With graph based feedback, the decision-maker observes not only the reward of selected arm but also the reward of its neighbors in feedback graph. One can bound the information ratio by the feedback graph's clique cover number \cite{liu18} or its independence number \cite{hao2022contextual}.
\item[Sparse linear models.] \citet{hao21} consider sparse linear bandits and show conditions under which the information ratio of Information-Directed Sampling in \cref{rem:lambda-info-ratio} is bounded by the number of nonzero elements in the parameter vector.
\item[Convex cost functions.] \citet{bubeck2016multi} and \citet{lattimore2020improved} study bandit learning problems where the reward function is known to be concave and bound the information ratio by a polynomial function of the dimension of the action space.
\end{description}
\subsection{A new bound on the information ratio of contextual bandits}\label{subsec:contextual}
Contextual bandit problems are a special case of our formulation that satisfy the following abstract assumption.
Re-read \cref{ex:contextual-bandit} to get intuition.
\begin{assumption}\label{assumption:contextual}
There is a set $\mathcal{X}$ and integer $k$ such that $\mathcal{A}$ is the set of functions mapping $\mathcal{X}$ to $[k]$. The observation at time $t$ is the tuple $O_t =(X_t, R_t) \in \mathcal{X}\times \mathbb{R}$.
Define $i_t := A_t(X_t)\in [k]$.
Assume that for each $t$, $X_{t+1} \perp (A_t, R_t) \mid X_t, \mathcal{F}_{t-1}$.
and $R_t \perp A_t \mid (X_t, i_t, \theta_t).$
\end{assumption}
Under this assumption, we provide an information ratio bound that depends on the number of arms $k$.
It is a massive improvement over \cref{cor:k-armed}, which depends on the number of \emph{decision-rules}.
\begin{lemma}\label{lem:contextual}
Under Assumption \ref{assumption:contextual}, $\Gamma(\pi^{\rm TS}) \leq 2\cdot \sigma^{2} \cdot k$.
\end{lemma}
Theorem \ref{thm:main-result} therefore bounds regret in terms of the entropy rate of the optimal decision rule process $(A^*_t)_{t\in \mathbb{N}}$, the number of arms $k$, and the reward variance proxy $\sigma^2$.
\citet{neu22} recently highlighted that information-ratio analysis seems not to deal adequately with context, and proposed a substantial modification which considers information gain about model parameters rather than optimal decision-rules.
\cref{lem:contextual} appears to resolve this open question without changing the information ratio itself.
Our bounds scale with the entropy of the optimal decision-rule, instead of the entropy of the true model parameter, as in \citet{neu22}.
By the data processing inequality, the former is always smaller.
Our proof bounds the per-period information ratio, so it can be used to provide finite time regret bounds for stationary contextual bandit problems.
\citet{hao2022contextual} provide an interesting study of variants of Information-directed sampling in contextual bandits with complex information structure.
It is not immediately clear how that work relates to \cref{lem:contextual} and the information ratio of Thompson sampling.
The next corollary combines the information ratio bound above with the earlier bound of \cref{thm:effective-horizon-bound}.
The bound depends on the number of arms, the dimension of the parameter space, and the effective time horizon.
No further structural assumptions (e.g., linearity) are needed.
An unfortunate feature of the result is that it applies only to parameter vectors that are quantized at scale $\epsilon$.
The logarithmic dependence on $\epsilon$ is omitted in the $\tilde{O}(\cdot)$ notation, but displayed in the proof.
When outcome distributions are smooth in $\theta_t$, we believe this could be removed with careful analysis.
\begin{corollary}\label{cor:contextual} Under \cref{assumption:contextual},
if $\theta_t \in \{ -1, -1+\epsilon, \ldots, 1-\epsilon, 1 \}^{p}$ is a discretized $p$-dimensional vector, and the optimal policy process $(A^*_t)_{t\in \mathbb{N}}$ is stationary, then
\[
\Delta(\pi^{\rm TS}) \leq \tilde{O}\left( \sigma \sqrt{ \frac{p \cdot k}{\tau_\textup{eff}} } \right).
\]
\end{corollary}
\section{Lower Bound}\label{sec:lower}
We provide an impossibility result through the next Theorem, showing that no algorithm can perform significantly better than the upper bounds provided in the previous section.
Our proof is built by modifying well known lower bound examples for stationary bandits.
\begin{theorem} \label{thm:lower-bound}
Let $k > 1$ and $\tau \geq k$.
There exists a nonstationary bandit problem instance $|\mathcal{A}|=k$ and $\tau_{\rm eff}=\tau$, such that
$$ \inf_{\pi}\Delta(\pi) \geq C \cdot \sigma \sqrt{ \frac{|\mathcal{A}|}{\tau_{\rm eff}} }, $$
where $C$ is a universal constant.
\end{theorem}
\begin{remark}
For the problem instance constructed in the proof, the entropy rate of optimal action process is $\bar{H}(A^*) \approx \log(| \mathcal{A} |)/\tau_{\rm eff}$.
This implies that the upper bound established in \cref{cor:k-armed} is tight up to logarithmic factors, and so is the one established in \cref{thm:main-result}.
\end{remark}
\section{Conclusion and Open Questions}
We have provided a new information-theoretic analysis of interactive learning in changing environments.
The results offer an intriguing measure of the difficulty of learning: the entropy rate of the optimal action process.
A strength of the approach is that it applies to nonstationary variants of many of the most important learning problems.
Instead of designing algorithms to make the proofs work, most results apply to TS, one of the most widely used bandit algorithms.
TS can explore too aggressively in nonstationary learning problems with short effective horizon.
It is continually uncertain about the optimal arm and explores often in response.
But the value of acquiring information is low if it cannot be exploited for long before the state of the environment changes.
To resolve this, one should consider variants of TS that \emph{satisfice}, like the version proposed by \citet{liu22}.
We conjecture that a synthesis of our analysis with the information-ratio analysis of satisficing in \citet{russo22}
could tighten our bounds in some cases.
Namely, we believe they are loose in problems where the optimal action changes frequently and unpredictably, but one still attain near-optimal rewards by tracking an (`satisficing') action-sequence which changes less frequently.
Worst-case examples in the variation budget framework \cite{besbes14} are often addressed in this way. See \citet{chen19}
\vfill
\pagebreak
\nocite{langley00}
| {'timestamp': '2023-02-10T02:07:04', 'yymm': '2302', 'arxiv_id': '2302.04452', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04452'} | arxiv |
\section{Introduction}
\label{sec:intro}
Many important application domains for machine learning (ML), such as numerical weather prediction, the internet
of things or healthcare, generate decentralized data \cite{BigDataNetworksBook}. Decentralized
data consists of local datasets that are related by an intrinsic network structure. Such a
network structure might arises from relations between the generators of local datasets or
functional constrains of the M\cite{nflarxiv2022}. We can represent such networked
data using an undirected weighted empirical graph \cite[Ch. 11]{SemiSupervisedBook}.
There is already a substantial body of literature on machine learning (ML) and signal processing
models and techniques for graph structured data \cite{SemiSupervisedBook,EmergingGSP}.
Most of existing work studies parametric models for local datasets that are related by an
intrinsic network structure. Arguably the most basic setting are scalar graph signal-in-noise
models using different smoothness or clustering assumptions \cite{JungTVMin2019,EmergingGSP}.
The extension from scalar signal-in-noise models to vector-valued graph signals and networked
exponential families has been studied in \cite{JungNetExp2020,VarmaTSIPN2020}.
Federated learning (FL) is an umbrella term for collaborative training of ML models from decentralized
data. FL methods have been championed for high-dimensional parametric models such as deep nets \cite{pmlr-v54-mcmahan17a,FLBookLudwig,FLBookYang}.
A focus of FL research so far has been on distributed optimization methods that exchange
different forms of model parameter updates such as gradients \cite{Liu2020,DeanDistSGD2012,TsiBerAth86,NEURIPS2018_8fb21ee7}.
However, there is only little work on FL of non-parametric models such as decision trees.
The adaption of specific decision tree algorithms to a FL setting is discussed in \cite[Ch. 2]{FLBookLudwig}.
The closest to our work is a recent study of a model agnostic \gls{fl} method that uses knowledge
distillation to couple the training of (arbitrary) local models \cite{Afonin2022}. Similar to this knowledge
distillation approach also we use the predictions of local models on the same dataset to construct
a regularization term. However, in contrast to \cite{Afonin2022} we exploit the network structure
of decentralized data to construct the regularization term.
{\bf Contribution.} To the best of our knowledge, we present the first model agnostic FL method for
decentralized data with an intrinsic network structure. Our method copes with arbitrary collections
of local models for which efficient implementations are available. Examples for such implementations
can be found in Python libraries such as \texttt{scikit-learn}, \texttt{Keras} or \texttt{PyTorch} \cite{JMLR:v12:pedregosa11a,AutoKeras2023,NEURIPS2019_bdbca288}. The proposed method
couples the training of well-connected local models (forming a cluster) via enforcing them to deliver
similar predictions for a pre-specified test set.
{\bf Outline.} Section \ref{sec:non_parametric_nfl} formulates the problem of \gls{fl} from
decentralized data. Section \ref{sec_fedrelax} presents a model-agnostic \gls{fl} method
that trains heterogeneous networks of (local) ML models in a distributed fashion.
\section{Problem Formulation}
\label{sec:non_parametric_nfl}
Section \ref{sec_emp_graph} introduces the \gls{empgraph} as a useful representation
of collections of \gls{localdataset}s along with their similarities.
Section \ref{sec_net_models} augments the \gls{empgraph} by assigning a separate
local \gls{hypospace} (or model) to each node. Section \ref{sec_fedrelax} presents our
model agnostic FL method for coupling the training of local models by regularization.
The regularization will be implemented by enforcing a small variation of local models at
well-connected nodes (clusters). Section \ref{sec_gtv_measure} introduces the \gls{gtv} as
quantitative measure for the variation of heterogeneous networks of ML models.
large \gls{trainset} to train each local model.
\subsection{The Empirical Graph }
\label{sec_emp_graph}
We represent decentralized data, i.e., collections of local datasets $\localdataset{i}$, for $i = \{1,\ldots,n\}$,
using an \gls{empgraph} $\mathcal{G} \defeq \pair{\mathcal{V}}{\mathcal{E}}$ with nodes (vertices) $\mathcal{V} = \{1,\ldots,n\}$.
The \gls{empgraph} of decentralized data is an undirected weighted graph $\mathcal{G}=(\mathcal{V},\mathcal{E})$
whose nodes $\mathcal{V} \defeq \{1,\ldots,n\}$ carry the \gls{localdataset}s $\localdataset{i}$, for $i \in \mathcal{V}$.
Each node $i \!\in\!\mathcal{V}$ of the \gls{empgraph} $\mathcal{G}$ carries the \gls{localdataset}
\begin{equation}
\label{equ_def_local_dataset_plain}
\localdataset{i} \defeq \left\{ \big(\featurevec^{(i,1)},\truelabel^{(i,1)}\big), \ldots,\big(\featurevec^{(i,m_{i})},\truelabel^{(i,m_{i})}\big) \right\}.
\end{equation}
Here, $\featurevec^{(i,\sampleidx)}$ and $\truelabel^{(i,\sampleidx)}$ denote, respectively, the feature vector and
true label of the $\sampleidx$th \gls{datapoint} in the \gls{localdataset} $\localdataset{i}$.
Note that the size $m_{i}$ of the \gls{localdataset} might vary between different
nodes $i \in \mathcal{V}$.
An undirected edge $\{i,i'\}\!\in\!\mathcal{E}$ in the \gls{empgraph} indicates that the local
datasets $\localdataset{i}$ and $\localdataset{i'}$ have similar statistical properties.
We quantify the level of similarity by a positive edge weight $A_{i,i'}\!>\!0$.\footnote{The notion of statistical similarity
could be made precise using a \gls{probmodel} that interprets the \gls{datapoint}s in each \gls{localdataset} $\localdataset{i}$
as \gls{iid} draws from an underlying \gls{probdist} $p^{(i)}\big(\featurevec,\truelabel\big)$.
}
The neighbourhood of a node $i \in \mathcal{V}$ is $\neighbourhood{i} \defeq \{ i' \in \mathcal{V}: \{i,i'\} \in \mathcal{E}\}$.
Note that the undirected edges $e{i}{i'}$ of an empirical graph encode a symmetric
notion of similarity between \gls{localdataset}s. If the \gls{localdataset} $\localdataset{i}$ at node $i$
is (statistically) similar to the \gls{localdataset} $\localdataset{i'}$ at node $i'$, then also the
\gls{localdataset} $\localdataset{i'}$ is (statistically) similar to the \gls{localdataset} $\localdataset{i}$.
The \gls{empgraph} of \gls{netdata} is a design choice which is guided by \gls{compasp} and \gls{statasp} of the resulting
ML method. For example, using an \gls{empgraph} with a relatively small number of edges (``sparse graphs'')
typically results in a smaller computational complexity. Indeed, the amount of computation required by the \gls{fl}
methods developed in Section \ref{sec_fedrelax} is proportional to the number of edges in the \gls{empgraph}.
On the other hand, the \gls{empgraph} should contain sufficient number of edges between nodes that
carry statistically similar \gls{localdataset}s. This allows \gls{gtvmin} techniques to adaptively
pool \gls{localdataset}s into clusters of (approximately) homogeneous data.
\subsection{Networked Models}
\label{sec_net_models}
Consider \gls{netdata} with \gls{empgraph} $\mathcal{G}$ whose nodes $i \in \mathcal{V}$ carry \gls{localdataset}s
$\localdataset{i}$. For each node $i \in \mathcal{V}$, we wish to learn a useful \gls{hypothesis}
$\learntlocalhypothesis{i}$ from a local \gls{hypospace} $\localmodel{i}$. The
learnt \gls{hypothesis} should incur a small average \gls{loss} over a \gls{localdataset} $\localdataset{i}$,
\begin{equation}
\label{equ_def_local_lossfunc}
\hspace*{-3mm}\locallossfunc{i}{\learntlocalhypothesis{i}}\!\defeq\!(1/\localsamplesize{i}) \sum_{\sampleidx=1}^{\localsamplesize{i}} \hspace*{-1mm}\loss{\big( \featurevec^{(i,\sampleidx)}, \truelabel^{(i,\sampleidx)} \big)}{\learntlocalhypothesis{i}}.
\end{equation}
A collection of local models $\localmodel{i}$, for each $i \in \mathcal{V}$,
defines a \gls{netmodel} $\netmodel{\mathcal{G}}$ over the \gls{empgraph} $\mathcal{G}$,
\begin{equation}
\netmodel{\mathcal{G}}: i \mapsto \localmodel{i} \mbox{ for each node } i \in \mathcal{V}.
\end{equation}
A \gls{netmodel} is constituted by networked \gls{hypothesis} maps $\hypothesis \in \netmodel{\mathcal{G}}$.
Each such networked \gls{hypothesis} map assigns each node $i \in \mathcal{V}$ a local \gls{hypothesis},
\begin{equation}
\hypothesis: i \mapsto \localhypothesis{i} \in \localmodel{i}.
\end{equation}
It is important to note a \gls{netmodel} may combine different types of local models $\localmodel{i}$.
For example, $\localmodel{i}$ might be a linear model $\linmodel{\featuredim}$, while $\localmodel{i'}$
might be a \gls{decisiontree} for some other node $i' \neq i$. The only restriction we
place on the choice for local models is the availability of computational means (``a .fit() function'') to
train them via regularized empirical risk minimization.
\subsection{Generalized Total Variation}
\label{sec_gtv_measure}
In principle, we could train each local model $\localmodel{i}$ separately on the
corresponding \gls{localdataset} $\localdataset{i}$ for each node $i \in \mathcal{V}$.
However, the \gls{localdataset}s might be too small to train a \gls{localmodel} which might be
a deep neural net or a linear model using a large number of features. As a remedy, we could try
to pool local datasets if they have similar statistical properties to obtain a sufficiently large
dataset to train the local models $\localmodel{i}$.
We use the network structure of the \gls{empgraph} $\mathcal{G}$ to adaptively pool \gls{localdataset}s
with similar statistical properties. This pooling will be implemented by requiring local models at
well-connected nodes (clusters) to behave similar on a common test set. To make this informal
idea more precise we next introduce a quantity measure for the variation of local models across
the edges in $\mathcal{G}$.
Consider two nodes $i, i' \in \mathcal{G}$ in the \gls{empgraph} that are connected by
an edge $e{i}{i'}$ with weight $A_{i,i'}$. We define
the variation between $\hypothesis^{(i)}$ and $\hypothesis^{(i')}$ via the discrepancy
between their predictions
\begin{align}
\label{equ_def_variation_non_parametric}
\hspace*{-4mm} \variation{\localhypothesis{i}}{\localhypothesis{i'}} & \!\defeq\! (1/m') \sum_{\sampleidx=1}^{m'}
\bigg[\loss{\pair{\featurevec^{(\sampleidx)}}{\hypothesis^{(i)}\big(\featurevec^{(\sampleidx)}\big)}}{\hypothesis^{(i')}} \nonumber \\
&\hspace*{10mm} \!+\!\loss{\pair{\featurevec^{(\sampleidx)}}{\hypothesis^{(i')}\big(\featurevec^{(\sampleidx)}\big)}}{\hypothesis^{(i)}} \bigg]
\end{align}
on a common test-set
\begin{equation}
\label{equ_test_set}
\dataset^{(\rm test)} = \left\{ \featurevec^{(1)},\ldots, \featurevec^{(m')}\right\}.
\end{equation}
The test set \eqref{equ_test_set} must be shared with each node $i \in \mathcal{V}$ of the \gls{empgraph}.
We then define the \gls{gtv} of a networked \gls{hypothesis} $\hypothesis \in \netmodel{\mathcal{G}}$,
consisting of local \gls{hypothesis} maps $\localhypothesis{i} \in \localmodel{i}$ (for each node $i \in \mathcal{V}$)
by summing the discrepancy \eqref{equ_def_variation_non_parametric} over all edges $\mathcal{E}$,
\begin{align}
\label{equ_def_gtv_non_param}
\gtv{\hypothesis} \defeq \sum_{e{i}{i'} \in \mathcal{E}} A_{i,i'} \variation{\localhypothesis{i}}{\localhypothesis{i'}}.
\end{align}
Note that $\gtv{\hypothesis}$ is parametrized by the choice for the \gls{lossfunc} $L$ used to compute
the discrepancy $\variation{\localhypothesis{i}}{\localhypothesis{i'}}$ \eqref{equ_def_variation_non_parametric}.
The \gls{lossfunc} might be different from the local \gls{lossfunc} \eqref{equ_def_local_lossfunc} used to
measure the prediction error of a local \gls{hypothesis} $\localhypothesis{i}$. However, it might be
beneficial to use the same \gls{lossfunc} in \eqref{equ_def_local_lossfunc} and
\eqref{equ_def_variation_non_parametric} (see Section \ref{equ_def_mod_agn_fredreg}).
\section{A Model Agnostic FL Method}
\label{sec_fedrelax}
We now present our \gls{fl} method for learning a local \gls{hypothesis} map $\learntlocalhypothesis{i}$ for
each node $i$ of a an \gls{empgraph} $\mathcal{G}$. This method is from an instance of \gls{rerm},
using \gls{gtv} \eqref{equ_def_gtv_non_param} as regularizer,
\begin{equation}
\label{equ_def_gtv_min}
\min_{\{ \localhypothesis{i} \in \localmodel{i}\}} \sum_{i \in \mathcal{V}} \locallossfunc{i}{\localhypothesis{i}} + \lambda
\sum_{e{i}{i'} \in \mathcal{E}} A_{i,i'} \variation{\localhypothesis{i}}{\localhypothesis{i'}} .
\end{equation}
We use block-coordinate minimization \cite{ParallelDistrBook,CvxAlgBertsekas} to solve \gls{gtvmin} \eqref{equ_def_gtv_min}.
To this end, we rewrite \eqref{equ_def_gtv_min} as
\begin{equation}
\label{equ_GTVMin_MOCHA_coordmin}
\min_{\hypothesis \in \netmodel{\mathcal{G}}} \underbrace{\sum_{i \in \mathcal{V}}
\locallossfunc{i}{\localhypothesis{i}}+(\lambda/2) \sum_{i' \in \neighbourhood{i}} A_{i,i'} \variation{\localhypothesis{i}}{\localhypothesis{i'}}}_{\defeq f(\localhypothesis{1},\ldots,\localhypothesis{n})} \nonumber \\
\end{equation}
Given some local \gls{hypothesis} maps $\estlocalhypositer{i}{k'}$, for all nodes $i'\in \mathcal{V}$,
we compute (hopefully improved) updated local \gls{hypothesis} maps $\estlocalhypositer{i}{k'+1}$
by minimizing $f(\hypothesis)$ along $\localhypothesis{i}$, keeping the other local \gls{hypothesis} maps fixed,
\begin{align}
\label{equ_def_coord_min_update}
\estlocalhypositer{i}{k+1} & \in \argmin_{\localhypothesis{i} \in \localmodel{i}}f\bigg( \estlocalhypositer{1}{k},\ldots,\estlocalhypositer{i-1}{k},\localhypothesis{i},\estlocalhypositer{i+1}{k},\ldots \bigg) \nonumber \\
& \hspace*{-10mm} \stackrel{\eqref{equ_GTVMin_MOCHA_coordmin}}{=} \argmin_{{\localhypothesis{i} \in \localmodel{i}}} \locallossfunc{i}{\localhypothesis{i}} + (\lambda/2) \sum_{i' \in \neighbourhood{i}} A_{i,i'} \variation{\localhypothesis{i}}{\estlocalhypositer{i'}{k}}.
\end{align}
We obtain Algorithm \ref{alg_fed_relax_nonparam} by iterating \eqref{equ_def_coord_min_update} (simultaneously at
all nodes $i \in \mathcal{V}$) until a \gls{stopcrit} is met.
\begin{algorithm}[htbp]
\caption{FedRelax}
\label{alg_fed_relax_nonparam}
{\bf Input}: empirical graph $\mathcal{G}$ with edge weights $A_{i,i'}$;
local \gls{lossfunc}s $\locallossfunc{i}{\cdot}$; test-set $\dataset' = \left\{ \featurevec^{(1)},\ldots, \featurevec^{(m')}\right\}$; \gls{gtv} parameter $\lambda$; \gls{lossfunc} $L$ for computing the discrepancy $\discrepancy{i}{i'}{\hypothesis}$ \\
{\bf Initialize}: $k\!\defeq\!0$; $\estlocalhypositer{i}{0}\!\equiv\!0$ for all nodes $i \in \mathcal{V}$
\begin{algorithmic}[1]
\While{stopping criterion is not satisfied}
\For{all nodes $i \in \mathcal{V}$ in parallel}
\State share predictions $\left\{ \estlocalhypositer{i}{k} \big(\featurevec \big) \right\}_{\featurevec \in \dataset^{(\rm test)} }$,
with neighbours $i' \in \neighbourhood{i}$
\State \label{equ_update_fed_relax} update \gls{hypothesis} $\estlocalhypositer{i}{k}$ as follows:
\begin{align}
\label{equ_update_step_fed_relax}
\hspace*{-6mm} \estlocalhypositer{i}{k+1} & \!\in\! \argmin_{\localhypothesis{i} \in \localmodel{i}} \hspace*{-1mm} \locallossfunc{i}{\localhypothesis{i}} \!+\! (\lambda/2)\hspace*{-3mm} \sum_{i' \in \neighbourhood{i}}\hspace*{-3mm} A_{i,i'} \variation{\localhypothesis{i}}{\estlocalhypositer{i'}{k}}.
\end{align}
\EndFor
\State $k\!\defeq\!k\!+\!1$
\EndWhile
\end{algorithmic}
\end{algorithm}
The main computational work of Algorithm \ref{alg_fed_relax_nonparam} is done in step \eqref{equ_update_fed_relax}.
This step is an instance of \gls{rerm} for the local model $\localmodel{i}$ at each node
$i \in \mathcal{V}$. The regularization term for this \gls{rerm} instance is a weighted sum of the
discrepancies \eqref{equ_def_variation_non_parametric} between the predictions (for the labels
on the test set \eqref{equ_test_set}) of the local \gls{hypothesis} map $\localhypothesis{i}$
and the predictions of the current local \gls{hypothesis} maps $\localhypothesis{i}$ at
neighbouring nodes $i' \in \neighbourhood{i}$.
\subsection{Model Agnostic Federated Regression}
\label{equ_def_mod_agn_fredreg}
Note that Algorithm \ref{alg_fed_relax_nonparam} is parametrized by the choices for the \gls{lossfunc}
used to measure the training error \eqref{equ_def_local_lossfunc} of a local \gls{hypothesis} $\hat{\hypothesis}{i}$ and the \gls{lossfunc}
used to measure the discrepancy \eqref{equ_def_variation_non_parametric} between the local models at
connected nodes.
A popular choice for the \gls{lossfunc} in regression problems, i.e., data points having an
numeric label, is the \gls{sqerrloss}
\begin{equation}
\label{equ_squared_loss}
\loss{(\featurevec,\truelabel)}{h} \defeq \big(\truelabel - \underbrace{h(\featurevec)}_{=\predictedlabel} \big)^{2}.
\end{equation}
We obtain Algorithm \ref{alg_fed_relax_nonparam_regr} as the special case of Algorithm \ref{alg_fed_relax_nonparam} when using
the \gls{sqerrloss} in \eqref{equ_def_local_lossfunc} and \eqref{equ_def_variation_non_parametric}.
\begin{algorithm}[htbp]
\caption{FedRelax Least-Squares Regression}
\label{alg_fed_relax_nonparam_regr}
{\bf Input}: empirical graph $\mathcal{G}$ with edge weights $A_{i,i'}$; local \gls{lossfunc}s $\locallossfunc{i}{\cdot}$; test-set $\dataset' = \left\{ \featurevec^{(1)},\ldots, \featurevec^{(m')}\right\}$; \gls{gtv} parameter $\lambda$ \\
{\bf Initialize}: $k\!\defeq\!0$; $\estlocalhypositer{i}{0}\!\equiv\!0$ for all nodes $i \in \mathcal{V}$
\begin{algorithmic}[1]
\While{stopping criterion is not satisfied}
\For{all nodes $i \in \mathcal{V}$ in parallel}
\State share test-set labels $\left\{ \estlocalhypositer{i}{k} \big(\featurevec \big) \right\}_{\featurevec \in \dataset^{(\rm test)} }$,
with neighbours $i' \in \neighbourhood{i}$
\State update \gls{hypothesis} $\estlocalhypositer{i}{k}$ as follows:
\begin{align}
\label{equ_update_step_fed_relax}
\hspace*{-4mm} \estlocalhypositer{i}{k+1} & \in \argmin_{\localhypothesis{i} \in \localmodel{i}} \bigg[ \locallossfunc{i}{\localhypothesis{i}} & \nonumber \\
& \hspace*{-8mm}+ (\lambda/(2m')) \hspace*{-3mm} \sum_{i' \in \neighbourhood{i}}\hspace*{-3mm} A_{i,i'} \hspace*{-1mm}\sum_{\sampleidx=1}^{m'} \left(
\hypothesis^{(i)}\big(\featurevec^{(\sampleidx)}\big) -\estlocalhypositer{i'}{k} \big(\featurevec^{(\sampleidx)}\big) \right)^2 \bigg].
\end{align}
\EndFor
\State $k\!\defeq\!k\!+\!1$
\EndWhile
\end{algorithmic}
\end{algorithm}
Note that the update \eqref{equ_update_step_fed_relax} is nothing but regularized \gls{erm} for
learning a local \gls{hypothesis} $\localhypothesis{i} \in \localmodel{i}$ from the
\gls{localdataset} $\localdataset{i}$. The regularization term in \eqref{equ_update_step_fed_relax} is
the average \gls{sqerrloss} incurred on the (``pseudo-'') labeled test set (see \eqref{equ_test_set})
\begin{equation}
\bigcup_{i' \in \neighbourhood{i}} \left\{ \pair{\featurevec^{(1)}}{\estlocalhypositer{i'}{k}\big(\featurevec^{(1)}},\ldots, \pair{\featurevec^{(m')}}{\estlocalhypositer{i'}{k}\big(\featurevec^{(m')}} \right\}.
\end{equation}
| {'timestamp': '2023-02-10T02:03:10', 'yymm': '2302', 'arxiv_id': '2302.04363', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04363'} | arxiv |
\section{Introduction}
\label{sec:1_introduction}
\IEEEPARstart{D}{esigning} current references to bias analog blocks constituting Internet-of-Things (IoT) nodes, such as low-power operational amplifiers \cite{Magnelli_2013} and wake-up timers \cite{Jeong_2015}, requires these references to be both area-efficient and robust to process, voltage and temperature (PVT) variations. This task appears to be of particular difficulty in the nA range, with Fig.~\ref{fig:1_context}(a) highlighting the absence of area-efficient solutions for the generation of a constant-with-temperature (CWT) nA-range current. This gap originates from the fact that conventional CWT current references [Fig.~\ref{fig:1_context}(b)] consist in applying a reference voltage to a voltage-to-current converter, which is usually implemented by a gate-leakage transistor \cite{Wang_2016, Wang_2018, Zhuang_2020} or a resistor \cite{Wang_2019_TCAS, Huang_2020}. These converters are well suited to the generation of a pA- or $\mu$A-range current, in the sense that they occupy a reasonable silicon area at this current level. Unfortunately, the generation of a nA-range current would lead to a much larger area, as the resistance of the gate-leakage transistor (resp. resistor) needs to be decreased (resp. increased) by placing devices in parallel (resp. series). Besides, proportional-to-absolute-temperature (PTAT) current references operating in the nA range, such as \cite{CamachoGaleano_2005, CamachoGaleano_2008}, are area-efficient because they rely on a self-cascode MOSFET (SCM) biased with a PTAT voltage. This structure generates a current proportional to the so-called specific sheet current and thus, to temperature. Even though prior designs have tried to harness the area efficiency of SCMs to generate a CWT current \cite{Huang_2010, Wang_2019_VLSI}, they cannot easily be ported to other technologies as they rely on a particular temperature dependence of the specific sheet current. An even more important challenge is thus to tackle key criteria such as the temperature coefficient (TC) and line sensitivity (LS) in the specific case of current references operating in the nA range.\looseness=-1\\
\begin{figure}[!t]
\centering
\includegraphics[width=.49\textwidth]{figure_1_context_v4.pdf}
\caption{(a) Trade-off between silicon area and reference current, based on prior art, highlighting the absence of area-efficient solutions for the generation of a nA-range CWT current. (b) Conventional CWT current references are based on a reference voltage applied to a gate-leakage transistor or a resistor, which are respectively well suited to the generation of a pA- or $\mu$A-range current.}
\label{fig:1_context}
\end{figure}
\IEEEpubidadjcol
\indent In this work, we propose a nA-range CWT current reference based on an SCM, which differs from \cite{CamachoGaleano_2005, CamachoGaleano_2008} by the addition of a CWT offset to the PTAT voltage biasing the SCM. This offset voltage is key in making SCM-based references CWT, and is obtained as the threshold voltage difference $\Delta V_T$ between two transistors of the same $V_T$ type, one of them being forward body-biased to reduce its threshold voltage. For the sake of generalization, this work expands on our conference paper \cite{Lefebvre_2022_ESSCIRC} by demonstrating the feasibility of the proposed reference in a conventional bulk technology, compared to fully-depleted silicon-on-insulator (FDSOI) only in \cite{Lefebvre_2022_ESSCIRC}. The proposed reference is validated in two CMOS technologies through post-layout simulations in TSMC \mbox{65-nm} bulk and measurements in GlobalFoundries (GF) \mbox{22-nm} FDSOI. In addition, it provides additional insight into the design, architecture and post-layout simulations of the reference in both technologies. The paper is structured as follows. Section~\ref{sec:2_governing_equations_and_operation_principle} explains the operation principle of the proposed reference based on its governing equations. Next, Section~\ref{sec:3_design_and_sizing_methodology} details the methodology used to size the reference. Then, Section~\ref{sec:4_optimization_and_simulation_results} discusses design optimizations, as well as simulation results in 65 and 22~nm, while Section~\ref{sec:5_measurement_results} presents the measurement results in 22~nm. Finally, Section~\ref{sec:6_comparison_to_the_state_of_the_art} compares the proposed reference to the state of the art, and Section~\ref{sec:7_conclusion} offers some concluding remarks.\looseness=-1
\section{Governing Equations and Operation Principle}
\label{sec:2_governing_equations_and_operation_principle}
\indent In this section, our first objective is to explain how the addition of a CWT offset to the voltage biasing the SCM leads to a temperature-independent reference current, based on general equations governing the current reference behavior. Then, we highlight the differences with respect to PTAT references \cite{CamachoGaleano_2005, CamachoGaleano_2008} and detail how temperature independence is achieved in the proposed reference with generic parameters. Finally, we compare different ways of implementing the offset voltage.\looseness=-1
\begin{figure}[!t]
\centering
\includegraphics[width=.488\textwidth]{figure_2_basic_schematic_v1.pdf}
\caption{Basic schematic of the proposed current reference, which consists of an SCM formed by $M_{1-2}$ (in blue) and further simplified in (b), and a $\beta$-multiplier composed of $M_{6-7}$ (in orange) summarized in (c).}
\label{fig:2_basic_schematic}
\end{figure}
\vspace{-0.25cm}
\subsection{Governing Equations}
\label{subsec:2A_governing_equations}
\indent To establish the equations governing the reference, we rely on the schematic in Fig.~\ref{fig:2_basic_schematic}(a), which consists of two main elements: an SCM and a $\beta$-multiplier, both supplied by pMOS current mirrors. First, the SCM relies on long-channel transistors in moderate inversion, for which a simplified model such as the analog compact MOSFET (ACM) model \cite{Cunha_1998} is adequate to describe the transistor current-voltage (\mbox{I-V}) curve. In this model, the drain current is given by
\begin{equation}
I_D = I_{SQ}S(i_f-i_r)\textrm{,}\label{eq:id_acm}
\end{equation}
where $I_{SQ} = \frac{1}{2}\mu C_{ox}^{'} nU_T^2$ is the specific sheet current, $\mu$ is the carrier mobility, $C_{ox}^{'}$ is the normalized gate oxide capacitance, $n$ is the subthreshold slope factor, $U_T$ is the thermal voltage, $S = W/L$ is the transistor aspect ratio, and $i_f$, $i_r$ are the forward and reverse inversion levels. The transistor I-V curve is captured by
\begin{equation}
V_P - V_S = U_T \left[\sqrt{1+i_f} - 2 + \log\left(\sqrt{1+i_f}-1\right)\right]\textrm{,}\label{eq:vs_acm}
\end{equation}
where $V_P = (V_G - V_{T0})/n$ is the pinch-off voltage, $V_{T0}$ is the threshold voltage at zero $V_{BS}$, and all voltages are referred to the transistor's body. A similar equation is obtained for the reverse inversion level, by replacing $i_{f}$ by $i_{r}$ and $V_S$ by $V_D$ in (\ref{eq:vs_acm}), but it is only relevant when the transistor is not saturated.\\
\indent Two distinct expressions of voltage $V_X$ are obtained by applying the ACM equations to transistors $M_{1-2}$ forming the SCM, and are given by (\ref{eq:vx_SCM_if1}) and (\ref{eq:vx_SCM_ir1}) in Appendix \ref{sec:8_appendix} with $\alpha \triangleq i_{f1}/i_{f2} > 1$ and $\beta \triangleq i_{r1}/i_{f2} \in [0;1]$. Then, the ratio of the aspect ratios of $M_{1-2}$ must comply with
\begin{equation}
\frac{S_1}{S_2} = \frac{I_{SQ2}}{I_{SQ1}} \frac{1+N}{N} \frac{1}{\alpha - \beta}\label{eq:S1_over_S2}
\end{equation}
to ensure that Kirchhoff's current law is respected, $N$ being the current ratio between $M_3$ and $M_4$. Next, the ACM equations are applied to the weak-inversion transistors $M_{6-7}$ constituting the $\beta$-multiplier [Fig.~\ref{fig:2_basic_schematic}(c)]. We consider two distinct cases to obtain the expression of voltage $V_X$. First, the case in which $V_{B6} = V_X$ and $M_{6-7}$ have different threshold voltages. In this case, $V_X$ is given by
\begin{IEEEeqnarray}{RCL}
V_X & \simeq & n_6 U_T \log(JK) + \left(\frac{n_6}{n_7}V_{T07} - V_{T06}\right)\textrm{,}\label{eq:vx_beta_mult_vt_type}\\
& = & n U_T \log(JK) + \left(V_{T07} - V_{T06}\right)\textrm{,}\label{eq:vx_beta_mult_length}
\end{IEEEeqnarray}
$J$ and $K$ being current mirror ratios, with (\ref{eq:vx_beta_mult_vt_type}) corresponding to transistors with different $V_T$ types and hence entirely distinct characteristics, and (\ref{eq:vx_beta_mult_length}) to transistors of the same $V_T$ type but with different lengths, and thus similar characteristics except for their $V_{T0}$.
Second, we deal with the case in which $V_{B6} > V_X$, $M_{6-7}$ have the same $V_T$ type and length, and forward body$\:$/$\:$back-gate biasing (FBB) is leveraged to reduce $V_{T6}$. If the impact of the body effect on threshold voltage is modeled as $V_T = V_{T0} - \gamma_b V_{BS}$ for an nMOS, with $\gamma_b$ denoting the body factor, voltage $V_X$ is computed as
\begin{equation}
V_X = n U_T \log(JK)+ \gamma_b\left(V_{B6} - V_X\right)\textrm{.}\label{eq:vx_beta_mult_fbb}
\end{equation}
Ultimately, regardless of the origin of $\Delta V_T$, (\ref{eq:vx_beta_mult_vt_type}) to (\ref{eq:vx_beta_mult_fbb}) boil down to a single expression
\begin{equation}
V_X = n U_T \log(K_{PTAT}) + \Delta V_T\textrm{,}\label{eq:vx_beta_mult_final}
\end{equation}
with $K_{PTAT} \triangleq JK$. Connecting the SCM and the $\beta$-multiplier as in Fig.~\ref{fig:2_basic_schematic}(a) amounts to equating (\ref{eq:vx_SCM_if1}) and (\ref{eq:vx_beta_mult_final}), and leads to
\begin{IEEEeqnarray}{C}
\left[\left(\sqrt{1+\alpha i_{f2}}-\sqrt{1+i_{f2}}\right) + \log\left(\frac{\sqrt{1+\alpha i_{f2}}-1}{\sqrt{1+i_{f2}}-1}\right)\right]\IEEEnonumber\\
= \log(K_{PTAT}) + \textcolor{ECS-Red}{\frac{\Delta V_T}{n U_T}}\textrm{,}\label{eq:vx_equality}
\end{IEEEeqnarray}
in which only the term highlighted in red is temperature-dependent due to the combined temperature dependence of $\Delta V_T$ and $U_T$. Besides, applying (\ref{eq:id_acm}) to $M_2$ gives the expression of the reference current
\begin{equation}
I_{REF}(T) = I_{SQ2}(T) i_{f2}(T) (S_2/N)\textrm{,}\label{eq:iref}
\end{equation}
where $I_{SQ2}(T) \propto U_T^2\mu(T) \propto T^{2-m}$, with $\mu(T) = \mu(T_0)\left(T/T_0\right)^{-m}$, and $m$ is the temperature exponent of the carrier mobility. An important quantity which remains to be defined is the sensitivity of the reference current to $V_X$,
\begin{equation}
S_{I_{REF}} = \frac{1}{I_{REF}} \frac{dI_{REF}}{dV_X} = \frac{1}{I_{REF}} \frac{dI_{REF}}{di_{f2}} \frac{di_{f2}}{dV_X}\textrm{,}
\end{equation}
with $I_{REF}$ expressed by (\ref{eq:iref}) and $di_{f2}/dV_X$ computed from (\ref{eq:vx_SCM_if1}), consequently yielding
\begin{equation}
S_{I_{REF}} = \frac{2}{i_{f2}n_2 U_T}\left[\frac{\alpha}{\sqrt{1+\alpha i_{f2}}-1} - \frac{1}{\sqrt{1+i_{f2}}-1}\right]^{-1}\textrm{.}\label{eq:siref}
\end{equation}
\indent In what follows, the LS and TC are computed using the box method, i.e.,
\begin{IEEEeqnarray}{RCL}
\textrm{LS} & = & \frac{\left(I_{REF,\mathrm{max}}-I_{REF,\mathrm{min}}\right)}{I_{REF,\mathrm{avg}} \left(V_{DD,\mathrm{max}}-V_{DD,\mathrm{min}}\right)} \times 100 \: \%\textrm{/V,}\label{eq:LS}\\
\textrm{TC} & = & \frac{\left(I_{REF,\mathrm{max}}-I_{REF,\mathrm{min}}\right)}{I_{REF,\mathrm{avg}} \left(T_{\mathrm{max}}-T_{\mathrm{min}}\right)} \times 10^6 \: \textrm{ppm/}^\circ\textrm{C,}\label{eq:TC}%
\end{IEEEeqnarray}
where $I_{REF,\mathrm{min/avg/max}}$ respectively stand for the minimum, average, and maximum reference current among the considered range. $V_{DD,\mathrm{min/max}}$ (resp. $T_{\mathrm{min/max}}$) refer to the lower and upper bounds of the voltage (resp. temperature) range.
\vspace{-0.25cm}
\subsection{Operation Principle}
\label{subsec:2B_operation_principle}
\begin{figure}[!t]
\centering
\includegraphics[width=.48\textwidth]{figure_3_operation_principle_v2.pdf}
\caption{Operation principle of PTAT references proposed in prior art \cite{CamachoGaleano_2005, CamachoGaleano_2008} (in orange) and of the proposed CWT reference (in blue). Analytical expression of (a) the voltage $V_X$ applied to the SCM, (b) the inversion level of $M_2$, denoted as $i_{f2}$, and (c) the reference current $I_{REF}$, as a function of temperature and for $\Delta V_T$~=~20~mV. Generic technological parameters $n$~=~1.2 and $m$~=~1.25 are selected. (b) and (c) are normalized by their value at 25$^\circ$C. For the proposed CWT reference, the parameters leading to a minimum $I_{REF}$ TC are $K_{PTAT} = 6$ and $\alpha = 2.9$.}
\label{fig:3_operation_principle}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_4_parameters_impact_v2.pdf}
\caption{Analytical expression for (a) the TC of $I_{REF}$ and (b) the sensitivity $S_{I_{REF}}$, as a function of $K_{PTAT}$ and $\alpha$, and for the same technological parameters as Fig.~\ref{fig:3_operation_principle}. (c) Location of the $I_{REF}$ TC valley in the $(K_{PTAT};\:\alpha)$ space, for $\Delta V_T$ ranging from 10 to 30~mV. (d) $I_{REF}$ TC and $S_{I_{REF}}$ as a function of $\Delta V_T$, for $\alpha = 4$ and the optimal value of $K_{PTAT}$.}
\label{fig:4_parameters_impact}
\end{figure}
In prior art \cite{CamachoGaleano_2005, CamachoGaleano_2008}, a PTAT reference current is obtained with $ V_{B6} = V_X$ and $M_{6-7}$ sharing the same $V_T$ type and length, thus yielding $\Delta V_T = 0$ and resulting in a purely PTAT voltage $V_X$ [Fig.~\ref{fig:3_operation_principle}(a)]. Equation~(\ref{eq:vx_equality}) subsequently becomes temperature-independent as the term in red amounts to zero. It also means that $i_{f2}$ does not change with temperature [Fig.~\ref{fig:3_operation_principle}(b)]. Ultimately, this forces $I_{REF}$ to have the same temperature dependence as $I_{SQ}$, as stated by (\ref{eq:iref}), and to follow a PTAT trend dictated by $T^{2-m}$ [Fig.~\ref{fig:3_operation_principle}(c)].\\
\indent In the proposed CWT current reference, an offset voltage $\Delta V_T > 0$ which is made CWT by design is added to $V_X$ [Fig.~\ref{fig:3_operation_principle}(a)], augmenting (\ref{eq:vx_equality}) with the temperature-dependent term in red. This causes $i_{f2}$ to decrease with temperature [Fig.~\ref{fig:3_operation_principle}(b)] and, with a proper selection of parameters $(K_{PTAT};\:\alpha)$, can make the temperature dependence of $i_{f2}$ compensate that of $I_{SQ}$. This results in a temperature-independent $I_{REF}$ as depicted in Fig.~\ref{fig:3_operation_principle}(c). An obvious question which arises at this stage is how to choose $(K_{PTAT};\:\alpha)$ to reach temperature independence. In Figs.~\ref{fig:4_parameters_impact}(a) and (b), we study their impact on two figures of merit (FoMs) of the current reference, namely the TC of $I_{REF}$ and $S_{I_{REF}}$, for a fixed CWT $\Delta V_T$~=~20~mV, and generic technological parameters $n$~=~1.2 and $m$~=~1.25. Fig.~\ref{fig:4_parameters_impact}(a) reveals the existence of an $I_{REF}$ TC valley for a linear relationship between $K_{PTAT}$ and $\alpha$. Furthermore, this valley corresponds to an iso-sensitivity curve in Fig.~\ref{fig:4_parameters_impact}(b). In Fig.~\ref{fig:4_parameters_impact}(c), we assess the influence of $\Delta V_T$ on the location of the $I_{REF}$ TC valley, and notice that increasing $\Delta V_T$ raises both the slope and offset of the linear relation between these two parameters. Technological parameters also have an influence on the valley location, with $n$ and $m$ having respectively an effect opposite and similar to $\Delta V_T$. However, these parameters are fixed by the technology and we do not consider them as potential tuning knobs for design. Lastly, Fig.~\ref{fig:4_parameters_impact}(d) depicts the evolution of the FoMs for $\Delta V_T$ ranging from 10 to 30~mV, $\alpha = 4$, and $K_{PTAT}$ corresponding to the $I_{REF}$ TC valley. It emphasizes that a constant \mbox{80-ppm/$^\circ$C} TC can be achieved with a proper choice of parameters, but that $S_{I_{REF}}$ improves from 7.33 to 2.45~$\%$/mV with a growing $\Delta V_T$. This trend is explained by the fact that an increase in $V_X$ pushes $M_{1-2}$ further into moderate inversion and decreases $S_{I_{REF}}$, at the cost of an increased area for the SCM and a larger minimum supply voltage. The values taken by parameters $(K_{PTAT};\:\alpha)$ are thus practically limited by such considerations during the sizing.
\vspace{-0.25cm}
\subsection{Practical Implementation of $\Delta V_{T}$}
\label{subsec:2C_practical_implementation_of_dvt}
The question that remains to be answered is how the offset voltage $\Delta V_T$ is practically achieved in the proposed current reference, knowing that it should ideally be CWT to ease the sizing, and that it does not need to be very large, as $S_{I_{REF}}$ improves less and less for large $\Delta V_T$ values [Fig.~\ref{fig:4_parameters_impact}(d)].
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_5_dvt_implementation_v4.pdf}
\caption{All figures correspond to \mbox{1-$\mu$m-wide} standard-well pMOS devices simulated at 25$^\circ$C, and the threshold voltage is extracted from $g_m/I_D$ vs. $V_{SG}$ curves as described in \cite{Jespers_2017}. $|V_{T0}|$ variations with the transistor length for (a) LVT, RVT and HVT core pMOS in \mbox{65-nm} bulk and (b) LVT and ULL I/O pMOS in \mbox{22-nm} FDSOI. For \mbox{1-$\mu$m-long} devices, (c) $|V_T|$ and (d) $d|V_T|/dV_{SB}$ with $V_{SB}$ for 65- and \mbox{22-nm} devices. $V_{SB}$ is limited by 0.7~V in 65~nm, to avoid the forward biasing of the parasitic diode between the transistor's source and body, and by the \mbox{1.8-V} supply voltage in 22~nm.}
\label{fig:5_dvt_implementation}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=.422\textwidth]{figure_6_pmos_implementation_schematic_v3.pdf}
\caption{Schematic of the proposed reference with a pMOS-based topology, featuring a low-power voltage reference to generate the body$\:$/$\:$back-gate voltage $V_{B6}$. This voltage reference is formed by transistors $M_{8-10}$ and relies on the $V_T$ difference between HVT and LVT pMOS in \mbox{65-nm} bulk (resp. ULL and LVT pMOS in \mbox{22-nm} FDSOI). Note that an nMOS-based topology is also possible, at the cost of a slightly larger silicon area due to the use of triple-well devices.}
\label{fig:6_pmos_implementation_schematic}
\end{figure}
In addition, a large $\Delta V_T$ also increases voltage $V_{GS1} = V_G$ in the SCM, resulting in a larger minimum supply voltage. A good trade-off is thus to have $\Delta V_T$ around 20 to 25~mV. Note that in what follows, we opt for an implementation based on a pMOS SCM as it limits the area overhead by using nwells instead of triple wells, and by leveraging the lower specific current of pMOS devices compared to nMOS ones. Three options are available to obtain a threshold voltage difference between two transistors: (i) different $V_T$ types, (ii) the same $V_T$ type but different lengths, and (iii) leveraging FBB to change the $V_T$ of one out of two transistors sharing the same $V_T$ type and length. Figs.~\ref{fig:5_dvt_implementation}(a) and (b) illustrate the variations of $|V_{T0}|$ for pMOS devices, respectively in TSMC \mbox{65-nm} bulk [Fig.~\ref{fig:5_dvt_implementation}(a)] in which \mbox{low-,} regular- and high-$V_T$ (LVT$\:$/$\:$RVT$\:$/$\:$HVT) core devices are available, and GF \mbox{22-nm} FDSOI [Fig.~\ref{fig:5_dvt_implementation}(b)], in which low-$V_T$ (LVT) and ultra-low-leakage (ULL) I/O devices are available. Both figures show that the $V_T$ difference resulting from using different transistor types is typically between 0.1 and 0.2~V, and is hence much larger than the $\Delta V_T$ we seek to achieve. Then, the same $V_T$ type but different lengths is a possibility to implement a $\Delta V_T$ in the desired range, with a difference from 31 to 120~mV in 65~nm, and from 17 to 27~mV in 22~nm. Nevertheless, this solution requires one of the transistors to be close to minimum length, which degrades other FoMs such as line sensitivity and mismatch, and leads to undesired second order effects due to the use of short-channel devices. Lastly, Figs.~\ref{fig:5_dvt_implementation}(c) and (d) represent the evolution of $V_T$ and the derivative $dV_T/dV_{SB}$ as a function of $V_{SB}$. Fig.~\ref{fig:5_dvt_implementation}(d) shows that in 65~nm, the body factor ranges from 74 to 244~mV/V depending on the $V_T$ type, while in 22~nm, it is around 165~mV/V close to zero $V_{SB}$, i.e., body$\:$/$\:$back-gate and source connected to the same voltage. In this work, we choose to exploit FBB as it allows to obtain a positive offset $\Delta V_T$ contrary to RBB, provides a sufficient tuning range for a \mbox{20-to-25-mV} $\Delta V_T$, and offers the advantage of having devices $M_{6-7}$ with the same technological parameters.\\
\indent A schematic of the proposed current reference including the body$\:$/$\:$back-gate bias generator ($M_{8-10}$) is represented in Fig.~\ref{fig:6_pmos_implementation_schematic}. Note that the topology has been inverted compared to Fig.~\ref{fig:2_basic_schematic}(a), i.e., nMOS and pMOS devices are swapped, as well as ground and supply voltage connections. The proposed reference is thus built around a pMOS-based SCM. The voltage reference is based on the $\Delta V_{SG}$ between an HVT ($M_8$) and LVT ($M_9$) devices biased by a current source ($M_{10}$). It generates a positive reference voltage thanks to the $V_{T}$ difference between $M_{8-9}$, which are practically implemented with core HVT and LVT devices in 65~nm (resp. I/O ULL and LVT devices in 22~nm). Assuming a weak-inversion transistor in saturation, i.e., with $V_{SD} > 4U_T$, $V_{SG}$ is expressed as
\begin{equation}
V_{SG} = |V_{T0}| + nU_T\log\left(\frac{I_{SD}}{I_{SQ}S}\right)\textrm{,}\label{eq:vsg_subthreshold}
\end{equation}
where $I_{SQ} = \mu C_{ox}^{'}(n-1)U_T^2$ is another definition of the specific sheet current. Using (\ref{eq:vsg_subthreshold}), $V_{SB6}$ is equal to
\begin{equation}
V_X-V_{B6} = \left|V_{T08}-V_{T09}\right| + nU_T\log\left(\frac{I_{SQ9}S_9}{I_{SQ8}S_8}\right)\textrm{,}\label{eq:vb6_minus_vx}
\end{equation}
in which the first term is either PTAT or complementary-to-absolute-temperature (CTAT) depending on the TC of the threshold voltages, and the second term's TC can be tuned by changing the ratio $S_9/S_8$. This voltage reference will be sized so that $\Delta V_T$ between $M_6$ and $M_7$ is temperature-independent, as detailed in Section~\ref{subsec:3B_body_back_gate_bias_generator}. Finally, the voltage reference changes the ratio (\ref{eq:S1_over_S2}) to
\begin{equation}
\frac{S_1}{S_2} = \frac{I_{SQ2}}{I_{SQ1}} \frac{1+\mathbf{M}+N}{N} \frac{1}{\alpha - \beta}\textrm{.}\label{eq:S1_over_S2_final}
\end{equation}
\section{Design and Sizing Methodology}
\label{sec:3_design_and_sizing_methodology}
\subsection{Overview of the Methodology}
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_7_sizing_methodology_v2.pdf}
\caption{Four-step flowchart of the design and sizing methodology.}
\label{fig:7_sizing_methodology}
\end{figure}
Fig.~\ref{fig:7_sizing_methodology} provides a flowchart of the sizing methodology. It requires inputs from the designer, i.e., a target reference current, current mirror ratios, transistor lengths and inversion levels, as well as technological parameters, and it outputs transistor widths. The methodology is divided into four steps.
\par\mbox{Step 1)} consists in sizing the body$\:$/$\:$back-gate bias generator by selecting $W_{8-9}$ such that $\Delta V_T$'s TC is minimized.
\par\mbox{Step 2)} makes an educated guess of the value of $\alpha$ minimizing the TC of $I_{REF}$ for a fixed $K_{PTAT}$, which is denoted as $\alpha_{\mathrm{guess}}$. The prediction is based on the linear relationship between $K_{PTAT}$ and $\alpha$ obtained through the parametric analysis developed in Section~\ref{subsec:2A_governing_equations}. It requires the $\Delta V_T$ computed by \mbox{step 1)}, and technological parameters $n$ and $m$, obtained by fitting the ACM model to $g_m/I_D$ curves extracted from SPICE simulations as lookup tables \cite{Jespers_2017}.
\par\mbox{Step 3)} sizes the current reference for a range of $\alpha$ values and a fixed $K_{PTAT}$, based on $\Delta V_T$ and parameters $n$, $m$ and $I_{SQ}$. Several sizings, which differ by the widths of $M_{1-2}$, are used to perform pre-layout SPICE simulations, from which we extract the value of $\alpha$ leading to a minimum $I_{REF}$ TC. This value is referred to as $\alpha_{\mathrm{sim}}$ and should be close to $\alpha_{\mathrm{guess}}$.
\par\mbox{Step 4)} simply consists in running the sizing algorithm with $\alpha = \alpha_{\mathrm{sim}}$, thereby delivering the final transistor widths.
\vspace{-0.25cm}
\subsection{Body$\:$/$\:$Back-Gate Bias Generator}
\label{subsec:3B_body_back_gate_bias_generator}
The setup employed to size the body$\:$/$\:$back-gate bias generator is illustrated in Fig.~\ref{fig:8_sizing_body_bias_gen}(a). It is composed of a low-power voltage reference formed by $M_{8-9}$, biased by an ideal current source $M \times I_{REF}$ with $M$~=~1 and $I_{REF}$~=~1.25~nA, and transistors $M_{6-7}$, respectively body-biased by a positive and zero $V_{SB}$. For $M_{8-9}$, we choose a relatively long length of 5~$\mu$m in 65~nm and 8~$\mu$m in 22~nm to reduce LS and variability. In Figs.~\ref{fig:8_sizing_body_bias_gen}(b) and (c), the width of $M_{8-9}$ is swept from 0.5 to 5~$\mu$m in 0.1-$\mu$m steps to select the design point minimizing the TC of $\Delta V_T$ in 22~nm. Figs.~\ref{fig:8_sizing_body_bias_gen}(b) and (d) show that it corresponds to a slightly CTAT yet close to CWT $V_X - V_{B6}$, with a 123-ppm/$^\circ$C TC, and achieves a 31-ppm/$^\circ$C $\Delta V_T$ in Figs.~\ref{fig:8_sizing_body_bias_gen}(c) and (e). This result is consistent with the fact that $\Delta V_T$ is obtained through the back-gate effect, as described for an nMOS by $V_T(V_{BS}) = V_{T0} - \gamma_b V_{BS}$, where the body factor $\gamma_b$ is temperature-independent at first order in FDSOI~\cite{daSilva_2021}. In 65~nm, a CTAT 1230-ppm/$^\circ$C $V_X - V_{B6}$ voltage is required to obtain a CWT 46-ppm/$^\circ$C $\Delta V_T$, as it is obtained through the temperature-dependent body effect
\begin{equation}
V_T (V_{BS}) = V_{T0} + \gamma_b \left(\sqrt{2\phi_{fp} - V_{BS}} - \sqrt{2\phi_{fp}}\right)\textrm{,}\label{eq:vt_body_effect}
\end{equation}
where $\phi_{fp}$ is Fermi's potential.
\vspace{-0.25cm}
\subsection{Temperature-Independent Current Reference}
\label{subsec:3C_temperature_independent_current_reference}
The parametric analysis yields Figs.~\ref{fig:9_sizing_current_ref}(a) and (b), which are akin to Fig.~\ref{fig:4_parameters_impact}, but for 22~nm and a $\Delta V_T$ of 17.6~mV. As already described in Section~\ref{subsec:2B_operation_principle}, the $I_{REF}$ TC valley corresponds to a linear relationship between $K_{PTAT}$ and $\alpha$, along with an \mbox{iso-$S_{I_{REF}}$} curve. Next, the current reference sizing per se can be performed in two ways. The first one is similar to the sizing methodology proposed in \cite{CamachoGaleano_2005, CamachoGaleano_2008} and is based solely on the ACM model.
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_8_sizing_body_bias_gen_v5.pdf}
\caption{$\Delta V_T$ is made CWT by tuning the TC of $V_{SB6}$ by means of the ratio $S_9/S_8$ (\ref{eq:vb6_minus_vx}). All figures correspond to the behavior in TT. (a) Schematic and testbench of the low-power voltage reference used to generate $V_{B6}$. TC of (b) $V_X - V_{B6}$ and (c) $\Delta V_T$, for different widths of $M_{8-9}$ with $L$~=~8~$\mu$m in 22~nm. (d) Reference voltage $V_X - V_{B6}$ and (e) resulting threshold voltage difference $\Delta V_T$ as a function of temperature at the chosen design point.}
\label{fig:8_sizing_body_bias_gen}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_9_sizing_current_ref_v3.pdf}
\caption{$I_{REF}$ is made CWT by properly selecting $K_{PTAT}$ and $\alpha$. (a) $I_{REF}$ TC and (b) $S_{I_{REF}}$ for different values of $(K_{PTAT};\:\alpha)$ with $\Delta V_T$~=~17.6~mV, $m$~=~1, and $n$~=~1.2, obtained from step~1) of the sizing methodology. In 22~nm and for different values of $\alpha$, (c) $I_{REF}$ TC computed from the analytical model and pre-layout simulation results, with the reference sized using an ACM-based approach, and (d) $S_{I_{REF}}$ and $i_{f1}$, $i_{f2}$. In 65 and 22~nm, (e) $I_{REF}$ TC and (f) $W_1$ as a function of $S_2/S_1$, for both ACM- and lookup-table-based sizings.}
\label{fig:9_sizing_current_ref}
\end{figure}
It consists of five main steps:
\begin{enumerate}
\item Compute voltage $V_X$ using (\ref{eq:vx_beta_mult_final});
\item Solve (\ref{eq:vx_SCM_if1}) for $i_{f2}$, then calculate $i_{f1} = \alpha i_{f2}$, $S_{I_{REF}}$ from (\ref{eq:siref}), and $S_2$ from (\ref{eq:id_acm});
\item Solve (\ref{eq:vx_SCM_ir1}) for $\beta$, calculate $i_{r1} = \beta i_{f2}$ and $S_1$ from (\ref{eq:S1_over_S2_final});
\item Compute the aspect ratio of $M_{6-7}$ using (\ref{eq:id_acm});
\item Compute the aspect ratio of transistors $M_{3-5}$ and $M_{10}$ forming the current mirrors using (\ref{eq:id_acm}).
\end{enumerate}
The second way to perform the sizing replaces \mbox{steps b) -- c)} by a direct use of lookup tables. The gate voltage of $M_{1-2}$ is swept while keeping $V_X$ to the value fixed by a), thus providing sizes complying with the SCM structure. This second method is theoretically more accurate, as transistors are better described by lookup tables than by a limited set of parameters.\looseness=-1\\
\indent Let us now take a closer look at the results of the sizing algorithm, with Figs.~\ref{fig:9_sizing_current_ref}(a) to (d) presenting sizing results in 22~nm and Figs.~\ref{fig:9_sizing_current_ref}(e) and (f), results in both 65 and 22~nm. Fig.~\ref{fig:9_sizing_current_ref}(c) is obtained by fixing $K_{PTAT}$ to 6 and extracting a slice of the 3D surface in Fig.~\ref{fig:9_sizing_current_ref}(a). It reveals that the \mbox{70-ppm/$^\circ$C} TC found for $\alpha_{\mathrm{guess}}$~=~4.975 closely matches the location of the minimum TC obtained from pre-layout simulations for $\alpha_{\mathrm{sim}}$~=~5, but differs in terms of value with a slightly larger \mbox{119-ppm/$^\circ$C} TC. Moreover, Fig.~\ref{fig:9_sizing_current_ref}(d) indicates that, along the $I_{REF}$ TC valley, $S_{I_{REF}}$ remains stable around 5.62~$\%$/mV while $i_{f1}$, $i_{f2}$ decrease for larger values of $\alpha$, as $M_{1-2}$ are pushed closer to weak inversion. Then, Fig.~\ref{fig:9_sizing_current_ref}(e) depicts the TC of $I_{REF}$ computed from \mbox{pre-layout} simulations as a function of $S_2/S_1$, which is a proxy for $\alpha$ (\ref{eq:S1_over_S2_final}). In~65~nm, pre-layout simulation results faintly diverge, with the ACM-based sizing leading to a \mbox{191-ppm/$^\circ$C} TC at $S_2/S_1$~=~0.92, and the lookup-table-based one to a \mbox{202-ppm/$^\circ$C} TC at $S_2/S_1$~=~0.73. In addition, the ACM-based sizing tends to output a narrower transistor $M_1$ than its lookup-table-based counterpart [Fig.~\ref{fig:9_sizing_current_ref}(f)]. These discrepancies are presumably related to the approximated transistor behavior resulting from the estimation of ACM model parameters, as well as second order effects such as channel width modulation. In~22~nm, both sizing methods come up with a minimum at $S_2/S_1$~=~1.47, and Fig.~\ref{fig:9_sizing_current_ref}(f) confirms that the sizes output by both algorithms are in close agreement.
\vspace{-0.25cm}
\section{Optimization and Simulation Results}
\label{sec:4_optimization_and_simulation_results}
This section comes in two parts. First, Sections~\ref{subsec:4A_line_sensitivity_improvement} and \ref{subsec:4B_parasitic_diode_leakage_mitigation} introduce architectural optimizations to the proposed reference, by respectively discussing how to improve LS and how to limit the TC degradation due to parasitic diode leakage at high temperature. Next, Section~\ref{subsec:4C_final_implementation_performance} presents the schematic and post-layout simulation results of the proposed reference implemented in two common scaled technologies, i.e., TSMC 65-nm bulk and GF 22-nm FDSOI.
\vspace{-0.25cm}
\subsection{Line Sensitivity Improvement by Low-Voltage Cascoding}
\label{subsec:4A_line_sensitivity_improvement}
Low-voltage cascoding is often used in scaled technologies to improve LS without compromising the minimum supply voltage. An analytical approach allows to better grasp which transistors induce a dependence to supply voltage in the first place. The SCM in Fig.~\ref{fig:6_pmos_implementation_schematic} can be simplified by a resistor [Fig.~\ref{fig:10_low_voltage_cascode}(a)] with an equivalent behavior around the operation point, denoted as $Q$. For this pMOS implementation, the resistance is given by
\begin{equation}
r_{SCM} = \left.\frac{\partial \left(V_{DD}-V_X\right)}{\partial I_{REF}}\right|_Q = \frac{1}{I_{REF} S_{I_{REF}}}\textrm{.}\label{eq:rSCM}
\end{equation}
\noindent Relying on the small signal schematic in Fig.~\ref{fig:10_low_voltage_cascode}(b) and first considering the case without transistor $M_{6C}$, i.e., $v_y = v_{bn}$, the absolute LS of $V_X$ and the relative LS of $I_{REF}$ around $Q$ can be expressed as
\begin{IEEEeqnarray}{RCL}
\left.\frac{\partial \left(V_{DD}-V_X\right)}{\partial V_{DD}}\right|_Q & = & \frac{v_{dd}-v_x}{v_{dd}} = \frac{\frac{g_{d5}}{J} + g_{d6}}{g_{m6}}\textrm{,}\label{eq:LS_small_sig_vx_basic}\\
\frac{1}{I_{REF}} \left.\frac{\partial I_{REF}}{\partial V_{DD}}\right|_Q & = & \frac{1}{I_{REF}}\frac{i_{ref}}{v_{dd}} = S_{I_{REF}} \frac{v_{dd}-v_x}{v_{dd}}\textrm{,}\label{eq:LS_small_sig_iref}
\end{IEEEeqnarray}
under the common assumption that $g_m \gg g_d = 1/r_o$. Equation~(\ref{eq:LS_small_sig_vx_basic}) indicates that the dependence of $v_{dd}-v_x$ to $v_{dd}$ can be attributed to $M_{5-6}$'s output conductance. Next, $M_{6C}$ in Fig.~\ref{fig:10_low_voltage_cascode}(a) is used to cascode $M_6$, and is biased by voltage $V_{G8}$ originating from the body$\:$/$\:$back-gate bias generator [Fig.~\ref{fig:6_pmos_implementation_schematic}]. A complete low-voltage cascode as depicted in Fig.~\ref{fig:14_final_implementation_schematic}(b) can also be used, but does not bring any significant LS improvement as $M_7$ is in diode and already has negligible $V_{DS}$ variations. Based on Fig.~\ref{fig:10_low_voltage_cascode}(b) and assuming that $v_{g8} \simeq v_x$, the absolute LS of $V_X$ becomes
\begin{figure}[!t]
\centering
\includegraphics[width=.478\textwidth]{figure_10_low_voltage_cascode_v3.pdf}
\caption{(a) Schematic of the $\beta$-multiplier with low-voltage cascoding of $M_6$ through transistor $M_{6C}$. (b) Small signal schematic of (a).}
\label{fig:10_low_voltage_cascode}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_11_low_voltage_cascode_sim_v3.pdf}
\caption{Pre-layout simulations of (a) $V_{DD}-V_X$ and (b) $I_{REF}$ with respect to the supply voltage in the TT 25$^\circ$C corner, highlighting the improvement of LS achieved by cascoding $M_6$ in both 65- and \mbox{22-nm} technologies. The minimum supply voltage is 0.7~V in 65~nm and 0.9~V in 22~nm.}
\label{fig:11_low_voltage_cascode_sim}
\end{figure}
\begin{equation}
\frac{v_{dd}-v_x}{v_{dd}} = \frac{\frac{g_{d5}}{J}}{g_{m6} + \left(\frac{g_{d6}}{g_{m6c}}\right)r_{SCM}} \simeq \frac{\frac{g_{d5}}{J}}{g_{m6}}\textrm{,}\label{eq:LS_small_sig_vx_cascode}
\end{equation}
while the relative LS of $I_{REF}$ is still given by (\ref{eq:LS_small_sig_iref}). LS is reduced because $g_{d6}$ no longer appears in (\ref{eq:LS_small_sig_vx_cascode}), which is highly beneficial as $M_6$ is in weak inversion while $M_5$ is closer to moderate inversion, meaning that $M_6$ is shorter than $M_5$ and therefore has a larger output conductance. In addition, current mirrors are implemented using composite transistors, i.e., the series connection of devices sharing the same $V_G$ and $V_B$ \cite{Galup-Montoro_1994}, further reducing the output conductance.\\
\indent In 65~nm, simulations without cascoding exhibit an LS of $V_X$ and $I_{REF}$ [Fig.~\ref{fig:11_low_voltage_cascode_sim}] respectively worth 8.55~mV/V and 16.12~$\%$/V, computed from 0.7 to 1.2~V using the \textbf{box method}. Based on the small signal parameters extracted at the center of the supply voltage range, i.e., 0.95~V, (\ref{eq:LS_small_sig_vx_basic}) predicts an LS of $V_X$ of 7.81~mV/V which compares fairly well to the \mbox{8.25-mV/V} simulated value, computed with \textbf{first-order finite differences} around $Q$ rather than with the box method. Equation~(\ref{eq:LS_small_sig_iref}) links the LS of $I_{REF}$ to $v_{dd}-v_x/v_{dd}$, and yields a \mbox{21.33-$\%$/V} value diverging from the \mbox{15.75-$\%$/V} simulation, likely due to an overestimation of $S_{I_{REF}}$. With cascoding, the LS of $V_X$ and $I_{REF}$ improve to 1.27~mV/V and 0.62~$\%$/V. Besides, the \mbox{0.90-mV/V} LS of $V_X$ prediction agrees with the \mbox{1.25-mV/V} simulation. Similarly to the non-cascoded case, the \mbox{2.46-$\%$/V} prediction for the LS of $I_{REF}$ is exaggerated compared to the \mbox{0.83-$\%$/V} simulation.\\
\indent Simulations without cascoding in 22~nm yield a \mbox{0.56-mV/V} LS of $V_X$ and a \mbox{3.26-$\%$/V} LS of $I_{REF}$ from 0.9 to 1.8~V. The small signal approach estimates an LS of $V_X$ worth 0.35~mV/V around 1.35~V, which compares fairly well to the \mbox{0.33-mV/V} simulated value. A \mbox{1.96-$\%$/V} LS of $I_{REF}$ is predicted by (\ref{eq:LS_small_sig_iref}) and closely matches the \mbox{1.89-$\%$/V} simulation, thus confirming the correct evaluation of $S_{I_{REF}}$~=~5.85~$\%$/mV. Cascoding reduces LS to 0.04~mV/V and 0.26~$\%$/V for $V_X$ and $I_{REF}$. Moreover, predictions give a \mbox{0.04-mV/V} LS of $V_X$ which agrees with the 0.038-mV/V simulation, while the LS of $I_{REF}$ is accurately predicted to be 0.22~$\%$/V, which is close to the \mbox{0.23-$\%$/V} simulation as for the case without cascoding.\\
\indent To conclude, cascoding decisively diminishes $I_{REF}$ LS by a factor 26$\times$ in 65~nm (resp. 12.5$\times$ in 22~nm) and comes for free in the proposed reference as $V_{G8}$ is readily available from the body$\:$/$\:$back-gate bias generator.
\vspace{-0.25cm}
\subsection{Parasitic Diode Leakage Mitigation}
\label{subsec:4B_parasitic_diode_leakage_mitigation}
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_12_parasitic_nwell_psub_diode_v1.pdf}
\caption{$I_{REF}$ TC is degraded by the leakage of parasitic nwell/psub diodes. (a) Schematic of the SCM and body$\:$/$\:$back-gate bias generator with parasitic diodes. (b) Cross-section of pMOS devices in conventional bulk and standard-well FDSOI technologies. (c) Temperature dependence of $I_{REF}$ in TT 1.8~V, based on pre- and post-layout simulations in 22~nm. (d) Diode leakage as a function of temperature in 22~nm, for reverse voltages of 0.9 and 1.8~V.}
\label{fig:12_parasitic_nwell_psub_diode}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_13_vb6_buffering_v2.pdf}
\caption{Schematic of the body$\:$/$\:$back-gate bias generator (a) with a buffering stage implemented as an LDO, or (c) with a leakage suppression mechanism, obtained by implementing $M_6$ with a triple-well nMOS device whose deep nwell is biased by a body bias generator replica. (b) Temperature dependence of $I_{REF}$ in pre- and post-layout simulations, with a fine-tuning of the SCM sizes in TT 1.8~V. (d) Cross-section of triple-well nMOS devices.}
\label{fig:13_vb6_buffering}
\end{figure}
\begin{figure*}[!t]
\centering
\includegraphics[width=.9\textwidth]{figure_14_final_implementation_schematic_v3.pdf}
\caption{Complete schematic of the proposed nA-range CWT reference in (a) TSMC \mbox{65-nm} bulk and (b) GF \mbox{22-nm} FDSOI. The schematic includes a dynamic startup circuit similar to \cite{CamachoGaleano_2008}, a buffering stage of the body$\:$/$\:$back-gate voltage of $M_6$, and a low-voltage cascode. Note that the startup circuits are slightly different due to the presence of the buffering stage in 22~nm. In the \mbox{65-nm} design, $M_8$ and $M_{S2-S4}$ are implemented with core HVT pMOS devices, while in the \mbox{22-nm} one, $M_8$ is implemented with an I/O ULL pMOS devices.}
\label{fig:14_final_implementation_schematic}
\end{figure*}
\begin{figure}[!t]
\centering
\includegraphics[width=.422\textwidth]{figure_15_layout_v3.pdf}
\caption{Layout of the reference in (a) \mbox{65-nm} bulk and (b) \mbox{22-nm} FDSOI.}
\label{fig:15_layout}
\end{figure}
In the case of a pMOS-based SCM [Fig.~\ref{fig:12_parasitic_nwell_psub_diode}(a)] and at high temperature, $I_{REF}$ TC is degraded by leakage currents flowing from $V_X$ and $V_{B6}$ to ground through parasitic nwell/psub diodes. The origin of these diodes is illustrated by the cross-section of pMOS devices in Fig.~\ref{fig:12_parasitic_nwell_psub_diode}(b). This issue does not occur in 65~nm due to the lower reverse voltage applied to the diodes and the limited nwell area required by $M_{6-6C-9}$, as smaller devices can be used because of the low $S_{I_{REF}}$. Therefore, we only discuss the \mbox{22-nm} design in what follows. Next, Fig.~\ref{fig:12_parasitic_nwell_psub_diode}(c) shows that in 22~nm, the pre-layout simulation in TT 1.8~V features a \mbox{125-ppm/$^\circ$C} TC, while post-layout simulations with either diode $D_{VX}$ or both diodes $D_{VX}$ and $D_{VB6}$ result in a degraded $I_{REF}$ TC of 244 and 370~ppm/$^\circ$C, respectively. This degradation arises from the exponential increase of diode leakage with temperature [Fig.~\ref{fig:12_parasitic_nwell_psub_diode}(d)], causing a deviation from the pre-layout behavior above 50$^\circ$C. $D_{VB6}$'s leakage attains 21 to 33.8~pA at 85$^\circ$C and mostly has an indirect impact on $I_{REF}$ by inducing a change in $V_{B6}$, passed on $I_{REF}$ through $\Delta V_T$. Furthermore, $D_{VX}$'s leakage at 85$^\circ$C lies between 7.8 and 12.5~pA and has a direct impact on $I_{REF}$ by drawing some current away from the SCM and $\beta$-multiplier. However, it should be noted that this impact can be alleviated by connecting the body of $M_2$ to $V_{DD}$ while accounting for this change in the sizing of the SCM.\\
\indent In Fig.~\ref{fig:13_vb6_buffering}, two solutions are proposed to combat the adverse effect of parasitic diode leakage. First, a low-dropout (LDO) regulator copes with $D_{VB6}$'s leakage by buffering node $V_{B6,\mathrm{in}}$ [Fig.~\ref{fig:13_vb6_buffering}(a)]. It consists of four main components: (i) a self-biased 4T operational transconductance amplifier (OTA) with an nMOS differential pair, (ii) a regulation pMOS $M_{P3}$ delivering the leakage current of $D_{VB6}$, (iii) a capacitor $C_{B6}$ ensuring the stability of the LDO, and (iv) a Miller capacitor $C_F$ ensuring the stability of the whole reference by adding a dominant pole $f_{pd} = (g_{m8}+g_{d8})/(2\pi C_F A_{v,OTA})$ at node $V_{B6,\mathrm{in}}$, with $A_{v,OTA}$ the differential voltage gain of the OTA in DC conditions. Fig.~\ref{fig:13_vb6_buffering}(b) reveals that a \mbox{117-ppm/$^\circ$C} $I_{REF}$ TC is obtained pre-layout with this additional buffering stage. With a fine-tuning of the SCM sizes to alleviate the impact of $D_{VX}$'s residual leakage, an increase of the TC to 184~ppm/$^\circ$C is observed post-layout, albeit the degradation is lessened compared to the 370~ppm/$^\circ$C without buffering. At last, the buffering stage entails power and area overheads corresponding to 14.3~$\%$ (0.83~nW) and 14.7~$\%$ (1940~$\mu$m$^2$) of the total power and area usage.\\
\indent Second, in the case of an nMOS-based SCM, leakage suppression could be achieved by biasing the deep nwell with a voltage $V_{DNW} \simeq V_{B6}$. This technique is inspired from ultra-low-power voltage references \cite{Fassio_2021}, and forces a voltage drop close to zero across the parasitic pwell/deep-nwell diode $D_{VB6}$ [Fig.~\ref{fig:13_vb6_buffering}(c)], thus suppressing the leakage from $V_{B6}$. Voltage $V_{DNW}$ is easily generated by a replica of the low-power voltage reference which provides the leakage of $D_{DNW}$. The origin of diodes $D_{VB6}$ and $D_{DNW}$ is illustrated by the cross-section of triple-well devices in Fig.~\ref{fig:13_vb6_buffering}(d).
\vspace{-0.25cm}
\subsection{Final Implementation Performance}
\label{subsec:4C_final_implementation_performance}
The complete schematic of the proposed reference is disclosed in Fig.~\ref{fig:14_final_implementation_schematic} for the 65- and \mbox{22-nm} designs, and features three additions compared to Fig.~\ref{fig:6_pmos_implementation_schematic}. Firstly, a dynamic startup circuit \cite{CamachoGaleano_2005, CamachoGaleano_2008}, to make sure the reference is not stuck around its zero-$I_{REF}$ stable operation point. For applications relying on a low-slew-rate supply voltage, a suitable startup circuit can be obtained by replacing $C_S$ by a diode-connected pMOS or by relying on the conventional circuit in \cite{Liu_1998}, at the cost of an increased power consumption. Second, a buffering stage for $V_{B6}$ in 22~nm. Lastly, a low-voltage cascode to improve LS, which is either implemented with a single transistor in 65~nm, or in full in 22~nm. Our analysis in Section~\ref{subsec:4A_line_sensitivity_improvement} nevertheless suggests that the \mbox{22-nm} cascode could be simplified to a single transistor without loss of performance. Furthermore, a pMOS-based SCM has been selected to avoid the minor area penalty and slightly more complex body$\:$/$\:$back-gate connections entailed by the use of triple-well devices, albeit a design relying on an nMOS-based SCM is totally feasible. Then, the layout is presented in Fig.~\ref{fig:15_layout}, and transistor sizes are summarized in Table~\ref{table:final_implementation_sizes}, with core (resp. I/O) LVT devices used by default in 65~nm (resp. 22~nm). Most transistors present relatively small aspect ratios, as they are biased with a current in the nA range lower than their specific sheet current $I_{SQ}$ and, for some of them, are operated in moderate inversion, thus reducing their aspect ratio even further. This effect is more pronounced in the \mbox{65-nm} design because the body$\:$/$\:$back-gate bias generator produces a \mbox{28-mV} $\Delta V_T$, as opposed to 17~mV in 22~nm, which pushes $M_{1-2}$ closer to strong inversion.\\
\indent Next, we discuss the performance of the proposed reference. First, Fig.~\ref{fig:16_sim_iref_vs_vdd} illustrates the dependence to supply voltage, with the minimum supply voltage given by
\begin{IEEEeqnarray}{RCL}
V_{DD,\mathrm{min}} & = & V_{DS,\mathrm{sat}} + \max\big(V_{SG1}, V_{SG8} + V_{SG1} - V_{SG2},\IEEEnonumber\\
& & V_{GS4} + V_{SD6C,\mathrm{sat}} + V_{SG1} - V_{SG2}, V_{SG7}\big)\label{eq:vdd_min}\textrm{,}
\end{IEEEeqnarray}
in which each expression inside the max function corresponds to one of the branches of the schematic in Fig.~\ref{fig:14_final_implementation_schematic}(a). Second, Fig.~\ref{fig:17_sim_iref_vs_T} displays the temperature dependence of $V_X$ and $I_{REF}$. Third, Fig.~\ref{fig:18_sim_iref_vs_T_mc} studies the variability of $I_{REF}$ and its TC for 10$^3$ Monte-Carlo (MC) simulations. Note that $I_{REF}$ variability can be estimated from $\sigma_{V_X}$ at first order using
\begin{table}[!t]
\centering
\caption{Sizing of the proposed nA-range CWT reference.}
\label{table:final_implementation_sizes}
\begin{scriptsize}
\begin{tabular}{lcccccc}
\toprule
& \multicolumn{3}{c}{TSMC \mbox{65-nm} bulk} & \multicolumn{3}{c}{GF \mbox{22-nm} FDSOI}\\
\cmidrule(l){2-4} \cmidrule(l){5-7}
& $W$ [$\mu$m] & $L$ [$\mu$m] & $i_f$ & $W$ [$\mu$m] & $L$ [$\mu$m] & $i_f$\\
\midrule
$M_1$ & 0.365 & 20$\times$10 & 52.46 & 2.39 & 20$\times$8 & 5.17\\
$M_2$ & 0.3 & 20$\times$10 & 22.09 & 2.74 & 16$\times$8 & 1.10\\
$M_3$ & 3$\times$0.35 & 5$\times$10 & 0.69 & 1 & 5$\times$8 & 0.25\\
$M_4$ & 0.35 & 5$\times$10 & 0.69 & 1 & 5$\times$8 & 0.25\\
$M_5$ & 2$\times$0.35 & 5$\times$10 & 0.69 & 3$\times$1 & 5$\times$8 & 0.25\\
$M_6$ & 4$\times$1 & 10 & 0.03 & 20$\times$5 & 2$\times$8 & 0.003\\
$M_7$ & 1 & 10 & 0.03 & 10$\times$5 & 2$\times$8 & 0.003\\
$M_{6C}$ & 0.22 & 10 & - & 8$\times$5 & 4 & -\\
$M_{7C}$ & - & - & - & 24$\times$5 & 4 & -\\
$M_8$ & 2$\times$2.34 & 4$\times$5 & - & 4$\times$5 & 8 & -\\
$M_9$ & 2$\times$0.22 & 4$\times$5 & - & 4$\times$4 & 8 & -\\
$M_{10}$ & 0.35 & 5$\times$10 & 0.69 & 1 & 5$\times$8 & 0.25\\
$M_{S1}$ & 0.35 & 5$\times$10 & 0.69 & 0.16 & 5$\times$8 & 0.25\\
$M_{S2-S4}$ & 0.2 & 20 & - & 4 & 8 & -\\
$C_{S}$ & 2.5 & 2 & - & 12.5 & 5 & -\\
\bottomrule
\end{tabular}
\end{scriptsize}
\end{table}
\begin{figure}[!t]
\centering
\includegraphics[width=.425\textwidth]{figure_16_sim_iref_vs_vdd_v4.pdf}
\caption{Post-layout simulations of the supply voltage dependence of $V_X$ and $I_{REF}$ in all process corners and at 25$^\circ$C, in \mbox{65-nm} bulk [(a) and (b)] and in \mbox{22-nm} FDSOI [(c) and (d)].}
\label{fig:16_sim_iref_vs_vdd}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=.425\textwidth]{figure_17_sim_iref_vs_T_v5.pdf}
\caption{Post-layout simulations of the temperature dependence of $V_X$ and $I_{REF}$ in all process corners, at 1.2~V in \mbox{65-nm} bulk [(a) and (b)] and at 1.8~V in \mbox{22-nm} FDSOI [(c) and (d)].}
\label{fig:17_sim_iref_vs_T}
\end{figure}
\begin{equation}
\left(\sigma/\mu\right)_{I_{REF}} = S_{I_{REF}} \sigma_{V_X}\label{eq:var_iref}\textrm{.}
\end{equation}
Finally, Fig.~\ref{fig:19_sim_iref_startup} depicts the startup waveforms in nominal and extreme corners for a \mbox{100-$\mu$s} \mbox{rise-time} voltage source.\\
\indent In 65~nm, the layout [Fig.~\ref{fig:15_layout}(a)] is dominated by the SCM which occupies 23.8~$\%$ of the \mbox{0.0021-mm$^2$} area, followed by the current mirrors with 22.8~$\%$. In TT, the LS of $V_X$ is equal to 1.28~mV/V from 0.7 to 1.2~V [Fig.~\ref{fig:16_sim_iref_vs_vdd}(a)] and yields a 0.69-$\%$V LS of $I_{REF}$ [Fig.~\ref{fig:16_sim_iref_vs_vdd}(b)]. Process variations have negligible impact on the LS but change $I_{REF}$ by +19.09~$\%$ in FF and -7.20~$\%$ in SF. Fig.~\ref{fig:17_sim_iref_vs_T}(a) highlights the slightly different TC of $V_X$ due to process variations of the subthreshold slope factor. These differences result in $I_{REF}$ TC discrepancies, with a typical and worst-case values of 208 and 393~ppm/$^\circ$C. Regarding variability, only mismatch can be simulated in 65~nm as no statistical models for global process variations are available in the process design kit (PDK) used in this work. Fig.~\ref{fig:18_sim_iref_vs_T_mc}(a) exhibits a \mbox{2.92-$\%$} ($\sigma/\mu$) lower than the 3.74~$\%$ inferred from (\ref{eq:var_iref}) and the \mbox{1.37-mV} $\sigma_{V_X}$, concurring with the hypothesis of an $S_{I_{REF}}$ overestimation. Regarding TC, its median and 99$^\mathrm{th}$ percentile are 213 and 431~ppm/$^\circ$C [Figs.~\ref{fig:18_sim_iref_vs_T_mc}(b) and (c)]. Finally, the typical and worst-case startup times $t_s$ are 3.4 and 29.2~ms [Fig.~\ref{fig:19_sim_iref_startup}(a)].\\
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_18_sim_iref_vs_T_mc_v3.pdf}
\caption{For 10$^3$ post-layout MC simulations in TT, histograms of $I_{REF}$ at 25$^\circ$C, and $I_{REF}$ TC from \mbox{-40} to 85$^\circ$C, at 1.2~V in \mbox{65-nm} bulk [(a) to (c)] and 1.8~V in \mbox{22-nm} FDSOI [(d) to (f)]. (d) to (f) correspond to simulations of local mismatch, global process variations, and their combined effects.}
\label{fig:18_sim_iref_vs_T_mc}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=.4\textwidth]{figure_19_sim_iref_startup_v4.pdf}
\caption{Post-layout startup waveforms in the fastest (FF 85$^\circ$C), typical (TT 25$^\circ$C), and slowest (SS \mbox{-40$^\circ$C}) corners, (a) at 1.2~V in \mbox{65-nm} bulk and (b) 1.8~V in \mbox{22-nm} FDSOI in the three process and temperature corners, using a voltage source with a rise time of 100~$\mu$s.}
\label{fig:19_sim_iref_startup}
\end{figure}
\indent In 22~nm, the layout [Fig.~\ref{fig:15_layout}(b)] is dominated by $M_{6-7}$, which need to be large to minimize $\sigma_{V_X}$ and thus account for 28.7~$\%$ of the \mbox{0.0132-mm$^2$} area. Then, regarding supply voltage dependence, the slender process variations impacting $V_X$ [Fig.~\ref{fig:16_sim_iref_vs_vdd}(c)] stem from $V_{B6}$ through $\Delta V_T$. However, $I_{REF}$ is mainly impacted by $I_{SQ}$ variations [Fig.~\ref{fig:16_sim_iref_vs_vdd}(d)], and changes by at most +9.85~$\%$ in SF and -9.51~$\%$ in FS. From 0.9 to 1.8~V, the LS of $V_X$ is worth 50~$\mu$V/V in TT, and translates to a \mbox{0.26-$\%$/V} LS of $I_{REF}$. Furthermore, LS is relatively constant across process corners except in FS, for which the \mbox{0.68-$\%$/V} value can be explained by the distortion close to 0.9~V. It requires a higher $V_{DD}$ to cope with the increased pMOS $V_T$. Then, $V_X$ has the same TC across process corners [Fig.~\ref{fig:17_sim_iref_vs_T}(c)], leading to similar $I_{REF}$ TCs in Fig.~\ref{fig:17_sim_iref_vs_T}(d). The typical and worst-case TCs are 184 and 230~ppm/$^\circ$C, the latter being partially explained by the lower $I_{REF}$ value in this process corner, as $I_{REF}$ TC is a relative metric. As far as variability is concerned, in 22~nm, we can simulate the impact of mismatch, process variations, and their combined effects. On the one hand, mismatch has a strong impact on $I_{REF}$ ($\sigma/\mu$) due to the large $S_{I_{REF}}$. The simulated \mbox{0.87-mV} $\sigma_{V_X}$ leads to a \mbox{4.92-$\%$} ($\sigma/\mu$) prediction, which falls short of the \mbox{6.39-$\%$} simulation [Fig.~\ref{fig:18_sim_iref_vs_T_mc}(d)] due to additional mismatch in the SCM and the mirrors. Besides, TC variability is relatively limited, with a 203- and \mbox{299-ppm/$^\circ$C} median and 99$^\mathrm{th}$ percentile [Figs.~\ref{fig:18_sim_iref_vs_T_mc}(e) and (f)]. On the other hand, process variations have a restricted impact on $I_{REF}$, with a \mbox{2.18-$\%$} ($\sigma/\mu$), but deteriorate $I_{REF}$ TC, with a 99$^\mathrm{th}$ percentile shifted to 887~ppm/$^\circ$C due to a malfunction of the buffer for extreme process realizations causing $I_{REF}$ to drop at high temperature. Unsurprisingly, the combined effects yield a \mbox{6.66-$\%$} ($\sigma/\mu$) for $I_{REF}$, together with a 227- and \mbox{972-ppm/$^\circ$C} median and 99$^\mathrm{th}$ percentile for $I_{REF}$ TC. Lastly, the typical and worst-case $t_s$ are 456~ms and 8.3~s [Fig.~\ref{fig:19_sim_iref_startup}(b)], because of the parasitic caps of large transistors. While the worst-case \mbox{8.3-s} $t_s$ could be critical, most applications require the reference to operate down to \mbox{-40$^\circ$C} but not to start in the extreme SS \mbox{-40$^\circ$C} corner, as nA-range current references are often always-on circuits. Nevertheless, this issue can be solved by widening $M_{S2-S3}$ in Fig.~\ref{fig:14_final_implementation_schematic}(b), at the expense of a TC degradation in FF 85$^\circ$C.
\begin{figure}[!t]
\centering
\includegraphics[width=.469\textwidth]{figure_20_meas_setup_v2.pdf}
\caption{(a) Chip microphotograph in GF \mbox{22-nm} FDSOI, with the proposed reference highlighted in white. (b) Conceptual and (c) actual measurement testbench for supply voltage and temperature dependence characterization.}
\label{fig:20_meas_setup}
\end{figure}
\vspace{-0.25cm}
\section{Measurement Results}
\label{sec:5_measurement_results}
In this section, we describe the testbench used to characterize the proposed current reference, fabricated in GF 22-nm FDSOI as part of a \mbox{1.56-mm$^2$} microcontroller unit for biomedical applications codenamed ICare [Fig.~\ref{fig:20_meas_setup}(a)]. Then, we present the LS and TC measurements across the 20 dies in Figs.~\ref{fig:21_meas_iref_vs_vdd} and \ref{fig:22_meas_iref_vs_T}, before discussing the discrepancies with respect to post-layout simulations based on Figs.~\ref{fig:23_sim_meas_iref_cross_process} and \ref{fig:24_sim_meas_iref_vs_T}.
\vspace{-0.25cm}
\subsection{Measurement Testbench}
Conceptual and actual views of the testbench are shown in Figs.~\ref{fig:20_meas_setup}(b) and (c). Supply voltage dependence is characterized using a two-channel Keithley K2636A source measurement unit (SMU), providing the supply voltage to the reference on channel A, and a \mbox{0.9-V} $V_{DS}$ to the output nMOS transistor on channel B. The supply current $I_{VDD}$ and the output current, equal to $8\times I_{REF}$, are measured by the K2636A, while a K2400 supplies the I/O voltage [Fig.~\ref{fig:20_meas_setup}(c)]. Supply voltage is then swept from 0 to 1.8~V in \mbox{25-mV} steps. Then, temperature dependence is characterized using an Espec SH-261 climatic chamber which sweeps temperature from \mbox{-40} to 85$^\circ$C in 5$^\circ$C steps. Both equipments are connected in GPIB to a PC running a testing routine in LabWindows. Lastly, LS and TC are computed across the 20 dies according to (\ref{eq:LS}) and (\ref{eq:TC}).
\begin{figure}[!t]
\centering
\includegraphics[width=.4\textwidth]{figure_21_meas_iref_vs_vdd_v1.pdf}
\caption{(a) Post-layout-simulated and measured average $I_{REF}$, with (b) details of the 20 dies. Measured histograms of (c) $I_{REF}$ at 1.8~V and (d) LS from 0.9 to 1.8~V. All figures are obtained at a temperature of 25$^\circ$C.}
\label{fig:21_meas_iref_vs_vdd}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_22_meas_iref_vs_T_v1.pdf}
\caption{(a) Post-layout-simulated and measured temperature dependence of the average $I_{REF}$ and $I_{VDD}$. Measured temperature dependence of $I_{REF}$ (b) without and (c) with normalization by the value at 25$^\circ$C, for the 20 dies. (d) Measured histogram of $I_{REF}$ TC from \mbox{-40} to 85$^\circ$C. All figures are obtained for a supply voltage of 1.8~V.}
\label{fig:22_meas_iref_vs_T}
\end{figure}
\vspace{-0.25cm}
\subsection{Supply Voltage and Temperature Dependence}
Firstly, Fig.~\ref{fig:21_meas_iref_vs_vdd} quantifies the LS and variability of $I_{REF}$ obtained in measurement at 25$^\circ$C. Fig.~\ref{fig:21_meas_iref_vs_vdd}(a) describes the supply voltage dependence of $I_{REF}$ for post-layout simulations in TT and for the measurements average. The measured $V_{DD,\mathrm{min}}$ remains about 0.9~V as expected from simulation, but $I_{REF}$ shrinks from 1.25 to 0.9~nA. This difference cannot be explained by the mismatch of the mirror between $I_{REF}$ and the output current, as the current ratio has a limited \mbox{1.5-$\%$} ($\sigma/\mu$) evaluated from 10$^3$ MC simulations. As hypothesized in \cite{Lefebvre_2022_ESSCIRC} and confirmed in this work, this reduction is linked to global process variations and more specifically to skewed process corners of the ULL and LVT I/O devices $M_8$ and $M_9$ constituting the body$\:$/$\:$back-gate generator, as illustrated in Figs.~\ref{fig:23_sim_meas_iref_cross_process}(a) and \ref{fig:24_sim_meas_iref_vs_T}(a). Details of the 20 dies are depicted in Fig.~\ref{fig:21_meas_iref_vs_vdd}(b), and histograms of $I_{REF}$ at 1.8~V and LS from 0.9 to 1.8~V are respectively presented in Figs.~\ref{fig:21_meas_iref_vs_vdd}(c) and (d). Fig.~\ref{fig:21_meas_iref_vs_vdd}(c) features a \mbox{9.20-$\%$} ($\sigma/\mu$) larger than the \mbox{6.66-$\%$} value obtained in Section~\ref{subsec:4C_final_implementation_performance}, which takes both mismatch and statistical process variations into account. Assuming the mean has been perfectly estimated, the \mbox{99-$\%$} confidence interval (CI) for the variance gives a CI for ($\sigma/\mu$) equal to [7.3~$\%$;$\:$15.3~$\%$], meaning that the limited sample size cannot explain the ($\sigma/\mu$) discrepancy. The lower $I_{REF}$ and higher ($\sigma/\mu$) are rather explained by a CWT offset $\Delta V_T$ lower than its nominal value [Figs.~\ref{fig:23_sim_meas_iref_cross_process}(a) and (c)], the larger variability being linked to an increased sensitivity $S_{I_{REF}}$ as $M_{1-2}$'s inversion level is reduced. Finally, Fig.~\ref{fig:21_meas_iref_vs_vdd}(d) reveals that the measured LS is around 0.39~$\%$/V, which is close to the 0.26~$\%$/V obtained in post-layout simulation.\\
\indent Furthermore, Fig.~\ref{fig:22_meas_iref_vs_T} gauges the temperature dependence of $I_{VDD}$ and $I_{REF}$ at 1.8~V. Fig.~\ref{fig:22_meas_iref_vs_T}(a) highlights the second order behavior of $I_{REF}$ in simulation and measurement, as well as a slighly PTAT trend observed in measurement only. $I_{VDD}$ amounts to 8.8~nA in simulation (resp. 6.4~nA in measurement), leading to a \mbox{7.8-nW} (resp. \mbox{5.8-nW}) power consumption at 0.9~V. Details of the 20 dies are portrayed in absolute value in Fig.~\ref{fig:22_meas_iref_vs_T}(b), and normalized by the value of $I_{REF}$ at 25$^\circ$C in Fig.~\ref{fig:22_meas_iref_vs_T}(c). The measured TC is comprised between 440 and 760~ppm/$^\circ$C, with an average of 565~ppm/$^\circ$C [Fig.~\ref{fig:22_meas_iref_vs_T}(d)]. Skewed process variations of ULL and LVT I/O devices reliably explain the TC deterioration, as a decreased (resp. increased) $\Delta V_T$ compared to its nominal value results in a slightly PTAT (resp. CTAT) behavior [Figs.~\ref{fig:23_sim_meas_iref_cross_process}(b) and (c)]. Besides, Fig.~\ref{fig:24_sim_meas_iref_vs_T} depicts the process corners showing the closest agreement with the measurements in terms of $I_{REF}$ and TC, with TCs of 446 and 557~ppm/$^\circ$C observed in the (TT, SF, typ.) and (FS, TT, typ.) process corners, respectively [Fig.~\ref{fig:24_sim_meas_iref_vs_T}(a)]. These results much better coincide with the measured \mbox{565-ppm/$^\circ$C} TC than the nominal corner [Fig.~\ref{fig:24_sim_meas_iref_vs_T}(b)]. Finally, Fig.~\ref{fig:24_sim_meas_iref_vs_T} suggests that the measurements are better explained by a minimum process for the parasitic nwell/psub diode $D_{VX}$ than by a typical process.
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_23_sim_meas_iref_cross_process_v1.pdf}
\caption{Skewed process corners of ULL and LVT I/O devices have an impact on (a) $I_{REF}$ at 25$^\circ$C and (b) $I_{REF}$ TC from -40 to 85$^\circ$C, due to (c) changes in the CWT offset $\Delta V_{T}$ with respect to its nominal value. All results are obtained for a supply voltage of 1.8~V and a typical process for parasitic nwell/psub diodes.}
\label{fig:23_sim_meas_iref_cross_process}
\end{figure}
\setlength{\tabcolsep}{2pt}
\begin{table*}[!t]
\centering
\caption{Comparison table of temperature-independent nA-range current references.}
\vspace{-0.1cm}
\label{table:soa_nanoamp_range}
\resizebox{\linewidth}{!}{%
\begin{threeparttable}
\begin{scriptsize}
\begin{tabular}[t]{lcccccccccccccccc}
\toprule
& Huang & Far & Kim & Cordova & Santamaria & Aminzadeh & Kayahan & Dong & Ji & Wang & Wang & Huang & Lee & \multicolumn{3}{c}{\textbf{Lefebvre}}\\
& \cite{Huang_2010} & \cite{Far_2015} & \cite{Kim_2016} & \cite{Cordova_2017} & \cite{Santamaria_2019} & \cite{Aminzadeh_2022} & \cite{Kayahan_2013} & \cite{Dong_2017} & \cite{Ji_2017} & \cite{Wang_2019_VLSI} & \cite{Wang_2019_TCAS} & \cite{Huang_2020} & \cite{Lee_2020} & \multicolumn{3}{c}{\textbf{This work}}\\
\midrule
Publication & ISCAS & ROPEC & ISCAS & ISCAS & ISCAS & AEU & TCAS-I & ESSCIRC & ISSCC & VLSI-DAT & TCAS-I & TCAS-II & JSSC & \multicolumn{3}{c}{JSSC}\\
Year & 2010 & 2015 & 2016 & 2017 & 2019 & 2022 & 2013 & 2017 & 2017 & 2019 & 2019 & 2020 & 2020 & \multicolumn{3}{c}{2022}\\
\cmidrule(l){15-17}
Type of work & Sim. & Sim. & Sim. & Sim. & Sim. & Sim. & Silicon & Silicon & Silicon & Silicon & Silicon & Silicon & Silicon & Sim. & Sim. & Silicon\\
Number of samples & N/A & N/A & N/A & N/A & N/A & N/A & 90 & 32\tnote{$\ast$} & 10 & 10 & 16 & 10 & 10 & N/A & N/A & 20\\
\midrule
Technology & 0.18$\mu$m & 0.18$\mu$m & 0.13$\mu$m & 0.18$\mu$m & 0.18$\mu$m & 0.18$\mu$m & 0.35$\mu$m & 0.18$\mu$m & 0.18$\mu$m & 0.18$\mu$m & 0.18$\mu$m & 0.18$\mu$m & 0.18$\mu$m & 65nm & \multicolumn{2}{c}{22nm FDSOI}\\
$I_{REF}$ [nA] & 2.05 & 14 & 27 & 10.86 & 2.66 & 6.7 & 25 & 35.02 & 6.64 & 6.46 & 9.77 & 11.6 & 1 & 1.10 & 1.25 & 0.9\\
Power [nW] & 5.1 & 150 & N/A & 30.5 & 26 & 51 & 28500 & 1.02 & 9.3 & 15.8 & 28 & 48.64 & 4.5/14\tnote{$\triangleright$} & 5.41 & 7.84 & 5.81\\
& $@$0.85V & $@$1V & & $@$0.9V & $@$2V & $@$1.1V & $@$5V & $@$1.5V & $@$N/A & $@$0.85V & $@$0.7V & $@$0.8V & $@$1.5V & $@$0.7V & \multicolumn{2}{c}{$@$0.9V}\\
Area [mm$^2$] & N/A & \textcolor{ECS-Blue}{\textbf{0.0102}} & N/A & \textcolor{ECS-Blue}{\textbf{0.01}} & \textcolor{ECS-Blue}{\textbf{0.0093}} &\textcolor{ECS-Red}{\textbf{0.46}} & \textcolor{ECS-Blue}{\textbf{0.0053}} & 0.0169 & \textcolor{ECS-Red}{\textbf{0.055}} & \textcolor{ECS-Red}{\textbf{0.062}} & \textcolor{ECS-Red}{\textbf{0.055}} & \textcolor{ECS-Red}{\textbf{0.054}} & \textcolor{ECS-Red}{\textbf{0.332}} & \textcolor{ECS-Blue}{\textbf{0.0021}} & \multicolumn{2}{c}{\textcolor{ECS-Blue}{\textbf{0.0132}}}\\
\midrule
Supply range [V] & 0.85 -- 2.2 & 1 -- 3.3 & 1.2 & 0.9 -- 1.8 & 2 -- 3.3\tnote{$\diamond$} & 1.1 -- 1.8 & 5 & 1.5 -- 2.5 & 1.3 -- 1.8 & 0.85 -- 2 & 0.7 -- 1.2 & 0.8 -- 2 & 1.5 -- 2 & 0.7 -- 1.2 & \multicolumn{2}{c}{0.9 -- 1.8}\\
LS [$\%$/V] & 1.35 & \textcolor{ECS-Blue}{\textbf{0.1}} & N/A & \textcolor{ECS-Blue}{\textbf{0.54}} & \textcolor{ECS-Red}{\textbf{11}}\tnote{$\diamond$} &\textcolor{ECS-Blue}{\textbf{0.03}} & \textcolor{ECS-Red}{\textbf{150}} & 3 & 1.16 & 4.15 & \textcolor{ECS-Blue}{\textbf{0.6}} & 1.08 & 1.4 & \textcolor{ECS-Blue}{\textbf{0.69}} & \textcolor{ECS-Blue}{\textbf{0.26}} & \textcolor{ECS-Blue}{\textbf{0.39}}\tnote{$\triangleleft$}\\
\midrule
Temperature range [$^\circ$C] & 0 -- 150 & 0 -- 70 & -30 -- 150 & -20 -- 120 & -40 -- 125 & -40 -- 120 & 0 -- 80 & -40 -- 120 & 0 -- 110 & -10 -- 100 & -40 -- 125 & -40 -- 120 & -20 -- 80 & -40 -- 85 & \multicolumn{2}{c}{-40 -- 85}\\
TC [ppm/$^\circ$C] & \textcolor{ECS-Blue}{\textbf{91}} & \textcolor{ECS-Blue}{\textbf{20}} & 327 & \textcolor{ECS-Blue}{\textbf{108}} & \textcolor{ECS-Blue}{\textbf{182}} & \textcolor{ECS-Blue}{\textbf{40.33}} & \textcolor{ECS-Blue}{\textbf{128}}/250\tnote{$\star$} & 282 & 680/283\tnote{$\dagger$} & \textcolor{ECS-Blue}{\textbf{138}}\tnote{$\ddagger$} & \textcolor{ECS-Blue}{\textbf{149.8}} & \textcolor{ECS-Blue}{\textbf{169}} & 289/265\tnote{$\triangleright$} & \textcolor{ECS-Blue}{\textbf{213}} & \textcolor{ECS-Blue}{\textbf{203}} & 565\tnote{$\triangleleft$}\\
\midrule
$I_{REF}$ var. (process) [$\%$] & 7.5 & N/A & 3.7 & 15.8/11.6\tnote{$\dagger$} & N/A & N/A & 8/1.22\tnote{$\star$} & 4.7 & N/A & N/A & +11.7/-8.7\tnote{$\diamond$} & +17.6/-10.3\tnote{$\triangleleft$} & N/A & +19.1/-7.2 & +9.9/-9.5 & N/A\\
$I_{REF}$ var. (mismatch) [$\%$] & N/A & \textcolor{ECS-Red}{\textbf{5.8}} & N/A & N/A & \textcolor{ECS-Red}{\textbf{20.30}} & \textcolor{ECS-Blue}{\textbf{0.70}} & \textcolor{ECS-Blue}{\textbf{1.4}} (sim.) & \textcolor{ECS-Blue}{\textbf{1.6}} & 4.07/\textcolor{ECS-Blue}{\textbf{1.19}}\tnote{$\star$} & 3.33 & \textcolor{ECS-Blue}{\textbf{1.6}} & 4.3 & \textcolor{ECS-Blue}{\textbf{1.26}}/\textcolor{ECS-Blue}{\textbf{0.25}}\tnote{$\dagger$} & 2.92 & \textcolor{ECS-Red}{\textbf{6.39}} & \textcolor{ECS-Red}{\textbf{9.20}}\\
\midrule
Trimming & No & No & No & Yes$\:$(6b) & No & No & No & No & Yes & No & Yes$\:$(5b) & Yes$\:$(6b) & Yes$\:$(27b) & No & No & No\\
Special components & No & No & Res. & \textcolor{ECS-Red}{\textbf{ZVT}} & No & Res., \textcolor{ECS-Red}{\textbf{BJT}} & No & Res., \textcolor{ECS-Red}{\textbf{BJT}} & No & Res. & Res., & Res. & No & No & No & No\\
\bottomrule
\end{tabular}
\end{scriptsize}
\begin{footnotesize}
\begin{tablenotes}
\item[$\ast$] 16 dies for the TT process corner and 4 dies for each of the FF, SS, SF and FS process corners.
\item[$\star$] Simulated and measured values.
\item[$\dagger$] Before and after trimming.
\item[$\ddagger$] Best TC, the average one is not reported.
\item[$\diamond$] Estimated from figures.
\item[$\triangleleft$] Mean measured value across the 20 dies.
\item[$\triangleright$] For 25 and 2.5 minutes between two calibrations.
\end{tablenotes}
\end{footnotesize}
\end{threeparttable}%
}
\end{table*}
\vspace{-0.25cm}
\section{Comparison to the State of the Art}
\label{sec:6_comparison_to_the_state_of_the_art}
This section compares our work to the state of the art of current references through some important trade-offs, illustrated in Fig.~\ref{fig:25_comparison_to_soa}, and focuses on nA-range CWT references in Table~\ref{table:soa_nanoamp_range}. We report post-layout simulation results in \mbox{65-nm} bulk and \mbox{22-nm} FDSOI, and measurement results in \mbox{22-nm} FDSOI, coresponding to the three orange markers in Fig.~\ref{fig:25_comparison_to_soa}. Firstly, the 65-nm design surpasses all references in Table~\ref{table:soa_nanoamp_range}, simulated or fabricated, with a \mbox{0.0021-mm$^2$} area, and offers a 25$\times$ reduction compared to prior art of fabricated references. Then, the \mbox{0.0132-mm$^2$} silicon area in 22~nm outperforms all other fabricated references in Table~\ref{table:soa_nanoamp_range} by at least a factor 4$\times$, except for \cite{Kayahan_2013} whose \mbox{28.5-$\mu$W} power consumption is prohibitive in most applications.
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_24_sim_meas_iref_vs_T_v1.pdf}
\caption{Post-layout-simulated and measured temperature dependence of $I_{REF}$ at 1.8~V (a) without and (b) with normalization by the value at 25$^\circ$C. Post-layout simulations correspond to skewed process corners for LVT I/O devices, ULL I/O devices, and parasitic nwell/psub diodes.}
\label{fig:24_sim_meas_iref_vs_T}
\end{figure}
Fig.~\ref{fig:25_comparison_to_soa}(a) further demonstrates that the proposed references are almost unchallenged in terms of silicon area among nA-range CWT references, and lie beyond the trade-off of conventional references. Only \cite{Santamaria_2019} is competitive in terms of silicon area with a \mbox{0.0093-mm$^2$ design}, as it relies on diode-connected and zero-$V_{GS}$ transistors as voltage-to-current converter. However, it suffers from a strong degradation of other FoMs with a 2-V $V_{DD,\mathrm{min}}$, an \mbox{11-$\%$/V} LS and a \mbox{20.3-$\%$} ($\sigma/\mu$). The low area overhead of the proposed reference is linked to the fact that it relies solely on transistors, contrary to other references which include area-hungry resistors. Besides, the implementation in advanced technology nodes further helps reducing the absolute area overhead. They reach the lowest reference current among CWT references at the exception of gate-leakage-based ones, which could be modified to reach a nA-range current but only at the cost of a $10^2$-to-$10^3\times$ larger area.\\
\indent In Table~\ref{table:soa_nanoamp_range}, power consumption and minimum supply voltage are on par with the state of the art, while LS is among the best for nA-range references with a sub-1-$\%$/V value obtained by low-voltage cascoding for both implementations, and backed by a large intrinsic gain $g_m/g_d$ in FDSOI \cite{Cathelin_2017}. Next, in terms of TC, the \mbox{213-} and \mbox{203-ppm/$^\circ$C} simulated values obtained for the proposed \mbox{65-} and \mbox{22-nm} designs are faintly larger than the TC of other fabricated references [Table~\ref{table:soa_nanoamp_range} and Fig.~\ref{fig:25_comparison_to_soa}(b)]. However, the design proposed in \cite{Wang_2019_TCAS, Huang_2010} relies on a temperature exponent of carrier mobility close to two and cannot be ported to most technologies, whereas \cite{Wang_2019_TCAS, Huang_2020, Ji_2017} are area-hungry due to the use of resistors and/or OTAs, and \cite{Lee_2020} due to the use of a current DAC and a low-TC reference. The TC degradation of the proposed 22-nm design to 565~ppm/$^\circ$C in measurement calls for a TC calibration mechanism, extensively used by fabricated references in Table~\ref{table:soa_nanoamp_range} \cite{Wang_2019_TCAS, Huang_2020, Ji_2017, Lee_2020}, to retrieve quasi simulation-level performance. Possible implementations could for example tune the current ratio between $M_5$ and $M_4$ using a binary-weighted mirror \cite{Huang_2020} to change $K_{PTAT}$, or the number of transistors connected in series to implement $M_1$ \cite{Zhuang_2020} to change $\alpha$. In Fig.~\ref{fig:25_comparison_to_soa}(c), the proposed references fare quite well against prior art but can simply not compete against gate-leakage-based (resp. resistor-based) references in the pA (resp. $\mu$A) range. Finally, Fig.~\ref{fig:25_comparison_to_soa}(d) demonstrates that the proposed designs are competitive with most existing references in terms of LS and TC. The main drawback of the proposed \mbox{22-nm} design is its large sensitivity to mismatch and process variations, with a \mbox{9.20-$\%$} ($\sigma/\mu$) due to a large $S_{I_{REF}}$, which could be improved by increasing the sizes of $M_{6-7}$, or by increasing $\Delta V_T$ as it is done in the \mbox{65-nm} design, whose simulated variability scales down to 2.92~$\%$.\looseness=-1
\begin{figure}[!t]
\centering
\includegraphics[width=.45\textwidth]{figure_25_comparison_to_soa_v4.pdf}
\caption{Trade-offs between (a) area and $I_{REF}$, (b) $I_{REF}$ and TC, (c) area and TC, and (d) LS and TC, based on the state of the art of current references.}
\label{fig:25_comparison_to_soa}
\end{figure}
\vspace{-0.25cm}
\section{Conclusion}
\label{sec:7_conclusion}
In this work, we demonstrated a CWT current reference operating in the nA range. It relies on an SCM biased by a PTAT voltage with a CWT offset voltage, which stems from the $V_T$ difference between transistors of the same $V_T$ type, one of them being forward body-biased, through its body in bulk or back-gate in FDSOI. Then, we presented a comprehensive methodology for sizing the proposed reference based on the ACM model and validated it through post-layout simulations in \mbox{65-nm} bulk and \mbox{22-nm} FDSOI. The \mbox{65-nm} reference produces a \mbox{1.1-nA} current with an LS of 0.69~$\%$/V and a TC of 213~ppm/$^\circ$C, and power and area overheads of 5.4~nW and 0.0021~mm$^2$. Lastly, the \mbox{22-nm FDSOI} design was fabricated and generates a \mbox{0.9-nA} current with a \mbox{0.39-$\%$/V} LS and a {565-ppm/$^\circ$C} TC, while consuming 5.8~nW and occupying a silicon area of 0.0132~mm$^2$. The TC degradation from simulation to measurement, together with the large \mbox{9.20-$\%$} variability due to mismatch and process variations, ask for a TC calibration scheme to be explored in further work.
\vspace{-0.25cm}
\appendices
\section{Analytical Expressions of Voltage $V_X$}
\label{sec:8_appendix}
\indent Applying the ACM equations to transistors $M_{1-2}$ forming the SCM [Fig.~\ref{fig:2_basic_schematic}(b)] leads to two distinct equations. The first one is obtained by defining $\alpha \triangleq i_{f1}/i_{f2} > 1$ and expresses voltage $V_X$ as
\begin{IEEEeqnarray}{RCL}
V_X & = & nU_T \Bigg[\left(\sqrt{1+\alpha i_{f2}}-\sqrt{1+i_{f2}}\right)\IEEEnonumber\\
& & + \log\left(\frac{\sqrt{1+\alpha i_{f2}}-1}{\sqrt{1+i_{f2}}-1}\right)\Bigg]\textrm{,}\label{eq:vx_SCM_if1}
\end{IEEEeqnarray}
while the second one relates $\beta \triangleq i_{r1}/i_{f2} \in [0;1]$ to voltage $V_X$ and amounts to
\begin{IEEEeqnarray}{RCL}
V_X(n-1) & = & nU_T \Bigg[\left(\sqrt{1+i_{f2}}-\sqrt{1+\beta i_{f2}}\right)\IEEEnonumber\\
& & + \log\left(\frac{\sqrt{1+i_{f2}}-1}{\sqrt{1+\beta i_{f2}}-1}\right)\Bigg]\textrm{.}\label{eq:vx_SCM_ir1}
\end{IEEEeqnarray}
\vspace{-0.25cm}
\section*{Acknowledgments}
The authors would like to thank Pierre G\'{e}rard for the measurement testbench, El\'{e}onore Masarweh for the microphotograph, and ECS group members for their proofreading.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2023-02-10T02:08:48', 'yymm': '2302', 'arxiv_id': '2302.04504', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04504'} | arxiv |
\section{Introduction}
Acoustic echo cancellation (AEC) and speech dereverberation (DR) play important roles in speech processing applications like real-time communications and automatic speech recognition. AEC aims to remove echos introduced by the playback signals. DR aims to reduce reverberation and restore direct path sounds, optionally retaining early reflections. Adaptive filters are widely used in the two tasks, such as the normalized least means square (NLMS) filter~\cite{shynk1992frequency}, the recursive least square (RLS) filter, and the weighted prediction error (WPE) algorithm~\cite{yoshioka2012generalization}. Kalman filters have also been separately applied in AEC~\cite{enzner2006frequency,paleologu2013study,yang2017frequency,yang2022low} and DR~\cite{schwartz2014online,braun2016online,braun2018linear,lemercier2022neural}.
From the view of adaptive filtering, AEC and DR share many similarities in their solving process. Both tasks are related to estimation of the room impulse responses (RIRs), one relating a source position to the microphone position and the other relating a loudspeaker position to the microphone position.
Joint algorithms that deal with AEC and DR at the same time have shown performance gains over separate partial algorithms~\cite{takeda2009ica,takeda2012efficient,togami2014simultaneous,carbajal2020joint}.
Takeda et al.~\cite{takeda2009ica} achieve blind dereverberation and echo cancellation by applying a frequency domain independent component analysis (ICA) model.
It is assumed that direct sound frame is independent of late reverberation and playback signals, which is approximately true under multiple input/output inverse filtering theorem (MINT) conditions.
Togami and Kawaguchi \cite{togami2014simultaneous} combine acoustic echo reduction, speech dereverberation and noise reduction by assuming a time-varying local Gaussian model of the microphone input signal. The linear filters are optimized under a unified likelihood function that directly reflects the eventual speech enhancement performance.
Cohen et al.~\cite{cohen2021online} propose a Kalman-EM method based on a moving average model for speech dereverberation, and the Kalman filter is adopted to estimate the clean signal after echo cancellation in the E-step.
The reverberant signals are often described by an auto-regressive (AR) model in the short time Fourier transform (STFT) domain.
Our previous works~\cite{wang2021weighted,wang2020semi} reformulate AEC and DR from the semi-blind source separation perspective, respectively. A RLS based joint DRAEC algorithm is further derived in~\cite{na21_interspeech}.
Considering RLS can be seen a special case of Kalman filter~\cite{sayed1994state}, we further propose in this paper a joint DRAEC algorithm using Kalman filters.
The AR model coefficients and the loudspeaker-to-microphone acoustic transfer functions (ATFs) are considered time-varying and are modeled simultaneously using a first-order Markov process.
By minimizing a unified mean squared error loss function, a novel joint DRAEC algorithm is derived. The joint algorithm not only outperforms its RLS counterpart but also outperforms cascaded alternatives that use Kalman based AEC and Kalman based DR sequentially.
\section{Signal model}
We consider a multi-channel convolutive mixture in the short-time Fourier transform (STFT) domain. A sensor array of $M$ microphones captures signals from source $S(t,f)$ and signal $X(t,f)$ played by a loudspeaker, with $t$ and $f$ the time index and the frequency index, respectively.
The $m$th microphone signal in the $f$th band is given by:
\begin{align}\label{eq:signalmodel}
\nonumber Y_m(t) = & \sum_{l=0}^{\infty}A_{m,l}(t)S(t-l) \\
& + \sum_{l=0}^{\infty}B_{m,l}(t) X(t-l) + V_m(t)
\end{align}
where $A_{m,l}$ denotes the source-to-microphone transfer function, $B_{m,l}$ denotes the loudspeaker-to-microphone transfer function, and $V_m$ denotes the background noise.
The signal can be approximated by an auto-regressive model~\cite{togami2014simultaneous} as:
\begin{align}\label{eq:armodel}
\nonumber Y_m(t) = & S_m(t) + \sum_{n=1}^{M}\sum_{l=0}^{L_Y-1}C_{m,n,l}Y_n(t-\Delta-l)\\
& + \sum_{l=0}^{L_X-1}B_{m,l}(t) X(t-l) + \tilde{V}_m(t)
\end{align}
where $S_m$ is the direct path sound and early reflections, $\Delta$ marks the boundary between early reflections and late reverberation, $C_{m,n,l}$ denotes the multichannel auto-regressive coefficients, and $\tilde{V}$ contains the modeling error.
The first term in the right-hand side of (\ref{eq:armodel}) is defined as the target to be recovered:
\begin{equation}\label{eq:filtering}
S_m(t) = Y_m(t) - {\bf w}^H_m(t){\bf z}(t)
\end{equation}
where
\begin{align}\label{eq:filterw}
\nonumber & {\bf w}_m = [
\underset{{\bf w}_\text{AEC}}{\underbrace{ B^*_{m,0}, ..., B^*_{m,L_X-1}, }}\\
& \underset{{\bf w}_\text{DR}}{\underbrace{ C^*_{m,1,0}, ..., C^*_{m,1,L_Y-1}, ..., C^*_{m,M,0}, ..., C^*_{m,M,L_Y-1} }} ]^T
\end{align}
is a unified vector consisting of the AEC related filters of length $L_X$ and the DR related filters of length $ML_Y$, and
\begin{align}
\nonumber {\bf z}(t) = [& X(t), ..., X(t-L_X+1), \\
\nonumber & Y_1(t-\Delta), ..., Y_1(t-\Delta-L_Y+1), \\
\nonumber & \quad ..., \\
& Y_M(t-\Delta), ..., Y_M(t-\Delta-L_Y+1)]^T
\end{align}
is a concatenation of the playback signals and the time-delayed microphone observations. $(\cdot)^*$ denotes complex conjugate, $(\cdot)^H$ denotes Hermitian transpose and $(\cdot)^T$ denotes transpose.
An optimal estimate of the filter coefficients (\ref{eq:filterw}) can be obtained by minimizing the squared error loss function:
\begin{equation}
J_{\bf{w}} = \min \sum_{m=1}^{M}E\{|{\bf w}_m(t)-\hat{\bf w}_m(t)|^2\}
\end{equation}
where $\hat{(\cdot)}$ denotes variable estimate. We assume the following algorithm is performed for each microphone independently, and the subscript $m$ is omitted for brevity.
\begin{figure}[th]
\centering
\centerline{\includegraphics[width=0.85\columnwidth]{fig1.pdf}}
\caption{Source models of joint DRAEC and cascaded DR-AEC and AEC-DR.}
\label{fig1}
\end{figure}
\section{The proposed algorithm}
Both the source-to-microphone and loudspeaker-to-microphone transfer functions are time-varying in real acoustic scenarios, therefore the filter states $\{B_l, C_{n,l}\}$ are also considered to be time-varying. This is described by a first-order Markov process:
\begin{equation}
{\bf w}(t) = {\bf}A(t) *{\bf w}(t-1) + {\bf u}(t)
\end{equation}
where ${A}(t)$ is the state transition parameter and ${\bf u}(t) \sim \mathcal{N}({\bf 0}, {\bf \Phi}_{\bf u}(t))$ describes the process noise that follows a zero-mean complex Gaussian distribution.
\subsection{Kalman based DRAEC}
Given the above formulation, the well-known Kalman filter\cite{kalman1960new} is applied to estimate ${\bf w}(t)$. We denote ${\bf \Phi}$ as the state vector error covariance matrix:
\begin{equation}
{\bf \Phi}(t) = E\{[{\bf w}(t)-\hat{\bf w}(t)][{\bf w}(t)-\hat{\bf w}(t)]^H\}
\end{equation}
The filter update equations are given by:
\begin{align}
S(t|t-1) &= Y(t) - {\bf w}^H(t|t-1){\bf z}(t) \\
{\hat{\bf w}}(t) &= {\bf w}(t|t-1)+{\bf k}(t)S^*(t|t-1) \\
{\bf \Phi}(t) &=[{\bf I} - {\bf k}(t){\bf z}^H(t)]{\bf \Phi}(t|t-1)
\end{align}
where the Kalman gain
\begin{equation}
{\bf k}(t) = \frac{{\bf \Phi}(t|t-1){\bf z}(t)}{
\phi_S(t)+{\bf z}^H(t){\bf \Phi}(t|t-1){\bf z}(t)},
\end{equation}
$\phi_S(t)=E\{S(t)S^*(t)\}$ denotes power spectral density of the desired source and $\bf I$ is a unit matrix of proper size. The next time step predict equations are given by:
\begin{align}
& {\bf w}(t+1|t)= A(t){\hat{\bf w}}(t) \\
& {\bf \Phi}(t+1|t) = A^2(t) {\bf \Phi}(t)+{\bf \Phi}_{\bf u}(t)
\end{align}
The target source is eventually recovered by:
\begin{equation}\label{eq:filtering}
\hat{S}(t) = Y(t) - {\hat{\bf w}}^H(t){\bf z}(t)
\end{equation}
\subsection{Cascaded solutions}
Fig.~\ref{fig1} depicts source models of joint DRAEC and alternative cascaded DR-AEC and cascaded AEC-DR, where the last two are named by their solving orders.
For comparison, we formulate the solution of AEC-DR as:
\begin{align}
\nonumber & \bar{S}(t) = Y(t) - {\bf w}_{\text{AEC}}^H(t){\bf x}(t) \\
& S(t) = \bar{S}(t) - \bar{{\bf w}}_{\text{DR}}(t)\bar{\bf s}(t)
\end{align}
where ${\bf x}(t)$ is a vector of the playback signals, and $\bar{\bf s}(t)$ is a vector of the time delayed signals $\{\bar{S}_m(t-\Delta-l)\}$ after AEC.
Note that the AR coefficients $\bar{{\bf w}}_{\text{DR}}$ are different from ${\bf w}_{\text{DR}}$ as defined in (\ref{eq:filterw}), because the involved signals are different.
The DR filter is thus susceptible to performance of the AEC filter.
The loss function in this case is given by:
\begin{align}
\nonumber J_{{\bf w}} = & \min E\{|{\bf w}_{\text{AEC}}(t)-\hat{\bf w}_{\text{AEC}}(t)|^2\}\\
& + \min E\{|\bar{\bf w}_{\text{DR}}(t)-{\hat{\bar{\bf w}}}_{\text{DR}}(t)|^2\}
\end{align}
and it can be optimized by performing Kalman filter based AEC and Kalman filter based DR sequentially.
\subsection{Parameter estimation}
The Kalman filter requires suitable estimators for ${\bf \Phi}_{\bf u}(t)$ and $\phi_S(t)$. Similarly as in \cite{braun2016online}, we use ${\bf \Phi}_{\bf u}(t) = \phi_{\bf u}(t) {\bf I}$, assuming the elements in ${\bf w}(t)$ uncorrelated and identically distributed. The variance parameter
\begin{equation}
\phi_{\bf u}(t) = \frac{1}{L}E\{|{\hat{\bf w}}(t) - {\hat{\bf w}}(t-1)|^2\} + \eta
\end{equation}
is estimated by the change of filter coefficients over time, where $L$ denotes the filter length and $\eta$ is a small positive number to retain the tracking ability when the acoustic environment changes.
A maximum likelihood estimation of $\phi_S$ is given by:
\begin{equation}
\hat{\phi_S}(t) = \alpha \phi(t-1) + (1-\alpha)S(t|t-1)S^*(t|t-1)
\end{equation}
and
\begin{equation}
\phi(t) = \alpha \phi(t-1) + (1-\alpha)\hat{S}(t)\hat{S}^*(t)
\end{equation}
where $\alpha$ is a recursive smoothing factor.
For initialization, we use ${\bf w}(0) = {\bf 0}$ and ${\bf \Phi}(0)={\bf I}$.
\section{Experiments}
\begin{figure}[th]
\centering
\centerline{\includegraphics[width=1.05\columnwidth]{erle.pdf}}
\caption{ERLE when echo path changes. Best viewed in color.}
\label{fig2}
\end{figure}
The experiments are conducted in echoic, echoic \& reverberant, and echoic \& reverberant \& noisy environments. Reverberation only is not considered because the source models as in shown Fig.~\ref{fig1} would degenerate to the same one.
The sampling frequency is 16 kHz. We use a frame size of 32 ms, 50\% overlap between frames and a STFT size of 1024 points. The AEC filter length is set to $L_X=5$ and the DR filter length is $L_Y=5$ with delay $\Delta=2$.
We use $A=1$, $\eta=1e^{-4}$ and $\alpha=0.8$ in the Kalman filters. The experimental setup mainly follows that as in~\cite{na21_interspeech}. The proposed algorithm is compared with its RLS based variants, the implementations of which are open sourced\footnote{https://github.com/nay0648/unified2021}.
\subsection{Echo}
We first consider the task of single talk echo cancellation. The echo signals are recorded using a smart speaker with $M=2$ microphones and one loudspeaker. In Fig.~\ref{fig2}, echo return loss enhancement (ERLE), defined as ratio of the input signal power to the output signal power, is investigated. Echo path change is simulated by concatenating two different test files. Kalman-DRAEC achieves the highest steady state performance of 31.15 dB ERLE, surpassing the second-best Kalman-AEC-DR by 2.30dB and all the RLS variants. The joint DRAEC algorithms outperforms cascaded alternatives, DR-AEC and AEC-DR.
One reason is the microphone signal contains an echoic copy of the playback sounds, and filtering on microphone signals helps echo reduction especially when nonlinear echo exists.
\begin{table*}[th]
\caption{PESQ scores in double-talk periods. In the case of no reverb, clean speech is used as the reference.}
\label{tab1}
\centering
\begin{tabular}{l|ccc|ccc|ccc}
\hline
RT60 & \multicolumn{3}{c}{no reverb} & \multicolumn{3}{c}{0.3s} & \multicolumn{3}{c}{0.6s} \\
SER & 0dB & -10dB & -20dB & 0dB & -10dB & -20dB & 0dB & -10dB & -20dB \\ \hline
\text{Orig}
& 1.06 & 1.07 & 1.04 & 1.14 & 1.07 & 1.07 & 1.11 & 1.08 & 1.07 \\ \hline
\text{Kalman-DRAEC}
& 1.54 & \bf 1.24 & \bf 1.13 & 1.92 &\bf 1.40 &\bf 1.11 & 1.57 &\bf 1.32 &\bf 1.10 \\ \hline
\text{Kalman-DR-AEC}
& 1.23 & 1.06 & 1.09 & 1.55 & 1.14 & 1.08 & 1.35 & 1.12 & 1.09 \\ \hline
\text{Kalman-AEC-DR}
& \bf 1.58 & 1.23 & 1.11 & \bf 1.96 & 1.39 & 1.10 &\bf 1.59 & 1.32 & 1.10 \\ \hline
\text{RLS-DRAEC}
& 1.40 & 1.19 & 1.04 & 1.74 & 1.34 & 1.08 & 1.48 & 1.28 & 1.09 \\ \hline
\text{RLS-DR-AEC}
& 1.24 & 1.12 & 1.04 & 1.60 & 1.23 & 1.07 & 1.38 & 1.21 & 1.08 \\ \hline
\text{RLS-AEC-DR}
& 1.39 & 1.18 & 1.04 & 1.74 & 1.33 & 1.08 & 1.48 & 1.27 & 1.09 \\
\hline
\end{tabular}
\end{table*}
Double talk utterances are simulated by adding clean speech to the echo signals at signal-to-echo (SER) ratios of 0 dB, -10 dB and -20 dB. The perceptual evaluation of speech quality (PESQ) scores are evaluated and reported in the first category in Table~\ref{tab1}. Kalman-DRAEC achieves overall highest scores when SER=-10 dB and SER=-20 dB, and scores comparable to Kalman-AEC-DR (1.54 vs 1.58) in SER=0 dB.
\subsection{Echo \& Reverb}
Taking reverberation into account, clean speech is first convolved with room impulse responses before adding with echo signals. The impulse responses are generated in random-sized rooms using the Image method~\cite{allen1979image}. The direct sound with early reverberation (50ms) is used as reference. Double talk PESQ scores are reported in the right parts of Table~\ref{tab1}. The trend is the same as in the echoic environments. Kalman filter based algorithms perform overall better than the RLS based variants. Performing DR before AEC is not recommended because the source model as in Fig.~\ref{fig2}(b) mixes up the source signal and the echo signal.
High reverberation (0.6s) and high echo level (SER=-20dB) is challenging for all the algorithms.
\begin{table}[th]
\caption{SDR (dB) improvements with respect to input.}
\label{tab2}
\centering
\begin{tabular}{lcccc}
\hline
SER & \multicolumn{2}{c}{0dB} & \multicolumn{2}{c}{-10dB} \\
RT60 & 0.3s & 0.6s & 0.3s & 0.6s \\ \hline
\text{Kalman-DRAEC}
& 9.27& 7.68& 16.49& 13.75 \\ \hline
\text{Kalman-DR-AEC}
& 8.90& 7.41& 14.75& 12.25 \\ \hline
\text{Kalman-AEC-DR}
& 9.37&\bf 7.78& 16.57&\bf 13.77 \\ \hline
\text{RLS-DRAEC}
&\bf 9.69& 7.50&\bf 16.82& 13.54 \\ \hline
\text{RLS-DR-AEC}
& 9.51& 7.32& 16.05& 12.74 \\ \hline
\text{RLS-AEC-DR}
& 9.63& 7.43& 16.76& 13.40 \\
\hline
\end{tabular}
\end{table}
\begin{table}[th]
\caption{SIER (dB) improvements with respect to input.}
\label{tab3}
\centering
\begin{tabular}{lcccc}
\hline
SER & \multicolumn{2}{c}{0dB} & \multicolumn{2}{c}{-10dB} \\
RT60 & 0.3s & 0.6s & 0.3s & 0.6s \\ \hline
\text{Kalman-DRAEC}
&\bf 11.54&\bf 9.57&\bf 12.96&\bf 10.02 \\ \hline
\text{Kalman-DR-AEC}
& 9.48& 7.85& 8.48 & 6.72 \\ \hline
\text{Kalman-AEC-DR}
& 11.36& 9.38& 12.46& 9.22 \\ \hline
\text{RLS-DRAEC}
& 11.12& 9.25& 12.09& 8.93 \\ \hline
\text{RLS-DR-AEC}
& 10.71& 8.71& 10.40& 6.87 \\ \hline
\text{RLS-AEC-DR}
& 10.95& 9.04& 11.90& 8.35 \\
\hline
\end{tabular}
\end{table}
\subsection{Echo \& Reverb \& Noise}
The proposed algorithm is also evaluated in complex scenarios where interference and noise coexist. Interfering signals are added at signal-to-interference ratio (SIR) of 0~dB.
Signal-to-distortion ratio (SDR)~\cite{vincent2006performance} and
a non-instructive metrics, namely microphone signal to interference-plus-echo ratio (SIER), are respectively reported in Table~\ref{tab2} and Table~\ref{tab3}. SDR measures the overall quality of the processed speech. SIER measures the non-target reduction performance.
Kalman-DRAEC is advantages in SIER and scores highest in all the test cases, nevertheless, at a cost of more speech distortion as shown in the SDR scores. Based on the previous results, the advantage of DRAEC mainly comes from introducing more echo reduction.
\section{Conclusion}
This paper introduces a joint DRAEC algorithm using Kalman filters that performs echo cancellation and speech dereverberation at the same time. The joint algorithm is derived from a unified mean squared error loss function and outperforms cascaded DR-AEC and AEC-DR alternatives. The Kalman based algorithms also outperforms their RLS based variants because the acoustic environment change is explicitly modeled by a first-order Markov model.
\bibliographystyle{IEEEtran}
| {'timestamp': '2023-02-10T02:07:40', 'yymm': '2302', 'arxiv_id': '2302.04469', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04469'} | arxiv |
\section{Introduction}
With the rapid development in web technology, Internet users have been provided with tremendous amount of information, which impedes the selection of relevant information to the user, resulting in protracted decision-making process and reduced decision quality. To address this problem of information overload, solid efforts have been made by researchers in various domains to develop recommendation systems that are able to generate curated information based on user preferences, ranging from online advertisement\cite{Chaudhuri2016}, music selection\cite{Kowald2020}, move rating\cite{Nguyen2013}, to product recommendation\cite{Agarwal2018}. By exploiting user-item (UI) relations, recommender systems recommender systems hold the promise of streamlining data and provide personalization, and have been a key determining factor for driving a nuanced customer experience\cite{Ricci2015}. As a result, they have been widely adopted by online retailers and web service providers to perfect their products and acquire profit. \\\\
E-commerce has gained increasing importance and popularity among customers. Although recommendation systems are now intrinsic to many industries, there are some unique challenges that thwart the widespread adoption in the field of E-commerce. In most of the cases, potential customers do not have a crisp understanding of what they want to buy. It is hard for them to accurately express their need with limited taxonomy of attributes with the internal search engine.\cite{Agarwal2018} As a result, they get discouraged fairly easily in the process of navigating through a plethora of options. Undoubtedly, the capability of recommender system implemented by those online retailers to capture the intrinsic item characteristics and user preferences has becoming one of the biggest differentiators against their competitors and is critical to ensuring the success of a company\cite{Ricci2015}.\\\\
There is largely a dichotomy of recommendation algorithms. Content-based algorithms build user specific and item specific profiles, usually in the form of a vector. The user profile describes the contents that he or she likes, and the item profile describes the contents that it contains. To create those profiles, a good amount of auxiliary information of users and items are required. Then a similarity metric, typically a dot product, is used to determined user preferences. Collaborative filtering approach analyzes past user behavior and finds similar users and items based on the history. The core assumption here is that the users who have agreed in the past tend to also agree in the future. People have also been using deep learning (DL) techniques to further improve the performance of those recommender models, as DL provides better modelling power, flexibility, and feature representation learning. Covington et al.\cite{Covington} presented a deep neural network based recommender for video recommendation on YouTube. Cheng et al. \cite{Cheng2016} proposed a wide \& deep model for generic recommender systems with sparse inputs. Shumpei et al. \cite{Okura2017} showcased a recurrent neural network (RNN) based news recommender system for Yahoo News. All of these deep learning based models have proven to have significant improvement over traditional models. Hybrid model refers to recommender system that integrates two or more types of recommendation methods.
While most of the existing recommendation algorithms are powerful in modeling user-item relationships, they have major limitations regarding the utilization of text information. Specifically, they cannot effectively incorporate textual information in e-commerce datasets, which are in abundance and might potentially be very informative. Without preparations, those recommendation algorithms also suffer acute relevance problems due to lack of negative feedback in the context of online retail\cite{Jiang2020}. The problem regarding which recommender algorithms to use and how to effectively use those algorithms, while heatedly debated and investigated, remains challenging and unsolved.\\\\
The recent emergence and development of BERT (Bidirectional Encoder Representations from Transformers) and its variants in NLP field has drastically increased the modeling power of machine learning models to understand textual information\cite{Devlin2019}. By leveraging the power of pretraining contextual representation on large scale text datasets and unsupervised training objectives, BERT has been able to achieve state-of-art performances in a board range of natural language processing tasks. \\\\
However, in the field of e-commerce, people could not exploit the full advantage of BERT algorithms due to the following reasons: BERT cannot always accurately understand the frequently appearing domain specific phrases because they are not included in the training objective; in the context of e-commerce, textual information such as item label or item description typically has very limited length compared with other data sources such as movie reviews or web documents, on which BERT is hard to make inference without additional domain specific pretraining and is very susceptible to noises in the dataset\cite{Zhang2020}. \\\\
It remains unclear that how the benefit of a unified language representation model would help the recommendation models to better understand and capture the underlying rules that affects people's decision making, and how different schemes of further pretraining would influence the final recommendation results. In our paper, we address this question for a high performing pre-trained language model, RoBERTa\cite{Liu2019}, and investigate the effectiveness of various approaches to incorporate rich text features into traditional recommender system algorithms on an online retail data set. We consider two types of recommendation algorithms - content-based recommender algorithm (matrix factorization, abbreviated as MF) and machine learning based algorithm (XGBoost and decision tree). We evaluate the performance increase gained through the incorporation of sentence embeddings against baseline algorithms, and we show that the introduction of RoBERTa consistently increases model performance regardless of which recommender algorithm is used. Additionally, the effect of pretraining BERT with transformer-based denoising auto-encoder (TSDAE) and masked language model(MLM) is also investigated. For MLM, in accordance to the RoBERTa paper, we use dynamic masking rather than static masking\cite{Liu2019}. Inspired by this process, We further propose a recommendation scheme that we consider to be the most effective for MF and XGBoost respectively. Our experiment shows that recommendation models trained under this scheme outperforms their vanilla counterparts even with highly sparse user-item interaction matrices. \\
In summary, our contribution includes:
\begin{itemize}
\item a comprehensive study on incorporating rich textual information in the domain of e-commerce to improve performance of recommender algorithms;
\item a thorough evaluation and visualization of recommendation results made by vanilla recommendation algorithms and BERT enhanced recommendation models;
\item an investigation into the effectiveness of domain-adaptive pretraining.
\end{itemize}
\section{Related Work}
\subsubsection{Matrix Factorization}
A straightforward matrix factorization model maps both users and items to a joint latent factor space of dimensionality K — such that user-item interactions are modeled as inner products of user feature vector and item feature vector in that space\cite{Nguyen2013}. However, pure matrix factorization relies on past information, and cannot accurately capture some observed variation in the rating values are due to biases associated with either users or items. Xxx solves this by using a new training objective and error term with additional bias term\cite{Tran2018}. However, the cold start problem remains challenging due to its inability to address new items and new users\cite{Elahi2016}. Wang et al. Integrates additional user attributes (demographics) to relieve this problem\cite{Wang2012}, though the performance of matrix factorization model still suffers from high sparsity of the user-item interaction matrix. It is also common in many real-world use cases that we only have access to implicit feedback, where user-item interactions like clicks, likes, or purchases are used as a proxy to indicate a preference or dislike for those items. Standard matrix factorization-based collaborative filtering treats the entries of the user-item matrix as explicit user preferences given to items. Those algorithms assume explicit data, where the user has rated both things they like and dislike using some rating scale. They typically work by treating the missing data as an unknown, set them to some constant (usually 0), and then the decomposed matrices are trained to reproduce the entire matrix, including the unknown values using SGD. Hu et al. proposed implicit feedback\cite{Hu2008}. Essentially, instead of trying to model the matrix of ratings directly, implicit matrix factorization is used to treat the data as numbers representing the strength in observations of user actions (such as the number of clicks, or the cumulative duration someone spent viewing a movie). Those numbers are then related to the level of confidence in observed user preferences, rather than explicit ratings given to items. The model then tries to find latent factors that can be used to predict the expected preference of a user for an item.
\subsubsection{Pre-trained Language Model}
Recently, substantial work has shown that pre-trained language models (PLMs) can learn universal language representations\cite{Peters2018, Radford2018, Devlin2019}. Those language representations learned on large corpus avoid training a new model from scratch and allow faster and better implementation of NLP tasks.
Compared with traditional word embedding models\cite{Gupta2015}, PLMs learn to predict and represent words based on the entire input context, thus are capable of understanding semantics more accurately. Although PLMs have been successful on a broad range of NLP task, there are still lots of areas of improvement to be made. Many efforts have been done to further optimize its robustness and model performance. SpanBERT\cite{Joshi2020} proposes random masked span reconstruction instead of single word reconstruction. However, the span consists of random continuous words and may not form phrases, thus fails to capture phrase-level knowledge accurately. ERNIE-1.0\cite{Sun2019} integrates phrase-level masking and entity-level masking into BERT. RoBERTa\cite{Liu2019} proposes modifications to the BERT pretraining procedure that improve end-task performance, allowing PLMs to further untap its potential.
PLMs have proved its ability on sentence completion tasks (including modest performance in Winograd challenge sentences) if trained on a large corpus.
\subsubsection{XGBoost}
Among many powerful machine learning algorithms, gradient tree boosting is one of the methods that has been proven to shine in many standard classification benchmarks. XGBoost is a fast and highly scalable implementation for tree boosting. It handles sparse input with a novel tree learning algorithm and handles instance weights
in approximate tree learning with
As recommendation systems are being used for a long time, several algorithms for recommendation have been developed. Literature shows that extending model based algorithms \cite{Martin2017} is the most promising class of algorithms. In this class, several machine learning techniques are adapted to work with user-item interactions as well as interaction data, and user and item properties. One of those techniques which appeared to be very successful in earlier studies is decision tree learning. In this method a decision tree is used to predict the target value of an item by means of observation that have been made. By using the gradient boosting technique, models are added sequentially to correct the errors of prior models until no further improvements can be made.
\subsubsection{Fine-tuning PLMs}
Fine-tuning a pre-trained language model (PLM) has become the standard for doing transfer learning in natural language processing. Over the last three years, fine-tuning\cite{Howard2018} has superseded the use of feature extraction of pre-trained embeddings\cite{Peters2018} while PLMs are favoured over models trained on translation \cite{McCann2018}, natural language inference \cite{Conneau2017}, and other tasks due to their increased sample efficiency and performance \cite{Zhang2019b}. The empirical success of these methods has led to the development of even larger models \cite{Devlin2019, Raffel2020}. Recent models are so large in fact that they can achieve reasonable performance without any parameter updates\cite{Brown2020}. The limitations of this zero-shot setting, however, make it likely that in order to achieve the best performance or stay reasonably efficient, fine-tuning will continue to be the modus operandi when using large PLMs in practice.
\section{Datasets and Data Preparation}
Three different text datasets are used in this paper. We use Online Retail dataset\cite{Chen2019} as our main target of study. It focuses on a narrow domain of e-commerce, as this British Online retailer sells a limited number of things during the period when this dataset is collected. We use Amazon dataset as a dataset that is similar but covers a broader range of things, as they are both e-commerce datasets. The openwebtext dataset\cite{Cohen2019} is considered as a close analogy to what text datasets are used for RoBERTa training, and it is only used for cross reference when computing vocabulary similarity. Only part of it is sampled due to its much larger size compared to the other two datasets.\\
The online retail dataset consists of transactions occurring between 01/12/2010 and 09/12/2011 for a UK-based and registered non-store online retail. The company mainly sells unique all-occasion gifts. Many customers of the company are wholesalers.
Each observation has eight covariates, which are invoice ID, stock code, item description, quantity, date, unit price, customer ID, and country. The invoice ID is a 6-digit number uniquely assigned by the retail to be able to identify if different items belong to the same user. Canceled transactions is indicated by invoice number which starts with letter 'C'. The stock code is a 5-digit integral number uniquely assigned to each distinct product, while the customer ID is a 5-digit user specific integer. The item description is a short sentence describing what the item is. Date is the day and time when each transaction was generated. The last one is country, showing the name of the country where each customer resides. There are 37 countries in total, ranging from North America to EU, with most customers from UK and France. The first five lines of the dataset is shown in \autoref{tab:figure0}.
\begin{figure*}
\centering
\includegraphics[scale=0.6,angle=90]{data_plots/first_five_lines_v.PNG}
\caption[snippet of Online Retail dataset]
{a snippet of the Online Retail dataset}
\label{tab:figure0}
\end{figure*}
\\
There are some special entries and interesting characteristics in the dataset that are worth mentioning:
\begin{itemize}
\item Transactions with negative quantity
\begin{itemize}
\item The magnitude of those negative values match with previous purchase records in the dataset.
\item In the context of online retail, it means some items got returned.
\end{itemize}
\item Transactions with zero or negative price.
\begin{itemize}
\item Transactions with zero price does not bring useful information to analysis, moreover mainly there are not any description for such transactions.
\item Transactions with negative price. From the description we could see that these transactions were probably made as corrections.
\end{itemize}
\item Long-tailed data distribution with extreme outliners
\begin{itemize}
\item Right-skewness of quantity and unit price. As shown in \autoref{tab:figure1}, even in log scale, the data is still right-skewed. In fact, 50\% of the users only purchase 1-3 items at a time, while some wholesaler does big purchases with more than 500 of the same items. In addition, most items sold in the dataset are cheap, with rare cases of high unit prices. As a result, those data are extremely right-skewed.
\item Outliners. From \autoref{tab:figure2}, most of items are common, daily products which have a normal price. However, some items in this dataset are very expensive, and that might influence the amount of purchase significantly. Also, standard deviation for quantity is 218.08, which is extremely huge. This is caused by some rare and extreme events. For example, a big purchase of 80955 items happened during the period when the dataset is recorded, but unfortunately this order is eventually cancelled and thus is not taken as part of our data.\\
\end{itemize}
\end{itemize}
There are 1336 of transactions with negative quantity value among non-cancelled transactions, and 1336 transactions with zero price and negative quantity. This corresponds to 1.71\% and 0.46\% of the total number of observation entries in the dataset, which is insignificant and less likely to cause loss of information if those problematic entries are directly filtered out.
There are 541909 entries in this online retail dataset, and there are 406829 non-null customer IDs and 540455 item descriptions, meaning 24.9\% of customer IDs and 0.27\% of item descriptions are null object and thus cannot be used. After filtering out all the null entries and return cases, there are 397924 observations. Those records correspond to 4339 distinct users and 3665 unique items. This gives a user-item matrix with a sparsity of 97.5\%.
To reduce the influence of outliners and uneven distribution on the performance of our models, there are normally two methods. We can standardize the features by subtracting mean and dividing the result by standard deviation, but that would result in negative values in features and potentially negative output values in matrix factorization. Here we choose the second method, evening out the distribution by creating a histogram as shown by \autoref{tab:figure3} and assign labels to each quantity range that approximately contains the same amount of products. Due to the discrete nature of this method, each label would not have the same amount of items, but as shown in \autoref{tab:figure3}, the distribution is much better than the right-skewed one shown in \autoref{tab:figure1}.
\begin{figure}
\centering
\includegraphics[scale=0.8]{data_plots/quantity_hist.PNG}
\caption[Close up of]
{histogram of purchased quantity of items in online retail dataset}
\label{tab:figure1}
\end{figure}
\begin{figure}
\centering
\includegraphics[scale=0.7]{data_plots/unit_price_hist.PNG}
\caption[Close up of]
{histogram of unit price of items in online retail dataset}
\label{tab:figure2}
\end{figure}
\begin{figure}
\centering
\includegraphics[scale=0.8]{data_plots/rating_hist.PNG}
\caption[Close up of]
{histogram of ratings after quantity-to-rating conversion in online retail dataset}
\label{tab:figure3}
\end{figure}
\begin{figure*}
\centering
\includegraphics[scale=0.45]{data_plots/modified_pipeline.PNG}
\caption[Close up of]
{Flow chart of the data processing and training pipeline}
\label{tab:figure4}
\end{figure*}
\section{Baseline Models}
We first build baseline models without using the text information of production description. Two main recommendation models are used in this paper:
\begin{itemize}
\item Matrix Factorization Recommender
\item XGBoost Factorization Recommender
\end{itemize}
And for each approach, we have done investigation on the performance of three variants of those recommendation models. The details are listed in \autoref{tab:table1}.
\begin{table}[h!]
\begin{center}
\caption{Recommender models and variants}
\label{tab:table1}
\begin{tabular}{l|c|r}
\textbf{} & \textbf{Recommender 1} & \textbf{Recommender 2} \\
variant & Matrix Factorization & XGBoost \\
\hline
1 & vanilla & vanilla \\
2 & generalized lower rank models & with random forest\\
3 & implicit & with embedding features\\
\end{tabular}
\end{center}
\end{table}
\subsection{Matrix Factorization}
Standard matrix factorization-based collaborative filtering treats the entries of the user-item matrix as explicit user preferences given to items. Those algorithms assume explicit data, where the user has rated both things they like and dislike using some rating scale. They typically work by treating the missing data as an unknown, setting them to a constant (usually 0), and then the decomposed matrices are trained to reproduce the entire matrix, including the unknown values using stochastic gradient descent (SGD)\cite{Nguyen2013}.
It is, however, common in many real-world use cases that we only have access to implicit feedback (e.g. views, clicks, purchases, likes, shares). Essentially, instead of trying to model the matrix of ratings directly, implicit matrix factorization is used to treat the data as numbers representing the strength in observations of user actions (such as the number of clicks, or the cumulative duration someone spent viewing a movie). Those numbers are then related to the level of confidence in observed user preferences, rather than explicit ratings given to items. The model then tries to find latent factors that can be used to predict the expected preference of a user for an item\cite{Hu2008}.
Take the dataset used in this paper as an example, we can assume that a user buying an item means they like it, but we don't have the corresponding signal that a user doesn't like an item. Implicit data is usually more plentiful and easier to collect than explicit data - and even when you have the user give 5-star ratings the vast majority of those ratings are going to be positive only, so you need to account for implicit behaviour anyways. This means we can't just treat the missing data as unknowns, instead we have to treat a user not buying an item as being a signal that the user might not like that item. This presents a couple of challenges in learning a factorized representation.
The first challenge is in doing this factorization efficiently: by treating the unknowns as negatives, the naive implementation would look at every single entry in our input matrix. Since the dimensionality here is roughly 4K by 3K - there are over 12 million total entries to consider, compared to only 40K non-zero entries. The second problem is that we can't be certain that a user not listening to an artist actually means that they don't like it. There could be other reasons for the artist not being listened to, especially considering that we only have the top 50 most played artists for each user in the dataset.
To handle the case where we're not confident about our negative data, this approach learns a factorized matrix representation using different confidence levels on binary preferences: unseen items are treated as negative with a low confidence, where present items are treated as positive with a much higher confidence.
\subsection{XGBoost and Random Forest}
XGBoost builds decision tree one each time. Each new tree corrects errors which were made by previously trained decision trees\cite{Chen2016}. Since boosted trees are derived by optimizing an objective function, basically XGBoost can be used to solve almost all objective function that we can write gradient out. This includes things like ranking and Poisson regression, which RF is harder to achieve. XGBoost model, however, due to its strong modeling power, is more sensitive to over-fitting if the data is noisy. Training generally takes longer than RF because of the fact that trees are built sequentially. Additionally, XGBoost based models are usually harder to tune than RF. There are a few important hyper-parameters including: number of trees, depth of trees and learning rate, and the each tree built is generally shallow.\\
Random Forest (RF) trains each tree independently, using a random sample of the data\cite{Louppe2014}. This randomness helps to make the model more robust than a single decision tree. Thanks to that random forest is less likely to over-fit on the training data. The random forest dissimilarity helps to achieve high predictive accuracy for a high-dimensional problem with strongly correlated features, and has thus been used in a variety of applications. It also helps to reduce susceptibility against data that are highly noisy and that contains a lot of missing values e.g., some of the attributes are categorical or semi-continuous. The model tuning for RF is much easier than in case of XGBoost. In random forest we have two main parameters: number of features to be selected at each node and number of decision trees. The main limitation of the Random Forest algorithm is that a large number of trees can make the algorithm slow for real-time prediction. For data including categorical variables with different number of levels, random forests are biased in favor of those attributes with more levels.\\
XGBoost is normally used to train gradient-boosted decision trees and other gradient boosted models. Random Forests use the same model representation and inference, as gradient-boosted decision trees, but a different training algorithm. One can use XGBoost to train a standalone random forest or use random forest as a base model for gradient boosting.\\
In this paper, XGBoost is chosen as the recommender algorithm that models all the features extracted from the online retail dataset and provides recommendations for each user that are evaluated against ground truth purchases. RF algorithm is used as a feature selecter in an effort to minimize the influence of less useful features and underlying noises that could lead to over-fitting on the XGBoost model.
\section{RoBERTa Fine-tuning}
\subsection{Corpus similarity}
Two text datasets are used in this paper for RoBERTa fine-tuning.
\begin{itemize}
\item item descriptions in online retail dataset
\item item descriptions in Amazon meta-data dataset
\end{itemize}
\autoref{tab:figure5} shows the word similarity between these two text datasets. \autoref{tab:figure6} and \autoref{tab:figure7} shows the top 10 common words found in descriptions of online retail dataset and Amazon description dataset respectively after stop word filtering is applied.
\begin{figure}
\centering
\includegraphics[scale=0.6]{data_plots/voc_sim.PNG}
\caption[Vocabulary Similarity Matrix]
{Vocabulary overlap (\%) between each language corpus. Vocabularies for each domain are created by considering the top 150 most frequent words in item descriptions sampled from each domain. A sample from openwebtext dataset is taken as a data source that is similar to RoBERTa’s pretraining corpus since the dataset used to train RoBERTa is no longer available.
\label{tab:figure5}}
\end{figure}
Note that stop word filtering has been used on both retail dataset and amazon dataset to get the word count. In comparison, descriptions in amazon dataset are much longer in character length, and contains less key information than in the case of retail dataset. This could potentially cause memory issues in GPU during training and add undesirable noises in the pre-trained result. To save memory, during the pretraining process, the sentences extracted from amazon dataset are divided into 512 different batches with a batch of size 2000, and the character limit is set to 50 in an effort to match the character length of the descriptions in retail dataset and to filter out less useful information in those descriptions.
\begin{figure}
\centering
\includegraphics[scale=0.45]{data_plots/formated_retail_cleaned.png}
\caption[Retail Top 10 Words]
{Top 10 common words found in descriptions of retail dataset with stop word filtered.}
\label{tab:figure6}
\end{figure}
\begin{figure}
\centering
\includegraphics[scale=0.5]{data_plots/formated_amazon_cleaned.png}
\caption[Amazon Top 10 Words]
{Top 10 common words found in descriptions of amazon dataset with stop word filtered.}
\label{tab:figure7}
\end{figure}
\subsection{Combined DAPT and TAPT}
Datasets curated to specific tasks of interest are typically a subset of textual information in a broader domain. Here we make the hypothesis that the online retail dataset is a narrowly defined subset of the broader e-commerce domain represented by amazon dataset due to its comparably smaller size. We adapt a similar pretraining scheme as used by Gururangan et al.\cite{Gururangan2020} that contains three different phases. We begin with regular RoBERTa pretraining, and then we use the online retail dataset and amazon review dataset for task adaptive pretraining (TAPT) and domain adaptive pretraining (DAPT) respectively. As suggested by Gururangan et al. \cite{Gururangan2020}, DAPT and TAPT might complement each other, depending on whether a spectrum of domains is defined around tasks at various levels of granularity. \\
We investigate the effect of using both adaptation techniques together and observe the effect of manipulating the order of different pretraining phases. We begin with RoBERTa, and then apply one of DAPT or TAPT as a baseline. Then we explore two different orders of pretraining phases as shown in \autoref{tab:table5}. We show that combining domain- and task-adaptive pretraining achieves better performance on all tasks compared to their baseline counterparts. The results also demonstrate that applying TAPT after DAPT yields a better recommendation accuracy.
\section{Experimental Results}
Two main recommender models are used in the paper, Matrix factorization and XGBoost. Various variant approaches are taken to explore the key to better recommendation performance. The detailed list is shown in \autoref{tab:table1}.\\
We first establish baseline performance using vanilla Matrix Factorization and XGBoost models. Based on these, we add additional tweaks to see if there is any improvement and to better understand how to apply PLMs to those recommender systems. For visualizing and evaluating PLMs, we pass the sentences in our text datasets into those trained models and generate sentence embeddings of a fixed dimension of 728. Those high dimensional sentence embeddings are then passed through dimension reducing networks, where their dimension is reduced to either 10d or 2d depending on the settings. Two choices of dimension reduction methods are available, T-SNE and PCA. PCA provides more consistent result and faster running time\cite{Garber2015}, while T-SNE provides better clustering result while having slower running speed. T-SNE also does not work well on high dimensional vectors. In this paper, the embedding space is 2 dimensional, visualized through PCA and results are also generated using PCA. T-SNE are tested, and following \cite{VanDerMaaten2008}, we use PCA to reduce the dimension to 10d before we use T-SNE to further reduce it to 2d. However, T-SNE does not yield better result and the analysis regarding its performance is not relevant to our study in this paper. \\
We use distilled RoBERTa as our baseline pretrained language model, with optional fine-tuning following two pretraining schemes introduced by Gururangan et al. \cite{Gururangan2020}, domain adaptive pretraining (DAPT) and task adaptive pretraining (TAPT). Our domain specific pretraining follows the settings prescribed for training RoBERTa. Due to the memory constraints, we did not choose to further pretrain RoBERTa model on openwebtext. Instead, we use RoBERTa as a baseline model, and investigate the effect of DAPT and TAPT using amazon description dataset and retail description dataset respectively. Two different kinds of pretraining method are used, Transformer-based Sequential Denoising Auto-Encoder (TSDAE) and masked language model (MLM). Studies have show that TSDAE is a strong pre-training method for learning sentence embeddings, significantly outperforming other approaches like MLM. It also provides better generalization and robustness for heterogeneous domains than the baseline RoBERTa model where domain knowledge is required. The pre-training is done in different orders to compare the effectiveness of different schemes. \\
\begin{table}
\centering
\begin{tabular}{ |p{1.8cm}||p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}| }
\hline
\multicolumn{5}{|c|}{Evaluation Result of XGBoost based algorithms} \\
\hline
& Accuracy & Precision & Recall & F1 score\\
\hline
Baseline & 71.2 (0.2) & 70.1 (0.3)& 70.8 (0.4) & 70.4 (0.2)\\
@ batch 100 & 72.3 (0.3) & 71.4 (0.4) & 69.9 (0.9) & 70.6 (0.3)\\
@ batch 200 & 72.4 (0.2) & 72.2 (0.3)& 71.0 (0.6) & 71.6 (0.3)\\
@ batch 300 & 73.0 (0.4) & 72.6 (0.6)& 72.2 (0.4) & 72.4 (0.3)\\
@ batch 400 & 73.3 (0.2) & 72.8 (0.2) & 72.5 (0.3)& 72.6 (0.2) \\
@ batch 500 & 73.1 (0.3) & 73.0 (0.2)& \textbf{72.8} (0.4)& 72.9 (0.3)\\
@ final & \textbf{73.6} (0.6)& \textbf{73.4} (0.2)& 72.6 (0.4)& \textbf{73.0} (0.3)\\
\hline
\end{tabular}
\caption{Prediction accuracy, precision, recall, and F1 score with standard deviation of baseline model (RoBERTa) calculated from 5 trial runs and model that has been further pretrained using Amazon dataset using TSDAE. The above result is evaluated on the same amazon dataset using XGBoost except that the final model after trained with 512 batches is evaluated on retail dataset.}
\label{tab:table2}
\end{table}
\begin{table}
\centering
\begin{tabular}{ |p{1.8cm}||p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}| }
\hline
\multicolumn{5}{|c|}{Evaluation Result of XGBoost based algorithms} \\
\hline
& Accuracy & Precision & Recall & F1 score\\
\hline
Baseline & 67.4 (0.3) & 68.2 (0.2)& 67.0 (0.3) & 64.8 (0.3) \\
@ batch 100 & 72.2 (0.3) & 71.6 (0.2) & 69 (0.2) & 70.3 (0.3)\\
@ batch 200 & 72.4 (0.2) & 72.5 (0.3)& 71.0 (0.1) & 71.7 (0.4)\\
@ batch 300 & 73.0 (0.2) & 72.8 (0.2)& 72.2 (0.3) & 72.5 (0.1)\\
@ batch 400 & 73.3 (0.3) & 73.0 (0.3) & 72.5 (0.5)& 72.7 (0.4) \\
@ batch 500 & 74.0 (0.1) & 73.6 (0.3) & \textbf{73.2} (0.2)& 73.4 (0.2)\\
@ final & \textbf{74.2} (0.2) & \textbf{74.5} (0.4)& 72.8 (0.3)& \textbf{73.6} (0.2)\\
\hline
\end{tabular}
\caption{Prediction accuracy, precision, recall, and F1 score with standard deviation of baseline model (RoBERTa) calculated from 5 trial runs and model that has been further pretrained using Amazon dataset using MLM. The above results are evaluated on the same amazon dataset using XGBoost except that the final model after trained with 512 batches is evaluated on retail dataset.}
\label{tab:table3}
\end{table}
First, we investigate the effectiveness of DAPT and TAPT individually. Amazon sentences are divided into 512 batches of size 2000, with maximum characters allowed in each sentence set to 50. Then those batches are fed into two different pretraining frameworks, TSDAE and MLM respectively. Prediction accuracy, precision, recall and F1 score are used as evaluation metrics and model performance is evaluated every 100 batch and at the end. The results are listed in \autoref{tab:table2} and \autoref{tab:table3}. The performance of XGB recommender increases with training for all evaluation metrics and the speed becomes slower with the increase of batch number. This can also be supported by the training loss graph shown in \autoref{tab:figure8}. Training loss drops fast at first 100 batches and then becomes stable after that.\\ \begin{figure}[h]
\centering
\includegraphics[scale=0.6]{xgb_plots/formated_mlm_loss.png}
\caption[Visualization of embedding space distribution of items recommended by matrix factorization model and the ground truths]
{Loss value vs batch number for MLM pretraining graph evaluated on amazon dataset}
\label{tab:figure8}
\end{figure}
Then we explore different orders of combining TSDAE and MLM pretraining, with different combinations of DAPT and TAPT, in comparison to the baseline performance we just established above. The result is listed in \autoref{tab:table4}. \\
\begin{table}[ht!]
\centering
\begin{tabular}{ |p{2.2cm}||p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}| }
\hline
\multicolumn{5}{|c|}{Evaluation Result of XGBoost based algorithms} \\
\hline
& Accuracy & Precision & Recall & F1 score\\
\hline
TSDAE @amazon & 71.2 (0.2) & 70.1 (0.3)& 70.8 (0.4) & 70.4 (0.2) \\
MLM @amazon & 72.3 (0.6) & 71.1 (0.4) & 69.8 (0.4) & 70.4 (0.2)\\
T\textrightarrow M @amazon & 72.4 (0.3) & 72.2 (0.2)& 71.4 (0.3) & 71.8 (0.3)\\
M\textrightarrow T @amazon & 73.0 (0.1) & 72.6 (0.3)& 72.2 (0.2) & 72.4 (0.4)\\
T\textrightarrow M @retail & 73.3 (0.2) & 72.8 (0.4) & 72.5 (0.6)& 72.6 (0.1) \\
M\textrightarrow T @retail & 73.1 (0.4) & 73.0 (0.2) & 72.8 (0.4)& 72.9 (0.3)\\
MLM @D\textrightarrow T & 73.6 (0.2)& 73.4 (0.4)& 72.6 (0.2)& 73.0 (0.2)\\
TSDAE @D\textrightarrow T & 73.5 (0.3) & 73.2 (0.2)& 72.6 (0.1)& 72.9 (0.1)\\
T\textrightarrow M @D\textrightarrow T & 74.4 (0.2) & 74.3 (0.2)& \textbf{73.1} (0.2)& 73.7 (0.2)\\
M\textrightarrow T @D\textrightarrow T & \textbf{74.8} (0.2)& \textbf{74.5} (0.3)& 73.0 (0.4)& \textbf{73.7} (0.5)\\
\hline
\end{tabular}
\caption{Prediction accuracy, precision, recall, and F1 score with standard deviation calculated from 5 trial runs. T\textrightarrow M stands for TSDAE\textrightarrow MLM, D\textrightarrow T stands for DAPT\textrightarrow TAPT.}
\label{tab:table4}
\end{table}
We also study the influence of various features used in generating recommendations by XGBoost model. Random Forest algorithm is used as an optional feature selection method that filters out features with importance less than 0.04 in an attempt to reduce the chance of XGBoost model overfitting on less useful features. Different features are added in a paralleled manner except those with a * after the feature name. The details are listed in \autoref{tab:table5}.\\
\begin{table}[htbp]
\centering
\begin{tabular}{ |p{1.8cm}||p{1.2cm}|p{1.2cm}|p{1.1cm}|p{1.1cm}| }
\hline
\multicolumn{5}{|c|}{Evaluation Result of XGB based algorithms} \\
\hline
& Accuracy &Precision &Recall &F1 score\\
\hline
Vanilla XGB & 54.2 (0.3) & 52.3 (0.2)& 49.5 (0.2) & 67 (0.1) \\
+RandomForest & 56.1 (0.4) & 55.4 (0.2) & 51.9 (0.3) & 56.4 (0.6)\\
+cluster label & 60.2 (0.3) & 61.2 (0.3)& 55.1 (0.1) & 58.7 (0.3)\\
+10d embed & 73.0 (0.2) & 72.8 (0.5)& 72 (0.3) & 73 (0.2)\\
+2d embed & 73.3 (0.3) & 73.0 (0.4) & 72.5 (0.2)& 73 (0.5) \\
best TAPT & 74.0 (1.2) & 73.6 (0.8) & 73.2 (0.9)& 73.6 (0.6)\\
+stock code & 74.2 (0.3) & 74.5 (0.4)& 72.8 (0.5)& 73.9 (0.2)\\
+invoice no. & 74.2 (0.6) & 74.5 (0.3)& 72.8 (0.3)& 73.9 (0.6)\\
DATP\textrightarrow TAPT & 74.2 (0.3) & 74.5 (0.5)& 72.8 (0.4)& 73.9 (0.4)\\
\hline
\end{tabular}
\caption{Prediction accuracy, precision, recall, and F1 score of the final XGBoost model with standard deviation (calculated from a total of 5 trial runs) using different number of features. The result is evaluated on retail dataset.}
\label{tab:table5}
\end{table}
Since the number of purchased items are labeled as 0, 1, 2, 3, 4, we also want to check the performance of the model on each label, namely, on each range of purchase numbers. The result is shown in \autoref{tab:table6}. \\
\begin{table}
\centering
\begin{tabular}{ |p{0.8cm}||p{1.2cm}|p{1.2cm}|p{1.6cm}|p{1.6cm}| }
\hline
\multicolumn{5}{|c|}{Evaluation Result of XGB based algorithms} \\
\hline
Label & TSDAE & MLM & T\textrightarrow MLM & MLM\textrightarrow T\\
\hline
0 & 75.3 (0.2) & 77.6 (0.4)& 80.2 (0.4) & 82.0 (0.2) \\
1 & 50.4 (0.2) & 52.4 (0.2) & 53.9 (0.3) & 55.4 (0.2)\\
2 & 58.7 (0.2) & 60.4 (0.2)& 60.8 (0.3) & 62.6 (0.1)\\
3 & 77.8 (0.3) & 78.1 (0.3)& 78.4 (0.4) & 79.2 (0.3)\\
4 & 79.2 (0.2) & 79.4 (0.1)& 80.0 (0.2)& 81.4 (0.3)\\
\hline
\end{tabular}
\caption{Maximum prediction accuracy achieved by DAPT followed by TAPT with different pretraining strategies, averaging 3 trial runs with standard deviation.}
\label{tab:table6}
\end{table}
\begin{table}
\centering
\begin{tabular}{ |p{2.1cm}||p{1.4cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}| }
\hline
\multicolumn{5}{|c|}{Evaluation Result of MF based algorithms} \\
\hline
Label & Precision@5 & Recall@5 & F1 score & MAP\\
\hline
vanilla MF & 23.4 (0.3) & 3.4 (0.1) & 5.9 (0.2) & 54.6 (0.1) \\
GLRM & 26.4 (0.2) & 4.8 (1.2) & 8.1 (1.4) & 57.4 (0.9)\\
Implicit MF & 33.4 (0.5) & 6.2 (1.4)& 10.5 (1.1) & 58.6 (2.4)\\
+cluster label & 35.6 (0.8) & 6.4 (0.7)& 10.8 (0.8) & 58.9 (0.8)\\
+embed similarity & \textbf{36.2} (1.0)& \textbf{6.6} (1.2)& \textbf{11.2} (1.3) & \textbf{60.2} (2.3)\\
\hline
\end{tabular}
\caption{Precision, recall, F1 score and MAP @5 evaluated on retail dataset using matrix factorization with different matrix factorization algorithms. * means the dataset has been filtered as following: any user that has purchased less than 5 items and any item that has been purchased less than 5 times are removed from the dataset for training and evaluation.}
\label{tab:table7}
\end{table}
\begin{table}
\centering
\begin{tabular}{ |p{2.0cm}||p{1.4cm}|p{1cm}|p{1.1cm}|p{1.1cm}| }
\hline
\multicolumn{5}{|c|}{Evaluation Result of MF based algorithms} \\
\hline
Label & Precision@5 & Recall@5 & F1 score & MAP\\
\hline
TSDAE @retail & 35.8 (0.7) & 6.4 (0.7)& 10.9 (0.7) & 59.2 (0.1) \\
MLM @retail & 36.3 (0.3) & 6.6 (0.6) & 11.2 (0.9) & 60.6 (0.6)\\
T\textrightarrow M @retail & 36.3 (0.8) & 6.6 (1.2) & 11.2 (1.4) & \textbf{60.4} (0.9)\\
M\textrightarrow T @retail & \textbf{36.4} (0.3) & \textbf{6.7} (0.5)& \textbf{11.2} (0.6) & 60.2 (0.4)\\
\hline
\end{tabular}
\caption{Precision, recall, F1 score and MAP @5 evaluated on retail dataset using matrix factorization with different strategies of pretraining listed in first column. The matrix factorization method used here is implicit matrix factorization with cosine similarity between sentence embeddings generated by pretrained TAPT model. }
\label{tab:table8}
\end{table}
\begin{table*}[t]
\centering
\begin{tabular}{ |p{2.6cm}||p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|}
\hline
\multicolumn{11}{|c|}{Evaluation Result of MF based algorithms} \\
\hline
& item 1 & item 2 & item 3&item 4&item 5&item 6&item 7&item 8&item 9& item 10\\
\hline
recommendation & 1605 & 266 & 1931 &1930 &749 &620 & 751 &1937 &2609 & 2612 \\
cluster label & 7 & 5& 5& 6 & 7 & 4 & 5 & 5 & 7 & 7\\
ground truth & 170 & 171 & 1203 &1205& 1253 &1410& 1482& 1483 & 1484 & N/A\\
cluster label & 7 & 11 & 1 &1&2&9&4 & 4 & 4 & N/A\\
predict correctness & \xmark & \xmark & \xmark & \xmark& \xmark& \xmark& \xmark& \xmark& \xmark & N/A\\
label correctness & \checkmark & \xmark & \xmark & \xmark& \xmark& \xmark& \xmark& \xmark& \xmark & N/A\\
\hline
\end{tabular}
\caption{Recommendation and cluster label prediction with evaluation result for a user example that the model does not perform well on.}
\label{tab:table9}
\end{table*}
As shown in \autoref{tab:table7}, recall @5 is quite low in comparison to precision @5. This is understandable because of the characteristics of the retail dataset used in this paper. Lots of the customers of this online retailer are also retailers from other industry, and they usually purchase a lot of items of different types at once. As a fact, there are costumers who bought more than 40 items. Even if the 5 recommendations made by the model are all correct, that would only give us a 5/40 = 12.5\% recall @5. Therefore, recall @5 is not a very good metric here to evaluate the performance of the matrix factorization model as the number of recommendations made here is typically much lower than the amount of items that got purchased by the customers. A better metric to look at here would be precision based, namely, f1 score or MAP(mean average precision).\\
We speculate that there is no strong interrelationship between different customers who have done purchases at this online retail. Customers tend to buy items that belong to their industry. For example, furniture retailers like to buy crews and other related components, and normally in a large number. That does not relate well with another user, say an individual buyer. The customer\_id feature whose introduction leads to a boost in model performance supports this speculation. \\
\begin{figure}[h]
\centering
\includegraphics[scale=0.42]{visualization_plots/modified_2d_vis.PNG}
\caption[Visualization of embedding space distribution of items recommended by matrix factorization model and the ground truths]
{embedding space visualization for user 0 (left) and user 1 (right)}
\label{tab:figure9}
\end{figure}
\begin{figure}[h]
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{visualization_plots/pca_clustering.png}
\caption{PCA}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{visualization_plots/tsne_clustering.png}
\caption{T-SNE}
\end{subfigure}
\caption{embedding space generated using PCA (left) and T-SNE (right), with each dot representing the embedding vector of a specific product description}
\label{tab:figure10}
\end{figure}
Two user examples on which the model does not recommend items accurately are chosen here for visualization to better understand what happened. The examples are visualized through PCA and shown in \autoref{tab:figure9}. We evaluate them based on two criteria, correctness on the predicted cluster label and predicted stock code of the item. For the left example, the details of which are shown in \autoref{tab:table9}, only 1 out of 10 cluster label is predicted correctly, and none of the stock codes. From \autoref{tab:figure9}, we observe that predicted items are mostly clustered around cluster 7 and cluster 5, while the ground truth items spread around them. This means that the recommender has picked up some patterns, and tries to focus on some dimensions of the latent space that it considers to be important. However, due to lack of modeling power, it could not fully exploit the rich information contained in the sentence embeddings. Similar pattern can also be observed from the right figure in \autoref{tab:figure9}. As a reference, \autoref{tab:figure10} show the difference between the distributions of embedding vectors visualized in 2d through PCA (left) and T-SNE (right) respectively. The result obtained by PCA is more spread out while the result obtained by T-SNE is more tightly clustered. However, due to the high dimensional nature of sentence embeddings, it remains difficult to accurately interpret the result in 2D, which is subject to visualization methods.\\
\section{Discussion and Future Work}
Experiments have shown that MF-based recommenders do not work well with sentence embeddings when they are taken directly as the recommendation algorithms. Attempts are made to combine sentence embeddings generated by PLMs as item representations with item features generated by MF model. The approaches taken include:
\begin{itemize}
\item combining top ranked recommendation results from MF recommender and PLM recommender that ranks items based on cosine similarity of their sentence embeddings.
\item taking each entry of the UI matrix as a weighted sum of the dot product of user vector and item vector from MF model and the similarity score from the PLM
\item using sentence embeddings of items purchased by other users who are considered to be similar user by MF model as auxiliary information to facilitate the MF recommender
\end{itemize}
However, none of the above-mentioned approaches lead to any observable improvement in recommendation performance. This shows that, due to the high dimensional nature of sentence embeddings and the characteristics of this Online Retail Dataset, MF is not the ideal model to be used directly as the recommendation algorithm. A model that better leverages the rich information contained within those sentence embeddings is needed. However, as suggested by LadaBERT\cite{Mao2021}, when matrix factorization is used as a model compression technique alongside with weight pruning and knowledge distillation, BERT model can be made less memory and data intensive. It also helps the model to perform better with significantly fewer training overheads. It is not covered in this paper and can be an interesting future direction.
We find that the introduction of transformer based pretrained language embedding model can boost the performance of traditional recommendation algorithms, especially on XGBoost recommender. Through carefully designed fune-tuning on RoBERTa model using TSDAE and MLM, the recommendation accuracy can be further improved. Empirical data shows that MLM followed by TSDAE achieves a better performance increase, as we speculate that MLM pretraining provides a rudimentary domain specific knowledge to the model and TSDAE further increases generalization and robustness across heterogeneous domains.
The vocabulary similarity between amazon description dataset and retail description dataset is comparably low, and this might compromise the effectiveness of domain specific pretraining. Also due to GPU memory constraints, the datasets used in this paper are small scaled in comparison to language corpus that are used to train RoBERTa. A dataset that is larger in scale and more structurally similar to the online retail dataset can be used in the future to investigate the full potential of this pretraining method.
There are more state-of-art deep learning based recommendation algorithms that could be used as the recommendation model. In this paper we choose to focus on an investigation on the effectiveness of the introduction of pre-trained language models into recommender systems using matrix factorization algorithm or XGBoost algorithm. Exploring the benefits of PLMs on deep learning based recommender systems will be an interesting future direction.
As suggested and experimented by Zhang et al.\cite{Zhang2020}, Adaptive Hybrid Masking (AHM) extends MLM by introducing a new masking
strategy. Specifically, it sets two different modes, i.e., word masking mode and phrase masking mode. The former randomly masks separate words while the latter masks domain phrases. Moreover, it can adaptively switch between the two modes based on feedback losses, enabling the model to capture word-level and phrase-level knowledge progressively. Compared with MLM, it has a higher potential to increase the model performance if it is chosen to be the fine-tuning method. Additionally, like AHM, new advanced pre-training methods can be used instead of the two that are used in this paper in the future.
\section{Conclusion}
Recent empirical improvements due to the incorporation of PLMs and thoroughly designed fine-tuning strategies into traditional recommender systems have been shown that rich, staged, and unsupervised pre-training is a vital and indispensable part of boosting model performance in the newly thriving field of e-commerce. Our major contribution is to investigate various methods of combining PLMs and fine-tuning with MF and XGBoost recommendation algorithms, and propose a fine-tuning scheme that allows the traditional model to outperform its vanilla counterpart respectively.
\clearpage
\bibliographystyle{apalike}
| {'timestamp': '2023-02-10T02:06:47', 'yymm': '2302', 'arxiv_id': '2302.04443', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04443'} | arxiv |
\section{Additional Subroutines from Fischer \etal}
\label{sec:additional_subroutines}
For reasons of formatting and convenience, we include in this section all of the coloring subroutines referred to in \Cref{algo:Delta-main} and the proof of \Cref{lem:high_degree_delta_col}.
\begin{algorithm}[H]
\caption{{\sc SlackGeneration} (node $v$)} \label{algo:slack}
Activate $v$ w.p. $1/20$ and choose a color $c_v$ from $[\Delta]$.
If $v$ is activated and none of the (activated) neighbors of $v$ have chosen $c_v$ to try, then color $v$ with color $c_v$.
\end{algorithm}
\begin{algorithm}[H]
\caption{{\sc Color-$V_*$}} \label{algo:color-v-star}
Color $V_*$ by calling the (Deg+1)-List-coloring algorithm (Algorithm~\ref{alg:LSColorReduce}).
\end{algorithm}
\begin{algorithm}[H]
\caption{{\sc Color-$\mathcal{O}$}} \label{algo:color-o}
Let $\mathcal{X}$ denotes the set of (uncolored) nodes in ordinary almost-cliques that have unit slack.
Color $\mathcal{O} \setminus \mathcal{X}$ by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}).
Color $\mathcal{X}$ by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}).
\end{algorithm}
\begin{algorithm}[H]
\caption{{\sc Color-$\mathcal{R}$}} \label{algo:color-r}
For each runaway almost-clique $C$, let $\mathcal{Y}_C$ be the set of neighbors of the escape node $e_C$ in $C$. Let $\mathcal{Y}$ denote the union of all $\mathcal{Y}_C$'s.
Color $\mathcal{R} \setminus \mathcal{Y}$, by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}).
Color $\mathcal{Y}$ by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}).
\end{algorithm}
\begin{algorithm}[H]
\caption{{\sc Color-$\mathcal{N}$}} \label{algo:color-n}
A nice almost-clique is of \emph{type 1} if $C$ contains a special node (protector or escape node). A nice almost-clique is of \emph{type 2} if it is a clique and has no special node. A nice almost-clique is of \emph{type 3} if it has a non-edge. Let $\mathcal{N}_1, \mathcal{N}_2$ and $\mathcal{N}_3$ be the set of nodes in type 1 nice almost-cliques, type 2 nice almost-cliques and type 3 nice almost-cliques respectively.
{\sc Color-$\mathcal{N}_1$} (Algorithm~\ref{algo:color-n-1}): colors $\mathcal{N}_1 \setminus (\mathcal{P}\cup \mathcal{E})$.
{\sc Color-$\mathcal{N}_2$} (Algorithm~\ref{algo:color-n-2}): colors $\mathcal{N}_2$.
{\sc Color-$\mathcal{N}_2$} (Algorithm~\ref{algo:color-n-3}): colors $\mathcal{N}_2$.
\end{algorithm}
\begin{algorithm}[H]
\caption{{\sc Color-$\mathcal{N}_1$}} \label{algo:color-n-1}
For a type 1 nice almost-clique $C$, let $\mathcal{Z}_C$ denote the neighbors of the special node of $C$ in $C$. Let $\mathcal{Z}_1$ denote the union of all $\mathcal{Z}_C$'s.
Color $\mathcal{N}_1 \setminus (\mathcal{Z}_1 \cup \mathcal{P} \cup \mathcal{E})$, by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}).
Color $\mathcal{Z}_1$ by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}).
\end{algorithm}
\begin{algorithm}[H]
\caption{{\sc Color-$\mathcal{N}_2$}} \label{algo:color-n-2}
For a type 2 nice almost-clique $C$, let $v_c$ be an arbitrary simplicial node in $C$. Let $\mathcal{Z}_2$ denote the set of all such $v_c$'s.
Color $\mathcal{N}_2 \setminus \mathcal{Z}_2$, by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}).
Color $ \mathcal{Z}_2$, by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}).
\end{algorithm}
\newpage
\begin{algorithm}[H]
\caption{{\sc Color-$\mathcal{N}_3$}} \label{algo:color-n-3}
For a type 3 nice almost-clique $C$, consider a pair $\{x_C,y_C\}$ that is a non-edge. Let $P$ be the set of all such pairs. Make a virtual graph $H$ with $P$ as the node set and there is an edge between $\{x_{C_1},y_{C_1}\}$ and $\{x_{C_2},y_{C_2}\}$ if a node of $\{x_{C_1},y_{C_1}\}$ is a neighbor of a node $\{x_{C_2},y_{C_2}\}$. The palette of a node $\{x_C,y_C\}$ is the intersection of the current palettes of the nodes $x_C$ and $y_C$.
Color $H$ by calling by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}). For a pair $\{x_C,y_C\}$ in $P$, assign the color of $\{x_C,y_C\}$ to both $x_C$ and $y_C$.
For a type 3 nice almost-clique $C$, let $\mathcal{I}_C$ denote the set of common neighbors of $x_C$ and $y_C$ in $C$, and $\mathcal{I}$ be the union of all $\mathcal{I}_C$'s.
Color $\mathcal{N}_3\setminus \mathcal{I}$ by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}).
Color $\mathcal{I}$ by calling by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce})
\end{algorithm}
\begin{algorithm}[H]
\caption{{\sc Color-$\mathcal{GP}$}} \label{algo:color-g}
For a guarded almost-clique $C$, consider the protector node $p_C$ and a non-neighbor $u_C$ of $p_C$ in $C$, and form a pair $\{u_C,p_C\}$. Let $Q$ be the set of all such pairs. Make a virtual graph $H$ with $Q$ as the node set and there is an edge between $\{u_{C_1},p_{C_1}\}$ and $\{u_{C_2},p_{C_2}\}$ if one node of $\{u_{C_1},p_{C_1}\}$ is a neighbor of $\{u_{C_2},p_{C_2}\}$. The palette of a node $\{u_C,p_C\}$ is the intersection of the palettes of the nodes $u_C$ and $p_C$.
Color $H$ by calling by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}). For pair $\{u_C,p_C\}$ in $Q$, assign the color of $(x_C,y_C)$ to both $x_C$ and $y_C$.
For a guarded almost-clique $C$, let $\mathcal{J}_C$ denote the set of common neighbors of $u_C$ and $p_C$ in $C$, and $\mathcal{J}$ be the union of all $\mathcal{J}_C$'s.
Color $\mathcal{G}\setminus \mathcal{J}$ by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce}).
Color $\mathcal{J}$ by calling by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce})
\end{algorithm}
\begin{algorithm}[H]
\caption{{\sc Color-$\mathcal{E}$}} \label{algo:color-e}
Color $\mathcal{E}$, by calling the (Deg+1)-List-Coloring algorithm (Algorithm~\ref{alg:LSColorReduce})
\end{algorithm}
\section{Introduction}
\label{sec:intro}
Graph coloring is one of the most fundamental problems in algorithms which has been studied extensively in various settings for several decades. It has been playing an especially prominent role in distributed and parallel computing, not only because of its numerous applications, but also since some variants of coloring problems naturally model typical symmetry breaking problems, as frequently encountered in decentralized systems (see, e.g., \cite{BE13} for an overview of early advances).
Parallel graph coloring has been studied since the 1980s \cite{karloff1985fast}, and nowadays $(\Delta+1)$-coloring and $(2\Delta-1)$-edge-coloring are considered among the most fundamental graph problems in the area (here and throughout the paper, $\Delta$ refers to the maximum degree of the input graph).
In this paper, we study the parallel complexity of a natural generalization of the $(\Delta+1)$-coloring problem\footnote{$(\Delta+1)$-coloring problem is to color a graph of maximum degree $\Delta$ using $\Delta+1$ colors.}, the problem of \emph{(degree+1)-list coloring} (\DILC). In the \DILC problem, for a given undirected graph $G = (V,E)$, each node has an input palette of acceptable colors of size one more than its degree, and the objective is to find a proper coloring using these palettes. While it is easy to design a simple linear-time (sequential) greedy algorithm for \DILC, the parallel and distributed complexity of \DILC is less well understood. Clearly, the problem is not easier than the $(\Delta+1)$-coloring problem and its variant the $(\Delta + 1)$-list coloring proble
\footnote{In $(\Delta + 1)$-list coloring each node has a palette of $\Delta+1$ many colors for its disposal (rather than $\deg+1$ many, as in~\DILC).}, but the challenge of dealing with nodes having color palettes of greatly different sizes seems to make the problem significantly more difficult. Still, it has been observed that by using techniques developed in \cite{FHK16,Kuhn20}, one can deterministically reduce \DILC to $(\Delta + 1)$-list coloring with only an $O(\log\Delta)$ multiplicative and $O(\log^*n)$ additive overhead in the running time (number of rounds). However the logarithmic complexity gap is still significant and until very recently, this gap has been elusive for the most efficient distributed and parallel algorithms for \DILC. The first advance (in the distributed setting) has come only very recently, when Halld{\'o}rsson, Kuhn, Nolin, and Tonoyan \cite{hknt_local_d1lc} presented a randomized $O(\log^3\log n)$-rounds distributed algorithm for \DILC in the \LOCAL distributed model, matching the state-of-the art complexity for the simpler $(\Delta+1)$-coloring problem due to Chang, Li, and Pettie \cite{CLP20}). In another very recent work, Halld{\'o}rsson, Nolin, and Tonoyan \cite{HNT22} extended the framework and showed that \DILC can be solved
in $O(\log^5\log n)$-rounds in the distributed \CONGEST model, matching the state-of-the-art complexity for the simpler $(\Delta+1)$-coloring problem in \CONGEST by Halld{\'{o}}rsson, Kuhn, Maus, and Tonoyan~\cite{HKMT21}).
In this paper we demonstrate that the \DILC problem can be efficiently solved in the \emph{Massively Parallel Computation} (\MPC) model with sublinear local space, matching the complexity of the state-of-the-art \MPC algorithms for the simpler $(\Delta+1)$-coloring and $(\Delta+1)$-list coloring problems.
\paragraph{MPC model}
The \emph{Massively Parallel Computation} (\MPC) model, introduced over a decade ago by Karloff \etal \cite{KSV10}, is a nowadays standard theoretical model for parallel algorithms. The model has been developed on the basis of its successful modeling of parallel and distributed frameworks such as MapReduce \cite{mapreduce}, Hadoop \cite{hadoop}, Dryad \cite{dryad}, and Spark \cite{spark}, and it shares many similarities to classical models of parallel computation (e.g., PRAM) and distributed models (e.g., \CONGESTEDC). In this paper, we focus on the \emph{low-space/sublinear} MPC regime, in which machines have local space $\lspace = O(n^{\phi})$ for any arbitrary constant $\phi \in (0,1)$, where $n$ is the number of nodes in the graph. This model has attracted a lot of attention recently, see, e.g., \cite{ANOY14,ASSWZ18,BKS17,BHH19,BKM20,BBDFHKU19,CC22,CFGUZ19,CDP20,CDP21,CDPsparse,CLMMOS18,GGKMR18,GKU19,GU19,GSZ11,LMOS20}. Recent works have provided many algorithms for fundamental graph problems such as connectivity, approximate matching, maximal matching, maximal independent set, and $(\Delta+1)$ coloring.
It is known that the $(\Delta+1)$-coloring algorithm due to Chang \etal \cite{CFGUZ19} can be combined with the network decomposition result of \cite{RG20} to obtain a randomized $O(\log\log\log n)$-round \MPC algorithm, which is currently the state-of-the-art bound for $(\Delta+1)$-list-coloring. Recently, Czumaj \etal \cite{CDP21} showed that this result can be derandomized, even for the list-coloring version of the problem. In this paper we show that these bounds can be matched on a sublinear local space \MPC for the more general \DILC problem.
We first show how to combine the \DILC framework for the \LOCAL model due to Halld{\'o}rsson \etal \cite{hknt_local_d1lc} with the techniques developed in earlier works on the \MPC model, to obtain a randomized \MPC algorithm for \DILC working in $O(\log\log\log n)$ rounds, w.h.p.
Then we present a more challenging part (our main contribution) and show that the $O(\log\log\log n)$-rounds randomized \MPC algorithm can be efficiently derandomized in the \MPC model.
\begin{theorem}[\textbf{Main}]
\label{thm:main:deter}
Let $\spacexp \in (0,1)$ be an arbitrary constant. There exists a deterministic algorithm that, for every $n$-node graph $G=(V,E)$, solves the \DILC problem using $O(\log\log\log n)$ rounds, in the low-space \MPC model with local space $\lspace = O(n^{\spacexp})$ and global space $O(m+n^{1+\spacexp})$.
\end{theorem}
Observe that the bound in \Cref{thm:main:deter} matches the state-of-the-art bound for the complexity of the simpler $(\Delta+1)$-coloring problem in the (low-space) \MPC model (see \cite{CFGUZ19} for the randomized bound and \cite{CDP21} for the deterministic bound). Furthermore, the recently developed framework connecting the complexity of \LOCAL and low-space \MPC algorithms (see \cite{GKU19,CDPcompstab}), provides some evidence that our upper bound cannot be asymptotically improved, unless the complexity of the $(\Delta+1)$-coloring problem is
$(\log\log n)^{o(1)}$
in the \LOCAL model. This is because \cite{GKU19,CDPcompstab} show that for a class of component stable algorithms and conditioned on the so-called 1-vs-2-cycles conjecture, no low-space \MPC algorithm can run faster than the logarithm of the complexity of \LOCAL algorithms. (Still, even conditioned on the 1-vs-2-cycles conjecture, it might be conceivable that a non-component stable randomized \MPC low-space algorithm can solve $(\Delta+1)$-coloring in $o(\log\log\log n)$ rounds, and further, we do not have any good enough \LOCAL lower bounds for coloring, and so maybe an
$(\log\log n)^{o(1)}$-rounds
\LOCAL algorithm is possible.)
Finally, notice that Roughgarden \etal \cite{RVW18} showed that proving any super-constant lower bound in the low-space \MPC for any problem in \model{P} would separate $\model{NC}^1$ from \model{P}, making any \emph{unconditional} super-constant (low-space \MPC) lower bound unlikely.
As an application of our framework for \DILC developed in \Cref{thm:main:deter}, we consider the related problem of $\Delta$-coloring graphs of maximum degree $\Delta \ge 3$ that contain no clique of size $\Delta+1$ (cf. Brooks' theorem \cite{Brooks41}). Recently, Fischer, Halld{\'o}rsson, and Maus \cite{FHM23} devised a general approach allowing to reduce in a constant number of rounds (in \LOCAL, \CONGEST, \and \CONGESTEDC) the $\Delta$-coloring problem to a constant number of instances of (degree+1)-list coloring, assuming $\Delta = \omega(\log^3 n)$ (for the \CONGESTEDC algorithm $\Delta = \omega(\log^{4+\varepsilon} n)$ is required, for a small constant $\varepsilon$). This was then extended to obtain a randomized $O(\text{poly}(\log\log n))$-rounds \LOCAL algorithm to $\Delta$-color any graph of maximum degree $\Delta \ge 3$ that does not contain a clique of size $\Delta+1$. In this paper we obtain a similar result for the \MPC model.
\begin{theorem}
\label{thm:delta_coloring}
Let $\spacexp \in (0,1)$ be an arbitrary
constant. There exists a randomized algorithm that for any $n$-node graph $G = (V,E)$ with maximum degree $\Delta \ge 3$ that does not contain a $(\Delta+1)$-clique, finds a $\Delta$-coloring of $G$ in $O(\log\log\log n)$ rounds on the low-space \MPC model with local space $\lspace =O(n^{\spacexp})$ and global space $O(m+n^{1+\spacexp})$.
\end{theorem}
In this paper, our main focus is on the proof of \Cref{thm:main:deter} and we defer its application to the proof of \Cref{thm:delta_coloring} to \Cref{sec:Delta-coloring}.
\subsection{Setting and notation}
\label{sec:setting}
For $k \in \mathbb{N}$, $[k]$ denotes the set $\{1,\ldots,k\}$. For $a,b \in \mathbb{N}$, $[a,b]$ denotes the set of integers in $\{a,a+1,\ldots,b\}$. We consider a graph
$G=(V,E)$ with $V$ as the node set and $E$ as the edge set with $|V|=n$ and $|E|=m$.
The set of neighbors of a node $v$ is denoted by $N(v)$ and the degree of a node $v$ is denoted by $d(v)$. For a node $v$, $\Psi(v)$ denotes the list of colors in the color palette of node $v$ and $p(v)$ denotes the size of $\Psi(v)$. The maximum degree of any node in $G$ is denoted by $\Delta$. As we go on coloring the nodes of the graph $G$, the graph will change and the color palettes of the nodes will also change. Often, we denote the current (rather than the input) graph by $G$. For all graphs we consider, we have $p(v)\geq d(v)+1$. For a subset $X \subseteq V$, $G[X]$ denotes the subgraph induced by $X$ and $m(X)$ denotes the number of edges in $G[X]$.
\paragraph{Degree+1 list coloring (D1LC)}
The \textbf{degree+1 list coloring (D1LC) problem} is for a given graph $G = (V,E)$ and given color palettes $\Psi(u)$ assigned to each node $u \in V$, such that $\size{\Psi(u)} \geq d(u)+1$, the objective to find a proper coloring of nodes in $G$ such that each node as assigned to a color from its color palette (and, as in proper coloring, no edge in $G$ is monochromatic).
\paragraph{Massively Parallel Computation model.}
We consider the \emph{Massively Parallel Computation} (\MPC) model, which is a parallel system with some number of machines, each of them having some local space~\lspace.
At the beginning of computation, each machine receives some part of the input, with the constraint that it must fit within its local space. In our case, for the \DILC problem, the input is a set of $n$ nodes, $m$ edges, and $n$ color palettes of total size $O(n+m)$. Hence we will require that the number of machines is $\Omega(\tfrac{n+m}{\lspace})$, for otherwise the input would not fit the system. The computation on an \MPC proceeds in synchronous rounds. In each round, each machine processes its local data and performs an arbitrary local computation on its data without communicating with other machines. At the end of each round, machines can exchange messages. Each message is sent only to a single machine specified by the machine that is sending the message. All messages sent and received by each machine in each round have to fit into the machine's local space. Hence, the total number of messages sent by any machine and received by any machine is bounded by \lspace, and the total amount of communication across the whole \MPC is bounded by \lspace times the number of machines. At the beginning of the next round, each machine can process all messages received in the previous round. When the algorithm terminates, machines collectively output the solution.
Observe that if a single machine can store the entire input, then any problem (like, e.g., \DILC) can be solved in a single round, since no communication is required. In order for our algorithms to be as scalable as possible, normally one wants to consider graph problems in the low-space regime, where local space $\lspace = n^{\spacexp}$ for any given constant $\spacexp \in (0,1)$. (There has been some research considering also the case when $\lspace = \Theta(n)$, or even when $\lspace = n^{1+\spacexp}$ (in which case one wants to study the case that $\lspace \ll m$) but we will not consider such setting in the current paper.) We will require that the number of machines is not significantly more than required,
specifically that it is $\widetilde{O}(n+\frac{m}{\lspace})$ (note that the optimal amount would be $\widetilde{O}(\frac{n+m}{\lspace})$, but our algorithm requires the ability to assign a machine to each node).
A major challenge in the design of \MPC algorithms in the low-space regime is that the local space of each machine is (possibly) not sufficient to store all the edges incident to a single node. This constraint naturally requires an \MPC algorithm to rely on extensive communication between machines, and most of the techniques known are based on some graph sparsification. It is important to note here that even in the low-space regime, the \MPC model is known \cite{GSZ11} to be stronger than the PRAM model, e.g., it is known that sorting\footnote{Here we consider sorting of $N$ objects on an \MPC with local space $N^{\gamma}$ and on $N^{1-\gamma}$ machines, for any constant $\gamma>0$.} (and in fact, many related tasks, like prefix sum computation) can be performed in a constant number of rounds, even deterministically, see \cite{GSZ11}. Observe that with this tool, we can gather nodes' neighborhoods to contiguous blocks of machines, and learn their degrees, in a constant number of rounds, and that we can assume, without loss of generality, that the input can be distributed arbitrarily on the first $\Theta(\tfrac{n+m}{\lspace})$ machines on an \MPC.
\subsection{Technical contribution}
While the \MPC model is notionally stronger than \LOCAL, writing \MPC algorithms which work in an exponentially lower number of rounds than their \LOCAL counterparts is often challenging, due to the limited local space of each machine in the \MPC model. In particular, nodes of high degree often cannot hope to collect their $2$-hop neighborhood in the \MPC model, and this renders many common subroutines in \LOCAL algorithms challenging (for example, in the setting of coloring, computing an almost-clique decomposition).
We overcome this technical difficulty using a deterministic recursive sparsification approach similar to \cite{CDP20,CDP21} where we repeatedly partition an instance of \DILC with maximum degree $\Delta$ into $n^\delta$ \DILC instances, each with maximum degree $\Delta / n^\delta$. Here $\delta \in (0,1)$ is a constant less than $\phi$ to be fixed later and $\phi$ is our local space parameter, i.e., $s=O(n^\phi)$. All but one of these instances are \emph{valid} \DILC instances and so can be solved immediately (using this recursive sparsification if the degree is still too high), and the final instance can only be solved when it is determined which colors are unused in the other instances. In this way, we can reduce the maximum degree of the \DILC instances which we have to solve to an arbitrarily small polynomial in $n$.
For \DILC instances with degrees between $\log^7 n$ and some arbitrarily small polynomial $n^\delta$, we show that a recent algorithm of \cite{hknt_local_d1lc} can be efficiently simulated in the \MPC setting using information only in the $2$-hop neighborhood of each node. Then, we show that the randomized subroutines from the algorithm of \cite{hknt_local_d1lc} can be efficiently derandomized, as they all satisfy a particular set of properties. The derandomization in this paper uses pseudorandom generators (PRGs) combined with the method of conditional expectations. The main difficulty is that PRGs restricted by the local space requirement of low-space \MPC will fail on some non-trivial proportion of nodes even if the base randomized procedure succeeds with high probability. Furthermore, in general this can cause a chain reaction of nodes failing to meet the success requirements of the randomized procedure. To overcome this difficulty, we formalize in \Cref{prng-derandomizable} a collection of properties that allow us to fully derandomize a procedure the PRG, which we prove in \Cref{lem:fullderand}. This lemma may be of independent interest as a powerful black-box derandomization technique in \MPC.
For instances with degree lower than $\log^7 n$, we can use an existing algorithm of Czumaj et al. \cite{CDP21}.
\paragraph{$\Delta$-coloring.}
The \DILC problem has been studied extensively in distributed and parallel setting largely thanks to its use in the designing of algorithms for other coloring problems. For example, \DILC has been frequently used as a subroutine in $(\Delta + 1)$-coloring algorithms (in the post-shattering step). Fischer \etal \cite{FHM23} observed recently that one can solve the $\Delta$-coloring problem using algorithms for \DILC: the approach due to Fischer \etal relies on a reduction from $\Delta$-coloring to a constant number of D1LC instances. We combine our \DILC \MPC algorithm from \Cref{thm:main:deter} with the reduction from \cite{FHM23} to obtain an $O(\log\log\log n)$-rounds algorithm for the $\Delta$-coloring problem (\Cref{thm:delta_coloring}). In particular, we show that the delicate almost-clique decomposition and classification required in the $\Delta$-coloring algorithm of Fischer \etal \cite{FHM23} can be performed in $O(1)$ rounds of sublinear \MPC. While the \CONGEST result of Fischer \etal \cite{FHM23} holds only for $\Delta = \omega(\log^3 n)$, our result does not require this restriction (i.e., holds for all values of $\Delta \geq 3$ provided the graph is $\Delta$-colorable, that is, provided it does not contain a $(\Delta+1)$-clique), exploiting the ability of \MPC to perform ``graph exponentiation'' when the maximum degree is low. (Because of space constraints, the analysis is deferred to \Cref{sec:Delta-coloring}.)
\subsection{Related work}
Our work continues a long line of research studying the parallel and distributed computing of graph coloring problems. For the references to earlier work on distributed coloring algorithms we refer to the monograph by Barenboim and Elkin \cite{BE13} (see also the influential papers by Linial \cite{Linial87,Linial92}). We will discuss here only more recent advances (and final results) for the four most relevant coloring problems, $(\Delta+1)$-coloring, $(\Delta+1)$-list-coloring, \DILC, and $\Delta$-coloring, leaving more detailed discussion and more references to the papers listed below. After extensive research in distributed computing for the $(\Delta+1)$-coloring problem, we understand its complexity for the \LOCAL, \CONGESTEDC, and also for the \MPC model, quite well. For \CONGESTEDC (and also for \MPC with linear memory, $\lspace = O(n)$), we know now how to solve $(\Delta+1)$-coloring in a constant number of rounds, see \cite{chang2018optimal,CDP20}. For the \LOCAL model, after a very long line of research, the current state of the art upper bound for randomized algorithm is by Ghaffari and Kuhn \cite{GK21} (see also \cite{RG20}), which achieves $O(\log^3\log n)$ round complexity w.h.p. There is no deterministic $o(\log n)$-round \LOCAL algorithm known.
For the low-space \MPC, it is known that the $(\Delta+1)$-coloring algorithm due to Chang et al. \cite{CFGUZ19} can be combined with the network decomposition result of \cite{RG20} to obtain a randomized $O(\log\log\log n)$-round \MPC algorithm, which is currently the state-of-the-art bound for the problem; this result was derandomized by Czumaj \etal \cite{CDP21}. Furthermore, all algorithms mentioned above for $(\Delta+1)$-coloring can be extended to solve also $(\Delta+1)$-list-coloring.
For the \DILC problem, which is a generalization of $(\Delta+1)$-coloring and $(\Delta+1)$-list-coloring, there have not been many comparable bounds until the very recent work of Halld{\'o}rsson \etal \cite{hknt_local_d1lc}. In \cite{hknt_local_d1lc}, by significantly extending the earlier approached for $(\Delta+1)$-coloring (in particular, to allow to efficiently deal with nodes of various degrees), it is shown that \DILC can be solved in $O(\log^3\log n)$ rounds in \LOCAL, w.h.p.
As a byproduct, the framework of Halld{\'o}rsson \etal \cite{hknt_local_d1lc} can be incorporated into a constant-round \MPC algorithm assuming the local \MPC space is slightly \emph{superlinear}, i.e., $O(n \log^4n)$ \cite[Corollary 2]{hknt_local_d1lc}.
A similar bound has been recently obtained for
the \CONGEST model in \cite{HNT22}, solving \DILC in $O(\log^5\log n)$ \CONGEST rounds, w.h.p.
We make extensive use of the framework laid out by Halld{\'o}rsson \etal \cite{hknt_local_d1lc} in their algorithm for \LOCAL in the design of our \DILC algorithm.
Our work relies also on some sparsification and derandomization techniques developed for parallel and distributed coloring algorithms.
With respect to derandomization,
our techniques are closely related to the recent papers by Czumaj \etal \cite{CDP20,CDP21}. The central approach underlying our analysis of derandomization using a pseudorandom generator has been used extensively before, though in the context of \MPC algorithms it has been used only recently in \cite{CDP21}.
In comparison to the perhaps more famous coloring problems listed above, relatively little has been written about the problem of $\Delta$-coloring in the parallel and distributed setting. In the \LOCAL model, the problem was first discussed in a paper by Panconesi and Srinivasan \cite{local_nature_delta_coloring}, and that algorithm was recently revisited and improved by Ghaffari \etal \cite{DBLP:journals/dc/GhaffariHKM21}.
In distributed models with communication bandwidth restrictions (and so, the setting closer to the model we consider here), the first breakthrough came only recently, in a paper by Fischer, Halld{\'o}rsson, and Maus \cite{FHM23}. They gave a \CONGEST algorithm which gives a $\Delta$-coloring of the graph in $O(\poly \log \log n)$ rounds if $\Delta = \omega(\log^3 n)$, which decreases to $O(\log^* n)$ rounds if $\Delta = \omega(\log^{21} n)$. Their result for large values of $\Delta$ was a substantial improvement over the state-of-the-art in any distributed model ($O(\log n)$ rounds previously being the best known), and combined with the result given by \cite{DBLP:journals/dc/GhaffariHKM21} for sub-polylogarithmic values of $\Delta$, they also achieved a $O(\poly\log\log n)$ round algorithm for $\Delta$-coloring in the \LOCAL model.
We are not aware of any direct prior work on $\Delta$-coloring in any model of parallel computing. An $O(\log n)$ round algorithm for \PRAM follows straightforwardly from the $O(\log n)$-round MIS algorithm of Luby \cite{Luby86}: one can find an MIS and defer coloring those nodes, the remaining nodes all gain at least $1$ slack, and therefore form a $(\Delta+1)$-coloring instance. This algorithm can be transformed into a $O(\log n)$ round \MPC algorithm, using well-known results relating to the simulation of \PRAM algorithms in \MPC. We note that the complexity of our algorithm represents a double-exponential improvement over this.
\hide{\subsection*{Notations}
\begin{itemize}
\item $G(V,E)$-- Graph with $n$ nodes.
\item $d_{G}(v)$--- The degree of $v$ in $G$.
\item $N_{G}(v)$--- The neighborhood of $v$ in $G$.
\item $G[W]$--- The subgraph of $G$ induced by $W \subseteq V$.
\item $O(n^\spacexp)$--- The space bound of each machine \peter{I changed this because the parts from \cite{CDP20} already use $\delta$ for something else, and we'll need to compare $\delta$ and $\eps$ later.}
\end{itemize}
}
\input{parts/preliminaries}
\input{parts/d1lc_randomised}
\input{parts/d1lc_deterministic}
\input{parts/Coloring-delta}
\bibliographystyle{alpha}
\section{Proof of Lemma~\ref{lem:derandomizable-subroutines}}
\label{sec:proof-of-4-2}
We conclude with the proof of \Cref{lem:derandomizable-subroutines}: that the randomized coloring subroutines from the algorithm of Halld{'o}rsson \etal are normal $(O(1),\Delta_G)$-round distributed procedures.
\begin{proof}
First, we note that at the start of any algorithm, nodes may be assumed to have information about which sets they are members of ($V_{\text{sparse}}$, $V_{\text{uneven}}$, etc.), as by earlier simulation arguments ({see \Cref{obs:spse}}) this can be computed in $O(1)$ rounds in \LOCAL (and \MPC, for low enough degree). We may also assume that nodes have information about the value of any of the parameters in \Cref{def:parameters} for themselves and any of their neighbours ({see \Cref{lem:computing_parameters}}). Note that this is, in total, $O(\Delta_{G}^2)$ words of information for each node $v$: a constant number of words for each parameter, $O(\Delta_{G})$ words for set membership, multiplied by the number of neighbors of $v$, which is $O(\Delta_{G})$.
We look at each in turn:
\begin{itemize}
\item \textbf{\sc TryRandomColor}: The procedure takes $O(1)$ rounds of \LOCAL. Nodes need no other words of input information. Nodes only use information from their neighbors, and each node uses $O(\log \Delta_{G})$ random bits to select a color from its palette. Note that the computation is $O(\Delta_{G})$. The output information is either a color with which $v$ has permanently colored itself, or {\sc Fail} if it does not color itself: this is clearly $O(\Delta_{G})$ words of information. The success property is that the slack of a node increases from $c \cdot d_{G}(v)$ for some constant $c$ to $2 \cdot d_{G}(v)$ \cite[Lemma~26]{hknt_local_d1lc}. This is computable in time linear in the degree of a node and based only on the output of the immediate neighbors of a node. The property succeeds for each node with probability $p=\exp(\Omega(s(v)))$, and by our precondition, $s(v)$ is at least polylogarithmic so this is with high probability. Nodes deferring does not affect the algorithm, since this creates at least as much as slack as it would if all nodes participated.
\item \textbf{\sc GenerateSlack}: This takes $O(1)$ rounds of \LOCAL and nodes need no other information at the beginning of the procedure. During the procedure, nodes only use information from their neighbors and $\widetilde{O}(\Delta_{G})$ random bits (to determine whether the node is sampled and if so, what color is attempted). The output of the procedure is either the color with which $v$ permanently colored itself, or {\sc Fail}. The success of the procedure is quite complicated: depending on the type of node, a different guarantee on the eventual slack is required. We note, however, that these guarantees all succeed with high probability and are computable using only information in the immediate neighborhood of $v$ \cite[Lemmas~10, 11, 13, 15, 17, 18]{hknt_local_d1lc}. Deferring nodes creates temporary slack and so does not hurt the procedure.
\item \textbf{\sc PutAside}: The algorithm consists of $1$ round of \LOCAL, and nodes need no additional information. During the procedure, nodes only use information from their neighbours, and use $O(\polylog(n)) \in O(\Delta_{G})$ (by construction) random bits to independently sample nodes into $S_C$. The output of the procedure is one word (whether $v \in P_C$). A node succeeds if the put-aside set of the almost-clique containing it (say $C$) satisfies $\size{P_C} = \Omega(\ell^2)$ for some polylogarithmic $\ell$ \cite[Lemma~5]{hknt_local_d1lc}. This can be checked using the $2$-hop neighborhood of $v$ because the diameter of $C$ is at most $2$. The property succeeds with high probability. If we defer nodes then this can hurt the size of the put-aside per se, however this is not an issue: the fact that we are deferring nodes creates the necessary slack that the put-aside set would be creating anyway. We have to be careful however, to color the deferred nodes \emph{after} the put-aside set, otherwise we lose the property that the put-aside sets in different almost-cliques are independent.
\item \textbf{\sc SynchColorTrial}: This procedure takes $1$ round of \LOCAL. Nodes need no additional information about their neighborhood beforehand. Nodes only use information from their immediate neighbors during the procedure (since leader $x_C$ neighbors all nodes in the set of inliers $I_C$), and in the worst case (i.e.~if the node in question is $x_C$), nodes need $\widetilde{O}(\Delta_{G})$ random bits to permute their palette. The output of the procedure for a node $v \in I_C$ for some $C$ is either a color in $\Psi_v$ or {\sc Fail}. The success property for the procedure is that, for the almost-clique $C$ that $v$ is in, the number of nodes that return {\sc Fail} is bounded by $O(t)$, where $t$ is some polylogarithmic value \cite[Lemma~7]{hknt_local_d1lc}. This happens with high probability ($\exp(-t)$). Nodes dropping out can only help the algorithm, as they are not counted as nodes which fail to be colored.
\item \textbf{\sc SlackColor}: There are three parts to the algorithm. First, {\sc TryRandomColor} is called in order to amplify the slack of each node (which is linear in the degree: a prerequisite of {\sc SlackColor}). Then two loops of {\sc MultiTrial} instances are run.\\
The $O(1)$ calls to {\sc TryRandomColor} are normal $(O(1), \Delta_{G})$-distributed procedures by the item above.\\
Each iteration of the first for-loop of executions of {\sc MultiTrial} takes $O(1)$ \LOCAL rounds. Nodes need no additional input information. During the execution of the loop, nodes only use information from their immediate neighbors, and only use $O(\Delta_{G})$ random bits to select a subset of their palette. The output of the procedure for $v$ is either a color in $\Psi_v$ or {\sc Fail}, which is one word. Nodes succeed (with high probability) if $d(v) \le \slack{v}/\min(2^{x_i},\rho^\kappa)$ \cite[Lemma~27]{hknt_local_d1lc}. This is, again, computable using only the output of the node and output information of the immediate neighborhood. Nodes deferring reduce the degree (temporarily), and so they cannot cause the property to be unsatisfied.\\
The second for-loop of {\sc MultiTrial} instances are normal distributed procedures for the same reason: the success property is $d(v) \le \slack{v}/\min(\rho^{(i+1) \cdot \kappa},\rho)$, and also satisfies the requirements of \Cref{prng-derandomizable}. So, overall \textbf{\sc SlackColor} consists of a sequence of $O(\log^* \Delta)$ normal $(O(1), \Delta_G)$-round distributed procedures.\qedhere
\end{itemize}
\end{proof}
\section{Derandomization of Algorithm for Low-Degree Instances}
\section{Derandomization for Low-Degree}
\label{sec:deterministic_d1lc}
In this section, we give a deterministic \MPC algorithm, for \DILC for a graph $G$ with maximum degree at most $n^{7\delta}$, that takes $O(\log \log \log n)$ rounds on an \MPC with $\lspace=O(n^\phi)$ and $O(n^{1+\phi})$ global space~\footnote{The number of edges is always at most $O(n^{1+\phi})$.}. This is possible due to the simulation of deterministic steps in \cite{hknt_local_d1lc} when the maximum degree is at most $\sqrt{\lspace}$ as discussed in \Cref{sec:randomized-d1lc} and the fact that the randomized steps in \cite{hknt_local_d1lc} can be efficiently derandomized. In particular, we will discuss the derandomization of \textsc{TryRandomColor}(\Cref{alg:try_random_color}), \textsc{SlackColor} (\Cref{alg:slack_color}), {\sc GenerateSlack} (\Cref{alg:generate_slack}), \textsc{PutAside} (\Cref{alg:put-aside}) and \textsc{SyncColorTrial} (\Cref{alg:synch}) by proving that all of them are $(O(\log ^*n),\Delta)$-round distributed procedures and arguing that such procedures can be efficiently derandomized by using pseudorandom generators. We can show that, in one iteration with $O(\log^* n)$ rounds, the number of uncolored nodes will be reduced by a factor of $n^{\Omega(1)}$ (that are deferred to be colored in the later iterations). So, by repeating the process for $O(1)$ iterations, we have $O(\log n)$ nodes left to be colored. Another thing to note that, we are considering the algorithm of \Cref{sec:overview_of_hknt} here when the degree of the nodes is at least $\log ^7 n$. So, we always defer the coloring of the nodes whose degree is at most $\log ^7 n$. So, at the end we have a graph (of at most $n$ nodes) having maximum degree $\log ^7 n$. Note that this can be colored in $O(\log \log \log n)$ rounds due to a result of \cite{CDP21}.
In this section, graph $G$ is often is not clear from the context. So, we use $n_G$ to denote the number of nodes in $G$. For a node $v$, $N_G(v)$ denote the set of neighbors of $v$ in $G$ and $d_G(v)$ denotes the degree of $v$ in $G$. We denote the maximum degree of any node in $G$ by $\Delta_G$. For a node $v$ and $c \in \mathbb{N}$, $N^c_G(v)$ denotes the nodes in the $c$-hop neighborhood of $v$.
\subsection{Normal distributed procedures}
First, we define the notion of $(c,\Delta_G)$-round randomized distributed procedure.
\begin{definition}\label{prng-derandomizable}
A \emph{normal $(c,\Delta_G)$-round distributed procedure} running on a graph $G$, of maximum degree \emph{at most} $\Delta_G$, is a procedure in the randomized \LOCAL model satisfying the following criteria:
\begin{itemize}
\item The procedure takes $c$ rounds of \LOCAL.
\item At the beginning of the procedure, nodes $v$ have $O(\Delta_G^c)$-word sets of input information $\textsc{In}_v$ associated with them.
\item During the procedure, nodes only use information from their $c$-hop neighborhood (i.e. from $\textsc{In}_v \cup \bigcup_{u\in N^c_G(v)} \textsc{In}_u\}$ and $O(\Delta_G^{2c})$ random bits, and perform $O(\Delta_G^{8c})$ computation.
\item The output of the procedure is a new $O(\Delta_G^c)$-word set of output information $\textsc{Out}_v$ for each node.
\item The procedure has a `success property' (computable with $O(\Delta_G^{8c})$ computation) that determines whether it has been successful for a particular node, based on the output information of that node and its $c$-hop neighborhood (formally, $\textsc{SP} : \textsc{Out}_v \cup \bigcup_{u\in N^c_G(v)} \textsc{Out}_u \rightarrow \{T,F\}$).
\item At the end of the procedure, then for any node $v$, $$\Prob{\textsc{SP}(\textsc{Out}_v \cup \bigcup_{u\in N^c_G(v)} \textsc{Out}_u ) = T} \ge 1-\frac{1}{2n_G}.$$
\item Each success property is such that `deferring' nodes to be dealt with later cannot cause the property to become unsatisfied. That is, if we denote by $\textsc{Defer}_w$ a special status indicating that $w$ is to be deferred (which is not to be conferred by the procedure itself), then adding $\textsc{Defer}_w$ to $w$'s output information should not cause any other nodes' success properties to become unsatisfied. Formally:
$$
\textsc{SP}\left(\textsc{Out}_v \cup \bigcup_{u\in N^c_G(v)} \textsc{Out}_u \right) = T
\Rightarrow \forall w\in N^c_G(v), \textsc{SP}\left(\textsc{Out}_v\cup \{\textsc{Defer}_w\} \cup \bigcup_{u\in N^c_G(v)} \textsc{Out}_u \right) = T\enspace.
$$
\end{itemize}
\end{definition}
In the following lemma, we show that a number of randomized subroutines of \cite{hknt_local_d1lc} are in fact normal $(O(1), \Delta_G)$-round distributed procedures. Under these circumstances, we can use a pseudorandom generator, combined with the method of conditional expectations, to derandomize the algorithm. The details of PRG and the derandomization will be discussed in \Cref{sec:derand}.
\begin{lemma}
\label{lem:derandomizable-subroutines}
The subroutines
{\sc TryRandomColor} (\Cref{alg:try_random_color}),
{\sc GenerateSlack} (\Cref{alg:generate_slack}),
{\sc PutAside} (\Cref{alg:put-aside}),
and {\sc SynchColorTrial} (\Cref{alg:synch})
are all normal $(O(1), \Delta_{G})$-round distributed procedures. The subroutine {\sc SlackColor} (\Cref{alg:slack_color}) consists of a sequence of $O(\log^* \Delta)$ normal $(O(1), \Delta_G)$-round distributed procedures.
\end{lemma}
\begin{proof}
First, we note that at the start of any algorithm, nodes may be assumed to have information about which sets they are members of ($V_{\text{sparse}}$, $V_{\text{uneven}}$, etc.), as by earlier simulation arguments ({see \Cref{obs:spse}}) this can be computed in $O(1)$ rounds in \LOCAL (and \MPC, for low enough degree). We may also assume that nodes have information about the value of any of the parameters in \Cref{def:parameters} for themselves and any of their neighbours ({see \Cref{lem:computing_parameters}}). Note that this is, in total, $O(\Delta_{G}^2)$ words of information for each node $v$: a constant number of words for each parameter, $O(\Delta_{G})$ words for set membership, multiplied by the number of neighbors of $v$, which is $O(\Delta_{G})$.
We look at each in turn:
\begin{itemize}
\item \textbf{\sc TryRandomColor}: The procedure takes $O(1)$ rounds of \LOCAL. Nodes need no other words of input information. Nodes only use information from their neighbors, and each node uses $O(\log \Delta_{G})$ random bits to select a color from its palette. Note that the computation is $O(\Delta_{G})$. The output information is either a color with which $v$ has permanently colored itself, or {\sc Fail} if it does not color itself: this is clearly $O(\Delta_{G})$ words of information. The success property is that the slack of a node increases from $c \cdot d_{G}(v)$ for some constant $c$ to $2 \cdot d_{G}(v)$ \cite[Lemma~26]{hknt_local_d1lc}. This is computable in time linear in the degree of a node and based only on the output of the immediate neighbors of a node. The property succeeds for each node with probability $p=\exp(\Omega(s(v)))$, and by our precondition, $s(v)$ is at least polylogarithmic so this is with high probability. Nodes deferring does not affect the algorithm, since this creates at least as much as slack as it would if all nodes participated.
\item \textbf{\sc GenerateSlack}: This takes $O(1)$ rounds of \LOCAL and nodes need no other information at the beginning of the procedure. During the procedure, nodes only use information from their neighbors and $\widetilde{O}(\Delta_{G})$ random bits (to determine whether the node is sampled and if so, what color is attempted). The output of the procedure is either the color with which $v$ permanently colored itself, or {\sc Fail}. The success of the procedure is quite complicated: depending on the type of node, a different guarantee on the eventual slack is required. We note, however, that these guarantees all succeed with high probability and are computable using only information in the immediate neighborhood of $v$ \cite[Lemmas~10, 11, 13, 15, 17, 18]{hknt_local_d1lc}. Deferring nodes creates temporary slack and so does not hurt the procedure.
\item \textbf{\sc PutAside}: The algorithm consists of $1$ round of \LOCAL, and nodes need no additional information. During the procedure, nodes only use information from their neighbours, and use $O(\polylog(n)) \in O(\Delta_{G})$ (by construction) random bits to independently sample nodes into $S_C$. The output of the procedure is one word (whether $v \in P_C$). A node succeeds if the put-aside set of the almost-clique containing it (say $C$) satisfies $\size{P_C} = \Omega(\ell^2)$ for some polylogarithmic $\ell$ \cite[Lemma~5]{hknt_local_d1lc}. This can be checked using the $2$-hop neighborhood of $v$ because the diameter of $C$ is at most $2$. The property succeeds with high probability. If we defer nodes then this can hurt the size of the put-aside per se, however this is not an issue: the fact that we are deferring nodes creates the necessary slack that the put-aside set would be creating anyway. We have to be careful however, to color the deferred nodes \emph{after} the put-aside set, otherwise we lose the property that the put-aside sets in different almost-cliques are independent.
\item \textbf{\sc SynchColorTrial}: This procedure takes $1$ round of \LOCAL. Nodes need no additional information about their neighborhood beforehand. Nodes only use information from their immediate neighbors during the procedure (since leader $x_C$ neighbors all nodes in the set of inliers $I_C$), and in the worst case (i.e.~if the node in question is $x_C$), nodes need $\widetilde{O}(\Delta_{G})$ random bits to permute their palette. The output of the procedure for a node $v \in I_C$ for some $C$ is either a color in $\Psi_v$ or {\sc Fail}. The success property for the procedure is that, for the almost-clique $C$ that $v$ is in, the number of nodes that return {\sc Fail} is bounded by $O(t)$, where $t$ is some polylogarithmic value \cite[Lemma~7]{hknt_local_d1lc}. This happens with high probability ($\exp(-t)$). Nodes dropping out can only help the algorithm, as they are not counted as nodes which fail to be colored.
\item \textbf{\sc SlackColor}: There are three parts to the algorithm. First, {\sc TryRandomColor} is called in order to amplify the slack of each node (which is linear in the degree: a prerequisite of {\sc SlackColor}). Then two loops of {\sc MultiTrial} instances are run.\\
The $O(1)$ calls to {\sc TryRandomColor} are normal $(O(1), \Delta_{G})$-distributed procedures by the item above.\\
Each iteration of the first for-loop of executions of {\sc MultiTrial} takes $O(1)$ \LOCAL rounds. Nodes need no additional input information. During the execution of the loop, nodes only use information from their immediate neighbors, and only use $O(\Delta_{G})$ random bits to select a subset of their palette. The output of the procedure for $v$ is either a color in $\Psi_v$ or {\sc Fail}, which is one word. Nodes succeed (with high probability) if $d(v) \le \slack{v}/\min(2^{x_i},\rho^\kappa)$ \cite[Lemma~27]{hknt_local_d1lc}. This is, again, computable using only the output of the node and output information of the immediate neighborhood. Nodes deferring reduce the degree (temporarily), and so they cannot cause the property to be unsatisfied.\\
The second for-loop of {\sc MultiTrial} instances are normal distributed procedures for the same reason: the success property is $d(v) \le \slack{v}/\min(\rho^{(i+1) \cdot \kappa},\rho)$, and also satisfies the requirements of \Cref{prng-derandomizable}. So, overall \textbf{\sc SlackColor} consists of a sequence of $O(\log^* \Delta)$ normal $(O(1), \Delta_G)$-round distributed procedures.\qedhere
\end{itemize}
\end{proof}
\subsection{PRGs and derandomization}\label{sec:derand}
A \emph{Pseudorandom Generator (PRG)} is a function that takes a short \emph{random seed} and produces a longer string of \emph{pseudorandom} bits, which are computationally indistinguishable from truly random bits. We use the following definition from \cite{Vadhan12} for indistinguishability
\begin{definition
[Definition 7.1 in \cite{Vadhan12}]
\label{def:computational-indistinguishability}
Random variables $X$ and $Y$ taking values in $\{0,1\}^m$ are $(t,\eps)$ \textbf{indistinguishable} if for every non-uniform algorithm $T:\{0,1\}^m\rightarrow \{0,1\}$ running in time at most $t$, we have $|\Pr[T(X)=1]-\Pr[T(Y)=1]| \le \eps$.
\end{definition}
Let $U_k$ denote a random variable generated uniformly at random from $\{0,1\}^k$. Then pseudorandom generators are defined as follows:
\begin{definition}[PRG, Definition 7.3 in \cite{Vadhan12}]
\label{def:PRG}
A deterministic function $\mathcal{G}:\{0,1\}^d \to \{0,1\}^m$ is an \textbf{$(t,\eps)$ pseudorandom generator (PRG)} if (1) $d < m$, and (2) $\mathcal{G}(U_d)$ and $U_m$ are $(t,\eps)$ indistinguishable
\end{definition}
A simple application of the probabilistic method can show the existence of PRGs with optimal parameters:
\begin{proposition}[Proposition 7.8 in \cite{Vadhan12}]
\label{prop:perfect-PRG}
For all $t \in \mathbb{N}$ and $\eps>0$, there exists a (non-explicit) $(t,\eps)$ pseudorandom generator $\mathcal{G}: \{0,1\}^d \to \{0,1\}^t$ with seed length $d = \Theta(\log t+\log(1/\eps))$.
\end{proposition}
As shown in \cite{CDPcompstab}, such a PRG can be computed using relatively low space (but exponential computation).
\begin{lemma}[Lemma 35 of \cite{CDPcompstab}, arXiv version]
\label{lem:prg-alg}
For all $t \in \mathbb{N}$ and $\eps>0$, there exists an algorithm for computing the $(t,\eps)$ PRG of \Cref{prop:perfect-PRG} in time $\exp(poly(t/\eps))$ and space $poly(t/\eps)$.
\end{lemma}
For any integer $k\in \mathbb{N}$, let $G^k$ be the $k$-power of $G$, that is, $G^k$ is the graph having the same node set as $G$ and any pair of nodes at a distance at most $k$ in $G$ form an edge in $G^k$.
\begin{lemma}\label{lem:phasederand}
There is a constant $C$ such that, given an $O(\Delta_G^{8c})$-coloring of $G^{4c}$, any normal $(c,\Delta_G)$-round distributed procedure on a graph $G$ can be derandomized in $O(1)$ round of \MPC, using $\lspace=O(\Delta_G^{cC})$ space per machine and global $O(n_G \Delta_G^{cC})$, with the following properties:
\begin{itemize}
\item At most $\frac 12+n_G \Delta_G^{-11c}$ nodes are deferred.
\item All non-deferred nodes $v$ satisfy the success property.
\end{itemize}
\end{lemma}
\begin{proof}
First, for each node $v$ we collect the input information of its $8c$-hop neighborhood ($\textsc{In}_v \cup \bigcup_{u\in N^c_G(v)} \textsc{In}_u$) to a dedicated machine. This takes $c$ rounds, and requires $O(\Delta_G^{8c} \cdot \Delta_G^c) = O(\Delta_G^{11c})$ space per machine and $O(n_G \Delta_G^{11c})$ global space. Our aim is then to simulate the procedure using randomness produced by the $(\Delta_G^{11c}, \Delta_G^{-11c})$ PRG implied by \Cref{prop:perfect-PRG}. This PRG has seed length $d = \Theta(\log \Delta_G)$ and requires $poly(\Delta_G^{11c})$ space to construct and store. We choose $C$ so that this $poly(\Delta_G^{11c})$ term is $O(\Delta_G^{cC})$.
The PRG, when evaluated on a seed, produces a string of $\Delta_G^{11c}$ pseudorandom bits. We use the provided $O(\Delta_G^{8c})$-coloring of $G^{4c}$ to split this string into the input randomness for each node. By definition of a normal $(c,\Delta_G)$-round distributed procedure, each node requires $O(\Delta_G^{2c})$ random bits, and we provide a node colored $i$ in the $O(\Delta_G^{8c})$-coloring with the $i^{th}$ chunk of $O(\Delta_G^{2c})$ bits from the PRG's output. This means that any pair of nodes within distance $4c$ receive disjoint chunks of pseudorandom bits.
The output of the PRG under a random seed is $(\Delta_G^{11c},\Delta_G^{-11c})$ indistinguishable from a uniform distribution. Consider the process of simulating the procedure for all nodes within distance $c$ of a node $v$, and then evaluating the success property $\textsc{SP}(\textsc{Out}_v \cup \bigcup_{u\in N^c_G(v)} \textsc{Out}_u ) $. By definition of a normal $(c,\Delta_G)$-round distrib\-ut\-ed procedure, this combined process requires $O(\Delta_G^{9c})$ computation, and depends on the input information and randomness of nodes up to distance $2c$ from $v$ (and note that all nodes within this radius receive different chunks of the PRG's output as their pseudorandom bits). This combined process can therefore be run on one \MPC machine. Furthermore, it can be considered a non-uniform algorithm using at most $\Delta_G^{9c}$ computation, and so is `fooled' by the PRG. This means that the output ($T$ or $F$, indicating whether the success property is satisfied) at $v$ differs with probability at most $\Delta_G^{-11c}$ from what it would be under full randomness. That is, the output will be $F$ with probability at most $\frac{1}{2n_G}+ \Delta_G^{-11c}$.
The expected number of nodes who do not satisfy the success property, when simulating the procedure using the PRG with a random seed, is therefore at most $\frac 12+n_G \Delta_G^{-11c}$. Since this value is an aggregate of functions computable by individual machines, using the method of conditional expectations (as implemented for low-space MPC in \cite{CDPsparse,CDP20}) we can deterministically select a seed for the PRG for which the number of nodes which do not satisfy the success property is at most its expectation (i.e. at most $\frac 12+n_G \Delta_G^{-11c}$), in $O(1)$ rounds.
Then, we simply mark the nodes which do not satisfy the success property as deferred. In doing so, we meet the conditions of the lemma.
\end{proof}
\begin{lemma}\label{lem:fullderand}
There is a constant $C$ such that, given an $O(\Delta_G^{8c})$-coloring of $G^{4c}$, any normal $(c,\Delta_G)$-round distributed procedure on a graph $G$ with $\Delta_G \le n^{7\delta}$ can be derandomized in $O(1)$ rounds of \MPC, using $\lspace=O( n^{7\delta cC})$ space per machine and global space $O(n_G \cdot n^{7\delta cC})$, with all nodes satisfying the success condition of the procedure.
\end{lemma}
\begin{proof}
We repeatedly apply \Cref{lem:phasederand} to the graph induced by the deferred nodes, in each case using $\Delta_G = n^{7\delta}$ as an upper bound on the maximum degree (even though the actual maximum degree may be significantly lower). After $r$ iterations of this, the number of remaining deferred nodes is at most $\frac 34 + n\cdot n^{-11cr\cdot7\delta}$. Taking $r=1/\delta$ (which is $O(1)$), we then have fewer than $1$ remaining deferred node, i.e.~all nodes satisfy the success condition.
\end{proof}
\begin{lemma}\label{lem:phasecolor}
The algorithm of \cite{hknt_local_d1lc} for \DILC for nodes of degree at least $\log^7 n$, running on a graph $G$, of maximum degree \emph{at most} $n^{7\delta}$, can be derandomized in $O(\log^* n)$ rounds. The process uses $O(n^{7\delta cC})$ space per machine and $O(n_G \cdot n^{7\delta cC})$ global space, where $C$ is as in \Cref{lem:phasederand}.
\end{lemma}
\begin{proof}
We use $\Delta_G = n^{7\delta}$ as an upper bound on the maximum degree $G$, and first compute the $O(\Delta_G^{8c})$-coloring of $G^{4c}$ required for \Cref{lem:fullderand}. This can be done in $O(\log^* n)$ rounds by simulating Linial's \cite{Linial92} deterministic \LOCAL algorithm round-by-round. Then, since we showed in \Cref{lem:derandomizable-subroutines} that the algorithm of \cite{hknt_local_d1lc} can be expressed as a sequence of $O(\log^* n)$ \emph{phases}, each of which are normal $(c, \Delta_G )$-round distributed procedures for some constant $c$, we can apply \Cref{lem:fullderand} to derandomize each phase in turn, resulting in a deterministic coloring of all nodes.
\end{proof}
Since the algorithm of \cite{hknt_local_d1lc} is only for nodes of degree at least $\log^7 n$, note that our repeated derandomization steps can leave a set $D$ of remaining uncolored nodes with degrees of at most $\log^7 n$.
\subsection{\DILC when the maximum degree is $n^{7\delta}$}
The remaining algorithm is simple: we apply \Cref{lem:phasecolor} to deterministically color all nodes of degree at least $\log^7 n$ (with some nodes potentially remaining uncolored once their uncolored degree drops below $\log^7 n$, and then apply the following lemma to color the remaining low-degree nodes:
\begin{lemma}[Lemma 14 of \cite{CDP21}]\label{lem:lowdeg}
For any $n$-node graph $G$ with maximum degree $\Delta = \log^{O(1)} n$, there exists an $O(\log \log \log n)$-round deterministic algorithm for
computing \DILC, using $O(n^\phi)$ space per machine and $O(n^{1+\phi})$ global space, for any positive constant~$\phi \in (0,1)$.
\end{lemma}
The algorithm for \DILC when the degree is $O(n^{7\delta})$ is described in \Cref{alg:DLDC} and its correctness is proved in \Cref{thm:midcolor}.
\begin{algorithm}[H]
\caption{\textsc{DerandomizedMidDegreeColor}$(G)$}
\label{alg:DLDC}
Let $G_{\text{low}}$ consist of all nodes of $G$ with palette size at most $\log^7 n$.
Derandomize coloring of $G\setminus G_{\text{low}}$ as in \Cref{lem:phasecolor}, leaving a set $D$ of uncolored nodes with low degree.
$G_{\text{low}}\gets G_{\text{low}} \cup D$.
Update palettes of $G_{\text{low}}$, then color using \Cref{lem:lowdeg}.
\end{algorithm}
\begin{theorem}\label{thm:midcolor}
\textsc{DerandomizedMidDegreeColor}, performed on a DL1C instance $G$ of degree at most $n^{7\delta}$, properly colors all nodes in $O(\log \log\log n)$ rounds of \MPC, using $O(n^{7\delta cC})$ space per machine and $O(n_{G} \cdot n^{7\delta cC})$ global space, where $C$ is as in \Cref{lem:phasederand}.
\end{theorem}
\begin{proof}
After applying \Cref{lem:phasecolor} the degree of all uncolored nodes in $G$ must also be at most $\log^7 n$, so all remaining nodes are colored by \Cref{lem:lowdeg}.
The space usage is dominated by that of \Cref{lem:phasecolor}, and the number of rounds required is $O(\log\log\log n)$ since it is dominated by the $O(\log\log\log n)$ rounds for \Cref{lem:lowdeg}.
\end{proof}
\section{Deterministic D1LC Algorithm}
To reduce our \DILC instances to a collection of instances with lower degree, in order to fit constant-radius balls onto machines, we employ a recursive structure \textsc{LowSpaceColorReduce} (\Cref{alg:LSColorReduce}) similar to \cite{CDP20,CDP21}.
\begin{algorithm}[H]
\caption{\textsc{LowSpaceColorReduce}$(G)$}
\label{alg:LSColorReduce}
$G_{\text{mid}},G_1 \dots, G_{n^{\delta}} \gets \textsc{LowSpacePartition}(G)$.
For each $i = 1, \dots,n^{\delta}-1$ in parallel: call \textsc{LowSpaceColorReduce}$(G_i)$.
Update color palettes of $G_{n^{\delta}}$, call \textsc{LowSpaceColorReduce}$(G_{n^{\delta}})$.
Update color palettes of $G_{\text{mid}}$.
Color $G_{\text{mid}}$ using \textsc{DerandomizedMidDegreeColor}$(G_{\text{mid}})$.
\end{algorithm}
The recursive structure in the above algorithm relies on a partitioning procedure to divide the nodes and colors in the input instance into \emph{bins}:
\begin{algorithm}[H]
\caption{\textsc{LowSpacePartition}$(G)$}
\label{alg:LSPartition}
Let $G_{\text{mid}}$ be the graph induced by the set of nodes $v$ with $d(v)\le n^{7\delta}$.
Let hash function $h_1:[n]\rightarrow [n^{\delta}]$ map each node $v$ to a bin $h_1(v) \in [n^{\delta}]$.
Let hash function $h_2:[n^2]\rightarrow [n^{\delta}-1]$ map colors $\gamma$ to a bin $h_2(\gamma) \in [n^{\delta}-1]$.
Let $G_1,\dots,G_{n^{\delta}}$ be the graphs induced by bins $1,\dots,n^{\delta}$ respectively, minus the nodes in $G_{\text{mid}}$.
Restrict palettes of nodes in $G_1,\dots,G_{n^{\delta}-1}$ to colors assigned by $h_2$ to corresponding bins.
Return $G_{\text{mid}},G_1,\dots,G_{n^{\delta}}$.
\end{algorithm}
We can follow the analysis of \cite{CDP20} to analyze the partitioning process, since it is only the base cases that have changed. The following lemma provides the important properties of the partitioning:
\begin{lemma}[Lemma 4.6 of \cite{CDP20}]\label{lem:LSdeterministic-hashing}
Assume that, at the beginning of a call to \textsc{LowSpacePartition}, we have $d(v)<p(v)$ for all nodes $v$. Then, in $O(1)$ \MPC rounds with $O(n^{7\delta})$ local space per machine and $O(n+m)$ global space (over all parallel instances), one can deterministically select hash functions $h_1$, $h_2$ such that after the call,
%
\begin{itemize}
\item for any node $v\notin G_{\text{mid}}$, $d'(v) < 2d(v)n^{-\delta}$, and
\item for any node $v$, $d'(v)<p'(v)$.
\end{itemize}
Here $d'(v)$ denotes the degree of $v$ in the subgraph induced by the nodes present in the same bucket as $v$ and $p'(v)$ denotes the number of $v$'s palette colors that are in the same bucket as $v$.
\end{lemma}
Now we are ready to prove our main result that $(\deg+1)$-list coloring can be performed deterministically in $O(\log \log\log n)$ rounds of \MPC, with $O(n^\spacexp)$ local space and $O(m+n^{1+\spacexp})$ global space.
\begin{proof}[Proof of \Cref{thm:main:deter}]
As in \cite{CDP21}, calling \textsc{LowSpaceColorReduce} on our input graph creates a recursion tree of $O(1)$ depth (since each recursive call reduces the maximum degree by a $n^{-\delta}$ factor). It therefore creates $O(1)$ sequential sets of base-case instances to solve concurrently, which in \Cref{alg:LSColorReduce} are solved by \textsc{DerandomizedMidDegreeColor}. Furthermore, each set of concurrent instances has at most $n$ nodes in total, since all nodes are only partitioned into one instance, and each instance has maximum degree $n^{7\delta}$.
By \Cref{thm:midcolor}, each such instance $G$ is colored in $O(\log\log\log n)$ rounds using $O(n^{7\delta cC})$ space per machine and $O(n \cdot n^{7\delta cC})$ global space. The global space used by all concurrent instances is therefore $O(n \cdot n^{7\delta cC})$. Setting $\delta$ sufficiently smaller than the space parameter \spacexp, this is $O(n^\spacexp)$ space per machine and $O(n^{1+\spacexp})$ global space. Since receiving the input and the first call to \textsc{LowSpacePartition} also requires $O(m)$ global space, the overall space bound is $O(m+n^{1+\spacexp})$.
\end{proof}
\section{Proofs from Section~\ref{sec:randomized-d1lc}}
\label{sec:proofs-from-sec-3}
In this section we provide some proofs of the claims made in \Cref{sec:randomized-d1lc}. These lemmas pertain to the simulation of deterministic subroutines from Fischer \etal, such as computing certain parameters for each node, and computing a set of nodes $V_\text{start}$ for which it is not easy to generate slack using color trials.
We begin with the proof of \Cref{lem:computing_parameters}, which showed that parameters such as slack, sparsity, and disparity can be computed in sublinear \MPC in $O(1)$ rounds using $O(m+n^{1+\phi})$ global space.
\begin{proof}[Proof of \Cref{lem:computing_parameters}]
We extensively use the subroutines in \Cref{lem:mpc_subroutines_low_degree}. We deal with the parameters in the order they appear in \Cref{def:parameters}.
\begin{itemize}
\item \textbf{Slack:} In $O(1)$ rounds, we can sort tuples corresponding to edges incident to $v$ and colors in $\Psi(v)$ such that they appear on consecutive machines: we can then count how many of each there are and compute \slack{v}.
\item \textbf{Sparsity:} Since we can compute $d(v)$ for all nodes in constant rounds (machines can collect all edges incident to $v$ and count them), to compute $\sparsity{v}$ it remains to count the edges between neighbors of $v$. By the second subroutine in \Cref{lem:mpc_subroutines_low_degree} we can collect the $2$-hop neighborhood of $v$ on a single machine. We can then remove duplicates if necessary and count the number of edges, and then calculate \sparsity{v}.
\item \textbf{Disparity:} By the first subroutine of \Cref{lem:mpc_subroutines_low_degree} we can collect the palette of each of the neighbors of $v$ in constant rounds, allowing us to calculate \disparity{u}{v} for each neighbor $u$ of~$v$.
\item \textbf{Discrepancy:} Follows immediately from the ability to collect \disparity{u}{v} for all neighbors $u$ of $v$.
\item \textbf{Unevenness:} It suffices to collect $d(u)$ from each neighbor $u$ of $v$, which can be done using the first subroutine of \Cref{lem:mpc_subroutines_low_degree}.
\item \textbf{Slackability / Strong Slackability:} Note that these are additions of already computed parameters, and hence can be computed in constant rounds.
\end{itemize}
Mainly due to Lemma~\ref{lem:mpc_subroutines_low_degree} and from the above description, it is easy to see that each of the above parameters can be computed in $O(1)$ rounds for all the nodes in parallel. For the global space complexity for computing the above parameters, note that each node $v$ collects it $2$-neighborhood which is of size $O(\lspace)$ as maximum degree of any node is $O(\sqrt{\lspace})$.
\end{proof}
We next consider the identification of $V_{\text{start}}$, the subset of $V_\text{sparse} \cup V_\text{uneven}$ for which it is hard to generate slack. To identify this set, we consider a breakdown of $V_\text{sparse} \cup V_\text{uneven}$ into several sets based on the parameters defined in \Cref{def:parameters}.
We first explain the notion of a ``heavy'' color. A heavy color $c$ with respect to a node $v$ is a color such that if all of the neighbors of $v$ were to pick a color from their palettes uniformly at random, the expected number of neighbors of $v$ which would pick $c$ (which we denote $H(c)$) is at least some suitable constant. We denote by $\mathcal{C}_v^{\text{heavy}}$ the set of heavy colors with respect to $v$. Now $V_{\text{start}}$ is defined as follows (taken from \cite{hknt_local_d1lc}; the $\veps_i$ are all constants):
\begin{align*}
V_{\text{balanced}} &= \{v \in V_{\text{sparse}} : | \{u \in N(v) : d(u) > 2d(v)/3| \geq \veps_1 d(v)\}\}. \\
V_{\text{disc}} &= \{v \in V_{\text{sparse}} : \discrepancy{v} \geq \veps_2 d(v)\}. \\
V_{\text{easy}} &=
\begin{aligned}[t]
& V_{\text{balanced}} \cup V_{\text{disc}} \cup V_{\text{uneven}}\\
& \cup \{v \in V_{\text{sparse}} : | N(v) \cap V_{\text{dense}} \geq \veps_3 d(v) \}.
\end{aligned}\\
V_{\text{heavy}} &= \{v \in V_{\text{sparse}} \setminus V_{\text{easy}} : \textstyle \sum_{c \in \mathcal{C}_v^{\text{heavy}}} H(c) \geq \veps_4 d(v)\}. \\
V_{\text{start}} &= \{v \in V_{\text{sparse}} \setminus (V_{\text{easy}} \cup V_{\text{heavy}}) : N(v) \cap V_{\text{easy}} | \geq \veps_5 d(v)\}.
\end{align*}
We can now prove \Cref{lem:identifying_vstart}:
\begin{proof}[Proof of \Cref{lem:identifying_vstart}]
Observe that $V_{\text{balanced}}$, $V_{\text{disc}}$, and $V_{\text{easy}}$ are computable in $O(1)$ rounds by applications of \Cref{lem:computing_parameters} and \Cref{lem:mpc_subroutines_low_degree}. We briefly note that, again using an application of the first subroutine of \Cref{lem:mpc_subroutines_low_degree}, nodes can be made aware of which neighbors are in which sets in $O(1)$ rounds.
It remains to compute which colors are heavy (and the set $V_{\text{heavy}}$): by the first subroutine of \Cref{lem:mpc_subroutines_low_degree} we can gather the palettes of all neighbors of $v$ on $M(v)$, and then $M(v)$ can compute this information in $O(1)$ rounds.
\end{proof}
We conclude with the proof that we can identify leaders, inliers, and outliers of almost-cliques, and establish which almost-cliques require put-aside sets, in $O(1)$ rounds.
\begin{proof}[Proof of \Cref{lem:finding_leaders}]
First, we explain how we can find the \emph{leader} $x_{C}$ and the \emph{outliers} $O_{C}$ for each almost-clique $C \in \cC$. The leader $x_{C}$ is the node in $C$ with minimum slackability. As we can determine the slackability of all the nodes (in $C$) by using $O(1)$ rounds in parallel (see \Cref{lem:computing_parameters}), we can determine $x_{C}$ for each $i \in [t]$ in parallel in $O(1)$ rounds. The slackability of an almost-clique $C$ is defined as the the slackability of its leader $x_C$. $C$ is said to be a \emph{low slack} almost-clique if its slackability is at most $\ell=\log^{2.1} \Delta$. Recall that these are the almost-cliques (with low slackability) for which we need to find put-aside sets.
Let $O_C$ be the set of \emph{outliers} in an almost-clique $C$. $O_C$ is comprised of the union of the $\frac{\max\{{d(x_C), \size{C}}\}}{3}$ nodes with the fewest common neighbors with $x_C$, the $\frac{\size{C}}{6}$ nodes of largest degree, and the nodes in $C$ that are not neighbors of $x_C$. The nodes in $C$ that are not outliers are called \emph{inliers} of $C$ (denoted by $I_C$). As each almost-clique $C$ is stored in one machine and we can determine the degrees of the nodes in $O(1)$ rounds, we can clearly find $O_C$ and $I_C$ for all almost-cliques in $O(1)$ rounds.
\end{proof}
\section{D1LC in Sublinear \MPC with Linear Global Space}
\section{Simulating Deterministic \LOCAL Subroutines in Sublinear \MPC}
\section{Simulating \LOCAL Subroutines}
\label{sec:randomized-d1lc}
First, we provide some arguments that the subroutines in \cite{hknt_local_d1lc} which are already deterministic can be simulated efficiently in the \MPC model, provided that the maximum degree of the \DILC instance is below $\sqrt{\lspace}$.
In particular we show that, deterministically in $O(1)$ rounds, when the maximum degree is less than $\sqrt{\lspace}$, we can compute: all the parameters defined in \Cref{def:parameters}, a $(\deg+1)$-ACD (see \Cref{def:acd}), the set $V_{\text{start}}\subseteq V_{\text{sparse}}$~\footnote{A full definition of $V_{\text{start}}$ will be discussed later in this section.} (whose purpose was described in Section~\ref{sec:sparse}), the leaders, inliers, and outliers from each almost-clique, and the put-aside sets.
We begin with a useful lemma that says (in essence) that nodes can send and receive $O(\sqrt{\lspace})$ messages to each of their neighbours in one round\footnote{We remark that the \MPC model is not node-centric, but machine-centric, and that when we talk about node $u$ ``sending messages'' to node $v$, we suppose that each node has a machine responsible for it, and mean that the machine responsible for node $u$ is sending a message to the machine responsible for node $v$.}, provided that their degree is $O(\sqrt{{\lspace}})$.
\begin{lemma}
\label{lem:mpc_subroutines_low_degree}
Let $G=(V, E)$ be a graph $G$ such that for all $v \in V$, $d(v) \leq O(\sqrt{\lspace})$.
Suppose each node $v$ is assigned some unique machine $M(v)$: informally, $M(v)$ is responsible for $v$. Then, the following subroutines can be performed in parallel for each $v$ (and its assigned machine $M(v)$) in $O(1)$ rounds in \MPC with $\lspace = O(n^\spacexp)$, and global space $O(m+n^{1+\spacexp})$:
\begin{itemize}
\item $M(v)$ can send $d(v)$ messages to each machine $M'$ such that $M(u)$ is responsible for node $u \in N(v)$
\item $M$ can collect all of the edges between neighbours of $v$
\end{itemize}
\end{lemma}
\begin{proof}
Suppose each node is allocated a machine (giving global space of $O(m+n^{1+\phi})$. The machine responsible for node $v$ can prepare $d(v)$ messages for each of the neighbors of $v$. This takes $\leq \lspace$ local space, so these messages can be sent in $O(1)$ rounds. The second subroutine follows from the first: the $d(v)$ words that each node broadcasts consists of the list of its neighbors.
\end{proof}
We can now argue that provided the maximum degree of our graph is low enough, the parameters described in \Cref{def:parameters} can be efficiently computed in parallel for each node.
\begin{lemma}[Computing Parameters of \Cref{def:parameters}]
\label{lem:computing_parameters}
For a graph $G=(V, E)$ with maximum degree {${\Delta \leq O(\sqrt{\lspace})}$}, all of the parameters listed in \Cref{def:parameters} can be computed for every node in parallel in \MPC with $\lspace = O(n^\spacexp)$ and global space $O(m+n^{1+\spacexp})$ in $O(1)$ rounds.
\end{lemma}
\begin{proof}
We extensively use the subroutines in \Cref{lem:mpc_subroutines_low_degree}. We deal with the parameters in the order they appear in \Cref{def:parameters}.
\begin{itemize}
\item \textbf{Slack:} In $O(1)$ rounds, we can sort tuples corresponding to edges incident to $v$ and colors in $\Psi(v)$ such that they appear on consecutive machines: we can then count how many of each there are and compute \slack{v}.
\item \textbf{Sparsity:} Since we can compute $d(v)$ for all nodes in constant rounds (machines can collect all edges incident to $v$ and count them), to compute $\sparsity{v}$ it remains to count the edges between neighbors of $v$. By the second subroutine in \Cref{lem:mpc_subroutines_low_degree} we can collect the $2$-hop neighborhood of $v$ on a single machine. We can then remove duplicates if necessary and count the number of edges, and then calculate \sparsity{v}.
\item \textbf{Disparity:} By the first subroutine of \Cref{lem:mpc_subroutines_low_degree} we can collect the palette of each of the neighbors of $v$ in constant rounds, allowing us to calculate \disparity{u}{v} for each neighbor $u$ of~$v$.
\item \textbf{Discrepancy:} Follows immediately from the ability to collect \disparity{u}{v} for all neighbors $u$ of $v$.
\item \textbf{Unevenness:} It suffices to collect $d(u)$ from each neighbor $u$ of $v$, which can be done using the first subroutine of \Cref{lem:mpc_subroutines_low_degree}.
\item \textbf{Slackability / Strong Slackability:} Note that these are additions of already computed parameters, and hence can be computed in constant rounds.
\end{itemize}
Mainly due to Lemma~\ref{lem:mpc_subroutines_low_degree} and from the above description, it is easy to see that each of the above parameters can be computed in $O(1)$ rounds for all the nodes in parallel. For the global space complexity for computing the above parameters, note that each node $v$ collects it $2$-neighborhood which is of size $O(\lspace)$ as maximum degree of any node is $O(\sqrt{\lspace})$.
\end{proof}
Next, we show how to compute an $(\deg +1)$-ACD in $O(1)$ rounds.
\begin{lemma}[Computing $(\deg+1)$-ACD]
\label{lem:computing_acd}
For a graph $G=(V, E)$ with maximum degree $\Delta \leq O(\sqrt{\lspace})$, an $(\deg+1)$-ACD can be computed in \MPC with $\lspace = O(n^\spacexp)$ and global space $O(m+n^{1+\phi})$ in $O(1)$ rounds.
\end{lemma}
\begin{proof}
First we argue that the diameter of the subgraph induced by any almost-clique $C$, is at most $2$. This is the case because, by (iv) of \Cref{def:acd}, the number of neighbors any node $v \in C$ has in $C$ is $\size{N(v) \cap C} \geq \frac{\size{C}} {1+ \veps_{ac}} > \frac{\size{C}}{2}$. Hence, any two nodes $u$ and $v$ in $C$ have a common neighbor in $C$.
By \Cref{lem:computing_parameters}, all nodes ($v$) can compute their sparsity ($\zeta_v$) and unevenness ($\eta_v$) in $O(1)$ rounds in parallel. From the values of $\zeta_v$ and $\eta_v$, we can decide whether $v \in V_{\text{sparse}}$, or $v \in V_{\text{uneven}}$, or neither, giving the following:
\begin{observation}\label{obs:spse}
{$V_{\text{sparse}}$ and $V_{\text{uneven}}$ can be determined in $O(1)$ rounds.}
\end{observation}
Note that each node $v \in (V \setminus (V_{\text{sparse}} \sqcup V_{\text{uneven}}))$ is present in some almost-clique $C(v)$. As the diameter of $G[C(v)]$ is at most 2, $C(v)$ is a subset of the $2$-hop neighborhood of $v$. As $d(v)\leq O(\sqrt{\lspace})$, by \Cref{lem:mpc_subroutines_low_degree} the $2$-hop neighborhood of $v$ can be found in $O(1)$ rounds and stored on a single machine. Once this is done, $M(v)$ can determine which almost-clique $v$ is in. Putting everything together, the ACD can be computed in $O(1)$ rounds and the global space used is $O(m+n^{1+\phi})$.
\end{proof}
Finally, we argue that we can identify a set of nodes $V_\text{start} \subseteq V_\text{sparse} \sqcup V_\text{uneven}$ for which it is difficult to generate slack. We give a more detailed characterisation of $V_\text{start}$ shortly, and prove \Cref{lem:identifying_vstart} that says that $V_\text{start}$ can be identified in $O(1)$ rounds. We then argue (\Cref{lem:finding_leaders}) that we can identify the leaders, inliers, and outliers of all almost-cliques, and identify the almost-cliques for which we need to create a put-aside set in $O(1)$ rounds.
We now consider the identification of $V_{\text{start}}$, the subset of $V_\text{sparse} \cup V_\text{uneven}$ for which it is hard to generate slack. To identify this set, we consider a breakdown of $V_\text{sparse} \cup V_\text{uneven}$ into several sets based on the parameters defined in \Cref{def:parameters}.
We first explain the notion of a ``heavy'' color. A heavy color $c$ with respect to a node $v$ is a color such that if all of the neighbors of $v$ were to pick a color from their palettes uniformly at random, the expected number of neighbors of $v$ which would pick $c$ (which we denote $H(c)$) is at least some suitable constant. We denote by $\mathcal{C}_v^{\text{heavy}}$ the set of heavy colors with respect to $v$. Now $V_{\text{start}}$ is defined as follows (taken from \cite{hknt_local_d1lc}; the $\veps_i$ are all constants):
\begin{align*}
V_{\text{balanced}} &= \{v \in V_{\text{sparse}} : | \{u \in N(v) : d(u) > 2d(v)/3| \geq \veps_1 d(v)\}\}. \\
V_{\text{disc}} &= \{v \in V_{\text{sparse}} : \discrepancy{v} \geq \veps_2 d(v)\}. \\
V_{\text{easy}} &=
\begin{aligned}[t]
& V_{\text{balanced}} \cup V_{\text{disc}} \cup V_{\text{uneven}}\\
& \cup \{v \in V_{\text{sparse}} : | N(v) \cap V_{\text{dense}} \geq \veps_3 d(v) \}.
\end{aligned}\\
V_{\text{heavy}} &= \{v \in V_{\text{sparse}} \setminus V_{\text{easy}} : \textstyle \sum_{c \in \mathcal{C}_v^{\text{heavy}}} H(c) \geq \veps_4 d(v)\}. \\
V_{\text{start}} &= \{v \in V_{\text{sparse}} \setminus (V_{\text{easy}} \cup V_{\text{heavy}}) : N(v) \cap V_{\text{easy}} | \geq \veps_5 d(v)\}.
\end{align*}
\begin{lemma}[Identifying $V_{\text{start}}$]
\label{lem:identifying_vstart}
Given a graph $G=(V, E)$ with maximum maximum degree $\Delta \leq \sqrt{\lspace}$, the set $V_{\text{start}}$ can be identified on an \MPC with $\lspace = O(n^\spacexp)$ and global space $O(m+n^{1 + \phi})$ in $O(1)$ rounds.
\end{lemma}
\begin{proof}
Observe that $V_{\text{balanced}}$, $V_{\text{disc}}$, and $V_{\text{easy}}$ are computable in $O(1)$ rounds by applications of \Cref{lem:computing_parameters} and \Cref{lem:mpc_subroutines_low_degree}. We briefly note that, again using an application of the first subroutine of \Cref{lem:mpc_subroutines_low_degree}, nodes can be made aware of which neighbors are in which sets in $O(1)$ rounds.
It remains to compute which colors are heavy (and the set $V_{\text{heavy}}$): by the first subroutine of \Cref{lem:mpc_subroutines_low_degree} we can gather the palettes of all neighbors of $v$ on $M(v)$, and then $M(v)$ can compute this information in $O(1)$ rounds.
\end{proof}
In the following lemma, we show that we can identify leaders, inliers, and outliers of almost-cliques, and establish which almost-cliques require put-aside sets, in $O(1)$ rounds.
\begin{lemma}[Finding leaders, outliers and inliers]
\label{lem:finding_leaders}
Given a graph $G=(V, E)$ with maximum maximum degree $\Delta \leq \sqrt{\lspace}$, we can find the leader, the set of inliers and the set of outliers for each almost-clique in \MPC with $\lspace = O(n^\spacexp)$ and global space $O(m+n^{1 + \phi})$ in $O(1)$ rounds. Moreover, we can detect all the almost-cliques for which we need to find put-aside sets.
\end{lemma}
\begin{proof}
First, we explain how we can find the \emph{leader} $x_{C}$ and the \emph{outliers} $O_{C}$ for each almost-clique $C \in \cC$. The leader $x_{C}$ is the node in $C$ with minimum slackability. As we can determine the slackability of all the nodes (in $C$) by using $O(1)$ rounds in parallel (see \Cref{lem:computing_parameters}), we can determine $x_{C}$ for each $i \in [t]$ in parallel in $O(1)$ rounds. The slackability of an almost-clique $C$ is defined as the the slackability of its leader $x_C$. $C$ is said to be a \emph{low slack} almost-clique if its slackability is at most $\ell=\log^{2.1} \Delta$. Recall that these are the almost-cliques (with low slackability) for which we need to find put-aside sets.
Let $O_C$ be the set of \emph{outliers} in an almost-clique $C$. $O_C$ is comprised of the union of the $\frac{\max\{{d(x_C), \size{C}}\}}{3}$ nodes with the fewest common neighbors with $x_C$, the $\frac{\size{C}}{6}$ nodes of largest degree, and the nodes in $C$ that are not neighbors of $x_C$. The nodes in $C$ that are not outliers are called \emph{inliers} of $C$ (denoted by $I_C$). As each almost-clique $C$ is stored in one machine and we can determine the degrees of the nodes in $O(1)$ rounds, we can clearly find $O_C$ and $I_C$ for all almost-cliques in $O(1)$ rounds.
\end{proof}
\section{Algorithm for $\Delta$-coloring}
\label{sec:Delta-coloring}
In this section we show an application of \Cref{thm:main:deter} and present a $O(\log\log\log n)$-round \MPC algorithm for the related problem of $\Delta$-coloring (\Cref{thm:delta_coloring}). The algorithm is randomized, and uses \Cref{thm:main:deter} repeatedly as a subroutine.
We remark that we can only find a $\Delta$-coloring when $\Delta \geq 3$ in $o(\log n)$ rounds in low-space \MPC. This is because there is a long-standing conjecture that we cannot distinguish a cycle of length $n$ from two cycles of length $n/2$ in $o(\log n)$ rounds of sublinear \MPC: it is therefore not possible to tell in $o(\log n)$ sublinear \MPC rounds whether a $2$-regular graph with $n=4k+2$ is a single ($2$-colorable) cycle of even length, or two (not $2$-colorable) cycles of odd length. We note that the assumption that $\Delta \geq 3$ is standard in all distributed literature on this problem.
In the following subsections, we show that we can simulate a version of the algorithm given by Fischer \etal (\cite[Theorem 1.1]{FHM23}), which gives an algorithm to $\Delta$-color graphs with {$\Delta = \omega(\log^{3} n)$} in the \CONGEST model, to give an algorithm for the same range of $\Delta$ in $O(\log\log\log n)$ \MPC rounds.
This \CONGEST algorithm fails for $\Delta = o(\log^3 n)$, because certain claims no longer succeed with sufficiently high probability.
However, for graphs which do not satisfy this condition (i.e.~those for which $\Delta = o(\log^{3} n)$), we can in any case find a $\Delta$-coloring in $O(\log\log\log n)$ rounds, by exploiting graph exponentiation to collect our $O(\poly \log\log n)$-hop neighborhoods, and then simulating an earlier \LOCAL algorithm given by \cite{DBLP:journals/dc/GhaffariHKM21}.
\begin{remark}
\label{rem:low_degree_delta_coloring}
There is a randomized $O(\log\log\log n)$-round low-space \MPC algorithm which, w.h.p., finds a $\Delta$-coloring of $G$, for any $n$-node graph $G$ with maximum degree $\Delta$ such that $\Delta \geq 3$, $\Delta = O(\log^{3} n)$, and $G$ does not contain a clique of size $(\Delta + 1)$.
The algorithm uses $O(m+n^{1+\phi})$ global space.
\end{remark}
\begin{proof}
Ghaffari \etal give a randomized \LOCAL algorithm for the problem of $\Delta$-coloring when $\Delta \geq 3$ \cite[Theorem 1]{DBLP:journals/dc/GhaffariHKM21}. This algorithm succeeds w.h.p.~and runs in $O(\sqrt{\Delta \cdot \log \Delta} \cdot \log^* \Delta \cdot \log^2\log n)$ rounds. We note that the complexity of this algorithm is $O(\poly\log\log n)$ when $\Delta = O(\poly \log n)$.
\LOCAL algorithms which run in $k$ rounds can be simulated in \MPC by collecting the $k$-hop neighborhood of each node and simulating the choices of the nodes. Therefore, simulating the algorithm of Ghaffari \etal requires each node to collect its $O(\poly \log\log n)$-hop neighborhood. This can be achieved using graph exponentiation in $O(\log(\poly\log\log n)) = O(\log\log\log n)$ rounds, using at most $(\log^{3} n)^{O(\poly\log\log n)} = o(n^\phi)$ extra global space per node, for an arbitrary positive constant $\phi$.
\end{proof}
We also give the following lemma, which much of the rest of this section will be dedicated to proving:
\begin{lemma}
\label{lem:high_degree_delta_col}
There is a randomized $O(\log\log\log n)$-round low-space \MPC algorithm which, w.h.p., finds a $\Delta$-coloring of $G$, for any $n$-node graph $G$ with maximum degree $\Delta$ such that $\Delta \geq 3$, $\Delta = \omega(\log^{3} n)$, and $G$ does not contain a clique of size $(\Delta + 1)$.
The algorithm uses $O(m+n^{1+\phi})$ global space for an aritrary constant $\phi \in (0,1)$.
\end{lemma}
Note that these two results together imply \Cref{thm:delta_coloring}:
\begin{proof}[Proof of \Cref{thm:delta_coloring}]
We can determine the value of $\Delta$ for our input graph in $O(1)$ rounds using sorting and prefix sum. Then we use either the algorithm of \Cref{rem:low_degree_delta_coloring} or \Cref{lem:high_degree_delta_col}, depending on the value of $\Delta$.
\end{proof}
\subsection{Overview of $\Delta$-coloring algorithm of \cite{FHM23}}
We give a brief overview of the $\Delta$-coloring algorithm of \cite{FHM23} for the \LOCAL and \CONGEST models of distributed computing {when $\Delta \omega(\log ^3 n)$}. In general, $\Delta$-coloring is much harder than $(\Delta+1)$-coloring in a distributed or parallel setting: in part because each node has one fewer color, but primarily because while in $(\Delta+1)$-coloring a valid partial coloring can be extended to a valid full coloring, this is not the case for $\Delta$-coloring.
Because of this, one has to be much more careful when coloring nodes in a $\Delta$-coloring problem: it must be ensured that all nodes can be given some ``slack'' so that they can be colored.
To achieve this, Fischer \etal first perform an almost-clique decomposition tailored to the problem of $\Delta$-coloring. They then categorise the almost-cliques into several different types, depending on how easy it is to generate slack for nodes inside them and what type of external neighbors they have. Nodes are then classified into a series of sets, depending on which type of almost-clique they belong to, and whether they have many neighbors to particular almost-cliques.
Finally, these sets of nodes are colored, in a particular order. Most sets of nodes need to be colored using a $(\deg + 1)$-list-coloring algorithm
We break down our proof of \Cref{lem:high_degree_delta_col} as follows.
In \Cref{sec:delta-acd} we define a useful ACD for $\Delta$-coloring and show that it can be computed in $O(1)$ rounds of low-space \MPC.
In \Cref{sec:classifying_nodes} we show that we can perform the necessary classifications of almost-cliques and nodes which the algorithm of Fischer \etal requires in $O(1)$ \MPC rounds.
Finally, in \Cref{sec:implementation_of_coloring} we show that the coloring procedures can be implemented in $O(\log\log\log n)$ \MPC rounds and conclude the proof of \Cref{lem:high_degree_delta_col}.
\subsection{Almost-clique decomposition in $O(1)$ rounds}
\label{sec:delta-acd}
We begin by defining an ACD which will be useful in $\Delta$-coloring. {This ACD was originally given by Fischer \etal \cite{FHM23}}. We note that a different ACD is required for $\Delta$-coloring than for the \DILC problem (as used in \Cref{sec:acd}). This ACD is to some extent simpler, as all almost-cliques are approximately of the same size, and there is no $V_\text{uneven}$.
\begin{definition}[$\Delta$-{\sc ACD}]\label{defi:acd-delta}
Let $G(V,E)$ be a graph and $\veps \in (0,1/20)$ be a constant. A partition of $V$ into $V_{\text{sparse}}$ and $V_{\text{dense}}$, such that $V_{\text{dense}}$ is further partitioned into $C_1,\ldots,C_k$, is said to be an \emph{almost-clique decomposition} ({\sc ACD}) if
\begin{enumerate}
\item[(i)] For each node in $v \in V_{\text{sparse}}$, $\frac{1}{\Delta}\left[{\Delta \choose 2}-m(N(v))\right]=\Omega(\eps^2\Delta)$;
\item[(ii)] For every $i \in [k]$, $(1-\eps)\Delta \leq \size{C_i} \leq (1+3\eps)\Delta$;
\item[(iii)] Each dense node $v$ has at least $(1-4\veps)\Delta$ neighbors in $C(v)$, i.e., $\size{N(v) \cap C(v)} \geq (1-4\veps)\Delta$;
\item[(iv)] For each node $u \notin C_i$, $\size{N(u) \cap C_i} \leq (1-2\eps)\Delta$.
\end{enumerate}
\end{definition}
{For the description of the algorithm for computing a {\sc $\Delta$-ACD}, we need some notions in the following definition.}
\begin{definition}[{similarity, friend and density} ~\cite{HKMT20}]
Two nodes $u,v \in V$ are \emph{$\eta$-similar} if $\size{N(u) \cap N(v)}\geq (1-\eta)\Delta$. Two $\eta$-similar nodes $u$ and $v$ are such that $\{u,v\} \in E$ are said to be \emph{$\eta$-friend}. A node $v$ is said to be \emph{$\eta$-dense} if $v$ has at least $(1-\eta)\Delta$ $\eta$-friends.
\end{definition}
We now give an algorithm for computing the ACD defined in \Cref{defi:acd-delta}. A similar version of this algorithm was originally given by Halld{\'o}rsson \etal for $(\Delta + 1)$-coloring in the \CONGEST model \cite[Algorithm 7]{HKMT20} and subsequently adapted by \cite{FHM23} for use in $\Delta$-coloring. We show later that it can also be implemented in \MPC with low local space, in $O(1)$ rounds.
\begin{algorithm}[H]
\caption{\textsc{$\Delta$-ACD-Computation}$(G,\eps)$}
\label{alg:acd-delta}
Let $\eta=\eps/27$;
Sample each node with probability $1/\sqrt{\Delta}$ and add to a set $S$.
For each $v \in V$, select a node from $N(v) \cap S$ u.a.r., and add it to multi-set $T$ with probability $\min\{1,\size{S \cap N(v)}/2\sqrt{\Delta}\}$.
For $v \in S$, if there is some $u \in N(v) \cap S$ such that $u$ has multiplicity $(1-2\eta)\sqrt{\Delta}/2$ in $T$, then $v$ is said to be \emph{approximately $\eta$-similar} to $u$.
$F = \{\{u,v\} \in E : \text{$u$ is approximately $\eta$-similar to $v$}\}$
\mbox{$S_{\text{dense}}=\{v \in S: v~\mbox{is incident to at least $(1-2\eta)\sqrt{\Delta}$ edges in $F$}\}$.}
Each $v \in S_\textit{dense}$ selects a $u \in S_{\text{dense}}$ such that $\{u,v\}\in F$ and the ID of $u$ is minimized, and adds $u$ to a multiset $U$.
For each $v \in V$, if there exists a $u \in N(v)$ that has multiplicity at least $(1-11\eta)\sqrt{\Delta}$ in $U$, then the AC-ID of $v$ is the same as the ID of $u$. Otherwise, $v$ is added to a set $V'$.\label{algo13:step8}
Let $C_1', \ldots, C_{t}'$ be sets of nodes such that nodes in $C_k'$ have the same AC-ID. For $i \in [t]$, if $\size{C_i}< (1-\eta)\Delta$ or there is an $x \in C_i$ such that $\size{N(x) \cap C_i} < (1-\eta)\Delta$, then remove the AC-ID of nodes in $C_i'$ and add them to $V'$.\label{algo13:step9}
Let $v \in V'$. If $v$ has at least $(1-108\eta)\Delta$ neighbors in some $C_i'$, then give $v$ the same AC-ID as that of $C_i'$.\label{algo13:step10}
Output $C_1, \ldots, C_{k}$ such that the nodes in a particular $C_i$ have the same AC-ID; $V_{\text{dense}}=C_1 \sqcup \ldots \sqcup C_k$; and $V_{\text{sparse}}=V \setminus V_{\text{dense}}$.\label{algo13:step11}
\end{algorithm}
\begin{theorem}\label{lem:main-delta}
The output produced by \textsc{$\Delta$-ACD-Computation} is an $\Delta$-{\sc ACD} as defined in Definition~\ref{defi:acd-delta}. Moreover, \textsc{$\Delta$-ACD-Computation} can be implemented in $O(1)$ \MPC rounds.
\end{theorem}
To prove the above lemma, we have the following guarantee.
\begin{lemma}[Lemma~9.7 in \cite{HKMT20}]
\label{lem:hal-delta}
With high probability, the following hold.
\begin{itemize}
\item[(i)] Every $\eta/4$-dense node has an AC-ID and, for $i \in [t]$, $C_i'$ has a $\eta/4$-dense node. That is, for every node in $v \in V'$, we have $\frac{1}{\Delta}\left[{\Delta \choose 2}-m(N(v))\right]=\Omega(\eta^2\Delta)$;
\item[(ii)] For $i \in [t]$, $ (1-\eta)\Delta \leq \size{C_i'}\leq (1+25\eta)\Delta$;
\item[(iii)] For $i \in [t]$ and $v \in C_i'$, $\size{N(v) \cap C(v)} \geq (1-27\eta)\Delta$.
\end{itemize}
\end{lemma}
\begin{lemma}[Properties of the output produced by Algorithm~\ref{alg:acd-delta}]
\label{lem:acd-brook}
The output produced by \textsc{$\Delta$-ACD-Computation} is an {\sc ACD} as defined in Definition~\ref{defi:acd-delta}.
\end{lemma}
\begin{proof}
The proof is similar to the proof of Lemma 2.1 of~\cite{FHM23}. For completeness, we are having it here.
Consider $V'$ and $C_1',\ldots,C_t'$ in Step~\ref{algo13:step8} and~\ref{algo13:step9} of Algorithm~\ref{alg:acd-delta}, respectively. Note that they satisfy all three properties as mentioned in Lemma~\ref{lem:hal-delta} with high probability. Now, consider the way the algorithm finds $C_1,\ldots,C_t$ and $V_{\text{sparse}} \subseteq V'$ in Steps~\ref{algo13:step10} and Steps~\ref{algo13:step11}.
For the proof of (i) of Definition~\ref{defi:acd-delta}, from Lemma~\ref{lem:hal-delta} (i), note that for each node $v \in V'$ we have $\frac{1}{\Delta}\left[{\Delta \choose 2}-m(N(v))\right]=\Omega(\eps^2\Delta)$. As $V_{sparse} \subseteq V'$ and $\eta=\eps/27$, each node $v \in V_{\text{sparse}}$ satisfies $\frac{1}{\Delta}\left[{\Delta \choose 2}-m(N(v))\right]=\Omega(\eps^2\Delta)$.
For the proof of (ii), we first show an upper bound on $\size{C_i \setminus C_i'}$. By Lemma~\ref{lem:hal-delta} (iii), the number of neighbors of any node in $C_i'$ that are outside $C_i'$ is at most $27\eta\Delta$. Again by Lemma~\ref{lem:hal-delta} (ii), the total number of edges having exactly one end point inside $C_i'$ is at most $\size{C_i'} \cdot 27 \eta \leq (1+25 \eta)27 \eta \Delta$. By the definition of tnodesces in $C_i \setminus C_i'$, as each node in $C_i \setminus C_i'$ has at least $(1-108\eta)\Delta$ neighbors, $\size{C_i \setminus C_i'}$ is at most $(1+25 \eta)27 \eta \Delta/(1-108\eta) \leq 50\eta \Delta$. So, $\size{C_i}=\size{C_i'}+\size{C_i \setminus C_i'}=(1+25 \eta)\Delta +50\eta \Delta=(1+75\eta)\Delta<(1+3\eps)\Delta$.
Now, we proof of (iii) of Definition~\ref{defi:acd-delta}. Due to (iii) of Lemma~\ref{lem:hal-delta} and the way the algorithm adnodeses to $C_i'$ to form $C_i$, for any node $v \in C_i$, $\size{N(v) \cap C(v)} \geq (1-108\eta)\Delta = (1-4\eps)\Delta$.
For the proof of (iv) of Definition~\ref{defi:acd-delta}, consider the definition of $V_{\text{sparse}}$. Each node in $V_{\text{sparse}}$ has at most $(1-108\eta)\Delta$ neighbors in $C_i'$. Also, we have argued that $\size{C_i \setminus C_i'}\leq 50 \eta \Delta$. So, each node in $V_{\text{sparse}}$ has at most $(1-58\eta)\Delta < (1-2\eps)\Delta$ neighbors in $C_i'$.
\end{proof}
We briefly describe the preconditions of our \MPC and give some notation:
\begin{remark}
\label{rem:mpc_initial_conditions}
At the beginning of an \MPC algorithm whose input is a graph $G = (V, E)$, we may assume that the edges are sorted lexicographically across machines: i.e., each machine has a contiguous subsequence of the sorted edges.
If there is an edge $\{x, y\} \in E$, we assume that both pairs $(x, y)$ and $(y, x)$ are present.
We say that the pair $(x, y)$ is incident to $x$, but that $(y, x)$ is not.
We say a machine $M(v)$ is responsible for a node $v$ if the lexicographically first edge incident to $v$ is on $M(v)$. Machines can figure out which nodes they are responsible for in $O(1)$ rounds using some simple communication with the machines which have the adjacent data.
We note that if these conditions are not present, they can be enforced in $O(1)$ rounds using sorting.
\end{remark}
We now give a lemma similar to \Cref{lem:mpc_subroutines_low_degree}, except these subroutines work regardless of the maximum degree of the input graph:
\begin{lemma}
\label{lem:mpc_capabilities}
Given the preconditions and definitions in \Cref{rem:mpc_initial_conditions}, we can perform each of the following tasks in $O(1)$ rounds:
\begin{itemize}
\item \textbf{Broadcasting a message to all neighbors:} Given a node $v$, we can append a message $\mu$ to each edge $(u, v)$ for each $u \in N(v)$. This can be done for all nodes in parallel, and if the messages are all of size $\mu$ the procedure requires a $O(\mu)$ factor extra global space.
\item \textbf{Uniformly at random selecting a neighbor:} Each node $v$ can randomly select a neighbor $u \in N(v)$ and broadcast its choice to all neighbors. This selection can be restricted to a subset of neighbors.
\end{itemize}
\end{lemma}
\begin{proof}
We start by describing the useful subroutine of ``broadcasting a message'' $\mu$ from a node $u$ to all neighbors of $u$. First, we append $\mu$ to all pairs incident to $u$: for example if there was a pair $(u, v)$ this pair would now be a tuple $(u, v, \mu)$. Then we swap the first two elements of the tuple (our example would become $(v, u, \mu)$. Finally, we sort these tuples lexicographically: we now have a state similar to our preconditions in \Cref{rem:mpc_initial_conditions}, except all tuples incident to $u$ are ``tagged'' with some additional information from that neighbor of $u$. We remark that this operation just requires sorting and can therefore be achieved in $O(1)$ rounds using a factor of $O(\mu)$ extra global space.
It is similarly easy to see that selecting a uniformly random neighbor of each node can be achieved in $O(1)$ rounds: append a random value to each edge and sort all edges lexicographically by their first endpoint and this random value, then pick the first incident edge. Again this just requires sorting and so takes $O(1)$ rounds, and this can be done for all the nodes in parallel. We also note that this can be easily extended to selecting at random from a subset of neighbors (by including membership of the subset in the sorting criteria).
\end{proof}
\begin{lemma}[MPC Implementation of ACD Decomposition]
\label{lem:mpc-acd-delta}
\Cref{alg:acd-delta} can be implemented in $O(1)$ rounds on an MPC with $O(n^\phi)$ local space and $O(m+n)$ global space.
\end{lemma}
\begin{proof}
We argue for each line in the proof that some mix of sorting, prefix sum, local computation, and subroutines from \Cref{lem:mpc_capabilities} suffices.
\begin{itemize}
\item Line 2 can be decided for each $v$ by $M(v)$ without communication.
\item Lines 3 and 7 are subroutines similar to the uniformly random selection in \Cref{lem:mpc_capabilities} (although line 7 does not require randomness). Suppose node $u$ selects node $v$ to add to $T$ (resp.\ $U$): $M(u)$ can broadcast this fact to $M(v)$, and then $M(v)$, using prefix sum, can compute the multiplicity of $v$ in $T$ (resp.\ $U$) and broadcast it to all neighbors of $v$.
\item Lines 4, 6, 8, 9, and 10 require us to calculate for each node how many of its neighbors satisfy some condition. This can be done by all nodes first broadcasting whether they meet the condition (as in \Cref{lem:mpc_capabilities} followed by prefix sum to count the number of a node's neighbors which do meet the precondition.\\
Consider line 4 as an example. First, all nodes broadcast which neighbor they selected in line 3. Then, for each node $v$, $M(v)$ knows how many of $v$'s neighbors selected $v$ in line 3, and therefore what the multiplicity of $v$ in $T$ is. $M(v)$ can then broadcast to its neighbors whether $v$ has sufficient multiplicity.
\item Line 5: requires us to calculate for each node whether neighbors meet two conditions (membership of $S$ and multiplicity in $T$). This can be done locally once machines responsible for neighbors broadcast this information.
\end{itemize}
\end{proof}
Finally, we observe that we have shown both constituent parts of \Cref{lem:main-delta}.
\begin{proof}[Proof of Lemma~\ref{lem:main-delta}]
Follows immediately from \Cref{lem:acd-brook} and \Cref{lem:mpc-acd-delta}.
\end{proof}
\subsection{Classifying nodes in sublinear \MPC}
\label{sec:classifying_nodes}
After an ACD is performed in the algorithm of \cite{FHM23}, nodes are partitioned into a series of sets, which have to be ($(\deg+1)$-list-) colored in a particular order in order to ensure that each node has enough slack.
The classification of nodes into these sets is based on several factors: the most significant is the \emph{type} of almost-clique which the node is in. Almost-cliques are divided into types based on how easy they are to color.
In this subsection we discuss the classification of almost-cliques (and subsequently, of nodes), and how this can be done in \MPC.
We first give the classification of almost-cliques specified by Fischer \etal \cite{FHM23}:
\begin{definition}[almost-clique Classification (\cite{FHM23})]
\label{def:ac_classification}
A node is \emph{special} to an almost-clique if it is outside the almost-clique and has at least $\Delta^{2/3}/2$ neighbors in the AC. A node is \emph{simplicial} if its neighborhood is a clique. Almost-cliques are characterized as follows:
\begin{itemize}
\item An \emph{easy} almost-clique is one that contains a simplicial node or a non-edge.
\item A \emph{difficult} almost-clique is an almost-clique which is: not easy; has a special neighbor; and $|C| \geq \Delta - \Delta^{1/3}$. Each difficult clique picks a special neighbor $v$ and is then assigned a subtype in the following way:
\begin{itemize}
\item $v$ is an \emph{escape} if it is picked by at least two almost-cliques. Almost-cliques which pick escapes as their special neighbor are \emph{runaway} almost-cliques.
\item $v$ is a \emph{protector} if it is only picked by one AC. Almost-cliques which pick protectors as their special neighbor are \emph{guarded} almost-cliques.
\end{itemize}
\item A \emph{nice} almost-clique is easy or contains a picked special node (of another AC).
\item An \emph{ordinary} almost-clique is neither difficult nor nice.
\end{itemize}
\end{definition}
We simplify the \MPC implementation of classifying almost-cliques by observing that the following is an equivalent definition of an ``easy'' almost-clique.
\begin{observation}[Alternative Characterisation of Easy Cliques]
\label{obs:alternative_easy_cliques}
An almost-clique $C$ is easy if either of the following are true:
(i) there is a non-edge in $C$; or
(ii) $C$ is a clique, and there is a node in $C$ with no external degree.
\end{observation}
\begin{proof}
It suffices to show that if there is no non-edge in the almost-clique, then all simplicial nodes in the almost-clique have no external degree. We prove this by contradiction.
Let $C$ be an almost-clique with no non-edge (i.e.~$C$ is a clique). Suppose there is a simplicial node $v$ with an external neighbor $w$. Then $w \not \in C$, and (since $v$ is simplicial) there is an edge between $w$ and all nodes of $C$. But this contradicts Definition~\ref{defi:acd-delta}.(iv), implying $C$ is not an almost-clique. Therefore no simplicial node in $C$ can have any external degree.
\end{proof}
Using this classification of almost-cliques, Definition 3.2 of \cite{FHM23} requires that the nodes of the graph are partitioned into the following sets:
\begin{itemize}
\item $\mathcal{P}$: The set of protector nodes
\item $\mathcal{E}$: The set of escape nodes
\item $\mathcal{V_*}$: Nodes in $V_{sparse}$, excluding those in $\mathcal{P} \cup \mathcal{E}$
\item $\mathcal{O}$: Nodes in ``ordinary'' almost-cliques
\item $\mathcal{R}$: Nodes in ``runaway'' almost-cliques
\item $\mathcal{N}$: Nodes in ``nice'' almost-cliques, excluding any in $\mathcal{P} \cup \mathcal{E}$
\item $\mathcal{G}$: Nodes in ``guarded'' almost-cliques
\end{itemize}
\begin{lemma}\label{lem:group}
Given an ACD $G = V_{sparse} \sqcup C_1 \sqcup \dots \sqcup C_k$, we can classify all nodes in $G$ into one of the sets from \cite[Definition~3.2]{FHM23} in $O(1)$ \MPC rounds.
\end{lemma}
\begin{proof}
First, we will show that we can classify the almost-cliques $C_1\dots C_k$ according to Definition~\ref{def:ac_classification}. For ease of presentation we will assume that each almost-clique has a dedicated series of machines responsible for classifying it, and consider the classification of some almost-clique $C$ which has $n$ nodes and $m$ edges (including edges incident to $C$). We can classify this almost-clique in $O(1)$ \MPC rounds, using $O(n^\delta)$ local space and $O(n+m)$ global space as follows:
\begin{itemize}
\item \textbf{Easy almost-cliques:} We make use of Observation~\ref{obs:alternative_easy_cliques}, and check the two conditions in order.\\
To check condition~(i) we can add a boolean value to an edge to indicate if both endpoints are in $C$. Let $m'$ be the number of edges with both endpoints in $C$: to check whether there is a non-edge it suffices to check whether $m' = \binom{n}{2}$. This can be done using sorting and prefix-sum in $O(1)$ \MPC rounds. Note that it is easy to extend this computation to \emph{find} a non-edge (find a node in $C$ with degree less than $|C-1|$, and find a node in $C$ which it is not connected to).\\
If there is no non-edge in $C$ then we need to check condition~(ii): whether there is any node in $C$ with no external degree. This can be done using sorting and an application of prefix sum, again in $O(1)$ \MPC rounds.
\item \textbf{Difficult almost-cliques:} We have already checked whether $C$ is easy, and it's also easy to check whether $C$ is of sufficient size.\\
It remains to check whether $C$ has a special neighbor, and if so to further classify $C$ as a ``guarded'' or a ``runaway'' almost-clique. We can sort the edges which are incident to one node in $C$ and one outside and count the number of instances of each endpoint outside $C$ (using prefix sum) to determine if any of them are special.\\
If we do not find a node outside $C$ with enough neighbors in $C$ then $C$ is not difficult. If we do then suppose $v$ is the special node which we pick arbitrarily. We move our frame of reference temporarily to the computation across all almost-cliques. Each almost-clique can send its picked special node to a dedicated series of machines. These machines can sort the special nodes which they receive and determine whether each special node was picked by more than one almost-clique using prefix sum. Then these machines can identify whether each special node is a protector or an escape, and send this information back to the almost-cliques that submitted the special nodes.
\item \textbf{Nice almost-cliques:} $C$ knows whether it is easy, and the dedicated machines which computed the special nodes can inform the machines responsible for $C$ as to whether $C$ contains any picked special nodes.
\item \textbf{Ordinary almost-cliques:} $C$ knows from the previous steps whether it is difficult or nice. If it is neither, it is ordinary.
\end{itemize}
From the almost-clique decomposition (\Cref{lem:mpc-acd-delta}), for each node $v$, $M(v)$ knows either which almost-clique $v$ is in, or knows that $v$ is in $V_{sparse}$. Following the computation above, the machines responsible for classifying $C$ can broadcast its type, and so: if $v$ is in an almost-clique, $M(v)$ also knows which type of almost-clique it is in. $M(v)$ also knows whether $v$ was picked as a special node by any almost-clique, and if so what type of special node $v$ is.
Further, if $v$ is in a nice almost-clique $C$, it knows whether $C$ contains a special node or a non-edge (this matters for \Cref{algo:color-n}). This is because special nodes and non-edges can be identified by the arguments above, and if $M(v)$ knows that $v$ is a special node or the endpoint of a non-edge in its almost-clique, this information can be broadcast to all nodes of $C$ in $O(1)$ rounds (recall that $C$ has constant diameter).
This computation is therefore sufficient to classify the nodes into $\mathcal{O}$, $\mathcal{R}$, $\mathcal{N}$, or $\mathcal{G}$ immediately. Since each machine responsible for a node knows whether its node is a picked special node, they can check membership of $\mathcal{P}$ or $\mathcal{E}$. Finally, as machines also know if their nodes are in $V_{sparse}$, they can check membership of $\mathcal{V}_*$.
\end{proof}
\subsection{Full $\Delta$-coloring algorithm}
\label{sec:implementation_of_coloring}
Algorithm~\ref{algo:Delta-main} is the high level description of the $\Delta$-coloring algorithm in low-space \MPC when $\Delta=\omega(\log^{3} n)$. For formatting reasons, we defer the pseudocode of the subroutines to \Cref{sec:additional_subroutines}. The description is same as the algorithm of for $\Delta$-coloring in the {\sc Congest} model~\cite{FHM23}. Here, our contribution is to argue that the same can be implemented in sublinear \MPC. The algorithm colors the venodesn a specific way such that it breaks the coloring procedure into constant many (Deg+1)-List-Coloring instances. Note that each such (Deg+1)-List-Coloring instance can be solved with $O(\log \log \log n)$ rounds in sublinear \MPC, thanks to \Cref{thm:main:deter}.
\begin{remark}
In the following algorithm and subsequent description, when we color a node $c$ with color $v$, $v$ is considered to be deleted from the graph and $c$ is removed from the palettes of all neighbors of $v$.
When we say we color a set of nodes $U \subseteq V$, we mean that we color the nodes of the graph $G[U]$.
Initially, all nodes have the palette $[\Delta]$.
\end{remark}
\begin{algorithm}[H]
\caption{$\Delta$-{\sc Coloring-LowSpace}} \label{algo:Delta-main}
Compute an ACD as defined in Definition~\ref{defi:acd-delta}.
Classify the nodes into different types using Lemma~\ref{lem:group}.
Run {\sc SlackGeneration} (Algorithm~\ref{algo:slack}) on $\mathcal{V}_* \sqcup \mathcal{O} \sqcup \mathcal{R}$.
{\sc Color-$V_*$} (Algorithm~\ref{algo:color-v-star}): colors $V_* =V_{\text{sparse}} \setminus (\mathcal{P} \cup \mathcal{E})$.
{\sc Color-$\mathcal{O}$} (Algorithm~\ref{algo:color-o}): colors $\mathcal{O}$.
{\sc Color-$\mathcal{R}$} (Algorithm~\ref{algo:color-r}): colors $\mathcal{R}$.
{\sc Color-$\mathcal{N}$} (Algorithm~\ref{algo:color-n}): colors $\mathcal{N}$.
{\sc Color-$\mathcal{GP}$} (Algorithm~\ref{algo:color-g}): colors $\mathcal{G} \cup \mathcal{P}$.
{\sc Color-$\mathcal{E}$} (Algorithm~\ref{algo:color-e}): colors $\mathcal{E}$.
\end{algorithm}
Finally, we prove \Cref{lem:high_degree_delta_col}, arguing that \Cref{algo:Delta-main} can be implemented in $O(\log\log\log n)$ rounds of \MPC.
\begin{proof}[Proof of \Cref{lem:high_degree_delta_col}]
Correctness of the algorithm follows from arguments made in \cite{FHM23}.
Regarding implementation: we look at all of the steps of \Cref{algo:Delta-main} in turn:
\begin{enumerate}
\item By \Cref{lem:mpc-acd-delta}, we can compute an ACD in \MPC in $O(1)$ rounds.
\item By \Cref{lem:group}, we can classify all nodes into their respective sets in $O(1)$ \MPC rounds.
\item \Cref{algo:slack} requires each machine responsible for a node to make a random choice and broadcast it to neighbors: by \Cref{lem:mpc_capabilities} this can be done in $O(1)$ rounds.
\item \Cref{algo:color-v-star} just requires a single use of \Cref{thm:main:deter}.
\item \Cref{algo:color-o}: $M(v)$ can determine whether $v$ has slack by arguments similar to those in \Cref{lem:computing_parameters} (we no longer have $\Delta < \sqrt{\lspace}$, but slack can still be computed using prefix sum). The remainder of the algorithm consists of two uses of \Cref{thm:main:deter}.
\item \Cref{algo:color-r}: $M(v)$ knows whether $v$ is a member of a runaway clique and whether it is an escape node. Machines can broadcast whether their node is an escape node, and subsequently determine whether their node is adjacent to its clique's escape node (and hence in $\mathcal{Y}$). The remainder of the algorithm is two uses of \Cref{thm:main:deter}.
\item \Cref{algo:color-n}: By \Cref{lem:group}, machines know which subtype of nice almost-clique they belong to. Then, depending on which subtype a node's almost-clique is, we do one of the following:
\begin{enumerate}
\item \Cref{algo:color-n-1}: Similar to \Cref{algo:color-r}, machines can determine whether their node is adjacent to a special node. The remainder of the algorithm is two uses of \Cref{thm:main:deter}.
\item \Cref{algo:color-n-2}: By \Cref{lem:group}, machines know whether their node is the simplicial node in that node's almost-clique with the lowest ID. The remainder of the algorithm is two uses of \Cref{thm:main:deter}.
\item \Cref{algo:color-n-3}: By \Cref{lem:group}, we have identified a non-edge from the all nice almost-cliques which have them. We can compute the union of the palettes of each edge using sorting, and then gather all of these non-edges on a dedicated series of machines.\\
Machines can broadcast whether the nodes they are responsible for are endpoints of a non-edge in their almost-clique, and we can then send all edges for which both endpoints are endpoints of a non-edge, and send those to the same dedicated series of machines. Those machines can determine which non-edges are adjacent and create the virtual graph, and call the D1LC algorithm on that graph (\Cref{thm:main:deter}) and color the endpoints as described.\\
Then, machines can check whether their nodes are adjacent to both endpoints of the almost-clique containing their node, and after two more uses of \Cref{thm:main:deter}, we are done.
\end{enumerate}
\item \Cref{algo:color-g}: We can identify a non-neighbor of the protector node of each clique using sorting. After this is done, the remaining steps of this algorithm mirror that of \Cref{algo:color-n-3}.
\item \Cref{algo:color-e} just uses \Cref{thm:main:deter} once.
\end{enumerate}
Since we can implement each of its steps in $O(\log\log\log n)$ rounds in the stated local and global space bounds, we can implement \Cref{algo:Delta-main} in $O(\log\log\log n)$ rounds: this concludes the proof of the lemma.
\end{proof}
\section{Preliminaries (and overview of \cite{hknt_local_d1lc})}
\label{sec:overview_of_hknt}
In this section, we give an overview of the recent work of \cite{hknt_local_d1lc}. Among several other contributions, \cite{hknt_local_d1lc} give an algorithm which, in the \LOCAL model of distributed computing, given an input instance of $(\deg + 1)$-list coloring {for a graph $G$}, colors all nodes of $G$ having degrees at least $\log ^7 n$ in $O(\log^* n)$ rounds. We give an overview of their algorithm here, because our algorithm in \MPC to color all nodes in the degree range $\left[\log^7 n, n^{7\delta}\right]$ uses steps of the algorithm in~\cite{hknt_local_d1lc}, where $\delta < \phi$ (recall that $\phi$ is our local space parameter, i.e., $\lspace=O(n^\phi)$). In particular, \Cref{sec:randomized-d1lc} argues that we can simulate this algorithm of {\cite{hknt_local_d1lc}} in sublinear \MPC, and \Cref{sec:deterministic_d1lc} argues that we can do so deterministically.
The algorithm of \cite{hknt_local_d1lc} (for the degree range $[\log^7 n, n]$) requires several careful arguments which rely on nodes being able to calculate certain parameters, in particular the following:
\begin{definition}[Parameters from \cite{hknt_local_d1lc}]
\label{def:parameters}
The following node-parameters are used in the coloring algorithm of \cite{hknt_local_d1lc}:
\begin{itemize}
\item \emph{Slack} $\slack{v} = p(v) - d(v)$: The difference between a the size of the palette of a node and its degree.
\item \emph{Sparsity} $\sparsity{v} = \frac{1}{d(v)} \cdot \left[ \binom{d(v)}{2} - m(N(v)) \right]$~\footnote{{$m(N(v))$ denotes the number of edges in the subgraph induced by $N(v)$}.}: The proportion of non-edges between neighbors of $v$.
\item \emph{Disparity} $\disparity{u}{v} = |\Psi(u) \setminus \Psi(v)| / |\Psi(u)|$: The (proportional) difference between the palettes of $u$ and $v$.
\item \emph{Discrepancy} $\discrepancy{v} = \sum_{u \in N(v)} \discrepancy{u, v}$: The sum of disparities between $v$ and its neighbors.
\item \emph{Unevenness} $\unevenness{v} = \sum_{u \in N(v)} \frac{\max(0, d(u) - d(v))}{d(u) + 1)}$: A quantity that relates to how many of the neighbors of $v$ have much higher degree than $v$.
\item \emph{Slackability} $\slackability{v} = \discrepancy{v} + \sparsity{v}$, \emph{Strong Slackability} $\sslackability{v} = \unevenness{v} + \sparsity{v}$: How easy it is to create slack for a node.
\end{itemize}
\end{definition}
The coloring algorithm for the degree range $\left[\log^7 n, n\right]$ given in \cite{hknt_local_d1lc} has the form outlined as \Cref{alg:color_middle_degrees}. As already mentioned, we use that algorithm to color the nodes with degrees in $[\log^7 n, n^{7\delta}]$. We will discuss the subroutines of \Cref{alg:color_middle_degrees} in subsequent subsections from \Cref{sec:acd}--\Cref{sec:dense}.
\begin{algorithm}[H]
\caption{${\text{\sc ColorMiddle}}$: Colors nodes with degrees in $[\log^7 n, n^{7\delta}]$ {\small (extracted from \cite{hknt_local_d1lc})}}
\label{alg:color_middle_degrees}
Compute an almost-clique decomposition (ACD).
{\sc ColorSparse} (\Cref{alg:color_sparse}).
{\sc ColorDense} (\Cref{alg:color_dense}).
\end{algorithm}
\subsection{Computing an almost-clique decomposition}
\label{sec:acd}
First, the authors of \cite{hknt_local_d1lc} compute an \emph{almost-clique decomposition} of the input graph. The almost-clique decomposition is as follows:
\begin{definition}[{$(\mbox{deg}+1)$-ACD}~\cite{AlonA20, hknt_local_d1lc}]
\label{def:acd}
Let $G=(V,E)$ be a graph and $\veps_{ac}, \veps_{sp} \in (0,1)$ be constants. A partition of $V$ into $V_{\text{sparse}} \sqcup V_{\text{uneven}} \sqcup V_{\text{dense}}$, such that $V_{\text{dense}}$ can be partitioned into $C_1, \ldots, C_t$ for some $t$, is said to be an almost-clique decomposition for $G$ if
\begin{enumerate}
\item[(i)] Every $v \in V_{\text{sparse}}$ is $\veps_{sp} d(v)$-sparse;
\item[(ii)] Every $v \in V_{\text{uneven}}$ is $\veps_{sp} d(v)$-uneven;
\item[(iii)] For every $i \in [t]$ and $v \in C_i$, $d(v)\leq (1+\veps_{ac})\size{C_i}$;
\item[(iv)] For every $i \in [t]$ and $v \in C_i$, $\size{C_i} \leq (1+\veps_{ac})\size{N(v) \cap C_i}.$
\end{enumerate}
\end{definition}
Intuitively:
\begin{itemize}
\item $V_{\text{sparse}}$: A set of (sufficiently) \emph{sparse} nodes. A node is $\varepsilon$-sparse if there are $\varepsilon \cdot d(v)$ many non-edges between neighbors of $v$.
\item $V_{\text{uneven}}$: A set of \emph{uneven} nodes. A node is uneven if many of its neighbors have a much higher degree than $v$. Formally, a node $v$ is $\eta$-uneven if $\eta_v \geq \sum_{u \in N(v)} \frac{\max(0, d(u) - d(v))}{d(u) + 1}$.
\item $V_{\text{dense}}=C_1\sqcup \dots \sqcup C_t$: Each $C_i$ is an \emph{almost-clique}. Intuitively, almost-cliques are very well connected parts of the graph. Formally, for some $\varepsilon_{sc}$ and for all almost-cliques $C_i$ and all $v \in C_i$, $d(v) \leq (1 + \varepsilon_{ac}) \size{C_i}$, and $\size{C_i} \leq (1 + \varepsilon_{ac}) \size{N(v) \cap C_i}$.
\end{itemize}
After computing an ACD and partitioning the nodes into $V_{\text{sparse}}$, $V_{\text{uneven}}$ and $V_{\text{dense}}$, nodes in $V_{\text{sparse}} \sqcup V_{\text{uneven}}$ are colored first by \textsc{ColorMiddle} (\Cref{alg:color_middle_degrees}) by subroutine \textsc{ColorSparse} and then the nodes in $V_{\text{dense}}=C_1 \sqcup \dots \sqcup C_t$ are colored hy subroutine \textsc{ColorDense}.
\subsection{Coloring sparse nodes}\label{sec:sparse}
Before discussing about coloring the sparse nodes, we first discuss about a subroutine {\sc SlackColor} (\Cref{alg:slack_color}) which is used by Step 2 and 3 of \Cref{alg:color_middle_degrees} for colorng sparse nodes and dense nodes, respectively.
\textsc{SlackColor} colors all nodes which have slack linear in their degree (and the degree is large enough) in $O(\log^*n)$ rounds. The authors of \cite{hknt_local_d1lc} point out that similar results were shown in \cite{sw10-distributed-symmetry-breaking}: in this paper we focus on simulating and derandomizing the algorithm {\sc SlackColor} given in \cite{hknt_local_d1lc}.
Note that {\sc SlackColor} takes two parameter $s_{min}$ and $\kappa$ as input where $s_{min}$ is an integer that lies between $1$ and the minimum amount of slack of any node (that we want to color) and $\kappa$ lies between $1/s_{min}$ and $1$. \footnote{The success probability of \textsc{SlackColor} depends on $s_{min}$ and $\kappa$. Also, \cite{hknt_local_d1lc} uses \textsc{SlackColor} only when $s_{min}=\Omega(\ell)$ and $\kappa$ is a suitable constant, where \mbox{$\ell=\log^{2.1}\Delta$ .}}.\textsc{SlackColor} requires two subroutines, i.e., \textsc{TryRandomColor} (\Cref{alg:try_random_color}) and \textsc{MultiTrial} (\Cref{alg:multi_trial}).
\begin{algorithm}[H]
\caption{\textsc{SlackColor}$(s_{min})$, for node $v$, from \cite{hknt_local_d1lc}}
\label{alg:slack_color}
Do ${\text{\sc TryRandomColor}}(v)$ for $O(1)$ rounds.
If $\slack{v} < 2d(v)$ then terminate.
Let $\rho\gets s_{\min}^{1/(1+\kappa)}$. \textit{\small \hfill //$s_{min}$ is globally known such that $1<s_{min}\leq\min_{v}s(v)$ and $\kappa$ is an input parameter such that $1/s_{min}<\kappa \leq 1$.}
\For{$i$ from $0$ to $\log^* \rho$}{
$x_i \gets 2 \uparrow \uparrow i$ \textit{\small \hfill // {$2 \uparrow \uparrow i$ refers to iterated exponentiation, i.e., $2 \uparrow \uparrow 0 = 1$ and $2 \uparrow \uparrow (i + 1) = 2^{2 \uparrow \uparrow i}$}.}
$\text{{\sc MultiTrial}}(x_i)$ $2$ times
If $d(v) > \slack{v}/\min(2^{x_i},\rho^\kappa)$ then terminate.
}
\For{$i$ from $1$ to $\lceil 1/\kappa \rceil$}{
$x_i \gets \rho^{i \cdot \kappa}$.
$\text{{\sc MultiTrial}}(x_i)$ $3$ times.
If $d(v) > \slack{v}/\min(\rho^{(i+1) \cdot \kappa},\rho)$ then terminate.
}
$\text{{\sc MultiTrial}}(\rho)$.
\end{algorithm}
\begin{algorithm}[H]
\caption{{\sc TryRandomColor}(node $v$) from \cite{hknt_local_d1lc}}
\label{alg:try_random_color}
Pick $\psi_v$ u.a.r. from $\Psi(v)$.
Send $\psi_v$ to each $u \in N(v)$, receive the set $T = \{\psi_u : u \in N^+(v)\}$, where $N^+(v)$ is the set of neighbours whose colors ``conflict'' with $v$.
If $\psi_v \not\in T$ then permanently color $v$ with $\psi_v$.
Send and receive permanent colors, and remove the received one from $\Psi(v)$
\end{algorithm}
\begin{algorithm}[H]
\caption{$\text{\sc{MultiTrial}}(x)$ from \cite{hknt_local_d1lc}}
\label{alg:multi_trial}
$v$ picks a set $X_v$ of $x$ random colors in its palette $\Psi(v)$, sends them to neighbours
\If{$\exists \psi \in X_v$ such that $\forall u \in N(v), \psi \not \in X_v$}{
Permanently color $v$ with some such $\psi$ and broadcast to $N(v)$.
}
\end{algorithm}
The first coloring task is to color all nodes which are \emph{sparse} or \emph{uneven} (that are in $V_{\text{sparse}}$ or $V_{\text{uneven}}$). The outline of the subroutine which does this ({\sc ColorSparse}) is in \Cref{alg:color_sparse}.
\begin{algorithm}[H]
\caption{{\sc ColorSparse} from \cite{hknt_local_d1lc}}
\label{alg:color_sparse}
Identify set of nodes $V_{\text{start}} \subset V_{\text{sparse}}$.
{\sc GenerateSlack} in $G\left[(V_{\text{sparse}} \cup V_{\text{uneven}}) \setminus V_{\text{start}}\right]$.
{\sc SlackColor} $V_{\text{start}}$.
{\sc SlackColor} $V_{\text{sparse}} \setminus V_{\text{start}}$ and $V_{\text{uneven}}$.
\end{algorithm}
The challenge here is that all nodes at the start of the algorithm are only guaranteed to have constant slack: in the (easier) $(\Delta + 1)$-coloring problem, nodes of low-degree are guaranteed to have slack linear in their degree. The authors of \cite{hknt_local_d1lc} overcome this by identifying some subset of the nodes in $V_{\text{sparse}}$ for which it is hard to generate slack: they call this set $V_{\text{start}}$. They then generate some slack using a simple primitive ({\sc GenerateSlack}, \Cref{alg:generate_slack}) for nodes in $(V_{\text{sparse}} \cup V_{\text{uneven}}) \setminus V_{\text{start}}$.
\begin{algorithm}[H]
\caption{{\sc GenerateSlack} from \cite{hknt_local_d1lc}}
\label{alg:generate_slack}
$S \gets$ Each node $v$ is sampled into $S$ independently w.p. $1/10$.
For all $v \in S$ in parallel $\text{{\sc TryRandomColor}}(v)$.
\end{algorithm}
They show that nodes in $V_{\text{start}}$ have many neighbours in $(V_{\text{sparse}} \cup V_{\text{uneven}}) \setminus
V_{\text{start}}$, and so nodes in $V_{\text{start}}$ have considerable \emph{temporary slack} (slack obtained from neighbors being colored later). Since $(V_{\text{sparse}} \cup
V_{\text{uneven}}) \setminus V_{\text{start}}$ are exactly the nodes
which do not struggle to obtain slack, they have that all
sparse/uneven nodes have slack linear in their degree, and this is
enough to color them in $O(\log^* n)$ rounds (by the algorithm of
\cite{sw10-distributed-symmetry-breaking} or by {\sc SlackColor}).
\subsection{Coloring dense nodes}\label{sec:dense}
Finally, it remains to color nodes in the almost-cliques $C_1 \sqcup \dots \sqcup C_t$. The algorithm for doing this given in \cite{hknt_local_d1lc} is {\sc ColorDense} (\Cref{alg:color_dense}).
\begin{algorithm}[H]
\caption{{\sc ColorDense} from \cite{hknt_local_d1lc}}
\label{alg:color_dense}
Compute the leader $x_C$ and outliers $O_C$ for each almost-clique $C$. Let $O=\bigcup\limits_{C \in \cC} O_C$, where $\cC$ denotes the set of all almost-cliques.
{\sc GenerateSlack}.
$P_C \leftarrow${\sc PutAside}$(C)$ for each low slack almost-clique $C$. Let $P$ denote the set of union of all such $P_C$'s.
{\sc SlackColor} $O$.
{\sc SynhColorTrial} $V _{\text{dense}} \setminus P$.
{\sc SlackColor} $V_{\text{dense}} \setminus P $.
For each $C \in C$ with low slackability, $x_C$ collects the palettes in $P_C$ and colors the nodes locally.
\end{algorithm}
First, each almost-clique $C$ selects a \emph{leader} $x_C$, i.e., the node with minimum slackability (breaking ties arbitrarily).~\footnote{See Definition~\ref{def:parameters} for the definition of slackability of a node.} The slackability of an almost-clique $C$ is the slackability of the leader $x_C$. $C$ is said to an almost-clique with low slackability if its slackability is at most $\ell=\log^{2.1} \Delta$; otherwise $C$ has high slackability. For each each almost-clique with low slackability, we need to to remove some of the nodes to help the coloring process. The details will be discussed later in this section.
The intuition is that the leader has similar palettes to a large fraction of other nodes in the almost-clique, a property which will be useful later. Then the almost-clique is split roughly in half, into \emph{inliers} and \emph{outliers}: inliers are the nodes that are similar to the leader (by some criteria that we will discuss later), and outliers are nodes which are dissimilar to the leader. In particular, since outliers are (slightly less than) half of the almost-clique, they have slack linear in their degree and can be colored in $O(\log^* n)$ rounds by {\sc SlackColor} (if we defer the nodes in the inliers to be colored later).
Next, inliers need to be colored. Since the leader is very similar to the inliers (in particular: it is connected to all inliers and has a similar palette to them), a surprisingly simple process, where the leader proposes one of its colors to each inlier (such that it proposes each color to at most one inlier), suffices. The pseudocode for this process is given in {\sc SynchColorTrial} (\Cref{alg:synch}). After {\sc SynchColorTrial} has completed, there is linear slack at each remaining inlier to apply {\sc SlackColor} and color the remaining inliers in $O(\log^* n)$ rounds.
\begin{algorithm}
\caption{{\sc SynhColorTrial} for almost-clique $C$ \cite{hknt_local_d1lc}}
\label{alg:synch}
{
$x_C$ randomly permutes its pallete $\Psi(x_C)$, sends each neighbor $v \in I_C$ a distinct color $c(v)$.
\textit{\small \hfill // $I_C=C\setminus O_C$ denotes the set of inliers of the almost-clique $C$.}
Send $c(u)$ to $N(v)$, and receive the set $T=\{c(u):u \in N^{+}(v)\}$. \textit{\small \hfill // $N^+(v)$ is the set of neighbours whose colors ``conflict'' with $v$.}
If $c(v) \notin T$, then permanently color $v$ with $c(v)$.
Send and receive permanent colors, and remove the received one from $\Psi(v)$.
}
\end{algorithm}
\begin{algorithm}
\caption{{\sc PutAside}($C$) from~\cite{hknt_local_d1lc}}
\label{alg:put-aside}
{
Sample each node in $v \in I_C$ independently with probability $p_s=\frac{\ell^2}{48 \Delta_C}$, and include in the set $S_C$, where $\ell=\log ^{2.1} \Delta$.
Let $S$ denote the union of such $S_C$'s.
return $P_C$ as the set of nodes in $S_C$ that does not have a neighbor in $S$.
}
\end{algorithm}
Finally, there is an additional challenge to overcome for some almost-cliques. If the ``slackability'' (intuition: a measure of easy it is to generate slack) is low, {\sc SynchColorTrial} might not create enough slack for the remaining inliers. The authors of \cite{hknt_local_d1lc} get around this by computing a ``put-aside'' set: a set of inliers which we set aside and color at the end of the algorithm. The put-aside set is computed using {\sc PutAside} (\Cref{alg:put-aside}), and has three important properties: it is of polylogarithmic size (in each almost-clique that needs it); put-aside sets in different almost-cliques have no edges between them; and the inliers not assigned to the put-aside set each have {sufficient neighbours in the put-aside sets} which are to create sufficient slack to be colored ultrafast by {\sc SlackColor}.
\section{Introduction}
\label{sec:intro}
Graph coloring is one of the most fundamental problems in algorithms which has been studied extensively in various settings for several decades. It has been playing an especially prominent role in distributed and parallel computing, not only because of its numerous applications, but also since some variants of coloring problems naturally model typical symmetry breaking problems, as frequently encountered in decentralized systems (see, e.g., \cite{BE13} for an overview of early advances).
Parallel graph coloring has been studied since the 1980s \cite{karloff1985fast}, and nowadays $(\Delta+1)$-coloring and $(2\Delta-1)$-edge-coloring are considered among the most fundamental graph problems in the area (here and throughout the paper, $\Delta$ refers to the maximum degree of the input graph).
In this paper, we study the parallel complexity of a natural generalization of the $(\Delta+1)$-coloring problem\footnote{$(\Delta+1)$-coloring problem is to color a graph of maximum degree $\Delta$ using $\Delta+1$ colors.}, the problem of \emph{(degree+1)-list coloring} (\DILC). In the \DILC problem, for a given undirected graph $G = (V,E)$, each node has an input palette of acceptable colors of size one more than its degree, and the objective is to find a proper coloring using these palettes. While it is easy to design a simple linear-time (sequential) greedy algorithm for \DILC, the parallel and distributed complexity of \DILC is less well understood. Clearly, the problem is not easier than the $(\Delta+1)$-coloring problem and its variant the $(\Delta + 1)$-list coloring proble
\footnote{In $(\Delta + 1)$-list coloring each node has a palette of $\Delta+1$ many colors for its disposal (rather than $\deg+1$ many, as in~\DILC).}, but the challenge of dealing with nodes having color palettes of greatly different sizes seems to make the problem significantly more difficult. Still, it has been observed that by using techniques developed in \cite{FHK16,Kuhn20}, one can deterministically reduce \DILC to $(\Delta + 1)$-list coloring with only an $O(\log\Delta)$ multiplicative and $O(\log^*n)$ additive overhead in the running time (number of rounds). However the logarithmic complexity gap is still significant and until very recently, this gap has been elusive for the most efficient distributed and parallel algorithms for \DILC. The first advance (in the distributed setting) has come only very recently, when Halld{\'o}rsson, Kuhn, Nolin, and Tonoyan \cite{hknt_local_d1lc} presented a randomized $O(\log^3\log n)$-rounds distributed algorithm for \DILC in the \LOCAL distributed model, matching the state-of-the art complexity for the simpler $(\Delta+1)$-coloring problem due to Chang, Li, and Pettie \cite{CLP20}). In another very recent work, Halld{\'o}rsson, Nolin, and Tonoyan \cite{HNT22} extended the framework and showed that \DILC can be solved
in $O(\log^5\log n)$-rounds in the distributed \CONGEST model, matching the state-of-the-art complexity for the simpler $(\Delta+1)$-coloring problem in \CONGEST by Halld{\'{o}}rsson, Kuhn, Maus, and Tonoyan~\cite{HKMT21}).
In this paper we demonstrate that the \DILC problem can be efficiently solved in the \emph{Massively Parallel Computation} (\MPC) model with sublinear local space, matching the complexity of the state-of-the-art \MPC algorithms for the simpler $(\Delta+1)$-coloring and $(\Delta+1)$-list coloring problems.
\paragraph{MPC model}
The \emph{Massively Parallel Computation} (\MPC) model, introduced over a decade ago by Karloff \etal \cite{KSV10}, is a nowadays standard theoretical model for parallel algorithms. The model has been developed on the basis of its successful modeling of parallel and distributed frameworks such as MapReduce \cite{mapreduce}, Hadoop \cite{hadoop}, Dryad \cite{dryad}, and Spark \cite{spark}, and it shares many similarities to classical models of parallel computation (e.g., PRAM) and distributed models (e.g., \CONGESTEDC). In this paper, we focus on the \emph{low-space/sublinear} MPC regime, in which machines have local space $\lspace = O(n^{\phi})$ for any arbitrary constant $\phi \in (0,1)$, where $n$ is the number of nodes in the graph. This model has attracted a lot of attention recently, see, e.g., \cite{ANOY14,ASSWZ18,BKS17,BHH19,BKM20,BBDFHKU19,CC22,CFGUZ19,CDP20,CDP21,CDPsparse,CLMMOS18,GGKMR18,GKU19,GU19,GSZ11,LMOS20}. Recent works have provided many algorithms for fundamental graph problems such as connectivity, approximate matching, maximal matching, maximal independent set, and $(\Delta+1)$ coloring.
It is known that the $(\Delta+1)$-coloring algorithm due to Chang \etal \cite{CFGUZ19} can be combined with the network decomposition result of \cite{RG20} to obtain a randomized $O(\log\log\log n)$-round \MPC algorithm, which is currently the state-of-the-art bound for $(\Delta+1)$-list-coloring. Recently, Czumaj \etal \cite{CDP21} showed that this result can be derandomized, even for the list-coloring version of the problem. In this paper we show that these bounds can be matched on a sublinear local space \MPC for the more general \DILC problem.
We first show how to combine the \DILC framework for the \LOCAL model due to Halld{\'o}rsson \etal \cite{hknt_local_d1lc} with the techniques developed in earlier works on the \MPC model, to obtain a randomized \MPC algorithm for \DILC working in $O(\log\log\log n)$ rounds, w.h.p.
Then we present a more challenging part (our main contribution) and show that the $O(\log\log\log n)$-rounds randomized \MPC algorithm can be efficiently derandomized in the \MPC model.
\begin{theorem}[\textbf{Main}]
\label{thm:main:deter}
Let $\spacexp \in (0,1)$ be an arbitrary constant. There exists a deterministic algorithm that, for every $n$-node graph $G=(V,E)$, solves the \DILC problem using $O(\log\log\log n)$ rounds, in the low-space \MPC model with local space $\lspace = O(n^{\spacexp})$ and global space $O(m+n^{1+\spacexp})$.
\end{theorem}
Observe that the bound in \Cref{thm:main:deter} matches the state-of-the-art bound for the complexity of the simpler $(\Delta+1)$-coloring problem in the (low-space) \MPC model (see \cite{CFGUZ19} for the randomized bound and \cite{CDP21} for the deterministic bound). Furthermore, the recently developed framework connecting the complexity of \LOCAL and low-space \MPC algorithms (see \cite{GKU19,CDPcompstab}), provides some evidence that our upper bound cannot be asymptotically improved, unless the complexity of the $(\Delta+1)$-coloring problem is
$(\log\log n)^{o(1)}$
in the \LOCAL model. This is because \cite{GKU19,CDPcompstab} show that for a class of component stable algorithms and conditioned on the so-called 1-vs-2-cycles conjecture, no low-space \MPC algorithm can run faster than the logarithm of the complexity of \LOCAL algorithms. (Still, even conditioned on the 1-vs-2-cycles conjecture, it might be conceivable that a non-component stable randomized \MPC low-space algorithm can solve $(\Delta+1)$-coloring in $o(\log\log\log n)$ rounds, and further, we do not have any good enough \LOCAL lower bounds for coloring, and so maybe an
$(\log\log n)^{o(1)}$-rounds
\LOCAL algorithm is possible.)
Finally, notice that Roughgarden \etal \cite{RVW18} showed that proving any super-constant lower bound in the low-space \MPC for any problem in \model{P} would separate $\model{NC}^1$ from \model{P}, making any \emph{unconditional} super-constant (low-space \MPC) lower bound unlikely.
As an application of our framework for \DILC developed in \Cref{thm:main:deter}, we consider the related problem of $\Delta$-coloring graphs of maximum degree $\Delta \ge 3$ that contain no clique of size $\Delta+1$ (cf. Brooks' theorem \cite{Brooks41}). Recently, Fischer, Halld{\'o}rsson, and Maus \cite{FHM23} devised a general approach allowing to reduce in a constant number of rounds (in \LOCAL, \CONGEST, \and \CONGESTEDC) the $\Delta$-coloring problem to a constant number of instances of (degree+1)-list coloring, assuming $\Delta = \omega(\log^3 n)$ (for the \CONGESTEDC algorithm $\Delta = \omega(\log^{4+\varepsilon} n)$ is required, for a small constant $\varepsilon$). This was then extended to obtain a randomized $O(\text{poly}(\log\log n))$-rounds \LOCAL algorithm to $\Delta$-color any graph of maximum degree $\Delta \ge 3$ that does not contain a clique of size $\Delta+1$. In this paper we obtain a similar result for the \MPC model.
\begin{theorem}
\label{thm:delta_coloring}
Let $\spacexp \in (0,1)$ be an arbitrary
constant. There exists a randomized algorithm that for any $n$-node graph $G = (V,E)$ with maximum degree $\Delta \ge 3$ that does not contain a $(\Delta+1)$-clique, finds a $\Delta$-coloring of $G$ in $O(\log\log\log n)$ rounds on the low-space \MPC model with local space $\lspace =O(n^{\spacexp})$ and global space $O(m+n^{1+\spacexp})$.
\end{theorem}
In this paper, our main focus is on the proof of \Cref{thm:main:deter} and we defer its application to the proof of \Cref{thm:delta_coloring} to \Cref{sec:Delta-coloring}.
\subsection{Setting and notation}
\label{sec:setting}
For $k \in \mathbb{N}$, $[k]$ denotes the set $\{1,\ldots,k\}$. For $a,b \in \mathbb{N}$, $[a,b]$ denotes the set of integers in $\{a,a+1,\ldots,b\}$. We consider a graph
$G=(V,E)$ with $V$ as the node set and $E$ as the edge set with $|V|=n$ and $|E|=m$.
The set of neighbors of a node $v$ is denoted by $N(v)$ and the degree of a node $v$ is denoted by $d(v)$. For a node $v$, $\Psi(v)$ denotes the list of colors in the color palette of node $v$ and $p(v)$ denotes the size of $\Psi(v)$. The maximum degree of any node in $G$ is denoted by $\Delta$. As we go on coloring the nodes of the graph $G$, the graph will change and the color palettes of the nodes will also change. Often, we denote the current (rather than the input) graph by $G$. For all graphs we consider, we have $p(v)\geq d(v)+1$. For a subset $X \subseteq V$, $G[X]$ denotes the subgraph induced by $X$ and $m(X)$ denotes the number of edges in $G[X]$.
\paragraph{Degree+1 list coloring (D1LC)}
The \textbf{degree+1 list coloring (D1LC) problem} is for a given graph $G = (V,E)$ and given color palettes $\Psi(u)$ assigned to each node $u \in V$, such that $\size{\Psi(u)} \geq d(u)+1$, the objective to find a proper coloring of nodes in $G$ such that each node as assigned to a color from its color palette (and, as in proper coloring, no edge in $G$ is monochromatic).
\paragraph{Massively Parallel Computation model.}
We consider the \emph{Massively Parallel Computation} (\MPC) model, which is a parallel system with some number of machines, each of them having some local space~\lspace.
At the beginning of computation, each machine receives some part of the input, with the constraint that it must fit within its local space. In our case, for the \DILC problem, the input is a set of $n$ nodes, $m$ edges, and $n$ color palettes of total size $O(n+m)$. Hence we will require that the number of machines is $\Omega(\tfrac{n+m}{\lspace})$, for otherwise the input would not fit the system. The computation on an \MPC proceeds in synchronous rounds. In each round, each machine processes its local data and performs an arbitrary local computation on its data without communicating with other machines. At the end of each round, machines can exchange messages. Each message is sent only to a single machine specified by the machine that is sending the message. All messages sent and received by each machine in each round have to fit into the machine's local space. Hence, the total number of messages sent by any machine and received by any machine is bounded by \lspace, and the total amount of communication across the whole \MPC is bounded by \lspace times the number of machines. At the beginning of the next round, each machine can process all messages received in the previous round. When the algorithm terminates, machines collectively output the solution.
Observe that if a single machine can store the entire input, then any problem (like, e.g., \DILC) can be solved in a single round, since no communication is required. In order for our algorithms to be as scalable as possible, normally one wants to consider graph problems in the low-space regime, where local space $\lspace = n^{\spacexp}$ for any given constant $\spacexp \in (0,1)$. (There has been some research considering also the case when $\lspace = \Theta(n)$, or even when $\lspace = n^{1+\spacexp}$ (in which case one wants to study the case that $\lspace \ll m$) but we will not consider such setting in the current paper.) We will require that the number of machines is not significantly more than required,
specifically that it is $\widetilde{O}(n+\frac{m}{\lspace})$ (note that the optimal amount would be $\widetilde{O}(\frac{n+m}{\lspace})$, but our algorithm requires the ability to assign a machine to each node).
A major challenge in the design of \MPC algorithms in the low-space regime is that the local space of each machine is (possibly) not sufficient to store all the edges incident to a single node. This constraint naturally requires an \MPC algorithm to rely on extensive communication between machines, and most of the techniques known are based on some graph sparsification. It is important to note here that even in the low-space regime, the \MPC model is known \cite{GSZ11} to be stronger than the PRAM model, e.g., it is known that sorting\footnote{Here we consider sorting of $N$ objects on an \MPC with local space $N^{\gamma}$ and on $N^{1-\gamma}$ machines, for any constant $\gamma>0$.} (and in fact, many related tasks, like prefix sum computation) can be performed in a constant number of rounds, even deterministically, see \cite{GSZ11}. Observe that with this tool, we can gather nodes' neighborhoods to contiguous blocks of machines, and learn their degrees, in a constant number of rounds, and that we can assume, without loss of generality, that the input can be distributed arbitrarily on the first $\Theta(\tfrac{n+m}{\lspace})$ machines on an \MPC.
\subsection{Technical contribution}
While the \MPC model is notionally stronger than \LOCAL, writing \MPC algorithms which work in an exponentially lower number of rounds than their \LOCAL counterparts is often challenging, due to the limited local space of each machine in the \MPC model. In particular, nodes of high degree often cannot hope to collect their $2$-hop neighborhood in the \MPC model, and this renders many common subroutines in \LOCAL algorithms challenging (for example, in the setting of coloring, computing an almost-clique decomposition).
We overcome this technical difficulty using a deterministic recursive sparsification approach similar to \cite{CDP20,CDP21} where we repeatedly partition an instance of \DILC with maximum degree $\Delta$ into $n^\delta$ \DILC instances, each with maximum degree $\Delta / n^\delta$. Here $\delta \in (0,1)$ is a constant less than $\phi$ to be fixed later and $\phi$ is our local space parameter, i.e., $s=O(n^\phi)$. All but one of these instances are \emph{valid} \DILC instances and so can be solved immediately (using this recursive sparsification if the degree is still too high), and the final instance can only be solved when it is determined which colors are unused in the other instances. In this way, we can reduce the maximum degree of the \DILC instances which we have to solve to an arbitrarily small polynomial in $n$.
For \DILC instances with degrees between $\log^7 n$ and some arbitrarily small polynomial $n^\delta$, we show that a recent algorithm of \cite{hknt_local_d1lc} can be efficiently simulated in the \MPC setting using information only in the $2$-hop neighborhood of each node. Then, we show that the randomized subroutines from the algorithm of \cite{hknt_local_d1lc} can be efficiently derandomized, as they all satisfy a particular set of properties. The derandomization in this paper uses pseudorandom generators (PRGs) combined with the method of conditional expectations. The main difficulty is that PRGs restricted by the local space requirement of low-space \MPC will fail on some non-trivial proportion of nodes even if the base randomized procedure succeeds with high probability. Furthermore, in general this can cause a chain reaction of nodes failing to meet the success requirements of the randomized procedure. To overcome this difficulty, we formalize in \Cref{prng-derandomizable} a collection of properties that allow us to fully derandomize a procedure the PRG, which we prove in \Cref{lem:fullderand}. This lemma may be of independent interest as a powerful black-box derandomization technique in \MPC.
For instances with degree lower than $\log^7 n$, we can use an existing algorithm of Czumaj et al. \cite{CDP21}.
\paragraph{$\Delta$-coloring.}
The \DILC problem has been studied extensively in distributed and parallel setting largely thanks to its use in the designing of algorithms for other coloring problems. For example, \DILC has been frequently used as a subroutine in $(\Delta + 1)$-coloring algorithms (in the post-shattering step). Fischer \etal \cite{FHM23} observed recently that one can solve the $\Delta$-coloring problem using algorithms for \DILC: the approach due to Fischer \etal relies on a reduction from $\Delta$-coloring to a constant number of D1LC instances. We combine our \DILC \MPC algorithm from \Cref{thm:main:deter} with the reduction from \cite{FHM23} to obtain an $O(\log\log\log n)$-rounds algorithm for the $\Delta$-coloring problem (\Cref{thm:delta_coloring}). In particular, we show that the delicate almost-clique decomposition and classification required in the $\Delta$-coloring algorithm of Fischer \etal \cite{FHM23} can be performed in $O(1)$ rounds of sublinear \MPC. While the \CONGEST result of Fischer \etal \cite{FHM23} holds only for $\Delta = \omega(\log^3 n)$, our result does not require this restriction (i.e., holds for all values of $\Delta \geq 3$ provided the graph is $\Delta$-colorable, that is, provided it does not contain a $(\Delta+1)$-clique), exploiting the ability of \MPC to perform ``graph exponentiation'' when the maximum degree is low. (Because of space constraints, the analysis is deferred to \Cref{sec:Delta-coloring}.)
\subsection{Related work}
Our work continues a long line of research studying the parallel and distributed computing of graph coloring problems. For the references to earlier work on distributed coloring algorithms we refer to the monograph by Barenboim and Elkin \cite{BE13} (see also the influential papers by Linial \cite{Linial87,Linial92}). We will discuss here only more recent advances (and final results) for the four most relevant coloring problems, $(\Delta+1)$-coloring, $(\Delta+1)$-list-coloring, \DILC, and $\Delta$-coloring, leaving more detailed discussion and more references to the papers listed below. After extensive research in distributed computing for the $(\Delta+1)$-coloring problem, we understand its complexity for the \LOCAL, \CONGESTEDC, and also for the \MPC model, quite well. For \CONGESTEDC (and also for \MPC with linear memory, $\lspace = O(n)$), we know now how to solve $(\Delta+1)$-coloring in a constant number of rounds, see \cite{chang2018optimal,CDP20}. For the \LOCAL model, after a very long line of research, the current state of the art upper bound for randomized algorithm is by Ghaffari and Kuhn \cite{GK21} (see also \cite{RG20}), which achieves $O(\log^3\log n)$ round complexity w.h.p. There is no deterministic $o(\log n)$-round \LOCAL algorithm known.
For the low-space \MPC, it is known that the $(\Delta+1)$-coloring algorithm due to Chang et al. \cite{CFGUZ19} can be combined with the network decomposition result of \cite{RG20} to obtain a randomized $O(\log\log\log n)$-round \MPC algorithm, which is currently the state-of-the-art bound for the problem; this result was derandomized by Czumaj \etal \cite{CDP21}. Furthermore, all algorithms mentioned above for $(\Delta+1)$-coloring can be extended to solve also $(\Delta+1)$-list-coloring.
For the \DILC problem, which is a generalization of $(\Delta+1)$-coloring and $(\Delta+1)$-list-coloring, there have not been many comparable bounds until the very recent work of Halld{\'o}rsson \etal \cite{hknt_local_d1lc}. In \cite{hknt_local_d1lc}, by significantly extending the earlier approached for $(\Delta+1)$-coloring (in particular, to allow to efficiently deal with nodes of various degrees), it is shown that \DILC can be solved in $O(\log^3\log n)$ rounds in \LOCAL, w.h.p.
As a byproduct, the framework of Halld{\'o}rsson \etal \cite{hknt_local_d1lc} can be incorporated into a constant-round \MPC algorithm assuming the local \MPC space is slightly \emph{superlinear}, i.e., $O(n \log^4n)$ \cite[Corollary 2]{hknt_local_d1lc}.
A similar bound has been recently obtained for
the \CONGEST model in \cite{HNT22}, solving \DILC in $O(\log^5\log n)$ \CONGEST rounds, w.h.p.
We make extensive use of the framework laid out by Halld{\'o}rsson \etal \cite{hknt_local_d1lc} in their algorithm for \LOCAL in the design of our \DILC algorithm.
Our work relies also on some sparsification and derandomization techniques developed for parallel and distributed coloring algorithms.
With respect to derandomization,
our techniques are closely related to the recent papers by Czumaj \etal \cite{CDP20,CDP21}. The central approach underlying our analysis of derandomization using a pseudorandom generator has been used extensively before, though in the context of \MPC algorithms it has been used only recently in \cite{CDP21}.
In comparison to the perhaps more famous coloring problems listed above, relatively little has been written about the problem of $\Delta$-coloring in the parallel and distributed setting. In the \LOCAL model, the problem was first discussed in a paper by Panconesi and Srinivasan \cite{local_nature_delta_coloring}, and that algorithm was recently revisited and improved by Ghaffari \etal \cite{DBLP:journals/dc/GhaffariHKM21}.
In distributed models with communication bandwidth restrictions (and so, the setting closer to the model we consider here), the first breakthrough came only recently, in a paper by Fischer, Halld{\'o}rsson, and Maus \cite{FHM23}. They gave a \CONGEST algorithm which gives a $\Delta$-coloring of the graph in $O(\poly \log \log n)$ rounds if $\Delta = \omega(\log^3 n)$, which decreases to $O(\log^* n)$ rounds if $\Delta = \omega(\log^{21} n)$. Their result for large values of $\Delta$ was a substantial improvement over the state-of-the-art in any distributed model ($O(\log n)$ rounds previously being the best known), and combined with the result given by \cite{DBLP:journals/dc/GhaffariHKM21} for sub-polylogarithmic values of $\Delta$, they also achieved a $O(\poly\log\log n)$ round algorithm for $\Delta$-coloring in the \LOCAL model.
We are not aware of any direct prior work on $\Delta$-coloring in any model of parallel computing. An $O(\log n)$ round algorithm for \PRAM follows straightforwardly from the $O(\log n)$-round MIS algorithm of Luby \cite{Luby86}: one can find an MIS and defer coloring those nodes, the remaining nodes all gain at least $1$ slack, and therefore form a $(\Delta+1)$-coloring instance. This algorithm can be transformed into a $O(\log n)$ round \MPC algorithm, using well-known results relating to the simulation of \PRAM algorithms in \MPC. We note that the complexity of our algorithm represents a double-exponential improvement over this.
\hide{\subsection*{Notations}
\begin{itemize}
\item $G(V,E)$-- Graph with $n$ nodes.
\item $d_{G}(v)$--- The degree of $v$ in $G$.
\item $N_{G}(v)$--- The neighborhood of $v$ in $G$.
\item $G[W]$--- The subgraph of $G$ induced by $W \subseteq V$.
\item $O(n^\spacexp)$--- The space bound of each machine \peter{I changed this because the parts from \cite{CDP20} already use $\delta$ for something else, and we'll need to compare $\delta$ and $\eps$ later.}
\end{itemize}
}
\input{parts/preliminaries}
\input{parts/d1lc_randomised}
\input{parts/d1lc_deterministic}
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2023-02-10T02:03:39', 'yymm': '2302', 'arxiv_id': '2302.04378', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04378'} | arxiv |
\section{Introduction}
\begin{figure}[t]
\begin{center}
\centerline{\includegraphics[width=\columnwidth]{gradient_flow.png}}
\caption{Both the forward diffusion process and reverse generation process in diffusion generative models correspond to Wasserstein gradient flow along the same gradient-flow-path.}
\label{wasserstein_grad}
\end{center}
\vspace{-0.8cm}
\end{figure}
Score-based (or Diffusion) models are a new type of generative models in the field of computer vision and machine learning, achieving state-of-the-art results in image synthesis \cite{diffusion_beats_gan} and log likelihood \cite{diffusion_variational}. They have recently gained popularity due to interesting applications such as text to image generation (DALL-E \cite{dalle2}, \cite{latent_diffusion} and Imagen \cite{imagen2022photorealistic}), image super-resolution, image editing \cite{sdedit_meng}, etc. Score-based generative models have enjoyed diverse perspectives from different fields. Originally, diffusion models (DDPM) were developed from expected lower bound (ELBO) maximization on data log likelihood \cite{Ho_ddpm}. \citet{song_datagradient} showed that we can learn gradient of log likelihood (called score functions) and use it to generate images. \citet{song2021scorebased} showed that the epsilon function in DDPM is in fact the scaled version of the score function. They further generalized these models to a continuous setting as stochastic differential equations \cite{song2021scorebased}. More recent works have connected score-based generative models with Schrodinger bridge problem \cite{Bortoli2021diffusion} and control theoretic perspectives \cite{likelihood_chen2022, likelihood_huang2021}.
In this work, we present a completely different view-point on score-based generative models: geometric perspective.
To the best of our knowledge, we are the first to explore the geometric connection of these generative models. Applying the solid mathematical framework in the area of Wasserstein gradient flow \cite{jko, ambrosio2005gradient, wibisono2018sampling, salim2020wasserstein, korba2020non}, we show that the forward and backward process of adding noise and generating image from the noise are in fact equivalent to moving on a gradient-flow-path in a metric space of probability distributions following the Wasserstein gradient flow equation.
While our understanding of score-based generative models has matured over time, few important questions remain unanswered. For example, why is it a good idea to choose forward and reverse variance the same? Can we choose reverse variance differently? Are score-based generative models same as the energy based models \cite{gen_convnet, flow_contrastive_ebm, comet}? Furthermore, new models have been proposed like Wavefit \cite{wavefit}, which tries to generalize the diffusion sampling to a proximal gradient type of update. How can we explain this type of algorithms? In this work, we demonstrate that the geometric connection investigated in this work helps to answer these questions from a geometric point of view.
In addition to conceptual advantages and novel perspectives, geometric framework enables us to design practical algorithms with faster sampling capability. Score-based generative models work remarkably well when the number of sampling-steps is large (i.e. small step-size). However, the sampling time is also large for such finer schemes. As we decrease the number of sampling steps, the samples move away from the gradient-flow-path incurring error in each step, and resulting into high overall error. To minimize such error and achieve high quality samples even with small number of sampling steps, we propose to project back intermediate samples to the gradient-flow-path after every step. To achieve this, we propose an efficient estimation of Wasserstein gradient to descend towards the flow-path. As demonstrated in the result section, our proposed method significantly reduces error for smaller number of sampling steps.
Below we summarize our contributions. All complete proofs are included in the appendix.
\begin{enumerate}
\item To the best of our knowledge, this is the first work to theoretically prove the connection between score-based generative models and Wasserstein gradient flow. We establish this relationship through Theorems \ref{forward_thm} and \ref{reverse_flow}.
\item This connection sheds light on several interesting questions: 1) the reverse variance in score-based generative models, 2) the connection between score-based model and energy based model, and 3) the use of proximal gradient algorithms as proposed in recent works.
\item Based on these insights, we propose a new algorithm which generalizes the score-based model and allows for significantly faster sampling, which would otherwise be very difficult to achieve. To achieve this, we also propose an efficient Wasserstein gradient estimation algorithm.
\end{enumerate}
\section{Related Works}
Early works on diffusion models were based on matching the forward and reverse joint distributions through bounds on log likelihood \cite{Ho_ddpm, sohl2015deep}. \cite{song_datagradient} proposed a score-based generative model motivating from the Langevin dynamics and estimating the score function. Later \cite{song2021scorebased} showed that the two approaches are actually equivalent and it can be generalized further in continuous time setting through the stochastic differential equations. On the more theoretical directions, score-based optimization has been shown to be equivalent to likelihood maximization through Feynman-Kac theorem \cite{likelihood_chen2022, likelihood_huang2021}. Other notable works are interpreting the forward diffusion and generation as solving the Schrodinger Bridge problem \cite{Bortoli2021diffusion}. Many approaches have been proposed to speed up the sampling process through clever ways to solve differential equations \cite{fast_solver}.
In their seminal work, Jordan, Kinderlehrer, Otto (JKO) proved the connection between Wasserstein gradient flow and the the diffusion systems guided by Fokker-Planck equations \cite{jko}. This result has been vastly generalized and formalized by \cite{villani2003topics, villani2009optimal} and \cite{ambrosio2005gradient} giving birth to the theory of Wasserstein gradient flow and optimization on space of probability measures. Several notable works have followed in machine learning \cite{wibisono2018sampling}, \cite{korba2020non}, \cite{salim2020wasserstein}, for example for sampling, generative models, etc.
\section{Preliminaries}
\subsection{Notations}
Let $\mathcal{B}(\mathcal{X})$ denote the Borel $\sigma$- algebra over $\mathcal{X}$, and let $\mu$ denote a probability measure on $\mathcal{X}$. $\mathcal{P}_2(\mathcal{X})$ denotes the space of probability measures $\mu$ on $\mathcal{X}$ with finite second order moment.
For any $\mu \in \mathcal{P}_2(\mathcal{X})$, $L^2(\mu)$ is the space of functions $f: \mathcal{X} \to \mathcal{X}$ such that $\int ||f||^2 d\mu < \infty$ \cite{ambrosio2005gradient, korba2020non}. Let $T: \mathcal{X} \to \mathcal{X} $, then $T_{\#} \mu$ denotes the pushforward measure of $\mu$ by $T$ such that the transfer lemma $\int \phi(T(x))d\mu(x) = \int \phi(y)dT_{}\mu(y)$ holds for any measurable bounded function $\phi$. We use Wasserstein-2 distance as a metric on the space of probability measures. The Wasserstein-2 distance is defined as $W_2^2 (\mu, \nu) = \inf_{s \in S(\mu, \nu)} \int ||x-y||^2 ds(x,y)$, where $\mu, \nu \in P_2(\mathcal{X})$ and $\mathcal{S}(\mu, \nu)$ is the set of couplings between $\mu$ and $\nu$, i.e. the set of nonnegative measures, $s$ over $\mathcal{X} \times \mathcal{X}$ such that their projections on first and second components are $P_{\#}s = \mu$ and $Q_{\#}s = \nu$ where $P: (x,y) \mapsto x$ and $Q: (x,y) \mapsto y$ \cite{villani2003topics}.
\subsection{Wasserstein Gradient Flow}
Let $(\mu_t)_{t \in (0,T)}$ denote a family of probability measures.
This family satisfies a continuity equation if there exists a family of velocity fields, $(v_t)_{t \in (0,T)}$ such that
\begin{align}
\label{continuity_eq}
\frac{\partial \mu_t}{\partial t} + div(\mu_t v_t) = 0
\end{align}
in a distributional sense. It is also absolutely continuous if $||v_t||_{L^2(\mu_t)}$ is integrable over $(0,T)$. Among all possible $v_t$, there is one with minimum $L^2(\mu_t)$ norm, and it lies on the tangent space of $\mathcal{P}_2(\mathcal{X})$ and is called tangent vector field \cite{ambrosio2005gradient} Chapter 8.
We define a functional on the space of probability measures, $\mathcal{F}(\mu) : \mathcal{P}_2(\mathcal{X}) \to (-\infty, \infty)$. We define Wasserstein gradient of any functionals on the $\mathcal{P}_2(\mathcal{X})$ space as the change in the value of functional with small perturbation on the probability measure. Wasserstein gradient can be expressed in the following form \cite{ambrosio2005gradient} Chapter 10:
\begin{align}
\nabla_{W_2} \mathcal{F} = \nabla \mathcal{F'}(\mu)
\end{align}
Consider the KL divergence, $\text{KL}(\mu || \pi)$ between any measure $\mu$ and a base measure $\pi$. We can show that the Wasserstein gradient of the functional $\text{KL}(.|| \pi)$ at $\mu$ is
\begin{align}
\nabla_{W_2} \text{KL}(.|| \pi) = \nabla \log (\frac{ \mu}{\pi})
\end{align}
In the family $(\mu_t)_{t \in (0,T)}$, let the initial measure be $\mu_0 = \rho$ and final measure is $\mu_T = \pi$. Then there exists a geodesic between two probability measures $\rho$ and $\pi$ with respect to the Wasserstein metric. If we choose the velocity field equal to the negative of Wasserstein gradient (i.e. $v_t = - \nabla_{W_2} \text{KL}(.|| \pi) $), then we can show that the path traced by the probability measures is the geodesic between $\rho$ and $\pi$ \cite{ambrosio2005gradient} Chapter 7, and the flow is known as Wasserstein gradient flow. Using the functional $\text{KL}(.|| \pi)$ and the continuity equation, we obtain the equation of Wasserstein gradient flow as:
\begin{align}
\frac{\partial \mu_t}{\partial t} = div \big[\mu_t \nabla \log (\frac{ \mu_t}{\pi})]
\end{align}
Wasserstein gradient flow is a differential equation of probability measures. Consider a Wasserstein gradient flow with initial measure $\mu_0$ satisfying the continuity equation \ref{continuity_eq}. Let $x_0 \sim \mu_0$ be sample from the initial measure. The differential equation for the samples can be derived from continuity equation as follows \cite{ambrosio2005gradient}:
\begin{align}
\label{mu_to_x}
\dot{x} = v_t
\end{align}
\subsection{Score Based Generative Model}
Score-based generative model \cite{song2021scorebased} extends diffusion models to work on continuous time setting using stochastic differential equations (SDEs). The forward and reverse process of adding noise and generating images are interpreted as forward and reverse diffusion process with following differential equations:
\begin{align}
\label{for_sde}
\text{FOR}:dx &= f(x,t)dt +g_t dw\\
\nonumber
& t: 0\to T, x_0 \sim \rho\\
\label{rev_sde}
\text{REV}:dx &= [f(x,t) - g_t^2 \nabla_x \log \mu_t(x)] dt + g_t d\bar{w}\\
\nonumber
& t: T\to 0, x_T \sim \pi
\end{align}
where $f$ is forward drift function and $dw$ is the Brownian motion. Note that the flow of time in two SDE is different: the time flows from $0$ to $T$ in the forward process and the initial distribution is $\rho$, while the time flows from $T$ to $0$ in the reverse process. Time direction is crucial in the stochastic differential equation because for the forward process, $x_t$ is independent of the future $t' >t$ while in the reverse direction it is independent of the past \cite{anderson1982reverse}. To make things simpler such that time always flow in positive direction, we can equivalently use the positive time notation indexed by $\tau$ (following is equivalent to eq.(\ref{rev_sde})):
\begin{align}
\label{rev_sde_tau}
dx &= [- f(x,\tau) + g_{\tau}^2 \nabla_x \log \mu_{\tau}(x)] d\tau + g_{\tau} d\bar{w}\\
\nonumber
& \tau: 0\to T, x_0 \sim \pi, \tau = T - t
\end{align}
Note that we use $t$ for forward flow of time and $\tau = T-t$ for the backward flow of time, so that $\tau$ now flows from $0$ to $T$. With this notation, $\mu_{t=0} = \mu_{\tau = T} = \rho$, $\mu_{t=T} = \mu_{\tau = 0} = \pi$, and $\beta_t = \beta_{T-\tau}$. Euler-Maruyama discretization of the reverse SDE equation yields:
\begin{align}
\label{discrete_reverse_sde}
x_{\tau+\delta \tau} = x_{\tau} +(g_{\tau}^2 \nabla_x \log \mu_{\tau}(x) - f(x,\tau)) \delta \tau + g_{\tau} z
\end{align}
where $z \sim N(0, I)$ is a random normal distributed sample.
\section{Forward Diffusion as Gradient Flow}
Instead of taking the velocity vector to be negative of Wasserstein gradient, we consider an accelerated flow where at any time, $t$, the velocity is equal to the negative Wasserstein gradient scaled by a time-varying $\beta_t$.
\begin{proposition}[Accelerated Wasserstein Gradient Flow]
We define accelerated gradient flow with respect to the functional $\mathcal{F}$ as the gradient flow where the velocity vector is defined as $v_t = -\beta_t \nabla_{W_2} \mathcal{F}$. Consequently, the continuity equation is given by:
\begin{align}
\label{accelerated_gf}
\frac{\partial \mu_t}{\partial t} = div \big[\mu_t \beta_t \nabla_{W_2} \mathcal{F} ]
\end{align}
\end{proposition}
Using this accelerated Wasserstein Gradient flow, we can establish a connection with the forward process in score-based generative model. We start from the Fokker-Planck equation corresponding to the stochastic differential equation of the forward diffusion process given by eq.(\ref{for_sde}):
\begin{align}
\label{fokker_planck}
\frac{\partial \mu_t}{\partial t} = -div (\mu_t f) + \frac{1}{2}div(\nabla(g_t^2 \mu_t))
\end{align}
where the initial measure is $\mu_0 = \rho$. Following this SDE, we know that it will end up in the final measure, $\mu_T = \pi$.
Next theorem shows that the forward Fokker Planck equation and the accelerated Wasserstein Gradient descent are equivalent.
\begin{theorem}
\label{forward_thm}
Consider an accelerated gradient flow in eq.(\ref{accelerated_gf}) with initial measure $\mu_0 = \rho$ and the target measure $\mu_T = \pi$ and the functional on the Wasserstein space defined by $\mathcal{F}(\mu) = \text{KL}(.||\pi)$. The family of measures corresponding to this gradient flow is equivalent to the family of measures corresponding to the forward Fokker Plank equation in eq.(\ref{fokker_planck}) given that $f$ and $\beta_t$ take the following form: $f = {\beta_t} \nabla \log \pi$, $\beta_t = \frac{g_t^2}{2}$.
\end{theorem}
\begin{remark}
Consider the special case with measure $\mu_T = \pi =\mathcal{N}(0,I) = {\exp(-\frac{||x||^2}{2})}/{Z}$, we get $f = -\beta x$ and the forward diffusion equation is given by the following SDE:
\begin{align}
dx = -{\beta_t}x dt +\sqrt{2\beta_t}dw
\end{align}
which is exactly the forward flow of DDPM model \cite{Ho_ddpm, song2021scorebased}.
\end{remark}
This implies that the forward diffusion process considered in the diffusion generative model, DDPM \cite{Ho_ddpm, song2021scorebased} can be equivalently thought as an accelerated Wasserstein gradient flow starting from an initial measure $\mu_0 = \rho$ corresponding to the data distribution and following the negative gradient towards the target measure $\mu_T = \mathcal{N}(0, I)$.
\begin{remark}
We can also think of accelerated Wasserstein gradient flow as regular Wasserstein gradient flow with non-uniform discretization, \textit{i.e.,} step at $t$ is scaled by $\beta_t$.
\end{remark}
Next we investigate the geometric interpretation of the generation process or the reverse SDE.
\section{Generation as Reverse Gradient Flow}
Next theorem establishes the equivalence between the reverse SDE and the Wasserstein Gradient flow.
\begin{theorem}
\label{reverse_flow}
The reverse SDE in eq.(\ref{rev_sde_tau}) is equivalent to the Wasserstein gradient flow in the space of probability measures with respect to the functional $\mathcal{F}(\mu ) = - \text{KL}(.||\pi)$ starting from the initial measure $\mu_{\tau = 0} = \pi$ towards the target measure $\mu_{\tau = T} = \rho$.
\end{theorem}
\begin{proof}
\begin{align}
\mathcal{F}(\mu) &= -KL(\mu||\pi)\\
& = \int -\log \mu d\mu + \int \log \pi d\mu \\
\label{add_subtract}
& = \color{red}{\underbrace{\color{black}{\int (-2 \log \mu + \log \pi)
d\mu}}_{{\mathcal{G}}}} \color{black}{+} \color{blue} {\underbrace{\color{black}{ \int \log \mu d\mu}}_{\mathcal{H}}}
\end{align}
Here, we apply forward backward splitting scheme due to \cite{wibisono2018sampling, salim2020wasserstein}
\begin{align}
\label{descend}
\nu_{\tau} &= (I - \beta_{\tau} \nabla_{{W}_2}\mathcal{G}(\mu_{\tau}))_{\#} \mu_{\tau}\\
\label{jko_step}
\mu_{\tau+ \delta \tau} &= JKO_{\beta_{\tau} \mathcal{H}}(\nu_{\tau})
\end{align}
where $\nabla_{{W}_2}\mathcal{G}(\mu)$ is the Wasserstein gradient, the expression for which can be obtained as:
\begin{align}
\nabla_{W_2} \mathcal{G} = \nabla \mathcal{G'}(\mu) = \nabla(-2 \log \mu + \log \pi)
\end{align}
In eq.(\ref{descend}), we are trying to move in the direction of Wasserstein gradient. Let samples $x_{\tau}$ from distribution $x_{\tau} \sim \mu_{\tau}$. Transforming differential equation in measure space to sample space, similar to eq.(\ref{mu_to_x}), yields:
\begin{align}
&y_{\tau} = x_{\tau} -\beta_{\tau} \nabla(-2 \log \mu_t(x_{\tau}) + \log \pi(x_{\tau}) ) \delta \tau
\end{align}
In eq.(\ref{jko_step}), we are using JKO operator as a solution of the negative entropy functional, $\mathcal{H}$, where the JKO operator is defined as : $$JKO_{\beta, \mathcal{H}}(\nu) = \underset{\zeta \in \mathcal{P}_2(\mathcal{X})}{\text{argmin}} \mathcal{H}(\zeta) + \frac{1}{2 \beta} W_2^2(\zeta, \nu)$$
For the negative entropy functional, we have the exact solution as Brownian motion \cite{jko, wibisono2018sampling, salim2020wasserstein}. Let $y_{\tau} \sim \nu_{\tau}$, we obtain
\begin{align}
&y_{\tau} = x_{\tau} -\beta_{\tau} \nabla(-2 \log \mu_t(x_{\tau}) + \log \pi(x_{\tau})) \delta \tau\\
&x_{\tau + \delta \tau} = y_{\tau} + \sqrt{2\beta_{\tau}} z_{\tau}
\end{align}
Combining both, we obtain
\begin{align}
\nonumber
x_{\tau+\delta \tau} &= x_{\tau} +(2\beta_{\tau} \nabla \log \mu_{\tau}(x_{\tau}) - \beta_{\tau}\nabla \log \pi(x_{\tau}))\delta \tau \\
&+ \sqrt{2\beta_{\tau}} z_{\tau}
\end{align}
In the limiting case as $\delta \tau \to 0$, we obtain,
\begin{align}
\nonumber
dx = (2\beta_{\tau} \nabla \log \mu_{\tau}(x_{\tau}) - \beta_{\tau}\nabla \log \pi(x_{\tau}))d \tau
+ \sqrt{2\beta_{\tau}} dw
\end{align}
which coincides exactly with the reverse SDE in eq.(\ref{rev_sde_tau}) for $g_{\tau}^2 = 2\beta_{\tau}$ and $f = \beta_{\tau}\nabla \log \pi$.
\end{proof}
The reverse SDE or the score-based model is trying to reverse the forward process by tracing the path followed in the forward process in the opposite direction. One important implication of this theorem is that since we are moving towards the target measure $\mu_T = \mathcal{N}(0, I)$ in the forward process, the reverse is actually simply moving away from $\mathcal{N}(0, I)$, which is realized as the accelerated Wasserstein gradient flow with the functional $- \text{KL}(.||\pi)$. The gradient flow path with constant velocity is the geodesic. Since we are considering gradient flow path with acceleration, it is not exactly the geodesic, but similar path traced by gradient flow. We will call it gradient-flow-path in rest of the paper.
\section{Insights, Connections, Discussion}
We have shown that both the forward and reverse diffusion process involved in score-based generative models are gradient flows on the space of probability measures.
We gain geometric insights because of this geometric interpretation.
\subsection{Alternative Interpretation of Reverse SDE equation}
Score-based generative model uses the fact that for every forward SDE of the form in eq.(\ref{for_sde}), there exists a reverse SDE as in eq.(\ref{rev_sde_tau}), which is a remarkable result due to \cite{anderson1982reverse}. Theorem \ref{reverse_flow} provides an interesting interpretation of this result from a completely different perspective. In eq.(\ref{add_subtract}), we added and subtracted the negative entropy term $\int \log \mu d\mu$ in diffusion and drift terms respectively. It allowed us to design a forward-backward algorithm instead of forward algorithm of Wasserstein gradient flow. The backward term essentially added the Brownian motion term yielding us a reverse stochastic differential equation. Note that if we had not added and subtracted the term $\int \log \mu d\mu$, we would have obtained following iterative scheme:
\begin{align}
x_{\tau+\delta \tau} &= x_{\tau} +(\beta_{\tau} \nabla \log \mu_{\tau}(x_{\tau}) - \beta_{\tau}\nabla \log \pi(x_{\tau}))\delta \tau
\end{align}
Note that this is a discretized version of the following ODE.
\begin{align}
\label{rev_ode}
\frac{dx}{d\tau} = -f(x, \tau) + \frac{1}{2}g_{\tau}^2 \nabla \log \mu_{\tau}(x), \hspace{0.2cm} \tau: [0 \to T]
\end{align}
Comparing this equation with eq.(\ref{rev_sde_tau}), observe that eq.(\ref{rev_sde_tau}) has an additional $\frac{1}{2}g_t^2 \nabla \log \mu_t(x)$ in the drift part which is compensated by the Brownian motion $g_{\tau} d\Tilde{w}$. It is clear to see that eq.(\ref{rev_sde_tau}) and eq.(\ref{rev_ode}) yields same family of marginal distributions at $\tau \in [0,T]$ even though the former is deterministic differential equation and the latter is the stochastic. Perhaps the advantage of score-based models is that stochasticity helps in generating diverse samples for small sample size.
\subsection{Why is reverse variance same as the forward variance?}
In the DDPM model \cite{Ho_ddpm}, it was not clear how to choose the variance of the reverse differential equation, and why choosing the reverse variance the same as in forward is a good strategy. From previous analysis, we see that the reverse variance must be same as the forward because we have added and subtracted the same negative entropy term from both the drift and the diffusion. However, it is possible to change the reverse time variance. For example, we can add $\alpha \int \log \mu d\mu $ to both the drift and diffusion terms in eq. (\ref{add_subtract}). Then the reverse SDE variance will be $\sqrt{2 \alpha \beta_t }$, but then the drift term in eq.(\ref{rev_sde_tau}) will also be modified to $\frac{1+\alpha}{2}g_t^2 \nabla \log \mu_t(x)$ instead of $g_t^2 \nabla \log \mu_t(x)$.
\subsection{Contrasting Score-based with Energy-based Model}
Let's assume that the probability measure of data can be obtained in the form of $\rho \propto \exp(-V)$. Consider Wasserstein gradient descent with the functional as $KL(.||\rho)$
\begin{align}
\mathcal{F}(\mu) &= KL(\mu||\rho)\\
& = \int V d\mu + \int \log \mu d\mu
\end{align}
We can use the same forward-backward splitting scheme as we used in Theorem 2 Proof, and with similar reasoning, we can recover the Langevin dynamics:
\begin{align}
x_{\tau+\delta \tau} &= x_{\tau} - \beta_{\tau}\nabla V(x_{\tau})\delta \tau
+ \sqrt{2\beta_{\tau}} z
\end{align}
This demonstrates the critical difference between the Energy-based model and the score-based model: while the energy based model is moving towards the data distribution $\mu_0 = \rho$ with functional $KL(.||\rho)$, the score-based model is moving away from the isotropic Gaussian distribution ($\pi$) with the functional, $-KL(.||\pi)$ . Score-based generative model traces the forward diffusion path in the reverse direction thereby avoiding the need to work with the data distribution $\rho$. In the energy based model, however, we need to either estimate energy function like $V$ \cite{flow_contrastive_ebm, comet} or KL divergence with the data, $\rho$.
\subsection{Proximal Algorithms in Diffusion models}
WaveFit \cite{wavefit} tries to generalize the iteration in diffusion models to a proximal algorithm. Motivating from a fixed point iteration, they try to improve upon DDPM model by drawing ideas from GANs and propose a proximal algorithm type of approach which is faster in generating samples than DDPM without losing quality. Here, we show that starting from geometric perspective we can reach the proximal algorithm as a way to perform Wasserstein gradient descent. Consider a functional, say $\mathcal{F}(\mu) = KL(\mu||\rho)$ for example where $\rho$ is the data distribution. Forward discretization of Wasserstein gradient descent yields us iteration \cite{jko, salim2020wasserstein}
\begin{align}
\mu_{\tau'}
= \underset{\nu \in \mathcal{P}_2(\mathcal{X})}{\text{argmin}} \mathcal{F}(\nu) + \frac{1}{2 \gamma} W_2^2(\nu, \mu)
\end{align}
which is a proximal gradient algorithm in the space of probability measures. This justifies why proximal algorithms make sense in the context of diffusion generative models or score-based generative models because we are trying to reach the data distribution descending in the direction of Wasserstein gradient. \citet{jko, wibisono2018sampling, salim2020wasserstein} have shown that proximal algorithm converges to the target distribution, $\rho$. As for the choice of functional $\mathcal{F}$, it can be any convex functional that decreases as we descend towards the target measure $\rho$. Wavefit \cite{wavefit} shows that using much stronger GAN-type objective as a functional yields good result.
\section{Challenges with Faster Sampling}
\begin{figure}[t!]
\begin{center}
\centerline{\includegraphics[width=\columnwidth]{celeba_comparison.png}}
\caption{Qualitative comparison of Celeb-A samples generated by Score-based model and our model at different number of sampling steps (N). Our model maintains reasonable quality even when N decreases down to 20. }
\label{fig:celeba}
\end{center}
\vspace{-0.7cm}
\end{figure}
Once the connection between the gradient flow and score-based generative model is established, we can interpret the generation as a process walking on the gradient-flow-path. If we follow the flow-path with small steps, we can reliably reach the initial data distribution, as demonstrated by the success of the score-based generative models and diffusion models. However, this is not a great idea if we increase the step size. The score-based increment is a linear approximation and therefore it accrues more error as we increase the step size. It has been experimentally observed that the samples get poorer as we increase the step size in score-based models \cite{diffusion_beats_gan, Ho_ddpm, song2021scorebased}.
From a geometric point-of-view, we are taking Wasserstein gradient steps using forward-backward strategy. While this strategy works well when the step size is small, it converges to a biased measure for large step-size. Bias associated with the forward-backward strategy for large step size has been studied in the context of Wasserstein gradient flow \cite{wibisono2018sampling}. In our case, this issue is further exacerbated by the fact that the functional $-\text{KL}(\mu|| \pi)$ we are trying to minimize is actually concave with respect to $\mu$.
\begin{figure}[t]
\begin{center}
\centerline{\includegraphics[width=\columnwidth]{predict-project.png}}
\caption{During generation, sample moves tangentially to the gradient-flow-path in the reverse direction. If the step-size is large, it incurs error, which we mitigate by projection to the gradient-flow-path.}
\label{fig:predict_project}
\end{center}
\vspace{-0.5cm}
\end{figure}
To mitigate this issue, we propose an intuitive and geometric idea: projection. As shown in Fig.\ref{fig:predict_project}, as we try to sample in score-based models with large step-size, the error gets large and the trajectory deviates away from the gradient-flow-path. We propose to resolve this problem by projecting again to the gradient-flow-path before taking another step.
\section{Projection to Gradient-flow-path}
\begin{algorithm}[tb]
\caption{Predict-Project Sampling}
\label{alg:sampling}
\begin{algorithmic}[1]
\STATE Inputs: $N$, $\delta \mu$, $s_{\theta}^{*}$, $T_{\theta}^{*}$
\STATE $x \sim \mathcal{N}(0,I)$,
$\delta \tau = 1/N$
\FOR{$\tau=0$ {\bfseries to} $1 - 1/N$}
\STATE $x^{pred} = x +(2\beta_{\tau} s_{\theta}^{*}(x) - \beta_{\tau}\nabla \log \pi(x_{\tau}))\delta \tau$
\STATE $x^{proj} = x^{pred} + T_{\theta}^*(x^{pred}, \tau + \delta \tau) .\sqrt{\beta_\tau}.{\delta \mu}. \delta \tau $
\STATE $z \sim \mathcal{N}(0,I)$
\STATE $x = x^{proj} + \sqrt{2\beta_t}z$
\ENDFOR
\STATE RETURN $x$
\end{algorithmic}
\end{algorithm}
Score-based generative model first trains a score model, $s$ such that $s_{\theta}^*(x_\tau, \tau) = \nabla \log \mu_{\tau}(x_{\tau})$ using score matching strategy. Once, the score model is trained, the discretized Eurler-Maruyama step (eq.(\ref{discrete_reverse_sde})) is used for generation of samples, where score function, $s^*$ replaces $\nabla \log \mu_{\tau}(x_{\tau})$:
\begin{align}
\nonumber
x_{\tau+\delta \tau} &= x_{\tau} +(2\beta_{\tau} s_{\theta}^*(x_\tau, \tau) - \beta_{\tau}\nabla \log \pi(x_{\tau}))\delta \tau \\
\nonumber
&+ \sqrt{2\beta_{\tau}} z\\
\label{eq:pred}
& = x_{\tau+\delta \tau}^{pred} + \sqrt{2\beta_{\tau}} z_{\tau}
\end{align}
It can also be interpreted as predict and diffuse steps, where predict step is $x_{\tau+\delta \tau}^{pred} = x_{\tau} +(2\beta_{\tau} s_{\theta}^*(x_\tau, \tau) - \beta_{\tau}\nabla \log \pi(x_{\tau}))\delta \tau$.
Since generation is trying to trace the gradient-flow-path, after each of these predict-diffuse, we should obtain samples from the measure $\mu_{\tau + \delta \tau}$ on the gradient-flow-path. Because of discretization error and bias, these samples do not lie on the gradient-flow-path, in fact they deviate away. To pull these samples towards the measure, $\mu_{\tau + \delta \tau}$ on the gradient-flow-path, we use the fact that we have a way to sample from the measures on gradient-flow-path. Using the SDE equation, we can write closed form conditional distribution of $\mu_{\tau + \delta \tau}$ as follows:
\begin{align}
\nonumber
\mu_{\tau+\delta \tau | T}(x_{\tau + \delta \tau} | x_{ T}) = \mathcal{N}(x_{\tau+\delta \tau};x_{\tau+\delta \tau}^{mean}(x_{\tau=T}), 2 \beta_{\tau+ \delta \tau}I)
\end{align}
Sampling from this conditional distribution is given by the following equation:
\begin{align}
\label{eq:sample_geodesic}
x_{\tau+\delta \tau} = x_{\tau+\delta \tau}^{mean}(x_{\tau = T}) + \sqrt{2\beta_{\tau + \delta \tau}} z_{\tau}
\end{align}
Comparing eq.(\ref{eq:sample_geodesic}) with eq.(\ref{eq:pred}), we note that pulling $x_{\tau+\delta \tau}^{pred}$ close to $x_{\tau+\delta \tau}^{mean}$ may be enough to pull the samples $x_{\tau+\delta \tau} $ in eq.(\ref{eq:pred}) towards gradient-flow-path assuming that $\beta_{\tau + \delta \tau}$ is close to $\beta_{\tau }$. In terms of measures, we consider the measure associated with samples $x_{\tau+\delta \tau}^{pred}$ and target samples $x_{\tau+\delta \tau}^{mean}$. Let's define the measure corresponding to samples $x^{pred}_{\tau+\delta \tau}$ as $\mu^{pred}_{\tau+\delta \tau}$ and the measures corresponding to means, $x_{\tau+\delta \tau}^{mean}$ as $\mu^{mean}_{\tau+\delta \tau}$. We can sample from the measure $\mu^{mean}_{\tau+\delta \tau}$ by first sampling from $x_{\tau=T} \sim \mu_{\tau=T}$, and passing them through $x_{\tau+\delta \tau}^{mean}$. Our strategy to project the samples in eq.(\ref{eq:pred}) onto gradient-flow-path is to project the pred measure, $\mu^{pred}_{\tau+\delta \tau}$ to the mean measure $\mu^{mean}_{\tau+\delta \tau}$. We achieve this through Wasserstein gradient descent in the space of probability measures. For that, we need an efficient way to estimate Wasserstein gradient, which we describe in next subsection.
\subsection{ Efficient Estimation of Wasserstein Gradient }
Imagine that we want to estimate Wasserstein Gradient of a functional $\mathcal{J}(\mu)$, \textit{i.e.}, $\nabla_{W_2}\mathcal{J}(\mu)$. For that, we can use the following Taylor expansion:
\begin{align}
\label{Wgradient_est}
\mathcal{J}((I +h T)_{\# \mu} ) = \mathcal{J}(\mu) + h \langle \nabla_{W_2}\mathcal{J}(\mu), T \rangle_{\mu} + o(h)
\end{align}
where, $\nabla_{W_2}\mathcal{J}(\mu) \in L^2(\mu)$ is the Wasserstein gradient of $\mathcal{J}$ at $\mu$.
To estimate the Wasserstein gradient, consider the following optimization problem:
\begin{align}
T^* = \underset T {argmin} \hspace{0.2cm}{\langle \nabla_{W_2}\mathcal{J}(\mu), T \rangle_{\mu} + \frac{1}{2h}||T||^2 _{\mu}}
\end{align}
It is easy to see that $T^* = -h \nabla_{W_2}\mathcal{J}(\mu)$ is the solution of this problem. Plug in eq.(\ref{Wgradient_est}), and parameterize the gradient function $T$ as a function of neural network parameters $\theta$. Hence, we solve the following optimization problem:
\begin{align}
\label{efficient_Wasserstein_grad}
\underset {\theta} {min} \hspace{0.2cm}{\mathcal{J}((I + T_\theta)_{\# \mu} ) + \frac{1}{2h}||T_{\theta}||^2 _{\mu}}
\end{align}
This optimization is efficient and can use parallel processing because: 1) it only requires samples from the measure $\mu$, and 2) we can use minibatch from the measure $\mu$ to update neural network parameters at a time. This removes the need to obtain all samples at a time leading to stochastic gradient descent optimization of $\theta$.
\subsection{Predict-Project Algorithm}
\begin{table}[t]
\caption{Comparison of FID score as a measure of generated image quality between score-based and our generative model at different number of sampling steps N.}
\label{fid_is_score}
\begin{center}
\begin{small}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{lcccccr}
\toprule
{Datasets}
&& N = 1000 & N = 100 & N = 40 & N = 20 \\
\hline
\multicolumn{6}{c}{FID Score $\downarrow$}\\
\hline
\multirow{ 2}{*}{Celeb-A}& Score Model & \multirow{ 2}{*}{6.331}& 35.14 & 149.42 & 222.71 \\
&Predict-Project & & \textbf{20.54} & \textbf{68.23} & \textbf{121.12}
\\ \hline
\multirow{ 2}{*}{LSUN}& Score Model & \multirow{ 2}{*}{15.12}& 34.62 & 122.23 & 246.17 \\
&Predict-Project & & \textbf{25.35} & \textbf{66.61} & \textbf{164.32}
\\ \hline
\multirow{ 2}{*}{SVHN}& Score Model & \multirow{ 2}{*}{18.95}& \textbf{146.63} & 183.30 & 285.61 \\
&Predict-Project & & 149.56 & \textbf{ 174.34} & \textbf{152.94 }\\
\bottomrule
\end{tabular}
}
\end{small}
\end{center}
\vspace{-0.4cm}
\end{table}
\begin{figure*}[t!]
\begin{center}
\centerline{\includegraphics[width=0.9\textwidth]{N_40_comparison.png}}
\caption{Comparison of generated samples in three datasets when number of sampling steps is decreased to as low as N = 40.}
\label{fig:N_40}
\end{center}
\vspace{-0.5cm}
\end{figure*}
With the Wasserstein gradient estimation method in hand, we now move on to project $\mu_{\tau+\delta \tau}^{pred}$ to $\mu_{\tau+\delta \tau}^{mean}$. We define the functional $\mathcal{J}$ in the following way:
\begin{align}
\nonumber
&\mathcal{J}_{\tau+\delta \tau}((I + T_{\theta, \tau+\delta \tau})_{\#}{ \mu_{\tau+\delta \tau}^{pred}} )\\
&= \int ||x_{\tau+\delta \tau}^{pred} + T_{\theta}(x_{\tau+\delta \tau}^{pred}) - x_{\tau+\delta \tau}^{mean}||^2 d\mu_{\tau+\delta \tau}^{pred}(x_{\tau+\delta \tau}^{pred})
\end{align}
Note that, $T_{\theta, \tau+\delta \tau}$ is indexed by time. Instead of learning different $T_{\theta}$ for different time, we parameterize it by time as $T(., \tau)$ as in score function \cite{song2021scorebased}. Similarly, we choose $h = 1/\sqrt{\beta_{\tau}}$ to be different for different $\tau$ in eq.(\ref{efficient_Wasserstein_grad}). To train the projection function, $T$, we sample $\tau $ from the uniform distribution in the interval $(0,1]$, $x_{\tau=T} \sim \mu_{\tau=T}$ and optimize the following optimization:
\begin{align}
\nonumber
\underset {\theta} {min} \hspace{0.2cm} E_{\tau, x_{\tau = T}}& \big [ ||x_{\tau+\delta \tau}^{pred} + T_{\theta}(x_{\tau +\delta \tau}^{pred}, \tau +\delta \tau ) - x_{\tau +\delta \tau}^{mean}||^2 \\
\nonumber
& + \frac{\sqrt{\beta_{\tau}}}{2}||T_{\theta}(x_{\tau +\delta \tau}^{pred}, \tau +\delta \tau)||^2 \big ]
\end{align}
After training, we have,
$\sqrt{\beta_{\tau}}T_{\theta}^* = - \nabla_{W_2}\mathcal{J}(\mu^{pred})$. Using this relation, we update the sample as
\begin{align}
x^{proj} &= x^{pred} - \nabla_{W_2}\mathcal{J}(\mu^{pred})(x^{pred}).{\delta \mu}. \delta \tau\\
&= x^{pred} +\sqrt{\beta_\tau} T_{\theta}^*(x^{pred}, \tau) .{\delta \mu}. \delta \tau
\end{align}
where $\delta \mu$ is the small scalar by which to move in the direction of Wasserstein gradient and $\delta \tau$ is present due to the fact that the Wasserstein gradient flow with velocity field $v_t$ corresponds to dynamics $\dot{x_{\tau}} = v_{\tau}(x_{\tau})$ (see eq.(\ref{mu_to_x})). See Algorithm \ref{alg:sampling} for full sampling algorithm.
\section{Experimental Results}
To demonstrate efficacy of our algorithm, we train and generate samples on three datasets: 1) Celeb-A dataset, 2) LSUN-church dataset, and 3) SVHN dataset, where all images are of size $64 \times 64$. Our neural network architecture for both score model and projection model uses standard U-net architecture with attention due to \cite{diffusion_beats_gan}. We use publicly available code from \cite{song2021scorebased} as score-based model. In these experiments, we demonstrate that as we decrease the number of sampling steps, the quality of samples decreases in Score-based generative model, but we maintain quality to a reasonable level even when the number of sampling steps is reduced to as low as 20. We use FID metric \cite{fid_gans} to measure the sample qualities.
In Table \ref{fid_is_score}, we compare the FID score of generated images from score-based method and our Predict-Project method. We outperform the score-based method by a large margin in all cases except SVHN (N=100). This underperformance could be because our model is not trained well in SVHN (see appendix) due to lack of time. For qualitative comparison, please see Fig. (\ref{fig:N_40}) and Fig. (\ref{fig:celeba}). These results our claim that projecting to the gradient-flow-path improves sample quality, especially when the number of sampling-step is low.
\section{Conclusion}
We presented a novel geometric perspective on score-based generative models (also called diffusion generative models) by showing that they are in fact gradient flows in a space of probability measures. The geometric insight gained from this connection helped us answer and clarify some critical open questions. We also demonstrated that it can help us design faster sampling algorithm. We believe that this connection will help diffuse knowledge between Wasserstein gradient flow field and score-based generative models field in the future inspiring interesting solutions to problems in both areas. Similarly, connection with energy-based models, proximal algorithms and reverse SDE could help design better algorithms in general and generative models in specific. Energy-based models, for example, can be combined with score-based models in the light of geometric understanding.
\newpage
\newpage
| {'timestamp': '2023-02-10T02:05:15', 'yymm': '2302', 'arxiv_id': '2302.04411', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04411'} | arxiv |
\section{Introduction}
Quasiseparable matrices arise frequently in various problems of numerical analysis and are becoming
increasingly important in computer algebra, e.g. by their application to handle linearizations of polynomial
matrices~\cite{BEG17}.
Structured representations for these matrices and their generalisations have been widely studied but
to our knowledge they have not been
compared in detail with each other.
In this paper we aim to adapt \texttt{SSS}~\cite{Eidelman1999OnAN}
and \texttt{HSS} \cite{changu03, lyons2005fast}, two of the
most prominent formats of numerical analysis to exact computations
and compare them theoretically and experimentally to the \Bruhat
format \cite{PS18}
These formats all have linear storage size in both the dimension and the structure parameter.
We do not investigate the Givens weight representation~\cite{DeBa08} as it strongly relies on
orthogonal transformations in \CC, which transcription in the algebraic setting is more challenging.
See \cite{Vandebril2005ABO, VVBM08, Hackbusch2015HierarchicalMA} for
an extensive bibliography on
computing with
quasiseparable matrices.
\begin{definition}
An \(n \times n\) matrix \(A\) is \(s\)-quasiseparable if for all \(k \in \intset{1,n}\),
\(\rank(\submat{A}{1..k}{k+1..n})\leq s\) and
\(\rank(\submat{A}{k+1..n}{1..k})\leq s\).
\end{definition}
\smallskip
\noindent
{\em Complexity bound notation.}
We consider matrices over an abstract commutative field $\K$, and count arithmetic operations in $\K$.
Our detailed comparison of formats aims in particular to determine the asymptotic multiplicative
constants, an insightful measure on the algorithm's behaviour in pratice.
In this regard, we will use the leading term in the complexities as the measure for our comparison:
namely a function \(\Time{XXX}(n,s)\) such that the number of field operations for
running Algorithm XXX
with parameters \(n,s\) is \(\Time{XXX}(n,s) + o(\Time{XXX}(n,s))\)
asymptotically in \(n\) and \(s\).
We proceed similarly for the space cost bounds with the notation \(\Space{XXX}(n,s)\).
We denote by \(\omega\) a
feasible exponent for square matrix multiplication, and \(C_\omega\) the
corresponding leading constant; namely, using above notation, \(\Time{MM}(n)=C_\omega n^\omega\),
where \texttt{MM} corresponds to the operation \(C = C + AB\) with \(A,B,C\in\K^{n \times n}\).
The straightforward generalization gives
\(\Time{MM}(m,k,n)=C_\omega mnk \min(m,k,n)^{\omega -3}\) for the product of
an \(m\times k\) by a \(k\times n\) matrix.
\subsection{Rank revealing factorizations}
Space efficient representations for quasiseparable matrices rely on
rank revealing factorizations: a rank \(r\) matrix \(A\in\K^{m\times n}\) is represented by two
matrices \(L\in\K^{m\times r}
R\in\K^{r\times n}\) such that \(A=LR\).
In exact linear algebra, such factorizations are usually computed using Gaussian elimination, such
as PLUQ, CUP, PLE, CRE decompositions~\cite{JPS13,DPS17,Sto00}, which we will generically denote by \PLUQ.
Cost estimates of the above factorization algorithms are either given as \(\bigO{mnr^{\omega-2}}\) or with explicit leading constants
\(\Time{RF}(m,n,r)=K_\omega n^\omega\) under genericity assumptions: \(m=n=r\)
and generic rank profile~\cite{JPS13,DPS17}.
We refer to~\cite{PSV23} for an analysis in the non-generic case of the leading constants in the cost of the two main
variants of divide and conquer Gaussian elimination algorithms.
We may therefore assume that \(\Time{RF}(m,n,r)=C_\texttt{RF}mnr^{\omega-2}\)
for a constant $C_\texttt{RF}$, for \(\omega \geq 1+\log_2 3\), which is the case for all pratical
matrix multiplication algorithm. Note that for \(\omega=3\), these costs are both equal to
\(2mnr\).
Unfortunately, the non-predictable rank distribution among the blocks being processed leads to
an over-estimation of some intermediate costs which forbids tighter constants
(i.e. interpolating the known one \(K_3=2/3\) in the generic case).
The algorithms presented here still carry on for smaller values of \(\omega\), but we chose to skip
the more complex derivation of estimates on their leading constants for the sake of clarity.
Our algorithms for \SSS and \HSS can use any rank revealing factorization.
On the other hand, the \Bruhat format requires one revealing the additional information of the rank profile matrix,
e.g. the CRE decompositions used here (See~\cite{DPS17}).
\begin{theorem}[\cite{MaHe07,DPS17}]\label{th:cre}
Any rank \(r\) matrix \(A\in\K^{m\times n}\) has a CRE decomposition \(A=CRE\) where \(C\in
\K^{m\times r}\) and \(E\in\K^{r\times n}\) are in column and row echelon form,
and \(R\in\K^{r\times r}\) is a permutation matrix.
\end{theorem}
The costs we give in relation to \Bruhat generator therefore rely on constants \(C_\texttt{RF}\)
from factorizations allowing to produce a CRE decomposition, like the ones in~\cite{PSV23}.
\begin{table*}[ht]
\caption{Summary of operation and storage costs}\label{tab}
\begin{tabular}{l|ccc|ccc}
\toprule
& \multicolumn{3}{c|}{\(\omega\)} & \multicolumn{3}{c}{\(\omega=3\)}\\
& \SSS & \HSS & \Bruhat & \SSS & \HSS & \Bruhat \\
\midrule
Storage & \(7ns\) & \(18ns\) & \(4ns\)& \(7ns\) & \(18ns\) & \(4ns\)\\
Gen. from Dense & \(2C_\texttt{RF}n^2s^{\omega-2}\) &\(2^{\omega}C_\texttt{RF}n^2s^{\omega-2}\) & \(C_\texttt{RF}n^2s^{\omega-2}\) & \(4n^2s\) &\(16n^2s\) & \(2n^2s\) \\
\(\times\) Dense block vector\((n\times v)\)
& \(7C_\omega nsv^{\omega-2}\) & \(18C_\omega nsv^{\omega-2}\) & \(8C_\omega
nsv^{\omega-2}\) & \(14 nsv\) & \(36 nsv\) & \(16 nsv\) \\
Addition & \((10+2^\omega)C_\omega ns^{\omega-1}\) &&\(\paren{\frac{9 \cdot 2^{\omega - 2} - 8}{2^{\omega - 2} - 1}\cw
+ 2\crf} n s^{\omega - 1} \log n/s\)& \(36ns^2\) & & \(24ns^2 \log n/s\)\\
Product & \((31+2^\omega)C_\omega ns^{\omega-1}\) &&& \(78 n s^2\) \\
\bottomrule
\end{tabular}
\end{table*}
\subsection{Contributions}
In \cref{sec:gen} we define the \SSS, \HSS and \Bruhat formats.
We then adapt algorithms operating with \HSS
and \SSS generators
from the literature to the exact context.
The \HSS generation algorithm is given in a new iterative version
and the \SSS product algorithm has an improved cost.
We focus for \SSS on basic bricks on which other operations can be built.
This opens the door to adaptation of
fast algorithms for inversion and system solving \cite{CDGPV03, EG05bsss, CDGPSVW05}
and format modeling operations such as
merging, splitting and model reduction \cite{CDGPV03}.
In \cref{sec:dtb} we give a generic \Bruhat generation algorithm from which we derive new fast algorithms for
the generation from a sparse matrix and from a sum of matrices in \Bruhat form.
\Cref{tab} displays the best cost estimates for differents operations on an \(n \times n\) \(s\)-quasi-separable matrix in the three formats presented in the paper.
The best and optimal storage size is reached by the \Bruhat format which also has the fastest generator computation algorithm.
However, this is not reflected in the following operation costs as applying a quasiseparable matrix to a dense matrix is least expensive with an \SSS generator
and addition and product of \(n \times n\) matrices given in \Bruhat form is super-linear in \(n\).
We notice in \cref{prop:hcost} that \HSS is twice as expensive as \SSS and gives no advantage in our context.
We thus stop the comparison at the generator computation.
We still give in \cref{tab} the cost of quasiseparable \(\times\) dense product which is proportional to the generator size \cite{lyons2005fast}.
We complete this analysis with experiments showing that despite slightly worse
asymptotic cost estimates, \SSS performs better than \Bruhat in practice for the construction in
\Cref{sec:ecd} and the product by a dense block vector in \Cref{sec:eca}.
\section{Presentation of the formats}
\label{sec:gen}
\subsection{\SSS generators} \label{sec:SSSgen}
Introduced in~\cite{Eidelman1999OnAN}, \SSS generators were later improved independently in
\cite{EG05bsss} and \cite{CDGPV03} using block-versions, which we present here.
In particular, the space was improved from \(\bigO{ns^2}\) to \(\bigO{ns}\).
An \(s\)-quasiseparable matrix is sliced following a grid of \(s \times s\) blocks.
Blocks on, over and under the diagonal are treated separately.
On one side of the diagonal, each block is defined by a product depending on its row
(left-most block of the product), its column (right-most block), and its distance to
the diagonal
(number of blocks in the product).
\begin{definition} \label{def:SSS}
Let \(A = \left[\begin{smallmatrix}A_{1,1} & \cdots & A_{1,N} \\
\vdots && \vdots \\
A_{N,1} & \cdots & A_{N,N} \end{smallmatrix}\right] \in \K^{n \times n}\)
with \(t \times t\) blocks \(A_{i,j}\) for \(i,j <N\) and \(N = \ceil{n/t}\).
\(A\) is given in sequentially semi-separable format of
order \(t\) (\(t\)-\SSS) if it is given by the \(t \times t\) matrices
\(\paren{P_i, V_i}_{i\in\intset{2,N}}\), \(
\paren{Q_i, U_i}_{i\in\intset{1, N - 1}},
\paren{R_i, W_i}_{i\in\intset{2,N - 1}},
\paren{D_i}_{i\in\intset{1,N} }\) s.t.
\begin{equation}
\label{eq:def}
A_{i,j} = \left\{\begin{matrix} P_i R_{i - 1} \dots R_{j + 1} Q_j & \text{if } i > j \\
D_i & \text{if } i = j \\
U_i W_{i + 1} \dots W_{j - 1} V_j & \text{otherwise}
\end{matrix}\right.
\end{equation}
\end{definition}
\begin{proposition}
Any \(n \times n\) \(s\)-quasiseparable matrix has an \(s\)-\SSS representation. It uses \(\Space{\SSS}(n,s)=7ns\) field elements.
\end{proposition}
\begin{proof}
Direct consequence of \cref{prop:dts}.
\end{proof}
\subsection{\HSS generators} \label{sec:HSSSgen}
The \HSS format was first introduced in \cite{CGP06ULV}, although the idea originated with the {\it uniform \(\mathcal H\)-matrices}
of \cite{Hackbusch1999ASM} and in more details with the {\it \(\mathcal H^2\)-matrices} of \cite{HKS99H2}, with algorithms relying on \cite{Starr91}.
The \(\mathcal H^2\) format is slightly different from \HSS, more details in \cite{Hackbusch2015HierarchicalMA}.
The format is close to \SSS (see \cref{prop:altdef}) as the way of defining blocks is similar. Yet,
the slicing grid is built recursively and the definition of blocks product depends on the path to follow in the recursion tree.
Also, both sides of the diagonal are treated jointly and the format is therefore less compact, which
as will be shown
makes \HSS less efficient.
The structure is complex and notations differ in the literature.
We made the following choices:
we avoid the recursive tree definition inherited from the Fast Multipole Method \cite{CGP06ULV} and
thus only consider constant-depth recursive block divisions.
We made this choice to focus on linear algebra and quasiseparable matrices with no pre-requisites
(no notion of where the rank is).
For the same reason we focus on uniform subdivisions.
Most literature on \HSS
uses non-uniform grids in order to adapt to matrices with a structure
within the quasiseparable rank structure \cite{CGP06ULV}.
Despite being more general, this adds confusion which is not needed in our case.
We use a notation similar to \cite{XCGL10HSS} with transition matrices.
\begin{definition}
Let \(A \in \K^{n \times n}\) and the uniform block divisions
\begin{equation}
\label{eq:kdiv}
A = \left[\begin{smallmatrix}A_{k;1,1} & \cdots & A_{k;1,2^k} \\
\vdots && \vdots \\
A_{k;2^k,1} & \cdots & A_{k;2^k, 2^k} \end{smallmatrix}\right].
\end{equation}
\(A\) is given in hierarchically semi-separable format of
order \(t\) (\(t\)-\HSS) if it is given by the \(t \times t\) matrices
\(
\paren{U_{K;i}, V_{K;i}, D_i}_{i\in\intset{1,N}}\), \(
\paren{R_{k;i}, W_{k;i}}_{\substack{k\in\intset{2,K}\\ i\in\intset{1,2^k}}}\) and
\(\paren{B_{k;i}}_{\substack{k\in\intset{1,K}\\ i\in\intset{1,2^k}}}\)
with \(N = \ceil{n/t}\) and \(K \geq\log N\)
such that for \(i \in \intset{1,N}\),
\( A_{K;i,i} = D_i\)
and if we define recursively for \(k\) from \(K - 1\) to \(1\) and \(i \in \intset{1,{2^k}}\),
\( U_{k;i} = \begin{bmatrix} U_{k + 1; 2i - 1}R_{k + 1; 2i - 1} \\
U_{k + 1; 2i}R_{k + 1; 2i} \end{bmatrix}\) and \(V_{k;i} = \begin{bmatrix} W_{k + 1; 2i - 1}V_{k + 1; 2i - 1} &
W_{k + 1; 2i}V_{k + 1; 2i} \end{bmatrix}\) then
\begin{equation}\label{eq:HSS}
\begin{array}{rcl}
A_{k;2i - 1, 2i} &=& U_{k;2i - 1}B_{k;2i - 1}V_{k; 2i} \\
A_{k;2i, 2i - 1} &=& U_{k;2i}B_{k;2i}V_{k; 2i - 1}
\end{array}
\end{equation}
\end{definition}
The \HSS generator can be seen as a recursive \SSS generator with two differences :
the use of the \(B\) matrices, and the distribution of the translation matrices.
The similarity is made clear in \cref{prop:altdef}.
\begin{proposition}
\label{prop:altdef}
Let \(U_{K;i}, V_{K;i}, D_i, R_{k;i}, W_{k;i}, B_{k;i}\) for appropriate \(k \leq K, i \leq 2^k\)
a \(t\)-\HSS generator for \(A\).
Let \(I,J \in \intset{1,2^K}\) and \(k\) the highest level of recursion for which \(A_{K;I,J}\) is not included in a diagonal block.
For \(i_1 = \lfloor I / 2^{K - k - 1}\rfloor, i_0 = \lfloor I / 2^{K - k}\rfloor\) and \(j_1 =
\lfloor J / 2^{K - k - 1}\rfloor\) we have
\begin{equation}
\label{eq:altdef}
A_{K ; I, J} =
U_{K ; I} R_{K ; I} ... R_{k + 1; i_1} B_{k ; i_0}
W_{k + 1; j_1} ... W_{K ; J} V_{K ; J}
\end{equation}
\end{proposition}
\begin{proof}
By induction on~\Cref{eq:HSS}.
\end{proof}
\begin{proposition}
\label{prop:hcost}
Any \(n \times n\) \(s\)-quasiseparable matrix has a \(2s\)-\HSS representation.
This is the optimal block parameter and the representation uses \(\Space{HSS}(n,s)=18ns\) field elements.
\end{proposition}
\begin{proof}
Consequence of \cref{prop:dth}.
For optimality let \(A\) be \(s\)-quasiseparable given in \(t\)-\HSS form. We use \cref{prop:altdef}:
\begin{equation}
\label{eq:rkbound}
\begin{bmatrix} A_{K ; 3\dots4,1\dots 2} & A_{K ; 3\dots4,5\dots 6} \end{bmatrix} =
\begin{bmatrix}
U_{K ; 3} R_{K ; 3}\\ U_{K ; 4} R_{K ; 4} \end{bmatrix} H
\end{equation}
where \(H \in K^{t \times 4t}\). The quasi-separability of \(A\) bounds the rank of the left part of
\cref{eq:rkbound} by \(2s\) while the one of the right side is bounded by \(t\).
When the first bound is tight we get \(t\geq 2s\).
\end{proof}
\subsection{\Bruhat generators}
The \Bruhat generator was first defined in \cite{P16,PS18}.
Contrarily to \SSS and \HSS, it does not use on a pre-defined grid but relies on the rank profile
information contained in the rank profile matrix~\cite{DPS17} of the lower and upper triangular
parts of the quasiseparable matrix.
Recall from \cite{PS18} that a matrix is \(t\)-overlapping if any subset of \(t + 1\) of its non-zero columns
(resp. rows)
contains at
least one whose leading non-zero element
is below (resp. before) the trailing non-zero element of another.
We call \(\J n\) the anti-identity matrix of dimension \(n\) and define the {\it Left} operator
\(\ultriangle:\K^{n\times n} \rightarrow \K^{n\times n}\) s.t.
\begin{equation}
\lft{A}_{i,j} = \left\{\begin{matrix} A_{i,j} & \text{ if } i + j \leq n \\
0 & \text{ otherwise } \end{matrix} \right..
\end{equation}
\begin{definition}
An \(n\times n\) matrix \(A\) is represented in \(t\)-\Bruhat format if it is given by a diagonal matrix
\(D\in \K^{n\times n}\) and 6 matrices \(
\Tag{C}{L}
\Tag{R}{L}
\Tag{E}{L}
\Tag{C}{U}
\Tag{R}{U}
\Tag{E}{U}\
where \(\Tag{C}{L}\in\K^{n \times u}\) and \(\Tag{C}{U}\in\K^{n \times v} \) are
in column echelon form and \(t\)-overlapping, \(\Tag{E}{L}\in\K^{u\times n}\) and
\(\Tag{E}{U}\in\K^{v\times n}\) are in column echelon form and \(t\)-overlapping
and \( \Tag{R}{L}\in\K^{u \times u}, \Tag{R}{U}\in\K^{v\times v}\) are permutation matrices and satisfy
\[
A= D+ \J{n}\lft{\Tag{C}{L}\Tag{R}{L}\Tag{E}{L}} + \lft{\Tag{C}{U}\Tag{R}{U}\Tag{E}{U}} \J{n}
\]
\end{definition}
\begin{proposition}
Any \(n \times n\) \(s\)-quasiseparable matrix has an \(s\)-\Bruhat representation. It uses
\(\Space{Bruhat}(n,s)=4ns\) field elements which is optimal.
\end{proposition}
\begin{proof}
By~\cite[Theorem~20]{PS18}. As \(2ns\) coefficients are necessary to represent all rank \(s\)
triangular matrices, \(4ns\) is optimal.
\end{proof}
\section{Construction of the generators}
\subsection{\SSS generator from a dense matrix}
We recall in \algoName{algo:DenseToSSS} the construction of an \SSS generetor from a dense
\(s\)-quasiseparable matrix \(A\in\K^{n\times n}\).
It is adapted from \cite[\S 6.1]{CDGPV03} and \cite[Alg. 6.5]{EG05bsss} where the
SVD based numerical rank revealing factorizations are replaced by~\PLUQ.
The blocks \(D_i\) are directly extracted from the dense matrix in \cref{step:di}.
Each block-triangular part is then compressed independently.
Each step eliminates a chunk made of a block-row of A and a remainder from the previous step.
The result is three blocks of the generator and a remainder to be eliminated at the subsequent step.
\begin{algorithm}[htb]
\algoCaptionLabel{DenseToSSS}{}
\begin{algorithmic}[1]
\algrenewcommand{\algorithmicensure}{\emph{InOut:}}
\Require{$A$ an $n\times n$ $s$-quasi-separable matrix with \(s \leq t\)}
\Ensure{\(P_i, Q_i, R_i, U_i, V_i, W_i, D_i\) for appropriate \(i \in \intset{1,N}\)
a \(t\)-\SSS representation of \(A\)}
\State \(A = \begin{smatrix} A_{1, 1} & \cdots & A_{1, N} \\
\vdots & & \vdots \\
A_{N, 1} & \cdots & A_{N, N} \end{smatrix}, H = \begin{smatrix} H_{0, 1} & \cdots & H_{0, N} \\
\vdots & & \vdots \\
H_{N, 1} & \cdots & H_{N, N} \end{smatrix}\gets 0\
\For {\(k = 1\dots N - 1\)}
\State \(D_k \gets A_{k,k}\) \label{step:di}
\State \(\paren{\begin{bmatrix} W_k \\ U_k\end{bmatrix}, \begin{bmatrix} V_{k + 1} &
H_{k, k + 2 \dots N} \end{bmatrix}} \gets
\PLUQ\paren{\begin{bmatrix} H_{k - 1, k + 1 \dots N} \label{step:pluq}\\
A_{k, k + 1 \dots N} \end{bmatrix}}\)
\State \(\paren{\begin{bmatrix} Q_{k + 1} \\ H_{k + 2 \dots N, k } \end{bmatrix}, \begin{bmatrix} R_k & P_k\end{bmatrix}
}
\gets
\PLUQ\paren{
\left[\begin{smallmatrix}
H_{k + 1 \dots N, k - 1} & A_{k + 1 \dots N, k}
\end{smallmatrix}\right]}\) \label{step:pluq2
\EndFor
\State{\(D_N = A_{N,N}\)}
\end{algorithmic}
\end{algorithm}
\begin{proposition}
\label{prop:dts}
\algoName{algo:DenseToSSS} computes a \(t\)-\SSS generator for an \(s\)-quasiseparable matrix (\(s \leq t\)) in
\(\Time{DenseToSSS}(n,t)=2C_\texttt{RF}n^2s^{\omega-2}\) field operations.
\end{proposition}
\begin{proof}
For \(k \in \intset{1,{N - 1}}\), the dimensions of the output of Lines \ref{step:pluq} and \ref{step:pluq2}
are sufficient since the input of the factorisation is a concatenation of a block of \(A\) with a
rank-revealing factor
of another block of \(A\) on the same side of the diagonal, and is hence of rank at most \(s\).
Let \(i,j \in \intset{1,N}\).
If \(i = j\) \cref{step:di}
for \(k = i\)
gives \(D_i = A_{i,i}\).
If \(i < j\), \cref{step:pluq} gives
\begin{align}
W_{j - 1}V_j &= H_{j-2,j} \\
W_kH_{k,j} &= H_{k - 1, j} & ( k &\in \intset{{1},{j - 2}})\\
U_i H_{i,j} &= A_{i, j} & (i &< N) \\
U_iV_{i + 1} &= A_{i, i+1}
\end{align}
which combines to \(U_i W_{i + 1} \dots W_{j - 1} V_j = A_{i, j}\).
The same way, if \(i > j\) then \(P_i R_{i - 1} \dots R_{j + 1} Q_j = A_{i,j}\).
The cost is
\(
\sum_{k = 1}^{N - 1} 2 \Time{RF}(t(N-k), 2t, s) = 2C_\texttt{RF} n^2 s^{\omega-2}
\).
\end{proof}
\subsection{\HSS generator from a dense matrix}
The first construction algorithm for a general quasiseparable matrix is presented in \cite{CGP06ULV}.
We present in \algoName{algo:DenseToHSS} an iterative version of the faster and simpler algorithm of \cite{XCGL10HSS}.
Each step of the loop on \(k\) passes block-row-wise and block-column-wise on the matrix inherited from the previous step,
factorising block rows and block columns two by two.
At each step each block is hence factorised twice, producing transition matrices \(R\) and \(W\), the remainder being either
passed to the following step or finally stored as a \(B\) matrix.
\begin{algorithm}[htbp]
\algoCaptionLabel{DenseToHSS}{}
\begin{algorithmic}[1]
\algrenewcommand{\algorithmicensure}{\emph{InOut:}}
\Require{$A$ an $n\times n$ quasiseparable matrix of order s}
\Ensure{\(U_{K;i}, V_{K;i}, D_i, R_{k;i}, W_{k;i}, B_{k;i}\) for appropriate \(k \leq K, i \leq 2^k\)
a \(t\)-\HSS representation of \(A\) with \(t \geq 2s\)}
\State \(H \gets A\) \label{step:ha}
\Comment{ Use the block division of \cref{eq:kdiv} with \(k = K\)}
\For{\(i = 1 \dots 2^K\)}
\State \(D_i \gets A_{K;i,i}\) \label{step:hdi}
\EndFor
\For {\(k = K \dots 1\)}
\For{\(i = 1 \dots 2^{k }\)} \Comment{All operations are in this loop}
\Statex \CommentLine{\(R_{K + 1 ; 2 i}\) (resp. \(W_{K + 1 ; 2 i}\) )
has row (resp. column) dimension 0}
\State \(\paren{
\begin{bmatrix} R_{k + 1; 2 i - 1} \\ R_{k + 1 ; 2 i} \end{bmatrix},
\begin{bmatrix} \hlu_{k ; i, 1 \dots i - 1} &
\hu_{k;i , i + 1 \dots 2^k}\end{bmatrix}
} \gets
\PLUQ\paren{
\left[\begin{smallmatrix} \hl_{k; i, 1 \dots i - 1} &
H_{k; i, i + 1 \dots2^k}\end{smallmatrix}\right]}\) \label{step:pluq1}
\State \(\paren{\left[\begin{smallmatrix}\hlu_{k;1 \dots i - 1, i} \\
\hl_{k; i + 1 \dots 2^k, i }\end{smallmatrix}\right],
\left[\begin{smallmatrix} W_{k + 1; 2 i - 1} & W_{k + 1 ; 2 i} \end{smallmatrix}\right]} \gets
\PLUQ\paren{\left[\begin{smallmatrix} \hu_{k;1 \dots i - 1, i } \\
H_{k; i + 1 \dots 2^k, i }\end{smallmatrix}\right]}\) \label{step:plc}
\EndFor
\For{\(i = 1 \dots 2^{k - 1}\)} \Comment{Only renaming from here}
\State \(B_{k; 2 i - 1} \gets \hlu_{k ; 2 i - 1, 2 i}\)
\State \(B_{k; 2 i} \gets \hlu_{k ; 2 i , 2 i - 1}\)
\For{\(j = 1 \dots 2^{k - 1}, j \neq i\)}
\State \(H_{k - 1 ; i, j} \gets \begin{bmatrix} \hlu_{k ; 2 i - 1, 2 j - 1} & \hlu_{k ; 2 i - 1, 2 j} \\
\hlu_{k ; 2 i , 2 j - 1} & \hlu_{k ; 2 i , 2 j} \end{bmatrix}\) \label{step:rec}
\State \( H_{k - 1 : j, i} \gets \begin{bmatrix} \hlu_{k : 2 j - 1, 2 i - 1} & \hlu_{k : 2 j - 1, 2 i} \\
\hlu_{k : 2 j , 2 i - 1} & \hlu_{k : 2 j , 2 i} \end{bmatrix}\)
\EndFor
\EndFor
\EndFor
\For{\(i = 1 \dots 2^K\)}
\State \( U_{K ; i} \gets R_{K + 1 ; 2 i - 1}\) \label{step:u}
\State \( V_{K ; i} \gets W_{K + 1 ; 2 i - 1}\)\label{step:v}
\EndFor
\end{algorithmic}
\end{algorithm}
\begin{proposition}
\label{prop:dth}
\algoName{algo:DenseToHSS} computes a \(t\)-\HSS generator for an \(s\)-quasiseparable matrix if \(2s \leq t\) in
\(C_\texttt{RF}n^2t^{\omega-2}\) field operations. For \(t=2s\),
this is \(\Time{DenseToHSS}(n,s)=2^{\omega}C_\texttt{RF}n^2s^{\omega-2}\).
\end{proposition}
\begin{proof}
Let \(k \in \intset{1,K}\), \(i\neq j \in \intset{1,{2^k}}\).
The dimensions of the output in Lines \ref{step:pluq1} and \ref{step:plc} is sufficient since the matrices being factorized are each time a concatenation of two blocks of rank at most \(s\) and are hence of rank at most
\(2s \leq t\).
If \(|i - j| = 1\),
the instructions give
\begin{equation}
\label{eq:iej}
H_{k;i, j} = \begin{bmatrix}R_{k + 1 ; 2i - 1} \\ R_{k + 1 ; 2i } \end{bmatrix} B_{k ; i} \begin{bmatrix}W_{k + 1 ; 2j - 1} & W_{k + 1 ; 2j } \end{bmatrix}.
\end{equation}
Otherwise,
\begin{equation}
\label{eq:inj}
H_{k;i, j} = \begin{bmatrix}R_{k + 1 ; 2i - 1} \\ R_{k + 1 ; 2i } \end{bmatrix} \hlu_{k ; i, j} \begin{bmatrix}W_{k + 1 ; 2j - 1} & W_{k + 1 ; 2j } \end{bmatrix}.
\end{equation}
Let now \(I,J \in \intset{1,N}\).
If \(I = J\), \cref{step:hdi}
gives \(D_I = A_{K;I,J}\).
Otherwise, let \(k\) be the highest level of recursion for which \(A_{K;I,J}\) is not included in a diagonal
block.
From \cref{step:ha}, \(A_{K;I,J} = H_{K;I,J}\).
\Cref{eq:inj} can be used \(K - k\) times, together with \cref{step:rec} to get
\begin{equation}
\label{eq:prod}
A_{K;I,J} =
R_{K + 1; 2 I - 1} \dots R_{k + 2; i_2}\hlu_{k + 1; i_1, j_1}
W_{k + 2 ; j_2} \dots W_{K + 1 ; 2 J - 1}
\end{equation}
where \(i_2 = \lfloor I / 2^{K - k - 2}\rfloor, i_1 = \lfloor I / 2^{K - k - 1}\rfloor, j_1 =
\lfloor J / 2^{K - k - 1}\rfloor\) and \(j_2 = \lfloor J/ 2^{K - k - 2}\rfloor\).
%
\(R_{K + 1; 2 I - 1}\), \(W_{K + 1 ; 2 J - 1}\) and \(\hlu_{k + 1; i_1, j_1}\) can be replaced in \cref{eq:prod} using Lines
\ref{step:u} and \ref{step:v} and \cref{eq:iej} (from the definition of \(k\) we have
\(|i_1 - j_1| = 1\))
in order to get \cref{eq:altdef};
this concludes the proof of correctness.
\Cref{step:pluq1} at \(k<K\) and \(i\) peforms a rank revealing decompositions on an input formed
by the \(2t\times (i-1)t\) block \(\hu_{k;i,1 \dots i - 1 } \) and
the \(2t\times 2t(2^k-i)\) block \(H_{k; i, i + 1 \dots 2^k }\) at cost \(\Time{RF}(t(2^{k+1} - i), 2t, t)\).
The cost is equal for~\cref{step:plc}.
The overall cost is then
\(
\sum_{k=1}^{\log_2 \frac{n}{t}} \sum_{i=1}^{2^k} 4C_\texttt{RF}(2^{k+1}-i)t^\omega
\leq 4C_\texttt{RF}n^2t^{\omega-2}
\leq 2^{\omega}C_\texttt{RF}n^2s^{\omega-2}.
\)
\end{proof}
Because
the blocks of each side of the diagonal are defined by the same matrices,
\algoName{algo:DenseToHSS}
and any \HSS construction
algorithm
applies rank revealing
factorisations on blocks with rank bounded by \(2s\) for
\(s\)-quasiseparable matrices instead of
\(s\) in \algoName{algo:DenseToSSS}.
The optimal \HSS block size of \(s\)-quasiseparable matrices is thus \(2s\),
which makes \HSS less efficient
in terms of storage and operation cost.
As the costs are higher and \HSS has the same drawbacks as \SSS, namely needing a fixed slicing grid and a
previously computed quasiseparability order,
we do not detail more algorithms for \HSS.
For information in the numerical context we mainly refer to \cite{lyons2005fast, SDC07}.
Note that faster construction algorithms exist, probabilistic in \cite{Mart11HSS} and with constraints on the input in
\cite{CGP06ULV}.
\subsection{Bruhat generator from a dense matrix}
\label{sec:dtb}
The construction of a \Bruhat generator from a dense matrix is achieved by
\cite[Alg.~12]{PS18}
run twice, once for each of the upper and lower triangular parts of the input matrix,
and the diagonal matrix \(D\) is directly extracted from the dense matrix.
We give in \algoName{algo:LBruhatGen} an updated version of \cite[Alg.~12]{PS18},
where Schur complement computations are delayed until they are needed.
This allows for faster computations when the input is not given as a dense matrix
and will be used for computing the sum of two matrices in \Bruhat form and generators from a sparse matrix.
\algoName{algo:LBruhatGen} can be given any input format,
provided we have a way to compute for any submatrix \(B\) of the input matrix
\begin{enumerate}
\item \(\bbcre(B, G, H)\) a CRE decomposition of \(B - G \trsp H\); \label{it:bbcre}
\item for \RRP a set of indices,
\(\exprows B{\RRP}\) and \expcols B \RRP the rows and columns of \({B}\)
with indices in \RRP. \label{it:expand}
\end{enumerate}
We use the notation
\texttt{TRSM} for {\it TRiangular Solve Matrix}: \texttt{TRSM}\((L,A)\) outputs \(\inv L A\) for \(L\) triangular.
\begin{algorithm}[htbp]
\algoCaptionLabel{LBruhatGen}{}
\begin{algorithmic}[1]
\Require{\(A\in\K^{m\times m}\) left triangular \(s_A\)-quasiseparable}
\Require{\(G,H \in \K^{m\times t}\)}
\Comment{\(t=0\) on the first call}
\Ensure{\(C, R, E\) a left-\Bruhat generator for \(A - \lft{G\trsp H}\)}
\State Split
\(
A = \begin{bmatrix}\Tag{A}{11}&\Tag{A}{12}\\\Tag{A}{21}&\end{bmatrix},
G = \begin{bmatrix}\Tag{G}{1} \\\Tag{G}{2} \end{bmatrix},
H = \begin{bmatrix} \Tag{H}{1}\\ \Tag{H}{2} \end{bmatrix}
\) where \(\Tag{A}{11}\in \K^{\frac{m}{2}\times \frac{m}{2}}\)
\State \(C_0,R_0,E_0 \assign \bbcre(\Tag{A}{11},\Tag{G}{1},\Tag{H}1)\) \label{step:bbcre}
\State \(\RRP \assign \text{\texttt{RRP}}(C_0); \CRP \assign \text{\texttt{CRP}}(E_0);
r_0\assign \#\RRP \) \label{step:rp}
\State \( \begin{bmatrix} U & V \end{bmatrix} \assign E_0 Q_{\mathcal C}\)
where \(U\in \K^{r_0\times r_0}\) is upper triangular
\State \(\begin{bmatrix} L \\ M \end{bmatrix} \assign P_{\mathcal R} C_0 \)
where \(L \in \K^{r_0\times r_0}\) is lower triangular.
\State \(X\assign \exprows{\Tag{A}{12}}{\RRP} - \rows{\Tag{G}{1}}{\RRP}\trsp {\Tag{H}{2}}\) \label{step:cbx}
\State \({\Tag{B}{12}}\!\assign \lftr{\trsm \paren{L, X}}\) \label{step:tr1}
\Comment{\(\rows{\Tag{A}{12}}{\RRP} = \lftr{L \Tag{B}{12}
+ \rows{\Tag{G}{1}}{\RRP}\trsp{\Tag{H}{2}}}\)}
\State \(Y\assign \expcols{\Tag{A}{21}}{\CRP} - \Tag{G}{2}\trsp{\rows{\Tag{H}{1}}{\CRP}}\) \label{step:cby}
\State \(\trsp{\Tag{B}{21}}\assign \lftc{\trsm(\trsp U,\trsp{Y})}\) \label{step:tr2}
\Statex
\Comment{\(\cols{\Tag{A}{21}}{\CRP} = \lftc{ \Tag{B}{21} U
+ \Tag{G}{2}\cols{\trsp{\Tag{H}{1}}}{\CRP}}\)}
\State{\(C_1, R_1, E_1 \assign\)}
\Statex\(\ltcre
\left(\expcols{\Tag{A}{21}}{\compl{\CRP}}\rows{\Id}{\compl{\CRP}},
\begin{smatrix}\Tag{G}2 & \Tag{B}{21}\end{smatrix},
\cols{\Id}{\compl{\CRP}}
\begin{smatrix} {\rows{\Tag{H}{1}}{\compl{\CRP}}} & \trsp{V} \end{smatrix}
\right)\) \label{step:cbc1}
\State\(C_2, R_2, E_2 \assign\)
\Statex\(\ltcre
\left(\cols{\Id}{\compl{\RRP}}\exprows{\Tag{A}{12}}{\compl{\RRP}},
\cols{\Id}{\compl{\RRP}}
\begin{smatrix}\rows{\Tag{G}{1}}{\compl{\RRP}} & M\end{smatrix},
\begin{smatrix} {\Tag{H}{2}} & \trsp{\Tag{B}{12}} \end{smatrix}\right)\) \label{step:cbc2}
\State{\(P_{01} \assign\) the permutation which sorts the rows of \(E_0\) and \(E_1\) by
increasing column of pivot}
\State{\(P_{02} \assign\) the permutation which sorts the columns of \(C_0\) and \(C_2\)
by increasing row of pivot}
\State{\(C \assign \begin{smatrix} C_0 & C_2 & \\
{\Tag{B}{21}}\trsp{R_0} & & C_1\end{smatrix}\begin{smatrix}P_{02} & \\
& I\end{smatrix}\)}
\State{\(R \assign \begin{smatrix} \trsp{P_{02}}& \\
& I \end{smatrix}\begin{smatrix} {R_{0}}& & \\
& & R_2 \\ & R_1 & \end{smatrix}\begin{smatrix} \trsp{P_{01}}& \\ & I \end{smatrix}\)}
\State{\(E \assign \begin{smatrix}P_{01} & \\
& I\end{smatrix}\begin{smatrix} E_0 & \trsp{R_0} {\Tag{B}{12}} \\
E_1 & \\ & E_2\end{smatrix}\)}
\State \Return \(C, R, E\)
\end{algorithmic}
\end{algorithm}
\begin{proposition}
\label{prop:dtb}
An \(s\)-\Bruhat generator can be computed from an \(n \times n\) dense \(s\)-quasiseparable matrix in
\(\Time{DenseToB}(n,s) = C_\texttt{RF} n^2s^{\omega - 2}\).
\end{proposition}
\begin{proof}
\algoName{algo:LBruhatGen} is adapted from~\cite[Alg.~12]{PS18}; we therefore refer to the
proof of~\cite[Theorem~24]{PS18} for its correctness.
Apart from the order in which they are made, the operations are the same in both algorithms when the input is dense and the cost is hence the same.
Computing a \Bruhat generator from a dense matrix is two applications of \algoName{algo:LBruhatGen}.
The cost satisfies
\(\Time{LBG}(n,s) \leq C_\texttt{RF}/4 n^2s^{\omega - 2}+2\Time{LBG}(n/2,s)
\leq C_\texttt{RF}/2 n^2 s^{\omega - 2}.
\
\end{proof}
\subsection{Bruhat generator from a sparse matrix}
In applications, matrices are often presented in a sparse structure. In order to detect and/or harness
their quasiseparable structure, it is crucial to exploit the sparsity in the construction of the
quasiseparable generators.
For the construction of a \Bruhat generator, the generic algorithm \algoName{algo:LBruhatGen} can be
applied on a sparse matrix, provided two operations are specialized:
\begin{enumerate}
\item the extraction of a subset of \(\leq s\) rows or columns into a dense format, which is
straightforward for a sparse matrix;
\item the computation of a CRE decompoistion, which is specialized in~\algoName{algo:SparseCRE}
which in turn uses \algoName{algo:SparseRankProfiles}
\end{enumerate}
\begin{algorithm}[htb]
\algoCaptionLabel{SparseCRE}{
\begin{algorithmic}[1]
\Require{\(A\in \K^{m \times m}\) a rank \(\leq s\) sparse matrix}
\Require{\( G, H\in \K^{m\times t}\)}
\Ensure \(C,R,E\) such that \(A = CRE + G\trsp H\)
\State \(\RRP, \CRP \assign \Call{algo:SparseRankProfiles}{A, G, H} \)
\State \(P=\begin{bmatrix} \rows{\Id}{\RRP} \\ \rows{\Id}{\compl{\RRP}} \end{bmatrix} \) ;
\(Q = \begin{bmatrix} \cols{\Id}{\CRP} & \cols{\Id}{\compl{\CRP}} \end{bmatrix}\) \label{alg:csu:q}
\Statex
\CommentLine{With {\(\Tag{\bar A}{11} \in \K^{|\RRP|\times|\RRP|}\)} write
\(P\paren{A - G\trsp H}Q =
\begin{bmatrix} \Tag{\bar A}{11}& \Tag{\bar A}{12}\\ \Tag{\bar A}{21}& \Tag{\bar A}{22}\end{bmatrix} -
\begin{bmatrix} \Tag{\bar G}{1} \\ \Tag{\bar G}{2}\end{bmatrix}
\trsp{\begin{bmatrix} \Tag{\bar H}{1}\\ \Tag{\bar H}{2}\end{bmatrix}}\)}
\State \(\Tag{M}{11} \assign \Tag{\bar A}{11}- \Tag{\bar G}{1} \trsp{(\Tag{\bar H}{1})}\) \label{alg:csu:a11}
\State \(\Tag{M}{12} \assign \Tag{\bar A}{12}- \Tag{\bar G}{1} \trsp{(\Tag{\bar H}{2})}\) \label{alg:csu:a11}
\State \(\Tag{M}{21} \assign \Tag{\bar A}{21}- \Tag{\bar G}{2} \trsp{(\Tag{\bar H}{1})}\) \label{alg:csu:a11}
\State \((L,R,U) \assign \cre\paren{\Tag{M}{11}}\) \label{alg:CREsparse:cre1}
\State \(C\assign \texttt{TRSM}(L, \Tag{\bar M}{12})\) \Comment{\(C= L^{-1} (\Tag{\bar A}{12}-\Tag{G}{1}\Tag{H}{2})\)} \label{alg:CREsparse:ostrsm}
\State \(D\assign \texttt{TRSM}(\Tag{\bar A}{21},\trsp{U})\)\Comment{\(D=(\Tag{\bar A}{21}-\Tag{G}{2}\Tag{H}{1})U^{-1}\)}
\State \(E\assign \begin{bmatrix} U & \trsp{R}C\end{bmatrix} \trsp{Q}\)
\State \(C\assign \trsp{P} \begin{bmatrix} L \\ D\trsp{R}\end{bmatrix} \)
\State \Return \((C,R,E)\)
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[htb]
\algoCaptionLabel{SparseRankProfiles}{
\begin{algorithmic}[1]
\Require{\(A\in\K^{n\times n}\) a sparse matrix of rank $\leq s$.}
\Require{\(G,H \in \K^{n\times t}\) dense matrices}
\Ensure{\(\RRP_A,\CRP_A\) the row and column rank profiles of \(A-G\trsp H\)}
\State \(\Tag{T}{1} \assign \) a unif. random \(n\times (s+t)\) Toeplitz matrix from \(S\subseteq \K\)
\State \(\Tag{T}{2} \assign \) a unif. random \( (s+t) \times n\) Toeplitz matrix from \(S\subseteq \K\)
\State \(K \assign \trsp{H} \Tag{T}{1}\) \label{line:toep1}
\State \(L \assign \Tag{T}{2} G\) \label{line:toep2}
\State \(P \assign A \Tag{T}{1} - GK\)
\State \(Q \assign \Tag{T}{2} A - L\trsp{H}\)
\State \Return \texttt{RowRankProfile}\((P)\), \texttt{ColRankProfile}\((Q)\)
\end{algorithmic}
\end{algorithm}
\begin{lemma}
\label{lem:sprp}
\algoName{algo:SparseRankProfiles} is correct with probablity at least \(1-2r/|S|\) and runs in
\(\Time{SparseRP}(n,r)=2(C_\omega +C_\texttt{RF})nr^{\omega-1}+2r|A|\) with \(r=t+s\).
\end{lemma}
\begin{proof}
Applying the Toeplitz pre-conditionners in~\cref{line:toep1,line:toep2} costs
\(\frac{nt}{r}\softO{r}\) which is domintated by \(nr^{\omega-1}\).
\end{proof}
\begin{proposition}
\label{prop:spc}
\algoName{algo:SparseCRE} computes a CRE decomposition of \(A - G \trsp H\) with probablity at least \(1-2r/|S|\) in
\(\Time{SparseCRE}(n,r) =
\left(\frac{2^{\omega}-3}{2^{\omega-2}-1}C_\omega+2C_\texttt{RF}\right) n r^{\omega - 1}+2r|A|\) field operations for
\(s + t \leq r\).
\end{proposition}
\begin{proof}
Let \(\rho\) be the rank of \(A-G\trsp H\).
\begin{equation*}
\begin{split}
\Time{SparseCRE}(n,r)&=2\Time{MM}(n,r,t) + \Time{CRE}(\rho,\rho,\rho) + 2\Time{TRSM}(n-\rho,\rho) \\ & +\Time{SparseRP}(n,r)\\
& \leq nr^{\omega-1}\left(4C_\omega+\frac{2C_\omega}{2^{\omega-1}-2}+2C_\texttt{RF}\right)+2r|A|.
\end{split}
\end{equation*}
\end{proof}
\begin{proposition}
\algoName{algo:LBruhatGen} computes a Left-\Bruhat generator from an sparse \(s\)-quasiseparable matrix \(A \in \K^{n\times n}\) in
\begin{equation*}
\Time{SpGenB}(n,s, |A|)=
\paren{\frac{2^{\omega + 1}-9}{2^{\omega-1}-2} \cw + \crf} n s^{\omega - 1} \log n/s + 2s|A|
\end{equation*}
field operations with probability at least \(1-2n/|S|\).
\end{proposition}
\begin{proof}
First, remark that the \(G\) and \(H\) matrices correspond to delayed Schur complement updates for
pivots processed in the previous calls. Hence, in every call to \algoName{algo:LBruhatGen}, these
pivots are located to the left, to the top or in the left-top corner of the work matrix. The
quasiseparable condition imposes that there are \(t\leq 2s\) of them.
Moreover, in the call to \algoName{algo:SparseCRE}, the ranks verify \(r_A+r_B+t \leq s\). Hence
we can bound \(t\) and write the cost of \algoName{algo:LBruhatGen} only in terms of \(n\) the dimension of
the matrix, \(s\) the initial quasiseparability order, and \(|\cdot|\) the amount of non-zero coefficients of the submatrices we consider.
\begin{align*}
T(n,s, |A|) &\leq &&T(n/2,s, |A_2|)+ T(n/2, s, |A_3|) \\ &&&+
\Time{SparseCRE}(n/2,s, |A_1|) \\
&&&+
2\Time{MM}(s, 2s, n / 2) + 2\Time{TRSM}(s, n/ 2)\\
&\leq &&T(n/2,s, |A_2|)+ T(n/2, s, |A_3|) +
2s|A_1| \\
&&&+ \paren{\frac{2^{\omega + 1}-9}{2^{\omega-1}-2} \cw + \crf} n s^{\omega - 1}.
\end{align*}
The failure probability is obtained by a union bound on the failure probability of each of the \(n/s\) calls to \algoName{algo:SparseCRE}.
\end{proof}
We are not aware of any similar algorithm for computing an \SSS or \HSS generator using the sparsity of the input matrix and can hence
only compare our result to the quadratic generation from a dense matrix.
\subsection{Experimental comparison}
\label{sec:ecd}
To complement the asymptotic cost analysis, we present in~\cref{fig:dtq} experiments comparing the
computation time for the construction of \SSS and \Bruhat generators.
The timings for \Bruhat are sub-linear in \(s\), as could be expected from \cref{prop:dtb} but
also slightly depends on \(r\) which comes from neglected costs arising e.g. from the
numerous permutations.
The \SSS cost is constant on our values for reasons we are unable to explain yet.
It is almost always lower than the \Bruhat cost. Yet remember that \algoName{algo:DenseToSSS} takes the quasiseparable order as input, so it has to be computed first (for example with \algoName{algo:LBruhatGen}).
\section{Application to a block vector}
We study here the application of an \(s\)-quasi-separable matrix \(A \in \K^{n \times n}\) given by its generators
(\SSS or \Bruhat) to a block of \(v\) vectors \(B \in \K^{n \times v}\).
We give the costs for \(v \leq s\) (they can be otherwise deduced by slicing \(B\) in blocks
of \(s\) columns).
\subsection{\SSS \(\times\) dense}
We here recall the algorithm of \cite[\S 2]{CDGPV03} for computing the product of
an \SSS matrix with a dense
matrix (independently published in \cite[Alg. 7.1]{EG05bsss}).
For simplicity, \algoName{algo:LowSSSxDense} only details the computations with a strictly
lower-block-triangular
\SSS matrix,
that is a matrix whose \SSS representation is zero except for the \(P_i, Q_i\) and \(R_i\).
Extrapolating from there to the product with any \SSS matrix can be done by transposing
the algorithm for the upper-block-triangular part, and adding the product with the
block-diagonal matrix made of the \(D_i\).
\begin{algorithm}[htbp]
\algoCaptionLabel{LowSSSxDense}{}
\begin{algorithmic}[1]
\algrenewcommand{\algorithmicensure}{\emph{InOut:}}
\Require{
\(P_i, Q_i, R_i\) for
\(i \in \intset{1,N}\)
an \(s\)-\SSS generator for a strictly lower-block-triangular
matrix \(A\);
\(B\text{ and }C\) dense \(n \times v\) matrices}
\Ensure{\(C += AB\)}
\State Split \(B = \begin{bmatrix} B_{1}\\
\vdots \\
B_{N} \end{bmatrix}\), \(C = \begin{bmatrix} C_{1}\\
\vdots \\
C_{N} \end{bmatrix}\) in \(s\times s\) blocks
\State \(\Hi 1 \gets Q_1 B_1\)
\For {\(i = 2\dots N\)}
\State \(\Hi i \gets Q_i B_i + R_i \Hi{i - 1}\)
\State \(C_i \gets C_i + P_i\Hi{i - 1}\)
\EndFor
\end{algorithmic}
\end{algorithm}
\begin{proposition}
\label{prop:sxd}
The product of an \(n \times n\) matrix given by its \(s\)-\SSS generator with an \(n \times v\) dense
matrix with \(v \leq s\) can be computed in
\(\Time{SxDense}(n,s,v)= 7C_\omega nsv^{\omega-2}\).
\end{proposition}
\begin{proof}
In \algoName{algo:LowSSSxDense} we have by induction that
\begin{equation}
\text{for }i \in \intset{1,N}, \Hi i = \sum_{j = 1}^{i } R_{i} \dots R_{j + 1} Q_jB_j.
\end{equation}
As the blocks of the product follow
\begin{align}
C_i
&= P_i \sum_{j = 1}^{i - 1} R_{i - 1} \dots R_{j + 1} Q_jB_j, \label{eq:ci}
\end{align}
\(\Hi{i - 1}\) can be multiplied once by \(P_i\) to compute \(C_i\) and once by
\(R_i\) to compute the following blocks.
The cost is \(N \times C_\omega s^2v^{\omega-2}\) for the diagonal blocks and two applications of
\algoName{algo:LowSSSxDense} in which
each step costs \(3C_\omega s^2v^{\omega-2}\).
\end{proof}
\subsection{\Bruhat \(\times\) dense}
\begin{proposition}
\label{prop:bxd}
The product of an \(n\times n\) matrix given by its \(s\)-\Bruhat generator by a
dense \(n\times v\) matrix with \(v\leq s\) can be computed in
\(
\Time{BxDense}(n,s,v)=8C_\omega nsv^{\omega-2}
\).
\end{proposition}
\begin{proof}
This is given
by \cite[Alg.~14]{PS18} called twice on the lower and upper triangular part
of the quasiseparable matrix.
\end{proof}
Note that in order to benefit from fast matrix multiplication, the \Bruhat generator (using
\(4ns\) space) needs to be transfered into a Compact-\Bruhat form, by storing each echelon
from into two block diagonal matrices using twice as many field elements (additonal ones being
zeros). This compression can be done online, hence the space storage remains \(4ns\), but the cost
of the product by a dense matrix becomes \(8C_\omega nst^{\omega-2}\) hence losing the advantage over the \SSS
format (with cost \(7C_\omega nsv^{\omega-2}\) for the same operation).
\subsection{Experimental comparison}
\label{sec:eca}
Experimental results are given in \cref{fig:apq} (\cref{app:fig}).
As expected from Propositions \ref{prop:sxd} and \ref{prop:bxd} we obtain costs that are linear in \(s\); we can also observe the same slight dependance in \(r\) of the \Bruhat cost as in \cref{sec:ecd}.
On the parameters we chose, \SSS is about four times faster than \Bruhat.
This can be explained by the compactification of the \Bruhat generator needed for the product.
This operation is free of arithmetic operations and hence does not appear in the cost of
\cref{prop:bxd} but the data tranfers are non-negligible in practice.
\section{Sum of quasiseparable matrices}
The sum and product of two quasiseparable matrices of order \(s_B\) and \(s_C\)
are quasiseparable matrices of order at most \(s_B + s_C\).
In this section we show how to compute \SSS and \Bruhat generators for the sum of two quasiseparable matrices.
The result we give in \cref{prop:sumcost} for the sum of matrices given in \SSS form can only be used on two
generators defined on the same grid.
This is a drawback of most operations in \SSS which is avoided with the \Bruhat format.
As a consequence, in a large sequence of operations, the \SSS grid size needs to be chosen according
to the maximal quasi-separability order among all intermediate results,
while the \Bruhat always fits to the current quasiseparable order. This can impact the overall cost.
The slower original \SSS format of~\cite{Eidelman1999OnAN} avoids this issue, at the expense of
multiplying space and time costs by the quasiseparability order, as in~\cite{BEG17,BEG14}.
\subsection{SSS sum}
Consider two matrices \(B\) and \(C\) with the same order \(s\).
We first note that the concatenation of
the blocks of both input generators leads to matrices which satisfy \cref{eq:def}
for \(A = C + B\) \cite[\S 10.2]{CDGPV03}
Let \(\Tag PK_i, \Tag VK_i
, \Tag QK_i, \Tag UK_i
, \Tag RK_i, \Tag WK_i
, \Tag DK_i
\) for appropriate \(i \in \intset{1,N}\) be an \(s\)-\SSS representation of $K$ for $K\in\{B,C\}$.
\label{prop:apb}
The following matrices satisfy \cref{eq:def} with $A=B+C$, for appropriate \(i \in \intset{1,N}\).
\begin{align}
P_i &= \begin{bmatrix}
\Tag PB_{i} & \Tag PC_{i}
\end{bmatrix} ,
Q_i = \begin{bmatrix}
\Tag QB_{i}\\ \Tag QC_{i}
\end{bmatrix},
R_i = \begin{bmatrix}
\Tag RB_{i} & \\
& \Tag RC_i
\end{bmatrix}\\
U_i &= \begin{bmatrix}
\Tag UB_{i} & \Tag UC_{i}
\end{bmatrix},
V_i = \begin{bmatrix}
\Tag VB_{i}\\\Tag VC_{i}
\end{bmatrix},
W_i = \begin{bmatrix}
\Tag WB_{i} & \\
& \Tag WC_i
\end{bmatrix}\\
D_i &= \Tag DB_i + \Tag DC_i \label{eq:dab}
\end{align}
Such sets of matrices with these dimensions satisfying \cref{eq:def}
will be called an \((s, 2s)\)-\SSS generator for \(A\).
The granularity of their description remains that of \(s \times s\) blocks, but the dimension of the matrices in the representation is doubled and leads to a suboptimal storage size.
A second step is therefore to use \algoName{algo:SssCompression} to obtain a \(2s\)-\SSS generator for the sum
and reduce the storage size by \(4s(n-2s)\).
\begin{algorithm}[htbp]
\algoCaptionLabel{SssCompression}{}
\begin{algorithmic}[1]
\algrenewcommand{\algorithmicensure}{\emph{InOut:}}
\Require
\(P_i, Q_i, R_i, U_i, V_i, W_i, D_i\) for appropriate \(i \in \intset{1,N}\),
an \((s, 2s)\)-\SSS generator for \(A \in \K^{n \times n}\)}
\Ensure{\(P'_i, Q'_i, R'_i, U'_i, V'_i, W'_i, D'_i\) for appropriate \(i \in \intset{1,M}\),
a \(2s\)-\SSS representation of \(A\)
with
\(M = \lceil N/2 \rceil\)}
\For {\(i \gets 1\dots M\)}
\State \( P'_i \gets \begin{bmatrix}
P_{2i-1} \\
P_{2i} R_{2i - 1}
\end{bmatrix}\)
\State \( Q'_i \gets \begin{bmatrix}
R_{2i} Q_{2i-1} & Q_{2i}
\end{bmatrix}\)
\State \( R'_i \gets R_{2i} R_{2i - 1} \)
\State \( U'_i \gets \begin{bmatrix}
U_{2i-1} W_{2i} \\
U_{2i}
\end{bmatrix}\)
\State \( V'_i \gets \begin{bmatrix}
V_{2i-1} & W_{2i - 1} V_{2i}
\end{bmatrix}\)
\State \( W'_i \gets W_{2i - 1} W_{2i} \)
\State \( D'_i \gets \begin{bmatrix}
D_{2i - 1} & U_{2i - 1} V_{2i} \\
P_{2i} Q_{2i - 1} & D_{2i}
\end{bmatrix}\)
\EndFor
\end{algorithmic}
\end{algorithm}
\begin{proposition}
\label{prop:sumcost}
A \(2s\)-\SSS representation of \(B + C \in \K^{n \times n}\) can be computed from \(s\)-\SSS
representations of \(B\) and \(C\) in time
\begin{equation}
\Time{S+S}(n,s) \gets \paren{10 + 2^\omega} C_\omega n s^{\omega - 1}.
\end{equation}
\end{proposition}
\begin{proof}
For any \(s \times s\) block \(A_{i,j}\) of \(A = B + C\),
it can be checked that the representation in the output of \algoName{algo:SssCompression} called on the generator of \cref{prop:apb} matches.
The additions of \cref{eq:dab} are dominated by the call to
\algoName{algo:SssCompression} whose cost is of \(M\) steps with four \(2s \times 2s\) by \(2s \times s\) products,
two \(2s \times 2s\) square products, and two \(s \times 2s\) by \(2s \times s\) products.
\end{proof}
Note that the \((s, 2s)\)-\SSS generator is intermediate between the \SSS form and the original definition of
quasiseparable matrices given in
\cite{Eidelman1999OnAN}, where the generators are \(s \times s\) matrices but the granularity of the
description is of dimension 1.
\subsection{Bruhat sum}
\label{sec:bsum}
As with \SSS,
the sum of two matrices in \Bruhat form can be computed by first concatenation of both generators, then by retrieving the \Bruhat format in a second step.
Given two left triangular matrices \(A\) and \(B\) given by \Bruhat generators
\(\Tag{C}{A},\Tag{R}{A},\Tag{E}{A},\Tag{C}{B},\Tag{R}{B},\Tag{E}{B}\), their sum indeed writes
\begin{equation}\label{eq:sumbb}
A+B = \lft{
\begin{bmatrix} \Tag{C}{A}&\Tag{C}{B}\end{bmatrix}
\begin{bmatrix} \Tag{R}{A}\\ & \Tag{R}{B}\end{bmatrix}
\begin{bmatrix} \Tag{E}{A} \\ \Tag{E}{B}\end{bmatrix}
}.
\end{equation}
A \Bruhat generator for the right side in \cref{eq:sumbb} can be obtained from a call to
\algoName{algo:LBruhatGen}, viewed here as a compression algorithm.
This relies on a specific CRE decomposition
(\algoName{algo:BruhatSumCRE}),
and on having
\(\exprows D \RRP\)
for \(D\)
a submatrix of a sum given as in \cref{eq:sumbb} and \RRP a set of
row indices
(\cref{prop:exp}).
\begin{algorithm}[htb]
\algoCaptionLabel{BruhatSumCRE}{}
\begin{algorithmic}[1]
\Require{\(A, B \in\K^{n\times n}\) of rank $\leq r_A$ and \(\leq r_B\) given by
generators
\(\Tag{C}{A},\Tag{R}{A},\Tag{E}{A},\Tag{C}{B},\Tag{R}{B},\Tag{E}{B}\)
s.t. \(A=\Tag{C}{A}\Tag{R}{A}\Tag{E}{A}\) and \( B=\Tag{C}{B}\Tag{R}{B}\Tag{E}{B}\) which
are submatrices of \Bruhat generators of matrices comprising \(A\) and \(B\)}
\Require{\(G,H \in \K^{n\times t}\)}
\Ensure{\(C, R, E\) such that \(A+B = C R E + G\trsp H\)}
\State \(\Tag{C}{R},\Tag{R}{R},\Tag{E}{R} \assign \cre\paren{
\begin{smatrix}
\Tag{R}{A}\Tag{E}{A}\\
\Tag{R}{B}\Tag{E}{B}\\
-\trsp H
\end{smatrix}
}
\) \label{step:rh}
\State \(\Tag{C}{L},\Tag{R}{L},\Tag{E}{L} \assign \cre\paren{
\begin{smatrix} \Tag{C}{A} &\Tag{C}{B} & G \end{smatrix}
}\)
\State \(X \assign \Tag{R}{L}\Tag{E}{L}
\Tag{C}{R}\Tag{R}{R}\)
\State \( \Tag{C}{X},\Tag{R}{X},\Tag{E}{X} \assign \cre(X)\)
\State \(C\assign \Tag{C}{L}\Tag{C}{X}\) \label{step:c}
\State \(R\assign \Tag{R}{X}\)
\State \(E\assign \Tag{E}{X}\Tag{E}{R}\) \label{step:e}
\end{algorithmic}
\end{algorithm}
\begin{proposition}
\algoName{algo:BruhatSumCRE} computes a CRE decomposition of \(A+B - G \trsp H\) in
\(\Time{BSumCRE}(n,r) = \paren{3 C_\omega + 2 C_\texttt{RF}} n r^{\omega - 1}\) for \(r_A+r_B + t \leq r\).
\end{proposition}
\begin{proof}
The matrices \(C\) and \(E\) are in column and row echelon form respectively as they are products of
two echelon forms.
The cost is that of two dense CRE decompositions of size \(n \times (r_A+r_B + t)\) and products of an
\(n \times (r_A+r_B+t)\) matrix by two
\((r_A+r_B + t) \times ( r_A+r_B+t)\) and one \((r_A+r_B + t) \times n
\) matrices.
\end{proof}
\begin{proposition}
\label{prop:exp}
For \(D\in\K^{n\times n}\) a submatrix of a
the left-triangular part of a
sum as in \cref{eq:sumbb} and \RRP a set of
\(s\) row indices,
\(\exprows D \RRP\) can be computed in \(\Time{SumExp}(n, s) = \cw ns^{\omega - 1}\).
\end{proposition}
\begin{proof}
There are at most \(s_A\) (resp. \(s_B\)) pivots of \(A\) (resp. \(B\)) impacting \(D\).
We can thus write \(D = CRE\) with \(C\) made of \(n\) rows and \(s_A + s_B\) columns of \(\begin{bmatrix} \Tag{C}{A}&\Tag{C}{B}\end{bmatrix}\),
\(R\) a permutation and \(E\) made of \(n\) columns and \(s_A\) rows of \(\Tag{E}{A}\) and \(s_B\) rows of \(\Tag{E}{B}\).
\end{proof}
\begin{proposition}
\label{prop:cbsum}
The \Bruhat form of the sum of two \(n \times n\) matrices of quasiseparable order \(s_A\) and \(s_B\) in \Bruhat form can be computed
in
\(
\Time{B+B}(n,s) = \paren{\frac{9 \cdot 2^{\omega - 2} - 8}{2^{\omega - 2} - 1}\cw
+ 2\crf} n s^{\omega - 1} \log n/s \label{eq:comp+}
\)
for \(s=s_A+s_B\).
\end{proposition}
\begin{proof}
Each lower and upper triangular part is converted to a left triangular instance and computed
independently.
\algoName{algo:LBruhatGen} is then called twice with \(t=0\) on an input matrix
in factorized form as in~\eqref{eq:sumbb}.
The proof is the same as for \cref{prop:spc} except that in the cost, the \Time{SparseCRE} terms
are replaced by \Time{BruhatSumCRE} terms and
the rows and columns of the submatrices are computed at a cost given by \Time{SumExp}.
Then we have
\begin{align*}
T(n,s) &\leq &&2T(n/2,s)+\Time{BSumCRE}(n/2,s) + 2\Time{SumExp}(n/2,s,s) \nonumber\\
&&&+
2\Time{MM}(s, 2s, n / 2) + 2\Time{TRSM}(s, n/ 2)\\
&\leq &&2T(n/2,s) + \paren{\frac{9 \cdot 2^{\omega - 3} - 4}{2^{\omega - 2} - 1}\cw + \crf}ns^{\omega - 1}
\end{align*}
for one call to \algoName{algo:LBruhatGen}.
\end{proof}
\section{Product in \SSS}
The product of two matrices given in \SSS form uses two tricks we have seen previously.
The first one is to start by computing an \((s, 2s)\)-\SSS representation before
compression,
as in the sum.
Unlike the sum, computations are needed in addition to concatenation to get this
representation.
The second trick is to speed up these computations by using a Horner-like accumulation
as in \algoName{algo:LowSSSxDense}.
This accumulation will be done on both sides for the computation of all necessary
products \(A_{i,k}B_{k,j}\) where \(A_{i,k}\) is under (resp. over) the diagonal and
\(B_{k,j}\) is over (resp. under) it.
\algoName{algo:SSSxSSS} details these computations, using the \Gi i and \Hi i as accumulators.
It presents an improvement over the algorithm of
\cite[\S 3]{CDGPV03} and \cite[Alg. 7.2]{EG05bsss}:
4 products have been avoided at each step by keeping them in memory in the
\(T_i\) and \(S_i\).
They can also be avoided in the numerical context.
\begin{algorithm}[htb]
\algoCaptionLabel{SSSxSSS}{}
\begin{algorithmic}[1]
\algrenewcommand{\algorithmicensure}{\emph{InOut:}}
\Require{For both \(M \in \{A, B\}\),
\(\Tag PM_i,\Tag QM_i,\Tag RM_i,\Tag UM_i,\Tag VM_i,\Tag WM_i\), \(\Tag DM_i\) for appropriate \(i \in \intset{1,N}\)
an \(s\)-\SSS generator for \(M\)}
\Ensure
A \(2s\)-\SSS generator for \(C = AB\)}
\Statex \CommentLine{\it All values not given as input are initialised to 0}
\For {\(i \gets 1\dots N\)}
\State \(\Gi{i} \gets \Tag QA_{i - 1} \Tag UB_{i - 1} + T_{i - 1} \Tag WB_{i - 1}\) \label{step:gi}
\State\( T_i \gets \Tag RA_{i} \Gi{i}\) \label{step:si}
\State\( S_i \gets \Tag PA_{i} \Gi{i}\) \label{step:ti}
\State \( Q_i \gets \begin{bmatrix}
\Tag QB_{i}\\
\Tag QA_{i} \Tag DB_{i} + T_i\Tag VB_{i}
\end{bmatrix}\)
\State \( R_i \gets \begin{bmatrix}
\Tag RB_{i} & 0 \\
\Tag QA_{i}\Tag PB_i & \Tag RA_i
\end{bmatrix}\)
\State \( U_i \gets \begin{bmatrix}
\Tag UA_{i} & \Tag DA_{i} \Tag UB_{i} + S_i\Tag WB_{i}
\end{bmatrix} \)
\State \( W_i \gets \begin{bmatrix}
\Tag WA_{i} & \Tag VA_{i}\Tag UB_i \\
0 & \Tag WB_i
\end{bmatrix}\)
\EndFor
\For {\(i \gets N \dots 1\)}
\State \(\Hi{i} \gets \Tag VA_{i + 1} \Tag PB_{i + 1} + T_{i + 1} \Tag RB_{i + 1}\) \label{step:hi}
\State \(T_i \gets \Tag UA_{i}\Hi{i}\) \label{step:tit}
\State \( D_i \gets \Tag DA_i \Tag DB_i + S_{i}\Tag VB_{i} + T_i\Tag QB_{i}\) \label{step:xdi}
\State \( P^{C}_i \gets \begin{bmatrix}
\Tag DA_{i} \Tag PB_{i} + T_{i}\Tag RB_{i} & \Tag PA_{i}
\end{bmatrix} \)
\State \(T_i \gets \Tag WA_{i}\Hi{i}\)\label{step:tim}
\State \( V_i \gets \begin{bmatrix}
\Tag VA_{i} \Tag DB_{i} + T_i\Tag QB_{i} \\
\Tag VB_{i}
\end{bmatrix}\)
\EndFor
\State \Return \(\Call{algo:SssCompression}{ \paren{P_i, Q_i, R_i, U_i, V_i, W_i, D_i}_{i\in\intset{1,N}}}\)
\end{algorithmic}
\end{algorithm}
\begin{theorem}
\label{prop:sxs}
\algoName{algo:SSSxSSS} computes a \(2s\)-\SSS generator for the product of
two \(n \times n\) matrices given in \(s\)-\SSS form in
\begin{equation}
\Time{SSSxSSS}(n,s)=\paren{31 + 2^\omega}C_\omega ns^{\omega-1}.\end{equation}
\end{theorem}
\begin{proof}
Using Lines \ref{step:gi} and \ref{step:ti} for \(\Gi i\) and Lines \ref{step:hi} and
\ref{step:tim} for \Hi i, induction on \(i\) shows that
\begin{equation}
\Gi i =
\sum_{k = 1}^{i - 1} \Tag RA_{i - 1} \hdots \Tag RA_{k + 1} \Tag QA_k \Tag UB_k \Tag WB_{k + 1} \hdots \Tag WB_{i - 1}
\end{equation}
\begin{equation}
\Hi i =
\sum_{k = i +1}^{N} \Tag WA_{i + 1} \hdots \Tag WA_{k - 1} \Tag VA_k \Tag PB_k \Tag RB_{k - 1} \hdots \Tag RB_{i + 1}
\end{equation}
Combining these results with \cref{step:si} for \(S_i\), \cref{step:tit} for \(T_i\) and
finally \cref{step:xdi}, we get that
\( \Tag DC_i = \sum_{k = 1}^N A_{i,k}B_{k,i} = C_{i,i}\).
When \( i < j\), the products \(A_{i,k}B_{k,j}\) take five shapes: lower block of \(A\)
\(\times\) upper block of \(B\), diagonal block \(\times\) upper block,
upper \(\times\) upper, upper \(\times\) diagonal and upper \(\times\) lower.
The equality
\begin{align}
\Tag UC_i \Tag WC_{i + 1} \dots \Tag WC_{j - 1} \Tag VC_j = \sum_{k = 1}^N A_{i,k}B_{k,j}
\end{align}
and its
counterpart when \(i > j\) can be checked with tedious but straightforward calculations.
The cost is that of 21 products and 8 sums of \(s \times s\) matrices at each of the
\(N\) steps and on call to \algoName{algo:SssCompression}.
\end{proof}
Again the result of \cref{prop:sxs} is limited to matrices defined on the same grid
and the result always has the same storage size, whatever its quasi-separability order.
This is also true for product with \HSS generators in numerical analysis \cite{SDC07}.
The \Bruhat format can avoid these issues, but to our knowledge no sub-quadratic algorithm exists
for the product of two \Bruhat generators.
The method used for the sum in \cref{sec:bsum} opens the door towards a linear or quasi-linear product algorithm
using \algoName{algo:LBruhatGen}.
| {'timestamp': '2023-02-10T02:09:01', 'yymm': '2302', 'arxiv_id': '2302.04515', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04515'} | arxiv |
\section{Introduction}
\label{submission}
The field of neural architecture search (NAS) emerged about a decade ago as an effort to automatise the process of neural geometry optimisation. At the early stages of NAS development, every candidate architecture used to be evaluated through the training process (reinforcement learning \citep{williams1992simple}, evolutionary algorithms \citep{real2019regularized}, Bayesian optimisation \citep{falkner2018bohb, white2021bananas}).
One-shot algorithms adopting weight sharing dispense of multiple architectures training, reducing the search time drastically (efficient reinforcement learning \citep{pham2018efficient}, random search with parameters sharing\citep{li2020random}, differentiable methods). Nevertheless, they require the training of a massive hypernet, which necessitates elaborate hyperparameter tuning. While these methods prove efficient, they do not systematically achieve satisfactory results \citep{dong2019searching}. One of the best of them, DARTS- \citep{chu2020darts}, shows significant uncertainty compared to evolutionary or reinforcement algorithms.
There are available methods that estimate network performance without training the dataset of interest but relying on an auxiliary predictive machine learning (ML) model built on a dataset of trained architectures \citep{istrate2019tapas,deng2017peephole}. These methods aim to accelerate the NAS process for image recognition but still rely on training and cannot apply to other ML problems.
Evaluating geometries through training brings multiple disadvantages. The most obvious is that training is a computationally expensive procedure, and large-scale geometry evaluation often cannot be carried out on massive datasets. Consequently, architectures are usually trained with a single random seed and a fixed set of hyperparameters. This fact raises the question of whether the chosen architecture is statistically reliable and might lead to selecting a sub-optimal model, optimal only in the context of the fixed set of hyperparameters. Training also implies using hand-labelled data, which brings in human error -- ImageNet dataset, for instance, is known to have a label error of about $6$\,$\rm\%$ \citep{northcutt2021pervasive}. Importantly, from the fundamental point of view, the above NAS methods do not explain why a given architecture is selected.
\subsection{Zero-cost NAS}
To alleviate the process of architecture search, many researchers focus on developing methods that allow finding optimal architectures without model training -- so-called zero-cost NAS methods. These methods evaluate networks via some trainless metric. They typically require the equivalent of one or a few training epochs, which is two to three orders of magnitude faster than other NAS methods.
\begin{description}[style=unboxed,leftmargin=0cm]
\item[Weight agnostic neural networks.]
One of the pioneering works in zero-shot NAS is presented by \citet{gaier2019weight}. They demonstrate a constructor that builds up neural architectures based on the mean accuracy over several initialisations with constant shared weights and the number of parameters contained within the model. The resulting model achieves over $90\%$ accuracy on MNIST data \citep{lecun2010mnist} when the weights are fixed to the best-performing constants. While these results are very intriguing, the authors admit that such architectures do not perform particularly well upon training. Moreover, back in $2019$, the benchmark databases of trained architectures, which are now routinely used to compare NAS metrics with each other, were yet to be released, which disables the comparison of this zero-shot method against the most recent ones.
\item[Jacobian covariance.]
In $2020$, \citet{mellor2020neural} present the \texttt{naswot} metric, which exploits the rectified linear unit (ReLU, \citet{agarap2018deep}) activation function's property to yield distinct activation patterns for different architectures. Concretely, every image yields a binary activation vector upon passing through a network, forming a binary matrix for a mini-batch. The logarithm of the determinant of this matrix serves as a scoring metric. Authors show that larger \texttt{naswot} values are associated with better training performances, which leads to the conclusion that high-performing networks should be able to distinguish the inputs before training. Unfortunately, the method can only be implemented on networks with ReLU activation functions, which limits its applicability to convolutional architectures. In the first version of the paper released in June 2020, the authors presented another scoring method using Jacobian covariance (\texttt{jacov}) and achieved significantly different performances. Following \citet{abdelfattah2021zero}, we compare our results against \texttt{jacov} as well.
Another work employing the abovementioned ReLU property is \citet{chen2021neural}. They combine the number of linear regions in the input space with the spectrum of the neural tangent kernel (NTK) to build the \texttt{tenas} metric. Instead of evaluating each network in the search space individually, they create a super-network built with all the available edges and operators and then prune it.
\item[Coefficient of variance.]
Another early work on fully trainless NAS belongs to \citet{gracheva2021trainless}, which evaluates the stability of untrained scores over random weights initialisations. The author initialises the networks with multiple random seeds, and architectures are selected based on the coefficient of variance of the accuracy at initialisation, \texttt{CV}. While \texttt{CV} performance is associated with a high error rate, the author concludes that a good architecture should be stable against random weight fluctuations. While this method can, in theory, apply to any neural architecture type, it requires multiple initialisations and is relatively heavy compared to \texttt{naswot} and later methods. Furthermore, accuracy-based scoring metrics can only apply to classification problems, and it is unclear how to extend \texttt{CV} implementation to the regression tasks.
\item[Gradient sign.] The \texttt{grad\_sign} metric is built to approximate the sample-wise optimisation landscape \citep{zhang2021gradsign}. The authors argue that the closer local minima for various samples sit to each other, the higher the probability that the corresponding gradients will have the same sign. The number of samples yielding the same gradient sign approximates this probability. It allows to evaluate the smoothness of the optimisation landscape and architecture trainability. The method requires labels and gradient computation.
\item[Pruning-at-initialisation proxies.]
Several powerful zero-cost proxies have emerged as an adaptation of pruning-at-initialisation methods to NAS in the work by \citet{abdelfattah2021zero}: \texttt{grad\_norm} \citep{wang2020picking}, \texttt{snip} \citep{lee2018snip}, \texttt{synflow} \citep{tanaka2020pruning}. These metrics are originally developed to evaluate the network's parameters' salience and prune away potentially meaningless synapses. They require a single forward-backwards pass to compute the loss. Then, the importance of parameters is computed as a multiplication of the weight value and gradient value. \citet{abdelfattah2021zero} integrate the salience over all the parameters in the network to evaluate its potential upon training. What is particularly interesting about the \texttt{synflow} metric is that it evaluates the architectures without looking at the data by computing the loss as the product of all the weights' values (randomly initialised). \texttt{synflow} metric shows the most consistent performance among various search spaces and sets the state-of-the-art for the zero-cost NAS.
\end{description}
Both \texttt{naswot} and \texttt{synflow} do not depend on labels, which arguably reduces the effect of human error during data labelling. Moreover, \texttt{naswot} does not require gradient computation, which renders this method less memory-intensive.
The above results imply that neural networks might have some intrinsic property which defines their prediction potential before training. Such property should not depend on the values of trainable parameters (weights) but only on the network's topology. In the present work, we combine the takeaways from the existing trainless NAS implementations to present a new metric which significantly outperforms existing zero-cost NAS methods.
\subsection{NAS benchmarks}
To guarantee our metric's reproducibility and compare its performance against other NAS algorithms, we evaluate it on the three widely used NAS benchmark datasets.
\begin{description}[style=unboxed,leftmargin=0cm]
\item[NAS-Bench-101] The first and one of the largest NAS benchmark sets of trained architectures. It consists of $423{,}624$ cell-based convolutional neural networks \citep{ying2019bench}. The architectures consist of three stacks of cells, each followed by max-pooling layers. Cells may have up to $7$ vertices and $9$ edges, with $3$ possible operations. This benchmark is trained multiple times on a single dataset, \mbox{CIFAR-10} \citep{krizhevsky2009learning}, with a fixed set of hyperparameters for $108$ epochs.
\item[NAS-Bench-201] It is a set of architectures with a fixed skeleton consisting of a convolution layer and three stacks of cells connected by a residual block \citep{dong2020bench}. Each cell is a densely connected directed acyclic graph with $4$ nodes, $5$ possible operations and no limits on the number of edges, providing a total of $15{,}625$ possible architectures. Architectures are trained on three major datasets: \mbox{CIFAR-10}, \mbox{CIFAR-100} \citep{krizhevsky2009learning} and a downsampled version of ImageNet \citep{chrabaszcz2017downsampled}. Training hyperparameters are fixed, and the training spans $200$ epochs.
\item[NAS-Bench-NLP] As the name suggests, this benchmark consists of architectures suitable for neural language processing \citep{klyuchnikov2022bench}. Concretely, it consists of randomly-generated recurrent neural networks. Recurrent cells comprise $24$ nodes, $3$ hidden states and $3$ input vectors at most, with $7$ allowed operations. Here, we only consider models trained and evaluated on Penn Treebank (PTB, \citet{marcinkiewicz1994building}) dataset: $14{,}322$ random networks with a single seed and $4{,}114$ with tree seeds. The training spans $50$ epochs and is conducted with fixed hyperparameters.
\end{description}
\section{Epsilon metric}
Two existing NAS methods inspire the metric that we share in the present work: \texttt{CV} \citep{gracheva2021trainless} and weight agnostic neural networks \citep{gaier2019weight}. Both metrics aim to exclude individual weight values from consideration when evaluating networks: the former cancels out the individual weights via multiple random initialisations, while the latter sets them to the same value across the network. It is very intriguing to see that an network can be characterised purely by its topology.
As mentioned above, the \texttt{CV} metric has two principal disadvantages. While it shows a fairly consistent trend with trained accuracy, it suffers from high uncertainty. It can be, to some degree, explained by the fact that random weight initialisations bring in some noise. Our idea is that replacing random initialisations with single shared weight initialisations, similarly to \citet{gaier2019weight}, should improve the method's performance.
The second weak point is that \texttt{CV} is developed for classification problems and relies on accuracy. Therefore, it needs to be clarified how to apply this metric to regression problems. The coefficient of variation is a ratio of standard deviation to mean, and \citet{gracheva2021trainless} shows that \texttt{CV} correlates negatively with train accuracy. It implies that the mean untrained accuracy should be maximised. On the other hand, for regression tasks, performance is typically computed as some error, which is sought to be minimised. It is not apparent whether the division by mean untrained \textit{error} would result in the same trend for \texttt{CV} metric.
To address this issue, we decided to consider raw outputs. This modification renders the method applicable to any neural architecture. However, it comes with a difference: accuracy returns a single value per batch of data, while raw outputs are $[N_{\textrm{BS}} \times L]$ matrices, where $N_{\rm{BS}}$ is the batch size and $L$ is the length of a single output.\footnote{This length depends on the task and architecture: for regression tasks $L=1$, for classification, $L$ is equal to the number of classes, and for recurrent networks, it depends on the desired length of generated string.} In our work, we flatten these matrices to obtain a single vector $\mathbf{v}$ of length $L_{v}=N_{\textrm{BS}} \times L$ per initialisation. We then stuck both initialisations into a single output matrix $\mathbf{V}$.
Before proceeding to statistics computation over initialisations, we also must normalise the output vectors: in the case of constant shared weights, outputs scale with weight values. In order to compare initialisations on par with each other, we use min-max normalisation:
\begin{equation}
\mathbf{V}_{i}^\prime=\frac{\mathbf{V}_{i}-\min(\mathbf{V}_{i})}{\max(\mathbf{V}_{i})-\min(\mathbf{V}_{i})},
\label{eqn:minmax}
\end{equation}
where $i$ is the index for initialisations, $i=\{0,1\}$.
We noticed that two distinct weights are sufficient to grasp the difference between initialisations. Accordingly, instead of standard deviation, we use mean absolute error between the normalised outputs of two initialisations:
\begin{equation}
\delta = \frac{1}{L_{v}} \sum\limits_{j=0}^{L_{v}}\lvert \mathbf{V}_{1,j}^\prime - \mathbf{V}_{2,j}^\prime\rvert.
\label{eqn:delta}
\end{equation}
The mean is computed over the outputs of both initialisations as follows:
\begin{equation}
\mu = \frac{1}{L_{v}} \sum\limits_{j=0}^{L_{v}} \frac{\mathbf{V}_{1,j}^\prime + \mathbf{V}_{2,j}^\prime}{2}
= \frac{1}{2L_{v}} \sum\limits_{i=0}^{2} \sum\limits_{j=0}^{L_{v}}\mathbf{V}_{i,j}^\prime
\label{eqn:mean}
\end{equation}
Finally, the metric is computed as the ratio of $\delta$ and $\mu$:
\begin{equation}
\varepsilon = \frac{\delta}{\mu}.
\label{eqn:epsilon}
\end{equation}
We refer to our metric as \texttt{epsilon}, as a tribute to the $\varepsilon$ symbol used in mathematics to denote error bounds. Algorithm \ref{algo} details the \texttt{epsilon} metric computation.
\begin{algorithm}[tb]
\caption{Algorithm for \texttt{epsilon} metric computation}
\label{algo}
\begin{algorithmic}
\STATE Select a \texttt{batch} of data from train set
\FOR{\texttt{arch} in \texttt{search space}}
\STATE Initialise empty output \texttt{matrix}
\FOR{\texttt{weight} in [\texttt{val1}, \texttt{val2}]}
\STATE Initialise \texttt{arch} with constant shared \texttt{weight}
\STATE Forward pass the \texttt{batch} through \texttt{arch}
\STATE Get and flatten \texttt{outputs}
\STATE Minmax normalise \texttt{outputs} (Eq. \ref{eqn:minmax})
\STATE Append \texttt{outputs} to the output \texttt{matrix}
\ENDFOR
\STATE Compute difference between the rows of the output \texttt{matrix} (Eq. \ref{eqn:delta})
\STATE Compute mean over the output \texttt{matrix} (Eq. \ref{eqn:mean})
\STATE Compute \texttt{epsilon} metric (Equation \ref{eqn:epsilon})
\ENDFOR
\end{algorithmic}
\end{algorithm}
\section{Results}
\subsection{Empirical evaluation}
Here we evaluate the performance of \texttt{epsilon} and compare it to the results for zero-cost NAS metrics reported in \citet{abdelfattah2021zero}. We use the following evaluation scores (computed with \texttt{NaN} omitted):
\begin{itemize}
\itemsep-0.2em
\item Spearman $\rho$ (global): Spearman rank correlation $\rho$ evaluated on the entire dataset.
\item Spearman $\rho$ (top-$10\%$):
Spearman rank correlation $\rho$ for the top-$10\%$ performing architectures.
\item Kendall $\tau$ (global): Kendall rank correlation coefficient $\tau$ evaluated on the entire dataset.
\item Kendall $\tau$ (top-$10\%$): Kendall rank correlation coefficient $\tau$ for the top-$10\%$ performing architectures.
\item Top-$10\%$/top-$10\%$: fraction of top-$10\%$ performing models within the top-$10\%$ models ranked by zero-cost scoring metric ($\%$).
\item Top-64/top-$10\%$: number of top-64 models ranked by zero-cost scoring metric within top-$5\%$ performing models.
\end{itemize}
\subsubsection{NAS-Bench-201}
The results for overall \texttt{epsilon} performance on NAS-Bench-201 are given in Table \ref{tab:results_201} along with other zero-cost NAS metrics. The Kendall $\tau$ score is not reported in \citet{abdelfattah2021zero}, but it is considered more robust than Spearman $\rho$ and is increasingly used for NAS metric evaluation. We use the data provided by \citet{abdelfattah2021zero} to evaluate their Kendal $\tau$. Note that our results differ from the original paper for some evaluation scores. In such cases, we indicate the original values between brackets. In particular, there is a discrepancy in computing the values in the last column, \textit{Top-64/top-$5\%$}, while the rest of the results are consistent. Figure \ref{fig:other_results_201} in Appendix suggests that our calculations are correct.
\begin{table*}[!t]
\caption{Zero-cost metrics performance for the NAS-Bench-201 search space with its three datasets: CIFAR-10, CIFAR-100 and ImageNet16-120. We give the original values from \citet{abdelfattah2021zero} for reference between brackets. We highlight the best-performing metrics in bold.}
\label{tab:results_201}
\begin{center}
\small
\resizebox{0.9\textwidth}{!} {
\begin{tabular}{lrrrrp{0.1mm}rrrrrr}
\toprule
\noalign{\vskip 1 pt}
\multirow{2}{*}{Metric} & \multicolumn{4}{c}{Spearman $\rho$} & & \multicolumn{2}{c}{Kendall $\tau$} & \multicolumn{2}{c}{Top-10\%/} & \multicolumn{2}{c}{Top-64/} \\
\cline{2-5}\cline{7-8}
\noalign{\vskip 1.5pt}
& \multicolumn{2}{c}{global} & \multicolumn{2}{c}{top-10\%} & & \multicolumn{1}{c}{global} & \multicolumn{1}{c}{top-10\%} & \multicolumn{2}{c}{top-10\%}& \multicolumn{2}{c}{top-5\%} \\
\midrule
\noalign{\vskip 1pt}
\multicolumn{12}{c}{CIFAR-10}\\
\midrule
\noalign{\vskip 1pt}
\texttt{grad\_sign} & 0.77 & & & & & & & & & & \\
\texttt{synflow} & 0.74 & & 0.18 & & & 0.54 & 0.12 & 45.75 & (46) & 29 & (44) \\
\texttt{grad\_norm} & 0.59 & (0.58) & -0.36 & (-0.38) & & 0.43 & -0.21 & 30.26 & (30) & 1 & (0) \\
\texttt{grasp} & 0.51 & (0.48) & -0.35 & (-0.37) & & 0.36 & -0.21 & 30.77 & (30) & 3 & (0) \\
\texttt{snip} & 0.60 & (0.58) & -0.36 & (-0.38) & & 0.44 & -0.21 & 30.65 & (31) & 1 & (0) \\
\texttt{fisher} & 0.36 & & -0.38 & & & 0.26 & -0.24 & 4.99 & ( 5) & 0 & (0) \\
\texttt{jacov} & -0.73 & (0.73) & 0.15 & (0.17) & & 0.55 & -0.10 & 24.72 & (25) & 11 & (15) \\
\texttt{epsilon} & \pmb{0.87} & & \pmb{0.55} & & & \pmb{0.70} & \pmb{0.40} & \pmb{67.39} & & \pmb{59} & \\
\midrule
\noalign{\vskip 1pt}
\multicolumn{12}{c}{CIFAR-100}\\
\midrule
\texttt{grad\_sign} & 0.79 & & & & & & & & & & \\
\texttt{synflow} & 0.76 & & 0.42 & & & 0.57 & 0.29 & 49.71 & (50) & 45 & (54) \\
\texttt{grad\_norm} & 0.64 & & -0.09 & & & 0.47 & -0.05 & 35.00 & (35) & 0 & (4) \\
\texttt{grasp} & 0.55 & (0.54) & -0.10 & (-0.11) & & 0.39 & -0.06 & 35.32 & (34) & 3 & (4) \\
\texttt{snip} & 0.64 & (0.63) & -0.08 & (-0.09) & & 0.47 & -0.05 & 35.25 & (36) & 0 & (4) \\
\texttt{fisher} & 0.39 & & -0.15 & (-0.16) & & 0.28 & -0.10 & 4.22 & ( 4) & 0 & (0) \\
\texttt{jacov} & -0.70 & (0.71) & 0.07 & (0.08) & & 0.54 & 0.05 & 22.11 & (24) & 7 & (15) \\
\texttt{epsilon} & \pmb{0.90} & & \pmb{0.59} & & & \pmb{0.72} & \pmb{0.43} & \pmb{81.24} & & \pmb{62} & \\
\noalign{\vskip 1pt}
\midrule
\multicolumn{12}{c}{ImageNet16-120}\\
\midrule
\texttt{grad\_sign} & 0.78 & & & & & & & & & & \\
\texttt{synflow} & 0.75 & & \pmb{0.55} & & & 0.56 & \pmb{0.39} & 43.57 & (44) & 26 & (56) \\
\texttt{grad\_norm} & 0.58 & & 0.12 & (0.13) & & 0.43 & 0.09 & 31.29 & (31) & 0 & (13) \\
\texttt{grasp} & 0.55 & (0.56) & 0.10 & & & 0.39 & 0.07 & 31.61 & (32) & 2 & (14) \\
\texttt{snip} & 0.58 & & 0.13 & & & 0.43 & 0.09 & 31.16 & (31) & 0 & (13) \\
\texttt{fisher} & 0.33 & & 0.02 & & & 0.25 & 0.01 & 4.61 & ( 5) & 0 & (0) \\
\texttt{jacov} & 0.70 & (0.71) & 0.08 & (0.05) & & 0.53 & 0.05 & 29.63 & (44) & 10 & (15) \\
\texttt{epsilon} & \pmb{0.85} & & 0.53 & & & \pmb{0.67} & 0.37 & \pmb{71.51} & & \pmb{59} & \\
\bottomrule
\end{tabular}
}
\end{center}
\end{table*}
For NAS-Bench-201, we also report average performance when selecting one architecture from a pool of $N$ random architectures. The statistics are reported over $500$ runs. Table \ref{tab:avrg_performance} compares \texttt{epsilon} to other trainless metrics. Note that \texttt{te-nas} starts with a super-network composed of all the edges and operators available within the space. In this case, $N$ is not applicable, and the performance can not be improved. In principle, other methods' performance should improve with higher $N$ values.
\begin{table*}[!t]
\caption{Comparison of the trainless metrics performances against existing NAS algorithms on CIFAR-10, CIFAR-100 and ImageNet16-120 datasets. On the top, we list the best-performing methods that require training (REA \cite{real2019regularized}, random search, REINFORCE \cite{williams1992simple}, BOHB \cite{falkner2018bohb}). We report the average best-achieved test accuracy over $500$ runs, with $1{,}000$ architectures ($100$ for \texttt{grad\_sign})sampled from the search space at random. For \texttt{tenas}, the results are reported for $4$ random seeds. Random and optimal performances are given as baseline.}
\vspace{5pt}
\label{tab:avrg_performance}
\centering
\setlength{\tabcolsep}{3pt}
\renewcommand{\arraystretch}{1.2}
\resizebox{\textwidth}{!} {
\begin{tabular}{lllp{0.01\textwidth}llp{0.01\textwidth}ll}
\hline
\multirow{2}{*}{Method} & \multicolumn{2}{l}{CIFAR-10} & \multirow{2}{*}{} & \multicolumn{2}{l}{CIFAR-100} & \multirow{2}{*}{} & \multicolumn{2}{l}{ImageNet16-120} \\
\cline{2-3}\cline{5-6}\cline{8-9}
& validation & test & & validation & test & & validation & test \\
\hline
\multicolumn{9}{c}{State-of-the-art}\\
REA & $91.19 \pm 0.31$ & $93.92 \pm 0.3$ & & $71.81 \pm 1.12$ & $71.84 \pm 0.99$ & & $45.15 \pm 0.89$ & $45.54 \pm 1.03$ \\
Random Search & $90.93 \pm 0.36$ & $93.92 \pm 0.31$ & & $70.93 \pm 1.09$ & $71.04 \pm 1.07$ & & $44.45 \pm 1.1$ & $44.57 \pm 1.25$ \\
REINFORCE & $91.09 \pm 0.37$ & $93.92 \pm 0.32$ & & $71.61 \pm 1.12$ & $71.71 \pm 1.09$ & & $45.05 \pm 1.02$ & $45.24 \pm 1.18$ \\
BOHB & $90.82 \pm 0.53$ & $93.92 \pm 0.33$ & & $70.74 \pm 1.29$ & $70.85 \pm 1.28$ & & $44.26 \pm 1.36$ & $44.42 \pm 1.49$ \\
\hline
\multicolumn{9}{c}{Baselines (N=1000)}\\
Optimal & $91.34 \pm 0.18$ & $94.20 \pm 0.13$ & & $72.53 \pm 0.53$ & $72.84 \pm 0.41$ & & $45.93 \pm 0.51$ & $46.59 \pm 0.34$ \\
Random & $84.11 \pm 11.71$ & $87.40 \pm 11.94$ & & $61.57 \pm 11.305$ & $61.67 \pm 11.35$ & & $33.97 \pm 8.68$ & $33.67 \pm 8.98$ \\
\hline
\multicolumn{9}{c}{Trainless (N=1000)}\\
\texttt{naswot} & $89.69 \pm 0.73$ & $92.96 \pm 0.81$ & & $69.86 \pm 1.21$ & $69.98 \pm 1.22$ & & $43.95 \pm 2.05$ & $44.44 \pm 2.10$ \\
\texttt{synflow} & $89.91 \pm 0.83$ & $90.12 \pm 0.78$ & & $70.35 \pm 2.25$ & $70.37 \pm 2.08$ & & $41.73 \pm 3.91$ & $42.11 \pm 4.02$ \\
\texttt{grad\_norm} & $88.13 \pm 2.35$ & $88.42 \pm 2.28$ & & $66.35 \pm 5.45$ & $66.48 \pm 5.32$ & & $33.88 \pm 11.46$ & $33.90 \pm 11.74$ \\
\texttt{grasp} & $87.85 \pm 2.12$ & $88.17 \pm 2.04$ & & $65.36 \pm 5.57$ & $65.45 \pm 5.48$ & & $32.23 \pm 10.95$ & $32.20 \pm 11.23$ \\
\texttt{snip} & $87.47 \pm 2.19$ & $87.81 \pm 2.12$ & & $64.61 \pm 5.52$ & $64.74 \pm 5.43$ & & $30.65 \pm 11.32$ & $30.55 \pm 11.55$ \\
\texttt{fisher} & $87.01 \pm 2.31$ & $87.36 \pm 2.23$ & & $63.54 \pm 5.69$ & $63.67 \pm 5.62$ & & $26.70 \pm 10.83$ & $29.56 \pm 10.83$ \\
\texttt{jacov} & $88.17 \pm 1.67$ & $88.45 \pm 1.69$ & & $67.73 \pm 2.69$ & $67.90 \pm 2.77$ & & $31.58 \pm 10.65$ & $31.44 \pm 10.83$ \\
\texttt{epsilon} & $\pmb{91.03} \pm \pmb{0.42}$ & $\pmb{93.86} \pm \pmb{0.43}$ & & $\pmb{71.76} \pm \pmb{0.90}$ & $\pmb{71.79} \pm \pmb{0.86}$ & & $\pmb{45.11} \pm \pmb{0.99}$ & $\pmb{45.42} \pm \pmb{1.21}$ \\
\hline
\multicolumn{9}{c}{Trainless (N=100)}\\
\texttt{grad\_sign} & $89.84 \pm 0.61$ & $93.31 \pm 0.47$ & & $70.22 \pm 1.32$ & $70.33 \pm 1.28$ & & $42.07 \pm 2.78$ & $42.42 \pm 2.81$ \\
\texttt{epsilon} & $\pmb{90.44} \pm \pmb{0.97}$ & $\pmb{93.39} \pm \pmb{0.82}$ & & $\pmb{70.85} \pm \pmb{1.30}$ & $\pmb{71.00} \pm \pmb{1.26}$ & & $\pmb{44.03} \pm \pmb{2.02}$ & $\pmb{44.20} \pm \pmb{2.04}$ \\
\hline
\multicolumn{9}{c}{Trainless (N/A)}\\
\texttt{tenas} & & $93.9 \pm 0.47$ & & & $71.24 \pm 0.56$ & & & $42.38 \pm 0.46$ \\
\hline
\end{tabular}
}
\end{table*}
Comparing the results for \texttt{epsilon} with other zero-cost NAS metrics, we can see that it outperforms them by a good margin. Figure \ref{fig:results_201} further confirms the applicability of the method to the NAS-Bench-201 field (similar figures for other methods can be found in Appendix, Figure \ref{fig:other_results_201}). However, NAS-Bench-201 is a relatively compact search space; furthermore, it has been used for \texttt{epsilon} development.
\begin{figure*}[!t]
\centering
\resizebox{\textwidth}{!}{%
\includegraphics[height=3cm]{figures/results/NAS-Bench-201/epsilon_CIFAR10.png}\hfill
\includegraphics[height=3cm]{figures/results/NAS-Bench-201/epsilon_CIFAR100.png}\hfill
\includegraphics[height=3cm]{figures/results/NAS-Bench-201/epsilon_IMAGENET.png}
}
\caption{Zero-cost NAS \texttt{epsilon} metric performance illustration for NAS-Bench-201 search space evaluated on CIFAR-10, CIFAR-100 and ImageNet16-120 datasets. The horizontal axis shows test accuracy upon training. Each dot corresponds to an architecture; the darker the colour, the more
parameters it contains. The figure represents the search space of $15{,}625$ networks (excluding architectures with \texttt{NaN} scores).}
\label{fig:results_201}
\end{figure*}
\subsubsection{NAS-Bench-101}
We use NAS-Bench-101 space to confirm that the success of \texttt{epsilon} metric in the previous section is not due to overfitting the NAS-Bench-201 search space and to see how it applies to a vaster search space. Table \ref{tab:results_101} together with Figure \ref{fig:results_101} confirm that it performs reasonably well on NAS-Bench-101, too.
\begin{table*}[!t]
\caption{Zero-cost metrics performance evaluated on NAS-Bench-101 search space, CIFAR-10 dataset. Values from \citet{abdelfattah2021zero} are given for reference between brackets. We highlight the best-performing metrics in bold.}
\label{tab:results_101}
\begin{center}
\small
\resizebox{0.9\textwidth}{!} {
\begin{tabular}{lrrrrp{0.1mm}rrrrrr}
\toprule
\noalign{\vskip 1 pt}
\multirow{2}{*}{Metric} & \multicolumn{4}{c}{Spearman $\rho$} & & \multicolumn{2}{c}{Kendall $\tau$} & \multicolumn{2}{c}{Top-10\%/} & \multicolumn{2}{c}{Top-64/} \\
\cline{2-5}\cline{7-8}
\noalign{\vskip 1.5pt}
& \multicolumn{2}{c}{global} & \multicolumn{2}{c}{top-10\%} & & \multicolumn{1}{c}{global} & \multicolumn{1}{c}{top-10\%} & \multicolumn{2}{c}{top-10\%}& \multicolumn{2}{c}{top-5\%} \\
\midrule
\noalign{\vskip 1pt}
\multicolumn{12}{c}{CIFAR-10}\\
\midrule
\noalign{\vskip 1pt}
\texttt{grad\_sign} & 0.45 & & & & & & & & & & \\
\texttt{synflow} & 0.37 & & \pmb{0.14} & & & 0.25 & \pmb{0.10} & 22.67 & 23 & 4 & (12) \\
\texttt{grad\_norm} & -0.20 & & -0.05 & (0.05) & & -0.14 & -0.03 & 1.98 & 2 & 0 & (0) \\
\texttt{grasp} & 0.45 & & -0.01 & & & 0.31 & -0.01 & 25.60 & 26 & 0 & (6) \\
\texttt{snip} & -0.16 & & 0.01 & (-0.01) & & -0.11 & 0.00 & 3.43 & 3 & 0 & (0) \\
\texttt{fisher} & -0.26 & & -0.07 & (0.07) & & -0.18 & -0.05 & 2.65 & 3 & 0 & (0) \\
\texttt{jacov} & 0.38 & (0.38) & -0.08 & (0.08) & & -0.05 & 0.05 & 1.66 & 2 & 0 & (0) \\
\texttt{epsilon} & \pmb{0.62} & & 0.12 & & & \pmb{0.44} & 0.08 & \pmb{40.33} & & \pmb{10} & \\
\bottomrule
\end{tabular}
}
\end{center}
\end{table*}
\begin{figure*}[!t]
\begin{center}
\resizebox{0.7\textwidth}{!}{
\includegraphics[height=3.5cm]{figures/results/NAS-Bench-101/epsilon_CIFAR10_101.png}\hfill
\includegraphics[height=3.5cm]{figures/results/NAS-Bench-NLP/epsilon_NLP.png}
}
\caption{Zero-cost NAS \texttt{epsilon} metric performance illustration for NAS-Bench-101 search space, CIFAR-10 dataset and NAS-Bench-NLP search space, PTB dataset. The horizontal axis shows test accuracy upon training. Each dot corresponds to an architecture; the darker the colour, the more parameters it contains. The figure shows $423{,}624$ and $14{,}322$ networks for NAS-Bench-101 and NAS-Bench-NLP, respectively (excluding architectures with \texttt{NaN} scores).}
\label{fig:results_101}
\end{center}
\vspace{-10pt}
\end{figure*}
\subsubsection{NAS-Bench-NLP}
Both NAS-Bench-201 and NAS-Bench-101 are created to facilitate NAS in image recognition. They operate convolutional networks of very similar constitutions. To truly probe the generalisability of the \texttt{epsilon} metric, we test it on NAS-Bench-NLP. Both input data format and architecture type differ from the first two search spaces.
Unfortunately, \citet{abdelfattah2021zero} provides no data for NAS-Bench-NLP, disabling us from using their results for calculations. Therefore, in Table \ref{tab:results_nlp}, we give only values provided in the paper together with our \texttt{epsilon} metric (data for \texttt{ficher} is absent). We want to note that, unlike accuracy, perplexity used for language-related ML problems should be minimised. Therefore, the signs of correlations with scoring metrics should be reversed, which is not the case for numbers given in \citet{abdelfattah2021zero}.
The performance of \texttt{epsilon} metric on the NAS-Bench-NLP space is not exceptional. While there is a trend towards better architectures with increasing metric value, the noise level is beyond acceptable. It might stem from the characteristics of the benchmark itself (factors like a relatively small sample of networks given vast space, chosen hyperparameters, dropout rates, and others may distort NAS performance). Nonetheless, the trend is visible enough to conclude that \texttt{epsilon} metric can apply to recurrent type architectures.
\begin{table*}[!t]
\caption{Zero-cost metrics performance evaluated on NAS-Bench-NLP search space, PTB dataset. We highlight the best-performing metrics in bold.}
\label{tab:results_nlp}
\begin{center}
\small
\resizebox{!}{0.9in} {
\begin{tabular}{lrrp{0.1mm}rrrr}
\toprule
\noalign{\vskip 1 pt}
\multirow{2}{*}{Metric} & \multicolumn{2}{c}{Spearman $\rho$} & & \multicolumn{2}{c}{Kendall $\tau$} & Top-10\%/ & Top-64/ \\
\cline{2-3}\cline{5-6}
\noalign{\vskip 1.5pt}
& \multicolumn{1}{c}{global} & \multicolumn{1}{c}{top-10\%}& & global & top-10\% & top-10\% & top-5\% \\
\midrule
\noalign{\vskip 1pt}
\multicolumn{8}{c}{PTB}\\
\midrule
\noalign{\vskip 1pt}
\texttt{synflow} & 0.34 & 0.10 & & \textemdash & \textemdash & 22 & \textemdash \\
\texttt{grad\_norm} & -0.21 & 0.03 & & \textemdash & \textemdash & 10 & \textemdash \\
\texttt{grasp} & 0.16 & \pmb{0.55} & & \textemdash & \textemdash & 4 & \textemdash \\
\texttt{snip} & -0.19 & -0.02 & & \textemdash & \textemdash & 10 & \textemdash \\
\texttt{jacov} & \pmb{0.38} & 0.04 & & \textemdash & \textemdash & \pmb{38} & \textemdash \\
\texttt{epsilon} & -0.34 & -0.12 & & -0.23 & -0.08 & 24.87 & 11 \\
\bottomrule
\end{tabular}
}
\end{center}
\end{table*}
\subsection{Integration with other NAS methods}
\label{sec:implement}
While it is possible to utilise zero-cost metrics independently, they are often implemented within other NAS. Here we provide examples of random search and ageing evolution algorithms when used in tandem with \texttt{epsilon}.
Similarly to \citet{abdelfattah2021zero}, we compare random search performance with and without warm-up. First, we create a warm-up pool of $3{,}000$ architectures. Then, during the first $64$ steps of random search, the algorithm picks networks from the pool based on the highest trainless score and accordingly updates the best test performance.
For ageing evolution, the same principle applies. En plus, we report the results of implementation where every next parent is decided based on the highest \texttt{epsilon} score ("move"). In other words, the trainless scoring metric replaces validation accuracy in move mode. Finally, the child is created by parent mutation (within an edit distance of $1$) and added to the pool. Finally, the oldest network is removed from the pool.
For both described algorithms, we run the procedure until the number of trained architectures reaches $300$ and perform $100$ random rounds. Figure \ref{fig:integration} shows that \texttt{epsilon} metric leads to considerable improvements in terms of time and precision. The best performance is achieved in combination with a warm-up. Figure \ref{fig:integration_other} assembles warm-up performances for several trainless metrics.
\begin{figure*}[!t]
\centering
\begin{minipage}[6.8cm]{.32\linewidth}
\subfigure{
\includegraphics[width=.95\textwidth]{figures/integration/CIFAR10_EA_Len300_Rounds100.png}
}\\
\hfill
\subfigure{
\includegraphics[width=.95\textwidth]{figures/integration/CIFAR10_RS3000+RS_100it.png}
}
\end{minipage}
\begin{minipage}[6.8cm]{.32\linewidth}
\subfigure{
\includegraphics[width=.95\textwidth]{figures/integration/CIFAR100_EA_Len300_Rounds100.png}
}\\
\hfill
\subfigure{
\includegraphics[width=.95\textwidth]{figures/integration/CIFAR100_RS3000+RS_100it.png}
}
\end{minipage}
\begin{minipage}[6.8cm]{.32\linewidth}
\subfigure{
\includegraphics[width=.95\textwidth]{figures/integration/IMAGENET16-120_EA_Len300_Rounds100.png}
}\\
\hfill
\subfigure{
\includegraphics[width=.95\textwidth]{figures/integration/IMAGENET16-120_RS3000+RS_100it.png}
}
\end{minipage}
\caption{\texttt{epsilon} integration within ageing evolution (top) and random search (bottom) NAS algorithms for three datasets from NAS-Bench-201 search space.}
\label{fig:integration}
\end{figure*}
\section{Discussion}
While \texttt{epsilon} metric shows solid empirical performance, the underlying reasons for this are unclear.
There are several hints towards its understanding. First, mathematically, \texttt{epsilon} represents the difference in the output distribution shapes between initialisations. The shape of the output is affected by layer widths, activation functions, batch normalisation, skip connections and other factors, which we generally refer to as network geometry. With constant shared weights, one can probe the effects of the geometry without being obstructed by the randomness of initialisation.
Second, during the weight ablation studies (Section \ref{sec:ablations}), we noticed that the best performance is achieved when the weights are set to the lowest and highest values that do not lead to excessive outputs explosion or vanishing. Therefore, \texttt{epsilon} measures the amplitude of the outputs' distribution shape change due to geometry.
Finally, during the synthetic data studies, we see that grey-scale solid images work reasonably well as inputs. The distribution over the input samples is uniform, which makes it easier to track the changes in its shape as the signal propagates through the network.
That said, a coherent theoretical foundation of \texttt{epsilon} is missing and should be developed in future.
\section{Conclusions}
This work presents a novel zero-cost NAS scoring metric \texttt{epsilon}. It consists of two network initialisations followed by two forward passes. The value of \texttt{epsilon} reflects how neural network outputs' distribution changes between low and high constant shared weight initialisations. It shows that the higher this difference, the better the network will perform upon training.
The metric does not require labels or gradient computation and is fast and lightweight. Evaluation takes $0.1\sim1$ seconds per architecture on a single GPU (depending on the size of the architecture and batch size) and can be realised on a CPU. \texttt{epsilon} can virtually apply for any ML problem (care should be taken with embedding initialisation, as explained in Section \ref{sec:embedding}).
This work evaluates \texttt{epsilon} on three staple NAS search spaces: NAS-Bench-201, NAS-Bench-101 and NAS-Bench-NLP. It shows good stable performance with each of them, regardless of the data set. It also significantly improves the performances of random and evolutionary NAS algorithms (see Section \ref{sec:implement}).
The only significant disadvantage of the method is that it requires the choice of constant weight values during initialisation. Our tests show that it must be set up individually for each search space. We plan to automate the weight selection process in our future work.
\subsubsection*{Acknowledgments}
The authors would like to thank Dr. Ayako Nakata and Dr. Guillaume Lambard for their continuous support and advice.
\bibliographystyle{unsrtnat}
| {'timestamp': '2023-02-10T02:04:53', 'yymm': '2302', 'arxiv_id': '2302.04406', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04406'} | arxiv |
\section{Introduction}
\label{sec:intro}
Please follow the steps outlined below when submitting your manuscript to the IEEE Computer Society Press.
This style guide now has several important modifications (for example, you are no longer warned against the use of sticky tape to attach your artwork to the paper), so all authors should read this new version.
\subsection{Language}
All manuscripts must be in English.
\subsection{Dual submission}
Please refer to the author guidelines on the CVPR\ 2023\ web page for a
discussion of the policy on dual submissions.
\subsection{Paper length}
Papers, excluding the references section, must be no longer than eight pages in length.
The references section will not be included in the page count, and there is no limit on the length of the references section.
For example, a paper of eight pages with two pages of references would have a total length of 10 pages.
{\bf There will be no extra page charges for CVPR\ 2023.}
Overlength papers will simply not be reviewed.
This includes papers where the margins and formatting are deemed to have been significantly altered from those laid down by this style guide.
Note that this \LaTeX\ guide already sets figure captions and references in a smaller font.
The reason such papers will not be reviewed is that there is no provision for supervised revisions of manuscripts.
The reviewing process cannot determine the suitability of the paper for presentation in eight pages if it is reviewed in eleven.
\subsection{The ruler}
The \LaTeX\ style defines a printed ruler which should be present in the version submitted for review.
The ruler is provided in order that reviewers may comment on particular lines in the paper without circumlocution.
If you are preparing a document using a non-\LaTeX\ document preparation system, please arrange for an equivalent ruler to appear on the final output pages.
The presence or absence of the ruler should not change the appearance of any other content on the page.
The camera-ready copy should not contain a ruler.
(\LaTeX\ users may use options of cvpr.sty to switch between different versions.)
Reviewers:
note that the ruler measurements do not align well with lines in the paper --- this turns out to be very difficult to do well when the paper contains many figures and equations, and, when done, looks ugly.
Just use fractional references (\eg, this line is $087.5$), although in most cases one would expect that the approximate location will be adequate.
\subsection{Paper ID}
Make sure that the Paper ID from the submission system is visible in the version submitted for review (replacing the ``*****'' you see in this document).
If you are using the \LaTeX\ template, \textbf{make sure to update paper ID in the appropriate place in the tex file}.
\subsection{Mathematics}
Please number all of your sections and displayed equations as in these examples:
\begin{equation}
E = m\cdot c^2
\label{eq:important}
\end{equation}
and
\begin{equation}
v = a\cdot t.
\label{eq:also-important}
\end{equation}
It is important for readers to be able to refer to any particular equation.
Just because you did not refer to it in the text does not mean some future reader might not need to refer to it.
It is cumbersome to have to use circumlocutions like ``the equation second from the top of page 3 column 1''.
(Note that the ruler will not be present in the final copy, so is not an alternative to equation numbers).
All authors will benefit from reading Mermin's description of how to write mathematics:
\url{http://www.pamitc.org/documents/mermin.pdf}.
\subsection{Blind review}
Many authors misunderstand the concept of anonymizing for blind review.
Blind review does not mean that one must remove citations to one's own work---in fact it is often impossible to review a paper unless the previous citations are known and available.
Blind review means that you do not use the words ``my'' or ``our'' when citing previous work.
That is all.
(But see below for tech reports.)
Saying ``this builds on the work of Lucy Smith [1]'' does not say that you are Lucy Smith;
it says that you are building on her work.
If you are Smith and Jones, do not say ``as we show in [7]'', say ``as Smith and Jones show in [7]'' and at the end of the paper, include reference 7 as you would any other cited work.
An example of a bad paper just asking to be rejected:
\begin{quote}
\begin{center}
An analysis of the frobnicatable foo filter.
\end{center}
In this paper we present a performance analysis of our previous paper [1], and show it to be inferior to all previously known methods.
Why the previous paper was accepted without this analysis is beyond me.
[1] Removed for blind review
\end{quote}
An example of an acceptable paper:
\begin{quote}
\begin{center}
An analysis of the frobnicatable foo filter.
\end{center}
In this paper we present a performance analysis of the paper of Smith \etal [1], and show it to be inferior to all previously known methods.
Why the previous paper was accepted without this analysis is beyond me.
[1] Smith, L and Jones, C. ``The frobnicatable foo filter, a fundamental contribution to human knowledge''. Nature 381(12), 1-213.
\end{quote}
If you are making a submission to another conference at the same time, which covers similar or overlapping material, you may need to refer to that submission in order to explain the differences, just as you would if you had previously published related work.
In such cases, include the anonymized parallel submission~\cite{Authors14} as supplemental material and cite it as
\begin{quote}
[1] Authors. ``The frobnicatable foo filter'', F\&G 2014 Submission ID 324, Supplied as supplemental material {\tt fg324.pdf}.
\end{quote}
Finally, you may feel you need to tell the reader that more details can be found elsewhere, and refer them to a technical report.
For conference submissions, the paper must stand on its own, and not {\em require} the reviewer to go to a tech report for further details.
Thus, you may say in the body of the paper ``further details may be found in~\cite{Authors14b}''.
Then submit the tech report as supplemental material.
Again, you may not assume the reviewers will read this material.
Sometimes your paper is about a problem which you tested using a tool that is widely known to be restricted to a single institution.
For example, let's say it's 1969, you have solved a key problem on the Apollo lander, and you believe that the CVPR70 audience would like to hear about your
solution.
The work is a development of your celebrated 1968 paper entitled ``Zero-g frobnication: How being the only people in the world with access to the Apollo lander source code makes us a wow at parties'', by Zeus \etal.
You can handle this paper like any other.
Do not write ``We show how to improve our previous work [Anonymous, 1968].
This time we tested the algorithm on a lunar lander [name of lander removed for blind review]''.
That would be silly, and would immediately identify the authors.
Instead write the following:
\begin{quotation}
\noindent
We describe a system for zero-g frobnication.
This system is new because it handles the following cases:
A, B. Previous systems [Zeus et al. 1968] did not handle case B properly.
Ours handles it by including a foo term in the bar integral.
...
The proposed system was integrated with the Apollo lunar lander, and went all the way to the moon, don't you know.
It displayed the following behaviours, which show how well we solved cases A and B: ...
\end{quotation}
As you can see, the above text follows standard scientific convention, reads better than the first version, and does not explicitly name you as the authors.
A reviewer might think it likely that the new paper was written by Zeus \etal, but cannot make any decision based on that guess.
He or she would have to be sure that no other authors could have been contracted to solve problem B.
\medskip
\noindent
FAQ\medskip\\
{\bf Q:} Are acknowledgements OK?\\
{\bf A:} No. Leave them for the final copy.\medskip\\
{\bf Q:} How do I cite my results reported in open challenges?
{\bf A:} To conform with the double-blind review policy, you can report results of other challenge participants together with your results in your paper.
For your results, however, you should not identify yourself and should not mention your participation in the challenge.
Instead present your results referring to the method proposed in your paper and draw conclusions based on the experimental comparison to other results.\medskip\\
\begin{figure}[t]
\centering
\fbox{\rule{0pt}{2in} \rule{0.9\linewidth}{0pt}}
\caption{Example of caption.
It is set in Roman so that mathematics (always set in Roman: $B \sin A = A \sin B$) may be included without an ugly clash.}
\label{fig:onecol}
\end{figure}
\subsection{Miscellaneous}
\noindent
Compare the following:\\
\begin{tabular}{ll}
\verb'$conf_a$' & $conf_a$ \\
\verb'$\mathit{conf}_a$' & $\mathit{conf}_a$
\end{tabular}\\
See The \TeX book, p165.
The space after \eg, meaning ``for example'', should not be a sentence-ending space.
So \eg is correct, {\em e.g.} is not.
The provided \verb'\eg' macro takes care of this.
When citing a multi-author paper, you may save space by using ``et alia'', shortened to ``\etal'' (not ``{\em et.\ al.}'' as ``{\em et}'' is a complete word).
If you use the \verb'\etal' macro provided, then you need not worry about double periods when used at the end of a sentence as in Alpher \etal.
However, use it only when there are three or more authors.
Thus, the following is correct:
``Frobnication has been trendy lately.
It was introduced by Alpher~\cite{Alpher02}, and subsequently developed by
Alpher and Fotheringham-Smythe~\cite{Alpher03}, and Alpher \etal~\cite{Alpher04}.''
This is incorrect: ``... subsequently developed by Alpher \etal~\cite{Alpher03} ...'' because reference~\cite{Alpher03} has just two authors.
\begin{figure*}
\centering
\begin{subfigure}{0.68\linewidth}
\fbox{\rule{0pt}{2in} \rule{.9\linewidth}{0pt}}
\caption{An example of a subfigure.}
\label{fig:short-a}
\end{subfigure}
\hfill
\begin{subfigure}{0.28\linewidth}
\fbox{\rule{0pt}{2in} \rule{.9\linewidth}{0pt}}
\caption{Another example of a subfigure.}
\label{fig:short-b}
\end{subfigure}
\caption{Example of a short caption, which should be centered.}
\label{fig:short}
\end{figure*}
\section{Formatting your paper}
\label{sec:formatting}
All text must be in a two-column format.
The total allowable size of the text area is $6\frac78$ inches (17.46 cm) wide by $8\frac78$ inches (22.54 cm) high.
Columns are to be $3\frac14$ inches (8.25 cm) wide, with a $\frac{5}{16}$ inch (0.8 cm) space between them.
The main title (on the first page) should begin 1 inch (2.54 cm) from the top edge of the page.
The second and following pages should begin 1 inch (2.54 cm) from the top edge.
On all pages, the bottom margin should be $1\frac{1}{8}$ inches (2.86 cm) from the bottom edge of the page for $8.5 \times 11$-inch paper;
for A4 paper, approximately $1\frac{5}{8}$ inches (4.13 cm) from the bottom edge of the
page.
\subsection{Margins and page numbering}
All printed material, including text, illustrations, and charts, must be kept
within a print area $6\frac{7}{8}$ inches (17.46 cm) wide by $8\frac{7}{8}$ inches (22.54 cm)
high.
Page numbers should be in the footer, centered and $\frac{3}{4}$ inches from the bottom of the page.
The review version should have page numbers, yet the final version submitted as camera ready should not show any page numbers.
The \LaTeX\ template takes care of this when used properly.
\subsection{Type style and fonts}
Wherever Times is specified, Times Roman may also be used.
If neither is available on your word processor, please use the font closest in
appearance to Times to which you have access.
MAIN TITLE.
Center the title $1\frac{3}{8}$ inches (3.49 cm) from the top edge of the first page.
The title should be in Times 14-point, boldface type.
Capitalize the first letter of nouns, pronouns, verbs, adjectives, and adverbs;
do not capitalize articles, coordinate conjunctions, or prepositions (unless the title begins with such a word).
Leave two blank lines after the title.
AUTHOR NAME(s) and AFFILIATION(s) are to be centered beneath the title
and printed in Times 12-point, non-boldface type.
This information is to be followed by two blank lines.
The ABSTRACT and MAIN TEXT are to be in a two-column format.
MAIN TEXT.
Type main text in 10-point Times, single-spaced.
Do NOT use double-spacing.
All paragraphs should be indented 1 pica (approx.~$\frac{1}{6}$ inch or 0.422 cm).
Make sure your text is fully justified---that is, flush left and flush right.
Please do not place any additional blank lines between paragraphs.
Figure and table captions should be 9-point Roman type as in \cref{fig:onecol,fig:short}.
Short captions should be centred.
\noindent Callouts should be 9-point Helvetica, non-boldface type.
Initially capitalize only the first word of section titles and first-, second-, and third-order headings.
FIRST-ORDER HEADINGS.
(For example, {\large \bf 1. Introduction}) should be Times 12-point boldface, initially capitalized, flush left, with one blank line before, and one blank line after.
SECOND-ORDER HEADINGS.
(For example, { \bf 1.1. Database elements}) should be Times 11-point boldface, initially capitalized, flush left, with one blank line before, and one after.
If you require a third-order heading (we discourage it), use 10-point Times, boldface, initially capitalized, flush left, preceded by one blank line, followed by a period and your text on the same line.
\subsection{Footnotes}
Please use footnotes\footnote{This is what a footnote looks like.
It often distracts the reader from the main flow of the argument.} sparingly.
Indeed, try to avoid footnotes altogether and include necessary peripheral observations in the text (within parentheses, if you prefer, as in this sentence).
If you wish to use a footnote, place it at the bottom of the column on the page on which it is referenced.
Use Times 8-point type, single-spaced.
\subsection{Cross-references}
For the benefit of author(s) and readers, please use the
{\small\begin{verbatim}
\cref{...}
\end{verbatim}} command for cross-referencing to figures, tables, equations, or sections.
This will automatically insert the appropriate label alongside the cross-reference as in this example:
\begin{quotation}
To see how our method outperforms previous work, please see \cref{fig:onecol} and \cref{tab:example}.
It is also possible to refer to multiple targets as once, \eg~to \cref{fig:onecol,fig:short-a}.
You may also return to \cref{sec:formatting} or look at \cref{eq:also-important}.
\end{quotation}
If you do not wish to abbreviate the label, for example at the beginning of the sentence, you can use the
{\small\begin{verbatim}
\Cref{...}
\end{verbatim}}
command. Here is an example:
\begin{quotation}
\Cref{fig:onecol} is also quite important.
\end{quotation}
\subsection{References}
List and number all bibliographical references in 9-point Times, single-spaced, at the end of your paper.
When referenced in the text, enclose the citation number in square brackets, for
example~\cite{Authors14}.
Where appropriate, include page numbers and the name(s) of editors of referenced books.
When you cite multiple papers at once, please make sure that you cite them in numerical order like this \cite{Alpher02,Alpher03,Alpher05,Authors14b,Authors14}.
If you use the template as advised, this will be taken care of automatically.
\begin{table}
\centering
\begin{tabular}{@{}lc@{}}
\toprule
Method & Frobnability \\
\midrule
Theirs & Frumpy \\
Yours & Frobbly \\
Ours & Makes one's heart Frob\\
\bottomrule
\end{tabular}
\caption{Results. Ours is better.}
\label{tab:example}
\end{table}
\subsection{Illustrations, graphs, and photographs}
All graphics should be centered.
In \LaTeX, avoid using the \texttt{center} environment for this purpose, as this adds potentially unwanted whitespace.
Instead use
{\small\begin{verbatim}
\centering
\end{verbatim}}
at the beginning of your figure.
Please ensure that any point you wish to make is resolvable in a printed copy of the paper.
Resize fonts in figures to match the font in the body text, and choose line widths that render effectively in print.
Readers (and reviewers), even of an electronic copy, may choose to print your paper in order to read it.
You cannot insist that they do otherwise, and therefore must not assume that they can zoom in to see tiny details on a graphic.
When placing figures in \LaTeX, it's almost always best to use \verb+\includegraphics+, and to specify the figure width as a multiple of the line width as in the example below
{\small\begin{verbatim}
\usepackage{graphicx} ...
\includegraphics[width=0.8\linewidth]
{myfile.pdf}
\end{verbatim}
}
\subsection{Color}
Please refer to the author guidelines on the CVPR\ 2023\ web page for a discussion of the use of color in your document.
If you use color in your plots, please keep in mind that a significant subset of reviewers and readers may have a color vision deficiency; red-green blindness is the most frequent kind.
Hence avoid relying only on color as the discriminative feature in plots (such as red \vs green lines), but add a second discriminative feature to ease disambiguation.
\section{Final copy}
You must include your signed IEEE copyright release form when you submit your finished paper.
We MUST have this form before your paper can be published in the proceedings.
Please direct any questions to the production editor in charge of these proceedings at the IEEE Computer Society Press:
\url{https://www.computer.org/about/contact}.
{\small
\bibliographystyle{ieee_fullname}
\section{Introduction} \label{sec:intro}
\begin{figure}
\centering
\includegraphics[width=0.9\columnwidth]{figures/spider_all.png}
\caption[]
{Our sustainable geospatial foundation model (GFM) achieves strong performance on a broad set of tasks in comparison to other state-of-the-art geospatial pretraining methods (SeCo \cite{seco}, SatMAE \cite{satmae}) and ImageNet supervised pretraining baselines.}
\label{fig:model_comparison}
\end{figure}
With the rise of large-scale satellite and aerial imageries~\cite{landsat,naip}, geospatial technologies are becoming increasingly important. Progress in this domain can substantially improve our ability to understand the earth and how we interact with it.
Nonetheless, in the current era of deep learning, data fuels progress. Thankfully, the amount of data and tasks in the geospatial domain continues to grow. This has recently been made evident in a survey \cite{earthnets} compiling hundreds of published datasets for earth observation. Beyond curated datasets, openly available satellite imagery programs like Sentinel~\cite{sentinel}, Landsat~\cite{landsat}, and National Agriculture Imagery Program (NAIP)~\cite{naip} also provide a plethora of data for use.
With such a vast interest in the application of geospatial and remote sensing data,
the computer vision community has been continually investing in designing better algorithms to harness the available data and improve performance on various tasks.
Particularly, with the rising popularity of foundation models in vision and natural language, many works have worked on building strong pretrained models specific to the geospatial domain \cite{seco, gassl, satmae, millionAID_supervised_pretraining}.
These methods typically train a network from scratch on a large corpus of remote sensing imagery. Unfortunately, this can require a significant amount of data and training time to achieve good performance, especially when employing large state-of-the-art transformer models.
However, in this pursuit of a stronger geospatial foundation model, one potentially useful tool has been largely forgotten. ImageNet pretrained models are readily available for the majority of state-of-the-art architectures. More recently, we now have many models trained on the larger scale ImageNet-22k~\cite{imagenet} dataset, providing even stronger and more general representations than before.
Rather than beginning the pretraining process tabula rasa, could these ImageNet representations serve as a base on which stronger geospatial models can be built?
In the same spirit, continual pretraining has been practiced in the NLP domain with success in various works \cite{dontStopPretraining, continual_temporal, continual_mixedLang}. In this paradigm, existing foundation models are further improved for a specific domain or task through a secondary pretraining stage. In principle, we reason that such a paradigm has the potential to produce strong geospatial models in an efficient and sustainable manner.
To this end, we investigate a sustainable approach for building geospatial foundation models. Specifically, we form a multi-objective continual pretraining paradigm, simultaneously leveraging ImageNet pretrained features and self-supervised learning on a concise collection of geospatial imagery. In our investigations, we discover two important factors in the process.
\begin{itemize}
\item \textbf{Data choice matters.} We find that the selection of pretraining data matters, even within the geospatial domain. Therefore, we select a diverse collection of data from various sources to capture a wider variety of general remote sensing scenes, which we term as GeoPile. Conducting masked image modeling with GeoPile is significantly more effective and sample efficient compared to other common alternatives (see Section \ref{sec:data}).
\item \textbf{Continual pretraining.} Available pretrained models on diverse datasets like ImageNet-22k should not be ignored when building geospatial foundation models. Rather, by leveraging their representations, we can build strong models for geospatial applications in a sustainable manner. To this end, we investigate a multi-objective continual pretraining paradigm for simple and effective learning (see Section \ref{sec:gfm}). By continual pretraining, we show that our newly proposed Geospatial Foundation Model (GFM) outperforms previous state-of-the-art geospatial pretrained models on a broad set of tasks, as shown in Figure~\ref{fig:model_comparison}.
\end{itemize}
\section{Related Work} \label{sec:related}
\subsection{Masked Image Modeling}
Masked image modeling (MIM) has been proposed in various forms in recent years, but has quickly become very popular as an effective pretraining task.
In general, the goal is to learn from data in a self-supervised manner by asking the model to generate pixel values for intentionally-withheld regions in an image.
\cite{context_encoders} is an early work with an aim of learning strong visual representations through inpainting masked regions. In \cite{generative_pretrain}, Chen et. al train a large transformer to predict pixels autoregressively. After the introduction of vision transformers (ViT) \cite{vit}, many works continued to improve various MIM variants. \cite{beit} and \cite{ibot} take inspiration from BERT \cite{bert} in natural language processing, and tokenize the image patches with either a pretrained model or jointly trained online tokenizer, with the objective being to reconstruct at a token-level rather than raw pixels. Recently, \cite{simmim} and \cite{mae} show that a masked image modeling task of simply regressing directly on the image pixels is sufficient and effective. In this work, we leverage the framework from \cite{simmim}, as it is compatible with hierarchical transformer architectures \cite{swin}.
\subsection{Geospatial Pretraining}
Various works have experimented with employing supervised or self-supervised pretraining paradigms in the geospatial domain. The classical work of \cite{indomain}, and more recent paper \cite{millionAID_supervised_pretraining}, investigate supervised pretraining on individual datasets of various sizes. Interestingly, these still often found the ImageNet pretrained models to perform very well, particularly with vision transformers \cite{vit, swin}.
Other works have explored self-supervised learning paradigms for remote sensing, primarily focused on contrastive methods. \cite{seco} and \cite{gassl} employ a MoCo \cite{mocov2} style objective using spatially aligned but temporally different images as the positive pairs. \cite{saumoco} and \cite{tile2vec} also utilize a MoCo-inspired objective, but specify a cropping procedure to generate positives and negatives within and across images. \cite{colorOutofSpace} employs a colorization objective on Sentinel-2 imagery utilizing the various spectral bands. Most recently, SatMAE \cite{satmae} explores the use of masked image modeling to train a large ViT model. This work is similar in some respect to ours, as we also train a transformer model with an MIM objective. However, we find that SatMAE often does not perform better than the off-the-shelf ImageNet-22k pretrained ViT (Section \ref{sec:experiments}). This indicates both the difficulty of building strong geospatial foundation models from scratch and highlights the potential usefulness of leveraging continual pretraining instead, as we investigate in this work.
In this work, we develop our pretraining objective based on a masked image modeling approach like \cite{simmim, mae}.
MIM has recently been shown to be particularly effective in the natural image domain, surpassing many contrastive works and being shown to be friendlier to downstream optimization \cite{simmim, mae, ibot, beit, dark_secrets}. Exploration of the masked image modeling framework in geospatial applications is still in its early stages, and could help allivate some concerns with contrastive approaches in this domain.
Particularly, the choice of augmentations with contrastive methods can be quite difficult, as common selections such as greyscale, color jitter and others that heavily affect the intensity of the image can instill undesirable invariances \cite{indomain}. On the other hand, MIM objectives like \cite{simmim, mae} rely only on simple spatial augmentations such as flipping and cropping. Furthermore, a common remote sensing application is that of change detection, which requires a model to detect changes in two images from the same location but at different times. In order to still be effective on this task, works that use contrastive approaches on temporal positives introduce various design choices. For instance, SeCo \cite{seco} creates multiple feature subspaces during pretraining, each one invariant to a separate form of augmentation. \cite{matter} also employs temporal positives, but instead chooses the sampling locations for the pretraining data to ensure that image pairs contain primarily natural illumination and viewing angle variant, without major changes such as new urban developments.
\begin{figure*}
\centering
\includegraphics[trim={160 160 160 160},clip, width=0.9\textwidth]{figures/samples.pdf}
\caption[]
{We visualize some example images from the pretraining datasets. From left to right: ImageNet, Sentinel-2, and GeoPile. Sentinel-2 has noticeably much lower feature diversity within a single image and across images than that of ImageNet or our GeoPile pretraining dataset.}
\label{fig:data_comparison_visual}
\end{figure*}
\subsection{Continual Pretraining}
Continual pretraining has been primarily introduced in the natural language domain \cite{dontStopPretraining, continual_temporal, continual_mixedLang}, in order to improve large language models (LLM). \cite{dontStopPretraining} illustrates the viability of two additional stages of pretraining, using in-domain data (domain-adaptive), and then even further using task-specific data (task-adaptive). \cite{continual_temporal} proposes a continual training paradigm for enabling temporal reasoning abilities to pretrained language models. \cite{continual_mixedLang} focus on using continual pretraining to enable mixed language neural machine translation. In the vision domain, \cite{medseg} employs a BYOL \cite{byol} style continual pretraining paradigm for 2D medical image segmentation. \cite{selfimproveself} explores a hierarchical pretraining approach for task adaptation. However, they primarily focus on adapting to a specific downstream task at a time, employing three training stages on top of an existing pretrained model for each task individually. In contrast, we employ one efficient in-domain pretraining setting that can generalize to many downstream tasks, as illustrated in Section \ref{sec:experiments}. Furthermore, rather than directly loading the pretrained weights from existing models as initialization, we find instead that leveraging the representations as an auxiliary distillation objective during the pretraining process enables learning strong in-domain representations in a sustainable manner.
\section{Methodology}
We aim to investigate a sustainable approach for building geospatial foundation models. This leads us to two key insights. First, the selection of pretraining data matters, even within the geospatial domain. We discuss our empirical findings to this end in Section \ref{sec:data}. Second, available pretrained models on diverse datasets like ImageNet-22k should not be ignored when building geospatial foundation models. In fact, by leveraging their representations, we can build strong models for geospatial applications in a sustainable manner. These discussions can be found in Section \ref{sec:gfm}.
\subsection{Pre-training Data Matters} \label{sec:data}
A particularly common choice of source data among geospatial contrastive pretraining works is Sentinel-2 imagery \cite{seco, matter, colorOutofSpace} due to its large corpus of available data and ease of access.
Therefore, to begin our study, we first gather a pretraining dataset of ~1.3 million (matching the scale of ImageNet-1k~\cite{imagenet}) Sentinel-2 images using the sampling technique from \cite{seco}.
After gathering the Sentinel-2 data, we employ it to pretrain a Swin-B \cite{swin} model with the masked image modeling (MIM) objective from \cite{simmim}.
We then finetune and evaluate this model on a wide variety of downstream datasets to get a broad understanding of its performance potential in many tasks (see Section \ref{sec:experiments} for task details). For a comparison, we finetune the ImageNet-22k pretrained Swin-B from the official Swin Transformer repository \cite{swin} on all downstream tasks as a baseline. In order to compare these models across all tasks, we introduce an average relative performance metric (ARP) in which we take the relative percentage difference on each task with respect to the ImageNet-22k baseline, and then average that difference:
\begin{equation} \label{eg:arp}
\text{ARP}(M) = \frac{1}{N}\sum_{i=1}^N \frac{\text{score}(M, \text{task}_i) -\text{score}( \text{baseline}, \text{task}_i)}{\text{score}( \text{baseline}, \text{task}_i)}.
\end{equation}
\noindent Here ``baseline'' is the Swin-B model pretrained on ImageNet-22k and finetuned on ImageNet-1k, as mentioned above. $M$ denotes the model for performance evaluation, and N is the number of tasks. There are $7$ tasks used in Section~\ref{sec:experiments} covering important geospatial tasks such as classification, multi-label classification, semantic segmentation, change detection, and super-resolution. The reported ARP value is scaled by 100 to show as a percentage.
We compare these two models in Table \ref{tab:data}.
Interestingly, we find that the Sentinel-2 model performs poorly on downstream tasks compared to the ImageNet-22k baseline.
To investigate this further, we also pretrain a model using MIM on ImageNet-1k,
and find this actually performs better than using Sentinel-2 imagery.
While there is obviously a degree of domain shift between ImageNet and remote sensing data, we reason that Sentinel-2 data alone lacks sufficient feature diversity for a strong pretraining dataset. As a basic indicator, we calculate the average image entropy over a randomly sampled set of 3000 images for both ImageNet-1k and our collected Sentinel-2 data and find it to be 5.1 and 3.9 respectively. Note that entropy is certainly not the sole factor at play, such an evaluation can still provides insights into the advantages of ImageNet over sentinel. For MIM objectives, training data with a substantially lower entropy can make for an easier reconstruction task, since masked regions may be more similar to their neighbors. Therefore, the network does not have to work as hard to fill in the blanks, limiting the learning potential. Qualitatively, we also visualize multiple samples from ImageNet-1k and Sentinel-2 in the top row of Figure \ref{fig:data_comparison_visual}. The feature diversity within a single image and across images of Sentinel-2 is perceivably lower than that of ImageNet. This result indicates that a comparatively narrow scope of features is provided to the model when pretraining with Sentinel-2.
Therefore, we set out to collect a diverse geospatial pretraining dataset. Sourcing from both labeled and unlabelled data, we form a new pretraining dataset which we term GeoPile. The breakdown of GeoPile is shown in Table \ref{tab:geopile}. For textural detail, we ensure a variety of ground sample distances (GSD), including images with much higher resolution imagery than Sentinel-2 (which has a GSD of 10m). Furthermore, the selected labeled datasets encompass a wide variety of classes from general remote sensing scenes, ensuring visual diversity across samples. We calculate the average entropy of our GeoPile dataset, and find it to be 4.6, much closer to that of ImageNet-1k. Furthermore, the textural and visual diversity is qualitatively evident in Figure \ref{fig:data_comparison_visual}. As shown in Table \ref{tab:data}, the enhancing effect of the data selection is evident in the substantial performance increase.
To further improve the performance of our pretrained model in comparison to the ImageNet-22k baseline, we increase the number of training epochs in the last rows of Table \ref{tab:data}. While we are able to make improvements, this comes at the cost of substantially more compute and carbon footprint for marginal gain. Therefore, we ask the question: can we significantly improve performance with minimal compute and carbon footprint overhead? To this end, we investigate a simple and sustainable approach for building geospatial foundation models with strong performance.
\begin{table}
\caption{Dataset Analysis. To evaluate each method, we finetune the pretrained model on seven different tasks, outlined in Section \ref{sec:experiments} and report the ARP metric defined in Equation \ref{eg:arp}.
Overall, our collected GeoPile pretraining dataset significantly improves downstream performance. To further improve the performance in a sustainable manner, we introduce our continuous training paradigm GFM. We show the ARP and CO2 estimations \cite{co2} for GFM trained on GeoPile.}
\label{tab:data}
\centering
\setlength\tabcolsep{4.0pt}
\renewcommand{\arraystretch}{0.9
\begin{tabular}{ccccc}
\toprule
Method & \# Images & Epochs & ARP $\uparrow$ & CO2 $\downarrow$\\
\toprule
ImageNet-22k Sup. & 14M & - & 0.0 & -\\
\midrule
ImageNet-1k & 1.3M & 100 & 1.82 & 17.76\\
Sentinel-2 \cite{seco} & 1.3M & 100 & -5.53 & 17.76\\
GeoPile & 600k & 200 & 2.02 & 12.64\\
GeoPile & 600k & 800 & 2.44 & 50.56\\
\midrule
GFM & 600k & 100 & 4.47 & 8.56\\
\midrule
\end{tabular}
\end{table}
\begin{table}
\caption{Breakdown of datasets in the GeoPile. We gather approximately 600k samples from a combination of labeled and unlabeled satellite imagery.}
\label{tab:geopile}
\centering
\setlength\tabcolsep{5.0pt}
\renewcommand{\arraystretch}{0.9
\begin{tabular}{cccc}
\toprule
Dataset & \# Images & GSD & \# Classes\\
\toprule
NAIP\cite{naip} & 300,000 & 1m & n/a\\
RSD46-WHU \cite{RSD46-WHU} & 116,893 & 0.5m - 2m & 46\\
MLRSNet \cite{MLRSNet} & 109,161 & 0.1m - 10m & 60\\
RESISC45 \cite{RESISC45} & 31,500 & 0.2m - 30m & 45\\
PatternNet \cite{PatternNet} & 30,400 & 0.1m - 0.8m & 38\\
\midrule
\end{tabular}
\end{table}
\subsection{Sustainable GFM} \label{sec:gfm}
\begin{figure*}
\centering
\includegraphics[trim={100 60 100 60},clip, width=0.75\textwidth]{figures/gfm.pdf}
\caption[]
{Our GFM multi-objective continual pretraining paradigm. Two parallel branches, one initialized with ImageNet-22k weights (top) and another from random initialization (bottom).
Blue functional blocks are frozen during training, and green ones are trained. In a teacher-student fashion, we leverage the intermediate features of an ImageNet-22k pretrained model to guide and quicken learning. Furthermore, we build in an MIM objective on the student branch to allow for learning valuable in-domain features directly from the geospatial data.}
\label{fig:gfm}
\end{figure*}
Nowadays, state-of-the-art models release pretrained weights on very large and diverse datasets like ImageNet-22k. While not perfect for geospatial tasks, these models still contain a vast amount of useful knowledge that is generalizable across many settings.
Nonetheless, the majority of previous works in geospatial pretraining neglect the available ImageNet representations, which is not ideal, especially for large transformer models that are notoriously data hungry and computationally expensive to train.
Instead, we reason that the valuable knowledge available in these large-scale models should be leveraged to produce strong performance with minimized overhead. To this end, we propose an unsupervised multi-objective training paradigm for sustainable training of geospatial foundation models, illustrated in Figure \ref{fig:gfm}.
There are two main components in our framework. First, we randomly initialize an encoder and decoder set up for MIM as in \cite{simmim}. During training, the input is randomly masked, and the network attempts to reconstruct the image at the output. This MIM objective is enforced with an L1 loss. \cite{simmim}:
\begin{equation}
\mathcal{L}_{MIM}=\frac{\left\|\mathbf{O}_\kappa-\mathbf{G}_\kappa\right\|_1}{N},
\end{equation}
where $\mathbf{O}_{\kappa}$ is the original pixel information from the masked regions, $\mathbf{G}_{\kappa}$ are the generated reconstructions for those masked regions, and $N$ is the total number of masked pixels.
To leverage the strong representations from the ImageNet model, we initialize a second encoder branch up to a chosen stage $L$ and load the pretrained weights.
This branch will serve as a form of teacher during the training process to the other "student" branch, which will serve as our final GFM model. For the ImageNet teacher, we freeze the weight, to both ensure that the structured representations are maintained during the training process, and also reduce the computation required during optimization.
Rather than using the masked input as in the student branch, the teacher receives the unmasked image as input,
and provides a feature output $f_{L}^{T}$ at stage $L$. This feature has access to the full context of the input, enabling it to capture informative representations.
We utilize this feature to guide the representations of the student, and form a secondary objective with the cosine similarity between branch features:
\begin{equation}
\mathcal{L}_{feat} = -\frac{P(f_{L}^{S})}{\left\|P(f_{L}^{S})\right\|_2} \cdot \frac{f_{L}^{T}}{\left\|f_{L}^{T}\right\|_2},
\end{equation}
where $f_{L}^{S}$ and $f_{L}^{T}$ are the intermediate features of the student and teacher branches at stage $L$, and $P$ is an linear projection layer. Therefore, the final loss during training is simply the summation of these objectives:
\begin{equation} \label{eq:loss_combined}
\mathcal{L} = \mathcal{L}_{MIM} + \alpha\mathcal{L}_{feat}.
\end{equation}
where $\alpha$ is a balancing term, which we find is best simply with $\alpha=1.0$ (Section \ref{sec:ablation}).
This training paradigm enables an ideal two-fold optimization. Distillation from the intermediate features of the teacher ensure that the student can benefit from the teacher's diverse knowledge, learning more in less time. Furthermore, the student is simultaneously given freedom to adapt to in-domain data through its own pretraining objective, gathering new domain-specific features to improve performance.
We analyze the ARP and sustainability potential of this approach in Table \ref{tab:data}. Notably, our GFM is able to achieve better overall performance with substantially less computation and emissions impact \footnote{CO2 estimations were completed with \url{https://mlco2.github.io/impact} from \cite{co2}} compared to tabula rasa pretraining with the same dataset, illustrating that our multi-objective continual pretraining paradigm is a sustainable method for training these models.
\section{Experiments} \label{sec:experiments}
To verify the effectiveness of our model in detail, we conduct experiments on eight geospatial datasets of various tasks including change detection (Section \ref{sec:change_det}), classification (Section \ref{sec:classification}), segmentation (Section \ref{sec:seg_detect}), and super-resolution (Section \ref{sec:superres}).
\subsection{Change Detection} \label{sec:change_det}
Change detection is a particularly important remote sensing task, helping us understand how humans interact with our planet over time, and natural phenomena that change our planet's landscape. We conduct experiments on both the Onera Satellite Change Detection (OSCD \cite{OSCD}) in Table \ref{tab:OSCD} and DSIFN \cite{DSIFN} in Table \ref{tab:DSFIN}.
OSCD consists of 14 image pairs extracted from various regions around the world within a three year period of 2015 to 2018. The images are taken from Sentinel-2 with GSDs ranging from 10m to 60m, and split into 14 images for training and 10 for evaluation. The annotations indicate whether the change has occurred on a pixel level, and focus primarily on urban developments. Similarly, we also test our method on DSIFN dataset. This dataset contains high-resolution imagery, such as WorldView-3 and GeoEys-1 \cite{DSIFN}. This dataset contains 3490 high resolution samples for training and 48 images for evaluation respectively. Every pair of images from a given location at two different timestamps will be fed into the swin encoder \cite{swin} for feature extraction. The difference between the features from each pair is computed and fed into to an UPerNet \cite{Upernet} to generate the final binary segmentation masks \cite{seco, siamdiff}. The encoder is initialized with the pretrained weights.
For both datasets, we report the precision, recall, and F1 score on the ``change" class. As the results presented from OSCD (Table \ref{tab:OSCD} and Figure \ref{fig:OSCD}) and DSIFN (Table \ref{tab:DSFIN}), GFM shows a consistent improvement over the ImageNet-22k baseline across both datasets. Notably, SatMAE is able to improve over its ImageNet-22k baseline on OSCD, but lags behind on DSIFN. This further highlights the difficulty of training large vision transformers from scratch that can perform consistently across different GSDs.
\begin{table}
\caption{Onera Satellite Change Detection Results}
\label{tab:OSCD}
\centering
\setlength\tabcolsep{5.0pt}
\resizebox{\columnwidth}{!}{
\begin{tabular}{cccc}
\toprule
Method & Precision $\uparrow$ & Recall $\uparrow$ & F1 $\uparrow$\\
\toprule
ResNet50 (ImageNet-1k) \cite{resnet} & \textbf{70.42} & 25.12 & 36.20\\
SeCo \cite{seco} & 65.47 & 38.06 & 46.94\\
MATTER \cite{matter} & 61.80 & 57.13 & 59.37\\
ViT (ImageNet-22k) \cite{vit} & 48.34 & 22.52 & 30.73\\
SatMAE \cite{satmae} & 48.19 & 42.24 & 45.02\\
Swin (random)\cite{swin} & 51.80 & 47.69 & 49.66\\
Swin (ImageNet-22k)\cite{swin} & 46.88 & 59.28 & 52.35\\
\midrule
GFM & 58.07 & \textbf{61.67} & \textbf{59.82}\\
\midrule
\end{tabular}
}
\end{table}
\begin{table}
\caption{DSFIN Change Detection Results}
\label{tab:DSFIN}
\centering
\setlength\tabcolsep{5.0pt}
\resizebox{\columnwidth}{!}{
\begin{tabular}{cccc}
\toprule
Method & Precision $\uparrow$ & Recall $\uparrow$ & F1 $\uparrow$\\
\toprule
ResNet50 (ImageNet-1k) \cite{resnet} & 28.74 & \textbf{92.07} & 43.80\\
SeCo \cite{seco} & 39.68 & 81.02 & 53.27\\
ViT (ImageNet-22k) \cite{vit} & 70.77 & 66.34 & 68.49\\
SatMAE \cite{satmae} & 70.45 & 60.29 & 64.98\\
Swin (random)\cite{swin} & 57.97 & 62.06 & 59.94\\
Swin (ImageNet-22k)\cite{swin} & 67.11 & 72.33 & 69.62\\
\midrule
GFM & \textbf{74.83} & 67.98 & \textbf{71.24}\\
\midrule
\end{tabular}
}
\end{table}
\begin{figure}
\centering
\includegraphics[width=0.8\columnwidth]{figures/OSCD.png}
\caption[]
{Qualitative results on OSCD. White, green, red colors represent true positive, false positive, and false negative respectively.}
\label{fig:OSCD}
\end{figure}
\subsection{Classification} \label{sec:classification}
Another common remote sensing application is that of classification. We evaluate two datasets common in the literature \cite{seco, matter}: UC Merced Land Use Dataset \cite{ucm} and BigEarthNet \cite{BEN}.
The UC Merced Land Use Dataset is a classic dataset in the remote sensing field. It contains 21 classes, each with 100 images at 256x256 pixels and an approximate GSD of 1 foot. We split the data into train and validation according to \cite{data_splits}.
BigEarthNet \cite{BEN} (BEN) is a large-scale remote sensing dataset for multi-label classification. The data consist of 12-band Sentinel-2 images with sizes of 120x120, 60x60, and 20x20 pixels for the bands at 10m, 20m, and 60m GSDs, respectively.
We employ the data split and 19 class evaluation as common in the literature \cite{indomain, seco, satmae}.
In Table \cite{BEN}, we report the classification accuracy on UC Merced (UCM) and mean average precision results on BigEarthNet (BEN) for all methods.
On UC Merced, we note the SeCo \cite{seco} pretrained model performs significantly worse than its ImageNet-1k pretrained counterpart with ResNet-50.
These two datasets are very different in both classes, satellite source, and GSDs, and therefore having a diverse feature knowledge is imperative to maintaining performance despite these distinctions.
Our model can provide robust performance in both cases by leveraging ImageNet representation and remote sensing data in its learning. Furthermore, one key motivation for training a geospatial foundation model is to improve the sample efficiency for downstream tasks. Notably, we find that our model maintains strong performance on BigEarthNet, even when only given 1\% of the training data.
\begin{table}
\caption{UC Merced classification accuracy and BigEarthNet multi-label classification mean average precision results on the validation set.}
\label{tab:BEN}
\centering
\setlength\tabcolsep{5.0pt}
\resizebox{\columnwidth}{!}{
\begin{tabular}{cccc}
\toprule
Method & UCM & BEN 10\% & BEN 1\%\\
\toprule
ResNet50 (ImageNet-1k) \cite{resnet} & 98.8 & 80.0 & 41.3\\
SeCo \cite{seco} & 97.1 & 82.6 & 63.6\\
ViT (ImageNet-22k)\cite{vit} & 93.1 & 84.7 & 73.6\\
SatMAE \cite{satmae} & 92.6 & 81.8 & 68.9\\
Swin (random)\cite{swin} & 66.9 & 80.6 & 65.7\\
Swin (ImageNet-22k) \cite{swin} & \textbf{99.0} & 85.7 & 79.5\\
\midrule
GFM & \textbf{99.0} & \textbf{86.3} & \textbf{80.7}\\
\midrule
\end{tabular}
}
\end{table}
\subsection{Segmentation} \label{sec:seg_detect}
Segmentation is a popular remote sensing application for enabling automated extraction of building footprints or land cover mappings over wide regions. We therefore conduct experiments on this task on two different datasets.
Vaihingen \cite{vaihingen} is an urban semantic segmentation dataset collected over Vaihingen, Germany at a GSD of 0.9m. We employ the data split implemented in the MMSegmentation library \cite{mmseg} for our experiments, with 344 training and 398 for validation, all with an image size of 512x512 pixels. The WHU Aerial building \cite{whu} dataset is sampled over Christchurch, New Zealand at a GSD of 0.3m. Image tiles are provided at $512\times 512$ pixels, split into 4736 for training and 2416 for evaluation.
We report the intersect of union (IoU) segmentation results for all methods in Table \ref{tab:seg}. ImageNet pretrained models are notably strong performers in all cases. On both datasets, SeCo lags substantially behind its ImageNet counterpart. Interestingly, SatMAE is able to bring improvement over ImageNet-22k on WHU, but fails to do so to a larger degree on Vaihingen.
However, our approach is able to leverage the already strong ImageNet-22k representations and guide them towards the geospatial domain, resulting in overall improvement.
\begin{table}
\caption{Results on the WHU Aerial and Vaihingen segmentation datasets. We finetune all methods for 40k iterations, and report the IoU for the building class on WHU and mean IoU (mIoU) across the 6 classes (impervious surface, building, low vegetation, tree, car, clutter) of Vaihingen.}
\label{tab:seg}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{cccc}
\toprule
Method & WHU Aerial & Vaihingen\\
\toprule
ResNet50 (ImageNet-1k) \cite{resnet} & 88.5 & 74.0\\
SeCo \cite{seco} & 86.7 & 68.9\\
ViT (ImageNet-22k) \cite{vit} & 81.6 & 72.6\\
SatMAE \cite{satmae} & 82.5 & 70.6 \\
Swin (random) \cite{swin} & 88.2 & 67.0\\
Swin (ImageNet-22k) \cite{swin} & 90.4 & 74.7 \\
\midrule
GFM & \textbf{90.7} & \textbf{75.3} \\
\midrule
\end{tabular}
\end{table}
\iffalse
\begin{table}
\caption{(super resolution) Results}
\label{tab:superres}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{ccc}
\toprule
Method & PSNR & SSIM\\
\toprule
ViT (ImageNet-22k) & - & -\\
SatMAE & - & -\\
Swin (random) & - & -\\
Swin (ImageNet-22k) & - & -\\
\midrule
GFM & - & -\\
\midrule
\end{tabular}
\end{table}
\fi
\begin{table}
\caption{SpaceNet2 Super-resolution Results}
\label{tab:spacenet}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{ccc}
\toprule
Method & PSNR $\uparrow$ & SSIM $\uparrow$\\
\toprule
ViT (ImageNet-22k)\cite{vit} & \textbf{23.279} & 0.619 \\
SatMAE \cite{satmae} & 22.742 & 0.621 \\
Swin (random) \cite{swin} & 21.825 & 0.594 \\
Swin (ImageNet-22k) \cite{swin} & 21.655 & 0.612 \\
\midrule
GFM & 22.599 & \textbf{0.638} \\
\midrule
\end{tabular}
\end{table}
\subsection{Super-resolution} \label{sec:superres}
In the previous experiments, we evaluated several common high-level tasks. Nonetheless, the low-level task of super-resolution is also important in the geospatial domain.
For this task, we repurpose the SpaceNet2 dataset, which contains 10,593 8-band images from four cities across the world: Las Vegas, Paris, Shanghai, and Khartoum. The data is provided at both a GSD of 1.24m (multi-spectral, 162x162 pixels) and 0.3m (pan-sharpened multispectral, 650x650 pixels). We formulate a super-resolution task, taking as input the 1.24m multi-spectral images and generating the 0.3m pan-sharpened equivalent. We evaluate the super-resolution performance of our model and several baselines with the peak signal-to-noise ratio (PSNR) and structural similarity index measure (SSIM) in Table \ref{tab:spacenet}.
The ViT-L ImageNet-22k model and our model are among the best in terms of PSNR and SSIM, respectively. Interestingly, SatMAE is not able to improve over this baseline. On the other hand, our method improves considerably over its ImageNet-22k baseline.
\subsection{Ablation Studies} \label{sec:ablation}
We perform multiple ablation studies on the choice of distillation stage, loss balancing term $\alpha$, and the GeoPile dataset components.
\subsection{Distillation Stage}
When implementing our feature map distillation objective, a natural question is at which point should the mappping take place. We experiment different locations by stage in the Swin transformer and calculate the corresponding ARP in Figure \ref{fig:ablation_plot}. Overall, performing the distillation after Stage 3 yields the highest ARP. Hence, we employ this scheme for all downstream experiments.
This result is also intuitively expected; distilling at Stage 3 gives a large portion of the model the supervisory signal from the teacher, while still allowing for purely domain-specific feature learning in the final layers.
\iffalse
\begin{table}
\caption{Feature Distillation Ablation \textcolor{red}{Make this a bar plot}}
\label{tab:dist_abl}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{cc}
\toprule
Position & ARP $\uparrow$ \\
\toprule
\midrule
Stage 1 & 0.75\\
Stage 2 & 1.04\\
Stage 3 & 2.39\\
Stage 4 & 1.75\\
\midrule
\end{tabular}
\end{table}
\fi
\begin{figure}
\centering
\includegraphics[width=0.8\columnwidth]{figures/ablation_plot.png}
\caption[]
{a) Distillation stage ablation results. b) $\alpha$ balancing tern ablation results.}
\label{fig:ablation_plot}
\end{figure}
\subsection{Balancing Term $\alpha$}
As discussed in Section \ref{sec:gfm}, our multi-objective loss in Equation \ref{eq:loss_combined} has the potential to use a balancing parameter $\alpha$. We ablate this parameter in Figure \ref{fig:ablation_plot} and report the corresponding ARP. Overall, we find that model with $\alpha=1.0$ performs the best.
\iffalse
\begin{table}
\caption{Balancing Term $\alpha$ Ablation. \textcolor{red}{Make this a bar plot}}
\label{tab:alpha_abl}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{cc}
\toprule
$\alpha$ & ARP \\
\toprule
0.1 & 1.10\\
0.5 & 1.64\\
1.0 & 2.39\\
\midrule
\end{tabular}
\end{table}
\fi
\subsection{GeoPile Pretraining Dataset}
To ablate components of the GeoPile, we remove each dataset individually to see its relative importance. Also, we compare using just the labeled data portion and using just the unlabeled NAIP imagery portion.
As expected, using just data from labeled datasets gives better performance with less images than using just images gathered from just NAIP. The human-curated samples in these datasets are more likely to contain relevant objects and features, as they each correspond to a particular class of interest. Still, unlabeled data like NAIP can be sourced easily and with scale. Further scaling of both labeled and unlabeled portions could further improve performance; however, it will also increase the training time and sustainability impact. Therefore, we maintain GeoPile at approximately 600,000 images.
\begin{table}
\caption{GeoPile pretraining dataset ablation. We remove each dataset individually from GeoPile and report the number of images remaining and resulting ARP. The row ``w/o curated datasets" removes all data other than NAIP imagery.}
\label{tab:data_ablation}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{ccc}
\toprule
Data & \# Images & ARP $\uparrow$ \\
\toprule
w/o WHU-RSD46 & 444,061 & 2.87\\
w/o MLRSNet & 451,793 & 3.30\\
w/o Resisc45 & 529,454 & 2.72\\
w/o PatternNet & 557,554 & 2.98\\
w/o curated datasets & 300,000 & 1.62\\
w/o NAIP & 260,954 & 2.65\\
\midrule
\end{tabular}
\end{table}
\subsection{Continual Pretraining Comparison}
In Table \ref{tab:init_ablation}, we compare our training paradigm with the vanilla continual pretraining approach of using the ImageNet-22k weights as initialization prior to beginning the pretraining step with GeoPile. We find this to be helpful in improving performance over simply starting from scratch. This validates the effectiveness of continual pretraining, even with simply initialization. However, the performance is still limited despite significant computation. On the other hand, our multi-objective pretraining paradigm significantly improves the overall performance with minimal computational needs and carbon impact.
\begin{table}
\caption{Continual pretraining comparison. In the first two rows, we experiment with simply initilizing the model with ImageNet-22k weights prior to conduction MIM training on GeoPile. However, our proposed GFM is both more effective and efficient.}
\label{tab:init_ablation}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{cccc}
\toprule
Method & Epochs & ARP $\uparrow$ & CO2 $\downarrow$\\
\toprule
ImageNet-22k Init. & 200 & 2.66 & 12.64\\
ImageNet-22k Init. & 800 & 2.98 & 50.56\\
GFM & 100 & 4.47 & 8.56\\
\midrule
\end{tabular}
\end{table}
\section{Conclusion}
In summary, this paper investigates a sustainable approach for building geospatial foundation models. To this end, we first construct a concise yet diverse collection of data from various sources for effective pretraining. Second, we propose a multi-objective continual pretraining paradigm, in which we leverage the strong representations of ImageNet-22k to guide and quicken learning, while simultaneously providing the freedom to learn valuable in-domain features through self-supervised learning on geospatial data.
We hope our GFM is one step forward in inspiring the path towards high-performing yet sustainable geospatial foundation models.
{\small
\bibliographystyle{ieee_fullname}
\section{Introduction} \label{sec:intro}
\begin{figure}
\centering
\includegraphics[width=0.9\columnwidth]{figures/spider_all.png}
\caption[]
{Our sustainable geospatial foundation model (GFM) achieves strong performance on a broad set of tasks in comparison to other state-of-the-art geospatial pretraining methods (SeCo \cite{seco}, SatMAE \cite{satmae}) and ImageNet supervised pretraining baselines.}
\label{fig:model_comparison}
\end{figure}
With the rise of large-scale satellite and aerial imageries~\cite{landsat,naip}, geospatial technologies are becoming increasingly important. Progress in this domain can substantially improve our ability to understand the earth and how we interact with it.
Nonetheless, in the current era of deep learning, data fuels progress. Thankfully, the amount of data and tasks in the geospatial domain continues to grow. This has recently been made evident in a survey \cite{earthnets} compiling hundreds of published datasets for earth observation. Beyond curated datasets, openly available satellite imagery programs like Sentinel~\cite{sentinel}, Landsat~\cite{landsat}, and National Agriculture Imagery Program (NAIP)~\cite{naip} also provide a plethora of data for use.
With such a vast interest in the application of geospatial and remote sensing data,
the computer vision community has been continually investing in designing better algorithms to harness the available data and improve performance on various tasks.
Particularly, with the rising popularity of foundation models in vision and natural language, many works have worked on building strong pretrained models specific to the geospatial domain \cite{seco, gassl, satmae, millionAID_supervised_pretraining}.
These methods typically train a network from scratch on a large corpus of remote sensing imagery. Unfortunately, this can require a significant amount of data and training time to achieve good performance, especially when employing large state-of-the-art transformer models.
However, in this pursuit of a stronger geospatial foundation model, one potentially useful tool has been largely forgotten. ImageNet pretrained models are readily available for the majority of state-of-the-art architectures. More recently, we now have many models trained on the larger scale ImageNet-22k~\cite{imagenet} dataset, providing even stronger and more general representations than before.
Rather than beginning the pretraining process tabula rasa, could these ImageNet representations serve as a base on which stronger geospatial models can be built?
In the same spirit, continual pretraining has been practiced in the NLP domain with success in various works \cite{dontStopPretraining, continual_temporal, continual_mixedLang}. In this paradigm, existing foundation models are further improved for a specific domain or task through a secondary pretraining stage. In principle, we reason that such a paradigm has the potential to produce strong geospatial models in an efficient and sustainable manner.
To this end, we investigate a sustainable approach for building geospatial foundation models. Specifically, we form a multi-objective continual pretraining paradigm, simultaneously leveraging ImageNet pretrained features and self-supervised learning on a concise collection of geospatial imagery. In our investigations, we discover two important factors in the process.
\begin{itemize}
\item \textbf{Data choice matters.} We find that the selection of pretraining data matters, even within the geospatial domain. Therefore, we select a diverse collection of data from various sources to capture a wider variety of general remote sensing scenes, which we term as GeoPile. Conducting masked image modeling with GeoPile is significantly more effective and sample efficient compared to other common alternatives (see Section \ref{sec:data}).
\item \textbf{Continual pretraining.} Available pretrained models on diverse datasets like ImageNet-22k should not be ignored when building geospatial foundation models. Rather, by leveraging their representations, we can build strong models for geospatial applications in a sustainable manner. To this end, we investigate a multi-objective continual pretraining paradigm for simple and effective learning (see Section \ref{sec:gfm}). By continual pretraining, we show that our newly proposed Geospatial Foundation Model (GFM) outperforms previous state-of-the-art geospatial pretrained models on a broad set of tasks, as shown in Figure~\ref{fig:model_comparison}.
\end{itemize}
\section{Related Work} \label{sec:related}
\subsection{Masked Image Modeling}
Masked image modeling (MIM) has been proposed in various forms in recent years, but has quickly become very popular as an effective pretraining task.
In general, the goal is to learn from data in a self-supervised manner by asking the model to generate pixel values for intentionally-withheld regions in an image.
\cite{context_encoders} is an early work with an aim of learning strong visual representations through inpainting masked regions. In \cite{generative_pretrain}, Chen et. al train a large transformer to predict pixels autoregressively. After the introduction of vision transformers (ViT) \cite{vit}, many works continued to improve various MIM variants. \cite{beit} and \cite{ibot} take inspiration from BERT \cite{bert} in natural language processing, and tokenize the image patches with either a pretrained model or jointly trained online tokenizer, with the objective being to reconstruct at a token-level rather than raw pixels. Recently, \cite{simmim} and \cite{mae} show that a masked image modeling task of simply regressing directly on the image pixels is sufficient and effective. In this work, we leverage the framework from \cite{simmim}, as it is compatible with hierarchical transformer architectures \cite{swin}.
\subsection{Geospatial Pretraining}
Various works have experimented with employing supervised or self-supervised pretraining paradigms in the geospatial domain. The classical work of \cite{indomain}, and more recent paper \cite{millionAID_supervised_pretraining}, investigate supervised pretraining on individual datasets of various sizes. Interestingly, these still often found the ImageNet pretrained models to perform very well, particularly with vision transformers \cite{vit, swin}.
Other works have explored self-supervised learning paradigms for remote sensing, primarily focused on contrastive methods. \cite{seco} and \cite{gassl} employ a MoCo \cite{mocov2} style objective using spatially aligned but temporally different images as the positive pairs. \cite{saumoco} and \cite{tile2vec} also utilize a MoCo-inspired objective, but specify a cropping procedure to generate positives and negatives within and across images. \cite{colorOutofSpace} employs a colorization objective on Sentinel-2 imagery utilizing the various spectral bands. Most recently, SatMAE \cite{satmae} explores the use of masked image modeling to train a large ViT model. This work is similar in some respect to ours, as we also train a transformer model with an MIM objective. However, we find that SatMAE often does not perform better than the off-the-shelf ImageNet-22k pretrained ViT (Section \ref{sec:experiments}). This indicates both the difficulty of building strong geospatial foundation models from scratch and highlights the potential usefulness of leveraging continual pretraining instead, as we investigate in this work.
In this work, we develop our pretraining objective based on a masked image modeling approach like \cite{simmim, mae}.
MIM has recently been shown to be particularly effective in the natural image domain, surpassing many contrastive works and being shown to be friendlier to downstream optimization \cite{simmim, mae, ibot, beit, dark_secrets}. Exploration of the masked image modeling framework in geospatial applications is still in its early stages, and could help allivate some concerns with contrastive approaches in this domain.
Particularly, the choice of augmentations with contrastive methods can be quite difficult, as common selections such as greyscale, color jitter and others that heavily affect the intensity of the image can instill undesirable invariances \cite{indomain}. On the other hand, MIM objectives like \cite{simmim, mae} rely only on simple spatial augmentations such as flipping and cropping. Furthermore, a common remote sensing application is that of change detection, which requires a model to detect changes in two images from the same location but at different times. In order to still be effective on this task, works that use contrastive approaches on temporal positives introduce various design choices. For instance, SeCo \cite{seco} creates multiple feature subspaces during pretraining, each one invariant to a separate form of augmentation. \cite{matter} also employs temporal positives, but instead chooses the sampling locations for the pretraining data to ensure that image pairs contain primarily natural illumination and viewing angle variant, without major changes such as new urban developments.
\begin{figure*}
\centering
\includegraphics[trim={160 160 160 160},clip, width=0.9\textwidth]{figures/samples.pdf}
\caption[]
{We visualize some example images from the pretraining datasets. From left to right: ImageNet, Sentinel-2, and GeoPile. Sentinel-2 has noticeably much lower feature diversity within a single image and across images than that of ImageNet or our GeoPile pretraining dataset.}
\label{fig:data_comparison_visual}
\end{figure*}
\subsection{Continual Pretraining}
Continual pretraining has been primarily introduced in the natural language domain \cite{dontStopPretraining, continual_temporal, continual_mixedLang}, in order to improve large language models (LLM). \cite{dontStopPretraining} illustrates the viability of two additional stages of pretraining, using in-domain data (domain-adaptive), and then even further using task-specific data (task-adaptive). \cite{continual_temporal} proposes a continual training paradigm for enabling temporal reasoning abilities to pretrained language models. \cite{continual_mixedLang} focus on using continual pretraining to enable mixed language neural machine translation. In the vision domain, \cite{medseg} employs a BYOL \cite{byol} style continual pretraining paradigm for 2D medical image segmentation. \cite{selfimproveself} explores a hierarchical pretraining approach for task adaptation. However, they primarily focus on adapting to a specific downstream task at a time, employing three training stages on top of an existing pretrained model for each task individually. In contrast, we employ one efficient in-domain pretraining setting that can generalize to many downstream tasks, as illustrated in Section \ref{sec:experiments}. Furthermore, rather than directly loading the pretrained weights from existing models as initialization, we find instead that leveraging the representations as an auxiliary distillation objective during the pretraining process enables learning strong in-domain representations in a sustainable manner.
\section{Methodology}
We aim to investigate a sustainable approach for building geospatial foundation models. This leads us to two key insights. First, the selection of pretraining data matters, even within the geospatial domain. We discuss our empirical findings to this end in Section \ref{sec:data}. Second, available pretrained models on diverse datasets like ImageNet-22k should not be ignored when building geospatial foundation models. In fact, by leveraging their representations, we can build strong models for geospatial applications in a sustainable manner. These discussions can be found in Section \ref{sec:gfm}.
\subsection{Pre-training Data Matters} \label{sec:data}
A particularly common choice of source data among geospatial contrastive pretraining works is Sentinel-2 imagery \cite{seco, matter, colorOutofSpace} due to its large corpus of available data and ease of access.
Therefore, to begin our study, we first gather a pretraining dataset of ~1.3 million (matching the scale of ImageNet-1k~\cite{imagenet}) Sentinel-2 images using the sampling technique from \cite{seco}.
After gathering the Sentinel-2 data, we employ it to pretrain a Swin-B \cite{swin} model with the masked image modeling (MIM) objective from \cite{simmim}.
We then finetune and evaluate this model on a wide variety of downstream datasets to get a broad understanding of its performance potential in many tasks (see Section \ref{sec:experiments} for task details). For a comparison, we finetune the ImageNet-22k pretrained Swin-B from the official Swin Transformer repository \cite{swin} on all downstream tasks as a baseline. In order to compare these models across all tasks, we introduce an average relative performance metric (ARP) in which we take the relative percentage difference on each task with respect to the ImageNet-22k baseline, and then average that difference:
\begin{equation} \label{eg:arp}
\text{ARP}(M) = \frac{1}{N}\sum_{i=1}^N \frac{\text{score}(M, \text{task}_i) -\text{score}( \text{baseline}, \text{task}_i)}{\text{score}( \text{baseline}, \text{task}_i)}.
\end{equation}
\noindent Here ``baseline'' is the Swin-B model pretrained on ImageNet-22k and finetuned on ImageNet-1k, as mentioned above. $M$ denotes the model for performance evaluation, and N is the number of tasks. There are $7$ tasks used in Section~\ref{sec:experiments} covering important geospatial tasks such as classification, multi-label classification, semantic segmentation, change detection, and super-resolution. The reported ARP value is scaled by 100 to show as a percentage.
We compare these two models in Table \ref{tab:data}.
Interestingly, we find that the Sentinel-2 model performs poorly on downstream tasks compared to the ImageNet-22k baseline.
To investigate this further, we also pretrain a model using MIM on ImageNet-1k,
and find this actually performs better than using Sentinel-2 imagery.
While there is obviously a degree of domain shift between ImageNet and remote sensing data, we reason that Sentinel-2 data alone lacks sufficient feature diversity for a strong pretraining dataset. As a basic indicator, we calculate the average image entropy over a randomly sampled set of 3000 images for both ImageNet-1k and our collected Sentinel-2 data and find it to be 5.1 and 3.9 respectively. Note that entropy is certainly not the sole factor at play, such an evaluation can still provides insights into the advantages of ImageNet over sentinel. For MIM objectives, training data with a substantially lower entropy can make for an easier reconstruction task, since masked regions may be more similar to their neighbors. Therefore, the network does not have to work as hard to fill in the blanks, limiting the learning potential. Qualitatively, we also visualize multiple samples from ImageNet-1k and Sentinel-2 in the top row of Figure \ref{fig:data_comparison_visual}. The feature diversity within a single image and across images of Sentinel-2 is perceivably lower than that of ImageNet. This result indicates that a comparatively narrow scope of features is provided to the model when pretraining with Sentinel-2.
Therefore, we set out to collect a diverse geospatial pretraining dataset. Sourcing from both labeled and unlabelled data, we form a new pretraining dataset which we term GeoPile. The breakdown of GeoPile is shown in Table \ref{tab:geopile}. For textural detail, we ensure a variety of ground sample distances (GSD), including images with much higher resolution imagery than Sentinel-2 (which has a GSD of 10m). Furthermore, the selected labeled datasets encompass a wide variety of classes from general remote sensing scenes, ensuring visual diversity across samples. We calculate the average entropy of our GeoPile dataset, and find it to be 4.6, much closer to that of ImageNet-1k. Furthermore, the textural and visual diversity is qualitatively evident in Figure \ref{fig:data_comparison_visual}. As shown in Table \ref{tab:data}, the enhancing effect of the data selection is evident in the substantial performance increase.
To further improve the performance of our pretrained model in comparison to the ImageNet-22k baseline, we increase the number of training epochs in the last rows of Table \ref{tab:data}. While we are able to make improvements, this comes at the cost of substantially more compute and carbon footprint for marginal gain. Therefore, we ask the question: can we significantly improve performance with minimal compute and carbon footprint overhead? To this end, we investigate a simple and sustainable approach for building geospatial foundation models with strong performance.
\begin{table}
\caption{Dataset Analysis. To evaluate each method, we finetune the pretrained model on seven different tasks, outlined in Section \ref{sec:experiments} and report the ARP metric defined in Equation \ref{eg:arp}.
Overall, our collected GeoPile pretraining dataset significantly improves downstream performance. To further improve the performance in a sustainable manner, we introduce our continuous training paradigm GFM. We show the ARP and CO2 estimations \cite{co2} for GFM trained on GeoPile.}
\label{tab:data}
\centering
\setlength\tabcolsep{4.0pt}
\begin{tabular}{ccccc}
\toprule
Method & \# Images & Epochs & ARP $\uparrow$ & CO2 $\downarrow$\\
\toprule
ImageNet-22k Sup. & 14M & - & 0.0 & -\\
\midrule
ImageNet-1k & 1.3M & 100 & 1.82 & 17.76\\
Sentinel-2 \cite{seco} & 1.3M & 100 & -5.53 & 17.76\\
GeoPile & 600k & 200 & 2.02 & 12.64\\
GeoPile & 600k & 800 & 2.44 & 50.56\\
\midrule
GFM & 600k & 100 & 4.47 & 8.56\\
\midrule
\end{tabular}
\end{table}
\begin{table}
\caption{Breakdown of datasets in the GeoPile. We gather approximately 600k samples from a combination of labeled and unlabeled satellite imagery.}
\label{tab:geopile}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{cccc}
\toprule
Dataset & \# Images & GSD & \# Classes\\
\toprule
NAIP\cite{naip} & 300,000 & 1m & n/a\\
RSD46-WHU \cite{RSD46-WHU} & 116,893 & 0.5m - 2m & 46\\
MLRSNet \cite{MLRSNet} & 109,161 & 0.1m - 10m & 60\\
RESISC45 \cite{RESISC45} & 31,500 & 0.2m - 30m & 45\\
PatternNet \cite{PatternNet} & 30,400 & 0.1m - 0.8m & 38\\
\midrule
\end{tabular}
\end{table}
\subsection{Sustainable GFM} \label{sec:gfm}
\begin{figure*}
\centering
\includegraphics[trim={100 60 100 60},clip, width=0.75\textwidth]{figures/gfm.pdf}
\caption[]
{Our GFM multi-objective continual pretraining paradigm. Two parallel branches, one initialized with ImageNet-22k weights (top) and another from random initialization (bottom).
Blue functional blocks are frozen during training, and green ones are trained. In a teacher-student fashion, we leverage the intermediate features of an ImageNet-22k pretrained model to guide and quicken learning. Furthermore, we build in an MIM objective on the student branch to allow for learning valuable in-domain features directly from the geospatial data.}
\label{fig:gfm}
\end{figure*}
Nowadays, state-of-the-art models release pretrained weights on very large and diverse datasets like ImageNet-22k. While not perfect for geospatial tasks, these models still contain a vast amount of useful knowledge that is generalizable across many settings.
Nonetheless, the majority of previous works in geospatial pretraining neglect the available ImageNet representations, which is not ideal, especially for large transformer models that are notoriously data hungry and computationally expensive to train.
Instead, we reason that the valuable knowledge available in these large-scale models should be leveraged to produce strong performance with minimized overhead. To this end, we propose an unsupervised multi-objective training paradigm for sustainable training of geospatial foundation models, illustrated in Figure \ref{fig:gfm}.
There are two main components in our framework. First, we randomly initialize an encoder and decoder set up for MIM as in \cite{simmim}. During training, the input is randomly masked, and the network attempts to reconstruct the image at the output. This MIM objective is enforced with an L1 loss. \cite{simmim}:
\begin{equation}
\mathcal{L}_{MIM}=\frac{\left\|\mathbf{O}_\kappa-\mathbf{G}_\kappa\right\|_1}{N},
\end{equation}
where $\mathbf{O}_{\kappa}$ is the original pixel information from the masked regions, $\mathbf{G}_{\kappa}$ are the generated reconstructions for those masked regions, and $N$ is the total number of masked pixels.
To leverage the strong representations from the ImageNet model, we initialize a second encoder branch up to a chosen stage $L$ and load the pretrained weights.
This branch will serve as a form of teacher during the training process to the other "student" branch, which will serve as our final GFM model. For the ImageNet teacher, we freeze the weight, to both ensure that the structured representations are maintained during the training process, and also reduce the computation required during optimization.
Rather than using the masked input as in the student branch, the teacher receives the unmasked image as input,
and provides a feature output $f_{L}^{T}$ at stage $L$. This feature has access to the full context of the input, enabling it to capture informative representations.
We utilize this feature to guide the representations of the student, and form a secondary objective with the cosine similarity between branch features:
\begin{equation}
\mathcal{L}_{feat} = -\frac{P(f_{L}^{S})}{\left\|P(f_{L}^{S})\right\|_2} \cdot \frac{f_{L}^{T}}{\left\|f_{L}^{T}\right\|_2},
\end{equation}
where $f_{L}^{S}$ and $f_{L}^{T}$ are the intermediate features of the student and teacher branches at stage $L$, and $P$ is an linear projection layer. Therefore, the final loss during training is simply the summation of these objectives:
\begin{equation} \label{eq:loss_combined}
\mathcal{L} = \mathcal{L}_{MIM} + \alpha\mathcal{L}_{feat}.
\end{equation}
where $\alpha$ is a balancing term, which we find is best simply with $\alpha=1.0$ (Section \ref{sec:ablation}).
This training paradigm enables an ideal two-fold optimization. Distillation from the intermediate features of the teacher ensure that the student can benefit from the teacher's diverse knowledge, learning more in less time. Furthermore, the student is simultaneously given freedom to adapt to in-domain data through its own pretraining objective, gathering new domain-specific features to improve performance.
We analyze the ARP and sustainability potential of this approach in Table \ref{tab:data}. Notably, our GFM is able to achieve better overall performance with substantially less computation and emissions impact \footnote{CO2 estimations were completed with \url{https://mlco2.github.io/impact#compute} from \cite{co2}} compared to tabula rasa pretraining with the same dataset, illustrating that our multi-objective continual pretraining paradigm is a sustainable method for training these models.
\section{Experiments} \label{sec:experiments}
To verify the effectiveness of our model in detail, we conduct experiments on eight geospatial datasets of various tasks including change detection (Section \ref{sec:change_det}), classification (Section \ref{sec:classification}), segmentation (Section \ref{sec:seg_detect}), and super-resolution (Section \ref{sec:superres}).
\subsection{Change Detection} \label{sec:change_det}
Change detection is a particularly important remote sensing task, helping us understand how humans interact with our planet over time, and natural phenomena that change our planet's landscape. We conduct experiments on both the Onera Satellite Change Detection (OSCD \cite{OSCD}) in Table \ref{tab:OSCD} and DSIFN \cite{DSIFN} in Table \ref{tab:DSFIN}.
OSCD consists of 14 image pairs extracted from various regions around the world within a three year period of 2015 to 2018. The images are taken from Sentinel-2 with GSDs ranging from 10m to 60m, and split into 14 images for training and 10 for evaluation. The annotations indicate whether the change has occurred on a pixel level, and focus primarily on urban developments. Similarly, we also test our method on DSIFN dataset. This dataset contains high-resolution imagery, such as WorldView-3 and GeoEys-1 \cite{DSIFN}. This dataset contains 3490 high resolution samples for training and 48 images for evaluation respectively. Every pair of images from a given location at two different timestamps will be fed into the swin encoder \cite{swin} for feature extraction. The difference between the features from each pair is computed and fed into to an UPerNet \cite{Upernet} to generate the final binary segmentation masks \cite{seco, siamdiff}. The encoder is initialized with the pretrained weights.
For both datasets, we report the precision, recall, and F1 score on the ``change" class. As the results presented from OSCD (Table \ref{tab:OSCD} and Figure \ref{fig:OSCD}) and DSIFN (Table \ref{tab:DSFIN}), GFM shows a consistent improvement over the ImageNet-22k baseline across both datasets. Notably, SatMAE is able to improve over its ImageNet-22k baseline on OSCD, but lags behind on DSIFN. This further highlights the difficulty of training large vision transformers from scratch that can perform consistently across different GSDs.
\begin{table}
\caption{Onera Satellite Change Detection Results}
\label{tab:OSCD}
\centering
\setlength\tabcolsep{5.0pt}
\resizebox{\columnwidth}{!}{
\begin{tabular}{cccc}
\toprule
Method & Precision $\uparrow$ & Recall $\uparrow$ & F1 $\uparrow$\\
\toprule
ResNet50 (ImageNet-1k) \cite{resnet} & \textbf{70.42} & 25.12 & 36.20\\
SeCo \cite{seco} & 65.47 & 38.06 & 46.94\\
MATTER \cite{matter} & 61.80 & 57.13 & 59.37\\
ViT (ImageNet-22k) \cite{vit} & 48.34 & 22.52 & 30.73\\
SatMAE \cite{satmae} & 48.19 & 42.24 & 45.02\\
Swin (random)\cite{swin} & 51.80 & 47.69 & 49.66\\
Swin (ImageNet-22k)\cite{swin} & 46.88 & 59.28 & 52.35\\
\midrule
GFM & 58.07 & \textbf{61.67} & \textbf{59.82}\\
\midrule
\end{tabular}
}
\end{table}
\begin{table}
\caption{DSFIN Change Detection Results}
\label{tab:DSFIN}
\centering
\setlength\tabcolsep{5.0pt}
\resizebox{\columnwidth}{!}{
\begin{tabular}{cccc}
\toprule
Method & Precision $\uparrow$ & Recall $\uparrow$ & F1 $\uparrow$\\
\toprule
ResNet50 (ImageNet-1k) \cite{resnet} & 28.74 & \textbf{92.07} & 43.80\\
SeCo \cite{seco} & 39.68 & 81.02 & 53.27\\
ViT (ImageNet-22k) \cite{vit} & 70.77 & 66.34 & 68.49\\
SatMAE \cite{satmae} & 70.45 & 60.29 & 64.98\\
Swin (random)\cite{swin} & 57.97 & 62.06 & 59.94\\
Swin (ImageNet-22k)\cite{swin} & 67.11 & 72.33 & 69.62\\
\midrule
GFM & \textbf{74.83} & 67.98 & \textbf{71.24}\\
\midrule
\end{tabular}
}
\end{table}
\begin{figure}
\centering
\includegraphics[width=0.8\columnwidth]{figures/OSCD.png}
\caption[]
{Qualitative results on OSCD. White, green, red colors represent true positive, false positive, and false negative respectively.}
\label{fig:OSCD}
\end{figure}
\subsection{Classification} \label{sec:classification}
Another common remote sensing application is that of classification. We evaluate two datasets common in the literature \cite{seco, matter}: UC Merced Land Use Dataset \cite{ucm} and BigEarthNet \cite{BEN}.
The UC Merced Land Use Dataset is a classic dataset in the remote sensing field. It contains 21 classes, each with 100 images at 256x256 pixels and an approximate GSD of 1 foot. We split the data into train and validation according to \cite{data_splits}.
BigEarthNet \cite{BEN} (BEN) is a large-scale remote sensing dataset for multi-label classification. The data consist of 12-band Sentinel-2 images with sizes of 120x120, 60x60, and 20x20 pixels for the bands at 10m, 20m, and 60m GSDs, respectively.
We employ the data split and 19 class evaluation as common in the literature \cite{indomain, seco, satmae}.
In Table \cite{BEN}, we report the classification accuracy on UC Merced (UCM) and mean average precision results on BigEarthNet (BEN) for all methods.
On UC Merced, we note the SeCo \cite{seco} pretrained model performs significantly worse than its ImageNet-1k pretrained counterpart with ResNet-50.
These two datasets are very different in both classes, satellite source, and GSDs, and therefore having a diverse feature knowledge is imperative to maintaining performance despite these distinctions.
Our model can provide robust performance in both cases by leveraging ImageNet representation and remote sensing data in its learning. Furthermore, one key motivation for training a geospatial foundation model is to improve the sample efficiency for downstream tasks. Notably, we find that our model maintains strong performance on BigEarthNet, even when only given 1\% of the training data.
\begin{table}
\caption{UC Merced classification accuracy and BigEarthNet multi-label classification mean average precision results on the validation set.}
\label{tab:BEN}
\centering
\setlength\tabcolsep{5.0pt}
\resizebox{\columnwidth}{!}{
\begin{tabular}{cccc}
\toprule
Method & UCM & BEN 10\% & BEN 1\%\\
\toprule
ResNet50 (ImageNet-1k) \cite{resnet} & 98.8 & 80.0 & 41.3\\
SeCo \cite{seco} & 97.1 & 82.6 & 63.6\\
ViT (ImageNet-22k)\cite{vit} & 93.1 & 84.7 & 73.6\\
SatMAE \cite{satmae} & 92.6 & 81.8 & 68.9\\
Swin (random)\cite{swin} & 66.9 & 80.6 & 65.7\\
Swin (ImageNet-22k) \cite{swin} & \textbf{99.0} & 85.7 & 79.5\\
\midrule
GFM & \textbf{99.0} & \textbf{86.3} & \textbf{80.7}\\
\midrule
\end{tabular}
}
\end{table}
\subsection{Segmentation} \label{sec:seg_detect}
Segmentation is a popular remote sensing application for enabling automated extraction of building footprints or land cover mappings over wide regions. We therefore conduct experiments on this task on two different datasets.
Vaihingen \cite{vaihingen} is an urban semantic segmentation dataset collected over Vaihingen, Germany at a GSD of 0.9m. We employ the data split implemented in the MMSegmentation library \cite{mmseg} for our experiments, with 344 training and 398 for validation, all with an image size of 512x512 pixels. The WHU Aerial building \cite{whu} dataset is sampled over Christchurch, New Zealand at a GSD of 0.3m. Image tiles are provided at $512\times 512$ pixels, split into 4736 for training and 2416 for evaluation.
We report the intersect of union (IoU) segmentation results for all methods in Table \ref{tab:seg}. ImageNet pretrained models are notably strong performers in all cases. On both datasets, SeCo lags substantially behind its ImageNet counterpart. Interestingly, SatMAE is able to bring improvement over ImageNet-22k on WHU, but fails to do so to a larger degree on Vaihingen.
However, our approach is able to leverage the already strong ImageNet-22k representations and guide them towards the geospatial domain, resulting in overall improvement.
\begin{table}
\caption{Results on the WHU Aerial and Vaihingen segmentation datasets. We finetune all methods for 40k iterations, and report the IoU for the building class on WHU and mean IoU (mIoU) across the 6 classes (impervious surface, building, low vegetation, tree, car, clutter) of Vaihingen.}
\label{tab:seg}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{cccc}
\toprule
Method & WHU Aerial & Vaihingen\\
\toprule
ResNet50 (ImageNet-1k) \cite{resnet} & 88.5 & 74.0\\
SeCo \cite{seco} & 86.7 & 68.9\\
ViT (ImageNet-22k) \cite{vit} & 81.6 & 72.6\\
SatMAE \cite{satmae} & 82.5 & 70.6 \\
Swin (random) \cite{swin} & 88.2 & 67.0\\
Swin (ImageNet-22k) \cite{swin} & 90.4 & 74.7 \\
\midrule
GFM & \textbf{90.7} & \textbf{75.3} \\
\midrule
\end{tabular}
\end{table}
\subsection{Super-resolution} \label{sec:superres}
In the previous experiments, we evaluated several common high-level tasks. Nonetheless, the low-level task of super-resolution is also important in the geospatial domain.
For this task, we repurpose the SpaceNet2 dataset, which contains 10,593 8-band images from four cities across the world: Las Vegas, Paris, Shanghai, and Khartoum. The data is provided at both a GSD of 1.24m (multi-spectral, 162x162 pixels) and 0.3m (pan-sharpened multispectral, 650x650 pixels). We formulate a super-resolution task, taking as input the 1.24m multi-spectral images and generating the 0.3m pan-sharpened equivalent. We evaluate the super-resolution performance of our model and several baselines with the peak signal-to-noise ratio (PSNR) and structural similarity index measure (SSIM) in Table \ref{tab:spacenet}.
The ViT-L ImageNet-22k model and our model are among the best in terms of PSNR and SSIM, respectively. Interestingly, SatMAE is not able to improve over this baseline. On the other hand, our method improves considerably over its ImageNet-22k baseline.
\iffalse
\begin{table}
\caption{(super resolution) Results}
\label{tab:superres}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{ccc}
\toprule
Method & PSNR & SSIM\\
\toprule
ViT (ImageNet-22k) & - & -\\
SatMAE & - & -\\
Swin (random) & - & -\\
Swin (ImageNet-22k) & - & -\\
\midrule
GFM & - & -\\
\midrule
\end{tabular}
\end{table}
\fi
\begin{table}
\caption{SpaceNet2 Super-resolution Results}
\label{tab:spacenet}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{ccc}
\toprule
Method & PSNR $\uparrow$ & SSIM $\uparrow$\\
\toprule
ViT (ImageNet-22k)\cite{vit} & \textbf{23.279} & 0.619 \\
SatMAE \cite{satmae} & 22.742 & 0.621 \\
Swin (random) \cite{swin} & 21.825 & 0.594 \\
Swin (ImageNet-22k) \cite{swin} & 21.655 & 0.612 \\
\midrule
GFM & 22.599 & \textbf{0.638} \\
\midrule
\end{tabular}
\end{table}
\subsection{Ablation Studies} \label{sec:ablation}
We perform multiple ablation studies on the choice of distillation stage, loss balancing term $\alpha$, and the GeoPile dataset components.
\subsection{Distillation Stage}
When implementing our feature map distillation objective, a natural question is at which point should the mappping take place. We experiment different locations by stage in the Swin transformer and calculate the corresponding ARP in Figure \ref{fig:ablation_plot}. Overall, performing the distillation after Stage 3 yields the highest ARP. Hence, we employ this scheme for all downstream experiments.
This result is also intuitively expected; distilling at Stage 3 gives a large portion of the model the supervisory signal from the teacher, while still allowing for purely domain-specific feature learning in the final layers.
\iffalse
\begin{table}
\caption{Feature Distillation Ablation \textcolor{red}{Make this a bar plot}}
\label{tab:dist_abl}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{cc}
\toprule
Position & ARP $\uparrow$ \\
\toprule
\midrule
Stage 1 & 0.75\\
Stage 2 & 1.04\\
Stage 3 & 2.39\\
Stage 4 & 1.75\\
\midrule
\end{tabular}
\end{table}
\fi
\begin{figure}
\centering
\includegraphics[width=0.8\columnwidth]{figures/ablation_plot.png}
\caption[]
{a) Distillation stage ablation results. b) $\alpha$ balancing tern ablation results.}
\label{fig:ablation_plot}
\end{figure}
\subsection{Balancing Term $\alpha$}
As discussed in Section \ref{sec:gfm}, our multi-objective loss in Equation \ref{eq:loss_combined} has the potential to use a balancing parameter $\alpha$. We ablate this parameter in Figure \ref{fig:ablation_plot} and report the corresponding ARP. Overall, we find that model with $\alpha=1.0$ performs the best.
\iffalse
\begin{table}
\caption{Balancing Term $\alpha$ Ablation. \textcolor{red}{Make this a bar plot}}
\label{tab:alpha_abl}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{cc}
\toprule
$\alpha$ & ARP \\
\toprule
0.1 & 1.10\\
0.5 & 1.64\\
1.0 & 2.39\\
\midrule
\end{tabular}
\end{table}
\fi
\subsection{GeoPile Pretraining Dataset}
To ablate components of the GeoPile, we remove each dataset individually to see its relative importance. Also, we compare using just the labeled data portion and using just the unlabeled NAIP imagery portion.
As expected, using just data from labeled datasets gives better performance with less images than using just images gathered from just NAIP. The human-curated samples in these datasets are more likely to contain relevant objects and features, as they each correspond to a particular class of interest. Still, unlabeled data like NAIP can be sourced easily and with scale. Further scaling of both labeled and unlabeled portions could further improve performance; however, it will also increase the training time and sustainability impact. Therefore, we maintain GeoPile at approximately 600,000 images.
\begin{table}
\caption{GeoPile pretraining dataset ablation. We remove each dataset individually from GeoPile and report the number of images remaining and resulting ARP. The row ``w/o curated datasets" removes all data other than NAIP imagery.}
\label{tab:data_ablation}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{ccc}
\toprule
Data & \# Images & ARP $\uparrow$ \\
\toprule
w/o WHU-RSD46 & 444,061 & 2.87\\
w/o MLRSNet & 451,793 & 3.30\\
w/o Resisc45 & 529,454 & 2.72\\
w/o PatternNet & 557,554 & 2.98\\
w/o curated datasets & 300,000 & 1.62\\
w/o NAIP & 260,954 & 2.65\\
\midrule
\end{tabular}
\end{table}
\subsection{Continual Pretraining Comparison}
In Table \ref{tab:init_ablation}, we compare our training paradigm with the vanilla continual pretraining approach of using the ImageNet-22k weights as initialization prior to beginning the pretraining step with GeoPile. We find this to be helpful in improving performance over simply starting from scratch. This validates the effectiveness of continual pretraining, even with simply initialization. However, the performance is still limited despite significant computation. On the other hand, our multi-objective pretraining paradigm significantly improves the overall performance with minimal computational needs and carbon impact.
\begin{table}
\caption{Continual pretraining comparison. In the first two rows, we experiment with simply initilizing the model with ImageNet-22k weights prior to conduction MIM training on GeoPile. However, our proposed GFM is both more effective and efficient.}
\label{tab:init_ablation}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{cccc}
\toprule
Method & Epochs & ARP $\uparrow$ & CO2 $\downarrow$\\
\toprule
ImageNet-22k Init. & 200 & 2.66 & 12.64\\
ImageNet-22k Init. & 800 & 2.98 & 50.56\\
GFM & 100 & 4.47 & 8.56\\
\midrule
\end{tabular}
\end{table}
\section{Conclusion}
In summary, this paper investigates a sustainable approach for building geospatial foundation models. To this end, we first construct a concise yet diverse collection of data from various sources for effective pretraining. Second, we propose a multi-objective continual pretraining paradigm, in which we leverage the strong representations of ImageNet-22k to guide and quicken learning, while simultaneously providing the freedom to learn valuable in-domain features through self-supervised learning on geospatial data.
We hope our GFM is one step forward in inspiring the path towards high-performing yet sustainable geospatial foundation models.
{\small
\bibliographystyle{ieee_fullname}
\section{Overview}
The supplementary material is organized into the following sections:
\begin{itemize}
\item Section~\ref{training_details}: Training details for the pretraining stage and all downstream tasks.
\item Section~\ref{carbon}: Details on training time and calculations of CO2 impact.
\item Section~\ref{mim_ablation}: Experimental ablation of the GFM multi-objective training.
\item Section~\ref{temporal}: Temporal pairs experiment in our multi-objective training.
\item Section~\ref{superres_residual}: Further analysis on the SpaceNet2 super-resolution task.
\item Section~\ref{broader_impact}: Discussion on the broader impact and limitations of our work.
\end{itemize}
\section{Training Details} \label{training_details}
We provide the training details for the various stages and tasks in our evaluation. \ul{Code and GeoPile dataset will be made publicly available upon acceptance}.
\textbf{Pretraining}:
We employ 8 NVIDIA A100 GPUs with a batch size of 2048 (128 per GPU) and the image size of 192$\times$192. All pretraining settings are the same as in \cite{simmim}.
\textbf{Change Detection}:
4 NVIDIA A10G GPUs are employed for all downstream tasks. We modify the MMsegmentation \cite{mmseg} framework to conduct our change detection experiments.
For OSCD, as the raw image size is large but the number of samples is very small, we tile the images into 192$\times$192 pixels and train for 4000 iterations. For DSFIN, we train for 10k iterations with image size 512$\times$512. We employ an SGD optimizer with a learning rate of 0.01 and weight decay of 5.0e-4, and the default polynomial scheduler of \cite{mmseg}.
\textbf{Classification}:
On UC Merced, we train with a batch size of 1024 (128 per GPU) at image size 256$\times$256. We train for 100 epochs with a base learning rate of 1.0e-4. We employ random flip, crop and standard Mixup \cite{mixup} augmentation. Optimizer, weight decay, Mixup parameters, and other training settings are the same as in \cite{simmim}.
For BigEarthNet, we slightly upscale the original 120$\times$120 images to 128$\times$128 for ease of dimensional compatibility with the Swin transformer. We then employ the same training settings as with UC Merced.
\textbf{Segmentation}:
We employ the MMsegmentation \cite{mmseg} framework to conduct our segmentation experiments. For both datasets, we train for 40k iterations with an image size of 512$\times$512. All other training settings are the same as the default configuration in \cite{mmseg} for the respective backbones (Swin, ViT, ResNet50) and compatible decoders (UperNet \cite{Upernet} for transformers and Deeplabv3 \cite{deeplab} for ResNets).
\textbf{Super-resolution}:
On the SpaceNet2 super-resolution tasks, we train with a batch size of 64 (16 per GPU) with input image size 160$\times$160 and target size 640$\times$640. We train for 100 epochs with a base learning rate of 1.25e-5. Optimizer, weight decay, and other training settings are the same as in \cite{simmim}, but with no random augmentations. We employ the standard decoder from \cite{simmim} to produce the original input size from the encoder features, and then upscale using a convolution-based upsampling block based on the image reconstruction module for classic super-resolution employed in \cite{swinir}.
Detailed results for all downstream experiments and ablations from the main manuscript are provided in Table \ref{tab:full_results}.
\begin{table*}[t]
\caption{Ablation results for the training objectives in GFM. For w/o teacher, we only conduct MIM with GeoPile. For w/o MIM, we simply perform the distillation objective from the ImageNet-22k model to our student model with GeoPile.}
\label{tab:min_ablation}
\centering
\setlength\tabcolsep{3.0pt}
\begin{tabular}{cccccccccc}
\toprule
Method & OSCD (F1) & DSFIN (F1) & UCM & BEN 10\% & BEN 1\% & WHU & Vai. & SN2 (PSNR) & SN2 (SSIM)\\
\toprule
w/o teacher & 57.3 & 67.65 & 98.8 & \textbf{86.5} & 80.0 & 90.5 & 74.0 & 22.509 & 0.631\\
w/o MIM & 59.58 & \textbf{71.86} & 98.8 & 86.1 & 80.2 & 90.2 & 72.6 & 22.069 & 0.608\\
\midrule
GFM & \textbf{59.82} & 71.24 & \textbf{99.0} & 86.3 & \textbf{80.7} & \textbf{90.7} & \textbf{75.3} & \textbf{22.599} & \textbf{0.638}\\
\bottomrule
\end{tabular}
\end{table*}
\begin{table*}[t]
\caption{Results for employing temporal pairs and datasets from SeCo \cite{seco} in our multi-objective pretraining framework. TP indicates that the teacher receives one image from a temporal pair, and the student receives the other. SI indicates that the same image is inputted to the teacher and student.}
\label{tab:data_temp}
\centering
\setlength\tabcolsep{2.5pt}
\begin{tabular}{ccccccccccc}
\toprule
Dataset & Inputs & OSCD (F1) & DSFIN (F1) & UCM & BEN 10\% & BEN 1\% & WHU & Vai. & SN2 (PSNR) & SN2 (SSIM)\\
\toprule
SeCo 100k \cite{seco} & TP & 57.03 & 62.48 & 80.0 & 80.6 & 68.6 & 88.3 & 66.3 & 22.078 & 0.572\\
SeCo 100k \cite{seco} & SI & 58.41 & 67.92 & 92.1 & 83.9 & 76.5 & 88.8 & 68.1 & 22.439 & 0.602\\
SeCo 1M \cite{seco} & SI & 58.87 & 69.41 & 95.7 & 86.2 & 77.1 & 89.6 & 71.0 & 22.281 & 0.626\\
\midrule
GeoPile & SI & \textbf{59.82} & \textbf{71.24} & \textbf{99.0} & \textbf{86.3} & \textbf{80.7} & \textbf{90.7} & \textbf{75.3} & \textbf{22.599} & \textbf{0.638}\\
\bottomrule
\end{tabular}
\end{table*}
\section{Training Time and Carbon Calculations} \label{carbon}
To calculate the CO2 impact of training various models, we employ the ML CO2 Impact estimator at \url{https://mlco2.github.io/impact#compute} from \cite{co2}. The total impact is dependent on the hardware type, GPU provider, region, and total time used. Our pretraining experiments were conducted in the AWS US East (Ohio) region, which has a carbon efficiency of 0.57 kg eq. CO2 per kWh. For our GFM, just 7.5 hours of training is needed on 8 A100 GPUs, resulting in a total carbon impact of 8.56 kg eq. CO2. This is significantly lower than the previous state-of-the-art geospatial model, SatMAE \cite{satmae}. According to the reported carbon impact in their paper \cite{satmae}, SatMAE requires 109.44 kg eq. CO2 on the Google Cloud Platform us-central1 region, which has a carbon efficiency of 0.57 kg eq. CO2 per kWh (same as AWS US East Ohio). Therefore, \ul{GFM enables more than 12$\times$ reduction in total carbon impact in comparison to SatMAE.}
\section{Multi-objective Ablation} \label{mim_ablation}
To further ablate the performance of GFM, we also experiment with removing the teacher component and MIM component in Table \ref{tab:min_ablation}. We find that the multi-objective approach is the best performer overall. This shows that both the distillation and MIM objectives together are important aspects of efficient and effective geospatial learning.
\section{Temporal Pairs Experiment} \label{temporal}
Some works employ temporal pairs in the pretraining procedure \cite{seco, gassl, matter}, meaning two satellite images from the same spatial region but taken at different times. We also experiment with the use of temporal positives in our training paradigm using the dataset proposed in SeCo \cite{seco}. In this case, the teacher receives one image from a temporal pair, and the student receives the other. The temporal changes can possibly serve as a form of natural augmentation for the distillation objective. However, as shown in Table \ref{tab:data_temp}, we find that using temporal positives (TP) is worse than simply using the same image (SI) for both branches. Therefore, we simply use the same image for both branches for other experiments. We further scale up the data by employing the 1M sample Sentinel-based dataset from SeCo. Nonetheless, GeoPile proves to be more effective as a pretraining data source for our GFM.
\section{Super-resolution with Residual Connection} \label{superres_residual}
In super-resolution tasks, a residual connection can be included from the input to the output stage \cite{swinir}. We make this modification as well for both ViT and Swin, and present the results in Table \ref{tab:spacenet_residual}. Interestingly, the Swin transformer benefits from this, while ViT does not. Nonetheless, in comparison to baselines, the conclusion is the same; SatMAE is not able to improve over its ImageNet-22k baseline, but GFM does.
\begin{table}
\caption{SpaceNet2 super-resolution results with the residual connection.}
\label{tab:spacenet_residual}
\centering
\setlength\tabcolsep{5.0pt}
\begin{tabular}{ccc}
\toprule
Method & PSNR $\uparrow$ & SSIM $\uparrow$\\
\toprule
ViT (ImageNet-22k)\cite{vit} & 22.548 & 0.629 \\
SatMAE \cite{satmae} & 22.450 & 0.636 \\
Swin (random) \cite{swin} & 22.190 & 0.642 \\
Swin (ImageNet-22k) \cite{swin} & 22.918 & 0.640 \\
\midrule
GFM & \textbf{22.963} & \textbf{0.660} \\
\midrule
\end{tabular}
\end{table}
\begin{table*}[t]
\caption{Detailed downstream results for all experiments in the main manuscript. We abbreviate the following for vertical space: UC Merced (UCM), BigEarthNet (BEN), WHU Aerial (WHU), Vaihingen (Vai), SpaceNet2 (SN2).}
\label{tab:full_results}
\centering
\setlength\tabcolsep{2.5pt}
\begin{tabular}{cccccccccc}
\toprule
Method & OSCD (F1) & DSFIN (F1) & UCM & BEN 10\% & BEN 1\% & WHU & Vai. & SN2 (PSNR) & SN2 (SSIM)\\
\toprule
ImageNet-22k baseline & 52.35 & 69.62 & 99.0 & 85.7 & 79.5 & 90.4 & 74.7 & 21.655 & 0.612\\
\midrule
ImageNet-1k & 57.19 & 67.71 & 97.4 & 85.7 & 78.9 & 89.4 & 73.2 & 22.648 & 0.631\\
Sentinel-2 & 55.14 & 64.31 & 94.5 & 84.9 & 70.0 & 86.2 & 63.3 & 19.961 & 0.566\\
GeoPile (200ep) & 56.59 & 68.31 & 98.8 & 86.0 & 79.2 & 89.4 & 73.6 & 22.315 & 0.630\\
GeoPile (800ep) & 57.30 & 67.65 & 98.8 & 86.5 & 80.0 & 90.5 & 74.0 & 22.509 & 0.631\\
\midrule
Stage 1 & 56.20 & 69.79 & 98.1 & 85.8 & 78.3 & 89.0 & 73.3 & 22.153 & 0.626\\
Stage 2 & 58.97 & 68.27 & 96.9 & 86.1 & 79.0 & 89.4 & 72.2 & 22.409 & 0.625\\
Stage 4 & 60.31 & 68.97 & 98.3 & 86.1 & 80.8 & 89.8 & 73.0 & 22.495 & 0.638\\
\midrule
$\alpha$ = 0.1 & 58.98 & 67.44 & 99.0 & 86.0 & 80.6 & 89.7 & 72.2 & 22.213 & 0.633\\
$\alpha$ = 0.5 & 59.38 & 70.25 & 97.9 & 86.1 & 80.7 & 89.8 & 73.2 & 22.26 & 0.635\\
\midrule
w/o WHU-RSD46 & 58.79 & 69.25 & 98.3 & 86.1 & 80.6 & 89.7 & 72.9 & 22.51 & 0.632\\
w/o MLRSNet & 60.01 & 69.21 & 98.8 & 86.1 & 80.5 & 89.9 & 72.9 & 22.409 & 0.633\\
w/o Resisc45 & 58.33 & 69.22 & 98.6 & 86.3 & 80.7 & 89.8 & 72.4 & 22.206 & 0.635\\
w/o PatternNet & 59.00 & 70.37 & 98.3 & 86.3 & 80.5 & 89.8 & 71.9 & 22.293 & 0.629\\
w/o curated datasets & 58.49 & 67.16 & 98.1 & 85.7 & 79.9 & 88.9 & 72.7 & 22.852 & 0.584\\
w/o NAIP & 58.72 & 70.54 & 98.3 & 85.5 & 79.6 & 89.7 & 70.8 & 22.574 & 0.632\\
\midrule
ImageNet-22k Init. (200ep) & 56.71 & 67.46 & 98.6 & 86.2 & 79.3 & 89.9 & 74.1 & 22.513 & 0.633\\
ImageNet-22k Init. (800ep) & 57.52 & 66.23 & 98.8 & 86.3 & 79.3 & 90.1 & 75.1 & 22.626 & 0.645\\
\midrule
GFM & 59.82 & 71.24 & 99.0 & 86.3 & 80.7 & 90.7 & 75.3 & 22.599 & 0.638\\
\bottomrule
\end{tabular}
\end{table*}
\section{Broader Impact and Limitations} \label{broader_impact}
We anticipate that our GFM approach will serve as an example to inspire other works in investigating sustainable methods for developing geospatial foundation models.
As the geospatial community continues to innovate, the resulting impact promises to positively benefit both the earth and society. Automating the process of extracting useful information from geospatial data can aid scientists, engineers, and others to make data-informed decisions on infrastructure advancement, food supply improvements, and natural disaster response.
A potential limitation of our GFM approach is that it may still be somewhat constrained by the performance of the ImageNet-22k model. If perhaps a model was trained from scratch on an extremely large corpus of remote sensing data, the performance may eventually also lead to improved performance over ImageNet baselines. However, this would incur a substantial amount of training and CO2 impact. Furthermore, ImageNet models are constantly being improved and released by the general computer vision community, providing a consistent source of better baseline models. Therefore, our approach enables the geospatial domain to effectively leverage these improvements for better in-domain performance with minimal carbon impact. We believe this is a sustainable way for the geospatial community to continually benefit from the most recent progress in computer vision, enabling a smarter, safer, and healthier planet.
{\small
\bibliographystyle{ieee_fullname}
| {'timestamp': '2023-02-10T02:07:53', 'yymm': '2302', 'arxiv_id': '2302.04476', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04476'} | arxiv |
\section{Introduction}
Edit distance is a measure of similarity of two strings.
It measures how many symbols one has to insert, delete or substitute in a string $x$ to get a string $y$.
The measure has many applications from text processing to bioinformatics.
The edit distance $\ED(x,y)$ of two strings $x$ and $y$ can be computed in time $O(n^2)$ by a classic dynamic programming algorithm~\cite{WF74}.
Save for poly-log improvements in the running time~\cite{MP80,G16},
the best known running time for edit distance computation is $O(n+k^2)$~\cite{LMS98}, where $k=\ED(x,y)$.
Assuming Strong Exponential Time Hypothesis (SETH) this running time cannot be substantially improved~\cite{BI15}.
The conditional lower bound does not exclude some approximation algorithms, though, and there was a recent progress on computing edit distance in almost-linear time to within some constant factor approximation~\cite{CDGKS18,KS20,BR20,AN20}.
Another problem for edit distance that saw a major progress in recent years is sketching.
In sketching we want to map a string $x$ to a short sketch $\mathrm{sk}^{\mathrm{ED}}_{n,k}(x)$
so that from sketches $\mathrm{sk}^{\mathrm{ED}}_{n,k}(x)$ and $\mathrm{sk}^{\mathrm{ED}}_{n,k}(y)$ of two strings $x$ and $y$ we can compute their edit distance, either exactly or approximately. Apriori it is not even obvious that short sketches for edit distance exist. In a surprising construction,
Belazzougui and Zhang~\cite{belazzougui_zhang} gave an exact edit distance sketch of size $O(k^{8}\log^{5}n)$ bits.
The sketch size was then improved to $O(k^{3}\log^{2}(\frac{n}{\delta})\log{n})$ bits by Jin, Nelson and Wu~\cite{nelson_edit_sketch}, where the $\ED(x,y)$ was computed exactly from the sketches with probability at least $1-\delta$, if $\ED(x,y)\le k$.
The current best sketch is of size $O(k^{2}\log^{3}n)$ bits and was given by Kociumaka, Porat and Starikovskaya~\cite{editsketchfocs2021}.
\cite{nelson_edit_sketch} gives a lower bound $\Omega(k)$ on the size of a sketch for exact edit distance.
The major problem in edit distance computation as well as in sketching is how to align the matching parts of two strings $x$ and $y$.
Finding an optimal alignment of two strings is the crux in the computation of edit distance and its sketching.
In sketching finding a good alignment is even more challenging as we do not have both strings in our hands simultaneously to look for the matching.
To the best of our knowledge, to resolve this issue all edit distance sketches use {\em CGK random walk} on strings~\cite{CGK16}
which allows to embed the edit distance metrics into Hamming distance metrics with distortion $O(k)$.
The walk implicitly fixes some reasonably good matching between the two strings.
Going from the CGK random walk to a sketch is non-trivial undertaking and all three sketch results rely on sophisticated machinery to achieve it.
In this paper we provide a new technique to align two strings $x$ and $y$ in oblivious manner.
In nutshell, we provide a decomposition procedure that breaks $x$ and $y$ into the same number of ``short'' blocks so that at most $k$ pairs
of blocks in the decomposition of $x$ and $y$ differ, and all other pairs of blocks are matching in an optimal alignment.
So the edit distance of $x$ and $y$ is the sum of edit distances of the differing blocks.
To be more specific our blocks are not short in their length
but they are short in the sense that each of them can be described by a context-free grammar of size ${\widetilde{O}}(k)$.
Our decomposition algorithm constructs the grammars.
Our decomposition is based on {\em locally consistent parsing} of strings a technique similar to the one used in~\cite{lcp-application94, BES06, Jow, lcp_application2020}.
Our main technical result is:
\begin{theorem}[String decomposition]\label{t-main1}
There is an algorithm running in time ${\widetilde{O}}(nk)$ that for each string $x$ of length at most $n$ produces grammars $G^x_1,\dots,G^x_s$ such that with probability at least $1-O(1/\sqrt{n})$, $x={\mathrm{eval}}(G^x_1)\cdots {\mathrm{eval}}(G^x_s)$ and each of the grammars is of size ${\widetilde{O}}(k)$. Furthermore, for any two strings $x$ and $y$ of edit distance at most $k$ with grammars $G^x_1,\dots,G^x_s$ and $G^y_1,\dots,G^y_{s'}$, resp., that are produced by the algorithm using the same randomness, the following is true simultaneously with probability at least $4/5$:
\begin{enumerate}
\item $s=s'$,
\item $G^x_i=G^y_i$, for all $i\in \{1,\dots,s\}$ except for at most $k$ indices $i$, and
\item $\ED(x,y)=\sum_i \ED({\mathrm{eval}}(G^x_i),{\mathrm{eval}}(G^y_i))$.
\end{enumerate}
\end{theorem}
Here, for a grammar $G$, ${\mathrm{eval}}(G)$ denotes its evaluation.
Our decomposition can be used immediately to give an embedding of edit distance into Hamming distance with distortion $O(k)$.
It also readily yields a sketch for exact edit distance of size ${\widetilde{O}}(k^2)$:
\begin{theorem}[Sketch for edit distance]\label{t-main2}
There is a randomized sketching algorithm $\mathrm{sk}^{\mathrm{ED}}_{n,k}$ that on an input string $x$ of length at most $n$ produces a sketch $\mathrm{sk}^{\mathrm{ED}}_{n,k}(x)$
of size ${\widetilde{O}}(k^2)$ in time ${\widetilde{O}}(nk)$, and a comparison algorithm running in time ${\widetilde{O}}(k^2)$ such that given two sketches $\mathrm{sk}^{\mathrm{ED}}_{n,k}(x)$ and $\mathrm{sk}^{\mathrm{ED}}_{n,k}(y)$ for two strings $x$ and $y$ of length at most $n$ obtained using the same randomness of the sketching algorithm outputs with probability at least $1-1/n$ (over the randomness of the sketching and comparison algorithms) the edit distance of $x$ and $y$ if it is less than $k$ and $\infty$ otherwise.
\end{theorem}
Furthermore, we can also provide a {\em rolling sketch}, a sketch in which we can update the stored string by appending a symbol or
removing its first symbol.
\begin{theorem}[Rolling sketch for edit distance]\label{t-main3}
There are algorithms ${\mathrm{Append}}(sk_x,a)$, ${\mathrm{Remove}}(sk_{ax},a)$, and ${\mathrm{Compare}}(sk_x, sk_y)$ such that for integer parameters $k\le m$:
\begin{enumerate}
\item Given a sketch $sk_x$ representing a string $x$ and a symbol $a$, ${\mathrm{Append}}(sk_x,a)$ outputs a sketch $sk_{xa}$ for the string $xa$ in time ${\widetilde{O}}(k^2)$.
\item Given a sketch $sk_{ax}$ representing a string $ax$ for a symbol $a$, ${\mathrm{Remove}}(sk_{ax},a)$ outputs a sketch $sk_{x}$ for the string $x$ in time ${\widetilde{O}}(k^2)$.
\item Given two sketches $sk_{x}$ and $sk_y$ representing strings $x$ and $y$ obtained from the same random sketch for empty string using two sequences of at most $m$ operations ${\mathrm{Append}}$ and ${\mathrm{Remove}}$, ${\mathrm{Compare}}(sk_x, sk_y)$ calculates the edit distance of $x$ and $y$
if it is less than $k$, and outputs $\infty$ otherwise. The algorithm ${\mathrm{Compare}}(sk_x, sk_y)$ runs in time ${\widetilde{O}}(k^2)$.
\end{enumerate}
All the sketches are of size ${\widetilde{O}}(k^2)$.
The probability that any of the algorithms fails or produces incorrect output is at most $1/m$ over the initial randomness of the sketch for empty string and internal randomness of the algorithms.
\end{theorem}
We remark that we did not attempt to optimize the running time of either of our algorithms, or poly-log factors in the sketch sizes,
and we believe that both parameters can be readily improved by usual amortization techniques of processing symbols in batches of size ${\widetilde{O}}(k)$.
We believe that building the sketch in the first theorem can be done in time ${\widetilde{O}}(n)$ using fast multi-point polynomial evaluation for
${\widetilde{O}}(k)$-wise independent hash functions, the update time in the last theorem can be improved to ${\widetilde{O}}(1)$ by buffering ${\widetilde{O}}(k)$ symbols
that shall be inserted or removed without affecting the other parameters of the algorithm.
Another distinguishing feature of our decomposition procedure compared to the technique of CGK random walks is its parallelizability.
CGK random walk seems inherently sequential whereas our decomposition procedure can be easily parallelized.
We believe that our decomposition will allow for further applications beyond our simple sketches.
\subsection{Related work}
The problem of embedding edit distance to other distance measures, like Hamming distance, $\ell_1$, etc. has been studied extensively. In \cite{CGK16}, the authors have given a randomized embedding from edit distance to Hamming distance, where any string $x \in \{0,1\}^n$ can be mapped to a string $f(x)\in \{0,1\}^{3n}$, given a random string $r\in\{0,1\}^{\log^{2}n}$, such that, $\ED(x,y)/2 \le \Ham(f(x),f(y)) \le O(\ED(x,y)^2)$ with probability at least $2/3$.
Batu, Ergun and Sahinalp~\cite{BES06} have introduced a dimensionality reduction technique, where any string $x$ of length $n$ can be mapped to a string $f(x)$ of length at most ${n}/{r}$, for any parameter $r$, with a distortion of ${\widetilde{O}}(r)$.
They used the locally consistent parsing technique for their embedding.
Ostrovsky and Rabani \cite{hamming_to_l1_rabani_2007} gave an embedding from edit distance to $\ell_1$ distance with a distortion of $O(\sqrt{\log n \log \log n})$.
Jowhari \cite{Jow} also gave a randomized embedding from edit distance to $\ell_1$ distance with a distortion of $O(\log n \log^{*}n)$. He used the embedding given by Cormode and Muthukrishnan \cite{CM02} who showed that any string $x$ of length $n$ can be mapped to a vector $f(x)$ of length $m=O(2^{n \log n})$, such that for any pair of strings $x,y$ of length $n$ each, $\ED(x,y)/2 \le \lVert f(x)-f(y) \rVert_{\ell_1} \le O(\log n \log^{*}n) \cdot \ED(x,y)$. Since the size of the vector was too large, \cite{Jow} used random hashing to get his final embedding.
\subsection{Our techniques}
We first provide the intuition for our technique. We would like to break a string $x$ into small blocks {\em obliviously}
so that when a string $y$ is broken by the same procedure, the difference between $x$ and $y$ caused by the edit operations
is confined within the corresponding blocks of $x$ and $y$, and the overall decomposition is not affected by them.
For random binary strings $x$ and $y$ this could be done fairly easily:
look on all the (overlapping) windows of $\log n$ consecutive bits in each of the strings and for each window decide at random whether to make a break at that window or not.
To make it consistent between $x$ and $y$ use some random hash function $H:\{0,1\}^{\log n} \rightarrow \{0,\dots,D-1\}$
so that if the hash function evaluates to $0$ on a given window then start a next block of the decomposition.
If we chose $D$ suitably, say $D \ge 10 k \log n$, then we are unlikely to start a new block in any window which is affected by the the at most $k$ edit operations on $x$ and $y$. In that case we obtain the desired decomposition. Hence, decomposing random strings $x$ and $y$ is easy.
The issue is what to do with non-random strings.
Consider for example strings $x$ and $y$ that are very sparse, so they contain $\sqrt{n}$ ones sprinkled within the vast ocean of zeros.
The hash function $H$ will see mostly windows of 0's and occasionally a window of the form $0^i10^{\log(n) - i -1}$.
The decomposition will have no effect on such strings despite the fact that the string might contain $\Omega(\sqrt{n})$ bits of entropy.
However, we can compress such sparse strings: replace stretches of zeros by some binary encoded information about their length,
and try to break the strings again.
Still, this will fail if in our example the stretches of zeros are replaced by stretches of some repeated pattern such as $(01)^*$.
So we need slightly more general compression which will compress any $\log n$ bits into $\log(n)/2$ bits.
By repeating the sequence of steps: split and compress, we will eventually get the desired decomposition of each string.
Our actual algorithm mimics the above intuition.
It is technically easier to work with a larger alphabet, so we extend the input alphabet $\Sigma$ by adding special compression symbols into the work alphabet $\Gamma$.
(Without loss of generalization we can assume that $\Sigma$ is of size $O(n^3)$ otherwise we can hash each symbol of our input strings using some perfect hash function into an alphabet of size $O(n^3)$ without affecting the edit distance of a given pair of strings.)
To split a string we will use a random ${\widetilde{O}}(k)$-wise independent hash function $H:\Gamma^2 \rightarrow \{0,\dots,D-1\}$, for $D=\Theta(k \log n)$.
If the hash function is zero on a pair of consecutive symbols in a string, we start a new block of the decomposition on the first symbol in the pair.
Then in each resulting block we replace stretches of repeated symbols by a special compression symbol from $\Gamma$ representing the block,
and we use a pair-wise independent hash function $C:\Gamma^2 \rightarrow (\Gamma \setminus \Sigma)$ to compress non-overlapping pairs of symbols
into one symbol. This latter step requires some care as we have to make sure that we select non-overlapping pairs in the same way in $x$ and $y$.
For the selection of non-overlapping pairs we use the locally consistent coloring of Cole and Vishkin~\cite{cole1986deterministic,linial1987distributive,linial1992locality} where the selection of pairs depends only on the context of $O(\log^* n)$ symbols.
The compression reduces the size of each block by a factor of $2/3$.
We repeat the compress and split process for $O(\log n)$ iterations until each compressed block of $x$ is of size at most 2.
{\em Decompression} of each block then gives us the desired decomposition of $x$. (See Fig.~\ref{fig:hierarchy} for an illustration.)
It is natural and convenient to represent each of the blocks by a context-free grammar which corresponds to the compression process.
We can argue that the grammars will be of size $O(D \log n)$ with high probability.
So we can represent each string by a sequence of small grammars so that if $x$ and $y$ are at edit distance at most $k$
then at most $k$ pairs of their grammars will differ, and the sum of the edit distances of differing pairs is the edit distance of $x$ and $y$.
Note, that edit distance of two strings represented by context-free grammars can be computed efficiently~\cite{ED_compressed_string_Soda22}.
These are the main ideas behind our decomposition algorithm, and we provide more details in Section~\ref{s-decomposition}
\smallskip
Building a sketch from the string decomposition is straightforward:
We encode each grammar in binary using fixed number of bits, and we use off-the-shelf sketch for Hamming distance to sketch the sequence of grammars.
As the Hamming distance sketch does not recover identical bits but only the mismatched bits we make sure that if two grammars differ then
their binary encoding differ in every bit.
Over binary alphabet this might be impossible but over large alphabets one could use error-correcting codes to achieve the desired effect of recovering the differing grammars; for simplicity we use the Karp-Rabin fingerprint of the whole grammar to encode the binary 0 and 1 distinctly.
See Section~\ref{s-binencoding} for the details of our encoding and Section~\ref{s-edsketch} for details of the sketch for edit distance.
\smallskip
To design a rolling sketch for edit distance where we can extend the represented string by a new symbol or repeatedly remove the first symbol
of the represented string
we will employ our decomposition technique together with the rolling sketch for Hamming distance of Clifford, Kociumaka, and Porat~\cite{rollinghashSODA2019}.
We will argue that appending a new symbol to a string affects only some fixed number of grammars in the decomposition of a string.
There is a certain threshold $T$ so that except for the last $T$ grammars the decomposition of a string stays the same regardless of how many
other symbols are appended.
Hence, we will keep a buffer of at most $T$ {\em active} grammars corresponding to the recently added symbols,
and upon addition of a new symbol we will only update those grammars.
We are guaranteed that the grammars before this threshold will stay the same forever, so we can {\em commit} them into the rolling Hamming sketch
(in the form of their binary encoding.)
Similarly, we will keep a buffer of up-to $T$ {\em active} grammars that capture the symbols that were deleted from the sketch most recently.
Once they become ``mature'' enough we can commit them by removing their binary encoding from the rolling Hamming sketch.
(See Fig.~\ref{fig:rolling_sketch} for an illustration.)
This allows to maintain a rolling sketch for edit distance.
Evaluation of an edit distance query on two rolling sketches will use their Hamming sketch to recover differing committed grammars.
Together with the active grammars of inserted and deleted symbols this provides enough information for evaluating the edit distance query.
Technical details are explained in Section~\ref{s-rolling}.
In Section~\ref{s-param} we give a table of parameters used throughout the paper.
\section{Notations and preliminaries}
For any string $x = x_1x_2x_2\dots x_n$ and integers $p,q$, $x[p]$ denotes $x_p$, $x[p,q]$ represents substring $x' = x_p\dots x_q$ of $x$, and $x[p,q)=x[p,q-1]$.
If $q<p$, then $x[p,q]$ is the empty string $\eps$. $x[p,\dots]$ represents $x[p,|x|]$, where $|x|$ is the length of $x$.
"$\cdot$"-operator is used to denote concatenation, e.g $x\cdot y$ is the concatenation of two strings $x$ and $y$. ${\mathrm{Dict}}(x) = \{x[i,i+1], i \in [n-1]\}$, is the dictionary of string $x$, which stores all pairs of consecutive symbols that appear in $x$.
For strings $x$ and $y$, $\ED(x,y)$ is the minimum number of modifications ({\em edit operations}) required to change $x$ into $y$, where a single modification can be adding a character, deleting a character or substituting a character in $x$.
All logarithms are based-2 unless stated otherwise.
For integers $p>q$, $\sum_{i=p}^{q} a_i=0$ by definition regardless of $a_i$'s.
\subsection{Grammars}\label{s-grammars}
Let $\Sigma \subseteq \Gamma$ be two alphabets and $\# \not\in \Gamma$. A {\em grammar} $G$ is a set of {\em rules} of the type $c \rightarrow ab$
or $c \rightarrow a^r$, where $c \in (\Gamma \cup \{\#\}) \setminus \Sigma$, $a,b \in \Gamma$ and $r\in {\mathbb{N}}$.
$c$ is the {\em left hand side} of the rule, and $ab$ or $a^r$ is the {\em right hand side} of the rule.
$\#$ is the starting symbol. The size $|G|$ of the grammar is the number of rules in $G$.
We only consider grammars where each $a \in \Gamma \cup \{\#\}$ appears on the left hand side of at most one rule of $G$, we call such grammars {\em deterministic}.
(We assume that rules of the form $c \rightarrow a^r$ are stored in implicit (compressed) form.)
The ${\mathrm{eval}}(G)$ is the string from $\Sigma^*$ obtained from $\#$ by iterative rewriting of the intermediate results by the rules from $G$.
If the rewriting process never stops or stops with a string not from $\Sigma^*$, ${\mathrm{eval}}(G)$ is undefined.
Observe, that we can replace each rule of the type $c \rightarrow a^r$ by a collection of at most $2\lceil \log r \rceil$ new rules of the other type using some auxiliary symbols.
Hence, for each grammar $G$ there is another grammar $G'$ using only the first type of the rules such that ${\mathrm{eval}}(G)={\mathrm{eval}}(G')$ and $|G'| \le |G| \cdot 2 \lceil \log |{\mathrm{eval}}(G)| \rceil$.
Using a depth-first traversal of a deterministic grammar $G$ we can calculate its {\em evaluation size $|{\mathrm{eval}}(G)|$} in time $O(|G|)$.
Given a deterministic grammar $G$ and an integer $m$ less or equal to its evaluation size, we can construct in time $O(|G|)$
another grammar $G'$ of size $O(|G|)$ such that ${\mathrm{eval}}(G')={\mathrm{eval}}(G)[m,\dots]$. $G'$ will use some new auxiliary symbols.
Given a deterministic grammar $G$, using a depth-first traversal on symbols reachable from the starting symbol $\#$
we can identify in time $O(|G|)$ the smallest sub-grammar $G'\subseteq G$ with the same evaluation.
We will use the following observation of Ganesh, Kociumaka, Lincoln and Saha \cite{ED_compressed_string_Soda22}:
\begin{proposition}[\cite{ED_compressed_string_Soda22}]\label{p-edgrammar}
There is an algorithm that on input of two grammars $G_x$ and $G_y$ of size at most $m$ computes the edit distance $k$ of ${\mathrm{eval}}(G_x)$ and ${\mathrm{eval}}(G_y)$ in time $O( (m + k^2) \cdot {\mathrm{poly}}(\log m+n))$, where $n=|{\mathrm{eval}}(G_x)|+|{\mathrm{eval}}(G_y)|$.
\end{proposition}
\subsection{Rolling Hamming distance sketch}\label{s-hammin}
For two strings $x$ and $y$ of the same length, we define their {\em mismatch information}
${\mathrm{MIS}}(x,y)=\{(i,x[i],y[i]);$ $i \in \{1,\dots,|x|\} \textit{ and }x[i]\neq y[i]\}$.
The Hamming distance of $x$ and $y$ is $\Ham(x,y)=|{\mathrm{MIS}}(x,y)|$.
There exist various sketches for Hamming distance, which allow to compute Hamming distance with low error probability \cite{hamming_sketch2,hamming_sketch3}. Moreover, \cite{porat2007,rollinghashSODA2019} also allow to retrieve the mismatch information.
For our purposes we will use the sketch given by Clifford, Kociumaka, and Porat~\cite{rollinghashSODA2019}.
Let $k\le n$ be integers and $p \ge n^3$ be a prime.
\cite{rollinghashSODA2019} give a randomized sketch for Hamming distance
$\mathrm{sk}^{\mathrm{Ham}}_{n,k,p} : \{1,\dots,p-1\}^* \rightarrow \{0,\dots,p-1\}^{k+4}$ computable in time ${\widetilde{O}}(n)$ with the following properties.\footnote{Clifford, Kociumaka and Porat have the sketch size only $k+3$ elements but we include as an extra item the randomness of the sketch, which is a single element from $\{0,\dots,p-1\}$
used to compute Karp-Rabin fingerprint.}
\begin{proposition}[\cite{rollinghashSODA2019}]\label{p-skham}
There is a randomized algorithm working in time $O(k \log^3 p)$ that given sketches $\mathrm{sk}^{\mathrm{Ham}}_{n,k,p}(x)$
and $\mathrm{sk}^{\mathrm{Ham}}_{n,k,p}(y)$ of two strings $x$ and $y$ of length $\ell \le n$ constructed using the same randomness decides whether $\Ham(x,y)\le k$, and if so returns ${\mathrm{MIS}}(x,y)$,
with probability of error at most $1/n$ over the randomness of the sketches and the internal randomness of the algorithm.
\end{proposition}
They also construct the following update procedures for their sketch. We will use them to construct a rolling sketch for edit distance.
\begin{proposition}[Lemma 2.3 of \cite{rollinghashSODA2019}]
For $x\in \{1,\dots, p\}^*$ of length less than $n$ and $a \in \{1,\dots, p\}$, in time $O(k \log p)$ we can compute:
\begin{enumerate}
\item $\mathrm{sk}^{\mathrm{Ham}}_{n,k,p}(xa)$ and $\mathrm{sk}^{\mathrm{Ham}}_{n,k,p}(ax)$, given $\mathrm{sk}^{\mathrm{Ham}}_{n,k,p}(x)$ and $a$.
\item $\mathrm{sk}^{\mathrm{Ham}}_{n,k,p}(x)$ given $\mathrm{sk}^{\mathrm{Ham}}_{n,k,p}(xa)$ or $\mathrm{sk}^{\mathrm{Ham}}_{n,k,p}(ax)$, and $a$.
\end{enumerate}
\end{proposition}
Corollary 2.5 of \cite{rollinghashSODA2019} states that appending a character to a sketch of $x$ can be done even faster namely in amortized time $O(\log p)$.
\subsection{Locally consistent coloring}\label{s-locally_consistent_parsing}
The following color reduction procedure allows for locally consistent parsing of strings. The technique was originally proposed by Cole and Vishkin \cite{cole1986deterministic} and further studied by Linial \cite{linial1987distributive,linial1992locality}.
\begin{proposition}[\cite{cole1986deterministic,linial1987distributive,linial1992locality}]\label{thm:color_reduction}
There exists a function $F_{\mathrm{CVL}}:\Gamma^* \rightarrow \{1,2,3\}^*$ with the following properties. Let $R= \log^* |\Gamma| + 20$. For each string $x \in \Gamma^*$ in which no two consecutive symbols are the same:
\begin{enumerate}
\item $|F_{\mathrm{CVL}}(x)|=|x|$ and $F_{\mathrm{CVL}}(x)$ can be computed in time $O(R\cdot |x|)$.
\item For $i\in \{1,\dots, |x|\}$, the $i$-th symbol of $F_{\mathrm{CVL}}(x)$ is a function of symbols of $x$ only in positions $\{i-R,i-R+1\dots,i+R\}$.
\item No two consecutive symbols of $F_{\mathrm{CVL}}(x)$ are the same.
\item Out of every three consecutive symbols of $F_{\mathrm{CVL}}(x)$ at least one of them is 1.
\item If $|x|=1$ then $F_{\mathrm{CVL}}(x)=3$, and otherwise $F_{\mathrm{CVL}}(x)$ starts by 1 and ends by either 2 or 3.
\end{enumerate}
\end{proposition}
The first three items are standard for $R= \log^* |\Gamma| + 10$. The other two can be obtained by a simple modification of the output of the standard function.
In the output, replace first in parallel each sequence 232 by 212, and then each sequence 323 by 313. This guarantees the fourth condition.
To satisfy the fifth condition, if $|x|=1$, set $F_{\mathrm{CVL}}(x)=3$, if $|x|=2$, set $F_{\mathrm{CVL}}(x)=12$, if $|x|=3$, set $F_{\mathrm{CVL}}(x)=123$, and if $|x|=4$, set $F_{\mathrm{CVL}}(x)=1212$.
If $|x|>4$ then
replace the sequence at the beginning of the output as follows: if it starts by a word from $\{2,3\}\{2,3\}1$ replace it by 121,
if it starts by $\{2,3\}1\{2,3\}\{2,3\}$ replace it by 1212, if it starts by $\{2,3\}1\{2,3\}1$ replace it by 1231. Then at the end of the sequence, replace $1\{2,3\}1$ by 123,
and $1\{2,3\}\{2,3\}1$ by 1212. This will increase the local dependency to at most $R= \log^* |\Gamma| + 20$.
\section{Decomposition algorithm}\label{s-decomposition}
In this section we describe our main technical tool that we have developed. It is a randomized procedure that splits a string $x$ into blocks $B^x_1,B^x_2,\dots, B^x_s$ and for each block it produces a grammar of size at most $S={\widetilde{O}}(k)$. Furthermore, if $B^x_1,B^x_2,\dots, B^x_s$ is the decomposition
for a string $x$ and $B^y_1,B^y_2,\dots, B^x_{s'}$ is the decomposition for a string $y$, obtained using the same randomness, where $\ED(x,y)\le k$ then with good probability, $s=s'$ and $B^x_i=B^y_i$ for all but $k$ indices $i$. The edit distance of $x$ and $y$ can be calculated
as $\ED(x,y)=\sum_i \ED(B^x_i,B^y_i)$ where $i$ ranges over the differing blocks.
First we provide an overview of the algorithm, specific details are given in the next sub-section.
The decomposition procedure proceeds in $O(\log n)$ rounds.
In each round, the algorithm maintains a decomposition of $x$ into {\em compressed} blocks. In each round each block of size at least two is first {\em compressed} and then {\em split}.
The compression is done by compressing pairs of consecutive symbols into one using a randomly chosen pair-wise independent hash function $C_\ell : \Gamma^2 \rightarrow \Gamma$, where $\ell$ is the round number ({\em level}).
Non-overlapping pairs of symbols are chosen for compression using a {\em locally consistent coloring} so that every three symbols shrink to at most two. Prior to the compression of pairs we replace each repeated sequence $a^r$ of a symbol $a$, $r\ge 2$, by a special character ${\mathtt{r}}_{a,r}$.
The splitting procedure uses a ${\widetilde{O}}(k)$-wise independent hash function $H_\ell : \Gamma^2 \rightarrow \{0,\dots, D-1\}$ to select places where to subdivide each block into sub-blocks, where $D={\widetilde{O}}(k)$ is a suitable parameter.
We start a new block at each consecutive pair of symbols $ab$, where $H_\ell(ab)=0$.
After $O(\log n)$ rounds, each block is compressed into at most two symbols and we output a grammar that can generate the block.
For the correctness of the algorithm we will need to establish several properties of the algorithm. Some of these properties are related to behaviour on a single string $x$, others analyze the behaviour of the procedure on a pair of strings $x$ and $y$ of edit distance at most $k$.
The properties we want from the algorithm when it runs on $x$ are the following: In each round, each block should be compressed by factor at least $2/3$ while the size of the required grammar capturing the compression should be ${\widetilde{O}}(k)$.
The former is achieved by the design of the compression procedure.
The latter goal is provided by the property of the splitting procedure which makes sure that each block $B=b_1b_2\cdot b_m$ resulting from a split has small dictionary ${\mathrm{Dict}}(B)=\{b_ib_{i+1}, i=1,\dots,m-1\}$. In particular, we require
$|{\mathrm{Dict}}(B)| = {\widetilde{O}}(k)$. The grammar size will be proportional to this dictionary.
For the compression procedure we require that it preserves information so the function $C_\ell$ is one-to-one on each ${\mathrm{Dict}}(B)$. Since the total size of all dictionaries is bounded by ${\widetilde{O}}(n)$ this can be easily achieved by picking $C_\ell$ at random provided that its range size is $\Omega(n^3)$.
Additionally, we need the following property to hold on a pair of strings $x$ and $y$ of edit distance at most $k$ with good probability: The splitting procedure should never split $x$ or $y$ in a {\em region} which is affected by edit operations that transform $x$ to $y$ (for some canonical choice of those operations.) The total size of those regions will be again ${\widetilde{O}}(k)$ so we can satisfy this property if each pair of symbols has probability at most $1/{\widetilde{O}}(k)$ to start a new block. This constrains the choice of the range size for the splitting function $H_\ell$.
In the next section we describe the decomposition algorithm fully, and then we establish its properties.
\subsection{Algorithm description}
Let $n$ be an upper bound on the length of the input string and $k\le n$ be given.
Set $L=\lceil \log_{3/2} n \rceil+3$ to be an upper bound on the decomposition depth.
Let $\Sigma$ be an input alphabet of size at most $n^3$, $\Sigma_c=\{{\mathtt{c}}_1,{\mathtt{c}}_2,\dots,{\mathtt{c}}_{L n^3}\}$ and
$\Sigma_r=\{{\mathtt{r}}_{a,r}, a \in \Sigma \cup \Sigma_c, r \in \{2,3,\dots, n\} \}$ be auxiliary pair-wise disjoint alphabets.
Let $\Gamma = \Sigma \cup \Sigma_c \cup \Sigma_r$ be the working alphabet, and $\#$ be a symbol not in $\Gamma$. Notice $|\Gamma| = O(n^5 + |\Sigma|)$.
We call symbols from $\Sigma^0_c=\Sigma$ {\em level-0 compression symbols}, and for $\ell\ge 1$, symbols from $\Sigma_c^\ell=\{{\mathtt{c}}_i,\, (\ell-1) n^3 < i \le \ell n^3 \}$ are {\em level-$\ell$ compression symbols}.
Additionally, symbols from $\Sigma_r^\ell = \{ {\mathtt{r}}_{a,r}\in \Sigma_r,$ $a$ is a level-$(\ell-1)$ compression symbol$\}$ are also {\em level-$\ell$ compression symbols}.
Let $R= \log^* |\Gamma| + 20$, $D= 110 R (L+1) k$ and $S=30 DL \log n + 6$ be parameters.
The algorithm is a recursive algorithm of depth at most $L$.
It starts by selecting at random several hash functions:
For $\ell=1,\dots, L$, it selects at random a compression hash function $C_\ell:\Gamma^2 \rightarrow \Sigma^\ell_c$ from a pair-wise independent hash family, and for $\ell=0,\dots, L$, it selects at random a splitting function $H_\ell:\Gamma^2 \rightarrow \{0,\dots, D-1\}$ from a $(5D \log n)$-wise independent hash family.
Main building blocks of the algorithm are two functions, ${\mathrm{Compress}}$ and ${\mathrm{Split}}$. The first one compresses strings by a factor of $2/3$, and the other splits strings at random points. Their pseudo-code is provided as Algorithm 1 and 2. We describe them next.
${\mathrm{Compress}}$. The function ${\mathrm{Compress}}(B,\ell)$ takes as input a string $B$ over alphabet $\Gamma$ of length at least two, and an integer $\ell \ge 1$, which denotes the level number. Divide $B$ into minimum number of blocks $B_1, \dots, B_m$, $B=B_1B_2B_3\dots B_m$, so that in each $B_i$ either all the characters are the same, i.e. $B_i = a^r$ for some $a\in\Gamma$ and $r\ge 2$, or no two adjacent characters are the same. The first step is to compress the $B_{i}$'s which contain repeated characters by simply replacing the whole $B_i$ with the symbol ${\mathtt{r}}_{a,|B_i|}$, where $a$ is the repeated character. Then for the remaining blocks, the following compression is applied: Let $B_i$ be an uncompressed block. Each character of $B_i$ is colored by applying $F_{\mathrm{CVL}}(B_i)$. Divide $B_i$ into blocks $B_i = B'_1B'_2\dots B'_s$, such that for each $B'_j$ only the first character is colored 1. Now, according to Proposition~\ref{thm:color_reduction}, length of each $B'_j$ is either 2 or 3. If $B'_j = ab$, replace it with $C_{\ell}(ab)$ else if $B'_j = abc$, replace it with $C_{\ell}(ab)\cdot c$, where $a,b,c \in \Gamma$. The actual pseudo-code given below performs the compression of blocks of repeats in two stages, where in the first stage we replace the repeated sequence $a^r$ by ${\mathtt{r}}_{a,r} \cdot \#$, and then in the next stage we remove the extra symbol $\#$. This simplifies analysis in Lemma~\ref{l-compress}. Assuming that $C_\ell$ can be evaluated in time $O(1)$, the running time of ${\mathrm{Compress}}(B,\ell)$ is dominated by the time needed to compute $F_{\mathrm{CVL}}$-coloring of blocks which is $O(R \cdot |B|)$ in total.
\begin{algorithm}[H]
\label{algo:compress}
\caption{${\mathrm{Compress}}(B,\ell)$}\label{alg-compress}
\KwIn{String $B$ over alphabet $\Gamma$ of length at least two, and level number $\ell$.}
\KwOut{String $B''$ over alphabet $\Gamma$.}
\vspace{1mm}
\hrule\vspace{1mm}
Divide $B=B_1B_2B_3\dots B_m$ into minimum number of blocks so that each maximal subword $a^r$ of $B$, for $a\in\Gamma$ and $r\ge 2$, is one of the blocks.
\For{each $i\in \{1,\dots, m\}$}{
\lIf{$B_i=a^r$, where $r\ge 2$}{Set $B'_i = {\mathtt{r}}_{a,r} \cdot \#$ and color ${\mathtt{r}}_{a,r}$ by 1 and $\#$ by 2.\footnotemark}
\lElse{Set $B'_i = B_i$ and color each symbol of $B'_i$ according to $F_{\mathrm{CVL}}(B_i)$}
}
Set $B'=B'_1B'_2\cdots B'_m$, $B''=\eps$, and $i = 1$.
\While{$i<|B'|$}{
\lIf{ $B'[i+1] = \#$}{ $B'' = B'' \cdot B'[i]$}
\lElse{ $B'' = B'' \cdot C_\ell(B'[i,i+1])$}
$i = i+2$.
\lIf{$i\le |B'|$ and $B'[i]$ is not colored 1}{
$B'' = B'' \cdot B'[i]$, $i = i+1$
}
}
Return $B''$.
\end{algorithm}
\footnotetext{If $a={\mathtt{r}}_{b,s}$ for some $b\in \Gamma$ and $s\in {\mathbb{N}}$, then set $B'_i = {\mathtt{r}}_{b,{rs}} \cdot \#$. However, such a situation should never happen during the execution of the algorithm as level-$\ell$ compression symbol can be introduced only at level $\ell$.}
${\mathrm{Split}}$. The function takes as input a string $B$ over alphabet $\Gamma$ of length at least two, and an integer $\ell \ge 1$. The function splits the string $B$ into smaller blocks.
The algorithm works as follows:
For each $i \in \{2,\dots, |B|-1\}$, if $H_\ell(B[i,i+1])=0$, start a new block at position $i$.
The running time of ${\mathrm{Split}}(B,\ell)$ is dominated by the time to evaluate $H_\ell$ at $|B|-2$ points.
\begin{algorithm}[H]
\caption{${\mathrm{Split}}(B,\ell)$}\label{alg-split}
\KwIn{String $B$ over alphabet $\Gamma$ of length at least two, and level number $\ell$.}
\KwOut{A sequence of strings $(B_0,B_1,\dots,B_s)$ over alphabet $\Gamma$.}
\vspace{1mm}
\hrule\vspace{1mm}
Let $i_1< \dots <i_s$ be all $i\in \{2,\dots, |B|-1\}$ where $H_\ell(B[i,i+1])=0$. Set $s=0$ if no such $i$ exists.
Let $i_0=1$ and $i_{s+1}=|B|+1$.
For $j=0,\dots, s$, set $B_j = B[i_j,i_{j+1})$.
Return $(B_0,B_1,\dots,B_s)$.
\end{algorithm}
The main recursive step of the algorithm is encompassed in function ${\mathrm{Process}}$. The function gets a block $B\in \Gamma^*$ as its input.
The block might have already been compressed previously, so the function also gets dictionaries that allow decompression of the block.
If the block is already of length at most two, then the function outputs the block.
Otherwise it compresses the block $B$ using ${\mathrm{Compress}}$, then it subdivides the compressed block using ${\mathrm{Split}}$, and invokes itself recursively on each sub-block.
For the output, each block is represented by a grammar. The grammar is reconstructed from the compressed block and its dictionaries by a simple bread-first search algorithm provided in the function ${\mathrm{Grammar}}$.
\begin{algorithm}[H]
\caption{${\mathrm{Process}}(B,(D_1,D_2,\dots,D_{\ell-1}),\ell)$}\label{alg-process}
\KwIn{String $B \in \Gamma^*$, a sequence of dictionaries $D_i \subseteq \Gamma^2$ for decompressing $B$, and level number $\ell$.}
\KwOut{A sequence of blocks of $B$ each encoded by a grammar.}
\vspace{1mm}
\hrule\vspace{1mm}
\lIf{$|B|\le 2$}{
Output ${\mathrm{Grammar}}(B,(D_1,D_2,\dots,D_{\ell-1}),\ell-1)$ and return
}
$A={\mathrm{Compress}}(B,\ell)$.
$(B_0,B_1,\dots,B_s) = {\mathrm{Split}}(A,\ell)$.
For $i=0,\dots, s$, ${\mathrm{Process}}(B_i,(D_1,\dots,D_{\ell-1},{\mathrm{Dict}}(B)),\ell+1)$.
\end{algorithm}
To decompose an input string $x$ into blocks, we first apply function ${\mathrm{Split}}(x,0)$ to $x$ and then invoke ${\mathrm{Process}}(B,(),1)$ on each of the obtained blocks $B$.
Breaking the string $x$ into sub-blocks guarantees that each block passed to ${\mathrm{Process}}$ has small dictionary whereas the dictionary of $x$ could have been arbitrarily large.
\begin{algorithm}[H]
\label{alg-prune}
\caption{${\mathrm{Grammar}}(B,(D_1,D_2,\dots,D_{\ell}),\ell)$}
\KwIn{String $B \in \Gamma^*$, a sequence of dictionaries $D_i \subseteq \Gamma^2$ for decompressing $B$.}
\KwOut{The smallest grammar $G$ for $B$ based on the dictionaries $D_i$ and hash functions $C_1,\dots,C_\ell$.}
\vspace{1mm}
\hrule\vspace{1mm}
Let $C = \{c \in \Sigma_c: c \text{ appears in }B\text{ or }{\mathtt{r}}_{c,r} \text{ appears in }B \text{ for some }r\}$. {\em \hfil // Symbols needed to decompress $B$}
$G = \{ \# \rightarrow B\}$.
\For{ $j=\ell,\dots, 1$}
{
\For{each $ab \in D_j$}{
\lIf{$C_{j}(ab) \in C$}{
$G =G \cup \{ C_{j}(ab) \rightarrow ab\}$,
\Indp$C = C \cup \{c \in \Sigma_c; c \in \{a,b\} \text{ or }{\mathtt{r}}_{c,r} \in \{a,b\} \text{ for some }r\}$
}
}
}
For each ${\mathtt{r}}_{a,r}$ appearing in any of the rules in $G$, add ${\mathtt{r}}_{a,r} \rightarrow a^r$ to $G$.
Return $G$.
\end{algorithm}
\subsection{Correctness of the decomposition algorithm}\label{s-correctness}
Our goal is to establish the following theorem which is a stronger version of Theorem~\ref{t-main1}:
\begin{theorem}\label{t-decomposition}
Let $x$ and $y$ be a pair of strings of length at most $n$ with $\ED(x,y) \le k$. Let $G^x_1,\dots,G^x_s$ and $G^y_1,\dots,G^y_{s'}$
be the sequence of grammars output by the decomposition algorithm on input $x$ and $y$ respectively, using the same choice of random functions
$C_1,\dots,C_L$ and $H_0,\dots,H_L$. The following is true for $n$ large enough:
\begin{enumerate}
\item With probability at least $1-2/n$, $x={\mathrm{eval}}(G^x_1)\cdots {\mathrm{eval}}(G^x_s)$ and $y={\mathrm{eval}}(G^y_1)\cdots {\mathrm{eval}}(G^y_{s'})$.
\item With probability at least $1-2/\sqrt{n}$, for all $i \in \{1,\dots,s\}$ and $j\in \{1,\dots, s'\}$, $|G^x_i|,|G^y_j| \le S$.
\item With probability at least $9/10$, $s=s'$, $G^x_i=G^y_i$, for all $i\in \{1,\dots,s\}$ except for at most $k$ indices $i$, and
$\ED(x,y)=\sum_i \ED({\mathrm{eval}}(G^x_i),{\mathrm{eval}}(G^y_i))$.
\end{enumerate}
\end{theorem}
By union bound, all three parts happen simultaneously with probability at least $9/10-2/n-1/\sqrt{n}$ which is $\ge 4/5$ for $n$ large enough.
To prove the theorem we make some simple observations about the algorithm, first.
\begin{lemma}
For any string $B$ of length at least two, and $\ell \ge 1$, $|{\mathrm{Compress}}(B,\ell)| \le \frac{2}{3}|B|+1$ and $|{\mathrm{Compress}}(B,\ell)|<|B|$.
\end{lemma}
\begin{proof}
Let $B=B_1B_2B_3\dots B_m$ be as in the procedure.
Every block $B_i$ that equals to $a^r$, for some $a$ and $r\ge 2$, is reduced to one symbol by the compression.
The other blocks are colored using $F_{\mathrm{CVL}}(\cdot)$ and compressed.
Unless a block $B_i$ is of size one, the coloring induces division of the block $B_i$ into subwords of size two or three,
where the former is compressed into one symbol and the latter into two symbols.
Hence, each such a block is compressed to at most $2/3$ of its size.
So the only blocks $B_i$ that do not shrink are of size one, and are sandwiched between blocks of repeated symbols
(that shrink by a factor of at least two).
The worst-case situation is when $m$ is odd, blocks $B_i$ are of size one for odd $i$,
and of size two for even $i$. In that case the original string $B$ shrinks to size $\lfloor \frac{2}{3}|B| \rfloor + 1$.
This proves the first inequality.
The second inequality is also clear from the analysis above: The only time the string does not shrink is if it is of size one.
\end{proof}
\begin{corollary}\label{c-decomposition1}
On a string $B$ of length at most $n$, the depth of the recursive calls of ${\mathrm{Process}}$ is at most $L$.
\end{corollary}
Indeed, from the previous lemma it follows that each block after $\ell$ compressions and splits is of size at most $(2/3)^\ell |B| + 3$.
Hence, after $L=\lceil \log_{3/2} n \rceil+3$ recursive calls ${\mathrm{Process}}$ must stop the recursion.
\begin{lemma}\label{l-decomposition1}
Let $B\in \Gamma^*$ be of length at most $n$, and $\ell \in \{0,\dots,L\}$. Let $(B_0,B_1,\dots, B_s)={\mathrm{Split}}(B,\ell)$ where $H_\ell : \Gamma^2 \rightarrow \{0,\dots,D-1\}$ is chosen at random from $(5D \log n)$-wise independent hash family. Then with probability at least $1-1/n^3$, for all $j\in \{0,\dots,s\}$, $|{\mathrm{Dict}}(B_j)| \le 5D \log n$.
\end{lemma}
\begin{proof}
If for some $j\in \{0,\dots,s\}$, $|{\mathrm{Dict}}(B_j)| > 5D \log n$, then there exists $1 < r < t \le |B|$ such that $|{\mathrm{Dict}}(B[r,t])| = 5D \log n$
and for all $i\in \{r,\dots,t-1\}$, $H_\ell(B[i,i+1]) \neq 0$.
(Pick $r$ to be the position in $B$ of the second symbol of $B_j$ and $r$ some later position in $B_j$.)
For a fixed $r$ and $t$ with $|{\mathrm{Dict}}(B[r,t])| = 5D \log n$, $\Pr_{H_\ell}[ \forall i \in \{r,\dots,t-1\}, H_\ell(B[i,i+1])\neq 0] \le \left(1-\frac{1}{D}\right)^{5D \log n}$ by the $(5D \log n)$-wise independence of $H_\ell$.
Hence, $\Pr_{H_\ell}[ \exists 1<r<t \le |B|, |{\mathrm{Dict}}(B[r,t])| = 5D\log n \text{ and } \forall i \in \{r,\dots,t-1\}, H_\ell(B[i,i+1])\neq 0] \le |B|^2 \left(1-\frac{1}{D}\right)^{5D\log n} \le n^2 e^{-5\log n} \le 1/n^3.$
\end{proof}
\begin{lemma}
For $B\in \Gamma^*$, $\ell \le L$, $D_1,D_2,\dots,D_\ell \subseteq \Gamma^2$, ${\mathrm{Grammar}}(B,(D_1,\dots,D_\ell),\ell)$ outputs a grammar $G$ of size at most $3|B|+ 6\sum_i |D_i|$, and runs in time ${\widetilde{O}}(|B|+\sum_i |D_i|$).
\end{lemma}
\begin{proof}
The main loop of the algorithm iterates over all the pairs from $D_j$. In each iteration we can add a rule of the type $c \rightarrow ab$ to $G$.
Hence, the number of such rules in $G$ is at most $|B|+2\sum_i |D_i|$.
Last, we add to $G$ rules for symbols from $\Sigma_r$ that appear on right hand sides of rules in $G$.
This increases the size of $G$ by at most factor of 3.
If $C$ is stored using some efficient data structure such as binary search trees or hash tables, each iteration takes ${\widetilde{O}}(1)$ time.
(We assume that evaluation of $C_j(\cdot)$ takes $O(1)$.) Hence, the total running time is bounded by claimed bound.
\end{proof}
During processing of a string $x$, there are at most $Ln$ calls to the function ${\mathrm{Split}}$.
(The actual number of calls is $O(n)$ as the strings shrink exponentially but our simple upper bound suffices.)
The probability that any one of them would produce a block with dictionary larger than $5D \log n$ is at most $Ln/n^3$.
We can conclude the next corollary which implies the second item of Theorem~\ref{t-decomposition}.
\begin{corollary}\label{c-part2}
For $n$ large enough, on a string $x$ of length at most $n$,
processing the string $x$ produces a sequence of grammars each of size at most $S=30 DL \log n + 6$
with probability at least $1-1/n$.
\end{corollary}
For the grammars produced by the algorithm to be deterministic, we need that each $C_\ell$ is one-to-one on ${\mathrm{Dict}}(B)$
for each block $B$ on which ${\mathrm{Compress}}(B,\ell)$ is invoked. That will happen with high probability by a standard argument:
\begin{lemma}\label{l-onetoone}
Let $B\in \Gamma^*$ be of length at most $n$ and $\ell \in \{1,\dots,L\}$.
Let $C_\ell:\Gamma^2 \rightarrow \{{\mathtt{c}}_i,\, (\ell-1) n^3 < i \le \ell n^3 \}$ be chosen at random from a pair-wise independent family of hash functions.
Then with probability at least $1-|B|/n^2$, $C_\ell$ is one-to-one on ${\mathrm{Dict}}(B)$.
\end{lemma}
\begin{proof}
For two distinct elements from ${\mathrm{Dict}}(B)$, the probability of a collision for randomly chosen $C_\ell$ is at most $1/n^3$.
By the union bound, the probability that $C_\ell$ is not one-to-one on ${\mathrm{Dict}}(B_j)$ is at most $|{\mathrm{Dict}}(B)|^2/n^3 \le |B|/n^2$ as $|{\mathrm{Dict}}(B)|\le |B|\le n$.
\end{proof}
During processing of a string $x$, there are at most $Ln$ calls to the function ${\mathrm{Compress}}$.
For a fixed level $\ell \in \{1,\dots,L\}$, the total size of blocks $B$ for which ${\mathrm{Compress}}(B,\ell)$ is invoked
is at most $n$.
By the previous lemma and the union bound, the probability that during any of those calls ${\mathrm{Compress}}(B,\ell)$ uses
a function $C_\ell$ that is not one-to-one on ${\mathrm{Dict}}(B)$ is at most $1/n$.
If all the hash functions $C_1, C_2,\dots, C_L$ that are used to compress blocks of $x$ are one-to-one on their respective blocks then the grammars that ${\mathrm{Grammar}}$ produces will be deterministic, and they will evaluate to their respective blocks of $x$.
(We can actually conclude a stronger statement that each $C_\ell$ will be one-to-one on the union of all blocks at level $\ell$ with high probability.)
We can conclude the next corollary which implies the first item of Theorem~\ref{t-decomposition}.
\begin{corollary}\label{c-part1}
For $n$ large enough, on a string $x$ of length at most $n$, with probability at least $1-L/n$,
processing the string $x$ produces a sequence of grammars $G_1,G_2,\dots, G_s$
such that $x={\mathrm{eval}}(G_1) \cdots {\mathrm{eval}}(G_s)$.
\end{corollary}
At this point we can estimate the running time of the decomposition algorithm.
We can let the algorithm fail, and produce some trivial decomposition of $x$,
whenever ${\mathrm{Split}}$ produces a block with dictionary larger than $5D \log n$.
If it does not fail, then all grammars are of size at most $S$ which is ${\widetilde{O}}(k)$.
There are at most $n$ of them so time spent in ${\mathrm{Grammar}}(\dots)$ is bounded by ${\widetilde{O}}(nk)$.
The total time spent in ${\mathrm{Compress}}(\dots)$ is proportional to the sum of sizes of all non-trivial blocks over all levels
of recursion which is $O(nL)={\widetilde{O}}(n)$.
(A more accurate estimate on the total size of blocks is $O(n)$ since the blocks are shrinking geometrically in each iteration.)
This means that the time to execute all calls to ${\mathrm{Compress}}$ is $O(nL R) = {\widetilde{O}}(n)$.
The time spent in ${\mathrm{Split}}(\dots)$ is dominated by the time needed to evaluate $H_\ell$.
The number of evaluation points at a given level $\ell$ is proportional to the total size of all blocks at that level.
Since $H_\ell$ can be evaluated at a single point in time $O(D \log n)={\widetilde{O}}(k)$, we get a trivial upper bound $O(nL D \log n)={\widetilde{O}}(nk)$ on time spent in ${\mathrm{Split}}$.
Hence, in total the decomposition procedure runs in time ${\widetilde{O}}(nk)$.
(We believe that the total running time can be improved to ${\widetilde{O}}(n)$ on average.
One could argue that in expectation the number of grammars the procedure produces is ${\widetilde{O}}(n/k)$
as the average block size a string $x$ is decomposed into should be at least $\Omega(D/\log n)$.
So we believe that the total running time of calls to ${\mathrm{Grammar}}$ is ${\widetilde{O}}(n)$.
Using multi-point evaluation of $(5D \log n)$-wise independent hash functions we could reduce the time for
evaluation of $H_\ell$ on a given level to ${\widetilde{O}}(n)$.)
\begin{proposition}
Given $k\le n$, the running time of the decomposition algorithm on a string $x$ of length at most $n$ is ${\widetilde{O}}(nk)$ with probability at least $1-1/n$.
\end{proposition}
It remains to address the properties of the algorithm run on a pair of strings $x$ and $y$ of edit distance at most $k$ to establish Theorem~\ref{t-decomposition}.
For the pair of strings $x$ and $y$ we fix a {\em canonical decomposition of $x$ and $y$} to be a sequence of words $w_0,w_1,\dots,w_k, u_i,\dots, u_k, v_1, \dots, v_k \in \Gamma^*$ such that $x=w_0 u_1 w_1 u_2 w_2\cdots u_k w_k$, $y=w_0 v_1 w_1 v_2 w_2 \cdots v_k w_k$
and $|u_i|,|v_i| \le 1$ for all $i$. By the definition of edit distance such a decomposition exists: each pair $(u_i, v_i)$ represents one edit operation, and we fix one such decomposition to be {\em canonical}.
Observe, if we now partition $x$ into blocks $B^x_1,\dots,B^x_s$ so that each $B^x_i$ starts within one of the $w_j$'s,
and we partition $y$ into blocks $B^y_1,\dots,B^y_s$ so that each block $B^y_i$ starts at the corresponding location in $w_j$ as $B^x_i$,
then $\ED(x,y)=\sum_i \ED(B^x_i,B^y_i)$.
We need to understand what happens with the decomposition of $x$ and $y$ when we apply the ${\mathrm{Compress}}$ function.
Let $x=uwv$ and $x'={\mathrm{Compress}}(x,\ell)=u'w'v'$, for some $u,w,v,u'w'v' \in \Gamma^*$.
We say that a symbol $c$ in $w'$ {\em comes from the compression of $w$}
if either it is directly copied from $w$ by ${\mathrm{Compress}}$, or
it is the image $c=C_\ell(ab)$ of a pair of symbols $ab$ where $a$ belongs to $w$, or
$c={\mathtt{r}}_{a,r}$ replaced a block $a^r$ where the first symbol of $a^r$ belongs to $w$.
{\em $w'$ is the compression of $w$} if it consists precisely of the symbols that come from the compression of $w$.
Furthermore, we say a symbol $c$ in $w'$ {\em comes weakly from the compression of $w$}
if either it is directly copied from $w$ by ${\mathrm{Compress}}$, or
it is the image $c=C_\ell(ab)$ of a pair of symbols $ab$ where $a$ or $b$ belong to $w$, or
$c={\mathtt{r}}_{a,r}$ replaced a block $a^r$ where some symbol of $a^r$ belongs to $w$.
{\em $w'$ is the weak compression of $w$} if it consists precisely of the symbols that come weakly from the compression of $w$.
Notice, a weak compression of $w$ might contain and extra symbol at the beginning compared to the compression of $w$.
The following lemma captures what compression does to the canonical decomposition of $x$ and $y$. (See Fig.~\ref{fig:compression} for illustration.)
\begin{lemma}\label{l-compress}
Let $x$ and $y$ be strings over $\Gamma$, and let $x'={\mathrm{Compress}}(x,\ell)$ and $y'={\mathrm{Compress}}(y,\ell)$.
Let $x=w_0 u_1 w_1 u_2 w_2\cdots u_q w_q$ and $y=w_0 v_1 w_1 v_2 w_2 \cdots v_q w_q$ for some strings $w_i$, $u_i$ and $v_i$ where for $i\in \{1,\dots,q\}$, $|u_i|,|v_i| \le 4R + 24$.
Then there are $w'_0,w'_1, \dots, w'_q,u'_1, \dots, u'_q,v'_1, \dots, v'_q \in \Gamma^*$ such that
for $i\in \{1,\dots,q\}$, $|u'_i|,|v'_i| \le 4R + 24$, $x'=w'_0 u'_1 w'_1 u'_2 w'_2\cdots u'_q w'_q$
and $y'=w'_0 v'_1 w'_1 v'_2 w'_2\cdots v'_q w'_q$.
Moreover, each $w'_i$ is the compression of the same subword of $w_i$ in both $x$ and $y$.
\end{lemma}
For each $x=w_0 u_1 w_1 u_2 w_2\cdots u_q w_q$, $y=w_0 v_1 w_1 v_2 w_2 \cdots v_q w_q$ and $\ell$ we fix one choice of $w'_0,\dots, w'_q,$ $u'_0, \dots, u'_q,$ $v'_0,\dots, v'_q$ satisfying the lemma. We will refer to it as the {\em canonical decomposition} of $x'$ and $y'$ induced by the decomposition of $x$ and $y$ as given by the lemma.
\begin{proof}
The first stage of ${\mathrm{Compress}}$ replaces maximal blocks of repeated symbols by shortcuts. To simplify our analysis first we will reassign blocks of repeated symbols
among neighboring blocks of $w_i$, $u_i$ and $v_i$, resp., so each maximal block of symbols in $x$ and $y$ is fully contained in one of the words $w_i$, $u_i$ or $v_i$.
For $i=1,\dots, q-1$ we define words $w^{(1)}_i$ and parameters $a_i, b_i \in \Gamma$ and $k_i, k'_i \in {\mathbb{N}}$ as follows: If $w_i$ contains at least two distinct symbols
let $w_i=a_i^{k_i} w^{(1)}_i b_i^{k'_i}$ so that $k_i$ and $k'_i$ are maximum possible, otherwise $w_i=a_i^{k_i}$ for some $a_i$ and $k_i$ ($k_i$ might be zero), and we set $w^{(1)}_i = \eps$, $b_i=a_i$ and $k'_i=0$.
Let $w_0=w^{(1)}_0 b_0^{k'_0}$ for maximum possible $k'_0$ and some symbol $b_0$.
Let $w_q= a_q^{k_q} w^{(1)}_q$ for maximum possible $k_q$ and some symbol $a_q$.
For $i=1,\dots,q$, we let $u^{(1)}_i = b^{k'_{i-1}}_{i-1} u_i a^{k_i}_i$.
Similarly, $v^{(1)}_i = b^{k'_{i-1}}_{i-1} v_i a^{k_i}_i$. Hence, $x=w^{(1)}_0 u^{(1)}_1 w^{(1)}_1 \cdots u^{(1)}_q w^{(1)}_q$ and $y=w^{(1)}_0 v^{(1)}_1 w^{(1)}_1 \cdots v^{(1)}_q w^{(1)}_q$.
Next, if there is a maximal block of symbols $a^r$ contained in $u^{(1)}_s w^{(1)}_s \cdots u^{(1)}_t$ starting in $u^{(1)}_s$ and ending in $u^{(1)}_t$, $s\neq t$, we add all the symbols of the $a^r$ to the end of $u^{(1)}_s$ and remove them from the other $u^{(1)}_i$, $i=s+1,\dots,t$. (Notice, $w^{(1)}_i=\eps$ for $s<i<t$ because of the definition of $w^{(1)}_i$, and $u^{(1)}_i$ will become empty for $s<i<t$.) We do this for all maximal blocks of repeated symbols that span multiple $u^{(1)}_i$. We perform similar moves on $v^{(1)}_i$'s.
After all of those moves we denote the resulting subwords by $w^{(2)}_i$, $u^{(2)}_i$, and $v^{(2)}_i$. (Notice, $w^{(2)}_i=w^{(1)}_i$ for all $i$.)
We have: $x=w^{(2)}_0 u^{(2)}_1 w^{(2)}_1 \cdots u^{(2)}_q w^{(2)}_q$ and $y=w^{(2)}_0 v^{(2)}_1 w^{(2)}_1 \cdots v^{(2)}_q w^{(2)}_q$.
At this stage, each maximal block of repeated symbols in $x$ or $y$ is contained in one of the subwords $w^{(2)}_i$, $u^{(2)}_i$, and $v^{(2)}_i$.
The first stage of ${\mathrm{Compress}}$ replaces each maximal block $a^r$, $r\ge 2$, by a sequence ${\mathtt{r}}_{a,r} \#$,
and we apply this procedure on each subword $w^{(2)}_i$, $u^{(2)}_i$, and $v^{(2)}_i$ to obtain corresponding subwords $w^{(3)}_i$, $u^{(3)}_i$,
and $v^{(3)}_i$.
Observe, for $i=1,\dots,q$, $|u^{(3)}_i|,|v^{(3)}_i| \le 4R + 28$.
This is because every $u_i$ is transformed into $u^{(3)}_i$ by appending or prepending possibly empty block of repeated symbols, i.e., $u^{(3)}_i = a^r u_i b^{r'}$ for some $a,b,r,r'$, or removing its content entirely.
Each block of repeats is reduced to two symbols so each $u^{(3)}_i$ is longer than the original by at most 4 symbols. Similarly for $v^{(3)}_i$.
Next, coloring function $F_{\mathrm{CVL}}$ is used on parts of $x$ and $y$ that are not obtained from repeated symbols; the two symbols replacing each repeated block are colored by $1$ and $2$, resp.
We refer to this as $\{1,2,3\}$-coloring. At most $R$ first and last symbols of each $w^{(3)}_i$ might be colored differently in $x$ and $y$ as the color of each symbol depends on the context of at most $R$ symbols on either side of the symbol, and that context might differ in $x$ and $y$.
Hence, only symbols near the border of $w^{(3)}_i$ that are in vicinity of $u^{(3)}_i$'s and $v^{(3)}_i$'s, resp., might get different colors.
All the other symbols of $w^{(3)}_i$ are colored the same in both $x$ and $y$.
The coloring is then used to make decisions on which pairs of symbols are compressed into one.
We will let $u'_i$ be the symbols that come from the compression of symbols in $u^{(3)}_i$,
the first up-to $R+2$ symbols of $w^{(3)}_i$, and the last up-to $R+3$ symbols of $w^{(3)}_{i-1}$.
Next we specify precisely which symbols of $w^{(3)}_i$ and $w^{(3)}_{i-1}$ are considered to be compressed into symbols belonging to $u'_i$.
For $i=0,\dots, q$, if $|w^{(3)}_i| \ge R+3$, let $s^x_i$ be the position of the first symbol in $w^{(3)}_i$ among positions $R+1,R+2,R+3$ which is colored 1 in $x$ by the $\{1,2,3\}$-coloring.
If $|w^{(3)}_i| < R+3$, let $s^x_i=1$.
Next, if $|w^{(3)}_i| \ge 2R+3$ set $t^x_i$ to be the first position from left colored 1 among the symbols of $w^{(3)}_i$ at positions $R+1, R+2, R+3$ counting from right.
If $|w^{(3)}_i| < 2R+3$, set $t^x_i$ to be equal to $s^x_i$.
For $i=0$, if $|w^{(3)}_0| \ge R+3$ then redefine $s^x_0=1$.
For $i=q$, redefine $t^x_q=|w^{(3)}_q|+1$ and if $|w^{(3)}_q| < R+3$ then redefine $s^x_q$ to $t^x_q$.
Similarly, define $s^y_i$ and $t^y_i$ based on the $\{1,2,3\}$-coloring of $y$.
Notice, $s^x_i\neq t^x_i$ iff $s^y_i\neq t^y_i$.
Furthermore, if $s^x_i\neq t^x_i$ then either $i \in \{q,0\}$ or $|w^{(3)}_i| \ge 2R+3$ so $s^x_i=s^y_i$ and $t^x_i=t^y_i$ as the symbols $R$-away from either end of $w^{(3)}_i$ are colored the same in $x$ and $y$.
We let $u'_i$ to be the compression of $w^{(3)}_{i-1}[t^x_{i-1},|w^{(3)}_{i-1}|] \cdot u^{(3)}_i \cdot w^{(3)}_i[1,s^x_i)$ and
similarly, $v'_i$ to be the compression of $w^{(3)}_{i-1}[t^y_{i-1},|w^{(3)}_{i-1}|] \cdot v^{(3)}_i \cdot w^{(3)}_i[1,s^y_i)$.
We let $w'_i$ be the compression of $w^{(3)}_i[s^y_i,t^y_i)$.
Hence, $u'_i$ comes from the compression of at most $|u^{(3)}_i| + 2R+5 \le 6R + 33$ symbols.
Since each symbol after a symbol colored 1 is {\em removed} by the compression, and each consecutive triple of symbols contains at least one symbol colored by 1, the at most $6R + 27$ symbols are compressed into at most $(6R + 33)\cdot 2/3 + 2 =4R+24$ symbols. So $u'_i$ is of length at most $4R+24$. Similarly for $v'_i$.
\end{proof}
The following generalization of the previous lemma will be useful to design a rolling sketch.
It considers situation where $x$ and $y$ are prefixed by some strings $u$ and $v$, resp., that we want to ignore from the analysis. The proof of the lemma is a straightforward modification of the above proof.
\begin{lemma}\label{l-compress-rolling}
Let $x,y,u,v\in \Gamma^*$, and let $u'x'={\mathrm{Compress}}(ux,\ell)$ and $v'y'={\mathrm{Compress}}(vy,\ell)$, where
$x'$ is the weak compression of $x$, and $y'$ is the weak compression of $y$.
Let $x=u_0w_0 u_1 w_1 u_2 w_2\cdots u_q w_q$ and $y=v_0w_0 v_1 w_1 v_2 w_2 \cdots v_q w_q$ for some strings $w_i$, $u_i$ and $v_i$ where for $i\in \{0,\dots,q\}$, $|u_i|,|v_i| \le 4R + 24$.
Then there are $w'_0,w'_1, \dots, w'_q,u'_0,u'_1, \dots, u'_q,v'_0,v'_1, \dots, v'_q \in \Gamma^*$ such that
for $i\in \{0,\dots,q\}$, $|u'_i|,|v'_i| \le 4R + 24$, $x'=u'_0w'_0 u'_1 w'_1 u'_2 w'_2\cdots u'_q w'_q$
and $y'=v_0'w'_0 v'_1 w'_1 v'_2 w'_2\cdots v'_q w'_q$.
Moreover, each $w'_i$ is the compression of the same subword of $w_i$ in both $x$ and $y$.
\end{lemma}
Let $x\in \Sigma^*$. Let $H_0,H_1,\dots,H_L, C_1,C_2,\dots,C_L$ be chosen.
We define inductively the {\em trace} of the algorithm on $x$ at level $\ell\ge 0$ to consist of sequences
$B^{x}(\ell,1),\dots, B^{x}(\ell,s^{x}_{\ell}) \in \Gamma^*$, of auxiliary sequences $A^{x}(\ell,1),\dots, A^{x}(\ell,{s^{x}_{\ell}}) \in \Gamma^*$ and $t^{x}_{\ell,1},\dots, t^{x}_{\ell,{s^{x}_{\ell}+1}} \in {\mathbb{N}}$.
Their meaning is: $B^x(\ell,i)$ is compressed into $A^x(\ell,i)$ and that is split into blocks $B^x(\ell+1,j)$ for $t^x_{\ell+1,i} \le j < t^x_{\ell+1,i+1}$. (See Fig.~\ref{fig:hierarchy} for illustration.)\footnote{To avoid double and triple indexes we use our notation $B^x(\ell,i)$ and $A^x(\ell,i)$ instead of the usual $B^x_{\ell,i}$ and $A^x_{\ell,i}$.}
Set $$B^{x}(0,1),\dots, B^{x}(0,{s^x_0})={\mathrm{Split}}(x,0).$$
For $\ell=1,\dots,L$ we define $B^{x}(\ell,1),\dots, B^{x}(\ell,s^x_\ell)$ inductively. Set $t^{x}_{\ell,1}=1$.
For $i=1,\dots, s^{x}_{\ell-1}$, if $|B^{x}(\ell-1,i)| \ge 2$, then
$$A^{x}(\ell-1,i) = {\mathrm{Compress}}(B^{x}(\ell-1,i),\ell),$$
and for $(B_0,B_1,\dots,B_s)= {\mathrm{Split}}(A^{x}(\ell-1,i),\ell)$ set
$$B^{x}(\ell,{t^{x}_{\ell,i}}) = B_0,\,\,\, B^{x}(\ell,{t^{x}_{\ell,i}+1}) = B_1,\,\,\, \dots,\,\,\, B^{x}(\ell,{t^{x}_{\ell,i}+s}) = B_s$$
and $t^{x}_{\ell,{i+1}} = t^{x}_{\ell,i} + s +1$.
If $|B^{x}(\ell-1,i)| < 3$, then set
$B^{x}(\ell,{t^{x}_{\ell,i}})$ and $A^{x}(\ell-1,i)$ to $B^{x}(\ell-1,i),$ and $t^{x}_{\ell,{i+1}} = t^{x}_{\ell,i} + 1$.
For $j=s^{x}_{\ell-1}$, set $s^{x}_{\ell} = t^{x}_{\ell,j+1}$.
\begin{figure}[htp]
\centering
\includegraphics[width=\textwidth]{ed_sketch_img1.pdf}
\caption{The hierachical decomposition of $x$.}
\label{fig:hierarchy}
\end{figure}
\medskip
Furthermore, for $x$ and $y\in \Sigma^*$, $\ell, i\ge 0$, define a canonical decomposition of blocks $A^x(\ell,i),$ $B^x(\ell,i),$ $A^y(\ell,i),$ $B^y(\ell,i)$ inductively as follows.
Let $A^x(-1,1)=x$ and $A^y(-1,1)=y$. Let $t^x_{-1,1}=1, t^x_{-1,2}=2,$ $s^x_{-1}=1$, $t^y_{-1,1}=1,$ $t^y_{-1,2}=2$, and $s^y_{-1}=1$.
Let $$A^x(-1,1)=w_0 u_1 w_1 u_2 w_2\cdots u_k w_k \,\,\,\,\&\,\,\,\,
A^y(-1,1)=w_0 v_1 w_1 v_2 w_2 \cdots v_k w_k$$ be the canonical decomposition of the pair $x$ and $y$.
For $\ell \ge 0$ and $j\in \{1,\dots, s^{x}_{\ell}\}$, let $i$ be such that
$t^x_{\ell-1,i} \le j < t^x_{\ell-1,i+1}$ and $m=j-t^x_{\ell-1,i}$.
Then $B^x(\ell,j)$ is the $m$-th block of ${\mathrm{Split}}(A^x(\ell-1,i),\ell)$.
If the decomposition of $A^x(\ell-1,i)$ is defined and is equal to $w_0 u_1 w_1 u_2 w_2\cdots u_q w_q$, for some $u_i,w_i\in \Gamma^*$, then
the decomposition of $B^x(\ell,j)$ is the restriction of the decomposition of $A^x(\ell-1,i)$
to symbols of the $m$-th block of ${\mathrm{Split}}(A^x(\ell-1,i),\ell)$. Otherwise the decomposition of $B^x(\ell,j)$ is undefined. Similarly for $B^y(\ell,j)$. (See Fig.~\ref{fig:compression}.)
For $\ell \ge 0$ and $j\in \{1,\dots, s^{x}_{\ell}\}$, if $B^x(\ell,j)$ and $B^y(\ell,j)$ have defined decompositions $B^x(\ell,j)= w_0 u_1 w_1 u_2 w_2\cdots u_q w_q$ and $B^y(\ell,j)=w_0 v_1 w_1 v_2 w_2\cdots v_q w_q$ for some $u_i,v_i,w_i \in \Gamma^*$,
then we let $A^x(\ell,j) = w'_0 u'_1 w'_1 u'_2 \cdots w'_{q}$
and $A^y(\ell,j) = w'_0 v'_1 w'_1 v'_2 \cdots w'_{q}$ be their canonical decomposition induced by $B^x(\ell,j)$ and $B^x(\ell,j)$ as given by Lemma~\ref{l-compress}.
\begin{figure}[htp]
\centering
\includegraphics[width=\linewidth]{ed_sketch_img2.pdf}
\caption{Decomposition of $B^x(\ell,i)$ after compression and split.}
\label{fig:compression}
\end{figure}
\bigskip
To conclude item 3 of Theorem~\ref{t-decomposition} we want to argue that $x$ and $y$ are recursively split into sub-blocks that respect their canonical decomposition. So we want all splits of blocks to occur in matching parts of $x$ and $y$. For $A^x(\ell-1,i)$ with canonical decomposition
$w_0 u_1 w_1 u_2 w_2\cdots u_q w_q$ we say that ${\mathrm{Split}}(A^x(\ell-1,i), \ell)$ makes {\em undesirable split} if it starts a new block at a position $j$
that either belongs to one of the $u_1,u_2,\dots,u_q$ or is the first or last symbol of one of the $w_0,w_1,\dots,w_q$.
Recall, ${\mathrm{Split}}(A^x(\ell-1,i), \ell)$ starts a new block at each position $j$ such that $H_\ell(A^x(\ell-1,i)[j,j+1])=0$.
Since $H_\ell$ is chosen at random a given position starts a new block with probability $1/D$.
Similarly, for $A^y(\ell-1,i)$ with canonical decomposition
$w'_0 v_1 w'_1 v_2 \cdots v_{q'} w'_{q'}$ we say that ${\mathrm{Split}}(A^y(\ell-1,i), \ell)$ makes {\em undesirable split}
if it starts a new block at a position $j$ that either belongs to one of the $v_1,v_2,\dots,v_{q'}$ or is the first or last symbol of one of
the $w'_0,w'_1,\dots,w'_{q'}$.
If $A^x(\ell-1,i)$ and $A^y(\ell-1,i)$ have {\em matching} canonical decomposition (that is $q=q'$ and each $w_j=w'_j$)
and both ${\mathrm{Split}}(A^x(\ell-1,i), \ell)$ and ${\mathrm{Split}}(A^y(\ell-1,i), \ell)$ make no undesirable split then $A^x(\ell-1,i)$ and $A^y(\ell-1,i)$
are split in the same number of blocks with matching canonical decomposition as they are split at the same positions in the corresponding $w_j$'s.
For given $\ell \in \{0,\dots,L\}$, if no undesirable split happens during ${\mathrm{Split}}(A^x(\ell'-1,i), \ell')$ and ${\mathrm{Split}}(A^y(\ell'-1,i), \ell')$, for any $\ell' < \ell$ and $i$,
then for each $\ell' < \ell$, the number of blocks $B^x(\ell',i)$ and $B^y(\ell',i)$ will be the same, i.e., $s^x_{\ell'} = s^y_{\ell'}$, and blocks
$B^x(\ell',i)$ and $B^y(\ell',i)$ will have matching canonical decomposition.
The total number of $u_j$'s in canonical decomposition of all $B^x(\ell',i)$, $i=1,\dots,t^x_{\ell'}$, will be at most $k$, and similarly for $v_j$'s.
Thus, there will be at most $(4R+24+2)k+2$ positions where an undesirable split can happen in ${\mathrm{Split}}(A^x(\ell-1,i), \ell)$
for any $i$. Similarly, there are at most $(4R+26)k+2$ positions where an undesirable split can happen in ${\mathrm{Split}}(A^y(\ell-1,i), \ell)$.
By union bound, the probability that an undesirable split happens in some ${\mathrm{Split}}(A^y(\ell-1,i), \ell)$ or ${\mathrm{Split}}(A^y(\ell-1,i), \ell)$,
for some $\ell$ and $i$, is at most $2(4R+28)k(L+1)/D \le 11 R k (L+1) / D \le 1/10$.
Thus, if no undesirable split happens there are at most $k$ indices $i$ for which the canonical decomposition of $B^x(\ell,i)$ contains some $u_j$.
All other blocks $B^x(\ell,i)$ have a canonical decomposition consisting of a single block $w_0$, for various $w_0$ depending on $\ell$ and $i$.
Similarly, the canonical decomposition of $B^y(\ell,i)$ contains $v_j$ if and only if $B^x(\ell,i)$ contains $u_j$.
Blocks $B^y(\ell,i)$ that do not contain $v_j$ are identical to $B^x(\ell,i)$ so they have the same grammar.
Hence, if no undesirable split happens, item 3 of Theorem~\ref{t-decomposition} will be satisfied.
\smallskip
The following theorem generalizes item 3 of Theorem~\ref{t-decomposition} and it will be useful to construct the rolling sketch in Section~\ref{s-rolling}.
\begin{theorem}\label{t-decomposition-rolling}
Let $u,v,x,y\in \Sigma^*$ be strings such that $|ux|,|vy|\le n$ and $\ED(x,y) \le k$. Let $G^x_1,\dots,G^x_s$ and $G^y_1,\dots,G^y_{s'}$
be the sequence of grammars output by the decomposition algorithm on input $ux$ and $vy$ respectively, using the same choice of random functions
$C_1,\dots,C_L$ and $H_0,\dots,H_L$. With probability at least $1-1/5$ the following is true: There exist integers $r,r',t,t'$ such that $s-t=s'-t'$,
$$x = {\mathrm{eval}}(G^x_t)[r,\dots] \cdot {\mathrm{eval}}(G^x_{t+1}) \cdots {\mathrm{eval}}(G^x_s) \;\;\;\&\;\;\;y={\mathrm{eval}}(G^y_{t'})[r',\dots] \cdot {\mathrm{eval}}(G^y_{t'+1})\cdots {\mathrm{eval}}(G^y_{s'}),$$
and $$\ED(x,y)=\ED({\mathrm{eval}}(G^x_{t})[r,\dots], {\mathrm{eval}}(G^y_{t'})[r',\dots]) + \sum_{i>0} \ED({\mathrm{eval}}(G^x_{t+i}),{\mathrm{eval}}(G^y_{t'+i})).$$
\end{theorem}
Its proof is a minor modification of the proof above.
We start with the canonical decomposition of $x=w_0 u_1 w_1 \cdots u_k w_k$ and $y=w_0 v_1 w_1 \cdots v_k w_k$,
form the decomposition $ux=uu_0w_0 u_1 w_1 \cdots u_k w_k$ and $vy=vv_0 w_0 v_1 w_1 \cdots v_k w_k$ where $u_0=v_0=\eps$,
and follow the compression and split procedures.
We want to argue that during each split operation, all splits occur either in $w_j$'s and are the same on $ux$ and $vy$, or they occur in $u$ or $v$ where we do not care for them.
Again we define a split to be {\em undesirable} if it starts a new block at a position $j$ that belongs to one of the
$u_0,u_1,\dots,u_{k}$, $v_0,v_1,\dots,v_{k}$ or it is the position of the first or last symbol of $w_0,w_1,\dots$ or $w_{k}$.
Inductively we maintain that whenever a block $B^{ux}(\ell,i)$ contains a descendant of the compression of $u_j$,
its corresponding block $B^{vy}(\ell,i')$ contains a descendant of the compression of $v_j$.
(Here, the correspondence is counting from the highest index $i$ to the lowest and similarly for $i'$,
so $B^{ux}(\ell,i)$ corresponds to $B^{vy}(\ell,i')$ if $i-i'=s^{ux}_\ell- s^{vy}_\ell$.)
If the blocks contain a descendant of $u_0$ and $v_0$, resp., then we apply Lemma~\ref{l-compress-rolling} to construct a descendant decomposition after their compression.
For all other blocks that contain some $w_j, u_j$ or $v_j$ we use Lemma~\ref{l-compress} to construct its descendant decomposition.
We do not care for decomposition of blocks $B^{ux}(\ell,i)$ that are descendants of $u$ but do not contain $u_0$,
and similarly we do not care for decomposition of blocks $B^{vy}(\ell,i)$ that are descendants of $v$ but do not contain $v_0$.
(They might be decomposed arbitrarily so the number of blocks that are descendants of $u$ might differ from the number of blocks that
are descendants of $v$.)
Inductively, there are at most $2(4R+28)(k+1)$ positions where an undesirable split can happen in blocks $B^{ux}(\ell,i)$ and $B^{vy}(\ell,i)$
for given level $\ell$.
In total there are at most $2(4R+28)(k+1)(L+1)$ positions where an undesirable split can happen.
Thus, the probability of making an undesirable split during a run of the algorithm is bounded
by $2(4R+28)(k+1)(L+1)/D \le 22 R k (L+1) / D \le 1/5$.
If no undesirable split ever happens then the symbols that are weak compression of symbols from $x$ and $y$ are contained withing the corresponding blocks $B^{ux}(\ell,i)$ and $B^{yv}(\ell,i')$. For the blocks $B^{ux}(\ell,i)$ and $B^{vy}(\ell,i')$ that contain descendants of $u_0$ and $v_0$
it is fine if their prefixes that descend from $u$ and $v$, resp., which are to the left of the descendants of $u_0$ and $v_0$, are split differently
in $B^{ux}(\ell,i)$ and $B^{vy}(\ell,i')$. This does not affect the correspondence between blocks $B^{ux}(\ell,i)$ and $B^{vy}(\ell,i')$ that
weakly come from $x$ and $y$.
This concludes the proof of Theorem~\ref{t-decomposition-rolling}.
\subsection{Encoding a grammar}\label{s-binencoding}
We will set a parameter $N \ge n^{3}$ to be a suitable integer: Let ${F_\mathrm{KR}} : \{0,1\}^* \rightarrow \{1,\dots,N\}$ be
a hash function picked at random, such as Karp-Rabin fingerprint \cite{rabin_karp},
so for any two strings $u,v \in \{0,1\}^*$, if $u\neq v$ then $\Pr_{{F_\mathrm{KR}}}[{F_\mathrm{KR}}(u)={F_\mathrm{KR}}(v)] \le (|u|+|v|)/N$.
Set $M= 3 S \cdot \lceil 1 + \log |\Gamma| \rceil$.
We will encode a grammar $G$ over $\Gamma$ of length at most $S$ given by our decomposition algorithm by a string ${\mathrm{Enc}}(G)$ over alphabet $\{1,\dots,2N\}$ of length $M$.
The encoding is obtained as follows:
First, order the rules of the grammar $G$ lexicographically.
Then encode the rules in binary one by one using $3 \cdot \lceil 1 + \log |\Gamma| \rceil$ bits for each rule. (The extra bit allows to mark unused symbols.)
This gives a binary string of length at most $M$, which we pad by zeros to the length precisely $M$.
We call the resulting binary string ${\mathrm{Bin}}(G)$.
Compute $h_G = {F_\mathrm{KR}}({\mathrm{Bin}}(G))$.
We replace each 0 in ${\mathrm{Bin}}(G)$ by $h_G$, and each 1 in ${\mathrm{Bin}}(G)$ by $N+h_G$ to obtain the string ${\mathrm{Enc}}(G)$.
Clearly, ${\mathrm{Enc}}(G)$ is a string over alphabet $\{1,\dots,2N\}$ of length exactly $M$.
The encoding can be computed in time $O(M)$.
For completeness, we encode any grammar $G$ of length more than $S$ or that uses rules with more than two symbols on the right as ${\mathrm{Enc}}(G)=1^M$.
By the property of ${F_\mathrm{KR}}$ the following holds.
\begin{lemma}\label{l-binenc}
Let $G,G'$ be two grammars of size at most $S$ output by our decomposition algorithm. Let ${F_\mathrm{KR}}$ be chosen at random.
\begin{enumerate}
\item ${\mathrm{Enc}}(G) \in \{1,\dots, 2N\}^M$.
\item If $G=G'$ then ${\mathrm{Enc}}(G)={\mathrm{Enc}}(G')$.
\item If $G\neq G'$ then ${\mathrm{Enc}}(G)={\mathrm{Enc}}(G')$ with probability at most $2M/N$.
\item If ${\mathrm{Enc}}(G)\neq {\mathrm{Enc}}(G')$ then $\Ham({\mathrm{Enc}}(G), {\mathrm{Enc}}(G'))=M$, that is they differ in every symbol.
\end{enumerate}
\end{lemma}
\subsection{Edit distance sketch}\label{s-edsketch}
Let $n$ and $k\le n$ be two parameters, and $p\ge 2N+1$ be a prime such that $p\ge (nM)^3$.
For a string $x \in \Sigma^*$ of length at most $n$, we compute its sketch by running first the decomposition algorithm of Theorem~\ref{t-decomposition}
to get grammars $G_1,G_2,\dots, G_s$. Encode each grammar $G_i$ by encoding ${\mathrm{Enc}}(G_i)$ from Section~\ref{s-binencoding} using the same ${F_\mathrm{KR}}$ picked at random.
Concatenate the encoding to get a string $w = {\mathrm{Enc}}(G_1)\cdot {\mathrm{Enc}}(G_2) \cdots {\mathrm{Enc}}(G_s)$.
Calculate the Hamming sketch $\mathrm{sk}^{\mathrm{Ham}}_{n',m',p}(w)$ on $w$ for strings of length $n'=nM$ and Hamming distance at most $k'=kM$ from Section~\ref{s-hammin}.
Set the sketch $\mathrm{sk}^{\mathrm{ED}}_{n,k}(x) = \mathrm{sk}^{\mathrm{Ham}}_{n',k',p}(w)$.
The calculation of $\mathrm{sk}^{\mathrm{ED}}_{n,k}(x)$ can be done in time ${\widetilde{O}}(nk)$ as the number of grammars is at most $n$ and each grammar requires ${\widetilde{O}}(k)$ time to be encoded into binary. The Hamming sketch can be constructed in time ${\widetilde{O}}(nk)$.
(We believe that on average we expect only ${\widetilde{O}}(n/k)$ grammars to be produced for a given string $x$ so the actual running time should be ${\widetilde{O}}(n)$ on average.)
\begin{theorem}
Let $x,y \in \Sigma^*$ be strings of length at most $n$ such that $\ED(x,y) \le k$.
Let $\mathrm{sk}^{\mathrm{ED}}_{n,k}(x)$ and $\mathrm{sk}^{\mathrm{ED}}_{n,k}(y)$ be obtained using the same randomness for the decomposition algorithm and the same choice of ${F_\mathrm{KR}}$.
With probability at least $2/3$, we can calculate $\ED(x,y)$ from $\mathrm{sk}^{\mathrm{ED}}_{n,k}(x)$ and $\mathrm{sk}^{\mathrm{ED}}_{n,k}(y)$.
\end{theorem}
Assume that the output of the decomposition algorithm on $x$ and $y$ satisfies all the conclusions of Theorem~\ref{t-decomposition-rolling}.
In particular, for $x$ we get ${\mathrm{eval}}(G^x_1)\cdot {\mathrm{eval}}(G^x_2) \cdots {\mathrm{eval}}(G^x_s)$
and for $y$ we get ${\mathrm{eval}}(G^y_1) \cdots {\mathrm{eval}}(G^y_s)$, for some $s\le n$,
each of the grammars is of size at most $S$, $\ED(x,y)=\sum_i \ED({\mathrm{eval}}(G^x_i),{\mathrm{eval}}(G^y_i))$,
and the number of pairs $G^x_i$ and $G^y_i$ where $G^x_i\neq G^y_i$ is at most $k$.
Assume that ${F_\mathrm{KR}}$ is chosen so that ${\mathrm{Enc}}(G^x_i) \neq {\mathrm{Enc}}(G^y_i)$ for each of the pairs where $G^x_i$ and $G^y_i$ differ.
In order to determine $\ED(x,y)$, we recover the (Hamming) mismatch information between ${\mathrm{Enc}}(G^x_1)\cdot {\mathrm{Enc}}(G^x_2) \cdots {\mathrm{Enc}}(G^x_s)$
and ${\mathrm{Enc}}(G^y_1)\cdot {\mathrm{Enc}}(G^y_2) \cdots {\mathrm{Enc}}(G^y_s)$ from $\mathrm{sk}^{\mathrm{ED}}_{n,k}(x)$ and $\mathrm{sk}^{\mathrm{ED}}_{n,k}(y)$.
That gives grammars $G^x_i$ and $G^y_i$, for all $i$ where $G^x_i\neq G^y_i$.
(Whenever the two grammars differ, their encoding differ in every symbol by Lemma~\ref{l-binenc} so we can recover them from the Hamming mismatch information.)
Calculating the edit distance of each of the pair of differing grammars using the algorithm from Proposition~\ref{p-edgrammar} we recover $\ED(x,y)$ as the sum of their edit distances.
The sum is correct unless some of the assumptions fail:
The probability that the grammar decomposition fails (does not have properties from Theorem~\ref{t-decomposition}) for the pair $x$ and $y$ is at most $1/5$ for $n$ large enough.
The probability that the choice of ${F_\mathrm{KR}}$ fails (two distinct grammars have the same encoding) is at most $2kM/N < 1/n$ by the choice of $N$.
The probability that the Hamming distance sketch fails to recover the mismatch information between all the grammars is at most $1/n$.
So in total, the probability that the output of the algorithm is incorrect is at most $1/3$.
The running time of the comparison algorithm is ${\widetilde{O}}(k^2)$: The Hamming mismatch information can be recovered in time ${\widetilde{O}}(kM)={\widetilde{O}}(k^2)$ (Proposition~\ref{p-skham}), then we build the $\le k$ mismatched grammars in time ${\widetilde{O}}(k^2)$, and run the edit distance computation
on the pairs of grammars in time $\sum_{i<k} {\widetilde{O}}(k+k_i^2) \le {\widetilde{O}}(k^2)$, where $k_i$ is the edit distance of the $i$-th pair of mismatched grammars.
(We interrupt the edit distance computation if it takes more time than ${\widetilde{O}}(k^2)$ which would indicate $\ED(x,y)>k$.)
To decide whether $\ED(x,y) > k$ we note that on input $x$ and $y$, the Hamming sketch either outputs the correct mismatched places if their number
is $\le k'$ or it outputs $\infty$ if there are more mismatches than that or the sequences sketched by the Hamming sketch are of different length.
(We assume that the Hamming sketch knows the number of symbols it is sketching.)
In the $\infty$-case we know that there are more than $k$ different pairs of grammars or the decomposition of $x$ and $y$ failed, and we can report $\ED(x,y) > k$. In the other case we try to calculate the edit distance of the differing pairs of grammars.
If we spend more than ${\widetilde{O}}(k^2)$ time on it or we get a number larger than $k$ then we report $\ED(x,y)>k$.
This correctly decides whether $\ED(x,y)>k$ with probability at least $2/3$.
To prove Theorem~\ref{t-main2} we build a more robust sketch by taking $c\log n$ independent copies of the sketch $\mathrm{sk}^{\mathrm{ED}}_{n,k}$.
To calculate the edit distance of two sketched strings we run the edit distance calculation on each of the corresponding pairs of copies,
and output the majority answer. A usual application of Chernoff bound shows that the probability of correct answer is at least $1-1/n$ for suitable
constant $c>0$.
\section{Rolling sketch for edit distance}\label{s-rolling}
In this section we will construct the rolling sketch of Theorem~\ref{t-main3}. We will use two claims that will be proved in Section~\ref{s-rollingproofs}. The first one addresses how much a compression of a string $w$ might change depending on what is appended to it.
\begin{lemma}\label{l-extension}
Let $\ell\in \{0,\dots,L\}$ and $v,u,w\in \Gamma^*$. Let $w'u'={\mathrm{Compress}}(wu,\ell)$ and let $w''v'={\mathrm{Compress}}(wv,\ell)$, where $w'$ is the compression
of $w$ when compressing $wu$ and $w''$ is the compression of $w$ when compressing $wv$. Let $t=|w'|-3(R+1)$ or $t=|w'u'|-|u|-3(R+1)$. Then $w'[1,t]=w''[1,t]$.
\end{lemma}
The next lemma addresses how much the overall decomposition of a string $x$ might change if we append a suffix $z$ to it.
\begin{lemma}\label{l-grammarsuffix}
Let $x,z\in \Sigma^*$, $|xz|\le n$. Let $H_0,\dots, H_L, C_1,\dots, C_L$ be given.
Let $G^x_1,G^x_2,\dots,G^x_s$ be the output of the decomposition algorithm on input $x$, and
$G^{xz}_1,G^{xz}_2,\dots,G^{xz}_{s'}$ be the output of the decomposition algorithm on input $xz$ using the given hash functions.
Let $T=L(3R+6)$.
\begin{enumerate}
\item $G^x_i=G^{xz}_i$ for all $i=1\dots,s-T$.
\item $|x| \le \sum_{i=1}^{\min(s+T,s')} |{\mathrm{eval}}(G^{xz}_i)| $.
\end{enumerate}
\end{lemma}
The second part says that if $x$ is decomposed into $s$ grammars by itself, then it can be recovered from the first $s+T$ grammars for $xz$.
Hence, appending extra symbols to $x$ cannot increase the number of grammars that cover $x$ by more than $T$.
Let $m\ge k$ and $n\ge 10m^3$ be integers. A rolling sketch for a string obtained by up-to $m$ insertions (to the right end) and $m$ deletions (from the left end)
from an empty word consists of three data structures: {\em insertion buffer}, {\em deletion buffer} and a Hamming distance sketch $\mathrm{sk}^{\mathrm{Ham}}_{n',k',p}$, where $k'=(4T+1)(k+2)M$, $n'=nM$ and $p\ge n'^3$ is a chosen prime.
The insertion buffer maintains a buffer of {\em committed grammars} $G_{s-4T+1},G_{s-4T+2},\dots, G_{s}$ and a buffer of {\em active grammars} $G^i_1,\dots,G^i_t$,
$t \le T$. The deletion buffer is similar, it maintains a buffer of {\em committed grammars} $G_{r-4T+1},G_{r-4T+2},\dots, G_{r}$ and a buffer of {\em active grammars} $G^d_1,\dots,G^d_{t'}$, $t' \le T$. The Hamming sketch is a sketch of grammars $G_{r-2T+1},G_{r-2T+2},\dots, G_{s-2T}$, each encoded
as a string of length $M$ over the alphabet $\{1,\dots,2N\}$.
In addition to that, the sketch keeps track of the current
value of $r$ and $s$, and remembers a collection of pair-wise independent hash functions $C_1,\dots, C_L$, a collection of $(5D \log n)$-wise independent hash functions $H_0,\dots, H_L$, and randomness for Karp-Rabin fingerprint to compute binary encoding of grammars.
The hash functions and the randomness of Karp-Rabin fingerprint are chosen at random when creating the sketch for empty string.
This extra information requires ${\widetilde{O}}(k)$ bits to specify.
Initially, the committed grammars in the insertion and deletion buffers are all treated as empty sets, there are no active grammars in the insertion or deletion buffers so $t=t'=0$ and $s=r=0$.
For $u,x \in \Sigma^*$, if in total a string $ux$ was inserted into the sketch
then $G_{1},\dots, G_{s}, G^i_1,\dots,G^i_t$ represents $ux$,
that is $ux$ is the concatenation of the evaluation of the grammars.
If in total the string $u$ was deleted from the sketch, then $G_{1},\dots, G_{r}, G^d_1,\dots,G^d_{t^d}$ represents $u$. (See Fig.~\ref{fig:rolling_sketch} for an illustration.)
\begin{figure}[htp]
\centering
\includegraphics[width=\textwidth]{ed_sketch_img3.pdf}
\caption{Rolling sketch.}
\label{fig:rolling_sketch}
\end{figure}
\smallskip\noindent{\em Appending a symbol.}
When we append additional symbol $a$ to the sketch we modify input buffers as follows:
We update the active grammars $G^i_1,\dots,G^i_t$ by appending $a$ as explained further below. Say the update produces grammars $G'^i_1,\dots,G'^i_{t'}$.
If $t'\le T$ then the produced grammars will become the active grammars, and no more changes are done to the sketch.
Otherwise we commit the first $t'-T$ grammars $G'^i_1,\dots,G'^i_{t'-T}$ one-by-one into the committed buffer as grammars $G_{s+1},\cdots,G_{s+t'-T}$ and we keep the remaining grammars as the active grammars.
Committing a grammar $G_{s+1}$ into the committed buffer
will trigger addition of $G_{s-2T+1}$ into the Hamming sketch at the end of the represented sequence of grammars
(if $s-2T+1>0$), and removing the grammar $G_{s-4T+1}$
from the committed buffer. For insertion into the Hamming sketch, the grammar $G_{s-2T+1}$ is encoded into binary as in Section~\ref{s-binencoding}
and then the binary string is encoded using the Karp-Rabin fingerprint ${F_\mathrm{KR}}$ of {\em all} the grammars $G_{s-4T+1},\dots, G_{s+1}$, instead of only the grammar $G_{s-2T+1}$. (Thus, a change in any of the neighboring grammars will trigger a recovery of also the grammar $G_{s-2T+1}$ when calculating a mismatch information
from the Hamming sketch.) We repeat this process for each grammar being committed.
By the second part of Lemma~\ref{l-grammarsuffix} $t'\le t+T \le 2T$ so we will commit at most $T={\widetilde{O}}(1)$ grammars.
It takes time $O(MT)={\widetilde{O}}(k)$ to prepare the binary encoding of each of the committed grammars, and ${\widetilde{O}}(k^2)$ to insert it into the Hamming sketch.
The update of the active grammars takes ${\widetilde{O}}(k)$ time as described below. So in total this step takes ${\widetilde{O}}(k^2)$ time.
\smallskip\noindent{\em Removing a symbol.}
Deletion buffer works in manner similar to insertion buffer, we add the removed symbol $a$ to the active grammars, but when committing the grammar $G_{r+1}$, we use ${F_\mathrm{KR}}$-fingerprint of all the grammars $G_{r-4T+1},\dots, G_{r+1}$
to encode grammar $G_{r-2T+1}$ which is then {\em removed} from the beginning of the sequence of grammars represented by the Hamming sketch (if $r-2T+1>0$),
i.e., we update the Hamming sketch to reflect this removal. Similarly to appending a symbol, this step takes time ${\widetilde{O}}(k^2)$.
\smallskip\noindent{\em Active grammar update.}
The update of active grammars $G^i_1,\dots,G^i_t$ when appending $a$ is done as follows. $G_{1},\dots, G_{s}, G^i_1,\dots,G^i_t$ represents $ux$
so we need to calculate the grammars for $uxa$. We claim that only the active grammars might change: At some point, $G_{s}$ became committed so at that time there was $T$ active grammars following it. If at that point the grammars together represented a string $z$, by appending more symbols to $z$ we cannot change grammars
$G_{1},G_{1},\dots, G_{s}$ according to the first part of Lemma~\ref{l-grammarsuffix}. So appending $a$ to $ux$ will affect only the active grammars.
From the analysis in the proof of Lemma~\ref{l-grammarsuffix} it follows that for $\ell \in \{0,\dots,1\}$
if $B^{ux}(\ell,1),\dots,B^{ux}(\ell,s^{xy}_\ell)$ is the trace of the decomposition algorithm on $ux$ at level $\ell$,
and $B^{uxa}(\ell,1),\dots,B^{uxa}(\ell,s^{xya}_\ell)$ is the trace on $uxa$, then their difference spans at most $\ell (3R+6)$ last symbols
of $B^{ux}(\ell,1) \cdots B^{ux}(\ell,s^{xy}_\ell)$.
So instead of decompressing the active grammars completely, adding $a$ and recompressing them back,
we only decompress the necessary part of each trace $B^{ux}(\ell,1) \cdots B^{ux}(\ell,s^{xy}_\ell)$.
Let $\# \rightarrow v_i$ be the starting rule of the active grammar $G_i$.
Starting from the string $v_1 \cdot v_2 \cdots v_t$, for each $\ell=L,\dots,1$,
we iteratively rewrite all level-$\ell$ symbols in the string using the appropriate grammars
while only maintaining at most $T$ last symbols of the resulting string.
(Care has to be taken to maintain information about any sequence $a^r$ stretching from those $T$ last symbols to the left.)
We add $a$ to the resulting string and re-apply compress and split procedures for levels $0,1,\dots, \ell-1$ to
recompress only the part of the trace affected by modifications.
As we perform the compression of symbols we maintain a set $G$ of all grammar rules needed for decompression.
(We initialize $G$ with the union of all rules from the active grammars $G^i_1,\dots,G^i_t$ minus the starting rules,
and we iteratively add new rules coming from the recompression.)
For the recompression we need to know the context of up-to $R+1$ symbols preceding the modified part of the trace.
On the other hand, the modification can affect the recompression of up-to $R+1$ symbols to the left from the left-most modified symbol in the trace.
Those $R+1$ symbols all happen to be within the decompressed suffix of the trace of size at most $T$.
Eventually, we get a new level-$L$ trace $B^{uxa}(L,s^{xya}_L-t'+1),\dots,B^{uxa}(L,s^{xya}_L)$, for some $t'$.
Each new grammar $G'^i_j$ is obtained by taking the grammar $G \cup \{ \# \rightarrow B^{uxa}(L,s^{xya}_L-t'+j) \}$ and removing from it all useless rules. This can be done in time $O(|G|)$. (See Section~\ref{s-grammars}).
Overall the update of active grammars on insertion of a single symbol will require $O(LT)={\widetilde{O}}(1)$ evaluations of split hash functions $H_0,\dots,H_L$,
$O(LT)={\widetilde{O}}(1)$ evaluations of compress hash functions $C_1,\dots,C_L$, and $O(T (LT + \sum_{j=1}^t |G^i_{j}|))$ time to produce the new grammars.
As the total size of the grammars is ${\widetilde{O}}(k)$ and the time to evaluate $H_\ell$ at a single point is also ${\widetilde{O}}(k)$, the overall time for the update of active grammars is ${\widetilde{O}}(k)$. We provide a more detailed description of the update procedure in Section~\ref{s-update}.
\smallskip\noindent{\em Edit distance evaluation.}
Consider strings $x$ and $y$ of length at most $m$ and edit distance at most $k$. Consider the rolling sketch $\mathrm{sk}^{\mathrm{Rolling}}_{m,k}(x)$ for $x$ obtained by
inserting symbols $ux$ and removing symbols $u$, for some $u\in \Sigma^*$ where $|ux|\le m$.
Consider also the rolling sketch for $y$ obtained by
inserting symbols $vy$ and removing symbols $v$, for some $v\in \Sigma^*$ where $|vy|\le m$.
Both sketches should use the same randomness that is to start from the same sketch for empty string.
The rolling sketch for $x$ consists of the insertion buffer with committed grammars $G^x_{s^x-4T+1},$ $G^x_{s^x-4T+2},$ $\dots,$ $G^x_{s^x}$ and with active grammars $G^{ix}_1,\dots,G^{ix}_{t^x}$, and the deletion buffer with committed grammars $G^x_{r^x-4T+1},$ $G^x_{r^x-4T+2},$ $\dots,$ $G^x_{r^x}$ and active grammars $G^{dx}_1,\dots,G^{dx}_{t'^x}$, $t'^x \le T$. Its Hamming sketch sketches the sequence of grammars $G^x_{r^x-2T+1},G^x_{r^x-2T+2},\dots, G^x_{s^x-2T}$. Similarly for $y$, we have the committed insertion grammars $G^y_{s^y-4T+1},G^y_{s^y-4T+2},\dots, G^y_{s^y}$, etc.
We extend the notation so for $j\in \{1,\dots,t^x\}$, we let $G^x_{s^x+j}$ denote the active grammar $G^{ix}_j$, and similarly for $y$.
Let $d^x = s^x + t^x - r^x$ and $d^y = s^y + t^y - r^y$.
We assume that the hash functions used to decompose $ux$ and $vy$ into grammars satisfy the probabilistic conclusion of Theorem~\ref{t-decomposition-rolling}. That means that grammars $G^x_{r},\dots$ and $G^y_{r},\dots$ can be aligned from the right
so $G^x_j$ corresponds to $G^y_{j-d^x + d^y}$, for $j\ge r^x$ (they might not be identical because of the edit operations).
Without loss of generality we assume that $d^x \ge d^y$.
Before proceeding with the algorithm we first observe that $d^x-d^y < 2T$.
Let $p^x\ge r^x+1$ be the index of the grammar $G^x_{p^x}$ which produces the first symbol of $x$ when we evaluate all the grammars.
Similarly, $p^y\ge r^y+1$ is the index of $G^y_{p^y}$ which produces the first symbol of $y$. By Lemma~\ref{l-grammarsuffix}
applied on $x\leftarrow u$ and $z \leftarrow x$ we get that $p^x \le r^x + t'^x + T \le r^x + 2T$, and similarly $p^y \le r^y + 2T$.
By our assumption on success of Theorem~\ref{t-decomposition-rolling}, $s^x + t^x - p^x = s^y - t^y - p^y$.
Hence, $s^x + t^x - s^y - t^y = p^x - p^y \le r^x + 2T - r^y - 1 \le r^x - r^y + (2T-1)$.
Thus $d^x - d^y = s^x + t^x -r^x - s^y - t^y + r^y \le r^x - r^y + (2T-1) - r^x + r^y \le 2T-1$.
If $d^x < 10T$ then we can recover all the grammars $G^x_{r^x-2T+1},G^x_{r^x-2T+2},\dots, G^x_{s^x-2T}$ from their Hamming sketch by constructing an auxiliary {\em dummy} Hamming sketch $sk'$ for a sequence of $1$'s of length $(s^x-r^x)M$
and comparing the two sketches. ($M$ is the length of the encoding of each grammar.)
Their mismatch information reveals all the grammars $G^x_{r^x-2T+1},\dots, G^x_{s^x-2T}$
Since $d^y \le d^x$, we can similarly recover all the grammars $G^y_{r^y-2T+1},\dots, G^y_{s^y-2T}$ from their Hamming sketch.
Thus we know all grammars $G^x_{r^x+1},G^x_{r^x+2},\dots, G^x_{s^x+t^x}$ and $G^x_{r^y+1},G^y_{r^y+2},\dots, G^y_{s^y+t^y}$.
We also know grammars $G^{dx}_1,\dots,G^{dx}_{t'^x}$ and $G^{dy}_1,\dots,G^{dy}_{t'^y}$ that need to be {\em subtracted}
from our grammars. As noted in Section~\ref{s-grammars}, for each of the grammars we can calculate its evaluation size.
From that information we can easily identify $p^x$ and $p^y$, and shorten the grammars $G^x_{p^x}$ and $G^y_{p^y}$ to produce
only symbols of $x$ and $y$, respectively.
We can combine all the grammars of $x$ into one grammar $G^x$, and all the grammars of $y$ into $G^y$,
and run the algorithm of Ganesh, Kociumaka, Lincoln and Saha~\cite{ED_compressed_string_Soda22} to calculate the edit distance of $x$ and $y$.
Since $T={\widetilde{O}}(1)$, that will take time ${\widetilde{O}}(|G^x|+|G^y| + k^2) = {\widetilde{O}}(k^2)$.
If $d^x \ge 10T$ then we proceed as follows. Clearly, $d^y \ge 8T$, so $s^y - r^y \ge 7T$ and $s^x - r^x \ge 9T$.
Thus $G^x_{r^x-2T+1},G^x_{r^x-2T+2},\dots, G^x_{s^x-2T}$ and $G^y_{r^y-2T+1},G^y_{r^y-2T+2},\dots, G^y_{s^y-2T}$
consist of at least $7T$ grammars each, and those grammars are sketched by their Hamming sketches.
Although we assume that there is a correspondence between the grammar $G^x_j$, for $j\ge r^x$, and $G^y_{j-d^x+d^y}$
the sequences $G^x_{r^x-2T+1},\dots, G^x_{s^x-2T}$ and $G^y_{r^y-2T+1},\dots, G^y_{s^y-2T}$ are misaligned in their Hamming sketches by $d^x-d^y$ grammars.
To rectify this misalignment, we prepend $(d^x-d^y)M$ copies of symbol $1$ into the sketch for $G^y_{r^y-2T+1},\dots, G^y_{s^y-2T}$.
Furthermore, if $t^x < t^y$ then we append $(t^y - t^x)M$ ones into the sketch for $G^y_{r^y-2T+1},\dots, G^y_{s^y-2T}$,
to rectify the difference in the number of sketched grammars.
Otherwise if $t^x > t^y$ then we append $(t^x - t^y)M$ ones into the sketch for $G^x_{r^x-2T+1},\dots, G^x_{s^x-2T}$.
Now we can calculate the mismatch information from the Hamming sketches to find out the pairs of grammars
$G^x_j$ and $G^y_{j-d^x+d^y}$, $j\ge r^x + 1$, that are different.
If for some $j\in \{r^x + 1,\dots, r^x+2T\}$, $G^x_j$ and $G^y_{j-d^x+d^y}$ differ then because we use the Karp-Rabin
fingerprint of the two grammars to encode also the neighboring grammars up-to distance $2T$, we recover from the sketch
all the grammars $G^x_j$ and $G^y_{j-d^x+d^y}$, for $j=r^x + 1,\dots, r^x+2T$.
By counting the evaluation size of each of those grammars and comparing it with the evaluation size of active grammars in deletion buffers of $x$ and $y$, resp.,
we identify $p^x$ and $p^y$, and how much the grammars $G^x_{p^x}$ and $G^y_{p^y}$ should be shortened to produce
only symbols of $x$ and $y$.
After shortening $G^x_{p^x}$ and $G^y_{p^y}$ we calculate the edit distance of their evaluation.
We sum it up with the edit distance of evaluation of each pair of grammars $G^x_j$ and $G^y_{j-d^x+d^y}$, for $j>p^x$,
that was identified as mismatch by the Hamming distance sketch or that belongs among the active grammars in insertion buffers of either $x$ or $y$.
There will be at most $T$ mismatched pairs involving the active grammars, and $(4T+1)k$ pairs identified by the Hamming sketch.
In the remaining case when $G^x_j$ and $G^y_{j-d^x+d^y}$ are identical for all $j\in \{r^x + 1,\dots, r^x+2T\}$,
we might not be able to recover all those grammars from the Hamming sketches,
and we might not be able to identify $p^x$ and $p^y$.
However, since $G^x_{p^x}=G^y_{p^y}$, we know that the part of $x$ produced by $G^x_{p^x}$ is either a prefix or
suffix of the part of $y$ produced by $G^y_{p^y}$.
The difference in the size of the two parts is the edit distance of the two parts.
The difference is given by the difference between the total evaluation size of active grammars in the deletion buffer of $x$,
and the total evaluation size of active grammars in the deletion buffer of $y$ together with grammars $G^y_{r_y-j}$,
for $j=0,\dots, d^x-d^y-1$.
The latter grammars are in the committed deletion buffer of $y$ and they agree with $G^x_{r^x+1},\dots, G^x_{r^x+d^x-d^y}$.
Hence, the edit distance of the parts of $x$ and $y$ coming from $G^x_{p^x}$ and $G^y_{p^y}$ can be determined.
All other mismatching pairs of grammars are identified by the Hamming sketch or are among active grammars of the insertion buffers.
So we proceed as in the previous case to calculate their contribution to the edit distance of $x$ and $y$.
The edit distance of $x$ and $y$ is the sum of those edit distances.
We see that in both the cases we need the Hamming sketch to be able to recover at least $T$ mismatched grammars at the very end caused by
the dummy padding, $4T$ grammars at the beginning corresponding to $G^x_{r^x-2T+1},G^x_{r^x-2T+2},\dots, G^x_{r^x+2T}$,
$2T$ neighbors of $G^x_{r^x+2T}$ to the right,
and at most $(4T+1)k$ mismatched grammars caused by the edit operations between $x$ and $y$.
This is less than $M(4T+1)(k+2)$ which is the number of mismatches our Hamming sketch can recover.
The time needed to compare the sketched strings can be bounded as follows:
In total the procedure generates at most $O(T k)$ pairs of grammars of total size ${\widetilde{O}}(k^2)$ on which it runs edit distance computation from Proposition~\ref{p-edgrammar}.
If those edit distance computations take total time more than ${\widetilde{O}}(k^2)$ we can terminate them as we know the overall edit distance is larger than $k$.
Recovering differing grammars from the Hamming distance sketch takes time ${\widetilde{O}}(k')={\widetilde{O}}(k^2)$.
Their follow-up processing such as counting their evaluation size and shortening them is proportional to their total size which is ${\widetilde{O}}(k^2)$.
Hence, the time for comparing strings is ${\widetilde{O}}(k^2)$.
\bigskip\noindent{\em Failure probability.}
The update operations can fail if the grammar decomposition produces large grammars or the grammars are not deterministic (because of a collision caused by compression hash functions).
This happens with probability at most $1/n$ for each update.
Since we perform at most $m$ updates, the failure probability of any update operations is at most $m/n \le 1/10m^2$ by our choice of $m$ and $n$.
When comparing two sketches for strings $x$ and $y$ of edit distance at most $k$,
Theorem~\ref{t-decomposition-rolling} might fail to align their grammar decomposition.
This happens with probability at most $1/5$.
With probability at most $2/n$ the Hamming sketches might fail to recover the differing pairs of grammars.
There is no other source of failure for strings of edit distance at most $k$ so the probability of the compare operation failing is at most $1/3$.
To boost the success probability of comparison from $2/3$ to $1-1/2m$,
we again form a more robust sketch by taking $c\log m$ independent copies of the rolling edit distance sketch
and operate on them simultaneously. For comparison we output the most frequent answer from the individual sketches.
This multiplies the failure probability of update operations by $c\log m$, so it is still at most $1/2m$ for $m$ large enough.
The comparison will fail with probability at most $1/2m$.
For strings of edit distance more than $k$ the comparison of an individual edit sketch will fail either
because the Hamming sketch would need to recover more than $k$ pairs of differing grammars or
because the total edit distance of the differing grammars is more than $k$.
In both these failure cases we can always output $\infty$ to be on the safe side.
\subsection{Proofs of Lemma~\ref{l-extension} and \ref{l-grammarsuffix}}\label{s-rollingproofs}
Here we prove the remaining two lemmas.
\bigskip
\begin{proofof}{Lemma~\ref{l-extension}}
For the simplicity of case analysis we first compare the compression of $wu$ and $w$. Consider the division of $w=B_1\dots B_m$
when calling ${\mathrm{Compress}}(w,\ell)$, and the division $wu=B'_1\dots B'_{m'}$ when calling ${\mathrm{Compress}}(wu,\ell)$. Let $w'''={\mathrm{Compress}}(w,\ell)$, from line.
Let $a$ be the last symbol of $w$. We consider three cases.
If $B_m=a^r$, $r\ge 1$, then $B_i=B'_i$ for all $i=1\dots,m-1$, and $B_m$ is a prefix of $B'_m$, not necessarily proper. In this case,
the compression of each $B_i$ and $B'_i$, $i=1,\dots, m-1$, is the same, so $w'''$ equals to $w'$ in all but possibly the last symbol.
Otherwise, $B_m$ consists of at least two singleton symbols. If the first symbol of $u$ is $a$, then $B'_m=B_m[1,|B_m|-1]$, and $B'_{m+1}=a^r$, for some $r\ge 2$. $F_{\mathrm{CVL}}$ will color the same all symbols of $B_m$ and $B'_m$ except for at most the last $R$ symbols. Hence, $B_m$ and $B'_m$ will be compressed the same except for at most the last $R$ symbols. The last $R$ symbols are compressed into at most $R$ symbols in $w'''$, and $B'_{m+1}$ will be compressed into a single symbol. In this case we conclude that $w'[1,|w'|-R-1]=w'''[1,|w'|-R-1]$.
If the first symbol of $u$ is not $a$ then $B_m$ is a prefix of $B'_m$, and the compression of $B_m$ and $B'_m[1,|B_m|]$ will differ in at most $R$ last symbols. So $w'[1,|w'|-R]=w'''[1,|w'|-R]$.
Hence, in all three cases $w'[1,|w'|-R-1]=w'''[1,|w'|-R-1]$. Moreover, $\left| |w'|-|w'''|\right| \le R+1 $.
A similar argument gives $w''[1,|w''|-R-1]=w'''[1,|w''|-R-1]$, and $\left| |w''|-|w'''|\right| \le R+1$. By the triangle inequality, $\left| |w'|-|w''|\right| \le 2(R+1)$. Hence, $w'[1,|w'|-3(R+1)]=w''[1,|w'|-3(R+1)]$. Since $|u'|\le |u|$, $|w'u'|-|u| \le |w'|$. The claim follows.
\end{proofof}
\bigskip
\begin{proofof}{Lemma~\ref{l-grammarsuffix}}
{\em Part 1.}
Consider strings $B^x(\ell,i)$ from the trace of the algorithm on $x$ given the hash functions $H_0,\dots, H_L, C_1,\dots, C_L$. (See Section~\ref{s-correctness}) Similarly for $B^{xz}(\ell,i)$.
For $\ell=0,\dots,L$ we will define integers $i_\ell$ and $\Delta_\ell$ satisfying:
\begin{enumerate}
\item For all $i<i_\ell$, $B^x(\ell,i)= B^{xz}(\ell,i)$,
\item $B^x(\ell,i_\ell)[1,|B^x(\ell,i_\ell)|-\Delta_\ell]= B^{xz}(\ell,i_\ell)[1,|B^x(\ell,i_\ell)|-\Delta_\ell]$,
\item $\Delta_\ell + \sum_{i=i_\ell+1}^{s^x_\ell} |B^x(\ell,i)| \le \ell (3R+3)+1$.
\end{enumerate}
For $\ell=0$, $B^x(0,1),B^x(0,2),\dots, B^x(0,s^x_0)={\mathrm{Split}}(x,0)$, so we set $i_0=s^x_0$ and $\Delta_0=1$.
Since $B^{xz}(0,1),B^{xz}(0,2),\dots, B^{xz}(0,s^{xz}_0)={\mathrm{Split}}(xz,0)$,
$s^x_0 \le s^{xz}_0$ and $B^x(0,s^x_0)$ might differ from $B^{xz}(0,s^x_0)$ by containing
the last symbol of $x$ which might be the first symbol of $B^{xz}(0,s^x_0+1)$. Otherwise, $B^x(0,s^x_0)$ is the prefix of $B^{xz}(0,s^x_0)$
so the properties of $i_0$ and $\Delta_0$ are satisfied.
For $\ell=1,\dots,L$, having defined $i_{\ell-1}$ and $\Delta_{\ell-1}$ we will define $i_{\ell}$ and $\Delta_{\ell}$:
Define
$$A^x_{\ell-1}={\mathrm{Compress}}(B^x(\ell-1,i_{\ell-1}),\ell) \;\;\;\;\&\;\;\;\; A^{xz}_{\ell-1}={\mathrm{Compress}}(B^{xz}(\ell-1,i_{\ell-1}),\ell),$$
$$(B_0,B_1,\dots, B_m)={\mathrm{Split}}(A^x_{\ell-1},\ell) \;\;\;\;\&\;\;\;\; (B'_0,B'_1,\dots, B'_{m'})={\mathrm{Split}}(A^{xz}_{\ell-1},\ell).$$
For simplicity of exposition in this proof we assume that for any $B\in \Gamma^*$ of size at most $2$, ${\mathrm{Compress}}(B,\ell)=B$ and ${\mathrm{Split}}(B,\ell)=(B)$, so they both perform no action on $B$ of size at most 2.
Let
\begin{align*}
w &= B^x(\ell-1,i_{\ell-1})[1,|B^x(\ell-1,i_{\ell-1})|-\Delta_{\ell-1}],\\
u &= B^x(\ell-1,i_{\ell-1})[1+|B^x(\ell-1,i_{\ell-1})|-\Delta_{\ell-1},\dots],\\
v &= B^{xz}(\ell-1,i_{\ell-1})[1+|B^x(\ell-1,i_{\ell-1})|-\Delta_{\ell-1},\dots].
\end{align*}
By Lemma~\ref{l-extension}, $A^x_{\ell-1}$ and $A^{xz}_{\ell-1}$ agree
on at least the first $|A^x_{\ell-1}| -(3R+3) - |u|=|A^x_{\ell-1}| -(3R+3) - \Delta_{\ell-1}$ symbols.
(This is trivial when $|w|\le 2$, in particular, when $|B^x(\ell-1,i_{\ell-1})|\le 2$ or $|B^{xz}(\ell-1,i_{\ell-1})|\le 2$.)
Let $i\in \{0,\dots,m\}$ be the largest $i$ such that for all $j < i$, $B_j=B'_j$. Let $i_\ell$ be the index of block $B_i$ among
blocks $B^x(\ell,1), B^x(\ell,2), \dots, B^x(\ell,s^x_\ell)$.
Notice, $B^x(\ell,j)= B^{xz}(\ell,j)$, for all $j<i_\ell$.
Let $\Delta_\ell \ge 0$ be the smallest integer such that $B_i[1,|B_i|-\Delta_\ell]=B'_i[1,|B_i|-\Delta_\ell]$.
(So the second property holds for $\ell$, as $B^x(\ell,i_\ell)=B_i$ and $B^{xz}(\ell,i_\ell)=B'_i$.)
Since $B_i[|B_i|-\Delta_\ell+1,\dots] \cdot B_{i+1} \dots B_m$ forms a part of a suffix of $A^x_{\ell-1}$ on which $A^x_{\ell-1}$ and $A^{xz}_{\ell-1}$ differ,
$\Delta_\ell + \sum_{j=i+1}^{m} |B_j| \le (3R+3)+ \Delta_{\ell-1}$.
Notice, $\sum_{j=i_\ell+1+s-i}^{s^x_\ell} |B^x(\ell,j)| \le \sum_{j=i_{{\ell-1}+1}}^{s^x_{\ell-1}} |B^x(\ell-1,j)|$ as each $B^x(\ell,j)$
on the left is a part of a compression of some $B^x(\ell-1,j)$ on the right.
Hence, $$\sum_{j=i_{\ell+1}}^{s^x_\ell} |B^x(\ell,j)| + \Delta_\ell \le
(3R+3) + \Delta_{\ell-1} + \sum_{j=i_{{\ell-1}+1}}^{s^x_{\ell-1}} |B^x(\ell-1,j)| \le (3R+3)+(\ell-1)(3R+3)+1 \le \ell(3R+3)+1
$$
Eventually, $\Delta_L + \sum_{i=i_L+1}^{s^x_L} |B^x(L,i)| \le L (3R+3)+1$.
Also $B^x(L,j)=B^{xz}(L,j)$ for $j=1,\dots,i_L-1$.
Hence, $G^x_j=G^{xz}_j$ for $j=1,\dots,i_L-1$.
Since each $|B^x(\ell,j)|\ge 1$, $s^x_L - i_L \le L(3R+3)+1$, which implies $s^x_L - (L(3R+3)+2) \le s^x_L - T \le i_L-1$ and the claim follows.
\medskip\noindent{\em Part 2.}
The proof of this part proceeds similarly to the first part. Let $B^{x}(\ell,i)$ and $B^{xz}(\ell,i)$ be as above. For $\ell=0,\dots,L$, we will define a sequence of integers $i_\ell, t_\ell, p_\ell, r_\ell$ satisfying:
\begin{enumerate}
\item $t_\ell$ is the last index $i$ such that $B^{xz}(\ell,i)$ contains some symbol that comes from the compression of $x$, and $r_\ell$ is the length of the prefix of $B^{xz}(\ell,t_\ell)$ that comes from the compression of $x$.
\item $i_\ell \le t_\ell$ and for all $i<i_\ell$, $B^x(\ell,i)= B^{xz}(\ell,i)$,
\item $B^x(\ell,i_\ell)[1,p_\ell]= B^{xz}(\ell,i_\ell)[1,p_\ell]$,
\item $r_\ell - p_\ell + \sum_{j=i_\ell}^{t_\ell-1} |B^{xz}(\ell,j)| \le \ell (3R+3)+1$.
\end{enumerate}
For $\ell=0$, $B^x(0,1),B^x(0,2),\dots, B^x(0,s^x_0)={\mathrm{Split}}(x,0)$ and $B^{xz}(0,1),B^{xz}(0,2),\dots, B^{xz}(0,s^{xz}_0)={\mathrm{Split}}(xz,0)$,
so we set $i_0=s^x_0$. If $|B^x(0,s^x_0)| \le |B^{xz}(0,s^x_0)|$ we set $t_0=i_0$, and $r_0=p_0=|B^x(0,i_0)|$, otherwise the last symbol of $x$ starts the block $B^{xz}(0,s^x_0+1)$ so we set $t_0=i_0+1$, $p_0= |B^{x}(0,s^x_0)|$ and $r_0=1$. (For completeness we set $i_{-1}=t_{-1}=1$.) Clearly, the four properties are satisfied by this choice.
For $\ell=1,\dots,L$, having defined $i_{\ell-1},t_{\ell-1},p_{\ell-1},r_{\ell-1}$ we will define $i_{\ell},t_{\ell},p_{\ell}$, and $r_{\ell}$.
As before, let $$A^x_{\ell-1}={\mathrm{Compress}}(B^x(\ell-1,i_{\ell-1}),\ell) \;\;\;\;\&\;\;\;\; A^{xz}_{\ell-1}={\mathrm{Compress}}(B^{xz}(\ell-1,i_{\ell-1}),\ell).$$
\medskip\noindent {\em Case 1.}
Consider the case when $i_{\ell-1}=t_{\ell-1}$. Let
\begin{align*}
w &= B^{xz}(\ell-1,i_{\ell-1})[1,p_{\ell-1}],\\
u_x &= B^{xz}(\ell-1,i_{\ell-1})[1+p_{\ell-1},r_\ell],\\
u_z &= B^{xz}(\ell-1,i_{\ell-1})[1+r_{\ell-1},\dots],\\
v &= B^{x}(\ell-1,i_{\ell-1})[1+p_{\ell-1},\dots].
\end{align*}
Let $A^{xz}_{\ell-1}=w'u'_x u'_z$ where $w'$ comes from the compression of $w$,
$u'_x$ comes from the compression of $u_x$, and $u'_z$ comes from the compression of $u_z$.
Let $A^{x}_{\ell-1}=w''v'$ where $w''$ comes from the compression of $w$, and $v'$ comes from the compression of $v$.
Set $r'_\ell=|w'u'_x|$, let $p'_\ell \le r'_\ell$ be the largest integer so that $A^{xz}_{\ell-1}[1,p'_\ell] = A^{x}_{\ell-1}[1,p'_\ell]$.
By Lemma~\ref{l-extension}, $p'_\ell \ge |w'|-3(R+1)$ so $r'_\ell - p'_\ell \le |w'u'_x| - |w'| + 3(R+1) \le |u'_x| + 3(R+1)$.
Furthermore, $|u'_x| \le |u_x| \le r_{\ell-1} - p_{\ell-1} \le (\ell-1) \cdot (3R+3)+1$, which follows by properties of $p_{\ell-1}$ and $r_{\ell-1}$, so $r'_\ell - p'_\ell \le \ell (3R+3)+1$.
Let $(B_0,B_1,\dots,B_{m})={\mathrm{Split}}(A^{xz}_{\ell-1},\ell).$
Let $i\ge 0$ be the smallest integer such that $p'_\ell \le \sum_{j=0}^i|B_j|$ and
let $t\ge 0$ be the smallest such that $r'_\ell \le \sum_{j=0}^t|B_j|$.
Set $p_\ell = p'_\ell - \sum_{j=0}^{i-1}|B_j|$ and $r_\ell = r'_\ell - \sum_{j=0}^{t-1}|B_j|$.
Let $i_\ell$ be the index of block $B_i$ among blocks $B^{xz}(\ell,1), B^{xz}(\ell,2), \dots, B^{xz}(\ell,s^{xz}_\ell)$, and
let $t_\ell$ be the index of $B_t$ among those blocks.
Notice, $B^x(\ell,j)= B^{xz}(\ell,j)$, for all $j<i_\ell$.
We conclude the case by observing that
$r_{\ell} - p_{\ell} + \sum_{j=i}^{t-1}|B_j| = \sum_{j=i}^{t-1}|B_j| + (r'_\ell - \sum_{j=0}^{t-1}|B_j|) - (p'_\ell - \sum_{j=0}^{i-1}|B_j|)
= p'_\ell - r'_\ell \le \ell (3R+3)+1$.
\medskip\noindent {\em Case 2.}
The case $i_{\ell-1}<t_{\ell-1}$ is similar.
In this case we let $w$ and $v$ to be as in the previous case and $u=B^{xz}(\ell-1,i_{\ell-1})[1+p_{\ell-1},\dots]$.
We let $p'_\ell \le |A^{xy}_{\ell-1}|$ be the largest integer so that $A^{xz}_{\ell-1}[1,p'_\ell] = A^{x}_{\ell-1}[1,p'_\ell]$.
By Lemma~\ref{l-extension}, $p'_\ell \ge |A^{xy}_{\ell-1}|-3(R+1)-|u| = |A^{xy}_{\ell-1}|-3(R+1)- |B^{xz}(\ell-1,i_{\ell-1})|+p_{\ell-1}$.
Rearranging terms: $-p'_\ell+|A^{xy}_{\ell-1}| \le - p_{\ell-1} + |B^{xz}(\ell-1,i_{\ell-1})| + 3(R+1)$.
Let $i\ge 0$ be the smallest integer such that $p'_\ell \le \sum_{j=0}^i|B_j|$.
Let $p_\ell = p'_\ell - \sum_{j=0}^{i-1}|B_j|$,
and $i_\ell$ be the index of the block $B_i$ within $B^{xz}(\ell,1), B^{xz}(\ell,2), \dots, B^{xz}(\ell,s^{xz}_\ell)$.
Hence, $-p_\ell + \sum_{j=i_\ell}^{i_\ell+m-i} |B^{xz}(\ell,j)| = -p_\ell + \sum_{j=i}^{m} |B_j| = -p'_\ell+ \sum_{j=0}^{m} |B_j| = -p'_\ell+|A^{xy}_{\ell-1}| \le - p_{\ell-1} + |B^{xz}(\ell-1,i_{\ell-1})| + 3(R+1)$.
Let $C^{xz}_{\ell-1}={\mathrm{Compress}}(B^{xz}(\ell-1,t_{\ell-1}),\ell)$ and $(B'_0,B'_1,\dots,B'_{m'})={\mathrm{Split}}(C^{xz}_{\ell-1},\ell)$.
Let $r'_\ell$ be the largest position in $C^{xz}_{\ell-1}$ of a symbol coming from compression of $x$,
and $t\ge 0$ be the smallest integer such that $r'_\ell \le \sum_{j=0}^t|B_j|$, and set $r_\ell = r'_\ell - \sum_{j=0}^{t-1}|B'_j|$.
Let $t_\ell$ be the index of the block $B'_t$ within $B^{xz}(\ell,1), B^{xz}(\ell,2), \dots, B^{xz}(\ell,s^{xz}_\ell)$.
Clearly, $r'_\ell \le r_{\ell-1}$ so
$r_\ell + \sum_{j=t_\ell-t}^{t_\ell-1} |B^{xz}(\ell,j)| = r_\ell + \sum_{j=0}^{t-1}|B'_j| \le r'_\ell \le r_{\ell-1}$.
Notice, $\sum_{j=i_\ell+m-i+1}^{t_\ell-t-1} |B^{xz}(\ell,j)| \le \sum_{j=i_{\ell-1}+1}^{t_{\ell-1}-1} |B^{xz}(\ell-1,j)|$.
By partitioning the sum, rearranging the terms and using the upper bounds derived so far we have:
$r_\ell - p_\ell + \sum_{j=i_\ell}^{t_\ell-1} |B^{xz}(\ell,j)|
= -p_\ell + \sum_{j=i_\ell}^{i_\ell+m-i} |B^{xz}(\ell,j)| + \sum_{j=i_\ell+m-i+1}^{t_\ell-t-1} |B^{xz}(\ell,j)| + \sum_{j=t_\ell-t}^{t_\ell-1} |B^{xz}(\ell,j)| + r_\ell
\le - p_{\ell-1} + |B^{xz}(\ell-1,i_{\ell-1})| + 3(R+1) + \sum_{j=i_{\ell-1}+1}^{t_{\ell-1}-1} |B^{xz}(\ell-1,j)| + r_{\ell-1}
= r_{\ell-1} - p_{\ell-1} + \sum_{j=i_{\ell-1}}^{t_{\ell-1}-1} |B^{xz}(\ell-1,j)| + 3(R+1)
\le (\ell-1)\cdot (3R+3)+1 + 3(R+1) \le \ell (3R+3) + 1 $, where the second to last inequality follows by the properties of our numbers for $\ell-1$.
For $\ell=L$ we get: $r_L - p_L + \sum_{j=i_L}^{t_L-1} |B^{xz}(L,j)| \le L (3R+3)+1$. Since $p_L \le |B^{xz}(L,i_L)|$, and $r_L \ge 0$ we get: $\sum_{j=i_L+1}^{t_L-1} |B^{xz}(\ell,j)| \le L (3R+3)+2$. Since each $B^{xz}(L,j)$ is of non-zero size,
$t_L-i_L-1 \le L (3R+3)+2$. Thus $t_L \le i_L + L (3R+3)+3 \le s^x_L + L (3R+3)+3$, as $i_L \le s^x_L$. The claim follows.
\end{proofof}
\section{Appending a symbol to a grammar decomposition}
\label{s-update}
In this section we provide a detailed description of the process of updating the active grammars of a string $x$ when appending a new symbol $a$.
By Lemma~\ref{l-grammarsuffix} only the last $T$ grammars of $x$ might change when adding a new symbol $a$.
As observed already previously, Lemma~\ref{l-grammarsuffix} also implies that once a grammar becomes more than
$(T+1)$-th grammar from the end it will never change, despite the fact that the number of grammars that follow it might shrink after adding more symbols.
(Adding more symbols might create periodicity that will be exploited by the compression.)
Our rolling sketch algorithm keeps at most $T$ active grammars that might still change after adding more symbols.
It is convenient for our implementation of the update function to have access also to the previous at most $T$ committed grammars (to have the proper context for re-compression).
Our rolling sketch algorithm has those committed grammars available in appropriate buffers.
Thus we will assume that the update function is always invoked with exactly $T+1$ grammars, unless $x$ is decomposed into less that $T+1$ grammars.
Some of the first few grammars from the output of the update procedure should be discarded as they correspond to grammars that should stay the same.
In particular, if there are $t$ active grammars and $s$ committed grammars then we should discard the first $\min(s,T+1-t)$ grammars
from its output.
The following statement encapsulates the properties of our update procedure ${\mathrm{UpdateActiveGrammars}}()$.
\begin{theorem}\label{t-update}
Let integers $k\le n$ and functions $C_1,\dots,C_L$ and $H_0,\dots,H_L$ be given.
For any $a\in \Sigma$ and $x\in \Sigma^*$ of length at most $n$ with $G_1,\dots,G_s$ being the grammars output by the decomposition algorithm on input $x$ using functions $C_1,\dots,C_L,H_0,\dots,H_L$, ${\mathrm{UpdateActiveGrammars}}(G_{s-\min(s,T+1)+1},\dots,G_s,a)$ outputs a sequence of grammars $G'_1,\dots,G'_{t'}$
such that $G_1,\dots,G_{s-\min(s,T+1)}, G'_1,\dots,G'_{t'}$ is the sequence that would be output by the decomposition algorithm on $x\cdot a$ using the functions $C_1,\dots,C_L, H_0,\dots,H_L$.
The update algorithm runs in time ${\widetilde{O}}(k L T)={\widetilde{O}}(k)$ and outputs $t' \le 4TL$ grammars.
\end{theorem}
Here we assume that the decomposition algorithm does not fail neither on $x$ nor on $x\cdot a$
with respect to producing correct deterministic grammars
so the first two parts of Theorem~\ref{t-decomposition} are satisfied for $x$ and $y=x\cdot a$,
and the choice of functions $C_1,\dots,C_L$ and $H_0,\dots,H_L$.
For the simplicity of our implementation, we assume a stronger property of $C_1,\dots,C_L$,
that each $C_\ell$ is one-to-one on the union of all blocks of $x$ and $x \cdot a$ at level $\ell$.
(See remark after Lemma~\ref{l-onetoone}.)
\subsection{Auxiliary functions}
Our update algorithm uses several simple and straightforward auxiliary functions we describe next.
Function ${\mathrm{DecompressSymbol}}(c,G,\ell,t)$ takes a symbol $c\in \Gamma$ and if it is a level-$\ell$ symbol
compressed by the grammar $G$ then it returns its decompression truncated to the length of at most $t$ symbols.
Otherwise it returns the original symbols $c$.
\begin{algorithm}[H]
\DontPrintSemicolon
\caption{${\mathrm{DecompressSymbol}}(c,G,\ell,t)$}
\KwIn{A symbol $c$, a grammar $G$, a level $\ell$, maximum output size $t\ge 2$.}
\KwOut{Decompresses $c$ if it was compressed at level $\ell$. Returns at most $t$ symbols of the decompression.}
\vspace{1mm}
\hrule\vspace{1mm}
\lIf{$c\in \Sigma^\ell_c$}{ let $a,b \in \Gamma$ be such that $c\rightarrow ab \in G$. Return $ab$. }
\lIf{$c\in \Sigma^\ell_r$}{ let $a\in \Gamma,r\in {\mathbb{N}}$ be such that $c={\mathtt{r}}_{a,r}$. Return $a^{\min(t,r)}$. }
Return $c$.
\end{algorithm}
Function ${\mathrm{DecompressString}}(Z,G,\ell)$ decompresses all level-$\ell$ compression symbols in a string $Z\in \Gamma^*$ using the grammar $G$, and returns the resulting decompressed string.
\begin{algorithm}[H]
\DontPrintSemicolon
\caption{${\mathrm{DecompressString}}(Z,G,\ell)$}
\KwIn{A string $Z$, a grammar $G$, and level $\ell$.}
\KwOut{Decompresses $z$ at level $\ell$.}
\vspace{1mm}
\hrule\vspace{1mm}
$Y=\eps$.
\lFor{$i=1$ to $|Z|$}{ $Y = Y\cdot {\mathrm{DecompressSymbol}}(Z[i],G,\ell,\infty)$.}
Return $Y$.
\end{algorithm}
Function ${\mathrm{DecompressSymbolLength}}(c,\ell)$ returns the length of the decompression of a symbol $c$ at level $\ell$.
\begin{algorithm}[H]
\DontPrintSemicolon
\caption{${\mathrm{DecompressSymbolLength}}(c,\ell)$}
\KwIn{A symbol $c$, a level $\ell$.}
\KwOut{Returns the length of decompression of $c$ at level $\ell$.}
\vspace{1mm}
\hrule\vspace{1mm}
\lIf{$c\in \Sigma^\ell_c$}{ return 2. }
\lIf{$c\in \Sigma^\ell_r$}{ let $a \in \Gamma,r\in {\mathbb{N}}$ be such that $c={\mathtt{r}}_{a,r}$. Return $r$. }
Return $1$.
\end{algorithm}
\begin{algorithm}[H]
\label{algo:compress1}
\DontPrintSemicolon
\caption{${\mathrm{CompressWithGrammar}}(B,\ell)$}
\KwIn{String $B$ over alphabet $\Gamma$, and level number $\ell$.}
\KwOut{String $B''$ over alphabet $\Gamma$, and set of applied rules $G'$.}
\vspace{1mm}
\hrule\vspace{1mm}
\lIf{$|B|\le 1$}{ return $B,\emptyset$. }
Set $G'=\emptyset$.
Divide $B=B_1B_2B_3\dots B_m$ into minimum number of blocks so that each maximal subword $a^r$ of $B$, for $a\in\Gamma$ and $r\ge 2$, is one of the blocks.
\For{each $i\in \{1,\dots, m\}$}{
\If{$B_i=a^r$, where $r\ge 2$}{
Set $B'_i = {\mathtt{r}}_{a,r} \cdot \#$ and color ${\mathtt{r}}_{a,r}$ by 1 and $\#$ by 2.
$G' = G' \cup \{ {\mathtt{r}}_{a,r} \rightarrow a^r \}$;
}
\lElse{Set $B'_i = B_i$ and color each symbol of $B'_i$ according to $F_{\mathrm{CVL}}(B_i)$}
}
Set $B'=B'_1B'_2\cdots B'_m$, $B''=\eps$, and $i = 1$.
\While{$i<|B'|$}{
\lIf{ $B'[i+1] = \#$}{ $B'' = B'' \cdot B'[i]$}
\Else{
$B'' = B'' \cdot C_\ell(B'[i,i+1])$;
$G' = G' \cup \{ C_\ell(B'[i,i+1])\rightarrow B'[i,i+1] \}$;
}
$i = i+2$.
\lIf{$i\le |B'|$ and $B'[i]$ is not colored 1}{
$B'' = B'' \cdot B'[i]$, $i = i+1$
}
}
Return $B'', G'$.
\end{algorithm}
Function ${\mathrm{CompressWithGrammar}}(B,\ell)$ is an extension of ${\mathrm{Compress}}(B,\ell)$ that in addition
to compressed block $B$ at level $\ell$ returns the set of grammar rules used for the compression of $B$ at this level.
Finally, function ${\mathrm{FindCompressedPrefix}}(Z,p,\ell)$ returns the length of the smallest prefix of a string $Z$
that decompresses into at least $p$ symbols at level $\ell$.
\begin{algorithm}[H]
\label{algo:find_index}
\DontPrintSemicolon
\caption{${\mathrm{FindCompressedPrefix}}(Z,p,\ell)$}
\KwIn{String $Z$, an integer $p$, level $\ell$.}
\KwOut{Smallest index $j$ such that level $\ell$ decompression of $Z[1,j]$ has length $\ge p$.}
\vspace{1mm}
\hrule\vspace{1mm}
$q=0$ and $j=0$.
\While{$q < p$}{
$j = j+1$;
$p = p+{\mathrm{DecompressSymbolLength}}(Z[j],\ell)$;
}
Return $j$.
\end{algorithm}
\subsection{Main functions}
The core of the update function ${\mathrm{UpdateActiveGrammars}}((G_1,\dots,G_t),a)$ is build around the functions we describe next.
The functions use globally accessible set of grammar rules $G$ that contains all the rules from
$G_1,\dots,G_t$ except for the starting rules.
(This set of rules is deterministic assuming the remark after Theorem~\ref{t-update}.)
The functions will build a sequence of strings $Z_L,Z_{L-1},\dots,Z_0$ each of length at most $2T$.
$Z_L$ is the concatenation of the right-hand-sides of starting rules of $G_1,\dots,G_t$.
For $\ell=L,\dots,1$, $Z_{\ell-1}$ is then build inductively by decompressing a (suitable) largest suffix
of $Z_\ell$ so that $Z_{\ell-1}$ would be of length at most $T+4 \le 2T$.
The decompression is provided by function ${\mathrm{PartiallyDecompress}}(Z,F,\ell)$ which returns tuple $Z',F',u,r'$.
In the case that the first symbol of the decompressed suffix of $Z_\ell$ is the level-$\ell$ repeat symbol
${\mathtt{r}}_{a,r}$ that would expand $Z_{\ell-1}$ beyond the limit of $T+4$ symbols, we truncate the expansion
of that symbol to the length $r_{\ell}=r'$.
The return value $u$ indicates how many symbols of $Z$ were left uncompressed (which would include the partially decompressed symbol ${\mathtt{r}}_{a,r}$).
It satisfies that if $u\ne 0$ then $|Z'|\ge T$.
Strings $Z_L,\dots,Z_0$ satisfy that for $\ell=L,\dots,1$, if $|Z_\ell|\ge T$ then $|Z_{\ell-1}|\ge T$.
(In particular, if ${\mathrm{UpdateActiveGrammars}}()$ is invoked with at least $T+1$ grammars, then all $Z_\ell$ are of length at least $T$.
The compression of the first grammar might depend on unseen grammars in that case so we cannot re-compress it at will.)
Strings $Z_L,\dots,Z_0$ are accompanied by strings of integers $F_L,\dots,F_0$ over the alphabet $\{0,\dots,L+1\}$.
The value of $F_\ell[i]$ indicates at which level the symbol $Z_\ell[i]$ becomes the first symbol in its block.
In particular, $F_\ell[i] < \ell$ indicates that a block starts at position $i$ of $Z_\ell$.
This value is relevant for re-compression of updated strings $Z_0,\dots,Z_L$.
The initial values of $F_L$ are computed using ${\mathrm{SplittingDepth}}(G)$.
Function ${\mathrm{SplittingDepth}}(G)$ is fairly straightforward: For a grammar $G$, it inductively decompresses
the first two symbols of the evaluation of $G$.
It finds the lowest level $\ell$, at which the first two symbols of the decompression give zero when function $H_\ell$ is applied on them.
After obtaining $Z_L,\dots,Z_0$, ${\mathrm{UpdateActiveGrammars}}((G_1,\dots,G_t),a)$ appends $a$ to $Z_0$, and then
re-compresses $Z_0,\dots,Z_{L-1}$ using a function ${\mathrm{Recompress}}(B,Z,F,u,r,\ell)$.
We provide more details on function ${\mathrm{Recompress}}(B,Z,F,u,r,\ell)$ further below.
Invoking ${\mathrm{UpdateActiveGrammars}}((G_1,\dots,G_t),a)$ returns a sequence of updated grammars.
\begin{algorithm}[H]
\label{algo:partial_decompress}
\DontPrintSemicolon
\caption{${\mathrm{PartiallyDecompress}}(Z,F,\ell)$}
\KwIn{String $Z$, splitting depth string $F$, and level $\ell$.}
\KwOut{Decompressed string $Z'$, splitting depth string $F'$, unused count $u$, repeat count $r'$.}
\vspace{1mm}
\hrule\vspace{1mm}
Set $Z'=\eps$ and $F'=\eps$.
\For{$u = |Z|$ to $1$}{
\If{$Z[u] = {\mathtt{r}}_{a,r}$, where ${\mathtt{r}}_{a,r} \in \Sigma_{r}^{\ell}$}{\;
\lIf{$|Z'| + r \le T + 3$}{
$Z' = a^r \cdot Z'$ and
$F' = F[u] \cdot (L+1)^{r-1} \cdot F'$
}
\Else{
$r' = T - |Z'| + 1$;
$Z' = a^{r'} \cdot Z'$ and $F' = (L+1)^{r'} \cdot F'$ ;
Return $Z',F',u,r'$.
}
}
\ElseIf{$Z[u]=a$, where $a \in \Sigma_{c}^{\ell}$}{
$Z' = b\cdot c \cdot Z'$, where $a\rightarrow b\cdot c$ is in $G$;
$F' = F[u] \cdot (L+1) \cdot F'$;
}
\lElse{$Z' = Z[u] \cdot Z'$ and $F' = F[u] \cdot F'$}
\lIf{$|Z'| \ge T$}{
return $Z',F',u-1,0$.
}
}
Return $Z',F',0,0$.
\end{algorithm}
\begin{algorithm}[H]
\DontPrintSemicolon
\caption{${\mathrm{SplittingDepth}}(G)$}\label{alg-split-depth}
\KwIn{Non-empty grammar $G$.}
\KwOut{The first level $\ell$ where $G$ would be separated as a new block.}
\vspace{1mm}
\hrule\vspace{1mm}
Let $v$ be such that $\# \rightarrow v \in G$. \acc{$v$ are the first two symbols of ${\mathrm{eval}}(G)$.}
$d = L+1$.
\For{ $\ell=L,\dots, 0$}
{
\lIf{$|v|\ge 2$ and $H_\ell(v[1,2])=0$}{$d = \ell$.}
$u = {\mathrm{DecompressSymbol}}(v[1],G,\ell,2)$
\lIf{$|v| \ge 2$}{ $u = u \cdot {\mathrm{DecompressSymbol}}(v[2],G,\ell,2)$.}
$v=u$.
}
Return $d$.
\end{algorithm}
\begin{algorithm}[H]
\label{algo:update_ag}
\DontPrintSemicolon
\caption{${\mathrm{UpdateActiveGrammars}}(AG,a)$}
\KwIn{List of grammars $AG = (G_1 , \dots , G_t)$ representing a string $x$, and a symbol $a$.}
\KwOut{Updated list of grammars $AG'$ representing string $x\cdot a$.}
\vspace{1mm}
\hrule\vspace{1mm}
\acc{Construct a set of rules $G$, initial compressed string $Z_L$ and splitting depth string $F_L$.}
For $i=1,\dots,t$, let $\# \rightarrow v_i$ be the starting rule in $G_i$.
Set $G = \bigcup_{i=1}^t G_i \setminus \{\# \rightarrow v_i\}$.
Set $Z_L = v_1$ and $F_L = 0 \cdot (L+1)^{|v_1|-1}$.
For $i=2,\dots,t$, set $Z_L = Z_L \cdot v_i$ and $F_L = F_L \cdot {\mathrm{SplittingDepth}}(G_i) \cdot (L+1)^{|v_i|-1}$.
\acc{Perform partial decompression}
\For{$\ell = L$ to $1$}{
$Z_{\ell-1}, F_{\ell-1}, u_{\ell}, r_{\ell} = {\mathrm{PartiallyDecompress}}(Z_{\ell},F_{\ell}, \ell)$.
}
\acc{Perform re-compression}
$Z_0 = Z_0\cdot a$;
$B = {\mathrm{Split}}(Z_0,0)$;
\For{$\ell = 1$ to $L$}{
$B',G' = {\mathrm{Recompress}}(B,Z_{\ell}, F_{\ell}, u_{\ell}, r_{\ell}, |Z_{\ell-1}|, \ell)$
$G = G \cup G'$
$B = B'$
}
Let $B = (B_1,\dots , B_{t'})$.
$AG'=()$.
\For{$i = 1$ to $t'$}{
$G' = G \cup \{\#\rightarrow B_i\}$.
Remove from $G'$ unnecessary rules to get $G'_i$ (as in Section~\ref{s-grammars}).
Append $G'_i$ to $AG'$.
}
Return $AG'$.
\end{algorithm}
Function ${\mathrm{Recompress}}(B,Z,F,u,r,\ell)$ gets a sequence $B=(B_0,\dots,B_s)$ of blocks
that represent compression of the updated $Z_{\ell-1}$ (after adding $a$) up-to level $\ell-1$.
It also gets the original $Z_\ell$, the splitting depth string $F_\ell$, the number of symbols $u_\ell$
that were decompressed from $Z_\ell$ to get the original $Z_{\ell-1}$ and the parameter $r_\ell$
that indicates that the first $r_\ell$ symbols of $Z_{\ell-1}$ are a partial decompression of the repeat symbol $Z_{\ell}[u]$.
It outputs a sequence of blocks $B'$ that represent the updated block $Z_\ell$ compressed up-to level $\ell$, and a set of rules $G'$ that were used for compression at level $\ell$.
Blocks $B_1,\dots,B_s$ can be independently compressed and split at level $\ell$.
The block $B_0$ needs a special treatment though as it needs to be combined with its possible remainder in $Z_\ell$.
This is done in function ${\mathrm{RecompressFirstBlock}}(B_0,Z,F,u,r,\ell)$.
Remaining blocks for the output ${\mathrm{Recompress}}()$ are obtained from $Z_\ell$ by splitting it into blocks according
to $F_\ell$.
\begin{algorithm}[H]
\label{algo:recompression}
\DontPrintSemicolon
\caption{${\mathrm{Recompress}}(B,Z,F,u,r,z,\ell)$}
\KwIn{$B=(B_0,\dots,B_s)$ sequence of blocks, original uncompressed string $Z$, splitting depth string $F$ of $Z$, $u$ number of uncompressed symbols in $Z$, repeat count $r$, $z=|Z_{\ell-1}|$, and level $\ell$.}
\KwOut{$B'$ a new sequence of blocks representing $B$ together with $Z[1,u]$, and set of newly added rules $G'$.}
\vspace{1mm}
\hrule\vspace{1mm}
\lIf{$z<T$}{ $B'=()$, $G'=\emptyset$, $u'=0$, $j=0$. \acc{No symbols precede $B_0$.} }
\Else{
$B',G',u' = {\mathrm{RecompressFirstBlock}}(B_0,Z,F,u,r,\ell)$. \acc{ Compress block $B_0$. }
$j=1$.
}
\acc{ Compress blocks $B_j,\dots,B_s$.}
\For{$i = j$ to $s$}{
\lIf{$|B_i|\le 2$}{ $B'' = (B_i)$; $G''=\emptyset$ }
\Else{
$B'_i,G'' = {\mathrm{CompressWithGrammar}}(B_i,\ell)$.
$B'' = {\mathrm{Split}}(B'_i,\ell)$.
}
Append $B''$ to $B'$.
$G'= G' \cup G''$.
}
$i=u'$. \acc{ Separate remaining blocks in $Z$. }
\While{$i>0$}{
\lWhile{$i>1$ and $F[i]>\ell$}{$i=i-1$.}
Add $Z[i,u']$ as the first item of $B'$.
$i=i-1; u'=i$.
}
Return $B',G'$.
\end{algorithm}
Function ${\mathrm{RecompressFirstBlock}}(B_0,Z,F,u,r,\ell)$ is the most complicated function of the whole re-compression process.
The function is invoked only if $|Z_{\ell-1}|\ge T$.
The function gets the first level $\ell-1$ block $B_0$ that needs to be combined with its remainder in $Z=Z_\ell$.
The remainder is a suffix of $Z_\ell[1,u]$, where $r$ indicates that the first $r$ symbols of the original $Z_{\ell-1}$ were obtained by the partial decompression of $Z_\ell[u]$.
If $r\ne 0$ then the compression of the part of $B_0$ that follows its leading $a$'s ($Z_\ell[u]={\mathtt{r}}_{a,r'}$) is independent of the compression of the part of $Z$ belonging to $B_0$ and preceding $Z_\ell[u]$, as $r'-r\ge 2$.
Thus we can compress that part of $B_0$, combine it with an appropriate repetition symbol ${\mathtt{r}}_{a,r''}$
and append it to the appropriate suffix of $Z_\ell[1,u-1]$ (which is already compressed at level $\ell$.)
If $r=0$ then we invoke a function ${\mathrm{CrossOverBlock}}(B_0,Z[u',\dots],u-u'+1,\ell)$, where $u'$ is the first symbol in $Z_\ell$ that belongs to the block of $B_0$.
Eventually, we split the compressed block $B_0$ using ${\mathrm{Split}}()$.
\begin{algorithm}[H]
\label{algo:recompressionFirst}
\DontPrintSemicolon
\caption{${\mathrm{RecompressFirstBlock}}(B_0,Z,F,u,r,\ell)$}
\KwIn{Block $B_0$, an original uncompressed string $Z$, splitting depth string $F$ of $Z$, $u$ number of uncompressed symbols in $Z$, repeat count $r$, and level $\ell$.}
\KwOut{$B'$ a new sequence of blocks representing $B_0$ together with $Z[1,u]$, and set of newly added rules $G'$, number $u'$ of unused symbols in $Z$.}
\lIf{$r\ne 0$}{$u=u-1$.}
$u'= u+1$. \acc{ Find the beginning of block $B_0$ in the uncompressed part $Z$. }
\lWhile{$u'>1$ and $d[u'] \ge \ell$}{
$u'=u'-1$.
}
\If{$r \ne 0$}{
\acc{ Block $B_0$ starts by partially decompressed symbol ${\mathtt{r}}_{a,r}$. }
Let $a\in \Gamma$ and $r'\in {\mathbb{N}}$ be such that $Z[u+1]={\mathtt{r}}_{a,r'}$.
\lFor{$i=1$ to $|B_0|$}{
\lIf{$B_0[i] \ne a$}{break;}
}
\lIf{$B_0[i]=a$}{ $B'=\eps, G'' = \emptyset$, $i=i+1$. }
\lElse{$B',G'' = {\mathrm{CompressWithGrammar}}(B_0[i,\dots],\ell)$.}
$B' = Z[u',u] \cdot {\mathtt{r}}_{a,r'-r+i-1} \cdot B'$.
}
\Else{
$B',G'' = {\mathrm{CrossOverBlock}}(B_0, Z[u',\dots],u-u'+1,\ell)$.
}
$B'' = {\mathrm{Split}}(B',\ell)$.
Return $B'',G'',u'-1$.
\end{algorithm}
Function ${\mathrm{CrossOverBlock}}(B,Z,u,\ell)$ gets a block $B$ that was compressed up-to level $\ell-1$ and
needs to be combined with its remainder $Z[1,u]$ that is compressed up-to level $\ell$.
(The resulting block should correspond to ``$Z[1,u] \cdot B$''.)
We know that $|Z_{\ell-1}|\ge T \ge L(3R+3)$ otherwise ${\mathrm{RecompressFirstBlock}}()$ and ${\mathrm{CrossOverBlock}}()$ would not be called.
By the three properties of $\Delta_{\ell-1}$ and $i_{\ell-1}$ defined in the proof of Part 1 of Lemma~\ref{l-grammarsuffix}
we know that the first $3(R+1)$ symbols of $Z_{\ell-1}$ were not modified as a result of appending the new symbol to $x$.
Hence the first $\min(3(R+1),|B|)$ symbols of $B$ correspond to the decompression of $Z[u+1,\dots]$.
In this part of $B$ we look for any repeated symbol.
If we find a repeated symbol there, we combine the compression of the part of $B$ starting at the repeated symbol with the original
part of $Z[u+1,\dots]$ that produced the symbols of $B$ preceding the repeated symbol (and also with $Z[1,u]$).
By the properties of compression, repeated symbols break dependence between compressed symbols.
If $|B|\le 2R+20$ then at least $3(R+1)-2R-20>2$ unchanged symbols follow $B$.
Thus $B$ ends at its original location as it was split at some level $<\ell$ and the first two symbols of the next block at all
levels $<\ell$ are the same as originally.
Finally, if $|B|>2R+20$ and there is no repeated symbol in the first up-to $3(R+1)$ symbols of $B$
then we can compress $B$ to get $B'$, strip from $B'$ the compression of the first $R+10$ symbols
and combine it with the original compression of those $R+10$ symbols from $Z$.
(The first up-to $3(R+1)$ symbols of $B$ consist of singletons.
The compression of a singleton depends on the context of at most $R+3$ symbols on either side.)
\begin{algorithm}[H]
\label{algo:recompressionCross}
\DontPrintSemicolon
\caption{${\mathrm{CrossOverBlock}}(B,Z,u,\ell)$}
\KwIn{Block $B$, an original uncompressed string $Z$, number $u$ of unused symbols in $Z$, and level $\ell$.}
\KwOut{$B'$ and set of newly added rules $G'$.}
\acc{ Try to find a repeated symbol in unmodified $B$. }
$i=1$.
\lWhile{$i<|B|$ and $i < 3(R+1)$ and $B[i]\ne B[i+1]$}{ $i=i+1$.}
\If{$i<|B|$ and $B[i] = B[i+1]$}{
\acc{$B[i]$ is a repeated symbol.}
$B',G' = {\mathrm{CompressWithGrammar}}(B[i,\dots],\ell)$.
$j = {\mathrm{FindCompressedPrefix}}(Z[u+1,\dots],i-1,\ell)$.
$B' = Z[1,u+j] \cdot B'$.
}
\ElseIf{$|B|\le 2R+20$}{
$j = {\mathrm{FindCompressedPrefix}}(Z[u+1,\dots], |B|, \ell)$. \acc{At least two unchanged symbols follow $B$.}
$B' = Z[1,u+j]$, $G'=\emptyset$.
}
\Else{
$B',G' = {\mathrm{CompressWithGrammar}}(B,\ell)$.
$p = {\mathrm{FindCompressedPrefix}}(B',R+10, \ell)$.
$j = {\mathrm{FindCompressedPrefix}}(Z[u+1,\dots], R+10, \ell)$.
$B' = Z[1,u+j-1] \cdot B'[p,\dots]$.
}
Return $B',G'$.
\end{algorithm}
The correctness of the update algorithm follows from its description.
\subsection{Time analysis}
We assume that strings are represented efficiently (e.g. by balanced trees) so we can extract a sub-string, concatenate strings, etc. in time ${\widetilde{O}}(1)$. All strings that we will operate on will be of length $O(T)$.
Similarly, we assume that grammars are represented efficiently so that we can look-up a rule with a given
left-hand symbol, append two grammars, etc. in time ${\widetilde{O}}(1)$.
Then ${\mathrm{DecompressSymbol}}()$ and ${\mathrm{DecompressSymbolLength}}()$ takes time ${\widetilde{O}}(1)$.
The time complexity of each of the functions ${\mathrm{CompressWithGrammar}}()$, ${\mathrm{DecompressString}}()$,
${\mathrm{FindCompressedPrefix}}()$, ${\mathrm{PartiallyDecompress}}()$ and ${\mathrm{CrossOverBlock}}()$ is proportional to the length of strings on which it operates so it is ${\widetilde{O}}(T)$.
Time of ${\mathrm{SplittingDepth}}()$ is proportional to the depth of the grammar, which in our case is at most ${\widetilde{O}}(L)$.
Each ${\mathrm{RecompressFirstBlock}}()$ executes $O(T)$ operations on strings and grammars, and $O(T)$
evaluations of $H_\ell$ (inside the calls to ${\mathrm{Split}}()$).
Since $H_\ell$ is ${\widetilde{O}}(k)$-wise independent, its evaluation takes time ${\widetilde{O}}(k)$.
So ${\mathrm{RecompressFirstBlock}}()$ takes time ${\widetilde{O}}(k T)$.
Similarly, each ${\mathrm{Recompress}}()$ executes up-to one call to ${\mathrm{RecompressFirstBlock}}()$, $O(T)$ operations on strings and grammars, and $O(T)$ evaluations of $H_\ell$ to split blocks.
Again, its total time complexity is ${\widetilde{O}}(k T)$.
Eventually, ${\mathrm{UpdateActiveGrammars}}()$ executes up-to $T$ ${\mathrm{SplittingDepth}}()$, $O(T)$ string operations,
$L$ calls to ${\mathrm{PartiallyDecompress}}()$ and ${\mathrm{Recompress}}()$, and then up-to $O(LT)$ invocations of
grammar minimization procedure costing ${\widetilde{O}}(k)$ time each. Thus, the total time for ${\mathrm{UpdateActiveGrammars}}()$ is ${\widetilde{O}}(LTk)$.
The number of grammars the algorithm outputs is at most $\sum_{\ell=0}^L |Z_\ell| \le 2T(L+1) \le 4TL$.
\section{Table of parameters}\label{s-param}
\begin{center}
\begin{tabular}{ |l|c|c|c| }
\hline
Definition & Asymptotics & Meaning & Reference \\
\hline
\hline
$R = \log^{*}|\Gamma| + 20$ & $\log^* n$ & compression locality & Section \ref{s-locally_consistent_parsing}\\ \hline
$L=\lceil \log_{3/2} n \rceil+3$ & $ \log n$ & recursion depth & Section \ref{s-decomposition}, Corollary \ref{c-decomposition1}\\ \hline
$D = 110c-R(L+1)k$ & $k \log n \log^* n$ & $1/$splitting probability & Section \ref{s-decomposition}, Lemma \ref{l-decomposition1}\\ \hline
$S=30 DL \log n + 6$ & $k \log^3 n \log^* n$ & maximum grammar size & Section \ref{s-decomposition}, Theorem \ref{t-decomposition}\\ \hline
$M= 3 S \cdot \lceil 1 + \log |\Gamma| \rceil$ & $k \log^4 n \log^* n$ & grammar encoding size & Section \ref{s-binencoding}\\ \hline
$T=L(3R+6)$ & $\log n \log^* n$ & locality of suffix changes & Section \ref{s-rolling}, Lemma \ref{l-grammarsuffix}\\ \hline
$N \ge n^3$ & $n^3$ & ${F_\mathrm{KR}}$ range size & Section \ref{s-binencoding}\\ \hline
\end{tabular}
\end{center}
\section*{Acknowledgements}
The authors benefited greatly from discussions with Nicole Wein who took part in the initial stages of this project.
The second author also benefited from many discussions on edit distance with Mike Saks.
We are grateful to Tomasz Kociumaka for providing us with a reference for Proposition~\ref{p-edgrammar}.
We thank anonymous reviewers for their comments.
\bibliographystyle{alpha}
| {'timestamp': '2023-02-10T02:07:53', 'yymm': '2302', 'arxiv_id': '2302.04475', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04475'} | arxiv |
\section{Introduction}
The recent decade has witnessed a fast-growing demand for processing and analyzing complex networks. While there are numerous studies about the single static network(\cite{amini2013pseudo, gao2017achieving,gao2018community,wang2021fast,jing2022community,yu2022collaborative}), researchers have shown increasing interest in the study of the multilayer network (\cite{paul2017spectral,le2018estimating,lei2020consistent, arroyo2021inference, jing2021community, li2021super, chen2022global}), which is a more powerful representation of multi-relational data. Numerous kinds of real-world data could be recorded as multilayer networks, such as brain connectivity networks, gene-gene interactivity networks and world trading networks.\\
Since community structure is a common observation in static network analysis, it naturally raises the question on how to define and detect community structure in multilayer networks. In a multilayer network, the nodes represent individuals of interest and the edges between nodes in different layers represent different relationships. Such complex relations in multilayer networks pose great challenges to identify and analyze its community structure. Particularly, the heterogeneity across layers can be characterized by individual links, group memberships of nodes, or connectivity patterns inside the community and among different communities. Recently, \cite{jing2021community} proposed a novel mixture multilayer SBM(MMSBM) with a new tensor-based method TWIST to simultaneously cluster networks and identify global and local group memberships of vertices. Moreover, \cite{lyu2021latent} introduced a novel mixture multilayer LSM(MMLSM) that estimates the latent positions of nodes via the generalized low-rank tensor decomposition.\\
In this paper, we propose an R package \textbf{rMultiNet} to analyze the mixture multilayer network. Fig.\ref{fig:framework} illustrates the overview of our package \textbf{rMultiNet}. We provide several prevalent methods for users to study the latent features of multilayer networks. First, we provide three real datasets as examples to study and two generative models, the MMSBM and the MMLSM, to generate mixture multilayer networks. Then, we provide several fitting methods from \cite{jing2021community} and \cite{lyu2021latent} to reveal the embedding results of the multilayer network following with several prevalent clustering methods to analyze the embedding results. Last, several data visualization functions are provided to present the out-comings.
\begin{figure}
\centering
\includegraphics[width=6in]{framework.png}
\caption{overview of the \textbf{rMultiNet} package} \label{fig:framework}
\end{figure}
\section{Package overview}
\textbf{rMultiNet} includes models to generate multilayer networks, several algorithms to learn complex mixture multilayer networks' latent structures, multiple clustering methods to further analyze the embedding results, and several visualization functions for presentation. The package is organized into the modules listed below:
\begin{itemize}
\item \textbf{Generation}: \textbf{rMultiNet} adopts the mixture multilayer stochastic(MMSBM) (\cite{jing2021community}) and mixture multilayer latent space(MMLSM) (\cite{lyu2021latent}) to generate mixture multilayer networks.
\item \textbf{Embedding}: \textbf{rMultiNet} contains two tensor decomposition algorithms for mixture multilayer network embedding, e.g., the TWIST proposed by \cite{jing2021community} and the ProjectedGD introduced by \cite{lyu2021latent}. Moreover, a naive method, spectral clustering on the sum of adjacency matrices from all layers (Sum–Adj) and Mode-3 flatting(M3-SC), proposed in \cite{jing2021community}, is included as a baseline for comparison.
\item \textbf{Clustering}: \textbf{rMultiNet} provides several clustering methods to analyze the embedding results, such as K-means (\cite{likas2003global}), spectral clustering (\cite{dong2012clustering}) and Density-based spatial clustering of applications with noise (DBSCAN) (\cite{hahsler2019dbscan}).
\item \textbf{Datasets}: \textbf{rMultiNet} contains three datasets for study.
\textbf{Human malaria parasite gene network}: The data under investigation are the 9 Highly variable regions of the malaria parasite gene sequence. Each network contains 212 nodes, which appear on all 9 layers. More details about the background and the data pre-processing could be found in \cite{larremore2013network} and \cite{jing2021community}.\\
\textbf{Worldwide food trading network}: In this multilayer network, layers represent different products, nodes are countries, and edges at each layer represent trading relationships of a specific food product among countries. The data is collected by \cite{de2015structural} and is available at http://www.fao.org. After data pre-processing (\cite{jing2021community}), we obtain a 30-layers network with 99 nodes. \\
\textbf{UN Commodity trading network}: The dataset contains annual trade information for countries in 2019 from the UN Comtrade Database (https://comtrade.un.org). We focus on the top representative 48 countries ranked by the exports of goods and services in US dollars. Each layer represents a different type of commodity classified into 97 categories (\cite{lyu2021latent}).\\
\end{itemize}
\section{Functionality and Examples}
In this section, we provide the detailed usage of \textbf{rMultiNet} package. Specific meanings of notations used in this part can be found in \cite{jing2021community} and \cite{lyu2021latent}.
The multilayer network to be explored can be either generated from the package or loaded from external files. The data load from external files needs to be in the form of the `\emph{tensor}` class defined in package \textbf{rTensor}. We provide two approaches to generate the adjacency tensor of the mixture multilayer network in \textbf{rMultiNet} as follows, corresponding to MMSBM and MMLSM respectively.\\
$>$ \emph{library(rMultiNet)}\\
$>$ \emph{GenerateMMSBM(n, m, L, K, d = NULL, r = NULL)}\\
$>$ \emph{GenerateMMLSM(n, m, L, rank, U\_mean= 0.5, cmax =1, d, int\_type = `Uniform', kernel\_fun = `logit', scale\_par=1)}\\
Here, $n$ is the number of vertices, $m$ is the number of types of the network, $L$ is the number of layers, $K$ is the number of groups of vertices, $d$ is the average degree of the network in each layer and
$r$ is the out-in ratio in each layer. Particularly in function \emph{GenerateMMLSM}, $rank$ is the rank of latent position matrix $U$, {\emph{U\_mean}} is the mean of the normal distribution of each entry of $U$, \emph{cmax} is the entry-wise upper bound of core tensor C, {\emph{int\_type}} represents the ways of generating tensor C (\emph{`Uniform'} or \emph{`Norm'}), {\emph{kernel\_fun}} is the link function of generating the adjacency tensor (\emph{`logit'} or \emph{`probit'}) and {\emph{scale\_par}} is the scaling factor of the parameter tensor. The output is a list including an adjacency tensor and the generating parameters $\Theta$.\\
The multilayer network loaded or generated from the above, will be stored as an adjacency tensor. \textbf{rMultiNet} provides algorithms to learn the latent structure of the adjacency tensor.\\
$>$ \emph{InitializationMMSBM(tnsr, ranks=NULL)}\\
$>$ \emph{PowerIteration(tnsr, ranks=c(2,2,2), type="TWIST", U\_0\_list, delta1=1000, delta2=1000, max\_iter = 25, tol = 1e-05)}\\
The function \emph{InitializationMMSBM} outputs initialization \emph{U\_0\_list}, which can be the input of function \emph{PowerIteration}. Here \emph{tnsr} is the adjacency tensor of the network, \emph{type} specifies the iterative algorithm to run \emph{`TWIST'} or \emph{`Tucker'}, \emph{delta1} and \emph{delta2} are tuning parameters for regularization in mode-1 and mode-2, \emph{max\_iter} is the max times of iteration and \emph{tol} is the convergence tolerance. Note that the \emph{ranks} is the rank of the core tensor calculated by the equation $m \times K - (m - 1)$ (see \cite{jing2021community}). The output is a list including the core tensor $Z$, network embedding and node embedding. \\
$>$ \emph{SpecClustering(tnsr, rank, embedding\_type = "Layer")}\\
In function \emph{SpecClustering}, \emph{tnsr} is the adjacency tensor, \emph{rank} is the number of columns of the output matrix $U$, \emph{embedding\_type} specifies the embedding type (Sum-Adj for \emph{`Node'} and M3-SC for \emph{`Layer'}). The output matrix $U$ can be applied in cluster methods like kmeans.\\
$>$ \emph{InitializationLSM(gen\_list, n, rank, M, perturb = 0.1, int\_type)}\\
$>$ \emph{ProjectedGD(Ini\_list, Cmax, eta\_outer = 1e-04,
tmax\_outer = 35, p\_type =`logit', rd =`Non', show = TRUE, sgma =1, sample\_size =5000)}\\
In function \emph{InitializationLSM}, \emph{gen\_list} is a list including the adjacency tensor and the parameter $\Theta$ of the mixture multilayer network, \emph{$n$} is the number of nodes, \emph{rank} is the rank of $U$; \emph{M} is the number of network types, \emph{perturb} specifies the upper bound of Uniform distribution, \emph{int\_type} specifies the method to initialize $U$ and $W$ ( \emph{`spec'}, \emph{`rand'} or \emph{`warm'}). The output of function \emph{InitializationLSM} is a list including the adjacency tensor, $U_{0}$, $W_{0}$ and tuning parameters $\{\delta_{1}, \delta_{2}, \delta_{3}\}$. In function \emph{ProjectedGD}, \emph{Ini\_list} is the output of function \emph{InitializationLSM}, \emph{Cmax} is the upper limits for adding the coefficient constraint, \emph{eta\_outer} is the learning rate in gradient descent, \emph{tmax\_outer} is the number of iterations in gradient descent, \emph{p\_type} specifies the type of link function (\emph{`logit'}, \emph{`probit'} or \emph{`poisson'}), \emph{rd} specifies whether to use stochastic sampling (\emph{`rand'} or \emph{`Non'}) and \emph{sgma} is the link function parameter $\sigma$. The output is the embedding results of nodes and layers.\\
\textbf{rMultiNet} also implements functions for visualization.\\
$>$ \emph{Embedding\_network(network\_membership,L, paxis = 2)} \\
This function is used to produce plots of network embedding and node embedding, respectively. Here \emph{paxis} specifies the number of eigenvectors to use in the plot. If the number of eigenvectors is more than two, a plot table is supposed to generate. By default, it plots the second eigenvector and the third eigenvector.\\
$>$ \emph{Community\_cluster\_km(embedding,type,cluster\_number)} \\
$>$ \emph{Community\_cluster\_dbscan(embedding,type,eps\_value =.05,pts\_value=5)} \\
Clustering algorithms like K-means and DBSCAN can be applied to the results of embedding. Here, \emph{type} can be either node embedding \emph{`n'} or network embedding \emph{`N'}, \emph{cluster\_number} is the number of clusters for Kmeans, \emph{eps\_value} and \emph{pts\_value} is parameters for DBSCAN.
\section{Summary}
\textbf{rMultiNet} introduces an extension R package that includes a variety of traditional and state-of-the-art tensor decomposition methods for mixture multilayer network analysis. The package is developed with the modular pipeline mode: generative modeling, embedding algorithms, and visualization. In response to growing data and interactions in different networks, \textbf{rMultiNet} aims to help study complex networks, especially mixture multilayer networks. The dynamic networks also apply in this package which can be regarded as a special case of multilayer networks with layers indexed by time.
\acks{}
\vskip 0.2in
| {'timestamp': '2023-02-10T02:06:30', 'yymm': '2302', 'arxiv_id': '2302.04437', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04437'} | arxiv |
\section{Introduction}
\label{sec:introduction}
Electroencephalography (EEG) is a modality that allows the passive measurement outside the head of the electrical potential arising mainly from the electrical activity of the brain.
The measurements obtained at sensors at time \textit{t} are linear combinations of the electrical activities at this same time \textit{t} of a set of “sources” located at the level of the cerebral cortex. These sources are time dependent on each other according to a complex biophysical model that is poorly understood (because it depends on many parameters) and which is therefore not easy to establish. The temporal dependence between cortical sources remains poorly understood and difficult to obtain, at least if we are trying to stick closely to biophysical models. There are, however, simple models which,
even if they are not completely justified by biology, are general enough to be used with EEG measurements. An example of those are auto regressive models (AR).
These models are based on the hypothesis that the signal can be explained by a combination of its past values plus some random factor called innovation. The AR model has been used on several occasions and in different ways. For example they allow to model the interactions between the different zones of the brain during cognitive tasks~\cite{belaoucha-papadopoulo:20}, to extract information from signals~\cite{ding-bressler-etal:00} or detect state changes~\cite{kirch-muhsal-etal:15}. Finally, autoregressive models are sometimes used in conjunction with machine learning methods for performing classification tasks~\cite{faradji-ward-etal:19}.
One promising application of EEG signal analysis is Brain Computer Interfaces (BCI). BCI can be defined as a technology that measures brain activity and translates that signal into instructions or commands for a digital system.
We focus on electroencephalography (EEG)-based BCI (BCI-EEG), which is non-invasive, possess a high time resolution and is relatively inexpensive. Because of these characteristics, BCI-EEG interfaces are candidates to becoming the main BCI technology in a mass deployment perspective for everyday use.
In particular, we focus on motor imagery BCI paradigms, where the user changes his brain activity by imagining the movement of a body part.
Even though BCI was created for medical purposes, the use of this technology has expanded, and found its way into non-medical applications ranging from drone control~\cite{duan-xie-etal:19}, rehabilitation in neurological diseases to applications in the context of Virtual and Augmented reality~\cite{wen-fan-etal:21} or video gaming.
However, despite the incredible progress made in the last ten years, the BCI field is still in its infancy. In fact, we have not yet obtained a level of accuracy that would allow an application in everyday life. Moreover, the classification performance are particularly sub-optimal for some particular subjects suffering from 'BCI illiteracy':
some research estimates that about $30\%$ of all BCI users are unable to reach at least $70\%$ of accuracy with the current technology, despite the fact that they undergo the same training process as normal subjects~\cite{blankertz-sannelli-etal:10}. This problem is extremely limiting for possible future applications because it compromises the universality of BCI systems.
Over the past 10 years, the Riemann distance-based classification paradigm has shown interesting performances for BCI-EEG classification~\cite{barachant-bonnet-etal:10}.
The key idea behind this method is to map covariance matrices into an appropriate geometrical space: the space of Symmetric Positive Definite (SPD) matrices, which is actually a differentiable manifold with a natural Riemann structure~\cite{forstner-moonen:03}. It is therefore natural to try to extend this Riemannian approach with ideas from auto-regressive models in order to optimize the performance even for the most difficult subjects.
In order to create a new algorithm for the BCI-EEG classification, we must focus on the following basic characteristics: be computationally efficient, improve accuracy compared to the state of the art, keep improvements applicable to all possible BCI paradigms, do not require excessive time for training the hyper-parameters related to the model. So far, there have been several attempts to improve over the results obtained with the Riemann distance-based algorithm~\cite{barachant-bonnet-etal:11b}. However, these attempts, while showing superior performance, obtained such results by introducing additional problems, which requires complex optimization of hyper-parameters.
The goal of this work is to improve the performance of the classification algorithms, exploiting the nonlinear components of the EEG signal and combining this approach with Riemann distance-based classifiers. The idea is thus to push further the logic of the Riemann algorithm by defining an appropriate SPD matrix that maximizes the amount of information related to a particular task, contained in the EEG signal.
The AR model can be computed using the Yule-Walker equations, which involve a SPD matrix i.e. the augmented covariance matrix with lags. Thus, a fairly natural idea is to extend the standard Riemannian approach by using these augmented covariance matrices with lags.
This idea of using an augmented covariance matrix with delays was also recently introduced~\cite{sosulski-tangermann:22} where it was used in combination with a Linear Discriminant Analysis algorithm and applied on Event Related Potential datasets. To the authors' knowledge the approach of combing the augmented covariance with the Riemannian classification is completely a novelty.
This approach can also be seen from the point of view of dynamical systems: since the AR Yule-Walker matrix is a matrix of delayed covariance, we can extract the same matrix using the standard covariance matrix stemming from an embedding of the original system in a high dimensional space. Thus such a matrix incorporates the nonlinear properties of the EEG signal.
Hence, it is natural to connect our approach with the delay embedding theorem proposed by Takens~\cite{takens:81} in the context of non-linear dynamical systems.
Most EEG classification algorithms are based on the assumption that the signal can be described through a linear model. However, studies have shown that the EEG signal follows a nonlinear model~\cite{casdagli-iasemidis-etal:97} and because of this nonlinear component, the use of signal analysis techniques based on linearity assumptions could lose important characteristics. Only recently some classification algorithms are being proposed based on the use of quantities defined in the context of nonlinear systems theory such as correlation dimension, Lyapunov exponents, mutual information and the minimum embedding dimension~\cite{fang-chen-etal:15, hosseinifard-moradi-etal:13}. Such features, however, are extremely computationally demanding.
The basic idea of our approach is to embed the EEG data in a high dimensional space using the theory of non-linear dynamics, and then to classify the EEG signal using the Riemannian framework. In this sense, we are thus combining the two strengths of both approaches, the use of the nonlinear component of the signal and the performance of the Riemannian distance-based algorithm.
In order to validate the methods, we apply our approach both with a classification on the Riemann surface using the Minimum Distance to the Mean and another classification on the Tangent Space using Support Vector Machine. We will test our approach on several datasets and several subjects using the \href{http://moabb.neurotechx.com/docs/index.html}{MOABB} framework~\cite{jayaram-barachant:18}, with both within-session and cross-session evaluation.
The article is structured as follows: in section~\ref{sec:materials}, we first describe the theoretical approach that underlies the model, and then the datasets considered and the performed statistical analysis. In section~\ref{sec:results}, we lists the results obtained using within-session and cross-session evaluation. Finally, in section~\ref{sec:discussion}, we analyze the implications of the method and its current limitations. Section~\ref{sec:conclusion} summarizes the results of our study.
\section{Materials and Methods}
\label{sec:materials}
\subsection{BCI classification}
The EEG signal can be represented using a multivariate time-serie $\mathbf{X} \in \mathbb{R}^{d \times T}$ where $T$ is the number of sampled data point and $d$ is the number of electrodes.
This work is focused on motor imagery classification tasks, so for example we are interested in predicting whether a subject is thinking about moving the right hand or the left hand (see
Fig.~\ref{fig1:Figure_dataset_BCI}).
We segment the EEG datasets into different short-time windows or epochs corresponding to a single motor task. Each such epoch is labelled by the actual motor task achieved by the subject. So for example to classify right vs left hand, we will get some epochs associated with the left hand label and other with the right hand one. We apply a feature extraction on each epoch in order to create disjoint training and testing datasets. The training dataset is used to train a classification algorithm. After the training procedure, we use the classifier to predict the outcome on the testing dataset.
\begin{figure}[!ht]
\centering
\includegraphics[width=\linewidth]{Figure/carra1.png}
\caption{Example of an EEG dataset composed of 4 electrodes. For a motor imagery task for the classification between right and left hand. The experimental paradigm consists in asking the subject to imagine the movement of a body part (left or right hand in this case), at specific times instants marked with green lines. For each green line, an epoch of data (blue boxes) is collected and associated with its left/right hand label. A subset of these epochs forms the training dataset. Later when presented with a new epoch (not contained in the training dataset), we would like to be able to classify whether the subject is thinking about moving his right or the left hand.}
\label{fig1:Figure_dataset_BCI}
\end{figure}
\subsection{Riemann geometry}
Over the past 10 years, Riemannian distance-based classification paradigms have shown interesting performances for SPD matrix classification~\cite{barachant-bonnet-etal:10}. The key idea behind this method is to map the covariance matrix into an appropriate geometrical space. The space of SPD matrix is a differentiable manifold with a natural Riemann structure~\cite{forstner-moonen:03}.
The spaces of $n \times n$ real square
and real symmetric matrices are denoted the eigenvalues of by $M(n)$ and $S(n)$, respectively: $S(n) = \left\{\mathbf{S} \in M(n), \;\mathbf{S}^{T}=\mathbf{S}\right\}$. The space of SPD matrices is defined as $P(n)=\{\mathbf{P} \in S(n), \mathbf{P}>0\}$.
In this way, we can represent a matrix $\mathbf{P} \in S(n)$ as a point on a Riemann surface of dimension $n(n+1)/2$.
Since the space of SPD matrix is a manifold of non zero curvature, we cannot use the concepts of Euclidean geometry since they are not reliable and have instead to rely on Riemannian geometry. It is possible to define a distance between two SPD matrix $\mathbf{P}_1$ and $\mathbf{P}_2$ in $P(n)$ as the length of the geodesic that connects $\mathbf{P}_1$ and $\mathbf{P}_2$ on the Riemann surface. In this paper, we use the affine-invariant metric~\cite{moakher:05}
\begin{equation}
\delta_{R}\left(\mathbf{P}_{1}, \mathbf{P}_{2}\right)=\left\|\log \left(\mathbf{P}_{1}^{-\frac{1}{2}} \mathbf{P}_{2} \mathbf{P}_{1}^{-\frac{1}{2}}\right)\right\|_{F}=\left[\sum_{i=1}^{n} \log ^{2} \lambda_{i}\right]^{1 / 2}
\label{Riemann metric}
\end{equation}
where $\|\cdot\|_{F}$ is the Frobenius norm, $Log()$ is the logarithm of a matrix and $\lambda_i$ are the eigenvalues of $\mathbf{P}_1^{-\frac{1}{2}}\mathbf{P}_2\mathbf{P}_1^{-\frac{1}{2}}$.
The choice of the metric is not unique but we choose that metric because it possesses relevant properties for BCI applications: invariance under reordering, invariance under congruent transformation and invariance under inversion~\cite{congedo-barachant-etal:17}.
To define the mean of $m$ SPD matrices $(\mathbf{P}_1, ..., \mathbf{P}_m)$, we use the concept of Fréchet mean~\cite{moakher:05}
\begin{equation}
\mathbf{\overline{P}} =\underset{\mathbf{P} \in P(n)}{\operatorname{argmin}} \sum_{i=1}^{m} \delta_{R}^{2}\left(\mathbf{P}, \mathbf{P}_{i}\right)
\end{equation}
$\mathbf{\overline{P}}$ is called the geometric mean in the Riemannian sense or the center of mass of $(\mathbf{P}_1, ..., \mathbf{P}_m)$. Note that, for $m>2$, no closed-form expression is know, so we need to employ an iterative algorithm~\cite{pennec-fillard-etal:04}. Due to the properties of Eq.~(\ref{Riemann metric}), the geometric mean inherits the properties of congruence invariance~\cite{congedo-barachant-etal:17}. The geometric mean is also robust, both with respect to outliers and for cross-session and across-subject applications.
For every point $\mathbf{P}_i \in P(n)$, in a complete Riemann space, we can define a point $\mathbf{S}_i \in S(n)$ in the tangent space $\mathbf{T}_P$ to the Riemann surface at point $\mathbf{P} \in P(n)$. The tangent space has zero curvature by definition and allows us to use standard machine learning algorithms and other classical tools. Mappings from the Riemann surface to the tangent space and from the tangent space to the Riemann surface, are provided respectively by the Riemannian Exp and Log maps~\cite{moakher:05} (see Fig.~\ref{fig:figure_Riemann}):
\begin{equation}
\operatorname{Exp}_{\mathbf{P}}\left(\mathbf{S}_{i}\right) = \mathbf{P}^{1 / 2} \operatorname{Exp}\left(\mathbf{P}^{-1 / 2} \mathbf{S}_{i} \mathbf{P}^{-1 / 2}\right) \mathbf{P}^{1 / 2}\\
\end{equation}
\begin{equation} \operatorname{Log}_{\mathbf{P}}\left(\mathbf{P}_{i}\right)= \mathbf{P}^{1 / 2} \operatorname{Log}\left(\mathbf{P}^{-1 / 2} \mathbf{P}_{i} \mathbf{P}^{-1 / 2}\right) \mathbf{P}^{1 / 2}
\end{equation}
\begin{figure}[!ht]
\centering
\includegraphics[width=0.8\linewidth]{Figure/carra2.png}
\caption{A Riemann manifold and the maps from/to the tangent plane.}
\label{fig:figure_Riemann}
\end{figure}
In the context of a Riemann distance based classification algorithm, we estimate a spatial covariance matrix for each epoch with the standard approach of the spatial sample covariance estimator
\begin{equation}
\operatorname{Cov}(\mathbf{X})=\frac{1}{Time-1} \sum_{i=1}^{Time}\mathbf{X}_{i}\mathbf{X}_{i}^{\textit{T}} \;
\end{equation}
where $T$ is the transpose operator. This is not the only option for estimating the covariance. We could have used other estimators, but this one has the advantage of being unbiased when the number of electrodes is much smaller than the temporal instants contained in an epoch.
As the covariance matrix belongs to the SPD space, it is possible to classify the different mental states using the Riemannian framework.
Note that the classification can be perform either on the Riemann surface, using algorithms specifically defined on the Riemann manifold as Minimum Distance to the Mean (MDM), or by moving points to tangent space and using standard classification algorithms such as Support Vector Machine (SVM) or Logistic Regression~\cite{barachant-bonnet-etal:11b}.
\subsection{Augmented covariance}
This section discusses the autoregressive model and the motivation to create the augmented covariance method.
Our approach consists in considering the recorded EEG signal as a realization of a multivariate random process whose law is unknown. With certain assumptions, we can assure that this random process follows an autoregressive model.
EEG time series are not stationary: the signal properties change over time according to the underlying mental processes, but for sufficiently short time windows where the mental task does not vary, we can consider the signal as weakly stationary which means that $\mathbb{E}\left(\widetilde{\mathbf{X}}\right)$ and $\mathbb{E}\left(\widetilde{\mathbf{X}_{t+i}}, \widetilde{\mathbf{X}_t}^T\right)$ are independent of time $t$ in each window $i$.
Under the assumption of weak stationary, we can model the signal as a random process that follows an autoregressive model: this means that future values are expressed as a function of past ones plus a random component called innovation. Thus, we can model the multivariate EEG signal using an autoregressive model of order $p$~\cite{lutkepohl:05}
\begin{equation}
\mathbf{X}_{t}=\sum_{i=1}^{p} \mathbf{A}_{i} \mathbf{X}_{t-i\tau}+\bm{\varepsilon}_{\mathbf{t}}
\label{Autoregressive_eq}
\end{equation}
where $\mathbf{X}_t \in \mathbb{R}^{d \times 1}$ is the EEG signal at time $t$, $\mathbf{A}_i \in \mathbb{R}^{d \times d}$ are the autoregressive coefficients , $\tau$ is the lag and $\bm{\varepsilon}_t \in \mathbb{R}^{d \times 1}$ is the innovation component.
The order $p$ of the process, the delay as well as the autoregressive coefficients $\mathbf{A}_i$ are unknowns and must be estimated from the signal. The classic approach to estimate the autoregressive coefficients is using the Yule-Walker equation.
In order to derive it, we simply post multiply Equation (\ref{Autoregressive_eq}) by $\mathbf{X}_{t-k}$ and compute the expectation value. Denoting by $\mathbf{\Gamma}(i) = \mathbb{E}(\mathbf{X}_t, \mathbf{X}_{t-k}^T)\in \mathbb{R}^{d \times d}$ the matrix of auto-covariance with lag $i$ and by $\mathbf{U}$ the auto-covariance matrix of the innovation considered as independent from past values, we get the following equations for $i \in [1, p]$
\begin{equation}
\left\{\begin{array}{l}
\mathbf{\Gamma}(\mathbf{0})=\sum_{k=1}^{p} \mathbf{A}_{k} \mathbf{\Gamma}(-k\tau)+\mathbf{U} \; \; \; \text { for } i=0 \\
\mathbf{\Gamma}(\mathbf{i}) \; =\sum_{k=1}^{p} \mathbf{A}_{k} \mathbf{\Gamma}(i-k\tau) \; \; \; \; \; \; \; \; \text { for } i \neq 0
\end{array}\right.
\label{YW_eq}
\end{equation}
The second Equation (\ref{YW_eq}) in matrix notation yields
\begin{equation}
\left[\begin{array}{cccc}
\mathbf{\Gamma}_{0} & \mathbf{\Gamma}_{-1} & \mathbf{\Gamma}_{-2} & \cdots \\
\mathbf{\Gamma}_{1} & \mathbf{\Gamma}_{0} & \mathbf{\Gamma}_{-1} & \cdots \\
\mathbf{\Gamma}_{2} & \mathbf{\Gamma}_{1} & \mathbf{\Gamma}_{0} & \cdots \\
\vdots & \vdots & \vdots & \ddots \\
\mathbf{\Gamma}_{p-1} & \mathbf{\Gamma}_{p-2} & \mathbf{\Gamma}_{p-3} & \cdots
\end{array}\right]
\left[\begin{array}{c}
\mathbf{A}_{1} \\
\mathbf{A}_{2} \\
\mathbf{A}_{3} \\
\vdots \\
\mathbf{A}_{p}
\end{array}\right]
=
\left[\begin{array}{c}
\mathbf{\Gamma}_{1} \\
\mathbf{\Gamma}_{2} \\
\mathbf{\Gamma}_{3} \\
\vdots \\
\mathbf{\Gamma}_{p}
\end{array}\right]
\end{equation}
The autoregressive coefficients $\mathbf{A}_i$ are solutions of a linear system. We define the augmented covariance Matrix $\mathbf{\Gamma}_{aug}$ as
\begin{equation}
\mathbf{\Gamma}_{Aug} = \left[\begin{array}{cccc}
\mathbf{\Gamma}_{0} & \mathbf{\Gamma}_{-1} & \mathbf{\Gamma}_{-2} & \cdots \\
\mathbf{\Gamma}_{1} & \mathbf{\Gamma}_{0} & \mathbf{\Gamma}_{-1} & \cdots \\
\mathbf{\Gamma}_{2} & \mathbf{\Gamma}_{1} & \mathbf{\Gamma}_{0} & \cdots \\
\vdots & \vdots & \vdots & \ddots \\
\mathbf{\Gamma}_{p-1} & \mathbf{\Gamma}_{p-2} & \mathbf{\Gamma}_{p-3} & \cdots
\end{array}\right]
\end{equation}
$\mathbf{\Gamma}_{aug}$ is symmetric by construction since $\mathbf{\Gamma}_{i} = \mathbf{\Gamma}_{-i}$. A fairly natural idea is therefore to use these $\mathbf{\Gamma}_{aug}$ matrices for classification algorithms using the Riemannian framework.
$\mathbf{\Gamma}_{aug}$ combines spatial covariance with some temporal information on the signal.
It is equivalent to consider an augmented dataset by embedding our EEG dataset in a dimension equal to $d \times p$, with a fixed delay $\tau$ (Fig. \ref{Figure_dataset}).
Segmenting this new augmented dataset in epochs and computing the epoch covariance matrices results in exactly the same $\mathbf{\Gamma}_{aug}$ matrix.
\begin{figure*}[!ht]
\centering
\subfloat[]{%
\includegraphics[width=0.5\linewidth]{Figure/carra3a.png}}
\hfill
\subfloat[]{%
\includegraphics[width=0.5\linewidth]{Figure/carra3b.png}}
\caption{(a) Consider the EEG signal with 4 channels and an epoch (blue box), and create a new dataset by concatenating its values at time $t$ with those at time $t+\tau$.
(b) Result of the previous procedure at every point of the dataset. This is a higher dimensional dataset for a fixed delay $\tau$ and with dimension $d \times p$ (here $d=4$ and $p=2$).
The augmented covariance matrix of the original signal $\mathbf{\Gamma}_{aug}$ is exactly the standard covariance matrix of this concatenated dataset.
}
\label{Figure_dataset}
\end{figure*}
The sample covariance matrix is an effcient and unbiased estimator of the real covariance matrix~\cite{hastie-tibshirani-etal:09}.
In the case of BCI applications, we are in a Finite Observation Large-Dimensional Limit condition (FOLDL)~\cite{bartz:16}. In the case of $\mathbf{\Gamma}_{aug}$ the number of time sample $T$ is kept fixed while the dimensionality tends to be multiplied by the embedding dimension. The performance of the sample covariance is no more reliable and the estimator is no longer consistent.
A reliable estimator is obtained using a shrinkage estimator defined as
\begin{equation}
\widehat{\mathbf{C}}_{shrink} = (1-\lambda)\widehat{\mathbf{C}}_{sample} + \lambda \frac{Tr\left(\widehat{\mathbf{C}}_{sample}\right)}{d} I
\end{equation}
Specifically, we are going to use the Shrinkage estimator introduced by Ledoit-Wolf~\cite{ledoit-wolf:04}, who developed an analytical formula to find the parameter $\lambda$ that minimizes the mean squared error between the estimated and the real covariance matrices.
\subsection{Non Linear Dynamical approach}
The formulation of the problem using the augmented dataset shows a natural connection with the delay-embedding theorem attributed to Takens~\cite{takens:81} in the context of non-linear dynamical systems.
Most EEG classification algorithms are based on the assumption that the signal is describable through a linear theory. However, recent studies have proven that the EEG signal follows a nonlinear model~\cite{casdagli-iasemidis-etal:97}. Because of this nonlinear component, the use of signal analysis techniques based on linearity assumptions could lose important characteristics.
Recently some algorithms have been proposed that use quantities defined in the context of nonlinear systems theory as classification features, however, these quantities are extremely time consuming.
Let us now try to understand the idea behind phase space reconstruction based on Takens's theorem. Usually what we observe in an experiment is not a phase space object but a time series, most likely only a sequence of scalar measurements, so that not all the dynamic variables involved in the dynamics of the system under study are made available through the measurement process. So in most cases a time series can be seen as the values taken by the observed variables of a partially observable dynamical system. It is obvious that even with a precise knowledge of the measurement process it may be impossible to reconstruct the state space of the original system from the data. Fortunately, a reconstruction of the original phase space is not really necessary for data analysis and sometimes
not even desirable. It is sufficient to construct a new space that is dynamically equivalent to the original one. The process that we have just enunciated is very well summarized by Figure~\ref{fig:fig1}.
\begin{figure}[!ht]
\centering
\includegraphics[width=\linewidth]{Figure/carra4.png}
\caption{Illustration of the concept of the Delay-Embedding theorem. Reproduced with permission from Ana González-Marcos~\cite{pedro-carracedo-fuentes-jimenez-etal:20}}
\label{fig:fig1}
\end{figure}
Considering that a process of measurement create a time series ${s(n)}$.
According to Takens’s theorem, the geometric structure of the multi variable dynamics of the system can be unfolded from the observable $s(n)$ in a $D$-dimensional space constructed from the delay vector
\begin{equation}
\textbf{s}_E(n) = [s(n), s(n - \tau), ..., s(n - (D - 1)\tau)]^T
\end{equation}
where $\tau$ is a positive integer called the embedding delay and $D$ embedding dimension. So $\textbf{s}_E(n) \in \mathbb{R}^{D}$ is an embedding of the original phase space.
As seen previously, the augmented covariance matrix is equivalent to using a standard covariance matrix on an embedding the EEG data in a high dimensional space. The approach is thus related to the theory of non-linear dynamics, but then, instead of trying to identify the dynamics's parameters, we classify the mental state using the Riemann framework. In this sense, the two strengths of both approaches are thus combined: the use of the nonlinear component of the signal and the performance of the Riemann distance-based algorithms. Our approach turns out to be a natural extension of the Riemann distance-based classification that considers SPD matrices that contain a greatest amount of information extracted from the signal for dynamical systems theory. Thus the classification method based on the Riemann framework becomes even more effective by accounting for some non-linearities of the signal measured through the embedding of the data.
\subsection{Datasets Considered}
To test the performance of our method, we used datasets implemented in the MOABB framework, which are open-access.
We consider five motor imagery BCI datasets consisting of several subjects for each dataset and several sessions for each subject.
Table~\ref{table:dataset} contains all the details about the considered datasets.
\begin{table}[!ht]
\resizebox{\linewidth}{!}{\begin{tabular}{c|c|c|c|c|c|c|c}
\text { Dataset } & \text { subjects } & \text { channels } & \text {sampling rate } & \text { sessions } & \text { tasks } & \text { trials/class } & \text{Epoch (s)} \\
\hline \text { Zhou2016~\cite{ zhou-wu-etal:16}} & 3 & 14 & 250 Hz & 3 & 3 & 160 & [0, 5] \\
\hline \text {BNCI2014001~\cite{tangermann-muller-etal:12}} & 9 & 22 & 250 Hz & 2 & 4 & 144 & [2, 6] \\
\hline \text {BNCI2015001~\cite{faller-vidaurre-etal:12}} & 12 & 13 & 512 Hz & 1 & 2 & 200 & [0, 5] \\
\hline \text {BNCI2014002~\cite{steyrl-scherer-etal:16}} & 14 & 15 & 512 Hz & 5 & 2 & 80 & [3, 8] \\
\hline \text {BNCI2014004~\cite{leeb-lee-etal:07}} & 9 & 3 & 250 Hz & 1 & 2 & 360 & [3, 7.5]\\
\hline
\end{tabular}}
\caption{Dataset considered during this study}
\label{table:dataset}
\end{table}
On all datasets, we apply a standard band-pass filter with range [8; 35] Hz for the motor imagery task. We consider epochs with lengths equal to the duration of task conditions which varies with the datasets under consideration. All classes are balanced in these datasets.
\subsection{Parameter Estimation}
Our model depends on two hyper-parameters, the order of the autoregressive model (equivalently the embedding dimension $D$) and the delay $\tau$. In order to compute these two parameters for every dataset and every subject, we developed two different strategies: one based on the grid search algorithm and another one based on the concept of non-linear dynamical systems. We select hyper-parameters for each subject in the case of performance evaluation using the within-session and cross-session evaluation methodology.
\subsubsection{Grid Search}
In order to find the hyper-parameters, we allow the grid search on two parameters to run on the domain defined by: $D \in [1, 10]$ and $\tau \in [1, 10]$.
The grid search are performed using the exact same procedure used for the evaluation procedure as we will outline later. Note that Grid-Search should always provide the best solution in the explored domain (multiple minima are possible).
\subsubsection{Non Linear Dynamical approach}
The parameters $D$ and $\tau$ can also be estimated using the concepts of non-linear dynamical systems. There are several algorithms for estimating optimal parameters in noisy conditions that can be grouped in two categories: traditional and unified approaches. Both approaches were implemented using the \href{https://juliadynamics.github.io/DynamicalSystems.jl/dev/}{DynamicalSystem.jl} library~\cite{datseris:18}.
\paragraph{Traditional approach}
The traditional approach tries to find the best value of the time delay $\tau$ and then an optimal embedding dimension $D$ separately.
Our approach is based on computing the Average Mutual Information (AMI)~\cite{fraser-swinney:86} and the number of neighbours using Cao's algorithm~\cite{cao:97}.
The embedding theorem places no restrictions on the choice of time delay in the reconstruction process.
In theory, with an unlimited number of measurements without noise, any delay is equally valid, except certain multiples of the precise period of a periodic signal. In practice, the amount of data is finite, which means that some constraint is needed to identify the best value of time delay $\tau$. The AMI algorithm is using the position of the first minimum of the mutual information as the optimal value of $\tau$.
There is no rule of thumb to impose a minimum reconstruction dimension $D$ but, among all possible techniques, the False Nearest Neighbors (FNN) with Cao’s modification stands out. This algorithm is based on the consideration that in a reconstruction space of very low dimension, two points appear to be closer to each other than they actually are. Thus, two points are considered as real neighbors if their distance remains constant as the reconstruction dimension increases. The embedding dimension is selected as the value where the FNN saturates around 1.
Since that algorithms were created for dealing with univariate data we accumulate the results of each channel and epoch and we select $\tau$ as the first minimum of the overall Mutual Information. With analogous consideration we compute the embedding dimension $D$ is the value for which the overall false nearest neighbour saturates around 1.
\paragraph{Unified approach}
The unified approach finds at the same time an optimal combination of $\tau$ and $D$. For this approach, we use the MDOP algorithm~\cite{nichkawde:13}.
The MDOP algorithm works iteratively by finding the best delay and embedding dimensions together. The algorithm starts with the current dataset and adds a lagged version of that dataset to it by finding the correct value of $\tau$ such that the redundancy between coordinates is minimized, i.e. by maximizing the beta statistics~\cite{nichkawde:13}. After each embedding cycle the FNN-statistic~\cite{kennel-brown-etal:92} is being checked and as soon as this statistic drops below a threshold, the algorithm terminates.
It should be noted that this algorithm produces different values of $\tau$ for each embedding cycle, so we decide to select the optimal value of $\tau$ as an average of these values, while we select $D$ as the number of cycles.
\subsection{Pipeline}
We intend to evaluate how the augmented covariance method (ACM) as a general technique can increase the performance in different settings. In particular, we consider several classification methods on the Riemann surface and on the tangent space as shown in Table~\ref{table:pipeline}.
\begin{table*}[!ht]
\resizebox{\linewidth}{!}{
\begin{tabular}{c|c|*{3}{c}}
\hline
\textbf{Surface} & \textbf{Standard algorithm} & \multicolumn{3}{c}{\bfseries Augmented algorithm} \\
\hline
& & \multicolumn{1}{c}{\bfseries Grid Search} & \multicolumn{1}{c}{\bfseries Traditional Approach} & \multicolumn{1}{c}{\bfseries Unified Approach} \\
\hline
Riemann Surface & MDM & ACM+MDM & ACM+MDM AMI aFNN & ACM+MDM MDOP \\
Tangent Space & TANG+SVM & ACM+TANG+SVM & ACM+TANG+SVM AMI aFNN & ACM+TANG+SVM MDOP \\
\hline
\end{tabular}
}
\caption{Considered pipelines with classification both on Riemann surface and on Tangent Space.}
\label{table:pipeline}
\end{table*}
We compare our best method "ACM+TANG+SVM" (classification on tangent space using a SVM with grid search), against several algorithms in the literature of BCI.
\begin{enumerate}
\item "CSP+LDA", a combination of the Common spatial pattern (CSP) algorithm followed by a classification performed on a shrinkage Linear Discriminant Analysis (LDA)~\cite{lotte-guan:10b}.
\item "FgMDM", a classification method by Minimum Distance to the Mean after having applied a geodesic filtering~\cite{yger-berar-etal:16}.
\item "COV+EN", a classification method in the tangent space using an Elastic Network as classifier~\cite{corsi-chevallier-etal:22}.
\end{enumerate}
For classification scores, we use different model validation techniques depending on the considered paradigm: for within-session evaluations (WS), we used a 5-fold cross-validation while for cross-session evaluations (CS), we used a leave-one-session-out paradigm.
All the hyper parameters of the classifiers used in this study are optimized with grid search. Table~\ref{table:pipeline_parameter} summarizes the domains over which these grid searches are performed.
\begin{table}[!ht]
\centering
\begin{tabular}{c|c|c}
\hline
\textbf{Pipeline} & \textbf{Parameter} & \textbf{Value} \\ \hline
"COV+EN" & l1 ratio & [0.15, 0.30, 0.45, 0.60, 0.75] \\ \hline
"TANG+SVM" & C & [0.5, 1, 1.5] \\
& Kernel & ["linear", "rbf"] \\ \hline
"CSP+LDA" & nfilter & [1, 2, 3, 4, 5, 6, 7, 8] \\ \hline
"ACM+TANG+SVM" & C & [0.5, 1, 1.5] \\
& Kernel & ["linear", "rbf"] \\
& Order & [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] \\
& Lag & [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] \\\hline
"ACM+MDM" & Order & [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] \\
& Lag & [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] \\\hline
\end{tabular}
\caption{Parameter considered for each pipelines}
\label{table:pipeline_parameter}
\end{table}
\subsection{Statistical Analysis}
In order to validate the best pipeline from a statistical point of view, we use the instrument provided by the MOABB framework. This algorithm use a mixture of permutation and non-parametric tests in order to keep the algorithm fast.
The MOABB framework uses a one-tailed permutation-based paired t-test~\cite{student:08} for datasets with less than 20 subjects, or a Wilcoxon signed-rank test~\cite{wilcoxon:92} otherwise.
This statistical test is used to generate a p-value that compares two pipelines for each pair of pipelines. Then, the p-values are combined using Stouffer’s method~\cite{stouffer-suchman-etal:49} in order to get a final p-value for each hypothesis.
In order to prevent the problem of false positive, we apply the Bonferroni correction~\cite{bonferroni:36}.
In this way, we can validate the results using several subjects and several datasets.
The score are obtained using the Area Under (AUC) Receiver Operating Characteristic (ROC) curve. AUC ranges in value from 0 to 1 and a higher AUC value is a better classifier. In case of a multi-class classification the metric used is the accuracy.
\section{Results}
\label{sec:results}
In this section, we report the results of the augmented covariance method over the classification on both the Riemann surface and the Tangent Space. To validate the robustness and validity of our approach, we test the algorithm on different datasets, subjects and tasks using the MOABB framework. By definition Grid Search will always give the best solution for the Augmented approaches provided the optimum is in the search domain. Thus, the comparison between Grid-Search and Non Linear Dynamics approaches will be always in favor of the former because we chose a Gird-Search domain that is large enough.
\subsection{Right hand vs Left hand}
We consider 3 different datasets: BNCI2014001, BNCI2014004 and Zhou2016 to classify a right vs left hand task classification using within-session and cross-session evaluation procedures.
\subsubsection{Riemann surface classification}
All methods using ACM show an improvement with respect to the standard MDM algorithm as shown in Table~\ref{table:MDM-rhlh-whithinsession}. Using ACM and selecting hyper parameters with grid search gives performance improvements in the range 3\%-7\%, while selecting those with the traditional and unified approaches give close results (but with decreases of AUC of up to 3\% for the traditional approach and 5\% for the unified one). These tendencies are true in both the within-session (WS) and cross-session (CS) frameworks. Figures~\ref{fig:MDM-rhlh-whithinsession} and~\ref{fig:MDM-rhlh-crosssession} provide a detailed statistical study of the significance of these results.
\begin{table}[!ht]
\resizebox{\linewidth}{!}{\begin{tabular}{c|c|c|c|c|c}
\text { Dataset } & Eval & \text {MDM} & \text {ACM+Grid Search} & \text {ACM+Traditional} & \text {ACM+Unified} \\
\hline \text {BNCI2014001} & WS & $0.84 \pm 0.14$ & \textbf{0.91} $\pm$ \textbf{0.11} & 0.89 $\pm$ 0.12 & $0.86 \pm 0.14$ \\
\hline \text {BNCI2014004} & WS & $0.78 \pm 0.16$ & \textbf{0.83} $\pm$ \textbf{0.14} & $0.82 \pm 0.15$ & $0.81 \pm 0.16$ \\
\hline \text { Zhou2016} & WS & $0.89 \pm 0.08$ & \textbf{0.93} $\pm$ \textbf{0.07} & $0.90 \pm 0.07$ & $0.91 \pm 0.08$ \\ \hline
\hline \text {BNCI2014001} & CS & $0.83 \pm 0.15$ & \textbf{0.91} $\pm$ \textbf{0.11} & $0.88 \pm 0.13$ & $0.86 \pm 0.13$ \\
\hline \text {BNCI2014004} & CS & $0.79 \pm 0.15$ & \textbf{0.83} $\pm$ \textbf{0.14} & \textbf{0.83} $\pm$ \textbf{0.14} & $0.81 \pm 0.15$ \\
\hline \text {Zhou2016} & CS & $0.92 \pm 0.05$ & \textbf{0.95} $\pm$ \textbf{0.04} & $0.93 \pm 0.04$ & $0.93 \pm 0.04$ \\
\hline
\end{tabular}}
\caption{Performance (AUC) of Right hand vs Left hand using MDM based algorithms.}
\label{table:MDM-rhlh-whithinsession}
\end{table}
\subsubsection{Tangent space classification}
The tangent space classification with SVM is in general more effective than with the Riemann surface classification approaches as shown in Table~\ref{table:TANG+SVM-rhlh-whithinsession}. This is true for the baseline method as well as for the ACM ones. The ACM based methods with parameter estimation based on dynamical system theory shows results comparable to those obtained with the standard covariance matrix (AUC changes from -1\% to +2\%). Yet, the use of the ACM with grid search shows some notable improvements with respect to all other methods which behave similarly on this dataset (3-7\% depending on the dataset). Again, these improvements occur similarly for both the WS and CS frameworks. Figures~\ref{fig:TANG+SVM-rhlh-whithinsession} and~\ref{fig:TANG+SVM-rhlh-crosssession} provide a detailed study of the statistical significance of these results.
\begin{table}[!ht]
\resizebox{\linewidth}{!}{\begin{tabular}{c|c|c|c|c|c}
\text {Dataset} & Eval & \text {TANG+SVM} & \text {ACM+Grid Search} & \text {ACM+Traditional} & \text {ACM+Unified } \\
\hline \text {BNCI2014001} & WS & $0.89 \pm 0.11$ & \textbf{0.95} $\pm$ \textbf{0.07} & $0.89 \pm 0.12$ & $0.88 \pm 0.13$ \\
\hline \text {BNCI2014004} & WS & $0.81 \pm 0.15$ & \textbf{0.88} $\pm$ \textbf{0.12} & $0.81 \pm 0.16$ & $0.81 \pm 0.15$ \\
\hline \text {Zhou2016} & WS & $0.93 \pm 0.07$ & \textbf{0.96} $\pm$ \textbf{0.05} & $0.94 \pm 0.06$ & $0.93 \pm 0.07$ \\ \hline
\hline \text {BNCI2014001} & CS & $0.86 \pm 0.13$ & \textbf{0.93} $\pm$ \textbf{0.09} & $0.88 \pm 0.12$ & $0.88 \pm 0.12$ \\
\hline \text {BNCI2014004} & CS & $0.81 \pm 0.14$ & \textbf{0.85} $\pm$ \textbf{0.14} & $0.80 \pm 0.16$ & $0.81 \pm 0.15$ \\
\hline \text {Zhou2016} & CS & $0.92 \pm 0.07$ & \textbf{0.95} $\pm$ \textbf{0.04} & $0.93 \pm 0.05$ & $0.93 \pm 0.06$ \\
\hline
\end{tabular}}
\caption{Performance (AUC) of Right hand vs Left hand using TANG+SVM based algorithm.}
\label{table:TANG+SVM-rhlh-whithinsession}
\end{table}
\subsubsection{State of the Art} Our best approach (ACM with TANG+SVM classification and hyper-parameters found with grid search) is compared to advanced state of the art methods (usually showing better results than the baseline method) in Table~\ref{table:TANG+SVM-rhlh-whithinsession-stateart}. It brings a notable improvements over all these methods with an average improvement of AUC by 2-9\% and also a significant decrease in the standard deviation of these values meaning that the results are more consistent across subjects. A detailed study of the statistical significance of these results is provided in Figures~\ref{fig:TANG+SVM-rhlh-whithinsession-stateart} and~\ref{fig:TANG+SVM-rhlh-crosssession-stateart}.
\begin{table}[!ht]
\resizebox{\linewidth}{!}{\begin{tabular}{c|c|c|c|c|c}
\text { Dataset } & Eval & \text {CSP+LDA} & \text {ACM+TANG+SVM(Grid Search)} & \text {COV+EN} & \text {FgMDM} \\
\hline \text {BNCI2014001} & WS & $0.86 \pm 0.13$ & \textbf{0.95} $\pm$ \textbf{0.07} & $0.89 \pm 0.11$ & $0.88 \pm 0.11$ \\
\hline \text {BNCI2014004} & WS & $0.80 \pm 0.15$ & \textbf{0.88} $\pm$ \textbf{0.12} & $0.80 \pm 0.15$ & $0.79 \pm 0.16$ \\
\hline \text {Zhou2016} & WS & $0.93 \pm 0.08$ & \textbf{0.96} $\pm$ \textbf{0.05} & $0.94 \pm 0.07$ & $0.91 \pm 0.08$ \\ \hline
\hline \text {BNCI2014001} & CS & $0.86 \pm 0.14$ & \textbf{0.93} $\pm$ \textbf{0.09} & $0.87 \pm 0.13$ & $0.85 \pm 0.14$ \\
\hline \text {BNCI2014004} & CS & $0.81 \pm 0.14$ & \textbf{0.85} $\pm$ \textbf{0.14} & $0.81 \pm 0.14$ & $0.80 \pm 0.14$ \\
\hline \text {Zhou2016} & CS & $0.93 \pm 0.07$ & \textbf{0.95} $\pm$ \textbf{0.04} & $0.93 \pm 0.07$ & $0.90 \pm 0.09$ \\
\hline
\end{tabular}}
\caption{Performance (AUC) of Right hand vs Left hand using ACM+TANG+SVM algorithm against the state of the art.}
\label{table:TANG+SVM-rhlh-whithinsession-stateart}
\end{table}
\subsection{Right hand vs Feet}
This classification task was performed on 4 different datasets: BNCI2014001, BNCI2014002, BNCI2015001 and Zhou2016 to classify a right hand vs feet task classification using a within-session and cross-session evaluation procedure.
\subsubsection{Riemann surface classification}
All methods using ACM show an improvement with respect to the standard MDM algorithm as shown in Table~\ref{table:MDM-rf-whithinsession}. The best performance is obtained with using ACM and selecting hyper parameters with grid search (3-6\% improvements in AUC). Selecting those obtained with the traditional approach gives close results (with decrease of performance of up-to 3\%). The unified approach is usually worse than the traditional one. As before, the tendency is similar for both WS and CS frameworks.
Figures~\ref{fig:MDM-rf-whithinsession} and~\ref{fig:MDM-rf-crosssession} show a detailed study of the statistical significance.
\begin{table}[!ht]
\resizebox{\linewidth}{!}{\begin{tabular}{c|c|c|c|c|c}
\text {Dataset} & Eval & \text {MDM} & \text {ACM+Grid Search} & \text {ACM+Traditional} & \text {ACM+Unified} \\
\hline \text {BNCI2014001} & WS & $0.91 \pm 0.10$ & \textbf{0.96} $\pm$ \textbf{0.05} & $0.95 \pm 0.06$ & $0.93 \pm 0.10$ \\
\hline \text {BNCI2014002} & WS & $0.77 \pm 0.15$ & \textbf{0.83} $\pm$ \textbf{0.15} & $0.81 \pm 0.15$ & $0.78 \pm 0.17$ \\
\hline \text {BNCI2015001} & WS & $0.86 \pm 0.13$ & \textbf{0.91} $\pm$ \textbf{0.11} & 0.90 $\pm$ 0.11 & $0.89 \pm 0.12$ \\
\hline \text {Zhou2016} & WS & $0.92 \pm 0.05$ & \textbf{0.96} $\pm$ \textbf{0.04} & $0.93 \pm 0.05$ & $0.94 \pm 0.05$ \\ \hline
\hline \text {BNCI2014001} & CS & $0.90 \pm 0.12$ & \textbf{0.95} $\pm$ \textbf{0.06} & $0.93 \pm 0.07$ & $0.92 \pm 0.10$ \\
\hline \text {BNCI2015001} & CS & $0.87 \pm 0.12$ & \textbf{0.91} $\pm$ \textbf{0.09} & \textbf{0.91} $\pm$ \textbf{0.10} & $0.89 \pm 0.11$ \\
\hline \text {Zhou2016} & CS & $0.93 \pm 0.06$ & \textbf{0.96} $\pm$ \textbf{0.04} & $0.95 \pm 0.05$ & $0.95 \pm 0.05$ \\
\hline
\end{tabular}}
\caption{Performance (AUC) of Right hand vs Feet using MDM based algorithms.}
\label{table:MDM-rf-whithinsession}
\end{table}
\subsubsection{Tangent space classification}
As in the Left vs Right hand case, the tangent space classification with SVM is in general more effective than with the Riemann surface classification approaches as shown in Table~\ref{table:TANG+SVM-rf-whithinsession}. The ACM based methods with parameter estimation based on dynamical system theory shows comparable results to the standard covariance matrix (in one dataset, performance decreases slightly). Yet, the use of the ACM with grid search shows some notable improvements (1-4\%) with respect to all other methods which behave similarly on these datasets, which is notable given the very high AUC values already obtained with the baseline method. Figures~\ref{fig:TANG+SVM-rf-whithinsession} and~\ref{fig:TANG+SVM-rf-crosssession} provide a detailed study of the statistical significance of these results.
\begin{table}[!ht]
\resizebox{\linewidth}{!}{\begin{tabular}{c|c|c|c|c|c}
\text {Dataset} & Eval & \text {TANG+SVM} & \text {ACM+Grid Search} & \text {ACM+Traditional} & \text {ACM+Unified} \\
\hline \text {BNCI2014001} & WS & $0.95 \pm 0.07$ & \textbf{0.98} $\pm$ \textbf{0.02} & $0.95 \pm 0.06$ & $0.95 \pm 0.07$ \\
\hline \text {BNCI2014002} & WS & $0.87 \pm 0.12$ & \textbf{0.91} $\pm$ \textbf{0.10} & $0.86 \pm 0.13$ & $0.85 \pm 0.15$ \\
\hline \text {BNCI2015001} & WS & $0.92 \pm 0.08$ & \textbf{0.95} $\pm$ \textbf{0.06} & \textbf{0.93} $\pm$ \textbf{0.09} & $0.92 \pm 0.09$ \\
\hline \text {Zhou2016} & WS & $0.97 \pm 0.03$ & \textbf{0.99} $\pm$ \textbf{0.01} & $0.97 \pm 0.02$ & $0.97 \pm 0.04$ \\ \hline
\hline \text {BNCI2014001} & CS & $0.94 \pm 0.07$ & \textbf{0.97} $\pm$ \textbf{0.04} & $0.94 \pm 0.07$ & $0.93 \pm 0.08$ \\
\hline \text {BNCI2015001} & CS & $0.90 \pm 0.10$ & \textbf{0.94} $\pm$ \textbf{0.07} & $0.92 \pm 0.08$ & $0.91 \pm 0.09$ \\
\hline \text {Zhou2016} & CS & $0.96 \pm 0.05$ & \textbf{0.99} $\pm$ \textbf{0.01} & $0.98 \pm 0.02$ & $0.98 \pm 0.03$ \\
\hline
\end{tabular}}
\caption{Performance (AUC) of Right hand vs Feet using TANG+SVM based algorithms.}
\label{table:TANG+SVM-rf-whithinsession}
\end{table}
\subsubsection{State of the Art}
Our best approach (ACM with TANG+SVM classification and hyper-parameters found with grid search) is compared to other state of the art in Table~\ref{table:TANG+SVM-rf-whithinsession-stateart}. It brings a notable improvement over all these methods. A detailed study of the statistical significance of these results is provided in Figures~\ref{fig:TANG+SVM-rf-whithinsession-stateart} and~\ref{fig:TANG+SVM-rf-crosssession-stateart}.
\begin{table}[!ht]
\resizebox{\linewidth}{!}{\begin{tabular}{c|c|c|c|c|c}
\text {Dataset} & Eval & \text {CSP+LDA} & \text {ACM+TANG+SVM(Grid Search)} & \text {COV+EN} & \text {FgMDM} \\
\hline \text {BNCI2014001} & WS & $0.93 \pm 0.10$ & \textbf{0.98} $\pm$ \textbf{0.02} & $0.95 \pm 0.06$ & $0.94 \pm 0.08$ \\
\hline \text {BNCI2014002} & WS & $0.86 \pm 0.12$ & \textbf{0.91} $\pm$ \textbf{0.10} & $0.87 \pm 0.12$ & $0.85 \pm 0.12$ \\
\hline \text {BNCI2015001} & WS & $0.90 \pm 0.10$ & \textbf{0.95} $\pm$ \textbf{0.06} & $0.92 \pm 0.08$ & $0.90 \pm 0.10$ \\
\hline \text {Zhou2016} & WS & $0.95 \pm 0.04$ & \textbf{0.99} $\pm$ \textbf{0.01} & $0.97 \pm 0.03$ & $0.96 \pm 0.03$ \\ \hline
\hline \text {BNCI2014001} & CS & $0.90 \pm 0.12$ & \textbf{0.97} $\pm$ \textbf{0.05} & $0.94 \pm 0.07$ & $0.93 \pm 0.08$ \\
\hline \text {BNCI2015001} & CS & $0.89 \pm 0.11$ & \textbf{0.94} $\pm$ \textbf{0.07} & $0.91 \pm 0.09$ & $0.90 \pm 0.10$ \\
\hline \text {Zhou2016} & CS & $0.95 \pm 0.05$ & \textbf{0.99} $\pm$ \textbf{0.01} & $0.96 \pm 0.04$ & $0.95 \pm 0.06$ \\
\hline
\end{tabular}}
\caption{Performance (AUC) of Right hand vs Feet using ACM+TANG+SVM algorithm against the state of the art.}
\label{table:TANG+SVM-rf-whithinsession-stateart}
\end{table}
\subsection{Right hand vs Left hand vs Feet}
In this case, we use 2 different datasets BNCI2014001 and Zhou2016 to classify a right vs left hand vs feet tasks using a within-session and cross-session evaluation procedure.
\subsubsection{Riemann surface classification}
In all cases, methods using ACM show an improvement with respect to the standard MDM algorithm as shown in Table~\ref{table:MDM-3class-whithinsession}. Grid search parameter optimisation leads to 6-9\% improvements.
The improvements obtained with the other two methods (standard or unified) are lower 1-6\%. Again, in all cases,
the standard deviations are lower which indicate more consistent results across subjects. Figures~\ref{fig:MDM-3class-whithinsession} and~\ref{fig:MDM-3class-crosssession} show a detailed study of the statistical significance.
\begin{table}[!ht]
\resizebox{\linewidth}{!}{\begin{tabular}{c|c|c|c|c|c}
\text {Dataset} & Eval & \text {MDM} & \text {ACM+Grid Search} & \text {ACM+Traditional} & \text {ACM+Unified} \\
\hline \text {BNCI2014001} & WS & $0.72 \pm 0.15$ & \textbf{0.81} $\pm$ \textbf{0.11} & $0.78 \pm 0.13$ & $0.76 \pm 0.14$ \\
\hline \text {Zhou2016} & WS & $0.75 \pm 0.07$ & \textbf{0.81} $\pm$ \textbf{0.04} & $0.76 \pm 0.06$ & 0.79 $\pm$ 0.05 \\ \hline
\hline \text {BNCI2014001} & CS & $0.66 \pm 0.13$ & \textbf{0.75} $\pm$ \textbf{0.11} & $0.74 \pm 0.12$ & $0.70 \pm 0.12$ \\
\hline \text {Zhou2016} & CS & $0.70 \pm 0.09$ & \textbf{0.75} $\pm$ \textbf{0.06} & $0.72 \pm 0.09$ & 0.72 $\pm$ 0.09 \\
\hline
\end{tabular}}
\caption{Performance (Accuracy) of Right hand vs Left hand vs Feet using MDM based algorithms.}
\label{table:MDM-3class-whithinsession}
\end{table}
\subsubsection{Tangent space classification}
As in the previous results, the tangent space classification with SVM is more effective than with the Riemann surface classification approaches as shown in Table~\ref{table:TANG+SVM-3class-whithinsession}. In this case, the traditional method for computing the ACM hyper-parameters gives worse results than the baseline, failing to select a good set of parameters. The unified approach does a little bit better with improvements of 1-2\%. Using of the ACM with grid search gives the best results and shows some notable (7\%-8\%) improvements with respect to the baseline method.
Figures~\ref{fig:TANG+SVM-3class-whithinsession} and~\ref{fig:TANG+SVM-3class-crosssession} show a detailed study of the statistical significance.
\begin{table}[!ht]
\resizebox{\linewidth}{!}{\begin{tabular}{c|c|c|c|c|c}
\text {Dataset} & Eval & \text {TANG+SVM} & \text {ACM+Grid Search} & \text {ACM+Traditional} & \text {ACM+Unified} \\
\hline \text {BNCI2014001} & WS & $0.79 \pm 0.13$ & \textbf{0.87} $\pm$ \textbf{0.09} & $0.79 \pm 0.13$ & $0.80 \pm 0.14$ \\
\hline \text {Zhou2016} & WS & $0.84 \pm 0.05$ & \textbf{0.88} $\pm$ \textbf{0.03} & $0.83 \pm 0.03$ & $0.86 \pm 0.04$ \\ \hline
\hline \text {BNCI2014001} & CS & $0.69 \pm 0.13$ & \textbf{0.80} $\pm$ \textbf{0.10} & $0.74 \pm 0.12$ & $0.73 \pm 0.14$ \\
\hline \text {Zhou2016} & CS & $0.74 \pm 0.09$ & \textbf{0.81} $\pm$ \textbf{0.07} & $0.79 \pm 0.08$ & 0.76 $\pm$ 0.08 \\
\hline
\end{tabular}}
\caption{Performance (Accuracy) of Right hand vs Left hand vs Feet using TANG+SVM based algorithms.}
\label{table:TANG+SVM-3class-whithinsession}
\end{table}
\subsubsection{State of the Art}
Our best approach (ACM with TANG+SVM classification and hyper-parameters found with grid search) is compared to the state of the art in Table~\ref{table:TANG+SVM-3class-whithinsession-stateart}. It brings a notable improvement (7\%-11\%) over all these methods. A detailed study of the statistical significance of these results is provided in Figures~\ref{fig:TANG+SVM-3class-whithinsession-stateart} and~\ref{fig:TANG+SVM-3class-crosssession-stateart}.
\begin{table}[!ht]
\resizebox{\linewidth}{!}{\begin{tabular}{c|c|c|c|c|c}
\text {Dataset} & Eval & \text {CSP+LDA} & \text {ACM+TANG+SVM(Grid Search)} & \text {COV+EN} & \text {FgMDM} \\
\hline \text {BNCI2014001} & WS & $0.76 \pm 0.15$ & \textbf{0.87} $\pm$ \textbf{0.09} & $0.80 \pm 0.14$ & $0.77 \pm 0.14$ \\
\hline \text {Zhou2016} & WS & $0.83 \pm 0.06$ & \textbf{0.88} $\pm$ \textbf{0.03} & $0.85 \pm 0.05$ & $0.81 \pm 0.06$ \\ \hline
\hline \text {BNCI2014001} & CS & $0.68 \pm 0.15$ & \textbf{0.80} $\pm$ \textbf{0.10} & $0.70 \pm 0.11$ & $0.69 \pm 0.13$ \\
\hline \text {Zhou2016} & CS & $0.74 \pm 0.13$ & \textbf{0.81} $\pm$ \textbf{0.07} & $0.75 \pm 0.10$ & 0.72 $\pm$ 0.10 \\
\hline
\end{tabular}}
\caption{Performance (Accuracy) of Right hand vs Left hand vs Feet using ACM+TANG+SVM algorithm against the state of the art.}
\label{table:TANG+SVM-3class-whithinsession-stateart}
\end{table}
\section{Discussion}
\label{sec:discussion}
The numerous tests on different classification tasks, both binary and multi class, have shown that the augmented covariance approach is always superior in performance in all situations considered. This result is also confirmed through comparison with the state of the art algorithms and this is true in both the within- and cross- session frameworks. The performance improvements are naturally less important when the baseline methods are performing better initially, but this definitely shows that the augmented covariance approach brings some valuable information into the classification problem for these datasets. Naturally, the selection of hyper parameters that produces the best performance is through the use of grid search (because we used a search domain large enough). However, the modality based on non-linear dynamics concepts is also shown to produce in general better performance than standard algorithms (there are a few exceptions), with the traditional method being in general slightly better performing than the unified approach.
However, the selection of the hyper parameters through grid search is time consuming in the training phase of the algorithm to search for hyper parameters, and since these values are shown to be subject dependent it is necessary to search for the correct hyper parameters for each subject. Fig.~\ref{Figure_hyper} (a) shows one example of the spread of the order and lag hyper parameters over subjects and sessions. There are 15 sets of parameters found by grid search for 18 subjects $\times$ sessions. Comparatively the unified and traditional approaches give more condensed point sets. It can be seen that they are able to correctly identify only one of the two hyper parameters, the lag and the order respectively, but not both. Furthermore, these algorithms select parameters outside the grid search domain and create extreme high dimensional ACM, that need to be regularized using a Ledoit-Wolf~\cite{ledoit-wolf:04} procedure, which is probably the reason for their lower performances. Yet, these methods based on nonlinear systems theory place an important theoretical foundation for finding efficiently proper hyper parameters which generally achieve performance improvements for both within-session and cross-session evaluation, even if far from optimal. Figure~\ref{Figure_hyper} (b) shows the set of parameters that provide an accuracy within 99\% of the best one. On this example, we see that there are numerous almost equivalent sets of hyper parameters, which shows that focusing on the actual optimal value is maybe too strict. Figure~\ref{Figure_hyper} (c) is a voting map which counts for each couple of hyper parameters when they are found in this 99\% region over subjects $\times$ sessions. It can be seen that the best vote reaches the value of 9 which is only 50\% of the maximum possible value of 18. This shows that the distribution of optimal hyper parameters is not unimodal and that it will be difficult to find a fixed value that would work in every situation.
Other classification tasks and datasets behave similarly.
\begin{figure*}[!ht]
\centering
\subfloat[]{%
\includegraphics[width=0.25\linewidth]{Figure/HyperParam_BNCI2014001_lhrh_MDM.png}}
\hfill
\subfloat[]{%
\includegraphics[width=0.31\linewidth]{Figure/HyperParam_Area_BNCI2014001_lhrh_MDM_sub1_Session_E.png}}
\hfill
\subfloat[]{%
\includegraphics[width=0.29\linewidth]{Figure/HyperParam_HeatMap_BNCI2014001_lhrh_MDM.png}}
\caption{(a) Plot of the best hyper parameter for the ACM+MDM algorithm for each session and subject in the left hand right hand task, using the dataset BNCI2014001. Red box define the limit where we run the grid search.
(b) Heatmap that show the area that contain the hyper parameter that provide a classification score of $99\%$ of the maximum score obtained. This results is shown for Subject 1 in BNCI2014001 Session E in a right hand vs left hand task.
(c) General Heatmap that sow the maximum occurrence of best area of hyper parameter. It is obtained by counting the number of non empty boxes in plots (b) over all sessions and subjects.
}
\label{Figure_hyper}
\end{figure*}
While our approach has been shown to achieve improvement in accuracy performance in many BCI applications in the Motor Imagery task, it has some limitations. First of all, like other methods, it relies on the assumption of the validity of the sample covariance estimator. When the used time windows are way greater than the dimension of covariance matrix, this assumption remains valid. But this dimension increases quickly with higher AR orders. In that case, the matrix is still a symmetric positive matrix but is not definite and Riemannian metrics can no longer be used. To solve this issue, it is possible to adopt shrinkage or other methods to estimate covariance~\cite{ledoit-wolf:04,bartz-muller:14,sabbagh-ablin-etal:19}.
Finally, note that the augmented method increases computational time because of the increased dimensionality of the augmented covariance compared to the standard covariance~\cite{you-park:22}, as shown in Figure~\ref{fig:figure_Time}. Yet, even in the higher orders, the total time divided by the number of classified windows shows that the augmented approach is compatible with real time computation.
\begin{figure}[!ht]
\centering
\includegraphics[width=0.6\linewidth]{Figure/Time_BNCI2014001_rf_sub1.png}
\caption{Total evaluation computational time for the MOABB within-session evaluation for subject 1 of BNCI2014001 with the task right hand vs feet. Computational times at order 1 correspond to standard covariance. Similar behaviours occur in the other evaluation procedures, subjects, tasks and datasets.}
\label{fig:figure_Time}
\end{figure}
\section{Conclusion}
\label{sec:conclusion}
In this research, we explored the use of the augmented covariance matrix for the classification of Motor Imagery task in EEG-BCI.
This methodology amounts to integrate temporal information into the normal spatial covariance, and improves quite dramatically classification results over the state of the art when used with Riemann distance based classification algorithms. There remain some issues with the definiteness of the augmented covariance matrix, which stems from the augmentation of the dimensionality of the covariance matrix. Another issue is the choice of the hyper parameters which is costly. Yet, we show that methods inspired by the Takens' theorem can provide some reasonable parameter values at the cost of a decrease of the improvements (but with improvements still in most cases).
The current study focused on offline classification. Our next direction will be to extend the approach for online classification. To do this, it will be necessary to test the algorithms on narrower epoch windows and integrate them with a sliding window approach. Another important development of the augmented approach would be to see whether it is also efficient with smaller training dataset contexts i.e. with either a low number of electrodes or with fewer training samples. This would provide an important usability improvement for BCIs, potentially reducing the setup and/or the calibration times. We have already seen that performance over the state of the art is improved in the case of BNCI2014004, which possesses only 3 electrodes, but this needs to be generalized to the other datasets and to a smaller set of training samples.
Another work direction is to analyse more in depth the distribution of hyper parameters with the objective of identifying a methodology to make the classifier parameter free (e.g. by using ensemble classifiers methodology).
\section*{Acknowledgment}
This work has been partially financed by a EUR DS4H/Neuromod fellowship. The authors are grateful to the OPAL infrastructure from Université Côte d'Azur for providing resources and support.
\section*{Data and Code Availability}
The codes used to produce the results of this study are publicly available in this Github repository:
\url{https://github.com/carraraig/Augmented_Covariance_BCI}.
\printbibliography
| {'timestamp': '2023-02-10T02:08:53', 'yymm': '2302', 'arxiv_id': '2302.04508', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04508'} | arxiv |
\section*{Acknowledgements}
\section{Littlestone Dimension and Online Learning}
\label{sec:littlestone}
In this section, we show tight learning bounds of hierarchically labeled $k$-tuples for any constant integer $k > 0$. These bounds also hold for non-binary hierarchical trees.
Throughout this section, we consider an online learning setting as in~\citet{DanielySBS15}, defined as follows: in a series of rounds $\tau=1,\dots,T$, an online algorithm $\mathcal{A}$ receives in each round a $k$-tuple $t_\tau \in V^k$, and outputs an orientation $\orient{t}_\tau$ of $t_\tau$.
At the end of a round, a ``correct'' output $\orient{t}_\tau^*$ is revealed to the algorithm. The choice of $\orient{t}_\tau$ may only depend on $t_1,\dots,t_{\tau-1}$ and $\orient{t}_1^*,\dots,\orient{t}_{\tau-1}^*$. Our goal is to minimize the number of mistakes the algorithm makes $\err_T = \left|\left\{\tau \in {1,\dots,T} \mid \orient{t}_\tau \neq \orient{t}_\tau^*\right\}\right|$.
We say that a sequence is realizable if there is a hierarchical tree on $V$ satisfying all constraints $\orient{t}_1^*,\dots,\orient{t}_T^*$. In the agnostic (i.e. non-realizable setting), we say that the algorithm has regret $K$ if the number of mistakes it makes is $\mathrm{OPT}+K$ where $\mathrm{OPT}$ the minimum number of mistakes achieved by any tree on the sequence.
We give a tight $\Theta(n\log{n})$ bound on the multi-class Littlestone dimension, which was introduced by~\citet{DanielySBS15} as an extension of the binary-class Littlestone dimension~\citep{Littlestone87}.
Similarly to the Natarajan dimension, the notion of (multi-class) Littlestone dimension almost tightly characterizes the mistake and regret bounds of a hypothesis class in the online model, in both the realizable and agnostic setting.
\begin{definition}[Littlestone dimension]\label{def:littlestone}
Let $V$ be an $n$ point set, and $k$ be some constant parameter.
Let $L$ be a complete binary rooted tree such that each of its internal nodes is labeled by a $k$-tuple $t$ and each of its two edges to its children is labeled by a different orientation on $t$.
We say that $L$ is Littlestone-shattered if for each path from the root to a leaf which traverses the nodes $t_1, \ldots, t_l$, there is a hierarchical tree on point set $V$ such that for each $\tau$, the label of the edge $(t_\tau,t_{\tau+1})$ is a constraint satisfied by the tree.
The Littlestone dimension $\text{LDim}$ of learning a hierarchical tree representation is the maximum depth of a full binary tree that is Littlestone-shattered (as a function of $n$).
\end{definition}
The connection between the Littlestone dimension and online learning is described in Theorem~\ref{thm:littlestone_to_sample}. We refer to~\citet[Section 5.1]{DanielySBS15} for a full survey of the multi-class Littlestone dimension.
\begin{theorem}[\citet{DanielySBS15}, Theorems 24, 25, 26, informal]
\label{thm:littlestone_to_sample}
In the realizable online setting, there exists an online algorithm that makes at most $\text{LDim}$ mistakes on any realizable sequence.
On the other hand, any randomized online algorithm has an expected number of mistakes on the worst sequence of at least $\nicefrac \text{LDim} 2$.
In the agnostic online setting, there is an algorithm with expected regret $O(\sqrt{T \cdot \text{LDim} \cdot \log T})$, and any algorithm has expected regret at least $\Omega(\sqrt{T \cdot \text{LDim}})$.
\end{theorem}
Hence, it suffices to bound $\text{LDim}$.
\begin{lemma}
\label{lem:littlestone_upper_bound}
$\text{LDim} = O(n \log n)$.
\end{lemma}
\begin{proof}
Assume for contradiction that there is a Littlestone-shattered tree $L$ of depth $d=2n\log(2n)+3$. Let $\mathcal{G}$ be the set of all hierarchical trees on the point set $V$, and notice that $|\mathcal{G}| \leq 2^{2n\log(2n)+1}$.
We show that there is a root-to-leaf path $(v_0, \ldots, v_d)$ such that no hierarchical tree satisfies the constraints of the edges of this path.
We choose the vertices $v_0,\dots,v_d$ in an iterative manner, and let $\mathcal{G}_i$ be the set of hierarchical trees that satisfy the constraints of the edges in the sub-path $(v_0,\dots,v_\tau)$.
Initially, let $v_0$ be the tree's root, and $\mathcal{G}_0 = \mathcal{G}$.
Given a we have chosen $v_0,\dots,v_\tau$ to be in the path, we choose $v_{i+1}$ as follows.
Among two constraints $(v_\tau, u^{(1)})$ and $(v_\tau, u^{(2)})$ on the edges from $v_\tau$ to its children, at least one of them satisfies at most half of trees from $\mathcal{G}_\tau$, since these constraints are mutually contradictory. We select the corresponding child as $v_{\tau+1}$.
After $d$ steps, it holds that $|\mathcal{G}_d| < 1$, meaning $\mathcal{G}_d$ is empty.
Hence, there is no hierarchical tree that satisfies first $d$ constraints of this path, a contradiction to $L$ being Littlestone-shattered.
\end{proof}
In the remainder of the section, we show the following lemma.
\begin{lemma}
\label{lem:littlestone_lower_bound}
$\text{LDim} = \Omega(n \log n)$.
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lem:littlestone_lower_bound}]
Let $n'$ be the largest power of $k$ such that $n' \leq n$. We construct a Littlestone-shattered tree $L$ of depth $\frac{n'\log_k{n'}}{k} = \Omega(\frac{n\log_k{n}}{k^2})$, thus showing the lower bound on $\text{LDim}$. Let $V' = \{x_1,\dots,x_{n'}\} \subseteq V$ be a set of $n'$ items of $V$.
\begin{definition}
A tournament function $P$ is a function that given a set of points $X \subseteq V'$ whose size is a power of $k$, partitions $X$ into disjoint $k$-tuples.
\end{definition}
\begin{definition}
For a set of data points $x_1,\dots,x_l$, a $(x_1,\dots,x_l)$-ladder is a tree shown in Figure~\ref{fig:ladder}.
We say that $x_i$ has rank $i$ in the ladder.
\end{definition}
\begin{figure}[H]
\centering
\input{pics/ladder.tex}
\caption{$(x_1, \ldots, x_{l})$-ladder.}
\label{fig:ladder}
\end{figure}
\begin{algorithm}[t!]
\caption{\textsc{BuildLittleStoneTree}$(v, X_1, \ldots, X_\ell)$}
\label{alg:build_littlestone_tree}
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
\Input{Tree node $v$; partition of $V'$ into equal-sized sets $X_1^{(v)}, \ldots, X_\ell^{(v)}$, where $\ell$ is a power of $k$}
\Output{A subtree of the current node in the Littlestone tree}
\If{$|X_i^{(v)}| = 1$}{
\Return single leaf node
}
Let $\{t_1, \ldots,t_{\nicefrac{n'}{k}}\} = P(X_1) \cup ... \cup P(X_\ell)$ \\
Create a complete binary tree $\tilde L$ of depth $\nicefrac{n'}{k}$ as follows \\
\For{$\tau=1, \ldots, \nicefrac{n'}{k}$}{
Label every node on layer $\tau$ as $t_\tau$ \\
Label outgoing edges from each node on layer $\tau$ as $D(t_\tau)$ and $U(t_\tau)$ \\
}
Let $\tilde L$ be the resulting tree \\
\For{each leaf $u$ of $\tilde L$}{
Initalize $X_1^{{(u)}}, \ldots, X_\ell^{{(u)}}$ as empty sets \\
\For{each $x \in V'$} {
Let $i \ge 0$ be unique index such that $t_\tau \in X_{i + 1}^{(v)}$ \\
There exists a unique edge on the path from the root of $\tilde L$ to $u$ containing $x$ \\
Let $r$ be the rank of $x$ in the label of this edge (recall that the edge label is a ladder) \\
Let $j$ be $i \cdot k + r$ \\
Assign $x$ to $X_j^{{(u)}}$
}
In $\tilde L$, replace $u$ with \textsc{BuildLittleStoneTree}$(X_1^{{(u)}}, \ldots, X_\ell^{{(u)}})$
}
\Return $\tilde L$
\end{algorithm}
Let $P$ be some arbitrary tournament function. Let $D$ be a function that maps any $k$-tuple $(x_1,\dots,x_k)$ to the $(x_1,\dots,x_k)$-ladder, where $x_1, \ldots, x_k$ are lexicographically ordered.
Similarly, let $U$ be a function that maps the set to the $(x_k,\dots,x_1)$-ladder (i.e. in the reversed lexicographic order).
We describe the labeling of the Littlestone tree using a recursive process \textsc{BuildLittleStoneTree} (Algorithm~\ref{alg:build_littlestone_tree}), which receives as input subtree rooted $v$ whose edges and vertices are unlabeled, and a partition of $V'$ into disjoint sets $X_{1}^{(v)},\dots,X_{\ell}^{(v)}$ of equal size (which is a power of $k$).
\textsc{BuildLittleStoneTree} builds the Littlestone tree from top to bottom, by constructing next $\nicefrac{n'}{k}$ layers.
We initially run this procedure starting with $v$ being the root, $\ell=1$, and hence $X_1^{(v)} = V'$.
Let $v$ be a vertex on which a recursive call is made, and let $X_1^{(v)},\dots,X_\ell^{(v)}$ be the input partition.
If $|X_1^{(v)}| = \dots = |X_\ell^{(v)}| = 1$, then $u$ is the leaf of the Littlestone tree, and we halt.
Otherwise, we label the first $\nicefrac{n'}{k}$ layers as follows.
Let $t_\tau,\dots,t_{n'/k}$ be the $k$-tuples of $P(X_1^{(v)}) \cup ... \cup P(X_\ell^{(v)})$.
For $\tau=1,\dots,\nicefrac{n'}{k}$, we label all vertices of $\tau$'th layer in the subtree of $v$ with $t_\tau$, and its two edges with $D(t_\tau)$ and $U(t_\tau)$ respectively.
Next, we need to call \textsc{BuildLittleStoneTree} from each node $u$ which is $\nicefrac{n'}{k}$ layers below $v$.
For that, we need to compute partition $X_{1}^{(u)}, \ldots, X_{1}^{(v)}$ and .
We need to assign each $x \in V'$ to some $X_i^{(u)}$, which we do as follows.
For each $x \in V'$ we compute the following quantities.
\begin{itemize}
\item $\Ind^{(v)}(x)$ is the unique index $i \geq 0$ such that $x \in X_{i}^{(v)}$.
\item On the path from $v$ to $u$, there exists a unique edge whose label (which is a ladder) contains $x$.
Then $\Rank^{(v)}(x, u)$ is the rank of $x$ in that ladder.
\end{itemize}
Then we assign $x$ to $X_j^{(u)}$, where $j = \Ind^{(v)}(x) \cdot k + \Rank^{(v)}(x, u)$.
In other word, we encode $j$ as a 2-digit number, where the highest digit equals $\Ind^{(v)}(x)$, and the lowest digit equals $\Rank^{(v)}(x, u)$.
\begin{lemma}
\label{lem:set_sizes}
Let $v$ be a node of depth $s \cdot \nicefrac{n'}{k}$ in $L$ for some integer $s$.
Then $|X_i^{(v)}| = \nicefrac{n'}{k^\tau}$ for any $1 \leq i \leq k^s$.
\end{lemma}
\begin{proof}
We prove the claim by induction on $\tau$.
For $s = 0$, the claim is trivial since for in root $r$ we have $X_1^{(r)} = V'$, and thus $|X_1^{(r)}| = n'$.
Assume by induction that the statement holds for $s < \log_k n'$
Let $u$ be a node of depth $(s+1) \cdot \nicefrac{n'}{k}$, and let $v$ be its ancestor node in depth $s \cdot \nicefrac{n'}{k}$ in $L$.
By the induction assumption, $X_i^{(v)} = \nicefrac{n'}{k^s}$ for any $1 \leq i \leq k^s$.
First, note that elements from different $X_i^{(v)}$ are assigned to different $X_j^{(u)}$.
It remains to consider elements from some fixed $X_i^{(v)}$.
Each element $x \in X_i^{(v)}$ appears in exactly one ladder constraint in the path between $v$ and $u$.
Aside from $x$, there are $k-1$ other items from $X_i^{(v)}$ in the same ladder, and each of them has a different rank.
Therefore the number of elements from $X_i^{(v)}$ with $\Rank^{(v)}(x) = r$ is exactly $\frac{|X_j^{(v)}|}{k} = \frac{n'}{k^{s+1}}$ for any $1 \leq r \leq k$.
Since elements from different $X_i^{(v)}$ are assigned to different sets $X_j^{(u)}$, the result follows.
\end{proof}
\begin{lemma}
\label{lem:online_order_preserve}
Assume the label of some edge $(u,v)$ in $L$ is the $(x_1,\dots,x_k)$-ladder for some $x_1,\dots,x_k \in V'$. Then in any leaf descendant $w$ of $v$, and for any $1 \leq i < j \leq k$, it holds that $\Ind^{(w)}(x_{i}) < \Ind^{(w)}(x_{j})$.
\end{lemma}
\begin{proof}
Let $v_1,\dots,v_\ell$ be the vertices on the path between between $v$ and $w$ (inclusive) on which \textsc{BuildLittleStoneTree} was called, i.e. those whose depth is a multiple of $\nicefrac{n'}{k}$).
We prove by induction that for $1\leq s \leq \ell$ it holds that $\Ind^{(v_s)}(x_{i}) < \Ind^{(v_s)}(x_{j})$.
Induction base.
Let $p$ be the closest ancestor of $v$ (excluding $v$) on which a recursive call is made.
We know that $\Ind^{(p)}(x_{i}) = \Ind^{(p)}(x_{j})$, since the ladder on edge $(u,v)$ contains both $x_i$ and $x_j$.
Denoting $\Ind^* = \Ind^{(p)}(x_{i})$, we know that $x_{i}$ and $x_{j}$ are mapped to some $X_{k \cdot \Ind^* + r_1}$ and $X_{k \cdot \Ind^* + r_2}$ for some integers $1 \leq r_1 < r_2 \leq k$.
Therefore, $\Ind^{(v_1)}(x_{i}) < \Ind^{(v_1)}(x_{j})$.
Assume by induction that $\Ind^{(v_s)}(x_{i}) < \Ind^{(v_s)}(x_{j})$ for $s < \ell$.
In the recursive call to $v_s$, every item $x$ in contained in a set $X_{k \cdot \Ind^{(v_s)}(x) + r}$ for some $1 \leq r \leq k$.
Therefore, if $\Ind^{(v_s)}(x_{i}) < \Ind^{(v_s)}(x_{j})$ then $\Ind^{(v_{s+1})}(x_{i}) < \Ind^{(v_{s+1})}(x_{j})$. Since $v_\ell = w$, the claim follows.
\end{proof}
\begin{lemma}
\label{lem:little_shattered}
$L$ is Littlestone-shattered.
\end{lemma}
\begin{proof}
Given a root-to-leaf path $v_1,\dots,v_\ell$, and assume that the leaf $v_l$ that was given partition $X_1^{(v_\ell)},\dots,X_{n'}^{(v_\ell)}$.
Recall that by Lemma~\ref{lem:set_sizes}, any $X_i^{(v_\ell)}$ is of size $1$ for all $1 \leq i \leq n'$. Let $(x_1,\dots,x_{n'})$ be the points of $V'$ ordered such that $x_i$ is the unique item in $X_i^{(v_\ell)}$.
We show that a hierarchical tree defined as a $(x_1,\dots,x_{n'})$-ladder satisfies all constraints on the path $v_1,\dots,v_\ell$.
Assume for contradiction that there are some $i < j$ such that $x_i$ and $x_j$ appear in a ladder constraint in one of the edges of the path $v_1,\dots,v_\ell$, such that $x_i$'s rank is larger than $x_j$.
By Lemma~\ref{lem:online_order_preserve}, it holds that $j = \Ind^{(v_\ell)}(x_j)+1 < \Ind^{(v_\ell)}(x'_i)+1 = i$, leading to contradiction.
\end{proof}
By construction, $L$ is of depth $\frac{n'\log_k{n'}}{k} = \Omega(\frac{n\log_k{n}}{k^2})$, and by Lemma~\ref{lem:little_shattered} $L$ is shattered, therefore $\text{LDim} = \Omega(n\log{n})$.
We conclude the proof of Lemma~\ref{lem:littlestone_lower_bound}.
\end{proof}
Since $\text{LDim} = \Theta(n \log n)$, then Theorem~\ref{thm:online_main} follows immediately from Theorem 5.1, Theorem 5.2, and Theorem 5.3 of \cite{DanielySBS15}.
\begin{theorem}[Formal version of Theorem~\ref{thm:online_main}]
\label{thm:littlestone_main_formal}
Let $k$ be any constant integer. In the realizable online setting, there exists an online algorithm that makes at most $O(n\log{n})$ mistakes on any realizable sequence. On the other hand, any randomized online algorithm has an expected number of mistakes on the worst sequence of at least $\Omega(n\log{n})$. In the agnostic online setting, there is an algorithm with expected regret $O(\sqrt{T \cdot n\log{n} \cdot \log (T)})$, and any algorithm has expected regret at least $\Omega(\sqrt{T \cdot n\log{n}})$ for a series of length $T$.
\end{theorem}
\section{Missing proofs from Section~\ref{sec:pac}}
\label{app:n_dimension}
\begin{theorem}[Theorem~\ref{thm:natarajan} restated]
For any $V$, we have $\text{NDim}(H_3(V)) = |V|-2$.
\end{theorem}
\begin{proof}
\noindent $\text{NDim}(H_3(V)) \ge |V|-2$: follows from Lemma~\ref{lem:natarajan_lb}.
\vspace{1em}
\noindent $\text{NDim}(H_3(V)) \le |V|-2$: For contradiction, assume that there exists an N-shattered set of triplets $\Delta = \{t_i\}_{i=1}^m$ of size $m \ge |V|-1$.
Let $\orient{t_i}^{(1)}$ and $\orient{t_i}^{(2)}$ be the orientations from the definition of N-shattering for each $t_i$.
By Theorem~\ref{thm:triplets}, there exists a contradictory orientation $\orient{\Delta}^* = \{\orient{t_i}^*\}_{i=1}^k$.
If for all $i$ we have $\orient{t_i}^* = \orient{t_i}^{(1)}$ or $\orient{t_i}^* = \orient{t_i}^{(2)}$, then we have a contradiction: the set is not N-shattered since there exists $f:\ [k] \to [2]$ such that the orientation $\bbr{\orient{t_i}^{(f(i))}}_{i=1}^m = \orient{\Delta}^*$ is contradictory.
It remains to consider the case when for some $t_i \in \Delta$ we have $\orient{t_i}^* \ne \orient{t_i}^{(1)}$ and $\orient{t_i}^* \ne \orient{t_i}^{(2)}$.
Among all contradictory orientations we consider $\orient{\Delta}^*$ which has the smallest number of such $t_i$.
Let $S$ be the critical set.
We denote $\orient{t_i}^* = \C abc$, $\orient{t_i}^{(1)} = \C acb$ and $\orient{t_i}^{(2)} = \C bca$.
Constraint $\C abc$ generates edge $(a,b)$.
If $(a,b,c)$ doesn't belong to $\Delta|_S$ or removing edge $(a,b)$ doesn't disconnect $S$, then the orientation of this edge is not important and we can change the triplet orientation arbitrarily to $\orient{t_i}^{(1)}$ or $\orient{t_i}^{(2)}$.
Otherwise, removing this edge partitions $S$ into two connected components $U$ and $V$ such that $a \in U$ and $b \in V$.
However, we can restore connectivity using $\orient{t_i}^{(1)}$ or $\orient{t_i}^{(2)}$:
if $c \in U$, then $b$ and $c$ are in different connected components, and we can connect $S$ using edge generated by $\C bca$.
Similarly, if $c \in V$, then $a$ and $c$ are in different connected components, and we connect $S$ using $\C acb$.
In both cases, we reorient $t_i$ according to either $\orient{t_i}^{(1)}$ or $\orient{t_i}^{(2)}$ while maintaining connectivity of $S$ and not changing orientations of other triplets.
Hence, we have contradiction with the assumption that $\orient{t_i}^*$ has smallest number of $t_i$ such that $\orient{t_i}^* \ne \orient{t_i}^{(1)}$ and $\orient{t_i}^* \ne \orient{t_i}^{(2)}$
Hence such $t_i$ doesn't exist and $\Delta$ is not N-shattered.
\end{proof}
\begin{theorem}
\label{thm:natarajan_nonbinary}
Let $H_3^*$ be defined identically to $H_3$ (Definition~\ref{def:hypothesis}) with the only change that the ground-truth trees don't have to be binary.
Then $\text{NDim}(H_3^*(V)) = |V|-2$.
\end{theorem}
\begin{proof}
$ $
\paragraph{$\text{NDim}(H_3^*(V)) \ge |V|-2$:} since the possible labels for $H_3$ is a subset of labels for $H_3^*$, the lower bound on $\text{NDim}(H_3^*)$ follows from the lower bound on $\text{NDim}(H_3)$.
\paragraph{$\text{NDim}(H_3^*(V)) \le |V|-2$:} To simplify the presentation, w.l.o.g. we assume that $V$ is the critical set.
From Theorem~\ref{thm:crit_set_is_a_closed_set}, we know that for any set of triplets $\Delta$ with $|\Delta| \ge |V| - 1$ there exists a contradictory orientation $\orient{\Delta}$ which uses only constraints of form $\C abc$.
Towards contradiction, let's assume that $\Delta$ can be N-shattered using $H_3^*$.
For every triplet $t_i = (a_i, b_i, c_i)$ from $\Delta$, let $\orient{t_i}^{(1)}$ and $\orient{t_i}^{(2)}$ be allowed orientations from the definition of N-shattering.
We show that we can reorient every constraint according to $o^{(1)}_i$ or $o^{(2)}_i$ while maintaining the connectivity of $V$.
Let $\orient{\Delta} = \bbr{\orient{t_1}, \ldots, \orient{t}_{|V|-1}} = \bbr{\C{a_i}{b_i}{c_i}}_{i=1}^{|V|-1}$ be the contradictory orientation of $\Delta$ according to Theorem~\ref{thm:crit_set_is_a_closed_set}.
We process the constraints depending on types of $\orient{t_i}^{(1)}$ and $\orient{t_i}^{(2)}$ in the following order:\todo{Finish}
\begin{enumerate}
\item Constraints for which $\orient{t_i} = \orient{t_i}^{(1)}$ or $\orient{t_i} = \orient{t_i}^{(2)}$~-- these constraints use labels from the definition of N-shattering, and hence we don't reorient them.
\item Constraints $\orient{t_i} = \C{a_i}{b_i}{c_i}$ for which $\orient{t_i}^{(1)} = \C{a_i}{c_i}{b_i}$ and $\orient{t_i}^{(2)} = \C{b_i}{c_i}{a_i}$.
We reorient all such constraints without breaking connectivity, see Theorem~\ref{thm:natarajan}.
\item Constraints for which $\orient{t_i}^{(1)} = \C{a_i}{c_i}{b_i}$ and $\orient{t_i}^{(2)} = \TW{a_i}{b_i}{c_i}$.
We say that such constraints are of Type 3 and perform case analysis on such constraints:
\end{enumerate}
\textbf{Case 1:} If there exists a constraint such that reorienting it using $\orient{t_i}^{(1)}$ doesn't break connectivity, then we reorient the triplet using $\orient{t_i}^{(1)}$.
In the remaining cases, we assume that using $\orient{t_i}^{(1)}$ breaks connectivity for all $i$, i.e. for each Type 3 constraint $\C{a_i}{b_i}{c_i}$, reorienting it as $\C{a_i}{c_i}{b_i}$ breaks connectivity.
In particular, it means that $a_i$ and $c_i$ are in the same component after removing edge $(a_i,b_i)$.
\textbf{Case 2} (Figure~\ref{fig:type3_no_between}): There exist constraint $\C{a_{i^*}}{b_{i^*}}{c_{i^*}}$ such that there is no edge from other Type 3 constraint on the path from $a_{i^*}$ to $c_{i^*}$.
Then we reorient the triplet as $\orient{t_{i^*}}^{(2)}$, i.e. $\TW{a_{i^*}}{b_{i^*}}{c_{i^*}}$.
Note that $a_{i^*}$ and $c_{i^*}$ are connected, and, since there is no edge from other Type 3 constraints between $a_{i^*}$ and $c_{i^*}$, they will always remain connected, and hence we can perform $t$-extension using $\TW{a_{i^*}}{b_{i^*}}{c_{i^*}}$.
Again, after the $t$-extension, $V$ remains connected.
\begin{figure*}[t!]
\centering
\begin{subfigure}[t]{\ifarxiv{\columnwidth}\else{\columnwidth}\fi}
\centering
\input{pics/type3_no_between.tex}
\caption{Case 2: for a Type 3 constraint $\C{a_{i^*}}{b_{i^*}}{c_{i^*}}$, if there is no edge from other Type 3 constraint on the path from ${a_{i^*}}$ to ${c_{i^*}}$, then we reorient the constraint as $\TW{a_{i^*}}{b_{i^*}}{c_{i^*}}$}
\label{fig:type3_no_between}
\end{subfigure}
\vspace{1em}
\begin{subfigure}[t]{\ifarxiv{\columnwidth}\else{\columnwidth}\fi}
\centering
\input{pics/type3_between.tex}
\caption{Case 3: when we have constraints $\C{a_1}{b_1}{c_1}, \ldots, \C{a_\ell}{b_\ell}{c_\ell}$ such that edge $(a_{i+1}, b_{i+1})$ separates $a_i$ from $c_i$ (we equalize $\ell+1$ with $1$), we can reorient all constraints as $\C{a_i}{c_i}{b_i}$ while preserving connectivity.
Note that if, for example, $a_1$ and $b_1$ are swapped, then it would fit under Case 1: reorienting $\C{a_1}{b_1}{c_1}$ as $\C{a_1}{c_1}{b_1}$ alone would preserve connectivity.
}
\label{fig:type3_between}
\end{subfigure}
\caption{Case analysis of Type 3 constraints in Theorem~\ref{thm:natarajan_nonbinary}}
\end{figure*}
\textbf{Case 3} (Figure~\ref{fig:type3_between}): For each constraint $\C {a_i}{b_i}{c_i}$, there exists another constraint $\C{a_j}{b_j}{c_j}$ such that edge $(a_j,b_j)$ is on the path from $a_i$ to $c_i$. Consider a graph on these constraints, where there exists an edge $i \to j$ when $(a_j,b_j)$ is on the path from $a_i$ to $c_i$. Since Case 2 is not realized, the graph has a cycle $i_1 \to i_2 \to \ldots \to i_\ell \to i_1$.
Among such cycles, we consider the cycle with the smallest length.
To simplify the notation, we assume that the cycle is exactly $1 \to 2 \to \ldots \to \ell \to 1$ and equalize $\ell+1$ with $1$.
The important observation is that, for every $i$, among the edges in the cycle, only $(a_{i + 1}, b_{i+1})$ cuts $a_i$ from $c_i$.
Otherwise, if there exists another $j$ with $(a_j, b_j)$ cutting $a_{i}$ from $c_{i}$, we can remove $i+1, \ldots, j-1$ from the cycle, hence reducing its size and contradicting its minimality.
Hence, one of the following holds regardless of the orientation of the triplets in the cycle (importantly, since Case 1 is not realized, $a_i$ and $c_i$ are in the same connected component after removing edge $(a_i,b_i)$):
%
\begin{itemize}
\item $a_{i}$ is connected to $a_{i+1}$ and $c_{i}$ is connected to $b_{i+1}$.
\item $a_{i}$ is connected to $b_{i+1}$ and $c_{i}$ is connected to $a_{i+1}$.
\end{itemize}
%
We reorient the constraints in the cycle using the corresponding $\orient{t_{i}}^{(1)}$, i.e. $\C{a_{i}}{b_{i} }{c_{i}} \to \C{a_{i}}{c_{i}}{b_{i}}$ for all $s$.
Since after the reorientation $a_{i}$ is connected to $c_{i}$, in both cases, $a_{i}$ is connected to both $a_{i+1}$ and $b_{i+1}$.
Hence, all of $a_{1}, \ldots, a_{\ell}$ and $b_{1}, \ldots, b_{\ell}$ are connected after the reorientation, and hence $V$ remains connected.
As long as a Type 3 constraint exists, we can apply one of Cases 1, 2 or 3, reducing the number of such constraints.
Hence, after at most $|V|$ reorientations, all constraints are oriented in accordance to the definition of N-shattering, concluding the proof.
\end{proof}
\todo{Pictures}
From the above theorem, the main result follows.
\begin{theorem}
\label{thm:non-binary}
For a constant $k$, the sample complexity of learning non-binary hierarchically labeled $k$-tuples, denoted by $m_{H_k^*}^r(\varepsilon, \delta)$ in the realizable setting and $m_{H_k^*}^a(\varepsilon, \delta)$ in the agnostic setting, is bounded by:
\begin{align*}
C_1 \frac{n + \log \frac 1\delta}{\varepsilon} \le m_{H_k^*}^r(\varepsilon, \delta) & \le C_2 \frac{n \log \frac 1\varepsilon + \log \frac 1\delta}{\varepsilon} \\
C_1 \frac{n + \log \frac 1\delta}{\varepsilon^2} \le m_{H_k^*}^a(\varepsilon, \delta) & \le C_2 \frac{n + \log \frac 1\delta}{\varepsilon^2}
\end{align*}
\end{theorem}
\section{Missing proofs from Section~\ref{sec:contr_orient}}
\label{app:missing_proofs}
Recall that we associate constraint $\C abc$ with edge $(a,b)$.
Intuitively, the tree is consistent with constraint, if it cuts off $c$ before cutting edge $\{a,b\}$.
\begin{definition}
\label{def:generated_edges}
Let $C$ denote the set of all possible constraints over $V$.
We define the function $e\colon\ C \rightarrow V \times V$, referred to as the \emph{edge generating function}, as $e(\C abc) = (a,b)$.
For any $C' \subseteq C$, we define $e(C') = \{e(t) \mid t \in C'\}$.
\end{definition}
Recall that we call the set of constraints contradictory if there is no tree consistent with these constraints.
We call a set $S$ closed w.r.t. the set of triplets $\Delta$ if there exists an orientation $\orient{\Delta}$ of $\Delta$, such that $e(\orient{\Delta} |_{S})$ connects $S$.
\begin{lemma}
\label{lem:closed_set_proof}
A set of triplets $\Delta$ over $V$ allows a contradictory orientation iff there exists a set $S \subseteq V$ that is closed w.r.t. $\Delta$.
\end{lemma}
\begin{proof}
$ $\newline
$\Longrightarrow$: We will instead prove the contrapositive; i.e., we will assume that there is no set closed w.r.t. $\Delta$ and show that any orientation of $\Delta$ is non-contradictory.
Given any orientation of $\orient{\Delta} = \bbr{\C {a_i}{b_i}{c_i}}_i$ of $\Delta$, we will build in a top-down manner a hierarchical tree satisfying $\orient{\Delta}$.
At every step we have a set of points $S \subseteq V$ that we would like to split.
In order to do so consider $\orient{\Delta} |_{S}$ and let $E_S = e(\orient{\Delta} |_S)$. By our earlier assumption, there does not exist a set that is closed w.r.t. $\Delta$ - in particular, $S$ is not such a set. Therefore, $E_S$ does not connect $S$ and there exists a disconnected bipartition $S = C_1 \cup C_2$. The algorithm cuts $C_1$ from $C_2$.
Clearly, the algorithm is well-defined (if there are multiple possible bipartitions, it selects an arbitrary one).
Furthermore, the algorithm never breaks any constraints and, since it eventually splits all points, it must have satisfied all the constraints~-- thereby completing the proof.
\vspace{3pt}
\noindent $\Longleftarrow$: Let $S$ be a closed set w.r.t. $\Delta$. Then by Definition \ref{def:closed_set} there exists an orientation $\orient{\Delta}$ such that $e(\orient{\Delta}|_S)$ connects $S$.
We next prove that $\orient{\Delta}$ is a contradictory orientation of $\Delta$.
Assume towards contradiction that this is not the case.
Therefore, there exists a hierarchical tree satisfying all constraints in $\orient{\Delta}$.
Consider the first (closest to the root) tree node that cuts the set $S$.
Since $e(\orient{\Delta}|_S)$ connects $S$, the cut must cut an edge in $e(\orient{\Delta}|_S)$.
Denote this edge as $(a,b)$ and let the $\C abc$ be the constraint generating the edge.
By the definition of $\orient{\Delta}|_S$, $c$ must belong to $S$, and hence constraint $\C abc$ is violated by the tree~-- in contradiction to our assumption, thereby concluding our proof.
\end{proof}
\begin{theorem}[Theorem~\ref{thm:crit_set_is_a_closed_set} restated]
Let $\Delta$ be a set of triplets over $V$ of size $|\Delta| \geq |V| -1$.
Then any critical set w.r.t. $\Delta$ is closed w.r.t. $\Delta$.
\end{theorem}
Before proving Theorem~\ref{thm:crit_set_is_a_closed_set}, we define the following crucial operation.
\begin{definition}[Reorientation]
For a fixed triplet, when changing a constraint from $\C abc$ to another constraint (i.e. $\C bca$ or $\C acb$), we say that we \emph{reoriented} the constraint.
\end{definition}
\begin{proof}[Proof of Theorem~\ref{thm:crit_set_is_a_closed_set}]
Let $S$ be a critical set and $\Delta |_S$ be the set of triplets induced by $S$. If $S$ is closed then the proof holds.
Otherwise any orientation of $\Delta$ results in $e(\orient{\Delta}|_S)$ not connecting $S$.
Consider $\orient{\Delta}$ such that the maximum forest $\mathcal F$ with vertices from $S$ and edges from $e(\orient{\Delta}|_S)$ has more than $1$ component.
Among all such forests we consider the one with the maximum number of edges.
Then, the forest $\mathcal F$ has at most $|S| - 2$ edges, and there exists a constraint $\C abc \in \orient{\Delta} |_S$ such that $e(\C abc)$ is not in the forest.
Below, we refer to triplet $(a,b,c)$ as the \emph{unused triplet}.
If two of these vertices, e.g. $a$ and $b$, belong to different trees, we can generate the edge $(a,b)$ to connect the trees, contradicting maximality of the forest $\mathcal F$.
Hence, $a$, $b$ and $c$ must belong to the same tree, which we denote $T^*$.
Among all $\orient{\Delta}$ and maximum forests $\mathcal F$ on $\orient{\Delta}$, we consider the ones minimizing the size of $T^*$.
By minimality of $S$, the vertices of $T^*$ don't form a critical set, and hence there must exist a non-empty set of constraints $\orient{\Delta}^* = \bbr{\C {x_i}{y_i}{z_i}}_{i=1}^m$ such that $(x_i,y_i)$ is an edge in tree $T^*$ and $z_i$ belongs to a different tree.
Let $U_1, \ldots, U_k$ be the connected components obtained by removing edges $\{(x_i,y_i)\}_{i=1}^m$ from $T^*$.
It suffices to consider the following cases (other cases are symmetrical).
\begin{figure}[t!]
\centering
\begin{subfigure}[t]{\ifarxiv{0.48\columnwidth}\else{\columnwidth}\fi}
\includegraphics[width=\columnwidth]{pics/Triple_inside.pdf}
\caption{Case 1: $(x_i,y_i)$ separates $a$ from $b$ and $c$. In this case, we connect $T^*$ to the tree containing $z_i$}
\label{fig:inside}
\end{subfigure}
\hfill
\begin{subfigure}[t]{\ifarxiv{0.48\columnwidth}\else{\columnwidth}\fi}
\includegraphics[width=\columnwidth]{pics/Triple_outside_inside.pdf}
\caption{Case 2a: $(x_i,y_i)$ doesn't separate $a$, $b$ and $c$. If there exists an edge $(u,v)$ with the third vertex outside $U$ and separating $a$ from $b$ and $c$, we can connect $T^*$ to the tree containing $z_i$ by generating $(a,b)$ and reorient $(u,v)$}
\label{fig:outside_inside}
\end{subfigure}
\begin{subfigure}[t]{\ifarxiv{0.48\columnwidth}\else{\columnwidth}\fi}
\includegraphics[width=\columnwidth]{pics/Triple_outside_outside.pdf}
\captionsetup{singlelinecheck=off}
\caption{Case 2b: $(x_i,y_i)$ doesn't separate $a$, $b$ and $c$.
If there is a constraint $\C uvw$ such that
\begin{compactenum}
\item $u,v \in U$ and $w \notin U$,
\item $(u, v)$ doesn't separate $a$, $b$ and $c$,
\item $(u, v)$ doesn't separate $a$, $b$, $c$ from $x_i$, $y_i$ (unlike Case 2c in Figure~\ref{fig:outside_outside_sep}),
\end{compactenum}
then we reorient edges $(u, v)$ and $(x_i,y_i)$, connecting vertices $v$, $w$ and $y_i$ to the tree containing $z_i$, hence reducing the size of $T^*$}
\label{fig:outside_outside}
\end{subfigure}
\hfill
\begin{subfigure}[t]{\ifarxiv{0.48\columnwidth}\else{\columnwidth}\fi}
\includegraphics[width=\columnwidth]{pics/Triple_outside_outside_sep.pdf}
\captionsetup{singlelinecheck=off}
\caption{Case 2c: $(x_i,y_i)$ doesn't separate $a$, $b$ and $c$. If there is a triplet $(u, v, w)$ such that
\begin{compactenum}
\item $u,v \in U$ and $w \notin U$,
\item $(u, v)$ doesn't separate $a$, $b$ and $c$,
\item $(u, v)$ separates $a$, $b$, $c$ from $x_i$, $y_i$ (unlike Case 2b in Figure~\ref{fig:outside_outside}),
\end{compactenum}
then we reorient edges $(u,v)$ and $(x_i, y_i)$, connecting vertices $v$, $w$, $x_i$ and $y_i$ to the tree containing $z_i$, hence reducing the size of $T^*$}
\label{fig:outside_outside_sep}
\end{subfigure}
\caption{Case analysis in Theorem~\ref{thm:crit_set_is_a_closed_set}}
\end{figure}
\paragraph{Case 1: $a \in U_j$ and $b,c \notin U_j$ for some $j$}
Then there exists a tree edge $(x_i,y_i)$ such that removing the edge separates $a$ from $b$ and $c$ (see Figure~\ref{fig:inside}).
W.l.o.g. we assume that $x_i \in U_j$.
Reorienting $(x_i,y_i)$ connects $U_j$ and the tree containing $z_i$, but also disconnects $U_j$ from the rest of $T^*$.
By orienting $(a,b,c)$ as $\C abc$, we connect $U_j$ with the rest of $T^*$.
To summarize, we connected $T^*$ to another tree, contradicting the maximality of forest $\mathcal F$.
\paragraph{Case 2: $a,b,c \in U_j$ for some $j$}
We denote $U = U_j$.
Below we show that we can either connect $T^*$ to another tree (contradicting the maximality of the forest) or reduce the size of $T^*$ (contradicting the minimality of $T^*$) while still guaranteeing that the number of trees doesn't change and $T^*$ contains the unused triplet $(a,b,c)$.
Since $U$ is not a critical set (since $S$ is a critical set, it is by definition minimal), there exists constraint $\C uvw$ such that $u,v \in U$ and $w \notin U$.
Let $\bbr{\C {x_i}{y_i}{z_i}}_i$ be a set of constraints from $\orient{\Delta}$ such that for every $i$, edge $(x_i,y_i)$ is in $T^*$ and removing $(x_i, y_i)$ separates $w$ from $u$ and $v$.
Let $\tilde T_i$ be the tree containing $z_i$.
\paragraph{Case 2a: Removal of $(u, v)$ separates $a,b,c$ (Figure~\ref{fig:outside_inside})}
There exists a tree edge $(u, v)$ such that $u,v \in U$, $w \notin U$, and w.l.o.g. $(u, v)$ separates $a$ from $b$ and $c$.
Then reorienting $(u, v)$ and $(x_i,y_i)$ and generating edge $(a, b)$ connects $T^*$ to another tree, contradicting maximality of $\mathcal F$.
\paragraph{Case 2b: Removal of $(u, v)$ does not separate $a,b,c$, and removal of $(u, v)$ doesn't separate $x_i,y_i$ from $a,b,c$ (Figure~\ref{fig:outside_outside})}
We reorient $(v,u)$ to $(v,w)$, where $v$ is the node furthest from $a,b,c$) and $(x_i,y_i)$.
Hence, the vertices $y_i, v, w$ (and other vertices connected to them) are disconnected from $T^*$ and connected to $\tilde T$.
Hence, $T^*$ still contains the unused triplet $(a,b,c)$, and the size of the forest doesn't change; however, the size of $T^*$ decreases, contradicting the minimality of $T^*$.
\paragraph{Case 2c: Removal of $(u, v)$ does not separate $a,b,c$, and removal of $(u, v)$ separates $x_i,y_i$ from $a,b,c$ (Figure~\ref{fig:outside_outside_sep})}
We reorient $(u,v)$ to $(v,w)$, where $v$ is the node furthest from $a,b,c$) and $(x_i,y_i)$.
Hence, the vertices $x_i, y_i, v, w$ are disconnected from $T^*$ and connected to $\tilde T$.
Similar to Case 2b, we decrease the size of $T^*$, contradicting the minimality of $T^*$.
In all cases, we show a contradiction, meaning that the maximal forest must have at least $|S|-1$ edges, implying that $S$ is connected.
\end{proof}
\subsection{\texorpdfstring{$k$}{k}-tuple constraints}
We first reduce the problem to the triplet case.
\begin{lemma}
\label{lem:tuple_to_tiplet}
Let $(a_1, a_2, \ldots, a_k)$ be a $k$-tuple.
Then there exists a set of $k-2$ distinct triples $\Delta = \bbr{(a_i^{(t)}, a_j^{(t)}, a_\ell^{(t)})}_{t=1}^{k-2}$ such that for any orientation of $\Delta$ there exists a tree over $a_1, \ldots, a_k$ satisfying all constraints in the orientation.
\end{lemma}
\begin{figure}[t!]
\centering
\input{pics/tuple_tree.tex}
\caption{Lemma~\ref{lem:tuple_to_tiplet}: A tree satisfying a orientation of $\bbr{\C {a_1}{a_2}{a_t}}_{t=3}^{k}$ where $S_o$ is a set of labels $a_t$ satisfying $\C {a_1}{a_2}{a_t}$, $S_1$ is a set of points $a_t$ satisfying $C {a_2}{a_t}{a_1}$ and $S_2$ is a set of points $a_t$ satisfying $\C {a_1}{a_t}{a_2}$.
$T(S_i)$ denotes an arbitrary tree on $S_i$}
\label{fig:tuple_tree}
\end{figure}
\begin{figure*}[t!]
\centering
\input{pics/tuple_lb.tex}
\caption{Theorem~\ref{thm:shatter_lb}: Given tree $T_i$ (satisfying $\orient{t_1}, \ldots, \orient{t_i}$), constraint $\orient{t_{i+1}}$, and $\{a,b\} = t_i \cap t_{i+1}$, we construct tree $T_{i+1}$ satisfying $\orient{t_1}, \ldots, \orient{t_{i+1}}$}
\label{fig:tuple_lb}
\end{figure*}
\begin{proof}
We define $\Delta = \bbr{(a_1, a_2, a_t)}_{t=3}^{k}$ and let $\orient{\Delta}$ be some orientation of $\Delta$.
We partition $a_3, \ldots, a_k$ into three sets depending on which vertex is separated in $(a_1, a_2, a_t)$:
\begin{compactitem}
\item $a_t$ is in $S_1$ when $a_1$ is separated, i.e. $S_1 = \bbr{a_j \mid \C {a_2}{a_j}{a_1} \in \orient{\Delta}}$;
\item $a_t$ is in $S_2$ when $a_2$ is separated, i.e. $S_2 = \bbr{a_j \mid \C {a_1}{a_j}{a_2} \in \orient{\Delta}}$;
\item $a_t$ is in $S_o$ when $a_t$ is separated, i.e. $S_o = \bbr{a_j \mid \C {a_2}{a_2}{a_j} \in \orient{\Delta}}$.
\end{compactitem}
Then the tree shown in Figure~\ref{fig:tuple_tree}, where $T(S_i)$ is any tree over $S_i$, satisfies $\orient{\Delta}$.
\end{proof}
\begin{theorem}
\label{thm:tuples}
Let $|V|$ be a set and $\Delta$ be a set of $k$-tuples on $V$.
If $|\Delta| \geq \left\lceil \frac{|V|-1}{k-2} \right\rceil$, there exists a contradictory orientation of $\Delta$.
\end{theorem}
\begin{proof}
Let $\Delta = \{t_1, \ldots, t_{\ell}\}$ and for each $k$-tuple $t_i$ let $\Delta_i$ be the set of triplets from Lemma~\ref{lem:tuple_to_tiplet}.
Let $M = \cup_i \Delta_i$ (w.l.o.g. we assume that $\Delta_i$ are disjoint since otherwise getting contradiction in the following reasoning is trivial).
We first observe that if we can find a contradictory orientation of $M$, then by Lemma \ref{lem:tuple_to_tiplet} we can construct a contradictory orientation of $\Delta$.
Namely, if $\orient{\Delta}_1, \ldots, \orient{\Delta}_\ell$ is a contradictory orientation of $M$, then for each $i$ we select a tree which is consistent with $\orient{\Delta}_i$.
Therefore, it is enough to show that there exists a contradictory orientation of $M$.
We have $|M| = |\Delta| \cdot (k-2)$ and since $|\Delta| \geq \left\lceil \frac{|V|-1}{k-2} \right\rceil$, we are guaranteed that $|M| \geq |V| - 1$.
Thus, by Theorem \ref{thm:triplets} there exists a contradictory orientation of $\Delta$, thereby concluding the proof.
\end{proof}
\paragraph{Note} For $|\Delta|=1$, we have $|V| - 1 \le k-2$, i.e. $|V| < k$, and hence no $k$-tuple can be constructed.
Allow repeating elements in a tuple trivializes the problem: a contradiction can be achieved by using a constraint of form $\C aba$.
Next, we observe that one cannot achieve a better bound than Theorem~\ref{thm:tuples}, i.e. there exists a set of $k$-tuples of size $\left\lceil \frac{|V|-1}{k-2} \right\rceil - 1$ which doesn't have a contradictory orientation.
\begin{theorem}
\label{thm:shatter_lb}
There exists a set $\Delta$ of $k$-tuples with $|\Delta| = \left\lceil \frac{|V|-1}{k-2} \right\rceil - 1$, which does not have a contradictory orientation.
\end{theorem}
\begin{proof}
Given set $V = \{a_1, \ldots, a_{|V|}\}$, we select $\Delta$ as:
\begin{align*}
\Delta = \Big\{
&(a_1, a_2, \ldots, a_k), \\
&(a_{k-1}, \ldots, a_{2k - 2}), \\
&(a_{2k - 1}, \ldots, a_{3k - 4}), \\
&\quad\quad\ldots \\
&(a_{(|\Delta|-1)(k-2) + 1}, \ldots, a_{|\Delta| (k-2) + 2}) \Big\},
\end{align*}
i.e. $\Delta = \{t_1, \ldots, t_m\}$ where $|t_i|=k$, $|t_i \cap t_{i+1}| = 2$, and $t_i$ and $t_j$ are disjoint for $|i - j| > 1$.
Note that $\Delta$ uses at most $|V|$ points, since
\begin{flalign*}
|\Delta| (k-2) + 2
&= \left(\left\lceil \frac{|V|-1}{k-2} \right\rceil - 1\right) (k - 2) + 2 \notarxiv{\\&}
\le \frac{|V| - 1 - 1}{k-2} (k - 2) + 2
\le |V|
.\end{flalign*}
For any orientation $\orient{\Delta} = \{\orient{t}_1, \ldots, \orient{t}_{|\Delta|}\}$ of $\Delta$, we now construct a tree satisfying $\orient{\Delta}$.
We construct a sequence of trees $T_1, \ldots, T_{|\Delta|}$ such that $T_i$ satisfies all of $\orient{t_1}, \ldots, \orient{t_i}$.
We define $T_1 = \orient{t_1}$.
Then, given $T_i$ and $\orient{t}_{i+1}$, we construct $T_{i+1}$ as shown in Figure~\ref{fig:tuple_lb}.
Since all constraints satisfied by $T_i$ and $\orient{t_{i+1}}$ are satisfied by $T_{i+1}$, then $T_{i+1}$ satisfies $\orient{t_1}, \ldots, \orient{t_{i+1}}$.
\end{proof}
\subsection{Constraints of form \texorpdfstring{$\TW abc$}{[a|b|c]}.}
\label{ssec:3_way_constraints}
In this section, we extend the result from Theorem~\ref{thm:natarajan} to the case when constraints of form $(a|b|c)$ are allowed, i.e. tree $T$ satisfies the constraint if $\lca_T(a,b)=\lca_T(b,c)=\lca_T(a,c)$.
We show exactly the same bound as in Theorem~\ref{thm:natarajan}, which allows us to use other results without changes.
Similarly to Section~\ref{sec:contr_orient}, for an orientation $\overrightarrow \Delta$ and set $S \subseteq V$ we define $E_S = \bbr{(a,b) \mid \C abc \in \overrightarrow \Delta|_S}$.
Additionally, we introduce the following operation to handle $\TW abc$ constraints.
\begin{definition}
Let $[a|b|c] \in \overrightarrow \Delta|_S$ and let $\mathcal E$ be a set of edges. If at least two of the vertices $a,b,c$ are connected by a path in $\mathcal E$, we say that $\mathcal E \cup \{(a,c), (a,b), (b,c)\}$ is a $t$-extension of $\mathcal E$ using $\TW abc$.
\end{definition}
\textbf{Note:} Importantly, the definition requires that two endpoints of the constraint are already connected by existing edges.
Intuitively, if $a$ and $b$ are connected, we can't cut them at the current level.
Hence, we also can't cut $c$ from $a$ and $b$ due to the constraint.
We hence connect $c$ to $a$ and $b$ to show that they can't be cut at the current level.
\begin{definition}
Let $\Delta$ be a set of triplets.
$S$ is \textbf{closed} if there exists an orientation $\orient{\Delta}$ and a sequence $\mathcal E_0, \ldots, \mathcal E_k$, where:
\begin{itemize}
\item $\mathcal E_0 = E_S$,
\item $\mathcal E_{i+1}$ is a $t$-extension of $\mathcal E_i$ for all $i$ using a constraint from $\overrightarrow \Delta|_S$,
\item $\mathcal E_k$ connects $S$.
\end{itemize}
\end{definition}
\begin{lemma}
\label{lem:nonbinary:closed_is_contradictory}
Let $\Delta$ be a set of triplets on $V$.
Then there exists a contradictory orientation of $\Delta$ iff there exists a closed subset of $V$.
\end{lemma}
\begin{proof}
$ $\\
\noindent $\Longleftarrow$: Let $S$ be a closed set. For contradiction, assume that the hierarchical tree exists and consider the first tree node cutting $S$ into $\mathcal U = \{U_1, \ldots, U_\ell\}$. The tree can't cut an edge from $E_S$ (see Lemma~\ref{lem:closed_set_proof}), so $U_i$ are not connected by edges from $E_S$.
Since $S$ is critical, there exists $\orient{\Delta}$ and a sequence $\mathcal E_0, \ldots, \mathcal E_k$ such that $\mathcal E_0 = E_S$, $\mathcal E_k$ connects $S$, and $\mathcal E_i$ is a $t$-extensions of $\mathcal E_{i-1}$ using constraint $\TW{a_i}{b_i}{c_i} \in \overrightarrow \Delta|_S$. Let $\mathcal E_{i^*}$ be the first $t$-extension in the sequence connecting some of the components from $\mathcal U$ (such $i^*$ exists since $E_k$ connects $S$).
Since $\mathcal E_{i^*}$ is a $t$-extension of $\mathcal E_{i^*-1}$ using $\TW{a_{i^*}}{b_{i^*}}{c_{i^*}}$, there exists a path $P$ in $\mathcal E_{i^*-1}$ connecting (w.l.o.g.) $a_{i^*}$ and $b_{i^*}$. This path consists of the following types of edges:
\begin{itemize}
\item Edges from $E_S$. All endpoints of such an edge must belong to the same component from $\mathcal U$.
\item $(a_i,c_i)$, where $(a_i,c_i) = \mathcal E_{i} \setminus \mathcal E_{i-1}$ for $i < i^*$. By our assumption, $\mathcal E_{i^*}$ is the first $t$-extension connecting different components from $\mathcal U$, and hence $(a_i,c_i)$ belong to the same component from $\mathcal U$.
\end{itemize}
%
Hence, all nodes in $P$ lie in the same $U^* \in \mathcal U$, implying $a_{i^*},b_{i^*} \in U^*$.
Since $c_{i^*} \notin U^*$, this leads to a contradiction since all of $a$, $b$ and $c$ must belong to the same component or to different components.
\vspace{1em}
\noindent $\Longrightarrow$: We instead prove the contrapositive: if there is no critical set, then for any orientation $\orient{\Delta}$ we can build a hierarchical tree.
Let the current tree node correspond to the set $S$ of size at least $2$. Since $S$ is not critical, it's not connected after performing all possible $t$-extensions.
Let $\mathcal U = \{U_1, \ldots, U_k\}$ be the connected components after performing all $t$-extensions (note that any maximal sequence of non-trivial contractions results in the same connected components).
We show that splitting $S$ into $\mathcal U$ doesn't violate any constraint.
First, it doesn't violate any constraints of form $\C abc$ since it doesn't cut an edge from $E_S$.
It remains to show that it doesn't violate any constraint of form $\TW abc$.
If $\TW abc$ can be used for $t$-extension, then $a$, $b$ and $c$ must be connected (by definition of $t$-extension and the fact that we performed all possible $t$-extensions) and belong to the same component; hence, their constraints are not violated.
It remains to consider constraints $\C abc$ that can't be used for $t$-extension.
But for such constraints, none of its pair of endpoints is connected, and hence $a$, $b$ and $c$ belong to different components.
Hence, no constraints are violated.
\end{proof}
\section{Conclusion}
In this paper we give almost optimal bounds on the sample complexity of learning hierarchical tree representations of data from labeled tuples in both distributional (PAC-learning) and online case. Our experimental results confirm the convergence bounds predicted by the theory on trees generated from the ImageNet dataset.
\section{Experiments}
\label{sec:experiments}
In this section, we empirically verify our theoretical findings by evaluating the prediction accuracy of binary trees constructed from labeled triplets on the unlabeled triplets from the same distribution.
We consider the binary realizable case, when the triplets are labeled according to a ground-truth binary tree, the binary agnostic case, and the non-binary realizable case.
\paragraph{Tree building algorithm} We first describe in detail our approach for building a tree.
For the agnostic case, the constraints in our experiments are contradictory, since, as shown in Figure~\ref{fig:max_cons}, we encounter a contradiction after sampling $\approx 1.2 n$ constraints.
Hence, we need an approach that handles contradictory constraints.
It's known that the theoretical sample complexity can be achieved by using an Empirical Risk Minimizer~\citep{daniely2015multiclass}.
In our case, this means finding the tree which violates the least number of known constraints.
However, such a problem is NP-hard and is very hard to approximate~\cite{chester2013resolving}.
As shown in Lemma~\ref{lem:closed_set_proof}, the contradiction arises when the tree node encounters a connected component, and hence any partition cuts at least one edge.
When there are multiple connected components, we cut them from each other.
Otherwise, we cut the minimal number of edges at every layer, which is known to achieve $O(n)$ approximation.
\begin{figure}[t!]
\centering
\includegraphics[width=\ifarxiv{0.4}\else{0.7}\fi\columnwidth]{pics/max_cons.png}
\caption{For the agnostic case with randomly generated vectors, for each number of vectors, we show the number of uniformly sampled triplets on these vectors (oriented according to the distances in the triplets) until we reach a contradiction, averaged over $10$ trials.
There is a clear linear dependence with factor $\approx 1.2$}
\label{fig:max_cons}
\end{figure}
\paragraph{Datasets}
For the realizable case, we perform experiments on randomly generated trees and on
ImageNet~\citep{deng2009Imagenet} hierarchy\footnote{\url{https://github.com/waitwaitforget/ImageNet-Hierarchy-Visualization}}.
We preprocess the ImageNet hierarchy as follows:
\begin{itemize}
\item for non-binary tree experiments: the full hierarchy (48,860 points);
\item for binary tree experiments: a sample of $256$ leaves that induce a binary subtree.
\end{itemize}
For the agnostic case, we consider 2 datasets: 1) randomly sampled vectors from the uniform distribution on $[0,1]^{100}$ and 2) Spambase~\citep{Dua:2019} dataset containing feature vectors for $4601$ different emails for the purpose of spam detection.
\begin{figure}[p]
\centering
\begin{subfigure}[t]{\ifarxiv{0.48\columnwidth}\else{\columnwidth}\fi}
\includegraphics[width=\columnwidth]{pics/Random_PCA_realizable_errorbars.png}
\caption{Prediction error depending on the number of samples for a random tree with $n\in \{100, 500\}$ nodes, and the ImageNet hierarchy.
For each dataset, we average the results over 10 runs, and the error bars correspond to $10\%$ and $90\%$ quantiles.}
\label{fig:scatter}
\end{subfigure}
\hfill
\begin{subfigure}[t]{\ifarxiv{0.48\columnwidth}\else{\columnwidth}\fi}
\includegraphics[width=\columnwidth]{pics/linear_dep.png}
\caption{For random trees with $n$ nodes, we show dependence of $k \cdot \err$ on $k$, where $k$ as the ratio of number of samples to $n$.
As Theorem~\ref{thm:natarajan_main} indicates, this number is close to a constant for different $n$ and $k$. Each data point shows the mean values over $10$ runs.}
\label{fig:const}
\end{subfigure}
\caption{Binary Realizable case}
\end{figure}
\begin{figure}[p]
\centering
\ifarxiv
\includegraphics[width=0.45\columnwidth]{pics/spambase_and_random_identity.png}
\else
\includegraphics[width=0.65\columnwidth]{pics/spambase_and_random_identity.png}
\fi
\caption{Agnostic case. Prediction error depending on the number of samples. We sample $n$ random $100$-dimensional vectors and a subset of the Spambase dataset of size $n$.
}
\label{fig:spambase_random}
\end{figure}
\todo{Rearrange plots?}
\begin{figure}[p]
\centering
\includegraphics[width=\ifarxiv{0.4}\else{0.8}\fi\columnwidth]{pics/imagenet_full.png}
\caption{Non-binary Realizable case. For full ImageNet hierarchy, we show the dependence of $k \cdot \err$ on $k$, where $k$ is the ratio of samples to nodes ($n$).
Similarly to Figure~\ref{fig:const}, this number is close to a constant for various $k$. Error bars correspond to $10\%$ and $90\%$ quantiles over $10$ runs.}
\label{fig:imagenet_full}
\end{figure}
\paragraph{Binary Realizable case}
Given a ground-truth tree, we sample triplets from this tree uniformly at random.
Since the orientations for these triplets are not contradictory, we can construct a tree and make predictions according to the tree.
We first build a non-binary tree using the algorithm described in~\citet{ASSU81}, and then binarize it by replacing each non-binary node with a random binary tree on its children.
For this approach, Figure~\ref{fig:scatter} shows the dependence of the error rate on $k$, where $k$ is the ratio of the number of samples to the number of labels.
The results imply that the error rate depends on $k$ and is independent of the number of leaves or other properties of the ground-truth tree.
From Theorem~\ref{thm:natarajan_main} we know that the sample complexity is roughly proportional to $\frac{n}{\varepsilon}$, and hence we expect $\varepsilon \cdot k = \frac{\varepsilon}{n} \cdot n_{\text{samples}}$ to be approximately constant.
Figure~\ref{fig:const} confirms this hypothesis since $\varepsilon \cdot k$ is approximately $0.4$ for various values of $n$ and $k$.
\paragraph{Agnostic case}
For this scenario, we assume that the input is vectors in the Euclidean space, and we generate triplet constraints as follows.
Given a triplet of vectors $(a, b, c)$, we create constraint $\C abc$ if $\|a - b\| \le \min(\|a-c\|, \|b-c\|)$.
Such constraints can be contradictory if the dataset is not hierarchical, meaning that the setting is agnotic.
Similarly to the realizable case, Figure~\ref{fig:spambase_random} shows the dependence of the error rate on $k$, where $k$ is the ratio of the number of samples to the number of labels.
Since random vectors don't have any hierarchical structure, known samples don't provide sufficient information about the unseen samples, and hence the error rate is close to trivial $\nicefrac 23$ regardless of $k$.
On the other hand, since Spambase feature vectors have a hierarchical structure, they error rate on this dataset is significantly lower and slowly decreases with $k$.
\paragraph{Non-binary realizable case}
In this experiment on the full ImageNet hierarchy, constraints of type $\C abc$ are present, and hence we verify the theoretical result from Section~\ref{ssec:3_way_constraints}.
To handle these constraints, when partitioning a node using connected components, for each connected component we create a child of the node, i.e. we don't binarize the tree.
As shown in Figure~\ref{fig:imagenet_full}, similarly to the binary tree case, the product of the error rate and the number of constraints is approximately constant.
Note that the value in Figure~\ref{fig:imagenet_full} (0.2) is lower than in the value in Figure~\ref{fig:const} (0.4).
This is explained by the large number of $\TW ijk$ constraints in the hierarchy (since most of the nodes are separated at the top level of the hierarchy), and the fact that, when no samples are provided, all constraints are predicted as $\TW ijk$.
\section{Introduction}
The algorithmic problem of constructing hierarchical data representations has been of major importance for many decades, due to its applications in statistics~\citep{W63,GR69}, entomology~\citep{MS57}, plant biology~\citep{S48}, genomics~\citep{ESBB98} and other domains.
Efficient collection of labeled data is a problem of key importance for construction of hierarchical data representations. In this paper we consider the problem of constructing tree representations of data from labeled samples, focusing on understanding the optimal number of samples required for this task.
The most basic type of a label that allows one to construct a tree representation consists of a triplet of points $(x, y, z)$ labeled according to the induced hierarchical structure within the triplet.
For example, given images of a cat, a dog, and a plane, the label would describe the cat and the dog as being more similar to each other than to the plane.
This ``odd one out'' type of label is the simplest one to collect in a crowdsourcing setting.
In this paper, we focus on understanding the number of such labeled samples required in order to construct a tree representation of the underlying data, which enables one to accurately predict subsequent labels in the future. This is then further generalized to include larger labeled subsets of data. Examples of possible trees consistent with certain triplet and tuple labelings are shown in Figure~\ref{fig:consistency}.
\ifarxiv
\newcommand{0.22\textwidth}{0.48\textwidth}
\else
\newcommand{0.22\textwidth}{0.22\textwidth}
\fi
\begin{figure}[t!]
\centering
\begin{subfigure}[b]{0.22\textwidth}
\centering
\input{pics/constraint_sat_1.tex}
\caption{Triplet labelings and a tree consistent with the labelings.}
\label{fig:constraint_sat_1}
\end{subfigure}
\ifarxiv \hspace{1em} \else \hfill \fi
\begin{subfigure}[b]{0.22\textwidth}
\centering
\input{pics/constraint_sat_2.tex}
\caption{$4$-tuple labelings and a tree consistent with the labelings.}
\label{fig:constraint_sat_2}
\end{subfigure}
\hfill
\caption{An example for the triplet and $k$-tuple setting, where two labeled queries and a tree consistent with the queries are shown.
The tree satisfies all hierarchical relations of both labeled queries.
For example, in Figure~\ref{fig:constraint_sat_1}, the lowest common ancestor of $a$ and $b$ (denoted $\lca(a, b)$) is below $\lca(a,c)$ and $\lca(b, c)$, as in its first labeled query.}
\label{fig:consistency}
\end{figure}
\subsection{Our Results}
Let $n$ be the number of points in the dataset.
We present results in two settings: PAC learning and online learning. In both cases, our objective is to build a classifier that given access to labeled tuples can predict labels for the subsequent tuples with high probability.
\paragraph{PAC learning} In the \emph{Probably Approximately Correct (PAC) learning} setting~\citep{V84}, the tuples are generated from a fixed unknown distribution $\mathcal D$.
The goal is to predict their labels with probability at least $1 - \epsilon$, i.e. achieve the error rate at most $\epsilon$, while providing this guarantee with overall probability at least $1 - \delta$.
We distinguish between the two cases: in the \emph{realizable} setting it is assumed that the labels are consistent (i.e. there exists a tree that respects all observed labels), while in the \emph{agnostic} PAC-learning setting, such a tree does not necessarily exist.
In this setting, the goal is to predict the labels with probability at least $1 - \epsilon - \epsilon_{T^*}$, where $\epsilon_{T^*}$ is the smallest prediction error among all trees on the set of points.
In the PAC-learning setting, our main result is as follows:
\begin{theorem}[Informal version of Theorem~\ref{thm:natarajan_main}]
\label{thm:pac-learning-intro}
The sample complexity of $(\epsilon, \delta)$-PAC-learning hierarchically labeled tuples is $\Theta(\frac{n}{\epsilon} \cdot \polylog(\frac{1}{\epsilon}, \frac{1}{\delta}))$ in the realizable settings.
Furthermore, in the agnostic setting, the complexity is $\Theta(\frac{n}{\epsilon^2} \cdot \polylog(\frac{1}{\epsilon}, \frac{1}{\delta}))$.
\end{theorem}
This result also holds for non-binary trees.
\paragraph{Online learning}
In the \emph{online learning} setting, it is no longer assumed that the tuples are generated from a fixed distribution.
The tuples can be selected to arrive in an adversarial order.
The accuracy is evaluated sequentially, counting the overall number of mistakes made by the algorithm throughout the sequence.
In the realizable setting, it is assumed that the tree generating the labels is fixed in advance and all labels seen by the algorithm are consistent with this tree.
In the agnostic setting, this is no longer assumed, similarly to the PAC-learning scenario.
Our main result in this setting is:
\begin{theorem}[Informal\arxiv{ version of Theorem~\ref{thm:littlestone_main_formal}}]
\label{thm:online_main}
On a sequence of triplets of length $T$, the number of mistakes made by an online learning algorithm for predicting their hierarchical structure is $\Theta(n \log n)$ in the realizable case. In the agnostic case, the number of mistakes is at most $O(\sqrt{T n \log n \log (T)})$ and at least $\Omega(\sqrt{T n \log n})$ larger than the optimum number of mistakes achieved by any tree.
\end{theorem}
A summary of our results is shown in Table~\ref{table:results} (which hold for both triplet queries, and more generally to $k$-tuples for constant $k$).
\def1{1.5}
\begin{table}[ht!]
\centering
\begin{tabular}{ |l|c| }
\hline
& Number of $k$-tuple labels for constant $k$ \\
\hline
PAC realizable* & $\Theta(\frac{n}{\epsilon} \cdot \polylog(\frac{1}{\epsilon}, \frac{1}{\delta}))$ \\
\hline
PAC agnostic* & $\Theta(\frac{n}{\epsilon^2} \cdot \polylog(\frac{1}{\epsilon}, \frac{1}{\delta}))$ \\
\hline
Online realizable** & $\Theta(n \log n)$ \\
\hline
Online agnostic** & \makecell{$O(\sqrt{T n \log n \log (T)})+\mathrm{OPT} $, \\ $\Omega(\sqrt{T n \log n}) + \mathrm{OPT}$} \\
\hline
\end{tabular}
\ifarxiv{\caption{[*] Binary trees are considered in Theorem~\ref{thm:natarajan_main}, and non-binary trees in Theorem~\ref{thm:non-binary}. [**] Binary trees are considered in Theorem~\ref{thm:littlestone_main_formal}, and the non-binary case follows from Theorem~\ref{thm:non-binary}.}\label{table:results}}\else{\caption{Summary of sample complexities in each setting}\label{table:results}}\fi
\end{table}
\def1{1}
\subsection{Our Techniques}
\label{ssec:our_techniques}
It is known (see e.g.~\citet{DanielySBS15}) that the PAC-learning and online learning complexities are nearly tightly described in terms of the Natarajan~\citep{N89} and Littlestone~\citep{Littlestone87} dimensions respectively. Hence in this paper we focus on giving tight bounds on these two values. Since the exact definitions are technical, we refer the reader to to Definition~\ref{def:natarajan} for the precise definition of Natarajan dimension and the full version for the Littlestone dimension.
\paragraph{Natarajan dimension}
In the PAC-learning setting, VC-dimension~\citep{VC71} can be used to capture query complexity for binary classification problems.
The problem of labeling tuples considered in this paper corresponds to multiclass classification since even for triplets there are three ``odd one out'' labels possible.
A generalization of VC-dimension which captures this scenario is the Natarajan dimension~\citep{N89}. While it can be shown via a simple probabilistic argument that this dimension is $O(n \log n)$, we argue that the exact bound is in fact linear in the number of points, which implies Theorem~\ref{thm:pac-learning-intro}.
In this section, we focus on triplet constraints; \ifarxiv{Lemma~\ref{lem:tuple_to_tiplet} shows how to reduce the $k$-tuples to triplets. }\else{in the full version, we show how to reduce $k$-tuples to triplets. }\fi
\begin{comment}
Note that each triple can be labeled with three possible ``odd one out'' labels, i.e. for a triple $(x,y,z)$ a potential labeling is $((x,y),z)$, corresponding to the fact that in the tree the least common ancestor of $x$ and $y$ should be lower than the least common ancestor of all three points.
Hence we have a multiclass learning problem (in the case of $k$-tuples above the number of classes is $2^{O(k)}$, corresponding to all possible binary trees with $k$ leaves).
In order to bound the sample complexity we use the following version of the definition of Natarajan dimension adapted to our setting:
\begin{definition}[Natarajan shattering]
Let $S = \{\{x_1, y_1, z_1\}, \dots \{x_k, y_k, z_k\}\}$ be a set of triples of points. The hypothesis set $H$ \emph{Natarajan shatters} $S$ if for every triple $\Delta \in S$ there exist two edges $e_1(\Delta) \neq e_2(\Delta)$ within this triple, such that for every subset $T \subseteq S$ the hypothesis space $H$ allows us to select an edge $e_3(\Delta)$ for every $\Delta \in S$ so that:
\begin{compactitem}
\item For every $\Delta \in T$ it holds that $e_3(\Delta) = e_1(\Delta)$,
\item For every $\Delta \in S \setminus T$ it holds that $e_3(\Delta) = e_2(\Delta)$.
\end{compactitem}
The Natarajan dimension (denoted as $d(H)$) of a hypothesis class $H$ is defined as the size of the largest cardinality of a set which can be Natarajan shattered.
\end{definition}
\end{comment}
In order to bound the sample complexity, we use a version of the definition of Natarajan dimension adapted to our setting.
Given a triple $\Delta = (a, b, c)$, we denote an ``odd one out'' constraint separating $c$ from $a$ and $b$ as $\C abc$.
For each triplet, there are $3$ possible constraints, i.e. $3$ possible labels.
We are now ready to define the notion of Natarajan Shattering.
\begin{definition}[Natarajan Shattering]
\label{def:natarajan_shattering}
Let $S = \{(a_1, b_1, c_1), \dots (a_k, b_k, c_k)\}$ be a set of triples of points. We say $S$ is \emph{Natarajan shattered} if for every triple $(a_i, b_i, c_i) \in S$ there exist two distinct constraints $f_1(a_i, b_i, c_i)$, $f_2(a_i, b_i, c_i)$ (e.g. $f_1(a_i, b_i, c_i) = \C{a_i}{c_i}{b_i}, f_2(a_i, b_i, c_i) = \C{a_i}{b_i}{c_i}$) on this triple, such that for every subset $R \subseteq S$ there is a hierarchical tree $T$ for which:
\begin{compactitem}
\item For every $\Delta \in R$ it holds that $T$ satisfies $f_1(\Delta)$,
\item For every $\Delta \in S \setminus R$ it holds that $T$ satisfies $f_2(\Delta)$.
\end{compactitem}
The Natarajan dimension of the hierarchically labeled tuples is defined as the size of the largest cardinality of a set which can be Natarajan shattered.
\end{definition}
Intuitively, for every triplet in $S$, we fix two labels (out of three possible).
The set is shattered if all possible $2^{|S|}$ combinations of these labels on $S$ are realizable by the hypothesis space.
\begin{example}
Consider a point set, consisting of $4$ points: $a, b, c, d$. Consider two sets of triples:
\begin{itemize}
\item $S_1 = \{(a, b, c), (b, c, d)\}$
\item $S_2 = \{(a, b, c), (b, c, d), (c, d, a)\}$.
\end{itemize}
Note that for $S_1$ we can select $f_1(a, b, c) = \C abc$, $f_2(a, b, c) = \C bca$ and also $f_1(b,c,d) = \C bcd, f_2(b, c, d) = \C cdb$. Then for any of the four subsets of $S_1$ we can create a tree which is consistent with the $f_1$ choices on the subset and consistent with the $f_2$ choices otherwise. We show all four resulting trees on Figure~\ref{fig:shattering}.
\begin{figure}[t!]
\centering
\input{pics/shattering.tex}
\caption{Shattering a set of two triplets $\{(a, b, c), (b, c, d)\}$.}
\label{fig:shattering}
\end{figure}
It is less straightforward, however, to check that for the set $S_2$, no possible selection of $f_1, f_2$ for each of its triangles can be used to satisfy the definition of Natarajan shattering.
This follows from our key technical result.
\end{example}
\begin{theorem}\label{thm:natarajan-intro}
The Natarajan dimension of hierarchically labeled triplets on $n$ elements is $n - 2$.
\end{theorem}
The proof is based on identifying subsets with a certain property, which we refer to as \emph{closed sets} (Definition~\ref{def:closed_set}) which prevent construction of a consistent tree.
We then further characterize these sets in terms of easier to define \emph{critical sets} (Definition~\ref{def:critical_set}).
We prove that for $n-1$ elements a critical set must exist, which, combined with the fact that a set of consistent $n-2$ pairs of constraints exists, gives a tight bound for the Natarajan dimension.
\paragraph{Littlestone dimension}
Next, we show a tight bound on the Littlestone dimension. For the purpose of the introduction, it is convenient to view the Littlestone dimension in our setting as follows. Assume that we have two players Alice and Bob who play the following game for $t$ iterations. Initially, there is an empty set of constraints $C$. In every iteration, Alice passes Bob a triplet from the set of points $V$, and two distinct elements from this triplet. For example, suppose that the triplet is $(a,b,c)$ and the elements chosen are $a,b$. Then Bob chooses one of the two constraints where one of the chosen elements is the ``odd one out'', i.e. $\C bca$ or $\C acb$ and adds it to $C$.
The Littlestone dimension is the maximum number of rounds $t$ for which Alice has a strategy that results in $C$ admitting a tree that satisfies all constraints in $C$, regardless of Bob's strategy.
\begin{theorem}
\label{thm:littlestone_intro}
The Littlestone dimension of hierarchically labeled triples is $\Theta(n \log n)$.
\end{theorem}
To prove the lower bound on the Littlestone dimension, we need to describe Alice's strategy of producing an adaptive sequence of queries of size $\Omega(n\log{n})$ such that for any choice of Bob's query answers there is a hierarchical tree consistent with the query answers at the end of the sequence. The sequence we construct is intuitively a sort tournament on $V$, for which there is always some ordering $v_1,\dots,v_n$ on the point set $V$ such that if we place the points in order in a hierarchical tree whose internal nodes are shaped like a path, this tree satisfies all constraints.
\paragraph{Non-binary trees} When all constraints are of type ``odd one out'', it suffices to consider binary trees: if a non-binary tree is consistent with the constraints, then its binarization (i.e. we replace a node with $\ell$ children with an arbitrary binary tree on these children) is also consistent.
However, one may generalize the problem to non-binary trees by considering constraints of the form \textit{``points $i,j$ and $k$ must be split simultaneously''}.
For the PAC-learning setting, in \ifarxiv{Appendix~\ref{app:missing_proofs}}\else{the full version}\fi, we consider and solve this setting by extending Theorem~\ref{thm:pac-learning-intro} appropriately.
In the online learning setting, Theorem~\ref{thm:online_main} generalizes as well -- the same lower bound holds for the non-binary setting and the upper bound generalizes trivially.
\subsection{Related Work}
An early work by~\citet{ASSU81} shows that given access to $m$ consistently labeled triples on $n$ vertices, the tree satisfying them can be constructed in $O(mn)$ time. This was improved to $O(m \log^2 n)$ time using the techniques in~\citet{HKW99, HLT01}, and to $O(\min(n^2,m\log{n})+\sqrt{mn}\log^{2.5}(n))$ by~\citet{Thorup99}.
Compared with our settings where we are given queries from some distribution and aim for a bounded error rate on unseen triplets, a related line of work considers the problem of exactly reconstructing the entire tree using adaptively or non-adaptively chosen triplet queries (see e.g.~\citet{KLW96,EK18}).
For non-adaptive queries, a lower bound of $\Omega(n^3)$ queries precludes any non-trivial results~\citep{EK18}.
For adaptive queries, $\Theta(n \log n)$ consistent queries and running time are necessary and sufficient for the construction of the tree~\citep{KLW96}.
This can be extended to handle a mix of independently correct labels and adversarial noise, resulting in similar bounds for constant noise levels~\citep{EK18}.
In the case when labeled data is allowed to be inconsistent, minimizing the number of disagreements with labeled triplets is known to be hard to approximate~\citep{CDW13}.
Recent work~\citet{CMA21} gives algorithms for maximizing the number of agreements between the tree and the labeled data. In a related line of work, results are known for optimizing certain objectives while respecting triplet constraints~\citep{CNC18}.
\section{Near-Linear Algorithm for Constructing an HCT for Triplet Constraints}
In this section, we show how to leverage our new perspective on triplet constraint satisfaction to design a very simple $O(m\log^2{n}+n\alpha(m,n))$ time algorithm for constructing an HCT consistent with a set of $m$ given triplet constraints over $n$ points.
This significantly improves the previous results of \orr{add here some related work stuff} \danny{the citation is \cite{Inferring_a_tree_from_lowest_common_ancestors_with_an_application_to_the_optimization_of_relational_expressions} - but I think this should be moved to the introduction.}
\begin{theorem}
\label{thm:htc_construction_alg}
Let $V = \{v_1,\dots,v_n\}$ be a set of points, and $\bar{\Delta} = \{(a_i|b_ic_i)\}_{i=1}^m $ a set of triplet constraints. There is a deterministic $O(m\log^2{n}+n\alpha(m,n))$ time algorithm which outputs a binary hierarchical clustering tree consistent with all constraints in $\bar{\Delta}$, or outputs that no such tree exists.
\end{theorem}
In our algorithm, we use the decremental Minimum Spanning Forest (MSF) data-structure of \cite{HLT01}:
\begin{theorem}[\cite{HLT01} Theorem 6]
\label{thm:decrement_msf}
There exists a deterministic decremental MSF data-structure that can be initialized on a graph with $n$ vertices and $m$ edges and supports any sequence of deletions in $O(m\log^2{n})$ total time.
\end{theorem}
While we use the the data-structure of \cite{HLT01} in an almost black-box manner, we need to note a few very simple facts regarding it for our algorithm. Whenever an edge in the maintained MFS is deleted, a single replacement edge is found and added to the MSF (unless no replacement edge exists), and the rest of the forest remains unchanged. When a non-forest edge is deleted, the maintained MSF is unchanged. Whenever a deletion in the MSF occurs, the data-structure reports the replacement edge that was chosen. We can augment the data-structure to return after a deletion (a) the heaviest edge in the new MSF, (b) which (if any) vertices became isolated after the deletion, and (c) the number of connected components in the MSF in the following manner - since at most two edges are changed in the maintained MSF during a deletion, this augmentation can be trivially implemented by (a) maintaining a maximum heap on the edges of the maintained MFS, which can be done in $O(\log{n})$ time per deletion, (b) maintaining a counter for each vertex, which contains its degree, which can be done in $O(1)$ time per deletion, and (c) a counter of the number of edges in the MSF after a deletion, which is decreased by one each time a deletion of a MSF edge is performed but a replacement edge was not found. We also note that the data-structure works for multi-graphs. \orr{Move to appendix and expand}
Next, we describe our algorithm for constructing an HTC satisfying the constraints of $\bar{\Delta}$, or rejects if no such tree exists. First, we construct a weighted multi-graph $G$ on $n$ vertices and $m$ edges from $\bar{\Delta}$ in the following manner: For each $(a_i|b_ic_i)$, we add the edge $\{b_i,c_i\}$ with weight $1$, and an edge $\{a_i,b_i\}$ with weight $2$. For convenience, we call the set of edges of weight $1$ \emph{blue edges}, the edges of weight $2$ \emph{red edges}, and denote these sets $E_{\mathrm{blue}},E_{\mathrm{red}}$ respectively. For each such $\{b_i,c_i\}$ and $\{a_i,b_i\}$ added, we say that the edges are coupled and maintain a mapping $M$ that maps each $\{b_i,c_i\}$ to its coupled $\{a_i,b_i\}$.
We initialize the data-structure of Theorem~\ref{thm:decrement_msf} on $G$, which we denote by $A(G)$. At the first phase of the algorithm, we run the Cut-Inter-Component-Edges sub-procedure, detailed in the next paragraph, in iterations $j=1,\dots,...$ until either the sub-procedure rejects (in which case, we output that no HTC satisfying the constraints exists) or the graph of $A(G)$ contains only isolated nodes. We denote the $j$'th iteration of this phase by $\StepOne{j}$, and $L_j$ the list returned by the Cut-Inter-Component-Edges sub-procedure run in this iteration. Let $r$ be the number of iterations $\StepOne{1},\dots,\StepOne{r}$ of the first phase.
\paragraph{Cut-Inter-Component-Edges sub-procedure:} First, we initialize a linked list $\mathrm{Del} = \emptyset$. Let $e_1$ be the heaviest edge in the MSF of $A(G)$ at the start of the sub-procedure. We proceed in iterations until the heaviest edge in the MSF is a blue edge. At the start of the $i$'th step, if the heaviest edge $e_i$ is a red edge, we delete $e_i$ from $A(G)$ and add its coupled edge $e'_i$ to $\mathrm{Del}$, marking it for later deletion, and to the end of the $L$. If $e_i$ is a red edge, then we instead remove the edges in $\mathrm{Del}$ marked for deletion $e'_1,\dots,e'_{i-1}$ from $A(G)$ and return the list $L=\mathrm{Del}$. This concludes the sub-procedure.
After the end of the first phase of the algorithm, we construct an HTC $T^*$ in the following manner: We initialize $T^*$ to be a collection of isolated vertices $v_1,\dots,v_n$ (one for each point), and initialize a union-find data-structure $U$ where each vertex $v_i$ is in a separate set.
For $j=r\dots,1$, where the $j$'th iteration is denoted as $\StepTwo{j}$ we perform the following: let $\{x_{1},y_{1}\},\dots,\{x_{k},y_{k}\}$ be the edges of $L_j$.
For $i=1,\dots,k$, we check whether $U$ the set of $x_{k-i}$ and the set of $y_{k-i}$ are the same. If they are not, we perform a union operation in $U$ between $x_{k-i}$ and $y_{k-i}$, add a new vertex $t_i$ to $T^*$, and connect in $T^*$ both the root of the tree containing $x_{k-i}$ and the root of the tree containing $y_{k-i}$ as children of $t_i$.
Let $c$ be the number of trees in $T^*$ at the end of $\StepTwo{j}$, and $T_1,\dots,T_c$ the trees of $T^*$ at this time (numbered arbitrarily). If $c > 1$ we add new vertices $t'_1,\dots,t'_c$ to $T^*$, and for each $i < c$ connect in $T^*$ the vertices $t'_{i+1}$ as a child of $t'_{i}$, and the root of $T_i$ as a child of $t'_i$. Finally, we output $T^*$.
\paragraph*{Correctness:}
\begin{lemma}
\label{lem:alg_terminates}
The algorithm terminates after $O(m\log^2{n}+n\alpha(m,n))$ time.
\end{lemma}
\begin{proof}
We can bound the running time of the first phase by $O(m\log^2{n}+n)$, since we all deletion operations on $A(G)$ have a total running time of $O(m\log^2{n})$, and we otherwise perform $O(m+n)$ elementary operations for maintaining supporting data-structures such as $L$ and $\mathrm{Del}$. In the second phase, we perform at most $O(m+n)$ operations on $U$, costing us $O((m+n)\alpha(m,n)))$, as well as performing $O(m+n)$ of maintaining supporting data-structures.
\end{proof}
Before proving correctness and soundness, we recall that by Lemma~\orr{todo: ref}, if $\bar{\Delta}$ is satisfiable by an HTC if and only if for any $H'_{blue} \subseteq E_{\mathrm{blue}}$ and their coupled edges $H'_{red} \subseteq E_{\mathrm{red}}$, then for $S = V(E')$, the graph $G[S]$ does not contain a spanning tree on the blue edges. \orr{this needs a proof very similar to the one we have in the triplet part}
\begin{lemma}[Soundness]
\label{lem:alg_soundness}
If the algorithm rejects, then there exists no HTC which satisfies all constraints of $\bar{\Delta}$.
\end{lemma}
\begin{proof}
Assume that the algorithm rejects, meaning that for some $j^*$, in the start of $\StepOne{j^*}$ the heaviest edge of the MSF of $A(G)$ is blue. In particular, since the graph is not a collection of isolated vertices, the blue edges in $A(G)$ at the start of $j^*$ have a connected component $S \subseteq V$ which contains more than one vertex, composed by some blue edges $\{x_1,y_1\},\dots,\{x_k,y_k\}$.
We note that for each of their coupled red edges $\{x'_1,y'_1\},\dots,\{x'_k,y'_k\}$, both $x'_i$ and $y'_i$ must be in $S$ - Otherwise, by construction, $\{x_i,y_i\}$ and $\{x'_i,y'_i\}$ share a vertex (w.l.o.g $x_i=x'_i$), and if $y'_i$ is contained in a different connect component of the blue edges, then the heaviest edge in the MSF of $A(G)$ at the start of $j^*$ must be a red edge, which is a contradiction.
Therefore, $S$ contains all endpoints of $\{x_1,y_1\},\dots,\{x_k,y_k\}$ and $\{x'_1,y'_1\},\dots,\{x'_k,y'_k\}$, and by Lemma~\orr{todo: ref} this implies that the constraints of $\bar{\Delta}$ are not satisfiable by an HTC.
\end{proof}
Before completing the proof of correctness, we prove a few useful invariants of the algorithm.
\begin{lemma}
\label{lem:step1_cc_is_step2_backwards}
For any $1 \leq i \leq r$, At the start of $\StepTwo{i}$, the set of each vertex $v$ in $U$ is its blue edged connected component in $A(G)$ at the start of $\StepOne{r-i+1}$
\end{lemma}
\begin{proof}
Recall that since the algorithm does not reject, $\bigcup_i L_i$ is the set of all blue edges in the initial graph $G$. For any $0 \leq i \leq r$, at steps $\StepOne{1},\dots,\StepOne{r-i+1}$ we removed $L_1,\dots,L_{r-i+1}$, meaning that the remaining blue edges are exactly $L_{r-i},\dots,L_{r}$. In $\StepTwo{1},\dots,\StepTwo{i}$, we process each blue edge $\{x_j,y_j\}$ in $L_{r-i},\dots,L_{r}$ and union the sets of $\{x_j,y_j\}$ (if they are not already in the same set), which implies that the sets in $U$ are exactly these blue connected components.
\end{proof}
\begin{lemma}
\label{lem:deleted_red_is_intercomponent}
If a red edge $\{x,y\}$ is deleted during $\StepOne{i}$, then the vertices $x$ and $y$ do not have a path in $E_{\mathrm{blue}}$ at the start of $\StepOne{i}$.
\end{lemma}
\begin{proof}
Recall that if $\{x,y\}$ is a red edge that is deleted during $\StepOne{i}$, then it is in the MSF of $A(G)$ at some time during $\StepOne{i}$. In addition, no blue edge is deleted between the start of $\StepOne{i}$ and that time (blue edges are only deleted near the end of a step). Therefore, there is no blue path between $a$ and $c$ at the start of $\StepOne{i}$; Otherwise, $\{x,y\}$ could be replaced by a blue edge while maintaining the same connected components, reducing the total weight of the MSF, contradiction to its minimality.
\end{proof}
\begin{lemma}[Correctness]
\label{lem:alg_correctness}
If the algorithm does not reject, it outputs an HTC $T^*$ satisfying all constraints of $\bar{\Delta}$.
\end{lemma}
\begin{proof}
Assume by contradiction that some constraint $(a|bc) \in \bar{\Delta}$ is unsatisfied by $T^*$, and let $i$ such that $\{a,b\} \in L_i$. By Lemma~\ref{lem:deleted_red_is_intercomponent} the red edge $\{a,c\}$ must be an inter-component edge in the blue connected components of $\StepOne{i}$ This implies that at the start of $\StepOne{i+1}$, $a$ is in a different blue connected component than both $b,c$. By Lemma~\ref{lem:step1_cc_is_step2_backwards}, in $\StepTwo{r-i+1}$ is $b,c$ are in the same set in $U$, but $a$ is not in this set. By construction of $T^*$, this implies that $b,c$ are contained in a subtree which does not contain $a$, meaning that $(a|bc)$ is satisfied, contradiction.
\end{proof}
\subsection{Extension to $k$-constraint satisfaction}
In this subsection, we show how to extend our algorithm to a near-linear algorithm for computing an HTC for $k$-hierarchical constraints.
\begin{theorem}
Let $V = \{v_1,\dots,v_n\}$ be a set of points, and $\bar{\Delta} = \{T_1,\dots,T_l\}_{i=1}^m $ a set of $k$-hierarchical constraints. There is a deterministic $O(mk\log^2{n}\log{k}+n\alpha(m\log{k},n))$ time algorithm which outputs a binary hierarchical clustering tree consistent with all constraints in $\bar{\Delta}$, or outputs that no such tree exists.
\end{theorem}
We reduce to the triplet constraint algorithm of Theorem~\ref{thm:htc_construction_alg}.
\begin{lemma}[TODO:cite]
\label{lem:define_tree_by_constraints}
For an HTC $T$ with $t$ leaves, there exists a set of triplet constraints $\{a_i|b_ic_i\}_{i=1}^{O(t\log{t}}$ such that $T$ satisfies all constraints in $\bar{\Delta}_T$, and no other tree $T'$ on $t$ leaves satisfies $\bar{\Delta}_T$. Such a set $\bar{\Delta}_T$ can be computed in $O(t\log{t}$ time.
\end{lemma}
\begin{remark}
We note that the size of the input is $O(mk\log{n}+n)$, \orr{write better}
\end{remark}
Let $\widetilde{\Delta} = \bigcup_{i=1}^l \Delta_{T_i}$, where $\Delta_{T_i}$ is a set of size $O(k\log{k}$ uniquely defining $T_i$ of Lemma~\ref{lem:define_tree_by_constraints}. We run the algorithm of Theorem~\ref{thm:htc_construction_alg} on $\widetilde{\Delta}$.
\begin{lemma}
If the algorithm rejects, then there exists no HTC which satisfies all constraints of $\bar{\Delta}$. If the algorithm does not reject, it outputs an HTC $T^*$ satisfying all constraints of $\bar{\Delta}$.
\end{lemma}
\begin{proof}
By Lemma~\ref{lem:define_tree_by_constraints}, for any $0 \leq i \leq l$ the constraint defined by $T_i$ is equivalent to the set of constraints $\bar{\Delta}_T$ \orr{is this clear?}. Correctness immediately follows from Lemma~\ref{lem:alg_correctness} and Lemma~\ref{lem:alg_soundness}.
\end{proof}
\section{PAC-learning and Natarajan Dimension}
\label{sec:pac}
In this section, we present tight sample complexity bounds for PAC learning for $k$-tuple constraints.
Recall that the set $\Delta = \{t_i\}_{i=1}^n$ of $k$-tuples is N-shattered if for every $k$-tuple $t_i$ we can select two different orientations $\orient{t}^{(1)}_i$ and $\orient{t}^{(2)}_i$ such that every combination of orientations of different $k$-tuples is not contradictory, i.e. for any $f:\ [n] \to [2]$ the orientation $\{\orient{t}^{(f(i))}_i\}_{i=1}^n$ is not contradictory.
Given the Natarajan dimension, Lemma~\ref{lem:natarajan_samples} gives the tight bound on sample complexity up to the factor $O(\frac 1\varepsilon \log |Y|)$.
Note that when $k$ is constant, $|Y|$ is also constant.
We first lower-bound the Natarajan dimension:
\begin{lemma}\label{lem:natarajan_lb}
For any $V$ and $k \ge 3$, we have $\text{NDim}(H_k(V)) \ge |V| - k + 1$.
\end{lemma}
\begin{proof}
Let $A$ be an arbitrary subset of $V$ of size $k-1$, and let $B = V \setminus A$.
We construct the set of $k$-tuples as $\Delta = \{A \cup \{b\} \mid b \in B\}$.
Let $T_A$ be an arbitrary hierarchical tree on $A$.
For each $A \cup \{b\} \in \Delta$, we construct the orientations as follows: we replace a leaf $a$ of $T_A$ with a new node with two children: $a$ and $b$.
By choosing two different leaves, we obtain two different orientations of $A \cup \{b\}$, as required by the definition of N-shattering.
It's easy to check that $\Delta$ is N-shattered using these orientations: all elements from $A$ are in agreement across all constraints since they all are oriented according to $T_A$, while every element from $B$ participates in only one constraint, and hence can't lead to a contradiction.
Therefore, $\text{NDim}(H_k(V)) \ge |B| = |V| - k + 1$.
\end{proof}
\noindent Next, we upper-bound the Natarajan dimension for triplets using results from Section~\ref{sec:contr_orient}.
\begin{theorem}\label{thm:natarajan}
For any $V$, we have $\text{NDim}(H_3(V)) = |V|-2$.
\end{theorem}
We provide the full proof in \ifarxiv{Appendix~\ref{app:n_dimension}}\else{the full version}\fi.
First, note that the result doesn't immediately follow from Theorem~\ref{thm:crit_set_is_a_closed_set} since Theorem~\ref{thm:crit_set_is_a_closed_set} finds a contradictory orientation among all possible $3^{m}$ orientations of $m$ constraints.
However, Natarajan shattering allows us to choose one of only two orientations of each triplet, i.e. it allows $2^{m}$ possible orientations.
Hence, we need to handle the case when the contradicting orientation from Theorem~\ref{thm:crit_set_is_a_closed_set} orients some triplet in a non-allowed way.
Let $S$ be a critical set, $\orient{\Delta}|_S$ be its induced orientation connecting $S$, and $[a,b | c] \in \orient{\Delta}|_S$ be a non-allowed orientation of a triplet.
Note that it means that both remaining orientations $[a,c| b]$ and $[b,c | a]$ are allowed.
If removing edge $(a,b)$ doesn't disconnect $S$, we reorient it arbitrarily.
Otherwise, removing $(a,b)$ separates $S$ into two connected components.
We reorient $(a,b)$ in the following way: if $c$ belongs to the same part as $a$, then we use edge $(b,c)$; otherwise, we use edge $(a,c)$.
As shown in Figure~\ref{fig:reorient_natarajan}, such reorientation preserves connectivity of $S$.
\begin{figure}[t!]
\centering
\ifarxiv
\includegraphics[width=0.6\columnwidth]{pics/Reorient_natarajan.pdf}
\else
\includegraphics[width=0.8\columnwidth]{pics/Reorient_natarajan.pdf}
\fi
\caption{Theorem~\ref{thm:natarajan}: when orientation $\C abc$ is not allowed, we can reorient it while preserving connectivity}
\label{fig:reorient_natarajan}
\end{figure}
Combining Lemma~\ref{lem:natarajan_lb} and Theorem~\ref{thm:natarajan} yields the following corollary.
\begin{corollary}
For any $V$ and $k \ge 3$, we have $|V| - k + 1 \le \text{NDim}(H_k(V)) \le |V| - 2$.
\end{corollary}
Using Lemma~\ref{lem:natarajan_samples}, we get our main result.
\begin{theorem}
\label{thm:natarajan_main}
For constant $k$, the sample complexity of learning hierarchically labeled $k$-tuples, denoted by $m_{H_k}^r(\varepsilon, \delta)$ in the realizable setting and $m_{H_k}^a(\varepsilon, \delta)$ in the agnostic setting, is bounded by:
\begin{align*}
C_1 \frac{n + \log \frac 1\delta}{\varepsilon} \le m_{H_k}^r(\varepsilon, \delta) & \le C_2 \frac{n \log \frac 1\varepsilon + \log \frac 1\delta}{\varepsilon} \\
C_1 \frac{n + \log \frac 1\delta}{\varepsilon^2} \le m_{H_k}^a(\varepsilon, \delta) & \le C_2 \frac{n + \log \frac 1\delta}{\varepsilon^2}
\end{align*}
\end{theorem}
In \ifarxiv{Appendix~\ref{app:n_dimension}}\else{the full version}\fi, we prove that the identical result holds for the non-binary case.
The proof idea is similar to that of Theorem~\ref{thm:natarajan}, with the only change that we must handle the case when $[a|b|c]$ is one of the allowed constraints.
\section{Preliminaries}
\label{sec:preliminaries}
\noindent We begin with a formal definition of a hierarchical tree.
\begin{definition}
\label{def:hc_tree}
Given a set of points $V$, we define a \emph{hierarchical tree} $T$ as a binary tree such that $V$ is bijectively mapped on the leaves of $T$.
\end{definition}
With a slight abuse of notation, for a fixed tree $T$, we treat elements of $V$ as the leaves of $T$.
For two leaves $i,j$ and a hierarchical tree $T$, we denote the least common ancestor, i.e. the internal node corresponding to the smallest subtree containing both $i$ and $j$, as $\lca_T(i,j)$.
We are interested in satisfying structural constraints on the elements of $V$.
In each section, we consider different types of constraints in the following order:
\begin{itemize}
\item We first consider the simplest structured constraints, i.e. constraints on three elements.
\item We then generalize our result for constraints on $k \ge 3$ elements.
\item Finally, we further generalize our result for the case when the trees are not necessarily binary.
\end{itemize}
\paragraph{Triplet constraints}
\begin{definition}
\label{def:triplet_constraints}
For a hierarchical tree $T$ and a triplet of distinct points $(a,b,c) \subseteq V$\footnote{Since the original order inside the tuples doesn't matter, with a slight abuse of notation we treat tuples (triplets in particular) as sets.} we say that $T$ \emph{satisfies the constraint} denoted $[a,b | c]$ if $T$ cuts $c$ from $a$ and $b$, i.e. $\lca_T(a,c) = \lca_T(b,c)$.
We call such a constraint an orientation of triplet $(a,b,c)$.
\end{definition}
\begin{definition}
\label{def:orientation}
For a triplet $t = (a,b,c) \subseteq V$ we say that an \emph{orientation} of the triplet is a constraint over the nodes $a,b,c$, i.e. $\C abc$, $\C acb$, or $\C bca$. We further denote it as $\orient{t}$. Given a set of triplets $\Delta = \{(a_i, b_i, c_i)\}_i$ over $V$, we say that an orientation of $\Delta$ is a set of orientations over each triplet in $\Delta$. We similarly denote it as $\orient{\Delta}$.
\end{definition}
That is, orientation is a particular choice of constraint(s) generated based on a given triplet(s).
In order to apply our results in the PAC-learning setting, we are interested in the sets of constraints that can not be satisfied:
\begin{definition}
\label{def:contradictory_triplet_set}
We define a set of constraints as \emph{contradictory} if there is no hierarchical tree that satisfies all constraints in the set.
\end{definition}
\paragraph{$k$-tuple constraints}
Any orientation of a triplet uniquely defines a tree on this triplet.
We can use this intuition to define constraints on $k$ elements.
\begin{definition}
\label{def:k_constraint}
Let $A=(a_1, \ldots, a_k)$ be a $k$-tuple, and let $T_A$ be a binary tree with leaves $a_1, \ldots, a_k$.
Then we say that a binary tree $T$ \emph{satisfies constraint $T_A$} if any triplet constraint $\C{a_i}{a_j}{a_t}$ satisfied by $T_A$ is also satisfied by $T$.
\end{definition}
\begin{definition}
\label{def:k_tuple_orientation}
For a given $k$-tuple $(a_1, \ldots, a_k) \subseteq V$, an orientation of the tuple is any constraint on $a_1,\ldots, a_k$.
\end{definition}
\paragraph{Non-binary trees}
When non-binary trees are allowed, some nodes $i,j,k$ can be separated at the same time,
i.e. $\lca_T(a,b)=\lca_T(a,c)=\lca_T(b,c)$.
We denote such case as $\TW abc$.
Similarly, we allow $k$-tuple constraints where multiple elements can be separated at the same time.
\paragraph{Sample complexity}
Let $\mathcal D$ be the distribution on $X \times Y$, where $X$ is the set of inputs and $Y$ is the set of labels.
Let $H \subseteq Y^X$ be a hypothesis space\footnote{$Y^X$ is the set of all functions $X \to Y$}.
For a given $h \in H$, we define the error rate as $\err_{\mathcal D}(h) = \mathbb{P}_{(x,y) \sim \mathcal D} [h(x) \ne y]$.
Let $h^*_{\mathcal D} = \argmin_{h \in H} \err_{\mathcal D}(h)$.
We say that the settings are realizable if $\err_{\mathcal D}(h^*_{\mathcal D}) = 0$; otherwise, we say that the settings are agnostic.
\begin{definition}[Sample complexity]
We define \emph{sample complexity} $m_H(\varepsilon, \delta)$ as the minimum number of samples, such that there exists a predictor that, for any distribution $\mathcal D$, given $m_H(\varepsilon, \delta)$ samples from $\mathcal D$, achieves error rate at most $\err_{\mathcal D}(h^*_{\mathcal D}) + \epsilon$ with probability at least $\delta$.
We denote the sample complexity as $m_H^r(\varepsilon, \delta)$ for the realizable case and $m_H^a(\varepsilon, \delta)$ for the agnostic case.
\end{definition}
For the binary classification task ($|Y|=2$), the sample complexity can be estimated using VC-dimension~\citep{VC71}.
Its analog for the multi-class settings is the Natarajan dimension.
\begin{definition}[Natarajan dimension~\citep{N89}]\label{def:natarajan}
Let $X$ be the set of inputs, $Y$ be the set of labels, and let $H \subseteq Y^X$ be a hypothesis class.
We say that $S \subseteq X$ is N-shattered by $H$ if there exist $f_1,f_2\colon\ X \to Y$ such that $f_1(x) \ne f_2(x)$ for all $x \in S$ and for every $T \subseteq S$ there exists $g \in H$ such that:
\[
g(x)=f_1(x) \text{ for } x \in T\text{ and } g(x)=f_2(x)\text{ for } x \notin T
\]
The Natarajan dimension $\text{NDim}(H)$ of $H$ is the maximum size of an N-shattered set.
\end{definition}
In our case, the hypothesis space is defined by the set of constraints induced by all possible hierarchical trees:
\begin{definition}
\label{def:hypothesis}
Given a set $V$ be a set and an integer $k \ge 3$, let $X$ be the set of $k$-tuples on $V$ and $Y$ be the set of orientations of the $k$-tuples.
Then we use $H_k(V)$ to denote a set of mappings $X \to Y$ such that for each mapping there exists a hierarchical tree where each $k$-tuple is oriented according to the mapping.
\end{definition}
The following result gives a tight estimate of the sample complexity based on the Natarajan dimension of the problem
\begin{lemma}[\citet{bendavid1995characterizations}]
\label{lem:natarajan_samples}
If $|Y| < \infty$, then for the sample complexity $m_H^r(\varepsilon, \delta)$, the following holds for some universal constants $C_1$ and $C_2$ for the realizable case:
\begin{align*}
C_1 \frac{\text{NDim}(H) + \log \frac 1\delta}{\varepsilon} &\le m_H^r(\varepsilon, \delta) \le C_2 \frac{\text{NDim}(H) \log \frac 1\varepsilon \log |Y| + \log \frac 1\delta}{\varepsilon}
\shortintertext{For the agnostic case:}
C_1 \frac{\text{NDim}(H) + \log \frac 1\delta}{\varepsilon^2} &\le m_H^a(\varepsilon, \delta) \le C_2 \frac{\text{NDim}(H) \log |Y| + \log \frac 1\delta}{\varepsilon^2}
\end{align*}
\end{lemma}
\todo{Littlestone dimension}
\section{Contradictory orientations}
\label{sec:contr_orient}
As described in Section~\ref{ssec:our_techniques}, the key component in our analysis is a tight bound on the Natarajan dimension.
To find it, we first consider a simpler question: ``\textit{for a given $n$, what is the minimum $m$, such that for any set of $m$ triplets on $[n]$ there exists a contradictory orientation of these triplets?}''
Recall that the definition of Natarajan dimension restricts the candidate orientations so that every triplet has only two allowed orientations, giving $2^m$ possible label combinations.
In this section, we answer this question without such a restriction, i.e. we check whether all $3^m$ label combinations are possible\footnote{One may think of this as another generalization of VC shattering, although not directly applicable to PAC learning}, and handle the restriction in the next section.
In what follows we prove that $m=n-1$.
\begin{theorem}
\label{thm:triplets}
For any $n > 2$, any set of triplets of size at least $n-1$ on these points allows for a contradictory orientation.
\end{theorem}
\subsection{Closed set}
We can think about every constraint $\C abc$ as an edge $(a,b)$ which corresponds to a separate vertex $c$, and we say that $\C abc$ ``generates'' edge $(a,b)$.
Clearly, if a hierarchical tree satisfies constraint $\C abc$, then there must exist a tree node such that one child's subtree contains $a$ and $b$, and another child's subtree contains $c$.
In other words, the tree is contradictory if it cuts an edge $(a,b)$ before first separating $c$ from $a$ and $b$.
When building a tree in a top-down manner, each node corresponds to some set of elements $S \subseteq V$, which we want to partition further.
When partitioning $S$, only triplets lying entirely in $S$ (which we call induced by $S$) can lead to a contradiction.
\begin{definition}[Induced triplets/constraints]
Let $\Delta$ be a set of triplets over $V$ and let $S \subseteq V$. We define the set of triplets in $\Delta$ which are \emph{induced} by $S$ as $\Delta |_{S} = \{t \in \Delta \mid t \subseteq S\}$ (i.e., the set of all triplets that lie entirely within $S$).
Similarly, given a set of constraints $C$, we define $C |_{S} = \bbr{\C abc \in C \mid a,b,c \in S}$.
\end{definition}
The above reasoning implies that it's impossible to split a tree node with set $S$ if it's connected by the edges generated by the constraints induced by $S$, since splitting $S$ would cut at least one edge (see Figure~\ref{fig:connected_contradiction} for example).
We will show that the existence of the hierarchical tree is determined by the existence of such set $S$.
For fixed $\Delta$, if it's possible to orient $\Delta$ so that $\orient{\Delta}|_S$ connects $S$, we call $S$ a closed set.
\begin{figure}[t!]
\centering
\input{pics/connected.tex}
\caption{Let $S = \{a,b,c,d\}$ and $\orient{\Delta} = \bbr{\C abc, \C acd, \C adb}$.
Since $S$ is connected by edges generated by $\orient{\Delta}|_S$, the constraints are contradictory.
When first splitting $S$, we must cut an edge, which leads to a contradiction: cutting edge $(a,b)$ violates $\C abc$, cutting $(a,c)$ violates $\C acd$, and cutting $(a,d)$ violates $\C adb$.
}
\label{fig:connected_contradiction}
\end{figure}
\begin{definition}[Closed set] \label{def:closed_set}
Let $\Delta$ be a set of triplets over $V$. We say that a set $S \subseteq V $ is \emph{closed} w.r.t. $\Delta$ if there exists an orientation of $\Delta$ denoted as $\orient{\Delta}$, such that $E|_S=\{(a,b) \mid \C abc \in \orient{\Delta} |_{S}\}$ connects $S$.
\end{definition}
\noindent The following Lemma shows that the presence of a closed subset is a necessary and sufficient condition for existence of a contradictory orientation.
The proof is given in \ifarxiv{Appendix~\ref{app:missing_proofs}}\else{the full version}\fi.
\begin{lemma}
\label{lem:closed_set}
A set of triplets $\Delta$ over $V$ allows for a contradictory orientation if and only if there exists a set $S \subseteq V$ that is closed w.r.t. $\Delta$.
\end{lemma}
The proof is based on the above intuition.
If the set is not connected by the edges generated by $\orient{\Delta} |_{S}$, then by separating connected components we don't cut any edge, and hence don't violate any constraints.
On the other hand, if the set is connected, when we first split $S$, we cut at least one edge $(a,b)$ such that $\C abc \in \orient{\Delta}|_S$.
But this violates the constraint, as it requires $c$ to be first separated from $a$ and $b$.
\subsection{Critical set}
We next show that, when $\Delta$ is sufficiently large, there exists a set $S$ such that we can always construct a contradictory orientation of $\Delta|_S$.
We call such a set a critical set.
\begin{definition}[Critical set]
\label{def:critical_set}
Let $\Delta$ be a set of triplets over $V$ of size $|\Delta| \ge |V| - 1$.
We say that set $S \subseteq V$ is \emph{critical} w.r.t. $\Delta$ if it satisfies the following conditions:
\begin{itemize}
\item $S$ induces at least $|S|-1$ triplets, i.e. $\card{\Delta |_S} \geq |S|-1$,
\item Among all such sets, $S$ has the minimal cardinality.
\end{itemize}
\end{definition}
\noindent Note that this is well defined since $V$ satisfies the condition: $|\Delta| = \card{\Delta |_V} \geq |V|-1$.
Intuitively, $|S| - 1$ is the minimum possible number of edges which can connect $S$.
The surprising fact is that this condition suffices, which leads to the main result of this section (Theorem~\ref{thm:triplets}).
\begin{theorem}
\label{thm:crit_set_is_a_closed_set}
Let $\Delta$ be a set of triplets over $V$ of size $|\Delta| \geq |V| -1$.
Then any critical set w.r.t. $\Delta$ is closed w.r.t. $\Delta$.
\end{theorem}
We present the full proof of Theorem~\ref{thm:crit_set_is_a_closed_set} \ifarxiv{in Appendix~\ref{app:missing_proofs}}\else{in the full version}\fi.
The proof relies on the operation which we call \emph{reorientation}: given constraint $\C abc$, we change it to either $\C acb$ or $\C bca$, which respectively changes the generated edge from $(a,b)$ to either $(a,c)$ or $(b,c)$.
The proof is by contradiction: for a critical set $S$, we assume that no orientation of $\Delta|_S$ generates edges connecting $S$.
Among all orientations, we consider the one whose edges result in the smallest number of connected components.
We show that by performing certain reorientations, we can reduce the number of connected components, leading to a contradiction.
Since the edges generated by the orientation don't connect $S$, there must exist an ``unused'' triplet $(a,b,c)$, such that adding or removing its edges $(a,b)$, $(a,c)$ and $(b,c)$ doesn't change the number of connected components.
All of $a,b,c$ belong to the same tree $T$ in the spanning forest of $S$ (otherwise, we could orient $(a,b,c)$ so that it connects two trees, reducing the number of connected components).
By orienting this triplet as, for example, $\C abc$, we can reorient any edge on the path from $a$ to $b$ in $T$ without disconnecting vertices in $T$.
If there exists a reorientation that connects $T$ to another tree in the spanning forest, using this reorientation we decrease the number of connected components, as shown in Figure~\ref{fig:reorient_simple}.
Such a reorientation might not always be immediately available, but we show that it's always possible to build a chain of reorientations so that the number of connected components decreases.
\begin{figure}[t!]
\centering
\ifarxiv
\includegraphics[width=0.6\columnwidth]{pics/Triple_inside_copy.pdf}
\else
\includegraphics[width=0.8\columnwidth]{pics/Triple_inside_copy.pdf}
\fi
\caption{A case from Theorem 8: selecting orientation $\C abc$ allows one to reorient any edge on the path from $a$ to $b$. In this case, on this path there is an edge $(x, y)$ generated by constraint $\C xyz$, where $z$ belongs to another spanning tree. Reorienting $\C xyz$ connects the trees}
\label{fig:reorient_simple}
\end{figure}
\paragraph{$k$-tuples}
In \ifarxiv{Theorem~\ref{thm:tuples}}\else{the full version}\fi, we show that any set of $k$-tuples of size at least $\left\lceil \frac{|V|-1}{k-2} \right\rceil$ has a contradictory specification\arxiv{,} and \arxiv{Theorem~\ref{thm:shatter_lb} shows} that the bound is tight for $k$-tuples\footnote{However, as we show in the next section, the $(k-2)^{-1}$ factor doesn't propagate to the sample complexity}.
The main idea is that, for the sake of analysis, we can replace a $k$-tuple with $k-2$ ``independent'' triplets, meaning that all $3^{k-2}$ orientations of these triplets are not contradictory.
Namely, all the triplets share two elements and differ in the third one.
\paragraph{Non-binary trees}
When constraints of form $\C abc$ are allowed, after adjusting the definitions, the overall idea is the same: a contradictory orientation exists iff a closed set exists, and any critical set is closed.
While the definition of a critical set doesn't change~-- it's a minimum-size set $S$ with $\ge |S|-1$ induced edges~-- the definition of a closed set changes substantially, as described next.
As before, we have a set $\mathcal E = E|_S$ of edges induced by $S$, but now we might have additional constraints of form $[a|b|c]$.
The main idea is as follows: if e.g. $a$ and $b$ are already connected by $\mathcal{E}$, they can't be separated by the first cut.
Hence, by definition of $[a|b|c]$, $c$ also can't be separated from $a$ and $b$ by the first cut.
Since we perform the first cut based on the connectivity of the set, the fact that $c$ can't be separated from $a$ and $b$ can be expressed by adding edge $(a,c)$, i.e. $\mathcal E \gets \mathcal E \cup \{(a,c)\}$, hence connecting $a$, $b$ and $c$ (see Figure~\ref{fig:nonbinary_edge}).
\begin{figure}[t!]
\centering
\input{pics/nonbinary_edge.tex}
\caption{Given constraint $[a|b|c]$, when $a$ and $b$ are connected, we can also connect them to $c$}
\label{fig:nonbinary_edge}
\end{figure}
Now, we can say that $S$ is \emph{closed} w.r.t. $\Delta$ if there exists an orientation of $\Delta$ such that $S$ is connected after performing all such possible operations.
Similarly to the binary-tree case, the existence of such a set implies a contradictory orientation.
This intuition is formalized in \ifarxiv{Lemma~\ref{lem:nonbinary:closed_is_contradictory}}\else{the full version}\fi.
Obviously, critical sets are closed: by only using constraints of type $\C abc$, we can use Theorem~\ref{thm:crit_set_is_a_closed_set} directly.
However, constraints of type $[a|b|c]$ result in an additional option in the definition of N-shattering (we have to choose $2$ labels out of $4$ instead of $3$), and hence the Natarajan dimension can potentially increase.
In the next section, we show that this is not the case for our problem.
| {'timestamp': '2023-02-10T02:08:26', 'yymm': '2302', 'arxiv_id': '2302.04492', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04492'} | arxiv |
\section{Introduction}\label{sec:introduction}
Offering incentives (e.g., cash bonuses, discounts, coupons) to consumers are effective ways for online platforms to acquire new users, increase user engagement, and boost platform revenue~\cite{lin2017monetary,zhao2019uplift,zhao2019unified,makhijani2019lore,goldenberg2020free,zhang2021bcorle,tu2021personalized,ai2022lbcf,albert2022commerce,zhou2023direct}.
For example, coupons in Taobao~\cite{zhang2021bcorle} are offered to increase user activity, promotions in Booking~\cite{goldenberg2020free} can improve user satisfaction, cash bonuses in Kuaishou~\cite{ai2022lbcf} are used to stimulate user retention, and promotions in Uber~\cite{zhao2019uplift} can encourage users to start using a new product.
Despite the effectiveness, these marketing campaigns could incur high costs, and thus the total budget is often capped in real-world scenarios.
From the perspective of online platforms, the goal of a marketing campaign is often described as maximizing a specific business goal (e.g., user retention) under a specific budget constraint.
To this end, allocating an appropriate amount of incentive to different users is essential for optimizing marketing effectiveness since different users could respond differently to incentives.
This budget allocation problem has great practical implications and has been investigated for decades.
Many recent advances address the budget allocation problem using a two-stage paradigm~\cite{zhao2019unified,ai2022lbcf,tu2021personalized,albert2022commerce}: in the first stage the individual-level heterogeneous treatment effects are estimated using causal inference techniques, and then the estimated effects are fed into an integer programming formulation as coefficients to find the optimal allocation.
However, the objectives of these two stages are fundamentally different, and in practice, we have observed these objectives are not perfectly aligned.
For example, if the total budget is extremely low, then an effective allocation algorithm should distribute incentives only to a small subset of users who are fairly sensitive to incentives.
In this case, an improved treatment effects predictor might have worse marketing effectiveness, if the model has a higher precision on all users on average but performs poorly on this small subset of users.
In this paper, we propose a novel end-to-end approach to optimize marketing effectiveness under budget constraints, directly and precisely.
Our core idea is to construct a regularizer to represent the marketing goal, and further optimize it efficiently using gradient estimation techniques.
Concretely, we use S-Learner~\cite{kunzel2019metalearners} based on Deep Neural Networks (DNNs) to predict the treatment effects of different users.
Given the estimated treatment effects, we further formulate the budget allocation problem as a multiple choice knapsack problem (MCKP)~\cite{kellerer2004multiple}, and exploit the Expected Outcome Metric method (EOM) to build an unbiased estimation (denoted as $Q$) of the marketing goal (i.e., the expected business goal under a certain budget constraint).
The $Q$ function represents the marketing effectiveness and is the exact objective we want to maximize, thus we treat $Q$ as a regularizer and integrate it into the training objective of the S-Learner model.
However, there remains one challenge in doing so: since our construction process of $Q$ involves solving a series of MCKPs using Lagrange multipliers and thus many non-differentiable operations are involved in, the automatic differentiation mechanism in modern machine learning libraries (such as TensorFlow~\cite{tensorflow2015-whitepaper} and PyTorch~\cite{paszke2019pytorch}) would not give correct gradients.
Our solution to resolve this issue is to treat $Q$ as a black-box function and exploit gradient estimation techniques such as the finite-difference method or natural evolution strategies (NES)~\cite{wierstra2014natural} to obtain the gradients.
As such, the regularizer could be effectively jointly optimized with the original learning objective of the S-Leanrer model.
This regularizer endows the S-Learner model with an ability to directly learn from the marketing goal and further maximize it, in a principled way.
Our proposed method is extensively evaluated on both offline simulations and online experiments.
Experimental results demonstrate that our proposed end-to-end training framework can achieve significantly better marketing effectiveness, in comparison with current state-of-the-arts.
We further deploy the proposed method in a large-scale short video platform to allocate cash bonuses to users to incentivize them to create more videos, and online A/B tests show our method significantly outperforms the baseline methods by at least 1.24\% more video creators under the same budget, which is a tremendous improvement over these months.
Currently, our proposed method is serving hundreds of millions of users.
\section{Related Works}\label{sec:related_work}
\subsection{Budget Allocation}
Starting from a common objective, many budget allocation methods have been proposed.
Early methods~\cite{guelman2015uplift,zhao2017uplift,zhao2019uplift} often select the amount of incentives for users heuristically after obtaining the heterogeneous treatment effects estimation.
However, lacking an explicit optimization problem formulation could make these methods less effective in maximizing the marketing goal.
A popular way of allocating budget is to follow a two-stage paradigm~\cite{zhao2019unified,makhijani2019lore,goldenberg2020free,tu2021personalized,ai2022lbcf,albert2022commerce}: in the first stage uplift models are used to predict the treatment effects, and in the second stage integer programming is invoked to find the optimal allocation.
For instance, \citet{zhao2019unified} propose to use a logit response model~\cite{phillips2021pricing} to predict treatment effects and then obtain the optimal allocation via root-finding for KKT conditions.
Later, \citet{tu2021personalized} introduce various advanced estimators (including Causal Tree~\cite{athey2016recursive}, Causal Forest~\cite{wager2018estimation} and Meta-Learners~\cite{soltys2015ensemble,kunzel2019metalearners}) to estimate the heterogeneous effects.
The second stage has also received much research attention.
\citet{makhijani2019lore} formulate the marketing goal as a Min-Cost Flow network optimization problem for better expressivity.
More recently, \citet{ai2022lbcf,albert2022commerce} use MCKP to represent the budget allocation problem in the discrete case and develop efficient solvers based on Lagrangian duality.
Though effective, owing to the misalignment between the objectives of these two stages, solutions from these two-stage methods could be suboptimal.
Several methods have also been proposed to directly learn the optimal budget assignment policy~\cite{xiao2019model,du2019improve,goldenberg2020free,zou2020heterogeneous,zhang2021bcorle,zhou2023direct}.
\citet{xiao2019model,zhang2021bcorle} develop reinforcement learning solutions based on constrained Markov decision process to directly learn an optimal policy.
However, learning such complicated policies in a pure model-free black-box approach without exploiting the causal structures could suffer from sample inefficiency.
\citet{du2019improve,zou2020heterogeneous,goldenberg2020free} propose to directly learn the ratios between values and costs in the binary treatment setting, and treatments could be first applied to users with higher scores.
Later, a contemporary work~\cite{zhou2023direct} proves the proposed loss in~\cite{du2019improve,zou2020heterogeneous} cannot achieve the correct rank when
the loss converges.
Furthermore, the method proposed in~\cite{goldenberg2020free} is applicable only if the budget constraint is that monetary ROI$\ge0$, which is not flexible enough for many marketing campaigns in online Internet platforms.
\citet{zhou2023direct} extend the decision-focused learning idea to the multiple-treatments setting and develop a loss function to learn decision factors for MCKP solutions.
However, the proposed method relies on the assumption of diminishing marginal utility, which is often not strictly hold in practice.
\subsection{Gradient Estimation}
Estimating the gradients of a black-box function has been extensively studied for decades and widely used in the field of reinforcement learning~\cite{sutton1999policy} and adversarial attack~\cite{ilyas2018black,guo2019subspace}.
The simplest approach is the finite-difference strategy, i.e., calculating the gradients by definition.
The finite-difference strategy could give accurate gradients but might be computationally expensive if the independent variables of the black-box function have high dimensionalities.
An alternative way of gradient estimation is natural evolution strategies (NES)~\cite{wierstra2014natural}, which generate several search directions to probe local geometrics of the black-box function and estimate the gradients based on sampled search directions.
NES is generally more computationally efficient than the finite-difference strategy, but the estimated gradients are noisy.
Antithetic sampling~\cite{salimans2017evolution} could be employed to reduce the variance of NES gradient estimation.
In this paper, we present both finite-difference- and NES-based algorithms for gradient estimation.
\section{Our End-to-End Framework}\label{sec:method}
Many budget allocation methods follow a two-stage paradigm, which may lead to degraded performance due to the misalignment between the objectives of the two stages.
We reckon it can be beneficial to properly incorporate the allocation process based on the second stage into the learning objective, such that the model can directly learn to maximize the marketing goal.
In this section, we first introduce major notations, then briefly analyze the two-stage paradigm, finally we present our end-to-end training framework.
\subsection{Notations}\label{sec:notation}
In most online Internet platforms, randomized controlled trials (RCT) could be easily deployed and thus a decent amount of RCT data could usually be collected at an acceptable cost in practice.
As such, in this paper, we focus on training models using RCT data for simplicity and leave the exploration on exploiting observational data to future works.
We use $u_i\in\mathbb R^d$ to denote the features for $i$-th user in a certain user group.
The term ``user group'' might refer to a group of RCT training users or a group of non-RCT users whose budgets are allocated by our model.
The exact meaning of the term ``user group'' should be easily inferred from the context in this paper.
We set $K$ mutually exclusive treatments, and each treatment represents a certain amount of incentives (e.g., cash bonus, or discount levels) assigned to the user.
The treatment assigned to user $u_i$ in RCT is denoted by $t_i\in\{1,\ldots K\}$, and the user would have a binary response $y_i\in\{0,1\}$ after receiving the treatment $t_i$.
The response shall be the business goal we want to maximize.
Meanwhile, applying treatment $t_i$ to user $u_i$ would induce a non-negative cost $z_i\ge 0$.
Each sample from an RCT dataset consists of a quadruple $(u_i, t_i, y_i, z_i)$.
\subsection{The Two-Stage Paradigm}\label{sec:method_two_stage}
As discussed, a lot of efforts have been devoted to two-stage budget allocation methods~\cite{zhao2019unified,makhijani2019lore,goldenberg2020free,tu2021personalized,ai2022lbcf,albert2022commerce}.
In this section, we briefly introduce common components in two-stage budget allocation methods.
In the first stage, two-stage methods seek to build an uplift model to predict the uplifts of responses under all possible treatments.
In principle, any uplift models could be applied in this stage, such as S-Learners~\cite{kunzel2019metalearners}, R-Learners~\cite{nie2021quasi}, Uplift Trees~\cite{rzepakowski2012decision}, Causal Forests~\cite{athey2016recursive}, GRFs~\cite{athey2019generalized}, ORFs~\cite{oprescu2019orthogonal} and LBCFs~\cite{ai2022lbcf}.
Although some tree-based uplift models like GRFs~\cite{athey2019generalized} and ORFs~\cite{oprescu2019orthogonal} are unbiased uplift estimators with theoretical convergence guarantees, the splitting criteria in their tree-growing process are not flexible enough to be easily extended and integrated with our proposed regularizers.
Thus in this paper, we restrict our attention to using S-Leaners with DNNs~\cite{krizhevsky2012imagenet} as base models, just like~\cite{zhou2023direct}.
A typical DNN S-Learner model $f$ would take the user feature $u_i$ as input and feed $u_i$ into a multi-layer perceptron (MLP) with several fully-connected layers to obtain the base hidden representation $h_i$ of the user $u_i$, and then the model $f$ would branch $2K$ headers (i.e., shadow MLPs) on the top of the base hidden representation $h_i$ to predict responses and costs for every possible treatment, where each treatment corresponds two headers (one header for response and the other header for cost).
In general, any DNN architecture could be used in this stage provided the DNN model takes $u_i$ as input and outputs two $K$-dimensional vectors for predicted responses/costs under all possible treatments, and in this paper, we use the simple architecture described above and leave the exploration on DNN architectures to future works.
Let $\theta$ exhaustively collects learnable parameters of the above DNN S-Leaner $f$, and let $f_v\left(u_i;\theta\right)\in\mathbb R^K$ and $f_c\left(u_i;\theta\right)\in\mathbb R^K$ denote the predicted responses/costs of $f$.
The predicted response and cost of applying treatment $j$ to user $u_i$ are denoted by $f_v\left(u_i;\theta\right)_j$ and $f_c\left(u_i;\theta\right)_j$, respectively.
Given a training set with $N$ RCT users, the DNN S-Learner is trained in the first stage by minimizing the following objective:
\begin{equation}\label{eqn:loss_s_learner}
L_{\textrm{SL}}\left(\theta\right)=-\frac{1}{N}\sum_{i=1}^N L_{\textrm{CE}}\left(f_v\left(u_i;\theta\right)_{t_i}, y_i\right)+L_{\textrm{C}}\left(f_c\left(u_i;\theta\right)_{t_i}, z_i\right),
\end{equation}
where $L_{\textrm{CE}}(\cdot,\cdot)$ is the cross entropy loss for the binary response, and $L_{\textrm{C}}(\cdot,\cdot)$ is a suitable loss for the cost target.
The formulation of $L_{\textrm{C}}(\cdot,\cdot)$ could vary from one dataset to another.
For example, on a dataset where the cost label $z_i$ is categorical, it could be reasonable to use a cross entropy-loss for $L_{\textrm{C}}(\cdot,\cdot)$, while on another dataset where the cost label $z_i$ is continuous, a regression loss would be more appropriate for $L_{\textrm{C}}(\cdot,\cdot)$.
After minimizing the objective $L_{\textrm{SL}}\left(\theta\right)$ in Equation~\eqref{eqn:loss_s_learner}, given a feature vector of a user, the well-trained DNN S-Leaner model should predict unbiased estimations of expected responses/costs of this user under all possible treatments.
In the second stage, two-stage methods usually keep the uplift model $f$ fixed and use a multiple choice knapsack problem (MCKP)~\cite{kellerer2004multiple} formulation to maximize the marketing goal under the budget constraint.
Suppose the total budget for a group of $M$ users is set to $T$.
The expected response of $u_i$ under treatment $j$ is denoted by $v_{ij}\in[0, 1]$, and $v_{ij}$ could be predicted by the well-trained DNN S-Learner from the first stage: $v_{ij}=f_v\left(u_i;\theta\right)_j$.
Let $c_{ij}\ge 0$ denotes the expected cost of $u_i$ under treatment $j$, and $c_{ij}$ could also be similarily predicted by $c_{ij}=f_c\left(u_i;\theta\right)_j$.
Using the above coefficients and constants, two-stage methods typically construct the following MCKP to find the optimal personalized treatment assignment solution $x\in\{0,1\}^{M\times K}$ which could maximize the expected marketing goal under a given budget constraint:
\begin{equation}\label{eqn:mckp}
\begin{aligned}
\max_{x} \quad & \sum_{i=1}^M\sum_{j=1}^K v_{ij}x_{ij} \\
\textrm{s.t.} \quad & \sum_{i=1}^M\sum_{j=1}^K c_{ij}x_{ij}\le T\\
& \sum_{j=1}^Kx_{ij}=1,\quad i=1,2,\ldots,M \\
& x_{ij}\in\{0,1\},\quad i=1,2,\ldots,M,\quad j=1,2,\ldots,K,
\end{aligned}
\end{equation}
where the $M\times K$ matrix $x$ represents the budget allocation solution for $M$ users.
All entries in $x$ are either 0 or 1.
Each row of $x$ has exactly one entry with value 1, and $x_{ij}=1$ means user $u_i$ should be assigned with treatment $j$.
Although MCKP is proven to be NP-Hard~\cite{kellerer2004multiple}, in practice we can approximately solve it by first making linear relaxation to get rid of the integer constraints and then converting it to the dual problem~\cite{ai2022lbcf,zhou2023direct}.
Specifically, the dual problem of MCKP has only one scalar variable $\alpha$ under a constraint that $\alpha\ge 0$~\cite{kellerer2004multiple}, and the objective of dual problem is given by
\begin{equation}\label{eqn:mckp_dual}
\begin{aligned}
\min_{\alpha\ge 0} \quad & \alpha T+\sum_{i=1}^M\max_j\left(v_{ij}-\alpha c_{ij}\right).
\end{aligned}
\end{equation}
The dual problem~\eqref{eqn:mckp_dual} could be efficiently solved via bisection methods such as Dyer-Zemel algorithm~\cite{zemel1984n} or dual gradient descent~\cite{ai2022lbcf,zhou2023direct}.
Once the optimal dual solution $\alpha^*$ is obtained, the optimal solution $x^*$ of the primal MCKP~\eqref{eqn:mckp} could be given by KKT conditions:
\begin{equation}\label{eqn:mckp_primal_dual_optimal}
x_{ij}^*=\begin{cases}
1, & \text{if } j = \argmax_k v_{ik}-\alpha^*\cdot c_{ik} \\
0, & \text{otherwise.}
\end{cases}
\end{equation}
Interested readers can read the insightful paper~\cite{kellerer2004multiple} for more details about solving MCKPs.
\subsection{Marketing Goal as a Regularizer}\label{sec:method_regularizer}
As discussed in Section~\ref{sec:introduction}, our core idea for end-to-end training is to construct a regularizer to represent the marketing goal (i.e., the expected response under a certain budget constraint) and optimize it efficiently using gradient estimation techniques.
Suppose we have a batch of $B$ RCT users from the training set (we set the batch size to $B=10,000$ in all experiments), the S-Learner model could predict responses for each user and we shall stack their predicted responses into a $B\times K$ matrix $v$ to simplify the notations, and the costs of applying arbitrary treatments to these users could also be stacked into a $B\times K$ matrix $c$ in a similar way.
In this section, we present our solution to design a function $Q(v,c)$ to map the predicted response matrix $v$ and cost matrix $c$ to the marketing goal and integrate $Q(v,c)$ into the training objective of the S-Leaner model as a regularizer.
\begin{figure}[t]
\centering
\includegraphics[width=.8\linewidth]{cost_value}
\caption{Example of sensitiveness curve between the empirical business goal (y-axis) and empirical cost (x-axis) in the marketing data.}
\Description{EExample of sensitiveness curve between the empirical business goal (y-axis) and empirical cost (x-axis) in the marketing data}
\label{fig:cost_value}
\end{figure}
We use Expected Outcome Metric (EOM) method~\cite{zhao2017uplift,ai2022lbcf,zhou2023direct} to construct $Q(v,c)$.
Concretely, starting from any dual feasible solution $\alpha\ge 0$, we can obtain the corresponding budget allocation solution $x$ via KKT conditions in Equation~\eqref{eqn:mckp_primal_dual_optimal}.
Since $\alpha$ is the Lagrangian multiplier associated with the budget constraint in the primal MCKP~\eqref{eqn:mckp}, we know from complementary slackness conditions that $x$ must be the primal optimal solution for another MCKP in which the total budget $T$ is set to be $T=\sum_{i=1}^M\sum_{j=1}^K c_{ij}x_{ij}$ while other coefficients $c$ and $v$ remain unchanged.
In other words, given any $\alpha\ge 0$, the corresponding $x$ is the optimal budget allocation solution under a certain total budget constraint.
Using the budget allocation solution $x$, we can find the set of user indices (denoted by $\mathcal S_\alpha$) in the $B$ RCT users whose treatment on the RCT data is equal to the assigned treatment in $x$:
\begin{equation}\label{eqn:same_treatment}
\mathcal S_\alpha = \left\{i\,\middle |\,t_i=\argmax_j x_{ij},\,\, i=1,2,\ldots,B\right\},
\end{equation}
where $t_i$ is the treatment applied to user $u_i$ in the RCT data.
Based on the set $\mathcal S_\alpha$, the per-capita response $V\left(v, c,\alpha\right)\in\mathbb R_+$ and per-capita cost $C\left(v, c,\alpha\right)\in\mathbb R_+$ could be empirically estimated by:
\begin{equation}\label{eqn:V_and_D}
\begin{aligned}
V\left(v, c, \alpha\right) &= \frac{1}{\left\lvert\mathcal S_\alpha\right\rvert}\sum_{i\in\mathcal S_\alpha} y_i \\
C\left(v, c, \alpha\right) &= \frac{1}{\left\lvert\mathcal S_\alpha\right\rvert}\sum_{i\in\mathcal S_\alpha} z_i,
\end{aligned}
\end{equation}
where $y_i\in\{0,1\}$ and $z_i\in\mathbb R_+$ denote the response and cost of user $u_i$ in the RCT data respectively, and $\left\lvert\mathcal S_\alpha\right\rvert$ represents the cardinality of set $\mathcal S_\alpha$.
\begin{algorithm}[th]
\caption{Evaluate $Q(v,c)$ given $v$ and $c$}\label{alg:Q}
\begin{algorithmic}[1]
\State {\bfseries Input:} the predicted response/cost matrix $v$/$c$ of a group of $B$ users; the total budget $T$; the maximum number of iterations $I$ in bisection; the maximum $\alpha_{\textrm{max}}$ in bisection; the tolerance $\epsilon$ of per-capita cost in bisection.
\State {\bfseries Output:} the expected per-capita response $Q(v,c)$ under the optimal budget allocation solution.
\State Initialize $t\gets 1$, $\alpha_l\gets 0$, $\alpha_h\gets\alpha_{\textrm{max}}$.
\While{$t\le I$}
\State // Evaluate the middle point in the search interval.
\State $\alpha_m\gets\frac{\alpha_l+\alpha_h}{2}$
\State Recover the primal solution $x_m$ corresponing to $\alpha_m$ using KKT conditions in Equation~\eqref{eqn:mckp_primal_dual_optimal}.
\State Based on $x_m$, evaluate empirical per-capita response $V\left(v,c,\alpha_m\right)$ and empirical per-capita cost $C\left(v,c, \alpha_m\right)$ using Equation~\eqref{eqn:same_treatment} and Equation~\eqref{eqn:V_and_D}.
\State
\State // Check if we could break early.
\State Calculate the per-capita cost error: $e\gets\left\lvert C\left(v,c,\alpha_m\right)-\frac{T}{B}\right\rvert$.
\If{$e\le\epsilon$}
\State break
\EndIf
\State
\State // Update search interval.
\If{$C\left(v,c,\alpha_m\right)>\frac{T}{B}$}
\State // Empirical cost is too high, we should turn down the budget in MCKP by increasing $\alpha$.
\State $\alpha_l\gets\alpha_m$
\Else
\State // Empirical cost is too low, we should turn up the budget in MCKP by decreasing $\alpha$.
\State $\alpha_h\gets\alpha_m$
\EndIf
\State
\State // Update step counter.
\State $t\gets t+1$
\EndWhile
\State {\bfseries return} the final empirical per-capita response $V\left(v, c,\alpha_m\right)$.
\end{algorithmic}
\end{algorithm}
As discussed, the obtained $x$ is the optimal budget allocation solution for these $B$ users under a certain budget constraint, and thus we could tune the total budget by adjusting the value of dual feasible solution $\alpha$~\cite{kellerer2004multiple}.
As such, we could start from $\alpha=0$ and gradually increase its value, and the total budget in MCKP would be accordingly decreased.
In this process, we could plot empirical per-capita cost $C\left(v, c,\cdot\right)$ and empirical per-capita response $V\left(v, c,\cdot\right)$ in the same figure~\footnote{Note this curve might not be strictly monotonically increasing since the empirical estimation process is noisy.} to illustrate the users' expected responses under different costs, and an example figure is shown in Figure~\ref{fig:cost_value}.
Based on this curve, intuitively we can use bisection search to find a suitable $\alpha'$ such that the empirical per-capita cost $C\left(v, c,\alpha'\right)\in\mathbb R_+$ equals the given per-capita budget $\frac{T}{\left\lvert\mathcal S_\alpha\right\rvert}$ in the original MCKP, and define $Q(v,c)$ as the empirical per-capita response at that $\alpha'$: $Q(v,c)=V\left(v,c,\alpha'\right)$.
All details of evaluating $Q(v,c)$ given $v$ and $c$ are summarized in Algorithm~\ref{alg:Q}.
The bisection process in Algorithm~\ref{alg:Q} could also be extended to $n$-ary search by adding more middle points in the search interval in each iteration.
Although the bisection method and the $n$-ary search method share the same asymptotic time complexity, in modern GPU devices the $n$-ary search method could usually run faster if the implementation is properly vectorized.
Given a batch of training data with $B$ RCT users, instead of optimizing the original objective $L_{\textrm{SL}}\left(\theta\right)$ in Equation~\eqref{eqn:loss_s_learner} for S-Learner, we could directly optimize the marketing effectiveness by minimizing the following regularized objective $L_R(\theta)$ in this batch:
\begin{equation}\label{eqn:loss_regularized}
L_R(\theta)=L_{\textrm{SL}}(\theta)-\lambda\cdot Q(v,c),
\end{equation}
where $L_{\textrm{SL}}(\theta)$ is the original loss in Equation~\eqref{eqn:loss_s_learner} on this batch, and $\lambda>0$ is a scaling factor that balances the importance of the original objective $L_{\textrm{SL}}\left(\theta\right)$ and the regularizer $Q(v,c)$.
If the gradient $\frac{\partial Q(v,c)}{\partial v}$ and $\frac{\partial Q(v,c)}{\partial c}$ could be obtained (see Section~\ref{sec:method_grad_estimation}), we can integrate the gradient into the back-propagation process (see Section~\ref{sec:method_training}).
As such, the regularizer $Q(v,c)$ could be jointly optimized with the original learning objective $L_{\textrm{SL}}(\theta)$ and the whole objective $L_R(\theta)$ in Equation~\eqref{eqn:loss_regularized} could be efficiently solved in an end-to-end flavor.
This endows the trained model with an ability to directly learn from the marketing goal and further maximize it, in a principled way.
\subsection{Gradient Estimation}\label{sec:method_grad_estimation}
As shown in Algorithm~\ref{alg:Q}, the construction of regularizer $Q(v,c)$ involves many non-differentiable operations.
Thus if we na\"ively implement Algorithm~\ref{alg:Q} as a computational graph in modern machine learning libraries such as TensorFlow~\cite{tensorflow2015-whitepaper} and PyTorch~\cite{paszke2019pytorch}, the automatic differentiation mechanism would not generate correct gradients.
In this section, we present our solution to overcome this challenge and calculate the (estimation of) gradient $\frac{\partial Q(v,c)}{\partial v}$ and $\frac{\partial Q(v,c)}{\partial c}$.
We treat $Q(v,c)$ as a black-box function, and use two strategies to estimate the gradients: 1) finite-difference strategy in Section~\ref{sec:method_grad_estimation_fd}, and 2) natural evolution strategies (NES)~\cite{wierstra2014natural} in Section~\ref{sec:method_grad_estimation_nes}.
For clarity of presentation, in this section, we would present the detailed solution for estimating $\frac{\partial Q(v,c)}{\partial v}$ only, and estimating for $\frac{\partial Q(v,c)}{\partial c}$ could be similarly performed.
\subsubsection{Finite-Difference Strategy}\label{sec:method_grad_estimation_fd}
Finite-difference strategy is commonly used in the field of black-box adversarial attack~\cite{chen2017zoo,tu2019autozoom} to estimate the gradient of a complicated black-box function.
Specifically, given predicted responses $v\in [0,1]^{B\times K}$ of a batch of $B$ RCT training users, the $l$-th element in the gradient matrix $\frac{\partial Q(v,c)}{\partial v}\in\mathbb{R}^{B\times K}$ could be estimated by:
\begin{equation}\label{eqn:fd}
\left(\frac{\partial Q(v,c)}{\partial v}\right)_l\approx\frac{Q\left(v+h\cdot e_l,c\right)-Q\left(v-h\cdot e_l,c\right)}{2h},
\end{equation}
where $l=1,2,\ldots,B\times K$, $h$ is a small positive constant to perturb the input of the $Q$ function, and $e_l\in \{0,1\}^{B\times K}$ is the standard basis matrix with only the $l$-th component as 1.
We use the symmetric difference quotient~\cite{peter2014calculus} to improve the numerical stability.
Using Equation~\eqref{eqn:fd}, theoretically, we could estimate each entry of the matrix $\frac{\partial Q(v,c)}{\partial v}$ one by one, and finally stack results of all entries together to obtain the estimation of the entire gradient matrix $\frac{\partial Q(v,c)}{\partial v}$, at the cost of evaluating the $Q$ function $2\times B\times K$ times.
However, the forward process of function $Q$ is sophisticated, and thus evaluating the $Q$ function for $2\times B\times K$ times could be computationally intensive in practice.
To accelerate the finite-difference process, we use a strategy somewhat analogous to a coordinate descent: randomly masking some entries.
Concretely, in each training iteration, instead of evaluating all $B\times K$ entries of $\frac{\partial Q(v,c)}{\partial v}$, we randomly select $F'\ll B\times K$ entries and evaluate these entries of $\frac{\partial Q(v,c)}{\partial v}$ using Equation~\eqref{eqn:fd} while other entries are set to zero.
In practice, we could adjust the hyper-parameter $F'$ to achieve a sensible trade-off between computational efficiency and the accuracy of the gradient estimation.
\subsubsection{Natural Evolution Strategy}\label{sec:method_grad_estimation_nes}
NES is a popular derivative-free numerical optimization algorithm and it is commonly used in the field of black-box adversarial attack~\cite{ilyas2018black,ilyas2018prior,guo2019subspace}.
Suppose a random variable $v'\in\mathbb{R}^{B\times K}$ follows an isotropic normal distribution with $v$ as the center and $\sigma^2I$ as the covariance matrix: $v'\sim\mathcal{N}\left(v,\sigma^2I\right)$, where $\sigma$ is a small positive constant and $I$ is a $\left(B\times K\right)$-by-$\left(B\times K\right)$ identity matrix.
NES seeks to maximize the expected value of function $Q$ under the distribution of $v'$ by estimating the gradient using the ``log derivative trick''\footnote{Similar trick is also used in policy gradient algorithms in reinforcement learning.}:
\begin{equation}\label{eqn:nes}
\begin{aligned}
\frac{\partial}{\partial v}\mathbb{E}_{v'}\left[Q\left(v',c\right)\right]&=\frac{\partial}{\partial v}\int Q\left(v',c\right)\pi\left(v'\middle|\,v\right)\,\textrm{d}v'\\
&=\int Q\left(v',c\right)\frac{\partial}{\partial v}\pi\left(v'\middle|\,v\right)\,\textrm{d}v'\\
&=\int Q\left(v',c\right)\frac{\pi\left(v'\middle|\,v\right)}{\pi\left(v'\middle|\,v\right)}\frac{\partial}{\partial v}\pi\left(v'\middle|\,v\right)\,\textrm{d}v'\\
&=\int Q\left(v',c\right)\pi\left(v'\middle|\,v\right)\frac{\partial}{\partial v}\log\left(\pi\left(v'\middle|\,v\right)\right)\,\textrm{d}v'\\
&=\mathbb{E}_{v'}\left[Q\left(v',c\right)\frac{\partial}{\partial v}\log\left(\pi\left(v'\middle|\,v\right)\right)\right],
\end{aligned}
\end{equation}
where $\pi\left(v'\middle|\,v\right)$ is the probability density function of the random variable $v'$.
If the variance $\sigma^2$ is small enough, the expected value of $Q$ in Equation~\eqref{eqn:nes} should be close to $Q(v,c)$, and thus we could use NES to estimate the gradient $\frac{\partial Q(v,c)}{\partial v}$:
\begin{equation}\label{eqn:nes2}
\begin{aligned}
\frac{\partial Q(v,c)}{\partial v}&\approx\frac{\partial}{\partial v}\mathbb{E}_{v'}\left[Q\left(v',c\right)\right]\\
&=\mathbb{E}_{v'}\left[Q\left(v',c\right)\frac{\partial}{\partial v}\log\left(\pi\left(v'\middle|\,v\right)\right)\right]\\
&\approx \frac{1}{\sigma N'}\sum_{i=1}^{N'}\delta_i\cdot Q\left(v+\sigma\delta_i,c\right),
\end{aligned}
\end{equation}
where in the last equation we use empirical average value to estimate the expectation, $\delta_i\in\mathbb{R}^{B\times K}$ is a sample from the standard normal distribution in the $B\times K$ dimensional vector space, and $N'$ is the number of sampling directions.
Using Equation~\eqref{eqn:nes2}, we could obtain an unbiased estimation of the gradient $\frac{\partial Q(v,c)}{\partial v}$ in a derivative-free fashion.
The hyper-parameter $N'$ controls the trade-off between the computational efficiency and accuracy of NES.
\begin{algorithm}[th]
\caption{Train DNN model end-to-end for budget allocation}\label{alg:train}
\begin{algorithmic}[1]
\State {\bfseries Input:} a training dataset consists of RCT users; initialized DNN model parameter $\theta$;
\State {\bfseries Output:} a well-trained DNN model for budget allocation
\While{not converged}
\State Get one batch of training data from the training set.
\State Run forward-propagation and get predicted results $v$ and $c$.
\State Estimate $\frac{\partial Q(v,c)}{\partial v}$ and $\frac{\partial Q(v,c)}{\partial c}$ using finite-difference strategy (Equation~\eqref{eqn:fd}) or NES (Equation~\eqref{eqn:nes2}).
\State Calculate the surrogate loss $L_S(\theta)$ using Equation~\eqref{eqn:loss_surrogate}.
\State Run back-propagation to obtain $\frac{\partial L_S(\theta)}{\partial\theta}$.
\State Run one gradient descent step to update $\theta$ based on $\frac{\partial L_S(\theta)}{\partial\theta}$.
\EndWhile
\State {\bfseries return} the well-trained DNN model $\theta$.
\end{algorithmic}
\end{algorithm}
Like other Monte Carlo methods, NES also suffers from high variance when estimating a vector in a high dimensional space.
To reduce the variance, we employ antithetic sampling~\cite{salimans2017evolution} to generate $N'$ sampling directions: we first sample $\frac{N'}{2}$ i.i.d. Gaussian noises as $\delta_i,\, i=1,2,\ldots,\frac{N'}{2}$, and then set the remaining $\frac{N'}{2}$ directions by flipping the signs of previous $\frac{N'}{2}$ directions: $\delta_i=-\delta_{N'-i+1},\, i=\frac{N'}{2}+1,\frac{N'}{2}+2,\ldots,N'$.
This sampling strategy has been empirically verified to be effective in many previous works~\cite{ilyas2018black,ilyas2018prior,guo2019subspace}.
\subsection{Training}\label{sec:method_training}
In this section, we present our solution to train the DNN model to maximize the marketing goal, by optimizing the regularized objective $L_R(\theta)$ in Equation~\eqref{eqn:loss_regularized}.
Common gradient descent based optimizers such as SGD or Adam~\cite{kingma2015adam} would require the gradients w.r.t. DNN model parameter (i.e., $\frac{\partial Q(v,c)}{\partial\theta}$) to update $\theta$, while in Section~\ref{sec:method_grad_estimation} we only have $\frac{\partial Q(v,c)}{\partial v}$ and $\frac{\partial Q(v,c)}{\partial c}$.
Thus, a back-propagation step which converts $\frac{\partial Q(v,c)}{\partial v}$ and $\frac{\partial Q(v,c)}{\partial c}$ to $\frac{\partial Q(v,c)}{\partial\theta}$ is required.
To this end, we design the following surrogate loss $L_S(\theta)$:
\begin{equation}\label{eqn:loss_surrogate}
\begin{split}
L_S(\theta)=L_{\textrm{CE}}(\theta)-\lambda\cdot\Tr\left[v^\mathrm{T}\texttt{stop\_gradient}\left(\frac{\partial Q(v,c)}{\partial v}\right)\right]\\
-\lambda\cdot\Tr\left[c^\mathrm{T}\texttt{stop\_gradient}\left(\frac{\partial Q(v,c)}{\partial c}\right)\right],
\end{split}
\end{equation}
where $\lambda>0$ is a scaling factor that balances the importance of the original objective and the regularizer, $\Tr[\cdot]$ is the matrix trace operator, $v^\mathrm{T}$ and $c^\mathrm{T}$ is the transpose of matrix $v$ and $c$ respectively, and $\texttt{stop\_gradient}(\cdot)$ is the operator to treat a certain variable as a constant and avoid back-propagation through it.\footnote{In TensorFlow this could be achieved via $\texttt{tf.stop\_gradient()}$, and in PyTorch this could be achieved by \texttt{tensor.detach()}.}
Unlike the regularizer part of $L_R(\theta)$ which is cumbersome to handle, the regularizer part of $L_S(\theta)$ is a simple linear combination of elements in matrix $v$ and $c$, which are output values from the last layer of the DNN model.
As such, the gradient of $L_S(\theta)$ w.r.t. $\theta$ could be easily obtained by running a standard back-propagation over the DNN model.
Furthermore, it could be verified that $L_S(\theta)$ and $L_R(\theta)$ shares the same first order gradient: $\frac{\partial L_S(\theta)}{\partial\theta}=\frac{\partial L_R(\theta)}{\partial\theta}$.
Thus, with the help of the surrogate loss $L_S(\theta)$, we could effectively optimize the original regularized objective $L_R(\theta)$, and the well-trained DNN model shall learn to maximize the marketing goal in an end-to-end manner.
Algorithm~\ref{alg:train} summarizes all details for training.
\section{Experimental Results}\label{sec:experiment}
\subsection{Datasets}\label{sec:experiment_datasets}
We evaluate the efficacy of our method in three different datasets:
\begin{itemize}
\item Synthetic dataset.
To elaborate on key components of our idea (i.e., EOM and gradient estimation), we generate a synthetic dataset consisting of 10,000 RCT users.
We set four different treatments (i.e., $K=4$), and the treatment $t_i$ applied to the $i$-th user in RCT is randomly sampled from these four treatments with equal probabilities.
We assume the $i$-th user has a four-dimensional ground truth vector $v^{\textrm{gt}}_i\in [0,1]^4$, where the $j$-th element in $v^{\textrm{gt}}_i$ (denoted by $v^{\textrm{gt}}_{ij}$) represents the probability of $y_i=1$ when treatment $j$ is applied to that user.
We use the following three steps to generate $v^{\textrm{gt}}_i$: 1) the first element of $v^{\textrm{gt}}_i$ (i.e., $v^{\textrm{gt}}_{i1}$) is sampled from the uniform distribution in $[0, 0.1]$, 2) to determine the remaining elements of $v^{\textrm{gt}}_i$, we sample three i.i.d. numbers from the uniform distribution in $[0, 0.2]$ and sort these three numbers in descending order (denoted by $0.2\ge k_1\ge k_2\ge k_3\ge 0$), and 2) these three numbers are used as incremental values of $v^{\textrm{gt}}$: let $v^{\textrm{gt}}_{ij}=v^{\textrm{gt}}_{i(j-1)}+k_{j-1}$, where $j=2,3,4$.
Once the four-dimensional ground truth vector $v^{\textrm{gt}}_{i}$ is generated, we get the $t_i$-th element of the $v^{\textrm{gt}}_{i}$ (denoted by $v^{\textrm{gt}}_{i(t_i)}$) and sample the binary response $y_i$ of the $i$-th user from the Bernoulli distribution with probability $v^{\textrm{gt}}_{i(t_i)}$.
We assume the cost of applying the $j$-th treatment to any user is $j$.
In other words, we set the $\left(i,j\right)$-th element in ground-truth cost matrix $c^{\textrm{gt}}$ to be $c^{\textrm{gt}}_{ij}=j$, where $j=1,2,3,4$.
The synthetic dataset is designed for illustrating the effectiveness of EOM and gradient estimation, thus the features of users are omitted in this dataset.
\item CRITEO-UPLIFT v2~\cite{diemert2018large}.
This publicly available dataset is designed for evaluating models for uplift modeling.
This dataset contains 13.9 million samples which are collected from an RCT.
Each sample has 12 dense features, one binary treatment indicator, and two binary labels: visit and conversion.
In this dataset, treatment is defined as whether the user is targeted by advertising or not, and labels are defined as positive if the user visited/converted on the advertiser's website during a test period of two weeks.
To evaluate different budget allocation methods, we follow~\cite{zhou2023direct} and use the visit/conversion label as the cost/value respectively.
We compare the performance of our proposed method with state-of-the-arts in CRITEO-UPLIFT v2 to demonstrate the effectiveness of our method.
\item KUAISHOU-PRODUCE-COIN.
Produce Coin is a common marketing campaign to incentivize short video creators to upload more short videos in Kuaishou.
In this campaign, we provide a prized task to each short video creator on the Kuaishou platform.
Concretely, in each task, if a creator uploads a video within 24 hours, he/she will receive a certain amount of coins as a reward.
Each creator could see the number of coins he/she could possibly obtain, and if the number seems attractive enough the creator might finish the task to collect these coins.
We manually select 30 distinct levels of coins (e.g., 1 coin, 2 coins, $\ldots$), and each creator will be assigned one of these 30 levels.
The amount of coins could be personalized to maximize the total amount of video uploads under the constraint that the total amount of coins does not exceed a certain limit.
In this dataset, we define treatment as the level of coins, thus we have $K=30$ treatments.
For the user (i.e., creator) $u_i$, the response $y_i$ would be $y_i=1$ if the user has successfully completed the task, and otherwise, we set $y_i=0$.
The cost of applying a treatment to $u_i$ would be defined as the real number of coins sent to $u_i$: if $y_i=1$ we set the cost to the number of coins corresponding to the assigned treatment, and if $y_i=0$ we set the cost to zero.
To collect this dataset we conduct an RCT for one week.
In this RCT, we randomly sample one reward level from predefined 30 levels with equal probabilities for each user as the treatment and collect the response/cost label from the logs.
This dataset contains 82.4 million samples, and we deploy several models trained on this dataset in the Kuaishou platform to evaluate the online performance of different methods.
To protect data privacy, we normalize the per-capita response/cost and report the normalized values on all tables and figures.
\end{itemize}
\subsection{Evaluation Metrics}\label{sec:experiment_metrics}
We use the following evaluation metrics to evaluate and compare the performance of different methods:
\begin{itemize}
\item AUCC (Area Under the Cost Curve) in~\cite{du2019improve}.
AUCC is commonly used in existing literatures~\cite{du2019improve,ai2022lbcf,zhou2023direct} to evaluate the ranking performance of uplift models in the two-treatment setting.
Interested readers can check the original paper~\cite{du2019improve} for more details about the evaluation process of AUCC.
In this paper, we use AUCC to compare the performance of different methods in CRITEO-UPLIFT v2.
\item EOM (Expected Outcome Metric).
EOM or similar metric is also commonly used in existing literatures~\cite{ai2022lbcf,zhou2023direct} to empirically estimate the expected outcome (e.g., per-capita response or per-capita cost) for arbitrary budget allocation policy.
EOM can make an unbiased estimation of any outcome, provided that outcome is calculable given a budget allocation solution on RCT data.
Thus, EOM is more flexible than AUCC in practice.
In this paper, we use EOM in the synthetic dataset and the KUAISHOU-PRODUCE-COIN dataset to evaluate different budget allocation methods, and technical details of EOM have been introduced in Equation~\eqref{eqn:same_treatment} and Equation~\eqref{eqn:V_and_D} in Section~\ref{sec:method_regularizer}.
\end{itemize}
\subsection{Implementation Details}\label{sec:experiment_details}
Implementation details on different datasets are shown as follows:
\begin{itemize}
\item The synthetic dataset.
To illustrate the basic idea of EOM and gradient estimation in our proposed method, we first generate a cost matrix $c\in\mathbb{R}_+^{10,000\times5}$ and a value matrix $v\in[0,1]^{10,000\times5}$ as the starting point, and then use the Adam optimizer with a learning rate 0.005 to optimize $v$ by maximizing $Q(v, c)$ for 100 gradient ascent steps.
For the starting point of cost matrix $c$, we directly use the ground-truth cost matrix $c=c^{\textrm{gt}}$ and keep it fixed during gradient ascent.
For the starting point of value matrix $v$, we use the same procedure as described in Section~\ref{sec:experiment_datasets} to re-generate a random matrix $v$ which satisfies the following conditions for all $i$: 1) $0\le v_{i1}\le v_{i2} \le v_{i3} \le v_{i4}$, and 2) $v_{i2}-v_{i1}\ge v_{i3}-v_{i2}\ge v_{i4}-v_{i3} \ge 0$.
We set the per-capita budget to 2.0 for evaluating the $Q$ function.
Since features of users are omitted in the synthetic dataset, we could not expect any generalization.
Thus, we treat all 10,000 samples as training samples and report per-capita response and per-capita cost estimated by EOM on all training samples.
\item CRITEO-UPLIFT v2.
We compare our proposed method with the following baseline methods in terms of AUCC:
\begin{itemize}
\item TSM-SL.
The baseline two-stage method in many existing literatures~\cite{ai2022lbcf,zhao2019unified,zhou2023direct}.
In the first stage, a DNN-based S-Learner model is exploited to predict the conversion uplifts and visit uplifts for individuals.
In the second stage, an MCKP formulation could be used to find the optimal budget allocation solution.
However for AUCC, the explicit budget allocation solution is not required, and we simply rank different individuals by the ratio between the conversion uplifts and visit uplifts and use the rank to compute AUCC.
\item Direct Rank~\cite{du2019improve}.
\citet{du2019improve} propose a direct rank method to directly learn the ratios between values and costs and use the ratios to rank individuals.
\item DRP~\cite{zhou2023direct}.
\citet{zhou2023direct} design several decision factors for MCKP solutions, and propose a surrogate loss function to directly learn these decision factors.
\end{itemize}
Following~\cite{zhou2023direct}, we randomly sample 70\% samples from the dataset as the training set, and the remaining samples are used as the test set.
We report the performance of different methods in the test set, and for baseline methods, we directly cite results from~\cite{zhou2023direct}.
For our proposed method, we use a DNN architecture described in Section~\ref{sec:method_two_stage}: the base DNN is a 4-layer MLP (hidden sizes 512-256-128-64), and each header DNN is a 2-layer MLP (hidden sizes 32-1).
We insert a ReLU activation layer after each fully connected layer in both base DNN and header DNN, except the final output layer in header DNN.
We also insert a Batch Normalization layer~\cite{ioffe2015batch} after the activation layer for faster convergence.
The value of $\lambda$ in the surrogate loss $L_S(\theta)$ in Equation~\eqref{eqn:loss_surrogate} is set to 200.
For the finite-difference strategy, we set $F'=4,000$ and $h=0.0003$.
For NES, we set $N'=2,000$ and $\sigma=0.001$.
The MSRA initialization~\cite{he2015delving} is invoked to initialize all weight matrices in our model.
The randomly initialized DNN S-Learner model is trained using the Adam optimizer with a learning rate of 0.0001 for 10 epochs.
In each training step, the per-capita budget for evaluating the $Q$ function is randomly sampled from a uniform distribution in $[0.039, 0.047]$.
Following~\cite{zhou2023direct}, we run our proposed method 20 times and report the mean and variance of results.
\item KUAISHOU-PRODUCE-COIN.
To demonstrate the effectiveness of our proposed training framework in real-world scenarios, we conduct both offline evaluation and online evaluation to compare our proposed method and TSM-SL.
The offline experiment and online experiment share the following settings:
\begin{itemize}
\item The architecture for base DNN header DNN is kept the same as in the CRITEO-UPLIFT v2 dataset.
\item We train the DNN S-Learner model using the Adam optimizer with a learning rate of 0.0003 for 20 epochs.
To make a fair comparison, we use identical feature engineering/DNN architecture/training policies for our proposed method and TSM-SL.
\item In each training step, the per-capita budget for evaluating the $Q$ function is randomly sampled from a uniform distribution in $[1.0, 1.5]$.
\end{itemize}
Furthermore, in the offline experiment:
\begin{itemize}
\item We randomly sample 80\% of users from the KUAISHOU-PRODUCE-COIN dataset as the training set and the remaining 20\% is used as the test set.
\item We employ EOM and bisection to find the value of per-capita response when per-capita cost equals 1.2, and this metric is used to measure the performance of different methods.
\end{itemize}
In the online experiment:
\begin{itemize}
\item All samples in the KUAISHOU-PRODUCE-COIN dataset are used for training and the obtained well-trained models are deployed in an online A/B test in the Kuaishou platform to compare the efficacy of their budget allocation policies in the real world.
\item The online A/B test is conducted for one week.
There are 14.2 million users in the online A/B test, and these users are disjoint for users in the KUAISHOU-PRODUCE-COIN dataset.
We randomly partition 14.2 million users into two equally sized groups, one group for our proposed method and the other group for TSM-SL.
For each group, the reported per-capita response/cost is directly computed over the entire 7.1 million users, and EOM is not employed.
\end{itemize}
\end{itemize}
\begin{figure}[thbp]
\centering
\begin{subfigure}[b]{0.48\linewidth}
\includegraphics[width=1.0\linewidth]{synthetic_gt_rct}
\caption{}\label{fig:synthetic_gt_rct}
\end{subfigure}
\begin{subfigure}[b]{0.48\linewidth}
\includegraphics[width=1.0\linewidth]{synthetic_nes_cos_sim}
\caption{}\label{fig:synthetic_nes_cos_sim}
\end{subfigure}
\begin{subfigure}[b]{0.48\linewidth}
\includegraphics[width=1.0\linewidth]{synthetic_v0}
\caption{}\label{fig:synthetic_v0}
\end{subfigure}
\begin{subfigure}[b]{0.48\linewidth}
\includegraphics[width=1.0\linewidth]{synthetic_v100}
\caption{}\label{fig:synthetic_v100}
\end{subfigure}
\caption{Results on the synthetic dataset.}\vspace{-1.5em}
\label{fig:synthetic_result}
\end{figure}
\subsection{Results on Synthetic Dataset}
Results on the synthetic dataset are summarized in Figure~\ref{fig:synthetic_result}.
The black line in Figure~\ref{fig:synthetic_gt_rct} shows the statistics about per-capita cost and per-capita value in RCT.
As discussed in Section~\ref{sec:method_regularizer}, starting from any cost and value matrix we could obtain a series of budget allocation solutions corresponding to different budgets, and further invoke EOM to empirically estimate the per-capita value $V\left(v, c,\alpha\right)$ and per-capita cost $C\left(v, c,\alpha\right)$ for each budget allocation solution.
We perform the above EOM procedure using ground-truth $v^{\textrm{gt}}$ and $c^{\textrm{gt}}$, and plot the trajectory of $V\left(v^{\textrm{gt}}, c^{\textrm{gt}},\cdot\right)$ and $C\left(v^{\textrm{gt}}, c^{\textrm{gt}},\cdot\right)$ as the red dotted line in Figure~\ref{fig:synthetic_gt_rct}.
The value of $Q$ function for ground-truth $v^{\textrm{gt}}$ and $c^{\textrm{gt}}$ is $Q\left(v^{\textrm{gt}}, c^{\textrm{gt}}\right)=0.2123$.
To verify the effectiveness of the gradient estimation process, we first generate initial $v$ and $c$ as described in Section~\ref{sec:experiment_details} and study the cosine similarity between our estimated gradient and the precise gradient.
To this end, we first set $F'=40,000$ and use the finite-difference strategy to calculate the precise gradient $\frac{\partial Q(v,c)}{\partial v}$.
Then, we use NES to estimate $\frac{\partial Q(v,c)}{\partial v}$ (Equation~\eqref{eqn:nes2}) and gradually increase $N'$.
Finally, we check the cosine similarity between the NES estimated gradient and the precise gradient.
Figure~\ref{fig:synthetic_nes_cos_sim} shows the relations between cosine similarity and $N'$, and we can see that as more sampling directions are involved in NES, the estimated gradients are more accurate.
We further plug the estimated gradient by NES into an Adam optimizer to maximize $Q(v, c)$, which represents the per-capita value when the per-capita cost equals 2.0.
Figure~\ref{fig:synthetic_v0} shows the per-capita value and per-capita cost of initial $v$ and $c$.
The value of $Q$ function for initial $v$ and $c$ is $Q(v, c)=0.1996$.
After 100 gradient ascent steps, we can increase the value of $Q$ function from 0.1996 to 0.2141.
Figure~\ref{fig:synthetic_v100} shows the per-capita value and per-capita cost of optimized $v$ and $c$.
By comparing Figure~\ref{fig:synthetic_v0} and Figure~\ref{fig:synthetic_v100}, we see that our proposed method could effectively increase the value of $Q$ function.
From the properties of EOM, we know that $Q$ would be an unbiased estimator of the marketing goal.
As such, the marketing goal could be effectively maximized.
Since we only have 10,000 data samples, the Adam optimizer could severely overfit the training data and thus in Figure~\ref{fig:synthetic_v100} there might be a peak around the region where the per-capita budget equals 2.0.
\subsection{Results on CRITEO-UPLIFT v2}
\begin{table}[thbp]
\vspace{-1em}
\caption{Results on CRITEO-UPLIFT v2.}
\label{tab:criteo_result}
\begin{tabular}{cc}
\toprule
Method & AUCC \\
\midrule
TSM-SL & 0.7561 $\pm$ 0.0113 \\
Direct Rank~\cite{du2019improve} & 0.7562 $\pm$ 0.0131 \\
DRP~\cite{zhou2023direct} & 0.7739 $\pm$ 0.0002 \\
Ours-NES & 0.7849 $\pm$ 0.0167 \\
Ours-FD & \bf{0.7904 $\pm$ 0.0096} \\
\bottomrule
\end{tabular}
\end{table}
Results on CRITEO-UPLIFT v2 are summarized in Table~\ref{tab:criteo_result}.
Ours-FD and Ours-NES refer to our proposed method with finite-difference strategy / NES as the gradient estimator, respectively.
We see both Ours-FD and Ours-NES significantly outperform all competitive methods in the sense of AUCC.
Ours-FD has the highest variance in AUCC for 20 runs, and this phenomenon could be partially explained by the fact that NES gradients are noisy.
Although the performance of Ours-FD surpasses that of Ours-NES, Ours-FD costs 4x more running times on an NVIDIA Tesla T4 GPU (Ours-FD 17.6 hours v.s. Ours-NES 4.3 hours) since we need to evaluate the $Q$ function for more times.
\subsection{Results on KUAISHOU-PRODUCE-COIN}
We adopt Ours-FD for the KUAISHOU-PRODUCE-COIN dataset and compare it with TSM-SL.
\begin{figure}[t]
\centering
\includegraphics[width=.75\linewidth]{kuaishou_produce_coin_fd_lambda}
\caption{Impact of $\lambda$ for our method on the KUAISHOU-PRODUCE-COIN dataset.}
\Description{Offline performance on KUAISHOU-PRODUCE-COIN}
\label{fig:kuaishou_produce_coin_fd_lambda}
\end{figure}
\subsubsection{Offline Evaluation}
We are interested in how the value of $\lambda$ in Equation~\eqref{eqn:loss_surrogate} affects the performance of Ours-FD.
We set $\lambda\in\{0,1,2,5,10,20,50,100,200,500,1000,2000,5000\}$ and measure the performance of Ours-FD.
For each value of $\lambda$, we train the model four times and report their average performance.
Figure~\ref{fig:kuaishou_produce_coin_fd_lambda} illustrates the impact of $\lambda$ in Equation~\eqref{eqn:loss_surrogate} in Ours-FD.
By definition, we know that if we set $\lambda=0$, Ours-FD would be reduced to TSM-SL.
If $\lambda>0$, the regularizer would take effect and the DNN S-Learner model could learn from the marketing goal directly.
However, if $\lambda$ is too large, the regularizer could dominate the training objective and the predicted responses and costs could be far away from their ground-truth values thus the training process could be unstable.
In Figure~\ref{fig:kuaishou_produce_coin_fd_lambda}, when $\lambda\le 200$ the per-capita response would increase with $\lambda$, and it is clear that our regularizer is beneficial for the marketing goal in this region.
Furthermore, if $\lambda\ge500$, the performance of Ours-FD would be worse than that of TSM-SL since the training process becomes unstable.
\subsubsection{Online Evaluation}
For online evaluation, we re-train the model using the entire KUAISHOU-PRODUCE-COIN dataset.
We deploy Ours-FD with $\lambda=200$ and TSM-SL into the online A/B test.
To measure the performance of different methods, we calculate the per-capita response and per-capita cost by averaging the results over seven days.
When compared with TSM-SL, Ours-FD achieves a -0.369\% lower per-capita cost and a 1.24\% higher per-capita response simultaneously, which is considered to be a significant improvement over these months.
The Ours-FD model is currently deployed to allocate marketing budgets for hundreds of millions of users.
\section{Conclusion}\label{sec:conclusion}
In this paper, we investigate the end-to-end training framework in the budget allocation problem.
We formulate the business goal under a certain budget constraint as a black-box regularizer and develop two efficient gradient estimation algorithms to optimize it.
For both gradient estimation algorithms, we suggest a hyper-parameter to trade off the computation complexity and the accuracy of estimated gradients.
Our proposed method shall endow the well-trained DNN model with the ability to directly learn from the marketing goal and further maximize it.
Extensive experiments on three datasets have shown the superiority of our method in both offline simulation and online experiments.
Our future work will focus on reducing the variance for gradient estimation and applying this approach in more complicated real-world marketing scenarios.
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2023-02-10T02:07:53', 'yymm': '2302', 'arxiv_id': '2302.04477', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04477'} | arxiv |
\section{Acknowledgement}
The authors of this paper were supported by the NSFC Fund (U20B2053) from the NSFC of China, the RIF (R6020-19 and R6021-20) and the GRF (16211520 and 16205322) from RGC of Hong Kong, the MHKJFS (MHP/001/19) from ITC of Hong Kong and the National Key R\&D Program of China (2019YFE0198200) with special thanks to HKMAAC and CUSBLT, and the Jiangsu Province Science and Technology Collaboration Fund (BZ2021065). We also thank the support from the UGC Research Matching Grants (RMGS20EG01-D, RMGS20CR11, RMGS20CR12, RMGS20EG19, RMGS20EG21, RMGS23CR05, RMGS23EG08).
\section{Comparison between Different Prefix Prompts}\label{sec:prefix_comp}
In this section, we conduct experiments on ACE-2005 dataset to compare the effectiveness of using different prefix prompts in our models. We compare the following prefix prompts with the one discussed in Section \ref{sec:prompting_module}: (1) ``\textbf{This is a [] event whose trigger is "[]".}''; (2) ``\textbf{The event type is [], and its occurrence is most clearly expressed by "[]".}''; (3) ``\textbf{The event type is [] and the trigger is "[]".}''. The results are shown in Table \ref{tab:diff_prefix}, where ``Prefix (0)'' refers to the prefix prompt discussed in Section \ref{sec:prompting_module}, whereas ``Prefix (1)'' refers to the first prefix prompt described in this section, and so on.
\begin{table}[!h]
\centering
\begin{tabular}{cc}
\toprule
Prefix Prompt & F1\\
\midrule
Prefix (0) & \textbf{66.1}\\
Prefix (1) & 65.2\\
Prefix (2) & 65.6\\
Prefix (3) & 63.0\\
\bottomrule
\end{tabular}
\caption{Performance of different prefix prompts.}
\label{tab:diff_prefix}
\end{table}
From the table we can see that the prefix prompt described in Section \ref{sec:prompting_module} is the most effective one, which might be due to the fact that the prefix prompt not only is based on the definitions of events and triggers \citep{grishman2005nyu}, but also has a natural and smooth expression.
\section{Results of all Other Global Constraints}\label{sec:comp_other_cons}
\begin{table*}[!h]
\centering
\resizebox{2\columnwidth}{!}{
\begin{tabular}{cc}
\toprule
Global constraint & Effect on overall performance \\
\midrule
There is at most one Time-Arg in each event. & 0.4 \\
There is at most one Place-Arg in each event. & 0.1 \\
A TRANSPORT event has at most one Destination argument. & -0.2 \\
A TRANSPORT event has at most one ORIGIN argument. & -0.1 \\
A START-POSITION event has at most one Person argument. & 0.2 \\
A START-POSITION event has at most one Entity argument. & -0.1 \\
A START-POSITION event has at most one Position argument. & 0.1 \\
A End-POSITION event has at most one Person argument. & -0.2 \\
If a Start-Position event and an End-Position event share & \multirow{5}{*}{
0.1} \\
arguments, then Start-Position.Person is the same as & \\
End-Position.Person, and Start-Position.Entity is the same & \\
as End-Position.Entity, Start-Position.Position is the same & \\
as End-Position.Position. & \\
If an Arrest-Jail event and a Charge-Indict event share arguments, & \multirow{3}{*}{0.3} \\
Arrest-Jail.Person is the same as Charge-Indict.Defendant, they & \\
share the same Crime argument. & \\
If a Die event and an Attack event share arguments, then & \multirow{5}{*}{-0.2} \\
Die.Place is the same as Attack.Place, Die.Victim is the &\\
same as Attack.Target, Die.Instrument is the same as &\\
Attack.Instrument, Die.Time is the same as Attack.Time, &\\
Die.Agent is the same as Attack.Attacker. & \\
\bottomrule
\end{tabular}
}
\caption{Other global constraints and corresponding effects on overall performance.}
\label{tab:comp_other_cons}
\end{table*}
In this section, we present the results of all other global constraints. The results are shown in Table \ref{tab:comp_other_cons}.
\section{Conclusion}
We propose a zero-shot EAC model using global constraints with prompting.
Compared with previous works, our model does not require any annotation or manual prompt design, and our constraint modeling method can be easily adapted to any other datasets.
Hence, our model can be easily generalized to any open-world event ontologies.
Experiments on two standard event extraction datasets demonstrate our model's effectiveness.
\section{Experiments}
We first present the experimental settings, baselines used for comparison, and some implementation details. Next, we show and analyze the experiment results. Then we present a detailed analysis of the prompting module and global constraints regularization module. Finally, we conduct an error analysis.
\subsection{Settings}\label{sec:settings}
We use ACE (2005-E$^+$)\footnote{https://www.ldc.upenn.edu/collaborations/past-projects/ace} \citep{DoddingtonMPRSW04,LinJHW20} and ERE(-EN) \citep{SongBSRMEWKRM15} as datasets. In total, ACE has 33 event types and 22 roles, whereas ERE has 38 event types and 21 roles. We pre-process all events to keep only the event subtypes whenever applicable, as done in \citep{LinJHW20}.
Following the pre-processing in \citep{ZhangWR21}, for each dataset, we merge all splits into one test set since our approach is zero-shot.
When argument spans are not given, we pipeline our model with an argument identification module adapted from \citep{LyuZSR20}. Specifically, we replace the QA model in \citep{LyuZSR20} with a more powerful PTLM with a span classification head on top, and the whole model has been fined-tuned for extractive QA tasks. Then for a passage, we prompt each role using the new QA model as in \citep{LyuZSR20}. We collect the prompt results for all roles (ignoring the ``None'' result) as candidate spans for the passage.
We use the F1 score for evaluation following \citep{JiG08}, where argument spans are evaluated on the head level when not given.
Regarding PTLMs, We use GPT-J (6B) \citep{gpt-j} instances from Huggingface \citep{WolfDSCDMCRLFDS20}, where an instance for causal language modeling is used for prompting, and an instance for QA is used for argument identification.
In all the following sections except Section \ref{sec:main_res}, we conduct experiments on ACE, assuming that argument spans are given.
\subsection{Main Results}\label{sec:main_res}
\begin{table*}[!ht]
\centering
\resizebox{2\columnwidth}{!}{
\begin{tabular}{ccccc}
\toprule
\multirow{2}{*}{Model} & \multicolumn{2}{c}{ACE} & \multicolumn{2}{c}{ERE} \\%\cline{2-5}
& argument span given & argument span not given & argument span given & argument span not given \\
\midrule
\citep{naacl2022degree} (supervised) & 79.3 & 71.8 & 79.8 & 72.5 \\
\midrule
\citep{LiuCLBL20} & 46.1 & 24.2 & 40.9 & 22.8 \\
\citep{LyuZSR20} & 47.8 & 26.9 & 44.5 & 26.3 \\
\citep{ZhangWR21} & 53.6 & 23.5 & 51.9 & 20.2 \\
Ours & \textbf{66.1} & \textbf{31.2} & \textbf{62.8} & \textbf{29.6} \\ \bottomrule
\end{tabular}
}
\caption{Performance of supervised model, zero-shot baselines, and our model. The best scores among the ones of zero-shot methods are in bold font.}
\label{tab:main_res}
\end{table*}
We report the main results comparing our models with three previous powerful zero-shot models \citep{LiuCLBL20,LyuZSR20,ZhangWR21}. Moreover, we also report the results of a SOTA supervised model \citep{naacl2022degree}. We obtain the results of all compared methods from our own experiments to ensure a fair comparison on the same datasets and same settings.
From Table \ref{tab:main_res}, we have the following observations:
\begin{itemize}
\item Our model achieves superior performance on both datasets under both settings compared with all zero-shot baselines. Specifically, our model surpasses the best zero-shot baselines \citep{ZhangWR21} by 12.5\% and 10.9\% on ACE and ERE, respectively. Without argument spans, our model outperforms the respective best zero-shot baselines \citep{LyuZSR20} by 4.3\% and 3.3\% on ACE and ERE, respectively, which is also a noticeable gap. Such large performance improvements can be attributed to the following: (1) the prefix prompt guides the PTLM to effectively capture input's event-related perspective and trigger; (2) the cloze prompt leverages linguistic and commonsense knowledge stored in PTLM to improve its contextual understanding of event arguments; (3) the global constraints regularization incorporate global information and domain knowledge in inference. In Section \ref{sec:analyze_prompt}, we compare the effects of using different PTLMs like BERT in the prompting module, and the results show that our model consistently outperforms previous zero-shot models, as shown in Table \ref{tab:main_res} and Figure \ref{fig:analysis_prompt_ptlm}.
\item Compared with the supervised SOTA model \citep{naacl2022degree}, there is still a significant gap between our model's performance and that it. Specifically, \citep{naacl2022degree} outperforms our model by 13.2\% and 17.0\% on ACE and ERE, respectively. When argument spans are not provided, \citep{naacl2022degree} outruns our model by 40.6\% and 42.9\% on ACE and ERE, respectively. We can see that the advantage of supervised SOTA over our zero-shot method is much more distinct when argument spans are not given in advance. This is probably because our zero-shot argument identification module described in Section \ref{sec:settings} is not powerful enough, which causes severe error propagation to our EAC model.
\end{itemize}
\subsection{Analysis of Prompting Module}\label{sec:analyze_prompt}
We conduct experiments to examine the effects of different configurations of prefix prompt templates.
Specifically, we compare our model's complete prefix prompt with the following configurations: (1) removing event type information from the prefix; (2) removing trigger information from the prefix; (3) removing the whole prefix.
For instance, suppose the passage is ``In Baghdad, a bomb was fired at 17 people.'' mentioned in Section \ref{sec:prompting_module}, the prefix in configuration (1) would be \textbf{``This event's occurrence is most clearly expressed by `fired'.''}, the prefix in configuration (2) would be \textbf{``This is a Attack event.''}, and in configuration (3) there would be no prefix.
\begin{table}[t]
\centering
\begin{tabular}{ccc}
\toprule
Configurations & F1 & $\Delta$ \\
\midrule
complete prefix prompt & 66.1 & - \\
\midrule
w/o event type & 64.4 & -1.7 \\
w/o trigger & 64.9 & -1.2 \\
w/o prefix prompt & 62.8 & -3.3 \\
\bottomrule
\end{tabular}
\caption{Results of using different configurations of prefix prompt.}
\label{tab:prefix}
\end{table}
The corresponding results are shown in Table \ref{tab:prefix}, where we have the following observations. First, removing either event type or trigger from the prefix prompt will cause a performance drop, which indicates that both kinds of information have contributions to the prompting process. Second, event type plays a more significant role than trigger does in prefix prompt, and the joint effect of them is greater than the sum of their respective effects.
In addition, we examine the effects of using different PTLMs in the prompting module.
We compare the following PTLMs with GPT-J (6B): BERT (large, uncased) \citep{DevlinCLT19}, RoBERTa (large) \citep{roberta}, BART (large) \citep{LewisLGGMLSZ20}, GPT-2 (xl) \citep{radford2019language}, T5 (11B) \citep{RaffelSRLNMZLL20}. The results are shown in Figure \ref{fig:analysis_prompt_ptlm}, where we have the following observations.
\begin{figure}[t]
\centering
\resizebox{\columnwidth}{!}{
\includegraphics{Figures/analysis_prompt.png}
}
\caption{Comparison between the performance of using different PTLMs in prompting module.}
\label{fig:analysis_prompt_ptlm}
\end{figure}
First, the instance using GPT-J has the best performance, surpassing other instances by 4.2\% to 7.9\%. This shows that GPT-J has a better ability to understand events and their associated arguments compared to other PTLMs. Second, as PTLMs are listed in ascending order based on their numbers of parameters, we can see that for the first five models, the performance increases as the sizes of PTLMs become larger, which is consistent with the widely accepted notion that the larger model has a better capability of solving language tasks. However, the instance using the largest PTLM, T5 (11B), has a worse performance than GPT-2 and GPT-J. This is probably because autoregressive language modeling is more suitable for capturing information related to event arguments than mask language modeling is.
\subsection{Analysis of Global Constraints Regularization Module}\label{sec:analyze_constraint}
We conduct experiments to study the individual effect of each global constraint on the overall performance.
The results are shown in Table \ref{tab:used_constraints}, where we have the following observations.
\begin{table}[!h]
\centering
\begin{tabular}{cccc}
\toprule
~ & Model & F1 & $\Delta$ \\
\midrule
~ & Full model & 66.1 & - \\
\midrule
~ & w/o cross-task constraint & 60.5 & -5.6 \\
~ & w/o cross-argument constraint & 64.8 & -1.3 \\
~ & w/o cross-event constraint & 63.6 & -2.5 \\
\bottomrule
\end{tabular}
\caption{Results of using different configurations of global constraints.}
\label{tab:used_constraints}
\end{table}
First, every global constraint used by our model is beneficial to overall performance, which demonstrates that exploiting the domain knowledge about cross-task, cross-argument, and cross-event relations indeed provides our model with global understanding of event arguments. Second, the contribution of cross-task constraint is the most significant, which suggests that the global insights from the entity typing tasks are more effective in improving our model's reasoning ability about event arguments. Third, the cross-argument constraint is less effective than the other constraints, which shows that the global insights provided by the cross-argument constraint is less informative than those provided by the other constraints.
Apart from the three global constraints described above, we have designed another 11 global constraints, which rely on cross-argument or cross-event relations. We add each of them into our model to check their respective effects on the overall performance.
The results of three of them are in Table \ref{tab:other_constraints}, whereas the results of all of them are in Section \ref{sec:comp_other_cons}.
From the results, we can find that each of these constraints either brings minor improvement or even has a negative influence on the overall performance.
Hence, we do not incorporate these constraints in our model to maintain our model's efficiency and effectiveness. %
\begin{table*}[t]
\centering
\resizebox{2\columnwidth}{!}{
\begin{tabular}{cc}
\toprule
Global constraint & Effect on overall performance \\
\midrule
There is at most one Time-Arg in each event. & 0.4 \\
A TRANSPORT event has at most one ORIGIN argument. & -0.1 \\
If an Arrest-Jail event and a Charge-Indict event share arguments, & \multirow{3}{*}{0.3} \\
Arrest-Jail.Person is the same as Charge-Indict.Defendant, they & \\
share the same Crime argument. & \\
\bottomrule
\end{tabular}
}
\caption{Results of three other global constraints. Results of all other global constraints are in Section \ref{sec:comp_other_cons}}
\label{tab:other_constraints}
\end{table*}
\subsection{Error Analysis}\label{sec:error_analysis}
We manually checked 100 wrong predictions of our model and found that most of the errors are caused by too general roles of some event types. Specifically, some roles' linguistic meanings are so general that a model, not knowing their detailed event-type-dependent semantics, tends to assign them to some arguments which should have been assigned other roles. An example is shown in Figure \ref{fig:error_analysis}.
\begin{figure}[t]
\centering
\resizebox{0.85\columnwidth}{!}{
\includegraphics{Figures/Error_Analysis.png}
}
\caption{An Example of the wrong prediction caused by too general argument roles. The text in \textbf{bold face} denotes trigger and the \underline{underlined text} denotes target argument span.}
\label{fig:error_analysis}
\end{figure}
The example describes a Justice:Arrest-Jail event, which is associated with the following roles: ``Person,'' ``Agent,'' ``Crime,'' ``Time,'' and ``Place.'' ``Person'' refers to the person who is jailed or arrested, whereas ``Agent'' refers to the jailer or the arresting agent. In the example, the argument span's true role should be ``Agent'' according to the detailed event-type-dependent semantics of ``Person'' and ``Agent.''
However, our approach is zero-shot and directly models all role labels as natural language words, without incorporating the detailed event-type-dependent semantics of those roles, which are too general (e.g., ``Person'').
Therefore, our model assigns ``Person'' to ``Police'' since it is reasonable from the perspectives of linguistic and commonsense knowledge, and ``Person'' is much more common than ``Agent'' in the pre-training corpus of the PTLM in the prompting module, which makes it have much higher likelihood in the language modeling process.
Incorporating event-type-dependent semantics of the roles which are too general into our model is left as future work.
\section{Introduction}
Event Argument Classification\footnote{We focus on event argument because existing zero-shot trigger extraction models like \citet{ZhangWR21} are already strong enough, but the arguments remain a challenge. Our argument identification approach is described in Section \ref{sec:settings}.} (EAC), finding the roles of event arguments, is an important and challenging event extraction sub-task.
\begin{figure}
\centering
\resizebox{0.85\columnwidth}{!}{
\includegraphics{Figures/EAC_Example.png}
}
\caption{An example of EAC. The trigger is in \textbf{bold face}. Arguments are \underline{underlined} and connected to their roles by arrows.}
\label{fig:eac_example}
\end{figure}
As shown in Figure \ref{fig:eac_example}, a ``Transfer-Money'' event whose trigger is ``acquiring'' has several argument spans (e.g., ``Daily Planet''). By determining the role of these arguments (e.g., ``Daily Planet'' as ``Beneficiary''), we can obtain a better understanding of the event, thus benefiting related applications like stock price prediction \citep{DingZLD15} and biomedical research \citep{ZhaoZYHML21}.
Many previous EAC works require numerous annotations to train their models \citep{LinJHW20,naacl2022degree,LiuHSW22}, which is not only costly as the annotations are labor-intensive but also difficult to be generalized to datasets of novel domains.
Accordingly, some EAC models adopt a few-shot learning paradigm \citep{MaW0LCWS22,naacl2022degree}. However, they are sensitive to the few-shot example selection and they still require costly task-specific training, which hinders their real-life deployment.
There have been some zero-shot EAC models based on transfer learning \citep{DaganJVHCR18}, or label semantics \citep{ZhangWR21, WangYCSH22}, or prompt learning \citep{LiuCLBL20,LyuZSR20,HuangHNCP22,abs-2204-02531}.
However, these models' corresponding limitations impede their real-life deployment. The model based on transfer learning can be ineffective when new event types are very different from the observed one. As for models using label semantics, they require a laborious preparation process and have unsatisfactory performance. Regarding models adopting prompt learning, they need tedious prompt design customized to every new type of events and arguments, and their performance is also limited.
To address the aforementioned issues, we propose an approach using global constraints with prompting to tackle zero-shot EAC.
Global constraints can be viewed as a type of supervision signal from domain knowledge, which is crucial for zero-shot EAC since supervision from annotations is inaccessible. Moreover, our model's constraints module provides abundant global insights across tasks, arguments, and events.
Prompting can also be regarded as a supervision signal as it induces abundant knowledge from Pre-Trained Language Models (PTLM).
Unlike previous zero-shot EAC works, which need a tedious prompt design for every new type of events and arguments, the novel prompt templates of our model's prompting module can be easily adapted to all possible types of events and arguments in a fully automatic way.
Specifically, given an event and its passage, our model first adds prefix prompt, cloze prompt, and candidate roles into the passage, which creates a set of new passages. The Prefix prompt describes the event type and trigger span. Cloze prompt connects each candidate to the target argument span. Afterwards, our model adopts a PTLM to compute the language modeling loss for each of the new passages, whose negative value would be the respective prompting score.
The role with the highest prompting score is the initial prediction.
Then, our model uses global constraints to regularize the initial prediction. The global constraints are based on the domain knowledge of the following relations: (1) cross-task relation, where our model additionally performs another one or more classification task on target argument span, and our model's predictions on EAC and other task(s) should be consistent; (2) cross-argument relation, where arguments of one event should collectively abide by certain constraint(s); (3) cross-event relation, where some argument playing a certain role in one event should play a typical role in another related event.
We conduct comprehensive experiments to demonstrate the effectiveness of our model. Particularly, our approach surpasses all zero-shot baselines by at least 12.5\% and 10.9\% F1 on ACE and ERE, respectively. When argument spans are not given, our model outperforms the best zero-shot baseline by 4.3\% and 3.3\% F1 on ACE and ERE, respectively.
Besides that, we also conduct experiments to show that both the prompting and constraints modules contribute to the final success.
\section{Limitations}
Our work has the following limitations.
One limitation is that our model is not aware of the detailed event-type-dependent semantics of those roles which are too general, as discussed in Section 3.5. In the future, we will work on enabling our model to capture the event-type-dependent semantics of the roles which are too general.
Another limitation is that our model's performance is still unsatisfactory compared with SOTA supervised model when argument spans are not given, as discussed in Section 3.2.
In the future, we will work on designing a more powerful zero-shot event argument identification module for our model, so that we can obtain satisfactory zero-shot EAC performance even when argument spans are not given.
\section{Methodology}
We first present an overview of our approach. Then we introduce the details by describing its prompting module and global constraints regularization module.
We follow \citep{DBLP:journals/corr/abs-2107-13586} to name a prompt inserted before input text as \textit{prefix prompt}, and a prompt with slot(s) to fill in and insert in the middle of input text as \textit{cloze prompt}.
\subsection{Overview}\label{sec:model_overview}
\begin{figure*}[t]
\centering
\resizebox{2\columnwidth}{150pt}{
\includegraphics{Figures/Model_Overview.png}
}
\caption{Model overview using prediction for one argument span as an example. $[T]_1$ and $[T]_2$ are the parts of the input passage before and after the span, respectively. $k$ is the number of candidate roles of the event type.}
\label{fig:model_overview}
\end{figure*}
As shown in Figure \ref{fig:model_overview}, given a passage with a target argument span, our model infers the target's role without annotation and task-specific training. Our model has two modules.
The first module is the prompting module that creates and scores several new passages. During creation, the model adds prefix prompt, cloze prompt, and candidate roles into the passage, where the prefix prompt contains information about event type and trigger, and the cloze prompt joins each candidate with a target argument span.\footnote{Since we focus on event argument classification, we assume that the event types and trigger spans are given. The settings without given argument spans will be discussed in Section \ref{sec:settings}.} Afterwards, the model uses a PTLM to score the new passages.
Our novel prompt templates can easily adapt to all possible events and arguments without manual work.
Initial prediction is the role with the best prompting scores.
The second module is the global constraints regularization module, where the model regularizes the prediction by three types of global constraints: cross-task constraint, cross-argument constraint, and cross-event constraint. All global constraints are based on event-related domain knowledge about inter-task, inter-argument, and inter-event relations.
\subsection{Prompting Module}\label{sec:prompting_module}
In this section, we describe the prompting module in detail.
Given a passage, we first add a prefix prompt containing information about the event type and trigger span to the beginning. Such a prompt can guide a PTLM to: (1) accurately capture the input text's perspective related to the event; (2) have a clear awareness of the trigger.
Based on the definitions of events and triggers \citep{grishman2005nyu}, we create the following prefix prompt: ``\textbf{This is a [] event whose occurrence is most clearly expressed by [].}'' where the first and second pairs of square brackets are the placeholders of event type and trigger span respectively. We also conducted some experiments comparing different prefix prompts in Section \ref{sec:prefix_comp}, and the results showed that the prefix above is the most effective.
Second, for each candidate role, the module inserts the cloze prompt behind the target argument span, and the role fills the prompt' slot.
The cloze prompt adopts the hypernym extraction pattern ``\textbf{M and any other []}'' \citep{DaiSW20}, where ``M'' denotes the argument span and the square bracket is the placeholder of the candidate role. We did not try other hypernym extraction patterns as \citep{DaiSW20} had shown that our pattern is the most effective.
The motivation for adopting the hypernym extraction pattern for cloze prompt is that, to some extent a role can be regarded as a context-specific hypernym of the respective argument span of the associated event (e.g., ``Beneficiary'' can be seen as a context-specific hypernym of ``Daily Planet''of the Transfer-Money event described by the example in Figure \ref{fig:eac_example}). Hence, such a prompt induces the linguistic and commonsense knowledge stored in PTLM to help identify which candidate role is the most reasonable.
After adding the previous two types of prompts, we get several new passages. For instance, suppose the passage is``In Baghdad, a bomb was fired at 17 people.'' whose event type is ``Conflict:Attack'', trigger is ``fired'', target argument span is ``bomb'', and candidate roles are \{``Attacker'', ``Instrument'', ``Place'', ``Time'', ``Target''\}.
The created passages would be: (1) ``\textit{This is a Attack event whose occurrence is most clearly expressed by ``fired.''} In Baghdad, a bomb \textit{and any other \underline{attacker}} was fired at 17 people.''; (2) ``\textit{This is a Attack ... ``fired.''} ... bomb \textit{and any other \underline{instrument}} was ...''; and similar text for other roles.\footnote{We only use the subtype of all events following the pre-processing done by \citep{LinJHW20}}
For each new passage, we apply a PTLM to compute the language modeling loss.
The negative value of the loss would be the prompting score of the respective passage, where a higher value indicates higher plausibility according to the PTLM.
\textbf{Since our model's prompt templates are independent of event type and argument role, their adaptation to any new type of events and arguments is trivial and fully automatic.} Hence, our prompting method is more scalable and generalizable than those of previous zero-shot EAC models, since, for every new type of events and arguments they need to design a customized prompt. For instance, for every type of events/arguments, \citet{LyuZSR20} manually design a unique prompt as text entailment/question answering template.
The initial prediction would be the role with the highest prompting score.
Since the steps of obtaining scores for each candidate role are independent of other candidate roles, we implement the steps of different candidate roles in parallel. Such a parallel implementation significantly improves our model's efficiency.
\subsection{Global Constraints Regularization Module}\label{sec:constraints}
This module regularizes the prediction by the following three types of global constraints.\footnote{We designed 14 global constraints in total and we used preliminary experiments to choose the three most effective ones. In the preliminary experiments, we randomly sample 1k instances covering all trigger and argument types. We then evaluate each constraint on the sampled subset.}
\textbf{Cross-task constraint} exploits the label dependency between EAC and auxiliary task(s) so that our model can get global information from the auxiliary task(s) about event arguments. We use \textbf{Event Argument Entity Typing (EAET)} as the auxiliary task. The task aims to classify an argument into its context-dependent entity type (e.g., PER). \textbf{As specified in ACE2005 ontology, an argument of a certain role in an event can only be one of several respective entity types (e.g., an argument of ``Attack'' role in a Conflict:Attack event can only be ``ORG,'' ``PER,'' or ``GPE'').} Based on this domain knowledge, we design the cross-task constraint as follows: (1) For each input passage, our model performs prompting for EAET, where the prompting is the same as in Section \ref{sec:prompting_module} except that candidate entity types replace the candidate roles in cloze prompt.; (2) After obtaining the scores and prediction of EAET, the model check the consistency between the predictions of EAC and EAET; (3) If the consistency is violated and the score of EAC's predicted role is lower, then discard the current role, use the role with the highest score in the remaining ones, and check the consistency again; (4) The constraint ends when the labels of two tasks are consistent. An example illustrating this type of constraint is shown in Figure \ref{fig:cross-task_constraint}.
\begin{figure}[t]
\centering
\resizebox{0.8\columnwidth}{!}{
\includegraphics{Figures/Cross-task_constraint.png}
}
\caption{An Example of cross-task constraint. The text in \textbf{bold face} is the trigger, \underline{underlined text} is target argument span, and a tuple denotes a predicted label with its prompting score (e.g., ``(Target, -3.5)’’ denotes the predicted label ``Target’’ with its prompting score``-3.5’’). Similar notations are adopted in all remaining figures.}
\label{fig:cross-task_constraint}
\end{figure}
\textbf{Cross-argument constraint} is based on domain knowledge about relationships between arguments within an event. Specifically, our model constrains the number of particular arguments for some or all events. For instance, it is very unlikely that an event mentioned is associated with multiple ``Time'' arguments. Such constraints offer a global understanding of event arguments to our model. The cross-argument constraint we adopt is ``\textbf{A Personnel:End-POSITION event has at most one Position argument}.'' Given a Personnel:End-POSITION event, our model first checks the number of ``Position'' argument. If the number is more than one, then our model will first collect the arguments whose roles are ``Position'' and remove the one with the highest score among these arguments. Then for each remaining argument, our model would change the role to its candidate with the second highest score. An example illustrating this type of constraint is shown in Figure \ref{fig:cross-argument_constraint}.
\begin{figure}[t]
\centering
\resizebox{0.6\columnwidth}{!}{
\includegraphics{Figures/Cross-argument_constraint.png}
}
\caption{An Example of cross-argument constraint.}
\label{fig:cross-argument_constraint}
\end{figure}
\textbf{Cross-event constraint} regularizes predicted roles of arguments shared by related events. A model with such a constraint can have global insights into event arguments, because while they are making inferences for the arguments of one event, they are aware of the information of other related event(s) and cross-event relations.
The cross-event constraint we adopt is ``\textbf{If a Life:Injure event and a Conflict:Attack event share arguments, then Injure.Place is the same as Attack.Place, Injure.Victim is the same as Attack.Target, Injure.Instrument is the same as Attack.Instrument, Injure.Time is the same as Attack.Time, Injure.Agent is the same as Attack.Attacker}''. Given a passage containing an Injure and an Attack event sharing arguments, the model imposes the constraint by checking the consistency between the respective roles of each shared argument as specified in the constraint. Any inconsistency would be fixed by changing the role with a lower prompting score to the new one satisfying the consistency. An example illustrating this type of constraint is shown in Figure \ref{fig:cross-event_constraint}.
\begin{figure}[t]
\centering
\resizebox{\columnwidth}{!}{
\includegraphics{Figures/Cross-event_constraint.png}
}
\caption{An Example of cross-event constraint.}
\label{fig:cross-event_constraint}
\end{figure}
Our constraint modeling method can be easily generalized to other datasets/ontologies by simply using the knowledge about corresponding cross-task, cross-argument, and cross-event relations to design new constraints. The design processes are not costly as we could easily find such knowledge from the guidelines of the target dataset.
\section{Preliminaries}
In this paper, we denote the sets of event types and argument roles as $\mathcal{E}$ and $\mathcal{R}$ respectively. Given an event type $E \in \mathcal{E}$ like ``Justice:Sue,X'' $\mathcal{R}_E \subset \mathcal{R}$ denotes the set of roles the arguments in $E$ can possibly have.
Pre-trained language model is abbreviated as PTLM.
Given a passage $S$, an event trigger $g$ in $S$, the event type $E_g$ of $g$, argument spans $\mathcal{A}_g$ of $g$ in $S$, the aim of zero-shot EAC is: for every argument $a \in \mathcal{A}_g$, find its role $r_a \in \mathcal{R}_{E_g}$ without annotation and task-specific training. We follow \citep{DBLP:journals/corr/abs-2107-13586} to name a prompt inserted before input text as \textit{prefix prompt}, and a prompt with slot(s) to fill in and inserted in the middle of input text as \textit{cloze prompt}.
\section{Related Work}
In this section, we introduce related works about constraint modeling, event extractions, and prompt-based Information Extraction (IE).
\subsection{Constraint Modeling}
Constraint modeling, as an important technique in machine learning and NLP, aims to improve a model's performance by incorporating domain knowledge as constraints~\cite{ganchev2010posterior,chang2012structured,ChangSR13,DeutschUR19,ChangRRR08,CGRS10,GracaGT10}.
One of the most significant advantages of constrained modeling is that it enables a model to capture the expressive and complex dependency structure in structured prediction problems like EAC~\cite{chang2012structured}.
Especially in zero-shot scenarios, constrained modeling can provide useful indirect supervision to a model, which further boosts performance~\cite{ganchev2010posterior}.
Some previous works have adopted constraints based on event-related domain knowledge to classify event arguments~\cite{LinJHW20,ZhangWR21}.
However, their constraints either require labor-intensive annotations~\cite{LinJHW20} or consider limited global information (e.g., cross-event relations)~\cite{ZhangWR21}.
In this paper, our model uses global constraints to regularize prediction by incorporating global insights from cross-task, cross-argument, and cross-event relations.
\subsection{Event Extraction}
Event extraction is a fundamental information extraction task~\cite{DBLP:conf/muc/Sundheim92,DBLP:conf/coling/GrishmanS96,DBLP:conf/aaai/Riloff96,grishman2005nyu,chen2021event,DuC20,LiuCLBL20}, which can be further divided into four sub-tasks: trigger identification, trigger classification, argument identification, and argument classification.
Traditional efforts mostly focus on the supervised setting~\cite{JiG08,DBLP:conf/acl/LiaoG10,DBLP:conf/acl/LiuCHL016,DBLP:conf/acl/ChenXLZ015,DBLP:conf/naacl/NguyenCG16,DBLP:conf/emnlp/LiuLH18,DBLP:journals/dint/ZhangJS19,DBLP:conf/emnlp/WaddenWLH19,LinJHW20}.
However, these works could suffer from the huge burden of human annotation.
In this work, we focus on the argument classification task and propose a model using prompting and global constraints, without annotation and task-specific training.
\subsection{Prompt-based IE}
With the fast development of large PTLMs like T5~\cite{RaffelSRLNMZLL20}, GPT-3~\cite{DBLP:conf/nips/BrownMRSKDNSSAA20}, and Pathway Language models~\cite{DBLP:journals/corr/abs-2204-02311}, the prompt-based method has been an efficient tool of applying those giant models into downstream NLP tasks~\cite{DBLP:journals/corr/abs-2107-13586}. IE is not an exception.
People have been using leverage prompts and giant models to solve IE tasks like named entity recognition~\cite{DBLP:conf/acl/CuiWLYZ21}, semantic parsing~\cite{DBLP:conf/emnlp/ShinLTCRPPKED21}, and relations extraction~\cite{DBLP:journals/corr/abs-2202-04824,DBLP:journals/corr/abs-2105-11259} in a zero-shot or few-shot way.
However, previous prompting methods for IE need a tedious prompt design for every new type of events and arguments.
In contrast, our model's prompt templates can be adapted to all possible types of events and arguments in a fully automatic way.
| {'timestamp': '2023-02-10T02:07:20', 'yymm': '2302', 'arxiv_id': '2302.04459', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04459'} | arxiv |
\section{Introduction}
With the proliferation of mobile devices, an increasing amount of population data is being collected, and there is a growing demand for their use.
Currently, we can quickly find out how many people are staying in Tokyo, Japan, at any given time or place.
These data can be useful in a wide range of situations. For example, they can be exploited to reduce crowding and traffic congestion through transportation planning, to improve the efficiency of rideshares and delivery services, to promote consumption, and to guide evacuation and estimate casualty losses during disasters \citep{wang2018spatial,suzuki2013using,paez2004spatial}. Hence, analyzing population data is important; this study addresses this issue.
Our motivating dataset is population data collected by NTT DOCOMO, one of the largest mobile carriers in Japan.
NTT DOCOMO has approximately 82 million customers (excluding corporate accounts) in Japan, and based on their operational data, the number of mobile terminals in each base station area is counted. The population of each area is then extrapolated with high accuracy using NTT DOCOMO's cell phone penetration rate \citep[See][for more details]{terada2013population,oyabu2013evaluating}. We will focus on the five special wards of Tokyo as our study area. A mesh is defined as a square of 500 meters, and there are approximately 400 meshes in the area. At each mesh, hourly population data was obtained for 365 days.
Our objective in this paper is to predict the population in each district. There are several characteristics of the data that should be understood before constructing the model.
The first is the spatial structure.
Figure \ref{fig:districts} illustrates the number of people at 14:00 on January 29, 2019. There are some districts with more people and some with fewer people, and these geographic changes are gradational. Hence the spatial correlation should be taken into account.
Another feature is the time series structure.
Consider the hourly population transition in two districts, an office and a residential area, for the week beginning Sunday, January 13, 2019, shown in Figure \ref{fig:population}. The red and blue points represent the flow of people in a business district and residential area, respectively.
Basically, the population trends of the previous day are the same as that of the following day, but the population trend switches drastically between holidays (Sunday, Saturday, and Monday, which is a public holiday) and weekdays.
This is intuitive; on weekdays, more people stay in the business area, whereas on holidays, downtown and residential areas are relatively more populated.
In addition, the data presented here has the distinction of being large-scale, with dozens dimensional data collected over hundreds of days and hundreds of locations. This is a considerable obstacle in spatiotemporal modeling.
\begin{figure}[t]
\centering
\includegraphics[width=0.65\textwidth]{fig_map_id.pdf}
\caption{Number of people in central districts of Tokyo at $14$ AM on January $29, 2019.$\label{fig:districts}}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=\textwidth]{Fig3.pdf}
\caption{Hourly population data in two districts. Red represents a business district and blue represents a residential area.\label{fig:population}}
\end{figure}
In this study, we integrate (a) functional data analysis (FDA) and (b) Bayesian factor models to solve those issues.
\begin{itemize}
\item[(a)] FDA is a methodology that treats and analyzes longitudinal data as curves, reduces parameters, and facilitates handling high-dimensional data \citep{ramsay2004functional,horvath2012inference,kokoszka2017introduction}. Even with discretely measured data, it is natural to think of the data as if there is a latent curve because the data are assumed to exist not only at the point of observation but also at other points.
Many methods have been used to fit the function, including methods that apply basis functions such as splines and Fourier functions. In this work, the path of the Gaussian process is assumed to be the underlying function, and its parameters are of interest.
\item[(b)] To estimate the mean parameters, we introduced the Bayesian factor model \citep[e.g.,][]{calder2007dynamic,nakajima2013bayesian,lopes2000bayesian,lopes2003expected}. Based on the state space model, a few distinctive districts of the city were assigned as factors to elucidate the spatial dependence and reduce the computational cost because only the time series of factors needed to be considered.
\end{itemize}
These two elaborations make it possible to implement the large-scale spatiotemporal model. The method is feasible by Gibbs sampler \citep{gelfand1990sampling} and also allowed for the development of factor selection schemes based on posterior predictive loss \citep{gelfand1998model}.
In addition, we set the factor loading matrix to be identifiable and sparse. Identifiability allows for unique inference results for factor loading matrices, and sparsity clarifies which districts influence another district.
This interpretability, along with the uncertainty inherent in Bayesian models, makes predictions important in applications.
Highly explanatory forecasts are useful to convince decision-makers, and 95\% probability bad case scenarios are of value to them.
Because the demand for their use will continue to increase as more detailed regional and temporal population data become available, our proposed method may contribute to evidence-based policy making.
The FDA framework for spatiotemporal data has been addressed in several previous studies \citep{zhang2023bayesian,li2021multilevel,wakayama2021locally,romano2011clustering,giraldo2011ordinary,jiang2012clustering}. However, most of them have taken the approach of using time as the argument of the function and incorporating it into the analysis of spatial function data, ignoring the temporal structure.
While there have been a few spatiotemporal developments in topics unrelated to forecasting (e.g., missing value completion by \cite{zhu2022spatiotemporal}), our contribution to the field is to propose a forecasting model that reflects spatiotemporal features in the state space.
The remainder of the paper is organized as follows.
Section \ref{sec:model} describes the settings, model, its computations and factor selection procedure.
In Section \ref{sec:sim}, we study the features and performance of our method compared to other methods through numerical experiments.
We apply our method to population flow data in Section \ref{sec:DA}. The contributions of this study are discussed in section \ref{sec:con}.
\section{Spatiotemporal Factor Models for Functional Data}\label{sec:model}
\subsection{Setting and model}\label{sec:set}
Let $y_{ts}(\tau)$ be the observed functional data (population) at time $t\in \{1,\ldots,T\}$ and in region $s\in\{1,\ldots,N\}$ with an observation point $\tau \in \{\tau_1,\ldots,\tau_K\}.$
For any $t$ and $s$, we assume the following measurement error model.
\begin{align*}
y_{ts}(\tau) &= z_{ts}(\tau)+ \varepsilon_{ts} , \ \ \ \ \ \varepsilon_{ts}\sim N(0,e_s^2),
\end{align*}
where $\varepsilon_{ts}$ is an error term, which is independent of $t$ and $s$, $e^2_s$ is an unknown variance, and $z_{ts}$ is the focus.
Such models are widely adopted in the context of Bayesian modeling of functional data \citep{yang2016smoothing,yang2017efficient,wakayama2022functional}.
Assume function $z_{ts}$ follows the Gaussian process.
\begin{align*}
z_{ts}(\tau) \sim \mathcal{GP}(f_{ts}, \eta_s^2 R(\phi_s)),
\end{align*}where $f_{ts}$ is the mean parameter, $R(\phi_s)= \rho_{\phi_s}(d)$ is correlation kernel and $\eta_s$ is its scale.
Given the observed points, $\tau_1,\ldots,\tau_K$, the above assumption leads to the following multivariate normal distribution:
\begin{align*}
(z_{ts}(\tau_1),\ldots, z_{ts}(\tau_K)) \sim N \left((f_{ts}(\tau_1),\ldots, f_{ts}(\tau_K)), \tilde{R}_s \right),
\end{align*}
where $\tilde{R}_s$ denotes a $K\times K$-matrix with $(i,j)$-components $\eta_s^2 \rho_{\phi_s}(|\tau_i-\tau_j|)$.
Viewing a vector as a finite subset of a stochastic process is beneficial. If we attempt to estimate a $K$-dimensional covariance matrix using ordinary multivariate analysis, as many as $K \times (K-1)/2$ (e.g., $24(24-1)/2=276$ if $K=24$) parameters are required, which is laborious to estimate.
However, by assuming that the vector is a finite subset of the path of a stochastic process, we only need to estimate a few parameters of the covariance kernel (only $\eta_s$ and $\phi_s$ for each point in the above case).
In other words, time-consuming calculations are eliminated by considering the underlying stochastic process.
\subsection{State space factor models}
To model the mean parameters over time and space, the following state models are considered:
\begin{align}\label{eq:factor}
\bm{z}_t &= (B\otimes I_K)\bm{x}_t+\bm{\nu}_t,\ \ \ \ \ \ \bm{\nu}_t\sim N(\bm{0},\mathrm{blockdiag}(\tilde{R}_1,\ldots, \tilde{R}_N) ) \\
\bm{x}_{t} &= G \bm{x}_{t-1}+ D_t\bm{\mu} + \bm{\omega}_t , \ \ \ \ \bm{\omega}_t\sim N(\bm{0},\Lambda)\nonumber,
\end{align}where $\bm{z}_{t}:=\left(\bm{z}_{t1},\bm{z}_{t2},\ldots,\bm{z}_{tN} \right) :=\left(z_{t1}(\tau_1),\ldots,z_{t1}(\tau_K),z_{t2}(\tau_1),\ldots,z_{tN}(\tau_K) \right)$ is an $NK$-dimensional vector,
$\bm{x}_{t}:=\left(\bm{x}_{t1},\bm{x}_{t2},\ldots,\bm{x}_{tM} \right) :=\left(x_{t1}(\tau_1),\ldots,x_{t1}(\tau_K),x_{t2}(\tau_1),\ldots,x_{tM}(\tau_K) \right)$ is an $MK$-dimensional vector, $\bm{\mu}:=\left(\bm{\mu}_{1},\bm{\mu}_{2},\ldots,\bm{\mu}_{M} \right) :=\left(\mu_{1}(\tau_1),\ldots,\mu_{M}(\tau_K) \right)$ is an $MK$-dimensional vector,
$D_t\in\{-1,0,1\}$ is a dummy variable,
$G$ is an $MK\times MK$ state evolution matrix,
$\bm{\nu}_t$ and $\bm{\omega}_t$ are the corresponding error terms,
$\Lambda:=\mathrm{diag}(\lambda^2_1\ldots,\lambda_M^2)$ is error variance in factor time series and $B$ is an $N\times M$-matrix denoted by
\begin{align*}
B &=\left(
\begin{array}{ccccc}
1 & 0& 0&\ldots &0\\
b_{21} & 1 & 0&\ldots &0\\
b_{31} & b_{32} & 1&\ldots &0\\
\vdots & \vdots & &\ddots &\vdots\\
b_{M1} & b_{M2} & b_{M3}&\ldots &1\\
b_{M+1,1} & b_{M+1,2} & b_{M+1,3}&\ldots &b_{M+1,M}\\
\vdots & \vdots & &\ddots &\vdots\\
b_{N,1} & b_{N,2} & b_{N,3}&\ldots &b_{N,M}\\
\end{array}
\right).
\end{align*}
Note that the number of factors $M$ is less than $N$.
This formulation is a factor model \citep{Aguilar1999a, elkhouly2021dynamic, gamerman2008spatial}.
At each $t$, many vectors $\{\bm{z}_{ts}\}_{s=1}^N$ are represented by a small number of vectors $\{\bm{x}_{ts}\}_{s=1}^M$, which makes the formulation compatible with large-scale data, because only a small number of evolutions must be considered. At each $t$, a large number of vectors $\{\bm{z}_{ts}\}_{s=1}^N$ are represented by a small number of vectors $\{\bm{x}_{ts}\}_{s=1}^M$.
This makes it compatible with large-scale data because only a small number of evolutions need to be considered.
Furthermore, defining the factor loading matrix in this way guarantees identifiability and interpretability.
Analysis might be easier if all components were parameters, but there could be multiple expressions describing the relationship between explanatory factors and explained variables, which would render the parameters inexplicable.
In this case, for example, the first factor $\bm{x}_{t1}$ is equal to the first mean parameter $\bm{z}_{t1}$ minus noise; the second factor $\bm{x}_{t2}$ is equal to the second mean parameter $\bm{z}_{t2}$ minus $b_{21}\times \bm{x}_{t1}$ minus noise, and so on.
That is, the $s$th factor represents the part of the $s$th trend that is not explained by the first $s-1$th factors. Hence, we formulated this method to clarify the role of each parameter.
Note that the time series equation contains the $D_t\bm{\mu}$ term.
$D_t$ depends on a combination of $t$ and $t-1$.
$D_t$ is $1$ when $(t,t-1)$ is (holiday, weekday), $-1$ for (weekday, holiday), and $0$ otherwise.
$\mu_s$ represents the difference in holidays compared with weekdays at each location. This allows for the modeling of day-off effects. This term can be designed more flexibly based on empirical knowledge. For example, the day before a holiday, such as Friday, tends to have a different population trend from that on a typical weekday; hence, a term can be added to reflect this:
\begin{align}\label{eq:add}
\bm{z}_t &= (B\otimes I_K)\bm{x}_t+\bm{\nu}_t,\ \ \ \ \ \ \bm{\nu}_t\sim N(\bm{0},\mathrm{blockdiag}(\tilde{R}_1,\ldots, \tilde{R}_N) ), \\
\bm{x}_{t} &= G \bm{x}_{t-1}+ D_t\bm{\mu} + D_t' \bm{\mu}'+ \bm{\omega}_t , \ \ \ \ \bm{\omega}_t\sim N(\bm{0},\Lambda)\nonumber,
\end{align}where $D_t'$ and $\bm{\mu}'$ are analogous of $D_t'$ and $\bm{\mu}'$.
The benefits of such flexibility are discussed in Section 5.
\subsection{Factor loading matrix}
To reflect the spatial structure, we consider the column vector $\bm{b}_{\cdot s}:= (b_{s+1,s},\ldots,b_{N,s})$ of $B$ and set the following prior:
\begin{align}\label{def:col}
\bm{b}_{\cdot s}|\upsilon\theta_s \sim \mathcal{N}(\bm{0},\upsilon\theta_s^2 Q_s^{-1}(\psi)),\ \ \ \ \ \ s=1,\ldots,M
\end{align}where $\upsilon$ and $\theta_s$ are scale parameters, $Q_s(\psi)= (I-\psi W_s)(I-\psi W_s)^{\top}$, $\psi$ is a spatial autoregression parameter and $W_s$ is the adjacency matrix for $s+1$ to $N$th points, whose $(i,j)$-entry is one if district $i$ and district $j$ are adjacent and zero otherwise.
The covariance matrix of $\bm{b}_{\cdot s}$ (the effect of the $s$th factor) depends on $Q_s$.
In other words, adjacent districts tend to be similarly affected.
Additionally, designing $Q_s$ as a sparse matrix makes computation less expensive because fast inverse matrix computation techniques as well as fast random sampling from a multivariate normal distribution are developed (e.g., ``sparseMVN" package in R language).
We suggest adopting the following prior distribution as the scale parameters: \begin{align*}
\upsilon \sim C^+(0,1), \ \ \ \ \theta_s\sim C^+(0,1), \ \ \ s=1,...,M,
\end{align*}
where $C^+$ denotes the half-Caushy prior.
Such prior is used in the horseshoe prior \citep{carvalho2009handling,carvalho2010horseshoe} for a univariate parameter, and the resulting distribution of $\bm{b}_{\cdot s}$ is a multivariate version of the horseshoe prior.
A similar multivariate prior is adopted in \cite{shin2020functional} and \cite{wakayama2022functional} in non-spatial settings.
The horseshoe distribution is known for strong shrinking ability, which allows the coefficients of singular factors to be zero.
In addition, unlike the Laplace distribution, it has a property called tail robustness, which firmly leaves the non-shrinking parts large.
This clarify whether the factor is effective, and also allows for highlighting important venues or specific facilities.
\subsection{Posterior computation}\label{sec:pos}
For the variance parameters, $e_s^2\sim IG(\frac{n_{e}}{2},\frac{n_{e}s_{e}}{2})$, $\lambda^2_s\sim IG(\frac{n_{\lambda}}{2},\frac{n_{\lambda}s_{\lambda}}{2})$, $\eta^2\sim IG(\frac{n_{\eta}}{2},\frac{n_{\eta}s_{\eta}}{2})$ are employed as an analytically tractable conjugate priors.
As for correlation kerner parameter, we set $\phi\sim IG(2,\beta)$, where $\beta = \frac{K-1}{-2\log 0.05}$ as \cite{gamerman2008spatial} did.
Concerning the day-off effect, we assume $\mu_s \sim N(0,\eta_s'R(\phi_s')).$
To ensure evolution is a stationary process, we assume $\gamma_s\sim N_{tr(-1,1)}(m_{\gamma},\sigma^2_{\gamma})$, where $G= \mathop{\rm diag}\nolimits(\gamma_1,\ldots,\gamma_M)\otimes I_K$.
We set $\psi\sim Be(1,1)$ after row normalization of each $W_s$.
The data augmentation technique developed by \cite{makalic2015simple} allows the horseshoe distribution introduced in $\bm{b}_{\cdot s}$to be re-expressed as a simple hierarchical prior. This representation also ensures that the prior conjugates and simplifies the computation of the posterior distribution.
The joint posterior density of all parameters is given by\begin{align*}
&\prod_{t,s,k} \pi \left(y_{ts}(\tau_k) \mid z_{ts}(\tau_k),e^2_s\right)
\prod_{t}\pi\left( \bm{z}_{t} \mid B,\bm{x}_t,\bm{\eta},\bm{\phi}\right)
\pi (\bm{x}_t\mid G,\bm{\mu},\bm{x}_{t-1},\Lambda) \\
&\times \pi (B\mid \bm{\theta},\psi)
\pi (G,\bm{e}, \bm{\theta}, \psi,\bm{\eta},\bm{\phi},\bm{\mu},\Lambda).
\end{align*}
The full conditional distributions of all parameters, except for the Gaussian process parameters, were obtained explicitly; therefore, we implemented the Metropolis algorithm within the Gibbs sampler. The concrete posterior distribution is described below.
First, the expression for $B$ introduced in (\ref{def:col}) is complicated; therefore, we reorganize it with respect to $\bm{b}_{\cdot s}$.
Define $\tilde{\bm{z}}_t^{(s)}:=(\tilde{\bm{z}}_{t,s+1}^{(s)\top},\ldots,\tilde{\bm{z}}_{tN}^{(s)\top} )^{\top}$ where $\tilde{\bm{z}}_{tj}^{(s)}:= \bm{z}_{tj} - \sum_{i\neq s}b_{ji}\bm{x}_{ti}$ for each $s\in \{1,...,M\}$
\begin{align*}
X_{ts} := \left(
\begin{array}{c}
\bm{\iota}_1\otimes \bm{x}_{ts} \\
\bm{\iota}_2\otimes \bm{x}_{ts} \\
\vdots \\
\bm{\iota}_{N-s}\otimes \bm{x}_{ts}
\end{array}
\right),\ \ \ \mathrm{and}\ \ \ \bm{\iota}_j:= \underset{\ \hat{j}}{(0,\ldots,0,1,0\ldots,0)}\in \mathbb{R}^{N-s}.
\end{align*}
Then, we obtain $\tilde{\bm{z}}_t^{(s)} = X_{ts}\bm{b}_{\cdot s}+\bm{\nu}_t$
Once the standard form of the regression using $\bm{b}_{\cdot s}$ is obtained, the remainder of the calculation is simple. Here, we present the full conditional distribution.
\begin{itemize}
\item[-] (Sampling from $\bm{z}_t$) \ \ The full conditional distribution of $\bm{z}_t$ is $N(\bm{m}_{z_t}, \Sigma_{z_t})$, where
\begin{align*}
\bm{m}_{z_t} & = \Sigma_{z_t}\left(E^{-1}\bm{y}_{t}+ \mathrm{blockdiag} (\tilde{R}_1^{-1},...,\tilde{R}_N^{-1} )(B\otimes I_K) \bm{x}_t \right), \ \ \ \\
\Sigma_{z_t} & = \left( E^{-1} + \mathrm{blockdiag} (\tilde{R}_1^{-1},...,\tilde{R}_N^{-1} ) \right)^{-1}, \ \ \ \\
E & = \mathop{\rm diag}\nolimits(e_s^2)\otimes I_K.
\end{align*}
\item[-] (Sampling from $\bm{x}_t$) \ \ The full conditional distribution of $\bm{x}_t$ is $N(\bm{m}_{x_t}, \Sigma_{x_t})$, where
\begin{align*}
\Sigma_{x_t} & = \left( (B\otimes I_K)^{\top}\mathrm{blockdiag} (\tilde{R}_1^{-1},...,\tilde{R}_N^{-1} )(B\otimes I_K)+\Lambda^{-1} + G^{\top} \Lambda^{-1} G \right)^{-1}, \\
\bm{m}_{x_t}& = \Sigma_{x_t}\Big((B\otimes I_K)^{\top}\mathrm{blockdiag} (\tilde{R}_1^{-1},...,\tilde{R}_N^{-1} )\bm{z}_t+ \Lambda^{-1}G\bm{x}_{t-1}\\
&\ \ \ \ \ \ \ \ \ \ \ \ \ + G \Lambda^{-1} \bm{x}_{t+1} +D_t\Lambda^{-1}\bm{\mu} - D_{t+1} G^{\top}\Lambda^{-1}\bm{\mu} \Big).
\end{align*}
\item[-] (Sampling from $G$) \ \ The full conditional distribution of $\gamma_s$ is $N_{tr(-1,1)}(\tilde{m}_{\gamma},\tilde{\sigma}^2_{\gamma})$, where
\begin{align*}
\tilde{m}_{\gamma} & = \tilde{\sigma}^2_{\gamma} \left(\sum_{t=2}^T \frac{ ( \bm{x}_{ts}- D_t\bm{\mu}_s )^{\top}\bm{x}_{t-1,s}}{\lambda^2_s} + \frac{m_{\gamma}}{\sigma^2_{\gamma}}\right), \\
\tilde{\sigma}^2_{\gamma} & = \left(\sum_{t=2}^T \frac{\bm{x}_{t-1,s}^{\top}\bm{x}_{t-1,s}}{\lambda^2_s} + \frac{1}{\sigma^2_{\gamma}} \right)^{-1} .
\end{align*}
\item[-] (Sampling from $e_s^2$) \ \ The full conditional distribution of $e^2_s$ is\begin{align*}
IG\left(\frac{n_e+TK}{2},\frac{n_{e}s_{e}+\sum_{t=1}^T\| \bm{y}_{ts}-\bm{z}_{ts}\|_2^2 }{2}\right).
\end{align*}
\item[-] (Sampling from $\lambda^2_s$) \ \ The full conditional distribution of ${\lambda}^2_s$ is\begin{align*}
IG\left(\frac{n_{\lambda}+(T-1)K}{2},\frac{n_{\lambda}s_{\lambda}+\sum_{t=2}^T\|\bm{x}_{ts}-\gamma_s\bm{x}_{t-1,s}- D_t\bm{\mu}_s\|_2^2 }{2}\right).
\end{align*}
\item[-] (Sampling from $\eta_s^2$) \ \ The full conditional distribution of $\eta_s^2$ is\begin{align*}
IG\left(\frac{n_{\eta}+TK}{2},\frac{n_{\eta}s_{\eta}+\eta_s^2\sum_{t=1}^T(\bm{z}_{ts}-(\bm{b}_{s\cdot}\otimes I_K ) \bm{x}_t)^{\top}\tilde{R}^{-1}_{\phi_s}(\bm{z}_{ts}-(\bm{b}_{s\cdot}\otimes I_K ) \bm{x}_t) }{2}\right).
\end{align*}
\item[-] (Sampling from $\phi_s$) \ \ The full conditional distribution of $\phi_s$ is not written in analytic form. Hence we sample $\phi_s$ using the random-walk Metropolis-Hastings method with acceptance rate \begin{align*}
\min \left[1, \frac{ \tilde{\phi}_s^{-3}\exp\left(-\frac{\beta}{\tilde{\phi}_s}\right)\prod_{s}\det(\tilde{R}_{\tilde{\phi}_s})^{-\frac12}\exp \left\{ -\frac12 \left(\bm{z}_{ts} - (\bm{b}_{s\cdot}\otimes I_K )\bm{x}_t\right)^{\top} \tilde{R}_{\tilde{\phi}_s}^{-1}\left(\bm{z}_{ts} - (\bm{b}_{s\cdot}\otimes I_K )\bm{x}_t\right) \right\}}{\phi_s^{-3}\exp\left(-\frac{\beta}{\phi_s}\right)\prod_{s}\det(\tilde{R}_{\phi_s})^{-\frac12}\exp \left\{ -\frac12 \left(\bm{z}_{ts} - (\bm{b}_{s\cdot}\otimes I_K )\bm{x}_t\right)^{\top} \tilde{R}_{\phi_s}^{-1}\left(\bm{z}_{ts} - (\bm{b}_{s\cdot}\otimes I_K )\bm{x}_t\right) \right\}}\right].
\end{align*}
\item[-] (Sampling from $\bm{\mu}_s$) \ \ The full conditional distribution of $\bm{\mu}_s$ is $N(\bm{m}_{\mu_s},\Sigma_{\mu_s})$, where
\begin{align*}
\bm{m}_{\mu_s} & = \Sigma_{\mu_s} \lambda_s^{-2} \sum_{t=2}^TD_t(\bm{x}_{t}- G\bm{x}_{t-1} ) ,\\
\Sigma_{\mu_s} & = \left( \sum_{t=2}^TD_t^2 \lambda_s^{-1}\right)^{-1}.
\end{align*}
\item[-] (Sampling from $B$)
The full conditional distribution of $\bm{b}_{\cdot s}$ is $N(\bm{m}_b, \Sigma_b),$ where \begin{align*}
\bm{m}_b &= \Sigma_b\sum_{t=1}^T X_{ts}^{\top} \mathrm{blockdiag}(\tilde{R}_1^{-1},...,\tilde{R}_N^{-1}) \tilde{\bm{z}_t}^{(s)}\\
\Sigma_b &= \left(\upsilon^2\bm{\theta}_s^{-2}Q_s + \sum_{t=1}^T X_{ts}^{\top} \mathrm{blockdiag}(\tilde{R}_1^{-1},...,\tilde{R}_N^{-1}) X_{ts} \right)^{-1}.
\end{align*}
\item[-] (Sampling from $\theta_s^2$) \ \ The full conditional distribution of ${\theta}_s^2$ is\begin{align*}
IG\left(\frac{N-s+1}{2},\frac{\bm{b}_{\cdot s}^{\top}Q_s(\psi)\bm{b}_{\cdot s} }{2\upsilon^2}+\frac{1}{\zeta_s}\right).
\end{align*}
\item[-] (Sampling from $\zeta_s$) \ \ The full conditional distribution of ${\zeta}_s$ is\begin{align*}
IG\left(1,\frac{1}{\theta_s^2}+1\right).
\end{align*}
\item[-] (Sampling from $\upsilon^2$) \ \ The full conditional distribution of $\upsilon^2$ is\begin{align*}
IG\left(\frac{1+\sum_{s=1}^M N-s}{2},\sum_{s=1}^M\frac{\bm{b}_{\cdot s}^{\top}Q_s(\psi)\bm{b}_{\cdot s} }{2\theta_s^2}+\frac{1}{\nu}\right).
\end{align*}
\item[-] (Sampling from $\nu$) \ \ The full conditional distribution of $\nu$ is\begin{align*}
IG\left(1,\frac{1}{\upsilon^2}+1\right).
\end{align*}
\item[-] (Sampling from $\psi$) \ \ The full conditional distribution of $\psi$ is not analytically available. Hence we implement random-walk Metropolis-Hastings with acceptance rate \begin{align*}
\min \left[1, \frac{\tilde{\psi}^{17}(1-\tilde{\psi})\prod_{s=1}^M\det\left(Q_s^{-1}(\tilde{\psi})\right)^{-\frac12}\exp\left( -\frac{\bm{b}_{\cdot s}^{\top}Q_s(\tilde{\psi})\bm{b}_{\cdot s}}{2\upsilon^2\theta_s^2}\right)}{\psi^{17}(1-\psi)\prod_{s=1}^M\det\left(Q_s^{-1}(\psi)\right)^{-\frac12}\exp\left( -\frac{\bm{b}_{\cdot s}^{\top}Q_s(\psi)\bm{b}_{\cdot s}}{2\upsilon^2\theta_s^2}\right)} \right].
\end{align*}
\end{itemize}
\subsection{Selecting factors}\label{subsec:select}
The critical concern in this section is how to determine the factors. Even in univariate problems, determining the factors and number of factors is difficult, and the typical method is to align those that appear important based on domain knowledge \citep{prado2021time}.
However, this method requires a subjective selection of factors, and it is unclear whether the selected factors are crucial.
We offer the following solution to this problem:
\begin{itemize}
\item[1.] Prepare some factor sets as candidates.
\item[2.] Assign shrinkage priors to $\upsilon$ and $\theta_s$ and implement the proposed method (for smaller scale data) for all candidates.
\item[3.] Calculate the posterior predictive losses (PPL) and choose the best factor set from the candidates.
\begin{align*}
{\rm PPL} = \sum_{s=1}^N \Biggl[\sum_{t=1}^T \left\{ \bm{y}_{ts}-{\rm E}_p[\bm{z}_{ts}]\right\}^\top
\left\{ \bm{y}_{ts}-{\rm E}_p[\bm{z}_{ts}]\right\}+TK{\rm E}_p[\sigma_s^2] + \sum_{t=1}^T\mathrm{tr} \left({\rm Cov}_p(\bm{z}_{ts})\right) \Biggr]
\end{align*}
\item[4.] In the chosen set, if the coefficient of the $s$th factor $\bm{b}_{\cdot s}$ is unshrunk, we consider the $s$th factor necessary but delete it otherwise.
\end{itemize}
Because $\bm{b}_{\cdot s}$ is the coefficient corresponding to the $s$th factor, the $s$th factor does not affect the others (i.e., it is insignificant) if it is reduced to zero by the shrinkage distribution.
Thus, we assign more factors to the model beforehand and retain the essential factors and eliminate unnecessary factors using the effect of the shrinkage distribution.
Although this procedure allows for factor selection, implementing it on a large-scale dataset is time consuming. This negates one advantage of the factor model which is that it reduces the computational burden.
Therefore, we recommend implementing factor selection for smaller-scale data and then implementing the proposed model with the selected factors for the entire dataset.
\section{Numerical Experiment}\label{sec:sim}
To confirm the usefulness of the proposed method, we investigated the properties of the proposed method and compared its accuracy with that of existing methods.
\subsection{Experimental Setting}
First, we consider the structure of the city. We assume $N$ districts, $C_1 - C_{N}$, where districts $C_1$ and $C_2$ are dominant, influencing the other districts, as shown in Figure \ref{fig:diag}. Assume that $C_3$ and $C_4$ are the next most influential districts and that they have the trends of $C_1$ and $C_2$ but also their own trends, which spread to adjacent districts $C_6 - C_{N}$. Note that it is unrealistic for a single district, either $C_3$ or $C_4$, to be adjacent to $N-4 (>>10)$ districts, but we ignore this for the numerical experiment.
The data-generating process is defined as follows.
\begin{align*}
&\mathrm{-\ \ measurement \ error}\\
&\ \ \ \ \ \ y_{ts}(\tau)\sim N(z_{ts}(\tau),e_s^2)\\
&\mathrm{-\ \ state\ variables \ from \ factors}\\
&\ \ \ \ \ \ z_{1,s}(\tau) = x_{1,s}(\tau) + \mathcal{G}\mathcal{P}(0,R(1)/4 ),\ \ \ s=1,2,5 \\
&\ \ \ \ \ \ z_{1,3} = 2/3 x_{1,1}+ x_{1,3}+ \mathcal{G}\mathcal{P}(0,R(1)/4), \\
&\ \ \ \ \ \ z_{1,4} = 2/3 x_{1,2}+ x_{1,4}+ \mathcal{G}\mathcal{P}(0,R(1)/4), \\
&\ \ \ \ \ \ z_{1,s} = w_{1s} z_{1,3}+ w_{2s} z_{1,4}+ \mathcal{G}\mathcal{P}(0,R(1)/4), \ \ \ s=6,...,N,\\
&\mathrm{-\ \ time \ series \ of \ factors}\\
&\ \ \ \ \ \ x_{ts}(\tau) = 0.8 x_{t-1,s}(\tau) + N(\bm{0},I_K) , \ \ \ s=1,...,5,\\
&\ \ \ \ \ \ x_{1,1},..., x_{1,5}\overset{\mathrm{i.i.d.}}{\sim} \mathcal{G}\mathcal{P}(0,25R(4)),
\end{align*}where $R(\phi)$ is the radial basis function kernel defined as $R(\phi) = \exp(-\|\tau_i-\tau_j\|^2/\phi)$ and $e_s$ is the measurement error deviation. $z_{1,s}\ (s=6,...,N)$ is mixture of $z_{1,3}$ and $z_{1,4}$, and their weights -- $\bm{w}_1=\{w_{1s}\}_{s=6}^N$ and $\bm{w}_2=\{w_{2s}\}_{s=6}^N$ -- are independently sampled from an $(N-5)$-variate Gaussian distribution with mean zero and a band-type covariance matrix, in which the diagonal is $1$, the $(i,i+1)$th and $(i,i-1)$th entries are $1/2$, and the others entries are $0$. The day-off effect is fixed at zero and is not discussed here, as it is the focus of the following section.
\begin{figure}[tb]
\centering
\begin{tikzcd}
C_1 \ar[r, "1/2"]
& C_3 \ar[dr, ""]
&
&[1.5em] \\
&
&\ \ \ \ \ \ C_6,\ldots,C_{N} \\
C_2 \ar[r, "1/2"]
& C_4 \ar[ur, ""] & & C_5\\
\end{tikzcd}
\caption{Diagram showing the influence of each district on the other districts.\label{fig:diag}}
\end{figure}
All data were measured at $K(=24)$ points on the function over a period of $T$ days. The first $M(=5)$ districts were also considered factors.
To perform the experiment on different space-time scales, we prepared $(20,50)$ and $(50,90)$ as combinations of $(N,T)$.
We set the noise such that the signal-to-noise ratio (SNR) was the same for all points. In other words, the noise variance was heterogeneous. Specifically, we set $e_s$ to $1/5$ (high SNR) and $1/2$ (low SNR) as the standard deviation of the signal in each district.
We conduct the following three methods\begin{itemize}
\item[-] FFM: our proposed functional factor model.
\item[-] NSFFM: non-sparse version of the functional factor model. The prior distribution of $B$ is constructed as
\begin{align}
\bm{b}_{\cdot s}|\theta \sim \mathcal{N}(\bm{0},\theta^2 Q_s^{-1}(\psi)),\ \ \ \ \ \
\theta\sim IG(0.1,0.1), \ \ \ \ \ \ s=1,\ldots,M. \nonumber
\end{align} This allowed us to investigate how the sparsity of factor loading matrix $B$ affects interpretability and estimation accuracy.
\item[-] BART: Bayesian additive regression trees developed by \cite{chipman2010bart}. The purpose of using BART is to study the accuracy of FFM estimation compared to nonparametric flexible methods; however, it is not a time-series method. BART can be applied by ignoring the spatial structure and considering a bivariate regression problem at each location (in this case, the explanatory variables were $t$ and $\tau$).
\end{itemize}
For all methods, we used $5000$ posterior draws after discarding $5000$ burn-in samples. The resulting sample medians were considered point estimates. To assess the point estimates and sampled posterior distribution, we adopted the following criteria:
\begin{itemize}
\item[-]
Root mean square error (RMSE): Difference between the posterior medians and the true values, defined as
$$
\mathrm{RMSE}=\sqrt{\frac{1}{NTK} \sum_{s=1}^{N}\sum_{t=1}^T\sum_{\tau=1}^{K} \bigl(\hat{z}_{ts}(\tau)-z_{ts}(\tau)\bigl)^2}.
$$
\item[-]
Coverage probability (CP): Coverage accuracy of the credible interval, defined as
$$
\mathrm{CP}=\frac{1}{NTK} \sum_{s=1}^{N}\sum_{t=1}^T\sum_{\tau=1}^{K} \mathbb{I}_{\{ \hat{z}_{ts}^{97.5}(\tau)>z_{ts}(\tau) >\hat{z}_{ts}^{2.5}(\tau) \}}.
$$
\end{itemize}
\subsection{result}
Table \ref{tab:full} lists the RMSEs and CPs for each scenario. The FFM and NSFFM performed better than BART.
This is because BART is a nonparametric method that does not consider spatial or time-series structures, whereas FFM is a spatiotemporal method. Hence, the RMSE is lower and CP is higher for FFM than for BART.
In addition, under all scenarios, FFM performed slightly better than NSFFM because the spatial structure was captured more accurately by completely eliminating unnecessary factors.
\begin{table}[tb]
\caption{
Averaged values of RMSE (root mean square error) and CP (coverage probability of 95$\%$ credible interval) for functional factor model (FFM), non-sparse functional factor model (FSFFM), and Bayesian additive regression trees (BART).
\label{tab:full}
}
\centering
\medskip
\begin{tabular}{cccccccccccc}
\toprule
SNR & $(N,T)$ &Method & & RMSE & CP(\%) \\
\midrule
low & (20,50) &{\bf FFM} & & 0.459 & 96.6 \\
& &NSFFM & & 0.465 & 96.8 \\
& &BART & & 1.647 & 66.6 \\
& (50,90) &{\bf FFM} & & 0.321 & 97.8 \\
& &NSFFM & & 0.352 & 98.5 \\
& &BART & & 1.346 & 58.6 \\
\midrule
high & (20,50) &{\bf FFM} & & 0.192 & 95.5\\
& &NSFFM & & 0.197 & 97.3 \\
& &BART & & 1.341 & 63.3 \\
& (50,90) &{\bf FFM} & & 0.135 & 97.8 \\
& &NSFFM & & 0.149 & 98.8 \\
& &BART & & 1.194 & 55.5 \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}[p]
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[keepaspectratio, height=12cm]{FFM.png}
\subcaption{FFM}
\end{minipage}
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[keepaspectratio, height=12cm]{NSFFM.png}
\subcaption{NSFFM}
\end{minipage}
\caption{Estimated factor loading matrices by functional factor model (left) and non-sparse functional factor model (right) when signal-to-noise ratio is low.\label{fig:B}}
\end{figure}
\begin{figure}[]
\centering
\begin{center}
\includegraphics[width=0.9\textwidth]{gamma_est.pdf}
\end{center}
\caption{Posterior distribution of the autoregressive parameters.\label{fig:gamma}}
\end{figure}
Next, we discuss the impacts of these factors on each district. Figure \ref{fig:B} shows the estimated factor loading matrices, which represent the influence of five factors on twenty districts. The left plot is estimated using the FFM and the right plot is estimated using the NSFFM. The major difference between the two plots is the coefficient of the fifth factor, that is, the fifth column of matrix $B$.
The NSFFM results suggest that the fifth factor has a small impact on districts 12 and 13. This is inconsistent with the original data-generating process and is misleading; because NSFFM lacks the ability to sparsify irrelevant factors, it must place some weight on these factors.
By contrast, FFM removes the weights of unnecessary factors. This allowed us to clarify the connection between factors and districts.
We also considered the time-series structure. Figure \ref{fig:gamma} shows the posterior distributions of the autoregressive parameters when $(N,T)$ is $(20,50)$ and SNR is low; the results are similar for the other scenarios. All results were distributed around the true values; therefore, the time-series structure was well modeled.
In particular, $\gamma_3$ and $\gamma_4$ are close to $0.8$ although they are considered challenging to estimate accurately because, unlike other factors, the 3rd and 4th factors are observed as a mixture of other factors.
\section{Analysis of Population Data in Tokyo}\label{sec:DA}
This section describes the implementation of the proposed method using real data.
Because our main aim was accurate prediction, the factors needed to be selected beforehand, the process of which is described in Section \ref{subsec:fac}. Then, before the forecast, Section \ref{subsec:off} discusses the day-off effect, which is important to understand the city.
Then, the forecasting performance and possible improvements are investigated in Section \ref{subsec:pred}.
Because the data were observed hourly and daily for one year, $K=24$ and $T=365$. Saturdays, Sundays, and national holidays in 2019 were defined as days off.
Because different scales at each location would make it challenging to interpret the factor loading matrix, the scale data were normalized as follows: \begin{align*}
\frac{y_{ts}(\tau)}{\sqrt{\sum_{t,\tau}y_{ts}^2(\tau)/K/T}}.
\end{align*}
\subsection{Factor selection}\label{subsec:fac}
The dataset for factor selection comprised population data for the first $100$ days and $50$ randomly selected locations.
\begin{itemize}
\item[1.] First, we prepared four factor sets consisting of seven elements.
One set was chosen subjectively and three were chosen randomly.
\item[2.] For each factor set, we implemented the proposed methods with $\upsilon \sim C^+(0,1), \ \theta_s\sim C^+(0,1)$, and $s=1,...,M.$
\item[3.] After calculating the PPL, we chose the factor set such that the PPL was minimized. This set is listed in Table \ref{description} and illustrated in Figure \ref{fig:facmap}.
\end{itemize}
\begin{table}[b]
\caption{Description of the factor districts and the explained districts.\label{description}}
\label{table:}
\centering
\begin{tabular}{cclll}
\toprule
&Number & District & Description \\
\midrule
&1 & Nihonbashi & Business district \\
&2 & Shibuya & Downtown \\
&3 & Sasazuka & Residential area \\
&4 & Ueno Station & Hub station \\
&5 & Shinjuku & Downtown \\
&6 & Hakusan & Residential area \\
&7 & Port of Tokyo & Seaport \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}[t]
\centering
\includegraphics[width=0.6\textwidth]{factor_map.pdf}
\hspace{-1cm}
\caption{Locations of factor districts.\label{fig:facmap}}
\end{figure}
\begin{figure}[p]
\centering
\includegraphics[height=0.95\textheight]{SelectFactor2.pdf}
\hspace{-1cm}
\caption{Estimated factor loading matrix.\label{fig:sele}}
\end{figure}
Figure \ref{fig:sele} shows the estimated factor loading matrix for the selected set. Several important things can be inferred from this. One is the relationship between the factors and other districts. For example, the $8-11$th and $18-20$th districts are categorized as being residential areas. In Table \ref{description}, the third factor (district) is in a residential area as well. Hence, it is natural for those districts to be well explained by the third factor. Additionally, the $12-15$th districts were office areas, similar to the first district, and the factor loading matrix was consistent with this.
These relationships are intuitively plausible and allow for a more detailed understanding of the urban structure.
Another noteworthy point is shrinkage. Although we selected the best factor set from the candidates in the above procedure, we could also choose factors within the set. Table \ref{description} shows that the coefficients of the sixth and seventh factors are negligible.
The seventh factor was based on population data from a wharf in Tokyo, but in this case, there were no districts that could be explained by this factor. The sixth district was in a residential area which matched the third district. Hence, the trends specific to residential areas were captured by the third factor, and there was little that could be additionally explained by the sixth factor.
\begin{figure}[t]
\begin{center}
\includegraphics[width=\textwidth]{flow_est2.pdf}
\end{center}
\caption{Day-off effects $\bm{\mu}_s$ of all factors.\label{fig:off}}
\end{figure}
\subsection{day-off effect}\label{subsec:off}
Next, we focused on the day-off effect.
Figure \ref{fig:off} illustrates the estimated day-off effect $\bm{\mu}_s$ of each factor.
These results provided interesting insights.
The first is the day-off effect in the office districts. As represented by the first factor (the business district), there were fewer people on holidays because they did not come to work.
In downtown and residential areas, the holiday population tended to increase.
This is because many people went downtown to enjoy the holidays but did not leave their homes in residential areas to commute to school or work, as they did on weekdays.
Another interesting feature was the day-off effect of the fourth factor. This region was a hub station and many people used it to commute to work or school. Hence, Ueno Station was particularly populated during rush hour (9:00 and 19:00) on weekdays.
However, this did not occur on holidays, so the population decreased at those times.
\subsection{Prediction}\label{subsec:pred}
Finally, we predicted future data for $400$ districts.
We implemented three experiments. In the first (second, third) one, we used the first $152$ ($212$, $272$) days as training data and the following $30$ days as test data to evaluate the performance. Note that the results reported below are the average of these three experiments.
Based on the discussion in Section \ref{subsec:fac}, we employed five districts in the best set as factors.
To optimize performance, we considered the following two extensions to the original method:
\begin{itemize}
\item[I.] Add pre-day-off effects to the factor evolution equation (\ref{eq:add}).
\item[II.] Add pre-day-off effects and pre-working effects to the factor evolution equation. The latter effect was added because on weekdays before a day off there were likely to be different trends and vice versa.
\end{itemize}
To evaluate the prediction error, we define the scale-adjusted RMSE (SRMSE) as follows:
\begin{align*}
\frac{ \sqrt{T^{-1}\sum_t\|\hat{\bm{y}}_{ts} - \bm{y}_{ts}\|_2^2} }{ \sqrt{T^{-1}\sum_t\|\bm{y}_{ts}\|_2^2} }.
\end{align*}
We applied the proposed methods to train the data and obtained $5000$ posterior samples after $15000$ burn-in periods. For these samples, we obtained forecasts using the Monte Carlo approximation and reported the SRMSE values.
\begin{table}[tb]
\caption{
Scale-adjusted root mean square error (SRMSE) of three methods for each factor, average SRMSE for non-factors, and average SRMSE for all districts on weekdays, holidays, and the entire period.\label{tab:RMSE}
}
\centering
\medskip
\begin{tabular}{cccccccccccc}
\toprule
&Factor & Original FFM & Extension I & Extension II \\
\midrule
&1 & 0.050 & 0.053 & 0.045 \\
&2 & 0.258 & 0.161 & 0.134\\
All days&3 & 0.041 & 0.037 & 0.028 \\
&4 & 0.112 & 0.097 & 0.087\\
&5 & 0.306 & 0.206 & 0.190\\
&Average& 0.088 & 0.066 & 0.062\\
\midrule
&1 & 0.039 & 0.041 & 0.041\\
&2 & 0.200 & 0.089 & 0.096\\
Working days&3 & 0.038 & 0.050 & 0.027 \\
&4 & 0.110 & 0.089 & 0.070\\
&5 & 0.200 & 0.144 & 0.127\\
&Average& 0.079 & 0.058 & 0.058 \\
\midrule
&1 & 0.202 & 0.045 & 0.041 \\
&2 & 0.352 & 0.145 & 0.075\\
Days off&3 & 0.044 & 0.044 & 0.033\\
&4 & 0.120 & 0.093 & 0.091\\
&5 & 0.435 & 0.198 & 0.128 \\
&Average& 0.134 & 0.062 &0.056 \\
\bottomrule
\end{tabular}
\end{table}
Table \ref{tab:RMSE} shows the SRMSE of the three methods for the five factors, the average RMSEs for the non-factors, and the average RMSEs for all districts. We further divided the results into errors on weekdays and holidays and overall errors. Generally, the prediction accuracy was good, not only for the factor districts, but also for the other districts, which were represented by the aggregation of factors. This means that the factor model is successfully capturing the relationships among the districts.
Then, we examined the difference between the original and extended methods. Overall, both extensions performed better than the original. By adding the pre-holiday effect, we identified the change in the shift from weekdays to holidays. This increased the precision of the estimates for both weekday and holiday trends. Focusing on changes by region, we found large declines, particularly in Districts 2 and 5, because the extensions were able to reflect the trend that people were more likely to congregate in downtown areas on Friday nights.
Next, we focused on how Extension I differs from Extension II. In terms of days off, Extension II outperformed by a wide margin. The tendency to stay at home instead of going out when the following day was a working day (even on holidays) was reflected in the larger changes in downtown (Districts 2 and 5) and residential areas (District 3). Figure \ref{fig:predmap} shows the population map at 5:00, 12:00 and 19:00 on the first Monday and Sunday after 152 days. This visualizes the result that the proposed method successfully captures the difference between holidays and weekdays.
\begin{figure}[t]
\begin{center}
\includegraphics[width=\textwidth]{Estimated_maps.pdf}
\end{center}
\caption{Predicted population map by Extension II at 05:00, 12:00 and 19:00 on Monday and Sunday.\label{fig:predmap}}
\end{figure}
\section{Conclusion}\label{sec:con}
In this study, we developed a method for modeling and predicting spatiotemporal functions. This method integrates the concepts of functional data analysis and Bayesian factor modeling, reduces overall computation by considering the time series structure of only a small number of factors, and reveals the spatial structure by identifying the relationships between the factors and the remaining parts.
This mitigates the large size of the data by inputting the problem into functional data analysis.
The motivating application was population flow data, that is, the number of people observed in each area on a daily basis, which was difficult to estimate or predict without increasing computational complexity and losing interpretability. However, Bayesian sparsity variable selection and dimension reduction specific to factor models allowed for the computation of large datasets. Simulation studies and empirical applications demonstrated that the proposed method accurately estimated trends and provided a detailed representation of spatial and time-series structures, including the day-off effect.
We discussed how the proposed model could be modified according to the domain knowledge, which improved predictions. The corresponding terms and factor loading matrix were easy to interpret and further information could be extracted.
Therefore, this can facilitate the use of population data by government agencies and businesses in various areas, such as disaster prevention planning, tourism analysis, and outdoor advertising.
Considering that as more people have devices, it will be possible to collect accurate data in finer meshes (that is, in more locations); future studies should seek to develop approximate Bayesian methods to reduce computational complexity.
\section*{Acknowledgments}
Research of the authors was supported in part by JSPS KAKENHI Grant Numbers 22J21090 and 21H00699 from Japan Society for the Promotion of Science.
\bibliographystyle{chicago}
| {'timestamp': '2023-02-10T02:05:16', 'yymm': '2302', 'arxiv_id': '2302.04412', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04412'} | arxiv |
\section{Introduction}
\label{introduction}
Machine learning has become ubiquitous in computer networks, with applications in areas such as traffic engineering \cite{zuo2019learning}, performance optimization \cite{ali2020performance}, network security \cite{akbar2012improving}, anomaly detection \cite{shon2007hybrid} and root cause analysis \cite{gonzalez2017root}. Reinforcement Learning (RL) in particular has gained substantial momentum in developing congestion control (CC) algorithms \cite{badarla2011learning,jay2019deep, jin2018congestion, lan2019deep,li2016learning,li2018qtcp,mai2019self,nie2019dynamic,ramana2005learning,silva2016smart,tarraf1995reinforcement, xiao2019tcp, xu2019experience, abbasloo2020classic}, routing \cite{mammeri2019reinforcement}, video rate control \cite{huang2018qarc, mao2017neural}, network access \cite{wang2018deep, naparstek2018deep}, network security \cite{nguyen2019deep, uprety2020reinforcement} and proactive caching \cite{zhu2018deep, he2017integrated}. Learning-based algorithms have the potential to adapt to a wide range of network deployments, topologies, traffic workloads and link technologies without requiring engineering (and tuning) of bespoke algorithms to cover said diversity. This, in turn, opens up opportunities for developing future-proof algorithms that can be trained offline, and continuously optimise their behaviour as networks and user workloads evolve.
Learning-based protocols are still in their infancy and substantial research is required to yield deployable solutions \cite{fuhrer2022implementing}. Developing an RL-based protocol is a complex process that requires (1) deciding on a particular RL algorithm, (2) devising a suitable and effective RL model, (3) training the agent(s) in a realistic network setup, and (4) deploying the agent in the wild. The first two of these involves a range of design decisions related to the action and state space of the RL agent, the reward function and the RL algorithm itself. Training the agent is far from trivial; a potentially large number of hyper-parameters (e.g., the discount rate \textit{gamma}, the size of replay/memory buffer, etc.) need to be explored to ensure that the resulting policy is the best possible given the selected RL algorithm and model, the training setup (e.g. in terms of the used network parameters, topology and workload) and the expected deployment parameters. At the same time, training an agent requires the collection of (very) large amounts of agent experience, which can happen either using a real network deployment (e.g., as in \cite{abbasloo2020classic}), a network emulator (e.g., as in \cite{sacco2021owl}) or network simulations (e.g., as in \cite{tessler2022reinforcement}).
We argue that network simulators, in particular discrete event, packet level simulators, provide a very effective platform for training RL-based network protocols and respective algorithms. First, simulators offer a \textit{fully controllable and configurable} experimentation environment. Network simulators employ domain-specific languages that make defining `networks', including the underlying topology, link characteristics, and traffic workloads, to be simulated easy. Moreover, simulations can run independently and in parallel to each other. It would be extremely expensive and time-consuming to enable such configurability on a real network. Network emulations such as the ones used in \cite{netravali2015mahimahi} support only some limited configurability. Second, training an agent for a network protocol (e.g., a CC policy for a TCP sender) requires exchanging traffic between multiple endpoints. In a real or emulated network, said traffic must be actually played out in the network which, depending on the training setup and parameters, may add a substantial overhead in the training process, in terms of the time it takes to collect agent experience (e.g., in a scenario where the network capacity is very small or when the agent is still far from optimised)\footnote{In \cite{abbasloo2020classic}, models are trained on a pool of servers with a total of 320 CPU cores and edge-switches connected through high-speed links, with training and experimentation constrained by the real-time cost of transmitting data in a real network, in addition to the cost of setting up the system. }. To make things worse, training congestion control policies in high-speed network deployments can be very problematic (or, in fact, impossible) due to the agent needing actions much faster than what the trainer can calculate\footnote{For example, in \cite{abbasloo2020classic} they fix the agent's action calculation/monitoring interval to 20ms, indicating that much lower values would not be possible.}. On the contrary, network traffic generated by inefficient policies can be played very quickly within a simulated network, while the simulated nature of the deployment eliminates the issue around high-performance network deployments.
Third, network simulators support \textit{reproducibility of results} by design, which is crucial for learning based approaches; it is surprising that many papers in RL-based CC (and other fields of computer networks) are being published without any provision for (or even discussion around) reproducibility\footnote{A shining exception is Remy, one of the earliest learning-based CC algorithms\cite{winstein2013tcp, sivaraman2014experimental}.}, when other communities have had reproducibility protocols embedded in their peer review processes. Reproducibility with real or emulated networks is not really possible. Finally, we posit that the development of a \textit{training playground} for computer network researchers would be beneficial for the research community; we envisage a framework such as \cite{brockman2016openai} where researchers can formulate problems and train agents to operate within the given problem space boundaries, and share learned policies (along with all selected parameters and hyper-parameters).
In this paper, we introduce \textit{RayNet}, a scalable and flexible framework for developing learning-based network protocols; we focus on \textit{RL-based CC algorithms} but there is no fundamental limitation in the framework that would prevent the development of other types of learning-based protocols, such as RL-based routing \cite{stampa2017deep}. RayNet integrates two state of the art frameworks, namely OMNeT++ \cite{varga2008overview} and Ray \cite{moritz2018ray}, in an elegant and resource-efficient way. OMNeT++ is a state-of-the-art packet level, discrete event network simulator that is widely used by the networking research community and supports fully reproducible simulations. Ray is a general-purpose and universal distributed compute framework designed to perform any compute-intensive job (written in Python) with flexibility, including distributed training, hyper-parameter tuning, deep RL, and production model serving. RLlib \cite{liang2018rllib} in particular is an open-source RL toolkit that employs fine-grained nested parallelism to achieve state-of-the-art performance across a wide variety of RL workloads and provides scalable abstractions for assembling new RL algorithms with minimal programming overhead. RayNet is embedded deeply within OMNeT++ by tapping into the simulator's event loop, to control the simulation when needed; e.g., to collect experience - observations and reward - and enforce agent actions within the RL setup. At the same time, RayNet operates as a Ray Trainer, enabling users to run distributed multi-node training on OMNeT++ simulated networks through a set of Python bindings. Said integration is very efficient and the only (minimal) overhead is induced by the Python bindings that allow Ray to control a network simulation. We prototype an RL-driven CC approach as a case study to demonstrate how RayNet facilitates the design, engineering, and assessment of RL solutions for complex networking problems. Through experimentation, we show how RayNet enables optimisation and analysis of our RL-driven congestion control protocol, decoupling the learning logic configuration from the networking environment set-up and providing a multi-agent architecture. RayNet is, to the best of our knowledge, the first framework to integrate Ray/RLlib and OMNeT++ end-to-end. In \cite{gawlowicz2019ns}, a ns-3-based framework that exports an OpenAI Gym interface is presented. Unlike \cite{gawlowicz2019ns}, RayNet directly integrates OMNeT++ within a Ray worker by utilising Python bindings and by controlling the execution of the simulator. This reduces the potential for significant overhead associated with the inter-process communication required by \cite{gawlowicz2019ns}. This, along with RayNet's end-to-end interaction with Ray, results in large-scale, parallel training that is on par, in terms of efficiency, with the most advanced frameworks (as explained in Section \ref{experimentation_efficiency}). RayNet is available as an open source project at \textit{https://github.com/giacomoni/raynet}.
\section{Background}
\label{background}
In this section we briefly present work related to RayNet. First, we provide an overview of RL and CC. Then, we discuss OMNeT++ (and INET), focussing on its discrete event nature and programming interface for controlling network simulations. Finally, we discuss the key characteristics of Ray and how one can scale up RL using RLlib.
\subsection{Reinforcement Learning}
\label{rl}
\begin{figure}
\includegraphics[width=0.6\textwidth]{diagrams/interaction.pdf}
\centering
\caption{The agent–environment interaction in a Markov decision process \cite{sutton2018reinforcement}}.
\label{rl_interaction}
\end{figure}
RL is the process of learning how to maximise a numerical reward signal by mapping states to actions. The agent is initialised with a random decision-making strategy, thus it must experiment to determine which actions yield the greatest reward. Some actions may affect not only the immediate reward but also some or all of subsequent rewards.
The problem of RL can be formalised as the optimal control of partially-known Markov Decision Processes (MDP), a straightforward framing of the problem of learning from interaction to achieve a goal. The agent and environment interact at each of a sequence of discrete time steps, $t_0,t_1,t_2,t_3,...,t_n$, as shown in Fig. \ref{rl_interaction}. At each time step $t$, the agent receives a representation of the environment’s state, $S_t \in \mathcal{S}$, and on that basis selects an action, $A_t \in \mathcal{A}$. One time step later, partly as a consequence of its action, the agent receives a numerical reward, $R_{t+1}$, and finds itself in a new state, $S_{t+1}$. The MDP and agent together thereby give rise to a \textit{trajectory}, a sequence of states, actions and rewards $S_0, A_0, R_1, S_1, A_1, R_2, S_2, A_2, R_3, ...$. The ultimate goal for an RL agent is to find the policy, a mapping between space and actions $\pi: \mathcal{S} \rightarrow \mathcal{A}$, that maximises the \textit{discounted} cumulative reward:
\begin{equation}
\sum_{k=0}^{\infty} \gamma^k R_{t+k+1}
\end{equation}
where $\gamma \in [0,1]$ is the \textit{discount rate}\footnote{$\gamma = 1$ is valid only for episodic environments.}. Deep Reinforcement Learning (DRL) combines RL methods with non-linear function approximation, i.e. neural networks, to cope with target tasks in which states encountered may never have been seen before. In order to make rational judgments in such situations, it is required to generalise from prior experiences with distinct conditions that are comparable to the current ones in some way. Non-stationarity, bootstrapping, and delayed targets are challenges that do not often emerge in traditional supervised learning with NN, but do in RL with function approximation. A more detailed discussion of RL can be found in \cite{sutton2018reinforcement}.
RL algorithms require to sample trajectories of experience in order to improve the current policy. On-policy algorithms learn from experience sampled by the policy itself, whereas off-policy algorithms use (or re-use) experience collected by other policies to improve the currently optimised policy. \textit{Sample efficiency} is a key performance metric when designing and testing new RL algorithms \cite{yu2018towards}. Collecting trajectories of experience can be non-trivial for certain tasks. First, RL performs a trial-and-error search, which arises the challenge of the trade-off between exploration and exploitation. To gain a large cumulative reward, an agent must favour actions that it has previously tried and found to be rewarding. To discover such actions, however, it must try actions that have not been chosen previously. In certain applications (e.g., autonomous driving/robotics), the risk associated with the exploration can be high and the agent has to be trained on a safe environment before deployment on the real one. Second, some tasks may span over large time-scales and collecting samples of experience may be time-consuming. It is therefore very common that simulations are used to provide an efficient and safe environment for training RL agents. Agents can be subsequently be deployed `on the field' using the learned policy, which may or may not be updating based on experience collected by the deployed agent.
\subsection{Congestion Control}
\label{congestion control}
Multiple users accessing the same network must share available network resources - bandwidth and buffers - which are finite. Network congestion is a network state characterised by increased network delays, high packet loss and an overall network performance degradation, as a result of having one or more flows going through a bottleneck link where the required bandwidth exceeds the available one; this, in turn, results in severe degradation of users' quality of experience. Congestion must therefore be monitored and controlled. Congestion control is a distributed process which involves end-hosts, and potentially in-network devices, and aims to maximise network resource utilisation while fairly allocating resources among all users. During data transmission, the amount of required network resources depends on the sender's transmission rate. In modern computer networks, regulation of the transmission rate is done by end-hosts.
Research on congestion control has been active for the past four decades for two main reasons. First, the decentralised nature of computer networks, coupled with the heterogeneity of application requirements and network architectures, makes congestion control an inherently complex problem. Second, networks and traffic patterns evolve, and new network architectures constantly emerge. This requires frequent rethinking of congestion control algorithms or the introduction of new ones, otherwise current algorithms may operate sub-optimally. As a result, new iterations of design, engineering and experimentation of protocols are required. For example, multiple iterations of CC have been deployed in the wild, since TCP Tahoe, including TCP Cubic \cite{ha2008cubic}, TCP Compound \cite{song2006compound} and MultiPath TCP \cite{paasch2014multipath}. At the same time, there has been a plethora of proposed CC algorithms for data centre (\cite{alizadeh2010data, mittal2015timely, wu2010ictcp}), wireless (\cite{mascolo2001tcp, kliazovich2006tcp, shimonishi2005improving}) and satellite (\cite{akyildiz2001tcp, taleb2006refwa, durresi2001congestion}) networks all of which present wildly different characteristics and challenges compared to each other.
Most commonly deployed congestion control protocols use a sliding window of data packets (with or without explicit data pacing by the sender) to monitor and control the number of data in transit, by adjusting the window's size. CC algorithms modify the size of the window in response to congestion events (e.g., inferred packet loss, acknowledgement of packet delivery, or in-network marking of packets). Historically, there have been three fundamental categories of congestion control solutions: loss-based, delay-based, and network-specific solutions. Loss-based (or reactive) solutions, such as TCP Cubic \cite{ha2008cubic}, are general purpose protocols that perform congestion control based on inferred packet loss; the window size increases until packet loss is inferred, at which point, the window size is decreased. Delay-based (or proactive) solutions, such as TCP Vegas \cite{brakmo1994tcp}, monitor per packet delay and change the congestion window to proactively decrease connection latency and, therefore, aim to avoid congestion packet loss. Some protocols, such as TCP Compound \cite{song2006compound} and BBR \cite{cardwell2017bbr}, take a combined approach reacting to both loss and delay increase. Network-specific solutions are built to operate in specific networking settings, allowing for greater assumptions during protocol design. For example, protocols like DCTCP \cite{alizadeh2010data} target data centre networks, characterised by shallow buffers, high speed links and standardised network topologies (such as Clos topologies); TCP Westwood \cite{mascolo2001tcp} uses bandwidth estimation to distinguish congestion and stochastic packet loss in wireless channels.
Recently, a new approach for end-to-end congestion control has arisen, arguing that congestion signals and control actions are too complex for humans to interpret and that algorithms may provide superior policies. This defines an objective function to guide the development of the control strategy (e.g., on each ACK or periodically) that will optimise the specified function. Early work in this thread included off-line optimization of a fixed rule table \cite{winstein2013tcp, sivaraman2014experimental} and online gradient ascent optimization \cite{dong2015pcc, dong2018pcc}, with later work adopting sequential decision-making optimization via Reinforcement Learning algorithms \cite{badarla2011learning,jay2019deep, jin2018congestion, lan2019deep,li2016learning,li2018qtcp,mai2019self,nie2019dynamic,ramana2005learning,silva2016smart,tarraf1995reinforcement, xiao2019tcp, xu2019experience, abbasloo2020classic}.
\subsection{OMNeT++ Simulator}
\label{OMNeT++}
OMNeT++ is an extensible, modular and component-based C++ simulation framework that is primarily intended for the development of network simulators. The term `network' is used in a broad sense, encompassing wired and wireless communication networks, on-chip networks, queuing networks, etc. A simulation model consists of one or more components that encapsulate network functionality (e.g., the TCP/IP protocol stack, communication channels, mobility models) and interact with each other through gates. Components are developed in C++, then integrated using a high-level language into compound components and, finally, models to be simulated. INET is a model library for the OMNeT++ simulation environment that incorporates functionality for simulating computer networks (including the TCP/IP stack and several link/physical layer technologies).
OMNeT++ is a discrete-event simulator, which means that time progresses through scheduling events in the simulated future. The event queue is therefore a key data structure; scheduled events are placed in the queue according to their scheduled execution (simulated) time and the simulator executes events sequentially from the head of the queue, until no more events exist in the queue; i.e. the end of the simulation.
\begin{algorithm}
\caption{Simulation Life Cycle}\label{standalone}
\begin{algorithmic}[1]
\State initialise network \textit{model}
\While{ $\textit{queue.size} \neq 0$}
\State $\textit{event} \gets \textit{queue.get}$
\State $\textit{currentTime} \gets \textit{event.timestamp}$ \Comment{advance simulated time}
\State \textbf{process(}\textit{event}\textbf{)} \Comment{processing may alter event queue}
\EndWhile
\State finish simulation \Comment{statistics collection and clean-up }
\end{algorithmic}
\end{algorithm}
OMNeT++ simulations run as a single-threaded process; the pseudo-code shown in Listing \ref{standalone} shows at a high-level the life cycle of a standalone simulation execution. The network model is first imported and initialised (line 1). All simulation components are declared and interconnected in a collection of descriptive files (NED files) that constitute the model. The NED files specify the simulation model's structure, such as the number of nodes in the network, the links between nodes, and the protocols stacks supported at each node. Configuration (.ini) files set model components to work in a certain way, including the kind of application running on each node, the type of traffic, the physical link attributes, etc. Each component, whose behaviour is implemented in C++, is then dynamically linked to the simulation kernel. During initialisation of the network model, including its individual components (e.g., applications, links, TCP/IP stack), one or more events may be instantiated and inserted in the event queue. If none is created, then the simulation is completed and clean-up is performed (line 6). In the opposite case, the simulator program iterates over each one of the events in the queue in a chronological order and process it (lines 2 - 5); such processing may involve sending a message through a network link, or performing a timeout event. Processing an event may therefore generate new events; e.g., a timer is reset and rescheduled for the simulated future after its expiration. The simulation ends when no more events exist in the queue.
OMNeT++ offers an Application Programming Interface (API) through which simulations can be executed and controlled programmatically. More specifically, through this API, a programmer can iterate over events in the queue and process them individually; this feature is key in RayNet's integration with the Ray and RLlib as discussed in Section \ref{raynet_implementation}.
\subsection{Ray and RLlib}
\label{ray_rllib}
Ray \cite{moritz2018ray} is a platform for general-purpose cluster computing that supports simulation, training, and servicing for RL applications. RLlib \cite{liang2018rllib} is an open-source library that provides scalable software primitives for RL and enables a broad range of algorithms to be implemented with high performance, scalability, and substantial code reuse. RLlib supports a variety of environment interfaces for training agents.\footnote{See https://docs.ray.io/en/latest/rllib/rllib-env.html for an excellent discussion of supported RLlib environments.} \textit{OpenAI Gym} is the primary interface for single-agent training environments. When an episode begins, the initial observation is returned to the agent and the environment is reset to its initial state. The agent interacts with the environment by providing the action, and it receives a reward for the action performed and the subsequent observation. This interaction takes place in \textit{steps}, until an episode termination condition is met, either because the environment has achieved a terminal state or because the environment's maximum number of steps has been reached. In a multi-agent environment, numerous agents may act simultaneously, sequentially, or in a combination of the two. The \textit{MutiAgentEnv} interface enables mapping of trajectories to individual agents and the assignment of distinct policies to distinct agents. An agent can be mapped to a single policy, while a policy can be mapped to multiple agents. In many cases, the environment must run autonomously, outside of RLlib's control, such as in gaming engines or robotic simulator examples, although RLlib is still employed for training the respective agents' policies. Instead of having the agent actively step the environment and wait for the returned tuple, RLlib provides the \textit{ExternalEnv} interface, which permits querying a policy for actions and logging end-of-step tuples. RLlib allows scalability of experience collection in two ways: vectorisation of multiple environments within a single process and batching policy evaluations across these environments; i.e., distributing multiple environments across multiple processes, where each environment runs as an independent process.
\section{Design Principles}
\label{principles}
In this section, we discuss the key design principles underpinning RayNet, leaving all the implementation-specific details for Section \ref{raynet_implementation}.
\noindent\textbf{Separation of environment from learning.} As with standard RL training playgrounds, the environment must be logically separated from the learning process and its execution needs to adhere to a few simple operations (and, programmatically, to a respective API). This ensures that one can change learning algorithms and hyper-parameters without having to change anything in the environment where the agent(s) operate(s) in. Conversely, it is crucial that the environment can change without requiring any changes to the learning infrastructure, in order to support learning in different contexts and scenarios. A typical example of such a separation is the \textit{OpenAI Gym} abstraction that is widely adopted in numerous RL setups. Such a separation is particularly important in the context of computer networks, where a single agent may have to be trained in diverse network setups, regarding the physical topology, number of end-hosts, traffic workloads etc. In addition, the step size definition may be different depending on the nature of the problem being solved by the RL agent. Typically, games, such as Chess or Go, have a discrete turn-based structure in which each step corresponds to a player's turn. Other tasks, including Atari Games and Robot Control, necessitate the discretisation of time. For networking-related problems, time is continuous\footnote{Note that we refer to continuous time despite the fact that RayNet employs a discrete event simulator where simulated time progresses through the execution of events.}. Agents act at predefined time intervals that signal an RL step, the length of which depends on the particular task. It is therefore important that fine-grained control of the step size is supported, where agents can step independently to each other, in groups or individually. RayNet allows for a step-based approach (built on top of the \textit{OpenAI Gym} environment) by having Ray directly controlling the event execution loop for each simulation, as discussed in Section \ref{event_looping}.
\noindent\textbf{Support for multi-agent environments.} Learning policies for core network functions, such as CC and routing, requires operating multiple agents within a single environment. For example, as part of the learning process, one could have multiple TCP flows (i.e., CC agents that use the same policy) competing for bandwidth on a network link. Similarly, multiple routers in a network may be acting on flows independently, following the same or different policies. It is therefore crucial to support environment execution (for training and/or evaluation purposes) with multiple agents that may or may not learn/employ the same policy. RayNet supports this by integrating Ray/RLlib's multi-agent interface with a bespoke signalling system for disseminating and collecting actions, rewards, and observations that we developed using OMNeT++'s API, as detailed in Section \ref{raynet_environment}.
\noindent\textbf{Reproducibility.} Reproducibility enables researchers to replicate published results, identify errors or limitations and propose ways forward. RL is generally hard to reproduce due to the algorithms' intrinsic variance, the environments' stochasticity, and the potentially large number of hyper-parameters that can go unreported. \textit{RayNet} aims to minimise factors that can lead to non-reproducible results by employing OMNeT++ as the underlying environment for collecting experience to optimise agent policies. OMNeT++ simulations are deterministic by design, allowing for fully reproducible results; OMNeT++'s sophisticated pseudo-random number generator framework allows for controlling randomness and enabling truly independent runs of the same simulation (i.e., a RayNet environment). On top of this, Ray and RLlib, support state-of-the-art reporting of hyper-parameters, limiting non-determinism only to algorithms' intrinsic variance.
\noindent\textbf{Efficiency and scalability.} RL requires the collection of a very large amount of experience through which agents learn how to best interact with their environment. Experience is then collected into a replay/memory buffer and learning is usually done by drawing an experience batch out of this buffer. Three issues are crucial in this process; (1) the environment must be quick in transforming agents' actions into a reward, and some partially observable state, as modelled in the learning process; (2) the learning itself must be done efficiently; (3) and all available computational resources must be used as efficiently as possible; by enabling parallel instantiation and execution of as many environments as possible; and by minimising the overhead in the interaction between the learning and environment execution components of the RL setup. RayNet adheres to this principle, by using lightweight Python bindings (see Section \ref{overview}) to integrate Ray/RLlib with OMNeT++ in a programmatic fashion. Ray allows for running multiple environments in parallel, and OMNeT++ itself runs each environment (i.e., a network simulation) efficiently as a single-threaded process which enables parallel learning at scale.
\section{RayNet Architecture}
\label{raynet_implementation}
In this section, we discuss RayNet in detail. We first provide a high-level overview of its architecture, and describe how the RLlib environment is integrated with OMNeT++'s event loop and simulation models. We then focus on the bespoke signal system we developed within OMNeT++ so that Ray/RLlib can efficiently communicate actions to agents and collect observations and rewards from them at user-defined learning steps. Finally, we discuss how we can deploy trained agents (and associated policies) into a simulated environment and in a real-world computer network.
\subsection{Overview}
\label{overview}
\begin{figure}
\includegraphics[width=\textwidth]{diagrams/worker.pdf}
\centering
\caption{An overview of a RayNet worker's components. The \textit{Trainer} and \textit{Worker} are Ray processes. The Worker initialises and controls a Python class that implements the \textit{OpenAI Gym} interface and serves as the RL environment. Through the \textit{pybind11} API, OMNeT++ and the simulation model are embedded into the environment.}
\label{core_modules}
\end{figure}
RayNet employs Ray and RLlib which operate as discussed in Section \ref{ray_rllib}. OMNeT++ is used to instantiate learning environments. Ray's trainer and workers are completely oblivious of the implementation details of the learning environment, which are abstracted away through the \textit{OpenAI Gym} interface supported by RLlib. Figure \ref{core_modules} illustrates an overview of RayNet; for clarity, only a single worker is shown to interact with Ray's trainer. Having multiple workers running in parallel is trivially supported by Ray and wouldn't affect any of the discussed components in this section.
The trainer, i.e. the process running the RL algorithm, delegates policy evaluation to one or more parallel processes, referred to as rollout workers, to speed up experience collection during training. Each rollout worker is assigned one (as in Figure \ref{core_modules}) or more RayNet environments and interacts with them only by calling the methods exported by the \textit{OpenAI Gym} interface, namely \textit{initialise()}, \textit{step()} and \textit{reset()}, as shown in Figure \ref{core_modules}.
The environment itself is an OMNeT++ simulation, which consists of the discrete event loop handler, core OMNeT++ classes, including a user interface class, such as the \textit{cmdenv}\footnote{OMNeT++ calls these environments and are meant to facilitate configuration and execution of simulations, but they have nothing to do with the concept of RLlib environments.}, and all different simulation models that compose an OMNeT++ `network'. As discussed, in Section \ref{OMNeT++}, OMNeT++ exports an API to initialise, and run simulations, programmatically, instead of running a simulation as a standalone process. RayNet does not run OMNeT++ simulations as independent processes; instead, it employs the exported API to programmatically control the life cycle of a simulation; said life cycle is mapped to the methods exported by the \textit{OpenAI Gym} interface, effectively integrating Ray/RLlib with OMNeT++. Below, we briefly describe these methods abstracting away from the details of OMNeT++. In Section \ref{raynet_environment}, we analyse in detail the interactions within the OMNeT++ simulation in response to calling these methods.
\begin{itemize}
\item \textbf{initialise():} this method creates and initialises the environment. Objects of all core OMNeT++ classes along with classes that comprise the network are instantiated. The event loop handler is instantiated and, as part of the network initialisation, one or more events are scheduled for the future (e.g., an application sends a packet down to the data transport layer or a wireless node broadcasts a link layer frame). Note that the simulation has not started at this point; an episode can be started only after the \textit{reset()} method below is called.
\item \textbf{reset():} at any point or at the end of an episode (i.e., a running OMNeT++ simulation), the Ray/RLlib worker can call this method to restore the environment to a random or starting state. The function returns the starting observation for this new episode that is about to begin.
\item \textbf{step(action):} progression within an episode is done by calling this method. The worker provides the action to be performed on the environment, and the environment transitions to the subsequent state. The function returns an observation of the newly attained state, a reward value for the performed action, and a Boolean flag indicating whether the new state is final (i.e. the end of an episode) or not. Multiple agents can step in the environment simultaneously in which case all the aforementioned scalar values become vectors of values, with each element in the vector (e.g., the reward vector) being associated to a specific agent operating in the environment. The definition of the step, action, reward and observation space along with how the environment transitions from one state to another are problem-specific. The RL algorithm that runs within the trainer (see Figure \ref{core_modules}) feeds the action, reward and observation space into its internal model, but is oblivious of how the environment transitions or, in fact, what the environment is. In RayNet, all environment-specific knowledge is embedded within the OMNeT++ code. In the next section we explain how OMNeT++ signifies the end of a step, which triggers the \textit{step()} method to return control to the worker.
\end{itemize}
The last but crucial link of this integration is the Python bindings implemented using \textit{pybind11}\footnote{https://pybind11.readthedocs.io/}. As shown in Figure \ref{core_modules}, the Python bindings sit between the worker and the OMNeT++ API; they implement the \textit{OpenAI Gym} methods by subsequently calling bindings of C++ methods that directly call methods exported by the OMNeT++ API.
\subsection{Event Looping and Environment Stepping}
\label{event_looping}
\begin{algorithm}
\caption{Environment Stepping}\label{embedded}
\begin{algorithmic}[1]
\Procedure{Step}{}
\While{ $\textit{queue.size} \neq 0$}
\State $\textit{event} \gets \textit{queue.get}$ \Comment{retrieve event from head of event queue}
\State $\textit{currentTime} \gets \textit{event.timestamp}$ \Comment{advance simulated time}
\If{\textit{event}.type = \textsc{step}}
\State $\textit{obs} \gets \textit{model.getObs}$
\State $\textit{reward} \gets \textit{model.getReward}$
\State $\textit{done} \gets \textit{model.getDone}$
\State \Return \textit{(obs, reward, done)} \Comment{return control to the worker}
\Else
\State \textbf{process(}\textit{event}\textbf{)} \Comment{processing may alter event queue}
\EndIf
\EndWhile
\EndProcedure
\end{algorithmic}
\end{algorithm}
Performing a step in the integrated OMNeT++/OpenAI Gym environment requires executing one or many\footnote{In a large scale network simulation there could be thousands of simulated events in a single environment step.} simulated events. As a result of executing an event, the simulated time advances to the future time at which the event was scheduled to be executed.
As discussed in Section \ref{overview}, RayNet integrates OMNeT++ into Ray workers through OMNeT++'s API and by tapping into its event processing loop. The pseudo-code shown in Listing \ref{embedded}, which describes the behaviour of the \textit{step()} method mentioned in the previous section, illustrates this integration. Every time a worker calls the \textit{step()} method, through the \textit{pybind11} API (see Figure \ref{core_modules}), control passes to the event loop in Listing \ref{embedded}, which iterates over each one of the events in the queue in chronological order and process it (lines 2 - 11), until either no more events exist or a special \textsc{step} event is found (line 5). In the former case, the simulation (and implicitly the last step of the RL episode) is completed, and the worker cleans up the simulation outside this method. In the latter case, the end of the step is signified and the worker collects the reward (or vector of rewards for multiple agents) and observation (or vector of observations) from the agent(s) operating in the environment (lines 6 - 8), as discussed in Section \ref{raynet_environment}.
There are two important points related to the described integration; (1) Ray/RLlib (i.e., the trainer and workers) are completely oblivious of the nature of the step and the internals of the environment. The worker only knows to call the \textit{step()} method, which, in turn, consumes events in OMNeT++'s queue, effectively progressing the simulation (i.e., performing operations in the environment) without any need to understand the semantics of these events. Similarly, the step does not need to be defined by the trainer or worker(s); the \textit{step()} method returns when a \textsc{step} event is found in the queue. (2) Crucially, it is the responsibility of the environment to place this special event in the queue; this provides flexibility in defining a step within a specific problem space; e.g., in a CC problem the end of the step may be after a fixed amount of time elapses, or after a fixed or dynamically calculated number of packet acknowledgments are received by the sender. In all these cases, it is some user-defined OMNeT++ module that schedules a \textsc{step} event when some problem-specific conditions are met.
\subsection{RayNet Environment}
\label{raynet_environment}
A RayNet environment consists of OMNeT++ simulation models, implemented as C++ modules, and RayNet-specific modules (namely \textit{RL agents}, the \textit{Stepper} and \textit{Broker} as depicted in Figure \ref{environment_internals}) that facilitate environment stepping and its interaction with the Ray workers. A RayNet environment contains one or more RL agents that act based on policies trained outside the environment (i.e., within the Ray trainer, as depicted in Figure \ref{core_modules}). For example, in a CC setup, an agent could operate within the data transport layer, controlling the transmission rate for a specific network flow, while calculating the required observations and reward that are used for training one or more policies (see Section \ref{cc_with_raynet} for more details on our CC use case). The Stepper module is responsible for coordinating with the RL agents to enable the environment to transition to a new state when a Ray worker calls the \textit{step()} method. The Broker module is responsible for serialising and de-serialising action/observation/reward values (scalar or vectors) and disseminating these to agents (actions) and the Ray worker (observations/rewards), at the beginning and end of a step, respectively.
Interaction between the RayNet-specific modules is implemented using the signalling system provided by OMNeT++, which adopts a publish/subscribe communication paradigm. More specifically, an OMNeT++ module can subscribe by name to one or more signal types; multiple modules can subscribe to the same signal. When a module publishes a signal of one of the types for which other modules have previously subscribed, OMNeT++ passes the signal to these modules through a callback mechanism. A key advantage of such a paradigm is that the coupling between publisher and subscriber modules is loose; i.e., these modules do not need to know of each other to be able to communicate. This is crucial in RayNet because an environment may contain multiple agents that appear and disappear at different times during the life cycle of an environment; e.g., TCP senders for respective TCP flows. With OMNeT++'s signalling system, RL agents can communicate with the Stepper and Broker modules by publishing and subscribing to a priory known signal types without requiring referencing each other at compile time.
Upon environment initialisation the Stepper and Broker modules are also initialised and, as part of this, they subscribe to specific signal types so that (1) they can coordinate with each other and (2) receive messages by RL agents. RL agents that are present when the environment is initialised, register their presence with the Stepper and Broker modules by publishing signals of specific types, and subscribe to specific signal types so that they can receive messages from them; RL agents that appear during the life cycle of an environment follow the same registration process with the Stepper and Broker modules. At this point, initialisation is complete and the \textit{initialise()} method that triggered the operations described above returns control to the Ray worker.
Next, Ray workers call the \textit{reset()} method of the OpenAI Gym API, which brings the environment to a state where the first step can be taken. This may be involve processing zero to many simulated events that have been queued in the event queue during initialisation and events that need to be scheduled and executed as part of the environment resetting. It is the Stepper module that signals this state by inserting a \textsc{step} event at the front of the queue (i.e., scheduling the event to the present simulated time). The environment is now ready to be stepped and the \textit{reset()} method returns control to the Ray worker, along with the initial environment observation.
\begin{figure}
\includegraphics[width=\textwidth]{diagrams/environment.pdf}
\centering
\caption{OMNeT++ module interactions throughout the life cycle of a step}
\label{environment_internals}
\end{figure}
A Ray worker subsequently steps the environment (by repeatedly calling the \textit{step()} method) until the end of the episode - the definition of the episode is problem-specific; e.g., the end of the simulation or reaching some internal milestone. The end of the episode is signified by the environment, by returning the step() method with the relevant Boolean flag set to true. Figure \ref{environment_internals} illustrates the sequence of RayNet-specific operations that take place during a step. Note that, as discussed in Section \ref{event_looping}, a potentially large amount of simulated events may be executed during a step; here we focus only on events, signalling and data exchange related to the step itself; all other events are standard OMNeT++ events that simulate some intended network functionality. When the Ray worker calls the \textit{step()} method, the \textsc{step} event that was previously inserted in the event queue is consumed and a new environment step begins ((1) in Figure \ref{environment_internals}). The value of the action is passed to the Broker module, directly through the OMNeT++ API which allows accessing OMNeT++ modules by name ((2) in Figure \ref{environment_internals}). Depending on the number of RL agents present in the environment, this value may be a scalar value or a vector of values (in fact a pair of \{agent-id, action\} values), one for each RL agent. The Broker module then `broadcasts' the action(s) by publishing a signal that RL agents are subscribed ((3) in Figure \ref{environment_internals}). At this point every RL agent is aware of what it needs to do in the current step. The Ray worker loops over events in the event queue until a \textsc{step} event is encountered. As discussed above, such a step event is inserted in the queue by the Stepper module when some environment-specific condition is met ((5) in Figure \ref{environment_internals}). Throughout the duration of each step, the Stepper module coordinates with the Agent modules using the signalling system to delineate the end of the step ((4) in Figure \ref{environment_internals}); e.g., in Section \ref{cc_with_raynet}, we describe how we have used per-agent timers (implemented as self-messages in OMNeT++) to step the environment in our CC use case. RL agents signal their observation and reward to the Broker module at the end of the step ((6) in Figure \ref{environment_internals}). When the Ray worker encounters the \textsc{step} event in the event queue, it collects observations and rewards directly from the Broker module through the OMNeT++ API ((7) in Figure \ref{environment_internals}). These are communicated back to the Ray trainer which places them into the RL replay/memory buffer.
\subsection{Policy Deployment}
\label{deployment}
Deploying a learned policy within RayNet's simulated environment is straightforward; Ray/RLlib allows to reload previously trained policies, either for evaluation or resume training from some saved checkpoint. During evaluation, exploration is not necessary and can be disabled when computing actions. In fact, the reward, unless is part of the input features of the observation, is not required by the agent during the decision-making process, and it is only used during training of the policy. In Section \ref{experimental_evaluation}, we show how trained agents perform when deployed in a wide variety of environments, all of which are simulated.
Deploying a policy that was learned with RayNet in a real network deployment would require (1) exporting the learned model(s) that comprise the policy which is a feature of Ray/RLlib and (2) integrating the policy with a real-world implementation of the network functionality under consideration. For example, in the CC use case, one could integrate the learned policy into a user-space process that communicates with a kernel-space implementation of a modified TCP protocol using the sockets API, as it is done in \cite{abbasloo2020classic}. The modified TCP protocol collects observations and passes them to the user-space process that, in turn, feeds back to it an action calculated by taking into account the received observations.
\section{Learning Congestion Control with RayNet}
\label{cc_with_raynet}
In this section, we describe a use case of RayNet, namely Congestion Control (CC) with deep reinforcement learning (DRL), that we have developed to showcase RayNet's functionality. As discussed in Section \ref{congestion control}, CC is responsible for adjusting the amount of in-flight (i.e., sent but unacknowledged) data and/or the pace at which data is sent, so that (1) network utilisation is maximal, (2) perceived latency is minimal, and (3) some form of fairness is adhered to (e.g. max-min fairness). A CC policy dictates an action (e.g., increasing the amount of allowed in-flight bytes) in response to some signalled or inferred state from the network (e.g. an increase in the experienced packet round trip time, or receiving three duplicate acknowledgments).
\begin{figure}[H]
\includegraphics[width=0.75\textwidth]{diagrams/ccusecase.pdf}
\centering
\caption{Timeline of the congestion window evolution of a simulated episode with two flows (agents). After the initialization, flows are scheduled and \textit{reset() }is called on the environment. The end of the initial step marks the end of a \textit{reset()} call and control of the window is delegated to the agents. The agents adjust the congestion window (red squares) at the beginning of each step.}
\label{ccusecase}
\end{figure}
In our use case, each RL agent sits on the sender side of each data transport flow in the network. For each flow, data transmission takes place in steps, and at the beginning of each step the RL policy fixes the congestion window size for the whole step duration - no updates in the congestion window size occur within a step in response to incoming acknowledgments or any other in-network signals. Depending on the network's path propagation delay and bandwidth, the steady-state congestion window size of a flow can range over several orders of magnitude, therefore, similarly to \cite{abbasloo2020classic}, to reduce the action space size, the policy action $\alpha$ is a multiplier applied to the current congestion window size. At the beginning of each step $t$, RL agents set the value of the $cwnd_{t}$, according to Equation \ref{cwnd_eq}.
\begin{equation}
\label{cwnd_eq}
cwnd_{t} = 2^{\alpha} \times cwnd_{t-1}
\end{equation}
The choice\footnote{We do not discuss in any detail the rationale behind selecting the specific action, observation and reward and present these here only for completeness so that we can discuss experimental results presented in Section \ref{experimental_evaluation}.} of $ \alpha $ is limited to the range [-2,2], so that the congestion window can increase by a max of four times and decrease to a max of a quarter of the current window size.
RL agents infer the state of the network through observations defined as as follows:
\begin{enumerate}
\item The throughput $\mathcal{R}$ achieved in the last step over the estimated maximum bandwidth $\mathcal{R}^{max}$ of the connection.
\item The min-max normalised smoothed round trip time $\tilde{d}$, measured in the last step, where the min and max RTT values, $d^{min}$ and $d^{max}$ respectively, are estimated from the beginning of the connection.
\item The ratio of packets lost $\mathcal{L}$ over total packets transmitted in the last step
\item The current congestion window size.
\end{enumerate}
At each step, the reward $r$ assigned to the agent depends on the throughput $\mathcal{R}$, round trip time $d$ and loss rate $\mathcal{L}$ measured in the step as follows:
\begin{equation}
r=\begin{cases}
\frac{\mathcal{R}}{\mathcal{R}^{max}} - L, & \text{if $\frac{\mathcal{R}}{\mathcal{R}^{max}} - L < 1 \land d = d^{min}$}.\\
(\frac{\mathcal{R}}{\mathcal{R}^{max}} - L) \cdot \frac{d^{min}}{d} \cdot (1 - \tilde{d}), & \text{otherwise}.
\end{cases}
\end{equation}
where $\tilde{d} = \frac{d - d^{min}}{d^{max} - d^{min}}$.
The life cycle of an example episode with two flows is illustrated in Figure \ref{ccusecase}. After the environment initialisation, Flow 1 (shown in blue) is scheduled to start first at time $t_{f1}$ and Flow 2 (shown in green) is scheduled to start at time $t_{f2}$. Upon calling the \textit{reset()} method, the simulation loop starts executing events until the first flow starts. When the flow starts, it sets the congestion window to a small fixed value (as in \cite{ha2008cubic}), publishes a signal to the \textit{Stepper} module to register its presence, and declares the duration of its initial step ((4) in Figure \ref{environment_internals}). For simplicity, here we assume that some known average of the Round-Trip Time (RTT) in the network is selected as step size.\footnote{In practice, we employ a \textit{slow-start} phase (as TCP does) during which the congestion window size is increased exponentially in every RTT, until either a threshold is reached or packet loss occurs. This enables the sender to acquire good estimates of the current RTT, the minimum observed RTT and the maximum observed throughput; the former is used to set the duration of the first step, and the rest are used in the calculating rewards.}At time $t_{s1}$ the RL agent calculates its environment observation for the initial step and publishes it to the \textit{Broker}, signalling the end of the step and returning from the \textit{reset()} method. After inferring the next action from the received observation, the Ray worker calls the \textit{step()} method passing the new action to the environment. The duration of this (and all subsequent) steps is calculated by the agent at the start of each step. Each RL agent (one for each flow) in the network steps independently, and each step lasts for an amount of simulated time equal to twice the minimum RTT that the sender has observed in the last 10 seconds for this connection - the minimum RTT should change only when the network path changes due to re-routing. Each RL agent declares its own step duration to the Stepper module ((4) in Figure \ref{environment_internals}), which subsequently schedules a \textsc{step} event accordingly ((5) in Figure \ref{environment_internals}); note that the step duration can vary from step to step, as depicted in Figure \ref{ccusecase}. Flow 2 (shown in green) starts at time $t_{f2}$, in the middle of one of Flow 1's steps. Flow 2 also performs its initial step; at time $t_{s2}$, and before Flow 1 steps, the first observation value is returned and a new step for Flow 2 begins upon receiving a new action drawn from the RL policy. Note that in the figure, RL agents of different flows step independently from the each other collecting observations and rewards that are all fed into the same training process; i.e., learning a single RL policy.
\begin{figure}
\begin{minipage}[b]{0.47\textwidth}
\centering
\includegraphics[width=0.8\textwidth]{diagrams/Dumbell.pdf}
\caption{Dumbell topology}
\label{dumbel_topology}
\end{minipage}
\hfill
\begin{minipage}[b]{0.47\textwidth}
\centering
\begin{tabular}[t]{||c | c | c||}
\hline
\textbf{Bandwidth} & \textbf{RTT} & \textbf{Buffer} \\ [0.5ex]
\hline\hline
64-128Mbps & 16-64ms & 80-800 packets \\ [0.5ex]
\hline
\end{tabular}
\tabcaption{Network Parameters' ranges during training}
\label{tab:training_range}
\end{minipage}
\end{figure}
\section{Experimenting with RayNet}
\label{experimental_evaluation}
In this section, we explore RayNet's capabilities and performance characteristics through experimentation with (1) the congestion control use case discussed in Section \ref{cc_with_raynet} and (2) a simple CartPole environment \cite{barto1983neuronlike} that we also developed in RayNet. Our aim is to showcase that RayNet meets the design principles set out in Section \ref{principles}, namely \textit{separation of environment from learning}, \textit{support for multi-agent environments}, and \textit{efficiency and scalability}.\footnote{We do not discuss the \textit{reproducibility} principle any further here; OMNeT++ simulations are deterministic therefore any reproducibility limitations only stem from RL algorithms' intrinsics.}First, we demonstrate how \textit{RayNet}'s design facilitates learning in the context of a complex networking task which involves the search and optimization of RL algorithms and respective hyper-parameters, evaluation on diverse networking environments, and analysis of multi-agent performance. Second, we demonstrate that RayNet's overhead in terms of CPU and memory utilisation, and learning efficiency is negligible when compared to learning to perform the same baseline task (i.e., the CartPole task) using Open AI's CartPole environment. All experiments were conducted on a Linux server with 32 CPUs and 128GB of RAM.
\subsection{Separation of environment from learning}
\label{experimentation_separation}
Here, we train models to yield efficient congestion control policies using the reward function and observations discussed in Section \ref{cc_with_raynet}. Specifically, we train a single RL agent (i.e., a sender) on a Dumbell network shown in Figure \ref{dumbel_topology}. Delay, loss rate, and maximum bandwidth for the connection are determined by the path bottleneck's traffic load, physical transmission rate, and buffer size. Consequently, we model any network end-to-end path as a single bottleneck link with propagation delay equal to the path's delay and link rate equal to the link in the path with the lowest link rate. We adopt a `train and deploy' approach for our congestion control policy. During training, the policy is optimised by a specific algorithm, which generates samples of experience, and continuously updated so as to maximise the expected cumulative reward.
\noindent\textbf{Varying environment parameters.} First, we demonstrate how RayNet enables varying the environment completely independently of its learning components. We expose the congestion control agent to a variety of network configurations, with network parameters sampled from the ranges shown in Table \ref{tab:training_range}. We train the agent for 1 million environment steps using sixteen parallel rollout workers. Each worker creates its own RL environment (i.e., simulated network) by uniformly sampling its parameters over each of the parameter ranges listed in Table \ref{tab:training_range}. Workers simultaneously produce and provide the trainer with experience by stepping their environments independently. Parallel experience gathering from multiple networking scenarios prevents the model from overfitting particular network conditions and avoids ``catastrophic forgetting'' of network scenarios for which experience had been gathered earlier in the training process \cite{abbasloo2020classic}. We define the parameterised networks using OMNeT++'s NED language and set the precise values of bottleneck bandwidth, propagation delay, and buffer size at the beginning of each episode. The agent is trained using Deep Deterministic Policy Gradient (DDPG), a model-free actor-critic algorithm based on the deterministic policy gradient that can operate over a continuous action space \cite{lillicrap2015continuous}, in conjunction with distributed prioritised experience replay \cite{horgan2018distributed}. Similar to other deep learning and reinforcement learning solutions, DDPG comes with a set of hyper-parameters, such as the replay buffer size, neural network learning rates, target network update scale, etc., which are frequently optimised for the specific task at hand through search. Optimization of the algorithm's hyper-parameters is outside the scope of this study, thus we have fixed them to the default values of the RLlib implementation. However, RLlib allows hyper-parameter to be easily configured using a simple key-value map. Ray also includes Ray Tune \cite{}, an automated tool for tuning hyper-parameters, which can be customised to employ sophisticated search techniques, such as grid search and Bayesian optimisation. All this advanced functionality is complementary to RayNet and accessible by default through Ray.
We evaluate the DDPG-trained policy on networks with parameters sampled from a wider ranges than the ones used for training so that we can assess how well the policy generalises to unseen environments. Using neural networks, deep RL models relate continuous state space to actions and/or expected reward. Due to the state value space being extremely large, the model cannot exhaustively explore all of the space, eventually encountering states it has never seen before. Assessing the model's performance in regions of the state space that were not observed during training can help prevent deployment failures. We evaluate the agent by varying one of the three studied dimensions (bandwidth, propagation delay, and buffer size) within a range that includes but is broader than the respective training range (see Table \ref{tab:training_range}), while keeping the other two fixed at the mean value of the training range. We assess the performance of the agent (and its underlying congestion control policy) by measuring three key performance metrics; \textit{normalised throughput} (i.e., the measured throughput over the theoretical maximum one), \textit{queuing delay} (at the network bottleneck), and \textit{packet loss}.
\begin{figure}[t]
\centering
\includegraphics[width=1\linewidth]{plots/bandwidth2.pdf}
\caption{Normalised throughput, queuing delay and average loss rate of a single flow as the bottleneck bandwidth varies. Shaded region indicates the bottleneck bandwidth range used during training.}
\label{fig:bandwidth}
\centering
\includegraphics[width=1\linewidth]{plots/rtt2.pdf}
\caption{Normalised throughput, queuing delay and average loss rate of a single flow as the propagation delay varies. Shaded region indicates the propagation delay range used during training.}
\label{fig:rtt}
\centering
\includegraphics[width=1\linewidth]{plots/buffer2.pdf}
\caption{Normalised throughput, queuing delay and average loss rate of a single flow as the buffer size varies. Shaded region indicates the buffer size range used during training.}
\label{fig:buffer}
\end{figure}
Figures \ref{fig:bandwidth}, \ref{fig:rtt} and \ref{fig:buffer} depict the (a) normalised throughput, (b) queuing delay, and (c) loss-rate for a single flow in networks when varying bandwidth, propagation delay, and buffer size, respectively. Lines depict the mean values and the blue-shaded regions depict the standard deviation. On the x-axis and y-axis, we show the varying parameter of the network and measured performance metric, respectively. The red-shaded region depicts the training range for the varying network parameter. Although analysing these results in depth is beyond the scope of this paper, for completeness, we briefly discuss the behaviour of the learned policy, noting that it is RayNet that allows such analysis through its clean separation of the environment from the learning components.
The network's bottleneck bandwidth influences flow's throughput, queuing delay and loss rate the most compared to the other two dimensions, i.e. propagation delay and buffer size. In fact, if the bandwidth of the network falls within the training range values, the flow achieves the highest bandwidth utilisation (Figure \ref{fig:bandwidth}.a), lowest queuing delay (Figure \ref{fig:bandwidth}.b) and negligible packet loss rate (Figure \ref{fig:bandwidth}.c). If the bottleneck bandwidth falls outside of the training range, the flow's throughput degrades when the available bandwidth is less than the experienced values (Figure \ref{fig:bandwidth}.a), due to large congestion windows that overfill the bottleneck buffer, increasing queuing delays (Figure \ref{fig:bandwidth}.b) and packet loss (Figure \ref{fig:bandwidth}.c); when the available bandwidth is greater than the experienced range, the policy's control of the congestion window results in underutilisation of the bottleneck link, characterised by low throughput (Figure \ref{fig:bandwidth}.a) and no queuing delay (Figure \ref{fig:bandwidth}.b). Even when available bandwidth is underutilised, the flow experiences loss rate (Figure \ref{fig:bandwidth}.c). This is due to an increase packet loss at the conclusion of the Slow Start phase in larger BDP connections, when the number of in-flight packets is larger and so is packet loss. When the propagation delay is raised, the resultant behaviour is comparable (Figure \ref{fig:rtt}.c). Setting the propagation delay outside of the training ranges does not affect performance as much as the variation of bandwidth does. In fact, the stepping system of the policy is delay agnostic, and always set to the least round trip time measured during the connection. With increased propagation delay, BDP and loss rate towards the end of slow start rise (Figure \ref{fig:rtt}.c). Queues build-up is also more likely (Figure \ref{fig:rtt}.b). Variation in buffer size mostly increases queuing times, which increase linearly with buffer size (Figure \ref{fig:buffer}.b).
\begin{figure}[t]
\centering
\begin{minipage}[t]{.32\textwidth}
\centering
\includegraphics[width=\linewidth]{plots/episode_reward_mean.pdf}
\captionof{figure}{Cumulative episode reward during training over the number of experience steps collected so far. Mean and standard deviation are computed across the 15 parallel episodes and seeds at each training step. }
\label{fig:episode_reward_mean}
\end{minipage}
\hfill
\begin{minipage}[t]{.32\textwidth}
\centering
\includegraphics[width=\linewidth]{plots/episode_length_mean.pdf}
\captionof{figure}{Episode length during training over the number of experience steps collected so far. Mean and standard deviation are computed across the 15 parallel episodes and seeds at each training step}
\label{fig:episode_len_mean}
\end{minipage}
\hfill
\begin{minipage}[t]{.32\textwidth}
\centering
\raisebox{0.3cm}{\includegraphics[width=\linewidth]{plots/time_over_algorithm.pdf}}
\captionof{figure}{Duration of a training session of 1 million steps with PPO, SAC and DDPG. Error bars depict the standard deviation across training sessions with different seeds.}
\label{fig:alg_len}
\end{minipage}
\end{figure}
\noindent\textbf{Varying learning parameters and hyper-parameters.} Discovering and optimising RL policies often requires empirical evaluation to identify the best RL algorithm and its hyper-parameters for a given task/problem and it has been shown that specific algorithms perform best in some problems than others \cite{xu2014reinforcement}. For instance, some task may inherently require a stochastic decision making policy to maximise the objective, like in the Rock-Paper-Scissors example, where a deterministic policy would inevitably lead to sub-optimal decisions. Even after fixing the RL algorithm to be used in a specific use case, one needs to evaluate its efficacy within a broad range of hyper-parameters associated to the selected algorithm. For example, DDPG require fine tuning of the exploration strategy \cite{lillicrap2015continuous}; SAC enforces exploration including the maximization of the policy's entropy in the reward formulation, at the cost of introducing a new \textit{temperature} hyper-parameter \cite{haarnoja2018soft} that trades off exploration and rewards; PPO uses a surrogate loss function to keep the step from the old policy to the new policy within a safe range, which requires either a clipping threshold, a weighted KL divergence factor or a combination of the two \cite{schulman2017proximal}. Several hyper-parameters are common to multiple RL algorithms but need to be optimised separately for each algorithm and task at hand. For example, off-policy algorithms often store experience in replay buffers, whose size must be set; the discount factor $\gamma$ is a common hyper-parameter to the majority of RL algorithms implementations; function approximators like neural networks bring their whole package of hyper-parameters, such as learning rates, loss optimizers, activation functions, and so on. RayNet supports such exploratory studies out of the box, by integrating Ray/RLlib with OMNeT++ so that the RL environment is completely separated to the learning components. To demonstrate this capability, we train RL policies in the experimental setup discussed above, using three state-of-the-art algorithms; PPO \cite{schulman2017proximal}, a policy gradient algorithm, (APEX) DDPG \cite{lillicrap2015continuous}, a deterministic policy gradient algorithm with distributed prioritised experience replay, and SAC \cite{haarnoja2018soft}, a soft policy optimization version of the actor-critic algorithm. All three algorithms are part of RLlib \cite{liang2018rllib} and all relevant configuration is done using RLlib's APIs, completely independently of the underlying environments (which are parameterised as in the previous section).
Figure \ref{fig:episode_reward_mean} illustrates the average cumulative reward of episodes attained during training of the agent with the three aforementioned algorithms. Both PPO and SAC optimise a stochastic policy, that is, a distribution of actions given the state, and each policy update is constrained by selecting a safe region for the policy update (PPO) or by imposing the maximum entropy principle (SAC). In both instances, the cumulative reward is increasing monotonically, and both algorithms converged to their asymptotic optimum after the same number of training steps (around 125K). The asymptotic cumulative reward of SAC is dependent on the entropy weight factor, and the default entropy maximisation strategy led in a lower cumulative reward than PPO. DDPG, meanwhile, optimises a deterministic strategy. The policy update is not restrictive, and the policy change is contingent on the exploration strategy. Figure \ref{fig:episode_reward_mean} shows that an initial warm-up time of 200,000 steps with random experience gathering delays learning of DDPG. As the policy begins training, the cumulative reward reaches a local maximum before recovering and converging to a superior asymptotic maximum. This behaviour is a result of the varied duration of episodes. As per the definition of our congestion control model, an episode can end in three ways: (1) the policy creates a high level of congestion that may be too difficult to recover from, at which point the episode ends; (2) the flow is entirely delivered; or (3) the episode reaches a maximum number of steps (400 steps in our case). In the second scenario, the policy's cumulative reward may be deceptive regarding the quality of the policy itself. Figure \ref{fig:episode_len_mean} and Figure \ref{fig:episode_reward_mean} illustrate that longer episodes may result in greater cumulative reward, but for a fixed size flow, shorter episodes imply shorter flow completion times, a consequence of well behaving congestion control policies. Among the three classes of algorithms, SAC requires the longest wall clock time to complete training, twice as much as PPO and DDPG do (Figure \ref{fig:alg_len}).
\subsection{Support for multi-agent environments}
\label{eval_multi_agent}
\begin{figure}[t]
\centering
\begin{minipage}[t]{.45\textwidth}
\centering
\includegraphics[width=.85\linewidth]{plots/cwnd_multi.png}
\caption{Evolution of the congestion window of two contending flows. Flows are controlled by two independent agents, but both agents use the same policy.}
\label{fig:cwnd_multi}
\end{minipage}
\hfill
\begin{minipage}[t]{.45\textwidth}
\centering
\includegraphics[width=.85\linewidth]{plots/throughput_multi.png}
\caption{Throughput achieved by two contending flows governed by two independent agents using the same policy. }
\label{fig:thr_multi}
\end{minipage}
\end{figure}
In this section, we showcase \textit{RayNet}'s support for multi-agent environments by experimenting with networks where two flows contend for resources at the shared bottleneck shown in Figure \ref{dumbel_topology}. To simplify the discussion, we only allow multiple agents to run in the network when evaluating a previously learned policy. The policy itself is learned using a single agent that experiences different networks as discussed in the previous section. Internally, \textit{RayNet} employs the same exact mechanisms (discussed in Section \ref{environment_internals}) to enable multiple agents to operate in an environment and communicate with Ray in the context of policy learning or evaluating a policy. We run the two flows on a network with a 440-packet buffer, a 100Mbps bottleneck and 35ms propagation delay.
Figure \ref{fig:cwnd_multi} shows the evolution of the congestion window size for the two flows. When the first agent (blue line) starts controlling the window, it brings its size to match the connection's bandwidth delay product (BDP), that is the optimal window size for a single flow traversing an empty network path \cite{kleinrock2018internet}. When the second flow (green line) starts transmission, the window grows exponentially as part of the slow start phase, until loss occurs. Then, the RL agent takes over control and the congestion window is adjusted towards the BDP of the connection. Despite the lack of multiple flows experience during training, the policy achieves a relatively fair allocation of bandwidth among the two flows (Figure \ref{fig:thr_multi}). The first flow (agent) brings the window to match the BDP as soon as the second flow terminates.
\subsection{Efficiency and Scalability}
\label{experimentation_efficiency}
\begin{figure}[t]
\centering
\begin{minipage}[t]{.45\textwidth}
\centering
\includegraphics[width=0.85\linewidth]{plots/cpu_usage.pdf}
\caption{Average CPU usage of RayNet and OpenAI Gym when training a DQN agent on the CartPole task.}
\label{fig:cpu_usage}
\end{minipage}
\hfill
\begin{minipage}[t]{.45\textwidth}
\centering
\includegraphics[width=0.85\linewidth]{plots/ram_usage.pdf}
\caption{Average RAM usage of RayNet and OpenAI Gym when training a DQN agent on the CartPole task.}
\label{fig:ram_usage}
\end{minipage}
\end{figure}
So far we have showcased that RayNet enables rich experimentation with RL-based network protocols, by separating the environment from the learning and supporting multiple agents when learning and evaluating RL policies. It is crucial that such features do not come at a cost of slow and resource-hungry learning. In this section we provide evidence that RayNet's overhead is minimal when compared to a state-of-the-art learning framework. We do so by implementing the CartPole task \textit{CartPole-v1} as an OMNeT++ model within RayNet and comparing its learning efficiency with that of the CartPole task implemented in the Open AI Gym.
In the CartPole task, a non-actuated junction connects a pole to a frictionless track-traveling cart. The pole is positioned vertically on the cart, and the objective is to balance it by applying forces to the cart's left and right sides. Before detailing the specifics of the experiments, we discuss briefly our \textit{RayNet} implementation of the CartPole environment based on \cite{1606.01540} utilising Figure \ref{environment_internals} as a reference. The dynamics of the CartPole state transitions are implemented in a single simulation component. During environment initialization, the \textit{Broker}, \textit{Stepper} and CartPole modules register to specific signal types so that actions, observations, and rewards can be exchanged. When \textit{reset()} is called on the environment, the internal state of the CartPole component is reset to a random value (of the state space). The CartPole component immediately sends the randomly generated observation to the \textit{Broker}, and the \textit{Stepper} inserts a \textsc{step} event into the queue. After retrieving the observation from the \textit{Broker} and calculating a new action, the rollout worker invokes \textit{step(action)} on the environment with the new action to execute. The \textit{Broker} delivers the action to the CartPole component through a signal, and the state transition accompanied by reward calculation immediately follows. The new observation and reward are then pushed to the \textit{Broker}, the \textit{Stepper} inserts a new \textsc{step} event into the queue, and the step() method finishes.
\begin{figure}[t]
\centering
\begin{minipage}[t]{.45\textwidth}
\centering
\includegraphics[width=0.85\linewidth]{plots/reward_over_absolute_time.pdf}
\captionof{figure}{Mean reward averaged across multiple DQN training sessions on the CartpPole task with 2, 4, 8, 16, 32 and 64 parallel workers over wall time. Policies trained with OpenAI Gym environment and RayNet yield similar reward.}
\label{fig:reward_on_time}
\end{minipage}
\hfill
\begin{minipage}[t]{.45\textwidth}
\centering
\includegraphics[width=0.85\linewidth]{plots/reward_and_time_by_workers.pdf}
\captionof{figure}{Relative wall clock time and reward achieved when training DQN on the CartPole task with a varying number of parallel workers. RayNet achieves the target reward in the same wall clock time when using Omnet++ based environment and OpenAI gym environment. The maximum reward achieved depends on the number of parallel workers.}
\label{fig:reward_time_on_workers}
\end{minipage}
\end{figure}
For both setups, we train a DQN \cite{mnih2013playing} policy using a varying number - between 2 and 64 - of rollout workers that operate in parallel. For each \{environment, number of workers\} pair we run the training with three different seeds and each run terminates upon yielding a mean cumulative reward of 450 across all parallel workers or after 2000 seconds of training. The maximum achievable cumulative reward for the CartPole-v1 environment is 500 but the exploration during training can take suboptimal actions and the maximum reward may never be measured. Figures \ref{fig:cpu_usage} and \ref{fig:ram_usage} show the CPU and RAM usage, respectively, when training the DQN agent using the \textit{RayNet} and Open AI gym environment, respectively. Given the low computational cost of modelling the mechanics of the CartPole, as the number of parallel workers increase, the CPU usage is bounded by the I/O operations required by the communication between trainer and workers. We observe that the RayNet's penalty for integrating OMNeT++ through the \textit{pybind11} API is negligible regardless of the number of workers producing experience in parallel. RAM utilisation grows linearly with the number of parallel workers and both implementations utilise a similar amount of memory.
Crucially, the training time of the DQN agent is also invariant with respect to the two environment implementations. Figure \ref{fig:reward_time_on_workers} shows the relative wall time taken to train the policy and the mean episode reward achieved at the end of training. Any extra complexity added with \textit{RayNet}'s environment does not affect the time required to train the DQN agent compared to the OpenAI Gym environment. The reward achieved is susceptible to neural network weights initialisation, the randomness introduced by the distributed nature of the system (e.g. arrival times of batches of experience at the trainer) and the number of parallel workers; however, the agent's cumulative reward achieved during training is similar regardless of the trained environment (Figure \ref{fig:reward_on_time}).
\section{Conclusion}
\label{conclusion}
In this paper, we presented \textit{RayNet}, a simulation platform for training and evaluating reinforcement learning-driven network protocols. RayNet integrates a widely used, off-the shelf discrete-event simulator, OMNeT++, and Ray/RLlib, a distributed platform for reinforcement leaning at scale. The integration is achieved through the usage of Python bindings and the signalling system that is implemented by OMNeT++, that allow RL agents to control decision making in the simulated environment.
We presented a case study on the design and experimentation of an RL-driven approach for congestion control. Our results show how RayNet’s design facilitates learning-based protocol development; it allows separate and extensible configuration for the learning algorithm and the networking environment; it supports multi-agent simulation, with each agent stepping independently; and it introduces minimal overhead compared to existing general-purpose training frameworks.
Our future work is on developing more use cases for RayNet, including RL-based routing and traffic engineering. RayNet is available as an open-source project for the research community to use and develop further. At the same time we are currently using RayNet in researching fair congestion control algorithms and studying existing RL-based CC models in depth.
\bibliographystyle{ACM-Reference-Format}
\section{Introduction}
| {'timestamp': '2023-02-10T02:09:11', 'yymm': '2302', 'arxiv_id': '2302.04519', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04519'} | arxiv |
\section{Introduction}\label{sec:introduction}}
\IEEEPARstart{C}{lassical} test theory (CTT) is the current modus operandi for evaluating supervised machine learning models, that assumes all cases (samples) are created equivalent. This approach is operationalized by first establishing a percentage of the data held in reserve (i.e., ‘test data’) to which the model is naive. The test data are comprised of a random sample of anywhere between 10-30\% of the total dataset and capitalizes on an n-fold cross validation process where the portion of data allocated for evaluation purposes is staged and iterated upon \cite{Krstajic}. From this point evaluations are made to assess model performance. These typically include area under the curve (AUC), receiver operating curve (ROC), accuracy, sensitivity, specificity, recall, and F1.
While these evaluation metrics are useful, they are not without their drawbacks \cite{Santafe}. These processes suffer from two pitfalls: 1) it requires the use of all the data in the set due to concerns regarding bias and undergoes cross-validation to compensate and 2) it does not provide an understanding of how robust the model is in the face of a case of varying classification difficulty.\\
Item response theory (IRT) is synonymous with modern test theory. Within this field questions administered to students on exams are scored either 'correct' or 'incorrect', binarizing the data. The pattern of responses for any given question are used to develop logistic regression curves that delineate the difficulty of the question posed and subsequently the latent ability of an examinee for a given question \cite{Embretson_2000}. IRT models based on 0 or 1 outcome data are referred to as dichotomous IRT models which include one-, two- and three-parameter models. The one-parameter logistic model (1PL) has only one characteristic often referred to as the difficulty, denoted with \textit{b} \cite{Rasch_1960}. The b-characteristic is scaled using the normal distribution. Questions (items) with higher \textit{b} values require more information or a higher latent ability to get correct and score '1'. Contrast this with polytonomous IRT models \cite{Samejima_1969} which allow for non-binary outcomes referred to as a graded response models where false dichotomies are generated that collapse feature options (1, 2, 3, 4 for a 4 outcome variable which can be continuous or categorical) into two groups at various stages along the value continuum. Both dichotomous and polytonomous IRT models can be extended into the machine learning literature where we can think of individual cases as students taking exams and liken the predictor variables to the questions posed creating cut points for right and wrong and will be showcased here.\\
The purpose of this study was to capitalize on integrating IRT and Computer Adaptive Testing (CAT) with machine learning. IRT provides estimates of case difficulty. CAT is normally used to present items of varying difficulty to test takers, and programs have been written to automate the CAT process \cite{Mengehetti}; however, we presented cases of varying difficulty, in terms of their ease of classification determined a-priori and classification independent, within a machine learning environment. We compared the results of a traditional machine learning training/testing approach with our approach.\\
IRT has been used in machine learning environments to select features that have characteristics contributing to classifying cases \cite{Kline_features}. It has also been shown to be useful in identifying case classification difficulty \cite{Kline_JMIR}. Case difficulty refers to the level of difficulty a supervised machine learning classification model will have in correctly classifying the case. The focus of the current research is to extend the use of the case classification difficulty parameters that are estimated as part of the IRT analyses. While these difficulty parameters are often called person-theta values ($\theta$) in traditional IRT contexts, in the current study we will refer to them as Case Difficulty Indices (CDIs). CDI values for a sample of cases that have been IRT analyzed based on a number of features are normally distributed with a mean of 0 and standard deviation of 1.0. Thus, most CDIs range between -2.50 and +2.50.
The CDI results allow for the identification of which cases are more centrally and more peripherally located on the difficulty distribution. Assuming a binary classification model, cases that are more centrally located are more difficult to classify into their respective categories, while those at the periphery are easier \cite{Kline_JMIR}. This phenomenon is shown in Fig. 1, where the probability of correct classification for those cases who are in class 2, gets progressively better as estimated CDI values become higher, and progressively worse as estimated CDI values become lower. Conversely, for those cases in class 1, the probability of correct classification gets progressively worse as CDI estimates become higher, and progressively better as estimated CDI values become lower.\\
\begin{figure}[!h]
\centering
\includegraphics[width=7cm]{Figures/CDI_accuracy_theory.png}
\caption{Probability of correct classification vs. CDI score for each class}
\end{figure}
Because the CDI estimates are based on the normal distribution, scores below the mean of 0.0 have negative (low) values and those above the mean have positive (higher) values. Thus, one of the classes of cases must have their CDI values multiplied by -1 (to obtain the additive inverse of the values) to assure comparable interpretation for both classes when graphing the data and later for administration of a CAT.\\
Also capitalizing on the a-priori case difficulty information, we can take advantage of an adaptive approach to machine learning model evaluation. That is, rather than allowing the machine learning model to randomly select cases as input for classification testing, we take a more theory-driven approach and guide the machine to self-select from cases at specified CDI levels. This novel approach will provide a unique metric, the Machine Learning Capability (MLC), by which to evaluate the utility of the machine learning model and information about the data set itself.\\
To execute this process, we draw on the principles of Computer Adaptive Testing (CAT) for guidance, as this is a long-standing methodology developed for ascertaining a test-taker's innate ability. CAT was developed to provide a precise and efficient estimate of a test-taker’s ability \cite{Lord}. CAT begins with the creation of a population of items with known characteristics (such as level of difficulty). The principle of applying CAT works as follows: 1) a question of intermediate difficulty is offered first to the test taker; 2) the test taker gets the item correct or incorrect; 3) If an incorrect response is made, the next item presented will be easier; 4) If a correct response is made, the next item presented will be more difficult; 5) This process continues iteratively, initially making larger steps between levels of difficulty and then smaller and smaller steps between item difficulty levels; and 6) Stopping criteria are invoked to end the process.\\
An overview of CAT Methodology is shown in Fig. 2. An initial estimation of the latent ability of the test taker is provided to start the process. When administering the CAT in machine learning, there is an expected monotonic progression in the probability of incorrectly classifying the case as CDI values increase \cite{Kingsbury}.
\begin{figure}[ht]
\centering
\includegraphics[width=8cm]{Figures/Cat_overview.png}
\caption{Overview of Computer Adaptive Testing (CAT) Methodology}
\end{figure}
We employed a CAT-based evaluation of machine learning models by using cases, rather than test items, as the input. In particular, the relative difficulty levels of the cases and how the machine learning models performed on them was the focus of this research.
The model evaluation criteria included time allocated to the evaluation, the number of cases needed to ascertain an estimate of the model’s classification performance, the MLC metric that incorporates how robust the model is when presented with easy and difficult cases. \\
\section{Methods}
We deliberately used two quite different datasets to demonstrate this process. One was a health-related data set, the Medical Information Mart for Intensive Care III (MIMIC-III). This set contains numerous features modestly related to the class outcome (in-hospital mortality). The other was a physical science data, the Predicting Pulsar Star data set obtained from the UCI Machine Learning Repository. This set has only a few features but they are strongly related to the class outcome. Doing so showcased how such differences play out in machine learning models but are not explicit using traditional evaluation metrics. \\
We also deliberately created balanced data sets. This is because we wanted to ascertain the intrinsic ability of the classifier with respect to class without biasing it. \\
\subsection{MIMIC Data Set}
The MIMIC-III database houses health data of over 40,000 critical care unit patients at the Beth Israel Deaconess Medical Centre between 2001-2012 \cite{Johnson} \cite{Johnson_2017}. The database was queried using SQL plug-in for Python. Case inclusion criteria were: 1) age of 16 years or older; and 2) and at least 3/4 of the features of interest available for a select case (patient), leading to subsequent imputation. There were 4039 cases over the age of 16 that experienced ‘death in hospital.’ From the remaining ‘no death in hospital’ data a random sample was selected equivalent to the number that died to give a final balanced sample size of 8,078. This data set was used previously \cite{Kline_JMIR} to demonstrate how classifiers deal with different levels of cased difficulty. \\
\subsubsection{MIMIC Features}
Features of predictive interest for the machine learning model were selected based on the SAPS II (simplified acute physiology) score \cite{LeGall} and are shown in Table 1. They included demographic, procedural, pre-existing conditions, and laboratory values. Laboratory values represent the worst-values taken during the ICU stay. \\
To prepare the data for a dichotomous IRT analysis, all features were coded into disease promoting (1) or disease protective (0) states. Lab values falling outside of the normal ranges were coded with a 1 (too low or too high), disease presence (e.g. Metastatic cancer) was coded with a 1, age was demarcated based on those above 65 who were allocated with 1 \cite{Fuchs}\cite{Lindemark}\cite{Alam}\cite{Atramont}, men were assigned 1 \cite{Mahmood}, and those that entered under emergency were coded 1. Normal values were obtained from several sources \cite{MedicalCouncil}\cite{Teasdale_1974}\cite{Teasdale_1976}\cite{Ichan} \cite{Lapum}\cite{MDCalc}\cite{Healthline}.
\begin{table}[ht]
\caption{MIMIC Variables - Based on SAPSII}
\label{table_example}
\centering
\begin{tabular}{|c||c|}
\hline
Feature & Healthy normal = 0\\
\hline
AIDS & Absent = 0, Present = 1\\
Heme Malignancy & Absent = 0, Present = 1\\
Metastatic Cancer & Absent = 0, Present = 1\\
Glasgow coma scale (1-15) & 15 = 0, $\leq$ 14 = 1\\
WBC Minimum ($*10^9$/L) & 4-10 = 0\\
WBC Maximum ($*10^9$/L) & 4-10 = 0\\
Na Minimum (mmol/L)& 135-145 = 0\\
Na Maximum (mmol/L)& 135-145 = 0\\
K Minimum (mmol/L)& 3.5-5 = 0\\
K Maximum (mmol/L) & 3.5-5 = 0\\
Bili Maximum (mg/dL)& $\leq$ 1.52 = 0\\
HCO$_3$ Minimum (mmol/L) & 24-30 = 0\\
HCO$_3$ Maximum (mmol/L)& 24-30 = 0\\
BUN Minimum (mg/dL)& 7-22 = 0\\
BUN Maximum (mg/dL)& 7-22 = 0\\
PO$_2$ (mmHg)& 85-105 = 0\\
FiO$_2$ (\%) & 21 = 0, $\leq$ 21 = 1\\
Mean heart rate (bpm) & 60-100 = 0\\
Mean systolic blood pressure (mmHg) & 95-145 = 0\\
Maximum temperature ($^{\circ}$C) & 36.5-37.5 = 0\\
Urine Output (mL/24h)& 800-2000 = 0\\
Sex (M/F) & M=1, F=0\\
Age (yrs) & $\leq$ 65 = 0, $>$ 65 = 1\\
Admission type & Emergency = 1, else = 0 \\
\hline
\end{tabular}
\end{table}
\subsection{Pulsar Data}
Pulsars are a rare type of Neutron star that produce detectable radio emissions. They are of scientific interest as probes of space-time, the inter-stellar medium, and states of matter. Because of the rarity of pulsar stars, detecting the broadband radio emission signature generated by a true pulsar from other-generated broadband signatures is an important classification task.\\
The Predicting Pulsar Star data set (N=17898), obtained from the UCI Machine Learning Repository (N=17898) \cite{Dua}\cite{Lyon_2017}\cite{Lyon_2016} was used in this study. Of the total cases, 1639 (9.2\%) were pulsars and 16259 (90.8\%) were not. A balanced data set was created by selecting a random sample of 1639 cases from the non-pulsar stars, providing a final sample size of 3278.\\
\subsubsection{Pulsar Features}
Four features were used from the data set. They are continuous variables obtained from the integrated pulse profile that describe a longitude-resolved version of the signal averaged in both time and frequency. They include the Mean, Standard Deviation, Excess Kurtosis, and Skewness of the integrated profile. Because of the relationships between the features and classification, the mean and standard deviation scores were inverted (multiplied by -1) \cite{Mir}, rendering all features monotonically and positively related to the classification categories of pulsar =1/non-pulsar = 0. To prepare the data for a polytomous IRT analysis, the continuous data of the four predictors were divided into their respective quartiles coinciding with 0-25\%, 25-50\%, 50-75\% and 75-100\% (Table 2).
\begin{table*}[ht]
\caption{Pulsar Feature Cutpoints for the Integrated Profile}
\centering
\begin{tabular}{|c||c|c|c|c|}
\hline
Quartile & Mean & Standard Deviation & Kurtosis & Skew\\
\hline
0-25\% (1) & Lowest to -118.42383 & Lowest to -49.051276 & Lowest to .176350204 & Lowest to .082984570\\
26-50\% (2) & -118.42384 to -95.382813 & -49.051277 to -43.567262 & .176350205 to .633206915 & .082984571 to 1.31210544\\
51-75\% (3) & -95.382814 to -54.195313 & -43.567263 to -36.387227 & .633206916 to 2.96592054 & 1.31210545 to 11.6310510\\
76-100\% (4) & -54.195314 to Highest & -36.387228 to Highest & 2.96592055 to Highest & 11.6310511 to Highest\\
\hline
\end{tabular}
\end{table*}
\subsection{IRT Analyses}
IRTPRO\cite{Cai} was used to obtain the difficulty and discrimination characteristics of the predictor variables which subsequently underpins the scoring system of case difficulties in each of the data sets. These calculated predictor variable characteristics combined with each case’s scores on the features provide a pattern of responding that allows for unique overall scoring for each case.\\
\subsubsection{IRT Feature Analysis}
The MIMIC predictor data were encoded to binary (0,1) in accordance with the normal value cut points mentioned previously. Thus, a 2-parameter logistic marginal maximum likelihood model was used to determine the difficulty ($\beta_i$) and discrimination parameters ($\alpha_i$)\cite{Bock_1981} for each predictor variable/item. This is shown in the logistic curve as per Eq. 1. $X_{is}$ is the response of the person/case instance ($s$) to the specific item/predictive variable '$i$' (0 or 1), $\beta_i$ the difficulty of item $i$ (location of the inflection on the x-axis) and $\alpha_i$ the discrimination or slope of the item. This is visually demonstrated in Figure 3.
\begin{figure}[ht]
\centering
\includegraphics[width=7cm]{Figures/sigmoid_curve.png}
\caption{Example of an item characteristic curve in 2-PL model}
\end{figure}
\begin{equation}
P(X_{is}=1|\theta_s,\beta_i,\alpha_i) = \frac{\exp[\alpha_i(\theta_s - \beta_i)]}{1 + \exp[\alpha_i(\theta_s - \beta_i)]}
\end{equation}
The Pulsar data were continuous and separated into 4 quartile based categories (0,1,2,3) as this set of predictor variables can be characterized as ordered categorical responses. Thus, a polytomous maximum likelihood graded response model \cite{Samejima_1969}, \cite{Samejima_1972}, \cite{Penfield} was used to determine the difficulty and discrimination parameters of the predictors for each of the 4 categories. In a graded response model, each item/predictive feature is described by a common item slope parameter ($\alpha_i$) and one between category threshold $\beta_{ij}$) where $j=1,..m_i$, and $m_i+1$ is equal to the number of response categories within an item/predictor, where each category can now be resembled by a 2-PL model. Computing the conditional probability for each case responding to a particular category requires a two-step process. 1) Computation of ($m_i$) distinct curves for each item (Eq. 2), and 2) computing the actual category response probabilities for $x = 0,1,2,3$ by subtraction of all categories of greater value (Eq. 3).
\begin{equation}
P_{ix}^*(\theta_s) = \frac{\exp[\alpha_i(\theta_s - \beta_ij)]}{1 + \exp[\alpha_i(\theta_s - \beta_ij)]}
\end{equation}
\begin{equation}
P_{ix}^*(\theta_s) = P_{ix}^*(\theta_s) - P_{i(x+1)}^*(\theta_s)
\end{equation}
\begin{figure}[ht]
\centering
\includegraphics[width=7cm]{Figures/multi_curve.png}
\caption{Example of an item characteristic curves in polytonomous model}
\end{figure}
\subsubsection{IRT Case Difficulty Index (CDI) Analysis}
Case difficulty indices (CDI) are synonymous with the latent case based ability (referred to as $\theta$ throughout these equations. This distinction is required given the classification nature of a machine learning problem and how it differs from psychometric testing usage. Additionally it has been cited in the literature previously \cite{Kline_JMIR}.\\
CDIs are calculated using a maximum likelihood estimation. Each case provides 'responses' to questions (predictor variables) with each response being either correct or incorrect (as converted previously based on normal values or scale). Therefore, the probability that a case with CDI ($\theta$) level obtains a given response on that variable can be computed. The probability that a case with CDI ($\theta$) obtains a response $U_i$ on item $i$ where $U_i$ = 0 if incorrect and $U_i$ = 1 if correct is denoted by $P(U_i | \theta)$. In a correct response ie. $P(U_i=1| \theta)$ this can be denoted $P_i(\theta)$, and as $U_i$ is a binomial variable this relationship can be expressed as:
\begin{equation}
P(U_i | \theta) = P_i^{U_i}(1-P_i)^{1-U_i}
\end{equation}
\begin{equation}
P(U_i | \theta) = P_i^{U_i}Q_i^{1-U_i}
\end{equation}
The probability of the vector of responses provided can be given by Eq 6, and taking the natural log results in equation 7.
\begin{equation}
P(U_i | \theta) = \prod_{i=1}^{n}P_i^{u_i}Q_i^{1-u_i}
\end{equation}
\begin{equation}
L = log(P(U_i | \theta))
\end{equation}
The value of $\theta$ that maximizes the likelihood function L is $\hat{\theta}$ or latent ability/CDI:
\begin{equation}
\theta= \underset{\theta}{argmax}(L)
\end{equation}
It is the response pattern of a case to the items (predictor variables) parameters $\alpha$ and $\beta$ that ultimately offer placement of the case along the CDI continuum (alive-dead or non-pulsar-pulsar). Lower CDIs indicate the case is less likely to be either a dead case for the MIMIC data or a pulsar star for the Pulsar data. Conversely, higher CDIs indicate the case is more likely to be either a dead case for the MIMIC data or a pulsar star for the Pulsar data. As noted earlier, CDI scores typically range from -2.5 to + 2.5.\\
\subsection{Machine Learning, Computer Adaptive Testing and the Machine Learning Capability (MLC) Metric}
To compare the traditional machine learning evaluation paradigm to the one proposed in this research, the data were processed in two different ways.
\subsubsection{Traditional Machine Learning Analysis and Evaluation}
Machine learning and all subsequent analyses were performed in a Python 3.7 environment. Using a traditional approach, both datasets underwent training on a neural network. To obtain the traditional evaluation metrics we split the data in a random 70-30 train-test split for use in ascertaining hyperparameters, where 70\% was used in development. Hyperparameters were selected using a grid search for learning rate, activation function and number of neurons in the hidden layer. The grid investigated for the neural network included activation functions such as softmax, softplus, softsign, relu, Tanh, sigmoid, and hard sigmoid; learning rates such as 0.01, 0.1, 0.2, and 0.3; and hidden neurons
of 6, 8, 12, 18, 24, and 30. Within this hyperperparameter tuning approach, the 70\% dataset underwent a 5 fold cross-validation and model evaluation was performed using the traditional metrics AUC, recall, accuracy and F1. Following this the same metrics were calculated based on the 30\% hold out model naive test set.\\
\subsubsection{Machine Learning Analysis Evaluated Via CAT}
The CDI values from each data set were placed on a their respective continua. Then CDI scores were ‘binned’ in increments of 0.25$\sigma$ intervals centered at zero. Cases in each of the bins were randomly split into 70-30 (train-test). This was done to assure that there was a stratified random sampling based on case difficulty used to train the model. Bins with a very small number of cases ($\leq$2) were either split in half for training/testing if there were only two cases in the bin or assigned to the training set if there was only one case in the bin. The same hyperparameters as those from the traditional approach were used to ascertain the hyperparameters of this model. This model did not use the 30\% test sample to generate traditional metrics. Instead, once the neural network model was trained on the 70\% training cases, the CAT procedure was initiated.\\
Thus, the CAT evaluations were based on the 30\% test cases that had been ‘binned’. This was done so that is was possible to present increasingly difficult or easier cases to the model to which the model was naive. Two sets of CAT analyses were conducted for each of the two data sets (MIMIC and Pulsar), as each class of data was run separately within the CAT framework. Class 1 included the ‘dead’ cases in the MIMIC and ‘pulsar’ cases in the Pulsar data sets. Class 2 included the ‘alive’ cases in the MIMIC and ‘non-pulsar’ cases in the Pulsar data set. Each of these four classes underwent separate CAT evaluation protocols.
One of the classes must have their CDI values multiplied by -1 (to obtain the additive inverse of the values) to assure comparable interpretation for both classes administrating the CAT. This ensures a unidirectional representation of difficulty. Thus, the class 1 data (‘dead’ in the MIMIC dataset and ‘pulsar star’ in the Pulsar dataset) were multiplied by -1 to ensure comparable CDI values across class. Figure 3 shows the inversion of scores from Fig. 1 for the class 1 CDI scores. \\
\begin{figure}[ht]
\centering
\includegraphics[width=7cm]{Figures/CDI_after_flip.png}
\caption{Probability of correct classification vs. CDI score for each class}
\end{figure}
We then presented a case from each class with CDI values closest to their 25th percentile to initialize the algorithm for each class. Cases from each class were then presented for classification to the algorithm one at a time, based on their CDI value, which was dependent on whether the algorithm correctly or incorrectly classified the prior case. The evaluation process stored the: 1) total number of cases queried in increments of 1 after each case is 'presented for classification' by the algorithm, 2) number of correct and incorrect classifications and 3) cumulative sum of the CDIs presented. \\
Case presentation was performed in a step-wise fashion \cite{Wright} using a simple algorithm particularly useful in a Rasch IRT model \cite{Mead} - which characterizes our case-difficulty data - and the purpose is to classify \cite{Linacre}. In the event the case was correctly classified, Eq. 6 is used. If it is incorrectly classified equation Eq. 7 is used, where L denotes the number of cases presented to that point, and G is the addition of Gaussian randomness inserted into the increment but whose standard deviation is within the prescribed stopping criteria estimate. We added this to introduce some randomness into the next estimate of ability to avoid a local minimum.
\begin{equation}
CDI_{t+1} = CDI_t + \frac{2}{2^L} + N(0,0.1)
\end{equation}
\begin{equation}
CDI_{t+1} = CDI_t - \frac{2}{2^L} + N(0,0.1)
\end{equation}
The criterion for when the testing process ends is synonymous with the stopping rule. Typically, this is either after a certain number of test items have been administered (fixed-length) or after a specified precision of the estimator has been reached (variable length). A variable length stopping criteria was used (standard error of the measure), seen in Eq. 8 below. Where $SE_M$ denotes the standard error of the measure, and $r$ is the reliability of the measure that is set by the user at outset. For our purposes $\sigma$ = 1, as the CDI values have already been normalized ($\mu$ = 0; $\sigma$ = 1) and it was determined that we wanted a reliability of 0.98 for our $SE_M$. The smaller the $SE_M$ the more cases it will take to solve, but the more reliable the result. Utilizing these restrictions the $SE_M$ was determined to be 0.14. The standard error of the measure was calculated on each iteration and if less than the value set by the user, the process will terminate.
\begin{equation}
SE_M = \sigma\sqrt{1-r}
\end{equation}
We have termed the metric associated with the capability of the supervised algorithm as the Machine Learning Capability (MLC). Recall that the CAT ends when the highly reliable highest difficulty is reached. Thus, this new metric indicates the case difficulty level at which the machine learning model terminates. It is calculated for each class, offering the user an understanding of the capability of the model for each. Computational efficiency was calculated as the total time it took for each case to be processed through the network.\\
Estimation of the MLCs for each class is calculated by Eq. 9. The code was written so it only becomes eligible to be calculated after a minimum of five cases have been used and is updated iteratively in a loop. Modified versions of Eq. 9 were used if the total number of right or wrong cases were equal to zero (Eq. 10 and Eq. 11, respectively). Where $H$ is the summed difficulty of cases asked, $L$ the number of cases used, $R$ the number of cases correctly classified and $W$ the number of cases incorrectly classified.
\begin{equation}
MLC = H/L + \ln(\frac{R}{W})
\end{equation}
\begin{equation}
MLC = H/L + \ln(\frac{R+0.5}{W-0.5})
\end{equation}
\begin{equation}
MLC = H/L + \ln(\frac{R-0.5}{W+0.5})
\end{equation}
Table 3 summarizes the CAT information used for coding the process where CDI$_0$ is the initial starting estimate of ability (25th percentile).
\begin{table}[!h]
\caption{Summary of CAT Information}
\centering
\begin{tabular}{ |p{2cm}||p{3cm}|p{2cm}| }
\hline
Component & Parameters & Returns\\
\hline
Initializer & 25th percentile item & CDI$_0$ \\
\hline
Selector & Item bank, administered items, CDI$_t$, & Index of next item\\
\hline
Estimator & item bank, CDI$_t$, administered items, response vector & CDI$_{t+1}$\\
\hline
Stopper & administered items, SE$_M$ & True or False\\
\hline
\end{tabular}
\end{table}
Conventional and the novel MLC metric were timed in their computational efficiency while 'administering' cases and reported below. For completeness sake these were run on an Intel\textsuperscript{\tiny\textregistered} Core\textsuperscript{\tiny\texttrademark} i7-8565U CPU at 1.80GHz with 16GB RAM.
\section{Results}
\subsection{Descriptive Results}
Distributions of the original CDI values for each dataset are shown in Fig. 4 and 5. In the frequency distributions, the data are shown in their 0.25$\theta$ width ‘bins’. The violin plots show the probability density functions of the data at each point by class. These plots indicate that the data are more separable in the Pulsar dataset compared to the MIMIC.
\begin{figure*}[!h]
\centering
\includegraphics[width=14cm]{Figures/MIMIC_dist.png}
\caption{MIMIC CDI distributions cumulatively (a) and by class (b)}
\end{figure*}
\begin{figure*}[!h]
\centering
\includegraphics[width=14cm]{Figures/Pulsar_dist.png}
\caption{Pulsar CDI distributions cumulatively (a) and by class (b)}
\end{figure*}
The CDI distributions for each class can be plotted against one another in a kernel density estimate (KDE) based on their actual class (1 versus 2) and the difficulty anticipated in assigning each case to its correct class. The class 1 data (‘dead’ in the MIMIC dataset and ‘pulsar star’ in the Pulsar dataset) were multiplied by -1 to ensure comparable CDI values across class. Using KDE plots, the distributions of these revised two datasets can be observed in Fig. 6. These provide an alternative visualization of the data that are presented in the violin plots. However, in the KDE plots the data for each class now have comparable ‘low’ and ‘high’ CDI values by virtue of having multiplied class 1 values by -1.
\begin{figure*}[!h]
\centering
\includegraphics[width=14cm]{Figures/kde_both.png}
\caption{KDE of difficulty contained within the set corresponding to each outcome class: a) MIMIC, b) Pulsar.}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[width=14cm]{Figures/monotonicity_data.png}
\caption{Monotonicity of accuracy for MIMIC (a) and Pulsar (b) datasets}
\end{figure*}
\begin{table*}[!h]
\caption{MIMIC mortality - Evaluation Metrics}
\centering
\begin{tabular}{|c||c|c|c|c|}
\hline
Metric & Value & Data required (no.) & Comp. time (s) & Difficulty Adjusted\\
\hline
Accuracy & 0.761 & 100\% (8078) & 0.520 & No \\
\hline
Precision & 0.756 & 100\% (8078) & 0.548 & No \\
\hline
Recall & 0.796 & 100\% (8078) & 0.389 & No\\
\hline
F1 & 0.752 & 100\% (8078) & 0.555 & No\\
\hline
AUC & 0.756 & 100\% (8078) & 0.66 & No\\
\hline
MLC (died) & 0.43 & 0.21\% (17) & 0.011\ & Yes\\
\hline
MLC (lived) & 0.78 & 0.22\% (19) & 0.021 & Yes\\
\hline
\end{tabular}
\end{table*}
\begin{table*}[!h]
\caption{Pulsar star - Evaluation Metrics}
\centering
\begin{tabular}{|c||c|c|c|c|}
\hline
Metric & Value & Data required (no.)& Comp. time (s) & Difficulty Adjusted\\
\hline
Accuracy & 0.92 & 100\% (3278) & 0.34 & No\\
\hline
Precision & 0.967 & 100\% (3278)& 0.33 & No \\
\hline
Recall & 0.880 & 100\% (3278) & 0.29 & No\\
\hline
F1 & 0.922 & 100\% (3278) & 0.31 & No\\
\hline
AUC & 0.926 & 100\% (3278) & 0.32 & No\\
\hline
MLC (pulsar) & 0.12 & 0.55\% (18) & 0.019 & Yes\\
\hline
MLC (non-pulsar) & 0.32 &0.52\% (17) & 0.013 & Yes\\
\hline
\end{tabular}
\end{table*}
\begin{figure*}[!h]
\centering
\includegraphics[width=14cm]{Figures/MIMIC_Pulsar_CAT.png}
\caption{Computer adaptive testing evaluation of each test}
\end{figure*}
It is noticeable from the KDE plots that the overall difficulty of the MIMIC data is higher relative to the Pulsar data. Most of the cases have CDI scores less than 0.0 in the Pulsar set, while many are much higher in the MIMIC set. This means that there are going to be more cases in the MIMIC data that are likely to be classified into the incorrect class relative to the Pulsar set.\\
\subsection{Machine Learning, Computer Adaptive Testing (CAT), and Machine Learning Capacity (MLC) Results}
The initialization estimation values for the CAT for each class in the MIMIC dataset was: -0.955 (died) and -0.967 (lived). For the pulsar dataset: -1.17 (non-pulsar) and -1.47 (pulsar). These values correspond the CDI 25th percentile value for each class tested. The 25th percentile was selected to provide a relatively 'easy' case for classification. Fig. 7 confirms the monotonicity of the relationship between CDI scores and classification accuracy. This is relevant insofar as it substantiates that CDI scores are a valid way to assess case difficulty. This figure was generated by using the traditional machine learning evaluation metric of accuracy and plotting it against class (prior to inversion for CAT) and CDI.\\
Tables 4 and 5 show the traditional and MLC evaluation metrics on the two datasets. Of note, a column for computational time and whether or not difficulty was incorporated in the metric are additionally reported. The MIMIC data set shows solid classification with the model. Interestingly the MLC value for the cases that ‘died’ reached a CDI difficulty level of 0.43. This indicates the model was able to reliably correctly classify the ‘died’ cases with CDI scores almost a half standard deviation above the mean. The MLC value for the cases that were ‘alive’ reached a CDI difficulty level of 0.78. This indicates the model was able to reliably correctly classify the ‘alive’ cases with CDI scores more than 3/4 of a standard deviation above the mean.\\
The Pulsar data, on the other hand, showed excellent classification. The MLC values indicate that the model was able to reliably correctly classify ‘pulsar’ cases with CDI scores just above the mean, and non-pulsar cases with CDI scores about 1/3 a standard deviation above the mean.
It is also important to note the very small number of resources needed to ascertain the MLC values for all of the classes. Less than 1\% of the data were needed for these metrics to converge, and 5\% of the computing time of the traditional metrics.\\
Fig. 8 graphically represents how the MLC values are arrived at based on correct and incorrect responding in the CAT process. The level at which the MLC line asymptotes correspond to the level of case difficulty that can be reliably handled by the machine learning algorithm. Specifically, Fig. 8 b) in the 'non-pulsar' data hits a perfectly flat line as it has reached the maximum CDI contained within the Pulsar dataset for that class (0.34) as the ML algorithm is consistently getting these cases correct the selection process will continue to pose cases to the algorithm that are ideally more difficult but as our item selection is always limited by our CDI distribution in the dataset it will search the same vicinity until the $SE_M$ is reached.
Fig. 9 shows how the summary MLC values for each class can be reported in an (x, y) coordinate system. The x-axis corresponds to the MLC value for class 1 and the y-axis corresponds to the MLC value for class 2. The MLC values for the MIMIC classes (0.78 - alive, 0.43 - dead) and for the Pulsar classes (0.32 – non-pulsar, 0.12 - pulsar) indicate the maximum points at which the machine learning algorithm is capable of differentiating each class. Summarizing the combination of the characteristics of the data set and the machine learning algorithm used in this manner provides insight into the relative robustness of these two regarding their capability in handling difficult to classify cases. While the Pulsar traditional measures suggested an excellent model, this was primarily due to the type of data with which it was presented. The MIMIC traditional measures suggested more modest classification accuracies. However, this model was capable of handling more difficult cases relative to the Pulsar model.\\
\begin{figure}[!h]
\centering
\includegraphics[width=8cm]{Figures/MLC_mimic_pulsar.png}
\caption{Machine Learning Capability of Classifiers}
\end{figure}
\subsection{Practical Application of the Machine Learning Capability (MLC) Index}
These MLC values can now be used to assess whether or not a case should be classified based on the machine learning algorithm, or if the case characteristics exceed the limitations of the model. For example, assume a new patient comes into an intensive care unit (ICU) and their SAPSII data are inserted into the MIMIC-based machine learning algorithm generated in this research. The machine learning algorithm produces a class prediction (alive or dead) for that case. That patient’s SAPSII data will also be submitted to the IRT function with known feature parameters and thus a CDI score for the patient will be generated. \\
If the CDI score is within the maximum capability of the machine learning model, then we can be confident that the machine learning algorithm is able to classify that case. This confidence is bolstered because the reliability of the stopping criterion for the MLC values was set to be very high (0.98). If the CDI score is outside the maximum capability of the machine learning model, then the case should have an intervention, with a field expert.\\
Note that the CDI would need to be multiplied by -1 if the case was classified by the machine learning algorithm as ‘dead’ (class 1), as per the additive inversion that was necessary for the class 1 data CAT administration and the subsequent MLC metric. If the case was classified as ‘alive,’ there would be no need for the inversion before interpretation.
Continuing with the example, assume that the case had a CDI score of 0.80 and was classified as ‘alive’. Since the classification is associated with class 2, we would directly assess the CDI against the class 2 MLC value of 0.78 and observe that it exceeds this value. Thus, we would assume that the case was too difficult to be classified by the algorithm and would need input from other sources (e.g., physician) to make the classification call. This is demonstrated in Fig. 10.\\
Working through a second example, assume that the case had a score of 0.80, but was classified as ‘dead’. Since this classification is associated with class 1, we need to invert the score to be -0.80 before interpretation. Since this score is below the MLC value of 0.43, we would assume that the machine learning algorithm was correct in making the classification that this case is highly likely to die.\\
Similarly with the Pulsar data: Assume a star’s integrated profile value CDI score was 0.10 and classified as a non-pulsar. Since this value is below the class 2 critical MLC value for a non-pulsar star, it can be assumed to be correctly classified as such. On the other hand if it was classified as a pulsar (and thus the CDI score inverted to be -0.10), this exceeds the class 1 value of -0.12. Thus, the astronomer might look for other evidence for correct classification of this star.\\
Testing the cases with CDIs below the MLC in either dataset for each class we get an accuracy of 94.7\% percent for pulsar star and 96.8\% for non-pulsar star. In the MIMIC dataset we achieve 91\% in the lived class and 87.5\% in the died class.
\begin{figure*}[!h]
\centering
\includegraphics[width=14cm]{Figures/real-world-app.PNG}
\caption{Implementation of the MLC for real-world decision making}
\end{figure*}
\section{Discussion}
\subsection{General Findings}
The purpose of this research was to extend the use of CDI values generated from IRT models to assess the capability of a machine learning algorithm as it pertains to successful classification of difficult cases. This process led to the development and implementation of the MLC index. The MLC provides interesting and useful information to the end user.\\
First, it provides a summary index that integrates the performance of the machine learning algorithm with the uniqueness of the data set under investigation. This makes it possible to compare models as well as assess one’s own model. Second, it requires very little data - a benefit that many disciplines would find helpful particularly when users only have access to small datasets. Third, the CDI indices on which it is based are separate from the machine learning model. This avoids the circularity issue often run into where end-classification is used to assign weights to the features used in the algorithm. Fourth, although not usually a problem for many computer systems, the time taken to generate the MLC indices is much lower than for traditional machine learning evaluation metrics.
The practical application possibilities of the MLC are profound. If one knows the CDI value of a case, and one knows the upper limits of the capability of a machine learning algorithm, it is possible to determine whether or not the case should be reliably classified by the algorithm. We can now add the MLC metric to our ML-based decision making repertoire to suggest the point at which humans need to intervene in case assessment. Up to the MLC, the practitioner can be confident that the algorithm will perform in a valid and reliable manner. \\
This approach demands a strong machine learning protocol be designed and precise CDI information for the case be ascertained. Use of such a methodology should be undertaken only with a solid understanding of the strengths and limitations of various machine learning models is imperative. The current and prior research suggests that the assessment of feature characteristics using IRT is a very valuable resource to set such CDI values as it provides robust estimates of the features’ characteristics when processed using a large number of cases \cite{Guilleux}. \\
Typically in a supervised machine learning problem data allocated to the 'test' category is anywhere between 10-30\% of the data. For which evaluations regarding specificity, sensitivity, recall, F1 and accuracy are calculated. The proposed method advocates for moving toward a single numeric per class outcome in supervised machine learning that takes into account case difficulty. Case difficulty is established independently of the classification performed by algorithms and as such remains an unbiased metric. As cases are normalized for difficulty in the dataset, the MLC represents both an ability metric in the more traditional sense of IRT literature and a cross-dataset metric.\\
Traditional machine learning model evaluation metrics are useful in that they provide an overall sense of the utility of a model on a data set. We are not advocating replacing them; instead we suggest that adding the MLC would provide complementary information to the investigator. This index provides a more nuanced understanding of which cases are difficult to classify and at what point they become so difficult that the machine learning algorithm requires additional input, such as a human expert. \\
As observed in the results, the Pulsar dataset was more separable and had a higher accuracy. But when bench-marked against the MIMIC dataset it was clear that this high accuracy was performing well due to the characteristics of the data set (i.e., specific cases and specific features), and not necessarily the capability of the machine learning model.\\
Using the MLC may be viewed as an evolving process when the CDI is not a static measure of a case's difficulty. This would occur when the predictor values are in flux (e.g., changing patient data over time). In such instances the CDI acts a temporally responsive metric and may change in a direction that demands thoughtful application for the continued use (if the CDI is below the MLC of model) or disuse (if the CDI is above the MLC of model) of the machine learning model as it pertains to a specific case at a given point in time. Following this logic, researchers and end users are encouraged to perform ad-hoc investigations into which features and their respective values are driving a given case to have a CDI that may exceed the limitations of the ML model. With this insight, attempts can be made to correct or target these predictor variables (if modifiable) with the goal of moving the case into an easier-to-classify state that would be within the capability of the MLC of the trained model. This easier classification state should be beneficial to both ML-based and human expert decision-making paradigms.\\
An understanding of when and why algorithms should be used to support human decision-making will facilitate their uptake and allow for the judicious expenditure of labor-intensive human resources. However, many ethical and legal issues surround real-world deployment of ML algorithms. Some of these include transparency, known or unknown biases, social benevolence, and privacy of information \cite{Vollmer}. Knowing a-priori that an individual case is well encapsulated within the limitations of the model is important to build trust with domain experts as well as address the issues that may arise in answer to the question ‘can/should this be handled by our ML model?’ The MLC metric devised here can address some of these concerns as the CDIs on which it is based are calculated independent of the actual ML models using analytics that are transparent, and any biases against race, gender, etc. can be assessed by way of IRT multi-group analyses. These possibilities are important to explore based on extant literature that suggests expected differences \cite{Vollmer}. Decisions are becoming more complex with the addition of new information regarding diagnostic tools, treatment options, possible side effects, human burnout, and cost effectiveness \cite{CIHR}. Maximizing ML and human resources while simultaneously engendering transparent insight should be a priority for industry and government stakeholders and the MLC framework’s utility as a decision-support system has wide-ranging implications.
\subsection{Future Research}
Several areas of future research suggest themselves from this study. We used a single mode of data (i.e., numeric) to showcase the MLC. However, incorporating multi-modal data into machine learning algorithms and IRT models would be an important next step in this research. The data in our sets had only two classification outcomes. We hypothesize that the MLC index process would extend well to multi-class outcome data. In addition, we used balanced data sets. With an imbalanced dataset, depending on the class that is imbalanced and what CDI values are contained within the additional cases, there may exist a higher MLC for that class. This would be particularly true if these case CDI values are close to zero or higher. This is an empirical question that can be answered in future research.\\
Though this process was demonstrated using neural networks, this method can be extended for use in all supervised machine learning models as well as multi-class outcomes.\\
The MLC index approach is anticipated to extend to areas of supervised machine learning where there is a need to determine the maximum capability of the algorithm, and where other knowledge (e.g., human) needs to be drawn upon. This is likely to be of interest in many fields where much effort has been focused and algorithms are compared to their human counterparts. Determining where the machine-human dividing line is located has, to this point, remained elusive. The MLC provides a step forward in attempting to solve this problem. A critical follow up to this research would be to trial this approach in a real-world setting and assess its anticipated performance.
\section{Conclusion}
The MLC index represents a reliable and novel way to evaluate and report in a standardized manner the classification performance of a supervised learning algorithm for each class of outcome. It is less reliant on the total number of correct versus incorrect classifications, and instead focuses on which ones are correct and which ones are incorrect. This measure uses far fewer data points, and is computationally more efficient. While a neural network was used as the example of traditional machine learning approach in the current research, the process is suitable for use in all supervised machine learning models and can also be extended to multi-class outcomes. The MLC index provides a metric by which the limitations of machine learning models can be ascertained, and thus at what point other interventions need to override the machine learning algorithm.
\ifCLASSOPTIONcompsoc
\section*{Acknowledgments}
\else
\section*{Acknowledgment}
\fi
The authors would like to thank MIT for the MIMIC database, the UCI repository for the Pulsar dataset utilized in this study and Dr. Theresa Kline for reviewing earlier versions of the manuscript.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
| {'timestamp': '2023-02-10T02:03:50', 'yymm': '2302', 'arxiv_id': '2302.04386', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04386'} | arxiv |
\section{Introduction}
Music is a high-level human art form whose combination of harmony, melody, and rhythm makes people feel happy and adjust their mood. Its rich contents can express one's feelings or emotions and even tell a story. In recent years, music generation has been a heated study with the development of deep learning techniques.
Some works~\cite{DBLP:journals/corr/abs-2211-11216} aim at studying symbolic music generation, which learns to predict a sequence composition of notes, pitch, and dynamic attributes. The generated symbolic music does not contain performance attributes; thus, post-processing work to synthesize the audio of the music is usually needed. On the other hand, some works~\cite{DBLP:journals/corr/abs-2208-08706} aim at studying generating audio or waveform music. It does not need extra work for synthesizing; however, the generated audio signals are usually more difficult to control to have satisfactory performance attributes.
Besides works on unconditional music generation, there have been some explorations about conditional music generation~\cite{DBLP:journals/corr/abs-2208-08706,DBLP:journals/corr/abs-2211-11248}, which aims to meet the application requirements in some scenarios, such as automatic video soundtrack creation and auxiliary music creation with specific genres or features. Generative models can leverage information from various modalities, such as text and image, to create relevant outputs for a conditional generation. In computer vision, works on conditional image generation have been widely studied. The amazing performance brought by these cutting-edge techniques has aroused wide-spread attention in the industry~\cite{DBLP:journals/corr/MirzaO14,DBLP:conf/nips/SohnLY15,DBLP:conf/icml/NicholDRSMMSC22,DBLP:conf/cvpr/RombachBLEO22}.
However, the problem of generating waveform music based on free-form text has yet to be well-researched. Similar to the need for video background music generation, creating music according to specific information from other modalities is also in wide demand, such as creating background music for Internet media articles. While there have been several pieces of research on text conditional music generation such as~\cite{DBLP:journals/corr/abs-2211-11216}, BUTTER~\cite{zhang2020butter} and Mubert\footnote{https://github.com/MubertAI/Mubert-Text-to-Music}, they are not able to directly generate musical audio based on free-form text. BUTTER~\cite{zhang2020butter} only receives limited keywords as text conditions and generates symbolic music scores that need further post-processing music synthesizing works. Though \cite{DBLP:journals/corr/abs-2211-11216} can process texts with richer forms, it is also a symbolic music generation work. The pieces of music from Mubert are all created by human musicians. When given specific text, the pieces of music are retrieved based on predetermined genre text labels and sequentially combined. It can only create limited music, and the transitions between different music segments are unnatural.
In order to overcome the shortcomings of these previous works, we propose ERNIE-Music, the first attempt at free-form text-to-music generation in the waveform domain using diffusion models. To solve the problem of lacking a large-amount parallel text-to-music dataset, we collect the data from the Internet by utilizing the ``comment voting'' mechanism. We apply conditional diffusion models to process musical waveforms to model the generative process and study which kind of text format benefits the model to learn text-music relevance better. As a result, the generated music samples are diverse and graceful flowing, which outperforms methods from related works by a large margin. To conclude, the contributions of this paper are:
1) We propose the first music generation model that receives free-form texts as the condition and generates waveform music based on the diffusion model;
2) We propose to solve the problem of lacking such free-form text-music parallel data by collecting data from the Internet by utilizing the comment voting mechanism;
3) We study and compare using two forms of texts to condition the generative model and proves that using free-form text obtains better text-music relevance;
4) The results show that our model can generate diverse and high-quality music with higher text-music relevance, which outperforms other methods by a large margin.
\section{Related Work}
\subsection{Symbolic vs. Audio}
Music representation is usually divided into two categories: symbolic representation and audio representation.
Symbolic representations are discrete variables and include many musical concepts such as pitch, duration, chords, etc. For example, the MIDI (Musical Instrument Digital Interface) is an industry-standard electronic communication protocol that defines notes and playing codes for electronic instruments and other playing devices. It allows electronic instruments, computers, mobile phones, and other electronic devices to connect, adjust and synchronize with each other to exchange performance information in real time. MIDI consists of an ordered sequence of MIDI events, each of which can control the start, end, duration, velocity, and instrument of musical notes. REMI~\cite{huang2020pop} uses the sequence model to learn MIDI-derived event representation to generate expressive piano music.
Audio representations are continuous variables that retain all music-related information and possess rich acoustic details, such as timbre, articulation, etc. Audio representations can be processed using a wide range of sophisticated audio signal processing techniques. For example, WaveNet~\cite{oord2016wavenet} and SampleRNN~\cite{mehri2016samplernn} employ original audio waveforms as model inputs.
\subsection{Controllable Music Generation}
The task of controlled music generation has been plagued by the central question of how to impose constraints on music. VQ-CPC~\cite{hadjeres2020vector} learns local music features that do not contain temporal information. \cite{DBLP:journals/corr/abs-2208-08706} uses tempo information as a condition to generate "techno" genre music. BUTTER~\cite{zhang2020butter} uses a natural language representation of the music key, meter, style, and other relevant attributes to control the generation of music. \cite{DBLP:journals/corr/abs-2211-11216} further explored the effect of different pre-training models in text-to-music generation. Mubert first computes the encoded representation of the input natural language and the music tags using Sentence-BERT~\cite{reimers2019sentence}. It selects the music tags closest to the input and generates a combination of sounds from the set of sounds corresponding to these music tags. All sounds are created by musicians and sound designers.
\subsection{Diffusion Models}
Diffusion models~\cite{DBLP:conf/icml/Sohl-DicksteinW15,DBLP:conf/nips/HoJA20} are latent variable models motivated by the non-equilibrium thermodynamics. They gradually destroy the structure of the original data distribution through an iterative forward diffusion process and then learn the reversal to reconstruct the original data by a finite iterative denoising process. In recent years, there has been an increased popularity of diffusion models in many areas, such as image generation~\cite{DBLP:conf/icml/NicholDRSMMSC22,DBLP:conf/nips/DhariwalN21,ramesh2022hierarchical} and audio generation~\cite{DBLP:conf/iclr/ChenZZWNC21,Kreuk2022AudioGenTG}. Our work is closely related to diffusion approaches for text-to-audio generation~\cite{DBLP:conf/iclr/ChenZZWNC21,Kreuk2022AudioGenTG}, which all generate audio waveforms but cope with different tasks. This work employs diffusion models to synthesize music waveforms given arbitrary textual prompts, while previous works focus on speech generation.
\section{Method}
In this section, we first introduce the backgrounds of diffusion models and then describe the text-conditional diffusion model we use, in addition to the model architecture and the training objectives.
\begin{figure*}[!htb]
\centering
\includegraphics[width=0.82 \textwidth]{model_v2.2.pdf}
\caption{The overall architecture. The original Chinese text is ``{\cn{钢琴旋律的弦音,轻轻地、温柔地倾诉心中的遐想、心中的爱恋}}''.}
\label{fig:model}
\end{figure*}
\subsection{Unconditional Diffusion Model}
Diffusion Models~\cite{DBLP:conf/icml/Sohl-DicksteinW15,DBLP:conf/nips/SongE19,DBLP:conf/nips/HoJA20} consist of a \textit{forward process} which iteratively adds noise to a data sample and a \textit{reverse process} which denoises a data sample by multiple times to generate a sample that conforms to real data distribution. We adopt the diffusion model defined with continuous time~\cite{DBLP:journals/corr/abs-2107-00630,DBLP:journals/corr/abs-1905-09883,DBLP:conf/iclr/ChenZZWNC21,DBLP:conf/iclr/0011SKKEP21,DBLP:conf/iclr/SalimansH22}.
Consider a data sample $x$ from distribution $p(x)$; diffusion models leverage latent variables $z_t$ where $t \in \mathbb{R}$ ranges from $0$ to $1$. The log signal-to-noise-ratio $\lambda_t$ is defined as $\lambda_t={\rm log}[\alpha_t^2/\sigma_t^2]$, where $\alpha_t$ and $\sigma_t$ denote the noise schedule.
For the \textit{forward process} or \textit{diffusion process}, Gaussian noise is added to the sample iteratively, which satisfies a Markov chain:
\begin{align}
q(z_t|x)&=\mathcal N (z_t;\alpha_t x, \sigma_t^2 \textbf{I}) \nonumber \\
q(z_{t'}|z_t) &= \mathcal N (z_{t'};(\alpha_{t'}/\alpha_t)z_t, \sigma_{t'|t}^2 \textbf{I}) \nonumber
\end{align}
where $t,t' \in [0,1]$ and $t<t'$, and $\sigma_{t'|t}^2=(1-e^{\lambda_{t'}-\lambda_t})\sigma_{t'}^2$.
In the \textit{reverse process}, a function approximation with parameters $\theta$ (denoted as $\hat{x}_\theta(z_t, \lambda_t, t) \approx x$) estimates the denoising procedure:
\begin{equation}
p_\theta(z_t|z_{t'}) = \mathcal{N} (z_t; \tilde{\mu}_{t|t'}(z_{t'}, x)), \tilde{\sigma}_{t|t'}^2\textbf{I}) \nonumber
\end{equation}
where $\tilde{\mu}_{t|t'}(z_{t'}, x, t')) = e^{\lambda_{t'}-\lambda_t}(\alpha_t/\alpha_{t'})z_{t'} + (1-e^{\lambda_{t'}-\lambda_t})\alpha_t x$. Starting from $z_1 \sim \mathcal{N}(0,\textbf{I})$, by applying the denoising procedure on the latent variables $z_t$, $z_0 = \hat{x}$ can be generated at the end of \textit{reverse process}. To train the denoising model $\hat{x}_\theta(z_t, \lambda_t, t)$, without loss of generality, the weighted mean squared error loss is adopted:
\begin{equation}\label{eqation_loss}
L = E_{t \sim [0,1], \epsilon \sim \mathcal{N} (0,\textbf{I})}[w(\lambda_t) \lVert \hat{x}_\theta(z_t, \lambda_t, t)-x \rVert _2^2]
\end{equation}
where $w(\lambda_t)$ denotes the weighting function and $\epsilon \sim \mathcal{N} (0,\textbf{I})$ denotes the noise.
\subsection{Conditional Diffusion Model}
Many works successfully implement generative models with conditional settings~\cite{DBLP:journals/corr/MirzaO14,DBLP:conf/nips/SohnLY15,DBLP:conf/cvpr/RombachBLEO22}. Conditional diffusion models approximate distribution $p(x|y)$ instead of $p(x)$ by modeling the denoising process $\hat{x}_\theta(z_t, \lambda_t, t, y)$, where $y$ denotes the condition. $y$ can be any type of modality such as image, text, and audio. Specifically, in our text-to-music generation scenario, $y$ is a text prompt to guide the model to generate related music. We discuss the details of modeling the conditional diffusion model in the following sections.
\subsubsection{Model Architecture}\label{timestep_condition}
For text-to-music generation, the condition $y$ for the diffusion process is text. As shown in Figure \ref{fig:model}, our overall model architecture contains a conditional music diffusion model which models the predicted \textit{velocity} $\hat{v}_\theta(z_t, t, y)$~\cite{DBLP:conf/iclr/SalimansH22}, and a text encoder ${\rm E}(\cdot)$ which maps text tokens with length $n$ into a sequence of vector representations $[ s_0; S] $ with dimension $d_E$, where $S=[ s_1, ..., s_n] $, and $s_i \in \mathbb{R}^{d_E}$, and $s_0$ is the classification representation of the text.
The inputs of the music diffusion model are latent variable $z_t \in \mathbb{R}^{d_c \times d_s}$, timestep $t$ (which is then transformed to the embedding $e_t \in \mathbb{R}^{d_t \times d_s}$), and the representation of text sequence $[ s_0; S] \in \mathbb{R}^{(n+1) \times d_E}$, where $d_c$ denotes the number of the channels, $d_s$ denotes the sample size, $d_t$ denotes the feature size of the timestep embedding. The output is the estimated \textit{velocity} $\hat{v}_t \in \mathbb{R}^{d_c \times d_s} $.
Inspired by previous works about latent diffusion models~\cite{DBLP:conf/icml/NicholDRSMMSC22,DBLP:conf/cvpr/RombachBLEO22,DBLP:conf/nips/DhariwalN21}, we adopt the architecture of UNet~\cite{DBLP:conf/miccai/RonnebergerFB15} whose key components are stacked convolutional blocks and self-attention blocks~\cite{DBLP:conf/nips/VaswaniSPUJGKP17}. Generation models can estimate the conditional distribution $p(x|y)$, and the conditional information $y$ can be fused into the generative models in many ways~\cite{DBLP:conf/nips/SohnLY15}.
Our diffusion network targets at predicting the latent velocity $\hat{v}_\theta$ at randomly sampled timestep $t$ given the noised latent $z_t$ and a textual input $[ s_0; S]$ as the condition. To introduce the condition into the diffusion process, we perform an fusing operation ${\rm Fuse}(\cdot, \cdot)$ on the timestep embedding $e_t$ and the text classification representation $s_0$ to obtain the text-aware timestep embedding ${e'}_t = {\rm Fuse}(e_t, s_0) \in \mathbb{R}^{d_{t'} \times d_s} $. Then it is concatenated with $z_t$ to obtain $z'_t = (z_t \oplus {e'}_t) \in \mathbb{R} ^{(d_{t'}+d_c)\times d_s}$. We omit the operations about the timestep embedding in Figure~\ref{fig:model} for simplicity. In the following Section \ref{compare_fuse}, we compare the performance of the different implementations of the fusing operation ${\rm Fuse}(\cdot, \cdot)$.
Moreover, we introduce the conditional representation into the self-attention blocks~\cite{DBLP:conf/nips/VaswaniSPUJGKP17}, which model the global information of the music signals. In the self-attention blocks, consider the intermediate representation of $z'_t \in \mathbb{R} ^{(d_t+d_c)\times d_s}$ is $\phi(z'_t) \in \mathbb{R}^{d_a \times d_\phi}$, and $S \in \mathbb{R}^{n \times d_E}$, the output is computed as follows:
\begin{equation}
{\rm Attention}(Q,K,V)={\rm softmax}(\frac{QK^T}{\sqrt{d_k}})V \nonumber
\end{equation}
\begin{equation}
{\rm head_i} = {\rm Attention}(Q_i, K_i, V_i) \nonumber
\end{equation}
\begin{equation}
Q_i = \phi(z'_t) \cdot W_i^Q \nonumber
\end{equation}
\begin{equation}
K_i = {\rm Concat}(\phi(z'_t) \cdot W_i^K,\, S \cdot W_i^{SK}) \nonumber
\end{equation}
\begin{equation}
V_i = {\rm Concat}(\phi(z'_t) \cdot W_i^V,\, S \cdot W_i^{SV}) \nonumber
\end{equation}
\begin{equation}
{\rm CSA}(\phi(z'_t),\,S)={\rm Concat}({\rm head_1}, ..., {\rm head_h})W^O \nonumber
\end{equation}
\noindent where $W_i^Q \in \mathbb{R}^{d_{\phi} \times d_q}$, $W_i^K \in \mathbb{R}^{d_{\phi} \times d_k}$, $W_i^V \in \mathbb{R}^{d_{\phi} \times d_v}$, $W_i^{SK} \in \mathbb{R}^{d_{E} \times d_k}$, $W_i^{SV} \in \mathbb{R}^{d_{E} \times d_v}$, $W^O \in \mathbb{R}^{hd_{v} \times d_{\phi}}$ are parameter matrices, and $h$ denotes the number of heads, and ${\rm CSA}(\cdot, \cdot)$ denotes the conditional self-attention operation.
\subsubsection{Training}
Following~\cite{DBLP:conf/iclr/SalimansH22}, we set the weighting function in equation~\ref{eqation_loss} as the ``SNR+1'' weighting for a more stable denoising process.
Specifically, for the noise schedule $\alpha_t$ and $\sigma_t$, we adopt the cosine schedule~\cite{DBLP:conf/icml/NicholD21} $\alpha_t={\rm cos}(\pi t / 2)$, $\sigma_t={\rm sin}(\pi t / 2)$, and the variance-preserving diffusion process satisfies $\alpha_t^2 + \sigma_t^2 = 1$.
We denote the function approximation as $\hat{v}_\theta(z_t, t, y)$, where $y$ denotes the condition. The prediction target of $\hat{v}_\theta(z_t, t, y)$ is \textit{velocity} $v_t \equiv \alpha_t \epsilon - \sigma_t x$, which gives $\hat{x}=\alpha_tz_t-\sigma_t \hat{v}_\theta(z_t, t, y)$. Finally, our training objective is:
\begin{align}
L_\theta &= (1+\alpha_t^2/\sigma_t^2) \lVert x-\hat{x}_t \rVert_2^2 \nonumber \\
&= \lVert v_t - \hat{v}_t \rVert _2^2 \nonumber
\end{align}
Algorithm \ref{alg:train} displays the complete training process with the diffusion objective proposed by \cite{DBLP:conf/iclr/SalimansH22}.
\begin{algorithm}
\caption{Training}\label{alg:train}
\begin{algorithmic}
\Repeat
\State $x \sim p(x \vert y)$
\State $t \sim \text{Uniform}([0, 1])$
\State $\epsilon \sim \mathcal{N}(\mathbf{0}, \mathbf{I})$
\State $v_t \gets \alpha_t \epsilon - \sigma_t x $
\State Take gradient step on
\State \hskip 2em $\nabla_\theta \Vert v_t - \hat{v}_\theta ( \alpha_t x + \sigma_t \epsilon , t, y) \Vert^2 $
\Until{converged}
\end{algorithmic}
\end{algorithm}
\section{Experiments}
In this section, we introduce some implementation details of our model and details of the training data and the specific evaluation methods. We compare the performance of the generated music among our model and methods from related works by manual evaluation. Finally, we analyze several features of our generated music and the factors that might affect the text-music relevance, such as different implementations of the fusing operation and different formats of the input text.
\begin{table}[h]\small
\renewcommand\arraystretch{1.2}
\centering
\caption{\label{tab:data_statistics} The statistics of our collected Web Music with Text dataset.}
\begin{tabular}{p{4cm}|p{1.5cm}|p{1.5cm}}
\hline
& Train & Test \\
\hline
Num. of Data Samples & 3890 & 204 \\
\hline
Avg. Text (Tokens) Length & 63.23 & 64.45 \\
\hline
Music Sample Rate & \multicolumn{2}{l}{16000} \\
\hline
Music Sample Size & \multicolumn{2}{l}{327680} \\
\hline
Music Duration & \multicolumn{2}{l}{20 seconds} \\
\hline
\end{tabular}
\end{table}
\subsection{Implementation Details}
Following previous works~\cite{DBLP:conf/cvpr/RombachBLEO22,DBLP:conf/icml/NicholDRSMMSC22,DBLP:conf/nips/HoJA20}, we use UNet~\cite{DBLP:conf/miccai/RonnebergerFB15} architecture for the diffusion model. The UNet model uses 14 layers of stacked convolutional blocks and attention blocks for the downsample and upsample module, with skipped connections between layers with the same hidden size. It uses the input/output channels of 512 for the first ten layers and two 256s and 128s afterward. We employ the attention at 16x16, 8x8, and 4x4 resolutions. The sample size and sample rate of the waveform are 327,680 and 16,000, and the channel size is 2. The timestep embedding layer contains trainable parameters of 8x1 shape. It concatenates the noise schedule to obtain the embedding, which is then expanded to the sample size to obtain $e_t \in \mathbb{R}^{16 \times 327,680} $. We train the model for 580,000 steps using Adam optimizers with a learning rate of 4e-5 and a training batch size of 96. We save exponential moving averaged model weights with a decay rate of 0.995, except for the first 25 epochs. For the text encoder ${\rm E}(\cdot)$, we use ERNIE-M~\cite{ouyang-etal-2021-ernie}, which can process multi-lingual texts.
\subsection{Dataset}
\begin{table}[h]\small
\renewcommand\arraystretch{1.5}
\centering
\caption{\label{tab:example_data} Examples of our Web Music with Text dataset.}
\begin{tabular}{p{1.5cm}|p{1.5cm}|p{4cm}}
\hline
Title & Musician & Text \\
\hline
{\cn {风的礼物}}\newline Gift of the Wind & {\cn {西村由纪江}} \newline Yukie Nishimura &
{\cn{轻快的节奏,恰似都市丽人随风飘过的衣袂。放松的心情,片刻的愉快驱散的是工作的压力和紧张,沉浸其中吧,自己的心。}}\newline The brisk rhythm is like the clothes of urban beauties drifting in the wind. A relaxed mood, a moment of pleasure, dispels the pressure and tension of work. Immerse yourself, your own heart, in it.
\\
\hline
{\cn {九龙水之悦}} \newline Joy of the Kowloon Water & {\cn {李志辉}} \newline Zhihui Li & {\cn{聆听[九龙水之悦]卸下所有的苦恼,卸下所有的沉重,卸下所有的忧伤,还心灵一份纯净,还人生一份简单。}} \newline Listen to ``The Joy of the Kowloon Water" to remove all the troubles, all the heaviness, and all the sorrows and restore the purity of the soul and the simplicity of life. \\
\hline
{\cn {白云}} \newline Nuvole Bianche & {\cn{鲁多维科·伊诺}} \newline Ludovico Einaudi & {\cn{钢琴的更宁静,可大提琴的更多的是悠扬和深沉,也许是不同的演奏方式带来不同的音乐感受吧。}} \newline The piano is more serene, but the cello is more melodious and deep. Perhaps different playing methods bring different musical feelings. \\
\hline
\end{tabular}
\end{table}
There are few available parallel training data pairs of free-form text and music. To solve this problem, we collect an amount of such data from the Internet, whose language is mainly Chinese.
We use the Internet's ``comment voting'' mechanism to collect such data. On the music service supporting platforms, some users enjoy writing comments on the kinds of music that interest them. If other users think these comments are of high quality, they will click the ``upvote'' button, and comments with a high count of upvotes can be selected as the ``popular comment''. By our observation, the ``popular comments'' are generally relatively high quality and usually contain much useful music-related information such as musical instruments, genres, and expressed human moods. Based on such rules, we collect a large amount of comment text-music parallel data pairs from the Internet to train the text conditional music generation model. The statistics of our collected Web Music with Text dataset and some examples are listed in Table~\ref{tab:data_statistics} and~\ref{tab:example_data}.
\subsection{Evaluation Metric}
For the text-to-music generation task, we evaluate performance in two aspects: text-music relevance and music quality. Generally, the evaluation of music can be measured by objective and subjective metrics. However, in terms of objective evaluation, there is currently a lack of well-recognized and authoritative objective evaluation methods for text-music relevance. Besides, for music quality, the objective metrics such as FAD (Frechet Audio Distance), Scale Consistency (SC), and Pitch Entropy (PE) are only calculating the closeness between the generated music and the real music instead of the actual quality of the generated music~\cite{DBLP:journals/corr/abs-2211-11248}. Therefore, we employ human evaluation methods to evaluate the music generated by our model in terms of text-music relevance and music quality.
For the evaluation method, we manually score the generated music and calculate the mean score by averaging over results from different evaluators. We use the compared methods or models to generate music based on texts from the test set. We hire 10 people to perform human evaluation, scoring the music generated by each compared model, and then average the scores over the 10 people for each generated music. The identification of models corresponding to the generated music is invisible to the evaluators. Finally, we average the scores of the same model on the entire test samples to obtain the final evaluation results of the models.
\subsection{Compared Methods}
The methods for comparison are Text-to-Symbolic Music (denoted as TSM)~\cite{DBLP:journals/corr/abs-2211-11216}, Mubert and Musika~\cite{DBLP:journals/corr/abs-2208-08706}. The generated music from Mubert is actually created by human musicians, and TSM only generates music score, which needs to be synthesized into music audio by additional tools, so the music quality among Mubert, TSM, and our model is not comparable. Thus, we only compare the text-music relevance between them and our model. To synthesize the music audio based on the symbolic music score generated by TSM, we first adopt abcMIDI\footnote{https://github.com/sshlien/abcmidi} to convert the abc file output by TSM to MIDI file and then use FluidSynth\footnote{https://github.com/FluidSynth/fluidsynth} to synthesize the final music audio. For music quality, we compare our model's performance with Musika, a recent famous work that also directly generates waveform music.
\begin{table}[h]\small
\renewcommand\arraystretch{1.2}
\centering
\caption{\label{tab:main_results} Comparison of text-music relevance.}
\begin{tabular}{p{3.5cm}|p{1cm}|p{1cm}|p{1cm}}
\hline
Method & Score$\uparrow$ & Top Rate $\uparrow$ & Bottom Rate$\downarrow$ \\
\hline
TSM~\cite{DBLP:journals/corr/abs-2211-11216} & 2.05 & 12\% & 27\% \\
\hline
Mubert & 1.85 & 37\% & 32\%\\
\hline
our model & \textbf{2.43} & \textbf{55\%} & \textbf{12\%}\\
\hline
\end{tabular}
\end{table}
\begin{table}[h]\small
\renewcommand\arraystretch{1.2}
\centering
\caption{\label{tab:quality_results} Comparison of music quality.}
\begin{tabular}{p{3.5cm}|p{1cm}|p{1cm}|p{1cm}}
\hline
Method & Score$\uparrow$ & Top Rate$\uparrow$ & Bottom Rate$\downarrow$ \\
\hline
Musika~\cite{DBLP:journals/corr/abs-2208-08706} & 3.03 & 5\% & 13\% \\
\hline
our model & \textbf{3.63} & \textbf{15}\% & \textbf{2}\% \\
\hline
\end{tabular}
\end{table}
\subsection{Results}
Table~\ref{tab:main_results} and \ref{tab:quality_results} show the evaluation results of text-music relevance and music quality. For text-music relevance evaluation, we use a ranking score of 3 (best), 2, 1 to denote which of the three models has the best relevance given a piece of text. For music quality, we use a five-level score of 5 (best), 4, 3, 2, 1, which indicates to what extent the evaluator prefers the melody and coherence of the music. The top rate means the probability that the music obtains the highest score, and the bottom rate means the probability that the music obtains the lowest score. The results indicate that our model can generate music with better quality and text-music relevance which outperforms related works by a large margin.
\subsection{Analysis}
In this section, we analyze the feature of the diversity of our generated music through visualization results and study different factors that may affect the text-music relevance, including the text condition fusing operation and input text format.
\subsubsection{Diversity}
The music generated by our model has a high diversity. In terms of melody, our model can generate music with a softer and more soothing rhythm or more passionate and fast-paced music. In terms of emotional expression, some music sounds sad, while there is also very festive and cheerful music. In terms of musical instruments, it can generate music composed by various instruments, including piano, violin, erhu, and guitar. We selected two examples with apparent differences and analyzed them based on the visualization results. As shown in the waveform from Figure \ref{fig:spectrogram}, the fast-paced guitar piece has denser sound waves, while the piano pieces have a slower, more soothing rhythm. Moreover, the spectrogram shows that the guitar piece holds dense high and low-frequency sounds, while the piano piece is mainly in the bass part.
\begin{figure*}[h]\small\centering
\subfigure[]{
\begin{minipage}[]{0.42\linewidth}
\includegraphics[width=1\textwidth]{smooth_music.pdf}
\end{minipage}
}
\subfigure[]{
\begin{minipage}[]{0.42\linewidth}
\includegraphics[width=1\textwidth]{fast_guitar.pdf}
\end{minipage}
}
\subfigure[]{
\begin{minipage}[]{0.42\linewidth}
\includegraphics[width=1\textwidth]{spec_smooth_music.pdf}
\end{minipage}
}
\subfigure[]{
\begin{minipage}[]{0.42\linewidth}
\includegraphics[width=1\textwidth]{spec_fast_guitar.pdf}
\end{minipage}
}
\caption{The spectrogram and waveform of generated music examples. The model can generate diverse music, including smoothing and cadenced (a, c) and fast-paced (b, d) rhythms. Text of (a, c): The piano piece is light and comfortable yet deeply affectionate. Text of (b, d): A passionate, fast-paced guitar piece.} \label{fig:spectrogram}
\end{figure*}
\subsubsection{Comparison of Different Text Condition Fusing Operations}\label{compare_fuse}
\begin{figure}[!htb]
\centering
\includegraphics[width=.4 \textwidth]{mse2.pdf}
\caption{The MSE results on the test set for two implementations of the fusing operation.}
\label{fig:mse_testset}
\end{figure}
As introduced in Section \ref{timestep_condition}, we compare two implementations of the fusing operation ${\rm Fuse}(\cdot, \cdot)$, namely concatenation and element-wise summation. To evaluate the effect, we compare the performance on the test set as the training progresses. For every 5 training steps, we adopt the model checkpoint to generate pieces of music based on the texts in the test set and calculate the Mean Squared Error (MSE) of generated music and gold music from the test set. The visualization results are shown in Figure \ref{fig:mse_testset}, which indicates no apparent difference between the two fusing operations. For simplicity, we finally adopt the element-wise summation.
\subsubsection{Comparison of Different Formats of Input Text
}
Our proposed method leverages free-form text to generate music. However, considering that the more widely used methods in other works generate music based on a set of pre-defined music tags representing the specific music's feature~\cite{zhang2020butter}, we compare these two methods to obtain better text-music relevance of generated music. Therefore, we train two models with the two text formats and manually evaluate the text-music relevance of the generated music. Specifically, we compare two kinds of text format to condition the diffusion model: \textit{End-to-End Text Conditioning} and \textit{Music Tag Conditioning}.
\paragraph{End-to-End Text Conditioning}
Suppose the training data consists of multiple text and music pairs $<Y, X>$. The texts in $Y$ are free-form, describing some scenario, emotion, or just a few words about music features. We adopt the straightforward way to process the texts: to input them into the text encoder ${\rm E}(\cdot)$ to obtain the text representations. It relies on the natural high correlation of the $<Y, X>$, and the conditional diffusion model dynamically learns to capture the critical information from the text in the training process.
\paragraph{Music Tag Conditioning}
Using short and precise music tags as the text condition may make it easier for the model to learn the mapping between text and corresponding music. We analyze the text data from the training set and distill critical information from the texts to obtain music tags. Take Table \ref{tab:comment_example} for example. The key features of the music in a piece of long text are limited and can be extracted as music tags.
\begin{table}[h]\small
\renewcommand\arraystretch{1.5}
\centering
\caption{\label{tab:comment_example} Examples of free-form texts and corresponding music tags.}
\begin{tabular}{p{5cm}|p{2cm}}
\hline
Text & Tags \\
\hline
{\cn{聆听世界著名的钢琴曲简直是一种身心享受,我非常喜欢}} \newline Listening to the world famous piano music is simply a kind of physical and mental enjoyment, I like it very much & {\cn {钢琴}} \newline piano\\
\hline
{\cn {钢琴旋律的弦音,轻轻地、温柔地倾诉心中的遐想、心中的爱恋}} \newline The strings of the piano melody, gently and tenderly express the reverie and love in the heart & {\cn {钢琴,轻轻,温柔,爱}} \newline piano, gentle, tender, love\\
\hline
{\cn {提琴与钢琴合鸣的方式,在惆怅中吐露出淡淡的温柔气息}} \newline The ensemble of violin and piano reveals a touch of gentleness in melancholy & {\cn {钢琴, 小提琴, 温柔, 惆怅}} \newline piano, violin, gentle, melancholic\\
\hline
\end{tabular}
\end{table}
\noindent To obtain the music tags, we use the TF-IDF model to mine terms with higher frequency and importance from the dataset. Given a set of text $Y$, the basic assumption is that the texts contain various words or phrases related to music features such as instruments and genres. We aim to mine a tag set $T$ from $Y$. We assume two rules to define a good music tag representing typical music features: 1) A certain amount of different music can be described with the tag for the model to learn the ``text(tag)-to-music'' mapping without loss of diversity; 2) A tag is worthless if it appears in the descriptions of too many pieces of music. For example, almost every piece of music can be described as ``good listening"; thus, it should not be adopted as a music tag. Based on such rules, we leverage the TF-IDF model to mine the music tags. Because the language of our dataset is Chinese, we use jieba\footnote{https://github.com/fxsjy/jieba} to cut the sentences into terms. For a term $w$, we make statistics on the total dataset to obtain the TF ${\rm tf}(w)$ and the IDF ${\rm idf}(w)$, then the term score is obtained as ${\rm score}(w) = {\rm tf}(w) \cdot {\rm idf}(w)$. We reversely sort all the terms based on ${\rm score}(w)$ and manually select 100 best music tags to obtain the ultimate music tag set $T$, which can represent the features of music such as instruments, music genres, and expressed emotions. Table \ref{tab:tag_example} displays examples of the adopted and abandoned terms.
\begin{table}[h]\small
\renewcommand\arraystretch{1.5}
\centering
\caption{\label{tab:tag_example} Examples of the adopted and abandoned tags}
\begin{tabular}{p{1.8cm}|p{4cm}}
\hline
& Tags \\
\hline
Adopted & {\cn{希望,生命,钢琴,小提琴,孤独,温柔,幸福,悲伤,游戏,电影}} \newline hope, life, piano, violin, lonely, gentle, happiness, sad, game, movie \\
\hline
Abandoned & {\cn{音乐,喜欢,感觉,世界,好听,旋律,永远,音符,演奏,相信}} \newline music, like, feeling, world, good-listening, melody, forever, note, play, believe \\
\hline
\end{tabular}
\end{table}
\noindent We use the mined music tags to condition the diffusion process. For a piece of music from the training data, we concatenate its corresponding music tags with a separator symbol ``{\cn {,}}'' to obtain a music tag sequence as the conditioning text to train the model.
\begin{table}[h]\small
\renewcommand\arraystretch{1.1}
\centering
\caption{\label{tab:comparison_tag_text} Comparison of text-music relevance between two conditioning text formats.}
\begin{tabular}{p{4cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}}
\hline
Method & Score$\uparrow$ & Top Rate$\uparrow$ & Bottom Rate$\downarrow$ \\
\hline
Music Tag Conditioning & 1.7 & 22\% & 52\% \\
\hline
End-to-End Text Conditioning & \textbf{2.3} & \textbf{40\%} & \textbf{10\%} \\
\hline
\end{tabular}
\end{table}
We randomly select 50 samples from the test set for manual evaluation. Table \ref{tab:comparison_tag_text} shows the evaluation results of the two conditioning methods, which indicates that our proposed free-form text-based music generation method obtains better text-music relevance than using pre-defined music tags. The main reason might be that the human-made music tag selection rules introduce much noise and result in the loss of some useful information from the original text. Thus it is better to use the \textit{End-to-End Text Conditioning} method for the model to learn to capture useful information dynamically.
\section{Conclusion}
In this paper, we propose ERNIE-Music, the first music generation model to generate music audio based on free-form text. To solve the problem of lacking such text and music parallel data, we collect music from the Internet paired with their comment texts describing various music features. In order to analyze the effect of text format on learning text-music relevance, we mine music tags from the entire text collection and compare utilizing the two forms of text conditions. The results show that our free-form text-based conditional generation model creates diverse and coherent music and outperforms related works in music quality and text-music relevance.
\bibliographystyle{named}
| {'timestamp': '2023-02-10T02:07:18', 'yymm': '2302', 'arxiv_id': '2302.04456', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04456'} | arxiv |
\section{Introduction}\label{sec_int}
Massive multiple-input multiple-output (mMIMO) has been considered a key technology in
wireless communication systems such as the fifth-generation (5G) network and beyond~\cite{MUMIMO,Yang}.
In mMIMO systems, tens or hundreds of antennas communicate simultaneously, resulting in high energy and spectral efficiency.
One challenge in mMIMO systems is \textit{overloading} in which the number of transmitting antennas is larger than that of receiving antennas.
Signal detection in overloaded mMIMO systems requires linear regression of underdetermined systems, which further complicates the problem.
Recently, various MIMO signal detectors have been proposed to overcome the significant performance degradation of conventional detectors such as
the minimum mean square error (MMSE) detector~\cite{MMSE}.
In particular, trainable detectors based on deep learning techniques show excellent detection performance~\cite{Bala}.
Another challenge in mMIMO systems is related to ultra-reliable low-latency communication (URLLC)~\cite{Salh}, a key concept of post-5G networks.
As MIMO systems become massive, the computational complexity of signal detection becomes crucial.
Notably, a trainable MIMO detector has two types of computational complexity, i.e., \textit{training cost} and \textit{execution cost}.
The training cost relates to the scalability of the number of trainable parameters and the computational complexity of updating them in the training process.
In a realistic scenario, trainable detectors should be learned online depending on the channel state information (CSI).
This means that both training and execution costs are important for URLLC.
The recent trainable MIMO detectors are mainly based on a deep learning technique called deep unfolding (DU)~\cite{LISTA,DU,DU2}.
In DU, we first unroll the recursive structure of an iterative algorithm and embed some trainable parameters in each layer.
These trainable parameters are updated by an optimizer to minimize a proper loss function whose value is determined by the supervised data and corresponding outputs of the unrolled algorithm.
We can reduce the number of trainable parameters required by DU when compared with that required by conventional deep neural networks~\cite{TISTA2}.
Numerous DU-based algorithms have been proposed for mMIMO systems, which include
DetNet~\cite{DetNet}, trainable projected gradient (TPG) detector~\cite{TPG,TPG2}, and OAMP-net~\cite{He,He2}.
Although these DU-based detectors show excellent performance, their training or execution cost continues to be high.
For instance, in an mMIMO system with $n$ transmitting antennas,
the training and execution cost of DetNet is $O(n^2)$ but it contains $O(n^2)$ parameters, whereas the
TPG detector and OAMP-net have only $O(1)$ parameters
but require matrix inversion, resulting in $O(n^3)$ training and execution costs.
These facts suggest the need for developing a trainable MIMO detector with low training and execution costs.
The objective of this study was to develop a trainable MIMO detector with a simple structure. Accordingly, we propose an mMIMO detector with only $O(1)$ trainable parameters and computational cost of
$O(n^2)$ for training and execution per iteration.
To achieve our objective, we constructed a novel MIMO detector called Hubbard--Stratonovich (HS) detector inspired by the HS transformation~\cite{Hab,Stra}.
Then, by combining the HS detector with DU, we propose the trainable HS (THS) detector.
We numerically analyzed its detection performance by comparing it with those of a scalable modified TPG detector and other conventional detectors.
This paper is organized as follows.
Section~\ref{sec_set} describes the MIMO system model.
In Sec.~\ref{sec_TPG}, we present an existing DU-based detector.
Section~\ref{sec_HS} proposed HS and THS detectors.
Section~\ref{sec_cost} discusses the training and execution costs of trainable detectors.
We present the numerical results of the THS detector in Sec.~\ref{sec_res}, and
discuss its superiority in Sec.~\ref{sec_dis}.
Section~\ref{sec_con} summarizes this paper.
\section{Model Setting}\label{sec_set}
In this section, we describe the channel model and introduce several definitions and notations.
The number of transmitting and receiving antennas is denoted by $n$ and $m$, respectively. If $m < n$ holds, the MIMO system is considered overloaded.
For simplicity, we assume that the transmitter does not use precoding and that the receiver knows
the perfect CSI, i.e., the channel matrix.
Let $\t{x} := [\ti{x}_1,\ti{x}_2,\dots,\ti{x}_n]^{T} \in \t{{\mathbb S}} ^{n}$ be
a vector in which $\ti{x}_j$ ($j=1,\dots,n$) represents a transmitted symbol from the $j$-th antenna.
The discrete set $\t{\bb{S}} \subset \bb{C}$ represents a signal constellation.
Assuming a flat Rayleigh fading channel, the received signal $\t{y} := [\ti{y}_1,\ti{y}_2,\dots,\ti{y}_m]^{T} \in \bb{C}^{m}$
is given by
$
\t{y} = \t{H}\t{x} + \t{w},
$
where $\t{H} \in \bb{C}^{m \times n}$ is a channel matrix and
$\t{w}\in \bb{C}^m$ is a complex additive white Gaussian noise vector
with zero mean and covariance of $\sigma_{w}^2\bm I$.
This channel model can be rewritten in the real-number domain.
The equivalent channel over $\mathbb{R}$ is given by
\begin{equation}
\bm y = \bm H\bm x + \bm w, \label{eq_rec}
\end{equation}
where
\begin{align}
\bm y &:= \begin{bmatrix}
\Re(\t{y}) \\
\Im(\t{y})
\end{bmatrix} \in \bb{R}^{M},\
\bm H := \begin{bmatrix} \label{eq:H_real}
\Re(\t{H}) & - \Im(\t{H})\\
\Im(\t{H}) & \Re(\t{H})\\
\end{bmatrix}, \\
\bm{x} &:= \begin{bmatrix}
\Re(\t{{x}}) \\
\Im(\t{{x}})
\end{bmatrix} \in \bb{S}^{N}, \
\bm{w} := \begin{bmatrix}
\Re(\t{{w}}) \\
\Im(\t{{w}})
\end{bmatrix}\in \bb{R}^{M},
\end{align}
and $(N,M) := (2n,2m)$.
In the following, we consider the QPSK modulation, i.e., $\mathbb{S}=\{1,-1\}$, in the real-valued channel model (\ref{eq_rec}).
\section{TPG Detector}\label{sec_TPG}
Here, we describe the TPG detector~\cite{TPG,TPG2} as an example of the existing trainable MIMO detectors.
The MIMO signal detection is expressed as the following NP-hard optimization problem:
\begin{equation}
\bm{\hat x} := \mathrm{argmin}_{\bm{{x}}\in\mathbb{S}^N} \frac{1}{2}\|\bm{{y}}-\bm{{H}{x}}\|_2^2. \label{eq_2}
\end{equation}
In particular, this is a linear regression in an underdetermined system if the system is overloaded, i.e., $M<N$.
The TPG detector solves (\ref{eq_2}) using continuous relaxation and projected gradient descent.
The update rule of the TPG detector is given by
\begin{align}
\bm r_t &= \bm s_t + \gamma_{t} \bm W(\bm y -\bm H \bm s_t ),\\
\bm s_{t+1} &= \tanh(\bm r_t/|\theta_{t}|),
\end{align}
where $\bm s_0=\bm 0$ and $\{\gamma_t,\theta_t\}_{t=0}^{T-1}$ is a set of trainable parameters.
The $\tanh(\cdot)$ function is applied to each element.
The number of trainable parameters is omly $O(1)$, and the training cost is much lower than that of DetNet.
In the original TPG detector, the matrix $\bm W$ is a linear MMSE (LMMSE)-like matrix $\bm H^T(\bm H \bm H^T + \alpha \bm I)^{-1}$ with a trainable parameter $\alpha$ because $\bm W = \bm H^T$ based on gradient descent shows poor detection performance~\cite{TPG2}.
However, the LMMSE-like matrix requires matrix inversion, which has a computational cost of $O(n^3)$.
Matrix inversion is required for each update in the training process, resulting in a training cost of $O(n^3)$.
Another trainable detector called OAMP-net has the same problem.
\section{Hubbard--Stratonovich Detector}
\label{sec_HS}
Our goal is to propose a trainable MIMO signal detector without matrix inversions.
Unlike the TPG detector based on continuous relaxation, we consider sampling a solution of (\ref{eq_2}) using the Boltzmann distribution given by
\begin{equation}
P(\bm x;\beta):= \frac{1}{Z}\exp\left( -\frac{\beta\lambda}{2}\|\bm{{y}}-\bm{{H}{x}}\|_2^2\right) , \label{eq_B}
\end{equation}
where $\beta(>0)$ is called the inverse temperature, $\lambda(>0)$ is a scaling parameter, and $Z$ is a normalization constant called the partition function.
An optimal solution of (\ref{eq_2}) is obtained in the $\beta\to\infty$ limit, but calculating the probability is difficult because of $Z$.
Here, we attempt to sample $\bm x$ from (\ref{eq_B}) by using an efficient method proposed by Ohzeki~\cite{OH}.
The key step is the use of an identity known as the HS transformation in statistical physics~\cite{Hab,Stra}: for $a>0$,
\begin{equation}
\exp\left(-\frac{ax^2}{2}\right)=\int \frac{1}{\sqrt{2\pi a}}\exp\left(-\frac{z^2}{2a}-ixz\right)dz. \label{eq_HS}
\end{equation}
Recently, the HS transformation is also applied to probabilistic inference in machine learning~\cite{Koe}.
Then, the partition function $Z$ is rewritten as follows:
\begin{align}
Z &:= \sum_{\bm{x}\in\mathbb{S}^{N}} \exp\left( -\frac{\beta\lambda}{2}\|\bm{{y}}-\bm{{H}{x}}\|_2^2\right) \nonumber\\
&= \int \left(\prod_{j=1}^{M}\frac{dz_j}{\sqrt{2\pi \beta\lambda}}\right)
\sum_{\bm{x}\in\mathbb{S}^{N}} \exp\left( -\frac{\|\bm z\|_2^2}{2\beta\lambda} - i \bm z^T (\bm{Hx}-\bm{y})\right) \nonumber\\
&\propto \int d\bm v \sum_{\bm{x}\in\mathbb{S}^{N}}\exp\left( \frac{\beta \|\bm v\|_2^2}{2\lambda} + \beta \bm v^T (\bm{Hx}-\bm{y}) \right) \nonumber\\
&:=\int d\bm v e^{-\beta H(\bm v)}, \label{eq_z}
\end{align}
where $\bm z = (z_1,\dots,z_M)^T$, $\bm v = (v_1,\dots,v_M)^T$, and $z_j = i \beta v_j$ ($j=1,\dots, M$).
If $\beta$ is sufficiently large, the integral can be estimated by the saddle-point method, i.e.,
$Z\propto e^{-\beta H(\bm{\hat v})} $, where $\bm{\hat v}$ is a saddle point of the following function:
\begin{align}
H(\bm v)& = -\frac{\|\bm v\|_2^2}{2\lambda} + \bm v^T\bm{y} - \frac{1}{\beta}\ln Z(\bm v), \label{eq_hv1} \\
Z(\bm v) &:= \sum_{\bm{x}\in\mathbb{S}^{N}} e^{\beta \bm v^T \bm H \bm x}. \label{eq_hv2}
\end{align}
We can also estimate the expectation of $\bm x$ by $\bm{\hat v}$ because, using the same transformation, we have
\begin{align}
\sum_{\bm{x}\in\mathbb{S}^{N}} \bm xP(\bm x;\beta)& := \frac{1}{Z}\int d\bm v \!\sum_{\bm{x}\in\mathbb{S}^{N}} \bm x \exp\left( \frac{\beta \|\bm v\|_2^2}{2\lambda}\! + \!\beta \bm v^T (\bm{Hx}\!-\!\bm{y}) \right) \nonumber\\
&\simeq \frac{\sum_{\bm{x}\in\mathbb{S}^{N}} \bm x e^{\beta \bm{\hat v}^T \bm{Hx}} }{\sum_{\bm{x}\in\mathbb{S}^{N}} e^{\beta \bm{\hat v}^T \bm{Hx}}}. \label{eq_exx}
\end{align}
The expectation is equal to $\bm{\hat x}$ if the optimization problem (\ref{eq_2}) has a unique optimal solution.
Based on gradient descent, a simple update rule to estimate $\bm{\hat v}$ is obtained~\cite{OH}.
The derivative of (\ref{eq_hv1}) contains
the expectation of $\bm x$ defined as
\begin{equation}
\left<\bm x\right>_{\bm v}:= \frac{\sum_{\bm{x}\in\mathbb{S}^{N}} \bm x e^{\beta \bm v^T \bm H \bm x}}{\sum_{\bm{x}\in\mathbb{S}^{N}} e^{\beta \bm v^T \bm H \bm x}}. \label{eq_app3}
\end{equation}
This is equivalent to (\ref{eq_exx}) when $\bm v=\bm{\hat{v}}$.
For $i=1,\dots,N$, the $i$-th element of (\ref{eq_app3}) is easily calculated because $\{x_i\}$ become independent random variable in this problem setting.
We find
\begin{align}
\frac{\sum_{\bm{x}\in\mathbb{S}^{N}} x_i e^{\beta \bm v^T \bm H \bm x}}{\sum_{\bm{x}\in\mathbb{S}^{N}} e^{\beta \bm v^T \bm H \bm x}} &= \frac{\sum_{x_i \in\mathbb{S}} x_i e^{\beta (\bm H^T\bm v)_i x_i}}{\sum_{x_i\in\mathbb{S}} e^{\beta (\bm H^T\bm v)_i x_i}} \nonumber\\
& = \tanh(\beta (\bm H^T\bm v)_i ). \label{eq_app4}
\end{align}
Introducing $\bm u:= \bm H^T \bm v$, we have the update rule given by
\begin{align}
\bm u_{t+1} &= \left(1+\frac{\eta}{\lambda}\right)\bm u_t + \eta \bm H^T (\bm y -\bm H \bm s_t ), \label{eq_HS1}\\
\bm s_{t+1} &= \tanh(\beta \bm u_{t+1}),\label{eq_HS2}
\end{align}
where $\bm u_0\!=\!\bm s_0\!=\!\bm 0$ and $\eta$ is a step-size parameter.
The parameter $\lambda$ controls the strength of the quadratic term of (\ref{eq_hv1}).
We call this the Hubbard--Stratonovich (HS) detector.
Note that if $\bm u_t=\bm H \bm{\hat v}$ holds, $\bm s_t$ is equivalent to (\ref{eq_exx}) and possibly $\bm{\hat x}$.
Thus, the HS detector can be considered the expectation-maximization (EM) algorithm~\cite{EM} that searches
$\bm{\hat v}$ and $\bm{\hat x}$ simultaneously, where (\ref{eq_HS1}) and (\ref{eq_HS2}) correspond to the maximization step and expectation step, respectively.
It is also noteworthy that the difficulty in solving (\ref{eq_2}) by the HS detector is related to finding $\bm{\hat v}$ because the function $H(\bm v)$ is non-convex at least in the $\beta\to\infty$ limit.
Finally, DU is applied to the HS detector to train some internal parameters.
The trainable MIMO detector, called the THS detector, is defined as
\begin{align}
\bm u_{t+1} &= \zeta_{t} \bm u_t + \eta_{t} \bm H^T(\bm y -\bm H \bm s_t ), \label{eq_THS1}\\
\bm s_{t+1} &= \tanh(\beta_{t} \bm u_{t+1}),\label{eq_THS2}
\end{align}
where $\bm u_0\!=\!\bm s_0\!=\!\bm 0$.
We introduce $\{\beta_t, \eta_t,\zeta_t\}_{t=0}^{T-1}$ as trainable parameters, which affect the detection performance.
The inverse temperature $\beta_t$ is tuned because a large $\beta_t$ leads to fast convergence to an undesired local minima, whereas $\beta_t$ should be infinitely large as described above.
The step-size $\eta_t$ controls the convergence speed, and $\zeta_t$ is related to $\lambda$ in (\ref{eq_HS1}).
\section{Training and Execution Costs}
\label{sec_cost}
Here, we discuss the training and execution costs of the THS detector.
It is obvious that the THS detector contains only three trainable parameters in each iteration (or layer), and that
the computational complexity remains limited to $O(n^2)$ owing to the absence of matrix inversion.
In Tab.~\ref{tab_1}, we summarize the number of trainable parameters and the training and execution costs of the trainable MIMO detectors per iteration (or layer).
Note that the training cost indicates the computational complexity required to update the trainable parameters in the training process whereas the execution cost is the computational cost for executing the learned algorithm.
In particular, the TPG detector requires matrix inversion once during the execution, which is omitted from the execution cost per iteration in Tab.~\ref{tab_1}.
However, it requires a matrix inversion every time a trainable parameter $\alpha$ is updated in the training process, indicating that the training cost per update is $O(n^3)$.
We find that the THS detector is advantageous in terms of the number of trainable parameters when compared with DetNet.
In addition, the THS detector is more computationally efficient than the TPG detector and OAMP-net with matrix inversions.
Overall, the THS detector has the simplest structure in terms of the number of trainable parameters and the training and execution costs,
implying fast training and execution for mMIMO systems.
\begin{table}[t]
\centering
\caption{Number of trainable parameters and
computational costs for training and execution per iteration. }
\label{tab_1}
\begin{IEEEeqnarraybox}[\IEEEeqnarraystrutmode%
]{l"l"l"l"l}
\toprule
& $THS$ & $DetNet$ & $TPG$ & $OAMP-net$ \\
\midrule
$\# of parameters$ & O(1) & O(mn) & O(1) & O(1) \\
$Training cost$ & O(n^2) & O(n^2) & O(n^3) & O(n^3) \\
$Execution cost$ & O(n^2) & O(n^2) & O(n^2)^{\mbox{\dag}} & O(n^3) \\
\bottomrule
\end{IEEEeqnarraybox}\\
$^{\mbox{\dag}}$ The TPG detector requires matrix inversion once before its iterations.
\end{table}
\section{Numerical Results}
\label{sec_res}
In this section, we present the numerical results of the signal detection performance of the proposed THS detector.
\subsection{Simulation Settings}
We first describe the simulation settings.
In the MIMO system (\ref{eq_rec}), the signal-to-noise ratio (SNR) is given by $\mathrm{SNR}=10\log_{10}\frac{n}{\sigma_w^2}$. We estimate the bit error rate (BER) as the indicator for signal detection performance.
All real-valued detected signals are thresholded to $\mathbb{S}=\{1,-1\}$ using the sign function $\mathrm{sign}(*)$ for calculating the BER.
The THS detector was implemented using PyTorch 1.13.1~\cite{PyTorch}.
Its training is based on supervised learning in which pairs of transmitted and received signals $\{(\bm x,\bm y)\}$ are randomly generated. These training data are fed to the THS detector as a mini-batch.
In each parameter update, 1000 mini-batches of size 2000 are fed, and the parameters are updated by an Adam optimizer~\cite{Adam} with a learning rate of $2\times 10^{-4}$ to minimize the MSE loss function.
A channel matrix $\bm H$ is generated for each mini-batch.
We employed incremental training to ensure the stability of the training process (see~\cite{TPG2} for details).
The number of iterations was set to $T=30$, and the initial values of the trainable parameters were $\eta_t=0.01$ and $\beta_t=\zeta_t=1$.
We also examined the MMSE detector, enhanced reactive tabu search (ERTS)~\cite{ERTS}, HS detector, TPG detector, and its variant as the baseline algorithms.
MMSE and ERTS are conventional MIMO detectors. The computational complexity of the MMSE detector is $O(n^3)$.
ERTS searches a transmitted signal from the random initial points. Its computational cost is $O(Kn^2)$,
where $K$ is the number of iterations. We set $K=500$ in the simulations.
The HS detector is executed with fixed step-size parameters $\eta=0.1$ and $\lambda=1$.
The TPG detector was trained and executed under the same conditions as in~\cite{TPG2}.
In addition, we examined the TPG detector with $\bm W=\bm H^T$, called the scalable TPG detector; it has the same training and computational costs as the THS detector.
The number of iterations of the HS, TPG, and scalable TPG detectors was set to $T=30$, as in the case of the THS detector.
\subsection{Numerical Results}
We present the detection performance of overloaded mMIMO systems.
\begin{figure}[!t]
\centering
\includegraphics[width=0.94\linewidth]{./figs/DUOH_50_32.eps}
\caption{BER performance for $(n,m)=(50,32)$. The number of iterations of (T)HS and (scalable) TPG detectors is $T=30$ and that of ERTS is $K=500$.
}\label{zu_s1}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=0.94\linewidth]{./figs/DUOH_100_64.eps}
\caption{BER performance for $(n,m)=(100,64)$.
}\label{zu_s2}
\end{figure}
Figure~\ref{zu_s1} depicts the detection performance when $(n,m)=(50,32)$.
In this case, ERTS shows the best performance but the number of iterations $K=500$ is much larger than that of the (T)HS and TPG detectors.
Interestingly, the HS detector without learning shows better performance than the scalable TPG detector in the high-SNR regime.
The detection performance of the THS detector was superior to that of the HS detector, indicating that DU successfully improves the detection performance; when $\mathrm{SNR}=20$ dB, the BER of the THS detector was approximately $2.7\times 10^{-3}$ whereas
those of the HS and scalable TPG detectors were $1.1\times 10^{-2}$ and $1.8\times 10^{-2}$, respectively.
In addition, the detection performance of the THS detector was close to that of the TPG detector but the training cost was lower.
The SNR gap between the THS and TPG detectors was approximately $2.5$ dB at $\mathrm{BER}=2.0\times 10^{-3}$.
Figure~\ref{zu_s2} shows the detection performance when $(n,m)=(100,64)$.
In this case, the performance of the HS detector degrades significantly when compared with that of the THS detector, although it is superior to that of the MMSE detector. This is because the convergence speed of the HS detector becomes slower as the antenna size increases.
Similarly, the performance of ERTS degrades because of the curse of dimensionality in searching for a good estimation.
The THS detector showed better performance than the scalable TPG detector but poorer performance than the TPG detector;
further, it achieved a gain of approximately $2.5$ dB when compared with the scalable TPG detector at $\mathrm{BER}=2.0\times 10^{-4}$. In the high-SNR regime, the performance of the THS detector was fairly close to that of ERTS.
\begin{figure}[!t]
\centering
\includegraphics[width=0.94\linewidth]{./figs/DUOH_150_96.eps}
\caption{BER performance for $(n,m)=(150,96)$.
}\label{zu_s3}
\end{figure}
Figure~\ref{zu_s3} shows the detection performance when $(n,m)=(150,96)$.
We find that the detection performances of the ERTS and HS detectors are significantly degraded.
In addition, the scalable TPG detector shows an error floor around $\mathrm{BER}=10^{-4}$ in the high-SNR regime.
However, the THS detector exhibits better detection performance, especially in the high-SNR regime, whereas its SNR gap from the TPG detector increases.
When $\mathrm{SNR}=20$ dB, the BER of the THS detector is approximately $1.1\times 10^{-5}$ whereas that of the scalable TPG detector is approximately $1.1\times 10^{-4}$.
We can conclude that the THS detector successfully detects the transmitted signals in overloaded mMIMO systems.
Unlike the HS, scalable TPG, and ERTS detectors, the proposed THS detector shows excellent performance regardless of the number of antennas.
Moreover, it achieves a performance close to that of the TPG detector requiring matrix inversion.
\begin{figure}[!t]
\centering
\includegraphics[width=0.94\linewidth]{./figs/Comparison_grad.eps}
\caption{Average amplitude of gradient $G$ of the THS and scalable TPG detectors over $10^4$ signals for a noiseless MIMO system with $(n,m)=(50,32)$. The BER performances of the THS and scalable TPG detectors are $1.1\times 10^{-3}$ and $4.8\times 10^{-3}$, respectively.
}\label{zu_s4}
\end{figure}
\section{Discussion: Difference between THS and Scalable TPG Detectors}
\label{sec_dis}
In the previous section, the numerical results showed that the THS detector exhibited better detection performance than the scalable TPG detector. In this section, we discuss the reason for the successful signal detection of the THS detector.
First, we present the update rules of the two detectors.
The update rule of the scalable TPG detector is given by
\begin{equation}
\bm r_{t+1} = \tanh(\beta_t \bm r_t) + \eta_{t+1} \bm H^T[\bm y -\bm H \tanh(\beta_t \bm r_t) ], \label{eq_sc}
\end{equation}
where we set $\eta_t=\gamma_t$ and $\beta_t=|\theta_t|^{-1}$.
In this update rule, $\bm r_t$ is a search point of the problem (\ref{eq_2}), neglecting the constraint $\bm x\in\mathbb{S}^N$.
To investigate a fixed point of (\ref{eq_sc}), let us consider a noiseless case.
Then, the transmitted signal $\bm{x}_0$ is the exact solution of (\ref{eq_2}) and
should be a fixed point of (\ref{eq_sc}) because $\bm y = \bm H \bm x_0$ holds.
However, it is easily found that $\bm r^\ast $ satisfying $\bm x_0=\tanh(\beta_t \bm r^\ast)$ cannot be a fixed point unless $\beta_t\to \infty$ owing to the soft projection function $\tanh(\cdot)$.
Recalling that the TPG detector with $\beta\to\infty$ usually fails signal detection, it is difficult to find a fixed point in $\mathbb S$ for the TPG detector with finite $\beta_t$.
On the other hand, the THS detector is defined as
\begin{equation}
\bm u_{t+1} = \bm u_t + \eta_{t+1} \bm H^T[\bm y -\bm H \tanh(\beta_t \bm u_t) ], \label{eq_ths}
\end{equation}
where we assume $\zeta_t=1$ (or $\lambda\to\infty$).
The difference between the THS (\ref{eq_ths}) and scalable TPG (\ref{eq_sc}) detectors lies only in the first term.
However, as described in Sec.~\ref{sec_HS}, $\bm u_t$ relates to $\bm v$ of the HS transformation, and is regarded as local fields of $\bm x$, i.e., $P(x_i)\propto e^{\beta_t u_{ti}x_i}$, where $u_{ti}$ is the $i$-th element of $\bm u_t$.
In the noiseless case, the THS detector has a fixed point $\bm u^\ast$ corresponding to $\bm x_0=\tanh(\beta_t \bm u^\ast)$ for any $\beta_t>0$, unlike the scalable TPG detector.
Additionally, we numerically studied these detectors in a noiseless MIMO system with $(n,m)=(50,32)$.
In this case, the BERs of the THS and scalable TPG detectors were $1.1\times 10^{-3}$ and $4.8\times 10^{-3}$, respectively. The trained values of $\beta_t$ of the scalable TPG took a range from $0.24$ to $2.65$, indicating that the transmitted signal is not a fixed point of (\ref{eq_sc}).
Figure~\ref{zu_s4} shows the average amplitude of the gradient defined by
$G:= {N}^{-1} \| \bm H^T(\bm y -\bm H \bm s_t )\|_2$.
This value should be zero if $\bm s_t=\bm x_0$.
We find that the value for the THS detector gradually decreases as the number of iterations increases,
wheras that for the TPG detector remains large.
In Fig.~\ref{zu_s5}, we depict the average bit-flip ratio, which denotes the fraction of bit flips from $\mathrm{sign}(\bm s_{t})$ to $\mathrm{sign}(\bm s_{t+1})$.
We find that the bit-flip ratio of the THS detector drops as $G$ decreases whereas that of the TPG detector remains relatively large.
These differences suggest that the search point of the THS detector approaches a desired fixed point but that of the scalable TPG detector is far from the fixed point.
This numerical stability is another possible reason for the difference in the detection performance in the high-SNR regime.
\begin{figure}[!t]
\centering
\includegraphics[width=0.98\linewidth]{./figs/Comparison_flip.eps}
\caption{Average bit-flip ratio of the THS and scalable TPG detectors over $10^4$ signals for a noiseless MIMO system with $(n,m)=(50,32)$.
}\label{zu_s5}
\end{figure}
\section{Concluding Remarks}
\label{sec_con}
In this paper, we proposed a novel mMIMO detector
inspired by HS transformation and DU.
The proposed detector, called the THS detector, has a simple update rule with $O(1)$ trainable parameters per iteration.
In addition, its training and execution cost is $O(n^2)$ per iteration, which is the least among the existing trainable MIMO detectors, making it suitable for URLLC.
Numerical results showed that the THS detector performs better than the scalable TPG detector, which has the same computational costs. In addition, the performance is fairly close to that of the TPG detector but the computational costs are lower.
We also discussed the successful detection of the THS detector, and showed that it is more stable than the scalable TPG detector, as its search point is close to a fixed point in a noiseless case.
In our future study, we intend to investigate the THS detector for higher-order modulations and coded modulations. The application of the Chebyshev steps~\cite{ch,ch2} will be beneficial in reducing the number of trainable parameters.
A theoretical analysis of the HS and THS detector is also an interesting research topic.
\section*{Acknowledgement}
We thank Masayuki Ohzeki for discussions on~\cite{OH}.
ST also thanks Takashi Takahashi, Jun Takahashi, Yoshihiko Nishikawa, and Harukuni Ikeda for fruitful discussions.
This work was partly supported by JSPS KAKENHI Grant Numbers 22H00514, 22K17964, and 19K14613.
\IEEEtriggeratref{11}
| {'timestamp': '2023-02-10T02:07:27', 'yymm': '2302', 'arxiv_id': '2302.04461', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04461'} | arxiv |
\section*{Acknowledgements}
The authors would like to thank Ian Gemp, Chongli Qin, and Yoram Bachrach for fruitful discussions. AJB was generously supported by an IVADO Ph.D. fellowship.
\section{Further Related Work}
As described by [] and [], the desiderata for a generative model can be broken down into 3 main categories:
\begin{itemize}
\item Sample quality: Are the samples generated representative of the target distribution
\item Sample diversity: Do the generated samples cover the support of the target distribution
\item Generalization: Is the model learning to generate new samples or merely copying the training set
\end{itemize}
The former 2 have been addressed in some ways with previous scores such as IS, FID (which aggregate the score in one metric) and newer evaluation methods such as Precision/Recall (which separate them into two scores). We propose two methods of evaluating both of these properties using our KDE likelihood based approach.
Specifically, we can think of sample quality as the likelihood of the generated samples under a model of the likelihood of the test samples and sample diversity as being evaluated through the likelihood of the test set given a model of the likelihood of the generated samples. For the former, if the samples are deemed unlikely by the model from the test set, they are probably poor samples. For the latter, if certains parts of the support of the test set are not covered by the generated samples, then they will have low likelihood undert this model yielding a bad score.
There is an additional body of work which aims to test the degree to which a model overfits the training set. The most promising work, [Meehan, et al] performs a Mann Whitney test on the nearest neighbor distances in the feature space (after PCA projection). While the score does a good job of detecting overfitting in simple toy examples, there has been limited testing of its effectiveness on real world datasets and analysis of potential failure modes.
\begin{itemize}
\item Can use KDE to estimate likelihood, hard in high dimensions.
\item Need to compare test/train likelihood
\item Can use embeddings as in IS/FID
\end{itemize}
Combine the above can get our score
}
\section{Additional Results}
\subsection{LSUN results}
We conduct the same experiments found in \textbf{Q3} for the LSUN dataset \citep{yu2015lsun}. Specifically,
we evaluate the FLS on standard generative models and also perform a linear regression analysis with respect to FID. In Fig. \ref{fig:lsun_score_comparison} shows our findings where, for example, we observe that the Improved DDPM model \citep{nichol2021improved} is underrated by FID in comparison to FLS.
\label{app:additional_results}
\begin{figure*}[h!]
\begin{center}
\centerline{\includegraphics[width=\textwidth]{figures/metric_comparison_LSUN_Bedroom.png}}
\caption{FLS vs. FID for LSUN Bedrooms dataset.}
\label{fig:lsun_score_comparison}
\end{center}
\end{figure*}
\subsection{GAN truncation experiments}
We demonstrate the usefulness of a single comprehensive score for hyperparameter selection. For example, as demonstrated by ~\citep{brock2018large}, truncating the latent space variable you sample from for GANs can increase sample quality at the expense of sample diversity. Through FLS, picking the optimal truncation value for a GAN can be done in a way that trades off naturally between precision/recall. Below are the FID/FLS values for various truncation values of StyleGANXL on Imagenet 128x128 (unconditional). Interestingly, the optimal selected value is lower than FID in both cases, indicating once again that FLS seems to value image quality more highly than FID.
\begin{figure*}[h!]
\begin{center}
\centerline{\includegraphics[width=\textwidth]{figures/truncations.png}}
\caption{FLS vs. FID for selecting optimal GAN truncation values.}
\label{fig:gan_truncation_experiment}
\end{center}
\end{figure*}
\subsection{Overfitting and dataset size}
We investigate the impact of dataset size on overfitting. As generative models tend to struggle with small datasets, we start with a pre-trained StyleGAN2-Ada model on FFHQ and fine-tune it on AFHQ (cat), as described in ~\citep{karras2020training}. Specifically, we split the training set of AFHQ (cat) into subsets of varying sizes (500, 1000, 2000, 4000) and fine-tune a pre-trained StyleGAN2-Ada model on each subset, using default parameters. We then get the final checkpoints after 72 hours of training and compute FLS, CTScore and AuthPct on the checkpoint of each dataset size (using as training set the subset and no the whole dataset).
\begin{figure*}[h!]
\begin{center}
\centerline{\includegraphics[width=\textwidth]{figures/overfit_comparison_AFHQ.png}}
\caption{Overfitting metric values for StyleGAN2-Ada trained on various sizes of AFHQ cat. For \% overfit Gaussians (-50\%), a positive value indicates overfitting while for the other two metrics, a positive value indicates underfitting.}
\end{center}
\end{figure*}
Interestingly, here FLS indicates there is some degree of overfitting whereas the two other metrics signal that the models are underfit. The discrepancy can potentially by the same reason provided for the transforms experiment. Due to the relatively small sizes of the train and test sets, it is possible that the generated samples are far from both which leads CTScore and AuthPct to consider them "underfit". We also investigate qualitatively below, using the overfit Gaussian methodology used previously and find evidence of overfit samples that combine the color of some training samples and the pose of others.
\begin{figure*}[h!]
\begin{center}
\centerline{\includegraphics[width=\textwidth]{figures/overfit_samples_AFHQ.png}}
\caption{Overfit samples on AFHQ. Each row corresponds to the most overfit sample for some model, the leftmost image being the generated sample. The 8 images on the right are the samples in the train set with the highest likelihood for the Gaussian corresponding to that sample. From top to bottom: 500 training samples, 1000 training samples, 2000 training samples, 4000 training samples.}
\end{center}
\end{figure*}
\clearpage
\section{Additional overfit samples}
Below are additional overfit samples detected from various models/datasets.
\begin{figure*}[h!]
\begin{center}
\centerline{\includegraphics[width=\textwidth]{figures/overfit_samples_CIFAR10.png}}
\caption{Overfit samples for CIFAR10. Each row corresponds to the most overfit sample for some model, the leftmost image being the generated sample. The 8 images on the right are the samples in the train set with the highest likelihood for the Gaussian corresponding to that sample. From top to bottom: DDPM, NVAE, DiffStyleGAN2, ImprovedDDPM, StyleGANXL, BigGAN-CR, ReACGAN}
\end{center}
\end{figure*}
\begin{figure*}[h!]
\begin{center}
\centerline{\includegraphics[width=\textwidth]{figures/overfit_samples_ImageNet.png}}
\caption{Overfit samples on ImageNet. Each row corresponds to the most overfit sample for some model, the leftmost image being the generated sample. The 8 images on the right are the samples in the train set with the highest likelihood for the Gaussian corresponding to that sample. From top to bottom: ADM, StyleGANXL, ContraGAN, SNGAN, StyleGAN2, StyleGAN3}
\end{center}
\end{figure*}
\begin{figure*}[h!]
\begin{center}
\centerline{\includegraphics[width=\textwidth]{figures/overfit_samples_LSUNBedroom256.png}}
\caption{Overfit samples on LSUN Bedroom. Each row corresponds to the most overfit sample for some model, the leftmost image being the generated sample. The 8 images on the right are the samples in the train set with the highest likelihood for the Gaussian corresponding to that sample. From top to bottom: DiffProjGAN, DiffStyleGAN2, ADM, ImprovedDDPM, LatentDiff, ProjGAN}
\end{center}
\end{figure*}
\clearpage
\section{Optimization procedure}
Selecting $\sigma_j$ for each generated sample by solving the optimization problem \ref{eq:cross_val} is non-trivial. Even with the simplifying assumption of a diagonal covariance matrix, we still need to learn one parameter per Gaussian (of which there are 10000). As the likelihood of given points comes from the $\log$ of the sum of individual Gaussians, the $\sigma_j$ cannot be optimized independently. Thus, we turn to full batch gradient descent using the Adam optimizer with the following hyperparameters:
\begin{itemize}
\item 100 steps
\item $lr=0.5$
\item Initial value for log variance: $0$
\item We use a 2-step lr scheduler, reducing the learning rate by a factor of 10 after 50 steps.
\end{itemize}
In addition, getting the likelihood assigned by each Gaussian to each point requires computing the distance between each pair $(\mathbf{x}^{\text{gen}}_i, \mathbf{x}^{\text{train}}_i)$ which is $O(n^2)$ and time-consuming. As the distances and dimensions are large (at least for our high-dimensional experiments), the exponentiation and summations were often numerically unstable. To address this, we:
\begin{itemize}
\item Compute the $O(n^2)$ distance matrix once and store it so as not to recompute it for each step of the optimization procedure.
\item Optimize the log variances instead of the variances themselves
\item Convert $\sigma_j^{-d}$ to $\exp (-d \times \log(\sigma_j)$ to be able to take advantage of a numerically stable logsumexp.
\end{itemize}
From plotting the loss, the variances almost always converged in short order (usually less than 20 steps). While we have no guarantee that these were global minima, when there were exact copies or close to exact copies, \ref{alg:FLS} would recover very low log variances, as shown in \ref{prop1}.
\clearpage
\section{Experimental Setup}
\subsection{Detecting overfitting in low dimensions}
For the overfit KDE experiment, we generate $3000$ points from the Two Moons dataset using sckit-learn ~\citep{pedregosa2011scikit} with a noise value of $0.1$. The first $2000$ points are used as the training set and the last $1000$ as test set. We fit a KDE to the train set using bandwidth values varying from $10^{-4}$ to $10$ and sample $1000$ points as generated samples before computing our score.
As for the GAN, we use a simple $2$ layer fully connected generator and discriminator with ReLU activations. We generate $1000$ samples (less than above to better be able to visually see the difference between the train and test sets) with the same $0.1$ noise value. The first $500$ are used as train set and the last $500$ as test set. We train for $10000$ steps using full batch gradient descent (learning rate of $1e-2$) on the training set with a fixed value of the latent variable $z$ for the generated samples (to encourage it to overfit). Finally, the generated samples of that fixed $z$ are the generated samples.
\subsection{Detecting overfitting in high dimensions}
\xhdr{Data copying} We take $3$ separate batches of $10000$ samples from the CIFAR10 ~\citep{krizhevsky2014cifar} train set and the entire test set. The first is used as "training set" for the purposes of our score computation, the second as validation set and the last as baseline set. The "generated samples" are a mixture of the validation set and increasingly more samples from the "training set" (with a Gaussian noise of $0.1$ added in the feature space). Finally, we get score values with respect to the test set.
\xhdr{Simple transforms}
We use standard torchvision ~\citep{torchvision2016} image transforms applied to the "training set" above and repeat the same process:
\begin{itemize}
\item \textbf{Horizontal flip}: The image is flipped horizontally.
\item \textbf{Gaussian blur}: Gaussian blur with a $(5,5)$ kernel and a $\sigma$ of $0.5$.
\item \textbf{Horizontal Flip}: Color jitter transform with blur in $[0.6, 1.4]$, contrast in $[0.6,1.4]$, saturation in $[0.6, 1.4]$ and hue in $[-0.05, 0.05]$.
\item \textbf{Center crop 30}: Center crop the image to $(30,30)$ and fill the rest with black.
\item \textbf{Center crop 24}: Center crop the image to $(24,24)$ and fill the rest with black.
\item \textbf{Random rotation}: Random rotation between $[0,45]$ degrees.
\end{itemize}
\subsection{Large scale model comparison}
For model comparison, we either use pre-trained networks provided by the respective paper authors OR pre-trained networks provided by StudioGAN ~\citep{kang2022StudioGAN}, a very impressive library that reproduces a large array of GAN models.
We generate 10000 samples for each. Due to the computational requirements of generating samples from diffusion models (often ~2 orders of magnitude higher than GANs), we resort to lowering the number of steps during sampling with aggressive timestep respacing. It is likely that with more steps, diffusion models would achieve even higher FLS values.
\xhdr{CIFAR10 models}
\begin{itemize}
\item \textbf{StudioGAN} ~\citep{kang2022StudioGAN}: We take the pre-trained models provided \href{https://huggingface.co/Mingguksky/PyTorch-StudioGAN/tree/main/studiogan_official_ckpt/CIFAR10_tailored}{here}. Specifically, if there are multiple training runs, we take the latest one and use the weights from the best checkpoint. The models that were reproduced by StudioGAN that we used are: DCGAN ~\citep{radford2015unsupervised}, WGAN-GP ~\citep{gulrajani2017improved}, SNGAN ~\citep{miyato2018spectral}, SAGAN ~\citep{zhang2019self}, ReACGAN ~\citep{kang2021rebooting}, ProjGAN ~\citep{sauer2021projected}, LSGAN ~\citep{mao2017least}, LOGAN ~\citep{wu2019logan}, BigGAN-CR ~\citep{zhang2019consistency} and ACGAN-Mod ~\citep{kang2021rebooting}.
\item \textbf{StyleGANXL} ~\citep{sauer2022stylegan}: We use the pre-trained model provided \href{https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/cifar10.pkl
}{here} and generate 10000 samples (seeds $0-10000$).
\item \textbf{StyleGAN2-ada} ~\citep{karras2020training}: We use the pre-trained model provided \href{https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada/pretrained/cifar10.pkl}{here} with default parameters (seeds $0-10000$).
\item \textbf{DiffProjGAN and DiffStyleGAN2} ~\citep{wang2022diffusion}: We use the pre-trained model provided \href{https://huggingface.co/zhendongw/diffusion-gan/resolve/main/checkpoints/diffusion-projectedgan-cifar10.pkl}{here} and \href{https://huggingface.co/zhendongw/diffusion-gan/resolve/main/checkpoints/diffusion-stylegan2-cifar10.pkl}{here} with default parameters (seeds $0-10000$).
\item \textbf{DDPM} ~\citep{ho2020denoising}: We use the diffusers library ~\citep{von-platen-etal-2022-diffusers} (specifically the default DDIM pipeline) with the model provided \href{https://huggingface.co/google/ddpm-cifar10-32}{here}.
\item \textbf{ImprovedDDPM} ~\citep{nichol2021improved}: We use the model provided \href{https://openaipublic.blob.core.windows.net/diffusion/march-2021/cifar10_uncond_50M_500K.pt}{here} with $1000$ diffusion steps, a timestep respacing of 100 and DDIM ~\citep{song2020denoising} (otherwise we use default parameters).
\item \textbf{NVAE} ~\citep{vahdat2020nvae}: We use the checkpoint provided \href{https://drive.google.com/drive/folders/1M1CDwVoV0Ltj0E20yZ8UDY3aSUX284z6}{here} with default parameters.
\end{itemize}
\xhdr{ImageNet models}
\begin{itemize}
\item \textbf{StudioGAN} ~\citep{kang2022StudioGAN}: We take the pre-trained models provided \href{https://huggingface.co/Mingguksky/PyTorch-StudioGAN/tree/main/studiogan_official_ckpt/CIFAR10_tailored}{here}. Specifically, if there are multiple training runs, we take the latest one and use the weights from the best checkpoint. The models that were reproduced by StudioGAN that we used are: ReACGAN ~\citep{kang2021rebooting}, BigGAN ~\citep{brock2018large}, SNGAN ~\citep{miyato2018spectral}, ContraGAN ~\citep{kang2020contragan}, StyleGAN2 ~\citep{karras2020analyzing}, StyleGAN3 ~\citep{karras2021alias} and SAGAN ~\citep{zhang2019self}.
\item \textbf{StyleGANXL} ~\citep{sauer2022stylegan}: We use the pre-trained model provided \href{https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/imagenet128.pkl
}{here} and generate 10000 samples with default parameters (seeds $0-10000$).
\item \textbf{ADM} ~\citep{dhariwal2021diffusion}: We use the checkpoint provided \href{https://openaipublic.blob.core.windows.net/diffusion/jul-2021/128x128_diffusion.pt}{here} with $1000$ diffusion steps, a timestep respacing of 100 and DDIM (otherwise we use default parameters).
\end{itemize}
\xhdr{LSUN models}
\begin{itemize}
\item \textbf{ProjGAN} ~\citep{sauer2021projected}: We use the pre-trained models provided \href{https://s3.eu-central-1.amazonaws.com/avg-projects/projected_gan/models/bedroom.pkl
}{here} with default parameters (seeds $0-10000$).
\item \textbf{DiffProjGAN and DiffStyleGAN2} ~\citep{wang2022diffusion}: We use the checkpoints provided \href{https://huggingface.co/zhendongw/diffusion-gan/resolve/main/checkpoints/diffusion-projectedgan-lsun-bedroom.pkl}{here} and \href{https://huggingface.co/zhendongw/diffusion-gan/resolve/main/checkpoints/diffusion-stylegan2-lsun-bedroom.pkl}{here} with default parameters (seeds $0-10000$).
\item \textbf{ADM} ~\citep{dhariwal2021diffusion}: We use the checkpoint provided \href{https://openaipublic.blob.core.windows.net/diffusion/jul-2021/lsun_bedroom.pt}{here} with $1000$ diffusion steps, a timestep respacing of 100 and DDIM (otherwise we use default parameters).
\item \textbf{ImprovedDDPM} ~\citep{nichol2021improved}: We use the checkpoint provided \href{https://openaipublic.blob.core.windows.net/diffusion/jul-2021/128x128_diffusion.pt}{here} with $1000$ diffusion steps, a timestep respacing of 100 and DDIM (otherwise we use default parameters).
\item \textbf{Latent Diffusion} ~\citep{rombach2022high}: We use the checkpoint provided \href{https://ommer-lab.com/files/latent-diffusion/lsun_bedrooms.zip}{here} with $200$ diffusion steps, DDIM and an $\eta$ of $1$.
\end{itemize}
\clearpage
\section{Proof of Proposition~\ref{prop1}}
We now prove our Proposition \ref{prop1} from the main paper.
\label{app:proof}
\propx*
\begin{proof}
Let us consider $\mathbf{x}^{\text{gen}}_k \in \{
\mathbf{x}^{\text{gen}}_i\}_{j=1}^m \cap \{\mathbf{x}_{i}^{\text{train}}\}_{i=1}^n$, we have that there exists $l$ such that $\mathbf{x}^{\text{gen}}_k=\mathbf{x}^{\text{train}}_l$ thus
\begin{align*}
&\sum_{i=1}^{n} \log \sum_{j=1}^{m}
\frac{\exp \Big({\tfrac{-||\varphi(\mathbf{x}^{\text{gen}}_j)-\varphi(\mathbf{x}^{\text{train}}_i)||^2}{2 \sigma_j^2}}\Big)}{\sigma_j^{d}}\\
&\geq \frac{\exp \Big({\tfrac{-||\mathbf{x}^{\varphi(\text{gen}}_k)-\varphi(\mathbf{x}^{\text{train}}_l)||^2}{2 \sigma_j^2}}\Big)}{\sigma_k^{d}} \\
&=
\sigma_k^{-d} \underset{\sigma_k \to 0}{\longrightarrow} \infty
\end{align*}
\vspace{-25pt}
\end{proof}
\cut{
\subsection{Truncation experiments}
\clearpage
\section{Feature spaces}
}
\section{Conclusion}
\looseness=-1
In this paper, we introduce \textbf{FLS}, a new holistic evaluation metric for deep generative models that encompasses many of the key desiderata for a sound evaluation. Specifically, FLS is easy to compute, broadly applicable to all generative models, and evaluates generation quality, diversity, as well as generalization. Moreover, we show that, unlike previous approaches, FLS provides more insights into trained generative models while being universally applicable to all model families. We empirically demonstrate both on synthetic and real-world datasets that FLS can diagnose important failure modes such as memorization/overfitting---informing practitioners on the potential limitations of generative models that generate photo-realistic images. While we focused on the domain of natural images, a fertile direction for future work is to extend FLS to other data modalities such as text, audio, or time series and also evaluating conditional generative models.
\section{Experiments}
\label{sec:experiments}
\looseness=-1
We investigate the application of FLS on generative models that span a broad category of model families, including popular GAN, Diffusion, and VAE-based generative models. For datasets, we train our models on both toy datasets such as Two Moons \citep{pedregosa2011scikit}, as well as popular natural image, benchmarks in CIFAR10 \citep{krizhevsky2014cifar}, Imagenet \citep{deng2009imagenet}, LSUN \citep{yu2015lsun}, and AFHQ \citep{choi2020stargan}.
\looseness=-1
\xhdr{Baselines}
Throughout our experiments, we rely on three representative baseline metrics to evaluate generative models: FID, $C_T$ score \citep{meehan2020non}, and AuthPct. These baselines all have the benefit of being sample-based evaluation metrics and allow for a fair comparison with FLS. The $C_T$ is a Mann-Whitney test on the distribution of distances between generated and train samples compared to the distribution of distances between train samples and test samples (negative implies overfit, positive implies underfit). The AuthPct $\in [0,100]$, derived from authenticity described in \citep{alaa2022faithful}, is simply the percentage of generated samples deemed authentic by their metric (i.e., whose distance to their nearest neighbor in the train set is larger than the distance between that nearest neighbor and its nearest neighbor in the train set).
\looseness=-1
Our experiments seek to answer the following questions:
\begin{enumerate}[label={(\bf Q\arabic*)}, topsep=0pt, parsep=0pt, leftmargin=25pt, itemsep=2pt]
\item \textbf{Detecting overfitting in low dimensions}. Does FLS detect overfitting in low-dimensional settings?
\item \textbf{Detecting overfitting in high dimensions}. Does FLS detect overfitting in high-dimensional settings?
\item \textbf{Difference with existing metrics}. How does FLS compare to existing evaluation metrics?
\end{enumerate}
\subsection{Detecting overfitting in low dimensions (Q1)}
\looseness=-1
\xhdr{Overfitting on Two Moons}
We consider two generative models trained on the Two Moons dataset. The first model is a KDE with the kernel means set to the training set points (visualized in Fig. \ref{fig:density_fit}), but the bandwidth $\sigma$ varies from low to high. For our second model, we train a simple GAN with minor modifications, e.g., large batch sizes, to encourage it to overfit. In Fig. \ref{fig:basic_experiments}, we plot our FLS and all baselines throughout training. As expected, the FLS is near zero for low levels of $\sigma$, indicating a high degree of overfitting. However, as $\sigma$ increases, so does FLS as the samples become less and less overfit before finally starting to drop as the problem shifts from overfitting to underfitting. As such, FLS matches the ability of the $C_T$ score and AuthPct, to discern overfitting when $\sigma$ is low while also providing an evaluation of sample quality as $\sigma$ increases. Similarly, for the GAN model, we find that FLS provides a good measure of the improvement in sample quality as the GAN learns the distribution. Eventually, as the GAN begins to overfit, FLS decreases (even though sample quality and diversity remain high).
\begin{figure}[h!]
\vspace{-10pt}
\centerline{\includegraphics[width=1.1\linewidth, height=1.2in]{figures/basic_experiments.png}}
\vspace{-10pt}
\caption{Comparison of metrics on synthetic examples.}
\label{fig:basic_experiments}
\vspace{-15pt}
\end{figure}
\subsection{Detecting overfitting in high dimensions (Q2)}
\looseness=-1
\xhdr{Data Copying on CIFAR10}
We now study the effect of exact-data copying on CIFAR10, a high-dimensional setting that necessitates mapping inputs to a feature space. We construct a synthetic-generated set with ``perfect'' quality and diversity but with some memorized training examples. We do so by creating a mixture of the validation set and the training set. We add a small amount of noise to the features of the copied training examples as perfectly exact copies are unlikely. Intuitively, increasing the proportion of training examples in our synthetic-generated set corresponds to more overfitting/memorization. We report our results in Fig.~\ref{fig:basic_experiments} and observe that FLS decreases as the number of copied/memorized examples increases. The less drastic decrease relative to other metrics is due to the impact of sample quality. Indeed, even with a high percentage of copied samples, the generated samples still contain a large amount of high-quality/diversity samples.
\begin{figure}[ht]
\centerline{\includegraphics[width=\columnwidth]{figures/indexed_visualized_transformations.png}}
\vspace{-15pt}
\caption{Visualized examples of the transformations.}
\label{fig:image_transformations}
\vspace{-5pt}
\end{figure}
\begin{figure*}[ht]
\centerline{\includegraphics[width=\textwidth]{figures/overfit_comparison.png}}
\vspace{-10pt}
\caption{Overfitting score comparison for CIFAR10 and Imagenet generative models. \textbf{Left:} Computing ${\mathcal{O}}$ after standardization by subtracting by $50\%$. \textbf{Mid and Right:} $C_T$ score and AuthPct (also $-50\%$) on various deep generative models.}
\label{fig:cifar10_and_imagenet_overfit_comparison}
\vspace{-5pt}
\end{figure*}
\begin{figure}[H]
\centerline{\includegraphics[width=\columnwidth]{figures/FLS_fig_5.pdf}}
\caption{When generated samples are far from both the train and test set (relative to the distance between the train and test sets) but closer to the train set, overfitting is identified by FLS but not by the baselines.}
\vspace{-5pt}
\label{fig:score_discrepancy_explanation}
\end{figure}
\looseness=-1
\xhdr{Transformed Data Copying on CIFAR10}
We now consider a slightly more realistic scenario than nearly exact data copying by applying image transformation to each copied example. We experiment with popular data augmentation techniques---e.g., cropping, blurring, color jitter, and rotations---as our main image transformation methods (see. Fig.~\ref{fig:image_transformations}). Tab.~\ref{tab:image_transformation_results} summarizes our findings.
For all transformations, FLS correctly decreases as there are more copied training samples in the pseudo-generated. However, we find the baselines fail to detect overfitting for transformations center crop and random rotation. This failure to capture overfitting can, in part, be explained by both of these scores examining whether generated samples are too close to the training set and not whether they are closer to the training set than they are to the test set (see Fig. \ref{fig:score_discrepancy_explanation}).
\begin{table}[t]
\vspace{-2mm}
\caption{ \small
Detection of overfitting by various scores for a model that produces ${\mathcal{D}}_{\text{transformed}}$, a set of transformed copies of the training set. $\Delta \texttt{score} = \texttt{score}({\mathcal{D}}_{\text{baseline}})-\texttt{score}({\mathcal{D}}_{\text{transformed}})$.
}
\label{tab:image_transformation_results}
\begin{center}
\begin{sc}
\scriptsize
\begin{tabular}{lcccr}
\toprule
Transformation & $\Delta$FLS $\uparrow$& $\Delta$CTScore $\uparrow$ & $\Delta$AuthPct $\uparrow$ \\
\midrule
Horizontal Flip (a) & 66.8 \:\: {\color{OliveGreen}\cmark} & 71.5 \:\: {\color{OliveGreen}\cmark} & 72.8 \:\: {\color{OliveGreen}\cmark} \\
Gaussian Blur (b) & 65.3 \:\: {\color{OliveGreen}\cmark} & 66.9 \:\: {\color{OliveGreen}\cmark} & 72.6 \:\: {\color{OliveGreen}\cmark} \\
Color Jitter (c) & 25.4 \:\: {\color{OliveGreen}\cmark} & 48.5 \:\: {\color{OliveGreen}\cmark} & 65.0 \:\: {\color{OliveGreen}\cmark} \\
Center Crop 30 (d) & 19.3 \:\: {\color{OliveGreen}\cmark} & 20.1 \:\: {\color{OliveGreen}\cmark} & 46.7 \:\: {\color{OliveGreen}\cmark} \\
Center Crop 24 (e) & 21.0 \:\: {\color{OliveGreen}\cmark} & -21.5 \:\: {\color{red}\xmark} & -0.5 \:\: {\color{red}\xmark} \\
Random Rotation (f) & 17.3 \:\: {\color{OliveGreen}\cmark} & -16.6 \:\: {\color{red}\xmark} & -6.6 \:\: {\color{red}\xmark} \\
\bottomrule
\end{tabular}
\end{sc}
\end{center}
\vspace{-4pt}
\end{table}
\xhdr{Detecting overfitting}
We now investigate the overfitting capabilities of deep generative models on natural image datasets. We start by attempting to disentangle the impact of overfitting on FLS by examining each fitted Gaussian and computing the difference between the train and test log-likelihoods under each Gaussian,
\begin{equation}
{\mathcal{O}}_i = \log {\mathcal{N}}({\mathcal{D}}_{\text{train}}|x_i; \hat{\sigma_i}^2I) - \log {\mathcal{N}}({\mathcal{D}}_{\text{test}}|x_i; \hat{\sigma_i}^2I).
\end{equation}
\looseness=-1
If ${\mathcal{O}}_i$ is positive, we deem the Gaussian overfit. Calculating the percentage of overfit Gaussians gives us a proxy measure of the impact of overfitting on the final FLS value. We expect FLS $\approx 50$\% when there is no overfitting and rise linearly with the amount of overfitted samples. Quantitatively, we perform a large-scale evaluation of overfitting in \ref{fig:cifar10_and_imagenet_overfit_comparison}, evaluating ${\mathcal{O}}_i$, $C_T$ score and AuthPct on a variety of models and datasets. Interestingly, StyleGANXL~\citep{sauer2022stylegan} is deemed to overfit on both datasets, an observation that the $C_T$ score and AuthPct corroborates. In addition, using FLS, we find varying degrees of overfitting behavior for other standard generative models in a similar fashion as $C_T$ score and AuthPct.
We also qualitatively evaluate these findings by comparing the discrepancy between training and test likelihoods under each Gaussian---i.e., ${\mathcal{O}}_i$---in the generated samples. By ranking them, we achieve an ordering over the generated samples that have the highest to lowest contribution to overfitting. Using this as a tool, we visualize the overfitting behavior of standard deep generative models on CIFAR10 and Imagenet in Fig.~\ref{fig:cifar10_and_imagenet_overfit_comparison}. Interestingly, we find different candidates for ``overfit'' samples than simply looking at nearest-neighbors (as depicted in \ref{fig:overfit_samples_using_FLS}). It is likely that an overfit sample will resemble a bunch of different training samples, borrowing a bit from each instead of just being close to one of them, a subtlety that is captured by FLS and not nearest-neighbor-based evaluations.
\begin{figure*}[h!]
\begin{center}
\centerline{\includegraphics[width=\textwidth, height=2.9in]{figures/updated_overfit_vs_nn.png}}
\vspace{-10pt}
\caption{Overfit samples detected using FLS vs Nearest Neighbors, illustrating the more subtle overfitting captured by FLS. (1) is the sample corresponding to the most overfit gaussian while (2) consists of the train samples with the highest likelihood under (1). We compare with (3), the generated sample closest to the training set in $\ell_2$ distance, while (4) is the $3$ closest training sample. (a) is from BigGAN-CR on CIFAR10, (b) is from DiffStyleGAN2, (c) is from StyleGANXL on Imagenet, and (d) is from ContraGAN.}
\label{fig:overfit_samples_using_FLS}
\end{center}
\vspace{-5pt}
\end{figure*}
\begin{figure*}[h!]
\vspace{-5pt}
\begin{center}
\centerline{\includegraphics[width=\textwidth, height=2.9in]{figures/metric_comparison_CIFAR10.png}}
\vspace{-10pt}
\caption{FLS vs FID score comparisons for CIFAR10 and Imagenet.}
\label{fig:imagenet_score_comparison}
\end{center}
\vspace{-15pt}
\end{figure*}
\cut{
\begin{figure*}[h!]
\includegraphics[width=0.24\linewidth]{figures/stylegan2_training_800.pdf}
\includegraphics[width=0.24\linewidth]{figures/stylegan2_training_1600.pdf}
\includegraphics[width=0.24\linewidth]{figures/stylegan2_training_6400.pdf}
\includegraphics[width=0.24\linewidth]{figures/stylegan2_training_12800.pdf}
\vspace{-10pt}
\caption{StyleGAN 2 evaluated using FLS, FID, and $\%$ Overfit Gaussians versus training dataset size over the course of training. From left to right we use batch sizes of $800, 1600, 6400, 12800$ respectively.}
\label{fig:stylegan2_training_dataset_size}
\end{figure*}
}
\cut{
\xhdr{Detecting overfit samples}
Using our FLS score, it is possible to qualitatively inspect suspected overfitting samples in the following manner: since each Gaussian in the MoG used in FLS is initialized using the generated samples, it is possible to compute the likelihoods of train and tests under each Gaussian independently---i.e., we treat one Gaussian in the MoG as the generative model and use that to compute the train and test likelihood. By comparing the discrepancy between training and test likelihoods under each Gaussian in the generated samples and then ranking them, we achieve an ordering over the generated samples that have the highest to lowest contribution to overfitting. This notion of overfitting samples is more nuanced than a simple nearest neighbor test, capturing samples that are too close to multiple training images rather than just one (as depicted in \ref{fig:overfit_samples_using_FLS}). It is likely that an overfit sample will resemble a bunch of different training samples, borrowing a bit from each instead of just being close to one of them.
This method of detecting overfit samples provides a more nuanced analysis than typical nearest-neighbor comparisons (even if they are done in a suitable feature space). Even if there might be samples that are even closer to their training set equivalent, our method looks at the ensemble of samples. It is quite likely that an overfit sample will resemble a bunch of different training samples, borrowing a bit from each instead of just being close to one of them.
}
\looseness=-1
\subsection{Difference and Correlation with FID (Q3)}
\label{sec:exp_q3}
We now investigate the relationship between FLS and FID, performing a large-scale comparison of the same set of models and datasets. For CIFAR 10 and Imagenet, we plot FLS vs. FID in Fig \ref{fig:imagenet_score_comparison} respectively and conduct a simple linear regression analysis. A corresponding plot for LSUN is presented in Appendix~\S\ref{app:additional_results}. Overall, we find evidence of a strong correlation between FLS and FID for all datasets, which highlights that FLS captures sample quality/diversity as well. However, despite this correlation, by inspecting the residuals of a standard linear regression between FID and FLS, we notice a few clear outliers. In particular, we find that certain models obtain too high of an FID score given their FLS (i.e., ``overrated" by FID).
\looseness=-1
For example, we find that NVAE \citep{vahdat2020nvae} is overrated by FID. We reconcile this fact by noting that NVAE samples tend to be more diverse but of lower quality. The discrepancy in scores indicates that, from a likelihood perspective, FLS values sample quality more than FID. We also uncover models that FID underrates. For instance, on CIFAR 10, we find that DCGAN \citep{radford2015unsupervised} is underrated, which we hypothesize is due to the simplicity of the model and the fact that it predates the FID metric and is thus not the result of DCGAN trying to optimize for FID.
\section{Evaluation of Generative Models}
Given a training dataset $\mathcal{D}_{\text{train}} = \{\mathbf{x}_i\}^n_{i=1}$ drawn from a distribution $p_{\text{data}}$, one of the key objectives of generative modeling is to train a parametric model $g$ that is able to generate novel synthetic yet high-quality samples---i.e., the distribution $p_g$ induced by the generator is close to $p_{\text{data}}$.\footnote{By close we often refer to either a divergence between the two distributions (e.g. KL, JSD) or a distance metric like Wasserstein.}
While some lines of work can evaluate generative models via their density, such an evaluation technique is only possible when one has access to the exact density in a computationally efficient manner of the considered generative model \citep{song2021maximum}. Moreover, it has been argued that the likelihood of high-dimensional inputs as an evaluation metric for generative models has some major flaws~\citep{theis2015note,nowozin2016f,le2021perfect}.
\looseness=-1
As all deep generative models of interest are capable of producing samples, an effective way to evaluate these models is via their samples. Such a strategy has the benefit of bypassing the need to compute the exact density of a sample point by the model---thus allowing for a unified setting to evaluate all models. More precisely, given ${\mathcal{D}}_{\text{gen}} = \{ \mathbf{x}^{\text{gen}} \}_{i=1}^m$ generated samples, where each $\mathbf{x}^{\text{gen}} \sim p_g$ and ${\mathcal{D}}_{\text{test}} = \{ \mathbf{x}^{\text{test}} \}_{i=1}^n$ drawn from $p_{\text{data}}$, the goal is to evaluate how ``good" the generated samples are with respect to the real data distribution.
\subsection{Sample-based metrics}
\looseness=-1
Historically, sample-based metrics for evaluating deep generative models have been based on two ideas: 1) using an Inception network \citep{szegedy2016rethinking} backbone $ \varphi$ as a feature extractor to 2) compute a notion of distance (or similarity) between the generated and the real distribution. The Inception Score (IS) and the Fréchet Inception Distance are the two most popular examples and can be computed as follows:
\begin{align}
&\text{IS:} \quad \exp\Big(\frac{1}{m} \sum_{i=1}^m KL(p_\varphi(y| \mathbf{x}^{\text{gen}}_i)||p_{d}(y)\Big) \\
&\text{FID:}\quad \|\mu_g-\mu_p\|^2
+ \Tr(\Sigma_g + \Sigma_p - 2(\Sigma_g\Sigma_p)^{1/2})
\end{align}
where $p_\varphi(y|x)$ is the probability of each class given by the Inception network $\varphi$, $p(y)$ is the ratio of each class in the real data, $\mu_g := \frac{1}{m}\sum_{i=1}^m \varphi(\mathbf{x}^{\text{gen}}_i), \mu_p := \frac{1}{n} \sum_{i=1}^n \varphi(\mathbf{x}^{\text{test}}_i)$ are the empirical means of each distribution, and $\Sigma_g:= \frac{1}{m} \sum_{i=1}^m (\mathbf{x}^{\text{gen}}_i - \mu_g)(\mathbf{x}^{\text{gen}}_i -\mu_g)^\top, \Sigma_p := \frac{1}{n}\sum_{i=1}^n (\mathbf{x}^{\text{test}}_i - \mu_p)(\mathbf{x}^{\text{test}}_i-\mu_p)^\top$ are the empirical covariances.
\looseness=-1
The popularity of IS and FID as evaluation metrics for generative models is motivated by their correlation with perceptual quality and diversity. More recently, other metrics such as KID \citep{binkowski2018demystifying} (an unbiased version of FID) and precision/recall (which disentangles sample quality and distribution coverage)~\citep{sajjadi2018assessing} have followed in their steps and added additional nuance to generative model evaluation.
However, all the above metrics share the same failure mode: overfitting is not detected. In fact, a trivial generative model that merely memorizes the training set ${\mathcal{D}}_{\text{train}}$ would get a SOTA score (within statistical uncertainty). This happens regardless of whether if it was compared to the training set or the test set. Indeed, the distance between the training set and the test set is negligible compared to the distance between generated samples and the data distribution.
\subsection{Feature Likelihood Score}
\label{sec:FLS}
We now introduce our Feature Likelihood Score (FLS) which is predicated on the belief that a proper evaluation measure for generative models should go beyond sample quality and also inform practitioners of the generalization capabilities of their trained models. While previous sample-based methods have foregone density estimation in favor of computing distances between sample statistics, we seek to bring back a likelihood-based approach to evaluating generative models. To do so, we first propose our method for overfitting a mixture of Gaussians (MoGs). Through it, we can estimate the \emph{perceptual} density of high-dimensional samples in a way that accounts for \emph{overfitting}---i.e., samples that are closer to the training data than the test data. Specifically, our method aims at attributing 1) a good density to high-quality, non-overfit images and 2) a very large density to images that have been memorized.
\subsubsection*{Overfitting Mixtures of Gaussians}
\looseness=-1
Our method consists of a simple sample-based density estimator amenable to a variety of data domains inspired by a traditional mixture of Gaussians (MoG) density estimator with a few key distinctions. It consists of the following steps:
\begin{enumerate}[itemsep=0mm]
\item Map the samples to a chosen feature space.
\item Initialize a mixture of Gaussians (MoG) using each mapped sample as a Gaussian.
\item Select individual $\sigma^2_j$ for each Gaussian using a set of training samples (also in the feature space).
\item Evaluate log-likelihood of MoG on the test set.
\end{enumerate}
\looseness=-1
\xhdr{Step 1: Map to feature space}
The first change we make is to map the inputs to some perceptually meaningful feature space. A natural choice for this is the representation space of Inception-v3 network but given recent criticisms ~\citep{kynkaanniemi2022role}, we also experiment with CLIP features. While the resulting data is still high-dimensional (e.g. $d=2048$ or $d=512$) we ensure that a larger proportion of dimensions are useful and that the resulting $\ell_2$ distances between images are more meaningful.
\looseness=-1
\xhdr{Step 2: Model the density using an MoG} As in Kernel Density Estimation (KDE), to estimate a density from some set of points $
{\mathcal{D}}_{\text{gen}} = \{\mathbf{x}^{\text{gen}}_j\}_{j=1}^m$ we center an isotropic Gaussian around each point---i.e., the mean of the Gaussian is the coordinates of the point. This means that $j$-th data point has a Gaussian $\mathcal{N}( \varphi(\mathbf{x}_j^{\text{gen}}),\,\sigma_j^2 I_d)$.
Then, to compute the likelihood of a new point $\mathbf{x}$, we simply calculate the mean likelihood assigned to that point by all Gaussians in the mixture:
\begin{equation}
p_\sigma(\mathbf{x}) = \frac{1}{m} \sum_{j=1}^m \mathcal{N}( \varphi(\mathbf{x}) | \varphi(\mathbf{x}_j^{\text{gen}}),\,\sigma_j^2 I_d)
\label{eq:MoG_density}
\end{equation}
with the convention that $\mathcal{N}( \varphi(\mathbf{x}) | \varphi(\mathbf{x}^{\text{gen}}),\,0_d)$ is a dirac at $\varphi(\mathbf{x}^{\text{gen}})$. Henceforth, we denote this MoG estimator which has fixed centers initialized to a dataset (e.g. train set, generated set) as ${\mathcal{N}}(\varphi({\mathcal{D}}); \Sigma)$, where $\Sigma$ is a diagonal matrix of bandwidths parameters---i.e. $\mathbf{\sigma}^2I$, where $\mathbf{\sigma}^2$ is a vector.
\looseness=-1
\xhdr{Step 3: Use the train set to select $\sigma^2_j$}
An important question in kernel density estimation is selecting an appropriate bandwidth $\sigma_j^2$. Overwhelmingly, a single bandwidth is selected which can either be derived statistically or by minimizing some loss through cross validation~\citep{murphy2012machine}. We depart from this single bandwidth philosophy in favor of separate $\sigma_j^2$ values for each Gaussian. To select $\sigma_j^2$, instead of performing standard cross-validation on samples from $p_g$, we fit the bandwidths using a subset of training examples $\{\varphi(\mathbf{x}_{i}^{\text{train}})\}_{i=1}^n$ by minimizing their negative log-likelihood. Specifically, we solve the following optimization problem:
\begin{equation}
\hat \sigma \in \arg\max_{\mathbf{\sigma^2}}
\sum_{i=1}^{n} \log \sum_{j=1}^{m}
\sigma_j^{-d} \exp \Big({\tfrac{-||\varphi(\mathbf{x}^{\text{gen}}_j)-\varphi(\mathbf{x}^{\text{train}}_i)||^2}{2 \sigma_j^2}}\Big)
\label{eq:cross_val}
\end{equation}
\looseness=-1
We motivate using a subset of $\{\mathbf{x}_{i}^{\text{train}}\}_{i=1}^n$ for bandwidth selection as for each element of the training set copied by the generative model, the associated $\sigma_j^2$ is vanishing. The following proposition (proof in \S\ref{app:proof}) formalizes this intuition.
\begin{mdframed}[style=MyFrame2]
\begin{restatable}{proposition}{propx}
\label{prop1}
For each $\mathbf{x}^{\text{gen}}_k \in \{\mathbf{x}_{i}^{\text{train}}\}_{i=1}^n$ we have that $\hat \sigma_j^2 = 0$ where $\hat \sigma^2$ is a solution of~\eqref{eq:cross_val}.
\end{restatable}
\end{mdframed}
\looseness=-1
Proposition \ref{prop1} implies that each element of the training set that has been memorized induces a Dirac in the MoG density~\eqref{eq:MoG_density}. Thus, the learned density is able to identify copying of training samples. More generally, if one of the generated samples is unreasonably close to a training sample, its associated $\sigma^2$ will be very small as this maximizes the likelihood of the training sample. We illustrate this phenomenon with the Two-Moons dataset~\citep{pedregosa2011scikit} in Figure~\ref{fig:density_fit}. Note that since this dataset is low-dimensional, we do not need to use a feature extractor (Step 1). In Figure~\ref{fig:density_fit} we can see that the more approximate copies of the training set appear in the generated set, the more the estimated density (using~\eqref{eq:cross_val}) contains high values around ``copies'' of the training set. As such, overfit generated samples yield an overfit MoG that does not model the distribution of real data $p_{\text{data}}$ and will yield poor (i.e., low) log-likelihood on the test set ${\mathcal{D}}_{\text{test}}$.
\looseness=-1
\begin{figure*}[ht]
\centering
\includegraphics[width=\linewidth, height=1.5in]{figures/MoG.pdf}
\vspace{-8mm}
\caption{Estimated density (in {\color{Violet}purple}) of the generated distribution using an MoG centered at the generated samples $\mathbf{x}^{\text{gen}}_i$ (in {\color{blue}blue})~\eqref{eq:MoG_density}. The selection of $\sigma_i^2$ is done via~\eqref{eq:cross_val}. The training points $\mathbf{x}^{\text{train}}_i\sim p_d$, sampled from the two-moons dataset, are represented in {\color{orange}orange}. The generated points correspond to $k$ approximates copies of the training set $\mathbf{x}^{\text{gen}}_i = \mathbf{x}^{\text{train}}_i + \mathcal{N}(0,10^{-4})\,,\, i=1,\ldots,k$ and $200-k$ independent samples from the data distribution $\mathbf{x}^{\text{gen}}_i \sim p_{d}, i=k+1,\ldots,200$. The dark areas correspond to high-density values.}
\label{fig:density_fit}
\vspace{-5pt}
\end{figure*}
\looseness=-1
\xhdr{Step 4: Evaluate MoG density} To get a quantitative evaluation of the density obtained in Step 3, we evaluate the likelihood of the ${\mathcal{D}}_{\text{test}}$ under $p_{\hat \sigma}(\mathbf{x})$. As demonstrated in Figure~\ref{fig:density_fit}, in settings with $k > 0 $, the generated samples are too close to the training set meaning that all test samples will have a low likelihood (as they are far from the center of Gaussians with low variances). Evaluation of the test set provides a succinct way of measuring the generalization performance of our generative model which is a key aspect that is lost in metrics such as IS and FID.
It is important to note that while it is indeed possible to train any other density model, an MoG offers a favorable tradeoff in being simple and scalable to large datasets while being highly interpretable as we optimize for each $\sigma^2_j$. Furthermore, a MoG density estimator is universal \citep{nguyen2020approximation}.
\cut{
\begin{algorithm}[tb]
\label{alg:FLS}
\caption{: Fit OGM}
\begin{algorithmic}
\STATE {\bfseries Input:} $x^{\text{train}}$, $x^{\text{centers}}$, $\varphi$
\STATE $x^{\text{train}} \leftarrow \varphi(x^{\text{train}})$
\STATE $x^{\text{centers}} \leftarrow \varphi(x^{\text{centers}})$
\STATE $\mathbf{\sigma^2} \leftarrow 1$
\STATE // We compute and store the $N \times M$ matrix of pairwise L2 distances so it doesn't need to be recomputed during the optimization loop
\STATE $\text{dists} \leftarrow d(x^{\text{train}}, x^{\text{centers}})$
\STATE Initialize $OGM$ with $x^{\text{centers}}, \mathbf{\sigma^2}$
\WHILE{$\mathbf{\sigma^2}$ not converged}
\STATE // Gradient descent on the NLL of the train data
\STATE $\mathbf{\sigma^2}\leftarrow \nabla_{\mathbf{\sigma^2}} OGM(x^{\text{train}})$
\ENDWHILE
\STATE // Return the fit $OGM$ and the final NLL of the train set
\STATE \textbf{return} $OGM, OGM(x^{\text{train}})$
\end{algorithmic}
\end{algorithm}
}
\begin{figure}[t]
\vspace{-5mm}
\begin{algorithm}[H]
\small
\textbf{Inputs:} $ \hat{{\mathcal{D}}}_{\text{train}}, {\mathcal{D}}, \varphi, \alpha $
\newline
\xhdr{Train} Fit MoG on $\hat{{\mathcal{D}}}_{\text{train}}$ with $\mu = \varphi({\mathcal{D}})$
\begin{algorithmic}[1]
\STATE $\Sigma = \mathbf{\sigma}^2I$ \hfill\COMMENT{// Initialize all bandwidths $\sigma^2_j = 1$}
\STATE $ \mathbb{H} = d(\varphi(\hat{{\mathcal{D}}}_{\text{train}}), \varphi({\mathcal{D}}))$ \hfill\COMMENT{// Pre-compute distance matrix.}
\WHILE{$\mathbf{\sigma}^2$ not converged}
\STATE ${\mathcal{L}} = -\log {\mathcal{N}}(\varphi(\hat{{\mathcal{D}}}_{\text{train}}) | \varphi({\mathcal{D}}); \Sigma)$
\STATE $\mathbf{\sigma}^2\leftarrow \sigma^2 - \alpha \nabla_{\mathbf{\sigma}^2} {\mathcal{L}}$ \hfill\COMMENT{// Gradient descent on NLL }
\ENDWHILE
\STATE $\hat{\Sigma} \leftarrow \mathbf{\hat{\sigma}}^2 I$ \hfill\COMMENT{// $\mathbf{\hat{\sigma}}^2$ is the bandwidth at convergence}
\STATE \textbf{return} ${\mathcal{N}} (\varphi({\mathcal{D}}); \hat{\Sigma})$ \hfill\COMMENT{// Return Trained MoG}
\end{algorithmic}
\caption{ Fitting MoGs for \textsc{FLS}}
\label{alg:FLS}
\end{algorithm}
\vspace{-5mm}
\end{figure}
\begin{figure}[ht]
\includegraphics[width=1.0\linewidth]{figures/FLS_flow_diagram.pdf}
\vspace{-15pt}
\caption{Computation procedure for FLS.}
\label{score_computation_both}
\vspace{-5pt}
\end{figure}
\subsubsection*{FLS Computation}
Now that we've established our method of density estimation for high-dimensional settings, we detail how to use it to compute our FLS score.
FLS is designed to provide a single score that takes into account \textbf{sample quality} (IS, precision, etc.), \textbf{sample diversity} (FID, recall) while also punishing generative models that \textbf{overfit}. To compute our FLS score we use $3$ sets of samples: the training set (20000 samples), the test set (10000 samples), and a set of generated samples (10000 samples).
Unless indicated otherwise, for our experiments we used the number of samples given in parentheses. We experimented with larger amounts of samples but this had a minimal impact on score values. We then map all the samples to the chosen feature space (Inception v3 or CLIP).\footnote{FLS can theoretically be used in any domain with any method for mapping inputs to a meaningful feature space. An investigation of this is beyond the scope of this paper.} Once mapped, we normalize the features to have 0 mean and unit variance before computing our scores.
We start by taking the training set and splitting it randomly into two even subsets, ${\mathcal{D}}_{\text{train}} = \hat{{\mathcal{D}}}_{\text{train}} \cup {\mathcal{D}}_{\text{baseline}}$. The first half $ \hat{{\mathcal{D}}}_{\text{train}}$ will be used to fit the MoG density estimator while the second half ${\mathcal{D}}_{\text{baseline}}$ will act as our baseline. Assuming that the training set and testing set are drawn i.i.d. from $p_{\text{data}}$, the second subset ${\mathcal{D}}_{\text{baseline}}$ serves as a reasonable proxy for samples generated by a perfect generative model. We then fit two MoG density estimators to $ \hat{{\mathcal{D}}}_{\text{train}}$. The first, ${\mathcal{N}}(\varphi({\mathcal{D}}_{\text{gen}}); \hat{\Sigma}_{\text{gen}})$, uses the generated samples as centers while the second, ${\mathcal{N}}(\varphi({\mathcal{D}}_{\text{baseline}}); \hat{\Sigma}_{\text{baseline}})$ uses the second half of the train data as centers---i.e. $\varphi({\mathcal{D}}_{\text{baseline}})$. The training procedure for the MoG is outlined in Algorithm \ref{alg:FLS}. Finally, we evaluate the log-likelihood of ${\mathcal{D}}_{\text{test}}$ under both MoGs which we denote as $nll_{\text{gen}} = \log {\mathcal{N}}(\varphi({\mathcal{D}}_{\text{test}})|\varphi({\mathcal{D}}_{\text{gen}}); \hat{\Sigma}_{\text{gen}})$ and $nll_{\text{baseline}} = \log {\mathcal{N}}(\varphi({\mathcal{D}}_{\text{test}})|\varphi({\mathcal{D}}_{\text{baseline}}); \hat{\Sigma}_{\text{baseline}})$ respectively. \textbf{FLS is then defined as:}
\begin{align}
\text{FLS}({\mathcal{D}}_{\text{gen}}) &:= \exp \left( 2 \frac{nll_{\text{baseline}} - nll_{\text{gen}}}{d} \right ) \times 100.
\label{eqn:fls_overall}
\end{align}
where $d$ is the dimension of the feature space. This is equivalent to looking at the $d^{th}$ root of the likelihood ratio. A visual depiction of the process is provided in Fig.~\ref{score_computation_both}. Intuitively, the score can be considered as a grade with a value of 100 indicating a ``perfect" generative model that does as well as a set of samples drawn from the data distribution. Lower values are indicative of problems in some of the three areas evaluated by FLS. Poor sample quality will lead to Gaussian centers that are far from the test set and thus a lower likelihood. A failure to sufficiently cover the data manifold will lead to some test samples having very low likelihoods. Finally, overfitting to the training set will yield the MoG density estimator to overfit and yield a bad likelihood value on the test set.
\section{Introduction}
Data generation and simulation are a some of the fastest-growing use cases of deep generative models, with success stories spanning the artificial intelligence spectrum \citep{karras2020analyzing, brown2020language, wu2021protein}. Despite the growth of applications---and unlike supervised or reinforcement learning---there is lack of clear consensus on an evaluation protocol that is equally applicable to any generative modeling family. With the wide-spread adoption of deep generative models and the growing concerns regarding their data privacy~\citep{carlini2023extracting, hitaj2017deep}, especially in high-stakes and industrial production environments, it is critical to not only reliably evaluate the efficacy of generative models beyond sample quality and diversity but also to diagnose potential failure modes such as memorization.
\begin{figure}[h!]
\vspace{-10pt}
\centerline{\includegraphics[width=\linewidth]{figures/headline_plot.png}}
\vspace{-10pt}
\caption{FLS for a generative model that overfits (higher is better). (a) Generated samples are low quality and do not match the underlying Two Moons data $\implies$ low FLS. (b) Generated samples are high quality, diverse, and are not overfit to the training set $\implies$ high FLS. (c) Generated samples are still high quality and diverse \textbf{but too closely resemble the training set} $\implies$ lower FLS.}
\label{fig:headline_plot}
\end{figure}
Current approaches to evaluating generative models are either limited in their applicability to certain model classes (e.g. likelihood) \citep{van2021memorization} or are one-dimensional scores that miss important facets for evaluation \citep{xu2018empirical, esteban2017real, meehan2020non}. In particular, empirically observed phenomena such as memorization, overfitting, mode collapse, and mode dropping are often overlooked in favor of purely sample quality based metrics such as FID and Inception score. While there exists a body of work \citep{webster2019detecting, alaa2022faithful, meehan2020non} dedicated to identifying memorization and overfitting in generative models these themselves have various problems such as being too dependent on nearest neighbor computations or are unable to assess sample quality directly. Thus, at present, there lacks an evaluation measure capable of assessing both sample quality and the generalization capabilities of a generative model.
\xhdr{Current Work}
We propose a new sample-based score, the Feature Likelihood Score (FLS) that captures sample quality, is as scalable as popular sample-based metrics such as FID and Inception score and, crucially, is able to \textbf{diagnose overfitting}. Intuitively, FLS is derived from the commonly used likelihood evaluation protocol but is also able to assess the generalization performance of the generative model in a similar manner to most supervised learning setups. Evaluation using FLS has many consequential benefits:
\begin{enumerate}[noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt, leftmargin=*]
\item \textbf{Interpretability:} As scores improve sample quality also improves matching intuition and interpretability.
\item \textbf{Diagnosing Overfitting:} As overfitting begins (i.e., memorization of the training set) FLS reports an inferior score \emph{despite} any drop in sample quality and diversity.
\item \textbf{Holistic Evaluation:} FLS provides a nuanced evaluation of generative models revealing that some models are overvalued by the FID metric in their (generalization) performance, while many models that have slightly higher FID are better ranked by FLS.
\item \textbf{Universal Applicability:} FLS is applicable to all generative models including popular methods like VAEs, Normalizing Flows, GANs, and Diffusion models with minimal overhead as it is computed using only samples.
\end{enumerate}
\looseness=-1
At an intuitive level, FLS achieves this goal by revisiting the vanilla likelihood metric but in the feature space of a pre-trained Inception-v3 network~\citep{szegedy2016rethinking} or a pre-trained CLIP network~\citep{radford2021learning}. As most models lack explicit densities, we model the density of the generative model in the feature space by using a mixture of isotropic Gaussians (MoG) whose means are the features of the generated samples. Unlike, conventional likelihood evaluation, FLS is purposely built to diagnose overfitting as it relies on estimating the (perceptual) likelihood of some held-out test data.
Specifically, the key step of our method is that the variance of each isotropic Gaussian is learned by maximizing the likelihood of the set of training examples that were used to train the generative model. Intuitively, the learned Gaussians collapse to Diracs whenever a generated sample is too close to a training example, as illustrated in Fig.~\ref{fig:density_fit}. We then take advantage of this overfitting by evaluating the log-likelihood of the test set. A model that produces overfit samples will yield an overfit MoG that will have a poor log-likelihood on the test set and hence be punished for its overfitting.
We demonstrate the utility of FLS by conducting extensive experiments across a large variety of generative models for the datasets CIFAR10 \citep{krizhevsky2014cifar}, Imagenet \citep{deng2009imagenet}, and LSUN \citep{yu2015lsun}. In particular, we demonstrate that FLS is able to accurately detect overfitting behavior in synthetic settings where other metrics fail \ref{sec:experiments} while for natural image datasets we show that FLS is well correlated with popular sample-based metrics like FID, demonstrating it is a good judge of sample quality. In addition, FLS is able to comment on the generalization ability of these trained models both quantitatively and qualitatively, providing an estimate of the degree of overfitting and which samples are the worst offenders. Finally, FLS sheds light on which existing pre-trained models are underrated or overrated by FID---enabling a quantitative appreciation for certain model classes such as DDPM \citep{ho2020denoising} while adding additional scrutiny to models like StyleGAN-XL \citep{sauer2022stylegan}.
\section{Related Work}
The prevalence of deep generative models and their impressive capacity to generate highly realistic data samples has led to the creation of many evaluation metrics.
\xhdr{Likelihood evaluation}
The most common metric, and perhaps most natural, is the negative log-likelihood (NLL) of the test set, whenever it is easily computable. While appealing theoretically, in most cases, the generative model doesn't provide a density (e.g. GANs) or it is only possible to compute a lower bound of the test NLL (e.g. VAEs, continuous diffusion models, etc.) \citep{burda2015importance, song2021maximum,huang2021variational}. Even when possible, log-likelihood-based evaluation suffers from a variety of pitfalls in high dimensions and may often not correlate with higher sample quality \citep{nalisnick2018deep,le2021perfect}. Indeed many practitioners have empirically witnessed phenomena such as mode-dropping, mode-collapse, and overfitting \citep{yazici2020empirical} all of which are not easily captured simply through the NLL.
\looseness=-1
\xhdr{Sample-based evaluation}
Generative models can also be evaluated purely based on the quality and diversity of their generated samples with popular sample-based metrics such as the Inception score, FID or precision/recall \citep{salimans2016improved,heusel2017gans, sajjadi2018assessing}. However, a key limitation of these metrics is that they don't differentiate between good samples and overfit samples.
\looseness=-1
\xhdr{Overfitting evaluation}
Several approaches seek to provide metrics that are capable of detecting overfitting in generative models. These scores can again be categorized based on whether one can extract an exact likelihood \citep{van2021memorization} or a lower bound to it via annealed importance sampling \citep{wu2016quantitative}.
For GANs, popular approaches include training an additional discriminator in a Wasserstein GAN that does not provide gradients to the generator \citep{adlam2019investigating} and adding a memorization score to the FID metric \citep{bai2021training}.
Alternate approaches to detect overfitting seek to find real data samples that are closest to generated samples via membership attacks \citep{liu2018generative, webster2019detecting}. Recently, non-parametric tests have been employed to detect memorization or exact data copying in generative models \citep{xu2018empirical, esteban2017real, meehan2020non}. Parametric approaches to detect data copying have also been explored such as using neural network divergences \citep{gulrajani2020towards} or using latent recovery \citep{webster2019detecting}. Finally, \citet{alaa2022faithful} propose a multi-faceted metric with a binary sample-wise test to determine if a sample is authentic or not (i.e. overfit).
| {'timestamp': '2023-02-10T02:06:37', 'yymm': '2302', 'arxiv_id': '2302.04440', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04440'} | arxiv |
\section{Introduction}\label{sec:1}
Multivariate time series forecasting has been an increasingly popular topic in various scenarios, such as electricity forecasting~\cite{Khan2020TowardsEE}, weather forecasting~\cite{Angryk2020MultivariateTS}, and traffic flow estimation~\cite{Chen2001FreewayPM}. With the scaling of computing resources and model architectures, deep learning techniques, including RNN-based~\cite{Lai2018ModelingLA} and CNN-based models~\cite{Bai2018AnEE}, have achieved better prediction performance than traditional statistical methods~\cite{Zhang2003TimeSF,Ariyo2014StockPP}. Due to the capture of long-range dependencies, Transformer~\cite{Vaswani2017AttentionIA} has been recently used to catch long-term temporal correlation in time series forecasting and has demonstrated promising results~\cite{Zhou2021InformerBE, Wu2021AutoformerDT,Liu2022PyraformerLP,Zhou2022FEDformerFE}. The overall architecture of existing Transformer-based models on time series forecasting is illustrated in Figure~\ref{fig:1}. In the embedding module, the input time series are generally fed into one 1D convolutional layer to generate temporal tokens with positional or date-specific encoding at the point level for preserving ordering information. Then the encoder will capture the temporal interaction among time points via an attention-like mechanism, and the decoder will generate the prediction sequence in one pass.
\begin{figure}[ht]
\begin{center}
\centerline{\includegraphics[width=0.8\columnwidth]{figures/Transformer.pdf}}
\caption{The overall architecture of Transformer-based models for time series forecasting. Notice that the generation of the prediction sequence in the decoder is non-autoregressive.}
\label{fig:1}
\end{center}
\vskip -0.2in
\end{figure}
\begin{figure*}[ht]
\vskip 0.2in
\centering
\subfigure[Modifications of Transformer.\label{fig:2a}]{\includegraphics[scale=0.4]{figures/Transformer_etth1.pdf}}\
\subfigure[Variants of Fourier-Net~\cite{LeeThorp2021FNetMT}.\label{fig:2b}]{\includegraphics[scale=0.4]{figures/FFT_etth1.pdf}}
\vskip -0.1in
\caption{ETTh1~\cite{Zhou2021InformerBE} forecasting results of the modifications on Transformer and variants of Fourier-Net at 96-96 setting (The length of the historical horizon is set as 96 and the prediction length is 96). The higher R-squared score indicates better performance.}
\label{fig:2}
\end{figure*}
Although these Transformer-based models perform well on long-term time series forecasting tasks, there are still some problems to be addressed. First, there is a lack of explanation about the attention mechanism for capturing temporal dependency. A simple yet effective baseline DLinear~\cite{Zeng2022AreTE} questioned whether Transformer-based models are effective for time series forecasting. Second, Transformer-based models heavily rely on additional positional or date-specific encoding to guarantee the ordering of attention score, which may disturb the capture of temporal interaction. Third, while existing Transformer-based methods almost concentrate on how to reduce the complexity of attention computation, and have designed various sparse attention mechanisms through proper selection strategies to attain $O(L\log L)$ even $O(L)$ time and memory complexity where $L$ denotes the length of input sequence. However, these methods have a bulk of additional operations beyond attention, which makes the actual running time very long. To verify the effectiveness of the attention mechanism on time series forecasting, we conduct a group of experiments on ETTh1~\cite{Zhou2021InformerBE}. Figure~\ref{fig:2a} provides the forecasting results of the modifications on the Transformer. We can see that directly replacing the attention layer with Fourier Transform maintains the forecasting performance and removing the cross-attention significantly improves it. These results indicate that the attention mechanism on time series forecasting tasks may not be that effective. Figure~\ref{fig:2b} shows that applying a simple Fourier Transform can achieve the same, even better forecasting performance compared with attention-based models without extra positional or date-specific encoding. Additionally, individually capturing temporal and channel dependencies may bring extra improvement.
\begin{figure}[h]
\vskip 0.2in
\centering
\subfigure[The redundancy of temporal information.]{\includegraphics[scale=0.4]{figures/temporal.pdf}}\
\subfigure[The redundancy across different channels.]{\includegraphics[scale=0.4]{figures/channel.pdf}}
\vskip -0.1in
\caption{The redundancy of existing multivariate time series data. \textbf{top}: Exchange rate under different sampling rates. \textbf{bottom}: Electricity consumption of three consumers.}
\label{fig:3}
\end{figure}
Moreover, due to the difference in the sampling rate and the number of sensors, the current multivariate time series data from different scenarios often vary greatly in data form and have serious redundancy. Consider one instance of collected time series data as a tensor $\mathcal{X}\in\mathbb{R}^{n\times c}$, where $n$ denotes the length of $\mathcal{X}$ and $c$ is the dimension size. It is often uncertain which one is bigger or smaller between $n$ and $c$. That is, $\mathcal{X}$ generally has the low-rank property, such that $\text{rank}(\mathcal{X})\ll\min(n,c)$. Figure~\ref{fig:3} illustrates the ubiquitous redundancy of temporal and channel information. Specifically, the redundancy in temporal information is reflected in that the original sequence and the down-sampled sequence almost maintain the same temporal characteristics. The redundancy across channels occurs in that the information described by each channel may be consistent. Motivated by the above observations, we propose a novel and general framework for multivariate time series forecasting, named MTS-Mixers. The main contributions of this paper are:
\begin{itemize}
\item We investigate the attention mechanism in time series forecasting and propose a novel and general framework named MTS-Mixers, which respectively capture temporal and channel dependencies.
\item We leverage the low-rank property of existing time series data via factorized temporal and channel mixing and attain better prediction accuracy and efficiency.
\item MTS-Mixers has achieved state-of-the-art forecasting performance on several public real-world multivariate time series datasets, yielding a 15.4\% MSE and a 12.9\% MAE reduction on average.
\end{itemize}
\section{Related Work}
Due to the ability of the attention mechanism to capture long-range dependencies, Transformer-based models have been widely used in language and vision tasks. \citet{Song2018AttendAD,Ma2019CDSACS,LI2019EnhancingTL} tried to directly apply vanilla Transformer to time series data but failed in long sequence forecasting tasks as self-attention operation scales quadratically with the input sequence length. \citet{Child2019GeneratingLS} applied sparse attention to reducing time complexity and memory usage for processing longer sequences. \citet{Zhou2021InformerBE} introduced non-autoregressive decoding to generate future time series to be predicted in one pass and designed selective attention for higher efficiency. \citet{Liu2022PyraformerLP} proposed tree structure pyramidal attention for lower complexity. To enhance the capture of temporal dependency, \citet{Wu2021AutoformerDT, Woo2022ETSformerES, Zhou2022FEDformerFE} disentangled time series data into trend and seasonality parts by removing the moving average and introduced frequency domain transformation. Recently, a simple but effective baseline~\cite{Zeng2022AreTE} questioned whether Transformers are effective for time series forecasting, reminding us to rethink the role of the attention mechanism.
Apart from the dot product attention mechanism, it is shown in Synthesizer~\cite{Tay2020SynthesizerRS}, MLP-Mixer~\cite{Tolstikhin2021MLPMixerAA}, FNet~\cite{LeeThorp2021FNetMT} and Poolformer~\cite{Diao2022MetaFormerAU} that, by replacing attention in Transformer with spatial MLP, Fourier Transform and pooling layer, the resulting models will deliver competitive performance in machine translation and computer vision domain. Unlike mentioned works above, we first investigate what we actually learn from attention-like modules in time series forecasting tasks, and then propose MTS-Mixers with factorized temporal and channel mixing to fit the inherent low-rank property of time series data.
\section{Preliminary}
\subsection{Problem definition}
Given a historical multivariate time series instance $\mathcal{X}_h=[\boldsymbol{x}_1,\boldsymbol{x}_2,\dots,\boldsymbol{x}_n]\in\mathbb{R}^{n\times c}$ with the length of $n$, time series forecasting tasks aim to predict the next $m$ steps values $\mathcal{X}_f=[\boldsymbol{x}_{n+1},\boldsymbol{x}_{n+2},\dots,\boldsymbol{x}_{n+m}]\in\mathbb{R}^{m\times c}$ across all the $c$ channels. Forecasting tasks are required to learn a map $\mathcal{F}:\mathcal{X}_h^{n\times c}\mapsto\mathcal{X}_f^{m\times c}$ where $\mathcal{X}_h$ and $\mathcal{X}_f$ are consecutive.
\subsection{Rethinking the mechanism of attention in Transformer-based forecasting models}\label{sec:3.2}
The general workflow of existing Transformer-based methods on time series forecasting tasks is illustrated in Figure~\ref{fig:1}. First, we generally utilize a 1D convolutional layer to obtain the input embedding $\mathcal{X}_\text{in}\in\mathbb{R}^{n\times d}$ from the original time series $\mathcal{X}_h\in\mathbb{R}^{n\times c}$ with the positional or date-specific encoding. Then on the encoder side, self-attention or other correlation patterns are used to capture token-level temporal similarity as
\begin{equation}
\Tilde{\mathcal{X}}=\text{softmax}(\frac{\mathcal{X}_\text{in}\cdot\mathcal{X}_\text{in}^\top}{\sqrt{d}})\cdot\mathcal{X}=R_1\cdot\mathcal{X}_\text{in},
\end{equation}
where $R_1\in\mathbb{R}^{n\times n}$ describes token-wise temporal information. A feedforward neural network with two linear layers and activation function will be applied on $\Tilde{\mathcal{X}}$ to learn channel-wise features. On the decoder side, an initialized query $Q\in\mathbb{R}^{m\times d}$ is used to generate forecasting results as
\begin{equation}
\Tilde{\mathcal{X}_f}=\text{softmax}(\frac{Q\cdot\Tilde{\mathcal{X}}^\top}{\sqrt{d}})\cdot\Tilde{\mathcal{X}}=R_2\cdot\Tilde{\mathcal{X}},
\end{equation}
where $R_2\in\mathbb{R}^{m\times n}$ describes the relationship between the input historical time series and the output prediction series. A projection layer is applied on $\Tilde{\mathcal{X}_f}$ to obtain the final forecasting target $\mathcal{X}_f\in\mathbb{R}^{m\times c}$.
In essence, Transformer-based methods for time series forecasting contain two stages: learning token-wise temporal dependency across channels, and learning a map between input time series and output forecasting results. However, as shown in Figure~\ref{fig:2}, removing self-attention or cross-attention can maintain or even improve the forecasting performance. Replacing self-attention with Fourier Transform also delivers similar results, and respectively modeling temporal and channel dependencies will further enhance it. This means what we learn from attention-like modules is temporal dependency across all channels, and cross-attention bridges the relationship between input and output sequences. Attention mechanisms may not be necessary for capturing temporal dependency. Learning the mapping between input and output sequences and disentangling the modeling of temporal and channel dependencies may lead to better forecasting performance.
\begin{figure*}[ht]
\vskip 0.2in
\begin{center}
\centerline{\includegraphics[width=2\columnwidth]{figures/MTS-Mixer.pdf}}
\caption{The overall architecture of MTS-Mixers. \textbf{Left}: the modules in the dashed box describe the general framework. \textbf{Right}: three specific implementations, where we can use attention, random matrix, or factorized MLP to capture dependencies.}
\label{fig:4}
\end{center}
\vskip -0.2in
\end{figure*}
\section{MTS-Mixers}\label{sec:4}
This section introduces MTS-Mixers, our proposed general framework for time series forecasting that respectively captures temporal and channel dependencies. The overall architecture of MTS-Mixers is shown in Figure~\ref{fig:4}, which aims to learn a map between the input $\mathcal{X}_h\in\mathbb{R}^{n\times c}$ and the output $\mathcal{X}_f\in\mathbb{R}^{m\times c}$. Notably, the input embedding module is optional. For better understanding, filters such as convolutional layers and the attention are simplified as a module for capturing temporal interaction. Then the other module for catching channel interaction is also applied, and the linear projection layer outputs the final forecasting results. Equation~(\ref{eq3}) depicts the above simplified time series forecasting process.
\begin{equation}\label{eq3}
\begin{aligned}
\mathcal{X}_h^\mathcal{T}&=\texttt{Temporal}(\texttt{norm}(\mathcal{X}_h)), \\
\mathcal{X}_h^\mathcal{C}&=\texttt{Channel}(\mathcal{X}_h+\mathcal{X}_h^\mathcal{T}), \\
\mathcal{X}_f&=\texttt{Linear}(\mathcal{X}_h^\mathcal{T}+\mathcal{X}_h^\mathcal{C}).
\end{aligned}
\end{equation}
In this paper, we provide three specific implementations of MTS-Mixers. More details of them are as follows.
\textbf{Attention-based MTS-Mixer.} As Equation~(\ref{eq4}) shows, we add the sinusoidal positional encoding to obtain the input embedding $\Tilde{\mathcal{X}_h}$. Then, the multi-head self-attention will be used to capture temporal dependency $\mathcal{X}_h^\mathcal{T}$. A feed-forward network is to learn the channel interaction $\mathcal{X}_h^\mathcal{C}$. Compared with the vanilla Transformer, we remove its decoder and use one linear layer to directly learn the map between the learned features and the prediction sequence.
\begin{equation}\label{eq4}
\begin{aligned}
\Tilde{\mathcal{X}_h}&=\texttt{norm}(\mathcal{X}_h)+\texttt{PE}(\mathcal{X}_h), \\
\mathcal{X}_h^\mathcal{T}&=\texttt{Attention}(\Tilde{\mathcal{X}_h},\Tilde{\mathcal{X}_h},\Tilde{\mathcal{X}_h}), \\
\mathcal{X}_h^\mathcal{C}&=\texttt{FFN}(\Tilde{\mathcal{X}_h}+\mathcal{X}_h^\mathcal{T}).
\end{aligned}
\end{equation}
\textbf{Random matrix MTS-Mixer.} As mentioned in Section~\ref{sec:3.2}, what we need to learn from the input $\mathcal{X}_h$ is three matrices: $T\in\mathbb{R}^{n\times n}$ describes the temporal dependency, $C\in\mathbb{R}^{c\times c}$ describes the channel dependency and the projection $F\in\mathbb{R}^{m\times n}$ with the optional bias or activation. Equation~(\ref{eq5}) demonstrates a time series forecasting process via matrix multiplication as
\begin{equation}\label{eq5}
\mathcal{X}_f=F\cdot\sigma(T)\cdot\mathcal{X}_h\cdot\phi(C),
\end{equation}
where the operators $\sigma$ and $\phi$ denote the optional added bias or activation. Because the initialization of the matrices $F$, $T$, and $C$ are controllable, we call it a random matrix MTS-Mixer. The experiments in Section~\ref{sec:5.3} analyze the impact of different methods of initialization.
\begin{table*}[ht]
\centering
\caption{Multivariate time series forecasting results. The length of the historical horizon is set as 36 for ILI and 96 for the others. The prediction lengths are \{24,36,48,60\} for ILI and \{96, 192, 336, 720\} for others. The best results are highlighted in \textbf{bold}.}
\label{tab:1}
\vskip 0.15in
\begin{small}
\setlength\tabcolsep{5.5pt}
\begin{tabular}{c|c|cc|cc|cc|cc|cc|cc|cc}
\toprule
\multicolumn{2}{c|}{Method} & \multicolumn{2}{c|}{MTS-Mixers} & \multicolumn{2}{c|}{FEDformer} & \multicolumn{2}{c|}{DLinear} & \multicolumn{2}{c|}{SCINet} &
\multicolumn{2}{c|}{Pyraformer} & \multicolumn{2}{c|}{Autoformer} & \multicolumn{2}{c}{Informer} \\
\midrule
\multicolumn{2}{c|}{Metric} & MSE & MAE & MSE & MAE & MSE & MAE & MSE & MAE & MSE & MAE
& MSE & MAE & MSE & MAE \\
\midrule
\multirow{5}{*}{\rotatebox{90}{ECL}}
& 96 & \textbf{0.146} & \textbf{0.246} & \underline{0.193} & 0.308 & 0.199 & \underline{0.284} & 0.205 & 0.312 & 0.386 & 0.449 & 0.201 & 0.317 & 0.274 & 0.368 \\
& 192 & \textbf{0.163} & \textbf{0.260} & 0.201 & 0.315 & 0.198 & \underline{0.287} & \underline{0.197} & 0.308 & 0.378 & 0.443 & 0.222 & 0.334 & 0.296 & 0.386 \\
& 336 & \textbf{0.175} & \textbf{0.273} & 0.214 & 0.329 & 0.210 & \underline{0.302} & \underline{0.202} & 0.312 & 0.376 & 0.443 & 0.231 & 0.338 & 0.300 & 0.394 \\
& 720 & \textbf{0.202} & \textbf{0.295} & 0.246 & 0.355 & 0.245 & \underline{0.335} & \underline{0.234} & 0.338 & 0.376 & 0.445 & 0.254 & 0.361 & 0.373 & 0.439 \\
\cmidrule{2-16}
& Avg. & \textbf{0.172} & \textbf{0.269} & 0.214 & 0.327 & 0.213 & \underline{0.302} & \underline{0.210} & 0.318 & 0.379 & 0.445 & 0.227 & 0.338 & 0.311 & 0.397 \\
\midrule
\multirow{5}{*}{\rotatebox{90}{Traffic}}
& 96 & \textbf{0.516} & \textbf{0.339} & \underline{0.587} & \underline{0.366} & 0.650 & 0.396 & 0.651 & 0.393 & 0.867 & 0.468 & 0.613 & 0.388 & 0.719 & 0.391 \\
& 192 & \textbf{0.521} & \textbf{0.353} & \underline{0.604} & \underline{0.373} & 0.605 & 0.378 & 0.604 & 0.372 & 0.869 & 0.467 & 0.616 & 0.382 & 0.696 & 0.379 \\
& 336 & \textbf{0.557} & \textbf{0.358} & 0.621 & 0.383 & \underline{0.612} & \underline{0.382} & 0.611 & 0.375 & 0.881 & 0.469 & 0.622 & 0.387 & 0.777 & 0.420 \\
& 720 & \textbf{0.578} & \textbf{0.369} & \underline{0.626} & \underline{0.382} & 0.645 & 0.394 & 0.649 & 0.393 & 0.896 & 0.473 & 0.660 & 0.408 & 0.864 & 0.472 \\
\cmidrule{2-16}
& Avg. & \textbf{0.543} & \textbf{0.355} & \underline{0.609} & \underline{0.376} & 0.628 & 0.388 & 0.629 & 0.383 & 0.878 & 0.469 & 0.628 & 0.391 & 0.764 & 0.415 \\
\midrule
\multirow{5}{*}{\rotatebox{90}{PeMS04}}
& 96 & \textbf{0.349} & \textbf{0.309} & \underline{0.427} & \underline{0.382} & 0.725 & 0.560 & 0.554 & 0.410 & 0.621 & 0.469 & 1.183 & 0.772 & 0.578 & 0.440 \\
& 192 & \textbf{0.378} & \textbf{0.333} & \underline{0.449} & \underline{0.396} & 0.749 & 0.577 & 0.629 & 0.446 & 0.658 & 0.491 & 1.217 & 0.799 & 0.631 & 0.466 \\
& 336 & \textbf{0.387} & \textbf{0.343} & \underline{0.464} & \underline{0.402} & 0.680 & 0.528 & 0.611 & 0.442 & 0.626 & 0.463 & 1.587 & 0.934 & 0.666 & 0.489 \\
& 720 & \textbf{0.431} & \textbf{0.363} & \underline{0.521} & \underline{0.446} & 0.750 & 0.568 & 0.713 & 0.496 & 0.711 & 0.510 & 1.696 & 0.969 & 0.752 & 0.536 \\
\cmidrule{2-16}
& Avg. & \textbf{0.386} & \textbf{0.337} & \underline{0.465} & \underline{0.407} & 0.726 & 0.558 & 0.627 & 0.449 & 0.654 & 0.483 & 1.421 & 0.869 & 0.657 & 0.483 \\
\midrule
\multirow{5}{*}{\rotatebox{90}{Exchange}}
& 96 & \textbf{0.079} & \textbf{0.197} & 0.148 & 0.278 & \underline{0.088} & \underline{0.218} & 0.142 & 0.249 & 1.748 & 1.105 & 0.197 & 0.323 & 0.847 & 0.752 \\
& 192 & \textbf{0.172} & \textbf{0.295} & 0.271 & 0.380 & \underline{0.176} & \underline{0.315} & 0.261 & 0.364 & 1.874 & 1.151 & 0.300 & 0.369 & 1.204 & 0.895 \\
& 336 & \underline{0.321} & \textbf{0.409} & 0.460 & 0.500 & \textbf{0.313} & \underline{0.427} & 0.457 & 0.490 & 1.943 & 1.172 & 0.509 & 0.524 & 1.672 & 1.036 \\
& 720 & \underline{0.842} & \textbf{0.690} & 1.195 & 0.841 & \textbf{0.839} & \underline{0.695} & 1.364 & 0.859 & 2.085 & 1.206 & 1.447 & 0.941 & 2.478 & 1.310 \\
\cmidrule{2-16}
& Avg. & \textbf{0.354} & \textbf{0.398} & 0.519 & 0.500 & \textbf{0.354} & \underline{0.414} & 0.556 & 0.491 & 1.913 & 1.159 & 0.613 & 0.539 & 1.550 & 0.998 \\
\midrule
\multirow{5}{*}{\rotatebox{90}{Weather}}
& 96 & \textbf{0.162} & \textbf{0.207} & 0.217 & 0.296 & \underline{0.196} & \underline{0.255} & 0.239 & 0.271 & 0.622 & 0.556 & 0.266 & 0.336 & 0.300 & 0.384 \\
& 192 & \textbf{0.208} & \textbf{0.250} & 0.276 & 0.336 & \underline{0.237} & \underline{0.296} & 0.283 & 0.303 & 0.739 & 0.624 & 0.307 & 0.367 & 0.598 & 0.544 \\
& 336 & \textbf{0.268} & \textbf{0.294} & 0.339 & 0.380 & \underline{0.283} & \underline{0.335} & 0.330 & 0.335 & 1.004 & 0.753 & 0.359 & 0.395 & 0.578 & 0.523 \\
& 720 & \textbf{0.346} & \textbf{0.345} & 0.403 & 0.428 & \underline{0.347} & \underline{0.383} & 0.400 & 0.379 & 1.420 & 0.934 & 0.419 & 0.428 & 1.059 & 0.741 \\
\cmidrule{2-16}
& Avg. & \textbf{0.246} & \textbf{0.274} & 0.309 & 0.360 & \underline{0.266} & \underline{0.317} & 0.313 & 0.322 & 0.946 & 0.717 & 0.338 & 0.382 & 0.634 & 0.548 \\
\midrule
\multirow{5}{*}{\rotatebox{90}{ILI}}
& 24 & \textbf{1.677} & \textbf{0.799} & 3.228 & 1.260 & \underline{2.398} & \underline{1.040} & 2.782 & 1.106 & 7.394 & 2.012 & 3.483 & 1.287 & 5.764 & 1.677 \\
& 36 & \textbf{1.470} & \textbf{0.743} & 2.679 & 1.080 & \underline{2.646} & 1.088 & 2.689 & \underline{1.064} & 7.551 & 2.031 & 3.103 & 1.148 & 4.755 & 1.467 \\
& 48 & \textbf{1.406} & \textbf{0.757} & 2.622 & 1.078 & 2.614 & 1.086 & \underline{2.324} & \underline{0.999} & 7.662 & 2.057 & 2.669 & 1.085 & 4.763 & 1.469 \\
& 60 & \textbf{1.827} & \textbf{0.862} & 2.857 & 1.157 & 2.804 & 1.146 & 2.802 & \underline{1.112} & 7.931 & 2.100 & \underline{2.770} & 1.125 & 5.264 & 1.564 \\
\cmidrule{2-16}
& Avg. & \textbf{1.595} & \textbf{0.790} & 2.846 & 1.144 & \underline{2.616} & 1.090 & 2.649 & \underline{1.070} & 7.635 & 2.050 & 3.006 & 1.161 & 5.136 & 1.544 \\
\bottomrule
\end{tabular}
\end{small}
\vskip -0.1in
\end{table*}
\textbf{Factorized temporal and channel mixing.} Given the low-rank property of time series data described in Section~\ref{sec:1}, we design the factorized temporal and channel mixing strategies to capture dependencies with less redundancy. Specifically for the time series data with the temporal redundancy, we extract the temporal dependencies as Equation~(\ref{eq6})
\begin{equation}\label{eq6}
\begin{aligned}
\mathcal{X}_{h,1},\dots,\mathcal{X}_{h,s}&=\texttt{sampled}(\texttt{norm}(\mathcal{X}_h)), \\
\mathcal{X}_{h,i}^\mathcal{T}&=\texttt{Temporal}(\mathcal{X}_{h,i})\quad i\in[1,s], \\
\mathcal{X}_h^\mathcal{T}&=\texttt{merge}(\mathcal{X}_{h,1}^\mathcal{T},\dots,\mathcal{X}_{h,s}^\mathcal{T}),
\end{aligned}
\end{equation}
where we first equidistantly downsample the original time series into $s$ interleaved subsequences. Then we individually utilize one temporal feature extractor (e.g., MLP or attention) to learn temporal information of those subsequences and merge them in the original order. For the time series data with channel redundancy, we reduce the noise of tensors corresponding to the time series in channel dimension by matrix decomposition as Equation~(\ref{eq7})
\begin{equation}\label{eq7}
\begin{aligned}
\Tilde{\mathcal{X}_h^\mathcal{C}}&=\mathcal{X}_h+\mathcal{X}_h^\mathcal{T}, \\
\Tilde{\mathcal{X}_h^\mathcal{C}}&=\mathcal{X}_h^\mathcal{C}+N\approx UV+N, \\
\end{aligned}
\end{equation}
where $N\in\mathbb{R}^{n\times c}$ represents the noise and $\mathcal{X}_h^\mathcal{C}\in\mathbb{R}^{n\times c}$ refers to the channel dependency after denoising. $U\in\mathbb{R}^{n\times m}$ and $V\in\mathbb{R}^{m\times c}$ ($m<c$) denote factorized channel interaction. We can use traditional methods such as truncated SVD~\cite{Rust1998TruncatingTS} and NMF~\cite{Geng2021IsAB} to obtain $\mathcal{X}_h^\mathcal{C}$. Here we provide a simple but effective factorizing method as
\begin{equation}\label{eq8}
\mathcal{X}_h^\mathcal{C}=\sigma(\Tilde{\mathcal{X}_h^\mathcal{C}}\cdot W_1^\top+b_1)\cdot W_2^\top+b_2,
\end{equation}
where $W_1\in\mathbb{R}^{m\times c}$, $W_2\in\mathbb{R}^{c\times m}$ and $\sigma$ is an activation function. Different from MLP-like architectures in the vision domain, here we emphasize the temporal and channel redundancy of time series data and thus propose our factorization strategies. Notably, all the variants of our proposed MTS-Mixers can be mixed in an additive fashion if necessary. In practice, we only adopt the MLP-based MTS-Mixers via factorized temporal and channel mixing for the comparison with other baselines on forecasting tasks. See Appendix~\ref{ap:3.1} for more implementation details.
\section{Experiments}
\subsection{Experimental setup}
\begin{table*}[ht]
\centering
\caption{The forecasting performance of different types of models on ECL dataset. The length of historical horizon is set as 96, and the MSE and MAE results are averaged from 4 different prediction lengths \{96, 192, 336, 720\}.}
\vskip 0.15in
\begin{small}
\begin{tabular}{wc{0.15\linewidth}|wc{0.28\linewidth}|wc{0.22\linewidth}|wc{0.07\linewidth}wc{0.07\linewidth}}
\toprule
Backbone & Interaction capture & Low-rank property usage & MSE & MAE \\
\midrule
\multirow{11}{*}{MTS-Mixers} & None & $\times$ & 0.215 & 0.304 \\
& $+$ Temporal MLP & $\times$ & 0.189 & 0.280 \\
& $+$ Channel MLP & $\times$ & 0.185 & 0.285 \\
& $\dagger$ Factorized MLP & $\surd$ & \textbf{0.172} & \textbf{0.269} \\
\cmidrule{2-5}
& Attention & $\times$ & 0.215 & 0.316 \\
& $\dagger$ Factorized Attention & $\surd$ & 0.206 & 0.309 \\
& $+$ Channel Factorization & $\surd$ & 0.198 & 0.302 \\
\cmidrule{2-5}
& Random Matrix & $\times$ & 0.201 & 0.287 \\
& Identity Matrix & $\times$ & 0.201 & 0.286 \\
& $\dagger$ Factorized Matrix & $\surd$ & 0.195 & 0.286 \\
& $+$ Channel Factorization & $\surd$ & 0.192 & 0.283 \\
\midrule
\multirow{2}{*}{FEDformer} & Autocorrelation + DWT & $\surd$ & 0.214 & 0.327 \\
& $+$ Channel Factorization & $\surd$ & 0.205 & 0.319 \\
\midrule
\multirow{2}{*}{SCINet} & Tree-Conv & $\surd$ & 0.210 & 0.318 \\
& $+$ Channel Factorization & $\surd$ & 0.197 & 0.295 \\
\bottomrule
\end{tabular}
\end{small}
\vskip -0.1in
\label{tab:2}
\end{table*}
\textbf{Datasets.} We conduct extensive experiments on several public real-world benchmarks, covering economics, energy, traffic, weather, and infectious disease forecasting scenarios. Here is a detailed description of the datasets.
(1)
ECL\footnote{https://archive.ics.uci.edu/ml/datasets/} records the hourly electricity consumption of 321 customers from 2012 to 2014.
(2) ETT (Electricity Transformer Temperature)~\citep{Zhou2021InformerBE} consists of the data collected from electricity transformers, recording six power load features and oil temperature.
(3) Traffic\footnote{http://pems.dot.ca.gov/} contains the change of hourly road occupancy rates measured by hundreds of sensors on San Francisco Bay area freeways, which is collected from the California Department of Transportation.
(4) PeMS04~\cite{Chen2001FreewayPM} records the change of traffic flow at 307 sensors in the Bay Area over 2 months from Jan 1st, 2018 to Feb 28th, 2018.
(5) Weather\footnote{https://www.ncei.noaa.gov/data/local-climatological-data/} contains 21 meteorological indicators like humidity and pressure in the 2020 year from nearly 1600 locations in the U.S.
(6) Exchange~\citep{Lai2018ModelingLA} is a collection of exchange rates among eight different countries from 1990 to 2016.
(7) ILI\footnote{https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html} records the weekly influenza-like illness (ILI) patients data from Centers for Disease Control and Prevention of the United States between 2002 and 2021, describing the ratio of patients observed with ILI and the total number of patients.
For a fair comparison, we follow the same standard protocol and split all forecasting datasets into training, validation, and test sets by the ratio of 6:2:2 for the ETT dataset and 7:1:2 for the other datasets.
\textbf{Baselines.} We select six baseline methods for comparison, including four latest state-of-the-art Transformer-based models: Informer~\cite{Zhou2021InformerBE}, Autoformer~\cite{Wu2021AutoformerDT}, Pyraformer~\cite{Liu2022PyraformerLP}, FEDformer~\cite{Zhou2022FEDformerFE} and two latest non-Transformer models SCINet~\cite{liu2022scinet} and DLinear~\cite{Zeng2022AreTE}. All the baselines follow the same evaluation protocol for a fair comparison. See Appendix~\ref{ap:3.2} for more details.
\textbf{Implementation details.} Our method is trained with the L2 loss, using the Adam optimizer~\citep{Kingma2015AdamAM}. The training process is early stopped within 10 epochs. MSE $\frac{1}{n}\sum_{i=1}^n(\boldsymbol{y}-\boldsymbol{\hat{y}})^2$ and MAE $\frac{1}{n}\sum_{i=1}^n\vert\boldsymbol{y}-\boldsymbol{\hat{y}}\vert$ are adopted as evaluation metrics on all the benchmarks. All the models are implemented in PyTorch~\citep{Paszke2019PyTorchAI} and trained/tested on a single Nvidia A100 40GB GPU for three times. See Appendix~\ref{ap:3} for more experimental details and hyper-parameters setting.
\begin{figure*}[ht]
\vskip 0.2in
\begin{center}
\centerline{\includegraphics[width=2\columnwidth]{figures/sampling.pdf}}
\caption{The impact of the hyper-parameter $s\in\{1,2,3,4,6,8,12\}$ which corresponds to the number of interleaved subsequences after downsampling the original time series data under the 96-96 setting. A lower MSE means better performance.}
\label{fig:5}
\end{center}
\vskip -0.2in
\end{figure*}
\subsection{Main results}
To fairly compare the forecasting performance, we follow the same evaluation protocol, where the length of the historical horizon is set as 36 for ILI and 96 for the others. The prediction lengths are \{24,36,48,60\} for ILI and \{96, 192, 336, 720\} for others. Table~\ref{tab:1} summarizes the results of multivariate time series forecasting on six datasets. The best results are highlighted in bold and the second best is underlined. MTS-Mixers achieves consistent state-of-the-art performance in all benchmarks. Especially compared with previous state-of-the-art results, MTS-Mixers yields a \textbf{18.1\%} averaged MSE reduction in ECL, \textbf{10.8\%} in Traffic, \textbf{17.0\%} in PeMS04, comparable results in Exchange, \textbf{7.2\%} in Weather and \textbf{39.0\%} in ILI. The full benchmarks on the ETT are provided in Appendix~\ref{ap:1}. See Appendix~\ref{ap:2} for more results of univariate time series forecasting. Note that the strong baseline FEDformer generally performs well on large datasets while DLinear performs well on small datasets. MTS-Mixers outperforms in all benchmarks and prediction length settings, implying its strength in various real-world scenarios.
\subsection{Ablation studies}\label{sec:5.3}
In this section, the ablation experiments are conducted, aiming at investigating: (1) the forecasting performance of the variants of MTS-Mixers; (2) the impact of factorized modules applied on other types of models, and (3) the detailed settings of temporal and channel factorization.
\textbf{Variants of MTS-Mixers.}
Table~\ref{tab:2} summarizes the forecasting performance of the variants of MTS-Mixers and other types of models on the ECL dataset over four different prediction lengths. Notice that the "None" interaction capture refers to a simple linear layer, which has been also mentioned in~\cite{Zeng2022AreTE}. In general, our proposed MTS-Mixers based on MLP, attention, and random matrix all achieve better results than previous works, which verifies the effectiveness of this general framework on multivariate time series forecasting. All the variants of MTS-Mixers can gain consistent promotion via temporal and channel factorization, verifying that our proposed factorized strategies can be generalized to other models for capturing better temporal and channel interactions. Specifically, MTS-Mixers based on factorized MLP achieves the best prediction results, while the factorized attention outperforms the previous state-of-the-art Transformer-based models. MTS-Mixers based on factorized MLP does not need any positional or date-specific embedding, which guarantees the capture of temporal characteristics with less distortion. MTS-Mixers based on factorized attention outperforms vanilla attention with fewer parameters because the points in the subsequences after downsampling have more semantic information than before, which alleviates the over-fitting problem. Surprisingly, MTS-Mixers based on random matrix achieves better results than attention, which further explains the non-necessity of attention mechanism in the capture of the temporal dependency. Note that the "identity" means the parameters of the random matrix are initialized to the identity matrix, which indicates the initialization of the random matrix has slight effects on the forecasting performance.
Notably, some methods like FEDformer and SCINet also have tried to utilize the low-rand property of time series data. Specifically, FEDformer determines required features in the frequency domain through random selection to obtain sparser temporal information. SCINet also applies downsampling to the original time series, recursively generating odd and even subsequences in a tree structure to learn multi-scale temporal dependencies. We apply the channel factorization to them and also achieve a consistent promotion.
\begin{table*}[ht]
\centering
\caption{Running time (seconds) analysis for Transformer-based methods at different phases on the ECL dataset.}
\vskip 0.15in
\begin{small}
\begin{tabular}{c|c|cccccc}
\toprule
\multirow{2}{*}{Phase} & \multirow{2}{*}{H} & MTS-Mixers & MTS-Mixers & \multirow{2}{*}{FEDformer} & \multirow{2}{*}{Autoformer} & \multirow{2}{*}{Informer} & \multirow{2}{*}{Transformer} \\
& & (MLP) & (attention) & \\
\midrule
\multirow{4}{*}{Training} & 96 & 10.3 $\pm$ 0.4 & 12.1 $\pm$ 0.7 & 72.4 $\pm$ 4.8 & 29.1 $\pm$ 0.7 & 24.4 $\pm$ 0.7 & 20.6 $\pm$ 0.9 \\
& 192 & 12.0 $\pm$ 0.4 & 14.5 $\pm$ 0.3 & 81.0 $\pm$ 3.6 & 31.4 $\pm$ 0.4 & 28.5 $\pm$ 1.1 & 22.8 $\pm$ 0.5 \\
& 336 & 14.8 $\pm$ 0.3 & 17.2 $\pm$ 0.1 & 100.2 $\pm$ 3.1 & 38.9 $\pm$ 0.5 & 33.2 $\pm$ 0.2 & 27.5 $\pm$ 0.8 \\
& 720 & 21.2 $\pm$ 0.6 & 23.0 $\pm$ 0.4 & 139.9 $\pm$ 1.0 & 65.0 $\pm$ 0.8 & 44.0 $\pm$ 1.1 & 39.0 $\pm$ 0.1 \\
\midrule
\multirow{4}{*}{Inference} & 96 & 10.3 $\pm$ 0.5 & 9.4 $\pm$ 1.3 & 13.8 $\pm$ 0.3 & 12.5 $\pm$ 0.2 & 10.7 $\pm$ 1.3 & 10.5 $\pm$ 1.2 \\
& 192 & 12.8 $\pm$ 0.7 & 11.7 $\pm$ 0.4 & 18.6 $\pm$ 0.6 & 17.9 $\pm$ 1.3 & 16.1 $\pm$ 1.3 & 15.1 $\pm$ 1.1 \\
& 336 & 16.6 $\pm$ 0.9 & 17.0 $\pm$ 0.8 & 26.0 $\pm$ 0.7 & 27.5 $\pm$ 0.3 & 21.3 $\pm$ 1.5 & 21.0 $\pm$ 1.7 \\
& 720 & 26.2 $\pm$ 0.5 & 26.7 $\pm$ 0.6 & 44.9 $\pm$ 2.2 & 48.3 $\pm$ 2.2 & 40.1 $\pm$ 3.6 & 36.6 $\pm$ 0.2 \\
\bottomrule
\end{tabular}
\end{small}
\vskip -0.1in
\label{tab:3}
\end{table*}
\textbf{Temporal factorization.}
Figure~\ref{fig:5} demonstrates the impact of the hyper-parameter $s\in\{1,2,3,4,6,8,12\}$ which corresponds to the number of interleaved subsequences after downsampling the original time series data. Both MTS-Mixers based on MLP and attention achieve better forecasting performance after using temporal factorization. Notably, different datasets generally have different optimal $s$ because they are collected from various scenarios and sensors with particular sampling rates. MTS-Mixers based on attention can obtain more promotions with larger $s$ because it yields more semantic points with less redundancy.
To further improve the efficiency of temporal factorization, we can use only one temporal feature extractor (i.e. shared parameters) for different downsampled subsequences. As Table~\ref{tab:4} shows, parameter-sharing temporal factorization can significantly reduce the parameter quantity with a trade-off.
\begin{table}[htbp]
\caption{The forecasting resutls of MTS-Mixers with shared parameters or not on the ETTm1 96-96 setting.}
\label{tab:4}
\vskip 0.15in
\begin{center}
\begin{small}
\begin{tabular}{c|c|cc|c}
\toprule
Backbone & $s$ & MSE & MAE & params. \\
\midrule
MLP & 1 & 0.333 & 0.370 & 0.27M \\
MLP & 8 & 0.319 & 0.357 & 0.28M \\
MLP (shared) & 8 & 0.360 & 0.391 & 0.10M \\
\midrule
Attention & 1 & 0.358 & 0.389 & 4.23M \\
Attention & 8 & 0.347 & 0.382 & 33.77M \\
Attention (shared) & 8 & 0.348 & 0.383 & 4.23M \\
\bottomrule
\end{tabular}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
\begin{table}[htbp]
\caption{The forecasting resutls of MTS-Mixers with different channel factorization strategies on the ECL 96-96 setting.}
\label{tab:5}
\vskip 0.15in
\begin{center}
\begin{small}
\begin{tabular}{c|cc}
\toprule
Decomposition & MSE & MAE \\
\midrule
None & 0.179 & 0.275 \\
Truncated SVD~\cite{Rust1998TruncatingTS} & 0.162 & 0.254 \\
NMF~\cite{Geng2021IsAB} & 0.159 & 0.251 \\
Channel Drop~\cite{Kong2021ReflashDI} & 0.164 & 0.256 \\
Factorized MLP (ours) & 0.146 & 0.246 \\
\bottomrule
\end{tabular}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
\textbf{Channel factorization.} As mentioned in Section~\ref{sec:4}, here we study the effects of other decomposition methods on channel factorization. Table~\ref{tab:5} provides four denoising strategies, which all successfully alleviate the redundancy across channels and achieve higher prediction accuracy. Specifically, we only retain 10\% of the maximum singular value in truncated SVD and follow the same setting of NMF in~\citet{Geng2021IsAB}. As for channel drop, we randomly discard 10\% channels and set them as 0. The experiments prove the necessity of channel factorization in time series forecasting.
\subsection{Model analysis}
\textbf{Prediction patterns analysis.} As Figure~\ref{fig:6} shows, we investigate what patterns the models learn in forecasting tasks. Specifically, most of the heads in attention of vanilla Transformer may hardly capture any useful information. Instead, the variants of MTS-Mixers consistently learn the similar mapping matrix with periodic characteristics. We provide additional analysis and visualisation of weights for other datasets in Appendices~\ref{ap:4} and~\ref{ap:5}.
\begin{figure}[h]
\vskip 0.2in
\centering
\subfigure[Visual analysis of Transformer attention on ECL.]{\includegraphics[scale=0.34]{figures/ecl_trans.pdf}}\
\subfigure[Visual analysis of MTS-Mixers on ECL.]{\includegraphics[scale=0.34]{figures/ecl_mixing.pdf}}
\vskip -0.1in
\caption{The visual analysis of Transformer and MTS-Mixers on the ECL. Only one layer of the encoder is used for each model.}
\label{fig:6}
\end{figure}
\textbf{Runtime analysis.} We conduct runtime analysis for Transformer based methods on the ECL dataset. Each of them is run three times for one epoch. As Table~\ref{tab:3} shows, our proposed MTS-Mixers achieve better efficiency in the training and inference stages. Although some previous works have emphasized their contribution to reducing the complexity of attention, their operational efficiency is not high due to a bulk of additional processing such as Wavelet Transform, reminding us to challenge their claimed efficiency.
\section{Conclusion}
This paper proposes MTS-Mixers, a general framework for multivariate time series forecasting. We conducted an extensive study to investigate the real contribution and deficiencies of attention mechanisms on the performance of time series forecasting. The experimental results have demonstrated that attention is unnecessary for capturing temporal dependencies, and the redundancy in time series data affects the forecasting performance. Furthermore, our proposed temporal and channel factorization strategies leverage the low-rank property of time series data and have achieved state-of-the-art results on several real-world datasets with higher efficiency. Model analysis on patterns that the models have learned indicates that the mapping between the input and output sequences may be the key we need.
| {'timestamp': '2023-02-10T02:08:44', 'yymm': '2302', 'arxiv_id': '2302.04501', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04501'} | arxiv |
\section{Extra Experiments for FLAC}
\label{sec:experimentApp}
\subsection{Effect of Network Delays on FLAC}
\label{sec:YCSBVaryNetworkDelay}
Figure \ref{fig:delay} presents the throughput and latency of {\ensuremath{\textsf{FLAC}}}, 2PC, 3PC,
C-PAC, EC under the varying settings of network delay.
{\ensuremath{\textsf{FLAC}}} performs better than all other protocols when the network delay is
higher than 5ms, and its advantage over the others increases as the network delay
increases.
As the network delay increases from 5ms to 40ms, {\ensuremath{\textsf{FLAC}}} achieves a 31.0\% to
49.6\% increase in throughput and 34.4\% to 59.0\% decrease in latency compared
to EC and 2PC.
There are two reasons for this achievement of {\ensuremath{\textsf{FLAC}}}.
Firstly, {\ensuremath{\textsf{FLAC}}} mainly run the protocol {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} in this failure-free
environment.
Secondly, {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} can commit transactions more efficiently with lesser message
delays on the participant side than all other protocols (Table~\ref{tab:cp}).
In this experiment, all the protocols exhibit performance degradation as the
network delay increases.
This phenomenon is due to the fact that when the network delay is higher, the
transaction blocking and execution time will be longer.
\begin{figure}[h]
\centering
\subfigure[Throughput.]{%
\includegraphics[width=0.48\linewidth]{figures/delay_thoughput.pdf}
\label{fig:delay-th}}
\subfigure[Tail latency.]{%
\includegraphics[width=0.48\linewidth]{figures/delay_latency.pdf}
\label{fig:delay-la}}
\vspace{-1em}
\caption{Performance of all protocols under the YCSB-like
micro-benchmark with varying network delay.}
\label{fig:delay}
\end{figure}
\subsection{Sensitivity Analysis of All Protocols}
In the previous experiments, all protocols were evaluated with only cross-shard
transactions, which is the default setting of the YCSB-like micro-benchmark
(Section \ref{setup}).
However, it is well-known that cross-shard transactions can affect the system
throughput due to its blocking effect on single-shard transactions
\cite{gupta2018easycommit, maiyya2019unifying, chrysanthis1998recovery}.
Therefore, we conduct this experiment to assess the protocols' performance in a
mixed setting where both single-shard and cross-shard transactions can occur,
with the cross-shard transaction percentage ranging from 0\% (all transactions
are single-shard) to 100\% (all transactions are cross-shard).
As can be seen in Figure~\ref{fig:cross},
when all transactions are single-shard, all protocols achieve the same high
throughput and low latency since single-shard transactions are committed directly~\cite{gupta2018easycommit, lu2021epoch}.
When the percentage of cross-shard transactions increases, the throughput of all
the protocols decrease due to the long occupation of resources by such
transactions.
In this experiment, {\ensuremath{\textsf{FLAC}}} can still perform better than all other protocols in
all settings when there are cross-shard transactions.
Again, this result is due to the low latency of the protocol {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} on
the participant side: it requires only 1 message delay on the participant, while
2PC, 3PC, EC, C-PAC require at least 2 message delays (Table~\ref{tab:cp}).
\subsection{Message Complexity Side-Effects of FLAC}
As mentioned in Section~\ref{sec:comparison}, the network bandwidth could become the bottleneck as the number of involved participants increases.
Our experiment in Section~\ref{exp} has shown that {\ensuremath{\textsf{FLAC}}}'s throughput gets close to others as 10 participants are involved in transactions.
To further demonstrate the side effect of increased message complexity, we let transactions only access one record on each participant and added the number of participants to 15, to amplify the impact of message complexity.
It can be observed that {\ensuremath{\textsf{FLAC}}} and EC both perform better than others before 10 participants per transaction but act slightly worse than 2PC in throughput afterwise (0.97x and 0.90x for {\ensuremath{\textsf{FLAC}}} and EC, respectively).
It presents the side-effect of higher message complexity of two protocols.
Such a problem does not affect {\ensuremath{\textsf{FLAC}}} under most OLTP workloads since the number of participants per transaction is less than 10 in practice~\cite{council2010tpc, gupta2018easycommit}.
\begin{figure}[ht]
\centering
\subfigure[All transactions.]{%
\includegraphics[width=0.48\linewidth]{figures/cross_thoughput.pdf}
\label{fig:cross-th}}
\subfigure[Only single-shard transactions.]{%
\includegraphics[width=0.48\linewidth]{figures/cross_thoughput_single.pdf}
\label{fig:cross-only}}
\caption{Performance under the YCSB-like micro-benchmark, with
varying percentage of cross-shard transactions.}
\label{fig:cross}
\end{figure}
\begin{figure}[htbp]
\centering
\subfigure[Throughput.]{\includegraphics[width=0.48\linewidth]{figures/scale_more_thoughput.pdf}
\label{fig:scale-more-th}}
\subfigure[Tail latency.]{%
\includegraphics[width=0.48\linewidth]{figures/scale_more_latency.pdf}
\label{fig:scale-more-la}}
\caption{Performance under the YCSB-like micro-benchmark with
varying numbers of participants.}
\label{fig:scale-more}
\end{figure}
\subsection{Comparison between Non-Replicated and Replicated Protocols}
This experiment shows a comparison between {\ensuremath{\textsf{FLAC}}} and a state-of-the-art replicated commit protocol G-PAC~\cite{maiyya2019unifying}.
We reuse the replicated setting in G-PAC's original paper~\cite{maiyya2019unifying} to replicate all three shards across three participant nodes.
As Figure~\ref{fig:ycsb-more} shows, G-PAC has 65.3\% lower throughput with 2.68x latency compared to {\ensuremath{\textsf{FLAC}}}.
It reveals that replicated commit protocols like G-PAC achieves higher availability at the cost of normal transaction processing efficiency.
Thus, we design {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} for non-replicated settings and let it only involve one node per replica group when customized for replicated systems (Section~\ref{app:discussion}).
\begin{figure}[htbp]
\centering
\subfigure[Throughput.]{\includegraphics[width=0.48\linewidth]{figures/ycsb_thoughput_replicated.pdf}
\label{fig:ycsb-more-th}}
\subfigure[Tail latency.]{%
\includegraphics[width=0.48\linewidth]{figures/ycsb_latency_replicated.pdf}
\label{fig:ycsb-more-la}}
\caption{Performance under the YCSB-like micro-benchmark with
varying numbers of clients.}
\label{fig:ycsb-more}
\end{figure}
\subsection{Performance of All Protocols on TPC-C Benchmark of Real Workloads}
Figure~\ref{fig:tpc} presents the performance of all protocols on the TPC-C
benchmark of real workload.
In this experiment, {\ensuremath{\textsf{FLAC}}} still achieves the best performance.
In particular, it achieves 1.35x to 2.22x throughput speedup compared with the
other protocols, while its tail latency is only 35.4\% to 65.0\% of them.
Compared to the previous experimental results on the YCSB-like micro-benchmark
(Figure~\ref{fig:ycsb}), all the protocols achieve higher throughput and lower
latency for the TPC-C benchmark.
An explanation for this result is that the TPC-C benchmark contains many
single-shard transactions, which can be quickly processed by all protocols,
unlike the YCSB-like micro-benchmark which contains only cross-shard
transactions, as described earlier in Section \ref{setup}.
\begin{figure}[ht]
\centering
\subfigure[Throughput.]{%
\includegraphics[width=0.48\linewidth]{figures/mi_tpc_thoughput.pdf}
\label{fig:tpc-th}}
\subfigure[Tail latency.]{%
\includegraphics[width=0.48\linewidth]{figures/mi_tpc_latency.pdf}
\label{fig:tpc-la}}
\vspace{-1em}
\caption{Performance of all protocols under TPC-C macro-benchmark,
with varying numbers of clients.}
\label{fig:tpc}
\end{figure}
\section{Failure Handling, Correctness Proofs, and Replication Support}
\input{chapters/termination-and-failure.tex}
\subsection{Failure Detection Rules of RLSM Manager}
\label{sec:failureDetectionProof}
We list detailed proofs and explanations for all failure detections in Algorithm~\ref{alg:rlsm}.
\subsubsection{Failure detection for {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} or {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} by missing results.}
A crash or a network failure can be detected by checking if the coordinator does
not receive all participants' execution results, i.e., some results are missing,
as formalized in Proposition \ref{prop:CrashFailureFlacFF}.
\begin{proposition}[Failure detection by missing results]
\label{prop:CrashFailureFlacFF}
In an execution of {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} or {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} for a transaction $T$, if the coordinator
$C^*$ is alive and fails to collect the transaction result from a participant
$C_i$, that is $|\ensuremath{\mathcal{R}_T}| < |\ensuremath{\mathcal{C}_T}|$, then there exist a failure in
$C_i$'s execution.
%
\end{proposition}
\begin{proof}
By contradiction, assume that there is no failure happened in the execution of
$C_i$.
%
Since there is no crash failure and the protocol is executed non-blockingly in \textit{propose} phase,
$C_i$ will be able to vote and make a decision, and send back its result to
the coordinator.
%
Since there is no network failure, $C_i$'s result will reach the coordinator
within the network timeout.
%
This result contradicts the hypothesis that $C^*$ fails to collect the
result of $C_i$.
%
\end{proof}
Note that if the current protocol is {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, the failure type detected by
Proposition~\ref{prop:CrashFailureFlacFF} is agnostic before the crash timeout.
In this case, the RLSM manager will first input CF events to the RLSMs of
non-responsive participants, who are likely to crash (line
\ref{line:AlgRlsmCFDetect}).
Then, it will input NF events to the RLSMs of participants who reply late (line
\ref{line:AlgRlsmAsyNF4FF}), since these late replies are likely caused by
network failures.
When the current protocol is {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, which tolerates crash failures, then
failures detected by Proposition \ref{prop:CrashFailureFlacFF} can only be
network failures.
Like the previous case, the RLSM manager can just input NF events to the
RLSMs of participants who reply late (line \ref{line:AlgRlsmAsyNF4CF}).
\subsubsection{Failure detection for {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} by {\ensuremath{Undecide}} decision.}
Network failures between participants in an execution {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} can be detected by
examining if the result $\result{\ensuremath{Yes}, \ensuremath{Undecide}}$ is returned to the
coordinator (lines
\ref{line:AlgRlsmCheckNF4flacFF}--\ref{line:AlgRlsmNF4flacFF}), as formalized as
in Proposition \ref{prop:NetworkFailureFlacFF} below.
\begin{proposition}[Failure detection for {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} by {\ensuremath{Undecide}} decision]
\label{prop:NetworkFailureFlacFF}
In an execution of {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} for a transaction $T$, if all nodes can return
their results ($|\ensuremath{\mathcal{R}_T}| = |\ensuremath{\mathcal{C}_T}|$), and a node $C_i$ returns
$\result{\ensuremath{Yes}, \ensuremath{Undecide}}$, then a network failure occurs during the
execution.
\end{proposition}
\begin{proof}
Assume that there is no network failure in the transaction execution.
%
Firstly, according to Algorithm~\ref{alg:LP1}, when $C_i$ returns
{\result{\ensuremath{Yes}, \ensuremath{Undecide}}}, it did not receive all the votes of other
participants.
%
Secondly, since $|\ensuremath{\mathcal{R}_T}|$ = $|\ensuremath{\mathcal{C}_T}|$, then no participant crashed in
the \textit{propose} phase.
%
Since there is no network failure, votes from all other participants after
being broadcasted will manage to reach $C_i$ (Algorithm~\ref{alg:LP1}).
%
This result contradicts the earlier result that $C_i$ did not receive all
the votes of other participants.
\end{proof}
Note that during the failure detection for {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, the RLSM manager can
pinpoint crash failures to specific participants.
However, if a network failure occurs, it cannot identify precisely the involving
participants, since network failure can happen among a set of nodes.
In this case, the RLSM manager will shift all the participants' states to the
network-failure level (line \ref{line:AlgRlsmNF4flacFF}).
\subsubsection{Network failure detection for {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} by {\ensuremath{Abort}} decision.}
Network failures in the execution of {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} can be detected by checking if
there exist aborted transactions that should be committed (lines
\ref{line:AlgRlsmCheckNF4flacCF}--\ref{line:AlgRlsmNF4flacCF}).
We formalize this detection in Proposition
\ref{prop:NetworkFailureFlacCFFromAborts}.
\begin{proposition}[Network Failure Detection for {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}]
\label{prop:NetworkFailureFlacCFFromAborts}
In the execution of {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} for a transaction, if the coordinator can collect
the results from all participants ($|\ensuremath{\mathcal{R}_T}| = |\ensuremath{\mathcal{C}_T}|$), and there
exists a participant returns $\result{\ensuremath{Yes}, \ensuremath{Abort}}$, while no participant
votes $\ensuremath{No}$, then there exist network failures during the execution.
\end{proposition}
\begin{proof}
By contradiction, suppose that there is no network failure.
%
Since the coordinator can collect all the results ($|\ensuremath{\mathcal{R}_T}| = |\ensuremath{\mathcal{C}_T}|$), no
participant crashes in the \textit{propose} phase.
%
Since no participant votes $\ensuremath{No}$, all of them must vote $\ensuremath{Yes}$.
%
Moreover, there is no network failure, thus all participants in $\ensuremath{\mathcal{C}_T}$
should receive {\ensuremath{Yes}} votes from others and then return $\result{\ensuremath{Yes},
\ensuremath{Undecide}}$ (Algorithm \ref{alg:LP2}).
%
It contradicts the hypothesis that there exists participant return
$\result{\ensuremath{Yes}, \ensuremath{Abort}}$.
\end{proof}
\subsection{Correctness Proof of RLSM Manager}
\label{sec:rlsmCorrectness}
This section shows the correctness of {\ensuremath{\mathrm{RLSM}}} in two aspects: soundness (Proposition~\ref{thmSoundness}) and completeness (Proposition~\ref{thmCompleteness}), i.e.
{\ensuremath{\mathrm{RLSM}}} does not report false failures, and it detects all failures that cause the abort of committable transactions.
\begin{proposition}
[Soundness of RLSM]
\label{thmSoundness}
In execution of {\ensuremath{\textsf{FLAC}}} for a transition, if the RLSM manager triggers a $CF$
or an $NF$ event, then there is indeed an unexpected failure that occurs during the transaction execution.
\end{proposition}
\begin{proof}
Algorithm~\ref{alg:rlsm} has listed all possible ways to detect failures (for example, $CF$ in line~\ref{line:AlgRlsmCFDetect}).
The following Proposition~\ref{prop:CrashFailureFlacFF}, \ref{prop:NetworkFailureFlacFF}, and ~\ref{prop:NetworkFailureFlacCFFromAborts} have proven the correctness of each detected failure, so that $CF$ can only be triggered by the execution of {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} when crash or network failures happen, while $NF$ is triggered by the execution of {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} only when network failures occur.
\end{proof}
\begin{proposition}[Completeness of RLSM]
\label{thmCompleteness}
In an execution of {\ensuremath{\textsf{FLAC}}} for transaction $T$, if there is a crash or
a network failure occurring that aborts committable transactions, then
the RLSM manager will always be able to detect it and trigger the event $CF$
or $NF$.
\end{proposition}
\begin{proof}
We prove this by contra position.
Firstly, for {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, if it does
not trigger any $CF$ or $NF$ event (Algorithm \ref{alg:rlsm}), then (i) $\ensuremath{\mathcal{R}_T}$ must contain only the
$\ensuremath{Commit}$ or only the $\ensuremath{Abort}$ decision, and (ii) the coordinator can collect
all the participants' results ($|\ensuremath{\mathcal{R}_T}| = |\ensuremath{\mathcal{C}_T}|$).
%
It follows that no
crash failure occurs.
%
From (i), all participants have decided {\ensuremath{Commit}} or {\ensuremath{Abort}}.
%
Then, according to Algorithm~\ref{alg:LP1}, each node has received $|\ensuremath{\mathcal{C}_T}|$ votes, indicating no network failure affecting the executions of committable transactions.
Secondly, for {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, if it does not
trigger any $NF$ event (Algorithm \ref{alg:rlsm}),
%
then $\ensuremath{\mathcal{R}_T}$ must either contain all $\result{\ensuremath{Yes}, \ensuremath{Undecide} }$ or contains some $\result{\ensuremath{No}, \ensuremath{Abort}}$. In particular:
When all nodes replied $\result{\ensuremath{Yes}, \ensuremath{Undecide} }$, the coordinator will decide to commit the transaction (Algorithm \ref{alg:LP2}, line
\ref{line:AlgCO2Commit}), implying that the committable transactions are not affected.
%
When some nodes replied $\result{\ensuremath{No}, \ensuremath{Abort}}$, the transaction is not committable.
%
Thus, the committable transactions in {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} are not affected by non-detected failures either.
\qedhere
\end{proof}
\input{chapters/proof}
\input{chapters/discussion}
\section{Draft}
\phxsays{I am trying to explain the result of learning $\ensuremath{\alpha_{\mathsf{NF}}}$, and to see whether it is good to put it back to the paper.
I draft the description here first}
\phxedit{
[Technical Report.]
Here we give a detailed reason why {\prac} can shorten the time each participant to decide.
We only discuss 2PC because Easy Commit takes a longer time to decide on participants as shown in \cite{gupta2018easycommit}.
Let $t(x, y)$ to be the transmission time between $x, y$.
We can have all messages transmitted with the shortest path between $t(u, v)$ and $t(C^*, u) + t(C^*, v)$.
The time cost for a participant $u$ executed with {\prac} in \textit{fast path} to decide the result for transaction $T$ is $max\{ t(u, v) + t(C^*, v) | v \in {\ensuremath{\mathcal{C}_T}} \}$.
Meanwhile, the time cost for a participant $u$ executed with 2PC to decide the result for transaction $T$ is
$ t(C^*, u) + 2 max\{ t(C^*, v) | v \in {\ensuremath{\mathcal{C}_T}} \} = max\{ t(C^*, u) + 2t(C^*, v) | v \in {\ensuremath{\mathcal{C}_T}} \} \ge max\{ t(u, v) + t(C^*, v) | v \in {\ensuremath{\mathcal{C}_T}} \}.$
In all, {\prac} can always make participants stay undecided for a shorter time than 2PC in \textit{fast path}. Such an improvement in decide time is more significant when $max\{t(C^*, v) | v \in {\ensuremath{\mathcal{C}_T}} \}$ is close to $max\{t(u, v) | v \in {\ensuremath{\mathcal{C}_T}} \}$.
}
\section{Background}
\label{background}
\subsection{Non-Blocking Atomic Commit}
\label{nbac}
The atomic commit problem is for a set of nodes in a distributed database system
to decide to commit or abort a transaction~\cite{DataI}.
The decision is always based on the ``votes'' from nodes indicating their local
checks for the transaction.
A node votes {\ensuremath{No}} if it wants to abort a transaction due to local invalid
executions that violate ACID properties, process crashes, etc. Otherwise, the
node votes {\ensuremath{Yes}} to inform other nodes it is ready to commit. Once collecting
enough information, each node will decide to commit or abort locally.
Existing research defines the correctness and liveness of
atomic commit protocols (ACPs) as three properties: \textit{agreement},
\textit{validity}, and \textit{termination} \cite{NBAF, WFD, Skeen, HFC}.
%
We formally describe these properties in Definition \ref{def1}.
An atomic commit protocol (ACP) is always expected to satisfy the
\textit{agreement} and \textit{validity} properties for protocol correctness,
while a non-blocking ACP also needs to ensure the \textit{termination} property
for liveness (Definition \ref{def1}).
\begin{definition}[Non-Blocking Atomic Commit \cite{NBAF, WFD, Skeen, HFC}]
\label{def1}
Let $\ensuremath{\mathcal{S}}$ be a distributed system of $n$ nodes $C_1, ..., C_n$ and $\Pi$
be an atomic commit protocol (ACP) defined by two events:
\begin{itemize}[leftmargin=1.5em]
\item Propose: $C_1, ..., C_n$ proposes values $v_1, ..., v_n$
representing the vote ($v_i$ is either {\ensuremath{No}} or {\ensuremath{Yes}}).
\item Decide: $C_1, ..., C_n$ outputs the decided values $d_1, ...,
d_n$ ($d_i$ is either {\ensuremath{Abort}} or {\ensuremath{Commit}}).
\end{itemize}
\noindent An execution of $\Pi$ is said to solve the non-blocking atomic
commit problem iff it satisfies three properties:
\begin{itemize}[leftmargin=1.5em]
\item Agreement: no two nodes decide differently ($\forall i, j.~ d_i =
d_j$).
\item Validity: a node decides {\ensuremath{Abort}} only if some nodes propose {\ensuremath{No}} or
a failure occurs; it decides {\ensuremath{Commit}} only if all nodes propose {\ensuremath{Yes}}.
\item Termination:
every correct node will eventually decide regardless of failures.
\end{itemize}
\noindent Finally, $\Pi$ is said to be a non-blocking ACP in $\ensuremath{\mathcal{S}}$ if every
execution of $\Pi$ in $\ensuremath{\mathcal{S}}$ solves the non-blocking atomic problem.
\end{definition}
\subsection{The Failure Model and Safe Assumptions}
\label{failures}
Real systems often face different kinds of failures, such as process crashes,
message losses, and Byzantine faults~\cite{demillo1982cryptographic, IMPOS}.
It is therefore not easy to consider all possible failures when designing systems.
Instead, the designer often proclaims a set of expected failures as basis.
In this work, we adopt the failure model used by existing ACPs \cite{2PC, 3PC,
12PC, gupta2018easycommit, Skeen, HFC} that crash failure is considered and
point-to-point network communications never fail but could be
delayed.
We also employ their assumption that the receiver node can reliably detect the
crash failure of the sender node by a timeout, which makes it possible
to differentiate between crashed nodes and slow nodes~\cite{IMPOS,
DBLP:phd/us/Chandra93}.
We call this timeout as \textit{crash timeout}, i.e., the timeout
which is used to detect crash failures.
Moreover, we also follow \cite{yan2020domino} to use \textit{network timeout} to
accommodate non-delayed messages that expose low variability of delays.
Note that \textit{network timeout} is smaller than \textit{crash
timeout} because the former only accommodates non-delayed messages while the
latter accommodates all messages.
In this work, we follow \cite{HFC} to classify the operating conditions into
three categories:
\begin{itemize}[nolistsep]
\item[(i)] Failure-free environments: the environments which do not contain any
crashed nodes or delayed messages.
\item[(ii)] Crash-failure environments: the environments in which nodes might crash
but messages are never delayed.
\item[(iii)] Network-failure environments: the environments where the crashed nodes and
delayed messages can both occur.
\end{itemize}
The above classification enables us to implement two optimizations in
ACPs for the failure-free and crash-failure environments.
First, in a failure-free environment, an ACP does not need to consider crash
failures, thus can be optimized further for higher efficiency.
Second, in both failure-free and crash-failure environments where all
connections are non-delayed, a node can try to synchronize with others by
broadcasting a message and waiting for a short network
timeout~\cite{yan2020domino} (one network delay), instead of sending
round-trip messages to synchronize (two network delays) like other
ACPs \cite{12PC, 2PC, 3PC, gupta2018easycommit}.
Moreover, since all messages
arrive within a network timeout,
the message receiver can quickly assert
the crash failure of the sender.
It gives optimization opportunities for the ACP executions when some nodes
crash.
There are also other failure models considered in distributed systems, such as
timing failures \cite{frolund1998quality, ouyang2016reducing}, gray failures
\cite{huang2017gray}, Byzantine failures \cite{castro2002practical,
ruan2019fine, maiyya2020fides}.
A timing failure occurs when servers return correct but untimely responses
~\cite{cristian1991understanding}.
ACPs can treat timing failures occurring within the crash timeout
as network failures and other timing failures as crash failures.
In contrast, gray failures happen when a system's unhealthy behavior is
observed by users but not by the system itself, and a Byzantine failure occurs
when nodes behave arbitrarily or send misleading messages.
These failures cannot be tolerated by both {\ensuremath{\textsf{FLAC}}} and existing ACPs.
~\cite{2PC, 3PC, 12PC, gupta2018easycommit, Skeen, HFC}
\section{Conclusions}
\label{conclusion}
We have presented {\ensuremath{\textsf{FLAC}}}, a robust failure-aware atomic commit protocol for
distributed transactions.
{\ensuremath{\textsf{FLAC}}} includes a novel state transition model RLSM to infer the operating
conditions.
Reinforcement learning is also applied to boost its adaptivity and performance in
unstable environments.
We have implemented a distributed transactional key-value storage with \ensuremath{\textsf{FLAC}}~
and evaluated its performance.
The results show that \ensuremath{\textsf{FLAC}}~ achieves up to 2.22x improvement in throughput and
up to 2.82x speedup in latency, compared to existing protocols 2PC, 3PC, Easy
Commit, C-PAC.
We have also evaluated the effectiveness of reinforcement learning on tuning {\ensuremath{\textsf{FLAC}}}'s
parameters.
The results indicate that the tuning can improve the performance of {\ensuremath{\textsf{FLAC}}} in
unstable environments.
\subsection{Extending \ensuremath{\textsf{FLAC}}~ to Support Replicated Systems}
\label{app:discussion}
This section discusses {\ensuremath{\textsf{FLAC}}}'s position regarding replicated systems.
Classical database systems depend on highly available hardware, like high-end servers, to ensure system availability.
However, these systems cannot guarantee both availability and data consistency following node or network failures.
Existing database systems~\cite{corbett2013spanner, DBLP:journals/pvldb/YangYHZYYCZSXYL22} avoid this problem by introducing cross-region replicas synchronized by consensus protocols.
The atomic commit protocols in these systems are either separated ~\cite{corbett2013spanner} or combined~\cite{zhang2018building, maiyya2019unifying, DBLP:journals/pvldb/YangYHZYYCZSXYL22} from underlying consensus protocols.
Both frameworks achieve high availability at the cost of increased transaction normal processing overhead due to the use of extra nodes and the extra message round trips brought by replications.
Compared to these replicated commit protocols, {\ensuremath{\textsf{FLAC}}} is not designed for systems that require extremely high availability.
Instead, it strikes a balance between system availability and efficiency.
For availability, it immediately adjusts the protocol to a higher robustness level upon detecting unexpected failures, minimizing the protocol's blocking.
For efficiency, {\ensuremath{\textsf{FLAC}}} only executes transactions with costly but highly available protocols when necessary.
We compare it with G-PAC, a state-of-the-art replicated commit protocol, to show their difference in Appendix~\ref{sec:experimentApp}.
In all, {\ensuremath{\textsf{FLAC}}} can be customized into replicated systems with the following changes:
\begin{itemize}
\item In {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, the transaction commit only involves the leader node of each replica group. The leader node that serves as a participant broadcasts its decision to all replicas asynchronously before finishing its local transaction branch.
\item {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}} is changed to a replicated commit protocol that provides high availability at the cost of a longer normal processing time (as shown by our experiments in Appendix~\ref{sec:experimentApp}).
\item When upward transitions towards {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}}, each leader first synchronizes its local decisions to its replicas group. The parameter {\ensuremath{\alpha_{\mathsf{NF}}}} is increased to leverage the extra cost brought by such synchronizations in upward transitions.
\end{itemize}
\section{Evaluation}
\label{exp}
We have implemented {\ensuremath{\textsf{FLAC}}} in a prototype system using mostly Golang, except
the reinforcement learning component is written in Python.
Our system processes transactions similarly to Google's Percolator~\cite{GOO}.
Each transaction retries when it gets aborted due to conflicts (at most 10
times).
Our system does not retry transactions that cannot commit due to consistency
requirements or system failures.
The source code is published at \cite{flacCode}.
We have also conducted extensive experiments to evaluate and compare the
performance of {\ensuremath{\textsf{FLAC}}} with
state-of-the-art ACPs: 2PC \cite{2PC}, 3PC
\cite{3PC}, Easy Commit (EC) \cite{gupta2018easycommit}, and PAC
\cite{maiyya2019unifying}.
For the baselines 2PC, 3PC, and EC, we adopted the implementation design in
\cite{gupta2018easycommit}.
For PAC \cite{maiyya2019unifying}, we implemented its centralized variant,
denoted as C-PAC, where the coordinator is fixed as the leader.
Note that we do not compare {\ensuremath{\textsf{FLAC}}} with protocols designed for systems which
replicate data across different nodes like TAPIR~\cite{zhang2018building},
G-PAC~\cite{maiyya2019unifying}
since their settings are different from {\ensuremath{\textsf{FLAC}}}'s
system model.
In the following, we will present our detailed experimental results regarding to
three main aspects: (1) performance comparison of {\ensuremath{\textsf{FLAC}}} versus other protocols: 2PC, 3PC, EC, C-PAC, (2) impact of {\ensuremath{\textsf{FLAC}}}'s
parameters (network buffer parameter $r$, numbers of consecutive failure-free
runs $\ensuremath{\alpha_{\mathsf{CF}}}$, $\ensuremath{\alpha_{\mathsf{NF}}}$) on its performance, and (3) effectiveness of
reinforcement learning in enhancing the performance of {\ensuremath{\textsf{FLAC}}} for unstable
operating conditions.
Appendix~\ref{sec:experimentApp} also includes experiments about the effect of network delays,
a comparison between {\ensuremath{\textsf{FLAC}}} and replicated commit protocols, {\ensuremath{\textsf{FLAC}}}'s message delay side effects, and a sensitivity analysis showing {\ensuremath{\textsf{FLAC}}}'s performance under varying cross-shared transaction percentages.
\subsection{Experiment Setup}
\label{setup}
We conducted experiments on 11 server nodes deployed in a data cluster with
Ubuntu 20.04 system.
Each server consists of 10x2 3.7GHz Intel Xeon CPU W-1290P processor, 128GB of
DRAM, and connects to the cluster by 1Gbps network with 0.2ms network delay.
For our experiments, we configure one node as the coordinator while the others
are participants.
Each node maintains a single server process that handles requests from others
using lightweight execution threads.
We simulate a cross-datacenter environment by adding 10ms latency
to packages sent among these nodes.
\textbf{Benchmarks.} For micro benchmarking, we run the experiment on a
YCSB-like micro-benchmark proposed in ~\cite{cooper2010benchmarking,
maiyya2019unifying, qadah2021highly}.
Clients continuously generate read and write multi-record transactions with
closed loops, whose data access distribution fits Zipfian
distribution~\cite{cooper2010benchmarking} with a skew factor that controls
contention.
We make all transactions in this benchmark cross-shard by default to evaluate
the performance of all protocols in handling cross-shard transactions.
Tail latency (99\% latency or P99 latency) is used to measure transaction
latency since it can reflect precisely user experiences.
This latency is also widely used by existing systems \cite{chen2021achieving,
decandia2007dynamo, suresh2015c3, prekas2017zygos}.
For macro benchmarking, we use TPC-C, a standard benchmark for OLTP
systems that include three types of read-write and two types of read-only
transactions~\cite{council2010tpc}.
We utilize three warehouses located separately in three server nodes.
Each warehouse contains 10 different districts, and each district maintains the
information of 3000 customers.
We use closed loops to simulate clients that keep sending transactions to the
coordinator and control the contention by adjusting the client thread number.
For this TPC-C benchmark, we only use ACPs for cross-shard transactions and
commit all single-shard transactions in a single message round trip as
in~\cite{gupta2018easycommit, lu2021epoch}.
\textbf{Parameters.}
We conduct the experiments in two operating environments: (i) the failure-free
environment, and (ii) the failure environment where crash and network failures
frequently occurs.
A parameter $\tau$ is used to control how failures are generated: in every cycle
of $2 \tau$ seconds, the system exhibits $\tau$ seconds of crash or network
failures, and then resumes to normal for the remaining $\tau$ seconds.
By default, we set the number of clients to 512 (YCSB-like) and 3000 (TPC-C), skew factor to 0.5, and network
buffer parameter $r$ to 1.
We also follow the existing works \cite{maiyya2019unifying, 1PCD} to set the
number of participant nodes to 3 when assessing the protocols' detailed
performance.
An experiment with varying number of participants, ranging from 3 to 10, is also
conducted to evaluate their scalability.
\subsection{Performance in Failure-Free Environment}
\label{failure-free}
In this environment, no failure will occur.
We start to record the experimental data 5 seconds after all the machines have
warmed up.
All tests are run for 10 times and we record their average results.
\begin{figure}[ht]
\centering
\subfigure[Throughput (skew factor = 0.5).]{%
\includegraphics[width=0.48\linewidth]{figures/ycsb_thoughput.pdf}
\label{fig:ycsb-th}}
\subfigure[Tail latency (skew factor = 0.5).]{%
\includegraphics[width=0.48\linewidth]{figures/ycsb_latency.pdf}
\label{fig:ycsb-la}}
\subfigure[Throughput (512 clients).]{%
\includegraphics[width=0.48\linewidth]{figures/skew_thoughput.pdf}
\label{fig:skew-th}}
\subfigure[Tail latency (512 clients).]{%
\includegraphics[width=0.48\linewidth]{figures/skew_latency.pdf}
\label{fig:skew-la}}
\vspace{-1em}
\caption{Performance of all protocols under the YCSB-like micro-benchmark
with varying client numbers, skew factors.}
\label{fig:ycsb}
\end{figure}
\subsubsection{Experiment with the YCSB-like micro-benchmark, under varying
numbers of clients and different skew factors.}
\label{sec:YCSBVaryContention}
Figure \ref{fig:ycsb} presents our experimental results, in which, {\ensuremath{\textsf{FLAC}}}
demonstrates a significant gain in throughput, with a substantial reduction in
latency in all these settings.
For example, when there are 512 clients (Figures \ref{fig:ycsb}a and
\ref{fig:ycsb}b), {\ensuremath{\textsf{FLAC}}} achieves 1.36x, 1.43x, 2.19x, and 2.16x throughput
speedup compared to EC, 2PC, 3PC, and C-PAC, while {\ensuremath{\textsf{FLAC}}}'s latency is about
54.4\%, 63.8\%, 35.6\%, and 37.4\% of the others respectively.
When the skew factor is 0.6 (Figures \ref{fig:ycsb}c and \ref{fig:ycsb}d), it
achieves from 1.45x to 2.22x throughput speedup and from 32.9\% to 49.5\%
decrease in latency compared to other protocols EC, 2PC, 3PC, and C-PAC.
Again, these better performances of {\ensuremath{\textsf{FLAC}}} are contributed by the protocol
{\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} in this failure-free environment.
More specifically, {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} requires only 1 message delay on each participant
to commit or abort transactions, while all the protocols EC, 2PC, 3PC, and C-PAC
require at least 2 message delays (Table~\ref{tab:cp}).
We also observe in Figure \ref{fig:ycsb} that {\ensuremath{\textsf{FLAC}}} performs slightly worse
than EC in low contention settings with small number of clients
(1{\textasciitilde}128) and low value of skew factor (0.0{\textasciitilde}0.3).
In the low contention setting, the protocols' performance is dependent mainly on
the latency of the coordinator side.
EC can perform better in such setting since it requires only 2 message delays on
the coordinator side, which is less than 3 of {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} (Table~\ref{tab:cp}).
\begin{figure}[ht]
\centering
\subfigure[16 clients.]{%
\includegraphics[width=0.48\linewidth]{figures/breakdown_low.pdf}
\label{fig:breakdown-low}}
\subfigure[512 clients.]{%
\includegraphics[width=0.48\linewidth]{figures/breakdown.pdf}
\label{fig:breakdown-high}}
\vspace{-1em}
\caption{Latency breakdown under the YCSB-like micro-benchmark when
there are 16 and 512 clients.
}
\label{fig:breakdown}
\end{figure}
The above observation is also consistent with our experimental results on
latency breakdown of all protocols in Figure~\ref{fig:breakdown}.
In low contention, EC performs the best for its fewer coordinator side delays
(Figure~\ref{fig:breakdown-low}), while {\ensuremath{\textsf{FLAC}}} outperforms others for the
reduce in retry cost thanks to its less blocking between transactions
(Figure~\ref{fig:breakdown-high}).
\subsubsection{Scalability evaluation of all protocols with the YCSB-like
micro-benchmark, under a varying number of participants.}
As mentioned previously, we follow existing works \cite{maiyya2019unifying,
1PCD} to set the number of participants to 3.
However, in practice, users can choose to use a different number of participants
depending on applications.
Therefore, we conduct this experiment to study how {\ensuremath{\textsf{FLAC}}} and other protocols
can scale with a larger number of participants, ranging from 3 to 10.
According to Figure~\ref{fig:scale}, when the number of participants increases,
the throughput of all the protocols reduces, while their latency increases.
Such decay in performance is due to the long occupation of transaction
resources across multiple nodes, when the number of nodes gets larger.
Nevertheless, {\ensuremath{\textsf{FLAC}}} still performs better than others in all settings.
For example, in the settings of 3 and 10 participant nodes, it respectively
obtains from 1.36x to 2.19x and from 1.20x to 1.62x throughput speedup
more than other protocols.
This performance gain is also due to the similar reason we explained before: the
protocol {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, which operates in this failure-free environment,
requires less number of participant-side message delays than other protocols
(Table~\ref{tab:cp}).
\begin{figure}[ht]
\centering
\subfigure[Throughput.]{\includegraphics[width=0.48\linewidth]{figures/scale_thoughput.pdf}
\label{fig:scale-th}}
\subfigure[Tail latency.]{%
\includegraphics[width=0.48\linewidth]{figures/scale_latency.pdf}
\label{fig:scale-la}}
\vspace{-1em}
\caption{Performance under the YCSB-like micro-benchmark with
varying numbers of participants.}
\label{fig:scale}
\end{figure}
\subsubsection{Impact of the Network Buffer Parameter $r$}
\label{effect_r}
As described in Section ~\ref{LP1}, this parameter is used to adjust the message
delay upper bound for different network conditions.
To study its impact on protocol performance, we evaluate {\ensuremath{\textsf{FLAC}}} with the TPC-C
benchmark under different contentions when the number of clients varies.
The results are presented in Figure~\ref{fig:r}.
Firstly, when $r$ changes from 0.5 to 1, the throughput increases from 13.0K tps
to 21.7K tps and the latency decreases from 684ms to 321ms.
With smaller $r$, the system assumes a shorter network timeout to collect
messages.
Consequently, more messages fail to arrive within the network timeout, and
{\ensuremath{\textsf{FLAC}}} regards them as network failures, causing it to incline to the more
stringent network-failure level.
Secondly, when $r$ changes from 0.1 to 0.5 and from 1 to 8, the throughput
decreases from 14.1K to 13.0K and from 21.7K to 12.2K, while the latency
increases from 556ms to 684ms and from 321ms to 683ms, respectively.
This degrading of {\ensuremath{\textsf{FLAC}}}'s performance while $r$ increases is because the
coordinator waits for a longer time to get all participants' results before
sending its decision back to them.
\begin{figure}[ht]
\centering
\subfigure[Throughput.]{%
\includegraphics[width=0.476\linewidth]{figures/rs_th.pdf}
\label{fig:rs-th}}
\subfigure[Tail latency.]{%
\includegraphics[width=0.476\linewidth]{figures/rs_la.pdf}
\label{fig:rs-la}}
\vspace{-1em}
\caption{Effects of network buffer
parameter $r$ on {\ensuremath{\textsf{FLAC}}}. Darker color indicates higher latency or
throughput.}
\label{fig:r}
\end{figure}
\subsection{Performance on Failure Environment}
Failure environment is created by frequently injecting crashes or delays into
nodes and network connections~\footnote{We pick one participant and let it stop or delay message handling.}.
This injection is controlled by the parameter $\tau$ (Section \ref{setup}): a
failure is triggered and last in $\tau$ seconds for a periodic cycle of $2\tau$
seconds.
We record experimental data after the machine warm up time in $5 + 2\tau$
seconds\footnote{$5$ seconds is the time needed to warm up all the machines, and
$2 \tau$ seconds is one buffering time cycle needed for the performance of all
the protocols to become stable.}.
\subsubsection{Experiment with the TPC-C benchmark and environments containing
only crash failures or only network failures.}
\begin{figure}[ht]
\centering
\subfigure[Throughput.]{%
\includegraphics[width=0.48\linewidth]{figures/unstable_CF_protocols.pdf}
\label{fig:unstable-cf-th}}
\subfigure[Tail Latency.]{%
\includegraphics[width=0.48\linewidth]{figures/unstable_CF_protocols_la.pdf}
\label{fig:unstable-cf-la}}
\subfigure[Throughput.]{%
\includegraphics[width=0.48\linewidth]{figures/unstable_NF_protocols.pdf}
\label{fig:unstable-nf-th}}
\subfigure[Tail Latency.]{%
\includegraphics[width=0.48\linewidth]{figures/unstable_NF_protocols_la.pdf}
\label{fig:unstable-nf-la}}
\vspace{-1em}
\caption{Protocol performance under TPC-C benchmark with environments having
only crash (a, b) or only network failures (c, d).}
\label{fig:unstable}
\end{figure}
Figure~\ref{fig:unstable} presents the experimental results in different
environments where crash failures or network failures happen on a participant
periodically.
Here, the notation {CF{-}50ms} (or {NF{-}50ms}) means that the environment will
repeatedly exhibit a crash failure (or a network failure) for 50ms and then
resume to normal for another 50ms ($\tau = 50ms$).
In all failure settings ($\tau = 50ms, 100ms, 0.5s, 1s$), {\ensuremath{\textsf{FLAC}}} always achieves
better performance than other protocols.
Figures \ref{fig:unstable-cf-th} and \ref{fig:unstable-cf-la} show that with
periodic crash failures, {\ensuremath{\textsf{FLAC}}} gains from 1.67x to 2.25x throughput speedup,
while its latency drops from 25.2\% to 93.3\%, compared to the next two best
protocols EC and 2PC.
Such improvement is derived from {\ensuremath{\textsf{FLAC}}}'s capability to select and execute the
most suitable protocol between {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}.
When network failures happen (Figures \ref{fig:unstable-nf-th} and
\ref{fig:unstable-nf-la}) {\ensuremath{\textsf{FLAC}}} can still achieve better throughput speedup
(from 1.41x to 2.22x), and lower latency (from 38.0\% to 77.1\%) compared to EC
and 2PC.
This performance improvement, again, is due to {\ensuremath{\textsf{FLAC}}}'s adaptivity to switch
between its protocols ({\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}}).
\subsubsection{Experiment with the TPC-C benchmark and environments containing
both crash and network failures.}
\label{sec:UnstableEnv1}
\begin{figure}[ht]
\centering
\subfigure[Throughput.]{%
\includegraphics[width=0.48\linewidth]{figures/unstable_mixed_protocols.pdf}
\label{fig:addition-th}}
\subfigure[Tail Latency.]{%
\includegraphics[width=0.48\linewidth]{figures/unstable_mixed_protocols_la.pdf}
\label{fig:addition-la}}
\vspace{-1em}
\caption{Protocol performance under the TPC-C benchmark
with environments containing both crash and network failures.}
\label{fig:addition}
\end{figure}
Figure~\ref{fig:addition} presents the experimental results in different
environments where crash failures and network failures both happen.
For example, the combined setting CF{-}50ms NF{-}1s indicate that the
environment will repeatedly exhibit a crash failure for 50ms, resume to normal
for the next 50ms, and then continue to exhibit a network failure for 1s, and
return to normal for the next 1s.
In all experimented settings (CF{-}$\tau_1$ NF{-}$\tau_2$, where $\tau_1,
\tau_2$ can be $50ms$ or $1s$), {\ensuremath{\textsf{FLAC}}} still performs the best among all
protocols.
In particular, it achieves from 1.73x to 2.09x more throughput speedup than EC
and 2PC (the next two best protocols), while its latency reduced from 24.8\% to
96.9\% of them.
This result is also due to {\ensuremath{\textsf{FLAC}}}'s ability to switch to a suitable protocol
({\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, or {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}}) when the operating environment changes.
\subsubsection{Impact of reinforcement learning (RL) on fine-tuning
robustness-downgrade parameters ($\ensuremath{\alpha_{\mathsf{CF}}}$, $\ensuremath{\alpha_{\mathsf{NF}}}$) to {\ensuremath{\textsf{FLAC}}}'s
performance}
\label{sec:TurningRLParams}
Figure~\ref{fig:unstable-rl} reports the performance comparison of {\ensuremath{\textsf{FLAC}}} in
failure environments when the parameters $\ensuremath{\alpha_{\mathsf{CF}}}, \ensuremath{\alpha_{\mathsf{NF}}}$ are fine-tuned
by RL compared to when they are fixed to 4 settings:
(1) $\ensuremath{\alpha_{\mathsf{CF}}}{=}1$, $\ensuremath{\alpha_{\mathsf{NF}}}{=}1$, which adapts {\ensuremath{\textsf{FLAC}}} to environments where
failures do not recur quickly (stable environments),
(2) $\ensuremath{\alpha_{\mathsf{CF}}}{=}1, \ensuremath{\alpha_{\mathsf{NF}}}{=}256$, where network failures recur quickly,
(3) $\ensuremath{\alpha_{\mathsf{CF}}}{=}256$, $ \ensuremath{\alpha_{\mathsf{NF}}}{=}1$, where crash failures recur quickly,
(4) $\ensuremath{\alpha_{\mathsf{CF}}}{=}256$, $\ensuremath{\alpha_{\mathsf{NF}}}{=}256$, where all failures recur quickly.
The result shows that {\ensuremath{\textsf{FLAC}}} obtains better or equivalent performances when
$\ensuremath{\alpha_{\mathsf{CF}}}, \ensuremath{\alpha_{\mathsf{NF}}}$ are fined-tuned by RL, compared to when they are fixed to
certain values in all environments.
In particular, {\ensuremath{\textsf{FLAC}}} with RL-tuned parameters outperforms other fix-valued
settings in the environments where network failures recur fast (Figure
\ref{fig:unstable-rl-th}, NF-50ms) or where crashes recur fast but network
failures recur slowly (Figure \ref{fig:unstable-rl-mixed}, CF-50ms NF-1s).
We also notice that a fixed-value setting can enable {\ensuremath{\textsf{FLAC}}} to perform well in
some environments, such as the settings (i) $\ensuremath{\alpha_{\mathsf{CF}}}{=}256$, $\ensuremath{\alpha_{\mathsf{NF}}}{=}1$ for
environments where crash failures recur fast (Figure \ref{fig:unstable-rl-th},
CF-50ms), (ii) $\ensuremath{\alpha_{\mathsf{CF}}}{=}1$, $\ensuremath{\alpha_{\mathsf{NF}}}{=}1$ for stable environments (Figure
\ref{fig:unstable-rl-th}, CF-1s, Figure \ref{fig:unstable-rl-mixed}, CF-1s NF-1s),
and (iii) $\ensuremath{\alpha_{\mathsf{CF}}}{=}256$, $\ensuremath{\alpha_{\mathsf{NF}}}{=}256$ for environments
where network failures recur fast (Figure \ref{fig:unstable-rl-th},
NF-50s).
However, there is no fixed-value setting that can make {\ensuremath{\textsf{FLAC}}} perform well in
all experimented failure environments.
In contrast, the setting that fine-tunes $\ensuremath{\alpha_{\mathsf{CF}}}$, $\ensuremath{\alpha_{\mathsf{NF}}}$ by RL
can boost {\ensuremath{\textsf{FLAC}}} to gain better performance in all these environments,
as described earlier.
Furthermore, {\ensuremath{\textsf{FLAC}}} only spent up to 5 seconds for such parameter tuning.
This experiment confirms our proposal that RL can help to fine-tune the
robustness-downgrade transition parameters so that {\ensuremath{\textsf{FLAC}}} can perform well in different failure environments.
\begin{figure}[ht]
\centering
\subfigure[Only crash or only network failures.]{%
\includegraphics[width=0.48\linewidth]{figures/unstable_rl.pdf}
\label{fig:unstable-rl-th}}
\subfigure[Both crash and network failures.]{%
\includegraphics[width=0.48\linewidth]{figures/unstable_rl_mixed.pdf}
\label{fig:unstable-rl-mixed}}
\vspace{-1em}
\caption{Comparison of {\ensuremath{\textsf{FLAC}}}'s performance under TPC-C benchmark
with fixed-value and RL-tuned parameters {\ensuremath{\alpha_{\mathsf{CF}}}, \ensuremath{\alpha_{\mathsf{NF}}}}.}
\label{fig:unstable-rl}
\end{figure}
\subsection{Proof of Correctness}
\label{sec:formalProof}
\subsubsection{FSA Model of ACP}
We follow existing works~\cite{Skeen, gupta2018easycommit, gray2006consensus} to model the transaction execution at each node as an \textbf{finite state automata} (FSA) and regards network messages as the inputs/outputs.
The state of FSA on node $i$ is called the \textbf{local state}.
For a state transition, the node reads nonempty strings of messages sent to it, writes strings of messages as output, and makes an instantaneous change to the local state.
The local state transitions are atomic without crash failures and performed asynchronously.
Figure~\ref{fig:prac-ff} and Figure~\ref{fig:prac-cf} separately present the FSA for {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} (Algorithms ~\ref{alg:CO1} ~\ref{alg:LP1} ~\ref{alg:CO2} and ~\ref{alg:LP2}).
Node 1 is fixed as the coordinator, while nodes 2 -- n represent involved participants.
We mark the event "a $MessageName$ message is sent from $u$ to $v$" as $MessageName_{u, v}$.
FSAs contain five basic states: \textbf{initial state} $q_i$, two \textbf{wait states} $w_i, r_i$, and two \textbf{final states} $c_i, a_i$ indicating the transaction is committed/aborted.
FSAs for {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} also contain two \textbf{buffer states}: a committable state $tc_i$ and an abortable state $ta_i$.
The two buffer states originals from the transmit-before-decide technique~\cite{gupta2018easycommit}, corresponding to the \textit{TRANSMIT-C} state and \textit{TRANSMIT-A} state of EasyCommit, respectively.
These FSAs are acyclic for eventual termination and are non-deterministic due to deadlocks, failures, triggers, or user aborts.
The messages sent between nodes can be reordered or delayed but can reach the destination before \textit{timeout} without crash failures.
\begin{figure}[ht]
\centering
\subfigure[Coordinator.]{%
\includegraphics[width=0.8\linewidth]{figures/fsa-ff-co.png}
\label{fig:fsa-ff-co}
}
\subfigure[Participant.]{%
\includegraphics[width=0.8\linewidth]{figures/fsa-ff-pa.png}
\label{fig:fsa-ff-pa}
}
%
\caption{The FSA of {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}.}
\label{fig:fsa-ff}
\end{figure}
Here we list some key definitions in Skeen's formalism~\cite{Skeen, gupta2018easycommit}.
The overall state of a distributed transaction $T$ can be defined as a combination of (i) a vector of all local states and (ii) the pending messages in the network, which is called the \textbf{global state}.
The global state is a \textbf{global final state} if all local states are final states.
The global state is a \textbf{global terminal state} if all local states are blocked and cannot transition to the following states.
Regarding a local state $x$, all local states that could concurrently exist with $x$ in reachable global states are called the \textbf{concurrency set} of $x$.
Finally, we call local states that can only exist when all participants have voted yes the \textbf{committable states}.
Otherwise, they are called \textbf{non-committable states}.
\begin{figure}[ht]
\centering
\subfigure[Coordinator.]{%
\includegraphics[width=0.98\linewidth]{figures/fsa-cf-co.png}
\label{fig:fsa-cf-co}
}
\subfigure[Participant.]{%
\includegraphics[width=0.98\linewidth]{figures/fsa-cf-pa.png}
\label{fig:fsa-cf-pa}
}
\caption{The FSA of {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} protocol.}
\label{fig:fsa-cf}
\end{figure}
\subsubsection{Properties}
With the FSA model of ACPs, the atomic commit protocol correctness defined in Definition~\ref{def1} can be rewritten as Definition~\ref{def:fsa-acp}.
\begin{definition}
\label{def:fsa-acp}
A commit protocol is a non-blocking atomic commit protocol if it ensures the following properties for global terminate states:
\begin{itemize}
\item The commit state is not in the concurrency set of the abort state.
\item Only committable states can reach the commit state.
\item A committable state must eventually transition to the commit state in a failure-free environment.
\item All global terminal states are global final states.
\end{itemize}
They respectively correspond to the agreement, validity, and termination properties in Definition~\ref{def1}.
\end{definition}
\subsubsection{Sub-protocol Correctness}
\label{sec:subCorrectness}
The correctness of ACP can be described as a combination of agreement and validity properties.
We first present the correctness of {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}.
Based on Figure~\ref{fig:fsa-ff-pa} and ~\ref{fig:fsa-cf-pa}, we list concurrent sets of each state in Table~\ref{tab:concurrency-ff} and ~\ref{tab:concurrency-cf}.
For instance, $q_i$ does not concurrent with $c_j$ in Table~\ref{tab:concurrency-ff}, because the transition to $c_j$ requires $yes_{i,j}$, indicating $i$'s FSA has at least transited to $r_i$.
$q_i$ coexists with $w_j$ when the propose messages arrive node $j$ earlier than node $i$.
In this case, if node $j$ then votes {\ensuremath{No}}, $q_i$ will coexist with $a_j$.
Note that $r_i$'s concurrency set is not listed in tables, because it can always transition and thus is not in any terminate state.
Among all states, $c_i$ of both protocols and $tc_i, w_i$ of {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} are committable states.
\begin{table}[ht]
\centering
\caption{{\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} concurrency sets}
\label{tab:concurrency-ff}
\begin{tabular}{|c|c|c|c|c|}
\hline
& $q_j$ & $w_j$ & $a_j$ & $c_j$ \\
\hline
$q_i$ & \checkmark & \checkmark & \checkmark & \\
\hline
$w_i$ & \checkmark & \checkmark & \checkmark & \checkmark \\
\hline
$a_i$ & \checkmark & \checkmark & \checkmark & \\
\hline
$c_i$ & & \checkmark & & \checkmark \\
\hline
\end{tabular}
\end{table}
\begin{table}[ht]
\centering
\caption{{\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} concurrency sets}
\label{tab:concurrency-cf}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
& $q_j$ & $w_j$ & $ta_j$ & $tc_j$ & $a_j$ & $c_j$ \\
\hline
$q_i$ & \checkmark & \checkmark & \checkmark & & & \\
\hline
$w_i$ & \checkmark & \checkmark & \checkmark & \checkmark & & \\
\hline
$ta_i$ & \checkmark & \checkmark & \checkmark & & \checkmark & \\
\hline
$tc_i$ & & \checkmark & & \checkmark & & \checkmark \\
\hline
$a_i$ & & & \checkmark & & \checkmark & \\
\hline
$c_i$ & & & & \checkmark & & \checkmark \\
\hline
\end{tabular}
\end{table}
In both tables, the commit state is not in the concurrency set of the abort state, ensuring the agreement property according to Definition~\ref{def:fsa-acp}.
The first node decides commit must be committable (collect all {\ensuremath{Yes}}), and thus ensures rule 2 (commit validity).
Rule 3 (abort validity) holds for $c_i$ in {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} since $c_i$ is already the final commit state.
Rule 3 for the rest committable states ($w_i, tc_i$ in {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}) can be proven by the following statements:
In a failure-free environment, the vote from each participant will reach the coordinator and results in a commit decision.
The commit decision then must reach all participants without network failure, inputting $commit_{1,i}$ to each FSA, transitioning them to $tc_i$, and committing transaction branches.
In all, committable states in both protocols ensure abort validity.
Another property of {\ensuremath{\textsf{FLAC}}} mentioned in Section~\ref{LP2} is the liveness of {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}.
We reuse the fundamental non-blocking theorem~\cite{Skeen} to prove this part.
The theorem can be concluded as Theorem~\ref{the:nbac}.
\begin{theorem}[Fundamental non-blocking theorem.]
\label{the:nbac}
An ACP is non-blocking iff it ensures the following two conditions for participant FSAs:
(i) no local state is concurrent with both commit and abort states, and
(ii) no noncommittable state is concurrent with commit states.
\end{theorem}
It can be directly observed from Table~\ref{tab:concurrency-ff} and ~\ref{tab:concurrency-cf} that no state is concurrent with both $c_i$ and $a_i$, while $c_i$ is only concurrent with committable states $c_i$ and $tc_i$.
Thus, we can conclude that {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} ensures liveness regarding crash failures.
\section{\pac\ Design}
\label{implementation}
\subsection{Components}
We implemented the code for \pac \ in Go, and the code for RL learner (which is included in \ensuremath{\mathrm{RLSM}}) in python. The implementation is available publicly on GitHub.~\cite{PAC}
\subsection{Message Upper Bound}
\label{factorr}
As demonstrated above, the message upper bound is defined as the sum of message passing time and local execution time. When implementing the system, a problem arises about how to select that value for the \pac \ protocol.
To reach theoretical optima, the waiting time for each cohort should be different and be tailored for each cohort. This can be done without lots of work on a stable network. However, if message delays between nodes keep changing, it would affect the performance. This reveals a natural trade-off between the requirement for network and the performance in \pac.
Specifically, we record the average of that message upper bound based on real executions and message delay between cohorts. Then we let the \pac \ protocol waits for $r$ ($r \ge 1$) times that result.
This $r$ represents how confident we are on the network stableness between cohorts. Section~\ref{exp} gives our evaluation in the trade-off on the selection of $r$ during experiments.
\section{Introduction}
Database systems that support critical operations require all transactions
to guarantee the ACID properties (atomicity, consistency, isolation, durability)
\cite{gray1992transaction}.
Among them, the atomicity property, which mandates a transaction
must happen in its entirety, is costly to guarantee, especially in sharded or
distributed databases.
Sharded databases partition states into disjoint computing nodes for horizontal
scalability.
Consequently, when a transaction's accesses span across nodes, a new challenge
arises on how nodes agree on a common status of the transaction.
To address this problem, atomic commit protocols (ACPs) such as
two-phase commit (2PC) \cite{2PC} and three-phase commit (3PC) \cite{3PC} have been
proposed.
However, one fundamental drawback of ACPs is that they work with a fixed assumption
on the node behavior and network connectivity, i.e., the operating conditions.
For example, 2PC only ensures termination in failure-free environments,
rendering services unavailable even in the event of two-node crashes \cite{2PC,
gupta2018easycommit}.
3PC overcomes this problem with an additional message round trip \cite{3PC,
gupta2020efficient}.
However, the overhead of this additional message round trip
often overshadows the benefit of the termination property, especially when the
failure-free run constitutes the bulk of system operating time.
To alleviate the above problems, we design {\ensuremath{\textsf{FLAC}}}, a
\underline{\textbf{f}}ai\underline{\textbf{l}}ure-aware
\underline{\textbf{a}}tomic \underline{\textbf{c}}ommit protocol, which can
monitor and adapt its execution to failures happening in the operating
environments to improve its performance.
Similar to existing ACPs~\cite{ML12PC, presumedeither2PC, 2PC, 3PC,
gupta2018easycommit}, our system model consists of a coordinator node and
different participant nodes.
The coordinator drives the protocol while participants vote on the transaction
status.
To make {\ensuremath{\textsf{FLAC}}} operate efficiently in environments where different types of
failures can occur, we design it to handle transactions from clients in four
steps.
First, the coordinator sends \textit{Propose} messages to participants with its
current assumption on operating conditions, so that participants can select the
corresponding protocol according to the hinted conditions.
Second, the participants execute the selected protocol and send the execution
results back to the coordinator.
Third, the coordinator performs a validation to detect whether any unexpected
failure happens during the execution so that it can adjust {\ensuremath{\textsf{FLAC}}} to adapt to
the new environment.
This step is conducted by a component called the robustness-level state machine
({\ensuremath{\mathrm{RLSM}}}) resided inside the coordinator.
Finally, the coordinator makes the final decision and sends the results to all
undecided participants so that they can commit or abort the transaction
accordingly.
In our work, we follow state-of-the-art approaches \cite{2PC, 3PC,
gupta2018easycommit, gupta2020efficient, HFC} to consider two types of
failures that can happen in the operating environment of ACPs.
Consequently, three types of environments can occur during the execution of
{\ensuremath{\textsf{FLAC}}}, where (i) no failure occurs; (ii) participant nodes might crash but
there is no delayed network connection, or (iii) both crashed nodes and delayed
connections occur.
We have implemented in {\ensuremath{\textsf{FLAC}}} a family of three protocols that can operate
effectively in the three aforementioned environments.
These protocols correspond to the three robustness levels: failure-free,
crash failure, and network failure, based on the expected failure set defined
in~\cite{HFC}.
{\ensuremath{\textsf{FLAC}}} can switch between the three protocols based on closely monitoring
its operating environment.
In any setting, {\ensuremath{\textsf{FLAC}}} can always ensure the safety~\cite{gupta2018easycommit}
that no two participants will decide differently, and a {\ensuremath{Commit}} decision is
made only if all participants have voted {\ensuremath{Yes}}.
Furthermore, it can guarantee the liveness property when the correct
protocol is selected for a given operating condition.
Finally, when there is a change in the operating condition (e.g., a node crashes or recovers),
the {\ensuremath{\mathrm{RLSM}}} component in the coordinator will adjust each node's robustness level accordingly.
More specifically, when the operating condition changes, the previously selected protocol may not be appropriate for the new environment.
This incorrect selection of protocol can cause potential blocking of transactions.
To alleviate the blocking problem,
we equip \ensuremath{\mathrm{RLSM}}~ with RL-tuned parameters to capture failure's degree of recurrence, and let {\ensuremath{\mathrm{RLSM}}} cautiously adjust nodes' robustness levels to lenient ones.
As a result, {\ensuremath{\textsf{FLAC}}} can consistently provide high performance in all environments.
In summary, we make the following contributions:
\begin{itemize}[nolistsep, left=0.5em]
\item We propose {\ensuremath{\textsf{FLAC}}}, a robust failure-aware commit
protocol for the transaction atomicity under different operating conditions.
\item We design a robustness-level state machine ({\ensuremath{\mathrm{RLSM}}}), a provable state
transition model to infer operating conditions for {\ensuremath{\textsf{FLAC}}}.
\item We apply reinforcement learning methods to fine-tune parameters of {\ensuremath{\mathrm{RLSM}}}, which improves the
performance of {\ensuremath{\textsf{FLAC}}} in unstable environments.
\item We implement a key-value store system with transaction support based on Google Percolator \cite{GOO} as a test bed to evaluate {\ensuremath{\textsf{FLAC}}} and other atomic commit protocols (ACPs).
\item We conduct a comprehensive evaluation of {\ensuremath{\textsf{FLAC}}} with state-of-the-art ACPs using the above system with
YCSB-like micro-benchmark and TPC-C workloads. Our experiments show
that {\ensuremath{\textsf{FLAC}}}'s ability to adapt to different operating conditions results in a significant performance gain compared to other ACPs.
\end{itemize}
The rest of this paper is organized as follows.
Section \ref{background} introduces the background of ACPs.
Section \ref{sec:systemModel}, \ref{sec:subProtocols} present the design of our
{\ensuremath{\textsf{FLAC}}} protocol: its system model, protocols, and transaction processing
system.
Section \ref{rlsm} introduces the failure detector {\ensuremath{\mathrm{RLSM}}}, and shows how
{\ensuremath{\textsf{FLAC}}} combines three protocols with it.
Section \ref{exp} exhibits our performance evaluation of {\ensuremath{\textsf{FLAC}}} and existing ACPs.
We then review related works in Section~\ref{related}, discuss the limitations
of {\ensuremath{\textsf{FLAC}}} and future work in Section \ref{sec:short-discussion}, and finally
conclude in Section~\ref{conclusion}.
\section{Dedicated Protocols for Different Operating Environments}
\label{sec:subProtocols}
This section describes the three dedicated protocols {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}},
{\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}} that our {\ensuremath{\textsf{FLAC}}} protocol uses to operate in three different
environments: failure-free, crash-failure, and network-failure.
We first present each protocol in detail and then prove their correctness.
Finally, we compare these dedicated protocols with existing ACPs and discuss their
strengths and weaknesses.
\subsection{{\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} for Failure-Free Environment}
\label{LP1}
Distributed systems suffer from two major bottlenecks related to ACP~\cite{DBLP:journals/corr/abs-2206-00623, DBLP:journals/pvldb/YuXPSRD18}.
First, the long coordinator-side delay prolongs the latency of distributed transactions.
Second, the long participant-side delay of ACP could block the execution of
concurrent transactions and limit system parallelism.
In the failure-free environment, {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} assumes no network failures or
crash failures among all participant and coordinator nodes.
This gives us opportunities to address both aforementioned challenges.
By adopting optimizations discussed in Section~\ref{failures}, we design {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} to take fewer message delays on
both the coordinator and the participants than existing ACPs like 2PC~\cite{2PC} in failure-free environments.
\begin{figure}[ht]
\centering
\includegraphics[width=\linewidth]{figures/flacFF.pdf}
\caption{Timeline of {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}.}
\label{fig:prac-ff}
\end{figure}
We describe the {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} protocol for the coordinator and the participants
in Algorithms \ref{alg:CO1} and \ref{alg:LP1}, respectively.
Its timeline is also illustrated in Figure~\ref{fig:prac-ff}.
The coordinator initiates
an execution of the protocol on receiving a transaction $T$ from
clients.
It sends the $Propose$ message to all involved participants $\ensuremath{\mathcal{C}_T}$ and then
waits for their execution results in $W_{C^*}$ time (Algorithm \ref{alg:CO1},
lines \ref{line:CO1Broadcast}--\ref{line:CO1Wait}).
\input{chapters/algo-flacff-coordinator}
\input{chapters/algo-flacff-participant}
In Algorithm \ref{alg:CO1}, $W_{C^*}$ is the network timeout
on the coordinator: it is used to accommodate all the results sent back from
failure-free participants.
We compute $W^*$ by utilizing a parameter called the message delay upper bound
$U$.
Given two arbitrary nodes $x$ and $y$, $U(x,y)$ indicates the time window for
all messages between these two nodes to arrive without network failures.
%
It is computed by multiplying the maximum delay $\sigma(x, y)$ of a ping
message\footnote{Each ping message is a 64-byte ICMP package. We measured this
ping message delay for 100 times (when the network connection between $x$ and
$y$ is stable) and took the maximum value as $\sigma(x, y)$.} between $x$ and
$y$\, with a network buffer parameter $r$\footnote{The network buffer parameter
$r$ is used to adjust the message delay upper bound for different network
conditions. We will show later in the experiments (Section \ref{effect_r}) how
different values of $r$, ranging from 0.1 to 8, affect the performance of
{\ensuremath{\textsf{FLAC}}}.}, that is: $U(x,y) = \sigma(x,y) \times r$.
Using this maximum message delay upper bound $U$, we can calculate the
network timeout $W_{C^*}$ by the maximum time for a failure-free
participant $C_i$ to get votes from all others participants $C_j \in \ensuremath{\mathcal{C}_T}$ and
replies its message to $C^*$,
that is: $W_{C^*} = max\{ U(C^*, C_j) + U(C_j, C_i) +
U(C_i, C^*)\}$, for any $C_i, C_j \in C_T$.
For each participant $C_i$, upon receiving the {$Propose$} message, it first
determines and broadcasts its local vote to other participants (Algorithm
\ref{alg:LP1}, lines \ref{line:AlgLP1DecideVote}, \ref{line:AlgLP1Broadcast}).
If this vote is {\ensuremath{No}}, it will decide to abort the transaction (lines
\ref{line:AlgLP1VoteNo}--\ref{line:AlgLP1VoteNoAndAbort}).
Otherwise, it will exchange votes with other participants within the
pre-calculated network timeout $W_{C_i}$ (lines
\ref{line:AlgLP1ExchangeVotes}--\ref{line:AlgLP1Finish}).
Here, $W_{C_i}$ is computed by subtracting the latest arrival time of votes sent
from failure-free participants to $C_i$ by the received time of the
\textit{Propose} message on $C_i$.
More specifically, $W_{C_i} = max\{t_{\textrm{sent}} + U(C^*, C_j) + U(C_j, C_i)
- t_{\textrm{recv}}$, for any $C_j \in C_T \}$, where $t_{\textrm{sent}}$,
$t_{\textrm{recv}}$ are respectively the clock time of $C^*$ and $C_i$ when
sending and receiving the \textit{Propose} message\,\footnote{This computation
might be affected by clock skew and makes $W_{C_i}$ inaccurate, as pointed out
in \cite{yan2020domino}.
However, such clock skew will not affect the correctness of {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}.}.
Within the network timeout $W_{C_i}$, the participant $C_i$ will decide
{\ensuremath{Abort}} if it receives a {\ensuremath{No}} vote (lines
\ref{line:AlgLP1ReceiveNo}--\ref{line:AlgLP1Abort}), or decide {\ensuremath{Commit}} if it
receives {\ensuremath{Yes}} votes from all participants (lines
\ref{line:AlgLP1ReceiveAllYes}--\ref{line:AlgLP1Commit}).
Otherwise, $C_i$ will remain {\ensuremath{Undecide}}, send back this result to the
coordinator, and wait for the coordinator's decision (lines
\ref{line:AlgLP1Sendback}--\ref{line:AlgLP1Undecided}).
If it can receive a decision before a crash timeout, it will return that
decision and finish the execution (lines \ref{line:AlgLP1GetDecisionFromOthers}--\ref{line:AlgLP1CoordinatorDecision}).
Otherwise, the coordinator might crash, and $C_i$ will run a termination
protocol to get the decision from other participant nodes in $\ensuremath{\mathcal{C}_T}$, or to
reach an agreement among them on $T$'s decision with a new coordinator (line
\ref{line:AlgLP1TerminationProtocol}).
For the coordinator $C^*$, after collecting the result set $\ensuremath{\mathcal{R}_T}$, it will
proceed with one of the following three scenarios.
Firstly, if $\ensuremath{\mathcal{R}_T}$ includes a {\ensuremath{Commit}} or {\ensuremath{Abort}} decision, $C^*$ will
broadcast this decision to other {\ensuremath{Undecide}} participants, and then returns it
to clients (Algorithm \ref{alg:CO1}, lines
~\ref{line:CO1CommitOrAbort}--\ref{line:CO1FastPath}).
Note that when there is no {\ensuremath{Undecide}} participant, this execution path is
called the \textit{fast path}, as illustrated in Figure~\ref{fig:SAB}.
Secondly, if $\ensuremath{\mathcal{R}_T}$ contains results from all participants who also stay
{\ensuremath{Undecide}}, then all these participants vote {\ensuremath{Yes}}\,\footnote{The result $\result{\ensuremath{No}, \ensuremath{Undecide}}$ will never
occur.}.
Thus, $C^*$ can simply notify a $\ensuremath{Commit}$ decision to them and return this
decision (lines \ref{line:AlgCO1AllUndecided}--\ref{line:AlgCO1Commit}).
Finally, if $\ensuremath{\mathcal{R}_T}$ does not contain the results of all participants, $C^*$
will not have enough information to make a decision.
Then, it will run the termination protocol to continue the execution of $T$
(line \ref{line:AlgCO1Termination}).
$C^*$ will wait for the results of other participants until (i) it can receive
an {\ensuremath{Abort}} or a {\ensuremath{Commit}} decision to decide for $T$ accordingly or (ii) it can
receive the same \result{\ensuremath{Yes}, \ensuremath{Undecide}} results from all participants and
decide {\ensuremath{Commit}} for $T$.
For crash recovery, {\ensuremath{\textsf{FLAC}}} adds transaction logs into non-volatile storage and recovers from crash failures like existing ACPs ~\cite{2PC, gupta2018easycommit}.
Details about {\ensuremath{\textsf{FLAC}}}'s failure handling can be found in Appendix~\ref{sec:failureHandleApp}.
\vspace{-0.5em}
\subsection{\hspace{-0.5em}\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}~for~Crash-Failure~Environment}
\label{LP2}
In the crash-failure environment, \ensuremath{\textsf{FLAC}}~ assumes no delayed message among the
participant nodes.
However, these nodes are subject to crashes.
Therefore, we consider the following two requirements when designing {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}
to improve its performance.
Firstly, {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} will always ensure liveness when crash failures happen, to
reduce the blocking of resources \cite{Skeen, 3PC,
chrysanthis1998recovery}.
Secondly, it will quickly abort transactions that cannot commit due to crash
failures so that they do not affect the commit of other transactions.
We present the {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} protocol in Algorithms \ref{alg:CO2}, \ref{alg:LP2} and
Figure~\ref{fig:prac-cf}.
On the coordinator side, to meet the above requirements, {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} will quickly
abort a transaction if it cannot receive results from all participants after
the network timeout $W_{C^*}$ (Algorithm \ref{alg:CO2}, lines
\ref{line:AlgCO2NotReceiveAll}--\ref{line:AlgCO2Abort}).
It is also the only difference between the {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} protocols for
the coordinator (Algorithm \ref{alg:CO2} vs. Algorithm \ref{alg:CO1}).
\input{chapters/algo-flaccf-coordinator}
\input{chapters/algo-flaccf-participant}
On the participant side, the {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} protocol for each participant (Algorithm
\ref{alg:LP2}) is also similar to the {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} protocol (Algorithm
\ref{alg:LP1}), except for the following two differences.
Firstly, to satisfy the liveness requirement, we apply the
\textit{transmission-before-decide} technique as proposed in
\cite{gupta2018easycommit}.
Each participant will broadcast their decision to other nodes before rolling back
or persisting the transaction (Algorithm \ref{alg:LP2}, lines
\ref{line:AlgLP2BroadcastAbort}, \ref{line:AlgLP2SlowPath}, and
\ref{line:AlgLP2BroadcastAbort2}).
With reliable connections, the broadcasted decision will eventually reach
every non-crashed node.
Therefore, when a participant is blocked for not receiving any decision, no
participant has decided for $T$.
It can then communicate with a new coordinator to commit or abort the
transaction (line \ref{line:AlgLP2TentativeCommit}).
Secondly, each participant can quickly abort a transaction if it can detect a
crash failure in other participants.
In particular, if the participant $C_i$ does not receive all {\ensuremath{Yes}} votes from
other participants within the network timeout $W_{C_i}$, it can directly decide
{\ensuremath{Abort}} (lines
\ref{line:AlgLP2NotReceiveAllYes}--\ref{line:AlgLP2VoteYesAndAbort}).
This processing corresponds to the \textit{fast execution path} of the
participant, as illustrated in Figure \ref{fig:prac-cf}.
In addition to the above requirements, termination protocol will also be
triggered if a participant receives all {\ensuremath{Yes}} votes from other participants,
but does not receive any {\ensuremath{Abort}} or {\ensuremath{Commit}} decision from other participants
or the coordinator within the crash timeout.
In this case, the transmission-before-decide technique ensures that none of these nodes has made a decision for the transaction.
Thus, all alive participants can run the termination protocol to reach an agreement
for the transaction.
\begin{figure}[ht]
\centering
\includegraphics[width=\linewidth]{figures/flacCF.pdf}
\caption{Timeline of {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}. Each participant forwards its decisions to
others before committing/aborting the transaction.}
\label{fig:prac-cf}
\end{figure}
\vspace{-1.5em}
\subsection{\hspace{-0.5em}{\fontsize{10.2}{12}\selectfont
{\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}} for Network-Failure Environment}}
\label{LP3}
In this environment, both crash failures and network failures may occur.
There have been several ACPs proposed to handle both these two failures, such as 3PC
\cite{3PC}, PAC \cite{maiyya2019unifying}, and Easy Commit (EC)
\cite{gupta2018easycommit}.
Among them, EC is the state-of-the-art non-blocking protocol, which is well
optimized for the network-failure environment.
For this environment, it is challenging to design a new ACP
that is better than EC.
%
Moreover, our goal is not to design a new protocol for the specific
network-failure environment, but rather to design the {\ensuremath{\textsf{FLAC}}} protocol which
can adapt well to different operating environments.
%
Therefore, we directly adopt the EC protocol as the dedicated protocol
{\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}} for the network-failure environment.
%
By using EC, {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}} can directly commit transactions without having to enter
the \textit{validate} or \textit{propose} phases like {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and
{\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}.
Finally, since {\ensuremath{\textsf{FLAC}}}'s design is modular, in the future, if there is a new ACP
that can perform better than EC, we can also adopt it as {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}}.
\input{chapters/tbl-protocol-comparison}
\input{chapters/short-proof.tex}
\subsection{Protocol Comparison}
\label{sec:comparison}
We conclude this section by presenting a theoretical comparison among {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}},
{\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}}, and other ACPs: 2PC \cite{2PC}, 3PC \cite{3PC}, PAC
\cite{maiyya2019unifying}, Easy Commit \cite{gupta2018easycommit} in Table
\ref{tab:cp}.
Here, we calculate the maximum number of message delays that can happen on the
coordinator and participants.
There are three cases related to a {\ensuremath{\textsf{FLAC}}} execution: when it successfully commits a transaction, aborts a
transaction, or crashes before the transaction begins.
We also measure the message complexity, and describe which failures
each protocol can tolerate while ensuring liveness.
Overall, {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} require fewer message delays on both
the coordinator and the participants,
compared to 2PC, 3PC, and PAC.
As discussed in Section~\ref{LP1}, the fewer message delay enables {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and
{\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} to perform better than other protocols in distributed settings.
Table~\ref{tab:cp} also emphasizes our goal to design {\ensuremath{\textsf{FLAC}}} to adapt well to the changes
in the operating environment.
{\ensuremath{\textsf{FLAC}}} can perform well in different operating conditions: while
{\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} is designed for failure-free environments, {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} can tolerate
crash failures, and {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}} can endure both crash and network failures.
This is the major difference between {\ensuremath{\textsf{FLAC}}} and the other protocols like 2PC, which
can only support network failures, or 3PC, EC, which can endure crash
and network failures, but might not perform well in the failure-free
environment.
\subsection{Correctness Proof of \ensuremath{\textsf{FLAC}}}
\label{sec:flacCorrectness}
We conclude our {\ensuremath{\textsf{FLAC}}} design with a proof of correctness for the overall system formed by all components introduced in this paper, including the two-phase transaction processing system (Section~\ref{sec:systemModel}), dedicated protocols for each operating environment (Section~\ref{sec:subProtocols}), and the {\ensuremath{\mathrm{RLSM}}} manager (Section~\ref{rlsm}).
\begin{proposition}[Correctness]
{\ensuremath{\textsf{FLAC}}} ensures overall safety, liveness (Definition~\ref{def1}), and durability.
\end{proposition}
\begin{proof}
{\ensuremath{\textsf{FLAC}}} ensures overall safety by executing transactions with commit protocols that have been proven to be safe (Proposition~\ref{prop:Safety}).
It sticks to {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, or {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}} in each execution and thus avoids the problems caused by interleaving executions.
For liveness, {\ensuremath{\textsf{FLAC}}} continuously detects unexpected failures that could cause transactions to be aborted or blocked (Proposition~\ref{thmSoundness} and ~\ref{thmCompleteness}) and adjusts to a more suitable protocol for eventual liveness (Proposition~\ref{prop:Liveness} and Algorithm~\ref{alg:rlsm}).
Finally, by persisting the transaction logs to non-volatile storages and designing ways to recover nodes from failures with these logs (Section~\ref{recovery}), {\ensuremath{\textsf{FLAC}}} ensures durability.
\end{proof}
\section{Related works}
\label{related}
\vspace{-0.1em}
Atomic Commit Protocol (ACP) for distributed transactions is an important topic in
database systems.
Initially proposed by Skeen in~\cite{Skeen}, ACP sees a series of improvements
in ~\cite{HFC, NBAF, WFD}.
Among them, 2PC~\cite{2PC} is widely recognized as the golden standard in the
industry but is also well-known to be the bottleneck of distributed systems for
its low efficiency.
Existing ACPs optimize 2PC by (i) enhancing the performance during normal
processing, or (ii) improving availability by ensuring liveness property, or
(iii) making the protocol adaptive for better overall performance.
To enhance the performance during normal processing, PrA (Presumed Abort)
and PrC (Presumed Commit) protocols were introduced in
\cite{mohan1986transactionprcpra}, which use additional logs to reduce the cost
of aborting or committing messages.
PrC was further optimized in \cite{lampson1993new} by giving up knowledge about
the transactions prior to coordinator failures to enhance its performance.
Nonetheless, these protocols, and their variants in \cite{al1997enhancing,
chrysanthis1998recovery}, cannot reduce the participant-side message delay.
To improve such participant-side message delay, 1PC \cite{1PCY} and other
variant protocols \cite{stamos1990low, stonebraker1979UV, stamos1993EP}
sacrifice the generalizability by adding additional strong assumptions, while
O2PC \cite{levy1991optimistic} compromises the atomicity by optimistically
assuming all global transactions will not fail to ensure serializability.
Compared with them, {\ensuremath{\textsf{FLAC}}} can execute transactions more
efficiently without compromising the generalizability or the ACID properties.
Several works have also been proposed to improve the availability of ACPs by
ensuring the liveness property.
3PC and variant ACPs ~\cite{skeen1982quorum, 3PC, gupta2018easycommit} address
2PC's lack of termination when nodes fail by adding additional messages or
communication steps.
G-PAC and its variants \cite{hammer1980reliability, PAX, maiyya2019unifying,
zhang2018building} ensure the liveness of 2PC under node failures by
replication.
Easy Commit (EC) reduces the communication steps of 3PC by the
transmission-before-decide technique \cite{gupta2018easycommit}.
Paxos Commit is introduced in \cite{PAX} to ensure liveness by replicating
coordinator logs.
Unlike them, {\ensuremath{\textsf{FLAC}}} does not require replicas; it is equipped with an
adaptivity ability to handle failures and achieve high performance.
Moreover, while other ACPs assume a fixed running condition, {\ensuremath{\textsf{FLAC}}} monitors
the condition during execution and dynamically switches to a suitable dedicated
protocol.
There are also other ACPs that can switch to operate a suitable protocol
when system behavior or requirements change.
For example, ACOM \cite{ACOM} can shift between 2PC-PrA and 2PC-PrC according to
node behavior.
ADTP \cite{ADTP} can let service providers choose between PrC and PrA.
ML1-2PC \cite{12PC, ML12PC} can dynamically select either 1PC or 2PC based on
transaction behavior and system requirements.
Besides, a consensus protocol Domino \cite{yan2020domino} can adapt executions
automatically between fast or slow paths with the network timeout.
Compared to these works, {\ensuremath{\textsf{FLAC}}} focuses on a different setting: it optimizes
ACP for operating environments where crash or network failures can occur and
change over time.
Such setting is common in cloud systems~\cite{decandia2007dynamo}, and {\ensuremath{\textsf{FLAC}}}
can achieve good performance without compromising generalizability.
\section{Robustness-Level State Machines}
\label{rlsm}
We now describe the robustness-level state machine (RLSM) manager of the
coordinator node (Figure \ref{fig:STA}).
Recall that this component is responsible for capturing the robustness level of
each participant node so that the coordinator can determine the suitable
dedicated protocol ({\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, or {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}}) to execute a
transaction.
Following previous works~\cite{DBLP:phd/us/Chandra93,
DBLP:conf/srds/GuerraouiLS95}, we design {\ensuremath{\mathrm{RLSM}}} as a lightweight and
practical failure detector that provides enough properties to ensure {\ensuremath{\textsf{FLAC}}}'s
liveness.
To minimize {\ensuremath{\mathrm{RLSM}}}'s impact on transaction processing, {\ensuremath{\mathrm{RLSM}}} does not add any
extra network communications (only based on {\ensuremath{\mathcal{R}_T}}), and it only adjusts
protocols when liveness is affected.
Note that we employ an RL-based parameter tuner for {\ensuremath{\mathrm{RLSM}}}'s downgrade
transitions.
To avoid this parameter tuning becoming a new bottleneck, we take its model
training off the critical path and cache the learned results.
In the following, we formalize the RLSM in Definition~\ref{def-rlsm} and
describe its state transitions.
\begin{definition}[RLSM]
\label{def-rlsm}
A robustness-level state machine (RLSM) is a state machine denoted as $\langle
\mathcal{L}, L_0, \mathcal{E}, \delta \rangle$, which comprises of:
\begin{itemize}[label=--, left=0.5em, nosep]
\item A set of states $\ensuremath{\mathcal{L}} = \{\ensuremath{L_{\mathsf{FF}}}, \ensuremath{L_{\mathsf{CF}}}, \ensuremath{L_{\mathsf{NF}}}\}$, in
which $\ensuremath{L_{\mathsf{FF}}}, \ensuremath{L_{\mathsf{CF}}}, \ensuremath{L_{\mathsf{NF}}}$ respectively represent the
failure-free, crash-failure, and network-failure robustness levels.
\item An initial state $L_0 = \ensuremath{L_{\mathsf{FF}}}$.
\item A set of input events $\ensuremath{\mathcal{E}} = \{ CF, NF, FF(\ensuremath{\alpha_{\mathsf{CF}}}),
FF(\ensuremath{\alpha_{\mathsf{NF}}})\}$, in which $CF, NF$ respectively indicate a crash or a
network failure occurs in a transaction execution, $FF(\ensuremath{\alpha_{\mathsf{CF}}})$,
$FF(\ensuremath{\alpha_{\mathsf{NF}}})$ respectively represent a sequence of $\ensuremath{\alpha_{\mathsf{CF}}}$ and a
sequence of $\ensuremath{\alpha_{\mathsf{NF}}}$ consecutive failure-free transaction executions at
the crash- and the network-failure level.
\item A state transition function $\delta : \ensuremath{\mathcal{L}} \times \ensuremath{\mathcal{E}}
\rightarrow \ensuremath{\mathcal{L}}$, which is defined as the illustration in
Figure~\ref{fig:RLSM}.
\end{itemize}
\end{definition}
\vspace{-0.5em}
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{figures/rlsm.pdf}
\caption{{\ensuremath{\mathrm{RLSM}}} transition diagram.}
\label{fig:RLSM}
\end{figure}
\vspace{-0.5em}
Note that in Definition \ref{def-rlsm}, parameter $\ensuremath{\alpha_{\mathsf{CF}}}$ and $\ensuremath{\alpha_{\mathsf{NF}}}$ of
the two events $FF(\ensuremath{\alpha_{\mathsf{CF}}})$ and $FF(\ensuremath{\alpha_{\mathsf{NF}}})$ are determined separately for
transaction executions in the crash-failure and the network-failure levels.
Moreover, for each transition state, the RLSM manager can only detect
events corresponding to the state's intolerable failures.
Specifically, while it can detect the two events $CF, NF$ for {\ensuremath{L_{\mathsf{FF}}}}
state, only the event $NF$ can be caught for {\ensuremath{L_{\mathsf{CF}}}} state.
Furthermore, none of the two events $CF$ and $NF$ can be tracked for {\ensuremath{L_{\mathsf{NF}}}}
state.
Algorithm \ref{alg:rlsm} formalizes how the RLSM manager detects unexpected failures or consecutive failure-free executions and sends the corresponding events (Definition~\ref{def-rlsm}) to the participants' RLSMs.
Firstly, if the RLSM manager can detect a crash or a network failure during a transaction
execution (lines \ref{line:AlgRlsmMissingFF}, \ref{line:AlgRlsmCheckNF4flacFF},
\ref{line:AlgRlsmMissingCF}, \ref{line:AlgRlsmCheckNF4flacCF}), it will trigger
a $CF$ or $NF$ event to update the current state to a more stringent robustness
level {\ensuremath{L_{\mathsf{CF}}}} or {\ensuremath{L_{\mathsf{NF}}}} (lines \ref{line:AlgRlsmCFDetect},
\ref{line:AlgRlsmAsyNF4FF}, \ref{line:AlgRlsmNF4flacFF},
\ref{line:AlgRlsmAsyNF4CF}, \ref{line:AlgRlsmNF4flacCF}).
This update is called the \textit{robustness upgrade} transition; it
corresponds to the solid lines in Figure \ref{fig:RLSM}.
Secondly, if the RLSM manager observes a number of failure-free consecutive
executions in a high robustness-level state ($\ensuremath{\alpha_{\mathsf{CF}}}$ times for $\ensuremath{L_{\mathsf{CF}}}$
and $\ensuremath{\alpha_{\mathsf{NF}}}$ times for {\ensuremath{L_{\mathsf{NF}}}} -- lines \ref{line:AlgRlsmCheck4DownCF},
\ref{line:AlgRlsmCheck4DownNF}), it will respectively trigger the event
$FF(\ensuremath{\alpha_{\mathsf{CF}}})$ or $FF(\ensuremath{\alpha_{\mathsf{NF}}})$ to move the system to the lowest
robustness-level state {\ensuremath{L_{\mathsf{FF}}}} (lines \ref{line:AlgRlsmDownCF},
\ref{line:AlgRlsmDownNF}).
This update is called the \textit{robustness downgrade} transition;
it corresponds to the dotted lines in Figure \ref{fig:RLSM}.
In the following subsections, we will elaborate on these failure detections and
robustness transitions.
\vspace{-0.5em}
\input{chapters/algo-rlsm}
\vspace{-0.5em}
\subsection{Robustness-Upgrade Transitions}
\label{upward}
The robustness-upgrade transition shifts {\ensuremath{\mathrm{RLSM}}} of a participant
toward a more stringent robustness level so that subsequent transactions
involving it can run with a more resilient protocol.
We design {\ensuremath{\textsf{FLAC}}} to take a lazy approach that only upgrades the robustness
level when it can detect transaction-blocking failures by analyzing past
execution results.
It is different from traditional approaches \cite{yu2011practical,
DBLP:conf/ipps/ZhangS08} that continuously monitor the systems to predict the
periods when failure can happen proactively.
Such monitoring can be a new bottleneck of the system.
In contrast, {\ensuremath{\textsf{FLAC}}} can detect failures efficiently by analyzing past execution
results as follows:
First, the {\ensuremath{\mathrm{RLSM}}} manager can detect
failures for both {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} by checking if the coordinator does not receive all participants'
results, i.e., some results are missing in {\ensuremath{\mathcal{R}_T}}.
For {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, the failure type is agnostic before a crash timeout.
In this case, the {\ensuremath{\mathrm{RLSM}}} manager first inputs CF events to the
RLSMs of non-responsive participants, who are likely to crash (line
\ref{line:AlgRlsmCFDetect}).
Then, it will send NF events to the RLSMs of participants who reply
late (line \ref{line:AlgRlsmAsyNF4FF}), since these late replies are likely
caused by network delays.
For {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, it tolerates crash failures, and thus only needs to detect
network failures.
Like the previous case, the RLSM manager will input NF events to the RLSMs of
participants who reply late (line \ref{line:AlgRlsmAsyNF4CF}).
Second, the {\ensuremath{\mathrm{RLSM}}} manager can detect network failures for both {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} by analyzing the received results.
For {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, it will report that network failures occur between
participants if the coordinator receives $\result{\ensuremath{Yes}, \ensuremath{Undecide}}$ (lines \ref{line:AlgRlsmCheckNF4flacFF}--\ref{line:AlgRlsmNF4flacFF}).
This {\ensuremath{Undecide}} result indicates that some votes sent to a participant did not arrive on time due to network delay.
For {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, it will conclude that a network failure occurs if there
exist aborted transactions that get all {\ensuremath{Yes}} votes (lines
\ref{line:AlgRlsmCheckNF4flacCF}--\ref{line:AlgRlsmNF4flacCF}).
This is because if there were no network failures and all participants voted {\ensuremath{Yes}}, the transactions should have been committed.
For both {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, if a network failure occurred, the {\ensuremath{\mathrm{RLSM}}} manager cannot identify precisely the involved participants, since the failure can happen among a set of nodes.
Therefore, the {\ensuremath{\mathrm{RLSM}}} manager will shift all the participants' states to the
network-failure level (lines \ref{line:AlgRlsmNF4flacFF}, \ref{line:AlgRlsmNF4flacCF}).
We prove the correctness of our failure detection rules above in Appendix~\ref{sec:failureDetectionProof}. We also prove the soundness and
completeness of the {\ensuremath{\mathrm{RLSM}}} state transition algorithm in Appendix~\ref{sec:rlsmCorrectness} and the
correctness of {\ensuremath{\textsf{FLAC}}} in Appendix ~\ref{sec:flacCorrectness}.
\vspace{-0.5em}
\subsection{Robustness-Downgrade Transitions}
\label{downwd}
The robustness-downgrade transitions shift the RLSM state from a stringent level to
a lenient one.
{\ensuremath{\textsf{FLAC}}} triggers these transitions by monitoring the protocol execution.
Specifically, if there is a participant in the crash-failure level who can consecutively
execute $\ensuremath{\alpha_{\mathsf{CF}}}$ transactions without any failure, then the
RLSM manager can transition its RLSM to the failure-free level (lines
\ref{line:AlgRlsmCheck4DownCF}--\ref{line:AlgRlsmDownCF}).
Likewise, $\ensuremath{\alpha_{\mathsf{NF}}}$ is the number of consecutive failure-free transaction
executions that a participant must perform at the network-failure level before
its RLSM can be shifted to the failure-free level (lines
\ref{line:AlgRlsmCheck4DownNF}--\ref{line:AlgRlsmDownNF}).
The two parameters $\ensuremath{\alpha_{\mathsf{CF}}}$, $\ensuremath{\alpha_{\mathsf{NF}}}$ above control the trade-off between
the protocol adaptivity and the state transitioning frequency.
Intuitively, the smaller values of $\ensuremath{\alpha_{\mathsf{CF}}}$ and $\ensuremath{\alpha_{\mathsf{NF}}}$ enable {\ensuremath{\textsf{FLAC}}} to
react faster upon the change of operating conditions, thus getting more
opportunities to run a more lenient protocol.
However, it also lets {\ensuremath{\textsf{FLAC}}} enter the costly \textit{slow path}
when failures recur quickly.
\textit{Fine-tuning $\ensuremath{\alpha_{\mathsf{CF}}}$ and $\ensuremath{\alpha_{\mathsf{NF}}}$ by reinforcement learning (RL).}
Generally, it is challenging to fine-tune $\ensuremath{\alpha_{\mathsf{CF}}}$ and $\ensuremath{\alpha_{\mathsf{NF}}}$ to
optimize the performance of {\ensuremath{\textsf{FLAC}}}.
A naive approach is to exhaustively test their possible values, but this trial
and error method is costly.
Also, this test needs to be performed every time the system is reconfigured,
such as, when adding a new node or replacing a machine.
To mitigate this problem, we propose an RL-based optimizer to automatically
select the best $\ensuremath{\alpha_{\mathsf{CF}}}$ and $\ensuremath{\alpha_{\mathsf{NF}}}$.
We employ q-learning ~\cite{watkins1992q} as the RL learner and build our model
as depicted in Figure~\ref{fig:rl}.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.9\linewidth]{figures/rl.pdf}
\vspace{-0.5em}
\caption{Overview of the RL-based optimizer,
where $L, \mu$ denote the current robustness
level and the reward (average throughput).}
\label{fig:rl}
\end{figure}
In essence, the RLSM manager asynchronously sends the execution results $\ensuremath{\mathcal{R}_T}$ with
their robustness levels $L$ to the collector.
The collector resets the learner's state once it encounters a level change.
Otherwise, it buffers $(L, \ensuremath{\mathcal{R}_T})$ until enough pairs are collected.
It then calculates the average throughput (transaction per second -- tps) as
the reward $\mu$\,\footnote{Users can decide how to choose a suitable reward
function to obtain good performance, depending on their applications.
%
In this work, we use the average throughput.
%
Other systems such as ~\cite{decandia2007dynamo, corbett2013spanner,
yan2020domino} value tail latency, while ~\cite{debnath2010flashstore} value
throughput, and \cite{li2019qtune, yoon2018mutant} value both and thus
express their requirements using more complex functions.} and sends $(L, \mu)$
to the strategy maker, who can use this information to train the learner.
The learner learns a Markov chain on whether to continue waiting or
make the downgrade transitions regarding the current state.
{The strategy maker interacts with the learner during training and
adjusts the participants' {\ensuremath{\mathrm{RLSM}}} according to the learner's replies.
After enough training, the strategy maker can cache the learned strategies as
$\ensuremath{\alpha_{\mathsf{CF}}}$ or $\ensuremath{\alpha_{\mathsf{NF}}}$.
According to our experiment that we will show later in Section
\ref{sec:TurningRLParams}, the throughput gain for parameters greater than 256
is insignificant, and thus we limit the maximum value of $\ensuremath{\alpha_{\mathsf{CF}}}$
and $\ensuremath{\alpha_{\mathsf{NF}}}$ to 256 in our RL model.
With a limited search space, the parameter tuner only takes up to 5 seconds to
tune the parameters.
The users can call the RL-based parameter tuner after a time interval
(e.g., hourly) or when the system is reconfigured (e.g. replacing a node).
The upward and downward transitions allow a participant's {\ensuremath{\mathrm{RLSM}}} to
keep its data in memory without durability.
They ensure the fast correction of {\ensuremath{\mathrm{RLSM}}} whose robustness level may not match actual operating environments.
Thus, the {\ensuremath{\mathrm{RLSM}}} can be recovered to an arbitrary robustness level without
concerns about protocol liveness.
Our system sets the default {\ensuremath{\mathrm{RLSM}}} level to the failure-free level to execute
more transactions with lightweight protocols.
\section{Limitations and Future Work}
\label{sec:short-discussion}
We now discuss the limitations of {\ensuremath{\textsf{FLAC}}} and our future work.
Firstly, {\ensuremath{\textsf{FLAC}}}'s higher message complexity can affect system performance when
each transaction involves many participants.
However, we have conducted additional experiments to study this limitation and
observed that {\ensuremath{\textsf{FLAC}}} always performs better or at least comparably to other
protocols in all settings.
Details of these experiments are described in Appendix~\ref{sec:experimentApp}.
Secondly, {\ensuremath{\textsf{FLAC}}} may compromise the liveness of transactions executed with
wrong operating condition assumptions.
The blocked transactions could exacerbate the contention between transactions
and reduce system throughput.
Such blocking has already been widely accepted in existing systems that use 2PC.
Meanwhile, we have proposed {\ensuremath{\mathrm{RLSM}}} to alleviate this problem, enabling {\ensuremath{\textsf{FLAC}}}
to outperform all other protocols even in unstable environments.
Thirdly, we follow state-of-the-art ACPs \cite{2PC, 3PC, gupta2018easycommit,
gupta2020efficient} to not consider system replication in the design of
{\ensuremath{\textsf{FLAC}}}.
Nonetheless, {\ensuremath{\textsf{FLAC}}} can be easily customized for replicated systems by three
steps: asynchronously replicating decisions for {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}},
synchronizing decisions to replicas upon transition to the network-failure
level, and adopting replicated ACPs for {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}}.
We detail these steps in Appendix~\ref{app:discussion}.
Note that {\ensuremath{\textsf{FLAC}}} does not always ensure availability when failures
happen.
Unlike replicated ACPs ~\cite{PAX, maiyya2019unifying, zhang2018building},
{\ensuremath{\textsf{FLAC}}} is not designed for systems that require extremely high availability.
Instead, it strikes a balance between system availability and efficiency.
We discuss this issue with more details in Appendix~\ref{app:discussion}.
\subsection{Protocol Correctness}
Like existing atomic commit protocols~\cite{PAX, skeen1982quorum, gupta2018easycommit, maiyya2019unifying}, we prove the correctness of {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, and {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}} in safety and liveness.
\begin{proposition}[Safety]
\label{prop:Safety} All protocols in {\ensuremath{\textsf{FLAC}}} ensure the validity and the agreement
properties (Definition \ref{def1}).
\end{proposition}
\begin{proof}
(1). The validity property of {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} is ensured by Algorithm \ref{alg:LP1}:
this protocol decides {\ensuremath{Abort}} only if there exists a node voting {\ensuremath{No}}
(lines \ref{line:AlgLP1VoteNo}--\ref{line:AlgLP1VoteNoAndAbort},
\ref{line:AlgLP1ReceiveNo}--\ref{line:AlgLP1Abort}), and decides {\ensuremath{Commit}}
when all nodes vote {\ensuremath{Yes}} (lines
\ref{line:AlgLP1ReceiveAllYes}--\ref{line:AlgLP1Commit}), which implies no
node votes {\ensuremath{No}}.
(2). {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}'s agreement is proved by contradiction.
%
Suppose that there are two nodes deciding differently, then there is a node
deciding {\ensuremath{Commit}}, and another deciding {\ensuremath{Abort}}.
%
Since there is one node deciding {\ensuremath{Commit}}, it follows from Algorithm
\ref{alg:LP1} (lines \ref{line:AlgLP1ReceiveAllYes}--\ref{line:AlgLP1Commit})
that all nodes must vote {\ensuremath{Yes}}.
%
Since there is one node deciding {\ensuremath{Abort}}, according to Algorithm
\ref{alg:LP1} (lines \ref{line:AlgLP1VoteNo}--\ref{line:AlgLP1VoteNoAndAbort},
\ref{line:AlgLP1ReceiveNo}--\ref{line:AlgLP1Abort}), there must be a node
voting {\ensuremath{No}}.
%
The two previous results contradict each other.
(3). {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}'s validity property. According to Algorithm \ref{alg:CO2},
{\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} decides {\ensuremath{Commit}} if all nodes vote $\ensuremath{Yes}$ and no failures happen
(lines \ref{line:AlgCO2Commit}--\ref{line:AlgCO2NotReceiveAll}). Moreover,
Algorithm~\ref{alg:LP2} shows that {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} will decide {\ensuremath{Abort}} if there
exists a node voting $\ensuremath{No}$ (lines
\ref{line:AlgLP2VoteNo}--\ref{line:AlgLP2VoteNoAndAbort},
\ref{line:AlgLP2BroadcastAbort2}--\ref{line:AlgLP2VoteYesAndAbort}). Hence,
the validity of {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} is confirmed.
(4). For {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}'s agreement, by contradiction, suppose there are two nodes
deciding differently: node $C_{i}$ decides {\ensuremath{Commit}} and node $C_{j}$ decides
{\ensuremath{Abort}}.
%
Since $C_i$ decides {\ensuremath{Commit}}, according to Algorithm~\ref{alg:CO2} (lines
\ref{line:AlgCO2Commit}--\ref{line:AlgCO2NotReceiveAll}), no node decides
{\ensuremath{Abort}} before the crash timeout.
%
Algorithm \ref{alg:LP2} (lines
\ref{line:AlgLP2TentativeCommit}--\ref{line:AlgLP2SlowPath}) shows that
$C_{i}$ needs to broadcast its {\ensuremath{Commit}} decision before deciding {\ensuremath{Commit}},
this decision will reach all nodes before the crash timeout, and make them
decide {\ensuremath{Commit}}, too.
%
This result contradicts with the assumption that $C_{j}$ decides {\ensuremath{Abort}}.
(5). For {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}}, it is identical to EC; therefore, its safety is
guaranteed since EC's safety is proved in \cite{gupta2018easycommit}.
\end{proof}
\begin{proposition}[Liveness]
\label{prop:Liveness}
All protocols in {\ensuremath{\textsf{FLAC}}} ensure the termination property when executed in expected operating conditions.
\end{proposition}
\begin{proof}
{\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} does not need to consider the transaction blocking due to crash
failures for its failure-free operating condition assumptions.
%
{\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} makes progress with its termination protocol in case of
timeout due to crash failures (Section~\ref{LP2}).
%
Finally, {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}}, which is identical to EC, has been proven to be
non-blocking in ~\cite{gupta2018easycommit}.
\end{proof}
\section{System Overview}
\label{sec:systemModel}
This section presents an overview of our {\ensuremath{\textsf{FLAC}}} protocol: its
architecture and transaction processing system.
\subsection{Architecture}
We design {\ensuremath{\textsf{FLAC}}} using a typical transactional system architecture,
where one node is designated as the coordinator, while the other nodes serve as
participants.
Its system model is depicted in Figure~\ref{fig:STA}, where $C^*$ is
the coordinator and $\ensuremath{\mathcal{S}} =\{C_1, ..., C_n\}$ are the participants.
Each participant manages a local data store, while the coordinator serves as a
transaction coordinator which accepts and manages transactions from clients.
A transaction $T$ may read or update data stored in multiple nodes
which directly participate in $T$'s execution.
We denote these participant nodes as $\ensuremath{\mathcal{C}_T}$ $(\ensuremath{\mathcal{C}_T} \subseteq \ensuremath{\mathcal{S}})$.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.9\linewidth]{figures/sys_model.pdf}
\caption{The {\ensuremath{\textsf{FLAC}}} system model.}
\label{fig:STA}
\end{figure}%
Furthermore, {\ensuremath{\textsf{FLAC}}} consists of three different protocols, namely
{\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}}, which are dedicated respectively to a
failure-free, a crash-failure, and a network-failure environment.
In each execution, the coordinator $C^*$ first selects the most suitable
protocol, denoted as $\Pi_T$, based upon operating conditions of the
participants $\ensuremath{\mathcal{C}_T}$.
Then, all nodes in $\ensuremath{\mathcal{C}_T}$ will jointly execute $\Pi_T$ and try to reach their
local decisions for $T$.
Afterwards, they reply with their execution results to $C^*$.
These results, denoted as $\ensuremath{\mathcal{R}_T}$, include the nodes' initial votes and
decisions.
If a node fails to make a decision ({\ensuremath{Commit}}/{\ensuremath{Abort}}), it is
called the \textit{undecided} participant.
Finally, the coordinator $C^*$ will decide to commit/abort the transaction based
on the collected results and send that decision to all undecided participants.
Since we consider both crash and network failures (Section \ref{background}),
some participants in $\ensuremath{\mathcal{C}_T}$ might crash, or their replied results might not
reach the coordinator within the network timeout due to delay.
All other participants whose results can be well received by the coordinator are
called the responsive participants, and their results contribute to the result
set $\ensuremath{\mathcal{R}_T}$.
Furthermore, each of the responsive participants can either (i) vote {\ensuremath{Yes}} and
decide {\ensuremath{Commit}}, or (ii) vote {\ensuremath{Yes}} and decide {\ensuremath{Abort}}, or (iii) vote {\ensuremath{Yes}}
and do not decide, or (iv) vote {\ensuremath{No}} and decide {\ensuremath{Abort}}.
We denote these cases as $\result{\ensuremath{Yes}, \ensuremath{Commit}}$, $\result{\ensuremath{Yes}, \ensuremath{Abort}}$,
$\result{\ensuremath{Yes}, \ensuremath{Undecide}}$, and $\result{\ensuremath{No}, \ensuremath{Abort}}$
\footnote{The two cases $\result{\ensuremath{No}, \ensuremath{Commit}}$ and $\result{\ensuremath{No}, \ensuremath{Undecide}}$
will never occur since participants which vote {\ensuremath{No}} will always decide
{\ensuremath{Abort}} immediately (by the validity property in Definition~\ref{def1}).}.
The necessity of collecting both votes and decisions to keep protocol safe and alive is justified in Section~\ref{upward} and Section~\ref{downwd}.
We also equip the coordinator node $C^*$ with a component called robustness-level
state machine (RLSM) manager, which is responsible for determining the suitable
protocol $\Pi_T$ to execute $T$.
More specifically, we first represent three operating environments in
Section~\ref{failures} as three robustness levels: failure-free ($\ensuremath{L_{\mathsf{FF}}}$),
crash failure ($\ensuremath{L_{\mathsf{CF}}}$), and network failure ($\ensuremath{L_{\mathsf{NF}}}$).
During a transaction execution, {\ensuremath{\textsf{FLAC}}} analyzes the results reported by
participant nodes to detect if any failure occurs.
If there is an unexpected failure occurring in a participant node
(e.g., network failure or crash failure), it will upgrade this
node's robustness level to a more stringent level.
Otherwise, {\ensuremath{\textsf{FLAC}}} will record the total number of consecutive transactions
which have been executed successfully in this node.
If this number reaches a threshold representing the environment's stability,
{\ensuremath{\textsf{FLAC}}} will downgrade the node's robustness level to a more lenient level.
Later in Section \ref{rlsm}, we shall describe how to use reinforcement learning
to fine-tune this threshold so that {\ensuremath{\textsf{FLAC}}} can adapt well to changes of the
operating environment.
In our system model, we follow existing works~\cite{gupta2018easycommit,
skeen1982quorum, 3PC, 2PC} to assume \textit{reliable} but \textit{delayable}
connections between nodes.
Furthermore, although we currently separate the coordinator from the
participants, {\ensuremath{\textsf{FLAC}}} can be easily extended to the setting where the
coordinator also serves as a participant node, like the system model proposed in
\cite{lamport2006fast}.
This setting is simply an optimized version of our current system model, in
which the connection between that participant and the coordinator happens in
the same node.
We summarize the notations used in this paper in Table~\ref{tab:notation}.
\begin{table}[ht]
\centering
\caption{Symbols and descriptions}
\vspace{-1em}
\label{tab:notation}
\begin{tabular}{llll}
\toprule
$\ensuremath{\mathcal{S}}$ & the system of $n$ participant nodes $C_1, ..., C_n$ \\
$C^*$ & the coordinator node \\
$T$ & the transaction sent to $C^*$ \\
$\ensuremath{\mathcal{C}_T}$ & the participant nodes contributing to the commit of $T$ \\
$\ensuremath{\mathcal{R}_T}$ & the tentative execution results of $\ensuremath{\mathcal{C}_T}$ for $T$ \\
$\Pi_T$ & the protocol selected for $T$ \\
\bottomrule
\end{tabular}
\end{table}
\subsection{Transaction Processing}
\label{steps}
{\ensuremath{\textsf{FLAC}}} requires two phases to process a transaction $T$: the \textit{propose}
and the \textit{validate} phase.
They are described as follows.
\subsubsection{The propose phase.}
\label{propose}
The coordinator $C^*$ first selects a protocol $\Pi_T$ based on the most
stringent robustness level of participant nodes $\ensuremath{\mathcal{C}_T}$ of $T$.
Then, it instructs all these nodes to execute $\Pi_T$ to process $T$ tentatively
or persistently.
Next, relevant participant nodes $\ensuremath{\mathcal{C}_T}$ execute $\Pi_T$ trying to make local
decisions for $T$.
There are two scenarios for each participant node as follows.
Firstly, if the participant can make an {\ensuremath{Abort}} or {\ensuremath{Commit}} decision, it will
complete its local execution for $T$, add the decision in its log, and roll back or persist the local
changes respectively.
Secondly, if the participant cannot make a decision (i.e., stays {\ensuremath{Undecide}}),
it will block its local transaction execution and wait for the message from the
coordinator or other participants to continue.
In any cases, all participant nodes in $\ensuremath{\mathcal{C}_T}$ will eventually
reply their final states ({\ensuremath{Commit}}/{\ensuremath{Abort}}/{\ensuremath{Undecide}}) and initial votes
({\ensuremath{Yes}}/{\ensuremath{No}}) to $C^*$.
The collection of decisions and votes constitutes the set of results
$\ensuremath{\mathcal{R}_T}$, which is processed by {\ensuremath{\textsf{FLAC}}} in the second phase:
the \textit{validate} phase.
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{figures/flac-path.pdf}
\caption{Overall timeline of {\ensuremath{\textsf{FLAC}}}. \textit{Fast} path happens when all
participants make an {\ensuremath{Abort}} or {\ensuremath{Commit}} decision.
\textit{Slow} path occurs when some participants stay {\ensuremath{Undecide}}.
}
\label{fig:SAB}
\end{figure}
\subsubsection{The validate phase.}
\label{validate}
In this phase, the coordinator $C^*$ performs two tasks concurrently to process
the result set $\ensuremath{\mathcal{R}_T}$.
Firstly, $C^*$ analyzes the results in $\ensuremath{\mathcal{R}_T}$ to detect if any failure
occurs and adjusts the robustness level of nodes in $\ensuremath{\mathcal{C}_T}$ accordingly.
We will explain in detail this adjustment in Section~\ref{rlsm}.
Secondly, it commits or aborts the transaction $T$ in a \textit{fast}
or a \textit{slow execution path}.
In particular, a \textit{fast path} is resulted when all nodes in $\ensuremath{\mathcal{C}_T}$ have
decided to abort or commit the transaction $T$.
Since $T$ is already rolled back or made persist in the
\textit{propose} phase at each participant node (Section~\ref{propose}), the participants have finished their executions of $T$, and thus the
coordinator $C^*$ only needs to send the decision to clients and terminate
the transaction $T$.
This path is illustrated by the blue dashed line in Figure~\ref{fig:SAB}.
In contrast, a \textit{slow path} is resulted when not all
participant nodes $\ensuremath{\mathcal{C}_T}$ have decided to abort/commit the transaction $T$.
In this case, the coordinator $C^*$ dictates a decision according to $\ensuremath{\mathcal{R}_T}$
and $\Pi_T$, and then notifies all participants.
Each participant, upon receiving the decision, will locally commit or abort $T$
on its storage.
After broadcasting all messages to notify the decision, the coordinator then
reports the decision to clients.
This path is illustrated by the red and blue solid lines; both labeled by
\textsf{``Slow path''} in Figure~\ref{fig:SAB}.
{\ensuremath{\textsf{FLAC}}} executes most transactions in \textit{fast path} for efficiency. The reason is two-fold. On the coordinator side, the \textit{slow path} requires it to broadcast
decisions to all {\ensuremath{Undecide}} participants, which slightly increases the
latency.
%
On the participants' side, the \textit{slow path} requires each participant to
block and wait for decisions from other nodes, which introduces significant
contention between concurrent transactions and reduces the throughput.
Therefore, to achieve high performance, {\ensuremath{\textsf{FLAC}}} tries to execute most
transactions in \textit{fast path}.
\subsection{Failure Handling of {\ensuremath{\textsf{FLAC}}}}
\label{sec:failureHandleApp}
This section elaborates on how {\ensuremath{\textsf{FLAC}}} handles crash failures during transaction processing.
We follow existing works~\cite{skeen1983formal, gupta2018easycommit, skeen1982quorum} to discuss {\ensuremath{\textsf{FLAC}}}'s failure handling in two aspects:
how {\ensuremath{\textsf{FLAC}}} safely recovers a node from crash failure by continuing half-executed transactions (crash recovery),
and how {\ensuremath{\textsf{FLAC}}} terminates the transaction execution when it gets blocked by crash failure of some other nodes (protocol termination).
\subsubsection{Crash Recovery}
\label{recovery}
{\ensuremath{\textsf{FLAC}}} tolerates crash failures by adding transaction logs to non-volatile storages.
In recovery, we provide a set of rules that help crashed nodes resolve half-executed transactions without violating safety properties.
We design {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} to take a similar logging strategy as 2PC~\cite{2PC}.
It logs the votes and decisions of participants as $ready-yes/no$ or $commit/abort$ before sending votes to others or making local decisions, respectively.
{\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} adds $ready-yes/no$ and $commit/abort$ logs alike {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}}, and follow ~\cite{gupta2018easycommit} to add $transit-commit/abort$ logs before broadcasting the decision.
We exclude the recovery process of {\ensuremath{\textsf{FLAC}_{\mathsf{NF}}}} since it reuses EC.
The following paragraphs show how {\ensuremath{\textsf{FLAC}}} performs the crash recovery of the coordinator and participants.
When a coordinator node recovers from crash failure, it first finds all half-executed transactions recorded in $propose$ logs, temporarily blocks accesses to data records updated by them, and resolves these transactions following three steps:
\begin{itemize}
\item For each half-executed transaction $T$, the coordinator first checks if $\Pi_{T} = ${\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} and no $transit-commit$ log is detected locally. If this check succeeds, by Algorithm~\ref{alg:CO2}, no participant node could decide {\ensuremath{Commit}}. Thus, the coordinator can directly abort the transaction.
\item Otherwise, the coordinator queries $T's$ logs on participants in {\ensuremath{\mathcal{C}_T}}. If a decision log is found, the coordinator decides accordingly to ensure the agreement property. If there exist alive participant nodes in {\ensuremath{\mathcal{C}_T}} that do not include $ready-no$ logs, the coordinator directly decides {\ensuremath{Abort}} since the transaction is not committable without all {\ensuremath{Yes}} votes (validity property).
\item Finally, if $T$'s state is still unresolved, the coordinator waits until it gets the $ready-yes$ logs from all {\ensuremath{\mathcal{C}_T}} and continues {\ensuremath{\textsf{FLAC}}}'s execution in Algorithm~\ref{alg:CO1} line~\ref{line:AlgCO1AllUndecided} or Algorithm~\ref{alg:CO2} line ~\ref{line:AlgCO2Commit} to commit the transaction $T$.
\end{itemize}
In recovery, the participant first takes the same process as the coordinator to detect half-executed transactions and blocks concurrent access to involved data records.
It then directly aborts half-executed transactions with $ready-no$ logs by validity property.
If the transaction is still unresolved, the participant attempts to get the final state by communicating with other nodes.
The participant decides the final state of an unresolved transaction $T$ by the following three cases:
\begin{itemize}
\item If the participant obtains a decision for $T$ from other nodes, it decides accordingly by the agreement property.
\item Suppose the participant detects an alive participant in {\ensuremath{\mathcal{C}_T}} without $ready-yes$ logs for $T$, it directly aborts the transaction by the validity property.
\item If neither case occurred, the participant waits until it receives $ready-yes$ logs from all {\ensuremath{\mathcal{C}_T}} and reaches an agreement with them using a new coordinator.
\end{itemize}
\subsubsection{Protocol Termination}
\label{termination}
In {\ensuremath{\textsf{FLAC}}} executions, a node $C_i$ may wait for the messages from others to continue its local execution.
This node $C_i$ may hold back its execution to accommodate all messages from alive nodes before the crash timeout.
If no message arrives at $C_i$ before the crash timeout due to crash failures, $C_i$ will block its local execution and switches to termination protocol, trying to avoid transaction blocking.
Our protocol {\ensuremath{\textsf{FLAC}}} guarantees the non-blocking termination of transactions executed with a correct dedicated protocol that matches the actual operating condition.
Otherwise, {\ensuremath{\textsf{FLAC}}} may block the current transaction execution and wait for some crashed nodes' recovery.
In the following paragraph, we present our termination protocol by listing each coordinator's or participant's behaviors on the crash timeout.
As shown in Algorithms ~\ref{alg:CO1} \ref{alg:LP1} \ref{alg:CO2} and \ref{alg:LP2}, the coordinator can only timeout in {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} (Algorithm~\ref{alg:CO1} line~\ref{line:AlgCO1Termination}), while the participant can timeout in both {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} and {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} (Algorithm~\ref{alg:LP1} line~\ref{line:AlgLP1TerminationProtocol} and Algorithm~\ref{alg:LP2} line~\ref{line:AlgLP2Termination}).
If a coordinator timeouts, it blocks the execution of transaction $T$ locally, requests the transaction state on {\ensuremath{\mathcal{C}_T}}, and waits until it (i) receives the decision for $T$ and decides accordingly (by the agreement property), (ii) finds the absence of $ready-yes$ log on one participant and then decides {\ensuremath{Abort}} (by the validity property), or (iii) receives \result{\ensuremath{Yes}, \ensuremath{Undecide}} from all participants and then decides {\ensuremath{Commit}} by continuing on Algorithm~\ref{alg:CO1} line~\ref{line:AlgCO1AllUndecided} or Algorithm~\ref{alg:CO2} line ~\ref{line:AlgCO2Commit}.
A participant timeout in {\ensuremath{\textsf{FLAC}_{\mathsf{FF}}}} first tries to find the decision logs or the absence of $ready-yes$ logs from other nodes and decides with the same process as the coordinator.
If neither is found on alive nodes, the participant waits until all $\ensuremath{\mathcal{C}_T}$ become alive and then reaches an agreement among them by a new coordinator.
Otherwise, if a participant timeouts in {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}}, the transmission-before-decide technique~\cite{gupta2018easycommit} used by {\ensuremath{\textsf{FLAC}_{\mathsf{CF}}}} ensures that no node has made a decision for $T$.
Thus, the participant can safely decide {\ensuremath{Abort}} and terminate the current transaction execution.
| {'timestamp': '2023-03-03T02:10:03', 'yymm': '2302', 'arxiv_id': '2302.04500', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04500'} | arxiv |
\section{Introduction}
A direct quotation, a verbatim replication of a speaker's words as opposed to offering news reporters' own opinions, manifests news stories' neutrality, factuality, and objectivity~\cite{ZELIZER+1989+369+388}. Quoting others also adds color to the news with authentic expressions and conveniently establishes authority based on the speakers’ reputation~\cite{newsreportingwriting}. Therefore, a direct quotation constitutes an integral element of news reporting~\cite{nylund2003quoting}.
More studies have found a link between the use of direct quotations and fake news. Content analyses of news stories document evidence such that deceptive (\emph{versus} trustworthy) news articles contain more direct quotations~\cite{dalecki2009news,govaert2020deceptive}. An equally problematic but less studied concern involving direct quotations is \emph{contextomy}, quoting words out of context in a way that alters the speaker's intention. A previous study argued that contextomy is a "common spin tactic" of news reporters promoting their political agenda~\cite[p.~332]{mcglone2005quoted}.
\begin{table*}[t]
\small
\centering
\begin{tabular}{p{3.75cm} | p{9.2cm} | c}
\hline
News headline quote & Body-text quotes & Label\\\hline
\makecell[l]{
"이대론 그리스처럼 파탄"\\
(A debt crisis, like Greece, is \\ on the horizon)} &
\makecell[l]{"건강할 때 재정을 지키지 못하면 그리스처럼 될 수도 있다"\\(If we do not maintain our fiscal health, we may end up like Greece) \\"강력한 ‘지출 구조조정’을 통해 허투루 쓰이는 예산을 아껴 필요한 \\곳에 투입해야 한다" (Wasted budgets should be reallocated to areas \\ in need through the reconstruction of public expenditure)} & Contextomized \\ \hline
\makecell[l]{"불필요한 모임 일절 자제"\\
(Avoid unnecessary gatherings \\ altogether)} & \makecell[l]{"저도 백신을 맞고 해서 여름에 어디 여행이라도 한번 갈 계획을\\ 했었는데..." (Since being vaccinated, I had planned to travel somewhere \\in the summer, but ...)\\"행사가 일단 다 취소됐고요..." (Events have been canceled...)\\"어떤 행위는 금지하고 어떤 행위는 허용한다는 개념이 아니라 \\불필요한 모임과 약속, 외출을 일제 자제하고…." (It is not a matter of \\prohibiting or permitting specific activities, but of avoiding unnecessary \\ gatherings, appointments, and going out altogether...)} & Modified \\\hline
\end{tabular}
\caption{Dataset examples in Korean and their English translations}
\label{tab:quote_main_examples}
\end{table*}
Some news outlets have been notorious for editorializing and sensationalizing their stories with contextomized quotes in news headlines ~\cite{han2013comparative}. The first example in Table~\ref{tab:quote_main_examples} illustrates contextomy. This example has a headline, "A government handing out money ... `A debt crisis, like Greece, is on the horizon'." The quoted sentence rephrased a financial expert saying in the body text, "If we do not maintain our fiscal health, we may end up like Greece." This is far from word-for-word replication. Instead, the headline reduced the expert's normative claim about government spending and fiscal distress to a blurb that blasted the national leadership, which was on the opposite side of the political spectrum. As such, a contextomized quote in a news headline can serve as an editorial slogan, misinforming public opinion.
\begin{figure}[t!]
\centering
\includegraphics[width=.65\linewidth]{fig/sample.PNG}
\caption{The central idea of QuoteCSE is based on journalism principles, where quotes from news headlines and body text should be matched. The proposed contrastive learning framework maximizes the semantic similarity between the headline quote and the matched quote in the body text while minimizing the similarity for other unmatched quotes in the same or other articles.}
\label{fig:intro}
\end{figure}
We propose a new problem of identifying contextomized quotes in news headlines. In contrast to a modified quote, which corrects grammar, replaces unheralded pronouns with proper names, removes unnecessary phrases, and substitutes synonyms, a \textbf{contextomized quote} refers to the excerpt of words with semantic changes from the original statement~\cite{mcglone2005quoted}.
Hence, the task is to classify whether a headline quote is semantically matched by comparing quotes in the news headline and body text.
To tackle the detection task, we propose using contrastive learning for quote representation, which trains a model to maximize the similarity of samples that are expected to be similar (known as \textit{positive} samples). Simultaneously, the model tries to reduce the similarity between samples that should be dissimilar (aka \textit{negative} samples). Following the recent research in contrastive sentence embedding~\cite{gao-etal-2021-simcse,chuang-etal-2022-diffcse}, we introduce a positive and negative sample selection strategy that is suited to the problem.
Our key idea is illustrated in Figure~\ref{fig:intro}. If a direct quotation appears in a news headline, there should be a quote with the same semantics in the body text. Furthermore, the title quote must be distinct from other quotes in the same article or from quotes in other (randomly chosen) news articles. Since quotes from the same article share common topics, it is more challenging to distinguish a headline quote from those in its body text than to understand semantic differences between quotes from distinct articles. Adopting the `hard' negatives in contrastive loss can help a model learn an effective representation, thereby capturing nuanced semantic differences between quotes. Evaluation experiments show its effectiveness at the target problem as well as its high quality in terms of theoretical measures, such as alignment and uniformity.
Our main contributions are three-fold:
\begin{enumerate}
\item Based on journalism research and principles, we present a new NLP problem of detecting contextualized quotes in news headlines.
\item We release a dataset for the detection problem based on a guideline constructed by annotators with journalism expertise. The label annotation by three workers achieved Krippendorff's alpha of 0.93.
\item We present QuoteCSE, a contrastive quote embedding framework that is designed based on journalism ethics. A QuoteCSE-based detection model outperformed existing methods, including SimCSE and fine-tuned BERT.
\end{enumerate}
\section{Related Work}
Following the recent success in computer vision~\cite{pmlr-v119-chen20j,He_2020_CVPR,NEURIPS2020_f3ada80d,Chen_2021_CVPR}, previous studies on contrastive sentence embedding focused on how to construct a positive pair by employing data augmentation methods to an anchor sentence~\cite{fang2020cert,giorgi-etal-2021-declutr,2020arXiv201215466W,yan-etal-2021-consert}.
A recent study showed that a simple dropout augmentation (unlike complex augmentations) with BERT to construct a positive pair could be an effective strategy known as SimCSE~\cite{gao-etal-2021-simcse}. Another study improved the performance by combining SimCSE with masked token detection~\cite{chuang-etal-2022-diffcse}. This study proposes a strategy for selecting positive and negative samples according to journalistic ethics.
\section{Problem and Data}
\paragraph{Research Problem}
Let a given news article be $X:(T, B)$, where $T$ is the news title, and $B$ is the body text. Our task is to predict a binary label $Y$ indicating whether the headline quote in $T$ is either contextomized (1) or modified (0) by referring to the body-text quotes. The detection target is news articles that use at least one direct quotation in the headline and body text.
\paragraph{News Data Collection}
We gathered a nationwide corpus of Korean news articles published through Naver, a popular news aggregator service. Direct quotes in news articles were identified via regular expression.
The dataset contains around 0.4 million news stories published until 2019.
\paragraph{Label Annotation}
Two journalism-major undergraduates were trained to manually label whether a direct quote in the headline is contextomized or modified. The \emph{contextomized} quote refers to the excerpt of words with semantic changes from the original statement. The \emph{modified} quote in a headline keeps the semantics of the original expression but is a different phrase or sentence. A faculty member in mass communication drafted annotation guidelines that stipulated the definitions of contextomized and modified quotations with multiple examples. The annotators reviewed the guidelines and labeled 70 (up to 200) news articles per training session. Inconsistent cases were discussed to reach a consensus. After the eighth iterative training practice over two weeks, the annotators achieved high inter-coder reliability (Krippendorff’s alpha = 0.93 for 200 articles). Then the annotators split the rest and labeled the news articles separately.
We randomly sampled 2,000 news articles for the manual annotation. We ignored cases where the body text includes an identical quote to the one in the headline because its detection can be achieved by a string-matching method without learning.
As a result, the final dataset comprises 814 contextomized and 786 modified samples, leaving a total N of 1,600. Table~\ref{tab:quote_main_examples} presents examples. We investigate contrastive embedding approaches to utilize the 381,206 news articles that remained unlabeled.
\section{Methods}
To predict the label $L$ of $X:(T, B)$, we utilize contrastive embedding and measure the semantic relationship between quotes in the headline and body text. We introduce the main framework.
\subsection{Background: SimCSE}
SimCSE~\cite{gao-etal-2021-simcse} is a contrastive learning method that updates a pretrained bidirectional transformer language model to represent the sentence embedding. Its loss function adapts InfoNCE~\cite{oord2018representation}, which considers identical text with a different dropout mask as a positive sample and the other text within the same batch as negative samples. Formally, the SimCSE loss of $i$-th text $x_i$ is
\vspace{-1mm}
\begin{equation}
\label{eq:simcse}
-\text{log} \frac{e^{\text{sim}(\mathbf{h}_i,\tilde{\mathbf{h}}_i)/\tau}}{\sum^{N}_{j=1}e^{\text{sim}(\mathbf{h}_i,\tilde{\mathbf{h}}_j)/\tau}},
\end{equation}
where $\mathbf{h}_i$ is $x_i$'s embedding\footnote{We applied a 2-layer MLP projection head to the hidden representation corresponding to the [CLS] token in the pretrained BERT.}, $\tilde{\mathbf{h}}_i$ is the embedding of positive sample, $\tau$ is temperature hyperparameter, $N$ is the batch size, and $\text{sim}(\cdot,\cdot)$ is the cosine similarity between embedding vectors.
\subsection{Proposed Method: QuoteCSE}
We propose \textbf{QuoteCSE}, a domain-driven contrastive embedding framework on news quotes. Its contribution is in defining positive and hard negatives according to journalism principles. This framework identifies positive and negative samples for a news headline quote according to the golden rules of journalism: When a direct quotation appears in a news headline, its body text should include a quote that is either identical or semantically similar to the headline quote. The latter form can be a good candidate for contrastive learning, where semantically identical yet lexically different quotes serve as `positive' samples. The other quotes in the body text represent different semantics yet cover the same topic, serving as \textit{hard negative} samples.
We define the QuoteCSE loss of $i$-th sample $X^{(i)}:(T^{(i)},B^{(i)})$ as
\vspace{-1mm}
\begin{equation}
\label{eq:quotecse}
-\text{log} \frac{e^{\text{sim}(\mathbf{h}_i,\mathbf{h}^+_i)/\tau}}{\sum^{N}_{j=1}\{e^{\text{sim}(\mathbf{h}_i,\mathbf{h}_j^+)/\tau}+e^{\text{sim}(\mathbf{h}_i,\mathbf{h}_j^-)/\tau}\}},
\end{equation}
where $\mathbf{h}_i$ is embedding of headline quote for $i$-th sample. $\mathbf{h}^+_i$ and $\mathbf{h}^-_i$ are embedding of positive and negative quotes in the same body text $B^{(i)}$. $\mathbf{h}^+_j$ and $\mathbf{h}^-_j$ are embeddings of $X^{(j)}$, other news articles in the same batch ($i\neq j$), which are negative samples.
We applied SentenceBERT (SBERT)~\cite{reimers-gurevych-2019-sentence} to make initial assignments on positive (i.e., semantically identical) and negative (i.e., dissimilar) samples among quotes in the body text. A quote is deemed positive if it appears the most similar to the quote in the news headline. After excluding the positive sample, one quote from the body text was chosen randomly as the negative sample. We removed news articles where the cosine similarity between the anchor and the positive sample is below 0.75 because the news headline quote might be contextomized. Additionally, news articles that did not contain at least two quotes in the body text were eliminated. The remaining 86,275 articles were divided into 69,020, 8,627, and 8,628 for training, validation, and testing of contrastive learning methods.
We compared QuoteCSE with three baseline embedding methods, (i) \textsf{BERT}~\cite{devlin-etal-2019-bert}\footnote{huggingface.co/monologg/kobert}, (ii) \textsf{SBERT}\footnote{huggingface.co/jhgan/ko-sbert-sts}, and (iii) SimCSE. For BERT and SBERT, we used the model checkpoint that was pretrained on a Korean corpus. For SimCSE, we tested two versions. The first version is to train BERT on our news corpus by minimizing Eq.~\ref{eq:simcse} on headline quotes~(\textsf{SimCSE-Quote}). The second version is a publicly available SimCSE embedding pretrained on a corpus on natural language inference in Korean (\textsf{SimCSE-NLI})\footnote{github.com/BM-K/KoSimCSE-SKT}. For QuoteCSE and SimCSE-Quote, we used SBERT for the initial assignments of positive and negative samples. The assignments iteratively get updated for every training step using the target embedding being trained (e.g., QuoteCSE). QuoteCSE and SimCSE-Quote were trained on the 69,020 sizes of the unlabeled corpus with a batch size of 16, which is the upper limit under the computing environment.
\begin{table}[t]
\centering
\resizebox{.9\linewidth}{!}{%
\begin{tabular}{lcc}
\toprule
& F1 & AUC \\ \midrule
BERT & 0.665$\pm$0.007 & 0.662$\pm$0.006 \\
SBERT & 0.44$\pm$0.083 & 0.591$\pm$0.020 \\
SimCSE-Quote & 0.69$\pm$0.009 & 0.686$\pm$0.009 \\
SimCSE-NLI & 0.617$\pm$0.008 & 0.623$\pm$0.008 \\\midrule
BERT fine-tune & \textbf{0.754}$\pm$0.006 &\textbf{0.749}$\pm$0.006 \\
QuoteCSE &\textbf{0.77}$\pm$0.007 & \textbf{0.768}$\pm$0.008 \\\bottomrule
\end{tabular}
}
\caption{Performance comparison with baselines.}
\label{tab:evaluation}
\end{table}
To assess the role of contrastive learning,
we implemented a binary MLP classifier with a 64-dimensional hidden layer, following an embedding evaluation framework~\cite{conneau-kiela-2018-senteval}. The model takes $\mathbf{u}$, $\mathbf{v}$, $|\mathbf{u}-\mathbf{v}|$, and $\mathbf{u}*\mathbf{v}$ as input, where $\mathbf{u}$ and $\mathbf{v}$ are the embeddings of a news headline quote and the body-text quote most similar to the $\mathbf{u}$, respectively. In deciding $\mathbf{v}$, cosine similarity is used along with the target embedding. The classifier predicts whether the headline quote is contextomized based on a vector relationship between $\mathbf{u}$ and $\mathbf{v}$.
For evaluation, we report the mean F1 and AUC scores by repeating the split process 15 times on the labeled dataset with a ratio of 8:2. As a strong baseline, we also tested a fine-tuned BERT classifier (\textsf{BERT fine-tune}) that takes '[CLS] $q_t$ [SEP] $q_{b,1}, \cdots, q_{b,N_{b}}$ [SEP]' where $q_t$ is the headline quote, $q_{b,i}$ is the $i$-th quote in the body text, and $N_b$ is the number of body-text quotes. Details of the model configuration and computing environment are in Section~\ref{sec:computing}.
\section{Evaluation Results}
Table~\ref{tab:evaluation} presents the evaluation results for the contextomized quote detection. We report the average performance along with standard errors by repeating the experiments using each different random seed. QuoteCSE obtained an F1 of 0.77 and an AUC of 0.76, outperforming the fine-tuned BERT and other contrastive learning methods. Among the baseline models, the fine-tuned BERT model achieved the best F1 of 0.754, which is significantly higher than the performance of the standard contrastive learning methods. The results point to the effectiveness of journalism-driven contrastive quote embedding for the detection problem.
\begin{table}[t]
\centering
\resizebox{.95\linewidth}{!}{%
\begin{tabular}{cccc}
\toprule
Positive & Hard Negative & F1 & AUC \\ \midrule
QuoteCSE & QuoteCSE &\textbf{0.77}$\pm$0.007 & \textbf{0.768}$\pm$0.008 \\\midrule
SimCSE & QuoteCSE & 0.7$\pm$0.005 & 0.69$\pm$0.004 \\
QuoteCSE & \makecell{$-$} & 0.674$\pm$0.006 & 0.673$\pm$0.006 \\\bottomrule
\end{tabular}
}
\caption{Ablation results confirm the role of both positive and negative samples in the model.}
\label{tab:ablation}
\end{table}
\paragraph{Ablation experiment}
We examined the importance of positive and negative samples in the QuoteCSE framework by removing each component. The first model is to replace QuoteCSE's positive sample with that of SimCSE, which is an embedding of the anchor text with a different dropout mask. The second model is to ignore the hard negative sample from QuoteCSE. It only differs from SimCSE in the selection of the positive sample. We trained two contrastive embeddings using the 69,020-size unlabeled corpus. Table~\ref{tab:ablation} presents the results. The detection performance of QuoteCSE was reduced significantly by the ablation of the positive and negative samples. The hard negative sample turned out to be more critical to the detection performance, as F1 of the corresponding model decreased by 0.096. The results confirm the necessity of both positive and negative samples in the QuoteCSE framework.
\begin{table}[t]
\centering
\resizebox{.95\linewidth}{!}{%
\begin{tabular}{lccc}
\toprule
& \makecell{Alignment\\(title-title)} & \makecell{Alignment\\(title-body)} & Uniformity \\ \midrule
BERT & 0.638 &0.738 &-0.711 \\
SBERT & \textbf{0.227} &0.329 &-1.356 \\
SimCSE-Quote & 0.503 & 0.38 &-2.176 \\
SimCSE-NLI &0.319 & \textbf{0.26} & \textbf{-3.257} \\ \midrule
QuoteCSE
& \textbf{0.15} &\textbf{0.194} &\textbf{-3.562} \\ \bottomrule
\end{tabular}
}
\caption{Results of alignment (i.e., closeness of positive samples) and uniformity (i.e., even distribution) scores
}
\label{tab:alignment}
\end{table}
\paragraph{Embedding quality}
We employed two metrics to evaluate the quality of contrastive sentence embeddings~\cite{pmlr-v119-wang20k}. The first is \textit{alignment}, which measures how closely positive pairs are located in the embedding space. The next is \textit{uniformity}, which measures how evenly distributed the target data is. A smaller value denotes a higher embedding quality for both metrics, and their formal definitions are given in Section~\ref{app:alignment_uniformity}. We examined two alignments: (i) between two embeddings from the same headline quote with a different dropout mask (title-title) and (ii) between a headline quote and a positive quote in the body text (title-body).
We measured the three metrics on the test split of unlabeled data. Table~\ref{tab:alignment} shows that QuoteCSE achieves the best result for all types of theoretical measures, implying a high embedding quality.
\paragraph{Error analysis}
\label{app:false-positive}
We identified a common pattern of false positives where a model deems a quote contextomized, which turned out to be modified. They corresponded to instances in which a quote in the headline represents a claim that combines multiple quotes in the body text. For example, in a news article, a headline quote was ``감옥 같은 생활... 음식 엉망 (Prison-like conditions... Poor food)'' which could be referred to multiple quotes in the body text ``삿포로 생활은 감옥처럼 느껴진다 (Living in Sapporo feels like being in prison)'' and ``음식도 엉망이다 (food is poor).'' Since the current detection framework compares a headline quote and another quote in the body text, it could not detect the corner case of a modified quote. Future studies could investigate an approach that considers multiple quotes in the body text.
\section{Conclusion}
Inspired by the importance of direct quotations in news reporting and their widespread misuse, this study proposed a new NLP problem of detecting contextomized news quotes. While there had been studies on quote identification~\cite{Pavllo_Piccardi_West_2018} and speaker attribution~\cite{10.1145/3437963.3441760}, this study is the first to discern a specific type of headline news quote that distorts the speaker's intention and is cut out of context. Not only does it violate journalism ethics~\cite{newsreportingwriting,nylund2003quoting}, but it can also mislead public opinion~\cite{mcglone2005quoted}. Therefore, tackling the problem of detecting contextomized quotes in news headlines can significantly aid the existing efforts to nurture healthy media environments using NLP techniques~\cite{oshikawa-etal-2020-survey}.
Understanding the subtle semantic differences between quotes from news headlines and those from body text is a prerequisite for detecting contextomized news quotes. To assist with this, we introduce QuoteCSE, a contrastive learning framework for quote representation. We specifically tailored SimCSE~\cite{gao-etal-2021-simcse} to the detection of the editorial slogan by proposing a positive and negative sample selection strategy consistent with journalism ethics. In the evaluation experiments, we confirmed the effectiveness of both positive and hard negative samples in the journalism-driven contrastive learning framework. Altogether, the findings imply the crucial role of domain knowledge in tackling computational social science problems.
\section*{Limitations and Future Directions}
First, since this study was done on a monolingual corpus in Korean, the generalizability of the method to other languages is unknown. Future research could replicate this study in other languages to test its broad applicability. Second, the contrastive learning techniques were only tested to a batch size of 16 due to the particular computing environment. To address this limitation, we also tested MoCo-based methods that mitigate the memory limitation~\cite{chen2020mocov2}; however, the results were unsatisfactory (Section~\ref{app:moco}). The effect of large batch sizes might be examined in future studies. Third, there may be corner cases that the current detection framework is unable to handle. Even if a direct quotation in the headline is schematically consistent with a quote in the body text, this by no means guarantees the authenticity of the quoted remark. It could have been made up by the speaker in the first place. Accordingly, future research warrants considering labels on veracity in conjunction with labels on whether they are contextomized or modified.
\section*{Ethics and Impact Statement}
Despite the limited headline space, journalism textbooks underscore that direct quotations should meet the strict verbatim criterion~\cite{brooks2001art,newsreportingwriting,cappon1982associated}. This verbatim rule renders news stories with direct quotations more credible and factual. The aforementioned instances of contextomized quotes, however, violate this public trust in journalism. We thus propose a new NLP problem of detecting contextomized quotes and aim to better contribute to the development of responsible media ecosystems. This study is an example of how social science theories can be incorporated with NLP techniques. Thus it will have a broader impact on future studies in NLP and computational social science.
We used public news dataset published through a major web portal in South Korea. Our data is considered clean regarding misinformation because the platform implements a strong standard in deciding which news outlets to admit. However, the considered news data is not free from media bias, and the learned embedding may learn such political bias. Therefore, users should be cautious about applying the embedding to problems in a more general context. We have fewer privacy concerns because our study used openly accessible news data following journalistic standards.
{
\section*{Acknowledgement}
K. Park and J. Han are the corresponding authors. This research was supported by the National Research Foundation of Korea (2021R1F1A1062691), the Institute of Information \& Communications Technology Planning \& Evaluation (IITP-2023-RS-2022-00156360, 2019-0-00075: Artificial Intelligence Graduate School Program (KAIST)), and the Institute for Basic Science (IBS-R029-C2). We are grateful to Seung Eon Lee for putting together the dataset and to the reviewers for their detailed comments that helped improve the paper.
}
| {'timestamp': '2023-02-10T02:07:34', 'yymm': '2302', 'arxiv_id': '2302.04465', 'language': 'en', 'url': 'https://arxiv.org/abs/2302.04465'} | arxiv |
Subsets and Splits